Merge qualified backup expiration parent into GitHub connection work

Co-Authored-By: Paperclip <noreply@paperclip.ing>

* commit 'aae32f2f493848199f6cb8c0a9996af3ee0061b1': (30 commits)
  Scope status-card refresh tasks to their claim revision
  test(chat): retain completion identity before link metadata loads
  test(chat): locate completion through its rendered task link
  fix(chat): recover committed native Agent Chat replies (#18465)
  perf(heartbeat): drive retry promotion from durable deadlines (#18387)
  fix(ui): make the Coordinator composer footer opaque (#18455)
  fix(testops): verify unexpanded result job runs (#18462)
  test(server): observe restored Retry before draining unrelated work
  test(runner): own listener cleanup across setup failures
  test(runner): buffer upgrade frames until the wire subscribes
  fix(runner): preserve OpenCode written-answer defaults (#18456)
  fix(native): fence retries when replaying an audited Stop (#18457)
  test: await async outcomes and drive saved deadlines deterministically (#18416)
  fix(ui): retain startup autosave through session recovery (#18412)
  perf(server): recover independent native replies concurrently (#18421)
  perf(chat): scope task questions and batch inbox queue checks (#18422)
  fix(native): recover controllers across webserver replacement (#18343)
  fix(ui): restore task document authoring and add persistence journey (#18356)
  fix(tools): stabilize tied profile entry order (#18427)
  fix(adapter-utils): tolerate entries removed during workspace snapshots (#18426)
  ...
This commit is contained in:
DottaandPaperclip committed 2026-10-31 09:41:51 -05:00
commit f522ab07e2
484 files changed
+33834 -1620

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
import { Router } from "express";
import type { Db } from "@paperclipai/db";
import { forbidden } from "../errors.js";
import { sendAgentChatMessage } from "../services/agent-chat-messages.js";
import { assertCompanyAccess } from "./authz.js";
export function agentChatMessageRoutes(db: Db) {
const router = Router();
router.post("/agents/me/chat/messages", async (req, res) => {
if (req.actor.type !== "agent" || !req.actor.agentId || !req.actor.companyId || !req.actor.runId) {
throw forbidden("An authenticated task run is required");
}
assertCompanyAccess(req, req.actor.companyId);
const receipt = await sendAgentChatMessage(db, {
companyId: req.actor.companyId, agentId: req.actor.agentId, runId: req.actor.runId, agentApiKeyId: req.actor.keyId,
keyScope: req.actor.keyScope, onBehalfOfUserId: req.actor.onBehalfOfUserId,
authorizingUserId: req.actor.authorizingUserId, source: req.actor.source,
}, req.body);
res.status(receipt!.replayed ? 200 : 201).json(receipt);
});
return router;
}
+14 -5
View File
@@ -41,7 +41,7 @@ import { toolConnections } from "@paperclipai/db";
import { aiConnectionService } from "../services/ai-connections.js";
import { probeCopilotConnection, probeCopilotExecutionTarget } from "../services/copilot-connection-probe.js";
import { antigravityConnectionModels } from "../services/antigravity-connection-models.js";
import { resolveAntigravityCandidateAdmission } from "../services/native-runtime/acpx-qualification.js";
import { resolveAntigravityCandidateAdmission, resolveKimiCandidateAdmission } from "../services/native-runtime/acpx-qualification.js";
import { defaultAiConnectionForHire } from "../services/agent-ai-connection-default.js";
import { assertAiConnectionCreateAccess, canInstallSharedAiConnectionForNewAgent, responsibleUserForAiRequest } from "./ai-connections.js";
import { isAiConnectionCompatible } from "@paperclipai/shared";
@@ -1874,6 +1874,11 @@ export function agentRoutes(
try { antigravityCandidate = resolveAntigravityCandidateAdmission({ companyId, model: selected.model }); }
catch { throw unprocessable("This Google Antigravity candidate requires the exact enabled model and a current operator authorization.", { code: "paperclip_runner_antigravity_candidate_invalid" }); }
}
let kimiCandidate: ReturnType<typeof resolveKimiCandidateAdmission>;
if (companyId && selected?.provider === "acpx" && selected.acpxAgent === "kimi" && typeof selected.model === "string") {
try { kimiCandidate = resolveKimiCandidateAdmission({ companyId, model: selected.model }); }
catch { throw unprocessable("This Kimi candidate requires the exact enabled model and a current operator authorization.", { code: "paperclip_runner_kimi_candidate_invalid" }); }
}
if (asRecord(config)?.provider === "openai_dot") {
if (experimental.enableOpenAiDot !== true) throw unprocessable(
"OpenAI Dot is experimental and disabled on this instance.",
@@ -1886,7 +1891,7 @@ export function agentRoutes(
} else if (!([undefined, "codex", "opencode"].includes(asRecord(config)?.provider as string | undefined)) &&
!(asRecord(config)?.provider === "acpx" && asRecord(config)?.acpxAgent === "copilot") &&
!["claude_local", "pi_local", "grok_local"].includes(agentHarnessType("paperclip_runner", asRecord(config) ?? {})) &&
experimental.enableNativeRunner !== true && !antigravityCandidate) {
experimental.enableNativeRunner !== true && !antigravityCandidate && !kimiCandidate) {
throw unprocessable(
"Paperclip Runner is experimental and disabled on this instance.",
{ code: "paperclip_runner_rollout_disabled" },
@@ -1961,9 +1966,9 @@ export function agentRoutes(
throw unprocessable("Select a Paperclip Runner provider before converting this agent.");
}
const next = { ...defaults, ...input.nextAdapterConfig };
if (next.provider === "acpx" && next.acpxAgent === "pi") {
if (next.provider === "acpx" && (next.acpxAgent === "pi" || next.acpxAgent === "kimi")) {
next.model = input.nextAdapterConfig.model
?? (input.previousAdapterType === "pi_local" ? input.previousAdapterConfig.model : "");
?? (input.previousAdapterType === `${next.acpxAgent}_local` ? input.previousAdapterConfig.model : "");
} else if (!asNonEmptyString(next.model)) next.model = defaults.model;
return normalizeLegacyRunnerProvider(next);
}
@@ -2200,7 +2205,7 @@ export function agentRoutes(
);
const incompleteModelSetup = input.setupOnly && input.adapterType === "paperclip_runner"
&& (normalizedAdapterConfig.provider === "opencode"
|| (normalizedAdapterConfig.provider === "acpx" && normalizedAdapterConfig.acpxAgent === "pi"))
|| (normalizedAdapterConfig.provider === "acpx" && ["pi", "kimi"].includes(String(normalizedAdapterConfig.acpxAgent))))
&& (normalizedAdapterConfig.model === undefined || normalizedAdapterConfig.model === "");
// Inactive drafts can precede model selection. Test/hire always validate the complete profile.
if (!incompleteModelSetup) await assertAdapterConfigConstraints(
@@ -3076,6 +3081,10 @@ export function agentRoutes(
return;
}
const provider = asNonEmptyString(req.query.provider);
if (type === "paperclip_runner" && provider === "acpx" && req.query.acpxAgent === "kimi") {
res.json([]);
return;
}
if (type === "paperclip_runner" && provider === "acpx" && req.query.acpxAgent === "antigravity") {
if (environment && environment.driver !== "local") throw unprocessable("Google Antigravity account model discovery requires the Paperclip host.");
let binding: AiConnectionBinding = { provider: "google", method: "subscription", mode: "responsible_user" };
+20 -4
View File
@@ -11,6 +11,8 @@ import { issueSummariesQuerySchema, type IssueSummary } from "@paperclipai/share
import { listIssueSummaries } from "../services/issue-summaries.js";
import { assertNoCaseHandoffMutation } from "../services/heartbeat/case-handoff-lifecycle.js";
import { assertLegacyRunTaskOwnership } from "../legacy-run-task-ownership.js";
import { withConversationReadState } from "../services/agent-chat-read-state.js";
import { markIssueReadSchema } from "@paperclipai/shared";
import { enqueueFastResponse } from "../services/fast-responses.js";
import { hasRequiredWorkspaceRecovery, LEGACY_WORKSPACE_RECOVERY_SCHEMA } from "../services/workspace-restore-recovery-state.js";
import { hasUnverifiedNativeWorkspaceFinalizationOwner } from "../services/native-runtime/native-workspace-finalization-recovery-state.js";
@@ -12107,11 +12109,22 @@ export function issueRoutes(
res.status(403).json({ error: "Board user context required" });
return;
}
const input = markIssueReadSchema.parse(req.body ?? {});
let readAt: Date | SQL = new Date();
if (input.throughCommentId) {
if (!issue.conversationAgentId || issue.conversationUserId !== req.actor.userId) throw forbidden("Only the chat owner can mark a conversation message read");
const [comment] = await db.select({ createdAt: sql<string>`${issueComments.createdAt}::text` }).from(issueComments).where(and(
eq(issueComments.id, input.throughCommentId), eq(issueComments.companyId, issue.companyId), eq(issueComments.issueId, issue.id),
isNull(issueComments.deletedAt),
));
if (!comment) throw notFound("Chat message not found");
readAt = sql`${comment.createdAt}::timestamptz`;
}
const readState = await svc.markRead(
issue.companyId,
issue.id,
req.actor.userId,
new Date(),
readAt,
);
const actor = getActorInfo(req);
await logActivity(db, {
@@ -18546,7 +18559,7 @@ export function issueRoutes(
if (req.actor.type !== "board" || !req.actor.userId) throw forbidden("Board user access required");
if (!(await instanceSettings.getExperimental()).enableAgentChat) throw notFound("Agent Chat is disabled");
const conversations = await svc.listConversations(companyId, req.actor.userId);
res.json(await filterIssuesForActor(req, conversations));
res.json(await withConversationReadState(db, companyId, req.actor.userId, await filterIssuesForActor(req, conversations)));
});
// GET stays read-only. POST resolves the single chat on explicit add or first send/upload.
@@ -18562,7 +18575,10 @@ export function issueRoutes(
const agent = resolved.agent;
const existing = await svc.getConversation(companyId, agent.id, req.actor.userId);
if (existing && !(await assertIssueReadAllowed(req, res, existing))) return;
if (existing || method === "get") { res.json(existing); return; }
if (existing || method === "get") {
res.json(existing ? (await withConversationReadState(db, companyId, req.actor.userId, [existing]))[0] : null);
return;
}
const issue = await svc.create(companyId, {
title: `Chat with ${agent.name}`, assigneeAgentId: agent.id,
conversationAgentId: agent.id, conversationUserId: req.actor.userId,
@@ -18571,7 +18587,7 @@ export function issueRoutes(
await logActivity(db, { companyId, actorType: "user", actorId: req.actor.userId,
action: "issue.conversation_opened", entityType: "issue", entityId: issue.id,
details: { agentId: agent.id } });
res.json(issue);
res.json((await withConversationReadState(db, companyId, req.actor.userId, [issue]))[0]);
});
}
+13 -1
View File
@@ -38,6 +38,8 @@ import {
slackSearchConfigSchema,
// Agent
submitAgentCommentarySchema,
sendChatMessageSchema,
markIssueReadSchema,
agentCommentaryQuerySchema,
AGENT_PALETTE_IDS,
AGENT_AVATAR_SIZES,
@@ -1670,6 +1672,7 @@ function resolveOperationAuthLevel(
|| /^\/api\/companies\/\{companyId\}\/agents\/\{agentId\}\/grok-binding(?:\/(?:routine|verify|retry|stop|recover))?$/.test(path)) return "board";
if (PUBLIC_OPERATIONS.has(key)) return "public";
if (key === "POST /api/companies/{companyId}/agent-commentary") return "agent_heartbeat";
if (key === "POST /api/agents/me/chat/messages") return "agent_heartbeat";
if (method.toUpperCase() === "GET" && path.startsWith("/api/companies/{companyId}/agent-commentary")) return "board";
if (key === "POST /api/mcp/project-tools" || key === "POST /api/companies/{companyId}/slack/tasks/{issueId}/tools") return "agent_run";
if (RUNTIME_TOOLS_OPERATIONS.has(key)) return "runtime_tools";
@@ -4736,7 +4739,7 @@ registry.registerPath({
path: "/api/issues/{id}/read",
tags: ["issues"],
summary: "Mark an issue as read",
request: { params: z.object({ id: z.string() }) },
request: { params: z.object({ id: z.string() }), body: { ...jsonBody(markIssueReadSchema), required: false } },
responses: { 200: r.ok(), 401: r.unauthorized },
});
@@ -5760,6 +5763,15 @@ registry.registerPath({
responses: { 200: r.ok(), 401: r.unauthorized, 403: r.forbidden, 404: r.notFound },
});
registry.registerPath({
method: "post", path: "/api/agents/me/chat/messages", tags: ["agents"],
summary: "Send a task message to the agent's own chat",
description: "Requires the assigned agent's active standard task run, standard credentials and an active responsible human. Resolves or creates that agent's conversation automatically. Company visibility, task permissions, Stop and the shared cross-issue run cap apply. Equivalent retries do not spend another slot. Does not wake the chat agent or change task status.",
request: { body: jsonBody(sendChatMessageSchema) },
responses: { 200: r.ok(), 201: { ...r.ok(), description: "Message saved" }, 400: r.badRequest,
401: r.unauthorized, 403: r.forbidden, 404: r.notFound, 409: r.conflict, 429: r.tooManyRequests },
});
const agentCommentaryAcknowledgementSchema = z.object({
id: z.string().uuid(),
kind: z.enum(["complaint", "suggestion"]),