mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-01 09:39:53 +01:00
merge: integrate agent lifecycle ownership from master
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
commit
ad5d8826ad
159 files changed
+7173
-2805
No files matched your search
@@ -197,7 +197,7 @@ describe("probeClaudeAcpSandboxLogin", () => {
|
||||
|
||||
// The parsed result is a success, so no login gate and no probe-unavailable
|
||||
// check appears.
|
||||
expect(checks).toEqual([]);
|
||||
expect(checks).toEqual([expect.objectContaining({ code: "claude_hello_probe_passed", level: "info" })]);
|
||||
});
|
||||
|
||||
it("keeps a non-auth failed probe with a token phrase on the probe-unavailable path", async () => {
|
||||
@@ -256,7 +256,7 @@ describe("probeClaudeAcpSandboxLogin", () => {
|
||||
expect(authRequired?.hint).toBe("Run `claude login` in this environment, then retry the probe.");
|
||||
});
|
||||
|
||||
it("emits no checks when the sandbox probe reports a healthy login", async () => {
|
||||
it("records a successful probe when the sandbox reports a healthy login", async () => {
|
||||
probeResult.value = { exitCode: 0, stdout: helloStdout, stderr: "", timedOut: false };
|
||||
|
||||
const checks = await probeClaudeAcpSandboxLogin({
|
||||
@@ -264,7 +264,13 @@ describe("probeClaudeAcpSandboxLogin", () => {
|
||||
target: sandboxTarget,
|
||||
});
|
||||
|
||||
expect(checks).toEqual([]);
|
||||
expect(checks).toEqual([expect.objectContaining({ code: "claude_hello_probe_passed", level: "info" })]);
|
||||
});
|
||||
|
||||
it("does not record success for an empty probe result", async () => {
|
||||
probeResult.value = { exitCode: 0, stdout: "", stderr: "", timedOut: false };
|
||||
const checks = await probeClaudeAcpSandboxLogin({ config: { engine: "acp" }, target: sandboxTarget });
|
||||
expect(checks).toEqual([expect.objectContaining({ code: "claude_acp_login_probe_unavailable", level: "warn" })]);
|
||||
});
|
||||
|
||||
it("emits a distinct warn check, not a silent pass, when the probe cannot run", async () => {
|
||||
@@ -552,6 +558,8 @@ describe("Claude ACP hello probe on local and SSH targets", () => {
|
||||
expect(result.checks).toContainEqual(expect.objectContaining({
|
||||
code: "claude_acp_anthropic_api_key_detected", level: "warn",
|
||||
}));
|
||||
expect(result.status).toBe("warn");
|
||||
expect(result.checks).toContainEqual(expect.objectContaining({ code: "claude_hello_probe_passed", level: "info" }));
|
||||
// The host key value never enters a check.
|
||||
expect(JSON.stringify(result.checks)).not.toContain("sk-ant-host-key");
|
||||
});
|
||||
|
||||
@@ -721,7 +721,10 @@ export async function probeClaudeAcpSandboxLogin(input: {
|
||||
});
|
||||
return [buildAcpLoginProbeUnavailableCheck("The Claude login probe did not complete.", targetIsSandbox)];
|
||||
}
|
||||
return [];
|
||||
if (!/\bhello\b/i.test(parsedStream.summary)) {
|
||||
return [buildAcpLoginProbeUnavailableCheck("The Claude login probe did not return hello.", targetIsSandbox)];
|
||||
}
|
||||
return [{ code: "claude_hello_probe_passed", level: "info", message: "Claude login probe succeeded." }];
|
||||
}
|
||||
|
||||
export async function testClaudeAcpEnvironment(
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
"generate": "pnpm run check:migrations && pnpm run clean && tsc -p tsconfig.json && drizzle-kit generate && pnpm run prune:snapshots",
|
||||
"prune:snapshots": "ls src/migrations/meta/*_snapshot.json | sort -r | tail -n +6 | xargs rm -f",
|
||||
"migrate": "pnpm run check:migrations && tsx src/migrate.ts",
|
||||
"seed": "tsx src/seed.ts"
|
||||
"seed": "pnpm --filter @paperclipai/server exec tsx scripts/seed.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@paperclipai/shared": "workspace:*",
|
||||
|
||||
@@ -7,6 +7,7 @@ import postgres from "postgres";
|
||||
import { createBufferedTextFileWriter, runDatabaseBackup, runDatabaseRestore } from "./backup-lib.js";
|
||||
import { ensurePostgresDatabase } from "./client.js";
|
||||
import {
|
||||
EMBEDDED_POSTGRES_TEST_TIMEOUT_MS,
|
||||
getEmbeddedPostgresTestSupport,
|
||||
startEmbeddedPostgresTestDatabase,
|
||||
} from "./test-embedded-postgres.js";
|
||||
@@ -105,7 +106,7 @@ describeEmbeddedPostgres("runDatabaseBackup", () => {
|
||||
if (previous === undefined) delete process.env.PAPERCLIP_PG_DUMP_PATH;
|
||||
else process.env.PAPERCLIP_PG_DUMP_PATH = previous;
|
||||
}
|
||||
});
|
||||
}, EMBEDDED_POSTGRES_TEST_TIMEOUT_MS);
|
||||
|
||||
it("preserves identity generation, sequence options and progress in JavaScript backups", async () => {
|
||||
const source = await createTempDatabase();
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
ALTER TABLE "agents" ADD COLUMN "lifecycle_state" text DEFAULT 'ready' NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "agents" ADD COLUMN "lifecycle_required_plugin_ids" jsonb;--> statement-breakpoint
|
||||
ALTER TABLE "agents" ADD COLUMN "lifecycle_holds" jsonb DEFAULT '[]'::jsonb NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "agents" ADD COLUMN "lifecycle_version" integer DEFAULT 0 NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "agents" ADD COLUMN "lifecycle_error" text;--> statement-breakpoint
|
||||
ALTER TABLE "agents" ADD COLUMN "lifecycle_operation" jsonb;--> statement-breakpoint
|
||||
CREATE INDEX "agents_lifecycle_work_idx" ON "agents" USING btree ("lifecycle_state","updated_at","id");
|
||||
--> statement-breakpoint
|
||||
UPDATE "agents" SET
|
||||
"lifecycle_state" = CASE "status"
|
||||
WHEN 'pending_approval' THEN 'pending_approval'
|
||||
WHEN 'paused' THEN 'paused'
|
||||
WHEN 'terminated' THEN 'terminated'
|
||||
ELSE 'ready' END,
|
||||
"lifecycle_holds" = CASE WHEN "status" = 'paused'
|
||||
THEN jsonb_build_array(coalesce("pause_reason", 'manual')) ELSE '[]'::jsonb END;
|
||||
+1406
-10
File diff suppressed because it is too large.
Load diff
+7
@@ -2227,6 +2227,13 @@
|
||||
"when": 1791490887468,
|
||||
"tag": "0319_heavy_captain_midlands",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 320,
|
||||
"version": "7",
|
||||
"when": 1791497222457,
|
||||
"tag": "0320_daily_onslaught",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { AgentAppearance } from "@paperclipai/shared";
|
||||
import type { AgentAppearance, AgentLifecycleState, AgentLifecycleOperation } from "@paperclipai/shared";
|
||||
import {
|
||||
type AnyPgColumn,
|
||||
pgTable,
|
||||
@@ -25,6 +25,12 @@ export const agents = pgTable(
|
||||
icon: text("icon"),
|
||||
appearance: jsonb("appearance").$type<AgentAppearance>(),
|
||||
status: text("status").notNull().default("idle"),
|
||||
lifecycleState: text("lifecycle_state").$type<AgentLifecycleState>().notNull().default("ready"),
|
||||
lifecycleRequiredPluginIds: jsonb("lifecycle_required_plugin_ids").$type<string[]>(),
|
||||
lifecycleHolds: jsonb("lifecycle_holds").$type<string[]>().notNull().default([]),
|
||||
lifecycleVersion: integer("lifecycle_version").notNull().default(0),
|
||||
lifecycleError: text("lifecycle_error"),
|
||||
lifecycleOperation: jsonb("lifecycle_operation").$type<AgentLifecycleOperation>(),
|
||||
reportsTo: uuid("reports_to").references((): AnyPgColumn => agents.id),
|
||||
capabilities: text("capabilities"),
|
||||
adapterType: text("adapter_type").notNull().default("process"),
|
||||
@@ -45,6 +51,7 @@ export const agents = pgTable(
|
||||
},
|
||||
(table) => ({
|
||||
companyIdUq: unique("agents_company_id_uq").on(table.companyId, table.id),
|
||||
lifecycleWorkIdx: index("agents_lifecycle_work_idx").on(table.lifecycleState, table.updatedAt, table.id),
|
||||
companyStatusIdx: index("agents_company_status_idx").on(table.companyId, table.status),
|
||||
companyReportsToIdx: index("agents_company_reports_to_idx").on(table.companyId, table.reportsTo),
|
||||
companyDefaultEnvironmentIdx: index("agents_company_default_environment_idx").on(table.companyId, table.defaultEnvironmentId),
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
import { createDb } from "./client.js";
|
||||
import { companies, agents, goals, projects, issues } from "./schema/index.js";
|
||||
|
||||
const url = process.env.DATABASE_URL;
|
||||
if (!url) throw new Error("DATABASE_URL is required");
|
||||
|
||||
const db = createDb(url);
|
||||
|
||||
console.log("Seeding database...");
|
||||
|
||||
const [company] = await db
|
||||
.insert(companies)
|
||||
.values({
|
||||
name: "Paperclip Demo Co",
|
||||
description: "A demo autonomous company",
|
||||
status: "active",
|
||||
budgetMonthlyCents: 50000,
|
||||
})
|
||||
.returning();
|
||||
|
||||
const [ceo] = await db
|
||||
.insert(agents)
|
||||
.values({
|
||||
companyId: company!.id,
|
||||
name: "CEO Agent",
|
||||
role: "ceo",
|
||||
title: "Chief Executive Officer",
|
||||
status: "idle",
|
||||
adapterType: "process",
|
||||
adapterConfig: { command: "echo", args: ["hello from ceo"] },
|
||||
budgetMonthlyCents: 15000,
|
||||
})
|
||||
.returning();
|
||||
|
||||
const [engineer] = await db
|
||||
.insert(agents)
|
||||
.values({
|
||||
companyId: company!.id,
|
||||
name: "Engineer Agent",
|
||||
role: "engineer",
|
||||
title: "Software Engineer",
|
||||
status: "idle",
|
||||
reportsTo: ceo!.id,
|
||||
adapterType: "process",
|
||||
adapterConfig: { command: "echo", args: ["hello from engineer"] },
|
||||
budgetMonthlyCents: 10000,
|
||||
})
|
||||
.returning();
|
||||
|
||||
const [goal] = await db
|
||||
.insert(goals)
|
||||
.values({
|
||||
companyId: company!.id,
|
||||
title: "Ship V1",
|
||||
description: "Deliver first control plane release",
|
||||
level: "company",
|
||||
status: "active",
|
||||
ownerAgentId: ceo!.id,
|
||||
})
|
||||
.returning();
|
||||
|
||||
const [project] = await db
|
||||
.insert(projects)
|
||||
.values({
|
||||
companyId: company!.id,
|
||||
goalId: goal!.id,
|
||||
name: "Control Plane MVP",
|
||||
description: "Implement core board + agent loop",
|
||||
status: "in_progress",
|
||||
leadAgentId: ceo!.id,
|
||||
})
|
||||
.returning();
|
||||
|
||||
await db.insert(issues).values([
|
||||
{
|
||||
companyId: company!.id,
|
||||
projectId: project!.id,
|
||||
goalId: goal!.id,
|
||||
title: "Implement atomic task checkout",
|
||||
description: "Ensure in_progress claiming is conflict-safe",
|
||||
status: "todo",
|
||||
priority: "high",
|
||||
assigneeAgentId: engineer!.id,
|
||||
createdByAgentId: ceo!.id,
|
||||
},
|
||||
{
|
||||
companyId: company!.id,
|
||||
projectId: project!.id,
|
||||
goalId: goal!.id,
|
||||
title: "Add budget auto-pause",
|
||||
description: "Pause agent at hard budget ceiling",
|
||||
status: "backlog",
|
||||
priority: "medium",
|
||||
createdByAgentId: ceo!.id,
|
||||
},
|
||||
]);
|
||||
|
||||
console.log("Seed complete");
|
||||
process.exit(0);
|
||||
@@ -6550,11 +6550,11 @@ it("rotates PRP authority in place for a warm cross-run attachment", async () =>
|
||||
it("reopens Pi after a completed turn within its cold admission budget during warm attachment", async () => {
|
||||
const root = await mkdtemp(join(tmpdir(), "runnerd-pi-warm-admission-"));
|
||||
const cliRoot = join(root, "dist/cli");
|
||||
await mkdir(cliRoot, { recursive: true });
|
||||
await mkdir(cliRoot, { recursive: true, mode: 0o700 });
|
||||
const sidecarPath = join(cliRoot, "acpx-runtime-sidecar.cjs");
|
||||
const journal = join(root, "commands.ndjson");
|
||||
const fixture = await readFile(fileURLToPath(new URL("./fixtures/fake-pi-warm-sidecar.cjs", import.meta.url)), "utf8");
|
||||
await writeFile(sidecarPath, fixture.replace("/* fixture-config */ null", JSON.stringify({ journal, resumeDelayMs: 32_000, commandDigest: QUALIFIED_ACPX_PROFILES.pi.commandDigest })));
|
||||
await writeFile(sidecarPath, fixture.replace("/* fixture-config */ null", JSON.stringify({ journal, resumeDelayMs: 32_000, commandDigest: QUALIFIED_ACPX_PROFILES.pi.commandDigest })), { mode: 0o600 });
|
||||
const digest = (path: string) => `sha256:${createHash("sha256").update(readFileSync(path)).digest("hex")}`;
|
||||
const bundle = createCapabilityRunnerdCodexTransport({
|
||||
provider: "acpx", acpxAgent: "pi", piThinkingLevel: "low", acpxPermissionMode: "deny-all",
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { AgentLifecycleRequest, AgentLifecycleResult } from "@paperclipai/shared";
|
||||
import type { AiConnectionRouterRequest, AiConnectionRouterResult } from "@paperclipai/shared";
|
||||
/**
|
||||
* `definePlugin` — the top-level helper for authoring a Paperclip plugin.
|
||||
@@ -358,6 +359,8 @@ export interface PluginDefinition {
|
||||
* Requires `external.objects.read`.
|
||||
*/
|
||||
/** Propose a member from host-authorized candidates. Requires ai.connections.route. */
|
||||
onAgentLifecycle?(params: AgentLifecycleRequest): Promise<AgentLifecycleResult>;
|
||||
|
||||
onRouteAiConnection?(params: AiConnectionRouterRequest): Promise<AiConnectionRouterResult>;
|
||||
|
||||
onResolveExternalObject?(
|
||||
|
||||
@@ -456,3 +456,5 @@ export { preserveEnvironmentSyncErrorDiagnostic, environmentSyncErrorData, readE
|
||||
export type { PluginEnvironmentSyncErrorDiagnostic } from "./environment-sync-error.js";
|
||||
|
||||
export type { AiConnectionPool, AiConnectionPoolConfig, AiConnectionPoolMember, AiConnectionRouterRequest, AiConnectionRouterResult, AiConnectionRouterSelection } from "@paperclipai/shared";
|
||||
|
||||
export type { AgentLifecycleRequest, AgentLifecycleResult } from "@paperclipai/shared";
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { AgentLifecycleRequest, AgentLifecycleResult } from "@paperclipai/shared";
|
||||
import type { AiConnectionRouterRequest, AiConnectionRouterResult } from "@paperclipai/shared";
|
||||
/**
|
||||
* JSON-RPC 2.0 message types and protocol helpers for the host ↔ worker IPC
|
||||
@@ -1345,6 +1346,7 @@ export interface HostToWorkerMethods {
|
||||
/** Scoped plugin API route dispatch. */
|
||||
handleApiRequest: [params: PluginApiRequestInput, result: PluginApiResponse];
|
||||
/** @see PLUGIN_SPEC.md §13.8 */
|
||||
agentLifecycle: [params: AgentLifecycleRequest, result: AgentLifecycleResult];
|
||||
getData: [params: GetDataParams, result: unknown];
|
||||
/** @see PLUGIN_SPEC.md §13.9 */
|
||||
performAction: [params: PerformActionParams, result: unknown];
|
||||
@@ -1481,6 +1483,7 @@ export const HOST_TO_WORKER_OPTIONAL_METHODS: readonly HostToWorkerMethodName[]
|
||||
"runJob",
|
||||
"handleWebhook",
|
||||
"handleApiRequest",
|
||||
"agentLifecycle",
|
||||
"getData",
|
||||
"performAction",
|
||||
"executeTool",
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { AgentLifecycleRequest, AgentLifecycleResult } from "@paperclipai/shared";
|
||||
import type { AiConnectionRouterRequest, AiConnectionRouterResult } from "@paperclipai/shared";
|
||||
import { environmentCreationCleanupErrorData } from "./environment-creation-cleanup.js";
|
||||
import { environmentSyncErrorData, withEnvironmentSyncErrorCapture } from "./environment-sync-error.js";
|
||||
@@ -1659,6 +1660,9 @@ export function startWorkerRpcHost(options: WorkerRpcHostOptions): WorkerRpcHost
|
||||
return handleExecuteTool(params as ExecuteToolParams);
|
||||
case "detectExternalObjects":
|
||||
return handleDetectExternalObjects(params as DetectExternalObjectsParams);
|
||||
case "agentLifecycle":
|
||||
if (!plugin.definition.onAgentLifecycle) throw methodNotImplemented("agentLifecycle");
|
||||
return plugin.definition.onAgentLifecycle(params as AgentLifecycleRequest);
|
||||
case "routeAiConnection":
|
||||
if (!plugin.definition.onRouteAiConnection) throw methodNotImplemented("routeAiConnection");
|
||||
return plugin.definition.onRouteAiConnection(params as AiConnectionRouterRequest);
|
||||
@@ -1779,6 +1783,7 @@ export function startWorkerRpcHost(options: WorkerRpcHostOptions): WorkerRpcHost
|
||||
if (plugin.definition.onIdleDrain) supportedMethods.push("prepareIdleSleep", "releaseIdleSleep");
|
||||
if (plugin.definition.onApiRequest) supportedMethods.push("handleApiRequest");
|
||||
if (plugin.definition.onDetectExternalObjects) supportedMethods.push("detectExternalObjects");
|
||||
if (plugin.definition.onAgentLifecycle) supportedMethods.push("agentLifecycle");
|
||||
if (plugin.definition.onRouteAiConnection) supportedMethods.push("routeAiConnection");
|
||||
if (plugin.definition.onResolveExternalObject) supportedMethods.push("resolveExternalObject");
|
||||
if (plugin.definition.onRefreshExternalObjects) supportedMethods.push("refreshExternalObjects");
|
||||
|
||||
@@ -1340,6 +1340,7 @@ export const PLUGIN_CAPABILITIES = [
|
||||
"approvals.read",
|
||||
"issue.documents.read",
|
||||
"agents.read",
|
||||
"agents.lifecycle.manage",
|
||||
"goals.read",
|
||||
"goals.create",
|
||||
"goals.update",
|
||||
|
||||
@@ -2859,3 +2859,7 @@ export * from "./agent-avatar-upload.js";
|
||||
|
||||
export type { DotBinding, DotInvitation, DotConnection, DotPairing } from "./dot-invitations.js";
|
||||
export { agentHarnessType, agentRunner, paperclipRunnerProfileForHarness, paperclipRunnerSupportsPlatform, type AgentRunnerChoice, type AgentRunner, type AgentRunnerAvailability } from "./agent-runner.js";
|
||||
|
||||
export { AGENT_LIFECYCLE_STATES, type AgentLifecycleState, type AgentLifecycleOperation } from "./types/agent-lifecycle.js";
|
||||
|
||||
export type { AgentLifecycleRequest, AgentLifecycleResult } from "./types/agent-lifecycle.js";
|
||||
@@ -0,0 +1,31 @@
|
||||
/** The lifecycle controls admission. Execution status describes current work. */
|
||||
export const AGENT_LIFECYCLE_STATES = [
|
||||
"pending_approval", "preparing", "verifying", "ready", "pausing", "paused",
|
||||
"resuming", "terminating", "cleaning_up", "terminated", "rejected",
|
||||
] as const;
|
||||
export type AgentLifecycleState = typeof AGENT_LIFECYCLE_STATES[number];
|
||||
|
||||
export interface AgentLifecycleOperation {
|
||||
id: string;
|
||||
resumeState?: "preparing" | "verifying" | "ready";
|
||||
hostComplete: boolean;
|
||||
completedPluginIds: string[];
|
||||
leaseOwner?: string;
|
||||
leaseUntil?: string;
|
||||
retryAt?: string;
|
||||
attempts: number;
|
||||
responsibleUserId?: string | null;
|
||||
}
|
||||
|
||||
export interface AgentLifecycleRequest {
|
||||
companyId: string;
|
||||
agentId: string;
|
||||
operationId: string;
|
||||
version: number;
|
||||
phase: AgentLifecycleState;
|
||||
}
|
||||
export interface AgentLifecycleResult {
|
||||
operationId: string;
|
||||
version: number;
|
||||
status: "complete" | "pending";
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { AgentLifecycleState } from "./agent-lifecycle.js";
|
||||
import type { AgentAppearance } from "../agent-appearance.js";
|
||||
import type { AiConnectionLoginIntent } from "../ai-connections.js";
|
||||
import type {
|
||||
@@ -90,6 +91,9 @@ export interface Agent {
|
||||
appearance?: AgentAppearance | null;
|
||||
avatarUrl?: string;
|
||||
status: AgentStatus;
|
||||
lifecycleState?: AgentLifecycleState;
|
||||
lifecycleVersion?: number;
|
||||
lifecycleError?: string | null;
|
||||
reportsTo: string | null;
|
||||
capabilities: string | null;
|
||||
adapterType: AgentAdapterType;
|
||||
|
||||
@@ -1098,3 +1098,5 @@ export type { AgentInstructionErrorCode, AgentInstructionErrorDetails, AgentInst
|
||||
export type { AgentInstructionCandidate } from "./agent.js";
|
||||
|
||||
export * from "./skill-source.js";
|
||||
|
||||
export * from "./agent-lifecycle.js";
|
||||
@@ -688,6 +688,8 @@ export interface PaperclipPluginManifestV1 {
|
||||
/** Capabilities this plugin requires from the host. Enforced at runtime. */
|
||||
capabilities: PluginCapability[];
|
||||
/** Opt into the native pooled-connection catalog, setup, and management UI. */
|
||||
/** Required participant in agent preparation, stop, resume, and cleanup. */
|
||||
agentLifecycle?: true;
|
||||
aiConnectionRouter?: { name: string; description: string };
|
||||
/** Entrypoint paths relative to the package root. */
|
||||
entrypoints: {
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { updateAgentSchema } from "./agent.js";
|
||||
|
||||
describe("agent update schema", () => {
|
||||
it.each(["paused", "idle", "terminated"])("accepts lifecycle status request %s", status => {
|
||||
expect(updateAgentSchema.parse({ status })).toEqual({ status });
|
||||
});
|
||||
it.each(["active", "running", "error", "pending_approval"])("rejects direct status write %s", status => {
|
||||
const result = updateAgentSchema.safeParse({ name: "Renamed", status });
|
||||
expect(result.success).toBe(false);
|
||||
if (!result.success) expect(result.error.issues).toEqual(expect.arrayContaining([
|
||||
expect.objectContaining({ path: ["status"] }),
|
||||
]));
|
||||
});
|
||||
it.each([{ spentMonthlyCents: 0 }, { name: "Renamed", spentMonthlyCents: 10 }])("rejects spend totals: %j", payload => {
|
||||
const result = updateAgentSchema.safeParse(payload);
|
||||
expect(result.success).toBe(false);
|
||||
if (!result.success) expect(result.error.issues).toEqual(expect.arrayContaining([
|
||||
expect.objectContaining({ path: ["spentMonthlyCents"] }),
|
||||
]));
|
||||
});
|
||||
it("accepts profile and budget limit changes", () => {
|
||||
expect(updateAgentSchema.parse({ name: "Renamed", budgetMonthlyCents: 100 })).toEqual({ name: "Renamed", budgetMonthlyCents: 100 });
|
||||
});
|
||||
});
|
||||
@@ -4,7 +4,6 @@ import { z } from "zod";
|
||||
import {
|
||||
AGENT_ICON_NAMES,
|
||||
AGENT_ROLES,
|
||||
AGENT_STATUSES,
|
||||
INBOX_MINE_ISSUE_STATUS_FILTER,
|
||||
} from "../constants.js";
|
||||
import { agentAdapterTypeSchema } from "../adapter-type.js";
|
||||
@@ -157,8 +156,8 @@ export const updateAgentSchema = objectWithoutDefaults(
|
||||
.extend({
|
||||
permissions: z.never().optional(),
|
||||
replaceAdapterConfig: z.boolean().optional(),
|
||||
status: z.enum(AGENT_STATUSES).optional(),
|
||||
spentMonthlyCents: z.number().int().nonnegative().optional(),
|
||||
status: z.enum(["paused", "idle", "terminated"]).optional(),
|
||||
spentMonthlyCents: z.never().optional(),
|
||||
});
|
||||
|
||||
export type UpdateAgent = z.infer<typeof updateAgentSchema>;
|
||||
|
||||
@@ -33,6 +33,12 @@ describe("plugin capability constants", () => {
|
||||
});
|
||||
|
||||
describe("plugin manifest validators", () => {
|
||||
it("requires authority for required agent lifecycle participants", () => {
|
||||
const manifest = { id: "example.lifecycle", apiVersion: 1, version: "0.1.0", displayName: "Lifecycle", description: "Lifecycle tests", author: "Tests", categories: ["automation"], entrypoints: { worker: "worker.js" }, agentLifecycle: true };
|
||||
expect(pluginManifestV1Schema.safeParse({ ...manifest, capabilities: ["agents.read"] }).success).toBe(false);
|
||||
expect(pluginManifestV1Schema.parse({ ...manifest, capabilities: ["agents.lifecycle.manage"] }).agentLifecycle).toBe(true);
|
||||
});
|
||||
|
||||
it("requires routing authority for native pooled connector declarations without a custom UI bundle", () => {
|
||||
const manifest = { id: "example.pool", apiVersion: 1, version: "0.1.0", displayName: "Pool", description: "Pool", author: "Tests", categories: ["connector"], entrypoints: { worker: "worker.js" }, aiConnectionRouter: { name: "AI connection pool", description: "Use saved connections" } };
|
||||
expect(pluginManifestV1Schema.safeParse({ ...manifest, capabilities: ["ui.page.register"] }).success).toBe(false);
|
||||
|
||||
@@ -782,6 +782,7 @@ export const pluginManifestV1Schema = z.object({
|
||||
"minimumPaperclipVersion must follow semver (e.g. 1.0.0)",
|
||||
).optional(),
|
||||
capabilities: z.array(z.enum(PLUGIN_CAPABILITIES)).min(1),
|
||||
agentLifecycle: z.literal(true).optional(),
|
||||
aiConnectionRouter: z.object({ name: z.string().trim().min(1).max(100), description: z.string().trim().min(1).max(500) }).strict().optional(),
|
||||
entrypoints: z.object({
|
||||
worker: z.string().min(1),
|
||||
@@ -806,6 +807,10 @@ export const pluginManifestV1Schema = z.object({
|
||||
launchers: z.array(pluginLauncherDeclarationSchema).optional(),
|
||||
}).optional(),
|
||||
}).superRefine((manifest, ctx) => {
|
||||
if (manifest.agentLifecycle && !manifest.capabilities.includes("agents.lifecycle.manage")) {
|
||||
ctx.addIssue({ code: z.ZodIssueCode.custom, message: "Agent lifecycle participation requires agents.lifecycle.manage", path: ["capabilities"] });
|
||||
}
|
||||
|
||||
// ── Entrypoint ↔ UI slot consistency ──────────────────────────────────
|
||||
// Plugins that declare UI slots must also declare a UI entrypoint so the
|
||||
// host knows where to load the bundle from (PLUGIN_SPEC.md §10.1).
|
||||
|
||||
Reference in new issue
Block a user