@theoremjs/studio 0.3.4-next.679.gcdf1a3a → 0.3.4-next.711.g78e504a

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 (161) hide show
  1. package/agreement.js +35 -5
  2. package/browser-connection.d.ts +1 -1
  3. package/browser-connection.js +3 -1
  4. package/browser-execution.js +1 -0
  5. package/compile-workspace.js +12 -5
  6. package/compile.d.ts +5 -3
  7. package/compile.js +80 -36
  8. package/cookbooks/catalog.d.ts +2 -2
  9. package/cookbooks/catalog.js +296 -51
  10. package/cookbooks/project.js +1 -0
  11. package/cookbooks/tools.js +64 -0
  12. package/draft.d.ts +23 -4
  13. package/draft.js +25 -2
  14. package/guardrail-probe.d.ts +3 -1
  15. package/guardrail-probe.js +37 -5
  16. package/mod.d.ts +2 -3
  17. package/mod.js +2 -3
  18. package/package.json +4 -4
  19. package/page/assets/Banner-GFaYsfrc.js +3 -0
  20. package/page/assets/Center-CgO0c-qo.js +1 -0
  21. package/page/assets/{ConsoleFrame-BMf3HicW.js → ConsoleFrame-KmyDVQkS.js} +3 -3
  22. package/page/assets/{MenuBottomSheet-sVJMYa4R.js → MenuBottomSheet-BSQO5V7g.js} +1 -1
  23. package/page/assets/{SchemaFields-DYormNVH.js → SchemaFields-CIsMisSq.js} +1 -1
  24. package/page/assets/{ToolResultCharts-Ce4lVdgN.js → ToolResultCharts-95plvcj4.js} +1 -1
  25. package/page/assets/{TraceInspector-DHyj0IHY.js → TraceInspector-D2113s73.js} +1 -1
  26. package/page/assets/{TraceOverview-CeiOIqk9.js → TraceOverview-Bz2EnBzL.js} +3 -3
  27. package/page/assets/{_virtual_studio-type-sources-BwSqfSwd.js → _virtual_studio-type-sources-La9AcR1O.js} +360 -97
  28. package/page/assets/browser-connection-B2a2EaIg.js +3 -0
  29. package/page/assets/browser-engine--lGbAmPM.js +13 -0
  30. package/page/assets/browser-transport-h1KAGUN4.js +45 -0
  31. package/page/assets/{crypto-CD14HeXH.js → crypto-BnoW7FFO.js} +1 -1
  32. package/page/assets/{encode-files-DhoC5hWG.js → encode-files-DoLGXgup.js} +1 -1
  33. package/page/assets/{export-agent-Cs2S0oXB.js → export-agent-CA42Pf8A.js} +3 -3
  34. package/page/assets/{guardrail-tester-IcJWVveC.js → guardrail-tester-fDJlewVB.js} +2 -2
  35. package/page/assets/index-Bd7U_fu_.js +149 -0
  36. package/page/assets/{labels-provider-t4c-5JMk.js → labels-provider-uONlWExD.js} +1 -1
  37. package/page/assets/live-messages-CTL-QEqM.js +1 -0
  38. package/page/assets/people-CIsR0-5R.js +1 -0
  39. package/page/assets/project-address-DjxPZuyn.js +1 -0
  40. package/page/assets/reader-COeSYhdZ.js +5 -0
  41. package/page/assets/{schemas-BQ9Jydzb.js → schemas-D7cgkv3L.js} +1 -1
  42. package/page/assets/shaped-data-7q5Be8sp.js +20 -0
  43. package/page/assets/{stub-nxRsh1jo.js → stub-DJBcKncO.js} +25 -7
  44. package/page/assets/studio-code-pane-MXm30Ppv.js +10 -0
  45. package/page/assets/{studio-console-Cn-v8Vvw.js → studio-console-dHEr6mr5.js} +1 -1
  46. package/page/assets/studio-decision-BoSmTyjn.js +1 -0
  47. package/page/assets/studio-embedding-B5E__vsY.js +2 -0
  48. package/page/assets/studio-host-console-CadL7PPh.js +2 -0
  49. package/page/assets/{studio-labels-CiLuAo3N.js → studio-labels-sxDmOFeL.js} +1 -1
  50. package/page/assets/studio-live-Cgt4zKeL.js +5 -0
  51. package/page/assets/studio-map-BgeqrIh_.js +1 -0
  52. package/page/assets/{studio-session-CjUQSXx0.js → studio-session-ClF2iNCX.js} +1 -1
  53. package/page/assets/studio-trace-replay-BqYGBZ1t.js +3 -0
  54. package/page/assets/{studio-type-checker-BbUSqqOS.js → studio-type-checker-DutkTKte.js} +1 -1
  55. package/page/assets/tool-schema-m1KPujBp.js +17 -0
  56. package/page/assets/{trace-record-DxgSKmYY.js → trace-record-Dm2jEhUR.js} +1 -1
  57. package/page/assets/trace-schema--4IGmLeE.js +1 -0
  58. package/page/assets/tree-5tuw5ISS.js +3 -0
  59. package/page/assets/turn-client-BmadRouD.js +2 -0
  60. package/page/assets/{use-one-call-BZKByPJh.js → use-one-call-IXfdRlUH.js} +1 -1
  61. package/page/assets/use-second-ticker-D6JSf9B3.js +1 -0
  62. package/page/assets/workspace-CMUi6xcQ.js +1 -0
  63. package/page/index.html +22 -20
  64. package/people.d.ts +2 -0
  65. package/people.js +3 -1
  66. package/policy.js +1 -0
  67. package/providers.d.ts +2 -2
  68. package/providers.js +8 -3
  69. package/read-source.js +67 -7
  70. package/registrations.d.ts +32 -4
  71. package/runtime-scope.d.ts +6 -3
  72. package/runtime-scope.js +16 -4
  73. package/runtime.js +15 -2
  74. package/section-notes.d.ts +1 -0
  75. package/section-notes.js +1 -0
  76. package/serve-page.mjs +8 -4
  77. package/server/draft-handler.d.ts +4 -4
  78. package/server/draft-handler.js +3 -2
  79. package/server/draft-probe.d.ts +9 -1
  80. package/server/draft-probe.js +2 -1
  81. package/server/handler.d.ts +0 -3
  82. package/server/handler.js +62 -38
  83. package/server/live.d.ts +7 -2
  84. package/server/live.js +11 -5
  85. package/server/run-traces.d.ts +5 -1
  86. package/server/run-traces.js +7 -3
  87. package/server/save-new.js +5 -5
  88. package/server/save-plan.js +2 -1
  89. package/server/save-session.js +4 -2
  90. package/server/serve.js +2 -1
  91. package/server/test-key.d.ts +2 -2
  92. package/server/test-key.js +1 -1
  93. package/slot-values.d.ts +2 -0
  94. package/slot-values.js +22 -0
  95. package/source.js +11 -4
  96. package/system-markup.d.ts +9 -7
  97. package/system-markup.js +38 -19
  98. package/tool-readers.d.ts +23 -0
  99. package/tool-readers.js +60 -0
  100. package/tools.js +5 -1
  101. package/types.d.ts +6 -1
  102. package/ui/inspector-context.d.ts +1 -8
  103. package/ui/inspector-context.js +0 -7
  104. package/ui/inspector.d.ts +43 -1
  105. package/ui/inspector.js +50 -9
  106. package/ui/lib/entries.d.ts +13 -0
  107. package/ui/lib/entries.js +43 -0
  108. package/ui/lib/project-traces.d.ts +5 -0
  109. package/ui/lib/project-traces.js +11 -1
  110. package/ui/lib/studio-page.d.ts +6 -1
  111. package/ui/lib/studio-page.js +33 -31
  112. package/ui/lib/studio-prefs.d.ts +0 -4
  113. package/ui/lib/studio-prefs.js +0 -7
  114. package/ui/lib/studio-project.d.ts +10 -6
  115. package/ui/lib/studio-project.js +19 -4
  116. package/ui/lib/studio-session.d.ts +2 -0
  117. package/ui/lib/studio-session.js +40 -2
  118. package/ui/lib/studio-store.d.ts +2 -2
  119. package/ui/lib/studio-store.js +9 -5
  120. package/ui/lib/tool-probe.d.ts +2 -0
  121. package/ui/lib/tool-probe.js +3 -2
  122. package/ui/lib/type-icons.d.ts +1 -0
  123. package/ui/lib/type-icons.js +2 -1
  124. package/ui/profile-editor.js +69 -45
  125. package/ui/studio-compare.d.ts +14 -4
  126. package/ui/studio-compare.js +58 -24
  127. package/ui/studio-live.d.ts +1 -1
  128. package/ui/studio-live.js +8 -3
  129. package/ui/studio-runner.d.ts +3 -2
  130. package/ui/studio-runner.js +16 -14
  131. package/ui/studio-screen.d.ts +1 -2
  132. package/ui/studio-screen.js +33 -37
  133. package/ui/studio-settings.js +4 -13
  134. package/ui/studio-trace-replay.js +7 -1
  135. package/workspace.js +3 -2
  136. package/asks.d.ts +0 -54
  137. package/asks.js +0 -69
  138. package/page/assets/Banner-CkcwUyOn.js +0 -4
  139. package/page/assets/Center-nHS1JSux.js +0 -1
  140. package/page/assets/browser-connection-DSUHVCT5.js +0 -3
  141. package/page/assets/browser-engine-BXSD3WU8.js +0 -11
  142. package/page/assets/browser-transport-cp9y8bBz.js +0 -45
  143. package/page/assets/index-JWco7tJJ.js +0 -145
  144. package/page/assets/live-messages-CiLmR89m.js +0 -1
  145. package/page/assets/reader-DrOfMM8I.js +0 -5
  146. package/page/assets/shaped-data-H1miOZm2.js +0 -20
  147. package/page/assets/studio-code-pane-B8MOEW9g.js +0 -8
  148. package/page/assets/studio-decision-CjJ_pqdJ.js +0 -1
  149. package/page/assets/studio-embedding-Cq3ePsfC.js +0 -2
  150. package/page/assets/studio-host-console-D__Of1no.js +0 -2
  151. package/page/assets/studio-live-DvDQbP5V.js +0 -5
  152. package/page/assets/studio-map-BZFYGG_Y.js +0 -1
  153. package/page/assets/studio-trace-replay-D22FgUA5.js +0 -3
  154. package/page/assets/tool-schema-BmRYaywn.js +0 -17
  155. package/page/assets/trace-schema-9CdEyG6Q.js +0 -1
  156. package/page/assets/tree-3N-1RPZz.js +0 -3
  157. package/page/assets/turn-client-DN8PawJr.js +0 -2
  158. package/page/assets/use-second-ticker-CEwOSS-d.js +0 -1
  159. package/page/assets/workspace-CTSW941G.js +0 -1
  160. package/ui/confirm-write.d.ts +0 -12
  161. package/ui/confirm-write.js +0 -45
@@ -4745,11 +4745,12 @@ export type { EmbeddingRules } from './src/kernel/registry/embedding-rules.js';
4745
4745
  export { embeddingMediaIssues, embeddingRules } from './src/kernel/registry/embedding-rules.js';
4746
4746
  export type { KernelRegistry } from './src/kernel/registry/kernel-registry.js';
4747
4747
  export { createKernelRegistry } from './src/kernel/registry/kernel-registry.js';
