ima2-gen 1.1.21 → 1.1.22
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 +30 -4
- package/bin/ima2.js +14 -4
- package/bin/lib/platform.js +34 -5
- package/docs/README.ko.md +31 -0
- package/lib/agentQueueWorker.js +6 -0
- package/lib/agentRuntime.js +3 -2
- package/lib/atomicWrite.js +14 -0
- package/lib/grokProxyLauncher.js +5 -3
- package/lib/inflight.js +1 -1
- package/lib/oauthLauncher.js +5 -0
- package/lib/videoFrameExtract.js +3 -3
- package/package.json +5 -7
- package/routes/edit.js +2 -1
- package/routes/generate.js +4 -3
- package/routes/health.js +4 -3
- package/routes/multimode.js +2 -1
- package/routes/video.js +4 -2
- package/server.js +29 -2
- package/ui/dist/.vite/manifest.json +12 -12
- package/ui/dist/assets/{AgentWorkspace-B_hq9CLg.js → AgentWorkspace-COxQ5TjU.js} +1 -1
- package/ui/dist/assets/{CardNewsWorkspace-wD12J7qk.js → CardNewsWorkspace-B0OkcuVz.js} +1 -1
- package/ui/dist/assets/{NodeCanvas-CI_wuPMf.js → NodeCanvas-BSsclEBh.js} +1 -1
- package/ui/dist/assets/{PromptBuilderPanel-CUTujJUV.js → PromptBuilderPanel-DpC9A5Rz.js} +1 -1
- package/ui/dist/assets/{PromptImportDialog-CUi66jPK.js → PromptImportDialog-CVwT0rLd.js} +2 -2
- package/ui/dist/assets/{PromptImportDiscoverySection-Cm3vrjY4.js → PromptImportDiscoverySection-BDCkRCRs.js} +1 -1
- package/ui/dist/assets/{PromptImportFolderSection-DOtWTD9n.js → PromptImportFolderSection-QoKbZD83.js} +1 -1
- package/ui/dist/assets/{PromptLibraryPanel-BMjQegRa.js → PromptLibraryPanel-BhFgeKnY.js} +2 -2
- package/ui/dist/assets/SettingsWorkspace-CfjrlH5R.js +1 -0
- package/ui/dist/assets/index-C-mur7pa.css +1 -0
- package/ui/dist/assets/index-CCP5nUOj.js +42 -0
- package/ui/dist/assets/{index-31uVIdt4.js → index-Cxhzi3bs.js} +1 -1
- package/ui/dist/index.html +2 -2
- package/bin/commands/annotate.ts +0 -119
- package/bin/commands/cancel.ts +0 -48
- package/bin/commands/canvas-versions.ts +0 -80
- package/bin/commands/capabilities.ts +0 -110
- package/bin/commands/cardnews.ts +0 -249
- package/bin/commands/comfy.ts +0 -54
- package/bin/commands/config.ts +0 -186
- package/bin/commands/defaults.ts +0 -192
- package/bin/commands/doctor.ts +0 -202
- package/bin/commands/edit.ts +0 -150
- package/bin/commands/gen.ts +0 -214
- package/bin/commands/grok.ts +0 -90
- package/bin/commands/history.ts +0 -146
- package/bin/commands/ls.ts +0 -64
- package/bin/commands/metadata.ts +0 -39
- package/bin/commands/multimode.ts +0 -196
- package/bin/commands/node.ts +0 -166
- package/bin/commands/observability.ts +0 -176
- package/bin/commands/ping.ts +0 -31
- package/bin/commands/prompt-sub/build.ts +0 -101
- package/bin/commands/prompt.ts +0 -492
- package/bin/commands/ps.ts +0 -81
- package/bin/commands/session.ts +0 -266
- package/bin/commands/show.ts +0 -72
- package/bin/commands/skill.ts +0 -70
- package/bin/commands/video.ts +0 -442
- package/bin/ima2.ts +0 -430
- package/bin/lib/args.ts +0 -92
- package/bin/lib/browser-id.ts +0 -16
- package/bin/lib/client.ts +0 -122
- package/bin/lib/config-store.ts +0 -120
- package/bin/lib/destructive-confirm.ts +0 -19
- package/bin/lib/doctor-checks.ts +0 -91
- package/bin/lib/error-hints.ts +0 -23
- package/bin/lib/files.ts +0 -39
- package/bin/lib/output.ts +0 -73
- package/bin/lib/platform.ts +0 -99
- package/bin/lib/recover-output.ts +0 -139
- package/bin/lib/sse.ts +0 -73
- package/bin/lib/star-prompt.ts +0 -97
- package/bin/lib/storage-doctor.ts +0 -39
- package/bin/lib/ui-build.ts +0 -85
- package/config.ts +0 -354
- package/lib/agentCommandParser.ts +0 -69
- package/lib/agentGenerationPlanner.ts +0 -273
- package/lib/agentQuestionResponder.ts +0 -266
- package/lib/agentQueueStore.ts +0 -270
- package/lib/agentQueueWorker.ts +0 -89
- package/lib/agentRuntime.ts +0 -604
- package/lib/agentSettings.ts +0 -72
- package/lib/agentStore.ts +0 -422
- package/lib/agentStoreRows.ts +0 -136
- package/lib/agentTypes.ts +0 -154
- package/lib/apiCachePolicy.ts +0 -11
- package/lib/assetLifecycle.ts +0 -146
- package/lib/canvasVersionStore.ts +0 -223
- package/lib/capabilities.ts +0 -126
- package/lib/cardNewsGenerator.ts +0 -271
- package/lib/cardNewsJobStore.ts +0 -142
- package/lib/cardNewsManifestStore.ts +0 -154
- package/lib/cardNewsPlanner.ts +0 -236
- package/lib/cardNewsPlannerClient.ts +0 -155
- package/lib/cardNewsPlannerPrompt.ts +0 -62
- package/lib/cardNewsPlannerSchema.ts +0 -321
- package/lib/cardNewsRoleTemplateStore.ts +0 -47
- package/lib/cardNewsTemplateStore.ts +0 -252
- package/lib/codexDetect.ts +0 -71
- package/lib/comfyBridge.ts +0 -235
- package/lib/composerSnapshot.ts +0 -33
- package/lib/configKeys.ts +0 -62
- package/lib/db.ts +0 -295
- package/lib/errInfo.ts +0 -43
- package/lib/errorClassify.ts +0 -100
- package/lib/generationCancel.ts +0 -28
- package/lib/generationErrors.ts +0 -238
- package/lib/grokImageAdapter.ts +0 -513
- package/lib/grokMultimodeAdapter.ts +0 -84
- package/lib/grokProxyLauncher.ts +0 -153
- package/lib/grokRuntime.ts +0 -23
- package/lib/grokSizeMapper.ts +0 -71
- package/lib/grokVideoAdapter.ts +0 -458
- package/lib/grokVideoCanvas.ts +0 -26
- package/lib/grokVideoDownload.ts +0 -59
- package/lib/grokVideoPlannerPrompt.ts +0 -67
- package/lib/historyIndex.ts +0 -51
- package/lib/historyList.ts +0 -181
- package/lib/imageMetadata.ts +0 -113
- package/lib/imageMetadataStore.ts +0 -67
- package/lib/imageModels.ts +0 -165
- package/lib/inflight.ts +0 -281
- package/lib/localImportStore.ts +0 -114
- package/lib/logger.ts +0 -161
- package/lib/nodeStore.ts +0 -91
- package/lib/oauthLauncher.ts +0 -94
- package/lib/oauthNormalize.ts +0 -30
- package/lib/oauthProxy/errors.ts +0 -128
- package/lib/oauthProxy/generators.ts +0 -494
- package/lib/oauthProxy/index.ts +0 -28
- package/lib/oauthProxy/prompts.ts +0 -123
- package/lib/oauthProxy/references.ts +0 -45
- package/lib/oauthProxy/runtime.ts +0 -115
- package/lib/oauthProxy/streams.ts +0 -232
- package/lib/oauthProxy/types.ts +0 -9
- package/lib/oauthProxy.ts +0 -3
- package/lib/openDirectory.ts +0 -47
- package/lib/pngInfo.ts +0 -26
- package/lib/promptBuilder/attachments.ts +0 -74
- package/lib/promptBuilder/client.ts +0 -130
- package/lib/promptBuilder/constants.ts +0 -9
- package/lib/promptBuilder/context.ts +0 -36
- package/lib/promptBuilder/errors.ts +0 -12
- package/lib/promptBuilder/requestSchema.ts +0 -56
- package/lib/promptBuilder/responseParser.ts +0 -219
- package/lib/promptBuilder/systemPrompt.ts +0 -135
- package/lib/promptBuilder/transport.ts +0 -94
- package/lib/promptBuilder/types.ts +0 -109
- package/lib/promptImport/curatedSources.ts +0 -141
- package/lib/promptImport/discoveryRegistry.ts +0 -329
- package/lib/promptImport/errors.ts +0 -18
- package/lib/promptImport/githubDiscovery.ts +0 -309
- package/lib/promptImport/githubFolder.ts +0 -397
- package/lib/promptImport/githubSource.ts +0 -257
- package/lib/promptImport/gptImageHints.ts +0 -70
- package/lib/promptImport/parsePromptCandidates.ts +0 -179
- package/lib/promptImport/promptIndex.ts +0 -326
- package/lib/promptImport/rankPromptCandidates.ts +0 -65
- package/lib/promptImport/types.ts +0 -103
- package/lib/promptSafetyPolicy.ts +0 -5
- package/lib/providerOptions.ts +0 -56
- package/lib/referenceImageCompress.ts +0 -84
- package/lib/refs.ts +0 -133
- package/lib/requestLogger.ts +0 -49
- package/lib/responsesDoctor.ts +0 -456
- package/lib/responsesErrors.ts +0 -83
- package/lib/responsesFallback.ts +0 -114
- package/lib/responsesImageAdapter.ts +0 -466
- package/lib/responsesParse.ts +0 -452
- package/lib/responsesTools.ts +0 -28
- package/lib/runtimeContext.ts +0 -146
- package/lib/runtimePorts.ts +0 -105
- package/lib/sessionStore.ts +0 -308
- package/lib/storageMigration.ts +0 -310
- package/lib/styleSheet.ts +0 -139
- package/lib/systemTrash.ts +0 -20
- package/lib/videoContinuity.ts +0 -180
- package/lib/videoFrameExtract.ts +0 -78
- package/lib/videoSeriesChain.ts +0 -29
- package/lib/visibleTextLanguagePolicy.ts +0 -7
- package/routes/agent.ts +0 -308
- package/routes/annotations.ts +0 -118
- package/routes/canvasVersions.ts +0 -69
- package/routes/capabilities.ts +0 -18
- package/routes/cardNews.ts +0 -211
- package/routes/comfy.ts +0 -43
- package/routes/edit.ts +0 -352
- package/routes/generate.ts +0 -492
- package/routes/grok.ts +0 -24
- package/routes/health.ts +0 -123
- package/routes/history.ts +0 -221
- package/routes/imageImport.ts +0 -37
- package/routes/index.ts +0 -52
- package/routes/metadata.ts +0 -77
- package/routes/multimode.ts +0 -499
- package/routes/nodes.ts +0 -578
- package/routes/promptBuilder.ts +0 -37
- package/routes/promptImport.ts +0 -379
- package/routes/prompts.ts +0 -428
- package/routes/quota.ts +0 -89
- package/routes/sessions.ts +0 -317
- package/routes/storage.ts +0 -47
- package/routes/video.ts +0 -300
- package/routes/videoExtended.ts +0 -284
- package/server.ts +0 -293
- package/ui/dist/assets/SettingsWorkspace-PiaVnsdA.js +0 -1
- package/ui/dist/assets/index-CjgnNtgt.css +0 -1
- package/ui/dist/assets/index-Da2s4_-5.js +0 -36
package/bin/commands/defaults.ts
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import { config } from "../../config.js";
|
|
2
|
-
import { parseArgs } from "../lib/args.js";
|
|
3
|
-
import { resolveServer, request } from "../lib/client.js";
|
|
4
|
-
import {
|
|
5
|
-
buildEffectiveConfig,
|
|
6
|
-
deleteNestedKey,
|
|
7
|
-
displayPath,
|
|
8
|
-
envOverrideForKey,
|
|
9
|
-
getNestedKey,
|
|
10
|
-
loadFileCfg,
|
|
11
|
-
restartNotice,
|
|
12
|
-
saveFileCfg,
|
|
13
|
-
setNestedKey,
|
|
14
|
-
CONFIG_FILE,
|
|
15
|
-
} from "../lib/config-store.js";
|
|
16
|
-
import { color, die, dieWithError, json, out } from "../lib/output.js";
|
|
17
|
-
|
|
18
|
-
const MODEL_KEYS = ["imageModels.default", "apiProvider.defaultImageModel"] as const;
|
|
19
|
-
const REASONING_KEYS = ["imageModels.reasoningEffort", "apiProvider.defaultReasoningEffort"] as const;
|
|
20
|
-
|
|
21
|
-
const HELP = `
|
|
22
|
-
ima2 defaults [subcommand] [options]
|
|
23
|
-
|
|
24
|
-
Inspect or change persistent model/reasoning defaults.
|
|
25
|
-
|
|
26
|
-
Subcommands:
|
|
27
|
-
ls Show effective defaults
|
|
28
|
-
set model <model> Persist default model for GPT OAuth and API paths
|
|
29
|
-
set reasoning <effort> Persist default reasoning effort for GPT OAuth and API paths
|
|
30
|
-
reset model Remove persisted model defaults
|
|
31
|
-
reset reasoning Remove persisted reasoning defaults
|
|
32
|
-
|
|
33
|
-
Options:
|
|
34
|
-
--json Print JSON
|
|
35
|
-
--local Do not query running server
|
|
36
|
-
--server <url> Query a specific running server for ls/default output
|
|
37
|
-
`;
|
|
38
|
-
|
|
39
|
-
const FLAGS = {
|
|
40
|
-
json: { type: "boolean" },
|
|
41
|
-
local: { type: "boolean" },
|
|
42
|
-
server: { type: "string" },
|
|
43
|
-
help: { short: "h", type: "boolean" },
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
function localDefaults() {
|
|
47
|
-
const effective = buildEffectiveConfig();
|
|
48
|
-
return {
|
|
49
|
-
ok: true,
|
|
50
|
-
source: "local",
|
|
51
|
-
server: null,
|
|
52
|
-
defaults: {
|
|
53
|
-
oauth: {
|
|
54
|
-
model: getNestedKey(effective, "imageModels.default"),
|
|
55
|
-
reasoningEffort: getNestedKey(effective, "imageModels.reasoningEffort"),
|
|
56
|
-
},
|
|
57
|
-
api: {
|
|
58
|
-
model: getNestedKey(effective, "apiProvider.defaultImageModel"),
|
|
59
|
-
reasoningEffort: getNestedKey(effective, "apiProvider.defaultReasoningEffort"),
|
|
60
|
-
size: getNestedKey(effective, "apiProvider.defaultSize"),
|
|
61
|
-
webSearchEnabled: getNestedKey(effective, "apiProvider.allowWebSearch"),
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
async function readDefaults(args: ReturnType<typeof parseArgs>) {
|
|
68
|
-
if (args.local) return localDefaults();
|
|
69
|
-
try {
|
|
70
|
-
const server = await resolveServer({ serverFlag: args.server });
|
|
71
|
-
const capabilities = await request(server.base, "/api/capabilities", { timeoutMs: 5000 });
|
|
72
|
-
return {
|
|
73
|
-
ok: true,
|
|
74
|
-
source: "server",
|
|
75
|
-
server: server.base,
|
|
76
|
-
defaults: capabilities.defaults,
|
|
77
|
-
};
|
|
78
|
-
} catch (error) {
|
|
79
|
-
if (args.server) throw error;
|
|
80
|
-
return localDefaults();
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function printDefaults(payload: any): void {
|
|
85
|
-
out(`ima2 defaults (${payload.source})`);
|
|
86
|
-
out(`server: ${payload.server || "none"}`);
|
|
87
|
-
out("");
|
|
88
|
-
out(`oauth model: ${payload.defaults?.oauth?.model}`);
|
|
89
|
-
out(`oauth reasoning: ${payload.defaults?.oauth?.reasoningEffort}`);
|
|
90
|
-
out(`api model: ${payload.defaults?.api?.model}`);
|
|
91
|
-
out(`api reasoning: ${payload.defaults?.api?.reasoningEffort}`);
|
|
92
|
-
if (payload.defaults?.api?.size) out(`api size: ${payload.defaults.api.size}`);
|
|
93
|
-
if (payload.defaults?.api?.webSearchEnabled !== undefined) {
|
|
94
|
-
out(`api web search: ${payload.defaults.api.webSearchEnabled ? "enabled" : "disabled"}`);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function validateModel(value: string): void {
|
|
99
|
-
if (!config.imageModels.valid.has(value)) {
|
|
100
|
-
die(2, `model must be one of: ${Array.from(config.imageModels.valid).join(", ")}`);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function validateReasoning(value: string): void {
|
|
105
|
-
if (!config.imageModels.validReasoningEfforts.has(value)) {
|
|
106
|
-
die(2, `reasoning must be one of: ${Array.from(config.imageModels.validReasoningEfforts).join(", ")}`);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function warnOverrides(keys: readonly string[]): void {
|
|
111
|
-
for (const key of keys) {
|
|
112
|
-
const override = envOverrideForKey(key);
|
|
113
|
-
if (!override) continue;
|
|
114
|
-
out(color.yellow(`warning: env ${override.envVar}=${override.value} is currently overriding ${key}.`));
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function setDefaults(keys: readonly string[], value: string): void {
|
|
119
|
-
const fileCfg = loadFileCfg();
|
|
120
|
-
for (const key of keys) setNestedKey(fileCfg, key, value);
|
|
121
|
-
saveFileCfg(fileCfg);
|
|
122
|
-
warnOverrides(keys);
|
|
123
|
-
out(color.green("✓ ") + `wrote ${keys.join(", ")}=${JSON.stringify(value)} to ${displayPath(CONFIG_FILE)}`);
|
|
124
|
-
out(color.dim(restartNotice()));
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function resetDefaults(keys: readonly string[]): void {
|
|
128
|
-
const fileCfg = loadFileCfg();
|
|
129
|
-
let changed = false;
|
|
130
|
-
for (const key of keys) changed = deleteNestedKey(fileCfg, key) || changed;
|
|
131
|
-
if (!changed) {
|
|
132
|
-
out(color.dim(`(no persisted defaults found for ${keys.join(", ")})`));
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
saveFileCfg(fileCfg);
|
|
136
|
-
out(color.green("✓ ") + `removed ${keys.join(", ")} from ${displayPath(CONFIG_FILE)}`);
|
|
137
|
-
out(color.dim(restartNotice()));
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
async function listSub(argv: string[]): Promise<void> {
|
|
141
|
-
const args = parseArgs(argv, { flags: FLAGS });
|
|
142
|
-
try {
|
|
143
|
-
const payload = await readDefaults(args);
|
|
144
|
-
if (args.json) json(payload);
|
|
145
|
-
else printDefaults(payload);
|
|
146
|
-
} catch (error) {
|
|
147
|
-
dieWithError(error);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
async function setSub(argv: string[]): Promise<void> {
|
|
152
|
-
const args = parseArgs(argv, { flags: FLAGS });
|
|
153
|
-
const [target, value] = args.positional;
|
|
154
|
-
if (!target || !value) die(2, "usage: defaults set <model|reasoning> <value>");
|
|
155
|
-
if (target === "model") {
|
|
156
|
-
validateModel(value);
|
|
157
|
-
setDefaults(MODEL_KEYS, value);
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
if (target === "reasoning") {
|
|
161
|
-
validateReasoning(value);
|
|
162
|
-
setDefaults(REASONING_KEYS, value);
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
die(2, "target must be one of: model, reasoning");
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
async function resetSub(argv: string[]): Promise<void> {
|
|
169
|
-
const args = parseArgs(argv, { flags: FLAGS });
|
|
170
|
-
const target = args.positional[0];
|
|
171
|
-
if (target === "model") {
|
|
172
|
-
resetDefaults(MODEL_KEYS);
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
if (target === "reasoning") {
|
|
176
|
-
resetDefaults(REASONING_KEYS);
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
die(2, "usage: defaults reset <model|reasoning>");
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
export default async function defaultsCmd(argv: string[]) {
|
|
183
|
-
const sub = argv[0];
|
|
184
|
-
if (sub === "--help" || sub === "-h") {
|
|
185
|
-
out(HELP);
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
if (!sub || sub === "ls" || sub.startsWith("-")) return listSub(sub === "ls" ? argv.slice(1) : argv);
|
|
189
|
-
if (sub === "set") return setSub(argv.slice(1));
|
|
190
|
-
if (sub === "reset") return resetSub(argv.slice(1));
|
|
191
|
-
die(2, `unknown subcommand: ${sub}\n${HELP}`);
|
|
192
|
-
}
|
package/bin/commands/doctor.ts
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import { createRequire } from "module";
|
|
2
|
-
import { existsSync, readFileSync } from "fs";
|
|
3
|
-
import { dirname, join } from "path";
|
|
4
|
-
import { fileURLToPath } from "url";
|
|
5
|
-
import { buildHardeningDoctorLines } from "../lib/doctor-checks.js";
|
|
6
|
-
import { buildStorageDoctorLines } from "../lib/storage-doctor.js";
|
|
7
|
-
import { detectCodexAuth } from "../../lib/codexDetect.js";
|
|
8
|
-
import { runImageDoctorProbe } from "../../lib/responsesDoctor.js";
|
|
9
|
-
import { config as runtimeConfig } from "../../config.js";
|
|
10
|
-
|
|
11
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
12
|
-
const ROOT = join(__dirname, "../..");
|
|
13
|
-
const requireFromRoot = createRequire(join(ROOT, "package.json"));
|
|
14
|
-
const CONFIG_FILE = runtimeConfig.storage.configFile;
|
|
15
|
-
const LEGACY_CONFIG_FILE = join(ROOT, ".ima2", "config.json");
|
|
16
|
-
|
|
17
|
-
let pkg = { version: "?", name: "ima2-gen" };
|
|
18
|
-
try {
|
|
19
|
-
pkg = JSON.parse(readFileSync(join(ROOT, "package.json"), "utf-8"));
|
|
20
|
-
} catch {}
|
|
21
|
-
|
|
22
|
-
function loadConfig() {
|
|
23
|
-
if (existsSync(CONFIG_FILE)) {
|
|
24
|
-
return JSON.parse(readFileSync(CONFIG_FILE, "utf-8"));
|
|
25
|
-
}
|
|
26
|
-
if (existsSync(LEGACY_CONFIG_FILE)) {
|
|
27
|
-
try { return JSON.parse(readFileSync(LEGACY_CONFIG_FILE, "utf-8")); } catch {}
|
|
28
|
-
}
|
|
29
|
-
return {};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function missingRuntimeDeps() {
|
|
33
|
-
const deps = ["express", "better-sqlite3", "openai", "openai-oauth", "progrok/package.json"];
|
|
34
|
-
return deps.filter((dep) => {
|
|
35
|
-
try {
|
|
36
|
-
requireFromRoot.resolve(dep);
|
|
37
|
-
return false;
|
|
38
|
-
} catch {
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
}).map((dep) => dep === "progrok/package.json" ? "progrok" : dep);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function valueAfter(args: string[], name: string) {
|
|
45
|
-
const index = args.indexOf(name);
|
|
46
|
-
if (index === -1) return null;
|
|
47
|
-
return args[index + 1] || null;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function showImageProbeHelp() {
|
|
51
|
-
console.log(`
|
|
52
|
-
Usage: ima2 doctor image-probe [options]
|
|
53
|
-
|
|
54
|
-
Runs live, sanitized Responses probes for EMPTY_RESPONSE diagnosis.
|
|
55
|
-
The output never includes prompt text, auth tokens, URLs with credentials, or base64 image data.
|
|
56
|
-
|
|
57
|
-
Options:
|
|
58
|
-
--json Emit machine-readable JSON
|
|
59
|
-
--matrix Add current-payload web_search/tool_choice probes
|
|
60
|
-
--provider <api|oauth> Override configured provider
|
|
61
|
-
--model <model> Override image-capable Responses model
|
|
62
|
-
--size <size> Default: 1024x1024
|
|
63
|
-
--quality <quality> Default: low
|
|
64
|
-
--moderation <value> Default: low
|
|
65
|
-
--prompt <text> Override built-in cat prompt
|
|
66
|
-
--oauth-url <url> Override GPT OAuth proxy URL
|
|
67
|
-
--timeout-ms <ms> Per-probe timeout
|
|
68
|
-
`);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
async function imageProbe(args: string[]) {
|
|
72
|
-
if (args.includes("-h") || args.includes("--help")) {
|
|
73
|
-
showImageProbeHelp();
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
const fileConfig = loadConfig();
|
|
77
|
-
const result = await runImageDoctorProbe({
|
|
78
|
-
provider: valueAfter(args, "--provider") || fileConfig.provider || "oauth",
|
|
79
|
-
apiKey: typeof fileConfig.apiKey === "string" ? fileConfig.apiKey : undefined,
|
|
80
|
-
oauthUrl: valueAfter(args, "--oauth-url") || undefined,
|
|
81
|
-
model: valueAfter(args, "--model") || runtimeConfig.imageModels?.default || "gpt-5.4-mini",
|
|
82
|
-
size: valueAfter(args, "--size") || "1024x1024",
|
|
83
|
-
quality: valueAfter(args, "--quality") || "low",
|
|
84
|
-
moderation: valueAfter(args, "--moderation") || "low",
|
|
85
|
-
prompt: valueAfter(args, "--prompt") || undefined,
|
|
86
|
-
matrix: args.includes("--matrix"),
|
|
87
|
-
timeoutMs: Number(valueAfter(args, "--timeout-ms")) || undefined,
|
|
88
|
-
ctx: { config: runtimeConfig },
|
|
89
|
-
});
|
|
90
|
-
if (args.includes("--json")) {
|
|
91
|
-
console.log(JSON.stringify(result, null, 2));
|
|
92
|
-
process.exit(result.summary.ok ? 0 : 1);
|
|
93
|
-
}
|
|
94
|
-
console.log(`\n ${pkg.name} v${pkg.version} — Image Probe\n`);
|
|
95
|
-
console.log(` Provider: ${result.provider}`);
|
|
96
|
-
console.log(` Model: ${result.model}`);
|
|
97
|
-
console.log(` Prompt: ${result.promptId} (${result.promptChars} chars, redacted)`);
|
|
98
|
-
for (const probe of result.probes) {
|
|
99
|
-
const mark = probe.ok ? "✓" : "✗";
|
|
100
|
-
const reason = probe.diagnosticReason ? ` — ${probe.diagnosticReason}` : "";
|
|
101
|
-
console.log(` ${mark} ${probe.id}${reason}`);
|
|
102
|
-
console.log(
|
|
103
|
-
` status=${probe.response.httpStatus ?? "n/a"} events=${probe.response.eventCount} images=${probe.response.imageResultCount} textChars=${probe.response.textOutputChars}`,
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
console.log(`\n ${result.summary.passed} passed, ${result.summary.failed} failed\n`);
|
|
107
|
-
process.exit(result.summary.ok ? 0 : 1);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
async function standardDoctor() {
|
|
111
|
-
console.log(`\n ${pkg.name} v${pkg.version} — Doctor\n`);
|
|
112
|
-
|
|
113
|
-
let ok = 0;
|
|
114
|
-
let fail = 0;
|
|
115
|
-
|
|
116
|
-
const nodeVersion = process.version;
|
|
117
|
-
const nodeMajor = parseInt(nodeVersion.slice(1).split(".")[0]);
|
|
118
|
-
if (nodeMajor >= 20) {
|
|
119
|
-
console.log(` ✓ Node.js ${nodeVersion} (>= 20)`);
|
|
120
|
-
ok++;
|
|
121
|
-
} else {
|
|
122
|
-
console.log(` ✗ Node.js ${nodeVersion} (requires >= 20)`);
|
|
123
|
-
fail++;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (existsSync(join(ROOT, "package.json"))) {
|
|
127
|
-
console.log(" ✓ package.json found");
|
|
128
|
-
ok++;
|
|
129
|
-
} else {
|
|
130
|
-
console.log(" ✗ package.json missing");
|
|
131
|
-
fail++;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const missingDeps = missingRuntimeDeps();
|
|
135
|
-
if (missingDeps.length === 0) {
|
|
136
|
-
console.log(" ✓ runtime dependencies resolvable");
|
|
137
|
-
ok++;
|
|
138
|
-
} else {
|
|
139
|
-
console.log(` ✗ missing runtime dependencies: ${missingDeps.join(", ")}`);
|
|
140
|
-
fail++;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (existsSync(join(ROOT, ".env"))) {
|
|
144
|
-
console.log(" ✓ .env file exists");
|
|
145
|
-
ok++;
|
|
146
|
-
} else {
|
|
147
|
-
console.log(" ⚠ .env file not found (optional — copy from .env.example)");
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const fileConfig = loadConfig();
|
|
151
|
-
if (fileConfig.provider) {
|
|
152
|
-
console.log(` ✓ Configured: ${fileConfig.provider}`);
|
|
153
|
-
ok++;
|
|
154
|
-
} else {
|
|
155
|
-
console.log(" ⚠ Not configured — run 'ima2 setup'");
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
const advPath = runtimeConfig.storage.advertiseFile;
|
|
159
|
-
const adv = existsSync(advPath) ? JSON.parse(readFileSync(advPath, "utf-8")) : null;
|
|
160
|
-
console.log(` ℹ Preferred backend port: ${runtimeConfig.server.port}`);
|
|
161
|
-
if (adv?.backend || adv?.port) {
|
|
162
|
-
console.log(` ℹ Backend actual URL: ${adv?.backend?.url || adv?.url || `http://localhost:${adv.port}`}`);
|
|
163
|
-
if (adv?.oauth) console.log(` ℹ GPT OAuth actual URL: ${adv.oauth.url} (${adv.oauth.status || "unknown"})`);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const hardeningLines = await buildHardeningDoctorLines({
|
|
167
|
-
root: ROOT,
|
|
168
|
-
configFile: CONFIG_FILE,
|
|
169
|
-
fileConfig,
|
|
170
|
-
});
|
|
171
|
-
for (const line of hardeningLines) {
|
|
172
|
-
const prefix =
|
|
173
|
-
line.kind === "pass" ? "✓"
|
|
174
|
-
: line.kind === "fail" ? "✗"
|
|
175
|
-
: line.kind === "warn" ? "⚠"
|
|
176
|
-
: "ℹ";
|
|
177
|
-
console.log(` ${prefix} ${line.text}`);
|
|
178
|
-
if (line.kind === "pass") ok++;
|
|
179
|
-
if (line.kind === "fail") fail++;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
const storageLines = await buildStorageDoctorLines({
|
|
183
|
-
rootDir: ROOT,
|
|
184
|
-
config: runtimeConfig,
|
|
185
|
-
});
|
|
186
|
-
console.log("");
|
|
187
|
-
for (const line of storageLines) console.log(line);
|
|
188
|
-
|
|
189
|
-
const auth = detectCodexAuth();
|
|
190
|
-
if (auth.platform === "win32") console.log(" ℹ Windows GPT OAuth note: use WSL2 for Codex login.");
|
|
191
|
-
|
|
192
|
-
console.log(`\n ${ok} passed, ${fail} failed\n`);
|
|
193
|
-
process.exit(fail > 0 ? 1 : 0);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
export async function doctor(args: string[] = []) {
|
|
197
|
-
if (args[0] === "image-probe") {
|
|
198
|
-
await imageProbe(args.slice(1));
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
await standardDoctor();
|
|
202
|
-
}
|
package/bin/commands/edit.ts
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { parseArgs } from "../lib/args.js";
|
|
2
|
-
import { resolveServer, request } from "../lib/client.js";
|
|
3
|
-
import { fileToDataUri, dataUriToFile, defaultOutName } from "../lib/files.js";
|
|
4
|
-
import { out, die, dieWithError, color, json } from "../lib/output.js";
|
|
5
|
-
import { config } from "../../config.js";
|
|
6
|
-
import { createCliRequestId, recoverGeneratedOutputs, formatRecoveryHint } from "../lib/recover-output.js";
|
|
7
|
-
|
|
8
|
-
import { errInfo } from "../../lib/errInfo.js";
|
|
9
|
-
const VALID_MODES = new Set(["auto", "direct"]);
|
|
10
|
-
const VALID_MODERATION = new Set(["auto", "low"]);
|
|
11
|
-
const VALID_PROVIDERS = new Set(["auto", "oauth", "api", "grok"]);
|
|
12
|
-
const KNOWN_IMAGE_MODELS = new Set(["gpt-5.5", "gpt-5.4", "gpt-5.4-mini", "gpt-5.3-codex-spark", "grok-imagine-image", "grok-imagine-image-quality"]);
|
|
13
|
-
|
|
14
|
-
const SPEC = {
|
|
15
|
-
flags: {
|
|
16
|
-
prompt: { short: "p", type: "string" },
|
|
17
|
-
quality: { short: "q", type: "string", default: "low" },
|
|
18
|
-
size: { short: "s", type: "string", default: "1024x1024" },
|
|
19
|
-
out: { short: "o", type: "string" },
|
|
20
|
-
json: { type: "boolean" },
|
|
21
|
-
timeout: { type: "string", default: "180" },
|
|
22
|
-
server: { type: "string" },
|
|
23
|
-
model: { type: "string" },
|
|
24
|
-
provider: { type: "string" },
|
|
25
|
-
mode: { type: "string", default: "auto" },
|
|
26
|
-
moderation: { type: "string", default: "low" },
|
|
27
|
-
session: { type: "string" },
|
|
28
|
-
"reasoning-effort": { type: "string" },
|
|
29
|
-
"web-search": { type: "boolean" },
|
|
30
|
-
"no-web-search": { type: "boolean" },
|
|
31
|
-
help: { short: "h", type: "boolean" },
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const HELP = `
|
|
36
|
-
ima2 edit <file> --prompt "<text>" [options]
|
|
37
|
-
|
|
38
|
-
Edit an existing image (inpainting-style).
|
|
39
|
-
|
|
40
|
-
Options:
|
|
41
|
-
-p, --prompt <text> Edit instruction (required)
|
|
42
|
-
-q, --quality <low|medium|high>
|
|
43
|
-
-s, --size <WxH>
|
|
44
|
-
-o, --out <file>
|
|
45
|
-
--json
|
|
46
|
-
--model <gpt-5.5|gpt-5.4|gpt-5.4-mini|grok-imagine-image|grok-imagine-image-quality>
|
|
47
|
-
--provider <auto|oauth|api|grok> Provider (oauth = GPT OAuth; grok = xAI Grok)
|
|
48
|
-
--mode <auto|direct> Prompt handling mode. Default: auto
|
|
49
|
-
--moderation <auto|low> Default: low
|
|
50
|
-
--session <id> Apply session style sheet if enabled
|
|
51
|
-
--reasoning-effort <none|low|medium|high|xhigh>
|
|
52
|
-
--web-search / --no-web-search Override default web-search toggle
|
|
53
|
-
`;
|
|
54
|
-
|
|
55
|
-
export default async function editCmd(argv: string[]) {
|
|
56
|
-
const args = parseArgs(argv, SPEC);
|
|
57
|
-
if (args.help) { out(HELP); return; }
|
|
58
|
-
const input = args.positional[0];
|
|
59
|
-
if (!input) die(2, "input image path required");
|
|
60
|
-
if (!args.prompt) die(2, "--prompt is required");
|
|
61
|
-
if (!VALID_MODES.has(String(args.mode))) die(2, "--mode must be one of: auto, direct");
|
|
62
|
-
if (!VALID_MODERATION.has(String(args.moderation))) die(2, "--moderation must be one of: auto, low");
|
|
63
|
-
if (args.provider && !VALID_PROVIDERS.has(String(args.provider))) {
|
|
64
|
-
die(2, "--provider must be one of: auto, oauth, api, grok");
|
|
65
|
-
}
|
|
66
|
-
if (args.model && !KNOWN_IMAGE_MODELS.has(String(args.model))) {
|
|
67
|
-
die(2, "--model must be one of: gpt-5.5, gpt-5.4, gpt-5.4-mini, gpt-5.3-codex-spark, grok-imagine-image, grok-imagine-image-quality");
|
|
68
|
-
}
|
|
69
|
-
const VALID_REASONING = new Set(["none", "low", "medium", "high", "xhigh"]);
|
|
70
|
-
if (args["reasoning-effort"] && !VALID_REASONING.has(String(args["reasoning-effort"]))) {
|
|
71
|
-
die(2, "--reasoning-effort must be one of: none, low, medium, high, xhigh");
|
|
72
|
-
}
|
|
73
|
-
if (args["web-search"] && args["no-web-search"]) {
|
|
74
|
-
die(2, "--web-search and --no-web-search are mutually exclusive");
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
let server;
|
|
78
|
-
try { server = await resolveServer({ serverFlag: args.server }); }
|
|
79
|
-
catch (e) {
|
|
80
|
-
const err = errInfo(e);
|
|
81
|
-
if (args.json) json({ ok: false, error: err.message, code: err.code, status: err.status });
|
|
82
|
-
dieWithError(e);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const imageDataUri = await fileToDataUri(input);
|
|
86
|
-
const imageB64 = imageDataUri.split(",")[1];
|
|
87
|
-
|
|
88
|
-
const timeoutMs = (parseInt(String(args.timeout)) || 180) * 1000;
|
|
89
|
-
const explicitOut = args.out ? String(args.out) : null;
|
|
90
|
-
const requestId = createCliRequestId("req_cli_edit");
|
|
91
|
-
|
|
92
|
-
let resp;
|
|
93
|
-
try {
|
|
94
|
-
const editBody: any = {
|
|
95
|
-
prompt: args.prompt,
|
|
96
|
-
image: imageB64,
|
|
97
|
-
quality: args.quality,
|
|
98
|
-
size: args.size,
|
|
99
|
-
model: args.model,
|
|
100
|
-
mode: args.mode,
|
|
101
|
-
moderation: args.moderation,
|
|
102
|
-
sessionId: args.session,
|
|
103
|
-
requestId,
|
|
104
|
-
};
|
|
105
|
-
if (args["reasoning-effort"]) editBody.reasoningEffort = args["reasoning-effort"];
|
|
106
|
-
if (args.provider) editBody.provider = args.provider;
|
|
107
|
-
if (args["no-web-search"]) editBody.webSearchEnabled = false;
|
|
108
|
-
else if (args["web-search"]) editBody.webSearchEnabled = true;
|
|
109
|
-
resp = await request(server.base, "/api/edit", {
|
|
110
|
-
method: "POST",
|
|
111
|
-
body: editBody,
|
|
112
|
-
timeoutMs,
|
|
113
|
-
headers: { "X-Request-Id": requestId },
|
|
114
|
-
});
|
|
115
|
-
} catch (e) {
|
|
116
|
-
const err = errInfo(e);
|
|
117
|
-
const isTimeout = err.name === "TimeoutError" || err.name === "AbortError";
|
|
118
|
-
if (isTimeout && explicitOut) {
|
|
119
|
-
const result = await recoverGeneratedOutputs(server.base, requestId, {
|
|
120
|
-
explicitOut,
|
|
121
|
-
expectedCount: 1,
|
|
122
|
-
json: Boolean(args.json),
|
|
123
|
-
});
|
|
124
|
-
if (result.recovered) {
|
|
125
|
-
if (args.json) {
|
|
126
|
-
json({ ok: true, requestId, recovered: true, path: result.paths[0] });
|
|
127
|
-
} else {
|
|
128
|
-
out(formatRecoveryHint(result));
|
|
129
|
-
out(color.green("✓ ") + result.paths[0] + color.dim(" (recovered)"));
|
|
130
|
-
}
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
if (!args.json) out(formatRecoveryHint(result));
|
|
134
|
-
}
|
|
135
|
-
if (args.json) json({ ok: false, error: err.message, code: err.code, requestId });
|
|
136
|
-
dieWithError(e);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const image = resp.image;
|
|
140
|
-
if (!image) die(1, "server returned no image");
|
|
141
|
-
const target = explicitOut || `${config.storage.generatedDir}/${defaultOutName(0, 1)}`;
|
|
142
|
-
await dataUriToFile(image, String(target));
|
|
143
|
-
|
|
144
|
-
if (args.json) {
|
|
145
|
-
json({ ok: true, path: target, requestId: resp.requestId, elapsed: resp.elapsed });
|
|
146
|
-
} else {
|
|
147
|
-
out(color.green("✓ ") + target);
|
|
148
|
-
if (resp.elapsed) out(color.dim(`elapsed ${resp.elapsed}s`));
|
|
149
|
-
}
|
|
150
|
-
}
|