@theoremjs/studio 0.3.4-next.693.g4ab1526 → 0.3.4-next.715.geef22fd

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/agreement.js +35 -5
  2. package/compile.d.ts +3 -3
  3. package/compile.js +43 -20
  4. package/cookbooks/catalog.js +8 -10
  5. package/draft.d.ts +12 -9
  6. package/draft.js +4 -4
  7. package/mod.d.ts +1 -2
  8. package/mod.js +1 -2
  9. package/package.json +4 -4
  10. package/page/assets/Banner-CrhjYjDy.js +3 -0
  11. package/page/assets/{ConsoleFrame-BvgFGqp2.js → ConsoleFrame-dOTqIkpb.js} +1 -1
  12. package/page/assets/{MenuBottomSheet-BZecY8fw.js → MenuBottomSheet-DeuZCVb-.js} +1 -1
  13. package/page/assets/{SchemaFields-BNNkvyyO.js → SchemaFields-DeuNDrvj.js} +1 -1
  14. package/page/assets/{ToolResultCharts-C3CPsfXl.js → ToolResultCharts-B-pokquL.js} +1 -1
  15. package/page/assets/{TraceInspector-36e6ozKD.js → TraceInspector-CvJ0wx9n.js} +1 -1
  16. package/page/assets/{TraceOverview-CSdJ_cYY.js → TraceOverview-cIjJwpvK.js} +1 -1
  17. package/page/assets/{_virtual_studio-type-sources-DSpwr3WK.js → _virtual_studio-type-sources-BxnDf9BC.js} +225 -85
  18. package/page/assets/browser-connection-CuWeoI9s.js +3 -0
  19. package/page/assets/browser-engine-C3SeJyrA.js +13 -0
  20. package/page/assets/{browser-transport-GzhRiBdm.js → browser-transport-DKhZ4zo1.js} +3 -3
  21. package/page/assets/{crypto-B8dqEoWf.js → crypto-BnoW7FFO.js} +1 -1
  22. package/page/assets/{encode-files-CHeRLBO8.js → encode-files-DoLGXgup.js} +1 -1
  23. package/page/assets/{export-agent-botXSyoH.js → export-agent-CO4lAMum.js} +1 -1
  24. package/page/assets/{guardrail-tester-DYR7EPIy.js → guardrail-tester-Slctc2oI.js} +1 -1
  25. package/page/assets/{index-B7sK7d-l.js → index-CAK9cdCh.js} +72 -76
  26. package/page/assets/{labels-provider-t4c-5JMk.js → labels-provider-uONlWExD.js} +1 -1
  27. package/page/assets/{live-messages-DN_q2nBN.js → live-messages-M0vS3YB0.js} +1 -1
  28. package/page/assets/people-CIsR0-5R.js +1 -0
  29. package/page/assets/reader-747-Cvu8.js +5 -0
  30. package/page/assets/{shaped-data-CJQ3W_RE.js → shaped-data-7q5Be8sp.js} +3 -3
  31. package/page/assets/{stub-U6wDGe3P.js → stub--LOYiyQO.js} +1 -1
  32. package/page/assets/studio-code-pane-CuccT4Ur.js +10 -0
  33. package/page/assets/{studio-console-B7zL133d.js → studio-console-DwxLzV9_.js} +1 -1
  34. package/page/assets/{studio-decision-CbRjfbvG.js → studio-decision-w6OjVUM3.js} +1 -1
  35. package/page/assets/{studio-embedding-DQ0QrEsu.js → studio-embedding-CxFoTvOd.js} +1 -1
  36. package/page/assets/studio-host-console-BhQSkUhA.js +2 -0
  37. package/page/assets/{studio-labels-jYWBoEyP.js → studio-labels-q6eBFSru.js} +1 -1
  38. package/page/assets/{studio-live-D0YRu2zQ.js → studio-live-D5NjMEky.js} +1 -1
  39. package/page/assets/{studio-map-C4Ra1QqL.js → studio-map-DlkGoGam.js} +1 -1
  40. package/page/assets/studio-session-ClF2iNCX.js +1 -0
  41. package/page/assets/{studio-trace-replay-D-f2p7k9.js → studio-trace-replay-Ccv4ToIz.js} +1 -1
  42. package/page/assets/{studio-type-checker-CVNPnko-.js → studio-type-checker-Dm2eit0p.js} +1 -1
  43. package/page/assets/{tool-schema-BDG2_rlP.js → tool-schema-6RWBAqGO.js} +2 -2
  44. package/page/assets/{trace-record-DoXjxrmJ.js → trace-record-Dm2jEhUR.js} +1 -1
  45. package/page/assets/tree-DcCW259J.js +3 -0
  46. package/page/assets/turn-client-OLK12Fyi.js +2 -0
  47. package/page/assets/{use-one-call-B3t-kfc5.js → use-one-call-CLndFp2X.js} +1 -1
  48. package/page/assets/use-second-ticker-D6JSf9B3.js +1 -0
  49. package/page/assets/{workspace-DUfaxr-g.js → workspace-DSAX72vF.js} +1 -1
  50. package/page/index.html +18 -17
  51. package/read-source.js +41 -8
  52. package/registrations.d.ts +9 -1
  53. package/runtime.js +1 -0
  54. package/section-notes.d.ts +1 -0
  55. package/section-notes.js +1 -0
  56. package/serve-page.mjs +8 -4
  57. package/server/handler.d.ts +0 -3
  58. package/server/handler.js +4 -26
  59. package/server/live.d.ts +1 -2
  60. package/server/live.js +3 -4
  61. package/server/save-plan.js +2 -1
  62. package/system-markup.d.ts +9 -7
  63. package/system-markup.js +38 -19
  64. package/tools.js +1 -0
  65. package/types.d.ts +3 -0
  66. package/ui/inspector-context.d.ts +1 -8
  67. package/ui/inspector-context.js +0 -7
  68. package/ui/inspector.d.ts +43 -1
  69. package/ui/inspector.js +50 -9
  70. package/ui/lib/entries.d.ts +13 -0
  71. package/ui/lib/entries.js +43 -0
  72. package/ui/lib/project-traces.js +2 -10
  73. package/ui/lib/studio-prefs.d.ts +0 -4
  74. package/ui/lib/studio-prefs.js +0 -7
  75. package/ui/lib/studio-project.d.ts +2 -5
  76. package/ui/lib/studio-project.js +1 -4
  77. package/ui/profile-editor.js +37 -49
  78. package/ui/studio-screen.d.ts +0 -1
  79. package/ui/studio-screen.js +8 -18
  80. package/ui/studio-settings.js +1 -12
  81. package/asks.d.ts +0 -61
  82. package/asks.js +0 -78
  83. package/page/assets/Banner-DrRNC3MG.js +0 -4
  84. package/page/assets/browser-connection-dads1eyK.js +0 -3
  85. package/page/assets/browser-engine-CugH58NS.js +0 -13
  86. package/page/assets/reader-DHN96tSr.js +0 -5
  87. package/page/assets/studio-code-pane-Boy63AK2.js +0 -8
  88. package/page/assets/studio-host-console-DDA2Um2-.js +0 -2
  89. package/page/assets/studio-session-CPnJaHc-.js +0 -1
  90. package/page/assets/tree-CcEbNvms.js +0 -3
  91. package/page/assets/turn-client-BmOSpCgw.js +0 -2
  92. package/page/assets/use-second-ticker-CWjCHLG6.js +0 -1
  93. package/ui/confirm-write.d.ts +0 -12
  94. package/ui/confirm-write.js +0 -45
