@theoremjs/studio 0.3.4-next.508.geda6db0 → 0.3.4-next.524.g5000023

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 (60) hide show
  1. package/compile.js +44 -2
  2. package/draft.d.ts +54 -1
  3. package/draft.js +14 -0
  4. package/mod.d.ts +1 -1
  5. package/mod.js +1 -1
  6. package/package.json +4 -4
  7. package/page/assets/{Banner-BcHZFaJb.js → Banner-CqLOCD6Z.js} +2 -2
  8. package/page/assets/{ConsoleFrame-Byq_hSpu.js → ConsoleFrame-Tjt_zLbG.js} +1 -1
  9. package/page/assets/{ContextMenu-C6S-GYrc.js → ContextMenu-DPqKbw_f.js} +2 -2
  10. package/page/assets/{ToolResultCharts-CkEf5ub5.js → ToolResultCharts-BQwnjoiy.js} +1 -1
  11. package/page/assets/{TraceInspector-BsYHHhGv.js → TraceInspector-C2rlhE71.js} +1 -1
  12. package/page/assets/{TraceOverview-CMFfbfGM.js → TraceOverview-B9V8W-q0.js} +1 -1
  13. package/page/assets/{_virtual_studio-type-sources-CTIGQ210.js → _virtual_studio-type-sources-oXv11QXQ.js} +54 -17
  14. package/page/assets/browser-engine-CywA6yoH.js +11 -0
  15. package/page/assets/browser-transport-CFSkVqTn.js +47 -0
  16. package/page/assets/{compile-egress-BSxOdX4K.js → compile-egress-BRGW9qfO.js} +2 -2
  17. package/page/assets/{crypto-DAIn4qnM.js → crypto-D0sMVyOH.js} +1 -1
  18. package/page/assets/{encode-files-oYzzs_iG.js → encode-files-BvmEyafH.js} +1 -1
  19. package/page/assets/{export-agent-BeUTYowB.js → export-agent-CC6sy8t7.js} +1 -1
  20. package/page/assets/{guardrail-tester-DLT99rnO.js → guardrail-tester-DN3ZAkjj.js} +1 -1
  21. package/page/assets/host-patterns-cSf1U25G.js +1 -0
  22. package/page/assets/{index-DNA-Y8Mp.js → index-escjDtrD.js} +71 -71
  23. package/page/assets/{live-ingress-lDUGPwth.js → live-ingress-qi-y5uvH.js} +1 -1
  24. package/page/assets/{live-messages-BnBioidx.js → live-messages-BfGupbXr.js} +1 -1
  25. package/page/assets/reader-Dwjcmg_e.js +7 -0
  26. package/page/assets/{shaped-data-1Qn2111E.js → shaped-data-yA5pdGCO.js} +15 -11
  27. package/page/assets/{stub-B3GersQP.js → stub-B5Xqezkf.js} +1 -1
  28. package/page/assets/studio-code-pane-TzEXqNrr.js +8 -0
  29. package/page/assets/{studio-console-CJT5FkWm.js → studio-console-CmukeRuA.js} +1 -1
  30. package/page/assets/{studio-decision-DhHdHb7Z.js → studio-decision-DXttPtt-.js} +1 -1
  31. package/page/assets/{studio-embedding-B8vBhuZU.js → studio-embedding-DJCN5JlP.js} +1 -1
  32. package/page/assets/{studio-host-console-CE_5_tEn.js → studio-host-console-DlSXTr46.js} +2 -2
  33. package/page/assets/{studio-labels-C2SI_T2p.js → studio-labels-B6Q2NeFO.js} +1 -1
  34. package/page/assets/studio-live-Cag9FHZu.js +5 -0
  35. package/page/assets/{studio-map-CKm_FCd9.js → studio-map-FtpYQ1kF.js} +1 -1
  36. package/page/assets/{studio-trace-replay-BRMD6pex.js → studio-trace-replay-CC7mjkLh.js} +1 -1
  37. package/page/assets/{studio-type-checker-DoaPHYNy.js → studio-type-checker-DnHx9_mj.js} +1 -1
  38. package/page/assets/tool-schema-Cz7rA_Ff.js +17 -0
  39. package/page/assets/{trace-record-DWxIfO7D.js → trace-record-Czcy5c-7.js} +1 -1
  40. package/page/assets/tree-OAdfOli8.js +3 -0
  41. package/page/assets/{turn-client-DF0ije7A.js → turn-client-B3luhTmk.js} +1 -1
  42. package/page/assets/types-DUW-r0Zo.js +1 -0
  43. package/page/assets/{use-one-call-Bhnpve1Y.js → use-one-call-D3R9z_11.js} +1 -1
  44. package/page/assets/workspace-DBo9uy_h.js +1 -0
  45. package/page/index.html +17 -17
  46. package/read-source.js +10 -1
  47. package/registrations.d.ts +6 -0
  48. package/tools.js +3 -0
  49. package/types.d.ts +6 -0
  50. package/ui/profile-editor.js +21 -5
  51. package/page/assets/browser-engine-DjYv346h.js +0 -11
  52. package/page/assets/browser-transport-Bm3uY9Fj.js +0 -47
  53. package/page/assets/host-patterns-C9RMP16Q.js +0 -1
  54. package/page/assets/reader-BFYIhA73.js +0 -7
  55. package/page/assets/studio-code-pane-CCi7-lyE.js +0 -8
  56. package/page/assets/studio-live-CKSSyYZj.js +0 -5
  57. package/page/assets/tool-schema-DXYwL5aE.js +0 -18
  58. package/page/assets/tree-Chi6mqzx.js +0 -3
  59. package/page/assets/types-2I4NfLiS.js +0 -1
  60. package/page/assets/workspace-U3w2ELtN.js +0 -1
