@theoremjs/studio 0.3.5-next.945.g127cfdd → 0.3.5-next.947.ga93f6be

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 (61) hide show
  1. package/package.json +4 -4
  2. package/page/assets/{BottomSheet-CGCeV0j1.js → BottomSheet-CbCAQUBQ.js} +1 -1
  3. package/page/assets/{ConsoleFrame-D2GshrNG.js → ConsoleFrame-DH2a1vrD.js} +1 -1
  4. package/page/assets/{ContextMenu-DBz-JG4k.js → ContextMenu-D0oalW1u.js} +2 -2
  5. package/page/assets/{DateInput-D4P1qXs4.js → DateInput-tbtgv-q-.js} +1 -1
  6. package/page/assets/{DropdownMenu-L_jMBqTm.js → DropdownMenu-BGHkPlA7.js} +2 -2
  7. package/page/assets/{Link-8shHw31C.js → Link-BdlPyZ6G.js} +1 -1
  8. package/page/assets/{MenuBottomSheet-CpgKx3Gn.js → MenuBottomSheet-WfWPx-Ma.js} +1 -1
  9. package/page/assets/{PowerSearchBottomSheet-DpeYUQEs.js → PowerSearchBottomSheet-Dhba6Dlf.js} +1 -1
  10. package/page/assets/{RankedBars-BiLmrqKa.js → RankedBars-X7KS7Ey_.js} +1 -1
  11. package/page/assets/{SchemaFields-CFmjkJ6M.js → SchemaFields-BSR3HgW9.js} +1 -1
  12. package/page/assets/{ShapedData-DwKqBicC.js → ShapedData-8E1Hf69N.js} +1 -1
  13. package/page/assets/{TokenizerBottomSheet-CqNod-xJ.js → TokenizerBottomSheet-CFnjuPJw.js} +1 -1
  14. package/page/assets/{ToolResultCharts-B8nqKU-p.js → ToolResultCharts-DT0OMyYN.js} +1 -1
  15. package/page/assets/{Toolbar-JItJGIdz.js → Toolbar-B2vBVJtH.js} +1 -1
  16. package/page/assets/{TraceInspector-CR2p0Rsk.js → TraceInspector-Pj2XJuEw.js} +2 -2
  17. package/page/assets/{TraceOverview-4URknKAx.js → TraceOverview-D4DIcN9l.js} +1 -1
  18. package/page/assets/{_virtual_studio-type-sources-D6OCf7oS.js → _virtual_studio-type-sources-CWoI42kg.js} +57 -28
  19. package/page/assets/browser-connection-Dv7xbw01.js +1 -0
  20. package/page/assets/browser-engine-CUolmSdJ.js +16 -0
  21. package/page/assets/{browser-transport-B4Kwu8zD.js → browser-transport-DZysgy_n.js} +2 -2
  22. package/page/assets/{compile-8yHA7cmn.js → compile-DLWyxLzo.js} +2 -2
  23. package/page/assets/{encode-files-C49AZpSN.js → encode-files-Ds3y6S6n.js} +1 -1
  24. package/page/assets/{export-agent-DnBVyBSA.js → export-agent-CXvtWAIR.js} +1 -1
  25. package/page/assets/{getRadiusAndStrokeWidthFromDot-BWoQYgPp.js → getRadiusAndStrokeWidthFromDot-j4wSScez.js} +1 -1
  26. package/page/assets/{guardrail-health-Bx0iZLTr.js → guardrail-health-B5uD28im.js} +1 -1
  27. package/page/assets/{guardrail-tester-BQJ57eVF.js → guardrail-tester-COTpzp0w.js} +1 -1
  28. package/page/assets/{index-yC5X4xkW.js → index-9t-ygFkN.js} +8 -8
  29. package/page/assets/{json-code-DvTbV1HF.js → json-code-DtIiEApl.js} +1 -1
  30. package/page/assets/{labels-provider-BEgq92JU.js → labels-provider-Bd1FiylS.js} +1 -1
  31. package/page/assets/{live-messages-BrQhgNiV.js → live-messages-C-FbebJ6.js} +1 -1
  32. package/page/assets/{prompt-row-D6KsHzGX.js → prompt-row-DGQ7P1Ze.js} +1 -1
  33. package/page/assets/{reader--ohfEAKk.js → reader-Zu8mdSRg.js} +2 -2
  34. package/page/assets/{registry-DTX5GVdX.js → registry-CjatM33q.js} +1 -1
  35. package/page/assets/schema-CHxE5EUz.js +3 -0
  36. package/page/assets/{shaped-data-gYhn8vze.js → shaped-data-KV3CIOIt.js} +15 -15
  37. package/page/assets/{stub-CnSd7ZhQ.js → stub-DiDXlAmt.js} +1 -1
  38. package/page/assets/{studio-code-pane-DqwItrQC.js → studio-code-pane-BRxcoh92.js} +3 -3
  39. package/page/assets/{studio-console-C3fb3uvx.js → studio-console-vhGV4snh.js} +1 -1
  40. package/page/assets/{studio-decision-DU0xJ_yF.js → studio-decision-Dd7Cz-Yf.js} +1 -1
  41. package/page/assets/{studio-embedding-BWRXx7j3.js → studio-embedding-D2GQt7X2.js} +1 -1
  42. package/page/assets/studio-host-console-D-lSv2ma.js +2 -0
  43. package/page/assets/{studio-live-V8VdBf-b.js → studio-live-D_nF6Z7B.js} +1 -1
  44. package/page/assets/{studio-map-DUsPuSdw.js → studio-map-BjwC3AFc.js} +1 -1
  45. package/page/assets/{studio-media-DrQcx2gs.js → studio-media-BqVez1lU.js} +3 -3
  46. package/page/assets/{studio-trace-replay-CiPB4pLJ.js → studio-trace-replay-Pw89VSWS.js} +1 -1
  47. package/page/assets/{studio-type-checker-DE8zvwkv.js → studio-type-checker-DC1LxprE.js} +1 -1
  48. package/page/assets/{tool-schema-Cw0KPTnQ.js → tool-schema-h27oVndM.js} +1 -1
  49. package/page/assets/{trace-record-DK92KCo0.js → trace-record-BOw-semK.js} +1 -1
  50. package/page/assets/{tree-CrlkcK_x.js → tree-CUvi9p2d.js} +1 -1
  51. package/page/assets/{turn-client-Cef0JadZ.js → turn-client-w8IxCaeD.js} +2 -2
  52. package/page/assets/types-Bl7WithI.js +1 -0
  53. package/page/assets/{use-one-call-BzjYM1tg.js → use-one-call-C_E4YmwY.js} +1 -1
  54. package/page/assets/{useDismissSearchOnTouchDrag-CJF2iaqF.js → useDismissSearchOnTouchDrag-Cv-vZ59K.js} +1 -1
  55. package/page/assets/{workspace-iTQdUZ--.js → workspace-BluAvYVx.js} +1 -1
  56. package/page/index.html +21 -21
  57. package/page/assets/browser-connection-WnnSpy0l.js +0 -1
  58. package/page/assets/browser-engine-B3DypGiU.js +0 -16
  59. package/page/assets/schema-DXPRQZid.js +0 -3
  60. package/page/assets/studio-host-console-BcxYCUod.js +0 -2
  61. package/page/assets/types-D394SB-s.js +0 -1
@@ -4853,12 +4853,12 @@ export { GATE_DECISIONS, type GateDecision } from './src/kernel/tools/gate-answe
4853
4853
  export type { MemoryToolExecutionOptions } from './src/kernel/tools/memory-execution.js';
4854
4854
  export { createMemoryToolExecution } from './src/kernel/tools/memory-execution.js';
4855
4855
  export type { CredentialQuery, McpProtocolVersion, McpRpcResponse, ToolRegistry, } from './src/kernel/tools/mod.js';
