@theoremjs/studio 0.3.4-next.679.gcdf1a3a → 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.
Files changed (141) hide show
  1. package/asks.d.ts +9 -2
  2. package/asks.js +19 -10
  3. package/browser-connection.d.ts +1 -1
  4. package/browser-connection.js +3 -1
  5. package/browser-execution.js +1 -0
  6. package/compile-workspace.js +12 -5
  7. package/compile.d.ts +4 -2
  8. package/compile.js +58 -37
  9. package/cookbooks/catalog.d.ts +2 -2
  10. package/cookbooks/catalog.js +299 -52
  11. package/cookbooks/project.js +1 -0
  12. package/cookbooks/tools.js +64 -0
  13. package/draft.d.ts +21 -5
  14. package/draft.js +25 -2
  15. package/guardrail-probe.d.ts +3 -1
  16. package/guardrail-probe.js +37 -5
  17. package/mod.d.ts +2 -2
  18. package/mod.js +2 -2
  19. package/package.json +4 -4
  20. package/page/assets/Banner-DrRNC3MG.js +4 -0
  21. package/page/assets/Center-CgO0c-qo.js +1 -0
  22. package/page/assets/{ConsoleFrame-BMf3HicW.js → ConsoleFrame-BvgFGqp2.js} +3 -3
  23. package/page/assets/{MenuBottomSheet-sVJMYa4R.js → MenuBottomSheet-BZecY8fw.js} +1 -1
  24. package/page/assets/{SchemaFields-DYormNVH.js → SchemaFields-BNNkvyyO.js} +1 -1
  25. package/page/assets/{ToolResultCharts-Ce4lVdgN.js → ToolResultCharts-C3CPsfXl.js} +1 -1
  26. package/page/assets/{TraceInspector-DHyj0IHY.js → TraceInspector-36e6ozKD.js} +1 -1
  27. package/page/assets/{TraceOverview-CeiOIqk9.js → TraceOverview-CSdJ_cYY.js} +3 -3
  28. package/page/assets/{_virtual_studio-type-sources-BwSqfSwd.js → _virtual_studio-type-sources-DSpwr3WK.js} +143 -13
  29. package/page/assets/browser-connection-dads1eyK.js +3 -0
  30. package/page/assets/browser-engine-CugH58NS.js +13 -0
  31. package/page/assets/browser-transport-GzhRiBdm.js +45 -0
  32. package/page/assets/{crypto-CD14HeXH.js → crypto-B8dqEoWf.js} +1 -1
  33. package/page/assets/{encode-files-DhoC5hWG.js → encode-files-CHeRLBO8.js} +1 -1
  34. package/page/assets/{export-agent-Cs2S0oXB.js → export-agent-botXSyoH.js} +3 -3
  35. package/page/assets/{guardrail-tester-IcJWVveC.js → guardrail-tester-DYR7EPIy.js} +2 -2
  36. package/page/assets/index-B7sK7d-l.js +153 -0
  37. package/page/assets/live-messages-DN_q2nBN.js +1 -0
  38. package/page/assets/project-address-DjxPZuyn.js +1 -0
  39. package/page/assets/reader-DHN96tSr.js +5 -0
  40. package/page/assets/{schemas-BQ9Jydzb.js → schemas-D7cgkv3L.js} +1 -1
  41. package/page/assets/shaped-data-CJQ3W_RE.js +20 -0
  42. package/page/assets/{stub-nxRsh1jo.js → stub-U6wDGe3P.js} +25 -7
  43. package/page/assets/studio-code-pane-Boy63AK2.js +8 -0
  44. package/page/assets/{studio-console-Cn-v8Vvw.js → studio-console-B7zL133d.js} +1 -1
  45. package/page/assets/studio-decision-CbRjfbvG.js +1 -0
  46. package/page/assets/studio-embedding-DQ0QrEsu.js +2 -0
  47. package/page/assets/{studio-host-console-D__Of1no.js → studio-host-console-DDA2Um2-.js} +2 -2
  48. package/page/assets/{studio-labels-CiLuAo3N.js → studio-labels-jYWBoEyP.js} +1 -1
  49. package/page/assets/studio-live-D0YRu2zQ.js +5 -0
  50. package/page/assets/studio-map-C4Ra1QqL.js +1 -0
  51. package/page/assets/studio-session-CPnJaHc-.js +1 -0
  52. package/page/assets/studio-trace-replay-D-f2p7k9.js +3 -0
  53. package/page/assets/{studio-type-checker-BbUSqqOS.js → studio-type-checker-CVNPnko-.js} +1 -1
  54. package/page/assets/tool-schema-BDG2_rlP.js +17 -0
  55. package/page/assets/{trace-record-DxgSKmYY.js → trace-record-DoXjxrmJ.js} +1 -1
  56. package/page/assets/trace-schema--4IGmLeE.js +1 -0
  57. package/page/assets/tree-CcEbNvms.js +3 -0
  58. package/page/assets/turn-client-BmOSpCgw.js +2 -0
  59. package/page/assets/{use-one-call-BZKByPJh.js → use-one-call-B3t-kfc5.js} +1 -1
  60. package/page/assets/{use-second-ticker-CEwOSS-d.js → use-second-ticker-CWjCHLG6.js} +1 -1
  61. package/page/assets/workspace-DUfaxr-g.js +1 -0
  62. package/page/index.html +20 -19
  63. package/people.d.ts +2 -0
  64. package/people.js +3 -1
  65. package/policy.js +1 -0
  66. package/providers.d.ts +2 -2
  67. package/providers.js +8 -3
  68. package/read-source.js +34 -7
  69. package/registrations.d.ts +23 -3
  70. package/runtime-scope.d.ts +6 -3
  71. package/runtime-scope.js +16 -4
  72. package/runtime.js +14 -2
  73. package/server/draft-handler.d.ts +4 -4
  74. package/server/draft-handler.js +3 -2
  75. package/server/draft-probe.d.ts +9 -1
  76. package/server/draft-probe.js +2 -1
  77. package/server/handler.js +71 -25
  78. package/server/live.d.ts +7 -1
  79. package/server/live.js +11 -4
  80. package/server/run-traces.d.ts +5 -1
  81. package/server/run-traces.js +7 -3
  82. package/server/save-new.js +5 -5
  83. package/server/save-session.js +4 -2
  84. package/server/serve.js +2 -1
  85. package/server/test-key.d.ts +2 -2
  86. package/server/test-key.js +1 -1
  87. package/slot-values.d.ts +2 -0
  88. package/slot-values.js +22 -0
  89. package/source.js +11 -4
  90. package/tool-readers.d.ts +23 -0
  91. package/tool-readers.js +60 -0
  92. package/tools.js +4 -1
  93. package/types.d.ts +3 -1
  94. package/ui/inspector-context.js +1 -1
  95. package/ui/lib/project-traces.d.ts +5 -0
  96. package/ui/lib/project-traces.js +21 -3
  97. package/ui/lib/studio-page.d.ts +6 -1
  98. package/ui/lib/studio-page.js +33 -31
  99. package/ui/lib/studio-project.d.ts +8 -1
  100. package/ui/lib/studio-project.js +19 -1
  101. package/ui/lib/studio-session.d.ts +2 -0
  102. package/ui/lib/studio-session.js +40 -2
  103. package/ui/lib/studio-store.d.ts +2 -2
  104. package/ui/lib/studio-store.js +9 -5
  105. package/ui/lib/tool-probe.d.ts +2 -0
  106. package/ui/lib/tool-probe.js +3 -2
  107. package/ui/lib/type-icons.d.ts +1 -0
  108. package/ui/lib/type-icons.js +2 -1
  109. package/ui/profile-editor.js +57 -21
  110. package/ui/studio-compare.d.ts +14 -4
  111. package/ui/studio-compare.js +58 -24
  112. package/ui/studio-live.d.ts +1 -1
  113. package/ui/studio-live.js +8 -3
  114. package/ui/studio-runner.d.ts +3 -2
  115. package/ui/studio-runner.js +16 -14
  116. package/ui/studio-screen.d.ts +1 -1
  117. package/ui/studio-screen.js +26 -20
  118. package/ui/studio-settings.js +3 -1
  119. package/ui/studio-trace-replay.js +7 -1
  120. package/workspace.js +3 -2
  121. package/page/assets/Banner-CkcwUyOn.js +0 -4
  122. package/page/assets/Center-nHS1JSux.js +0 -1
  123. package/page/assets/browser-connection-DSUHVCT5.js +0 -3
  124. package/page/assets/browser-engine-BXSD3WU8.js +0 -11
  125. package/page/assets/browser-transport-cp9y8bBz.js +0 -45
  126. package/page/assets/index-JWco7tJJ.js +0 -145
  127. package/page/assets/live-messages-CiLmR89m.js +0 -1
  128. package/page/assets/reader-DrOfMM8I.js +0 -5
  129. package/page/assets/shaped-data-H1miOZm2.js +0 -20
  130. package/page/assets/studio-code-pane-B8MOEW9g.js +0 -8
  131. package/page/assets/studio-decision-CjJ_pqdJ.js +0 -1
  132. package/page/assets/studio-embedding-Cq3ePsfC.js +0 -2
  133. package/page/assets/studio-live-DvDQbP5V.js +0 -5
  134. package/page/assets/studio-map-BZFYGG_Y.js +0 -1
  135. package/page/assets/studio-session-CjUQSXx0.js +0 -1
  136. package/page/assets/studio-trace-replay-D22FgUA5.js +0 -3
  137. package/page/assets/tool-schema-BmRYaywn.js +0 -17
  138. package/page/assets/trace-schema-9CdEyG6Q.js +0 -1
  139. package/page/assets/tree-3N-1RPZz.js +0 -3
  140. package/page/assets/turn-client-DN8PawJr.js +0 -2
  141. package/page/assets/workspace-CTSW941G.js +0 -1
