@theoremjs/studio 0.3.5-next.953.gf255d6a → 0.3.5-next.959.g351c307

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 (62) hide show
  1. package/package.json +4 -4
  2. package/page/assets/{BottomSheet-Dqu4JNyD.js → BottomSheet-DVdX9BBE.js} +1 -1
  3. package/page/assets/{ConsoleFrame-DPrqoO63.js → ConsoleFrame-THhhAEP5.js} +1 -1
  4. package/page/assets/{ContextMenu-CCkYC5oC.js → ContextMenu-Cboog74g.js} +2 -2
  5. package/page/assets/{DateInput-DwjJ32WU.js → DateInput-uC-fDXyG.js} +1 -1
  6. package/page/assets/{DropdownMenu-BRiIS7y5.js → DropdownMenu-C7h8h-0w.js} +2 -2
  7. package/page/assets/{Link-BJzFzYZZ.js → Link-kFun-IlM.js} +1 -1
  8. package/page/assets/{MenuBottomSheet-Cyn-X5mT.js → MenuBottomSheet-CwS_YI1q.js} +1 -1
  9. package/page/assets/{PowerSearchBottomSheet-D5BDnFGs.js → PowerSearchBottomSheet-zdGqCDgu.js} +1 -1
  10. package/page/assets/{RankedBars-BXzW5iyc.js → RankedBars-3xJdmdQX.js} +1 -1
  11. package/page/assets/{SchemaFields-ALf11yt1.js → SchemaFields-DmhGgfyh.js} +1 -1
  12. package/page/assets/{ShapedData-BrCc-5Nm.js → ShapedData-BTuvDXEZ.js} +1 -1
  13. package/page/assets/{TokenizerBottomSheet-_Po-O1nL.js → TokenizerBottomSheet-oXeJnDQc.js} +1 -1
  14. package/page/assets/{ToolResultCharts-B25Wz9N0.js → ToolResultCharts-gFpTjBvh.js} +1 -1
  15. package/page/assets/{Toolbar-BIbNDUSH.js → Toolbar-DCD06BBq.js} +1 -1
  16. package/page/assets/{TraceInspector-BmEdTqRp.js → TraceInspector-CizL3CHe.js} +2 -2
  17. package/page/assets/{TraceOverview-mRMoiRtX.js → TraceOverview-BZxHxBRZ.js} +1 -1
  18. package/page/assets/{_virtual_studio-type-sources-CUh9eCnG.js → _virtual_studio-type-sources-Dgfw_yrN.js} +51 -18
  19. package/page/assets/{browser-connection-CGupl9NP.js → browser-connection-B_d6mC7E.js} +1 -1
  20. package/page/assets/browser-engine-CcgdHuwJ.js +17 -0
  21. package/page/assets/browser-transport-BvCk51WP.js +2 -0
  22. package/page/assets/{compile-CFGS7Xyf.js → compile-B6NPCubN.js} +2 -2
  23. package/page/assets/{encode-files-D8MkiRgr.js → encode-files-DQhaOIhQ.js} +1 -1
  24. package/page/assets/{export-agent-BPjy13tY.js → export-agent-C6yZsFmc.js} +1 -1
  25. package/page/assets/{getRadiusAndStrokeWidthFromDot-DzvtGV5n.js → getRadiusAndStrokeWidthFromDot-DTs8vzee.js} +1 -1
  26. package/page/assets/{guardrail-health-BqzfgVwd.js → guardrail-health-Ba59KccZ.js} +1 -1
  27. package/page/assets/{guardrail-tester-BmMnSNZC.js → guardrail-tester-DeAOsVuR.js} +1 -1
  28. package/page/assets/{index-1UzYNcXu.js → index-BgC0zUqN.js} +9 -9
  29. package/page/assets/{json-code-DGEtlWGK.js → json-code-DxJPohHd.js} +1 -1
  30. package/page/assets/{labels-provider-3Sbk2Bjb.js → labels-provider-M5ttLlLm.js} +1 -1
  31. package/page/assets/{live-messages-CJ07JRrf.js → live-messages-Cggih6Yv.js} +1 -1
  32. package/page/assets/{prompt-row-bMhO_cjO.js → prompt-row-DJi0XgHd.js} +1 -1
  33. package/page/assets/reader-Vt-mQ6zw.js +5 -0
  34. package/page/assets/registry-C0KSfYFL.js +1 -0
  35. package/page/assets/schema-BbzFAyIO.js +3 -0
  36. package/page/assets/{shaped-data-CRpw7JlX.js → shaped-data-6dHnx8Ju.js} +9 -9
  37. package/page/assets/{stub-u1_pPFZW.js → stub-DyMgk61D.js} +1 -1
  38. package/page/assets/{studio-code-pane-9n_JT7Xe.js → studio-code-pane-CAIGE2-u.js} +3 -3
  39. package/page/assets/{studio-console-CVLcXMgl.js → studio-console-Dkaz4IQW.js} +1 -1
  40. package/page/assets/{studio-decision-BJbqzh-i.js → studio-decision-DV29rXST.js} +1 -1
  41. package/page/assets/{studio-embedding-C49c_URE.js → studio-embedding-BST4FYgn.js} +1 -1
  42. package/page/assets/{studio-host-console-CgZNhDaO.js → studio-host-console-DCf1JPzw.js} +2 -2
  43. package/page/assets/{studio-live-B6AxEhrA.js → studio-live-C-IPx4_8.js} +1 -1
  44. package/page/assets/{studio-map-BDxiF8IC.js → studio-map-uyRhvDzU.js} +1 -1
  45. package/page/assets/{studio-media-BbimKgrs.js → studio-media-9m4YcyAv.js} +1 -1
  46. package/page/assets/{studio-trace-replay-DOIf9BGF.js → studio-trace-replay-TGycm64u.js} +1 -1
  47. package/page/assets/{studio-type-checker-DuCCZTVo.js → studio-type-checker-BmGciI0m.js} +1 -1
  48. package/page/assets/{tool-schema-UsTCet4o.js → tool-schema-BxxcS67z.js} +1 -1
  49. package/page/assets/{trace-record-BhrZGQoo.js → trace-record-D7r7Ay3S.js} +1 -1
  50. package/page/assets/{tree-Db8E16o-.js → tree-8epO6zSL.js} +1 -1
  51. package/page/assets/{turn-client-DCxJT6xY.js → turn-client-BfTi2B2k.js} +1 -1
  52. package/page/assets/types-DVVKQvPj.js +1 -0
  53. package/page/assets/{use-one-call-CxoNRi9H.js → use-one-call-B9_erjJm.js} +1 -1
  54. package/page/assets/{useDismissSearchOnTouchDrag-B5-quEz5.js → useDismissSearchOnTouchDrag-DiK31rqG.js} +1 -1
  55. package/page/assets/{workspace-RYi4swYS.js → workspace-D027YlCa.js} +1 -1
  56. package/page/index.html +21 -21
  57. package/page/assets/browser-engine-BglZe00s.js +0 -16
  58. package/page/assets/browser-transport-BMKJqyTU.js +0 -2
  59. package/page/assets/reader-D3Gh1gq-.js +0 -5
  60. package/page/assets/registry-CoAjLZ3F.js +0 -1
  61. package/page/assets/schema-JVGuH9o3.js +0 -3
  62. package/page/assets/types-CPBggAgB.js +0 -1
@@ -7596,12 +7596,17 @@ export interface RefusedMedia {
7596
7596
  from: 'input' | 'history' | 'tool';
7597
7597
  }
7598
7598
  /**
7599
- * The turn went on without files the provider refused. Set only when the same call, sent
7600
- * without them, was accepted: that is the proof the files were at fault.
7599
+ * The turn went on without files: first those the profile does not take (its \`accept\` lists and
7600
+ * byte limits), left out before any call, then those the provider refused. A refused file is
7601
+ * listed only when the same call, sent without it, was accepted: that is the proof it was at fault.
7601
7602
  */
7602
7603
  export interface MediaRefused {
7603
7604
  dropped: RefusedMedia[];
7604
- /** The provider's own reason, for the builder only: \`forClient\` strips the whole report. */
7605
+ /**
7606
+ * Why, for the builder only: \`forClient\` strips the whole report. A line per file left out
7607
+ * names its type and each check it failed (\`image/gif: mime_not_allowed\`); then the provider's
7608
+ * own reason.
7609
+ */
7605
7610
  said: string;
7606
7611
  }
