mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-04 12:50:37 +01:00
Merge master connection cleanup and model catalog updates
This commit is contained in:
commit
774ca63cca
4 files changed
+36
-5
No files matched your search
@@ -50,6 +50,7 @@ export const models = [
|
||||
{ id: "claude-opus-4-8", label: "Claude Opus 4.8" },
|
||||
{ id: "claude-opus-4-7", label: "Claude Opus 4.7" },
|
||||
{ id: "claude-opus-4-6", label: "Claude Opus 4.6" },
|
||||
{ id: "claude-opus-4-5", label: "Claude Opus 4.5" },
|
||||
{ id: "claude-sonnet-5", label: "Claude Sonnet 5" },
|
||||
{ id: "claude-sonnet-4-6", label: "Claude Sonnet 4.6" },
|
||||
{ id: "claude-sonnet-4-5", label: "Claude Sonnet 4.5" },
|
||||
|
||||
@@ -67,6 +67,7 @@ describe("adapter model listing", () => {
|
||||
// Newest release of the most capable family leads the list (#14877).
|
||||
expect(models[0]?.id).toBe("claude-fable-5-1");
|
||||
expect(models.some((model) => model.id === "claude-sonnet-5")).toBe(true);
|
||||
expect(models.some((model) => model.id === "claude-opus-4-5")).toBe(true);
|
||||
expect(models.some((model) => model.id === "claude-fable-5-1")).toBe(true);
|
||||
expect(models.some((model) => model.id === "claude-fable-5")).toBe(true);
|
||||
expect(models.some((model) => model.id === "claude-mythos-5")).toBe(true);
|
||||
|
||||
@@ -434,6 +434,31 @@ describePostgres("already available connection requests", () => {
|
||||
expect(wakeup).toHaveBeenCalledWith(f.agentId, expect.objectContaining({ requestedByActorType: "system", idempotencyKey: `connection-intent:${f.intent.id}:expired`, contextSnapshot: expect.objectContaining({ refreshTools: true, responsibleUserId: "connection-owner" }) }));
|
||||
});
|
||||
|
||||
it.each(["blocked", "todo", "backlog"] as const)("retires a satisfied card on a %s task without waking its agent", async (status) => {
|
||||
const f = await seed(); const wakeup = vi.fn().mockResolvedValue(null);
|
||||
await db.update(issues).set({ status }).where(eq(issues.id, f.issueId));
|
||||
const worker = connectionIntentDeliveryService(db, { wakeup });
|
||||
await worker.sweepPending();
|
||||
expect((await db.select().from(issueThreadInteractions))[0]).toMatchObject({ status: "expired", resolvedByUserId: null,
|
||||
result: { outcome: "expired", connectionId: f.connection.id } });
|
||||
expect(await db.select().from(connectionIntentDeliveries)).toHaveLength(0);
|
||||
expect(wakeup).not.toHaveBeenCalled();
|
||||
expect((await db.select().from(issues))[0].status).toBe(status);
|
||||
expect(await db.select().from(activityLog)).toEqual([expect.objectContaining({ actorType: "system", action: "issue.thread_interaction_resolved" })]);
|
||||
expect(await worker.hasPending()).toBe(false);
|
||||
});
|
||||
|
||||
it("keeps a blocked task's card pending until its connection is usable", async () => {
|
||||
const f = await seed();
|
||||
await db.update(issues).set({ status: "blocked" }).where(eq(issues.id, f.issueId));
|
||||
await db.update(connectionGrants).set({ status: "revoked" });
|
||||
expect(await satisfiedConnectionIntentService(db).sweepPending()).toMatchObject({ satisfied: 0 });
|
||||
expect((await db.select().from(issueThreadInteractions))[0].status).toBe("pending");
|
||||
await db.update(connectionGrants).set({ status: "active" });
|
||||
expect(await satisfiedConnectionIntentService(db).sweepPending()).toMatchObject({ satisfied: 1 });
|
||||
expect(await db.select().from(connectionIntentDeliveries)).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("rechecks access after a restart before it delivers the saved continuation", async () => {
|
||||
const f = await seed();
|
||||
await satisfiedConnectionIntentService(db).sweepPending();
|
||||
|
||||
@@ -3,7 +3,7 @@ import { notifyChatConfirmationResolution } from "./chat-confirmation-notificati
|
||||
import { enqueueTerminalIssueInteractionChatPublications } from "./chat-interaction-publications.js";
|
||||
import { connectionManagementService } from "./connection-management.js";
|
||||
import { chatCredentialEntryGenerations } from "./chat-channels/credentials.js";
|
||||
import { and, asc, eq, gt, inArray, isNull, or } from "drizzle-orm";
|
||||
import { and, asc, eq, gt, inArray, isNull, notInArray, or } from "drizzle-orm";
|
||||
import { approvals, chatEndpoints, chatExternalPrincipals, chatIdentityLinks, toolConnections, companyMemberships, connectionIntentDeliveries, issueApprovals, issueThreadInteractions, issues, type Db } from "@paperclipai/db";
|
||||
import { connectionIntentPayloadSchema } from "@paperclipai/shared";
|
||||
import { logActivity, publishActivity, type ActivityPublication } from "./activity-log.js";
|
||||
@@ -128,7 +128,7 @@ export function satisfiedConnectionIntentService(db: Db) {
|
||||
.from(issueThreadInteractions).innerJoin(issues, and(
|
||||
eq(issues.id, issueThreadInteractions.issueId), eq(issues.companyId, issueThreadInteractions.companyId),
|
||||
)).where(and(eq(issueThreadInteractions.kind, "connection_intent"), eq(issueThreadInteractions.status, "pending"),
|
||||
inArray(issues.status, ["in_progress", "in_review"]), isNull(issues.assigneeUserId),
|
||||
notInArray(issues.status, ["done", "cancelled"]), isNull(issues.assigneeUserId),
|
||||
...(afterId ? [gt(issueThreadInteractions.id, afterId)] : [])))
|
||||
.orderBy(asc(issueThreadInteractions.id)).limit(50);
|
||||
// Rotate past unavailable cards so they cannot starve a later ready one.
|
||||
@@ -154,7 +154,9 @@ export function satisfiedConnectionIntentService(db: Db) {
|
||||
eq(companyMemberships.principalId, intent.addresseeUserId),
|
||||
)).for("share");
|
||||
}
|
||||
const connection = await findSatisfiedToolConnection(txDb, task, intent);
|
||||
const continues = ["in_progress", "in_review"].includes(task.status);
|
||||
const connection = continues ? await findSatisfiedToolConnection(txDb, task, intent)
|
||||
: ["done", "cancelled"].includes(task.status) ? null : await findAvailableToolConnection(txDb, task, intent);
|
||||
if (!connection) return false;
|
||||
await notifyIssueReviewState(tx, candidate);
|
||||
const now = new Date();
|
||||
@@ -169,8 +171,10 @@ export function satisfiedConnectionIntentService(db: Db) {
|
||||
const interaction = await issueThreadInteractionService(txDb).getById(retired.id);
|
||||
if (interaction) await enqueueTerminalIssueInteractionChatPublications(txDb, interaction);
|
||||
await tx.update(issues).set({ updatedAt: now }).where(and(eq(issues.id, task.id), eq(issues.companyId, task.companyId)));
|
||||
await tx.insert(connectionIntentDeliveries).values({ interactionId: intent.id, companyId: task.companyId }).onConflictDoNothing();
|
||||
await notifyDeliveryWork(tx, DELIVERY_QUEUES.connection);
|
||||
if (continues) {
|
||||
await tx.insert(connectionIntentDeliveries).values({ interactionId: intent.id, companyId: task.companyId }).onConflictDoNothing();
|
||||
await notifyDeliveryWork(tx, DELIVERY_QUEUES.connection);
|
||||
}
|
||||
await logActivity(txDb, { companyId: task.companyId, actorType: "system", actorId: "connection-reconciliation",
|
||||
action: "issue.thread_interaction_resolved", entityType: "issue", entityId: task.id,
|
||||
details: { interactionId: intent.id, interactionKind: "connection_intent", status: "expired",
|
||||
|
||||
Reference in new issue
Block a user