theorum 1.0.0 → 1.1.3

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 (204) hide show
  1. package/README.md +81 -25
  2. package/esm/mod.d.ts +48 -29
  3. package/esm/mod.js +37 -24
  4. package/esm/src/cli/commands/bench.js +13 -16
  5. package/esm/src/cli/commands/fuzz-canary.js +25 -29
  6. package/esm/src/cli/commands/guardrails-eval.d.ts +14 -0
  7. package/esm/src/cli/commands/guardrails-eval.js +15 -0
  8. package/esm/src/cli/commands/profile.js +12 -3
  9. package/esm/src/cli/commands/run.js +8 -9
  10. package/esm/src/cli/commands/test.js +8 -8
  11. package/esm/src/cli/event-log.d.ts +1 -1
  12. package/esm/src/cli/index.js +12 -0
  13. package/esm/src/cli/matrix/synthesizer.d.ts +6 -6
  14. package/esm/src/cli/matrix/synthesizer.js +23 -22
  15. package/esm/src/guardrails/canary-gate.d.ts +2 -1
  16. package/esm/src/guardrails/canary-gate.js +2 -1
  17. package/esm/src/guardrails/canary.d.ts +9 -1
  18. package/esm/src/guardrails/canary.js +21 -10
  19. package/esm/src/guardrails/corpus/canary-egress-attacks.d.ts +1 -0
  20. package/esm/src/guardrails/corpus/fuzz-inbound.js +12 -15
  21. package/esm/src/guardrails/corpus/inbound-payloads.js +1 -0
  22. package/esm/src/guardrails/corpus/live-attacks.js +0 -1
  23. package/esm/src/guardrails/corpus/mod.d.ts +1 -0
  24. package/esm/src/guardrails/corpus/secrets.d.ts +1 -0
  25. package/esm/src/guardrails/corpus/secrets.js +1 -0
  26. package/esm/src/guardrails/corpus/strings.d.ts +1 -0
  27. package/esm/src/guardrails/corpus/strings.js +1 -0
  28. package/esm/src/guardrails/corpus/types.d.ts +1 -0
  29. package/esm/src/guardrails/egress.d.ts +26 -3
  30. package/esm/src/guardrails/egress.js +69 -18
  31. package/esm/src/guardrails/error.d.ts +14 -23
  32. package/esm/src/guardrails/error.js +86 -77
  33. package/esm/src/guardrails/eval/corpus.d.ts +108 -0
  34. package/esm/src/guardrails/eval/corpus.js +978 -0
  35. package/esm/src/guardrails/eval/mod.d.ts +51 -0
  36. package/esm/src/guardrails/eval/mod.js +133 -0
  37. package/esm/src/guardrails/eval/score.d.ts +66 -0
  38. package/esm/src/guardrails/eval/score.js +114 -0
  39. package/esm/src/guardrails/events.d.ts +25 -0
  40. package/esm/src/guardrails/events.js +56 -0
  41. package/esm/src/guardrails/hits.d.ts +24 -0
  42. package/esm/src/guardrails/hits.js +45 -0
  43. package/esm/src/guardrails/lexicon.d.ts +39 -0
  44. package/esm/src/guardrails/lexicon.js +200 -0
  45. package/esm/src/guardrails/live-outbound-gate.d.ts +15 -13
  46. package/esm/src/guardrails/live-outbound-gate.js +131 -89
  47. package/esm/src/guardrails/mod.d.ts +19 -4
  48. package/esm/src/guardrails/mod.js +12 -3
  49. package/esm/src/guardrails/network.d.ts +19 -0
  50. package/esm/src/guardrails/network.js +234 -0
  51. package/esm/src/guardrails/policy.d.ts +35 -0
  52. package/esm/src/guardrails/policy.js +50 -0
  53. package/esm/src/guardrails/progressive-yield.d.ts +51 -0
  54. package/esm/src/guardrails/progressive-yield.js +98 -0
  55. package/esm/src/guardrails/quota.d.ts +17 -3
  56. package/esm/src/guardrails/quota.js +18 -4
  57. package/esm/src/guardrails/sanitize.d.ts +36 -6
  58. package/esm/src/guardrails/sanitize.js +152 -60
  59. package/esm/src/guardrails/serialize.d.ts +35 -0
  60. package/esm/src/guardrails/serialize.js +58 -0
  61. package/esm/src/guardrails/testing.d.ts +7 -0
  62. package/esm/src/guardrails/testing.js +4 -0
  63. package/esm/src/guardrails/theorum-error.d.ts +12 -0
  64. package/esm/src/guardrails/theorum-error.js +15 -0
  65. package/esm/src/guardrails/tool-directives.d.ts +48 -0
  66. package/esm/src/guardrails/tool-directives.js +124 -0
  67. package/esm/src/guardrails/tool-result.d.ts +93 -0
  68. package/esm/src/guardrails/tool-result.js +276 -0
  69. package/esm/src/guardrails/types.d.ts +291 -0
  70. package/esm/src/guardrails/types.js +72 -0
  71. package/esm/src/host/client-turn.js +4 -0
  72. package/esm/src/host/mint-trace.d.ts +1 -1
  73. package/esm/src/kernel/auth/crypto.d.ts +42 -0
  74. package/esm/src/kernel/auth/crypto.js +106 -0
  75. package/esm/src/kernel/auth/mod.d.ts +11 -0
  76. package/esm/src/kernel/auth/mod.js +11 -0
  77. package/esm/src/kernel/auth/oauth.d.ts +47 -0
  78. package/esm/src/kernel/auth/oauth.js +278 -0
  79. package/esm/src/kernel/auth/types.d.ts +133 -0
  80. package/esm/src/kernel/auth/types.js +13 -0
  81. package/esm/src/kernel/engine/delta.js +43 -2
  82. package/esm/src/kernel/engine/live-inbound.d.ts +15 -3
  83. package/esm/src/kernel/engine/live-inbound.js +22 -8
  84. package/esm/src/kernel/engine/live-ingress.d.ts +19 -0
  85. package/esm/src/kernel/engine/live-ingress.js +47 -0
  86. package/esm/src/kernel/engine/repair.js +13 -12
  87. package/esm/src/kernel/engine/runner/gates.js +127 -40
  88. package/esm/src/kernel/engine/runner/mod.d.ts +6 -4
  89. package/esm/src/kernel/engine/runner/mod.js +182 -43
  90. package/esm/src/kernel/engine/runner/schema-validation.js +3 -3
  91. package/esm/src/kernel/engine/runner/stages.d.ts +39 -0
  92. package/esm/src/kernel/engine/runner/stages.js +89 -0
  93. package/esm/src/kernel/engine/runner/state.d.ts +24 -0
  94. package/esm/src/kernel/engine/runner/steps.js +128 -61
  95. package/esm/src/kernel/engine/runner/stream.d.ts +9 -2
  96. package/esm/src/kernel/engine/runner/stream.js +114 -55
  97. package/esm/src/kernel/engine/session/mod.d.ts +3 -1
  98. package/esm/src/kernel/engine/session/mod.js +386 -34
  99. package/esm/src/kernel/interaction-parts.d.ts +14 -0
  100. package/esm/src/kernel/interaction-parts.js +23 -0
  101. package/esm/src/kernel/mod.d.ts +19 -7
  102. package/esm/src/kernel/mod.js +10 -5
  103. package/esm/src/kernel/profile-graph.d.ts +159 -0
  104. package/esm/src/kernel/profile-graph.js +156 -0
  105. package/esm/src/kernel/registry/attachments.d.ts +10 -10
  106. package/esm/src/kernel/registry/attachments.js +29 -26
  107. package/esm/src/kernel/registry/catalog.d.ts +25 -11
  108. package/esm/src/kernel/registry/catalog.js +59 -24
  109. package/esm/src/kernel/registry/ingress.js +34 -22
  110. package/esm/src/kernel/registry/profile-outputs.d.ts +4 -0
  111. package/esm/src/kernel/registry/profile-outputs.js +8 -0
  112. package/esm/src/kernel/registry/profiles.d.ts +34 -14
  113. package/esm/src/kernel/registry/profiles.js +306 -59
  114. package/esm/src/kernel/registry/provider-request.js +2 -0
  115. package/esm/src/kernel/registry/resolve.d.ts +7 -6
  116. package/esm/src/kernel/registry/resolve.js +102 -117
  117. package/esm/src/kernel/registry/schemas.js +1 -1
  118. package/esm/src/kernel/registry/sole-model.d.ts +8 -0
  119. package/esm/src/kernel/registry/sole-model.js +10 -0
  120. package/esm/src/kernel/registry/system-prompt.d.ts +10 -0
  121. package/esm/src/kernel/registry/system-prompt.js +40 -0
  122. package/esm/src/kernel/registry/system-role.d.ts +8 -0
  123. package/esm/src/kernel/registry/system-role.js +14 -0
  124. package/esm/src/kernel/registry/vault.d.ts +2 -2
  125. package/esm/src/kernel/registry/vault.js +4 -4
  126. package/esm/src/kernel/schema.d.ts +97 -11
  127. package/esm/src/kernel/schema.js +256 -111
  128. package/esm/src/kernel/stages.d.ts +175 -0
  129. package/esm/src/kernel/stages.js +476 -0
  130. package/esm/src/kernel/stop.d.ts +65 -11
  131. package/esm/src/kernel/stop.js +46 -11
  132. package/esm/src/kernel/tools/events.d.ts +41 -0
  133. package/esm/src/kernel/tools/events.js +71 -0
  134. package/esm/src/kernel/tools/execute.d.ts +63 -24
  135. package/esm/src/kernel/tools/execute.js +475 -224
  136. package/esm/src/kernel/tools/harness.js +16 -14
  137. package/esm/src/kernel/tools/invoke.js +26 -8
  138. package/esm/src/kernel/tools/mod.d.ts +3 -1
  139. package/esm/src/kernel/tools/mod.js +2 -1
  140. package/esm/src/kernel/tools/permission.d.ts +15 -0
  141. package/esm/src/kernel/tools/permission.js +47 -0
  142. package/esm/src/kernel/tools/project.js +5 -3
  143. package/esm/src/kernel/tools/registry.js +20 -10
  144. package/esm/src/kernel/tools/remote.d.ts +94 -0
  145. package/esm/src/kernel/tools/remote.js +577 -0
  146. package/esm/src/kernel/tools/resolve.d.ts +17 -7
  147. package/esm/src/kernel/tools/resolve.js +38 -17
  148. package/esm/src/kernel/tools/schema.d.ts +2 -0
  149. package/esm/src/kernel/tools/schema.js +23 -6
  150. package/esm/src/kernel/tools/stage-run.d.ts +105 -0
  151. package/esm/src/kernel/tools/stage-run.js +155 -0
  152. package/esm/src/kernel/tools/types.d.ts +198 -20
  153. package/esm/src/kernel/types.d.ts +253 -114
  154. package/esm/src/kernel/util/find-last.d.ts +2 -0
  155. package/esm/src/kernel/util/find-last.js +10 -0
  156. package/esm/src/observability/destinations.d.ts +31 -0
  157. package/esm/src/observability/destinations.js +67 -0
  158. package/esm/src/observability/mod.d.ts +10 -3
  159. package/esm/src/observability/mod.js +6 -2
  160. package/esm/src/observability/policy.d.ts +27 -0
  161. package/esm/src/observability/policy.js +80 -0
  162. package/esm/src/observability/resolve-policy.d.ts +16 -0
  163. package/esm/src/observability/resolve-policy.js +64 -0
  164. package/esm/src/observability/trace-attach.d.ts +3 -1
  165. package/esm/src/observability/trace-attach.js +17 -10
  166. package/esm/src/observability/trace-record.d.ts +12 -4
  167. package/esm/src/observability/trace-record.js +63 -19
  168. package/esm/src/observability/trace-sink.d.ts +19 -0
  169. package/esm/src/observability/trace-sink.js +10 -0
  170. package/esm/src/observability/trace.d.ts +14 -11
  171. package/esm/src/observability/trace.js +23 -14
  172. package/esm/src/observability/types.d.ts +113 -0
  173. package/esm/src/observability/types.js +11 -0
  174. package/esm/src/providers/create-provider.d.ts +7 -4
  175. package/esm/src/providers/create-provider.js +21 -7
  176. package/esm/src/providers/google/interactions/framing.d.ts +8 -0
  177. package/esm/src/providers/google/interactions/framing.js +74 -13
  178. package/esm/src/providers/google/live/framing.d.ts +5 -2
  179. package/esm/src/providers/google/live/framing.js +49 -12
  180. package/esm/src/providers/google/live/openapi-schema.js +3 -2
  181. package/esm/src/providers/google/live/stream.d.ts +9 -0
  182. package/esm/src/providers/google/live/stream.js +16 -3
  183. package/esm/src/providers/openrouter/cache-control.d.ts +24 -0
  184. package/esm/src/providers/openrouter/cache-control.js +23 -0
  185. package/esm/src/providers/openrouter/chat.d.ts +21 -1
  186. package/esm/src/providers/openrouter/chat.js +51 -6
  187. package/esm/src/providers/openrouter/image.js +8 -19
  188. package/esm/src/providers/openrouter/openai/chat-payload.js +23 -1
  189. package/esm/src/providers/openrouter/openai/compat.d.ts +7 -1
  190. package/esm/src/providers/openrouter/openai/compat.js +23 -4
  191. package/esm/src/providers/openrouter/openai/image-payload.js +8 -2
  192. package/esm/src/providers/openrouter/openai/sdk-messages.d.ts +1 -1
  193. package/esm/src/providers/openrouter/openai/sdk-messages.js +32 -5
  194. package/package.json +1 -1
  195. package/esm/src/interface/blocks.d.ts +0 -20
  196. package/esm/src/interface/blocks.js +0 -180
  197. package/esm/src/interface/from-profile.d.ts +0 -14
  198. package/esm/src/interface/from-profile.js +0 -104
  199. package/esm/src/interface/inputs.d.ts +0 -8
  200. package/esm/src/interface/inputs.js +0 -127
  201. package/esm/src/interface/mod.d.ts +0 -10
  202. package/esm/src/interface/mod.js +0 -9
  203. package/esm/src/interface/types.d.ts +0 -153
  204. package/esm/src/interface/types.js +0 -13
