@theoremjs/studio 0.3.4-next.548.gbb156b2 → 0.3.4-next.554.g84e62b0

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 (156) hide show
  1. package/README.md +54 -14
  2. package/agreement.js +22 -7
  3. package/compile.js +3 -1
  4. package/cookbooks/catalog.d.ts +18 -0
  5. package/cookbooks/catalog.js +84 -8
  6. package/cookbooks/mod.d.ts +1 -1
  7. package/draft.d.ts +2 -0
  8. package/mod.d.ts +1 -1
  9. package/package.json +4 -4
  10. package/page/assets/Banner-CypKeoPt.js +2 -0
  11. package/page/assets/BottomSheet-Dbh6A5Vl.js +1 -0
  12. package/page/assets/{Card-Ghe4ozhC.js → Card-DruykyeB.js} +1 -1
  13. package/page/assets/CheckboxInput-CFZ_Wq8-.js +2 -0
  14. package/page/assets/CodeBlock-CfVOtDeO.js +52 -0
  15. package/page/assets/CollapsibleGroup-FIawJRo4.js +1 -0
  16. package/page/assets/ConsoleFrame-o1h8eHpY.js +3 -0
  17. package/page/assets/ContextMenu-XBM6rqqH.js +2 -0
  18. package/page/assets/DateInput-B1ICJtHn.js +1 -0
  19. package/page/assets/{Dialog-BDUExlk_.js → Dialog-Sd04KQS2.js} +1 -1
  20. package/page/assets/EmptyState-C_uF9Wyj.js +1 -0
  21. package/page/assets/HoverCard-DMyWUvwP.js +1 -0
  22. package/page/assets/Icon-BqkS-pIq.js +3 -0
  23. package/page/assets/IconButton-DVUFx-8p.js +1 -0
  24. package/page/assets/ListItem-QF7KFt0h.js +1 -0
  25. package/page/assets/MenuBottomSheet-DB7k7yMt.js +1 -0
  26. package/page/assets/MenuBottomSheetActionList-3L0HS4Kf.js +1 -0
  27. package/page/assets/SchemaFields-DthGCSIM.js +1 -0
  28. package/page/assets/ScrollableArea-BHfY7sWH.js +1 -0
  29. package/page/assets/SegmentedControlItem-BBGRPrxp.js +1 -0
  30. package/page/assets/{Text-BsiAsowd.js → Text-BOqCfzZC.js} +2 -2
  31. package/page/assets/{TimestampHoverCard-CCnmnVlQ.js → TimestampHoverCard-CDCVpEWM.js} +1 -1
  32. package/page/assets/{ToolResultCharts-DQc5tTgc.js → ToolResultCharts-DG2VPRGs.js} +1 -1
  33. package/page/assets/Tooltip-BWs5DLrM.js +1 -0
  34. package/page/assets/TraceInspector-CSlGFNuh.js +1 -0
  35. package/page/assets/{TraceOverview-DqhP_wzg.js → TraceOverview-Ck6C_Ez_.js} +2 -2
  36. package/page/assets/{_virtual_studio-type-sources-CvOETQ24.js → _virtual_studio-type-sources-CxP3L28S.js} +139 -77
  37. package/page/assets/browser-engine-D6JZkPvV.js +11 -0
  38. package/page/assets/browser-transport-Dap3OD5q.js +47 -0
  39. package/page/assets/{crypto-Dd6XxhqK.js → crypto-CrMpJY2D.js} +1 -1
  40. package/page/assets/{embedding-space-view-BU2AjjAx.js → embedding-space-view-CN0VHXXH.js} +1 -1
  41. package/page/assets/{encode-files-CiyHxnUC.js → encode-files-BCf3-Q7y.js} +1 -1
  42. package/page/assets/{export-agent-D-Rj6FQy.js → export-agent-BOvhPd_f.js} +1 -1
  43. package/page/assets/fieldParts-B7DYLgh4.js +1 -0
  44. package/page/assets/focusableSelector-DXZeMU85.js +1 -0
  45. package/page/assets/{guardrail-tester-lZGPnEIR.js → guardrail-tester-DfZ1mIDQ.js} +2 -2
  46. package/page/assets/index-CM9UyI8f.js +146 -0
  47. package/page/assets/isRenderable-DHkzpAoQ.js +1 -0
  48. package/page/assets/{labels-provider-BObUoNKa.js → labels-provider-DkA22zkP.js} +1 -1
  49. package/page/assets/{live-messages-DuLSkEdL.js → live-messages-D1DPu8uD.js} +1 -1
  50. package/page/assets/plainDate-BHiJcj7o.js +1 -0
  51. package/page/assets/reader-BJZH_Cmn.js +7 -0
  52. package/page/assets/{shaped-data-DYOBdvLJ.js → shaped-data-AVV4e7rW.js} +1 -1
  53. package/page/assets/{stub-kLwOLu-h.js → stub-BMUhx6B5.js} +1 -1
  54. package/page/assets/studio-code-pane-CcvVwTrU.js +8 -0
  55. package/page/assets/{studio-console-DgsrR6Qy.js → studio-console-CT4dvZQc.js} +1 -1
  56. package/page/assets/studio-decision-CJKqP0sE.js +1 -0
  57. package/page/assets/studio-embedding-CmY144a3.js +2 -0
  58. package/page/assets/studio-host-console-E4-8fIww.js +2 -0
  59. package/page/assets/studio-labels-dSptB7mq.js +3 -0
  60. package/page/assets/studio-live-BH4AubX8.js +5 -0
  61. package/page/assets/{studio-map-D7QZ6RAm.js → studio-map-DIm07L5J.js} +1 -1
  62. package/page/assets/{studio-trace-replay-BSts3p2O.js → studio-trace-replay-C5Wa5BcR.js} +2 -2
  63. package/page/assets/{studio-type-checker-BNljIXdE.js → studio-type-checker-B_CHmWnf.js} +1 -1
  64. package/page/assets/{tool-schema--CLE7o0H.js → tool-schema-DCF2M0n_.js} +6 -6
  65. package/page/assets/{trace-patterns-CS99kExN.js → trace-patterns-D6TbkLLr.js} +1 -1
  66. package/page/assets/{trace-record-B2MF8flo.js → trace-record-Dtrz7WQ7.js} +1 -1
  67. package/page/assets/tree-Cy9xwG_l.js +3 -0
  68. package/page/assets/{turn-client-DXtNeRHG.js → turn-client-mCvAwEgO.js} +1 -1
  69. package/page/assets/types-CB42MysU.js +1 -0
  70. package/page/assets/{use-one-call-TAgOAnMo.js → use-one-call-t6S5-SaV.js} +1 -1
  71. package/page/assets/use-second-ticker-GWBt83pd.css +1 -0
  72. package/page/assets/use-trace-records-B1vrKQmA.js +1 -0
  73. package/page/assets/useAdaptivePresentation-Bma4-u1a.js +1 -0
  74. package/page/assets/useAnnounce-DTSHZvjg.js +1 -0
  75. package/page/assets/useClipboard-CbN9bb4J.js +1 -0
  76. package/page/assets/useDevWarning-Z9SoixOP.js +1 -0
  77. package/page/assets/useFocusReturnVisibility-BHKv5Jwr.js +1 -0
  78. package/page/assets/useMenuPress-DLG1QOiE.js +1 -0
  79. package/page/assets/useResolvedRequired-DbsOcDqy.js +1 -0
  80. package/page/assets/useScrollableArea-DuF_pz9m.js +1 -0
  81. package/page/assets/useTooltip-c097gL_-.js +1 -0
  82. package/page/assets/{workspace-Cb6PICiw.js → workspace-BFrc6kx2.js} +1 -1
  83. package/page/index.html +48 -41
  84. package/read-source.js +5 -4
  85. package/read-studio.mjs +99 -0
  86. package/requirements.d.ts +3 -0
  87. package/requirements.js +10 -0
  88. package/server/alerts.d.ts +23 -0
  89. package/server/alerts.js +82 -0
  90. package/server/draft-handler.d.ts +3 -0
  91. package/server/draft-handler.js +5 -1
  92. package/server/events.d.ts +38 -0
  93. package/server/events.js +95 -0
  94. package/server/handler.d.ts +11 -3
  95. package/server/handler.js +64 -8
  96. package/server/project-source.d.ts +6 -3
  97. package/server/project-source.js +45 -4
  98. package/server/project.js +25 -3
  99. package/server/save-session.d.ts +2 -0
  100. package/server/save-session.js +7 -1
  101. package/server/serve.d.ts +1 -1
  102. package/server/serve.js +174 -18
  103. package/server/test-key.d.ts +19 -2
  104. package/server/test-key.js +51 -74
  105. package/server/watch.d.ts +8 -0
  106. package/server/watch.js +16 -5
  107. package/start.mjs +95 -5
  108. package/ui/built/theme.css +2 -2
  109. package/ui/built/theme.css.d.ts +2 -2
  110. package/ui/built/theorem-studio.d.ts +2 -2
  111. package/ui/built/theorem-studio.js +3 -3
  112. package/ui/built/theorem-studio.variants.d.ts +2 -2
  113. package/ui/lib/page-errors.d.ts +13 -0
  114. package/ui/lib/page-errors.js +31 -0
  115. package/ui/profile-editor.js +1 -1
  116. package/ui/studio-runner.d.ts +1 -1
  117. package/ui/studio-runner.js +7 -3
  118. package/ui/studio-screen.js +23 -11
  119. package/page/assets/Banner-BP1TXM0J.js +0 -2
  120. package/page/assets/BottomSheet-BQPskY35.js +0 -1
  121. package/page/assets/CheckboxInput-C9kbVyhK.js +0 -2
  122. package/page/assets/CodeBlock-Kjgv83A6.js +0 -52
  123. package/page/assets/CollapsibleGroup-Bfnp4Aaz.js +0 -1
  124. package/page/assets/ConsoleFrame-Da49DUMV.js +0 -3
  125. package/page/assets/ContextMenu-DGeuOuIz.js +0 -2
  126. package/page/assets/DateInput-BJt-UTCy.js +0 -1
  127. package/page/assets/EmptyState-C8W4JKBZ.js +0 -1
  128. package/page/assets/HoverCard-C6thuzrf.js +0 -1
  129. package/page/assets/Icon-ZfFwTt8n.js +0 -3
  130. package/page/assets/IconButton-CG5klqF1.js +0 -1
  131. package/page/assets/ScrollableArea-C8AVuqnt.js +0 -1
  132. package/page/assets/Section-DJ97F7QE.js +0 -1
  133. package/page/assets/SegmentedControlItem-BLuJOusN.js +0 -1
  134. package/page/assets/Tooltip-CTEuMRLe.js +0 -1
  135. package/page/assets/TraceInspector-Cn7_V-2C.js +0 -1
  136. package/page/assets/browser-engine-BUuO2-Ve.js +0 -11
  137. package/page/assets/browser-transport-FDq0Q4Fx.js +0 -47
  138. package/page/assets/fieldParts-Cs6Amprh.js +0 -1
  139. package/page/assets/index-Bk_jhM4_.js +0 -145
  140. package/page/assets/reader-DJB6MzQf.js +0 -7
  141. package/page/assets/studio-code-pane-D7R84b_Y.js +0 -8
  142. package/page/assets/studio-decision-uyaB9Oo3.js +0 -1
  143. package/page/assets/studio-embedding-tRaNKz_n.js +0 -2
  144. package/page/assets/studio-host-console-DzpUuYer.js +0 -2
  145. package/page/assets/studio-labels-CByQ2z3Y.js +0 -3
  146. package/page/assets/studio-live-CWeuAs3g.js +0 -5
  147. package/page/assets/tree-CDqNZ8w-.js +0 -3
  148. package/page/assets/types-DTbqRZ5l.js +0 -1
  149. package/page/assets/use-second-ticker-CnxaP3LD.css +0 -1
  150. package/page/assets/use-trace-records-CZNBjTS0.js +0 -1
  151. package/page/assets/useAdaptivePresentation-BY_zvjIp.js +0 -1
  152. package/page/assets/useClipboard-B1amtN2V.js +0 -1
  153. package/page/assets/useDevWarning-Cna3kqg1.js +0 -1
  154. package/page/assets/useScrollableArea-vxuztwym.js +0 -1
  155. package/page/assets/useTooltip-rxACYEAC.js +0 -1
  156. /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\`).
@@ -6003,6 +6018,24 @@ export interface TurnRequest {
6003
6018
  */
6004
6019
  onAgentCall?: AgentCallHook;
6005
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
+ }
6006
6039
  /** A profile projected for a client, with its secrets and server-only fields removed. */
6007
6040
  export interface ProjectedProfile extends ProfileModelFields {
6008
6041
  id: string;
@@ -7597,7 +7630,8 @@ import type { KeySlot } from '../types.js';
7597
7630
  export type KeyCredential = string | JsonObject;
7598
7631
  export interface CredentialContext {
7599
7632
  providerId: string;
7600
- apiId: string;
7633
+ /** The model the call is for. Absent for a key check, which calls no model. */
7634
+ apiId?: string;
7601
7635
  keySlot: KeySlot;
7602
7636
  signal?: AbortSignal;
7603
7637
  }
@@ -8738,6 +8772,90 @@ declare function contentOf(record: TraceRecord, value: TraceAttributeValue | und
8738
8772
  declare function inlineContent(record: TraceRecord, value: unknown): unknown;
8739
8773
  export type { TraceRecord };
8740
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;
8741
8859
  `,"file:///node_modules/@theoremjs/agents/src/kernel/protocols/binding.d.ts":`import { z } from 'zod';
8742
8860
  import { type JsonObject } from '../json.js';
8743
8861
  import { type KeySlot } from '../schema.js';
@@ -8805,6 +8923,24 @@ export declare function protocolOf(provider: RegisteredProvider, binding: ModelB
8805
8923
  * binding with its options parsed; changes nothing in place.
8806
8924
  */
8807
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;
8808
8944
  `,"file:///node_modules/@theoremjs/agents/src/kernel/tools/types.d.ts":`import type { z } from 'zod';
8809
8945
  import type { TurnDestinations } from '../../guardrails/destinations.js';
8810
8946
  import type { ResolveHost } from '../../guardrails/network.js';
@@ -9338,80 +9474,6 @@ export interface ModelToolResult {
9338
9474
  /** Directive signals found in the content; raises the turn's taint. */
9339
9475
  suspicious?: GuardrailHit[];
9340
9476
  }
9341
- `,"file:///node_modules/@theoremjs/agents/src/kernel/protocols/runtime.d.ts":`import { type Wait } from '../../providers/shared/retry.js';
9342
- import { type JsonObject } from '../json.js';
9343
- import type { KeyVault } from '../registry/vault.js';
9344
- import type { DecisionResult, KeySlot } from '../types.js';
9345
- import { type DecisionModelBinding, type ModelBinding } from './binding.js';
9346
- import type { ProviderLimits } from './limits.js';
9347
- import type { DecisionCall, EmbeddingCall, EmbeddingResult, ModelProfileType, ProtocolOperations } from './protocol.js';
9348
- import type { RegisteredProvider } from './provider.js';
9349
- /** Opens a WebSocket with the headers and subprotocols a sign-in put on it. */
9350
- export type OpenWebSocket = (url: string, init: {
9351
- headers: Headers;
9352
- protocols: string[];
9353
- }) => Promise<WebSocket>;
9354
- /**
9355
- * The runtime's own WebSocket. It takes no headers, so a sign-in that needs them is refused; a host
9356
- * that can send them passes \`openWebSocket\`.
9357
- */
9358
- export declare function plainWebSocket(provider: string): OpenWebSocket;
9359
- /** What a host lends every provider call: its keys, its network, its clock, and its budgets. */
9360
- export interface ProviderHostOptions {
9361
- /** Overrides the model's own \`limits\`, one field at a time. */
9362
- limits?: ProviderLimits;
9363
- vault?: KeyVault;
9364
- fetch?: typeof fetch;
9365
- wait?: Wait;
9366
- openWebSocket?: OpenWebSocket;
9367
- }
9368
- /** One call's setup: a checked binding on its registered provider, and the host's means. */
9369
- export interface CallSetup {
9370
- provider: RegisteredProvider;
9371
- binding: ModelBinding | DecisionModelBinding;
9372
- profileType: ModelProfileType;
9373
- vault?: KeyVault;
9374
- fetch?: typeof fetch;
9375
- wait?: Wait;
9376
- /** Milliseconds the call has left; a retry never waits past it, so the real cause is reported. */
9377
- timeLeft?(): number;
9378
- openWebSocket?: OpenWebSocket;
9379
- limits?: ProviderLimits;
9380
- signal?: AbortSignal;
9381
- tapUpstream?(row: JsonObject): void;
9382
- /** Hands the wire rows to the stream as \`raw\` events, for looking around. */
9383
- rawRows?: boolean;
9384
- /** Told the slot and key each attempt signs with, so the caller can redact it and key its state. */
9385
- onKey?(slot: KeySlot | undefined, key: unknown): void;
9386
- }
9387
- /**
9388
- * One binding's call, as the kernel runs it: the protocol's operations with the kernel's retries,
9389
- * ids, origins, and prices around them.
9390
- */
9391
- /** What the kernel runs for one binding. */
9392
- export type ProtocolCall = Required<Omit<ProtocolOperations, 'decide'>> & {
9393
- decide(request: DecisionCall): Promise<DecisionResult>;
9394
- embed(request: EmbeddingCall): Promise<EmbeddingResult>;
9395
- };
9396
- export declare function callProtocol(setup: CallSetup): ProtocolCall;
9397
- `,"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. */
9398
- export type Wait = (ms: number, signal?: AbortSignal | null) => Promise<void>;
9399
- /** All the waiting one call may do between tries; a wait that would pass it sends the last answer back. */
9400
- export declare const WAIT_BUDGET_MS = 5000;
9401
- export declare const waitDefault: Wait;
9402
- export declare function isTransientHttp(status: number): boolean;
9403
- /** 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. */
9404
- export declare function isTransientThrown(err: unknown): boolean;
9405
- export declare function backoffMs(attempt: number): number;
9406
- /** \`retry-after-ms\`, else \`Retry-After\` in seconds or as a date; undefined when absent or unreadable. */
9407
- export declare function retryAfterMs(headers: Headers, now?: number): number | undefined;
9408
- /**
9409
- * Retries a transient status (408, 429, 5xx gateway) or a network failure while the waits stay
9410
- * within five seconds in all, at most four times. Each wait is the response's \`Retry-After\` when it gives one, else
9411
- * 1s, 2s, 4s then 8s; a wait that would pass the five seconds, or the call's own time left, is not
9412
- * taken, and the last answer or error goes back as it came. An abort ends the wait.
9413
- */
9414
- export declare function retryTransient(send: typeof fetch, wait?: Wait, timeLeft?: () => number): typeof fetch;
9415
9477
  `,"file:///node_modules/@theoremjs/agents/src/kernel/stages.d.ts":`import type { SpanHandle } from '../observability/trace-span.js';
9416
9478
  import type { StageApplyWarningCode, TurnStage } from './schema.js';
9417
9479
  import type { TurnStop } from './stop.js';