@oyasmi/pipiclaw 0.9.5-beta.2 → 0.9.5-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +9 -11
- package/README.md +9 -11
- package/dist/agent/channel-runner.d.ts +12 -24
- package/dist/agent/channel-runner.js +74 -30
- package/dist/agent/maintenance-context.d.ts +2 -0
- package/dist/agent/maintenance-context.js +15 -0
- package/dist/agent/prompt/sections.js +8 -6
- package/dist/agent/prompt/types.d.ts +1 -1
- package/dist/agent/runner-factory.js +1 -1
- package/dist/agent/session/command-extension.js +11 -0
- package/dist/agent/session/compaction-summary.js +6 -2
- package/dist/agent/session/execution-trace.d.ts +14 -0
- package/dist/agent/session/execution-trace.js +57 -0
- package/dist/agent/session/session-events.d.ts +2 -7
- package/dist/agent/session/session-events.js +35 -12
- package/dist/agent/session/session-host.d.ts +12 -22
- package/dist/agent/session/session-host.js +46 -65
- package/dist/agent/turn/task-digest.d.ts +1 -2
- package/dist/agent/turn/task-digest.js +33 -33
- package/dist/agent/turn/turn-context.d.ts +1 -1
- package/dist/agent/turn/turn-context.js +1 -1
- package/dist/agent/turn/turn-finish.d.ts +2 -2
- package/dist/agent/turn/turn-finish.js +3 -2
- package/dist/agent/turn/turn-pipeline.d.ts +4 -2
- package/dist/agent/turn/turn-pipeline.js +33 -5
- package/dist/agent/types.d.ts +64 -14
- package/dist/agent/types.js +3 -0
- package/dist/app/home.js +3 -4
- package/dist/channel/channel-event.d.ts +4 -12
- package/dist/channel/ingress.d.ts +1 -9
- package/dist/channel/store.d.ts +1 -1
- package/dist/commands/catalog.js +25 -19
- package/dist/commands/router.d.ts +5 -2
- package/dist/commands/router.js +9 -4
- package/dist/config/settings.d.ts +5 -12
- package/dist/config/settings.js +0 -7
- package/dist/config/tools.d.ts +2 -2
- package/dist/config/tools.js +2 -2
- package/dist/dingtalk/bot.d.ts +2 -0
- package/dist/dingtalk/bot.js +4 -0
- package/dist/dingtalk/cards.d.ts +7 -0
- package/dist/dingtalk/cards.js +32 -2
- package/dist/dingtalk/delivery.d.ts +4 -1
- package/dist/dingtalk/delivery.js +104 -191
- package/dist/dingtalk/progress.d.ts +41 -6
- package/dist/dingtalk/progress.js +173 -16
- package/dist/file-store.d.ts +4 -0
- package/dist/file-store.js +6 -1
- package/dist/jobs/completion-observer.d.ts +20 -0
- package/dist/jobs/completion-observer.js +107 -0
- package/dist/jobs/completion-signal.d.ts +9 -0
- package/dist/jobs/completion-signal.js +32 -0
- package/dist/jobs/completion-wake.d.ts +1 -1
- package/dist/jobs/completion-wake.js +2 -13
- package/dist/jobs/manager.d.ts +11 -29
- package/dist/jobs/manager.js +103 -176
- package/dist/jobs/probe.d.ts +3 -0
- package/dist/jobs/probe.js +42 -0
- package/dist/jobs/record.d.ts +3 -6
- package/dist/jobs/runtime.d.ts +28 -0
- package/dist/jobs/runtime.js +69 -0
- package/dist/memory/boundary-work.d.ts +2 -0
- package/dist/memory/boundary-work.js +79 -37
- package/dist/memory/commands.js +4 -1
- package/dist/memory/index-budget.js +18 -15
- package/dist/memory/journal.js +2 -1
- package/dist/memory/lifecycle.d.ts +4 -8
- package/dist/memory/lifecycle.js +21 -51
- package/dist/memory/reflect-job.d.ts +0 -6
- package/dist/memory/reflect-job.js +13 -34
- package/dist/memory/reflect.d.ts +4 -0
- package/dist/memory/reflect.js +32 -5
- package/dist/memory/review-log.d.ts +13 -0
- package/dist/memory/review-log.js +49 -0
- package/dist/memory/search.js +7 -4
- package/dist/memory/source-window.d.ts +18 -1
- package/dist/memory/source-window.js +59 -9
- package/dist/memory/store.d.ts +2 -0
- package/dist/memory/store.js +45 -13
- package/dist/playbooks/agent-delegation.md +10 -4
- package/dist/playbooks/background-jobs.md +4 -4
- package/dist/playbooks/event-scheduling.md +2 -2
- package/dist/playbooks/memory-and-learning.md +3 -3
- package/dist/playbooks/outbound-media.md +2 -2
- package/dist/playbooks/runtime-orientation.md +10 -6
- package/dist/playbooks/task-lead.md +54 -33
- package/dist/runtime/bootstrap.d.ts +11 -24
- package/dist/runtime/bootstrap.js +92 -59
- package/dist/runtime/channel-queue.d.ts +2 -0
- package/dist/runtime/channel-queue.js +5 -1
- package/dist/runtime/durable-dispatch.d.ts +7 -0
- package/dist/runtime/durable-dispatch.js +66 -7
- package/dist/runtime/ingress-busy.d.ts +1 -2
- package/dist/runtime/ingress-busy.js +2 -35
- package/dist/runtime/ingress-commands.d.ts +1 -1
- package/dist/runtime/ingress-commands.js +28 -20
- package/dist/runtime/ingress-deps.d.ts +4 -7
- package/dist/runtime/ingress.js +23 -13
- package/dist/runtime/shutdown.d.ts +1 -1
- package/dist/runtime/shutdown.js +2 -2
- package/dist/runtime/task-close.d.ts +4 -0
- package/dist/runtime/task-close.js +102 -0
- package/dist/runtime/task-control.d.ts +34 -0
- package/dist/runtime/task-control.js +225 -0
- package/dist/runtime/task-input.d.ts +13 -0
- package/dist/runtime/task-input.js +129 -0
- package/dist/runtime/task-lane-types.d.ts +123 -0
- package/dist/runtime/task-lane-types.js +14 -0
- package/dist/runtime/task-lane.d.ts +99 -0
- package/dist/runtime/task-lane.js +703 -0
- package/dist/runtime/task-pending.d.ts +8 -0
- package/dist/runtime/task-pending.js +40 -0
- package/dist/runtime/task-spawn.d.ts +4 -4
- package/dist/runtime/task-spawn.js +4 -4
- package/dist/runtime/task-step.d.ts +32 -0
- package/dist/runtime/task-step.js +276 -0
- package/dist/runtime/turn-run.d.ts +4 -16
- package/dist/runtime/turn-run.js +17 -155
- package/dist/runtime/wake-coalescing.d.ts +1 -3
- package/dist/runtime/wake-coalescing.js +2 -4
- package/dist/shared/format.d.ts +0 -6
- package/dist/shared/format.js +0 -17
- package/dist/shared/host-process.d.ts +2 -0
- package/dist/shared/host-process.js +16 -1
- package/dist/shared/jsonl-appender.d.ts +5 -0
- package/dist/shared/jsonl-appender.js +25 -2
- package/dist/skills/catalog.d.ts +9 -0
- package/dist/skills/catalog.js +34 -0
- package/dist/skills/commands.d.ts +3 -12
- package/dist/skills/commands.js +36 -22
- package/dist/skills/loader.d.ts +2 -31
- package/dist/skills/loader.js +101 -68
- package/dist/skills/roots.d.ts +12 -0
- package/dist/skills/roots.js +18 -0
- package/dist/skills/types.d.ts +24 -0
- package/dist/skills/types.js +1 -0
- package/dist/subagents/completion-wake.js +0 -10
- package/dist/subagents/discovery.d.ts +1 -1
- package/dist/subagents/discovery.js +10 -16
- package/dist/subagents/dispatch.js +8 -16
- package/dist/subagents/external/cursor-cli.d.ts +2 -0
- package/dist/subagents/external/cursor-cli.js +256 -0
- package/dist/subagents/external/harness.d.ts +5 -5
- package/dist/subagents/external/reconciliation.d.ts +7 -0
- package/dist/subagents/external/reconciliation.js +105 -0
- package/dist/subagents/external/recovery.d.ts +20 -0
- package/dist/subagents/external/recovery.js +71 -0
- package/dist/subagents/external/registry.js +2 -0
- package/dist/subagents/external/role-warnings.d.ts +17 -0
- package/dist/subagents/external/role-warnings.js +42 -0
- package/dist/subagents/external/run.js +18 -22
- package/dist/subagents/format.d.ts +1 -1
- package/dist/subagents/format.js +1 -1
- package/dist/subagents/grace.d.ts +2 -2
- package/dist/subagents/grace.js +3 -3
- package/dist/subagents/internal/run.js +7 -5
- package/dist/subagents/internal/worker.js +31 -2
- package/dist/subagents/result.js +2 -3
- package/dist/subagents/run-record.d.ts +4 -7
- package/dist/subagents/run-record.js +2 -2
- package/dist/subagents/runs.d.ts +33 -46
- package/dist/subagents/runs.js +126 -245
- package/dist/subagents/task-settlement.d.ts +3 -0
- package/dist/subagents/task-settlement.js +20 -0
- package/dist/subagents/types.d.ts +1 -2
- package/dist/subagents/workspace-summary.js +5 -1
- package/dist/tasks/archive.d.ts +11 -0
- package/dist/tasks/archive.js +141 -0
- package/dist/tasks/board.d.ts +5 -12
- package/dist/tasks/board.js +4 -30
- package/dist/tasks/bound-work.d.ts +12 -6
- package/dist/tasks/bound-work.js +37 -24
- package/dist/tasks/brief.d.ts +38 -14
- package/dist/tasks/brief.js +128 -70
- package/dist/tasks/budget.d.ts +3 -3
- package/dist/tasks/budget.js +9 -4
- package/dist/tasks/commands.d.ts +14 -9
- package/dist/tasks/commands.js +190 -121
- package/dist/tasks/completion.d.ts +12 -0
- package/dist/tasks/completion.js +35 -0
- package/dist/tasks/contract.d.ts +8 -17
- package/dist/tasks/contract.js +41 -43
- package/dist/tasks/control.d.ts +138 -0
- package/dist/tasks/control.js +1 -0
- package/dist/tasks/create.d.ts +1 -1
- package/dist/tasks/create.js +3 -3
- package/dist/tasks/delivery.d.ts +24 -0
- package/dist/tasks/delivery.js +221 -0
- package/dist/tasks/file-mutation.d.ts +5 -0
- package/dist/tasks/file-mutation.js +38 -0
- package/dist/tasks/frontmatter.d.ts +43 -28
- package/dist/tasks/frontmatter.js +83 -40
- package/dist/tasks/input-receipts.d.ts +7 -0
- package/dist/tasks/input-receipts.js +60 -0
- package/dist/tasks/loop-log.d.ts +147 -28
- package/dist/tasks/loop-log.js +239 -28
- package/dist/tasks/receipts.d.ts +19 -0
- package/dist/tasks/receipts.js +48 -0
- package/dist/tasks/state.d.ts +93 -0
- package/dist/tasks/state.js +156 -0
- package/dist/tasks/store.d.ts +81 -49
- package/dist/tasks/store.js +244 -147
- package/dist/tools/bash.d.ts +3 -5
- package/dist/tools/bash.js +8 -22
- package/dist/tools/contract/details.d.ts +6 -6
- package/dist/tools/contract/details.js +6 -6
- package/dist/tools/contract/execution-trace.d.ts +4 -0
- package/dist/tools/contract/execution-trace.js +23 -0
- package/dist/tools/contract/presentation.js +6 -2
- package/dist/tools/edit.d.ts +1 -0
- package/dist/tools/edit.js +45 -42
- package/dist/tools/index.d.ts +8 -12
- package/dist/tools/index.js +16 -6
- package/dist/tools/memory-manage.js +8 -1
- package/dist/tools/registry.d.ts +7 -11
- package/dist/tools/registry.js +52 -25
- package/dist/tools/skill.d.ts +2 -2
- package/dist/tools/skill.js +24 -10
- package/dist/tools/subagent-manage.js +7 -4
- package/dist/tools/subagent.d.ts +0 -2
- package/dist/tools/subagent.js +2 -7
- package/dist/tools/task-manage/control-tools.d.ts +4 -0
- package/dist/tools/task-manage/control-tools.js +65 -0
- package/dist/tools/task-manage/create.js +2 -1
- package/dist/tools/task-manage/factory.d.ts +12 -6
- package/dist/tools/task-manage/factory.js +72 -57
- package/dist/tools/task-manage/lifecycle.d.ts +7 -12
- package/dist/tools/task-manage/lifecycle.js +118 -66
- package/dist/tools/task-manage/log-view.js +8 -5
- package/dist/tools/task-manage/schema.d.ts +21 -26
- package/dist/tools/task-manage/schema.js +29 -35
- package/dist/tools/task-manage/shared.d.ts +8 -39
- package/dist/tools/task-manage/shared.js +19 -68
- package/dist/tools/task-manage/step-tools.d.ts +5 -0
- package/dist/tools/task-manage/step-tools.js +103 -0
- package/dist/tools/task-manage/types.d.ts +25 -18
- package/dist/tools/write-content.d.ts +1 -0
- package/dist/tools/write-content.js +6 -1
- package/dist/tools/write.d.ts +1 -0
- package/dist/tools/write.js +1 -0
- package/dist/usage/ledger.d.ts +4 -4
- package/dist/usage/render.js +2 -2
- package/dist/web/search-providers.js +0 -33
- package/dist/webapi/request-policy.js +1 -1
- package/examples/sub-agents/README.md +23 -16
- package/examples/sub-agents/agents/claude-high.md +1 -1
- package/examples/sub-agents/agents/claude-main.md +1 -1
- package/examples/sub-agents/agents/codex-flash.md +1 -1
- package/examples/sub-agents/agents/codex-high.md +1 -1
- package/examples/sub-agents/agents/codex-main.md +4 -4
- package/examples/sub-agents/agents/cursor-high.md +22 -0
- package/examples/sub-agents/agents/cursor-main.md +22 -0
- package/examples/sub-agents/agents/glm-flash.md +1 -1
- package/examples/sub-agents/agents/glm-high.md +2 -2
- package/examples/sub-agents/agents/scout.md +30 -0
- package/package.json +6 -6
- package/dist/runtime/task-driver.d.ts +0 -116
- package/dist/runtime/task-driver.js +0 -443
- package/dist/runtime/task-wake.d.ts +0 -48
- package/dist/runtime/task-wake.js +0 -32
- package/dist/shared/wake-claim.d.ts +0 -23
- package/dist/shared/wake-claim.js +0 -26
- package/dist/skills/validation.d.ts +0 -8
- package/dist/skills/validation.js +0 -91
- package/dist/skills/workspace.d.ts +0 -33
- package/dist/skills/workspace.js +0 -116
- package/dist/tasks/steer.d.ts +0 -8
- package/dist/tasks/steer.js +0 -81
- package/dist/tasks/ticket.d.ts +0 -71
- package/dist/tasks/ticket.js +0 -138
- package/dist/tools/task-manage/step-end.d.ts +0 -11
- package/dist/tools/task-manage/step-end.js +0 -117
|
@@ -3,7 +3,7 @@ import type { SubAgentThinkingLevel } from "../discovery.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* The harness adapter seam (spec 040, D4). Every external run is reduced to the same process
|
|
5
5
|
* model (D3: one prompt, one short-lived process); what differs between `claude-code`,
|
|
6
|
-
* `codex-cli`, and `exec` is only argv assembly and stdout parsing, and that is exactly what this
|
|
6
|
+
* `codex-cli`, `cursor-cli`, and `exec` is only argv assembly and stdout parsing, and that is exactly what this
|
|
7
7
|
* interface covers. It carries no state machine of its own — `runs.ts` owns that.
|
|
8
8
|
*/
|
|
9
9
|
export interface ExternalInvocationInput {
|
|
@@ -26,7 +26,7 @@ export interface ExternalInvocationInput {
|
|
|
26
26
|
export interface BuildInvocationResult {
|
|
27
27
|
executable: string;
|
|
28
28
|
args: string[];
|
|
29
|
-
/** Whether this harness can be continued later via `resumeSessionId` (claude-code/codex-cli). */
|
|
29
|
+
/** Whether this harness can be continued later via `resumeSessionId` (claude-code/codex-cli/cursor-cli). */
|
|
30
30
|
resumable: boolean;
|
|
31
31
|
/**
|
|
32
32
|
* claude-code only (D4): a session id it picked and passed via `--session-id` *before* running,
|
|
@@ -50,9 +50,9 @@ export interface ExternalOutcome {
|
|
|
50
50
|
/** The harness's own session/thread id, captured for a later `resume` even if this run failed midway. */
|
|
51
51
|
sessionId?: string;
|
|
52
52
|
usage?: Partial<UsageTotals>;
|
|
53
|
-
/** `exec`
|
|
53
|
+
/** `cursor-cli`/`exec` are always false: neither reports tokens. */
|
|
54
54
|
usageKnown: boolean;
|
|
55
|
-
/** `codex-cli`/`exec` are always false:
|
|
55
|
+
/** `cursor-cli`/`codex-cli`/`exec` are always false: none of them reports a cost field. */
|
|
56
56
|
costKnown: boolean;
|
|
57
57
|
stderrTail?: string;
|
|
58
58
|
errorMessage?: string;
|
|
@@ -65,7 +65,7 @@ export interface ParseOutcomeInput {
|
|
|
65
65
|
stderrTail?: string;
|
|
66
66
|
}
|
|
67
67
|
export interface ExternalHarness {
|
|
68
|
-
readonly id: "claude-code" | "codex-cli" | "exec";
|
|
68
|
+
readonly id: "claude-code" | "codex-cli" | "cursor-cli" | "exec";
|
|
69
69
|
/**
|
|
70
70
|
* Spec 042 D12: bumped by hand whenever this adapter's `parseOutcome` schema assumptions
|
|
71
71
|
* change. Persisted on the run and shown by `/subagents show`, so a failure caused by upstream
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RunRecord, SettleInput } from "../run-record.js";
|
|
2
|
+
type Settle = (runId: string, input: SettleInput, options: {
|
|
3
|
+
announce: boolean;
|
|
4
|
+
}) => Promise<void>;
|
|
5
|
+
export declare function processIdentity(record: RunRecord): Promise<"same" | "different" | "unknown">;
|
|
6
|
+
export declare function reconcileExternalRun(record: RunRecord, settle: Settle, active: () => boolean): Promise<void>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { stat } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import * as log from "../../log.js";
|
|
4
|
+
import { isProcessAlive, isProcessGroupAlive, processGroupQuiescent, readProcessStartTime, reapProcessGroup, } from "../../shared/host-process.js";
|
|
5
|
+
import { finalizeExternalRun } from "./settlement.js";
|
|
6
|
+
export async function processIdentity(record) {
|
|
7
|
+
if (!record.pid || !record.pidStartedAt)
|
|
8
|
+
return "unknown";
|
|
9
|
+
const current = await readProcessStartTime(record.pid);
|
|
10
|
+
return !current ? "unknown" : current === record.pidStartedAt ? "same" : "different";
|
|
11
|
+
}
|
|
12
|
+
export async function reconcileExternalRun(record, settle, active) {
|
|
13
|
+
if (!record.pid) {
|
|
14
|
+
await settle(record.runId, {
|
|
15
|
+
status: "lost",
|
|
16
|
+
failureReason: "No pid was ever recorded for this run; it cannot be proven to have started.",
|
|
17
|
+
usage: record.usage,
|
|
18
|
+
usageKnown: record.usageKnown,
|
|
19
|
+
costKnown: record.costKnown,
|
|
20
|
+
turns: record.turns ?? 0,
|
|
21
|
+
toolCalls: record.toolCalls ?? 0,
|
|
22
|
+
durationMs: Date.now() - record.startedAt,
|
|
23
|
+
durationEstimated: true,
|
|
24
|
+
outputText: "",
|
|
25
|
+
}, { announce: true });
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (isProcessAlive(record.pid) && (await processIdentity(record)) !== "different") {
|
|
29
|
+
return; // Still genuinely running; nothing to reconcile yet.
|
|
30
|
+
}
|
|
31
|
+
if (!active())
|
|
32
|
+
return;
|
|
33
|
+
log.logInfoEvent("subagent.process.observed", "External process completion observed", {
|
|
34
|
+
fields: { runId: record.runId, taskId: record.taskId, observer: "adopted", deskDir: record.deskDir },
|
|
35
|
+
});
|
|
36
|
+
// A dead leader can leave writing descendants. Reap its group before releasing the lease.
|
|
37
|
+
// A reused leader is never signalled, including via its (possibly reused) group id.
|
|
38
|
+
if (!isProcessAlive(record.pid)) {
|
|
39
|
+
await reapProcessGroup(record.pid);
|
|
40
|
+
if (!(await processGroupQuiescent(record.pid))) {
|
|
41
|
+
log.logWarn("subagent.recovery.group_unconfirmed", "Adopted process cleanup failed", {
|
|
42
|
+
fields: { runId: record.runId, pid: record.pid },
|
|
43
|
+
reason: "Process group quiescence could not be confirmed",
|
|
44
|
+
});
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else if (isProcessGroupAlive(record.pid)) {
|
|
49
|
+
log.logWarn("subagent.recovery.group_unconfirmed", "Adopted process cleanup failed", {
|
|
50
|
+
fields: { runId: record.runId, pid: record.pid },
|
|
51
|
+
reason: "PID was reused and process group ownership cannot be confirmed",
|
|
52
|
+
});
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (!active())
|
|
56
|
+
return;
|
|
57
|
+
if (!record.harness) {
|
|
58
|
+
// Defensive only: external runs always get a harness at register() time (spec 040 D1).
|
|
59
|
+
await settle(record.runId, {
|
|
60
|
+
status: "failed",
|
|
61
|
+
failureReason: "Run has no recorded harness; cannot judge it.",
|
|
62
|
+
usage: record.usage,
|
|
63
|
+
usageKnown: record.usageKnown,
|
|
64
|
+
costKnown: record.costKnown,
|
|
65
|
+
turns: record.turns ?? 0,
|
|
66
|
+
toolCalls: record.toolCalls ?? 0,
|
|
67
|
+
durationMs: Date.now() - record.startedAt,
|
|
68
|
+
durationEstimated: true,
|
|
69
|
+
outputText: "",
|
|
70
|
+
}, { announce: true });
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
// Duration can only be estimated post-restart: the artifact file's own mtime is the closest
|
|
74
|
+
// proxy for "when the process last wrote something" (D1); wall clock from the last known
|
|
75
|
+
// process start is the fallback when the file is missing (e.g. already GC'd).
|
|
76
|
+
const processStartedAt = record.processStartedAt ?? record.startedAt;
|
|
77
|
+
let durationMs = Date.now() - processStartedAt;
|
|
78
|
+
try {
|
|
79
|
+
const eventsStat = await stat(join(record.artifactDir, "events.jsonl"));
|
|
80
|
+
durationMs = eventsStat.mtimeMs - processStartedAt;
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
// No events file (or already GC'd) — fall back to the wall-clock estimate above.
|
|
84
|
+
}
|
|
85
|
+
const maxWallTimeSec = record.maxWallTimeSec ??
|
|
86
|
+
(record.deadlineAt ? Math.round((record.deadlineAt - record.startedAt) / 1000) : undefined);
|
|
87
|
+
if (!active())
|
|
88
|
+
return;
|
|
89
|
+
log.logEvent("debug", "subagent.finalizer.started", "External run finalizer started", {
|
|
90
|
+
fields: { runId: record.runId, taskId: record.taskId, observer: "adopted", deskDir: record.deskDir },
|
|
91
|
+
});
|
|
92
|
+
await finalizeExternalRun({
|
|
93
|
+
harnessId: record.harness,
|
|
94
|
+
purpose: record.purpose,
|
|
95
|
+
workingDirectory: record.workingDirectory,
|
|
96
|
+
artifactDir: record.artifactDir,
|
|
97
|
+
exitCode: undefined,
|
|
98
|
+
durationMs: Math.max(0, durationMs),
|
|
99
|
+
durationEstimated: true,
|
|
100
|
+
terminationReason: record.terminationReason,
|
|
101
|
+
maxWallTimeSec,
|
|
102
|
+
mutates: record.mutates,
|
|
103
|
+
workspaceBaseline: record.workspaceBaseline,
|
|
104
|
+
}, (settleInput, options) => (active() ? settle(record.runId, settleInput, options) : Promise.resolve()), { announce: record.terminationReason !== "cancelled" });
|
|
105
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Scheduling only: the manager remains the owner of reconciliation and settlement. */
|
|
2
|
+
export declare class AdoptedRunObserver {
|
|
3
|
+
private readonly current;
|
|
4
|
+
private readonly check;
|
|
5
|
+
private readonly failed;
|
|
6
|
+
private readonly intervalMs;
|
|
7
|
+
private readonly entries;
|
|
8
|
+
private timer?;
|
|
9
|
+
private stopped;
|
|
10
|
+
constructor(current: (id: string) => {
|
|
11
|
+
status: string;
|
|
12
|
+
deadlineAt?: number;
|
|
13
|
+
} | undefined, check: (id: string) => Promise<void>, failed: (id: string, error: unknown) => void, intervalMs?: number);
|
|
14
|
+
add(id: string): void;
|
|
15
|
+
remove(id: string): void;
|
|
16
|
+
stop(): void;
|
|
17
|
+
private next;
|
|
18
|
+
private schedule;
|
|
19
|
+
private tick;
|
|
20
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/** Scheduling only: the manager remains the owner of reconciliation and settlement. */
|
|
2
|
+
export class AdoptedRunObserver {
|
|
3
|
+
constructor(current, check, failed, intervalMs = 10_000) {
|
|
4
|
+
this.current = current;
|
|
5
|
+
this.check = check;
|
|
6
|
+
this.failed = failed;
|
|
7
|
+
this.intervalMs = intervalMs;
|
|
8
|
+
this.entries = new Map();
|
|
9
|
+
this.stopped = false;
|
|
10
|
+
}
|
|
11
|
+
add(id) {
|
|
12
|
+
if (this.stopped || this.entries.has(id))
|
|
13
|
+
return;
|
|
14
|
+
this.entries.set(id, { due: this.next(id), checking: false });
|
|
15
|
+
this.schedule();
|
|
16
|
+
}
|
|
17
|
+
remove(id) {
|
|
18
|
+
this.entries.delete(id);
|
|
19
|
+
this.schedule();
|
|
20
|
+
}
|
|
21
|
+
stop() {
|
|
22
|
+
this.stopped = true;
|
|
23
|
+
clearTimeout(this.timer);
|
|
24
|
+
this.timer = undefined;
|
|
25
|
+
this.entries.clear();
|
|
26
|
+
}
|
|
27
|
+
next(id) {
|
|
28
|
+
const now = Date.now();
|
|
29
|
+
const deadline = this.current(id)?.deadlineAt;
|
|
30
|
+
// An expired deadline is checked each cycle, without a busy loop on unknown identity.
|
|
31
|
+
return deadline && deadline > now ? Math.min(now + this.intervalMs, deadline) : now + this.intervalMs;
|
|
32
|
+
}
|
|
33
|
+
schedule() {
|
|
34
|
+
clearTimeout(this.timer);
|
|
35
|
+
this.timer = undefined;
|
|
36
|
+
if (this.stopped)
|
|
37
|
+
return;
|
|
38
|
+
const pending = [...this.entries.values()].filter((entry) => !entry.checking);
|
|
39
|
+
if (!pending.length)
|
|
40
|
+
return;
|
|
41
|
+
this.timer = setTimeout(() => this.tick(), Math.max(0, Math.min(...pending.map((entry) => entry.due)) - Date.now()));
|
|
42
|
+
this.timer.unref?.();
|
|
43
|
+
}
|
|
44
|
+
tick() {
|
|
45
|
+
if (this.stopped)
|
|
46
|
+
return;
|
|
47
|
+
for (const [id, entry] of this.entries) {
|
|
48
|
+
if (entry.checking || entry.due > Date.now())
|
|
49
|
+
continue;
|
|
50
|
+
if (this.current(id)?.status !== "running") {
|
|
51
|
+
this.entries.delete(id);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
entry.checking = true;
|
|
55
|
+
void this.check(id)
|
|
56
|
+
.catch((error) => this.failed(id, error))
|
|
57
|
+
.finally(() => {
|
|
58
|
+
if (this.stopped || this.entries.get(id) !== entry)
|
|
59
|
+
return;
|
|
60
|
+
if (this.current(id)?.status !== "running")
|
|
61
|
+
this.entries.delete(id);
|
|
62
|
+
else {
|
|
63
|
+
entry.checking = false;
|
|
64
|
+
entry.due = this.next(id);
|
|
65
|
+
}
|
|
66
|
+
this.schedule();
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
this.schedule();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { claudeCodeHarness } from "./claude-code.js";
|
|
2
2
|
import { codexCliHarness } from "./codex-cli.js";
|
|
3
|
+
import { cursorCliHarness } from "./cursor-cli.js";
|
|
3
4
|
import { execHarness } from "./exec.js";
|
|
4
5
|
const harnesses = {
|
|
5
6
|
"codex-cli": codexCliHarness,
|
|
6
7
|
"claude-code": claudeCodeHarness,
|
|
8
|
+
"cursor-cli": cursorCliHarness,
|
|
7
9
|
exec: execHarness,
|
|
8
10
|
};
|
|
9
11
|
export function getExternalHarness(id) {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Non-fatal external-role warnings (spec 042 D4/D10, spec 066 D6). The role still loads.
|
|
3
|
+
* This file stays free of discovery and harness imports so `discovery.ts` can call it without a cycle.
|
|
4
|
+
*/
|
|
5
|
+
export interface ExternalRoleWarningInput {
|
|
6
|
+
/** Role filename, so a warning can be traced back to the file that produced it. */
|
|
7
|
+
entryName: string;
|
|
8
|
+
harness: string;
|
|
9
|
+
command: string;
|
|
10
|
+
mutates: "read" | "write";
|
|
11
|
+
/** Resolved memory mode. Anything other than `none` discloses desk memory to the external process. */
|
|
12
|
+
memory: string;
|
|
13
|
+
/** True when frontmatter `model` is set. External models are never taken from the invocation. */
|
|
14
|
+
modelConfigured: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** Join every applicable warning. An unlucky combination must not hide one of them. */
|
|
17
|
+
export declare function externalRoleWarning(input: ExternalRoleWarningInput): string | undefined;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { splitShellWords } from "../../shared/shell-words.js";
|
|
2
|
+
const FORCE_TOKENS = new Set(["-f", "--force", "--yolo"]);
|
|
3
|
+
function hasWorktreeToken(token) {
|
|
4
|
+
return token === "--worktree" || token === "-w" || token.startsWith("--worktree=");
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Cursor print mode does not write files unless the command itself opts in, and a worktree flag
|
|
8
|
+
* writes somewhere the workspace lease does not cover. Token-based, not a substring search: a path
|
|
9
|
+
* that happens to contain `--force` is not a permission flag.
|
|
10
|
+
*/
|
|
11
|
+
function cursorCommandWarnings(input) {
|
|
12
|
+
if (input.harness !== "cursor-cli")
|
|
13
|
+
return [];
|
|
14
|
+
const tokens = splitShellWords(input.command);
|
|
15
|
+
const hasForce = tokens.some((token) => FORCE_TOKENS.has(token));
|
|
16
|
+
const warnings = [];
|
|
17
|
+
if (input.mutates === "write" && !hasForce) {
|
|
18
|
+
warnings.push(`${input.entryName}: print mode does not write changes to files unless command includes -f, --force, or --yolo`);
|
|
19
|
+
}
|
|
20
|
+
if (input.mutates === "read" && hasForce) {
|
|
21
|
+
warnings.push(`${input.entryName}: command includes -f, --force, or --yolo, so the CLI can modify files and the workspace write lock will not stop it`);
|
|
22
|
+
}
|
|
23
|
+
if (tokens.some(hasWorktreeToken)) {
|
|
24
|
+
warnings.push(`${input.entryName}: --worktree writes under ~/.cursor/worktrees/, outside the delegation working directory, so the workspace write lock does not cover those files`);
|
|
25
|
+
}
|
|
26
|
+
return warnings;
|
|
27
|
+
}
|
|
28
|
+
/** Join every applicable warning. An unlucky combination must not hide one of them. */
|
|
29
|
+
export function externalRoleWarning(input) {
|
|
30
|
+
const warnings = [];
|
|
31
|
+
if (input.memory !== "none") {
|
|
32
|
+
warnings.push(`${input.entryName}: memory: ${input.memory} sends the desk memory index / journal content to this external process`);
|
|
33
|
+
}
|
|
34
|
+
// Substring, matching the historical discovery check: `$MODEL` is a placeholder, not a flag,
|
|
35
|
+
// and may sit inside a larger token (`--model=$MODEL`). `$EFFORT` has no equivalent check
|
|
36
|
+
// because thinkingLevel can be supplied per invocation.
|
|
37
|
+
if (input.command.includes("$MODEL") && !input.modelConfigured) {
|
|
38
|
+
warnings.push(`${input.entryName}: command references $MODEL but no "model" is configured; that argv token will be dropped on every dispatch`);
|
|
39
|
+
}
|
|
40
|
+
warnings.push(...cursorCommandWarnings(input));
|
|
41
|
+
return warnings.length > 0 ? warnings.join("; ") : undefined;
|
|
42
|
+
}
|
|
@@ -345,36 +345,33 @@ export async function launchExternalRun(input) {
|
|
|
345
345
|
// process that later reuses the same number. `undefined` when `ps` is unavailable — restore()
|
|
346
346
|
// treats a conflict as unsafe to signal, while ordinary adoption remains conservative. Run
|
|
347
347
|
// alongside the D12 CLI-version probe — neither depends on the other, and both are best-effort.
|
|
348
|
-
const
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
]
|
|
352
|
-
|
|
353
|
-
|
|
348
|
+
const probes = [
|
|
349
|
+
async () => ({ pidStartedAt: await (input.readProcessStartTimeFn ?? readProcessStartTime)(pid) }),
|
|
350
|
+
async () => ({ cliVersion: await (input.probeCliVersionFn ?? probeCliVersion)(invocation.executable) }),
|
|
351
|
+
];
|
|
352
|
+
for (const probe of probes) {
|
|
353
|
+
void Promise.resolve()
|
|
354
|
+
.then(probe)
|
|
355
|
+
.then((info) => runManager.updateLaunchMetadata(input.runId, info, { pid, processStartedAt }))
|
|
356
|
+
.catch((error) => log.logWarn("subagent.launch_probes.failed", "Launch probe failed", {
|
|
354
357
|
reason: errorMessage(error),
|
|
355
358
|
fields: { runId: input.runId },
|
|
356
359
|
}));
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
// The production probes are already best-effort; keep the same property for test seams or
|
|
360
|
-
// a future host implementation and never leave a spawned child unobserved because metadata
|
|
361
|
-
// collection failed.
|
|
362
|
-
log.logWarn("subagent.launch_probes.collect_failed", "Launch probe collection failed", {
|
|
363
|
-
reason: errorMessage(error),
|
|
364
|
-
fields: { runId: input.runId },
|
|
365
|
-
});
|
|
366
|
-
});
|
|
367
|
-
// Deliberately attach the close watcher before waiting for probe metadata. A fast child can exit
|
|
368
|
-
// during that wait; the promise is already listening, and finalization waits for the launch
|
|
369
|
-
// metadata promise so terminal publication still follows the same safe order.
|
|
360
|
+
}
|
|
361
|
+
// Optional diagnostics never gate process cleanup or terminal publication.
|
|
370
362
|
void closePromise.then(async (exitCode) => {
|
|
371
|
-
|
|
363
|
+
log.logInfoEvent("subagent.process.observed", "External process completion observed", {
|
|
364
|
+
fields: { runId: input.runId, taskId: input.taskId, observer: "live" },
|
|
365
|
+
});
|
|
372
366
|
clearTimeout(wallClockTimer);
|
|
373
367
|
// Spec 042 D8: this fires on every exit (normal, cancelled, or timed out) as a backup reap —
|
|
374
368
|
// a cancel/timeout already killed the group via its own call site above. The common case
|
|
375
369
|
// (nothing left) returns immediately with no signal and no wait; only a genuinely lingering
|
|
376
370
|
// descendant (the leader exited before it did) pays the TERM-then-KILL sequence.
|
|
377
371
|
await reapProcessGroup(pid);
|
|
372
|
+
log.logEvent("debug", "subagent.finalizer.started", "External run finalizer started", {
|
|
373
|
+
fields: { runId: input.runId, taskId: input.taskId, observer: "live", deskDir: input.deskDir },
|
|
374
|
+
});
|
|
378
375
|
const durationMs = Date.now() - processStartedAt;
|
|
379
376
|
const terminationReason = runManager.get(input.runId)?.terminationReason;
|
|
380
377
|
// Spec 042 D1: parse whatever the process actually wrote *before* applying a cancel/timeout
|
|
@@ -407,8 +404,7 @@ export async function launchExternalRun(input) {
|
|
|
407
404
|
void killProcessGroup(pid);
|
|
408
405
|
}
|
|
409
406
|
// The dispatching tool call does not wait for the probes: the pid is already durable and the
|
|
410
|
-
// cancel handle installed, so they are diagnostics only.
|
|
411
|
-
// close watcher above) so a run's terminal record carries them.
|
|
407
|
+
// cancel handle installed, so they are diagnostics only.
|
|
412
408
|
return { ok: true };
|
|
413
409
|
function failedSettleInput(reason) {
|
|
414
410
|
return {
|
|
@@ -13,5 +13,5 @@ export declare function elapsedMs(record: RunRecord, now?: number): number;
|
|
|
13
13
|
* mistake it for a precise figure. */
|
|
14
14
|
export declare function formatRunDuration(record: RunRecord, now?: number): string;
|
|
15
15
|
export declare function harnessLabel(record: RunRecord): string;
|
|
16
|
-
/** `undefined` when cost genuinely is not known (e.g. `codex-cli`, `exec`) — never displayed as $0. */
|
|
16
|
+
/** `undefined` when cost genuinely is not known (e.g. `cursor-cli`, `codex-cli`, `exec`) — never displayed as $0. */
|
|
17
17
|
export declare function formatCost(record: RunRecord): string | undefined;
|
package/dist/subagents/format.js
CHANGED
|
@@ -19,7 +19,7 @@ export function formatRunDuration(record, now = Date.now()) {
|
|
|
19
19
|
export function harnessLabel(record) {
|
|
20
20
|
return record.harness ? `${record.runtime}/${record.harness}` : record.runtime;
|
|
21
21
|
}
|
|
22
|
-
/** `undefined` when cost genuinely is not known (e.g. `codex-cli`, `exec`) — never displayed as $0. */
|
|
22
|
+
/** `undefined` when cost genuinely is not known (e.g. `cursor-cli`, `codex-cli`, `exec`) — never displayed as $0. */
|
|
23
23
|
export function formatCost(record) {
|
|
24
24
|
if (!record.costKnown)
|
|
25
25
|
return undefined;
|
|
@@ -15,10 +15,10 @@ export declare function watchAbort(signal: AbortSignal | undefined): {
|
|
|
15
15
|
* placeholder instead of the result (D2). A code constant, not a settings key, per CLAUDE.md's
|
|
16
16
|
* rule for numeric thresholds.
|
|
17
17
|
*/
|
|
18
|
-
export declare const
|
|
18
|
+
export declare const CHAT_SYNC_GRACE_MS = 10000;
|
|
19
19
|
/**
|
|
20
20
|
* Effective sync grace window. A test-only env override (`PIPICLAW_TEST_SUBAGENT_SYNC_GRACE_MS`)
|
|
21
21
|
* lets the deterministic e2e layer exercise the detached-settlement + completion-wake path
|
|
22
|
-
* (spec 048 A14/A15/A16) without a multi-minute wait; production always uses
|
|
22
|
+
* (spec 048 A14/A15/A16) without a multi-minute wait; production always uses the shared ten-second chat window.
|
|
23
23
|
*/
|
|
24
24
|
export declare function resolveSyncGraceMs(override?: number): number;
|
package/dist/subagents/grace.js
CHANGED
|
@@ -43,15 +43,15 @@ export function watchAbort(signal) {
|
|
|
43
43
|
* placeholder instead of the result (D2). A code constant, not a settings key, per CLAUDE.md's
|
|
44
44
|
* rule for numeric thresholds.
|
|
45
45
|
*/
|
|
46
|
-
export const
|
|
46
|
+
export const CHAT_SYNC_GRACE_MS = 10_000;
|
|
47
47
|
/**
|
|
48
48
|
* Effective sync grace window. A test-only env override (`PIPICLAW_TEST_SUBAGENT_SYNC_GRACE_MS`)
|
|
49
49
|
* lets the deterministic e2e layer exercise the detached-settlement + completion-wake path
|
|
50
|
-
* (spec 048 A14/A15/A16) without a multi-minute wait; production always uses
|
|
50
|
+
* (spec 048 A14/A15/A16) without a multi-minute wait; production always uses the shared ten-second chat window.
|
|
51
51
|
*/
|
|
52
52
|
export function resolveSyncGraceMs(override) {
|
|
53
53
|
if (override !== undefined)
|
|
54
54
|
return override;
|
|
55
55
|
const env = Number(process.env.PIPICLAW_TEST_SUBAGENT_SYNC_GRACE_MS);
|
|
56
|
-
return Number.isFinite(env) && env > 0 ? env :
|
|
56
|
+
return Number.isFinite(env) && env > 0 ? env : CHAT_SYNC_GRACE_MS;
|
|
57
57
|
}
|
|
@@ -104,11 +104,13 @@ export async function dispatchInternalRun(input) {
|
|
|
104
104
|
error: error instanceof Error ? error : new Error(String(error)),
|
|
105
105
|
}));
|
|
106
106
|
const abortWatch = watchAbort(signal);
|
|
107
|
-
const raceResult =
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
const raceResult = runContext.taskId
|
|
108
|
+
? "timed-out"
|
|
109
|
+
: await Promise.race([
|
|
110
|
+
outcomePromise,
|
|
111
|
+
sleepUnref(Math.max(0, deadline - now)).then(() => "timed-out"),
|
|
112
|
+
abortWatch.aborted,
|
|
113
|
+
]);
|
|
112
114
|
abortWatch.dispose();
|
|
113
115
|
if (raceResult !== "timed-out" && raceResult !== "aborted") {
|
|
114
116
|
runManager.clearCancelHandle(runContext.runId);
|
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
import { Agent } from "@earendil-works/pi-agent-core";
|
|
6
6
|
import { clampThinkingLevel, streamSimple } from "@earendil-works/pi-ai/compat";
|
|
7
7
|
import { convertToLlm } from "@earendil-works/pi-coding-agent";
|
|
8
|
+
import * as log from "../../log.js";
|
|
8
9
|
import { getJournalDir } from "../../memory/journal.js";
|
|
9
10
|
import { getMemoryDir, getMemoryIndexPath } from "../../memory/store.js";
|
|
10
11
|
import { DEFAULT_SECURITY_CONFIG } from "../../security/config.js";
|
|
12
|
+
import { withExecutionTrace } from "../../tools/contract/execution-trace.js";
|
|
11
13
|
import { describeToolCall } from "../../tools/contract/presentation.js";
|
|
12
14
|
import { addUsage } from "../../usage/totals.js";
|
|
13
15
|
import { DEFAULT_THINKING_LEVEL, withSubAgentsDirWriteDeny, } from "../discovery.js";
|
|
@@ -95,7 +97,19 @@ function filterToolsByName(allTools, names) {
|
|
|
95
97
|
*/
|
|
96
98
|
export function startWorker(input) {
|
|
97
99
|
const { handle, options, config, runContext, scopedExecutor, state, retryBackoff, runManager, emitUpdate } = input;
|
|
98
|
-
|
|
100
|
+
let request = 0;
|
|
101
|
+
let requestStartedAt = 0;
|
|
102
|
+
let firstOutput = false;
|
|
103
|
+
const traceFields = () => ({
|
|
104
|
+
desk: options.runtimeContext.desk,
|
|
105
|
+
channelId: options.runtimeContext.channelId,
|
|
106
|
+
runId: runContext.runId,
|
|
107
|
+
taskId: runContext.taskId,
|
|
108
|
+
generation: runContext.runId,
|
|
109
|
+
request,
|
|
110
|
+
batch: request,
|
|
111
|
+
});
|
|
112
|
+
const availableTools = (options.buildTools ?? buildSubagentTools)(scopedExecutor, config.bashTimeoutSec, options, runContext).map((tool) => withExecutionTrace(tool, traceFields));
|
|
99
113
|
handle.worker =
|
|
100
114
|
options.createWorker?.({
|
|
101
115
|
subAgent: config,
|
|
@@ -117,7 +131,13 @@ export function startWorker(input) {
|
|
|
117
131
|
convertToLlm,
|
|
118
132
|
// Read on every request, so a backup-model switch only has to replace the key.
|
|
119
133
|
getApiKey: async () => state.apiKey,
|
|
120
|
-
streamFn:
|
|
134
|
+
streamFn: (model, context, streamOptions) => {
|
|
135
|
+
request++;
|
|
136
|
+
requestStartedAt = Date.now();
|
|
137
|
+
firstOutput = false;
|
|
138
|
+
log.logEvent("debug", "agent.provider.started", "Provider request started", { fields: traceFields() });
|
|
139
|
+
return streamSimple(model, context, streamOptions);
|
|
140
|
+
},
|
|
121
141
|
});
|
|
122
142
|
handle.wallClockTimer = setTimeout(() => {
|
|
123
143
|
state.failureReason = `Wall time budget exceeded (${config.maxWallTimeSec}s)`;
|
|
@@ -126,11 +146,20 @@ export function startWorker(input) {
|
|
|
126
146
|
handle.worker?.abort();
|
|
127
147
|
}, config.maxWallTimeSec * 1000);
|
|
128
148
|
handle.unsubscribe = handle.worker.subscribe((event) => {
|
|
149
|
+
if (!firstOutput && event.type === "message_update" && event.assistantMessageEvent.type.endsWith("_delta")) {
|
|
150
|
+
firstOutput = true;
|
|
151
|
+
log.logEvent("debug", "agent.provider.output", "Provider first output observed", {
|
|
152
|
+
fields: { ...traceFields(), elapsedMs: Date.now() - requestStartedAt },
|
|
153
|
+
});
|
|
154
|
+
}
|
|
129
155
|
if (event.type === "message_end" && isAssistantMessage(event.message)) {
|
|
130
156
|
state.assistantTurns++;
|
|
131
157
|
addUsage(state.usage, event.message.usage);
|
|
132
158
|
}
|
|
133
159
|
if (event.type === "tool_execution_start") {
|
|
160
|
+
log.logEvent("debug", "agent.tool.preparing", "Tool preparation started", {
|
|
161
|
+
fields: { ...traceFields(), toolCallId: event.toolCallId, tool: event.toolName },
|
|
162
|
+
});
|
|
134
163
|
state.toolCalls++;
|
|
135
164
|
const label = describeToolCall(event.toolName, event.args);
|
|
136
165
|
emitUpdate(formatStatus(config.name, label));
|
package/dist/subagents/result.js
CHANGED
|
@@ -30,9 +30,8 @@ export function formatStatus(agentName, text) {
|
|
|
30
30
|
*/
|
|
31
31
|
export function buildDispatchedText(runId, agentName, runtimeLabel, workingDirectory) {
|
|
32
32
|
return (`[Dispatched] runId=${runId}, agent ${agentName} (${runtimeLabel}), working directory ${workingDirectory}.\n` +
|
|
33
|
-
"Status: running.
|
|
34
|
-
"Finish independent work and dispatches, then end the turn when only waiting remains; do not re-dispatch or poll to wait.
|
|
35
|
-
'Inside a task step, use task_step_end outcome=park with ticket {"kind":"work"}.');
|
|
33
|
+
"Status: running. Whoever dispatched it (this chat, or the task whose step did) will be woken with the result and artifact path once it finishes.\n" +
|
|
34
|
+
"Finish independent work and dispatches, then end the turn when only waiting remains; do not re-dispatch or poll to wait.");
|
|
36
35
|
}
|
|
37
36
|
export function buildFailureText(config, reason, lastAssistantText) {
|
|
38
37
|
const trimmedLastText = lastAssistantText.trim();
|
|
@@ -2,7 +2,7 @@ import type { UsageTotals } from "../usage/totals.js";
|
|
|
2
2
|
import type { WorkspaceBaseline } from "./workspace-summary.js";
|
|
3
3
|
export type RunStatus = "running" | "completed" | "failed" | "cancelled" | "lost";
|
|
4
4
|
export type RunRuntime = "internal" | "external";
|
|
5
|
-
export type RunHarness = "claude-code" | "codex-cli" | "exec";
|
|
5
|
+
export type RunHarness = "claude-code" | "codex-cli" | "cursor-cli" | "exec";
|
|
6
6
|
export type RunMutates = "read" | "write";
|
|
7
7
|
export type RunResolution = {
|
|
8
8
|
kind: "found";
|
|
@@ -33,9 +33,9 @@ export interface PendingSettlement {
|
|
|
33
33
|
}
|
|
34
34
|
export interface RunUsage {
|
|
35
35
|
usage: UsageTotals;
|
|
36
|
-
/** False
|
|
36
|
+
/** False for harnesses that cannot report tokens at all (`cursor-cli`, `exec`). */
|
|
37
37
|
usageKnown: boolean;
|
|
38
|
-
/** False for harnesses that omit a cost field (`codex-cli`, `exec`). */
|
|
38
|
+
/** False for harnesses that omit a cost field (`cursor-cli`, `codex-cli`, `exec`). */
|
|
39
39
|
costKnown: boolean;
|
|
40
40
|
}
|
|
41
41
|
export interface RunRecord extends RunUsage {
|
|
@@ -84,9 +84,6 @@ export interface RunRecord extends RunUsage {
|
|
|
84
84
|
taskAccounted?: boolean;
|
|
85
85
|
/** Set once the completion wake has been hallmarked for delivery; guards against a duplicate wake. */
|
|
86
86
|
wakeEnqueued?: boolean;
|
|
87
|
-
/** Durable one-time relationship between the internally produced wake and task activation (T9). */
|
|
88
|
-
wakeClaimDispatchId?: string;
|
|
89
|
-
wakeConsumedAt?: number;
|
|
90
87
|
pid?: number;
|
|
91
88
|
/** `ps`'s `lstart` for `pid` at launch — the OS-verifiable identity check that tells this
|
|
92
89
|
* process apart from an unrelated one that later reuses the same pid (D10.3). */
|
|
@@ -213,7 +210,7 @@ export declare function randomRunIdSuffix(): string;
|
|
|
213
210
|
/** Strips a leading `run_` (case-insensitive) so `show a1b2c3` and `show run_a1b2c3` resolve
|
|
214
211
|
* the same way — nobody should have to remember whether the prefix is required. */
|
|
215
212
|
export declare function normalizeRunIdQuery(query: string): string;
|
|
216
|
-
/** Settled runs and every runtime-managed artifact are retained together for
|
|
213
|
+
/** Settled runs and every runtime-managed artifact are retained together for 30 days. GC runs
|
|
217
214
|
* daily, so an item can remain for up to one additional sweep interval after this age. */
|
|
218
215
|
export declare const RUN_RETENTION_MS: number;
|
|
219
216
|
export declare const RUN_ARTIFACT_FILENAMES: readonly ["prompt.txt", "system-prompt.txt", "events.jsonl", "stderr.log", "output.md"];
|
|
@@ -32,9 +32,9 @@ export function normalizeRunIdQuery(query) {
|
|
|
32
32
|
const lower = query.trim().toLowerCase();
|
|
33
33
|
return lower.startsWith(RUN_ID_PREFIX) ? lower.slice(RUN_ID_PREFIX.length) : lower;
|
|
34
34
|
}
|
|
35
|
-
/** Settled runs and every runtime-managed artifact are retained together for
|
|
35
|
+
/** Settled runs and every runtime-managed artifact are retained together for 30 days. GC runs
|
|
36
36
|
* daily, so an item can remain for up to one additional sweep interval after this age. */
|
|
37
|
-
export const RUN_RETENTION_MS =
|
|
37
|
+
export const RUN_RETENTION_MS = 30 * 24 * 60 * 60_000;
|
|
38
38
|
export const RUN_ARTIFACT_FILENAMES = [
|
|
39
39
|
"prompt.txt",
|
|
40
40
|
"system-prompt.txt",
|