@theoremjs/studio 0.3.4-next.544.gb5ef325 → 0.3.4-next.550.gf20b9cd

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 (173) hide show
  1. package/README.md +57 -17
  2. package/agreement.js +22 -7
  3. package/compile.js +61 -13
  4. package/cookbooks/catalog.d.ts +26 -3
  5. package/cookbooks/catalog.js +114 -60
  6. package/cookbooks/exchanges.d.ts +3 -0
  7. package/cookbooks/exchanges.js +7 -2
  8. package/cookbooks/mod.d.ts +3 -3
  9. package/cookbooks/mod.js +2 -2
  10. package/cookbooks/project.js +1 -3
  11. package/draft.d.ts +23 -5
  12. package/draft.js +10 -2
  13. package/media-accept.d.ts +7 -0
  14. package/media-accept.js +17 -0
  15. package/mod.d.ts +4 -4
  16. package/mod.js +3 -3
  17. package/package.json +4 -4
  18. package/page/assets/Banner-Bvkdyf59.js +2 -0
  19. package/page/assets/BottomSheet-Dbh6A5Vl.js +1 -0
  20. package/page/assets/{Card-Ghe4ozhC.js → Card-DruykyeB.js} +1 -1
  21. package/page/assets/CheckboxInput-CFZ_Wq8-.js +2 -0
  22. package/page/assets/CodeBlock-CfVOtDeO.js +52 -0
  23. package/page/assets/CollapsibleGroup-FIawJRo4.js +1 -0
  24. package/page/assets/ConsoleFrame-BTL67qHr.js +3 -0
  25. package/page/assets/ContextMenu-BngxR9na.js +2 -0
  26. package/page/assets/DateInput-B1ICJtHn.js +1 -0
  27. package/page/assets/{Dialog-BDUExlk_.js → Dialog-Sd04KQS2.js} +1 -1
  28. package/page/assets/EmptyState-C_uF9Wyj.js +1 -0
  29. package/page/assets/HoverCard-DMyWUvwP.js +1 -0
  30. package/page/assets/Icon-BqkS-pIq.js +3 -0
  31. package/page/assets/IconButton-DVUFx-8p.js +1 -0
  32. package/page/assets/ListItem-QF7KFt0h.js +1 -0
  33. package/page/assets/MenuBottomSheet-C4fG_GyZ.js +1 -0
  34. package/page/assets/MenuBottomSheetActionList-3L0HS4Kf.js +1 -0
  35. package/page/assets/SchemaFields-BT2XCbid.js +1 -0
  36. package/page/assets/ScrollableArea-BHfY7sWH.js +1 -0
  37. package/page/assets/SegmentedControlItem-BBGRPrxp.js +1 -0
  38. package/page/assets/{Text-BsiAsowd.js → Text-BOqCfzZC.js} +2 -2
  39. package/page/assets/{TimestampHoverCard-CCnmnVlQ.js → TimestampHoverCard-CDCVpEWM.js} +1 -1
  40. package/page/assets/{ToolResultCharts-BAIAtrxa.js → ToolResultCharts-rJr0Ksno.js} +1 -1
  41. package/page/assets/Tooltip-BWs5DLrM.js +1 -0
  42. package/page/assets/TraceInspector-DQI_wNzL.js +1 -0
  43. package/page/assets/{TraceOverview-C6T0S77W.js → TraceOverview-DmfmwSR6.js} +2 -2
  44. package/page/assets/{_virtual_studio-type-sources-C1mRXxbj.js → _virtual_studio-type-sources-CxP3L28S.js} +158 -78
  45. package/page/assets/browser-engine-B1PxEekk.js +11 -0
  46. package/page/assets/browser-transport-BOHBmYvp.js +47 -0
  47. package/page/assets/{embedding-space-view-BU2AjjAx.js → embedding-space-view-CN0VHXXH.js} +1 -1
  48. package/page/assets/{export-agent-m6Z0No6j.js → export-agent-BvEVKW_C.js} +8 -8
  49. package/page/assets/fieldParts-B7DYLgh4.js +1 -0
  50. package/page/assets/focusableSelector-DXZeMU85.js +1 -0
  51. package/page/assets/{guardrail-tester-oVuyo5d2.js → guardrail-tester-08T-hMFL.js} +2 -2
  52. package/page/assets/index-eSb7kilv.js +146 -0
  53. package/page/assets/isRenderable-DHkzpAoQ.js +1 -0
  54. package/page/assets/{labels-provider-Gus3heEH.js → labels-provider-DkA22zkP.js} +2 -2
  55. package/page/assets/{live-messages-BNhCuiuF.js → live-messages-DmTC8qc8.js} +1 -1
  56. package/page/assets/plainDate-BHiJcj7o.js +1 -0
  57. package/page/assets/reader-DoTXxl0W.js +7 -0
  58. package/page/assets/{stub-DPcZtI0s.js → stub-CKo_lxer.js} +1 -1
  59. package/page/assets/studio-code-pane-CEG07Zk7.js +8 -0
  60. package/page/assets/{studio-console-DoZMv_gr.js → studio-console-udt4MmTi.js} +1 -1
  61. package/page/assets/studio-decision-tocwLzxr.js +1 -0
  62. package/page/assets/studio-embedding-DQ84xzlj.js +2 -0
  63. package/page/assets/studio-host-console-BJOUpXHR.js +2 -0
  64. package/page/assets/studio-labels-Zqd84hcs.js +3 -0
  65. package/page/assets/studio-live-BmuHpeF4.js +5 -0
  66. package/page/assets/{studio-map-Dv8iCayn.js → studio-map-qP_i4hWG.js} +1 -1
  67. package/page/assets/studio-trace-replay-JUMs6EMA.js +2 -0
  68. package/page/assets/{studio-type-checker-B5DVxAZ0.js → studio-type-checker-B_CHmWnf.js} +1 -1
  69. package/page/assets/{tool-schema-CxLtS_Zt.js → tool-schema-CWGccblZ.js} +6 -6
  70. package/page/assets/{trace-patterns-CS99kExN.js → trace-patterns-D6TbkLLr.js} +1 -1
  71. package/page/assets/tree-B7VVMg1s.js +3 -0
  72. package/page/assets/{turn-client-BCi5WnI6.js → turn-client-CoLR6hrl.js} +1 -1
  73. package/page/assets/types-CL44MvsT.js +1 -0
  74. package/page/assets/{use-one-call-TEvndb3j.js → use-one-call-BKeMtY5F.js} +1 -1
  75. package/page/assets/use-second-ticker-GWBt83pd.css +1 -0
  76. package/page/assets/use-trace-records-B1vrKQmA.js +1 -0
  77. package/page/assets/useAdaptivePresentation-Bma4-u1a.js +1 -0
  78. package/page/assets/useAnnounce-DTSHZvjg.js +1 -0
  79. package/page/assets/useClipboard-CbN9bb4J.js +1 -0
  80. package/page/assets/useDevWarning-Z9SoixOP.js +1 -0
  81. package/page/assets/useFocusReturnVisibility-BHKv5Jwr.js +1 -0
  82. package/page/assets/useMenuPress-DLG1QOiE.js +1 -0
  83. package/page/assets/useResolvedRequired-DbsOcDqy.js +1 -0
  84. package/page/assets/useScrollableArea-DuF_pz9m.js +1 -0
  85. package/page/assets/useTooltip-c097gL_-.js +1 -0
  86. package/page/assets/workspace-NGa3jjDc.js +1 -0
  87. package/page/index.html +45 -38
  88. package/read-source.js +35 -8
  89. package/read-studio.mjs +99 -0
  90. package/replay.d.ts +3 -1
  91. package/replay.js +53 -5
  92. package/requirements.d.ts +3 -0
  93. package/requirements.js +10 -0
  94. package/server/alerts.d.ts +23 -0
  95. package/server/alerts.js +82 -0
  96. package/server/draft-handler.d.ts +3 -0
  97. package/server/draft-handler.js +5 -1
  98. package/server/events.d.ts +38 -0
  99. package/server/events.js +95 -0
  100. package/server/handler.d.ts +11 -3
  101. package/server/handler.js +64 -8
  102. package/server/project-source.d.ts +6 -3
  103. package/server/project-source.js +45 -4
  104. package/server/project.js +25 -3
  105. package/server/save-session.d.ts +2 -0
  106. package/server/save-session.js +7 -1
  107. package/server/serve.d.ts +1 -1
  108. package/server/serve.js +174 -18
  109. package/server/test-key.d.ts +19 -2
  110. package/server/test-key.js +51 -74
  111. package/server/watch.d.ts +8 -0
  112. package/server/watch.js +16 -5
  113. package/start.mjs +95 -5
  114. package/surface.js +1 -2
  115. package/ui/built/theme.css +2 -2
  116. package/ui/built/theme.css.d.ts +2 -2
  117. package/ui/built/theorem-studio.d.ts +2 -2
  118. package/ui/built/theorem-studio.js +3 -3
  119. package/ui/built/theorem-studio.variants.d.ts +2 -2
  120. package/ui/lib/export-agent.js +20 -2
  121. package/ui/lib/page-errors.d.ts +13 -0
  122. package/ui/lib/page-errors.js +31 -0
  123. package/ui/lib/studio-examples.js +0 -4
  124. package/ui/lib/studio-page.d.ts +8 -3
  125. package/ui/lib/studio-page.js +34 -13
  126. package/ui/profile-editor.js +186 -34
  127. package/ui/studio-decision.js +4 -1
  128. package/ui/studio-runner.d.ts +1 -1
  129. package/ui/studio-runner.js +7 -3
  130. package/ui/studio-screen.js +24 -18
  131. package/ui/studio-trace-replay.js +1 -8
  132. package/workspace.d.ts +1 -0
  133. package/workspace.js +3 -2
  134. package/page/assets/Banner-BUrqNrQ9.js +0 -2
  135. package/page/assets/BottomSheet-BQPskY35.js +0 -1
  136. package/page/assets/CheckboxInput-C9kbVyhK.js +0 -2
  137. package/page/assets/CodeBlock-Kjgv83A6.js +0 -52
  138. package/page/assets/CollapsibleGroup-PavPZ114.js +0 -1
  139. package/page/assets/ConsoleFrame-BpbXMWsq.js +0 -3
  140. package/page/assets/ContextMenu-D_6fLWw7.js +0 -2
  141. package/page/assets/DateInput-BJt-UTCy.js +0 -1
  142. package/page/assets/EmptyState-C8W4JKBZ.js +0 -1
  143. package/page/assets/HoverCard-C6thuzrf.js +0 -1
  144. package/page/assets/Icon-ZfFwTt8n.js +0 -3
  145. package/page/assets/IconButton-CG5klqF1.js +0 -1
  146. package/page/assets/ScrollableArea-C8AVuqnt.js +0 -1
  147. package/page/assets/Section-DJ97F7QE.js +0 -1
  148. package/page/assets/SegmentedControlItem-BLuJOusN.js +0 -1
  149. package/page/assets/Tooltip-CTEuMRLe.js +0 -1
  150. package/page/assets/TraceInspector-CvaN-GcS.js +0 -1
  151. package/page/assets/browser-engine-BS9Kn2Gx.js +0 -11
  152. package/page/assets/browser-transport-eqZ9n2AK.js +0 -47
  153. package/page/assets/fieldParts-Cs6Amprh.js +0 -1
  154. package/page/assets/index-Q8T7gvHP.js +0 -149
  155. package/page/assets/reader-BT_YeHdq.js +0 -7
  156. package/page/assets/studio-code-pane-BB8Q348A.js +0 -8
  157. package/page/assets/studio-decision-BPT3x1kT.js +0 -1
  158. package/page/assets/studio-embedding-cH6PQupx.js +0 -2
  159. package/page/assets/studio-host-console-ZvV5TFC4.js +0 -2
  160. package/page/assets/studio-labels-Dwd-ojX5.js +0 -3
  161. package/page/assets/studio-live-DDInnfd7.js +0 -5
  162. package/page/assets/studio-trace-replay-Dl792A2v.js +0 -2
  163. package/page/assets/tree-Bi2FOU_h.js +0 -3
  164. package/page/assets/types-s-3wFTyD.js +0 -1
  165. package/page/assets/use-second-ticker-CnxaP3LD.css +0 -1
  166. package/page/assets/use-trace-records-BkAYJz0M.js +0 -1
  167. package/page/assets/useAdaptivePresentation-BY_zvjIp.js +0 -1
  168. package/page/assets/useClipboard-B1amtN2V.js +0 -1
  169. package/page/assets/useDevWarning-Cna3kqg1.js +0 -1
  170. package/page/assets/useScrollableArea-vxuztwym.js +0 -1
  171. package/page/assets/useTooltip-rxACYEAC.js +0 -1
  172. package/page/assets/workspace-BiCkglEt.js +0 -1
  173. /package/page/assets/{use-second-ticker-VX91zrxj.js → use-second-ticker-DhbZ0Soz.js} +0 -0
