@bitkyc08/opencodex 2.19.0 → 2.20.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 (119) hide show
  1. package/gui/dist/assets/index-DF_UFrGS.css +1 -0
  2. package/gui/dist/assets/index-DSK3S5HY.js +76 -0
  3. package/gui/dist/index.html +2 -2
  4. package/package.json +1 -1
  5. package/src/adapters/mimo-free.ts +17 -0
  6. package/src/adapters/openai-chat.ts +367 -32
  7. package/src/adapters/registry.ts +144 -0
  8. package/src/chat/inbound.ts +13 -7
  9. package/src/cli/claude.ts +2 -1
  10. package/src/cli/combo.ts +3 -0
  11. package/src/cli/dispatch.ts +8 -0
  12. package/src/cli/export-command.ts +2 -2
  13. package/src/cli/help.ts +2 -0
  14. package/src/cli/index.ts +3 -2
  15. package/src/cli/lab.ts +135 -1
  16. package/src/cli/minimax.ts +491 -0
  17. package/src/cli/models-runtime.ts +22 -1
  18. package/src/cli/models.ts +67 -2
  19. package/src/cli/opencode.ts +2 -1
  20. package/src/cli/registry.ts +22 -2
  21. package/src/clients/config-export.ts +125 -7
  22. package/src/codex/app-server-processes.ts +57 -2
  23. package/src/codex/app-server-restart-service.ts +232 -0
  24. package/src/codex/catalog/aggregation.ts +10 -1
  25. package/src/codex/catalog/effort.ts +15 -3
  26. package/src/codex/catalog/parsing.ts +3 -1
  27. package/src/codex/catalog/provider-fetch.ts +45 -5
  28. package/src/codex/catalog/sync.ts +74 -4
  29. package/src/codex/convergence.ts +2 -0
  30. package/src/combos/index.ts +1 -0
  31. package/src/combos/request.ts +30 -0
  32. package/src/combos/types.ts +6 -0
  33. package/src/config.ts +52 -0
  34. package/src/generated/compatibility-version.json +224 -76
  35. package/src/images/loop.ts +11 -1
  36. package/src/integrations/registry.ts +7 -0
  37. package/src/lab/conformance/jcs.ts +42 -2
  38. package/src/lab/conformance/negative-controls.ts +6 -2
  39. package/src/lab/conformance/runner.ts +16 -5
  40. package/src/lab/fabric/observe.ts +49 -14
  41. package/src/lab/index.ts +16 -0
  42. package/src/lab/ledger/purge.ts +152 -83
  43. package/src/lab/ledger/store.ts +168 -54
  44. package/src/lab/observe/from-conformance.ts +8 -6
  45. package/src/lab/observe/from-live.ts +8 -2
  46. package/src/lab/paths.ts +23 -0
  47. package/src/lab/public/bundle.ts +217 -0
  48. package/src/lab/public/community-authority.ts +175 -0
  49. package/src/lab/public/community-files.ts +29 -0
  50. package/src/lab/public/community.ts +479 -0
  51. package/src/lab/public/file-safety.ts +155 -0
  52. package/src/lab/public/ids.ts +26 -0
  53. package/src/lab/public/index.ts +16 -0
  54. package/src/lab/public/mutation-lock.ts +424 -0
  55. package/src/lab/public/operator.ts +353 -0
  56. package/src/lab/public/origin-purge.ts +79 -0
  57. package/src/lab/public/origin.ts +203 -0
  58. package/src/lab/public/privacy.ts +143 -0
  59. package/src/lab/public/private-file.ts +261 -0
  60. package/src/lab/public/project.ts +124 -0
  61. package/src/lab/public/purge-test-fault.ts +21 -0
  62. package/src/lab/public/purge.ts +223 -0
  63. package/src/lab/public/registry.ts +44 -0
  64. package/src/lab/public/revocation.ts +252 -0
  65. package/src/lab/public/signature.ts +219 -0
  66. package/src/lab/public/storage.ts +105 -0
  67. package/src/lab/public/strict-json.ts +206 -0
  68. package/src/lab/public/time.ts +26 -0
  69. package/src/lab/public/types.ts +172 -0
  70. package/src/lab/public/validate.ts +391 -0
  71. package/src/lib/codex-restart-contract.ts +120 -0
  72. package/src/lib/lab-activation.ts +109 -47
  73. package/src/lib/lab-live-pinned-sender.ts +16 -5
  74. package/src/lib/pinned-http.ts +70 -16
  75. package/src/lib/self-launch-argv.ts +15 -0
  76. package/src/lib/state-store-registrations.ts +2 -0
  77. package/src/lib/upstream-reachability.ts +4 -0
  78. package/src/lib/windows-elevation.ts +10 -1
  79. package/src/providers/derive.ts +24 -4
  80. package/src/providers/registry.ts +7 -3
  81. package/src/providers/request-pacing.ts +310 -0
  82. package/src/providers/service-tier.ts +143 -0
  83. package/src/providers/static-model-discovery.ts +86 -0
  84. package/src/reasoning-effort.ts +27 -1
  85. package/src/router.ts +23 -6
  86. package/src/routing/capability.ts +4 -2
  87. package/src/routing/compatibility/behavior.ts +5 -1
  88. package/src/server/adapter-resolve.ts +2 -32
  89. package/src/server/auth-cors.ts +8 -0
  90. package/src/server/chat-completions.ts +74 -36
  91. package/src/server/chat-native-sse.ts +331 -0
  92. package/src/server/chat-native.ts +371 -0
  93. package/src/server/management/combo-routes.ts +16 -2
  94. package/src/server/management/config-routes.ts +6 -4
  95. package/src/server/management/context.ts +17 -0
  96. package/src/server/management/lab-routes.ts +181 -19
  97. package/src/server/management/model-routes.ts +76 -2
  98. package/src/server/management/model-rows.ts +8 -0
  99. package/src/server/management/provider-capability-config.ts +48 -0
  100. package/src/server/management/provider-routes.ts +76 -4
  101. package/src/server/management/system-restart.ts +4 -2
  102. package/src/server/management/system-routes.ts +38 -0
  103. package/src/server/relay.ts +17 -3
  104. package/src/server/responses/compact.ts +4 -1
  105. package/src/server/responses/core.ts +257 -46
  106. package/src/server/responses/empty-completion-guard.ts +276 -0
  107. package/src/server/responses/fetch-helpers.ts +35 -4
  108. package/src/server/responses/pacing-overload.ts +13 -0
  109. package/src/server/responses/policy-fallback.ts +16 -2
  110. package/src/server/responses/terminal-guard.ts +1 -1
  111. package/src/server/responses/upstream-error.ts +5 -0
  112. package/src/server/responses.ts +17 -2
  113. package/src/types.ts +66 -4
  114. package/src/update/index.ts +6 -5
  115. package/src/update/job.ts +5 -6
  116. package/src/update/notify.ts +5 -3
  117. package/src/usage/log.ts +11 -1
  118. package/gui/dist/assets/index-CQ7bIKee.css +0 -1
  119. package/gui/dist/assets/index-D_JUZLEC.js +0 -76
