@agimon-ai/po-image-gen 0.0.0-alpha.151 → 0.0.0-alpha.152
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -4
- package/dist/apiContracts.cjs +1 -1
- package/dist/apiContracts.cjs.map +1 -1
- package/dist/apiContracts.mjs +1 -1
- package/dist/apiContracts.mjs.map +1 -1
- package/dist/extensions/native.mjs +2 -2
- package/dist/extensions/native.mjs.map +1 -1
- package/dist/extensions/server.cjs +52 -24
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.mjs +52 -24
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/extensions/web.mjs +14 -11
- package/dist/extensions/web.mjs.map +1 -1
- package/dist/{imagegenTool-tnDwaYpe.mjs → imagegenTool-C9nAa9_G.mjs} +239 -188
- package/dist/imagegenTool-C9nAa9_G.mjs.map +1 -0
- package/dist/{imagegenTool-BjNsLs9o.cjs → imagegenTool-CpXZxFEy.cjs} +250 -187
- package/dist/imagegenTool-CpXZxFEy.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.mts +6 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +9 -9
- package/src/prompts/codemode-how-to-image-gen/SKILL.md +5 -3
- package/dist/imagegenTool-BjNsLs9o.cjs.map +0 -1
- package/dist/imagegenTool-tnDwaYpe.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -14,20 +14,23 @@ Sign in to **ChatGPT for Po features** under Settings > Providers (or with `/log
|
|
|
14
14
|
|
|
15
15
|
- `prompt`: non-blank image instructions.
|
|
16
16
|
- `transparent_background`: optional boolean.
|
|
17
|
+
- `gif`: optional object requesting animated GIF output. `{}` uses backend defaults (9 frames, 200 ms each); `frame_count` accepts integers 2 to 16 and `frame_duration_ms` accepts integers 20 to 2000. Omit for PNG. Works with generation or edits; backend entitlement still applies.
|
|
17
18
|
- `referenced_image_paths`: optional list of up to five absolute local PNG, JPEG, WebP, or GIF file paths. Omit for a new image; supply for an edit. A GIF is sent as a PNG of its first frame. Each file is limited to 20 MiB, with 50 MiB total.
|
|
18
19
|
- `num_last_images_to_include`: optional 1 to 5. Edits the most recent images from user messages and tool results instead, for targets without a local path. Never combined with `referenced_image_paths`; fails when fewer images are available. Same size limits.
|
|
19
20
|
|
|
20
21
|
These match Codex's `image_gen.imagegen` arguments. Codex fixes model, quality and size rather than exposing them, and so does Po.
|
|
21
22
|
|
|
22
|
-
The result includes an inline PNG and a save hint. Files are created exclusively at `<poHome>/generated_images/<session>/<call>.png
|
|
23
|
+
The result includes an inline PNG or animated GIF and a save hint. Files are created exclusively in the session's temporary `images` directory when available, otherwise at `<poHome>/generated_images/<session>/<call>.png` (or `.gif`); existing files are never overwritten. Artifact copies preserve the original format and animation. A save failure returns the image with a warning. Output is limited to 32 MiB by the transport and 20 MiB by artifact storage and previews. Details record each local input file as `{ path, sha256 }` of the bytes read, and the card lists them.
|
|
23
24
|
|
|
24
|
-
In code mode, `imagegen.generate` also shows each image to the model when the exec run returns. When the run's image limit refuses
|
|
25
|
+
In code mode, `imagegen.generate` also shows each image to the model when the exec run returns. GIFs use the existing first-frame PNG preview while the image card and saved file retain the animation. When the run's image limit refuses a preview, the result carries `modelVisibilityWarning`; do not repeat generation.
|
|
25
26
|
|
|
26
|
-
Quota, account denial, and network failures are returned without retrying. Cancelling propagates the abort signal. Model/quality/size selection and MCP are not included.
|
|
27
|
+
Quota, account denial, and network failures are returned without retrying. Quota failures retain a validated request ID when supplied. Recognized usage-limit responses include `failure: { kind: 'usage_limit_exceeded', limitId: 'image_gen' | 'imagegen_premium', resetsAt? }`, with reset time in Unix seconds. Cancelling propagates the abort signal. Model/quality/size selection and MCP are not included.
|
|
27
28
|
|
|
28
29
|
## Code mode
|
|
29
30
|
|
|
30
|
-
When code mode is bound, the package registers the `imagegen` namespace (`imagegen.generate(prompt, { transparentBackground?, referencedImagePaths?, numLastImagesToInclude? })
|
|
31
|
+
When code mode is bound, the package registers the `imagegen` namespace (`imagegen.generate(prompt, { transparentBackground?, gif?: { frameCount?, frameDurationMs? }, referencedImagePaths?, numLastImagesToInclude? })`) and withdraws the `imagegen` tool, so the model sees one surface. Success resolves to `{ savedPath }` or `{ saveWarning }`, optionally with `modelVisibilityWarning`; quota failure resolves to `{ error, requestId?, failure? }`. Other errors throw. Both surfaces run the same generate, save and artifact-copy path, and the cockpit draws namespace calls with the tool's image card. The pinned `codemode-how-to-image-gen` skill teaches its use.
|
|
32
|
+
|
|
33
|
+
For a simple animation, use `await imagegen.generate('A fox waving in a seamless loop', { gif: { frameCount: 9, frameDurationMs: 200 } })`. To edit a generated GIF's motion, inspect its frames and supply a spritesheet with equal-sized cells in a regular grid as a reference, then set `gif`. Passing the GIF itself as a reference sends only its first frame.
|
|
31
34
|
|
|
32
35
|
## Structure and lifecycle
|
|
33
36
|
|
package/dist/apiContracts.cjs
CHANGED
|
@@ -16,7 +16,7 @@ const Artifact = typebox.Type.Object({
|
|
|
16
16
|
originalPath: typebox.Type.String(),
|
|
17
17
|
sourceSha256: typebox.Type.String(),
|
|
18
18
|
data: typebox.Type.String(),
|
|
19
|
-
mimeType: typebox.Type.Literal("image/png"),
|
|
19
|
+
mimeType: typebox.Type.Union([typebox.Type.Literal("image/png"), typebox.Type.Literal("image/gif")]),
|
|
20
20
|
offset: typebox.Type.Optional(typebox.Type.Integer({ minimum: 0 }))
|
|
21
21
|
});
|
|
22
22
|
const apiContracts = (0, _agimon_ai_po_core_apiContracts.defineApiContract)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiContracts.cjs","names":["Type","defineApiContract","jsonApiResponses"],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\nconst Metadata = { id: Type.String(), createdAt: Type.String(), byteLength: Type.Integer() };\nconst Artifact = Type.Object({\n ...Metadata,\n sessionId: Type.String(),\n originalPath: Type.String(),\n sourceSha256: Type.String(),\n data: Type.String(),\n mimeType: Type.Literal('image/png'),\n offset: Type.Optional(Type.Integer({ minimum: 0 })),\n});\n\nexport const apiContracts = defineApiContract({\n version: 1,\n http: [\n {\n id: 'promoteImage',\n scope: 'session',\n basePath: 'images',\n path: '/promote',\n method: 'POST',\n authentication: 'owner',\n description: 'Copy one preserved session image into session artifacts for Author.',\n body: {\n contentType: 'application/json',\n required: true,\n schema: Type.Object(\n { id: Type.String({ pattern: '^[A-Za-z0-9_-]{1,128}$' }) },\n { additionalProperties: false },\n ),\n },\n responses: jsonApiResponses(Type.Object({ sessionId: Type.String(), path: Type.String() })),\n },\n {\n id: 'listImages',\n scope: 'session',\n basePath: 'images',\n path: '/artifacts',\n method: 'GET',\n authentication: 'owner',\n description: 'List preserved images in the current session.',\n responses: jsonApiResponses(\n Type.Object({\n sessionId: Type.String(),\n items: Type.Array(Type.Object(Metadata)),\n nextCursor: Type.Union([Type.String(), Type.Null()]),\n }),\n ),\n },\n {\n id: 'readImage',\n scope: 'session',\n basePath: 'images',\n path: '/artifact',\n method: 'GET',\n authentication: 'owner',\n description: 'Read a verified preserved session image by artifact or tool call identity.',\n responses: jsonApiResponses(Artifact),\n },\n ],\n sockets: [],\n dynamic: [],\n});\nexport default apiContracts;\n"],"mappings":";;;;;;;AAGA,MAAM,WAAW;CAAE,IAAIA,QAAAA,KAAK,OAAO;CAAG,WAAWA,QAAAA,KAAK,OAAO;CAAG,YAAYA,QAAAA,KAAK,QAAQ;AAAE;AAC3F,MAAM,WAAWA,QAAAA,KAAK,OAAO;CAC3B,GAAG;CACH,WAAWA,QAAAA,KAAK,OAAO;CACvB,cAAcA,QAAAA,KAAK,OAAO;CAC1B,cAAcA,QAAAA,KAAK,OAAO;CAC1B,MAAMA,QAAAA,KAAK,OAAO;CAClB,UAAUA,QAAAA,KAAK,QAAQ,WAAW;
|
|
1
|
+
{"version":3,"file":"apiContracts.cjs","names":["Type","defineApiContract","jsonApiResponses"],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\nconst Metadata = { id: Type.String(), createdAt: Type.String(), byteLength: Type.Integer() };\nconst Artifact = Type.Object({\n ...Metadata,\n sessionId: Type.String(),\n originalPath: Type.String(),\n sourceSha256: Type.String(),\n data: Type.String(),\n mimeType: Type.Union([Type.Literal('image/png'), Type.Literal('image/gif')]),\n offset: Type.Optional(Type.Integer({ minimum: 0 })),\n});\n\nexport const apiContracts = defineApiContract({\n version: 1,\n http: [\n {\n id: 'promoteImage',\n scope: 'session',\n basePath: 'images',\n path: '/promote',\n method: 'POST',\n authentication: 'owner',\n description: 'Copy one preserved session image into session artifacts for Author.',\n body: {\n contentType: 'application/json',\n required: true,\n schema: Type.Object(\n { id: Type.String({ pattern: '^[A-Za-z0-9_-]{1,128}$' }) },\n { additionalProperties: false },\n ),\n },\n responses: jsonApiResponses(Type.Object({ sessionId: Type.String(), path: Type.String() })),\n },\n {\n id: 'listImages',\n scope: 'session',\n basePath: 'images',\n path: '/artifacts',\n method: 'GET',\n authentication: 'owner',\n description: 'List preserved images in the current session.',\n responses: jsonApiResponses(\n Type.Object({\n sessionId: Type.String(),\n items: Type.Array(Type.Object(Metadata)),\n nextCursor: Type.Union([Type.String(), Type.Null()]),\n }),\n ),\n },\n {\n id: 'readImage',\n scope: 'session',\n basePath: 'images',\n path: '/artifact',\n method: 'GET',\n authentication: 'owner',\n description: 'Read a verified preserved session image by artifact or tool call identity.',\n responses: jsonApiResponses(Artifact),\n },\n ],\n sockets: [],\n dynamic: [],\n});\nexport default apiContracts;\n"],"mappings":";;;;;;;AAGA,MAAM,WAAW;CAAE,IAAIA,QAAAA,KAAK,OAAO;CAAG,WAAWA,QAAAA,KAAK,OAAO;CAAG,YAAYA,QAAAA,KAAK,QAAQ;AAAE;AAC3F,MAAM,WAAWA,QAAAA,KAAK,OAAO;CAC3B,GAAG;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N,QAAQ;GACR,gBAAgB;GAChB,aAAa;GACb,YAAA,GAAWE,gCAAAA,iBAAAA,CAAiB,QAAQ;EACtC;CACF;CACA,SAAS,CAAC;CACV,SAAS,CAAC;AACZ,CAAC"}
|
package/dist/apiContracts.mjs
CHANGED
|
@@ -12,7 +12,7 @@ const Artifact = Type.Object({
|
|
|
12
12
|
originalPath: Type.String(),
|
|
13
13
|
sourceSha256: Type.String(),
|
|
14
14
|
data: Type.String(),
|
|
15
|
-
mimeType: Type.Literal("image/png"),
|
|
15
|
+
mimeType: Type.Union([Type.Literal("image/png"), Type.Literal("image/gif")]),
|
|
16
16
|
offset: Type.Optional(Type.Integer({ minimum: 0 }))
|
|
17
17
|
});
|
|
18
18
|
const apiContracts = defineApiContract({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiContracts.mjs","names":[],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\nconst Metadata = { id: Type.String(), createdAt: Type.String(), byteLength: Type.Integer() };\nconst Artifact = Type.Object({\n ...Metadata,\n sessionId: Type.String(),\n originalPath: Type.String(),\n sourceSha256: Type.String(),\n data: Type.String(),\n mimeType: Type.Literal('image/png'),\n offset: Type.Optional(Type.Integer({ minimum: 0 })),\n});\n\nexport const apiContracts = defineApiContract({\n version: 1,\n http: [\n {\n id: 'promoteImage',\n scope: 'session',\n basePath: 'images',\n path: '/promote',\n method: 'POST',\n authentication: 'owner',\n description: 'Copy one preserved session image into session artifacts for Author.',\n body: {\n contentType: 'application/json',\n required: true,\n schema: Type.Object(\n { id: Type.String({ pattern: '^[A-Za-z0-9_-]{1,128}$' }) },\n { additionalProperties: false },\n ),\n },\n responses: jsonApiResponses(Type.Object({ sessionId: Type.String(), path: Type.String() })),\n },\n {\n id: 'listImages',\n scope: 'session',\n basePath: 'images',\n path: '/artifacts',\n method: 'GET',\n authentication: 'owner',\n description: 'List preserved images in the current session.',\n responses: jsonApiResponses(\n Type.Object({\n sessionId: Type.String(),\n items: Type.Array(Type.Object(Metadata)),\n nextCursor: Type.Union([Type.String(), Type.Null()]),\n }),\n ),\n },\n {\n id: 'readImage',\n scope: 'session',\n basePath: 'images',\n path: '/artifact',\n method: 'GET',\n authentication: 'owner',\n description: 'Read a verified preserved session image by artifact or tool call identity.',\n responses: jsonApiResponses(Artifact),\n },\n ],\n sockets: [],\n dynamic: [],\n});\nexport default apiContracts;\n"],"mappings":";;;AAGA,MAAM,WAAW;CAAE,IAAI,KAAK,OAAO;CAAG,WAAW,KAAK,OAAO;CAAG,YAAY,KAAK,QAAQ;AAAE;AAC3F,MAAM,WAAW,KAAK,OAAO;CAC3B,GAAG;CACH,WAAW,KAAK,OAAO;CACvB,cAAc,KAAK,OAAO;CAC1B,cAAc,KAAK,OAAO;CAC1B,MAAM,KAAK,OAAO;CAClB,UAAU,KAAK,QAAQ,WAAW;
|
|
1
|
+
{"version":3,"file":"apiContracts.mjs","names":[],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\nconst Metadata = { id: Type.String(), createdAt: Type.String(), byteLength: Type.Integer() };\nconst Artifact = Type.Object({\n ...Metadata,\n sessionId: Type.String(),\n originalPath: Type.String(),\n sourceSha256: Type.String(),\n data: Type.String(),\n mimeType: Type.Union([Type.Literal('image/png'), Type.Literal('image/gif')]),\n offset: Type.Optional(Type.Integer({ minimum: 0 })),\n});\n\nexport const apiContracts = defineApiContract({\n version: 1,\n http: [\n {\n id: 'promoteImage',\n scope: 'session',\n basePath: 'images',\n path: '/promote',\n method: 'POST',\n authentication: 'owner',\n description: 'Copy one preserved session image into session artifacts for Author.',\n body: {\n contentType: 'application/json',\n required: true,\n schema: Type.Object(\n { id: Type.String({ pattern: '^[A-Za-z0-9_-]{1,128}$' }) },\n { additionalProperties: false },\n ),\n },\n responses: jsonApiResponses(Type.Object({ sessionId: Type.String(), path: Type.String() })),\n },\n {\n id: 'listImages',\n scope: 'session',\n basePath: 'images',\n path: '/artifacts',\n method: 'GET',\n authentication: 'owner',\n description: 'List preserved images in the current session.',\n responses: jsonApiResponses(\n Type.Object({\n sessionId: Type.String(),\n items: Type.Array(Type.Object(Metadata)),\n nextCursor: Type.Union([Type.String(), Type.Null()]),\n }),\n ),\n },\n {\n id: 'readImage',\n scope: 'session',\n basePath: 'images',\n path: '/artifact',\n method: 'GET',\n authentication: 'owner',\n description: 'Read a verified preserved session image by artifact or tool call identity.',\n responses: jsonApiResponses(Artifact),\n },\n ],\n sockets: [],\n dynamic: [],\n});\nexport default apiContracts;\n"],"mappings":";;;AAGA,MAAM,WAAW;CAAE,IAAI,KAAK,OAAO;CAAG,WAAW,KAAK,OAAO;CAAG,YAAY,KAAK,QAAQ;AAAE;AAC3F,MAAM,WAAW,KAAK,OAAO;CAC3B,GAAG;CACH,WAAW,KAAK,OAAO;CACvB,cAAc,KAAK,OAAO;CAC1B,cAAc,KAAK,OAAO;CAC1B,MAAM,KAAK,OAAO;CAClB,UAAU,KAAK,MAAM,CAAC,KAAK,QAAQ,WAAW,GAAG,KAAK,QAAQ,WAAW,CAAC,CAAC;CAC3E,QAAQ,KAAK,SAAS,KAAK,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC;AACpD,CAAC;AAED,MAAa,eAAe,kBAAkB;CAC5C,SAAS;CACT,MAAM;EACJ;GACE,IAAI;GACJ,OAAO;GACP,UAAU;GACV,MAAM;GACN,QAAQ;GACR,gBAAgB;GAChB,aAAa;GACb,MAAM;IACJ,aAAa;IACb,UAAU;IACV,QAAQ,KAAK,OACX,EAAE,IAAI,KAAK,OAAO,EAAE,SAAS,yBAAyB,CAAC,EAAE,GACzD,EAAE,sBAAsB,MAAM,CAChC;GACF;GACA,WAAW,iBAAiB,KAAK,OAAO;IAAE,WAAW,KAAK,OAAO;IAAG,MAAM,KAAK,OAAO;GAAE,CAAC,CAAC;EAC5F;EACA;GACE,IAAI;GACJ,OAAO;GACP,UAAU;GACV,MAAM;GACN,QAAQ;GACR,gBAAgB;GAChB,aAAa;GACb,WAAW,iBACT,KAAK,OAAO;IACV,WAAW,KAAK,OAAO;IACvB,OAAO,KAAK,MAAM,KAAK,OAAO,QAAQ,CAAC;IACvC,YAAY,KAAK,MAAM,CAAC,KAAK,OAAO,GAAG,KAAK,KAAK,CAAC,CAAC;GACrD,CAAC,CACH;EACF;EACA;GACE,IAAI;GACJ,OAAO;GACP,UAAU;GACV,MAAM;GACN,QAAQ;GACR,gBAAgB;GAChB,aAAa;GACb,WAAW,iBAAiB,QAAQ;EACtC;CACF;CACA,SAAS,CAAC;CACV,SAAS,CAAC;AACZ,CAAC"}
|
|
@@ -15,8 +15,8 @@ const SHA256_HEX = /^[0-9a-f]{64}$/;
|
|
|
15
15
|
function imagegenToolView({ args, result }) {
|
|
16
16
|
const prompt = typeof args.prompt === "string" ? args.prompt : "";
|
|
17
17
|
const editing = Array.isArray(args.referenced_image_paths) && args.referenced_image_paths.length > 0 || typeof args.num_last_images_to_include === "number";
|
|
18
|
-
const image = result?.content.find((block) => block !== null && typeof block === "object" && "type" in block && block.type === "image" && "mimeType" in block && block.mimeType === "image/png" && "data" in block && typeof block.data === "string");
|
|
19
|
-
const src = image ? `data
|
|
18
|
+
const image = result?.content.find((block) => block !== null && typeof block === "object" && "type" in block && block.type === "image" && "mimeType" in block && (block.mimeType === "image/png" || block.mimeType === "image/gif") && "data" in block && typeof block.data === "string");
|
|
19
|
+
const src = image ? `data:${image.mimeType};base64,${image.data}` : void 0;
|
|
20
20
|
const details = result?.details;
|
|
21
21
|
return {
|
|
22
22
|
prompt,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native.mjs","names":["fontOf","PoNativeTheme","useEffect","useState","StyleSheet","ImageTile","id","label","src","FittedImageProps","accessibilityLabel","maxHeight","FittedImage","aspectRatio","setAspectRatio","live","Image","getSize","width","height","uri","styles","fittedImage","ImageViewerViewProps","image","ImageViewerView","viewer","sans","heading","error","dim","create","theme","fontFamily","fontSize","base","lineHeight","uni__dependencies","color","colors","red","gap","spacing","padding","hi","lg","fontWeight","semibold","borderRadius","md","styles","ToolMessageRenderProps","fontOf","MessageItem","MessageItemBody","MessageItemHeader","MessageItemStatus","resultTextLines","toolTone","PoNativeTheme","StyleSheet","imagegenToolView","imageViewerTab","FittedImage","IMAGE_MAX_HEIGHT","ImagegenToolMessage","props","result","output","running","isError","sessionId","view","label","prompt","expanded","styles","summary","sans","faint","editing","src","openTransientTab","id","toolCallId","inputImages","length","inputs","dim","map","input","index","String","path","mono","text","sha256","line","error","create","theme","flex","flexDirection","alignItems","gap","spacing","minWidth","uni__dependencies","fontFamily","fontSize","base","lineHeight","color","colors","flexShrink","sm","red","toolImagegen"],"sources":["../../src/extensions/workspaces/sessions/(frontend)/tool/_lib/imagegenToolView.ts","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/SessionImagesView.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/SessionImages.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/ImagegenToolMessage.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/imagegen.native.tsx","../../generated/native.ts"],"sourcesContent":["import type { ToolMessageRenderProps } from '@agimon-ai/po-core/web';\n\n/** The tool accepts at most five references, so a longer list is not this tool's. */\nconst MAX_INPUT_IMAGES = 5;\nconst SHA256_HEX = /^[0-9a-f]{64}$/;\nexport function imagegenToolView({ args, result }: Pick<ToolMessageRenderProps, 'args' | 'result'>) {\n const prompt = typeof args.prompt === 'string' ? args.prompt : '';\n const editing =\n (Array.isArray(args.referenced_image_paths) && args.referenced_image_paths.length > 0) ||\n typeof args.num_last_images_to_include === 'number';\n // Only inline PNG results from this tool, never a URL supplied in details.\n const image = result?.content.find(\n (block): block is { type: 'image'; data: string; mimeType: 'image/png' } =>\n block !== null &&\n typeof block === 'object' &&\n 'type' in block &&\n block.type === 'image' &&\n 'mimeType' in block &&\n block.mimeType === 'image/png' &&\n 'data' in block &&\n typeof block.data === 'string',\n );\n const src = image ? `data:image/png;base64,${image.data}` : undefined;\n const details = result?.details;\n const inlineOnly =\n details !== null &&\n typeof details === 'object' &&\n 'saveWarning' in details &&\n typeof details.saveWarning === 'string';\n const inputImages =\n details !== null && typeof details === 'object' && 'inputImages' in details && Array.isArray(details.inputImages)\n ? details.inputImages\n .filter(\n (entry): entry is { path: string; sha256: string } =>\n entry !== null &&\n typeof entry === 'object' &&\n typeof entry.path === 'string' &&\n typeof entry.sha256 === 'string' &&\n SHA256_HEX.test(entry.sha256),\n )\n .slice(0, MAX_INPUT_IMAGES)\n .map(({ path, sha256 }) => ({ path, sha256 }))\n : [];\n return { prompt, editing, src, inlineOnly, inputImages };\n}\n","import { fontOf } from '@agimon-ai/po-native-components';\nimport type { PoNativeTheme } from '@agimon-ai/po-web-components/nativeTheme';\nimport { useEffect, useState } from 'react';\nimport { Image, ScrollView, Text } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nexport interface ImageTile {\n id: string;\n label: string;\n /** A `data:image/png;base64,` URI, never a remote URL. */\n src?: string;\n}\n\nexport interface FittedImageProps {\n src: string;\n accessibilityLabel?: string;\n maxHeight?: number;\n}\n\n/** Full width at the PNG's own aspect ratio, so it is never letterboxed. */\nexport function FittedImage({ src, accessibilityLabel, maxHeight }: FittedImageProps) {\n const [aspectRatio, setAspectRatio] = useState(1);\n useEffect(() => {\n let live = true;\n // getSize works on React Native and React Native Web alike; onLoad's event shape differs.\n // An unreadable image keeps the square and shows nothing worse than before.\n Image.getSize(src, (width, height) => {\n if (live && width > 0 && height > 0) setAspectRatio(width / height);\n });\n return () => {\n live = false;\n };\n }, [src]);\n return (\n <Image\n source={{ uri: src }}\n accessibilityLabel={accessibilityLabel}\n resizeMode=\"contain\"\n style={[styles.fittedImage, { aspectRatio, maxHeight }]}\n />\n );\n}\n\nexport interface ImageViewerViewProps {\n image: ImageTile;\n}\n\n/** The full image with its title. Read only: native has no Author feedback panel yet. */\nexport function ImageViewerView({ image }: ImageViewerViewProps) {\n return (\n <ScrollView testID=\"session-image-viewer\" contentContainerStyle={styles.viewer}>\n <Text accessibilityRole=\"header\" numberOfLines={1} style={[styles.sans, styles.heading]}>\n {image.label}\n </Text>\n {image.src ? (\n <FittedImage src={image.src} accessibilityLabel={image.label} />\n ) : (\n <Text accessibilityRole=\"alert\" style={[styles.sans, styles.error]}>\n This image could not be loaded.\n </Text>\n )}\n <Text style={[styles.sans, styles.dim]}>Original image, read only.</Text>\n </ScrollView>\n );\n}\n\nconst styles = StyleSheet.create((theme: PoNativeTheme) => ({\n sans: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n },\n dim: { color: theme.colors.dim },\n error: { color: theme.colors.red },\n viewer: { gap: theme.spacing(3), padding: theme.spacing(4) },\n heading: {\n color: theme.colors.hi,\n fontSize: theme.fontSize.lg,\n lineHeight: theme.lineHeight.lg,\n fontWeight: theme.fontWeight.semibold,\n },\n fittedImage: { width: '100%', borderRadius: theme.borderRadius.md },\n}));\n","import type { WebPluginSlotProps } from '@agimon-ai/po-core/native';\n\nimport { ImageViewerView, type ImageTile } from './SessionImagesView.native';\n\ntype TransientTab = Parameters<WebPluginSlotProps['openTransientTab']>[0];\n\n/**\n * The viewer shows bytes the caller already holds: the tool result's inline PNG.\n *\n * ponytail: no durable-artifact lookup, because the web only needs it for the\n * Author feedback panel and no native package contributes one. Resolve it as\n * the web's transcriptImageTab does once native Author feedback exists.\n */\nexport function imageViewerTab(sessionId: string, image: ImageTile): TransientTab {\n return {\n id: `image-gen-image-${encodeURIComponent(image.id)}`,\n label: image.label,\n panel: (props) => (props.sessionId === sessionId ? <ImageViewerView image={image} /> : null),\n };\n}\n","import type { ToolMessageRenderProps } from '@agimon-ai/po-core/native';\nimport {\n fontOf,\n MessageItem,\n MessageItemBody,\n MessageItemHeader,\n MessageItemStatus,\n resultTextLines,\n toolTone,\n} from '@agimon-ai/po-native-components';\nimport type { PoNativeTheme } from '@agimon-ai/po-web-components/nativeTheme';\nimport { Pressable, Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { imagegenToolView } from '../_lib/imagegenToolView';\nimport { imageViewerTab } from './SessionImages.native';\nimport { FittedImage } from './SessionImagesView.native';\n\n/** Tallest the image gets in the card; the web caps it at 24rem. */\nconst IMAGE_MAX_HEIGHT = 384;\n\n/**\n * The imagegen tool's timeline item on native, as the web's ImagegenToolMessage:\n * the prompt in the header and, expanded by default, the image full width with\n * the tool's own lines under it. Tapping the image opens it full size.\n */\nexport function ImagegenToolMessage(props: ToolMessageRenderProps) {\n const { result, output, running, isError, sessionId } = props;\n const view = imagegenToolView(props);\n const label = view.prompt || 'Generated image';\n return (\n <MessageItem tone={toolTone({ running, isError })} expandable defaultExpanded>\n {({ expanded }) => (\n <>\n <MessageItemHeader title=\"imagegen\">\n <View testID=\"tool-call-imagegen\" style={styles.summary}>\n <Text numberOfLines={1} style={[styles.sans, styles.prompt]}>\n {view.prompt}\n </Text>\n <Text style={[styles.sans, styles.faint]}>{view.editing ? 'edit' : 'generate'}</Text>\n </View>\n </MessageItemHeader>\n {expanded ? (\n <MessageItemBody testID=\"tool-result-imagegen\">\n {running ? <MessageItemStatus tone=\"running\">creating image</MessageItemStatus> : null}\n {isError ? <MessageItemStatus tone=\"error\">failed</MessageItemStatus> : null}\n {!isError && view.src ? (\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel={`Open ${label}`}\n disabled={sessionId === null}\n onPress={() => {\n if (sessionId !== null && view.src)\n props.openTransientTab(\n imageViewerTab(sessionId, { id: `transcript-${props.toolCallId}`, label, src: view.src }),\n );\n }}\n >\n <FittedImage src={view.src} maxHeight={IMAGE_MAX_HEIGHT} />\n </Pressable>\n ) : null}\n {view.inputImages.length > 0 ? (\n <View accessibilityLabel=\"Input images\" style={styles.inputs}>\n <Text style={[styles.sans, styles.dim]}>Input images</Text>\n {view.inputImages.map((input, index) => (\n <View key={`${String(index)}-${input.path}`}>\n <Text selectable style={[styles.mono, styles.text]}>\n {input.path}\n </Text>\n <Text selectable style={[styles.mono, styles.dim]}>\n sha256 {input.sha256}\n </Text>\n </View>\n ))}\n </View>\n ) : null}\n {resultTextLines(result, output).map((line, index) => (\n <Text\n key={`${String(index)}-${line}`}\n selectable\n style={[styles.sans, isError ? styles.error : styles.dim]}\n >\n {line}\n </Text>\n ))}\n </MessageItemBody>\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 sans: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n },\n prompt: { flex: 1, minWidth: 0, color: theme.colors.text },\n faint: { flexShrink: 0, color: theme.colors.faint },\n mono: {\n fontFamily: fontOf(theme.fontFamily.mono),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n },\n inputs: { gap: theme.spacing(1) },\n text: { color: theme.colors.text },\n dim: { color: theme.colors.dim },\n error: { color: theme.colors.red },\n}));\n","import { defineToolRenderer } from '@agimon-ai/po-core/native';\n\nimport { ImagegenToolMessage } from './_components/ImagegenToolMessage.native';\n\nexport default defineToolRenderer({ message: ImagegenToolMessage });\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineNativePlugin, type WebPluginContributions } from '@agimon-ai/po-core/native';\n\nimport toolImagegen from '../src/extensions/workspaces/sessions/(frontend)/tool/imagegen.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: 'image-gen',\n packageName: '@agimon-ai/po-image-gen',\n session: {\n get toolRenderers(): WebPluginContributions['toolRenderers'] { return [via({ tools: ['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,IAAY;CAAE,GAAG;CAAU,GAAI;AAAiB;AAEzE,MAAa,eAAe,mBAAmB;CAC7C,IAAI;CACJ,aAAa;CACb,SAAS,EACP,IAAI,gBAAyD;EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,EAAE,GAAGU,uBAAY,CAAC;CAAG,EACtH;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"native.mjs","names":["fontOf","PoNativeTheme","useEffect","useState","StyleSheet","ImageTile","id","label","src","FittedImageProps","accessibilityLabel","maxHeight","FittedImage","aspectRatio","setAspectRatio","live","Image","getSize","width","height","uri","styles","fittedImage","ImageViewerViewProps","image","ImageViewerView","viewer","sans","heading","error","dim","create","theme","fontFamily","fontSize","base","lineHeight","uni__dependencies","color","colors","red","gap","spacing","padding","hi","lg","fontWeight","semibold","borderRadius","md","styles","ToolMessageRenderProps","fontOf","MessageItem","MessageItemBody","MessageItemHeader","MessageItemStatus","resultTextLines","toolTone","PoNativeTheme","StyleSheet","imagegenToolView","imageViewerTab","FittedImage","IMAGE_MAX_HEIGHT","ImagegenToolMessage","props","result","output","running","isError","sessionId","view","label","prompt","expanded","styles","summary","sans","faint","editing","src","openTransientTab","id","toolCallId","inputImages","length","inputs","dim","map","input","index","String","path","mono","text","sha256","line","error","create","theme","flex","flexDirection","alignItems","gap","spacing","minWidth","uni__dependencies","fontFamily","fontSize","base","lineHeight","color","colors","flexShrink","sm","red","toolImagegen"],"sources":["../../src/extensions/workspaces/sessions/(frontend)/tool/_lib/imagegenToolView.ts","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/SessionImagesView.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/SessionImages.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/ImagegenToolMessage.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/imagegen.native.tsx","../../generated/native.ts"],"sourcesContent":["import type { ToolMessageRenderProps } from '@agimon-ai/po-core/web';\n\n/** The tool accepts at most five references, so a longer list is not this tool's. */\nconst MAX_INPUT_IMAGES = 5;\nconst SHA256_HEX = /^[0-9a-f]{64}$/;\nexport function imagegenToolView({ args, result }: Pick<ToolMessageRenderProps, 'args' | 'result'>) {\n const prompt = typeof args.prompt === 'string' ? args.prompt : '';\n const editing =\n (Array.isArray(args.referenced_image_paths) && args.referenced_image_paths.length > 0) ||\n typeof args.num_last_images_to_include === 'number';\n // Only supported inline image results from this tool, never a URL supplied in details.\n const image = result?.content.find(\n (block): block is { type: 'image'; data: string; mimeType: 'image/png' | 'image/gif' } =>\n block !== null &&\n typeof block === 'object' &&\n 'type' in block &&\n block.type === 'image' &&\n 'mimeType' in block &&\n (block.mimeType === 'image/png' || block.mimeType === 'image/gif') &&\n 'data' in block &&\n typeof block.data === 'string',\n );\n const src = image ? `data:${image.mimeType};base64,${image.data}` : undefined;\n const details = result?.details;\n const inlineOnly =\n details !== null &&\n typeof details === 'object' &&\n 'saveWarning' in details &&\n typeof details.saveWarning === 'string';\n const inputImages =\n details !== null && typeof details === 'object' && 'inputImages' in details && Array.isArray(details.inputImages)\n ? details.inputImages\n .filter(\n (entry): entry is { path: string; sha256: string } =>\n entry !== null &&\n typeof entry === 'object' &&\n typeof entry.path === 'string' &&\n typeof entry.sha256 === 'string' &&\n SHA256_HEX.test(entry.sha256),\n )\n .slice(0, MAX_INPUT_IMAGES)\n .map(({ path, sha256 }) => ({ path, sha256 }))\n : [];\n return { prompt, editing, src, inlineOnly, inputImages };\n}\n","import { fontOf } from '@agimon-ai/po-native-components';\nimport type { PoNativeTheme } from '@agimon-ai/po-web-components/nativeTheme';\nimport { useEffect, useState } from 'react';\nimport { Image, ScrollView, Text } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nexport interface ImageTile {\n id: string;\n label: string;\n /** A `data:image/png;base64,` URI, never a remote URL. */\n src?: string;\n}\n\nexport interface FittedImageProps {\n src: string;\n accessibilityLabel?: string;\n maxHeight?: number;\n}\n\n/** Full width at the PNG's own aspect ratio, so it is never letterboxed. */\nexport function FittedImage({ src, accessibilityLabel, maxHeight }: FittedImageProps) {\n const [aspectRatio, setAspectRatio] = useState(1);\n useEffect(() => {\n let live = true;\n // getSize works on React Native and React Native Web alike; onLoad's event shape differs.\n // An unreadable image keeps the square and shows nothing worse than before.\n Image.getSize(src, (width, height) => {\n if (live && width > 0 && height > 0) setAspectRatio(width / height);\n });\n return () => {\n live = false;\n };\n }, [src]);\n return (\n <Image\n source={{ uri: src }}\n accessibilityLabel={accessibilityLabel}\n resizeMode=\"contain\"\n style={[styles.fittedImage, { aspectRatio, maxHeight }]}\n />\n );\n}\n\nexport interface ImageViewerViewProps {\n image: ImageTile;\n}\n\n/** The full image with its title. Read only: native has no Author feedback panel yet. */\nexport function ImageViewerView({ image }: ImageViewerViewProps) {\n return (\n <ScrollView testID=\"session-image-viewer\" contentContainerStyle={styles.viewer}>\n <Text accessibilityRole=\"header\" numberOfLines={1} style={[styles.sans, styles.heading]}>\n {image.label}\n </Text>\n {image.src ? (\n <FittedImage src={image.src} accessibilityLabel={image.label} />\n ) : (\n <Text accessibilityRole=\"alert\" style={[styles.sans, styles.error]}>\n This image could not be loaded.\n </Text>\n )}\n <Text style={[styles.sans, styles.dim]}>Original image, read only.</Text>\n </ScrollView>\n );\n}\n\nconst styles = StyleSheet.create((theme: PoNativeTheme) => ({\n sans: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n },\n dim: { color: theme.colors.dim },\n error: { color: theme.colors.red },\n viewer: { gap: theme.spacing(3), padding: theme.spacing(4) },\n heading: {\n color: theme.colors.hi,\n fontSize: theme.fontSize.lg,\n lineHeight: theme.lineHeight.lg,\n fontWeight: theme.fontWeight.semibold,\n },\n fittedImage: { width: '100%', borderRadius: theme.borderRadius.md },\n}));\n","import type { WebPluginSlotProps } from '@agimon-ai/po-core/native';\n\nimport { ImageViewerView, type ImageTile } from './SessionImagesView.native';\n\ntype TransientTab = Parameters<WebPluginSlotProps['openTransientTab']>[0];\n\n/**\n * The viewer shows bytes the caller already holds: the tool result's inline PNG.\n *\n * ponytail: no durable-artifact lookup, because the web only needs it for the\n * Author feedback panel and no native package contributes one. Resolve it as\n * the web's transcriptImageTab does once native Author feedback exists.\n */\nexport function imageViewerTab(sessionId: string, image: ImageTile): TransientTab {\n return {\n id: `image-gen-image-${encodeURIComponent(image.id)}`,\n label: image.label,\n panel: (props) => (props.sessionId === sessionId ? <ImageViewerView image={image} /> : null),\n };\n}\n","import type { ToolMessageRenderProps } from '@agimon-ai/po-core/native';\nimport {\n fontOf,\n MessageItem,\n MessageItemBody,\n MessageItemHeader,\n MessageItemStatus,\n resultTextLines,\n toolTone,\n} from '@agimon-ai/po-native-components';\nimport type { PoNativeTheme } from '@agimon-ai/po-web-components/nativeTheme';\nimport { Pressable, Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { imagegenToolView } from '../_lib/imagegenToolView';\nimport { imageViewerTab } from './SessionImages.native';\nimport { FittedImage } from './SessionImagesView.native';\n\n/** Tallest the image gets in the card; the web caps it at 24rem. */\nconst IMAGE_MAX_HEIGHT = 384;\n\n/**\n * The imagegen tool's timeline item on native, as the web's ImagegenToolMessage:\n * the prompt in the header and, expanded by default, the image full width with\n * the tool's own lines under it. Tapping the image opens it full size.\n */\nexport function ImagegenToolMessage(props: ToolMessageRenderProps) {\n const { result, output, running, isError, sessionId } = props;\n const view = imagegenToolView(props);\n const label = view.prompt || 'Generated image';\n return (\n <MessageItem tone={toolTone({ running, isError })} expandable defaultExpanded>\n {({ expanded }) => (\n <>\n <MessageItemHeader title=\"imagegen\">\n <View testID=\"tool-call-imagegen\" style={styles.summary}>\n <Text numberOfLines={1} style={[styles.sans, styles.prompt]}>\n {view.prompt}\n </Text>\n <Text style={[styles.sans, styles.faint]}>{view.editing ? 'edit' : 'generate'}</Text>\n </View>\n </MessageItemHeader>\n {expanded ? (\n <MessageItemBody testID=\"tool-result-imagegen\">\n {running ? <MessageItemStatus tone=\"running\">creating image</MessageItemStatus> : null}\n {isError ? <MessageItemStatus tone=\"error\">failed</MessageItemStatus> : null}\n {!isError && view.src ? (\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel={`Open ${label}`}\n disabled={sessionId === null}\n onPress={() => {\n if (sessionId !== null && view.src)\n props.openTransientTab(\n imageViewerTab(sessionId, { id: `transcript-${props.toolCallId}`, label, src: view.src }),\n );\n }}\n >\n <FittedImage src={view.src} maxHeight={IMAGE_MAX_HEIGHT} />\n </Pressable>\n ) : null}\n {view.inputImages.length > 0 ? (\n <View accessibilityLabel=\"Input images\" style={styles.inputs}>\n <Text style={[styles.sans, styles.dim]}>Input images</Text>\n {view.inputImages.map((input, index) => (\n <View key={`${String(index)}-${input.path}`}>\n <Text selectable style={[styles.mono, styles.text]}>\n {input.path}\n </Text>\n <Text selectable style={[styles.mono, styles.dim]}>\n sha256 {input.sha256}\n </Text>\n </View>\n ))}\n </View>\n ) : null}\n {resultTextLines(result, output).map((line, index) => (\n <Text\n key={`${String(index)}-${line}`}\n selectable\n style={[styles.sans, isError ? styles.error : styles.dim]}\n >\n {line}\n </Text>\n ))}\n </MessageItemBody>\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 sans: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n },\n prompt: { flex: 1, minWidth: 0, color: theme.colors.text },\n faint: { flexShrink: 0, color: theme.colors.faint },\n mono: {\n fontFamily: fontOf(theme.fontFamily.mono),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n },\n inputs: { gap: theme.spacing(1) },\n text: { color: theme.colors.text },\n dim: { color: theme.colors.dim },\n error: { color: theme.colors.red },\n}));\n","import { defineToolRenderer } from '@agimon-ai/po-core/native';\n\nimport { ImagegenToolMessage } from './_components/ImagegenToolMessage.native';\n\nexport default defineToolRenderer({ message: ImagegenToolMessage });\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineNativePlugin, type WebPluginContributions } from '@agimon-ai/po-core/native';\n\nimport toolImagegen from '../src/extensions/workspaces/sessions/(frontend)/tool/imagegen.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: 'image-gen',\n packageName: '@agimon-ai/po-image-gen',\n session: {\n get toolRenderers(): WebPluginContributions['toolRenderers'] { return [via({ tools: ['imagegen'] }, toolImagegen)]; },\n },\n});\n"],"mappings":";;;;;;;;;;;;AAGA,MAAM,mBAAmB;AACzB,MAAM,aAAa;AACnB,SAAgB,iBAAiB,EAAE,MAAM,UAA2D;CAClG,MAAM,SAAS,OAAO,KAAK,WAAW,WAAW,KAAK,SAAS;CAC/D,MAAM,UACH,MAAM,QAAQ,KAAK,sBAAsB,KAAK,KAAK,uBAAuB,SAAS,KACpF,OAAO,KAAK,+BAA+B;CAE7C,MAAM,QAAQ,QAAQ,QAAQ,MAC3B,UACC,UAAU,QACV,OAAO,UAAU,YACjB,UAAU,SACV,MAAM,SAAS,WACf,cAAc,UACb,MAAM,aAAa,eAAe,MAAM,aAAa,gBACtD,UAAU,SACV,OAAO,MAAM,SAAS,QAC1B;CACA,MAAM,MAAM,QAAQ,QAAQ,MAAM,SAAS,UAAU,MAAM,SAAS,KAAA;CACpE,MAAM,UAAU,QAAQ;CAoBxB,OAAO;EAAE;EAAQ;EAAS;EAAK,YAlB7B,YAAY,QACZ,OAAO,YAAY,YACnB,iBAAiB,WACjB,OAAO,QAAQ,gBAAgB;EAeU,aAbzC,YAAY,QAAQ,OAAO,YAAY,YAAY,iBAAiB,WAAW,MAAM,QAAQ,QAAQ,WAAW,IAC5G,QAAQ,YACL,QACE,UACC,UAAU,QACV,OAAO,UAAU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ACjC;CACApB,QAAQ;EAAEiB,KAAKJ,MAAMK,QAAQ,CAAC;EAACE,mBAAA,CAAA,CAAA;CAAC;CAChCZ,MAAM;EAAEiB,OAAOZ,MAAMa,OAAOlB;EAAIY,mBAAA,CAAA,CAAA;CAAC;CACjCnB,KAAK;EAAEwB,OAAOZ,MAAMa,OAAOzB;EAAGmB,mBAAA,CAAA,CAAA;CAAC;CAC/BT,OAAO;EAAEc,OAAOZ,MAAMa,OAAOG;EAAGT,mBAAA,CAAA,CAAA;CAAC;AACnC,EAAE;;;AC3GF,IAAA,0BAAe,mBAAmB,EAAE,SAAS,oBAAoB,CAAC;;;ACClE,MAAM,OAAU,UAAmC,UAChD,UAAU,KAAA,IAAY,KAAA,IAAY;CAAE,GAAG;CAAU,GAAI;AAAiB;AAEzE,MAAa,eAAe,mBAAmB;CAC7C,IAAI;CACJ,aAAa;CACb,SAAS,EACP,IAAI,gBAAyD;EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,EAAE,GAAGU,uBAAY,CAAC;CAAG,EACtH;AACF,CAAC"}
|
|
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
const require_imagegenTool = require("../imagegenTool-
|
|
5
|
+
const require_imagegenTool = require("../imagegenTool-CpXZxFEy.cjs");
|
|
6
6
|
let node_crypto = require("node:crypto");
|
|
7
7
|
let node_path = require("node:path");
|
|
8
8
|
let _agimon_ai_po_core_serverPlugin = require("@agimon-ai/po-core/serverPlugin");
|
|
@@ -15,6 +15,8 @@ let typebox_value = require("typebox/value");
|
|
|
15
15
|
const DECLARATIONS = `interface ImagegenOptions {
|
|
16
16
|
/** Ask for a transparent background. */
|
|
17
17
|
transparentBackground?: boolean;
|
|
18
|
+
/** Simple looping GIF, 2 to 16 frames and 20 to 2000 ms per frame. {} defaults to 9 frames at 200 ms. Omit for PNG. */
|
|
19
|
+
gif?: { frameCount?: number; frameDurationMs?: number };
|
|
18
20
|
/**
|
|
19
21
|
* Up to five absolute local PNG, JPEG, WebP or GIF paths to edit; a GIF is sent as its first frame.
|
|
20
22
|
* Omit both reference options for a new image.
|
|
@@ -28,9 +30,13 @@ const DECLARATIONS = `interface ImagegenOptions {
|
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
interface ImagegenResult {
|
|
31
|
-
/** Where the PNG was saved. Absent when saving
|
|
33
|
+
/** Where the PNG or animated GIF was saved. Absent when saving or generation failed. */
|
|
32
34
|
savedPath?: string;
|
|
33
35
|
saveWarning?: string;
|
|
36
|
+
/** A generation failure, not a save warning. Do not retry quota failures. */
|
|
37
|
+
error?: string;
|
|
38
|
+
requestId?: string;
|
|
39
|
+
failure?: { kind: 'usage_limit_exceeded'; limitId: 'image_gen' | 'imagegen_premium'; resetsAt?: number };
|
|
34
40
|
/** Why the model did not get to see the image, such as this exec already returning 4 images or 5 MB. */
|
|
35
41
|
modelVisibilityWarning?: string;
|
|
36
42
|
}
|
|
@@ -38,7 +44,7 @@ interface ImagegenResult {
|
|
|
38
44
|
declare const imagegen: {
|
|
39
45
|
/**
|
|
40
46
|
* Generates or edits one image with the person's ChatGPT sign-in. The cockpit shows it as an image card, and
|
|
41
|
-
* the model sees
|
|
47
|
+
* the model sees a still preview with this exec's output; no image() call is needed.
|
|
42
48
|
*/
|
|
43
49
|
generate(prompt: string, options?: ImagegenOptions): Promise<ImagegenResult>;
|
|
44
50
|
};`;
|
|
@@ -46,7 +52,7 @@ declare const imagegen: {
|
|
|
46
52
|
function createImagegenNamespace(options) {
|
|
47
53
|
return {
|
|
48
54
|
name: "imagegen",
|
|
49
|
-
summary: "Generate or edit
|
|
55
|
+
summary: "Generate or edit PNGs and animated GIFs with the ChatGPT sign-in. Returns a saved path, a save warning, or a structured quota error; shows a still preview to the model.",
|
|
50
56
|
declarations: DECLARATIONS,
|
|
51
57
|
bind(run) {
|
|
52
58
|
if (run.sessionId !== options.context.sessionId) throw new Error("Imagegen namespace belongs to another session.");
|
|
@@ -61,6 +67,7 @@ function createImagegenNamespace(options) {
|
|
|
61
67
|
const params = {
|
|
62
68
|
prompt,
|
|
63
69
|
...extra.transparentBackground === void 0 ? {} : { transparent_background: extra.transparentBackground },
|
|
70
|
+
...extra.gif === void 0 ? {} : { gif: typeof extra.gif === "object" && extra.gif !== null && !Array.isArray(extra.gif) ? Object.fromEntries(Object.entries(extra.gif).map(([key, value]) => [key === "frameCount" ? "frame_count" : key === "frameDurationMs" ? "frame_duration_ms" : key, value])) : extra.gif },
|
|
64
71
|
...extra.referencedImagePaths === void 0 ? {} : { referenced_image_paths: extra.referencedImagePaths },
|
|
65
72
|
...extra.numLastImagesToInclude === void 0 ? {} : { num_last_images_to_include: extra.numLastImagesToInclude }
|
|
66
73
|
};
|
|
@@ -79,7 +86,7 @@ function createImagegenNamespace(options) {
|
|
|
79
86
|
result = await options.tool.execute(`codemode-${(0, node_crypto.randomUUID)()}`, params, run.signal, void 0, options.context);
|
|
80
87
|
run.record?.({
|
|
81
88
|
...record,
|
|
82
|
-
ok:
|
|
89
|
+
ok: !result.isError,
|
|
83
90
|
ms: Date.now() - started,
|
|
84
91
|
result
|
|
85
92
|
});
|
|
@@ -93,18 +100,33 @@ function createImagegenNamespace(options) {
|
|
|
93
100
|
});
|
|
94
101
|
throw error;
|
|
95
102
|
}
|
|
96
|
-
const image = result.content.find((block) => block.type === "image");
|
|
97
|
-
const shown = image && (run.emitImage?.({
|
|
98
|
-
data: image.data,
|
|
99
|
-
mimeType: image.mimeType
|
|
100
|
-
}) ?? {
|
|
101
|
-
emitted: false,
|
|
102
|
-
warning: "This host does not show code-mode images to the model."
|
|
103
|
-
});
|
|
104
103
|
const details = result.details;
|
|
104
|
+
if (result.isError) return {
|
|
105
|
+
error: result.content.filter((block) => block.type === "text").map((block) => block.text).join("\n"),
|
|
106
|
+
...details.requestId ? { requestId: details.requestId } : {},
|
|
107
|
+
...details.failure ? { failure: { ...details.failure } } : {}
|
|
108
|
+
};
|
|
109
|
+
const image = result.content.find((block) => block.type === "image");
|
|
110
|
+
let warning;
|
|
111
|
+
if (image) try {
|
|
112
|
+
const preview = image.mimeType === "image/gif" ? {
|
|
113
|
+
data: require_imagegenTool.gifToPng(Buffer.from(image.data, "base64")).toString("base64"),
|
|
114
|
+
mimeType: "image/png"
|
|
115
|
+
} : {
|
|
116
|
+
data: image.data,
|
|
117
|
+
mimeType: image.mimeType
|
|
118
|
+
};
|
|
119
|
+
const shown = run.emitImage?.(preview) ?? {
|
|
120
|
+
emitted: false,
|
|
121
|
+
warning: "This host does not show code-mode images to the model."
|
|
122
|
+
};
|
|
123
|
+
if (!shown.emitted) warning = shown.warning;
|
|
124
|
+
} catch {
|
|
125
|
+
warning = "The generated image is available, but its model preview could not be displayed.";
|
|
126
|
+
}
|
|
105
127
|
return {
|
|
106
128
|
...details.savedPath ? { savedPath: details.savedPath } : { saveWarning: details.saveWarning },
|
|
107
|
-
...
|
|
129
|
+
...warning ? { modelVisibilityWarning: warning } : {}
|
|
108
130
|
};
|
|
109
131
|
};
|
|
110
132
|
const members = Object.create(null);
|
|
@@ -156,17 +178,23 @@ function createImagePromotion(home, sessionId, environment, binding, mountSignal
|
|
|
156
178
|
await safeDirectory(root);
|
|
157
179
|
const candidates = environment.PO_SESSION_TEMP_DIR ? [(0, node_path.join)(environment.PO_SESSION_TEMP_DIR, "images"), (0, node_path.join)(home, "generated_images", sessionId)] : [(0, node_path.join)(home, "generated_images", sessionId)];
|
|
158
180
|
let bytes;
|
|
181
|
+
let extension = "png";
|
|
159
182
|
let label = "image";
|
|
160
183
|
for (const candidate of candidates) {
|
|
161
184
|
const info = await fs.fileInfo(candidate, context);
|
|
162
185
|
if (!info.ok && info.error.code === "not_found") continue;
|
|
163
186
|
(0, _agimon_ai_po_core_platform.getOrThrow)(info);
|
|
164
187
|
await safeDirectory(candidate);
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
188
|
+
for (const suffix of ["png", "gif"]) {
|
|
189
|
+
const path = (0, node_path.join)(candidate, `${id}.${suffix}`);
|
|
190
|
+
const leaf = await fs.fileInfo(path, context);
|
|
191
|
+
if (!leaf.ok && leaf.error.code === "not_found") continue;
|
|
192
|
+
(0, _agimon_ai_po_core_platform.getOrThrow)(leaf);
|
|
193
|
+
bytes = await readImage(fs, path, context, suffix);
|
|
194
|
+
extension = suffix;
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
if (!bytes) continue;
|
|
170
198
|
const labelPath = (0, node_path.join)(candidate, `${id}.txt`);
|
|
171
199
|
if ((await fs.fileInfo(labelPath, context)).ok) {
|
|
172
200
|
const text = new TextDecoder().decode(await (0, _agimon_ai_po_core_platform.readBoundedFile)(fs, labelPath, 64, context));
|
|
@@ -175,7 +203,7 @@ function createImagePromotion(home, sessionId, environment, binding, mountSignal
|
|
|
175
203
|
break;
|
|
176
204
|
}
|
|
177
205
|
if (!bytes) throw new Error("Image not found.");
|
|
178
|
-
const name = `${label}-${(0, node_crypto.createHash)("sha256").update(bytes).digest("hex").slice(0, 12)}
|
|
206
|
+
const name = `${label}-${(0, node_crypto.createHash)("sha256").update(bytes).digest("hex").slice(0, 12)}.${extension}`;
|
|
179
207
|
const directory = (0, node_path.join)(root, "generated-images");
|
|
180
208
|
check();
|
|
181
209
|
await safeDirectory(root);
|
|
@@ -188,7 +216,7 @@ function createImagePromotion(home, sessionId, environment, binding, mountSignal
|
|
|
188
216
|
const info = await fs.fileInfo(target, context);
|
|
189
217
|
if (!info.ok && info.error.code === "not_found") return false;
|
|
190
218
|
(0, _agimon_ai_po_core_platform.getOrThrow)(info);
|
|
191
|
-
const existing = await
|
|
219
|
+
const existing = await readImage(fs, target, context, extension);
|
|
192
220
|
if (!Buffer.from(existing).equals(Buffer.from(bytes))) throw new Error("Artifact filename is already in use.");
|
|
193
221
|
return true;
|
|
194
222
|
};
|
|
@@ -222,16 +250,16 @@ function createImagePromotion(home, sessionId, environment, binding, mountSignal
|
|
|
222
250
|
return run;
|
|
223
251
|
};
|
|
224
252
|
}
|
|
225
|
-
async function
|
|
253
|
+
async function readImage(fs, path, context, extension) {
|
|
226
254
|
if ((0, _agimon_ai_po_core_platform.getOrThrow)(await fs.fileInfo(path, context)).kind !== "file" || (0, _agimon_ai_po_core_platform.getOrThrow)(await fs.canonicalPath(path, context)) !== (0, node_path.resolve)(path)) throw new Error("Unsafe image file.");
|
|
227
255
|
const reader = (0, _agimon_ai_po_core_platform.getOrThrow)(await fs.openBinaryReader(path, { noFollow: true }, context));
|
|
228
256
|
try {
|
|
229
257
|
const before = (0, _agimon_ai_po_core_platform.getOrThrow)(await reader.info(context));
|
|
230
|
-
if (before.size < PNG_SIGNATURE.length || before.size > 20971520) throw new Error("Image exceeds the size limit or is empty.");
|
|
258
|
+
if (before.size < (extension === "gif" ? 6 : PNG_SIGNATURE.length) || before.size > 20971520) throw new Error("Image exceeds the size limit or is empty.");
|
|
231
259
|
const data = (0, _agimon_ai_po_core_platform.getOrThrow)(await reader.read(0, before.size, context));
|
|
232
260
|
const after = (0, _agimon_ai_po_core_platform.getOrThrow)(await reader.info(context));
|
|
233
261
|
if (data.length !== before.size || before.size !== after.size || before.mtimeMs !== after.mtimeMs) throw new Error("Image changed during access.");
|
|
234
|
-
if (!Buffer.from(data.subarray(0, PNG_SIGNATURE.length)).equals(PNG_SIGNATURE)) throw new Error("Image is not a PNG.");
|
|
262
|
+
if (extension === "gif" ? !require_imagegenTool.isGif(data) : !Buffer.from(data.subarray(0, PNG_SIGNATURE.length)).equals(PNG_SIGNATURE)) throw new Error(extension === "gif" ? "Image is not a GIF." : "Image is not a PNG.");
|
|
235
263
|
return data;
|
|
236
264
|
} finally {
|
|
237
265
|
await reader.close(_agimon_ai_po_core_platform.BACKGROUND_CONTEXT);
|