orbit-agent-runtime 0.8.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.
Files changed (168) hide show
  1. package/CHANGELOG.md +750 -0
  2. package/LICENSE +201 -0
  3. package/README.md +492 -0
  4. package/README.zh-CN.md +389 -0
  5. package/benchmarks/README.md +24 -0
  6. package/benchmarks/gateway.mjs +68 -0
  7. package/benchmarks/pae.mjs +90 -0
  8. package/benchmarks/replay.mjs +51 -0
  9. package/benchmarks/run-all.mjs +24 -0
  10. package/benchmarks/wal.mjs +50 -0
  11. package/bin/orbit.mjs +523 -0
  12. package/dist/.tsbuildinfo +1 -0
  13. package/dist/demo-deepseek.d.ts +2 -0
  14. package/dist/demo-deepseek.d.ts.map +1 -0
  15. package/dist/demo-deepseek.js +66 -0
  16. package/dist/demo-deepseek.js.map +1 -0
  17. package/dist/demo-host.d.ts +2 -0
  18. package/dist/demo-host.d.ts.map +1 -0
  19. package/dist/demo-host.js +98 -0
  20. package/dist/demo-host.js.map +1 -0
  21. package/dist/demo-replay.d.ts +2 -0
  22. package/dist/demo-replay.d.ts.map +1 -0
  23. package/dist/demo-replay.js +68 -0
  24. package/dist/demo-replay.js.map +1 -0
  25. package/dist/src/core/orbitRuntimeHost.d.ts +349 -0
  26. package/dist/src/core/orbitRuntimeHost.d.ts.map +1 -0
  27. package/dist/src/core/orbitRuntimeHost.js +706 -0
  28. package/dist/src/core/orbitRuntimeHost.js.map +1 -0
  29. package/dist/src/index.d.ts +92 -0
  30. package/dist/src/index.d.ts.map +1 -0
  31. package/dist/src/index.js +226 -0
  32. package/dist/src/index.js.map +1 -0
  33. package/dist/test/audit_chain.test.d.ts +2 -0
  34. package/dist/test/audit_chain.test.d.ts.map +1 -0
  35. package/dist/test/audit_chain.test.js +283 -0
  36. package/dist/test/audit_chain.test.js.map +1 -0
  37. package/dist/test/channel_hub.test.d.ts +2 -0
  38. package/dist/test/channel_hub.test.d.ts.map +1 -0
  39. package/dist/test/channel_hub.test.js +66 -0
  40. package/dist/test/channel_hub.test.js.map +1 -0
  41. package/dist/test/cordis_adapter.test.d.ts +2 -0
  42. package/dist/test/cordis_adapter.test.d.ts.map +1 -0
  43. package/dist/test/cordis_adapter.test.js +280 -0
  44. package/dist/test/cordis_adapter.test.js.map +1 -0
  45. package/dist/test/cost_routing.test.d.ts +2 -0
  46. package/dist/test/cost_routing.test.d.ts.map +1 -0
  47. package/dist/test/cost_routing.test.js +31 -0
  48. package/dist/test/cost_routing.test.js.map +1 -0
  49. package/dist/test/domain_transaction.test.d.ts +2 -0
  50. package/dist/test/domain_transaction.test.d.ts.map +1 -0
  51. package/dist/test/domain_transaction.test.js +351 -0
  52. package/dist/test/domain_transaction.test.js.map +1 -0
  53. package/dist/test/file_channel.test.d.ts +2 -0
  54. package/dist/test/file_channel.test.d.ts.map +1 -0
  55. package/dist/test/file_channel.test.js +179 -0
  56. package/dist/test/file_channel.test.js.map +1 -0
  57. package/dist/test/gateway.test.d.ts +2 -0
  58. package/dist/test/gateway.test.d.ts.map +1 -0
  59. package/dist/test/gateway.test.js +548 -0
  60. package/dist/test/gateway.test.js.map +1 -0
  61. package/dist/test/governance_profile.test.d.ts +2 -0
  62. package/dist/test/governance_profile.test.d.ts.map +1 -0
  63. package/dist/test/governance_profile.test.js +214 -0
  64. package/dist/test/governance_profile.test.js.map +1 -0
  65. package/dist/test/governance_schema.test.d.ts +2 -0
  66. package/dist/test/governance_schema.test.d.ts.map +1 -0
  67. package/dist/test/governance_schema.test.js +200 -0
  68. package/dist/test/governance_schema.test.js.map +1 -0
  69. package/dist/test/host_integration.test.d.ts +2 -0
  70. package/dist/test/host_integration.test.d.ts.map +1 -0
  71. package/dist/test/host_integration.test.js +104 -0
  72. package/dist/test/host_integration.test.js.map +1 -0
  73. package/dist/test/host_journal_persistence.test.d.ts +2 -0
  74. package/dist/test/host_journal_persistence.test.d.ts.map +1 -0
  75. package/dist/test/host_journal_persistence.test.js +367 -0
  76. package/dist/test/host_journal_persistence.test.js.map +1 -0
  77. package/dist/test/impact_domain.test.d.ts +2 -0
  78. package/dist/test/impact_domain.test.d.ts.map +1 -0
  79. package/dist/test/impact_domain.test.js +48 -0
  80. package/dist/test/impact_domain.test.js.map +1 -0
  81. package/dist/test/injected_clock.test.d.ts +13 -0
  82. package/dist/test/injected_clock.test.d.ts.map +1 -0
  83. package/dist/test/injected_clock.test.js +200 -0
  84. package/dist/test/injected_clock.test.js.map +1 -0
  85. package/dist/test/isolation_domain.test.d.ts +2 -0
  86. package/dist/test/isolation_domain.test.d.ts.map +1 -0
  87. package/dist/test/isolation_domain.test.js +302 -0
  88. package/dist/test/isolation_domain.test.js.map +1 -0
  89. package/dist/test/journal_wal.test.d.ts +2 -0
  90. package/dist/test/journal_wal.test.d.ts.map +1 -0
  91. package/dist/test/journal_wal.test.js +622 -0
  92. package/dist/test/journal_wal.test.js.map +1 -0
  93. package/dist/test/mcp_adapter.test.d.ts +2 -0
  94. package/dist/test/mcp_adapter.test.d.ts.map +1 -0
  95. package/dist/test/mcp_adapter.test.js +440 -0
  96. package/dist/test/mcp_adapter.test.js.map +1 -0
  97. package/dist/test/openai_compat_channel.test.d.ts +2 -0
  98. package/dist/test/openai_compat_channel.test.d.ts.map +1 -0
  99. package/dist/test/openai_compat_channel.test.js +325 -0
  100. package/dist/test/openai_compat_channel.test.js.map +1 -0
  101. package/dist/test/openapi_adapter.test.d.ts +2 -0
  102. package/dist/test/openapi_adapter.test.d.ts.map +1 -0
  103. package/dist/test/openapi_adapter.test.js +270 -0
  104. package/dist/test/openapi_adapter.test.js.map +1 -0
  105. package/dist/test/orbit_cli.test.d.ts +2 -0
  106. package/dist/test/orbit_cli.test.d.ts.map +1 -0
  107. package/dist/test/orbit_cli.test.js +137 -0
  108. package/dist/test/orbit_cli.test.js.map +1 -0
  109. package/dist/test/pact_verifier.test.d.ts +2 -0
  110. package/dist/test/pact_verifier.test.d.ts.map +1 -0
  111. package/dist/test/pact_verifier.test.js +41 -0
  112. package/dist/test/pact_verifier.test.js.map +1 -0
  113. package/dist/test/pae_adapter.test.d.ts +2 -0
  114. package/dist/test/pae_adapter.test.d.ts.map +1 -0
  115. package/dist/test/pae_adapter.test.js +469 -0
  116. package/dist/test/pae_adapter.test.js.map +1 -0
  117. package/dist/test/plugin_sandbox_guard.test.d.ts +2 -0
  118. package/dist/test/plugin_sandbox_guard.test.d.ts.map +1 -0
  119. package/dist/test/plugin_sandbox_guard.test.js +57 -0
  120. package/dist/test/plugin_sandbox_guard.test.js.map +1 -0
  121. package/dist/test/rate_limit_behavior.test.d.ts +2 -0
  122. package/dist/test/rate_limit_behavior.test.d.ts.map +1 -0
  123. package/dist/test/rate_limit_behavior.test.js +85 -0
  124. package/dist/test/rate_limit_behavior.test.js.map +1 -0
  125. package/dist/test/replay_compat.test.d.ts +2 -0
  126. package/dist/test/replay_compat.test.d.ts.map +1 -0
  127. package/dist/test/replay_compat.test.js +1122 -0
  128. package/dist/test/replay_compat.test.js.map +1 -0
  129. package/dist/test/replay_engine.test.d.ts +2 -0
  130. package/dist/test/replay_engine.test.d.ts.map +1 -0
  131. package/dist/test/replay_engine.test.js +85 -0
  132. package/dist/test/replay_engine.test.js.map +1 -0
  133. package/dist/test/shell_channel.test.d.ts +2 -0
  134. package/dist/test/shell_channel.test.d.ts.map +1 -0
  135. package/dist/test/shell_channel.test.js +173 -0
  136. package/dist/test/shell_channel.test.js.map +1 -0
  137. package/dist/test/teardown_isolation.test.d.ts +10 -0
  138. package/dist/test/teardown_isolation.test.d.ts.map +1 -0
  139. package/dist/test/teardown_isolation.test.js +279 -0
  140. package/dist/test/teardown_isolation.test.js.map +1 -0
  141. package/dist/test/token_budget.test.d.ts +2 -0
  142. package/dist/test/token_budget.test.d.ts.map +1 -0
  143. package/dist/test/token_budget.test.js +113 -0
  144. package/dist/test/token_budget.test.js.map +1 -0
  145. package/dist/test/trace_journal.test.d.ts +2 -0
  146. package/dist/test/trace_journal.test.d.ts.map +1 -0
  147. package/dist/test/trace_journal.test.js +43 -0
  148. package/dist/test/trace_journal.test.js.map +1 -0
  149. package/dist/test/trace_journal_persistence.test.d.ts +2 -0
  150. package/dist/test/trace_journal_persistence.test.d.ts.map +1 -0
  151. package/dist/test/trace_journal_persistence.test.js +175 -0
  152. package/dist/test/trace_journal_persistence.test.js.map +1 -0
  153. package/dist/test/trace_persistence.test.d.ts +2 -0
  154. package/dist/test/trace_persistence.test.d.ts.map +1 -0
  155. package/dist/test/trace_persistence.test.js +216 -0
  156. package/dist/test/trace_persistence.test.js.map +1 -0
  157. package/dist/test/trip_protector.test.d.ts +2 -0
  158. package/dist/test/trip_protector.test.d.ts.map +1 -0
  159. package/dist/test/trip_protector.test.js +42 -0
  160. package/dist/test/trip_protector.test.js.map +1 -0
  161. package/examples/README.md +34 -0
  162. package/examples/cli-record-replay.mjs +74 -0
  163. package/examples/custom-channel.mjs +102 -0
  164. package/examples/js-pae-plugin.mjs +128 -0
  165. package/examples/mcp-adapter.mjs +102 -0
  166. package/package.json +60 -0
  167. package/src/core/orbitRuntimeHost.ts +853 -0
  168. package/src/index.ts +256 -0
