@theoremjs/studio 0.3.4-next.693.g4ab1526 → 0.3.4-next.715.geef22fd
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/agreement.js +35 -5
- package/compile.d.ts +3 -3
- package/compile.js +43 -20
- package/cookbooks/catalog.js +8 -10
- package/draft.d.ts +12 -9
- package/draft.js +4 -4
- package/mod.d.ts +1 -2
- package/mod.js +1 -2
- package/package.json +4 -4
- package/page/assets/Banner-CrhjYjDy.js +3 -0
- package/page/assets/{ConsoleFrame-BvgFGqp2.js → ConsoleFrame-dOTqIkpb.js} +1 -1
- package/page/assets/{MenuBottomSheet-BZecY8fw.js → MenuBottomSheet-DeuZCVb-.js} +1 -1
- package/page/assets/{SchemaFields-BNNkvyyO.js → SchemaFields-DeuNDrvj.js} +1 -1
- package/page/assets/{ToolResultCharts-C3CPsfXl.js → ToolResultCharts-B-pokquL.js} +1 -1
- package/page/assets/{TraceInspector-36e6ozKD.js → TraceInspector-CvJ0wx9n.js} +1 -1
- package/page/assets/{TraceOverview-CSdJ_cYY.js → TraceOverview-cIjJwpvK.js} +1 -1
- package/page/assets/{_virtual_studio-type-sources-DSpwr3WK.js → _virtual_studio-type-sources-BxnDf9BC.js} +225 -85
- package/page/assets/browser-connection-CuWeoI9s.js +3 -0
- package/page/assets/browser-engine-C3SeJyrA.js +13 -0
- package/page/assets/{browser-transport-GzhRiBdm.js → browser-transport-DKhZ4zo1.js} +3 -3
- package/page/assets/{crypto-B8dqEoWf.js → crypto-BnoW7FFO.js} +1 -1
- package/page/assets/{encode-files-CHeRLBO8.js → encode-files-DoLGXgup.js} +1 -1
- package/page/assets/{export-agent-botXSyoH.js → export-agent-CO4lAMum.js} +1 -1
- package/page/assets/{guardrail-tester-DYR7EPIy.js → guardrail-tester-Slctc2oI.js} +1 -1
- package/page/assets/{index-B7sK7d-l.js → index-CAK9cdCh.js} +72 -76
- package/page/assets/{labels-provider-t4c-5JMk.js → labels-provider-uONlWExD.js} +1 -1
- package/page/assets/{live-messages-DN_q2nBN.js → live-messages-M0vS3YB0.js} +1 -1
- package/page/assets/people-CIsR0-5R.js +1 -0
- package/page/assets/reader-747-Cvu8.js +5 -0
- package/page/assets/{shaped-data-CJQ3W_RE.js → shaped-data-7q5Be8sp.js} +3 -3
- package/page/assets/{stub-U6wDGe3P.js → stub--LOYiyQO.js} +1 -1
- package/page/assets/studio-code-pane-CuccT4Ur.js +10 -0
- package/page/assets/{studio-console-B7zL133d.js → studio-console-DwxLzV9_.js} +1 -1
- package/page/assets/{studio-decision-CbRjfbvG.js → studio-decision-w6OjVUM3.js} +1 -1
- package/page/assets/{studio-embedding-DQ0QrEsu.js → studio-embedding-CxFoTvOd.js} +1 -1
- package/page/assets/studio-host-console-BhQSkUhA.js +2 -0
- package/page/assets/{studio-labels-jYWBoEyP.js → studio-labels-q6eBFSru.js} +1 -1
- package/page/assets/{studio-live-D0YRu2zQ.js → studio-live-D5NjMEky.js} +1 -1
- package/page/assets/{studio-map-C4Ra1QqL.js → studio-map-DlkGoGam.js} +1 -1
- package/page/assets/studio-session-ClF2iNCX.js +1 -0
- package/page/assets/{studio-trace-replay-D-f2p7k9.js → studio-trace-replay-Ccv4ToIz.js} +1 -1
- package/page/assets/{studio-type-checker-CVNPnko-.js → studio-type-checker-Dm2eit0p.js} +1 -1
- package/page/assets/{tool-schema-BDG2_rlP.js → tool-schema-6RWBAqGO.js} +2 -2
- package/page/assets/{trace-record-DoXjxrmJ.js → trace-record-Dm2jEhUR.js} +1 -1
- package/page/assets/tree-DcCW259J.js +3 -0
- package/page/assets/turn-client-OLK12Fyi.js +2 -0
- package/page/assets/{use-one-call-B3t-kfc5.js → use-one-call-CLndFp2X.js} +1 -1
- package/page/assets/use-second-ticker-D6JSf9B3.js +1 -0
- package/page/assets/{workspace-DUfaxr-g.js → workspace-DSAX72vF.js} +1 -1
- package/page/index.html +18 -17
- package/read-source.js +41 -8
- package/registrations.d.ts +9 -1
- package/runtime.js +1 -0
- package/section-notes.d.ts +1 -0
- package/section-notes.js +1 -0
- package/serve-page.mjs +8 -4
- package/server/handler.d.ts +0 -3
- package/server/handler.js +4 -26
- package/server/live.d.ts +1 -2
- package/server/live.js +3 -4
- package/server/save-plan.js +2 -1
- package/system-markup.d.ts +9 -7
- package/system-markup.js +38 -19
- package/tools.js +1 -0
- package/types.d.ts +3 -0
- package/ui/inspector-context.d.ts +1 -8
- package/ui/inspector-context.js +0 -7
- package/ui/inspector.d.ts +43 -1
- package/ui/inspector.js +50 -9
- package/ui/lib/entries.d.ts +13 -0
- package/ui/lib/entries.js +43 -0
- package/ui/lib/project-traces.js +2 -10
- package/ui/lib/studio-prefs.d.ts +0 -4
- package/ui/lib/studio-prefs.js +0 -7
- package/ui/lib/studio-project.d.ts +2 -5
- package/ui/lib/studio-project.js +1 -4
- package/ui/profile-editor.js +37 -49
- package/ui/studio-screen.d.ts +0 -1
- package/ui/studio-screen.js +8 -18
- package/ui/studio-settings.js +1 -12
- package/asks.d.ts +0 -61
- package/asks.js +0 -78
- package/page/assets/Banner-DrRNC3MG.js +0 -4
- package/page/assets/browser-connection-dads1eyK.js +0 -3
- package/page/assets/browser-engine-CugH58NS.js +0 -13
- package/page/assets/reader-DHN96tSr.js +0 -5
- package/page/assets/studio-code-pane-Boy63AK2.js +0 -8
- package/page/assets/studio-host-console-DDA2Um2-.js +0 -2
- package/page/assets/studio-session-CPnJaHc-.js +0 -1
- package/page/assets/tree-CcEbNvms.js +0 -3
- package/page/assets/turn-client-BmOSpCgw.js +0 -2
- package/page/assets/use-second-ticker-CWjCHLG6.js +0 -1
- package/ui/confirm-write.d.ts +0 -12
- package/ui/confirm-write.js +0 -45
package/agreement.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { BOUNDARIES, DETECTORS, resolveAllow, resolveDetect, TOOL_BOUNDARIES, } from '@theoremjs/agents/guardrails';
|
|
9
9
|
import { unsetValue } from '@theoremjs/agents/kernel';
|
|
10
10
|
import { STUDIO_POLICY_UNSET } from "./policy.js";
|
|
11
|
+
import { promptLine } from "./system-markup.js";
|
|
11
12
|
function isRecord(value) {
|
|
12
13
|
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
13
14
|
}
|
|
@@ -51,11 +52,40 @@ function detectAsRead(detect, boundaries) {
|
|
|
51
52
|
allow: Object.fromEntries(allow),
|
|
52
53
|
};
|
|
53
54
|
}
|
|
54
|
-
/**
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
/**
|
|
56
|
+
* A prompt as the studio holds it: no white space at the ends of a line or a private section.
|
|
57
|
+
* why: this is studio policy, so a prompt written with a closing newline opens as the same prompt.
|
|
58
|
+
*/
|
|
59
|
+
function promptAsHeld(system) {
|
|
60
|
+
if (typeof system === 'string')
|
|
61
|
+
return system.trim();
|
|
62
|
+
if (!Array.isArray(system))
|
|
63
|
+
return system;
|
|
64
|
+
return system.map((line) => {
|
|
65
|
+
if (typeof line === 'string')
|
|
66
|
+
return line.trim();
|
|
67
|
+
if (!Array.isArray(line))
|
|
68
|
+
return line;
|
|
69
|
+
return promptLine(line.map((part) => isRecord(part) && typeof part.private === 'string'
|
|
70
|
+
? { private: part.private.trim() }
|
|
71
|
+
: part));
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/** A profile with its prompt as the studio holds it. */
|
|
75
|
+
function promptRead(profile) {
|
|
76
|
+
if (!isRecord(profile.identity) || profile.identity.system === undefined)
|
|
77
|
+
return profile;
|
|
78
|
+
return {
|
|
79
|
+
...profile,
|
|
80
|
+
identity: { ...profile.identity, system: promptAsHeld(profile.identity.system) },
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/** A profile with its prompt as the studio holds it and its `detect` as the kernel reads it. */
|
|
84
|
+
function asRead(project) {
|
|
85
|
+
if (!isRecord(project))
|
|
86
|
+
return project;
|
|
87
|
+
const profile = promptRead(project);
|
|
88
|
+
if (!isRecord(profile.guardrails) || profile.guardrails.detect === undefined)
|
|
59
89
|
return profile;
|
|
60
90
|
return {
|
|
61
91
|
...profile,
|
package/compile.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type DecisionAsset, type DecisionQuestion, type ImageProfileDefinition, type LiveProfileDefinition, type ProfileGuardrailsSpec, type SpeechProfileDefinition, type TextProfileDefinition, type TranscriptionProfileDefinition } from '@theoremjs/agents';
|
|
2
2
|
import { type DecisionProfileDefinition, type EmbeddingProfileDefinition, type HostProfileDefinition, type ProfileDefinition } from '@theoremjs/agents/kernel';
|
|
3
|
-
import type { GuardrailsDraft, StudioDraft } from './draft.ts';
|
|
3
|
+
import type { ConditionDraft, GuardrailsDraft, StudioDraft } from './draft.ts';
|
|
4
4
|
import type { StudioRunsOn } from './lent-keys.ts';
|
|
5
5
|
import { type StudioProvider } from './providers.ts';
|
|
6
6
|
import type { StructuredRegistration, ToolRegistration } from './registrations.ts';
|
|
@@ -45,8 +45,8 @@ export type AgentIdOf = (key: string) => string | undefined;
|
|
|
45
45
|
* `undefined` when none has that key or an agent tool can't run it.
|
|
46
46
|
*/
|
|
47
47
|
export type AgentToolInputOf = (key: string) => Record<string, unknown> | undefined;
|
|
48
|
-
/** The conditions a draft declares so far:
|
|
49
|
-
export declare function draftConditions(
|
|
48
|
+
/** The conditions a draft declares so far: each one named with a value, the first of a name. */
|
|
49
|
+
export declare function draftConditions(conditions: readonly ConditionDraft[]): Record<string, string[]>;
|
|
50
50
|
/** What a tool that runs this draft's agent takes, as the kernel derives it from the agent's inputs. */
|
|
51
51
|
export declare function agentToolInputSchema(draft: StudioDraft): Record<string, unknown> | undefined;
|
|
52
52
|
/** Why these headers can't be saved, when one of them looks like a credential. */
|
package/compile.js
CHANGED
|
@@ -289,35 +289,57 @@ const isAny = (_value) => true;
|
|
|
289
289
|
function parseHeaders(raw) {
|
|
290
290
|
return parseRecord(raw, isString);
|
|
291
291
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
292
|
+
/** The conditions a draft declares so far: each one named with a value, the first of a name. */
|
|
293
|
+
export function draftConditions(conditions) {
|
|
294
|
+
const declared = {};
|
|
295
|
+
for (const { name, values } of conditions) {
|
|
296
|
+
const named = name.trim();
|
|
297
|
+
if (named && values.length > 0 && !Object.hasOwn(declared, named))
|
|
298
|
+
declared[named] = values;
|
|
299
|
+
}
|
|
300
|
+
return declared;
|
|
301
|
+
}
|
|
302
|
+
/** What is wrong with each condition, reported on its row. Gives whether any was. */
|
|
303
|
+
function reportConditions(conditions, slots, report) {
|
|
304
|
+
const seen = new Set();
|
|
305
|
+
let wrong = false;
|
|
306
|
+
conditions.forEach(({ name, values }, at) => {
|
|
307
|
+
const named = name.trim();
|
|
308
|
+
if (!named && values.length === 0)
|
|
309
|
+
return;
|
|
310
|
+
const problem = !named
|
|
311
|
+
? 'This condition needs a name.'
|
|
312
|
+
: seen.has(named)
|
|
313
|
+
? `Two conditions are called "${named}".`
|
|
314
|
+
: systemLinesProblem('', { [named]: values }, slots);
|
|
315
|
+
seen.add(named);
|
|
316
|
+
if (!problem)
|
|
317
|
+
return;
|
|
318
|
+
wrong = true;
|
|
319
|
+
report('identity', problem, 'conditions', at);
|
|
320
|
+
});
|
|
321
|
+
return wrong;
|
|
296
322
|
}
|
|
297
323
|
/** The prompt's lines and the facts they read, each problem reported on the identity section. */
|
|
298
324
|
function compilePrompt(draft, report) {
|
|
299
|
-
const
|
|
300
|
-
if (
|
|
301
|
-
report('identity',
|
|
302
|
-
|
|
303
|
-
const lines = draft.identity.system.flatMap(({ text }) => {
|
|
304
|
-
const parsed = parseSystemMarkup(text);
|
|
305
|
-
if (!parsed.ok)
|
|
306
|
-
report('identity', parsed.message, 'system');
|
|
307
|
-
return parsed.ok && parsed.prompt !== undefined ? [parsed.prompt] : [];
|
|
308
|
-
});
|
|
325
|
+
const parsed = parseSystemMarkup(draft.identity.system);
|
|
326
|
+
if (!parsed.ok)
|
|
327
|
+
report('identity', parsed.message, 'system');
|
|
328
|
+
const lines = parsed.ok ? parsed.lines : [];
|
|
309
329
|
const [first] = lines;
|
|
310
330
|
const system = lines.length === 0
|
|
311
331
|
? undefined
|
|
312
332
|
: lines.length === 1 && typeof first === 'string'
|
|
313
333
|
? first
|
|
314
334
|
: lines;
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
335
|
+
const slots = Object.fromEntries(draft.inputs.slots.map((slot) => [
|
|
336
|
+
slot.name.trim(),
|
|
337
|
+
slot.choices.map((choice) => choice.value.trim()).filter(Boolean),
|
|
338
|
+
]));
|
|
339
|
+
const wrong = reportConditions(draft.identity.conditions, slots, report);
|
|
340
|
+
const conditions = draftConditions(draft.identity.conditions);
|
|
341
|
+
const declared = Object.keys(conditions).length > 0 ? conditions : undefined;
|
|
342
|
+
if (system !== undefined && !wrong) {
|
|
321
343
|
const problem = systemLinesProblem(system, declared, slots);
|
|
322
344
|
if (problem)
|
|
323
345
|
report('identity', problem, 'system');
|
|
@@ -397,6 +419,7 @@ function toolCommon(tool, fail, agentInputOf) {
|
|
|
397
419
|
loadTier: tool.loadTier,
|
|
398
420
|
paths: paths.length ? paths : ['*'],
|
|
399
421
|
...(tool.after ? { after: true } : {}),
|
|
422
|
+
...(tool.background ? { background: tool.background } : {}),
|
|
400
423
|
...schemas,
|
|
401
424
|
};
|
|
402
425
|
}
|
package/cookbooks/catalog.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { embeddingModelLimits } from '@theoremjs/agents';
|
|
2
2
|
import { DETECTOR_BOUNDARIES, DETECTORS } from '@theoremjs/agents/guardrails';
|
|
3
|
-
import { COMPACTION_DRAFT_DEFAULTS, createBlankDraft, defaultModelBinding, defaultToolSpec, draftKey, freeName, includableFacets, includeFacet, newOwnDetector, newPattern,
|
|
3
|
+
import { COMPACTION_DRAFT_DEFAULTS, createBlankDraft, defaultModelBinding, defaultToolSpec, draftKey, freeName, includableFacets, includeFacet, newOwnDetector, newPattern, setProfileType, } from "../draft.js";
|
|
4
4
|
import { firstServed } from "../policy.js";
|
|
5
5
|
import { addAgent, agentNodeId, markAgentStart, workspaceFromDraft, } from "../workspace.js";
|
|
6
6
|
import { DEMO_ALLOWED_HOSTS, DEMO_ARCHITECT_TOOLS, DEMO_CONCIERGE_TOOLS, DEMO_CONSOLE_TOOLS, DEMO_RESEARCH_STAGE_READ_TOOLS, DEMO_RESEARCH_TOOLS, demoInputsSpec, demoToolSpecs, RESEARCH_ALLOWED_HOSTS, } from "./tools.js";
|
|
@@ -385,7 +385,7 @@ function exampleTextDraft(identity, tools) {
|
|
|
385
385
|
const inputs = demoInputsSpec();
|
|
386
386
|
return {
|
|
387
387
|
...blank,
|
|
388
|
-
identity: { ...identity, profileType: 'text',
|
|
388
|
+
identity: { ...identity, profileType: 'text', conditions: [] },
|
|
389
389
|
included: ['outputs', 'turnBehaviour', 'guardrails', 'observability', 'labels'],
|
|
390
390
|
models: { defaultModel: 'open', allowModelSelect: true, maxSteps: 12, key: 'gemini' },
|
|
391
391
|
modelBindings: defaultTextModelBindings(),
|
|
@@ -461,9 +461,7 @@ function createResearchCompactorDraft() {
|
|
|
461
461
|
return exampleTextDraft({
|
|
462
462
|
agentId: 'research.compactor',
|
|
463
463
|
handle: 'compactor',
|
|
464
|
-
system:
|
|
465
|
-
newSystemLine('Summarise the research so far. Keep every source URL, every exact quote, and every open lead.'),
|
|
466
|
-
],
|
|
464
|
+
system: 'Summarise the research so far. Keep every source URL, every exact quote, and every open lead.',
|
|
467
465
|
}, { tools: { t2Loader: '', parallel: false }, toolSpecs: [] });
|
|
468
466
|
}
|
|
469
467
|
/** The speech agent that reads `research.scout`'s findings as a podcast. */
|
|
@@ -498,7 +496,7 @@ function createResearchLiveDraft() {
|
|
|
498
496
|
identity: {
|
|
499
497
|
...draft.identity,
|
|
500
498
|
agentId: 'research.scout.live',
|
|
501
|
-
system:
|
|
499
|
+
system: DEMO_LIVE_RESEARCH_SYSTEM,
|
|
502
500
|
},
|
|
503
501
|
};
|
|
504
502
|
}
|
|
@@ -521,7 +519,7 @@ export function createResearchScoutDraft() {
|
|
|
521
519
|
const base = exampleTextDraft({
|
|
522
520
|
agentId: 'research.scout',
|
|
523
521
|
handle: 'scout',
|
|
524
|
-
system: [DEMO_RESEARCH_SYSTEM, ...RESEARCH_READER_LINES].
|
|
522
|
+
system: [DEMO_RESEARCH_SYSTEM, ...RESEARCH_READER_LINES].join('\n\n'),
|
|
525
523
|
}, { tools: { t2Loader: '', parallel: true }, toolSpecs: exampleTools(DEMO_RESEARCH_TOOLS) });
|
|
526
524
|
return {
|
|
527
525
|
...base,
|
|
@@ -739,7 +737,7 @@ export function createExampleDraft() {
|
|
|
739
737
|
return exampleTextDraft({
|
|
740
738
|
agentId: 'travel.concierge',
|
|
741
739
|
handle: 'concierge',
|
|
742
|
-
system:
|
|
740
|
+
system: DEMO_CONCIERGE_SYSTEM,
|
|
743
741
|
}, {
|
|
744
742
|
tools: { t2Loader: 'discover_tools', parallel: false },
|
|
745
743
|
toolSpecs: exampleTools(DEMO_CONCIERGE_TOOLS),
|
|
@@ -753,7 +751,7 @@ export function createLiveExampleDraft() {
|
|
|
753
751
|
identity: {
|
|
754
752
|
...draft.identity,
|
|
755
753
|
agentId: 'travel.concierge.live',
|
|
756
|
-
system:
|
|
754
|
+
system: DEMO_LIVE_CONCIERGE_SYSTEM,
|
|
757
755
|
},
|
|
758
756
|
};
|
|
759
757
|
}
|
|
@@ -783,7 +781,7 @@ function architectDraft() {
|
|
|
783
781
|
return exampleTextDraft({
|
|
784
782
|
agentId: 'code.architect',
|
|
785
783
|
handle: 'architect',
|
|
786
|
-
system:
|
|
784
|
+
system: DEMO_ARCHITECT_SYSTEM,
|
|
787
785
|
}, { tools: { t2Loader: '', parallel: false }, toolSpecs: exampleTools(DEMO_ARCHITECT_TOOLS) });
|
|
788
786
|
}
|
|
789
787
|
/** Adds `draft` as an agent, and an agent tool that lets `caller` run it, leaving `caller` selected. */
|
package/draft.d.ts
CHANGED
|
@@ -15,19 +15,22 @@ 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
|
-
/**
|
|
19
|
-
export interface
|
|
18
|
+
/** A fact each turn states: its name and the values it can take. */
|
|
19
|
+
export interface ConditionDraft {
|
|
20
20
|
key: string;
|
|
21
|
-
|
|
21
|
+
name: string;
|
|
22
|
+
values: string[];
|
|
22
23
|
}
|
|
23
24
|
export interface IdentityDraft {
|
|
24
25
|
agentId: string;
|
|
25
26
|
profileType: StudioProfileType | '';
|
|
26
27
|
handle: string;
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
/**
|
|
29
|
+
* The whole prompt as typed: a blank line starts a new line, and private sections are wrapped as
|
|
30
|
+
* `{private: …}`. Unused on speech, which has no system channel.
|
|
31
|
+
*/
|
|
32
|
+
system: string;
|
|
33
|
+
conditions: ConditionDraft[];
|
|
31
34
|
}
|
|
32
35
|
export interface ModelsDraft {
|
|
33
36
|
/** Who holds the conversation a saved state continues; unset is the kernel's default, the host. */
|
|
@@ -419,7 +422,7 @@ export interface StudioDraft {
|
|
|
419
422
|
decision: DecisionDraft;
|
|
420
423
|
labels: LabelsDraft;
|
|
421
424
|
}
|
|
422
|
-
export declare function draftKey(prefix: 'agent' | '
|
|
425
|
+
export declare function draftKey(prefix: 'agent' | 'condition' | 'entry' | 'model' | 'tool' | 'question' | 'criterion' | 'reference' | 'image' | 'slot' | 'choice'): string;
|
|
423
426
|
export declare function defaultModelBinding(partial?: Partial<ModelBindingDraft>): ModelBindingDraft;
|
|
424
427
|
export declare function defaultToolSpec(partial?: Partial<ToolSpecDraft>): ToolSpecDraft;
|
|
425
428
|
/**
|
|
@@ -453,7 +456,7 @@ export declare function newDecisionImage(draft: StudioDraft, file: string, image
|
|
|
453
456
|
}): DecisionImageDraft;
|
|
454
457
|
/** A new slot, with a name the draft doesn't use yet and two blank choices. */
|
|
455
458
|
export declare function newSlot(slots: readonly SlotDraft[]): SlotDraft;
|
|
456
|
-
export declare function
|
|
459
|
+
export declare function newCondition(): ConditionDraft;
|
|
457
460
|
export declare function newSlotChoice(): SlotChoiceDraft;
|
|
458
461
|
/** One blank row: an option, a level, or a criterion. */
|
|
459
462
|
export declare function newCriterion(): DecisionCriterionDraft;
|
package/draft.js
CHANGED
|
@@ -247,8 +247,8 @@ 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
|
|
251
|
-
return { key: draftKey('
|
|
250
|
+
export function newCondition() {
|
|
251
|
+
return { key: draftKey('condition'), name: '', values: [] };
|
|
252
252
|
}
|
|
253
253
|
export function newSlotChoice() {
|
|
254
254
|
return { key: draftKey('choice'), value: '', description: '' };
|
|
@@ -282,8 +282,8 @@ export function createBlankDraft() {
|
|
|
282
282
|
agentId: '',
|
|
283
283
|
profileType: '',
|
|
284
284
|
handle: '',
|
|
285
|
-
system:
|
|
286
|
-
|
|
285
|
+
system: '',
|
|
286
|
+
conditions: [],
|
|
287
287
|
},
|
|
288
288
|
included: ['observability', 'labels'],
|
|
289
289
|
models: { defaultModel: '', allowModelSelect: false, maxSteps: null, key: '' },
|
package/mod.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
export { type StudioAsks, type WriteAsk, writeAsk, writeAskLine } from './asks.ts';
|
|
2
1
|
export { KNOWN_GEMINI_EMBEDDING_MODELS, KNOWN_OPENROUTER_EMBEDDING_MODELS, } from './browser-connection.ts';
|
|
3
2
|
export { type CompiledStudio, compileStudio, credentialHeaderProblem, credentialUrlProblem, draftConditions, type StudioCompileResult, type StudioIssue, type StudioProfileDefinition, type StudioTurnProfileDefinition, } from './compile.ts';
|
|
4
3
|
export { type CompiledWorkspace, compileWorkspace, type WorkspaceCompileResult, workspaceRunAgent, } from './compile-workspace.ts';
|
|
5
4
|
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
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.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,
|
|
6
|
+
export { agentToolTarget, COMPACTION_DRAFT_DEFAULTS, type ConditionDraft, 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, newCondition, 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';
|
|
8
7
|
export { EXAMPLE_EMBEDDING_FILES } from './example-embedding-files.ts';
|
|
9
8
|
export type { GuardrailProbe, GuardrailProbeAnswer, GuardrailProbeDraft, GuardrailProbeResult, ProbeBoundary, ProbeBoundaryNote, ProbeStatus, } from './guardrail-probe.ts';
|
|
10
9
|
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,8 @@
|
|
|
1
|
-
export { writeAsk, writeAskLine } from "./asks.js";
|
|
2
1
|
export { KNOWN_GEMINI_EMBEDDING_MODELS, KNOWN_OPENROUTER_EMBEDDING_MODELS, } from "./browser-connection.js";
|
|
3
2
|
export { compileStudio, credentialHeaderProblem, credentialUrlProblem, draftConditions, } from "./compile.js";
|
|
4
3
|
export { compileWorkspace, workspaceRunAgent, } from "./compile-workspace.js";
|
|
5
4
|
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,
|
|
5
|
+
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, newCondition, newCriteria, newCriterion, newDecisionImage, newDecisionQuestion, newModelBinding, newOwnDetector, newPattern, newSlot, newSlotChoice, newToolSpec, plantsCanary, removeModelBinding, STUDIO_PROFILE_TYPES, setProfileType, TIMER_MAX_MS, takesContinueInstruction, updateModelBinding, } from "./draft.js";
|
|
7
6
|
export { EXAMPLE_EMBEDDING_FILES } from "./example-embedding-files.js";
|
|
8
7
|
export { PROBE_BOUNDARIES, PROBE_BOUNDARY_NOTES, PROBE_STATUSES, PROBE_TEXT_LIMIT, probeDraft, probeRefusal, runGuardrailProbe, runGuardrailProbes, } from "./guardrail-probe.js";
|
|
9
8
|
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.715.geef22fd",
|
|
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.715.geef22fd",
|
|
81
|
+
"@theoremjs/web": "0.3.4-next.715.geef22fd",
|
|
82
|
+
"@theoremjs/react": "0.3.4-next.715.geef22fd"
|
|
83
83
|
},
|
|
84
84
|
"peerDependenciesMeta": {
|
|
85
85
|
"@theoremjs/react": {
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TraceInspector-CvJ0wx9n.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-7q5Be8sp.js","assets/host-patterns-F-KZIzkF.js","assets/trace-record-Dm2jEhUR.js","assets/TraceOverview-cIjJwpvK.js","assets/labels-provider-uONlWExD.js","assets/CodeBlock-CfVOtDeO.js","assets/useClipboard-CbN9bb4J.js","assets/index-CAK9cdCh.js","assets/browser-transport-DKhZ4zo1.js","assets/Center-CgO0c-qo.js","assets/IconSearch-BTx66a40.js","assets/schemas-D7cgkv3L.js","assets/tool-schema-6RWBAqGO.js","assets/reader-747-Cvu8.js","assets/browser-connection-CuWeoI9s.js","assets/live-ingress-OuSlQ6q7.js","assets/trace-schema--4IGmLeE.js","assets/stub--LOYiyQO.js","assets/Dialog-Sd04KQS2.js","assets/HoverCard-DMyWUvwP.js","assets/IconEye-BB5aY-wQ.js","assets/studio-labels-q6eBFSru.js","assets/turn-client-OLK12Fyi.js","assets/encode-files-DoLGXgup.js","assets/CollapsibleGroup-BsIYDnJR.js","assets/tree-DcCW259J.js","assets/crypto-BnoW7FFO.js","assets/use-second-ticker-D6JSf9B3.js","assets/use-second-ticker-GWBt83pd.css","assets/workspace-DSAX72vF.js","assets/lent-keys-C32ems-I.js","assets/editors-BJX_S59A.js","assets/project-address-DjxPZuyn.js","assets/people-CIsR0-5R.js","assets/studio-session-ClF2iNCX.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-uONlWExD.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-6RWBAqGO.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-7q5Be8sp.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-DcCW259J.js";import{V as Te,_ as Ee,c as De,h as Oe,u as V}from"./browser-connection-CuWeoI9s.js";import{a as ke,r as Ae}from"./live-ingress-OuSlQ6q7.js";import{i as je,n as Me,r as Ne}from"./use-second-ticker-D6JSf9B3.js";var Pe=x(`outline`,`check`,`Check`,[[`path`,{d:`M5 12l5 5l10 -10`,key:`svg-0`}]]),Fe=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=`••••`,Ie=/auth|key|token|secret|passw|pwd|cookie|session|signature|^sig$|credential|^code$|appid/i,Le=/auth|key|token|secret|passw|pwd|signature|credential|appid/i,Re=[[/^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`]],ze=16;function Be(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<ze&&i.push(`shorter than keys usually are`));let a=Re.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 Ve(e){try{return decodeURIComponent(e)}catch{return e}}function K(e){return Ie.test(e)}function He(e){let t=URL.canParse(e)?Ie:Le;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(Ve(r))?`${n}${r}=${H}`:e)}function Ue(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 We(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,n===`••••`?t?.[e]??n:n]))}function Ge(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 Ke=()=>void 0,qe=()=>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 Je={agentId:{label:`Profile id`,max:64},handle:{label:`Handle`,max:32}};function Ye(e,t,n){let{label:r,max:i}=Je[t];n.trim()?Array.from(n).length>i&&e(`identity`,`${r} is at most ${i} characters.`,t):e(`identity`,`${r} is required.`,t)}function Xe(e,t){Ye(t,`agentId`,e.identity.agentId),e.identity.profileType!==`host`&&Ye(t,`handle`,e.identity.handle)}function Ze(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 Qe(e){return e.length<2?e[0]??``:`${e.slice(0,-1).join(`, `)} or ${e.at(-1)}`}function $e(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 et(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 ${Qe(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 ${Qe(e)}.`:`Default effort '${a}' is not one of the efforts.`,`defaultEffort`)}return{efforts:i,defaultEffort:a}}function tt(e,t,n,r,i){let a=B(e.key),o=Ze(e,t,n,r),{apiId:s}=o,{efforts:c,defaultEffort:l}=et(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`),rt(e,n,t,a,r);let d=it(e,t,a,r,i),f=nt(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 nt(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 rt(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`?$e(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 it(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 at(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 ot(e,t,n,r){let{models:i,modelBindings:a}=e,o={};for(let s of a){let a=tt({...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=at(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 st(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 ct=e=>typeof e==`string`,lt=e=>!0;function ut(e){return st(e,ct)}function dt(e){let t={};for(let{name:n,values:r}of e){let e=n.trim();e&&r.length>0&&!Object.hasOwn(t,e)&&(t[e]=r)}return t}function ft(e,t,n){let r=new Set,i=!1;return e.forEach(({name:e,values:a},o)=>{let s=e.trim();if(!s&&a.length===0)return;let c=s?r.has(s)?`Two conditions are called "${s}".`:Te(``,{[s]:a},t):`This condition needs a name.`;r.add(s),c&&(i=!0,n(`identity`,c,`conditions`,o))}),i}function pt(e,t){let n=je(e.identity.system);n.ok||t(`identity`,n.message,`system`);let r=n.ok?n.lines:[],[i]=r,a=r.length===0?void 0:r.length===1&&typeof i==`string`?i:r,o=Object.fromEntries(e.inputs.slots.map(e=>[e.name.trim(),e.choices.map(e=>e.value.trim()).filter(Boolean)])),s=ft(e.identity.conditions,o,t),c=dt(e.identity.conditions),l=Object.keys(c).length>0?c:void 0;if(a!==void 0&&!s){let e=Te(a,l,o);e&&t(`identity`,e,`system`)}return{system:a,conditions:l}}function mt(e,t,n){let r=st(e,t);return r===null&&n(),r??void 0}function ht(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 gt(e){try{return new URL(e),!0}catch{return!1}}function _t(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 vt(e,t,n){let r=e.toolName.trim();_t(r,t);let i=e.description.trim();i||t(`Description is required.`,`description`);let a=e.toolType===`agent`?{inputSchema:n(e.agentKey??``)??bt,outputSchema:xt}:yt(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}:{},...e.background?{background:e.background}:{},...a}}function yt(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 bt=V(Oe({type:`text`}),`input`),xt=V(Ee,`output`);function St(e){let t=e.identity.profileType;if(t!==`text`&&t!==`image`&&t!==`speech`)return;let n=t!==`speech`&&L(e).includes(`inputs`)?Rt(e.inputs,t,()=>{}):void 0;return V(Oe({type:t,...n?{inputs:n}:{}}),`input`)}function Ct(e){return(e??``).split(`
|
|
3
|
+
`).map(e=>e.trim()).filter(Boolean)}function wt(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=Ct(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 Tt(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 Et(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 Dt(e,t){let n=ut(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=Tt(n??void 0);r&&t(r,`headersJson`);let i=e.toolType===`mcp`?`serverUrl`:`endpoint`,a=Et(e[i]?.trim());a&&t(a,i);let o=ht(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 Ot(e,t,n,r){let i=e[t]?.trim()??``;return i?gt(i)||r(`${n} must be a full URL.`,t):r(`${n} is required.`,t),i}function kt(e,t,n){let r=Ot(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],...Dt(e,n),...Object.keys(s).length?{mapping:s}:{}}}function At(e,t,n){let r=Ot(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,...Dt(e,n),...jt(e,n)}}function jt(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 Mt(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 Nt(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 Pt={http:kt,mcp:At,function:Mt,agent:Nt};function Ft(e){return Me.includes(e)}function It(e,t,n,r){let i=we(e.key);if(!Ft(e.toolType)){t(i,Ne,`toolType`);return}let a=!1,o=(e,n)=>{a=!0,t(i,e,n)},s=vt(e,o,r),c=wt(e,s,o),l=Pt[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 Lt(e,t,n,r,i,a){let o=[],s=new Set;for(let t of e.toolSpecs){let e=It(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 Rt(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=Bt(e,n),a=Ht(e,n),o=zt(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 zt(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 Bt(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 Vt(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 Ht(e,t){if(e.slots.length)return e.slots.forEach((n,r)=>{for(let i of Vt(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 Ut(e,t){let n=Ht(e,t),r=zt(e,t);return!n&&!r?{}:{inputs:{...n?{slots:n}:{},...r?{context:r}:{}}}}function Wt(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 Gt(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&&Wt(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 Kt(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 qt(e,t,n){let r=t?Kt(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 Jt(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 Yt(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 Xt(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 Zt(e){return Qt(e,()=>{})}function Qt(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 $t(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 en(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 tn(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=en(e,r);return i!==void 0&&n(`guardrails`,i,t),r}function nn(e,t,n){if(!t||!N[e].patterns)return{};let r=rn(t.hint,`sources.${e}.hint`,n),i=tn(t.patterns,`sources.${e}.patterns`,n);return{...t.theorem?{}:{theorem:!1},...i.length?{patterns:i}:{},...i.length&&r?{hint:r}:{}}}function rn(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 an(e,t){if(!e)return`Give this detector a key, such as acme.codenames.`;let n={label:e,action:`flag`,find:sn};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 on(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=rn(a.hint,`own.${i}.hint`,n),c=tn(a.patterns,`own.${i}.patterns`,n),l=a.label.trim(),u=an(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 sn=()=>[];function cn(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:sn}];let{hint:i,...a}=r;return[e,a]}))}function ln(e){let{guardrails:t}=e;return!t||!(`detect`in t)||t.detect===void 0?e:{...e,guardrails:{...t,detect:cn(t.detect)}}}function un(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`)?dn(a,e,n):void 0,c=nn(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,on(e.own,t,n));let a=F(`Detect`,cn(i),t);return a!==void 0&&n(`guardrails`,a,`detect`),Object.keys(i).length?i:void 0}function dn(e,t,n){if(fn(e))return $t(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 fn(e){return N[e].allow===`urls`}function pn(e){let{taintAfterRemoteRead:t,taintRemoteDestination:n}=e;if(t||n)return{...t?{afterRemoteRead:t}:{},...n?{remoteDestination:n}:{}}}function mn(e,t,n=I){let r={detect:un(e,n,t),quota:Yt(e,t),blockedReply:Xt(e,t),network:Qt(e,t),taint:pn(e)},i=Object.fromEntries(Object.entries(r).filter(([,e])=>e!==void 0));return Object.keys(i).length?i:void 0}function hn(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=mt(e.resourceJson,lt,()=>{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 gn={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,webp:`image/webp`,gif:`image/gif`};function _n(e){if(!URL.canParse(e))return;let t=new URL(e);return t.protocol!==`https:`&&t.protocol!==`http:`?void 0:gn[t.pathname.split(`.`).pop()?.toLowerCase()??``]}function vn(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=_n(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 yn(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=vn(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 bn(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 xn(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 Sn(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&&Cn(e,t,n.mode===`demo`?n.keys.liveInputTokens:void 0);let r=xn(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:wn(e)}:{},...Object.keys(s).length?{transcription:s}:{}}}function Cn(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 wn(e){let t=e.compressionTriggerTokens,n=e.compressionTargetTokens;return{...t===null?{}:{triggerTokens:t},slidingWindow:n===null?{}:{targetTokens:n}}}function Tn(e,t){let[n,...r]=t,{[n]:i,...a}=e;return!r.length||typeof i!=`object`||!i?a:{...a,[n]:Tn(i,r)}}function En(e){let t=e;for(let{path:n}of me(e))t=Tn(t,n.split(`.`));return t}function Dn(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 On=/^[a-z0-9_]+$/,kn=[`image/png`,`image/jpeg`];function An(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}>`;On.test(a)?Object.hasOwn(n,o)?i(`Image ${o} is used twice.`):!kn.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 Y(e,t,n){let r=t.has(`observability`)?hn(e.observability,n):void 0,i=Jt(e,t,t=>z(e,t),n);return{...r?{observability:r}:{},...i?{labels:i}:{}}}function jn(e,t){let{decision:n}=e,r=n.contract.trim();return r||t(`decision`,`Contract is required.`,`contract`),r}function Mn(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 Nn(e,t,n){let{decision:r}=e,i=new Set(L(e)),a=jn(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&&(Ze(o,`decision`,e.providers,t),rt(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?nt(o,s,t):void 0;J(t,`decision`,`maxStateBytes`,`Max state`,r.maxStateBytes,1);let l=Dn(r,t),u=An(r,t);return n.mode===`demo`&&Mn(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},...Y(e,i,t)},customTools:[],...r.questionsBuilt?{}:{questions:l},...Object.keys(u).length?{images:{...u}}:{}}}function Pn(e,t,n,r){let i=new Set(L(e)),{customTools:a,tools:o}=Lt(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`)?mn(e.guardrails,t,he):void 0;return{profile:En({type:`host`,id:e.identity.agentId.trim(),tools:o,...s?{guardrails:s}:{},...Y(e,i,t)}),customTools:a}}function Fn(e,t,n,r,i,a){let o=new Set(L(e)),s=t=>z(e,t),{system:c,conditions:l}=pt(e,n),u=ot(e,t,n,i),{outputs:d,structured:f}=o.has(`outputs`)?Gt(e.outputs,s(`outputs.structured`),n):{},{customTools:p,tools:m}=o.has(`tools`)?Lt(e,s(`tools.t2Loader`),s(`tools.parallel`),n,i,a):{customTools:[]},h=o.has(`turnBehaviour`)?qt(e.turnBehaviour,s(`turnBehaviour.resumption`),n):void 0,g=o.has(`guardrails`)?mn(e.guardrails,n):void 0;return{profile:En({type:t,id:e.identity.agentId.trim(),identity:{handle:e.identity.handle.trim(),...l?{conditions:l}:{},...c?{system:c}:{}},...u,...o.has(`image`)?{image:yn(e.image,n)}:{},...o.has(`speech`)?{speech:bn(e.speech,e,n)}:{},...o.has(`live`)?{live:Sn(e.live,n,r)}:{},...m?{tools:m}:{},...o.has(`inputs`)?t===`live`?Ut(e.inputs,n):{inputs:Rt(e.inputs,t,n)}:{},...d?{outputs:d}:{},...h?{turnBehaviour:h}:{},...g?{guardrails:g}:{},...Y(e,o,n)}),customTools:p,...f?{structured:f}:{}}}function In(e,t,n=Ke,r=qe){let i=[],a=(e,t,n,r)=>{i.push({nodeId:e,message:t,...n===void 0?{}:{field:n},...r===void 0?{}:{index:r}})};Xe(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`?Nn(e,a,t):o===`host`?Pn(e,a,n,r):Fn(e,o,a,t,n,r);if(i.length)return{ok:!1,issues:i};try{De(ln(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 X=e(i(),1),Z=t(),Ln=(0,X.lazy)(()=>b(()=>import(`./TraceInspector-CvJ0wx9n.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,84]))),Rn=(0,X.lazy)(()=>b(()=>import(`./TraceInspector-CvJ0wx9n.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,84]))),Q=(0,X.createContext)(`replace`);function zn({value:e,children:t}){return(0,Z.jsx)(Q,{value:e,children:t})}function Bn({id:e,toggle:t,traces:n}){return(0,Z.jsx)(_,{id:e,children:e=>(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(m,{floating:!0,children:t}),children:(0,Z.jsx)(Rn,{traces:n,isWide:e,end:t})})})}function Vn(e,t,n){let r=ee(),i=(0,X.useId)(),[a,o]=(0,X.useState)(!1),s=(0,X.use)(Q),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,Z.jsx)(y,{labels:c,icon:(0,Z.jsx)(l,{icon:ie}),panelId:i,open:u,size:e,onToggle:()=>o(e=>!e)}):null;return{toggle:d(),view:u?Hn(s===`panel`,i,t,d(`sm`)):null,labels:c,offered:!0}}function Hn(e,t,n,r){return e?(0,Z.jsx)(Un,{id:t,toggle:r,traces:n}):(0,Z.jsx)(Bn,{id:t,toggle:r,traces:n})}function Un({id:e,toggle:t,traces:n}){let{ref:r,width:i}=h();return(0,Z.jsx)(`div`,{id:e,ref:r,style:{height:`100%`,position:`relative`},children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(m,{floating:!0,children:t}),children:(0,Z.jsx)(Rn,{traces:n,isWide:p(i),end:t})})})}function Wn({inspector:e,children:t}){let n=(0,X.useRef)(null),r=g(n,!1),i=(0,X.useRef)(void 0),a=(0,X.useCallback)(e=>{n.current=e;let t=i.current;typeof t==`function`?t(e):t!=null&&(t.current=e)},[]);if(!(0,X.isValidElement)(t))return(0,Z.jsx)(v,{view:e.view,children:t});i.current=t.props.ref;let o=e.view!=null;return(0,X.cloneElement)(t,{ref:a,end:(0,Z.jsx)(f,{labels:e.labels,resizable:r.resizable,open:o,children:e.view})})}function Gn({inspector:e,children:t}){return(0,X.use)(Q)===`panel`&&e.offered?(0,Z.jsx)(Wn,{inspector:e,children:t}):(0,Z.jsx)(v,{view:e.view,children:t})}function Kn({records:e,head:t}){return(0,Z.jsx)(te,{children:(0,Z.jsx)(X.Suspense,{fallback:null,children:(0,Z.jsx)(Ln,{records:e,head:t})})})}var qn={info:`info`,warning:`warning`,error:`error`,success:`success`},Jn={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}},Yn={info:{kWkggS:`xgcxg3y`,$$css:!0},warning:{kWkggS:`x24i8r5`,$$css:!0},error:{kWkggS:`x1pritpl`,$$css:!0},success:{kWkggS:`xu13z74`,$$css:!0}};function Xn(e){return Object.prototype.hasOwnProperty.call(Yn,e)}var Zn={none:{kGVxlE:`x1gnnqk1`,$$css:!0},low:{kGVxlE:`x1i5ehqx`,$$css:!0},med:{kGVxlE:`x14hfi27`,$$css:!0},high:{kGVxlE:`x1kcpxr7`,$$css:!0}};function Qn({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,X.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,X.useRef)(null),k=(0,X.useId)(),A=qn[e],le=Jn[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,Z.jsxs)(`div`,{ref:ie,onFocusCapture:s(ae,F),onPointerDownCapture:s(S,de),...o(r(`banner-frame`,{container:_,elevation:v}),n($.root,Zn[v],R&&v!==`none`&&$.rootElevatedCard,ee),te,x),...oe,children:[(0,Z.jsxs)(`div`,{...o(r(`banner`,{container:_,status:e}),n($.header,he&&$.headerCentered,Xn(e)&&Yn[e],R&&(L?$.headerCardWithContent:$.headerCardStandalone))),children:[(0,Z.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,Z.jsx)(l,{icon:A,size:`md`,color:le,...r(`banner-icon`,{status:e})})}),(0,Z.jsxs)(`div`,{...{0:{className:`x78zum5 xdt5ytf xxhr3t x98rzlu xeuugli`},1:{className:`x78zum5 xdt5ytf xxhr3t x98rzlu xeuugli xgualba`}}[!!c(g)|0],children:[(0,Z.jsx)(`div`,{className:`x1ghz6dp xjb2p0i xcr08ib x2mo6ok x1kq96og x1tgivj0 xj0a0fe`,children:t}),c(i)&&(0,Z.jsx)(`div`,{...o(r(`banner-description`),{className:`x1ghz6dp xjb2p0i x141an7d x1sodnla x1ltkj2j xv1l7n4 xj0a0fe`}),children:i})]}),pe&&(0,Z.jsxs)(`div`,{...n($.endArea,ne.inset(a[`--spacing-2`])),children:[g,I&&(0,Z.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,Z.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,Z.jsx)(re,{variant:`ghost`,size:`sm`,label:ue,tooltip:N,icon:(0,Z.jsx)(l,{icon:`close`,size:`sm`,color:`inherit`}),onClick:fe,isIconOnly:!0})]})]}),L&&(0,Z.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})]})}Qn.displayName=`Banner`;export{We as _,Vn as a,Pe as b,Tt as c,Zt as d,ln as f,Be as g,He as h,Gn as i,Et as l,Ge as m,Kn as n,St as o,H as p,zn as r,In as s,Qn as t,dt as u,Ue as v,Fe as y};
|
|
@@ -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-
|
|
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-uONlWExD.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-CrhjYjDy.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-7q5Be8sp.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-CAK9cdCh.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
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
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{J as n}from"./index-
|
|
1
|
+
import{c as e}from"./themeProps-3IqahpCr.js";import{t}from"./BottomSheet-Dbh6A5Vl.js";import{J as n}from"./index-CAK9cdCh.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-
|
|
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-uONlWExD.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-6RWBAqGO.js";import{c as g,l as _}from"./shaped-data-7q5Be8sp.js";import{c as v,d as y,l as b,u as x}from"./ConsoleFrame-dOTqIkpb.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-CAK9cdCh.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};
|