Integrate current master before Copilot profile 35 freeze

Preserve upstream agent lifecycle and dependency updates without changing the Copilot runtime attestation.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip committed 2026-10-09 11:45:45 -05:00
commit 2a704c2cf8
198 files changed
+14211 -6906

No files matched your search

+97
View File
@@ -0,0 +1,97 @@
import { createDb } from "@paperclipai/db";
import { createAgentLifecycle } from "../src/services/agent-lifecycle.js";
import {
companies,
goals,
projects,
issues,
} from "@paperclipai/db";
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 createAgentLifecycle(db).requestHire(company!.id, {
name: "CEO Agent",
role: "ceo",
title: "Chief Executive Officer",
status: "idle",
adapterType: "process",
adapterConfig: { command: "echo", args: ["hello from ceo"] },
budgetMonthlyCents: 15000,
});
const engineer = await createAgentLifecycle(db).requestHire(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,
});
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);
+16 -2
View File
@@ -1,4 +1,4 @@
/** Opt-in live qualification: creates an isolated database/workspace and spends two Codex turns.
/** Opt-in live qualification: creates an isolated database/workspace and runs a harness test and two Codex turns.
* PATH=<pnpm-bin>:<codex-bin>:$PATH node --import tsx server/scripts/smoke-native-task-monitor.ts --run
*/
import assert from "node:assert/strict";
@@ -17,6 +17,9 @@ process.env.PAPERCLIP_INSTANCE_ID = "monitor-smoke";
process.env.PAPERCLIP_TELEMETRY_ENABLED = "false";
const { createDb, companies, agents, authUsers, companyMemberships, issues, heartbeatRuns, agentWakeupRequests, nativeRunResults, statusDecisions } = await import("@paperclipai/db");
const { startEmbeddedPostgresTestDatabase } = await import("../src/__tests__/helpers/embedded-postgres.js");
const { createAgentLifecycle, startAgentLifecycle } = await import("../src/services/agent-lifecycle.js");
const { createLifecycleDriver } = await import("../src/services/agent-lifecycle-driver.js");
const { createPluginWorkerManager } = await import("../src/services/plugin-worker-manager.js");
const { heartbeatService } = await import("../src/services/heartbeat.js");
const { setupRunnerPrpWebSocketServer, runnerPrpWebSocketInternals } = await import("../src/realtime/runner-prp-ws.js");
const { closeIdleWarmNativeSessionsForRestart } = await import("../src/services/native-runtime/native-session-executor.js");
@@ -30,6 +33,7 @@ process.env.PAPERCLIP_API_URL = `http://127.0.0.1:${address.port}`;
setupRunnerPrpWebSocketServer(server, { apiUrl: process.env.PAPERCLIP_API_URL });
const companyId = randomUUID(), agentId = randomUUID(), issueId = randomUUID();
const heartbeat = heartbeatService(db);
const lifecycle = startAgentLifecycle(db, createLifecycleDriver(db, createPluginWorkerManager()), () => true);
const readRuns = () => db.select().from(heartbeatRuns).where(eq(heartbeatRuns.companyId, companyId)).orderBy(heartbeatRuns.createdAt);
console.log(JSON.stringify({ root, companyId, agentId, issueId }));
try {
@@ -38,9 +42,18 @@ try {
await db.insert(companies).values({ id: companyId, name: "Isolated monitor smoke", issuePrefix: "MON", defaultResponsibleUserId: "monitor-smoke", requireBoardApprovalForNewAgents: false });
await db.insert(authUsers).values({ id: "monitor-smoke", name: "Monitor smoke", email: "monitor-smoke@example.test", createdAt: new Date(), updatedAt: new Date() });
await db.insert(companyMemberships).values({ companyId, principalType: "user", principalId: "monitor-smoke", status: "active", membershipRole: "owner" });
await db.insert(agents).values({ id: agentId, companyId, name: "Monitor verifier", status: "active", adapterType: "paperclip_runner",
await createAgentLifecycle(db).requestHire(companyId, { id: agentId, name: "Monitor verifier", status: "active", adapterType: "paperclip_runner",
adapterConfig: { provider: "codex", cwd, lifecycleMode: "warm", idleTimeoutMs: 300_000, timeoutSeconds: 180 },
runtimeConfig: { heartbeat: { enabled: false, wakeOnDemand: true } } });
const setupDeadline = Date.now() + 3 * 60_000;
while (true) {
const agent = await createAgentLifecycle(db).get(agentId);
assert.ok(agent, "the hired agent must exist");
assert.equal(agent.lifecycleError, null, "agent setup failed");
if (agent.lifecycleState === "ready") break;
assert.ok(Date.now() < setupDeadline, "agent setup timed out");
await delay(250);
}
await db.insert(issues).values({ id: issueId, companyId, title: "Verify a one-shot native task monitor", identifier: "MON-1", status: "in_progress", assigneeAgentId: agentId,
description: "This is an isolated two-run integration test. First run: use set_task_monitor on this task with a fresh nextCheckAt about 45 seconds in the future (compute the current UTC time if needed), notes saying to verify issue_monitor_due, and idempotencyKey monitor-live-first. Confirm the receipt. Then call paperclip_finish with yielded and continuation.kind monitor, accurately retaining the second run as blocking remaining work. End immediately after acceptance. Do not sleep or poll. Second run: if the wake reason is issue_monitor_due, the requested check succeeded. Report that reason and finish done using the current completion contract. Do not schedule another monitor or request human review. No files or other deliverables are required." });
await heartbeat.wakeup(agentId, { source: "on_demand", triggerDetail: "manual", reason: "monitor_smoke",
@@ -90,6 +103,7 @@ try {
await writeFile(join(root, "evidence.json"), JSON.stringify(evidence, null, 2));
console.log(JSON.stringify({ passed: true, evidence: join(root, "evidence.json"), warmReuse: evidence.warmReuse }));
} finally {
await lifecycle.stop();
await writeFile(join(root, "run-records.json"), JSON.stringify(await readRuns(), null, 2));
await closeIdleWarmNativeSessionsForRestart();
runnerPrpWebSocketInternals.resetForTests();
@@ -2,6 +2,7 @@
* Uses real Codex, disposable database/workspaces, and a private copy of login credentials.
* Writes only content-free evidence to stdout; never runs as part of the unit suite.
*/
import { createAgentLifecycle } from "../src/services/agent-lifecycle.js";
import assert from "node:assert/strict";
import { randomUUID } from "node:crypto";
import { chmod, copyFile, lstat, mkdir, mkdtemp, readdir, readFile, rm, writeFile } from "node:fs/promises";
@@ -63,7 +64,7 @@ try {
let result;
if (mode === "legacy") {
await server.db.update(heartbeatRuns).set({ runtimeMode: "legacy", nativeIssueId: null }).where(eq(heartbeatRuns.id, f.runId));
await server.db.update(agents).set({ adapterType: "codex_local" }).where(eq(agents.id, f.agentId));
await createAgentLifecycle(server.db).updateConfiguration(f.agentId, { adapterType: "codex_local" });
result = await executeLegacy({
runId: f.runId,
agent: { id: f.agentId, companyId: f.companyId, name: "Feedback smoke", adapterType: "codex_local", adapterConfig: {} },