Project Runner PRP events into task chat

This commit is contained in:
Dotta committed 2026-08-21 08:36:00 -05:00
1 parent 00b9012a28
commit d2c709ed19
6 files changed
+83 -5

No files matched your search

+1
View File
@@ -16171,6 +16171,7 @@ export function heartbeatService(db: Db, options: HeartbeatServiceOptions = {})
leaseOwner: runOptions.nativeLeaseOwner,
backend: options.nativeSessionBackendFactory?.(nativeExecution),
useRunnerd: agent.adapterType === "paperclip_runner",
onLog,
onSpawn: async (meta) => {
await persistRunProcessMetadata(run.id, meta);
},
@@ -247,6 +247,7 @@ export async function executePaperclipNativeSession(input: {
/** Test seam at the provider boundary; production always uses the package Codex backend. */
backend?: NativeSessionBackend;
useRunnerd?: boolean;
onLog?: (stream: "stdout" | "stderr", chunk: string) => Promise<void>;
}): Promise<AdapterExecutionResult> {
const leaseOwner = input.leaseOwner ?? `${input.runnerInstanceId}:${randomUUID()}`;
const leaseNow = new Date();
@@ -293,6 +294,10 @@ export async function executePaperclipNativeSession(input: {
completionContractSha256: input.execution.completionContract.sha256,
sourceInstanceId: input.runnerInstanceId,
controlPlaneSourceInstanceId: controlPlaneInstanceId,
}, {
onCommittedEvent: input.onLog
? async (event) => input.onLog!("stdout", `${JSON.stringify({ type: "paperclip.prp.event", event })}\n`)
: undefined,
});
let native: Awaited<ReturnType<typeof executeNativeSession>>;
try {
@@ -66,10 +66,14 @@ export class PaperclipControlPlanePort implements ControlPlanePort {
readonly #db: Db;
readonly #binding: PaperclipControlPlaneBinding;
#sessionId: string | null = null;
readonly #onCommittedEvent?: (event: PrpEvent) => Promise<void>;
constructor(db: Db, binding: PaperclipControlPlaneBinding) {
constructor(db: Db, binding: PaperclipControlPlaneBinding, options: {
onCommittedEvent?: (event: PrpEvent) => Promise<void>;
} = {}) {
this.#db = db;
this.#binding = structuredClone(binding);
this.#onCommittedEvent = options.onCommittedEvent;
}
async openRun(input: OpenControlPlaneRunInput): Promise<void> {
@@ -190,6 +194,7 @@ export class PaperclipControlPlanePort implements ControlPlanePort {
canonicalPayload: event as unknown as Record<string, unknown>,
},
});
if (persisted.disposition === "committed") await this.#onCommittedEvent?.(event);
return {
cursor: persisted.row.seq,
highestContiguousSourceSeq: persisted.highestContiguousSourceSeq,