@nodetool-ai/app-runtime 0.8.10 → 0.8.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -27,6 +27,7 @@ run's messages their own way and disagreed about what an app was showing.
27
27
  | `doc-ops.ts` | Immutable edits to the non-UI half of a document (operations, variables, resources) |
28
28
  | `bundle.ts` | The `ApplicationBundle`: an app plus the full graphs it binds, as one JSON artifact |
29
29
  | `script-run.ts` | The contract for an operation that runs a JS script instead of a workflow |
30
+ | `chat-app.ts` | The chat presentation: steps read from the `Stepper`, the `[app event]` turn a card sends, the app agent's system prompt and state snapshot |
30
31
  | `recipe-compiler.ts` | Deterministic Recipe authoring into normal Application documents, using typed contracts and concrete pinned operations |
31
32
  | `chat.ts` | Reading a bound value as a conversation, for the thread and composer widgets |
32
33
  | `documents.ts` | Unwrapping sketch and timeline refs out of a bound value |
@@ -1 +1 @@
1
- 2026-11-01T20:32:29.848Z
1
+ 2026-11-13T22:28:53.320Z
@@ -0,0 +1,136 @@
1
+ /**
2
+ * Chat presentation of a step app.
3
+ *
4
+ * A document with `presentation: "chat"` runs as a conversation: the app agent
5
+ * owns the loop and shows the app's steps as cards in the thread. This module
6
+ * holds what every surface has to agree on: how a document splits into steps,
7
+ * how a press inside a card reaches the agent as an app event, and how the
8
+ * agent reads the running app.
9
+ *
10
+ * Steps come from the document itself. A `Stepper` at the top level names the
11
+ * steps and the variable that holds the current one; every top-level widget
12
+ * gated `visibleWhen: <that variable> eq <step>` belongs to that step. A page
13
+ * app with that shape runs in chat with no layout change.
14
+ */
15
+ import type { ApplicationDocument } from "./document.js";
16
+ import { type AppInstanceState, type InvocationStatus } from "./state.js";
17
+ export interface ChatAppField {
18
+ /** The widget's binding: `var:<id>` or `op:<op>/in:<node>`. */
19
+ binding: string;
20
+ label: string;
21
+ }
22
+ export interface ChatAppStep {
23
+ value: string;
24
+ title: string;
25
+ /** The step's top-level widgets, with the step gate removed. */
26
+ items: unknown[];
27
+ /** The values the step's widgets hold, so the agent knows where each lives. */
28
+ fields: ChatAppField[];
29
+ }
30
+ export interface ChatAppLayout {
31
+ /** The Stepper's component id. */
32
+ stepperId: string;
33
+ /** The Stepper's binding, e.g. `var:step`. */
34
+ stepBinding: string;
35
+ /** The variable that holds the current step. */
36
+ stepVariableId: string;
37
+ steps: ChatAppStep[];
38
+ /** Top-level widgets gated on no step (a title, a note): shown above the thread. */
39
+ header: unknown[];
40
+ }
41
+ /**
42
+ * The variables a language-model picker binds. In chat the agent's own model
43
+ * fills them, so the cards do not show those pickers.
44
+ */
45
+ export declare const chatModelVariableIds: (document: Pick<ApplicationDocument, "ui">) => string[];
46
+ /**
47
+ * Keep only the widgets with one of `ids`, and the containers that hold them.
48
+ * A container keeps only its matching children. Returns all items when no id
49
+ * matches, so a wrong id never shows an empty card.
50
+ */
51
+ export declare const pickStepItems: (items: unknown[], ids: string[]) => unknown[];
52
+ /**
53
+ * Split a document into chat steps, or null when it has no top-level Stepper
54
+ * bound to a variable. Widgets gated on a step the Stepper does not list are
55
+ * dropped: they could never show on the page either.
56
+ */
57
+ export declare const chatAppLayout: (document: Pick<ApplicationDocument, "ui">) => ChatAppLayout | null;
58
+ export declare const isChatApp: (document: Pick<ApplicationDocument, "presentation" | "ui"> | null | undefined) => boolean;
59
+ /** What a press inside a card asks the agent to do. */
60
+ export type ChatAppRequest = {
61
+ kind: "step";
62
+ step: string;
63
+ } | {
64
+ kind: "run";
65
+ operationId: string;
66
+ };
67
+ /**
68
+ * An operation the agent started that outlived its tool call. The app sends
69
+ * it as an app event when the run ends, so the agent picks the loop back up.
70
+ */
71
+ export interface ChatAppSettled {
72
+ operationId: string;
73
+ status: "completed" | "failed" | "cancelled";
74
+ error?: string;
75
+ /** The step the operation moved the app to, when it set one. */
76
+ step?: string;
77
+ }
78
+ /**
79
+ * A press inside a card or on the steps bar, sent to the agent as a user turn.
80
+ * Cards run nothing themselves: the agent reads the event and acts on it.
81
+ */
82
+ export interface ChatAppEvent {
83
+ /** The step whose card held the control; absent for the steps bar. */
84
+ step?: string;
85
+ /** The control's visible label. */
86
+ control: string;
87
+ requests: ChatAppRequest[];
88
+ /** Labels of the values the user changed in this card since it was shown. */
89
+ changed?: string[];
90
+ /** Set when the event reports a finished run rather than a press. */
91
+ settled?: ChatAppSettled;
92
+ }
93
+ /** The text of the user turn an app event becomes. The model reads the JSON. */
94
+ export declare const formatChatAppEvent: (event: ChatAppEvent) => string;
95
+ /** Read an app event back from a user turn's text, or null for typed text. */
96
+ export declare const parseChatAppEvent: (text: string) => ChatAppEvent | null;
97
+ export interface ChatAppPromptOptions {
98
+ appRunId: string;
99
+ title: string;
100
+ }
101
+ /**
102
+ * The system-prompt addendum for the app agent: what the app makes, its steps
103
+ * and operations, the tools, and the rules of the loop.
104
+ */
105
+ export declare const buildChatAppSystemPrompt: (document: ApplicationDocument, layout: ChatAppLayout, { appRunId, title }: ChatAppPromptOptions) => string;
106
+ /** A short, model-sized form of an app value: long text cut, media as its ref. */
107
+ export declare const previewAppValue: (value: unknown) => unknown;
108
+ export interface ChatAppOperationState {
109
+ id: string;
110
+ name: string;
111
+ status: InvocationStatus | "idle";
112
+ error?: string;
113
+ }
114
+ export interface ChatAppStateSnapshot {
115
+ step: string | null;
116
+ steps: Array<{
117
+ value: string;
118
+ title: string;
119
+ }>;
120
+ variables: Record<string, unknown>;
121
+ inputs: Record<string, unknown>;
122
+ missing_required: string[];
123
+ operations: ChatAppOperationState[];
124
+ }
125
+ /** A compact read of the running app for the agent. */
126
+ export declare const chatAppSnapshot: (document: ApplicationDocument, layout: ChatAppLayout, state: AppInstanceState) => ChatAppStateSnapshot;
127
+ /**
128
+ * The invocation an operation's latest run settled into, following the
129
+ * client-reservation alias to the provider job id.
130
+ */
131
+ export declare const settledInvocation: (state: AppInstanceState, operationId: string, before: string | undefined) => {
132
+ id: string;
133
+ status: InvocationStatus;
134
+ error?: string;
135
+ } | null;
136
+ //# sourceMappingURL=chat-app.d.ts.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BAAgB,GAAG,MAAM,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,KAAK,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,UAAU,EAAE,qBAAqB,EAAE,CAAC;CACrC;AAED,uDAAuD;AACvD,eAAO,MAAM,eAAe,aAChB,mBAAmB,UACrB,aAAa,SACd,gBAAgB,KACtB,oBAuCF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,UACrB,gBAAgB,eACV,MAAM,UACX,MAAM,GAAG,SAAS,KACzB;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,gBAAgB,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAa7D,CAAC"}
@@ -0,0 +1,474 @@
1
+ /**
2
+ * Chat presentation of a step app.
3
+ *
4
+ * A document with `presentation: "chat"` runs as a conversation: the app agent
5
+ * owns the loop and shows the app's steps as cards in the thread. This module
6
+ * holds what every surface has to agree on: how a document splits into steps,
7
+ * how a press inside a card reaches the agent as an app event, and how the
8
+ * agent reads the running app.
9
+ *
10
+ * Steps come from the document itself. A `Stepper` at the top level names the
11
+ * steps and the variable that holds the current one; every top-level widget
12
+ * gated `visibleWhen: <that variable> eq <step>` belongs to that step. A page
13
+ * app with that shape runs in chat with no layout change.
14
+ */
15
+ import { isBoolean, isNumber, isRecord, isString } from "./predicates.js";
16
+ import { isLiveInvocation } from "./state.js";
17
+ const isPuckItem = (value) => isRecord(value) && isString(value.type) && isRecord(value.props);
18
+ const stepGate = (item, stepBinding) => {
19
+ const gate = item.props.visibleWhen;
20
+ if (!isRecord(gate) || gate.binding !== stepBinding || gate.op !== "eq") {
21
+ return null;
22
+ }
23
+ return isString(gate.value) ? gate.value : null;
24
+ };
25
+ const FIELD_BINDING = /^(var:[^/#]+|op:[^/]+\/in:[^/#]+)$/;
26
+ /** Labelled widgets bound to a variable or an operation input, in order. */
27
+ const fieldsOf = (items, stepBinding) => {
28
+ const fields = [];
29
+ const walk = (value) => {
30
+ if (Array.isArray(value)) {
31
+ value.forEach(walk);
32
+ return;
33
+ }
34
+ if (!isPuckItem(value))
35
+ return;
36
+ const { binding, label, title } = value.props;
37
+ const name = isString(label) && label.trim() ? label.trim() : isString(title) && title.trim() ? title.trim() : null;
38
+ if (isString(binding) &&
39
+ binding !== stepBinding &&
40
+ FIELD_BINDING.test(binding) &&
41
+ name &&
42
+ value.type !== "Button" &&
43
+ !fields.some((field) => field.binding === binding)) {
44
+ fields.push({ binding, label: name });
45
+ }
46
+ for (const nested of Object.values(value.props)) {
47
+ if (Array.isArray(nested))
48
+ walk(nested);
49
+ }
50
+ };
51
+ walk(items);
52
+ return fields;
53
+ };
54
+ /**
55
+ * The variables a language-model picker binds. In chat the agent's own model
56
+ * fills them, so the cards do not show those pickers.
57
+ */
58
+ export const chatModelVariableIds = (document) => {
59
+ const ids = [];
60
+ const walk = (value) => {
61
+ if (Array.isArray(value)) {
62
+ value.forEach(walk);
63
+ return;
64
+ }
65
+ if (!isPuckItem(value))
66
+ return;
67
+ const { binding, modelKind } = value.props;
68
+ if (value.type === "ModelSelect" &&
69
+ modelKind === "language_model" &&
70
+ isString(binding) &&
71
+ binding.startsWith("var:") &&
72
+ !ids.includes(binding.slice(4))) {
73
+ ids.push(binding.slice(4));
74
+ }
75
+ for (const nested of Object.values(value.props)) {
76
+ if (Array.isArray(nested))
77
+ walk(nested);
78
+ }
79
+ };
80
+ walk(document.ui.content);
81
+ return ids;
82
+ };
83
+ /**
84
+ * Drop the language-model pickers, and the `<id>-help` or `<id>-hint` text
85
+ * that explains each one, from a step's widgets.
86
+ */
87
+ const withoutModelPickers = (items, modelIds) => {
88
+ const hidden = new Set();
89
+ for (const id of modelIds) {
90
+ hidden.add(id);
91
+ hidden.add(`${id}-help`);
92
+ hidden.add(`${id}-hint`);
93
+ }
94
+ const strip = (list) => list
95
+ .filter((item) => {
96
+ if (!isPuckItem(item))
97
+ return true;
98
+ const { id, binding } = item.props;
99
+ if (item.type === "ModelSelect" && isString(binding) && modelIds.includes(binding.slice(4))) {
100
+ return false;
101
+ }
102
+ return !(isString(id) && hidden.has(id));
103
+ })
104
+ .map((item) => {
105
+ if (!isPuckItem(item))
106
+ return item;
107
+ const props = {};
108
+ for (const [key, value] of Object.entries(item.props)) {
109
+ props[key] = Array.isArray(value) ? strip(value) : value;
110
+ }
111
+ return { ...item, props };
112
+ });
113
+ return strip(items);
114
+ };
115
+ /**
116
+ * Keep only the widgets with one of `ids`, and the containers that hold them.
117
+ * A container keeps only its matching children. Returns all items when no id
118
+ * matches, so a wrong id never shows an empty card.
119
+ */
120
+ export const pickStepItems = (items, ids) => {
121
+ const wanted = new Set(ids);
122
+ const pick = (list) => {
123
+ const kept = [];
124
+ for (const item of list) {
125
+ if (!isPuckItem(item))
126
+ continue;
127
+ if (isString(item.props.id) && wanted.has(item.props.id)) {
128
+ kept.push(item);
129
+ continue;
130
+ }
131
+ let found = false;
132
+ const props = {};
133
+ for (const [key, value] of Object.entries(item.props)) {
134
+ if (Array.isArray(value) && value.some(isPuckItem)) {
135
+ const inner = pick(value);
136
+ if (inner.length)
137
+ found = true;
138
+ props[key] = inner;
139
+ }
140
+ else {
141
+ props[key] = value;
142
+ }
143
+ }
144
+ if (found)
145
+ kept.push({ ...item, props });
146
+ }
147
+ return kept;
148
+ };
149
+ const picked = pick(items);
150
+ return picked.length ? picked : items;
151
+ };
152
+ const withoutGate = (item) => {
153
+ const props = { ...item.props };
154
+ delete props.visibleWhen;
155
+ return { ...item, props };
156
+ };
157
+ /**
158
+ * Split a document into chat steps, or null when it has no top-level Stepper
159
+ * bound to a variable. Widgets gated on a step the Stepper does not list are
160
+ * dropped: they could never show on the page either.
161
+ */
162
+ export const chatAppLayout = (document) => {
163
+ const content = document.ui.content.filter(isPuckItem);
164
+ const stepper = content.find((item) => item.type === "Stepper");
165
+ if (!stepper)
166
+ return null;
167
+ const stepBinding = stepper.props.binding;
168
+ if (!isString(stepBinding) || !stepBinding.startsWith("var:"))
169
+ return null;
170
+ const rawSteps = Array.isArray(stepper.props.steps) ? stepper.props.steps : [];
171
+ const steps = [];
172
+ for (const raw of rawSteps) {
173
+ if (!isRecord(raw) || !isString(raw.value) || !raw.value)
174
+ continue;
175
+ if (steps.some((step) => step.value === raw.value))
176
+ continue;
177
+ steps.push({
178
+ value: raw.value,
179
+ title: isString(raw.title) && raw.title ? raw.title : raw.value,
180
+ items: [],
181
+ fields: []
182
+ });
183
+ }
184
+ if (steps.length === 0)
185
+ return null;
186
+ const header = [];
187
+ const modelIds = chatModelVariableIds(document);
188
+ for (const item of content) {
189
+ if (item === stepper)
190
+ continue;
191
+ const gate = stepGate(item, stepBinding);
192
+ if (gate === null) {
193
+ header.push(item);
194
+ continue;
195
+ }
196
+ steps.find((step) => step.value === gate)?.items.push(withoutGate(item));
197
+ }
198
+ for (const step of steps) {
199
+ step.items = withoutModelPickers(step.items, modelIds);
200
+ step.fields = fieldsOf(step.items, stepBinding);
201
+ }
202
+ return {
203
+ stepperId: isString(stepper.props.id) ? stepper.props.id : "steps",
204
+ stepBinding,
205
+ stepVariableId: stepBinding.slice("var:".length),
206
+ steps,
207
+ header
208
+ };
209
+ };
210
+ export const isChatApp = (document) => document?.presentation === "chat" && chatAppLayout(document) !== null;
211
+ const SETTLED_STATUSES = new Set(["completed", "failed", "cancelled"]);
212
+ const APP_EVENT_PREFIX = "[app event] ";
213
+ /** The text of the user turn an app event becomes. The model reads the JSON. */
214
+ export const formatChatAppEvent = (event) => `${APP_EVENT_PREFIX}${JSON.stringify(event)}`;
215
+ /** Read an app event back from a user turn's text, or null for typed text. */
216
+ export const parseChatAppEvent = (text) => {
217
+ if (!text.startsWith(APP_EVENT_PREFIX))
218
+ return null;
219
+ let value;
220
+ try {
221
+ value = JSON.parse(text.slice(APP_EVENT_PREFIX.length));
222
+ }
223
+ catch {
224
+ return null;
225
+ }
226
+ if (!isRecord(value) || !isString(value.control) || !Array.isArray(value.requests)) {
227
+ return null;
228
+ }
229
+ const requests = [];
230
+ for (const request of value.requests) {
231
+ if (!isRecord(request))
232
+ continue;
233
+ if (request.kind === "step" && isString(request.step)) {
234
+ requests.push({ kind: "step", step: request.step });
235
+ }
236
+ else if (request.kind === "run" && isString(request.operationId)) {
237
+ requests.push({ kind: "run", operationId: request.operationId });
238
+ }
239
+ }
240
+ const event = { control: value.control, requests };
241
+ if (isString(value.step))
242
+ event.step = value.step;
243
+ if (Array.isArray(value.changed))
244
+ event.changed = value.changed.filter(isString);
245
+ const settled = parseSettled(value.settled);
246
+ if (settled)
247
+ event.settled = settled;
248
+ return event;
249
+ };
250
+ const parseSettled = (value) => {
251
+ if (!isRecord(value) ||
252
+ !isString(value.operationId) ||
253
+ !isString(value.status) ||
254
+ !SETTLED_STATUSES.has(value.status)) {
255
+ return null;
256
+ }
257
+ const settled = {
258
+ operationId: value.operationId,
259
+ status: value.status
260
+ };
261
+ if (isString(value.error))
262
+ settled.error = value.error;
263
+ if (isString(value.step))
264
+ settled.step = value.step;
265
+ return settled;
266
+ };
267
+ // ── The agent's view of the app ─────────────────────────────────────────────
268
+ const textOf = (items, limit) => {
269
+ const lines = [];
270
+ const walk = (value) => {
271
+ if (Array.isArray(value)) {
272
+ value.forEach(walk);
273
+ return;
274
+ }
275
+ if (!isPuckItem(value))
276
+ return;
277
+ const { type, props } = value;
278
+ if (type === "Heading" || type === "Text" || type === "Markdown" || type === "Alert") {
279
+ for (const key of ["text", "title", "subtitle"]) {
280
+ const text = props[key];
281
+ if (isString(text) && text.trim() && !isString(props.binding)) {
282
+ lines.push(text.trim());
283
+ }
284
+ }
285
+ }
286
+ if (type === "Button" && isString(props.label)) {
287
+ lines.push(`[button: ${props.label}]`);
288
+ }
289
+ for (const nested of Object.values(props)) {
290
+ if (Array.isArray(nested))
291
+ walk(nested);
292
+ }
293
+ };
294
+ walk(items);
295
+ const joined = lines.join(" · ");
296
+ return joined.length > limit ? `${joined.slice(0, limit - 1)}…` : joined;
297
+ };
298
+ /**
299
+ * The system-prompt addendum for the app agent: what the app makes, its steps
300
+ * and operations, the tools, and the rules of the loop.
301
+ */
302
+ export const buildChatAppSystemPrompt = (document, layout, { appRunId, title }) => {
303
+ const objective = document.recipe?.creativeStrategy?.objective;
304
+ const steps = layout.steps
305
+ .map((step, index) => {
306
+ const summary = textOf(step.items, 320);
307
+ const values = step.fields
308
+ .map((field) => `${field.binding.startsWith("var:") ? field.binding.slice(4) : field.binding} (${field.label})`)
309
+ .join(", ");
310
+ return `${index + 1}. \`${step.value}\` "${step.title}"${summary ? ` — ${summary}` : ""}${values ? `\n Values: ${values}` : ""}`;
311
+ })
312
+ .join("\n");
313
+ const operations = document.operations
314
+ .map((operation) => `- \`${operation.id}\` "${operation.name}"${operation.agentTask ? " (your task, see below)" : ""}`)
315
+ .join("\n");
316
+ const tasks = document.operations
317
+ .filter((operation) => operation.agentTask)
318
+ .map((operation) => {
319
+ const writes = Object.values(operation.outputs)
320
+ .flatMap((mapping) => (mapping.to === "variable" ? [mapping.variableId] : []))
321
+ .join(", ");
322
+ return `### \`${operation.id}\` "${operation.name}"\nWrites: ${writes || "nothing"}\n${operation.agentTask}`;
323
+ })
324
+ .join("\n\n");
325
+ const modelIds = chatModelVariableIds(document);
326
+ return `# Running the app "${title}"
327
+ You run this mini app for the user as a conversation. You own the loop: the
328
+ user sees a steps bar, your messages, and the step cards you show. Cards show
329
+ results and collect values; they never run anything themselves.
330
+ ${objective ? `\nWhat it makes: ${objective}\n` : ""}
331
+ app_run_id: \`${appRunId}\` (pass it to every ui_app_run_* call)
332
+
333
+ Steps, in order:
334
+ ${steps}
335
+
336
+ Operations:
337
+ ${operations || "- none"}
338
+
339
+ ## Tools
340
+ Call these directly, never from inside \`execute_code\`: each call shows in the chat.
341
+ - \`ui_app_run_get_state\`: the current step, every value (with the empty required ones), and each operation's status and last error. Read it before deciding.
342
+ - \`ui_app_run_show_step\`: show a step's card in the chat and make it the current step. Add a short \`note\` for the user when it helps. Pass \`only\` with widget ids to show just those widgets of the step.
343
+ - \`ui_app_run_set_inputs\`: write values the user gave you in chat, or a fix you proposed and they accepted.
344
+ - \`ui_app_run_operation\`: run one operation and wait for it. It returns the outputs, the step the operation moved to, or the error with the run id. A long run returns \`status: "running"\` instead: say it is running and end the turn. An app event with \`settled\` arrives when it ends.
345
+ - \`ui_app_run_cancel\`: stop a running operation.
346
+
347
+ ${modelIds.length ? `\nThe language-model values (${modelIds.join(", ")}) follow the model of this chat. The app fills them before each run, so never ask the user to pick one.\n` : ""}${tasks ? `
348
+ ## Your tasks
349
+ These operations are yours. Do the work yourself with your own tools, such as reading web pages and searching images in a code action. Write the result with \`ui_app_run_set_inputs\`, then show the step that holds it. Never call \`ui_app_run_operation\` for them. When an app event asks to run one, that is the user asking you to do it now.
350
+
351
+ ${tasks}
352
+ ` : ""}
353
+ ## App events
354
+ A user turn that starts with \`[app event]\` is a press inside a card or on the steps bar, as JSON: \`step\` (the card), \`control\` (its label), \`requests\` (\`{"kind":"step","step":…}\` to go to a step, \`{"kind":"run","operationId":…}\` to run an operation, in the order the control lists them), \`changed\` (values edited in that card). An event with \`settled\` reports that an operation you started has ended: its \`status\`, \`error\` and the \`step\` it moved to. Treat it as that operation's result.
355
+
356
+ ## Rules
357
+ 1. Start by showing the first step. Show a step before you ask for its values. A value lives on the step that lists it under Values: to get one changed, show that step.
358
+ 2. Act on app events in order: run what it asks to run, then show the step it asks for. When an operation moves the step itself, show that step.
359
+ 3. Run an operation only after an app event asks for it or the user says yes in chat. Many spend money.
360
+ 4. When the user asks to go back, show that step. Keep values from later steps unless the user changes them.
361
+ 5. After a failure, say in one sentence what went wrong in the user's terms, then offer up to three ways forward: a value to change (show its step), another model, a retry, or a workaround. Never claim a result you did not get.
362
+ 6. Before a step that needs values that are still empty, say which ones and show the step that holds them.
363
+ 7. Say what the user needs in the \`note\` of ui_app_run_show_step and end the turn there, without a second message. Keep it to one or two sentences and do not repeat what the card already shows.
364
+ 8. Typed questions get plain answers. The user may ask anything about the app, a result, or a failure at any time.`;
365
+ };
366
+ /** A short, model-sized form of an app value: long text cut, media as its ref. */
367
+ export const previewAppValue = (value) => {
368
+ if (value === undefined || value === null || value === "")
369
+ return null;
370
+ if (isString(value)) {
371
+ return value.length > 240 ? `${value.slice(0, 239)}…` : value;
372
+ }
373
+ if (isNumber(value) || isBoolean(value))
374
+ return value;
375
+ if (Array.isArray(value)) {
376
+ return value.length <= 5
377
+ ? value.map(previewAppValue)
378
+ : { items: value.length, first: value.slice(0, 3).map(previewAppValue) };
379
+ }
380
+ if (isRecord(value)) {
381
+ if (isString(value.type) && (isString(value.uri) || isString(value.asset_id))) {
382
+ const media = { type: value.type };
383
+ // The asset id is the durable handle. A stored uri can be a resolved
384
+ // display path (file://, a signed URL) that no tool accepts.
385
+ if (isString(value.asset_id) && value.asset_id) {
386
+ media.uri = `asset://${value.asset_id}`;
387
+ }
388
+ else if (isString(value.uri)) {
389
+ media.uri = value.uri.slice(0, 160);
390
+ }
391
+ return media;
392
+ }
393
+ const keys = Object.keys(value);
394
+ if (keys.length > 12)
395
+ return { keys: keys.slice(0, 12), more: keys.length - 12 };
396
+ const out = {};
397
+ for (const key of keys) {
398
+ const nested = value[key];
399
+ out[key] = isRecord(nested) || Array.isArray(nested) ? "…" : previewAppValue(nested);
400
+ }
401
+ return out;
402
+ }
403
+ return String(value);
404
+ };
405
+ const isEmptyValue = (value) => value === undefined ||
406
+ value === null ||
407
+ value === "" ||
408
+ (Array.isArray(value) && value.length === 0) ||
409
+ (isRecord(value) && isString(value.type) && !value.uri && !value.asset_id && !value.data);
410
+ /** A compact read of the running app for the agent. */
411
+ export const chatAppSnapshot = (document, layout, state) => {
412
+ const step = state.variables[layout.stepVariableId];
413
+ const variables = {};
414
+ for (const declaration of document.variables) {
415
+ if (declaration.id === layout.stepVariableId)
416
+ continue;
417
+ variables[declaration.id] = previewAppValue(state.variables[declaration.id]);
418
+ }
419
+ const inputs = {};
420
+ for (const [key, slot] of Object.entries(state.inputs)) {
421
+ inputs[key] = previewAppValue(slot.value);
422
+ }
423
+ const stepOf = (binding) => layout.steps.find((step) => step.fields.some((field) => field.binding === binding))?.value;
424
+ const missing = (document.recipe?.inputs ?? [])
425
+ .filter((input) => input.required && isEmptyValue(state.variables[input.id]))
426
+ .map((input) => {
427
+ const step = stepOf(`var:${input.id}`);
428
+ return `${input.id} (${input.label})${step ? ` on step ${step}` : ""}`;
429
+ });
430
+ const operations = document.operations.map((operation) => {
431
+ const id = state.activeInvocation[operation.id];
432
+ const resolved = id ? (state.invocationAliases[id] ?? id) : undefined;
433
+ const invocation = resolved ? state.invocations[resolved] : undefined;
434
+ const entry = {
435
+ id: operation.id,
436
+ name: operation.name,
437
+ status: invocation ? invocation.status : "idle"
438
+ };
439
+ if (invocation?.error)
440
+ entry.error = invocation.error;
441
+ return entry;
442
+ });
443
+ return {
444
+ step: isString(step) ? step : null,
445
+ steps: layout.steps.map(({ value, title }) => ({ value, title })),
446
+ variables,
447
+ inputs,
448
+ missing_required: missing,
449
+ operations
450
+ };
451
+ };
452
+ /**
453
+ * The invocation an operation's latest run settled into, following the
454
+ * client-reservation alias to the provider job id.
455
+ */
456
+ export const settledInvocation = (state, operationId, before) => {
457
+ const active = state.activeInvocation[operationId];
458
+ if (!active || active === before)
459
+ return null;
460
+ const id = state.invocationAliases[active] ?? active;
461
+ if (id === before)
462
+ return null;
463
+ const invocation = state.invocations[id];
464
+ if (!invocation || isLiveInvocation(invocation))
465
+ return null;
466
+ const settled = {
467
+ id,
468
+ status: invocation.status
469
+ };
470
+ if (invocation.error)
471
+ settled.error = invocation.error;
472
+ return settled;
473
+ };
474
+ //# sourceMappingURL=chat-app.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-app.js","sourceRoot":"","sources":["../src/chat-app.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EACL,gBAAgB,EAGjB,MAAM,YAAY,CAAC;AAkCpB,MAAM,UAAU,GAAG,CAAC,KAAc,EAAqB,EAAE,CACvD,QAAQ,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAEnE,MAAM,QAAQ,GAAG,CAAC,IAAc,EAAE,WAAmB,EAAiB,EAAE;IACtE,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC;IACpC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,KAAK,WAAW,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI,EAAE,CAAC;QACxE,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAClD,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,oCAAoC,CAAC;AAE3D,4EAA4E;AAC5E,MAAM,QAAQ,GAAG,CAAC,KAAgB,EAAE,WAAmB,EAAkB,EAAE;IACzE,MAAM,MAAM,GAAmB,EAAE,CAAC;IAClC,MAAM,IAAI,GAAG,CAAC,KAAc,EAAQ,EAAE;QACpC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,C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