Merge remote-tracking branch 'origin/master' into swarm-neon-tmp

* origin/master:
  refactor(ui): prune 36 thin mocked jsdom UI tests and consolidate replay masking checks (#22834)
  docs: correct three budget claims from the review of the budget docs (#22833)
  refactor(test): prune 28 completed migration, prose-grep, and Storybook fixture tests (#22832)
  fix(e2e): observe scheduled native retries before grading tasks (#22826)
This commit is contained in:
Dotta committed 2026-11-24 16:57:44 -06:00
commit 83bf07cac4
85 files changed
+397 -15059

No files matched your search

@@ -1,56 +0,0 @@
import { expect, it, vi } from "vitest";
import { searchRunnerApi } from "../services/native-runtime/runner-api-catalog.js";
import { executeRunnerApi } from "../services/native-runtime/runner-api-client.js";
import { startOpenCodeMcpBridge } from "../../../packages/paperclip-runner/src/drivers/opencode/mcp-bridge.js";
import { searchApiAction } from "../../../packages/paperclip-runner/src/protocol-actions/search-api.js";
it("delivers personal primary profile guidance through actual API discovery and bounded OpenCode MCP output", async () => {
const descriptor = searchApiAction.live.descriptor;
let calls = 0;
const bridge = await startOpenCodeMcpBridge({
tools: [{ name: descriptor.operationId, description: descriptor.description, inputSchema: descriptor.inputSchema }],
handler: async call => {
expect(call.tool).toBe("search_api"); calls++;
return { type: "inputText", text: JSON.stringify(searchRunnerApi(call.arguments)) };
},
});
try {
const response = await fetch(bridge.url, { method: "POST", headers: {
Authorization: `Bearer ${bridge.secret}`, "Content-Type": "application/json", Accept: "application/json, text/event-stream",
}, body: JSON.stringify({ jsonrpc: "2.0", id: "primary-guidance", method: "tools/call",
params: { name: "paperclip_search_api", arguments: { query: "set primary agent", limit: 2 } } }) });
expect(response.status).toBe(200);
const wire = await response.json() as { result: { isError?: boolean; content: Array<{ type: string; text: string }> } };
expect(wire.result.isError).not.toBe(true);
const controller = JSON.parse(wire.result.content[0]!.text) as { type: string; text: string };
expect(controller.type).toBe("inputText");
expect(Buffer.byteLength(JSON.stringify(controller))).toBeLessThan(500_000);
const discovered = JSON.parse(controller.text) as ReturnType<typeof searchRunnerApi>;
const operation = discovered.results.find(row => row.operationId === "PUT /api/companies/{companyId}/primary-agent/me");
expect(operation).toBeDefined();
expect(operation!.description).toMatch(/agent.{0,12}profile/i);
expect(operation!.description).toContain("Set as my primary");
expect(operation!.description).toMatch(/confirm.{0,30}replac/i);
expect(operation!.description).toMatch(/chat picker.{0,70}does not change/i);
expect(operation!.authorization.actor).toBe("board");
expect(operation!.description).toContain("Agent credentials cannot access it");
expect(operation!.requestBody?.content["application/json"].schema.properties.primaryAgentId).toMatchObject({ type: "string", format: "uuid" });
expect(calls).toBe(1);
} finally { await bridge.close(); }
});
it("keeps personal preference calls on the agent identity and preserves the board-only denial", async () => {
const companyId = "00000000-0000-4000-8000-000000000111", runId = "00000000-0000-4000-8000-000000000112";
const request = vi.fn<typeof fetch>(async () => Response.json({ error: "Board access required" }, { status: 403 }));
const result = await executeRunnerApi({ operationId: "PUT /api/companies/{companyId}/primary-agent/me",
body: { primaryAgentId: "00000000-0000-4000-8000-000000000113" } },
{ companyId, runId, issueId: "00000000-0000-4000-8000-000000000114", workMode: "standard" },
{ apiUrl: "https://paperclip.test", token: "synthetic-agent-only", fetch: request,
readFile: async () => { throw new Error("No file read required"); },
saveResponse: async () => { throw new Error("No capture required"); } });
expect(result).toMatchObject({ ok: false, status: 403, data: { error: "Board access required" } });
expect(request).toHaveBeenCalledOnce();
const headers = new Headers(request.mock.calls[0]![1]?.headers);
expect(headers.get("Authorization")).toBe("Bearer synthetic-agent-only");
expect(headers.get("X-Paperclip-Run-Id")).toBe(runId);
});
@@ -1,37 +0,0 @@
import { expect, it } from "vitest";
import { searchRunnerApi } from "../services/native-runtime/runner-api-catalog.js";
import { startOpenCodeMcpBridge } from "../../../packages/paperclip-runner/src/drivers/opencode/mcp-bridge.js";
import { searchApiAction } from "../../../packages/paperclip-runner/src/protocol-actions/search-api.js";
it("discovers the existing secure human entry surface through native API search", async () => {
const descriptor = searchApiAction.live.descriptor;
const bridge = await startOpenCodeMcpBridge({
tools: [{ name: descriptor.operationId, description: descriptor.description, inputSchema: descriptor.inputSchema }],
handler: async call => ({ type: "inputText", text: JSON.stringify(searchRunnerApi(call.arguments)) }),
});
try {
for (const query of ["company credential secret", "personal publishing credential"]) {
const response = await fetch(bridge.url, { method: "POST", headers: {
Authorization: `Bearer ${bridge.secret}`, "Content-Type": "application/json", Accept: "application/json, text/event-stream",
}, body: JSON.stringify({ jsonrpc: "2.0", id: query, method: "tools/call",
params: { name: "paperclip_search_api", arguments: { query } } }) });
expect(response.status).toBe(200);
const wire = await response.json() as { result: { isError?: boolean; content: Array<{ text: string }> } };
expect(wire.result.isError).not.toBe(true);
const controller = JSON.parse(wire.result.content[0]!.text) as { text: string };
const discovered = JSON.parse(controller.text) as ReturnType<typeof searchRunnerApi>;
const operations = discovered.results.filter(operation => operation.description.includes("/company/settings/secrets"));
expect(operations.length, query).toBeGreaterThan(0);
expect(operations.some(operation => /human|signed-in person/.test(operation.description))).toBe(true);
expect(operations.some(operation => /never.*chat/i.test(operation.description))).toBe(true);
if (query.startsWith("personal")) {
const definitions = operations.find(operation => operation.path.endsWith("user-secret-definitions"));
expect(definitions?.description).toContain("Set my value");
expect(definitions?.description).toContain("current person");
expect(definitions?.description).toContain("Company admins can also open definition details");
expect(definitions?.description).toContain("other members use My secrets and Set my value");
expect(definitions?.authorization.actor).toBe("board");
}
}
} finally { await bridge.close(); }
});
@@ -1,55 +0,0 @@
import { describe, expect, it } from "vitest";
import { CHAT_PROVIDERS, updateChatEndpointSchema } from "@paperclipai/shared";
import { buildChatCommunicationGuidance } from "./chat-communication-guidance.js";
describe("initial medium communication guidance", () => {
it.each([true, false])("requires result and review updates in Slack (direct=%s)", (isDirectMessage) => {
const guidance = buildChatCommunicationGuidance({ provider: "slack", isDirectMessage });
expect(guidance).toContain("When you have results, update the user in the originating Slack");
expect(guidance).toContain("Put this update in your final response");
expect(guidance).toContain("When the user needs to review a plan, approve an action, or review a result");
expect(guidance).toContain("create the required human-input or approval interaction before you yield");
expect(guidance).toContain("do not continue gated work until the required approval is recorded");
});
it("guides Slack presentation while retaining ordinary agent tools and explicit output requests", () => {
const guidance = buildChatCommunicationGuidance({ provider: "slack", isDirectMessage: false, communicationInstructions: "Use customer-facing names." });
expect(guidance).toContain("shared channel thread");
expect(guidance).toContain("document or artifact tools");
expect(guidance).toContain("exact output");
expect(guidance).toContain("grant no additional authority");
expect(guidance).toContain('"Use customer-facing names."');
expect(buildChatCommunicationGuidance({ provider: "slack", isDirectMessage: true })).toContain("direct conversation");
});
it("keeps voice presentation concise without cancelling work on hangup or granting approvals", () => {
const guidance = buildChatCommunicationGuidance({ provider: "speko", isDirectMessage: true });
expect(guidance).toContain("Communication by voice");
expect(guidance).toContain("Keep your existing identity, runtime, tools, and task assignment");
expect(guidance).toContain("one focused clarification");
expect(guidance).toContain("durable Paperclip continuation");
expect(guidance).toContain("Delivery to Speko does not prove an answer was spoken");
expect(guidance).toContain("does not cancel work");
expect(guidance).toContain("Protected approvals must be completed in Paperclip");
});
it.each([false, true])("requires public links for created Slack tasks (DM: %s)", (isDirectMessage) => {
const guidance = buildChatCommunicationGuidance({ provider: "slack", isDirectMessage });
expect(guidance).toContain("include a clickable link to each created task");
expect(guidance).toContain("task identifier or title as the link text");
expect(guidance).toContain("public task URL returned by Paperclip tools or supplied in task context");
expect(guidance).toContain("never guess a URL");
expect(guidance).toContain("If no public task URL is available, say that the link is unavailable");
});
it.each(CHAT_PROVIDERS.filter((provider) => provider !== "slack" && provider !== "speko"))("leaves %s unchanged", (provider) => {
expect(buildChatCommunicationGuidance({ provider, isDirectMessage: false, communicationInstructions: "Ignored" })).toBeNull();
});
it("accepts clearing instructions and rejects oversized instructions and unsupported controls", () => {
expect(updateChatEndpointSchema.parse({ communicationInstructions: " " })).toEqual({ communicationInstructions: "" });
expect(updateChatEndpointSchema.safeParse({ communicationInstructions: "a".repeat(4001) }).success).toBe(false);
expect(updateChatEndpointSchema.safeParse({ replyDetail: "brief" }).success).toBe(false);
expect(updateChatEndpointSchema.safeParse({ progressUpdates: false }).success).toBe(false);
});
});
@@ -1,39 +0,0 @@
import { describe, expect, it } from "vitest";
import { renderOnboardingGreeting } from "./onboarding-greeting.js";
describe("renderOnboardingGreeting", () => {
it("introduces the agent by name as the user's first teammate", async () => {
const greeting = await renderOnboardingGreeting({
agentName: "Nova",
organizationName: "Acme",
});
expect(greeting).toContain(
"Welcome to Paperclip! I'm Nova, your first agent teammate.",
);
// No goal quote and no "give me one moment" — the agent is not about to run.
expect(greeting).not.toContain("aiming for");
expect(greeting).not.toContain("one moment");
// The "what would you like to do" ask moved to the opening card; the
// greeting only points at it.
expect(greeting).toContain("Pick how you'd like to start");
});
it("drops the name gracefully when no agent name is set", async () => {
const greeting = await renderOnboardingGreeting({
agentName: null,
organizationName: "Acme",
});
expect(greeting).toContain(
"Welcome to Paperclip! I'm your first agent teammate.",
);
expect(greeting).not.toContain("{{agentName}}");
});
it("trims whitespace/blank names to the no-name phrasing", async () => {
const greeting = await renderOnboardingGreeting({ agentName: " " });
expect(greeting).toContain("I'm your first agent teammate.");
});
});