@theoremjs/studio 0.3.4-next.871.gea9bbcc → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/README.md +1 -1
  2. package/cookbooks/catalog.d.ts +1 -1
  3. package/cookbooks/catalog.js +1 -1
  4. package/guardrail-bench.d.ts +186 -0
  5. package/guardrail-bench.js +66 -0
  6. package/guardrail-probe.d.ts +4 -2
  7. package/guardrail-probe.js +23 -2
  8. package/origins.d.ts +1 -1
  9. package/origins.js +1 -1
  10. package/package.json +4 -4
  11. package/page/assets/BaseTypeahead-CHXE162p.js +1 -0
  12. package/page/assets/{BottomSheet-Ijd3-EiJ.js → BottomSheet-CKodmH_q.js} +1 -1
  13. package/page/assets/{CollapsibleGroup-BnWI_jMR.js → CollapsibleGroup-YxyQ-UXo.js} +1 -1
  14. package/page/assets/{ConsoleFrame-sl_08t-S.js → ConsoleFrame-CcHhIel7.js} +1 -1
  15. package/page/assets/{DateInput-3xmp6QyV.js → DateInput-C2P3VOWH.js} +1 -1
  16. package/page/assets/{MenuBottomSheet-bFIiEbF_.js → MenuBottomSheet-Be_iagz6.js} +1 -1
  17. package/page/assets/ProgressBarMarkTooltip-BCgy6kk7.js +1 -0
  18. package/page/assets/RankedBars-CmyHIG4-.js +1 -0
  19. package/page/assets/{SchemaFields-DHG2EecV.js → SchemaFields-DvkF1spJ.js} +1 -1
  20. package/page/assets/{SegmentedControlItem-CTVJbfcv.js → SegmentedControlItem-DRVmwW9x.js} +1 -1
  21. package/page/assets/{TokenizerBottomSheet-C7wWNjLf.js → TokenizerBottomSheet-BWGxcrKN.js} +1 -1
  22. package/page/assets/ToolResultCharts-BxJS3q9d.js +1 -0
  23. package/page/assets/{Toolbar-B0ZpvYnL.js → Toolbar-GwS1PT9V.js} +1 -1
  24. package/page/assets/TraceInspector-DVBDD7bH.js +1 -0
  25. package/page/assets/{TraceOverview-Yhf9L-7s.js → TraceOverview-CR3DRfnT.js} +34 -34
  26. package/page/assets/{_virtual_studio-type-sources-NQ8eY2_H.js → _virtual_studio-type-sources-DiOYmd5J.js} +128 -71
  27. package/page/assets/browser-engine-A-dNm9JC.js +16 -0
  28. package/page/assets/{browser-transport-BhFcGvWp.js → browser-transport-J8tzWJNv.js} +2 -2
  29. package/page/assets/{browserClickWait-F6QvgsDI.js → browserClickWait-BSA4ZCzN.js} +1 -1
  30. package/page/assets/{export-agent-C1LknzFc.js → export-agent-DdjcE8pP.js} +3 -3
  31. package/page/assets/getRadiusAndStrokeWidthFromDot-CfhyOFVb.js +1 -0
  32. package/page/assets/guardrail-health-DXmUdlna.js +3 -0
  33. package/page/assets/guardrail-tester-D2ym7K4B.js +9 -0
  34. package/page/assets/index-CkGFbd4l.css +1 -0
  35. package/page/assets/{index-Hix1w6kY.js → index-DeAchcs2.js} +45 -45
  36. package/page/assets/{json-code-B13g9rlg.js → json-code-Cxww5ME0.js} +1 -1
  37. package/page/assets/{prompt-row-DGE5h-0F.js → prompt-row-CKcdEaRi.js} +4 -4
  38. package/page/assets/registry-Cl2mlSuk.js +1 -0
  39. package/page/assets/{studio-code-pane-BpYrChnW.js → studio-code-pane-DblixGst.js} +3 -3
  40. package/page/assets/{studio-console-5ZwlH-1a.js → studio-console-BOmPVlqt.js} +1 -1
  41. package/page/assets/studio-decision-DVz4JS3y.js +1 -0
  42. package/page/assets/{studio-embedding-DCMMMVFw.js → studio-embedding-C706qky_.js} +1 -1
  43. package/page/assets/{studio-host-console-CVKWwl3t.js → studio-host-console-BSLhmC-T.js} +2 -2
  44. package/page/assets/{studio-labels-h-JoNVLI.js → studio-labels-tTkrGnDa.js} +1 -1
  45. package/page/assets/{studio-live-DqPhe9Gd.js → studio-live-CvkqZw8r.js} +3 -3
  46. package/page/assets/{studio-map-Dcz7oT-v.js → studio-map-Cel4mfgK.js} +1 -1
  47. package/page/assets/studio-trace-replay-BkdHAhIX.js +3 -0
  48. package/page/assets/{studio-type-checker-DDcpR_0b.js → studio-type-checker-v8KJwpOP.js} +1 -1
  49. package/page/assets/{use-one-call-Ds7HYrGe.js → use-one-call-C4FbV7xi.js} +1 -1
  50. package/page/assets/{useFocusLeavingChange-8rK2N7Tp.js → useFocusLeavingChange-CRkFJGdd.js} +1 -1
  51. package/page/assets/useHighlightedOptionScroll-C7rzQTVc.js +1 -0
  52. package/page/index.html +11 -11
  53. package/probe-battery.js +16 -0
  54. package/runtime-scope.d.ts +2 -0
  55. package/runtime-scope.js +1 -1
  56. package/server/bench.d.ts +7 -0
  57. package/server/bench.js +203 -0
  58. package/server/save-wire.d.ts +1 -1
  59. package/server/serve.js +2 -0
  60. package/ui/guardrail-charts.d.ts +15 -0
  61. package/ui/guardrail-charts.js +175 -0
  62. package/ui/guardrail-health.d.ts +10 -0
  63. package/ui/guardrail-health.js +395 -0
  64. package/ui/guardrail-matrix.d.ts +17 -0
  65. package/ui/guardrail-matrix.js +109 -0
  66. package/ui/guardrail-tester.d.ts +16 -2
  67. package/ui/guardrail-tester.js +6 -5
  68. package/ui/studio-screen.js +3 -3
  69. package/ui/studio.css +69 -0
  70. package/page/assets/BaseTypeahead-BM3FoulY.js +0 -1
  71. package/page/assets/ToolResultCharts-DFKefRvo.js +0 -1
  72. package/page/assets/TraceInspector-ep2qcy9_.js +0 -1
  73. package/page/assets/browser-engine-B9h8eThv.js +0 -16
  74. package/page/assets/guardrail-tester-C188dNNz.js +0 -9
  75. package/page/assets/index-YKE-6URE.css +0 -1
  76. package/page/assets/registry-Du0mj5wR.js +0 -1
  77. package/page/assets/studio-decision-DaWLDjAy.js +0 -1
  78. package/page/assets/studio-trace-replay-DLHxUh4T.js +0 -3
  79. package/page/assets/useHighlightedOptionScroll-Do3FP80C.js +0 -1