@@ -0,0 +1,349 @@
1
+ import { ChannelHub } from "@orbit/core-hub";
2
+ import { TraceJournal } from "@orbit/core-hub";
3
+ import { PluginSandboxGuard } from "@orbit/core-hub";
4
+ import { PluginPactVerifier } from "@orbit/core-hub";
5
+ import { SandboxPool } from "@orbit/sandbox-runtime";
6
+ import { ImpactDomainGraph } from "@orbit/sandbox-runtime";
7
+ import { CostRouter } from "@orbit/core-hub";
8
+ import { RecordJournal } from "@orbit/core-hub";
9
+ import { ReplayEngine } from "@orbit/core-hub";
10
+ import { CapabilityGateway } from "@orbit/core-hub";
11
+ import { TokenBudgetEngine } from "@orbit/core-hub";
12
+ import { RateLimiter } from "@orbit/core-hub";
13
+ import { BehaviorCollector } from "@orbit/core-hub";
14
+ import { PaeAdapterRegistry } from "@orbit/pae-engine";
15
+ import { PaeChannel } from "@orbit/pae-engine";
16
+ import type { IPaeAdapter, PaeFidelity, PaeToolDescriptor } from "@orbit/pae-engine";
17
+ import type { AuditChainReport } from "@orbit/core-hub";
18
+ import type { AgentSandbox } from "@orbit/sandbox-runtime";
19
+ import { ChannelKind, ChannelCallCtx, PluginUnitPact, AgentBoxConfig, ReplayMode } from "@orbit/infra-common";
20
+ import { type GovernanceProfile, type GovernanceProfileName } from "@orbit/infra-common";
21
+ import type { RunVersionFingerprint } from "@orbit/infra-common";
22
+ import type { ClockSource } from "@orbit/infra-common";
23
+ import type { DomainTransportFactory } from "@orbit/sandbox-runtime";
24
+ import type { IsolationDomainPlan } from "@orbit/sandbox-runtime";
25
+ import type { DomainReconciliation, DomainTransaction } from "@orbit/sandbox-runtime";
26
+ export interface OrbitRuntimeHostOptions {
27
+ /** Durable audit/behavior journal (trace) WAL path. */
28
+ traceJournalPath?: string;
29
+ /** Durable recording-window journal WAL path (recovered on boot). */
30
+ recordJournalPath?: string;
31
+ /**
32
+ * Wall-clock source for every time-dependent decision that reaches a recorded
33
+ * value (trip cooldown, channel TTLs). Injecting a frozen clock makes a
34
+ * recording window reproducible; omitting it keeps the real clock, which is
35
+ * the previous behaviour.
36
+ */
37
+ clock?: ClockSource;
38
+ /**
39
+ * Retention bound for the durable audit journal: keep at most this many
40
+ * newest entries. An append-only audit log that grows without limit
41
+ * eventually fills the disk, and a full disk is an outage — so the bound is
42
+ * explicit and operator-chosen rather than an implicit default. Applied at
43
+ * boot (after recovery) and at shutdown. Omit for unbounded retention.
44
+ */
45
+ auditRetention?: number;
46
+ /**
47
+ * W29: governance tier (VISION §3.1). `standard` is the default and resolves
48
+ * to the kernel's pre-W29 numbers verbatim. `sandbox` disables token
49
+ * compression, widens rate limits, admits every PAE adapter kind and keeps
50
+ * the trace in memory. `strict` narrows rate limits, trips earlier, compresses
51
+ * aggressively, admits NO foreign adapters and REQUIRES a durable trace path
52
+ * (construction fails without one). The profile name is hashed into the run
53
+ * fingerprint, so a trace recorded under one tier refuses to replay under
54
+ * another (`RunFingerprintDriftError`).
55
+ */
56
+ governanceProfile?: GovernanceProfileName;
57
+ /**
58
+ * W30: HMAC-SHA256 signing key for the audit hash chain (VISION §3.1's
59
+ * "落盘 + 签名"). When provided, every audit entry is linked with
60
+ * `prevHash`/`chainHash` and `host.verifyAuditChain()` can prove the trail
61
+ * has not been tampered with. Without a key the journal records no chain
62
+ * fields at all (pre-W30 behaviour). The `strict` governance tier REQUIRES
63
+ * a signing key — a compliance tier must be able to prove its audit trail.
64
+ */
65
+ auditSigningKey?: string;
66
+ }
67
+ /**
68
+ * Top-level assembly: wires every component bottom-up and owns the host
69
+ * lifecycle. Components stay public for advanced scenarios (custom channels,
70
+ * audit), but day-to-day use should go through the facade methods below.
71
+ */
72
+ export declare class OrbitRuntimeHost {
73
+ readonly channelHub: ChannelHub;
74
+ readonly traceJournal: TraceJournal;
75
+ readonly pluginSandboxGuard: PluginSandboxGuard;
76
+ readonly pluginPactVerifier: PluginPactVerifier;
77
+ readonly sandboxPool: SandboxPool;
78
+ /** M3: dependency graph feeding isolation decisions. */
79
+ readonly impactGraph: ImpactDomainGraph;
80
+ /** M4: cost profiles and budget routing. */
81
+ readonly costRouter: CostRouter;
82
+ /** W8: pure-function token budget + context compressor (single source of truth). */
83
+ readonly tokenBudget: TokenBudgetEngine;
84
+ /** W11: pure-function rate limiter (call-count budget, replay-safe). */
85
+ readonly rateLimiter: RateLimiter;
86
+ /** W11: behavior collector (record / live-proposal / replay-bypass). */
87
+ readonly behaviorCollector: BehaviorCollector;
88
+ /** W7: unified gateway entry — the determinism boundary (capabilityInvoke). */
89
+ readonly gateway: CapabilityGateway;
90
+ /** W15: registry of foreign-runtime adapters (the adaptation surface). */
91
+ readonly paeRegistry: PaeAdapterRegistry;
92
+ /** W15: the channel that publishes the adaptation surface to the hub. */
93
+ readonly paeChannel: PaeChannel;
94
+ /** W8: kinds served by a PAE adapter; routing flips to "pae" when non-empty. */
95
+ private readonly paeAdapterKinds;
96
+ /**
97
+ * W20: the physical layer — isolation domains allocated from the impact
98
+ * graph. Created lazily: a host that never allocates domains keeps its
99
+ * previous hub surface and fingerprint byte for byte.
100
+ */
101
+ private domainManager;
102
+ /** W20: the gateway surface over the domain manager's units. */
103
+ private domainChannel;
104
+ /** W20: the graph changed since the last allocation (plan needs a re-sync). */
105
+ private domainsStaleFlag;
106
+ /** W27: durable recording-window journal WAL path, if configured. */
107
+ private readonly recordJournalPath?;
108
+ /** Injected clock, threaded to every time-dependent decision that is recorded. */
109
+ private readonly clock?;
110
+ /** W27: the recording window currently attached to the gateway (for flush). */
111
+ private activeRecordJournal;
112
+ /**
113
+ * W27: the same instance as {@link traceJournal}, held at its durable type.
114
+ * `traceJournal` stays declared as the base class on purpose — call sites must
115
+ * not depend on durability — so retention/compaction needs its own handle.
116
+ */
117
+ private readonly durableTraceJournal;
118
+ /** W27: audit retention bound; undefined means unbounded. */
119
+ private readonly auditRetention?;
120
+ /** W29: resolved governance tier; drives limiter / trip / compression / PAE / durability. */
121
+ private readonly governanceProfile;
122
+ /** W30: HMAC key for the audit hash chain; undefined = unsigned journal. */
123
+ private readonly auditSigningKey?;
124
+ constructor(opts?: OrbitRuntimeHostOptions);
125
+ /**
126
+ * Capability required by a channel method. Native channels map statically;
127
+ * PAE tools are resolved through the registry so a foreign tool is governed
128
+ * at the same granularity as a native method (read vs write), never wholesale.
129
+ * An unknown tool is treated as a write — the conservative default — so a
130
+ * mis-registered surface fails closed.
131
+ */
132
+ private requiredCapabilityFor;
133
+ /** Host-private trip pre-check delegating to the gateway's per-plugin map. */
134
+ private tripPreCheckFor;
135
+ /**
136
+ * The run-version fingerprint a recorded trace carries (W7, extended W15/W20).
137
+ *
138
+ * Both optional fields are **omitted rather than empty**: a host that never
139
+ * registers an adapter or allocates a domain produces exactly the fingerprint
140
+ * it produced before those layers existed, so a trace recorded on an older
141
+ * kernel is reported as configuration drift — never as a mystery digest
142
+ * mismatch.
143
+ */
144
+ runFingerprint(): RunVersionFingerprint;
145
+ /**
146
+ * W29: the resolved governance tier and its concrete numbers. Read-only —
147
+ * the tier is a construction-time decision; switching it means constructing
148
+ * a host with `governanceProfile`.
149
+ */
150
+ get currentGovernanceProfile(): GovernanceProfile;
151
+ bootHost(): Promise<void>;
152
+ /**
153
+ * W30: prove the audit trail has not been tampered with. Recomputes the
154
+ * hash chain from the genesis seed and reports the first broken entry.
155
+ * An unsigned journal (no key configured) reports `signed: false` and is
156
+ * vacuously consistent.
157
+ */
158
+ verifyAuditChain(): AuditChainReport;
159
+ /**
160
+ * W27: enforce the configured audit-retention bound and compact the WAL.
161
+ *
162
+ * Called automatically at boot and shutdown; exposed so an operator can prune
163
+ * a long-running host on demand without a restart.
164
+ *
165
+ * @returns the number of audit entries retained.
166
+ */
167
+ pruneAuditLog(): Promise<number>;
168
+ /** Reverse-order teardown: pool -> pact -> guards -> channels -> journal -> graph. */
169
+ shutdownHost(): Promise<void>;
170
+ /** Register a plugin; its declared channel deps feed the impact graph (M3). */
171
+ registerPlugin(pact: PluginUnitPact): void;
172
+ /** Spawn an agent sandbox; its channel deps feed the impact graph (M3). */
173
+ spawnAgentBox(cfg: AgentBoxConfig): AgentSandbox;
174
+ /**
175
+ * W8: declare a PAE adapter for a channel kind. Once any adapter is
176
+ * registered the gateway's `route` decision becomes "pae" for governed
177
+ * calls, and the run fingerprint's `paeEnabled` flips — so a trace recorded
178
+ * before PAE existed is detected as config drift, never as a digest mismatch.
179
+ */
180
+ registerPaeAdapter(kind: ChannelKind): void;
181
+ /**
182
+ * W15: attach a real foreign-runtime adapter.
183
+ *
184
+ * The adapter is validated, indexed and published as tools on the PAE
185
+ * channel, and a **dynamic pact** is derived from its declared surface and
186
+ * registered like any hand-written plugin manifest. That is what keeps the
187
+ * promise of "MCP-grade ecosystem reach without a governance downgrade": the
188
+ * foreign tool now passes the same capability check, trip protection, budget
189
+ * accounting and recording as a native channel method, because it *is* one.
190
+ *
191
+ * @returns the derived pact (already registered unless `registerPact: false`).
192
+ */
193
+ registerPaeToolAdapter(adapter: IPaeAdapter, opts?: {
194
+ registerPact?: boolean;
195
+ requireHostMinEdition?: string;
196
+ }): PluginUnitPact;
197
+ /**
198
+ * W29+W31: the governance gate for foreign adapters — kind admission
199
+ * (`paeAdmission`) and isolation cap (`maxIsolationLevel`, the trust
200
+ * assumption). `strict` admits no kind at all and caps isolation at L1; a
201
+ * denied adapter is rejected outright rather than half-connected.
202
+ */
203
+ private assertPaeAdmitted;
204
+ /**
205
+ * Register an adapter whose surface is only knowable *after* a handshake.
206
+ *
207
+ * `registerPaeToolAdapter` resolves the capability surface at registration
208
+ * time, which presupposes that the surface already exists. An MCP server
209
+ * announces its tools over the wire, so there is nothing to resolve until the
210
+ * connection is up. This variant connects first, lets the adapter discover
211
+ * what the peer actually exposes, and then registers exactly that.
212
+ *
213
+ * The handshake is not a governance bypass: registration still runs the same
214
+ * static validation and still derives a dynamic pact from the *discovered*
215
+ * surface, so a server that later announces a new tool is configuration drift
216
+ * on the next replay rather than a silently expanded capability.
217
+ */
218
+ connectPaeToolAdapter(adapter: IPaeAdapter, opts?: {
219
+ registerPact?: boolean;
220
+ requireHostMinEdition?: string;
221
+ maxWaitMs?: number;
222
+ }): Promise<PluginUnitPact>;
223
+ /**
224
+ * Detach an adapter: its tools stop being dispatchable, its derived pact is
225
+ * revoked, and the routing flag clears once the surface is empty. A trace
226
+ * recorded while it was present then replays as configuration drift, not as
227
+ * a mysterious digest mismatch.
228
+ *
229
+ * Resources held by the adapter are released in the background; use
230
+ * `releasePaeToolAdapter` when you need to wait for that to complete (for
231
+ * example before the process exits, or in a test that asserts a subprocess
232
+ * is gone).
233
+ */
234
+ unregisterPaeToolAdapter(adapterId: string): void;
235
+ /**
236
+ * Detach an adapter and await its release.
237
+ *
238
+ * Same as `unregisterPaeToolAdapter`, plus a wait for `teardown` to finish —
239
+ * the difference matters for adapters that own an OS process (MCP), where
240
+ * "unregistered" and "peer actually shut down" are separated by real time.
241
+ */
242
+ releasePaeToolAdapter(adapterId: string): Promise<void>;
243
+ /**
244
+ * Connect adapters registered after `bootHost`. Idempotent — adapters that
245
+ * are already connected are skipped, so it is safe to call after every batch
246
+ * of registrations.
247
+ */
248
+ bootPaeAdapters(): Promise<void>;
249
+ /**
250
+ * Capability negotiation for a foreign tool: returns the descriptor when the
251
+ * mapping is at least as faithful as required, otherwise throws. Callers make
252
+ * an informed choice instead of silently receiving a degraded result.
253
+ */
254
+ negotiatePaeTool(toolName: string, minFidelity?: PaeFidelity): PaeToolDescriptor;
255
+ /**
256
+ * M2: open a recording window; sandboxes running in "record" mode fill it.
257
+ *
258
+ * W27: when the host was constructed with `recordJournalPath`, the window is
259
+ * durable — every recorded call is mirrored to the WAL. Opening a *new* window
260
+ * truncates that WAL first (a fresh window must not inherit the previous
261
+ * run's calls); use {@link resumeRecording} to continue a prior window instead.
262
+ */
263
+ beginRecording(): RecordJournal;
264
+ /**
265
+ * W27: reopen the durable recording window persisted by a previous process.
266
+ *
267
+ * Recovers the WAL (crash-safe: a truncated trailing line is dropped) and
268
+ * re-attaches it, so `orderIndex` continues from the recovered length and the
269
+ * combined journal replays as one uninterrupted run. Without a configured
270
+ * `recordJournalPath` this degrades to a plain in-memory window.
271
+ */
272
+ resumeRecording(): Promise<RecordJournal>;
273
+ /**
274
+ * W27: the recording window currently attached to the gateway, or `null` if
275
+ * none was ever opened. After a boot with `recordJournalPath` configured this
276
+ * is the journal recovered from the WAL, so callers can inspect or replay a
277
+ * window persisted by a previous process without reopening it.
278
+ */
279
+ currentRecordJournal(): RecordJournal | null;
280
+ /** M2: attach a replay engine over a previously recorded journal. */
281
+ attachReplayEngine(journal: RecordJournal): ReplayEngine;
282
+ /** W7: the unified gateway entry — deterministic boundary for governed calls. */
283
+ capabilityInvoke<T>(params: {
284
+ kind: ChannelKind;
285
+ pluginId?: string;
286
+ funcName: string;
287
+ args: unknown[];
288
+ mode: ReplayMode;
289
+ ctx?: Partial<ChannelCallCtx>;
290
+ }): Promise<T>;
291
+ /**
292
+ * W31: gateway-side parameter validation for PAE tools that declare a
293
+ * schema. The error is raised as a plain Error (user-classified 400 by the
294
+ * console bridge); the recorded call never happens, so nothing to replay.
295
+ */
296
+ private assertArgsAgainstSchema;
297
+ /** M3: nodes that would be affected if the given node fails (reachability closure). */
298
+ isolationDomain(nodeId: string): string[];
299
+ /** M3: isolation theorem query — two nodes are provably independent. */
300
+ areIsolated(a: string, b: string): boolean;
301
+ /** M4: choose the cheapest channel that fits the budget and latency target. */
302
+ routeChannel(kinds: ChannelKind[], budget: number, maxLatencyMs: number): ChannelKind | undefined;
303
+ /** Whether the impact graph changed since the last domain allocation. */
304
+ domainsStale(): boolean;
305
+ /**
306
+ * Allocate isolation domains from the current impact graph and publish their
307
+ * unit surface on the gateway (W19 channel, W20 host state).
308
+ *
309
+ * Idempotent for a given graph: the sync is a diff, so re-running after a
310
+ * no-op graph change neither restarts child processes nor perturbs the plan
311
+ * hash. Registering the channel happens here and only here — a host that
312
+ * never allocates domains keeps its previous hub surface and fingerprint.
313
+ */
314
+ allocateIsolationDomains(opts?: {
315
+ transportFactory?: DomainTransportFactory;
316
+ clock?: ClockSource;
317
+ maxImpactClosure?: number;
318
+ maxDomainSize?: number;
319
+ defaultTimeoutMs?: number;
320
+ }): Promise<IsolationDomainPlan>;
321
+ /** The current domain plan, or `null` before the first allocation. */
322
+ domainPlan(): IsolationDomainPlan | null;
323
+ /** Running domains: id, units and isolation level, sorted. */
324
+ domains(): Array<{
325
+ domainId: string;
326
+ units: string[];
327
+ isolation: string;
328
+ }>;
329
+ /**
330
+ * Invoke a unit in its domain through the gateway — the cross-domain hop.
331
+ * Recorded and replayed like any other governed call; settled in the domain
332
+ * transaction ledger either way.
333
+ */
334
+ invokeDomainUnit<T>(unitId: string, tool: string, args?: unknown[], opts?: {
335
+ pluginUnitId?: string;
336
+ mode?: ReplayMode;
337
+ ctx?: Partial<ChannelCallCtx>;
338
+ }): Promise<T>;
339
+ /** The cross-domain transaction ledger (decision → execution → result). */
340
+ domainLedger(): readonly DomainTransaction[];
341
+ /** Reconcile the ledger — cross-domain events must balance (VISION 2.2). */
342
+ reconcileDomainTransactions(): DomainReconciliation;
343
+ /** Tear down every domain and release its host process. */
344
+ releaseIsolationDomains(): Promise<void>;
345
+ /** Context for domain synchronization calls. */
346
+ private domainCtx;
347
+ private newHostCtx;
348
+ }
349
+ //# sourceMappingURL=orbitRuntimeHost.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orbitRuntimeHost.d.ts","sourceRoot":"","sources":["../../../src/core/orbitRuntimeHost.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,OAAO,EAAE,YAAY,EAAyB,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAA0B,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAA+B,MAAM,iBAAiB,CAAC;AACjF,OAAO,EAAE,WAAW,EAA6B,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAMrF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MA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