@theoremjs/studio 0.3.5-next.917.g6cb0b91 → 0.3.5-next.918.g28ade76
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.
- package/package.json +4 -4
- package/page/assets/{BottomSheet-Cy4IF0ml.js → BottomSheet-qll7D1c7.js} +1 -1
- package/page/assets/{ConsoleFrame-0Tt1TX7l.js → ConsoleFrame-DKGS7zog.js} +1 -1
- package/page/assets/{DateInput-DdIpq1ad.js → DateInput-xLjOgfL7.js} +1 -1
- package/page/assets/{MenuBottomSheet-C1bUX1K8.js → MenuBottomSheet-BBtWnJG9.js} +1 -1
- package/page/assets/{PowerSearchBottomSheet-wiEAVHxz.js → PowerSearchBottomSheet-DGG106ft.js} +1 -1
- package/page/assets/{RankedBars-CP4ks5cK.js → RankedBars-I5bT4sbu.js} +1 -1
- package/page/assets/{SchemaFields-BYa4DMcS.js → SchemaFields-DTXCJ74W.js} +1 -1
- package/page/assets/{TokenizerBottomSheet-Duib8-np.js → TokenizerBottomSheet-BVMXpwZx.js} +1 -1
- package/page/assets/{ToolResultCharts-DrQPbfBG.js → ToolResultCharts-7Zdpxxt8.js} +1 -1
- package/page/assets/{Toolbar-rjnnyona.js → Toolbar-C-ciUKo2.js} +1 -1
- package/page/assets/{TraceInspector-B-aAMsSz.js → TraceInspector-VrNU8TlW.js} +2 -2
- package/page/assets/{TraceOverview-DzHI1uyZ.js → TraceOverview-DG0ZWPVf.js} +3 -3
- package/page/assets/{_virtual_studio-type-sources-CKocpeaM.js → _virtual_studio-type-sources-DF7uTKHt.js} +11 -12
- package/page/assets/browser-connection-COynzMLG.js +1 -0
- package/page/assets/browser-engine-crtdalXi.js +16 -0
- package/page/assets/{browser-transport-DTUtqtOj.js → browser-transport-Cs_H6BQz.js} +2 -2
- package/page/assets/{compile-DdVZ_rnu.js → compile-BmQjkp6E.js} +2 -2
- package/page/assets/encode-files-4TKL6X3k.js +1 -0
- package/page/assets/{export-agent-IVk7hfsL.js → export-agent-8VI4LCc0.js} +1 -1
- package/page/assets/{getRadiusAndStrokeWidthFromDot-AYz6t7_1.js → getRadiusAndStrokeWidthFromDot-kC0108S7.js} +1 -1
- package/page/assets/{guardrail-health-BrA9ig7k.js → guardrail-health-BwSPEBlz.js} +2 -2
- package/page/assets/{guardrail-tester-BLjfvOp6.js → guardrail-tester-DVCzvEFH.js} +1 -1
- package/page/assets/{index-DswdMgUb.js → index-CtRmKAu_.js} +71 -71
- package/page/assets/{json-code-B3VMJIlK.js → json-code-C96FE1-t.js} +1 -1
- package/page/assets/{labels-provider-CpBRjcdZ.js → labels-provider-85Xs6wuw.js} +1 -1
- package/page/assets/{live-messages-Blf6o6Di.js → live-messages-TJAppiyT.js} +1 -1
- package/page/assets/{prompt-row-DtXPYyWg.js → prompt-row-DhkHlZvg.js} +1 -1
- package/page/assets/reader-BFqChixe.js +5 -0
- package/page/assets/{registry-kjesbLCL.js → registry-DrKxNAcT.js} +1 -1
- package/page/assets/{schema-BQ_MNDUt.js → schema-Bd2vx9gf.js} +2 -2
- package/page/assets/{shaped-data-njRceHXF.js → shaped-data-kgpSHMF_.js} +17 -17
- package/page/assets/{stub-urbDad7_.js → stub-drq3K-8s.js} +1 -1
- package/page/assets/{studio-code-pane-DWD0fW0N.js → studio-code-pane-gd02FneP.js} +3 -3
- package/page/assets/{studio-console-DRYFijb2.js → studio-console-BsOmoSEi.js} +1 -1
- package/page/assets/{studio-decision-QRbyFPZI.js → studio-decision-Cgd0z2zF.js} +1 -1
- package/page/assets/{studio-embedding-Dq10c3ha.js → studio-embedding-Mn-6PqE-.js} +1 -1
- package/page/assets/{studio-host-console-CvysUoUX.js → studio-host-console-BFX1WAQC.js} +2 -2
- package/page/assets/{studio-labels-DYY2_-NQ.js → studio-labels-BUeu_6-W.js} +1 -1
- package/page/assets/studio-live-BTti_fAq.js +5 -0
- package/page/assets/{studio-map-Dnt-keid.js → studio-map-Dy1e9g7l.js} +1 -1
- package/page/assets/{studio-trace-replay-CJh6-FNS.js → studio-trace-replay-YflZy1RI.js} +1 -1
- package/page/assets/{studio-type-checker-eMyMcWLc.js → studio-type-checker-2krzvQb2.js} +1 -1
- package/page/assets/{tool-schema-NFg3VP_C.js → tool-schema-D2rR8UcM.js} +1 -1
- package/page/assets/{trace-record-DkT3R93h.js → trace-record-Db5o7bZW.js} +1 -1
- package/page/assets/tree-Cq9dT_Du.js +3 -0
- package/page/assets/turn-client-CLgiEt8s.js +2 -0
- package/page/assets/types-BjjlWUpS.js +1 -0
- package/page/assets/{use-one-call-CRtYn_ld.js → use-one-call-yis_2Nuo.js} +1 -1
- package/page/assets/{useDismissSearchOnTouchDrag-Dje_l-0_.js → useDismissSearchOnTouchDrag-CNig0RKc.js} +1 -1
- package/page/assets/{workspace-Cudxmk1-.js → workspace-D5X5AzJ7.js} +1 -1
- package/page/index.html +17 -17
- package/page/assets/browser-connection-D7-hqZlk.js +0 -1
- package/page/assets/browser-engine-Dza0hb2K.js +0 -16
- package/page/assets/encode-files-ClxOAPSR.js +0 -1
- package/page/assets/reader-D3pkP2jP.js +0 -5
- package/page/assets/studio-live-C5R8t3HS.js +0 -5
- package/page/assets/tree-1oG0sQg9.js +0 -3
- package/page/assets/turn-client-SYBmDrew.js +0 -2
- package/page/assets/types-DwuXqQ-z.js +0 -1
|
@@ -4750,7 +4750,7 @@ declare const TOOL_KINDS: readonly ["function", "http", "mcp", "agent"];
|
|
|
4750
4750
|
type ToolKind = (typeof TOOL_KINDS)[number];
|
|
4751
4751
|
/**
|
|
4752
4752
|
* The places a tool's text crosses: what the model sends, what comes back to it, its error text,
|
|
4753
|
-
* and what the call shows the person (its output, error,
|
|
4753
|
+
* and what the call shows the person (its output, error, and trace on the turn's events).
|
|
4754
4754
|
*/
|
|
4755
4755
|
declare const TOOL_CROSSINGS: readonly ["tool_arguments", "tool_output", "tool_failure", "tool_shown"];
|
|
4756
4756
|
/** One of {@linkcode TOOL_CROSSINGS}. */
|
|
@@ -7354,7 +7354,7 @@ export interface ToolCallEdit {
|
|
|
7354
7354
|
*
|
|
7355
7355
|
* - \`running\` — the body started; \`edited\` when the user changed the arguments;
|
|
7356
7356
|
* \`activity\` is the tool's activity label filled from the call's input.
|
|
7357
|
-
* - \`progress\` / \`trace\` / \`
|
|
7357
|
+
* - \`progress\` / \`trace\` / \`warning\` — streamed while it ran. A \`progress\` its
|
|
7358
7358
|
* output's check stops is not sent.
|
|
7359
7359
|
* - \`draft\` — the next piece of what the tool is writing, for a preview, each piece read at
|
|
7360
7360
|
* \`tool_output_<kind>\` first (an agent tool's: its agent's reply). Sent only under
|
|
@@ -7389,9 +7389,6 @@ export type ToolPhaseEvent = ToolPhaseBase & ({
|
|
|
7389
7389
|
} | {
|
|
7390
7390
|
phase: 'trace';
|
|
7391
7391
|
step: ToolTraceStep;
|
|
7392
|
-
} | {
|
|
7393
|
-
phase: 'artifact';
|
|
7394
|
-
artifact: unknown;
|
|
7395
7392
|
} | {
|
|
7396
7393
|
phase: 'warning';
|
|
7397
7394
|
warning: ToolWarning;
|
|
@@ -7600,11 +7597,12 @@ export type TurnEvent = {
|
|
|
7600
7597
|
}
|
|
7601
7598
|
/**
|
|
7602
7599
|
* The message \`input.lateResults\` put in the conversation, role \`user\`. It enters a history built
|
|
7603
|
-
* from events like any other message.
|
|
7600
|
+
* from events like any other message. \`operationIds\` are the calls whose results it holds.
|
|
7604
7601
|
*/
|
|
7605
7602
|
| {
|
|
7606
7603
|
type: 'late_results';
|
|
7607
7604
|
text: string;
|
|
7605
|
+
operationIds: string[];
|
|
7608
7606
|
} | {
|
|
7609
7607
|
type: 'media';
|
|
7610
7608
|
media: {
|
|
@@ -9860,9 +9858,6 @@ export type ToolStreamEvent<TOut = unknown> = {
|
|
|
9860
9858
|
} | {
|
|
9861
9859
|
kind: 'trace';
|
|
9862
9860
|
step: ToolTraceStep;
|
|
9863
|
-
} | {
|
|
9864
|
-
kind: 'artifact';
|
|
9865
|
-
artifact: unknown;
|
|
9866
9861
|
} | {
|
|
9867
9862
|
kind: 'warning';
|
|
9868
9863
|
warning: ToolWarning;
|
|
@@ -12583,7 +12578,7 @@ export interface HandlerEventChecks {
|
|
|
12583
12578
|
policy: ResolvedGuardrailPolicy;
|
|
12584
12579
|
/** \`tool_output_<kind>\`. */
|
|
12585
12580
|
boundary: ToolBoundary;
|
|
12586
|
-
/** \`tool_shown_<kind>\`: what its
|
|
12581
|
+
/** \`tool_shown_<kind>\`: what its trace is read at. */
|
|
12587
12582
|
shown: ToolBoundary;
|
|
12588
12583
|
callableTools: readonly string[];
|
|
12589
12584
|
/** Whether the host sees the handler's drafts (\`outputs.streaming.mode\` \`sse\`). */
|
|
@@ -13951,7 +13946,7 @@ export interface ShownToolValue {
|
|
|
13951
13946
|
event?: GuardrailEvent;
|
|
13952
13947
|
}
|
|
13953
13948
|
/**
|
|
13954
|
-
* A call's output, error,
|
|
13949
|
+
* A call's output, error, and trace reach the person on the turn's events, apart from
|
|
13955
13950
|
* what the model read back: the host's server forwards them to the browser as they are. Each is
|
|
13956
13951
|
* read here at \`tool_shown_<kind>\`, so a key a tool returned is not shown. \`readBack\` is
|
|
13957
13952
|
* untouched: what the model read is settled at \`tool_output_<kind>\`.
|
|
@@ -14013,7 +14008,11 @@ declare function readToolData(content: string): ToolDataRead[];
|
|
|
14013
14008
|
* word to the model. A person who types a fence only makes their own reply stricter.
|
|
14014
14009
|
*/
|
|
14015
14010
|
declare function isLateResult(message: TurnHistoryMessage): boolean;
|
|
14016
|
-
|
|
14011
|
+
/** The history message \`input.lateResults\` opens; its metadata names the calls it holds. */
|
|
14012
|
+
declare function lateResultsMessage(text: string, operationIds: readonly string[]): TurnHistoryMessage;
|
|
14013
|
+
/** The calls whose late results a history message holds. */
|
|
14014
|
+
declare function lateResultIds(message: TurnHistoryMessage): string[];
|
|
14015
|
+
export { isLateResult, lateResultIds, lateResultsMessage, readToolData, TOOL_CLOSE };
|
|
14017
14016
|
`,"file:///node_modules/@theoremjs/agents/src/guardrails/tool-directives.d.ts":`import type { AdvisoryLevel } from './types.js';
|
|
14018
14017
|
/**
|
|
14019
14018
|
* What of a tool's text reads as an instruction to the agent: an order to set its instructions
|
|
@@ -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-D2rR8UcM.js";import{$t as i,Ba as a,Ca as o,Ci as s,Cn as c,Ei as l,Ia as u,Ii as d,Ka as ee,Mi as f,Qi as te,Qt as ne,Si as p,Sn as m,Tn as h,Xi as re,Y as ie,Zi as ae,ao as g,bn as oe,ca as se,ga as ce,ji as le,nn as ue,oo as de,qi as fe,to as pe,wa as me,xn as _,zt as he}from"./shaped-data-kgpSHMF_.js";import{c as v}from"./host-patterns-F-KZIzkF.js";import{D as ge,S as _e,g as y,k as ve,v as ye,w as be}from"./schema-Bd2vx9gf.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=h(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=>!_(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 w(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 Ie={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 Le(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:Ie[e.code],params:t}}function Re(e,t){let n=Le(e);return g(n.key,n.params,t)}function T(e){return new v(`input`,`attachments refused: ${e.map(e=>e.code).join(`, `)}`,{copy:e.map(Le)})}function E(e){if(!De.test(e))throw new v(`request`,`attachment data must be base64`);return je(e)}function D(e){let t={mimeType:e.mimeType,name:e.name};return x(e)||(t.sizeBytes=E(e.data)),t}function ze(e,t,n){if(!Be(t,n))return;let r=Ae(e),i=w({attachments:m(e,`attachments`),voice:m(e,`voice`),limits:r},(t??[]).map(D),(n??[]).map(D));if(i.length>0)throw T(i)}function O(e,t){if(x(e))return e;let{mimeType:n,data:r}=e;if(!Oe.has(h(n)))return e;let i=Pe(n,o(r),t);return{...e,data:me(i)}}function Be(e,t){return(e?.length??0)>0||(t?.length??0)>0}function Ve(e,t,n,r){return ze(e,t,n),{attachments:t?.length?t.map(e=>O(e,r.attachment)):t,voice:n?.length?n.map(e=>O(e,r.voice)):n}}function k(e){let t=Object.keys(e);return t.length===1?t[0]:void 0}function A(e){return e==null}function j(e){return A(e)||typeof e!=`object`||Array.isArray(e)?null:e}function M(e){let t=j(e);return!t||t.type!==void 0&&t.type!==`object`?null:t}function N(e){let t=e.required;return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}function P(e){let t=e.properties;return j(t)??{}}function He(e,t){return e?`${e}.${t}`:t}function F(e,t){t.push({path:e,error:`required field '${e}' is missing`})}async function Ue(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 We(e){let{path:t,propSchema:n,child:r,isRequired:i,fields:a,options:o,failures:s,crashes:c}=e;if(A(r)){i&&F(t,s);return}await Ue(t,r,a?.[t],o,s,c);let l=M(n),u=l?j(r):null;l&&u&&await I(l,u,t,a,o,s,c)}async function I(e,t,n,r,i,a,o){let s=P(e),c=new Set(N(e)),l=new Set([...Object.keys(s),...c]),u=j(t);for(let e of l)await We({path:He(n,e),propSchema:s[e],child:u?.[e],isRequired:c.has(e),fields:r,options:i,failures:a,crashes:o})}async function Ge(e,t,n,r,i=[]){let a=M(e);if(!a)throw new v(`config`,`structured validation requires a JSON Schema object root`);let o=[];if(!j(t)){for(let e of N(a))F(e,o);return o}return await I(a,t,``,n,r,o,i),o}function Ke(e,t){let n=e;for(let e of t.split(`.`)){let t=M(n);if(!t)return!1;let r=P(t);if(!Object.hasOwn(r,e)&&!N(t).includes(e))return!1;n=r[e]}return!0}function qe(e){return e.map(e=>e.error).join(`; `)}function L(e,t){let n=e;for(let e of t.split(`.`))n=j(n)?.[e];return n}function R(e,t,n){let[r,...i]=t.split(`.`),a=j(e)??{};return r===void 0?e:{...a,[r]:i.length?R(a[r],i.join(`.`),n):n}}async function Je(e,t,n,r=[]){let i=[];for(let[a,o]of Object.entries(t??{})){let t=L(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 z(e,t){let n=e;for(let e of t.split(`.`)){let t=M(n);if(!t)return;n=P(t)[e]}let r=j(n);if(r?.type===`array`)return j(r.items)??void 0}function Ye(e,t,n,r){if(!n.provider?.trim()||!n.apiId?.trim())throw new v(`config`,g(`provider.binding_identity`))}function Xe(e){V(e.id,e.models),X(e.id,e.observability),zt(e.id,e.inputs);for(let[t,n]of Object.entries(e.models))U(e.id,t,n);return{type:`embedding`,id:e.id,identity:{handle:e.identity.handle},models:e.models,defaultModel:H(e.id,e),allowModelSelect:e.allowModelSelect,inputs:e.inputs,guardrails:e.guardrails,observability:e.observability,labels:e.labels}}function Ze(e){V(e.id,e.models),J(e.id,e.guardrails),X(e.id,e.observability);for(let[t,n]of Object.entries(e.models))U(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},...G(e),providerContinuation:void 0,maxSteps:void 0,inputs:{...e.inputs,text:!1},guardrails:e.guardrails,observability:e.observability,labels:e.labels}}function Qe(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=>`${ie(e.path)}: ${e.message}`).join(`; `)}`)}function $e(e,t,n){if(Qe(e,t,n,i),Ye(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?k(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),X(e.id,e.observability),{...e,identity:{handle:e.identity.handle}}}function B(e){return e===void 0?{}:{parallel:e}}function rt(e){return it(e.id,e.tools),X(e.id,e.observability),{type:`host`,id:e.id,tools:{allow:e.tools.allow,...B(e.tools.parallel)},guardrails:e.guardrails,observability:e.observability,labels:e.labels}}function it(e,t){if(!Array.isArray(t.allow))throw new v(`config`,`Profile ${e}: type 'host' must set tools.allow`)}function V(e,t){if(Object.keys(t).length===0)throw new v(`config`,`Profile ${e} must declare at least one model`)}function H(e,t){let n=t.defaultModel??k(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 U(e,t,n){W(e,t,n),Qe(e,t,n,ue),W(e,t,n)}function W(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(!d.includes(i))throw new v(`config`,`Profile ${e} model '${t}' effort '${n}': '${i}' is not a thinking level (${d.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 G(e){return{providerContinuation:e.providerContinuation?ce.parse(e.providerContinuation):{},models:e.models,defaultModel:H(e.id,e),allowModelSelect:e.allowModelSelect,maxSteps:e.maxSteps}}function K(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 (${s.join(` | `)}); got '${r}'`)}}function at(e,t){t&&(K(e,`allowContinue`,t.allowContinue),K(e,`autoContinue`,t.autoContinue))}function q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ot(e,t){let n=[e];for(let e of t)n=n.flatMap(t=>q(t)?e===`*`?Object.values(t):[t[e]]:[]);return n}var st=Object.entries(le).filter(([,e])=>e.required===!0).map(([e,t])=>[e,t.profileTypes]).sort(([e],[t])=>e.split(`.`).length-t.split(`.`).length);function ct(e){if(!q(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(!f.find(t=>t===e.type))throw new v(`config`,`Profile ${t}: type must be one of ${f.join(`, `)}`)}function lt(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 ut(e){let{id:t,type:n}=e,r=e;for(let[e,i]of st){if(i&&!i.includes(n))continue;let a=ae(e),o=ot(r,a.slice(0,-1)),s=a[a.length-1];if(o.some(e=>{if(!q(e))return!1;let t=e[s];return t==null||t===``}))throw new v(`config`,`Profile ${t}: type '${n}' must set ${a.join(`.`)}`)}}function dt(e){let{id:t,type:n}=e;if(n!==`live`&&te(`inputs`).includes(n)&&e.inputs==null)throw new v(`config`,`Profile ${t}: type '${n}' must set inputs`)}function ft(e){let[t]=re(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 pt(e,t){let n=t.turnBehaviour;at(e,n?.resumption)}function mt(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 J(e,t){let n=t=>new v(`config`,`Profile ${e}: ${t}`),r=Object.keys(t??{}).find(e=>!Y.includes(e));if(r!==void 0)throw n(`guardrails.${r} is not a setting; it takes ${Y.join(`, `)}`);gt(t?.blockedReply,n)}var Y=[`quota`,`detect`,`blockedReply`,`network`,`taint`],ht=[`onBlock`,`maxRetries`];function gt(e,t){if(e===void 0)return;let n=Object.keys(e).find(e=>!ht.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&&!u.includes(r))throw t(`guardrails.blockedReply.onBlock must be one of ${u.join(`, `)}`);if(i!==void 0&&(!Number.isInteger(i)||i<0))throw t(`guardrails.blockedReply.maxRetries must be a non-negative integer`)}function _t(e){let t=e.guardrails?.detect,n=e.type===`host`?se(`guardrails.detect`,t,a):se(`guardrails.detect`,t);if(n!==void 0)throw new v(`config`,`Profile ${e.id}: ${n}`)}function X(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(ee(t),`Profile ${e}: ${n}`,{cause:t})}}function vt(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??``;_e(r,`Profile ${e.id} identity.system`);let i=be(r,t,e.inputs?.options);if(i)throw new v(`config`,`Profile ${e.id} identity.system: ${i}`)}function Z(e){let t=yt(e),[n]=fe(e);if(n)throw new v(`config`,`Profile ${e.id}: ${n.path} ${n.message}`);return t}function yt(e){ct(e);for(let t of[`key`,`fallbackKey`,`protocol`,`provider`])if(t in e)throw new v(`config`,g(`provider.profile_configuration`,{profile:e.id,field:t}));ft(e),dt(e),ut(e),lt(e),e.labels&&de(e.labels,`Profile ${e.id}`);for(let t of pe)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(vt(e),_t(e),e.type===`host`)return rt(e);if(e.type===`decision`)return nt(e);if(e.type===`embedding`)return Xe(e);if(e.type===`transcription`)return Ze(e);V(e.id,e.models),pt(e.id,e),J(e.id,e.guardrails),e.type===`text`&&mt(e.id,e.outputs?.validation),X(e.id,e.observability);for(let[t,n]of Object.entries(e.models))U(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=G(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},Tt(o.id,o.inputs.attachments?.accept),wt(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,...B(e.tools.parallel)},turnBehaviour:e.turnBehaviour,guardrails:n,observability:r,labels:i},Se(o),Dt(o.id,o.live.contextCompression),Et(o);break;default:throw new v(`config`,`Unknown profile type '${String(e)}'`)}return St(o),bt(o),xt(o),o}function bt(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 xt(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 St(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 Ct={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 wt(e,t){for(let[n,{ok:r,rule:i}]of Object.entries(Ct)){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(oe(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 Tt(e,t){let n=t?.filter(e=>!_(l,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 Et(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 Dt(e,t){if(!t)return;let n=`Profile ${e} live.contextCompression`,r=t.triggerTokens,i=t.slidingWindow.targetTokens;if(Q(`${n}.triggerTokens`,r),Q(`${n}.slidingWindow.targetTokens`,i),r!==void 0&&i!==void 0&&i>=r)throw new v(`config`,`${n}: slidingWindow.targetTokens must be below triggerTokens`)}function Q(e,t){if(!(t===void 0||Number.isInteger(t)&&t>0))throw new v(`config`,`${e} must be a whole number above 0`)}function Ot(e,t,n,r){let i=`Profile ${t.id} model ${n} compaction`;if(kt(i,r),At(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 kt(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 At(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 jt(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 Mt(e,t){let n=ye(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*Nt(e){for(let[t,n]of Object.entries(e.models))for(let e of n.builtInTools??[])yield{modelId:t,id:e}}function Pt(e,t){for(let{modelId:n,id:r}of Nt(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 Ft(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`?Ft(t).flatMap(t=>{let n=e.find(t);return n?[n.jsonSchema]:[]}):[]}function Lt(e,t){let n=Ft(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=>z(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=>Ke(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=c(e)?.context;if(!t)return;let n=p;if(t.from.length===0||t.from.some(e=>!n.includes(e)))throw new v(`config`,`Profile ${e.id}: inputs.context.from must list ${p.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=Z(i),o=n&&a.type!==`host`?{...a,models:Object.fromEntries(Object.entries(a.models).map(([e,t])=>[e,ne(n.require(t.provider,t.apiId),t,a.type)]))}:a;if(jt(e,o),Mt(e,o),o.type!==`host`&&o.type!==`decision`&&o.type!==`embedding`){Pt(e,o),zt(o.id,c(o)),Rt(o),Lt(t,o);for(let[e,t]of Object.entries(o.models))t.compaction&&Ot(r,o,e,t.compaction)}r.set(o.id,o)};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{Ve as C,b as S,Re as _,an as a,E as b,Z as c,Ge as d,qe as f,k as g,R as h,Ht as i,It as l,L as m,Wt as n,on as o,z as p,en as r,Bt as s,Vt as t,Je as u,w as v,x,T as y};
|