@@ -10693,6 +10693,11 @@ export interface RunStageOutput extends Omit<StageApplyOutput, 'inject'> {
10693
10693
  }
10694
10694
  /** Stage events always emit, even with no handlers. */
10695
10695
  export declare function runStage(args: RunStageArgs): AsyncGenerator<TurnEvent, RunStageOutput>;
10696
+ /**
10697
+ * \`units\` as the profile's guardrails let them into the conversation. What they find is reported
10698
+ * once; a block refuses the turn.
10699
+ */
10700
+ export declare function sanitizeInjects(units: readonly InjectUnit[], guardrails: Profile['guardrails'], span?: SpanHandle): Generator<TurnEvent, InjectUnit[]>;
10696
10701
  `,"file:///node_modules/@theoremjs/agents/src/kernel/tools/unchecked-output.d.ts":`/**
10697
10702
  * A handler result with no type until the call runs, such as what a client
10698
10703
  * sent back. The tool's \`output\` schema checks the value when the call
@@ -10816,8 +10821,10 @@ export declare function operationWireValue(value: unknown): JsonValue;
10816
10821
  import { labelText } from '../../guardrails/labels.js';
10817
10822
  import type { SpanHandle, TraceAttributes } from '../../observability/trace-span.js';
10818
10823
  import type { TurnEvent } from '../types.js';
10824
+ import type { AgentCaller } from './agent.js';
10819
10825
  import { type ToolCallBase } from './events.js';
10820
10826
  import { type ToolExecutionCoordinator, type ToolOperationReply } from './operation.js';
10827
+ import type { RegisteredTool } from './types.js';
10821
10828
  /** When the model gets its reply: at the hand-off, past a time, if it asks, or when the body ends. */
