ima2-gen 1.1.21 → 1.1.23

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.
Files changed (214) hide show
  1. package/README.md +44 -7
  2. package/bin/commands/video.js +14 -0
  3. package/bin/ima2.js +14 -4
  4. package/bin/lib/platform.js +34 -5
  5. package/docs/README.ko.md +43 -2
  6. package/lib/agentQueueWorker.js +6 -0
  7. package/lib/agentRuntime.js +3 -2
  8. package/lib/atomicWrite.js +14 -0
  9. package/lib/grokImageAdapter.js +6 -0
  10. package/lib/grokProxyLauncher.js +5 -3
  11. package/lib/grokVideoAdapter.js +1 -1
  12. package/lib/grokVideoPlannerPrompt.js +10 -0
  13. package/lib/inflight.js +1 -1
  14. package/lib/oauthLauncher.js +5 -0
  15. package/lib/videoFrameExtract.js +3 -3
  16. package/package.json +5 -7
  17. package/routes/capabilities.js +13 -0
  18. package/routes/edit.js +2 -1
  19. package/routes/generate.js +32 -6
  20. package/routes/health.js +4 -3
  21. package/routes/multimode.js +2 -1
  22. package/routes/video.js +35 -3
  23. package/server.js +29 -2
  24. package/skills/ima2/SKILL.md +48 -6
  25. package/ui/dist/.vite/manifest.json +12 -12
  26. package/ui/dist/assets/{AgentWorkspace-B_hq9CLg.js → AgentWorkspace-C21zqdTZ.js} +1 -1
  27. package/ui/dist/assets/{CardNewsWorkspace-wD12J7qk.js → CardNewsWorkspace-BN-ga1lG.js} +1 -1
  28. package/ui/dist/assets/{NodeCanvas-CI_wuPMf.js → NodeCanvas-BbMa4IhI.js} +1 -1
  29. package/ui/dist/assets/{PromptBuilderPanel-CUTujJUV.js → PromptBuilderPanel-DRwBJRDQ.js} +1 -1
  30. package/ui/dist/assets/{PromptImportDialog-CUi66jPK.js → PromptImportDialog-Dp85kHCq.js} +2 -2
  31. package/ui/dist/assets/{PromptImportDiscoverySection-Cm3vrjY4.js → PromptImportDiscoverySection-BE8Q8MLD.js} +1 -1
  32. package/ui/dist/assets/{PromptImportFolderSection-DOtWTD9n.js → PromptImportFolderSection-PtH5x0sc.js} +1 -1
  33. package/ui/dist/assets/{PromptLibraryPanel-BMjQegRa.js → PromptLibraryPanel-FnM9tHI9.js} +2 -2
  34. package/ui/dist/assets/SettingsWorkspace-MARPGyBL.js +1 -0
  35. package/ui/dist/assets/index-BAFI6htx.js +42 -0
  36. package/ui/dist/assets/{index-31uVIdt4.js → index-BSXxr_Bt.js} +1 -1
  37. package/ui/dist/assets/index-DS-ADE7U.css +1 -0
  38. package/ui/dist/index.html +2 -2
  39. package/bin/commands/annotate.ts +0 -119
  40. package/bin/commands/cancel.ts +0 -48
  41. package/bin/commands/canvas-versions.ts +0 -80
  42. package/bin/commands/capabilities.ts +0 -110
  43. package/bin/commands/cardnews.ts +0 -249
  44. package/bin/commands/comfy.ts +0 -54
  45. package/bin/commands/config.ts +0 -186
  46. package/bin/commands/defaults.ts +0 -192
  47. package/bin/commands/doctor.ts +0 -202
  48. package/bin/commands/edit.ts +0 -150
  49. package/bin/commands/gen.ts +0 -214
  50. package/bin/commands/grok.ts +0 -90
  51. package/bin/commands/history.ts +0 -146
  52. package/bin/commands/ls.ts +0 -64
  53. package/bin/commands/metadata.ts +0 -39
  54. package/bin/commands/multimode.ts +0 -196
  55. package/bin/commands/node.ts +0 -166
  56. package/bin/commands/observability.ts +0 -176
  57. package/bin/commands/ping.ts +0 -31
  58. package/bin/commands/prompt-sub/build.ts +0 -101
  59. package/bin/commands/prompt.ts +0 -492
  60. package/bin/commands/ps.ts +0 -81
  61. package/bin/commands/session.ts +0 -266
  62. package/bin/commands/show.ts +0 -72
  63. package/bin/commands/skill.ts +0 -70
  64. package/bin/commands/video.ts +0 -442
  65. package/bin/ima2.ts +0 -430
  66. package/bin/lib/args.ts +0 -92
  67. package/bin/lib/browser-id.ts +0 -16
  68. package/bin/lib/client.ts +0 -122
  69. package/bin/lib/config-store.ts +0 -120
  70. package/bin/lib/destructive-confirm.ts +0 -19
  71. package/bin/lib/doctor-checks.ts +0 -91
  72. package/bin/lib/error-hints.ts +0 -23
  73. package/bin/lib/files.ts +0 -39
  74. package/bin/lib/output.ts +0 -73
  75. package/bin/lib/platform.ts +0 -99
  76. package/bin/lib/recover-output.ts +0 -139
  77. package/bin/lib/sse.ts +0 -73
  78. package/bin/lib/star-prompt.ts +0 -97
  79. package/bin/lib/storage-doctor.ts +0 -39
  80. package/bin/lib/ui-build.ts +0 -85
  81. package/config.ts +0 -354
  82. package/lib/agentCommandParser.ts +0 -69
  83. package/lib/agentGenerationPlanner.ts +0 -273
  84. package/lib/agentQuestionResponder.ts +0 -266
  85. package/lib/agentQueueStore.ts +0 -270
  86. package/lib/agentQueueWorker.ts +0 -89
  87. package/lib/agentRuntime.ts +0 -604
  88. package/lib/agentSettings.ts +0 -72
  89. package/lib/agentStore.ts +0 -422
  90. package/lib/agentStoreRows.ts +0 -136
  91. package/lib/agentTypes.ts +0 -154
  92. package/lib/apiCachePolicy.ts +0 -11
  93. package/lib/assetLifecycle.ts +0 -146
  94. package/lib/canvasVersionStore.ts +0 -223
  95. package/lib/capabilities.ts +0 -126
  96. package/lib/cardNewsGenerator.ts +0 -271
  97. package/lib/cardNewsJobStore.ts +0 -142
  98. package/lib/cardNewsManifestStore.ts +0 -154
  99. package/lib/cardNewsPlanner.ts +0 -236
  100. package/lib/cardNewsPlannerClient.ts +0 -155
  101. package/lib/cardNewsPlannerPrompt.ts +0 -62
  102. package/lib/cardNewsPlannerSchema.ts +0 -321
  103. package/lib/cardNewsRoleTemplateStore.ts +0 -47
  104. package/lib/cardNewsTemplateStore.ts +0 -252
  105. package/lib/codexDetect.ts +0 -71
  106. package/lib/comfyBridge.ts +0 -235
  107. package/lib/composerSnapshot.ts +0 -33
  108. package/lib/configKeys.ts +0 -62
  109. package/lib/db.ts +0 -295
  110. package/lib/errInfo.ts +0 -43
  111. package/lib/errorClassify.ts +0 -100
  112. package/lib/generationCancel.ts +0 -28
  113. package/lib/generationErrors.ts +0 -238
  114. package/lib/grokImageAdapter.ts +0 -513
  115. package/lib/grokMultimodeAdapter.ts +0 -84
  116. package/lib/grokProxyLauncher.ts +0 -153
  117. package/lib/grokRuntime.ts +0 -23
  118. package/lib/grokSizeMapper.ts +0 -71
  119. package/lib/grokVideoAdapter.ts +0 -458
  120. package/lib/grokVideoCanvas.ts +0 -26
  121. package/lib/grokVideoDownload.ts +0 -59
  122. package/lib/grokVideoPlannerPrompt.ts +0 -67
  123. package/lib/historyIndex.ts +0 -51
  124. package/lib/historyList.ts +0 -181
  125. package/lib/imageMetadata.ts +0 -113
  126. package/lib/imageMetadataStore.ts +0 -67
  127. package/lib/imageModels.ts +0 -165
  128. package/lib/inflight.ts +0 -281
  129. package/lib/localImportStore.ts +0 -114
  130. package/lib/logger.ts +0 -161
  131. package/lib/nodeStore.ts +0 -91
  132. package/lib/oauthLauncher.ts +0 -94
  133. package/lib/oauthNormalize.ts +0 -30
  134. package/lib/oauthProxy/errors.ts +0 -128
  135. package/lib/oauthProxy/generators.ts +0 -494
  136. package/lib/oauthProxy/index.ts +0 -28
  137. package/lib/oauthProxy/prompts.ts +0 -123
  138. package/lib/oauthProxy/references.ts +0 -45
  139. package/lib/oauthProxy/runtime.ts +0 -115
  140. package/lib/oauthProxy/streams.ts +0 -232
  141. package/lib/oauthProxy/types.ts +0 -9
  142. package/lib/oauthProxy.ts +0 -3
  143. package/lib/openDirectory.ts +0 -47
  144. package/lib/pngInfo.ts +0 -26
  145. package/lib/promptBuilder/attachments.ts +0 -74
  146. package/lib/promptBuilder/client.ts +0 -130
  147. package/lib/promptBuilder/constants.ts +0 -9
  148. package/lib/promptBuilder/context.ts +0 -36
  149. package/lib/promptBuilder/errors.ts +0 -12
  150. package/lib/promptBuilder/requestSchema.ts +0 -56
  151. package/lib/promptBuilder/responseParser.ts +0 -219
  152. package/lib/promptBuilder/systemPrompt.ts +0 -135
  153. package/lib/promptBuilder/transport.ts +0 -94
  154. package/lib/promptBuilder/types.ts +0 -109
  155. package/lib/promptImport/curatedSources.ts +0 -141
  156. package/lib/promptImport/discoveryRegistry.ts +0 -329
  157. package/lib/promptImport/errors.ts +0 -18
  158. package/lib/promptImport/githubDiscovery.ts +0 -309
  159. package/lib/promptImport/githubFolder.ts +0 -397
  160. package/lib/promptImport/githubSource.ts +0 -257
  161. package/lib/promptImport/gptImageHints.ts +0 -70
  162. package/lib/promptImport/parsePromptCandidates.ts +0 -179
  163. package/lib/promptImport/promptIndex.ts +0 -326
  164. package/lib/promptImport/rankPromptCandidates.ts +0 -65
  165. package/lib/promptImport/types.ts +0 -103
  166. package/lib/promptSafetyPolicy.ts +0 -5
  167. package/lib/providerOptions.ts +0 -56
  168. package/lib/referenceImageCompress.ts +0 -84
  169. package/lib/refs.ts +0 -133
  170. package/lib/requestLogger.ts +0 -49
  171. package/lib/responsesDoctor.ts +0 -456
  172. package/lib/responsesErrors.ts +0 -83
  173. package/lib/responsesFallback.ts +0 -114
  174. package/lib/responsesImageAdapter.ts +0 -466
  175. package/lib/responsesParse.ts +0 -452
  176. package/lib/responsesTools.ts +0 -28
  177. package/lib/runtimeContext.ts +0 -146
  178. package/lib/runtimePorts.ts +0 -105
  179. package/lib/sessionStore.ts +0 -308
  180. package/lib/storageMigration.ts +0 -310
  181. package/lib/styleSheet.ts +0 -139
  182. package/lib/systemTrash.ts +0 -20
  183. package/lib/videoContinuity.ts +0 -180
  184. package/lib/videoFrameExtract.ts +0 -78
  185. package/lib/videoSeriesChain.ts +0 -29
  186. package/lib/visibleTextLanguagePolicy.ts +0 -7
  187. package/routes/agent.ts +0 -308
  188. package/routes/annotations.ts +0 -118
  189. package/routes/canvasVersions.ts +0 -69
  190. package/routes/capabilities.ts +0 -18
  191. package/routes/cardNews.ts +0 -211
  192. package/routes/comfy.ts +0 -43
  193. package/routes/edit.ts +0 -352
  194. package/routes/generate.ts +0 -492
  195. package/routes/grok.ts +0 -24
  196. package/routes/health.ts +0 -123
  197. package/routes/history.ts +0 -221
  198. package/routes/imageImport.ts +0 -37
  199. package/routes/index.ts +0 -52
  200. package/routes/metadata.ts +0 -77
  201. package/routes/multimode.ts +0 -499
  202. package/routes/nodes.ts +0 -578
  203. package/routes/promptBuilder.ts +0 -37
  204. package/routes/promptImport.ts +0 -379
  205. package/routes/prompts.ts +0 -428
  206. package/routes/quota.ts +0 -89
  207. package/routes/sessions.ts +0 -317
  208. package/routes/storage.ts +0 -47
  209. package/routes/video.ts +0 -300
  210. package/routes/videoExtended.ts +0 -284
  211. package/server.ts +0 -293
  212. package/ui/dist/assets/SettingsWorkspace-PiaVnsdA.js +0 -1
  213. package/ui/dist/assets/index-CjgnNtgt.css +0 -1
  214. package/ui/dist/assets/index-Da2s4_-5.js +0 -36