@@ -4735,8 +4735,8 @@ export { PROFILE_GRAPH, profileGraphFacet, spineFacetsForProfileType, } from './
4735
4735
  export type { RuntimeAbilities } from './src/kernel/protocols/binding.js';
4736
4736
  export { checkBinding, commonModelSettingsSchema, decisionModelBindingSchema, keySlotSchema, keySlotsOf, modelBindingSchema, } from './src/kernel/protocols/binding.js';
4737
4737
  export { providerLimitsSchema } from './src/kernel/protocols/limits.js';
4738
- export type { CallSetup, ProtocolCall } from './src/kernel/protocols/runtime.js';
4739
- export { callProtocol, plainWebSocket } from './src/kernel/protocols/runtime.js';
4738
+ export type { CallSetup, KeyCheck, ProtocolCall } from './src/kernel/protocols/runtime.js';
4739
+ export { callProtocol, checkKey, plainWebSocket } from './src/kernel/protocols/runtime.js';
4740
4740
  export type { AttachmentFacts, AttachmentRules } from './src/kernel/registry/attachments.js';
4741
4741
  export { assertTurnAttachments, attachmentIssueCopy, attachmentIssues, attachmentIssueText, attachmentsRefused, base64Bytes, maxBytesForMime, requireMediaLimits, resolveMediaLimits, sanitizeCsvText, sanitizeTurnBlobs, } from './src/kernel/registry/attachments.js';
