@sema-agent/core 7.69.0 → 7.69.1
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 +583 -0
- package/dist/agents/repair-loop.js +6 -14
- package/dist/agents/subagent.js +2 -1
- package/dist/agents/verify.d.ts +1 -1
- package/dist/agents/verify.js +7 -1
- package/dist/brain/reasoning-request.d.ts +7 -0
- package/dist/brain/reasoning-request.js +6 -0
- package/dist/core/agent-config-dir.d.ts +39 -3
- package/dist/core/agent-config-dir.js +67 -11
- package/dist/core/allow-entry.d.ts +5 -5
- package/dist/core/allow-entry.js +12 -6
- package/dist/core/ask-headline.d.ts +2 -2
- package/dist/core/ask-origin.d.ts +31 -31
- package/dist/core/ask-origin.js +20 -13
- package/dist/core/attachment-source.d.ts +1 -1
- package/dist/core/attachment-source.js +1 -0
- package/dist/core/auto-compaction.d.ts +44 -62
- package/dist/core/auto-compaction.js +44 -103
- package/dist/core/cache-break-detector.d.ts +23 -11
- package/dist/core/cache-break-detector.js +11 -5
- package/dist/core/checkpoint-features.d.ts +1 -1
- package/dist/core/checkpoint-features.js +1 -1
- package/dist/core/checkpoint-requirements.d.ts +19 -1
- package/dist/core/checkpoint-requirements.js +6 -0
- package/dist/core/checkpoint-row-verdict.js +3 -0
- package/dist/core/checkpoint-store.d.ts +13 -2
- package/dist/core/child-clamp-seats.d.ts +30 -3
- package/dist/core/child-clamp-seats.js +24 -0
- package/dist/core/compaction-retired-members.d.ts +12 -0
- package/dist/core/compaction-retired-members.js +22 -0
- package/dist/core/config-refusal-codes.d.ts +1 -1
- package/dist/core/config-refusal-codes.js +2 -0
- package/dist/core/context-edit.d.ts +32 -17
- package/dist/core/context-edit.js +28 -0
- package/dist/core/cron.d.ts +68 -0
- package/dist/core/cron.js +259 -0
- package/dist/core/engine-attestation.d.ts +16 -0
- package/dist/core/engine-attestation.js +2 -0
- package/dist/core/engine-capabilities.d.ts +14 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +18 -7
- package/dist/core/engine-version.js +1 -1
- package/dist/core/gate-outcome.d.ts +29 -2
- package/dist/core/gate-outcome.js +6 -0
- package/dist/core/git-read-only.d.ts +10 -0
- package/dist/core/git-read-only.js +1 -0
- package/dist/core/git-worktree-env.js +9 -8
- package/dist/core/governance-codes.d.ts +9 -2
- package/dist/core/governance-codes.js +9 -0
- package/dist/core/locked-config.js +7 -3
- package/dist/core/lsp.d.ts +3 -0
- package/dist/core/lsp.js +3 -2
- package/dist/core/memory-engine/engine.d.ts +48 -12
- package/dist/core/memory-engine/engine.js +108 -46
- package/dist/core/memory-engine/file-backend.d.ts +2 -1
- package/dist/core/memory-engine/index-copies.d.ts +47 -0
- package/dist/core/memory-engine/index-copies.js +88 -0
- package/dist/core/memory-engine/layout.d.ts +20 -3
- package/dist/core/memory-engine/layout.js +39 -3
- package/dist/core/memory-engine/origin-clearance.d.ts +9 -7
- package/dist/core/memory-engine/origin-clearance.js +2 -4
- package/dist/core/memory-engine/types.d.ts +16 -3
- package/dist/core/mode-policy.d.ts +7 -1
- package/dist/core/mode-policy.js +9 -0
- package/dist/core/mods/session-compact.js +3 -3
- package/dist/core/mods/stations.d.ts +2 -0
- package/dist/core/mods/stations.js +2 -1
- package/dist/core/path-guard-rows.d.ts +8 -3
- package/dist/core/path-guard-rows.js +18 -5
- package/dist/core/peer-seat.d.ts +3 -0
- package/dist/core/peer-seat.js +3 -0
- package/dist/core/permission-rule-model.js +3 -2
- package/dist/core/process-identity.d.ts +11 -3
- package/dist/core/process-identity.js +26 -16
- package/dist/core/runner/assemble-result.d.ts +5 -0
- package/dist/core/runner/assemble-result.js +1 -1
- package/dist/core/runner/cleared-results-record.d.ts +33 -0
- package/dist/core/runner/cleared-results-record.js +56 -0
- package/dist/core/runner/compact-session.js +14 -9
- package/dist/core/runner/compaction-knobs.d.ts +1 -1
- package/dist/core/runner/continuation-gate.js +2 -1
- package/dist/core/runner/continues-from.d.ts +1 -1
- package/dist/core/runner/continues-from.js +1 -1
- package/dist/core/runner/contracts.d.ts +83 -31
- package/dist/core/runner/conversation-segment.d.ts +19 -12
- package/dist/core/runner/conversation-segment.js +27 -7
- package/dist/core/runner/derived-route-fallback.d.ts +2 -12
- package/dist/core/runner/derived-route-fallback.js +0 -6
- package/dist/core/runner/gate-exit.d.ts +2 -1
- package/dist/core/runner/gate-exit.js +4 -2
- package/dist/core/runner/git-status-frame.d.ts +2 -2
- package/dist/core/runner/git-status-frame.js +2 -1
- package/dist/core/runner/initial-run-state.js +1 -1
- package/dist/core/runner/leg-caller-places.d.ts +39 -0
- package/dist/core/runner/leg-caller-places.js +23 -0
- package/dist/core/runner/leg-frame.d.ts +8 -2
- package/dist/core/runner/leg-receipt.d.ts +29 -2
- package/dist/core/runner/leg-receipt.js +37 -6
- package/dist/core/runner/media-removed-seat.d.ts +10 -6
- package/dist/core/runner/media-removed-seat.js +6 -3
- package/dist/core/runner/messages-omitted-seat.d.ts +2 -1
- package/dist/core/runner/messages-omitted-seat.js +15 -5
- package/dist/core/runner/person-path-rows.d.ts +25 -7
- package/dist/core/runner/person-path-rows.js +16 -2
- package/dist/core/runner/prefix-ledger.d.ts +120 -0
- package/dist/core/runner/prefix-ledger.js +176 -0
- package/dist/core/runner/prepare-advisor.d.ts +2 -0
- package/dist/core/runner/prepare-advisor.js +2 -1
- package/dist/core/runner/prepare-artifact.d.ts +3 -0
- package/dist/core/runner/prepare-artifact.js +2 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +2 -0
- package/dist/core/runner/prepare-caps-and-workflow.js +4 -3
- package/dist/core/runner/prepare-config-doors.d.ts +9 -8
- package/dist/core/runner/prepare-config-doors.js +15 -12
- package/dist/core/runner/prepare-context-lane.d.ts +25 -6
- package/dist/core/runner/prepare-context-lane.js +82 -27
- package/dist/core/runner/prepare-gate-stations.d.ts +1 -2
- package/dist/core/runner/prepare-gate-stations.js +2 -4
- package/dist/core/runner/prepare-hands-readface.d.ts +18 -5
- package/dist/core/runner/prepare-hands-readface.js +41 -22
- package/dist/core/runner/prepare-inherited-gate.d.ts +5 -0
- package/dist/core/runner/prepare-inherited-gate.js +2 -0
- package/dist/core/runner/prepare-memory.d.ts +10 -2
- package/dist/core/runner/prepare-memory.js +51 -5
- package/dist/core/runner/prepare-policy-chain.d.ts +3 -0
- package/dist/core/runner/prepare-policy-chain.js +13 -2
- package/dist/core/runner/prepare-prompt-assembly.d.ts +12 -4
- package/dist/core/runner/prepare-prompt-assembly.js +10 -4
- package/dist/core/runner/prepare-prompt-inputs.d.ts +3 -7
- package/dist/core/runner/prepare-prompt-inputs.js +6 -7
- package/dist/core/runner/prepare-safety-scan.js +7 -0
- package/dist/core/runner/prepare-suspend-saga.d.ts +4 -0
- package/dist/core/runner/prepare-suspend-saga.js +3 -2
- package/dist/core/runner/prepare-task.js +59 -53
- package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +5 -11
- package/dist/core/runner/prepare-tool-disclosure-mount.js +7 -8
- package/dist/core/runner/prepare-turn-wiring.d.ts +16 -25
- package/dist/core/runner/prepare-turn-wiring.js +8 -18
- package/dist/core/runner/prepare-wiring-manifest.d.ts +1 -0
- package/dist/core/runner/prepare-wiring-manifest.js +3 -2
- package/dist/core/runner/prompt-suggestions.d.ts +3 -1
- package/dist/core/runner/prompt-suggestions.js +1 -1
- package/dist/core/runner/read-block-judge.d.ts +47 -0
- package/dist/core/runner/read-block-judge.js +33 -0
- package/dist/core/runner/role-resolution-table.d.ts +15 -10
- package/dist/core/runner/role-resolution-table.js +4 -5
- package/dist/core/runner/rule-store-unreadable-notice.d.ts +7 -4
- package/dist/core/runner/rule-store-unreadable-notice.js +4 -3
- package/dist/core/runner/run-compaction-machinery.d.ts +0 -10
- package/dist/core/runner/run-compaction-machinery.js +3 -39
- package/dist/core/runner/run-harness-handlers.js +4 -17
- package/dist/core/runner/run-identity-wiring.js +4 -1
- package/dist/core/runner/run-leg.js +11 -1
- package/dist/core/runner/run-recovery-lanes.d.ts +0 -4
- package/dist/core/runner/run-recovery-lanes.js +34 -18
- package/dist/core/runner/run-settle-and-teardown.d.ts +1 -3
- package/dist/core/runner/run-settle-and-teardown.js +14 -22
- package/dist/core/runner/run-telemetry-and-budget-seats.js +0 -1
- package/dist/core/runner/run-terminal-adoption.d.ts +11 -30
- package/dist/core/runner/run-terminal-adoption.js +5 -88
- package/dist/core/runner/run-tool-mount-facts.js +1 -5
- package/dist/core/runner/run-turn-boundary.js +56 -26
- package/dist/core/runner/runtask.js +7 -7
- package/dist/core/runner/session-hash-salt.d.ts +18 -0
- package/dist/core/runner/session-hash-salt.js +36 -0
- package/dist/core/runner/shell-env-withheld.d.ts +8 -5
- package/dist/core/runner/shell-env-withheld.js +3 -3
- package/dist/core/runner/side-call-account.d.ts +9 -1
- package/dist/core/runner/side-call-account.js +15 -4
- package/dist/core/runner/skill-mention.d.ts +12 -0
- package/dist/core/runner/skill-mention.js +50 -0
- package/dist/core/runner/stream-settle-backstop.js +1 -0
- package/dist/core/runner/synthetic-tools.js +2 -2
- package/dist/core/runner/tool-table-view.d.ts +5 -9
- package/dist/core/runner/tool-table-view.js +23 -21
- package/dist/core/runner/write-protection-station.d.ts +5 -2
- package/dist/core/runner/write-protection-station.js +1 -1
- package/dist/core/runner-deps.d.ts +25 -27
- package/dist/core/scheduler.d.ts +13 -3
- package/dist/core/scheduler.js +0 -12
- package/dist/core/secret-env.d.ts +47 -11
- package/dist/core/secret-env.js +65 -4
- package/dist/core/sensitive-path-policy.js +4 -0
- package/dist/core/session-checkout.js +10 -9
- package/dist/core/shell-read-silence.d.ts +2 -1
- package/dist/core/shell-run-candidates.d.ts +1 -1
- package/dist/core/shell-run-candidates.js +11 -3
- package/dist/core/task-event.d.ts +32 -10
- package/dist/core/task-intake.d.ts +5 -3
- package/dist/core/task-intake.js +6 -2
- package/dist/core/task-result.d.ts +39 -0
- package/dist/core/task-spec-members.d.ts +3 -0
- package/dist/core/task-spec-members.js +2 -2
- package/dist/core/task-spec.d.ts +37 -20
- package/dist/core/tool-policy.d.ts +30 -18
- package/dist/core/tool-policy.js +44 -32
- package/dist/core/tool-roster.d.ts +21 -7
- package/dist/core/tool-roster.js +34 -6
- package/dist/core/tool-spec-members.js +1 -1
- package/dist/core/tool-spec.d.ts +27 -0
- package/dist/core/tools.js +1 -0
- package/dist/core/trace.d.ts +42 -19
- package/dist/core/unc-spelling.d.ts +31 -0
- package/dist/core/unc-spelling.js +51 -0
- package/dist/core/wiring-manifest.d.ts +30 -3
- package/dist/core/wiring-manifest.js +10 -0
- package/dist/core/workflow-run-store-contract.js +22 -0
- package/dist/core/workflow-run-store.d.ts +17 -13
- package/dist/core/workflow-run-store.js +1 -1
- package/dist/core/write-protect.d.ts +4 -0
- package/dist/core/write-protect.js +17 -15
- package/dist/engine/compaction/compaction.d.ts +48 -98
- package/dist/engine/compaction/compaction.js +136 -216
- package/dist/engine/compaction/utils.d.ts +2 -11
- package/dist/engine/compaction/utils.js +4 -13
- package/dist/engine/execution-env/node-execution-env.js +17 -6
- package/dist/engine/harness/agent-harness.d.ts +19 -5
- package/dist/engine/harness/agent-harness.js +18 -7
- package/dist/engine/harness/types.d.ts +5 -7
- package/dist/engine/loop/agent-loop.d.ts +14 -1
- package/dist/engine/loop/agent-loop.js +31 -11
- package/dist/engine/loop/types.d.ts +8 -2
- package/dist/index.d.ts +9 -6
- package/dist/index.js +8 -6
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +1 -1
- package/dist/internal/harness.js +1 -1
- package/dist/orchestration/run-spec.js +7 -2
- package/dist/orchestration/run-workflow-tool.js +5 -3
- package/dist/orchestration/workflow-park-adoption.d.ts +66 -8
- package/dist/orchestration/workflow-park-adoption.js +195 -45
- package/dist/orchestration/workflow-types.d.ts +20 -0
- package/dist/orchestration/workflow-types.js +1 -0
- package/dist/orchestration/workflow.d.ts +3 -2
- package/dist/orchestration/workflow.js +10 -4
- package/dist/prompt-assembly/catalog/core-behavior.js +6 -0
- package/dist/prompt-assembly/catalog/events.d.ts +8 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/core-behavior.js +6 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/mechanism.js +1 -0
- package/dist/prompt-assembly/catalog/mechanism.d.ts +8 -0
- package/dist/prompt-assembly/catalog/mechanism.js +1 -0
- package/dist/prompt-assembly/catalog/schema.d.ts +1 -1
- package/dist/prompt-assembly/catalog/schema.js +1 -0
- package/dist/prompt-assembly/catalog/sections.js +8 -0
- package/dist/prompt-assembly/event-registry.js +1 -0
- package/dist/prompt-assembly/select.js +1 -0
- package/dist/prompt-assembly/turn-snapshot.d.ts +14 -27
- package/dist/prompt-assembly/turn-snapshot.js +6 -18
- package/dist/prompt-assembly/types.d.ts +3 -0
- package/dist/prompts/default.d.ts +9 -0
- package/dist/prompts/default.js +4 -0
- package/dist/shell/lex.d.ts +75 -11
- package/dist/shell/lex.js +340 -76
- package/dist/tools/fs/bash-program-position.js +2 -6
- package/dist/tools/fs/bash-readonly-classifier.d.ts +18 -3
- package/dist/tools/fs/bash-readonly-classifier.js +19 -9
- package/dist/tools/fs/containment-face.d.ts +12 -3
- package/dist/tools/fs/containment-face.js +16 -7
- package/dist/tools/fs/file-read-check.d.ts +26 -1
- package/dist/tools/fs/file-read-check.js +20 -2
- package/dist/tools/fs/fs-bash.js +4 -4
- package/dist/tools/fs/fs-read.d.ts +3 -0
- package/dist/tools/fs/fs-read.js +2 -2
- package/dist/tools/fs/fs-search-tools.d.ts +2 -2
- package/dist/tools/fs/fs-search-tools.js +4 -4
- package/dist/tools/fs/index.js +5 -3
- package/dist/tools/fs/pdf.js +12 -4
- package/dist/tools/fs/read-deny-home.d.ts +13 -2
- package/dist/tools/fs/read-deny-home.js +26 -22
- package/dist/tools/fs/read-deny.js +15 -6
- package/dist/tools/fs/removal-targets.d.ts +33 -17
- package/dist/tools/fs/removal-targets.js +160 -61
- package/dist/tools/fs/repo-map.d.ts +1 -1
- package/dist/tools/fs/repo-map.js +2 -2
- package/dist/tools/fs/safety.d.ts +28 -5
- package/dist/tools/fs/safety.js +72 -8
- package/dist/tools/fs/shell-read-bindings.d.ts +8 -2
- package/dist/tools/fs/shell-read-bindings.js +25 -6
- package/dist/tools/fs/shell-read-check.d.ts +3 -0
- package/dist/tools/fs/shell-read-check.js +22 -4
- package/dist/tools/fs/shell-read-establish.js +73 -43
- package/dist/tools/fs/shell-read-judge.d.ts +32 -14
- package/dist/tools/fs/shell-read-judge.js +13 -5
- package/dist/tools/fs/shell-read-object-path.d.ts +5 -1
- package/dist/tools/fs/shell-read-object-path.js +17 -4
- package/dist/tools/fs/shell-read-plan.d.ts +8 -2
- package/dist/tools/fs/shell-read-plan.js +36 -22
- package/dist/tools/fs/shell-read-sourced.js +12 -4
- package/dist/tools/fs/shell-read-start.d.ts +4 -2
- package/dist/tools/fs/shell-read-start.js +3 -3
- package/dist/tools/fs/shell-read-workdir.d.ts +14 -6
- package/dist/tools/fs/shell-read-workdir.js +35 -17
- package/dist/tools/scheduler-tools.d.ts +7 -17
- package/dist/tools/scheduler-tools.js +9 -85
- package/dist/tools/worktree.js +5 -4
- package/package.json +3 -2
- package/test/export-surface.snapshot.json +47 -1
- package/wire-changes/core-stores-sql@7.68.6.json +39 -0
- package/wire-changes/core-stores-sql@7.69.1.json +39 -0
- package/wire-changes/core@7.68.6.json +125 -0
- package/wire-changes/core@7.69.1.json +2561 -0
- package/wire-changes/mods-kernel@7.68.6.json +39 -0
- package/wire-changes/mods-kernel@7.69.1.json +39 -0
- package/wire-changes/primitives@7.68.6.json +39 -0
- package/wire-changes/primitives@7.69.1.json +39 -0
- package/wire-changes/wiki-gate@7.68.6.json +39 -0
- package/wire-changes/wiki-gate@7.69.1.json +39 -0
- package/dist/core/runner/prompt-hash-salt.d.ts +0 -1
- package/dist/core/runner/prompt-hash-salt.js +0 -2
package/dist/core/tool-roster.js
CHANGED
|
@@ -381,6 +381,7 @@ export function survivorsByName(mounted) {
|
|
|
381
381
|
winner.set(t.name, t);
|
|
382
382
|
return winner;
|
|
383
383
|
}
|
|
384
|
+
const byName = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
384
385
|
export const faceOf = (t) => t;
|
|
385
386
|
const protocolFolded = (source) => source === "mcp" || source === "a2a";
|
|
386
387
|
function catalogDefinitionOf(tool) {
|
|
@@ -418,6 +419,16 @@ export class RosterBuilder {
|
|
|
418
419
|
mounts = new ToolMountLedger((t) => getToolContract(t, "core").contractId);
|
|
419
420
|
settleMountPlan(executionEnv) {
|
|
420
421
|
const all = [...this.#tools, ...this.#engineLane];
|
|
422
|
+
for (const t of all) {
|
|
423
|
+
if (!this.#perTurn(t))
|
|
424
|
+
continue;
|
|
425
|
+
for (const n of [t.name, ...(t.aliases ?? [])]) {
|
|
426
|
+
const other = all.find((o) => o !== t && (o.name === n || (o.aliases ?? []).includes(n)));
|
|
427
|
+
if (other !== undefined) {
|
|
428
|
+
throw configError("config.tool_face_invalid", `tool ${JSON.stringify(t.name)} declares \`perTurn\`, and ${n === t.name ? "its name" : `its alias ${JSON.stringify(n)}`} is also answered by the mounted tool ${JSON.stringify(other.name)} — a per-turn tool must own every name it answers to: rename it, or drop \`perTurn\``);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
421
432
|
const members = [...survivorsByName(all).values()].map((t) => {
|
|
422
433
|
const meta = this.#meta.get(t);
|
|
423
434
|
return { name: t.name, ...planIdentityOf(t, meta?.source), mountedBy: meta?.mountedBy ?? "scenario", state: "mounted" };
|
|
@@ -427,6 +438,13 @@ export class RosterBuilder {
|
|
|
427
438
|
get tools() {
|
|
428
439
|
return this.#tools;
|
|
429
440
|
}
|
|
441
|
+
get perTurnStart() {
|
|
442
|
+
const i = this.#tools.findIndex((t) => this.#perTurn(t));
|
|
443
|
+
return i < 0 ? this.#tools.length : i;
|
|
444
|
+
}
|
|
445
|
+
#perTurn(tool) {
|
|
446
|
+
return this.#meta.get(tool)?.perTurn === true;
|
|
447
|
+
}
|
|
430
448
|
get length() {
|
|
431
449
|
return this.#tools.length;
|
|
432
450
|
}
|
|
@@ -443,9 +461,21 @@ export class RosterBuilder {
|
|
|
443
461
|
#mountOne(tool, meta, lane) {
|
|
444
462
|
const displaced = this.#survivorNamed(tool.name);
|
|
445
463
|
this.#admit(tool, meta);
|
|
446
|
-
lane
|
|
464
|
+
if (lane === this.#tools)
|
|
465
|
+
lane.splice(this.#placeOf(tool, meta), 0, tool);
|
|
466
|
+
else
|
|
467
|
+
lane.push(tool);
|
|
447
468
|
return [tool.name, ...(displaced?.aliases ?? []), ...(tool.aliases ?? [])];
|
|
448
469
|
}
|
|
470
|
+
#placeOf(tool, meta) {
|
|
471
|
+
const start = this.perTurnStart;
|
|
472
|
+
if (meta.perTurn !== true)
|
|
473
|
+
return start;
|
|
474
|
+
let at = start;
|
|
475
|
+
while (at < this.#tools.length && byName(this.#tools[at].name, tool.name) <= 0)
|
|
476
|
+
at++;
|
|
477
|
+
return at;
|
|
478
|
+
}
|
|
449
479
|
mountEngineLane(tool, meta) {
|
|
450
480
|
this.#settleEffects(this.#mountOne(tool, meta, this.#engineLane));
|
|
451
481
|
}
|
|
@@ -512,15 +542,13 @@ export class RosterBuilder {
|
|
|
512
542
|
}
|
|
513
543
|
for (const t of fresh)
|
|
514
544
|
this.#meta.set(t, meta);
|
|
515
|
-
|
|
516
|
-
this.#tools.splice(anchor, 0, ...fresh);
|
|
517
|
-
else
|
|
518
|
-
this.#tools.push(...fresh);
|
|
545
|
+
this.#tools.splice(anchor >= 0 ? anchor : this.perTurnStart, 0, ...fresh);
|
|
519
546
|
this.#settleEffects(this.#namesAfterRemoval(removed));
|
|
520
547
|
return { anchor };
|
|
521
548
|
}
|
|
522
549
|
snapshot(facts) {
|
|
523
|
-
const
|
|
550
|
+
const cut = this.perTurnStart;
|
|
551
|
+
const all = [...this.#tools.slice(0, cut), ...this.#engineLane, ...this.#tools.slice(cut)];
|
|
524
552
|
const over = rosterEntryCountProblem(rosterRowCount(all));
|
|
525
553
|
if (over !== undefined)
|
|
526
554
|
throw configError("config.tool_roster_bound", over);
|
|
@@ -5,7 +5,7 @@ import { isEngineDescriptor } from "../prompt-assembly/tool-catalog.js";
|
|
|
5
5
|
export const TOOL_SPEC_MEMBERS = Object.keys({
|
|
6
6
|
name: true, aliases: true, description: true, descriptionVariants: true, label: true, parameters: true, execute: true, effect: true,
|
|
7
7
|
egress: true, irreversibility: true, reversibilityProbe: true, permissionSeat: true, isConcurrencySafe: true, executionMode: true,
|
|
8
|
-
contentOrigin: true, offload: true, offloadThresholdChars: true, defer: true, alwaysLoad: true, prepareArguments: true,
|
|
8
|
+
contentOrigin: true, offload: true, offloadThresholdChars: true, defer: true, alwaysLoad: true, perTurn: true, prepareArguments: true,
|
|
9
9
|
validateInput: true, approvalPreview: true, family: true, pathTarget: true, hostTarget: true, ruleFace: true, renderHints: true, compactable: true,
|
|
10
10
|
budgetExempt: true, modelGate: true, contract: true, agentListing: true, agentModels: true, agentToolFaces: true,
|
|
11
11
|
agentToolLevelAllowTools: true, agentToolLevelDenyTools: true, agentToolPool: true, agentToolInheritsMcp: true, withAgents: true, boundaryLegs: true, boundaryLegsFor: true,
|
package/dist/core/tool-spec.d.ts
CHANGED
|
@@ -495,6 +495,19 @@ export interface ToolSpec<TParams extends TSchema = TSchema> {
|
|
|
495
495
|
* Exclusion still wins ({@link TaskSpec.excludeTools} unmounts — nothing left to keep inline).
|
|
496
496
|
*/
|
|
497
497
|
alwaysLoad?: boolean;
|
|
498
|
+
/**
|
|
499
|
+
* The host mounts this tool on SOME turns only: it goes after every other tool of `tools[]` (after the protocol tools and
|
|
500
|
+
* `ToolSearch`; several by name) and nothing else moves, so the others keep one beginning whether it is there or not. With
|
|
501
|
+
* several, the one that comes and goes takes those named after it out of that beginning too: declare it only on a tool that
|
|
502
|
+
* really comes and goes. A template rendering system, tools, messages keeps everything before it (the messages are
|
|
503
|
+
* rendered again either way); a backend rendering the tools FIRST (Anthropic's order) keeps the tools before it too and
|
|
504
|
+
* renders the system prompt and the messages again whenever the set changes (whether a provider's cache reads the kept
|
|
505
|
+
* tools there was not measured). `true` or absent, else `config.tool_face_invalid`; it must own every name it answers
|
|
506
|
+
* to (another tool answering to its name or an alias ⇒ `config.tool_face_invalid`: rename it or drop this; an
|
|
507
|
+
* engine-reserved name is refused first, `config.reserved_tool_name`). Independent of {@link defer}: deferred too, its
|
|
508
|
+
* placeholder sits at the end.
|
|
509
|
+
*/
|
|
510
|
+
perTurn?: true;
|
|
498
511
|
/**
|
|
499
512
|
* design/277 — model-gate CLASS tag (open vocabulary; the built-in table is
|
|
500
513
|
* {@link import("./tool-model-gate.js").TOOL_MODEL_GATE_CLASSES}, v1 vocabulary =
|
|
@@ -1036,6 +1049,14 @@ export interface ToolExecuteContext {
|
|
|
1036
1049
|
* read-only boundary ended at one level. Strictly a capability REMOVAL — it can never widen a child.
|
|
1037
1050
|
*/
|
|
1038
1051
|
handsReadOnly?: true;
|
|
1052
|
+
/**
|
|
1053
|
+
* The running task's READ-BLOCK clamp ({@link TaskSpec.blockReadsOutsideRoots} — the leg refuses reads outside its declared
|
|
1054
|
+
* directories, as the leg resolved it: the declaration or a resumed row's record of it), Runner-filled read-only on the
|
|
1055
|
+
* same trusted seat as {@link principal}; present ONLY when the leg refuses them, so an ordinary run's ctx gains no key.
|
|
1056
|
+
* A delegation tool copies it onto every child spec it builds (the clamp table's carrier): a child can never read where
|
|
1057
|
+
* its parent refuses to. Strictly a capability removal.
|
|
1058
|
+
*/
|
|
1059
|
+
blockReadsOutsideRoots?: true;
|
|
1039
1060
|
/**
|
|
1040
1061
|
* design/199 — the READ-face clamp carrier ({@link TaskSpec.readFace}): present (as "roots") ONLY
|
|
1041
1062
|
* when this run RESOLVED to the roots face, so a delegation tool pins every child spec to roots —
|
|
@@ -1068,6 +1089,12 @@ export interface ToolExecuteContext {
|
|
|
1068
1089
|
* model argument.
|
|
1069
1090
|
*/
|
|
1070
1091
|
writeProtectedAdditions?: readonly import("./write-protect.js").WriteProtectedEntry[];
|
|
1092
|
+
/** The parent leg's task-declared configuration roots ({@link TaskSpec.agentConfigDirs}, a resumed row's too), traveling the
|
|
1093
|
+
* delegation tree add-only. Runner-filled trusted seat, never a model argument. */
|
|
1094
|
+
agentConfigDirs?: readonly string[];
|
|
1095
|
+
/** The parent leg's caller homes ({@link TaskSpec.agentHomeDirs}, a resumed row's too), traveling the delegation tree
|
|
1096
|
+
* add-only. Runner-filled trusted seat, never a model argument. */
|
|
1097
|
+
agentHomeDirs?: readonly string[];
|
|
1071
1098
|
/**
|
|
1072
1099
|
* The parent task's OWN compliance deny additions ({@link TaskSpec.complianceAdditionalDenies}), traveling the
|
|
1073
1100
|
* delegation tree add-only (a child denies at least every capability its parent's request denied). Runner-filled
|
package/dist/core/tools.js
CHANGED
|
@@ -121,6 +121,7 @@ function buildProduct(spec, owner, options) {
|
|
|
121
121
|
...(spec.offloadThresholdChars !== undefined ? { offloadThresholdChars: spec.offloadThresholdChars } : {}),
|
|
122
122
|
...(spec.defer !== undefined ? { defer: spec.defer } : {}),
|
|
123
123
|
...(spec.alwaysLoad !== undefined ? { alwaysLoad: spec.alwaysLoad } : {}),
|
|
124
|
+
...(spec.perTurn !== undefined ? { perTurn: spec.perTurn } : {}),
|
|
124
125
|
...(spec.prepareArguments ? { prepareArguments: spec.prepareArguments } : {}),
|
|
125
126
|
...(spec.family !== undefined ? { family: spec.family } : {}),
|
|
126
127
|
...(spec.boundaryLegs !== undefined ? { boundaryLegs: spec.boundaryLegs } : {}),
|
package/dist/core/trace.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ import type { PromptEpochActivation, PromptIdentityLayers } from "../prompt-asse
|
|
|
24
24
|
import type { ChainLink, SupersededOverlay } from "../prompt-assembly/overlay.js";
|
|
25
25
|
import type { HostForm, HostRole, PromptLocale, RendererId } from "../prompt-assembly/catalog/schema.js";
|
|
26
26
|
import type { AssertAllKeysHandled } from "./ask-origin.js";
|
|
27
|
+
/** The two scopes of a manifest's salted digests (the `hashScope` member below). */
|
|
28
|
+
export type PromptHashScope = "session" | "leg";
|
|
27
29
|
/** The run's prompt identity as the manifest reports it: the identity digest, its inputs, and the session record that
|
|
28
30
|
* names it (the record's counter and how it came to be). */
|
|
29
31
|
export interface PromptManifestIdentity {
|
|
@@ -143,6 +145,10 @@ export type TraceEvent = {
|
|
|
143
145
|
chars: number;
|
|
144
146
|
hash: string;
|
|
145
147
|
}>;
|
|
148
|
+
/** How far this frame's salted digests compare: `"session"` — under the session's persisted hash salt, across its runs
|
|
149
|
+
* and engine processes; `"leg"` — this leg only (the session's store could not keep the salt; said once through
|
|
150
|
+
* `onError(phase:"config")`). Absent on a frame of an engine that salted per process. */
|
|
151
|
+
hashScope?: PromptHashScope;
|
|
146
152
|
sections: PromptManifestSection[];
|
|
147
153
|
/** Every overlay the composition superseded (a later one on the same target won, or it changed nothing this
|
|
148
154
|
* run); absent when none was. */
|
|
@@ -170,9 +176,8 @@ export type TraceEvent = {
|
|
|
170
176
|
toolDisclosure?: ToolDisclosureManifest;
|
|
171
177
|
ts: number;
|
|
172
178
|
} | {
|
|
173
|
-
/**
|
|
174
|
-
*
|
|
175
|
-
* prefix identity. Digests only, never prompt text. */
|
|
179
|
+
/** @deprecated Never minted since 7.69.1 (a request that does not extend the session's previous main request is the
|
|
180
|
+
* `prefix_changed` task event, judged from its bytes); the arm and its kind stay listed until 7.70.0 removes them. */
|
|
176
181
|
kind: "prompt.snapshot_changed";
|
|
177
182
|
version: 1;
|
|
178
183
|
taskId: string;
|
|
@@ -180,14 +185,9 @@ export type TraceEvent = {
|
|
|
180
185
|
cacheIdentity: string;
|
|
181
186
|
elements: import("../prompt-assembly/turn-snapshot.js").CacheIdentityElements;
|
|
182
187
|
};
|
|
183
|
-
/** Why the prefix moved — the declared word ({@link import("./cache-break-detector.js").PrefixChangeDeclaration});
|
|
184
|
-
* `leg_start_inputs` is the leg's first frame, against the session's anchor rather than an earlier request. */
|
|
185
188
|
cause: import("./cache-break-detector.js").PrefixChangeCause;
|
|
186
|
-
/** `tool_table` only: which writer moved the table. */
|
|
187
189
|
source?: import("../prompt-assembly/turn-snapshot.js").ToolTableSource;
|
|
188
|
-
/** `leg_start_inputs` only: the head segments that differ from the anchor (prompt block ids, `tools`). */
|
|
189
190
|
segments?: string[];
|
|
190
|
-
/** `tool_table` only: the first tool position whose wire face differs. */
|
|
191
191
|
firstChangedIndex?: number;
|
|
192
192
|
ts: number;
|
|
193
193
|
} | {
|
|
@@ -348,8 +348,10 @@ export type TraceEvent = {
|
|
|
348
348
|
*/
|
|
349
349
|
turn?: number;
|
|
350
350
|
/** Which call beside the loop this row is: a `SideCallLane` word (the closed set lives with the account,
|
|
351
|
-
* `runner/side-call-account.ts`)
|
|
352
|
-
*
|
|
351
|
+
* `runner/side-call-account.ts`), or `"suggestions"` — the prompt-suggestion pass after the answer, a trace-only row:
|
|
352
|
+
* its spend is the result's separate `stats.suggestions` line, never folded into `stats.costMicroUsd` (a host summing
|
|
353
|
+
* rows into a quota counts it). Present exactly when {@link turn} is absent — the one row builder of calls beside the
|
|
354
|
+
* loop stamps it; a main-loop row carries `turn` and no `lane`. */
|
|
353
355
|
lane?: string;
|
|
354
356
|
/** Normalized prompt tokens that MISSED the cache (Anthropic-protocol `input_tokens`
|
|
355
357
|
* shape) — disjoint from `cacheRead`/`cacheWrite`. Carried the cache-inclusive total up to 2.13.x. */
|
|
@@ -382,6 +384,27 @@ export type TraceEvent = {
|
|
|
382
384
|
* `"stop"`/`"length"`/`"toolUse"`/`"error"`/`"aborted"`). Post-normalization (Anthropic
|
|
383
385
|
* `end_turn`/`stop_sequence`→`"stop"`, `max_tokens`→`"length"`). */
|
|
384
386
|
stopReason?: string;
|
|
387
|
+
/**
|
|
388
|
+
* The request this call sent, as the session's prefix ledger read it before it went out (`core/runner/prefix-ledger.ts`):
|
|
389
|
+
* the request head's digest (thinking controls + system + tools, under the session's hash salt — comparable across the
|
|
390
|
+
* session's runs and engine processes, and with a fork whose branch holds the salt; never across unrelated sessions), its message
|
|
391
|
+
* count, its length in the ledger's canonical rendering, and whether it extends the session's previous main request of the same serving model (`"extends"`), has
|
|
392
|
+
* none known to this process (`"no-baseline"`), or where it stops repeating it. Judged from the bytes, never from
|
|
393
|
+
* `cacheRead` (a hybrid model can report zero cached tokens for a request that extends the last one). Present on a row
|
|
394
|
+
* for a request sent through the Brain seat while the leg's detection runs (`RunnerDeps.cacheBreakDetection`, default
|
|
395
|
+
* on); absent on a row for a hop a fallback walk left behind (its request is the same request).
|
|
396
|
+
*/
|
|
397
|
+
request?: {
|
|
398
|
+
head: string;
|
|
399
|
+
messages: number;
|
|
400
|
+
chars: number;
|
|
401
|
+
prefix: "extends" | "no-baseline" | {
|
|
402
|
+
at: number;
|
|
403
|
+
of: number;
|
|
404
|
+
region: "params" | "system" | "tools" | "messages";
|
|
405
|
+
message?: number;
|
|
406
|
+
};
|
|
407
|
+
};
|
|
385
408
|
ts: number;
|
|
386
409
|
} | {
|
|
387
410
|
kind: "tool.call";
|
|
@@ -801,10 +824,7 @@ export type TraceEvent = {
|
|
|
801
824
|
taskId: string;
|
|
802
825
|
ts: number;
|
|
803
826
|
} | {
|
|
804
|
-
/**
|
|
805
|
-
* compaction model's window is SMALLER than the main model's: from `fallbackAt` estimated
|
|
806
|
-
* context tokens on, every boundary's summary call will either clamp-truncate its input or
|
|
807
|
-
* fall back to the main model. A deployment shell surfaces this as a startup hint. */
|
|
827
|
+
/** @deprecated Never emitted: there is no separate compaction model whose window could be smaller. Removed in 7.70.0. */
|
|
808
828
|
kind: "compaction.window_config_warning";
|
|
809
829
|
version: 1;
|
|
810
830
|
taskId: string;
|
|
@@ -818,8 +838,8 @@ export type TraceEvent = {
|
|
|
818
838
|
/** design/145 §3 — a compaction pass's summary call FELL BACK from the independent compaction
|
|
819
839
|
* model to the MAIN model: the dry-run clamp showed the conversation would lose more than
|
|
820
840
|
* `clampTolerance` of its chars in the small window (and the budget/walltime gates allowed
|
|
821
|
-
* the more expensive main-model call).
|
|
822
|
-
*
|
|
841
|
+
* the more expensive main-model call).
|
|
842
|
+
* @deprecated Never emitted: the summary always runs on the main model. Removed in 7.70.0. */
|
|
823
843
|
kind: "compaction.model_fallback";
|
|
824
844
|
version: 1;
|
|
825
845
|
taskId: string;
|
|
@@ -835,7 +855,8 @@ export type TraceEvent = {
|
|
|
835
855
|
/** design/145 §3 — a summary input WAS clamp-truncated on the small compaction model and the
|
|
836
856
|
* loss is hereby DISCLOSED (the pre-145 silent mid-section drop): reason "budget"/"walltime"
|
|
837
857
|
* = the fallback was denied by that gate; "tolerance" = within `clampTolerance` (bounded).
|
|
838
|
-
* Fires pre-call (survives a later summary failure).
|
|
858
|
+
* Fires pre-call (survives a later summary failure).
|
|
859
|
+
* @deprecated Never emitted: there is no small compaction model to clip for. Removed in 7.70.0. */
|
|
839
860
|
kind: "compaction.clamp_disclosure";
|
|
840
861
|
version: 1;
|
|
841
862
|
taskId: string;
|
|
@@ -859,7 +880,8 @@ export type TraceEvent = {
|
|
|
859
880
|
kind: "compaction.input_truncated";
|
|
860
881
|
version: 1;
|
|
861
882
|
taskId: string;
|
|
862
|
-
/** Which summary call was truncated
|
|
883
|
+
/** Which summary call was truncated. Always `"history"`: a pass sends one summary request over everything it folds;
|
|
884
|
+
* `"turn_prefix"` is deprecated: always absent, removed in 7.70.0. */
|
|
863
885
|
label: "history" | "turn_prefix";
|
|
864
886
|
droppedChars: number;
|
|
865
887
|
keptChars: number;
|
|
@@ -1038,7 +1060,8 @@ export type TracerHook = (e: TraceEvent) => void;
|
|
|
1038
1060
|
* (`egressAccount`) — so a frame that carries a host's, a store's or a remote's words (a thrown text, a failure reason) needs no
|
|
1039
1061
|
* remembering at its mint site. */
|
|
1040
1062
|
export declare function emitTrace(tracer: TracerHook | undefined, build: () => TraceEvent): void;
|
|
1041
|
-
/**
|
|
1063
|
+
/** One kind per {@link TraceEvent} arm — the union is the source, this list follows it; a deprecated arm's kind stays listed,
|
|
1064
|
+
* never minted, until its removal. */
|
|
1042
1065
|
export declare const TRACE_EVENT_KINDS: readonly ["task.start", "prompt.assembled", "prompt.snapshot_changed", "reasoning.resolved", "config.assembled", "config.additional_directory_skipped", "task.end", "turn.end", "brain.call", "tool.call", "repetition.detected", "task.degraded", "observer.notify_failed", "permission.persisted_rule_allowed", "permission.read_only_allowed", "permission.skill_allowed", "permission.allowed_tools_allowed", "permission.rule_store_unreadable", "permission.rule_sync_resurrected", "permission.rule_sync_dropped", "permission.org_snapshot_unavailable", "permission.cross_boundary_taint", "permission.sandbox_admitted", "auto_mode.classified", "brain.failover", "breaker.transition", "brain.retry", "loop.recovery", "compaction.suppressed", "compaction.unevaluable", "compaction.blocked", "compaction.failed", "compaction.mooted", "compaction.noop", "compaction.disabled", "compaction.window_config_warning", "compaction.model_fallback", "compaction.clamp_disclosure", "compaction.manual_in_finalize", "compaction.input_truncated", "compaction.phase_timings", "compaction.announce_dropped", "context.trim", "context.mc_clear", "context.mc_null", "tool_result.capped", "context.media_removed", "vision.placeholder", "brain.echo_dropped", "preempt.ignored", "review.dropped", "task.onerror_sink_failed"];
|
|
1043
1066
|
/** Compile-time fence: `never` while the list and the union's `kind` words are the same words. */
|
|
1044
1067
|
export type TraceEventKindsMatchTheUnion = AssertAllKeysHandled<Exclude<TraceEvent["kind"], (typeof TRACE_EVENT_KINDS)[number]> | Exclude<(typeof TRACE_EVENT_KINDS)[number], TraceEvent["kind"]>>;
|
|
@@ -5,6 +5,37 @@
|
|
|
5
5
|
* (engine/execution-env/symlink-chain.ts).
|
|
6
6
|
*/
|
|
7
7
|
export declare function isUncSpelling(p: string): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* The drive path a drive's administrative share names, read with the host left unasked, or `undefined` — with every drive
|
|
10
|
+
* path's names read as Win32 trims them ({@link belowTheRoot}: `C:\Users\u.` and `C:\Users\u ` are `C:\Users\u`). A UNC
|
|
11
|
+
* (`\\host\share\…`) whose share is a drive's administrative share `X$` (either case) names that drive on WHICHEVER machine the
|
|
12
|
+
* host is: `\\h\c$\rest` ⇒ `C:\rest` — whether `h` is this machine (its loopback address, its own name, an alias) only the
|
|
13
|
+
* environment knows. The DOS device spellings of a location are read as Win32 reads them: `\\?\UNC\…` is the UNC it prefixes
|
|
14
|
+
* ({@link stripWin32ExtendedPrefix}); a `\\.\` path, with the device prefix as its root, names a drive when its first segment
|
|
15
|
+
* is one (`\\.\C:\rest` ⇒ `C:\rest`; a bare `\\.\C:` is the volume's raw device and stays unread), or a UNC this rule reads
|
|
16
|
+
* when it is `UNC`. Only the ROOT is read: what lies below it is kept as written ({@link belowTheRoot}) — a `..` there is each
|
|
17
|
+
* reader's to take, as it is in the drive spelling — but for a `..` that would climb above the root, which the root itself
|
|
18
|
+
* answers: a share holds it at the share (`\\h\c$\..\x` ⇒ `C:\x`), and a `\\.\` path whose `..` would leave the volume stays
|
|
19
|
+
* unread. `undefined` for every other spelling: any other share (which directory a share maps is the server's to say), a volume
|
|
20
|
+
* named another way (`\\.\Volume{…}`, `\\?\GLOBALROOT\…`), and a spelling of the POSIX family — `family`, the tree's where
|
|
21
|
+
* the reader knows it, else the spelling's own (a tightening judgment reads spellings no tree placed): on POSIX `//h/c$/x` is
|
|
22
|
+
* an ordinary path, on a win tree it is the share.
|
|
23
|
+
*
|
|
24
|
+
* It names a location the spelling MAY be, never the one it is: no tree places a path at it, no allow reads it, and no
|
|
25
|
+
* judgment reads it where a hit could make its answer looser. It turns "no row" into a row (the one judgment of guarded rows,
|
|
26
|
+
* where the views as read answer nothing), finds more rows below a root (the read-deny table's relations) and more protected
|
|
27
|
+
* locations (the removal guard's key) — never a proof that a command left one, never the place a command stands — and it gives
|
|
28
|
+
* a device spelling the namespace screen refuses a drive stand-in (the shell station's one placement function), read where
|
|
29
|
+
* that word's own reading tightens.
|
|
30
|
+
*/
|
|
31
|
+
export declare function localDriveSpellingOf(p: string, family?: PathFamily): string | undefined;
|
|
32
|
+
/** A Win32 device-namespace spelling (`\\.\…`, either separator): a location no tree places — the namespace screen refuses it,
|
|
33
|
+
* and where the engine reads a drive out of one (the shell station's stand-in) that drive is its own reading, not the word's. */
|
|
34
|
+
export declare function isDeviceSpelling(p: string): boolean;
|
|
35
|
+
/** A Win32 namespace prefix spelled with ANY forward slash (`//?/`, `//?\`, `/\?\`, `\\/./`, …) is the SAME namespace after
|
|
36
|
+
* Win32's own normalization — only the verbatim all-backslash spelling disables it — so it is folded whole to its backslash
|
|
37
|
+
* twin, never read as a UNC with host `?` or `.`. Every other spelling is returned as is. */
|
|
38
|
+
export declare function win32NamespacePrefixFolded(p: string): string;
|
|
8
39
|
/** The two spelling families a tree can be in. Read from the ROOT's spelling (the cwd's when a deployment
|
|
9
40
|
* supplies no root) — never from `process.platform`: the exec env may be remote and of the other family. */
|
|
10
41
|
export type PathFamily = "win" | "posix";
|
|
@@ -2,6 +2,57 @@ import { isDriveAbsoluteSpelling } from "@sema-agent/primitives";
|
|
|
2
2
|
export function isUncSpelling(p) {
|
|
3
3
|
return /^[\\/]{2}[^\\/]+[\\/]+[^\\/]/.test(p);
|
|
4
4
|
}
|
|
5
|
+
export function localDriveSpellingOf(p, family) {
|
|
6
|
+
if ((family ?? (isWinFormPath(p) ? "win" : "posix")) !== "win")
|
|
7
|
+
return undefined;
|
|
8
|
+
const s = stripWin32ExtendedPrefix(win32NamespacePrefixFolded(p));
|
|
9
|
+
if (/^\\\\\.\\/.test(s)) {
|
|
10
|
+
const read = belowTheRoot(s.slice(4), (kept) => (/^UNC$/i.test(kept[0] ?? "") ? 3 : 1), "refuse");
|
|
11
|
+
const volume = read?.segs ?? [];
|
|
12
|
+
const head = volume[0];
|
|
13
|
+
const sep = read?.trailing === true ? "\\" : "";
|
|
14
|
+
const below = volume.slice(1).join("\\");
|
|
15
|
+
if (head !== undefined && /^[A-Za-z]:$/.test(head))
|
|
16
|
+
return read.depth > 1 || sep !== "" ? `${head.toUpperCase()}\\${below}${below !== "" ? sep : ""}` : undefined;
|
|
17
|
+
return head !== undefined && /^UNC$/i.test(head) ? localDriveSpellingOf(`\\\\${volume.slice(1).join("\\")}${sep}`, "win") : undefined;
|
|
18
|
+
}
|
|
19
|
+
const drive = /^([A-Za-z]):[\\/]([\s\S]*)$/.exec(s);
|
|
20
|
+
const unc = drive !== null ? null : /^[\\/]{2}([^\\/]+)[\\/]+([^\\/]+)(?:[\\/]+([\s\S]*))?$/.exec(s);
|
|
21
|
+
if (drive === null && (unc === null || !/^[A-Za-z]\$$/.test(unc[2]) || /^[?.]$/.test(unc[1])))
|
|
22
|
+
return undefined;
|
|
23
|
+
const below = belowTheRoot(drive !== null ? drive[2] : (unc[3] ?? ""), () => 0, "clamp");
|
|
24
|
+
return `${(drive !== null ? drive[1] : unc[2][0]).toUpperCase()}:\\${below.segs.join("\\")}${below.segs.length > 0 && below.trailing ? "\\" : ""}`;
|
|
25
|
+
}
|
|
26
|
+
function belowTheRoot(below, floor, atRoot) {
|
|
27
|
+
let trailing = /[\\/]$/.test(below);
|
|
28
|
+
const segs = below.split(/[\\/]+/).filter((seg) => seg !== "");
|
|
29
|
+
const kept = [];
|
|
30
|
+
let depth = 0;
|
|
31
|
+
for (const [i, seg] of segs.entries()) {
|
|
32
|
+
if (seg === ".")
|
|
33
|
+
continue;
|
|
34
|
+
if (seg === "..") {
|
|
35
|
+
if (depth > floor(kept))
|
|
36
|
+
(kept.push(seg), depth--);
|
|
37
|
+
else if (atRoot === "refuse")
|
|
38
|
+
return undefined;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const trimmed = seg.replace(/([^.])\.$/, "$1");
|
|
42
|
+
const last = i === segs.length - 1 && !trailing ? trimmed.replace(/[. ]+$/, "") : trimmed;
|
|
43
|
+
if (last === "")
|
|
44
|
+
trailing = true;
|
|
45
|
+
else
|
|
46
|
+
(kept.push(last), depth++);
|
|
47
|
+
}
|
|
48
|
+
return { segs: kept, trailing, depth };
|
|
49
|
+
}
|
|
50
|
+
export function isDeviceSpelling(p) {
|
|
51
|
+
return /^[\\/]{2}\.[\\/]/.test(p);
|
|
52
|
+
}
|
|
53
|
+
export function win32NamespacePrefixFolded(p) {
|
|
54
|
+
return /^[\\/]{2}[?.][\\/]/.test(p) && !/^\\\\[?.]\\/.test(p) ? p.replace(/\//g, "\\") : p;
|
|
55
|
+
}
|
|
5
56
|
export function pathFamilyOf(bases) {
|
|
6
57
|
const tree = bases.root ?? bases.cwd;
|
|
7
58
|
return tree === undefined ? undefined : isWinFormPath(tree) ? "win" : "posix";
|
|
@@ -26,6 +26,7 @@ import { type StoreDurability } from "./checkpoint-store.js";
|
|
|
26
26
|
import type { ModAdmissionRecord } from "./mods/kernel/index.js";
|
|
27
27
|
import type { McpAuthorization, McpDelivered, McpFailureKind, McpServerLiveness } from "./mcp-failure.js";
|
|
28
28
|
import type { WriteProtectionTargetView } from "./write-protect.js";
|
|
29
|
+
import type { DeclaredPlaceSource } from "./runner/leg-caller-places.js";
|
|
29
30
|
import { type OnAsk } from "./tool-policy.js";
|
|
30
31
|
import type { ApprovalRoute } from "./approval-route.js";
|
|
31
32
|
import { type RunOrigin } from "./run-origin.js";
|
|
@@ -591,13 +592,33 @@ export interface WiringManifest {
|
|
|
591
592
|
* leg compiled at prepare holds rows and the leg's execution environment does not declare it keeps the byte floor
|
|
592
593
|
* (`capabilities.keepsReadFloor`), on a deployment that does not require the floor (one that does refuses the leg instead):
|
|
593
594
|
* the engine refuses what a command names, but a recursive read under a root reads the files below it there, deny rows
|
|
594
|
-
* included. Always `{ kept: false }` when present.
|
|
595
|
-
*
|
|
596
|
-
*
|
|
595
|
+
* included. Always `{ kept: false }` when present. The leg's wiring AS IT STARTED: a table the leg compiles after the manifest
|
|
596
|
+
* went out (the person's persisted rules changed mid-run) is not here — the leg's record over its whole life is
|
|
597
|
+
* {@link import("./task-result.js").TaskResult.readDenyFloor}, which reads the same latch when the result is assembled (so it
|
|
598
|
+
* holds wherever this cell does). The person's notice `config.read_deny_floor_unkept` is told once per session. ABSENT = the
|
|
599
|
+
* floor is kept, or the table held no row, or the leg was minted by an engine older than this member — a reader cannot tell
|
|
600
|
+
* the three apart from the manifest alone (the engine's version can).
|
|
597
601
|
*/
|
|
598
602
|
readDenyFloor?: {
|
|
599
603
|
kept: false;
|
|
600
604
|
};
|
|
605
|
+
/**
|
|
606
|
+
* EFFECTIVE half only, OUTSIDE {@link configFingerprint} (a task declares its own). PRESENT IFF the leg places deny rows at a
|
|
607
|
+
* declared place: a configuration root (`agentConfigDirs` — `RunnerDeps.agentConfigDir`, `TaskSpec.agentConfigDirs`, a resumed
|
|
608
|
+
* row's) or a caller's home (`agentHomeDirs` — `TaskSpec.agentHomeDirs`, a resumed row's). Each list holds one entry per place
|
|
609
|
+
* the leg's one mint holds, `from` naming every layer that declared it (`"deployment"` / `"task"` / `"checkpoint"`); a list with
|
|
610
|
+
* no place is absent. The paths themselves are not reported (host texts, the {@link readDeny} class): the section says how
|
|
611
|
+
* many places guard the leg and where each came from — a host that handed a root and sees no `"task"` entry knows it did not
|
|
612
|
+
* arrive. ABSENT = no declared place (the engine's own homes only), or an engine older than this member.
|
|
613
|
+
*/
|
|
614
|
+
declaredPlaces?: {
|
|
615
|
+
agentConfigDirs?: ReadonlyArray<{
|
|
616
|
+
readonly from: readonly DeclaredPlaceSource[];
|
|
617
|
+
}>;
|
|
618
|
+
agentHomeDirs?: ReadonlyArray<{
|
|
619
|
+
readonly from: readonly DeclaredPlaceSource[];
|
|
620
|
+
}>;
|
|
621
|
+
};
|
|
601
622
|
/**
|
|
602
623
|
* EFFECTIVE half only. PRESENT IFF auto-consolidation is EFFECTIVELY armed on this
|
|
603
624
|
* deployment (`autoRunOnRecommendationEffective`: an explicit `true`, or an absent seat under the
|
|
@@ -818,6 +839,12 @@ export interface WiringFacts {
|
|
|
818
839
|
/** Effective half only — the byte floor's judgment of the table the leg compiled ({@link WiringManifest.readDenyFloor}): `true` ⇔
|
|
819
840
|
* rows on an environment that does not keep the floor; absent or `false` ⇒ no cell. */
|
|
820
841
|
readDenyFloorUnkept?: boolean;
|
|
842
|
+
/** Effective half only — the leg's declared places as its one mint holds them ({@link WiringManifest.declaredPlaces}): per list,
|
|
843
|
+
* the layers each place came from (index-aligned with the mint's places); empty lists ⇒ no section. */
|
|
844
|
+
declaredPlaces?: {
|
|
845
|
+
readonly agentConfigDirs: ReadonlyArray<readonly DeclaredPlaceSource[]>;
|
|
846
|
+
readonly agentHomeDirs: ReadonlyArray<readonly DeclaredPlaceSource[]>;
|
|
847
|
+
};
|
|
821
848
|
/** Effective half only — `RunnerDeps.autoRunOnRecommendation === true`
|
|
822
849
|
* ({@link WiringManifest.autoConsolidation}); false ⇒ no section (byte-identical manifest). */
|
|
823
850
|
autoConsolidationOnRecommendation?: boolean;
|
|
@@ -197,6 +197,15 @@ function readWordFact(word, words, label) {
|
|
|
197
197
|
throw new Error(`the ${label} wiring fact ${JSON.stringify(word)} is not one of ${words.join("|")}`);
|
|
198
198
|
return word;
|
|
199
199
|
}
|
|
200
|
+
const DECLARED_PLACE_SOURCES = ["deployment", "task", "checkpoint"];
|
|
201
|
+
function declaredPlacesSection(fact) {
|
|
202
|
+
const list = (sources) => sources.map((from) => ({ from: from.map((w) => readWordFact(w, DECLARED_PLACE_SOURCES, "declared-place source")) }));
|
|
203
|
+
const section = {
|
|
204
|
+
...(fact.agentConfigDirs.length > 0 ? { agentConfigDirs: list(fact.agentConfigDirs) } : {}),
|
|
205
|
+
...(fact.agentHomeDirs.length > 0 ? { agentHomeDirs: list(fact.agentHomeDirs) } : {}),
|
|
206
|
+
};
|
|
207
|
+
return Object.keys(section).length > 0 ? { declaredPlaces: section } : {};
|
|
208
|
+
}
|
|
200
209
|
function readInteractionSeatsFact(fact) {
|
|
201
210
|
if (typeof fact.question !== "boolean")
|
|
202
211
|
throw new Error(`the interaction-seats wiring fact's question seat ${JSON.stringify(fact.question)} is not a boolean`);
|
|
@@ -286,6 +295,7 @@ export function deriveWiringManifest(facts) {
|
|
|
286
295
|
? { readDeny: { builtinTiers: [...facts.readDenyBuiltinTiersActive] } }
|
|
287
296
|
: {}),
|
|
288
297
|
...(facts.half === "effective" && facts.readDenyFloorUnkept === true ? { readDenyFloor: { kept: false } } : {}),
|
|
298
|
+
...(facts.half === "effective" && facts.declaredPlaces !== undefined ? declaredPlacesSection(facts.declaredPlaces) : {}),
|
|
289
299
|
...(facts.half === "effective" && facts.autoConsolidationOnRecommendation === true ? { autoConsolidation: { onRecommendation: true } } : {}),
|
|
290
300
|
...(facts.half === "effective" && facts.fileHistory !== undefined ? { fileHistory: readWordFact(facts.fileHistory, ["on", "disabled"], "file-history") } : {}),
|
|
291
301
|
...(facts.half === "effective" && facts.commandSandbox !== undefined && facts.commandSandbox.state !== "off"
|
|
@@ -150,6 +150,28 @@ export async function workflowRunStoreContract(make, runAssertion = defaultSeque
|
|
|
150
150
|
const again = await store.get("full");
|
|
151
151
|
assert.deepEqual(again, { ...full, rev: (got.rev ?? 0) + 1 }, "writing back what get returned keeps every member");
|
|
152
152
|
});
|
|
153
|
+
run("a park entry's settledDecisions written on a FINISHED run (cause park_decision_settled) comes back from get as written, on that entry alone, and survives the next write of the record", async () => {
|
|
154
|
+
const store = make();
|
|
155
|
+
const held = { callKey: "1:g", sessionId: "child-1", token: "tok-held", originRunId: "fin-s", parkedBy: "fin-s", generation: 1 };
|
|
156
|
+
const other = { callKey: "2:h", sessionId: "child-2", token: "tok-other", originRunId: "fin-s", parkedBy: "fin-s", generation: 1 };
|
|
157
|
+
const finished = createWorkflowRun({ id: "fin-s", status: "failed", error: "parked", errorCode: "workflow.agent_parked", parks: [held, other] });
|
|
158
|
+
await store.put(finished.id, finished);
|
|
159
|
+
const got = (await store.get("fin-s"));
|
|
160
|
+
const settled = [
|
|
161
|
+
{ decisionId: "dec-a", reason: "denied", code: "persisted_rule" },
|
|
162
|
+
{ decisionId: "dec-b", reason: "launch_unreadable" },
|
|
163
|
+
];
|
|
164
|
+
const written = { ...got, parks: got.parks.map((p) => (p.token === held.token ? { ...p, settledDecisions: settled.map((s) => ({ ...s })) } : p)) };
|
|
165
|
+
assert.equal(await store.update("fin-s", "tenant-a", written, { rev: got.rev ?? 0 }, { cause: "park_decision_settled" }), true, "the current rev wins on a finished row");
|
|
166
|
+
const after = (await store.get("fin-s"));
|
|
167
|
+
assert.deepEqual(after.parks, [{ ...held, settledDecisions: settled }, other], "the entry carries the member as written (order, each member, an absent code absent), and the other entry carries none of it");
|
|
168
|
+
assert.equal(after.status, "failed");
|
|
169
|
+
assert.equal(after.errorCode, "workflow.agent_parked");
|
|
170
|
+
assert.equal(after.rev, (got.rev ?? 0) + 1, "the write bumps rev");
|
|
171
|
+
const passed = { ...after, parks: after.parks.map((p) => (p.token === other.token ? { ...p, passedTo: "fin-s-next" } : p)) };
|
|
172
|
+
assert.equal(await store.update("fin-s", "tenant-a", passed, { rev: after.rev ?? 0 }, { cause: "park_pass" }), true);
|
|
173
|
+
assert.deepEqual((await store.get("fin-s")).parks, [{ ...held, settledDecisions: settled }, { ...other, passedTo: "fin-s-next" }], "a later write of what get returned keeps the member");
|
|
174
|
+
});
|
|
153
175
|
run("the key id is authoritative — a payload with a mismatched id never poisons the projection", async () => {
|
|
154
176
|
const store = make();
|
|
155
177
|
const r = createWorkflowRun({ id: "real", status: "running" });
|
|
@@ -202,20 +202,22 @@ export interface WorkflowRunListByScopeOptions {
|
|
|
202
202
|
}
|
|
203
203
|
/**
|
|
204
204
|
* The words a {@link WorkflowRunStore.update} call can state about itself ({@link WorkflowRunUpdateOptions.cause}) when it is not the
|
|
205
|
-
* owner recording its own run.
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
205
|
+
* owner recording its own run. Two words, each a write of a FINISHED run's record by another party — the whole record as `get` returned
|
|
206
|
+
* it with one member added, compared on `rev`, at most three calls per write of which at most one lands:
|
|
207
|
+
* - `park_pass` — a later continuation of the run's chain takes over a park that run holds: one park entry's `passedTo` added (#4455).
|
|
208
|
+
* - `park_decision_settled` — the engine's continuation records a host's decision for a park that run holds as one it will never use:
|
|
209
|
+
* entries added to park entries' `settledDecisions`.
|
|
210
|
+
* A store may read the word (one that wraps another and tells its own observers "this run's state changed" can tell these writes from
|
|
211
|
+
* the owner's: any word present means the run's own state did not change), but what it persists never depends on it: the row written
|
|
212
|
+
* is the same with the word and without it.
|
|
211
213
|
*/
|
|
212
|
-
export declare const WORKFLOW_RUN_UPDATE_CAUSES: readonly ["park_pass"];
|
|
214
|
+
export declare const WORKFLOW_RUN_UPDATE_CAUSES: readonly ["park_pass", "park_decision_settled"];
|
|
213
215
|
export type WorkflowRunUpdateCause = (typeof WORKFLOW_RUN_UPDATE_CAUSES)[number];
|
|
214
216
|
/** {@link WorkflowRunStore.update}'s options — the SINGLE shape the interface method and both the In-Memory and File implementations reference. */
|
|
215
217
|
export interface WorkflowRunUpdateOptions {
|
|
216
218
|
/** The kind of write, when it is not the owner recording its own run ({@link WORKFLOW_RUN_UPDATE_CAUSES}). PRESENT EXACTLY on such a
|
|
217
219
|
* write and absent on every write the owner makes of its own record (its progress and its terminal), so an absent `cause` reads "the
|
|
218
|
-
* run's own state changed". Never a gate and never persisted. */
|
|
220
|
+
* run's own state changed" and any word present reads "it did not". Never a gate and never persisted. */
|
|
219
221
|
cause?: WorkflowRunUpdateCause;
|
|
220
222
|
}
|
|
221
223
|
/**
|
|
@@ -236,11 +238,13 @@ export interface WorkflowRunStore {
|
|
|
236
238
|
* (an intervening update bumped it). On success the store bumps the row's `rev` (monotonic) and persists
|
|
237
239
|
* the new `run`. The workflow owner writes its record while it runs (best-effort progress recording — design/97 §F);
|
|
238
240
|
* once the run has finished, a later continuation of its chain may write it again to take over a park it holds
|
|
239
|
-
* (`WorkflowRun.parks[].passedTo
|
|
240
|
-
*
|
|
241
|
-
* `
|
|
242
|
-
*
|
|
243
|
-
*
|
|
241
|
+
* (`WorkflowRun.parks[].passedTo`), and the engine's continuation may write it again to record a decision for a park it holds as
|
|
242
|
+
* one it will never use (`WorkflowRun.parks[].settledDecisions`) — each the whole record as `get` returned it, with `expect.rev`.
|
|
243
|
+
* `expect.rev` lets each writer detect a lost write rather than silently clobber; a store must apply such a write to a finished
|
|
244
|
+
* run like any other. `opts.cause` (additive) names those other writes ({@link WORKFLOW_RUN_UPDATE_CAUSES}) and is absent on every
|
|
245
|
+
* write the owner makes of its own record, so a store that wraps another and reacts to "a run's state changed" can tell them apart
|
|
246
|
+
* (any word present: the run's own state did not change). It never changes what is persisted: the CAS and the row written are the
|
|
247
|
+
* same with it and without it, and a store that does not read it is correct.
|
|
244
248
|
*/
|
|
245
249
|
update(id: string, scope: string, run: WorkflowRun, expect?: {
|
|
246
250
|
rev: number;
|
|
@@ -97,7 +97,7 @@ export class WorkflowRunStoreError extends Error {
|
|
|
97
97
|
this.name = "WorkflowRunStoreError";
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
export const WORKFLOW_RUN_UPDATE_CAUSES = Object.freeze(["park_pass"]);
|
|
100
|
+
export const WORKFLOW_RUN_UPDATE_CAUSES = Object.freeze(["park_pass", "park_decision_settled"]);
|
|
101
101
|
export function nextWorkflowRunOnUpdate(cur, id, scope, run, expect, disclose) {
|
|
102
102
|
if (!cur || cur.scope !== scope)
|
|
103
103
|
return null;
|
|
@@ -196,6 +196,10 @@ export interface WriteProtectionCompileOptions {
|
|
|
196
196
|
* `.sema` (`RunnerDeps.agentConfigDir`, absolute, already screened): every row that names the `.sema` directory also
|
|
197
197
|
* names the same tail below this root, and a hit there cites the row. Omitted ⇒ the table is judged as it stands. */
|
|
198
198
|
readonly agentConfigDir?: string;
|
|
199
|
+
/** More configuration roots, placed exactly as {@link agentConfigDir} is (absolute, already screened). A Runner leg hands
|
|
200
|
+
* its one minted list here — the deployment's root, the task's `TaskSpec.agentConfigDirs`, a resumed row's — and leaves
|
|
201
|
+
* `agentConfigDir` unset. Omitted or `[]` ⇒ nothing more is placed. */
|
|
202
|
+
readonly declaredAgentConfigDirs?: readonly string[];
|
|
199
203
|
/**
|
|
200
204
|
* Called at most ONCE per judgment, at the moment the ENVIRONMENT half is found unable to contribute
|
|
201
205
|
* ({@link WriteProtectionViewAbsence}) — before the judgment returns, and on the hit arm as well as the
|