10822
10829
  export type ToolBackground = 'always' | {
10823
10830
  /**
@@ -10842,8 +10849,29 @@ export interface ToolBackgroundHandle extends ToolBackgroundCall {
10842
10849
  stop(reason?: string, options?: {
10843
10850
  graceMs?: number;
10844
10851
  }): void;
10852
+ /**
10853
+ * Tells the call's agent \`text\`, as a user message with \`id\`. It joins the agent's turn at the
10854
+ * next stage that takes an inject, or never if the call settles first.
10855
+ */
10856
+ steer(text: string, options: {
10857
+ id: string;
10858
+ }): ToolSteerReceipt;
10845
10859
  /** Resolves when the call has settled or been marked. */
10846
- done: Promise<void>;
10860
+ done: Promise<ToolBackgroundSettled>;
10861
+ }
10862
+ /** Whether a steer waits for the agent's turn, or why it was refused at once. */
10863
+ export type ToolSteerReceipt = {
10864
+ queued: true;
10865
+ } | {
10866
+ queued: false;
10867
+ reason: 'settled' | 'stopped' | ToolSteerRefusal;
10868
+ };
10869
+ /** Why a detached call takes no steers at all. */
10870
+ export type ToolSteerRefusal = 'not_agent' | 'steering_off';
10871
+ /** How a detached call ended, for its host. */
10872
+ export interface ToolBackgroundSettled {
10873
+ /** Ids of steers that were queued and never landed. */
10874
+ unreadSteers: string[];
10847
10875
  }
10848
10876
  /** The host's service for detached calls. Without it every tool runs inline. */