@@ -7,9 +7,10 @@
7
7
  *
8
8
  * @module
9
9
  */
10
- import type { CompactionMeter, CompactionTiming, ControlId, EgressOnBlock, FieldMeta, KeySlot, KeyVault, LiveActivityHandling, LiveContextCompression, LiveSpeechSensitivity, MediaInputKind, OverflowKeySlot, ProfileType, ProfileTypeProtocol, Protocol, Provider, SchemaEnforcement, SpeechAudioFormat, StreamMode, SummaryMode, ThinkingLevel, ToolLoadTier, TurnStopKind } from './schema.js';
11
- import type { InvokeToolRequest, ProfileToolsSpec, RegisteredTool, ToolCallEvent, ToolLoadContext, ToolPolicy, TurnToolSnapshot, WireFunctionTool } from './tools/types.js';
12
- export type { CompactionMeter, CompactionTiming, ControlId, EgressOnBlock, FieldMeta, InvokeToolRequest, KeySlot, KeyVault, LiveActivityHandling, LiveContextCompression, LiveSpeechSensitivity, MediaInputKind, OverflowKeySlot, ProfileToolsSpec, ProfileType, ProfileTypeProtocol, Protocol, Provider, RegisteredTool, SchemaEnforcement, SpeechAudioFormat, StreamMode, SummaryMode, ThinkingLevel, ToolCallEvent, ToolLoadContext, ToolLoadTier, ToolPolicy, TurnStopKind, TurnToolSnapshot, WireFunctionTool, };
10
+ import type { CacheMode, CacheTtl, CompactionMeter, CompactionTiming, ContinueStopKind, FieldMeta, KeySlot, KeyVault, LiveActivityHandling, LiveContextCompression, LiveSpeechSensitivity, MediaInputKind, OverflowKeySlot, ProfileType, ProfileTypeProtocol, Protocol, Provider, SchemaEnforcement, SpeechAudioFormat, StreamMode, SummaryMode, ThinkingLevel, ToolLoadTier, TurnStage, TurnStopKind } from './schema.js';
11
+ import type { StageApplyWarning, StageHandler } from './stages.js';
12
+ import type { HostProfileToolsSpec, InvokeToolRequest, InvokeToolResume, LiveProfileToolsSpec, ModelToolResult, ProfileToolsSpec, RegisteredTool, ToolCallEvent, ToolFailure, ToolGate, ToolLoadContext, ToolPolicy, TurnToolSnapshot, WireFunctionTool } from './tools/types.js';
13
+ export type { CacheMode, CacheTtl, CompactionMeter, CompactionTiming, ContinueStopKind, FieldMeta, HostProfileToolsSpec, InvokeToolRequest, KeySlot, KeyVault, LiveActivityHandling, LiveContextCompression, LiveProfileToolsSpec, LiveSpeechSensitivity, MediaInputKind, OverflowKeySlot, ProfileToolsSpec, ProfileType, ProfileTypeProtocol, Protocol, Provider, RegisteredTool, SchemaEnforcement, SpeechAudioFormat, StreamMode, SummaryMode, ThinkingLevel, ToolCallEvent, ToolGate, ToolLoadContext, ToolLoadTier, ToolPolicy, TurnStage, TurnStopKind, TurnToolSnapshot, WireFunctionTool, };
13
14
  /** Any host-declared model id. */