4856
- export { askUserTool, assertToolSettings, buildHttpToolTarget, createToolRegistry, credentialPlacement, executeHttpTool, executeMcpTool, formatToolFailureForModel, formatToolResult, isUnsupportedMcpProtocolError, MCP_PROTOCOL_VERSIONS, mcpRequestMeta, parseMcpRpcResponse, prepareTurnToolSnapshot, registerHarnessTools, resolveToolAuth, UncheckedOutput, uncheckedOutput, withCredentialQuery, } from './src/kernel/tools/mod.js';
4856
+ export { askUserTool, assertToolSettings, buildHttpToolTarget, createToolRegistry, credentialPlacement, executeHttpTool, executeMcpTool, formatToolFailureForModel, formatToolResult, isUnsupportedMcpProtocolError, MCP_PROTOCOL_VERSIONS, mcpRequestMeta, parseMcpRpcResponse, prepareTurnToolSnapshot, registerHarnessTools, resolveToolAuth, toolOutputPartSchema, UncheckedOutput, uncheckedOutput, withCredentialQuery, } from './src/kernel/tools/mod.js';
4857
4857
  export type { BackgroundToolEvent, BeginToolOperationResult, PageToolDispatch, PageToolExecution, SavedToolInvocation, TerminalToolEvent, ToolExecutionCoordinator, ToolOperationClaim, ToolOperationIdentity, ToolOperationOutcome, ToolOperationReply, ToolOperationUncertainty, } from './src/kernel/tools/operation.js';
4858
4858
  export { savedToolInvocationSchema, toolInvocationHash, toolOperationOutcomeSchema, toolOperationReplySchema, } from './src/kernel/tools/operation.js';
4859
4859
  export type { SettledToolCall, ToolCallResult, ToolStepCallResult, } from './src/kernel/tools/run.js';
4860
4860
  export type { ModelToolResult, PageAnswer, ToolContext, ToolMediaEntry, } from './src/kernel/tools/types.js';
4861
- export { awaitingUserInputSchema, type GateReference, gateReferenceSchema, isAwaitingUserInput, keptReply, reasoningPartSchema, type ToolOutputPart, TURN_EVENT_SCHEMAS, toolGateSchema, toolOutputPartSchema, turnDoneOf, turnEventSchema, turnHistoryMessageSchema, turnToolSnapshotSchema, } from './src/kernel/turn-events.js';
4861
+ export { awaitingUserInputSchema, type GateReference, gateReferenceSchema, isAwaitingUserInput, keptReply, reasoningPartSchema, type ToolOutputPart, TURN_EVENT_SCHEMAS, toolGateSchema, turnDoneOf, turnEventSchema, turnHistoryMessageSchema, turnToolSnapshotSchema, } from './src/kernel/turn-events.js';
4862
4862
  export type * from './src/kernel/types.js';
4863
4863
  export type { OtlpAnyValue, OtlpKeyValue, OtlpSpan, OtlpTraceRequest, ProfileObservabilitySpec, ResolvedObservabilityPolicy, ResolvedScrubSwitch, ResolvedTraceInclude, ResolvedTraceScrub, ScrubSwitch, SpanHandle, SpanLinkInput, SpanOptions, TraceAttributeGroup, TraceAttributeMeta, TraceAttributes, TraceAttributeValue, TraceBytes, TraceClock, TraceContent, TraceEventMeta, TraceIncludeSpec, TraceJson, TraceOptionMeta, TraceRecord, TraceScrubSpec, TraceSink, TraceSpan, TraceSpanEvent, TraceSpanKind, TraceSpanLink, TraceSpanMeta, TraceSpanStatus, TraceSpanType, TraceTree, TraceValueFormat, TraceWriteContext, } from './src/observability/mod.js';
4864
4864
  export { buildRecord, clearTraceDestinations, contentOf, getTraceDestination, inlineContent, isTraceSink, listTraceDestinationIds, memorySink, noopSink, readTraceparent, registerTraceDestination, requireTraceDestination, resolveObservabilityPolicy, resolveTraceWriter, startTrace, TRACE_ATTRIBUTE_GROUPS, TRACE_FIELDS, TRACE_SPAN_TYPES, TRACE_STATUS, toOtlpJson, traceAttributeMeta, traceBytes, traceContent, traceEventAttributeMeta, traceEventMeta, traceJson, traceRecordSchema, traceSpanMeta, writeTrace, } from './src/observability/mod.js';
@@ -5326,8 +5326,8 @@ import type { ToolBackgroundService } from './tools/background.js';
5326
5326
  import type { GateDecision } from './tools/gate-answer.js';
5327
5327
  import type { PageToolExecution, ToolExecutionCoordinator, ToolOperationOutcome } from './tools/operation.js';
5328
5328
  import type { AgentCall, AgentCallHook, AgentCallRequest, AgentToolDef, AgentToolInput, AgentToolOutput, HostProfileToolsSpec, InvokeToolRequest, InvokeToolResume, InvokeToolStepCall, InvokeToolStepRequest, LiveProfileToolsSpec, ModelToolResult, PageAnswer, ProfileToolsSpec, RegisteredTool, ToolCallEvent, ToolFailure, ToolGate, ToolLoadContext, ToolMediaEntry, ToolPolicy, TurnToolSnapshot, WireFunctionTool } from './tools/types.js';
5329
- import type { AttemptReason, CallDone, CompactionFailure, CompactionResult, CompactionSignal, DoneFields, GroundingEvent, InjectedMessages, InteractionMediaPart, InteractionMediaRefPart, InteractionPart, InteractionTextPart, InvalidField, ModelEvent, ProviderEvidence, RemovedItem, SessionEnded, SessionEvent, SessionEventKind, SessionEventOf, Source, ToolOutputPart, TurnCost, TurnEvent, TurnEventOf, TurnEventType, TurnGroundingCount, TurnHistoryMessage, TurnResponse, TurnTokenSide, TurnTokens } from './turn-events.js';
5330
- export type { AgentCall, AgentCallHook, AgentCallRequest, AgentToolDef, AgentToolInput, AgentToolOutput, AttemptReason, CallDone, CompactionFailure, CompactionMeter, CompactionOutcome, CompactionResult, CompactionSignal, CompactionTiming, ContinueStopKind, DoneFields, FieldMeta, GroundingEvent, HostProfileToolsSpec, InjectedMessages, InteractionMediaPart, InteractionMediaRefPart, InteractionPart, InteractionTextPart, InvalidField, InvokeToolRequest, InvokeToolResume, InvokeToolStepCall, InvokeToolStepRequest, KeySlot, KeyVault, LiveActivityHandling, LiveEndSensitivity, LiveProfileToolsSpec, LiveStartSensitivity, MediaInputKind, ModelEvent, ProfileToolsSpec, ProfileType, ProviderEvidence, RegisteredTool, RemovedItem, SessionEnded, SessionEvent, SessionEventKind, SessionEventOf, Source, SpeechAudioFormat, StreamMode, SummaryMode, ThinkingLevel, ToolCallEvent, ToolFailure, ToolGate, ToolLoadContext, ToolLoadTier, ToolMediaEntry, ToolOutputPart, ToolPolicy, TurnCost, TurnEvent, TurnEventOf, TurnEventType, TurnGroundingCount, TurnHistoryMessage, TurnResponse, TurnStage, TurnStopKind, TurnTokenSide, TurnTokens, TurnToolSnapshot, WireFunctionTool, };
5329
+ import type { AttemptReason, CallDone, CompactionFailure, CompactionResult, CompactionSignal, DoneFields, GroundingEvent, InjectedMessages, InteractionMediaPart, InteractionMediaRefPart, InteractionPart, InteractionTextPart, InvalidField, ModelEvent, ProviderEvidence, RemovedItem, SessionEnded, SessionEvent, SessionEventKind, SessionEventOf, Source, ToolOutputMediaPart, ToolOutputPart, ToolOutputRefPart, TurnCost, TurnEvent, TurnEventOf, TurnEventType, TurnGroundingCount, TurnHistoryMessage, TurnResponse, TurnTokenSide, TurnTokens } from './turn-events.js';
5330
+ export type { AgentCall, AgentCallHook, AgentCallRequest, AgentToolDef, AgentToolInput, AgentToolOutput, AttemptReason, CallDone, CompactionFailure, CompactionMeter, CompactionOutcome, CompactionResult, CompactionSignal, CompactionTiming, ContinueStopKind, DoneFields, FieldMeta, GroundingEvent, HostProfileToolsSpec, InjectedMessages, InteractionMediaPart, InteractionMediaRefPart, InteractionPart, InteractionTextPart, InvalidField, InvokeToolRequest, InvokeToolResume, InvokeToolStepCall, InvokeToolStepRequest, KeySlot, KeyVault, LiveActivityHandling, LiveEndSensitivity, LiveProfileToolsSpec, LiveStartSensitivity, MediaInputKind, ModelEvent, ProfileToolsSpec, ProfileType, ProviderEvidence, RegisteredTool, RemovedItem, SessionEnded, SessionEvent, SessionEventKind, SessionEventOf, Source, SpeechAudioFormat, StreamMode, SummaryMode, ThinkingLevel, ToolCallEvent, ToolFailure, ToolGate, ToolLoadContext, ToolLoadTier, ToolMediaEntry, ToolOutputMediaPart, ToolOutputPart, ToolOutputRefPart, ToolPolicy, TurnCost, TurnEvent, TurnEventOf, TurnEventType, TurnGroundingCount, TurnHistoryMessage, TurnResponse, TurnStage, TurnStopKind, TurnTokenSide, TurnTokens, TurnToolSnapshot, WireFunctionTool, };
5331
5331
  /** A host-chosen key naming one model binding in a profile's \`models\`. */