10849
10877
  export interface ToolBackgroundService {
@@ -10868,6 +10896,8 @@ export interface ToolDetach {
10868
10896
  support: ToolBackgroundSupport;
10869
10897
  trace: DetachedToolTrace;
10870
10898
  reply: () => ToolOperationReply;
10899
+ /** Why the call takes no steers; unset when its agent's turn reads them. */
10900
+ refuseSteers?: ToolSteerRefusal;
10871
10901
  }
10872
10902
  /** The \`ask\` argument, as the model reads it. */
10873
10903
  export declare function backgroundField(): z.ZodOptional<z.ZodBoolean>;
@@ -10880,12 +10910,10 @@ export declare function splitBackground(tool: {
10880
10910
  };
10881
10911
  /** How this call detaches, or \`undefined\` when it runs inline. */
10882
10912
  export declare function planDetach(args: {
10883
- tool: {
10884
- background?: ToolBackground;
10885
- name: string;
10886
- } | undefined;
10913
+ tool: RegisteredTool | undefined;
10887
10914
  input: unknown;
10888
10915
  support: ToolBackgroundSupport | undefined;
10916
+ agents: AgentCaller | undefined;
10889
10917
  base: ToolCallBase;
10890
10918
  labels: Parameters<typeof labelText>[2];
10891
10919
  }): ToolDetach | undefined;
@@ -10973,6 +11001,98 @@ export interface RequestChecks {
10973
11001
  }
10974
11002
  export declare function requestChecks(span: SpanHandle | undefined): RequestChecks;
10975
11003
  export declare function toolNetworkPolicy(ctx: ToolContext): NetworkGuardrailSpec | undefined;
11004
+ `,"file:///node_modules/@theoremjs/agents/src/kernel/tools/agent.d.ts":`import { z } from 'zod';
11005
+ import type { ToolOrigin } from '../../guardrails/types.js';
11006
+ import type { SpanHandle } from '../../observability/trace-span.js';
11007
+ import type { Profile, ProfileId, ProfileInputsSpec, TurnEvent, TurnTokens } from '../types.js';
11008
+ import type { SteerQueue } from './steer.js';
11009
+ import type { AgentToolDef, AgentToolInput, AgentToolOutput, RegisteredAgentTool, RegisteredTool, ToolFailure } from './types.js';
11010
+ /** How one agent tool call settled, with what the called agent used. */
11011
+ type AgentRun = {
11012
+ output: AgentToolOutput;
11013
+ tokens?: TurnTokens;
11014
+ } | {
11015
+ failure: ToolFailure;
11016
+ tokens?: TurnTokens;
11017
+ };
11018
+ /** Runs agent tool calls for one turn, which supplies the scope, provider, and hook. */
11019
+ interface AgentCaller {
11020
+ run(call: {
11021
+ tool: RegisteredAgentTool;
11022
+ callId: string;
11023
+ input: AgentToolInput;
11024
+ caller: Profile;
11025
+ /** The call's \`execute_tool\` span; the agent's turn opens under it. */
11026
+ span?: SpanHandle;
11027
+ signal?: AbortSignal;
11028
+ /** A detached call's steers, which only the agent's own turn reads. */
11029
+ steers?: SteerQueue;
11030
+ }): AsyncGenerator<TurnEvent, AgentRun>;
11031
+ /** Whether a running call of \`tool\` can be steered: its agent's profile allows injects. */
11032
+ takesSteers(tool: RegisteredAgentTool): boolean;
11033
+ }
11034
+ /** A call that settled without a reply; the model reads \`failure\`. */
11035
+ declare class AgentCallFailed extends Error {
11036
+ readonly failure: ToolFailure;
11037
+ constructor(failure: ToolFailure);
11038
+ }
11039
+ /**
11040
+ * What the model sent, split into what goes to the called agent and what only the host reads.
11041
+ *
11042
+ * why: A host field is the host's own word for something (an id it resolves); the called profile does not take it, so it never reaches the agent's turn.
11043
+ */
11044
+ declare function splitHostInput(tool: Pick<AgentToolDef, 'hostFields'>, input: AgentToolInput): {
11045
+ sent: AgentToolInput;
11046
+ hostInput?: Record<string, unknown>;
11047
+ };
11048
+ /**
11049
+ * The input of an agent tool that runs \`agent\`: text, and each channel the
11050
+ * profile's \`inputs\` declares. Anything else is refused, never dropped. The
11051
+ * called turn's own ingress checks MIME types and sizes.
11052
+ */
11053
+ declare function agentToolInputFor(agent: Pick<Profile, 'type'> & {
11054
+ inputs?: Pick<ProfileInputsSpec, 'attachments' | 'voice' | 'options'>;
11055
+ }, tool?: Pick<AgentToolDef, 'name' | 'fieldText' | 'hostFields' | 'hostOnly'>): z.ZodType<AgentToolInput>;
11056
+ declare const agentToolOutput: z.ZodType<AgentToolOutput>;
11057
+ /** Why \`profile\` can't be run by an agent tool, or \`undefined\` when it can. */
11058
+ declare function agentProfileProblem(profile: Profile, find: (name: string) => RegisteredTool | undefined): string | undefined;
11059
+ /** The profile an agent tool runs; throws \`config\` when the tool can't run it. */
11060
+ declare function agentToolProfile(def: AgentToolDef, findProfile: (id: ProfileId) => Profile | undefined, findTool: (name: string) => RegisteredTool | undefined): Profile;
11061
+ /** An agent with no tools of its own read only what it was sent; one with tools may have read outside content. */
11062
+ declare function agentToolOrigin(profile: Profile | undefined): ToolOrigin;
11063
+ /**
11064
+ * The called agent's reply: its text or its last structured reply, its media as parts, and what it cited.
11065
+ *
11066
+ * why: A structured reply's text is the same JSON as a string, so returning both would have the caller's model read the answer twice.
11067
+ */
11068
+ declare function agentToolOutputOf(turn: readonly TurnEvent[]): AgentToolOutput;
11069
+ declare function normalizeAgent(def: AgentToolDef, input: z.ZodType<AgentToolInput>, schemas: {
11070
+ inputSchema: Record<string, unknown>;
11071
+ outputSchema: Record<string, unknown>;
11072
+ }): RegisteredAgentTool;
11073
+ export type { AgentCaller, AgentRun };
11074
+ export { AgentCallFailed, agentProfileProblem, agentToolInputFor, agentToolOrigin, agentToolOutput, agentToolOutputOf, agentToolProfile, normalizeAgent, splitHostInput, };
11075
+ `,"file:///node_modules/@theoremjs/agents/src/kernel/tools/steer.d.ts":`import type { InjectUnit } from '../stages.js';
11076
+ /**
11077
+ * The steers a detached call was given and its agent's turn has not read yet. The call's handle
11078
+ * writes to it; its agent's turn lands what waits at a stage that takes an inject.
11079
+ *
11080
+ * invariant: A steer leaves the queue only when its message has joined the turn's history, or when
11081
+ * the call settles and the queue closes.
11082
+ */
11083
+ export declare class SteerQueue {
11084
+ private units;
11085
+ private closed;
11086
+ get isClosed(): boolean;
11087
+ /** Queues \`text\` as a user message with \`id\`; false once the queue is closed. */
11088
+ push(id: string, text: string): boolean;
11089
+ /** What waits now, in the order it was given. */
11090
+ waiting(): readonly InjectUnit[];
11091
+ /** \`landed\`, as \`waiting\` gave them, have joined the turn's history. */
11092
+ joined(landed: readonly InjectUnit[]): void;
11093
+ /** Closes the queue and gives the ids of the steers that never landed. */
11094
+ close(): string[];
11095
+ }
10976
11096
  `,"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. */
10977
11097
  export type LabelTemplate = string | readonly string[];
10978
11098
  /** \`expected: null\` is the check "is null". */
@@ -12188,6 +12308,7 @@ import type { ToolAccess } from '../schema.js';
12188
12308
  import { type InjectUnit, type StageHandler, type StageResult, type StepCall } from '../stages.js';
12189
12309
  import type { Profile, TurnEvent, TurnHistoryMessage, TurnTokens } from '../types.js';
12190
12310
  import { type ToolCallBase } from './events.js';
12311
+ import type { SteerQueue } from './steer.js';
12191
12312
  import type { ModelToolResult, ToolContext, ToolFailure, ToolGate, ToolLabels } from './types.js';
12192
12313
  /** How a call's wait for other calls in its step ended: they settled, or the wait cannot end. */
12193
12314
  export type StepWaitOutcome = {
@@ -12221,6 +12342,8 @@ export interface ToolStageSupport {
12221
12342
  bodyEnded?: () => void;
12222
12343
  /** Told what an agent tool's turn has spent so far. */
12223
12344
  spent?: (tokens: TurnTokens) => void;
12345
+ /** A detached agent call's steers, which its agent's own turn reads. */
12346
+ steers?: SteerQueue;
12224
12347
  }
12225
12348
  export type PreBodyOutcome = {
12226
12349
  ok: true;
@@ -12500,72 +12623,6 @@ export declare function gateDetails(tool: {
12500
12623
  labels?: ToolLabels;
12501
12624
  }, input: unknown): GateDetails;
12502
12625
  export declare function checkPermission(toolName: string, permission: ToolPermission, sessionPermissions?: string[], resume?: InvokeToolResume, details?: GateDetails): ToolGate | null;
12503
- `,"file:///node_modules/@theoremjs/agents/src/kernel/tools/agent.d.ts":`import { z } from 'zod';
12504
- import type { ToolOrigin } from '../../guardrails/types.js';
12505
- import type { SpanHandle } from '../../observability/trace-span.js';
12506
- import type { Profile, ProfileId, ProfileInputsSpec, TurnEvent, TurnTokens } from '../types.js';
12507
- import type { AgentToolDef, AgentToolInput, AgentToolOutput, RegisteredAgentTool, RegisteredTool, ToolFailure } from './types.js';
12508
- /** How one agent tool call settled, with what the called agent used. */
12509
- type AgentRun = {
12510
- output: AgentToolOutput;
12511
- tokens?: TurnTokens;
12512
- } | {
12513
- failure: ToolFailure;
12514
- tokens?: TurnTokens;
12515
- };
12516
- /** Runs agent tool calls for one turn, which supplies the scope, provider, and hook. */
12517
- interface AgentCaller {
12518
- run(call: {
12519
- tool: RegisteredAgentTool;
12520
- callId: string;
12521
- input: AgentToolInput;
12522
- caller: Profile;
12523
- /** The call's \`execute_tool\` span; the agent's turn opens under it. */
12524
- span?: SpanHandle;
12525
- signal?: AbortSignal;
12526
- }): AsyncGenerator<TurnEvent, AgentRun>;
12527
- }
12528
- /** A call that settled without a reply; the model reads \`failure\`. */
12529
- declare class AgentCallFailed extends Error {
12530
- readonly failure: ToolFailure;
12531
- constructor(failure: ToolFailure);
12532
- }
12533
- /**
12534
- * What the model sent, split into what goes to the called agent and what only the host reads.
12535
- *
12536
- * why: A host field is the host's own word for something (an id it resolves); the called profile does not take it, so it never reaches the agent's turn.
12537
- */
12538
- declare function splitHostInput(tool: Pick<AgentToolDef, 'hostFields'>, input: AgentToolInput): {
12539
- sent: AgentToolInput;
12540
- hostInput?: Record<string, unknown>;
12541
- };
12542
- /**
12543
- * The input of an agent tool that runs \`agent\`: text, and each channel the
12544
- * profile's \`inputs\` declares. Anything else is refused, never dropped. The
12545
- * called turn's own ingress checks MIME types and sizes.
12546
- */
12547
- declare function agentToolInputFor(agent: Pick<Profile, 'type'> & {
12548
- inputs?: Pick<ProfileInputsSpec, 'attachments' | 'voice' | 'options'>;
12549
- }, tool?: Pick<AgentToolDef, 'name' | 'fieldText' | 'hostFields' | 'hostOnly'>): z.ZodType<AgentToolInput>;
12550
- declare const agentToolOutput: z.ZodType<AgentToolOutput>;
12551
- /** Why \`profile\` can't be run by an agent tool, or \`undefined\` when it can. */
12552
- declare function agentProfileProblem(profile: Profile, find: (name: string) => RegisteredTool | undefined): string | undefined;
12553
- /** The profile an agent tool runs; throws \`config\` when the tool can't run it. */
12554
- declare function agentToolProfile(def: AgentToolDef, findProfile: (id: ProfileId) => Profile | undefined, findTool: (name: string) => RegisteredTool | undefined): Profile;
12555
- /** An agent with no tools of its own read only what it was sent; one with tools may have read outside content. */
12556
- declare function agentToolOrigin(profile: Profile | undefined): ToolOrigin;
12557
- /**
12558
- * The called agent's reply: its text or its last structured reply, its media as parts, and what it cited.
12559
- *
12560
- * why: A structured reply's text is the same JSON as a string, so returning both would have the caller's model read the answer twice.
12561
- */
12562
- declare function agentToolOutputOf(turn: readonly TurnEvent[]): AgentToolOutput;
12563
- declare function normalizeAgent(def: AgentToolDef, input: z.ZodType<AgentToolInput>, schemas: {
12564
- inputSchema: Record<string, unknown>;
12565
- outputSchema: Record<string, unknown>;
12566
- }): RegisteredAgentTool;
12567
- export type { AgentCaller, AgentRun };
12568
- export { AgentCallFailed, agentProfileProblem, agentToolInputFor, agentToolOrigin, agentToolOutput, agentToolOutputOf, agentToolProfile, normalizeAgent, splitHostInput, };
12569
12626
  `,"file:///node_modules/@theoremjs/agents/src/kernel/engine/tool-trace.d.ts":`import type { GuardrailEvent, ToolOrigin } from '../../guardrails/types.js';
12570
12627
  import { type SpanHandle, type TraceAttributes } from '../../observability/trace-span.js';
12571
12628
  import type { ToolPermission } from '../schema.js';