@jungjaehoon/mama-core 2.4.1 → 4.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/README.md +76 -239
- package/db/migrations/030-case-first-memory-substrate.sql +13 -98
- package/db/migrations/034-add-connector-event-scope-columns.sql +9 -13
- package/db/migrations/039-add-connector-event-operator-ingest-seq.sql +9 -95
- package/db/migrations/062-refresh-connector-event-sequences.sql +9 -113
- package/db/migrations/063-refresh-legacy-connector-event-updates.sql +9 -32
- package/db/migrations/067-add-connector-event-source-entity-id.sql +9 -13
- package/db/migrations/069-create-registry-nodes.sql +52 -0
- package/db/migrations/070-record-identity.sql +35 -0
- package/db/migrations/071-service-operation-origins.sql +187 -0
- package/db/migrations/072-observation-versions.sql +29 -0
- package/db/migrations/073-registry-corrections.sql +45 -0
- package/db/migrations/074-work-graph-ref-kinds.sql +39 -0
- package/db/migrations/075-agent-judgments.sql +58 -0
- package/db/migrations/076-scoped-checkpoint-bindings.sql +15 -0
- package/db/migrations/077-legacy-record-kind.sql +6 -0
- package/db/migrations/078-source-ingest-commands.sql +18 -0
- package/db/migrations/079-twin-edge-relations.sql +43 -0
- package/db/migrations/080-restore-duration-days.sql +7 -0
- package/db/migrations/081-mailbox.sql +61 -0
- package/db/migrations/082-commitments-row-id.sql +12 -0
- package/db/migrations/083-observation-is-the-evidence.sql +49 -0
- package/db/migrations/084-scope-kind-is-not-the-cores-to-list.sql +34 -0
- package/db/migrations/085-a-migration-has-a-source.sql +37 -0
- package/db/migrations/086-the-mailbox-is-generic.sql +110 -0
- package/db/migrations/087-mailbox-payload.sql +5 -0
- package/db/migrations/088-native-input-journal.sql +14 -0
- package/db/migrations/089-native-turn-receipt-lookup.sql +3 -0
- package/db/migrations/090-model-run-native-inputs.sql +29 -0
- package/db/migrations/091-native-turn-results.sql +11 -0
- package/db/migrations/092-restore-decision-fts.sql +34 -0
- package/db/migrations/093-native-turn-primary-kind.sql +14 -0
- package/db/migrations/094-commitment-run-provenance.sql +9 -0
- package/db/migrations/095-model-run-native-input-identity.sql +39 -0
- package/db/migrations/096-drop-connector-event-index-fts.sql +9 -0
- package/db/migrations/097-native-input-json-validity.sql +37 -0
- package/db/migrations/098-workflow-memory-kind.sql +105 -0
- package/db/migrations/099-commitment-revision-graph.sql +2 -0
- package/dist/action-contracts.d.ts +212 -0
- package/dist/action-contracts.js +10 -0
- package/dist/api/catalog.d.ts +118 -0
- package/dist/api/catalog.js +1756 -0
- package/dist/api/dispatch.d.ts +76 -0
- package/dist/api/dispatch.js +372 -0
- package/dist/canonicalize.d.ts +2 -2
- package/dist/canonicalize.js +3 -3
- package/dist/client/client.d.ts +33 -0
- package/dist/client/client.js +123 -0
- package/dist/client/ipc.d.ts +81 -0
- package/dist/client/ipc.js +314 -0
- package/dist/db-adapter/base-adapter.d.ts +6 -66
- package/dist/db-adapter/base-adapter.js +6 -6
- package/dist/db-adapter/index.d.ts +5 -5
- package/dist/db-adapter/index.js +2 -5
- package/dist/db-adapter/node-sqlite-adapter.d.ts +85 -15
- package/dist/db-adapter/node-sqlite-adapter.js +1985 -570
- package/dist/db-manager.d.ts +53 -97
- package/dist/db-manager.js +121 -603
- package/dist/embedding/embedder.d.ts +132 -0
- package/dist/embedding/embedder.js +299 -0
- package/dist/identity/principal-repository.d.ts +2 -2
- package/dist/index.d.ts +43 -58
- package/dist/index.js +97 -145
- package/dist/{context-compile/channel-grant.d.ts → knowledge/access.d.ts} +12 -17
- package/dist/knowledge/access.js +663 -0
- package/dist/knowledge/case-errors.d.ts +31 -0
- package/dist/knowledge/case-errors.js +40 -0
- package/dist/{cases/search-rollup.d.ts → knowledge/case-search-rollup.d.ts} +5 -4
- package/dist/{cases/search-rollup.js → knowledge/case-search-rollup.js} +6 -8
- package/dist/{cases/store.d.ts → knowledge/case-store.d.ts} +3 -6
- package/dist/{cases/store.js → knowledge/case-store.js} +7 -42
- package/dist/{cases/timeline-range.d.ts → knowledge/case-timeline-range.d.ts} +3 -3
- package/dist/{cases/timeline-range.js → knowledge/case-timeline-range.js} +47 -25
- package/dist/{cases/types.d.ts → knowledge/case-types.d.ts} +8 -2
- package/dist/{cases/types.js → knowledge/case-types.js} +1 -1
- package/dist/knowledge/commitment-revision-migration.d.ts +4 -0
- package/dist/knowledge/commitment-revision-migration.js +50 -0
- package/dist/knowledge/commitments.d.ts +192 -0
- package/dist/knowledge/commitments.js +386 -0
- package/dist/knowledge/decision-edges.d.ts +70 -0
- package/dist/knowledge/decision-edges.js +123 -0
- package/dist/{agent-graph/types.d.ts → knowledge/graph-query.d.ts} +80 -70
- package/dist/knowledge/graph-query.js +1585 -0
- package/dist/knowledge/identity.d.ts +16 -0
- package/dist/knowledge/identity.js +22 -0
- package/dist/knowledge/index.d.ts +47 -0
- package/dist/knowledge/index.js +90 -0
- package/dist/knowledge/judgment-edge.d.ts +6 -0
- package/dist/knowledge/judgment-edge.js +22 -0
- package/dist/knowledge/judgments.d.ts +118 -0
- package/dist/knowledge/judgments.js +802 -0
- package/dist/knowledge/observations.d.ts +160 -0
- package/dist/knowledge/observations.js +449 -0
- package/dist/knowledge/question-type.d.ts +34 -0
- package/dist/knowledge/question-type.js +70 -0
- package/dist/{search → knowledge}/ranker-features.js +1 -1
- package/dist/{search → knowledge}/search-quality.d.ts +0 -1
- package/dist/knowledge/search.d.ts +38 -0
- package/dist/knowledge/search.js +91 -0
- package/dist/knowledge/source-ingest.d.ts +65 -0
- package/dist/knowledge/source-ingest.js +174 -0
- package/dist/{edges/types.d.ts → knowledge/twin-edge-types.d.ts} +31 -4
- package/dist/{edges/types.js → knowledge/twin-edge-types.js} +13 -2
- package/dist/knowledge/work-dates.d.ts +49 -0
- package/dist/knowledge/work-dates.js +120 -0
- package/dist/mama-api.d.ts +114 -778
- package/dist/mama-api.js +313 -2461
- package/dist/memory/api.d.ts +264 -24
- package/dist/memory/api.js +1633 -843
- package/dist/memory/bootstrap-builder.d.ts +2 -1
- package/dist/memory/bootstrap-builder.js +5 -5
- package/dist/memory/channel-summary-state-store.d.ts +3 -2
- package/dist/memory/channel-summary-state-store.js +53 -51
- package/dist/memory/channel-summary-store.d.ts +5 -3
- package/dist/memory/channel-summary-store.js +3 -8
- package/dist/memory/dashboard-read.d.ts +46 -0
- package/dist/memory/dashboard-read.js +94 -0
- package/dist/memory/event-store.d.ts +3 -3
- package/dist/memory/event-store.js +3 -10
- package/dist/memory/finding-store.d.ts +3 -2
- package/dist/memory/finding-store.js +2 -7
- package/dist/memory/graph-read.d.ts +52 -0
- package/dist/memory/graph-read.js +130 -0
- package/dist/memory/judgment-types.d.ts +394 -0
- package/dist/memory/judgment-types.js +16 -0
- package/dist/memory/provenance-audit.d.ts +5 -2
- package/dist/memory/provenance-audit.js +8 -14
- package/dist/memory/provenance-live.d.ts +141 -0
- package/dist/memory/provenance-live.js +409 -0
- package/dist/memory/provenance-query.d.ts +5 -4
- package/dist/memory/provenance-query.js +21 -29
- package/dist/memory/provenance-resolver.d.ts +191 -0
- package/dist/memory/provenance-resolver.js +155 -0
- package/dist/memory/provenance.d.ts +1 -11
- package/dist/memory/provenance.js +2 -33
- package/dist/memory/recall-sanitize.d.ts +55 -0
- package/dist/memory/recall-sanitize.js +144 -0
- package/dist/memory/secret-filter.d.ts +32 -0
- package/dist/memory/secret-filter.js +126 -0
- package/dist/memory/truth-store.d.ts +2 -1
- package/dist/memory/truth-store.js +1 -4
- package/dist/memory/types.d.ts +74 -24
- package/dist/memory/types.js +75 -5
- package/dist/memory/write-adapters.d.ts +98 -0
- package/dist/memory/write-adapters.js +242 -0
- package/dist/operations/owner-action-effects.d.ts +53 -0
- package/dist/operations/owner-action-effects.js +96 -0
- package/dist/provenance/source-ref.d.ts +1 -1
- package/dist/provenance/source-ref.js +0 -2
- package/dist/registry/corrections.d.ts +31 -0
- package/dist/registry/corrections.js +332 -0
- package/dist/registry/record-identity.d.ts +49 -0
- package/dist/registry/record-identity.js +133 -0
- package/dist/registry/store.d.ts +101 -0
- package/dist/registry/store.js +395 -0
- package/dist/registry/types.d.ts +28 -0
- package/dist/registry/types.js +5 -0
- package/dist/relevance-scorer.js +2 -2
- package/dist/runtime/agent-event-bus.d.ts +50 -0
- package/dist/runtime/agent-event-bus.js +101 -0
- package/dist/runtime/drivers/claude-cli-wrapper.d.ts +152 -0
- package/dist/runtime/drivers/claude-cli-wrapper.js +375 -0
- package/dist/runtime/drivers/claude-effort.d.ts +4 -0
- package/dist/runtime/drivers/claude-effort.js +16 -0
- package/dist/runtime/drivers/cli-arg-redaction.d.ts +2 -0
- package/dist/runtime/drivers/cli-arg-redaction.js +18 -0
- package/dist/runtime/drivers/cli-secret-redaction.d.ts +17 -0
- package/dist/runtime/drivers/cli-secret-redaction.js +126 -0
- package/dist/runtime/drivers/codex-app-server-process.d.ts +277 -0
- package/dist/runtime/drivers/codex-app-server-process.js +2342 -0
- package/dist/runtime/drivers/codex-auxiliary-tools.d.ts +17 -0
- package/dist/runtime/drivers/codex-auxiliary-tools.js +267 -0
- package/dist/runtime/drivers/codex-home.d.ts +20 -0
- package/dist/runtime/drivers/codex-home.js +674 -0
- package/dist/runtime/drivers/codex-thread-registry.d.ts +63 -0
- package/dist/runtime/drivers/codex-thread-registry.js +433 -0
- package/dist/runtime/drivers/persistent-cli-adapter.d.ts +160 -0
- package/dist/runtime/drivers/persistent-cli-adapter.js +396 -0
- package/dist/runtime/drivers/persistent-cli-process.d.ts +425 -0
- package/dist/runtime/drivers/persistent-cli-process.js +1529 -0
- package/dist/runtime/drivers/types.d.ts +456 -0
- package/dist/runtime/drivers/types.js +110 -0
- package/dist/runtime/mailbox.d.ts +223 -0
- package/dist/runtime/mailbox.js +582 -0
- package/dist/runtime/model-run-store.d.ts +28 -0
- package/dist/{model-runs/store.js → runtime/model-run-store.js} +81 -41
- package/dist/{model-runs/types.d.ts → runtime/model-run-types.d.ts} +33 -4
- package/dist/{model-runs/types.js → runtime/model-run-types.js} +1 -1
- package/dist/runtime/native-effect-observer.d.ts +22 -0
- package/dist/runtime/native-effect-observer.js +103 -0
- package/dist/runtime/native-input-journal.d.ts +46 -0
- package/dist/runtime/native-input-journal.js +308 -0
- package/dist/runtime/native-prompt.d.ts +118 -0
- package/dist/runtime/native-prompt.js +496 -0
- package/dist/runtime/native-session.d.ts +10 -0
- package/dist/{agent-graph/index.js → runtime/native-session.js} +9 -6
- package/dist/runtime/native-tool-trace-observer.d.ts +5 -0
- package/dist/runtime/native-tool-trace-observer.js +65 -0
- package/dist/runtime/native-turn.d.ts +272 -0
- package/dist/runtime/native-turn.js +1041 -0
- package/dist/runtime/operations.d.ts +236 -0
- package/dist/runtime/operations.js +565 -0
- package/dist/runtime/post-tool-handler.d.ts +74 -0
- package/dist/runtime/post-tool-handler.js +137 -0
- package/dist/runtime/prompt-layers.d.ts +126 -0
- package/dist/runtime/prompt-layers.js +239 -0
- package/dist/runtime/runtime-process.d.ts +102 -0
- package/dist/runtime/runtime-process.js +206 -0
- package/dist/runtime/runtime.d.ts +278 -0
- package/dist/runtime/runtime.js +563 -0
- package/dist/runtime/session-pool.d.ts +176 -0
- package/dist/runtime/session-pool.js +369 -0
- package/dist/runtime/stimulus-payload.d.ts +5 -0
- package/dist/runtime/stimulus-payload.js +50 -0
- package/dist/runtime/subagent-bridge.d.ts +24 -0
- package/dist/{agent-graph/types.js → runtime/subagent-bridge.js} +1 -1
- package/dist/runtime/text-completion.d.ts +22 -0
- package/dist/{agent-situation/types.js → runtime/text-completion.js} +1 -1
- package/dist/runtime/token-estimator.d.ts +25 -0
- package/dist/runtime/token-estimator.js +75 -0
- package/dist/runtime/tool-trace-store.d.ts +22 -0
- package/dist/{model-runs → runtime}/tool-trace-store.js +46 -27
- package/dist/runtime/trace-summary.d.ts +5 -0
- package/dist/runtime/trace-summary.js +74 -0
- package/dist/runtime/turn-text.d.ts +23 -0
- package/dist/runtime/turn-text.js +41 -0
- package/dist/storage/database.d.ts +67 -0
- package/dist/storage/database.js +158 -0
- package/package.json +20 -34
- package/dist/agent-graph/alias-write.d.ts +0 -3
- package/dist/agent-graph/alias-write.js +0 -234
- package/dist/agent-graph/entity-resolve.d.ts +0 -3
- package/dist/agent-graph/entity-resolve.js +0 -271
- package/dist/agent-graph/errors.d.ts +0 -4
- package/dist/agent-graph/errors.js +0 -11
- package/dist/agent-graph/graph-query.d.ts +0 -5
- package/dist/agent-graph/graph-query.js +0 -360
- package/dist/agent-graph/index.d.ts +0 -6
- package/dist/agent-situation/builder.d.ts +0 -8
- package/dist/agent-situation/builder.js +0 -239
- package/dist/agent-situation/cache-key.d.ts +0 -4
- package/dist/agent-situation/cache-key.js +0 -64
- package/dist/agent-situation/index.d.ts +0 -7
- package/dist/agent-situation/index.js +0 -28
- package/dist/agent-situation/packet-store.d.ts +0 -27
- package/dist/agent-situation/packet-store.js +0 -228
- package/dist/agent-situation/ranking-policy.d.ts +0 -18
- package/dist/agent-situation/ranking-policy.js +0 -75
- package/dist/agent-situation/source-readers.d.ts +0 -52
- package/dist/agent-situation/source-readers.js +0 -300
- package/dist/agent-situation/types.d.ts +0 -195
- package/dist/cases/wiki-page-index.d.ts +0 -37
- package/dist/cases/wiki-page-index.js +0 -201
- package/dist/config-loader.d.ts +0 -68
- package/dist/config-loader.js +0 -239
- package/dist/connectors/event-index.d.ts +0 -24
- package/dist/connectors/event-index.js +0 -245
- package/dist/connectors/raw-query.d.ts +0 -40
- package/dist/connectors/raw-query.js +0 -412
- package/dist/connectors/types.d.ts +0 -117
- package/dist/connectors/types.js +0 -3
- package/dist/context-compile/boundary-defaults.d.ts +0 -12
- package/dist/context-compile/boundary-defaults.js +0 -105
- package/dist/context-compile/channel-grant.js +0 -66
- package/dist/context-compile/compiler-policy.d.ts +0 -39
- package/dist/context-compile/compiler-policy.js +0 -147
- package/dist/context-compile/compiler.d.ts +0 -18
- package/dist/context-compile/compiler.js +0 -404
- package/dist/context-compile/index.d.ts +0 -10
- package/dist/context-compile/index.js +0 -26
- package/dist/context-compile/packet-store.d.ts +0 -8
- package/dist/context-compile/packet-store.js +0 -239
- package/dist/context-compile/ref.d.ts +0 -7
- package/dist/context-compile/ref.js +0 -102
- package/dist/context-compile/source-readers.d.ts +0 -70
- package/dist/context-compile/source-readers.js +0 -840
- package/dist/context-compile/types.d.ts +0 -155
- package/dist/context-compile/types.js +0 -11
- package/dist/context-compile/visibility.d.ts +0 -21
- package/dist/context-compile/visibility.js +0 -224
- package/dist/decision-tracker.d.ts +0 -206
- package/dist/decision-tracker.js +0 -481
- package/dist/edges/ref-validation.d.ts +0 -7
- package/dist/edges/ref-validation.js +0 -321
- package/dist/edges/store.d.ts +0 -8
- package/dist/edges/store.js +0 -129
- package/dist/embedding-client.d.ts +0 -28
- package/dist/embedding-client.js +0 -53
- package/dist/embedding-server/index.d.ts +0 -67
- package/dist/embedding-server/index.js +0 -405
- package/dist/embedding-server/mobile/auth.d.ts +0 -44
- package/dist/embedding-server/mobile/auth.js +0 -150
- package/dist/embedding-server/mobile/daemon.d.ts +0 -129
- package/dist/embedding-server/mobile/daemon.js +0 -313
- package/dist/embedding-server/mobile/output-parser.d.ts +0 -115
- package/dist/embedding-server/mobile/output-parser.js +0 -241
- package/dist/embedding-server/mobile/session-api.d.ts +0 -57
- package/dist/embedding-server/mobile/session-api.js +0 -261
- package/dist/embedding-server/mobile/session-manager.d.ts +0 -138
- package/dist/embedding-server/mobile/session-manager.js +0 -378
- package/dist/embedding-server/mobile/websocket-handler.d.ts +0 -137
- package/dist/embedding-server/mobile/websocket-handler.js +0 -486
- package/dist/embeddings.d.ts +0 -68
- package/dist/embeddings.js +0 -244
- package/dist/entities/audit-metrics.d.ts +0 -68
- package/dist/entities/audit-metrics.js +0 -124
- package/dist/entities/candidate-generator.d.ts +0 -8
- package/dist/entities/candidate-generator.js +0 -24
- package/dist/entities/entity-linked-decision-counts.d.ts +0 -2
- package/dist/entities/entity-linked-decision-counts.js +0 -29
- package/dist/entities/entity-list.d.ts +0 -22
- package/dist/entities/entity-list.js +0 -3
- package/dist/entities/entity-orphan-list.d.ts +0 -17
- package/dist/entities/entity-orphan-list.js +0 -3
- package/dist/entities/entity-search.d.ts +0 -20
- package/dist/entities/entity-search.js +0 -3
- package/dist/entities/errors.d.ts +0 -55
- package/dist/entities/errors.js +0 -100
- package/dist/entities/lineage-store.d.ts +0 -28
- package/dist/entities/lineage-store.js +0 -204
- package/dist/entities/normalization.d.ts +0 -14
- package/dist/entities/normalization.js +0 -63
- package/dist/entities/policy-store.d.ts +0 -8
- package/dist/entities/policy-store.js +0 -75
- package/dist/entities/policy-types.d.ts +0 -72
- package/dist/entities/policy-types.js +0 -59
- package/dist/entities/projection.d.ts +0 -8
- package/dist/entities/projection.js +0 -82
- package/dist/entities/provenance-query.d.ts +0 -32
- package/dist/entities/provenance-query.js +0 -3
- package/dist/entities/read-identity.d.ts +0 -31
- package/dist/entities/read-identity.js +0 -264
- package/dist/entities/recall-bridge.d.ts +0 -5
- package/dist/entities/recall-bridge.js +0 -171
- package/dist/entities/resolution-engine.d.ts +0 -8
- package/dist/entities/resolution-engine.js +0 -3
- package/dist/entities/rollback-preview.d.ts +0 -35
- package/dist/entities/rollback-preview.js +0 -3
- package/dist/entities/source-locator.d.ts +0 -3
- package/dist/entities/source-locator.js +0 -32
- package/dist/entities/store.d.ts +0 -69
- package/dist/entities/store.js +0 -544
- package/dist/entities/types.d.ts +0 -166
- package/dist/entities/types.js +0 -30
- package/dist/memory/extraction-prompt.d.ts +0 -4
- package/dist/memory/extraction-prompt.js +0 -89
- package/dist/memory/scope-backfill.d.ts +0 -14
- package/dist/memory/scope-backfill.js +0 -3
- package/dist/memory/scope-store.d.ts +0 -4
- package/dist/memory/scope-store.js +0 -9
- package/dist/memory-store.d.ts +0 -87
- package/dist/memory-store.js +0 -78
- package/dist/model-runs/store.d.ts +0 -13
- package/dist/model-runs/tool-trace-store.d.ts +0 -8
- package/dist/notification-manager.d.ts +0 -7
- package/dist/notification-manager.js +0 -12
- package/dist/outcome-tracker.d.ts +0 -151
- package/dist/outcome-tracker.js +0 -271
- package/dist/query-intent.d.ts +0 -23
- package/dist/query-intent.js +0 -114
- package/dist/runtime/trusted-provenance.d.ts +0 -3
- package/dist/runtime/trusted-provenance.js +0 -6
- package/dist/search/question-type.d.ts +0 -5
- package/dist/search/question-type.js +0 -41
- package/dist/test-utils.d.ts +0 -80
- package/dist/test-utils.js +0 -218
- package/dist/tier-validator.d.ts +0 -43
- package/dist/tier-validator.js +0 -159
- package/dist/time-formatter.d.ts +0 -25
- package/dist/time-formatter.js +0 -93
- /package/dist/{search → knowledge}/feedback-store.d.ts +0 -0
- /package/dist/{search → knowledge}/feedback-store.js +0 -0
- /package/dist/{search → knowledge}/ranker-features.d.ts +0 -0
- /package/dist/{search → knowledge}/ranker-rescore.d.ts +0 -0
- /package/dist/{search → knowledge}/ranker-rescore.js +0 -0
- /package/dist/{search → knowledge}/ranker-trainer.d.ts +0 -0
- /package/dist/{search → knowledge}/ranker-trainer.js +0 -0
- /package/dist/{search → knowledge}/search-quality.js +0 -0
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The harness protocol — what a model runtime and this system say to each
|
|
3
|
+
* other.
|
|
4
|
+
*
|
|
5
|
+
* These names were split out of the product's agent/types.ts and
|
|
6
|
+
* model-runner.ts so the drivers beside this file could move without dragging
|
|
7
|
+
* the twenty-two file closure those two modules sit in. The product keeps both
|
|
8
|
+
* modules and re-exports these from here, so there is one definition.
|
|
9
|
+
*
|
|
10
|
+
* Nothing here knows a product: a tool exchange, a prompt, a runner's metrics
|
|
11
|
+
* and the errors a host tool can raise are the same shapes whichever daemon
|
|
12
|
+
* opens the session.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Tool use content block (Claude requesting tool execution)
|
|
16
|
+
*/
|
|
17
|
+
export interface PromptTerminalError {
|
|
18
|
+
code: 'MUTATION_COMMITTED_AFTER_ABORT' | 'MUTATION_OUTCOME_UNKNOWN' | 'TOOL_CONTRACT_REPEAT';
|
|
19
|
+
message: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Common response shape passed to onFinal callbacks.
|
|
23
|
+
* Both PersistentCLI and Codex app-server normalize their output to this format.
|
|
24
|
+
*/
|
|
25
|
+
export interface PromptFinalResponse {
|
|
26
|
+
content: string;
|
|
27
|
+
toolUseBlocks: ToolUseBlock[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Backend type identifier.
|
|
31
|
+
*/
|
|
32
|
+
export type HostToolJsonValue = null | boolean | number | string | HostToolJsonValue[] | {
|
|
33
|
+
[key: string]: HostToolJsonValue;
|
|
34
|
+
};
|
|
35
|
+
export type BackendType = 'claude' | 'codex';
|
|
36
|
+
/** Native acknowledgement only: neither model completion nor an effect receipt. */
|
|
37
|
+
export type NativeInputReceipt = {
|
|
38
|
+
backend: 'codex';
|
|
39
|
+
sessionId: string;
|
|
40
|
+
turnId: string;
|
|
41
|
+
} | {
|
|
42
|
+
backend: 'claude';
|
|
43
|
+
sessionId: string;
|
|
44
|
+
inputId: string;
|
|
45
|
+
};
|
|
46
|
+
/** The caller's stable invocation ID and native address, recorded before transport write. */
|
|
47
|
+
export interface NativeInputDispatch {
|
|
48
|
+
backend: BackendType;
|
|
49
|
+
sessionId: string;
|
|
50
|
+
inputId: string;
|
|
51
|
+
}
|
|
52
|
+
export declare class NativeInputUncertainError extends Error {
|
|
53
|
+
readonly target: NativeInputReceipt | NativeInputDispatch;
|
|
54
|
+
readonly retryable = false;
|
|
55
|
+
readonly code = "NATIVE_INPUT_UNCERTAIN";
|
|
56
|
+
constructor(message: string, target: NativeInputReceipt | NativeInputDispatch, cause?: unknown);
|
|
57
|
+
}
|
|
58
|
+
/** The exact steering target vanished before anything was written to native transport. */
|
|
59
|
+
export declare class NativeSteeringTargetUnavailableError extends Error {
|
|
60
|
+
readonly code = "NATIVE_STEERING_TARGET_UNAVAILABLE";
|
|
61
|
+
constructor();
|
|
62
|
+
}
|
|
63
|
+
export interface HostToolInputSchema {
|
|
64
|
+
readonly type: 'object';
|
|
65
|
+
readonly properties: Readonly<Record<string, HostToolJsonValue>>;
|
|
66
|
+
readonly required?: readonly string[];
|
|
67
|
+
readonly additionalProperties: boolean;
|
|
68
|
+
readonly oneOf?: readonly HostToolJsonValue[];
|
|
69
|
+
}
|
|
70
|
+
/** A dynamic function call received from the model host. */
|
|
71
|
+
export interface HostToolCall {
|
|
72
|
+
callId: string;
|
|
73
|
+
name: string;
|
|
74
|
+
input: Record<string, unknown>;
|
|
75
|
+
/** Aborted when the owning model turn fails, times out, or is disconnected. */
|
|
76
|
+
signal?: AbortSignal;
|
|
77
|
+
}
|
|
78
|
+
export type HostToolTerminalCode = 'MUTATION_COMMITTED_AFTER_ABORT' | 'MUTATION_OUTCOME_UNKNOWN' | 'TOOL_CONTRACT_REPEAT';
|
|
79
|
+
export interface ToolUseBlock {
|
|
80
|
+
type: 'tool_use';
|
|
81
|
+
id: string;
|
|
82
|
+
name: string;
|
|
83
|
+
input: Record<string, unknown>;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Tool result content block (response to tool_use)
|
|
87
|
+
*/
|
|
88
|
+
export interface ToolResultBlock {
|
|
89
|
+
type: 'tool_result';
|
|
90
|
+
tool_use_id: string;
|
|
91
|
+
content: string;
|
|
92
|
+
is_error?: boolean;
|
|
93
|
+
}
|
|
94
|
+
export interface CompletedToolExchange {
|
|
95
|
+
toolUse: ToolUseBlock;
|
|
96
|
+
toolResult: ToolResultBlock;
|
|
97
|
+
}
|
|
98
|
+
export interface PromptResult {
|
|
99
|
+
response: string;
|
|
100
|
+
usage: {
|
|
101
|
+
input_tokens: number;
|
|
102
|
+
output_tokens: number;
|
|
103
|
+
cache_creation_input_tokens?: number;
|
|
104
|
+
cache_read_input_tokens?: number;
|
|
105
|
+
};
|
|
106
|
+
session_id: string;
|
|
107
|
+
cost_usd?: number;
|
|
108
|
+
/** Only tool uses that still require host execution. */
|
|
109
|
+
toolUseBlocks?: ToolUseBlock[];
|
|
110
|
+
hasToolUse?: boolean;
|
|
111
|
+
/** Host-completed MCP exchanges observed on the Claude stream, in result order. */
|
|
112
|
+
completedToolExchanges?: CompletedToolExchange[];
|
|
113
|
+
/** Trusted terminal mutation outcome decoded from a completed local MCP exchange. */
|
|
114
|
+
terminalError?: PromptTerminalError;
|
|
115
|
+
duration_ms?: number;
|
|
116
|
+
}
|
|
117
|
+
export declare class ClaudeToolStreamProtocolError extends Error {
|
|
118
|
+
readonly code = "CLAUDE_TOOL_STREAM_PROTOCOL";
|
|
119
|
+
constructor(message: string);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Callbacks for PersistentCLI / Codex app-server prompt calls.
|
|
123
|
+
* Shared across all backend adapters to avoid duplicate definitions.
|
|
124
|
+
*/
|
|
125
|
+
export interface PromptCallbacks {
|
|
126
|
+
/** Must complete before the driver writes this input to the native transport. */
|
|
127
|
+
onInputDispatch?: (input: NativeInputDispatch) => void;
|
|
128
|
+
/** Emitted from the native input acknowledgement, before its final result. */
|
|
129
|
+
onAccepted?: (receipt: NativeInputReceipt) => void;
|
|
130
|
+
onDelta?: (text: string) => void;
|
|
131
|
+
onToolUse?: (name: string, input: Record<string, unknown>) => void;
|
|
132
|
+
/** unknown means the child ended without a matching tool result. */
|
|
133
|
+
onToolComplete?: (tool: string, toolUseId: string, isError: boolean, outcome?: 'unknown') => void;
|
|
134
|
+
/**
|
|
135
|
+
* A native subagent was announced on this run's own thread. Admission, not an
|
|
136
|
+
* external effect: it deliberately does NOT travel through onToolUse, because
|
|
137
|
+
* onToolUse writes a `native_tool` row into the owner effect ledger and any such
|
|
138
|
+
* row marks the occurrence unsafe to replay. A spawn must never do that.
|
|
139
|
+
*/
|
|
140
|
+
onSubagentStart?: (info: {
|
|
141
|
+
agentThreadId: string;
|
|
142
|
+
agentPath: string;
|
|
143
|
+
itemId: string;
|
|
144
|
+
}) => void;
|
|
145
|
+
/**
|
|
146
|
+
* The runner's OWN later turn answered on behalf of this request: the CLI's follow-up
|
|
147
|
+
* after a child spawned here finished, or after a task notification no tracked child
|
|
148
|
+
* claimed. That text is a later answer to the same request and must reach whoever asked;
|
|
149
|
+
* measured 2026-09-10 it otherwise had no reader.
|
|
150
|
+
*/
|
|
151
|
+
onFollowUp?: (info: {
|
|
152
|
+
agentThreadId: string;
|
|
153
|
+
agentPath: string;
|
|
154
|
+
itemId: string;
|
|
155
|
+
text: string;
|
|
156
|
+
isError: boolean;
|
|
157
|
+
}) => void;
|
|
158
|
+
onFinal?: (response: PromptFinalResponse) => void;
|
|
159
|
+
onError?: (error: Error) => void;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Token usage record for tracking API consumption
|
|
163
|
+
*/
|
|
164
|
+
export interface TokenUsageRecord {
|
|
165
|
+
channel_key: string;
|
|
166
|
+
agent_id?: string;
|
|
167
|
+
agent_version?: number;
|
|
168
|
+
input_tokens: number;
|
|
169
|
+
output_tokens: number;
|
|
170
|
+
cache_read_tokens?: number;
|
|
171
|
+
cost_usd?: number;
|
|
172
|
+
}
|
|
173
|
+
/** Codex app-server dynamic function definition. */
|
|
174
|
+
export interface HostToolDefinition {
|
|
175
|
+
type: 'function';
|
|
176
|
+
name: string;
|
|
177
|
+
description: string;
|
|
178
|
+
inputSchema: HostToolInputSchema;
|
|
179
|
+
}
|
|
180
|
+
/** Serialized result returned to the model host. */
|
|
181
|
+
export interface HostToolCallResult {
|
|
182
|
+
content: string;
|
|
183
|
+
isError: boolean;
|
|
184
|
+
stop?: boolean;
|
|
185
|
+
/** Fail the active model turn after returning this error result to the host. */
|
|
186
|
+
abort?: boolean;
|
|
187
|
+
/** Trusted host-tool terminal code; never derived from model-visible text. */
|
|
188
|
+
terminalCode?: HostToolTerminalCode;
|
|
189
|
+
}
|
|
190
|
+
/** Tools and executor scoped to one prompt run. */
|
|
191
|
+
export interface HostToolBridge {
|
|
192
|
+
readonly tools: readonly HostToolDefinition[];
|
|
193
|
+
execute(call: HostToolCall): Promise<HostToolCallResult>;
|
|
194
|
+
}
|
|
195
|
+
export declare function isHostToolTerminalCode(value: unknown): value is HostToolTerminalCode;
|
|
196
|
+
/** Typed transport for a trusted host-tool terminal result across model runtimes. */
|
|
197
|
+
export declare class HostToolTerminalError extends Error {
|
|
198
|
+
readonly terminalCode: HostToolTerminalCode;
|
|
199
|
+
readonly completedToolExchanges?: readonly CompletedToolExchange[] | undefined;
|
|
200
|
+
readonly retryable = false;
|
|
201
|
+
constructor(terminalCode: HostToolTerminalCode, message: string, completedToolExchanges?: readonly CompletedToolExchange[] | undefined);
|
|
202
|
+
}
|
|
203
|
+
/** A host tool deliberately stopped a run without claiming a terminal mutation outcome. */
|
|
204
|
+
export declare class HostToolAbortError extends Error {
|
|
205
|
+
readonly completedToolExchanges: readonly CompletedToolExchange[];
|
|
206
|
+
readonly retryable = false;
|
|
207
|
+
constructor(message: string, completedToolExchanges: readonly CompletedToolExchange[]);
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Options passed to prompt() that are backend-agnostic.
|
|
211
|
+
*/
|
|
212
|
+
export interface PromptOptions {
|
|
213
|
+
/** Called after the backend settles its actual session, before any input is dispatched. */
|
|
214
|
+
preparePrompt?: (session: NativeSessionState) => Promise<string>;
|
|
215
|
+
/** Stable, caller-persisted native invocation UUID; not the model session routing key. */
|
|
216
|
+
nativeInputId?: string;
|
|
217
|
+
model?: string;
|
|
218
|
+
resumeSession?: boolean;
|
|
219
|
+
allowedTools?: string[];
|
|
220
|
+
disallowedTools?: string[];
|
|
221
|
+
/** Allow the backend's native single-agent delegation primitive for this route. */
|
|
222
|
+
allowSpawnAgent?: boolean;
|
|
223
|
+
/** Allow the backend's native multi-agent team primitive for this route. */
|
|
224
|
+
allowAgentTeams?: boolean;
|
|
225
|
+
/**
|
|
226
|
+
* Per-call Claude builtin tool set (--tools) resolved from this turn's role.
|
|
227
|
+
* Undefined keeps the pool's construction-time default; '' means no builtins.
|
|
228
|
+
*/
|
|
229
|
+
tools?: string;
|
|
230
|
+
hostToolBridge?: HostToolBridge;
|
|
231
|
+
/** Per-run counted-token budget; enforced inside a codex turn (see CodexAppServerProcess). */
|
|
232
|
+
runTokenBudget?: number;
|
|
233
|
+
systemPrompt?: string;
|
|
234
|
+
/** Native working directory for this call; a restricted thread keeps it inside its read roots. */
|
|
235
|
+
cwd?: string;
|
|
236
|
+
/** Stable source/channel route used by persistent backends across daemon restarts. */
|
|
237
|
+
sessionKey?: string;
|
|
238
|
+
/** Stable identity/rules fingerprint, excluding dynamic conversation context. */
|
|
239
|
+
sessionPolicyFingerprint?: string;
|
|
240
|
+
/** Optional native thread/turn read boundary. The host states real roots. */
|
|
241
|
+
restrictedReadRoots?: readonly string[];
|
|
242
|
+
/**
|
|
243
|
+
* Pool ROUTING key (SessionPool id) for THIS call, NOT the CLI --session-id.
|
|
244
|
+
* The pool spawns processes with its own randomUUID() so the CLI never
|
|
245
|
+
* reloads disk history. Routes this prompt to this session's process
|
|
246
|
+
* without mutating shared adapter state.
|
|
247
|
+
*/
|
|
248
|
+
sessionId?: string;
|
|
249
|
+
/**
|
|
250
|
+
* Per-call CLI request timeout (ms) applied when this call spawns a fresh
|
|
251
|
+
* pooled process. Undefined leaves the pool's construction-time default in
|
|
252
|
+
* place, so only callers that opt in (operator worker runs) are affected.
|
|
253
|
+
*/
|
|
254
|
+
requestTimeout?: number;
|
|
255
|
+
/** Host-issued authority for this exact prompt attempt; persistent Claude binds it to MCP. */
|
|
256
|
+
/**
|
|
257
|
+
* Host-issued authority for this exact prompt attempt. A driver carries it
|
|
258
|
+
* to the tool bridge and reads exactly one field off it — the owning turn's
|
|
259
|
+
* cancellation — so that is all the protocol states. The rest of the shape
|
|
260
|
+
* belongs to whoever composes it.
|
|
261
|
+
*/
|
|
262
|
+
toolExecutionContext?: HostExecutionContext | null;
|
|
263
|
+
/**
|
|
264
|
+
* Rebuilds the FULL instructions for a backend that has to rehydrate a durable
|
|
265
|
+
* session on this call. Codex re-anchors the resumed thread with them
|
|
266
|
+
* (thread/resume accepts baseInstructions) instead of replaying a per-call prompt
|
|
267
|
+
* as user text. Lazy: backends invoke it only when a resume actually happens, so
|
|
268
|
+
* live sessions never pay the rebuild.
|
|
269
|
+
*/
|
|
270
|
+
resumeInstructions?: () => Promise<string>;
|
|
271
|
+
/** Measurement only: host lane and brief state for the per-turn [prompt] log line. */
|
|
272
|
+
promptTelemetry?: {
|
|
273
|
+
kind: string;
|
|
274
|
+
brief: 'sent' | 'omitted';
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
export type SessionPolicyStatus = 'missing' | 'compatible' | 'mismatch';
|
|
278
|
+
/** Actual native context, not the host's session-pool routing hint. */
|
|
279
|
+
export interface NativeSessionState {
|
|
280
|
+
sessionId: string;
|
|
281
|
+
isNewSession: boolean;
|
|
282
|
+
}
|
|
283
|
+
/** The native protocol explicitly rejected resumption because its context no longer exists. */
|
|
284
|
+
export declare class NativeSessionUnavailableError extends Error {
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Runtime metrics collected by a model runner.
|
|
288
|
+
*/
|
|
289
|
+
export interface RunnerMetrics {
|
|
290
|
+
requestCount: number;
|
|
291
|
+
failureCount: number;
|
|
292
|
+
avgLatencyMs: number;
|
|
293
|
+
lastRequestAt: number | null;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Standardized error categories for backend failures.
|
|
297
|
+
*/
|
|
298
|
+
export type ModelRunnerErrorCode = 'timeout' | 'crash' | 'context_overflow' | 'auth_failure' | 'rate_limit' | 'unknown';
|
|
299
|
+
/**
|
|
300
|
+
* Typed error thrown by IModelRunner implementations.
|
|
301
|
+
*/
|
|
302
|
+
export declare class ModelRunnerError extends Error {
|
|
303
|
+
readonly code: ModelRunnerErrorCode;
|
|
304
|
+
readonly retryable: boolean;
|
|
305
|
+
constructor(message: string, code: ModelRunnerErrorCode, retryable?: boolean);
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Unified model runner interface.
|
|
309
|
+
*
|
|
310
|
+
* Both PersistentCLIAdapter (Claude) and CodexRuntimeProcess (Codex)
|
|
311
|
+
* implement this contract so AgentLoop is backend-agnostic.
|
|
312
|
+
*/
|
|
313
|
+
export interface IModelRunner {
|
|
314
|
+
/** Backend identifier */
|
|
315
|
+
readonly backendType: BackendType;
|
|
316
|
+
/**
|
|
317
|
+
* Whether THIS runner can spawn a native subagent the host can observe.
|
|
318
|
+
*
|
|
319
|
+
* A contract that asks for delegation is only honest on a runner that has the primitive
|
|
320
|
+
* AND a spawn observation path: codex app-server has both (`onSubagentStart`). The
|
|
321
|
+
* persistent Claude CLI persona runs with `--tools ""` (no native Agent tool) and has no
|
|
322
|
+
* subagent stream, and some adapters have neither - on those, a "spawn one subagent"
|
|
323
|
+
* instruction can only be wasted steps or a reported failure. Read this capability rather
|
|
324
|
+
* than string-matching a backend name.
|
|
325
|
+
*/
|
|
326
|
+
readonly supportsNativeSubagents: boolean;
|
|
327
|
+
/**
|
|
328
|
+
* Whether a turn on THIS runner can be recorded as a model run.
|
|
329
|
+
*
|
|
330
|
+
* Absent or true means yes, which is the ordinary case: the record is the host's
|
|
331
|
+
* ledger entry about a turn that happened, so anything that actually runs one can
|
|
332
|
+
* be recorded. A runner sets this false only when it truthfully cannot stand behind
|
|
333
|
+
* a run - a double that returns canned text, for instance.
|
|
334
|
+
*
|
|
335
|
+
* It is stated HERE, by the driver, and nowhere else. It used to be inferred from
|
|
336
|
+
* whether the consumer's tools reached the host through a gateway, which is a fact
|
|
337
|
+
* about tool routing and not about whether a turn happened: the installed Claude
|
|
338
|
+
* MCP backend ran six tools, sent an owner report, and left the delivery unable to
|
|
339
|
+
* name the run that wrote it (`no_run_handle`, 2026-09-22).
|
|
340
|
+
*/
|
|
341
|
+
readonly reportsModelRuns?: boolean;
|
|
342
|
+
/** Send a prompt and receive a response */
|
|
343
|
+
prompt(content: string, callbacks?: PromptCallbacks, options?: PromptOptions): Promise<PromptResult>;
|
|
344
|
+
/** Only a native steering primitive may implement this; do not emulate it with another prompt. */
|
|
345
|
+
steer?(content: string, target: NativeInputReceipt, options?: Pick<PromptOptions, 'sessionKey' | 'sessionId'> & {
|
|
346
|
+
beforeSend?: () => void;
|
|
347
|
+
}): Promise<NativeInputReceipt>;
|
|
348
|
+
/** Read-only durable-session policy preflight. Codex uses this to rotate before a request. */
|
|
349
|
+
getSessionPolicyStatus?(options: PromptOptions): SessionPolicyStatus;
|
|
350
|
+
/** Retire one exact routed backend session before replacing its authority policy. */
|
|
351
|
+
resetSession?(sessionId?: string, sessionKey?: string): void | Promise<void>;
|
|
352
|
+
/** Set the session/channel ID */
|
|
353
|
+
setSessionId(id: string): void;
|
|
354
|
+
/** Set or update the system prompt (affects new processes only) */
|
|
355
|
+
setSystemPrompt(prompt: string): void;
|
|
356
|
+
/**
|
|
357
|
+
* Send a tool result back to the model (Claude-specific).
|
|
358
|
+
* Optional: Codex backends may leave this unimplemented.
|
|
359
|
+
*/
|
|
360
|
+
sendToolResult?(toolUseId: string, result: string, isError?: boolean, callbacks?: PromptCallbacks): Promise<PromptResult>;
|
|
361
|
+
/** Check if the runner is alive and ready to accept prompts */
|
|
362
|
+
isHealthy(): boolean;
|
|
363
|
+
/** Collect runtime metrics */
|
|
364
|
+
getMetrics(): RunnerMetrics;
|
|
365
|
+
/** Gracefully stop all processes */
|
|
366
|
+
stop(): void | Promise<void>;
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* The host's per-attempt authority as anything below the host sees it: an
|
|
370
|
+
* opaque record that carries the owning turn's cancellation. A driver or a
|
|
371
|
+
* hook hands it on and reads nothing else off it, so the rest of the shape
|
|
372
|
+
* stays with whoever composes it.
|
|
373
|
+
*/
|
|
374
|
+
export type HostExecutionContext = {
|
|
375
|
+
signal?: AbortSignal;
|
|
376
|
+
} & Record<string, unknown>;
|
|
377
|
+
export type AgentErrorCode = 'API_ERROR' | 'CLI_ERROR' | 'AGENT_STOPPED' | 'AUTH_ERROR' | 'RATE_LIMIT' | 'MAX_TOKENS' | 'MAX_TURNS' | 'EMERGENCY_MAX_TURNS' | 'INFINITE_LOOP_DETECTED' | 'NETWORK_ERROR' | 'TOOL_ERROR' | 'UNKNOWN_TOOL' | 'INVALID_RESPONSE' | 'ENVELOPE_EXPIRED' | 'WORKORDER_SUPERSEDED' | 'CLAUDE_TOOL_STREAM_PROTOCOL' | 'MUTATION_COMMITTED_AFTER_ABORT' | 'MUTATION_OUTCOME_UNKNOWN' | 'TOOL_CONTRACT_REPEAT' | 'relationship_target_unavailable';
|
|
378
|
+
/**
|
|
379
|
+
* A failure raised anywhere on the harness path. The code is what a caller
|
|
380
|
+
* reads; `retryable` says whether trying again could differ.
|
|
381
|
+
*/
|
|
382
|
+
export declare class AgentError extends Error {
|
|
383
|
+
readonly code: AgentErrorCode;
|
|
384
|
+
readonly cause?: Error | undefined;
|
|
385
|
+
readonly retryable: boolean;
|
|
386
|
+
constructor(message: string, code: AgentErrorCode, cause?: Error | undefined, retryable?: boolean);
|
|
387
|
+
}
|
|
388
|
+
export type MessageRole = 'user' | 'assistant';
|
|
389
|
+
export interface TextBlock {
|
|
390
|
+
type: 'text';
|
|
391
|
+
text: string;
|
|
392
|
+
}
|
|
393
|
+
/** Image source for base64 encoded images. */
|
|
394
|
+
export interface ImageSourceBase64 {
|
|
395
|
+
type: 'base64';
|
|
396
|
+
media_type: 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp';
|
|
397
|
+
data: string;
|
|
398
|
+
}
|
|
399
|
+
/** Image content block for multimodal input. */
|
|
400
|
+
export interface ImageBlock {
|
|
401
|
+
type: 'image';
|
|
402
|
+
source: ImageSourceBase64;
|
|
403
|
+
}
|
|
404
|
+
/** Document content block for document understanding. */
|
|
405
|
+
export interface DocumentBlock {
|
|
406
|
+
type: 'document';
|
|
407
|
+
source: {
|
|
408
|
+
type: 'base64';
|
|
409
|
+
media_type: string;
|
|
410
|
+
data: string;
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
export type ContentBlock = TextBlock | ImageBlock | DocumentBlock | ToolUseBlock | ToolResultBlock;
|
|
414
|
+
/** One message in conversation history. */
|
|
415
|
+
export interface Message {
|
|
416
|
+
role: MessageRole;
|
|
417
|
+
content: ContentBlock[] | string;
|
|
418
|
+
}
|
|
419
|
+
/** Why the model stopped producing this turn. */
|
|
420
|
+
export type StopReason = 'end_turn' | 'tool_use' | 'max_tokens' | 'stop_sequence';
|
|
421
|
+
/** Token accounting one turn reports back. */
|
|
422
|
+
export interface Usage {
|
|
423
|
+
input_tokens: number;
|
|
424
|
+
output_tokens: number;
|
|
425
|
+
cache_creation_input_tokens?: number;
|
|
426
|
+
cache_read_input_tokens?: number;
|
|
427
|
+
cost_usd?: number;
|
|
428
|
+
}
|
|
429
|
+
/** One assistant response as the harness hands it back. */
|
|
430
|
+
export interface ClaudeResponse {
|
|
431
|
+
id: string;
|
|
432
|
+
type: 'message';
|
|
433
|
+
role: 'assistant';
|
|
434
|
+
content: ContentBlock[];
|
|
435
|
+
model: string;
|
|
436
|
+
stop_reason: StopReason;
|
|
437
|
+
stop_sequence: string | null;
|
|
438
|
+
usage: Usage;
|
|
439
|
+
}
|
|
440
|
+
/** What a turn observer is told about a turn that just finished. */
|
|
441
|
+
export interface TurnInfo {
|
|
442
|
+
turn: number;
|
|
443
|
+
role: MessageRole;
|
|
444
|
+
content: ContentBlock[];
|
|
445
|
+
stopReason?: StopReason;
|
|
446
|
+
usage?: Usage;
|
|
447
|
+
}
|
|
448
|
+
/** Streaming callbacks are the same shape a prompt already takes. */
|
|
449
|
+
export type StreamCallbacks = PromptCallbacks;
|
|
450
|
+
/** Which door a tool call came through. */
|
|
451
|
+
export type GatewayExecutionSurface = 'model_tool' | 'reactive_internal' | 'direct';
|
|
452
|
+
/** Somewhere a run can park work it started and must not lose. */
|
|
453
|
+
export interface BackgroundTaskRegistry {
|
|
454
|
+
register(task: Promise<unknown>): void;
|
|
455
|
+
}
|
|
456
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The harness protocol — what a model runtime and this system say to each
|
|
4
|
+
* other.
|
|
5
|
+
*
|
|
6
|
+
* These names were split out of the product's agent/types.ts and
|
|
7
|
+
* model-runner.ts so the drivers beside this file could move without dragging
|
|
8
|
+
* the twenty-two file closure those two modules sit in. The product keeps both
|
|
9
|
+
* modules and re-exports these from here, so there is one definition.
|
|
10
|
+
*
|
|
11
|
+
* Nothing here knows a product: a tool exchange, a prompt, a runner's metrics
|
|
12
|
+
* and the errors a host tool can raise are the same shapes whichever daemon
|
|
13
|
+
* opens the session.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.AgentError = exports.ModelRunnerError = exports.NativeSessionUnavailableError = exports.HostToolAbortError = exports.HostToolTerminalError = exports.ClaudeToolStreamProtocolError = exports.NativeSteeringTargetUnavailableError = exports.NativeInputUncertainError = void 0;
|
|
17
|
+
exports.isHostToolTerminalCode = isHostToolTerminalCode;
|
|
18
|
+
class NativeInputUncertainError extends Error {
|
|
19
|
+
target;
|
|
20
|
+
retryable = false;
|
|
21
|
+
code = 'NATIVE_INPUT_UNCERTAIN';
|
|
22
|
+
constructor(message, target, cause) {
|
|
23
|
+
super(message, { cause });
|
|
24
|
+
this.target = target;
|
|
25
|
+
this.name = 'NativeInputUncertainError';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.NativeInputUncertainError = NativeInputUncertainError;
|
|
29
|
+
/** The exact steering target vanished before anything was written to native transport. */
|
|
30
|
+
class NativeSteeringTargetUnavailableError extends Error {
|
|
31
|
+
code = 'NATIVE_STEERING_TARGET_UNAVAILABLE';
|
|
32
|
+
constructor() {
|
|
33
|
+
super('Native steering requires the matching active turn');
|
|
34
|
+
this.name = 'NativeSteeringTargetUnavailableError';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.NativeSteeringTargetUnavailableError = NativeSteeringTargetUnavailableError;
|
|
38
|
+
class ClaudeToolStreamProtocolError extends Error {
|
|
39
|
+
code = 'CLAUDE_TOOL_STREAM_PROTOCOL';
|
|
40
|
+
constructor(message) {
|
|
41
|
+
super(message);
|
|
42
|
+
this.name = 'ClaudeToolStreamProtocolError';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.ClaudeToolStreamProtocolError = ClaudeToolStreamProtocolError;
|
|
46
|
+
function isHostToolTerminalCode(value) {
|
|
47
|
+
return (value === 'MUTATION_COMMITTED_AFTER_ABORT' ||
|
|
48
|
+
value === 'MUTATION_OUTCOME_UNKNOWN' ||
|
|
49
|
+
value === 'TOOL_CONTRACT_REPEAT');
|
|
50
|
+
}
|
|
51
|
+
/** Typed transport for a trusted host-tool terminal result across model runtimes. */
|
|
52
|
+
class HostToolTerminalError extends Error {
|
|
53
|
+
terminalCode;
|
|
54
|
+
completedToolExchanges;
|
|
55
|
+
retryable = false;
|
|
56
|
+
constructor(terminalCode, message, completedToolExchanges) {
|
|
57
|
+
super(message);
|
|
58
|
+
this.terminalCode = terminalCode;
|
|
59
|
+
this.completedToolExchanges = completedToolExchanges;
|
|
60
|
+
this.name = 'HostToolTerminalError';
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.HostToolTerminalError = HostToolTerminalError;
|
|
64
|
+
/** A host tool deliberately stopped a run without claiming a terminal mutation outcome. */
|
|
65
|
+
class HostToolAbortError extends Error {
|
|
66
|
+
completedToolExchanges;
|
|
67
|
+
retryable = false;
|
|
68
|
+
constructor(message, completedToolExchanges) {
|
|
69
|
+
super(message);
|
|
70
|
+
this.completedToolExchanges = completedToolExchanges;
|
|
71
|
+
this.name = 'HostToolAbortError';
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.HostToolAbortError = HostToolAbortError;
|
|
75
|
+
/** The native protocol explicitly rejected resumption because its context no longer exists. */
|
|
76
|
+
class NativeSessionUnavailableError extends Error {
|
|
77
|
+
}
|
|
78
|
+
exports.NativeSessionUnavailableError = NativeSessionUnavailableError;
|
|
79
|
+
/**
|
|
80
|
+
* Typed error thrown by IModelRunner implementations.
|
|
81
|
+
*/
|
|
82
|
+
class ModelRunnerError extends Error {
|
|
83
|
+
code;
|
|
84
|
+
retryable;
|
|
85
|
+
constructor(message, code, retryable = false) {
|
|
86
|
+
super(message);
|
|
87
|
+
this.name = 'ModelRunnerError';
|
|
88
|
+
this.code = code;
|
|
89
|
+
this.retryable = retryable;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.ModelRunnerError = ModelRunnerError;
|
|
93
|
+
/**
|
|
94
|
+
* A failure raised anywhere on the harness path. The code is what a caller
|
|
95
|
+
* reads; `retryable` says whether trying again could differ.
|
|
96
|
+
*/
|
|
97
|
+
class AgentError extends Error {
|
|
98
|
+
code;
|
|
99
|
+
cause;
|
|
100
|
+
retryable;
|
|
101
|
+
constructor(message, code, cause, retryable = false) {
|
|
102
|
+
super(message);
|
|
103
|
+
this.code = code;
|
|
104
|
+
this.cause = cause;
|
|
105
|
+
this.retryable = retryable;
|
|
106
|
+
this.name = 'AgentError';
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.AgentError = AgentError;
|
|
110
|
+
//# sourceMappingURL=types.js.map
|