@sema-agent/core 5.19.0 → 5.21.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 +102 -4
- package/dist/agents/agent-definition.d.ts +7 -0
- package/dist/agents/agent-transcript-tool.d.ts +30 -0
- package/dist/agents/builtin-agents.d.ts +60 -0
- package/dist/agents/cascade.d.ts +107 -0
- package/dist/agents/cumulative-stats.d.ts +56 -0
- package/dist/agents/observer.d.ts +162 -0
- package/dist/agents/peer-admission.d.ts +95 -0
- package/dist/agents/repair-loop.d.ts +226 -0
- package/dist/agents/retain-ledger.d.ts +141 -0
- package/dist/agents/roster-store.d.ts +105 -0
- package/dist/agents/roster-store.js +3 -0
- package/dist/agents/send-message-tool.d.ts +92 -0
- package/dist/agents/session-util.d.ts +5 -0
- package/dist/agents/subagent-steps.d.ts +66 -0
- package/dist/agents/subagent.d.ts +600 -0
- package/dist/agents/suspend-guard.d.ts +29 -0
- package/dist/agents/teacher.d.ts +75 -0
- package/dist/agents/team.d.ts +120 -1
- package/dist/agents/tool-filter.d.ts +34 -0
- package/dist/agents/verify.d.ts +198 -0
- package/dist/bench/metrics.d.ts +455 -0
- package/dist/brain/anthropic.d.ts +30 -0
- package/dist/brain/circuit-breaker.d.ts +33 -0
- package/dist/brain/circuit-breaker.js +14 -3
- package/dist/brain/context-overflow.d.ts +60 -3
- package/dist/brain/degrading.d.ts +67 -0
- package/dist/brain/errors.d.ts +42 -0
- package/dist/brain/failover.d.ts +15 -0
- package/dist/brain/media-degrade.d.ts +39 -0
- package/dist/brain/model-presets.d.ts +31 -0
- package/dist/brain/open-responses.d.ts +19 -0
- package/dist/brain/openai.d.ts +46 -0
- package/dist/brain/reasoning.d.ts +106 -1
- package/dist/brain/repetition.d.ts +83 -0
- package/dist/brain/request-params.d.ts +56 -0
- package/dist/brain/retry.d.ts +46 -0
- package/dist/brain/routing.d.ts +12 -0
- package/dist/brain/status-sink.d.ts +30 -1
- package/dist/brain/stream-engine.d.ts +147 -0
- package/dist/brain/stream-shared.d.ts +34 -0
- package/dist/brain/terminal-cause.d.ts +31 -0
- package/dist/brain/timeout.d.ts +108 -0
- package/dist/brain/timeout.js +11 -0
- package/dist/brain/tool-call-id.d.ts +20 -0
- package/dist/brain/tool-call-repair.d.ts +13 -0
- package/dist/config/catalog.d.ts +47 -0
- package/dist/config/defaults.d.ts +33 -0
- package/dist/core/a2a-task-state.d.ts +53 -0
- package/dist/core/a2a.d.ts +51 -0
- package/dist/core/arg-summary.d.ts +62 -0
- package/dist/core/ask-question.d.ts +272 -2
- package/dist/core/auto-compaction.d.ts +467 -0
- package/dist/core/auto-compaction.js +20 -6
- package/dist/core/auto-mode-prompt-assets.d.ts +8 -0
- package/dist/core/auto-mode-prompt.d.ts +27 -0
- package/dist/core/auto-mode.d.ts +54 -3
- package/dist/core/auto-promote.d.ts +100 -0
- package/dist/core/background-agent-store.d.ts +293 -0
- package/dist/core/background-agent-store.js +5 -0
- package/dist/core/background-shell.d.ts +110 -0
- package/dist/core/cache-break-detector.d.ts +34 -0
- package/dist/core/canonical-json.d.ts +57 -0
- package/dist/core/checkpoint-store.d.ts +1574 -16
- package/dist/core/compliance.d.ts +30 -0
- package/dist/core/consolidate-scope.d.ts +75 -0
- package/dist/core/context-edit.d.ts +99 -0
- package/dist/core/context-guard.d.ts +46 -0
- package/dist/core/exec-gate.d.ts +44 -0
- package/dist/core/exec-output-tail.d.ts +61 -0
- package/dist/core/file-snapshot-store.d.ts +104 -0
- package/dist/core/fs-write-gate-policy.d.ts +36 -0
- package/dist/core/git-worktree-env.d.ts +31 -0
- package/dist/core/governance-codes.d.ts +19 -0
- package/dist/core/hooks.d.ts +609 -1
- package/dist/core/human-input-projection.d.ts +37 -0
- package/dist/core/human-input-projection.js +13 -0
- package/dist/core/image-downsample.d.ts +74 -0
- package/dist/core/locked-config.d.ts +37 -0
- package/dist/core/lsp-diagnostics.d.ts +77 -0
- package/dist/core/lsp-protocol.d.ts +29 -0
- package/dist/core/lsp-session.d.ts +60 -1
- package/dist/core/lsp.d.ts +150 -1
- package/dist/core/mailbox-store.d.ts +57 -0
- package/dist/core/mailbox-store.js +2 -0
- package/dist/core/mcp.d.ts +385 -0
- package/dist/core/mcp.js +58 -11
- package/dist/core/media-byte-cap.d.ts +21 -0
- package/dist/core/memory-admission.d.ts +71 -0
- package/dist/core/memory-engine/content-origin.d.ts +64 -0
- package/dist/core/memory-engine/data-plane.d.ts +43 -0
- package/dist/core/memory-engine/dual-root.d.ts +24 -0
- package/dist/core/memory-engine/engine.d.ts +230 -0
- package/dist/core/memory-engine/engine.js +103 -35
- package/dist/core/memory-engine/file-backend.d.ts +155 -0
- package/dist/core/memory-engine/frontmatter.d.ts +16 -0
- package/dist/core/memory-engine/layout.d.ts +217 -0
- package/dist/core/memory-engine/memory-backend-contract.d.ts +12 -0
- package/dist/core/memory-engine/migrate.d.ts +9 -0
- package/dist/core/memory-engine/scan.d.ts +12 -0
- package/dist/core/memory-engine/scope-contract.d.ts +61 -1
- package/dist/core/memory-engine/sync-client.d.ts +87 -0
- package/dist/core/memory-engine/sync.d.ts +60 -0
- package/dist/core/memory-engine/tools.d.ts +41 -0
- package/dist/core/memory-engine/types.d.ts +188 -0
- package/dist/core/memory-recall.d.ts +141 -0
- package/dist/core/memory-vector.d.ts +20 -0
- package/dist/core/memory.d.ts +458 -0
- package/dist/core/message-utils.d.ts +6 -0
- package/dist/core/oracle-isolation.d.ts +69 -0
- package/dist/core/permission-rule-consent.d.ts +138 -0
- package/dist/core/permission-rule-model.d.ts +122 -0
- package/dist/core/permission-rule-store.d.ts +119 -3
- package/dist/core/permission-rules.d.ts +87 -1
- package/dist/core/present-plan-tool.d.ts +20 -0
- package/dist/core/pricing.d.ts +26 -0
- package/dist/core/property-harness.d.ts +86 -0
- package/dist/core/protocol-naming.d.ts +38 -0
- package/dist/core/protocol-table.d.ts +61 -0
- package/dist/core/push-queue.d.ts +1 -0
- package/dist/core/remote-env.d.ts +383 -1
- package/dist/core/retention-policy.d.ts +40 -0
- package/dist/core/retention-policy.js +21 -0
- package/dist/core/retention.d.ts +51 -0
- package/dist/core/roles.d.ts +59 -0
- package/dist/core/runner/active-skill-scope.d.ts +34 -0
- package/dist/core/runner/assemble-result.d.ts +134 -0
- package/dist/core/runner/compaction-call-options.d.ts +97 -1
- package/dist/core/runner/grounding-signal.d.ts +10 -0
- package/dist/core/runner/image.d.ts +17 -0
- package/dist/core/runner/image.js +29 -15
- package/dist/core/runner/memory-consolidation.d.ts +60 -0
- package/dist/core/runner/prepare-memory.d.ts +59 -0
- package/dist/core/runner/prepare-task.d.ts +1011 -2
- package/dist/core/runner/prepare-task.js +51 -14
- package/dist/core/runner/prompt-suggestions.d.ts +7 -0
- package/dist/core/runner/runtask.d.ts +304 -3
- package/dist/core/runner/runtask.js +17 -2
- package/dist/core/runner/session-file-state-replay.d.ts +49 -0
- package/dist/core/runner/session-rule-policy.d.ts +58 -0
- package/dist/core/runner/strict-output-schema.d.ts +18 -3
- package/dist/core/runner/synthetic-tools.d.ts +113 -0
- package/dist/core/runner/teardown-bounded.d.ts +34 -0
- package/dist/core/runner/tool-disclosure.d.ts +227 -0
- package/dist/core/runner/tool-output-projection.d.ts +6 -0
- package/dist/core/runner/turn-attachments.d.ts +634 -0
- package/dist/core/runner/usage-accounting.d.ts +32 -0
- package/dist/core/runtime.d.ts +9 -0
- package/dist/core/safe-notify.d.ts +64 -0
- package/dist/core/safety-axis-vocab.d.ts +23 -0
- package/dist/core/safety-merge-corpus.d.ts +37 -0
- package/dist/core/scheduler.d.ts +121 -0
- package/dist/core/secret-env.d.ts +32 -0
- package/dist/core/select-model.d.ts +15 -0
- package/dist/core/sensitive-path-policy.d.ts +42 -0
- package/dist/core/session-policy-store.d.ts +94 -0
- package/dist/core/session-reconcile.d.ts +80 -0
- package/dist/core/session-store.d.ts +85 -0
- package/dist/core/session.d.ts +153 -0
- package/dist/core/shared-memory/contract.d.ts +22 -0
- package/dist/core/shared-memory/normalize.d.ts +123 -2
- package/dist/core/shared-memory/tools.d.ts +14 -0
- package/dist/core/shared-memory/types.d.ts +105 -0
- package/dist/core/shutdown-debug.d.ts +6 -0
- package/dist/core/side-query.d.ts +38 -0
- package/dist/core/side-query.js +6 -1
- package/dist/core/skill-tool-specifier.d.ts +72 -0
- package/dist/core/skills-directory.d.ts +100 -1
- package/dist/core/spec-contract.d.ts +89 -0
- package/dist/core/store-contracts/background-agent-store-contract.d.ts +31 -0
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +26 -0
- package/dist/core/store-contracts/contract-harness.d.ts +20 -0
- package/dist/core/store-contracts/contract-kit-version.d.ts +27 -0
- package/dist/core/store-contracts/file-snapshot-store-contract.d.ts +8 -0
- package/dist/core/store-contracts/mailbox-store-contract.d.ts +42 -0
- package/dist/core/store-contracts/tool-result-store-contract.d.ts +13 -0
- package/dist/core/strategy-store.d.ts +37 -0
- package/dist/core/stub-env.d.ts +7 -0
- package/dist/core/surrogate-safe-slice.d.ts +35 -0
- package/dist/core/task-notification.d.ts +202 -0
- package/dist/core/task-outcome.d.ts +53 -0
- package/dist/core/task-registry-agent.d.ts +337 -1
- package/dist/core/task-registry-agent.js +2 -0
- package/dist/core/task-registry-monitor.d.ts +12 -0
- package/dist/core/task-registry-shared.d.ts +540 -0
- package/dist/core/task-registry.d.ts +343 -0
- package/dist/core/task-registry.js +13 -2
- package/dist/core/task-tool-shape.d.ts +44 -0
- package/dist/core/tighten-task-spec.d.ts +21 -0
- package/dist/core/tool-detach.d.ts +21 -0
- package/dist/core/tool-errors.d.ts +131 -0
- package/dist/core/tool-errors.js +4 -0
- package/dist/core/tool-name-aliases.d.ts +27 -0
- package/dist/core/tool-policy.d.ts +555 -0
- package/dist/core/tool-policy.js +3 -0
- package/dist/core/tool-result-budget.d.ts +32 -0
- package/dist/core/tool-result-store.d.ts +174 -1
- package/dist/core/tools.d.ts +45 -0
- package/dist/core/trace.d.ts +323 -0
- package/dist/core/types.d.ts +3859 -2
- package/dist/core/untrusted-egress.d.ts +8 -0
- package/dist/core/untrusted-text.d.ts +156 -0
- package/dist/core/usage-window-store.d.ts +95 -0
- package/dist/core/version.d.ts +1 -0
- package/dist/core/warm-resume.d.ts +17 -0
- package/dist/core/wiring-manifest.d.ts +169 -0
- package/dist/core/with-retry.d.ts +24 -0
- package/dist/core/workflow-journal-store.d.ts +160 -0
- package/dist/core/workflow-run-store-contract.d.ts +25 -0
- package/dist/core/workflow-run-store.d.ts +119 -0
- package/dist/core/workflow-run-store.js +2 -0
- package/dist/engine/compaction/compaction.d.ts +256 -1
- package/dist/engine/compaction/utils.d.ts +94 -0
- package/dist/engine/execution-env/kill-tree.d.ts +29 -0
- package/dist/engine/execution-env/node-execution-env.d.ts +94 -0
- package/dist/engine/harness/agent-harness.d.ts +116 -0
- package/dist/engine/harness/agent-harness.js +3 -14
- package/dist/engine/harness/messages.d.ts +15 -0
- package/dist/engine/harness/types.d.ts +464 -2
- package/dist/engine/llm/diagnostics.d.ts +4 -0
- package/dist/engine/llm/event-stream.d.ts +3 -0
- package/dist/engine/llm/index.d.ts +7 -0
- package/dist/engine/llm/types.d.ts +500 -3
- package/dist/engine/llm/validation.d.ts +3 -0
- package/dist/engine/loop/agent-loop.d.ts +87 -2
- package/dist/engine/loop/runtime-deps.d.ts +7 -0
- package/dist/engine/loop/types.d.ts +424 -0
- package/dist/engine/lsp/frame-decoder.d.ts +13 -0
- package/dist/engine/lsp/node-lsp-manager.d.ts +107 -0
- package/dist/engine/lsp/stdio-lsp-transport.d.ts +7 -0
- package/dist/engine/session/import-validate.d.ts +27 -0
- package/dist/engine/session/log-digest.d.ts +93 -0
- package/dist/engine/session/memory-repo.d.ts +6 -0
- package/dist/engine/session/memory-storage.d.ts +2 -0
- package/dist/engine/session/session.d.ts +75 -0
- package/dist/engine/session/storage-base.d.ts +8 -0
- package/dist/fixtures/index.d.ts +36 -0
- package/dist/index.d.ts +17 -2
- package/dist/index.js +1 -2
- package/dist/internal/harness-types.d.ts +6 -0
- package/dist/internal/harness.d.ts +11 -0
- package/dist/internal/llm.d.ts +6 -0
- package/dist/orchestration/builtin-workflows.d.ts +53 -0
- package/dist/orchestration/dev-vm-script-runner.d.ts +19 -0
- package/dist/orchestration/goal.d.ts +57 -0
- package/dist/orchestration/goal.js +3 -0
- package/dist/orchestration/run-spec.d.ts +42 -0
- package/dist/orchestration/run-spec.js +4 -0
- package/dist/orchestration/run-workflow-tool.d.ts +169 -0
- package/dist/orchestration/workflow-governance.d.ts +61 -0
- package/dist/orchestration/workflow-meta.d.ts +28 -0
- package/dist/orchestration/workflow-observe.d.ts +60 -0
- package/dist/orchestration/workflow-primitives.d.ts +23 -1
- package/dist/orchestration/workflow-sandbox-conformance.d.ts +38 -0
- package/dist/orchestration/workflow-script-runner.d.ts +88 -0
- package/dist/orchestration/workflow-script-store.d.ts +98 -0
- package/dist/orchestration/workflow-size-guideline.d.ts +67 -0
- package/dist/orchestration/workflow-types.d.ts +169 -2
- package/dist/orchestration/workflow.d.ts +358 -0
- package/dist/orchestration/workflow.js +13 -2
- package/dist/prompt-assembly/artifact-store.d.ts +33 -0
- package/dist/prompt-assembly/artifact.d.ts +25 -0
- package/dist/prompt-assembly/assemble.d.ts +20 -0
- package/dist/prompt-assembly/composer.d.ts +29 -0
- package/dist/prompt-assembly/epoch.d.ts +55 -1
- package/dist/prompt-assembly/event-registry.d.ts +35 -0
- package/dist/prompt-assembly/explain.d.ts +12 -0
- package/dist/prompt-assembly/tool-catalog.d.ts +38 -0
- package/dist/prompt-assembly/turn-snapshot.d.ts +40 -0
- package/dist/prompt-assembly/types.d.ts +115 -0
- package/dist/prompts/coordinator.d.ts +27 -0
- package/dist/prompts/default.d.ts +539 -0
- package/dist/prompts/simple-sections.d.ts +45 -0
- package/dist/prompts/supervisor.d.ts +66 -0
- package/dist/scenarios/env.d.ts +28 -0
- package/dist/scenarios/full-body.d.ts +50 -0
- package/dist/scenarios/scenario-registry.d.ts +60 -0
- package/dist/scenarios/teacher-quickstart.d.ts +27 -0
- package/dist/server/http.d.ts +17 -0
- package/dist/stores/cc/lockfile.d.ts +6 -0
- package/dist/stores/cc/mailbox-store.d.ts +8 -0
- package/dist/stores/cc/roster-adapter.d.ts +4 -0
- package/dist/stores/cc/sidecar-transcript.d.ts +66 -0
- package/dist/stores/file/background-agent-store.d.ts +24 -0
- package/dist/stores/file/background-agent-store.js +2 -1
- package/dist/stores/file/checkpoint-store.d.ts +38 -0
- package/dist/stores/file/file-snapshot-store.d.ts +25 -0
- package/dist/stores/file/fs-atomic.d.ts +155 -0
- package/dist/stores/file/index.d.ts +89 -0
- package/dist/stores/file/mailbox-store.d.ts +36 -0
- package/dist/stores/file/mailbox-store.js +2 -0
- package/dist/stores/file/memory-store.d.ts +82 -0
- package/dist/stores/file/permission-rule-store.d.ts +79 -0
- package/dist/stores/file/session-policy-store.d.ts +28 -0
- package/dist/stores/file/session-store.d.ts +40 -0
- package/dist/stores/file/shared-ledger.d.ts +83 -0
- package/dist/stores/file/tool-result-store.d.ts +11 -0
- package/dist/stores/file/usage-window-store.d.ts +18 -0
- package/dist/stores/file/workflow-journal-store.d.ts +100 -0
- package/dist/stores/file/workflow-run-store.d.ts +11 -0
- package/dist/stores/file/workflow-run-store.js +2 -0
- package/dist/tools/fs/bash-readonly-classifier.d.ts +282 -0
- package/dist/tools/fs/encoding.d.ts +60 -0
- package/dist/tools/fs/fs-bash.d.ts +133 -0
- package/dist/tools/fs/fs-pdf.d.ts +28 -0
- package/dist/tools/fs/fs-search-tools.d.ts +5 -0
- package/dist/tools/fs/fs-shared.d.ts +360 -0
- package/dist/tools/fs/fs-write.d.ts +16 -0
- package/dist/tools/fs/gh-rate-limit.d.ts +22 -0
- package/dist/tools/fs/index.d.ts +79 -0
- package/dist/tools/fs/notebook.d.ts +56 -0
- package/dist/tools/fs/pdf.d.ts +70 -0
- package/dist/tools/fs/pdf.js +8 -2
- package/dist/tools/fs/repo-map.d.ts +10 -0
- package/dist/tools/fs/safety.d.ts +376 -0
- package/dist/tools/fs/search.d.ts +131 -0
- package/dist/tools/loop-tick.d.ts +24 -0
- package/dist/tools/monitor.d.ts +55 -0
- package/dist/tools/scheduler-tools.d.ts +51 -0
- package/dist/tools/sql-adapters.d.ts +18 -0
- package/dist/tools/sql.d.ts +25 -0
- package/dist/tools/task-list.d.ts +77 -0
- package/dist/tools/todo.d.ts +8 -0
- package/dist/tools/web.d.ts +184 -0
- package/dist/tools/web.js +32 -5
- package/dist/tools/worktree.d.ts +81 -0
- package/package.json +2 -2
- package/dist/tools/gitea-issue.d.ts +0 -13
- package/dist/tools/gitea-issue.js +0 -75
|
@@ -3,12 +3,53 @@ import type { BackgroundShellCapability, BackgroundShellId, BackgroundPoll, Back
|
|
|
3
3
|
import { BackgroundShellError } from "../../core/background-shell.js";
|
|
4
4
|
import type { SchedulerCapability, ScheduledIntent, SchedulerContext, ScheduledTaskId, ScheduledTaskSummary } from "../../core/scheduler.js";
|
|
5
5
|
import { SchedulerError } from "../../core/scheduler.js";
|
|
6
|
+
/** Convert user-facing timeout seconds into a positive, timer-safe millisecond delay. */
|
|
6
7
|
export declare function resolveExecTimeoutMs(timeoutSeconds: unknown): number | undefined;
|
|
8
|
+
/** service [377] review finding (win32): `where bash.exe` can resolve to `System32\bash.exe` — the
|
|
9
|
+
* WSL LAUNCHER, not a native shell. Running it drops into a Linux subsystem where Windows cwd/paths
|
|
10
|
+
* do not exist; silently adopting it is exactly the "wrong shell, false green" failure D1 forbids.
|
|
11
|
+
* Filter it (and the WindowsApps alias) out of PATH discovery; Git-Bash candidates are tried first. */
|
|
7
12
|
export declare function isWslBashLauncher(p: string): boolean;
|
|
13
|
+
/** Shell discovery for the platform (service [377] ask ①: exported as the single SDK source so a host
|
|
14
|
+
* adapter does not mirror the platform logic). Explicit `customShellPath` wins (missing → err);
|
|
15
|
+
* win32 = Git-Bash discovery (ProgramFiles → PATH, WSL launcher filtered) with fail-loud
|
|
16
|
+
* `shell_unavailable` (never a silent cmd.exe fallback); POSIX = /bin/bash → PATH bash → sh. */
|
|
8
17
|
export declare function getShellConfig(customShellPath?: string): Promise<Result<{
|
|
9
18
|
shell: string;
|
|
10
19
|
args: string[];
|
|
11
20
|
}, ExecutionError>>;
|
|
21
|
+
/** RB-235 ([1937] BB2): the spool-reclaim decision, extracted PURE so every rule is unit-pinnable.
|
|
22
|
+
* Both reclaim sites (foreground `reclaimSpool`, background `syncSpool`) route through this one
|
|
23
|
+
* function so they cannot drift apart.
|
|
24
|
+
*
|
|
25
|
+
* The hazard: `truncateSync(path, 0)` while the writer is LIVE races its O_APPEND appends — a
|
|
26
|
+
* buffered write landing between the caller's stat and the truncate is destroyed whole
|
|
27
|
+
* (stdio-block granularity) and NO reader-side counter ever sees it (`truncated` /
|
|
28
|
+
* `bytesDroppedBeforeCursor` / `bytesFromStart` all undercount by exactly the raced amount). An
|
|
29
|
+
* earlier narrowing kept the truncate but moved it to the HARD cap, so live truncations became rare
|
|
30
|
+
* instead of routine; an external black-box audit of that build still measured whole 8192-byte
|
|
31
|
+
* blocks disappearing, so rarity was never the fix. Ruled 2026-08-03: drop truncate-under-a-live-
|
|
32
|
+
* writer entirely.
|
|
33
|
+
*
|
|
34
|
+
* The rule, in one line: **the file of a writer that can still append is append-only.** While the
|
|
35
|
+
* writer lives, only the reader's cursor moves; physical reclamation happens after it is terminal.
|
|
36
|
+
* - writer LIVE → never reclaim (no window exists to lose bytes in);
|
|
37
|
+
* - writer TERMINAL + fully consumed → truncate at the ROTATE mark (race-free);
|
|
38
|
+
* - writer TERMINAL + reader behind at HARD cap → truncate, byte-accounting the unread remainder
|
|
39
|
+
* (`skippedBytes` → recordSkippedBytes, the honest `[... N bytes truncated ...]` disclosure).
|
|
40
|
+
*
|
|
41
|
+
* Cost, stated honestly: a live producer that outruns the reader is no longer capped on disk — its
|
|
42
|
+
* spool grows for as long as it runs (bounded by the exec timeout / background hard wall, reclaimed
|
|
43
|
+
* in full at its death). Capping it would mean destroying bytes we cannot count, which is the defect
|
|
44
|
+
* itself; no portable Node syscall releases the consumed prefix of a file another process is
|
|
45
|
+
* appending to. The reader stays bounded regardless — `skipAhead` drops the un-retainable middle and
|
|
46
|
+
* accounts every skipped byte. The same unbounded-while-live posture already holds for the retain
|
|
47
|
+
* lane (design/128) and for the detached-descendant residual (RB-26), and matches the CC anchor's
|
|
48
|
+
* shape (named temp files, no rotation at all) with the file never outliving its writer.
|
|
49
|
+
*
|
|
50
|
+
* RESIDUAL, unchanged by this rule: `writerLive` describes the DIRECT child. A detached descendant
|
|
51
|
+
* holding the same fd can still append after the child is reaped, so a terminal-writer truncate can
|
|
52
|
+
* in principle race it — the documented RB-26 posture, and undetectable from this side of the fd. */
|
|
12
53
|
export declare function decideSpoolReclaim(args: {
|
|
13
54
|
size: number;
|
|
14
55
|
cursor: number;
|
|
@@ -21,6 +62,13 @@ export declare function decideSpoolReclaim(args: {
|
|
|
21
62
|
reclaim: true;
|
|
22
63
|
skippedBytes: number;
|
|
23
64
|
};
|
|
65
|
+
/** design/128 T1-1 / codex 1.236 复审 R2: open the spool file pair ALL-OR-NOTHING — a failure opening the
|
|
66
|
+
* second file must close the first fd before rethrowing (the caller's catch only clears its references, so
|
|
67
|
+
* a half-open pair would leak fdOut for the env's lifetime). `wx` + 0600 (never follow / never reuse an
|
|
68
|
+
* existing path). Exported for direct fault-injection tests (pre-create a path → EEXIST). `a` (not
|
|
69
|
+
* `w`): O_APPEND makes every child/descendant write an atomic append at the current end — which is
|
|
70
|
+
* what lets the foreground quota rotation truncate a fully-consumed file to zero and have the next
|
|
71
|
+
* write land at offset 0 (a plain-fd writer would keep its own offset and leave an unreadable hole). */
|
|
24
72
|
export declare function openSpoolPair(base: string): {
|
|
25
73
|
outPath: string;
|
|
26
74
|
errPath: string;
|
|
@@ -35,14 +83,30 @@ export declare class NodeExecutionEnv implements ExecutionEnv, BackgroundShellCa
|
|
|
35
83
|
private readonly bgShells;
|
|
36
84
|
private bgCounter;
|
|
37
85
|
private readonly retainBackgroundProcesses;
|
|
86
|
+
/** design/128 T1-1: lazily-created env-owned spool dir (mkdtemp under os tmp — unpredictable, never the cwd). */
|
|
38
87
|
private bgSpoolDir?;
|
|
39
88
|
readonly backgroundCapabilities: BackgroundShellCapability["backgroundCapabilities"];
|
|
40
89
|
constructor(options: {
|
|
41
90
|
cwd: string;
|
|
42
91
|
shellPath?: string;
|
|
43
92
|
shellEnv?: NodeJS.ProcessEnv;
|
|
93
|
+
/** VENDORED EDIT (D1, security): how much of `process.env` the shell child inherits. Default `"scrub"` =
|
|
94
|
+
* fail-closed (drop secret-pattern keys, keep PATH/build/locale). `"all"` = full inherit (trusted env);
|
|
95
|
+
* `string[]` = strict allowlist. `shellEnv`/per-exec `env` always pass through. */
|
|
44
96
|
inheritEnv?: "all" | "scrub" | string[];
|
|
97
|
+
/** design/105: inject a resident scheduler daemon backend (the shell daemon). Absent ⇒ scheduling INERT. */
|
|
45
98
|
scheduler?: SchedulerCapability;
|
|
99
|
+
/**
|
|
100
|
+
* design/128 T1-1 — deliver-a-living-service mode (default false). When true, background processes
|
|
101
|
+
* OUTLIVE the run: `disposeBackgroundShells()` becomes a no-op (the runner's every-exit-path dispose
|
|
102
|
+
* included) and background stdio is spooled to env-owned temp files (0600, `wx`, unpredictable path)
|
|
103
|
+
* so the child never dies of EPIPE after the host exits. DEPLOYMENT-declared at env construction —
|
|
104
|
+
* no TaskSpec/model-facing switch exists. The 2h bg-timeout reaper and `killBackground` still work
|
|
105
|
+
* while the host lives; after host exit, cleanup is the deployment's responsibility (e.g. the TB
|
|
106
|
+
* container teardown). v1 covers processes spawned via `execBackground` only (a detach-adopted
|
|
107
|
+
* foreground exec keeps pipe stdio — best-effort survival). Incompatible with durable-suspend
|
|
108
|
+
* deployments (their pre-suspend dispose becomes a no-op too — do not combine).
|
|
109
|
+
*/
|
|
46
110
|
retainBackgroundProcesses?: boolean;
|
|
47
111
|
});
|
|
48
112
|
get schedulerCapabilities(): SchedulerCapability["schedulerCapabilities"];
|
|
@@ -60,8 +124,22 @@ export declare class NodeExecutionEnv implements ExecutionEnv, BackgroundShellCa
|
|
|
60
124
|
abortSignal?: AbortSignal;
|
|
61
125
|
}): Promise<Result<string[], FileError>>;
|
|
62
126
|
readBinaryFile(path: string, abortSignal?: AbortSignal): Promise<Result<Uint8Array, FileError>>;
|
|
127
|
+
/** RB-221 ([1937]): whole-file replace via same-directory staging + fsync + rename (CC 2.1.220 `Q5`,
|
|
128
|
+
* pretty220.js:60808). The former single-step `writeFile` was an in-place O_TRUNC: an abort mid-write
|
|
129
|
+
* (Esc during a large Write — ctx.signal reaches here directly), ENOSPC, or a crash left the target as
|
|
130
|
+
* a torn prefix of the NEW content with the original unrecoverable. Post-fix contract: the target is
|
|
131
|
+
* either fully old or fully new; `aborted` means it was never touched. Known semantic change (same as
|
|
132
|
+
* CC): rename breaks a hard link — the other link keeps the old content. */
|
|
63
133
|
writeFile(path: string, content: string | Uint8Array, abortSignal?: AbortSignal): Promise<Result<void, FileError>>;
|
|
134
|
+
/** RB-221 ([1937]): the historical single-step in-place overwrite — kept for targets where
|
|
135
|
+
* staging+rename would change node identity (symlink chains, non-regular files) and as the
|
|
136
|
+
* CC-parity fallback for filesystems where the rename cannot work. NOT atomic by design. */
|
|
64
137
|
private writeFileInPlace;
|
|
138
|
+
/** Atomic exclusive create ({@link FileSystem.writeFileExclusive}): Node `wx` flag = one
|
|
139
|
+
* `open(O_CREAT|O_EXCL)` syscall — an existing file returns FileError `"already_exists"` and is left
|
|
140
|
+
* untouched. The EEXIST→already_exists mapping lives HERE, on the exclusive-open step only — a parent
|
|
141
|
+
* `mkdir` can also throw EEXIST (parent path component is a regular file) and that is NOT "the target
|
|
142
|
+
* already exists" (fable review). Parent directories are created like writeFile. */
|
|
65
143
|
writeFileExclusive(path: string, content: string | Uint8Array, abortSignal?: AbortSignal): Promise<Result<void, FileError>>;
|
|
66
144
|
appendFile(path: string, content: string | Uint8Array): Promise<Result<void, FileError>>;
|
|
67
145
|
fileInfo(path: string): Promise<Result<FileInfo, FileError>>;
|
|
@@ -81,13 +159,29 @@ export declare class NodeExecutionEnv implements ExecutionEnv, BackgroundShellCa
|
|
|
81
159
|
prefix?: string;
|
|
82
160
|
suffix?: string;
|
|
83
161
|
}): Promise<Result<string, FileError>>;
|
|
162
|
+
/** design/116 detach: adopt a RUNNING foreground child as a background shell. Pre-fills the bg tails with
|
|
163
|
+
* the output captured so far (so TaskOutput's first read has the full history), attaches fresh data/close
|
|
164
|
+
* handlers, and arms the default bg timeout. Returns undefined when the live-shell limit is hit (detach
|
|
165
|
+
* refused; the exec keeps running in the foreground). */
|
|
84
166
|
private adoptRunningChild;
|
|
85
167
|
spawnBackground(command: string, options?: BackgroundSpawnOptions): Promise<Result<{
|
|
86
168
|
shellId: BackgroundShellId;
|
|
87
169
|
}, BackgroundShellError>>;
|
|
88
170
|
pollBackground(shellId: BackgroundShellId): Promise<Result<BackgroundPoll, BackgroundShellError>>;
|
|
89
171
|
killBackground(shellId: BackgroundShellId): Promise<Result<void, BackgroundShellError>>;
|
|
172
|
+
/** design/128 T1-1: incrementally read a retained shell's spool files into the in-memory tails, so
|
|
173
|
+
* pollBackground serves the same cursor semantics whether stdio came over pipes or spool files.
|
|
174
|
+
* Bounded single read per stream per poll (the tail keeps only its rolling window anyway).
|
|
175
|
+
* codex R3 F-C: reads are positioned by spool.fileCursor (the FILE offset — rotation truncates
|
|
176
|
+
* the file), while poll slicing keeps using the logical stream totalBytes; the two advance in
|
|
177
|
+
* lockstep here but are NOT interchangeable after a rotation. */
|
|
90
178
|
private syncSpool;
|
|
179
|
+
/** codex R3 F-D + [1105]: reclaim an EPHEMERAL spool (detach-adopted, or any non-retain bg
|
|
180
|
+
* spawn — the whole unix bg lane is spool-backed now) — fold the final residue into the tails,
|
|
181
|
+
* unlink both files, and drop the spool reference (later syncs become no-ops). Idempotent;
|
|
182
|
+
* never touches design/128 retain-lane spools (no `ephemeral` flag). A still-writing detached
|
|
183
|
+
* descendant keeps its fd into the unlinked inode (RB-26 posture — no EPIPE, auto-reclaim at
|
|
184
|
+
* its exit). */
|
|
91
185
|
private reclaimEphemeralSpool;
|
|
92
186
|
disposeBackgroundShells(opts?: {
|
|
93
187
|
except?: readonly BackgroundShellId[];
|
|
@@ -2,26 +2,66 @@ import type { ActorAssertion, AssistantMessage, ImageContent, Model } from "../l
|
|
|
2
2
|
import type { AgentMessage, AgentTool, LoopMalformedToolUseRecovery, LoopThinkingOnlyRecovery, LoopTruncatedOutputRecovery, QueueMode, ThinkingLevel } from "../loop/types.js";
|
|
3
3
|
import { type EngineSegment } from "../../core/untrusted-text.js";
|
|
4
4
|
import type { AbortResult, AgentHarnessEvent, AgentHarnessEventResultMap, AgentHarnessOptions, AgentHarnessOwnEvent, AgentHarnessResources, AgentHarnessStreamOptions, ExecutionEnv, PromptTemplate, Skill } from "./types.js";
|
|
5
|
+
/** [c209-C] codex 收口 C1/C2 — engine-provenance metadata a caller can stamp on the user message it
|
|
6
|
+
* mints (see the field docs on {@link UserMessage}). Threaded from `prompt`/`steer`/`followUp`/
|
|
7
|
+
* `nextTurn` options into the persisted message so derived views (auto-mode window, compaction
|
|
8
|
+
* serializer) work from METADATA, never from reminder-shape guessing. */
|
|
5
9
|
export interface UserMessageProvenance {
|
|
10
|
+
/** Exact char length of the engine-prepended prefix on `text` (first-frame reminders etc.).
|
|
11
|
+
* Sugar for the single segment `[0, chars)` — when `engineSegments` is also supplied, segments win. */
|
|
6
12
|
enginePrefixChars?: number;
|
|
13
|
+
/** [c209-C] R4: engine-trusted `[start, end)` UTF-16 segments of `text` — the general form of
|
|
14
|
+
* `enginePrefixChars` for engine frames that are NOT a pure head (a resume continuation keeps
|
|
15
|
+
* issue order, so a trusted frame may follow an untrusted fenced one). See UserMessage.engineSegments. */
|
|
7
16
|
engineSegments?: ReadonlyArray<EngineSegment>;
|
|
17
|
+
/** The ENTIRE message is engine-minted guidance (nudges/finalize/attachment bundles), not user speech.
|
|
18
|
+
* [c209-C] R4: mutually exclusive with `provenance` — on a double-stamp, `provenance` wins (see below). */
|
|
8
19
|
engineMinted?: true;
|
|
20
|
+
/** [c209-C] R3: engine-injected note whose content must stay VISIBLE in derived views (diagnostics,
|
|
21
|
+
* task notifications, steering, recall) but never under user authority — see UserMessage.provenance. */
|
|
9
22
|
provenance?: "engine-note";
|
|
23
|
+
/** RB-30 terminal fix — an OPAQUE payload the engine rides on this queued message (the runner's
|
|
24
|
+
* task-notification frame). Never serialized, never interpreted by the harness: if the message is
|
|
25
|
+
* still undrained at agent_end, the payload is handed back through `onUndrainedEngineNotes` so
|
|
26
|
+
* the runner can pend it per session (the final-drain stranding window closes losslessly). */
|
|
10
27
|
enginePayload?: unknown;
|
|
28
|
+
/** design/171 §5.2 — WHO spoke this message (shared-session multiplayer attribution). Threaded
|
|
29
|
+
* verbatim onto {@link UserMessage.actor}: metadata only, never authority, never on the provider
|
|
30
|
+
* wire. The model-facing speaker envelope is rendered INTO `text` by the caller (the single
|
|
31
|
+
* projection point `projectHumanInput`) BEFORE the frame wrapping — the harness never rewrites
|
|
32
|
+
* text, so annotation stays adjacent to the frame it attributes. */
|
|
11
33
|
actor?: ActorAssertion;
|
|
12
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Harness-level recovery wiring (design/118 ④b/⑤). The loop's prompt-too-long seam wants a
|
|
37
|
+
* replacement TRANSCRIPT; at the harness level the correct policy is a SESSION-persisted reduction
|
|
38
|
+
* (e.g. a forced compaction) — otherwise the next turn's `createTurnState()` rebuilds the context
|
|
39
|
+
* from the session and the in-memory shrink evaporates. So the harness contract is: `recover`
|
|
40
|
+
* persists the reduction to the session and returns whether anything shrank; the harness then
|
|
41
|
+
* rebuilds the turn state FROM the session and hands the loop the rebuilt transcript.
|
|
42
|
+
*/
|
|
13
43
|
export interface HarnessLoopRecovery {
|
|
14
44
|
truncatedOutput?: LoopTruncatedOutputRecovery;
|
|
15
45
|
malformedToolUse?: LoopMalformedToolUseRecovery;
|
|
16
46
|
thinkingOnly?: LoopThinkingOnlyRecovery;
|
|
47
|
+
/** design/128-follow-up (TB 尸检 T1-4): recover from a DEGENERATE-REPETITION cutoff instead of ending the
|
|
48
|
+
* run — the brain already cut the stream and stamped the turn errored; when `detect` matches, the loop
|
|
49
|
+
* nudges "don't repeat that, take a different approach" and runs another turn, bounded to `maxContinues`
|
|
50
|
+
* CONSECUTIVE times (default 2). The cut-off turn stays in the transcript (its salvaged text is real
|
|
51
|
+
* context). `detect` is injected by the caller (core owns the brain's DEGENERATE_MESSAGE constant). */
|
|
17
52
|
degenerateOutput?: {
|
|
18
53
|
detect: (message: AssistantMessage) => boolean;
|
|
19
54
|
maxContinues?: number;
|
|
20
55
|
};
|
|
21
56
|
promptTooLong?: {
|
|
57
|
+
/** Persist a context reduction to the SESSION; return true if anything shrank. Must not throw. */
|
|
22
58
|
recover: (attempt: number) => Promise<boolean>;
|
|
59
|
+
/** Override the loop's default prompt-too-long classifier. */
|
|
23
60
|
detect?: (message: AssistantMessage) => boolean;
|
|
61
|
+
/** Max recovery retries per turn (loop default: 2). */
|
|
24
62
|
maxRetries?: number;
|
|
63
|
+
/** M1 CC-withhold parity: hold the failure's stream events until the recovery outcome is
|
|
64
|
+
* known (loop default: true). See LoopPromptTooLongRecovery.withholdErrorEvents. */
|
|
25
65
|
withholdErrorEvents?: boolean;
|
|
26
66
|
};
|
|
27
67
|
}
|
|
@@ -29,17 +69,38 @@ export declare class AgentHarness<TSkill extends Skill = Skill, TPromptTemplate
|
|
|
29
69
|
readonly env: ExecutionEnv;
|
|
30
70
|
private session;
|
|
31
71
|
private phase;
|
|
72
|
+
/** design/74 R3-A: a one-way soft-stop flag. When set, `shouldStopAfterTurn` returns true at the next turn
|
|
73
|
+
* boundary so the loop exits CLEANLY (emit `agent_end` + return) WITHOUT an abort/interrupt — the path a
|
|
74
|
+
* resource-slice suspend needs (an abort would trip the orphan-[INTERRUPTED] reconcile = corrupt resume). */
|
|
32
75
|
private _stopAfterTurn;
|
|
33
76
|
private runAbortController?;
|
|
34
77
|
private runPromise?;
|
|
35
78
|
private pendingSessionWrites;
|
|
36
79
|
private model;
|
|
37
80
|
private thinkingLevel;
|
|
81
|
+
/** RB-30 terminal fix — runner-set sink for engine-note payloads left undrained at agent_end. */
|
|
38
82
|
onUndrainedEngineNotes?: (payloads: unknown[]) => void;
|
|
83
|
+
/** design/176 — runner-set sink fired at the CONSUMPTION boundary, once per engine-note payload,
|
|
84
|
+
* in consumption order (steer/followUp drain and the turn-open nextTurn splice — the two points
|
|
85
|
+
* where a queued frame actually enters the model's input). The runner uses it to record the
|
|
86
|
+
* inbound peer hop chain of the message the model is about to see; writing at ENQUEUE time
|
|
87
|
+
* instead would let an outbound send inherit the chain of a message the model has not read yet.
|
|
88
|
+
* Advisory (swallow-guarded at the call sites via the runner's own closure); never re-entered
|
|
89
|
+
* for the same payload — consumption deletes the sidecar entry in the same step. */
|
|
39
90
|
onEngineNoteConsumed?: (payload: unknown) => void;
|
|
91
|
+
/** RB-30 codex F1/F2: shared recovery sweep — collects engine-note payloads from the given queues
|
|
92
|
+
* in DELIVERY order (steer before followUp, each queue forward — the live loop serves steering
|
|
93
|
+
* first, so the recovered redelivery must not present "later" frames ahead of "now/next"),
|
|
94
|
+
* removes those entries, and hands the payloads to the runner sink. Called from BOTH terminal
|
|
95
|
+
* paths: the natural agent_end AND abort() (which clears the queues before agent_end would see
|
|
96
|
+
* them — the hard-abort race that round-1 shipped would have lost). */
|
|
97
|
+
/** RB-30 R2 belt-and-braces: runner-callable idempotent recovery for exit paths that reach
|
|
98
|
+
* neither agent_end nor abort() (a pre-prompt throw after prepare). Swept entries are removed,
|
|
99
|
+
* so a double call is a no-op. */
|
|
40
100
|
recoverUndrainedEngineNotes(): void;
|
|
41
101
|
private sweepUndrainedEngineNotes;
|
|
42
102
|
private systemPrompt;
|
|
103
|
+
/** S4: physical system blocks (static per leg, additive — see AgentHarnessOptions.systemBlocks). */
|
|
43
104
|
private systemBlocks;
|
|
44
105
|
private streamOptions;
|
|
45
106
|
private getApiKeyAndHeaders?;
|
|
@@ -61,12 +122,24 @@ export declare class AgentHarness<TSkill extends Skill = Skill, TPromptTemplate
|
|
|
61
122
|
private followUpQueueMode;
|
|
62
123
|
private nextTurnQueue;
|
|
63
124
|
private loopRecovery?;
|
|
125
|
+
/** roadmap #5 (CC Stop hook): the runner-wired stop gate — see {@link setStopGate}. */
|
|
64
126
|
private stopGate?;
|
|
65
127
|
private handlers;
|
|
66
128
|
constructor(options: AgentHarnessOptions<TSkill, TPromptTemplate, TTool>);
|
|
67
129
|
private getHandlers;
|
|
68
130
|
private emitOwn;
|
|
69
131
|
private emitAny;
|
|
132
|
+
/**
|
|
133
|
+
* Emit a hook event to its registered handlers and return a single result.
|
|
134
|
+
*
|
|
135
|
+
* **Last-write-wins:** handlers run in registration order; each non-`undefined` result overwrites
|
|
136
|
+
* the previous one, and the LAST non-`undefined` result is returned (`undefined` = abstain, keeps
|
|
137
|
+
* the prior winner). Handlers do NOT compose — registering two handlers that both return a result
|
|
138
|
+
* for the same event silently drops all but the last. A handler that throws aborts the whole emit
|
|
139
|
+
* (errors are not swallowed). Callers that need ordered, composable semantics for one event (e.g.
|
|
140
|
+
* the design/37 two-phase tool gate: collect arg rewrites, then adjudicate policy) must funnel that
|
|
141
|
+
* logic through a SINGLE handler rather than relying on multiple handlers + this fold.
|
|
142
|
+
*/
|
|
70
143
|
private emitHook;
|
|
71
144
|
private emitBeforeProviderRequest;
|
|
72
145
|
private emitBeforeProviderPayload;
|
|
@@ -77,7 +150,19 @@ export declare class AgentHarness<TSkill extends Skill = Skill, TPromptTemplate
|
|
|
77
150
|
private createStreamFn;
|
|
78
151
|
private drainQueuedMessages;
|
|
79
152
|
private createLoopConfig;
|
|
153
|
+
/**
|
|
154
|
+
* design/118 ④b/⑤: wire (or clear) the loop's recovery chains. The runner calls this after
|
|
155
|
+
* construction — truncated-output auto-continue and the prompt-too-long recover policy are
|
|
156
|
+
* PROFILE decisions (the harness only relays them to the loop).
|
|
157
|
+
*/
|
|
80
158
|
setLoopRecovery(recovery: HarnessLoopRecovery | undefined): void;
|
|
159
|
+
/**
|
|
160
|
+
* roadmap #5 (CC Stop hook): wire (or clear) the stop gate — consulted ONLY when the run would
|
|
161
|
+
* otherwise end (no tool calls, steer + followUp queues dry). Non-empty return = the run
|
|
162
|
+
* continues with those messages injected; empty = the run ends. Policy (the Hooks.stop call,
|
|
163
|
+
* consecutive-block cap, reason formatting) lives in the runner; the harness only supplies the
|
|
164
|
+
* drain-point timing.
|
|
165
|
+
*/
|
|
81
166
|
setStopGate(gate: (() => Promise<AgentMessage[]>) | undefined): void;
|
|
82
167
|
private validateToolNames;
|
|
83
168
|
private flushPendingSessionWrites;
|
|
@@ -87,7 +172,19 @@ export declare class AgentHarness<TSkill extends Skill = Skill, TPromptTemplate
|
|
|
87
172
|
prompt(text: string, options?: {
|
|
88
173
|
images?: ImageContent[];
|
|
89
174
|
} & UserMessageProvenance): Promise<AssistantMessage>;
|
|
175
|
+
/** [920] R2-③: an empty/whitespace-only injection with no images carries ZERO information — it
|
|
176
|
+
* must not mint a user frame (strict endpoints reject empty user content, and an empty follow-up would
|
|
177
|
+
* pointlessly extend the run by one turn). No-op, not a throw: injection callers are fire-and-
|
|
178
|
+
* forget lanes (wakeups, reminders) and a shell bug upstream must not crash the run. */
|
|
90
179
|
private static emptyInjection;
|
|
180
|
+
/** REF-B6 — the ONE injection enqueue behind steer()/followUp()/nextTurn(): the [920] R2-③ empty-injection
|
|
181
|
+
* short circuit, the user frame, the RB-30 engine-payload SIDECAR (a WeakMap entry, never a message field —
|
|
182
|
+
* pre-prompt exits recover these too), the queue push, and the broadcast. All three lanes ship in ONE
|
|
183
|
+
* `queue_update` event (see emitQueueUpdate), so they are one protocol contract and must stay one
|
|
184
|
+
* implementation: [920] R2-③ and RB-30 each had to be patched in three places.
|
|
185
|
+
*
|
|
186
|
+
* The idle check is deliberately NOT here: its message differs per lane, and nextTurn() legitimately has
|
|
187
|
+
* none (queueing the NEXT prompt while idle is exactly what it is for). */
|
|
91
188
|
private enqueueInjection;
|
|
92
189
|
steer(text: string, options?: {
|
|
93
190
|
images?: ImageContent[];
|
|
@@ -112,9 +209,28 @@ export declare class AgentHarness<TSkill extends Skill = Skill, TPromptTemplate
|
|
|
112
209
|
setResources(resources: AgentHarnessResources<TSkill, TPromptTemplate>): Promise<void>;
|
|
113
210
|
getStreamOptions(): AgentHarnessStreamOptions;
|
|
114
211
|
setStreamOptions(streamOptions: AgentHarnessStreamOptions): Promise<void>;
|
|
212
|
+
/** RB-31 (design/148 S2) — swap the system prompt (+ physical blocks) for the NEXT turn snapshot,
|
|
213
|
+
* the setTools-mirror seam: a compaction-boundary center adoption changes the stable prefix at a
|
|
214
|
+
* legal boundary only (the running turn keeps its snapshot; createTurnState picks this up).
|
|
215
|
+
* Blocks and prompt swap ATOMICALLY here; the existing blocksSafe guard still verifies equality
|
|
216
|
+
* per snapshot, so a mismatched pair degrades to the single-block face, never a divergent wire. */
|
|
115
217
|
setSystemPrompt(prompt: string, blocks?: AgentHarnessOptions<TSkill, TPromptTemplate, TTool>["systemBlocks"]): void;
|
|
116
218
|
setTools(tools: TTool[], activeToolNames?: string[]): Promise<void>;
|
|
219
|
+
/**
|
|
220
|
+
* design/74 R3-A: request a CLEAN stop at the next turn boundary. Unlike {@link abort} (a hard
|
|
221
|
+
* AbortController cancel that — with no `suspendRef` — drives the orphan-[INTERRUPTED] session reconcile),
|
|
222
|
+
* this sets a one-way flag the loop reads via its `shouldStopAfterTurn` callback: the current turn finishes
|
|
223
|
+
* its tool calls, the loop emits `agent_end`, and returns. The runner uses it for a resource-slice suspend
|
|
224
|
+
* so the suspended session is left clean (resumable), never reconciled as interrupted. Idempotent.
|
|
225
|
+
*/
|
|
117
226
|
requestStopAfterTurn(): void;
|
|
227
|
+
/**
|
|
228
|
+
* VENDOR.md mod #5 (fixed at de-vendoring, design/118 ⑤): drain session writes queued during an
|
|
229
|
+
* ABORTED run. The harness intentionally does NOT flush on the abort path — the caller's interrupt
|
|
230
|
+
* reconcile must append its synthetic tool_results first (closing the open tool_call batch), then
|
|
231
|
+
* call this, so queued writes always land on a legal transcript. Safe to call anytime; no-op when
|
|
232
|
+
* the queue is empty.
|
|
233
|
+
*/
|
|
118
234
|
flushQueuedSessionWrites(): Promise<void>;
|
|
119
235
|
abort(): Promise<AbortResult>;
|
|
120
236
|
waitForIdle(): Promise<void>;
|
|
@@ -584,20 +584,9 @@ export class AgentHarness {
|
|
|
584
584
|
else if (write.type === "thinking_level_change") {
|
|
585
585
|
await this.session.appendThinkingLevelChange(write.thinkingLevel);
|
|
586
586
|
}
|
|
587
|
-
else
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
else if (write.type === "custom_message") {
|
|
591
|
-
await this.session.appendCustomMessageEntry(write.customType, write.content, write.display, write.details);
|
|
592
|
-
}
|
|
593
|
-
else if (write.type === "label") {
|
|
594
|
-
await this.session.appendLabel(write.targetId, write.label);
|
|
595
|
-
}
|
|
596
|
-
else if (write.type === "session_info") {
|
|
597
|
-
await this.session.appendSessionName(write.name ?? "");
|
|
598
|
-
}
|
|
599
|
-
else if (write.type === "leaf") {
|
|
600
|
-
await this.session.getStorage().setLeafId(write.targetId);
|
|
587
|
+
else {
|
|
588
|
+
const unreachable = write;
|
|
589
|
+
throw new AgentHarnessError("invalid_argument", `flushPendingSessionWrites: unhandled queued write type ${unreachable.type}`);
|
|
601
590
|
}
|
|
602
591
|
this.pendingSessionWrites.shift();
|
|
603
592
|
}
|
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
import type { ImageContent, Message, TextContent } from "../llm/index.js";
|
|
2
2
|
import type { AgentMessage, BashExecutionMessage, CompactionSummaryMessage, CustomMessage } from "../loop/types.js";
|
|
3
3
|
export type { BashExecutionMessage, CompactionSummaryMessage, CustomMessage, } from "../loop/types.js";
|
|
4
|
+
/** Harness-only transcript entries that can be normalized into LLM messages. */
|
|
4
5
|
export type HarnessMessage = AgentMessage | BashExecutionMessage | CustomMessage | CompactionSummaryMessage;
|
|
5
6
|
export declare function asAgentMessage(message: HarnessMessage): AgentMessage;
|
|
6
7
|
export declare const COMPACTION_SUMMARY_PREFIX = "This session is being continued from a previous conversation that ran out of context. The summary below covers the earlier portion of the conversation.\n\n<summary>\n";
|
|
7
8
|
export declare const COMPACTION_SUMMARY_SUFFIX = "\n</summary>\n\nRecent messages are preserved verbatim below. Continue the conversation from where it left off without asking the user any further questions. Resume directly \u2014 do not acknowledge the summary, do not recap what was happening, do not preface with \"I'll continue\" or similar. Pick up the last task as if the break never happened.";
|
|
9
|
+
/** Render a shell execution record as user-visible context text for the model. */
|
|
8
10
|
export declare function bashExecutionToText(msg: BashExecutionMessage): string;
|
|
11
|
+
/** Build a persisted compaction summary message from the repository timestamp string.
|
|
12
|
+
* `elidedMessages` (RB-398-b①): the render-time count of messages this summary stands in for —
|
|
13
|
+
* drives the wrapper's scale disclosure; omitted ⇒ the wrapper stays byte-identical. */
|
|
9
14
|
export declare function createCompactionSummaryMessage(summary: string, tokensBefore: number, timestamp: string, elidedMessages?: number): CompactionSummaryMessage;
|
|
15
|
+
/** Build a custom transcript message that can be shown and replayed into context. */
|
|
10
16
|
export declare function createCustomMessage(customType: string, content: string | (TextContent | ImageContent)[], display: boolean, details: unknown, timestamp: string): CustomMessage;
|
|
17
|
+
/** Prefix stamped on a salvaged block so readers (model, summaries, humans) see it is a normalization
|
|
18
|
+
* product, not authored content. */
|
|
11
19
|
export declare const NORMALIZED_CONTENT_PREFIX = "[invalid content block normalized to text]";
|
|
20
|
+
/**
|
|
21
|
+
* Fail-soft salvage for a possibly-poisoned LLM message ([868] 件b): any structurally-invalid
|
|
22
|
+
* `content` shape (bare object as the whole field, or a typeless/unknown-type block in the array) is
|
|
23
|
+
* normalized to a prefixed text block. Legal messages are returned BY REFERENCE, untouched. Shared by
|
|
24
|
+
* `convertToLlm` (provider leg) and `serializeConversation` (compaction leg) — one helper, two mouths.
|
|
25
|
+
*/
|
|
12
26
|
export declare function normalizeLlmMessageContent<T extends Message>(message: T): T;
|
|
27
|
+
/** Convert harness transcript messages into the LLM-facing message sequence. */
|
|
13
28
|
export declare function convertToLlm(messages: AgentMessage[]): Message[];
|