@@ -4,31 +4,14 @@
4
4
  */
5
5
  import { useCallback, useSyncExternalStore } from 'react';
6
6
  import { studioPageTools } from "../../mod.js";
7
+ import { choiceValues } from "../../slot-values.js";
7
8
  import { isRecord, session } from "./studio-session.js";
8
9
  const PAGE_PREFIX = 'theorem.studio.v2.page:';
9
- const NO_PAGE_VALUES = { slots: {}, contextJson: '' };
10
+ const NO_PAGE_VALUES = { slots: {}, conditions: {}, contextJson: '' };
10
11
  /** The context a blank preview box suggests. */
11
12
  export const CONTEXT_PLACEHOLDER = `{
12
13
  "page": "Checkout"
13
14
  }`;
14
- function choiceValues(decl) {
15
- if (Array.isArray(decl) &&
16
- decl.length > 0 &&
17
- decl.every((value) => typeof value === 'string' && value.trim() !== '')) {
18
- return decl;
19
- }
20
- if (!isRecord(decl) || !Array.isArray(decl.choices) || decl.choices.length === 0) {
21
- return undefined;
22
- }
23
- const values = [];
24
- for (const choice of decl.choices) {
25
- if (!isRecord(choice) || typeof choice.value !== 'string' || choice.value.trim() === '') {
26
- return undefined;
27
- }
28
- values.push(choice.value);
29
- }
30
- return values;
31
- }
32
15
  /** The slots a draft has so far that a page can pick from: each named, with a value, once. */
