codex-copilot-dx 1.2.33 → 1.3.1
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 +65 -110
- package/bin/cli.mjs +38 -102
- package/docs/ARCHITECTURE.md +33 -7
- package/docs/README.md +10 -76
- package/docs/REFERENCE.md +147 -1936
- package/package.json +11 -4
- package/src/access-settings.mjs +2 -2
- package/src/adapter.mjs +6 -1
- package/src/auth-credentials.mjs +1 -1
- package/src/auto-review-model.mjs +2 -2
- package/src/claude-gateway.mjs +4 -1
- package/src/cli-animation.mjs +2 -2
- package/src/cli-auth.mjs +3 -3
- package/src/cli-cache.mjs +2 -2
- package/src/cli-command-spec.mjs +260 -58
- package/src/cli-image.mjs +2 -2
- package/src/cli-limits.mjs +2 -2
- package/src/cli-m365.mjs +1 -1
- package/src/cli-management.mjs +7 -3
- package/src/cli-options.mjs +71 -408
- package/src/connection-runtime.mjs +1408 -377
- package/src/context-metrics.mjs +63 -0
- package/src/copilot-token-session.mjs +1 -1
- package/src/dashboard/connections.js +23 -4
- package/src/dashboard/console.js +1 -0
- package/src/dashboard/context.js +124 -0
- package/src/dashboard/flow.js +1 -1
- package/src/dashboard/icons.js +6 -2
- package/src/dashboard/index.html +12 -0
- package/src/dashboard/language.js +23 -0
- package/src/dashboard/ui.css +36 -3
- package/src/dashboard/ui.js +12 -4
- package/src/dashboard-api.mjs +11 -5
- package/src/dashboard.mjs +1 -0
- package/src/doctor.mjs +4 -4
- package/src/image-mcp.mjs +2 -2
- package/src/native-prediction-fix.mjs +1 -1
- package/src/native-prediction-profile.mjs +1 -1
- package/src/native-prediction-windows.mjs +1 -1
- package/src/native-prediction.mjs +6 -6
- package/src/nightly-update.mjs +2 -2
- package/src/optional-routes.mjs +2 -2
- package/src/provider-runtime.mjs +1 -1
- package/src/providers/m365-accounts.mjs +1 -1
- package/src/release-install.mjs +11 -15
- package/src/responses-handler.mjs +3 -0
- package/src/startup-ui.mjs +15 -11
- package/src/stream-performance.mjs +9 -0
- package/src/terminal-console.mjs +5 -4
- package/src/terminal-state.mjs +1 -1
- package/src/usage-store.mjs +2 -1
- package/src/usage.mjs +5 -5
- package/src/windows-command.mjs +2 -2
- package/bin/codex-copilot-dx.mjs +0 -11
- package/src/cli-models.mjs +0 -94
- package/src/legacy-command-warning.mjs +0 -38
package/src/cli-m365.mjs
CHANGED
|
@@ -122,7 +122,7 @@ export async function runM365Command({ action = "status", provider, model, autoR
|
|
|
122
122
|
return result;
|
|
123
123
|
}
|
|
124
124
|
if (!accountId) {
|
|
125
|
-
if (!prompt && (!input.isTTY || !output.isTTY)) throw new Error("Use ccdx m365 account --id ID from ccdx m365 accounts.");
|
|
125
|
+
if (!prompt && (!input.isTTY || !output.isTTY)) throw new Error("Use ccdx source m365 account --id ID from ccdx source m365 accounts.");
|
|
126
126
|
output.write(accounts.map((value, index) => ` ${index + 1}. ${terminalCell(value.login)} / ${terminalCell(value.tenant)}${value.selected ? " [selected]" : value.current_windows ? " [Windows sign-in]" : ""}`).join("\n") + "\n");
|
|
127
127
|
const answer = String(await ask("Choose an account, or q to cancel: ")).trim();
|
|
128
128
|
if (answer === "q") return { cancelled: true };
|
package/src/cli-management.mjs
CHANGED
|
@@ -33,7 +33,7 @@ export function formatManagement(value, { format, output = process.stdout, colum
|
|
|
33
33
|
}
|
|
34
34
|
const scalar = value => value === null || value === undefined ? "Not observed" : value === true ? "Yes" : value === false ? "No" : terminalCell(String(value));
|
|
35
35
|
const lines = (item, indent = "") => Object.entries(item).flatMap(([key, value]) => {
|
|
36
|
-
const label = key.replaceAll("_", " ").replace(/^./, char => char.toUpperCase());
|
|
36
|
+
const label = terminalCell(key.replaceAll("_", " ").replace(/^./, char => char.toUpperCase()));
|
|
37
37
|
if (Array.isArray(value)) {
|
|
38
38
|
if (!value.length) return [`${indent}${label}: None`];
|
|
39
39
|
if (value.every(row => row === null || typeof row !== "object")) return [`${indent}${label}: ${value.map(scalar).join(", ")}`];
|
|
@@ -104,7 +104,7 @@ export async function runManagementCommand(command, options = {}) {
|
|
|
104
104
|
if (flags.format === "json") return print(result);
|
|
105
105
|
const sourceNames = view.sources?.map(source => source.name).join(" · ");
|
|
106
106
|
return [`CCDX ${data.version}${options.version && options.version !== data.version ? ` · installed CLI ${options.version}` : ""}`,
|
|
107
|
-
`
|
|
107
|
+
`Running · up ${terminalUptime(data.uptime_ms)}`, `Web UI: ${baseUrl}`, `Enabled sources: ${view.sources?.length ?? "unknown"}`,
|
|
108
108
|
...(sourceNames ? [sourceNames] : []), "", print(view.clients, [["name", "Client"], ["setup", "Setup"], ["active", "Active"]]), "",
|
|
109
109
|
`Model requests: ${view.requests ?? "unknown"} total · ${view.active ?? "unknown"} active · ${view.outcomes.failed} failed`].join("\n");
|
|
110
110
|
}
|
|
@@ -123,7 +123,11 @@ export async function runManagementCommand(command, options = {}) {
|
|
|
123
123
|
if (!usage) throw new Error("Current-run usage is unavailable.");
|
|
124
124
|
return print(flags.provider ? usage.by_provider?.[flags.provider] || { records: 0 } : usage);
|
|
125
125
|
}
|
|
126
|
-
const { summarizeUsageLogs } = await import("./usage-store.mjs");
|
|
126
|
+
const { summarizeUsageLogs } = await import("./usage-store.mjs");
|
|
127
|
+
const summary = await summarizeUsageLogs(undefined, { ...(flags.provider ? { provider: flags.provider } : {}) });
|
|
128
|
+
if (flags.format === "json") return print(summary);
|
|
129
|
+
const { formatUsageSummary } = await import("./usage.mjs");
|
|
130
|
+
return formatUsageSummary(summary, { format: flags.format || "auto", output });
|
|
127
131
|
}
|
|
128
132
|
if (group === "update") {
|
|
129
133
|
const { dashboardUpdateStatus } = await import("./dashboard-updates.mjs");return print(await dashboardUpdateStatus());
|
package/src/cli-options.mjs
CHANGED
|
@@ -1,364 +1,29 @@
|
|
|
1
1
|
import { parseManagedCommand, managedCommandHelp, rootCommandHelp } from "./cli-command-spec.mjs";
|
|
2
|
-
import { isProviderId } from "./provider-metadata.mjs";
|
|
3
2
|
import { MAX_TIMER_DELAY_MS } from "./runtime-config.mjs";
|
|
4
3
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"--
|
|
14
|
-
"--
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"cache",
|
|
29
|
-
"limits",
|
|
30
|
-
"animation",
|
|
31
|
-
"enable-image",
|
|
32
|
-
"disable-image",
|
|
33
|
-
"image-status",
|
|
34
|
-
"auto-review-model",
|
|
35
|
-
"suggestion",
|
|
36
|
-
"prediction",
|
|
37
|
-
"m365",
|
|
38
|
-
"update",
|
|
39
|
-
"version",
|
|
40
|
-
]);
|
|
41
|
-
|
|
42
|
-
function unexpectedArgs(args) {
|
|
43
|
-
throw new Error(`Unexpected argument${args.length === 1 ? "" : "s"}: ${args.join(" ")}`);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function parseOptions(args, schema) {
|
|
47
|
-
const parsed = {};
|
|
48
|
-
const seen = new Set();
|
|
49
|
-
for (let index = 0; index < args.length; index += 1) {
|
|
50
|
-
const option = args[index];
|
|
51
|
-
const kind = schema.get(option);
|
|
52
|
-
if (!kind || seen.has(option)) unexpectedArgs([option]);
|
|
53
|
-
seen.add(option);
|
|
54
|
-
if (kind === "flag") {
|
|
55
|
-
parsed[option] = true;
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const value = args[index + 1];
|
|
60
|
-
if (value === undefined || !String(value).trim() || String(value).startsWith("-")) {
|
|
61
|
-
throw new Error(`Enter a value for ${option}`);
|
|
62
|
-
}
|
|
63
|
-
parsed[option] = value;
|
|
64
|
-
index += 1;
|
|
65
|
-
}
|
|
66
|
-
return parsed;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function checkedOutputFormat(value) {
|
|
70
|
-
const format = value || "";
|
|
71
|
-
if (!new Set(["table", "plain"]).has(format)) {
|
|
72
|
-
throw new Error(`Format must be table or plain: ${value}`);
|
|
73
|
-
}
|
|
74
|
-
return format;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function outputFormatOption(value) {
|
|
78
|
-
return value ? { outputFormat: checkedOutputFormat(value) } : {};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function baseCommand(command, extra = {}) {
|
|
82
|
-
return {
|
|
83
|
-
command,
|
|
84
|
-
showRequestId: false,
|
|
85
|
-
online: false,
|
|
86
|
-
compat: false,
|
|
87
|
-
...extra,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function checkedHelpTopic(parts = []) {
|
|
92
|
-
const normalized = parts.map((part, index) => {
|
|
93
|
-
return part;
|
|
94
|
-
}).join(" ");
|
|
95
|
-
if (!HELP_TOPICS.has(normalized)) throw new Error(`Unknown help topic: ${parts.join(" ")}`);
|
|
96
|
-
return normalized;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function helpCommand(parts = []) {
|
|
100
|
-
return baseCommand("help", { helpTopic: checkedHelpTopic(parts) });
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function nestedHelp(command, rest) {
|
|
104
|
-
if (!rest.length || !HELP_COMMANDS.has(rest.at(-1))) return null;
|
|
105
|
-
const args = rest.slice(0, -1);
|
|
106
|
-
if (command === "auth") {
|
|
107
|
-
if (args.length > 1) unexpectedArgs(args.slice(1));
|
|
108
|
-
return helpCommand(["auth", ...args]);
|
|
109
|
-
}
|
|
110
|
-
if (args.length) unexpectedArgs(args);
|
|
111
|
-
return helpCommand([command]);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function parseStartOptions(args) {
|
|
115
|
-
if (args.some((option) => RETIRED_CLAUDE_OPTIONS.has(option))) {
|
|
116
|
-
return baseCommand("retired", { integration: "Claude App and Claude Code" });
|
|
117
|
-
}
|
|
118
|
-
const seen = new Set();
|
|
119
|
-
for (const option of args) {
|
|
120
|
-
const kind = START_OPTIONS.get(option);
|
|
121
|
-
if (!kind || seen.has(kind)) unexpectedArgs([option]);
|
|
122
|
-
seen.add(kind);
|
|
123
|
-
}
|
|
124
|
-
return baseCommand("start", {
|
|
125
|
-
showRequestId: seen.has("show-request-id"),
|
|
126
|
-
...(seen.has("no-browser") ? { noBrowser: true } : {}),
|
|
127
|
-
...(seen.has("verbose") ? { verbose: true } : {}),
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export function parseCliArgs(args = []) {
|
|
132
|
-
const [command, ...rest] = args;
|
|
133
|
-
if (!command) return baseCommand("start");
|
|
134
|
-
const helpParts = HELP_COMMANDS.has(command) ? rest : HELP_COMMANDS.has(args.at(-1)) ? args.slice(0, -1) : null;
|
|
135
|
-
if (helpParts && managedCommandHelp(helpParts) !== null) return baseCommand("help", { helpTopic: helpParts.join(" ") });
|
|
136
|
-
if (["app", "config"].includes(command) && !rest.length) return baseCommand("help", { helpTopic: command });
|
|
137
|
-
const managed = parseManagedCommand(args);
|
|
138
|
-
if (managed) return managed.legacy ? parseCliArgs(managed.legacy) : baseCommand("manage", managed);
|
|
139
|
-
|
|
140
|
-
if (command === "reauth") return parseCliArgs(["auth", "reauth", ...rest]);
|
|
141
|
-
if (command === "source") { if (rest.length === 1 && HELP_COMMANDS.has(rest[0])) return helpCommand(["source"]);return parseCliArgs(["m365", "switch", ...rest]); }
|
|
142
|
-
if (command === "web") { if (rest.length === 1 && HELP_COMMANDS.has(rest[0])) return helpCommand(["web"]);if (rest.length) unexpectedArgs(rest);return baseCommand("web"); }
|
|
143
|
-
if (command === "image") {
|
|
144
|
-
if (rest.length === 1 && HELP_COMMANDS.has(rest[0])) return helpCommand(["image"]);
|
|
145
|
-
const [action = "status", ...extra] = rest;
|
|
146
|
-
if (!["status", "pause", "resume"].includes(action)) throw new Error("Choose image status, pause or resume.");
|
|
147
|
-
if (extra.length) unexpectedArgs(extra);
|
|
148
|
-
return baseCommand("image", { action });
|
|
149
|
-
}
|
|
150
|
-
if (command === "doctor" && ["network", "report"].includes(rest[0]) && rest.length === 2 && HELP_COMMANDS.has(rest[1])) return helpCommand(["doctor", rest[0]]);
|
|
151
|
-
if (HELP_COMMANDS.has(command)) {
|
|
152
|
-
const topic = rest;
|
|
153
|
-
if (topic.length > 2) unexpectedArgs(topic.slice(2));
|
|
154
|
-
return helpCommand(topic);
|
|
155
|
-
}
|
|
156
|
-
const profileOptionIndex = rest.indexOf("--profile");
|
|
157
|
-
const requestedProfile = profileOptionIndex >= 0 ? rest[profileOptionIndex + 1] : "";
|
|
158
|
-
const retiredClaudeInvocation = RETIRED_CLAUDE_OPTIONS.has(command)
|
|
159
|
-
|| (command === "start" && rest.some((option) => RETIRED_CLAUDE_OPTIONS.has(option)))
|
|
160
|
-
|| (command === "auth" && rest[0] === "login" && rest[1] === "claude")
|
|
161
|
-
|| (command === "models" && requestedProfile === "claude")
|
|
162
|
-
|| (command === "doctor" && rest[0] !== "config" && ["claude", "all"].includes(requestedProfile));
|
|
163
|
-
if (PM_COMMANDS.has(command)) return baseCommand("retired", { integration: "PM Studio" });
|
|
164
|
-
if (retiredClaudeInvocation) {
|
|
165
|
-
return baseCommand("retired", { integration: "Claude App and Claude Code" });
|
|
166
|
-
}
|
|
167
|
-
if ((command === "doctor" || command === "--doctor") && rest[0] === "config") {
|
|
168
|
-
if (rest.length === 2 && HELP_COMMANDS.has(rest[1])) return helpCommand(["doctor", "config"]);
|
|
169
|
-
if (rest.length > 1) unexpectedArgs(rest.slice(1));
|
|
170
|
-
return baseCommand("doctor", { configOnly: true });
|
|
171
|
-
}
|
|
172
|
-
const requestedHelp = nestedHelp(command, rest);
|
|
173
|
-
if (requestedHelp) return requestedHelp;
|
|
174
|
-
if (VERSION_COMMANDS.has(command)) {
|
|
175
|
-
if (rest.length) unexpectedArgs(rest);
|
|
176
|
-
return baseCommand("version");
|
|
177
|
-
}
|
|
178
|
-
if (command === "start") return parseStartOptions(rest);
|
|
179
|
-
if (command === "m365") {
|
|
180
|
-
const [action = "status", ...args] = rest;
|
|
181
|
-
if (!["status", "models", "switch", "on", "off", "remove", "accounts", "account"].includes(action)) throw new Error("Choose status, models, accounts, account, switch, on, off or remove");
|
|
182
|
-
let provider, remaining = args;
|
|
183
|
-
if (action === "switch" && args[0] && !args[0].startsWith("--")) { provider = args[0];remaining = args.slice(1); }
|
|
184
|
-
if (provider && !["github", "m365"].includes(provider) && !/^api_[a-z0-9_-]{1,60}$/.test(provider)) throw new Error("Choose github, m365 or a listed API source ID");
|
|
185
|
-
const values = parseOptions(remaining, new Map(action === "switch" ? [["--model", "value"], ["--auto-review-model", "value"]] : action === "account" ? [["--id", "value"]] : []));
|
|
186
|
-
if (values["--id"] && !/^[a-f0-9]{64}$/.test(values["--id"])) throw new Error("Use an account ID from ccdx m365 accounts");
|
|
187
|
-
return baseCommand("m365", { action, provider, model: values["--model"], autoReviewModel: values["--auto-review-model"], ...(values["--id"] ? { accountId: values["--id"] } : {}) });
|
|
188
|
-
}
|
|
189
|
-
if (command === "status" || command === "--status") {
|
|
190
|
-
if (rest.length) unexpectedArgs(rest);
|
|
191
|
-
return baseCommand("status");
|
|
192
|
-
}
|
|
193
|
-
if (command === "usage") {
|
|
194
|
-
const options = parseOptions(rest, new Map([["--format", "value"], ["--provider", "value"]]));
|
|
195
|
-
if (options["--provider"] && !isProviderId(options["--provider"])) throw new Error("Enter a valid source ID.");
|
|
196
|
-
return baseCommand("usage", { ...outputFormatOption(options["--format"]), ...(options["--provider"] ? { provider: options["--provider"] } : {}) });
|
|
197
|
-
}
|
|
198
|
-
if (command === "cache") {
|
|
199
|
-
let cacheArgs = rest;
|
|
200
|
-
if (rest.length === 1 && /^-\d+$/.test(rest[0])) {
|
|
201
|
-
cacheArgs = ["--limit", rest[0].slice(1)];
|
|
202
|
-
} else if (rest[0] === "-clean") {
|
|
203
|
-
cacheArgs = ["--clean", ...rest.slice(1)];
|
|
204
|
-
}
|
|
205
|
-
const options = parseOptions(cacheArgs, new Map([
|
|
206
|
-
["--limit", "value"],
|
|
207
|
-
["--clean", "flag"],
|
|
208
|
-
["--history", "flag"],
|
|
209
|
-
["--yes", "flag"],
|
|
210
|
-
]));
|
|
211
|
-
if (options["--limit"] && options["--clean"]) {
|
|
212
|
-
throw new Error("Use either --limit or --clean.");
|
|
213
|
-
}
|
|
214
|
-
if ((options["--history"] || options["--yes"]) && !options["--clean"]) {
|
|
215
|
-
throw new Error("--history and --yes require --clean");
|
|
216
|
-
}
|
|
217
|
-
const rawLimit = options["--limit"];
|
|
218
|
-
if (rawLimit && rawLimit !== "default" && !/^\d+$/.test(rawLimit)) {
|
|
219
|
-
throw new Error(`Cache limit must be an integer MiB value or default: ${rawLimit}`);
|
|
220
|
-
}
|
|
221
|
-
return baseCommand("cache", {
|
|
222
|
-
action: rawLimit ? "limit" : options["--clean"] ? "clean" : "status",
|
|
223
|
-
limitMib: rawLimit && rawLimit !== "default" ? Number(rawLimit) : undefined,
|
|
224
|
-
resetLimit: rawLimit === "default",
|
|
225
|
-
history: Boolean(options["--history"]),
|
|
226
|
-
yes: Boolean(options["--yes"]),
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
if (command === "limits") {
|
|
230
|
-
const limitArgs = rest.length === 1 && /^-\d+$/.test(rest[0])
|
|
231
|
-
? ["--decoded", rest[0].slice(1)]
|
|
232
|
-
: rest;
|
|
233
|
-
const options = parseOptions(limitArgs, new Map([["--decoded", "value"]]));
|
|
234
|
-
const rawLimit = options["--decoded"];
|
|
235
|
-
if (rawLimit && rawLimit !== "default" && !/^\d+$/.test(rawLimit)) {
|
|
236
|
-
throw new Error(`Decoded request-body limit must be an integer MiB value or default: ${rawLimit}`);
|
|
237
|
-
}
|
|
238
|
-
return baseCommand("limits", {
|
|
239
|
-
action: rawLimit ? "set" : "status",
|
|
240
|
-
limitMib: rawLimit && rawLimit !== "default" ? Number(rawLimit) : undefined,
|
|
241
|
-
resetLimit: rawLimit === "default",
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
if (PM_COMMANDS.has(command)) {
|
|
245
|
-
return baseCommand("retired", { integration: "PM Studio" });
|
|
246
|
-
}
|
|
247
|
-
if (command === "models") {
|
|
248
|
-
const options = parseOptions(rest, new Map([
|
|
249
|
-
["--profile", "value"],
|
|
250
|
-
["--format", "value"],
|
|
251
|
-
]));
|
|
252
|
-
const profile = options["--profile"];
|
|
253
|
-
if (profile === "claude") {
|
|
254
|
-
return baseCommand("retired", { integration: "Claude App and Claude Code" });
|
|
255
|
-
}
|
|
256
|
-
if (profile && profile !== "codex") throw new Error(`Profile must be codex: ${profile}`);
|
|
257
|
-
return {
|
|
258
|
-
...baseCommand("models"),
|
|
259
|
-
...outputFormatOption(options["--format"]),
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
if (command === "auth") {
|
|
263
|
-
const [action = "status", ...authArgs] = rest;
|
|
264
|
-
if (["login", "reauth", "check", "logout"].includes(action)) {
|
|
265
|
-
const values = authArgs[0] === "github" || authArgs[0] === "codex" ? authArgs.slice(1) : authArgs;
|
|
266
|
-
const options = parseOptions(values, new Map(action === "logout" ? [["--yes", "flag"]]
|
|
267
|
-
: action === "check" ? [["--format", "value"]] : [["--login", "value"], ["--reauth", "flag"]]));
|
|
268
|
-
if (options["--login"] && !/^[a-z\d_-]{1,39}$/i.test(options["--login"])) throw new Error("Enter a GitHub account name.");
|
|
269
|
-
return baseCommand("auth", { action, ...(options["--yes"] ? { yes: true } : {}),
|
|
270
|
-
...(options["--reauth"] ? { reauth: true } : {}), ...(options["--login"] ? { expectedLogin: options["--login"] } : {}),
|
|
271
|
-
...(options["--format"] ? outputFormatOption(options["--format"]) : {}) });
|
|
272
|
-
}
|
|
273
|
-
if (action === "status") {
|
|
274
|
-
const options = parseOptions(authArgs, new Map([
|
|
275
|
-
["--online", "flag"],
|
|
276
|
-
["--format", "value"],
|
|
277
|
-
]));
|
|
278
|
-
return {
|
|
279
|
-
...baseCommand("auth"),
|
|
280
|
-
action: "status",
|
|
281
|
-
profile: "",
|
|
282
|
-
online: Boolean(options["--online"]),
|
|
283
|
-
expectedLogin: "",
|
|
284
|
-
reauth: false,
|
|
285
|
-
...outputFormatOption(options["--format"]),
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
throw new Error(`Unknown auth action: ${action}`);
|
|
289
|
-
}
|
|
290
|
-
if (command === "animation") {
|
|
291
|
-
if (rest.length) unexpectedArgs(rest);
|
|
292
|
-
return baseCommand("animation");
|
|
293
|
-
}
|
|
294
|
-
if (command === "prediction") {
|
|
295
|
-
const [action = "status", ...extra] = rest;
|
|
296
|
-
if (!["on", "off", "status", "fix", "pause", "resume"].includes(action)) throw new Error("Choose prediction on, off, status, fix, pause or resume.");
|
|
297
|
-
if (extra.length) unexpectedArgs(extra);
|
|
298
|
-
return baseCommand("prediction", { action });
|
|
299
|
-
}
|
|
300
|
-
if (command === "suggestion") {
|
|
301
|
-
const [action = "status", model, ...extra] = rest;
|
|
302
|
-
if (!["on", "off", "model", "status"].includes(action)) throw new Error("Suggestion action must be on, off, model, or status");
|
|
303
|
-
if (extra.length || (model !== undefined && action !== "model")) unexpectedArgs(rest.slice(1));
|
|
304
|
-
if (["on", "model"].includes(action)) throw new Error("The CCDX prediction panel has been retired; use ccdx prediction for the separate optional native feature");
|
|
305
|
-
return baseCommand("suggestion", { action });
|
|
306
|
-
}
|
|
307
|
-
if (command === "enable-image" || command === "disable-image" || command === "image-status") {
|
|
308
|
-
if (rest.length) unexpectedArgs(rest);
|
|
309
|
-
return baseCommand("image", {
|
|
310
|
-
action: command === "enable-image" ? "enable" : command === "disable-image" ? "disable" : "status",
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
if (command === "auto-review-model") {
|
|
314
|
-
if (rest.length) unexpectedArgs(rest);
|
|
315
|
-
return baseCommand("auto-review-model");
|
|
316
|
-
}
|
|
317
|
-
if (command === "update") {
|
|
318
|
-
const permission = rest.filter(value => value === "--allow-remote");
|
|
319
|
-
if (permission.length > 1) throw new Error("--allow-remote may be specified only once");
|
|
320
|
-
const sources = rest.filter(value => value !== "--allow-remote");
|
|
321
|
-
if (sources.length > 1) unexpectedArgs(sources.slice(1));
|
|
322
|
-
const source = sources[0];
|
|
323
|
-
if (source && !new Set(["npm", "github", "gh"]).has(source)) {
|
|
324
|
-
throw new Error(`Choose npm or github. Received: ${source}`);
|
|
325
|
-
}
|
|
326
|
-
return {
|
|
327
|
-
...baseCommand("update"),
|
|
328
|
-
updateSource: source === "gh" ? "github" : source,
|
|
329
|
-
allowRemote: permission.length === 1,
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
if (command === "doctor" || command === "--doctor") {
|
|
333
|
-
if (["network", "report"].includes(rest[0])) {
|
|
334
|
-
if (rest.length > 1) unexpectedArgs(rest.slice(1));
|
|
335
|
-
return baseCommand("doctor", { tool: rest[0] });
|
|
336
|
-
}
|
|
337
|
-
const options = parseOptions(rest, new Map([
|
|
338
|
-
["--online", "flag"],
|
|
339
|
-
["--compat", "flag"],
|
|
340
|
-
["--fix", "flag"],
|
|
341
|
-
["--json", "flag"],
|
|
342
|
-
["--profile", "value"],
|
|
343
|
-
]));
|
|
344
|
-
const profile = options["--profile"];
|
|
345
|
-
if (profile === "claude" || profile === "all") {
|
|
346
|
-
return baseCommand("retired", { integration: "Claude App and Claude Code" });
|
|
347
|
-
}
|
|
348
|
-
if (profile && profile !== "codex") throw new Error(`Profile must be codex: ${profile}`);
|
|
349
|
-
return {
|
|
350
|
-
...baseCommand("doctor"),
|
|
351
|
-
online: Boolean(options["--online"]),
|
|
352
|
-
compat: Boolean(options["--compat"]),
|
|
353
|
-
...(options["--fix"] ? { fix: true } : {}),
|
|
354
|
-
...(options["--json"] ? { json: true } : {}),
|
|
355
|
-
};
|
|
356
|
-
}
|
|
357
|
-
if (RETIRED_CLAUDE_OPTIONS.has(command)) {
|
|
358
|
-
return baseCommand("retired", { integration: "Claude App and Claude Code" });
|
|
359
|
-
}
|
|
360
|
-
if (START_OPTIONS.has(command)) return parseStartOptions([command, ...rest]);
|
|
361
|
-
throw new Error(`Unknown command or option: ${command}`);
|
|
4
|
+
const base = value => ({ command: "manage", showRequestId: false, online: false, compat: false, ...value });
|
|
5
|
+
export function parseCliArgs(input = []) {
|
|
6
|
+
let args = [...input];
|
|
7
|
+
if (
|
|
8
|
+
!args.length ||
|
|
9
|
+
(args[0].startsWith("--") && ["--no-browser", "--verbose", "--show-request-id"].includes(args[0]))
|
|
10
|
+
)
|
|
11
|
+
args.unshift("start");
|
|
12
|
+
if (["--version", "-v"].includes(args[0])) args[0] = "version";
|
|
13
|
+
const help = ["help", "--help", "-h"].includes(args[0])
|
|
14
|
+
? args.slice(1)
|
|
15
|
+
: ["--help", "-h"].includes(args.at(-1))
|
|
16
|
+
? args.slice(0, -1)
|
|
17
|
+
: null;
|
|
18
|
+
if (help) {
|
|
19
|
+
if (help.length && managedCommandHelp(help) === null)
|
|
20
|
+
throw new Error(`Unknown help topic: ${help.join(" ")}`);
|
|
21
|
+
return base({ command: "help", helpTopic: help.join(" ") });
|
|
22
|
+
}
|
|
23
|
+
if (["app", "config", "source"].includes(args[0]) && args.length === 1)
|
|
24
|
+
return base({ command: "help", helpTopic: args[0] });
|
|
25
|
+
const parsed = parseManagedCommand(args);
|
|
26
|
+
return base(parsed.dispatch || parsed);
|
|
362
27
|
}
|
|
363
28
|
|
|
364
29
|
function integerEnv(env, name, fallback, { min, max = Number.MAX_SAFE_INTEGER }) {
|
|
@@ -383,12 +48,30 @@ export function parseAdapterAddressOptions(env = process.env) {
|
|
|
383
48
|
export function parseRuntimeOptions(env = process.env) {
|
|
384
49
|
return {
|
|
385
50
|
...parseAdapterAddressOptions(env),
|
|
386
|
-
modelRefreshTimeoutMs: integerEnv(env, "CCDX_MODEL_REFRESH_TIMEOUT_MS", 5000, {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
51
|
+
modelRefreshTimeoutMs: integerEnv(env, "CCDX_MODEL_REFRESH_TIMEOUT_MS", 5000, {
|
|
52
|
+
min: 1,
|
|
53
|
+
max: MAX_TIMER_DELAY_MS,
|
|
54
|
+
}),
|
|
55
|
+
existingAdapterTimeoutMs: integerEnv(env, "CCDX_EXISTING_ADAPTER_TIMEOUT_MS", 500, {
|
|
56
|
+
min: 1,
|
|
57
|
+
max: MAX_TIMER_DELAY_MS,
|
|
58
|
+
}),
|
|
59
|
+
modelRefreshIntervalMs: integerEnv(env, "CCDX_MODEL_REFRESH_INTERVAL_MS", 2 * 60 * 60 * 1000, {
|
|
60
|
+
min: 0,
|
|
61
|
+
max: MAX_TIMER_DELAY_MS,
|
|
62
|
+
}),
|
|
63
|
+
upstreamTimeoutMs: integerEnv(env, "CCDX_UPSTREAM_TIMEOUT_MS", 120000, {
|
|
64
|
+
min: 1,
|
|
65
|
+
max: MAX_TIMER_DELAY_MS,
|
|
66
|
+
}),
|
|
67
|
+
streamHandshakeTimeoutMs: integerEnv(env, "CCDX_STREAM_HANDSHAKE_TIMEOUT_MS", 120000, {
|
|
68
|
+
min: 1,
|
|
69
|
+
max: MAX_TIMER_DELAY_MS,
|
|
70
|
+
}),
|
|
71
|
+
streamIdleTimeoutMs: integerEnv(env, "CCDX_STREAM_IDLE_TIMEOUT_MS", 120000, {
|
|
72
|
+
min: 1,
|
|
73
|
+
max: MAX_TIMER_DELAY_MS,
|
|
74
|
+
}),
|
|
392
75
|
shutdownTimeoutMs: integerEnv(env, "CCDX_SHUTDOWN_TIMEOUT_MS", 5000, { min: 1, max: MAX_TIMER_DELAY_MS }),
|
|
393
76
|
};
|
|
394
77
|
}
|
|
@@ -396,7 +79,10 @@ export function parseRuntimeOptions(env = process.env) {
|
|
|
396
79
|
export function parseAdapterProbeOptions(env = process.env) {
|
|
397
80
|
return {
|
|
398
81
|
...parseAdapterAddressOptions(env),
|
|
399
|
-
existingAdapterTimeoutMs: integerEnv(env, "CCDX_EXISTING_ADAPTER_TIMEOUT_MS", 500, {
|
|
82
|
+
existingAdapterTimeoutMs: integerEnv(env, "CCDX_EXISTING_ADAPTER_TIMEOUT_MS", 500, {
|
|
83
|
+
min: 1,
|
|
84
|
+
max: MAX_TIMER_DELAY_MS,
|
|
85
|
+
}),
|
|
400
86
|
};
|
|
401
87
|
}
|
|
402
88
|
|
|
@@ -404,49 +90,26 @@ export function cliCommandName() {
|
|
|
404
90
|
return "ccdx";
|
|
405
91
|
}
|
|
406
92
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
"
|
|
416
|
-
|
|
417
|
-
"auth status": `Usage:\n ${name} auth status [--online] [--format table|plain]\n\n- Shows the saved GitHub Copilot account without exposing credentials.\n- --online also verifies its entitlement and model catalog.\n- Interactive terminals use a table by default.`,
|
|
418
|
-
doctor: `Usage:\n ${name} doctor [--online] [--compat] [--fix] [--json]\n ${name} doctor config\n\n- Checks credentials, managed configuration, command launchers, adapter, enabled optional features and observed client catalog.\n- Default is read-only; no inference requests.\n- --online validates account entitlement; --compat sends minimal inference requests and consumes a small amount of Copilot usage, requiring successful model completion rather than HTTP 200 alone.\n- --fix repairs owned Windows launchers and managed config, imports a verified existing credential only if none is saved, and asks the running adapter to repair enabled predictions once.\n- No interactive login, client program edits, forced App restarts, policy changes or optional feature activation.\n- Missing-credential repair can contact GitHub without --online.\n- Changed existing config is backed up to config.toml.ccdx-doctor.bak.\n- Partial repairs exit 1.\n- --json emits a redacted report, including before_checks for repairs.\n- App-internal cache and visible predictions are not externally verified.\n- The config subcommand remains strictly read-only.`,
|
|
419
|
-
"doctor config": `Usage:\n ${name} doctor config\n\n- Reads ~/.codex/config.toml, checks TOML syntax and CCDX-managed settings, and previews the existing startup writer's changes.\n- Does not merge Codex profiles or validate the complete installed Codex schema.\n- No authentication, network requests, file writes, or adapter/GUI startup.\n- Existing context_management=false is valid.\n- Exit 1 for errors, 0 for OK/warnings; unsupported arguments exit 2.`,
|
|
420
|
-
status: `Usage:\n ${name} status\n\n- Shows bounded runtime, routing, performance, queue, and cache metrics from a running adapter.`,
|
|
421
|
-
models: `Usage:\n ${name} models [--format table|plain]\n\n- Shows GPT models for the selected Codex provider.\n- GitHub performs a fresh read-only lookup; M365 uses its isolated catalog in the running service.\n- Interactive terminals use a table by default.`,
|
|
422
|
-
usage: `Usage:\n ${name} usage [--format table|plain] [--provider ID]\n\n- Summarizes local token usage metadata without reading prompt or completion content.\n- Optional provider filtering separates sources; default totals include all recorded sources.\n- Interactive terminals use a table by default.`,
|
|
423
|
-
cache: `Usage:\n ${name} cache\n ${name} cache --limit <MiB|default>\n ${name} cache --clean [--history] [--yes]\n\n- Shows runtime cache use, saves and applies the shared response-history limit, or clears the rebuildable image-transform cache.\n- --history also clears in-memory response history for all tasks and can make their next continuation fail, so interactive confirmation or --yes is required.\n- Generated image files and saved Codex transcripts are never deleted.\n- Short aliases: -128 sets 128 MiB and -clean equals --clean.`,
|
|
424
|
-
limits: `Usage:\n ${name} limits\n ${name} limits --decoded <MiB|default>\n\n- Shows configured and running request-body limits, or saves a decoded request-body limit from 128 to 512 MiB.\n- The raw-body limit is unchanged.\n- Restart ccdx to apply a saved change; no conversation or cache is cleared.\n- Short alias: -256 sets 256 MiB.`,
|
|
425
|
-
animation: `Usage:\n ${name} animation\n\n- Previews all terminal activity animations together and selects the saved theme.\n- Running CCDX 1.1.0+ applies it live; older services need a restart.`,
|
|
426
|
-
"enable-image": `Usage:\n ${name} enable-image\n\n- Interactively configures an HTTPS image API endpoint (base URLs are also accepted) and API key, detects its supported image model and protocol, installs CCDX image guidance, and checks the local image tool for Codex App without generating an image.\n- A blank key preserves the saved key only for the same origin; a new origin requires explicit key entry.\n- Concurrent unrelated config edits are preserved.`,
|
|
427
|
-
"disable-image": `Usage:\n ${name} disable-image\n\n- Disables the local CCDX image tool and removes its stored API credential and unmodified CCDX image guidance.`,
|
|
428
|
-
"image-status": `Usage:\n ${name} image-status\n\n- Shows provider configuration and locally advertised generation/editing tools without generating an image or exposing its API key.`,
|
|
429
|
-
"auto-review-model": `Usage:\n ${name} auto-review-model\n\n- Select a Responses model, then an advertised reasoning effort.\n- Enter keeps the default/current choice; q cancels both steps without saving.\n- Effort 0 follows the client (low when omitted).\n- Settings apply only to Auto-review on the next request; no client patch or restart is required for adapters running 0.9.13 or newer.`,
|
|
430
|
-
"suggestion": `The CCDX prediction panel has been retired. Run ${name} suggestion off to safely remove unchanged CCDX registrations. This cleanup does not change native predictions; see ${name} prediction --help for that separate opt-in feature.`,
|
|
431
|
-
m365: `Usage:\n ${name} m365 [status|models|accounts|account|on|off|remove]\n ${name} m365 account [--id ID]\n ${name} m365 switch [github|m365] [--model ID] [--auto-review-model ID]\n\n- M365 is discovered silently at startup on supported managed environments.\n- accounts lists local company accounts without requesting tokens.\n- account chooses a company account; --id supports scripts. A running updated service is required.\n- Saved bindings stay selected. Otherwise an exact Windows sign-in match, then a single company account, is used.\n- Changing accounts applies to M365 in Codex and Claude; start a new conversation.\n- Claude uses /anthropic on the same local port.\n- Codex stays on GitHub unless you explicitly switch.\n- M365 switching requires a running compatible adapter and available GPT/Auto-review choices; it never substitutes unavailable models.\n- Select an available model in Codex after switching an existing thread.\n- Off restores only owned Claude settings and selects GitHub.\n- Remove also clears the CCDX M365 profile, retaining a disabled preference and historical usage.\n- System Microsoft sign-in, GitHub credentials, predictions and images are preserved.`,
|
|
432
|
-
prediction: `Usage:\n ${name} prediction [status|on|off|fix|pause|resume]\n\n- Pause/resume only pauses adaptation; trust and route setup are kept.\n- Resume does not activate a feature that has not been set up.\n- Optional native next-message predictions; off by default. macOS and Windows.\n- Windows requires the registered official MSIX App, an initialized profile, Windows PowerShell and .NET Framework 4.7.2+; Git/OpenSSL is not required for prediction setup.\n- Quit Codex before on/off, then restart ccdx.\n- On adds private App-profile certificate trust and an App-only route for chatgpt.com and ab.chatgpt.com.\n- HTTPS on those hosts is decrypted locally; only prediction configuration is changed.\n- No client program files, OS trust, account permissions, MCP or Hooks are changed.\n- Static HTTP/HTTPS/SOCKS5 proxies and bypass rules are preserved.\n- Windows supports company PAC/WPAD; macOS dynamic PAC/WPAD remains unsupported.\n- Static IPv4/IPv6 CIDRs match URL IP literals without DNS.\n- The bridge port persists across restarts/updates; a busy saved port disables only predictions.\n- Launch/reuse checks the App's actual route; an older random or missing route may require one full App quit.\n- Official prediction configuration is preserved; the conversation's model is used.\n- App updates require another compatibility check.\n- Status distinguishes saved preference and observed config traffic from unverified candidate visibility.\n- Fix asks a compatible running CCDX adapter to repair the enabled bridge once on its saved port.\n- It never enables predictions, renews certificates or force-restarts Codex.\n- Healthy unchanged bridges are retained.\n- Fix rechecks system proxy settings.\n- Changed routes may need a normal App relaunch to reload cached PAC; failed rechecks preserve the previous bridge with a nonzero exit.\n- Process environment variables and Node trust are not hot-reloaded; changed trust inputs need a CCDX service restart.\n- Startup, status and doctor share sanitized environment diagnostics.\n- Missing App routes require a normal full quit and ccdx launch; partial repair exits 1.\n- An older adapter must first be upgraded and restarted once to gain this repair endpoint.`,
|
|
433
|
-
update: `Usage:\n ${name} update [npm|github] [--allow-remote]\n\n- Updates the global package from the configured npm registry or the latest stable GitHub release.\n- With no source, an interactive terminal prompts for one.\n- Windows uses system cmd.exe to run npm.cmd without changing PowerShell policy; use the .cmd entrypoint if scripts are blocked.\n- GitHub verifies a Release tarball; Git is not required. Dependencies use the configured npm registry.\n- By default npm's remote-download policy is preserved.\n- If npm reports EALLOWREMOTE for a trusted mirror tarball, --allow-remote explicitly permits URL dependencies for this one installation's entire dependency tree; it is not a hostname allowlist.\n- No .npmrc, registry or persistent policy is changed. GitHub updates retry once offline with a verified same-version platform package only after EALLOWREMOTE; other errors are not retried.\n- Use this only if company policy permits it.\n- Restart the running adapter after installation.`,
|
|
434
|
-
version: `Usage:\n ${name} --version`,
|
|
435
|
-
};
|
|
436
|
-
return sections[topic];
|
|
437
|
-
}
|
|
438
|
-
|
|
93
|
+
const integrationNotes = {
|
|
94
|
+
prediction:
|
|
95
|
+
"Optional native suggestions are off by default. Windows requires the initialized official MSIX App profile, Windows PowerShell and .NET Framework 4.7.2+; Git/OpenSSL is not required. The bridge port persists across restarts/updates; a busy saved port disables predictions only. Setup/removal requires Codex to be closed, then a normal CCDX restart. HTTPS on chatgpt.com and ab.chatgpt.com is decrypted locally; only prediction configuration is changed. App-profile trust and routing are used; no OS trust or client program files are changed. Proxy/PAC policy is preserved. Repair never enables predictions or force-restarts Codex. Environment trust changes require a service restart.",
|
|
96
|
+
image:
|
|
97
|
+
"Setup configures the image API and private credential without generating an image. An empty key keeps the saved key only for the same origin. Pause keeps credentials; remove deletes the stored image credential and unchanged CCDX guidance.",
|
|
98
|
+
review:
|
|
99
|
+
"Select an available model and reasoning level. Enter keeps the choice; q cancels without saving. The next review request uses the saved choice.",
|
|
100
|
+
doctor:
|
|
101
|
+
"Default checks are read-only and do not send inference. --online checks access; --compat sends minimal inference and consumes usage. --fix changes only owned configuration and launchers, backs up changed config, and never enables optional features or force-restarts Apps. Missing-credential repair can contact GitHub. Partial repairs exit 1.",
|
|
102
|
+
};
|
|
439
103
|
export function cliHelp(commandName = "ccdx", topic = "") {
|
|
440
104
|
if (!topic) return rootCommandHelp();
|
|
441
|
-
const parts = topic.split(" "),
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
return topicHelp("ccdx", checkedHelpTopic(topic.split(" ")));
|
|
105
|
+
const parts = topic.split(" "),
|
|
106
|
+
help = managedCommandHelp(parts);
|
|
107
|
+
if (help === null) throw new Error(`Unknown help topic: ${topic}`);
|
|
108
|
+
const feature =
|
|
109
|
+
parts[0] === "app" && parts[1] === "codex"
|
|
110
|
+
? parts[2]
|
|
111
|
+
: parts[0] === "doctor" && parts.length === 1
|
|
112
|
+
? "doctor"
|
|
113
|
+
: null;
|
|
114
|
+
return help + (integrationNotes[feature] ? "\n\n" + integrationNotes[feature] : "");
|
|
452
115
|
}
|