codex-copilot-dx 1.4.4 → 1.4.5

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 (64) hide show
  1. package/README.md +2 -1
  2. package/bin/cli.mjs +5 -4
  3. package/docs/ARCHITECTURE.md +16 -0
  4. package/docs/REFERENCE.md +34 -8
  5. package/package.json +1 -1
  6. package/src/access-settings.mjs +3 -1
  7. package/src/adapter.mjs +9 -1
  8. package/src/antigravity-chat-bridge.mjs +4 -2
  9. package/src/antigravity-handler.mjs +28 -16
  10. package/src/antigravity-images.mjs +3 -2
  11. package/src/antigravity-runtime.mjs +13 -3
  12. package/src/application-configuration.mjs +43 -0
  13. package/src/application-control.mjs +114 -0
  14. package/src/application-evidence.mjs +42 -0
  15. package/src/application-process.mjs +114 -0
  16. package/src/claude-gateway.mjs +24 -15
  17. package/src/cli-command-spec.mjs +7 -4
  18. package/src/cli-management.mjs +27 -2
  19. package/src/codex-image-host-launch.mjs +1 -2
  20. package/src/codex-launch-control.mjs +7 -7
  21. package/src/connection-management.mjs +18 -3
  22. package/src/connection-policy.mjs +3 -1
  23. package/src/connection-routing.mjs +7 -2
  24. package/src/connection-runtime.mjs +21 -5
  25. package/src/connection-view.mjs +9 -3
  26. package/src/context-compaction-wire.mjs +7 -6
  27. package/src/context-compaction.mjs +6 -4
  28. package/src/copilot-client.mjs +17 -13
  29. package/src/copilot-responses-compat.mjs +1 -0
  30. package/src/copilot-web.mjs +6 -2
  31. package/src/dashboard/applications.js +83 -0
  32. package/src/dashboard/connections.js +52 -14
  33. package/src/dashboard/console.js +19 -9
  34. package/src/dashboard/gemini.js +8 -5
  35. package/src/dashboard/index.html +16 -0
  36. package/src/dashboard/language.js +41 -0
  37. package/src/dashboard/ui.css +9 -0
  38. package/src/dashboard-api.mjs +6 -1
  39. package/src/dashboard.mjs +1 -0
  40. package/src/gemini-app.mjs +3 -2
  41. package/src/http-transport.mjs +5 -2
  42. package/src/launcher.mjs +6 -5
  43. package/src/native-images.mjs +1 -1
  44. package/src/provider-runtime.mjs +14 -9
  45. package/src/providers/api.mjs +18 -12
  46. package/src/providers/m365.mjs +9 -5
  47. package/src/request-admission.mjs +6 -0
  48. package/src/responses-bridge.mjs +5 -2
  49. package/src/responses-handler.mjs +2 -0
  50. package/src/responses-proxy.mjs +9 -4
  51. package/src/safe-upstream-error.mjs +9 -11
  52. package/src/service-control.mjs +29 -5
  53. package/src/settings-preferences.mjs +3 -3
  54. package/src/source-admission-state.mjs +29 -0
  55. package/src/source-admission.mjs +310 -0
  56. package/src/source-discovery-probe.mjs +35 -0
  57. package/src/source-discovery.mjs +112 -0
  58. package/src/source-response.mjs +134 -0
  59. package/src/source-transport.mjs +19 -0
  60. package/src/stream-contract.mjs +3 -1
  61. package/src/stream-performance.mjs +3 -1
  62. package/src/stream.mjs +6 -4
  63. package/src/upstream-body.mjs +9 -8
  64. package/src/user-settings.mjs +2 -2
