@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
package/dist/core/trace.d.ts
CHANGED
|
@@ -1,15 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Observability seam (1.37). core emits structured, **metadata-only** trace events; a deployment's
|
|
3
|
+
* hook bridges them to OTel / Prometheus. core never imports an APM SDK.
|
|
4
|
+
*
|
|
5
|
+
* Privacy: events carry NO prompt/completion/tool-argument content (OTel SHOULD-NOT-by-default). If
|
|
6
|
+
* content capture is ever added it will be a separate opt-in event the deployment redacts at collection.
|
|
7
|
+
*
|
|
8
|
+
* Delivery: best-effort, fire-and-forget. The hook returns `void` (callers can't synchronously await),
|
|
9
|
+
* MUST NOT throw (core wraps it) and MUST NOT do sync I/O on the hot path. Every event carries
|
|
10
|
+
* `version` so a hook can gracefully degrade on unknown fields.
|
|
11
|
+
*
|
|
12
|
+
* OTel GenAI semantic conventions: several fields below note the `gen_ai.*` attribute they feed. Those are
|
|
13
|
+
* MAPPING NOTES for whoever writes the bridge, not a compatibility promise — the whole `gen_ai.*` namespace
|
|
14
|
+
* is still Development-status upstream (no span/attribute marked Stable, and attribute names have already
|
|
15
|
+
* been renamed once), so a bridge must pin the convention version it targets and expect upgrade breakage.
|
|
16
|
+
* core's own contract is only the field names here; it deliberately stops at supplying the FACTS a bridge
|
|
17
|
+
* needs (ids, turn indices, token counts) rather than adopting the convention's vocabulary internally.
|
|
18
|
+
*/
|
|
1
19
|
import type { TaskStatus, ToolEffect } from "./types.js";
|
|
2
20
|
import type { ThinkingLevel } from "../internal/harness-types.js";
|
|
3
21
|
import type { ToolManifestRow } from "../prompt-assembly/tool-catalog.js";
|
|
22
|
+
/**
|
|
23
|
+
* R4 (1.285): the scalar face of `TaskResult.stats.mechanisms`, echoed on `task.end` so "did the
|
|
24
|
+
* engine machinery fire" is answerable from the trace alone. Counters/flags only —
|
|
25
|
+
* `repetitionEvents` carries model-authored text samples and stays result-side (the file-header
|
|
26
|
+
* metadata-only rule). Field meanings: see the `stats.mechanisms` JSDoc in core/types.ts.
|
|
27
|
+
*/
|
|
4
28
|
export interface TraceMechanismsSummary {
|
|
5
29
|
finalVerifyInjected?: true;
|
|
6
30
|
finalVerifyInjections?: number;
|
|
7
31
|
attachmentsInjected?: number;
|
|
32
|
+
/** design/164: how many LIMIT-APPROACH frames were injected this run (0..2). */
|
|
8
33
|
approachNoticesSent?: number;
|
|
9
34
|
repetitionCuts?: number;
|
|
10
35
|
repetitionSpared?: number;
|
|
11
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* design/168 (additive) — the RESOLVED deferred-tool disclosure strategy for one prepared leg, plus the
|
|
39
|
+
* seat that chose it. `strategy` is the EFFECTIVE value (after the direct-call-lane interlock), and
|
|
40
|
+
* `source` says where it came from: the task spec, the `SEMA_TOOL_MATERIALIZE_STRATEGY` env channel, the
|
|
41
|
+
* engine default, or `"degraded_no_direct_lane"` — the interlock narrowed a `"static"` request to
|
|
42
|
+
* `"swap"` because `deferSelfResolve: false` left the placeholder permanently uncallable. That last
|
|
43
|
+
* value implies an ENV-sourced request: the spec pairing is refused at prepare and the default is not
|
|
44
|
+
* `"static"`.
|
|
45
|
+
*
|
|
46
|
+
* Why it is reported at all: "which strategy did this leg actually run" was previously only answerable
|
|
47
|
+
* by re-deriving spec > env > release default by hand — the archaeology the config manifest exists to
|
|
48
|
+
* kill — and the two strategies differ in how the schema reaches the model, which is exactly what an
|
|
49
|
+
* operator diagnosing a caller that cannot form tool arguments needs to know first.
|
|
50
|
+
*/
|
|
12
51
|
export interface ToolDisclosureManifest {
|
|
52
|
+
/** How many tool names were deferred on this leg (0 ⇒ this section is absent entirely). */
|
|
13
53
|
deferredTools: number;
|
|
14
54
|
strategy: "swap" | "static";
|
|
15
55
|
source: "spec" | "env" | "default" | "degraded_no_direct_lane";
|
|
@@ -19,18 +59,42 @@ export type TraceEvent = {
|
|
|
19
59
|
version: 1;
|
|
20
60
|
taskId: string;
|
|
21
61
|
model: string;
|
|
62
|
+
/** R4 (1.285): the engine build (package.json version, runtime-resolved) that produced this
|
|
63
|
+
* run — binds trace forensics to an exact build. "unknown" if resolution failed. */
|
|
22
64
|
engineVersion?: string;
|
|
23
65
|
ts: number;
|
|
24
66
|
} | {
|
|
67
|
+
/**
|
|
68
|
+
* 提示词主权批 — the labelled composition of the assembled system prompt, emitted once right after
|
|
69
|
+
* `task.start`. Kills the "which blocks were actually in the prompt" black box: a deployment can
|
|
70
|
+
* assert the constitution/safety blocks are present (or that their absence was a deliberate
|
|
71
|
+
* `replaceAll`) instead of diagnosing missing-prompt incidents by archaeology. Metadata-only
|
|
72
|
+
* (block ids + sizes + short content hashes — never prompt text, per the file-header privacy rule).
|
|
73
|
+
*/
|
|
25
74
|
kind: "prompt.assembled";
|
|
26
75
|
version: 1;
|
|
27
76
|
taskId: string;
|
|
77
|
+
/** Who owned the constitution layer: "core" (structural default) / "replaced" (provider
|
|
78
|
+
* `replaceAll` opt-out) / "provider-assembled" (migration guard pass-through). */
|
|
28
79
|
constitution: "core" | "replaced" | "provider-assembled";
|
|
80
|
+
/** Ordered blocks: stable id (e.g. `role.base`, `harness.context`, `memory.safety`,
|
|
81
|
+
* `env.context`, `memory.tail`), size in chars, sha256-prefix content hash. [c209-C]:
|
|
82
|
+
* `skills.block` is GONE — the skills listing left the stable prefix for the skills_listing
|
|
83
|
+
* reminder frame (observable via `steering_injected` source "skills_listing"). */
|
|
29
84
|
blocks: Array<{
|
|
30
85
|
id: string;
|
|
31
86
|
chars: number;
|
|
32
87
|
hash: string;
|
|
33
88
|
}>;
|
|
89
|
+
/**
|
|
90
|
+
* Manifest v2 (campaign S1, ADDITIVE — the v1 `blocks` id wordlist above is a downstream
|
|
91
|
+
* contract and stays as-is): the compiled-IR view, one entry per pack section, carrying the
|
|
92
|
+
* assembly protocol's semantic/lifecycle dimensions (slot/carrier/cadence/cacheClass).
|
|
93
|
+
* Absent on the legacy free-form provider path (single opaque block, no section structure).
|
|
94
|
+
* `contentHash` (digest tiering, [1050]②): UNSALTED full sha256, present ONLY on
|
|
95
|
+
* operator-declared sections (typed `stableBlocks` lane) — the center-publish ↔ manifest
|
|
96
|
+
* reconciliation anchor. Core-native sections stay salted-only (`hash`).
|
|
97
|
+
*/
|
|
34
98
|
sections?: Array<{
|
|
35
99
|
id: string;
|
|
36
100
|
slot: string;
|
|
@@ -41,20 +105,32 @@ export type TraceEvent = {
|
|
|
41
105
|
hash: string;
|
|
42
106
|
contentHash?: string;
|
|
43
107
|
}>;
|
|
108
|
+
/**
|
|
109
|
+
* Campaign S2 (additive): the mounted tools plane — per-tool contract identity, durable-replay
|
|
110
|
+
* aliases, presentation-invariant shape digest and full wire-schema digest (initial mount face;
|
|
111
|
+
* deferred activations announce via tools_delta). Content-addressed digests (schemas are code).
|
|
112
|
+
*/
|
|
44
113
|
tools?: ToolManifestRow[];
|
|
45
114
|
totalChars: number;
|
|
115
|
+
/** design/148 S3 (additive, §10.2): the nine-element cache identity — digests only. */
|
|
46
116
|
snapshot?: {
|
|
47
117
|
cacheIdentity: string;
|
|
48
118
|
elements: import("../prompt-assembly/turn-snapshot.js").CacheIdentityElements;
|
|
49
119
|
};
|
|
120
|
+
/** design/148 S3 (additive, §10.1): the run's lowering record. */
|
|
50
121
|
lowering?: {
|
|
51
122
|
version: string;
|
|
52
123
|
form: string;
|
|
53
124
|
intentionalDivergences: readonly string[];
|
|
54
125
|
};
|
|
126
|
+
/** design/168 (additive): the resolved deferred-tool disclosure strategy + the seat that chose
|
|
127
|
+
* it. Absent when the leg deferred nothing. */
|
|
55
128
|
toolDisclosure?: ToolDisclosureManifest;
|
|
56
129
|
ts: number;
|
|
57
130
|
} | {
|
|
131
|
+
/** design/148 S3 (codex F3) — a mid-run identity refresh (deferred materialization / RB-31
|
|
132
|
+
* adoption / finalize thinking flip): the trace stream must never keep claiming a superseded
|
|
133
|
+
* prefix identity. Digests only, never prompt text. */
|
|
58
134
|
kind: "prompt.snapshot_changed";
|
|
59
135
|
version: 1;
|
|
60
136
|
taskId: string;
|
|
@@ -64,20 +140,35 @@ export type TraceEvent = {
|
|
|
64
140
|
};
|
|
65
141
|
ts: number;
|
|
66
142
|
} | {
|
|
143
|
+
/**
|
|
144
|
+
* How a task's requested reasoning intensity RESOLVED against the model's real capability (design/96 S6).
|
|
145
|
+
* Emitted once at task start when thinking is on, so a deployment can SEE — not silently swallow (§E
|
|
146
|
+
* honesty red-line) — that a binary provider ignored the tier (`graded:false`) or that an effort endpoint
|
|
147
|
+
* clamped it down (`clamped:true`). Metadata-only (tiers + format + endpoint, never prompt content).
|
|
148
|
+
*/
|
|
67
149
|
kind: "reasoning.resolved";
|
|
68
150
|
version: 1;
|
|
69
151
|
taskId: string;
|
|
152
|
+
/** The model whose endpoint resolved the intensity. */
|
|
70
153
|
model: string;
|
|
154
|
+
/** The intensity the task asked for. */
|
|
71
155
|
requested: ThinkingLevel;
|
|
156
|
+
/** The intensity actually in effect on the wire. */
|
|
72
157
|
effective: ThinkingLevel;
|
|
158
|
+
/** False = binary enable-only / no-effort endpoint: the tier was NOT honored as a gradient (intent only). */
|
|
73
159
|
graded: boolean;
|
|
160
|
+
/** True = `effective` differs from `requested` (the endpoint couldn't honor the request exactly). */
|
|
74
161
|
clamped: boolean;
|
|
162
|
+
/** The wire format the request uses (`openai`/`deepseek`/`qwen`/`budget`/…) — the reason for graded/clamped. */
|
|
75
163
|
format: string;
|
|
164
|
+
/** Coarse endpoint label (`model.api`, e.g. `openai-completions` / `anthropic-messages`). */
|
|
76
165
|
endpoint: string;
|
|
166
|
+
/** design/148 S3 (additive, §10.2): the nine-element cache identity — digests only. */
|
|
77
167
|
snapshot?: {
|
|
78
168
|
cacheIdentity: string;
|
|
79
169
|
elements: Record<string, string>;
|
|
80
170
|
};
|
|
171
|
+
/** design/148 S3 (additive, §10.1): the run's lowering record. */
|
|
81
172
|
lowering?: {
|
|
82
173
|
version: string;
|
|
83
174
|
form: string;
|
|
@@ -85,6 +176,13 @@ export type TraceEvent = {
|
|
|
85
176
|
};
|
|
86
177
|
ts: number;
|
|
87
178
|
} | {
|
|
179
|
+
/**
|
|
180
|
+
* Config-catalog manifest (clay ruling 2026-07-19) — the run's EFFECTIVE task-launch config
|
|
181
|
+
* with per-field provenance (default / spec / derived / host-declared), emitted once right
|
|
182
|
+
* after `prompt.assembled`. Kills the "which layer set this knob" archaeology: every run
|
|
183
|
+
* self-reports its true scale, and host-layer overrides arrive as DECLARED entries
|
|
184
|
+
* (`TaskSpec.configOverrides`, reason required) instead of invisible env/adapter state.
|
|
185
|
+
*/
|
|
88
186
|
kind: "config.assembled";
|
|
89
187
|
version: 1;
|
|
90
188
|
taskId: string;
|
|
@@ -94,14 +192,28 @@ export type TraceEvent = {
|
|
|
94
192
|
value: number | boolean | string | null;
|
|
95
193
|
provenance: "default" | "spec" | "derived" | "host-declared";
|
|
96
194
|
}>;
|
|
195
|
+
/** Reasons for host-declared entries, keyed by catalog key (the announcement face). */
|
|
97
196
|
overrideReasons?: Record<string, string>;
|
|
98
197
|
ts: number;
|
|
99
198
|
} | {
|
|
199
|
+
/**
|
|
200
|
+
* RB-371 ③ — an `additionalDirectories` entry could not be canonicalized at prepare (missing
|
|
201
|
+
* directory / dangling symlink / env error) and was SKIPPED fail-closed: the run proceeds with
|
|
202
|
+
* a NARROWER allow-root set than the spec asked for. Previously only the side-band
|
|
203
|
+
* `onError(phase:"config")` callback saw this; a deployment without an onError sink got a
|
|
204
|
+
* silently narrowed fence (the # Environment block advertises only the EFFECTIVE roots, so the
|
|
205
|
+
* model never sees the asked-for entry either). One frame per skipped entry.
|
|
206
|
+
*/
|
|
100
207
|
kind: "config.additional_directory_skipped";
|
|
101
208
|
version: 1;
|
|
102
209
|
taskId: string;
|
|
210
|
+
/** Which spec field the skipped entry came from. Absent = `additionalDirectories` (the
|
|
211
|
+
* original face, kept implicit for existing readers); `"additionalReadDirectories"` = the
|
|
212
|
+
* read-only whitelist arm (ruled 2026-08-05). */
|
|
103
213
|
field?: "additionalReadDirectories";
|
|
214
|
+
/** The spec entry as written (raw, not canonical — canonicalization is what failed). */
|
|
104
215
|
entry: string;
|
|
216
|
+
/** The canonicalization failure, `code: message` form. */
|
|
105
217
|
reason: string;
|
|
106
218
|
ts: number;
|
|
107
219
|
} | {
|
|
@@ -112,11 +224,24 @@ export type TraceEvent = {
|
|
|
112
224
|
errorCode?: string;
|
|
113
225
|
turns: number;
|
|
114
226
|
tokens: number;
|
|
227
|
+
/** ABSENT when any spend was unpriced (RB-368: no pricing entry + no `Model.cost` — no
|
|
228
|
+
* fabricated 0; matches `stats.costMicroUsd`) and on the prepare/finish-throw backstop frame. */
|
|
115
229
|
costMicroUsd?: number;
|
|
116
230
|
durationMs: number;
|
|
231
|
+
/** True when the task finished with a structured output (`submit_output`); 1.41 observability. */
|
|
117
232
|
hasStructuredOutput?: boolean;
|
|
233
|
+
/** R4 (1.285): scalar echo of `stats.mechanisms` (absent when no deadline mechanism engaged —
|
|
234
|
+
* byte-compatible with pre-1.285 frames). */
|
|
118
235
|
mechanisms?: TraceMechanismsSummary;
|
|
236
|
+
/** 1.296 件2a (TB2.0 run89): how LATE the hard walltime-abort timer fired vs its scheduled
|
|
237
|
+
* time, when materially late (> 5s; absent otherwise, and absent when it never fired). A
|
|
238
|
+
* large value is EVIDENCE THE ENGINE WAS NOT AT FAULT — setTimeout only runs when the event
|
|
239
|
+
* loop breathes, so lateness this size means the environment starved the process (run89: an
|
|
240
|
+
* abandoned compile group froze the loop 646s; the 1200s hard abort landed 683s late). */
|
|
119
241
|
timerLatenessMs?: number;
|
|
242
|
+
/** RB-20 (TB [991] b-form): the run was stopped by the SYNCHRONOUS turn-boundary walltime
|
|
243
|
+
* backstop, not the hard-abort timer — i.e. the deadline had passed but the setTimeout leg
|
|
244
|
+
* had not fired yet (starved event loop). Pairs with `timerLatenessMs` for attribution. */
|
|
120
245
|
walltimeSyncBackstop?: boolean;
|
|
121
246
|
ts: number;
|
|
122
247
|
} | {
|
|
@@ -131,16 +256,40 @@ export type TraceEvent = {
|
|
|
131
256
|
taskId: string;
|
|
132
257
|
model: string;
|
|
133
258
|
provider?: string;
|
|
259
|
+
/**
|
|
260
|
+
* RB-410 — 1-based index of the turn this provider call served, same numbering as `turn.end` and as
|
|
261
|
+
* `tool.call.turn`. Lets a bridge put a `chat` span and the `execute_tool` spans of the tools that
|
|
262
|
+
* call requested under one parent without re-deriving turn boundaries from event order.
|
|
263
|
+
*
|
|
264
|
+
* ABSENT on the compaction summarizer's own call: that call fires from the turn-boundary hook and
|
|
265
|
+
* is not a loop turn, so any number here would be a different measurement wearing the same name.
|
|
266
|
+
*/
|
|
134
267
|
turn?: number;
|
|
268
|
+
/** RB-457-a: normalized prompt tokens that MISSED the cache (Anthropic-protocol `input_tokens`
|
|
269
|
+
* shape) — disjoint from `cacheRead`/`cacheWrite`. Carried the cache-inclusive total up to 2.13.x. */
|
|
135
270
|
promptTokens: number;
|
|
271
|
+
/** RB-457-a: the cache-INCLUSIVE prompt total for this call (`promptTokens + cacheRead +
|
|
272
|
+
* cacheWrite`) — the figure `costMicroUsd` is computed from. */
|
|
136
273
|
totalInputTokens: number;
|
|
137
274
|
completionTokens: number;
|
|
138
275
|
cacheRead: number;
|
|
139
276
|
cacheWrite: number;
|
|
277
|
+
/** Wall time from the brain request to its final message. */
|
|
140
278
|
latencyMs: number;
|
|
279
|
+
/** Time to the first content delta (excludes thinking) — maps to OTel time_to_first_chunk (×1000). */
|
|
141
280
|
firstTokenMs?: number;
|
|
281
|
+
/** 1.296 件2b (TB2.0 run89 归因盲区): epoch ms at which the ENGINE ISSUED this provider call
|
|
282
|
+
* (the per-call closure evaluation immediately before the stream call — unlike `latencyMs`,
|
|
283
|
+
* which anchors on the FIRST DELTA and reads 0 for a zero-delta call). Distinguishes an
|
|
284
|
+
* in-flight call cut before its first delta (present, latencyMs 0, stopReason "aborted")
|
|
285
|
+
* from a call that was never issued (absent). Compaction-summarizer rows never carry it (they
|
|
286
|
+
* bypass the loop's per-call closures). */
|
|
142
287
|
callStartedAt?: number;
|
|
288
|
+
/** ABSENT when THIS call's serving model was unpriced (RB-368 — no fabricated 0). */
|
|
143
289
|
costMicroUsd?: number;
|
|
290
|
+
/** TB telemetry B1 (service [397]): the NORMALIZED finish reason of this call (`StopReason`:
|
|
291
|
+
* `"stop"`/`"length"`/`"toolUse"`/`"error"`/`"aborted"`). Post-normalization (Anthropic
|
|
292
|
+
* `end_turn`/`stop_sequence`→`"stop"`, `max_tokens`→`"length"`). */
|
|
144
293
|
stopReason?: string;
|
|
145
294
|
ts: number;
|
|
146
295
|
} | {
|
|
@@ -148,24 +297,47 @@ export type TraceEvent = {
|
|
|
148
297
|
version: 1;
|
|
149
298
|
taskId: string;
|
|
150
299
|
name: string;
|
|
300
|
+
/**
|
|
301
|
+
* RB-410 — the resolved call's id: the SAME value the wire's `tool_start`/`tool_end` `TaskEvent`
|
|
302
|
+
* carries for this call. OTel GenAI names it `gen_ai.tool.call.id` on the `execute_tool` span.
|
|
303
|
+
*
|
|
304
|
+
* Why it matters: without it the trace face and the event face could only be paired by tool NAME
|
|
305
|
+
* plus timestamp, which is ambiguous exactly where it hurts — two same-named calls inside one
|
|
306
|
+
* parallel batch. Absent only on frames from a build that predates this field.
|
|
307
|
+
*/
|
|
151
308
|
toolCallId?: string;
|
|
309
|
+
/**
|
|
310
|
+
* RB-410 — 1-based index of the turn this call ran in, on the same numbering `turn.end` reports
|
|
311
|
+
* (a `tool.call` is emitted BEFORE the `turn.end` that closes its turn, so the two agree without
|
|
312
|
+
* look-ahead). No GenAI attribute corresponds; it is the PARENT-span correlation key a bridge
|
|
313
|
+
* needs to nest an `execute_tool` span under the `chat` call that requested the tool.
|
|
314
|
+
*/
|
|
152
315
|
turn?: number;
|
|
153
316
|
durationMs: number;
|
|
154
317
|
ok: boolean;
|
|
155
318
|
effect?: ToolEffect;
|
|
156
319
|
ts: number;
|
|
157
320
|
} | {
|
|
321
|
+
/** Degenerate-repetition detector telemetry (clay 2026-07-10, 2e1c161 observability): a model
|
|
322
|
+
* stream was CUT for a degenerate loop, or a repetition landed in a detection window but was
|
|
323
|
+
* SPARED by a structural allowance (code-line shape / divider run). One event per detector hit. */
|
|
158
324
|
kind: "repetition.detected";
|
|
159
325
|
version: 1;
|
|
160
326
|
taskId: string;
|
|
161
327
|
turn: number;
|
|
162
328
|
action: "cut" | "spared";
|
|
163
329
|
rule: "char-run" | "unit-loop";
|
|
330
|
+
/** Repeating-unit length in chars (1 for a char run). */
|
|
164
331
|
period: number;
|
|
332
|
+
/** How many times the unit repeated. */
|
|
165
333
|
reps: number;
|
|
334
|
+
/** ≤120-char sample of the repeated unit/tail. */
|
|
166
335
|
segment: string;
|
|
167
336
|
ts: number;
|
|
168
337
|
} | {
|
|
338
|
+
/** A task was **degraded** to a cheaper model (rate_limit / breaker-open / near-budget, plus
|
|
339
|
+
* design/126 server_error / last_resort on the chain form). An alert-worthy operational event —
|
|
340
|
+
* quality dropped. Emitted once, when first degraded. */
|
|
169
341
|
kind: "task.degraded";
|
|
170
342
|
version: 1;
|
|
171
343
|
taskId: string;
|
|
@@ -175,6 +347,10 @@ export type TraceEvent = {
|
|
|
175
347
|
atTurn: number;
|
|
176
348
|
ts: number;
|
|
177
349
|
} | {
|
|
350
|
+
/** RB-473 batch 2b — a HOST observer callback threw inside a safe-notify isolation scope
|
|
351
|
+
* (bounded: first failure per site per scope). The engine is unaffected (the swallow is the
|
|
352
|
+
* contract); this event is the disclosure so a deployment learns its observer plumbing broke.
|
|
353
|
+
* `site` is the owner-chosen literal (e.g. "toolGate.onHookError"). */
|
|
178
354
|
kind: "observer.notify_failed";
|
|
179
355
|
version: 1;
|
|
180
356
|
taskId: string;
|
|
@@ -182,6 +358,12 @@ export type TraceEvent = {
|
|
|
182
358
|
message: string;
|
|
183
359
|
ts: number;
|
|
184
360
|
} | {
|
|
361
|
+
/**
|
|
362
|
+
* design/179 — a persisted allow rule resolved an ask, so no person was asked and no checkpoint was
|
|
363
|
+
* minted. The gate has an attribution channel for the deny side and had none for the allow side;
|
|
364
|
+
* this is that channel, because "why did this run without asking me?" must be answerable. Metadata
|
|
365
|
+
* only (the rule text is the canonical rule spelling, never the command's arguments).
|
|
366
|
+
*/
|
|
185
367
|
kind: "permission.persisted_rule_allowed";
|
|
186
368
|
version: 1;
|
|
187
369
|
taskId: string;
|
|
@@ -190,100 +372,180 @@ export type TraceEvent = {
|
|
|
190
372
|
rule: string;
|
|
191
373
|
ts: number;
|
|
192
374
|
} | {
|
|
375
|
+
/**
|
|
376
|
+
* design/179 — the persisted allow-rule store could not be read, so this call was adjudicated with
|
|
377
|
+
* ZERO rules (it asks, rather than silently behaving like an empty store). A loosening face that
|
|
378
|
+
* fails must say so.
|
|
379
|
+
*/
|
|
193
380
|
kind: "permission.rule_store_unreadable";
|
|
194
381
|
version: 1;
|
|
195
382
|
taskId: string;
|
|
196
383
|
message: string;
|
|
197
384
|
ts: number;
|
|
198
385
|
} | {
|
|
386
|
+
/** C1 — the failover brain served this call from a FALLBACK entry (`createFailoverBrain`): the
|
|
387
|
+
* primary (and possibly earlier hops) failed cleanly upfront. Without this, same-model gateway
|
|
388
|
+
* swaps are indistinguishable in `brain.call` (the model id doesn't change). */
|
|
199
389
|
kind: "brain.failover";
|
|
200
390
|
version: 1;
|
|
201
391
|
taskId: string;
|
|
392
|
+
/** Index of the brain that SERVED the call (0 = primary; ≥1 = a fallback hop). */
|
|
202
393
|
servedIndex: number;
|
|
394
|
+
/** Chain length. */
|
|
203
395
|
total: number;
|
|
396
|
+
/** Canonical `BrainErrorCode` of the LAST failed hop (the reason the switch happened), if coded. */
|
|
204
397
|
errorCode?: string;
|
|
205
398
|
ts: number;
|
|
206
399
|
} | {
|
|
400
|
+
/** C5 — a circuit breaker changed phase (trip / half-open probe window / close). The breaker
|
|
401
|
+
* previously mutated state with zero emit; only the fast-fail's generic error text was visible. */
|
|
207
402
|
kind: "breaker.transition";
|
|
208
403
|
version: 1;
|
|
209
404
|
taskId: string;
|
|
405
|
+
/** Breaker key (default `<provider>:<modelId>`). */
|
|
210
406
|
key: string;
|
|
211
407
|
phase: "open" | "half-open" | "closed";
|
|
408
|
+
/** Consecutive transient failures at the transition. */
|
|
212
409
|
failures: number;
|
|
213
410
|
ts: number;
|
|
214
411
|
} | {
|
|
412
|
+
/** C6 — the connect/mid-stream retry loop retried a provider call. The DISCARDED attempt's cost is
|
|
413
|
+
* UNKNOWABLE by construction (the usage frame never arrived — that's why the attempt failed), so
|
|
414
|
+
* this reports the attempt count honestly instead of a fabricated cost figure. */
|
|
215
415
|
kind: "brain.retry";
|
|
216
416
|
version: 1;
|
|
217
417
|
taskId: string;
|
|
418
|
+
/** 1-based attempt number that was ABANDONED (the retry that follows is attempt+1). */
|
|
218
419
|
attempt: number;
|
|
219
420
|
phase: "connect" | "midstream";
|
|
220
421
|
ts: number;
|
|
221
422
|
} | {
|
|
423
|
+
/** C2 — the agent loop drove one of its self-heal recoveries (malformed-tool retry / thinking-only
|
|
424
|
+
* retry / truncated continue / degenerate cut / mid-stream partial continue / reactive compact /
|
|
425
|
+
* walltime cutoff write-out). Previously test-only (LoopTraceSink was never wired in production);
|
|
426
|
+
* the only artifact was a display:false nudge message. */
|
|
222
427
|
kind: "loop.recovery";
|
|
223
428
|
version: 1;
|
|
224
429
|
taskId: string;
|
|
225
430
|
reason: string;
|
|
226
431
|
ts: number;
|
|
227
432
|
} | {
|
|
433
|
+
/** C3 — within-task compaction WANTED to fire (over threshold) but the anti-thrash floor
|
|
434
|
+
* (design/64 §25.2 `minTokens`) suppressed it. Repeated suppression = the run is drifting into
|
|
435
|
+
* the request-trim / prefix-cache-collapse band with zero signal (the success-only onCompaction
|
|
436
|
+
* never fires on this path). */
|
|
228
437
|
kind: "compaction.suppressed";
|
|
229
438
|
version: 1;
|
|
230
439
|
taskId: string;
|
|
440
|
+
/** Estimated context tokens at the suppressed boundary. */
|
|
231
441
|
estTokens: number;
|
|
442
|
+
/** The anti-thrash floor that suppressed the pass. */
|
|
232
443
|
floor: number;
|
|
233
444
|
ts: number;
|
|
234
445
|
} | {
|
|
446
|
+
/** The auto-compaction trigger could not be EVALUATED: the serving model declares no usable
|
|
447
|
+
* context window, so the predicate refuses on the unknown-window sentinel and there is no
|
|
448
|
+
* threshold to report. Distinct from a healthy under-threshold pass, which is deliberately
|
|
449
|
+
* silent — this one means auto-compaction is inert for the whole run. Emitted once per task
|
|
450
|
+
* (the state is configuration, not an event); the host also gets one `phase: "config"` error. */
|
|
235
451
|
kind: "compaction.unevaluable";
|
|
236
452
|
version: 1;
|
|
237
453
|
taskId: string;
|
|
454
|
+
/** What the pass could still estimate (structural + prompt overhead) despite the unknown window. */
|
|
238
455
|
estTokens: number;
|
|
239
456
|
ts: number;
|
|
240
457
|
} | {
|
|
458
|
+
/** design/134 复审 — a preCompact callback BLOCKED a compaction at a turn boundary (auto/manual
|
|
459
|
+
* triggers only; "forced" ignores the block). Deliberate hook decision, NOT a failure: the
|
|
460
|
+
* breaker is neither fed nor reset by it. This frame is what tells a blocked boundary apart
|
|
461
|
+
* from a structural no-op (under threshold / no cut point). */
|
|
241
462
|
kind: "compaction.blocked";
|
|
242
463
|
version: 1;
|
|
243
464
|
taskId: string;
|
|
465
|
+
/** The trigger the blocked pass ran under (never "forced" — forced ignores blocks). */
|
|
244
466
|
trigger: "auto" | "manual";
|
|
245
467
|
ts: number;
|
|
246
468
|
} | {
|
|
469
|
+
/** MF-18 修① [496]③ — a compaction pass FAILED: either a burned summary attempt threw
|
|
470
|
+
* (summarizer error / empty summary / oversized-summary guard; counted toward the §17.4
|
|
471
|
+
* breaker) or a manual /compact was drained against an ALREADY-OPEN breaker (no attempt).
|
|
472
|
+
* Before this frame the only evidence was `Runner.onError(phase:"compaction")` — a service
|
|
473
|
+
* that acked the manual verb (202) but saw no `compacted` event had ZERO stream/trace signal
|
|
474
|
+
* about why (the [496]③ fingerprint). */
|
|
247
475
|
kind: "compaction.failed";
|
|
248
476
|
version: 1;
|
|
249
477
|
taskId: string;
|
|
478
|
+
/** The trigger of the failed pass. */
|
|
250
479
|
trigger: "auto" | "manual" | "forced";
|
|
480
|
+
/** Engine-authored failure detail (CompactionError / guard message), clipped. */
|
|
251
481
|
reason: string;
|
|
252
482
|
ts: number;
|
|
253
483
|
} | {
|
|
484
|
+
/** MF-18 修① [496]③ — a manual /compact request was PROCESSED but MOOTED: the loop is dying
|
|
485
|
+
* (abort fired / durable suspend / plan review in flight) so no compaction can run. The
|
|
486
|
+
* compact() promise resolves "mooted"; this frame is the trace-side counterpart.
|
|
487
|
+
* `reason:"cancelled"` (additive) — the caller withdrew an IN-FLIGHT request via
|
|
488
|
+
* `compact({signal})` and the pass's summary call was aborted mid-air. A caller cancel is an
|
|
489
|
+
* external cause, not summarizer evidence: never counted toward the consecutive-failure
|
|
490
|
+
* breaker, never fired through `onError` (a deliberate withdrawal is not an engine error).
|
|
491
|
+
* A cancel that lands while the request is still PARKED resolves the caller silently (no
|
|
492
|
+
* frame — no boundary ever saw the request, so there is no pass to account for). */
|
|
254
493
|
kind: "compaction.mooted";
|
|
255
494
|
version: 1;
|
|
256
495
|
taskId: string;
|
|
257
496
|
reason: "task_ending" | "cancelled";
|
|
258
497
|
ts: number;
|
|
259
498
|
} | {
|
|
499
|
+
/** MF-18 修① [496]③ — a manual /compact attempt ran but found NOTHING to compact (no valid
|
|
500
|
+
* cut point / empty history): `maybeCompact` returned a structural `{compacted:false}` on a
|
|
501
|
+
* forced pass. Manual-only by design — an auto pass no-ops at nearly every boundary (spam). */
|
|
260
502
|
kind: "compaction.noop";
|
|
261
503
|
version: 1;
|
|
262
504
|
taskId: string;
|
|
263
505
|
ts: number;
|
|
264
506
|
} | {
|
|
507
|
+
/** MF-18 修① [496]③ — a manual /compact was processed while compaction is DISABLED by the
|
|
508
|
+
* task spec (`compaction.enabled:false`): the request can never be honored this run. */
|
|
265
509
|
kind: "compaction.disabled";
|
|
266
510
|
version: 1;
|
|
267
511
|
taskId: string;
|
|
268
512
|
ts: number;
|
|
269
513
|
} | {
|
|
514
|
+
/** design/145 §2 — static config early-warning, emitted once at task start when the configured
|
|
515
|
+
* compaction model's window is SMALLER than the main model's: from `fallbackAt` estimated
|
|
516
|
+
* context tokens on, every boundary's summary call will either clamp-truncate its input or
|
|
517
|
+
* fall back to the main model. A deployment shell surfaces this as a startup hint. */
|
|
270
518
|
kind: "compaction.window_config_warning";
|
|
271
519
|
version: 1;
|
|
272
520
|
taskId: string;
|
|
273
521
|
compactionModelWindow: number;
|
|
274
522
|
mainModelWindow: number;
|
|
523
|
+
/** ≈ headroom/(1−clampTolerance), in the compaction model's structural-token coordinate
|
|
524
|
+
* (estimate). Absent when `clampTolerance ≥ 1` (fallback disabled — clamp-only behavior). */
|
|
275
525
|
fallbackAt?: number;
|
|
276
526
|
ts: number;
|
|
277
527
|
} | {
|
|
528
|
+
/** design/145 §3 — a compaction pass's summary call FELL BACK from the independent compaction
|
|
529
|
+
* model to the MAIN model: the dry-run clamp showed the conversation would lose more than
|
|
530
|
+
* `clampTolerance` of its chars in the small window (and the budget/walltime gates allowed
|
|
531
|
+
* the more expensive main-model call). The `compacted` wire event carries the additive
|
|
532
|
+
* `modelFallback`/`fallbackReason` mirror. */
|
|
278
533
|
kind: "compaction.model_fallback";
|
|
279
534
|
version: 1;
|
|
280
535
|
taskId: string;
|
|
536
|
+
/** Serialized conversation size, MAIN-model structural tokens. */
|
|
281
537
|
contentTokens: number;
|
|
538
|
+
/** ≈ what fits in the compaction model's window (its structural tokens; estimate). */
|
|
282
539
|
headroomTokens: number;
|
|
283
540
|
truncationRatio: number;
|
|
541
|
+
/** 门A estimate (contentTokens × main input price); absent when pricing was unavailable. */
|
|
284
542
|
estCostMicroUsd?: number;
|
|
285
543
|
ts: number;
|
|
286
544
|
} | {
|
|
545
|
+
/** design/145 §3 — a summary input WAS clamp-truncated on the small compaction model and the
|
|
546
|
+
* loss is hereby DISCLOSED (the pre-145 silent mid-section drop): reason "budget"/"walltime"
|
|
547
|
+
* = the fallback was denied by that gate; "tolerance" = within `clampTolerance` (bounded).
|
|
548
|
+
* Fires pre-call (survives a later summary failure). */
|
|
287
549
|
kind: "compaction.clamp_disclosure";
|
|
288
550
|
version: 1;
|
|
289
551
|
taskId: string;
|
|
@@ -292,70 +554,131 @@ export type TraceEvent = {
|
|
|
292
554
|
estCostMicroUsd?: number;
|
|
293
555
|
ts: number;
|
|
294
556
|
} | {
|
|
557
|
+
/** design/145 门B-3 — a manual /compact was honored INSIDE the graceful-finalize window
|
|
558
|
+
* (user sovereignty over engine throttling), but the summary call will consume write-out
|
|
559
|
+
* time; the soft summary deadline (wall − cushion) still bounds it. Warn-grade. */
|
|
295
560
|
kind: "compaction.manual_in_finalize";
|
|
296
561
|
version: 1;
|
|
297
562
|
taskId: string;
|
|
298
563
|
ts: number;
|
|
299
564
|
} | {
|
|
565
|
+
/** MF-18 修② [496]③ — the summarization INPUT was truncated to fit the compaction model's
|
|
566
|
+
* context window (the 300K-session shape that previously guaranteed a prompt-too-long throw
|
|
567
|
+
* at every boundary). Fidelity disclosure: oldest `droppedChars` characters of the serialized
|
|
568
|
+
* conversation were omitted from the summary prompt. */
|
|
300
569
|
kind: "compaction.input_truncated";
|
|
301
570
|
version: 1;
|
|
302
571
|
taskId: string;
|
|
572
|
+
/** Which summary call was truncated: the history summary or the split-turn prefix summary. */
|
|
303
573
|
label: "history" | "turn_prefix";
|
|
304
574
|
droppedChars: number;
|
|
305
575
|
keptChars: number;
|
|
306
576
|
ts: number;
|
|
307
577
|
} | {
|
|
578
|
+
/** 压缩子阶段遥测 (1.283 批 G 观察项 / design/145 §6 正交后续批) — sub-phase wall-time split of
|
|
579
|
+
* ONE landed compaction pass, mirroring `maybeCompact().phaseDurations` 1:1 so a TB "整段 ~55s
|
|
580
|
+
* 停顿" reading can be attributed to prepare (context build/cut-point/gates) vs the summary LLM
|
|
581
|
+
* call vs persist (attachments/session rewrite/post measurement). Invariant: prepareMs +
|
|
582
|
+
* (summaryMs ?? 0) + persistMs === durationMs (exact tiling, shared end mark).
|
|
583
|
+
*
|
|
584
|
+
* EMITTED by the runtask bridge (F 批, follow-up to the frame-definition batch): each of the
|
|
585
|
+
* three `compacted`-event bridge points (boundary/manual, PTL-recovery, end-of-task finish)
|
|
586
|
+
* reads `comp.phaseDurations` off the maybeCompact result (next to the
|
|
587
|
+
* `...(comp.durationMs !== undefined …)` passthrough — which now also forwards `phaseDurations`
|
|
588
|
+
* onto the wire event, additive) and emits this frame right beside the event.
|
|
589
|
+
* Metadata-only per the file-header rule (durations + a retry counter, no content). */
|
|
308
590
|
kind: "compaction.phase_timings";
|
|
309
591
|
version: 1;
|
|
310
592
|
taskId: string;
|
|
593
|
+
/** Context build → trigger math → cut-point selection → hooks/provider consult → dry-run/gates. */
|
|
311
594
|
prepareMs: number;
|
|
595
|
+
/** The summary LLM leg (serialization → clamp → completion, incl. PTL retries). ABSENT on a
|
|
596
|
+
* provider-reuse pass — no summary call happened. */
|
|
312
597
|
summaryMs?: number;
|
|
598
|
+
/** Working-file attachments → session rewrite (appendCompaction) → post measurement → observers. */
|
|
313
599
|
persistMs: number;
|
|
600
|
+
/** Reactive prompt-too-long retries burned inside this pass's summary call(s). */
|
|
314
601
|
ptlRetries: number;
|
|
602
|
+
/** Whole-pass wall time — equals the `compacted` wire event's `durationMs`. */
|
|
315
603
|
durationMs: number;
|
|
316
604
|
ts: number;
|
|
317
605
|
} | {
|
|
606
|
+
/** MF-18 修③ [496]③ — a compaction landed at the run's FINAL boundary and the one-shot
|
|
607
|
+
* post-compact announce latch (background-task snapshot, G1 [482]) was never consumed: the
|
|
608
|
+
* next collected boundary it waits for never came. The announce is lost for THIS run (a
|
|
609
|
+
* follow-up run on the same session re-arms it from the session tail — see the resume
|
|
610
|
+
* re-arm seed in runtask). */
|
|
318
611
|
kind: "compaction.announce_dropped";
|
|
319
612
|
version: 1;
|
|
320
613
|
taskId: string;
|
|
321
614
|
ts: number;
|
|
322
615
|
} | {
|
|
616
|
+
/** C9 — the request-layer context guard TRIMMED messages out of a request view (design/123
|
|
617
|
+
* request-only trim; the session keeps them, but the model didn't see them this turn). */
|
|
323
618
|
kind: "context.trim";
|
|
324
619
|
version: 1;
|
|
325
620
|
taskId: string;
|
|
621
|
+
/** Messages dropped from THIS request view. */
|
|
326
622
|
dropped: number;
|
|
327
623
|
ts: number;
|
|
328
624
|
} | {
|
|
625
|
+
/** C8 — the per-turn aggregate tool-result budget capped a result (offloaded to the store, or
|
|
626
|
+
* degraded to a self-contained truncation preview when the store failed/absent). */
|
|
329
627
|
kind: "tool_result.capped";
|
|
330
628
|
version: 1;
|
|
331
629
|
taskId: string;
|
|
332
630
|
tool?: string;
|
|
631
|
+
/** Chars of the full result before capping. */
|
|
333
632
|
sizeChars: number;
|
|
633
|
+
/** True = store.put failed (or no store): the model lost read-back for this result. */
|
|
334
634
|
storeFallback: boolean;
|
|
335
635
|
ts: number;
|
|
336
636
|
} | {
|
|
637
|
+
/** C4 — image blocks were replaced with text placeholders because the served model declares no
|
|
638
|
+
* vision input (`ModelSpec.input` without "image"). Silent quality loss without this. */
|
|
337
639
|
kind: "vision.placeholder";
|
|
338
640
|
version: 1;
|
|
339
641
|
taskId: string;
|
|
642
|
+
/** Image blocks replaced in THIS request. */
|
|
340
643
|
count: number;
|
|
341
644
|
ts: number;
|
|
342
645
|
} | {
|
|
646
|
+
/** C10 — a `preemptSignal` fired on a task that is NOT resource-suspend-eligible: the preempt is a
|
|
647
|
+
* documented silent no-op, but the SCHEDULER that raised it needs to know it was ignored. */
|
|
343
648
|
kind: "preempt.ignored";
|
|
344
649
|
version: 1;
|
|
345
650
|
taskId: string;
|
|
346
651
|
ts: number;
|
|
347
652
|
} | {
|
|
653
|
+
/** C11 — a tool requested a human plan review (`ctx.requestReview()`) but the deployment cannot
|
|
654
|
+
* honor it (no checkpoint store / loop already terminating): the request was consumed + DROPPED
|
|
655
|
+
* (headless degrade). The HITL ask vanished with zero signal before this. NO free-text reason
|
|
656
|
+
* field (codex MED: `requestReview({reason})` carries tool/model-authored text — the file-header
|
|
657
|
+
* metadata-only rule forbids it here; the fact of the drop is the signal). */
|
|
348
658
|
kind: "review.dropped";
|
|
349
659
|
version: 1;
|
|
350
660
|
taskId: string;
|
|
351
661
|
ts: number;
|
|
352
662
|
} | {
|
|
663
|
+
/** The deployment `RunnerDeps.onError` sink ITSELF failed — threw synchronously, or (an async
|
|
664
|
+
* sink) returned a promise that rejected. The failure is swallowed at the Runner's chokepoint
|
|
665
|
+
* wrap by contract (a broken observer never breaks the run), so this frame is the only evidence
|
|
666
|
+
* a persistently broken sink leaves. No `taskId`: the sink context is session-scoped. */
|
|
353
667
|
kind: "task.onerror_sink_failed";
|
|
354
668
|
version: 1;
|
|
669
|
+
/** Session of the original `onError` invocation whose sink failed. */
|
|
355
670
|
sessionId: string;
|
|
671
|
+
/** Phase of the original `onError` invocation (e.g. "compaction", "config", "memory"). */
|
|
356
672
|
phase: string;
|
|
673
|
+
/** Sink-authored failure detail (`Error.message` / `String(value)`), clipped to 256 chars —
|
|
674
|
+
* deployment-code-authored, same posture as `compaction.failed.reason` (never model text). */
|
|
357
675
|
reason: string;
|
|
358
676
|
ts: number;
|
|
359
677
|
};
|
|
678
|
+
/**
|
|
679
|
+
* Best-effort, fire-and-forget trace sink. Returns `void` by contract so a caller cannot synchronously
|
|
680
|
+
* await it; the default (absent) hook is a no-op the JIT can elide. Must not throw or do sync I/O.
|
|
681
|
+
*/
|
|
360
682
|
export type TracerHook = (e: TraceEvent) => void;
|
|
683
|
+
/** Invoke a tracer without ever letting it break the task (absent → no-op; throws swallowed). */
|
|
361
684
|
export declare function emitTrace(tracer: TracerHook | undefined, build: () => TraceEvent): void;
|