@@ -4416,9 +4416,6 @@ interface HostMatcher {
4416
4416
  }
4417
4417
  /** Bumped whenever the compiled table's layout or meaning changes. */
4418
4418
  declare const PATTERN_COMPILER_VERSION = 3;
4419
- /** The most patterns one detector takes, and the longest each may be once written as a regular expression. */
4420
- declare const MAX_PATTERNS = 64;
4421
- declare const MAX_PATTERN_LENGTH = 1024;
4422
4419
  /** The patterns as a compiled table records them. */
4423
4420
  declare function patternSources(patterns: readonly HostPattern[]): PatternSource[];
4424
4421
  /** What is wrong with one pattern, or \`undefined\` when it runs. */
@@ -4439,7 +4436,7 @@ declare function listsPatterns(detect: unknown): boolean;
4439
4436
  /** \`patterns\`, valid, ready to run. */
4440
4437
  declare function matchersOf(patterns: readonly HostPattern[]): readonly HostMatcher[];
4441
4438
  export type { AutomatonData, CompiledPatterns, HostMatcher, HostPattern, PatternSource };
4442
- export { listsPatterns, MAX_PATTERN_LENGTH, MAX_PATTERNS, matchersOf, PATTERN_COMPILER_VERSION, patternListProblem, patternProblem, patternSources, patternsProblem, };
4439
+ export { listsPatterns, matchersOf, PATTERN_COMPILER_VERSION, patternListProblem, patternProblem, patternSources, patternsProblem, };
4443
4440
  `,"file:///node_modules/@theoremjs/agents/src/guardrails/detectors.d.ts":`/** labels-exempt-file: authoring labels, descriptions and profile-registration diagnostics for detectors — not runtime user or model copy (P2) */
4444
4441
  import { type Boundary } from './boundaries.js';
4445
4442
  import { type CompiledPatterns, type HostMatcher, type HostPattern } from './host-patterns.js';