@@ -13,7 +13,7 @@ const TERMINAL_OUTCOMES = Object.freeze(["completed", "incomplete", "failed", "c
13
13
  const INCOMPLETE_REASONS = new Set(["max_output_tokens", "max_messages", "content_filter", "steered"]);
14
14
  const TERMINAL_ORIGINS = new Set([
15
15
  "upstream_response", "upstream_event", "chat_completion", "client_validation",
16
- "upstream_http", "transport", "privacy", "client_disconnect", "unclassified",
16
+ "upstream_http", "transport", "privacy", "source_admission", "client_disconnect", "unclassified",
17
17
  ]);
18
18
  const MAX_MODEL_OUTCOME_LABELS = 32;
19
19
  const MAX_RECENT_REQUESTS = 20;
@@ -357,6 +357,8 @@ export function createStreamPerformanceMetrics({ now = () => performance.now(),
357
357
  attemptTimings() { return attemptTimings.map(attempt => ({ ...attempt })); },
358
358
  observeContext(values) {
359
359
  if (finished || !values || typeof values !== "object") return;
360
+ if (Number.isSafeInteger(values.source_queue_ms) && values.source_queue_ms >= 0) context.source_queue_ms = values.source_queue_ms;
361
+ if (values.delivery_cancelled === 1) context.delivery_cancelled = 1;
360
362
  if (Number.isSafeInteger(values.cached_input_tokens) && values.cached_input_tokens >= 0) cachedInput = values.cached_input_tokens;
361
363
  for (const key of [...Object.keys(context), "compaction", "requested_model", "reasoning_effort_requested", "reasoning_effort_sent", "usage_state", "capability_revision", "capability_constraints", "privacy_count", "privacy_ms", "privacy_state", "privacy_pending_bytes", "privacy_new_bytes", "privacy_pending_windows", "privacy_wait_budget_ms", "privacy_error", "privacy_event_type", "privacy_channel_type", "privacy_buffered_bytes", "privacy_terminal_seen", "client_tool_errors_received"]) {
362
364
  const value = values[key];
package/src/stream.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  // Yield fetch Response body lines while preserving SSE semantics for callers.
2
2
  // Handle LF, CRLF and CR endings, and release the reader if iteration stops early.
3
3
  import { loadRuntimeConfig } from "./runtime-config.mjs";
4
+ import { sourceResponseReader, observeSourceRead, failSourceRead, cancelSourceReader, releaseSourceReader } from "./source-response.mjs";
4
5
 
5
6
  const MAX_SSE_BUFFER_BYTES = loadRuntimeConfig().maxSseBufferBytes;
6
7
 
@@ -15,14 +16,15 @@ function appendLineFragment(parts, fragment, currentBytes, maxBufferBytes) {
15
16
  }
16
17
 
17
18
  export async function* webStreamLines(response, { onChunk, maxBufferBytes = MAX_SSE_BUFFER_BYTES } = {}) {
18
- const reader = response.body.getReader();
19
+ const reader = sourceResponseReader(response);
19
20
  const decoder = new TextDecoder();
20
21
  let lineParts = [];
21
22
  let lineBytes = 0;
22
23
  let skipLF = false, bareCR = false;
23
24
  try {
24
25
  while (true) {
25
- const { done, value } = await reader.read();
26
+ let next;try { next = await reader.read(); } catch (error) { failSourceRead(reader);throw error; }
27
+ observeSourceRead(reader, next);const { done, value } = next;
26
28
  if (done) break;
27
29
  onChunk?.(value);
28
30
  const decoded = decoder.decode(value, { stream: true });
@@ -83,7 +85,7 @@ export async function* webStreamLines(response, { onChunk, maxBufferBytes = MAX_
83
85
  yield !bareCR && line.endsWith("\r") ? line.slice(0, -1) : line;
84
86
  }
85
87
  } finally {
86
- await reader.cancel().catch(() => {});
87
- reader.releaseLock();
88
+ await cancelSourceReader(reader).catch(() => {});
89
+ releaseSourceReader(reader);
88
90
  }
89
91
  }
@@ -1,4 +1,5 @@
1
1
  import { httpError } from "./http-errors.mjs";
2
+ import { sourceResponseReader, observeSourceRead, failSourceRead, cancelSourceReader, releaseSourceReader, cancelSourceResponse, hasSourceReader } from "./source-response.mjs";
2
3
 
3
4
  export const MAX_UPSTREAM_ERROR_BODY_BYTES = 1024 * 1024;
4
5
  export const MAX_UPSTREAM_MODEL_CATALOG_BYTES = 8 * 1024 * 1024;
@@ -31,7 +32,7 @@ function unreadableUpstreamBody(label) {
31
32
  }
32
33
 
33
34
  async function cancelResponseBody(response) {
34
- try { await response?.body?.cancel?.(); } catch {}
35
+ try { await cancelSourceResponse(response); } catch {}
35
36
  }
36
37
 
37
38
  function responseAbortError(signal) {
@@ -42,7 +43,7 @@ function responseAbortError(signal) {
42
43
  }
43
44
 
44
45
  export function readResponseChunk(reader, signal) {
45
- if (!signal) return reader.read();
46
+ if (!signal) return hasSourceReader(reader) ? reader.read().then(value => { observeSourceRead(reader, value);return value; }, error => { failSourceRead(reader);throw error; }) : reader.read();
46
47
  if (signal.aborted) return Promise.reject(responseAbortError(signal));
47
48
  return new Promise((resolve, reject) => {
48
49
  let settled = false;
@@ -54,13 +55,13 @@ export function readResponseChunk(reader, signal) {
54
55
  };
55
56
  const onAbort = () => {
56
57
  const error = responseAbortError(signal);
57
- try { Promise.resolve(reader.cancel(error)).catch(() => {}); } catch {}
58
+ try { void cancelSourceReader(reader, error).catch(() => {}); } catch {}
58
59
  finish(reject, error);
59
60
  };
60
61
  signal.addEventListener("abort", onAbort, { once: true });
61
62
  reader.read().then(
62
- (value) => finish(resolve, value),
63
- (error) => finish(reject, error),
63
+ (value) => { observeSourceRead(reader, value);finish(resolve, value); },
64
+ (error) => { failSourceRead(reader);finish(reject, error); },
64
65
  );
65
66
  });
66
67
  }
@@ -96,7 +97,7 @@ export async function readBoundedResponseBuffer(response, {
96
97
  if ((responseContentLength(response) || 0) > 0) throw unreadableUpstreamBody(label);
97
98
  return Buffer.alloc(0);
98
99
  }
99
- const reader = response?.body?.getReader?.();
100
+ const reader = sourceResponseReader(response);
100
101
  if (!reader) throw unreadableUpstreamBody(label);
101
102
  const chunks = [];
102
103
  let total = 0;
@@ -107,7 +108,7 @@ export async function readBoundedResponseBuffer(response, {
107
108
  const chunk = Buffer.from(value);
108
109
  total += chunk.length;
109
110
  if (total > limit) {
110
- await reader.cancel().catch(() => {});
111
+ await cancelSourceReader(reader).catch(() => {});
111
112
  throw upstreamBodyTooLarge(label, limit);
112
113
  }
113
114
  chunks.push(chunk);
@@ -115,7 +116,7 @@ export async function readBoundedResponseBuffer(response, {
115
116
  return Buffer.concat(chunks, total);
116
117
  } finally {
117
118
  try {
118
- reader.releaseLock();
119
+ releaseSourceReader(reader);
119
120
  } catch (error) {
120
121
  if (!signal?.aborted) throw error;
121
122
  }
@@ -23,7 +23,7 @@ const AUTO_REVIEW_REASONING_KEY = "auto_review_reasoning";
23
23
  const TERMINAL_ANIMATION_KEY = "terminal_animation";
24
24
  const RESPONSE_HISTORY_MAX_MIB_KEY = "response_history_max_mib";
25
25
  const DECODED_BODY_LIMIT_MIB_KEY = "decoded_body_limit_mib";
26
- const SERVICE_FLAGS = ["terminal_animation_enabled", "open_webui", "image_enabled", "prediction_enabled", "context_compaction_enabled"];
26
+ const SERVICE_FLAGS = ["terminal_animation_enabled", "open_webui", "image_enabled", "prediction_enabled", "context_compaction_enabled", "codex_auto_launch"];
27
27
  export const DECODED_BODY_LIMIT_MIN_MIB = RUNTIME_DEFAULTS.maxDecodedBodyBytes / MIB;
28
28
  export const DECODED_BODY_LIMIT_MAX_MIB = 512;
29
29
  export { RESPONSE_HISTORY_MAX_MIB, RESPONSE_HISTORY_MIN_MIB };
@@ -138,7 +138,7 @@ export function writeNightlyUpdatePreference(enabled, options = {}) {
138
138
  return enabled;
139
139
  });
140
140
  }
141
- const serviceFlags = settings => Object.fromEntries(SERVICE_FLAGS.map(key => [key, settings[key] !== false]));
141
+ const serviceFlags = settings => Object.fromEntries(SERVICE_FLAGS.map(key => [key, key === "codex_auto_launch" ? settings[key] === true : settings[key] !== false]));
142
142
 
143
143
  // One strict read gives each status update a coherent view; no stale cache.
144
144
  export function serviceSettingsSnapshot(options = {}) {