7607
7612
  export interface DoneBase {
@@ -8020,9 +8025,9 @@ export type ToolType = (typeof TOOL_TYPES)[number];
8020
8025
  /** A tool type the host defines, which is every type but \`builtin\`. */
8021
8026
  export type CustomToolType = Exclude<ToolType, 'builtin'>;
8022
8027
  /**
8023
- * The package's complete media-input vocabulary: \`assertMediaMime\` refuses any MIME not
8024
- * here, so hosts keep no second table. Rows follow the widest provider's documented
8025
- * lists (verified 2026-09-12), plus TypeScript, \`application/xml\` and \`application/rtf\`. Provider alias essences (\`image/jpg\`, \`video/mov\`, …) are rows;
8028
+ * The MIME types the kernel names: the widest provider's documented lists (verified
8029
+ * 2026-09-12) and their alias essences (\`image/jpg\`, \`video/mov\`, …). \`mediaKindForMime\`
8030
+ * reads a type's kind here first; a type not here takes its kind from its top-level type.
8026
8031
  * \`resolveInputParts\` canonicalizes \`image/jpg\` to \`image/jpeg\` on the wire.
8027
8032
  */
8028
8033
  export declare const MEDIA_INPUT_KINDS: Record<string, MediaInputKind>;
@@ -8643,7 +8648,7 @@ export { applySpans, blobAt, mergeSpans, OMIT_CANARY, OMIT_INJECTION, OMIT_PROMP
8643
8648
  `,"file:///node_modules/@theoremjs/agents/src/guardrails/labels.d.ts":`/** Values that fill a label template's \`{param}\` placeholders. */
8644
8649
  export type LabelParams = Record<string, string | number>;
8645
8650
  /** Keys are stable API. */
8646
- 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", "turn.media_refused_image", "turn.media_refused_video", "turn.media_refused_file", "turn.media_refused_tool", "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.cut_off_guidance", "repair.reply_cut_off", "repair.call_cut_off", "repair.call_cut_off_guidance", "repair.nothing_written", "repair.nothing_written_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.email", "detect.hint.phone", "detect.hint.bank_account", "detect.hint.injection", "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", "stop.answer_missing", "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_host_fields", "tool.hook_failed", "tool.input_invalid_after_mutate", "tool.output_invalid_after_mutate", "tool.handler_no_output", "tool.did_not_run", "tool.unreachable", "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.late_result", "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"];
8651
+ 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", "turn.media_refused_image", "turn.media_refused_video", "turn.media_refused_file", "turn.media_refused_tool", "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.cut_off_guidance", "repair.reply_cut_off", "repair.call_cut_off", "repair.call_cut_off_guidance", "repair.nothing_written", "repair.nothing_written_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.email", "detect.hint.phone", "detect.hint.bank_account", "detect.hint.injection", "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", "stop.answer_missing", "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_host_fields", "tool.hook_failed", "tool.input_invalid_after_mutate", "tool.output_invalid_after_mutate", "tool.handler_no_output", "tool.did_not_run", "tool.unreachable", "tool.page_no_answer", "tool.page_timed_out", "tool.output_invalid", "tool.not_loaded_t2", "tool.wait_unknown", "tool.after_unknown", "tool.wait_cycle", "tool.after_field", "tool.background_field", "tool.background_started", "tool.late_result", "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"];
8647
8652
  /** One of {@linkcode LABEL_KEYS}. */
8648
8653
  export type LabelKey = (typeof LABEL_KEYS)[number];
8649
8654
  /**
@@ -13856,7 +13861,10 @@ export interface AttachmentRules {
13856
13861
  voice?: string[];
13857
13862
  limits?: MediaLimits;
13858
13863
  }
13859
- /** The one attachment check: the kernel throws on it at ingress and the headless interface runs it before a send. */
13864
+ /**
13865
+ * The one attachment check. The headless interface runs it before a send; at ingress the kernel
13866
+ * runs it on each file, leaves out the files it names, and throws only on what names no file.
13867
+ */
13860
13868
  declare function attachmentIssues(rules: AttachmentRules, files: AttachmentFacts[], clips: AttachmentFacts[]): AttachmentValidationIssue[];
13861
13869
  /** The user-facing wording key and params for an attachment issue. */
13862
13870
  declare function attachmentIssueCopy(issue: AttachmentValidationIssue): ErrorCopy;
@@ -13866,29 +13874,48 @@ declare function attachmentIssueText(issue: AttachmentValidationIssue, labels?:
13866
13874
  declare function attachmentsRefused(issues: readonly AttachmentValidationIssue[]): TheoremError;
13867
13875
  /** The decoded size of inline base64 data; throws when it is not base64. */
13868
13876
  declare function base64Bytes(data: string): number;
13869
- /** Provider references are checked for MIME and count; byte limits apply to inline blobs only. */
13877
+ /** Throws on every issue the check finds: a host's own check before a send. */
13870
13878
  declare function assertTurnAttachments(profile: Profile, attachments: Array<TurnBlob | TurnMediaRef> | undefined, voice: TurnBlob[] | undefined): void;
13879
+ /** A file the turn goes without, and what the check found wrong with it. */
13880
+ interface LeftOutFile {
13881
+ mimeType: string;
13882
+ channel: 'attachment' | 'voice';
13883
+ issues: AttachmentValidationIssue[];
13884
+ }
13885
+ interface TurnFiles {
13886
+ attachments?: Array<TurnBlob | TurnMediaRef>;
13887
+ voice?: TurnBlob[];
13888
+ leftOut: LeftOutFile[];
13889
+ }
13890
+ /**
13891
+ * invariant: a file the profile does not take is left out and the turn goes on; what names no file
13892
+ * (too many files, too many bytes in all) refuses the turn, since no one file is at fault.
13893
+ * Provider references are checked for MIME and count; byte limits apply to inline blobs only.
13894
+ */
13895
+ declare function splitTurnAttachments(profile: Profile, attachments: Array<TurnBlob | TurnMediaRef> | undefined, voice: TurnBlob[] | undefined): TurnFiles;
13871
13896
  /** Provider file references pass through unsanitized: the kernel has no bytes to scan. */
13872
13897
  declare function sanitizeTurnBlobs(profile: Profile, attachments: Array<TurnBlob | TurnMediaRef> | undefined, voice: TurnBlob[] | undefined, at: {
13873
13898
  attachment: BoundaryReader;
13874
13899
  voice: BoundaryReader;
13875
- }): {
13876
- attachments?: Array<TurnBlob | TurnMediaRef>;
13877
- voice?: TurnBlob[];
13878
- };
13879
- export { assertTurnAttachments, attachmentIssueCopy, attachmentIssues, attachmentIssueText, attachmentsRefused, base64Bytes, isTextFile, isTextFileData, isTurnMediaRef, maxBytesForMime, modelTextFile, requireMediaLimits, resolveMediaLimits, rewriteTextFile, sanitizeCsvText, sanitizeTurnBlobs, textFileText, };
13900
+ }): TurnFiles;
13901
+ export type { LeftOutFile, TurnFiles };
13902
+ export { assertTurnAttachments, attachmentIssueCopy, attachmentIssues, attachmentIssueText, attachmentsRefused, base64Bytes, isTextFile, isTextFileData, isTurnMediaRef, maxBytesForMime, modelTextFile, requireMediaLimits, resolveMediaLimits, rewriteTextFile, sanitizeCsvText, sanitizeTurnBlobs, splitTurnAttachments, textFileText, };
13880
13903
  `,"file:///node_modules/@theoremjs/agents/src/kernel/registry/catalog.d.ts":`import type { MediaInputKind, ModelBinding, ModelId, ModelProfile, Profile, ProfileInputsSpec, ThinkingLevel } from '../types.js';
13881
13904
  import { mimeEssence } from '../util/mime.js';
13882
13905
  /** Where a media input arrives: as an attachment or as voice. */
13883
13906
  type MediaInputChannel = 'attachments' | 'voice';
13884
13907
  /** Rules support a subtype wildcard such as \`image/*\`; parameter values are ignored. */
13885
13908
  declare function mimeAllowed(accept: readonly string[], mime: string): boolean;
13886
- /** The kind of media a MIME type is, or \`undefined\` when it is not accepted. */
13909
+ /**
13910
+ * The kind of media a MIME type is: its own row in \`MEDIA_INPUT_KINDS\`, else its top-level type
13911
+ * (\`image\`, \`audio\`, \`video\`), else \`document\`. \`undefined\` only for a string that is not a MIME
13912
+ * type. invariant: the profile's \`accept\` lists decide which types a turn takes, not this.
13913
+ */
13887
13914
  declare function mediaKindForMime(mime: string): MediaInputKind | undefined;
13888
13915
  declare function profileInputs(profile: Profile): ProfileInputsSpec | undefined;
13889
13916
  declare function profileAccept(profile: Profile, channel: MediaInputChannel): string[] | undefined;
13890
13917
  /**
13891
- * \`undefined\` when the profile accepts it nowhere or the kernel cannot classify it. Hosts route
13918
+ * \`undefined\` when the profile accepts it nowhere or it is not a MIME type. Hosts route
13892
13919
  * files with this instead of their own MIME table: the profile's \`accept\` lists are the whole declaration.
13893
13920
  */
13894
13921
  declare function mediaChannelForMime(profile: Profile, mime: string): MediaInputChannel | undefined;
@@ -14160,7 +14187,8 @@ export declare function getProvider(id: string): RegisteredProvider | undefined;
14160
14187
  export declare function listProviders(): RegisteredProvider[];
14161
14188
  /** Every protocol the default scope's providers serve. */
14162
14189
  export declare function listProtocols(): Protocol[];
14163
- `,"file:///node_modules/@theoremjs/agents/src/guardrails/sanitize.d.ts":`import type { NormalizedTurnRequest, Profile, TurnContext, TurnEvent, TurnHistoryMessage, TurnRequest } from '../kernel/types.js';
14190
+ `,"file:///node_modules/@theoremjs/agents/src/guardrails/sanitize.d.ts":`import { type LeftOutFile } from '../kernel/registry/attachments.js';
14191
+ import type { NormalizedTurnRequest, Profile, TurnContext, TurnEvent, TurnHistoryMessage, TurnRequest } from '../kernel/types.js';
14164
14192
  import { type Boundary } from './boundaries.js';
14165
14193
  import { type BoundaryReader } from './detect-at.js';
14166
14194
  import { TheoremError } from './theorem-error.js';
@@ -14189,6 +14217,8 @@ interface SanitizedTurnRequest {
14189
14217
  events: TurnEvent[];
14190
14218
  /** Set when a match blocks: the request does not reach the model, and the turn ends on this. */
14191
14219
  refusal?: TheoremError;
14220
+ /** The files the profile does not take, left out of \`request\`; the turn goes on without them. */
14221
+ leftOut: LeftOutFile[];
14192
14222
  }
14193
14223
  /**
14194
14224
  * \`req.system\` is host-assembled per turn — it interpolates retrieval and user
@@ -14196,7 +14226,10 @@ interface SanitizedTurnRequest {
14196
14226
  * path and stays verbatim.
14197
14227
  */
14198
14228
  declare function sanitizeTurnRequestWithEvents(req: TurnRequest, profile: Profile): SanitizedTurnRequest;
14199
- /** The turn request with its input cleaned under the profile's guardrails. Throws when a match blocks it. */
14229
+ /**
14230
+ * The turn request with its input cleaned under the profile's guardrails. Throws when a match
14231
+ * blocks it, and when the profile does not take one of its files: nothing here goes on without it.
14232
+ */
14200
14233
  declare function sanitizeTurnRequest(req: TurnRequest, profile: Profile): NormalizedTurnRequest;
14201
14234
  export type { SanitizedTurnRequest };
14202
14235
  export { contextText, requestRefused, sanitizeContext, sanitizeHistory, sanitizeProjectId, sanitizeTurnRequest, sanitizeTurnRequestWithEvents, };
@@ -1 +1 @@
1
- import{E as e,d as t,x as n}from"./schemas-D7cgkv3L.js";import{J as r}from"./tool-schema-UsTCet4o.js";import{$t as i,Ba as a,Cn as o,Fi as s,Oi as c,Pi as l,Qt as u,Ti as ee,Wa as te,Xa as ne,Y as re,Zi as ie,ao as ae,ba as oe,bn as se,ea as ce,fa as d,lo as f,na as le,nn as ue,ta as p,uo as m,wi as h,xn as de,zi as g,zt as fe}from"./shaped-data-CRpw7JlX.js";import{c as _}from"./host-patterns-DzBJj2uE.js";import{A as pe,D as me,M as he,T as ge,U as _e,x as ve,y as v}from"./schema-JVGuH9o3.js";import{a as ye,n as be}from"./live-ingress-ZR7rtkDx.js";function y(e){let t=Object.keys(e);return t.length===1?t[0]:void 0}function b(e){return e==null}function x(e){return b(e)||typeof e!=`object`||Array.isArray(e)?null:e}function S(e){let t=x(e);return!t||t.type!==void 0&&t.type!==`object`?null:t}function C(e){let t=e.required;return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}function w(e){let t=e.properties;return x(t)??{}}function xe(e,t){return e?`${e}.${t}`:t}function T(e,t){t.push({path:e,error:`required field '${e}' is missing`})}async function E(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 D(e){let{path:t,propSchema:n,child:r,isRequired:i,fields:a,options:o,failures:s,crashes:c}=e;if(b(r)){i&&T(t,s);return}await E(t,r,a?.[t],o,s,c);let l=S(n),u=l?x(r):null;l&&u&&await O(l,u,t,a,o,s,c)}async function O(e,t,n,r,i,a,o){let s=w(e),c=new Set(C(e)),l=new Set([...Object.keys(s),...c]),u=x(t);for(let e of l)await D({path:xe(n,e),propSchema:s[e],child:u?.[e],isRequired:c.has(e),fields:r,options:i,failures:a,crashes:o})}async function k(e,t,n,r,i=[]){let a=S(e);if(!a)throw new _(`config`,`structured validation requires a JSON Schema object root`);let o=[];if(!x(t)){for(let e of C(a))T(e,o);return o}return await O(a,t,``,n,r,o,i),o}function A(e,t){let n=e;for(let e of t.split(`.`)){let t=S(n);if(!t)return!1;let r=w(t);if(!Object.hasOwn(r,e)&&!C(t).includes(e))return!1;n=r[e]}return!0}function j(e){return e.map(e=>e.error).join(`; `)}function M(e,t){let n=e;for(let e of t.split(`.`))n=x(n)?.[e];return n}function N(e,t,n){let[r,...i]=t.split(`.`),a=x(e)??{};return r===void 0?e:{...a,[r]:i.length?N(a[r],i.join(`.`),n):n}}async function Se(e,t,n,r=[]){let i=[];for(let[a,o]of Object.entries(t??{})){let t=M(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 P(e,t){let n=e;for(let e of t.split(`.`)){let t=S(n);if(!t)return;n=w(t)[e]}let r=x(n);if(r?.type===`array`)return x(r.items)??void 0}function Ce(e,t,n,r){if(!n.provider?.trim()||!n.apiId?.trim())throw new _(`config`,f(`provider.binding_identity`))}function we(e){L(e.id,e.models),K(e.id,e.observability),X(e.id,e.inputs);for(let[t,n]of Object.entries(e.models))z(e.id,t,n);return{type:`embedding`,id:e.id,identity:{handle:e.identity.handle},models:e.models,defaultModel:R(e.id,e),allowModelSelect:e.allowModelSelect,inputs:e.inputs,guardrails:e.guardrails,observability:e.observability,labels:e.labels}}function Te(e){L(e.id,e.models),W(e.id,e.guardrails),K(e.id,e.observability);for(let[t,n]of Object.entries(e.models))z(e.id,t,n);if(`text`in e.inputs&&e.inputs.text!==!1)throw new _(`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},...V(e),providerContinuation:void 0,maxSteps:void 0,inputs:{...e.inputs,text:!1},guardrails:e.guardrails,observability:e.observability,labels:e.labels}}function F(e,t,n,r){let i=r.safeParse(n);if(!i.success)throw new _(`config`,`Profile ${e} model '${t}': ${i.error.issues.map(e=>`${re(e.path)}: ${e.message}`).join(`; `)}`)}function Ee(e,t,n){if(F(e,t,n,i),Ce(e,t,n,`decision`),`retry`in n)throw new _(`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 _(`config`,`Profile ${e} model '${t}' timeoutMs must be > 0`)}function De(e){let t=e.models?y(e.models):void 0;if(!t)throw new _(`config`,`Profile ${e.id}: type 'decision' must declare exactly one model`);Ee(e.id,t,e.models[t])}function Oe(e){if(e.inputs.state!==`json`)throw new _(`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 _(`config`,`Profile ${e.id}: decision inputs.maxStateBytes must be a positive integer`);if(!e.decision.contract.trim())throw new _(`config`,`Profile ${e.id}: decision.contract must be non-empty`)}function ke(e){return De(e),Oe(e),K(e.id,e.observability),{...e,identity:{handle:e.identity.handle}}}function I(e){return e===void 0?{}:{parallel:e}}function Ae(e){return je(e.id,e.tools),K(e.id,e.observability),{type:`host`,id:e.id,tools:{allow:e.tools.allow,...I(e.tools.parallel)},guardrails:e.guardrails,observability:e.observability,labels:e.labels}}function je(e,t){if(!Array.isArray(t.allow))throw new _(`config`,`Profile ${e}: type 'host' must set tools.allow`)}function L(e,t){if(Object.keys(t).length===0)throw new _(`config`,`Profile ${e} must declare at least one model`)}function R(e,t){let n=t.defaultModel??y(t.models);if(!n)throw new _(`config`,`Profile ${e} must set defaultModel when more than one model is declared`);if(!t.models[n])throw new _(`config`,`Profile ${e} defaultModel '${n}' is not declared`);return n}function z(e,t,n){B(e,t,n),F(e,t,n,ue),B(e,t,n)}function B(e,t,n){let r=n.efforts;if(!r||Object.keys(r).length===0){if(n.defaultEffort||n.allowEffortSelect)throw new _(`config`,`Profile ${e} model '${t}': defaultEffort and allowEffortSelect require efforts`);return}for(let[n,i]of Object.entries(r))if(!g.includes(i))throw new _(`config`,`Profile ${e} model '${t}' effort '${n}': '${i}' is not a thinking level (${g.join(`, `)})`);let i=Object.keys(r),a=n.defaultEffort??(i.length===1?i[0]:void 0);if(!a)throw new _(`config`,`Profile ${e} model '${t}' must set defaultEffort when more than one effort is declared`);if(!r[a])throw new _(`config`,`Profile ${e} model '${t}' defaultEffort '${a}' is not declared`);if(n.allowEffortSelect&&i.length<2)throw new _(`config`,`Profile ${e} model '${t}' allowEffortSelect requires at least two efforts`)}function V(e){return{providerContinuation:e.providerContinuation?oe.parse(e.providerContinuation):{},models:e.models,defaultModel:R(e.id,e),allowModelSelect:e.allowModelSelect,maxSteps:e.maxSteps}}function H(e,t,n){if(n?.length){for(let r of n)if(!fe(r))throw new _(`config`,`Profile ${e}: turnBehaviour.resumption.${t} may only include ContinueStopKind (${ee.join(` | `)}); got '${r}'`)}}function Me(e,t){t&&(H(e,`allowContinue`,t.allowContinue),H(e,`autoContinue`,t.autoContinue))}function U(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ne(e,t){let n=[e];for(let e of t)n=n.flatMap(t=>U(t)?e===`*`?Object.values(t):[t[e]]:[]);return n}var Pe=Object.entries(l).filter(([,e])=>e.required===!0).map(([e,t])=>[e,t.profileTypes]).sort(([e],[t])=>e.split(`.`).length-t.split(`.`).length);function Fe(e){if(!U(e))throw new _(`config`,`Profile definition must be an object`);let t=typeof e.id==`string`&&e.id.trim()?e.id:void 0;if(!t)throw new _(`config`,`Profile definition must set id`);if(!s.find(t=>t===e.type))throw new _(`config`,`Profile ${t}: type must be one of ${s.join(`, `)}`)}function Ie(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 _(`config`,`Profile ${e.id.slice(0,64)}: ${t} must be at most ${i} characters`)}function Le(e){let{id:t,type:n}=e,r=e;for(let[e,i]of Pe){if(i&&!i.includes(n))continue;let a=p(e),o=Ne(r,a.slice(0,-1)),s=a[a.length-1];if(o.some(e=>{if(!U(e))return!1;let t=e[s];return t==null||t===``}))throw new _(`config`,`Profile ${t}: type '${n}' must set ${a.join(`.`)}`)}}function Re(e){let{id:t,type:n}=e;if(n!==`live`&&le(`inputs`).includes(n)&&e.inputs==null)throw new _(`config`,`Profile ${t}: type '${n}' must set inputs`)}function ze(e){let[t]=ce(e);if(!t)return;let{offValue:n,reason:r}=t.scope,i=n===void 0?``:` (other than ${n})`;throw new _(`config`,`Profile ${e.id}: type '${e.type}' must not set ${t.path}${i} — ${r}`)}function Be(e,t){let n=t.turnBehaviour;Me(e,n?.resumption)}function Ve(e,t){let n=t=>new _(`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 W(e,t){let n=t=>new _(`config`,`Profile ${e}: ${t}`),r=Object.keys(t??{}).find(e=>!G.includes(e));if(r!==void 0)throw n(`guardrails.${r} is not a setting; it takes ${G.join(`, `)}`);Ue(t?.blockedReply,n)}var G=[`quota`,`detect`,`blockedReply`,`network`,`taint`],He=[`onBlock`,`maxRetries`];function Ue(e,t){if(e===void 0)return;let n=Object.keys(e).find(e=>!He.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 We(e){let t=e.guardrails?.detect,n=e.type===`host`?d(`guardrails.detect`,t,te):d(`guardrails.detect`,t);if(n!==void 0)throw new _(`config`,`Profile ${e.id}: ${n}`)}function K(e,t){try{let n=ye(t);if(!Number.isFinite(n.retainForDays))throw new _(`config`,`Profile ${e}: observability.retainForDays must be a finite number`);if(n.rotateAfterMiB<=0||!Number.isFinite(n.rotateAfterMiB))throw new _(`config`,`Profile ${e}: observability.rotateAfterMiB must be a positive number`)}catch(t){if(t instanceof _&&t.message.startsWith(`Profile `))throw t;let n=t instanceof Error?t.message:String(t);throw new _(ne(t),`Profile ${e}: ${n}`,{cause:t})}}function Ge(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??``;ge(r,`Profile ${e.id} identity.system`);let i=me(r,t,e.inputs?.options);if(i)throw new _(`config`,`Profile ${e.id} identity.system: ${i}`)}function q(e){let t=Ke(e),[n]=ie(e);if(n)throw new _(`config`,`Profile ${e.id}: ${n.path} ${n.message}`);return t}function Ke(e){Fe(e);for(let t of[`key`,`fallbackKey`,`protocol`,`provider`])if(t in e)throw new _(`config`,f(`provider.profile_configuration`,{profile:e.id,field:t}));ze(e),Re(e),Le(e),Ie(e),e.labels&&m(e.labels,`Profile ${e.id}`);for(let t of ae)if(e.labels?.[t]!==void 0)throw new _(`config`,`Profile ${e.id}: labels '${t}' is a host line, which a profile cannot change; set it with overrideLabels`);if(Ge(e),We(e),e.type===`host`)return Ae(e);if(e.type===`decision`)return ke(e);if(e.type===`embedding`)return we(e);if(e.type===`transcription`)return Te(e);L(e.id,e.models),Be(e.id,e),W(e.id,e.guardrails),e.type===`text`&&Ve(e.id,e.outputs?.validation),K(e.id,e.observability);for(let[t,n]of Object.entries(e.models))z(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=V(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},Qe(o.id,o.inputs.attachments?.accept),Ze(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,...I(e.tools.parallel)},turnBehaviour:e.turnBehaviour,guardrails:n,observability:r,labels:i},be(o),et(o.id,o.live.contextCompression),$e(o);break;default:throw new _(`config`,`Unknown profile type '${String(e)}'`)}return Ye(o),qe(o),Je(o),o}function qe(e){let{maxSteps:t}=e;if(!(t===void 0||Number.isInteger(t)&&t>0))throw new _(`config`,`Profile ${e.id}: maxSteps must be a whole number of 1 or more; leave it out for the default of 20`)}function Je(e){if(e.type===`text`&&e.turnBehaviour?.atStepLimit===`answer`&&e.maxSteps===1)throw new _(`config`,`Profile ${e.id}: turnBehaviour.atStepLimit 'answer' with maxSteps 1 leaves no step that can call a tool`)}function Ye(e){if(e.type===`live`)return;let t=e.outputs?.structured;if(!t||typeof t==`string`)return;let n=he(e,t.by);if(!n)throw new _(`config`,`Profile ${e.id}: outputs.structured.by '${t.by}' is not one of the profile's options`);let r=pe(n),i=Object.keys(t.map).filter(e=>!r.includes(e));if(i.length)throw new _(`config`,`Profile ${e.id}: outputs.structured.map maps ${i.join(`, `)}, not a choice of option '${t.by}'`)}var Xe={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 Ze(e,t){for(let[n,{ok:r,rule:i}]of Object.entries(Xe)){let a=t[n];if(a!==void 0&&!r(a))throw new _(`config`,`Profile ${e}: image.${n} must be ${i}`)}t.references?.forEach((t,n)=>{let r=`Profile ${e}: image.references[${n}]`;if(se(t.mimeType)!==`image`)throw new _(`config`,`${r} must be an image, not '${t.mimeType}'`);if(!(_e(t)?t.uri:t.data))throw new _(`config`,`${r} needs its bytes or its uri`)})}function Qe(e,t){let n=t?.filter(e=>!de(c,e));if(n?.length)throw new _(`config`,`Profile ${e}: an image profile's attachments take images, video, and PDF only, not ${n.join(`, `)}`)}function $e(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 _(`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 _(`config`,`${i}.resumed.prompt must be a prompt`);let{afterMs:a}=n;if(a!==void 0&&!(Number.isFinite(a)&&a>=0))throw new _(`config`,`${i}.resumed.afterMs must be 0 or more milliseconds`);if(!r)throw new _(`config`,`${i}.resumed needs live.sessionResumption: without it no call resumes`)}function et(e,t){if(!t)return;let n=`Profile ${e} live.contextCompression`,r=t.triggerTokens,i=t.slidingWindow.targetTokens;if(J(`${n}.triggerTokens`,r),J(`${n}.slidingWindow.targetTokens`,i),r!==void 0&&i!==void 0&&i>=r)throw new _(`config`,`${n}: slidingWindow.targetTokens must be below triggerTokens`)}function J(e,t){if(!(t===void 0||Number.isInteger(t)&&t>0))throw new _(`config`,`${e} must be a whole number above 0`)}function tt(e,t,n,r){let i=`Profile ${t.id} model ${n} compaction`;if(nt(i,r),rt(i,r),r.profile===void 0){if(t.type!==`text`||t.inputs.text===!1)throw new _(`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 _(`config`,`${i}: compaction profile '${r.profile}' must be registered before '${t.id}'`);if(a.type!==`text`||a.inputs.text===!1)throw new _(`config`,`${i}: compaction profile '${r.profile}' must be a text profile that takes text`)}function nt(e,t){if(t.maxTokens<=0)throw new _(`config`,`${e}: maxTokens must be > 0`);if(t.compactAt<=0||t.compactAt>=1)throw new _(`config`,`${e}: compactAt must be in (0, 1)`)}function rt(e,t){if(t.previousExchanges<0)throw new _(`config`,`${e}: previousExchanges must be >= 0`);if(t.previousExchanges<1&&t.previousExchanges>=t.compactAt)throw new _(`config`,`${e}: previousExchanges as fraction (${t.previousExchanges}) must be < compactAt (${t.compactAt})`);if(t.previousExchanges>1&&!Number.isInteger(t.previousExchanges))throw new _(`config`,`${e}: previousExchanges >= 1 must be an integer`)}function it(e,t){for(let n of v(t))if(e.get(n)?.type===`builtin`)throw new _(`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 at(e,t){let n=ve(t)?.t2Loader;if(n){if(!v(t).includes(n))throw new _(`config`,`Profile ${t.id} tools.t2Loader '${n}' must also be listed in tools.allow`);if(e.get(n)?.type!==`function`)throw new _(`config`,`Profile ${t.id} tools.t2Loader '${n}' must be a registered type: 'function' tool`)}}function*ot(e){for(let[t,n]of Object.entries(e.models))for(let e of n.builtInTools??[])yield{modelId:t,id:e}}function st(e,t){for(let{modelId:n,id:r}of ot(t))if(e.get(r)?.type!==`builtin`)throw new _(`config`,`Profile ${t.id} model '${n}' lists '${r}' in builtInTools — not a registered builtin`)}function Y(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 ct(e,t){return t?.type===`text`?Y(t).flatMap(t=>{let n=e.find(t);return n?[n.jsonSchema]:[]}):[]}function lt(e,t){let n=Y(t).map(n=>{let r=e.find(n);if(!r)throw new _(`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 _(`config`,`Profile ${t.id}: outputs.validation checks a structured reply, so it needs outputs.structured`);let o=a.filter(e=>!n.some(t=>P(t.jsonSchema,e)));if(o.length)throw new _(`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=>A(t.jsonSchema,e)));if(s.length)throw new _(`config`,`Profile ${t.id}: outputs.validation.fields has ${s.join(`, `)}, which no structured schema reaches through object properties`)}function ut(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 _(`config`,`Profile ${e.id}: inputs.context.from must list ${h.join(` or `)}`);if(!(Number.isInteger(t.maxChars)&&t.maxChars>0))throw new _(`config`,`Profile ${e.id}: inputs.context.maxChars must be a positive integer`)}function X(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 _(`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 _(`config`,`Profile ${e}: inputs.${t} must be a positive integer`)}function dt(e,t,n){let r=new Map,i=i=>{let a=q(i),s=n&&a.type!==`host`?{...a,models:Object.fromEntries(Object.entries(a.models).map(([e,t])=>[e,u(n.require(t.provider,t.apiId),t,a.type)]))}:a;if(it(e,s),at(e,s),s.type!==`host`&&s.type!==`decision`&&s.type!==`embedding`){st(e,s),X(s.id,o(s)),ut(s),lt(t,s);for(let[e,t]of Object.entries(s.models))t.compaction&&tt(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 _(`config`,`Unknown profile '${e}'`);return t},find:e=>r.get(e),has:e=>r.has(e),list:()=>[...r.values()],clear:()=>r.clear()}}function ft(e){let t=e?.trim()??``;if(t.startsWith(`AIza`))return`gemini`;if(t.startsWith(`sk-or-`))return`openrouter`}function Z(e){let t;try{t=new URL(e.baseUrl)}catch{throw new _(`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 _(`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 _(`blocked`,`Local requests must stay on the configured origin.`))}}var pt=n({data:t(n({id:e().min(1)}))});async function mt(e,t){let n=Z(e);if(!n?.fetch)throw new _(`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 _(`network`,`Local model list returned HTTP ${r.status}.`);let i=pt.safeParse(await r.json());if(!i.success)throw new _(`request`,`The endpoint returned an invalid model list.`);return[...new Set(i.data.data.map(e=>e.id))]}var ht=`https://openrouter.ai/api/v1/models`,gt=`https://openrouter.ai/api/v1/embeddings/models`,_t=[{id:`gemini-embedding-2-preview`,label:`Gemini Embeddings 2 (preview)`},{id:`gemini-embedding-001`,label:`Gemini Embedding 001`}],vt=[{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},bt=n({data:t(n({id:e().min(1),name:e().optional(),architecture:n({output_modalities:t(e()).optional()}).optional()}))}),Q=n({data:t(n({id:e().min(1),name:e().optional()}))}),xt=n({models:t(n({name:e().min(1),displayName:e().optional(),supportedGenerationMethods:t(e()).optional()})).optional(),nextPageToken:e().optional()}),St=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 _(`auth`,`${e} refused the key.`);if(!r.ok)throw new _(`network`,`${e} model list returned HTTP ${r.status}.`);return await r.json()}async function Ct(e,t,n,r){let i=n?.trim();if(t===`embedding`&&!i)return[...e===`openrouter`?vt:_t];if(e===`openrouter`)return await wt(t,i,r);if(!i)throw new _(`auth`,`Choose a key to list Gemini models.`);return await Et(t,i,r)}async function wt(e,t,n){let r={signal:n,headers:{Accept:`application/json`,...t?{Authorization:[`Bearer`,t].join(` `)}:{}}};if(e===`embedding`){let e=Q.safeParse(await $(`OpenRouter`,gt,r));if(!e.success)throw new _(`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=bt.safeParse(await $(`OpenRouter`,`${ht}?output_modalities=${i}`,r));if(!a.success)throw new _(`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 Tt={live:`bidiGenerateContent`,embedding:`embedContent`};async function Et(e,t,n){let i=Tt[e]??`generateContent`,a=[],o;for(let e=0;e<St;e++){let e=new URL(r);e.searchParams.set(`pageSize`,`1000`),o&&e.searchParams.set(`pageToken`,o);let s=xt.safeParse(await $(`Google`,e.href,{signal:n,headers:{Accept:`application/json`,"x-goog-api-key":t}}));if(!s.success)throw new _(`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 Dt(e){return[...new Set([e.key,e.fallbackKey,...Object.values(e.models??{}).flatMap(e=>[e.keySlot,e.fallbackKeySlot])].filter(e=>!!e))]}function Ot(e,t){return Object.fromEntries(e.map(e=>[e,Object.hasOwn(t,e)?t[e]:void 0]))}export{Dt as a,q as c,k as d,j as f,y as g,N as h,Z as i,ct as l,M as m,mt as n,Ot as o,P as p,Ct as r,dt as s,ft as t,Se as u};
1
+ import{E as e,d as t,x as n}from"./schemas-D7cgkv3L.js";import{J as r}from"./tool-schema-BxxcS67z.js";import{$t as i,Ba as a,Cn as o,Fi as s,Oi as c,Pi as l,Qt as u,Ti as ee,Wa as te,Xa as ne,Y as re,Zi as ie,ao as ae,ba as oe,bn as se,ea as ce,fa as d,lo as f,na as le,nn as ue,ta as p,uo as m,wi as h,xn as de,zi as g,zt as fe}from"./shaped-data-6dHnx8Ju.js";import{c as _}from"./host-patterns-DzBJj2uE.js";import{E as pe,G as me,N as he,O as ge,S as _e,b as v,j as ve}from"./schema-BbzFAyIO.js";import{a as ye,n as be}from"./live-ingress-ZR7rtkDx.js";function y(e){let t=Object.keys(e);return t.length===1?t[0]:void 0}function b(e){return e==null}function x(e){return b(e)||typeof e!=`object`||Array.isArray(e)?null:e}function S(e){let t=x(e);return!t||t.type!==void 0&&t.type!==`object`?null:t}function C(e){let t=e.required;return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}function w(e){let t=e.properties;return x(t)??{}}function xe(e,t){return e?`${e}.${t}`:t}function T(e,t){t.push({path:e,error:`required field '${e}' is missing`})}async function E(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 D(e){let{path:t,propSchema:n,child:r,isRequired:i,fields:a,options:o,failures:s,crashes:c}=e;if(b(r)){i&&T(t,s);return}await E(t,r,a?.[t],o,s,c);let l=S(n),u=l?x(r):null;l&&u&&await O(l,u,t,a,o,s,c)}async function O(e,t,n,r,i,a,o){let s=w(e),c=new Set(C(e)),l=new Set([...Object.keys(s),...c]),u=x(t);for(let e of l)await D({path:xe(n,e),propSchema:s[e],child:u?.[e],isRequired:c.has(e),fields:r,options:i,failures:a,crashes:o})}async function k(e,t,n,r,i=[]){let a=S(e);if(!a)throw new _(`config`,`structured validation requires a JSON Schema object root`);let o=[];if(!x(t)){for(let e of C(a))T(e,o);return o}return await O(a,t,``,n,r,o,i),o}function A(e,t){let n=e;for(let e of t.split(`.`)){let t=S(n);if(!t)return!1;let r=w(t);if(!Object.hasOwn(r,e)&&!C(t).includes(e))return!1;n=r[e]}return!0}function j(e){return e.map(e=>e.error).join(`; `)}function M(e,t){let n=e;for(let e of t.split(`.`))n=x(n)?.[e];return n}function N(e,t,n){let[r,...i]=t.split(`.`),a=x(e)??{};return r===void 0?e:{...a,[r]:i.length?N(a[r],i.join(`.`),n):n}}async function Se(e,t,n,r=[]){let i=[];for(let[a,o]of Object.entries(t??{})){let t=M(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 P(e,t){let n=e;for(let e of t.split(`.`)){let t=S(n);if(!t)return;n=w(t)[e]}let r=x(n);if(r?.type===`array`)return x(r.items)??void 0}function Ce(e,t,n,r){if(!n.provider?.trim()||!n.apiId?.trim())throw new _(`config`,f(`provider.binding_identity`))}function we(e){L(e.id,e.models),K(e.id,e.observability),X(e.id,e.inputs);for(let[t,n]of Object.entries(e.models))z(e.id,t,n);return{type:`embedding`,id:e.id,identity:{handle:e.identity.handle},models:e.models,defaultModel:R(e.id,e),allowModelSelect:e.allowModelSelect,inputs:e.inputs,guardrails:e.guardrails,observability:e.observability,labels:e.labels}}function Te(e){L(e.id,e.models),W(e.id,e.guardrails),K(e.id,e.observability);for(let[t,n]of Object.entries(e.models))z(e.id,t,n);if(`text`in e.inputs&&e.inputs.text!==!1)throw new _(`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},...V(e),providerContinuation:void 0,maxSteps:void 0,inputs:{...e.inputs,text:!1},guardrails:e.guardrails,observability:e.observability,labels:e.labels}}function F(e,t,n,r){let i=r.safeParse(n);if(!i.success)throw new _(`config`,`Profile ${e} model '${t}': ${i.error.issues.map(e=>`${re(e.path)}: ${e.message}`).join(`; `)}`)}function Ee(e,t,n){if(F(e,t,n,i),Ce(e,t,n,`decision`),`retry`in n)throw new _(`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 _(`config`,`Profile ${e} model '${t}' timeoutMs must be > 0`)}function De(e){let t=e.models?y(e.models):void 0;if(!t)throw new _(`config`,`Profile ${e.id}: type 'decision' must declare exactly one model`);Ee(e.id,t,e.models[t])}function Oe(e){if(e.inputs.state!==`json`)throw new _(`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 _(`config`,`Profile ${e.id}: decision inputs.maxStateBytes must be a positive integer`);if(!e.decision.contract.trim())throw new _(`config`,`Profile ${e.id}: decision.contract must be non-empty`)}function ke(e){return De(e),Oe(e),K(e.id,e.observability),{...e,identity:{handle:e.identity.handle}}}function I(e){return e===void 0?{}:{parallel:e}}function Ae(e){return je(e.id,e.tools),K(e.id,e.observability),{type:`host`,id:e.id,tools:{allow:e.tools.allow,...I(e.tools.parallel)},guardrails:e.guardrails,observability:e.observability,labels:e.labels}}function je(e,t){if(!Array.isArray(t.allow))throw new _(`config`,`Profile ${e}: type 'host' must set tools.allow`)}function L(e,t){if(Object.keys(t).length===0)throw new _(`config`,`Profile ${e} must declare at least one model`)}function R(e,t){let n=t.defaultModel??y(t.models);if(!n)throw new _(`config`,`Profile ${e} must set defaultModel when more than one model is declared`);if(!t.models[n])throw new _(`config`,`Profile ${e} defaultModel '${n}' is not declared`);return n}function z(e,t,n){B(e,t,n),F(e,t,n,ue),B(e,t,n)}function B(e,t,n){let r=n.efforts;if(!r||Object.keys(r).length===0){if(n.defaultEffort||n.allowEffortSelect)throw new _(`config`,`Profile ${e} model '${t}': defaultEffort and allowEffortSelect require efforts`);return}for(let[n,i]of Object.entries(r))if(!g.includes(i))throw new _(`config`,`Profile ${e} model '${t}' effort '${n}': '${i}' is not a thinking level (${g.join(`, `)})`);let i=Object.keys(r),a=n.defaultEffort??(i.length===1?i[0]:void 0);if(!a)throw new _(`config`,`Profile ${e} model '${t}' must set defaultEffort when more than one effort is declared`);if(!r[a])throw new _(`config`,`Profile ${e} model '${t}' defaultEffort '${a}' is not declared`);if(n.allowEffortSelect&&i.length<2)throw new _(`config`,`Profile ${e} model '${t}' allowEffortSelect requires at least two efforts`)}function V(e){return{providerContinuation:e.providerContinuation?oe.parse(e.providerContinuation):{},models:e.models,defaultModel:R(e.id,e),allowModelSelect:e.allowModelSelect,maxSteps:e.maxSteps}}function H(e,t,n){if(n?.length){for(let r of n)if(!fe(r))throw new _(`config`,`Profile ${e}: turnBehaviour.resumption.${t} may only include ContinueStopKind (${ee.join(` | `)}); got '${r}'`)}}function Me(e,t){t&&(H(e,`allowContinue`,t.allowContinue),H(e,`autoContinue`,t.autoContinue))}function U(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ne(e,t){let n=[e];for(let e of t)n=n.flatMap(t=>U(t)?e===`*`?Object.values(t):[t[e]]:[]);return n}var Pe=Object.entries(l).filter(([,e])=>e.required===!0).map(([e,t])=>[e,t.profileTypes]).sort(([e],[t])=>e.split(`.`).length-t.split(`.`).length);function Fe(e){if(!U(e))throw new _(`config`,`Profile definition must be an object`);let t=typeof e.id==`string`&&e.id.trim()?e.id:void 0;if(!t)throw new _(`config`,`Profile definition must set id`);if(!s.find(t=>t===e.type))throw new _(`config`,`Profile ${t}: type must be one of ${s.join(`, `)}`)}function Ie(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 _(`config`,`Profile ${e.id.slice(0,64)}: ${t} must be at most ${i} characters`)}function Le(e){let{id:t,type:n}=e,r=e;for(let[e,i]of Pe){if(i&&!i.includes(n))continue;let a=p(e),o=Ne(r,a.slice(0,-1)),s=a[a.length-1];if(o.some(e=>{if(!U(e))return!1;let t=e[s];return t==null||t===``}))throw new _(`config`,`Profile ${t}: type '${n}' must set ${a.join(`.`)}`)}}function Re(e){let{id:t,type:n}=e;if(n!==`live`&&le(`inputs`).includes(n)&&e.inputs==null)throw new _(`config`,`Profile ${t}: type '${n}' must set inputs`)}function ze(e){let[t]=ce(e);if(!t)return;let{offValue:n,reason:r}=t.scope,i=n===void 0?``:` (other than ${n})`;throw new _(`config`,`Profile ${e.id}: type '${e.type}' must not set ${t.path}${i} — ${r}`)}function Be(e,t){let n=t.turnBehaviour;Me(e,n?.resumption)}function Ve(e,t){let n=t=>new _(`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 W(e,t){let n=t=>new _(`config`,`Profile ${e}: ${t}`),r=Object.keys(t??{}).find(e=>!G.includes(e));if(r!==void 0)throw n(`guardrails.${r} is not a setting; it takes ${G.join(`, `)}`);Ue(t?.blockedReply,n)}var G=[`quota`,`detect`,`blockedReply`,`network`,`taint`],He=[`onBlock`,`maxRetries`];function Ue(e,t){if(e===void 0)return;let n=Object.keys(e).find(e=>!He.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 We(e){let t=e.guardrails?.detect,n=e.type===`host`?d(`guardrails.detect`,t,te):d(`guardrails.detect`,t);if(n!==void 0)throw new _(`config`,`Profile ${e.id}: ${n}`)}function K(e,t){try{let n=ye(t);if(!Number.isFinite(n.retainForDays))throw new _(`config`,`Profile ${e}: observability.retainForDays must be a finite number`);if(n.rotateAfterMiB<=0||!Number.isFinite(n.rotateAfterMiB))throw new _(`config`,`Profile ${e}: observability.rotateAfterMiB must be a positive number`)}catch(t){if(t instanceof _&&t.message.startsWith(`Profile `))throw t;let n=t instanceof Error?t.message:String(t);throw new _(ne(t),`Profile ${e}: ${n}`,{cause:t})}}function Ge(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??``;pe(r,`Profile ${e.id} identity.system`);let i=ge(r,t,e.inputs?.options);if(i)throw new _(`config`,`Profile ${e.id} identity.system: ${i}`)}function q(e){let t=Ke(e),[n]=ie(e);if(n)throw new _(`config`,`Profile ${e.id}: ${n.path} ${n.message}`);return t}function Ke(e){Fe(e);for(let t of[`key`,`fallbackKey`,`protocol`,`provider`])if(t in e)throw new _(`config`,f(`provider.profile_configuration`,{profile:e.id,field:t}));ze(e),Re(e),Le(e),Ie(e),e.labels&&m(e.labels,`Profile ${e.id}`);for(let t of ae)if(e.labels?.[t]!==void 0)throw new _(`config`,`Profile ${e.id}: labels '${t}' is a host line, which a profile cannot change; set it with overrideLabels`);if(Ge(e),We(e),e.type===`host`)return Ae(e);if(e.type===`decision`)return ke(e);if(e.type===`embedding`)return we(e);if(e.type===`transcription`)return Te(e);L(e.id,e.models),Be(e.id,e),W(e.id,e.guardrails),e.type===`text`&&Ve(e.id,e.outputs?.validation),K(e.id,e.observability);for(let[t,n]of Object.entries(e.models))z(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=V(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},Qe(o.id,o.inputs.attachments?.accept),Ze(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,...I(e.tools.parallel)},turnBehaviour:e.turnBehaviour,guardrails:n,observability:r,labels:i},be(o),et(o.id,o.live.contextCompression),$e(o);break;default:throw new _(`config`,`Unknown profile type '${String(e)}'`)}return Ye(o),qe(o),Je(o),o}function qe(e){let{maxSteps:t}=e;if(!(t===void 0||Number.isInteger(t)&&t>0))throw new _(`config`,`Profile ${e.id}: maxSteps must be a whole number of 1 or more; leave it out for the default of 20`)}function Je(e){if(e.type===`text`&&e.turnBehaviour?.atStepLimit===`answer`&&e.maxSteps===1)throw new _(`config`,`Profile ${e.id}: turnBehaviour.atStepLimit 'answer' with maxSteps 1 leaves no step that can call a tool`)}function Ye(e){if(e.type===`live`)return;let t=e.outputs?.structured;if(!t||typeof t==`string`)return;let n=he(e,t.by);if(!n)throw new _(`config`,`Profile ${e.id}: outputs.structured.by '${t.by}' is not one of the profile's options`);let r=ve(n),i=Object.keys(t.map).filter(e=>!r.includes(e));if(i.length)throw new _(`config`,`Profile ${e.id}: outputs.structured.map maps ${i.join(`, `)}, not a choice of option '${t.by}'`)}var Xe={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 Ze(e,t){for(let[n,{ok:r,rule:i}]of Object.entries(Xe)){let a=t[n];if(a!==void 0&&!r(a))throw new _(`config`,`Profile ${e}: image.${n} must be ${i}`)}t.references?.forEach((t,n)=>{let r=`Profile ${e}: image.references[${n}]`;if(se(t.mimeType)!==`image`)throw new _(`config`,`${r} must be an image, not '${t.mimeType}'`);if(!(me(t)?t.uri:t.data))throw new _(`config`,`${r} needs its bytes or its uri`)})}function Qe(e,t){let n=t?.filter(e=>!de(c,e));if(n?.length)throw new _(`config`,`Profile ${e}: an image profile's attachments take images, video, and PDF only, not ${n.join(`, `)}`)}function $e(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 _(`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 _(`config`,`${i}.resumed.prompt must be a prompt`);let{afterMs:a}=n;if(a!==void 0&&!(Number.isFinite(a)&&a>=0))throw new _(`config`,`${i}.resumed.afterMs must be 0 or more milliseconds`);if(!r)throw new _(`config`,`${i}.resumed needs live.sessionResumption: without it no call resumes`)}function et(e,t){if(!t)return;let n=`Profile ${e} live.contextCompression`,r=t.triggerTokens,i=t.slidingWindow.targetTokens;if(J(`${n}.triggerTokens`,r),J(`${n}.slidingWindow.targetTokens`,i),r!==void 0&&i!==void 0&&i>=r)throw new _(`config`,`${n}: slidingWindow.targetTokens must be below triggerTokens`)}function J(e,t){if(!(t===void 0||Number.isInteger(t)&&t>0))throw new _(`config`,`${e} must be a whole number above 0`)}function tt(e,t,n,r){let i=`Profile ${t.id} model ${n} compaction`;if(nt(i,r),rt(i,r),r.profile===void 0){if(t.type!==`text`||t.inputs.text===!1)throw new _(`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 _(`config`,`${i}: compaction profile '${r.profile}' must be registered before '${t.id}'`);if(a.type!==`text`||a.inputs.text===!1)throw new _(`config`,`${i}: compaction profile '${r.profile}' must be a text profile that takes text`)}function nt(e,t){if(t.maxTokens<=0)throw new _(`config`,`${e}: maxTokens must be > 0`);if(t.compactAt<=0||t.compactAt>=1)throw new _(`config`,`${e}: compactAt must be in (0, 1)`)}function rt(e,t){if(t.previousExchanges<0)throw new _(`config`,`${e}: previousExchanges must be >= 0`);if(t.previousExchanges<1&&t.previousExchanges>=t.compactAt)throw new _(`config`,`${e}: previousExchanges as fraction (${t.previousExchanges}) must be < compactAt (${t.compactAt})`);if(t.previousExchanges>1&&!Number.isInteger(t.previousExchanges))throw new _(`config`,`${e}: previousExchanges >= 1 must be an integer`)}function it(e,t){for(let n of v(t))if(e.get(n)?.type===`builtin`)throw new _(`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 at(e,t){let n=_e(t)?.t2Loader;if(n){if(!v(t).includes(n))throw new _(`config`,`Profile ${t.id} tools.t2Loader '${n}' must also be listed in tools.allow`);if(e.get(n)?.type!==`function`)throw new _(`config`,`Profile ${t.id} tools.t2Loader '${n}' must be a registered type: 'function' tool`)}}function*ot(e){for(let[t,n]of Object.entries(e.models))for(let e of n.builtInTools??[])yield{modelId:t,id:e}}function st(e,t){for(let{modelId:n,id:r}of ot(t))if(e.get(r)?.type!==`builtin`)throw new _(`config`,`Profile ${t.id} model '${n}' lists '${r}' in builtInTools — not a registered builtin`)}function Y(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 ct(e,t){return t?.type===`text`?Y(t).flatMap(t=>{let n=e.find(t);return n?[n.jsonSchema]:[]}):[]}function lt(e,t){let n=Y(t).map(n=>{let r=e.find(n);if(!r)throw new _(`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 _(`config`,`Profile ${t.id}: outputs.validation checks a structured reply, so it needs outputs.structured`);let o=a.filter(e=>!n.some(t=>P(t.jsonSchema,e)));if(o.length)throw new _(`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=>A(t.jsonSchema,e)));if(s.length)throw new _(`config`,`Profile ${t.id}: outputs.validation.fields has ${s.join(`, `)}, which no structured schema reaches through object properties`)}function ut(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 _(`config`,`Profile ${e.id}: inputs.context.from must list ${h.join(` or `)}`);if(!(Number.isInteger(t.maxChars)&&t.maxChars>0))throw new _(`config`,`Profile ${e.id}: inputs.context.maxChars must be a positive integer`)}function X(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 _(`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 _(`config`,`Profile ${e}: inputs.${t} must be a positive integer`)}function dt(e,t,n){let r=new Map,i=i=>{let a=q(i),s=n&&a.type!==`host`?{...a,models:Object.fromEntries(Object.entries(a.models).map(([e,t])=>[e,u(n.require(t.provider,t.apiId),t,a.type)]))}:a;if(it(e,s),at(e,s),s.type!==`host`&&s.type!==`decision`&&s.type!==`embedding`){st(e,s),X(s.id,o(s)),ut(s),lt(t,s);for(let[e,t]of Object.entries(s.models))t.compaction&&tt(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 _(`config`,`Unknown profile '${e}'`);return t},find:e=>r.get(e),has:e=>r.has(e),list:()=>[...r.values()],clear:()=>r.clear()}}function ft(e){let t=e?.trim()??``;if(t.startsWith(`AIza`))return`gemini`;if(t.startsWith(`sk-or-`))return`openrouter`}function Z(e){let t;try{t=new URL(e.baseUrl)}catch{throw new _(`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 _(`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 _(`blocked`,`Local requests must stay on the configured origin.`))}}var pt=n({data:t(n({id:e().min(1)}))});async function mt(e,t){let n=Z(e);if(!n?.fetch)throw new _(`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 _(`network`,`Local model list returned HTTP ${r.status}.`);let i=pt.safeParse(await r.json());if(!i.success)throw new _(`request`,`The endpoint returned an invalid model list.`);return[...new Set(i.data.data.map(e=>e.id))]}var ht=`https://openrouter.ai/api/v1/models`,gt=`https://openrouter.ai/api/v1/embeddings/models`,_t=[{id:`gemini-embedding-2-preview`,label:`Gemini Embeddings 2 (preview)`},{id:`gemini-embedding-001`,label:`Gemini Embedding 001`}],vt=[{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},bt=n({data:t(n({id:e().min(1),name:e().optional(),architecture:n({output_modalities:t(e()).optional()}).optional()}))}),Q=n({data:t(n({id:e().min(1),name:e().optional()}))}),xt=n({models:t(n({name:e().min(1),displayName:e().optional(),supportedGenerationMethods:t(e()).optional()})).optional(),nextPageToken:e().optional()}),St=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 _(`auth`,`${e} refused the key.`);if(!r.ok)throw new _(`network`,`${e} model list returned HTTP ${r.status}.`);return await r.json()}async function Ct(e,t,n,r){let i=n?.trim();if(t===`embedding`&&!i)return[...e===`openrouter`?vt:_t];if(e===`openrouter`)return await wt(t,i,r);if(!i)throw new _(`auth`,`Choose a key to list Gemini models.`);return await Et(t,i,r)}async function wt(e,t,n){let r={signal:n,headers:{Accept:`application/json`,...t?{Authorization:[`Bearer`,t].join(` `)}:{}}};if(e===`embedding`){let e=Q.safeParse(await $(`OpenRouter`,gt,r));if(!e.success)throw new _(`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=bt.safeParse(await $(`OpenRouter`,`${ht}?output_modalities=${i}`,r));if(!a.success)throw new _(`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 Tt={live:`bidiGenerateContent`,embedding:`embedContent`};async function Et(e,t,n){let i=Tt[e]??`generateContent`,a=[],o;for(let e=0;e<St;e++){let e=new URL(r);e.searchParams.set(`pageSize`,`1000`),o&&e.searchParams.set(`pageToken`,o);let s=xt.safeParse(await $(`Google`,e.href,{signal:n,headers:{Accept:`application/json`,"x-goog-api-key":t}}));if(!s.success)throw new _(`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 Dt(e){return[...new Set([e.key,e.fallbackKey,...Object.values(e.models??{}).flatMap(e=>[e.keySlot,e.fallbackKeySlot])].filter(e=>!!e))]}function Ot(e,t){return Object.fromEntries(e.map(e=>[e,Object.hasOwn(t,e)?t[e]:void 0]))}export{Dt as a,q as c,k as d,j as f,y as g,N as h,Z as i,ct as l,M as m,mt as n,Ot as o,P as p,Ct as r,dt as s,ft as t,Se as u};