codex-copilot-dx 0.10.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +18 -17
  2. package/bin/cli.mjs +24 -3
  3. package/docs/ARCHITECTURE.md +60 -14
  4. package/docs/README.md +3 -0
  5. package/docs/REFERENCE.md +186 -45
  6. package/package.json +2 -2
  7. package/src/adapter.mjs +19 -4
  8. package/src/browser-launch.mjs +22 -0
  9. package/src/claude-client-config.mjs +22 -5
  10. package/src/claude-gateway.mjs +30 -8
  11. package/src/claude-models.mjs +26 -0
  12. package/src/cli-animation.mjs +1 -1
  13. package/src/cli-image.mjs +3 -0
  14. package/src/cli-m365.mjs +1 -1
  15. package/src/cli-options.mjs +11 -6
  16. package/src/cli-table.mjs +1 -1
  17. package/src/client-integration.mjs +5 -1
  18. package/src/dashboard/console.js +141 -0
  19. package/src/dashboard/index.html +105 -52
  20. package/src/dashboard/language.js +103 -0
  21. package/src/dashboard/refresh.js +2 -1
  22. package/src/dashboard/status.js +60 -29
  23. package/src/dashboard/ui.css +49 -0
  24. package/src/dashboard/ui.js +113 -26
  25. package/src/dashboard-api.mjs +72 -7
  26. package/src/dashboard.mjs +1 -0
  27. package/src/image-mcp.mjs +9 -6
  28. package/src/live-models.mjs +11 -3
  29. package/src/log.mjs +13 -11
  30. package/src/m365-settings.mjs +0 -2
  31. package/src/native-prediction-recovery.mjs +1 -0
  32. package/src/native-prediction.mjs +6 -2
  33. package/src/observability.mjs +8 -1
  34. package/src/optional-routes.mjs +2 -2
  35. package/src/provider-metadata.mjs +21 -0
  36. package/src/provider-runtime.mjs +80 -26
  37. package/src/providers/m365-auth.mjs +4 -4
  38. package/src/providers/m365.mjs +10 -2
  39. package/src/response-failures.mjs +1 -1
  40. package/src/service-control.mjs +60 -0
  41. package/src/startup-ui.mjs +4 -3
  42. package/src/terminal-console.mjs +87 -0
  43. package/src/usage-analysis.mjs +1 -1
  44. package/src/usage-analytics.mjs +3 -3
  45. package/src/usage-store.mjs +40 -17
  46. package/src/usage.mjs +14 -7
  47. package/src/user-settings.mjs +21 -0
package/src/usage.mjs CHANGED
@@ -1,14 +1,16 @@
1
1
  import { cliOutputFormat, cliOutputWidth, formatResponsiveCliTable, terminalCell } from "./cli-table.mjs";
2
- import { cacheReadTokens, summarizeUsageLogs, usageCacheHitRate, usageLogPath } from "./usage-store.mjs";
2
+ import { cacheReadTokens, summarizeUsageLogs, usageCacheHitRate, usageLogPath, usageModelGroups } from "./usage-store.mjs";
3
3
 
