@agimon-ai/po-codemode 0.0.1-alpha.11 → 0.0.1-alpha.111

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.
@@ -1,5 +1,5 @@
1
- import { defineToolRenderer, defineWebPlugin, toolResultTextLines } from "@agimon-ai/po-core/web";
2
- import { CodeBlock, MessageItem, MessageItemBody, MessageItemHeader, MessageItemStatus, toolTone } from "@agimon-ai/po-web-components";
1
+ import { defineToolRenderer, defineWebPlugin } from "@agimon-ai/po-core/web";
2
+ import { CodeBlock, Markdown, MessageItem, MessageItemBody, MessageItemHeader, MessageItemStatus, ViewableImage, markdownMediaReview, toolTone } from "@agimon-ai/po-web-components";
3
3
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
4
  //#region src/extensions/workspaces/sessions/(frontend)/tool/_lib/execToolView.ts
5
5
  /** Tool names this package registers (registerTool's `name`). */
@@ -10,6 +10,7 @@ const ARGS_MAX = 160;
10
10
  const CALLS_MAX = 50;
11
11
  const IMAGE_TYPES = /^image\/(?:png|jpeg|webp|gif)$/u;
12
12
  const SAVED_LINE = /^Saved as (\S+) \((.+)\)$/u;
13
+ const DOCUMENT_LINE = /^(?:#{1,6} |```)/mu;
13
14
  function record(value) {
14
15
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
15
16
  }
@@ -49,9 +50,20 @@ function execCalls(details) {
49
50
  if (!Array.isArray(calls)) return [];
50
51
  return calls.slice(0, CALLS_MAX).map(callOf).filter((call) => call !== void 0);
51
52
  }
52
- /** A call's arguments on one line, for a row that has no card of its own. */
53
+ /** A call's arguments on one line, for a row that has no card of its own: `key: value · key: value`, strings unquoted. */
53
54
  function callArgsSummary(args) {
54
- return Object.keys(args).length === 0 ? "" : clip(JSON.stringify(args), ARGS_MAX);
55
+ return clip(Object.entries(args).map(([key, value]) => `${key}: ${typeof value === "string" ? value : JSON.stringify(value) ?? String(value)}`).join(" · "), ARGS_MAX);
56
+ }
57
+ /** A script's return on one line: a JSON object folds like call arguments, other JSON compacts, plain text joins its lines. */
58
+ function returnSummary(text) {
59
+ let value;
60
+ try {
61
+ value = JSON.parse(text);
62
+ } catch {
63
+ return text.split("\n").join(" ");
64
+ }
65
+ const object = record(value);
66
+ return object !== void 0 && Object.keys(object).length > 0 ? callArgsSummary(object) : clip(JSON.stringify(value), ARGS_MAX);
55
67
  }
56
68
  /** What a result holds, with the saved-script footer and the pictures taken out of the text. */
57
69
  function execResultView(result) {
@@ -60,29 +72,34 @@ function execResultView(result) {
60
72
  images: []
61
73
  };
62
74
  let saved;
63
- const content = [];
75
+ const texts = [];
76
+ const images = [];
64
77
  for (const block of result.content) {
65
- const text = record(block)?.type === "text" ? record(block)?.text : void 0;
66
- const match = typeof text === "string" ? SAVED_LINE.exec(text.trim()) : null;
67
- if (match?.[1] !== void 0 && match[2] !== void 0) saved = {
68
- id: match[1],
69
- path: match[2]
70
- };
71
- else content.push(block);
78
+ const item = record(block);
79
+ if (item?.type === "text" && typeof item.text === "string") {
80
+ const match = SAVED_LINE.exec(item.text.trim());
81
+ if (match?.[1] !== void 0 && match[2] !== void 0) saved = {
82
+ id: match[1],
83
+ path: match[2]
84
+ };
85
+ else texts.push(item.text);
86
+ } else if (item?.type === "image" && typeof item.data === "string" && typeof item.mimeType === "string" && IMAGE_TYPES.test(item.mimeType)) images.push({
87
+ mimeType: item.mimeType,
88
+ data: item.data
89
+ });
72
90
  }
73
- const images = content.flatMap((block) => {
74
- const image = record(block);
75
- return image?.type === "image" && typeof image.data === "string" && typeof image.mimeType === "string" && IMAGE_TYPES.test(image.mimeType) ? [{
76
- mimeType: image.mimeType,
77
- data: image.data
78
- }] : [];
79
- });
91
+ const lines = texts.join("\n").replaceAll("\r\n", "\n").replaceAll("\r", "\n").replaceAll(" ", " ").split("\n");
92
+ while (lines.length > 0 && lines.at(-1)?.trim() === "") lines.pop();
80
93
  return {
81
- lines: toolResultTextLines(content),
94
+ lines,
82
95
  ...saved === void 0 ? {} : { saved },
83
96
  images
84
97
  };
85
98
  }
99
+ /** Whether result text is a document, such as a report or a mermaid diagram, to draw rather than print. */
100
+ function readsAsDocument(text) {
101
+ return DOCUMENT_LINE.test(text);
102
+ }
86
103
  /** The header line for discover: what was asked for. */
87
104
  function discoverSummary(args) {
88
105
  if (typeof args.namespace === "string" && args.namespace !== "") return args.namespace;
@@ -145,138 +162,298 @@ function ToolSection({ label, children }) {
145
162
  }
146
163
  //#endregion
147
164
  //#region src/extensions/workspaces/sessions/(frontend)/tool/_components/ExecToolCard.tsx
148
- function CallRow({ call }) {
149
- const args = callArgsSummary(call.args);
165
+ /** The tree's elbow: a short branch from the rail to the item it leads to. */
166
+ const BRANCH = "relative before:absolute before:top-[1.125rem] before:-left-4 before:w-3 before:border-t before:border-po-border-soft";
167
+ const SUMMARY = "flex min-h-6 cursor-pointer list-none items-center gap-x-2 gap-y-0.5 [&::-webkit-details-marker]:hidden";
168
+ /** The folding mark at the end of a summary; it turns when the section opens. */
169
+ function Chevron() {
170
+ return /* @__PURE__ */ jsx("span", {
171
+ "aria-hidden": true,
172
+ className: "w-3 shrink-0 text-center text-po-dim transition-transform group-open:rotate-90",
173
+ children: "›"
174
+ });
175
+ }
176
+ /**
177
+ * Pictures and documents stay on screen whether or not their section is open: they are the point of the call.
178
+ * `review` is Author's annotate panel when Author is installed; without it the viewer only pans and zooms.
179
+ */
180
+ function Visuals({ text, images, label, review }) {
181
+ return /* @__PURE__ */ jsxs(Fragment, { children: [readsAsDocument(text) ? /* @__PURE__ */ jsx("div", {
182
+ "data-testid": "tool-output-document",
183
+ className: "max-h-96 overflow-auto text-sm",
184
+ children: /* @__PURE__ */ jsx(Markdown, {
185
+ text,
186
+ renderMediaReview: review
187
+ })
188
+ }) : null, images.map((image, index) => /* @__PURE__ */ jsx(ViewableImage, {
189
+ src: `data:${image.mimeType};base64,${image.data}`,
190
+ alt: `${label} image ${String(index + 1)}`,
191
+ renderReview: review,
192
+ "data-testid": "tool-output-image",
193
+ className: "max-h-48 max-w-full rounded-md border border-po-border-soft"
194
+ }, `${image.mimeType}-${String(index)}`))] });
195
+ }
196
+ /** One call on the rail. It opens to its whole args and result; its pictures and documents show either way. */
197
+ function CallRow({ call, review, suppressOutputs }) {
198
+ const view = execResultView(call.result ?? null);
199
+ const text = view.lines.join("\n");
200
+ const printed = text !== "" && (!call.ok || !readsAsDocument(text));
201
+ const opens = Object.keys(call.args).length > 0 || printed || call.error !== void 0;
202
+ const head = /* @__PURE__ */ jsxs(Fragment, { children: [
203
+ /* @__PURE__ */ jsx("span", {
204
+ className: "shrink-0 truncate font-mono font-semibold text-po-text max-sm:basis-full",
205
+ children: call.name
206
+ }),
207
+ /* @__PURE__ */ jsx("span", {
208
+ className: "min-w-0 flex-1 truncate font-mono text-po-dim group-open:invisible",
209
+ children: callArgsSummary(call.args)
210
+ }),
211
+ /* @__PURE__ */ jsx("span", {
212
+ "aria-hidden": true,
213
+ className: `w-3 shrink-0 text-center ${call.ok ? "text-po-green" : "text-po-red"}`,
214
+ children: call.ok ? "✓" : "✗"
215
+ }),
216
+ /* @__PURE__ */ jsx("span", {
217
+ className: "sr-only",
218
+ children: call.ok ? "completed" : "failed"
219
+ }),
220
+ /* @__PURE__ */ jsxs("span", {
221
+ className: "w-16 shrink-0 text-right tabular-nums text-po-dim",
222
+ children: [call.ms, " ms"]
223
+ })
224
+ ] });
150
225
  return /* @__PURE__ */ jsxs("div", {
151
226
  "data-testid": "exec-call",
152
- className: "flex flex-col gap-0.5",
153
- children: [/* @__PURE__ */ jsxs("div", {
154
- className: "flex items-center gap-2 text-sm",
155
- children: [
156
- /* @__PURE__ */ jsx("span", {
157
- className: "shrink-0 font-mono text-po-text",
158
- children: call.name
159
- }),
160
- /* @__PURE__ */ jsx("span", {
161
- className: "min-w-0 flex-1 truncate font-mono text-po-dim",
162
- children: args
163
- }),
164
- /* @__PURE__ */ jsx("span", {
165
- "aria-hidden": true,
166
- className: `w-3 shrink-0 text-center ${call.ok ? "text-po-green" : "text-po-red"}`,
167
- children: call.ok ? "✓" : "✗"
168
- }),
169
- /* @__PURE__ */ jsxs("span", {
170
- className: "w-16 shrink-0 text-right tabular-nums text-po-dim",
171
- children: [call.ms, " ms"]
172
- })
173
- ]
174
- }), call.error === void 0 ? null : /* @__PURE__ */ jsx("p", {
175
- className: "pl-5 text-sm break-words text-po-red",
176
- children: call.error
177
- })]
227
+ className: "flex flex-col gap-2 py-1.5",
228
+ children: [opens ? /* @__PURE__ */ jsxs("details", {
229
+ className: "group text-sm",
230
+ children: [/* @__PURE__ */ jsxs("summary", {
231
+ className: `${SUMMARY} flex-wrap`,
232
+ children: [head, /* @__PURE__ */ jsx(Chevron, {})]
233
+ }), /* @__PURE__ */ jsxs("div", {
234
+ className: "mt-2 flex flex-col gap-2",
235
+ children: [
236
+ Object.keys(call.args).length > 0 ? /* @__PURE__ */ jsx(CodeBlock, {
237
+ text: JSON.stringify(call.args, null, 2),
238
+ className: "language-json"
239
+ }) : null,
240
+ printed ? /* @__PURE__ */ jsx("pre", {
241
+ "data-testid": "exec-call-output",
242
+ className: "max-h-72 overflow-auto font-mono text-sm break-words whitespace-pre-wrap text-po-text",
243
+ children: text
244
+ }) : null,
245
+ call.error === void 0 ? null : /* @__PURE__ */ jsx("p", {
246
+ className: "text-sm break-words text-po-red",
247
+ children: call.error
248
+ })
249
+ ]
250
+ })]
251
+ }) : /* @__PURE__ */ jsx("div", {
252
+ className: "flex flex-wrap items-center gap-x-2 gap-y-0.5 text-sm",
253
+ children: head
254
+ }), !suppressOutputs ? /* @__PURE__ */ jsx(Visuals, {
255
+ text: call.ok ? text : "",
256
+ images: view.images,
257
+ label: call.name,
258
+ review
259
+ }) : null]
178
260
  });
179
261
  }
180
- function Calls({ calls, renderTool }) {
181
- return /* @__PURE__ */ jsx("ul", {
262
+ /** The script's outcome as the tree's last leaf: one line until opened, the whole text after; visuals always. */
263
+ function Returned({ result, isError, review, suppressOutputs }) {
264
+ const view = execResultView(result);
265
+ const text = view.lines.join("\n");
266
+ const label = isError ? "Error" : "Returned";
267
+ const ink = isError ? "text-po-red" : "text-po-text";
268
+ return /* @__PURE__ */ jsxs("div", {
269
+ "data-testid": `tool-result-${execToolName}`,
182
270
  className: "flex flex-col gap-2",
183
- children: calls.map((call, index) => {
184
- const card = call.tool === void 0 || renderTool === void 0 ? null : renderTool({
185
- toolName: call.tool,
186
- args: call.args,
187
- result: call.result ?? null,
188
- isError: !call.ok
189
- });
190
- return /* @__PURE__ */ jsx("li", { children: card ?? /* @__PURE__ */ jsx(CallRow, { call }) }, `${String(index)}-${call.name}`);
191
- })
271
+ children: [view.lines.length === 0 ? /* @__PURE__ */ jsx("p", {
272
+ className: "text-sm text-po-dim",
273
+ children: isError ? "Failed with no output." : "Returned nothing."
274
+ }) : !isError && readsAsDocument(text) ? /* @__PURE__ */ jsx("p", {
275
+ className: "text-sm font-semibold text-po-dim",
276
+ children: label
277
+ }) : /* @__PURE__ */ jsxs("details", {
278
+ className: "group text-sm",
279
+ children: [/* @__PURE__ */ jsxs("summary", {
280
+ className: `${SUMMARY} text-po-dim hover:text-po-blue`,
281
+ children: [
282
+ /* @__PURE__ */ jsx("span", {
283
+ className: "shrink-0 font-semibold",
284
+ children: label
285
+ }),
286
+ /* @__PURE__ */ jsx("span", {
287
+ className: `min-w-0 flex-1 truncate font-mono group-open:hidden ${ink}`,
288
+ children: returnSummary(text)
289
+ }),
290
+ /* @__PURE__ */ jsx(Chevron, {})
291
+ ]
292
+ }), /* @__PURE__ */ jsx("pre", {
293
+ "data-testid": "tool-output",
294
+ className: `mt-1 max-h-72 overflow-auto font-mono text-sm break-words whitespace-pre-wrap ${ink}`,
295
+ children: text
296
+ })]
297
+ }), !suppressOutputs ? /* @__PURE__ */ jsx(Visuals, {
298
+ text: isError ? "" : text,
299
+ images: view.images,
300
+ label: "Script",
301
+ review
302
+ }) : null]
192
303
  });
193
304
  }
194
305
  /**
195
- * The exec tool's timeline item. It stays folded until opened: the script is the
196
- * point of the call, so opening shows the code, every namespace call it made
197
- * (as the owning tool's card when one exists), then what it returned.
306
+ * The exec tool's timeline item. The calls the script made hang under it as a
307
+ * tree, each as the owning tool's own card when one exists, with what the
308
+ * script returned as the last leaf. Opening the item shows the script itself.
198
309
  */
199
- function ExecToolCard({ args, result, running, isError, defaultExpanded = false, renderTool }) {
310
+ function ExecToolCard(props) {
311
+ const { args, result, running, isError, defaultExpanded = false, renderTool, suppressOutputs } = props;
312
+ const review = markdownMediaReview(props);
200
313
  const code = execCode(args);
201
- const view = execResultView(result);
314
+ const saved = execResultView(result).saved;
202
315
  const calls = execCalls(result?.details);
316
+ const failed = calls.filter((call) => !call.ok).length;
317
+ const settled = !running || result !== null;
203
318
  return /* @__PURE__ */ jsx(MessageItem, {
204
319
  tone: toolTone({
205
320
  running,
206
321
  isError
207
322
  }),
208
- expandable: true,
323
+ expandable: code !== "",
209
324
  defaultExpanded,
210
- children: ({ expanded }) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(MessageItemHeader, {
211
- title: execToolName,
212
- children: [/* @__PURE__ */ jsx("span", {
213
- "data-testid": `tool-call-${execToolName}`,
214
- className: "min-w-0 flex-1 truncate text-po-text",
215
- children: execSummary(args)
216
- }), calls.length > 0 ? /* @__PURE__ */ jsxs("span", {
217
- className: "shrink-0 text-sm text-po-dim",
218
- children: [
219
- calls.length,
220
- " ",
221
- calls.length === 1 ? "call" : "calls"
222
- ]
223
- }) : null]
224
- }), expanded ? /* @__PURE__ */ jsxs(MessageItemBody, {
225
- "data-testid": `tool-result-${execToolName}`,
226
- className: "flex flex-col gap-4",
227
- children: [
228
- code === "" ? null : /* @__PURE__ */ jsx(ToolSection, {
325
+ children: ({ expanded }) => /* @__PURE__ */ jsxs(Fragment, { children: [
326
+ /* @__PURE__ */ jsxs(MessageItemHeader, {
327
+ title: execToolName,
328
+ children: [/* @__PURE__ */ jsx("span", {
329
+ "data-testid": `tool-call-${execToolName}`,
330
+ className: "min-w-0 flex-1 truncate text-po-text",
331
+ children: execSummary(args)
332
+ }), calls.length > 0 ? /* @__PURE__ */ jsxs("span", {
333
+ className: "shrink-0 text-sm text-po-dim",
334
+ children: [
335
+ calls.length,
336
+ " ",
337
+ calls.length === 1 ? "call" : "calls",
338
+ failed > 0 ? /* @__PURE__ */ jsxs("span", {
339
+ className: "text-po-red",
340
+ children: [
341
+ ", ",
342
+ failed,
343
+ " failed"
344
+ ]
345
+ }) : null
346
+ ]
347
+ }) : null]
348
+ }),
349
+ expanded ? /* @__PURE__ */ jsxs(MessageItemBody, {
350
+ className: "flex flex-col gap-2",
351
+ children: [/* @__PURE__ */ jsx(ToolSection, {
229
352
  label: "Code",
230
353
  children: /* @__PURE__ */ jsx(CodeBlock, {
231
354
  text: code,
232
355
  className: "language-ts"
233
356
  })
234
- }),
235
- calls.length === 0 ? null : /* @__PURE__ */ jsx(ToolSection, {
236
- label: "Calls",
237
- children: /* @__PURE__ */ jsx(Calls, {
238
- calls,
239
- renderTool
240
- })
241
- }),
242
- running && view.lines.length === 0 ? /* @__PURE__ */ jsx(MessageItemStatus, {
243
- tone: "running",
244
- children: "running"
245
- }) : /* @__PURE__ */ jsxs(ToolSection, {
246
- label: isError ? "Error" : "Result",
247
- children: [
248
- view.lines.length === 0 && view.images.length === 0 ? /* @__PURE__ */ jsx("p", {
249
- className: "text-sm text-po-dim",
250
- children: "No output."
251
- }) : null,
252
- view.lines.length === 0 ? null : /* @__PURE__ */ jsx("pre", {
253
- "data-testid": "tool-output",
254
- className: `max-h-72 overflow-auto font-mono text-sm break-words whitespace-pre-wrap ${isError ? "text-po-red" : "text-po-text"}`,
255
- children: view.lines.join("\n")
256
- }),
257
- view.images.map((image, index) => /* @__PURE__ */ jsx("img", {
258
- src: `data:${image.mimeType};base64,${image.data}`,
259
- alt: `Script image ${String(index + 1)}`,
260
- "data-testid": "tool-output-image",
261
- className: "max-h-96 max-w-full self-start rounded-md border border-po-border-soft"
262
- }, `${image.mimeType}-${String(index)}`))
263
- ]
264
- }),
265
- view.saved === void 0 ? null : /* @__PURE__ */ jsxs("p", {
357
+ }), saved === void 0 ? null : /* @__PURE__ */ jsxs("p", {
266
358
  className: "text-sm text-po-dim",
267
- title: view.saved.path,
359
+ title: saved.path,
268
360
  children: ["Saved as ", /* @__PURE__ */ jsx("span", {
269
361
  className: "font-mono text-po-text",
270
- children: view.saved.id
362
+ children: saved.id
271
363
  })]
364
+ })]
365
+ }) : null,
366
+ settled ? /* @__PURE__ */ jsxs("ol", {
367
+ "aria-label": "Script calls",
368
+ className: "mx-4 mb-3 flex flex-col gap-2 border-l border-po-border-soft pl-4 sm:ml-[2.125rem]",
369
+ children: [calls.map((call, index) => {
370
+ const card = call.tool === void 0 || renderTool === void 0 ? null : renderTool({
371
+ toolName: call.tool,
372
+ args: call.args,
373
+ result: call.result ?? null,
374
+ isError: !call.ok
375
+ });
376
+ return /* @__PURE__ */ jsx("li", {
377
+ className: `${BRANCH} flex flex-col gap-2`,
378
+ children: card === null ? /* @__PURE__ */ jsx(CallRow, {
379
+ call,
380
+ review,
381
+ suppressOutputs
382
+ }) : /* @__PURE__ */ jsxs(Fragment, { children: [card, !suppressOutputs ? /* @__PURE__ */ jsx(Visuals, {
383
+ text: "",
384
+ images: execResultView(call.result ?? null).images,
385
+ label: call.name,
386
+ review
387
+ }) : null] })
388
+ }, `${String(index)}-${call.name}`);
389
+ }), /* @__PURE__ */ jsx("li", {
390
+ className: BRANCH,
391
+ children: /* @__PURE__ */ jsx(Returned, {
392
+ result,
393
+ isError,
394
+ review,
395
+ suppressOutputs
396
+ })
397
+ })]
398
+ }) : null
399
+ ] })
400
+ });
401
+ }
402
+ /** Rich visuals already supported by exec, normalized for an opt-in output surface. */
403
+ function execToolOutputs(props) {
404
+ const review = markdownMediaReview(props);
405
+ const outputs = [];
406
+ const collect = (result, id, title, failed) => {
407
+ const text = execResultView(result).lines.join("\n");
408
+ if (!failed && readsAsDocument(text)) outputs.push({
409
+ id: `${id}:document`,
410
+ title,
411
+ content: /* @__PURE__ */ jsx(Visuals, {
412
+ text,
413
+ images: [],
414
+ label: title,
415
+ review
416
+ })
417
+ });
418
+ (result?.content ?? []).forEach((block, index) => {
419
+ if (block === null || typeof block !== "object" || !("type" in block) || block.type !== "image") return;
420
+ outputs.push({
421
+ id: `${id}:image:${String(index)}`,
422
+ title: `${title} image ${String(index + 1)}`,
423
+ content: /* @__PURE__ */ jsx(Visuals, {
424
+ text: "",
425
+ images: execResultView({
426
+ content: [block],
427
+ details: null
428
+ }).images,
429
+ label: title,
430
+ review
272
431
  })
273
- ]
274
- }) : null] })
432
+ });
433
+ });
434
+ };
435
+ execCalls(props.result?.details).forEach((call, index) => {
436
+ const owned = call.tool === void 0 ? [] : props.toolOutputs?.({
437
+ toolName: call.tool,
438
+ args: call.args,
439
+ result: call.result ?? null,
440
+ isError: !call.ok
441
+ }) ?? [];
442
+ if (owned.length === 0) collect(call.result ?? null, `call:${String(index)}`, call.name, !call.ok);
443
+ else for (const output of owned) outputs.push({
444
+ ...output,
445
+ id: `call:${String(index)}:${output.id}`
446
+ });
275
447
  });
448
+ collect(props.result, "returned", "Script", props.isError);
449
+ return outputs;
276
450
  }
277
451
  //#endregion
278
452
  //#region src/extensions/workspaces/sessions/(frontend)/tool/exec.web.tsx
279
- var exec_web_default = defineToolRenderer({ message: ExecToolCard });
453
+ var exec_web_default = defineToolRenderer({
454
+ message: ExecToolCard,
455
+ outputs: execToolOutputs
456
+ });
280
457
  //#endregion
281
458
  //#region generated/web.ts
282
459
  const via = (identity, value) => value === void 0 ? void 0 : {
@@ -1 +1 @@
1
- {"version":3,"file":"web.mjs","names":["toolDiscover","toolExec"],"sources":["../../src/extensions/workspaces/sessions/(frontend)/tool/_lib/execToolView.ts","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/DiscoverToolCard.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/discover.web.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/ToolSection.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/ExecToolCard.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/exec.web.tsx","../../generated/web.ts"],"sourcesContent":["import { type ToolResultView, toolResultTextLines } from '@agimon-ai/po-core/web';\n\n/** Tool names this package registers (registerTool's `name`). */\nexport const execToolName = 'exec' as const;\nexport const discoverToolName = 'discover' as const;\n\nconst SUMMARY_MAX = 120;\nconst ARGS_MAX = 160;\nconst CALLS_MAX = 50;\nconst IMAGE_TYPES = /^image\\/(?:png|jpeg|webp|gif)$/u;\nconst SAVED_LINE = /^Saved as (\\S+) \\((.+)\\)$/u;\n\nfunction record(value: unknown): Record<string, unknown> | undefined {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : undefined;\n}\n\nfunction clip(text: string, max: number): string {\n return text.length <= max ? text : `${text.slice(0, max - 1)}…`;\n}\n\n/** The script the call ran, exactly as the agent wrote it. */\nexport function execCode(args: Readonly<Record<string, unknown>>): string {\n return typeof args.code === 'string' ? args.code : '';\n}\n\n/** The header line: the script's first line, with a leading `//` comment marker dropped. */\nexport function execSummary(args: Readonly<Record<string, unknown>>): string {\n const first = execCode(args)\n .split('\\n')\n .map((line) => line.trim())\n .find((line) => line !== '');\n if (first === undefined) return 'script';\n return clip(first.replace(/^\\/\\/+\\s*/u, ''), SUMMARY_MAX);\n}\n\n/** One namespace call the script made, as exec reports it in the result's details. */\nexport interface ExecCall {\n /** The member called, such as `browser.click` or `mcp.github.search_issues`. */\n name: string;\n args: Record<string, unknown>;\n ok: boolean;\n ms: number;\n /** The tool name whose own card shows this call, when another package has one. */\n tool?: string;\n error?: string;\n result?: ToolResultView;\n}\n\nfunction callOf(value: unknown): ExecCall | undefined {\n const call = record(value);\n if (call === undefined || typeof call.name !== 'string' || call.name === '') return undefined;\n const result = record(call.result);\n return {\n name: call.name,\n args: record(call.args) ?? {},\n ok: call.ok !== false,\n ms: typeof call.ms === 'number' && Number.isFinite(call.ms) && call.ms >= 0 ? Math.round(call.ms) : 0,\n ...(typeof call.tool === 'string' && call.tool !== '' ? { tool: call.tool } : {}),\n ...(typeof call.error === 'string' && call.error !== '' ? { error: call.error } : {}),\n ...(result !== undefined && Array.isArray(result.content)\n ? { result: { content: result.content, details: result.details } }\n : {}),\n };\n}\n\n/** The nested calls recorded in a result's details; anything malformed is skipped. */\nexport function execCalls(details: unknown): ExecCall[] {\n const calls = record(details)?.calls;\n if (!Array.isArray(calls)) return [];\n return calls\n .slice(0, CALLS_MAX)\n .map(callOf)\n .filter((call): call is ExecCall => call !== undefined);\n}\n\n/** A call's arguments on one line, for a row that has no card of its own. */\nexport function callArgsSummary(args: Readonly<Record<string, unknown>>): string {\n return Object.keys(args).length === 0 ? '' : clip(JSON.stringify(args), ARGS_MAX);\n}\n\nexport interface ExecImage {\n mimeType: string;\n data: string;\n}\n\nexport interface ExecResultView {\n lines: string[];\n /** The saved-script footer exec appends: the id to import it by, and where it lives. */\n saved?: { id: string; path: string };\n images: ExecImage[];\n}\n\n/** What a result holds, with the saved-script footer and the pictures taken out of the text. */\nexport function execResultView(result: ToolResultView | null): ExecResultView {\n if (result === null) return { lines: [], images: [] };\n let saved: ExecResultView['saved'];\n const content: unknown[] = [];\n for (const block of result.content) {\n const text = record(block)?.type === 'text' ? record(block)?.text : undefined;\n const match = typeof text === 'string' ? SAVED_LINE.exec(text.trim()) : null;\n if (match?.[1] !== undefined && match[2] !== undefined) saved = { id: match[1], path: match[2] };\n else content.push(block);\n }\n const images = content.flatMap((block): ExecImage[] => {\n const image = record(block);\n return image?.type === 'image' &&\n typeof image.data === 'string' &&\n typeof image.mimeType === 'string' &&\n IMAGE_TYPES.test(image.mimeType)\n ? [{ mimeType: image.mimeType, data: image.data }]\n : [];\n });\n return { lines: toolResultTextLines(content), ...(saved === undefined ? {} : { saved }), images };\n}\n\n/** The header line for discover: what was asked for. */\nexport function discoverSummary(args: Readonly<Record<string, unknown>>): string {\n if (typeof args.namespace === 'string' && args.namespace !== '') return args.namespace;\n if (typeof args.query === 'string' && args.query !== '') return `find \"${clip(args.query, SUMMARY_MAX)}\"`;\n return 'namespaces and scripts';\n}\n","import type { ToolMessageRenderProps } from '@agimon-ai/po-core/web';\nimport {\n CodeBlock,\n MessageItem,\n MessageItemBody,\n MessageItemHeader,\n MessageItemStatus,\n toolTone,\n} from '@agimon-ai/po-web-components';\n\nimport { discoverSummary, discoverToolName } from '../_lib/execToolView';\n\nexport type DiscoverToolCardProps = ToolMessageRenderProps & { defaultExpanded?: boolean };\n\n/** The discover tool's timeline item: folded to what was asked for, open to what came back. */\nexport function DiscoverToolCard({ args, output, running, isError, defaultExpanded = false }: DiscoverToolCardProps) {\n const declarations = typeof args.namespace === 'string' && args.namespace !== '' && !isError;\n return (\n <MessageItem tone={toolTone({ running, isError })} expandable defaultExpanded={defaultExpanded}>\n {({ expanded }) => (\n <>\n <MessageItemHeader title={discoverToolName}>\n <span data-testid={`tool-call-${discoverToolName}`} className=\"min-w-0 flex-1 truncate text-po-text\">\n {discoverSummary(args)}\n </span>\n </MessageItemHeader>\n {expanded ? (\n <MessageItemBody data-testid={`tool-result-${discoverToolName}`} className=\"flex flex-col gap-2\">\n {running && output === '' ? <MessageItemStatus tone=\"running\">running</MessageItemStatus> : null}\n {output === '' ? null : declarations ? (\n <div className=\"max-h-96 overflow-auto\">\n <CodeBlock text={output} className=\"language-ts\" />\n </div>\n ) : (\n <pre\n data-testid=\"tool-output\"\n className={`max-h-96 overflow-auto font-mono text-sm break-words whitespace-pre-wrap ${isError ? 'text-po-red' : 'text-po-text'}`}\n >\n {output}\n </pre>\n )}\n </MessageItemBody>\n ) : null}\n </>\n )}\n </MessageItem>\n );\n}\n","import { defineToolRenderer } from '@agimon-ai/po-core/web';\n\nimport { DiscoverToolCard } from './_components/DiscoverToolCard';\n\nexport default defineToolRenderer({ message: DiscoverToolCard });\n","import type { ReactNode } from 'react';\n\n/** A labelled part of an expanded card body. */\nexport function ToolSection({ label, children }: { label: string; children: ReactNode }) {\n return (\n <section className=\"flex flex-col gap-1.5\">\n <h4 className=\"text-sm font-medium text-po-dim\">{label}</h4>\n {children}\n </section>\n );\n}\n","import type { ToolMessageRenderProps } from '@agimon-ai/po-core/web';\nimport {\n CodeBlock,\n MessageItem,\n MessageItemBody,\n MessageItemHeader,\n MessageItemStatus,\n toolTone,\n} from '@agimon-ai/po-web-components';\n\nimport {\n callArgsSummary,\n execCalls,\n execCode,\n execResultView,\n execSummary,\n execToolName,\n type ExecCall,\n} from '../_lib/execToolView';\nimport { ToolSection } from './ToolSection';\n\n/** Draws another tool's own card for a nested call, or nothing when no package owns one. */\nexport type RenderNestedTool = NonNullable<ToolMessageRenderProps['renderTool']>;\n\nexport type ExecToolCardProps = ToolMessageRenderProps & { defaultExpanded?: boolean };\n\nfunction CallRow({ call }: { call: ExecCall }) {\n const args = callArgsSummary(call.args);\n return (\n <div data-testid=\"exec-call\" className=\"flex flex-col gap-0.5\">\n <div className=\"flex items-center gap-2 text-sm\">\n <span className=\"shrink-0 font-mono text-po-text\">{call.name}</span>\n <span className=\"min-w-0 flex-1 truncate font-mono text-po-dim\">{args}</span>\n <span aria-hidden className={`w-3 shrink-0 text-center ${call.ok ? 'text-po-green' : 'text-po-red'}`}>\n {call.ok ? '✓' : '✗'}\n </span>\n <span className=\"w-16 shrink-0 text-right tabular-nums text-po-dim\">{call.ms} ms</span>\n </div>\n {call.error === undefined ? null : <p className=\"pl-5 text-sm break-words text-po-red\">{call.error}</p>}\n </div>\n );\n}\n\nfunction Calls({ calls, renderTool }: { calls: readonly ExecCall[]; renderTool: RenderNestedTool | undefined }) {\n return (\n <ul className=\"flex flex-col gap-2\">\n {calls.map((call, index) => {\n const card =\n call.tool === undefined || renderTool === undefined\n ? null\n : renderTool({\n toolName: call.tool,\n args: call.args,\n result: call.result ?? null,\n isError: !call.ok,\n });\n return <li key={`${String(index)}-${call.name}`}>{card ?? <CallRow call={call} />}</li>;\n })}\n </ul>\n );\n}\n\n/**\n * The exec tool's timeline item. It stays folded until opened: the script is the\n * point of the call, so opening shows the code, every namespace call it made\n * (as the owning tool's card when one exists), then what it returned.\n */\nexport function ExecToolCard({\n args,\n result,\n running,\n isError,\n defaultExpanded = false,\n renderTool,\n}: ExecToolCardProps) {\n const code = execCode(args);\n const view = execResultView(result);\n const calls = execCalls(result?.details);\n return (\n <MessageItem tone={toolTone({ running, isError })} expandable defaultExpanded={defaultExpanded}>\n {({ expanded }) => (\n <>\n <MessageItemHeader title={execToolName}>\n <span data-testid={`tool-call-${execToolName}`} className=\"min-w-0 flex-1 truncate text-po-text\">\n {execSummary(args)}\n </span>\n {calls.length > 0 ? (\n <span className=\"shrink-0 text-sm text-po-dim\">\n {calls.length} {calls.length === 1 ? 'call' : 'calls'}\n </span>\n ) : null}\n </MessageItemHeader>\n {expanded ? (\n <MessageItemBody data-testid={`tool-result-${execToolName}`} className=\"flex flex-col gap-4\">\n {code === '' ? null : (\n <ToolSection label=\"Code\">\n <CodeBlock text={code} className=\"language-ts\" />\n </ToolSection>\n )}\n {calls.length === 0 ? null : (\n <ToolSection label=\"Calls\">\n <Calls calls={calls} renderTool={renderTool} />\n </ToolSection>\n )}\n {running && view.lines.length === 0 ? (\n <MessageItemStatus tone=\"running\">running</MessageItemStatus>\n ) : (\n <ToolSection label={isError ? 'Error' : 'Result'}>\n {view.lines.length === 0 && view.images.length === 0 ? (\n <p className=\"text-sm text-po-dim\">No output.</p>\n ) : null}\n {view.lines.length === 0 ? null : (\n <pre\n data-testid=\"tool-output\"\n className={`max-h-72 overflow-auto font-mono text-sm break-words whitespace-pre-wrap ${isError ? 'text-po-red' : 'text-po-text'}`}\n >\n {view.lines.join('\\n')}\n </pre>\n )}\n {view.images.map((image, index) => (\n <img\n key={`${image.mimeType}-${String(index)}`}\n src={`data:${image.mimeType};base64,${image.data}`}\n alt={`Script image ${String(index + 1)}`}\n data-testid=\"tool-output-image\"\n className=\"max-h-96 max-w-full self-start rounded-md border border-po-border-soft\"\n />\n ))}\n </ToolSection>\n )}\n {view.saved === undefined ? null : (\n <p className=\"text-sm text-po-dim\" title={view.saved.path}>\n Saved as <span className=\"font-mono text-po-text\">{view.saved.id}</span>\n </p>\n )}\n </MessageItemBody>\n ) : null}\n </>\n )}\n </MessageItem>\n );\n}\n","import { defineToolRenderer } from '@agimon-ai/po-core/web';\n\nimport { ExecToolCard } from './_components/ExecToolCard';\n\nexport default defineToolRenderer({ message: ExecToolCard });\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineWebPlugin, type WebPluginContributions } from '@agimon-ai/po-core/web';\n\nimport toolDiscover from '../src/extensions/workspaces/sessions/(frontend)/tool/discover.web';\nimport toolExec from '../src/extensions/workspaces/sessions/(frontend)/tool/exec.web';\n\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const webPlugin = defineWebPlugin({\n id: 'codemode',\n session: {\n get toolRenderers(): WebPluginContributions['toolRenderers'] { return [via({ tools: ['discover'] }, toolDiscover), via({ tools: ['exec'] }, toolExec)]; },\n },\n});\n"],"mappings":";;;;;AAGA,MAAa,eAAe;AAC5B,MAAa,mBAAmB;AAEhC,MAAM,cAAc;AACpB,MAAM,WAAW;AACjB,MAAM,YAAY;AAClB,MAAM,cAAc;AACpB,MAAM,aAAa;AAEnB,SAAS,OAAO,OAAqD;CACnE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK,IACrE,QACD,KAAA;AACN;AAEA,SAAS,KAAK,MAAc,KAAqB;CAC/C,OAAO,KAAK,UAAU,MAAM,OAAO,GAAG,KAAK,MAAM,GAAG,MAAM,CAAC,EAAE;AAC/D;;AAGA,SAAgB,SAAS,MAAiD;CACxE,OAAO,OAAO,KAAK,SAAS,WAAW,KAAK,OAAO;AACrD;;AAGA,SAAgB,YAAY,MAAiD;CAC3E,MAAM,QAAQ,SAAS,IAAI,CAAC,CACzB,MAAM,IAAI,CAAC,CACX,KAAK,SAAS,KAAK,KAAK,CAAC,CAAC,CAC1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A,IAAA,mBAAe,mBAAmB,EAAE,SAAS,aAAa,CAAC;;;ACE3D,MAAM,OAAU,UAAmC,UAChD,UAAU,KAAA,IAAY,KAAA,IAAY;CAAE,GAAG;CAAU,GAAI;AAAiB;AAEzE,MAAa,YAAY,gBAAgB;CACvC,IAAI;CACJ,SAAS,EACP,IAAI,gBAAyD;EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,EAAE,GAAGA,oBAAY,GAAG,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,GAAGC,gBAAQ,CAAC;CAAG,EAC1J;AACF,CAAC"}
1
+ {"version":3,"file":"web.mjs","names":["toolDiscover","toolExec"],"sources":["../../src/extensions/workspaces/sessions/(frontend)/tool/_lib/execToolView.ts","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/DiscoverToolCard.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/discover.web.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/ToolSection.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/ExecToolCard.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/exec.web.tsx","../../generated/web.ts"],"sourcesContent":["// Imports nothing at runtime: the web and native cards share it, and the native\n// bundle may not load the web contract.\nimport type { ToolResultView } from '@agimon-ai/po-core/web';\n\n/** Tool names this package registers (registerTool's `name`). */\nexport const execToolName = 'exec' as const;\nexport const discoverToolName = 'discover' as const;\n\nconst SUMMARY_MAX = 120;\nconst ARGS_MAX = 160;\nconst CALLS_MAX = 50;\nconst IMAGE_TYPES = /^image\\/(?:png|jpeg|webp|gif)$/u;\nconst SAVED_LINE = /^Saved as (\\S+) \\((.+)\\)$/u;\n// A heading or a fence starts a line of Markdown, never one of JSON or a log.\nconst DOCUMENT_LINE = /^(?:#{1,6} |```)/mu;\n\nfunction record(value: unknown): Record<string, unknown> | undefined {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : undefined;\n}\n\nfunction clip(text: string, max: number): string {\n return text.length <= max ? text : `${text.slice(0, max - 1)}…`;\n}\n\n/** The script the call ran, exactly as the agent wrote it. */\nexport function execCode(args: Readonly<Record<string, unknown>>): string {\n return typeof args.code === 'string' ? args.code : '';\n}\n\n/** The header line: the script's first line, with a leading `//` comment marker dropped. */\nexport function execSummary(args: Readonly<Record<string, unknown>>): string {\n const first = execCode(args)\n .split('\\n')\n .map((line) => line.trim())\n .find((line) => line !== '');\n if (first === undefined) return 'script';\n return clip(first.replace(/^\\/\\/+\\s*/u, ''), SUMMARY_MAX);\n}\n\n/** One namespace call the script made, as exec reports it in the result's details. */\nexport interface ExecCall {\n /** The member called, such as `browser.click` or `mcp.github.search_issues`. */\n name: string;\n args: Record<string, unknown>;\n ok: boolean;\n ms: number;\n /** The tool name whose own card shows this call, when another package has one. */\n tool?: string;\n error?: string;\n result?: ToolResultView;\n}\n\nfunction callOf(value: unknown): ExecCall | undefined {\n const call = record(value);\n if (call === undefined || typeof call.name !== 'string' || call.name === '') return undefined;\n const result = record(call.result);\n return {\n name: call.name,\n args: record(call.args) ?? {},\n ok: call.ok !== false,\n ms: typeof call.ms === 'number' && Number.isFinite(call.ms) && call.ms >= 0 ? Math.round(call.ms) : 0,\n ...(typeof call.tool === 'string' && call.tool !== '' ? { tool: call.tool } : {}),\n ...(typeof call.error === 'string' && call.error !== '' ? { error: call.error } : {}),\n ...(result !== undefined && Array.isArray(result.content)\n ? { result: { content: result.content, details: result.details } }\n : {}),\n };\n}\n\n/** The nested calls recorded in a result's details; anything malformed is skipped. */\nexport function execCalls(details: unknown): ExecCall[] {\n const calls = record(details)?.calls;\n if (!Array.isArray(calls)) return [];\n return calls\n .slice(0, CALLS_MAX)\n .map(callOf)\n .filter((call): call is ExecCall => call !== undefined);\n}\n\n/** A call's arguments on one line, for a row that has no card of its own: `key: value · key: value`, strings unquoted. */\nexport function callArgsSummary(args: Readonly<Record<string, unknown>>): string {\n const pairs = Object.entries(args).map(\n ([key, value]) => `${key}: ${typeof value === 'string' ? value : (JSON.stringify(value) ?? String(value))}`,\n );\n return clip(pairs.join(' · '), ARGS_MAX);\n}\n\n/** A script's return on one line: a JSON object folds like call arguments, other JSON compacts, plain text joins its lines. */\nexport function returnSummary(text: string): string {\n let value: unknown;\n try {\n value = JSON.parse(text);\n } catch {\n return text.split('\\n').join(' ');\n }\n const object = record(value);\n return object !== undefined && Object.keys(object).length > 0\n ? callArgsSummary(object)\n : clip(JSON.stringify(value), ARGS_MAX);\n}\n\nexport interface ExecImage {\n mimeType: string;\n data: string;\n}\n\nexport interface ExecResultView {\n lines: string[];\n /** The saved-script footer exec appends: the id to import it by, and where it lives. */\n saved?: { id: string; path: string };\n images: ExecImage[];\n}\n\n/** What a result holds, with the saved-script footer and the pictures taken out of the text. */\nexport function execResultView(result: ToolResultView | null): ExecResultView {\n if (result === null) return { lines: [], images: [] };\n let saved: ExecResultView['saved'];\n const texts: string[] = [];\n const images: ExecImage[] = [];\n for (const block of result.content) {\n const item = record(block);\n if (item?.type === 'text' && typeof item.text === 'string') {\n const match = SAVED_LINE.exec(item.text.trim());\n if (match?.[1] !== undefined && match[2] !== undefined) saved = { id: match[1], path: match[2] };\n else texts.push(item.text);\n } else if (\n item?.type === 'image' &&\n typeof item.data === 'string' &&\n typeof item.mimeType === 'string' &&\n IMAGE_TYPES.test(item.mimeType)\n ) {\n images.push({ mimeType: item.mimeType, data: item.data });\n }\n }\n // As po-core's toolResultTextLines: CRLF folded, tabs widened, trailing blank lines dropped.\n const lines = texts.join('\\n').replaceAll('\\r\\n', '\\n').replaceAll('\\r', '\\n').replaceAll('\\t', ' ').split('\\n');\n while (lines.length > 0 && lines.at(-1)?.trim() === '') lines.pop();\n return { lines, ...(saved === undefined ? {} : { saved }), images };\n}\n\n/** Whether result text is a document, such as a report or a mermaid diagram, to draw rather than print. */\nexport function readsAsDocument(text: string): boolean {\n return DOCUMENT_LINE.test(text);\n}\n\n/** The header line for discover: what was asked for. */\nexport function discoverSummary(args: Readonly<Record<string, unknown>>): string {\n if (typeof args.namespace === 'string' && args.namespace !== '') return args.namespace;\n if (typeof args.query === 'string' && args.query !== '') return `find \"${clip(args.query, SUMMARY_MAX)}\"`;\n return 'namespaces and scripts';\n}\n","import type { ToolMessageRenderProps } from '@agimon-ai/po-core/web';\nimport {\n CodeBlock,\n MessageItem,\n MessageItemBody,\n MessageItemHeader,\n MessageItemStatus,\n toolTone,\n} from '@agimon-ai/po-web-components';\n\nimport { discoverSummary, discoverToolName } from '../_lib/execToolView';\n\nexport type DiscoverToolCardProps = ToolMessageRenderProps & { defaultExpanded?: boolean };\n\n/** The discover tool's timeline item: folded to what was asked for, open to what came back. */\nexport function DiscoverToolCard({ args, output, running, isError, defaultExpanded = false }: DiscoverToolCardProps) {\n const declarations = typeof args.namespace === 'string' && args.namespace !== '' && !isError;\n return (\n <MessageItem tone={toolTone({ running, isError })} expandable defaultExpanded={defaultExpanded}>\n {({ expanded }) => (\n <>\n <MessageItemHeader title={discoverToolName}>\n <span data-testid={`tool-call-${discoverToolName}`} className=\"min-w-0 flex-1 truncate text-po-text\">\n {discoverSummary(args)}\n </span>\n </MessageItemHeader>\n {expanded ? (\n <MessageItemBody data-testid={`tool-result-${discoverToolName}`} className=\"flex flex-col gap-2\">\n {running && output === '' ? <MessageItemStatus tone=\"running\">running</MessageItemStatus> : null}\n {output === '' ? null : declarations ? (\n <div className=\"max-h-96 overflow-auto\">\n <CodeBlock text={output} className=\"language-ts\" />\n </div>\n ) : (\n <pre\n data-testid=\"tool-output\"\n className={`max-h-96 overflow-auto font-mono text-sm break-words whitespace-pre-wrap ${isError ? 'text-po-red' : 'text-po-text'}`}\n >\n {output}\n </pre>\n )}\n </MessageItemBody>\n ) : null}\n </>\n )}\n </MessageItem>\n );\n}\n","import { defineToolRenderer } from '@agimon-ai/po-core/web';\n\nimport { DiscoverToolCard } from './_components/DiscoverToolCard';\n\nexport default defineToolRenderer({ message: DiscoverToolCard });\n","import type { ReactNode } from 'react';\n\n/** A labelled part of an expanded card body. */\nexport function ToolSection({ label, children }: { label: string; children: ReactNode }) {\n return (\n <section className=\"flex flex-col gap-1.5\">\n <h4 className=\"text-sm font-medium text-po-dim\">{label}</h4>\n {children}\n </section>\n );\n}\n","import type { ToolMessageRenderProps, ToolOutputDescriptor, ToolResultView } from '@agimon-ai/po-core/web';\nimport {\n CodeBlock,\n Markdown,\n markdownMediaReview,\n type MarkdownMediaReview,\n MessageItem,\n MessageItemBody,\n MessageItemHeader,\n toolTone,\n ViewableImage,\n} from '@agimon-ai/po-web-components';\n\nimport {\n callArgsSummary,\n execCalls,\n execCode,\n execResultView,\n execSummary,\n execToolName,\n readsAsDocument,\n returnSummary,\n type ExecCall,\n type ExecImage,\n} from '../_lib/execToolView';\nimport { ToolSection } from './ToolSection';\n\n/** Draws another tool's own card for a nested call, or nothing when no package owns one. */\nexport type RenderNestedTool = NonNullable<ToolMessageRenderProps['renderTool']>;\n\nexport type ExecToolCardProps = ToolMessageRenderProps & { defaultExpanded?: boolean };\n\n/** The tree's elbow: a short branch from the rail to the item it leads to. */\nconst BRANCH =\n 'relative before:absolute before:top-[1.125rem] before:-left-4 before:w-3 before:border-t before:border-po-border-soft';\n\nconst SUMMARY =\n 'flex min-h-6 cursor-pointer list-none items-center gap-x-2 gap-y-0.5 [&::-webkit-details-marker]:hidden';\n\n/** The folding mark at the end of a summary; it turns when the section opens. */\nfunction Chevron() {\n return (\n <span aria-hidden className=\"w-3 shrink-0 text-center text-po-dim transition-transform group-open:rotate-90\">\n ›\n </span>\n );\n}\n\n/**\n * Pictures and documents stay on screen whether or not their section is open: they are the point of the call.\n * `review` is Author's annotate panel when Author is installed; without it the viewer only pans and zooms.\n */\nfunction Visuals({\n text,\n images,\n label,\n review,\n}: {\n text: string;\n images: readonly ExecImage[];\n label: string;\n review: MarkdownMediaReview | undefined;\n}) {\n return (\n <>\n {readsAsDocument(text) ? (\n <div data-testid=\"tool-output-document\" className=\"max-h-96 overflow-auto text-sm\">\n <Markdown text={text} renderMediaReview={review} />\n </div>\n ) : null}\n {images.map((image, index) => (\n <ViewableImage\n key={`${image.mimeType}-${String(index)}`}\n src={`data:${image.mimeType};base64,${image.data}`}\n alt={`${label} image ${String(index + 1)}`}\n renderReview={review}\n data-testid=\"tool-output-image\"\n className=\"max-h-48 max-w-full rounded-md border border-po-border-soft\"\n />\n ))}\n </>\n );\n}\n\n/** One call on the rail. It opens to its whole args and result; its pictures and documents show either way. */\nfunction CallRow({\n call,\n review,\n suppressOutputs,\n}: {\n call: ExecCall;\n review: MarkdownMediaReview | undefined;\n suppressOutputs?: boolean;\n}) {\n const view = execResultView(call.result ?? null);\n const text = view.lines.join('\\n');\n const printed = text !== '' && (!call.ok || !readsAsDocument(text));\n const opens = Object.keys(call.args).length > 0 || printed || call.error !== undefined;\n const head = (\n <>\n <span className=\"shrink-0 truncate font-mono font-semibold text-po-text max-sm:basis-full\">{call.name}</span>\n <span className=\"min-w-0 flex-1 truncate font-mono text-po-dim group-open:invisible\">\n {callArgsSummary(call.args)}\n </span>\n <span aria-hidden className={`w-3 shrink-0 text-center ${call.ok ? 'text-po-green' : 'text-po-red'}`}>\n {call.ok ? '✓' : '✗'}\n </span>\n <span className=\"sr-only\">{call.ok ? 'completed' : 'failed'}</span>\n <span className=\"w-16 shrink-0 text-right tabular-nums text-po-dim\">{call.ms} ms</span>\n </>\n );\n return (\n <div data-testid=\"exec-call\" className=\"flex flex-col gap-2 py-1.5\">\n {opens ? (\n <details className=\"group text-sm\">\n <summary className={`${SUMMARY} flex-wrap`}>\n {head}\n <Chevron />\n </summary>\n <div className=\"mt-2 flex flex-col gap-2\">\n {Object.keys(call.args).length > 0 ? (\n <CodeBlock text={JSON.stringify(call.args, null, 2)} className=\"language-json\" />\n ) : null}\n {printed ? (\n <pre\n data-testid=\"exec-call-output\"\n className=\"max-h-72 overflow-auto font-mono text-sm break-words whitespace-pre-wrap text-po-text\"\n >\n {text}\n </pre>\n ) : null}\n {call.error === undefined ? null : <p className=\"text-sm break-words text-po-red\">{call.error}</p>}\n </div>\n </details>\n ) : (\n <div className=\"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-sm\">{head}</div>\n )}\n {!suppressOutputs ? (\n <Visuals text={call.ok ? text : ''} images={view.images} label={call.name} review={review} />\n ) : null}\n </div>\n );\n}\n\n/** The script's outcome as the tree's last leaf: one line until opened, the whole text after; visuals always. */\nfunction Returned({\n result,\n isError,\n review,\n suppressOutputs,\n}: {\n result: ExecToolCardProps['result'];\n isError: boolean;\n review: MarkdownMediaReview | undefined;\n suppressOutputs?: boolean;\n}) {\n const view = execResultView(result);\n const text = view.lines.join('\\n');\n const label = isError ? 'Error' : 'Returned';\n const ink = isError ? 'text-po-red' : 'text-po-text';\n return (\n <div data-testid={`tool-result-${execToolName}`} className=\"flex flex-col gap-2\">\n {view.lines.length === 0 ? (\n <p className=\"text-sm text-po-dim\">{isError ? 'Failed with no output.' : 'Returned nothing.'}</p>\n ) : !isError && readsAsDocument(text) ? (\n <p className=\"text-sm font-semibold text-po-dim\">{label}</p>\n ) : (\n <details className=\"group text-sm\">\n <summary className={`${SUMMARY} text-po-dim hover:text-po-blue`}>\n <span className=\"shrink-0 font-semibold\">{label}</span>\n <span className={`min-w-0 flex-1 truncate font-mono group-open:hidden ${ink}`}>{returnSummary(text)}</span>\n <Chevron />\n </summary>\n <pre\n data-testid=\"tool-output\"\n className={`mt-1 max-h-72 overflow-auto font-mono text-sm break-words whitespace-pre-wrap ${ink}`}\n >\n {text}\n </pre>\n </details>\n )}\n {!suppressOutputs ? (\n <Visuals text={isError ? '' : text} images={view.images} label=\"Script\" review={review} />\n ) : null}\n </div>\n );\n}\n\n/**\n * The exec tool's timeline item. The calls the script made hang under it as a\n * tree, each as the owning tool's own card when one exists, with what the\n * script returned as the last leaf. Opening the item shows the script itself.\n */\nexport function ExecToolCard(props: ExecToolCardProps) {\n const { args, result, running, isError, defaultExpanded = false, renderTool, suppressOutputs } = props;\n const review = markdownMediaReview(props);\n const code = execCode(args);\n const saved = execResultView(result).saved;\n const calls = execCalls(result?.details);\n const failed = calls.filter((call) => !call.ok).length;\n const settled = !running || result !== null;\n return (\n <MessageItem tone={toolTone({ running, isError })} expandable={code !== ''} defaultExpanded={defaultExpanded}>\n {({ expanded }) => (\n <>\n <MessageItemHeader title={execToolName}>\n <span data-testid={`tool-call-${execToolName}`} className=\"min-w-0 flex-1 truncate text-po-text\">\n {execSummary(args)}\n </span>\n {calls.length > 0 ? (\n <span className=\"shrink-0 text-sm text-po-dim\">\n {calls.length} {calls.length === 1 ? 'call' : 'calls'}\n {failed > 0 ? <span className=\"text-po-red\">, {failed} failed</span> : null}\n </span>\n ) : null}\n </MessageItemHeader>\n {expanded ? (\n <MessageItemBody className=\"flex flex-col gap-2\">\n <ToolSection label=\"Code\">\n <CodeBlock text={code} className=\"language-ts\" />\n </ToolSection>\n {saved === undefined ? null : (\n <p className=\"text-sm text-po-dim\" title={saved.path}>\n Saved as <span className=\"font-mono text-po-text\">{saved.id}</span>\n </p>\n )}\n </MessageItemBody>\n ) : null}\n {settled ? (\n <ol\n aria-label=\"Script calls\"\n className=\"mx-4 mb-3 flex flex-col gap-2 border-l border-po-border-soft pl-4 sm:ml-[2.125rem]\"\n >\n {calls.map((call, index) => {\n const card =\n call.tool === undefined || renderTool === undefined\n ? null\n : renderTool({\n toolName: call.tool,\n args: call.args,\n result: call.result ?? null,\n isError: !call.ok,\n });\n // ponytail: another tool's card folds as it likes, so its pictures are repeated under it and\n // may show twice while it is open; drop this once cards keep pictures visible when folded.\n return (\n <li key={`${String(index)}-${call.name}`} className={`${BRANCH} flex flex-col gap-2`}>\n {card === null ? (\n <CallRow call={call} review={review} suppressOutputs={suppressOutputs} />\n ) : (\n <>\n {card}\n {!suppressOutputs ? (\n <Visuals\n text=\"\"\n images={execResultView(call.result ?? null).images}\n label={call.name}\n review={review}\n />\n ) : null}\n </>\n )}\n </li>\n );\n })}\n <li className={BRANCH}>\n <Returned result={result} isError={isError} review={review} suppressOutputs={suppressOutputs} />\n </li>\n </ol>\n ) : null}\n </>\n )}\n </MessageItem>\n );\n}\n\n/** Rich visuals already supported by exec, normalized for an opt-in output surface. */\nexport function execToolOutputs(props: ToolMessageRenderProps): readonly ToolOutputDescriptor[] {\n const review = markdownMediaReview(props);\n const outputs: ToolOutputDescriptor[] = [];\n const collect = (result: ToolResultView | null, id: string, title: string, failed: boolean): void => {\n const text = execResultView(result).lines.join('\\n');\n if (!failed && readsAsDocument(text))\n outputs.push({\n id: `${id}:document`,\n title,\n content: <Visuals text={text} images={[]} label={title} review={review} />,\n });\n (result?.content ?? []).forEach((block, index) => {\n if (block === null || typeof block !== 'object' || !('type' in block) || block.type !== 'image') return;\n outputs.push({\n id: `${id}:image:${String(index)}`,\n title: `${title} image ${String(index + 1)}`,\n content: (\n <Visuals\n text=\"\"\n images={execResultView({ content: [block], details: null }).images}\n label={title}\n review={review}\n />\n ),\n });\n });\n };\n execCalls(props.result?.details).forEach((call, index) => {\n // A call another tool owns, such as an MCP App, is collected by that tool, as its card is drawn by it.\n const owned =\n call.tool === undefined\n ? []\n : (props.toolOutputs?.({\n toolName: call.tool,\n args: call.args,\n result: call.result ?? null,\n isError: !call.ok,\n }) ?? []);\n if (owned.length === 0) collect(call.result ?? null, `call:${String(index)}`, call.name, !call.ok);\n else for (const output of owned) outputs.push({ ...output, id: `call:${String(index)}:${output.id}` });\n });\n collect(props.result, 'returned', 'Script', props.isError);\n return outputs;\n}\n","import { defineToolRenderer } from '@agimon-ai/po-core/web';\n\nimport { ExecToolCard, execToolOutputs } from './_components/ExecToolCard';\n\nexport default defineToolRenderer({ message: ExecToolCard, outputs: execToolOutputs });\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineWebPlugin, type WebPluginContributions } from '@agimon-ai/po-core/web';\n\nimport toolDiscover from '../src/extensions/workspaces/sessions/(frontend)/tool/discover.web';\nimport toolExec from '../src/extensions/workspaces/sessions/(frontend)/tool/exec.web';\n\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const webPlugin = defineWebPlugin({\n id: 'codemode',\n session: {\n get toolRenderers(): WebPluginContributions['toolRenderers'] { return [via({ tools: ['discover'] }, toolDiscover), via({ tools: ['exec'] }, toolExec)]; },\n },\n});\n"],"mappings":";;;;;AAKA,MAAa,eAAe;AAC5B,MAAa,mBAAmB;AAEhC,MAAM,cAAc;AACpB,MAAM,WAAW;AACjB,MAAM,YAAY;AAClB,MAAM,cAAc;AACpB,MAAM,aAAa;AAEnB,MAAM,gBAAgB;AAEtB,SAAS,OAAO,OAAqD;CACnE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK,IACrE,QACD,KAAA;AACN;AAEA,SAAS,KAAK,MAAc,KAAqB;CAC/C,OAAO,KAAK,UAAU,MAAM,OAAO,GAAG,KAAK,MAAM,GAAG,MAAM,CAAC,EAAE;AAC/D;;AAGA,SAAgB,SAAS,MAAiD;CACxE,OAAO,OAAO,KAAK,SAAS,WAAW,KAAK,OAAO;AACrD;;AAGA,SAAgB,YAAY,MAAiD;CAC3E,MAAM,QAAQ,SAAS,IAAI,CAAC,CACzB,MAAM,IAAI,CAAC,CACX,KAAK,SAAS,KAAK,KAAK,CAAC,CAAC,CAC1B,MAAM,SAAS,SAAS,EAAE;CAC7B,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,OAAO,KAAK,MAAM,QAAQ,cAAc,EAAE,GAAG,WAAW;AAC1D;AAeA,SAAS,OAAO,OAAsC;CACpD,MAAM,OAAO,OAAO,KAAK;CACzB,IAAI,SAAS,KAAA,KAAa,OAAO,KAAK,SAAS,YAAY,KAAK,SAAS,IAAI,OAAO,KAAA;CACpF,MAAM,SAAS,OAAO,KAAK,MAAM;CACjC,OAAO;EACL,MAAM,KAAK;EACX,MAAM,OAAO,KAAK,IAAI,KAAK,CAAC;EAC5B,IAAI,KAAK,OAAO;EAChB,IAAI,OAAO,KAAK,OAAO,YAAY,OAA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I,QAAQ,OAAO,KAAK,EAAE,GAAG,OAAO;EAAK,CAAC;CACvG,CAAC;CACD,QAAQ,MAAM,QAAQ,YAAY,UAAU,MAAM,OAAO;CACzD,OAAO;AACT;;;AC5TA,IAAA,mBAAe,mBAAmB;CAAE,SAAS;CAAc,SAAS;AAAgB,CAAC;;;ACErF,MAAM,OAAU,UAAmC,UAChD,UAAU,KAAA,IAAY,KAAA,IAAY;CAAE,GAAG;CAAU,GAAI;AAAiB;AAEzE,MAAa,YAAY,gBAAgB;CACvC,IAAI;CACJ,SAAS,EACP,IAAI,gBAAyD;EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,EAAE,GAAGA,oBAAY,GAAG,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,GAAGC,gBAAQ,CAAC;CAAG,EAC1J;AACF,CAAC"}
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_codemodeTools = require("./codemodeTools-B3n6iodq.cjs");
2
+ const require_codemodeTools = require("./codemodeTools-Dcbn7U7P.cjs");
3
3
  exports.createCodemodeRegistry = require_codemodeTools.createCodemodeRegistry;
4
4
  exports.createCodemodeTools = require_codemodeTools.createCodemodeTools;