@sema-agent/core 7.51.2 → 7.52.0
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 +504 -2
- package/dist/agents/agent-transcript-tool.d.ts +1 -1
- package/dist/agents/cascade.js +4 -0
- package/dist/agents/cumulative-stats.d.ts +3 -0
- package/dist/agents/cumulative-stats.js +3 -0
- package/dist/agents/list-agents-tool.d.ts +1 -1
- package/dist/agents/read-inbox-tool.d.ts +1 -1
- package/dist/agents/repair-loop.js +4 -0
- package/dist/agents/send-message-tool.d.ts +11 -16
- package/dist/agents/send-message-tool.js +11 -13
- package/dist/agents/subagent.js +6 -4
- package/dist/agents/tool-filter.d.ts +40 -13
- package/dist/agents/tool-filter.js +28 -14
- package/dist/bench/metrics.d.ts +1 -0
- package/dist/brain/anthropic.js +16 -12
- package/dist/brain/model-presets.d.ts +4 -5
- package/dist/brain/model-presets.js +4 -4
- package/dist/brain/open-responses.js +16 -12
- package/dist/brain/openai.js +16 -12
- package/dist/brain/request-params.d.ts +12 -33
- package/dist/brain/request-params.js +5 -2
- package/dist/brain/request-route.d.ts +9 -8
- package/dist/brain/request-route.js +1 -0
- package/dist/brain/route-adjudicator.d.ts +117 -47
- package/dist/brain/route-adjudicator.js +171 -42
- package/dist/brain/route-conformance.js +2 -2
- package/dist/brain/status-sink.d.ts +18 -0
- package/dist/brain/status-sink.js +7 -0
- package/dist/core/allow-entry.d.ts +40 -8
- package/dist/core/allow-entry.js +23 -16
- package/dist/core/auto-compaction.d.ts +23 -20
- package/dist/core/auto-compaction.js +37 -16
- package/dist/core/auto-promote.d.ts +2 -1
- package/dist/core/auto-promote.js +2 -2
- package/dist/core/caller-tool-name.d.ts +9 -0
- package/dist/core/caller-tool-name.js +13 -0
- package/dist/core/checkpoint-requirements.d.ts +7 -1
- package/dist/core/checkpoint-requirements.js +2 -0
- package/dist/core/checkpoint-store.d.ts +36 -12
- package/dist/core/checkpoint-store.js +1 -1
- package/dist/core/child-clamp-seats.d.ts +6 -0
- package/dist/core/child-clamp-seats.js +2 -1
- package/dist/core/credential-vocabulary.d.ts +33 -8
- package/dist/core/credential-vocabulary.js +32 -7
- package/dist/core/decision-receipt.d.ts +2 -2
- package/dist/core/delegation-frames.d.ts +9 -2
- package/dist/core/delegation-name.d.ts +18 -0
- package/dist/core/delegation-name.js +47 -0
- package/dist/core/engine-capabilities.d.ts +8 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +36 -19
- package/dist/core/frontmatter-fence.d.ts +10 -0
- package/dist/core/frontmatter-fence.js +6 -0
- package/dist/core/gate-fold.js +5 -23
- package/dist/core/gate-lanes.js +356 -270
- package/dist/core/governance-codes.d.ts +9 -4
- package/dist/core/governance-codes.js +9 -3
- package/dist/core/hooks.d.ts +276 -734
- package/dist/core/hooks.js +97 -192
- package/dist/{tools/fs → core}/image-admission.d.ts +21 -3
- package/dist/{tools/fs → core}/image-admission.js +24 -6
- package/dist/core/mcp-connection-pool.d.ts +4 -1
- package/dist/core/mcp-connection-pool.js +7 -2
- package/dist/core/mcp-probe.d.ts +12 -9
- package/dist/core/mcp-probe.js +2 -2
- package/dist/core/mcp-server-spec.d.ts +16 -0
- package/dist/core/mcp.d.ts +11 -7
- package/dist/core/mcp.js +11 -5
- package/dist/core/memory-engine/data-plane.js +5 -1
- package/dist/core/memory-engine/distiller.js +16 -2
- package/dist/core/memory-engine/engine.d.ts +8 -11
- package/dist/core/memory-engine/engine.js +9 -5
- package/dist/core/memory-engine/frontmatter.d.ts +6 -0
- package/dist/core/memory-engine/frontmatter.js +19 -16
- package/dist/core/memory.d.ts +2 -2
- package/dist/core/mode-policy.d.ts +4 -0
- package/dist/core/mode-policy.js +7 -5
- package/dist/core/model-seat.d.ts +4 -1
- package/dist/core/mods/dollar.d.ts +109 -0
- package/dist/core/mods/dollar.js +154 -0
- package/dist/core/mods/host.d.ts +23 -0
- package/dist/core/mods/host.js +21 -0
- package/dist/core/mods/kernel/budget.d.ts +43 -0
- package/dist/core/mods/kernel/budget.js +83 -0
- package/dist/core/mods/kernel/dispatch.d.ts +100 -0
- package/dist/core/mods/kernel/dispatch.js +701 -0
- package/dist/core/mods/kernel/events.d.ts +242 -0
- package/dist/core/mods/kernel/events.js +210 -0
- package/dist/core/mods/kernel/index.d.ts +6 -0
- package/dist/core/mods/kernel/index.js +5 -0
- package/dist/core/mods/kernel/receive.d.ts +65 -0
- package/dist/core/mods/kernel/receive.js +123 -0
- package/dist/core/mods/kernel/registration.d.ts +131 -0
- package/dist/core/mods/kernel/registration.js +102 -0
- package/dist/core/mods/kernel/site-rules.d.ts +84 -0
- package/dist/core/mods/kernel/site-rules.js +104 -0
- package/dist/core/mods/stations.d.ts +350 -0
- package/dist/core/mods/stations.js +444 -0
- package/dist/core/own-property-receipt.js +11 -23
- package/dist/core/parent-spec-seat.d.ts +18 -7
- package/dist/core/parent-spec-seat.js +6 -2
- package/dist/core/path-identity.js +2 -1
- package/dist/core/permission-rule-syntax.d.ts +15 -0
- package/dist/core/permission-rule-syntax.js +24 -16
- package/dist/core/permission-rules.d.ts +7 -1
- package/dist/core/permission-rules.js +26 -15
- package/dist/core/prompt-section-seat.d.ts +15 -27
- package/dist/core/prompt-section-seat.js +73 -40
- package/dist/core/protocol-http-auth.d.ts +3 -1
- package/dist/core/protocol-http-auth.js +2 -0
- package/dist/core/reminder-mint.d.ts +2 -2
- package/dist/core/remote-env.d.ts +24 -12
- package/dist/core/remote-env.js +1 -0
- package/dist/core/resume-startup-cause.d.ts +16 -1
- package/dist/core/resume-startup-cause.js +4 -1
- package/dist/core/retired-keys.d.ts +4 -0
- package/dist/core/retired-keys.js +3 -0
- package/dist/core/runner/announce-once-ledger.d.ts +31 -1
- package/dist/core/runner/announce-once-ledger.js +22 -0
- package/dist/core/runner/assemble-result.d.ts +9 -0
- package/dist/core/runner/assemble-result.js +3 -1
- package/dist/core/runner/call-hook-stations.d.ts +23 -27
- package/dist/core/runner/call-hook-stations.js +58 -42
- package/dist/core/runner/caller-stop-gate.d.ts +25 -0
- package/dist/core/runner/caller-stop-gate.js +7 -0
- package/dist/core/runner/compaction-seams.d.ts +8 -22
- package/dist/core/runner/compaction-seams.js +28 -53
- package/dist/core/runner/construction-doors.js +11 -1
- package/dist/core/runner/contracts.d.ts +85 -83
- package/dist/core/runner/credential-origin-seat.d.ts +2 -0
- package/dist/core/runner/credential-origin-seat.js +19 -0
- package/dist/core/runner/extra-body-dropped-seat.d.ts +2 -6
- package/dist/core/runner/gate-exit.d.ts +47 -36
- package/dist/core/runner/gate-exit.js +8 -2
- package/dist/core/runner/image.js +1 -2
- package/dist/core/runner/inline-image.js +1 -1
- package/dist/core/runner/notice-seat-input.d.ts +11 -0
- package/dist/core/runner/notice-seat-input.js +1 -0
- package/dist/core/runner/person-path-rows.js +1 -0
- package/dist/core/runner/prepare-acquire-reconcile.js +5 -1
- package/dist/core/runner/prepare-ask-lane.d.ts +5 -7
- package/dist/core/runner/prepare-ask-lane.js +6 -15
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -2
- package/dist/core/runner/prepare-caps-and-workflow.js +25 -8
- package/dist/core/runner/prepare-config-doors.d.ts +5 -0
- package/dist/core/runner/prepare-config-doors.js +9 -0
- package/dist/core/runner/prepare-defer-classify.js +3 -4
- package/dist/core/runner/prepare-gate-stations.d.ts +8 -11
- package/dist/core/runner/prepare-gate-stations.js +11 -10
- package/dist/core/runner/prepare-inherited-gate.d.ts +8 -12
- package/dist/core/runner/prepare-inherited-gate.js +8 -21
- package/dist/core/runner/prepare-memory-engine-session.js +1 -1
- package/dist/core/runner/prepare-park-ask.js +10 -14
- package/dist/core/runner/prepare-policy-chain.d.ts +17 -15
- package/dist/core/runner/prepare-policy-chain.js +95 -100
- package/dist/core/runner/prepare-project-context.js +7 -10
- package/dist/core/runner/prepare-prompt-assembly.d.ts +45 -40
- package/dist/core/runner/prepare-prompt-assembly.js +134 -101
- package/dist/core/runner/prepare-prompt-inputs.d.ts +18 -19
- package/dist/core/runner/prepare-prompt-inputs.js +5 -7
- package/dist/core/runner/prepare-protocol-tools.d.ts +6 -4
- package/dist/core/runner/prepare-protocol-tools.js +2 -2
- package/dist/core/runner/prepare-safety-scan.js +6 -10
- package/dist/core/runner/prepare-suspend-saga.d.ts +6 -0
- package/dist/core/runner/prepare-suspend-saga.js +7 -5
- package/dist/core/runner/prepare-task.js +33 -15
- package/dist/core/runner/prepare-turn-wiring.d.ts +13 -15
- package/dist/core/runner/prepare-turn-wiring.js +29 -27
- package/dist/core/runner/prepare-wiring-manifest.d.ts +5 -6
- package/dist/core/runner/prepare-wiring-manifest.js +7 -7
- package/dist/core/runner/resume-apply.d.ts +5 -2
- package/dist/core/runner/resume-apply.js +24 -42
- package/dist/core/runner/resume-checkpoint-screen.d.ts +1 -0
- package/dist/core/runner/resume-checkpoint-screen.js +9 -1
- package/dist/core/runner/resume-preflight.js +38 -16
- package/dist/core/runner/retired-runner-deps.js +3 -1
- package/dist/core/runner/run-brain-sinks.d.ts +3 -2
- package/dist/core/runner/run-brain-sinks.js +5 -1
- package/dist/core/runner/run-compaction-machinery.d.ts +7 -1
- package/dist/core/runner/run-compaction-machinery.js +7 -33
- package/dist/core/runner/run-harness-handlers.js +4 -2
- package/dist/core/runner/run-identity-wiring.d.ts +3 -1
- package/dist/core/runner/run-identity-wiring.js +3 -2
- package/dist/core/runner/run-leg.js +62 -84
- package/dist/core/runner/run-notification-lane.js +1 -0
- package/dist/core/runner/run-recovery-lanes.d.ts +3 -0
- package/dist/core/runner/run-recovery-lanes.js +11 -10
- package/dist/core/runner/run-settle-and-teardown.js +9 -28
- package/dist/core/runner/run-stop-and-final-verify.js +18 -25
- package/dist/core/runner/run-terminal-adoption.d.ts +3 -0
- package/dist/core/runner/run-terminal-adoption.js +33 -22
- package/dist/core/runner/run-tool-mount-facts.js +5 -3
- package/dist/core/runner/run-turn-boundary.js +23 -34
- package/dist/core/runner/runtask.d.ts +6 -7
- package/dist/core/runner/runtask.js +14 -72
- package/dist/core/runner/session-rule-policy.d.ts +5 -5
- package/dist/core/runner/session-rule-policy.js +13 -8
- package/dist/core/runner/side-call-account.d.ts +68 -0
- package/dist/core/runner/side-call-account.js +61 -0
- package/dist/core/runner/stream-halt-verbs.js +12 -17
- package/dist/core/runner/stream-lifecycle-verbs.js +8 -5
- package/dist/core/runner/stream-steer-verb.d.ts +1 -1
- package/dist/core/runner/stream-steer-verb.js +20 -38
- package/dist/core/runner/sub-agent-deny-lists.d.ts +121 -22
- package/dist/core/runner/sub-agent-deny-lists.js +228 -71
- package/dist/core/runner/tool-end-body.d.ts +5 -6
- package/dist/core/runner/tool-end-body.js +6 -4
- package/dist/core/runner/tool-not-executed.d.ts +15 -0
- package/dist/core/runner/tool-not-executed.js +30 -0
- package/dist/core/runner/tool-occurrence.d.ts +8 -7
- package/dist/core/runner/tool-occurrence.js +5 -5
- package/dist/core/runner/tool-result-media-seat.d.ts +1 -1
- package/dist/core/runner-deps.d.ts +20 -28
- package/dist/core/safety-merge-corpus.js +18 -2
- package/dist/core/secret-env.d.ts +88 -20
- package/dist/core/secret-env.js +192 -38
- package/dist/core/session-policy-store.d.ts +52 -16
- package/dist/core/session-policy-store.js +118 -28
- package/dist/core/session-reconcile.d.ts +4 -0
- package/dist/core/session-reconcile.js +2 -1
- package/dist/core/shell-read-silence.js +3 -32
- package/dist/core/side-query.d.ts +5 -3
- package/dist/core/skill-grant.d.ts +3 -2
- package/dist/core/skill-grant.js +17 -9
- package/dist/core/skills-directory.d.ts +31 -11
- package/dist/core/skills-directory.js +655 -104
- package/dist/core/task-event.d.ts +13 -3
- package/dist/core/task-result.d.ts +8 -0
- package/dist/core/task-spec.d.ts +20 -19
- package/dist/core/task-stream.d.ts +14 -4
- package/dist/core/tighten-task-spec.d.ts +4 -3
- package/dist/core/tighten-task-spec.js +2 -4
- package/dist/core/tool-check-reading.d.ts +74 -0
- package/dist/core/tool-check-reading.js +80 -0
- package/dist/core/tool-policy.d.ts +59 -18
- package/dist/core/tool-policy.js +77 -12
- package/dist/core/tool-registry.d.ts +20 -0
- package/dist/core/tool-registry.js +4 -0
- package/dist/core/tool-spec.d.ts +10 -6
- package/dist/core/tools.js +2 -0
- package/dist/core/trace.d.ts +51 -32
- package/dist/core/unc-spelling.d.ts +10 -0
- package/dist/core/unc-spelling.js +3 -0
- package/dist/core/untrusted-egress.d.ts +8 -0
- package/dist/core/untrusted-egress.js +4 -1
- package/dist/core/user-attachment.d.ts +12 -2
- package/dist/core/user-attachment.js +17 -2
- package/dist/core/wiring-manifest.d.ts +14 -13
- package/dist/core/wiring-manifest.js +2 -2
- package/dist/engine/compaction/utils.js +1 -2
- package/dist/engine/execution-env/node-execution-env.d.ts +4 -3
- package/dist/engine/execution-env/symlink-chain.js +1 -1
- package/dist/engine/harness/agent-harness.d.ts +1 -1
- package/dist/engine/harness/agent-harness.js +3 -3
- package/dist/engine/harness/types.d.ts +17 -16
- package/dist/engine/harness/types.js +7 -1
- package/dist/engine/llm/types.d.ts +12 -7
- package/dist/engine/loop/agent-loop.js +1 -1
- package/dist/engine/loop/types.d.ts +1 -1
- package/dist/engine/lsp/node-lsp-manager.d.ts +2 -2
- package/dist/engine/session/import-validate.js +3 -10
- package/dist/engine/session/session.d.ts +4 -4
- package/dist/engine/session/session.js +4 -4
- package/dist/index.d.ts +20 -16
- package/dist/index.js +13 -11
- package/dist/internal/harness.d.ts +1 -1
- package/dist/internal/harness.js +1 -1
- package/dist/orchestration/run-spec.d.ts +4 -6
- package/dist/orchestration/run-spec.js +39 -63
- package/dist/orchestration/run-workflow-tool.js +1 -2
- package/dist/orchestration/workflow.d.ts +11 -3
- package/dist/orchestration/workflow.js +11 -2
- package/dist/prompt-assembly/artifact-store.d.ts +37 -56
- package/dist/prompt-assembly/artifact-store.js +31 -49
- package/dist/prompt-assembly/artifact.d.ts +89 -76
- package/dist/prompt-assembly/artifact.js +167 -146
- package/dist/prompt-assembly/assemble.d.ts +34 -29
- package/dist/prompt-assembly/assemble.js +33 -220
- package/dist/prompt-assembly/bands.d.ts +20 -0
- package/dist/prompt-assembly/bands.js +18 -0
- package/dist/prompt-assembly/catalog/constitution.d.ts +23 -0
- package/dist/prompt-assembly/catalog/constitution.js +69 -0
- package/dist/prompt-assembly/catalog/core-behavior.d.ts +9 -0
- package/dist/prompt-assembly/catalog/core-behavior.js +85 -0
- package/dist/prompt-assembly/catalog/index.d.ts +11 -0
- package/dist/prompt-assembly/catalog/index.js +59 -0
- package/dist/prompt-assembly/catalog/modes.d.ts +15 -0
- package/dist/prompt-assembly/catalog/modes.js +137 -0
- package/dist/prompt-assembly/catalog/role.d.ts +10 -0
- package/dist/prompt-assembly/catalog/role.js +157 -0
- package/dist/prompt-assembly/catalog/schema.d.ts +124 -0
- package/dist/prompt-assembly/catalog/schema.js +25 -0
- package/dist/prompt-assembly/catalog/sections.d.ts +9 -0
- package/dist/prompt-assembly/catalog/sections.js +98 -0
- package/dist/prompt-assembly/catalog/team.d.ts +4 -0
- package/dist/prompt-assembly/catalog/team.js +258 -0
- package/dist/prompt-assembly/composer.d.ts +24 -28
- package/dist/prompt-assembly/composer.js +124 -46
- package/dist/prompt-assembly/epoch.d.ts +89 -79
- package/dist/prompt-assembly/epoch.js +115 -142
- package/dist/prompt-assembly/explain.d.ts +58 -34
- package/dist/prompt-assembly/explain.js +21 -24
- package/dist/prompt-assembly/overlay.d.ts +127 -0
- package/dist/prompt-assembly/overlay.js +301 -0
- package/dist/prompt-assembly/renderers.d.ts +21 -0
- package/dist/prompt-assembly/renderers.js +39 -0
- package/dist/prompt-assembly/section-usage.d.ts +3 -3
- package/dist/prompt-assembly/section-usage.js +1 -1
- package/dist/prompt-assembly/select.d.ts +56 -0
- package/dist/prompt-assembly/select.js +69 -0
- package/dist/prompt-assembly/sugar.d.ts +31 -0
- package/dist/prompt-assembly/sugar.js +20 -0
- package/dist/prompt-assembly/turn-snapshot.d.ts +3 -2
- package/dist/prompt-assembly/types.d.ts +45 -148
- package/dist/prompts/coordinator.d.ts +2 -21
- package/dist/prompts/coordinator.js +3 -255
- package/dist/prompts/cowork.d.ts +27 -16
- package/dist/prompts/cowork.js +2 -23
- package/dist/prompts/default.d.ts +38 -500
- package/dist/prompts/default.js +20 -285
- package/dist/prompts/supervisor.d.ts +6 -71
- package/dist/prompts/supervisor.js +6 -117
- package/dist/tools/fs/bash-readonly-classifier.d.ts +6 -5
- package/dist/tools/fs/dir-entries.d.ts +4 -2
- package/dist/tools/fs/dir-entries.js +16 -4
- package/dist/tools/fs/fs-bash.d.ts +1 -1
- package/dist/tools/fs/fs-bash.js +22 -11
- package/dist/tools/fs/fs-pdf.js +17 -13
- package/dist/tools/fs/fs-read.js +4 -3
- package/dist/tools/fs/fs-shared.d.ts +1 -10
- package/dist/tools/fs/fs-shared.js +3 -4
- package/dist/tools/fs/fs-write.js +2 -1
- package/dist/tools/fs/notebook.js +1 -1
- package/dist/tools/fs/pdf.d.ts +20 -10
- package/dist/tools/fs/pdf.js +19 -10
- package/dist/tools/fs/program-read-model.d.ts +68 -8
- package/dist/tools/fs/program-read-model.js +112 -33
- package/dist/tools/fs/program-read-model.rows.js +30 -10
- package/dist/tools/fs/read-deny-home.d.ts +25 -9
- package/dist/tools/fs/read-deny-home.js +28 -27
- package/dist/tools/fs/read-deny.d.ts +41 -11
- package/dist/tools/fs/read-deny.js +51 -5
- package/dist/tools/fs/safety.d.ts +4 -26
- package/dist/tools/fs/safety.js +10 -32
- package/dist/tools/fs/search.js +15 -10
- package/dist/tools/fs/shell-read-argv.d.ts +3 -2
- package/dist/tools/fs/shell-read-argv.js +118 -38
- package/dist/tools/fs/shell-read-establish.d.ts +5 -5
- package/dist/tools/fs/shell-read-establish.js +11 -61
- package/dist/tools/fs/shell-read-identity.js +6 -3
- package/dist/tools/fs/shell-read-judge.d.ts +13 -15
- package/dist/tools/fs/shell-read-judge.js +18 -4
- package/dist/tools/fs/shell-read-plan.d.ts +2 -2
- package/dist/tools/web.js +1 -1
- package/package.json +13 -1
- package/test/export-surface.snapshot.json +242 -99
- package/wire-changes/core@7.52.0.json +5859 -0
- package/dist/core/hook-seats.d.ts +0 -66
- package/dist/core/hook-seats.js +0 -37
- package/dist/prompt-assembly/packs/sema-default.d.ts +0 -2
- package/dist/prompt-assembly/packs/sema-default.js +0 -147
- package/dist/prompts/simple-sections.d.ts +0 -58
- package/dist/prompts/simple-sections.js +0 -43
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The run's usage account for the model calls made BESIDE the main loop — the compaction summarizer, the permission
|
|
3
|
+
* classifier, a mod's `$.model.complete`: the lanes, what a reply tells the account, the one door a lane books through, and the
|
|
4
|
+
* ONE function behind it. The lane table says which `Stats` line keeps a lane's cost besides `costMicroUsd` (every lane folds
|
|
5
|
+
* into the total — it is the budget coordinate and the reported figure); it is total over the lanes by its fence, so a fourth
|
|
6
|
+
* lane is a row here, not a second accounting function.
|
|
7
|
+
*/
|
|
8
|
+
import type { AssistantMessageDiagnostic, Model, Usage } from "../../internal/llm.js";
|
|
9
|
+
import { type ModelPricing } from "../pricing.js";
|
|
10
|
+
import type { AssertAllKeysHandled } from "../ask-origin.js";
|
|
11
|
+
import type { RunnerDeps, TaskSpec } from "../types.js";
|
|
12
|
+
import type { Stats } from "./assemble-result.js";
|
|
13
|
+
/** Whose model call it is: the compaction summarizer, the permission classifier, a mod's `$.model.complete`. */
|
|
14
|
+
export type SideCallLane = "compaction" | "classifier" | "mod";
|
|
15
|
+
/** The `Stats` line a lane's cost is also kept in: compaction is its own partition line; the classifier and the mods share the side-call line. */
|
|
16
|
+
export declare const SIDE_CALL_LANE_TOTAL: {
|
|
17
|
+
readonly compaction: "compactionMicroUsd";
|
|
18
|
+
readonly classifier: "sideCallMicroUsd";
|
|
19
|
+
readonly mod: "sideCallMicroUsd";
|
|
20
|
+
};
|
|
21
|
+
export type LaneTotalCoversEverySideCallLane = AssertAllKeysHandled<Exclude<SideCallLane, keyof typeof SIDE_CALL_LANE_TOTAL>>;
|
|
22
|
+
/** A side call's reply as the account reads it: the provider's usage (absent ⇒ none reported), the marks of what is unknown,
|
|
23
|
+
* and the diagnostics that say a degrading brain served it from its fallback (the model that ANSWERED is the one priced). */
|
|
24
|
+
export interface SideCallReply {
|
|
25
|
+
readonly usage?: Usage;
|
|
26
|
+
readonly usageMissing?: true;
|
|
27
|
+
readonly stopReason?: string;
|
|
28
|
+
readonly diagnostics?: AssistantMessageDiagnostic[];
|
|
29
|
+
}
|
|
30
|
+
/** The leg's one door onto the run's usage account: every side call's reply is booked through it, once. */
|
|
31
|
+
export type SideCallBook = (lane: SideCallLane, model: Model, reply: SideCallReply | undefined) => void;
|
|
32
|
+
/** The leg's seats a side call is priced and traced on — everything the call needs that `stats` does not carry. */
|
|
33
|
+
export interface SideCallAccount {
|
|
34
|
+
/** The run's telemetry: a call on an unpriced model taints `unpricedSpend`; the trace row goes to its tracer. */
|
|
35
|
+
telemetry: {
|
|
36
|
+
unpricedSpend: boolean;
|
|
37
|
+
readonly tracer: TaskSpec["tracer"];
|
|
38
|
+
readonly taskId: string;
|
|
39
|
+
};
|
|
40
|
+
/** The deployment's price table, read at the call (a swapped deps seat reaches legs already running). */
|
|
41
|
+
pricing: () => RunnerDeps["pricing"];
|
|
42
|
+
/** The telemetry lane's price-table door, consulted for every table a side call adopts. */
|
|
43
|
+
noteUnevaluablePriceTable: (p: ModelPricing) => void;
|
|
44
|
+
/** The deployment's model catalog: where the fallback model of a degraded reply is looked up. */
|
|
45
|
+
catalog: RunnerDeps["models"];
|
|
46
|
+
}
|
|
47
|
+
/** What one side call tells the account beyond its usage: the model it asked, the marks of what is unknown, and — when a
|
|
48
|
+
* degrading brain served the reply from another model — that model's id. */
|
|
49
|
+
export interface SideCallCall {
|
|
50
|
+
model: Model;
|
|
51
|
+
account: SideCallAccount;
|
|
52
|
+
usageMissing?: true;
|
|
53
|
+
stopReason?: string;
|
|
54
|
+
servedBy?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* THE one place a model call made beside the main loop reaches the run's account: the compaction summarizer, the
|
|
58
|
+
* permission classifier and a mod's `$.model.complete` all land here, each with its lane. The call is accounted exactly
|
|
59
|
+
* like a main-loop call (re-priced in core from the deployment's table and the model's cache family, integer
|
|
60
|
+
* micro-USD, never the brain's own `usage.cost`), so the reported total, the budget gate at the next turn end and the
|
|
61
|
+
* trace agree about what the run spent. Latency and first-token time are not modeled (there are no per-delta hooks here).
|
|
62
|
+
*
|
|
63
|
+
* `usage` absent — the reply reported none — marks the leg's stats `usageMissing` (the totals are then a lower bound:
|
|
64
|
+
* unknown is not free). A reply the brain itself marked `usageMissing` does the same for its zero-filled usage.
|
|
65
|
+
*/
|
|
66
|
+
export declare function recordSideCallUsage(stats: Stats, usage: Usage | undefined, lane: SideCallLane, call: SideCallCall): void;
|
|
67
|
+
/** The leg's door: `recordSideCallUsage` bound to the leg's `stats` and account, reading what the reply itself says (its marks, and who served it). */
|
|
68
|
+
export declare function sideCallBookOf(stats: Stats, account: SideCallAccount): SideCallBook;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { readDegradation } from "../../brain/degrading.js";
|
|
2
|
+
import { isModelPriced, modelCostToPricing } from "../pricing.js";
|
|
3
|
+
import { emitTrace } from "../trace.js";
|
|
4
|
+
import { cacheFamilyOf, usageCostMicroUsd } from "./usage-accounting.js";
|
|
5
|
+
export const SIDE_CALL_LANE_TOTAL = {
|
|
6
|
+
compaction: "compactionMicroUsd",
|
|
7
|
+
classifier: "sideCallMicroUsd",
|
|
8
|
+
mod: "sideCallMicroUsd",
|
|
9
|
+
};
|
|
10
|
+
function catalogModel(id, catalog) {
|
|
11
|
+
if (catalog === undefined)
|
|
12
|
+
return undefined;
|
|
13
|
+
for (const m of Object.values(catalog))
|
|
14
|
+
if (m.id === id)
|
|
15
|
+
return m;
|
|
16
|
+
return Object.hasOwn(catalog, id) ? catalog[id] : undefined;
|
|
17
|
+
}
|
|
18
|
+
export function recordSideCallUsage(stats, usage, lane, call) {
|
|
19
|
+
if (usage === undefined || call.usageMissing === true)
|
|
20
|
+
stats.usageMissing = true;
|
|
21
|
+
if (usage === undefined)
|
|
22
|
+
return;
|
|
23
|
+
const { model: requested, account } = call;
|
|
24
|
+
const pricing = account.pricing();
|
|
25
|
+
const served = call.servedBy === undefined ? requested : catalogModel(call.servedBy, account.catalog);
|
|
26
|
+
const modelId = served?.id ?? call.servedBy ?? requested.id;
|
|
27
|
+
const price = pricing?.[modelId] ?? modelCostToPricing(served?.cost);
|
|
28
|
+
const priced = served !== undefined ? isModelPriced(served, pricing) : pricing?.[modelId] !== undefined;
|
|
29
|
+
if (!priced)
|
|
30
|
+
account.telemetry.unpricedSpend = true;
|
|
31
|
+
account.noteUnevaluablePriceTable(price);
|
|
32
|
+
const family = served !== undefined ? cacheFamilyOf(served) : "input-excludes-cached";
|
|
33
|
+
const { totalInputTokens, uncachedInputTokens, costMicroUsd } = usageCostMicroUsd(family, usage, price);
|
|
34
|
+
stats.tokens += usage.totalTokens || 0;
|
|
35
|
+
stats.promptTokens += uncachedInputTokens;
|
|
36
|
+
stats.totalInputTokens += totalInputTokens;
|
|
37
|
+
stats.cachedTokens += usage.cacheRead || 0;
|
|
38
|
+
stats.cacheWriteTokens += usage.cacheWrite || 0;
|
|
39
|
+
stats.outputTokens += usage.output || 0;
|
|
40
|
+
stats.costMicroUsd += costMicroUsd;
|
|
41
|
+
const total = SIDE_CALL_LANE_TOTAL[lane];
|
|
42
|
+
stats[total] = (stats[total] ?? 0) + costMicroUsd;
|
|
43
|
+
emitTrace(account.telemetry.tracer, () => ({
|
|
44
|
+
kind: "brain.call", version: 1, taskId: account.telemetry.taskId, model: modelId, ...(served !== undefined ? { provider: served.provider } : {}),
|
|
45
|
+
promptTokens: uncachedInputTokens, totalInputTokens, completionTokens: usage.output || 0,
|
|
46
|
+
cacheRead: usage.cacheRead || 0, cacheWrite: usage.cacheWrite || 0,
|
|
47
|
+
latencyMs: 0, ...(priced ? { costMicroUsd } : {}), ...(call.stopReason !== undefined ? { stopReason: call.stopReason } : {}), ts: Date.now(),
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
export function sideCallBookOf(stats, account) {
|
|
51
|
+
return (lane, model, reply) => {
|
|
52
|
+
const degradedTo = readDegradation(reply)?.to;
|
|
53
|
+
recordSideCallUsage(stats, reply?.usage, lane, {
|
|
54
|
+
model,
|
|
55
|
+
account,
|
|
56
|
+
...(reply?.usageMissing === true ? { usageMissing: true } : {}),
|
|
57
|
+
...(typeof reply?.stopReason === "string" ? { stopReason: reply.stopReason } : {}),
|
|
58
|
+
...(degradedTo !== undefined && degradedTo !== model.id ? { servedBy: degradedTo } : {}),
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
}
|
|
@@ -15,15 +15,16 @@ export function streamHaltVerbs(input) {
|
|
|
15
15
|
throw haltRefused("the task is not running");
|
|
16
16
|
const apply = () => {
|
|
17
17
|
const abortOwnedBeforeHalt = h.abortController.signal.aborted;
|
|
18
|
-
const receipt = h.harness.halt();
|
|
18
|
+
const receipt = h.loop.ended ? { turnCut: false, accepted: false } : h.harness.halt();
|
|
19
|
+
h.loop.callerStop.stop();
|
|
19
20
|
if (receipt.accepted && !abortOwnedBeforeHalt) {
|
|
20
21
|
h.loop.userHalted = true;
|
|
21
22
|
}
|
|
22
23
|
else if (!h.loop.userHalted) {
|
|
23
24
|
deliverEngineNotice(runner.deps.onNotice, {
|
|
24
25
|
code: "task.halt_unconsumed",
|
|
25
|
-
message: "a user halt arrived while the run was already ending for its own reason:
|
|
26
|
-
"
|
|
26
|
+
message: "a user halt arrived while the run was already ending for its own reason: it cut no turn and stopped no " +
|
|
27
|
+
"boundary — the run's own ending stands, and the result will not carry haltedByUser for this halt.",
|
|
27
28
|
detail: {
|
|
28
29
|
sessionId: h.sessionId,
|
|
29
30
|
runId: h.runId,
|
|
@@ -47,33 +48,27 @@ export function streamHaltVerbs(input) {
|
|
|
47
48
|
}
|
|
48
49
|
return { turnCut: receipt.turnCut };
|
|
49
50
|
};
|
|
50
|
-
try {
|
|
51
|
-
if (live.resultValue !== undefined || h.loop.ended)
|
|
52
|
-
throw haltRefused("the task is no longer running");
|
|
53
|
-
return apply();
|
|
54
|
-
}
|
|
55
|
-
catch (e) {
|
|
56
|
-
if (!(e instanceof Error && e.code === "invalid_state"))
|
|
57
|
-
throw e;
|
|
58
|
-
}
|
|
59
51
|
const birthDeadline = Date.now() + READY_TIMEOUT_MS;
|
|
60
|
-
while (live.resultValue === undefined
|
|
52
|
+
while (live.resultValue === undefined) {
|
|
61
53
|
try {
|
|
62
54
|
return apply();
|
|
63
55
|
}
|
|
64
|
-
catch (
|
|
65
|
-
if (!(
|
|
66
|
-
throw
|
|
56
|
+
catch (e) {
|
|
57
|
+
if (!(e instanceof Error && e.code === "invalid_state"))
|
|
58
|
+
throw e;
|
|
67
59
|
}
|
|
60
|
+
if (Date.now() >= birthDeadline)
|
|
61
|
+
throw haltRefused("the task is no longer running");
|
|
68
62
|
await new Promise((r) => setTimeout(r, 10));
|
|
69
63
|
}
|
|
70
|
-
throw haltRefused("the task
|
|
64
|
+
throw haltRefused("the task has already finished");
|
|
71
65
|
};
|
|
72
66
|
const destroy = () => (destroyOnce ??= (async () => {
|
|
73
67
|
const h = live.handle ?? (await orTimeout(ready));
|
|
74
68
|
if (h) {
|
|
75
69
|
h.abortController.abort();
|
|
76
70
|
void h.harness.abort();
|
|
71
|
+
h.loop.callerStop.stop();
|
|
77
72
|
}
|
|
78
73
|
await orTimeout(run.catch(() => { }));
|
|
79
74
|
await reapSuspended();
|
|
@@ -145,12 +145,15 @@ export function streamLifecycleVerbs(input) {
|
|
|
145
145
|
const h = live.handle ?? (await orTimeout(ready));
|
|
146
146
|
if (!h)
|
|
147
147
|
throw interruptRefused("the task is not running");
|
|
148
|
-
if (live.resultValue !== undefined
|
|
149
|
-
throw interruptRefused("the task
|
|
150
|
-
if (!h.abortController.signal.aborted)
|
|
148
|
+
if (live.resultValue !== undefined)
|
|
149
|
+
throw interruptRefused("the task has already finished");
|
|
150
|
+
if (!h.loop.ended && !h.abortController.signal.aborted)
|
|
151
151
|
h.loop.userInterrupted = true;
|
|
152
|
-
h.
|
|
153
|
-
|
|
152
|
+
if (!h.loop.ended) {
|
|
153
|
+
h.abortController.abort();
|
|
154
|
+
void h.harness.abort();
|
|
155
|
+
}
|
|
156
|
+
h.loop.callerStop.stop();
|
|
154
157
|
};
|
|
155
158
|
return { notify, optOutMemoryCapture, reconnectMcpServer, compact, detach, interrupt };
|
|
156
159
|
}
|
|
@@ -3,7 +3,7 @@ import { type TaskEvent, type TaskSpec, type TaskStream } from "../types.js";
|
|
|
3
3
|
import type { LiveHandle, RunInternals, RunnerDepsSeat, TaskStreamLiveSeat } from "./contracts.js";
|
|
4
4
|
import { type SteerReplayRecord, type SteerReplayRefusalDetail } from "../steer-replay.js";
|
|
5
5
|
export interface StreamSteerVerbInput {
|
|
6
|
-
/** borrowed-readonly — the task spec (
|
|
6
|
+
/** borrowed-readonly — the task spec (`principal`, `taskId`). */
|
|
7
7
|
spec: TaskSpec;
|
|
8
8
|
/** borrowed-readonly — the trusted run-internals channel (the spawning tool id the ledger frame carries). */
|
|
9
9
|
internals: RunInternals | undefined;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { uuidv7 } from "../../internal/harness.js";
|
|
2
2
|
import { snapshotActorAssertion } from "../../internal/llm.js";
|
|
3
3
|
import { MAX_STEER_INPUT_ID_CHARS } from "../checkpoint-store.js";
|
|
4
|
-
import { formatHookFeedback
|
|
4
|
+
import { formatHookFeedback } from "../hooks.js";
|
|
5
|
+
import { classicEventBase, failedHandlerClause, screenUserPrompt } from "../mods/stations.js";
|
|
5
6
|
import { buildHumanInputEvent, frameMidTurnUserInput, projectHumanInput } from "../human-input-projection.js";
|
|
6
7
|
import { injectionLaneOf, isSystemInjectionPriority, steerPriorityOf, SYSTEM_INJECTION_PRIORITIES } from "../task-notification.js";
|
|
7
8
|
import { deliverEngineNotice } from "../types.js";
|
|
8
9
|
import { inlineUntrusted, sanitizeUntrustedText } from "../untrusted-text.js";
|
|
9
10
|
import { announceAcceptance, armAcceptance, nextHumanInputSeq } from "./steer-admission.js";
|
|
10
11
|
import { steerReplayRefusal } from "../steer-replay.js";
|
|
11
|
-
import { asThrownError } from "../thrown-value.js";
|
|
12
12
|
export function streamSteerVerb(input) {
|
|
13
13
|
const { spec, internals, queue, acceptedSteerInputs, live, ready, orTimeout, readyTimeoutMs: READY_TIMEOUT_MS, steeringError, runner } = input;
|
|
14
14
|
let steerChain = Promise.resolve();
|
|
@@ -94,42 +94,24 @@ export function streamSteerVerb(input) {
|
|
|
94
94
|
if (live.resultValue !== undefined || h.loop.ended)
|
|
95
95
|
throw steeringError("the task is no longer running");
|
|
96
96
|
if (mintsAFrame) {
|
|
97
|
-
const screen = (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
catch (hookErr) {
|
|
117
|
-
if (hookErr instanceof Error && hookErr.code === "steering.blocked_by_hook")
|
|
118
|
-
throw hookErr;
|
|
119
|
-
const err = asThrownError(hookErr);
|
|
120
|
-
try {
|
|
121
|
-
runner.deps.onError?.(err, { phase: "hook", sessionId: h.sessionId });
|
|
122
|
-
}
|
|
123
|
-
catch {
|
|
124
|
-
}
|
|
125
|
-
throw steeringError(`the deployment's userPromptSubmit hook crashed while screening this steering input (${inlineUntrusted(err.message)}); the input was NOT accepted (fail-closed)`, "steering.blocked_by_hook");
|
|
126
|
-
}
|
|
127
|
-
if (decision?.block !== undefined && decision.block !== "") {
|
|
128
|
-
throw steeringError(`the deployment's userPromptSubmit hook blocked this steering input: ${inlineUntrusted(decision.block)}`, "steering.blocked_by_hook");
|
|
129
|
-
}
|
|
130
|
-
if (decision?.additionalContext !== undefined && decision.additionalContext !== "") {
|
|
131
|
-
payload = `${formatHookFeedback(decision.additionalContext, h.reminderMark)}\n\n${payload}`;
|
|
132
|
-
}
|
|
97
|
+
const screen = await screenUserPrompt(h.modBus, {
|
|
98
|
+
...classicEventBase(h.hookIdentity, h.permissionMode.observed),
|
|
99
|
+
prompt: text,
|
|
100
|
+
source: "steer",
|
|
101
|
+
inputId: effectiveInputId,
|
|
102
|
+
...(actor !== undefined ? { actor: snapshotActorAssertion(actor) } : {}),
|
|
103
|
+
}, h.abortController.signal);
|
|
104
|
+
if (screen?.kind === "aborted") {
|
|
105
|
+
throw steeringError(`the task was cancelled while the deployment's userPromptSubmit hook was still screening this steering input; the input was NOT accepted (fail-closed)`, "steering.blocked_by_hook");
|
|
106
|
+
}
|
|
107
|
+
if (screen?.kind === "failed") {
|
|
108
|
+
throw steeringError(`the deployment's userPromptSubmit hook ${failedHandlerClause(screen)} while screening this steering input; the input was NOT accepted (fail-closed)`, "steering.blocked_by_hook");
|
|
109
|
+
}
|
|
110
|
+
if (screen?.block !== undefined && screen.block !== "") {
|
|
111
|
+
throw steeringError(`the deployment's userPromptSubmit hook blocked this steering input: ${inlineUntrusted(screen.block)}`, "steering.blocked_by_hook");
|
|
112
|
+
}
|
|
113
|
+
if (screen?.additionalContext !== undefined && screen.additionalContext !== "") {
|
|
114
|
+
payload = `${formatHookFeedback(screen.additionalContext, h.reminderMark)}\n\n${payload}`;
|
|
133
115
|
}
|
|
134
116
|
}
|
|
135
117
|
const injectFramed = async () => {
|
|
@@ -1,29 +1,82 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THE judgment of every tool-name list one prepared task receives — the run's own selector lists (`TaskSpec.allowTools` /
|
|
3
|
-
* `TaskSpec.excludeTools
|
|
4
|
-
* carries (`TaskSpec.agents`), and the definitions and tool-level lists a mounted
|
|
5
|
-
* — the engine's built-ins are not judged; only a tool a deployment mounted (depth 0)
|
|
6
|
-
* a value that is not a list, an entry that is not a string
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
3
|
+
* `TaskSpec.excludeTools`; when the delegation lane spawned it, its spawning run judged them where they were mounted, and the evidence
|
|
4
|
+
* it handed down spares them here), the definitions it carries (`TaskSpec.agents`), and the definitions and tool-level lists a mounted
|
|
5
|
+
* delegation tool carries (the `authored` faces — the engine's built-ins are not judged; only a tool a deployment mounted (depth 0)
|
|
6
|
+
* publishes them). One rule for both sides: a value that is not a list, an entry that is not a string, a spelling that can name no tool
|
|
7
|
+
* and a spelling that is another spelling of a tool the list's universe carries (`BASH` beside `Bash`) are REFUSED; an entry whose
|
|
8
|
+
* name no tool of the universe answers to (a server this deployment does not declare, a misspelt name) is KEPT as written — the
|
|
9
|
+
* selector reads every entry by name, so a denied one hides a tool of that name whenever one is mounted and an allowed one admits
|
|
10
|
+
* it — and told to the host, one account per entry. And one contradiction, judged on every leg: a denylist (the run's own or one
|
|
11
|
+
* of its ceiling) that reaches a tool the leg's kind relies on (the catalog's protocol column) is refused — neither a silently
|
|
12
|
+
* ignored deny nor a silently crippled leg.
|
|
12
13
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
14
|
+
* Two kinds of list, two universes. A ROOT-facing list bounds the tools of the run that holds it: the run's own lists (also the
|
|
15
|
+
* ceiling of every child), the policy name audit and the session-rules write gate ask the same question of it. Its universe is the
|
|
16
|
+
* run's roster before the valve, the caller's own tools, every tool the catalog describes (`rootFacingToolNames`) and the exact
|
|
17
|
+
* names of the pools its reachable delegation tools declare and can list — and another spelling of a carried name is always refused,
|
|
18
|
+
* whatever a delegation tool injects per spawn. A CHILD-facing list bounds a child that does not exist yet: a definition's two
|
|
19
|
+
* lists and a delegation tool's two lists. Its universe is the pool the delegation tool that hands the child declares (names, aliases, the
|
|
20
|
+
* declared `extraToolNames`, and the tool's own name: the child is handed the tool again, rebuilt, while its depth allows) and the catalog — not the
|
|
21
|
+
* spawning run's roster, which the child is not handed; every definition is judged against each reachable delegation tool's own pool; a delegation tool whose factory
|
|
22
|
+
* injects tools per spawn with no declared roster lists none of its pool, so there another spelling is kept and told (it may be one
|
|
23
|
+
* of that pool's own). Only the delegation tools the run's own selector leaves are read, in both: a tool it takes out hands nobody
|
|
24
|
+
* anything. A layer a run inherits (its ceiling) is not asked again: the run that wrote it asked its own universe, and a layer a
|
|
25
|
+
* checkpoint row restored is read for its spelling before the claim. The same goes for the lists a delegation tool hands its child
|
|
26
|
+
* (the child's own): when the spawning run read them against a pool it could list, its evidence spares them in the child. When it
|
|
27
|
+
* could not (the keep above), the child is the run whose roster can answer — it refuses another spelling of a tool of its own
|
|
28
|
+
* universe (its roster, the catalog, the pools it can list, and the delegation tool that spawned it, under its exact mounted name: a name
|
|
29
|
+
* of the child's lineage, mounted at its depth or not — an exact hit of that name is the tool's own, whatever else reads as a twin of it),
|
|
30
|
+
* and the spawning run already told what it kept, so nothing is told a second time.
|
|
18
31
|
*
|
|
19
32
|
* Throws `config.tool_face_control` for the run's own lists and the protocol contradiction, `config.agent.unknown_tool` for a
|
|
20
|
-
* definition's or a delegation tool's lists
|
|
33
|
+
* definition's or a delegation tool's lists (`detail.reason`: `unknown_name` for a spelling no tool name can have, `near_miss` for
|
|
34
|
+
* another spelling of a tool of the universe) — synchronous, like the phase that calls it.
|
|
21
35
|
*/
|
|
22
36
|
import type { AgentTool } from "../../internal/harness.js";
|
|
23
37
|
import { type ProtocolId } from "../protocol-table.js";
|
|
24
|
-
import type { ToolLegKind, ToolSelectorLayer } from "../tool-face.js";
|
|
38
|
+
import type { ToolLegKind, ToolSelector, ToolSelectorLayer } from "../tool-face.js";
|
|
39
|
+
import { type ConstraintChainEntry } from "../tool-policy.js";
|
|
25
40
|
import type { TaskSpec } from "../types.js";
|
|
26
|
-
import type {
|
|
41
|
+
import type { CheckpointErrorReason } from "../checkpoint-store.js";
|
|
42
|
+
import type { AnnounceOnceSink, RunInternals } from "./contracts.js";
|
|
43
|
+
/** What the delegation tools a run mounts hand their children (the pools of {@link delegationPoolReading}). */
|
|
44
|
+
interface DelegationPoolReading {
|
|
45
|
+
readonly tools: NonNullable<TaskSpec["tools"]>;
|
|
46
|
+
readonly names: Set<string>;
|
|
47
|
+
readonly complete: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* THE judgment of the name a delegation tool is mounted under: the name it declares for itself (`createSubagentTool({ name })`, the default
|
|
51
|
+
* name when none is given), which the factory binds to the `execute` that carries the delegation out ({@link declaredDelegationNameOf}) —
|
|
52
|
+
* so a copy of the tool, a product of it, a stripped or shell copy all still say it. A delegation tool is ONE tool with ONE name: the lists
|
|
53
|
+
* of its agent definitions, the copy of it a child is handed, the rebuilt copy a run's own definitions produce and the prompt text it speaks
|
|
54
|
+
* all say the declared name, while the roster, the pool reading and the model's call say the mounted one. A mount whose `name` differs from
|
|
55
|
+
* the declared one makes the tool answer to two names — a denied list that names one of them is read against the other — so it is REFUSED,
|
|
56
|
+
* naming both names and the two ways to one name. This is the sentence of that refusal for the first such entry of the rosters given — or
|
|
57
|
+
* `undefined`; it never throws (an entry whose members cannot be read is not judged here: the roster snapshot refuses it). A tool the
|
|
58
|
+
* factory did not make, and a roster that is no list (the doors' to judge), are not read.
|
|
59
|
+
*/
|
|
60
|
+
export declare function renamedDelegationMountSentence(...rosters: unknown[]): string | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* The refusal of a renamed delegation mount at prepare (`config.tool_face_control`, `detail.reason: "renamed_mount"`), asked of every roster
|
|
63
|
+
* the run holds: the one the caller mounted and the one the per-task rebuild (a function the caller's tool supplies) handed back. A resume
|
|
64
|
+
* asks the roster it is handed once more before the claim (this same function, through the resume screen's config-refusal channel), so the row stays pending.
|
|
65
|
+
*/
|
|
66
|
+
export declare function refuseRenamedDelegationMounts(...rosters: unknown[]): void;
|
|
67
|
+
/**
|
|
68
|
+
* THE reading of what the delegation tools a run mounts hand their children, read after the run's own selector: only a delegation
|
|
69
|
+
* tool the selector leaves (`selector.admits`) counts — one it takes out hands nobody anything, and neither its pool names nor an
|
|
70
|
+
* unlistable pool of it belong to any universe. The tools themselves, every pool tool's name and alias (a declared `extraToolNames`
|
|
71
|
+
* roster included), and whether every one of those pools can be listed: a delegation tool whose factory injects tools per spawn with no
|
|
72
|
+
* declared roster has no listable pool (the static `tools` it was given included), so a name outside the listed ones may be one of its
|
|
73
|
+
* own. This is the one place the pool side of both universes is defined; the list judgment below and the policy name audit ask it.
|
|
74
|
+
*/
|
|
75
|
+
export declare function delegationPoolReading(callerTools: NonNullable<TaskSpec["tools"]>, selector: Pick<ToolSelector, "admits">): DelegationPoolReading;
|
|
76
|
+
/** The arms of this module's `config.tool_face_control` refusal that a resume carries before the claim as `detail.reason` of a `checkpoint.config_refused` — the same words
|
|
77
|
+
* ({@link CheckpointErrorReason}): a list the row recorded that is not a list / has a member that is not a string / has a spelling no tool name can have / is not in the
|
|
78
|
+
* spelling a row records, a record that is not one, a renamed delegation mount, an occupied table of declared names. */
|
|
79
|
+
export type PersistedToolFaceReason = Extract<CheckpointErrorReason, "not_a_list" | "not_a_string" | "unknown_name" | "unsupported_pattern" | "invalid_record" | "renamed_mount" | "registry_occupied">;
|
|
27
80
|
/**
|
|
28
81
|
* The names a definition's denied-tools entries stand for, for a lane that has neither a roster nor a notice sink at the point
|
|
29
82
|
* it builds its own policy (a workflow leg's agentType): each entry is read by the one reading, so `Tool(content)` denies the
|
|
@@ -32,6 +85,22 @@ import type { AnnounceOnceSink } from "./contracts.js";
|
|
|
32
85
|
* leg's roster and a sink; the leg's own policy-name audit is what reads them.
|
|
33
86
|
*/
|
|
34
87
|
export declare function deniedToolNamesOf(where: string, value: unknown): string[];
|
|
88
|
+
/**
|
|
89
|
+
* THE read-back of the tool names a checkpoint row carries, before the claim: the ceiling the resumed leg will run under when it is
|
|
90
|
+
* the row's (`ceiling`: absent when a live seat hands one) — each layer read by {@link readSelectorLayer} as a recorded layer — and
|
|
91
|
+
* the frozen policy chain (`inheritedGate.constraintChain`; each component's members {@link projectionToolNames} names), whose
|
|
92
|
+
* replay matches a name as recorded, which is the rule syntax's reading only for a name in its canonical spelling. The refusal
|
|
93
|
+
* sentence of the first entry neither reading may be applied to, naming it and where it sits, or `undefined`; a member that is not
|
|
94
|
+
* a list, or an entry that is not a string, is named by its type only. And the delegation tool the row records as having written the
|
|
95
|
+
* leg's own lists (`ownLists`, absent when a live seat hands one): it joins the universe those lists are asked of, so it must be a name.
|
|
96
|
+
* The refusal is its sentence and the arm it is ({@link CheckpointErrorReason}); {@link refusePersistedToolNames} throws it as prepare's own refusal.
|
|
97
|
+
*/
|
|
98
|
+
export declare function persistedToolNamesRefusal(ceiling: unknown, chain: readonly ConstraintChainEntry[] | undefined, ownLists?: unknown): {
|
|
99
|
+
readonly message: string;
|
|
100
|
+
readonly reason: PersistedToolFaceReason;
|
|
101
|
+
} | undefined;
|
|
102
|
+
/** {@link persistedToolNamesRefusal} as prepare's own refusal (`config.tool_face_control`, the arm as `detail.reason`): what a resume's pre-claim screen throws through the resume's one refusal channel. */
|
|
103
|
+
export declare function refusePersistedToolNames(ceiling: unknown, chain: readonly ConstraintChainEntry[] | undefined, ownLists?: unknown): void;
|
|
35
104
|
/**
|
|
36
105
|
* The upstream judgment of a run's own lists, when it holds: the evidence digest the spawning run handed down (live) or the resumed row
|
|
37
106
|
* recorded, returned only when it equals the digest of the lists this prepare read — the evidence is bound to the lists it was minted
|
|
@@ -41,6 +110,18 @@ export declare function boundToolListsJudgment(evidence: string | undefined, own
|
|
|
41
110
|
readonly allow: readonly string[] | undefined;
|
|
42
111
|
readonly exclude: readonly string[] | undefined;
|
|
43
112
|
}): string | undefined;
|
|
113
|
+
/**
|
|
114
|
+
* The record of the delegation tool that wrote a leg's own lists, held only for the lists it wrote: the live seat's (the delegation lane
|
|
115
|
+
* mints it with the digest of exactly the lists it handed the child) or, with none, the resumed row's. A prepare whose own lists digest to
|
|
116
|
+
* the record's `lists` keeps it — they are the lists that tool wrote, so their refusals name it and its name is a name of the leg's
|
|
117
|
+
* lineage; any other lists (a resume whose host handed another table) are the host's own `TaskSpec` seats, and the leg asks them as such
|
|
118
|
+
* with no lineage name cleared. A record that is not one (a host that set the live seat itself) refuses the leg, as a row's does before the
|
|
119
|
+
* claim: `config.tool_face_control`, `detail.reason: "invalid_record"`.
|
|
120
|
+
*/
|
|
121
|
+
export declare function boundOwnToolLists(record: unknown, own: {
|
|
122
|
+
readonly allow: readonly string[] | undefined;
|
|
123
|
+
readonly exclude: readonly string[] | undefined;
|
|
124
|
+
}): RunInternals["ownToolLists"];
|
|
44
125
|
export interface RunToolListsInput {
|
|
45
126
|
/** borrowed-readonly — the REBOUND spec: `agents` (the task's definitions) and `tools` (the caller's tools and the mounted delegation tools). */
|
|
46
127
|
spec: Pick<TaskSpec, "agents" | "tools">;
|
|
@@ -61,15 +142,33 @@ export interface RunToolListsInput {
|
|
|
61
142
|
/** borrowed-readonly — every layer of the run's selector (the ceiling, then its own) and the kinds of leg it is. */
|
|
62
143
|
layers: readonly ToolSelectorLayer[];
|
|
63
144
|
legs: readonly ToolLegKind[];
|
|
64
|
-
/** True ⇔ the spawning run's prepare judged exactly these own lists where they were mounted
|
|
65
|
-
*
|
|
145
|
+
/** True ⇔ the spawning run's prepare judged exactly these own lists where they were mounted, against a pool it could list (as the
|
|
146
|
+
* child-facing lists of the delegation tool or definition that wrote them) — the evidence digest it handed down (live, or recorded
|
|
147
|
+
* on the resumed row) equals the digest of the lists this prepare read ({@link boundToolListsJudgment}). They are then not judged
|
|
148
|
+
* again: neither told nor refused. */
|
|
66
149
|
judgedUpstream: boolean;
|
|
67
|
-
/**
|
|
68
|
-
*
|
|
69
|
-
|
|
150
|
+
/** True ⇔ a delegation lane spawned this leg inside a prepared run, which read these own lists against a pool it could not list: it
|
|
151
|
+
* kept what it could not judge and told it (no evidence digest was handed down). They are judged here, against this leg's roster,
|
|
152
|
+
* and refused as any own list is — but nothing is told a second time. Absent ⇒ nobody told. */
|
|
153
|
+
toldUpstream?: boolean;
|
|
154
|
+
/** The delegation tool (and the agent definition) whose lists the run's own are, when the run that spawned it wrote them
|
|
155
|
+
* (`RunInternals.ownToolLists`); absent ⇒ the run's own `TaskSpec` seats. Its sentence is {@link delegationListWhere}; its tool name is
|
|
156
|
+
* a name of the leg's lineage, so the run's own lists are asked of a universe that carries it. */
|
|
157
|
+
ownBy: RunInternals["ownToolLists"];
|
|
70
158
|
/** borrowed-readonly — the once-per-session ledger whose operator sink carries the notices. */
|
|
71
159
|
onceLedger: Pick<AnnounceOnceSink, "onError">;
|
|
72
160
|
/** borrowed-readonly — the acquired session's id (operator-line context). */
|
|
73
161
|
sessionId: string;
|
|
74
162
|
}
|
|
75
163
|
export declare function judgeRunToolLists(input: RunToolListsInput): void;
|
|
164
|
+
/**
|
|
165
|
+
* THE judgment of a tool ceiling a HOST wrote (`RunWorkflowOptions.toolCeiling`), asked of one workflow agent's spec before it launches.
|
|
166
|
+
* A ceiling a prepared run hands down was judged where it was written and is not asked again; one a host wrote was judged nowhere, and
|
|
167
|
+
* it bounds the tools of every agent that holds it — a root-facing list: it is read against the catalog, the agent's caller tools and the
|
|
168
|
+
* listable pools of the delegation tools the agent's own selector leaves (the layers above the host's — a launching run's —, the host's
|
|
169
|
+
* and the agent's own lists together: a tool they take out hands nobody anything), and another spelling of one of those is refused (`config.tool_face_control`,
|
|
170
|
+
* `detail.reason: "near_miss"`) rather than kept as a deny that hides nothing. A name no tool answers to stays kept (a tool of that
|
|
171
|
+
* name may be mounted later), unannounced: the host wrote no spec this leg could name the list of.
|
|
172
|
+
*/
|
|
173
|
+
export declare function judgeHostToolCeiling(layers: readonly ToolSelectorLayer[], agent: Pick<TaskSpec, "tools" | "allowTools" | "excludeTools">, above?: readonly ToolSelectorLayer[]): void;
|
|
174
|
+
export {};
|