@agimon-ai/po-codemode 0.0.1-alpha.82 → 0.0.1-alpha.84

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.
@@ -122,9 +122,9 @@ function CallRow({ call, host }) {
122
122
  const [open, setOpen] = useState(false);
123
123
  const view = execResultView(call.result ?? null);
124
124
  const text = view.lines.join("\n");
125
- const printed = text !== "" && !readsAsDocument(text);
125
+ const printed = text !== "" && (!call.ok || !readsAsDocument(text));
126
126
  const hasArgs = Object.keys(call.args).length > 0;
127
- const opens = hasArgs || printed;
127
+ const opens = hasArgs || printed || call.error !== void 0;
128
128
  return /* @__PURE__ */ jsxs(View, {
129
129
  testID: "exec-call",
130
130
  style: styles.call,
@@ -184,12 +184,12 @@ function CallRow({ call, host }) {
184
184
  style: [styles.mono, styles.text],
185
185
  children: text
186
186
  }) : null,
187
- call.error === void 0 ? null : /* @__PURE__ */ jsx(Text, {
187
+ open && call.error !== void 0 ? /* @__PURE__ */ jsx(Text, {
188
188
  style: [styles.sans, styles.error],
189
189
  children: call.error
190
- }),
190
+ }) : null,
191
191
  /* @__PURE__ */ jsx(Visuals, {
192
- text,
192
+ text: call.ok ? text : "",
193
193
  images: view.images,
194
194
  label: call.name,
195
195
  host
@@ -201,8 +201,7 @@ function CallRow({ call, host }) {
201
201
  function Returned({ result, isError, expanded, host }) {
202
202
  const view = execResultView(result);
203
203
  const text = view.lines.join("\n");
204
- const document = readsAsDocument(text);
205
- const whole = expanded || isError;
204
+ const document = !isError && readsAsDocument(text);
206
205
  return /* @__PURE__ */ jsxs(View, {
207
206
  testID: `tool-result-${execToolName}`,
208
207
  style: styles.leaf,
@@ -217,7 +216,7 @@ function Returned({ result, isError, expanded, host }) {
217
216
  ],
218
217
  children: isError ? "Error" : "Returned"
219
218
  }) : /* @__PURE__ */ jsxs(View, {
220
- style: whole ? styles.stack : styles.argsLine,
219
+ style: expanded ? styles.stack : styles.argsLine,
221
220
  children: [/* @__PURE__ */ jsx(Text, {
222
221
  style: [
223
222
  styles.sans,
@@ -227,16 +226,16 @@ function Returned({ result, isError, expanded, host }) {
227
226
  children: isError ? "Error" : "Returned"
228
227
  }), /* @__PURE__ */ jsx(Text, {
229
228
  selectable: true,
230
- numberOfLines: whole ? void 0 : 1,
229
+ numberOfLines: expanded ? void 0 : 1,
231
230
  style: [
232
231
  styles.mono,
233
232
  styles.args,
234
233
  isError ? styles.error : styles.text
235
234
  ],
236
- children: whole ? text : returnSummary(text)
235
+ children: expanded ? text : returnSummary(text)
237
236
  })]
238
237
  }), /* @__PURE__ */ jsx(Visuals, {
239
- text,
238
+ text: isError ? "" : text,
240
239
  images: view.images,
241
240
  label: "Script",
242
241
  host
@@ -260,7 +259,7 @@ function ExecToolCard(props) {
260
259
  running,
261
260
  isError
262
261
  }),
263
- expandable: code !== "",
262
+ expandable: code !== "" || isError,
264
263
  defaultExpanded,
265
264
  children: ({ expanded }) => /* @__PURE__ */ jsxs(Fragment, { children: [
266
265
  /* @__PURE__ */ jsx(MessageItemHeader, {
@@ -1 +1 @@
1
- {"version":3,"file":"native.mjs","names":["ToolMessageRenderProps","CodeBlock","fontOf","Markdown","MessageItem","MessageItemBody","MessageItemHeader","toolTone","ToolResultImage","PoNativeTheme","useState","StyleSheet","callArgsSummary","execCalls","execCode","execResultView","execSummary","execToolName","readsAsDocument","returnSummary","ExecCall","ExecImage","ExecToolCardProps","defaultExpanded","Visuals","text","images","label","host","map","image","index","mimeType","String","data","styles","CallRow","call","open","setOpen","view","result","lines","join","printed","hasArgs","Object","keys","args","length","opens","value","undefined","expanded","press","argsLine","mono","name","shrink","sans","dim","keep","ok","error","ms","JSON","stringify","Returned","isError","document","whole","leaf","stack","ExecToolCard","props","running","renderTool","code","calls","details","failed","filter","settled","summary","rail","card","tool","toolName","create","theme","flex","flexDirection","alignItems","gap","spacing","minWidth","uni__dependencies","flexShrink","marginHorizontal","marginBottom","paddingLeft","borderLeftWidth","borderColor","colors","minHeight","justifyContent","paddingVertical","fontFamily","fontSize","sm","lineHeight","fontWeight","color","green","red","width","aspectRatio","borderWidth","borderRadius","md","toolExec"],"sources":["../../src/extensions/workspaces/sessions/(frontend)/tool/_lib/execToolView.ts","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/ExecToolCard.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/exec.native.tsx","../../generated/native.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/native';\nimport {\n CodeBlock,\n fontOf,\n Markdown,\n MessageItem,\n MessageItemBody,\n MessageItemHeader,\n toolTone,\n ToolResultImage,\n} from '@agimon-ai/po-native-components';\nimport type { PoNativeTheme } from '@agimon-ai/po-web-components/nativeTheme';\nimport { useState } from 'react';\nimport { Pressable, Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\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';\n\nexport type ExecToolCardProps = ToolMessageRenderProps & { defaultExpanded?: boolean };\n\n/** Pictures and documents stay on screen whether or not their row is open: they are the point of the call. */\nfunction Visuals({\n text,\n images,\n label,\n host,\n}: {\n text: string;\n images: readonly ExecImage[];\n label: string;\n host: ToolMessageRenderProps;\n}) {\n return (\n <>\n {readsAsDocument(text) ? <Markdown text={text} /> : null}\n {images.map((image, index) => (\n <ToolResultImage\n key={`${image.mimeType}-${String(index)}`}\n host={host}\n data={image.data}\n mimeType={image.mimeType}\n accessibilityLabel={`${label} image ${String(index + 1)}`}\n resizeMode=\"contain\"\n style={styles.image}\n />\n ))}\n </>\n );\n}\n\n/** One call on the rail. Tapping it opens its whole args and result; its pictures and documents show either way. */\nfunction CallRow({ call, host }: { call: ExecCall; host: ToolMessageRenderProps }) {\n const [open, setOpen] = useState(false);\n const view = execResultView(call.result ?? null);\n const text = view.lines.join('\\n');\n const printed = text !== '' && !readsAsDocument(text);\n const hasArgs = Object.keys(call.args).length > 0;\n const opens = hasArgs || printed;\n return (\n <View testID=\"exec-call\" style={styles.call}>\n <Pressable\n disabled={!opens}\n onPress={() => setOpen((value) => !value)}\n accessibilityRole={opens ? 'button' : undefined}\n accessibilityState={opens ? { expanded: open } : undefined}\n accessibilityHint={opens ? 'Shows the whole arguments and result' : undefined}\n style={styles.press}\n >\n <View style={styles.argsLine}>\n <Text numberOfLines={1} style={[styles.mono, styles.name, styles.shrink]}>\n {call.name}\n </Text>\n {opens ? <Text style={[styles.sans, styles.dim, styles.keep]}>{open ? '\\u2304' : '\\u203a'}</Text> : null}\n </View>\n <View style={styles.argsLine}>\n <Text numberOfLines={1} style={[styles.mono, styles.args]}>\n {open ? '' : callArgsSummary(call.args)}\n </Text>\n <Text\n accessibilityLabel={call.ok ? 'completed' : 'failed'}\n style={[styles.sans, call.ok ? styles.ok : styles.error]}\n >\n {call.ok ? '\\u2713' : '\\u2717'}\n </Text>\n <Text style={[styles.sans, styles.dim]}>{call.ms} ms</Text>\n </View>\n </Pressable>\n {open && hasArgs ? <CodeBlock text={JSON.stringify(call.args, null, 2)} language=\"json\" /> : null}\n {open && printed ? (\n <Text testID=\"exec-call-output\" selectable style={[styles.mono, styles.text]}>\n {text}\n </Text>\n ) : null}\n {call.error === undefined ? null : <Text style={[styles.sans, styles.error]}>{call.error}</Text>}\n <Visuals text={text} images={view.images} label={call.name} host={host} />\n </View>\n );\n}\n\n/** The script's outcome as the rail's last leaf: one line while the card is folded, all of it once opened. */\nfunction Returned({\n result,\n isError,\n expanded,\n host,\n}: {\n result: ExecToolCardProps['result'];\n isError: boolean;\n expanded: boolean;\n host: ToolMessageRenderProps;\n}) {\n const view = execResultView(result);\n const text = view.lines.join('\\n');\n const document = readsAsDocument(text);\n const whole = expanded || isError;\n return (\n <View testID={`tool-result-${execToolName}`} style={styles.leaf}>\n {view.lines.length === 0 ? (\n <Text style={[styles.sans, styles.dim]}>{isError ? 'Failed with no output.' : 'Returned nothing.'}</Text>\n ) : document ? (\n <Text style={[styles.sans, styles.dim, styles.label]}>{isError ? 'Error' : 'Returned'}</Text>\n ) : (\n <View style={whole ? styles.stack : styles.argsLine}>\n <Text style={[styles.sans, styles.dim, styles.label]}>{isError ? 'Error' : 'Returned'}</Text>\n <Text\n selectable\n numberOfLines={whole ? undefined : 1}\n style={[styles.mono, styles.args, isError ? styles.error : styles.text]}\n >\n {whole ? text : returnSummary(text)}\n </Text>\n </View>\n )}\n <Visuals text={text} images={view.images} label=\"Script\" host={host} />\n </View>\n );\n}\n\n/**\n * The exec tool's timeline item on native, as the web's ExecToolCard: the\n * calls the script made hang under it on a rail, each as the owning tool's own\n * card when one exists, with what it returned as the last leaf. Opening the\n * item shows the script itself.\n */\nexport function ExecToolCard(props: ExecToolCardProps) {\n const { args, result, running, isError, defaultExpanded = false, renderTool } = props;\n const code = execCode(args);\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 <View testID={`tool-call-${execToolName}`} style={styles.summary}>\n <Text numberOfLines={1} style={[styles.sans, styles.text, styles.shrink]}>\n {execSummary(args)}\n </Text>\n {calls.length > 0 ? (\n <Text numberOfLines={1} style={[styles.sans, styles.dim, styles.keep]}>\n {calls.length} {calls.length === 1 ? 'call' : 'calls'}\n {failed > 0 ? <Text style={styles.error}>, {failed} failed</Text> : null}\n </Text>\n ) : null}\n </View>\n </MessageItemHeader>\n {expanded ? (\n <MessageItemBody>\n <CodeBlock text={code} language=\"ts\" />\n </MessageItemBody>\n ) : null}\n {settled ? (\n <View accessibilityLabel=\"Script calls\" style={styles.rail}>\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: as on the web, another tool's card folds as it likes, so its pictures are repeated\n // under it; drop this once cards keep pictures visible when folded.\n return card === null || card === undefined ? (\n <CallRow key={`${String(index)}-${call.name}`} call={call} host={props} />\n ) : (\n <View key={`${String(index)}-${call.name}`} style={styles.call}>\n {card}\n <Visuals\n text=\"\"\n images={execResultView(call.result ?? null).images}\n label={call.name}\n host={props}\n />\n </View>\n );\n })}\n <Returned result={result} isError={isError} expanded={expanded} host={props} />\n </View>\n ) : null}\n </>\n )}\n </MessageItem>\n );\n}\n\nconst styles = StyleSheet.create((theme: PoNativeTheme) => ({\n summary: { flex: 1, flexDirection: 'row', alignItems: 'center', gap: theme.spacing(2), minWidth: 0 },\n shrink: { flexShrink: 1 },\n keep: { flexShrink: 0 },\n rail: {\n gap: theme.spacing(2),\n marginHorizontal: theme.spacing(4),\n marginBottom: theme.spacing(3),\n paddingLeft: theme.spacing(3),\n borderLeftWidth: 1,\n borderColor: theme.colors['border-soft'],\n },\n // A row on the rail, not a card: the rail already groups the calls.\n call: { gap: theme.spacing(2) },\n // 44pt: the smallest comfortable touch target.\n press: { minHeight: 44, justifyContent: 'center', gap: theme.spacing(0.5), paddingVertical: theme.spacing(1) },\n argsLine: { flexDirection: 'row', alignItems: 'center', gap: theme.spacing(2) },\n stack: { gap: theme.spacing(1) },\n leaf: { gap: theme.spacing(2) },\n sans: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n },\n mono: {\n fontFamily: fontOf(theme.fontFamily.mono),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n },\n name: { fontWeight: '600', color: theme.colors.text },\n args: { flex: 1, minWidth: 0, color: theme.colors.dim },\n label: { fontWeight: '600' },\n text: { color: theme.colors.text },\n dim: { color: theme.colors.dim },\n ok: { color: theme.colors.green },\n error: { color: theme.colors.red },\n image: {\n width: '100%',\n aspectRatio: 16 / 9,\n borderWidth: 1,\n borderRadius: theme.borderRadius.md,\n borderColor: theme.colors['border-soft'],\n },\n}));\n","import { defineToolRenderer } from '@agimon-ai/po-core/native';\n\nimport { ExecToolCard } from './_components/ExecToolCard.native';\n\nexport default defineToolRenderer({ message: ExecToolCard });\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineNativePlugin, type WebPluginContributions } from '@agimon-ai/po-core/native';\n\nimport toolExec from '../src/extensions/workspaces/sessions/(frontend)/tool/exec.native';\n\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const nativePlugin = defineNativePlugin({\n id: 'codemode',\n session: {\n get toolRenderers(): WebPluginContributions['toolRenderers'] { return [via({ tools: ['exec'] }, toolExec)]; },\n },\n});\n"],"mappings":";;;;;;;;;;AAKA,MAAa,eAAe;AAG5B,MAAM,cAAc;AACpB,MAAM,WAAW;AACjB,MAAM,YAAY;AAClB,MAAM,cAAc;AACpB,MAAM,aAAa;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AAC"}
1
+ {"version":3,"file":"native.mjs","names":["ToolMessageRenderProps","CodeBlock","fontOf","Markdown","MessageItem","MessageItemBody","MessageItemHeader","toolTone","ToolResultImage","PoNativeTheme","useState","StyleSheet","callArgsSummary","execCalls","execCode","execResultView","execSummary","execToolName","readsAsDocument","returnSummary","ExecCall","ExecImage","ExecToolCardProps","defaultExpanded","Visuals","text","images","label","host","map","image","index","mimeType","String","data","styles","CallRow","call","open","setOpen","view","result","lines","join","printed","ok","hasArgs","Object","keys","args","length","opens","error","undefined","value","expanded","press","argsLine","mono","name","shrink","sans","dim","keep","ms","JSON","stringify","Returned","isError","document","leaf","stack","ExecToolCard","props","running","renderTool","code","calls","details","failed","filter","settled","summary","rail","card","tool","toolName","create","theme","flex","flexDirection","alignItems","gap","spacing","minWidth","uni__dependencies","flexShrink","marginHorizontal","marginBottom","paddingLeft","borderLeftWidth","borderColor","colors","minHeight","justifyContent","paddingVertical","fontFamily","fontSize","sm","lineHeight","fontWeight","color","green","red","width","aspectRatio","borderWidth","borderRadius","md","toolExec"],"sources":["../../src/extensions/workspaces/sessions/(frontend)/tool/_lib/execToolView.ts","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/ExecToolCard.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/exec.native.tsx","../../generated/native.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/native';\nimport {\n CodeBlock,\n fontOf,\n Markdown,\n MessageItem,\n MessageItemBody,\n MessageItemHeader,\n toolTone,\n ToolResultImage,\n} from '@agimon-ai/po-native-components';\nimport type { PoNativeTheme } from '@agimon-ai/po-web-components/nativeTheme';\nimport { useState } from 'react';\nimport { Pressable, Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\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';\n\nexport type ExecToolCardProps = ToolMessageRenderProps & { defaultExpanded?: boolean };\n\n/** Pictures and documents stay on screen whether or not their row is open: they are the point of the call. */\nfunction Visuals({\n text,\n images,\n label,\n host,\n}: {\n text: string;\n images: readonly ExecImage[];\n label: string;\n host: ToolMessageRenderProps;\n}) {\n return (\n <>\n {readsAsDocument(text) ? <Markdown text={text} /> : null}\n {images.map((image, index) => (\n <ToolResultImage\n key={`${image.mimeType}-${String(index)}`}\n host={host}\n data={image.data}\n mimeType={image.mimeType}\n accessibilityLabel={`${label} image ${String(index + 1)}`}\n resizeMode=\"contain\"\n style={styles.image}\n />\n ))}\n </>\n );\n}\n\n/** One call on the rail. Tapping it opens its whole args and result; its pictures and documents show either way. */\nfunction CallRow({ call, host }: { call: ExecCall; host: ToolMessageRenderProps }) {\n const [open, setOpen] = useState(false);\n const view = execResultView(call.result ?? null);\n const text = view.lines.join('\\n');\n const printed = text !== '' && (!call.ok || !readsAsDocument(text));\n const hasArgs = Object.keys(call.args).length > 0;\n const opens = hasArgs || printed || call.error !== undefined;\n return (\n <View testID=\"exec-call\" style={styles.call}>\n <Pressable\n disabled={!opens}\n onPress={() => setOpen((value) => !value)}\n accessibilityRole={opens ? 'button' : undefined}\n accessibilityState={opens ? { expanded: open } : undefined}\n accessibilityHint={opens ? 'Shows the whole arguments and result' : undefined}\n style={styles.press}\n >\n <View style={styles.argsLine}>\n <Text numberOfLines={1} style={[styles.mono, styles.name, styles.shrink]}>\n {call.name}\n </Text>\n {opens ? <Text style={[styles.sans, styles.dim, styles.keep]}>{open ? '\\u2304' : '\\u203a'}</Text> : null}\n </View>\n <View style={styles.argsLine}>\n <Text numberOfLines={1} style={[styles.mono, styles.args]}>\n {open ? '' : callArgsSummary(call.args)}\n </Text>\n <Text\n accessibilityLabel={call.ok ? 'completed' : 'failed'}\n style={[styles.sans, call.ok ? styles.ok : styles.error]}\n >\n {call.ok ? '\\u2713' : '\\u2717'}\n </Text>\n <Text style={[styles.sans, styles.dim]}>{call.ms} ms</Text>\n </View>\n </Pressable>\n {open && hasArgs ? <CodeBlock text={JSON.stringify(call.args, null, 2)} language=\"json\" /> : null}\n {open && printed ? (\n <Text testID=\"exec-call-output\" selectable style={[styles.mono, styles.text]}>\n {text}\n </Text>\n ) : null}\n {open && call.error !== undefined ? <Text style={[styles.sans, styles.error]}>{call.error}</Text> : null}\n <Visuals text={call.ok ? text : ''} images={view.images} label={call.name} host={host} />\n </View>\n );\n}\n\n/** The script's outcome as the rail's last leaf: one line while the card is folded, all of it once opened. */\nfunction Returned({\n result,\n isError,\n expanded,\n host,\n}: {\n result: ExecToolCardProps['result'];\n isError: boolean;\n expanded: boolean;\n host: ToolMessageRenderProps;\n}) {\n const view = execResultView(result);\n const text = view.lines.join('\\n');\n const document = !isError && readsAsDocument(text);\n return (\n <View testID={`tool-result-${execToolName}`} style={styles.leaf}>\n {view.lines.length === 0 ? (\n <Text style={[styles.sans, styles.dim]}>{isError ? 'Failed with no output.' : 'Returned nothing.'}</Text>\n ) : document ? (\n <Text style={[styles.sans, styles.dim, styles.label]}>{isError ? 'Error' : 'Returned'}</Text>\n ) : (\n <View style={expanded ? styles.stack : styles.argsLine}>\n <Text style={[styles.sans, styles.dim, styles.label]}>{isError ? 'Error' : 'Returned'}</Text>\n <Text\n selectable\n numberOfLines={expanded ? undefined : 1}\n style={[styles.mono, styles.args, isError ? styles.error : styles.text]}\n >\n {expanded ? text : returnSummary(text)}\n </Text>\n </View>\n )}\n <Visuals text={isError ? '' : text} images={view.images} label=\"Script\" host={host} />\n </View>\n );\n}\n\n/**\n * The exec tool's timeline item on native, as the web's ExecToolCard: the\n * calls the script made hang under it on a rail, each as the owning tool's own\n * card when one exists, with what it returned as the last leaf. Opening the\n * item shows the script itself.\n */\nexport function ExecToolCard(props: ExecToolCardProps) {\n const { args, result, running, isError, defaultExpanded = false, renderTool } = props;\n const code = execCode(args);\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\n tone={toolTone({ running, isError })}\n expandable={code !== '' || isError}\n defaultExpanded={defaultExpanded}\n >\n {({ expanded }) => (\n <>\n <MessageItemHeader title={execToolName}>\n <View testID={`tool-call-${execToolName}`} style={styles.summary}>\n <Text numberOfLines={1} style={[styles.sans, styles.text, styles.shrink]}>\n {execSummary(args)}\n </Text>\n {calls.length > 0 ? (\n <Text numberOfLines={1} style={[styles.sans, styles.dim, styles.keep]}>\n {calls.length} {calls.length === 1 ? 'call' : 'calls'}\n {failed > 0 ? <Text style={styles.error}>, {failed} failed</Text> : null}\n </Text>\n ) : null}\n </View>\n </MessageItemHeader>\n {expanded ? (\n <MessageItemBody>\n <CodeBlock text={code} language=\"ts\" />\n </MessageItemBody>\n ) : null}\n {settled ? (\n <View accessibilityLabel=\"Script calls\" style={styles.rail}>\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: as on the web, another tool's card folds as it likes, so its pictures are repeated\n // under it; drop this once cards keep pictures visible when folded.\n return card === null || card === undefined ? (\n <CallRow key={`${String(index)}-${call.name}`} call={call} host={props} />\n ) : (\n <View key={`${String(index)}-${call.name}`} style={styles.call}>\n {card}\n <Visuals\n text=\"\"\n images={execResultView(call.result ?? null).images}\n label={call.name}\n host={props}\n />\n </View>\n );\n })}\n <Returned result={result} isError={isError} expanded={expanded} host={props} />\n </View>\n ) : null}\n </>\n )}\n </MessageItem>\n );\n}\n\nconst styles = StyleSheet.create((theme: PoNativeTheme) => ({\n summary: { flex: 1, flexDirection: 'row', alignItems: 'center', gap: theme.spacing(2), minWidth: 0 },\n shrink: { flexShrink: 1 },\n keep: { flexShrink: 0 },\n rail: {\n gap: theme.spacing(2),\n marginHorizontal: theme.spacing(4),\n marginBottom: theme.spacing(3),\n paddingLeft: theme.spacing(3),\n borderLeftWidth: 1,\n borderColor: theme.colors['border-soft'],\n },\n // A row on the rail, not a card: the rail already groups the calls.\n call: { gap: theme.spacing(2) },\n // 44pt: the smallest comfortable touch target.\n press: { minHeight: 44, justifyContent: 'center', gap: theme.spacing(0.5), paddingVertical: theme.spacing(1) },\n argsLine: { flexDirection: 'row', alignItems: 'center', gap: theme.spacing(2) },\n stack: { gap: theme.spacing(1) },\n leaf: { gap: theme.spacing(2) },\n sans: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n },\n mono: {\n fontFamily: fontOf(theme.fontFamily.mono),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n },\n name: { fontWeight: '600', color: theme.colors.text },\n args: { flex: 1, minWidth: 0, color: theme.colors.dim },\n label: { fontWeight: '600' },\n text: { color: theme.colors.text },\n dim: { color: theme.colors.dim },\n ok: { color: theme.colors.green },\n error: { color: theme.colors.red },\n image: {\n width: '100%',\n aspectRatio: 16 / 9,\n borderWidth: 1,\n borderRadius: theme.borderRadius.md,\n borderColor: theme.colors['border-soft'],\n },\n}));\n","import { defineToolRenderer } from '@agimon-ai/po-core/native';\n\nimport { ExecToolCard } from './_components/ExecToolCard.native';\n\nexport default defineToolRenderer({ message: ExecToolCard });\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineNativePlugin, type WebPluginContributions } from '@agimon-ai/po-core/native';\n\nimport toolExec from '../src/extensions/workspaces/sessions/(frontend)/tool/exec.native';\n\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const nativePlugin = defineNativePlugin({\n id: 'codemode',\n session: {\n get toolRenderers(): WebPluginContributions['toolRenderers'] { return [via({ tools: ['exec'] }, toolExec)]; },\n },\n});\n"],"mappings":";;;;;;;;;;AAKA,MAAa,eAAe;AAG5B,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,SAA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AK;EAAEiD,OAAOvB,MAAMc,OAAOxC;EAAGiC,mBAAA,CAAA,CAAA;CAAC;CAC/BlD,IAAI;EAAEkE,OAAOvB,MAAMc,OAAOU;EAAKjB,mBAAA,CAAA,CAAA;CAAC;CAChC3C,OAAO;EAAE2D,OAAOvB,MAAMc,OAAOW;EAAGlB,mBAAA,CAAA,CAAA;CAAC;CACjCjE,OAAO;EACLoF,OAAO;EACPC,aAAa,KAAK;EAClBC,aAAa;EACbC,cAAc7B,MAAM6B,aAAaC;EACjCjB,aAAab,MAAMc,OAAO;EAAcP,mBAAA,CAAA,CAAA;CAC1C;AACF,EAAE;;;ACtQF,IAAA,sBAAe,mBAAmB,EAAE,SAAS,aAAa,CAAC;;;ACC3D,MAAM,OAAU,UAAmC,UAChD,UAAU,KAAA,IAAY,KAAA,IAAY;CAAE,GAAG;CAAU,GAAI;AAAiB;AAEzE,MAAa,eAAe,mBAAmB;CAC7C,IAAI;CACJ,SAAS,EACP,IAAI,gBAAyD;EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,GAAGwB,mBAAQ,CAAC;CAAG,EAC9G;AACF,CAAC"}
@@ -197,8 +197,8 @@ function Visuals({ text, images, label, review }) {
197
197
  function CallRow({ call, review }) {
198
198
  const view = execResultView(call.result ?? null);
199
199
  const text = view.lines.join("\n");
200
- const printed = text !== "" && !readsAsDocument(text);
201
- const opens = Object.keys(call.args).length > 0 || printed;
200
+ const printed = text !== "" && (!call.ok || !readsAsDocument(text));
201
+ const opens = Object.keys(call.args).length > 0 || printed || call.error !== void 0;
202
202
  const head = /* @__PURE__ */ jsxs(Fragment, { children: [
203
203
  /* @__PURE__ */ jsx("span", {
204
204
  className: "shrink-0 truncate font-mono font-semibold text-po-text max-sm:basis-full",
@@ -225,38 +225,38 @@ function CallRow({ call, review }) {
225
225
  return /* @__PURE__ */ jsxs("div", {
226
226
  "data-testid": "exec-call",
227
227
  className: "flex flex-col gap-2 py-1.5",
228
- children: [
229
- opens ? /* @__PURE__ */ jsxs("details", {
230
- className: "group text-sm",
231
- children: [/* @__PURE__ */ jsxs("summary", {
232
- className: `${SUMMARY} flex-wrap`,
233
- children: [head, /* @__PURE__ */ jsx(Chevron, {})]
234
- }), /* @__PURE__ */ jsxs("div", {
235
- className: "mt-2 flex flex-col gap-2",
236
- children: [Object.keys(call.args).length > 0 ? /* @__PURE__ */ jsx(CodeBlock, {
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
237
  text: JSON.stringify(call.args, null, 2),
238
238
  className: "language-json"
239
- }) : null, printed ? /* @__PURE__ */ jsx("pre", {
239
+ }) : null,
240
+ printed ? /* @__PURE__ */ jsx("pre", {
240
241
  "data-testid": "exec-call-output",
241
242
  className: "max-h-72 overflow-auto font-mono text-sm break-words whitespace-pre-wrap text-po-text",
242
243
  children: text
243
- }) : null]
244
- })]
245
- }) : /* @__PURE__ */ jsx("div", {
246
- className: "flex flex-wrap items-center gap-x-2 gap-y-0.5 text-sm",
247
- children: head
248
- }),
249
- call.error === void 0 ? null : /* @__PURE__ */ jsx("p", {
250
- className: "text-sm break-words text-po-red",
251
- children: call.error
252
- }),
253
- /* @__PURE__ */ jsx(Visuals, {
254
- text,
255
- images: view.images,
256
- label: call.name,
257
- review
258
- })
259
- ]
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
+ }), /* @__PURE__ */ jsx(Visuals, {
255
+ text: call.ok ? text : "",
256
+ images: view.images,
257
+ label: call.name,
258
+ review
259
+ })]
260
260
  });
261
261
  }
262
262
  /** The script's outcome as the tree's last leaf: one line until opened, the whole text after; visuals always. */
@@ -271,11 +271,10 @@ function Returned({ result, isError, review }) {
271
271
  children: [view.lines.length === 0 ? /* @__PURE__ */ jsx("p", {
272
272
  className: "text-sm text-po-dim",
273
273
  children: isError ? "Failed with no output." : "Returned nothing."
274
- }) : readsAsDocument(text) ? /* @__PURE__ */ jsx("p", {
274
+ }) : !isError && readsAsDocument(text) ? /* @__PURE__ */ jsx("p", {
275
275
  className: "text-sm font-semibold text-po-dim",
276
276
  children: label
277
277
  }) : /* @__PURE__ */ jsxs("details", {
278
- open: isError,
279
278
  className: "group text-sm",
280
279
  children: [/* @__PURE__ */ jsxs("summary", {
281
280
  className: `${SUMMARY} text-po-dim hover:text-po-blue`,
@@ -296,7 +295,7 @@ function Returned({ result, isError, review }) {
296
295
  children: text
297
296
  })]
298
297
  }), /* @__PURE__ */ jsx(Visuals, {
299
- text,
298
+ text: isError ? "" : text,
300
299
  images: view.images,
301
300
  label: "Script",
302
301
  review
@@ -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":["// 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 } 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({ call, review }: { call: ExecCall; review: MarkdownMediaReview | undefined }) {\n const view = execResultView(call.result ?? null);\n const text = view.lines.join('\\n');\n const printed = text !== '' && !readsAsDocument(text);\n const opens = Object.keys(call.args).length > 0 || printed;\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 </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 {call.error === undefined ? null : <p className=\"text-sm break-words text-po-red\">{call.error}</p>}\n <Visuals text={text} images={view.images} label={call.name} review={review} />\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}: {\n result: ExecToolCardProps['result'];\n isError: boolean;\n review: MarkdownMediaReview | undefined;\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 ) : readsAsDocument(text) ? (\n <p className=\"text-sm font-semibold text-po-dim\">{label}</p>\n ) : (\n <details open={isError} 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 <Visuals text={text} images={view.images} label=\"Script\" review={review} />\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 } = 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} />\n ) : (\n <>\n {card}\n <Visuals\n text=\"\"\n images={execResultView(call.result ?? null).images}\n label={call.name}\n review={review}\n />\n </>\n )}\n </li>\n );\n })}\n <li className={BRANCH}>\n <Returned result={result} isError={isError} review={review} />\n </li>\n </ol>\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":";;;;;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,M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CACG,MACD,oBAAC,SAAD;OACE,MAAK;OACL,QAAQ,eAAe,KAAK,UAAU,IAAI,CAAC,CAAC;OAC5C,OAAO,KAAK;OACJ;MACT,CAAA,CACD,EAAA,CAAA;KAEF,GAdK,GAAG,OAAO,KAAK,EAAE,GAAG,KAAK,MAc9B;IAER,CAAC,GACD,oBAAC,MAAD;KAAI,WAAW;KACb,UAAA,oBAAC,UAAD;MAAkB;MAAiB;MAAiB;KAAS,CAAA;IAC3D,CAAA,CACF;GACF,CAAA,IAAA;EACJ,EAAA,CAAA;CAEO,CAAA;AAEjB;;;AC9PA,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 } 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({ call, review }: { call: ExecCall; review: MarkdownMediaReview | undefined }) {\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 <Visuals text={call.ok ? text : ''} images={view.images} label={call.name} review={review} />\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}: {\n result: ExecToolCardProps['result'];\n isError: boolean;\n review: MarkdownMediaReview | undefined;\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 <Visuals text={isError ? '' : text} images={view.images} label=\"Script\" review={review} />\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 } = 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} />\n ) : (\n <>\n {card}\n <Visuals\n text=\"\"\n images={execResultView(call.result ?? null).images}\n label={call.name}\n review={review}\n />\n </>\n )}\n </li>\n );\n })}\n <li className={BRANCH}>\n <Returned result={result} isError={isError} review={review} />\n </li>\n </ol>\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":";;;;;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,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AAG,OAAO;MAC5D,UAAA,SAAS,OACR,oBAAC,SAAD;OAAe;OAAc;MAAS,CAAA,IAEtC,qBAAA,UAAA,EAAA,UAAA,CACG,MACD,oBAAC,SAAD;OACE,MAAK;OACL,QAAQ,eAAe,KAAK,UAAU,IAAI,CAAC,CAAC;OAC5C,OAAO,KAAK;OACJ;MACT,CAAA,CACD,EAAA,CAAA;KAEF,GAdK,GAAG,OAAO,KAAK,EAAE,GAAG,KAAK,MAc9B;IAER,CAAC,GACD,oBAAC,MAAD;KAAI,WAAW;KACb,UAAA,oBAAC,UAAD;MAAkB;MAAiB;MAAiB;KAAS,CAAA;IAC3D,CAAA,CACF;GACF,CAAA,IAAA;EACJ,EAAA,CAAA;CAEO,CAAA;AAEjB;;;AC9PA,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agimon-ai/po-codemode",
3
- "version": "0.0.1-alpha.82",
3
+ "version": "0.0.1-alpha.84",
4
4
  "description": "Code mode for Po sessions: discover and exec over namespaces other packages contribute",
5
5
  "keywords": [
6
6
  "ai",
@@ -63,18 +63,18 @@
63
63
  "access": "public"
64
64
  },
65
65
  "dependencies": {
66
- "@agimon-ai/po-config": "0.0.0-alpha.109",
67
- "@agimon-ai/po-core": "0.0.0-alpha.109",
68
- "@agimon-ai/po-web-components": "0.0.0-alpha.109",
66
+ "@agimon-ai/po-config": "0.0.0-alpha.111",
67
+ "@agimon-ai/po-core": "0.0.0-alpha.111",
68
+ "@agimon-ai/po-web-components": "0.0.0-alpha.111",
69
69
  "@deepseek-ai/cordis": "4.0.5",
70
70
  "react": "19.3.1",
71
71
  "typebox": "1.4.2"
72
72
  },
73
73
  "devDependencies": {
74
- "@agimon-ai/po-build": "0.0.0-alpha.109",
75
- "@agimon-ai/po-native-components": "0.0.0-alpha.109",
76
- "@agimon-ai/vibe-lint-plugin-po-extension": "0.0.0-alpha.109",
77
- "@agimon-ai/vibe-lint-plugin-po-web": "0.0.0-alpha.109",
74
+ "@agimon-ai/po-build": "0.0.0-alpha.111",
75
+ "@agimon-ai/po-native-components": "0.0.0-alpha.111",
76
+ "@agimon-ai/vibe-lint-plugin-po-extension": "0.0.0-alpha.111",
77
+ "@agimon-ai/vibe-lint-plugin-po-web": "0.0.0-alpha.111",
78
78
  "@earendil-works/pi-coding-agent": "1.5.0",
79
79
  "@types/node": "26.6.5",
80
80
  "@types/react": "19.3.0",
@@ -88,7 +88,7 @@
88
88
  "vitest": "5.0.4"
89
89
  },
90
90
  "peerDependencies": {
91
- "@agimon-ai/po-native-components": "0.0.0-alpha.109",
91
+ "@agimon-ai/po-native-components": "0.0.0-alpha.111",
92
92
  "@earendil-works/pi-coding-agent": "1.5.0",
93
93
  "react-native": "0.88.1",
94
94
  "react-native-unistyles": "^3.5.3"