@@ -35,6 +35,7 @@ import {
35
35
  import { isServiceViable } from "../../service";
36
36
  import { readRuntimePort } from "../../config";
37
37
  import { withProcessRuntimeProvenance } from "../../lib/bun-runtime";
38
+ import { selfLaunchArgv } from "../../lib/self-launch-argv";
38
39
  import {
39
40
  MEMORY_DRAIN_RESTART_MS,
40
41
  REPLACEMENT_READY_TIMEOUT_MS,
@@ -213,19 +214,20 @@ function spawnDetachedStart(
213
214
  port?: number,
214
215
  waitForHealthBeforeParentExit = true,
215
216
  ): Promise<void> {
216
- const args = [process.argv[1], "start"];
217
+ const args = ["start"];
217
218
  const expectedPort = typeof port === "number" && Number.isFinite(port) && port > 0 && port <= 65535
218
219
  ? Math.trunc(port)
219
220
  : undefined;
220
221
  if (expectedPort !== undefined) {
221
222
  args.push("--port", String(expectedPort));
222
223
  }
224
+ const launchArgs = selfLaunchArgv(args);
223
225
  return new Promise<void>((resolve, reject) => {
224
226
  let child: ReturnType<typeof spawn>;
225
227
  try {
226
228
  const env: NodeJS.ProcessEnv = { ...process.env };
227
229
  delete env.OCX_SERVICE;
228
- child = spawn(process.execPath, args, {
230
+ child = spawn(process.execPath, launchArgs, {
229
231
  detached: true,
230
232
  stdio: "ignore",
231
233
  windowsHide: true,
@@ -31,8 +31,16 @@ import {
31
31
  SYSTEM_RESTART_EXPECTED_PID_HEADER,
32
32
  parseExpectedSystemRestartPid,
33
33
  } from "../../lib/system-restart-contract";
34
+ import {
35
+ CODEX_APP_SERVER_STATE_PATH,
36
+ CODEX_RESTART_PATH,
37
+ } from "../../lib/codex-restart-contract";
34
38
  import { jsonResponse } from "../auth-cors";
35
39
  import { getInspectionCounters } from "../relay";
40
+ import type {
41
+ performCodexRestart,
42
+ readCodexAppServerState,
43
+ } from "../../codex/app-server-restart-service";
36
44
  import type { ManagementContext } from "./context";
37
45
  import { acceptSystemRestart } from "./system-restart";
38
46
 
@@ -137,5 +145,35 @@ export async function handleSystemRoutes(ctx: ManagementContext): Promise<Respon
137
145
  }, 202, req, config);
138
146
  }
139
147
 
148
+ if (
149
+ (url.pathname === CODEX_APP_SERVER_STATE_PATH && req.method === "GET")
150
+ || (url.pathname === CODEX_RESTART_PATH && req.method === "POST")
151
+ ) {
152
+ // Resolved inside the path check, not at the top of this function: every
153
+ // /api/system/* request runs through here, and an unconditional import would
154
+ // pull the platform process-enumeration helpers into requests that never
155
+ // touch them.
156
+ // An explicit branch rather than `??`: the seam is an optional property, and
157
+ // narrowing through a nullish default keeps its `undefined` in the union.
158
+ let service: {
159
+ readState: typeof readCodexAppServerState;
160
+ performRestart: typeof performCodexRestart;
161
+ };
162
+ const injected = ctx.deps.codexRestartService;
163
+ if (injected) {
164
+ service = injected;
165
+ } else {
166
+ const module = await import("../../codex/app-server-restart-service");
167
+ service = {
168
+ readState: module.readCodexAppServerState,
169
+ performRestart: module.performCodexRestart,
170
+ };
171
+ }
172
+ if (req.method === "GET") {
173
+ return jsonResponse(service.readState(), 200, req, config);
174
+ }
175
+ return jsonResponse(await service.performRestart(), 200, req, config);
176
+ }
177
+
140
178
  return null;
141
179
  }
@@ -366,6 +366,7 @@ export function trackSseForRequestLog(
366
366
  ): ReadableStream<Uint8Array> {
367
367
  const reader = body.getReader();
368
368
  let terminalReported = false;
369
+ let cancelled = false;
369
370
 
370
371
  const reportTerminal = (status: ResponsesTerminalStatus) => {
371
372
  if (terminalReported) return;
@@ -385,8 +386,10 @@ export function trackSseForRequestLog(
385
386
  try {
386
387
  const { done, value } = await reader.read();
387
388
  if (done) {
388
- inspector.finish();
389
- if (!terminalReported) reportTerminal("incomplete");
389
+ if (!cancelled) {
390
+ inspector.finish();
391
+ if (!terminalReported) reportTerminal("incomplete");
392
+ }
390
393
  inspector.dispose();
391
394
  controller.close();
392
395
  return;
@@ -394,12 +397,19 @@ export function trackSseForRequestLog(
394
397
  inspector.feed(value);
395
398
  controller.enqueue(value);
396
399
  } catch (err) {
397
- if (!terminalReported) reportTerminal("incomplete");
400
+ // The upstream read rejected: the 200 body died mid-flight. Client
401
+ // cancellation is the caller's separate 499 path, so a cancel-drained
402
+ // pending read (cancelled=true) must not carry the truncation marker.
403
+ if (!cancelled && !terminalReported && logCtx?.activeAttempt) {
404
+ logCtx.activeAttempt.streamAborted = true;
405
+ }
406
+ if (!cancelled && !terminalReported) reportTerminal("incomplete");
398
407
  inspector.dispose();
399
408
  try { controller.error(err); } catch { /* already torn down */ }
400
409
  }
401
410
  },
402
411
  cancel(reason) {
412
+ cancelled = true;
403
413
  inspector.dispose();
404
414
  onCancel();
405
415
  reader.cancel(reason).catch(() => {});
@@ -1122,6 +1132,10 @@ export function consumeForInspection(
1122
1132
  if (logCtx) {
1123
1133
  logCtx.transportPhase = "mid_stream";
1124
1134
  logCtx.terminalSource = "synthetic";
1135
+ // A truncated 200 body must not meter as a success the client never
1136
+ // received; the router's equivalent turn carries 502 + streamAborted
1137
+ // (codex-router #139).
1138
+ if (logCtx.activeAttempt) logCtx.activeAttempt.streamAborted = true;
1125
1139
  }
1126
1140
  onTerminal("failed", 502);
1127
1141
  }
@@ -490,7 +490,10 @@ export async function handleResponsesCompact(
490
490
  req.signal,
491
491
  connectMs,
492
492
  false,
493
- providerFetch(sendProvider),
493
+ providerFetch(sendProvider, undefined, {
494
+ providerName: route.providerName,
495
+ modelId: route.modelId,
496
+ }),
494
497
  // Every credential-bearing forward send gets manual redirects, not only
495
498
  // pool sends: direct mode carries the caller's credential too (#914).
496
499
  sendProvider.authMode === "forward",