@@ -1,20 +1,22 @@
1
- import type { SystemPrompt } from '@theoremjs/agents/kernel';
1
+ import type { SystemPart, SystemPrompt } from '@theoremjs/agents/kernel';
2
2
  /**
3
- * The studio's way to write a system prompt with private sections: the
4
- * whole prompt as text, each private section wrapped as `{private: …}`.
3
+ * The studio's way to write a system prompt: the whole prompt as text, a blank
4
+ * line starting a new line, each private section wrapped as `{private: …}`.
5
5
  */
6
6
  type SystemMarkup = {
7
7
  ok: true;
8
- prompt: SystemPrompt | undefined;
8
+ lines: SystemPrompt[];
9
9
  } | {
10
10
  ok: false;
11
11
  message: string;
12
12
  };
13
+ /** A line as the profile holds it, without the white space at its ends. */
14
+ declare function promptLine(parts: readonly SystemPart[]): SystemPrompt | undefined;
13
15
  /**
14
16
  * A section closes at the `}` that balances its `{`, so braces inside it pair
15
- * up as written. Its text is trimmed; the text around it is kept as written,
16
- * apart from the ends of the whole prompt.
17
+ * up as written, and a blank line inside it stays in it. Its text is trimmed;
18
+ * the text around it is kept as written, apart from the ends of each line.
17
19
  */
18
20
  declare function parseSystemMarkup(text: string): SystemMarkup;
19
21
  export type { SystemMarkup };