4
4
  export {
5
5
  usageSummaryVersion,
6
6
  usageLoggingStats,
7
+ runtimeUsageSnapshot,
7
8
  usageLogPath,
8
9
  usageLogMaxBytes,
9
10
  buildResponsesUsageRecord,
10
11
  buildMessagesUsageRecord,
11
12
  usageProvider,
13
+ usageModelGroups,
12
14
  recordUsage,
13
15
  recordResponsesUsage,
14
16
  flushUsageWritesForTests,
@@ -33,10 +35,16 @@ function cacheHitPercent(usage) {
33
35
  return rate === null ? "—" : `${usage.cache_hit_unknown_requests > 0 ? "~" : ""}${(rate * 100).toFixed(1)}%`;
34
36
  }
35
37
 
38
+ function providerSummaryLines(summary) {
39
+ if (summary.provider_filter) return [`Provider: ${summary.provider_filter}`];
40
+ const sources = Object.entries(summary.providers || {}).filter(([, count]) => count > 0);
41
+ return sources.some(([id]) => id !== "github")
42
+ ? [`Providers: ${sources.map(([id, count]) => `${id} ${fmt(count)}`).join(" / ")} (combined totals; use --provider to separate)`] : [];
43
+ }
44
+
36
45
  function formatPlainUsageSummary(summary, filePath, { sanitize = false } = {}) {
37
46
  const lines = [`Usage log: ${filePath}`];
38
- if (summary.provider_filter) lines.push(`Provider: ${summary.provider_filter}`);
39
- else if (summary.providers?.m365) lines.push(`Providers: GitHub ${fmt(summary.providers.github)} / M365 ${fmt(summary.providers.m365)} (combined totals; use --provider to separate)`);
47
+ lines.push(...providerSummaryLines(summary));
40
48
  if (summary.requests === 0) {
41
49
  lines.push("No usage records yet.");
42
50
  return (sanitize ? lines.map((line) => terminalCell(line, { fallback: "" })) : lines).join("\n");
@@ -48,7 +56,7 @@ function formatPlainUsageSummary(summary, filePath, { sanitize = false } = {}) {
48
56
  "",
49
57
  "By model:",
50
58
  );
51
- for (const [model, row] of Object.entries(summary.byModel)) {
59
+ for (const [model, row] of Object.entries(usageModelGroups(summary))) {
52
60
  lines.push(` ${model}: requests=${fmt(row.requests)} input=${fmt(row.input_tokens)} cache_read=${fmt(cacheReadTokens(row))} output=${fmt(row.output_tokens)} total=${fmt(row.total_tokens)} cache_hit=${cacheHitPercent(row)}`);
53
61
  }
54
62
  return (sanitize ? lines.map((line) => terminalCell(line, { fallback: "" })) : lines).join("\n");
@@ -89,7 +97,7 @@ function formatTableUsageSummary(summary, filePath, output) {
89
97
  { key: "total", label: "TOTAL", align: "right" },
90
98
  ];
91
99
  const compactColumns = [columns[0], columns[1], columns[5]];
92
- const modelUsage = Object.entries(summary.byModel)
100
+ const modelUsage = Object.entries(usageModelGroups(summary))
93
101
  .map(([model, row]) => ({ model, row }))
94
102
  .sort(compareModelUsage);
95
103
  const totalUsage = { requests: summary.requests, ...summary.totals };
@@ -107,8 +115,7 @@ function formatTableUsageSummary(summary, filePath, output) {
107
115
  } else {
108
116
  table.compact = false;
109
117
  }
110
- const lines = [`Usage log: ${safePath}`, ...(summary.provider_filter ? [`Provider: ${summary.provider_filter}`]
111
- : summary.providers?.m365 ? [`Providers: GitHub ${fmt(summary.providers.github)} / M365 ${fmt(summary.providers.m365)} (combined totals; use --provider to separate)`] : []), "", table.output];
118
+ const lines = [`Usage log: ${safePath}`, ...providerSummaryLines(summary), "", table.output];
112
119
  if (table.compact) {
113
120
  lines.push(
114
121
  "",
@@ -22,6 +22,7 @@ const AUTO_REVIEW_REASONING_KEY = "auto_review_reasoning";
22
22
  const TERMINAL_ANIMATION_KEY = "terminal_animation";
23
23
  const RESPONSE_HISTORY_MAX_MIB_KEY = "response_history_max_mib";
24
24
  const DECODED_BODY_LIMIT_MIB_KEY = "decoded_body_limit_mib";
25
+ const SERVICE_FLAGS = ["terminal_animation_enabled", "open_webui", "image_enabled", "prediction_enabled"];
25
26
  export const DECODED_BODY_LIMIT_MIN_MIB = RUNTIME_DEFAULTS.maxDecodedBodyBytes / MIB;
26
27
  export const DECODED_BODY_LIMIT_MAX_MIB = 512;
27
28
  export { RESPONSE_HISTORY_MAX_MIB, RESPONSE_HISTORY_MIN_MIB };
@@ -43,6 +44,12 @@ export function readUserSettings({ env = process.env, home = os.homedir(), stric
43
44
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
44
45
  throw invalidSettings(filePath, "expected a JSON object");
45
46
  }
47
+ for (const key of SERVICE_FLAGS) {
48
+ if (Object.hasOwn(parsed, key) && typeof parsed[key] !== "boolean") {
49
+ if (strict) throw invalidSettings(filePath, `${key} must be a boolean`);
50
+ delete parsed[key];
51
+ }
52
+ }
46
53
  if (Object.hasOwn(parsed, AUTO_REVIEW_MODEL_KEY)) {
47
54
  const value = parsed[AUTO_REVIEW_MODEL_KEY];
48
55
  if (typeof value !== "string" || !value.trim()) {
@@ -107,6 +114,20 @@ export function savedAutoReviewModel(options = {}) {
107
114
  return String(settings[AUTO_REVIEW_MODEL_KEY] || "").trim();
108
115
  }
109
116
 
117
+ export function servicePreferences(options = {}) {
118
+ const settings = readUserSettings({ ...options, strict: true });
119
+ return Object.fromEntries(SERVICE_FLAGS.map(key => [key, settings[key] !== false]));
120
+ }
121
+
122
+ export function writeServicePreference(key, value, options = {}) {
123
+ if (!SERVICE_FLAGS.includes(key) || typeof value !== "boolean") throw new Error("Unknown service setting or invalid boolean");
124
+ return withFileLockSync(`${userSettingsPath(options)}.lock`, () => {
125
+ const settings = readUserSettings({ ...options, strict: true });
126
+ const changed = atomicWriteFileIfChangedSync(userSettingsPath(options), `${JSON.stringify({ ...settings, [key]: value }, null, 2)}\n`, { mode: 0o600 });
127
+ return { changed, ...servicePreferences(options) };
128
+ });
129
+ }
130
+
110
131
  export function autoReviewModelPreference({ env = process.env, home = os.homedir() } = {}) {
111
132
  const { model, source } = autoReviewPreference({ env, home });
112
133
  return { model, source };