33
16
  export function draftSlots(slots) {
34
17
  const seen = new Set();
@@ -57,7 +40,11 @@ export function contextErrorOf(contextJson) {
57
40
  /** What the compiled agent takes from a page, or null when it takes nothing. */
58
41
  export function pageInputsOf(payload) {
59
42
  const { profile } = payload;
60
- if (profile.type === 'decision' || profile.type === 'host' || profile.type === 'embedding') {
43
+ if (profile.type === 'decision' ||
44
+ profile.type === 'host' ||
45
+ profile.type === 'embedding' ||
46
+ profile.type === 'speech' ||
47
+ profile.type === 'transcription') {
61
48
  return null;
62
49
  }
63
50
  const inputs = 'inputs' in profile ? profile.inputs : undefined;
@@ -66,17 +53,25 @@ export function pageInputsOf(payload) {
66
53
  const values = choiceValues(decl);
67
54
  return values ? [[name, values]] : [];
68
55
  }));
56
+ const conditions = profile.identity.conditions ?? {};
69
57
  const takesContext = inputs?.context?.from.includes('client') ?? false;
70
58
  const pageTools = Object.keys(studioPageTools(payload));
71
- if (!Object.keys(slots).length && !takesContext && !pageTools.length)
59
+ const takesNothing = !Object.keys(slots).length && !Object.keys(conditions).length && !takesContext;
60
+ if (takesNothing && !pageTools.length)
72
61
  return null;
73
- return { slots, takesContext, pageTools };
62
+ return { slots, conditions, takesContext, pageTools };
74
63
  }
75
- /** The value a slot sends: the one picked while the profile still lists it, else its first. */
76
- function slotValue(inputs, values, name) {
77
- const allowed = inputs.slots[name] ?? [];
78
- const picked = allowed.find((value) => value === values.slots[name]);
79
- return picked ?? allowed.at(0) ?? '';
64
+ /** The value a pick sends: the one picked while the profile still lists it, else its first. */
65
+ function pickedValue(allowed, picked) {
66
+ return allowed.find((value) => value === picked) ?? allowed.at(0) ?? '';
67
+ }
68
+ /** The turn's path and conditions as picked: the `path` condition is the turn's own path. */
69
+ function statedTurn(inputs, values) {
70
+ const picks = Object.entries(inputs.conditions).map(([name, allowed]) => [name, pickedValue(allowed, values.conditions[name])]);
71
+ if (!picks.length)
72
+ return undefined;
73
+ const { path, ...conditions } = Object.fromEntries(picks);
74
+ return { ...(path === undefined ? {} : { path }), conditions };
80
75
  }
81
76
  /** What goes with a turn or a call. Context that is not JSON is not sent, and says why. */
82
77
  export function sentPageValues(inputs, values) {
@@ -84,13 +79,17 @@ export function sentPageValues(inputs, values) {
84
79
  return {};
85
80
  const names = Object.keys(inputs.slots);
86
81
  const slots = names.length
87
- ? Object.fromEntries(names.map((name) => [name, slotValue(inputs, values, name)]))
82
+ ? Object.fromEntries(names.map((name) => [name, pickedValue(inputs.slots[name] ?? [], values.slots[name])]))
88
83
  : undefined;
84
+ const stated = statedTurn(inputs, values);
85
+ const sent = { slots, ...(stated ? { stated } : {}) };
89
86
  const typed = inputs.takesContext ? values.contextJson.trim() : '';
90
87
  if (!typed)
91
- return { slots };
88
+ return sent;
92
89
  const contextError = contextErrorOf(typed);
93
- return contextError ? { slots, contextError } : { slots, context: JSON.parse(typed) };
90
+ return contextError
91
+ ? { ...sent, contextError }
92
+ : { ...sent, context: JSON.parse(typed) };
94
93
  }
95
94
  function loadPageValues(agentKey) {
96
95
  try {
@@ -99,7 +98,10 @@ function loadPageValues(agentKey) {
99
98
  return NO_PAGE_VALUES;
100
99
  }
101
100
  const slots = Object.fromEntries(Object.entries(kept.slots).filter((entry) => typeof entry[1] === 'string'));
102
- return { slots, contextJson: kept.contextJson };
101
+ const conditions = isRecord(kept.conditions)
102
+ ? Object.fromEntries(Object.entries(kept.conditions).filter((entry) => typeof entry[1] === 'string'))
103
+ : {};
104
+ return { slots, conditions, contextJson: kept.contextJson };
103
105
  }
104
106
  catch {
105
107
  return NO_PAGE_VALUES;
@@ -3,8 +3,10 @@
3
3
  * the page the project's registered profiles and tools as a workspace, and runs each profile's
4
4
  * own code.
5
5
  */
6
+ import type { TranscriptBlock } from '@theoremjs/agents/interface';
7
+ import type { TheoremRewound } from '@theoremjs/web/client';
6
8
  import { type ProjectCode, type StudioAsks, type StudioWorkspace } from '../../mod.ts';
7
- import type { StudioPeopleOffer } from '../../people.ts';
9
+ import { type StudioActingAs, type StudioPeopleOffer } from '../../people.ts';
8
10
  import { type ReadStep } from '../../read-steps.ts';
9
11
  import type { EditedAnswer, OpenAnswer, OpenRequest, ProjectOrigins, ProviderPlace, SaveDone, SaveRefusal, SaveReview, SharedSetting, Unregistered } from '../../server/save-wire.ts';
10
12
  export interface ProjectSession {
@@ -83,6 +85,11 @@ export declare function undoSave(project: ProjectSession): Promise<SaveDone | Sa
83
85
  export declare function openEdited(project: ProjectSession, workspace: StudioWorkspace): Promise<EditedAnswer>;
84
86
  /** Where the local server runs the profile with this id as the builder's edits make it. */
85
87
  export declare function editedProfileEndpoint(project: ProjectSession, profileId: string): string;
88
+ /**
89
+ * A chat that opens on `blocks`, on the project's server: its ref and view. Every load seals with
90
+ * the run's one key, so whichever side goes on opens it.
91
+ */
92
+ export declare function startProjectConversation(project: ProjectSession, profileId: string, blocks: readonly TranscriptBlock[], actingAs: StudioActingAs | undefined): Promise<TheoremRewound>;
86
93
  /** Shows a line of one of the project's files in the editor the builder chose, or the studio command's. */
87
94
  export declare function openInEditor(project: ProjectSession, place: OpenRequest): Promise<OpenAnswer>;
88
95
  /** What a project's files say, which a Save or an edit in the builder's editor changes. */
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import { createContext, useContext } from 'react';
7
7
  import { filesPrint, providersAtStart, } from "../../mod.js";
8
+ import { actingAsHeaders } from "../../people.js";
8
9
  import { READ_STEPS } from "../../read-steps.js";
9
10
  import { projectEndpoint } from "./project-address.js";
10
11
  import { getPref } from "./studio-prefs.js";
@@ -21,7 +22,7 @@ export function projectCode(project, workspace) {
21
22
  origins: project.origins.profiles,
22
23
  };
23
24
  }
24
- export const NO_ASKS = { asked: [], inside: [] };
25
+ export const NO_ASKS = { asked: [], destructive: [], inside: [] };
25
26
  const NO_ORIGINS = { profiles: {}, tools: {}, providers: {} };
26
27
  /** Set while the page has a project open; `null` on the website's own page. */
27
28
  export const ProjectContext = createContext(null);
@@ -86,6 +87,23 @@ export function openEdited(project, workspace) {
86
87
  export function editedProfileEndpoint(project, profileId) {
87
88
  return `${project.endpoint}/edited/profiles/${encodeURIComponent(profileId)}`;
88
89
  }
90
+ /**
91
+ * A chat that opens on `blocks`, on the project's server: its ref and view. Every load seals with
92
+ * the run's one key, so whichever side goes on opens it.
93
+ */
94
+ export async function startProjectConversation(project, profileId, blocks, actingAs) {
95
+ const endpoint = project.profiles.includes(profileId)
96
+ ? projectProfileEndpoint(project, profileId)
97
+ : editedProfileEndpoint(project, profileId);
98
+ const response = await fetch(`${endpoint}/conversation/start`, {
99
+ method: 'POST',
100
+ headers: { 'content-type': 'application/json', ...actingAsHeaders(actingAs) },
101
+ body: JSON.stringify({ blocks }),
102
+ });
103
+ if (!response.ok)
104
+ throw new Error(`The studio server answered ${String(response.status)}.`);
105
+ return response.json();
106
+ }
89
107
  /** Shows a line of one of the project's files in the editor the builder chose, or the studio command's. */
90
108
  export function openInEditor(project, place) {
91
109
  const editor = getPref('editor');
@@ -36,6 +36,8 @@ export interface StoredWorkspace {
36
36
  export interface TabStorage {
37
37
  getItem(name: string): string | null;
38
38
  setItem(name: string, value: string): void;
39
+ /** `setItem` as the page goes: the next load of this tab reads it, whether or not the keep did. */
40
+ setItemLeaving(name: string, value: string): void;
39
41
  removeItem(name: string): void;
40
42
  keys(): string[];
41
43
  }
@@ -7,6 +7,8 @@ export const CHAT_PREFIX = 'theorem.studio.v2.chat:';
7
7
  /** In this tab's sessionStorage: the id its records are kept under. */
8
8
  const TAB_ID = 'theorem.studio.tab';
9
9
  const TAB_LOCK = 'theorem.studio.tab:';
10
+ /** In this tab's sessionStorage: the record the page wrote as it went, until the next load. */
11
+ const LEAVING = 'theorem.studio.leaving';
10
12
  /** Held while a tab claims its records and while a sweep runs, so a sweep never sees a tab half open. */
11
13
  const SWEEP_LOCK = 'theorem.studio.sweep';
12
14
  let open;
@@ -27,6 +29,28 @@ export function tabSession() {
27
29
  return null;
28
30
  }
29
31
  }
32
+ /** Sets aside or clears the record in `LEAVING`. A full or blocked sessionStorage keeps nothing. */
33
+ function setLeaving(record) {
34
+ try {
35
+ if (record)
36
+ tabSession()?.setItem(LEAVING, JSON.stringify(record));
37
+ else
38
+ tabSession()?.removeItem(LEAVING);
39
+ }
40
+ catch {
41
+ // The keep's own write may still land.
42
+ }
43
+ }
44
+ /** The record the last page set aside, if it left one. */
45
+ function readLeaving() {
46
+ try {
47
+ const raw = tabSession()?.getItem(LEAVING);
48
+ return raw ? JSON.parse(raw) : undefined;
49
+ }
50
+ catch {
51
+ return undefined;
52
+ }
53
+ }
30
54
  /** Holds `name` for as long as the page lives, if no one holds it now. */
31
55
  function hold(locks, name) {
32
56
  return new Promise((resolve) => {
@@ -98,11 +122,25 @@ export async function openTabStorage(options = {}) {
98
122
  };
99
123
  const { id, kept } = locks ? await locks.request(SWEEP_LOCK, claim) : await claim();
100
124
  const records = new Map(kept);
125
+ const setItem = (name, value) => {
126
+ records.set(name, value);
127
+ keep.put(id, name, value);
128
+ };
129
+ const leaving = readLeaving();
130
+ if (leaving)
131
+ setItem(leaving.name, leaving.value);
132
+ setLeaving();
101
133
  const storage = {
102
134
  getItem: (name) => records.get(name) ?? null,
103
135
  setItem: (name, value) => {
104
- records.set(name, value);
105
- keep.put(id, name, value);
136
+ setItem(name, value);
137
+ // why: a page brought back from the browser's cache goes on, and this write is newer.
138
+ setLeaving();
139
+ },
140
+ // why: a write to the keep begun on pagehide does not finish before a reload reads it.
141
+ setItemLeaving: (name, value) => {
142
+ setItem(name, value);
143
+ setLeaving({ name, value });
106
144
  },
107
145
  removeItem: (name) => {
108
146
  if (records.delete(name))
@@ -59,6 +59,6 @@ export declare function createStudioStore(initial: RestoredStudio, sites?: Share
59
59
  /** Drops the held change: no agent has it. */
60
60
  cancelShared: () => void;
61
61
  standOn: (files: string) => void;
62
- /** Writes now if a write is pending; the route calls it on pagehide and unmount. */
63
- flush(): void;
62
+ /** Writes now if a write is pending; the route calls it on pagehide, as `isLeaving`, and unmount. */
63
+ flush(isLeaving?: boolean): void;
64
64
  };
@@ -109,7 +109,7 @@ function agentOf(workspace, id) {
109
109
  })?.key;
110
110
  }
111
111
  /** Keeps the workspace, masked, in the tab's records. */
112
- function writeWorkspace(state) {
112
+ function writeWorkspace(state, isLeaving = false) {
113
113
  state.timer = undefined;
114
114
  const record = {
115
115
  v: STUDIO_WORKSPACE_VERSION,
@@ -117,7 +117,11 @@ function writeWorkspace(state) {
117
117
  revision: state.revision,
118
118
  ...(state.files === undefined ? {} : { files: state.files }),
119
119
  };
120
- session()?.setItem(state.slot, JSON.stringify(record));
120
+ const text = JSON.stringify(record);
121
+ if (isLeaving)
122
+ session()?.setItemLeaving(state.slot, text);
123
+ else
124
+ session()?.setItem(state.slot, text);
121
125
  }
122
126
  /** Queues a write, unless one is already queued. */
123
127
  function scheduleWrite(state) {
@@ -378,12 +382,12 @@ export function createStudioStore(initial, sites, toolSites) {
378
382
  state.files = files;
379
383
  scheduleWrite(state);
380
384
  },
381
- /** Writes now if a write is pending; the route calls it on pagehide and unmount. */
382
- flush() {
385
+ /** Writes now if a write is pending; the route calls it on pagehide, as `isLeaving`, and unmount. */
386
+ flush(isLeaving = false) {
383
387
  if (state.timer === undefined)
384
388
  return;
385
389
  clearTimeout(state.timer);
386
- writeWorkspace(state);
390
+ writeWorkspace(state, isLeaving);
387
391
  },
388
392
  };
389
393
  }
@@ -6,6 +6,8 @@ export interface ProbeResult {
6
6
  status?: number;
7
7
  statusText?: string;
8
8
  error?: string;
9
+ /** Why it got no answer: `ssrf_blocked` when the network guard refused the address. */
10
+ code?: string;
9
11
  preview?: string;
10
12
  elapsedMs?: number;
11
13
  tools?: string[];
@@ -1,6 +1,7 @@
1
1
  /**
2
- * One real call to a draft tool, from the server, which reaches public hosts only: the editor's
3
- * Test and th30's `test` action both go through here.
2
+ * One real call to a draft tool, from the server, which reaches public hosts only, or on a project
3
+ * what the agent's network guardrail allows: the editor's Test and th30's `test` action both go
4
+ * through here.
4
5
  */
5
6
  import { HTTP_METHODS } from '@theoremjs/agents';
6
7
  import { draftNetwork } from "../../compile.js";
@@ -12,6 +12,7 @@ export declare const PROFILE_TYPE_ICON: {
12
12
  text: import("react").ForwardRefExoticComponent<import("@tabler/icons-react").IconProps & import("react").RefAttributes<SVGSVGElement>>;
13
13
  image: import("react").ForwardRefExoticComponent<import("@tabler/icons-react").IconProps & import("react").RefAttributes<SVGSVGElement>>;
14
14
  speech: import("react").ForwardRefExoticComponent<import("@tabler/icons-react").IconProps & import("react").RefAttributes<SVGSVGElement>>;
15
+ transcription: import("react").ForwardRefExoticComponent<import("@tabler/icons-react").IconProps & import("react").RefAttributes<SVGSVGElement>>;
15
16
  live: import("react").ForwardRefExoticComponent<import("@tabler/icons-react").IconProps & import("react").RefAttributes<SVGSVGElement>>;
16
17
  decision: import("react").ForwardRefExoticComponent<import("@tabler/icons-react").IconProps & import("react").RefAttributes<SVGSVGElement>>;
17
18
  embedding: import("react").ForwardRefExoticComponent<import("@tabler/icons-react").IconProps & import("react").RefAttributes<SVGSVGElement>>;
@@ -1,4 +1,4 @@
1
- import { IconChartBar, IconChartScatter3d, IconFileSmile, IconGavel, IconHeadset, IconLetterT, IconListCheck, IconMathFunction, IconNumber, IconPhoto, IconServer, IconSquareDashed, IconTool, IconVolume, IconWorld, } from '@tabler/icons-react';
1
+ import { IconChartBar, IconChartScatter3d, IconFileSmile, IconGavel, IconHeadset, IconLetterT, IconListCheck, IconMathFunction, IconMicrophone, IconNumber, IconPhoto, IconServer, IconSquareDashed, IconTool, IconVolume, IconWorld, } from '@tabler/icons-react';
2
2
  import { IconMcp } from "../mcp-icon.js";
3
3
  /** An agent's icon, wherever one shows: the workspace's Agents list, an agent tool, a profile file. */
4
4
  export const AGENT_ICON = IconFileSmile;
@@ -7,6 +7,7 @@ export const PROFILE_TYPE_ICON = {
7
7
  text: IconLetterT,
8
8
  image: IconPhoto,
9
9
  speech: IconVolume,
10
+ transcription: IconMicrophone,
10
11
  live: IconHeadset,
11
12
  decision: IconGavel,
12
13
  embedding: IconChartScatter3d,
@@ -18,7 +18,6 @@ import { SegmentedControl, SegmentedControlItem } from '@astryxdesign/core/Segme
18
18
  import { StackItem } from '@astryxdesign/core/Stack';
19
19
  import { pixel, proportional, Table } from '@astryxdesign/core/Table';
20
20
  import { Text } from '@astryxdesign/core/Text';
21
- import { TextArea } from '@astryxdesign/core/TextArea';
22
21
  import { TextInput } from '@astryxdesign/core/TextInput';
23
22
  import { Thumbnail } from '@astryxdesign/core/Thumbnail';
24
23
  import { Token } from '@astryxdesign/core/Token';
@@ -29,12 +28,13 @@ import { ATTACHMENT_ACCEPT_MIMES, CONTINUE_STOP_KINDS, fieldMeta, HTTP_METHODS,
29
28
  import { BOUNDARIES, BOUNDARY_META, DETECT_ACTION_META, DETECT_ACTIONS, DETECTOR_BOUNDARIES, DETECTOR_GROUP_META, DETECTOR_GROUPS, DETECTOR_META, DETECTORS, TOOL_BOUNDARIES, TOOL_KINDS, } from '@theoremjs/agents/guardrails';
30
29
  import { MODEL_SELECT_MIN_MODELS } from '@theoremjs/agents/interface';
31
30
  import { createContext, lazy, Suspense, useContext, useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore, } from 'react';
32
- import { acceptSections, agentToolTarget, bindingSlots, COMPACTION_DRAFT_DEFAULTS, canSize, defaultEffortRequired, defaultModelRequired, definitionOf, draftAllows, draftKey, expandAccept, GOOGLE_BUILTIN_TOOLS, GOOGLE_IMAGE_ASPECT_RATIOS, GOOGLE_IMAGE_OUTPUT_MIMES, GOOGLE_IMAGE_RESOLUTIONS, GOOGLE_SPEECH_FORMATS, GOOGLE_SPEECH_VOICES, INLINE_LABELS, includableFacets, includeFacet, inputLimitsRequired, isGoogleRoute, isOpenRouterRoute, keptLimits, kernelDefinitions, LABEL_AREAS, LOCAL_PROVIDER_ID, labelAreaOf, lentCompression, MODEL_LIMITS, modelRoute, modelSlots, newCriteria, newCriterion, newDecisionImage, newDecisionQuestion, newModelBinding, newOwnDetector, newPattern, newSlot, newSlotChoice, newToolSpec, nextAccept, onStudioLocal, optionAt, PROFILE_LABEL_KEYS, plantsCanary, protocolOptionFields, removeModelBinding, STUDIO_TRACE_DESTINATION, sampleToolInput, sectionNote, servedProtocols, servesProfileType, setProfileType, studioNetworkNote, studioNodeRef, studioRunsProvider, studioTaintNote, TIMER_MAX_MS, takesContinueInstruction, toolSpecKeyOf, toolSpecNodeId, updateModelBinding, withOption, writeAsk, } from "../mod.js";
31
+ import { acceptSections, agentToolTarget, bindingSlots, COMPACTION_DRAFT_DEFAULTS, canSize, defaultEffortRequired, defaultModelRequired, definitionOf, draftAllows, draftConditions, draftKey, expandAccept, GOOGLE_BUILTIN_TOOLS, GOOGLE_IMAGE_ASPECT_RATIOS, GOOGLE_IMAGE_OUTPUT_MIMES, GOOGLE_IMAGE_RESOLUTIONS, GOOGLE_SPEECH_FORMATS, GOOGLE_SPEECH_VOICES, INLINE_LABELS, includableFacets, includeFacet, inputLimitsRequired, isGoogleRoute, isOpenRouterRoute, keptLimits, kernelDefinitions, LABEL_AREAS, LOCAL_PROVIDER_ID, labelAreaOf, lentCompression, MODEL_LIMITS, modelRoute, modelSlots, newCriteria, newCriterion, newDecisionImage, newDecisionQuestion, newModelBinding, newOwnDetector, newPattern, newSlot, newSlotChoice, newSystemLine, newToolSpec, nextAccept, onStudioLocal, optionAt, PROFILE_LABEL_KEYS, plantsCanary, protocolOptionFields, removeModelBinding, STUDIO_TRACE_DESTINATION, sampleToolInput, sectionNote, servedProtocols, servesProfileType, setProfileType, studioNetworkNote, studioNodeRef, studioRunsProvider, studioTaintNote, TIMER_MAX_MS, takesContinueInstruction, toolSpecKeyOf, toolSpecNodeId, updateModelBinding, withOption, writeAsk, } from "../mod.js";
33
32
  import { AddProviderButton } from "./add-provider.js";
34
33
  import { IconGoogle, IconOpenAi, IconOpenRouter, IconTypeSafe } from "./brand-icons.js";
35
34
  import { ChoiceRow, InspectorGroupTitle, InspectorRow, InspectorSection, ListRow, NamesRow, NumberRow, OriginLine, SegmentedRow, SetInCode, SliderRow, SwitchRow, TextAreaRow, TextRow, } from "./inspector.js";
36
35
  import { ConfirmWrite, GuardrailTest, LeavePage, ListBadges, LocalConnection, NodeIssues, ProjectAsks, QuestionLink, RowOrigins, RunsOn, SaidOrigin, useFieldStatus, useRowOrigin, WorkspaceContext, } from "./inspector-context.js";
37
36
  import { CONTEXT_PLACEHOLDER, contextErrorOf, draftSlots, usePageValues, } from "./lib/studio-page.js";
37
+ import { usePref } from "./lib/studio-prefs.js";
38
38
  import { useProject } from "./lib/studio-project.js";
39
39
  import { setToolCredential, subscribeToolCredentials, toolCredential, } from "./lib/tool-credentials.js";
40
40
  import { runToolProbe } from "./lib/tool-probe.js";
@@ -53,6 +53,11 @@ const PROFILE_TYPE_SEGMENTS = [
53
53
  { value: 'text', label: 'Text', icon: PROFILE_TYPE_ICON.text },
54
54
  { value: 'image', label: 'Image', icon: PROFILE_TYPE_ICON.image },
55
55
  { value: 'speech', label: 'Speech', icon: PROFILE_TYPE_ICON.speech },
56
+ {
57
+ value: 'transcription',
58
+ label: 'Transcription',
59
+ icon: PROFILE_TYPE_ICON.transcription,
60
+ },
56
61
  { value: 'live', label: 'Live', icon: PROFILE_TYPE_ICON.live },
57
62
  { value: 'decision', label: 'Decision', icon: PROFILE_TYPE_ICON.decision },
58
63
  { value: 'embedding', label: 'Embedding', icon: PROFILE_TYPE_ICON.embedding },
@@ -171,11 +176,19 @@ function withNewSections(before, after) {
171
176
  .reduce(includeFacet, after);
172
177
  }
173
178
  function SystemPromptSection({ identity, set, }) {
174
- return (_jsxs(InspectorSection, { title: "System prompt", children: [_jsx(TextArea, { label: "System prompt", isLabelHidden: true, size: "sm", rows: 8, value: identity.system, placeholder: fieldMeta('identity.system')?.unset, onChange: (system) => {
175
- set({ system });
176
- } }), _jsx(TextAreaRow, { label: "By role", path: "identity.systemByRole", field: "systemByRoleJson", value: identity.systemByRoleJson, rows: 4, hasSpellCheck: false, placeholder: SYSTEM_BY_ROLE_PLACEHOLDER, onChange: (systemByRoleJson) => {
177
- set({ systemByRoleJson });
178
- } })] }));
179
+ const { system } = identity;
180
+ const setLine = (key, text) => {
181
+ set({ system: system.map((line) => (line.key === key ? { ...line, text } : line)) });
182
+ };
183
+ return (_jsxs(InspectorSection, { title: "System prompt", children: [system.map((line, at) => (_jsxs(HStack, { gap: 1, vAlign: "start", children: [_jsx(StackItem, { size: "fill", children: _jsx(TextAreaRow, { label: `Line ${String(at + 1)}`, path: "identity.system", field: "system", rows: system.length === 1 ? ONLY_LINE_ROWS : LINE_ROWS, value: line.text, placeholder: fieldMeta('identity.system')?.unset, onChange: (text) => {
184
+ setLine(line.key, text);
185
+ } }) }), system.length > 1 && (_jsx(IconButton, { label: `Remove line ${String(at + 1)}`, variant: "ghost", size: "sm", icon: _jsx(Icon, { icon: IconX, size: "sm" }), onClick: () => {
186
+ set({ system: system.filter(({ key }) => key !== line.key) });
187
+ } }))] }, line.key))), _jsx(HStack, { children: _jsx(Button, { label: "Add line", variant: "ghost", size: "sm", icon: _jsx(Icon, { icon: IconPlus, size: "sm" }), onClick: () => {
188
+ set({ system: [...system, newSystemLine()] });
189
+ } }) }), _jsx(TextAreaRow, { label: "Conditions", path: "identity.conditions", field: "conditionsJson", value: identity.conditionsJson, rows: 4, hasSpellCheck: false, placeholder: CONDITIONS_PLACEHOLDER, onChange: (conditionsJson) => {
190
+ set({ conditionsJson });
191
+ } }), _jsx(ConditionPreviewRows, { conditionsJson: identity.conditionsJson })] }));
179
192
  }
180
193
  function IdentityEditor({ draft, setDraft }) {
181
194
  const keys = useLentKeys();
@@ -189,6 +202,7 @@ function IdentityEditor({ draft, setDraft }) {
189
202
  } }), identity.profileType !== 'host' && (_jsx(TextRow, { label: "Handle", path: "identity.handle", field: "handle", value: identity.handle, placeholder: "agent", maxLength: PROFILE_HANDLE_MAX_CHARS, onChange: (handle) => {
190
203
  set({ handle });
191
204
  } }))] }), identity.profileType !== 'speech' &&
205
+ identity.profileType !== 'transcription' &&
192
206
  identity.profileType !== 'decision' &&
193
207
  identity.profileType !== 'host' && _jsx(SystemPromptSection, { identity: identity, set: set })] }));
194
208
  }
@@ -506,6 +520,10 @@ function ProtocolOptionRow({ option, binding, set, }) {
506
520
  return (_jsx(NumberRow, { ...common, value: typeof value === 'number' ? value : null, hint: option.description, onChange: (next) => {
507
521
  write(next ?? undefined);
508
522
  } }));
523
+ case 'names':
524
+ return (_jsx(NamesRow, { label: option.label, path: "models.*.options", field: field, value: Array.isArray(value) ? value.filter((name) => typeof name === 'string') : [], onChange: (next) => {
525
+ write(next.length ? next : undefined);
526
+ } }));
509
527
  case 'text':
510
528
  return (_jsx(TextRow, { ...common, value: typeof value === 'string' ? value : '', hint: option.description, onChange: (next) => {
511
529
  write(next || undefined);
@@ -660,13 +678,13 @@ function AcceptRow({ label, path, value, picker, hasSizes, onChange, }) {
660
678
  const unset = fieldMeta(path)?.unset;
661
679
  return (_jsx(InspectorRow, { label: label, path: path, hasIssue: status !== undefined, hasNote: Boolean(status?.message), children: _jsx(StackItem, { size: "fill", children: _jsx(ComplexSelector, { label: label, isLabelHidden: true, size: "sm", placement: "below", status: status, value: value, triggerLabel: value.accept.length ? _jsx(AcceptTokens, { ...value }) : undefined, placeholder: unset, onChange: onChange, children: (current, change) => (_jsx(AcceptGrid, { current: current, change: change, picker: picker, hasSizes: hasSizes })) }) }) }));
662
680
  }
663
- function InputAcceptsSection({ inputs, set, image, hasSizes, }) {
681
+ function InputAcceptsSection({ inputs, set, image, voiceOnly, hasSizes, }) {
664
682
  const attachmentPicker = image ? IMAGE_ATTACHMENT_PICKER : ATTACHMENT_PICKER;
665
- return (_jsxs(InspectorSection, { title: "Accepts", path: "inputs", children: [_jsx(SwitchRow, { label: "Text", path: "inputs.text", value: inputs.text, onChange: (text) => {
666
- set({ text });
667
- } }), _jsx(AcceptRow, { label: "Attachments", path: "inputs.attachments.accept", value: { accept: inputs.attachmentsAccept, limits: inputs.limitsByMime }, picker: attachmentPicker, hasSizes: hasSizes, onChange: ({ accept, limits }) => {
668
- set({ attachmentsAccept: accept, limitsByMime: limits });
669
- } }), !image && (_jsx(AcceptRow, { label: "Voice", path: "inputs.voice.accept", value: { accept: inputs.voiceAccept, limits: inputs.limitsByMime }, picker: VOICE_PICKER, hasSizes: hasSizes, onChange: ({ accept, limits }) => {
683
+ return (_jsxs(InspectorSection, { title: "Accepts", path: "inputs", children: [!voiceOnly && (_jsxs(_Fragment, { children: [_jsx(SwitchRow, { label: "Text", path: "inputs.text", value: inputs.text, onChange: (text) => {
684
+ set({ text });
685
+ } }), _jsx(AcceptRow, { label: "Attachments", path: "inputs.attachments.accept", value: { accept: inputs.attachmentsAccept, limits: inputs.limitsByMime }, picker: attachmentPicker, hasSizes: hasSizes, onChange: ({ accept, limits }) => {
686
+ set({ attachmentsAccept: accept, limitsByMime: limits });
687
+ } })] })), !image && (_jsx(AcceptRow, { label: "Voice", path: "inputs.voice.accept", value: { accept: inputs.voiceAccept, limits: inputs.limitsByMime }, picker: VOICE_PICKER, hasSizes: hasSizes, onChange: ({ accept, limits }) => {
670
688
  set({ voiceAccept: accept, limitsByMime: limits });
671
689
  } }))] }));
672
690
  }
@@ -715,6 +733,15 @@ function SlotPreviewRows({ slots }) {
715
733
  setValues({ ...values, slots: { ...values.slots, [name]: next } });
716
734
  } }, name)));
717
735
  }
736
+ /** The value the studio's page states for each condition declared so far. Kept in this tab. */
737
+ function ConditionPreviewRows({ conditionsJson }) {
738
+ const [values, setValues] = usePageValues(useContext(WorkspaceContext)?.self ?? '');
739
+ return Object.entries(draftConditions(conditionsJson)).map(([name, allowed]) => (_jsx(ChoiceRow, { label: name, path: "identity.conditions", isRequired: true, value: allowed.find((value) => value === values.conditions[name]) ?? allowed[0], options: allowed, onChange: (next) => {
740
+ if (next) {
741
+ setValues({ ...values, conditions: { ...values.conditions, [name]: next } });
742
+ }
743
+ } }, name)));
744
+ }
718
745
  /** One of a slot's choices: the value a turn sends, what the page says of it, and a remove button. */
719
746
  function SlotChoiceRow({ choice, at, onChange, onRemove, }) {
720
747
  return (_jsxs(HStack, { gap: 1, vAlign: "center", children: [_jsx("div", { className: "criterion-label", children: _jsx(TextInput, { label: `Choice ${String(at + 1)} value`, isLabelHidden: true, size: "sm", value: choice.value, placeholder: "value", onChange: (value) => {
@@ -770,11 +797,15 @@ function InputsEditor({ draft, setDraft }) {
770
797
  const set = patch(setDraft, 'inputs');
771
798
  /** An image profile takes images, video, and PDF as references, and no voice. */
772
799
  const image = draft.identity.profileType === 'image';
773
- return (_jsxs(_Fragment, { children: [draftAllows(draft, 'inputs.attachments.accept') && (_jsx(InputAcceptsSection, { inputs: inputs, set: set, image: image, hasSizes: draftAllows(draft, 'inputs.limitsByMime') })), draftAllows(draft, 'inputs.maxFiles') && _jsx(InputLimitsSection, { inputs: inputs, set: set }), draftAllows(draft, 'inputs.context') && _jsx(InputContextSection, { inputs: inputs, set: set }), _jsx(InputSlotsSections, { inputs: inputs, set: set })] }));
800
+ const voiceOnly = !draftAllows(draft, 'inputs.attachments.accept');
801
+ return (_jsxs(_Fragment, { children: [(!voiceOnly || draftAllows(draft, 'inputs.voice')) && (_jsx(InputAcceptsSection, { inputs: inputs, set: set, image: image, voiceOnly: voiceOnly, hasSizes: draftAllows(draft, 'inputs.limitsByMime') })), draftAllows(draft, 'inputs.maxFiles') && _jsx(InputLimitsSection, { inputs: inputs, set: set }), draftAllows(draft, 'inputs.context') && _jsx(InputContextSection, { inputs: inputs, set: set }), draftAllows(draft, 'inputs.slots') && _jsx(InputSlotsSections, { inputs: inputs, set: set })] }));
774
802
  }
775
- const SYSTEM_BY_ROLE_PLACEHOLDER = `{
776
- "support": "Answer as the support desk."
803
+ const CONDITIONS_PLACEHOLDER = `{
804
+ "plan": ["free", "paid"]
777
805
  }`;
806
+ /** How tall a prompt line starts: one line alone is the whole prompt. */
807
+ const ONLY_LINE_ROWS = 8;
808
+ const LINE_ROWS = 3;
778
809
  /** The agents another agent can name: every one but itself, each by its id. */
779
810
  function otherAgents(agents, self, canName) {
780
811
  return agents
@@ -1970,8 +2001,12 @@ function ToolLoadingSection({ value, loaders, set, }) {
1970
2001
  }
1971
2002
  const MS = new Intl.NumberFormat('en-US', { style: 'unit', unit: 'millisecond' });
1972
2003
  /** The result's headline: the status line, or for an MCP server, what it offers. */
1973
- function probeTitle(result, tool) {
2004
+ function probeTitle(result, tool, inProject) {
1974
2005
  const took = result.elapsedMs === undefined ? '' : ` · ${MS.format(result.elapsedMs)}`;
2006
+ // why: on a project the test keeps to the agent's guardrail, as its runs do; the way out is there.
2007
+ if (inProject && result.code === 'ssrf_blocked') {
2008
+ return "This agent's network guardrail doesn't allow this address, so a run couldn't call it either. Change it in Guardrails, under Network.";
2009
+ }
1975
2010
  if (!result.ok && result.error)
1976
2011
  return result.error;
1977
2012
  if (tool.toolType === 'mcp' && result.tools) {
@@ -2048,6 +2083,7 @@ function ToolTest({ tool, guardrails }) {
2048
2083
  const shown = useContext(ShownProbe);
2049
2084
  const [result, setResult] = useState(shown);
2050
2085
  const http = tool.toolType === 'http';
2086
+ const inProject = useProject() !== null;
2051
2087
  const method = tool.method ?? HTTP_METHODS[0];
2052
2088
  // A result answers the request as it was: once what it reaches or sends changes, it's dropped.
2053
2089
  const target = probeTarget(tool, method);
@@ -2072,7 +2108,7 @@ function ToolTest({ tool, guardrails }) {
2072
2108
  };
2073
2109
  return (_jsxs(InspectorSection, { title: "Test", note: http ? sectionNote('tool.test.http', { method }) : sectionNote('tool.test.mcp'), children: [http && _jsx(SampleInputRow, { value: sampleInput, onChange: setTypedInput }), (tool.authType ?? 'none') !== 'none' && (_jsx(TestCredentialRow, { value: credential, onChange: setCredential })), _jsx(TestConnectionButton, { isLoading: pending, onClick: () => {
2074
2110
  void run();
2075
- } }), result && (_jsx(Banner, { status: probeStatus(result), title: probeTitle(result, tool), description: probeDetails(result) }))] }));
2111
+ } }), result && (_jsx(Banner, { status: probeStatus(result), title: probeTitle(result, tool, inProject), description: probeDetails(result) }))] }));
2076
2112
  }
2077
2113
  /** The tool types offered: an agent tool only where there are agents to run. */
2078
2114
  function toolTypeSegments(workspace) {
@@ -2244,8 +2280,8 @@ function AuthSection({ tool, set }) {
2244
2280
  } }), authType !== 'none' && _jsx(AuthCredentialRows, { tool: tool, authType: authType, set: set }), authType === 'oauth2' && _jsx(OAuthRows, { tool: tool, set: set })] }));
2245
2281
  }
2246
2282
  /** What the studio does about a tool that writes, when that is not what Permission says. */
2247
- function studioAskNote(asks, tool) {
2248
- if (asks.asked.includes(tool))
2283
+ function studioAskNote(asks, tool, askWrites) {
2284
+ if ((askWrites === 'destructive' ? asks.destructive : asks.asked).includes(tool))
2249
2285
  return 'In the studio this tool asks before every run, because it writes. Your application runs it as Permission says.';
2250
2286
  if (asks.inside.includes(tool))
2251
2287
  return 'This tool writes, and the studio cannot make it ask: a called agent runs it, and a question inside a called agent has no one to answer it. The call to that agent asks instead.';
@@ -2253,7 +2289,7 @@ function studioAskNote(asks, tool) {
2253
2289
  }
2254
2290
  /** Who may call the tool, whether it asks first, when it loads and on which paths. */
2255
2291
  function PolicySection({ draft, tool, set, }) {
2256
- const note = studioAskNote(useContext(ProjectAsks), tool.toolName);
2292
+ const note = studioAskNote(useContext(ProjectAsks), tool.toolName, usePref('askWrites'));
2257
2293
  return (_jsxs(InspectorSection, { title: "Policy", note: note, children: [_jsx(SegmentedRow, { label: "Access", path: "registerTool.access", field: "access", value: tool.access, segments: ACCESS_SEGMENTS, onChange: (access) => {
2258
2294
  set({ access });
2259
2295
  } }), _jsx(SegmentedRow, { label: "Permission", path: "registerTool.permission", field: "permission", value: tool.permission, segments: PERMISSION_SEGMENTS, onChange: (permission) => {
@@ -1,6 +1,6 @@
1
- import { type TheoremChatHandle } from '@theoremjs/react/ui';
2
- import { type TraceFeed } from '@theoremjs/web/client';
3
- import { type ReactNode, type Ref } from 'react';
1
+ import { TheoremChat, type TheoremChatHandle } from '@theoremjs/react/ui';
2
+ import { type StatedTurn, type TraceFeed } from '@theoremjs/web/client';
3
+ import { type ComponentProps, type ReactNode, type Ref } from 'react';
4
4
  import { type StudioWorkspace } from '../mod.ts';
5
5
  import type { EditedAnswer, SaveRefusal } from '../server/save-wire.ts';
6
6
  import { type ProjectSession } from './lib/studio-project.ts';
@@ -18,6 +18,11 @@ export declare function useEditedLoad(project: ProjectSession, edits: StudioWork
18
18
  * standing under the refusal, so the edited side keeps what it showed; with no edits, none.
19
19
  */
20
20
  export declare function useLoadedStamp(answer: EditedAnswer | undefined): string | undefined;
21
+ /**
22
+ * What the edited side states. While edits load it still runs the last load, which refuses a
23
+ * condition only the new edits declare, so it states what that load declares.
24
+ */
25
+ export declare function useLoadedStated(stated: StatedTurn | undefined, isLoaded: boolean): StatedTurn | undefined;
21
26
  /** Whether the builder put the files' side away: the edits then run alone. */
22
27
  export declare function useSavedHidden(): boolean;
23
28
  /**
@@ -40,7 +45,8 @@ export declare function SavedSide({ isCompared, children, }: {
40
45
  isCompared?: boolean;
41
46
  children: ReactNode;
42
47
  }): import("react").JSX.Element;
43
- export interface ProjectChatProps {
48
+ export /** What a chat resumes and starts with; the page keeps its conversation through these. */ type ChatStart = Pick<ComponentProps<typeof TheoremChat>, 'conversation' | 'conversationView' | 'initialText' | 'initialFiles' | 'initialVoice' | 'initialPending' | 'onConversationChange'>;
49
+ export interface ProjectChatProps extends ChatStart {
44
50
  project: ProjectSession;
45
51
  /** The id of the profile the page chats with, as its edits name it. */
46
52
  profileId: string;
@@ -54,6 +60,10 @@ export interface ProjectChatProps {
54
60
  chatRef?: Ref<TheoremChatHandle>;
55
61
  /** The value the page picked for each slot. */
56
62
  slots?: Record<string, string>;
63
+ /** What the edited side states, of the profile the edits make. */
64
+ stated?: StatedTurn;
65
+ /** What the files' side states, of the profile the files hold. */
66
+ savedStated?: StatedTurn;
57
67
  /** What the page tells the agent. */
58
68
  context?: unknown;
59
69
  }