4748
- export type { EmbeddingProfileDefinition, ImageProfileDefinition, LiveProfileDefinition, ProfileDefinition, ProfileDefinitionBase, ProfileRegistry, SpeechProfileDefinition, TextProfileDefinition, } from './src/kernel/registry/profiles.js';
4748
+ export type { EmbeddingProfileDefinition, ImageProfileDefinition, LiveProfileDefinition, ProfileDefinition, ProfileDefinitionBase, ProfileRegistry, SpeechProfileDefinition, TextProfileDefinition, TranscriptionProfileDefinition, } from './src/kernel/registry/profiles.js';
4749
4749
  export { createProfileRegistry, defineProfile } from './src/kernel/registry/profiles.js';
4750
4750
  export { pickModel } from './src/kernel/registry/resolve.js';
4751
4751
  export type { SchemaRegistry } from './src/kernel/registry/schemas.js';
4752
4752
  export { createSchemaRegistry } from './src/kernel/registry/schemas.js';
4753
+ export { resolveTurnSystemPrompt } from './src/kernel/registry/system-prompt.js';
4753
4754
  export type { AuthUnauthenticatedPolicy, ContinueStopKind, CustomToolType, HttpMethod, StepLimitMode, StudioAuthType, ToolAccess, ToolAuthType, ToolPermission, ToolType, TurnStopKind, } from './src/kernel/schema.js';
4754
4755
  export { API_EXPORTS, ATTACHMENT_ACCEPT_MIMES, AUTH_UNAUTHENTICATED_POLICIES, AWAITING_USER_INPUT_KINDS, AWAITING_USER_INPUT_STATUS, COMPACTION_METERS, COMPACTION_OUTCOMES, COMPACTION_TIMINGS, CONTINUE_STOP_KINDS, catalogPathFor, DYNAMIC_FIELD_PARENTS, EXTRA_FIELDS, fieldMeta, HTTP_METHODS, IMAGE_ATTACHMENT_ACCEPT_MIMES, isKeySlotName, isToolGateKind, isTurnInjectStage, isTurnStage, KEY_SLOT_NAME, LIVE_ACTIVITY_HANDLINGS, LIVE_END_SENSITIVITIES, LIVE_START_SENSITIVITIES, MEDIA_INPUT_KIND_VALUES, MEDIA_INPUT_KINDS, MEDIA_WILDCARDS, PROFILE_FIELDS, PROFILE_HANDLE_MAX_CHARS, PROFILE_ID_MAX_CHARS, PROFILE_TYPES, REQUEST_FIELDS, SPEECH_AUDIO_FORMATS, STREAM_MODES, STUDIO_AUTH_TYPES, SUMMARY_MODES, THINKING_LEVELS, TOOL_ACCESS, TOOL_AUTH_TYPES, TOOL_GATE_KINDS, TOOL_LOAD_TIERS, TOOL_PERMISSION, TOOL_TYPES, TURN_INJECT_STAGES, TURN_STAGES, TURN_STOP_KINDS, VOICE_ACCEPT_MIMES, } from './src/kernel/schema.js';
4755
4756
  export type { KernelScope } from './src/kernel/scope.js';