4742
4742
  export type { MediaInputChannel } from './src/kernel/registry/catalog.js';
@@ -4877,6 +4877,15 @@ export interface ProviderDefinition<C = unknown, K = unknown> {
4877
4877
  /** Only where the API reports no cost. */
4878
4878
  prices?: PriceTable;
4879
4879
  serves(connection: C): Serve<K>[];
4880
+ /**
4881
+ * How to ask the provider whether it takes a key: a GET to \`path\` on where it serves \`protocol\`,
4882
+ * signed as a call is. It must answer 2xx for a key that works and 400, 401 or 403 for one
4883
+ * that does not. \`checkKey\` sends it.
4884
+ */
4885
+ check?: {
4886
+ protocol: Protocol;
4887
+ path: string;
4888
+ };
4880
4889
  }
4881
4890
  /** A provider as defined; register it to use it. */
4882
4891
  export type Provider<C = unknown, K = unknown> = Readonly<ProviderDefinition<C, K>>;
@@ -4919,6 +4928,11 @@ export interface ProviderRegistry {
4919
4928
  /** Every protocol the registered providers serve, with the protocols they extend. */
4920
4929
  protocols(): Protocol[];
4921
4930
  }
4931
+ /** Where a provider serves a protocol; a config error when it does not. */
4932
+ export declare function served(provider: {
4933
+ id: string;
4934
+ serves: readonly Serve[];
4935
+ }, protocol: string): Serve;
4922
4936
  export declare function createProviderRegistry(): ProviderRegistry;