@@ -1,94 +0,0 @@
1
- import { isWin } from "../bin/lib/platform.js";
2
- import { config } from "../config.js";
3
- import { parseLocalhostPortFromUrl, parseOAuthReadyUrl } from "./runtimePorts.js";
4
- import { hasAuthFile } from "./codexDetect.js";
5
- import { type ChildProcess, spawn } from "node:child_process";
6
-
7
- export function startOAuthProxy(options: any = {}) {
8
- const oauthPort = options.oauthPort ?? config.oauth.proxyPort;
9
- const restartDelayMs = options.restartDelayMs ?? config.oauth.restartDelayMs;
10
- let currentChild: ChildProcess | null = null;
11
- let stopping = false;
12
- let restartTimer: NodeJS.Timeout | null = null;
13
- let hasBeenReady = false;
14
- let restartCount = 0;
15
- const MAX_RESTARTS = 3;
16
-
17
- const spawnProxy = () => {
18
- // Guard: don't start if no auth file exists (avoids pointless crash loops
19
- // and prevents openai-oauth from corrupting state on refresh failure)
20
- if (!hasAuthFile()) {
21
- console.log("[gpt-oauth] No Codex auth file found. Skipping GPT OAuth proxy.");
22
- options.onExit?.({ code: 0 });
23
- return;
24
- }
25
-
26
- console.log(`Starting GPT OAuth proxy (openai-oauth) on port ${oauthPort}...`);
27
- const spawnedAt = Date.now();
28
- const child = spawn("npx", ["openai-oauth", "--port", String(oauthPort)], {
29
- stdio: ["ignore", "pipe", "pipe"],
30
- shell: isWin,
31
- windowsHide: true,
32
- env: { ...process.env },
33
- });
34
- currentChild = child;
35
-
36
- child.stdout?.on("data", (d) => {
37
- const msg = d.toString().trim();
38
- if (!msg) return;
39
- console.log(`[gpt-oauth] ${msg}`);
40
- for (const line of msg.split(/\r?\n/)) {
41
- const url = parseOAuthReadyUrl(line);
42
- if (!url) continue;
43
- const port = parseLocalhostPortFromUrl(url);
44
- if (port && port !== oauthPort) {
45
- console.log(`[gpt-oauth] requested port ${oauthPort}, actual port ${port}`);
46
- }
47
- options.onReady?.({ url, port: port || oauthPort, requestedPort: oauthPort });
48
- hasBeenReady = true;
49
- }
50
- });
51
-
52
- child.stderr?.on("data", (d) => {
53
- const msg = d.toString().trim();
54
- if (msg && !msg.includes("npm warn")) console.error(`[gpt-oauth] ${msg}`);
55
- });
56
-
57
- child.on("exit", (code) => {
58
- if (currentChild === child) currentChild = null;
59
- if (stopping) return;
60
- const uptime = Date.now() - spawnedAt;
61
- if (uptime < 5000 && !hasBeenReady) {
62
- // Crashed immediately without ever becoming ready — likely missing openai-oauth or no token.
63
- // Don't restart; just mark as failed silently.
64
- console.log(`[gpt-oauth] proxy exited immediately (code ${code}). Skipping — Grok-only mode is fine.`);
65
- options.onExit?.({ code });
66
- return;
67
- }
68
- options.onExit?.({ code });
69
- if (restartCount >= MAX_RESTARTS) {
70
- console.log(`[gpt-oauth] max restarts (${MAX_RESTARTS}) reached. Giving up — Grok-only mode is fine.`);
71
- return;
72
- }
73
- restartCount++;
74
- console.log(`[gpt-oauth] exited with code ${code}, restarting in ${Math.round(restartDelayMs / 1000)}s... (attempt ${restartCount}/${MAX_RESTARTS})`);
75
- restartTimer = setTimeout(spawnProxy, restartDelayMs);
76
- });
77
- };
78
-
79
- spawnProxy();
80
-
81
- return {
82
- get child() {
83
- return currentChild;
84
- },
85
- kill(signal: NodeJS.Signals = "SIGTERM") {
86
- this.stop(signal);
87
- },
88
- stop(signal: NodeJS.Signals = "SIGTERM") {
89
- stopping = true;
90
- if (restartTimer) clearTimeout(restartTimer);
91
- try { currentChild?.kill(signal); } catch {}
92
- },
93
- };
94
- }
@@ -1,30 +0,0 @@
1
- // 0.09.12.2 — Keep supported image tool qualities intact for OAuth.
2
- // The exposed app contract accepts low/medium/high; normalize only malformed input so
3
- // the API response, UI metadata, and actual image_generation payload stay aligned.
4
-
5
- export const DEFAULT_IMAGE_QUALITY = "medium";
6
- export const VALID_IMAGE_QUALITIES = new Set(["low", "medium", "high"]);
7
-
8
- /**
9
- * @param {{ provider?: string, quality?: string }} input
10
- * @returns {{ quality: string, warnings: Array<{code:string,field:string,normalizedTo:string,reason:string}> }}
11
- */
12
- export function normalizeOAuthParams(input: { provider?: string; quality?: string } | null | undefined) {
13
- const requested = typeof input?.quality === "string" ? input.quality : DEFAULT_IMAGE_QUALITY;
14
-
15
- if (VALID_IMAGE_QUALITIES.has(requested)) {
16
- return { quality: requested, warnings: [] };
17
- }
18
-
19
- return {
20
- quality: DEFAULT_IMAGE_QUALITY,
21
- warnings: [
22
- {
23
- code: "QUALITY_DEFAULTED",
24
- field: "quality",
25
- normalizedTo: DEFAULT_IMAGE_QUALITY,
26
- reason: "invalid-quality",
27
- },
28
- ],
29
- };
30
- }
@@ -1,128 +0,0 @@
1
- import { logEvent } from "../logger.js";
2
- import { classifyUpstreamError, classifyUpstreamErrorCode } from "../errorClassify.js";
3
-
4
- interface MakeOAuthErrorOptions {
5
- status?: number;
6
- code?: string;
7
- upstreamBodyChars?: number;
8
- upstreamCode?: string | null;
9
- upstreamType?: string | null;
10
- upstreamParam?: string | null;
11
- eventType?: string;
12
- eventCount?: number;
13
- cause?: unknown;
14
- }
15
-
16
- interface OAuthError extends Error {
17
- code: string;
18
- status?: number;
19
- upstreamBodyChars?: number;
20
- upstreamCode?: string | null;
21
- upstreamType?: string | null;
22
- upstreamParam?: string | null;
23
- eventType?: string;
24
- eventCount?: number;
25
- cause?: unknown;
26
- }
27
-
28
- export function makeOAuthError(
29
- message: string,
30
- {
31
- status,
32
- code = "OAUTH_UPSTREAM_ERROR",
33
- upstreamBodyChars,
34
- upstreamCode,
35
- upstreamType,
36
- upstreamParam,
37
- eventType,
38
- eventCount,
39
- cause,
40
- }: MakeOAuthErrorOptions = {},
41
- ): OAuthError {
42
- const err = new Error(message) as OAuthError;
43
- err.code = code;
44
- if (status) err.status = status;
45
- if (typeof upstreamBodyChars === "number") err.upstreamBodyChars = upstreamBodyChars;
46
- if (upstreamCode) err.upstreamCode = upstreamCode;
47
- if (upstreamType) err.upstreamType = upstreamType;
48
- if (upstreamParam) err.upstreamParam = upstreamParam;
49
- if (eventType) err.eventType = eventType;
50
- if (typeof eventCount === "number") err.eventCount = eventCount;
51
- if (cause) err.cause = cause;
52
- return err;
53
- }
54
-
55
- export function parseOpenAIErrorBody(text: string) {
56
- try {
57
- const parsed = JSON.parse(text);
58
- const error = parsed?.error;
59
- if (!error || typeof error !== "object") return null;
60
- const message = typeof error.message === "string" ? error.message : "";
61
- if (!message) return null;
62
- return {
63
- message,
64
- code: typeof error.code === "string" ? error.code : null,
65
- type: typeof error.type === "string" ? error.type : null,
66
- param: typeof error.param === "string" ? error.param : null,
67
- };
68
- } catch {
69
- return null;
70
- }
71
- }
72
-
73
- export function normalizedOAuthCode(upstreamError: { code?: string | null; type?: string | null; message?: string | null } | null | undefined) {
74
- const byCode = classifyUpstreamErrorCode(upstreamError?.code);
75
- if (byCode !== "UNKNOWN") return byCode;
76
- const byType = classifyUpstreamErrorCode(upstreamError?.type);
77
- if (byType !== "UNKNOWN") return byType;
78
- const byMessage = classifyUpstreamError(upstreamError?.message);
79
- if (byMessage !== "UNKNOWN") return byMessage;
80
- return "OAUTH_UPSTREAM_ERROR";
81
- }
82
-
83
- interface ThrowOAuthHttpErrorOptions {
84
- requestId: string | null;
85
- scope?: string;
86
- fallbackMessage: string;
87
- }
88
-
89
- export function throwOAuthHttpError(res: { status: number }, text: string, { requestId, scope, fallbackMessage }: ThrowOAuthHttpErrorOptions) {
90
- const upstream = parseOpenAIErrorBody(text);
91
- const isClientError = res.status >= 400 && res.status < 500;
92
- if (isClientError && upstream?.message) {
93
- logEvent(scope || "oauth", "upstream_client_error", {
94
- requestId,
95
- status: res.status,
96
- code: upstream.code,
97
- type: upstream.type,
98
- param: upstream.param,
99
- errorChars: text.length,
100
- });
101
- throw makeOAuthError(upstream.message, {
102
- status: res.status,
103
- code: normalizedOAuthCode(upstream),
104
- upstreamBodyChars: text.length,
105
- upstreamCode: upstream.code,
106
- upstreamType: upstream.type,
107
- upstreamParam: upstream.param,
108
- });
109
- }
110
- throw makeOAuthError(fallbackMessage, {
111
- status: res.status,
112
- upstreamBodyChars: text.length,
113
- });
114
- }
115
-
116
- export function isAbortError(err: unknown) {
117
- const e = err as { name?: string; code?: string } | null | undefined;
118
- return e?.name === "AbortError" || e?.code === "ABORT_ERR";
119
- }
120
-
121
- export function throwOAuthTimeoutError(err: unknown, { timeoutMs: _timeoutMs, requestId: _requestId, scope }: { timeoutMs?: number; requestId?: string | null; scope?: string }) {
122
- throw makeOAuthError("OAuth image generation timed out", {
123
- code: "OAUTH_IMAGE_TIMEOUT",
124
- status: 504,
125
- cause: err,
126
- eventType: `${scope || "oauth"}.timeout`,
127
- });
128
- }