5332
5332
  export type ModelId = string;
5333
5333
  /** The id of a provider-side tool such as web search. */
@@ -7026,15 +7026,25 @@ export interface InteractionMediaRefPart {
7026
7026
  /** A part of a history message: text or media. */
7027
7027
  export type InteractionPart = InteractionTextPart | InteractionMediaPart | InteractionMediaRefPart;
7028
7028
  export declare const interactionPartSchema: z.ZodType<InteractionPart>;
7029
+ /** Media bytes a tool returned: the model reads them, and \`sent\` also shows them to the person. */
7030
+ export interface ToolOutputMediaPart extends InteractionMediaPart {
7031
+ sent?: true;
7032
+ /** Your own values, carried with the file to every view and resolver; Theorem does not read them, and the model never sees them. */
7033
+ metadata?: Record<string, unknown>;
7034
+ }
7035
+ /** A reference a tool returned: the person is shown it through the app's own resolver, and the model never reads it. */
7036
+ export interface ToolOutputRefPart extends InteractionMediaRefPart {
7037
+ /** Your own values, carried with the file to every view and resolver; Theorem does not read them, and the model never sees them. */
7038
+ metadata?: Record<string, unknown>;
7039
+ }
7029
7040
  /**
7030
7041
  * A part of what a tool returned. Text and media bytes are what the model reads; \`sent\` on media
7031
7042
  * also shows it to the person. A reference (\`uri\`) is shown to the person only, through the app's
7032
7043
  * own resolver: the model never reads it.
7033
7044
  */
7034
- export type ToolOutputPart = InteractionTextPart | (InteractionMediaPart & {
7035
- sent?: true;
7036
- }) | InteractionMediaRefPart;
7037
- export declare const toolOutputPartSchema: z.ZodType<ToolOutputPart>;
7045
+ export type ToolOutputPart = InteractionTextPart | ToolOutputMediaPart | ToolOutputRefPart;
7046
+ /** Reads a tool output part Theorem recorded; a tool's own output is checked by the stricter \`toolOutputPartSchema\`. */
7047
+ export declare const toolOutputPartRecord: z.ZodType<ToolOutputPart>;
7038
7048
  /** One message of a conversation history the host replays into a turn. */
7039
7049
  /** Where a piece of signed reasoning came from. \`protocol\` decides where it may go back to. */
7040
7050
  export interface ReasoningOrigin {
@@ -9956,8 +9966,8 @@ import type { GuardrailHit, Provenance, TurnTaint } from '../../guardrails/types
9956
9966
  import type { ToolCredentialSource } from '../auth/credential-source.js';
9957
9967
  import type { OAuthEndpoints } from '../auth/types.js';
9958
9968
  import type { AuthUnauthenticatedPolicy, HttpMethod, ToolAccess, ToolAuthType, ToolGateKind, ToolLoadTier, ToolPermission, ToolResumeCause } from '../schema.js';
9959
- import type { RemovedItem, Source, ToolCallEdit, ToolCallEvent, ToolCallRequest, ToolFailure, ToolGate, ToolOutputPart, ToolPhaseEvent, ToolTraceStep, ToolWarning, TurnToolSnapshot, WireFunctionTool } from '../turn-events.js';
9960
- import type { InteractionMediaRefPart, InteractionPart, ModelId, Profile, ProfileId, RunControls, ToolId, TurnInput, TurnRequest, TurnSpeech } from '../types.js';
9969
+ import type { RemovedItem, Source, ToolCallEdit, ToolCallEvent, ToolCallRequest, ToolFailure, ToolGate, ToolOutputPart, ToolOutputRefPart, ToolPhaseEvent, ToolTraceStep, ToolWarning, TurnToolSnapshot, WireFunctionTool } from '../turn-events.js';
9970
+ import type { InteractionPart, ModelId, Profile, ProfileId, RunControls, ToolId, TurnInput, TurnRequest, TurnSpeech } from '../types.js';
9961
9971
  import type { LabelTemplate } from './activity-label.js';
9962
9972
  import type { ToolBackground, ToolBackgroundService } from './background.js';
9963
9973
  import type { PageToolExecution, ToolExecutionCoordinator } from './operation.js';
@@ -10201,7 +10211,7 @@ export interface ToolOutputHooks<TOut = unknown> {
10201
10211
  export type ToolMediaEntry = {
10202
10212
  url: string;
10203
10213
  sent?: true;
10204
- } | InteractionMediaRefPart;
10214
+ } | ToolOutputRefPart;
10205
10215
  /** For a tool whose response the builder does not write; a function tool returns its media itself as \`parts\`. */
10206
10216
  export interface ToolMediaHooks<TOut = unknown> {
10207
10217
  /**
@@ -12533,9 +12543,10 @@ export declare function isMcpSessionId(value: string | null): value is string;
12533
12543
  * in either; the credential is never kept.
12534
12544
  */
12535
12545
  export declare function mcpSessionKey(url: string, headers: Record<string, string>): Promise<string>;
12536
- `,"file:///node_modules/@theoremjs/agents/src/kernel/tools/mod.d.ts":`export { authorizeToolReplay, coerceToolResultParts, executeRegisteredTool, leanToolResultData, projectForModel, } from './execute.js';
12546
+ `,"file:///node_modules/@theoremjs/agents/src/kernel/tools/mod.d.ts":`export { authorizeToolReplay, executeRegisteredTool, leanToolResultData, projectForModel, } from './execute.js';
12537
12547
  export { askUserTool, registerHarnessTools } from './harness.js';
12538
12548
  export { formatToolFailureForModel, formatToolResult } from './model-text.js';
12549
+ export { toolOutputPartSchema } from './output-parts.js';
12539
12550
  export type { ToolRegistry } from './registry.js';
12540
12551
  export { assertToolSettings, createToolRegistry } from './registry.js';
12541
12552
  export type { CredentialQuery, McpProtocolVersion, McpRpcResponse } from './remote.js';
@@ -12937,6 +12948,30 @@ export declare class HandlerEvents {
12937
12948
  /** Whether a check at the output's boundary stops \`data\`; a flag lets it through unreported. */
12938
12949
  private progressStops;
12939
12950
  }
12951
+ `,"file:///node_modules/@theoremjs/agents/src/kernel/tools/output-parts.d.ts":`import { z } from 'zod';
12952
+ import { type ToolOutputPart } from '../turn-events.js';
12953
+ import type { SchemaIssue } from './schema-issues.js';
12954
+ /** A reference part: the person is shown it through the app's own resolver. */
12955
+ export declare const toolOutputRefPartSchema: z.ZodObject<{
12956
+ type: z.ZodEnum<{
12957
+ image: "image";
12958
+ audio: "audio";
12959
+ video: "video";
12960
+ document: "document";
12961
+ }>;
12962
+ mimeType: z.ZodString;
12963
+ uri: z.ZodString;
12964
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
12965
+ }, z.core.$strict>;
12966
+ /**
12967
+ * A part a tool returns in its \`parts\`. A field the part does not name, empty bytes or an empty
12968
+ * reference fail the call as \`invalid_output\`, never dropped: put your own values in \`metadata\`.
12969
+ */
12970
+ export declare const toolOutputPartSchema: z.ZodType<ToolOutputPart>;
12971
+ /** Where an output's \`parts\` break {@link toolOutputPartSchema}, each issue on its own part's field. */
12972
+ export declare function toolOutputPartIssues(output: unknown): SchemaIssue[];
12973
+ /** The \`parts\` of an output whose parts had no {@link toolOutputPartIssues}. */
12974
+ export declare function checkedToolOutputParts(output: unknown): ToolOutputPart[] | undefined;
12940
12975
  `,"file:///node_modules/@theoremjs/agents/src/kernel/tools/model-text.d.ts":`import type { ModelToolResult, ToolFailure } from './types.js';
12941
12976
  /**
12942
12977
  * Every transport and replay formats through here, so the model's view of a call cannot drift.
@@ -12979,7 +13014,6 @@ import type { ToolOrigin } from '../../guardrails/types.js';
12979
13014
  import type { SpanHandle, TraceAttributes } from '../../observability/trace-span.js';
12980
13015
  import { type ToolCallEnd } from '../engine/tool-trace.js';
12981
13016
  import type { InjectUnit } from '../stages.js';
12982
- import { type ToolOutputPart } from '../turn-events.js';
12983
13017
  import type { Profile, TurnEvent } from '../types.js';
12984
13018
  import { type AgentCaller } from './agent.js';
12985
13019
  import { type ToolBackgroundSupport } from './background.js';
@@ -12995,12 +13029,6 @@ export declare function originOfTool(tool: RegisteredTool, tools: ToolRegistry):
12995
13029
  * whose text the kernel never reads. A call no tool takes is read as a function tool's.
12996
13030
  */
12997
13031
  export declare function toolArgumentsBoundary(tools: ToolRegistry, name: string): ToolBoundary | undefined;
12998
- /**
12999
- * A function tool's \`parts\` as tool media: text, media bytes (\`sent: true\` also shows them to the
13000
- * person) and references \`{ type, mimeType, uri }\` the person is shown and the model never reads.
13001
- * Invalid entries are dropped.
13002
- */
13003
- export declare function coerceToolResultParts(raw: unknown): ToolOutputPart[] | undefined;
13004
13032
  /** A tool's output without its \`parts\` key, which carries media the model receives separately; any other value is returned as it is. */
13005
13033
  export declare function leanToolResultData(output: unknown): unknown;
13006
13034
  /** What the model is told of a function tool's output: a fixed finding for a hidden tool, a finding plus the output for an awaiting-user result, otherwise the tool's own summary or finding and its data. */
@@ -14275,19 +14303,20 @@ declare function guardToolResult(finding: string, data: unknown, provenance: Pro
14275
14303
  * verbatim and is framed by the kernel as a system report.
14276
14304
  */
14277
14305
  declare function guardToolFailureText(message: string, provenance: Provenance, policy: ResolvedGuardrailPolicy, boundary: ToolBoundary | undefined): GuardedToolText;
14278
- /** What a call shows the person of one value, after it was read at \`tool_shown_<kind>\`. */
14279
- export interface ShownToolValue {
14280
- /** The value to show: every match set to \`redact\` replaced. Absent when a match blocks it. */
14306
+ /** One value of a call after it was read at its boundary. */
14307
+ export interface GuardedToolValue {
14308
+ /** The value to pass on: every match set to \`redact\` replaced. Absent when a match blocks it. */
14281
14309
  value?: unknown;
14282
14310
  event?: GuardrailEvent;
14283
14311
  }
14284
14312
  /**
14285
- * A call's output, error, and trace reach the person on the turn's events, apart from
14286
- * what the model read back: the host's server forwards them to the browser as they are. Each is
14287
- * read here at \`tool_shown_<kind>\`, so a key a tool returned is not shown. \`readBack\` is
14288
- * untouched: what the model read is settled at \`tool_output_<kind>\`.
14313
+ * A value of a call read whole at \`boundary\`, each match set to \`redact\` replaced in the string
14314
+ * it sits in. A call's output, error, trace and parts reach the person on the turn's events,
14315
+ * apart from what the model read back: the host's server forwards them to the browser as they
14316
+ * are, so each is read at \`tool_shown_<kind>\`. The text parts the model reads beside its
14317
+ * read-back are read at \`tool_output_<kind>\`, with \`scope\`.
14289
14318
  */
14290
- declare function guardShownValue(value: unknown, provenance: Provenance, policy: ResolvedGuardrailPolicy, boundary: ToolBoundary | undefined): ShownToolValue;
14319
+ declare function guardToolValue(value: unknown, provenance: Provenance, policy: ResolvedGuardrailPolicy, boundary: ToolBoundary | undefined, scope?: DetectScope): GuardedToolValue;
14291
14320
  /** A tool call's arguments after they were read at their boundary. */
14292
14321
  export interface InspectedToolArguments {
14293
14322
  /** The arguments to call the tool with. Absent when a match blocks: the tool is not called. */
@@ -14321,7 +14350,7 @@ declare function isSuspicious(taint: TurnTaint | undefined): boolean;
14321
14350
  * or not enforcement is configured, so the risk is visible before a host opts in.
14322
14351
  */
14323
14352
  declare function checkTaintGate(taint: TurnTaint | undefined, access: string, policy: ResolvedGuardrailPolicy, labels?: LabelOverrides): Verdict;
14324
- export { checkTaintGate, composeToolText, guardShownValue, guardToolFailureText, guardToolResult, inspectToolArguments, isRemoteOrigin, isSuspicious, isTainted, recordTaint, toolCallEvent, wrapToolData, };
14353
+ export { checkTaintGate, composeToolText, guardToolFailureText, guardToolResult, guardToolValue, inspectToolArguments, isRemoteOrigin, isSuspicious, isTainted, recordTaint, toolCallEvent, wrapToolData, };
14325
14354
  `,"file:///node_modules/@theoremjs/agents/src/guardrails/tool-fence.d.ts":`import type { TurnHistoryMessage } from '../kernel/turn-events.js';
14326
14355
  import type { GuardrailHit, Provenance } from './types.js';
14327
14356
  /** The closing tag of the fence a tool result is wrapped in. */
@@ -0,0 +1 @@
1
+ import{E as e,d as t,x as n}from"./schemas-D7cgkv3L.js";import{H as r}from"./tool-schema-h27oVndM.js";import{$t as i,Ba as a,Cn as o,Da as s,Fi as c,Oa as l,Oi as u,Pi as ee,Qt as te,Sn as d,Ti as ne,Tn as f,Wa as re,Xa as ie,Y as ae,Zi as oe,ao as se,ba as ce,bn as le,ea as ue,fa as p,lo as m,na as de,nn as fe,ta as pe,uo as me,wi as h,xn as g,zi as _,zt as he}from"./shaped-data-KV3CIOIt.js";import{c as v}from"./host-patterns-F-KZIzkF.js";import{A as ge,D as _e,M as ve,T as ye,x as be,y}from"./schema-CHxE5EUz.js";import{a as xe,n as Se}from"./live-ingress-OuSlQ6q7.js";var Ce=2,we=4,Te=3,Ee=/(^|,)(\s*)("?)(?:([=@])|([+-])(?![0-9."]))/gm,De=/^[A-Za-z0-9+/]*={0,2}$/,Oe=new Set([`text/csv`,`text/plain`,`text/markdown`]);function b(e){let{maxFiles:t,maxBytes:n,maxTurnBytes:r,limitsByMime:i}=e;if(t&&n&&r)return{maxFiles:t,maxBytes:n,maxTurnBytes:r,limitsByMime:i}}function ke(e,t){if(t.limitsByMime){let n=f(e);if(t.limitsByMime[n])return t.limitsByMime[n];let[r]=n.split(`/`),i=`${r}/*`;if(t.limitsByMime[i])return t.limitsByMime[i]}return t.maxBytes}function x(e){return`uri`in e}function Ae(e){if(e.type===`speech`)throw new v(`request`,`Profile ${e.id} (speech) does not accept media input`);if(e.type===`live`)throw new v(`request`,`Profile ${e.id} (live) does not accept turn attachment input`);if(e.type===`host`||e.type===`decision`||e.type===`embedding`)throw new v(`request`,`Profile ${e.id} (${e.type}) does not accept turn input`);let t=b(e.inputs??{});if(!t)throw new v(`config`,`Profile ${e.id} must set maxFiles, maxBytes, and maxTurnBytes`);return t}function je(e){let t=0;return e.endsWith(`==`)?t=Ce:e.endsWith(`=`)&&(t=1),Math.floor(e.length*Te/we)-t}function Me(e){try{return new TextDecoder(`utf-8`,{fatal:!0}).decode(e)}catch{return new TextDecoder(`latin1`).decode(e)}}function Ne(e){return e.replace(Ee,(e,...t)=>{let[n,r,i,a,o]=t;return`${n}${r}${i}'${a??``}${o??``}`})}function Pe(e,t,n){let r=Me(t);return e===`text/csv`&&(r=Ne(r)),new TextEncoder().encode(n.read(r))}function S(e,t){return t?{...e,fileName:t}:e}function C(e,t,n){return t.filter(t=>!g(e,t.mimeType)).map(e=>S({code:`mime_not_allowed`,params:{mimeType:e.mimeType,channel:n}},e.name))}function Fe(e,t){let n=[];e.length>t.maxFiles&&n.push({code:`too_many_files`,params:{maxFiles:t.maxFiles}});let r=0;for(let i of e){if(i.sizeBytes===void 0)continue;let e=ke(i.mimeType,t);i.sizeBytes>e&&n.push(S({code:`file_too_large`,params:{maxBytes:e}},i.name)),r+=i.sizeBytes}return r>t.maxTurnBytes&&n.push({code:`turn_too_large`,params:{maxTurnBytes:t.maxTurnBytes}}),n}function Ie(e,t,n){let r=[];return t.length>0&&!e.attachments&&r.push({code:`attachments_not_accepted`,params:{channel:`attachment`}}),n.length>0&&!e.voice&&r.push({code:`voice_not_accepted`,params:{channel:`voice`}}),r.length>0||t.length===0&&n.length===0?r:(e.attachments&&r.push(...C(e.attachments,t,`attachment`)),e.voice&&r.push(...C(e.voice,n,`voice`)),e.limits?[...r,...Fe([...t,...n],e.limits)]:[...r,{code:`limits_unconfigured`}])}var Le={mime_not_allowed:`attachments.mime_not_allowed`,too_many_files:`attachments.too_many_files`,too_many_of_kind:`attachments.too_many_of_kind`,file_too_large:`attachments.file_too_large`,turn_too_large:`attachments.turn_too_large`,attachments_not_accepted:`attachments.not_accepted`,voice_not_accepted:`attachments.not_accepted`,limits_unconfigured:`attachments.limits_unconfigured`};function Re(e){let t={};for(let[n,r]of Object.entries(e.params??{}))r!==void 0&&(t[n]=r);return e.fileName!==void 0&&(t.fileName=e.fileName),{key:Le[e.code],params:t}}function ze(e,t){let n=Re(e);return m(n.key,n.params,t)}function w(e){return new v(`input`,`attachments refused: ${e.map(e=>e.code).join(`, `)}`,{copy:e.map(Re)})}function T(e){if(!De.test(e))throw new v(`request`,`attachment data must be base64`);return je(e)}function E(e){let t={mimeType:e.mimeType,name:e.name};return x(e)||(t.sizeBytes=T(e.data)),t}function Be(e,t,n){if(!Ve(t,n))return;let r=Ae(e),i=Ie({attachments:d(e,`attachments`),voice:d(e,`voice`),limits:r},(t??[]).map(E),(n??[]).map(E));if(i.length>0)throw w(i)}function D(e,t){if(x(e))return e;let{mimeType:n,data:r}=e;if(!Oe.has(f(n)))return e;let i=Pe(n,s(r),t);return{...e,data:l(i)}}function Ve(e,t){return(e?.length??0)>0||(t?.length??0)>0}function He(e,t,n,r){return Be(e,t,n),{attachments:t?.length?t.map(e=>D(e,r.attachment)):t,voice:n?.length?n.map(e=>D(e,r.voice)):n}}function O(e){let t=Object.keys(e);return t.length===1?t[0]:void 0}function k(e){return e==null}function A(e){return k(e)||typeof e!=`object`||Array.isArray(e)?null:e}function j(e){let t=A(e);return!t||t.type!==void 0&&t.type!==`object`?null:t}function M(e){let t=e.required;return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}function N(e){let t=e.properties;return A(t)??{}}function Ue(e,t){return e?`${e}.${t}`:t}function P(e,t){t.push({path:e,error:`required field '${e}' is missing`})}async function We(e,t,n,r,i,a){if(!n)return;let o;try{o=await n(t,r)}catch(e){a.push(e),o={isValid:!1}}o.isValid||i.push({path:e,error:o.error||o.finding||`Validation failed for '${e}'`})}async function Ge(e){let{path:t,propSchema:n,child:r,isRequired:i,fields:a,options:o,failures:s,crashes:c}=e;if(k(r)){i&&P(t,s);return}await We(t,r,a?.[t],o,s,c);let l=j(n),u=l?A(r):null;l&&u&&await F(l,u,t,a,o,s,c)}async function F(e,t,n,r,i,a,o){let s=N(e),c=new Set(M(e)),l=new Set([...Object.keys(s),...c]),u=A(t);for(let e of l)await Ge({path:Ue(n,e),propSchema:s[e],child:u?.[e],isRequired:c.has(e),fields:r,options:i,failures:a,crashes:o})}async function Ke(e,t,n,r,i=[]){let a=j(e);if(!a)throw new v(`config`,`structured validation requires a JSON Schema object root`);let o=[];if(!A(t)){for(let e of M(a))P(e,o);return o}return await F(a,t,``,n,r,o,i),o}function qe(e,t){let n=e;for(let e of t.split(`.`)){let t=j(n);if(!t)return!1;let r=N(t);if(!Object.hasOwn(r,e)&&!M(t).includes(e))return!1;n=r[e]}return!0}function Je(e){return e.map(e=>e.error).join(`; `)}function I(e,t){let n=e;for(let e of t.split(`.`))n=A(n)?.[e];return n}function L(e,t,n){let[r,...i]=t.split(`.`),a=A(e)??{};return r===void 0?e:{...a,[r]:i.length?L(a[r],i.join(`.`),n):n}}async function Ye(e,t,n,r=[]){let i=[];for(let[a,o]of Object.entries(t??{})){let t=I(e,a);if(Array.isArray(t))for(let[e,s]of t.entries()){let t;try{t=await o.check(s,n)}catch(e){r.push(e),t={isValid:!1}}t.isValid||i.push({path:a,index:e,item:s,reason:t.error||t.finding||`Validation failed for '${a}'`,onFail:o.onFail})}}return i}function R(e,t){let n=e;for(let e of t.split(`.`)){let t=j(n);if(!t)return;n=N(t)[e]}let r=A(n);if(r?.type===`array`)return A(r.items)??void 0}function Xe(e,t,n,r){if(!n.provider?.trim()||!n.apiId?.trim())throw new v(`config`,m(`provider.binding_identity`))}function Ze(e){B(e.id,e.models),Y(e.id,e.observability),zt(e.id,e.inputs);for(let[t,n]of Object.entries(e.models))H(e.id,t,n);return{type:`embedding`,id:e.id,identity:{handle:e.identity.handle},models:e.models,defaultModel:V(e.id,e),allowModelSelect:e.allowModelSelect,inputs:e.inputs,guardrails:e.guardrails,observability:e.observability,labels:e.labels}}function Qe(e){B(e.id,e.models),q(e.id,e.guardrails),Y(e.id,e.observability);for(let[t,n]of Object.entries(e.models))H(e.id,t,n);if(`text`in e.inputs&&e.inputs.text!==!1)throw new v(`config`,`Profile ${e.id}: a transcription takes a voice clip, so inputs.text must be false`);return{type:`transcription`,id:e.id,identity:{handle:e.identity.handle},...W(e),providerContinuation:void 0,maxSteps:void 0,inputs:{...e.inputs,text:!1},guardrails:e.guardrails,observability:e.observability,labels:e.labels}}function z(e,t,n,r){let i=r.safeParse(n);if(!i.success)throw new v(`config`,`Profile ${e} model '${t}': ${i.error.issues.map(e=>`${ae(e.path)}: ${e.message}`).join(`; `)}`)}function $e(e,t,n){if(z(e,t,n,i),Xe(e,t,n,`decision`),`retry`in n)throw new v(`config`,`Profile ${e} model '${t}': a decision binding takes no retry; a decision retries only a transient failure, by the kernel's rule`);if(n.timeoutMs!==void 0&&(!Number.isFinite(n.timeoutMs)||n.timeoutMs<=0))throw new v(`config`,`Profile ${e} model '${t}' timeoutMs must be > 0`)}function et(e){let t=e.models?O(e.models):void 0;if(!t)throw new v(`config`,`Profile ${e.id}: type 'decision' must declare exactly one model`);$e(e.id,t,e.models[t])}function tt(e){if(e.inputs.state!==`json`)throw new v(`config`,`Profile ${e.id}: decision inputs.state must be 'json'`);let t=e.inputs.maxStateBytes;if(t!==void 0&&!(Number.isInteger(t)&&t>0))throw new v(`config`,`Profile ${e.id}: decision inputs.maxStateBytes must be a positive integer`);if(!e.decision.contract.trim())throw new v(`config`,`Profile ${e.id}: decision.contract must be non-empty`)}function nt(e){return et(e),tt(e),Y(e.id,e.observability),{...e,identity:{handle:e.identity.handle}}}function rt(e){return e===void 0?{}:{parallel:e}}function it(e){return at(e.id,e.tools),Y(e.id,e.observability),{type:`host`,id:e.id,tools:{allow:e.tools.allow,...rt(e.tools.parallel)},guardrails:e.guardrails,observability:e.observability,labels:e.labels}}function at(e,t){if(!Array.isArray(t.allow))throw new v(`config`,`Profile ${e}: type 'host' must set tools.allow`)}function B(e,t){if(Object.keys(t).length===0)throw new v(`config`,`Profile ${e} must declare at least one model`)}function V(e,t){let n=t.defaultModel??O(t.models);if(!n)throw new v(`config`,`Profile ${e} must set defaultModel when more than one model is declared`);if(!t.models[n])throw new v(`config`,`Profile ${e} defaultModel '${n}' is not declared`);return n}function H(e,t,n){U(e,t,n),z(e,t,n,fe),U(e,t,n)}function U(e,t,n){let r=n.efforts;if(!r||Object.keys(r).length===0){if(n.defaultEffort||n.allowEffortSelect)throw new v(`config`,`Profile ${e} model '${t}': defaultEffort and allowEffortSelect require efforts`);return}for(let[n,i]of Object.entries(r))if(!_.includes(i))throw new v(`config`,`Profile ${e} model '${t}' effort '${n}': '${i}' is not a thinking level (${_.join(`, `)})`);let i=Object.keys(r),a=n.defaultEffort??(i.length===1?i[0]:void 0);if(!a)throw new v(`config`,`Profile ${e} model '${t}' must set defaultEffort when more than one effort is declared`);if(!r[a])throw new v(`config`,`Profile ${e} model '${t}' defaultEffort '${a}' is not declared`);if(n.allowEffortSelect&&i.length<2)throw new v(`config`,`Profile ${e} model '${t}' allowEffortSelect requires at least two efforts`)}function W(e){return{providerContinuation:e.providerContinuation?ce.parse(e.providerContinuation):{},models:e.models,defaultModel:V(e.id,e),allowModelSelect:e.allowModelSelect,maxSteps:e.maxSteps}}function G(e,t,n){if(n?.length){for(let r of n)if(!he(r))throw new v(`config`,`Profile ${e}: turnBehaviour.resumption.${t} may only include ContinueStopKind (${ne.join(` | `)}); got '${r}'`)}}function ot(e,t){t&&(G(e,`allowContinue`,t.allowContinue),G(e,`autoContinue`,t.autoContinue))}function K(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function st(e,t){let n=[e];for(let e of t)n=n.flatMap(t=>K(t)?e===`*`?Object.values(t):[t[e]]:[]);return n}var ct=Object.entries(ee).filter(([,e])=>e.required===!0).map(([e,t])=>[e,t.profileTypes]).sort(([e],[t])=>e.split(`.`).length-t.split(`.`).length);function lt(e){if(!K(e))throw new v(`config`,`Profile definition must be an object`);let t=typeof e.id==`string`&&e.id.trim()?e.id:void 0;if(!t)throw new v(`config`,`Profile definition must set id`);if(!c.find(t=>t===e.type))throw new v(`config`,`Profile ${t}: type must be one of ${c.join(`, `)}`)}function ut(e){let t=e.identity?.handle,n=[[`id`,e.id,64],[`identity.handle`,typeof t==`string`?t:``,32]];for(let[t,r,i]of n)if(!(Array.from(r).length<=i))throw new v(`config`,`Profile ${e.id.slice(0,64)}: ${t} must be at most ${i} characters`)}function dt(e){let{id:t,type:n}=e,r=e;for(let[e,i]of ct){if(i&&!i.includes(n))continue;let a=pe(e),o=st(r,a.slice(0,-1)),s=a[a.length-1];if(o.some(e=>{if(!K(e))return!1;let t=e[s];return t==null||t===``}))throw new v(`config`,`Profile ${t}: type '${n}' must set ${a.join(`.`)}`)}}function ft(e){let{id:t,type:n}=e;if(n!==`live`&&de(`inputs`).includes(n)&&e.inputs==null)throw new v(`config`,`Profile ${t}: type '${n}' must set inputs`)}function pt(e){let[t]=ue(e);if(!t)return;let{offValue:n,reason:r}=t.scope,i=n===void 0?``:` (other than ${n})`;throw new v(`config`,`Profile ${e.id}: type '${e.type}' must not set ${t.path}${i} — ${r}`)}function mt(e,t){let n=t.turnBehaviour;ot(e,n?.resumption)}function ht(e,t){let n=t=>new v(`config`,`Profile ${e}: ${t}`),r=t?.maxRetries;if(r!==void 0&&(!Number.isInteger(r)||r<0))throw n(`outputs.validation.maxRetries must be a non-negative integer`)}function q(e,t){let n=t=>new v(`config`,`Profile ${e}: ${t}`),r=Object.keys(t??{}).find(e=>!J.includes(e));if(r!==void 0)throw n(`guardrails.${r} is not a setting; it takes ${J.join(`, `)}`);_t(t?.blockedReply,n)}var J=[`quota`,`detect`,`blockedReply`,`network`,`taint`],gt=[`onBlock`,`maxRetries`];function _t(e,t){if(e===void 0)return;let n=Object.keys(e).find(e=>!gt.includes(e));if(n!==void 0)throw t(`guardrails.blockedReply.${n} is not a setting; it takes onBlock and maxRetries`);let{onBlock:r,maxRetries:i}=e;if(r!==void 0&&!a.includes(r))throw t(`guardrails.blockedReply.onBlock must be one of ${a.join(`, `)}`);if(i!==void 0&&(!Number.isInteger(i)||i<0))throw t(`guardrails.blockedReply.maxRetries must be a non-negative integer`)}function vt(e){let t=e.guardrails?.detect,n=e.type===`host`?p(`guardrails.detect`,t,re):p(`guardrails.detect`,t);if(n!==void 0)throw new v(`config`,`Profile ${e.id}: ${n}`)}function Y(e,t){try{let n=xe(t);if(!Number.isFinite(n.retainForDays))throw new v(`config`,`Profile ${e}: observability.retainForDays must be a finite number`);if(n.rotateAfterMiB<=0||!Number.isFinite(n.rotateAfterMiB))throw new v(`config`,`Profile ${e}: observability.rotateAfterMiB must be a positive number`)}catch(t){if(t instanceof v&&t.message.startsWith(`Profile `))throw t;let n=t instanceof Error?t.message:String(t);throw new v(ie(t),`Profile ${e}: ${n}`,{cause:t})}}function yt(e){if(e.type===`host`||e.type===`decision`||e.type===`speech`||e.type===`transcription`||e.type===`embedding`)return;let{options:t,system:n}=e.identity,r=n??``;ye(r,`Profile ${e.id} identity.system`);let i=_e(r,t,e.inputs?.options);if(i)throw new v(`config`,`Profile ${e.id} identity.system: ${i}`)}function X(e){let t=bt(e),[n]=oe(e);if(n)throw new v(`config`,`Profile ${e.id}: ${n.path} ${n.message}`);return t}function bt(e){lt(e);for(let t of[`key`,`fallbackKey`,`protocol`,`provider`])if(t in e)throw new v(`config`,m(`provider.profile_configuration`,{profile:e.id,field:t}));pt(e),ft(e),dt(e),ut(e),e.labels&&me(e.labels,`Profile ${e.id}`);for(let t of se)if(e.labels?.[t]!==void 0)throw new v(`config`,`Profile ${e.id}: labels '${t}' is a host line, which a profile cannot change; set it with overrideLabels`);if(yt(e),vt(e),e.type===`host`)return it(e);if(e.type===`decision`)return nt(e);if(e.type===`embedding`)return Ze(e);if(e.type===`transcription`)return Qe(e);B(e.id,e.models),mt(e.id,e),q(e.id,e.guardrails),e.type===`text`&&ht(e.id,e.outputs?.validation),Y(e.id,e.observability);for(let[t,n]of Object.entries(e.models))H(e.id,t,n);let t=e.type===`speech`?{handle:e.identity.handle}:{handle:e.identity.handle,options:e.identity.options,system:e.identity.system},n=e.guardrails,r=e.observability,i=e.labels,a=W(e),o;switch(e.type){case`text`:o={type:`text`,id:e.id,identity:t,...a,tools:e.tools,inputs:e.inputs,outputs:e.outputs,turnBehaviour:e.turnBehaviour,guardrails:n,observability:r,labels:i};break;case`image`:o={type:`image`,id:e.id,identity:t,...a,image:e.image,tools:e.tools,inputs:e.inputs,outputs:e.outputs,turnBehaviour:e.turnBehaviour,guardrails:n,observability:r,labels:i},Et(o.id,o.inputs.attachments?.accept),Tt(o.id,o.image);break;case`speech`:o={type:`speech`,id:e.id,identity:t,...a,speech:e.speech,outputs:e.outputs,turnBehaviour:e.turnBehaviour,guardrails:n,observability:r,labels:i};break;case`live`:o={type:`live`,id:e.id,identity:t,...a,live:e.live,inputs:e.inputs,tools:{allow:e.tools.allow,...rt(e.tools.parallel)},turnBehaviour:e.turnBehaviour,guardrails:n,observability:r,labels:i},Se(o),Ot(o.id,o.live.contextCompression),Dt(o);break;default:throw new v(`config`,`Unknown profile type '${String(e)}'`)}return Ct(o),xt(o),St(o),o}function xt(e){let{maxSteps:t}=e;if(!(t===void 0||Number.isInteger(t)&&t>0))throw new v(`config`,`Profile ${e.id}: maxSteps must be a whole number of 1 or more; leave it out for the default of 20`)}function St(e){if(e.type===`text`&&e.turnBehaviour?.atStepLimit===`answer`&&e.maxSteps===1)throw new v(`config`,`Profile ${e.id}: turnBehaviour.atStepLimit 'answer' with maxSteps 1 leaves no step that can call a tool`)}function Ct(e){if(e.type===`live`)return;let t=e.outputs?.structured;if(!t||typeof t==`string`)return;let n=ve(e,t.by);if(!n)throw new v(`config`,`Profile ${e.id}: outputs.structured.by '${t.by}' is not one of the profile's options`);let r=ge(n),i=Object.keys(t.map).filter(e=>!r.includes(e));if(i.length)throw new v(`config`,`Profile ${e.id}: outputs.structured.map maps ${i.join(`, `)}, not a choice of option '${t.by}'`)}var wt={n:{ok:e=>Number.isInteger(e)&&e>=1,rule:`a whole number of 1 or more`},seed:{ok:Number.isInteger,rule:`a whole number`},outputCompression:{ok:e=>Number.isInteger(e)&&e>=0&&e<=100,rule:`a whole number from 0 to 100`}};function Tt(e,t){for(let[n,{ok:r,rule:i}]of Object.entries(wt)){let a=t[n];if(a!==void 0&&!r(a))throw new v(`config`,`Profile ${e}: image.${n} must be ${i}`)}t.references?.forEach((t,n)=>{let r=`Profile ${e}: image.references[${n}]`;if(le(t.mimeType)!==`image`)throw new v(`config`,`${r} must be an image, not '${t.mimeType}'`);if(!(x(t)?t.uri:t.data))throw new v(`config`,`${r} needs its bytes or its uri`)})}function Et(e,t){let n=t?.filter(e=>!g(u,e));if(n?.length)throw new v(`config`,`Profile ${e}: an image profile's attachments take images, video, and PDF only, not ${n.join(`, `)}`)}function Dt(e){let{greeting:t,resumed:n,sessionResumption:r}=e.live,i=`Profile ${e.id} live`;if(t!==void 0&&(typeof t!=`string`||!t.trim()))throw new v(`config`,`${i}.greeting must be a prompt; leave it out to wait`);if(!n)return;if(typeof n.prompt!=`string`||!n.prompt.trim())throw new v(`config`,`${i}.resumed.prompt must be a prompt`);let{afterMs:a}=n;if(a!==void 0&&!(Number.isFinite(a)&&a>=0))throw new v(`config`,`${i}.resumed.afterMs must be 0 or more milliseconds`);if(!r)throw new v(`config`,`${i}.resumed needs live.sessionResumption: without it no call resumes`)}function Ot(e,t){if(!t)return;let n=`Profile ${e} live.contextCompression`,r=t.triggerTokens,i=t.slidingWindow.targetTokens;if(Z(`${n}.triggerTokens`,r),Z(`${n}.slidingWindow.targetTokens`,i),r!==void 0&&i!==void 0&&i>=r)throw new v(`config`,`${n}: slidingWindow.targetTokens must be below triggerTokens`)}function Z(e,t){if(!(t===void 0||Number.isInteger(t)&&t>0))throw new v(`config`,`${e} must be a whole number above 0`)}function kt(e,t,n,r){let i=`Profile ${t.id} model ${n} compaction`;if(At(i,r),jt(i,r),r.profile===void 0){if(t.type!==`text`||t.inputs.text===!1)throw new v(`config`,`${i}: a profile that compacts itself must be a text profile that takes text`);return}let a=e.get(r.profile);if(!a)throw new v(`config`,`${i}: compaction profile '${r.profile}' must be registered before '${t.id}'`);if(a.type!==`text`||a.inputs.text===!1)throw new v(`config`,`${i}: compaction profile '${r.profile}' must be a text profile that takes text`)}function At(e,t){if(t.maxTokens<=0)throw new v(`config`,`${e}: maxTokens must be > 0`);if(t.compactAt<=0||t.compactAt>=1)throw new v(`config`,`${e}: compactAt must be in (0, 1)`)}function jt(e,t){if(t.previousExchanges<0)throw new v(`config`,`${e}: previousExchanges must be >= 0`);if(t.previousExchanges<1&&t.previousExchanges>=t.compactAt)throw new v(`config`,`${e}: previousExchanges as fraction (${t.previousExchanges}) must be < compactAt (${t.compactAt})`);if(t.previousExchanges>1&&!Number.isInteger(t.previousExchanges))throw new v(`config`,`${e}: previousExchanges >= 1 must be an integer`)}function Mt(e,t){for(let n of y(t))if(e.get(n)?.type===`builtin`)throw new v(`config`,t.type===`host`?`Profile ${t.id} lists builtin '${n}' in tools.allow — type 'host' never runs a model`:`Profile ${t.id} lists builtin '${n}' in tools.allow — declare it on models.*.builtInTools instead`)}function Nt(e,t){let n=be(t)?.t2Loader;if(n){if(!y(t).includes(n))throw new v(`config`,`Profile ${t.id} tools.t2Loader '${n}' must also be listed in tools.allow`);if(e.get(n)?.type!==`function`)throw new v(`config`,`Profile ${t.id} tools.t2Loader '${n}' must be a registered type: 'function' tool`)}}function*Pt(e){for(let[t,n]of Object.entries(e.models))for(let e of n.builtInTools??[])yield{modelId:t,id:e}}function Ft(e,t){for(let{modelId:n,id:r}of Pt(t))if(e.get(r)?.type!==`builtin`)throw new v(`config`,`Profile ${t.id} model '${n}' lists '${r}' in builtInTools — not a registered builtin`)}function Q(e){let t=e.type===`text`?e.outputs?.structured:void 0;return t?typeof t==`string`?[t]:[...new Set([...Object.values(t.map),t.fallback])]:[]}function It(e,t){return t?.type===`text`?Q(t).flatMap(t=>{let n=e.find(t);return n?[n.jsonSchema]:[]}):[]}function Lt(e,t){let n=Q(t).map(n=>{let r=e.find(n);if(!r)throw new v(`config`,`Profile ${t.id}: outputs.structured names '${n}', which is not a registered schema; register it before the profile`);return r}),r=t.type===`text`?t.outputs?.validation:void 0,i=Object.keys(r?.fields??{}),a=Object.keys(r?.items??{});if(!i.length&&!a.length)return;if(!n.length)throw new v(`config`,`Profile ${t.id}: outputs.validation checks a structured reply, so it needs outputs.structured`);let o=a.filter(e=>!n.some(t=>R(t.jsonSchema,e)));if(o.length)throw new v(`config`,`Profile ${t.id}: outputs.validation.items has ${o.join(`, `)}, which no structured schema reaches as a list with an items schema`);let s=i.filter(e=>!n.some(t=>qe(t.jsonSchema,e)));if(s.length)throw new v(`config`,`Profile ${t.id}: outputs.validation.fields has ${s.join(`, `)}, which no structured schema reaches through object properties`)}function Rt(e){let t=o(e)?.context;if(!t)return;let n=h;if(t.from.length===0||t.from.some(e=>!n.includes(e)))throw new v(`config`,`Profile ${e.id}: inputs.context.from must list ${h.join(` or `)}`);if(!(Number.isInteger(t.maxChars)&&t.maxChars>0))throw new v(`config`,`Profile ${e.id}: inputs.context.maxChars must be a positive integer`)}function zt(e,t){if(!t)return;let{attachments:n,voice:r,maxFiles:i,maxBytes:a,maxTurnBytes:o,limitsByMime:s}=t,c={maxFiles:i,maxBytes:a,maxTurnBytes:o};if((n||r)&&Object.values(c).some(e=>e===void 0))throw new v(`config`,`Profile ${e} must set maxFiles, maxBytes, and maxTurnBytes`);for(let[e,t]of Object.entries(s??{}))c[`limitsByMime['${e}']`]=t;for(let[t,n]of Object.entries(c))if(n!==void 0&&!(Number.isInteger(n)&&n>0))throw new v(`config`,`Profile ${e}: inputs.${t} must be a positive integer`)}function Bt(e,t,n){let r=new Map,i=i=>{let a=X(i),s=n&&a.type!==`host`?{...a,models:Object.fromEntries(Object.entries(a.models).map(([e,t])=>[e,te(n.require(t.provider,t.apiId),t,a.type)]))}:a;if(Mt(e,s),Nt(e,s),s.type!==`host`&&s.type!==`decision`&&s.type!==`embedding`){Ft(e,s),zt(s.id,o(s)),Rt(s),Lt(t,s);for(let[e,t]of Object.entries(s.models))t.compaction&&kt(r,s,e,t.compaction)}r.set(s.id,s)};return{register:i,registerMany(e){for(let t of e)i(t)},get(e){let t=r.get(e);if(!t)throw new v(`config`,`Unknown profile '${e}'`);return t},find:e=>r.get(e),has:e=>r.has(e),list:()=>[...r.values()],clear:()=>r.clear()}}function Vt(e){let t=e?.trim()??``;if(t.startsWith(`AIza`))return`gemini`;if(t.startsWith(`sk-or-`))return`openrouter`}function Ht(e){let t;try{t=new URL(e.baseUrl)}catch{throw new v(`config`,`Enter a valid localhost URL.`)}if(![`http:`,`https:`].includes(t.protocol)||![`localhost`,`127.0.0.1`,`[::1]`].includes(t.hostname)||t.username||t.password||t.search||t.hash)throw new v(`config`,`Use a localhost URL without credentials, query parameters or a fragment.`);return{baseUrl:t.href.replace(/\/$/,``),fetch:(e,n)=>new URL(e instanceof Request?e.url:String(e)).origin===t.origin?fetch(e,{...n,redirect:`error`,credentials:`omit`}):Promise.reject(new v(`blocked`,`Local requests must stay on the configured origin.`))}}var Ut=n({data:t(n({id:e().min(1)}))});async function Wt(e,t){let n=Ht(e);if(!n?.fetch)throw new v(`config`,`Enter a local endpoint.`);let r=await n.fetch(`${n.baseUrl}/v1/models`,{signal:t,headers:{Accept:`application/json`}});if(!r.ok)throw new v(`network`,`Local model list returned HTTP ${r.status}.`);let i=Ut.safeParse(await r.json());if(!i.success)throw new v(`request`,`The endpoint returned an invalid model list.`);return[...new Set(i.data.data.map(e=>e.id))]}var Gt=`https://openrouter.ai/api/v1/models`,Kt=`https://openrouter.ai/api/v1/embeddings/models`,qt=[{id:`gemini-embedding-2-preview`,label:`Gemini Embeddings 2 (preview)`},{id:`gemini-embedding-001`,label:`Gemini Embedding 001`}],Jt=[{id:`liquid/lfm-2.5-embedding-350m:free`,label:`Liquid LFM 2.5 Embedding 350M (free)`},{id:`nvidia/nemotron-3-embed-1b:free`,label:`NVIDIA Nemotron 3 Embed 1B (free)`},{id:`nvidia/llama-nemotron-embed-vl-1b-v2:free`,label:`NVIDIA Llama Nemotron Embed VL 1B v2 (free)`}],Yt={text:`text`,image:`image`,speech:`speech`,transcription:`transcription`,live:void 0,embedding:void 0},Xt=n({data:t(n({id:e().min(1),name:e().optional(),architecture:n({output_modalities:t(e()).optional()}).optional()}))}),Zt=n({data:t(n({id:e().min(1),name:e().optional()}))}),Qt=n({models:t(n({name:e().min(1),displayName:e().optional(),supportedGenerationMethods:t(e()).optional()})).optional(),nextPageToken:e().optional()}),$t=5;async function $(e,t,n){let r=await fetch(t,{...n,redirect:`error`,credentials:`omit`});if(r.status===400||r.status===401||r.status===403)throw new v(`auth`,`${e} refused the key.`);if(!r.ok)throw new v(`network`,`${e} model list returned HTTP ${r.status}.`);return await r.json()}async function en(e,t,n,r){let i=n?.trim();if(t===`embedding`&&!i)return[...e===`openrouter`?Jt:qt];if(e===`openrouter`)return await tn(t,i,r);if(!i)throw new v(`auth`,`Choose a key to list Gemini models.`);return await rn(t,i,r)}async function tn(e,t,n){let r={signal:n,headers:{Accept:`application/json`,...t?{Authorization:[`Bearer`,t].join(` `)}:{}}};if(e===`embedding`){let e=Zt.safeParse(await $(`OpenRouter`,Kt,r));if(!e.success)throw new v(`bad_response`,`OpenRouter returned an invalid embedding model list.`);return e.data.data.map(e=>({id:e.id,label:e.name??e.id}))}let i=Yt[e];if(!i)return[];let a=Xt.safeParse(await $(`OpenRouter`,`${Gt}?output_modalities=${i}`,r));if(!a.success)throw new v(`bad_response`,`OpenRouter returned an invalid model list.`);return a.data.data.filter(e=>e.architecture?.output_modalities?.includes(i)??!0).map(e=>({id:e.id,label:e.name??e.id}))}var nn={live:`bidiGenerateContent`,embedding:`embedContent`};async function rn(e,t,n){let i=nn[e]??`generateContent`,a=[],o;for(let e=0;e<$t;e++){let e=new URL(r);e.searchParams.set(`pageSize`,`1000`),o&&e.searchParams.set(`pageToken`,o);let s=Qt.safeParse(await $(`Google`,e.href,{signal:n,headers:{Accept:`application/json`,"x-goog-api-key":t}}));if(!s.success)throw new v(`bad_response`,`Google returned an invalid model list.`);for(let e of s.data.models??[]){if(!e.supportedGenerationMethods?.includes(i))continue;let t=e.name.replace(/^models\//,``);a.push({id:t,label:e.displayName??t})}if(o=s.data.nextPageToken,!o)break}return a}function an(e){return[...new Set([e.key,e.fallbackKey,...Object.values(e.models??{}).flatMap(e=>[e.keySlot,e.fallbackKeySlot])].filter(e=>!!e))]}function on(e,t){return Object.fromEntries(e.map(e=>[e,Object.hasOwn(t,e)?t[e]:void 0]))}export{He as C,b as S,ze as _,an as a,T as b,X as c,Ke as d,Je as f,O as g,L as h,Ht as i,It as l,I as m,Wt as n,on as o,R as p,en as r,Bt as s,Vt as t,Ye as u,Ie as v,x,w as y};