4923
4937
  `,"file:///node_modules/@theoremjs/agents/src/kernel/protocols/protocol.d.ts":`import { z } from 'zod';
4924
4938
  import { TheoremError } from '../../guardrails/error.js';
@@ -5236,6 +5250,7 @@ export interface ProfileImageSpec {
5236
5250
  includeText?: boolean;
5237
5251
  }
5238
5252
  import type { DecisionModelBinding, ModelBinding } from './protocols/binding.js';
5253
+ import type { ProviderHostOptions } from './protocols/runtime.js';
5239
5254
  export type { DecisionModelBinding, ModelBinding };
5240
5255
  /**
5241
5256
  * OpenRouter prompt-cache policy (\`models.*.options.cache\`).
@@ -5503,6 +5518,24 @@ export interface ProfileModelFields {
5503
5518
  /** Tool-loop ceiling. Omit = \`DEFAULT_MAX_STEPS\`; \`1\` = one-shot; \`> 1\` = hard cap. */
5504
5519
  maxSteps?: number;
5505
5520
  }
5521
+ /**
5522
+ * One allowed value for an \`inputs.slots\` entry. \`value\` is what the turn sends and what
5523
+ * \`{name}\` fills; optional \`description\` is visitor-facing UI copy only.
5524
+ */
5525
+ export interface SlotChoice {
5526
+ value: string;
5527
+ description?: string;
5528
+ }
5529
+ /**
5530
+ * One named slot: optional group \`label\` for the UI, and its choices. A bare \`string[]\` is
5531
+ * still accepted on define and normalized to \`{ choices: [{ value }] }\`.
5532
+ */
5533
+ export interface SlotDecl {
5534
+ label?: string;
5535
+ choices: SlotChoice[];
5536
+ }
5537
+ /** Authoring form for one slot: legacy value list, or a labeled declaration. */
5538
+ export type SlotDeclInput = string[] | SlotDecl;
5506
5539
  /** What a profile accepts as input. */
