@theoremjs/studio 0.3.4-next.677.g14b70fe → 0.3.4-next.693.g4ab1526
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/asks.d.ts +9 -2
- package/asks.js +19 -10
- package/browser-connection.d.ts +1 -1
- package/browser-connection.js +3 -1
- package/browser-execution.js +1 -0
- package/compile-workspace.js +12 -5
- package/compile.d.ts +4 -2
- package/compile.js +58 -37
- package/cookbooks/catalog.d.ts +2 -2
- package/cookbooks/catalog.js +300 -53
- package/cookbooks/project.js +1 -0
- package/cookbooks/tools.js +64 -0
- package/draft.d.ts +21 -5
- package/draft.js +25 -2
- package/guardrail-probe.d.ts +3 -1
- package/guardrail-probe.js +37 -5
- package/mod.d.ts +2 -2
- package/mod.js +2 -2
- package/package.json +4 -4
- package/page/assets/Banner-DrRNC3MG.js +4 -0
- package/page/assets/Center-CgO0c-qo.js +1 -0
- package/page/assets/{ConsoleFrame-BFCYCApu.js → ConsoleFrame-BvgFGqp2.js} +3 -3
- package/page/assets/{MenuBottomSheet-CezET_qZ.js → MenuBottomSheet-BZecY8fw.js} +1 -1
- package/page/assets/{SchemaFields-CIF3WtC0.js → SchemaFields-BNNkvyyO.js} +1 -1
- package/page/assets/{ToolResultCharts-D3pQGTH1.js → ToolResultCharts-C3CPsfXl.js} +1 -1
- package/page/assets/{TraceInspector-Bx3j_185.js → TraceInspector-36e6ozKD.js} +1 -1
- package/page/assets/{TraceOverview-ChpCMZRa.js → TraceOverview-CSdJ_cYY.js} +3 -3
- package/page/assets/{_virtual_studio-type-sources-BwSqfSwd.js → _virtual_studio-type-sources-DSpwr3WK.js} +143 -13
- package/page/assets/browser-connection-dads1eyK.js +3 -0
- package/page/assets/browser-engine-CugH58NS.js +13 -0
- package/page/assets/browser-transport-GzhRiBdm.js +45 -0
- package/page/assets/{crypto-CD14HeXH.js → crypto-B8dqEoWf.js} +1 -1
- package/page/assets/{encode-files-DhoC5hWG.js → encode-files-CHeRLBO8.js} +1 -1
- package/page/assets/{export-agent-nlvsxs9-.js → export-agent-botXSyoH.js} +3 -3
- package/page/assets/{guardrail-tester-C7r03f5Z.js → guardrail-tester-DYR7EPIy.js} +2 -2
- package/page/assets/index-B7sK7d-l.js +153 -0
- package/page/assets/live-messages-DN_q2nBN.js +1 -0
- package/page/assets/project-address-DjxPZuyn.js +1 -0
- package/page/assets/reader-DHN96tSr.js +5 -0
- package/page/assets/{schemas-BQ9Jydzb.js → schemas-D7cgkv3L.js} +1 -1
- package/page/assets/shaped-data-CJQ3W_RE.js +20 -0
- package/page/assets/{stub-nxRsh1jo.js → stub-U6wDGe3P.js} +25 -7
- package/page/assets/studio-code-pane-Boy63AK2.js +8 -0
- package/page/assets/{studio-console-BgymsByi.js → studio-console-B7zL133d.js} +1 -1
- package/page/assets/studio-decision-CbRjfbvG.js +1 -0
- package/page/assets/studio-embedding-DQ0QrEsu.js +2 -0
- package/page/assets/{studio-host-console-DtepSA77.js → studio-host-console-DDA2Um2-.js} +2 -2
- package/page/assets/{studio-labels-BZbz7-uL.js → studio-labels-jYWBoEyP.js} +1 -1
- package/page/assets/studio-live-D0YRu2zQ.js +5 -0
- package/page/assets/studio-map-C4Ra1QqL.js +1 -0
- package/page/assets/studio-session-CPnJaHc-.js +1 -0
- package/page/assets/studio-trace-replay-D-f2p7k9.js +3 -0
- package/page/assets/{studio-type-checker-BbUSqqOS.js → studio-type-checker-CVNPnko-.js} +1 -1
- package/page/assets/tool-schema-BDG2_rlP.js +17 -0
- package/page/assets/{trace-record-DxgSKmYY.js → trace-record-DoXjxrmJ.js} +1 -1
- package/page/assets/trace-schema--4IGmLeE.js +1 -0
- package/page/assets/tree-CcEbNvms.js +3 -0
- package/page/assets/turn-client-BmOSpCgw.js +2 -0
- package/page/assets/{use-one-call-DE5HvQsv.js → use-one-call-B3t-kfc5.js} +1 -1
- package/page/assets/{use-second-ticker-CEwOSS-d.js → use-second-ticker-CWjCHLG6.js} +1 -1
- package/page/assets/workspace-DUfaxr-g.js +1 -0
- package/page/index.html +20 -19
- package/people.d.ts +2 -0
- package/people.js +3 -1
- package/policy.js +1 -0
- package/providers.d.ts +2 -2
- package/providers.js +8 -3
- package/read-source.js +34 -7
- package/registrations.d.ts +23 -3
- package/runtime-scope.d.ts +6 -3
- package/runtime-scope.js +16 -4
- package/runtime.js +14 -2
- package/server/draft-handler.d.ts +4 -4
- package/server/draft-handler.js +3 -2
- package/server/draft-probe.d.ts +9 -1
- package/server/draft-probe.js +2 -1
- package/server/handler.js +71 -25
- package/server/live.d.ts +7 -1
- package/server/live.js +11 -4
- package/server/run-traces.d.ts +5 -1
- package/server/run-traces.js +7 -3
- package/server/save-new.js +5 -5
- package/server/save-session.js +4 -2
- package/server/serve.js +2 -1
- package/server/test-key.d.ts +2 -2
- package/server/test-key.js +1 -1
- package/slot-values.d.ts +2 -0
- package/slot-values.js +22 -0
- package/source.js +11 -4
- package/tool-readers.d.ts +23 -0
- package/tool-readers.js +60 -0
- package/tools.js +4 -1
- package/types.d.ts +3 -1
- package/ui/inspector-context.js +1 -1
- package/ui/lib/project-traces.d.ts +5 -0
- package/ui/lib/project-traces.js +21 -3
- package/ui/lib/studio-page.d.ts +6 -1
- package/ui/lib/studio-page.js +33 -31
- package/ui/lib/studio-project.d.ts +8 -1
- package/ui/lib/studio-project.js +19 -1
- package/ui/lib/studio-session.d.ts +2 -0
- package/ui/lib/studio-session.js +40 -2
- package/ui/lib/studio-store.d.ts +2 -2
- package/ui/lib/studio-store.js +9 -5
- package/ui/lib/tool-probe.d.ts +2 -0
- package/ui/lib/tool-probe.js +3 -2
- package/ui/lib/type-icons.d.ts +1 -0
- package/ui/lib/type-icons.js +2 -1
- package/ui/profile-editor.js +57 -21
- package/ui/studio-compare.d.ts +14 -4
- package/ui/studio-compare.js +58 -24
- package/ui/studio-live.d.ts +1 -1
- package/ui/studio-live.js +8 -3
- package/ui/studio-runner.d.ts +3 -2
- package/ui/studio-runner.js +16 -14
- package/ui/studio-screen.d.ts +1 -1
- package/ui/studio-screen.js +26 -20
- package/ui/studio-settings.js +3 -1
- package/ui/studio-trace-replay.js +7 -1
- package/workspace.js +3 -2
- package/page/assets/Banner-BkgdSxW_.js +0 -4
- package/page/assets/Center-nHS1JSux.js +0 -1
- package/page/assets/browser-connection-DSUHVCT5.js +0 -3
- package/page/assets/browser-engine-D1mbS8b9.js +0 -11
- package/page/assets/browser-transport-C8PD0IJk.js +0 -45
- package/page/assets/index-B7om06iO.js +0 -145
- package/page/assets/live-messages-CiLmR89m.js +0 -1
- package/page/assets/reader-DrOfMM8I.js +0 -5
- package/page/assets/shaped-data-H1miOZm2.js +0 -20
- package/page/assets/studio-code-pane-DA_z5w6h.js +0 -8
- package/page/assets/studio-decision-DWnr99n-.js +0 -1
- package/page/assets/studio-embedding-DCvI007w.js +0 -2
- package/page/assets/studio-live-CnyzlN29.js +0 -5
- package/page/assets/studio-map-DduCJzK7.js +0 -1
- package/page/assets/studio-session-CjUQSXx0.js +0 -1
- package/page/assets/studio-trace-replay-C0UPMVSt.js +0 -3
- package/page/assets/tool-schema-BmRYaywn.js +0 -17
- package/page/assets/trace-schema-9CdEyG6Q.js +0 -1
- package/page/assets/tree-3N-1RPZz.js +0 -3
- package/page/assets/turn-client-DN8PawJr.js +0 -2
- package/page/assets/workspace-CTSW941G.js +0 -1
package/draft.d.ts
CHANGED
|
@@ -15,14 +15,19 @@ export type StudioProfileType = ProfileType;
|
|
|
15
15
|
/** The types that run a model turn; a decision asks questions, and a host runs its tools. */
|
|
16
16
|
export type StudioTurnProfileType = Exclude<StudioProfileType, 'decision' | 'host'>;
|
|
17
17
|
export declare const STUDIO_PROFILE_TYPES: readonly StudioProfileType[];
|
|
18
|
+
/** One line of the prompt, with private sections wrapped as `{private: …}`. */
|
|
19
|
+
export interface SystemLineDraft {
|
|
20
|
+
key: string;
|
|
21
|
+
text: string;
|
|
22
|
+
}
|
|
18
23
|
export interface IdentityDraft {
|
|
19
24
|
agentId: string;
|
|
20
25
|
profileType: StudioProfileType | '';
|
|
21
26
|
handle: string;
|
|
22
|
-
/**
|
|
23
|
-
system:
|
|
24
|
-
/**
|
|
25
|
-
|
|
27
|
+
/** Unused on speech, which has no system channel. */
|
|
28
|
+
system: SystemLineDraft[];
|
|
29
|
+
/** The facts each turn states, as a JSON object of lists of values; blank omits them. */
|
|
30
|
+
conditionsJson: string;
|
|
26
31
|
}
|
|
27
32
|
export interface ModelsDraft {
|
|
28
33
|
/** Who holds the conversation a saved state continues; unset is the kernel's default, the host. */
|
|
@@ -176,10 +181,20 @@ export interface InputsDraft {
|
|
|
176
181
|
/** The longest context package from each sender, in characters of JSON. */
|
|
177
182
|
contextMaxChars: number | null;
|
|
178
183
|
}
|
|
184
|
+
/** The reply shapes a slot's value picks; any other value takes the outputs' own schema. */
|
|
185
|
+
export interface SlotShapesDraft {
|
|
186
|
+
slot: string;
|
|
187
|
+
shapes: {
|
|
188
|
+
choice: string;
|
|
189
|
+
schemaId: string;
|
|
190
|
+
schemaJson: string;
|
|
191
|
+
}[];
|
|
192
|
+
}
|
|
179
193
|
export interface OutputsDraft {
|
|
180
194
|
mode: 'text' | 'structured';
|
|
181
195
|
schemaId: string;
|
|
182
196
|
schemaJson: string;
|
|
197
|
+
bySlot?: SlotShapesDraft;
|
|
183
198
|
/** `''` omits it (kernel default: SSE). */
|
|
184
199
|
streamMode: '' | StreamMode;
|
|
185
200
|
streamThoughts: boolean;
|
|
@@ -404,7 +419,7 @@ export interface StudioDraft {
|
|
|
404
419
|
decision: DecisionDraft;
|
|
405
420
|
labels: LabelsDraft;
|
|
406
421
|
}
|
|
407
|
-
export declare function draftKey(prefix: 'agent' | 'model' | 'tool' | 'question' | 'criterion' | 'reference' | 'image' | 'slot' | 'choice'): string;
|
|
422
|
+
export declare function draftKey(prefix: 'agent' | 'line' | 'model' | 'tool' | 'question' | 'criterion' | 'reference' | 'image' | 'slot' | 'choice'): string;
|
|
408
423
|
export declare function defaultModelBinding(partial?: Partial<ModelBindingDraft>): ModelBindingDraft;
|
|
409
424
|
export declare function defaultToolSpec(partial?: Partial<ToolSpecDraft>): ToolSpecDraft;
|
|
410
425
|
/**
|
|
@@ -438,6 +453,7 @@ export declare function newDecisionImage(draft: StudioDraft, file: string, image
|
|
|
438
453
|
}): DecisionImageDraft;
|
|
439
454
|
/** A new slot, with a name the draft doesn't use yet and two blank choices. */
|
|
440
455
|
export declare function newSlot(slots: readonly SlotDraft[]): SlotDraft;
|
|
456
|
+
export declare function newSystemLine(text?: string): SystemLineDraft;
|
|
441
457
|
export declare function newSlotChoice(): SlotChoiceDraft;
|
|
442
458
|
/** One blank row: an option, a level, or a criterion. */
|
|
443
459
|
export declare function newCriterion(): DecisionCriterionDraft;
|
package/draft.js
CHANGED
|
@@ -247,6 +247,9 @@ export function newSlot(slots) {
|
|
|
247
247
|
const name = freeName('slot', slots.map((slot) => slot.name), (n) => `slot_${String(n)}`);
|
|
248
248
|
return { key: draftKey('slot'), name, label: '', choices: [newSlotChoice(), newSlotChoice()] };
|
|
249
249
|
}
|
|
250
|
+
export function newSystemLine(text = '') {
|
|
251
|
+
return { key: draftKey('line'), text };
|
|
252
|
+
}
|
|
250
253
|
export function newSlotChoice() {
|
|
251
254
|
return { key: draftKey('choice'), value: '', description: '' };
|
|
252
255
|
}
|
|
@@ -275,7 +278,13 @@ export function newCriteria(type) {
|
|
|
275
278
|
*/
|
|
276
279
|
export function createBlankDraft() {
|
|
277
280
|
return {
|
|
278
|
-
identity: {
|
|
281
|
+
identity: {
|
|
282
|
+
agentId: '',
|
|
283
|
+
profileType: '',
|
|
284
|
+
handle: '',
|
|
285
|
+
system: [newSystemLine()],
|
|
286
|
+
conditionsJson: '',
|
|
287
|
+
},
|
|
279
288
|
included: ['observability', 'labels'],
|
|
280
289
|
models: { defaultModel: '', allowModelSelect: false, maxSteps: null, key: '' },
|
|
281
290
|
modelBindings: [],
|
|
@@ -402,6 +411,15 @@ function imageInputs(inputs) {
|
|
|
402
411
|
voiceAccept: [],
|
|
403
412
|
};
|
|
404
413
|
}
|
|
414
|
+
/** Inputs a transcription profile can take: a voice clip and nothing else. */
|
|
415
|
+
function transcriptionInputs(inputs) {
|
|
416
|
+
return {
|
|
417
|
+
...inputs,
|
|
418
|
+
text: false,
|
|
419
|
+
attachmentsAccept: [],
|
|
420
|
+
voiceAccept: inputs.voiceAccept.length ? inputs.voiceAccept : ['audio/*'],
|
|
421
|
+
};
|
|
422
|
+
}
|
|
405
423
|
/** Updates a binding and keeps the default model attached to it through an id change. */
|
|
406
424
|
export function updateModelBinding(draft, bindingKey, change) {
|
|
407
425
|
const binding = draft.modelBindings.find((candidate) => candidate.key === bindingKey);
|
|
@@ -492,7 +510,11 @@ export function setProfileType(draft, type, keys) {
|
|
|
492
510
|
modelBindings.some((binding) => isGoogleRoute(modelRoute(draft.providers, type, binding)));
|
|
493
511
|
return {
|
|
494
512
|
...retyped,
|
|
495
|
-
inputs: type === 'image'
|
|
513
|
+
inputs: type === 'image'
|
|
514
|
+
? imageInputs(draft.inputs)
|
|
515
|
+
: type === 'transcription'
|
|
516
|
+
? transcriptionInputs(draft.inputs)
|
|
517
|
+
: draft.inputs,
|
|
496
518
|
...(voiceless ? { speech: { ...draft.speech, voice: GOOGLE_STARTING_VOICE } } : {}),
|
|
497
519
|
models: {
|
|
498
520
|
...draft.models,
|
|
@@ -508,6 +530,7 @@ const MODEL_PROFILE_TYPES = [
|
|
|
508
530
|
'text',
|
|
509
531
|
'image',
|
|
510
532
|
'speech',
|
|
533
|
+
'transcription',
|
|
511
534
|
'live',
|
|
512
535
|
'decision',
|
|
513
536
|
];
|
package/guardrail-probe.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @module
|
|
9
9
|
*/
|
|
10
|
-
import { type ProfileDefinition, type TraceRecord } from '@theoremjs/agents';
|
|
10
|
+
import { type ProfileDefinition, type RegisteredProvider, type TraceRecord } from '@theoremjs/agents';
|
|
11
11
|
import { type ErrorKind, type GuardrailEvent } from '@theoremjs/agents/guardrails';
|
|
12
12
|
import type { StructuredRegistration, ToolRegistration } from './registrations.ts';
|
|
13
13
|
import { type StudioDependency } from './runtime-scope.ts';
|
|
@@ -82,6 +82,8 @@ export declare function runGuardrailProbe(args: {
|
|
|
82
82
|
customTools: readonly ToolRegistration[];
|
|
83
83
|
structured?: StructuredRegistration;
|
|
84
84
|
dependencies?: readonly StudioDependency[];
|
|
85
|
+
/** The project's own providers, which the draft's models may name. */
|
|
86
|
+
projectProviders?: readonly RegisteredProvider[];
|
|
85
87
|
probe: GuardrailProbe;
|
|
86
88
|
signal?: AbortSignal;
|
|
87
89
|
}): Promise<GuardrailProbeResult>;
|
package/guardrail-probe.js
CHANGED
|
@@ -12,6 +12,7 @@ import { actionAt, DETECTORS, resolveDetect, sanitizeTurnRequestWithEvents, TOOL
|
|
|
12
12
|
import { ANSWER_TOOL, keySlotsOf, } from '@theoremjs/agents/kernel';
|
|
13
13
|
import { firstServed } from "./policy.js";
|
|
14
14
|
import { agentCallHook, runtimeProvider, writtenScope, } from "./runtime-scope.js";
|
|
15
|
+
import { choiceValues } from "./slot-values.js";
|
|
15
16
|
import { sampleFromJsonSchema } from "./tool-schema.js";
|
|
16
17
|
/** Where a probe's text enters the turn. */
|
|
17
18
|
export const PROBE_BOUNDARIES = [
|
|
@@ -600,7 +601,10 @@ function probeStatus(guardrails, refused) {
|
|
|
600
601
|
/** Throws when `profile` cannot be sent `probe`: it is refused, has no such boundary, or the text is too long. */
|
|
601
602
|
function assertProbeable(profile, probe) {
|
|
602
603
|
const refusal = probeRefusal(profile);
|
|
603
|
-
if (refusal ||
|
|
604
|
+
if (refusal ||
|
|
605
|
+
profile.type === 'decision' ||
|
|
606
|
+
profile.type === 'embedding' ||
|
|
607
|
+
profile.type === 'transcription') {
|
|
604
608
|
throw new TheoremError('request', refusal ?? ''); // labels-exempt: builder diagnostic
|
|
605
609
|
}
|
|
606
610
|
if (!probeBoundariesOf(profile).includes(probe.boundary)) {
|
|
@@ -611,15 +615,43 @@ function assertProbeable(profile, probe) {
|
|
|
611
615
|
throw new TheoremError('request', `A probe is at most ${PROBE_TEXT_LIMIT} characters.`); // labels-exempt: builder diagnostic
|
|
612
616
|
}
|
|
613
617
|
}
|
|
618
|
+
/**
|
|
619
|
+
* What a turn of `definition` states, each on its first value, as the studio's page opens them.
|
|
620
|
+
* why: The kernel refuses a turn that leaves a prompt line's condition or slot unset, and a probe
|
|
621
|
+
* has no page to pick them.
|
|
622
|
+
*/
|
|
623
|
+
function statedByFirstValues(definition) {
|
|
624
|
+
const inputs = 'inputs' in definition ? definition.inputs : undefined;
|
|
625
|
+
const declaredSlots = inputs && 'slots' in inputs ? inputs.slots : undefined;
|
|
626
|
+
const slots = Object.entries(declaredSlots ?? {}).flatMap(([name, decl]) => {
|
|
627
|
+
const value = choiceValues(decl)?.[0];
|
|
628
|
+
return value === undefined ? [] : [[name, value]];
|
|
629
|
+
});
|
|
630
|
+
const identity = 'identity' in definition ? definition.identity : undefined;
|
|
631
|
+
const declared = identity && 'conditions' in identity ? identity.conditions : undefined;
|
|
632
|
+
const { path, ...conditions } = Object.fromEntries(Object.entries(declared ?? {}).map(([name, values]) => [name, values[0] ?? '']));
|
|
633
|
+
return {
|
|
634
|
+
slots: Object.fromEntries(slots),
|
|
635
|
+
turn: {
|
|
636
|
+
...(path === undefined ? {} : { path }),
|
|
637
|
+
...(declared ? { conditions } : {}),
|
|
638
|
+
},
|
|
639
|
+
};
|
|
640
|
+
}
|
|
614
641
|
/** Where a probe runs: a host or a live agent calls the tool, any other takes a turn. */
|
|
615
642
|
function probeStream(run) {
|
|
616
643
|
const { scope, profile, probe, signal, onAgentCall, sink } = run;
|
|
617
|
-
if (run.type === 'host' || run.type === 'live') {
|
|
644
|
+
if (run.definition.type === 'host' || run.definition.type === 'live') {
|
|
618
645
|
return scope.invokeTool({ profile: profile.id, ...hostCall(probe), signal, onAgentCall }, sink);
|
|
619
646
|
}
|
|
647
|
+
const stated = statedByFirstValues(run.definition);
|
|
620
648
|
return scope.runTurn({
|
|
621
649
|
profile: profile.id,
|
|
622
|
-
input:
|
|
650
|
+
input: {
|
|
651
|
+
...turnInput(probe),
|
|
652
|
+
...(Object.keys(stated.slots).length ? { slots: stated.slots } : {}),
|
|
653
|
+
},
|
|
654
|
+
...stated.turn,
|
|
623
655
|
...(probe.boundary === 'system' ? { system: probe.text } : {}),
|
|
624
656
|
signal,
|
|
625
657
|
onAgentCall,
|
|
@@ -651,7 +683,7 @@ export async function runGuardrailProbe(args) {
|
|
|
651
683
|
...(args.dependencies ?? []),
|
|
652
684
|
...(asked.type === 'speech' || asked.type === 'live' ? [] : [remoteAgent(asked)]),
|
|
653
685
|
probedDraft(asked, args.customTools, args.structured, probe.text),
|
|
654
|
-
]);
|
|
686
|
+
], args.projectProviders);
|
|
655
687
|
if (!profile)
|
|
656
688
|
throw new TheoremError('request', 'No agent to probe.'); // labels-exempt: builder diagnostic
|
|
657
689
|
const seen = [];
|
|
@@ -683,7 +715,7 @@ export async function runGuardrailProbe(args) {
|
|
|
683
715
|
: probeStream({
|
|
684
716
|
scope,
|
|
685
717
|
profile,
|
|
686
|
-
|
|
718
|
+
definition: asked,
|
|
687
719
|
probe,
|
|
688
720
|
signal: args.signal,
|
|
689
721
|
onAgentCall,
|
package/mod.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { type StudioAsks, type WriteAsk, writeAsk, writeAskLine } from './asks.ts';
|
|
2
2
|
export { KNOWN_GEMINI_EMBEDDING_MODELS, KNOWN_OPENROUTER_EMBEDDING_MODELS, } from './browser-connection.ts';
|
|
3
|
-
export { type CompiledStudio, compileStudio, credentialHeaderProblem, credentialUrlProblem, type StudioCompileResult, type StudioIssue, type StudioProfileDefinition, type StudioTurnProfileDefinition, } from './compile.ts';
|
|
3
|
+
export { type CompiledStudio, compileStudio, credentialHeaderProblem, credentialUrlProblem, draftConditions, type StudioCompileResult, type StudioIssue, type StudioProfileDefinition, type StudioTurnProfileDefinition, } from './compile.ts';
|
|
4
4
|
export { type CompiledWorkspace, compileWorkspace, type WorkspaceCompileResult, workspaceRunAgent, } from './compile-workspace.ts';
|
|
5
5
|
export type { CookbookEntry, CookbookId, CookbookIncludeTag, CookbookTags, GoogleBindingViolation, GoogleFreeTierGrounding, GoogleImageAspectRatio, GoogleImageInputMime, GoogleImageOutputMime, GoogleImagePins, GoogleImageResolution, GoogleLivePins, GoogleSpeechPins, GoogleSpeechVoice, GoogleThinkingLevel, GoogleVoiceInputMime, LocalBindingViolation, ProfileSliceOptions, StitchRecipe, ToolSliceField, ToolSliceOptions, } from './cookbooks/mod.ts';
|
|
6
6
|
export { addArchitectExample, addResearchExample, COOKBOOK_IDS, COOKBOOK_TOOL_HANDLERS, COOKBOOKS, cookbookOpening, cookbookTraceRecords, createArchitectWorkspace, createConsoleExampleDraft, createDecisionExampleDraft, createExampleDraft, createGeminiEmbeddingExampleDraft, createLiveExampleDraft, createNarratorExampleDraft, createPageReaderExampleDraft, createResearchScoutDraft, createResearchWorkspace, DECISION_EXAMPLE_AGENT_ID, DECISION_EXAMPLE_STATE, DEMO_ALLOWED_HOSTS, DEMO_ARCHITECT_SYSTEM, DEMO_ARCHITECT_TOOLS, DEMO_CONCIERGE_SYSTEM, DEMO_CONCIERGE_TOOLS, DEMO_CONSOLE_TOOLS, DEMO_HTTP_SAMPLE_INPUT, DEMO_LIVE_CONCIERGE_SYSTEM, DEMO_RESEARCH_STAGE_READ_TOOLS, DEMO_RESEARCH_SYSTEM, DEMO_RESEARCH_TOOLS, DISCOVER_LOADED, decisionExampleAssets, decisionExampleDraft, demoHttpSampleInput, demoInputsSpec, demoToolSpecs, exampleTools, GEMINI_MODELS_URL, GOOGLE_BUILTIN_TOOLS, GOOGLE_FREE_TIER_GROUNDING, GOOGLE_IMAGE_ASPECT_RATIOS, GOOGLE_IMAGE_INPUT_MIMES, GOOGLE_IMAGE_OUTPUT_MIMES, GOOGLE_IMAGE_RESOLUTIONS, GOOGLE_NO_EFFORT_API_IDS, GOOGLE_NO_THINKING_API_IDS, GOOGLE_SINGLE_TURN_API_IDS, GOOGLE_SPEECH_FORMATS, GOOGLE_SPEECH_VOICES, GOOGLE_THINKING_LEVELS, GOOGLE_THINKING_REQUIRED_API_IDS, GOOGLE_VOICE_INPUT_MIMES, googleBindingViolation, googleEfforts, googleFreeTierBuiltins, localBindingViolation, OPENROUTER_BUILTIN_TOOLS, OPENROUTER_IMAGES_IGNORED_INPUTS, OPENROUTER_IMAGES_INPUT_MIMES, ollamaModelThinks, projectProfileSlice, projectToolSlice, RESEARCH_ALLOWED_HOSTS, RESEARCH_FIRST_TURN_PROMPT, RESEARCH_PAGE_READER_AGENT_ID, RESEARCH_PAGE_READER_STATE, RESEARCH_REPLY_SCHEMA_ID, RESEARCH_REPLY_SCHEMA_JSON, resolveCookbookSlice, stitchCookbook, } from './cookbooks/mod.ts';
|
|
7
|
-
export { agentToolTarget, COMPACTION_DRAFT_DEFAULTS, createBlankDraft, type DecisionCriterionDraft, type DecisionDraft, type DecisionImageDraft, type DecisionQuestionDraft, type DecisionQuestionType, defaultModelBinding, defaultToolSpec, draftAllows, draftFacets, draftKey, type EffortDraft, EXAMPLE_DECISION_STATE, EXAMPLE_EMBEDDING_QUERY, EXAMPLE_EMBEDDING_TEXT, EXAMPLE_SPAN_DECISION_STATE, exampleDecisionDraft, excludeFacet, type GuardrailsDraft, type IdentityDraft, type ImageDraft, type ImageReferenceDraft, INLINE_LABELS, type InputsDraft, type ItemRuleOnFail, includableFacets, includeFacet, type LabelsDraft, type LiveDraft, MODEL_LIMITS, type ModelBindingDraft, type ModelsDraft, newCriteria, newCriterion, newDecisionImage, newDecisionQuestion, newModelBinding, newOwnDetector, newPattern, newSlot, newSlotChoice, newToolSpec, type ObservabilityDraft, type OutputsDraft, type OwnDetectorDraft, type PatternDraft, type PatternSourceDraft, plantsCanary, removeModelBinding, type SlotChoiceDraft, type SlotDraft, type SpeechDraft, STUDIO_PROFILE_TYPES, type StudioDraft, type StudioProfileType, type StudioTurnProfileType, setProfileType, TIMER_MAX_MS, type ToolSpecDraft, type ToolsDraft, type TurnBehaviourDraft, takesContinueInstruction, updateModelBinding, } from './draft.ts';
|
|
7
|
+
export { agentToolTarget, COMPACTION_DRAFT_DEFAULTS, createBlankDraft, type DecisionCriterionDraft, type DecisionDraft, type DecisionImageDraft, type DecisionQuestionDraft, type DecisionQuestionType, defaultModelBinding, defaultToolSpec, draftAllows, draftFacets, draftKey, type EffortDraft, EXAMPLE_DECISION_STATE, EXAMPLE_EMBEDDING_QUERY, EXAMPLE_EMBEDDING_TEXT, EXAMPLE_SPAN_DECISION_STATE, exampleDecisionDraft, excludeFacet, type GuardrailsDraft, type IdentityDraft, type ImageDraft, type ImageReferenceDraft, INLINE_LABELS, type InputsDraft, type ItemRuleOnFail, includableFacets, includeFacet, type LabelsDraft, type LiveDraft, MODEL_LIMITS, type ModelBindingDraft, type ModelsDraft, newCriteria, newCriterion, newDecisionImage, newDecisionQuestion, newModelBinding, newOwnDetector, newPattern, newSlot, newSlotChoice, newSystemLine, newToolSpec, type ObservabilityDraft, type OutputsDraft, type OwnDetectorDraft, type PatternDraft, type PatternSourceDraft, plantsCanary, removeModelBinding, type SlotChoiceDraft, type SlotDraft, type SpeechDraft, STUDIO_PROFILE_TYPES, type StudioDraft, type StudioProfileType, type StudioTurnProfileType, type SystemLineDraft, setProfileType, TIMER_MAX_MS, type ToolSpecDraft, type ToolsDraft, type TurnBehaviourDraft, takesContinueInstruction, updateModelBinding, } from './draft.ts';
|
|
8
8
|
export { EXAMPLE_EMBEDDING_FILES } from './example-embedding-files.ts';
|
|
9
9
|
export type { GuardrailProbe, GuardrailProbeAnswer, GuardrailProbeDraft, GuardrailProbeResult, ProbeBoundary, ProbeBoundaryNote, ProbeStatus, } from './guardrail-probe.ts';
|
|
10
10
|
export { PROBE_BOUNDARIES, PROBE_BOUNDARY_NOTES, PROBE_STATUSES, PROBE_TEXT_LIMIT, probeDraft, probeRefusal, runGuardrailProbe, runGuardrailProbes, } from './guardrail-probe.ts';
|
package/mod.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { writeAsk, writeAskLine } from "./asks.js";
|
|
2
2
|
export { KNOWN_GEMINI_EMBEDDING_MODELS, KNOWN_OPENROUTER_EMBEDDING_MODELS, } from "./browser-connection.js";
|
|
3
|
-
export { compileStudio, credentialHeaderProblem, credentialUrlProblem, } from "./compile.js";
|
|
3
|
+
export { compileStudio, credentialHeaderProblem, credentialUrlProblem, draftConditions, } from "./compile.js";
|
|
4
4
|
export { compileWorkspace, workspaceRunAgent, } from "./compile-workspace.js";
|
|
5
5
|
export { addArchitectExample, addResearchExample, COOKBOOK_IDS, COOKBOOK_TOOL_HANDLERS, COOKBOOKS, cookbookOpening, cookbookTraceRecords, createArchitectWorkspace, createConsoleExampleDraft, createDecisionExampleDraft, createExampleDraft, createGeminiEmbeddingExampleDraft, createLiveExampleDraft, createNarratorExampleDraft, createPageReaderExampleDraft, createResearchScoutDraft, createResearchWorkspace, DECISION_EXAMPLE_AGENT_ID, DECISION_EXAMPLE_STATE, DEMO_ALLOWED_HOSTS, DEMO_ARCHITECT_SYSTEM, DEMO_ARCHITECT_TOOLS, DEMO_CONCIERGE_SYSTEM, DEMO_CONCIERGE_TOOLS, DEMO_CONSOLE_TOOLS, DEMO_HTTP_SAMPLE_INPUT, DEMO_LIVE_CONCIERGE_SYSTEM, DEMO_RESEARCH_STAGE_READ_TOOLS, DEMO_RESEARCH_SYSTEM, DEMO_RESEARCH_TOOLS, DISCOVER_LOADED, decisionExampleAssets, decisionExampleDraft, demoHttpSampleInput, demoInputsSpec, demoToolSpecs, exampleTools, GEMINI_MODELS_URL, GOOGLE_BUILTIN_TOOLS, GOOGLE_FREE_TIER_GROUNDING, GOOGLE_IMAGE_ASPECT_RATIOS, GOOGLE_IMAGE_INPUT_MIMES, GOOGLE_IMAGE_OUTPUT_MIMES, GOOGLE_IMAGE_RESOLUTIONS, GOOGLE_NO_EFFORT_API_IDS, GOOGLE_NO_THINKING_API_IDS, GOOGLE_SINGLE_TURN_API_IDS, GOOGLE_SPEECH_FORMATS, GOOGLE_SPEECH_VOICES, GOOGLE_THINKING_LEVELS, GOOGLE_THINKING_REQUIRED_API_IDS, GOOGLE_VOICE_INPUT_MIMES, googleBindingViolation, googleEfforts, googleFreeTierBuiltins, localBindingViolation, OPENROUTER_BUILTIN_TOOLS, OPENROUTER_IMAGES_IGNORED_INPUTS, OPENROUTER_IMAGES_INPUT_MIMES, ollamaModelThinks, projectProfileSlice, projectToolSlice, RESEARCH_ALLOWED_HOSTS, RESEARCH_FIRST_TURN_PROMPT, RESEARCH_PAGE_READER_AGENT_ID, RESEARCH_PAGE_READER_STATE, RESEARCH_REPLY_SCHEMA_ID, RESEARCH_REPLY_SCHEMA_JSON, resolveCookbookSlice, stitchCookbook, } from "./cookbooks/mod.js";
|
|
6
|
-
export { agentToolTarget, COMPACTION_DRAFT_DEFAULTS, createBlankDraft, defaultModelBinding, defaultToolSpec, draftAllows, draftFacets, draftKey, EXAMPLE_DECISION_STATE, EXAMPLE_EMBEDDING_QUERY, EXAMPLE_EMBEDDING_TEXT, EXAMPLE_SPAN_DECISION_STATE, exampleDecisionDraft, excludeFacet, INLINE_LABELS, includableFacets, includeFacet, MODEL_LIMITS, newCriteria, newCriterion, newDecisionImage, newDecisionQuestion, newModelBinding, newOwnDetector, newPattern, newSlot, newSlotChoice, newToolSpec, plantsCanary, removeModelBinding, STUDIO_PROFILE_TYPES, setProfileType, TIMER_MAX_MS, takesContinueInstruction, updateModelBinding, } from "./draft.js";
|
|
6
|
+
export { agentToolTarget, COMPACTION_DRAFT_DEFAULTS, createBlankDraft, defaultModelBinding, defaultToolSpec, draftAllows, draftFacets, draftKey, EXAMPLE_DECISION_STATE, EXAMPLE_EMBEDDING_QUERY, EXAMPLE_EMBEDDING_TEXT, EXAMPLE_SPAN_DECISION_STATE, exampleDecisionDraft, excludeFacet, INLINE_LABELS, includableFacets, includeFacet, MODEL_LIMITS, newCriteria, newCriterion, newDecisionImage, newDecisionQuestion, newModelBinding, newOwnDetector, newPattern, newSlot, newSlotChoice, newSystemLine, newToolSpec, plantsCanary, removeModelBinding, STUDIO_PROFILE_TYPES, setProfileType, TIMER_MAX_MS, takesContinueInstruction, updateModelBinding, } from "./draft.js";
|
|
7
7
|
export { EXAMPLE_EMBEDDING_FILES } from "./example-embedding-files.js";
|
|
8
8
|
export { PROBE_BOUNDARIES, PROBE_BOUNDARY_NOTES, PROBE_STATUSES, PROBE_TEXT_LIMIT, probeDraft, probeRefusal, runGuardrailProbe, runGuardrailProbes, } from "./guardrail-probe.js";
|
|
9
9
|
export { unheldProblem } from "./held-credentials.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theoremjs/studio",
|
|
3
|
-
"version": "0.3.4-next.
|
|
3
|
+
"version": "0.3.4-next.693.g4ab1526",
|
|
4
4
|
"description": "Theorem Studio: open a project's agents in a local studio on Deno, edit and run them, and save back to its files; or show the studio screen in a Vite app.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -77,9 +77,9 @@
|
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
79
|
"zod": "^4.6.5",
|
|
80
|
-
"@theoremjs/agents": "0.3.4-next.
|
|
81
|
-
"@theoremjs/web": "0.3.4-next.
|
|
82
|
-
"@theoremjs/react": "0.3.4-next.
|
|
80
|
+
"@theoremjs/agents": "0.3.4-next.693.g4ab1526",
|
|
81
|
+
"@theoremjs/web": "0.3.4-next.693.g4ab1526",
|
|
82
|
+
"@theoremjs/react": "0.3.4-next.693.g4ab1526"
|
|
83
83
|
},
|
|
84
84
|
"peerDependenciesMeta": {
|
|
85
85
|
"@theoremjs/react": {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TraceInspector-36e6ozKD.js","assets/rolldown-runtime-hePW80VL.js","assets/themeProps-3IqahpCr.js","assets/tokens.stylex-DkHf0P9C.js","assets/SegmentedControlItem-CZs-ycSA.js","assets/padding.stylex-B76907Zf.js","assets/VStack-CkVMcNiK.js","assets/mergeProps-ptS-gIMz.js","assets/StackItem-CQviqAfM.js","assets/useLayerDismissal-BAnTRYTt.js","assets/fieldParts-CoOpDoax.js","assets/Icon-BqkS-pIq.js","assets/devWarning-DxuplmRl.js","assets/Text-BOqCfzZC.js","assets/sharedResizeObserver-4U9Xq5Oq.js","assets/preload-helper-DpV6A1kQ.js","assets/useMediaQuery-BCT0NUeZ.js","assets/useResolvedRequired-DbsOcDqy.js","assets/useAnnounce-DTSHZvjg.js","assets/Tooltip-BWs5DLrM.js","assets/useTooltip-c097gL_-.js","assets/focusOutline.stylex-BT0kfa4t.js","assets/IconButton-DVUFx-8p.js","assets/focusableSelector-DXZeMU85.js","assets/useDevWarning-Z9SoixOP.js","assets/createReactComponent-CZwsv6DD.js","assets/isRtlElement-BG33-k_H.js","assets/plainDate-BHiJcj7o.js","assets/DateInput-CalwZl6a.js","assets/focusReturn-CTppP2k0.js","assets/Card-DruykyeB.js","assets/container.stylex-BmOi-8DQ.js","assets/ScrollableArea-ChTx-OVZ.js","assets/useScrollableArea-DuF_pz9m.js","assets/chainEventHandlers-C6ttXGfW.js","assets/BottomSheet-Dbh6A5Vl.js","assets/useScrollLock-Dyf6PHJt.js","assets/SidePanel-DEd3R1Q3.js","assets/CheckboxInput-CFZ_Wq8-.js","assets/isRenderable-DHkzpAoQ.js","assets/IconAlertTriangle-BqAEqqdU.js","assets/row-keys-WByP9Hsh.js","assets/IconShield-DDOh7Gr5.js","assets/shaped-data-CJQ3W_RE.js","assets/host-patterns-F-KZIzkF.js","assets/trace-record-DoXjxrmJ.js","assets/TraceOverview-CSdJ_cYY.js","assets/labels-provider-t4c-5JMk.js","assets/CodeBlock-CfVOtDeO.js","assets/useClipboard-CbN9bb4J.js","assets/index-B7sK7d-l.js","assets/browser-transport-GzhRiBdm.js","assets/Center-CgO0c-qo.js","assets/IconSearch-BTx66a40.js","assets/schemas-D7cgkv3L.js","assets/tool-schema-BDG2_rlP.js","assets/reader-DHN96tSr.js","assets/browser-connection-dads1eyK.js","assets/live-ingress-OuSlQ6q7.js","assets/trace-schema--4IGmLeE.js","assets/stub-U6wDGe3P.js","assets/Dialog-Sd04KQS2.js","assets/HoverCard-DMyWUvwP.js","assets/IconEye-BB5aY-wQ.js","assets/studio-labels-jYWBoEyP.js","assets/turn-client-BmOSpCgw.js","assets/encode-files-CHeRLBO8.js","assets/CollapsibleGroup-BsIYDnJR.js","assets/tree-CcEbNvms.js","assets/crypto-B8dqEoWf.js","assets/use-second-ticker-CWjCHLG6.js","assets/use-second-ticker-GWBt83pd.css","assets/workspace-DUfaxr-g.js","assets/lent-keys-C32ems-I.js","assets/editors-BJX_S59A.js","assets/project-address-DjxPZuyn.js","assets/studio-session-CPnJaHc-.js","assets/EmptyState-C_uF9Wyj.js","assets/useMenuPress-DLG1QOiE.js","assets/useAdaptivePresentation-Bma4-u1a.js","assets/useFocusReturnVisibility-BHKv5Jwr.js","assets/ListItem-QF7KFt0h.js","assets/index-C9rhrCGT.css","assets/trace-patterns-D6TbkLLr.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,l as n,n as r,u as i}from"./themeProps-3IqahpCr.js";import{h as a}from"./tokens.stylex-DkHf0P9C.js";import{t as o}from"./mergeProps-ptS-gIMz.js";import{b as s}from"./fieldParts-CoOpDoax.js";import{t as c}from"./isRenderable-DHkzpAoQ.js";import{t as l,x as u}from"./Icon-BqkS-pIq.js";import{T as d,c as f,d as p,l as m,m as h,p as g,s as _,t as v,u as y}from"./SidePanel-DEd3R1Q3.js";import{t as b}from"./preload-helper-DpV6A1kQ.js";import{n as ee,t as te}from"./labels-provider-t4c-5JMk.js";import{c as ne,n as re}from"./IconButton-DVUFx-8p.js";import{t as x}from"./createReactComponent-CZwsv6DD.js";import{a as ie}from"./ScrollableArea-ChTx-OVZ.js";import{F as ae,R as S,St as oe,Y as C,_ as se,h as w,i as T,j as E,q as D,v as ce,vn as O,z as k}from"./tool-schema-BDG2_rlP.js";import{c as A,r as le}from"./host-patterns-F-KZIzkF.js";import{Gn as j,Pn as M,Rn as N,Rr as ue,Sr as P,Un as F,Vn as de,an as fe,gr as I,in as pe,jn as me,vr as he}from"./shaped-data-CJQ3W_RE.js";import{C as L,G as R,J as ge,K as _e,S as z,U as ve,_ as ye,h as be,l as xe,m as Se,q as Ce,s as we,t as B}from"./tree-CcEbNvms.js";import{B as Te,_ as Ee,c as De,h as Oe,u as V}from"./browser-connection-dads1eyK.js";import{a as ke,r as Ae}from"./live-ingress-OuSlQ6q7.js";import{n as je,r as Me}from"./use-second-ticker-CWjCHLG6.js";var Ne=x(`outline`,`check`,`Check`,[[`path`,{d:`M5 12l5 5l10 -10`,key:`svg-0`}]]),Pe=x(`outline`,`copy`,`Copy`,[[`path`,{d:`M7 9.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667l0 -8.666`,key:`svg-0`}],[`path`,{d:`M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1`,key:`svg-1`}]]),H=`••••`,Fe=/auth|key|token|secret|passw|pwd|cookie|session|signature|^sig$|credential|^code$|appid/i,Ie=/auth|key|token|secret|passw|pwd|signature|credential|appid/i,Le=[[/^AIza/,`Google API key`],[/^sk-or-/,`OpenRouter key`],[/^sk-ant-/,`Anthropic key`],[/^sk-/,`OpenAI key`],[/^(?:ghp_|github_pat_)/,`GitHub token`],[/^xox[baprs]-/,`Slack token`],[/^AKIA/,`AWS access key id`],[/^eyJ[\w-]+\.[\w-]+\./,`JWT`],[/^Bearer\s/i,`a whole Bearer header, not a bare token`],[/^https?:\/\//i,`a URL, not a key`]],Re=16;function ze(e,t={}){let n=typeof e==`string`?e:``,r=n.trim(),i=[];/^(?:<.*>|x{3,}|\.{3}|your[-_ ]?(?:api[-_ ]?)?key|changeme|todo)$/i.test(r)?i.push(`a placeholder, not a real value`):(r&&r!==n&&i.push(`spaces or a line break around it`),/[\r\n]/.test(r)?i.push(`a line break inside`):/\s/.test(r)&&i.push(`a space inside`),/^(['"`]).*\1$/.test(r)&&i.push(`wrapped in quotes`),r&&r.length<Re&&i.push(`shorter than keys usually are`));let a=Le.find(([e])=>e.test(r))?.[1];return{secret:!0,set:r.length>0,...a?{looksLike:a}:{},problems:i,sameAs:[...t.sameAs??[]],usedBy:[...t.usedBy??[]]}}var U=/^([a-z][a-z0-9+.-]*:\/\/)([^/?#@]*)@/i,W=/([?&;])([^=?&;#\s]*)=([^&;#\s]*)/g;function G(e){let t=e.indexOf(`:`);return t<0?[e,void 0]:[e.slice(0,t),e.slice(t+1)]}function Be(e){try{return decodeURIComponent(e)}catch{return e}}function K(e){return Fe.test(e)}function Ve(e){let t=URL.canParse(e)?Fe:Ie;return e.replace(U,(e,t,n)=>{let[r,i]=G(n);return`${t}${r&&`••••`}${i===void 0?``:`:${i&&`••••`}`}@`}).replace(W,(e,n,r,i)=>i&&t.test(Be(r))?`${n}${r}=${H}`:e)}function He(e,t){let[n,r]=G(U.exec(t)?.[2]??``),i=new Map;for(let[,,e=``,n=``]of t.matchAll(W))i.set(e,[...i.get(e)??[],n]);return e.replace(U,(e,t,i)=>{let[a,o]=G(i),s=a===`••••`&&n?n:a,c=o===`••••`&&r?r:o;return`${t}${s}${c===void 0?``:`:${c}`}@`}).replace(W,(e,t,n,r)=>{let a=r===`••••`?i.get(n)?.shift():void 0;return a?`${t}${n}=${a}`:e})}function Ue(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,n===`••••`?t?.[e]??n:n]))}function We(e){if(e==null||e===``)return e;let t=e;if(typeof e==`string`)try{t=JSON.parse(e)}catch{return`(not a JSON object, ${String(e.length)} characters)`}if(typeof t!=`object`||!t||Array.isArray(t))return`(not a JSON object)`;let n=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,K(e)?H:t]));return typeof e==`string`?JSON.stringify(n):n}var Ge=/\{\s*private\s*:/g;function Ke(e,t){return e.slice(0,t).split(`
|
|
3
|
+
`).length}function qe(e){let t=[],n=0;for(let r of e.matchAll(Ge)){if(r.index<n)continue;let i=1,a=r.index+r[0].length;for(;a<e.length&&i>0;a++)e[a]===`{`?i++:e[a]===`}`&&i--;if(i>0)return{ok:!1,message:`The {private: section on line ${String(Ke(e,r.index))} has no closing }.`};let o=e.slice(r.index+r[0].length,a-1).trim();if(!o)return{ok:!1,message:`The {private: section on line ${String(Ke(e,r.index))} is empty.`};t.push(e.slice(n,r.index),{private:o}),n=a}if(t.push(e.slice(n)),t.length===1)return{ok:!0,prompt:e.trim()||void 0};let r=t[0],i=t.at(-1);return typeof r==`string`&&(t[0]=r.trimStart()),typeof i==`string`&&(t[t.length-1]=i.trimEnd()),{ok:!0,prompt:t.filter(e=>e!==``)}}var Je=()=>void 0,Ye=()=>void 0;function q(e){return(e??[]).map(e=>e.trim()).filter(Boolean)}function J(e,t,n,r,i,a){i===null||Number.isInteger(i)&&i>=a||e(t,`${r} must be a ${a?`positive`:`non-negative`} whole number.`,n)}var Xe={agentId:{label:`Profile id`,max:64},handle:{label:`Handle`,max:32}};function Ze(e,t,n){let{label:r,max:i}=Xe[t];n.trim()?Array.from(n).length>i&&e(`identity`,`${r} is at most ${i} characters.`,t):e(`identity`,`${r} is required.`,t)}function Qe(e,t){Ze(t,`agentId`,e.identity.agentId),e.identity.profileType!==`host`&&Ze(t,`handle`,e.identity.handle)}function $e(e,t,n,r){let i=B(e.key),a=E(n,t,{...e,apiId:e.apiId.trim()}),o=n.find(t=>t.id===e.provider);if(!o)r(i,`No provider is defined as ${e.provider}.`,`provider`);else if(!k(o,t))r(i,`${e.provider} doesn't serve ${t} agents.`,`provider`);else if(!k(o,t,e.protocol)){let n=(S(o,t)??[]).map(e=>e.id).join(` or `);r(i,n?`${e.provider} runs ${t} agents on ${n}, not ${e.protocol}.`:`${e.provider} doesn't serve ${t} agents on ${e.protocol}.`,`protocol`)}return a.apiId||r(i,`API model is required.`,`apiId`),a}function et(e){return e.length<2?e[0]??``:`${e.slice(0,-1).join(`, `)} or ${e.at(-1)}`}function tt(e,t){let n=ae(e).map(e=>e.path.split(`.`)[0]??e.path).find(e=>e.toLowerCase()===t.toLowerCase());return n?`${e.id} has no option ${t}. Did you mean ${n}?`:`${e.id} has no option ${t}.`}function nt(e,t,n,r){let i={};e.efforts.forEach(({alias:a,level:o},s)=>{let c=a.trim();c?c in i?r(n,`Effort alias '${c}' is used twice.`,`efforts`,s):i[c]=o:r(n,`Every effort needs an alias.`,`efforts`,s),w(t)&&!C.includes(o)&&r(n,`${e.provider} takes the ${et(C)} thinking level, not ${o}.`,`efforts`,s)}),e.allowEffortSelect&&Object.keys(i).length<2&&r(n,`Effort select needs at least two efforts.`,`allowEffortSelect`);let a=e.defaultEffort.trim();if(!a&&_e(e))r(n,`Pick a default effort — there is more than one.`,`defaultEffort`);else if(a&&!(a in i)){let e=Object.keys(i);r(n,e.length?`Default effort '${a}' is not one of the efforts. Pick ${et(e)}.`:`Default effort '${a}' is not one of the efforts.`,`defaultEffort`)}return{efforts:i,defaultEffort:a}}function rt(e,t,n,r,i){let a=B(e.key),o=$e(e,t,n,r),{apiId:s}=o,{efforts:c,defaultEffort:l}=nt(e,o,a,r),u=Object.keys(c).length;J(r,a,`maxOutputTokens`,`Max output tokens`,e.maxOutputTokens,1),e.temperature!==null&&!(Number.isFinite(e.temperature)&&e.temperature>=0)&&r(a,`Temperature must be zero or more.`,`temperature`),at(e,n,t,a,r);let d=ot(e,t,a,r,i),f=it(e,a,r);return{protocol:e.protocol,provider:e.provider,apiId:s,...e.keySlot?{keySlot:e.keySlot}:{},...e.fallbackKeySlot?{fallbackKeySlot:e.fallbackKeySlot}:{},...u?{efforts:c}:{},...l?{defaultEffort:l}:{},...e.allowEffortSelect?{allowEffortSelect:!0}:{},...e.summaries===null?{}:{summaries:e.summaries},...e.maxOutputTokens===null?{}:{maxOutputTokens:e.maxOutputTokens},...e.temperature===null?{}:{temperature:e.temperature},...e.builtInTools.length?{builtInTools:[...e.builtInTools]}:{},...Object.keys(e.options).length?{options:e.options}:{},...f?{limits:f}:{},...d?{compaction:d}:{}}}function it(e,t,n){let r={};for(let{name:i,label:a,isTimer:o}of be){let s=e.limits?.[i]??null;s!==null&&(J(n,t,`limits.${i}`,a,s,1),o&&s>2147483647&&n(t,`${a} must be at most ${ye} ms.`,`limits.${i}`),r[i]=s)}return Object.keys(r).length?r:void 0}function at(e,t,n,r,i){let a=t.find(t=>t.id===e.provider),o=a&&S(a,n)?.find(t=>t.id===e.protocol);for(let t of o?.options.safeParse(e.options).error?.issues??[]){let e=t.code===`unrecognized_keys`?t.keys[0]:t.path[0];i(r,o&&t.code===`unrecognized_keys`&&typeof e==`string`?tt(o,e):t.message,typeof e==`string`?`options.${e}`:`options`)}let s=e.apiId.trim();for(let t of s?o?.refusedOptions?.(s)??[]:[])e.options[t]!==void 0&&i(r,`${s} takes no ${t}.`,`options.${t}`)}function ot(e,t,n,r,i){let a=e.compactTiming;if(!a)return;t!==`text`&&r(n,`Only a text agent compacts its own history.`,`compactTiming`);let o=e.compactMaxTokens??null,s=e.compactAt??xe.compactAt,c=e.compactKeep??null;o===null&&r(n,`Compaction needs a budget.`,`compactMaxTokens`),J(r,n,`compactMaxTokens`,`Budget`,o,1),s>0&&s<1||r(n,`Compaction must start between 0 and 1 of the budget.`,`compactAt`),c!==null&&(c===0||Number.isInteger(c)&&c>=1||c>0&&c<s)||r(n,`Keep a whole number of exchanges, a fraction of the budget below where compaction starts, or 0.`,`compactKeep`);let l=e.compactWith??``,u=l?i(l):void 0;return l&&!u&&r(n,`The agent that summarised is gone. Pick another, or this agent.`,`compactWith`),{maxTokens:o??0,compactAt:s,...u?{profile:u}:{},previousExchanges:c??0,timing:a,...e.compactMeter?{meter:e.compactMeter}:{}}}function st(e,t,n){let{models:r,modelBindings:i}=e;i.length||n(`models`,`Add at least one model.`);let a=r.defaultModel.trim();return a&&!(a in t)?n(`models`,`Default model '${a}' is not one of the models.`,`defaultModel`):!a&&Ce(e)&&n(`models`,`Pick a default model — there is more than one.`,`defaultModel`),r.maxSteps!==null&&!Number.isInteger(r.maxSteps)&&n(`models`,`Max steps must be a whole number.`,`maxSteps`),a}function ct(e,t,n,r){let{models:i,modelBindings:a}=e,o={};for(let s of a){let a=rt({...s,keySlot:s.keySlot||i.key||void 0,fallbackKeySlot:s.fallbackKeySlot||i.fallbackKey||void 0},t,e.providers,n,r),c=s.modelId.trim(),l=B(s.key);c?c in o?n(l,`Model id '${c}' is used twice.`,`modelId`):o[c]=a:n(l,`Model id is required.`,`modelId`)}let s=st(e,o,n),c=i.providerHistory===`provider`||i.providerHistory===`stateless`?i.providerHistory:void 0;return{models:o,...s?{defaultModel:s}:{},...c?{providerContinuation:{history:c}}:{},...i.allowModelSelect?{allowModelSelect:!0}:{},...i.maxSteps===null?{}:{maxSteps:i.maxSteps}}}function Y(e,t){if(!e?.trim())return;let n;try{n=JSON.parse(e)}catch{return null}if(!n||typeof n!=`object`||Array.isArray(n))return null;let r=Object.entries(n);return r.every(([,e])=>t(e))?r.length?Object.fromEntries(r):void 0:null}var lt=e=>typeof e==`string`,ut=e=>!0;function dt(e){return Y(e,lt)}var ft=e=>Array.isArray(e)&&e.every(lt);function pt(e){return Y(e,ft)??{}}function mt(e,t){let n=Y(e.identity.conditionsJson,ft);n===null&&t(`identity`,`Conditions must be a JSON object of lists of values.`,`conditionsJson`);let r=e.identity.system.flatMap(({text:e})=>{let n=qe(e);return n.ok||t(`identity`,n.message,`system`),n.ok&&n.prompt!==void 0?[n.prompt]:[]}),[i]=r,a=r.length===0?void 0:r.length===1&&typeof i==`string`?i:r,o=n??void 0;if(a!==void 0&&n!==null){let n=Object.fromEntries(e.inputs.slots.map(e=>[e.name.trim(),e.choices.map(e=>e.value.trim()).filter(Boolean)])),r=Te(a,o,n);r&&t(`identity`,r,`system`)}return{system:a,conditions:o}}function ht(e,t,n){let r=Y(e,t);return r===null&&n(),r??void 0}function gt(e,t){if(!e.authType||e.authType===`none`)return;let n=e.authService?.trim()??``;n||t(`Service is required.`,`authService`);let r=q(e.authScopes),i=e.authType===`api_key`?e.authQueryParam?.trim():void 0;i&&q(e.queryParams).includes(i)&&t(`${i} is also one of the query parameters the model fills.`,`authQueryParam`);let a=i?{queryParam:i}:{...e.authHeaderName?.trim()?{headerName:e.authHeaderName.trim()}:{},...e.authHeaderPrefix===void 0?{}:{headerPrefix:e.authHeaderPrefix}};return{slot:e.authSlot?.trim()||`default`,type:e.authType,service:n,...a,onUnauthenticated:e.authUnauthenticated??`gate`,...r.length?{scopes:r}:{},...e.authClientId?.trim()?{clientId:e.authClientId.trim()}:{},...e.authRedirectUri?.trim()?{redirectUri:e.authRedirectUri.trim()}:{}}}function _t(e){try{return new URL(e),!0}catch{return!1}}function vt(e,t){e?se(e)&&t(`${e} is a provider builtin — turn it on under the model's built-in tools.`,`toolName`):t(`Tool name is required.`,`toolName`)}function yt(e,t,n){let r=e.toolName.trim();vt(r,t);let i=e.description.trim();i||t(`Description is required.`,`description`);let a=e.toolType===`agent`?{inputSchema:n(e.agentKey??``)??xt,outputSchema:St}:bt(e,t),o=q(e.paths);return{name:r,description:i,category:e.category.trim()||`studio`,access:e.access,permission:e.permission,loadTier:e.loadTier,paths:o.length?o:[`*`],...e.after?{after:!0}:{},...a}}function bt(e,t){let n=T(e.inputJson,`Input`);n.ok||t(n.error,`inputJson`);let r=T(e.outputJson,`Output`);return r.ok||t(r.error,`outputJson`),{inputSchema:n.ok?n.schema:{},outputSchema:r.ok?r.schema:{}}}var xt=V(Oe({type:`text`}),`input`),St=V(Ee,`output`);function Ct(e){let t=e.identity.profileType;if(t!==`text`&&t!==`image`&&t!==`speech`)return;let n=t!==`speech`&&L(e).includes(`inputs`)?zt(e.inputs,t,()=>{}):void 0;return V(Oe({type:t,...n?{inputs:n}:{}}),`input`)}function wt(e){return(e??``).split(`
|
|
4
|
+
`).map(e=>e.trim()).filter(Boolean)}function Tt(e,t,n){let r={},i={activity:{input:t.inputSchema},activityPast:{input:t.inputSchema,output:t.outputSchema},activityFailed:{input:t.inputSchema},request:{input:t.inputSchema}};for(let t of[`activity`,`activityPast`,`activityFailed`,`request`]){let a=wt(e[t]),[o]=a;if(o===void 0)continue;let s=a.length===1?o:a,c=oe(s,i[t]);c?n(c,t):r[t]=s}return Object.keys(r).length?r:void 0}function Et(e){let t=Object.entries(e??{}).find(([e,t])=>K(e)&&t!==`••••`)?.[0];return t?`${t} looks like a credential. Put it under Auth instead: Auth asks for it when a call runs and nothing saves it.`:void 0}function Dt(e){if(!e||!URL.canParse(e))return;let t=[...new URL(e).searchParams].find(([e,t])=>K(e)&&t&&t!==`••••`)?.[0];return t?`${t} in the URL looks like a credential. Put it under Auth instead, as an API key with ${t} as its query parameter: Auth asks for it when a call runs and nothing saves it.`:void 0}function Ot(e,t){let n=dt(e.headersJson);n===null&&t(`Headers must be a JSON object of strings. Until they are, a reload brings back the headers as they started.`,`headersJson`);let r=Et(n??void 0);r&&t(r,`headersJson`);let i=e.toolType===`mcp`?`serverUrl`:`endpoint`,a=Dt(e[i]?.trim());a&&t(a,i);let o=gt(e,t),s=e.maxResponseBytes??null;return s!==null&&!(Number.isInteger(s)&&s>=1)&&t(`Max response must be a positive whole number.`,`maxResponseBytes`),{...n?{headers:n}:{},...o?{auth:o}:{},...s===null?{}:{maxResponseBytes:s}}}function kt(e,t,n,r){let i=e[t]?.trim()??``;return i?_t(i)||r(`${n} must be a full URL.`,t):r(`${n} is required.`,t),i}function At(e,t,n){let r=kt(e,`endpoint`,`Endpoint URL`,n),i=q(e.pathParams),a=q(e.queryParams),o=e.bodyParam?.trim(),s={...i.length?{pathParams:i}:{},...a.length?{queryParams:a}:{},...o?{bodyParam:o}:{}};return{type:`http`,...t,endpoint:r,method:e.method??pe[0],...Ot(e,n),...Object.keys(s).length?{mapping:s}:{}}}function jt(e,t,n){let r=kt(e,`serverUrl`,`MCP server URL`,n),i=e.mcpToolName?.trim()??``;return i||n(`MCP tool name is required.`,`mcpToolName`),{type:`mcp`,...t,serverUrl:r,mcpToolName:i,...Ot(e,n),...Mt(e,n)}}function Mt(e,t){let n=e.sessionIdleMs??null,r=e.sessionMax??null;n!==null&&!(Number.isInteger(n)&&n>=1)&&t(`Idle must be a positive whole number.`,`sessionIdleMs`),r!==null&&!(Number.isInteger(r)&&r>=1)&&t(`Max must be a positive whole number.`,`sessionMax`);let i={...n===null?{}:{idleMs:n},...r===null?{}:{max:r}};return Object.keys(i).length?{session:i}:{}}function Nt(e,t,n){let r=e.answeredBy===`page`?{answeredBy:`page`}:{};if(!e.stubOutputJson?.trim())return{type:`function`,...t,...r};let i=T(e.stubOutputJson,`Stub output`);return i.ok||n(i.error.replace(` JSON Schema`,``),`stubOutputJson`),{type:`function`,...t,...r,...i.ok?{stubResponse:i.schema}:{}}}function Pt(e,t,n,r){let i=e.agentKey??``,a=i?r(i):void 0;i?a||n(`The agent this tool ran is gone. Pick another.`,`agentKey`):n(`Pick the agent this tool runs.`,`agentKey`);let o=e.maxCallsPerTurn??null;return o!==null&&!(Number.isInteger(o)&&o>=1)&&n(`Calls per turn must be a positive whole number.`,`maxCallsPerTurn`),{type:`agent`,...t,profile:a??``,...o===null?{}:{maxCallsPerTurn:o}}}var Ft={http:At,mcp:jt,function:Nt,agent:Pt};function It(e){return je.includes(e)}function Lt(e,t,n,r){let i=we(e.key);if(!It(e.toolType)){t(i,Me,`toolType`);return}let a=!1,o=(e,n)=>{a=!0,t(i,e,n)},s=yt(e,o,r),c=Tt(e,s,o),l=Ft[e.toolType](e,s,o,n),u=e.toolType===`agent`?``:e.stageAgentKey?.trim()??``,d=u?n(u):void 0;return a?void 0:{...l,...c?{labels:c}:{},...d&&l.type!==`agent`?{stageAgent:d}:{}}}function Rt(e,t,n,r,i,a){let o=[],s=new Set;for(let t of e.toolSpecs){let e=Lt(t,r,i,a);e&&(s.has(e.name)?r(we(t.key),`Tool name '${e.name}' is used twice.`,`toolName`):(s.add(e.name),o.push(e)))}let c=o.map(e=>e.name),l=t?e.tools.t2Loader.trim():``;l&&!s.has(l)&&r(`tools`,`T2 loader '${l}' must be one of the custom tools.`,`t2Loader`);let u=n&&e.tools.parallel;return{customTools:o,tools:{allow:c,...l?{t2Loader:l}:{},...u?{parallel:u}:{}}}}function zt(e,t,n){let r=t===`image`?e.attachmentsAccept.filter(e=>!O(fe,e)):[];if(r.length&&n(`inputs`,`An image profile takes images, video, and PDF only, not ${r.join(`, `)}.`,`attachmentsAccept`),!e.text&&!e.attachmentsAccept.length&&!e.voiceAccept.length&&n(`inputs`,`Take text, files, or voice notes: with none, the agent can be sent nothing.`,`text`),ge(e)){let t=[[`maxFiles`,`Max files`,e.maxFiles],[`maxBytes`,`Max bytes`,e.maxBytes],[`maxTurnBytes`,`Max turn bytes`,e.maxTurnBytes]];for(let[e,r,i]of t)i===null&&n(`inputs`,`${r} is required with attachments or voice.`,e)}J(n,`inputs`,`maxFiles`,`Max files`,e.maxFiles,1),J(n,`inputs`,`maxBytes`,`Max bytes`,e.maxBytes,1),J(n,`inputs`,`maxTurnBytes`,`Max turn bytes`,e.maxTurnBytes,1);let i=Vt(e,n),a=Ut(e,n),o=Bt(e,n);return{...e.text?{}:{text:!1},...e.attachmentsAccept.length?{attachments:{accept:[...e.attachmentsAccept]}}:{},...e.voiceAccept.length?{voice:{accept:[...e.voiceAccept]}}:{},...e.maxFiles===null?{}:{maxFiles:e.maxFiles},...e.maxBytes===null?{}:{maxBytes:e.maxBytes},...e.maxTurnBytes===null?{}:{maxTurnBytes:e.maxTurnBytes},...i?{limitsByMime:i}:{},...a?{slots:a}:{},...o?{context:o}:{}}}function Bt(e,t){if(e.contextFrom.length)return e.contextMaxChars===null&&t(`inputs`,`Max characters is required with context.`,`contextMaxChars`),J(t,`inputs`,`contextMaxChars`,`Max characters`,e.contextMaxChars,1),{from:[...e.contextFrom],maxChars:e.contextMaxChars??0}}function Vt(e,t){let n=Object.entries(e.limitsByMime);for(let[e,r]of n)Number.isInteger(r)&&r>=1||t(`inputs`,`Max size for ${e} must be a whole number of at least 1.`,`limitsByMime`);return n.length?{...e.limitsByMime}:void 0}function Ht(e,t,n){let r=e.name.trim(),i=[];r?n.findIndex(e=>e.name.trim()===r)<t&&i.push(`Another slot is called ${r}.`):i.push(`Name this slot.`);let a=e.choices.map(e=>e.value.trim());a.some(Boolean)||i.push(`Give this slot a choice.`),e.choices.some((e,t)=>!a[t]&&e.description.trim())&&i.push(`Every choice with a description needs a value.`);let o=a.filter((e,t)=>e&&a.indexOf(e)<t);for(let e of new Set(o))i.push(`${e} is a choice twice.`);return i}function Ut(e,t){if(e.slots.length)return e.slots.forEach((n,r)=>{for(let i of Ht(n,r,e.slots))t(`inputs`,i,`slots`,r)}),Object.fromEntries(e.slots.map(e=>{let t=e.label.trim(),n=e.choices.filter(e=>e.value.trim()).map(e=>({value:e.value.trim(),description:e.description.trim()})),r=!t&&n.every(e=>!e.description)?n.map(e=>e.value):{...t?{label:t}:{},choices:n.map(({value:e,description:t})=>t?{value:e,description:t}:{value:e})};return[e.name.trim(),r]}))}function Wt(e,t){let n=Ut(e,t),r=Bt(e,t);return!n&&!r?{}:{inputs:{...n?{slots:n}:{},...r?{context:r}:{}}}}function Gt(e,t,n){let{slot:r,shapes:i}=e.bySlot??{slot:``,shapes:[]},a=[],o={};for(let e of i){let t=T(e.schemaJson,`The reply shape for '${e.choice}'`);t.ok?(a.push({id:e.schemaId,spec:{jsonSchema:t.schema}}),o[e.choice]=e.schemaId):n(`outputs`,t.error,`schemaJson`)}return a.length?{also:a,written:{by:r,map:o,fallback:t}}:void 0}function Kt(e,t,n){let r,i=t&&e.validationEnabled;if(t&&e.mode===`structured`){let t=e.schemaId.trim();t||n(`outputs`,`Structured output needs a schema id.`,`schemaId`);let i=T(e.schemaJson,`Structured output`);i.ok||n(`outputs`,i.error,`schemaJson`),t&&i.ok&&(r={id:t,spec:{jsonSchema:i.schema}})}let a=r&&Gt(e,r.id,n);r&&a&&(r={...r,also:a.also}),i&&J(n,`outputs`,`maxRetries`,`Validation max retries`,e.maxRetries,0);let o=Object.fromEntries(Object.entries(e.itemRules).map(([e,t])=>[e,{onFail:t}])),s=i?{...e.maxRetries===null?{}:{maxRetries:e.maxRetries},...Object.keys(o).length?{items:o}:{}}:{},c={...e.streamMode?{mode:e.streamMode}:{},...e.streamThoughts?{}:{streamThoughts:!1}},l={...r?{structured:a?.written??r.id}:{},...Object.keys(s).length?{validation:s}:{},...Object.keys(c).length?{streaming:c}:{}};return{...Object.keys(l).length?{outputs:l}:{},...r?{structured:r}:{}}}function qt(e,t){return e.resumeEnabled?(J(t,`turnBehaviour`,`maxContinues`,`Max continues`,e.maxContinues,1),{allowContinue:[...e.allowContinue],autoContinue:[...e.autoContinue],...e.maxContinues===null?{}:{maxContinues:e.maxContinues}}):{allowContinue:[],autoContinue:[]}}function Jt(e,t,n){let r=t?qt(e,n):void 0,i={...r?{resumption:r}:{},...e.allowSteering?{}:{allowSteering:!1},...e.atStepLimit===`answer`?{atStepLimit:e.atStepLimit}:{}};return Object.keys(i).length?i:void 0}function Yt(e,t,n,r){let i=[],a=e=>t.has(e)||t.has(`labels`),{turnBehaviour:o,guardrails:s,outputs:c}=e;if(a(`turnBehaviour`)&&ve(e)&&i.push([`turnBehaviour`,`continueInstruction`,`continue.instruction`,o.continueInstruction.trim()]),a(`guardrails`)&&n(`identity.system`)&&i.push([`guardrails`,`canaryBindNote`,`canary.bind_note`,s.canaryBindNote.trim()]),a(`guardrails`)&&n(`guardrails.quota`)&&i.push([`guardrails`,`quotaMessage`,`quota.exhausted`,s.quotaMessage.trim()]),a(`outputs`)&&n(`outputs.validation`)&&i.push([`outputs`,`repairGuidance`,`repair.default_guidance`,c.repairGuidance.trim()]),a(`guardrails`)&&n(`guardrails.blockedReply`)&&(i.push([`guardrails`,`egressRepairGuidance`,`egress.default_repair_guidance`,s.egressRepairGuidance.trim()]),i.push([`guardrails`,`egressRefusal`,`egress.refusal`,s.egressRefusal.trim()])),t.has(`labels`))for(let[t,n]of Object.entries(e.labels))Se[t]||i.push([`labels`,t,t,n.trim()]);let l={};for(let[e,t,n,a]of i)if(a)try{ue({[n]:a},`Profile labels`),l[n]=a}catch(n){r(e,P(n),t)}return Object.keys(l).length?l:void 0}function Xt(e,t){if(e.quotaEnabled){if(e.quotaPerDay===null)t(`guardrails`,`Quota needs turns per day.`,`quotaPerDay`);else return J(t,`guardrails`,`quotaPerDay`,`Quota per day`,e.quotaPerDay,1),{perDay:e.quotaPerDay}}}function Zt(e,t){J(t,`guardrails`,`blockedReplyMaxRetries`,`Blocked reply max retries`,e.blockedReplyMaxRetries,0);let n={...e.blockedReplyOnBlock?{onBlock:e.blockedReplyOnBlock}:{},...e.blockedReplyMaxRetries===null?{}:{maxRetries:e.blockedReplyMaxRetries}};return Object.keys(n).length?n:void 0}function Qt(e){return $t(e,()=>{})}function $t(e,t){let n=e.allowedHosts.map(e=>e.trim()),r=n.indexOf(``);r!==-1&&t(`guardrails`,`Allowed hosts cannot be blank.`,`allowedHosts`,r);let i=q(e.allowedSchemes);if(e.allowPrivateNetworks||n.length||i.length)return{...e.allowPrivateNetworks?{allowPrivateNetworks:!0}:{},...n.length?{allowedHosts:n}:{},...i.length?{allowedSchemes:i}:{}}}function en(e,t,n){let r=t.hosts.map(e=>e.trim()),i=r.indexOf(``);i!==-1&&n(`guardrails`,`Allowed hosts cannot be blank.`,`allow.${e}.hosts`,i);let a=r.filter(Boolean),o={...a.length?{hosts:a}:{},...t.fromTools?{}:{fromTools:!1}};return Object.keys(o).length?o:void 0}function tn(e,t){for(let[t,n]of e.entries()){let e=`Pattern ${t+1}`;if(!n.name.trim())return`${e} needs a name.`;if(n.kind===`words`){if(!q(n.words).length)return`${e} needs a word to match.`}else if(!n.pattern)return`${e} needs a regular expression.`}let n=le(``,t);if(n===void 0)return;let r=/^\.patterns\[(\d+)\](?:\.(\w+))?:? (.*)$/s.exec(n);if(!r)return n.replace(/^\.patterns/,`This`);let[,i,a,o]=r;return`Pattern ${Number(i)+1}${a?`, ${a}`:``}: ${o}`}function nn(e,t,n){let r=e.map(e=>{let t=e.name.trim();if(e.kind===`words`)return{name:t,words:q(e.words)};let n=e.flags.trim();return{name:t,pattern:e.pattern,...n?{flags:n}:{}}}),i=tn(e,r);return i!==void 0&&n(`guardrails`,i,t),r}function rn(e,t,n){if(!t||!N[e].patterns)return{};let r=an(t.hint,`sources.${e}.hint`,n),i=nn(t.patterns,`sources.${e}.patterns`,n);return{...t.theorem?{}:{theorem:!1},...i.length?{patterns:i}:{},...i.length&&r?{hint:r}:{}}}function an(e,t,n){let r=e.trim();if(!r)return;let i=j(`The retry hint`,r);return i!==void 0&&n(`guardrails`,`${i}.`,t),r}function on(e,t){if(!e)return`Give this detector a key, such as acme.codenames.`;let n={label:e,action:`flag`,find:cn};return F(`Detect`,{[e]:n},t)===void 0?void 0:`A key is a namespace, a dot, and a name, in lower case letters, digits and _, such as acme.codenames.`}function sn(e,t,n){let r={};for(let[i,a]of e.entries()){let e=a.key.trim();if(Object.hasOwn(r,e)){n(`guardrails`,`Detector ${e} is listed twice.`,`own`,i);continue}let o=t.filter(e=>a.at[e]!==`ignore`),s=an(a.hint,`own.${i}.hint`,n),c=nn(a.patterns,`own.${i}.patterns`,n),l=a.label.trim(),u=on(e,t);u!==void 0&&n(`guardrails`,u,`own`,i),l||n(`guardrails`,`Give this detector a name.`,`own.${i}.label`),o.length||n(`guardrails`,`Pick what a match does. It is ignored now.`,`own.${i}.at`),u===void 0&&l&&o.length&&(r[e]={label:l,at:Object.fromEntries(o.map(e=>[e,a.at[e]])),patterns:c,...s?{hint:s}:{}})}return r}var cn=()=>[];function ln(e){return e===void 0||typeof e==`string`?e:Object.fromEntries(Object.entries(e).map(([e,t])=>{if(typeof t==`string`||t.patterns===void 0)return[e,t];let{patterns:n,...r}=t;if(e.includes(`.`))return[e,{...r,find:cn}];let{hint:i,...a}=r;return[e,a]}))}function un(e){let{guardrails:t}=e;return!t||!(`detect`in t)||t.detect===void 0?e:{...e,guardrails:{...t,detect:ln(t.detect)}}}function dn(e,t,n){let{detect:r}=e,i={};for(let a of M){let o=t.filter(e=>r[a][e]!==de[a][e]),s=t.some(e=>r[a][e]!==`ignore`)?fn(a,e,n):void 0,c=rn(a,e.sources[a],n);(o.length||s||Object.keys(c).length)&&(i[a]={...o.length?{at:Object.fromEntries(o.map(e=>[e,r[a][e]]))}:{},...c,...s?{allow:s}:{}})}Object.assign(i,sn(e.own,t,n));let a=F(`Detect`,ln(i),t);return a!==void 0&&n(`guardrails`,a,`detect`),Object.keys(i).length?i:void 0}function fn(e,t,n){if(pn(e))return en(e,t.allow[e],n);if(N[e].allow!==`names`)return;let r=t.innocentNames.map(e=>e.trim()),i=r.indexOf(``);i!==-1&&n(`guardrails`,`Allowed names cannot be blank.`,`innocentNames`,i);let a=r.filter(Boolean);return a.length?{names:a}:void 0}function pn(e){return N[e].allow===`urls`}function mn(e){let{taintAfterRemoteRead:t,taintRemoteDestination:n}=e;if(t||n)return{...t?{afterRemoteRead:t}:{},...n?{remoteDestination:n}:{}}}function hn(e,t,n=I){let r={detect:dn(e,n,t),quota:Xt(e,t),blockedReply:Zt(e,t),network:$t(e,t),taint:mn(e)},i=Object.fromEntries(Object.entries(r).filter(([,e])=>e!==void 0));return Object.keys(i).length?i:void 0}function gn(e,t){let n=ke({}),{writeTo:r}=e,{sampleRate:i}=e;Number.isFinite(i)&&i>=0&&i<=1||t(`observability`,`Sample rate must be between 0 and 1.`,`sampleRate`),e.retainForDays!==null&&!Number.isFinite(e.retainForDays)&&t(`observability`,`Retain for days must be a number.`,`retainForDays`),e.rotateAfterMiB!==null&&!(Number.isFinite(e.rotateAfterMiB)&&e.rotateAfterMiB>0)&&t(`observability`,`Rotate after MiB must be more than zero.`,`rotateAfterMiB`);let a=ht(e.resourceJson,ut,()=>{t(`observability`,`Resource must be a JSON object.`,`resourceJson`)}),o=Object.fromEntries(Object.entries(e.include).filter(([e,t])=>t!==n.include[e])),s=Object.fromEntries(Object.entries(e.scrub).filter(([e,t])=>t!==n.scrub[e])),c={writeTo:r,...i===n.sampleRate?{}:{sampleRate:i},...Object.keys(o).length?{include:o}:{},...Object.keys(s).length?{scrub:s}:{},...e.retainForDays===null?{}:{retainForDays:e.retainForDays},...e.rotateAfterMiB===null?{}:{rotateAfterMiB:e.rotateAfterMiB},...a?{resource:a}:{}};return Object.keys(c).length?c:void 0}var _n={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,webp:`image/webp`,gif:`image/gif`};function vn(e){if(!URL.canParse(e))return;let t=new URL(e);return t.protocol!==`https:`&&t.protocol!==`http:`?void 0:_n[t.pathname.split(`.`).pop()?.toLowerCase()??``]}function yn(e,t){return e.flatMap((e,n)=>{if(`data`in e)return e.mimeType.startsWith(`image/`)&&e.data?[{mimeType:e.mimeType,data:e.data,name:e.name}]:(t(`image`,`${e.name||`A reference`} is not an image.`,`references`,n),[]);let r=e.uri.trim(),i=vn(r);return i?[{mimeType:i,uri:r,...e.name?{name:e.name}:{}}]:(t(`image`,r?`Link to a .png, .jpg, .webp or .gif image over http(s).`:`Add a link or remove the reference.`,`references`,n),[])})}function bn(e,t){J(t,`image`,`n`,`Images per request`,e.n,1),J(t,`image`,`seed`,`Seed`,e.seed,0),J(t,`image`,`outputCompression`,`Compression`,e.outputCompression,0),e.outputCompression!==null&&e.outputCompression>100&&t(`image`,`Compression goes from 0 to 100.`,`outputCompression`);let n=yn(e.references,t);return{...e.aspectRatio.trim()?{aspectRatio:e.aspectRatio.trim()}:{},...e.resolution.trim()?{resolution:e.resolution.trim()}:{},...e.mimeType.trim()?{mimeType:e.mimeType.trim()}:{},...e.quality.trim()?{quality:e.quality.trim()}:{},...e.background.trim()?{background:e.background.trim()}:{},...e.n===null?{}:{n:e.n},...e.seed===null?{}:{seed:e.seed},...e.outputCompression===null?{}:{outputCompression:e.outputCompression},...e.includeText?{includeText:!0}:{},...n.length?{references:n}:{}}}function xn(e,t,n){let{format:r}=e;if(r){let e=t.modelBindings.find(e=>w(E(t.providers,`speech`,e))&&!D.includes(r));e&&n(`speech`,`Google doesn't make ${r}; ${e.modelId} is on ${e.provider}.`,`format`)}let i=t.modelBindings.find(e=>w(E(t.providers,`speech`,e)));i&&!e.voice.trim()&&n(`speech`,`Gemini needs a voice to speak; ${i.modelId} is on ${i.provider}.`,`voice`);let{speed:a}=e;return{...e.voice.trim()?{voice:e.voice.trim()}:{},...e.style.trim()?{style:e.style.trim()}:{},...a===null?{}:{speed:a},...r?{format:r}:{}}}function Sn(e,t){J(t,`live`,`resumedAfterMs`,`Away for`,e.resumedAfterMs,0);let n=e.resumedPrompt.trim();if(n&&!e.sessionResumption&&t(`live`,`A resume prompt needs Resumption on.`,`resumedPrompt`),!n)e.resumedAfterMs!==null&&t(`live`,`Away for needs a resume prompt.`,`resumedAfterMs`);else return{prompt:n,...e.resumedAfterMs===null?{}:{afterMs:e.resumedAfterMs}}}function Cn(e,t,n){!e.ingressAudio&&!e.ingressVideo&&!e.ingressText&&t(`live`,`Turn on at least one ingress channel.`),J(t,`live`,`vadPrefixPaddingMs`,`VAD prefix padding`,e.vadPrefixPaddingMs,0),J(t,`live`,`vadSilenceDurationMs`,`VAD silence duration`,e.vadSilenceDurationMs,0),e.contextCompression&&wn(e,t,n.mode===`demo`?n.keys.liveInputTokens:void 0);let r=Sn(e,t),i={audio:e.ingressAudio,video:e.ingressVideo,text:e.ingressText},a=Object.fromEntries(Object.entries(i).filter(([e,t])=>t!==Ae(e))),o={...e.vadActivityHandling?{activityHandling:e.vadActivityHandling}:{},...e.vadStartSensitivity?{startSensitivity:e.vadStartSensitivity}:{},...e.vadEndSensitivity?{endSensitivity:e.vadEndSensitivity}:{},...e.vadPrefixPaddingMs===null?{}:{prefixPaddingMs:e.vadPrefixPaddingMs},...e.vadSilenceDurationMs===null?{}:{silenceDurationMs:e.vadSilenceDurationMs}},s={...e.transcriptionInput?{input:!0}:{},...e.transcriptionOutput?{output:!0}:{}};return{...Object.keys(a).length?{ingress:a}:{},...e.voice.trim()?{voice:e.voice.trim()}:{},...Object.keys(o).length?{vad:o}:{},...e.sessionResumption?{sessionResumption:!0}:{},...e.greeting.trim()?{greeting:e.greeting.trim()}:{},...r?{resumed:r}:{},...e.contextCompression?{contextCompression:Tn(e)}:{},...Object.keys(s).length?{transcription:s}:{}}}function wn(e,t,n){J(t,`live`,`compressionTriggerTokens`,`Compression trigger`,e.compressionTriggerTokens,1),J(t,`live`,`compressionTargetTokens`,`Compression target`,e.compressionTargetTokens,1);let r=e.compressionTriggerTokens,i=e.compressionTargetTokens,a=n?.toLocaleString(`en-US`);n!==void 0&&r!==null&&r>n&&t(`live`,`Compression trigger can't exceed the ${a} input tokens a session holds on these keys.`,`compressionTriggerTokens`),i!==null&&(r!==null&&i>=r||n!==void 0&&r===null&&i>=n)&&t(`live`,r===null?`Compression target must be below the ${a} input tokens a session holds on these keys.`:`Compression target must be below the trigger.`,`compressionTargetTokens`)}function Tn(e){let t=e.compressionTriggerTokens,n=e.compressionTargetTokens;return{...t===null?{}:{triggerTokens:t},slidingWindow:n===null?{}:{targetTokens:n}}}function En(e,t){let[n,...r]=t,{[n]:i,...a}=e;return!r.length||typeof i!=`object`||!i?a:{...a,[n]:En(i,r)}}function Dn(e){let t=e;for(let{path:n}of me(e))t=En(t,n.split(`.`));return t}function On(e,t){let n=Object.create(null);return e.questionsBuilt||(e.questions.length||t(`decision`,`Add at least one question.`,`questions`),e.questions.forEach((e,r)=>{let i=e=>t(`decision`,e,`questions`,r),a=e.id.trim(),o=e.instructions.trim();a?Object.hasOwn(n,a)&&i(`Question id '${a}' is used twice.`):i(`Each question needs an id.`),o||i(`Question '${a||r+1}' needs instructions.`);let s=e.criteria.map(e=>({label:e.label.trim(),text:e.text.trim()}));if(!a||!o)return;if(e.type===`box`){let t=e.image?.trim();n[a]={type:`box`,instructions:o,...t?{image:t}:{}};return}if(e.type===`score`){(s.length<2||s.some(e=>!e.text))&&i(`Score '${a}' needs at least two levels, each described.`),n[a]={type:`score`,instructions:o,criteria:s.map(e=>e.text)};return}let c=Object.create(null);for(let e of s)e.label?Object.hasOwn(c,e.label)?i(`Option '${e.label}' of '${a}' is used twice.`):c[e.label]=e.text||e.label:i(`Every option of '${a}' needs a label.`);e.type===`choice`?(s.length<2&&i(`Choice '${a}' needs at least two options.`),n[a]={type:`choice`,instructions:o,criteria:c}):n[a]={type:`noul`,instructions:o,...s.length?{criteria:c}:{}}})),n}var kn=/^[a-z0-9_]+$/,An=[`image/png`,`image/jpeg`];function jn(e,t){let n=Object.create(null);return e.images.forEach((e,r)=>{let i=e=>t(`decision`,e,`images`,r),a=e.name.trim(),o=`<${a}>`;kn.test(a)?Object.hasOwn(n,o)?i(`Image ${o} is used twice.`):!An.includes(e.mimeType)||!e.data?i(`${o} is not a PNG or JPEG.`):n[o]={mimeType:e.mimeType,data:e.data}:i(`Name an image with lowercase letters, digits, and _.`)}),e.questions.forEach((e,r)=>{let i=[...e.instructions.matchAll(/<[a-z0-9_]+>/g)].map(([e])=>e),a=e.type===`box`?e.image?.trim():void 0;a?.startsWith(`<`)&&i.push(a);for(let e of new Set(i))Object.hasOwn(n,e)||t(`decision`,`No image is named ${e}.`,`questions`,r)}),n}function X(e,t,n){let r=t.has(`observability`)?gn(e.observability,n):void 0,i=Yt(e,t,t=>z(e,t),n);return{...r?{observability:r}:{},...i?{labels:i}:{}}}function Mn(e,t){let{decision:n}=e,r=n.contract.trim();return r||t(`decision`,`Contract is required.`,`contract`),r}function Nn(e,t,n,r){let i=n.decision,{decision:a,identity:o}=e,s=(e,t)=>e.trim().length>t;s(a.contract,i.idChars)&&r(`decision`,`Contract is limited to ${i.idChars} characters on these keys.`,`contract`),s(o.agentId,i.idChars)&&r(`identity`,`Profile id is limited to ${i.idChars} characters on these keys.`,`agentId`),s(o.handle,i.nameChars)&&r(`identity`,`Handle is limited to ${i.nameChars} characters on these keys.`,`handle`);let c=e.modelBindings[0];if(c){let e=B(c.key);c.timeoutMs!==null&&c.timeoutMs>i.timeoutMs&&r(e,`Timeout is limited to ${i.timeoutMs} ms on these keys.`,`timeoutMs`),s(c.modelId,i.nameChars)&&r(e,`Model id is limited to ${i.nameChars} characters on these keys.`,`modelId`),s(c.apiId,i.idChars)&&r(e,`API model is limited to ${i.idChars} characters on these keys.`,`apiId`)}a.maxStateBytes!==null&&a.maxStateBytes>i.stateBytes&&r(`decision`,`These keys take at most ${i.stateBytes} bytes of state.`,`maxStateBytes`),a.questions.length>i.questions&&r(`decision`,`These keys ask at most ${i.questions} questions.`,`questions`),a.images.length>i.images&&r(`decision`,`These keys send at most ${i.images} images.`,`images`),a.images.forEach((e,t)=>{Math.floor(e.data.length*3/4)>i.imageBytes&&r(`decision`,`Each image is limited to ${i.imageBytes} bytes on these keys.`,`images`,t)}),a.questions.forEach((a,o)=>{let l=e=>r(`decision`,e,`questions`,o);s(a.id,i.nameChars)&&l(`Question ids are limited to ${i.nameChars} characters on these keys.`),a.type===`box`&&i.images===0&&l(`These keys take no images, so a Box question has nothing to read.`),s(a.instructions,i.instructionsChars)&&l(`Instructions are limited to ${i.instructionsChars} characters on these keys.`),a.criteria.length>i.criteria&&l(`A question has at most ${i.criteria} options or levels on these keys.`),a.criteria.some(e=>s(e.text,i.criterionChars))&&l(`Each option or level is limited to ${i.criterionChars} characters on these keys.`),a.criteria.some(e=>s(e.label,i.nameChars))&&l(`Option labels are limited to ${i.nameChars} characters on these keys.`);let u=t[a.id.trim()],d=c&&u&&n.questionViolation(E(e.providers,`decision`,c),u);d&&l(d)})}function Pn(e,t,n){let{decision:r}=e,i=new Set(L(e)),a=Mn(e,t);e.modelBindings.length!==1&&t(`models`,`A decision needs exactly one model binding.`);let o=e.modelBindings[0],s=o?B(o.key):`models`;o&&($e(o,`decision`,e.providers,t),at(o,e.providers,`decision`,s,t),o.modelId.trim()||t(s,`Model id is required.`,`modelId`),J(t,s,`timeoutMs`,`Timeout`,o.timeoutMs,1));let c=o?it(o,s,t):void 0;J(t,`decision`,`maxStateBytes`,`Max state`,r.maxStateBytes,1);let l=On(r,t),u=jn(r,t);return n.mode===`demo`&&Nn(e,l,n.keys,t),{profile:{type:`decision`,id:e.identity.agentId.trim(),identity:{handle:e.identity.handle.trim()},models:o?{[o.modelId.trim()]:{protocol:o.protocol,provider:o.provider,apiId:o.apiId.trim(),...Object.keys(o.options).length?{options:o.options}:{},...o.keySlot||e.models.key?{keySlot:o.keySlot||e.models.key}:{},...o.fallbackKeySlot?{fallbackKeySlot:o.fallbackKeySlot}:{},...o.timeoutMs===null?{}:{timeoutMs:o.timeoutMs},...c?{limits:c}:{}}}:{},inputs:{state:`json`,...r.maxStateBytes===null?{}:{maxStateBytes:r.maxStateBytes}},decision:{contract:a},...X(e,i,t)},customTools:[],...r.questionsBuilt?{}:{questions:l},...Object.keys(u).length?{images:{...u}}:{}}}function Fn(e,t,n,r){let i=new Set(L(e)),{customTools:a,tools:o}=Rt(e,z(e,`tools.t2Loader`),z(e,`tools.parallel`),t,n,r);a.length||t(`tools`,`Add at least one tool: a host runs only its tools.`);let s=i.has(`guardrails`)?hn(e.guardrails,t,he):void 0;return{profile:Dn({type:`host`,id:e.identity.agentId.trim(),tools:o,...s?{guardrails:s}:{},...X(e,i,t)}),customTools:a}}function In(e,t,n,r,i,a){let o=new Set(L(e)),s=t=>z(e,t),{system:c,conditions:l}=mt(e,n),u=ct(e,t,n,i),{outputs:d,structured:f}=o.has(`outputs`)?Kt(e.outputs,s(`outputs.structured`),n):{},{customTools:p,tools:m}=o.has(`tools`)?Rt(e,s(`tools.t2Loader`),s(`tools.parallel`),n,i,a):{customTools:[]},h=o.has(`turnBehaviour`)?Jt(e.turnBehaviour,s(`turnBehaviour.resumption`),n):void 0,g=o.has(`guardrails`)?hn(e.guardrails,n):void 0;return{profile:Dn({type:t,id:e.identity.agentId.trim(),identity:{handle:e.identity.handle.trim(),...l?{conditions:l}:{},...c?{system:c}:{}},...u,...o.has(`image`)?{image:bn(e.image,n)}:{},...o.has(`speech`)?{speech:xn(e.speech,e,n)}:{},...o.has(`live`)?{live:Cn(e.live,n,r)}:{},...m?{tools:m}:{},...o.has(`inputs`)?t===`live`?Wt(e.inputs,n):{inputs:zt(e.inputs,t,n)}:{},...d?{outputs:d}:{},...h?{turnBehaviour:h}:{},...g?{guardrails:g}:{},...X(e,o,n)}),customTools:p,...f?{structured:f}:{}}}function Ln(e,t,n=Je,r=Ye){let i=[],a=(e,t,n,r)=>{i.push({nodeId:e,message:t,...n===void 0?{}:{field:n},...r===void 0?{}:{index:r}})};Qe(e,a),new Set([e.models.key,e.models.fallbackKey,...e.modelBindings.flatMap(t=>{let{keySlot:n,fallbackKeySlot:r}=R(e,t);return[n,r]})].filter(Boolean)).size>32&&a(`models`,`The studio supports up to 32 key slots.`,`key`);let o=e.identity.profileType;if(!o)return a(`identity`,`Pick a profile type.`,`profileType`),{ok:!1,issues:i};if(o!==`host`)for(let n of e.modelBindings){if(!n.apiId.trim())continue;let r=ce({...E(e.providers,o,n),builtInTools:n.builtInTools},t);r&&a(B(n.key),r.message,r.field)}let s=o===`decision`?Pn(e,a,t):o===`host`?Fn(e,a,n,r):In(e,o,a,t,n,r);if(i.length)return{ok:!1,issues:i};try{De(un(s.profile))}catch(e){if(!(e instanceof A))throw e;return{ok:!1,issues:[{nodeId:`identity`,message:e.message}]}}return{ok:!0,agentId:s.profile.id,providers:e.providers,...s}}var Z=e(i(),1),Q=t(),Rn=(0,Z.lazy)(()=>b(()=>import(`./TraceInspector-36e6ozKD.js`).then(e=>({default:e.TraceGuardrailsBody})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83]))),zn=(0,Z.lazy)(()=>b(()=>import(`./TraceInspector-36e6ozKD.js`).then(e=>({default:e.TraceFeedBody})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83]))),Bn=(0,Z.createContext)(`replace`);function Vn({value:e,children:t}){return(0,Q.jsx)(Bn,{value:e,children:t})}function Hn({id:e,toggle:t,traces:n}){return(0,Q.jsx)(_,{id:e,children:e=>(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(m,{floating:!0,children:t}),children:(0,Q.jsx)(zn,{traces:n,isWide:e,end:t})})})}function Un(e,t,n){let r=ee(),i=(0,Z.useId)(),[a,o]=(0,Z.useState)(!1),s=(0,Z.use)(Bn),c={name:r(`@theorem.panel.trace.name`),show:r(`@theorem.panel.trace.show`),hide:r(`@theorem.panel.trace.hide`),resize:r(`@theorem.panel.trace.resize`)};if(e.observability?.record!==!0)return{toggle:null,view:null,labels:c,offered:!1};let u=n??a,d=e=>n===void 0?(0,Q.jsx)(y,{labels:c,icon:(0,Q.jsx)(l,{icon:ie}),panelId:i,open:u,size:e,onToggle:()=>o(e=>!e)}):null;return{toggle:d(),view:u?Wn(s===`panel`,i,t,d(`sm`)):null,labels:c,offered:!0}}function Wn(e,t,n,r){return e?(0,Q.jsx)(Gn,{id:t,toggle:r,traces:n}):(0,Q.jsx)(Hn,{id:t,toggle:r,traces:n})}function Gn({id:e,toggle:t,traces:n}){let{ref:r,width:i}=h();return(0,Q.jsx)(`div`,{id:e,ref:r,style:{height:`100%`,position:`relative`},children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(m,{floating:!0,children:t}),children:(0,Q.jsx)(zn,{traces:n,isWide:p(i),end:t})})})}function Kn({inspector:e,children:t}){let n=(0,Z.useRef)(null),r=g(n,!1),i=(0,Z.useRef)(void 0),a=(0,Z.useCallback)(e=>{n.current=e;let t=i.current;typeof t==`function`?t(e):t!=null&&(t.current=e)},[]);if(!(0,Z.isValidElement)(t))return(0,Q.jsx)(v,{view:e.view,children:t});i.current=t.props.ref;let o=e.view!=null;return(0,Z.cloneElement)(t,{ref:a,end:(0,Q.jsx)(f,{labels:e.labels,resizable:r.resizable,open:o,children:e.view})})}function qn({inspector:e,children:t}){return(0,Z.use)(Bn)===`panel`&&e.offered?(0,Q.jsx)(Kn,{inspector:e,children:t}):(0,Q.jsx)(v,{view:e.view,children:t})}function Jn({records:e,head:t}){return(0,Q.jsx)(te,{children:(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(Rn,{records:e,head:t})})})}var Yn={info:`info`,warning:`warning`,error:`error`,success:`success`},Xn={info:`accent`,warning:`warning`,error:`error`,success:`success`},$={root:{k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,kMv6JI:`xjb2p0i`,$$css:!0},rootElevatedCard:{kaIpWk:`x1vf2byn`,$$css:!0},header:{k1xSpc:`x78zum5`,kGNEyG:`x1cy8zhl`,kwnvtZ:`x1a02dak`,k1C7PZ:`xak3so`,khm7nJ:`x4olc9o`,k8WAf4:`x8o8v82`,kg3NbH:`x1pzlopt`,$$css:!0},headerCardStandalone:{kaIpWk:`x1vf2byn`,$$css:!0},headerCardWithContent:{krdFHd:`xwxb7qi`,kfmiAY:`x13nour3`,kVL7Gh:`xbiv7yw`,kT0f0o:`x16uus16`,$$css:!0},headerCentered:{kGNEyG:`x6s0dn4`,$$css:!0},endArea:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kwnvtZ:`x1a02dak`,kjj79g:`x13a6bvl`,kOIVth:`x1txdalj`,kmuXW:`x2lah0s`,ks0D6T:`x193iq5w`,keTefX:`xvc5jky`,kqGvvJ:`x81ka23`,$$css:!0},chevron:{k1ekBW:`x11xpdln`,kIyJzY:`xuedmi6 x12w9bfk`,kAMwcw:`xlr8y92`,$$css:!0},chevronExpanded:{k3aq6I:`x19jd1h0`,$$css:!0}},Zn={info:{kWkggS:`xgcxg3y`,$$css:!0},warning:{kWkggS:`x24i8r5`,$$css:!0},error:{kWkggS:`x1pritpl`,$$css:!0},success:{kWkggS:`xu13z74`,$$css:!0}};function Qn(e){return Object.prototype.hasOwnProperty.call(Zn,e)}var $n={none:{kGVxlE:`x1gnnqk1`,$$css:!0},low:{kGVxlE:`x1i5ehqx`,$$css:!0},med:{kGVxlE:`x14hfi27`,$$css:!0},high:{kGVxlE:`x1kcpxr7`,$$css:!0}};function er({status:e,title:t,description:i,icon:f,isDismissable:p=!1,onDismiss:m,dismissLabel:h,endContent:g,container:_=`card`,elevation:v=`none`,collapsible:y=!0,children:b,xstyle:ee,className:te,style:x,ref:ie,onFocusCapture:ae,onPointerDownCapture:S,...oe}){let C=u(),[se,w]=(0,Z.useState)(!1),T=typeof y==`object`&&y?y:{},{isEnabled:E,isOpen:D,toggle:ce}=d({isCollapsible:y!==!1&&{...T,defaultIsOpen:T.defaultIsOpen??!1}}),O=(0,Z.useRef)(null),k=(0,Z.useId)(),A=Yn[e],le=Xn[e],j=c(b),M=C(`@astryx.banner.dismiss`),N=h??M,ue=h??(typeof t==`string`?C(`@astryx.banner.dismissTitled`,{dismiss:M,title:t}):M);if(se)return null;let P=(e,t)=>{e instanceof HTMLElement&&e!==document.body&&!t.contains(e)&&(O.current=e)},F=e=>{P(e.relatedTarget,e.currentTarget)},de=e=>{P(document.activeElement,e.currentTarget)},fe=()=>{let e=O.current;w(!0),m?.(),e?.isConnected&&e.focus()},I=E&&j,pe=c(g)||p||I,me=c(g)||p,he=!c(i)&&me,L=j&&(!E||D),R=_===`card`;return(0,Q.jsxs)(`div`,{ref:ie,onFocusCapture:s(ae,F),onPointerDownCapture:s(S,de),...o(r(`banner-frame`,{container:_,elevation:v}),n($.root,$n[v],R&&v!==`none`&&$.rootElevatedCard,ee),te,x),...oe,children:[(0,Q.jsxs)(`div`,{...o(r(`banner`,{container:_,status:e}),n($.header,he&&$.headerCentered,Qn(e)&&Zn[e],R&&(L?$.headerCardWithContent:$.headerCardStandalone))),children:[(0,Q.jsx)(`div`,{...c(f)?o(r(`banner-icon`,{status:e}),{className:`x78zum5 x6s0dn4 x2lah0s`}):{className:`x78zum5 x6s0dn4 x2lah0s`},"aria-hidden":`true`,children:c(f)?f:A==null?null:(0,Q.jsx)(l,{icon:A,size:`md`,color:le,...r(`banner-icon`,{status:e})})}),(0,Q.jsxs)(`div`,{...{0:{className:`x78zum5 xdt5ytf xxhr3t x98rzlu xeuugli`},1:{className:`x78zum5 xdt5ytf xxhr3t x98rzlu xeuugli xgualba`}}[!!c(g)|0],children:[(0,Q.jsx)(`div`,{className:`x1ghz6dp xjb2p0i xcr08ib x2mo6ok x1kq96og x1tgivj0 xj0a0fe`,children:t}),c(i)&&(0,Q.jsx)(`div`,{...o(r(`banner-description`),{className:`x1ghz6dp xjb2p0i x141an7d x1sodnla x1ltkj2j xv1l7n4 xj0a0fe`}),children:i})]}),pe&&(0,Q.jsxs)(`div`,{...n($.endArea,ne.inset(a[`--spacing-2`])),children:[g,I&&(0,Q.jsx)(re,{variant:`ghost`,size:`sm`,label:C(D?`@astryx.banner.collapse`:`@astryx.banner.expand`),tooltip:C(D?`@astryx.banner.collapse`:`@astryx.banner.expand`),icon:(0,Q.jsx)(l,{icon:`chevronDown`,size:`sm`,color:`inherit`,xstyle:[$.chevron,D&&$.chevronExpanded]}),onClick:ce,"aria-expanded":D,"aria-controls":L?k:void 0,isIconOnly:!0}),p&&(0,Q.jsx)(re,{variant:`ghost`,size:`sm`,label:ue,tooltip:N,icon:(0,Q.jsx)(l,{icon:`close`,size:`sm`,color:`inherit`}),onClick:fe,isIconOnly:!0})]})]}),L&&(0,Q.jsx)(`div`,{id:I?k:void 0,...o(r(`banner-content`,{container:_,status:e}),{0:{className:`x1de1mus x8o8v82 x1pzlopt xgbv0en xw8tdv1 x92x3c3 x1t7ytsu x18b5jzi x1q0q8m5 x1j92z86 x1gejf6u xw8gpjh`},1:{className:`x1de1mus x8o8v82 x1pzlopt xgbv0en xw8tdv1 x92x3c3 x1t7ytsu x18b5jzi x1q0q8m5 x1j92z86 x1gejf6u xw8gpjh x1k5g1gk x1eprgri`}}[!!R|0]),children:b})]})}er.displayName=`Banner`;export{Ue as _,Un as a,Ne as b,Et as c,Qt as d,un as f,ze as g,Ve as h,qn as i,Dt as l,We as m,Jn as n,Ct as o,H as p,Vn as r,Ln as s,er as t,pt as u,He as v,Pe as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e,l as t,n}from"./themeProps-3IqahpCr.js";import{f as r,l as i,p as a,u as o}from"./padding.stylex-B76907Zf.js";import{t as s}from"./mergeProps-ptS-gIMz.js";import{t as c}from"./createReactComponent-CZwsv6DD.js";var l=c(`outline`,`external-link`,`ExternalLink`,[[`path`,{d:`M12 6h-6a2 2 0 0 0 -2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-6`,key:`svg-0`}],[`path`,{d:`M11 13l9 -9`,key:`svg-1`}],[`path`,{d:`M15 4h5v5`,key:`svg-2`}]]),u=c(`outline`,`microphone`,`Microphone`,[[`path`,{d:`M9 5a3 3 0 0 1 3 -3a3 3 0 0 1 3 3v5a3 3 0 0 1 -3 3a3 3 0 0 1 -3 -3l0 -5`,key:`svg-0`}],[`path`,{d:`M5 10a7 7 0 0 0 14 0`,key:`svg-1`}],[`path`,{d:`M8 21l8 0`,key:`svg-2`}],[`path`,{d:`M12 17l0 4`,key:`svg-3`}]]),d=e(),f={base:{k1xSpc:`x78zum5`,$$css:!0},inline:{k1xSpc:`x3nfvp2`,$$css:!0},alignItemsCenter:{kGNEyG:`x6s0dn4`,$$css:!0},justifyContentCenter:{kjj79g:`xl56j7k`,$$css:!0}},p={sizing:(e,t,n,r)=>[{kzqmXN:e==null?e:`x5lhr3w`,kZKoxP:t==null?t:`x16ye13r`,ks0D6T:n==null?n:`xf68679`,kAzted:r==null?r:`x82snj4`,$$css:!0},{"--x-width":(e=>typeof e==`number`?e+`px`:e??void 0)(e),"--x-height":(e=>typeof e==`number`?e+`px`:e??void 0)(t),"--x-maxWidth":(e=>typeof e==`number`?e+`px`:e??void 0)(n),"--x-minHeight":(e=>typeof e==`number`?e+`px`:e??void 0)(r)}]};function m({axis:e=`both`,width:c,height:l,maxWidth:u,minHeight:m,padding:h,paddingInline:g,paddingInlineStart:_,paddingInlineEnd:v,paddingBlock:y,paddingBlockStart:b,paddingBlockEnd:x,isInline:S=!1,children:C,xstyle:w,className:T,style:E,ref:D,...O}){let k=_??g??h,A=v??g??h,j=b??y??h,M=x??y??h,N=s(n(`center`,{axis:e}),t(S?f.inline:f.base,(e===`both`||e===`vertical`)&&f.alignItemsCenter,(e===`both`||e===`horizontal`)&&f.justifyContentCenter,p.sizing(c??null,l??null,u??null,m??null),k!=null&&a[k],A!=null&&r[A],j!=null&&o[j],M!=null&&i[M],w),T,E);return(0,d.jsx)(`div`,{ref:D,...O,...N,children:C})}m.displayName=`Center`;export{u as n,l as r,m as t};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,u as n}from"./themeProps-3IqahpCr.js";import{c as r,l as i,n as a,t as o}from"./SegmentedControlItem-CZs-ycSA.js";import{t as s}from"./VStack-CkVMcNiK.js";import{n as c,t as l}from"./StackItem-CQviqAfM.js";import{p as u}from"./fieldParts-CoOpDoax.js";import{i as d}from"./useResolvedRequired-DbsOcDqy.js";import{_ as f,a as p,c as ee,f as te,g as ne,i as m,l as re,x as ie}from"./SidePanel-DEd3R1Q3.js";import{t as h}from"./Text-BOqCfzZC.js";import{n as g}from"./labels-provider-t4c-5JMk.js";import{n as _,t as v}from"./Card-DruykyeB.js";import{n as y,t as ae}from"./IconButton-DVUFx-8p.js";import{n as b}from"./ScrollableArea-ChTx-OVZ.js";import{i as oe}from"./Banner-
|
|
2
|
-
`).length,t),n)}var W=(0,E.createContext)({images:{},onImages:()=>{}});function we({value:e,label:t,isLabelHidden:n}){let r=g(),{images:i,onImages:a}=(0,E.useContext)(W),{read:o,status:s}=H(),[u,d]=(0,E.useState)(!1),f=Object.hasOwn(i,e)?A(i[e]):void 0;return(0,B.jsxs)(c,{gap:2,vAlign:`center`,children:[(0,B.jsx)(
|
|
3
|
-
`))),[o]=(0,E.useState)(()=>typeof e==`string`&&Object.hasOwn(i,e));if(o&&typeof e==`string`)return(0,B.jsx)(we,{value:e,label:n,isLabelHidden:r});if(typeof e==`boolean`)return(0,B.jsx)(pe,{label:n,value:e,onChange:t});if(typeof e==`number`)return(0,B.jsx)(
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,u as n}from"./themeProps-3IqahpCr.js";import{c as r,l as i,n as a,t as o}from"./SegmentedControlItem-CZs-ycSA.js";import{t as s}from"./VStack-CkVMcNiK.js";import{n as c,t as l}from"./StackItem-CQviqAfM.js";import{p as u}from"./fieldParts-CoOpDoax.js";import{i as d}from"./useResolvedRequired-DbsOcDqy.js";import{_ as f,a as p,c as ee,f as te,g as ne,i as m,l as re,x as ie}from"./SidePanel-DEd3R1Q3.js";import{t as h}from"./Text-BOqCfzZC.js";import{n as g}from"./labels-provider-t4c-5JMk.js";import{n as _,t as v}from"./Card-DruykyeB.js";import{n as y,t as ae}from"./IconButton-DVUFx-8p.js";import{n as b}from"./ScrollableArea-ChTx-OVZ.js";import{i as oe}from"./Banner-DrRNC3MG.js";import{n as se}from"./row-keys-WByP9Hsh.js";import{t as x}from"./Center-CgO0c-qo.js";import{a as S,o as ce}from"./shaped-data-CJQ3W_RE.js";import{n as C}from"./trace-patterns-D6TbkLLr.js";import{A as le,C as w,G as ue,M as de,Pt as fe,S as pe,V as me,w as T}from"./index-B7sK7d-l.js";var E=e(n(),1),he=new Set([`image/png`,`image/jpeg`]),D=`image/png,image/jpeg`;function O(e,t){let n=e.replace(/\.[^.]*$/,``).toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``)||`image`,r=`<${n}>`;for(let e=2;t.includes(r);e+=1)r=`<${n}_${String(e)}>`;return r}async function k(e){if(!he.has(e.type))return null;let t=new Uint8Array(await e.arrayBuffer()),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.subarray(e,e+32768));return{mimeType:e.type,data:btoa(n)}}function A(e){return`data:${e.mimeType};base64,${e.data}`}function j(e,t){return typeof e==`string`?e===t:Array.isArray(e)?e.some(e=>j(e,t)):typeof e==`object`&&e?Object.values(e).some(e=>j(e,t)):!1}function M(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>j(t,e)))}function N(e,t,n){let r=O(e,[...Object.keys(t),...n.map(e=>`<${e}>`)]);return{key:r.slice(1,-1),reference:r}}function P(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function F(e,t){let{images:n,state:r}=t;for(let[i,a]of e){let{key:e,reference:o}=N(i.name,{...t.host,...n},Object.keys(r));n={...n,[o]:a},r={...r,[e]:o}}return{images:n,state:r}}function I(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;n=Array.isArray(n)?n[Number(e)]:n[e]}return n}function L(e,t,n){let r=n===void 0||n in e?n:I(t,n);if(typeof r==`string`&&r in e)return e[r];let i=Object.values(e);return n===void 0&&i.length===1?i[0]:void 0}function R(e,t,n){return{x:e.left*t,y:e.top*n,width:(e.right-e.left)*t,height:(e.bottom-e.top)*n,line:Math.max(2,Math.round(Math.min(t,n)/200))}}var ge=.45;async function _e(e,t,n){let r=new Image;r.src=e,await r.decode();let i=document.createElement(`canvas`);i.width=r.naturalWidth,i.height=r.naturalHeight;let a=i.getContext(`2d`);if(!a)return e;let o=R(t,i.width,i.height);return a.drawImage(r,0,0),a.fillStyle=n.shade,a.globalAlpha=ge,a.beginPath(),a.rect(0,0,i.width,i.height),a.rect(o.x,o.y,o.width,o.height),a.fill(`evenodd`),a.globalAlpha=1,a.strokeStyle=n.outline,a.lineWidth=o.line,a.strokeRect(o.x,o.y,o.width,o.height),i.toDataURL(`image/png`)}function ve(e){let t=e.right-e.left,n=e.bottom-e.top;return{width:100/t,height:100/n,left:-e.left/t*100,top:-e.top/n*100}}function ye(e){return e.every(e=>typeof e==`string`)}function z(e){return e==null||typeof e==`string`?``:typeof e==`number`?0:typeof e==`boolean`?!1:Array.isArray(e)?[]:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,z(t)]))}function be(e){let t=e[0];if(typeof t!=`object`||!t||Array.isArray(t))return null;let n=Object.keys(t);return n.length===0||n.length>4||!e.every(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.keys(e).join()===n.join()&&Object.values(e).every(e=>typeof e!=`object`||!e))?null:n.map(t=>{let n=e.map(e=>String(e[t]??``).length),r=Math.max(t.length,...n);return{key:t,weight:Math.min(4,Math.max(1,Math.round(r/10)))}})}var B=t();function V(e){return e===null?[]:Array.isArray(e)?e:[e]}function H(){let e=g(),[t,n]=(0,E.useState)(null);return{read:async e=>{n(null);let t=[];for(let r of V(e)){let e=await k(r);e?t.push([r,e]):n(r.name)}return t},status:t===null?void 0:{type:`error`,message:e(`@theorem.decision.image_bad`,{file:t})}}}function xe({onImages:e}){let t=g(),{read:n,status:r}=H();return(0,B.jsx)(w,{label:t(`@theorem.decision.add_image`),isLabelHidden:!0,mode:`dropzone`,isMultiple:!0,accept:D,value:null,placeholder:t(`@theorem.decision.add_image_hint`),status:r,statusVariant:`detached`,onChange:t=>{n(t).then(t=>{t.length>0&&e(t)})}})}var Se={search:()=>[],bootstrap:()=>[]},Ce=48;function U(e,t,n){return Math.min(Math.max(e.split(`
|
|
2
|
+
`).length,t),n)}var W=(0,E.createContext)({images:{},onImages:()=>{}});function we({value:e,label:t,isLabelHidden:n}){let r=g(),{images:i,onImages:a}=(0,E.useContext)(W),{read:o,status:s}=H(),[u,d]=(0,E.useState)(!1),f=Object.hasOwn(i,e)?A(i[e]):void 0;return(0,B.jsxs)(c,{gap:2,vAlign:`center`,children:[(0,B.jsx)(ue,{src:f,alt:t,label:e,onClick:f?()=>d(!0):void 0}),f?(0,B.jsx)(me,{isOpen:u,onOpenChange:d,media:{src:f,alt:t,caption:e},hasZoom:!0}):null,(0,B.jsx)(l,{size:`fill`,children:(0,B.jsx)(w,{label:t,isLabelHidden:n,accept:D,value:null,placeholder:r(`@theorem.decision.replace_image`),status:s,statusVariant:`detached`,onChange:t=>{o(t).then(([t])=>{t&&a({...i,[e]:t[1]})})}})})]})}function G({value:e,onChange:t,label:n,isLabelHidden:r}){let{images:i}=(0,E.useContext)(W),[a]=(0,E.useState)(()=>typeof e==`string`&&(e.length>Ce||e.includes(`
|
|
3
|
+
`))),[o]=(0,E.useState)(()=>typeof e==`string`&&Object.hasOwn(i,e));if(o&&typeof e==`string`)return(0,B.jsx)(we,{value:e,label:n,isLabelHidden:r});if(typeof e==`boolean`)return(0,B.jsx)(pe,{label:n,value:e,onChange:t});if(typeof e==`number`)return(0,B.jsx)(de,{label:n,isLabelHidden:r,size:`sm`,value:e,isWheelEnabled:!1,onChange:t});if(e===null)return(0,B.jsx)(b,{label:n,isLabelHidden:r,size:`sm`,value:``,placeholder:`null`,isDisabled:!0,onChange:()=>{}});let s=String(e);return a?(0,B.jsx)(T,{label:n,isLabelHidden:r,size:`sm`,rows:U(s,2,12),value:s,onChange:t}):(0,B.jsx)(b,{label:n,isLabelHidden:r,size:`sm`,value:s,onChange:t})}function K({label:e,isRequired:t,description:n,children:r}){let i=(0,E.useId)();return(0,B.jsxs)(s,{gap:2,role:`group`,"aria-labelledby":i,children:[(0,B.jsx)(d,{label:e,inputID:``,labelID:i,isGroupLabel:!0,isRequired:t,description:n}),r]})}function q({children:e,...t}){return(0,B.jsx)(K,{...t,children:(0,B.jsx)(`div`,{style:{paddingInlineStart:12,borderInlineStart:`1px solid var(--color-border)`},children:e})})}function J({field:e,onAdd:t}){let n=g();return(0,B.jsx)(c,{children:(0,B.jsx)(y,{label:n(`@theorem.decision.add_item`,{field:e}),size:`sm`,variant:`ghost`,icon:(0,B.jsx)(fe,{size:14}),onClick:t})})}function Y({index:e,onRemove:t}){let n=g();return(0,B.jsx)(ae,{label:n(`@theorem.decision.remove_item`,{item:n(`@theorem.data.item`,{index:String(e+1)})}),size:`sm`,variant:`ghost`,icon:(0,B.jsx)(u,{size:14}),onClick:t})}function X({value:e,onChange:t}){return(0,B.jsx)(s,{gap:3,children:Object.entries(e).map(([n,r])=>(0,B.jsx)(Z,{label:S(n),value:r,onChange:r=>t({...e,[n]:r})},n))})}function Te({value:e,onChange:t,label:n}){let r=g(),i=se(e);if(ye(e))return(0,B.jsx)(le,{label:n,size:`sm`,value:e.map((e,t)=>({id:`${String(t)}:${e}`,label:e})),searchSource:Se,hasCreate:!0,debounceMs:0,placeholder:r(`@theorem.decision.add_value`),onChange:e=>t(e.map(e=>e.label))});let a=be(e),o=(0,B.jsx)(J,{field:n,onAdd:()=>t([...e,z(e.at(-1))])}),u=n=>(0,B.jsx)(Y,{index:n,onRemove:()=>{i.drop(n),t(e.filter((e,t)=>t!==n))}});if(a){let r={display:`grid`,gap:8,alignItems:`start`,gridTemplateColumns:`${a.map(e=>`minmax(0, ${String(e.weight)}fr)`).join(` `)} auto`},s=e;return(0,B.jsxs)(K,{label:n,children:[(0,B.jsxs)(`div`,{style:r,"aria-hidden":!0,children:[a.map(e=>(0,B.jsx)(h,{type:`supporting`,color:`secondary`,maxLines:1,children:S(e.key)},e.key)),(0,B.jsx)(`span`,{style:{width:28}})]}),i.rows.map(({index:e,key:n})=>{let i=s[e];return(0,B.jsxs)(`div`,{style:r,children:[a.map(n=>(0,B.jsx)(G,{label:`${S(n.key)} ${String(e+1)}`,isLabelHidden:!0,value:i[n.key]??null,onChange:r=>t(s.map((t,i)=>i===e?{...t,[n.key]:r}:t))},n.key)),u(e)]},n)}),o]})}return(0,B.jsx)(q,{label:n,children:(0,B.jsxs)(s,{gap:3,children:[i.rows.map(({item:n,index:i,key:a})=>{let o=r(`@theorem.data.item`,{index:String(i+1)}),s=n=>t(e.map((e,t)=>t===i?n:e));return(0,B.jsxs)(c,{gap:2,vAlign:`start`,children:[(0,B.jsx)(l,{size:`fill`,children:ce(n)?(0,B.jsx)(G,{label:o,isLabelHidden:!0,value:n,onChange:s}):(0,B.jsx)(Z,{label:o,value:n,onChange:s})}),u(i)]},a)}),o]})})}function Z({value:e,onChange:t,label:n}){return Array.isArray(e)?(0,B.jsx)(Te,{label:n,value:e,onChange:t}):typeof e==`object`&&e?(0,B.jsx)(q,{label:n,children:(0,B.jsx)(X,{value:e,onChange:t})}):(0,B.jsx)(G,{label:n,value:e,onChange:t})}function Ee({value:e,onChange:t,label:n}){return typeof e==`object`&&e&&!Array.isArray(e)?(0,B.jsx)(X,{value:e,onChange:t}):(0,B.jsx)(Z,{label:n,value:e,onChange:t})}var De={"--theorem-console-card":`var(--color-background-muted)`},Q=`(width < 768px)`,$=(0,E.createContext)(!0);function Oe(){return(0,E.useSyncExternalStore)(e=>{let t=globalThis.matchMedia(Q);return t.addEventListener(`change`,e),()=>{t.removeEventListener(`change`,e)}},()=>globalThis.matchMedia(Q).matches,()=>!1)}function ke({flush:e,wide:t,maxWidth:n,children:r}){let i=(0,B.jsx)(x,{axis:`horizontal`,width:`100%`,minHeight:`100%`,children:(0,B.jsx)(s,{width:`100%`,maxWidth:t?void 0:n,gap:3,padding:4,children:r})});return e?(0,B.jsx)(s,{height:`100%`,paddingInlineStart:3,style:{...De,paddingInlineEnd:te(3)},children:(0,B.jsx)(v,{variant:`transparent`,height:`100%`,padding:0,style:{overflowY:`auto`},children:i})}):(0,B.jsx)(m,{inset:`all`,padding:0,isScrollable:!0,children:i})}function Ae({inspector:e,maxWidth:t,flush:n=!1,columns:a=!1,requestLabel:o,className:s,style:c,children:l}){let u=(0,E.useRef)(null),d=e.toggle?(0,B.jsx)(re,{floating:!0,children:e.toggle}):void 0;return(0,B.jsx)(oe,{inspector:e,children:(0,B.jsx)(i,{ref:u,height:`fill`,className:s,style:{position:`relative`,...c},header:d,content:(0,B.jsx)(r,{padding:0,isScrollable:!1,children:(0,B.jsx)(je,{layoutRef:u,flush:n,columns:a,maxWidth:t,requestLabel:o,children:l})})})})}function je({layoutRef:e,flush:t,columns:n,maxWidth:r,requestLabel:i,children:a}){let o=Oe(),s=E.Children.toArray(a).length,c=n&&s>1;return c&&!o?(0,B.jsx)(Me,{requestLabel:i,layoutRef:e,children:a}):(0,B.jsx)(ke,{flush:t,wide:c,maxWidth:r,children:a})}function Me({requestLabel:e=`Request`,layoutRef:t,children:n}){let a=g(),o=(0,E.useRef)(null),[s]=(0,E.useState)(()=>t.current?.clientWidth??0),c=ne({defaultSize:s>0?Math.round(s*.4):`40%`,minSize:280,maxSize:f(70,{min:ie(280)}),containerRef:o}),[l,u]=E.Children.toArray(n),d={name:e,show:e,hide:e,resize:a(`@theorem.panel.resize`,{name:e})};return(0,B.jsx)($,{value:!1,children:(0,B.jsx)(i,{ref:o,height:`fill`,start:(0,B.jsx)(ee,{side:`start`,className:`theorem-console-request`,labels:d,resizable:c,open:!0,children:(0,B.jsx)(p,{label:e,children:l})}),content:(0,B.jsx)(r,{padding:0,isScrollable:!1,children:(0,B.jsx)(m,{inset:`beside`,className:`theorem-console-response`,children:u})})})})}function Ne({children:e}){return(0,B.jsx)(v,{variant:`muted`,padding:0,className:`theorem-console-card`,style:C,children:(0,B.jsx)($,{value:!1,children:e})})}function Pe({label:e,fill:t=!1,children:n}){return(0,E.use)($)?(0,B.jsx)(v,{variant:`muted`,padding:t?0:4,className:`theorem-console-card`,style:C,children:t?n:(0,B.jsx)(s,{height:`100%`,gap:3,children:n})}):t?n:(0,B.jsx)(p,{label:e,padding:4,children:n})}function Fe(e){return t=>{t.key===`Enter`&&(t.metaKey||t.ctrlKey)&&(t.preventDefault(),e())}}function Ie({title:e,onRun:t,children:n,...r}){let i=g(),l=(0,E.use)($),u=(0,B.jsxs)(s,{gap:3,padding:l?void 0:4,onKeyDown:Fe(t),children:[(0,B.jsxs)(c,{gap:2,hAlign:`between`,vAlign:`center`,children:[(0,B.jsx)(h,{type:`supporting`,color:`secondary`,as:`h3`,children:e}),r.onView?(0,B.jsxs)(a,{label:i(`@theorem.decision.view`),size:`sm`,value:r.view,onChange:e=>{r.onView(e===`json`?`json`:`fields`)},children:[(0,B.jsx)(o,{value:`fields`,label:i(`@theorem.decision.fields`),isDisabled:!r.hasFields}),(0,B.jsx)(o,{value:`json`,label:i(`@theorem.data.json`)})]}):r.actions]}),n]});return l?(0,B.jsx)(v,{variant:`muted`,padding:4,className:`theorem-console-card`,style:C,children:u}):u}var Le={"--font-family-body":`var(--font-family-code)`};function Re({label:e,text:t,isInvalid:n,onChange:r}){return(0,B.jsx)(T,{label:e,isLabelHidden:!0,value:t,onChange:r,rows:U(t,8,24),hasSpellCheck:!1,status:n?{type:`error`}:void 0,controlStyle:Le})}function ze({note:e,isReady:t,isRunning:n,runLabel:r,runningLabel:i,stopLabel:a,onRun:o,onStop:s}){return(0,B.jsxs)(c,{gap:3,hAlign:`between`,vAlign:`center`,children:[(0,B.jsx)(h,{type:`supporting`,color:`secondary`,style:t?void 0:{color:`var(--color-error)`},hasTabularNumbers:!0,children:e}),(0,B.jsxs)(c,{gap:2,vAlign:`center`,children:[n?(0,B.jsx)(y,{label:a,variant:`ghost`,onClick:s}):null,(0,B.jsx)(y,{label:n?i:r,variant:`primary`,isLoading:n,isDisabled:!t,onClick:o})]})]})}function Be(){let e=_();return(0,E.useMemo)(()=>{let t=new Intl.NumberFormat(e,{style:`unit`,unit:`byte`,unitDisplay:`narrow`}),n=new Intl.NumberFormat(e,{style:`unit`,unit:`kilobyte`,unitDisplay:`narrow`,maximumFractionDigits:1});return e=>e<1024?t.format(e):n.format(e/1024)},[e])}export{P as S,ve as _,Pe as a,_e as b,J as c,Y as d,Ee as f,L as g,xe as h,Ie as i,q as l,U as m,Ne as n,ze as o,W as p,Re as r,Be as s,Ae as t,K as u,F as v,M as x,A as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e}from"./themeProps-3IqahpCr.js";import{t}from"./BottomSheet-Dbh6A5Vl.js";import{
|
|
1
|
+
import{c as e}from"./themeProps-3IqahpCr.js";import{t}from"./BottomSheet-Dbh6A5Vl.js";import{J as n}from"./index-B7sK7d-l.js";var r=e();function i({finalFocusRef:e,isOpen:i,onOpenChange:a,label:o,children:s}){return(0,r.jsx)(t,{finalFocusRef:e,isOpen:i,onOpenChange:a,label:o,height:`hug`,purpose:`info`,children:(0,r.jsx)(n,{paddingBlockStart:4,paddingBlockEnd:0,paddingInline:1,children:s})})}i.displayName=`MenuBottomSheet`;export{i as MenuBottomSheet};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,u as n}from"./themeProps-3IqahpCr.js";import{n as r,t as i}from"./SegmentedControlItem-CZs-ycSA.js";import{t as a}from"./VStack-CkVMcNiK.js";import{n as o,t as s}from"./StackItem-CQviqAfM.js";import{t as c}from"./DateInput-CalwZl6a.js";import{t as l}from"./Text-BOqCfzZC.js";import{n as u}from"./labels-provider-t4c-5JMk.js";import{n as d}from"./ScrollableArea-ChTx-OVZ.js";import{n as f}from"./row-keys-WByP9Hsh.js";import{c as p,d as m,f as h}from"./tool-schema-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,u as n}from"./themeProps-3IqahpCr.js";import{n as r,t as i}from"./SegmentedControlItem-CZs-ycSA.js";import{t as a}from"./VStack-CkVMcNiK.js";import{n as o,t as s}from"./StackItem-CQviqAfM.js";import{t as c}from"./DateInput-CalwZl6a.js";import{t as l}from"./Text-BOqCfzZC.js";import{n as u}from"./labels-provider-t4c-5JMk.js";import{n as d}from"./ScrollableArea-ChTx-OVZ.js";import{n as f}from"./row-keys-WByP9Hsh.js";import{c as p,d as m,f as h}from"./tool-schema-BDG2_rlP.js";import{c as g,l as _}from"./shaped-data-CJQ3W_RE.js";import{c as v,d as y,l as b,u as x}from"./ConsoleFrame-BvgFGqp2.js";import{A as S,B as C,M as w,S as T,h as E,m as D,q as O,w as k,z as A}from"./index-B7sK7d-l.js";var j=e(n(),1),M=t(),N={search:()=>[],bootstrap:()=>[]},P={"--font-family-body":`var(--font-family-code)`},F=2;function I({text:e}){return(0,M.jsx)(l,{type:`supporting`,color:`secondary`,maxLines:F,children:e})}function L({field:e,children:t}){return(0,M.jsx)(x,{label:e.label,isRequired:e.isRequired,children:t})}function R({field:e,value:t,onChange:n}){let r=u(),[i,a]=(0,j.useState)(()=>t===void 0?``:_(t)),[o,s]=(0,j.useState)(!0);return(0,M.jsx)(k,{label:e.label,isRequired:e.isRequired,size:`sm`,rows:3,value:i,hasSpellCheck:!1,status:o?void 0:{type:`error`,message:r(`@theorem.decision.invalid_json`)},controlStyle:P,onChange:e=>{if(a(e),e.trim()===``)s(!0),n(void 0);else try{n(JSON.parse(e)),s(!0)}catch{s(!1)}}})}function z({field:e,item:t,value:n,onChange:r}){let i=Array.isArray(n)?n:[],c=f(i);return(0,M.jsx)(b,{label:e.label,isRequired:e.isRequired,description:e.description&&(0,M.jsx)(I,{text:e.description}),children:(0,M.jsxs)(a,{gap:3,children:[c.rows.map(({item:e,index:n,key:a})=>(0,M.jsxs)(o,{gap:2,vAlign:`start`,children:[(0,M.jsx)(s,{size:`fill`,children:(0,M.jsx)(Y,{schema:t,value:g(e)?e:{},onChange:e=>r(i.map((t,r)=>r===n?e:t))})}),(0,M.jsx)(y,{index:n,onRemove:()=>{c.drop(n),r(i.filter((e,t)=>t!==n))}})]},a)),(0,M.jsx)(v,{field:e.label,onAdd:()=>r([...i,p(t)])})]})})}function B(e){return{label:e.label,isRequired:e.isRequired,size:`sm`}}function V({field:e,options:t,isMenu:n,value:a,onChange:s}){return n?(0,M.jsx)(O,{...B(e),options:t,value:typeof a==`string`?a:void 0,hasSearch:t.length>10,onChange:s}):(0,M.jsx)(L,{field:e,children:(0,M.jsx)(o,{children:(0,M.jsx)(r,{label:e.label,size:`sm`,value:typeof a==`string`?a:``,onChange:s,children:t.map(e=>(0,M.jsx)(i,{value:e,label:e},e))})})})}function H({field:e,isLong:t,type:n,value:r,onChange:i}){let a=typeof r==`string`?r:``;return t?(0,M.jsx)(k,{...B(e),rows:3,value:a,onChange:i}):(0,M.jsx)(d,{...B(e),type:n,value:a,onChange:i})}function U({field:e,value:t,onChange:n}){let r=u(),i=Array.isArray(t)?t:[];return(0,M.jsx)(S,{...B(e),value:i.map((e,t)=>({id:`${String(t)}:${String(e)}`,label:String(e)})),searchSource:N,hasCreate:!0,debounceMs:0,placeholder:r(`@theorem.decision.add_value`),onChange:e=>n(e.map(e=>typeof i[0]==`number`&&Number.isFinite(Number(e.label))?Number(e.label):e.label))})}var W={choice:({field:e,control:t,value:n,onChange:r})=>(0,M.jsx)(V,{field:e,options:t.options,isMenu:t.isMenu,value:n,onChange:r}),range:({field:e,control:t,value:n,onChange:r})=>(0,M.jsx)(D,{label:e.label,isRequired:e.isRequired,min:t.min,max:t.max,step:1,value:typeof n==`number`?n:t.min,valueDisplay:`text`,onChange:r}),number:({field:e,control:t,value:n,onChange:r})=>(0,M.jsx)(w,{...B(e),value:typeof n==`number`?n:void 0,min:t.min,max:t.max,isIntegerOnly:t.isInteger,isWheelEnabled:!1,onChange:e=>r(e??void 0)}),switch:({field:e,value:t,onChange:n})=>(0,M.jsx)(T,{label:e.label,value:t===!0,onChange:n}),date:({field:e,value:t,onChange:n})=>(0,M.jsx)(c,{...B(e),value:typeof t==`string`?t:void 0,onChange:n}),text:({field:e,control:t,value:n,onChange:r})=>(0,M.jsx)(H,{field:e,isLong:t.isLong,type:t.type,value:n,onChange:r}),choices:({field:e,control:t,value:n,onChange:r})=>(0,M.jsx)(C,{label:e.label,value:Array.isArray(n)?n.filter(e=>typeof e==`string`):[],onChange:r,children:t.options.map(e=>(0,M.jsx)(A,{label:e,value:e},e))}),words:({field:e,value:t,onChange:n})=>(0,M.jsx)(U,{field:e,value:t,onChange:n}),rows:({field:e,control:t,value:n,onChange:r})=>(0,M.jsx)(z,{field:e,item:t.item,value:n,onChange:r}),group:({field:e,control:t,value:n,onChange:r})=>(0,M.jsx)(b,{label:e.label,isRequired:e.isRequired,description:e.description&&(0,M.jsx)(I,{text:e.description}),children:(0,M.jsx)(Y,{schema:t.schema,value:g(n)?n:{},onChange:r})}),json:({field:e,value:t,onChange:n})=>(0,M.jsx)(R,{field:e,value:t,onChange:n})};function G({field:e,value:t,onChange:n}){let r=W[e.control.kind],i=r({field:e,control:e.control,value:t,onChange:n}),o=e.control.kind===`rows`||e.control.kind===`group`;return!e.description||o?i:(0,M.jsxs)(a,{gap:1,children:[i,(0,M.jsx)(I,{text:e.description})]})}var K=200,q=18;function J({control:e}){switch(e.kind){case`number`:case`switch`:case`date`:return!0;case`choice`:return e.isMenu||e.options.join(``).length<=q;case`text`:return!e.isLong;default:return!1}}function Y({schema:e,value:t,onChange:n}){return(0,M.jsx)(E,{columns:{minWidth:K,repeat:`fill`},gap:3,children:m(e).map(e=>(0,M.jsx)(`div`,{style:J(e)?{minWidth:0,alignSelf:`start`}:{gridColumn:`1 / -1`,minWidth:0},children:(0,M.jsx)(G,{field:e,value:t[e.key],onChange:r=>n(h(t,e.key,r))})},e.key))})}function X({schema:e,value:t,onChange:n}){return(0,M.jsx)(Y,{schema:e,value:t,onChange:n})}export{X as t};
|