@theoremjs/studio 0.3.4-next.677.g14b70fe → 0.3.4-next.693.g4ab1526
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/asks.d.ts +9 -2
- package/asks.js +19 -10
- package/browser-connection.d.ts +1 -1
- package/browser-connection.js +3 -1
- package/browser-execution.js +1 -0
- package/compile-workspace.js +12 -5
- package/compile.d.ts +4 -2
- package/compile.js +58 -37
- package/cookbooks/catalog.d.ts +2 -2
- package/cookbooks/catalog.js +300 -53
- package/cookbooks/project.js +1 -0
- package/cookbooks/tools.js +64 -0
- package/draft.d.ts +21 -5
- package/draft.js +25 -2
- package/guardrail-probe.d.ts +3 -1
- package/guardrail-probe.js +37 -5
- package/mod.d.ts +2 -2
- package/mod.js +2 -2
- package/package.json +4 -4
- package/page/assets/Banner-DrRNC3MG.js +4 -0
- package/page/assets/Center-CgO0c-qo.js +1 -0
- package/page/assets/{ConsoleFrame-BFCYCApu.js → ConsoleFrame-BvgFGqp2.js} +3 -3
- package/page/assets/{MenuBottomSheet-CezET_qZ.js → MenuBottomSheet-BZecY8fw.js} +1 -1
- package/page/assets/{SchemaFields-CIF3WtC0.js → SchemaFields-BNNkvyyO.js} +1 -1
- package/page/assets/{ToolResultCharts-D3pQGTH1.js → ToolResultCharts-C3CPsfXl.js} +1 -1
- package/page/assets/{TraceInspector-Bx3j_185.js → TraceInspector-36e6ozKD.js} +1 -1
- package/page/assets/{TraceOverview-ChpCMZRa.js → TraceOverview-CSdJ_cYY.js} +3 -3
- package/page/assets/{_virtual_studio-type-sources-BwSqfSwd.js → _virtual_studio-type-sources-DSpwr3WK.js} +143 -13
- package/page/assets/browser-connection-dads1eyK.js +3 -0
- package/page/assets/browser-engine-CugH58NS.js +13 -0
- package/page/assets/browser-transport-GzhRiBdm.js +45 -0
- package/page/assets/{crypto-CD14HeXH.js → crypto-B8dqEoWf.js} +1 -1
- package/page/assets/{encode-files-DhoC5hWG.js → encode-files-CHeRLBO8.js} +1 -1
- package/page/assets/{export-agent-nlvsxs9-.js → export-agent-botXSyoH.js} +3 -3
- package/page/assets/{guardrail-tester-C7r03f5Z.js → guardrail-tester-DYR7EPIy.js} +2 -2
- package/page/assets/index-B7sK7d-l.js +153 -0
- package/page/assets/live-messages-DN_q2nBN.js +1 -0
- package/page/assets/project-address-DjxPZuyn.js +1 -0
- package/page/assets/reader-DHN96tSr.js +5 -0
- package/page/assets/{schemas-BQ9Jydzb.js → schemas-D7cgkv3L.js} +1 -1
- package/page/assets/shaped-data-CJQ3W_RE.js +20 -0
- package/page/assets/{stub-nxRsh1jo.js → stub-U6wDGe3P.js} +25 -7
- package/page/assets/studio-code-pane-Boy63AK2.js +8 -0
- package/page/assets/{studio-console-BgymsByi.js → studio-console-B7zL133d.js} +1 -1
- package/page/assets/studio-decision-CbRjfbvG.js +1 -0
- package/page/assets/studio-embedding-DQ0QrEsu.js +2 -0
- package/page/assets/{studio-host-console-DtepSA77.js → studio-host-console-DDA2Um2-.js} +2 -2
- package/page/assets/{studio-labels-BZbz7-uL.js → studio-labels-jYWBoEyP.js} +1 -1
- package/page/assets/studio-live-D0YRu2zQ.js +5 -0
- package/page/assets/studio-map-C4Ra1QqL.js +1 -0
- package/page/assets/studio-session-CPnJaHc-.js +1 -0
- package/page/assets/studio-trace-replay-D-f2p7k9.js +3 -0
- package/page/assets/{studio-type-checker-BbUSqqOS.js → studio-type-checker-CVNPnko-.js} +1 -1
- package/page/assets/tool-schema-BDG2_rlP.js +17 -0
- package/page/assets/{trace-record-DxgSKmYY.js → trace-record-DoXjxrmJ.js} +1 -1
- package/page/assets/trace-schema--4IGmLeE.js +1 -0
- package/page/assets/tree-CcEbNvms.js +3 -0
- package/page/assets/turn-client-BmOSpCgw.js +2 -0
- package/page/assets/{use-one-call-DE5HvQsv.js → use-one-call-B3t-kfc5.js} +1 -1
- package/page/assets/{use-second-ticker-CEwOSS-d.js → use-second-ticker-CWjCHLG6.js} +1 -1
- package/page/assets/workspace-DUfaxr-g.js +1 -0
- package/page/index.html +20 -19
- package/people.d.ts +2 -0
- package/people.js +3 -1
- package/policy.js +1 -0
- package/providers.d.ts +2 -2
- package/providers.js +8 -3
- package/read-source.js +34 -7
- package/registrations.d.ts +23 -3
- package/runtime-scope.d.ts +6 -3
- package/runtime-scope.js +16 -4
- package/runtime.js +14 -2
- package/server/draft-handler.d.ts +4 -4
- package/server/draft-handler.js +3 -2
- package/server/draft-probe.d.ts +9 -1
- package/server/draft-probe.js +2 -1
- package/server/handler.js +71 -25
- package/server/live.d.ts +7 -1
- package/server/live.js +11 -4
- package/server/run-traces.d.ts +5 -1
- package/server/run-traces.js +7 -3
- package/server/save-new.js +5 -5
- package/server/save-session.js +4 -2
- package/server/serve.js +2 -1
- package/server/test-key.d.ts +2 -2
- package/server/test-key.js +1 -1
- package/slot-values.d.ts +2 -0
- package/slot-values.js +22 -0
- package/source.js +11 -4
- package/tool-readers.d.ts +23 -0
- package/tool-readers.js +60 -0
- package/tools.js +4 -1
- package/types.d.ts +3 -1
- package/ui/inspector-context.js +1 -1
- package/ui/lib/project-traces.d.ts +5 -0
- package/ui/lib/project-traces.js +21 -3
- package/ui/lib/studio-page.d.ts +6 -1
- package/ui/lib/studio-page.js +33 -31
- package/ui/lib/studio-project.d.ts +8 -1
- package/ui/lib/studio-project.js +19 -1
- package/ui/lib/studio-session.d.ts +2 -0
- package/ui/lib/studio-session.js +40 -2
- package/ui/lib/studio-store.d.ts +2 -2
- package/ui/lib/studio-store.js +9 -5
- package/ui/lib/tool-probe.d.ts +2 -0
- package/ui/lib/tool-probe.js +3 -2
- package/ui/lib/type-icons.d.ts +1 -0
- package/ui/lib/type-icons.js +2 -1
- package/ui/profile-editor.js +57 -21
- package/ui/studio-compare.d.ts +14 -4
- package/ui/studio-compare.js +58 -24
- package/ui/studio-live.d.ts +1 -1
- package/ui/studio-live.js +8 -3
- package/ui/studio-runner.d.ts +3 -2
- package/ui/studio-runner.js +16 -14
- package/ui/studio-screen.d.ts +1 -1
- package/ui/studio-screen.js +26 -20
- package/ui/studio-settings.js +3 -1
- package/ui/studio-trace-replay.js +7 -1
- package/workspace.js +3 -2
- package/page/assets/Banner-BkgdSxW_.js +0 -4
- package/page/assets/Center-nHS1JSux.js +0 -1
- package/page/assets/browser-connection-DSUHVCT5.js +0 -3
- package/page/assets/browser-engine-D1mbS8b9.js +0 -11
- package/page/assets/browser-transport-C8PD0IJk.js +0 -45
- package/page/assets/index-B7om06iO.js +0 -145
- package/page/assets/live-messages-CiLmR89m.js +0 -1
- package/page/assets/reader-DrOfMM8I.js +0 -5
- package/page/assets/shaped-data-H1miOZm2.js +0 -20
- package/page/assets/studio-code-pane-DA_z5w6h.js +0 -8
- package/page/assets/studio-decision-DWnr99n-.js +0 -1
- package/page/assets/studio-embedding-DCvI007w.js +0 -2
- package/page/assets/studio-live-CnyzlN29.js +0 -5
- package/page/assets/studio-map-DduCJzK7.js +0 -1
- package/page/assets/studio-session-CjUQSXx0.js +0 -1
- package/page/assets/studio-trace-replay-C0UPMVSt.js +0 -3
- package/page/assets/tool-schema-BmRYaywn.js +0 -17
- package/page/assets/trace-schema-9CdEyG6Q.js +0 -1
- package/page/assets/tree-3N-1RPZz.js +0 -3
- package/page/assets/turn-client-DN8PawJr.js +0 -2
- package/page/assets/workspace-CTSW941G.js +0 -1
|
@@ -4745,11 +4745,12 @@ export type { EmbeddingRules } from './src/kernel/registry/embedding-rules.js';
|
|
|
4745
4745
|
export { embeddingMediaIssues, embeddingRules } from './src/kernel/registry/embedding-rules.js';
|
|
4746
4746
|
export type { KernelRegistry } from './src/kernel/registry/kernel-registry.js';
|
|
4747
4747
|
export { createKernelRegistry } from './src/kernel/registry/kernel-registry.js';
|
|
4748
|
-
export type { EmbeddingProfileDefinition, ImageProfileDefinition, LiveProfileDefinition, ProfileDefinition, ProfileDefinitionBase, ProfileRegistry, SpeechProfileDefinition, TextProfileDefinition, } from './src/kernel/registry/profiles.js';
|
|
4748
|
+
export type { EmbeddingProfileDefinition, ImageProfileDefinition, LiveProfileDefinition, ProfileDefinition, ProfileDefinitionBase, ProfileRegistry, SpeechProfileDefinition, TextProfileDefinition, TranscriptionProfileDefinition, } from './src/kernel/registry/profiles.js';
|
|
4749
4749
|
export { createProfileRegistry, defineProfile } from './src/kernel/registry/profiles.js';
|
|
4750
4750
|
export { pickModel } from './src/kernel/registry/resolve.js';
|
|
4751
4751
|
export type { SchemaRegistry } from './src/kernel/registry/schemas.js';
|
|
4752
4752
|
export { createSchemaRegistry } from './src/kernel/registry/schemas.js';
|
|
4753
|
+
export { resolveTurnSystemPrompt } from './src/kernel/registry/system-prompt.js';
|
|
4753
4754
|
export type { AuthUnauthenticatedPolicy, ContinueStopKind, CustomToolType, HttpMethod, StepLimitMode, StudioAuthType, ToolAccess, ToolAuthType, ToolPermission, ToolType, TurnStopKind, } from './src/kernel/schema.js';
|
|
4754
4755
|
export { API_EXPORTS, ATTACHMENT_ACCEPT_MIMES, AUTH_UNAUTHENTICATED_POLICIES, AWAITING_USER_INPUT_KINDS, AWAITING_USER_INPUT_STATUS, COMPACTION_METERS, COMPACTION_OUTCOMES, COMPACTION_TIMINGS, CONTINUE_STOP_KINDS, catalogPathFor, DYNAMIC_FIELD_PARENTS, EXTRA_FIELDS, fieldMeta, HTTP_METHODS, IMAGE_ATTACHMENT_ACCEPT_MIMES, isKeySlotName, isToolGateKind, isTurnInjectStage, isTurnStage, KEY_SLOT_NAME, LIVE_ACTIVITY_HANDLINGS, LIVE_END_SENSITIVITIES, LIVE_START_SENSITIVITIES, MEDIA_INPUT_KIND_VALUES, MEDIA_INPUT_KINDS, MEDIA_WILDCARDS, PROFILE_FIELDS, PROFILE_HANDLE_MAX_CHARS, PROFILE_ID_MAX_CHARS, PROFILE_TYPES, REQUEST_FIELDS, SPEECH_AUDIO_FORMATS, STREAM_MODES, STUDIO_AUTH_TYPES, SUMMARY_MODES, THINKING_LEVELS, TOOL_ACCESS, TOOL_AUTH_TYPES, TOOL_GATE_KINDS, TOOL_LOAD_TIERS, TOOL_PERMISSION, TOOL_TYPES, TURN_INJECT_STAGES, TURN_STAGES, TURN_STOP_KINDS, VOICE_ACCEPT_MIMES, } from './src/kernel/schema.js';
|
|
4755
4756
|
export type { KernelScope } from './src/kernel/scope.js';
|
|
@@ -4758,6 +4759,7 @@ export type { AwaitingUserInput, StageAffordance, StageApplyInput, StageApplyOut
|
|
|
4758
4759
|
export { applyStageResult, STAGE_AFFORDANCE_MATRIX, STAGE_AFFORDANCES, stageAllowsAffordance, stageEventFields, } from './src/kernel/stages.js';
|
|
4759
4760
|
export type { MediaTurnBehaviourSpec, ProfileTurnBehaviourSpec, ProfileTurnResumptionSpec, TurnContinueFrom, TurnStop, } from './src/kernel/stop.js';
|
|
4760
4761
|
export { AUTO_CONTINUE_DELAY_MS, DEFAULT_ALLOW_CONTINUE, DEFAULT_AUTO_CONTINUE, GenerationStopError, isContinueStopKind, isGenerationStopError, isResumeableStop, isUserCancelledStop, profileAllowsInject, profileAllowsSteering, profileTurnResumption, shouldAutoContinue, turnStopFromClientStreamEnd, turnStopFromInteractionStatus, turnStopFromOpenAiFinishReason, } from './src/kernel/stop.js';
|
|
4762
|
+
export { systemLinesProblem } from './src/kernel/system-lines.js';
|
|
4761
4763
|
export { authorizeToolReplay } from './src/kernel/tools/execute.js';
|
|
4762
4764
|
export { GATE_DECISIONS, type GateDecision } from './src/kernel/tools/gate-answer.js';
|
|
4763
4765
|
export type { MemoryToolExecutionOptions } from './src/kernel/tools/memory-execution.js';
|
|
@@ -4803,6 +4805,8 @@ export { openRouterEmbeddings } from './openrouter/embeddings-protocol.js';
|
|
|
4803
4805
|
export { openRouterImages } from './openrouter/images-protocol.js';
|
|
4804
4806
|
export { openRouterOpenAi } from './openrouter/protocol.js';
|
|
4805
4807
|
export { openRouterProvider } from './openrouter/provider.js';
|
|
4808
|
+
export type { OpenRouterTranscriptionsOptions } from './openrouter/transcriptions-protocol.js';
|
|
4809
|
+
export { openRouterTranscriptions } from './openrouter/transcriptions-protocol.js';
|
|
4806
4810
|
export { systemOne } from './system-one/protocol.js';
|
|
4807
4811
|
export { typesafeProvider } from './typesafe/provider.js';
|
|
4808
4812
|
`,"file:///node_modules/@theoremjs/agents/src/providers/typesafe/provider.d.ts":`import { type Provider } from '../../kernel/protocols/provider.js';
|
|
@@ -4941,7 +4945,7 @@ import type { ReasoningOrigin, ToolCallRequest } from '../turn-events.js';
|
|
|
4941
4945
|
import type { DecisionRequest, DecisionResult, EmbeddingInput, EmbeddingResult, EmbeddingTask, InteractionPart, ModelRequest, TurnContext, TurnEvent, TurnHistoryMessage, TurnResponse, TurnStop } from '../types.js';
|
|
4942
4946
|
import type { ProviderLimits } from './limits.js';
|
|
4943
4947
|
/** The kinds of profile a protocol can serve, each at its own endpoint: every type but \`host\`. */
|
|
4944
|
-
declare const MODEL_PROFILE_TYPES: readonly ["text", "image", "speech", "live", "decision", "embedding"];
|
|
4948
|
+
declare const MODEL_PROFILE_TYPES: readonly ["text", "image", "speech", "transcription", "live", "decision", "embedding"];
|
|
4945
4949
|
export type ModelProfileType = (typeof MODEL_PROFILE_TYPES)[number];
|
|
4946
4950
|
/** The turn events a protocol yields as they are. */
|
|
4947
4951
|
export type ProtocolContentEvent = Extract<TurnEvent, {
|
|
@@ -5586,6 +5590,12 @@ export type SystemPart = string | PrivateSystemPart;
|
|
|
5586
5590
|
* part is \`{ private }\`, the plain strings beside it are shareable.
|
|
5587
5591
|
*/
|
|
5588
5592
|
export type SystemPrompt = string | readonly SystemPart[];
|
|
5593
|
+
/** One line of a profile's prompt: text, or parts kept together. A leading \`when\` decides it. */
|
|
5594
|
+
export type SystemLine = string | readonly SystemPart[];
|
|
5595
|
+
/** A profile's prompt: a string, or lines. Every line that fits is sent, a blank line apart. */
|
|
5596
|
+
export type ProfileSystem = string | readonly SystemLine[];
|
|
5597
|
+
/** The facts a host states on each turn, by name, each with the values it can take. */
|
|
5598
|
+
export type ProfileConditions = Readonly<Record<string, readonly string[]>>;
|
|
5589
5599
|
/** A stretch of the system prompt as sent, and whether a reply may repeat it. */
|
|
5590
5600
|
export interface SystemPiece {
|
|
5591
5601
|
text: string;
|
|
@@ -5594,8 +5604,9 @@ export interface SystemPiece {
|
|
|
5594
5604
|
/** A profile's handle and system prompt. */
|
|
5595
5605
|
export interface ProfileIdentity {
|
|
5596
5606
|
handle: string;
|
|
5597
|
-
|
|
5598
|
-
|
|
5607
|
+
/** The facts this agent's turns state, by name, with the values each can take. */
|
|
5608
|
+
conditions?: ProfileConditions;
|
|
5609
|
+
system?: ProfileSystem;
|
|
5599
5610
|
}
|
|
5600
5611
|
/** The fields every profile type shares. */
|
|
5601
5612
|
export interface ProfileCommon {
|
|
@@ -5842,6 +5853,21 @@ export interface SpeechProfile extends Omit<ProfileCommon, 'identity'> {
|
|
|
5842
5853
|
speech: ProfileSpeechSpec;
|
|
5843
5854
|
turnBehaviour?: MediaTurnBehaviourSpec;
|
|
5844
5855
|
}
|
|
5856
|
+
/** A transcription profile's inputs: voice clips within byte limits, and no text. */
|
|
5857
|
+
export type TranscriptionInputsSpec = Required<Pick<ProfileInputsSpec, 'voice'>> & Pick<ProfileInputsSpec, 'maxFiles' | 'maxBytes' | 'maxTurnBytes' | 'limitsByMime'>;
|
|
5858
|
+
/**
|
|
5859
|
+
* Speech to text: a voice clip in, what was said out as the turn's text. No tools, no system
|
|
5860
|
+
* prompt, and no canary, because the model follows no instruction and has nothing of the profile's to leak.
|
|
5861
|
+
*/
|
|
5862
|
+
export interface TranscriptionProfile extends Omit<ProfileCommon, 'identity' | 'outputs' | 'maxSteps'> {
|
|
5863
|
+
type: 'transcription';
|
|
5864
|
+
identity: Pick<ProfileIdentity, 'handle'>;
|
|
5865
|
+
inputs: TranscriptionInputsSpec & {
|
|
5866
|
+
text: false;
|
|
5867
|
+
};
|
|
5868
|
+
outputs?: undefined;
|
|
5869
|
+
maxSteps?: undefined;
|
|
5870
|
+
}
|
|
5845
5871
|
/** A profile that holds a live audio session. */
|
|
5846
5872
|
export interface LiveProfile extends Omit<ProfileCommon, 'outputs'> {
|
|
5847
5873
|
type: 'live';
|
|
@@ -5867,7 +5893,7 @@ export interface HostProfile {
|
|
|
5867
5893
|
labels?: LabelOverrides;
|
|
5868
5894
|
}
|
|
5869
5895
|
/** The contract that defines an agent’s capabilities and the rules for its interactions. Its type determines which settings it accepts. */
|
|
5870
|
-
export type Profile = TextProfile | ImageProfile | SpeechProfile | LiveProfile | DecisionProfile | EmbeddingProfile | HostProfile;
|
|
5896
|
+
export type Profile = TextProfile | ImageProfile | SpeechProfile | TranscriptionProfile | LiveProfile | DecisionProfile | EmbeddingProfile | HostProfile;
|
|
5871
5897
|
/** Profiles that run a model turn — every type except \`host\` and \`decision\` (which runs through \`runDecision\`). */
|
|
5872
5898
|
export type ModelProfile = Exclude<Profile, HostProfile | DecisionProfile | EmbeddingProfile>;
|
|
5873
5899
|
/** The image a profile asks the model to return. */
|
|
@@ -5910,7 +5936,6 @@ export interface TurnRepairRequest {
|
|
|
5910
5936
|
/** What the user sent for a turn: text, slots, attachments, voice, and history. */
|
|
5911
5937
|
export interface TurnInput {
|
|
5912
5938
|
text?: string;
|
|
5913
|
-
role?: string;
|
|
5914
5939
|
slots?: Record<string, string>;
|
|
5915
5940
|
/** What the page or the host wants the model to know, by sender; the profile's \`inputs.context\` allows it. */
|
|
5916
5941
|
context?: TurnContext;
|
|
@@ -5974,6 +5999,8 @@ export interface TurnRequest {
|
|
|
5974
5999
|
sessionPermissions?: string[];
|
|
5975
6000
|
/** Host channel/path for catalog \`paths\` filtering. */
|
|
5976
6001
|
path?: string;
|
|
6002
|
+
/** This turn's facts, one value for each of \`profile.identity.conditions\` but \`path\`. */
|
|
6003
|
+
conditions?: Readonly<Record<string, string>>;
|
|
5977
6004
|
/** Host-owned metadata preserved for traces; the kernel does not interpret it. */
|
|
5978
6005
|
metadata?: Record<string, unknown>;
|
|
5979
6006
|
/**
|
|
@@ -6104,6 +6131,8 @@ export interface ResolvedGeneration extends ProviderGenerationConfig {
|
|
|
6104
6131
|
canary: string;
|
|
6105
6132
|
/** Snapshotted synchronously before any async work; the runner binds the canary on top. */
|
|
6106
6133
|
resolvedSystem: readonly SystemPiece[];
|
|
6134
|
+
/** Which of the profile's prompt lines fit this turn, by number from 1. */
|
|
6135
|
+
systemLines: readonly number[];
|
|
6107
6136
|
/** \`TurnRequest.host\`, carried to tool contexts only. Never sent to providers or traces. */
|
|
6108
6137
|
host?: unknown;
|
|
6109
6138
|
}
|
|
@@ -6146,6 +6175,8 @@ export interface SessionRequest {
|
|
|
6146
6175
|
/** As \`TurnRequest.builtInArgs\`. */
|
|
6147
6176
|
builtInArgs?: BuiltInArgs;
|
|
6148
6177
|
path?: string;
|
|
6178
|
+
/** As \`TurnRequest.conditions\`. */
|
|
6179
|
+
conditions?: Readonly<Record<string, string>>;
|
|
6149
6180
|
sessionPermissions?: string[];
|
|
6150
6181
|
history?: TurnHistoryMessage[];
|
|
6151
6182
|
/** The value chosen for each of the profile's \`inputs.slots\`. */
|
|
@@ -7189,7 +7220,7 @@ export declare function keptReply(events: readonly TurnEvent[]): TurnEvent[];
|
|
|
7189
7220
|
`,"file:///node_modules/@theoremjs/agents/src/kernel/schema.d.ts":`import { BLOCKED_REPLY_ON_BLOCK, type BlockedReplyOnBlock } from '../guardrails/types.js';
|
|
7190
7221
|
export { BLOCKED_REPLY_ON_BLOCK, type BlockedReplyOnBlock };
|
|
7191
7222
|
/** The kinds of profile: each fixes which fields and models a profile may use. */
|
|
7192
|
-
export declare const PROFILE_TYPES: readonly ["text", "image", "speech", "live", "decision", "embedding", "host"];
|
|
7223
|
+
export declare const PROFILE_TYPES: readonly ["text", "image", "speech", "transcription", "live", "decision", "embedding", "host"];
|
|
7193
7224
|
/** One of {@linkcode PROFILE_TYPES}. */
|
|
7194
7225
|
export type ProfileType = (typeof PROFILE_TYPES)[number];
|
|
7195
7226
|
/** Reasoning effort levels, lowest to highest; a model accepts only the levels its catalog row lists. */
|
|
@@ -7962,7 +7993,7 @@ export { applySpans, blobAt, mergeSpans, OMIT_CANARY, OMIT_INJECTION, OMIT_PROMP
|
|
|
7962
7993
|
`,"file:///node_modules/@theoremjs/agents/src/guardrails/labels.d.ts":`/** Values that fill a label template's \`{param}\` placeholders. */
|
|
7963
7994
|
export type LabelParams = Record<string, string | number>;
|
|
7964
7995
|
/** Keys are stable API. */
|
|
7965
|
-
export declare const LABEL_KEYS: readonly ["provider.decision_failed", "provider.decision_unavailable", "provider.decision_model_missing", "provider.decision_ended", "provider.decision_images_off", "provider.decision_box_model", "provider.budget_exhausted", "provider.adapter_version", "provider.adapter_methods", "provider.adapter_schemas", "provider.fallback_slot", "provider.model_fallback_slot", "provider.host_model", "provider.turn_profile", "provider.model_binding_missing", "provider.session_closed", "provider.settled_call", "provider.session_unavailable", "provider.live_input", "provider.tool_cancel_missing", "provider.kernel_gate", "provider.event_invalid", "provider.response_identity", "provider.credential_resolution", "provider.credential_shape", "provider.stored_continuation", "provider.continuation_mismatch", "provider.continuation_contract", "provider.stateless_history", "provider.events_after_completion", "provider.duplicate_call", "provider.tool_cancel_live", "provider.complete_unavailable", "provider.parallel_tools", "provider.binding_identity", "provider.profile_type", "provider.event_type", "provider.feature", "provider.input_kind", "provider.output_kind", "provider.builtin", "provider.credential_missing", "provider.profile_configuration", "continue.instruction", "canary.bind_note", "user_data.note", "context.note", "taint.blocked", "taint.reason_steered", "taint.reason_tainted", "taint.destination_blocked", "taint.destination_confirm", "advisory.notice_elevated", "advisory.notice_high", "advisory.guidance", "attachments.too_many_files", "attachments.too_many_of_kind", "attachments.file_too_large", "attachments.turn_too_large", "attachments.not_accepted", "attachments.mime_not_allowed", "attachments.limits_unconfigured", "quota.exhausted", "quota.busy", "error.config", "error.request", "error.conflict", "error.not_found", "error.input", "error.action", "error.auth", "error.rate_limit", "error.busy", "error.unsupported", "error.unavailable", "error.bad_response", "error.network", "error.timeout", "error.safety", "error.blocked", "error.declined", "error.failed", "error.cancelled", "error.internal", "repair.default_guidance", "repair.items_guidance", "repair.prompt_header", "repair.prompt_intro", "repair.prompt_instructions", "repair.history_heading", "repair.section_previous_output", "repair.section_validator_rejection", "repair.section_repair_guidance", "repair.section_instructions", "structured.answer_tool", "structured.answer_missing", "structured.cut_off", "structured.not_json", "compaction.request", "compaction.tool_call", "compaction.tool_result", "compaction.tool_files", "decision.box_image", "detect.blocked", "detect.call_blocked", "detect.output_blocked", "detect.shown_blocked", "detect.hint.ids", "detect.hint.financial", "detect.hint.network", "detect.hint.credentials", "detect.hint.injection", "detect.hint.tool_instructions", "detect.hint.canary_leak", "detect.hint.prompt_leak", "detect.hint.marker_leak", "detect.hint.ungiven_images", "detect.hint.ungiven_links", "detect.hint.tool_leak", "detect.hint.own", "egress.default_repair_guidance", "egress.refusal", "egress.refusal_cut", "egress.rejection", "egress.rejection_found", "egress.hint_unscannable", "egress.hint_provider_tool_leak", "thought.omitted_image", "thought.omitted_link", "thought.omitted_instructions", "session.abandon_gated", "session.tool_denied", "session.tool_aborted", "session.sign_in", "sign_in.link", "sign_in.pending", "sign_in.done", "sign_in.declined", "sign_in.expired", "sign_in.out_of_scope", "session.gate_expired", "session.provider_state_unowned", "session.conversation_unknown", "session.full", "session.busy", "session.turn_ended", "session.gate_pending", "session.part_skipped", "live.session_ended", "voice.unsupported", "voice.permission", "voice.unavailable", "voice.failed", "voice.empty", "stop.cancelled", "stop.interrupted", "stop.length", "stop.filtered", "stop.provider_error", "stop.stream_incomplete", "stop.step_limit", "composer.model", "composer.effort", "tool.awaiting_user", "tool.completed_hidden", "tool.t2_loader_needs_snapshot", "tool.t2_loader_shape", "tool.t2_loader_output_invalid", "tool.execution_uncertain", "tool.input_invalid", "tool.input_invalid_after_mutate", "tool.output_invalid_after_mutate", "tool.handler_no_output", "tool.did_not_run", "tool.page_no_answer", "tool.page_timed_out", "tool.output_invalid", "tool.not_loaded_t2", "tool.wait_unknown", "tool.wait_cycle", "tool.not_visible", "tool.builtin_not_enabled", "tool.provider_native", "tool.not_registered", "tool.builtin_needs_snapshot", "tool.not_allowed", "tool.not_eligible", "tool.unsupported_type", "tool.agent_call_limit", "tool.agent_failed", "tool.activity_failed", "protocol.not_served", "protocol.profile_type", "protocol.options", "protocol.option_clash", "protocol.base_options", "protocol.id_clash", "protocol.ws_headers", "protocol.builtin_unwritten", "protocol.provider_missing", "protocol.connection", "protocol.part_schema", "protocol.part_invalid", "protocol.key_invalid", "protocol.no_key", "protocol.reply_shape", "protocol.endpoint_url", "protocol.endpoint_host", "protocol.http", "protocol.no_operation", "protocol.definition", "protocol.provider_id_clash", "protocol.history_needed"];
|
|
7996
|
+
export declare const LABEL_KEYS: readonly ["provider.decision_failed", "provider.decision_unavailable", "provider.decision_model_missing", "provider.decision_ended", "provider.decision_images_off", "provider.decision_box_model", "provider.budget_exhausted", "provider.adapter_version", "provider.adapter_methods", "provider.adapter_schemas", "provider.fallback_slot", "provider.model_fallback_slot", "provider.host_model", "provider.turn_profile", "provider.model_binding_missing", "provider.session_closed", "provider.settled_call", "provider.session_unavailable", "provider.live_input", "provider.tool_cancel_missing", "provider.kernel_gate", "provider.event_invalid", "provider.response_identity", "provider.credential_resolution", "provider.credential_shape", "provider.stored_continuation", "provider.continuation_mismatch", "provider.continuation_contract", "provider.stateless_history", "provider.events_after_completion", "provider.duplicate_call", "provider.tool_cancel_live", "provider.complete_unavailable", "provider.parallel_tools", "provider.binding_identity", "provider.profile_type", "provider.event_type", "provider.feature", "provider.input_kind", "provider.output_kind", "provider.builtin", "provider.credential_missing", "provider.profile_configuration", "continue.instruction", "canary.bind_note", "user_data.note", "context.note", "taint.blocked", "taint.reason_steered", "taint.reason_tainted", "taint.destination_blocked", "taint.destination_confirm", "advisory.notice_elevated", "advisory.notice_high", "advisory.guidance", "attachments.too_many_files", "attachments.too_many_of_kind", "attachments.file_too_large", "attachments.turn_too_large", "attachments.not_accepted", "attachments.mime_not_allowed", "attachments.limits_unconfigured", "quota.exhausted", "quota.busy", "error.config", "error.request", "error.conflict", "error.not_found", "error.input", "error.action", "error.auth", "error.rate_limit", "error.busy", "error.unsupported", "error.unavailable", "error.bad_response", "error.network", "error.timeout", "error.safety", "error.blocked", "error.declined", "error.failed", "error.cancelled", "error.internal", "repair.default_guidance", "repair.items_guidance", "repair.prompt_header", "repair.prompt_intro", "repair.prompt_instructions", "repair.history_heading", "repair.section_previous_output", "repair.section_validator_rejection", "repair.section_repair_guidance", "repair.section_instructions", "structured.answer_tool", "structured.answer_missing", "structured.cut_off", "structured.not_json", "compaction.request", "compaction.tool_call", "compaction.tool_result", "compaction.tool_files", "decision.box_image", "detect.blocked", "detect.call_blocked", "detect.output_blocked", "detect.shown_blocked", "detect.hint.ids", "detect.hint.financial", "detect.hint.network", "detect.hint.credentials", "detect.hint.injection", "detect.hint.tool_instructions", "detect.hint.canary_leak", "detect.hint.prompt_leak", "detect.hint.marker_leak", "detect.hint.ungiven_images", "detect.hint.ungiven_links", "detect.hint.tool_leak", "detect.hint.own", "egress.default_repair_guidance", "egress.refusal", "egress.refusal_cut", "egress.rejection", "egress.rejection_found", "egress.hint_unscannable", "egress.hint_provider_tool_leak", "thought.omitted_image", "thought.omitted_link", "thought.omitted_instructions", "session.abandon_gated", "session.tool_denied", "session.tool_aborted", "session.sign_in", "sign_in.link", "sign_in.pending", "sign_in.done", "sign_in.declined", "sign_in.expired", "sign_in.out_of_scope", "session.gate_expired", "session.provider_state_unowned", "session.conversation_unknown", "session.full", "session.busy", "session.turn_ended", "session.gate_pending", "session.part_skipped", "live.session_ended", "voice.unsupported", "voice.permission", "voice.unavailable", "voice.failed", "voice.empty", "stop.cancelled", "stop.interrupted", "stop.length", "stop.filtered", "stop.provider_error", "stop.stream_incomplete", "stop.step_limit", "composer.model", "composer.effort", "tool.awaiting_user", "tool.completed_hidden", "tool.t2_loader_needs_snapshot", "tool.t2_loader_shape", "tool.t2_loader_output_invalid", "tool.execution_uncertain", "tool.input_invalid", "tool.input_invalid_after_mutate", "tool.output_invalid_after_mutate", "tool.handler_no_output", "tool.did_not_run", "tool.page_no_answer", "tool.page_timed_out", "tool.output_invalid", "tool.not_loaded_t2", "tool.wait_unknown", "tool.wait_cycle", "tool.after_field", "tool.not_visible", "tool.builtin_not_enabled", "tool.provider_native", "tool.not_registered", "tool.builtin_needs_snapshot", "tool.not_allowed", "tool.not_eligible", "tool.unsupported_type", "tool.agent_call_limit", "tool.agent_failed", "tool.activity_failed", "protocol.not_served", "protocol.profile_type", "protocol.options", "protocol.option_clash", "protocol.base_options", "protocol.id_clash", "protocol.ws_headers", "protocol.builtin_unwritten", "protocol.provider_missing", "protocol.connection", "protocol.part_schema", "protocol.part_invalid", "protocol.key_invalid", "protocol.no_key", "protocol.reply_shape", "protocol.endpoint_url", "protocol.endpoint_host", "protocol.http", "protocol.no_operation", "protocol.definition", "protocol.provider_id_clash", "protocol.history_needed"];
|
|
7966
7997
|
/** One of {@linkcode LABEL_KEYS}. */
|
|
7967
7998
|
export type LabelKey = (typeof LABEL_KEYS)[number];
|
|
7968
7999
|
/**
|
|
@@ -9116,6 +9147,8 @@ export interface ToolHostHooks<TIn = unknown> {
|
|
|
9116
9147
|
/** Runs before the host's \`pre_tool\` \`onStage\`. */
|
|
9117
9148
|
preTool?: (input: TIn, ctx: ToolContext) => import('../stages.js').StageResult | undefined | Promise<import('../stages.js').StageResult | undefined>;
|
|
9118
9149
|
exposeToModel?: boolean;
|
|
9150
|
+
/** The model gets an \`after\` field: the tools in the same step that must settle before this call starts. */
|
|
9151
|
+
after?: boolean;
|
|
9119
9152
|
}
|
|
9120
9153
|
export interface ToolOutputHooks<TOut = unknown> {
|
|
9121
9154
|
/** A source that fails \`sourceSchema\`, or a throw, is a \`sources_invalid\` warning and is not cited. */
|
|
@@ -9277,6 +9310,7 @@ export interface AgentToolDef extends ToolBase {
|
|
|
9277
9310
|
/** Channels the profile takes that the calling model can't fill; only \`onAgentCall\` sends them. */
|
|
9278
9311
|
hostOnly?: AgentToolChannel[];
|
|
9279
9312
|
preTool?: ToolHostHooks<AgentToolInput>['preTool'];
|
|
9313
|
+
after?: ToolHostHooks<AgentToolInput>['after'];
|
|
9280
9314
|
exposeToModel?: boolean;
|
|
9281
9315
|
}
|
|
9282
9316
|
export interface RegisteredAgentTool extends AgentToolDef, ToolHostHooks<AgentToolInput>, ToolOutputHooks<AgentToolOutput> {
|
|
@@ -9787,6 +9821,20 @@ export declare const toolOperationOutcomeSchema: z.ZodType<ToolOperationOutcome>
|
|
|
9787
9821
|
export declare function operationWireValue(value: unknown): JsonValue;
|
|
9788
9822
|
`,"file:///node_modules/@theoremjs/agents/src/guardrails/error.d.ts":"import type { TurnEventOf } from '../kernel/turn-events.js';\nimport type { TurnEvent } from '../kernel/types.js';\nimport { type LabelOverrides } from './labels.js';\nimport { type ErrorCopies, type ErrorKind, TheoremError } from './theorem-error.js';\n/** True when the value is an error named `AbortError`. */\ndeclare function isAbortError(err: unknown): boolean;\n/** `AbortSignal.timeout` rejects with a `TimeoutError`, not an `AbortError`. */\ndeclare function isTimeoutError(err: unknown): boolean;\n/** Throws when the signal has aborted: its framework, abort or timeout reason, else an `AbortError`. */\ndeclare function throwIfAborted(signal?: AbortSignal): void;\n/** Anything that is not a `TheoremError` or an abort escaped every boundary that names kinds: a THEOREM bug. */\ndeclare function errorKind(err: unknown): ErrorKind;\n/** The error kind for an HTTP status: 401, 402 and 403 are `auth`; 408, 504 and 524 `timeout`; 409 `conflict`; 429 `rate_limit`; 503 and 529 (overloaded) `busy`; 500 and above `unavailable`; the rest `unsupported`. */\ndeclare function kindOfHttpStatus(status: number): ErrorKind;\n/** The named reasons an error carries, one line each, in the profile's wording. */\ndeclare function errorCopyText(copy: ErrorCopies, labels?: LabelOverrides): string;\n/** Pass the profile's `labels`, or the profile's wording is skipped. */\ndeclare function publicError(err: unknown, labels?: LabelOverrides): string;\n/** Raw diagnostic for hosts, traces, and logs; never shown to end users. Each cause that says something new follows on its own line. */\ndeclare function describeError(err: unknown): string;\n/** fetch rejects only when no response came back, so any non-abort, non-timeout rejection is `network`. */\ndeclare function networkError(err: unknown): unknown;\n/** `send`, with a failed send or body read named as `networkError` names it. */\ndeclare function sendOrNetworkError(send: typeof fetch, ...args: Parameters<typeof fetch>): Promise<Response>;\ntype ProducedError = TurnEventOf<'error'> & {\n errorInternal: string;\n};\n/** No user wording yet: `withPublicLabels` adds it where the event reaches the host, the one place that knows the profile. */\ndeclare function toErrorEvent(err: unknown): ProducedError;\n/** Wording already set (host copy) is kept. */\ndeclare function withPublicLabels(event: TurnEvent, labels?: LabelOverrides): TurnEvent;\nexport type { ErrorCopies, ErrorCopy, ErrorKind, TheoremErrorOptions } from './theorem-error.js';\nexport { ERROR_KINDS } from './theorem-error.js';\nexport type { ProducedError };\nexport { describeError, errorCopyText, errorKind, isAbortError, isTimeoutError, kindOfHttpStatus, networkError, publicError, sendOrNetworkError, TheoremError, throwIfAborted, toErrorEvent, withPublicLabels, };\n","file:///node_modules/@theoremjs/agents/src/kernel/tools/activity-label.d.ts":`/** One line of wording, or a list of lines read top to bottom: the first that fits is shown. */
|
|
9789
9823
|
export type LabelTemplate = string | readonly string[];
|
|
9824
|
+
/** \`expected: null\` is the check "is null". */
|
|
9825
|
+
export type Check = {
|
|
9826
|
+
path: string;
|
|
9827
|
+
negated: boolean;
|
|
9828
|
+
expected: string | null;
|
|
9829
|
+
};
|
|
9830
|
+
export type Line = {
|
|
9831
|
+
joined: boolean;
|
|
9832
|
+
when: Check[] | 'unreadable';
|
|
9833
|
+
text: string;
|
|
9834
|
+
};
|
|
9835
|
+
/** A line's head, with its text exactly as written after the condition. */
|
|
9836
|
+
export declare function splitWhen(raw: string): Line;
|
|
9837
|
+
export declare function checkHolds(check: Check, input: unknown): boolean;
|
|
9790
9838
|
/** A tool's name as a label shows it: \`manage_alert\` reads "manage alert". */
|
|
9791
9839
|
export declare function toolNameInWords(name: string): string;
|
|
9792
9840
|
/**
|
|
@@ -9800,6 +9848,7 @@ export declare function fillActivityLabel(template: LabelTemplate | undefined, v
|
|
|
9800
9848
|
input: unknown;
|
|
9801
9849
|
output?: unknown;
|
|
9802
9850
|
}): string | undefined;
|
|
9851
|
+
export declare function checkProblem(check: Check, input: unknown, reads?: string): string | undefined;
|
|
9803
9852
|
export declare function activityLabelProblem(template: LabelTemplate, schemas: {
|
|
9804
9853
|
input: unknown;
|
|
9805
9854
|
output?: unknown;
|
|
@@ -9965,6 +10014,16 @@ export * from './prices.js';
|
|
|
9965
10014
|
export * from './protocol.js';
|
|
9966
10015
|
export * from './provider.js';
|
|
9967
10016
|
export { type CallSetup, callProtocol } from './runtime.js';
|
|
10017
|
+
`,"file:///node_modules/@theoremjs/agents/src/providers/openrouter/transcriptions-protocol.d.ts":`import { type Protocol } from '../../kernel/protocols/mod.js';
|
|
10018
|
+
/** What an \`openRouterTranscriptions\` binding sets in \`options\`. */
|
|
10019
|
+
export interface OpenRouterTranscriptionsOptions {
|
|
10020
|
+
provider?: {
|
|
10021
|
+
zdr?: boolean;
|
|
10022
|
+
data_collection?: 'allow' | 'deny';
|
|
10023
|
+
};
|
|
10024
|
+
}
|
|
10025
|
+
/** OpenRouter's speech to text. Its body is its own JSON, not OpenAI's multipart upload. */
|
|
10026
|
+
export declare const openRouterTranscriptions: Protocol<OpenRouterTranscriptionsOptions>;
|
|
9968
10027
|
`,"file:///node_modules/@theoremjs/agents/src/providers/openrouter/provider.d.ts":`import { type Provider } from '../../kernel/protocols/provider.js';
|
|
9969
10028
|
/** What registering \`openRouterProvider\` takes as \`connection\`. */
|
|
9970
10029
|
export interface OpenRouterConnection {
|
|
@@ -9973,13 +10032,39 @@ export interface OpenRouterConnection {
|
|
|
9973
10032
|
siteUrl?: string;
|
|
9974
10033
|
siteName?: string;
|
|
9975
10034
|
}
|
|
9976
|
-
/** OpenRouter: many labs' models behind one key. Chat, speech, images, and decisions. */
|
|
10035
|
+
/** OpenRouter: many labs' models behind one key. Chat, speech, transcription, images, and decisions. */
|
|
9977
10036
|
export declare const openRouterProvider: Provider<OpenRouterConnection, string>;
|
|
9978
|
-
`,"file:///node_modules/@theoremjs/agents/src/providers/openrouter/protocol.d.ts":`import { type
|
|
10037
|
+
`,"file:///node_modules/@theoremjs/agents/src/providers/openrouter/protocol.d.ts":`import { type JsonObject } from '../../kernel/json.js';
|
|
10038
|
+
import { type Protocol } from '../../kernel/protocols/mod.js';
|
|
9979
10039
|
import type { CacheSpec } from '../../kernel/types.js';
|
|
9980
10040
|
/** What an \`openRouterOpenAi\` binding sets in \`options\`. */
|
|
9981
10041
|
export interface OpenRouterOptions {
|
|
9982
10042
|
cache?: CacheSpec;
|
|
10043
|
+
provider?: OpenRouterRouting;
|
|
10044
|
+
}
|
|
10045
|
+
/** OpenRouter's own \`provider\` request field, under its own names. */
|
|
10046
|
+
export interface OpenRouterRouting {
|
|
10047
|
+
only?: string[];
|
|
10048
|
+
order?: string[];
|
|
10049
|
+
ignore?: string[];
|
|
10050
|
+
allow_fallbacks?: boolean;
|
|
10051
|
+
require_parameters?: boolean;
|
|
10052
|
+
data_collection?: 'allow' | 'deny';
|
|
10053
|
+
zdr?: boolean;
|
|
10054
|
+
enforce_distillable_text?: boolean;
|
|
10055
|
+
quantizations?: string[];
|
|
10056
|
+
sort?: string | {
|
|
10057
|
+
by: string;
|
|
10058
|
+
partition?: string;
|
|
10059
|
+
};
|
|
10060
|
+
preferred_min_throughput?: number | JsonObject;
|
|
10061
|
+
preferred_max_latency?: number | JsonObject;
|
|
10062
|
+
max_price?: {
|
|
10063
|
+
prompt?: number;
|
|
10064
|
+
completion?: number;
|
|
10065
|
+
request?: number;
|
|
10066
|
+
image?: number;
|
|
10067
|
+
};
|
|
9983
10068
|
}
|
|
9984
10069
|
/** Chat Completions with OpenRouter's caching, routing, web search, citations, and reasoning. */
|
|
9985
10070
|
export declare const openRouterOpenAi: Protocol<OpenRouterOptions>;
|
|
@@ -10412,7 +10497,7 @@ import { type DecisionGuardrailsSpec, type HostGuardrailsSpec, type ProfileGuard
|
|
|
10412
10497
|
import type { ProfileObservabilitySpec } from '../../observability/types.js';
|
|
10413
10498
|
import type { ProviderRegistry } from '../protocols/provider.js';
|
|
10414
10499
|
import type { ToolRegistry } from '../tools/registry.js';
|
|
10415
|
-
import type { DecisionModelBinding, DecisionProfile, EmbeddingProfile, HostProfile, HostProfileToolsSpec, ImageInputsSpec, ImageProfile, LiveProfile, LiveProfileToolsSpec, MediaTurnBehaviourSpec, ModelBinding, ModelId, Profile, ProfileIdentity, ProfileInputsSpec, ProfileOutputsSpec, ProfileToolsSpec, ProfileTurnBehaviourSpec, SpeechProfile, TextProfile } from '../types.js';
|
|
10500
|
+
import type { DecisionModelBinding, DecisionProfile, EmbeddingProfile, HostProfile, HostProfileToolsSpec, ImageInputsSpec, ImageProfile, LiveProfile, LiveProfileToolsSpec, MediaTurnBehaviourSpec, ModelBinding, ModelId, Profile, ProfileIdentity, ProfileInputsSpec, ProfileOutputsSpec, ProfileToolsSpec, ProfileTurnBehaviourSpec, SpeechProfile, TextProfile, TranscriptionInputsSpec, TranscriptionProfile } from '../types.js';
|
|
10416
10501
|
import type { SchemaRegistry } from './schemas.js';
|
|
10417
10502
|
/** Not shared by host profiles, which invoke tools without a model turn. */
|
|
10418
10503
|
export type ProfileDefinitionBase = {
|
|
@@ -10456,6 +10541,14 @@ export type SpeechProfileDefinition = Omit<ProfileDefinitionBase, 'identity'> &
|
|
|
10456
10541
|
speech: NonNullable<SpeechProfile['speech']>;
|
|
10457
10542
|
turnBehaviour?: MediaTurnBehaviourSpec;
|
|
10458
10543
|
};
|
|
10544
|
+
/** What a host writes to define a transcription profile. */
|
|
10545
|
+
export type TranscriptionProfileDefinition = Omit<ProfileDefinitionBase, 'identity' | 'outputs' | 'maxSteps'> & {
|
|
10546
|
+
type: 'transcription';
|
|
10547
|
+
identity: TranscriptionProfile['identity'];
|
|
10548
|
+
inputs: TranscriptionInputsSpec & {
|
|
10549
|
+
text?: false;
|
|
10550
|
+
};
|
|
10551
|
+
};
|
|
10459
10552
|
/** What a host writes to define a live profile. */
|
|
10460
10553
|
export type LiveProfileDefinition = ProfileDefinitionBase & {
|
|
10461
10554
|
type: 'live';
|
|
@@ -10489,13 +10582,15 @@ export type HostProfileDefinition = {
|
|
|
10489
10582
|
labels?: LabelOverrides;
|
|
10490
10583
|
};
|
|
10491
10584
|
/** Any profile definition, discriminated by \`type\`. */
|
|
10492
|
-
export type ProfileDefinition = TextProfileDefinition | ImageProfileDefinition | SpeechProfileDefinition | LiveProfileDefinition | DecisionProfileDefinition | EmbeddingProfileDefinition | HostProfileDefinition;
|
|
10585
|
+
export type ProfileDefinition = TextProfileDefinition | ImageProfileDefinition | SpeechProfileDefinition | LiveProfileDefinition | DecisionProfileDefinition | TranscriptionProfileDefinition | EmbeddingProfileDefinition | HostProfileDefinition;
|
|
10493
10586
|
/** Validate a definition and return the profile; throws on a malformed one. */
|
|
10494
10587
|
declare function defineProfile(input: TextProfileDefinition): TextProfile;
|
|
10495
10588
|
/** Validate an image definition and return the profile. */
|
|
10496
10589
|
declare function defineProfile(input: ImageProfileDefinition): ImageProfile;
|
|
10497
10590
|
/** Validate a speech definition and return the profile. */
|
|
10498
10591
|
declare function defineProfile(input: SpeechProfileDefinition): SpeechProfile;
|
|
10592
|
+
/** Validate a transcription definition and return the profile. */
|
|
10593
|
+
declare function defineProfile(input: TranscriptionProfileDefinition): TranscriptionProfile;
|
|
10499
10594
|
/** Validate a live definition and return the profile. */
|
|
10500
10595
|
declare function defineProfile(input: LiveProfileDefinition): LiveProfile;
|
|
10501
10596
|
/** Validate a decision definition and return the profile. */
|
|
@@ -10840,7 +10935,6 @@ export type PostToolStageOutcome = {
|
|
|
10840
10935
|
};
|
|
10841
10936
|
labelFailed?: true;
|
|
10842
10937
|
};
|
|
10843
|
-
/** Tool \`preTool\` → host \`pre_tool\` → mutate re-parse. */
|
|
10844
10938
|
export declare function runPreToolPipeline(args: {
|
|
10845
10939
|
tool: {
|
|
10846
10940
|
name: string;
|
|
@@ -10849,6 +10943,7 @@ export declare function runPreToolPipeline(args: {
|
|
|
10849
10943
|
};
|
|
10850
10944
|
access: ToolAccess;
|
|
10851
10945
|
labels?: ToolLabels;
|
|
10946
|
+
after?: boolean;
|
|
10852
10947
|
preTool?: (input: never, ctx: ToolContext) => StageResult | undefined | Promise<StageResult | undefined>;
|
|
10853
10948
|
};
|
|
10854
10949
|
input: unknown;
|
|
@@ -11632,6 +11727,28 @@ export interface MemoryToolExecutionOptions {
|
|
|
11632
11727
|
* A host that resumes across requests or workers supplies its own \`ToolExecutionCoordinator\`.
|
|
11633
11728
|
*/
|
|
11634
11729
|
export declare function createMemoryToolExecution(options?: MemoryToolExecutionOptions): ToolExecutionCoordinator;
|
|
11730
|
+
`,"file:///node_modules/@theoremjs/agents/src/kernel/system-lines.d.ts":`import type { ProfileConditions, ProfileSystem, SystemPiece, TurnRequest } from './types.js';
|
|
11731
|
+
/** What is wrong with a prompt's conditions and lines, or undefined. */
|
|
11732
|
+
export declare function systemLinesProblem(prompt: ProfileSystem, conditions: ProfileConditions | undefined, slots: Record<string, readonly string[]>): string | undefined;
|
|
11733
|
+
/** The facts a turn's \`when\` reads, once the turn has stated every condition with a listed value. */
|
|
11734
|
+
export declare function turnFacts(id: string, conditions: ProfileConditions | undefined, req: Pick<TurnRequest, 'path' | 'conditions'>, slots: Record<string, string> | undefined): Record<string, string>;
|
|
11735
|
+
/** A line that fit a turn: its number in the prompt as written, from 1, and its pieces. */
|
|
11736
|
+
export type KeptSystemLine = {
|
|
11737
|
+
line: number;
|
|
11738
|
+
pieces: SystemPiece[];
|
|
11739
|
+
};
|
|
11740
|
+
/**
|
|
11741
|
+
* Every line that fits. Whether plain text is shareable is settled on the prompt as written, so a
|
|
11742
|
+
* line dropped on this turn never changes the marks of one that stayed.
|
|
11743
|
+
*/
|
|
11744
|
+
export declare function pickSystemLines(prompt: ProfileSystem, facts: Record<string, string>, fill: (text: string) => string): KeptSystemLine[];
|
|
11745
|
+
/** \`where\` names the prompt in the error. A bare \`{ private }\` must sit inside a line's own list. */
|
|
11746
|
+
export declare function assertSystemLines(prompt: unknown, where: string): asserts prompt is ProfileSystem;
|
|
11747
|
+
/** The first tool in \`tools\` with a path \`conditions.path\` does not list, as a sentence. */
|
|
11748
|
+
export declare function toolPathProblem(conditions: ProfileConditions | undefined, tools: readonly {
|
|
11749
|
+
name: string;
|
|
11750
|
+
paths?: readonly string[];
|
|
11751
|
+
}[]): string | undefined;
|
|
11635
11752
|
`,"file:///node_modules/@theoremjs/agents/src/kernel/scope.d.ts":`import type { TraceSink } from '../observability/trace-sink.js';
|
|
11636
11753
|
import { type RunDecisionOptions } from './engine/decision.js';
|
|
11637
11754
|
import { type RunEmbeddingOptions } from './engine/embedding.js';
|
|
@@ -11775,6 +11892,19 @@ export declare function validateDecisionRequest(request: Omit<DecisionRequest, '
|
|
|
11775
11892
|
*/
|
|
11776
11893
|
export declare function runDecisionInRegistry(registry: KernelRegistry, request: DecisionRequest, options: RunDecisionOptions): Promise<DecisionResult>;
|
|
11777
11894
|
export {};
|
|
11895
|
+
`,"file:///node_modules/@theoremjs/agents/src/kernel/registry/system-prompt.d.ts":`import type { ModelProfile, SystemPiece, TurnRequest } from '../types.js';
|
|
11896
|
+
/**
|
|
11897
|
+
* Synchronous: snapshotted in \`resolveTurn\` before any async work. Each source
|
|
11898
|
+
* keeps its own marks: a \`{ private }\` part in \`req.system\` leaves the
|
|
11899
|
+
* profile's prompt as private as it was written.
|
|
11900
|
+
*/
|
|
11901
|
+
declare function resolveTurnSystem(profile: ModelProfile, req: TurnRequest): {
|
|
11902
|
+
pieces: SystemPiece[];
|
|
11903
|
+
lines: number[];
|
|
11904
|
+
};
|
|
11905
|
+
/** The whole prompt a turn sends, for what reads it outside a turn. */
|
|
11906
|
+
declare function resolveTurnSystemPrompt(profile: ModelProfile, req: TurnRequest): SystemPiece[];
|
|
11907
|
+
export { resolveTurnSystem, resolveTurnSystemPrompt };
|
|
11778
11908
|
`,"file:///node_modules/@theoremjs/agents/src/kernel/registry/embedding-rules.d.ts":`import type { EmbeddingModelLimits } from '../protocols/protocol.js';
|
|
11779
11909
|
import type { AttachmentValidationIssue, MimeInputs } from '../types.js';
|
|
11780
11910
|
import { type AttachmentFacts } from './attachments.js';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{A as e,D as t,E as n,O as r,T as i,b as a,c as o,d as s,f as c,x as l}from"./schemas-D7cgkv3L.js";import{Ct as ee,Et as te,H as ne,Ht as re,Qn as ie,Sn as ae,Un as oe,Vn as se,_n as ce,bn as u,ln as le,on as ue,qt as de,sn as fe,vn as d,wt as pe,yn as f,zn as me}from"./tool-schema-BDG2_rlP.js";import{c as p}from"./host-patterns-F-KZIzkF.js";import{A as he,Lr as m,Mn as ge,Nn as _e,Nr as ve,Rr as ye,Un as h,an as be,er as xe,fn as Se,jn as Ce,lr as g,pn as _,tn as v,tr as we,vn as y,vr as Te,wr as Ee}from"./shaped-data-CJQ3W_RE.js";import{a as De,n as Oe}from"./live-ingress-OuSlQ6q7.js";var ke=2,Ae=4,je=3,Me=/(^|,)(\s*)("?)(?:([=@])|([+-])(?![0-9."]))/gm,Ne=/^[A-Za-z0-9+/]*={0,2}$/,Pe=new Set([`text/csv`,`text/plain`,`text/markdown`]);function b(e){let{maxFiles:t,maxBytes:n,maxTurnBytes:r,limitsByMime:i}=e;if(t&&n&&r)return{maxFiles:t,maxBytes:n,maxTurnBytes:r,limitsByMime:i}}function Fe(e,t){if(t.limitsByMime){let n=ae(e);if(t.limitsByMime[n])return t.limitsByMime[n];let[r]=n.split(`/`),i=`${r}/*`;if(t.limitsByMime[i])return t.limitsByMime[i]}return t.maxBytes}function x(e){return`uri`in e}function Ie(e){if(e.type===`speech`)throw new p(`request`,`Profile ${e.id} (speech) does not accept media input`);if(e.type===`live`)throw new p(`request`,`Profile ${e.id} (live) does not accept turn attachment input`);if(e.type===`host`||e.type===`decision`||e.type===`embedding`)throw new p(`request`,`Profile ${e.id} (${e.type}) does not accept turn input`);let t=b(e.inputs??{});if(!t)throw new p(`config`,`Profile ${e.id} must set maxFiles, maxBytes, and maxTurnBytes`);return t}function Le(e){let t=0;return e.endsWith(`==`)?t=ke:e.endsWith(`=`)&&(t=1),Math.floor(e.length*je/Ae)-t}function Re(e){try{return new TextDecoder(`utf-8`,{fatal:!0}).decode(e)}catch{return new TextDecoder(`latin1`).decode(e)}}function ze(e){return e.replace(Me,(e,...t)=>{let[n,r,i,a,o]=t;return`${n}${r}${i}'${a??``}${o??``}`})}function Be(e,t,n){let r=Re(t);return e===`text/csv`&&(r=ze(r)),new TextEncoder().encode(n.read(r))}function S(e,t){return t?{...e,fileName:t}:e}function C(e,t,n){return t.filter(t=>!d(e,t.mimeType)).map(e=>S({code:`mime_not_allowed`,params:{mimeType:e.mimeType,channel:n}},e.name))}function Ve(e,t){let n=[];e.length>t.maxFiles&&n.push({code:`too_many_files`,params:{maxFiles:t.maxFiles}});let r=0;for(let i of e){if(i.sizeBytes===void 0)continue;let e=Fe(i.mimeType,t);i.sizeBytes>e&&n.push(S({code:`file_too_large`,params:{maxBytes:e}},i.name)),r+=i.sizeBytes}return r>t.maxTurnBytes&&n.push({code:`turn_too_large`,params:{maxTurnBytes:t.maxTurnBytes}}),n}function w(e,t,n){let r=[];return t.length>0&&!e.attachments&&r.push({code:`attachments_not_accepted`,params:{channel:`attachment`}}),n.length>0&&!e.voice&&r.push({code:`voice_not_accepted`,params:{channel:`voice`}}),r.length>0||t.length===0&&n.length===0?r:(e.attachments&&r.push(...C(e.attachments,t,`attachment`)),e.voice&&r.push(...C(e.voice,n,`voice`)),e.limits?[...r,...Ve([...t,...n],e.limits)]:[...r,{code:`limits_unconfigured`}])}var He={mime_not_allowed:`attachments.mime_not_allowed`,too_many_files:`attachments.too_many_files`,too_many_of_kind:`attachments.too_many_of_kind`,file_too_large:`attachments.file_too_large`,turn_too_large:`attachments.turn_too_large`,attachments_not_accepted:`attachments.not_accepted`,voice_not_accepted:`attachments.not_accepted`,limits_unconfigured:`attachments.limits_unconfigured`};function Ue(e){let t={};for(let[n,r]of Object.entries(e.params??{}))r!==void 0&&(t[n]=r);return e.fileName!==void 0&&(t.fileName=e.fileName),{key:He[e.code],params:t}}function We(e,t){let n=Ue(e);return m(n.key,n.params,t)}function Ge(e){return new p(`input`,`attachments refused: ${e.map(e=>e.code).join(`, `)}`,{copy:e.map(Ue)})}function Ke(e){if(!Ne.test(e))throw new p(`request`,`attachment data must be base64`);return Le(e)}function qe(e){let t={mimeType:e.mimeType,name:e.name};return x(e)||(t.sizeBytes=Ke(e.data)),t}function Je(e,t,n){if(!Xe(t,n))return;let r=Ie(e),i=w({attachments:f(e,`attachments`),voice:f(e,`voice`),limits:r},(t??[]).map(qe),(n??[]).map(qe));if(i.length>0)throw Ge(i)}function Ye(e,t){if(x(e))return e;let{mimeType:n,data:r}=e;if(!Pe.has(ae(n)))return e;let i=Be(n,xe(r),t);return{...e,data:we(i)}}function Xe(e,t){return(e?.length??0)>0||(t?.length??0)>0}function Ze(e,t,n,r){return Je(e,t,n),{attachments:t?.length?t.map(e=>Ye(e,r.attachment)):t,voice:n?.length?n.map(e=>Ye(e,r.voice)):n}}var Qe=`
|
|
2
|
+
|
|
3
|
+
`;function $e(e){if(typeof e==`string`)return;if(typeof e!=`object`||!e||Array.isArray(e))return`must be a string or { private: string }`;let t=Object.keys(e);if(t.length!==1||t[0]!==`private`)return`must have exactly one key, private`;let n=e.private;if(typeof n!=`string`)return`must be a string`;if(n===``)return`must not be empty`}function et(e,t){if(typeof e!=`string`){if(!Array.isArray(e))return`${t} must be a string or an array of parts`;if(e.length===0)return`${t} must not be an empty array`;for(let[n,r]of e.entries()){let e=$e(r);if(e)return`${t}[${n}]${typeof r==`object`&&r&&`private`in r?`.private`:``} ${e}`}}}function tt(e,t){let n=et(e,t);if(n)throw new p(`config`,n)}function nt(e,t,n){return tt(e,t),typeof e==`string`?n(e):e.map(e=>typeof e==`string`?n(e):{private:n(e.private)})}function rt(e){if(typeof e==`string`)return[{text:e,private:!0}];let t=e.some(e=>typeof e!=`string`);return e.map(e=>typeof e==`string`?{text:e,private:!t}:{text:e.private,private:!0})}function it(e){let t=[];for(let n of e)n.some(e=>e.text)&&(t.length>0&&t.push({text:Qe,private:!0}),t.push(...n));return t}function at(e){return e.map(e=>e.text).join(``)}function ot(e){let t=[],n=``;for(let r of e)r.private?n+=r.text:(n.trim()&&t.push(n),n=``);return n.trim()&&t.push(n),{text:at(e),private:t}}function st(e,t){return ot(it([e,...t.map(e=>e?[{text:e,private:!0}]:[])]))}function T(e){let t=Object.keys(e);return t.length===1?t[0]:void 0}var ct=/^[A-Za-z_][\w-]*$/,lt=/^\S+$/;function ut(e){return typeof e==`string`?[[e]]:e.map(e=>typeof e==`string`?[e]:e)}function dt(e){return typeof e==`string`?e:e.private}function E(e){return te(e[0]===void 0?``:dt(e[0]))}function ft(e,t){let n={};for(let[r,i]of Object.entries({...e,...t}))n[r]={type:`string`,enum:[...i]};return{type:`object`,properties:n}}function pt(e,t){for(let[n,r]of Object.entries(e??{})){if(!ct.test(n))return`Condition "${n}" needs a plain name.`;if(n===`input`||n===`output`)return`Condition "${n}" is a reserved name.`;if(Object.hasOwn(t,n))return`"${n}" is both a condition and a slot.`;if(r.length===0)return`Condition "${n}" lists no values.`;let e=r.find(e=>!lt.test(e)||e===`null`);if(e!==void 0)return`Condition "${n}" can't take the value "${e}".`}}function mt(e,t){if(e.length===0)return`It has no wording to send.`;let n=E(e);if(n.joined)return`A prompt line can't start with "+"; every line that fits is sent.`;if(n.when===`unreadable`)return`A line that opens with "when" needs a condition and a colon, like "when path is web: …".`;for(let e of n.when){if(e.path.includes(`.`))return`"${e.path}" isn't one condition or slot.`;if(e.expected===null)return`A condition always has a value, so "is null" never fits.`;let n=pe(e,t,`this profile’s conditions or slots`);if(n)return n}if(n.when.length>0&&!n.text&&e.length===1)return`It has no wording to send.`}function D(e,t,n){let r=pt(t,n);if(r)return r;let i=ft(t,n);for(let[t,n]of ut(e).entries()){let e=mt(n,i);if(e)return`Line ${t+1}: ${e}`}}function ht(e,t,n,r){let i=n.conditions??{};if(t===void 0){if(n.conditions)throw new p(`request`,`Profile ${e} declares no conditions`);return{...r}}if(Object.hasOwn(i,`path`))throw new p(`request`,`Profile ${e}: the turn's own path states path`);for(let n of Object.keys(i))if(!Object.hasOwn(t,n))throw new p(`request`,`Profile ${e} has no condition '${n}'`);let a={...r};for(let[r,o]of Object.entries(t)){let t=r===`path`?n.path:i[r];if(t===void 0)throw new p(`request`,`Profile ${e}: the turn left condition '${r}' unset`);if(!o.includes(t))throw new p(`request`,`Profile ${e}: '${t}' is no value of condition '${r}'`);a[r]=t}return a}function gt(e,t){return e.when!==`unreadable`&&e.when.every(e=>ee(e,t))}function _t(e,t,n){let r=ut(e),i=r.flat().some(e=>typeof e!=`string`),a=[];for(let[e,o]of r.entries()){let r=E(o);if(!gt(r,t))continue;let s=[];for(let[e,t]of o.entries()){let a=n(e===0?r.text:dt(t));a&&s.push({text:a,private:typeof t!=`string`||!i})}a.push({line:e+1,pieces:s})}return a}function vt(e,t){if(typeof e!=`string`){if(!Array.isArray(e))throw new p(`config`,`${t} must be a string or an array of lines`);if(e.length===0)throw new p(`config`,`${t} must not be an empty array`);for(let[n,r]of e.entries())if(typeof r!=`string`){if(!Array.isArray(r))throw new p(`config`,`${t}[${n}] must be a string or a list of parts; put { private } inside the list`);tt(r,`${t}[${n}]`)}}}function yt(e,t){let n=e?.path;if(n)for(let e of t){let t=e.paths?.find(e=>e!==`*`&&!n.includes(e));if(t!==void 0)return`Tool ${e.name} lists path "${t}", which is not one of ${n.join(`, `)}.`}}function O(e,t){let n=e.get(t);return n!==void 0&&n.type!==`builtin`}function k(e,t){return!e||e.includes(`*`)?!0:t?e.includes(t):!1}function bt(e,t){return t.filter(n=>{let r=e.get(n);return r?.type!==`builtin`||!(r.conflictsWith??[]).some(e=>t.includes(e))})}function A(e){return`tools`in e?e.tools.allow:[]}function j(e){return e.type===`text`||e.type===`image`?e.tools:void 0}function xt(e){return`tools`in e?e.tools.parallel:void 0}function St(e,t,n){return A(t).filter(r=>{let i=e.get(r);return!i||i.type===`builtin`?!1:t.type===`host`||k(i.paths,n.path)})}function Ct(e,t,n,r){let i=t.models[r];return i?(i.builtInTools??[]).filter(t=>{let r=e.get(t);return r?.type===`builtin`&&k(r.paths,n.path)}):[]}function M(e,t){let n=e.get(t);if(n&&n.type!==`builtin`)return{type:`function`,name:n.name,description:n.description,parameters:n.inputSchema}}function wt(e,t){let n=[];for(let r of t){let t=M(e,r);t&&n.push(t)}return n}function N(e,t,n){if(t.visible.includes(n))return;t.visible.push(n);let r=M(e,n);r&&!t.wire.some(e=>e.name===n)&&t.wire.push(r)}function Tt(e,t,n){if(t.builtins.includes(n))return;let r=e.get(n);if(r?.type!==`builtin`)return;let i=r.conflictsWith??[];t.builtins=t.builtins.filter(t=>{if(i.includes(t))return!1;let r=e.get(t);return!(r?.type===`builtin`&&r.conflictsWith?.includes(n))}),t.builtins.push(n)}function Et(e,t,n){return t.type===`live`||t.type===`host`?[...n]:n.filter(t=>e.get(t)?.loadTier===`T0`)}function Dt(e,t,n){return bt(e,n.filter(n=>{let r=e.get(n);return r?.type===`builtin`&&(t.type===`live`||r.loadTier===`T0`)}))}function Ot(e,t){if(t.type!==`text`&&t.type!==`image`&&t.type!==`live`)return;let n=A(t).flatMap(t=>e.get(t)??[]),r=yt(t.identity.conditions,n);if(r)throw new p(`config`,`Profile ${t.id}: ${r}`)}function P(e,t,n,r){Ot(e,t);let i=St(e,t,n),a=t.type===`host`||t.type===`decision`||t.type===`embedding`||r===void 0?[]:Ct(e,t,n,r),o=[...i,...a],s=Dt(e,t,o),c=Et(e,t,o);return{builtins:s,gated:o,visible:c,executable:c.filter(t=>O(e,t)),path:n.path,sessionPermissions:n.sessionPermissions,wire:wt(e,c)}}async function kt(e,t,n,r){let i=P(e,t,n,r);return await F(e,i,t,n),i}function At(e){return{builtins:[...e.builtins],gated:[...e.gated],visible:[...e.visible],executable:[...e.executable],path:e.path,sessionPermissions:e.sessionPermissions?[...e.sessionPermissions]:void 0,wire:e.wire.map(e=>({...e,parameters:structuredClone(e.parameters)}))}}async function F(e,t,n,r){let i=j(n)?.t1Policy;if(!i)return;let a;try{a=await i({profile:n,input:r.input,path:r.path,sessionPermissions:r.sessionPermissions,gated:t.gated,host:r.host})}catch(e){let t=e instanceof Error?e.message:String(e);throw new p(`config`,`Profile '${n.id}' tools.t1Policy rejected: ${t}`,{cause:e})}if(!Array.isArray(a))throw new p(`config`,`Profile '${n.id}' tools.t1Policy must return ToolId[]`);for(let n of a){if(!t.gated.includes(n))continue;let r=e.get(n);r?.loadTier===`T2`&&(r.type===`builtin`?Tt(e,t,n):N(e,t,n))}t.executable=t.visible.filter(t=>O(e,t))}var jt=new Set([`__proto__`,`constructor`,`prototype`]);function Mt(e){if(!he(e))return;let{loaded:t}=e;if(Array.isArray(t)&&t.every(e=>typeof e==`string`))return t}function Nt(e,t,n,r){if(r.type===`live`||r.type===`host`)return{promoted:[]};let i=[];for(let a of n){if(typeof a!=`string`||jt.has(a))return{promoted:[],failure:{code:`invalid_output`,kind:`bad_response`,message:`tools.t2Loader loaded ids must be plain strings`}};let n=Pt(e,a,r);if(`failure`in n)return{promoted:[],failure:n.failure};let{tool:o}=n;k(o.paths,t.path)&&t.gated.includes(a)&&i.push(a)}let a=[];for(let n of i)N(e,t,n),a.push(n);return t.executable=t.visible.filter(t=>O(e,t)),{promoted:a}}function I(e){return{failure:{code:`invalid_output`,kind:`bad_response`,message:e}}}function Pt(e,t,n){if(!A(n).includes(t))return I(`tools.t2Loader attempted to promote tool '${t}' outside profile allow`);let r=e.get(t);return r?r.type===`builtin`?I(`tools.t2Loader attempted to promote builtin '${t}' — only custom tools may be promoted`):r.loadTier===`T2`?{tool:r}:I(`tools.t2Loader attempted to promote tool '${t}' with loadTier '${r.loadTier}' — only T2 tools may be promoted`):I(`tools.t2Loader attempted to promote unknown tool '${t}'`)}function L(e){return Array.isArray(e)?[...e]:e.choices.map(e=>e.value)}function Ft(e){return Array.isArray(e)?{choices:e.map(e=>({value:e}))}:{...e.label!==void 0&&e.label!==``?{label:e.label}:{},choices:e.choices.map(e=>({value:e.value,...e.description!==void 0&&e.description!==``?{description:e.description}:{}}))}}function R(e){if(e)return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,Ft(t)]))}function z(e){return e?.slots?{...e,slots:R(e.slots)}:e}function B(e){return e==null}function V(e){return B(e)||typeof e!=`object`||Array.isArray(e)?null:e}function H(e){let t=V(e);return!t||t.type!==void 0&&t.type!==`object`?null:t}function U(e){let t=e.required;return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}function W(e){let t=e.properties;return V(t)??{}}function It(e,t){return e?`${e}.${t}`:t}function G(e,t){t.push({path:e,error:`required field '${e}' is missing`})}async function Lt(e,t,n,r,i){if(!n)return;let a=await n(t,r);a.isValid||i.push({path:e,error:a.error||a.finding||`Validation failed for '${e}'`})}async function Rt(e){let{path:t,propSchema:n,child:r,isRequired:i,fields:a,slots:o,failures:s}=e;if(B(r)){i&&G(t,s);return}await Lt(t,r,a?.[t],o,s);let c=H(n),l=c?V(r):null;c&&l&&await zt(c,l,t,a,o,s)}async function zt(e,t,n,r,i,a){let o=W(e),s=new Set(U(e)),c=new Set([...Object.keys(o),...s]),l=V(t);for(let e of c)await Rt({path:It(n,e),propSchema:o[e],child:l?.[e],isRequired:s.has(e),fields:r,slots:i,failures:a})}async function Bt(e,t,n,r){let i=H(e);if(!i)throw new p(`config`,`structured validation requires a JSON Schema object root`);let a=[];if(!V(t)){for(let e of U(i))G(e,a);return a}return await zt(i,t,``,n,r,a),a}function Vt(e,t){let n=e;for(let e of t.split(`.`)){let t=H(n);if(!t)return!1;let r=W(t);if(!Object.hasOwn(r,e)&&!U(t).includes(e))return!1;n=r[e]}return!0}function Ht(e){return e.map(e=>e.error).join(`; `)}function Ut(e,t){let n=e;for(let e of t.split(`.`))n=V(n)?.[e];return n}function Wt(e,t,n){let[r,...i]=t.split(`.`),a=V(e)??{};return r===void 0?e:{...a,[r]:i.length?Wt(a[r],i.join(`.`),n):n}}async function Gt(e,t,n){let r=[];for(let[i,a]of Object.entries(t??{})){let t=Ut(e,i);if(Array.isArray(t))for(let[e,o]of t.entries()){let t=await a.check(o,n);t.isValid||r.push({path:i,index:e,item:o,reason:t.error||t.finding||`Validation failed for '${i}'`,onFail:a.onFail})}}return r}function Kt(e,t){let n=e;for(let e of t.split(`.`)){let t=H(n);if(!t)return;n=W(t)[e]}let r=V(n);if(r?.type===`array`)return V(r.items)??void 0}var qt=class extends Error{failure;constructor(e){super(e.message),this.failure=e}},Jt=new Set([`text`,`image`,`speech`]),Yt=n().regex(/\S/),Xt=i({mimeType:n(),data:c(),name:n().optional()}),Zt=i({mimeType:n(),uri:n(),name:n().optional()}),Qt=i({voice:n().optional(),style:n().optional(),speed:a().positive().optional()});function $t(e){return i(Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=L(t);return[e,o(n).optional()]})))}var en=new Set([`text`,`attachments`,`voice`,`slots`,`speech`]);function tn(e,t){if(!e.hostFields)return{sent:t};let n={...t},r={};for(let t of Object.keys(e.hostFields))n[t]!==void 0&&(r[t]=n[t]);let{text:i,attachments:a,voice:o,slots:s,speech:c}=t;return{sent:{text:i,...a?{attachments:a}:{},...o?{voice:o}:{},...s?{slots:s}:{},...c?{speech:c}:{}},hostInput:r}}function nn(e,n){let{inputs:r}=e,a={text:Yt};r?.attachments&&(a.attachments=s(t([Xt,Zt])).optional()),r?.voice&&(a.voice=s(Xt).optional()),r?.slots&&(a.slots=$t(r.slots).optional()),e.type===`speech`&&(a.speech=Qt.optional());for(let e of n?.hostOnly??[]){if(!a[e])throw new p(`config`,`Tool '${n?.name}' keeps '${e}' for the host, which its profile does not take`);delete a[e]}for(let[e,t]of Object.entries(n?.fieldText??{})){let r=a[e];if(!r)throw new p(`config`,`Tool '${n?.name}' describes '${e}', which its profile does not take`);a[e]=r.describe(t)}for(let[e,t]of Object.entries(n?.hostFields??{})){if(en.has(e))throw new p(`config`,`Tool '${n?.name}' declares the host field '${e}', which is a field of every agent tool`);a[e]=t}return i(a)}var rn=l({text:n().optional(),structured:r().optional(),removed:s(l({path:n(),reason:n(),item:r()})).optional(),parts:s(me).optional(),sources:s(oe).optional()});function an(e){return e.type===`speech`||(e.type===`text`||e.type===`image`)&&e.inputs.text!==!1}function on(e){return e.type===`builtin`?!1:e.permission!==`auto`||`auth`in e&&e.auth!==void 0&&(e.auth.onUnauthenticated??`gate`)===`gate`}function sn(e,t){if(!Jt.has(e.type))return`it is a ${e.type} profile; an agent tool runs a text, image, or speech profile`;if(!an(e))return`it does not take text`;for(let n of A(e)){let e=t(n);if(!e)return`its tool '${n}' is not registered; register it first`;if(on(e))return`its tool '${n}' can stop on a gate; give it permission 'auto' and no sign-in`}}function cn(e,t,n){let r=`Agent tool "${e.name}"`,i=e.maxCallsPerTurn;if(i!==void 0&&!(Number.isInteger(i)&&i>0))throw new p(`config`,`${r}: maxCallsPerTurn must be a whole number above 0`);let a=t(e.profile);if(!a)throw new p(`config`,`${r}: profile '${e.profile}' must be registered before the tool`);let o=sn(a,n);if(o)throw new p(`config`,`${r} can't run '${e.profile}': ${o}`);return a}function ln(e){if(!e)return`delegated`;let t=`models`in e&&Object.values(e.models).some(e=>(e.builtInTools?.length??0)>0);return A(e).length===0&&!t?`local`:`delegated`}function un(e){let t=se(e),n=t.flatMap(e=>e.type===`text`?[e.text]:[]).join(``),r=re(t,e=>e.type===`structured`),i=r?.structured,a=t.flatMap(e=>e.type===`media`?[{type:e.media.mimeType.startsWith(`audio/`)?`audio`:`image`,mimeType:e.media.mimeType,data:e.media.data}]:[]),o=t.flatMap(e=>e.type===`citation`?e.sources:[]);return{...i===void 0?{text:n}:{structured:i},...r?.removed?.length?{removed:r.removed}:{},...a.length>0?{parts:a}:{},...o.length>0?{sources:o}:{}}}function dn(e,t,n){return{...e,type:`agent`,input:t,output:rn,sources:e=>e.sources??[],...n}}function fn(e,t,n){if(!e||typeof e!=`object`||Array.isArray(e))return n.push(`${t}: schema must be an object`),!1;let r=typeof e.type==`string`||Array.isArray(e.type),i=e.anyOf!==void 0||e.oneOf!==void 0;if(!r&&!i){if(t!==`$`)return!0;n.push(`${t}: missing type or combinator`)}return e.type===`array`&&e.items===void 0&&n.push(`${t}: array schema must define items`),!0}function pn(e,t,n,r){let i=Array.isArray(t)?t:[];for(let t of i)typeof t==`string`&&!Object.hasOwn(e,t)&&r.push(`${n}: required key '${t}' missing from properties`);for(let[t,i]of Object.entries(e))i&&typeof i==`object`&&K(i,`${n}.properties.${t}`,r)}function K(e,t,n){if(!fn(e,t,n))return;let r=e.properties;r&&typeof r==`object`&&!Array.isArray(r)&&pn(r,e.required,t,n),e.items&&typeof e.items==`object`&&!Array.isArray(e.items)&&K(e.items,`${t}.items`,n);for(let r of[`anyOf`,`oneOf`]){let i=e[r];Array.isArray(i)&&i.forEach((e,i)=>{e&&typeof e==`object`&&K(e,`${t}.${r}[${i}]`,n)})}}function mn(e,t){let n=[];if(K(e,`$`,n),n.length>0)throw new p(`config`,`Invalid tool ${t} schema: ${n.join(`; `)}`)}function hn(t,n=`output`){let r=e(t,{target:`draft-7`,io:n});return delete r.$schema,r.type||=`object`,r}function q(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(q);let t={};for(let n of Object.keys(e))n!==`__proto__`&&n!==`constructor`&&n!==`prototype`&&(t[n]=q(e[n]));return t}function gn(e){let t=/^[a-z][a-z0-9+.-]*:\/\/[^/?#]*/i.exec(e)?.[0];if(!t||/[{}]/.test(t))throw new p(`config`,`Endpoint "${e}" must start with a fixed scheme and host; placeholders belong in the path or query`)}function _n(e,t,n,r){if(!n.provider?.trim()||!n.apiId?.trim())throw new p(`config`,m(`provider.binding_identity`))}function vn(e){J(e.id,e.models),Q(e.id,e.observability),pr(e.id,e.inputs);for(let[t,n]of Object.entries(e.models))Y(e.id,t,n);return{type:`embedding`,id:e.id,identity:{handle:e.identity.handle},models:e.models,defaultModel:On(e.id,e),allowModelSelect:e.allowModelSelect,inputs:e.inputs,guardrails:e.guardrails,observability:e.observability,labels:e.labels}}function yn(e){J(e.id,e.models),Hn(e.id,e.guardrails),Q(e.id,e.observability);for(let[t,n]of Object.entries(e.models))Y(e.id,t,n);if(`text`in e.inputs&&e.inputs.text!==!1)throw new p(`config`,`Profile ${e.id}: a transcription takes a voice clip, so inputs.text must be false`);return{type:`transcription`,id:e.id,identity:{handle:e.identity.handle},...An(e),providerContinuation:void 0,maxSteps:void 0,inputs:{...e.inputs,text:!1},guardrails:e.guardrails,observability:e.observability,labels:e.labels}}function bn(e,t,n,r){let i=r.safeParse(n);if(!i.success)throw new p(`config`,`Profile ${e} model '${t}': ${i.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`; `)}`)}function xn(e,t,n){if(bn(e,t,n,fe),_n(e,t,n,`decision`),`retry`in n)throw new p(`config`,`Profile ${e} model '${t}': a decision binding takes no retry; a decision retries only a transient failure, by the kernel's rule`);if(n.timeoutMs!==void 0&&(!Number.isFinite(n.timeoutMs)||n.timeoutMs<=0))throw new p(`config`,`Profile ${e} model '${t}' timeoutMs must be > 0`)}function Sn(e){let t=e.models?T(e.models):void 0;if(!t)throw new p(`config`,`Profile ${e.id}: type 'decision' must declare exactly one model`);xn(e.id,t,e.models[t])}function Cn(e){if(e.inputs.state!==`json`)throw new p(`config`,`Profile ${e.id}: decision inputs.state must be 'json'`);let t=e.inputs.maxStateBytes;if(t!==void 0&&!(Number.isInteger(t)&&t>0))throw new p(`config`,`Profile ${e.id}: decision inputs.maxStateBytes must be a positive integer`);if(!e.decision.contract.trim())throw new p(`config`,`Profile ${e.id}: decision.contract must be non-empty`)}function wn(e){return Sn(e),Cn(e),Q(e.id,e.observability),{...e,identity:{handle:e.identity.handle}}}function Tn(e){return e===void 0?{}:{parallel:e}}function En(e){return Dn(e.id,e.tools),Q(e.id,e.observability),{type:`host`,id:e.id,tools:{allow:e.tools.allow,...Tn(e.tools.parallel)},guardrails:e.guardrails,observability:e.observability,labels:e.labels}}function Dn(e,t){if(!Array.isArray(t.allow))throw new p(`config`,`Profile ${e}: type 'host' must set tools.allow`)}function J(e,t){if(Object.keys(t).length===0)throw new p(`config`,`Profile ${e} must declare at least one model`)}function On(e,t){let n=t.defaultModel??T(t.models);if(!n)throw new p(`config`,`Profile ${e} must set defaultModel when more than one model is declared`);if(!t.models[n])throw new p(`config`,`Profile ${e} defaultModel '${n}' is not declared`);return n}function Y(e,t,n){kn(e,t,n),bn(e,t,n,le),kn(e,t,n)}function kn(e,t,n){let r=n.efforts;if(!r||Object.keys(r).length===0){if(n.defaultEffort||n.allowEffortSelect)throw new p(`config`,`Profile ${e} model '${t}': defaultEffort and allowEffortSelect require efforts`);return}for(let[n,i]of Object.entries(r))if(!y.includes(i))throw new p(`config`,`Profile ${e} model '${t}' effort '${n}': '${i}' is not a thinking level (${y.join(`, `)})`);let i=Object.keys(r),a=n.defaultEffort??(i.length===1?i[0]:void 0);if(!a)throw new p(`config`,`Profile ${e} model '${t}' must set defaultEffort when more than one effort is declared`);if(!r[a])throw new p(`config`,`Profile ${e} model '${t}' defaultEffort '${a}' is not declared`);if(n.allowEffortSelect&&i.length<2)throw new p(`config`,`Profile ${e} model '${t}' allowEffortSelect requires at least two efforts`)}function An(e){return{providerContinuation:e.providerContinuation?ie.parse(e.providerContinuation):{},models:e.models,defaultModel:On(e.id,e),allowModelSelect:e.allowModelSelect,maxSteps:e.maxSteps}}function jn(e,t,n){if(n?.length){for(let r of n)if(!de(r))throw new p(`config`,`Profile ${e}: turnBehaviour.resumption.${t} may only include ContinueStopKind (length | stream_incomplete | provider_error); got '${r}'`)}}function Mn(e,t){t&&(jn(e,`allowContinue`,t.allowContinue),jn(e,`autoContinue`,t.autoContinue))}function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Nn(e,t){let n=[e];for(let e of t)n=n.flatMap(t=>X(t)?e===`*`?Object.values(t):[t[e]]:[]);return n}var Pn=Object.entries(Se).filter(([,e])=>e.required===!0).map(([e,t])=>[e,t.profileTypes]).sort(([e],[t])=>e.split(`.`).length-t.split(`.`).length);function Fn(e){if(!X(e))throw new p(`config`,`Profile definition must be an object`);let t=typeof e.id==`string`&&e.id.trim()?e.id:void 0;if(!t)throw new p(`config`,`Profile definition must set id`);if(!_.find(t=>t===e.type))throw new p(`config`,`Profile ${t}: type must be one of ${_.join(`, `)}`)}function In(e){let t=e.identity?.handle,n=[[`id`,e.id,64],[`identity.handle`,typeof t==`string`?t:``,32]];for(let[t,r,i]of n)if(!(Array.from(r).length<=i))throw new p(`config`,`Profile ${e.id.slice(0,64)}: ${t} must be at most ${i} characters`)}function Ln(e){let{id:t,type:n}=e,r=e;for(let[e,i]of Pn){if(i&&!i.includes(n))continue;let a=ge(e),o=Nn(r,a.slice(0,-1)),s=a[a.length-1];if(o.some(e=>{if(!X(e))return!1;let t=e[s];return t==null||t===``}))throw new p(`config`,`Profile ${t}: type '${n}' must set ${a.join(`.`)}`)}}function Rn(e){let{id:t,type:n}=e;if(n!==`live`&&_e(`inputs`).includes(n)&&e.inputs==null)throw new p(`config`,`Profile ${t}: type '${n}' must set inputs`)}function zn(e){let[t]=Ce(e);if(!t)return;let{offValue:n,reason:r}=t.scope,i=n===void 0?``:` (other than ${n})`;throw new p(`config`,`Profile ${e.id}: type '${e.type}' must not set ${t.path}${i} — ${r}`)}function Bn(e,t){let n=t.turnBehaviour;Mn(e,n?.resumption)}function Vn(e,t){let n=t=>new p(`config`,`Profile ${e}: ${t}`),r=t?.maxRetries;if(r!==void 0&&(!Number.isInteger(r)||r<0))throw n(`outputs.validation.maxRetries must be a non-negative integer`)}function Hn(e,t){let n=t=>new p(`config`,`Profile ${e}: ${t}`),r=Object.keys(t??{}).find(e=>!Z.includes(e));if(r!==void 0)throw n(`guardrails.${r} is not a setting; it takes ${Z.join(`, `)}`);Wn(t?.blockedReply,n)}var Z=[`quota`,`detect`,`blockedReply`,`network`,`taint`],Un=[`onBlock`,`maxRetries`];function Wn(e,t){if(e===void 0)return;let n=Object.keys(e).find(e=>!Un.includes(e));if(n!==void 0)throw t(`guardrails.blockedReply.${n} is not a setting; it takes onBlock and maxRetries`);let{onBlock:r,maxRetries:i}=e;if(r!==void 0&&!g.includes(r))throw t(`guardrails.blockedReply.onBlock must be one of ${g.join(`, `)}`);if(i!==void 0&&(!Number.isInteger(i)||i<0))throw t(`guardrails.blockedReply.maxRetries must be a non-negative integer`)}function Gn(e){let t=e.guardrails?.detect,n=e.type===`host`?h(`guardrails.detect`,t,Te):h(`guardrails.detect`,t);if(n!==void 0)throw new p(`config`,`Profile ${e.id}: ${n}`)}function Q(e,t){try{let n=De(t);if(!Number.isFinite(n.retainForDays))throw new p(`config`,`Profile ${e}: observability.retainForDays must be a finite number`);if(n.rotateAfterMiB<=0||!Number.isFinite(n.rotateAfterMiB))throw new p(`config`,`Profile ${e}: observability.rotateAfterMiB must be a positive number`)}catch(t){if(t instanceof p&&t.message.startsWith(`Profile `))throw t;let n=t instanceof Error?t.message:String(t);throw new p(Ee(t),`Profile ${e}: ${n}`,{cause:t})}}function Kn(e){if(e.type===`host`||e.type===`decision`||e.type===`speech`||e.type===`transcription`||e.type===`embedding`)return;let{conditions:t,system:n}=e.identity,r={};for(let[t,n]of Object.entries(z(e.inputs)?.slots??{}))r[t]=L(n);let i=n??``;vt(i,`Profile ${e.id} identity.system`);let a=D(i,t,r);if(a)throw new p(`config`,`Profile ${e.id} identity.system: ${a}`)}function qn(e){Fn(e);for(let t of[`key`,`fallbackKey`,`protocol`,`provider`])if(t in e)throw new p(`config`,m(`provider.profile_configuration`,{profile:e.id,field:t}));zn(e),Rn(e),Ln(e),In(e),e.labels&&ye(e.labels,`Profile ${e.id}`);for(let t of ve)if(e.labels?.[t]!==void 0)throw new p(`config`,`Profile ${e.id}: labels '${t}' is a host line, which a profile cannot change; set it with overrideLabels`);if(Kn(e),Gn(e),e.type===`host`)return En(e);if(e.type===`decision`)return wn(e);if(e.type===`embedding`)return vn(e);if(e.type===`transcription`)return yn(e);J(e.id,e.models),Bn(e.id,e),Hn(e.id,e.guardrails),e.type===`text`&&Vn(e.id,e.outputs?.validation),Q(e.id,e.observability);for(let[t,n]of Object.entries(e.models))Y(e.id,t,n);let t=e.type===`speech`?{handle:e.identity.handle}:{handle:e.identity.handle,conditions:e.identity.conditions,system:e.identity.system},n=e.guardrails,r=e.observability,i=e.labels,a=An(e),o;switch(e.type){case`text`:o={type:`text`,id:e.id,identity:t,...a,tools:e.tools,inputs:z(e.inputs),outputs:e.outputs,turnBehaviour:e.turnBehaviour,guardrails:n,observability:r,labels:i};break;case`image`:o={type:`image`,id:e.id,identity:t,...a,image:e.image,tools:e.tools,inputs:z(e.inputs),outputs:e.outputs,turnBehaviour:e.turnBehaviour,guardrails:n,observability:r,labels:i},$n(o.id,o.inputs.attachments?.accept),Qn(o.id,o.image);break;case`speech`:o={type:`speech`,id:e.id,identity:t,...a,speech:e.speech,outputs:e.outputs,turnBehaviour:e.turnBehaviour,guardrails:n,observability:r,labels:i};break;case`live`:o={type:`live`,id:e.id,identity:t,...a,live:e.live,inputs:e.inputs?z(e.inputs):e.inputs,tools:{allow:e.tools.allow,...Tn(e.tools.parallel)},turnBehaviour:e.turnBehaviour,guardrails:n,observability:r,labels:i},Oe(o),tr(o.id,o.live.contextCompression),er(o);break;default:throw new p(`config`,`Unknown profile type '${String(e)}'`)}return Xn(o),Jn(o),Yn(o),o}function Jn(e){let{maxSteps:t}=e;if(!(t===void 0||Number.isInteger(t)&&t>0))throw new p(`config`,`Profile ${e.id}: maxSteps must be a whole number of 1 or more; leave it out for the default of 20`)}function Yn(e){if(e.type===`text`&&e.turnBehaviour?.atStepLimit===`answer`&&e.maxSteps===1)throw new p(`config`,`Profile ${e.id}: turnBehaviour.atStepLimit 'answer' with maxSteps 1 leaves no step that can call a tool`)}function Xn(e){if(e.type===`live`)return;let t=e.outputs?.structured;if(!t||typeof t==`string`)return;let n=u(e)?.slots?.[t.by];if(!n)throw new p(`config`,`Profile ${e.id}: outputs.structured.by '${t.by}' is not a slot in inputs.slots`);let r=L(n),i=Object.keys(t.map).filter(e=>!r.includes(e));if(i.length)throw new p(`config`,`Profile ${e.id}: outputs.structured.map maps ${i.join(`, `)}, not a choice of slot '${t.by}'`)}var Zn={n:{ok:e=>Number.isInteger(e)&&e>=1,rule:`a whole number of 1 or more`},seed:{ok:Number.isInteger,rule:`a whole number`},outputCompression:{ok:e=>Number.isInteger(e)&&e>=0&&e<=100,rule:`a whole number from 0 to 100`}};function Qn(e,t){for(let[n,{ok:r,rule:i}]of Object.entries(Zn)){let a=t[n];if(a!==void 0&&!r(a))throw new p(`config`,`Profile ${e}: image.${n} must be ${i}`)}t.references?.forEach((t,n)=>{let r=`Profile ${e}: image.references[${n}]`;if(ce(t.mimeType)!==`image`)throw new p(`config`,`${r} must be an image, not '${t.mimeType}'`);if(!(x(t)?t.uri:t.data))throw new p(`config`,`${r} needs its bytes or its uri`)})}function $n(e,t){let n=t?.filter(e=>!d(be,e));if(n?.length)throw new p(`config`,`Profile ${e}: an image profile's attachments take images, video, and PDF only, not ${n.join(`, `)}`)}function er(e){let{greeting:t,resumed:n,sessionResumption:r}=e.live,i=`Profile ${e.id} live`;if(t!==void 0&&(typeof t!=`string`||!t.trim()))throw new p(`config`,`${i}.greeting must be a prompt; leave it out to wait`);if(!n)return;if(typeof n.prompt!=`string`||!n.prompt.trim())throw new p(`config`,`${i}.resumed.prompt must be a prompt`);let{afterMs:a}=n;if(a!==void 0&&!(Number.isFinite(a)&&a>=0))throw new p(`config`,`${i}.resumed.afterMs must be 0 or more milliseconds`);if(!r)throw new p(`config`,`${i}.resumed needs live.sessionResumption: without it no call resumes`)}function tr(e,t){if(!t)return;let n=`Profile ${e} live.contextCompression`,r=t.triggerTokens,i=t.slidingWindow.targetTokens;if(nr(`${n}.triggerTokens`,r),nr(`${n}.slidingWindow.targetTokens`,i),r!==void 0&&i!==void 0&&i>=r)throw new p(`config`,`${n}: slidingWindow.targetTokens must be below triggerTokens`)}function nr(e,t){if(!(t===void 0||Number.isInteger(t)&&t>0))throw new p(`config`,`${e} must be a whole number above 0`)}function rr(e,t,n,r){let i=`Profile ${t.id} model ${n} compaction`;if(ir(i,r),ar(i,r),r.meter!=null&&r.meter!==`history`&&r.meter!==`input`)throw new p(`config`,`${i}: meter must be 'history' or 'input'`);if(r.profile===void 0){if(t.type!==`text`||t.inputs.text===!1)throw new p(`config`,`${i}: a profile that compacts itself must be a text profile that takes text`);return}let a=e.get(r.profile);if(!a)throw new p(`config`,`${i}: compaction profile '${r.profile}' must be registered before '${t.id}'`);if(a.type!==`text`||a.inputs.text===!1)throw new p(`config`,`${i}: compaction profile '${r.profile}' must be a text profile that takes text`)}function ir(e,t){if(t.maxTokens<=0)throw new p(`config`,`${e}: maxTokens must be > 0`);if(t.compactAt<=0||t.compactAt>=1)throw new p(`config`,`${e}: compactAt must be in (0, 1)`)}function ar(e,t){if(t.previousExchanges<0)throw new p(`config`,`${e}: previousExchanges must be >= 0`);if(t.previousExchanges<1&&t.previousExchanges>=t.compactAt)throw new p(`config`,`${e}: previousExchanges as fraction (${t.previousExchanges}) must be < compactAt (${t.compactAt})`);if(t.previousExchanges>1&&!Number.isInteger(t.previousExchanges))throw new p(`config`,`${e}: previousExchanges >= 1 must be an integer`)}function or(e,t){for(let n of A(t))if(e.get(n)?.type===`builtin`)throw new p(`config`,t.type===`host`?`Profile ${t.id} lists builtin '${n}' in tools.allow — type 'host' never runs a model`:`Profile ${t.id} lists builtin '${n}' in tools.allow — declare it on models.*.builtInTools instead`)}function sr(e,t){let n=j(t)?.t2Loader;if(n){if(!A(t).includes(n))throw new p(`config`,`Profile ${t.id} tools.t2Loader '${n}' must also be listed in tools.allow`);if(e.get(n)?.type!==`function`)throw new p(`config`,`Profile ${t.id} tools.t2Loader '${n}' must be a registered type: 'function' tool`)}}function*cr(e){for(let[t,n]of Object.entries(e.models))for(let e of n.builtInTools??[])yield{modelId:t,id:e}}function lr(e,t){for(let{modelId:n,id:r}of cr(t))if(e.get(r)?.type!==`builtin`)throw new p(`config`,`Profile ${t.id} model '${n}' lists '${r}' in builtInTools — not a registered builtin`)}function ur(e){let t=e.type===`text`?e.outputs?.structured:void 0;return t?typeof t==`string`?[t]:[...new Set([...Object.values(t.map),t.fallback])]:[]}function dr(e,t){let n=ur(t).map(n=>{let r=e.find(n);if(!r)throw new p(`config`,`Profile ${t.id}: outputs.structured names '${n}', which is not a registered schema; register it before the profile`);return r}),r=t.type===`text`?t.outputs?.validation:void 0,i=Object.keys(r?.fields??{}),a=Object.keys(r?.items??{});if(!i.length&&!a.length)return;if(!n.length)throw new p(`config`,`Profile ${t.id}: outputs.validation checks a structured reply, so it needs outputs.structured`);let o=a.filter(e=>!n.some(t=>Kt(t.jsonSchema,e)));if(o.length)throw new p(`config`,`Profile ${t.id}: outputs.validation.items has ${o.join(`, `)}, which no structured schema reaches as a list with an items schema`);let s=i.filter(e=>!n.some(t=>Vt(t.jsonSchema,e)));if(s.length)throw new p(`config`,`Profile ${t.id}: outputs.validation.fields has ${s.join(`, `)}, which no structured schema reaches through object properties`)}function fr(e){let t=u(e)?.context;if(!t)return;let n=v;if(t.from.length===0||t.from.some(e=>!n.includes(e)))throw new p(`config`,`Profile ${e.id}: inputs.context.from must list ${v.join(` or `)}`);if(!(Number.isInteger(t.maxChars)&&t.maxChars>0))throw new p(`config`,`Profile ${e.id}: inputs.context.maxChars must be a positive integer`)}function pr(e,t){if(!t)return;let{attachments:n,voice:r,maxFiles:i,maxBytes:a,maxTurnBytes:o,limitsByMime:s}=t,c={maxFiles:i,maxBytes:a,maxTurnBytes:o};if((n||r)&&Object.values(c).some(e=>e===void 0))throw new p(`config`,`Profile ${e} must set maxFiles, maxBytes, and maxTurnBytes`);for(let[e,t]of Object.entries(s??{}))c[`limitsByMime['${e}']`]=t;for(let[t,n]of Object.entries(c))if(n!==void 0&&!(Number.isInteger(n)&&n>0))throw new p(`config`,`Profile ${e}: inputs.${t} must be a positive integer`)}function mr(e,t,n){let r=new Map,i=i=>{let a=qn(i),o=n&&a.type!==`host`?{...a,models:Object.fromEntries(Object.entries(a.models).map(([e,t])=>[e,ue(n.require(t.provider,t.apiId),t,a.type)]))}:a;if(or(e,o),sr(e,o),o.type!==`host`&&o.type!==`decision`&&o.type!==`embedding`){lr(e,o),pr(o.id,u(o)),fr(o),dr(t,o);for(let[e,t]of Object.entries(o.models))t.compaction&&rr(r,o,e,t.compaction)}r.set(o.id,o)};return{register:i,registerMany(e){for(let t of e)i(t)},get(e){let t=r.get(e);if(!t)throw new p(`config`,`Unknown profile '${e}'`);return t},find:e=>r.get(e),has:e=>r.has(e),list:()=>[...r.values()],clear:()=>r.clear()}}function hr(e){let t=e?.trim()??``;if(t.startsWith(`AIza`))return`gemini`;if(t.startsWith(`sk-or-`))return`openrouter`}function gr(e){let t;try{t=new URL(e.baseUrl)}catch{throw new p(`config`,`Enter a valid localhost URL.`)}if(![`http:`,`https:`].includes(t.protocol)||![`localhost`,`127.0.0.1`,`[::1]`].includes(t.hostname)||t.username||t.password||t.search||t.hash)throw new p(`config`,`Use a localhost URL without credentials, query parameters or a fragment.`);return{baseUrl:t.href.replace(/\/$/,``),fetch:(e,n)=>new URL(e instanceof Request?e.url:String(e)).origin===t.origin?fetch(e,{...n,redirect:`error`,credentials:`omit`}):Promise.reject(new p(`blocked`,`Local requests must stay on the configured origin.`))}}var _r=l({data:s(l({id:n().min(1)}))});async function vr(e,t){let n=gr(e);if(!n?.fetch)throw new p(`config`,`Enter a local endpoint.`);let r=await n.fetch(`${n.baseUrl}/v1/models`,{signal:t,headers:{Accept:`application/json`}});if(!r.ok)throw new p(`network`,`Local model list returned HTTP ${r.status}.`);let i=_r.safeParse(await r.json());if(!i.success)throw new p(`request`,`The endpoint returned an invalid model list.`);return[...new Set(i.data.data.map(e=>e.id))]}var yr=`https://openrouter.ai/api/v1/models`,br=`https://openrouter.ai/api/v1/embeddings/models`,xr=[{id:`gemini-embedding-2-preview`,label:`Gemini Embeddings 2 (preview)`},{id:`gemini-embedding-001`,label:`Gemini Embedding 001`}],Sr=[{id:`liquid/lfm-2.5-embedding-350m:free`,label:`Liquid LFM 2.5 Embedding 350M (free)`},{id:`nvidia/nemotron-3-embed-1b:free`,label:`NVIDIA Nemotron 3 Embed 1B (free)`},{id:`nvidia/llama-nemotron-embed-vl-1b-v2:free`,label:`NVIDIA Llama Nemotron Embed VL 1B v2 (free)`}],Cr={text:`text`,image:`image`,speech:`speech`,transcription:`transcription`,live:void 0,embedding:void 0},wr=l({data:s(l({id:n().min(1),name:n().optional(),architecture:l({output_modalities:s(n()).optional()}).optional()}))}),Tr=l({data:s(l({id:n().min(1),name:n().optional()}))}),Er=l({models:s(l({name:n().min(1),displayName:n().optional(),supportedGenerationMethods:s(n()).optional()})).optional(),nextPageToken:n().optional()}),Dr=5;async function $(e,t,n){let r=await fetch(t,{...n,redirect:`error`,credentials:`omit`});if(r.status===400||r.status===401||r.status===403)throw new p(`auth`,`${e} refused the key.`);if(!r.ok)throw new p(`network`,`${e} model list returned HTTP ${r.status}.`);return await r.json()}async function Or(e,t,n,r){let i=n?.trim();if(t===`embedding`&&!i)return[...e===`openrouter`?Sr:xr];if(e===`openrouter`)return await kr(t,i,r);if(!i)throw new p(`auth`,`Choose a key to list Gemini models.`);return await jr(t,i,r)}async function kr(e,t,n){let r={signal:n,headers:{Accept:`application/json`,...t?{Authorization:[`Bearer`,t].join(` `)}:{}}};if(e===`embedding`){let e=Tr.safeParse(await $(`OpenRouter`,br,r));if(!e.success)throw new p(`bad_response`,`OpenRouter returned an invalid embedding model list.`);return e.data.data.map(e=>({id:e.id,label:e.name??e.id}))}let i=Cr[e];if(!i)return[];let a=wr.safeParse(await $(`OpenRouter`,`${yr}?output_modalities=${i}`,r));if(!a.success)throw new p(`bad_response`,`OpenRouter returned an invalid model list.`);return a.data.data.filter(e=>e.architecture?.output_modalities?.includes(i)??!0).map(e=>({id:e.id,label:e.name??e.id}))}var Ar={live:`bidiGenerateContent`,embedding:`embedContent`};async function jr(e,t,n){let r=Ar[e]??`generateContent`,i=[],a;for(let e=0;e<Dr;e++){let e=new URL(ne);e.searchParams.set(`pageSize`,`1000`),a&&e.searchParams.set(`pageToken`,a);let o=Er.safeParse(await $(`Google`,e.href,{signal:n,headers:{Accept:`application/json`,"x-goog-api-key":t}}));if(!o.success)throw new p(`bad_response`,`Google returned an invalid model list.`);for(let e of o.data.models??[]){if(!e.supportedGenerationMethods?.includes(r))continue;let t=e.name.replace(/^models\//,``);i.push({id:t,label:e.displayName??t})}if(a=o.data.nextPageToken,!a)break}return i}function Mr(e){return[...new Set([e.key,e.fallbackKey,...Object.values(e.models??{}).flatMap(e=>[e.keySlot,e.fallbackKeySlot])].filter(e=>!!e))]}function Nr(e,t){return Object.fromEntries(e.map(e=>[e,Object.hasOwn(t,e)?t[e]:void 0]))}export{Ze as $,At as A,D as B,Bt as C,Wt as D,Ut as E,xt as F,nt as G,T as H,j as I,w as J,rt as K,Nt as L,Mt as M,kt as N,R as O,A as P,b as Q,P as R,Gt as S,Kt as T,st as U,ht as V,it as W,Ke as X,Ge as Y,x as Z,rn as _,Mr as a,dn as b,qn as c,q as d,mn as f,ln as g,nn as h,gr as i,F as j,L as k,gn as l,sn as m,vr as n,Nr as o,qt as p,We as q,Or as r,mr as s,hr as t,hn as u,un as v,Ht as w,tn as x,cn as y,_t as z};
|