@agimon-ai/po-read 0.0.0-alpha.69 → 0.0.0-alpha.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/extensions/web.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineToolRenderer, defineWebPlugin } from "@agimon-ai/po-core/web";
|
|
2
|
-
import { HashlineLines, MessageItem, MessageItemBody, MessageItemHeader, MessageItemStatus, ToolPathLink, hashlineBody, resultTextLines, toolTone } from "@agimon-ai/po-web-components";
|
|
2
|
+
import { HashlineLines, MessageItem, MessageItemBody, MessageItemHeader, MessageItemStatus, ToolPathLink, ViewableImage, hashlineBody, resultTextLines, 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/readToolView.ts
|
|
5
5
|
function optionalNumber(value) {
|
|
@@ -90,21 +90,12 @@ function ReadToolMessage({ args, result, output, running, isError, fileTabFor, o
|
|
|
90
90
|
gutter: body.gutter,
|
|
91
91
|
path: view.path
|
|
92
92
|
}),
|
|
93
|
-
images.map((image, index) => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
className: "self-start",
|
|
100
|
-
children: /* @__PURE__ */ jsx("img", {
|
|
101
|
-
src: url,
|
|
102
|
-
alt: `Read result ${String(index + 1)}`,
|
|
103
|
-
"data-testid": "tool-result-read-image",
|
|
104
|
-
className: "h-auto max-h-96 max-w-full rounded-md border border-po-border-soft object-contain"
|
|
105
|
-
})
|
|
106
|
-
}, `${image.mimeType}:${String(index)}`);
|
|
107
|
-
}),
|
|
93
|
+
images.map((image, index) => /* @__PURE__ */ jsx(ViewableImage, {
|
|
94
|
+
src: `data:${image.mimeType};base64,${image.data}`,
|
|
95
|
+
alt: `Read result ${String(index + 1)}`,
|
|
96
|
+
"data-testid": "tool-result-read-image",
|
|
97
|
+
className: "h-auto max-h-96 max-w-full rounded-md border border-po-border-soft object-contain"
|
|
98
|
+
}, `${image.mimeType}:${String(index)}`)),
|
|
108
99
|
body.notice !== void 0 ? /* @__PURE__ */ jsx("span", {
|
|
109
100
|
className: "text-po-faint",
|
|
110
101
|
children: body.notice
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.mjs","names":["toolRead"],"sources":["../../src/extensions/workspaces/sessions/(frontend)/tool/_lib/readToolView.ts","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/ReadToolMessage.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/read.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 component library.\n\nexport interface ReadCallView {\n readonly path: string;\n /** `from N` and `N lines`, as the TUI's call heading lists them. */\n readonly details: readonly string[];\n}\n\nfunction optionalNumber(value: unknown): number | undefined {\n return typeof value === 'number' && Number.isFinite(value) ? value : undefined;\n}\n\n/** What the read call heading shows: the path, then the offset and limit when given. */\nexport function readCallView(args: Readonly<Record<string, unknown>>): ReadCallView {\n const offset = optionalNumber(args.offset);\n const limit = optionalNumber(args.limit);\n return {\n path: typeof args.path === 'string' ? args.path : '',\n details: [\n offset === undefined ? undefined : `from ${offset}`,\n limit === undefined ? undefined : `${limit} lines`,\n ].filter((value): value is string => value !== undefined && value.length > 0),\n };\n}\n\nconst IMAGE_MIME_TYPES = new Set(['image/png', 'image/jpeg', 'image/gif', 'image/webp']);\n\n/** The image blocks a read returned, limited to the formats both cards can draw. */\nexport function resultImages(content: readonly unknown[]): Array<{ data: string; mimeType: string }> {\n return content.flatMap((block) => {\n if (typeof block !== 'object' || block === null || Array.isArray(block)) return [];\n const value = block as Record<string, unknown>;\n return value.type === 'image' &&\n typeof value.data === 'string' &&\n typeof value.mimeType === 'string' &&\n IMAGE_MIME_TYPES.has(value.mimeType)\n ? [{ data: value.data, mimeType: value.mimeType }]\n : [];\n });\n}\n","import type { ToolMessageRenderProps } from '@agimon-ai/po-core/web';\nimport {\n HashlineLines,\n hashlineBody,\n MessageItem,\n MessageItemBody,\n MessageItemHeader,\n MessageItemStatus,\n resultTextLines,\n ToolPathLink,\n toolTone,\n} from '@agimon-ai/po-web-components';\n\nimport { readCallView, resultImages } from '../_lib/readToolView';\n\n/**\n * The read tool's timeline item, the web half of its renderCall and\n * renderResult: the call summary in the header and, when expanded, the\n * anchored lines with a line-number gutter in the body. A failure shows the\n * tool's message in red inside the expanded body instead.\n */\nexport function ReadToolMessage({\n args,\n result,\n output,\n running,\n isError,\n fileTabFor,\n openTransientTab,\n}: ToolMessageRenderProps) {\n const view = readCallView(args);\n const images = resultImages(result?.content ?? []);\n // A read is the one call whose file the session usually has not changed, so\n // this is the link that opens it read-only rather than in its history.\n const tab = fileTabFor(view.path);\n const body = result === null || isError ? null : hashlineBody(result, output, 'read', true);\n return (\n <MessageItem tone={toolTone({ running, isError })} expandable defaultExpanded={false}>\n {({ expanded }) => {\n return (\n <>\n <MessageItemHeader title=\"read\">\n <span data-testid=\"tool-call-read\" className=\"flex min-w-0 flex-1 items-center gap-2\">\n <ToolPathLink\n path={view.path}\n {...(tab === undefined ? {} : { onOpen: () => openTransientTab(tab) })}\n />\n {view.details.length > 0 ? (\n <span className=\"shrink-0 text-po-faint\">· {view.details.join(' · ')}</span>\n ) : null}\n </span>\n </MessageItemHeader>\n {expanded ? (\n isError ? (\n <MessageItemBody data-testid=\"tool-result-read\" className=\"flex flex-col\">\n <MessageItemStatus tone=\"error\">failed</MessageItemStatus>\n {resultTextLines(result, output).map((line, index) => (\n <span key={`${String(index)}-${line}`} className=\"whitespace-pre-wrap break-words text-po-red\">\n {line}\n </span>\n ))}\n </MessageItemBody>\n ) : body === null ? (\n running ? (\n <MessageItemBody data-testid=\"tool-result-read\">\n <MessageItemStatus tone=\"running\">running</MessageItemStatus>\n </MessageItemBody>\n ) : null\n ) : body.shown.length === 0 && body.notice === undefined && images.length === 0 ? null : (\n <MessageItemBody data-testid=\"tool-result-read\" className=\"flex flex-col gap-1\">\n {/* A read body is one file with no heading of its own, so the\n call's path is what names the grammar for it. */}\n <HashlineLines lines={body.shown} gutter={body.gutter} path={view.path} />\n {images.map((image, index) =>
|
|
1
|
+
{"version":3,"file":"web.mjs","names":["toolRead"],"sources":["../../src/extensions/workspaces/sessions/(frontend)/tool/_lib/readToolView.ts","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/ReadToolMessage.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/read.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 component library.\n\nexport interface ReadCallView {\n readonly path: string;\n /** `from N` and `N lines`, as the TUI's call heading lists them. */\n readonly details: readonly string[];\n}\n\nfunction optionalNumber(value: unknown): number | undefined {\n return typeof value === 'number' && Number.isFinite(value) ? value : undefined;\n}\n\n/** What the read call heading shows: the path, then the offset and limit when given. */\nexport function readCallView(args: Readonly<Record<string, unknown>>): ReadCallView {\n const offset = optionalNumber(args.offset);\n const limit = optionalNumber(args.limit);\n return {\n path: typeof args.path === 'string' ? args.path : '',\n details: [\n offset === undefined ? undefined : `from ${offset}`,\n limit === undefined ? undefined : `${limit} lines`,\n ].filter((value): value is string => value !== undefined && value.length > 0),\n };\n}\n\nconst IMAGE_MIME_TYPES = new Set(['image/png', 'image/jpeg', 'image/gif', 'image/webp']);\n\n/** The image blocks a read returned, limited to the formats both cards can draw. */\nexport function resultImages(content: readonly unknown[]): Array<{ data: string; mimeType: string }> {\n return content.flatMap((block) => {\n if (typeof block !== 'object' || block === null || Array.isArray(block)) return [];\n const value = block as Record<string, unknown>;\n return value.type === 'image' &&\n typeof value.data === 'string' &&\n typeof value.mimeType === 'string' &&\n IMAGE_MIME_TYPES.has(value.mimeType)\n ? [{ data: value.data, mimeType: value.mimeType }]\n : [];\n });\n}\n","import type { ToolMessageRenderProps } from '@agimon-ai/po-core/web';\nimport {\n HashlineLines,\n hashlineBody,\n MessageItem,\n MessageItemBody,\n MessageItemHeader,\n MessageItemStatus,\n resultTextLines,\n ToolPathLink,\n toolTone,\n ViewableImage,\n} from '@agimon-ai/po-web-components';\n\nimport { readCallView, resultImages } from '../_lib/readToolView';\n\n/**\n * The read tool's timeline item, the web half of its renderCall and\n * renderResult: the call summary in the header and, when expanded, the\n * anchored lines with a line-number gutter in the body. A failure shows the\n * tool's message in red inside the expanded body instead.\n */\nexport function ReadToolMessage({\n args,\n result,\n output,\n running,\n isError,\n fileTabFor,\n openTransientTab,\n}: ToolMessageRenderProps) {\n const view = readCallView(args);\n const images = resultImages(result?.content ?? []);\n // A read is the one call whose file the session usually has not changed, so\n // this is the link that opens it read-only rather than in its history.\n const tab = fileTabFor(view.path);\n const body = result === null || isError ? null : hashlineBody(result, output, 'read', true);\n return (\n <MessageItem tone={toolTone({ running, isError })} expandable defaultExpanded={false}>\n {({ expanded }) => {\n return (\n <>\n <MessageItemHeader title=\"read\">\n <span data-testid=\"tool-call-read\" className=\"flex min-w-0 flex-1 items-center gap-2\">\n <ToolPathLink\n path={view.path}\n {...(tab === undefined ? {} : { onOpen: () => openTransientTab(tab) })}\n />\n {view.details.length > 0 ? (\n <span className=\"shrink-0 text-po-faint\">· {view.details.join(' · ')}</span>\n ) : null}\n </span>\n </MessageItemHeader>\n {expanded ? (\n isError ? (\n <MessageItemBody data-testid=\"tool-result-read\" className=\"flex flex-col\">\n <MessageItemStatus tone=\"error\">failed</MessageItemStatus>\n {resultTextLines(result, output).map((line, index) => (\n <span key={`${String(index)}-${line}`} className=\"whitespace-pre-wrap break-words text-po-red\">\n {line}\n </span>\n ))}\n </MessageItemBody>\n ) : body === null ? (\n running ? (\n <MessageItemBody data-testid=\"tool-result-read\">\n <MessageItemStatus tone=\"running\">running</MessageItemStatus>\n </MessageItemBody>\n ) : null\n ) : body.shown.length === 0 && body.notice === undefined && images.length === 0 ? null : (\n <MessageItemBody data-testid=\"tool-result-read\" className=\"flex flex-col gap-1\">\n {/* A read body is one file with no heading of its own, so the\n call's path is what names the grammar for it. */}\n <HashlineLines lines={body.shown} gutter={body.gutter} path={view.path} />\n {images.map((image, index) => (\n <ViewableImage\n key={`${image.mimeType}:${String(index)}`}\n src={`data:${image.mimeType};base64,${image.data}`}\n alt={`Read result ${String(index + 1)}`}\n data-testid=\"tool-result-read-image\"\n className=\"h-auto max-h-96 max-w-full rounded-md border border-po-border-soft object-contain\"\n />\n ))}\n {body.notice !== undefined ? <span className=\"text-po-faint\">{body.notice}</span> : null}\n </MessageItemBody>\n )\n ) : null}\n </>\n );\n }}\n </MessageItem>\n );\n}\n","import { defineToolRenderer } from '@agimon-ai/po-core/web';\n\nimport { ReadToolMessage } from './_components/ReadToolMessage';\n\nexport default defineToolRenderer({ message: ReadToolMessage });\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineWebPlugin, type WebPluginContributions } from '@agimon-ai/po-core/web';\n\nimport toolRead from '../src/extensions/workspaces/sessions/(frontend)/tool/read.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: 'read',\n session: {\n get toolRenderers(): WebPluginContributions['toolRenderers'] { return [via({ tools: ['read'] }, toolRead)]; },\n },\n});\n"],"mappings":";;;;AASA,SAAS,eAAe,OAAoC;CAC1D,OAAO,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,IAAI,QAAQ,KAAA;AACvE;;AAGA,SAAgB,aAAa,MAAuD;CAClF,MAAM,SAAS,eAAe,KAAK,MAAM;CACzC,MAAM,QAAQ,eAAe,KAAK,KAAK;CACvC,OAAO;EACL,MAAM,OAAO,KAAK,SAAS,WAAW,KAAK,OAAO;EAClD,SAAS,CACP,WAAW,KAAA,IAAY,KAAA,IAAY,QAAQ,UAC3C,UAAU,KAAA,IAAY,KAAA,IAAY,GAAG,MAAM,OAC7C,CAAC,CAAC,QAAQ,UAA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CACvC,IAAI;CACJ,SAAS,EACP,IAAI,gBAAyD;EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,GAAGA,gBAAQ,CAAC;CAAG,EAC9G;AACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agimon-ai/po-read",
|
|
3
|
-
"version": "0.0.0-alpha.
|
|
3
|
+
"version": "0.0.0-alpha.70",
|
|
4
4
|
"description": "Snapshot-bound hashline read tool for Pi and Po.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -60,17 +60,17 @@
|
|
|
60
60
|
"access": "public"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@agimon-ai/po-config": "0.0.0-alpha.
|
|
64
|
-
"@agimon-ai/po-core": "0.0.0-alpha.
|
|
65
|
-
"@agimon-ai/po-hashline": "0.0.0-alpha.
|
|
66
|
-
"@agimon-ai/po-ui": "0.0.0-alpha.
|
|
67
|
-
"@agimon-ai/po-web-components": "0.0.0-alpha.
|
|
63
|
+
"@agimon-ai/po-config": "0.0.0-alpha.70",
|
|
64
|
+
"@agimon-ai/po-core": "0.0.0-alpha.70",
|
|
65
|
+
"@agimon-ai/po-hashline": "0.0.0-alpha.70",
|
|
66
|
+
"@agimon-ai/po-ui": "0.0.0-alpha.70",
|
|
67
|
+
"@agimon-ai/po-web-components": "0.0.0-alpha.70",
|
|
68
68
|
"@deepseek-ai/cordis": "4.0.5",
|
|
69
69
|
"typebox": "1.4.2"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@agimon-ai/po-build": "0.0.0-alpha.
|
|
73
|
-
"@agimon-ai/po-native-components": "0.0.0-alpha.
|
|
72
|
+
"@agimon-ai/po-build": "0.0.0-alpha.70",
|
|
73
|
+
"@agimon-ai/po-native-components": "0.0.0-alpha.70",
|
|
74
74
|
"@earendil-works/pi-coding-agent": "1.4.0",
|
|
75
75
|
"@earendil-works/pi-durable": "1.4.0",
|
|
76
76
|
"@tanstack/react-store": "0.11.2",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"vitest": "5.0.4"
|
|
88
88
|
},
|
|
89
89
|
"peerDependencies": {
|
|
90
|
-
"@agimon-ai/po-native-components": "0.0.0-alpha.
|
|
90
|
+
"@agimon-ai/po-native-components": "0.0.0-alpha.70",
|
|
91
91
|
"@earendil-works/pi-coding-agent": "1.4.0",
|
|
92
92
|
"react-native": "0.88.0",
|
|
93
93
|
"react-native-unistyles": "^3.5.3"
|