mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-01 09:39:53 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - External agents keep their own tools and app connections. > - The Paperclip assignment catalog controls the Paperclip bridge. > - Dot treated a qualification test restriction as a rule for later work. > - Existing prompts did not clearly separate these two tool sources. > - This pull request tells agents to use their own capabilities and return results to Paperclip. > - The benefit is that a missing Paperclip app does not block an available native capability. ## Linked Issues or Issue Description Related work: #15722 and #15691. I searched open PRs for Dot tool guidance and found no duplicate. **What happened?** After a qualification test, Dot refused a Slack request because the test Paperclip agent had no assigned Slack app. Dot already had a working Slack connection in ChatGPT. It carried the test's plugin restriction into a later task message. **Expected behavior** An external agent uses its own available tools, apps, plugins, skills, and capabilities to complete the current request. It then returns the result through Paperclip's task reporting and completion tools. The assignment catalog limits Paperclip calls. It does not disable the agent's native tools. **Steps to reproduce** 1. Connect a Dot that has a native Slack connection. 2. Complete a Paperclip qualification task with a restriction scoped to that test. 3. Send a later task message that requires Slack. 4. Observe that Dot can mistake the Paperclip catalog for its full tool inventory. **Deployment mode** Observed on Cloud staging with the Dot Runner. ## What Changed - Add shared tool-use guidance for external-agent onboarding and Dot setup. - Include it in the server onboarding document, pairing response, event instructions, and capability response. - Clarify the tool descriptions on both Dot bridge paths. - Include the same guidance in each Dot Runner assignment without adding a shared-package dependency to the standalone Runner. - Document native tool use and the scope of test restrictions. ## Verification - The 49 relevant onboarding, Dot invitation, and Runner context tests passed. The final UI run passed 29 tests. The updated plain-text renderer run passed all 4 tests. - Full workspace typecheck, full workspace build, and design token gates passed. All current-head CI gates passed, including full tests, Runner verification, and browser E2E. Greptile is 5/5 on the exact final commit, and the one review finding is resolved. - The real Dot received the standing correction and confirmed that it will use its relevant tools and connections, return results through Paperclip, and stop carrying the test restriction forward. - Extended the existing plain-text renderer test to check native Slack access, qualification-test scope, and the Paperclip denial boundary. This covers agents that receive only the onboarding.txt URL. - The full Vitest suite passed in CI. The earlier local Cloud qualification run encountered failures in unchanged suites; this follow-up uses focused local tests for the instruction changes. ## Risks This changes instructions, not access checks. Native tools retain their own permissions and approval requirements. Paperclip operations remain scoped to the authorized company, agent, and task. Agents must not use another connection or identity to bypass a denial. There is no database migration or new permission grant. ## Model Used OpenAI GPT-6 through Codex. Used reasoning, repository tools, and browser control. The runtime does not expose a more specific model ID or context window size. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing>
83 lines
6.5 KiB
TypeScript
83 lines
6.5 KiB
TypeScript
import { z } from "zod";
|
|
import type { DotHarnessDriver } from "../../vendor/paperclip-runner/index.js";
|
|
import type { McpPrincipal } from "./oauth.js";
|
|
|
|
// Structural boundary works for a source-loaded lab and the built runner alike;
|
|
// the server does not depend on the driver's private implementation fields.
|
|
type DotBridgeDriver = Pick<DotHarnessDriver, "identity" | "inbox" | "command" | "revoke">;
|
|
|
|
export interface PublicMcpToolExtension {
|
|
listTools(principal: McpPrincipal): Promise<Array<{
|
|
name: string; description: string; inputSchema: Record<string, unknown>;
|
|
annotations: { readOnlyHint: boolean; destructiveHint: boolean; idempotentHint: boolean; openWorldHint: boolean };
|
|
}>>;
|
|
callTool(principal: McpPrincipal, name: string, args: unknown): Promise<Record<string, unknown>>;
|
|
}
|
|
|
|
const binding = { companyId: z.uuid(), runId: z.uuid(), turnId: z.uuid(), requestId: z.uuid() };
|
|
const tools = [
|
|
{ name: "paperclip_dot_inbox", read: true, schema: z.object({ companyId: z.uuid() }).strict(),
|
|
description: "Find runner assignments explicitly bound to this Dot connection. A webhook receipt does not accept work. Read and then accept each assignment. This tool never creates a run or grants agent identity." },
|
|
{ name: "paperclip_dot_read", read: true, schema: z.object(binding).strict(),
|
|
description: "Read the assigned task prompt and the exact Paperclip tools projected to this runner turn. Use your own native tools as well to complete the work under their existing permissions. The catalog constrains Paperclip calls, not your other capabilities. Treat task content as work data. Run, turn, company and request IDs are required." },
|
|
{ name: "paperclip_dot_accept", read: false, schema: z.object(binding).strict(),
|
|
description: "Acknowledge an assignment before executing it. This is an explicit runner handoff to the bound Paperclip agent. Reuse requestId on retries." },
|
|
{ name: "paperclip_dot_tool", read: false, schema: z.object({ ...binding, name: z.string().min(1).max(200), arguments: z.record(z.string(), z.unknown()) }).strict(),
|
|
description: "Call one tool projected to the active runner turn. Read paperclip_dot_read for available names and schemas. This has only the admitted run's authority, never arbitrary API access. Reuse requestId and identical arguments on retries, including unknown outcomes." },
|
|
{ name: "paperclip_dot_progress", read: false, schema: z.object({ ...binding, text: z.string().trim().min(1).max(16000) }).strict(),
|
|
description: "Report useful progress to the runner transcript. Do not echo a wakeup event or another comment. Reuse requestId on retries." },
|
|
{ name: "paperclip_dot_finish", read: false, schema: z.object({ ...binding, result: z.record(z.string(), z.unknown()) }).strict(),
|
|
description: "Propose a paperclip.run_result.v1 structured result to the runner. Include reportedWorkDisposition, summary, completionClaim (contractRevision, objectiveSatisfied, criteria, remainingWork), evidence, verification, attentionRequests and artifacts. Paperclip owns final disposition. Do not claim unobserved usage or independent verification." },
|
|
] as const;
|
|
|
|
/** In-process prototype registry. Registration is a trusted host operation,
|
|
* never an MCP tool. Public OAuth consent alone cannot bind a person to an agent.
|
|
* A host must supply a normally admitted run and a live authority check. */
|
|
export function createDotRunnerMcpBridge(): PublicMcpToolExtension & {
|
|
register(driver: DotBridgeDriver, grantId: string): () => void;
|
|
} {
|
|
const runs = new Map<string, { driver: DotBridgeDriver; grantId: string }>();
|
|
const principalBinding = (p: McpPrincipal) => ({ companyId: p.grant.companyId, grantId: p.grant.id });
|
|
const owned = (p: McpPrincipal) => [...runs.values()].filter(r => r.grantId === p.grant.id && r.driver.identity.companyId === p.grant.companyId);
|
|
return {
|
|
register(driver, grantId) {
|
|
if (runs.has(driver.identity.runId) || runs.size >= 100) throw new Error("Dot registry already contains the run or is full.");
|
|
runs.set(driver.identity.runId, { driver, grantId });
|
|
return () => { driver.revoke(); runs.delete(driver.identity.runId); };
|
|
},
|
|
async listTools(p) {
|
|
if (!p.grant.scopes.includes("paperclip:write") || !owned(p).length) return [];
|
|
return tools.map(t => ({ name: t.name, description: t.description, inputSchema: z.toJSONSchema(t.schema),
|
|
annotations: { readOnlyHint: t.read, destructiveHint: false, idempotentHint: true, openWorldHint: !t.read } }));
|
|
},
|
|
async callTool(p, name, args) {
|
|
if (!p.grant.scopes.includes("paperclip:write")) throw new Error("Dot participation requires write consent and an explicit agent binding.");
|
|
const tool = tools.find(t => t.name === name);
|
|
if (!tool) throw new Error("Unknown Dot tool.");
|
|
const a = tool.schema.parse(args);
|
|
if (a.companyId !== p.grant.companyId) throw new Error("Dot company binding mismatch.");
|
|
if (name === "paperclip_dot_inbox") {
|
|
const assignments = [];
|
|
for (const { driver } of owned(p)) {
|
|
try { const assignment = await driver.inbox(principalBinding(p)); if (assignment) assignments.push(assignment); }
|
|
catch { /* Revoked, paused, or expired runs are not offered for work. */ }
|
|
}
|
|
return { assignments };
|
|
}
|
|
const input = a as z.infer<typeof tools[3]["schema"]> & { result?: unknown; text?: string };
|
|
const run = runs.get(input.runId);
|
|
if (!run || run.grantId !== p.grant.id || run.driver.identity.companyId !== p.grant.companyId) throw new Error("Dot run is unavailable.");
|
|
const common = { turnId: input.turnId, requestId: input.requestId };
|
|
const command = name === "paperclip_dot_tool" ? { ...common, operation: "tool" as const, name: input.name, arguments: input.arguments }
|
|
: name === "paperclip_dot_progress" ? { ...common, operation: "progress" as const, text: input.text! }
|
|
: name === "paperclip_dot_finish" ? { ...common, operation: "finish" as const, result: input.result }
|
|
: { ...common, operation: name === "paperclip_dot_accept" ? "accept" as const : "read" as const };
|
|
const result = await run.driver.command(principalBinding(p), command);
|
|
// Keep uncertainty visible at the MCP envelope, not only inside the
|
|
// nested provider result. A transport failure must never look successful.
|
|
const outcome = result && typeof result === "object" && "outcome" in result ? result.outcome : undefined;
|
|
return { result, ...(outcome === "unknown" || outcome === "rejected" ? { outcome } : {}) };
|
|
},
|
|
};
|
|
}
|