@oai404iao/pi-codex-imagegen 0.1.0-alpha.1 → 0.1.0

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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Alpha bootstrap candidate; initial npm publication is still pending.
4
4
 
5
- Peer floor: Pi 0.84.2; tested against 0.84.2 and 0.85.1.
5
+ Peer floor: Pi 0.85.1; tested against 0.85.1.
6
6
 
7
7
  `/image-gen` jobs are cancelled when the session is replaced or closed.
8
8
  Late authentication/results cannot notify the replacement session or initiate
@@ -11,6 +11,9 @@ rolled back; cancellation is not a guarantee of avoiding provider charges.
11
11
 
12
12
  Installs `image_generation`, background image commands, image persistence and
13
13
  presentation. Depends only on `pi-codex-runtime`, not core, web-search or the bundle.
14
+ When global `config.json.imageGeneration` is `false`, none of those generation
15
+ surfaces are registered. The gate also blocks late/manual standalone and direct
16
+ fallback execution before authentication or network I/O.
14
17
  Catalog-supported standalone profiles call Images generation/edit endpoints with
15
18
  Pi authentication. Hosted profiles need core unless the existing
16
19
  `directImageApiFallback` option was explicitly enabled.
package/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { default } from "./src/index.js";
2
+ export * from "./src/index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oai404iao/pi-codex-imagegen",
3
- "version": "0.1.0-alpha.1",
3
+ "version": "0.1.0",
4
4
  "private": false,
5
5
  "description": "Unpublished pi-codex-imagegen workspace for the staged Codex split",
6
6
  "type": "module",
@@ -24,13 +24,13 @@
24
24
  },
25
25
  "pi": {
26
26
  "extensions": [
27
- "./src/index.ts"
27
+ "./index.ts"
28
28
  ]
29
29
  },
30
30
  "peerDependencies": {
31
- "@earendil-works/pi-ai": ">=0.84.2",
32
- "@earendil-works/pi-coding-agent": ">=0.84.2",
33
- "@earendil-works/pi-tui": ">=0.84.2",
31
+ "@earendil-works/pi-ai": ">=0.85.1",
32
+ "@earendil-works/pi-coding-agent": ">=0.85.1",
33
+ "@earendil-works/pi-tui": ">=0.85.1",
34
34
  "typebox": "*"
35
35
  },
36
36
  "peerDependenciesMeta": {
@@ -45,7 +45,7 @@
45
45
  }
46
46
  },
47
47
  "dependencies": {
48
- "@oai404iao/pi-codex-runtime": "0.1.0-alpha.1"
48
+ "@oai404iao/pi-codex-runtime": "0.1.0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@earendil-works/pi-ai": "0.85.1",
@@ -66,6 +66,7 @@
66
66
  "registry": "https://registry.npmjs.org/"
67
67
  },
68
68
  "files": [
69
+ "index.ts",
69
70
  "src/",
70
71
  "LICENSE",
71
72
  "LICENSES/",
@@ -76,5 +77,5 @@
76
77
  "engines": {
77
78
  "node": ">=22.19.0"
78
79
  },
79
- "gitHead": "32ba01f3c08b7fd63d09e9b2373cf081c4525533"
80
+ "gitHead": "88cb6f56447d88b71232cd764ca5b29251341d23"
80
81
  }
package/src/index.ts CHANGED
@@ -11,6 +11,8 @@ import { createImageDisplay } from "./tools/image-generation/display.js";
11
11
  export default function codexImagegen(pi: ExtensionAPI): void {
12
12
  const broker = ensureCodexServices(pi);
13
13
  if (!broker.claim("package:imagegen")) return;
14
+ const settings = loadSettings();
15
+ if (!settings.enabled || !settings.imageGeneration) return;
14
16
  const display = createImageDisplay(pi);
15
17
  broker.addPresentation("image_generation", {
16
18
  clear: display.clear,
@@ -29,5 +31,5 @@ export default function codexImagegen(pi: ExtensionAPI): void {
29
31
  hasProviderRuntime: () => broker.coreEnabled,
30
32
  }) as never);
31
33
  });
32
- if (loadSettings().enabled) registerBackgroundImageGenerationCommand(pi);
34
+ registerBackgroundImageGenerationCommand(pi);
33
35
  }
@@ -51,6 +51,7 @@ async function urlToBase64(url: string, signal?: AbortSignal): Promise<string> {
51
51
  }
52
52
 
53
53
  export async function directImageGeneration(input: ImageGenerationInput, cwd: string, settings: CodexMinimalToolsSettings, signal?: AbortSignal) {
54
+ if (!settings.imageGeneration) throw new Error("Image generation is disabled by the global imageGeneration setting.");
54
55
  if (!settings.directImageApiFallback) throw new Error("Direct Images API fallback is disabled. Use native openai or openai-codex handling, or enable directImageApiFallback.");
55
56
  const apiKey = process.env.OPENAI_API_KEY;
56
57
  if (!apiKey) throw new Error("OPENAI_API_KEY is required for direct image_generation fallback.");
@@ -174,6 +175,7 @@ export async function standaloneImageGeneration(
174
175
  const model = ctx.model;
175
176
  if (!model || !ctx.modelRegistry) throw new Error("No active model is available for standalone image generation.");
176
177
  if (!settings.enabled) throw new Error("pi-codex-minimal-tools is disabled.");
178
+ if (!settings.imageGeneration) throw new Error("Image generation is disabled by the global setting or current model profile.");
177
179
  if (!input.prompt?.trim()) throw new Error("A prompt is required for standalone image generation.");
178
180
  if (input.num_last_images_to_include !== undefined && input.referenced_image_paths?.length) {
179
181
  throw new Error("Provide only one of referenced_image_paths or num_last_images_to_include.");
@@ -264,6 +266,9 @@ export function createImageGenerationToolDefinition(options: {
264
266
  const resolvedSettings = "modelProfile" in settings
265
267
  ? settings as ResolvedCodexModelSettings
266
268
  : loadModelSettings(ctx.model, cwd, settings);
269
+ if (!resolvedSettings.imageGeneration) {
270
+ throw new Error("Image generation is disabled by the global setting or current model profile.");
271
+ }
267
272
  if (resolvedSettings.imageGenerationImplementation === "standalone") {
268
273
  const sessionId = ctx.sessionManager?.getSessionId?.();
269
274
  return standaloneImageGeneration(params, ctx, resolvedSettings, signal, {