@@ -4758,14 +4759,16 @@ export type { AwaitingUserInput, StageAffordance, StageApplyInput, StageApplyOut
4758
4759
  export { applyStageResult, STAGE_AFFORDANCE_MATRIX, STAGE_AFFORDANCES, stageAllowsAffordance, stageEventFields, } from './src/kernel/stages.js';
4759
4760
  export type { MediaTurnBehaviourSpec, ProfileTurnBehaviourSpec, ProfileTurnResumptionSpec, TurnContinueFrom, TurnStop, } from './src/kernel/stop.js';
4760
4761
  export { AUTO_CONTINUE_DELAY_MS, DEFAULT_ALLOW_CONTINUE, DEFAULT_AUTO_CONTINUE, GenerationStopError, isContinueStopKind, isGenerationStopError, isResumeableStop, isUserCancelledStop, profileAllowsInject, profileAllowsSteering, profileTurnResumption, shouldAutoContinue, turnStopFromClientStreamEnd, turnStopFromInteractionStatus, turnStopFromOpenAiFinishReason, } from './src/kernel/stop.js';
4762
+ export { systemLinesProblem } from './src/kernel/system-lines.js';
4763
+ export type { ToolBackground, ToolBackgroundCall, ToolBackgroundHandle, ToolBackgroundService, } from './src/kernel/tools/background.js';
4761
4764
  export { authorizeToolReplay } from './src/kernel/tools/execute.js';
4762
4765
  export { GATE_DECISIONS, type GateDecision } from './src/kernel/tools/gate-answer.js';
4763
4766
  export type { MemoryToolExecutionOptions } from './src/kernel/tools/memory-execution.js';
4764
4767
  export { createMemoryToolExecution } from './src/kernel/tools/memory-execution.js';
4765
4768
  export type { CredentialQuery, McpProtocolVersion, McpRpcResponse, ToolRegistry, } from './src/kernel/tools/mod.js';
4766
4769
  export { askUserTool, buildHttpToolTarget, createToolRegistry, credentialPlacement, executeHttpTool, executeMcpTool, formatToolResult, isUnsupportedMcpProtocolError, MCP_PROTOCOL_VERSIONS, mcpRequestMeta, parseMcpRpcResponse, prepareTurnToolSnapshot, registerHarnessTools, resolveToolAuth, UncheckedOutput, uncheckedOutput, withCredentialQuery, } from './src/kernel/tools/mod.js';
4767
- export type { BeginToolOperationResult, PageToolDispatch, PageToolExecution, SavedToolInvocation, TerminalToolEvent, ToolExecutionCoordinator, ToolOperationClaim, ToolOperationIdentity, ToolOperationOutcome, ToolOperationUncertainty, } from './src/kernel/tools/operation.js';
4768
- export { savedToolInvocationSchema, toolInvocationHash, toolOperationOutcomeSchema, } from './src/kernel/tools/operation.js';
4770
+ export type { BackgroundToolEvent, BeginToolOperationResult, PageToolDispatch, PageToolExecution, SavedToolInvocation, TerminalToolEvent, ToolExecutionCoordinator, ToolOperationClaim, ToolOperationIdentity, ToolOperationOutcome, ToolOperationReply, ToolOperationUncertainty, } from './src/kernel/tools/operation.js';
4771
+ export { savedToolInvocationSchema, toolInvocationHash, toolOperationOutcomeSchema, toolOperationReplySchema, } from './src/kernel/tools/operation.js';
4769
4772
  export type { SettledToolCall, ToolCallResult, ToolStepCallResult, } from './src/kernel/tools/run.js';
4770
4773
  export type { ModelToolResult, PageAnswer, ToolContext } from './src/kernel/tools/types.js';
4771
4774
  export { awaitingUserInputSchema, type GateReference, gateReferenceSchema, isAwaitingUserInput, keptReply, reasoningPartSchema, TURN_EVENT_SCHEMAS, toolGateSchema, turnDoneOf, turnEventSchema, turnHistoryMessageSchema, turnToolSnapshotSchema, } from './src/kernel/turn-events.js';
@@ -4803,6 +4806,8 @@ export { openRouterEmbeddings } from './openrouter/embeddings-protocol.js';
4803
4806
  export { openRouterImages } from './openrouter/images-protocol.js';
4804
4807
  export { openRouterOpenAi } from './openrouter/protocol.js';
4805
4808
  export { openRouterProvider } from './openrouter/provider.js';
4809
+ export type { OpenRouterTranscriptionsOptions } from './openrouter/transcriptions-protocol.js';
4810
+ export { openRouterTranscriptions } from './openrouter/transcriptions-protocol.js';
4806
4811
  export { systemOne } from './system-one/protocol.js';
4807
4812
  export { typesafeProvider } from './typesafe/provider.js';
4808
4813
  `,"file:///node_modules/@theoremjs/agents/src/providers/typesafe/provider.d.ts":`import { type Provider } from '../../kernel/protocols/provider.js';
@@ -4941,7 +4946,7 @@ import type { ReasoningOrigin, ToolCallRequest } from '../turn-events.js';
4941
4946
  import type { DecisionRequest, DecisionResult, EmbeddingInput, EmbeddingResult, EmbeddingTask, InteractionPart, ModelRequest, TurnContext, TurnEvent, TurnHistoryMessage, TurnResponse, TurnStop } from '../types.js';
4942
4947
  import type { ProviderLimits } from './limits.js';
4943
4948
  /** The kinds of profile a protocol can serve, each at its own endpoint: every type but \`host\`. */
4944
- declare const MODEL_PROFILE_TYPES: readonly ["text", "image", "speech", "live", "decision", "embedding"];
4949
+ declare const MODEL_PROFILE_TYPES: readonly ["text", "image", "speech", "transcription", "live", "decision", "embedding"];
4945
4950
  export type ModelProfileType = (typeof MODEL_PROFILE_TYPES)[number];
4946
4951
  /** The turn events a protocol yields as they are. */
4947
4952
  export type ProtocolContentEvent = Extract<TurnEvent, {
@@ -5213,6 +5218,7 @@ export declare const providerLimitsSchema: z.ZodType<ProviderLimits>;
5213
5218
  import type { JsonObject } from './json.js';
5214
5219
  import type { CacheMode, CacheTtl, CompactionMeter, CompactionOutcome, CompactionTiming, ContextSender, ContinueStopKind, FieldMeta, KeySlot, KeyVault, LiveActivityHandling, LiveEndSensitivity, LiveStartSensitivity, MediaInputKind, ProfileType, SpeechAudioFormat, StreamMode, SummaryMode, ThinkingLevel, ToolLoadTier, TurnStage, TurnStopKind } from './schema.js';
5215
5220
  import type { StageHandler } from './stages.js';
5221
+ import type { ToolBackgroundService } from './tools/background.js';
5216
5222
  import type { GateDecision } from './tools/gate-answer.js';
5217
5223
  import type { PageToolExecution, ToolExecutionCoordinator } from './tools/operation.js';
5218
5224
  import type { AgentCall, AgentCallHook, AgentCallRequest, AgentToolDef, AgentToolInput, AgentToolOutput, HostProfileToolsSpec, InvokeToolRequest, InvokeToolResume, InvokeToolStepCall, InvokeToolStepRequest, LiveProfileToolsSpec, ModelToolResult, PageAnswer, ProfileToolsSpec, RegisteredTool, ToolCallEvent, ToolFailure, ToolGate, ToolLoadContext, ToolPolicy, TurnToolSnapshot, WireFunctionTool } from './tools/types.js';
@@ -5586,6 +5592,12 @@ export type SystemPart = string | PrivateSystemPart;
5586
5592
  * part is \`{ private }\`, the plain strings beside it are shareable.
5587
5593
  */
5588
5594
  export type SystemPrompt = string | readonly SystemPart[];
5595
+ /** One line of a profile's prompt: text, or parts kept together. A leading \`when\` decides it. */
5596
+ export type SystemLine = string | readonly SystemPart[];
5597
+ /** A profile's prompt: a string, or lines. Every line that fits is sent, a blank line apart. */
5598
+ export type ProfileSystem = string | readonly SystemLine[];
5599
+ /** The facts a host states on each turn, by name, each with the values it can take. */
5600
+ export type ProfileConditions = Readonly<Record<string, readonly string[]>>;
5589
5601
  /** A stretch of the system prompt as sent, and whether a reply may repeat it. */
5590
5602
  export interface SystemPiece {
5591
5603
  text: string;
@@ -5594,8 +5606,9 @@ export interface SystemPiece {
5594
5606
  /** A profile's handle and system prompt. */
5595
5607
  export interface ProfileIdentity {
5596
5608
  handle: string;
5597
- system?: SystemPrompt;
5598
- systemByRole?: Record<string, SystemPrompt>;
5609
+ /** The facts this agent's turns state, by name, with the values each can take. */
5610
+ conditions?: ProfileConditions;
5611
+ system?: ProfileSystem;
5599
5612
  }
5600
5613
  /** The fields every profile type shares. */
5601
5614
  export interface ProfileCommon {
@@ -5842,6 +5855,21 @@ export interface SpeechProfile extends Omit<ProfileCommon, 'identity'> {
5842
5855
  speech: ProfileSpeechSpec;
5843
5856
  turnBehaviour?: MediaTurnBehaviourSpec;
5844
5857
  }
5858
+ /** A transcription profile's inputs: voice clips within byte limits, and no text. */
5859
+ export type TranscriptionInputsSpec = Required<Pick<ProfileInputsSpec, 'voice'>> & Pick<ProfileInputsSpec, 'maxFiles' | 'maxBytes' | 'maxTurnBytes' | 'limitsByMime'>;
5860
+ /**
5861
+ * Speech to text: a voice clip in, what was said out as the turn's text. No tools, no system
5862
+ * prompt, and no canary, because the model follows no instruction and has nothing of the profile's to leak.
5863
+ */
5864
+ export interface TranscriptionProfile extends Omit<ProfileCommon, 'identity' | 'outputs' | 'maxSteps'> {
5865
+ type: 'transcription';
5866
+ identity: Pick<ProfileIdentity, 'handle'>;
5867
+ inputs: TranscriptionInputsSpec & {
5868
+ text: false;
5869
+ };
5870
+ outputs?: undefined;
5871
+ maxSteps?: undefined;
5872
+ }
5845
5873
  /** A profile that holds a live audio session. */
5846
5874
  export interface LiveProfile extends Omit<ProfileCommon, 'outputs'> {
5847
5875
  type: 'live';
@@ -5867,7 +5895,7 @@ export interface HostProfile {
5867
5895
  labels?: LabelOverrides;
5868
5896
  }
5869
5897
  /** The contract that defines an agent’s capabilities and the rules for its interactions. Its type determines which settings it accepts. */
5870
- export type Profile = TextProfile | ImageProfile | SpeechProfile | LiveProfile | DecisionProfile | EmbeddingProfile | HostProfile;
5898
+ export type Profile = TextProfile | ImageProfile | SpeechProfile | TranscriptionProfile | LiveProfile | DecisionProfile | EmbeddingProfile | HostProfile;
5871
5899
  /** Profiles that run a model turn — every type except \`host\` and \`decision\` (which runs through \`runDecision\`). */
5872
5900
  export type ModelProfile = Exclude<Profile, HostProfile | DecisionProfile | EmbeddingProfile>;
5873
5901
  /** The image a profile asks the model to return. */
@@ -5910,7 +5938,6 @@ export interface TurnRepairRequest {
5910
5938
  /** What the user sent for a turn: text, slots, attachments, voice, and history. */
5911
5939
  export interface TurnInput {
5912
5940
  text?: string;
5913
- role?: string;
5914
5941
  slots?: Record<string, string>;
5915
5942
  /** What the page or the host wants the model to know, by sender; the profile's \`inputs.context\` allows it. */
5916
5943
  context?: TurnContext;
@@ -5949,6 +5976,7 @@ export interface TurnTraceLink {
5949
5976
  /** A request to \`runTurn\`: the profile, the input, and the host's hooks and keys. */
5950
5977
  export interface TurnRequest {
5951
5978
  execution?: ToolExecutionCoordinator;
5979
+ background?: ToolBackgroundService;
5952
5980
  pageExecution?: PageToolExecution;
5953
5981
  providerState?: ProviderCheckpoint;
5954
5982
  profile: ProfileId;
@@ -5974,6 +6002,8 @@ export interface TurnRequest {
5974
6002
  sessionPermissions?: string[];
5975
6003
  /** Host channel/path for catalog \`paths\` filtering. */
5976
6004
  path?: string;
6005
+ /** This turn's facts, one value for each of \`profile.identity.conditions\` but \`path\`. */
6006
+ conditions?: Readonly<Record<string, string>>;
5977
6007
  /** Host-owned metadata preserved for traces; the kernel does not interpret it. */
5978
6008
  metadata?: Record<string, unknown>;
5979
6009
  /**
@@ -6008,6 +6038,12 @@ export interface TurnRequest {
6008
6038
  * Compared to \`profile.turnBehaviour.resumption.maxContinues\` when that cap is set.
6009
6039
  */
6010
6040
  continuation?: number;
6041
+ /**
6042
+ * Tools this reply already had when an earlier run of it paused. The turn opens with them on its
6043
+ * list, so an answered call does not take back what the model loaded. An id \`tools.allow\` or the
6044
+ * path does not grant is left out, as for \`tools.t1Policy\`.
6045
+ */
6046
+ promoted?: ToolId[];
6011
6047
  input?: TurnInput;
6012
6048
  /** Credentials for authenticated HTTP / MCP tools, read by auth slot when a tool needs one. */
6013
6049
  credentials?: ToolCredentialSource;
@@ -6104,6 +6140,8 @@ export interface ResolvedGeneration extends ProviderGenerationConfig {
6104
6140
  canary: string;
6105
6141
  /** Snapshotted synchronously before any async work; the runner binds the canary on top. */
6106
6142
  resolvedSystem: readonly SystemPiece[];
6143
+ /** Which of the profile's prompt lines fit this turn, by number from 1. */
6144
+ systemLines: readonly number[];
6107
6145
  /** \`TurnRequest.host\`, carried to tool contexts only. Never sent to providers or traces. */
6108
6146
  host?: unknown;
6109
6147
  }
@@ -6146,6 +6184,8 @@ export interface SessionRequest {
6146
6184
  /** As \`TurnRequest.builtInArgs\`. */
6147
6185
  builtInArgs?: BuiltInArgs;
6148
6186
  path?: string;
6187
+ /** As \`TurnRequest.conditions\`. */
6188
+ conditions?: Readonly<Record<string, string>>;
6149
6189
  sessionPermissions?: string[];
6150
6190
  history?: TurnHistoryMessage[];
6151
6191
  /** The value chosen for each of the profile's \`inputs.slots\`. */
@@ -6765,6 +6805,8 @@ export interface TurnToolSnapshot {
6765
6805
  path?: string;
6766
6806
  sessionPermissions?: string[];
6767
6807
  wire: WireFunctionTool[];
6808
+ /** The request has a background service, so \`ask\` tools offer the \`background\` argument. */
6809
+ modelBackground?: boolean;
6768
6810
  }
6769
6811
  /** The schema a tool snapshot parses against. */
6770
6812
  export declare const turnToolSnapshotSchema: z.ZodType<TurnToolSnapshot>;
@@ -6870,12 +6912,17 @@ export type ToolPhaseEvent = ToolPhaseBase & ({
6870
6912
  readBack?: string;
6871
6913
  parts?: InteractionPart[];
6872
6914
  activityPast?: string;
6873
- /** An agent tool's call: the called agent's own usage, which the caller's \`done.tokens\` includes. */
6915
+ /** An agent tool's call: the called agent's own usage. The caller's \`done.tokens\` includes it, unless the call settled after \`done\`. */
6874
6916
  tokens?: TurnTokens;
6875
6917
  } | {
6876
6918
  phase: 'gate';
6877
6919
  gate: ToolGate;
6878
6920
  readBack?: string;
6921
+ }
6922
+ /** The model reads \`readBack\` now and the call goes on; its real end reaches the host alone. */
6923
+ | {
6924
+ phase: 'background';
6925
+ readBack: string;
6879
6926
  } | {
6880
6927
  phase: 'error';
6881
6928
  failure: ToolFailure;
@@ -7189,7 +7236,7 @@ export declare function keptReply(events: readonly TurnEvent[]): TurnEvent[];
7189
7236
  `,"file:///node_modules/@theoremjs/agents/src/kernel/schema.d.ts":`import { BLOCKED_REPLY_ON_BLOCK, type BlockedReplyOnBlock } from '../guardrails/types.js';
7190
7237
  export { BLOCKED_REPLY_ON_BLOCK, type BlockedReplyOnBlock };
7191
7238
  /** The kinds of profile: each fixes which fields and models a profile may use. */
7192
- export declare const PROFILE_TYPES: readonly ["text", "image", "speech", "live", "decision", "embedding", "host"];
7239
+ export declare const PROFILE_TYPES: readonly ["text", "image", "speech", "transcription", "live", "decision", "embedding", "host"];
7193
7240
  /** One of {@linkcode PROFILE_TYPES}. */
7194
7241
  export type ProfileType = (typeof PROFILE_TYPES)[number];
7195
7242
  /** Reasoning effort levels, lowest to highest; a model accepts only the levels its catalog row lists. */
@@ -7962,7 +8009,7 @@ export { applySpans, blobAt, mergeSpans, OMIT_CANARY, OMIT_INJECTION, OMIT_PROMP
7962
8009
  `,"file:///node_modules/@theoremjs/agents/src/guardrails/labels.d.ts":`/** Values that fill a label template's \`{param}\` placeholders. */
7963
8010
  export type LabelParams = Record<string, string | number>;
7964
8011
  /** Keys are stable API. */
7965
- export declare const LABEL_KEYS: readonly ["provider.decision_failed", "provider.decision_unavailable", "provider.decision_model_missing", "provider.decision_ended", "provider.decision_images_off", "provider.decision_box_model", "provider.budget_exhausted", "provider.adapter_version", "provider.adapter_methods", "provider.adapter_schemas", "provider.fallback_slot", "provider.model_fallback_slot", "provider.host_model", "provider.turn_profile", "provider.model_binding_missing", "provider.session_closed", "provider.settled_call", "provider.session_unavailable", "provider.live_input", "provider.tool_cancel_missing", "provider.kernel_gate", "provider.event_invalid", "provider.response_identity", "provider.credential_resolution", "provider.credential_shape", "provider.stored_continuation", "provider.continuation_mismatch", "provider.continuation_contract", "provider.stateless_history", "provider.events_after_completion", "provider.duplicate_call", "provider.tool_cancel_live", "provider.complete_unavailable", "provider.parallel_tools", "provider.binding_identity", "provider.profile_type", "provider.event_type", "provider.feature", "provider.input_kind", "provider.output_kind", "provider.builtin", "provider.credential_missing", "provider.profile_configuration", "continue.instruction", "canary.bind_note", "user_data.note", "context.note", "taint.blocked", "taint.reason_steered", "taint.reason_tainted", "taint.destination_blocked", "taint.destination_confirm", "advisory.notice_elevated", "advisory.notice_high", "advisory.guidance", "attachments.too_many_files", "attachments.too_many_of_kind", "attachments.file_too_large", "attachments.turn_too_large", "attachments.not_accepted", "attachments.mime_not_allowed", "attachments.limits_unconfigured", "quota.exhausted", "quota.busy", "error.config", "error.request", "error.conflict", "error.not_found", "error.input", "error.action", "error.auth", "error.rate_limit", "error.busy", "error.unsupported", "error.unavailable", "error.bad_response", "error.network", "error.timeout", "error.safety", "error.blocked", "error.declined", "error.failed", "error.cancelled", "error.internal", "repair.default_guidance", "repair.items_guidance", "repair.prompt_header", "repair.prompt_intro", "repair.prompt_instructions", "repair.history_heading", "repair.section_previous_output", "repair.section_validator_rejection", "repair.section_repair_guidance", "repair.section_instructions", "structured.answer_tool", "structured.answer_missing", "structured.cut_off", "structured.not_json", "compaction.request", "compaction.tool_call", "compaction.tool_result", "compaction.tool_files", "decision.box_image", "detect.blocked", "detect.call_blocked", "detect.output_blocked", "detect.shown_blocked", "detect.hint.ids", "detect.hint.financial", "detect.hint.network", "detect.hint.credentials", "detect.hint.injection", "detect.hint.tool_instructions", "detect.hint.canary_leak", "detect.hint.prompt_leak", "detect.hint.marker_leak", "detect.hint.ungiven_images", "detect.hint.ungiven_links", "detect.hint.tool_leak", "detect.hint.own", "egress.default_repair_guidance", "egress.refusal", "egress.refusal_cut", "egress.rejection", "egress.rejection_found", "egress.hint_unscannable", "egress.hint_provider_tool_leak", "thought.omitted_image", "thought.omitted_link", "thought.omitted_instructions", "session.abandon_gated", "session.tool_denied", "session.tool_aborted", "session.sign_in", "sign_in.link", "sign_in.pending", "sign_in.done", "sign_in.declined", "sign_in.expired", "sign_in.out_of_scope", "session.gate_expired", "session.provider_state_unowned", "session.conversation_unknown", "session.full", "session.busy", "session.turn_ended", "session.gate_pending", "session.part_skipped", "live.session_ended", "voice.unsupported", "voice.permission", "voice.unavailable", "voice.failed", "voice.empty", "stop.cancelled", "stop.interrupted", "stop.length", "stop.filtered", "stop.provider_error", "stop.stream_incomplete", "stop.step_limit", "composer.model", "composer.effort", "tool.awaiting_user", "tool.completed_hidden", "tool.t2_loader_needs_snapshot", "tool.t2_loader_shape", "tool.t2_loader_output_invalid", "tool.execution_uncertain", "tool.input_invalid", "tool.input_invalid_after_mutate", "tool.output_invalid_after_mutate", "tool.handler_no_output", "tool.did_not_run", "tool.page_no_answer", "tool.page_timed_out", "tool.output_invalid", "tool.not_loaded_t2", "tool.wait_unknown", "tool.wait_cycle", "tool.not_visible", "tool.builtin_not_enabled", "tool.provider_native", "tool.not_registered", "tool.builtin_needs_snapshot", "tool.not_allowed", "tool.not_eligible", "tool.unsupported_type", "tool.agent_call_limit", "tool.agent_failed", "tool.activity_failed", "protocol.not_served", "protocol.profile_type", "protocol.options", "protocol.option_clash", "protocol.base_options", "protocol.id_clash", "protocol.ws_headers", "protocol.builtin_unwritten", "protocol.provider_missing", "protocol.connection", "protocol.part_schema", "protocol.part_invalid", "protocol.key_invalid", "protocol.no_key", "protocol.reply_shape", "protocol.endpoint_url", "protocol.endpoint_host", "protocol.http", "protocol.no_operation", "protocol.definition", "protocol.provider_id_clash", "protocol.history_needed"];
8012
+ export declare const LABEL_KEYS: readonly ["provider.decision_failed", "provider.decision_unavailable", "provider.decision_model_missing", "provider.decision_ended", "provider.decision_images_off", "provider.decision_box_model", "provider.budget_exhausted", "provider.adapter_version", "provider.adapter_methods", "provider.adapter_schemas", "provider.fallback_slot", "provider.model_fallback_slot", "provider.host_model", "provider.turn_profile", "provider.model_binding_missing", "provider.session_closed", "provider.settled_call", "provider.session_unavailable", "provider.live_input", "provider.tool_cancel_missing", "provider.kernel_gate", "provider.event_invalid", "provider.response_identity", "provider.credential_resolution", "provider.credential_shape", "provider.stored_continuation", "provider.continuation_mismatch", "provider.continuation_contract", "provider.stateless_history", "provider.events_after_completion", "provider.duplicate_call", "provider.tool_cancel_live", "provider.complete_unavailable", "provider.parallel_tools", "provider.binding_identity", "provider.profile_type", "provider.event_type", "provider.feature", "provider.input_kind", "provider.output_kind", "provider.builtin", "provider.credential_missing", "provider.profile_configuration", "continue.instruction", "canary.bind_note", "user_data.note", "context.note", "taint.blocked", "taint.reason_steered", "taint.reason_tainted", "taint.destination_blocked", "taint.destination_confirm", "advisory.notice_elevated", "advisory.notice_high", "advisory.guidance", "attachments.too_many_files", "attachments.too_many_of_kind", "attachments.file_too_large", "attachments.turn_too_large", "attachments.not_accepted", "attachments.mime_not_allowed", "attachments.limits_unconfigured", "quota.exhausted", "quota.busy", "error.config", "error.request", "error.conflict", "error.not_found", "error.input", "error.action", "error.auth", "error.rate_limit", "error.busy", "error.unsupported", "error.unavailable", "error.bad_response", "error.network", "error.timeout", "error.safety", "error.blocked", "error.declined", "error.failed", "error.cancelled", "error.internal", "repair.default_guidance", "repair.items_guidance", "repair.prompt_header", "repair.prompt_intro", "repair.prompt_instructions", "repair.history_heading", "repair.section_previous_output", "repair.section_validator_rejection", "repair.section_repair_guidance", "repair.section_instructions", "structured.answer_tool", "structured.answer_missing", "structured.cut_off", "structured.not_json", "compaction.request", "compaction.tool_call", "compaction.tool_result", "compaction.tool_files", "decision.box_image", "detect.blocked", "detect.call_blocked", "detect.output_blocked", "detect.shown_blocked", "detect.hint.ids", "detect.hint.financial", "detect.hint.network", "detect.hint.credentials", "detect.hint.injection", "detect.hint.tool_instructions", "detect.hint.canary_leak", "detect.hint.prompt_leak", "detect.hint.marker_leak", "detect.hint.ungiven_images", "detect.hint.ungiven_links", "detect.hint.tool_leak", "detect.hint.own", "egress.default_repair_guidance", "egress.refusal", "egress.refusal_cut", "egress.rejection", "egress.rejection_found", "egress.hint_unscannable", "egress.hint_provider_tool_leak", "thought.omitted_image", "thought.omitted_link", "thought.omitted_instructions", "session.abandon_gated", "session.tool_denied", "session.tool_aborted", "session.sign_in", "sign_in.link", "sign_in.pending", "sign_in.done", "sign_in.declined", "sign_in.expired", "sign_in.out_of_scope", "session.gate_expired", "session.provider_state_unowned", "session.conversation_unknown", "session.full", "session.busy", "session.turn_ended", "session.gate_pending", "session.part_skipped", "live.session_ended", "voice.unsupported", "voice.permission", "voice.unavailable", "voice.failed", "voice.empty", "stop.cancelled", "stop.interrupted", "stop.length", "stop.filtered", "stop.provider_error", "stop.stream_incomplete", "stop.step_limit", "composer.model", "composer.effort", "tool.awaiting_user", "tool.completed_hidden", "tool.t2_loader_needs_snapshot", "tool.t2_loader_shape", "tool.t2_loader_output_invalid", "tool.execution_uncertain", "tool.input_invalid", "tool.input_invalid_after_mutate", "tool.output_invalid_after_mutate", "tool.handler_no_output", "tool.did_not_run", "tool.page_no_answer", "tool.page_timed_out", "tool.output_invalid", "tool.not_loaded_t2", "tool.wait_unknown", "tool.wait_cycle", "tool.after_field", "tool.background_field", "tool.background_started", "tool.not_visible", "tool.builtin_not_enabled", "tool.provider_native", "tool.not_registered", "tool.builtin_needs_snapshot", "tool.not_allowed", "tool.not_eligible", "tool.unsupported_type", "tool.agent_call_limit", "tool.agent_failed", "tool.activity_failed", "protocol.not_served", "protocol.profile_type", "protocol.options", "protocol.option_clash", "protocol.base_options", "protocol.id_clash", "protocol.ws_headers", "protocol.builtin_unwritten", "protocol.provider_missing", "protocol.connection", "protocol.part_schema", "protocol.part_invalid", "protocol.key_invalid", "protocol.no_key", "protocol.reply_shape", "protocol.endpoint_url", "protocol.endpoint_host", "protocol.http", "protocol.no_operation", "protocol.definition", "protocol.provider_id_clash", "protocol.history_needed"];
7966
8013
  /** One of {@linkcode LABEL_KEYS}. */
7967
8014
  export type LabelKey = (typeof LABEL_KEYS)[number];
7968
8015
  /**
@@ -8969,6 +9016,7 @@ import type { AuthUnauthenticatedPolicy, HttpMethod, ToolAccess, ToolAuthType, T
8969
9016
  import type { RemovedItem, Source, ToolCallEdit, ToolCallEvent, ToolCallRequest, ToolFailure, ToolGate, ToolPhaseEvent, ToolTraceStep, ToolWarning, TurnToolSnapshot, WireFunctionTool } from '../turn-events.js';
8970
9017
  import type { InteractionPart, ModelId, Profile, ProfileId, ToolId, TurnInput, TurnRequest, TurnSpeech, TurnTraceLink } from '../types.js';
8971
9018
  import type { LabelTemplate } from './activity-label.js';
9019
+ import type { ToolBackground, ToolBackgroundService } from './background.js';
8972
9020
  import type { PageToolExecution, ToolExecutionCoordinator } from './operation.js';
8973
9021
  import type { UncheckedOutput } from './unchecked-output.js';
8974
9022
  export type { AuthUnauthenticatedPolicy, HttpMethod, ToolAccess, ToolAuthType, ToolCallEdit, ToolCallEvent, ToolCallRequest, ToolFailure, ToolGate, ToolPermission, ToolPhaseEvent, ToolTraceStep, ToolWarning, TurnToolSnapshot, WireFunctionTool, };
@@ -9116,6 +9164,12 @@ export interface ToolHostHooks<TIn = unknown> {
9116
9164
  /** Runs before the host's \`pre_tool\` \`onStage\`. */
9117
9165
  preTool?: (input: TIn, ctx: ToolContext) => import('../stages.js').StageResult | undefined | Promise<import('../stages.js').StageResult | undefined>;
9118
9166
  exposeToModel?: boolean;
9167
+ /** The model gets an \`after\` field: the tools in the same step that must settle before this call starts. */
9168
+ after?: boolean;
9169
+ /** When the model gets its reply. Unset is \`never\`: when the body ends. A turn without a background service runs inline. */
9170
+ background?: ToolBackground;
9171
+ /** \`inputSchema\` with the \`background\` argument. The registry sets it on an \`ask\` tool. */
9172
+ askInputSchema?: Record<string, unknown>;
9119
9173
  }
9120
9174
  export interface ToolOutputHooks<TOut = unknown> {
9121
9175
  /** A source that fails \`sourceSchema\`, or a throw, is a \`sources_invalid\` warning and is not cited. */
@@ -9277,6 +9331,8 @@ export interface AgentToolDef extends ToolBase {
9277
9331
  /** Channels the profile takes that the calling model can't fill; only \`onAgentCall\` sends them. */
9278
9332
  hostOnly?: AgentToolChannel[];
9279
9333
  preTool?: ToolHostHooks<AgentToolInput>['preTool'];
9334
+ after?: ToolHostHooks<AgentToolInput>['after'];
9335
+ background?: ToolHostHooks<AgentToolInput>['background'];
9280
9336
  exposeToModel?: boolean;
9281
9337
  }
9282
9338
  export interface RegisteredAgentTool extends AgentToolDef, ToolHostHooks<AgentToolInput>, ToolOutputHooks<AgentToolOutput> {
@@ -9358,6 +9414,7 @@ export type ToolPolicy = (ctx: ToolLoadContext) => ToolId[] | Promise<ToolId[]>;
9358
9414
  /** A request to run a held tool call outside a turn. */
9359
9415
  export interface InvokeToolRequest {
9360
9416
  execution?: ToolExecutionCoordinator;
9417
+ background?: ToolBackgroundService;
9361
9418
  /** invariant: Only the trusted host restores the kernel-issued identity from saved authority. */
9362
9419
  operationId?: string;
9363
9420
  profile: string;
@@ -9733,6 +9790,18 @@ export interface PageToolDispatch {
9733
9790
  export interface PageToolExecution {
9734
9791
  dispatch(claim: ToolOperationClaim, signal?: AbortSignal): Promise<PageToolDispatch>;
9735
9792
  }
9793
+ export type BackgroundToolEvent = TurnEventOf<'tool'> & {
9794
+ tool: Extract<TurnEventOf<'tool'>['tool'], {
9795
+ phase: 'background';
9796
+ }>;
9797
+ };
9798
+ /** What the model reads when a call goes on after its turn. */
9799
+ export interface ToolOperationReply {
9800
+ event: BackgroundToolEvent;
9801
+ replay: {
9802
+ modelResult: ModelToolResult;
9803
+ };
9804
+ }
9736
9805
  export interface ToolOperationOutcome {
9737
9806
  event: TerminalToolEvent;
9738
9807
  effects: 'not_started' | 'completed' | 'unknown';
@@ -9756,6 +9825,9 @@ export type BeginToolOperationResult = {
9756
9825
  } | {
9757
9826
  kind: 'settled';
9758
9827
  outcome: ToolOperationOutcome;
9828
+ } | {
9829
+ kind: 'background';
9830
+ reply: ToolOperationReply;
9759
9831
  } | {
9760
9832
  kind: 'running';
9761
9833
  } | {
@@ -9772,6 +9844,11 @@ export interface ToolExecutionCoordinator {
9772
9844
  kind: 'acquired';
9773
9845
  }> | undefined>;
9774
9846
  begin(operation: ToolOperationIdentity): Promise<BeginToolOperationResult>;
9847
+ /**
9848
+ * Keeps the reply the model reads for a call that goes on after its turn. The claim stays held
9849
+ * for \`settle\` or \`markUncertain\`. A coordinator without it cannot take a background service.
9850
+ */
9851
+ detach?(claim: ToolOperationClaim, reply: ToolOperationReply): Promise<void>;
9775
9852
  settle(claim: ToolOperationClaim, outcome: ToolOperationOutcome): Promise<void>;
9776
9853
  settleNotStarted(operation: ToolOperationIdentity, outcome: ToolOperationOutcome): Promise<void>;
9777
9854
  markUncertain(claim: ToolOperationClaim, reason: ToolOperationUncertainty): Promise<void>;
@@ -9783,10 +9860,182 @@ export declare function unresolvedOperation(kind: ErrorKind, reason: string, cau
9783
9860
  /** The host asked to run an operation that is still running or uncertain, so the host settles it first. */
9784
9861
  export declare function heldOperation(state: 'running' | 'uncertain'): TheoremError;
9785
9862
  export declare function toolInvocationHash(value: unknown): Promise<string>;
9863
+ export declare const toolOperationReplySchema: z.ZodType<ToolOperationReply>;
9786
9864
  export declare const toolOperationOutcomeSchema: z.ZodType<ToolOperationOutcome>;
9787
9865
  export declare function operationWireValue(value: unknown): JsonValue;
9788
- `,"file:///node_modules/@theoremjs/agents/src/guardrails/error.d.ts":"import type { TurnEventOf } from '../kernel/turn-events.js';\nimport type { TurnEvent } from '../kernel/types.js';\nimport { type LabelOverrides } from './labels.js';\nimport { type ErrorCopies, type ErrorKind, TheoremError } from './theorem-error.js';\n/** True when the value is an error named `AbortError`. */\ndeclare function isAbortError(err: unknown): boolean;\n/** `AbortSignal.timeout` rejects with a `TimeoutError`, not an `AbortError`. */\ndeclare function isTimeoutError(err: unknown): boolean;\n/** Throws when the signal has aborted: its framework, abort or timeout reason, else an `AbortError`. */\ndeclare function throwIfAborted(signal?: AbortSignal): void;\n/** Anything that is not a `TheoremError` or an abort escaped every boundary that names kinds: a THEOREM bug. */\ndeclare function errorKind(err: unknown): ErrorKind;\n/** The error kind for an HTTP status: 401, 402 and 403 are `auth`; 408, 504 and 524 `timeout`; 409 `conflict`; 429 `rate_limit`; 503 and 529 (overloaded) `busy`; 500 and above `unavailable`; the rest `unsupported`. */\ndeclare function kindOfHttpStatus(status: number): ErrorKind;\n/** The named reasons an error carries, one line each, in the profile's wording. */\ndeclare function errorCopyText(copy: ErrorCopies, labels?: LabelOverrides): string;\n/** Pass the profile's `labels`, or the profile's wording is skipped. */\ndeclare function publicError(err: unknown, labels?: LabelOverrides): string;\n/** Raw diagnostic for hosts, traces, and logs; never shown to end users. Each cause that says something new follows on its own line. */\ndeclare function describeError(err: unknown): string;\n/** fetch rejects only when no response came back, so any non-abort, non-timeout rejection is `network`. */\ndeclare function networkError(err: unknown): unknown;\n/** `send`, with a failed send or body read named as `networkError` names it. */\ndeclare function sendOrNetworkError(send: typeof fetch, ...args: Parameters<typeof fetch>): Promise<Response>;\ntype ProducedError = TurnEventOf<'error'> & {\n errorInternal: string;\n};\n/** No user wording yet: `withPublicLabels` adds it where the event reaches the host, the one place that knows the profile. */\ndeclare function toErrorEvent(err: unknown): ProducedError;\n/** Wording already set (host copy) is kept. */\ndeclare function withPublicLabels(event: TurnEvent, labels?: LabelOverrides): TurnEvent;\nexport type { ErrorCopies, ErrorCopy, ErrorKind, TheoremErrorOptions } from './theorem-error.js';\nexport { ERROR_KINDS } from './theorem-error.js';\nexport type { ProducedError };\nexport { describeError, errorCopyText, errorKind, isAbortError, isTimeoutError, kindOfHttpStatus, networkError, publicError, sendOrNetworkError, TheoremError, throwIfAborted, toErrorEvent, withPublicLabels, };\n","file:///node_modules/@theoremjs/agents/src/kernel/tools/activity-label.d.ts":`/** One line of wording, or a list of lines read top to bottom: the first that fits is shown. */
9866
+ `,"file:///node_modules/@theoremjs/agents/src/guardrails/error.d.ts":"import type { TurnEventOf } from '../kernel/turn-events.js';\nimport type { TurnEvent } from '../kernel/types.js';\nimport { type LabelOverrides } from './labels.js';\nimport { type ErrorCopies, type ErrorKind, TheoremError } from './theorem-error.js';\n/** True when the value is an error named `AbortError`. */\ndeclare function isAbortError(err: unknown): boolean;\n/** `AbortSignal.timeout` rejects with a `TimeoutError`, not an `AbortError`. */\ndeclare function isTimeoutError(err: unknown): boolean;\n/** Throws when the signal has aborted: its framework, abort or timeout reason, else an `AbortError`. */\ndeclare function throwIfAborted(signal?: AbortSignal): void;\n/** Anything that is not a `TheoremError` or an abort escaped every boundary that names kinds: a THEOREM bug. */\ndeclare function errorKind(err: unknown): ErrorKind;\n/** The error kind for an HTTP status: 401, 402 and 403 are `auth`; 408, 504 and 524 `timeout`; 409 `conflict`; 429 `rate_limit`; 503 and 529 (overloaded) `busy`; 500 and above `unavailable`; the rest `unsupported`. */\ndeclare function kindOfHttpStatus(status: number): ErrorKind;\n/** The named reasons an error carries, one line each, in the profile's wording. */\ndeclare function errorCopyText(copy: ErrorCopies, labels?: LabelOverrides): string;\n/** Pass the profile's `labels`, or the profile's wording is skipped. */\ndeclare function publicError(err: unknown, labels?: LabelOverrides): string;\n/** Raw diagnostic for hosts, traces, and logs; never shown to end users. Each cause that says something new follows on its own line. */\ndeclare function describeError(err: unknown): string;\n/** fetch rejects only when no response came back, so any non-abort, non-timeout rejection is `network`. */\ndeclare function networkError(err: unknown): unknown;\n/** `send`, with a failed send or body read named as `networkError` names it. */\ndeclare function sendOrNetworkError(send: typeof fetch, ...args: Parameters<typeof fetch>): Promise<Response>;\ntype ProducedError = TurnEventOf<'error'> & {\n errorInternal: string;\n};\n/** No user wording yet: `withPublicLabels` adds it where the event reaches the host, the one place that knows the profile. */\ndeclare function toErrorEvent(err: unknown): ProducedError;\n/** Wording already set (host copy) is kept. */\ndeclare function withPublicLabels(event: TurnEvent, labels?: LabelOverrides): TurnEvent;\nexport type { ErrorCopies, ErrorCopy, ErrorKind, TheoremErrorOptions } from './theorem-error.js';\nexport { ERROR_KINDS } from './theorem-error.js';\nexport type { ProducedError };\nexport { describeError, errorCopyText, errorKind, isAbortError, isTimeoutError, kindOfHttpStatus, networkError, publicError, sendOrNetworkError, TheoremError, throwIfAborted, toErrorEvent, withPublicLabels, };\n","file:///node_modules/@theoremjs/agents/src/kernel/tools/background.d.ts":`import { z } from 'zod';
9867
+ import { labelText } from '../../guardrails/labels.js';
9868
+ import type { SpanHandle, TraceAttributes } from '../../observability/trace-span.js';
9869
+ import type { TurnEvent } from '../types.js';
9870
+ import { type ToolCallBase } from './events.js';
9871
+ import { type ToolExecutionCoordinator, type ToolOperationReply } from './operation.js';
9872
+ /** When the model gets its reply: at the hand-off, past a time, if it asks, or when the body ends. */
9873
+ export type ToolBackground = 'always' | {
9874
+ afterMs: number;
9875
+ } | 'ask' | 'never';
9876
+ /** The call a detached event belongs to. */
9877
+ export interface ToolBackgroundCall {
9878
+ operationId: string;
9879
+ callId: string;
9880
+ toolId: string;
9881
+ }
9882
+ /** The host's hold on one detached call. */
9883
+ export interface ToolBackgroundHandle extends ToolBackgroundCall {
9884
+ /**
9885
+ * Stops the call. It settles as a \`cancelled\` failure with \`reason\` as its code, whatever the
9886
+ * body does. With no reason this is a shutdown: the call ends \`execution_interrupted\`. With
9887
+ * \`graceMs\`, a body that ignores its signal past that time settles anyway.
9888
+ */
9889
+ stop(reason?: string, options?: {
9890
+ graceMs?: number;
9891
+ }): void;
9892
+ /** Resolves when the call has settled or been marked. */
9893
+ done: Promise<void>;
9894
+ }
9895
+ /** The host's service for detached calls. Without it every tool runs inline. */
9896
+ export interface ToolBackgroundService {
9897
+ detached(call: ToolBackgroundHandle): void;
9898
+ event(event: TurnEvent, call: ToolBackgroundCall): void | Promise<void>;
9899
+ }
9900
+ /** A detached call's own trace record, joined to its turn through \`traceparent\`. */
9901
+ export interface DetachedToolTrace {
9902
+ open: (name: string, attributes: TraceAttributes) => SpanHandle;
9903
+ end: () => void | Promise<void>;
9904
+ }
9905
+ /** The service with what a request adds: its event projection and where a detached trace goes. */
9906
+ export interface ToolBackgroundSupport {
9907
+ service: ToolBackgroundService;
9908
+ project: (event: TurnEvent) => TurnEvent;
9909
+ openTrace: (callId: string) => DetachedToolTrace;
9910
+ }
9911
+ export interface ToolDetach {
9912
+ at: 'claim' | {
9913
+ afterMs: number;
9914
+ };
9915
+ support: ToolBackgroundSupport;
9916
+ trace: DetachedToolTrace;
9917
+ reply: () => ToolOperationReply;
9918
+ }
9919
+ /** The \`ask\` argument, as the model reads it. */
9920
+ export declare function backgroundField(): z.ZodOptional<z.ZodBoolean>;
9921
+ /** The call's input without \`background\`, and whether the model asked for it. */
9922
+ export declare function splitBackground(tool: {
9923
+ background?: ToolBackground;
9924
+ } | undefined, input: unknown): {
9925
+ input: unknown;
9926
+ asked: boolean;
9927
+ };
9928
+ /** How this call detaches, or \`undefined\` when it runs inline. */
9929
+ export declare function planDetach(args: {
9930
+ tool: {
9931
+ background?: ToolBackground;
9932
+ name: string;
9933
+ } | undefined;
9934
+ input: unknown;
9935
+ support: ToolBackgroundSupport | undefined;
9936
+ base: ToolCallBase;
9937
+ labels: Parameters<typeof labelText>[2];
9938
+ }): ToolDetach | undefined;
9939
+ /** A late result needs a coordinator to keep it. */
9940
+ export declare function assertBackgroundCoordinator(service: ToolBackgroundService | undefined, execution: ToolExecutionCoordinator | undefined): void;
9941
+ /** A tool that must answer in an open turn cannot detach; only an object input takes \`background\`. */
9942
+ export declare function assertBackgroundSetting(tool: {
9943
+ name: string;
9944
+ background?: ToolBackground;
9945
+ answeredBy?: string;
9946
+ }): void;
9947
+ `,"file:///node_modules/@theoremjs/agents/src/kernel/tools/events.d.ts":`import type { z } from 'zod';
9948
+ import { type LabelOverrides } from '../../guardrails/labels.js';
9949
+ import type { GuardrailEvent, NetworkGuardrailSpec } from '../../guardrails/types.js';
9950
+ import type { SpanHandle } from '../../observability/trace-span.js';
9951
+ import { type Source } from '../turn-events.js';
9952
+ import type { TurnEvent, TurnEventOf } from '../types.js';
9953
+ import type { ToolOperationClaim } from './operation.js';
9954
+ import type { ToolCallRequest, ToolContext, ToolFailure, ToolLabels, ToolPhaseEvent } from './types.js';
9955
+ export type ToolCallBase = Pick<ToolPhaseEvent, 'name' | 'callId'> & {
9956
+ operationId?: string;
9957
+ /** The call's failed label, from {@linkcode failedActivity}; absent, a failure names the tool. */
9958
+ activityFailed?: string;
9959
+ };
9960
+ export type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
9961
+ export type ToolPhasePatch = DistributiveOmit<ToolPhaseEvent, keyof ToolCallBase | 'at'>;
9962
+ export declare function toolEvent(base: ToolCallBase, patch: ToolPhasePatch): TurnEventOf<'tool'>;
9963
+ /**
9964
+ * The label a failed call shows: the tool's own, filled from the input the model sent, else the
9965
+ * labels' line naming the tool in words.
9966
+ */
9967
+ export declare function failedActivity(name: string, profileLabels?: LabelOverrides, labels?: ToolLabels, input?: unknown): string;
9968
+ /** The failed label of the call \`base\` names. */
9969
+ export declare function failedActivityOf(base: ToolCallBase): string;
9970
+ /** \`readBack\` is passed when the call's result guard already wrote the model's text. */
9971
+ export declare function failureEvent(base: ToolCallBase, failure: ToolFailure, readBack?: string): TurnEventOf<'tool'>;
9972
+ /** The first event of every call. */
9973
+ export declare function toolCallRequestEvent(base: ToolCallBase, args: Record<string, unknown>, { reasoning, stepId, stepCallCount, }?: Pick<ToolCallRequest, 'reasoning' | 'stepId' | 'stepCallCount'>): TurnEventOf<'tool'>;
9974
+ /** Unique: readers join a call's events by it. */
9975
+ export declare function newCallId(name: string): string;
9976
+ export declare function toolCallArguments(safeInput: unknown): Record<string, unknown>;
9977
+ export declare function messageOf(err: unknown): string;
9978
+ export declare function sourceEvents(base: ToolCallBase, sources: (output: unknown) => Source[], output: unknown): Generator<TurnEvent>;
9979
+ /** A call's claim, taken once at the hand-off: right before the destination is asked. */
9980
+ export declare class HandOff {
9981
+ private begin?;
9982
+ private taken?;
9983
+ private failed?;
9984
+ constructor(begin?: (() => Promise<ToolOperationClaim | undefined>) | undefined);
9985
+ claim(): Promise<ToolOperationClaim | undefined>;
9986
+ /** The claim's own failure is the coordinator's, so no tool catch may turn it into a tool failure. */
9987
+ rethrowClaimFailure(): void;
9988
+ }
9989
+ export declare function dispatchToolBody(tool: {
9990
+ labels?: ToolLabels;
9991
+ }, input: unknown, ctx: ToolContext, base: ToolCallBase, beginBody?: (preparedInput: unknown) => Promise<ToolOperationClaim | undefined>): AsyncGenerator<TurnEvent, HandOff>;
9992
+ export declare function startToolExecution<T>(tool: {
9993
+ input: z.ZodType<T>;
9994
+ }, rawInput: unknown, ctx: ToolContext): {
9995
+ ok: true;
9996
+ data: T;
9997
+ } | {
9998
+ ok: false;
9999
+ failure: ToolFailure;
10000
+ };
10001
+ export declare function networkBlockedEvent(): GuardrailEvent;
10002
+ export declare function networkBlocked(err: unknown, guardrail?: GuardrailEvent): Generator<TurnEvent, ToolFailure>;
10003
+ /**
10004
+ * Shared by HTTP and MCP so they cannot diverge on what SSRF enforcement means.
10005
+ * The check's time goes on the tool's span, when the call is traced.
10006
+ */
10007
+ export declare function guardToolTarget(url: string, ctx: ToolContext, span?: SpanHandle): Generator<TurnEvent, {
10008
+ ok: true;
10009
+ url: URL;
10010
+ } | {
10011
+ ok: false;
10012
+ failure: ToolFailure;
10013
+ }>;
10014
+ /** The checks a guarded request runs on its way, timed together: each hop's address, and its lookup. */
10015
+ export interface RequestChecks {
10016
+ /** Pass as \`fetchGuarded\`'s \`onCheck\`. */
10017
+ onCheck: (ms: number) => void;
10018
+ /** Records the checks once, when any ran, with the block they raised. */
10019
+ record: (blocked?: GuardrailEvent) => void;
10020
+ }
10021
+ export declare function requestChecks(span: SpanHandle | undefined): RequestChecks;
10022
+ export declare function toolNetworkPolicy(ctx: ToolContext): NetworkGuardrailSpec | undefined;
10023
+ `,"file:///node_modules/@theoremjs/agents/src/kernel/tools/activity-label.d.ts":`/** One line of wording, or a list of lines read top to bottom: the first that fits is shown. */
9789
10024
  export type LabelTemplate = string | readonly string[];
10025
+ /** \`expected: null\` is the check "is null". */
10026
+ export type Check = {
10027
+ path: string;
10028
+ negated: boolean;
10029
+ expected: string | null;
10030
+ };
10031
+ export type Line = {
10032
+ joined: boolean;
10033
+ when: Check[] | 'unreadable';
10034
+ text: string;
10035
+ };
10036
+ /** A line's head, with its text exactly as written after the condition. */
10037
+ export declare function splitWhen(raw: string): Line;
10038
+ export declare function checkHolds(check: Check, input: unknown): boolean;
9790
10039
  /** A tool's name as a label shows it: \`manage_alert\` reads "manage alert". */
9791
10040
  export declare function toolNameInWords(name: string): string;
9792
10041
  /**
@@ -9800,6 +10049,7 @@ export declare function fillActivityLabel(template: LabelTemplate | undefined, v
9800
10049
  input: unknown;
9801
10050
  output?: unknown;
9802
10051
  }): string | undefined;
10052
+ export declare function checkProblem(check: Check, input: unknown, reads?: string): string | undefined;
9803
10053
  export declare function activityLabelProblem(template: LabelTemplate, schemas: {
9804
10054
  input: unknown;
9805
10055
  output?: unknown;
@@ -9965,6 +10215,16 @@ export * from './prices.js';
9965
10215
  export * from './protocol.js';
9966
10216
  export * from './provider.js';
9967
10217
  export { type CallSetup, callProtocol } from './runtime.js';
10218
+ `,"file:///node_modules/@theoremjs/agents/src/providers/openrouter/transcriptions-protocol.d.ts":`import { type Protocol } from '../../kernel/protocols/mod.js';
10219
+ /** What an \`openRouterTranscriptions\` binding sets in \`options\`. */
10220
+ export interface OpenRouterTranscriptionsOptions {
10221
+ provider?: {
10222
+ zdr?: boolean;
10223
+ data_collection?: 'allow' | 'deny';
10224
+ };
10225
+ }
10226
+ /** OpenRouter's speech to text. Its body is its own JSON, not OpenAI's multipart upload. */
10227
+ export declare const openRouterTranscriptions: Protocol<OpenRouterTranscriptionsOptions>;
9968
10228
  `,"file:///node_modules/@theoremjs/agents/src/providers/openrouter/provider.d.ts":`import { type Provider } from '../../kernel/protocols/provider.js';
9969
10229
  /** What registering \`openRouterProvider\` takes as \`connection\`. */
9970
10230
  export interface OpenRouterConnection {
@@ -9973,13 +10233,39 @@ export interface OpenRouterConnection {
9973
10233
  siteUrl?: string;
9974
10234
  siteName?: string;
9975
10235
  }
9976
- /** OpenRouter: many labs' models behind one key. Chat, speech, images, and decisions. */
10236
+ /** OpenRouter: many labs' models behind one key. Chat, speech, transcription, images, and decisions. */
9977
10237
  export declare const openRouterProvider: Provider<OpenRouterConnection, string>;
9978
- `,"file:///node_modules/@theoremjs/agents/src/providers/openrouter/protocol.d.ts":`import { type Protocol } from '../../kernel/protocols/mod.js';
10238
+ `,"file:///node_modules/@theoremjs/agents/src/providers/openrouter/protocol.d.ts":`import { type JsonObject } from '../../kernel/json.js';
10239
+ import { type Protocol } from '../../kernel/protocols/mod.js';
9979
10240
  import type { CacheSpec } from '../../kernel/types.js';
9980
10241
  /** What an \`openRouterOpenAi\` binding sets in \`options\`. */
9981
10242
  export interface OpenRouterOptions {
9982
10243
  cache?: CacheSpec;
10244
+ provider?: OpenRouterRouting;
10245
+ }
10246
+ /** OpenRouter's own \`provider\` request field, under its own names. */
10247
+ export interface OpenRouterRouting {
10248
+ only?: string[];
10249
+ order?: string[];
10250
+ ignore?: string[];
10251
+ allow_fallbacks?: boolean;
10252
+ require_parameters?: boolean;
10253
+ data_collection?: 'allow' | 'deny';
10254
+ zdr?: boolean;
10255
+ enforce_distillable_text?: boolean;
10256
+ quantizations?: string[];
10257
+ sort?: string | {
10258
+ by: string;
10259
+ partition?: string;
10260
+ };
10261
+ preferred_min_throughput?: number | JsonObject;
10262
+ preferred_max_latency?: number | JsonObject;
10263
+ max_price?: {
10264
+ prompt?: number;
10265
+ completion?: number;
10266
+ request?: number;
10267
+ image?: number;
10268
+ };
9983
10269
  }
9984
10270
  /** Chat Completions with OpenRouter's caching, routing, web search, citations, and reasoning. */
9985
10271
  export declare const openRouterOpenAi: Protocol<OpenRouterOptions>;
@@ -10327,9 +10613,9 @@ export { clearTraceDestinations, getTraceDestination, isTraceSink, listTraceDest
10327
10613
  */
10328
10614
  import type { ToolPhaseEvent, TurnEvent } from '../turn-events.js';
10329
10615
  import type { StartedInvoke, StartedStep } from './invoke.js';
10330
- /** The phase a call ends on: it completed, a gate held it, or it failed. */
10616
+ /** The phase a call ends on: it completed, a gate held it, it failed, or it went on in the background. */
10331
10617
  export type SettledToolCall = Extract<ToolPhaseEvent, {
10332
- phase: 'complete' | 'gate' | 'error';
10618
+ phase: 'complete' | 'gate' | 'error' | 'background';
10333
10619
  }> & {
10334
10620
  /** Kernel-issued identity; a gate's resume carries it. */
10335
10621
  operationId?: string;
@@ -10412,7 +10698,7 @@ import { type DecisionGuardrailsSpec, type HostGuardrailsSpec, type ProfileGuard
10412
10698
  import type { ProfileObservabilitySpec } from '../../observability/types.js';
10413
10699
  import type { ProviderRegistry } from '../protocols/provider.js';
10414
10700
  import type { ToolRegistry } from '../tools/registry.js';
10415
- import type { DecisionModelBinding, DecisionProfile, EmbeddingProfile, HostProfile, HostProfileToolsSpec, ImageInputsSpec, ImageProfile, LiveProfile, LiveProfileToolsSpec, MediaTurnBehaviourSpec, ModelBinding, ModelId, Profile, ProfileIdentity, ProfileInputsSpec, ProfileOutputsSpec, ProfileToolsSpec, ProfileTurnBehaviourSpec, SpeechProfile, TextProfile } from '../types.js';
10701
+ import type { DecisionModelBinding, DecisionProfile, EmbeddingProfile, HostProfile, HostProfileToolsSpec, ImageInputsSpec, ImageProfile, LiveProfile, LiveProfileToolsSpec, MediaTurnBehaviourSpec, ModelBinding, ModelId, Profile, ProfileIdentity, ProfileInputsSpec, ProfileOutputsSpec, ProfileToolsSpec, ProfileTurnBehaviourSpec, SpeechProfile, TextProfile, TranscriptionInputsSpec, TranscriptionProfile } from '../types.js';
10416
10702
  import type { SchemaRegistry } from './schemas.js';
10417
10703
  /** Not shared by host profiles, which invoke tools without a model turn. */
10418
10704
  export type ProfileDefinitionBase = {
@@ -10456,6 +10742,14 @@ export type SpeechProfileDefinition = Omit<ProfileDefinitionBase, 'identity'> &
10456
10742
  speech: NonNullable<SpeechProfile['speech']>;
10457
10743
  turnBehaviour?: MediaTurnBehaviourSpec;
10458
10744
  };
10745
+ /** What a host writes to define a transcription profile. */
10746
+ export type TranscriptionProfileDefinition = Omit<ProfileDefinitionBase, 'identity' | 'outputs' | 'maxSteps'> & {
10747
+ type: 'transcription';
10748
+ identity: TranscriptionProfile['identity'];
10749
+ inputs: TranscriptionInputsSpec & {
10750
+ text?: false;
10751
+ };
10752
+ };
10459
10753
  /** What a host writes to define a live profile. */
10460
10754
  export type LiveProfileDefinition = ProfileDefinitionBase & {
10461
10755
  type: 'live';
@@ -10489,13 +10783,15 @@ export type HostProfileDefinition = {
10489
10783
  labels?: LabelOverrides;
10490
10784
  };
10491
10785
  /** Any profile definition, discriminated by \`type\`. */
10492
- export type ProfileDefinition = TextProfileDefinition | ImageProfileDefinition | SpeechProfileDefinition | LiveProfileDefinition | DecisionProfileDefinition | EmbeddingProfileDefinition | HostProfileDefinition;
10786
+ export type ProfileDefinition = TextProfileDefinition | ImageProfileDefinition | SpeechProfileDefinition | LiveProfileDefinition | DecisionProfileDefinition | TranscriptionProfileDefinition | EmbeddingProfileDefinition | HostProfileDefinition;
10493
10787
  /** Validate a definition and return the profile; throws on a malformed one. */
10494
10788
  declare function defineProfile(input: TextProfileDefinition): TextProfile;
10495
10789
  /** Validate an image definition and return the profile. */
10496
10790
  declare function defineProfile(input: ImageProfileDefinition): ImageProfile;
10497
10791
  /** Validate a speech definition and return the profile. */
10498
10792
  declare function defineProfile(input: SpeechProfileDefinition): SpeechProfile;
10793
+ /** Validate a transcription definition and return the profile. */
10794
+ declare function defineProfile(input: TranscriptionProfileDefinition): TranscriptionProfile;
10499
10795
  /** Validate a live definition and return the profile. */
10500
10796
  declare function defineProfile(input: LiveProfileDefinition): LiveProfile;
10501
10797
  /** Validate a decision definition and return the profile. */
@@ -10599,8 +10895,8 @@ export declare function profileToolsSpec(profile: Profile): ProfileToolsSpec | u
10599
10895
  export declare function profileToolsParallel(profile: Profile): boolean | undefined;
10600
10896
  export declare function resolveAllowedCustomToolIds(tools: ToolRegistry, profile: Profile, req: TurnRequest): ToolId[];
10601
10897
  export declare function resolveModelBuiltinIds(tools: ToolRegistry, profile: ModelProfile, req: TurnRequest, modelId: ModelId): ToolId[];
10602
- export declare function wireForTool(tools: ToolRegistry, name: string): WireFunctionTool | undefined;
10603
- export declare function buildWire(tools: ToolRegistry, visible: ToolId[]): WireFunctionTool[];
10898
+ export declare function wireForTool(tools: ToolRegistry, name: string, modelBackground?: boolean): WireFunctionTool | undefined;
10899
+ export declare function buildWire(tools: ToolRegistry, visible: ToolId[], modelBackground?: boolean): WireFunctionTool[];
10604
10900
  export declare function promoteTool(tools: ToolRegistry, state: TurnToolSnapshot, id: ToolId): void;
10605
10901
  export declare function promoteBuiltin(tools: ToolRegistry, state: TurnToolSnapshot, id: ToolId): void;
10606
10902
  /** Live declarations are fixed at session setup, so every allowed tool there is effectively T0. */
@@ -10612,6 +10908,8 @@ export declare function prepareTurnToolSnapshot(tools: ToolRegistry, profile: Pr
10612
10908
  /** So concurrent host invokes do not share mutable state. */
10613
10909
  export declare function cloneTurnToolSnapshot(state: TurnToolSnapshot): TurnToolSnapshot;
10614
10910
  export declare function expandT1Policy(tools: ToolRegistry, state: TurnToolSnapshot, profile: Profile, req: TurnRequest): Promise<void>;
10911
+ /** Puts the T2 tools among \`ids\` that the turn may call on its list; any other id is left out. */
10912
+ export declare function promoteTurnTools(tools: ToolRegistry, state: TurnToolSnapshot, ids?: readonly ToolId[]): void;
10615
10913
  export declare function extractLoadedIds(output: unknown): string[] | undefined;
10616
10914
  export declare function promoteLoadedTools(tools: ToolRegistry, state: TurnToolSnapshot, loaded: string[], profile: Profile): PromoteLoadedResult;
10617
10915
  export declare function promotionTarget(tools: ToolRegistry, id: string, profile: Profile): {
@@ -10802,6 +11100,8 @@ export interface ToolStageSupport {
10802
11100
  wait?: StepWait;
10803
11101
  /** The host sees a handler's drafts: \`outputs.streaming.mode\` \`sse\`. Unset outside a turn's step. */
10804
11102
  drafts?: boolean;
11103
+ /** Told when the body has ended, before \`post_tool\` reads it. */
11104
+ bodyEnded?: () => void;
10805
11105
  }
10806
11106
  export type PreBodyOutcome = {
10807
11107
  ok: true;
@@ -10840,7 +11140,6 @@ export type PostToolStageOutcome = {
10840
11140
  };
10841
11141
  labelFailed?: true;
10842
11142
  };
10843
- /** Tool \`preTool\` → host \`pre_tool\` → mutate re-parse. */
10844
11143
  export declare function runPreToolPipeline(args: {
10845
11144
  tool: {
10846
11145
  name: string;
@@ -10849,6 +11148,7 @@ export declare function runPreToolPipeline(args: {
10849
11148
  };
10850
11149
  access: ToolAccess;
10851
11150
  labels?: ToolLabels;
11151
+ after?: boolean;
10852
11152
  preTool?: (input: never, ctx: ToolContext) => StageResult | undefined | Promise<StageResult | undefined>;
10853
11153
  };
10854
11154
  input: unknown;
@@ -10882,82 +11182,6 @@ export declare function emitGateSettlement(args: {
10882
11182
  toolName: string;
10883
11183
  labels: LabelOverrides | undefined;
10884
11184
  }): AsyncGenerator<TurnEvent, string | undefined>;
10885
- `,"file:///node_modules/@theoremjs/agents/src/kernel/tools/events.d.ts":`import type { z } from 'zod';
10886
- import { type LabelOverrides } from '../../guardrails/labels.js';
10887
- import type { GuardrailEvent, NetworkGuardrailSpec } from '../../guardrails/types.js';
10888
- import type { SpanHandle } from '../../observability/trace-span.js';
10889
- import { type Source } from '../turn-events.js';
10890
- import type { TurnEvent, TurnEventOf } from '../types.js';
10891
- import type { ToolOperationClaim } from './operation.js';
10892
- import type { ToolCallRequest, ToolContext, ToolFailure, ToolLabels, ToolPhaseEvent } from './types.js';
10893
- export type ToolCallBase = Pick<ToolPhaseEvent, 'name' | 'callId'> & {
10894
- operationId?: string;
10895
- /** The call's failed label, from {@linkcode failedActivity}; absent, a failure names the tool. */
10896
- activityFailed?: string;
10897
- };
10898
- export type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
10899
- export type ToolPhasePatch = DistributiveOmit<ToolPhaseEvent, keyof ToolCallBase | 'at'>;
10900
- export declare function toolEvent(base: ToolCallBase, patch: ToolPhasePatch): TurnEventOf<'tool'>;
10901
- /**
10902
- * The label a failed call shows: the tool's own, filled from the input the model sent, else the
10903
- * labels' line naming the tool in words.
10904
- */
10905
- export declare function failedActivity(name: string, profileLabels?: LabelOverrides, labels?: ToolLabels, input?: unknown): string;
10906
- /** The failed label of the call \`base\` names. */
10907
- export declare function failedActivityOf(base: ToolCallBase): string;
10908
- /** \`readBack\` is passed when the call's result guard already wrote the model's text. */
10909
- export declare function failureEvent(base: ToolCallBase, failure: ToolFailure, readBack?: string): TurnEventOf<'tool'>;
10910
- /** The first event of every call. */
10911
- export declare function toolCallRequestEvent(base: ToolCallBase, args: Record<string, unknown>, { reasoning, stepId, stepCallCount, }?: Pick<ToolCallRequest, 'reasoning' | 'stepId' | 'stepCallCount'>): TurnEventOf<'tool'>;
10912
- /** Unique: readers join a call's events by it. */
10913
- export declare function newCallId(name: string): string;
10914
- export declare function toolCallArguments(safeInput: unknown): Record<string, unknown>;
10915
- export declare function messageOf(err: unknown): string;
10916
- export declare function sourceEvents(base: ToolCallBase, sources: (output: unknown) => Source[], output: unknown): Generator<TurnEvent>;
10917
- /** A call's claim, taken once at the hand-off: right before the destination is asked. */
10918
- export declare class HandOff {
10919
- private begin?;
10920
- private taken?;
10921
- private failed?;
10922
- constructor(begin?: (() => Promise<ToolOperationClaim | undefined>) | undefined);
10923
- claim(): Promise<ToolOperationClaim | undefined>;
10924
- /** The claim's own failure is the coordinator's, so no tool catch may turn it into a tool failure. */
10925
- rethrowClaimFailure(): void;
10926
- }
10927
- export declare function dispatchToolBody(tool: {
10928
- labels?: ToolLabels;
10929
- }, input: unknown, ctx: ToolContext, base: ToolCallBase, beginBody?: (preparedInput: unknown) => Promise<ToolOperationClaim | undefined>): AsyncGenerator<TurnEvent, HandOff>;
10930
- export declare function startToolExecution<T>(tool: {
10931
- input: z.ZodType<T>;
10932
- }, rawInput: unknown, ctx: ToolContext): {
10933
- ok: true;
10934
- data: T;
10935
- } | {
10936
- ok: false;
10937
- failure: ToolFailure;
10938
- };
10939
- export declare function networkBlockedEvent(): GuardrailEvent;
10940
- export declare function networkBlocked(err: unknown, guardrail?: GuardrailEvent): Generator<TurnEvent, ToolFailure>;
10941
- /**
10942
- * Shared by HTTP and MCP so they cannot diverge on what SSRF enforcement means.
10943
- * The check's time goes on the tool's span, when the call is traced.
10944
- */
10945
- export declare function guardToolTarget(url: string, ctx: ToolContext, span?: SpanHandle): Generator<TurnEvent, {
10946
- ok: true;
10947
- url: URL;
10948
- } | {
10949
- ok: false;
10950
- failure: ToolFailure;
10951
- }>;
10952
- /** The checks a guarded request runs on its way, timed together: each hop's address, and its lookup. */
10953
- export interface RequestChecks {
10954
- /** Pass as \`fetchGuarded\`'s \`onCheck\`. */
10955
- onCheck: (ms: number) => void;
10956
- /** Records the checks once, when any ran, with the block they raised. */
10957
- record: (blocked?: GuardrailEvent) => void;
10958
- }
10959
- export declare function requestChecks(span: SpanHandle | undefined): RequestChecks;
10960
- export declare function toolNetworkPolicy(ctx: ToolContext): NetworkGuardrailSpec | undefined;
10961
11185
  `,"file:///node_modules/@theoremjs/agents/src/kernel/tools/handler-events.d.ts":`import type { ToolBoundary } from '../../guardrails/boundaries.js';
10962
11186
  import type { Provenance, ResolvedGuardrailPolicy } from '../../guardrails/types.js';
10963
11187
  import type { TurnEvent } from '../types.js';
@@ -11044,6 +11268,7 @@ import { type ToolCallEnd } from '../engine/tool-trace.js';
11044
11268
  import type { InjectUnit } from '../stages.js';
11045
11269
  import type { InteractionPart, Profile, TurnEvent } from '../types.js';
11046
11270
  import { type AgentCaller } from './agent.js';
11271
+ import { type ToolBackgroundSupport } from './background.js';
11047
11272
  import { startToolExecution, type ToolCallBase } from './events.js';
11048
11273
  import type { ToolExecutionCoordinator, ToolOperationClaim, ToolOperationOutcome } from './operation.js';
11049
11274
  import type { ToolRegistry } from './registry.js';
@@ -11099,6 +11324,7 @@ export declare function authorizeToolReplay(args: {
11099
11324
  }): void;
11100
11325
  interface RegisteredToolCall {
11101
11326
  execution?: ToolExecutionCoordinator;
11327
+ background?: ToolBackgroundSupport;
11102
11328
  invocation?: unknown;
11103
11329
  onDispatch?: () => void;
11104
11330
  beginBody?: (preparedInput: unknown) => Promise<ToolOperationClaim | undefined>;
@@ -11632,6 +11858,28 @@ export interface MemoryToolExecutionOptions {
11632
11858
  * A host that resumes across requests or workers supplies its own \`ToolExecutionCoordinator\`.
11633
11859
  */
11634
11860
  export declare function createMemoryToolExecution(options?: MemoryToolExecutionOptions): ToolExecutionCoordinator;
11861
+ `,"file:///node_modules/@theoremjs/agents/src/kernel/system-lines.d.ts":`import type { ProfileConditions, ProfileSystem, SystemPiece, TurnRequest } from './types.js';
11862
+ /** What is wrong with a prompt's conditions and lines, or undefined. */
11863
+ export declare function systemLinesProblem(prompt: ProfileSystem, conditions: ProfileConditions | undefined, slots: Record<string, readonly string[]>): string | undefined;
11864
+ /** The facts a turn's \`when\` reads, once the turn has stated every condition with a listed value. */
11865
+ export declare function turnFacts(id: string, conditions: ProfileConditions | undefined, req: Pick<TurnRequest, 'path' | 'conditions'>, slots: Record<string, string> | undefined): Record<string, string>;
11866
+ /** A line that fit a turn: its number in the prompt as written, from 1, and its pieces. */
11867
+ export type KeptSystemLine = {
11868
+ line: number;
11869
+ pieces: SystemPiece[];
11870
+ };
11871
+ /**
11872
+ * Every line that fits. Whether plain text is shareable is settled on the prompt as written, so a
11873
+ * line dropped on this turn never changes the marks of one that stayed.
11874
+ */
11875
+ export declare function pickSystemLines(prompt: ProfileSystem, facts: Record<string, string>, fill: (text: string) => string): KeptSystemLine[];
11876
+ /** \`where\` names the prompt in the error. A bare \`{ private }\` must sit inside a line's own list. */
11877
+ export declare function assertSystemLines(prompt: unknown, where: string): asserts prompt is ProfileSystem;
11878
+ /** The first tool in \`tools\` with a path \`conditions.path\` does not list, as a sentence. */
11879
+ export declare function toolPathProblem(conditions: ProfileConditions | undefined, tools: readonly {
11880
+ name: string;
11881
+ paths?: readonly string[];
11882
+ }[]): string | undefined;
11635
11883
  `,"file:///node_modules/@theoremjs/agents/src/kernel/scope.d.ts":`import type { TraceSink } from '../observability/trace-sink.js';
11636
11884
  import { type RunDecisionOptions } from './engine/decision.js';
11637
11885
  import { type RunEmbeddingOptions } from './engine/embedding.js';
@@ -11681,12 +11929,14 @@ export { isModelProfile, pickModel, projectProfileInRegistry, projectProfileObje
11681
11929
  `,"file:///node_modules/@theoremjs/agents/src/kernel/engine/session/mod.d.ts":`import type { TraceSink } from '../../../observability/trace-sink.js';
11682
11930
  import type { ProviderHostOptions } from '../../protocols/runtime.js';
11683
11931
  import type { KernelRegistry } from '../../registry/kernel-registry.js';
11932
+ import { type ToolBackgroundService } from '../../tools/background.js';
11684
11933
  import { type PageToolExecution, type ToolExecutionCoordinator } from '../../tools/operation.js';
11685
11934
  import type { KeyVault, LiveSession, SessionRequest } from '../../types.js';
11686
11935
  export type { LiveSession, SessionRequest };
11687
11936
  /** Options for opening a live session: the key vault, a provider's own settings, a WebSocket opener, how long a gated call waits for its decision, and the sign-in gate policy. */
11688
11937
  export interface RunSessionOptions extends ProviderHostOptions {
11689
11938
  execution?: ToolExecutionCoordinator;
11939
+ background?: ToolBackgroundService;
11690
11940
  pageExecution?: PageToolExecution;
11691
11941
  /** The host's keys by slot; the session uses the slots its profile names. */
11692
11942
  vault?: KeyVault;
@@ -11775,6 +12025,19 @@ export declare function validateDecisionRequest(request: Omit<DecisionRequest, '
11775
12025
  */
11776
12026
  export declare function runDecisionInRegistry(registry: KernelRegistry, request: DecisionRequest, options: RunDecisionOptions): Promise<DecisionResult>;
11777
12027
  export {};
12028
+ `,"file:///node_modules/@theoremjs/agents/src/kernel/registry/system-prompt.d.ts":`import type { ModelProfile, SystemPiece, TurnRequest } from '../types.js';
12029
+ /**
12030
+ * Synchronous: snapshotted in \`resolveTurn\` before any async work. Each source
12031
+ * keeps its own marks: a \`{ private }\` part in \`req.system\` leaves the
12032
+ * profile's prompt as private as it was written.
12033
+ */
12034
+ declare function resolveTurnSystem(profile: ModelProfile, req: TurnRequest): {
12035
+ pieces: SystemPiece[];
12036
+ lines: number[];
12037
+ };
12038
+ /** The whole prompt a turn sends, for what reads it outside a turn. */
12039
+ declare function resolveTurnSystemPrompt(profile: ModelProfile, req: TurnRequest): SystemPiece[];
12040
+ export { resolveTurnSystem, resolveTurnSystemPrompt };
11778
12041
  `,"file:///node_modules/@theoremjs/agents/src/kernel/registry/embedding-rules.d.ts":`import type { EmbeddingModelLimits } from '../protocols/protocol.js';
11779
12042
  import type { AttachmentValidationIssue, MimeInputs } from '../types.js';
11780
12043
  import { type AttachmentFacts } from './attachments.js';