@nathapp/nax-agent 0.1.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 +24 -0
- package/LICENSE +21 -0
- package/README.md +49 -0
- package/dist/coding-tools/coding-tool-bash.d.ts +46 -0
- package/dist/coding-tools/coding-tool-bash.js +44 -0
- package/dist/coding-tools/coding-tool-extras.d.ts +35 -0
- package/dist/coding-tools/coding-tool-extras.js +56 -0
- package/dist/coding-tools/coding-tool-sandbox.d.ts +74 -0
- package/dist/coding-tools/coding-tool-sandbox.js +215 -0
- package/dist/coding-tools/coding-tool-support.d.ts +132 -0
- package/dist/coding-tools/coding-tool-support.js +159 -0
- package/dist/coding-tools/universal-coding-tools.d.ts +11 -0
- package/dist/coding-tools/universal-coding-tools.js +5 -0
- package/dist/command-interceptor/index.d.ts +55 -0
- package/dist/command-interceptor/index.js +60 -0
- package/dist/command-interceptor/shell.d.ts +36 -0
- package/dist/command-interceptor/shell.js +137 -0
- package/dist/command-safety/build.d.ts +19 -0
- package/dist/command-safety/build.js +47 -0
- package/dist/command-safety/guard.d.ts +32 -0
- package/dist/command-safety/guard.js +179 -0
- package/dist/command-safety/identifiers.d.ts +24 -0
- package/dist/command-safety/identifiers.js +20 -0
- package/dist/command-safety/index.d.ts +17 -0
- package/dist/command-safety/index.js +11 -0
- package/dist/command-safety/questions.d.ts +19 -0
- package/dist/command-safety/questions.js +60 -0
- package/dist/command-safety/row.d.ts +2 -0
- package/dist/command-safety/row.js +14 -0
- package/dist/command-safety/rule-scorer.d.ts +9 -0
- package/dist/command-safety/rule-scorer.js +391 -0
- package/dist/command-safety/shadow.d.ts +33 -0
- package/dist/command-safety/shadow.js +188 -0
- package/dist/command-safety/systemone-client.d.ts +16 -0
- package/dist/command-safety/systemone-client.js +92 -0
- package/dist/command-safety/tap.d.ts +37 -0
- package/dist/command-safety/tap.js +77 -0
- package/dist/command-safety/temp-only.d.ts +6 -0
- package/dist/command-safety/temp-only.js +215 -0
- package/dist/command-safety/tmp-write.d.ts +2 -0
- package/dist/command-safety/tmp-write.js +112 -0
- package/dist/command-safety/types.d.ts +185 -0
- package/dist/command-safety/types.js +21 -0
- package/dist/config/bash-approval.d.ts +33 -0
- package/dist/config/bash-approval.js +30 -0
- package/dist/config/catalog-overrides.d.ts +94 -0
- package/dist/config/catalog-overrides.js +7 -0
- package/dist/config/native-agent/index.d.ts +8 -0
- package/dist/config/native-agent/index.js +8 -0
- package/dist/config/schemas-sandbox.d.ts +31 -0
- package/dist/config/schemas-sandbox.js +45 -0
- package/dist/cost/core/index.d.ts +8 -0
- package/dist/cost/core/index.js +7 -0
- package/dist/cost/estimate.d.ts +34 -0
- package/dist/cost/estimate.js +65 -0
- package/dist/cost/model-spec.d.ts +28 -0
- package/dist/cost/model-spec.js +29 -0
- package/dist/cost/standard-types.d.ts +9 -0
- package/dist/cost/standard-types.js +1 -0
- package/dist/cost/usage-math.d.ts +18 -0
- package/dist/cost/usage-math.js +46 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +21 -0
- package/dist/infra/agent-logger.d.ts +22 -0
- package/dist/infra/agent-logger.js +19 -0
- package/dist/infra/credentials-config.d.ts +20 -0
- package/dist/infra/credentials-config.js +15 -0
- package/dist/infra/errors.d.ts +9 -0
- package/dist/infra/errors.js +11 -0
- package/dist/infra/index.d.ts +7 -0
- package/dist/infra/index.js +7 -0
- package/dist/infra/nax-error.d.ts +10 -0
- package/dist/infra/nax-error.js +16 -0
- package/dist/infra/spin-breaker/hash.d.ts +2 -0
- package/dist/infra/spin-breaker/hash.js +5 -0
- package/dist/infra/spin-breaker/index.d.ts +120 -0
- package/dist/infra/spin-breaker/index.js +340 -0
- package/dist/internal/agent-output-env.d.ts +44 -0
- package/dist/internal/agent-output-env.js +57 -0
- package/dist/internal/argv-exec.d.ts +58 -0
- package/dist/internal/argv-exec.js +224 -0
- package/dist/internal/bounded-io.d.ts +24 -0
- package/dist/internal/bounded-io.js +51 -0
- package/dist/internal/command-spec/index.d.ts +29 -0
- package/dist/internal/command-spec/index.js +36 -0
- package/dist/internal/describe-value-type.d.ts +8 -0
- package/dist/internal/describe-value-type.js +14 -0
- package/dist/internal/exec-framing.d.ts +18 -0
- package/dist/internal/exec-framing.js +22 -0
- package/dist/internal/file-lock.d.ts +91 -0
- package/dist/internal/file-lock.js +212 -0
- package/dist/internal/file-size.d.ts +2 -0
- package/dist/internal/file-size.js +12 -0
- package/dist/internal/git-add.d.ts +43 -0
- package/dist/internal/git-add.js +59 -0
- package/dist/internal/git-env.d.ts +59 -0
- package/dist/internal/git-env.js +93 -0
- package/dist/internal/git-exec.d.ts +58 -0
- package/dist/internal/git-exec.js +115 -0
- package/dist/internal/path-file-lock.d.ts +23 -0
- package/dist/internal/path-file-lock.js +25 -0
- package/dist/internal/process-alive.d.ts +42 -0
- package/dist/internal/process-alive.js +56 -0
- package/dist/internal/process-kill.d.ts +27 -0
- package/dist/internal/process-kill.js +54 -0
- package/dist/internal/realpath.d.ts +29 -0
- package/dist/internal/realpath.js +52 -0
- package/dist/internal/redact.d.ts +40 -0
- package/dist/internal/redact.js +161 -0
- package/dist/internal/shell-quote.d.ts +2 -0
- package/dist/internal/shell-quote.js +4 -0
- package/dist/internal/sort.d.ts +20 -0
- package/dist/internal/sort.js +20 -0
- package/dist/internal/strip-control-chars.d.ts +19 -0
- package/dist/internal/strip-control-chars.js +38 -0
- package/dist/internal/thenable.d.ts +10 -0
- package/dist/internal/thenable.js +15 -0
- package/dist/internal.d.ts +91 -0
- package/dist/internal.js +91 -0
- package/dist/native/adapter-deps.d.ts +46 -0
- package/dist/native/adapter-deps.js +43 -0
- package/dist/native/auth-types.d.ts +70 -0
- package/dist/native/auth-types.js +13 -0
- package/dist/native/auth.d.ts +133 -0
- package/dist/native/auth.js +362 -0
- package/dist/native/client.d.ts +50 -0
- package/dist/native/client.js +174 -0
- package/dist/native/complete.d.ts +33 -0
- package/dist/native/complete.js +88 -0
- package/dist/native/credentials/chained-store.d.ts +30 -0
- package/dist/native/credentials/chained-store.js +68 -0
- package/dist/native/credentials/change-guard.d.ts +51 -0
- package/dist/native/credentials/change-guard.js +136 -0
- package/dist/native/credentials/exec-source.d.ts +50 -0
- package/dist/native/credentials/exec-source.js +222 -0
- package/dist/native/credentials/fingerprint.d.ts +26 -0
- package/dist/native/credentials/fingerprint.js +174 -0
- package/dist/native/credentials/helper-process.d.ts +79 -0
- package/dist/native/credentials/helper-process.js +259 -0
- package/dist/native/credentials/helper-protocol.d.ts +36 -0
- package/dist/native/credentials/helper-protocol.js +79 -0
- package/dist/native/credentials/index.d.ts +60 -0
- package/dist/native/credentials/index.js +184 -0
- package/dist/native/errors.d.ts +34 -0
- package/dist/native/errors.js +109 -0
- package/dist/native/index.d.ts +25 -0
- package/dist/native/index.js +23 -0
- package/dist/native/model-resolver.d.ts +57 -0
- package/dist/native/model-resolver.js +73 -0
- package/dist/native/models.d.ts +116 -0
- package/dist/native/models.js +183 -0
- package/dist/native/session/ask-human.d.ts +15 -0
- package/dist/native/session/ask-human.js +22 -0
- package/dist/native/session/compaction.d.ts +94 -0
- package/dist/native/session/compaction.js +170 -0
- package/dist/native/session/handle-invalid-tool-call.d.ts +111 -0
- package/dist/native/session/handle-invalid-tool-call.js +159 -0
- package/dist/native/session/loop-events/cache-boundary.d.ts +11 -0
- package/dist/native/session/loop-events/cache-boundary.js +29 -0
- package/dist/native/session/loop-events/external-handler.d.ts +38 -0
- package/dist/native/session/loop-events/external-handler.js +193 -0
- package/dist/native/session/loop-events/index.d.ts +16 -0
- package/dist/native/session/loop-events/index.js +15 -0
- package/dist/native/session/loop-events/payload-guard.d.ts +9 -0
- package/dist/native/session/loop-events/payload-guard.js +31 -0
- package/dist/native/session/loop-events/registry.d.ts +84 -0
- package/dist/native/session/loop-events/registry.js +305 -0
- package/dist/native/session/loop-events/types.d.ts +251 -0
- package/dist/native/session/loop-events/types.js +14 -0
- package/dist/native/session/loop-handlers.d.ts +73 -0
- package/dist/native/session/loop-handlers.js +137 -0
- package/dist/native/session/nudge.d.ts +29 -0
- package/dist/native/session/nudge.js +35 -0
- package/dist/native/session/rate-provenance.d.ts +17 -0
- package/dist/native/session/rate-provenance.js +39 -0
- package/dist/native/session/session.d.ts +139 -0
- package/dist/native/session/session.js +208 -0
- package/dist/native/session/tool-input-exemplar.d.ts +2 -0
- package/dist/native/session/tool-input-exemplar.js +66 -0
- package/dist/native/session/tool-input-validation.d.ts +15 -0
- package/dist/native/session/tool-input-validation.js +146 -0
- package/dist/native/session/tool-mapping.d.ts +18 -0
- package/dist/native/session/tool-mapping.js +27 -0
- package/dist/native/session/tool-result.d.ts +37 -0
- package/dist/native/session/tool-result.js +25 -0
- package/dist/native/session/transcript-store.d.ts +77 -0
- package/dist/native/session/transcript-store.js +200 -0
- package/dist/native/session/truncation-handler.d.ts +47 -0
- package/dist/native/session/truncation-handler.js +83 -0
- package/dist/native/session/turn-accumulator.d.ts +45 -0
- package/dist/native/session/turn-accumulator.js +67 -0
- package/dist/native/session/turn-ask-human.d.ts +23 -0
- package/dist/native/session/turn-ask-human.js +41 -0
- package/dist/native/session/turn-compaction-step.d.ts +74 -0
- package/dist/native/session/turn-compaction-step.js +128 -0
- package/dist/native/session/turn-complete-step.d.ts +77 -0
- package/dist/native/session/turn-complete-step.js +159 -0
- package/dist/native/session/turn-end-event.d.ts +3 -0
- package/dist/native/session/turn-end-event.js +17 -0
- package/dist/native/session/turn-events.d.ts +63 -0
- package/dist/native/session/turn-events.js +48 -0
- package/dist/native/session/turn-loop-round-trip.d.ts +116 -0
- package/dist/native/session/turn-loop-round-trip.js +318 -0
- package/dist/native/session/turn-loop.d.ts +23 -0
- package/dist/native/session/turn-loop.js +250 -0
- package/dist/native/session/turn-result.d.ts +39 -0
- package/dist/native/session/turn-result.js +64 -0
- package/dist/native/session/turn-retry.d.ts +120 -0
- package/dist/native/session/turn-retry.js +182 -0
- package/dist/native/session/turn-tool-batch.d.ts +61 -0
- package/dist/native/session/turn-tool-batch.js +259 -0
- package/dist/native/session/turn-types.d.ts +164 -0
- package/dist/native/session/turn-types.js +36 -0
- package/dist/native/session-adapter.d.ts +56 -0
- package/dist/native/session-adapter.js +369 -0
- package/dist/native/session-affinity.d.ts +36 -0
- package/dist/native/session-affinity.js +43 -0
- package/dist/native/tier-providers.d.ts +18 -0
- package/dist/native/tier-providers.js +20 -0
- package/dist/permissions/approval-audit.d.ts +10 -0
- package/dist/permissions/approval-audit.js +22 -0
- package/dist/permissions/approvals-link.d.ts +20 -0
- package/dist/permissions/approvals-link.js +62 -0
- package/dist/permissions/approvals-store.d.ts +168 -0
- package/dist/permissions/approvals-store.js +259 -0
- package/dist/permissions/approvals-taint.d.ts +33 -0
- package/dist/permissions/approvals-taint.js +138 -0
- package/dist/permissions/ask-chain.d.ts +69 -0
- package/dist/permissions/ask-chain.js +32 -0
- package/dist/permissions/ask.d.ts +23 -0
- package/dist/permissions/ask.js +25 -0
- package/dist/permissions/bash-lex.d.ts +59 -0
- package/dist/permissions/bash-lex.js +279 -0
- package/dist/permissions/grammar.d.ts +12 -0
- package/dist/permissions/grammar.js +24 -0
- package/dist/permissions/index.d.ts +11 -0
- package/dist/permissions/index.js +9 -0
- package/dist/permissions/secret-spans.d.ts +19 -0
- package/dist/permissions/secret-spans.js +88 -0
- package/dist/permissions/types.d.ts +85 -0
- package/dist/permissions/types.js +1 -0
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.js +2 -0
- package/dist/runtime/node-glob.d.ts +3 -0
- package/dist/runtime/node-glob.js +83 -0
- package/dist/runtime/node-runtime.d.ts +3 -0
- package/dist/runtime/node-runtime.js +126 -0
- package/dist/runtime/slot.d.ts +11 -0
- package/dist/runtime/slot.js +17 -0
- package/dist/runtime/types.d.ts +51 -0
- package/dist/runtime/types.js +1 -0
- package/dist/runtime/which.d.ts +8 -0
- package/dist/runtime/which.js +32 -0
- package/dist/sandbox/argv-quote.d.ts +11 -0
- package/dist/sandbox/argv-quote.js +13 -0
- package/dist/sandbox/defaults.d.ts +27 -0
- package/dist/sandbox/defaults.js +47 -0
- package/dist/sandbox/git-guards.d.ts +64 -0
- package/dist/sandbox/git-guards.js +161 -0
- package/dist/sandbox/index.d.ts +11 -0
- package/dist/sandbox/index.js +10 -0
- package/dist/sandbox/launcher.d.ts +37 -0
- package/dist/sandbox/launcher.js +160 -0
- package/dist/sandbox/messages.d.ts +17 -0
- package/dist/sandbox/messages.js +46 -0
- package/dist/sandbox/policy-builder.d.ts +44 -0
- package/dist/sandbox/policy-builder.js +149 -0
- package/dist/sandbox/policy-inputs.d.ts +53 -0
- package/dist/sandbox/policy-inputs.js +76 -0
- package/dist/sandbox/probe.d.ts +8 -0
- package/dist/sandbox/probe.js +66 -0
- package/dist/sandbox/registry.d.ts +17 -0
- package/dist/sandbox/registry.js +57 -0
- package/dist/sandbox/session-tmp.d.ts +20 -0
- package/dist/sandbox/session-tmp.js +95 -0
- package/dist/sandbox/srt-backend.d.ts +21 -0
- package/dist/sandbox/srt-backend.js +99 -0
- package/dist/sandbox/types.d.ts +102 -0
- package/dist/sandbox/types.js +1 -0
- package/dist/session/adapter-failure.d.ts +60 -0
- package/dist/session/adapter-failure.js +11 -0
- package/dist/session/agent-stream-events.d.ts +103 -0
- package/dist/session/agent-stream-events.js +6 -0
- package/dist/session/interaction-handler.d.ts +53 -0
- package/dist/session/interaction-handler.js +2 -0
- package/dist/session/no-op-interaction-handler.d.ts +9 -0
- package/dist/session/no-op-interaction-handler.js +11 -0
- package/dist/session/protocol-types.d.ts +12 -0
- package/dist/session/protocol-types.js +1 -0
- package/dist/session/session-types.d.ts +456 -0
- package/dist/session/session-types.js +64 -0
- package/dist/session/tool-descriptor.d.ts +23 -0
- package/dist/session/tool-descriptor.js +5 -0
- package/dist/session/turn-deadline.d.ts +17 -0
- package/dist/session/turn-deadline.js +23 -0
- package/dist/tools/ask-request.d.ts +35 -0
- package/dist/tools/ask-request.js +57 -0
- package/dist/tools/bash-cwd.d.ts +82 -0
- package/dist/tools/bash-cwd.js +55 -0
- package/dist/tools/bash.d.ts +69 -0
- package/dist/tools/bash.js +283 -0
- package/dist/tools/delete.d.ts +57 -0
- package/dist/tools/delete.js +154 -0
- package/dist/tools/denial-redirect.d.ts +42 -0
- package/dist/tools/denial-redirect.js +266 -0
- package/dist/tools/deny-paths.d.ts +35 -0
- package/dist/tools/deny-paths.js +76 -0
- package/dist/tools/edit-region.d.ts +50 -0
- package/dist/tools/edit-region.js +90 -0
- package/dist/tools/edit.d.ts +25 -0
- package/dist/tools/edit.js +114 -0
- package/dist/tools/exec-allowlist-text.d.ts +18 -0
- package/dist/tools/exec-allowlist-text.js +24 -0
- package/dist/tools/exec-guard.d.ts +69 -0
- package/dist/tools/exec-guard.js +151 -0
- package/dist/tools/git-commit.d.ts +59 -0
- package/dist/tools/git-commit.js +220 -0
- package/dist/tools/git-flags/index.d.ts +10 -0
- package/dist/tools/git-flags/index.js +10 -0
- package/dist/tools/git.d.ts +88 -0
- package/dist/tools/git.js +397 -0
- package/dist/tools/glob.d.ts +29 -0
- package/dist/tools/glob.js +153 -0
- package/dist/tools/grep.d.ts +21 -0
- package/dist/tools/grep.js +162 -0
- package/dist/tools/index.d.ts +36 -0
- package/dist/tools/index.js +28 -0
- package/dist/tools/narrow-grants.d.ts +19 -0
- package/dist/tools/narrow-grants.js +54 -0
- package/dist/tools/nax-owned-writes.d.ts +135 -0
- package/dist/tools/nax-owned-writes.js +259 -0
- package/dist/tools/package-managers-table.d.ts +146 -0
- package/dist/tools/package-managers-table.js +325 -0
- package/dist/tools/package-managers-types.d.ts +36 -0
- package/dist/tools/package-managers-types.js +6 -0
- package/dist/tools/package-managers.d.ts +85 -0
- package/dist/tools/package-managers.js +391 -0
- package/dist/tools/path-list.d.ts +38 -0
- package/dist/tools/path-list.js +62 -0
- package/dist/tools/policy-bash-raw.d.ts +19 -0
- package/dist/tools/policy-bash-raw.js +210 -0
- package/dist/tools/policy-bash.d.ts +64 -0
- package/dist/tools/policy-bash.js +232 -0
- package/dist/tools/policy-command-branch.d.ts +32 -0
- package/dist/tools/policy-command-branch.js +63 -0
- package/dist/tools/policy-input.d.ts +2 -0
- package/dist/tools/policy-input.js +10 -0
- package/dist/tools/policy-match.d.ts +75 -0
- package/dist/tools/policy-match.js +117 -0
- package/dist/tools/policy-paths-branch.d.ts +97 -0
- package/dist/tools/policy-paths-branch.js +314 -0
- package/dist/tools/policy.d.ts +65 -0
- package/dist/tools/policy.js +232 -0
- package/dist/tools/protected-paths.d.ts +26 -0
- package/dist/tools/protected-paths.js +8 -0
- package/dist/tools/provider-adapt.d.ts +4 -0
- package/dist/tools/provider-adapt.js +32 -0
- package/dist/tools/provider-advertise.d.ts +39 -0
- package/dist/tools/provider-advertise.js +50 -0
- package/dist/tools/provider-grants.d.ts +36 -0
- package/dist/tools/provider-grants.js +72 -0
- package/dist/tools/provider-sanitize.d.ts +19 -0
- package/dist/tools/provider-sanitize.js +53 -0
- package/dist/tools/provider-types.d.ts +41 -0
- package/dist/tools/provider-types.js +26 -0
- package/dist/tools/read-continuation.d.ts +147 -0
- package/dist/tools/read-continuation.js +176 -0
- package/dist/tools/read-file.d.ts +32 -0
- package/dist/tools/read-file.js +85 -0
- package/dist/tools/read.d.ts +25 -0
- package/dist/tools/read.js +182 -0
- package/dist/tools/registry.d.ts +125 -0
- package/dist/tools/registry.js +67 -0
- package/dist/tools/request-capability.d.ts +13 -0
- package/dist/tools/request-capability.js +23 -0
- package/dist/tools/run-command-exec.d.ts +14 -0
- package/dist/tools/run-command-exec.js +161 -0
- package/dist/tools/run-command.d.ts +107 -0
- package/dist/tools/run-command.js +398 -0
- package/dist/tools/runtime-calltool.d.ts +146 -0
- package/dist/tools/runtime-calltool.js +223 -0
- package/dist/tools/runtime.d.ts +149 -0
- package/dist/tools/runtime.js +345 -0
- package/dist/tools/scratchpad.d.ts +20 -0
- package/dist/tools/scratchpad.js +197 -0
- package/dist/tools/spill.d.ts +81 -0
- package/dist/tools/spill.js +251 -0
- package/dist/tools/tool-audit.d.ts +171 -0
- package/dist/tools/tool-audit.js +183 -0
- package/dist/tools/truncate.d.ts +98 -0
- package/dist/tools/truncate.js +297 -0
- package/dist/tools/types.d.ts +145 -0
- package/dist/tools/types.js +24 -0
- package/dist/tools/verb-denial-argv-hint.d.ts +35 -0
- package/dist/tools/verb-denial-argv-hint.js +40 -0
- package/dist/tools/write.d.ts +9 -0
- package/dist/tools/write.js +45 -0
- package/package.json +54 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Failure descriptor returned (or synthesized) by an agent adapter. Part of the
|
|
3
|
+
* session contract (S1 spec section 4.2, port 2); `context/engine` re-exports it.
|
|
4
|
+
*
|
|
5
|
+
* The runner uses this to decide between escalation (quality) and agent
|
|
6
|
+
* fallback (availability), and passes it to `rebuildForAgent()` so the new
|
|
7
|
+
* bundle carries a failure-note chunk.
|
|
8
|
+
*
|
|
9
|
+
* See: docs/specs/SPEC-context-engine-v2.md §Availability fallback
|
|
10
|
+
*/
|
|
11
|
+
export interface AdapterFailure {
|
|
12
|
+
/**
|
|
13
|
+
* "availability" — vendor quota, rate-limit, service down, auth error.
|
|
14
|
+
* Triggers agent fallback (same tier, different agent).
|
|
15
|
+
* "quality" — review/verify rejected output.
|
|
16
|
+
* Triggers tier escalation by default; agent fallback is opt-in.
|
|
17
|
+
*/
|
|
18
|
+
category: "availability" | "quality";
|
|
19
|
+
/**
|
|
20
|
+
* Machine-readable outcome code.
|
|
21
|
+
* availability: fail-quota | fail-service-down | fail-auth | fail-rate-limit | fail-aborted | fail-stale
|
|
22
|
+
* quality: fail-timeout | fail-adapter-error | fail-quality | fail-unknown | fail-spin | fail-incomplete
|
|
23
|
+
*
|
|
24
|
+
* `fail-aborted` — the run was cancelled via AgentRunOptions.abortSignal
|
|
25
|
+
* (shutdown in progress). Not retriable; fallback chains should not fire.
|
|
26
|
+
* `fail-stale` — either (a) the idle watchdog cancelled due to no stream activity
|
|
27
|
+
* within the configured idle timeout, or (b) the agent finished cleanly with empty
|
|
28
|
+
* output. The `reason` field distinguishes: "idle-watchdog" vs "empty-output".
|
|
29
|
+
* Retriable up to maxRetryAttempts.
|
|
30
|
+
* `fail-spin` — the spin breaker ended the turn: the model kept issuing tool
|
|
31
|
+
* calls whose shape it had already issued, with no new work between them
|
|
32
|
+
* (nax#2013). Distinct from `fail-timeout` on purpose — both mean "no usable
|
|
33
|
+
* answer within the budget", but only this one is measurable as a spin, and
|
|
34
|
+
* #2013 exists because the failure mode was invisible. Retriable: the retry
|
|
35
|
+
* opens a fresh session, so the repetition is not carried forward.
|
|
36
|
+
* `fail-incomplete` — the turn ended with tool calls outstanding (transport's
|
|
37
|
+
* `turnIncomplete` fact), reachable through `normalizeHopOutput` even when the
|
|
38
|
+
* turn carries prose (nax#2054). Distinct from `fail-quality` on purpose: that
|
|
39
|
+
* outcome's policy is sameAgentRetry "none" + swap "quality-gated", which would
|
|
40
|
+
* hard-fail with no retry or swap when `agent.fallback.onQualityFailure` is off.
|
|
41
|
+
* Retriable on the timeout lane, same as `fail-spin`.
|
|
42
|
+
* `fail-invalid-tool-call` — the invalid-call budget ended the turn (nax#2047);
|
|
43
|
+
* not a timeout, so the retry names the rejected call (nax#2200). Timeout lane.
|
|
44
|
+
*/
|
|
45
|
+
outcome: "fail-quota" | "fail-service-down" | "fail-auth" | "fail-rate-limit" | "fail-aborted" | "fail-stale" | "fail-timeout" | "fail-adapter-error" | "fail-quality" | "fail-unknown" | "fail-spin" | "fail-incomplete" | "fail-invalid-tool-call";
|
|
46
|
+
/** Human-readable description (≤500 chars) for the failure-note chunk */
|
|
47
|
+
message: string;
|
|
48
|
+
/** True when the same agent/tier could succeed on immediate retry */
|
|
49
|
+
retriable: boolean;
|
|
50
|
+
/** Seconds to wait before retrying (for rate-limit failures) */
|
|
51
|
+
retryAfterSeconds?: number;
|
|
52
|
+
/**
|
|
53
|
+
* Observability tag — distinguishes outcome subtypes. No semantic effect on retry/swap.
|
|
54
|
+
* Examples: "idle-watchdog" (fail-stale from idle watchdog cancellation),
|
|
55
|
+
* "empty-output" (fail-stale synthesized when agent returned no output).
|
|
56
|
+
*/
|
|
57
|
+
reason?: string;
|
|
58
|
+
/** The rejected call behind a `fail-invalid-tool-call`, for the retry prompt. */
|
|
59
|
+
invalidToolCall?: import("./session-types.ts").InvalidToolCallDetail;
|
|
60
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Failure descriptor returned (or synthesized) by an agent adapter. Part of the
|
|
3
|
+
* session contract (S1 spec section 4.2, port 2); `context/engine` re-exports it.
|
|
4
|
+
*
|
|
5
|
+
* The runner uses this to decide between escalation (quality) and agent
|
|
6
|
+
* fallback (availability), and passes it to `rebuildForAgent()` so the new
|
|
7
|
+
* bundle carries a failure-note chunk.
|
|
8
|
+
*
|
|
9
|
+
* See: docs/specs/SPEC-context-engine-v2.md §Availability fallback
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent stream events: what an adapter reports while a call runs. Part of the
|
|
3
|
+
* session contract (S1 spec section 4.2, port 2). `runtime/agent-stream-events`
|
|
4
|
+
* re-exports these and keeps the bus.
|
|
5
|
+
*/
|
|
6
|
+
export interface AgentStreamEventBase {
|
|
7
|
+
/**
|
|
8
|
+
* Stream-local UUID minted per turn by the emitting adapter
|
|
9
|
+
* (`native/session-adapter.ts` `randomUUID()`, mirrored by ACP per prompt).
|
|
10
|
+
* It is the watchdog's and `onActiveCall`'s handle and is NOT a durable join key.
|
|
11
|
+
*/
|
|
12
|
+
readonly callId: string;
|
|
13
|
+
readonly runId: string;
|
|
14
|
+
readonly agentName: string;
|
|
15
|
+
readonly sessionName: string;
|
|
16
|
+
readonly storyId?: string;
|
|
17
|
+
/** Pipeline stage label. A plain string: the contract does not know nax's stage union. */
|
|
18
|
+
readonly stage?: string;
|
|
19
|
+
readonly pid?: number;
|
|
20
|
+
readonly timestamp: number;
|
|
21
|
+
/**
|
|
22
|
+
* The exact join key for this dispatch: the same value as the transcript's
|
|
23
|
+
* `owner` and the cost ledger's `scopeId`. Native only, because only native
|
|
24
|
+
* carries a `transcriptOwner` (ACP ignores it). It is deliberately NOT the
|
|
25
|
+
* sibling `callId`, which is a stream-local UUID — joining on `callId` is the
|
|
26
|
+
* mistake that produced nax#2045's 0-of-1,940 match rate.
|
|
27
|
+
*
|
|
28
|
+
* Absent means "unknown", never a coerced `""` and never the `callId`. An
|
|
29
|
+
* absent key must not be joined on; a present-but-wrong key would silently
|
|
30
|
+
* corrupt the join.
|
|
31
|
+
*/
|
|
32
|
+
readonly scopeId?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface AgentCallStartedEvent extends AgentStreamEventBase {
|
|
35
|
+
readonly kind: "agent.call_started";
|
|
36
|
+
readonly model: string;
|
|
37
|
+
readonly timeoutSeconds: number;
|
|
38
|
+
}
|
|
39
|
+
export interface AgentMessageUpdateEvent extends AgentStreamEventBase {
|
|
40
|
+
readonly kind: "agent.message_update";
|
|
41
|
+
readonly deltaBytes?: number;
|
|
42
|
+
}
|
|
43
|
+
export interface AgentThinkingUpdateEvent extends AgentStreamEventBase {
|
|
44
|
+
readonly kind: "agent.thinking_update";
|
|
45
|
+
readonly deltaBytes?: number;
|
|
46
|
+
}
|
|
47
|
+
export interface AgentUsageUpdateEvent extends AgentStreamEventBase {
|
|
48
|
+
readonly kind: "agent.usage_update";
|
|
49
|
+
readonly inputTokens?: number;
|
|
50
|
+
readonly outputTokens?: number;
|
|
51
|
+
readonly costUsd?: number;
|
|
52
|
+
/**
|
|
53
|
+
* Set when this usage report IS one round trip, which is the native
|
|
54
|
+
* transport's cadence: `turn-loop.ts` emits exactly one per `complete()`.
|
|
55
|
+
*
|
|
56
|
+
* The idle watchdog reads it to classify the event as tool-call-tier
|
|
57
|
+
* activity rather than semantic progress. Without it, a spinning native
|
|
58
|
+
* session reset `lastNonToolCallActivityAt` on every iteration and
|
|
59
|
+
* `toolCallOnlyIdleTimeoutSeconds` — the timer built for exactly that shape
|
|
60
|
+
* — could never expire (nax#2013).
|
|
61
|
+
*
|
|
62
|
+
* Absent on ACP, whose loop is separately bounded by `maxInteractions` and
|
|
63
|
+
* whose usage cadence is the agent's, not nax's.
|
|
64
|
+
*/
|
|
65
|
+
readonly perRoundTrip?: true;
|
|
66
|
+
/** Cache-read tokens the provider served from its prompt cache. Absent when
|
|
67
|
+
* the round trip reported no cache data — never coerced to 0, so "no cache
|
|
68
|
+
* data" and "zero cache tokens" stay distinguishable. */
|
|
69
|
+
readonly cacheRead?: number;
|
|
70
|
+
/** Cache-creation (write) tokens the round trip billed. Absent when unknown,
|
|
71
|
+
* for the same reason as `cacheRead`. */
|
|
72
|
+
readonly cacheWrite?: number;
|
|
73
|
+
/** Native only: 1-based index of the round trip this usage covers, within the turn.
|
|
74
|
+
* Absent on a compaction-summary or retry beat, which are not round-trip boundaries. */
|
|
75
|
+
readonly roundTrip?: number;
|
|
76
|
+
/** Whose cadence this report follows. "round-trip" is nax's own loop (native);
|
|
77
|
+
* "agent" is the delegated agent's, which is not a nax turn marker (ACP). */
|
|
78
|
+
readonly cadence?: "round-trip" | "agent";
|
|
79
|
+
}
|
|
80
|
+
export interface AgentToolCallUpdateEvent extends AgentStreamEventBase {
|
|
81
|
+
readonly kind: "agent.tool_call_update";
|
|
82
|
+
readonly toolName?: string;
|
|
83
|
+
}
|
|
84
|
+
export interface AgentProcessUpdateEvent extends AgentStreamEventBase {
|
|
85
|
+
readonly kind: "agent.process_update";
|
|
86
|
+
readonly status: "spawned" | "stderr" | "cancelled" | "exited";
|
|
87
|
+
readonly exitCode?: number;
|
|
88
|
+
}
|
|
89
|
+
export interface AgentCallEndedEvent extends AgentStreamEventBase {
|
|
90
|
+
readonly kind: "agent.call_ended";
|
|
91
|
+
readonly status: "success" | "error" | "cancelled" | "timeout";
|
|
92
|
+
readonly exitCode?: number;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* US-004: the native turn is waiting on a human approval prompt. Emitted as
|
|
96
|
+
* activity from the turn loop while a prompt is pending so the idle watchdog
|
|
97
|
+
* does not read legitimate human waiting as idleness. Carries no payload — the
|
|
98
|
+
* timestamp is all the watchdog reads.
|
|
99
|
+
*/
|
|
100
|
+
export interface AgentAwaitingHumanEvent extends AgentStreamEventBase {
|
|
101
|
+
readonly kind: "agent.awaiting_human";
|
|
102
|
+
}
|
|
103
|
+
export type AgentStreamEvent = AgentCallStartedEvent | AgentMessageUpdateEvent | AgentThinkingUpdateEvent | AgentUsageUpdateEvent | AgentToolCallUpdateEvent | AgentProcessUpdateEvent | AgentCallEndedEvent | AgentAwaitingHumanEvent;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export type AdapterInteraction = {
|
|
2
|
+
kind: "context-tool";
|
|
3
|
+
name: string;
|
|
4
|
+
input?: unknown;
|
|
5
|
+
error?: string;
|
|
6
|
+
} | {
|
|
7
|
+
kind: "question";
|
|
8
|
+
text: string;
|
|
9
|
+
} | {
|
|
10
|
+
kind: "coding-tool";
|
|
11
|
+
name: string;
|
|
12
|
+
input?: Record<string, unknown>;
|
|
13
|
+
/** Turn context, for the audit ledger. Native only. */
|
|
14
|
+
turnId?: string;
|
|
15
|
+
roundTrips?: number;
|
|
16
|
+
toolCallId?: string;
|
|
17
|
+
/** Native shapes the final post-handler result at its loop chokepoint. */
|
|
18
|
+
deferModelTruncation?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* The turn's single abort signal (US-002). Native only, sent on every
|
|
21
|
+
* coding-tool request; the handler forwards it into the tool's
|
|
22
|
+
* `ToolCallContext` so an in-flight Bash/Exec can SIGKILL its process
|
|
23
|
+
* group when the turn is cancelled. Absent on the other kinds, which
|
|
24
|
+
* never run a tool.
|
|
25
|
+
*/
|
|
26
|
+
signal?: AbortSignal;
|
|
27
|
+
/**
|
|
28
|
+
* Notifies the wiring layer that the tool is about to WAIT on something
|
|
29
|
+
* external (e.g. a human approval) (US-002). Native only; forwarded by
|
|
30
|
+
* the handler into the tool's `ToolCallContext`.
|
|
31
|
+
*/
|
|
32
|
+
onWaiting?: () => void;
|
|
33
|
+
};
|
|
34
|
+
export interface AdapterInteractionResponse {
|
|
35
|
+
answer: string;
|
|
36
|
+
/** Completes deferred coding-tool audit with the final model-facing content. */
|
|
37
|
+
finalizeAudit?: (content: string) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Present only when the permission policy refused the call.
|
|
40
|
+
*
|
|
41
|
+
* Structural rather than a string convention: `{ answer }` alone cannot
|
|
42
|
+
* distinguish "refused, and here is why" from "here is your file", and
|
|
43
|
+
* conflating the two is exactly what ADR-029 section 5 forbids.
|
|
44
|
+
*/
|
|
45
|
+
denied?: {
|
|
46
|
+
reason: string;
|
|
47
|
+
breach: boolean;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export interface InteractionHandler {
|
|
51
|
+
onInteraction(request: AdapterInteraction): Promise<AdapterInteractionResponse | null>;
|
|
52
|
+
}
|
|
53
|
+
export declare const NO_OP_INTERACTION_HANDLER: InteractionHandler;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared no-op interaction handler singleton.
|
|
3
|
+
*
|
|
4
|
+
* Kept in runtime so both agent/session layers can reuse the same object
|
|
5
|
+
* identity without importing each other's modules.
|
|
6
|
+
*/
|
|
7
|
+
export declare const NO_OP_INTERACTION_HANDLER: {
|
|
8
|
+
onInteraction(): Promise<null>;
|
|
9
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared no-op interaction handler singleton.
|
|
3
|
+
*
|
|
4
|
+
* Kept in runtime so both agent/session layers can reuse the same object
|
|
5
|
+
* identity without importing each other's modules.
|
|
6
|
+
*/
|
|
7
|
+
export const NO_OP_INTERACTION_HANDLER = {
|
|
8
|
+
async onInteraction() {
|
|
9
|
+
return null;
|
|
10
|
+
},
|
|
11
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared protocol identifiers captured from adapter-backed sessions.
|
|
3
|
+
*
|
|
4
|
+
* Kept in runtime so agent/session subsystems can depend on a neutral type
|
|
5
|
+
* without importing each other.
|
|
6
|
+
*/
|
|
7
|
+
export interface ProtocolIds {
|
|
8
|
+
/** Stable protocol record ID for a logical session. */
|
|
9
|
+
recordId: string | null;
|
|
10
|
+
/** Volatile physical session ID (changes on reconnect). */
|
|
11
|
+
sessionId: string | null;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|