@caupulican/pi-adaptative 0.86.3 → 0.86.6
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/CHANGELOG.md +44 -0
- package/dist/core/agent-paths.d.ts +13 -0
- package/dist/core/agent-paths.d.ts.map +1 -1
- package/dist/core/agent-paths.js +23 -0
- package/dist/core/agent-paths.js.map +1 -1
- package/dist/core/autonomy/bounded-completion.d.ts +7 -0
- package/dist/core/autonomy/bounded-completion.d.ts.map +1 -1
- package/dist/core/autonomy/bounded-completion.js +12 -4
- package/dist/core/autonomy/bounded-completion.js.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.d.ts +2 -0
- package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.js +6 -3
- package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
- package/dist/core/autonomy/subagent-prompt.js +1 -1
- package/dist/core/autonomy/subagent-prompt.js.map +1 -1
- package/dist/core/background-lane-controller.d.ts +25 -2
- package/dist/core/background-lane-controller.d.ts.map +1 -1
- package/dist/core/background-lane-controller.js +67 -0
- package/dist/core/background-lane-controller.js.map +1 -1
- package/dist/core/delegation/replay-safe-mailbox-bounds.d.ts +4 -0
- package/dist/core/delegation/replay-safe-mailbox-bounds.d.ts.map +1 -0
- package/dist/core/delegation/replay-safe-mailbox-bounds.js +20 -0
- package/dist/core/delegation/replay-safe-mailbox-bounds.js.map +1 -0
- package/dist/core/delegation/sanitized-context-fork.d.ts +25 -0
- package/dist/core/delegation/sanitized-context-fork.d.ts.map +1 -0
- package/dist/core/delegation/sanitized-context-fork.js +299 -0
- package/dist/core/delegation/sanitized-context-fork.js.map +1 -0
- package/dist/core/delegation/session-root-mailbox.d.ts +75 -0
- package/dist/core/delegation/session-root-mailbox.d.ts.map +1 -0
- package/dist/core/delegation/session-root-mailbox.js +627 -0
- package/dist/core/delegation/session-root-mailbox.js.map +1 -0
- package/dist/core/delegation/worker-agent-control-coordinator.d.ts +102 -9
- package/dist/core/delegation/worker-agent-control-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-agent-control-coordinator.js +1307 -125
- package/dist/core/delegation/worker-agent-control-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-agent-control.d.ts +183 -8
- package/dist/core/delegation/worker-agent-control.d.ts.map +1 -1
- package/dist/core/delegation/worker-agent-control.js +778 -48
- package/dist/core/delegation/worker-agent-control.js.map +1 -1
- package/dist/core/delegation/worker-attempt-executor.d.ts +9 -0
- package/dist/core/delegation/worker-attempt-executor.d.ts.map +1 -1
- package/dist/core/delegation/worker-attempt-executor.js +479 -214
- package/dist/core/delegation/worker-attempt-executor.js.map +1 -1
- package/dist/core/delegation/worker-authority-resolver.d.ts +9 -0
- package/dist/core/delegation/worker-authority-resolver.d.ts.map +1 -1
- package/dist/core/delegation/worker-authority-resolver.js +21 -2
- package/dist/core/delegation/worker-authority-resolver.js.map +1 -1
- package/dist/core/delegation/worker-context-fork-store.d.ts +71 -0
- package/dist/core/delegation/worker-context-fork-store.d.ts.map +1 -0
- package/dist/core/delegation/worker-context-fork-store.js +437 -0
- package/dist/core/delegation/worker-context-fork-store.js.map +1 -0
- package/dist/core/delegation/worker-context-inheritance-policy.d.ts +18 -0
- package/dist/core/delegation/worker-context-inheritance-policy.d.ts.map +1 -0
- package/dist/core/delegation/worker-context-inheritance-policy.js +28 -0
- package/dist/core/delegation/worker-context-inheritance-policy.js.map +1 -0
- package/dist/core/delegation/worker-conversation-revision.d.ts +31 -0
- package/dist/core/delegation/worker-conversation-revision.d.ts.map +1 -0
- package/dist/core/delegation/worker-conversation-revision.js +203 -0
- package/dist/core/delegation/worker-conversation-revision.js.map +1 -0
- package/dist/core/delegation/worker-conversation-store.d.ts +130 -18
- package/dist/core/delegation/worker-conversation-store.d.ts.map +1 -1
- package/dist/core/delegation/worker-conversation-store.js +1263 -79
- package/dist/core/delegation/worker-conversation-store.js.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.d.ts +30 -2
- package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.js +675 -111
- package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
- package/dist/core/delegation/worker-delegation-request.d.ts +2 -0
- package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -1
- package/dist/core/delegation/worker-delegation-request.js.map +1 -1
- package/dist/core/delegation/worker-dispatch-scheduler.d.ts +20 -1
- package/dist/core/delegation/worker-dispatch-scheduler.d.ts.map +1 -1
- package/dist/core/delegation/worker-dispatch-scheduler.js +210 -37
- package/dist/core/delegation/worker-dispatch-scheduler.js.map +1 -1
- package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -1
- package/dist/core/delegation/worker-execution-policy.js +14 -2
- package/dist/core/delegation/worker-execution-policy.js.map +1 -1
- package/dist/core/delegation/worker-fleet-limits.d.ts +38 -0
- package/dist/core/delegation/worker-fleet-limits.d.ts.map +1 -0
- package/dist/core/delegation/worker-fleet-limits.js +113 -0
- package/dist/core/delegation/worker-fleet-limits.js.map +1 -0
- package/dist/core/delegation/worker-lane-projection.d.ts +1 -0
- package/dist/core/delegation/worker-lane-projection.d.ts.map +1 -1
- package/dist/core/delegation/worker-lane-projection.js +6 -2
- package/dist/core/delegation/worker-lane-projection.js.map +1 -1
- package/dist/core/delegation/worker-lifecycle.d.ts +20 -3
- package/dist/core/delegation/worker-lifecycle.d.ts.map +1 -1
- package/dist/core/delegation/worker-lifecycle.js +42 -18
- package/dist/core/delegation/worker-lifecycle.js.map +1 -1
- package/dist/core/delegation/worker-notification-coordinator.d.ts +4 -0
- package/dist/core/delegation/worker-notification-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-notification-coordinator.js +45 -4
- package/dist/core/delegation/worker-notification-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-provider-turn-protocol.d.ts +50 -0
- package/dist/core/delegation/worker-provider-turn-protocol.d.ts.map +1 -0
- package/dist/core/delegation/worker-provider-turn-protocol.js +185 -0
- package/dist/core/delegation/worker-provider-turn-protocol.js.map +1 -0
- package/dist/core/delegation/worker-recovery-coordinator.d.ts +45 -4
- package/dist/core/delegation/worker-recovery-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-recovery-coordinator.js +223 -17
- package/dist/core/delegation/worker-recovery-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-retry-policy.d.ts +36 -0
- package/dist/core/delegation/worker-retry-policy.d.ts.map +1 -0
- package/dist/core/delegation/worker-retry-policy.js +41 -0
- package/dist/core/delegation/worker-retry-policy.js.map +1 -0
- package/dist/core/delegation/worker-runner.d.ts +3 -1
- package/dist/core/delegation/worker-runner.d.ts.map +1 -1
- package/dist/core/delegation/worker-runner.js +4 -2
- package/dist/core/delegation/worker-runner.js.map +1 -1
- package/dist/core/delegation/worker-task-view.d.ts +43 -0
- package/dist/core/delegation/worker-task-view.d.ts.map +1 -0
- package/dist/core/delegation/worker-task-view.js +194 -0
- package/dist/core/delegation/worker-task-view.js.map +1 -0
- package/dist/core/delegation/worker-terminal-handoff-coordinator.d.ts +55 -0
- package/dist/core/delegation/worker-terminal-handoff-coordinator.d.ts.map +1 -0
- package/dist/core/delegation/worker-terminal-handoff-coordinator.js +179 -0
- package/dist/core/delegation/worker-terminal-handoff-coordinator.js.map +1 -0
- package/dist/core/delegation/worker-tree-budget-coordinator.d.ts +2 -2
- package/dist/core/delegation/worker-tree-budget-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-tree-budget-coordinator.js +12 -46
- package/dist/core/delegation/worker-tree-budget-coordinator.js.map +1 -1
- package/dist/core/goals/goal-continuation-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-controller.js +15 -0
- package/dist/core/goals/goal-continuation-controller.js.map +1 -1
- package/dist/core/goals/goal-state.d.ts +6 -0
- package/dist/core/goals/goal-state.d.ts.map +1 -1
- package/dist/core/goals/goal-state.js +1 -0
- package/dist/core/goals/goal-state.js.map +1 -1
- package/dist/core/goals/goal-tool-core.d.ts +1 -0
- package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
- package/dist/core/goals/goal-tool-core.js +25 -3
- package/dist/core/goals/goal-tool-core.js.map +1 -1
- package/dist/core/keybindings.d.ts +10 -0
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +2 -0
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/orchestration/attempt-ordering.d.ts +9 -0
- package/dist/core/orchestration/attempt-ordering.d.ts.map +1 -0
- package/dist/core/orchestration/attempt-ordering.js +29 -0
- package/dist/core/orchestration/attempt-ordering.js.map +1 -0
- package/dist/core/orchestration/capability-gateway.d.ts +19 -0
- package/dist/core/orchestration/capability-gateway.d.ts.map +1 -1
- package/dist/core/orchestration/capability-gateway.js +19 -2
- package/dist/core/orchestration/capability-gateway.js.map +1 -1
- package/dist/core/orchestration/contracts.d.ts +43 -3
- package/dist/core/orchestration/contracts.d.ts.map +1 -1
- package/dist/core/orchestration/contracts.js +24 -0
- package/dist/core/orchestration/contracts.js.map +1 -1
- package/dist/core/orchestration/delegation-ledger.d.ts +8 -3
- package/dist/core/orchestration/delegation-ledger.d.ts.map +1 -1
- package/dist/core/orchestration/delegation-ledger.js +148 -55
- package/dist/core/orchestration/delegation-ledger.js.map +1 -1
- package/dist/core/orchestration/event-store.d.ts +6 -3
- package/dist/core/orchestration/event-store.d.ts.map +1 -1
- package/dist/core/orchestration/event-store.js +228 -30
- package/dist/core/orchestration/event-store.js.map +1 -1
- package/dist/core/orchestration/task-runtime-codecs.d.ts +31 -0
- package/dist/core/orchestration/task-runtime-codecs.d.ts.map +1 -0
- package/dist/core/orchestration/task-runtime-codecs.js +1471 -0
- package/dist/core/orchestration/task-runtime-codecs.js.map +1 -0
- package/dist/core/orchestration/task-runtime-projection.d.ts +30 -0
- package/dist/core/orchestration/task-runtime-projection.d.ts.map +1 -0
- package/dist/core/orchestration/task-runtime-projection.js +340 -0
- package/dist/core/orchestration/task-runtime-projection.js.map +1 -0
- package/dist/core/orchestration/task-runtime-reducer.d.ts +38 -0
- package/dist/core/orchestration/task-runtime-reducer.d.ts.map +1 -0
- package/dist/core/orchestration/task-runtime-reducer.js +1270 -0
- package/dist/core/orchestration/task-runtime-reducer.js.map +1 -0
- package/dist/core/orchestration/task-runtime-state.d.ts +142 -0
- package/dist/core/orchestration/task-runtime-state.d.ts.map +1 -0
- package/dist/core/orchestration/task-runtime-state.js +14 -0
- package/dist/core/orchestration/task-runtime-state.js.map +1 -0
- package/dist/core/orchestration/task-runtime.d.ts +44 -98
- package/dist/core/orchestration/task-runtime.d.ts.map +1 -1
- package/dist/core/orchestration/task-runtime.js +357 -1113
- package/dist/core/orchestration/task-runtime.js.map +1 -1
- package/dist/core/orchestration/worker-context-fork-reference.d.ts +20 -0
- package/dist/core/orchestration/worker-context-fork-reference.d.ts.map +1 -0
- package/dist/core/orchestration/worker-context-fork-reference.js +53 -0
- package/dist/core/orchestration/worker-context-fork-reference.js.map +1 -0
- package/dist/core/orchestration/worker-execution-contract.d.ts.map +1 -1
- package/dist/core/orchestration/worker-execution-contract.js +4 -2
- package/dist/core/orchestration/worker-execution-contract.js.map +1 -1
- package/dist/core/research/research-runner.d.ts +2 -0
- package/dist/core/research/research-runner.d.ts.map +1 -1
- package/dist/core/research/research-runner.js +1 -0
- package/dist/core/research/research-runner.js.map +1 -1
- package/dist/core/runtime-builder.d.ts.map +1 -1
- package/dist/core/runtime-builder.js +8 -0
- package/dist/core/runtime-builder.js.map +1 -1
- package/dist/core/secrets/credential-project.d.ts.map +1 -1
- package/dist/core/secrets/credential-project.js +24 -2
- package/dist/core/secrets/credential-project.js.map +1 -1
- package/dist/core/security/secret-text.d.ts +3 -0
- package/dist/core/security/secret-text.d.ts.map +1 -1
- package/dist/core/security/secret-text.js +15 -0
- package/dist/core/security/secret-text.js.map +1 -1
- package/dist/core/settings-manager.d.ts +3 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +160 -8
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/tools/delegate.d.ts +33 -15
- package/dist/core/tools/delegate.d.ts.map +1 -1
- package/dist/core/tools/delegate.js +763 -115
- package/dist/core/tools/delegate.js.map +1 -1
- package/dist/core/tools/goal.d.ts +1 -0
- package/dist/core/tools/goal.d.ts.map +1 -1
- package/dist/core/tools/goal.js +9 -1
- package/dist/core/tools/goal.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +1 -0
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/activity-lane.d.ts +5 -0
- package/dist/modes/interactive/components/activity-lane.d.ts.map +1 -1
- package/dist/modes/interactive/components/activity-lane.js +133 -49
- package/dist/modes/interactive/components/activity-lane.js.map +1 -1
- package/dist/modes/interactive/components/agents-overlay.d.ts +40 -0
- package/dist/modes/interactive/components/agents-overlay.d.ts.map +1 -0
- package/dist/modes/interactive/components/agents-overlay.js +153 -0
- package/dist/modes/interactive/components/agents-overlay.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +18 -13
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-event-controller.d.ts +1 -1
- package/dist/modes/interactive/interactive-event-controller.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-event-controller.js +6 -3
- package/dist/modes/interactive/interactive-event-controller.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +5 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +51 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/key-handlers.d.ts +1 -0
- package/dist/modes/interactive/key-handlers.d.ts.map +1 -1
- package/dist/modes/interactive/key-handlers.js +1 -0
- package/dist/modes/interactive/key-handlers.js.map +1 -1
- package/docs/harness-architecture.md +61 -17
- package/docs/settings.md +17 -9
- package/docs/worker-profiles.md +6 -2
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +12 -12
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.86.6] - 2026-08-08
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Enforced goal-graph dependency validation during worker admission, blocking worker dispatches whose target requirements depend on unsatisfied or open requirements.
|
|
8
|
+
- Automatically injected memory query capability and memory tools into worker execution plans when memory retrieval is enabled.
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Allowed auto-injected memory query capability and memory tool through worker execution contract boundaries without violating static capability ceilings.
|
|
13
|
+
- Exempted worker verification requests from goal-graph dependency checks so completed worker tasks can always be verified.
|
|
14
|
+
|
|
15
|
+
## [0.86.5] - 2026-08-08
|
|
16
|
+
|
|
17
|
+
## [0.86.4] - 2026-08-08
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- Made persistent workers the default delegation workflow: `delegate start` with an `agentId` now dispatches the new task onto that existing worker's durable conversation (idle agents only; the worker keeps its admitted authority — passing `authority`/`profileId` is rejected with `reuse_keeps_admitted_authority`; busy/unknown agents fail with explicit reasons), `list` reports each agent's live `activity` so idle specialists are discoverable, and the tool contract teaches the orchestrator to prefer reuse over minting unnecessary fresh worker identities. Starting without `agentId` creates a fresh specialist identity and conversation whose bounded birth context follows `forkTurns`.
|
|
22
|
+
- Added a host-owned, restart-durable worker attempt ladder: a delegated worker that fails on an evidence-classified transient error (network, 5xx, rate limit) is suspended durably and re-enqueued after jittered backoff, resuming from its persisted transcript under a fresh fence — instead of terminalizing and forcing the orchestrator to re-delegate blind. Bounded by the grant's durable `maxAttempts` ceiling (default 2 total attempts; `maxAttempts: 1` never ladders), evidence-gated (failures without a classified transient cause never retry), and restart-safe through persisted suspended state and the existing recovery path.
|
|
23
|
+
- Added a live agents panel (`ctrl+q` toggles, `escape` closes; configurable via `app.agents.open`/`app.agents.close`) as the detail view behind the statusline's aggregated concurrency counts: each worker lane with status, runtime, profile, elapsed time, and cost, plus running background tools — rendered in the same orchestration-panel row language as the delegate tool output.
|
|
24
|
+
- Added a shared bounded `delegate tasks` view of durable DAG tasks and attempts, same-objective `dependsOn` dispatch gates, peer `broadcast`, event-driven `wait_many`, subtree-scoped wake/control actions, durable root reply inboxes, and replay-safe idle-leaf retirement that preserves agent bindings and transcripts.
|
|
25
|
+
- Added immutable sanitized worker birth context with `forkTurns: "none" | "all" | "N"`: same-provider/model children inherit all bounded complete turns by default, cross-provider/model children default to none, and explicit cross-boundary inheritance is rejected.
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
|
|
29
|
+
- Redesigned the activity statusline above the editor into a fixed-slot layout (turn state · plan position · concurrency counts · last event): slots keep stable positions instead of shifting as chips arrive, concurrent background tools aggregate into per-runtime counts (`2 bash · 1 python`) instead of enumerating task ids, background tool chips show the task description instead of internal `tool-task-N` ids, color now carries status only, and only the plan slot truncates when width runs out.
|
|
30
|
+
- Bounded recursive orchestration before durable side effects (depth 8, 64 direct children, 256 each for session agents, tasks, and attempts, and 256 queued dispatches), persisted retry eligibility as exact `notBefore` deadlines, and exposed bounded retry/dependency state through the shared task projection.
|
|
31
|
+
- Raised the default global worker concurrency from 1 to 20 while retaining explicit positive safe-integer overrides and the existing fixed fleet, queue, budget, and write-reservation safety bounds.
|
|
32
|
+
|
|
33
|
+
### Fixed
|
|
34
|
+
|
|
35
|
+
- Fixed TUI startup benchmarks stopping the renderer without disposing session-owned resources, which left packaged smoke and profiling processes running indefinitely.
|
|
36
|
+
- Fixed the native Windows incident collector honoring an ambient session-directory environment variable over an explicitly supplied agent directory.
|
|
37
|
+
- Fixed persistent-worker control recovery so task-bearing wakeups, terminal handoffs, and inferred replies remain crash-safe and replay-safe after mailbox history pruning; bounded mailboxes now reserve mandatory byte, entry, and replay-evidence capacity, terminal notification failures retry autonomously, session-root replies use an explicit acknowledged inbox, and poisoned terminal-correlated tasks no longer block later work.
|
|
38
|
+
- Fixed delegated workers dying with bare `completion_error`: token budgets now charge prompt-cache reads at 10% instead of face value (a fixed ~3k-token cached system prompt no longer turns `maxTokens` into a request counter), non-viable grants (`maxTokens` under 5000) are rejected at `delegate start` with `token_budget_below_floor` instead of starving mid-flight, worker failure summaries and research lane results carry the underlying executor error, and transient provider failures (socket drops, 5xx, rate limits) retry with jittered backoff inside the worker attempt instead of failing instantly at $0.
|
|
39
|
+
- Fixed corrupted TUI rendering (stale duplicated status lines, wrapped line fragments) on terminals that render East Asian ambiguous characters (`·`, `…`, `●`) as two columns, such as Windows consoles with a CJK codepage/font: the renderer now probes the terminal's actual character width at startup and recalculates layout accordingly.
|
|
40
|
+
- Replaced timer-loop parent terminal-handoff retries with one bounded attempt-keyed retained queue that drains only on explicit terminal, mailbox-capacity, state-change, and recovery events; exact replays are inert, conflicts fail closed, callback failures remain retained, and reentrant signals redrain without polling.
|
|
41
|
+
- Fixed worker orchestration edge cases around bounded transcript paging, reopened transcript equality, tied attempt timestamps, long mailbox-control payload sanitization, paused suspended resumes, and concurrent mandatory verifiers: raw-entry cursors now disclose empty continuations and oversized-message omissions, canonical JSON and shared tool-detail retention prevent false divergence after a locked reopen, durable insertion order selects activity, paused work stays nonterminal, and admitted verifier demand retains queue/projection headroom plus capacity-event replay.
|
|
42
|
+
- Fixed orchestration authority drift by routing command admission, event replay, and snapshot recovery through exact shared reducers and strict codecs; canonical persistence and replay now reject unsupported fields, conflicting identities, invalid graph relationships, and divergent retained state, while file-locked exact-content reconciliation prevents stale worker-session owners from duplicating durable control delivery.
|
|
43
|
+
- Fixed persistent-worker transcript and completion ownership: one revision-fenced conversation core now verifies exact append bytes and bounded callback-evidenced suffixes across retries and cancellation, rejects stale supported writers, ownership-boundary content changes, unreserved results, and late output, preserves immutable birth metadata, accounts cumulative retry cost, and retains shared provider reservations until returned usage is charged.
|
|
44
|
+
- Fixed worker crash recovery discarding a durably persisted empty terminal response and calling the provider again; recovery now replays the empty completion so the original deterministic output validation runs without duplicate work or cost.
|
|
45
|
+
- Fixed malformed ancestor `.git` markers capturing project credential scope; repository discovery now requires a bounded, valid symbolic or detached Git `HEAD` before reading remote configuration.
|
|
46
|
+
|
|
3
47
|
## [0.86.3] - 2026-08-06
|
|
4
48
|
|
|
5
49
|
### Fixed
|
|
@@ -62,12 +62,25 @@ export declare function orchestrationEventStoreDir(agentDir: string, parentSessi
|
|
|
62
62
|
* but are intentionally outside the foreground session picker namespace.
|
|
63
63
|
*/
|
|
64
64
|
export declare function workerConversationSessionsDir(agentDir: string, parentSessionId: string): string;
|
|
65
|
+
/** `<orchestrationSessionDir>/worker-context-forks` -- immutable sanitized worker birth snapshots. */
|
|
66
|
+
export declare function workerContextForksDir(agentDir: string, parentSessionId: string): string;
|
|
67
|
+
/**
|
|
68
|
+
* `<workerContextForksDir>/<identity-digest>-<content-digest>.json` -- one immutable,
|
|
69
|
+
* content-addressed sanitized worker birth snapshot.
|
|
70
|
+
*/
|
|
71
|
+
export declare function workerContextForkFile(agentDir: string, parentSessionId: string, identityDigest: string, contentDigest: string): string;
|
|
65
72
|
/**
|
|
66
73
|
* `<orchestrationSessionDir>/worker-mailboxes/<scope-digest>.json` -- durable bounded control
|
|
67
74
|
* messages for one logical worker. Identity stays hashed so neither agent ids nor project paths
|
|
68
75
|
* become path segments.
|
|
69
76
|
*/
|
|
70
77
|
export declare function workerAgentMailboxFile(agentDir: string, parentSessionId: string, scopeDigest: string): string;
|
|
78
|
+
/**
|
|
79
|
+
* `<orchestrationSessionDir>/session-root-mailbox.json` -- the bounded durable reply inbox for the
|
|
80
|
+
* owning foreground session. The parent session identity is already encoded in the enclosing
|
|
81
|
+
* session directory, so this fixed filename cannot collide with another session root.
|
|
82
|
+
*/
|
|
83
|
+
export declare function sessionRootMailboxFile(agentDir: string, parentSessionId: string): string;
|
|
71
84
|
/**
|
|
72
85
|
* `<orchestrationSessionDir>/worker-actions/<scope-digest>.json` -- durable, bounded mutation
|
|
73
86
|
* intents and receipts for one fenced worker attempt. The opaque digest intentionally keeps task
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-paths.d.ts","sourceRoot":"","sources":["../../src/core/agent-paths.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"agent-paths.d.ts","sourceRoot":"","sources":["../../src/core/agent-paths.ts"],"names":[],"mappings":"AAyCA,OAAO,EACN,cAAc,EACd,yBAAyB,EACzB,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,qBAAqB,EACrB,eAAe,EACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAGhE,wEAAwE;AACxE,eAAO,MAAM,qBAAqB,YACjC,WAAW,EACX,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,WAAW,EACX,SAAS,EACT,WAAW,EACX,kBAAkB,CACT,CAAC;AAEX,oFAAoF;AACpF,eAAO,MAAM,0BAA0B,YACtC,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,UAAU,EACV,OAAO,EACP,OAAO,EACP,KAAK,EACL,MAAM,EACN,UAAU,EACV,QAAQ,EACR,UAAU,EACV,KAAK,EACL,KAAK,EACL,WAAW,CACF,CAAC;AAIX,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE/D;AAED,4GAA4G;AAC5G,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjE;AA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AAM,GAAG,MAAM,CAExF;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAS9G;AAED,wDAAwD;AACxD,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,gEAAgE;AAChE,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,YAAY,GAAG,UAAU,CAAC;AAE5F,oGAAoG;AACpG,wBAAgB,WAAW,CAAC,IAAI,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE7E;AAED,4FAA4F;AAC5F,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED;;;;;GAKG;AACH,OAAO,EACN,WAAW,EACX,yBAAyB,EACzB,oBAAoB,EACpB,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,eAAe,GACf,CAAC;AACF,YAAY,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE5G;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,iCAA2B,CAAC"}
|
package/dist/core/agent-paths.js
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* npm/ git/ sessions/ -- npmDir/gitDir/sessionsDir
|
|
22
22
|
* state/orchestration/sessions/<session-key>/ -- one foreground-session-owned
|
|
23
23
|
* control-plane bundle
|
|
24
|
+
* worker-context-forks/<identity-digest>-<content-digest>.json -- immutable birth snapshots
|
|
24
25
|
* worktrees/<repo-slug>/<laneKey> durable lane checkouts (core/worktree-sync) -- worktreesDir
|
|
25
26
|
* ```
|
|
26
27
|
*
|
|
@@ -191,6 +192,20 @@ export function orchestrationEventStoreDir(agentDir, parentSessionId) {
|
|
|
191
192
|
export function workerConversationSessionsDir(agentDir, parentSessionId) {
|
|
192
193
|
return join(orchestrationSessionDir(agentDir, parentSessionId), "worker-conversations");
|
|
193
194
|
}
|
|
195
|
+
/** `<orchestrationSessionDir>/worker-context-forks` -- immutable sanitized worker birth snapshots. */
|
|
196
|
+
export function workerContextForksDir(agentDir, parentSessionId) {
|
|
197
|
+
return join(orchestrationSessionDir(agentDir, parentSessionId), "worker-context-forks");
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* `<workerContextForksDir>/<identity-digest>-<content-digest>.json` -- one immutable,
|
|
201
|
+
* content-addressed sanitized worker birth snapshot.
|
|
202
|
+
*/
|
|
203
|
+
export function workerContextForkFile(agentDir, parentSessionId, identityDigest, contentDigest) {
|
|
204
|
+
if (!/^[a-f0-9]{64}$/i.test(identityDigest) || !/^[a-f0-9]{64}$/i.test(contentDigest)) {
|
|
205
|
+
throw new TypeError("Worker context fork identities must be hexadecimal SHA-256 digests.");
|
|
206
|
+
}
|
|
207
|
+
return join(workerContextForksDir(agentDir, parentSessionId), `${identityDigest.toLowerCase()}-${contentDigest.toLowerCase()}.json`);
|
|
208
|
+
}
|
|
194
209
|
/**
|
|
195
210
|
* `<orchestrationSessionDir>/worker-mailboxes/<scope-digest>.json` -- durable bounded control
|
|
196
211
|
* messages for one logical worker. Identity stays hashed so neither agent ids nor project paths
|
|
@@ -202,6 +217,14 @@ export function workerAgentMailboxFile(agentDir, parentSessionId, scopeDigest) {
|
|
|
202
217
|
}
|
|
203
218
|
return join(orchestrationSessionDir(agentDir, parentSessionId), "worker-mailboxes", `${scopeDigest.toLowerCase()}.json`);
|
|
204
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* `<orchestrationSessionDir>/session-root-mailbox.json` -- the bounded durable reply inbox for the
|
|
222
|
+
* owning foreground session. The parent session identity is already encoded in the enclosing
|
|
223
|
+
* session directory, so this fixed filename cannot collide with another session root.
|
|
224
|
+
*/
|
|
225
|
+
export function sessionRootMailboxFile(agentDir, parentSessionId) {
|
|
226
|
+
return join(orchestrationSessionDir(agentDir, parentSessionId), "session-root-mailbox.json");
|
|
227
|
+
}
|
|
205
228
|
/**
|
|
206
229
|
* `<orchestrationSessionDir>/worker-actions/<scope-digest>.json` -- durable, bounded mutation
|
|
207
230
|
* intents and receipts for one fenced worker attempt. The opaque digest intentionally keeps task
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-paths.js","sourceRoot":"","sources":["../../src/core/agent-paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EACN,cAAc,EACd,yBAAyB,EACzB,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,qBAAqB,EACrB,eAAe,GACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAEpE,wEAAwE;AACxE,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACpC,WAAW;IACX,eAAe;IACf,aAAa;IACb,kBAAkB;IAClB,WAAW;IACX,SAAS;IACT,WAAW;IACX,kBAAkB;CACT,CAAC;AAEX,oFAAoF;AACpF,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACzC,YAAY;IACZ,QAAQ;IACR,YAAY;IACZ,SAAS;IACT,QAAQ;IACR,UAAU;IACV,OAAO;IACP,OAAO;IACP,KAAK;IACL,MAAM;IACN,UAAU;IACV,QAAQ;IAC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M,CAAC,QAAgB;IACtC,OAAO,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AAC9B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,QAAgB;IAC5C,OAAO,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AACpC,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,MAAM,CAAC,QAAgB;IACtC,OAAO,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AAC9B,CAAC;AAID,oGAAoG;AACpG,MAAM,UAAU,WAAW,CAAC,IAAuB,EAAE,QAAgB;IACpE,OAAO,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AAC7B,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,oBAAoB,CAAC,QAAgB;IACpD,OAAO,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAE,aAAa,CAAC,CAAC;AAC/D,CAAC;AAED;;;;;GAKG;AACH,OAAO,EACN,WAAW,EACX,yBAAyB,EACzB,oBAAoB,EACpB,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,eAAe,GACf,CAAC;AAGF;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,wBAAwB,CAAC","sourcesContent":["/**\n * Typed path SSOT for everything machine-managed under `<agentDir>` (`~/.pi/agent/` by default,\n * `getAgentDir()` in `../config.ts`). Every writer that persists machine data (stores, caches, managed\n * runtimes/models, cross-process coordination) MUST resolve its path through one of the accessors\n * below instead of hand-rolling `join(agentDir, …)` — that ad-hoc pattern is exactly how root-level\n * stragglers like `trust.json` accumulated, and nothing stopped the next writer from doing it again.\n *\n * Canonical layout:\n * ```\n * <agentDir>/\n * auth.json settings.json models.json keybindings.json MEMORY.md USER.md SYSTEM.md … user CONFIG/MEMORY (root, kept)\n * okf-memory/ authored memory (root, kept)\n * skills/ extensions/ prompts/ themes/ profiles/ user RESOURCES (root, kept)\n * profiles/directories/<workspace-hash>/settings.json directory overlays\n * state/ durable machine state (model adaptation/fitness, tool performance,\n * learning observations, trust decisions, config backups, …) -- stateDir/stateFile\n * cache/ rebuildable, safe to delete (tool-path probes, jiti transform cache, uv) -- cacheDir/cacheFile\n * work/ transient/scratch, delegated to work-directory.ts (tenant/run/lease),\n * including context/sessions/<session-id>/{gc,artifacts} -- re-exported below\n * runtimes/<kind> models/<kind> -- runtimesDir/modelsDir\n * npm/ git/ sessions/ -- npmDir/gitDir/sessionsDir\n * state/orchestration/sessions/<session-key>/ -- one foreground-session-owned\n * control-plane bundle\n * worktrees/<repo-slug>/<laneKey> durable lane checkouts (core/worktree-sync) -- worktreesDir\n * ```\n *\n * Every accessor takes `agentDir` as an explicit, required first argument -- deliberately mirroring\n * `work-directory.ts`'s existing `getWorkRoot(agentDir)` convention rather than defaulting to\n * `getAgentDir()` internally. Several real callers (stores' `forAgentDir`, test harnesses with a temp\n * agentDir) build paths for a NON-default agentDir; a hidden default would silently resolve the wrong\n * root for those callers instead of failing loudly. Callers operating on the process-wide default pass\n * `getAgentDir()` explicitly at the call site.\n *\n * These accessors are pure path builders -- no directory creation, no I/O. Every existing writer\n * already creates its parent directory at write time (see `util/atomic-file.ts`'s\n * `mkdirSync(dirname(filePath), { recursive: true })`), so duplicating that here would be redundant\n * and would blur the \"pure function\" contract readers rely on.\n */\nimport { createHash } from \"node:crypto\";\nimport { join } from \"node:path\";\nimport {\n\tacquireWorkRun,\n\tassertPortablePathSegment,\n\tboundedWorkRetention,\n\tcreateWorkRunId,\n\tgetProcessWorkRun,\n\tgetWorkRoot,\n\tgetWorkRunDir,\n\tgetWorkTenantDir,\n\thasActiveWorkRunLease,\n\tpruneWorkTenant,\n} from \"../utils/work-directory.ts\";\nimport { getReloadCoordinationDir } from \"./reload-blockers.ts\";\nimport { requireBoundedTrimmedText } from \"./util/bounded-value.ts\";\n\n/** Root entries reserved for user-authored configuration and memory. */\nexport const AGENT_ROOT_FILE_NAMES = [\n\t\"auth.json\",\n\t\"settings.json\",\n\t\"models.json\",\n\t\"keybindings.json\",\n\t\"MEMORY.md\",\n\t\"USER.md\",\n\t\"SYSTEM.md\",\n\t\"APPEND_SYSTEM.md\",\n] as const;\n\n/** Root entries reserved for user resources and machine-managed storage classes. */\nexport const AGENT_ROOT_DIRECTORY_NAMES = [\n\t\"okf-memory\",\n\t\"skills\",\n\t\"extensions\",\n\t\"prompts\",\n\t\"themes\",\n\t\"profiles\",\n\t\"state\",\n\t\"cache\",\n\t\"bin\",\n\t\"work\",\n\t\"runtimes\",\n\t\"models\",\n\t\"sessions\",\n\t\"npm\",\n\t\"git\",\n\t\"worktrees\",\n] as const;\n\nconst AGENT_ROOT_ENTRY_NAMES = new Set<string>([...AGENT_ROOT_FILE_NAMES, ...AGENT_ROOT_DIRECTORY_NAMES]);\n\nexport function isCanonicalAgentRootEntry(name: string): boolean {\n\treturn AGENT_ROOT_ENTRY_NAMES.has(name);\n}\n\n/** `<agentDir>/<name>` -- a root-level user config/memory file (auth.json, settings.json, MEMORY.md, …). */\nexport function configFile(agentDir: string, name: string): string {\n\treturn join(agentDir, name);\n}\n\n/** `<agentDir>/okf-memory` -- user-authored durable OKF memory documents. */\nexport function okfMemoryDir(agentDir: string): string {\n\treturn join(agentDir, \"okf-memory\");\n}\n\n/** `<agentDir>/state` -- durable machine-managed state. Deleting it loses real history, not just cache. */\nexport function stateDir(agentDir: string): string {\n\treturn join(agentDir, \"state\");\n}\n\n/** `<agentDir>/state/<segments…>` */\nexport function stateFile(agentDir: string, ...segments: string[]): string {\n\treturn join(stateDir(agentDir), ...segments);\n}\n\nexport type ManagedMemoryFileName = \"MEMORY.md\" | \"USER.md\";\n\n/** `<agentDir>/state/memory/file-store/<name>.pi-managed.json` -- file-store ownership metadata. */\nexport function managedMemoryStateFile(agentDir: string, name: ManagedMemoryFileName): string {\n\tif (name !== \"MEMORY.md\" && name !== \"USER.md\") {\n\t\tthrow new TypeError(`Unsupported managed memory file name: ${name}`);\n\t}\n\treturn stateFile(agentDir, \"memory\", \"file-store\", `${name}.pi-managed.json`);\n}\n\n/** `<agentDir>/state/attachments` -- bounded, session-keyed clipboard image attachments. */\nexport function attachmentsDir(agentDir: string): string {\n\treturn stateFile(agentDir, \"attachments\");\n}\n\n/** Retired local-secret state root. Current credential storage is provider-backed and never writes here. */\nexport function secretsDir(agentDir: string): string {\n\treturn stateFile(agentDir, \"secrets\");\n}\n\n/** Retired local vault path retained only so model-facing file access stays denied. */\nexport function secretVaultFile(agentDir: string): string {\n\treturn join(secretsDir(agentDir), \"vault.json\");\n}\n\n/** Retired plaintext materialization root retained only so model-facing file access stays denied. */\nexport function managedSecretEnvDir(agentDir: string): string {\n\treturn join(secretsDir(agentDir), \"materialized\");\n}\n\n/** `<agentDir>/state/extensions/<namespace>` -- durable state owned by one extension. */\nexport function extensionStateDir(agentDir: string, namespace: string): string {\n\tassertPortablePathSegment(\"Extension namespace\", namespace);\n\treturn stateFile(agentDir, \"extensions\", namespace);\n}\n\n/** `<agentDir>/state/backups/config` -- explicit user-requested configuration snapshots. */\nexport function configBackupsDir(agentDir: string): string {\n\treturn stateFile(agentDir, \"backups\", \"config\");\n}\n\n/** `<agentDir>/cache` -- rebuildable; safe to delete (the next run just re-probes/recomputes). */\nexport function cacheDir(agentDir: string): string {\n\treturn join(agentDir, \"cache\");\n}\n\n/** `<agentDir>/cache/<segments…>` */\nexport function cacheFile(agentDir: string, ...segments: string[]): string {\n\treturn join(cacheDir(agentDir), ...segments);\n}\n\n/** `<agentDir>/cache/extensions/<namespace>` -- rebuildable cache owned by one extension. */\nexport function extensionCacheDir(agentDir: string, namespace: string): string {\n\tassertPortablePathSegment(\"Extension namespace\", namespace);\n\treturn cacheFile(agentDir, \"extensions\", namespace);\n}\n\n/** `<agentDir>/bin` -- managed executable helpers (fd, rg, jq, uv). */\nexport function binDir(agentDir: string): string {\n\treturn join(agentDir, \"bin\");\n}\n\n/** `<agentDir>/runtimes/<kind>` -- a managed runtime install (ollama, python, prism-llamacpp, needle, …). */\nexport function runtimesDir(kind: string, agentDir: string): string {\n\treturn join(agentDir, \"runtimes\", kind);\n}\n\n/** `<agentDir>/models/<kind>` -- downloaded model weights, grouped by provider/runtime. */\nexport function modelsDir(kind: string, agentDir: string): string {\n\treturn join(agentDir, \"models\", kind);\n}\n\n/** `<agentDir>/sessions` -- session transcript storage (large, established; not a \"loose file\"). */\nexport function sessionsDir(agentDir: string): string {\n\treturn join(agentDir, \"sessions\");\n}\n\nfunction orchestrationSessionKey(parentSessionId: string): string {\n\tconst normalized = requireBoundedTrimmedText(parentSessionId, 512, \"Parent session id\");\n\tconst readable =\n\t\tencodeURIComponent(normalized)\n\t\t\t.replaceAll(\"%\", \"_\")\n\t\t\t// encodeURIComponent deliberately leaves `*` unescaped, but Windows forbids it in paths.\n\t\t\t// Restrict the readable prefix to a portable ASCII subset; the digest retains exact identity.\n\t\t\t.replaceAll(/[^a-zA-Z0-9._~-]/g, \"_\")\n\t\t\t.slice(0, 80) || \"session\";\n\tconst digest = createHash(\"sha256\").update(normalized).digest(\"hex\").slice(0, 16);\n\treturn `${readable}-${digest}`;\n}\n\n/**\n * `<agentDir>/state/orchestration/sessions/<session-key>` -- the one durable control-plane\n * bundle owned by a foreground session. Event state, worker mailboxes, mutation journals, and\n * worker transcripts must stay beneath this boundary so explicit session deletion can remove\n * exactly its companion artifacts without scanning global state.\n */\nexport function orchestrationSessionsDir(agentDir: string): string {\n\treturn stateFile(agentDir, \"orchestration\", \"sessions\");\n}\n\n/**\n * `<agentDir>/state/orchestration/sessions/<session-key>` -- the one durable control-plane\n * bundle owned by a foreground session.\n */\nexport function orchestrationSessionDir(agentDir: string, parentSessionId: string): string {\n\treturn join(orchestrationSessionsDir(agentDir), orchestrationSessionKey(parentSessionId));\n}\n\n/** `<orchestrationSessionDir>/events` -- append-only event tail, snapshot, cursor, and idempotency state. */\nexport function orchestrationEventStoreDir(agentDir: string, parentSessionId: string): string {\n\treturn join(orchestrationSessionDir(agentDir, parentSessionId), \"events\");\n}\n\n/**\n * `<orchestrationSessionDir>/worker-conversations` -- durable Pi worker transcripts owned by one\n * foreground session. Worker conversations remain in SessionManager's established JSONL format,\n * but are intentionally outside the foreground session picker namespace.\n */\nexport function workerConversationSessionsDir(agentDir: string, parentSessionId: string): string {\n\treturn join(orchestrationSessionDir(agentDir, parentSessionId), \"worker-conversations\");\n}\n\n/**\n * `<orchestrationSessionDir>/worker-mailboxes/<scope-digest>.json` -- durable bounded control\n * messages for one logical worker. Identity stays hashed so neither agent ids nor project paths\n * become path segments.\n */\nexport function workerAgentMailboxFile(agentDir: string, parentSessionId: string, scopeDigest: string): string {\n\tif (!/^[a-f0-9]{32,64}$/i.test(scopeDigest)) {\n\t\tthrow new TypeError(\"Worker agent mailbox scope digest must be a hexadecimal SHA-256 prefix.\");\n\t}\n\treturn join(\n\t\torchestrationSessionDir(agentDir, parentSessionId),\n\t\t\"worker-mailboxes\",\n\t\t`${scopeDigest.toLowerCase()}.json`,\n\t);\n}\n\n/**\n * `<orchestrationSessionDir>/worker-actions/<scope-digest>.json` -- durable, bounded mutation\n * intents and receipts for one fenced worker attempt. The opaque digest intentionally keeps task\n * identifiers out of filesystem path segments and works on Windows and WSL.\n */\nexport function workerActionJournalFile(agentDir: string, parentSessionId: string, scopeDigest: string): string {\n\tif (!/^[a-f0-9]{32,64}$/i.test(scopeDigest)) {\n\t\tthrow new TypeError(\"Worker action journal scope digest must be a hexadecimal SHA-256 prefix.\");\n\t}\n\treturn join(\n\t\torchestrationSessionDir(agentDir, parentSessionId),\n\t\t\"worker-actions\",\n\t\t`${scopeDigest.toLowerCase()}.json`,\n\t);\n}\n\n/** `<agentDir>/npm` -- managed npm package installs. */\nexport function npmDir(agentDir: string): string {\n\treturn join(agentDir, \"npm\");\n}\n\n/**\n * `<agentDir>/worktrees` -- lane worktree checkouts for the worktree-sync subsystem\n * (`core/worktree-sync/`), grouped as `worktrees/<repo-slug>/<laneKey>`. These hold REAL\n * uncommitted agent work, so they are durable like `state/` -- never under transient `work/`,\n * whose retention would silently eat in-progress code.\n */\nexport function worktreesDir(agentDir: string): string {\n\treturn join(agentDir, \"worktrees\");\n}\n\n/** `<agentDir>/git` -- managed git-sourced package installs. */\nexport function gitDir(agentDir: string): string {\n\treturn join(agentDir, \"git\");\n}\n\nexport type AgentResourceKind = \"skills\" | \"prompts\" | \"themes\" | \"extensions\" | \"profiles\";\n\n/** `<agentDir>/<kind>` -- a user-managed resource directory. Root, kept: moving it breaks users. */\nexport function resourceDir(kind: AgentResourceKind, agentDir: string): string {\n\treturn join(agentDir, kind);\n}\n\n/** `<agentDir>/profiles/directories` -- durable per-directory resource-profile overlays. */\nexport function directoryProfilesDir(agentDir: string): string {\n\treturn join(resourceDir(\"profiles\", agentDir), \"directories\");\n}\n\n/**\n * `work/` is a mature transient/scratch root with its own tenant/run/lease/retention machinery\n * (`utils/work-directory.ts`). The SSOT delegates to it wholesale instead of reimplementing -- these\n * are straight re-exports so every category (state/cache/work/runtimes/models/…) is reachable from one\n * module without duplicating `work-directory.ts`'s logic.\n */\nexport {\n\tgetWorkRoot,\n\tassertPortablePathSegment,\n\tboundedWorkRetention,\n\tgetWorkTenantDir,\n\tgetWorkRunDir,\n\tgetProcessWorkRun,\n\thasActiveWorkRunLease,\n\tacquireWorkRun,\n\tcreateWorkRunId,\n\tpruneWorkTenant,\n};\nexport type { AcquireWorkRunOptions, WorkRetentionOptions, WorkRunLease } from \"../utils/work-directory.ts\";\n\n/**\n * `work/reload-coordination` -- cross-process reload/live-op coordination state. Already correctly\n * work-scoped (defined in `reload-blockers.ts`, its natural home given the surrounding reload-gate\n * logic there); re-exported here under the taxonomy's canonical name for SSOT discoverability.\n */\nexport const reloadCoordinationDir = getReloadCoordinationDir;\n"]}
|
|
1
|
+
{"version":3,"file":"agent-paths.js","sourceRoot":"","sources":["../../src/core/agent-paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;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,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;QAC7C,MAAM,IAAI,SAAS,CAAC,0EAA0E,CAAC,CAAC;IACjG,CAAC;IACD,OAAO,IAAI,CACV,uBAAuB,CAAC,QAAQ,EAAE,eAAe,CAAC,EAClD,gBAAgB,EAChB,GAAG,WAAW,CAAC,WAAW,EAAE,OAAO,CACnC,CAAC;AACH,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,MAAM,CAAC,QAAgB;IACtC,OAAO,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AAC9B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,QAAgB;IAC5C,OAAO,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AACpC,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,MAAM,CAAC,QAAgB;IACtC,OAAO,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AAC9B,CAAC;AAID,oGAAoG;AACpG,MAAM,UAAU,WAAW,CAAC,IAAuB,EAAE,QAAgB;IACpE,OAAO,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AAC7B,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,oBAAoB,CAAC,QAAgB;IACpD,OAAO,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAE,aAAa,CAAC,CAAC;AAC/D,CAAC;AAED;;;;;GAKG;AACH,OAAO,EACN,WAAW,EACX,yBAAyB,EACzB,oBAAoB,EACpB,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,eAAe,GACf,CAAC;AAGF;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,wBAAwB,CAAC","sourcesContent":["/**\n * Typed path SSOT for everything machine-managed under `<agentDir>` (`~/.pi/agent/` by default,\n * `getAgentDir()` in `../config.ts`). Every writer that persists machine data (stores, caches, managed\n * runtimes/models, cross-process coordination) MUST resolve its path through one of the accessors\n * below instead of hand-rolling `join(agentDir, …)` — that ad-hoc pattern is exactly how root-level\n * stragglers like `trust.json` accumulated, and nothing stopped the next writer from doing it again.\n *\n * Canonical layout:\n * ```\n * <agentDir>/\n * auth.json settings.json models.json keybindings.json MEMORY.md USER.md SYSTEM.md … user CONFIG/MEMORY (root, kept)\n * okf-memory/ authored memory (root, kept)\n * skills/ extensions/ prompts/ themes/ profiles/ user RESOURCES (root, kept)\n * profiles/directories/<workspace-hash>/settings.json directory overlays\n * state/ durable machine state (model adaptation/fitness, tool performance,\n * learning observations, trust decisions, config backups, …) -- stateDir/stateFile\n * cache/ rebuildable, safe to delete (tool-path probes, jiti transform cache, uv) -- cacheDir/cacheFile\n * work/ transient/scratch, delegated to work-directory.ts (tenant/run/lease),\n * including context/sessions/<session-id>/{gc,artifacts} -- re-exported below\n * runtimes/<kind> models/<kind> -- runtimesDir/modelsDir\n * npm/ git/ sessions/ -- npmDir/gitDir/sessionsDir\n * state/orchestration/sessions/<session-key>/ -- one foreground-session-owned\n * control-plane bundle\n * worker-context-forks/<identity-digest>-<content-digest>.json -- immutable birth snapshots\n * worktrees/<repo-slug>/<laneKey> durable lane checkouts (core/worktree-sync) -- worktreesDir\n * ```\n *\n * Every accessor takes `agentDir` as an explicit, required first argument -- deliberately mirroring\n * `work-directory.ts`'s existing `getWorkRoot(agentDir)` convention rather than defaulting to\n * `getAgentDir()` internally. Several real callers (stores' `forAgentDir`, test harnesses with a temp\n * agentDir) build paths for a NON-default agentDir; a hidden default would silently resolve the wrong\n * root for those callers instead of failing loudly. Callers operating on the process-wide default pass\n * `getAgentDir()` explicitly at the call site.\n *\n * These accessors are pure path builders -- no directory creation, no I/O. Every existing writer\n * already creates its parent directory at write time (see `util/atomic-file.ts`'s\n * `mkdirSync(dirname(filePath), { recursive: true })`), so duplicating that here would be redundant\n * and would blur the \"pure function\" contract readers rely on.\n */\nimport { createHash } from \"node:crypto\";\nimport { join } from \"node:path\";\nimport {\n\tacquireWorkRun,\n\tassertPortablePathSegment,\n\tboundedWorkRetention,\n\tcreateWorkRunId,\n\tgetProcessWorkRun,\n\tgetWorkRoot,\n\tgetWorkRunDir,\n\tgetWorkTenantDir,\n\thasActiveWorkRunLease,\n\tpruneWorkTenant,\n} from \"../utils/work-directory.ts\";\nimport { getReloadCoordinationDir } from \"./reload-blockers.ts\";\nimport { requireBoundedTrimmedText } from \"./util/bounded-value.ts\";\n\n/** Root entries reserved for user-authored configuration and memory. */\nexport const AGENT_ROOT_FILE_NAMES = [\n\t\"auth.json\",\n\t\"settings.json\",\n\t\"models.json\",\n\t\"keybindings.json\",\n\t\"MEMORY.md\",\n\t\"USER.md\",\n\t\"SYSTEM.md\",\n\t\"APPEND_SYSTEM.md\",\n] as const;\n\n/** Root entries reserved for user resources and machine-managed storage classes. */\nexport const AGENT_ROOT_DIRECTORY_NAMES = [\n\t\"okf-memory\",\n\t\"skills\",\n\t\"extensions\",\n\t\"prompts\",\n\t\"themes\",\n\t\"profiles\",\n\t\"state\",\n\t\"cache\",\n\t\"bin\",\n\t\"work\",\n\t\"runtimes\",\n\t\"models\",\n\t\"sessions\",\n\t\"npm\",\n\t\"git\",\n\t\"worktrees\",\n] as const;\n\nconst AGENT_ROOT_ENTRY_NAMES = new Set<string>([...AGENT_ROOT_FILE_NAMES, ...AGENT_ROOT_DIRECTORY_NAMES]);\n\nexport function isCanonicalAgentRootEntry(name: string): boolean {\n\treturn AGENT_ROOT_ENTRY_NAMES.has(name);\n}\n\n/** `<agentDir>/<name>` -- a root-level user config/memory file (auth.json, settings.json, MEMORY.md, …). */\nexport function configFile(agentDir: string, name: string): string {\n\treturn join(agentDir, name);\n}\n\n/** `<agentDir>/okf-memory` -- user-authored durable OKF memory documents. */\nexport function okfMemoryDir(agentDir: string): string {\n\treturn join(agentDir, \"okf-memory\");\n}\n\n/** `<agentDir>/state` -- durable machine-managed state. Deleting it loses real history, not just cache. */\nexport function stateDir(agentDir: string): string {\n\treturn join(agentDir, \"state\");\n}\n\n/** `<agentDir>/state/<segments…>` */\nexport function stateFile(agentDir: string, ...segments: string[]): string {\n\treturn join(stateDir(agentDir), ...segments);\n}\n\nexport type ManagedMemoryFileName = \"MEMORY.md\" | \"USER.md\";\n\n/** `<agentDir>/state/memory/file-store/<name>.pi-managed.json` -- file-store ownership metadata. */\nexport function managedMemoryStateFile(agentDir: string, name: ManagedMemoryFileName): string {\n\tif (name !== \"MEMORY.md\" && name !== \"USER.md\") {\n\t\tthrow new TypeError(`Unsupported managed memory file name: ${name}`);\n\t}\n\treturn stateFile(agentDir, \"memory\", \"file-store\", `${name}.pi-managed.json`);\n}\n\n/** `<agentDir>/state/attachments` -- bounded, session-keyed clipboard image attachments. */\nexport function attachmentsDir(agentDir: string): string {\n\treturn stateFile(agentDir, \"attachments\");\n}\n\n/** Retired local-secret state root. Current credential storage is provider-backed and never writes here. */\nexport function secretsDir(agentDir: string): string {\n\treturn stateFile(agentDir, \"secrets\");\n}\n\n/** Retired local vault path retained only so model-facing file access stays denied. */\nexport function secretVaultFile(agentDir: string): string {\n\treturn join(secretsDir(agentDir), \"vault.json\");\n}\n\n/** Retired plaintext materialization root retained only so model-facing file access stays denied. */\nexport function managedSecretEnvDir(agentDir: string): string {\n\treturn join(secretsDir(agentDir), \"materialized\");\n}\n\n/** `<agentDir>/state/extensions/<namespace>` -- durable state owned by one extension. */\nexport function extensionStateDir(agentDir: string, namespace: string): string {\n\tassertPortablePathSegment(\"Extension namespace\", namespace);\n\treturn stateFile(agentDir, \"extensions\", namespace);\n}\n\n/** `<agentDir>/state/backups/config` -- explicit user-requested configuration snapshots. */\nexport function configBackupsDir(agentDir: string): string {\n\treturn stateFile(agentDir, \"backups\", \"config\");\n}\n\n/** `<agentDir>/cache` -- rebuildable; safe to delete (the next run just re-probes/recomputes). */\nexport function cacheDir(agentDir: string): string {\n\treturn join(agentDir, \"cache\");\n}\n\n/** `<agentDir>/cache/<segments…>` */\nexport function cacheFile(agentDir: string, ...segments: string[]): string {\n\treturn join(cacheDir(agentDir), ...segments);\n}\n\n/** `<agentDir>/cache/extensions/<namespace>` -- rebuildable cache owned by one extension. */\nexport function extensionCacheDir(agentDir: string, namespace: string): string {\n\tassertPortablePathSegment(\"Extension namespace\", namespace);\n\treturn cacheFile(agentDir, \"extensions\", namespace);\n}\n\n/** `<agentDir>/bin` -- managed executable helpers (fd, rg, jq, uv). */\nexport function binDir(agentDir: string): string {\n\treturn join(agentDir, \"bin\");\n}\n\n/** `<agentDir>/runtimes/<kind>` -- a managed runtime install (ollama, python, prism-llamacpp, needle, …). */\nexport function runtimesDir(kind: string, agentDir: string): string {\n\treturn join(agentDir, \"runtimes\", kind);\n}\n\n/** `<agentDir>/models/<kind>` -- downloaded model weights, grouped by provider/runtime. */\nexport function modelsDir(kind: string, agentDir: string): string {\n\treturn join(agentDir, \"models\", kind);\n}\n\n/** `<agentDir>/sessions` -- session transcript storage (large, established; not a \"loose file\"). */\nexport function sessionsDir(agentDir: string): string {\n\treturn join(agentDir, \"sessions\");\n}\n\nfunction orchestrationSessionKey(parentSessionId: string): string {\n\tconst normalized = requireBoundedTrimmedText(parentSessionId, 512, \"Parent session id\");\n\tconst readable =\n\t\tencodeURIComponent(normalized)\n\t\t\t.replaceAll(\"%\", \"_\")\n\t\t\t// encodeURIComponent deliberately leaves `*` unescaped, but Windows forbids it in paths.\n\t\t\t// Restrict the readable prefix to a portable ASCII subset; the digest retains exact identity.\n\t\t\t.replaceAll(/[^a-zA-Z0-9._~-]/g, \"_\")\n\t\t\t.slice(0, 80) || \"session\";\n\tconst digest = createHash(\"sha256\").update(normalized).digest(\"hex\").slice(0, 16);\n\treturn `${readable}-${digest}`;\n}\n\n/**\n * `<agentDir>/state/orchestration/sessions/<session-key>` -- the one durable control-plane\n * bundle owned by a foreground session. Event state, worker mailboxes, mutation journals, and\n * worker transcripts must stay beneath this boundary so explicit session deletion can remove\n * exactly its companion artifacts without scanning global state.\n */\nexport function orchestrationSessionsDir(agentDir: string): string {\n\treturn stateFile(agentDir, \"orchestration\", \"sessions\");\n}\n\n/**\n * `<agentDir>/state/orchestration/sessions/<session-key>` -- the one durable control-plane\n * bundle owned by a foreground session.\n */\nexport function orchestrationSessionDir(agentDir: string, parentSessionId: string): string {\n\treturn join(orchestrationSessionsDir(agentDir), orchestrationSessionKey(parentSessionId));\n}\n\n/** `<orchestrationSessionDir>/events` -- append-only event tail, snapshot, cursor, and idempotency state. */\nexport function orchestrationEventStoreDir(agentDir: string, parentSessionId: string): string {\n\treturn join(orchestrationSessionDir(agentDir, parentSessionId), \"events\");\n}\n\n/**\n * `<orchestrationSessionDir>/worker-conversations` -- durable Pi worker transcripts owned by one\n * foreground session. Worker conversations remain in SessionManager's established JSONL format,\n * but are intentionally outside the foreground session picker namespace.\n */\nexport function workerConversationSessionsDir(agentDir: string, parentSessionId: string): string {\n\treturn join(orchestrationSessionDir(agentDir, parentSessionId), \"worker-conversations\");\n}\n\n/** `<orchestrationSessionDir>/worker-context-forks` -- immutable sanitized worker birth snapshots. */\nexport function workerContextForksDir(agentDir: string, parentSessionId: string): string {\n\treturn join(orchestrationSessionDir(agentDir, parentSessionId), \"worker-context-forks\");\n}\n\n/**\n * `<workerContextForksDir>/<identity-digest>-<content-digest>.json` -- one immutable,\n * content-addressed sanitized worker birth snapshot.\n */\nexport function workerContextForkFile(\n\tagentDir: string,\n\tparentSessionId: string,\n\tidentityDigest: string,\n\tcontentDigest: string,\n): string {\n\tif (!/^[a-f0-9]{64}$/i.test(identityDigest) || !/^[a-f0-9]{64}$/i.test(contentDigest)) {\n\t\tthrow new TypeError(\"Worker context fork identities must be hexadecimal SHA-256 digests.\");\n\t}\n\treturn join(\n\t\tworkerContextForksDir(agentDir, parentSessionId),\n\t\t`${identityDigest.toLowerCase()}-${contentDigest.toLowerCase()}.json`,\n\t);\n}\n\n/**\n * `<orchestrationSessionDir>/worker-mailboxes/<scope-digest>.json` -- durable bounded control\n * messages for one logical worker. Identity stays hashed so neither agent ids nor project paths\n * become path segments.\n */\nexport function workerAgentMailboxFile(agentDir: string, parentSessionId: string, scopeDigest: string): string {\n\tif (!/^[a-f0-9]{32,64}$/i.test(scopeDigest)) {\n\t\tthrow new TypeError(\"Worker agent mailbox scope digest must be a hexadecimal SHA-256 prefix.\");\n\t}\n\treturn join(\n\t\torchestrationSessionDir(agentDir, parentSessionId),\n\t\t\"worker-mailboxes\",\n\t\t`${scopeDigest.toLowerCase()}.json`,\n\t);\n}\n\n/**\n * `<orchestrationSessionDir>/session-root-mailbox.json` -- the bounded durable reply inbox for the\n * owning foreground session. The parent session identity is already encoded in the enclosing\n * session directory, so this fixed filename cannot collide with another session root.\n */\nexport function sessionRootMailboxFile(agentDir: string, parentSessionId: string): string {\n\treturn join(orchestrationSessionDir(agentDir, parentSessionId), \"session-root-mailbox.json\");\n}\n\n/**\n * `<orchestrationSessionDir>/worker-actions/<scope-digest>.json` -- durable, bounded mutation\n * intents and receipts for one fenced worker attempt. The opaque digest intentionally keeps task\n * identifiers out of filesystem path segments and works on Windows and WSL.\n */\nexport function workerActionJournalFile(agentDir: string, parentSessionId: string, scopeDigest: string): string {\n\tif (!/^[a-f0-9]{32,64}$/i.test(scopeDigest)) {\n\t\tthrow new TypeError(\"Worker action journal scope digest must be a hexadecimal SHA-256 prefix.\");\n\t}\n\treturn join(\n\t\torchestrationSessionDir(agentDir, parentSessionId),\n\t\t\"worker-actions\",\n\t\t`${scopeDigest.toLowerCase()}.json`,\n\t);\n}\n\n/** `<agentDir>/npm` -- managed npm package installs. */\nexport function npmDir(agentDir: string): string {\n\treturn join(agentDir, \"npm\");\n}\n\n/**\n * `<agentDir>/worktrees` -- lane worktree checkouts for the worktree-sync subsystem\n * (`core/worktree-sync/`), grouped as `worktrees/<repo-slug>/<laneKey>`. These hold REAL\n * uncommitted agent work, so they are durable like `state/` -- never under transient `work/`,\n * whose retention would silently eat in-progress code.\n */\nexport function worktreesDir(agentDir: string): string {\n\treturn join(agentDir, \"worktrees\");\n}\n\n/** `<agentDir>/git` -- managed git-sourced package installs. */\nexport function gitDir(agentDir: string): string {\n\treturn join(agentDir, \"git\");\n}\n\nexport type AgentResourceKind = \"skills\" | \"prompts\" | \"themes\" | \"extensions\" | \"profiles\";\n\n/** `<agentDir>/<kind>` -- a user-managed resource directory. Root, kept: moving it breaks users. */\nexport function resourceDir(kind: AgentResourceKind, agentDir: string): string {\n\treturn join(agentDir, kind);\n}\n\n/** `<agentDir>/profiles/directories` -- durable per-directory resource-profile overlays. */\nexport function directoryProfilesDir(agentDir: string): string {\n\treturn join(resourceDir(\"profiles\", agentDir), \"directories\");\n}\n\n/**\n * `work/` is a mature transient/scratch root with its own tenant/run/lease/retention machinery\n * (`utils/work-directory.ts`). The SSOT delegates to it wholesale instead of reimplementing -- these\n * are straight re-exports so every category (state/cache/work/runtimes/models/…) is reachable from one\n * module without duplicating `work-directory.ts`'s logic.\n */\nexport {\n\tgetWorkRoot,\n\tassertPortablePathSegment,\n\tboundedWorkRetention,\n\tgetWorkTenantDir,\n\tgetWorkRunDir,\n\tgetProcessWorkRun,\n\thasActiveWorkRunLease,\n\tacquireWorkRun,\n\tcreateWorkRunId,\n\tpruneWorkTenant,\n};\nexport type { AcquireWorkRunOptions, WorkRetentionOptions, WorkRunLease } from \"../utils/work-directory.ts\";\n\n/**\n * `work/reload-coordination` -- cross-process reload/live-op coordination state. Already correctly\n * work-scoped (defined in `reload-blockers.ts`, its natural home given the surrounding reload-gate\n * logic there); re-exported here under the taxonomy's canonical name for SSOT discoverability.\n */\nexport const reloadCoordinationDir = getReloadCoordinationDir;\n"]}
|
|
@@ -15,8 +15,15 @@ export interface BoundedCompletionOutcome {
|
|
|
15
15
|
failure?: {
|
|
16
16
|
status: BoundedCompletionFailureStatus;
|
|
17
17
|
reasonCode: string;
|
|
18
|
+
detail?: string;
|
|
18
19
|
};
|
|
19
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Preserve the executor's actual error alongside the stable reason code. A bare
|
|
23
|
+
* `completion_error` is undiagnosable from lane records alone (field lesson: workers dying
|
|
24
|
+
* on provider socket drops and budget denials all flattened to the same code).
|
|
25
|
+
*/
|
|
26
|
+
export declare function boundedFailureDetail(error: unknown): string | undefined;
|
|
20
27
|
export declare function runBoundedCompletion(args: {
|
|
21
28
|
/** Wall-clock budget in milliseconds; 0 disables. */
|
|
22
29
|
maxWallClockMs: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bounded-completion.d.ts","sourceRoot":"","sources":["../../../src/core/autonomy/bounded-completion.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bounded-completion.d.ts","sourceRoot":"","sources":["../../../src/core/autonomy/bounded-completion.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,MAAM,WAAW,iBAAiB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,8BAA8B,GAAG,UAAU,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE/E,MAAM,WAAW,wBAAwB;IACxC,oGAAoG;IACpG,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,OAAO,CAAC,EAAE;QAAE,MAAM,EAAE,8BAA8B,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1F;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAIvE;AAeD,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAChD,qDAAqD;IACrD,cAAc,EAAE,MAAM,CAAC;IACvB,qDAAqD;IACrD,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC7D,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAoFpC"}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
import { boundedRedactedDiagnosticText } from "../security/secret-text.js";
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Preserve the executor's actual error alongside the stable reason code. A bare
|
|
4
|
+
* `completion_error` is undiagnosable from lane records alone (field lesson: workers dying
|
|
5
|
+
* on provider socket drops and budget denials all flattened to the same code).
|
|
5
6
|
*/
|
|
7
|
+
export function boundedFailureDetail(error) {
|
|
8
|
+
const message = error instanceof Error ? error.message : typeof error === "string" ? error : undefined;
|
|
9
|
+
if (!message)
|
|
10
|
+
return undefined;
|
|
11
|
+
return boundedRedactedDiagnosticText(message);
|
|
12
|
+
}
|
|
6
13
|
const MAX_HOST_TIMER_DELAY_MS = 2_147_483_647;
|
|
7
14
|
function abortFailure(args) {
|
|
8
15
|
if (args.externalSignal?.aborted)
|
|
@@ -71,10 +78,11 @@ export async function runBoundedCompletion(args) {
|
|
|
71
78
|
};
|
|
72
79
|
}
|
|
73
80
|
if (winner.kind === "error") {
|
|
81
|
+
const detail = boundedFailureDetail(winner.error);
|
|
74
82
|
return {
|
|
75
83
|
failure: args.signal?.aborted || timeoutController.signal.aborted
|
|
76
84
|
? abortFailure({ externalSignal: args.signal, timeoutSignal: timeoutController.signal })
|
|
77
|
-
: { status: "failed", reasonCode: "completion_error" },
|
|
85
|
+
: { status: "failed", reasonCode: "completion_error", ...(detail ? { detail } : {}) },
|
|
78
86
|
};
|
|
79
87
|
}
|
|
80
88
|
const completion = winner.completion;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bounded-completion.js","sourceRoot":"","sources":["../../../src/core/autonomy/bounded-completion.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"bounded-completion.js","sourceRoot":"","sources":["../../../src/core/autonomy/bounded-completion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,C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AE,CAAC;oBACxF,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,kBAAkB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE;aACvF,CAAC;QACH,CAAC;QAED,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACrC,IAAI,IAAI,CAAC,MAAM,EAAE,OAAO,IAAI,iBAAiB,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YAC9D,OAAO;gBACN,UAAU;gBACV,OAAO,EAAE,YAAY,CAAC,EAAE,cAAc,EAAE,IAAI,CAAC,MAAM,EAAE,aAAa,EAAE,iBAAiB,CAAC,MAAM,EAAE,CAAC;aAC/F,CAAC;QACH,CAAC;QACD,OAAO,EAAE,UAAU,EAAE,CAAC;IACvB,CAAC;YAAS,CAAC;QACV,IAAI,YAAY,KAAK,SAAS;YAAE,YAAY,CAAC,YAAY,CAAC,CAAC;QAC3D,IAAI,CAAC,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IAC5D,CAAC;AACF,CAAC","sourcesContent":["import { boundedRedactedDiagnosticText } from \"../security/secret-text.ts\";\n\n/**\n * Shared wall-clock/cancellation envelope for one-shot lane completions (research and delegated workers).\n * Composes an optional external abort signal with an internal wall-clock timeout, executes the\n * injected completion, and maps every failure to a stable status/reasonCode pair. Never throws.\n */\n\nexport interface BoundedCompletion {\n\ttext: string;\n\tcostUsd: number;\n\tstopReason: string;\n}\n\nexport type BoundedCompletionFailureStatus = \"canceled\" | \"timeout\" | \"failed\";\n\nexport interface BoundedCompletionOutcome {\n\t/** Present when the executor settled; may coexist with `failure` when an abort raced the result. */\n\tcompletion?: BoundedCompletion;\n\tfailure?: { status: BoundedCompletionFailureStatus; reasonCode: string; detail?: string };\n}\n\n/**\n * Preserve the executor's actual error alongside the stable reason code. A bare\n * `completion_error` is undiagnosable from lane records alone (field lesson: workers dying\n * on provider socket drops and budget denials all flattened to the same code).\n */\nexport function boundedFailureDetail(error: unknown): string | undefined {\n\tconst message = error instanceof Error ? error.message : typeof error === \"string\" ? error : undefined;\n\tif (!message) return undefined;\n\treturn boundedRedactedDiagnosticText(message);\n}\n\ntype ExecutorSettlement = { kind: \"completion\"; completion: BoundedCompletion } | { kind: \"error\"; error: unknown };\n\nconst MAX_HOST_TIMER_DELAY_MS = 2_147_483_647;\n\nfunction abortFailure(args: {\n\texternalSignal?: AbortSignal;\n\ttimeoutSignal: AbortSignal;\n}): BoundedCompletionOutcome[\"failure\"] {\n\tif (args.externalSignal?.aborted) return { status: \"canceled\", reasonCode: \"external_abort\" };\n\tif (args.timeoutSignal.aborted) return { status: \"timeout\", reasonCode: \"wall_clock_exceeded\" };\n\treturn { status: \"failed\", reasonCode: \"completion_error\" };\n}\n\nexport async function runBoundedCompletion(args: {\n\t/** Wall-clock budget in milliseconds; 0 disables. */\n\tmaxWallClockMs: number;\n\t/** External cancellation (e.g. session disposal). */\n\tsignal?: AbortSignal;\n\texecute: (signal: AbortSignal) => Promise<BoundedCompletion>;\n}): Promise<BoundedCompletionOutcome> {\n\tconst timeoutController = new AbortController();\n\tlet resolveAbort!: () => void;\n\tconst abortPromise = new Promise<{ kind: \"abort\" }>((resolve) => {\n\t\tresolveAbort = () => resolve({ kind: \"abort\" });\n\t});\n\tconst onExternalAbort = (): void => resolveAbort();\n\targs.signal?.addEventListener(\"abort\", onExternalAbort, { once: true });\n\tlet timeoutTimer: ReturnType<typeof setTimeout> | undefined;\n\tlet remainingWallClockMs = args.maxWallClockMs;\n\tconst armTimeout = (): void => {\n\t\tconst delayMs = Math.min(remainingWallClockMs, MAX_HOST_TIMER_DELAY_MS);\n\t\ttimeoutTimer = setTimeout(() => {\n\t\t\tremainingWallClockMs -= delayMs;\n\t\t\tif (remainingWallClockMs > 0) {\n\t\t\t\tarmTimeout();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttimeoutController.abort();\n\t\t\tresolveAbort();\n\t\t}, delayMs);\n\t\tif (typeof timeoutTimer === \"object\" && \"unref\" in timeoutTimer) {\n\t\t\tconst { unref } = timeoutTimer as { unref?: () => void };\n\t\t\tunref?.call(timeoutTimer);\n\t\t}\n\t};\n\tif (args.maxWallClockMs > 0) armTimeout();\n\tconst signals: AbortSignal[] = [timeoutController.signal];\n\tif (args.signal) signals.push(args.signal);\n\tconst signal = AbortSignal.any(signals);\n\n\tlet settled: ExecutorSettlement | undefined;\n\tconst execution = Promise.resolve()\n\t\t.then(() => args.execute(signal))\n\t\t.then<ExecutorSettlement, ExecutorSettlement>(\n\t\t\t(completion) => {\n\t\t\t\tsettled = { kind: \"completion\", completion };\n\t\t\t\treturn settled;\n\t\t\t},\n\t\t\t(error: unknown) => {\n\t\t\t\tsettled = { kind: \"error\", error };\n\t\t\t\treturn settled;\n\t\t\t},\n\t\t);\n\tif (args.signal?.aborted) resolveAbort();\n\n\ttry {\n\t\tconst winner = await Promise.race([execution, abortPromise]);\n\t\tif (winner.kind === \"abort\") {\n\t\t\t// An abort and a completion can settle in the same microtask turn. Give the already-queued\n\t\t\t// executor handlers one chance to retain that completion (and its visible spend) without\n\t\t\t// ever waiting for a non-cooperative executor. Later settlement remains observed by\n\t\t\t// `execution`'s rejection handler, preventing an unhandled rejection after this returns.\n\t\t\tfor (let flush = 0; flush < 4 && settled === undefined; flush++) {\n\t\t\t\tawait Promise.resolve();\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t...(settled?.kind === \"completion\" ? { completion: settled.completion } : {}),\n\t\t\t\tfailure: abortFailure({ externalSignal: args.signal, timeoutSignal: timeoutController.signal }),\n\t\t\t};\n\t\t}\n\n\t\tif (winner.kind === \"error\") {\n\t\t\tconst detail = boundedFailureDetail(winner.error);\n\t\t\treturn {\n\t\t\t\tfailure:\n\t\t\t\t\targs.signal?.aborted || timeoutController.signal.aborted\n\t\t\t\t\t\t? abortFailure({ externalSignal: args.signal, timeoutSignal: timeoutController.signal })\n\t\t\t\t\t\t: { status: \"failed\", reasonCode: \"completion_error\", ...(detail ? { detail } : {}) },\n\t\t\t};\n\t\t}\n\n\t\tconst completion = winner.completion;\n\t\tif (args.signal?.aborted || timeoutController.signal.aborted) {\n\t\t\treturn {\n\t\t\t\tcompletion,\n\t\t\t\tfailure: abortFailure({ externalSignal: args.signal, timeoutSignal: timeoutController.signal }),\n\t\t\t};\n\t\t}\n\t\treturn { completion };\n\t} finally {\n\t\tif (timeoutTimer !== undefined) clearTimeout(timeoutTimer);\n\t\targs.signal?.removeEventListener(\"abort\", onExternalAbort);\n\t}\n}\n"]}
|
|
@@ -33,6 +33,8 @@ export interface LaneToolSurfaceOptions {
|
|
|
33
33
|
processMaxWallClockMs?: number;
|
|
34
34
|
/** Stable per-agent shell identity. Omitted when the compiled plan does not grant a host shell. */
|
|
35
35
|
shellSessionKey?: string;
|
|
36
|
+
/** Host-owned managed directory for complete shell output; never inferred from process-global config. */
|
|
37
|
+
shellOutputDirectory?: string;
|
|
36
38
|
/** Compiled policy path. When present, it is the only authorization source for this surface. */
|
|
37
39
|
grant?: ExecutionGrant;
|
|
38
40
|
toolManifests?: readonly ToolCapabilityManifest[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lane-tool-surface.d.ts","sourceRoot":"","sources":["../../../src/core/autonomy/lane-tool-surface.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAG5E,OAAO,EACN,iBAAiB,EAEjB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,MAAM,wCAAwC,CAAC;AAChD,OAAO,KAAK,EACX,cAAc,EACd,4BAA4B,EAC5B,sBAAsB,EACtB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AA6BhE,MAAM,WAAW,eAAe;IAC/B,oGAAoG;IACpG,KAAK,EAAE,SAAS,EAA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AmG;IACnG,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,yGAAyG;IACzG,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,gGAAgG;IAChG,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,aAAa,CAAC,EAAE,SAAS,sBAAsB,EAAE,CAAC;IAClD,2GAA2G;IAC3G,eAAe,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;IACvC,sFAAsF;IACtF,YAAY,CAAC,EAAE,mBAAmB,CAAC;IACnC,6EAA6E;IAC7E,YAAY,CAAC,EAAE,sBAAsB,CAAC;CACtC;AAgFD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,GAAG,eAAe,CA6HtF"}
|
|
@@ -40,7 +40,7 @@ function strictLaneProfilePatterns(profile) {
|
|
|
40
40
|
function resolveWriteRoots(cwd, writePaths) {
|
|
41
41
|
return writePaths.map((entry) => (path.isAbsolute(entry) ? path.resolve(entry) : path.resolve(cwd, entry)));
|
|
42
42
|
}
|
|
43
|
-
function createLaneTools(cwd, names, fileMutationIntents, additionalTools, readMemory, executionPolicy, processMaxWallClockMs = 0, shellSessionKey) {
|
|
43
|
+
function createLaneTools(cwd, names, fileMutationIntents, additionalTools, readMemory, executionPolicy, processMaxWallClockMs = 0, shellSessionKey, shellOutputDirectory) {
|
|
44
44
|
const factories = new Map([
|
|
45
45
|
["read", () => createReadTool(cwd)],
|
|
46
46
|
["grep", () => createGrepTool(cwd)],
|
|
@@ -53,7 +53,10 @@ function createLaneTools(cwd, names, fileMutationIntents, additionalTools, readM
|
|
|
53
53
|
factories.set(PROCESS_LANE_TOOL_NAME, () => createRunProcessTool(cwd, { policy: executionPolicy, maxWallClockMs: processMaxWallClockMs }));
|
|
54
54
|
}
|
|
55
55
|
if (shellSessionKey) {
|
|
56
|
-
factories.set(STABLE_SHELL_TOOL_NAME, () => createBashTool(cwd, {
|
|
56
|
+
factories.set(STABLE_SHELL_TOOL_NAME, () => createBashTool(cwd, {
|
|
57
|
+
sessionKey: shellSessionKey,
|
|
58
|
+
...(shellOutputDirectory ? { outputDirectory: shellOutputDirectory } : {}),
|
|
59
|
+
}));
|
|
57
60
|
}
|
|
58
61
|
if (readMemory) {
|
|
59
62
|
factories.set(MEMORY_LANE_TOOL_NAME, () => ({
|
|
@@ -160,7 +163,7 @@ export function createLaneToolSurface(options) {
|
|
|
160
163
|
...(deniedPaths && deniedPaths.length > 0 ? { deniedPaths } : {}),
|
|
161
164
|
};
|
|
162
165
|
return {
|
|
163
|
-
tools: createLaneTools(options.cwd, allowedTools, fileMutationIntents, additionalTools, options.readMemory, options.executionPolicy, options.processMaxWallClockMs, options.shellSessionKey),
|
|
166
|
+
tools: createLaneTools(options.cwd, allowedTools, fileMutationIntents, additionalTools, options.readMemory, options.executionPolicy, options.processMaxWallClockMs, options.shellSessionKey, options.shellOutputDirectory),
|
|
164
167
|
dispose: () => fileMutationIntents.dispose(),
|
|
165
168
|
allowedTools,
|
|
166
169
|
deniedTools,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lane-tool-surface.js","sourceRoot":"","sources":["../../../src/core/autonomy/lane-tool-surface.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EACN,iBAAiB,EACjB,4BAA4B,GAG5B,MAAM,wCAAwC,CAAC;AAOhD,OAAO,EAAE,mCAAmC,EAAE,MAAM,yCAAyC,CAAC;AAC9F,OAAO,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,4BAA4B,EAAE,MAAM,kCAAkC,CAAC;AAChF,OAAO,EA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G,gBAAgB,CAAC;gBAChC,QAAQ,EAAE,QAAQ,CAAC,IAAI;gBACvB,IAAI;gBACJ,GAAG,EAAE,OAAO,CAAC,GAAG;gBAChB,QAAQ,EAAE,wBAAwB,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY;aACpF,CAAC,CAAC;YACH,IAAI,OAAO,CAAC,OAAO,KAAK,OAAO;gBAAE,OAAO,SAAS,CAAC;YAClD,OAAO;gBACN,KAAK,EAAE,IAAI;gBACX,MAAM,EAAE,sBAAsB,OAAO,CAAC,UAAU,MAAM,OAAO,CAAC,OAAO,IAAI,2BAA2B,EAAE;aACtG,CAAC;QACH,CAAC;QACD,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC/B,CAAC;AACH,CAAC","sourcesContent":["import path from \"node:path\";\nimport type { AgentLoopConfig, AgentTool } from \"@caupulican/pi-agent-core\";\nimport { type Static, Type } from \"typebox\";\nimport { STABLE_SHELL_TOOL_NAME } from \"../default-tool-surface.ts\";\nimport {\n\tCapabilityGateway,\n\tCapabilityGatewayDeniedError,\n\ttype GatewayInitialUsage,\n\ttype SharedCapabilityBudget,\n} from \"../orchestration/capability-gateway.ts\";\nimport type {\n\tExecutionGrant,\n\tOrchestrationExecutionPolicy,\n\tToolCapabilityManifest,\n} from \"../orchestration/contracts.ts\";\nimport type { NormalizedProfile } from \"../profile-registry.ts\";\nimport { wrapToolWithCredentialExposureGuard } from \"../secrets/credential-exposure-guard.ts\";\nimport { matchesResourceProfilePattern } from \"../settings-manager.ts\";\nimport { createBashTool } from \"../tools/bash.ts\";\nimport { createEditTool } from \"../tools/edit.ts\";\nimport { FileMutationIntentController } from \"../tools/file-mutation-intent.ts\";\nimport { createFindTool } from \"../tools/find.ts\";\nimport { createGrepTool } from \"../tools/grep.ts\";\nimport { createLsTool } from \"../tools/ls.ts\";\nimport { createReadTool } from \"../tools/read.ts\";\nimport { createRunProcessTool } from \"../tools/run-process.ts\";\nimport { createWriteTool } from \"../tools/write.ts\";\nimport type { CapabilityEnvelope } from \"./contracts.ts\";\nimport { evaluateToolGate } from \"./gates.ts\";\n\nconst READ_ONLY_LANE_TOOL_NAMES = [\"read\", \"grep\", \"find\", \"ls\"] as const;\nconst MEMORY_LANE_TOOL_NAME = \"memory\" as const;\nconst WRITE_LANE_TOOL_NAMES = [\"write\", \"edit\"] as const;\nconst PROCESS_LANE_TOOL_NAME = \"run_process\" as const;\nconst MAX_LANE_MEMORY_QUERY_CHARS = 4_096;\nconst laneMemorySchema = Type.Object({\n\tquery: Type.String({\n\t\tmaxLength: MAX_LANE_MEMORY_QUERY_CHARS,\n\t\tdescription: \"What relevant standing memory or prior evidence to retrieve\",\n\t}),\n});\ntype LaneMemoryParams = Static<typeof laneMemorySchema>;\nconst WRITE_LANE_TOOL_NAME_SET = new Set<string>(WRITE_LANE_TOOL_NAMES);\n\nexport interface LaneToolSurface {\n\t/** Fresh tools owned by this lane only; no foreground tool instances or extension state leak in. */\n\ttools: AgentTool[];\n\t/** Release exact mutation payload leases owned by this isolated lane. */\n\tdispose(): Promise<void>;\n\t/** Exact names after profile globs are expanded. Safe to persist in a capability envelope. */\n\tallowedTools: string[];\n\t/** Exact safe-candidate names denied by the profile's block patterns. */\n\tdeniedTools: string[];\n\t/** Explicit grants that bind to no classified lane candidate (opaque tools stay fail-closed). */\n\tunboundAllowPatterns: string[];\n\t/** Per-call path and capability gate for the isolated child loop. */\n\tbeforeToolCall: NonNullable<AgentLoopConfig[\"beforeToolCall\"]>;\n\t/** Canonical cumulative authority/budget meter for a compiled worker grant. */\n\tgateway?: CapabilityGateway;\n}\n\nexport interface LaneToolSurfaceOptions {\n\tcwd: string;\n\tprofile?: NormalizedProfile;\n\t/** Private harness state that generic file tools must never traverse. */\n\tdeniedPaths?: readonly string[];\n\t/** Orchestrator-requested, policy-filtered read-only memory retrieval. Omitted means no memory tool. */\n\treadMemory?: (query: string) => Promise<string>;\n\t/** Research never sets this. Workers require both this flag and at least one write path. */\n\twriteEnabled?: boolean;\n\twritePaths?: readonly string[];\n\t/** Present only for process-capable owner profiles; absent means no process tool is materialized. */\n\texecutionPolicy?: OrchestrationExecutionPolicy;\n\tprocessMaxWallClockMs?: number;\n\t/** Stable per-agent shell identity. Omitted when the compiled plan does not grant a host shell. */\n\tshellSessionKey?: string;\n\t/** Compiled policy path. When present, it is the only authorization source for this surface. */\n\tgrant?: ExecutionGrant;\n\ttoolManifests?: readonly ToolCapabilityManifest[];\n\t/** Runtime-owned classified tools composed specifically for this lane (for example delegation control). */\n\tadditionalTools?: readonly AgentTool[];\n\t/** Durable cumulative active usage to seed the compiled grant's gateway on resume. */\n\tinitialUsage?: GatewayInitialUsage;\n\t/** Root-tree aggregate meter shared by this attempt and every descendant. */\n\tsharedBudget?: SharedCapabilityBudget;\n}\n\nfunction strictLaneProfilePatterns(profile: NormalizedProfile | undefined): {\n\tallow: string[];\n\tblock: string[];\n} {\n\tif (!profile) return { allow: [], block: [] };\n\tconst filter = profile.resources.tools;\n\tconst allow = [...(filter?.allow ?? [])];\n\tconst block = [...(filter?.block ?? [])];\n\t// Strict UAC: a shipped profile is the complete authority grant. Grant-all must be explicit.\n\tif (allow.length === 0 && block.length === 0) return { allow: [], block: [\"*\"] };\n\treturn { allow, block };\n}\n\nfunction resolveWriteRoots(cwd: string, writePaths: readonly string[]): string[] {\n\treturn writePaths.map((entry) => (path.isAbsolute(entry) ? path.resolve(entry) : path.resolve(cwd, entry)));\n}\n\nfunction createLaneTools(\n\tcwd: string,\n\tnames: readonly string[],\n\tfileMutationIntents: FileMutationIntentController,\n\tadditionalTools: ReadonlyMap<string, AgentTool>,\n\treadMemory?: (query: string) => Promise<string>,\n\texecutionPolicy?: OrchestrationExecutionPolicy,\n\tprocessMaxWallClockMs = 0,\n\tshellSessionKey?: string,\n): AgentTool[] {\n\tconst factories = new Map<string, () => AgentTool>([\n\t\t[\"read\", () => createReadTool(cwd)],\n\t\t[\"grep\", () => createGrepTool(cwd)],\n\t\t[\"find\", () => createFindTool(cwd)],\n\t\t[\"ls\", () => createLsTool(cwd)],\n\t\t[\"write\", () => createWriteTool(cwd, { intentController: fileMutationIntents })],\n\t\t[\"edit\", () => createEditTool(cwd, { intentController: fileMutationIntents })],\n\t]);\n\tif (executionPolicy) {\n\t\tfactories.set(PROCESS_LANE_TOOL_NAME, () =>\n\t\t\tcreateRunProcessTool(cwd, { policy: executionPolicy, maxWallClockMs: processMaxWallClockMs }),\n\t\t);\n\t}\n\tif (shellSessionKey) {\n\t\tfactories.set(STABLE_SHELL_TOOL_NAME, () => createBashTool(cwd, { sessionKey: shellSessionKey }));\n\t}\n\tif (readMemory) {\n\t\tfactories.set(MEMORY_LANE_TOOL_NAME, () => ({\n\t\t\tname: MEMORY_LANE_TOOL_NAME,\n\t\t\tlabel: \"Read Memory\",\n\t\t\tdescription:\n\t\t\t\t\"Retrieve bounded, source-labeled standing memory relevant to this delegated task. Read-only: no memory writes or lifecycle actions are available.\",\n\t\t\tparameters: laneMemorySchema,\n\t\t\texecute: async (_toolCallId, params) => {\n\t\t\t\tconst query = (params as LaneMemoryParams).query?.trim();\n\t\t\t\tif (!query || query.length > MAX_LANE_MEMORY_QUERY_CHARS) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`memory_query_invalid: query must contain from 1 through ${MAX_LANE_MEMORY_QUERY_CHARS} characters.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\" as const, text: await readMemory(query) }],\n\t\t\t\t\tdetails: { readOnly: true },\n\t\t\t\t};\n\t\t\t},\n\t\t}));\n\t}\n\treturn names.flatMap((name) => {\n\t\tconst additional = additionalTools.get(name);\n\t\tif (additional) return [additional];\n\t\tconst factory = factories.get(name);\n\t\treturn factory ? [wrapToolWithCredentialExposureGuard(factory(), cwd)] : [];\n\t});\n}\n\n/**\n * Materialize a fresh, fail-closed tool surface for one isolated lane.\n *\n * Admission selects classified built-ins plus runtime-owned injected controls. A compiled grant is\n * the only authority source for worker lanes; host shell and recursive delegation are materialized\n * when named by that grant. Write/edit additionally require the global write switch and a positive\n * path scope.\n */\nexport function createLaneToolSurface(options: LaneToolSurfaceOptions): LaneToolSurface {\n\tconst fileMutationIntents = new FileMutationIntentController();\n\tconst additionalTools = new Map<string, AgentTool>();\n\tfor (const tool of options.additionalTools ?? []) {\n\t\tif (!tool.name.trim()) throw new Error(\"An injected lane tool must have a name.\");\n\t\tif (additionalTools.has(tool.name)) throw new Error(`Injected lane tool '${tool.name}' is duplicated.`);\n\t\tadditionalTools.set(tool.name, tool);\n\t}\n\tconst writeCapable = options.writeEnabled === true && (options.writePaths?.length ?? 0) > 0;\n\tconst builtInCandidateNames = [\n\t\t...READ_ONLY_LANE_TOOL_NAMES,\n\t\t...(options.readMemory ? [MEMORY_LANE_TOOL_NAME] : []),\n\t\t...(writeCapable ? WRITE_LANE_TOOL_NAMES : []),\n\t\t...(options.executionPolicy ? [PROCESS_LANE_TOOL_NAME] : []),\n\t\t...(options.shellSessionKey ? [STABLE_SHELL_TOOL_NAME] : []),\n\t];\n\tfor (const name of additionalTools.keys()) {\n\t\tif (builtInCandidateNames.includes(name as (typeof builtInCandidateNames)[number])) {\n\t\t\tthrow new Error(`Injected lane tool '${name}' conflicts with a built-in lane tool.`);\n\t\t}\n\t}\n\tconst candidateNames = [...builtInCandidateNames, ...additionalTools.keys()];\n\tconst patterns = strictLaneProfilePatterns(options.profile);\n\tconst compiledToolNames = new Set(options.grant?.allowedTools ?? []);\n\tconst deniedTools = candidateNames.filter((name) =>\n\t\toptions.grant ? !compiledToolNames.has(name) : matchesResourceProfilePattern(name, patterns.block),\n\t);\n\tconst unboundAllowPatterns = options.grant\n\t\t? []\n\t\t: patterns.allow.filter(\n\t\t\t\t(pattern) => !candidateNames.some((name) => matchesResourceProfilePattern(name, [pattern])),\n\t\t\t);\n\tconst allowedTools = options.grant\n\t\t? candidateNames.filter((name) => compiledToolNames.has(name))\n\t\t: candidateNames.filter(\n\t\t\t\t(name) =>\n\t\t\t\t\t(patterns.allow.length === 0 || matchesResourceProfilePattern(name, patterns.allow)) &&\n\t\t\t\t\t!matchesResourceProfilePattern(name, patterns.block),\n\t\t\t);\n\tconst allowedToolSet = new Set<string>(allowedTools);\n\tconst manifestsByName = new Map(options.toolManifests?.map((manifest) => [manifest.toolName, manifest]) ?? []);\n\tif (options.grant?.allowedTools.some((name) => !manifestsByName.has(name))) {\n\t\tthrow new Error(\"Compiled lane grant references a tool without a capability manifest.\");\n\t}\n\tconst gateway = options.grant\n\t\t? new CapabilityGateway({\n\t\t\t\tgrant: options.grant,\n\t\t\t\tcwd: options.cwd,\n\t\t\t\t...(options.initialUsage !== undefined ? { initialUsage: options.initialUsage } : {}),\n\t\t\t\t...(options.sharedBudget ? { sharedBudget: options.sharedBudget } : {}),\n\t\t\t})\n\t\t: undefined;\n\tconst deniedPaths = options.deniedPaths?.map((entry) => path.resolve(entry));\n\tconst readEnvelope: CapabilityEnvelope = {\n\t\tid: \"isolated-lane-read-tools\",\n\t\tcapabilities: [\n\t\t\t\"filesystem.read\",\n\t\t\t...(allowedToolSet.has(MEMORY_LANE_TOOL_NAME) ? ([\"memory.query\"] as const) : []),\n\t\t\t...(allowedToolSet.has(PROCESS_LANE_TOOL_NAME) || allowedToolSet.has(STABLE_SHELL_TOOL_NAME)\n\t\t\t\t? ([\"process.exec\"] as const)\n\t\t\t\t: []),\n\t\t],\n\t\tallowedTools,\n\t\tdeniedTools,\n\t\tallowedPaths: [path.resolve(options.cwd)],\n\t\t...(deniedPaths && deniedPaths.length > 0 ? { deniedPaths } : {}),\n\t};\n\tconst writeEnvelope: CapabilityEnvelope = {\n\t\tid: \"isolated-lane-write-tools\",\n\t\tcapabilities: [\"filesystem.write\"],\n\t\tallowedTools,\n\t\tdeniedTools,\n\t\tallowedPaths: resolveWriteRoots(options.cwd, options.writePaths ?? []),\n\t\t...(deniedPaths && deniedPaths.length > 0 ? { deniedPaths } : {}),\n\t};\n\n\treturn {\n\t\ttools: createLaneTools(\n\t\t\toptions.cwd,\n\t\t\tallowedTools,\n\t\t\tfileMutationIntents,\n\t\t\tadditionalTools,\n\t\t\toptions.readMemory,\n\t\t\toptions.executionPolicy,\n\t\t\toptions.processMaxWallClockMs,\n\t\t\toptions.shellSessionKey,\n\t\t),\n\t\tdispose: () => fileMutationIntents.dispose(),\n\t\tallowedTools,\n\t\tdeniedTools,\n\t\tunboundAllowPatterns,\n\t\tbeforeToolCall: async ({ toolCall, args }) => {\n\t\t\tif (!allowedToolSet.has(toolCall.name)) {\n\t\t\t\treturn { block: true, reason: `Lane tool '${toolCall.name}' is outside the materialized UAC surface.` };\n\t\t\t}\n\t\t\tif (gateway) {\n\t\t\t\tconst manifest = manifestsByName.get(toolCall.name);\n\t\t\t\tif (!manifest) {\n\t\t\t\t\treturn { block: true, reason: `Lane tool '${toolCall.name}' has no compiled capability manifest.` };\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tgateway.authorizeToolCall(manifest, toolCall.name, args);\n\t\t\t\t\treturn undefined;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (error instanceof CapabilityGatewayDeniedError) {\n\t\t\t\t\t\treturn { block: true, reason: `Lane tool blocked (${error.reasonCode}): ${error.message}` };\n\t\t\t\t\t}\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst outcome = evaluateToolGate({\n\t\t\t\ttoolName: toolCall.name,\n\t\t\t\targs,\n\t\t\t\tcwd: options.cwd,\n\t\t\t\tenvelope: WRITE_LANE_TOOL_NAME_SET.has(toolCall.name) ? writeEnvelope : readEnvelope,\n\t\t\t});\n\t\t\tif (outcome.outcome === \"allow\") return undefined;\n\t\t\treturn {\n\t\t\t\tblock: true,\n\t\t\t\treason: `Lane tool blocked (${outcome.reasonCode}): ${outcome.message ?? \"capability gate denied it\"}`,\n\t\t\t};\n\t\t},\n\t\t...(gateway ? { gateway } : {}),\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"lane-tool-surface.js","sourceRoot":"","sources":["../../../src/core/autonomy/lane-tool-surface.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EACN,iBAAiB,EACjB,4BAA4B,GAG5B,MAAM,wCAAwC,CAAC;AAOhD,OAAO,EAAE,mCAAmC,EAAE,MAAM,yCAAyC,CAAC;AAC9F,OAAO,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,4BAA4B,EAAE,MAAM,kCAAkC,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,yBAAyB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAU,CAAC;AAC1E,MAAM,qBAAqB,GAAG,QAAiB,CAAC;AAChD,MAAM,qBAAqB,GAAG,CAAC,OAAO,EAAE,MAAM,CAAU,CAAC;AACzD,MAAM,sBAAsB,GAAG,aAAsB,CAAC;AACtD,MAAM,2BAA2B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AAC;QACH,CAAC;QACD,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC/B,CAAC;AACH,CAAC","sourcesContent":["import path from \"node:path\";\nimport type { AgentLoopConfig, AgentTool } from \"@caupulican/pi-agent-core\";\nimport { type Static, Type } from \"typebox\";\nimport { STABLE_SHELL_TOOL_NAME } from \"../default-tool-surface.ts\";\nimport {\n\tCapabilityGateway,\n\tCapabilityGatewayDeniedError,\n\ttype GatewayInitialUsage,\n\ttype SharedCapabilityBudget,\n} from \"../orchestration/capability-gateway.ts\";\nimport type {\n\tExecutionGrant,\n\tOrchestrationExecutionPolicy,\n\tToolCapabilityManifest,\n} from \"../orchestration/contracts.ts\";\nimport type { NormalizedProfile } from \"../profile-registry.ts\";\nimport { wrapToolWithCredentialExposureGuard } from \"../secrets/credential-exposure-guard.ts\";\nimport { matchesResourceProfilePattern } from \"../settings-manager.ts\";\nimport { createBashTool } from \"../tools/bash.ts\";\nimport { createEditTool } from \"../tools/edit.ts\";\nimport { FileMutationIntentController } from \"../tools/file-mutation-intent.ts\";\nimport { createFindTool } from \"../tools/find.ts\";\nimport { createGrepTool } from \"../tools/grep.ts\";\nimport { createLsTool } from \"../tools/ls.ts\";\nimport { createReadTool } from \"../tools/read.ts\";\nimport { createRunProcessTool } from \"../tools/run-process.ts\";\nimport { createWriteTool } from \"../tools/write.ts\";\nimport type { CapabilityEnvelope } from \"./contracts.ts\";\nimport { evaluateToolGate } from \"./gates.ts\";\n\nconst READ_ONLY_LANE_TOOL_NAMES = [\"read\", \"grep\", \"find\", \"ls\"] as const;\nconst MEMORY_LANE_TOOL_NAME = \"memory\" as const;\nconst WRITE_LANE_TOOL_NAMES = [\"write\", \"edit\"] as const;\nconst PROCESS_LANE_TOOL_NAME = \"run_process\" as const;\nconst MAX_LANE_MEMORY_QUERY_CHARS = 4_096;\nconst laneMemorySchema = Type.Object({\n\tquery: Type.String({\n\t\tmaxLength: MAX_LANE_MEMORY_QUERY_CHARS,\n\t\tdescription: \"What relevant standing memory or prior evidence to retrieve\",\n\t}),\n});\ntype LaneMemoryParams = Static<typeof laneMemorySchema>;\nconst WRITE_LANE_TOOL_NAME_SET = new Set<string>(WRITE_LANE_TOOL_NAMES);\n\nexport interface LaneToolSurface {\n\t/** Fresh tools owned by this lane only; no foreground tool instances or extension state leak in. */\n\ttools: AgentTool[];\n\t/** Release exact mutation payload leases owned by this isolated lane. */\n\tdispose(): Promise<void>;\n\t/** Exact names after profile globs are expanded. Safe to persist in a capability envelope. */\n\tallowedTools: string[];\n\t/** Exact safe-candidate names denied by the profile's block patterns. */\n\tdeniedTools: string[];\n\t/** Explicit grants that bind to no classified lane candidate (opaque tools stay fail-closed). */\n\tunboundAllowPatterns: string[];\n\t/** Per-call path and capability gate for the isolated child loop. */\n\tbeforeToolCall: NonNullable<AgentLoopConfig[\"beforeToolCall\"]>;\n\t/** Canonical cumulative authority/budget meter for a compiled worker grant. */\n\tgateway?: CapabilityGateway;\n}\n\nexport interface LaneToolSurfaceOptions {\n\tcwd: string;\n\tprofile?: NormalizedProfile;\n\t/** Private harness state that generic file tools must never traverse. */\n\tdeniedPaths?: readonly string[];\n\t/** Orchestrator-requested, policy-filtered read-only memory retrieval. Omitted means no memory tool. */\n\treadMemory?: (query: string) => Promise<string>;\n\t/** Research never sets this. Workers require both this flag and at least one write path. */\n\twriteEnabled?: boolean;\n\twritePaths?: readonly string[];\n\t/** Present only for process-capable owner profiles; absent means no process tool is materialized. */\n\texecutionPolicy?: OrchestrationExecutionPolicy;\n\tprocessMaxWallClockMs?: number;\n\t/** Stable per-agent shell identity. Omitted when the compiled plan does not grant a host shell. */\n\tshellSessionKey?: string;\n\t/** Host-owned managed directory for complete shell output; never inferred from process-global config. */\n\tshellOutputDirectory?: string;\n\t/** Compiled policy path. When present, it is the only authorization source for this surface. */\n\tgrant?: ExecutionGrant;\n\ttoolManifests?: readonly ToolCapabilityManifest[];\n\t/** Runtime-owned classified tools composed specifically for this lane (for example delegation control). */\n\tadditionalTools?: readonly AgentTool[];\n\t/** Durable cumulative active usage to seed the compiled grant's gateway on resume. */\n\tinitialUsage?: GatewayInitialUsage;\n\t/** Root-tree aggregate meter shared by this attempt and every descendant. */\n\tsharedBudget?: SharedCapabilityBudget;\n}\n\nfunction strictLaneProfilePatterns(profile: NormalizedProfile | undefined): {\n\tallow: string[];\n\tblock: string[];\n} {\n\tif (!profile) return { allow: [], block: [] };\n\tconst filter = profile.resources.tools;\n\tconst allow = [...(filter?.allow ?? [])];\n\tconst block = [...(filter?.block ?? [])];\n\t// Strict UAC: a shipped profile is the complete authority grant. Grant-all must be explicit.\n\tif (allow.length === 0 && block.length === 0) return { allow: [], block: [\"*\"] };\n\treturn { allow, block };\n}\n\nfunction resolveWriteRoots(cwd: string, writePaths: readonly string[]): string[] {\n\treturn writePaths.map((entry) => (path.isAbsolute(entry) ? path.resolve(entry) : path.resolve(cwd, entry)));\n}\n\nfunction createLaneTools(\n\tcwd: string,\n\tnames: readonly string[],\n\tfileMutationIntents: FileMutationIntentController,\n\tadditionalTools: ReadonlyMap<string, AgentTool>,\n\treadMemory?: (query: string) => Promise<string>,\n\texecutionPolicy?: OrchestrationExecutionPolicy,\n\tprocessMaxWallClockMs = 0,\n\tshellSessionKey?: string,\n\tshellOutputDirectory?: string,\n): AgentTool[] {\n\tconst factories = new Map<string, () => AgentTool>([\n\t\t[\"read\", () => createReadTool(cwd)],\n\t\t[\"grep\", () => createGrepTool(cwd)],\n\t\t[\"find\", () => createFindTool(cwd)],\n\t\t[\"ls\", () => createLsTool(cwd)],\n\t\t[\"write\", () => createWriteTool(cwd, { intentController: fileMutationIntents })],\n\t\t[\"edit\", () => createEditTool(cwd, { intentController: fileMutationIntents })],\n\t]);\n\tif (executionPolicy) {\n\t\tfactories.set(PROCESS_LANE_TOOL_NAME, () =>\n\t\t\tcreateRunProcessTool(cwd, { policy: executionPolicy, maxWallClockMs: processMaxWallClockMs }),\n\t\t);\n\t}\n\tif (shellSessionKey) {\n\t\tfactories.set(STABLE_SHELL_TOOL_NAME, () =>\n\t\t\tcreateBashTool(cwd, {\n\t\t\t\tsessionKey: shellSessionKey,\n\t\t\t\t...(shellOutputDirectory ? { outputDirectory: shellOutputDirectory } : {}),\n\t\t\t}),\n\t\t);\n\t}\n\tif (readMemory) {\n\t\tfactories.set(MEMORY_LANE_TOOL_NAME, () => ({\n\t\t\tname: MEMORY_LANE_TOOL_NAME,\n\t\t\tlabel: \"Read Memory\",\n\t\t\tdescription:\n\t\t\t\t\"Retrieve bounded, source-labeled standing memory relevant to this delegated task. Read-only: no memory writes or lifecycle actions are available.\",\n\t\t\tparameters: laneMemorySchema,\n\t\t\texecute: async (_toolCallId, params) => {\n\t\t\t\tconst query = (params as LaneMemoryParams).query?.trim();\n\t\t\t\tif (!query || query.length > MAX_LANE_MEMORY_QUERY_CHARS) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`memory_query_invalid: query must contain from 1 through ${MAX_LANE_MEMORY_QUERY_CHARS} characters.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\" as const, text: await readMemory(query) }],\n\t\t\t\t\tdetails: { readOnly: true },\n\t\t\t\t};\n\t\t\t},\n\t\t}));\n\t}\n\treturn names.flatMap((name) => {\n\t\tconst additional = additionalTools.get(name);\n\t\tif (additional) return [additional];\n\t\tconst factory = factories.get(name);\n\t\treturn factory ? [wrapToolWithCredentialExposureGuard(factory(), cwd)] : [];\n\t});\n}\n\n/**\n * Materialize a fresh, fail-closed tool surface for one isolated lane.\n *\n * Admission selects classified built-ins plus runtime-owned injected controls. A compiled grant is\n * the only authority source for worker lanes; host shell and recursive delegation are materialized\n * when named by that grant. Write/edit additionally require the global write switch and a positive\n * path scope.\n */\nexport function createLaneToolSurface(options: LaneToolSurfaceOptions): LaneToolSurface {\n\tconst fileMutationIntents = new FileMutationIntentController();\n\tconst additionalTools = new Map<string, AgentTool>();\n\tfor (const tool of options.additionalTools ?? []) {\n\t\tif (!tool.name.trim()) throw new Error(\"An injected lane tool must have a name.\");\n\t\tif (additionalTools.has(tool.name)) throw new Error(`Injected lane tool '${tool.name}' is duplicated.`);\n\t\tadditionalTools.set(tool.name, tool);\n\t}\n\tconst writeCapable = options.writeEnabled === true && (options.writePaths?.length ?? 0) > 0;\n\tconst builtInCandidateNames = [\n\t\t...READ_ONLY_LANE_TOOL_NAMES,\n\t\t...(options.readMemory ? [MEMORY_LANE_TOOL_NAME] : []),\n\t\t...(writeCapable ? WRITE_LANE_TOOL_NAMES : []),\n\t\t...(options.executionPolicy ? [PROCESS_LANE_TOOL_NAME] : []),\n\t\t...(options.shellSessionKey ? [STABLE_SHELL_TOOL_NAME] : []),\n\t];\n\tfor (const name of additionalTools.keys()) {\n\t\tif (builtInCandidateNames.includes(name as (typeof builtInCandidateNames)[number])) {\n\t\t\tthrow new Error(`Injected lane tool '${name}' conflicts with a built-in lane tool.`);\n\t\t}\n\t}\n\tconst candidateNames = [...builtInCandidateNames, ...additionalTools.keys()];\n\tconst patterns = strictLaneProfilePatterns(options.profile);\n\tconst compiledToolNames = new Set(options.grant?.allowedTools ?? []);\n\tconst deniedTools = candidateNames.filter((name) =>\n\t\toptions.grant ? !compiledToolNames.has(name) : matchesResourceProfilePattern(name, patterns.block),\n\t);\n\tconst unboundAllowPatterns = options.grant\n\t\t? []\n\t\t: patterns.allow.filter(\n\t\t\t\t(pattern) => !candidateNames.some((name) => matchesResourceProfilePattern(name, [pattern])),\n\t\t\t);\n\tconst allowedTools = options.grant\n\t\t? candidateNames.filter((name) => compiledToolNames.has(name))\n\t\t: candidateNames.filter(\n\t\t\t\t(name) =>\n\t\t\t\t\t(patterns.allow.length === 0 || matchesResourceProfilePattern(name, patterns.allow)) &&\n\t\t\t\t\t!matchesResourceProfilePattern(name, patterns.block),\n\t\t\t);\n\tconst allowedToolSet = new Set<string>(allowedTools);\n\tconst manifestsByName = new Map(options.toolManifests?.map((manifest) => [manifest.toolName, manifest]) ?? []);\n\tif (options.grant?.allowedTools.some((name) => !manifestsByName.has(name))) {\n\t\tthrow new Error(\"Compiled lane grant references a tool without a capability manifest.\");\n\t}\n\tconst gateway = options.grant\n\t\t? new CapabilityGateway({\n\t\t\t\tgrant: options.grant,\n\t\t\t\tcwd: options.cwd,\n\t\t\t\t...(options.initialUsage !== undefined ? { initialUsage: options.initialUsage } : {}),\n\t\t\t\t...(options.sharedBudget ? { sharedBudget: options.sharedBudget } : {}),\n\t\t\t})\n\t\t: undefined;\n\tconst deniedPaths = options.deniedPaths?.map((entry) => path.resolve(entry));\n\tconst readEnvelope: CapabilityEnvelope = {\n\t\tid: \"isolated-lane-read-tools\",\n\t\tcapabilities: [\n\t\t\t\"filesystem.read\",\n\t\t\t...(allowedToolSet.has(MEMORY_LANE_TOOL_NAME) ? ([\"memory.query\"] as const) : []),\n\t\t\t...(allowedToolSet.has(PROCESS_LANE_TOOL_NAME) || allowedToolSet.has(STABLE_SHELL_TOOL_NAME)\n\t\t\t\t? ([\"process.exec\"] as const)\n\t\t\t\t: []),\n\t\t],\n\t\tallowedTools,\n\t\tdeniedTools,\n\t\tallowedPaths: [path.resolve(options.cwd)],\n\t\t...(deniedPaths && deniedPaths.length > 0 ? { deniedPaths } : {}),\n\t};\n\tconst writeEnvelope: CapabilityEnvelope = {\n\t\tid: \"isolated-lane-write-tools\",\n\t\tcapabilities: [\"filesystem.write\"],\n\t\tallowedTools,\n\t\tdeniedTools,\n\t\tallowedPaths: resolveWriteRoots(options.cwd, options.writePaths ?? []),\n\t\t...(deniedPaths && deniedPaths.length > 0 ? { deniedPaths } : {}),\n\t};\n\n\treturn {\n\t\ttools: createLaneTools(\n\t\t\toptions.cwd,\n\t\t\tallowedTools,\n\t\t\tfileMutationIntents,\n\t\t\tadditionalTools,\n\t\t\toptions.readMemory,\n\t\t\toptions.executionPolicy,\n\t\t\toptions.processMaxWallClockMs,\n\t\t\toptions.shellSessionKey,\n\t\t\toptions.shellOutputDirectory,\n\t\t),\n\t\tdispose: () => fileMutationIntents.dispose(),\n\t\tallowedTools,\n\t\tdeniedTools,\n\t\tunboundAllowPatterns,\n\t\tbeforeToolCall: async ({ toolCall, args }) => {\n\t\t\tif (!allowedToolSet.has(toolCall.name)) {\n\t\t\t\treturn { block: true, reason: `Lane tool '${toolCall.name}' is outside the materialized UAC surface.` };\n\t\t\t}\n\t\t\tif (gateway) {\n\t\t\t\tconst manifest = manifestsByName.get(toolCall.name);\n\t\t\t\tif (!manifest) {\n\t\t\t\t\treturn { block: true, reason: `Lane tool '${toolCall.name}' has no compiled capability manifest.` };\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tgateway.authorizeToolCall(manifest, toolCall.name, args);\n\t\t\t\t\treturn undefined;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (error instanceof CapabilityGatewayDeniedError) {\n\t\t\t\t\t\treturn { block: true, reason: `Lane tool blocked (${error.reasonCode}): ${error.message}` };\n\t\t\t\t\t}\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst outcome = evaluateToolGate({\n\t\t\t\ttoolName: toolCall.name,\n\t\t\t\targs,\n\t\t\t\tcwd: options.cwd,\n\t\t\t\tenvelope: WRITE_LANE_TOOL_NAME_SET.has(toolCall.name) ? writeEnvelope : readEnvelope,\n\t\t\t});\n\t\t\tif (outcome.outcome === \"allow\") return undefined;\n\t\t\treturn {\n\t\t\t\tblock: true,\n\t\t\t\treason: `Lane tool blocked (${outcome.reasonCode}): ${outcome.message ?? \"capability gate denied it\"}`,\n\t\t\t};\n\t\t},\n\t\t...(gateway ? { gateway } : {}),\n\t};\n}\n"]}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
export const SUBAGENT_CORE_SYSTEM_PROMPT = [
|
|
12
12
|
"You are an autonomous agent in a coding-agent orchestration tree. Execution contract:",
|
|
13
13
|
"1. Use the maximum useful capability exposed by your tool surface; the kernel enforces the exact inherited authority.",
|
|
14
|
-
"2. You may delegate recursively, inspect
|
|
14
|
+
"2. You may delegate recursively within host-enforced fleet bounds, inspect only your own control subtree transcripts, and exchange threaded peer messages when those tools are present.",
|
|
15
15
|
"3. Concurrency, cumulative budgets, leases, cycle detection, cancellation, and irreversible user-authority boundaries are kernel-owned.",
|
|
16
16
|
"4. Never invent facts, file paths, APIs, or command results; state uncertainty directly.",
|
|
17
17
|
"5. Follow the requested output contract exactly; your result remains evidence that other agents may independently verify.",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subagent-prompt.js","sourceRoot":"","sources":["../../../src/core/autonomy/subagent-prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG;IAC1C,uFAAuF;IACvF,uHAAuH;IACvH
|
|
1
|
+
{"version":3,"file":"subagent-prompt.js","sourceRoot":"","sources":["../../../src/core/autonomy/subagent-prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG;IAC1C,uFAAuF;IACvF,uHAAuH;IACvH,yLAAyL;IACzL,yIAAyI;IACzI,0FAA0F;IAC1F,2HAA2H;CAC3H,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAWb,MAAM,UAAU,2BAA2B,CAAC,KAA0B;IACrE,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC;IACxC,MAAM,KAAK,GACV,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QAC9B,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,KAAK,CAAC,UAAU,CAAC;aACrC,MAAM,CAAC,CAAC,IAAI,EAAkB,EAAE,CAAC,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;aAClE,IAAI,CAAC,MAAM,CAAC,CAAC;IAClB,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,2BAA2B,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,2BAA2B,CAAC;AACtG,CAAC","sourcesContent":["/**\n * Agent system-prompt composition with an irreducible execution-contract core.\n *\n * The core is the \"ultimate level-0 default\": ~80 tokens of non-negotiable rules that survive ANY\n * customization. Everything above it — the lane's role prompt and a shipped profile's soul — is a\n * replaceable layer: settings, a lane profile, or the calling model (delegate tool) can erase and\n * replace it entirely. This keeps shipped subagents maximally efficient on small open models (a\n * caller can hand a tiny model a purpose-built minimal prompt) while the kernel remains the sole\n * authority and budget owner. Keep the core UNDER 300 tokens; it is deliberately terse.\n */\nexport const SUBAGENT_CORE_SYSTEM_PROMPT = [\n\t\"You are an autonomous agent in a coding-agent orchestration tree. Execution contract:\",\n\t\"1. Use the maximum useful capability exposed by your tool surface; the kernel enforces the exact inherited authority.\",\n\t\"2. You may delegate recursively within host-enforced fleet bounds, inspect only your own control subtree transcripts, and exchange threaded peer messages when those tools are present.\",\n\t\"3. Concurrency, cumulative budgets, leases, cycle detection, cancellation, and irreversible user-authority boundaries are kernel-owned.\",\n\t\"4. Never invent facts, file paths, APIs, or command results; state uncertainty directly.\",\n\t\"5. Follow the requested output contract exactly; your result remains evidence that other agents may independently verify.\",\n].join(\"\\n\");\n\nexport interface SubagentPromptParts {\n\t/** Situational identity from the shipped profile (replaceable layer). */\n\tsoul?: string;\n\t/** The lane's default role prompt (replaceable layer). */\n\trolePrompt: string;\n\t/** User- or model-provided replacement for every layer above level 0. */\n\toverride?: string;\n}\n\nexport function composeSubagentSystemPrompt(parts: SubagentPromptParts): string {\n\tconst override = parts.override?.trim();\n\tconst above =\n\t\toverride && override.length > 0\n\t\t\t? override\n\t\t\t: [parts.soul?.trim(), parts.rolePrompt]\n\t\t\t\t\t.filter((part): part is string => Boolean(part && part.length > 0))\n\t\t\t\t\t.join(\"\\n\\n\");\n\treturn above.length > 0 ? `${SUBAGENT_CORE_SYSTEM_PROMPT}\\n\\n${above}` : SUBAGENT_CORE_SYSTEM_PROMPT;\n}\n"]}
|