5507
5540
  export interface ProfileInputsSpec {
5508
5541
  text?: boolean;
@@ -5516,7 +5549,7 @@ export interface ProfileInputsSpec {
5516
5549
  maxBytes?: number;
5517
5550
  maxTurnBytes?: number;
5518
5551
  limitsByMime?: Record<string, number>;
5519
- slots?: Record<string, string[]>;
5552
+ slots?: Record<string, SlotDeclInput>;
5520
5553
  context?: ProfileContextSpec;
5521
5554
  }
5522
5555
  /** What a live profile declares beside its ingress channels. */
@@ -5985,6 +6018,24 @@ export interface TurnRequest {
5985
6018
  */
5986
6019
  onAgentCall?: AgentCallHook;
5987
6020
  }
6021
+ /**
6022
+ * How an application runs its turns: the one value its own call sites, its web handler and the
6023
+ * studio all use, so they cannot run a turn differently. An app that calls \`runTurn\` itself
6024
+ * writes \`runTurn(await wiring.prepare(turn), wiring.provider)\`.
6025
+ */
6026
+ export interface TurnWiring {
6027
+ /** Registers the application's profiles and tools. Called once, before the first turn. */
6028
+ register?: () => void | Promise<void>;
6029
+ /** The keys, network and limits each model call runs on. */
6030
+ provider?: ProviderHostOptions;
6031
+ /**
6032
+ * The turn the application runs, from the one it is given: the profile, the input with the
6033
+ * conversation's history, and the application's context as \`host\`. Set what the application
6034
+ * sets per turn, such as \`system\`, \`credentials\`, \`onStage\`, \`onAgentCall\`, \`path\` and
6035
+ * \`metadata\`. Text, image and speech turns run through it.
6036
+ */
6037
+ prepare?: (turn: NormalizedTurnRequest) => TurnRequest | Promise<TurnRequest>;
6038
+ }
5988
6039
  /** A profile projected for a client, with its secrets and server-only fields removed. */
5989
6040
  export interface ProjectedProfile extends ProfileModelFields {
5990
6041
  id: string;
@@ -7579,7 +7630,8 @@ import type { KeySlot } from '../types.js';
7579
7630
  export type KeyCredential = string | JsonObject;
7580
7631
  export interface CredentialContext {
7581
7632
  providerId: string;
7582
- apiId: string;
7633
+ /** The model the call is for. Absent for a key check, which calls no model. */
7634
+ apiId?: string;
7583
7635
  keySlot: KeySlot;
7584
7636
  signal?: AbortSignal;
7585
7637
  }
@@ -8720,6 +8772,90 @@ declare function contentOf(record: TraceRecord, value: TraceAttributeValue | und
8720
8772
  declare function inlineContent(record: TraceRecord, value: unknown): unknown;
8721
8773
  export type { TraceRecord };
8722
8774
  export { buildRecord, contentOf, inlineContent, TRACE_SCHEMA_URL };
8775
+ `,"file:///node_modules/@theoremjs/agents/src/kernel/protocols/runtime.d.ts":`import { type Wait } from '../../providers/shared/retry.js';
8776
+ import { type JsonObject } from '../json.js';
8777
+ import type { KeyVault } from '../registry/vault.js';
8778
+ import type { DecisionResult, KeySlot } from '../types.js';
8779
+ import { type DecisionModelBinding, type ModelBinding } from './binding.js';
8780
+ import type { ProviderLimits } from './limits.js';
8781
+ import type { DecisionCall, EmbeddingCall, EmbeddingResult, ModelProfileType, ProtocolOperations } from './protocol.js';
8782
+ import { type RegisteredProvider } from './provider.js';
8783
+ /** Opens a WebSocket with the headers and subprotocols a sign-in put on it. */
8784
+ export type OpenWebSocket = (url: string, init: {
8785
+ headers: Headers;
8786
+ protocols: string[];
8787
+ }) => Promise<WebSocket>;
8788
+ /**
8789
+ * The runtime's own WebSocket. It takes no headers, so a sign-in that needs them is refused; a host
8790
+ * that can send them passes \`openWebSocket\`.
8791
+ */
8792
+ export declare function plainWebSocket(provider: string): OpenWebSocket;
8793
+ /** What a host lends every provider call: its keys, its network, its clock, and its budgets. */
8794
+ export interface ProviderHostOptions {
8795
+ /** Overrides the model's own \`limits\`, one field at a time. */
8796
+ limits?: ProviderLimits;
8797
+ vault?: KeyVault;
8798
+ fetch?: typeof fetch;
8799
+ wait?: Wait;
8800
+ openWebSocket?: OpenWebSocket;
8801
+ }
8802
+ /** One call's setup: a checked binding on its registered provider, and the host's means. */
8803
+ export interface CallSetup {
8804
+ provider: RegisteredProvider;
8805
+ binding: ModelBinding | DecisionModelBinding;
8806
+ profileType: ModelProfileType;
8807
+ vault?: KeyVault;
8808
+ fetch?: typeof fetch;
8809
+ wait?: Wait;
8810
+ /** Milliseconds the call has left; a retry never waits past it, so the real cause is reported. */
8811
+ timeLeft?(): number;
8812
+ openWebSocket?: OpenWebSocket;
8813
+ limits?: ProviderLimits;
8814
+ signal?: AbortSignal;
8815
+ tapUpstream?(row: JsonObject): void;
8816
+ /** Hands the wire rows to the stream as \`raw\` events, for looking around. */
8817
+ rawRows?: boolean;
8818
+ /** Told the slot and key each attempt signs with, so the caller can redact it and key its state. */
8819
+ onKey?(slot: KeySlot | undefined, key: unknown): void;
8820
+ }
8821
+ /** What a provider said about a key when asked with its \`check\`. */
8822
+ export interface KeyCheck {
8823
+ provider: string;
8824
+ slot?: KeySlot;
8825
+ /**
8826
+ * \`accepted\`: the provider answered 2xx. \`refused\`: it answered 400, 401 or 403, or the key is
8827
+ * not one the provider takes. \`unreachable\`: no answer in time, or another status. \`empty\`: the
8828
+ * slot holds no key. \`unchecked\`: the provider declares no \`check\`.
8829
+ */
8830
+ state: 'accepted' | 'refused' | 'unreachable' | 'empty' | 'unchecked';
8831
+ status?: number;
8832
+ /** The provider's own words on a refusal, with the key taken out. */
8833
+ said?: string;
8834
+ }
8835
+ /**
8836
+ * Asks a registered provider whether it takes a key, with the GET its definition's \`check\`
8837
+ * names: \`key\` when given, else \`slot\` (by default its key slot) in \`vault\`. One request, never retried; the key is
8838
+ * not kept or logged.
8839
+ */
8840
+ export declare function checkKey(provider: RegisteredProvider, options?: {
8841
+ key?: unknown;
8842
+ vault?: KeyVault;
8843
+ /** The slot to read, when a model names its own. Default: the provider's \`keySlot\`. */
8844
+ slot?: string;
8845
+ fetch?: typeof fetch;
8846
+ signal?: AbortSignal;
8847
+ timeoutMs?: number;
8848
+ }): Promise<KeyCheck>;
8849
+ /**
8850
+ * One binding's call, as the kernel runs it: the protocol's operations with the kernel's retries,
8851
+ * ids, origins, and prices around them.
8852
+ */
8853
+ /** What the kernel runs for one binding. */
8854
+ export type ProtocolCall = Required<Omit<ProtocolOperations, 'decide'>> & {
8855
+ decide(request: DecisionCall): Promise<DecisionResult>;
8856
+ embed(request: EmbeddingCall): Promise<EmbeddingResult>;
8857
+ };
8858
+ export declare function callProtocol(setup: CallSetup): ProtocolCall;
8723
8859
  `,"file:///node_modules/@theoremjs/agents/src/kernel/protocols/binding.d.ts":`import { z } from 'zod';
8724
8860
  import { type JsonObject } from '../json.js';
8725
8861
  import { type KeySlot } from '../schema.js';
@@ -8787,6 +8923,24 @@ export declare function protocolOf(provider: RegisteredProvider, binding: ModelB
8787
8923
  * binding with its options parsed; changes nothing in place.
8788
8924
  */
8789
8925
  export declare function checkBinding<B extends ModelBinding | DecisionModelBinding>(provider: RegisteredProvider, binding: B, profileType: ModelProfileType, runtime?: RuntimeAbilities): B;
8926
+ `,"file:///node_modules/@theoremjs/agents/src/providers/shared/retry.d.ts":`/** How a retry waits; a host or test may pass its own. The signal ends the wait early. */
8927
+ export type Wait = (ms: number, signal?: AbortSignal | null) => Promise<void>;
8928
+ /** All the waiting one call may do between tries; a wait that would pass it sends the last answer back. */
8929
+ export declare const WAIT_BUDGET_MS = 5000;
8930
+ export declare const waitDefault: Wait;
8931
+ export declare function isTransientHttp(status: number): boolean;
8932
+ /** A rejected send that never got a response: a network failure, by \`networkError\`'s rule. An abort, a timeout, or any other kind is not. */
8933
+ export declare function isTransientThrown(err: unknown): boolean;
8934
+ export declare function backoffMs(attempt: number): number;
8935
+ /** \`retry-after-ms\`, else \`Retry-After\` in seconds or as a date; undefined when absent or unreadable. */
8936
+ export declare function retryAfterMs(headers: Headers, now?: number): number | undefined;
8937
+ /**
8938
+ * Retries a transient status (408, 429, 5xx gateway) or a network failure while the waits stay
8939
+ * within five seconds in all, at most four times. Each wait is the response's \`Retry-After\` when it gives one, else
8940
+ * 1s, 2s, 4s then 8s; a wait that would pass the five seconds, or the call's own time left, is not
8941
+ * taken, and the last answer or error goes back as it came. An abort ends the wait.
8942
+ */
8943
+ export declare function retryTransient(send: typeof fetch, wait?: Wait, timeLeft?: () => number): typeof fetch;
8790
8944
  `,"file:///node_modules/@theoremjs/agents/src/kernel/tools/types.d.ts":`import type { z } from 'zod';
8791
8945
  import type { TurnDestinations } from '../../guardrails/destinations.js';
8792
8946
  import type { ResolveHost } from '../../guardrails/network.js';
@@ -9320,80 +9474,6 @@ export interface ModelToolResult {
9320
9474
  /** Directive signals found in the content; raises the turn's taint. */
9321
9475
  suspicious?: GuardrailHit[];
9322
9476
  }
9323
- `,"file:///node_modules/@theoremjs/agents/src/kernel/protocols/runtime.d.ts":`import { type Wait } from '../../providers/shared/retry.js';
9324
- import { type JsonObject } from '../json.js';
9325
- import type { KeyVault } from '../registry/vault.js';
9326
- import type { DecisionResult, KeySlot } from '../types.js';
9327
- import { type DecisionModelBinding, type ModelBinding } from './binding.js';
9328
- import type { ProviderLimits } from './limits.js';
9329
- import type { DecisionCall, EmbeddingCall, EmbeddingResult, ModelProfileType, ProtocolOperations } from './protocol.js';
9330
- import type { RegisteredProvider } from './provider.js';
9331
- /** Opens a WebSocket with the headers and subprotocols a sign-in put on it. */
9332
- export type OpenWebSocket = (url: string, init: {
9333
- headers: Headers;
9334
- protocols: string[];
9335
- }) => Promise<WebSocket>;
9336
- /**
9337
- * The runtime's own WebSocket. It takes no headers, so a sign-in that needs them is refused; a host
9338
- * that can send them passes \`openWebSocket\`.
9339
- */
9340
- export declare function plainWebSocket(provider: string): OpenWebSocket;
9341
- /** What a host lends every provider call: its keys, its network, its clock, and its budgets. */
9342
- export interface ProviderHostOptions {
9343
- /** Overrides the model's own \`limits\`, one field at a time. */
9344
- limits?: ProviderLimits;
9345
- vault?: KeyVault;
9346
- fetch?: typeof fetch;
9347
- wait?: Wait;
9348
- openWebSocket?: OpenWebSocket;
9349
- }
9350
- /** One call's setup: a checked binding on its registered provider, and the host's means. */
9351
- export interface CallSetup {
9352
- provider: RegisteredProvider;
9353
- binding: ModelBinding | DecisionModelBinding;
9354
- profileType: ModelProfileType;
9355
- vault?: KeyVault;
9356
- fetch?: typeof fetch;
9357
- wait?: Wait;
9358
- /** Milliseconds the call has left; a retry never waits past it, so the real cause is reported. */
9359
- timeLeft?(): number;
9360
- openWebSocket?: OpenWebSocket;
9361
- limits?: ProviderLimits;
9362
- signal?: AbortSignal;
9363
- tapUpstream?(row: JsonObject): void;
9364
- /** Hands the wire rows to the stream as \`raw\` events, for looking around. */
9365
- rawRows?: boolean;
9366
- /** Told the slot and key each attempt signs with, so the caller can redact it and key its state. */
9367
- onKey?(slot: KeySlot | undefined, key: unknown): void;
9368
- }
9369
- /**
9370
- * One binding's call, as the kernel runs it: the protocol's operations with the kernel's retries,
9371
- * ids, origins, and prices around them.
9372
- */
9373
- /** What the kernel runs for one binding. */
9374
- export type ProtocolCall = Required<Omit<ProtocolOperations, 'decide'>> & {
9375
- decide(request: DecisionCall): Promise<DecisionResult>;
9376
- embed(request: EmbeddingCall): Promise<EmbeddingResult>;
9377
- };
9378
- export declare function callProtocol(setup: CallSetup): ProtocolCall;
9379
- `,"file:///node_modules/@theoremjs/agents/src/providers/shared/retry.d.ts":`/** How a retry waits; a host or test may pass its own. The signal ends the wait early. */
9380
- export type Wait = (ms: number, signal?: AbortSignal | null) => Promise<void>;
9381
- /** All the waiting one call may do between tries; a wait that would pass it sends the last answer back. */
9382
- export declare const WAIT_BUDGET_MS = 5000;
9383
- export declare const waitDefault: Wait;
9384
- export declare function isTransientHttp(status: number): boolean;
9385
- /** A rejected send that never got a response: a network failure, by \`networkError\`'s rule. An abort, a timeout, or any other kind is not. */
9386
- export declare function isTransientThrown(err: unknown): boolean;
9387
- export declare function backoffMs(attempt: number): number;
9388
- /** \`retry-after-ms\`, else \`Retry-After\` in seconds or as a date; undefined when absent or unreadable. */
9389
- export declare function retryAfterMs(headers: Headers, now?: number): number | undefined;
9390
- /**
9391
- * Retries a transient status (408, 429, 5xx gateway) or a network failure while the waits stay
9392
- * within five seconds in all, at most four times. Each wait is the response's \`Retry-After\` when it gives one, else
9393
- * 1s, 2s, 4s then 8s; a wait that would pass the five seconds, or the call's own time left, is not
9394
- * taken, and the last answer or error goes back as it came. An abort ends the wait.
9395
- */
9396
- export declare function retryTransient(send: typeof fetch, wait?: Wait, timeLeft?: () => number): typeof fetch;
9397
9477
  `,"file:///node_modules/@theoremjs/agents/src/kernel/stages.d.ts":`import type { SpanHandle } from '../observability/trace-span.js';
9398
9478
  import type { StageApplyWarningCode, TurnStage } from './schema.js';
9399
9479
  import type { TurnStop } from './stop.js';