@@ -6858,6 +6855,8 @@ export interface CompactionFailure {
6858
6855
  stop?: TurnStopKind;
6859
6856
  /** The error it reported, when it reported one. */
6860
6857
  error?: ErrorKind;
6858
+ /** Why it failed, for the builder only: \`forClient\` strips it for a visitor. */
6859
+ errorInternal?: string;
6861
6860
  /** It completed without a summary. */
6862
6861
  empty?: true;
6863
6862
  /** Nothing in \`toCompact\` was left for it to read, so it did not run. */
@@ -8033,6 +8032,11 @@ export interface GuardrailEvent {
8033
8032
  provenance?: Provenance;
8034
8033
  /** The block verdict's \`errorInternal\`: builder-only, stripped by \`forClient\`. */
8035
8034
  errorInternal?: string;
8035
+ /**
8036
+ * A failed host detector's \`errorInternal\` in the kernel's words only, with the same error id:
8037
+ * what the trace stores. Builder-only, stripped by \`forClient\`.
8038
+ */
8039
+ errorSummary?: string;
8036
8040
  }
8037
8041
  /** The schema a guardrail event parses against. */
8038
8042
  export declare const guardrailEventSchema: z.ZodType<GuardrailEvent>;
@@ -8945,12 +8949,25 @@ export interface ToolOutputHooks<TOut = unknown> {
8945
8949
  /** For a tool whose result names pictures by address; function tools return the bytes themselves as \`parts\`. */
8946
8950
  export interface ToolImageHooks<TOut = unknown> {
8947
8951
  /**
8948
- * The https addresses of pictures in \`output\` the model should see, at most \`MAX_TOOL_IMAGES\`
8949
- * of them. After the result passes the output guard, the kernel fetches each one through the
8950
- * profile's network policy, without the tool's credentials, and hands the model the image as a
8951
- * part; one it cannot fetch is an \`images_unfetched\` warning, never a failed call.
8952
+ * The https addresses of pictures in \`output\` the model should see. After the result passes the
8953
+ * output guard, the kernel fetches each one through the profile's network policy, without the
8954
+ * tool's credentials, and hands the model the image as a part; one it cannot fetch is an
8955
+ * \`images_unfetched\` warning, never a failed call.
8952
8956
  */
8953
8957
  images?: (output: TOut) => string[];
8958
+ /** How many of those pictures the kernel fetches, how large, and how slowly. Left out, there is no limit. */
8959
+ imageLimits?: ToolImageLimits;
8960
+ }
8961
+ /** Each limit left out is no limit. A picture past one is left out, not cut. */
8962
+ export interface ToolImageLimits {
8963
+ /** The most pictures one call hands the model; the first ones named are kept. */
8964
+ count?: number;
8965
+ /** The largest picture fetched. */
8966
+ bytes?: number;
8967
+ /** The most one call hands the model in all. */
8968
+ totalBytes?: number;
8969
+ /** How long each picture may take. */
8970
+ timeoutMs?: number;
8954
8971
  }
8955
8972
  export interface FunctionToolDef<TIn = unknown, TOut = unknown> extends ToolBase, ToolHostHooks<TIn>, ToolOutputHooks<TOut> {
8956
8973
  type: 'function';
@@ -9008,6 +9025,8 @@ export interface HttpToolDef<TIn = unknown, TOut = unknown> extends ToolBase, To
9008
9025
  };
9009
9026
  /** The service's own limit for one key; the kernel keeps this tool's requests within it. */
9010
9027
  limit?: HttpToolLimit;
9028
+ /** The most of a response body the kernel reads; past it the call fails \`response_too_large\`. Left out, there is no limit. */
9029
+ maxResponseBytes?: number;
9011
9030
  /**
9012
9031
  * How long the service may take to answer, its body read included. Past it the call
9013
9032
  * fails \`timeout\` and frees its place in the limit. Left out, a call waits as long as
@@ -9028,6 +9047,17 @@ export interface McpToolDef<TIn = unknown, TOut = unknown> extends ToolBase, Too
9028
9047
  mcpToolName: string;
9029
9048
  headers?: Record<string, string>;
9030
9049
  auth?: ToolAuthConfig;
9050
+ /** The most of a response body the kernel reads; past it the call fails \`response_too_large\`. Left out, there is no limit. */
9051
+ maxResponseBytes?: number;
9052
+ /** How long and how many of this tool's server sessions the kernel keeps. Left out, there is no limit. */
9053
+ session?: McpSessionLimits;
9054
+ }
9055
+ /** The sessions an MCP tool keeps: each field left out is no limit. */
9056
+ export interface McpSessionLimits {
9057
+ /** How long a session may sit unused before the next call opens a new one, in milliseconds. */
9058
+ idleMs?: number;
9059
+ /** The most sessions the tool keeps open; past it the least recently used is dropped. */
9060
+ max?: number;
9031
9061
  }
9032
9062
  /**
9033
9063
  * What an agent tool call carries: the text, and whatever else the called
@@ -9656,7 +9686,7 @@ declare function kindOfHttpStatus(status: number): ErrorKind;
9656
9686
  declare function errorCopyText(copy: ErrorCopies, labels?: LabelOverrides): string;
9657
9687
  /** Pass the profile's \`labels\`, or the profile's wording is skipped. */
9658
9688
  declare function publicError(err: unknown, labels?: LabelOverrides): string;
9659
- /** Raw diagnostic for hosts, traces, and logs; never shown to end users. */
9689
+ /** Raw diagnostic for hosts, traces, and logs; never shown to end users. Each cause that says something new follows on its own line. */
9660
9690
  declare function describeError(err: unknown): string;
9661
9691
  type ProducedError = TurnEventOf<'error'> & {
9662
9692
  errorInternal: string;
@@ -10643,14 +10673,19 @@ export { createToolRegistry };
10643
10673
  * Sessions for MCP servers that refuse a call without one. A session is a cache, not state: it
10644
10674
  * lives in memory on one tool registry, is never persisted, and losing it costs one reopen.
10645
10675
  */
10676
+ import type { McpSessionLimits } from './types.js';
10646
10677
  export type McpSession = {
10647
10678
  id: string;
10648
10679
  protocolVersion: string;
10649
10680
  };
10681
+ /** The tool a session is used for, and that tool's own \`session\` limits. */
10682
+ export interface McpSessionUse extends McpSessionLimits {
10683
+ tool: string;
10684
+ }
10650
10685
  export interface McpSessionCache {
10651
- get(key: string): McpSession | undefined;
10686
+ get(key: string, use: McpSessionUse): McpSession | undefined;
10652
10687
  /** Parallel callers for one key share a single \`open\`. */
10653
- open(key: string, open: () => Promise<McpSession>): Promise<McpSession>;
10688
+ open(key: string, use: McpSessionUse, open: () => Promise<McpSession>): Promise<McpSession>;
10654
10689
  /** Only drops the session if it's still \`id\`, so a late expiry can't evict a newer one. */
10655
10690
  drop(key: string, id: string): void;
10656
10691
  clear(): void;
@@ -10801,8 +10836,6 @@ export declare function refusedCredentialOutcome(tool: {
10801
10836
  name: string;
10802
10837
  auth?: ToolAuthConfig;
10803
10838
  }, refusal: CredentialRefusal | undefined, carried: boolean, ctx: ToolContext, base: ToolCallBase): Generator<TurnEvent, ToolBodyOutcome | undefined>;
10804
- /** The most of a tool's response body the kernel reads; past it the call fails instead of exhausting the host's memory. */
10805
- export declare const MAX_TOOL_RESPONSE_BYTES: number;
10806
10839
  /** Every string in \`value\` with the credential replaced. */
10807
10840
  export declare function omitSecret(value: unknown, secret: string): unknown;
10808
10841
  /** A failure's message and details with the credential replaced. */
@@ -11553,6 +11586,10 @@ interface Detection {
11553
11586
  text?: string;
11554
11587
  /** Every match, each named for its detector. */
11555
11588
  hits: GuardrailHit[];
11589
+ /** Why a host's \`find\` failed, for the builder only: it reaches \`guardrail.errorInternal\`. */
11590
+ errorInternal?: string;
11591
+ /** The same failure in the kernel's words only, with no text from the host: what the trace stores. */
11592
+ errorSummary?: string;
11556
11593
  }
11557
11594
  declare function stronger(left: DetectOutcome, right: DetectOutcome | 'ignore'): DetectOutcome;
11558
11595
  /**
@@ -11632,7 +11669,7 @@ declare function storedHostSpans(text: string, detect?: ResolvedDetect): RedactS
11632
11669
  interface BoundaryReader {
11633
11670
  /** The text to let through, or \`''\` once a match blocks: the caller reads \`found().action\`. */
11634
11671
  read(text: string): string;
11635
- found(): Pick<Detection, 'action' | 'hits'>;
11672
+ found(): Pick<Detection, 'action' | 'hits' | 'errorInternal' | 'errorSummary'>;
11636
11673
  }
11637
11674
  /** A reader for everything crossing \`boundary\` in one request. */
11638
11675
  declare function boundaryReader(boundary: Boundary, detect: ResolvedDetect): BoundaryReader;
@@ -11640,7 +11677,7 @@ declare function boundaryReader(boundary: Boundary, detect: ResolvedDetect): Bou
11640
11677
  * The guardrail event for what was found at a boundary, or \`undefined\` when nothing matched.
11641
11678
  * \`stage\` is the boundary's own unless the text was read as it streamed.
11642
11679
  */
11643
- declare function detectEvent(boundary: Boundary, found: Pick<Detection, 'action' | 'hits'>, provenance?: Provenance, stage?: GuardrailStage): GuardrailEvent | undefined;
11680
+ declare function detectEvent(boundary: Boundary, found: Pick<Detection, 'action' | 'hits' | 'errorInternal' | 'errorSummary'>, provenance?: Provenance, stage?: GuardrailStage): GuardrailEvent | undefined;
11644
11681
  export type { BoundaryReader, Detection, DetectOutcome, DetectScope, Release, StoredSides, StreamRead, Stretch, };
11645
11682
  export { boundaryReader, detectAt, detectEvent, detectorsAt, detectReads, detectRelease, hostAt, isScoped, leakScopeOf, redactDetectors, scopeOf, storedHostSpans, storedSpans, stronger, };
11646
11683
  `,"file:///node_modules/@theoremjs/agents/src/guardrails/egress.d.ts":`import type { ModelEvent } from '../kernel/types.js';
@@ -12165,7 +12202,7 @@ declare function sanitizeProjectId(id: string | undefined): string | undefined;
12165
12202
  */
12166
12203
  declare function sanitizeHistory(history: TurnHistoryMessage[], reader: BoundaryReader): TurnHistoryMessage[];
12167
12204
  /** The error a turn ends on when a detector set to \`block\` matched at \`boundary\`. */
12168
- declare function requestRefused(boundary: Boundary): TheoremError;
12205
+ declare function requestRefused(boundary: Boundary, reason?: string): TheoremError;
12169
12206
  /** A turn request read at each boundary it crosses. */
12170
12207
  interface SanitizedTurnRequest {
12171
12208
  request: NormalizedTurnRequest;
@@ -12233,7 +12270,7 @@ export { errorCopiesSchema, errorKindSchema, guardrailEventSchema } from './even
12233
12270
  export { guardrailFromHits, guardrailFromVerdict, guardrailTurnEvent, projectGuardrailTurnEvent, } from './events.js';
12234
12271
  export { hitFromSpan, projectGuardrailEvent, } from './hits.js';
12235
12272
  export type { CompiledPatterns, HostPattern } from './host-patterns.js';
12236
- export { listsPatterns, MAX_PATTERN_LENGTH, MAX_PATTERNS, patternListProblem, } from './host-patterns.js';
12273
+ export { listsPatterns, patternListProblem, } from './host-patterns.js';
12237
12274
  export { injectionSpans } from './injection.js';
12238
12275
  export type { ClientLabelKey, LabelKey, LabelOverrides, LabelParams } from './labels.js';
12239
12276
  export { CLIENT_LABEL_KEYS, LABEL_KEYS, labelCatalogRows, labelDefault, labelText, overrideLabels, resetLabels, validateLabelOverrides, } from './labels.js';