@agimon-ai/po-image-gen 0.0.0-alpha.2 → 0.0.0-alpha.200

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/LICENSE CHANGED
@@ -1,13 +1,102 @@
1
- MIT License
1
+ # Functional Source License, Version 1.1, MIT Future License
2
2
 
3
- Copyright (c) 2026 Vuong Ngo
3
+ ## Abbreviation
4
4
 
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
5
+ FSL-1.1-MIT
6
+
7
+ ## Notice
8
+
9
+ Copyright 2026 Agimon Pty Ltd
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+
15
+ The party offering the Software under these Terms and Conditions.
16
+
17
+ ### The Software
18
+
19
+ The "Software" is each version of the software that we make available under
20
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
21
+ Conditions with the Software.
22
+
23
+ ### License Grant
24
+
25
+ Subject to your compliance with this License Grant and the Patents,
26
+ Redistribution and Trademark clauses below, we hereby grant you the right to
27
+ use, copy, modify, create derivative works, publicly perform, publicly display
28
+ and redistribute the Software for any Permitted Purpose identified below.
29
+
30
+ ### Permitted Purpose
31
+
32
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33
+ means making the Software available to others in a commercial product or
34
+ service that:
35
+
36
+ 1. substitutes for the Software;
37
+
38
+ 2. substitutes for any other product or service we offer using the Software
39
+ that exists as of the date we make the Software available; or
40
+
41
+ 3. offers the same or substantially similar functionality as the Software.
42
+
43
+ Permitted Purposes specifically include using the Software:
44
+
45
+ 1. for your internal use and access;
46
+
47
+ 2. for non-commercial education;
48
+
49
+ 3. for non-commercial research; and
50
+
51
+ 4. in connection with professional services that you provide to a licensee
52
+ using the Software in accordance with these Terms and Conditions.
53
+
54
+ ### Patents
55
+
56
+ To the extent your use for a Permitted Purpose would necessarily infringe our
57
+ patents, the license grant above includes a license under our patents. If you
58
+ make a claim against any party that the Software infringes or contributes to
59
+ the infringement of any patent, then your patent license to the Software ends
60
+ immediately.
61
+
62
+ ### Redistribution
63
+
64
+ The Terms and Conditions apply to all copies, modifications and derivatives of
65
+ the Software.
66
+
67
+ If you redistribute any copies, modifications or derivatives of the Software,
68
+ you must include a copy of or a link to these Terms and Conditions and not
69
+ remove any copyright notices provided in or with the Software.
70
+
71
+ ### Disclaimer
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
74
+ IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
75
+ PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
76
+
77
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
78
+ SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
79
+ EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80
+
81
+ ### Trademarks
82
+
83
+ Except for displaying the License Details and identifying us as the origin of
84
+ the Software, you have no right under these Terms and Conditions to use our
85
+ trademarks, trade names, service marks or product names.
86
+
87
+ ## Grant of Future License
88
+
89
+ We hereby irrevocably grant you an additional license to use the Software under
90
+ the MIT license that is effective on the second anniversary of the date we make
91
+ the Software available. On or after that date, you may use the Software under
92
+ the MIT license, in which case the following will apply:
93
+
94
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
95
+ this software and associated documentation files (the "Software"), to deal in
96
+ the Software without restriction, including without limitation the rights to
97
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
98
+ of the Software, and to permit persons to whom the Software is furnished to do
99
+ so, subject to the following conditions:
11
100
 
12
101
  The above copyright notice and this permission notice shall be included in all
13
102
  copies or substantial portions of the Software.
package/README.md CHANGED
@@ -4,7 +4,7 @@ Generate and edit images using the ChatGPT subscription sign-in that Po features
4
4
 
5
5
  ## Activation
6
6
 
