@oyasmi/pipiclaw 0.9.3 → 0.9.4-beta.2
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/dist/agent/builtin-commands.d.ts +19 -0
- package/dist/agent/builtin-commands.js +80 -0
- package/dist/agent/channel-runner.d.ts +20 -208
- package/dist/agent/channel-runner.js +167 -1188
- package/dist/agent/maintenance-context.d.ts +1 -1
- package/dist/agent/maintenance-context.js +1 -1
- package/dist/agent/prompt/manifest.d.ts +6 -1
- package/dist/agent/prompt/manifest.js +45 -64
- package/dist/agent/prompt/resources.d.ts +3 -0
- package/dist/agent/prompt/resources.js +11 -2
- package/dist/agent/runner-factory.d.ts +1 -43
- package/dist/agent/{command-extension.d.ts → session/command-extension.d.ts} +4 -0
- package/dist/agent/{command-extension.js → session/command-extension.js} +48 -35
- package/dist/agent/{type-guards.d.ts → session/event-guards.d.ts} +2 -2
- package/dist/agent/{type-guards.js → session/event-guards.js} +5 -1
- package/dist/agent/session/model-selection.d.ts +47 -0
- package/dist/agent/session/model-selection.js +99 -0
- package/dist/agent/{session-adapter.d.ts → session/session-adapter.d.ts} +21 -1
- package/dist/agent/session/session-adapter.js +159 -0
- package/dist/agent/{session-events.d.ts → session/session-events.d.ts} +9 -5
- package/dist/agent/{session-events.js → session/session-events.js} +24 -13
- package/dist/agent/session/session-host.d.ts +200 -0
- package/dist/agent/session/session-host.js +621 -0
- package/dist/agent/{session-resource-gate.js → session/session-resource-gate.js} +5 -3
- package/dist/agent/status-render.d.ts +0 -1
- package/dist/agent/status-render.js +4 -16
- package/dist/agent/{context-budget.js → turn/context-budget.js} +5 -1
- package/dist/agent/{progress-formatter.d.ts → turn/progress-formatter.d.ts} +4 -1
- package/dist/agent/{run-queue.d.ts → turn/run-queue.d.ts} +1 -1
- package/dist/agent/{run-queue.js → turn/run-queue.js} +10 -5
- package/dist/{memory → agent/turn}/task-digest.js +4 -4
- package/dist/agent/turn/turn-context.d.ts +14 -0
- package/dist/agent/turn/turn-context.js +64 -0
- package/dist/agent/turn/turn-error.d.ts +31 -0
- package/dist/agent/turn/turn-error.js +68 -0
- package/dist/agent/turn/turn-finish.d.ts +50 -0
- package/dist/agent/turn/turn-finish.js +188 -0
- package/dist/agent/turn/turn-input.d.ts +43 -0
- package/dist/agent/turn/turn-input.js +79 -0
- package/dist/agent/turn/turn-pipeline.d.ts +68 -0
- package/dist/agent/turn/turn-pipeline.js +257 -0
- package/dist/agent/{turn-prompt.d.ts → turn/turn-prompt.d.ts} +2 -2
- package/dist/agent/{turn-prompt.js → turn/turn-prompt.js} +6 -2
- package/dist/agent/{turn-recovery.js → turn/turn-recovery.js} +1 -1
- package/dist/agent/{turn-state.d.ts → turn/turn-state.d.ts} +1 -1
- package/dist/agent/types.d.ts +43 -2
- package/dist/agent/types.js +1 -1
- package/dist/{models/auth-cli.d.ts → app/auth-command.d.ts} +1 -1
- package/dist/{models/auth-cli.js → app/auth-command.js} +14 -10
- package/dist/{runtime/app-home.d.ts → app/home.d.ts} +6 -2
- package/dist/{runtime/app-home.js → app/home.js} +22 -75
- package/dist/{runtime → app}/proxy.js +4 -2
- package/dist/{app-services.d.ts → app/services.d.ts} +5 -5
- package/dist/{app-services.js → app/services.js} +17 -14
- package/dist/channel/channel-context.d.ts +12 -2
- package/dist/channel/channel-context.js +29 -2
- package/dist/channel/channel-event.d.ts +10 -2
- package/dist/channel/channel-event.js +1 -1
- package/dist/channel/channel-index.js +4 -1
- package/dist/{runtime/project-commands.d.ts → channel/commands.d.ts} +1 -1
- package/dist/{runtime/project-commands.js → channel/commands.js} +17 -16
- package/dist/channel/project-scope-store.js +1 -1
- package/dist/channel/store.js +4 -0
- package/dist/commands/catalog.d.ts +24 -7
- package/dist/commands/catalog.js +91 -44
- package/dist/commands/reply-limits.d.ts +6 -0
- package/dist/commands/reply-limits.js +24 -0
- package/dist/{runtime/report-commands.d.ts → commands/router.d.ts} +10 -3
- package/dist/{runtime/report-commands.js → commands/router.js} +6 -6
- package/dist/{settings.d.ts → config/settings.d.ts} +10 -10
- package/dist/{settings.js → config/settings.js} +11 -11
- package/dist/{tools/config.d.ts → config/tools.d.ts} +1 -2
- package/dist/{tools/config.js → config/tools.js} +5 -2
- package/dist/dingtalk/access-token.d.ts +12 -0
- package/dist/dingtalk/access-token.js +51 -0
- package/dist/dingtalk/api.d.ts +19 -0
- package/dist/dingtalk/api.js +67 -0
- package/dist/dingtalk/bot.d.ts +97 -0
- package/dist/dingtalk/bot.js +389 -0
- package/dist/dingtalk/cards.d.ts +56 -0
- package/dist/dingtalk/cards.js +318 -0
- package/dist/{runtime → dingtalk}/channel-queue.js +4 -1
- package/dist/dingtalk/config.d.ts +19 -0
- package/dist/dingtalk/config.js +95 -0
- package/dist/dingtalk/connection.d.ts +57 -0
- package/dist/dingtalk/connection.js +356 -0
- package/dist/dingtalk/conversation-meta.d.ts +16 -0
- package/dist/dingtalk/conversation-meta.js +77 -0
- package/dist/{runtime → dingtalk}/delivery.d.ts +6 -2
- package/dist/{runtime → dingtalk}/delivery.js +29 -15
- package/dist/dingtalk/handler.d.ts +90 -0
- package/dist/dingtalk/handler.js +1 -0
- package/dist/dingtalk/inbound.d.ts +66 -0
- package/dist/dingtalk/inbound.js +137 -0
- package/dist/dingtalk/media.d.ts +66 -0
- package/dist/dingtalk/media.js +214 -0
- package/dist/events/{event-commands.js → commands.js} +99 -45
- package/dist/events/parse.d.ts +14 -0
- package/dist/events/parse.js +114 -0
- package/dist/events/types.d.ts +93 -0
- package/dist/events/types.js +1 -0
- package/dist/events/{event-validation.d.ts → validation.d.ts} +14 -3
- package/dist/events/{event-validation.js → validation.js} +17 -9
- package/dist/events/watcher.d.ts +67 -0
- package/dist/events/{events.js → watcher.js} +63 -121
- package/dist/executor.js +2 -2
- package/dist/index.d.ts +6 -4
- package/dist/index.js +2 -2
- package/dist/jobs/launch.d.ts +42 -0
- package/dist/jobs/launch.js +118 -0
- package/dist/{agent/job-manager.d.ts → jobs/manager.d.ts} +1 -67
- package/dist/{agent/job-manager.js → jobs/manager.js} +34 -157
- package/dist/jobs/record.d.ts +55 -0
- package/dist/jobs/record.js +36 -0
- package/dist/log.d.ts +12 -2
- package/dist/log.js +26 -34
- package/dist/main.js +3 -3
- package/dist/memory/commands.js +29 -23
- package/dist/memory/lifecycle.js +26 -5
- package/dist/memory/maintenance-gates.d.ts +2 -2
- package/dist/memory/maintenance-state.js +4 -1
- package/dist/memory/maintenance-tuning.d.ts +15 -0
- package/dist/memory/maintenance-tuning.js +3 -0
- package/dist/memory/reflect-job.d.ts +2 -2
- package/dist/memory/reflect-job.js +4 -2
- package/dist/memory/scheduler.d.ts +3 -3
- package/dist/memory/scheduler.js +5 -2
- package/dist/memory/sidecar-worker.js +1 -1
- package/dist/memory/transcript.js +1 -1
- package/dist/{agent/model-fallback.d.ts → models/fallback.d.ts} +6 -6
- package/dist/{agent/model-fallback.js → models/fallback.js} +15 -28
- package/dist/models/login-identity.d.ts +2 -0
- package/dist/models/login-identity.js +83 -0
- package/dist/models/provider-login.d.ts +3 -1
- package/dist/models/provider-login.js +8 -2
- package/dist/models/reference.d.ts +20 -0
- package/dist/models/{utils.js → reference.js} +0 -48
- package/dist/models/{utils.d.ts → runtime.d.ts} +1 -16
- package/dist/models/runtime.js +52 -0
- package/dist/paths.d.ts +2 -0
- package/dist/paths.js +9 -0
- package/dist/playbooks/agent-delegation.md +2 -2
- package/dist/playbooks/catalog.d.ts +6 -2
- package/dist/playbooks/catalog.js +9 -6
- package/dist/runtime/bootstrap.d.ts +7 -17
- package/dist/runtime/bootstrap.js +70 -659
- package/dist/runtime/durable-dispatch.d.ts +43 -4
- package/dist/runtime/durable-dispatch.js +153 -3
- package/dist/runtime/inbound-images.d.ts +18 -0
- package/dist/runtime/inbound-images.js +51 -0
- package/dist/runtime/shutdown.d.ts +39 -0
- package/dist/runtime/shutdown.js +120 -0
- package/dist/runtime/stop-watchdog.d.ts +16 -0
- package/dist/runtime/stop-watchdog.js +32 -0
- package/dist/runtime/task-driver.d.ts +6 -4
- package/dist/runtime/task-driver.js +58 -23
- package/dist/runtime/task-migration.js +25 -8
- package/dist/runtime/task-spawn.d.ts +1 -1
- package/dist/runtime/task-spawn.js +13 -6
- package/dist/runtime/turn-handler.d.ts +47 -0
- package/dist/runtime/turn-handler.js +318 -0
- package/dist/runtime/turn-run.d.ts +52 -0
- package/dist/runtime/turn-run.js +318 -0
- package/dist/runtime/wake-coalescing.d.ts +18 -0
- package/dist/runtime/wake-coalescing.js +29 -0
- package/dist/security/block-message.d.ts +22 -1
- package/dist/security/block-message.js +66 -1
- package/dist/security/command-guard.js +4 -0
- package/dist/security/network.d.ts +2 -1
- package/dist/security/network.js +7 -2
- package/dist/security/path-guard-check.js +2 -2
- package/dist/security/path-guard.js +4 -0
- package/dist/security/types.d.ts +1 -2
- package/dist/security/types.js +1 -2
- package/dist/shared/exact-keys.d.ts +1 -1
- package/dist/shared/format.d.ts +12 -0
- package/dist/shared/format.js +37 -0
- package/dist/shared/host-process.js +16 -4
- package/dist/shared/wake-claim.d.ts +1 -1
- package/dist/shared/with-timeout.d.ts +3 -2
- package/dist/shared/with-timeout.js +14 -3
- package/dist/{runtime/skill-commands.d.ts → skills/commands.d.ts} +2 -2
- package/dist/{runtime/skill-commands.js → skills/commands.js} +18 -11
- package/dist/{agent/workspace-resources.js → skills/loader.js} +1 -1
- package/dist/{tools/skill-security.js → skills/validation.js} +4 -0
- package/dist/skills/workspace.d.ts +33 -0
- package/dist/skills/workspace.js +116 -0
- package/dist/{runtime/subagent-commands.d.ts → subagents/commands.d.ts} +9 -7
- package/dist/{runtime/subagent-commands.js → subagents/commands.js} +116 -77
- package/dist/subagents/completion-wake.d.ts +17 -0
- package/dist/subagents/completion-wake.js +76 -0
- package/dist/subagents/detached-discovery.js +1 -1
- package/dist/subagents/discovery.d.ts +1 -1
- package/dist/subagents/discovery.js +2 -2
- package/dist/subagents/dispatch.d.ts +33 -0
- package/dist/subagents/dispatch.js +190 -0
- package/dist/subagents/external/claude-code.js +23 -1
- package/dist/subagents/external/dispatch.d.ts +25 -0
- package/dist/subagents/external/dispatch.js +90 -0
- package/dist/subagents/external/harness.d.ts +1 -1
- package/dist/subagents/external/progress-tail.d.ts +18 -1
- package/dist/subagents/external/progress-tail.js +64 -17
- package/dist/subagents/external/run.d.ts +5 -1
- package/dist/subagents/external/run.js +23 -9
- package/dist/subagents/external/settlement.d.ts +4 -1
- package/dist/subagents/external/settlement.js +1 -1
- package/dist/subagents/format.d.ts +1 -1
- package/dist/subagents/grace.d.ts +24 -0
- package/dist/subagents/grace.js +57 -0
- package/dist/subagents/internal/outcome.d.ts +24 -0
- package/dist/subagents/internal/outcome.js +149 -0
- package/dist/subagents/internal/provider-retry.d.ts +19 -0
- package/dist/subagents/internal/provider-retry.js +83 -0
- package/dist/subagents/internal/run.d.ts +31 -0
- package/dist/subagents/internal/run.js +240 -0
- package/dist/subagents/internal/state.d.ts +43 -0
- package/dist/subagents/internal/state.js +48 -0
- package/dist/subagents/internal/worker.d.ts +51 -0
- package/dist/subagents/internal/worker.js +167 -0
- package/dist/subagents/result.d.ts +62 -0
- package/dist/subagents/result.js +103 -0
- package/dist/subagents/run-record.d.ts +222 -0
- package/dist/subagents/run-record.js +101 -0
- package/dist/subagents/run-registry.d.ts +9 -0
- package/dist/subagents/run-registry.js +125 -0
- package/dist/subagents/runs.d.ts +16 -232
- package/dist/subagents/runs.js +132 -310
- package/dist/subagents/task-envelope.d.ts +36 -0
- package/dist/subagents/task-envelope.js +168 -0
- package/dist/subagents/types.d.ts +154 -0
- package/dist/subagents/types.js +1 -0
- package/dist/subagents/verification-outcome.d.ts +1 -1
- package/dist/subagents/workspace-summary.d.ts +16 -4
- package/dist/subagents/workspace-summary.js +74 -18
- package/dist/tasks/board.d.ts +10 -3
- package/dist/tasks/board.js +38 -3
- package/dist/tasks/{work-log.d.ts → bound-work.d.ts} +1 -1
- package/dist/tasks/{work-log.js → bound-work.js} +1 -1
- package/dist/tasks/brief.js +1 -1
- package/dist/{runtime/task-commands.d.ts → tasks/commands.d.ts} +1 -1
- package/dist/{runtime/task-commands.js → tasks/commands.js} +117 -67
- package/dist/tasks/contract-input.d.ts +1 -1
- package/dist/tasks/contract-input.js +1 -1
- package/dist/tasks/create.js +1 -1
- package/dist/tasks/frontmatter.d.ts +5 -0
- package/dist/tasks/frontmatter.js +8 -0
- package/dist/tasks/{log.d.ts → loop-log.d.ts} +11 -1
- package/dist/tasks/{log.js → loop-log.js} +59 -3
- package/dist/tasks/mutation-lock.js +1 -1
- package/dist/tasks/session-path.js +1 -1
- package/dist/tasks/steer.js +1 -1
- package/dist/tasks/store.js +6 -4
- package/dist/tasks/ticket.d.ts +3 -1
- package/dist/tasks/ticket.js +19 -1
- package/dist/tools/bash.d.ts +1 -1
- package/dist/tools/bash.js +2 -2
- package/dist/tools/{tool-details.d.ts → contract/details.d.ts} +11 -3
- package/dist/tools/{tool-details.js → contract/details.js} +42 -5
- package/dist/tools/{presentation.js → contract/presentation.js} +3 -3
- package/dist/tools/event-manage.d.ts +1 -1
- package/dist/tools/event-manage.js +4 -4
- package/dist/tools/index.d.ts +5 -3
- package/dist/tools/index.js +8 -6
- package/dist/tools/job.d.ts +1 -1
- package/dist/tools/memory-manage.js +4 -1
- package/dist/tools/registry.d.ts +7 -7
- package/dist/tools/registry.js +6 -6
- package/dist/tools/session-search.d.ts +1 -1
- package/dist/tools/skill.d.ts +2 -34
- package/dist/tools/skill.js +8 -116
- package/dist/tools/subagent-manage.d.ts +1 -1
- package/dist/tools/subagent-manage.js +19 -13
- package/dist/tools/subagent.d.ts +46 -0
- package/dist/tools/subagent.js +127 -0
- package/dist/tools/{task-manage.d.ts → task-manage/factory.d.ts} +7 -3
- package/dist/tools/{task-manage.js → task-manage/factory.js} +7 -7
- package/dist/tools/task-manage/lifecycle.js +2 -2
- package/dist/tools/task-manage/log-view.js +2 -2
- package/dist/tools/task-manage/shared.js +3 -3
- package/dist/tools/task-manage/step-end.js +7 -4
- package/dist/tools/task-manage/types.d.ts +1 -1
- package/dist/tools/web-fetch.d.ts +1 -1
- package/dist/tools/web-search.d.ts +1 -1
- package/dist/tui/app.d.ts +1 -1
- package/dist/tui/app.js +6 -6
- package/dist/tui/cli.d.ts +1 -1
- package/dist/tui/cli.js +3 -3
- package/dist/tui/commands.js +4 -4
- package/dist/tui/frontend.d.ts +44 -0
- package/dist/tui/frontend.js +13 -0
- package/dist/tui/pitui-frontend.d.ts +1 -1
- package/dist/tui/pitui-frontend.js +1 -1
- package/dist/tui/plain-frontend.d.ts +1 -1
- package/dist/tui/renderer.d.ts +3 -42
- package/dist/tui/renderer.js +3 -2
- package/dist/tui/terminal-context.d.ts +2 -2
- package/dist/tui/terminal-media-sender.d.ts +1 -1
- package/dist/tui/turn-controller.d.ts +3 -1
- package/dist/tui/turn-controller.js +36 -21
- package/dist/usage/ledger.js +7 -1
- package/dist/usage/render.js +3 -1
- package/dist/{shared/types.d.ts → usage/totals.d.ts} +3 -0
- package/dist/web/client.d.ts +5 -1
- package/dist/web/client.js +4 -0
- package/dist/web/config.d.ts +1 -1
- package/dist/web/fetch.d.ts +1 -1
- package/dist/web/search-providers.d.ts +1 -1
- package/dist/web/search.d.ts +1 -1
- package/package.json +9 -7
- package/dist/agent/session-adapter.js +0 -77
- package/dist/events/events.d.ts +0 -159
- package/dist/runtime/dingtalk.d.ts +0 -272
- package/dist/runtime/dingtalk.js +0 -1416
- package/dist/subagents/tool.d.ts +0 -206
- package/dist/subagents/tool.js +0 -1088
- /package/dist/{runtime → agent/prompt}/workspace-templates.d.ts +0 -0
- /package/dist/{runtime → agent/prompt}/workspace-templates.js +0 -0
- /package/dist/agent/{session-resource-gate.d.ts → session/session-resource-gate.d.ts} +0 -0
- /package/dist/agent/{context-budget.d.ts → turn/context-budget.d.ts} +0 -0
- /package/dist/agent/{progress-formatter.js → turn/progress-formatter.js} +0 -0
- /package/dist/{memory → agent/turn}/task-digest.d.ts +0 -0
- /package/dist/agent/{turn-recovery.d.ts → turn/turn-recovery.d.ts} +0 -0
- /package/dist/agent/{turn-state.js → turn/turn-state.js} +0 -0
- /package/dist/{runtime → app}/proxy.d.ts +0 -0
- /package/dist/{runtime → dingtalk}/channel-queue.d.ts +0 -0
- /package/dist/{runtime → dingtalk}/inbound-media.d.ts +0 -0
- /package/dist/{runtime → dingtalk}/inbound-media.js +0 -0
- /package/dist/events/{event-commands.d.ts → commands.d.ts} +0 -0
- /package/dist/{agent/workspace-resources.d.ts → skills/loader.d.ts} +0 -0
- /package/dist/{tools/skill-security.d.ts → skills/validation.d.ts} +0 -0
- /package/dist/tasks/{ledger.d.ts → contract.d.ts} +0 -0
- /package/dist/tasks/{ledger.js → contract.js} +0 -0
- /package/dist/tools/{subagent-tool-names.d.ts → contract/names.d.ts} +0 -0
- /package/dist/tools/{subagent-tool-names.js → contract/names.js} +0 -0
- /package/dist/tools/{presentation.d.ts → contract/presentation.d.ts} +0 -0
- /package/dist/{shared/types.js → usage/totals.js} +0 -0
package/dist/subagents/runs.d.ts
CHANGED
|
@@ -1,228 +1,7 @@
|
|
|
1
1
|
import type { ChannelEvent } from "../channel/channel-event.js";
|
|
2
2
|
import type { ChannelStore } from "../channel/store.js";
|
|
3
|
-
import { type UsageTotals } from "../shared/types.js";
|
|
4
3
|
import type { UsageLedger } from "../usage/ledger.js";
|
|
5
|
-
|
|
6
|
-
* The run: one abstraction level for delegation, whether it executes as an in-process sub-agent
|
|
7
|
-
* or (from spec 040 phase 2 onward) a short-lived external CLI process. See
|
|
8
|
-
* `docs/archive/specs/040-async-delegation-and-external-agents/design.md`, D1.
|
|
9
|
-
*
|
|
10
|
-
* State machine vocabulary is borrowed from `job-manager.ts`'s `JobStatus` rather than inventing
|
|
11
|
-
* a second one. Only three facts are persisted as idempotent markers (D1/P5) because only three
|
|
12
|
-
* side effects cannot be safely replayed: settling (writes output, frees a lease), recording
|
|
13
|
-
* usage (a ledger write is a real charge), and enqueuing the completion wake (redelivery makes
|
|
14
|
-
* the parent agent re-process the same result). Everything else — duration, tool counts, verdict
|
|
15
|
-
* — is plain data that can be overwritten harmlessly.
|
|
16
|
-
*/
|
|
17
|
-
export type RunStatus = "running" | "completed" | "failed" | "cancelled" | "lost";
|
|
18
|
-
export type RunRuntime = "internal" | "external";
|
|
19
|
-
export type RunHarness = "claude-code" | "codex-cli" | "exec";
|
|
20
|
-
export type RunMutates = "read" | "write";
|
|
21
|
-
/**
|
|
22
|
-
* Longest a dispatching tool call waits for its run to settle before returning a "still running"
|
|
23
|
-
* placeholder instead of the result (D2). A code constant, not a settings key, per CLAUDE.md's
|
|
24
|
-
* rule for numeric thresholds.
|
|
25
|
-
*/
|
|
26
|
-
export declare const SYNC_GRACE_MS = 120000;
|
|
27
|
-
/**
|
|
28
|
-
* Effective sync grace window. A test-only env override (`PIPICLAW_TEST_SUBAGENT_SYNC_GRACE_MS`)
|
|
29
|
-
* lets the deterministic e2e layer exercise the detached-settlement + completion-wake path
|
|
30
|
-
* (spec 048 A14/A15/A16) without a multi-minute wait; production always uses `SYNC_GRACE_MS`.
|
|
31
|
-
*/
|
|
32
|
-
export declare function resolveSyncGraceMs(override?: number): number;
|
|
33
|
-
/** D10.2: per-channel cap on concurrently running delegation runs. */
|
|
34
|
-
export declare const MAX_RUNNING_SUBAGENT_RUNS_PER_CHANNEL = 6;
|
|
35
|
-
/** D10.2: host-wide cap across every channel. Bounds unbounded process/worker growth only —
|
|
36
|
-
* not the full cross-subsystem (task/job/sidecar) admission scheme the design doc leaves open. */
|
|
37
|
-
export declare const MAX_RUNNING_SUBAGENT_RUNS_PER_HOST = 20;
|
|
38
|
-
/**
|
|
39
|
-
* Human-typeable run ids (spec 041). Runs used to be identified by the dispatching tool call's
|
|
40
|
-
* own id, which on some providers is a `call_<24 chars>|fc_<50 chars>` composite — useless in a
|
|
41
|
-
* chat UI where a human has to read it back to cancel or inspect a run. `mintRunId()` on
|
|
42
|
-
* `SubAgentRunManager` produces `run_` + 6 chars instead; the alphabet excludes 0/1/i/l/o/u
|
|
43
|
-
* because those are the characters people misread on a phone screen or misspeak out loud.
|
|
44
|
-
*/
|
|
45
|
-
export declare const RUN_ID_PREFIX = "run_";
|
|
46
|
-
export type RunResolution = {
|
|
47
|
-
kind: "found";
|
|
48
|
-
record: RunRecord;
|
|
49
|
-
} | {
|
|
50
|
-
kind: "ambiguous";
|
|
51
|
-
candidates: RunRecord[];
|
|
52
|
-
} | {
|
|
53
|
-
kind: "not_found";
|
|
54
|
-
};
|
|
55
|
-
export interface RunUsage {
|
|
56
|
-
usage: UsageTotals;
|
|
57
|
-
/** False only for harnesses that cannot report tokens at all (`exec`). */
|
|
58
|
-
usageKnown: boolean;
|
|
59
|
-
/** False for harnesses that omit a cost field (`codex-cli`, `exec`). */
|
|
60
|
-
costKnown: boolean;
|
|
61
|
-
}
|
|
62
|
-
export interface RunRecord extends RunUsage {
|
|
63
|
-
runId: string;
|
|
64
|
-
channelId: string;
|
|
65
|
-
runtime: RunRuntime;
|
|
66
|
-
harness?: RunHarness;
|
|
67
|
-
agent: string;
|
|
68
|
-
label: string;
|
|
69
|
-
source: "predefined" | "inline";
|
|
70
|
-
tools: string[];
|
|
71
|
-
model?: string;
|
|
72
|
-
purpose: "work" | "verify";
|
|
73
|
-
taskId?: string;
|
|
74
|
-
/** The task's Work Items id this run was dispatched for (spec 052, D4). */
|
|
75
|
-
item?: string;
|
|
76
|
-
workingDirectory: string;
|
|
77
|
-
artifactDir: string;
|
|
78
|
-
status: RunStatus;
|
|
79
|
-
startedAt: number;
|
|
80
|
-
finishedAt?: number;
|
|
81
|
-
durationMs?: number;
|
|
82
|
-
failureReason?: string;
|
|
83
|
-
turns?: number;
|
|
84
|
-
toolCalls?: number;
|
|
85
|
-
/** The checker's declared `VERDICT:` for a `purpose=verify` run (spec 052, D6): information for the leader, not a gate. */
|
|
86
|
-
verificationVerdict?: "pass" | "fail";
|
|
87
|
-
/** P2-2: `git status --porcelain` taken right after a `mutates: "write"` run finished, so the
|
|
88
|
-
* wake's reader does not have to spend its own first tool call finding out what changed. */
|
|
89
|
-
workspaceSummary?: string;
|
|
90
|
-
/** Set once settlement (write output, free resources) has happened; guards against replay. */
|
|
91
|
-
settledAt?: number;
|
|
92
|
-
/**
|
|
93
|
-
* Durable settlement intent. While this exists the public status remains `running` and the
|
|
94
|
-
* lease is still held; it lets a restart finish a settlement that crashed after the intent was
|
|
95
|
-
* recorded but before the terminal record was published.
|
|
96
|
-
*/
|
|
97
|
-
settlementPending?: PendingSettlement;
|
|
98
|
-
/** Set once this run's usage has been written to the ledger; guards against double billing. */
|
|
99
|
-
usageRecorded?: boolean;
|
|
100
|
-
/** Set once this run's cost has been credited to its task. Separate from `usageRecorded` so a
|
|
101
|
-
* replayed settlement can never credit it twice. */
|
|
102
|
-
taskAccounted?: boolean;
|
|
103
|
-
/** Set once the completion wake has been hallmarked for delivery; guards against a duplicate wake. */
|
|
104
|
-
wakeEnqueued?: boolean;
|
|
105
|
-
/** Durable one-time relationship between the internally produced wake and task activation (T9). */
|
|
106
|
-
wakeClaimDispatchId?: string;
|
|
107
|
-
wakeConsumedAt?: number;
|
|
108
|
-
pid?: number;
|
|
109
|
-
/** `ps`'s `lstart` for `pid` at launch — the OS-verifiable identity check that tells this
|
|
110
|
-
* process apart from an unrelated one that later reuses the same pid (D10.3). */
|
|
111
|
-
pidStartedAt?: string;
|
|
112
|
-
/** Wall-clock deadline (`setLaunched` time + `maxWallTimeSec`), so a restart can resume
|
|
113
|
-
* enforcing it — an in-process timer dies with the process that set it. */
|
|
114
|
-
deadlineAt?: number;
|
|
115
|
-
/** Set before the kill signal is sent, so whichever code path eventually settles this run (the
|
|
116
|
-
* live in-process watcher or the cross-restart deadline check) reports why, instead of guessing from
|
|
117
|
-
* protocol output alone (P1-1). */
|
|
118
|
-
terminationReason?: "timeout" | "cancelled";
|
|
119
|
-
argv?: string[];
|
|
120
|
-
sessionId?: string;
|
|
121
|
-
leaseKey?: string;
|
|
122
|
-
mutates?: RunMutates;
|
|
123
|
-
/** Spec 042 D1: the role's wall-time budget, persisted so restart reconciliation can report an
|
|
124
|
-
* accurate "budget exceeded (Ns)" reason instead of reverse-engineering it from `deadlineAt`. */
|
|
125
|
-
maxWallTimeSec?: number;
|
|
126
|
-
/** Spec 042 D1: the real process start time (`setLaunched` time), as opposed to `startedAt`
|
|
127
|
-
* (registration time) — restart reconciliation's duration estimate is measured from here. */
|
|
128
|
-
processStartedAt?: number;
|
|
129
|
-
/** This run's channel directory, so settlement (including restart reconciliation) can reach the
|
|
130
|
-
* owning task's log (spec 052, D4). */
|
|
131
|
-
channelDir?: string;
|
|
132
|
-
/** True when `durationMs` is a restart-reconciliation estimate rather than a measured process
|
|
133
|
-
* lifetime (spec 042 D1) — display surfaces prefix it with "≈". */
|
|
134
|
-
durationEstimated?: boolean;
|
|
135
|
-
/** Spec 042 D10: non-fatal argv-assembly warnings (e.g. a dropped placeholder token) recorded
|
|
136
|
-
* at launch, shown by `/subagents show`. */
|
|
137
|
-
invocationWarnings?: string[];
|
|
138
|
-
/** Spec 042 D7: fingerprint of the role's `command`/`externalModelRef`/`shell` at launch time
|
|
139
|
-
* (external only) — `follow_up` refuses to resume under a role that has since changed one of
|
|
140
|
-
* these instead of silently reinterpreting the old session under a new harness invocation. */
|
|
141
|
-
roleFingerprint?: string;
|
|
142
|
-
/** Spec 042 D12: the harness adapter's own schema version at launch — lets `/subagents show`
|
|
143
|
-
* distinguish "the target CLI's own protocol changed under an adapter that hasn't caught up"
|
|
144
|
-
* from "the agent itself failed". */
|
|
145
|
-
parserVersion?: number;
|
|
146
|
-
/** Spec 042 D12: best-effort `<executable> --version` output captured at launch (1s timeout,
|
|
147
|
-
* `undefined` if the probe failed or timed out) — the other half of the same diagnosis. */
|
|
148
|
-
cliVersion?: string;
|
|
149
|
-
}
|
|
150
|
-
export interface RegisterRunInput {
|
|
151
|
-
runId: string;
|
|
152
|
-
channelId: string;
|
|
153
|
-
runtime: RunRuntime;
|
|
154
|
-
harness?: RunHarness;
|
|
155
|
-
agent: string;
|
|
156
|
-
label: string;
|
|
157
|
-
source: "predefined" | "inline";
|
|
158
|
-
tools: string[];
|
|
159
|
-
model?: string;
|
|
160
|
-
purpose: "work" | "verify";
|
|
161
|
-
taskId?: string;
|
|
162
|
-
item?: string;
|
|
163
|
-
workingDirectory: string;
|
|
164
|
-
artifactDir: string;
|
|
165
|
-
/** This run's channel directory — where its owning task lives. Set at registration for every
|
|
166
|
-
* runtime, so settlement can credit the task whether the run was internal or external; the
|
|
167
|
-
* external launch path re-persists it with the rest of its info. */
|
|
168
|
-
channelDir?: string;
|
|
169
|
-
/** Set only when the caller already holds a workspace write lease for this run (D10.1). */
|
|
170
|
-
leaseKey?: string;
|
|
171
|
-
mutates?: RunMutates;
|
|
172
|
-
}
|
|
173
|
-
interface PendingSettlement {
|
|
174
|
-
status: SettleInput["status"];
|
|
175
|
-
failureReason?: string;
|
|
176
|
-
usage: UsageTotals;
|
|
177
|
-
usageKnown: boolean;
|
|
178
|
-
costKnown: boolean;
|
|
179
|
-
turns: number;
|
|
180
|
-
toolCalls: number;
|
|
181
|
-
durationMs: number;
|
|
182
|
-
durationEstimated?: boolean;
|
|
183
|
-
verificationVerdict?: "pass" | "fail";
|
|
184
|
-
workspaceSummary?: string;
|
|
185
|
-
sessionId?: string;
|
|
186
|
-
finishedAt: number;
|
|
187
|
-
announce: boolean;
|
|
188
|
-
}
|
|
189
|
-
export interface SettleInput {
|
|
190
|
-
status: "completed" | "failed" | "cancelled" | "lost";
|
|
191
|
-
failureReason?: string;
|
|
192
|
-
usage: UsageTotals;
|
|
193
|
-
usageKnown: boolean;
|
|
194
|
-
costKnown: boolean;
|
|
195
|
-
turns: number;
|
|
196
|
-
toolCalls: number;
|
|
197
|
-
durationMs: number;
|
|
198
|
-
/** True when `durationMs` is a restart-reconciliation estimate rather than a measured process
|
|
199
|
-
* lifetime (spec 042 D1) — display surfaces prefix it with "≈". */
|
|
200
|
-
durationEstimated?: boolean;
|
|
201
|
-
/** Full reply text. Settlement saves it to `output.md`; only its tail goes in the wake. */
|
|
202
|
-
outputText: string;
|
|
203
|
-
verificationVerdict?: "pass" | "fail";
|
|
204
|
-
/** P2-2: see `RunRecord.workspaceSummary`. */
|
|
205
|
-
workspaceSummary?: string;
|
|
206
|
-
/** The harness's own session/thread id, captured even on failure so a later resume can still use it. */
|
|
207
|
-
sessionId?: string;
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* A best-effort, out-of-band notice about a run — distinct from the completion wake (`dispatch`).
|
|
211
|
-
* The wake is an LLM turn (its delivery latency is whatever the model takes to respond); a notice
|
|
212
|
-
* is plain text rendered straight to the channel, so it reaches the user in roughly the time the
|
|
213
|
-
* run itself takes to settle, not the wake turn's latency on top of that.
|
|
214
|
-
*/
|
|
215
|
-
export interface RunNotice {
|
|
216
|
-
kind: "settled" | "progress";
|
|
217
|
-
runId: string;
|
|
218
|
-
agent: string;
|
|
219
|
-
/** Only set for `kind: "settled"`. */
|
|
220
|
-
status?: RunStatus;
|
|
221
|
-
durationMs: number;
|
|
222
|
-
/** Only set for `kind: "progress"`: the harness's most recently observed step, already short. */
|
|
223
|
-
step?: string;
|
|
224
|
-
}
|
|
225
|
-
export type RunNotifier = (channelId: string, notice: RunNotice) => void | Promise<void>;
|
|
4
|
+
import { type RegisterRunInput, type RunNotifier, type RunRecord, type RunResolution, type RunStatus, type SettleInput } from "./run-record.js";
|
|
226
5
|
export interface RunManagerOptions {
|
|
227
6
|
/**
|
|
228
7
|
* Root of the per-channel record directories (`<stateDir>/<escaped channelId>/`, escaped by
|
|
@@ -263,6 +42,9 @@ export declare class SubAgentRunManager {
|
|
|
263
42
|
* restart reconciliation already reads once from the finished process's own output. */
|
|
264
43
|
private stopped;
|
|
265
44
|
private readonly externalProgressTails;
|
|
45
|
+
/** Internal runs that went async report their steps in-process; this paces them exactly like the
|
|
46
|
+
* external tail does. Created on first report, dropped at settlement. */
|
|
47
|
+
private readonly internalProgressPacers;
|
|
266
48
|
private readonly queue;
|
|
267
49
|
constructor(channelId: string, options: RunManagerOptions);
|
|
268
50
|
/** Release observation timers without cancelling dispatched work or its settlement. */
|
|
@@ -283,6 +65,12 @@ export declare class SubAgentRunManager {
|
|
|
283
65
|
/** Start tailing a just-launched external run's artifact file for a human-readable step label
|
|
284
66
|
* (P1a). Best-effort only — see `progress-tail.ts` for the polling/pacing contract. */
|
|
285
67
|
private startExternalProgressTail;
|
|
68
|
+
/**
|
|
69
|
+
* A step label from an internal run that has outlived its sync grace window: nobody is watching
|
|
70
|
+
* the tool call any more, so without this the run would be silent until it settles. Paced by the
|
|
71
|
+
* same rules as an external run's tail; a no-op once the run is no longer running.
|
|
72
|
+
*/
|
|
73
|
+
noteProgress(runId: string, step: string): void;
|
|
286
74
|
private stopExternalProgressTail;
|
|
287
75
|
private forget;
|
|
288
76
|
get(runId: string): RunRecord | undefined;
|
|
@@ -368,7 +156,7 @@ export declare class SubAgentRunManager {
|
|
|
368
156
|
* Dispatch the completion wake. Durable-dispatch persists its own pending record before this
|
|
369
157
|
* call can be interrupted (`DurableDispatchService.dispatch`), and `dispatch()` is idempotent on
|
|
370
158
|
* `dispatchId`, so calling it again after a crash between here and marking `wakeEnqueued` is
|
|
371
|
-
* harmless — this is the same fix as
|
|
159
|
+
* harmless — this is the same fix as jobs/manager's `announce()` reordering (D7).
|
|
372
160
|
*/
|
|
373
161
|
private announce;
|
|
374
162
|
/** Explicit cancel (`subagent_run op=cancel`, spec 040 D6). Does not wake — it is the model's own decision. */
|
|
@@ -418,12 +206,8 @@ export declare class SubAgentRunManager {
|
|
|
418
206
|
private collectGarbageIfExpired;
|
|
419
207
|
collectGarbage(now?: number): Promise<void>;
|
|
420
208
|
}
|
|
421
|
-
/**
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
stop: () => void;
|
|
427
|
-
};
|
|
428
|
-
export type SubAgentRuntime = ReturnType<typeof createSubAgentRuntime>;
|
|
429
|
-
export {};
|
|
209
|
+
/**
|
|
210
|
+
* The channel each record directory belongs to. The id is read out of a record itself — the one
|
|
211
|
+
* lossless source, since a directory name is the *escaped* id and `__` cannot be turned back
|
|
212
|
+
* into `/` — with the directory name as the fallback for a directory without a readable record.
|
|
213
|
+
*/
|