20
- export { parseSystemMarkup };
22
+ export { parseSystemMarkup, promptLine };
package/system-markup.js CHANGED
@@ -1,14 +1,34 @@
1
1
  const OPEN = /\{\s*private\s*:/g;
2
- function lineAt(text, index) {
3
- return text.slice(0, index).split('\n').length;
2
+ const BLANK_LINE = /\n(?:[ \t]*\n)+/;
3
+ /** A line as the profile holds it, without the white space at its ends. */
4
+ function promptLine(parts) {
5
+ const [first, ...rest] = parts;
6
+ if (first === undefined)
7
+ return undefined;
8
+ if (rest.length === 0 && typeof first === 'string')
9
+ return first.trim() || undefined;
10
+ const line = [...parts];
11
+ const last = parts.at(-1);
12
+ if (typeof first === 'string')
13
+ line[0] = first.trimStart();
14
+ if (typeof last === 'string')
15
+ line[line.length - 1] = last.trimEnd();
16
+ const kept = line.filter((part) => part !== '');
17
+ const [only, ...others] = kept;
18
+ return others.length === 0 && typeof only === 'string' ? only : kept;
4
19
  }
5
20
  /**
6
21
  * A section closes at the `}` that balances its `{`, so braces inside it pair
7
- * up as written. Its text is trimmed; the text around it is kept as written,
8
- * apart from the ends of the whole prompt.
22
+ * up as written, and a blank line inside it stays in it. Its text is trimmed;
23
+ * the text around it is kept as written, apart from the ends of each line.
9
24
  */
10
25
  function parseSystemMarkup(text) {
11
- const parts = [];
26
+ const lines = [[]];
27
+ const addText = (chunk) => {
28
+ const [head = '', ...rest] = chunk.split(BLANK_LINE);
29
+ lines.at(-1)?.push(head);
30
+ lines.push(...rest.map((line) => [line]));
31
+ };
12
32
  let at = 0;
13
33
  for (const open of text.matchAll(OPEN)) {
14
34
  if (open.index < at)
@@ -21,31 +41,30 @@ function parseSystemMarkup(text) {
21
41
  else if (text[close] === '}')
22
42
  depth--;
23
43
  }
44
+ addText(text.slice(at, open.index));
24
45
  if (depth > 0) {
25
46
  return {
26
47
  ok: false,
27
- message: `The {private: section on line ${String(lineAt(text, open.index))} has no closing }.`,
48
+ message: `The {private: section on line ${String(lines.length)} has no closing }.`,
28
49
  };
29
50
  }
30
51
  const secret = text.slice(open.index + open[0].length, close - 1).trim();
31
52
  if (!secret) {
32
53
  return {
33
54
  ok: false,
34
- message: `The {private: section on line ${String(lineAt(text, open.index))} is empty.`,
55
+ message: `The {private: section on line ${String(lines.length)} is empty.`,
35
56
  };
36
57
  }
37
- parts.push(text.slice(at, open.index), { private: secret });
58
+ lines.at(-1)?.push({ private: secret });
38
59
  at = close;
39
60
  }
40
- parts.push(text.slice(at));
41
- if (parts.length === 1)
42
- return { ok: true, prompt: text.trim() || undefined };
43
- const first = parts[0];
44
- const last = parts.at(-1);
45
- if (typeof first === 'string')
46
- parts[0] = first.trimStart();
47
- if (typeof last === 'string')
48
- parts[parts.length - 1] = last.trimEnd();
49
- return { ok: true, prompt: parts.filter((part) => part !== '') };
61
+ addText(text.slice(at));
62
+ return {
63
+ ok: true,
64
+ lines: lines.flatMap((parts) => {
65
+ const line = promptLine(parts.filter((part) => part !== ''));
66
+ return line === undefined ? [] : [line];
67
+ }),
68
+ };
50
69
  }
51
- export { parseSystemMarkup };
70
+ export { parseSystemMarkup, promptLine };
package/tools.js CHANGED
@@ -23,6 +23,7 @@ export function registerCustomTool(tools, tool, handlers = {}) {
23
23
  permission: tool.permission,
24
24
  ...(tool.labels ? { labels: tool.labels } : {}),
25
25
  ...(tool.after ? { after: true } : {}),
26
+ ...(tool.background ? { background: tool.background } : {}),
26
27
  };
27
28
  if (tool.type === 'agent') {
28
29
  tools.register({
package/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { ToolBackground } from '@theoremjs/agents/kernel';
1
2
  import { type AuthUnauthenticatedPolicy, type CustomToolType, type HttpMethod, type StudioAuthType, type ToolAccess, type ToolLoadTier, type ToolPermission } from '@theoremjs/agents/schema';
2
3
  /** The tool types a studio draft builds. */
3
4
  export type StudioToolType = CustomToolType;
@@ -26,6 +27,8 @@ export type StudioToolSpecSeed = {
26
27
  answeredBy?: 'page';
27
28
  /** The model can name tools of its step that finish before this one starts. */
28
29
  after?: boolean;
30
+ /** When the model gets its reply while the body goes on. */
31
+ background?: ToolBackground;
29
32
  endpoint?: string;
30
33
  method?: HttpMethod;
31
34
  headersJson?: string;
@@ -1,5 +1,5 @@
1
1
  import type { InputStatus } from '@astryxdesign/core/Field';
2
- import { type NodeOrigins, type StudioAsks, type StudioIssue, type StudioProvider, type StudioRunPayload, type StudioRunsOn, type WriteAsk } from '../mod.ts';
2
+ import { type NodeOrigins, type StudioIssue, type StudioProvider, type StudioRunPayload, type StudioRunsOn } from '../mod.ts';
3
3
  import type { SettingOrigin } from '../server/save-wire.ts';
4
4
  /** The compile issues for the node being edited; rows show the ones on their field. */
5
5
  export declare const NodeIssues: import("react").Context<readonly StudioIssue[]>;
@@ -16,13 +16,6 @@ export declare const RowOrigins: import("react").Context<{
16
16
  scope: NodeOrigins;
17
17
  open: (origin: SettingOrigin) => void;
18
18
  } | null>;
19
- /**
20
- * Asks the builder before a real run of a tool that writes, and answers whether to run it. Where
21
- * no page mounts the question, the run is refused.
22
- */
23
- export declare const ConfirmWrite: import("react").Context<(ask: WriteAsk) => Promise<boolean>>;
24
- /** The project's tools that write: the ones the studio makes ask, and the ones it cannot. */
25
- export declare const ProjectAsks: import("react").Context<StudioAsks>;
26
19
  /** The origin a section around a row has already named, so the row does not name it again. */
27
20
  export declare const SaidOrigin: import("react").Context<SettingOrigin | undefined>;
28
21
  /**
@@ -23,13 +23,6 @@ export function useFieldStatus() {
23
23
  * builder's editor. `null` when no project is open, or the files do not hold the node.
24
24
  */
25
25
  export const RowOrigins = createContext(null);
26
- /**
27
- * Asks the builder before a real run of a tool that writes, and answers whether to run it. Where
28
- * no page mounts the question, the run is refused.
29
- */
30
- export const ConfirmWrite = createContext(() => Promise.resolve(false));
31
- /** The project's tools that write: the ones the studio makes ask, and the ones it cannot. */
32
- export const ProjectAsks = createContext({ asked: [], destructive: [], inside: [] });
33
26
  /** The origin a section around a row has already named, so the row does not name it again. */
34
27
  export const SaidOrigin = createContext(undefined);
35
28
  /**
package/ui/inspector.d.ts CHANGED
@@ -3,6 +3,16 @@ import { type IconType } from '@astryxdesign/core/Icon';
3
3
  import { type SelectorOptionType } from '@astryxdesign/core/Selector';
4
4
  import { type ReactNode } from 'react';
5
5
  import type { SettingOrigin } from '../server/save-wire.ts';
6
+ /**
7
+ * Inspector building blocks: captioned sections of label-and-control rows, after Astryx's
8
+ * canvas editor template. Every control is `sm` and hides its own label, because the row's
9
+ * label column names it; that column is one fixed width, so every control starts on one edge.
10
+ */
11
+ /**
12
+ * The label column, wide enough for the longest label ("Temperature", "Attachments") on one line.
13
+ * The template's is 80, which fits its shorter labels.
14
+ */
15
+ export declare const LABEL_COLUMN = 96;
6
16
  /**
7
17
  * Controls the project's files set in code: they show their value and take no edit. A disabled
8
18
  * fieldset turns off every control inside it, whatever kind it is.
@@ -65,6 +75,24 @@ export type FieldRowProps = {
65
75
  /** The draft field whose issues show on this row. */
66
76
  field?: string;
67
77
  } & IsRequired;
78
+ /**
79
+ * The names and values of an object the draft holds as JSON text, a row each. The rows are kept
80
+ * here while they are typed, since a row with no name is no part of the object yet, and start
81
+ * again from `value` when something else changes it. `typed` takes any JSON as a value.
82
+ */
83
+ export declare function EntriesRow({ label, noun, path, field, value, typed, namePlaceholder, valuePlaceholder, onChange, }: {
84
+ label: string;
85
+ /** What one row is: "Header" gives "Add header" and "Header 1 name". */
86
+ noun: string;
87
+ path: string;
88
+ /** The draft field whose issues show on this row. */
89
+ field: string;
90
+ value: string;
91
+ typed?: boolean;
92
+ namePlaceholder: string;
93
+ valuePlaceholder: string;
94
+ onChange: (next: string) => void;
95
+ }): import("react").JSX.Element;
68
96
  /**
69
97
  * Free text. Left blank, it shows `placeholder`, a value Tab takes up to edit (an example, or the
70
98
  * default); else `hint`, or what leaving it out does.
@@ -197,6 +225,8 @@ export type ChoiceRowProps<T extends string> = {
197
225
  value: T | '';
198
226
  options: readonly Choice<T>[];
199
227
  isDisabled?: boolean;
228
+ /** False for a choice that always holds a value, so it offers no way to clear it. */
229
+ hasClear?: boolean;
200
230
  hasSearch?: boolean;
201
231
  /** The options are still arriving. */
202
232
  isLoading?: boolean;
@@ -215,7 +245,7 @@ export type ChoiceRowProps<T extends string> = {
215
245
  * leaving it out does while blank. `hasSearch` filters a long list. A value the list leaves out
216
246
  * shows as itself, marked "Not in the list", so a list never hides or rewrites what the file says.
217
247
  */
218
- export declare function ChoiceRow<T extends string>({ label, path, field, value, options, isDisabled, isRequired, hasSearch, isLoading, emptyText, placeholder, status: given, hasHoverDescriptions, onChange, }: ChoiceRowProps<T>): import("react").JSX.Element;
248
+ export declare function ChoiceRow<T extends string>({ label, path, field, value, options, isDisabled, isRequired, hasClear, hasSearch, isLoading, emptyText, placeholder, status: given, hasHoverDescriptions, onChange, }: ChoiceRowProps<T>): import("react").JSX.Element;
219
249
  /**
220
250
  * Several choices from a list, the first few as badges and the rest counted (`ListBadges`): the
221
251
  * trigger is one line tall, and Astryx wraps badges past it. Left empty, it shows what leaving it
@@ -230,6 +260,18 @@ export declare function ListRow({ label, path, field, value, options, onChange,
230
260
  options: SelectorOptionType[];
231
261
  onChange: (next: string[]) => void;
232
262
  }): import("react").JSX.Element;
263
+ /** Names as tokens, typed and committed with Enter. Duplicates and blanks never make a token. */
264
+ export declare function NamesInput({ label, status, value, placeholder, isDisabled, disabledMessage, overflow, onChange, }: {
265
+ label: string;
266
+ status?: InputStatus;
267
+ value: string[];
268
+ placeholder?: string;
269
+ isDisabled?: boolean;
270
+ disabledMessage?: string;
271
+ /** `none` keeps every token in sight, at the same height, focused or not. */
272
+ overflow?: 'none' | 'unfocusedInline';
273
+ onChange: (next: string[]) => void;
274
+ }): import("react").JSX.Element;
233
275
  /**
234
276
  * Free-form names, typed and committed with Enter, each a token. Duplicates and blanks never make
235
277
  * it in. `disabledMessage` says why, when `isDisabled`.
package/ui/inspector.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Button } from '@astryxdesign/core/Button';
2
3
  import { FieldStatus } from '@astryxdesign/core/FieldStatus';
3
4
  import { HoverCard } from '@astryxdesign/core/HoverCard';
4
5
  import { HStack } from '@astryxdesign/core/HStack';
@@ -20,11 +21,12 @@ import { Token } from '@astryxdesign/core/Token';
20
21
  import { Tokenizer } from '@astryxdesign/core/Tokenizer';
21
22
  import { Tooltip } from '@astryxdesign/core/Tooltip';
22
23
  import { VStack } from '@astryxdesign/core/VStack';
23
- import { IconArrowBackUp, IconCheck, IconCode, IconCopy } from '@tabler/icons-react';
24
+ import { IconArrowBackUp, IconCheck, IconCode, IconCopy, IconPlus, IconX, } from '@tabler/icons-react';
24
25
  import { fieldMeta } from '@theoremjs/agents';
25
26
  import { useContext, useState } from 'react';
26
- import { originLabel, originPlace, originShortLabel, STUDIO_PROFILE_TYPES } from "../mod.js";
27
+ import { draftKey, originLabel, originPlace, originShortLabel, STUDIO_PROFILE_TYPES, } from "../mod.js";
27
28
  import { ISSUE_ROW_ATTRIBUTE, ListBadges, SaidOrigin, useFieldStatus, useRowOrigin, } from "./inspector-context.js";
29
+ import { entriesOf, entriesText } from "./lib/entries.js";
28
30
  import { tabFills } from "./lib/tab-fills.js";
29
31
  /**
30
32
  * Inspector building blocks: captioned sections of label-and-control rows, after Astryx's
@@ -35,7 +37,7 @@ import { tabFills } from "./lib/tab-fills.js";
35
37
  * The label column, wide enough for the longest label ("Temperature", "Attachments") on one line.
36
38
  * The template's is 80, which fits its shorter labels.
37
39
  */
38
- const LABEL_COLUMN = 96;
40
+ export const LABEL_COLUMN = 96;
39
41
  /**
40
42
  * Whether the field at `path` must be set, and what leaving it out does, from the kernel's catalog.
41
43
  * `isRequired` overrides it for a field required only in some cases, saying whether it is now.
@@ -140,6 +142,41 @@ function useFieldRow({ label, path, field, isRequired }) {
140
142
  function FillRow({ label, path, required, status, note, children, }) {
141
143
  return (_jsx(InspectorRow, { label: label, path: path, isRequired: required, hasIssue: status !== undefined, hasNote: Boolean((status ?? note)?.message), children: _jsx(StackItem, { size: "fill", children: children }) }));
142
144
  }
145
+ /**
146
+ * The names and values of an object the draft holds as JSON text, a row each. The rows are kept
147
+ * here while they are typed, since a row with no name is no part of the object yet, and start
148
+ * again from `value` when something else changes it. `typed` takes any JSON as a value.
149
+ */
150
+ export function EntriesRow({ label, noun, path, field, value, typed = false, namePlaceholder, valuePlaceholder, onChange, }) {
151
+ const status = useFieldStatus()(field);
152
+ const [entries, setEntries] = useState(() => entriesOf(value, typed));
153
+ const [held, setHeld] = useState(value);
154
+ if (value !== held) {
155
+ setHeld(value);
156
+ setEntries(entriesOf(value, typed));
157
+ }
158
+ const change = (next) => {
159
+ const text = entriesText(next, typed);
160
+ setEntries(next);
161
+ setHeld(text);
162
+ onChange(text);
163
+ };
164
+ return (_jsxs(VStack, { gap: 1, children: [_jsx(Tooltip, { content: fieldMeta(path)?.doc, hasHoverIndication: false, children: _jsx(Text, { type: "label", weight: "semibold", children: label }) }), entries.map((entry, at) => {
165
+ const row = `${noun} ${String(at + 1)}`;
166
+ const set = (patch) => {
167
+ change(entries.map((each) => (each.key === entry.key ? { ...each, ...patch } : each)));
168
+ };
169
+ return (_jsxs(HStack, { gap: 1, vAlign: "center", children: [_jsx(StackItem, { size: "fill", children: _jsx(TextInput, { label: `${row} name`, isLabelHidden: true, size: "sm", status: status, value: entry.name, placeholder: namePlaceholder, onChange: (name) => {
170
+ set({ name });
171
+ } }) }), _jsx(StackItem, { size: "fill", children: _jsx(TextInput, { label: `${row} value`, isLabelHidden: true, size: "sm", value: entry.value, placeholder: valuePlaceholder, onChange: (next) => {
172
+ set({ value: next });
173
+ } }) }), _jsx(IconButton, { label: `Remove ${row.toLowerCase()}`, variant: "ghost", size: "sm", icon: _jsx(Icon, { icon: IconX, size: "sm" }), onClick: () => {
174
+ change(entries.filter((each) => each.key !== entry.key));
175
+ } })] }, entry.key));
176
+ }), _jsx(HStack, { children: _jsx(Button, { label: `Add ${noun.toLowerCase()}`, variant: "ghost", size: "sm", icon: _jsx(Icon, { icon: IconPlus, size: "sm" }), onClick: () => {
177
+ change([...entries, { key: draftKey('entry'), name: '', value: '' }]);
178
+ } }) })] }));
179
+ }
143
180
  /**
144
181
  * Free text. Left blank, it shows `placeholder`, a value Tab takes up to edit (an example, or the
145
182
  * default); else `hint`, or what leaving it out does.
@@ -229,7 +266,7 @@ export function SegmentedRow({ label, path, field, value, segments, isDisabled,
229
266
  * leaving it out does while blank. `hasSearch` filters a long list. A value the list leaves out
230
267
  * shows as itself, marked "Not in the list", so a list never hides or rewrites what the file says.
231
268
  */
232
- export function ChoiceRow({ label, path, field, value, options, isDisabled, isRequired, hasSearch, isLoading, emptyText, placeholder, status: given, hasHoverDescriptions, onChange, }) {
269
+ export function ChoiceRow({ label, path, field, value, options, isDisabled, isRequired, hasClear = true, hasSearch, isLoading, emptyText, placeholder, status: given, hasHoverDescriptions, onChange, }) {
233
270
  const status = useFieldStatus()(field) ?? given;
234
271
  const { required, unset } = presence(path, isRequired);
235
272
  const listed = options.some((option) => (typeof option === 'string' ? option : option.value) === value);
@@ -256,7 +293,7 @@ export function ChoiceRow({ label, path, field, value, options, isDisabled, isRe
256
293
  emptyText,
257
294
  ...(hasHoverDescriptions ? { renderOption: hoverDescribed } : {}),
258
295
  };
259
- return (_jsx(InspectorRow, { label: label, path: path, isRequired: required, hasIssue: status !== undefined, hasNote: Boolean(status?.message), children: _jsx(StackItem, { size: "fill", children: required ? (_jsx(Selector, { ...shared, isRequired: true, value: value, placeholder: placeholder, onChange: choose })) : (_jsx(Selector, { ...shared, value: value || null, placeholder: placeholder ?? unset, hasClear: true, onChange: choose })) }) }));
296
+ return (_jsx(InspectorRow, { label: label, path: path, isRequired: required, hasIssue: status !== undefined, hasNote: Boolean(status?.message), children: _jsx(StackItem, { size: "fill", children: required || !hasClear ? (_jsx(Selector, { ...shared, isRequired: required, value: value, placeholder: placeholder, onChange: choose })) : (_jsx(Selector, { ...shared, value: value || null, placeholder: placeholder ?? unset, hasClear: true, onChange: choose })) }) }));
260
297
  }
261
298
  /** An option named on its row, with its description in a tooltip. */
262
299
  function hoverDescribed(option) {
@@ -276,6 +313,13 @@ export function ListRow({ label, path, field, value, options, onChange, }) {
276
313
  }
277
314
  /** A names row suggests nothing; every token is one the user typed. */
278
315
  const NO_SUGGESTIONS = { search: () => [], bootstrap: () => [] };
316
+ /** Names as tokens, typed and committed with Enter. Duplicates and blanks never make a token. */
317
+ export function NamesInput({ label, status, value, placeholder, isDisabled, disabledMessage, overflow = 'unfocusedInline', onChange, }) {
318
+ return (_jsx(Tokenizer, { label: label, status: status, isLabelHidden: true, size: "sm", value: value.map((name) => ({ id: name, label: name })), searchSource: NO_SUGGESTIONS, hasCreate: true, debounceMs: 0, placeholder: placeholder, isDisabled: isDisabled, disabledMessage: disabledMessage, tokenOverflowBehavior: overflow, onChange: (items) => {
319
+ const names = items.map((item) => item.label.trim()).filter(Boolean);
320
+ onChange([...new Set(names)]);
321
+ } }));
322
+ }
279
323
  /**
280
324
  * Free-form names, typed and committed with Enter, each a token. Duplicates and blanks never make
281
325
  * it in. `disabledMessage` says why, when `isDisabled`.
@@ -283,8 +327,5 @@ const NO_SUGGESTIONS = { search: () => [], bootstrap: () => [] };
283
327
  export function NamesRow({ label, path, field, value, placeholder, isDisabled, disabledMessage, onChange, }) {
284
328
  const status = useFieldStatus()(field);
285
329
  const { unset } = presence(path);
286
- return (_jsx(InspectorRow, { label: label, path: path, hasIssue: status !== undefined, hasNote: Boolean(status?.message), children: _jsx(StackItem, { size: "fill", children: _jsx(Tokenizer, { label: label, status: status, isLabelHidden: true, size: "sm", value: value.map((name) => ({ id: name, label: name })), searchSource: NO_SUGGESTIONS, hasCreate: true, debounceMs: 0, placeholder: placeholder ?? unset, isDisabled: isDisabled, disabledMessage: disabledMessage, tokenOverflowBehavior: "unfocusedInline", onChange: (items) => {
287
- const names = items.map((item) => item.label.trim()).filter(Boolean);
288
- onChange([...new Set(names)]);
289
- } }) }) }));
330
+ return (_jsx(InspectorRow, { label: label, path: path, hasIssue: status !== undefined, hasNote: Boolean(status?.message), children: _jsx(StackItem, { size: "fill", children: _jsx(NamesInput, { label: label, status: status, value: value, placeholder: placeholder ?? unset, isDisabled: isDisabled, disabledMessage: disabledMessage, onChange: onChange }) }) }));
290
331
  }
@@ -0,0 +1,13 @@
1
+ /** One name and value of a JSON object, as a row of the editor holds it. */
2
+ export interface Entry {
3
+ key: string;
4
+ name: string;
5
+ value: string;
6
+ }
7
+ /**
8
+ * The rows of a JSON object held as text: none while it is not one. With `typed`, a value can be
9
+ * any JSON and plain text is a string, so a string that reads as JSON shows in its quotes.
10
+ */
11
+ export declare function entriesOf(text: string, typed: boolean): Entry[];
12
+ /** The JSON object the named rows make, as text: blank when none is named. */
13
+ export declare function entriesText(entries: readonly Entry[], typed: boolean): string;
@@ -0,0 +1,43 @@
1
+ import { draftKey } from "../../draft.js";
2
+ import { isRecord } from "./studio-session.js";
3
+ function readsAsJson(text) {
4
+ try {
5
+ JSON.parse(text);
6
+ return true;
7
+ }
8
+ catch {
9
+ return false;
10
+ }
11
+ }
12
+ function valueText(value, typed) {
13
+ if (typeof value !== 'string')
14
+ return JSON.stringify(value);
15
+ return typed && readsAsJson(value) ? JSON.stringify(value) : value;
16
+ }
17
+ function typedValue(text) {
18
+ return readsAsJson(text) ? JSON.parse(text) : text;
19
+ }
20
+ /**
21
+ * The rows of a JSON object held as text: none while it is not one. With `typed`, a value can be
22
+ * any JSON and plain text is a string, so a string that reads as JSON shows in its quotes.
23
+ */
24
+ export function entriesOf(text, typed) {
25
+ if (!readsAsJson(text))
26
+ return [];
27
+ const parsed = JSON.parse(text);
28
+ if (!isRecord(parsed))
29
+ return [];
30
+ return Object.entries(parsed).map(([name, value]) => ({
31
+ key: draftKey('entry'),
32
+ name,
33
+ value: valueText(value, typed),
34
+ }));
35
+ }
36
+ /** The JSON object the named rows make, as text: blank when none is named. */
37
+ export function entriesText(entries, typed) {
38
+ const named = entries.flatMap(({ name, value }) => {
39
+ const trimmed = name.trim();
40
+ return trimmed ? [[trimmed, typed ? typedValue(value) : value]] : [];
41
+ });
42
+ return named.length > 0 ? JSON.stringify(Object.fromEntries(named)) : '';
43
+ }
@@ -1,9 +1,7 @@
1
1
  import { resolveObservabilityPolicy } from '@theoremjs/agents';
2
- import { ASK_WRITES_HEADER, ASK_WRITES_PARAM } from "../../asks.js";
3
2
  import { ACTING_AS_PARAM, actingAsHeader, actingAsHeaders, } from "../../people.js";
4
3
  import { eachLine, NDJSON } from "../../stream-lines.js";
5
4
  import { studioTraceLine } from "../../transport.js";
6
- import { getPref } from "./studio-prefs.js";
7
5
  /** Whether the agent records traces, so the page can offer them: the rule every view reads. */
8
6
  export function recordsTraces(payload) {
9
7
  return payload !== null && resolveObservabilityPolicy(payload.profile.observability).record;
@@ -30,15 +28,10 @@ function withoutTraces(traces) {
30
28
  send(line);
31
29
  });
32
30
  }
33
- /**
34
- * `fetch` for a project's runs: the studio's local server sends each run's trace behind its events.
35
- * Each run says which tools that write ask, as the builder's setting stands when it starts.
36
- */
31
+ /** `fetch` for a project's runs: the studio's local server sends each run's trace behind its events. */
37
32
  function tracedFetch(traces) {
38
33
  return async (input, init) => {
39
- const headers = new Headers(init?.headers);
40
- headers.set(ASK_WRITES_HEADER, getPref('askWrites'));
41
- const response = await fetch(input, { ...init, headers });
34
+ const response = await fetch(input, init);
42
35
  if (!response.body || !response.headers.get('content-type')?.startsWith(NDJSON))
43
36
  return response;
44
37
  return new Response(response.body.pipeThrough(withoutTraces(traces)), {
@@ -59,7 +52,6 @@ function tracedFetch(traces) {
59
52
  */
60
53
  export function liveSocketAddress(endpoint, actingAs) {
61
54
  const address = new URL(endpoint.replace(/^http/, 'ws'));
62
- address.searchParams.set(ASK_WRITES_PARAM, getPref('askWrites'));
63
55
  if (actingAs)
64
56
  address.searchParams.set(ACTING_AS_PARAM, actingAsHeader(actingAs));
65
57
  return address.href;
@@ -7,8 +7,6 @@ export interface StudioPrefs {
7
7
  filesToast: 'on' | 'off';
8
8
  /** Whether changing a value several agents share is asked about first. */
9
9
  askShared: 'always' | 'never';
10
- /** Which tools that write ask before a run: all of them, or only the destructive ones. */
11
- askWrites: 'always' | 'destructive';
12
10
  }
13
11
  export type StudioPref = keyof StudioPrefs;
14
12
  export declare const PREF_DEFAULTS: StudioPrefs;
@@ -22,5 +20,3 @@ export declare function getPref<K extends StudioPref>(name: K): StudioPrefs[K];
22
20
  export declare function setPref<K extends StudioPref>(name: K, value: StudioPrefs[K]): void;
23
21
  /** A preference, and the screen drawn again when it changes. */
24
22
  export declare function usePref<K extends StudioPref>(name: K): StudioPrefs[K];
25
- /** Whether a run of a tool that writes asks first: a destructive one always, another unless the builder said not to. */
26
- export declare function writeAsks(access: string): boolean;
@@ -10,14 +10,12 @@ export const PREF_DEFAULTS = {
10
10
  watch: 'on',
11
11
  filesToast: 'on',
12
12
  askShared: 'always',
13
- askWrites: 'always',
14
13
  };
15
14
  const PREF_KEYS = {
16
15
  editor: 'theorem.studio.editor',
17
16
  watch: 'theorem.studio.watch',
18
17
  filesToast: 'theorem.studio.files-toast',
19
18
  askShared: 'theorem.studio.ask-shared',
20
- askWrites: 'theorem.studio.ask-writes',
21
19
  };
22
20
  /** Whether a kept text is a value the preference takes. */
23
21
  const PREF_TAKES = {
@@ -25,7 +23,6 @@ const PREF_TAKES = {
25
23
  watch: (kept) => kept === 'off',
26
24
  filesToast: (kept) => kept === 'off',
27
25
  askShared: (kept) => kept === 'never',
28
- askWrites: (kept) => kept === 'destructive',
29
26
  };
30
27
  /** A preference as `storage` keeps it, or its default. */
31
28
  export function readPref(storage, name) {
@@ -81,7 +78,3 @@ function subscribePrefs(listener) {
81
78
  export function usePref(name) {
82
79
  return useSyncExternalStore(subscribePrefs, () => getPref(name), () => PREF_DEFAULTS[name]);
83
80
  }
84
- /** Whether a run of a tool that writes asks first: a destructive one always, another unless the builder said not to. */
85
- export function writeAsks(access) {
86
- return access === 'destructive' || getPref('askWrites') === 'always';
87
- }
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import type { TranscriptBlock } from '@theoremjs/agents/interface';
7
7
  import type { TheoremRewound } from '@theoremjs/web/client';
8
- import { type ProjectCode, type StudioAsks, type StudioWorkspace } from '../../mod.ts';
8
+ import { type ProjectCode, type StudioWorkspace } from '../../mod.ts';
9
9
  import { type StudioActingAs, type StudioPeopleOffer } from '../../people.ts';
10
10
  import { type ReadStep } from '../../read-steps.ts';
11
11
  import type { EditedAnswer, OpenAnswer, OpenRequest, ProjectOrigins, ProviderPlace, SaveDone, SaveRefusal, SaveReview, SharedSetting, Unregistered } from '../../server/save-wire.ts';
@@ -44,8 +44,6 @@ export interface ProjectSession {
44
44
  origins: ProjectOrigins;
45
45
  /** Where the files define each provider the project registered. */
46
46
  providerPlaces: ProviderPlace[];
47
- /** The tools that write: the ones the studio makes ask, and the ones it cannot. */
48
- asks: StudioAsks;
49
47
  /** The files as the server read them, as a short text that changes when they do. */
50
48
  print: string;
51
49
  /** What the project printed when its files stopped loading; the page shows the last load that did. */
@@ -64,7 +62,6 @@ export interface ProjectSession {
64
62
  * builder changed is left out, so the code writes it as the studio holds it.
65
63
  */
66
64
  export declare function projectCode(project: ProjectSession | null, workspace: StudioWorkspace): ProjectCode | undefined;
67
- export declare const NO_ASKS: StudioAsks;
68
65
  /** Set while the page has a project open; `null` on the website's own page. */
69
66
  export declare const ProjectContext: import("react").Context<ProjectSession | null>;
70
67
  export declare function useProject(): ProjectSession | null;
@@ -93,7 +90,7 @@ export declare function startProjectConversation(project: ProjectSession, profil
93
90
  /** Shows a line of one of the project's files in the editor the builder chose, or the studio command's. */
94
91
  export declare function openInEditor(project: ProjectSession, place: OpenRequest): Promise<OpenAnswer>;
95
92
  /** What a project's files say, which a Save or an edit in the builder's editor changes. */
96
- export type ProjectFiles = Pick<ProjectSession, 'profiles' | 'providers' | 'problems' | 'modelProblems' | 'differences' | 'unheld' | 'origins' | 'providerPlaces' | 'asks' | 'print' | 'unloaded' | 'people' | 'peopleProblem'>;
93
+ export type ProjectFiles = Pick<ProjectSession, 'profiles' | 'providers' | 'problems' | 'modelProblems' | 'differences' | 'unheld' | 'origins' | 'providerPlaces' | 'print' | 'unloaded' | 'people' | 'peopleProblem'>;
97
94
  /**
98
95
  * What the project's files say now that the page does not hold as edits: the profiles they hold
99
96
  * and the ones the studio cannot run, the settings they set in code, whose lines a Save moves,
@@ -4,7 +4,7 @@
4
4
  * own code.
5
5
  */
6
6
  import { createContext, useContext } from 'react';
7
- import { filesPrint, providersAtStart, } from "../../mod.js";
7
+ import { filesPrint, providersAtStart } from "../../mod.js";
8
8
  import { actingAsHeaders } from "../../people.js";
9
9
  import { READ_STEPS } from "../../read-steps.js";
10
10
  import { projectEndpoint } from "./project-address.js";
@@ -22,7 +22,6 @@ export function projectCode(project, workspace) {
22
22
  origins: project.origins.profiles,
23
23
  };
24
24
  }
25
- export const NO_ASKS = { asked: [], destructive: [], inside: [] };
26
25
  const NO_ORIGINS = { profiles: {}, tools: {}, providers: {} };
27
26
  /** Set while the page has a project open; `null` on the website's own page. */
28
27
  export const ProjectContext = createContext(null);
@@ -44,7 +43,6 @@ export function projectSession(name) {
44
43
  unregistered: [],
45
44
  origins: NO_ORIGINS,
46
45
  providerPlaces: [],
47
- asks: NO_ASKS,
48
46
  print: '',
49
47
  people: undefined,
50
48
  peopleProblem: undefined,
@@ -157,7 +155,6 @@ function filesOf(opened) {
157
155
  unheld: opened.unheld ?? [],
158
156
  origins: opened.origins ?? NO_ORIGINS,
159
157
  providerPlaces: opened.providerPlaces ?? [],
160
- asks: opened.asks ?? NO_ASKS,
161
158
  print: filesPrint(opened.workspace),
162
159
  // Set even when absent, so a setup file that stops offering people stops being offered.
163
160
  people: opened.people,