7
- This is an optional `image-gen` layer. Register `@agimon-ai/po-image-gen` under a layer's `packages` in your modes config, then include that layer in your chosen major mode. The repository's local `copilot` mode includes it for development; published starter configs do not.
7
+ This is an optional `image-gen` layer. Register `@agimon-ai/po-image-gen` under a layer's `packages` in your presets config, then include that layer in your chosen preset. The repository's local `copilot` preset includes it for development; published starter configs do not.
8
8
 
9
9
  Sign in to **ChatGPT for Po features** under Settings > Providers (or with `/login`). Image entitlement and quota depend on your account. This uses the same private ChatGPT image endpoints as Codex, which may change without notice.
10
10
 
@@ -14,15 +14,24 @@ 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
- - `referenced_image_paths`: optional list of up to five absolute local PNG, JPEG, or WebP file paths. Omit for a new image; supply for an edit. Each file is limited to 20 MiB, with 50 MiB total.
17
+ - `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
+ - `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.
18
19
 
19
- The result includes an inline PNG and a save hint. Files are created exclusively at `<poHome>/generated_images/<session>/<call>.png`; existing files are never overwritten. A save failure returns the image with a warning. Output is limited to 32 MiB.
20
+ These match Codex's `image_gen.imagegen` arguments. Codex fixes model, quality and size rather than exposing them, and so does Po.
20
21
 
