@jungjaehoon/mama-core 2.4.1 → 4.0.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/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 +1968 -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/commitments.d.ts +188 -0
- package/dist/knowledge/commitments.js +370 -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/judgments.d.ts +118 -0
- package/dist/knowledge/judgments.js +808 -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 +155 -0
- package/dist/runtime/drivers/claude-cli-wrapper.js +392 -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 +424 -0
- package/dist/runtime/drivers/persistent-cli-process.js +1543 -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,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CodexRuntimeProcess = void 0;
|
|
4
|
+
const events_1 = require("events");
|
|
5
|
+
const codex_app_server_process_js_1 = require("./drivers/codex-app-server-process.js");
|
|
6
|
+
const codex_auxiliary_tools_js_1 = require("./drivers/codex-auxiliary-tools.js");
|
|
7
|
+
/**
|
|
8
|
+
* Session-persistent Codex wrapper with the same minimal contract used by
|
|
9
|
+
* multi-agent runtime (sendMessage/isReady/stop + idle events).
|
|
10
|
+
*
|
|
11
|
+
* Implements both AgentRuntimeProcess (multi-agent) and IModelRunner (agent-loop).
|
|
12
|
+
* Uses one Codex app-server connection and multiplexes durable threads by
|
|
13
|
+
* session key. Different sessions may run concurrently; turns for the same
|
|
14
|
+
* session are serialized by CodexAppServerProcess.
|
|
15
|
+
*/
|
|
16
|
+
class CodexRuntimeProcess extends events_1.EventEmitter {
|
|
17
|
+
backendType = 'codex';
|
|
18
|
+
/** codex app-server spawns native subagents and reports the spawn via onSubagentStart. */
|
|
19
|
+
supportsNativeSubagents = true;
|
|
20
|
+
options;
|
|
21
|
+
appServer;
|
|
22
|
+
auxiliaryToolBridge;
|
|
23
|
+
defaultSessionKey;
|
|
24
|
+
systemPrompt;
|
|
25
|
+
stopped = false;
|
|
26
|
+
activeRequests = 0;
|
|
27
|
+
subagentCompletionAcceptance = null;
|
|
28
|
+
subagentCompletionAcceptanceRequired = false;
|
|
29
|
+
// ─── Metrics tracking ───
|
|
30
|
+
_requestCount = 0;
|
|
31
|
+
_failureCount = 0;
|
|
32
|
+
_totalLatencyMs = 0;
|
|
33
|
+
_lastRequestAt = null;
|
|
34
|
+
constructor(options) {
|
|
35
|
+
super();
|
|
36
|
+
this.options = { ...options };
|
|
37
|
+
this.defaultSessionKey = options.defaultSessionKey ?? 'default';
|
|
38
|
+
this.systemPrompt = options.systemPrompt ?? '';
|
|
39
|
+
this.appServer = new codex_app_server_process_js_1.CodexAppServerProcess({
|
|
40
|
+
hostRootDir: options.hostRootDir,
|
|
41
|
+
sessionKey: this.defaultSessionKey,
|
|
42
|
+
model: options.model ?? 'gpt-5.4',
|
|
43
|
+
systemPrompt: this.systemPrompt,
|
|
44
|
+
cwd: options.cwd ?? process.cwd(),
|
|
45
|
+
sandbox: options.sandbox ?? 'workspace-write',
|
|
46
|
+
command: options.command,
|
|
47
|
+
requestTimeout: options.requestTimeout,
|
|
48
|
+
codexHome: options.codexHome,
|
|
49
|
+
isolatedHome: options.isolatedHome,
|
|
50
|
+
registryRoot: options.registryRoot,
|
|
51
|
+
mcpConfigPath: options.mcpConfigPath,
|
|
52
|
+
authSourcePath: options.authSourcePath,
|
|
53
|
+
effort: options.effort,
|
|
54
|
+
shellTool: options.shellTool,
|
|
55
|
+
webSearch: options.webSearch,
|
|
56
|
+
shellEnvironment: options.shellEnvironment,
|
|
57
|
+
processEnv: options.processEnv,
|
|
58
|
+
deniedReadPaths: options.deniedReadPaths,
|
|
59
|
+
allowLoginShell: options.allowLoginShell,
|
|
60
|
+
// A completed child is accepted by the consumer's durable intake before the
|
|
61
|
+
// driver forgets it. Started events remain observational.
|
|
62
|
+
onSubagentEvent: (event) => {
|
|
63
|
+
if (event.kind === 'completed') {
|
|
64
|
+
if (this.subagentCompletionAcceptanceRequired && !this.subagentCompletionAcceptance) {
|
|
65
|
+
throw new Error('Subagent completion acceptance is detached');
|
|
66
|
+
}
|
|
67
|
+
this.subagentCompletionAcceptance?.(event);
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
this.emit('subagent', event);
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
console.warn(`[CodexRuntimeProcess] subagent observer failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
createSubagentBridge: options.createSubagentBridge,
|
|
77
|
+
});
|
|
78
|
+
this.auxiliaryToolBridge = options.auxiliaryToolPolicy
|
|
79
|
+
? (0, codex_auxiliary_tools_js_1.createCodexAuxiliaryToolBridge)({
|
|
80
|
+
...options.auxiliaryToolPolicy,
|
|
81
|
+
executeCommand: (command, cwd, roots, signal) => this.appServer.executeSandboxedCommand(command, cwd, roots, signal),
|
|
82
|
+
})
|
|
83
|
+
: undefined;
|
|
84
|
+
}
|
|
85
|
+
/** Synchronous durable acceptance of child completion, before driver cleanup. */
|
|
86
|
+
registerSubagentCompletionAcceptance(accept) {
|
|
87
|
+
if (this.subagentCompletionAcceptance) {
|
|
88
|
+
throw new Error('Subagent completion acceptance is already registered');
|
|
89
|
+
}
|
|
90
|
+
this.subagentCompletionAcceptanceRequired = true;
|
|
91
|
+
this.subagentCompletionAcceptance = accept;
|
|
92
|
+
return () => {
|
|
93
|
+
if (this.subagentCompletionAcceptance === accept)
|
|
94
|
+
this.subagentCompletionAcceptance = null;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
// ─── IModelRunner.prompt() ─────────────────────────────────────────────
|
|
98
|
+
async prompt(content, callbacks, options) {
|
|
99
|
+
return this.execute(content, callbacks, options);
|
|
100
|
+
}
|
|
101
|
+
steer(content, target, options) {
|
|
102
|
+
return this.appServer.steer(content, target, options?.sessionKey ?? options?.sessionId ?? this.defaultSessionKey, options?.beforeSend);
|
|
103
|
+
}
|
|
104
|
+
getSessionPolicyStatus(options) {
|
|
105
|
+
return this.appServer.getSessionPolicyStatus({
|
|
106
|
+
sessionKey: options.sessionKey ?? options.sessionId ?? this.defaultSessionKey,
|
|
107
|
+
model: options.model ?? this.options.model,
|
|
108
|
+
systemPrompt: options.systemPrompt ?? this.systemPrompt,
|
|
109
|
+
requestTimeout: options.requestTimeout ?? this.options.requestTimeout,
|
|
110
|
+
policyFingerprint: options.sessionPolicyFingerprint,
|
|
111
|
+
restrictedReadRoots: options.restrictedReadRoots,
|
|
112
|
+
cwd: options.cwd,
|
|
113
|
+
resumeSession: options.resumeSession,
|
|
114
|
+
hostToolBridge: options.hostToolBridge ?? this.auxiliaryToolBridge,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
resetSession(sessionId, sessionKey) {
|
|
118
|
+
return this.appServer.reset(sessionKey ?? sessionId ?? this.defaultSessionKey);
|
|
119
|
+
}
|
|
120
|
+
// ─── AgentRuntimeProcess.sendMessage() ─────────────────────────────────
|
|
121
|
+
async sendMessage(content, callbacks) {
|
|
122
|
+
return this.execute(content, callbacks);
|
|
123
|
+
}
|
|
124
|
+
async execute(content, callbacks, promptOptions) {
|
|
125
|
+
if (this.stopped) {
|
|
126
|
+
throw this.notifyError(new Error('Process is dead'), callbacks);
|
|
127
|
+
}
|
|
128
|
+
this.activeRequests++;
|
|
129
|
+
const startTime = Date.now();
|
|
130
|
+
this._requestCount++;
|
|
131
|
+
this._lastRequestAt = startTime;
|
|
132
|
+
try {
|
|
133
|
+
const normalized = await this.appServer.prompt(content, callbacks, {
|
|
134
|
+
nativeInputId: promptOptions?.nativeInputId,
|
|
135
|
+
sessionKey: promptOptions?.sessionKey ?? promptOptions?.sessionId ?? this.defaultSessionKey,
|
|
136
|
+
model: promptOptions?.model ?? this.options.model,
|
|
137
|
+
systemPrompt: promptOptions?.systemPrompt ?? this.systemPrompt,
|
|
138
|
+
requestTimeout: promptOptions?.requestTimeout ?? this.options.requestTimeout,
|
|
139
|
+
policyFingerprint: promptOptions?.sessionPolicyFingerprint,
|
|
140
|
+
restrictedReadRoots: promptOptions?.restrictedReadRoots,
|
|
141
|
+
cwd: promptOptions?.cwd,
|
|
142
|
+
resumeSession: promptOptions?.resumeSession,
|
|
143
|
+
hostToolBridge: promptOptions?.hostToolBridge ?? this.auxiliaryToolBridge,
|
|
144
|
+
resumeInstructions: promptOptions?.resumeInstructions,
|
|
145
|
+
preparePrompt: promptOptions?.preparePrompt,
|
|
146
|
+
promptTelemetry: promptOptions?.promptTelemetry,
|
|
147
|
+
});
|
|
148
|
+
this._totalLatencyMs += Date.now() - startTime;
|
|
149
|
+
callbacks?.onFinal?.({ content: normalized.response, toolUseBlocks: [] });
|
|
150
|
+
return normalized;
|
|
151
|
+
}
|
|
152
|
+
catch (err) {
|
|
153
|
+
this._failureCount++;
|
|
154
|
+
this._totalLatencyMs += Date.now() - startTime;
|
|
155
|
+
throw this.notifyError(err, callbacks);
|
|
156
|
+
}
|
|
157
|
+
finally {
|
|
158
|
+
this.activeRequests--;
|
|
159
|
+
if (!this.stopped && this.activeRequests === 0) {
|
|
160
|
+
this.emit('idle');
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
notifyError(error, callbacks) {
|
|
165
|
+
const normalized = error instanceof Error ? error : new Error(String(error));
|
|
166
|
+
try {
|
|
167
|
+
callbacks?.onError?.(normalized);
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
// Consumer callback failures must not replace the model failure.
|
|
171
|
+
}
|
|
172
|
+
return normalized;
|
|
173
|
+
}
|
|
174
|
+
// ─── IModelRunner session management ───────────────────────────────────
|
|
175
|
+
setSessionId(id) {
|
|
176
|
+
this.defaultSessionKey = id;
|
|
177
|
+
}
|
|
178
|
+
setSystemPrompt(prompt) {
|
|
179
|
+
this.systemPrompt = prompt;
|
|
180
|
+
}
|
|
181
|
+
// ─── IModelRunner health & metrics ─────────────────────────────────────
|
|
182
|
+
isReady() {
|
|
183
|
+
return !this.stopped;
|
|
184
|
+
}
|
|
185
|
+
isHealthy() {
|
|
186
|
+
return !this.stopped;
|
|
187
|
+
}
|
|
188
|
+
getMetrics() {
|
|
189
|
+
return {
|
|
190
|
+
requestCount: this._requestCount,
|
|
191
|
+
failureCount: this._failureCount,
|
|
192
|
+
avgLatencyMs: this._requestCount > 0 ? Math.round(this._totalLatencyMs / this._requestCount) : 0,
|
|
193
|
+
lastRequestAt: this._lastRequestAt,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
async stop() {
|
|
197
|
+
this.stopped = true;
|
|
198
|
+
await this.appServer.stop();
|
|
199
|
+
this.emit('close', 0);
|
|
200
|
+
}
|
|
201
|
+
getSessionId() {
|
|
202
|
+
return this.appServer.getThreadId(this.defaultSessionKey) ?? '';
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
exports.CodexRuntimeProcess = CodexRuntimeProcess;
|
|
206
|
+
//# sourceMappingURL=runtime-process.js.map
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import type { ContentBlock, PromptCallbacks } from './drivers/types.js';
|
|
2
|
+
import type { NativeTurnResult } from './native-turn.js';
|
|
3
|
+
import type { ActionSessionFacts } from '../action-contracts.js';
|
|
4
|
+
import type { ActionCatalog } from '../api/catalog.js';
|
|
5
|
+
import type { ActionDispatcher } from '../api/dispatch.js';
|
|
6
|
+
import type { TextCompletion } from './text-completion.js';
|
|
7
|
+
import type { JudgmentAccess } from '../knowledge/judgments.js';
|
|
8
|
+
import type { DatabaseAdapter } from '../db-manager.js';
|
|
9
|
+
import type { NativeInputDispatch, NativeInputReceipt } from './drivers/types.js';
|
|
10
|
+
import type { NativeTurnResultRecord } from './native-input-journal.js';
|
|
11
|
+
import { type IpcRequest } from '../client/ipc.js';
|
|
12
|
+
import { Mailbox, type MailboxRow, type Stimulus, type StimulusKind } from './mailbox.js';
|
|
13
|
+
/** The paths product assembly must state — the runtime never derives them. */
|
|
14
|
+
export interface RuntimePaths {
|
|
15
|
+
/** Private Unix socket the action catalog is served on. */
|
|
16
|
+
socketPath: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* One caller of this runtime. The credential file is what names the principal:
|
|
20
|
+
* whoever presents that token is that principal and gets exactly its access.
|
|
21
|
+
* The path is stated by the product for the same reason every other path is —
|
|
22
|
+
* core composing `<dir>/<principalId>` would let a principal's name choose a
|
|
23
|
+
* file.
|
|
24
|
+
*/
|
|
25
|
+
export interface RuntimePrincipal {
|
|
26
|
+
access: JudgmentAccess;
|
|
27
|
+
/** Rotated-per-boot token file (0600) this principal's callers present. */
|
|
28
|
+
credentialPath: string;
|
|
29
|
+
/**
|
|
30
|
+
* The run this principal's calls answer to, when its host can name one.
|
|
31
|
+
*
|
|
32
|
+
* An action whose authority is the run — execution evidence — is uncallable
|
|
33
|
+
* on a surface that names none, and a socket cannot derive a run from a
|
|
34
|
+
* request. The host that assembles the principal states it here, once, beside
|
|
35
|
+
* the access; a host that cannot name it omits it and its calls stay honestly
|
|
36
|
+
* unattributed.
|
|
37
|
+
*/
|
|
38
|
+
runEvidenceScope?: ActionSessionFacts['runEvidenceScope'];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The harness this runtime opened, from the outside.
|
|
42
|
+
*
|
|
43
|
+
* §4.3 gives `runtime.start` the DB, the native session, the model and the
|
|
44
|
+
* socket, and gives `stop` exactly what start opened. The session itself is
|
|
45
|
+
* built by product assembly - which harness, which workspace, which persona is
|
|
46
|
+
* the product's statement - and handed here so that ONE subject decides when it
|
|
47
|
+
* is alive. Before this, shutdown stopped the loop, disposed the session pool
|
|
48
|
+
* and closed the socket as three separate steps in one function, and the order
|
|
49
|
+
* between them was that function's private knowledge.
|
|
50
|
+
*/
|
|
51
|
+
export interface NativeInvocationOptions {
|
|
52
|
+
nativeInputId?: string;
|
|
53
|
+
onModelRunStarted?: (modelRunId: string) => void;
|
|
54
|
+
prepareSessionContent?: (session: import('./drivers/types.js').NativeSessionState) => Promise<ContentBlock[]>;
|
|
55
|
+
streamCallbacks?: PromptCallbacks;
|
|
56
|
+
}
|
|
57
|
+
export interface NativeSessionHandle {
|
|
58
|
+
/** One request to the native harness; model/tool iteration remains inside that harness. */
|
|
59
|
+
runTurn?(content: ContentBlock[], request?: NativeInvocationOptions): Promise<NativeTurnResult>;
|
|
60
|
+
/** Retire the native context and its pool route, preserving durable product records. */
|
|
61
|
+
resetSession?(sessionKey: string): Promise<void>;
|
|
62
|
+
/** Add input to the exact active turn; the runtime journals this input separately. */
|
|
63
|
+
steer?(content: string, target: NativeInputReceipt, sessionKey: string, beforeSend?: () => void): Promise<NativeInputReceipt>;
|
|
64
|
+
/** Release the harness and the sessions it holds. Called once, by `stop`. */
|
|
65
|
+
stop(): Promise<void>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A delivery that must NOT be tried again.
|
|
69
|
+
*
|
|
70
|
+
* Retry is the runtime's default because most failures are transient. Some are
|
|
71
|
+
* not: an external effect whose outcome is unknown cannot be replayed on a
|
|
72
|
+
* guess (§4.3), and a stimulus whose delivery already spent one must park where
|
|
73
|
+
* a person can see it rather than repeat it. Throwing this from `deliver` says
|
|
74
|
+
* exactly that — park the row dead, spend no attempt, and name it through
|
|
75
|
+
* `onDead`.
|
|
76
|
+
*/
|
|
77
|
+
export declare class StimulusQuarantine extends Error {
|
|
78
|
+
constructor(reason: string);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* How an accepted stimulus reaches the loop.
|
|
82
|
+
*
|
|
83
|
+
* The runtime journals dispatch before native IO and ACKs the native receipt.
|
|
84
|
+
* Returning from `deliver` settles the consumer adapter; it does not prove a
|
|
85
|
+
* judgment or an external effect. After dispatch, failures require reconciliation.
|
|
86
|
+
* Only failures known to precede dispatch remain eligible for automatic retry.
|
|
87
|
+
*
|
|
88
|
+
* This is delivery, not a second turn loop: what runs inside `deliver` is the
|
|
89
|
+
* native session the product already has, with its own resume, steering and
|
|
90
|
+
* turn observation. Nothing here interprets the stimulus, and nothing here
|
|
91
|
+
* decides a turn is finished — an ack says the loop took it and no more.
|
|
92
|
+
*/
|
|
93
|
+
export interface NativeDeliveryContext {
|
|
94
|
+
nativeInputId: string;
|
|
95
|
+
/** Read the one final result for a shared turn under this input's principal. */
|
|
96
|
+
resultForReceipt(receipt: NativeInputReceipt): NativeTurnResultRecord | null;
|
|
97
|
+
run<TRequest extends object>(content: ContentBlock[], request?: TRequest & NativeInvocationOptions): Promise<NativeTurnResult>;
|
|
98
|
+
/** Native steer acceptance, never a model result or an effect receipt. */
|
|
99
|
+
steer(content: string, target: NativeInputReceipt, sessionKey: string): Promise<NativeInputReceipt>;
|
|
100
|
+
wasDispatched(): boolean;
|
|
101
|
+
/** Must persist successfully before writing the input to the native transport. */
|
|
102
|
+
onInputDispatch(input: NativeInputDispatch): void;
|
|
103
|
+
/** Native acknowledgement, distinct from model completion and external effects. */
|
|
104
|
+
onAccepted(receipt: NativeInputReceipt): void;
|
|
105
|
+
}
|
|
106
|
+
export interface StimulusDelivery {
|
|
107
|
+
deliver(row: MailboxRow, context: NativeDeliveryContext): Promise<void>;
|
|
108
|
+
/** Reuse recorded results only. Never submit the input to a model again. */
|
|
109
|
+
reconcile?(row: MailboxRow): Promise<'settled' | 'unresolved'>;
|
|
110
|
+
onUncertain?(row: MailboxRow, reason: string): void | Promise<void>;
|
|
111
|
+
/** Consumer ports may still be opening; keep accepted inputs without spending attempts. */
|
|
112
|
+
ready?(): boolean;
|
|
113
|
+
/**
|
|
114
|
+
* A row this runtime parked dead, named once, as it happens.
|
|
115
|
+
*
|
|
116
|
+
* The runtime owns the claim and the retry, so it is the only subject that
|
|
117
|
+
* knows a stimulus was lost for good. A consumer that had to discover its own
|
|
118
|
+
* losses by re-reading the table would be claiming rows again to find them -
|
|
119
|
+
* which is the second claimer this door exists to remove.
|
|
120
|
+
*/
|
|
121
|
+
onDead?(row: MailboxRow, reason: string): void | Promise<void>;
|
|
122
|
+
/**
|
|
123
|
+
* Kinds delivered ahead of the rest. §4.3 forbids a host FIFO in which the
|
|
124
|
+
* person's current request waits behind a mass replay; stating the owner's
|
|
125
|
+
* own message here is what keeps that from happening.
|
|
126
|
+
*/
|
|
127
|
+
prefer?: readonly StimulusKind[];
|
|
128
|
+
/** How long a claim may go unacked before it returns to pending. */
|
|
129
|
+
leaseMs?: number;
|
|
130
|
+
/** How many rows one tick delivers before yielding. */
|
|
131
|
+
maxPerTick?: number;
|
|
132
|
+
/** Bound inputs waiting for native ACK; accepted model results do not consume this window. */
|
|
133
|
+
maxPendingInputs?: number;
|
|
134
|
+
/**
|
|
135
|
+
* How often to look when nothing has been accepted. `0` means only on accept.
|
|
136
|
+
*
|
|
137
|
+
* This is the floor under acceptance, not the way work normally arrives, so
|
|
138
|
+
* it is paced to the shortest retry backoff rather than to latency: an accept
|
|
139
|
+
* drains immediately, and nothing else becomes deliverable between ticks
|
|
140
|
+
* except a retry whose minimum wait is a minute.
|
|
141
|
+
*/
|
|
142
|
+
intervalMs?: number;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* What acceptance means, and what it does not.
|
|
146
|
+
*
|
|
147
|
+
* `accepted` says the stimulus is durable and will be delivered. It is not a
|
|
148
|
+
* claim that anything has been read, decided or done — v7 §4.4 is explicit that
|
|
149
|
+
* a delivery ACK is not a work receipt, and this receipt is one step earlier
|
|
150
|
+
* than that. `duplicate` says every ref the producer stated was already
|
|
151
|
+
* durable, so there is no new row and nothing was lost.
|
|
152
|
+
*/
|
|
153
|
+
export interface StimulusReceipt {
|
|
154
|
+
/** The durable row, or `null` when the stimulus was already held. */
|
|
155
|
+
inputId: string | null;
|
|
156
|
+
state: 'accepted' | 'duplicate';
|
|
157
|
+
}
|
|
158
|
+
export interface StartRuntimeOptions {
|
|
159
|
+
paths: RuntimePaths;
|
|
160
|
+
catalog: ActionCatalog;
|
|
161
|
+
dispatch: ActionDispatcher;
|
|
162
|
+
/**
|
|
163
|
+
* Every principal this runtime serves, each with its own credential file.
|
|
164
|
+
* The credential is a bearer token for local session proof only; it is never
|
|
165
|
+
* written to prompts, shared env, or logs. Two principals may not share a
|
|
166
|
+
* credential path — the token would no longer name one caller.
|
|
167
|
+
*/
|
|
168
|
+
principals: readonly RuntimePrincipal[];
|
|
169
|
+
/**
|
|
170
|
+
* Passed through to the socket server — host-stated call-site facts for
|
|
171
|
+
* calls on this socket (e.g. the surface name and the credential binding
|
|
172
|
+
* hash). Facts the socket cannot truthfully state stay absent.
|
|
173
|
+
*/
|
|
174
|
+
sessionFacts?: (access: JudgmentAccess, request: IpcRequest) => ActionSessionFacts | undefined;
|
|
175
|
+
/** Passed through to the socket server — reclaim a dead socket file, refuse a live one. */
|
|
176
|
+
reclaimStaleSocket?: boolean;
|
|
177
|
+
/**
|
|
178
|
+
* The one model this runtime opens, for the actions that need text back.
|
|
179
|
+
*
|
|
180
|
+
* A library that opens its own model decides for every host that installs it
|
|
181
|
+
* (§2.1). Absent means this runtime has no model to ask, and the actions
|
|
182
|
+
* that would have used one say so rather than answering as if they had.
|
|
183
|
+
*/
|
|
184
|
+
runner?: TextCompletion;
|
|
185
|
+
/**
|
|
186
|
+
* The store the durable intake is opened against.
|
|
187
|
+
*
|
|
188
|
+
* Stated by the product for the same reason every path is: core does not
|
|
189
|
+
* choose which database a consumer's mailbox lives in. Absent means this
|
|
190
|
+
* runtime has no intake, and `accept` refuses instead of quietly dropping a
|
|
191
|
+
* stimulus whose producer believes it is now durable.
|
|
192
|
+
*/
|
|
193
|
+
mailbox?: {
|
|
194
|
+
adapter: DatabaseAdapter;
|
|
195
|
+
clock?: () => number;
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* Where an accepted stimulus goes. Absent means this runtime accepts and
|
|
199
|
+
* keeps but hands nothing on — the store is then drained by whoever states
|
|
200
|
+
* they own it, and `drainOnce` is the door they use.
|
|
201
|
+
*/
|
|
202
|
+
delivery?: StimulusDelivery;
|
|
203
|
+
/**
|
|
204
|
+
* The harness this runtime owns for its lifetime.
|
|
205
|
+
*
|
|
206
|
+
* Absent means this runtime serves actions and keeps stimuli but opened no
|
|
207
|
+
* model session - an MCP-only profile is exactly that, and it should not
|
|
208
|
+
* pretend to close one.
|
|
209
|
+
*/
|
|
210
|
+
nativeSession?: NativeSessionHandle;
|
|
211
|
+
}
|
|
212
|
+
export interface RuntimeHandle {
|
|
213
|
+
/** Internal host port: only a currently claimed input may invoke the native session. */
|
|
214
|
+
runNative<TRequest extends object>(nativeInputId: string, content: ContentBlock[], request?: TRequest & NativeInvocationOptions): Promise<NativeTurnResult>;
|
|
215
|
+
socketPath: string;
|
|
216
|
+
/** The model this runtime opened, or undefined when it opened none. */
|
|
217
|
+
runner?: TextCompletion;
|
|
218
|
+
/**
|
|
219
|
+
* The durable intake this runtime opened, for the consumer that drains it.
|
|
220
|
+
*
|
|
221
|
+
* One store, opened once, by the subject that owns the loop's material. A
|
|
222
|
+
* product that constructed its own would have two openers of one table and
|
|
223
|
+
* no single place that says when it exists.
|
|
224
|
+
*/
|
|
225
|
+
mailbox?: Mailbox;
|
|
226
|
+
/**
|
|
227
|
+
* The one door a stimulus enters by. Durable on return, and nothing else.
|
|
228
|
+
*
|
|
229
|
+
* Refuses — loudly — a principal this runtime does not serve, an unknown
|
|
230
|
+
* kind, a stimulus with no channel identity, and a runtime that opened no
|
|
231
|
+
* intake. A producer holding a receipt believes the stimulus is kept, so
|
|
232
|
+
* none of those may pass quietly.
|
|
233
|
+
*/
|
|
234
|
+
accept(stimulus: Stimulus): StimulusReceipt;
|
|
235
|
+
/**
|
|
236
|
+
* Deliver what is pending, once. Returns what happened, so a caller that
|
|
237
|
+
* drives the drain itself can tell idle from failing.
|
|
238
|
+
*
|
|
239
|
+
* Runs the stale-claim replay first: a claim is a lease, so a delivery that
|
|
240
|
+
* died mid-flight is owed again rather than lost.
|
|
241
|
+
*/
|
|
242
|
+
drainOnce(): Promise<{
|
|
243
|
+
delivered: number;
|
|
244
|
+
failed: number;
|
|
245
|
+
dead: number;
|
|
246
|
+
}>;
|
|
247
|
+
/**
|
|
248
|
+
* The principal a presented credential names, or `undefined` for nobody.
|
|
249
|
+
*
|
|
250
|
+
* One boot issues the credentials; this is the same table the socket
|
|
251
|
+
* resolves against, read by a second local door rather than duplicated. It
|
|
252
|
+
* only ever narrows: an absent or unknown credential resolves to nobody, and
|
|
253
|
+
* there is no caller this answers for that the socket would not.
|
|
254
|
+
*/
|
|
255
|
+
principalFor(credential: string | undefined): RuntimePrincipal | undefined;
|
|
256
|
+
/** Whether this boot currently serves an exact principal for durable intake. */
|
|
257
|
+
servesPrincipal(principalId: string): boolean;
|
|
258
|
+
/** Add a product-identified caller to the live socket and intake without reopening either. */
|
|
259
|
+
servePrincipal(principal: RuntimePrincipal): void;
|
|
260
|
+
/** Remove a caller's socket identity and durable-intake admission immediately. */
|
|
261
|
+
unservePrincipal(principalId: string): void;
|
|
262
|
+
/** The harness this runtime opened, or undefined when it opened none. */
|
|
263
|
+
nativeSession?: Pick<NativeSessionHandle, 'stop' | 'resetSession'>;
|
|
264
|
+
/**
|
|
265
|
+
* Closes what start opened, in the order that makes each close safe: the
|
|
266
|
+
* drain first so nothing new is handed out, then the harness, then the socket
|
|
267
|
+
* and this boot's credential. A caller that stops answering action calls
|
|
268
|
+
* before the turn using them has ended would fail that turn on the way out.
|
|
269
|
+
*/
|
|
270
|
+
stop(): Promise<void>;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Opens the action surface: issues the session credential and serves
|
|
274
|
+
* `catalog`/`dispatch` on the private socket. `stop` closes the socket and
|
|
275
|
+
* removes the credential file it wrote — nothing else.
|
|
276
|
+
*/
|
|
277
|
+
export declare function startRuntime(options: StartRuntimeOptions): Promise<RuntimeHandle>;
|
|
278
|
+
//# sourceMappingURL=runtime.d.ts.map
|