14
15
  export type ModelId = string;
15
16
  /** Provider-projected builtin tool id (registered by presets/adapters). */
@@ -24,7 +25,7 @@ export type ProfileId = string;
24
25
  export type ChatRole = 'system' | 'user' | 'assistant';
25
26
  /**
26
27
  * Image-role output pins owned by the host profile.
27
- * The image model itself lives in `model.allow` / `model.config`.
28
+ * The image model itself lives in `profile.models`.
28
29
  * Aspect/size/mime values are host strings (presets/apps own the vocabularies).
29
30
  */
30
31
  export interface ProfileImageSpec {
@@ -43,34 +44,34 @@ export interface ProfileImageSpec {
43
44
  includeText?: boolean;
44
45
  }
45
46
  /** Public event types emitted by `runTurn` and provider adapters. */
46
- export type TurnEventType = 'thought' | 'text' | 'tool' | 'structured' | 'media' | 'grounding' | 'evidence' | 'tokens' | 'session' | 'done' | 'error';
47
- /** Live session control signals (provider-neutral). */
48
- export type SessionEventKind = 'closing_soon' | 'waiting_for_input';
47
+ export type TurnEventType = 'thought' | 'text' | 'tool' | 'structured' | 'media' | 'grounding' | 'evidence' | 'tokens' | 'session' | 'guardrail' | 'stage' | 'done' | 'error';
48
+ /**
49
+ * Live session control signals (provider-neutral).
50
+ *
51
+ * - `turn_complete` — one spoken response ended; the server may still be working.
52
+ * - `working` — server is reasoning or awaiting async tool results; more output may follow.
53
+ * - `idle` — server finished all processing; conversational cycle boundary.
54
+ */
55
+ export type SessionEventKind = 'closing_soon' | 'waiting_for_input' | 'turn_complete' | 'working' | 'idle';
49
56
  export interface SessionEvent {
50
57
  kind: SessionEventKind;
51
58
  /** Parsed drain window when the provider supplied a duration; omit when unknown. */
52
59
  timeLeftMs?: number;
53
60
  }
54
- /** Provider thinking levels used when a boolean thinking control is on or off. */
55
- export interface ThinkingMap {
56
- on: ThinkingLevel;
57
- off: ThinkingLevel;
58
- }
59
- /** Provider summary behavior used when a boolean thinking control is on or off. */
60
- export interface SummaryMap {
61
- on: SummaryMode;
62
- off: SummaryMode;
63
- }
64
- /** Host-declared metadata THEORUM needs to call a model safely. */
65
- export interface ModelSpec {
61
+ /** Host-named model binding wire routing and generation knobs for one profile model. */
62
+ export interface ModelBinding {
63
+ protocol: Protocol;
64
+ provider: Provider;
66
65
  /** Provider wire model id for the configured provider. */
67
66
  apiId: string;
68
- /** Thinking on/off map when the profile lists `thinking` in controls. Omit provider default. */
69
- thinking?: ThinkingMap;
70
- /** Levels this model accepts. Illegal values are clamped via `thinkingLevels`. */
71
- thinkingLevels?: ThinkingLevel[];
72
- /** Thinking-summary on/off map. Omit provider default. */
73
- summaries?: SummaryMap;
67
+ /** Alias thinking level. One entry = fixed; two+ may be selectable at turn time. */
68
+ efforts?: Record<string, ThinkingLevel>;
69
+ /** Effort alias when the turn omits `effort`. Defaults to the only key when there is one. */
70
+ defaultEffort?: string;
71
+ /** Turn may pass `{ effort: "<alias>" }`. Requires two or more `efforts` keys. */
72
+ allowEffortSelect?: boolean;
73
+ /** Emit thinking summaries on the stream. Omit → provider default. */
74
+ summaries?: boolean;
74
75
  /** Cap on output tokens. Omit → provider default. */
75
76
  maxOutputTokens?: number;
76
77
  /** Sampling temperature. Omit → provider default. */
@@ -81,12 +82,17 @@ export interface ModelSpec {
81
82
  */
82
83
  builtInTools?: BuiltinToolId[];
83
84
  /**
84
- * Optional vault slot for this model. When set, overrides `profile.model.key`.
85
+ * Optional vault slot for this model. When set, overrides `profile.key`.
85
86
  * Host-owned — e.g. pin image models to `paid`.
86
87
  */
87
88
  key?: KeySlot;
88
89
  /** Optional compaction policy for this model's context window (chat profiles). */
89
90
  compaction?: CompactionSpec;
91
+ /**
92
+ * OpenRouter prompt-cache policy. Omit → no opt-in `cache_control`.
93
+ * `defineProfile` accepts only when `provider` is `openrouter` (protocol `openAi`).
94
+ */
95
+ cache?: CacheSpec;
90
96
  /** Gemini Interactions: whether the provider stores the interaction. Omit → provider default. */
91
97
  store?: boolean;
92
98
  /**
@@ -95,6 +101,17 @@ export interface ModelSpec {
95
101
  */
96
102
  persistViaInteractionId?: boolean;
97
103
  }
104
+ /**
105
+ * OpenRouter prompt-cache policy (`models.*.cache`).
106
+ *
107
+ * - `automatic` — top-level `cache_control`; breakpoint advances with the conversation.
108
+ * - `system` — explicit breakpoint on the system instruction only.
109
+ */
110
+ export interface CacheSpec {
111
+ mode: CacheMode;
112
+ /** Ephemeral TTL. Omit → provider default (typically 5m on Anthropic). */
113
+ ttl?: CacheTtl;
114
+ }
98
115
  /**
99
116
  * Context supplied to a custom compaction trigger.
100
117
  *
@@ -209,7 +226,7 @@ export interface ProfileValidationSpec {
209
226
  }
210
227
  /**
211
228
  * Speech-role output pins owned by the host profile.
212
- * The speech model itself lives in `model.allow` / `model.config`.
229
+ * The speech model itself lives in `profile.models`.
213
230
  * Declared top-level under `speech` so `voice` here is the TTS voice id,
214
231
  * not ingress audio (`inputs.voice`).
215
232
  */
@@ -234,11 +251,26 @@ export interface LiveTranscriptionSpec {
234
251
  input?: boolean;
235
252
  output?: boolean;
236
253
  }
254
+ /**
255
+ * Realtime ingress modalities for a live session.
256
+ * Distinct from turn `inputs` (file attachments, MIME limits) — these gate
257
+ * `LiveSession.sendAudio` / `sendVideo` / `sendText` channels.
258
+ */
259
+ export interface LiveIngressSpec {
260
+ /** Microphone PCM via `sendAudio`. Omit → enabled. */
261
+ audio?: boolean;
262
+ /** Webcam JPEG frames via `sendVideo`. Omit → enabled. */
263
+ video?: boolean;
264
+ /** Typed text via `sendText`. Omit → disabled (opt-in). */
265
+ text?: boolean;
266
+ }
237
267
  /**
238
268
  * Output pins for a live-role profile (bidirectional WebSocket audio/video session).
239
- * The live model itself lives in `model.allow` / `model.config`.
269
+ * The live model itself lives in `profile.models`.
240
270
  */
241
271
  export interface ProfileLiveSpec {
272
+ /** Realtime ingress modality toggles (mic, camera frames, typed text). */
273
+ ingress?: LiveIngressSpec;
242
274
  /** Output TTS voice name (e.g. 'Puck', 'Aoede', 'Charon'). */
243
275
  voice?: string;
244
276
  /** Voice activity detection & barge-in configuration. */
@@ -263,54 +295,19 @@ export interface ProfileStreamingSpec {
263
295
  /** When false, filter `thought` events from the turn stream. */
264
296
  streamThoughts?: boolean;
265
297
  }
266
- export type { ProfileTurnResumptionSpec, TurnContinueFrom, TurnStop } from './stop.js';
267
- import type { ProfileTurnResumptionSpec, TurnContinueFrom, TurnStop } from './stop.js';
268
- /** Context passed to a host-owned outbound disclosure guard. */
269
- export interface EgressContext {
270
- text: string;
271
- canary?: string;
272
- slots?: Record<string, string>;
273
- profile: Profile;
274
- role?: string;
275
- }
276
- /** Decision returned by an egress guard. */
277
- export interface EgressEnforcementResult {
278
- blocked: boolean;
279
- text: string;
280
- hits?: string[];
281
- rejectionMessage?: string | null;
282
- }
283
- /** Function that evaluates candidate user-visible output before release. */
284
- export type EgressEnforcer = (context: EgressContext) => EgressEnforcementResult | Promise<EgressEnforcementResult>;
285
- /** Profile egress policy for rejection, retry, or refusal behavior. */
286
- export interface ProfileEgressSpec {
287
- enforce: EgressEnforcer;
288
- onBlock?: EgressOnBlock;
289
- maxRetries?: number;
290
- repairGuidance?: string;
291
- }
292
- /** Profile guardrail switches enforced by the kernel. */
293
- export interface ProfileGuardrailsSpec {
294
- /** Optional daily turn quota; omitted means quota enforcement is not configured. */
295
- quota?: {
296
- perDay: number;
297
- };
298
- canary?: boolean;
299
- sanitizeInput?: boolean;
300
- redactSensitive?: boolean;
301
- egress?: ProfileEgressSpec;
302
- }
303
- /** Model, provider, thinking, and step bounds for a profile. */
304
- export interface ProfileModelSpec<P extends Protocol = Protocol> {
305
- protocol: P;
306
- provider: Provider;
307
- /** Ids this profile may select. Each id must exist in `config`. */
308
- allow: ModelId[];
309
- /** Host-owned wire config keyed by the same ids used in `allow` / `select`. */
310
- config: Record<ModelId, ModelSpec>;
311
- select?: Record<string, ModelId>;
312
- thinking?: ThinkingLevel | Record<string, ThinkingLevel>;
313
- controls?: ControlId[];
298
+ export type { ProfileTurnBehaviourSpec, ProfileTurnResumptionSpec, TurnContinueFrom, TurnStop, } from './stop.js';
299
+ import type { GuardrailEvent, HostGuardrailsSpec, ProfileGuardrailsSpec } from '../guardrails/types.js';
300
+ import type { ProfileObservabilitySpec } from '../observability/types.js';
301
+ import type { ToolCredential } from './auth/types.js';
302
+ import type { ProfileTurnBehaviourSpec, TurnContinueFrom, TurnStop } from './stop.js';
303
+ /** Model routing fields shared by every profile type. */
304
+ export interface ProfileModelFields {
305
+ /** Host-named models. Each key is a selectable model id when `allowModelSelect` is set. */
306
+ models: Record<ModelId, ModelBinding>;
307
+ /** Default model id when the turn omits `model`. Defaults to the only key when there is one. */
308
+ defaultModel?: ModelId;
309
+ /** Turn may pass `{ model: "<id>" }`. Requires two or more `models` keys. */
310
+ allowModelSelect?: boolean;
314
311
  /**
315
312
  * Tool-loop ceiling. `<= 0` = unbounded; `1` = one-shot; `> 1` = hard cap.
316
313
  * Omit → unbounded (no THEORUM invent of `1`).
@@ -318,10 +315,6 @@ export interface ProfileModelSpec<P extends Protocol = Protocol> {
318
315
  maxSteps?: number;
319
316
  key?: OverflowKeySlot;
320
317
  }
321
- /** Wire model specification for turn-based profiles (text, image, speech). */
322
- export type TurnProfileModelSpec = ProfileModelSpec<ProfileTypeProtocol<'text'>>;
323
- /** Wire model specification for live bidirectional streaming profiles. */
324
- export type LiveProfileModelSpec = ProfileModelSpec<ProfileTypeProtocol<'live'>>;
325
318
  /** Text, attachment, voice, slot, and size rules for a profile. */
326
319
  export interface ProfileInputsSpec {
327
320
  text?: boolean;
@@ -350,43 +343,76 @@ export interface ProfileIdentity {
350
343
  systemByRole?: Record<string, string>;
351
344
  }
352
345
  /** Fields shared by every typed profile. */
353
- export interface ProfileCommon<P extends Protocol = Protocol> {
346
+ export interface ProfileCommon {
354
347
  id: ProfileId;
355
348
  identity: ProfileIdentity;
356
- model: ProfileModelSpec<P>;
349
+ models: Record<ModelId, ModelBinding>;
350
+ defaultModel?: ModelId;
351
+ allowModelSelect?: boolean;
352
+ maxSteps?: number;
353
+ key?: OverflowKeySlot;
357
354
  outputs?: ProfileOutputsSpec;
358
355
  guardrails?: ProfileGuardrailsSpec;
356
+ observability?: ProfileObservabilitySpec;
359
357
  }
360
358
  /** Text / structured turn engine with optional tool execution. */
361
- export interface TextProfile extends ProfileCommon<ProfileTypeProtocol<'text'>> {
359
+ export interface TextProfile extends ProfileCommon {
362
360
  type: 'text';
363
361
  tools: ProfileToolsSpec;
364
362
  inputs: ProfileInputsSpec;
365
- turnResumption?: ProfileTurnResumptionSpec;
363
+ /** Resume + mid-turn steering policy. */
364
+ turnBehaviour?: ProfileTurnBehaviourSpec;
366
365
  }
367
366
  /** Image-generation primary role. */
368
- export interface ImageProfile extends ProfileCommon<ProfileTypeProtocol<'image'>> {
367
+ export interface ImageProfile extends ProfileCommon {
369
368
  type: 'image';
370
369
  image: ProfileImageSpec;
371
370
  tools: ProfileToolsSpec;
372
371
  inputs: ProfileInputsSpec;
373
- turnResumption?: ProfileTurnResumptionSpec;
372
+ /** Resume policy (`allowSteering` is rejected — text/live only). */
373
+ turnBehaviour?: ProfileTurnBehaviourSpec;
374
374
  }
375
375
  /** Unary TTS — text-in locked by type; no tools / inputs block. */
376
- export interface SpeechProfile extends ProfileCommon<ProfileTypeProtocol<'speech'>> {
376
+ export interface SpeechProfile extends ProfileCommon {
377
377
  type: 'speech';
378
378
  speech: ProfileSpeechSpec;
379
- turnResumption?: ProfileTurnResumptionSpec;
379
+ /** Resume policy (`allowSteering` is rejected — text/live only). */
380
+ turnBehaviour?: ProfileTurnBehaviourSpec;
380
381
  }
381
382
  /** Bidirectional live session. */
382
- export interface LiveProfile extends ProfileCommon<ProfileTypeProtocol<'live'>> {
383
+ export interface LiveProfile extends Omit<ProfileCommon, 'outputs'> {
383
384
  type: 'live';
384
385
  live: ProfileLiveSpec;
385
- tools: ProfileToolsSpec;
386
- inputs?: ProfileInputsSpec;
386
+ tools: LiveProfileToolsSpec;
387
+ /**
388
+ * Stage inject gate only (`allowSteering`). Resumption is `live.sessionResumption`,
389
+ * not `turnBehaviour.resumption` (`docs/contracts/stages.md`).
390
+ */
391
+ turnBehaviour?: Pick<ProfileTurnBehaviourSpec, 'allowSteering'>;
392
+ }
393
+ /**
394
+ * Host-driven tool execution ceiling — never runs a model.
395
+ *
396
+ * `invokeTool` under a `host` profile executes any tool in `tools.allow` with no
397
+ * visibility or loading tiers and no path gating. No `models`, `identity`,
398
+ * `inputs`, `outputs`, `turnBehaviour`, `key`, or `maxSteps`. `resolveTurn`,
399
+ * `runTurn`, and `runSession` refuse it.
400
+ *
401
+ * `guardrails` is narrowed to {@link HostGuardrailsSpec}: only the guards that
402
+ * fire on the `invokeTool` path. Quota, canary, and egress guard a model turn,
403
+ * so `defineProfile` refuses them here rather than accepting inert config.
404
+ */
405
+ export interface HostProfile {
406
+ type: 'host';
407
+ id: ProfileId;
408
+ tools: HostProfileToolsSpec;
409
+ guardrails?: HostGuardrailsSpec;
410
+ observability?: ProfileObservabilitySpec;
387
411
  }
388
412
  /** Complete host-owned agent contract consumed by the kernel. */
389
- export type Profile = TextProfile | ImageProfile | SpeechProfile | LiveProfile;
413
+ export type Profile = TextProfile | ImageProfile | SpeechProfile | LiveProfile | HostProfile;
414
+ /** Profiles that bind models — every type except `host`. */
415
+ export type ModelProfile = Exclude<Profile, HostProfile>;
390
416
  /** Text part sent to provider adapters after input normalization. */
391
417
  export interface InteractionTextPart {
392
418
  type: 'text';
@@ -398,8 +424,18 @@ export interface InteractionMediaPart {
398
424
  mimeType: string;
399
425
  data: string;
400
426
  }
427
+ /**
428
+ * Media part carried by reference (e.g. a Gemini Files `files/<id>` uri).
429
+ * The host owns the upload and cleanup; THEORUM only carries the reference.
430
+ * Wired by the Google Interactions adapter; other adapters reject it.
431
+ */
432
+ export interface InteractionMediaRefPart {
433
+ type: MediaInputKind;
434
+ mimeType: string;
435
+ uri: string;
436
+ }
401
437
  /** Any provider input part accepted by THEORUM's provider contract. */
402
- export type InteractionPart = InteractionTextPart | InteractionMediaPart;
438
+ export type InteractionPart = InteractionTextPart | InteractionMediaPart | InteractionMediaRefPart;
403
439
  /** Native image response request passed to image-capable providers. */
404
440
  export interface ImageResponseFormat {
405
441
  type: 'image';
@@ -420,6 +456,14 @@ export interface TurnBlob {
420
456
  mimeType: string;
421
457
  data: string;
422
458
  }
459
+ /**
460
+ * Media attachment supplied by reference (provider file uri) instead of bytes.
461
+ * MIME acceptance still applies; base64 and byte limits do not.
462
+ */
463
+ export interface TurnMediaRef {
464
+ mimeType: string;
465
+ uri: string;
466
+ }
423
467
  /** Provider-neutral history message preserving text, parts, tools, and metadata. */
424
468
  export interface TurnHistoryMessage {
425
469
  role: 'system' | 'user' | 'assistant' | 'tool';
@@ -449,7 +493,7 @@ export interface TurnInput {
449
493
  text?: string;
450
494
  role?: string;
451
495
  slots?: Record<string, string>;
452
- attachments?: TurnBlob[];
496
+ attachments?: Array<TurnBlob | TurnMediaRef>;
453
497
  voice?: TurnBlob[];
454
498
  history?: TurnHistoryMessage[];
455
499
  repair?: TurnRepairRequest;
@@ -476,6 +520,11 @@ export interface TurnRequest {
476
520
  profile: ProfileId;
477
521
  /** Caller project id when one exists. Omitted on some HTTP hosts. */
478
522
  projectId?: string;
523
+ /**
524
+ * Sticky routing / cache session key for OpenRouter (`session_id`).
525
+ * Not the same as `projectId` or Gemini `previousInteractionId`.
526
+ */
527
+ sessionId?: string;
479
528
  /** Google Interactions server-side conversation state. Omit for stateless/manual history. */
480
529
  previousInteractionId?: string;
481
530
  /**
@@ -487,10 +536,12 @@ export interface TurnRequest {
487
536
  latitude: number;
488
537
  longitude: number;
489
538
  };
490
- /** Optional Interactions storage override. Omit to let profile model.config / provider decide. */
539
+ /** Optional Interactions storage override. Omit to let the selected model binding decide. */
491
540
  store?: boolean;
492
- select?: string;
493
- thinking?: boolean;
541
+ /** Selected model id when `profile.allowModelSelect` is true. */
542
+ model?: ModelId;
543
+ /** Selected effort alias when the binding has `allowEffortSelect`. */
544
+ effort?: string;
494
545
  /** Host-provided dynamic system prompt combined with profile persona */
495
546
  system?: string;
496
547
  /** Session permissions granted for this conversation turn */
@@ -499,6 +550,12 @@ export interface TurnRequest {
499
550
  path?: string;
500
551
  /** Host-owned metadata preserved for traces; the kernel does not interpret it. */
501
552
  metadata?: Record<string, unknown>;
553
+ /**
554
+ * Opaque application context handed to tool `handler` / `preTool` and
555
+ * `tools.t1Policy` as `ctx.host`. The kernel never reads, logs, traces, or
556
+ * serializes it.
557
+ */
558
+ host?: unknown;
502
559
  /**
503
560
  * Optional abort signal. When aborted, THEORUM stops the turn and cancels
504
561
  * in-flight provider HTTP where the adapter supports it.
@@ -511,7 +568,7 @@ export interface TurnRequest {
511
568
  continueFrom?: TurnContinueFrom;
512
569
  /**
513
570
  * 1-based continue attempt when `continueFrom` is set.
514
- * Compared to `profile.turnResumption.maxContinues` when that cap is set.
571
+ * Compared to `profile.turnBehaviour.resumption.maxContinues` when that cap is set.
515
572
  */
516
573
  continuation?: number;
517
574
  input?: TurnInput;
@@ -519,13 +576,19 @@ export interface TurnRequest {
519
576
  compactionProvider?: ModelProvider;
520
577
  /** Optional session resumption handle for continuing live WebSocket sessions. */
521
578
  sessionResumptionHandle?: string;
579
+ /** Host credentials for authenticated HTTP / MCP tools keyed by auth slot. */
580
+ credentials?: Record<string, ToolCredential>;
581
+ /**
582
+ * Turn-stage handler (`docs/contracts/stages.md`).
583
+ * Text `runTurn` emits stages and applies returned affordances.
584
+ */
585
+ onStage?: StageHandler;
522
586
  }
523
- /** Safe profile projection suitable for UI or host inspection. */
524
- export interface ProjectedProfile {
587
+ /** Safe profile projection suitable for UI or host inspection (model profiles only). */
588
+ export interface ProjectedProfile extends ProfileModelFields {
525
589
  id: string;
526
- type: ProfileType;
590
+ type: ModelProfile['type'];
527
591
  handle: string;
528
- model: ProfileModelSpec;
529
592
  tools: Array<RegisteredTool | {
530
593
  name: ToolId;
531
594
  missing: true;
@@ -548,7 +611,7 @@ export interface ProviderGenerationConfig {
548
611
  * `true` = SSE (THEORUM default when mode is omitted); `false` = buffered.
549
612
  */
550
613
  stream?: boolean;
551
- thinking: ThinkingLevel;
614
+ thinking?: ThinkingLevel;
552
615
  summaries?: SummaryMode;
553
616
  maxOutputTokens?: number;
554
617
  temperature?: number;
@@ -561,6 +624,16 @@ export interface ProviderGenerationConfig {
561
624
  latitude: number;
562
625
  longitude: number;
563
626
  };
627
+ /**
628
+ * OpenRouter prompt-cache policy from the selected model binding.
629
+ * Omitted for non-openrouter bindings.
630
+ */
631
+ cache?: CacheSpec;
632
+ /**
633
+ * OpenRouter sticky session id from `TurnRequest.sessionId`.
634
+ * Forwarded as request `session_id` when present.
635
+ */
636
+ sessionId?: string;
564
637
  }
565
638
  /** Resolved provider transport derived once in `resolveTurn`. */
566
639
  export type ProviderTransport = 'interactions' | 'geminiLive' | 'openAiCompat';
@@ -579,7 +652,7 @@ export interface ResolvedGeneration extends ProviderGenerationConfig {
579
652
  interactionOnlyInput?: Record<string, unknown>[];
580
653
  /**
581
654
  * Tool-loop ceiling. `undefined` or `<= 0` = unbounded.
582
- * Taken from `profile.model.maxSteps` with no THEORUM invent.
655
+ * Taken from `profile.maxSteps` with no THEORUM invent.
583
656
  */
584
657
  maxSteps?: number;
585
658
  structured: StructuredSchemaId | null;
@@ -589,12 +662,19 @@ export interface ResolvedGeneration extends ProviderGenerationConfig {
589
662
  input: InteractionPart[];
590
663
  /**
591
664
  * Vault key slot for credentialed transports (Google required; OpenRouter when
592
- * the profile pins `model.key` or a builtin forces `paid`). Never sent on the wire.
665
+ * the profile pins `key` or a builtin forces `paid`). Never sent on the wire.
593
666
  */
594
667
  keySlot?: KeySlot;
595
668
  canary: string;
596
669
  /** Optional session resumption handle for continuing live WebSocket sessions. */
597
670
  sessionResumptionHandle?: string;
671
+ /**
672
+ * Merged profile + turn system prompt, snapshotted synchronously in `resolveTurn`
673
+ * before any async work. Runner applies canary bind on top of this string.
674
+ */
675
+ resolvedSystem: string;
676
+ /** `TurnRequest.host`, carried to tool contexts only. Never sent to providers or traces. */
677
+ host?: unknown;
598
678
  }
599
679
  /** Token accounting emitted by providers or fallback estimation. */
600
680
  export interface TurnTokens {
@@ -604,6 +684,10 @@ export interface TurnTokens {
604
684
  toolUse?: number;
605
685
  /** Google code-execution / tool intermediate tokens when the API reports them. */
606
686
  intermediate?: number;
687
+ /** Prompt tokens read from provider cache (cache hit). */
688
+ cached?: number;
689
+ /** Prompt tokens written into provider cache. */
690
+ cacheWrite?: number;
607
691
  total: number;
608
692
  }
609
693
  /** Normalized citation or place source surfaced from a provider. */
@@ -683,6 +767,8 @@ export interface TurnEvent {
683
767
  grounding?: GroundingEvent;
684
768
  evidence?: ProviderEvidenceEvent;
685
769
  session?: SessionEvent;
770
+ /** Guardrail decision for this turn — rule identity and offsets, never content. */
771
+ guardrail?: GuardrailEvent;
686
772
  tokens?: TurnTokens;
687
773
  interactionId?: string;
688
774
  /** Session resumption handle updated during live sessions. */
@@ -697,6 +783,28 @@ export interface TurnEvent {
697
783
  compaction?: CompactionSignal;
698
784
  /** Why the turn ended. Present on terminal `done` events when known. */
699
785
  stop?: TurnStop;
786
+ /**
787
+ * Turn tool visibility snapshot when `stop.kind === 'tool'`.
788
+ * Hosts pass this to `invokeTool({ snapshot })` so T1/T2 resume matches the gated turn.
789
+ */
790
+ tools?: TurnToolSnapshot;
791
+ /** Turn-stage name when `type === 'stage'` (`docs/contracts/stages.md`). */
792
+ stage?: TurnStage;
793
+ /** Tool call id on `stage` / related tool-stage events. */
794
+ callId?: string;
795
+ /** Tool name on `stage` events (`pre_tool` / `post_tool`). Not `tool` (ToolCallEvent). */
796
+ toolName?: string;
797
+ /** True when a tool completed with awaiting_user_input (on stage/tool events). */
798
+ awaiting?: boolean;
799
+ /** pre_tool gate payload when `tool.phase === 'gate'` or stage carries a gate. */
800
+ gate?: ToolGate;
801
+ /** True when pre_tool settled without running the body. */
802
+ callNotStarted?: boolean;
803
+ /**
804
+ * Host-visible stage affordance warnings (`docs/contracts/stages.md`).
805
+ * Emitted after `onStage` when invalid/rejected fields were dropped.
806
+ */
807
+ stageWarnings?: StageApplyWarning[];
700
808
  }
701
809
  /**
702
810
  * Provider-neutral request object sent from the kernel to a model adapter.
@@ -758,21 +866,47 @@ export interface SessionRequest {
758
866
  sessionPermissions?: string[];
759
867
  history?: TurnHistoryMessage[];
760
868
  sessionResumptionHandle?: string;
761
- /**
762
- * Host-supplied function declarations for this session.
763
- * When set, replaces `generation.tools.wire` on the provider request
764
- * (Orchid-class hosts that resolve tools outside the Worker registry).
765
- */
766
- wireTools?: WireFunctionTool[];
767
869
  /** Optional realtime parts sent immediately after setup. */
768
870
  input?: InteractionPart[];
871
+ /**
872
+ * Registry-resolved tool snapshot from the process that owns the tool registry
873
+ * (`prepareTurnToolSnapshot`). When set, session setup declares `snapshot.wire`
874
+ * instead of resolving tools locally, so a relay process without the registry
875
+ * can open the session. Every custom id must be within the profile's
876
+ * `tools.allow`; ids outside it are refused.
877
+ */
878
+ snapshot?: TurnToolSnapshot;
769
879
  signal?: AbortSignal;
770
880
  metadata?: Record<string, unknown>;
881
+ /**
882
+ * Session-lifetime stage handler (`docs/contracts/stages.md`). Immutable for
883
+ * the session; no `setOnStage`.
884
+ */
885
+ onStage?: StageHandler;
886
+ /** Default credentials for `executeTool` (per-call args override). */
887
+ credentials?: Record<string, ToolCredential>;
888
+ /** Opaque host slot for stages / tool execute (per-call args override). */
889
+ host?: unknown;
771
890
  }
772
891
  /**
773
892
  * Long-lived live session returned by `runSession`.
774
893
  * `done` events mark conversational turn boundaries; the session stays open until `close()`.
775
894
  */
895
+ export type LiveExecuteToolArgs = {
896
+ name: string;
897
+ callId: string;
898
+ input?: unknown;
899
+ resume?: InvokeToolResume;
900
+ credentials?: Record<string, ToolCredential>;
901
+ host?: unknown;
902
+ };
903
+ export type LiveExecuteToolResult = {
904
+ outputRaw?: unknown;
905
+ outputModel?: ModelToolResult;
906
+ failure?: ToolFailure;
907
+ awaiting?: boolean;
908
+ gated?: ToolGate;
909
+ };
776
910
  export interface LiveSession {
777
911
  readonly profileId: ProfileId;
778
912
  readonly canary: string;
@@ -780,12 +914,17 @@ export interface LiveSession {
780
914
  sendAudio(args: {
781
915
  data: string;
782
916
  mimeType?: string;
783
- }): void;
917
+ }): Promise<void>;
784
918
  sendVideo(args: {
785
919
  data: string;
786
920
  mimeType?: string;
787
- }): void;
788
- sendText(text: string): void;
921
+ }): Promise<void>;
922
+ sendText(text: string): Promise<void>;
923
+ /**
924
+ * Registry tool execute with stages. Pumps `stage`/`tool` into `events()`.
925
+ * Gate → returns `gated` without upstream tool response; resume with `granted`.
926
+ */
927
+ executeTool(args: LiveExecuteToolArgs): Promise<LiveExecuteToolResult>;
789
928
  sendToolResponse(id: string, name: string, output: unknown): void;
790
929
  sendToolResponses(responses: Array<{
791
930
  id: string;
@@ -0,0 +1,2 @@
1
+ /** ES2022-safe replacement for `Array.prototype.findLast`. */
2
+ export declare function findLast<T>(items: readonly T[], predicate: (item: T) => boolean): T | undefined;
@@ -0,0 +1,10 @@
1
+ /** ES2022-safe replacement for `Array.prototype.findLast`. */
2
+ export function findLast(items, predicate) {
3
+ for (let i = items.length - 1; i >= 0; i -= 1) {
4
+ const item = items[i];
5
+ if (item !== undefined && predicate(item)) {
6
+ return item;
7
+ }
8
+ }
9
+ return undefined;
10
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Host-registered trace destinations for profile `observability.writeTo` ids.
3
+ *
4
+ * THEORUM does not invent filesystem roots. Hosts register a named destination
5
+ * once per process; profiles reference it by id.
6
+ *
7
+ * @module
8
+ */
9
+ import type { TraceSink } from './trace-sink.js';
10
+ /** JSONL directory destination — retention comes from profile policy at resolve time. */
11
+ export interface JsonlTraceDestination {
12
+ readonly kind: 'jsonl';
13
+ readonly dir: string;
14
+ }
15
+ /** Something a host may register under a destination id. */
16
+ export type TraceDestination = TraceSink | JsonlTraceDestination;
17
+ /** Build a JSONL destination descriptor for `registerTraceDestination`. */
18
+ declare function jsonlDestination(dir: string): JsonlTraceDestination;
19
+ declare function isJsonlTraceDestination(value: TraceDestination): value is JsonlTraceDestination;
20
+ declare function isTraceSink(value: TraceDestination): value is TraceSink;
21
+ /** Register a named destination for profile `observability.writeTo`. */
22
+ declare function registerTraceDestination(id: string, destination: TraceDestination): void;
23
+ /** Look up a registered destination; undefined when missing. */
24
+ declare function getTraceDestination(id: string): TraceDestination | undefined;
25
+ /** Require a registered destination or throw. */
26
+ declare function requireTraceDestination(id: string): TraceDestination;
27
+ /** List registered destination ids (stable sort). */
28
+ declare function listTraceDestinationIds(): string[];
29
+ /** Clear the destination registry (tests). */
30
+ declare function clearTraceDestinations(): void;
31
+ export { clearTraceDestinations, getTraceDestination, isJsonlTraceDestination, isTraceSink, jsonlDestination, listTraceDestinationIds, registerTraceDestination, requireTraceDestination, };