21
- Quota, account denial, and network failures are returned without retrying. Cancelling propagates the abort signal. History references, model/quality/size selection, and MCP are not included.
22
+ The result includes an inline PNG and a save hint. Files are created exclusively at `<poHome>/generated_images/<session>/<call>.png`; existing files are never overwritten. A save failure returns the image with a warning. Output is limited to 32 MiB. Details record each local input file as `{ path, sha256 }` of the bytes read, and the card lists them.
23
+
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 one, the result carries `modelVisibilityWarning` and the image stays saved.
25
+
26
+ 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. Other failures name the HTTP status and the backend's reason when it gives one. Cancelling propagates the abort signal. Model/quality/size selection and MCP are not included.
27
+
28
+ ## Code mode
29
+
30
+ When code mode is bound, the package registers the `imagegen` namespace (`imagegen.generate(prompt, { transparentBackground?, 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.
22
31
 
23
32
  ## Structure and lifecycle
24
33
 
25
- The generated server entry discovers the routed `imagegen.server.ts` tool. The web entry discovers its matching `imagegen.web.tsx` renderer. Tool execution uses the host's provider-neutral `imageGeneration` capability; extensions never receive tokens or headers. The host guards readiness and disposal, and refreshes existing OAuth credentials per call.
34
+ The generated server entry discovers the routed `root.server.ts`, which builds the tool and registers the code-mode namespace, and the `imagegen.server.ts` tool that reads it. The web entry discovers its matching `imagegen.web.tsx` renderer. Tool execution uses the host's provider-neutral `imageGeneration` capability; extensions never receive tokens or headers. The host guards readiness and disposal, and refreshes existing OAuth credentials per call.
26
35
 
27
36
  ## Development
28
37
 
@@ -16,33 +16,55 @@ 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.Literal("image/png"),
20
+ offset: typebox.Type.Optional(typebox.Type.Integer({ minimum: 0 }))
20
21
  });
21
22
  const apiContracts = (0, _agimon_ai_po_core_apiContracts.defineApiContract)({
22
23
  version: 1,
23
- http: [{
24
- id: "listImages",
25
- scope: "session",
26
- basePath: "images",
27
- path: "/artifacts",
28
- method: "GET",
29
- authentication: "owner",
30
- description: "List preserved images in the current session.",
31
- responses: (0, _agimon_ai_po_core_apiContracts.jsonApiResponses)(typebox.Type.Object({
32
- sessionId: typebox.Type.String(),
33
- items: typebox.Type.Array(typebox.Type.Object(Metadata)),
34
- nextCursor: typebox.Type.Union([typebox.Type.String(), typebox.Type.Null()])
35
- }))
36
- }, {
37
- id: "readImage",
38
- scope: "session",
39
- basePath: "images",
40
- path: "/artifact",
41
- method: "GET",
42
- authentication: "owner",
43
- description: "Read a verified preserved session image by artifact or tool call identity.",
44
- responses: (0, _agimon_ai_po_core_apiContracts.jsonApiResponses)(Artifact)
45
- }],
24
+ http: [
25
+ {
26
+ id: "promoteImage",
27
+ scope: "session",
28
+ basePath: "images",
29
+ path: "/promote",
30
+ method: "POST",
31
+ authentication: "owner",
32
+ description: "Copy one preserved session image into session artifacts for Author.",
33
+ body: {
34
+ contentType: "application/json",
35
+ required: true,
36
+ schema: typebox.Type.Object({ id: typebox.Type.String({ pattern: "^[A-Za-z0-9_-]{1,128}$" }) }, { additionalProperties: false })
37
+ },
38
+ responses: (0, _agimon_ai_po_core_apiContracts.jsonApiResponses)(typebox.Type.Object({
39
+ sessionId: typebox.Type.String(),
40
+ path: typebox.Type.String()
41
+ }))
42
+ },
43
+ {
44
+ id: "listImages",
45
+ scope: "session",
46
+ basePath: "images",
47
+ path: "/artifacts",
48
+ method: "GET",
49
+ authentication: "owner",
50
+ description: "List preserved images in the current session.",
51
+ responses: (0, _agimon_ai_po_core_apiContracts.jsonApiResponses)(typebox.Type.Object({
52
+ sessionId: typebox.Type.String(),
53
+ items: typebox.Type.Array(typebox.Type.Object(Metadata)),
54
+ nextCursor: typebox.Type.Union([typebox.Type.String(), typebox.Type.Null()])
55
+ }))
56
+ },
57
+ {
58
+ id: "readImage",
59
+ scope: "session",
60
+ basePath: "images",
61
+ path: "/artifact",
62
+ method: "GET",
63
+ authentication: "owner",
64
+ description: "Read a verified preserved session image by artifact or tool call identity.",
65
+ responses: (0, _agimon_ai_po_core_apiContracts.jsonApiResponses)(Artifact)
66
+ }
67
+ ],
46
68
  sockets: [],
47
69
  dynamic: []
48
70
  });
@@ -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});\n\nexport const apiContracts = defineApiContract({\n version: 1,\n http: [\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;AACpC,CAAC;AAED,MAAa,gBAAA,GAAeC,gCAAAA,kBAAAA,CAAkB;CAC5C,SAAS;CACT,MAAM,CACJ;EACE,IAAI;EACJ,OAAO;EACP,UAAU;EACV,MAAM;EACN,QAAQ;EACR,gBAAgB;EAChB,aAAa;EACb,YAAA,GAAWC,gCAAAA,iBAAAA,CACTF,QAAAA,KAAK,OAAO;GACV,WAAWA,QAAAA,KAAK,OAAO;GACvB,OAAOA,QAAAA,KAAK,MAAMA,QAAAA,KAAK,OAAO,QAAQ,CAAC;GACvC,YAAYA,QAAAA,KAAK,MAAM,CAACA,QAAAA,KAAK,OAAO,GAAGA,QAAAA,KAAK,KAAK,CAAC,CAAC;EACrD,CAAC,CACH;CACF,GACA;EACE,IAAI;EACJ,OAAO;EACP,UAAU;EACV,MAAM;EACN,QAAQ;EACR,gBAAgB;EAChB,aAAa;EACb,YAAA,GAAWE,gCAAAA,iBAAAA,CAAiB,QAAQ;CACtC,CACF;CACA,SAAS,CAAC;CACV,SAAS,CAAC;AACZ,CAAC"}
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;CAClC,QAAQA,QAAAA,KAAK,SAASA,QAAAA,KAAK,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC;AACpD,CAAC;AAED,MAAa,gBAAA,GAAeC,gCAAAA,kBAAAA,CAAkB;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,QAAQD,QAAAA,KAAK,OACX,EAAE,IAAIA,QAAAA,KAAK,OAAO,EAAE,SAAS,yBAAyB,CAAC,EAAE,GACzD,EAAE,sBAAsB,MAAM,CAChC;GACF;GACA,YAAA,GAAWE,gCAAAA,iBAAAA,CAAiBF,QAAAA,KAAK,OAAO;IAAE,WAAWA,QAAAA,KAAK,OAAO;IAAG,MAAMA,QAAAA,KAAK,OAAO;GAAE,CAAC,CAAC;EAC5F;EACA;GACE,IAAI;GACJ,OAAO;GACP,UAAU;GACV,MAAM;GACN,QAAQ;GACR,gBAAgB;GAChB,aAAa;GACb,YAAA,GAAWE,gCAAAA,iBAAAA,CACTF,QAAAA,KAAK,OAAO;IACV,WAAWA,QAAAA,KAAK,OAAO;IACvB,OAAOA,QAAAA,KAAK,MAAMA,QAAAA,KAAK,OAAO,QAAQ,CAAC;IACvC,YAAYA,QAAAA,KAAK,MAAM,CAACA,QAAAA,KAAK,OAAO,GAAGA,QAAAA,KAAK,KAAK,CAAC,CAAC;GACrD,CAAC,CACH;EACF;EACA;GACE,IAAI;GACJ,OAAO;GACP,UAAU;GACV,MAAM;GACN,QAAQ;GACR,gBAAgB;GAChB,aAAa;GACb,YAAA,GAAWE,gCAAAA,iBAAAA,CAAiB,QAAQ;EACtC;CACF;CACA,SAAS,CAAC;CACV,SAAS,CAAC;AACZ,CAAC"}
@@ -5,7 +5,7 @@ export declare const apiContracts: {
5
5
  schemas?: Record<string, boolean | object> | undefined;
6
6
  http: {
7
7
  id: string;
8
- scope: "global" | "session" | "workspace";
8
+ scope: "host" | "session" | "workspace";
9
9
  basePath?: string | undefined;
10
10
  path: string;
11
11
  method: "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT";
@@ -33,7 +33,7 @@ export declare const apiContracts: {
33
33
  }[];
34
34
  sockets: {
35
35
  id: string;
36
- scope: "global" | "session" | "workspace";
36
+ scope: "host" | "session" | "workspace";
37
37
  description: string;
38
38
  availability?: string | undefined;
39
39
  service: string;
@@ -1 +1 @@
1
- {"version":3,"file":"apiContracts.d.mts","names":[],"sources":["../src/schemas/apiContracts.ts"],"mappings":";qBAaa"}
1
+ {"version":3,"file":"apiContracts.d.mts","names":[],"sources":["../src/schemas/apiContracts.ts"],"mappings":";qBAca"}
@@ -12,33 +12,55 @@ 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.Literal("image/png"),
16
+ offset: Type.Optional(Type.Integer({ minimum: 0 }))
16
17
  });
17
18
  const apiContracts = defineApiContract({
18
19
  version: 1,
19
- http: [{
20
- id: "listImages",
21
- scope: "session",
22
- basePath: "images",
23
- path: "/artifacts",
24
- method: "GET",
25
- authentication: "owner",
26
- description: "List preserved images in the current session.",
27
- responses: jsonApiResponses(Type.Object({
28
- sessionId: Type.String(),
29
- items: Type.Array(Type.Object(Metadata)),
30
- nextCursor: Type.Union([Type.String(), Type.Null()])
31
- }))
32
- }, {
33
- id: "readImage",
34
- scope: "session",
35
- basePath: "images",
36
- path: "/artifact",
37
- method: "GET",
38
- authentication: "owner",
39
- description: "Read a verified preserved session image by artifact or tool call identity.",
40
- responses: jsonApiResponses(Artifact)
41
- }],
20
+ http: [
21
+ {
22
+ id: "promoteImage",
23
+ scope: "session",
24
+ basePath: "images",
25
+ path: "/promote",
26
+ method: "POST",
27
+ authentication: "owner",
28
+ description: "Copy one preserved session image into session artifacts for Author.",
29
+ body: {
30
+ contentType: "application/json",
31
+ required: true,
32
+ schema: Type.Object({ id: Type.String({ pattern: "^[A-Za-z0-9_-]{1,128}$" }) }, { additionalProperties: false })
33
+ },
34
+ responses: jsonApiResponses(Type.Object({
35
+ sessionId: Type.String(),
36
+ path: Type.String()
37
+ }))
38
+ },
39
+ {
40
+ id: "listImages",
41
+ scope: "session",
42
+ basePath: "images",
43
+ path: "/artifacts",
44
+ method: "GET",
45
+ authentication: "owner",
46
+ description: "List preserved images in the current session.",
47
+ responses: jsonApiResponses(Type.Object({
48
+ sessionId: Type.String(),
49
+ items: Type.Array(Type.Object(Metadata)),
50
+ nextCursor: Type.Union([Type.String(), Type.Null()])
51
+ }))
52
+ },
53
+ {
54
+ id: "readImage",
55
+ scope: "session",
56
+ basePath: "images",
57
+ path: "/artifact",
58
+ method: "GET",
59
+ authentication: "owner",
60
+ description: "Read a verified preserved session image by artifact or tool call identity.",
61
+ responses: jsonApiResponses(Artifact)
62
+ }
63
+ ],
42
64
  sockets: [],
43
65
  dynamic: []
44
66
  });
@@ -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});\n\nexport const apiContracts = defineApiContract({\n version: 1,\n http: [\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;AACpC,CAAC;AAED,MAAa,eAAe,kBAAkB;CAC5C,SAAS;CACT,MAAM,CACJ;EACE,IAAI;EACJ,OAAO;EACP,UAAU;EACV,MAAM;EACN,QAAQ;EACR,gBAAgB;EAChB,aAAa;EACb,WAAW,iBACT,KAAK,OAAO;GACV,WAAW,KAAK,OAAO;GACvB,OAAO,KAAK,MAAM,KAAK,OAAO,QAAQ,CAAC;GACvC,YAAY,KAAK,MAAM,CAAC,KAAK,OAAO,GAAG,KAAK,KAAK,CAAC,CAAC;EACrD,CAAC,CACH;CACF,GACA;EACE,IAAI;EACJ,OAAO;EACP,UAAU;EACV,MAAM;EACN,QAAQ;EACR,gBAAgB;EAChB,aAAa;EACb,WAAW,iBAAiB,QAAQ;CACtC,CACF;CACA,SAAS,CAAC;CACV,SAAS,CAAC;AACZ,CAAC"}
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;CAClC,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"}
@@ -0,0 +1,288 @@
1
+ import { defineNativePlugin, defineToolRenderer, useT } from "@agimon-ai/po-core/native";
2
+ import { View } from "react-native-unistyles/components/native/View";
3
+ import { Text } from "react-native-unistyles/components/native/Text";
4
+ import { Pressable } from "react-native-unistyles/components/native/Pressable";
5
+ import { MessageItem, MessageItemBody, MessageItemHeader, MessageItemStatus, fontOf, resultTextLines, toolTone } from "@agimon-ai/po-native-components";
6
+ import { StyleSheet } from "react-native-unistyles";
7
+ import { ScrollView } from "react-native-unistyles/components/native/ScrollView";
8
+ import { Image } from "react-native-unistyles/components/native/Image";
9
+ import { useEffect, useState } from "react";
10
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
11
+ //#region src/extensions/workspaces/sessions/(frontend)/tool/_lib/imagegenToolView.ts
12
+ /** The tool accepts at most five references, so a longer list is not this tool's. */
13
+ const MAX_INPUT_IMAGES = 5;
14
+ const SHA256_HEX = /^[0-9a-f]{64}$/;
15
+ function imagegenToolView({ args, result }) {
16
+ const prompt = typeof args.prompt === "string" ? args.prompt : "";
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:image/png;base64,${image.data}` : void 0;
20
+ const details = result?.details;
21
+ return {
22
+ prompt,
23
+ editing,
24
+ src,
25
+ inlineOnly: details !== null && typeof details === "object" && "saveWarning" in details && typeof details.saveWarning === "string",
26
+ inputImages: details !== null && typeof details === "object" && "inputImages" in details && Array.isArray(details.inputImages) ? details.inputImages.filter((entry) => entry !== null && typeof entry === "object" && typeof entry.path === "string" && typeof entry.sha256 === "string" && SHA256_HEX.test(entry.sha256)).slice(0, MAX_INPUT_IMAGES).map(({ path, sha256 }) => ({
27
+ path,
28
+ sha256
29
+ })) : []
30
+ };
31
+ }
32
+ //#endregion
33
+ //#region src/extensions/workspaces/sessions/(frontend)/tool/_components/SessionImagesView.native.tsx
34
+ /** Full width at the PNG's own aspect ratio, so it is never letterboxed. */
35
+ function FittedImage({ src, accessibilityLabel, maxHeight }) {
36
+ const [aspectRatio, setAspectRatio] = useState(1);
37
+ useEffect(() => {
38
+ let live = true;
39
+ Image.getSize(src, (width, height) => {
40
+ if (live && width > 0 && height > 0) setAspectRatio(width / height);
41
+ });
42
+ return () => {
43
+ live = false;
44
+ };
45
+ }, [src]);
46
+ return /* @__PURE__ */ jsx(Image, {
47
+ source: { uri: src },
48
+ accessibilityLabel,
49
+ resizeMode: "contain",
50
+ style: [styles$1.fittedImage, {
51
+ aspectRatio,
52
+ maxHeight
53
+ }]
54
+ });
55
+ }
56
+ /** The full image with its title. Read only: native has no Author feedback panel yet. */
57
+ function ImageViewerView({ image }) {
58
+ const t = useT();
59
+ return /* @__PURE__ */ jsxs(ScrollView, {
60
+ testID: "session-image-viewer",
61
+ contentContainerStyle: styles$1.viewer,
62
+ children: [
63
+ /* @__PURE__ */ jsx(Text, {
64
+ accessibilityRole: "header",
65
+ numberOfLines: 1,
66
+ style: [styles$1.sans, styles$1.heading],
67
+ children: image.label
68
+ }),
69
+ image.src ? /* @__PURE__ */ jsx(FittedImage, {
70
+ src: image.src,
71
+ accessibilityLabel: image.label
72
+ }) : /* @__PURE__ */ jsx(Text, {
73
+ accessibilityRole: "alert",
74
+ style: [styles$1.sans, styles$1.error],
75
+ children: t("imageGen.cannotLoad", "This image could not be loaded.")
76
+ }),
77
+ /* @__PURE__ */ jsx(Text, {
78
+ style: [styles$1.sans, styles$1.dim],
79
+ children: t("imageGen.original", "Original image, read only.")
80
+ })
81
+ ]
82
+ });
83
+ }
84
+ const styles$1 = StyleSheet.create((theme) => ({
85
+ sans: {
86
+ fontFamily: fontOf(theme.fontFamily.sans),
87
+ fontSize: theme.fontSize.base,
88
+ lineHeight: theme.lineHeight.base,
89
+ uni__dependencies: [0]
90
+ },
91
+ dim: {
92
+ color: theme.colors.dim,
93
+ uni__dependencies: [0]
94
+ },
95
+ error: {
96
+ color: theme.colors.red,
97
+ uni__dependencies: [0]
98
+ },
99
+ viewer: {
100
+ gap: theme.spacing(3),
101
+ padding: theme.spacing(4),
102
+ uni__dependencies: [0]
103
+ },
104
+ heading: {
105
+ color: theme.colors.hi,
106
+ fontSize: theme.fontSize.lg,
107
+ lineHeight: theme.lineHeight.lg,
108
+ fontWeight: theme.fontWeight.semibold,
109
+ uni__dependencies: [0]
110
+ },
111
+ fittedImage: {
112
+ width: "100%",
113
+ borderRadius: theme.borderRadius.md,
114
+ uni__dependencies: [0]
115
+ }
116
+ }));
117
+ //#endregion
118
+ //#region src/extensions/workspaces/sessions/(frontend)/tool/_components/SessionImages.native.tsx
119
+ /**
120
+ * The viewer shows bytes the caller already holds: the tool result's inline PNG.
121
+ *
122
+ * ponytail: no durable-artifact lookup, because the web only needs it for the
123
+ * Author feedback panel and no native package contributes one. Resolve it as
124
+ * the web's transcriptImageTab does once native Author feedback exists.
125
+ */
126
+ function imageViewerTab(sessionId, image) {
127
+ return {
128
+ id: `image-gen-image-${encodeURIComponent(image.id)}`,
129
+ label: image.label,
130
+ panel: (props) => props.sessionId === sessionId ? /* @__PURE__ */ jsx(ImageViewerView, { image }) : null
131
+ };
132
+ }
133
+ //#endregion
134
+ //#region src/extensions/workspaces/sessions/(frontend)/tool/_components/ImagegenToolMessage.native.tsx
135
+ /** Tallest the image gets in the card; the web caps it at 24rem. */
136
+ const IMAGE_MAX_HEIGHT = 384;
137
+ /**
138
+ * The imagegen tool's timeline item on native, as the web's ImagegenToolMessage:
139
+ * the prompt in the header and, expanded by default, the image full width with
140
+ * the tool's own lines under it. Tapping the image opens it full size.
141
+ */
142
+ function ImagegenToolMessage(props) {
143
+ const { result, output, running, isError, sessionId } = props;
144
+ const t = useT();
145
+ const view = imagegenToolView(props);
146
+ const label = view.prompt || t("imageGen.generated", "Generated image");
147
+ return /* @__PURE__ */ jsx(MessageItem, {
148
+ tone: toolTone({
149
+ running,
150
+ isError
151
+ }),
152
+ expandable: true,
153
+ defaultExpanded: true,
154
+ children: ({ expanded }) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(MessageItemHeader, {
155
+ title: "imagegen",
156
+ children: /* @__PURE__ */ jsxs(View, {
157
+ testID: "tool-call-imagegen",
158
+ style: styles.summary,
159
+ children: [/* @__PURE__ */ jsx(Text, {
160
+ numberOfLines: 1,
161
+ style: [styles.sans, styles.prompt],
162
+ children: view.prompt
163
+ }), /* @__PURE__ */ jsx(Text, {
164
+ style: [styles.sans, styles.faint],
165
+ children: view.editing ? t("imageGen.edit", "edit") : t("imageGen.generate", "generate")
166
+ })]
167
+ })
168
+ }), expanded ? /* @__PURE__ */ jsxs(MessageItemBody, {
169
+ testID: "tool-result-imagegen",
170
+ children: [
171
+ running ? /* @__PURE__ */ jsx(MessageItemStatus, {
172
+ tone: "running",
173
+ children: t("imageGen.creating", "creating image")
174
+ }) : null,
175
+ isError ? /* @__PURE__ */ jsx(MessageItemStatus, {
176
+ tone: "error",
177
+ children: t("imageGen.failed", "failed")
178
+ }) : null,
179
+ !isError && view.src ? /* @__PURE__ */ jsx(Pressable, {
180
+ accessibilityRole: "button",
181
+ accessibilityLabel: t("imageGen.open", "Open {name}", { name: label }),
182
+ disabled: sessionId === null,
183
+ onPress: () => {
184
+ if (sessionId !== null && view.src) props.openTransientTab(imageViewerTab(sessionId, {
185
+ id: `transcript-${props.toolCallId}`,
186
+ label,
187
+ src: view.src
188
+ }));
189
+ },
190
+ children: /* @__PURE__ */ jsx(FittedImage, {
191
+ src: view.src,
192
+ maxHeight: IMAGE_MAX_HEIGHT
193
+ })
194
+ }) : null,
195
+ view.inputImages.length > 0 ? /* @__PURE__ */ jsxs(View, {
196
+ accessibilityLabel: t("imageGen.inputs", "Input images"),
197
+ style: styles.inputs,
198
+ children: [/* @__PURE__ */ jsx(Text, {
199
+ style: [styles.sans, styles.dim],
200
+ children: t("imageGen.inputs", "Input images")
201
+ }), view.inputImages.map((input, index) => /* @__PURE__ */ jsxs(View, { children: [/* @__PURE__ */ jsx(Text, {
202
+ selectable: true,
203
+ style: [styles.mono, styles.text],
204
+ children: input.path
205
+ }), /* @__PURE__ */ jsxs(Text, {
206
+ selectable: true,
207
+ style: [styles.mono, styles.dim],
208
+ children: ["sha256 ", input.sha256]
209
+ })] }, `${String(index)}-${input.path}`))]
210
+ }) : null,
211
+ resultTextLines(result, output).map((line, index) => /* @__PURE__ */ jsx(Text, {
212
+ selectable: true,
213
+ style: [styles.sans, isError ? styles.error : styles.dim],
214
+ children: line
215
+ }, `${String(index)}-${line}`))
216
+ ]
217
+ }) : null] })
218
+ });
219
+ }
220
+ const styles = StyleSheet.create((theme) => ({
221
+ summary: {
222
+ flex: 1,
223
+ flexDirection: "row",
224
+ alignItems: "center",
225
+ gap: theme.spacing(2),
226
+ minWidth: 0,
227
+ uni__dependencies: [0]
228
+ },
229
+ sans: {
230
+ fontFamily: fontOf(theme.fontFamily.sans),
231
+ fontSize: theme.fontSize.base,
232
+ lineHeight: theme.lineHeight.base,
233
+ uni__dependencies: [0]
234
+ },
235
+ prompt: {
236
+ flex: 1,
237
+ minWidth: 0,
238
+ color: theme.colors.text,
239
+ uni__dependencies: [0]
240
+ },
241
+ faint: {
242
+ flexShrink: 0,
243
+ color: theme.colors.faint,
244
+ uni__dependencies: [0]
245
+ },
246
+ mono: {
247
+ fontFamily: fontOf(theme.fontFamily.mono),
248
+ fontSize: theme.fontSize.sm,
249
+ lineHeight: theme.lineHeight.sm,
250
+ uni__dependencies: [0]
251
+ },
252
+ inputs: {
253
+ gap: theme.spacing(1),
254
+ uni__dependencies: [0]
255
+ },
256
+ text: {
257
+ color: theme.colors.text,
258
+ uni__dependencies: [0]
259
+ },
260
+ dim: {
261
+ color: theme.colors.dim,
262
+ uni__dependencies: [0]
263
+ },
264
+ error: {
265
+ color: theme.colors.red,
266
+ uni__dependencies: [0]
267
+ }
268
+ }));
269
+ //#endregion
270
+ //#region src/extensions/workspaces/sessions/(frontend)/tool/imagegen.native.tsx
271
+ var imagegen_native_default = defineToolRenderer({ message: ImagegenToolMessage });
272
+ //#endregion
273
+ //#region generated/native.ts
274
+ const via = (identity, value) => value === void 0 ? void 0 : {
275
+ ...identity,
276
+ ...value
277
+ };
278
+ const nativePlugin = defineNativePlugin({
279
+ id: "image-gen",
280
+ packageName: "@agimon-ai/po-image-gen",
281
+ session: { get toolRenderers() {
282
+ return [via({ tools: ["imagegen"] }, imagegen_native_default)];
283
+ } }
284
+ });
285
+ //#endregion
286
+ export { nativePlugin };
287
+
288
+ //# sourceMappingURL=native.mjs.map