@bitkyc08/opencodex 2.7.43-preview.20260728 → 2.8.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 (173) hide show
  1. package/README.md +8 -1
  2. package/bin/ocx.mjs +47 -22
  3. package/gui/dist/assets/index-BDjpkcRN.js +67 -0
  4. package/gui/dist/assets/index-BHsKRFh9.css +1 -0
  5. package/gui/dist/index.html +2 -2
  6. package/package.json +1 -1
  7. package/src/AGENTS.md +28 -0
  8. package/src/adapters/anthropic.ts +15 -6
  9. package/src/adapters/cursor/discovery.ts +4 -1
  10. package/src/adapters/cursor/effort-map.ts +3 -0
  11. package/src/adapters/cursor/native-exec-shell.ts +18 -6
  12. package/src/adapters/cursor/protobuf-events.ts +24 -2
  13. package/src/adapters/cursor/protobuf-request.ts +1 -2
  14. package/src/adapters/cursor/tool-definitions.ts +68 -29
  15. package/src/adapters/google-wire-compiler.ts +4 -0
  16. package/src/adapters/google.ts +128 -2
  17. package/src/adapters/identity.ts +12 -2
  18. package/src/adapters/kiro.ts +64 -7
  19. package/src/adapters/mimo-free.ts +2 -0
  20. package/src/adapters/openai-responses.ts +246 -59
  21. package/src/claude/agents-inject.ts +5 -0
  22. package/src/claude/alias.ts +94 -14
  23. package/src/claude/inbound.ts +26 -9
  24. package/src/claude/outbound.ts +6 -3
  25. package/src/cli/account-auth.ts +1 -1
  26. package/src/cli/agent-driven.ts +37 -0
  27. package/src/cli/catalog-prewarm.ts +24 -0
  28. package/src/cli/claude.ts +35 -10
  29. package/src/cli/doctor.ts +71 -19
  30. package/src/cli/help.ts +42 -6
  31. package/src/cli/index.ts +93 -19
  32. package/src/cli/interactive-confirm.ts +133 -0
  33. package/src/cli/opencode.ts +701 -0
  34. package/src/cli/provider-runtime.ts +3 -0
  35. package/src/cli/provider.ts +31 -10
  36. package/src/cli/star-prompt.ts +79 -18
  37. package/src/cli/status.ts +47 -13
  38. package/src/cli/v2.ts +10 -1
  39. package/src/codex/account-id.ts +34 -0
  40. package/src/codex/account-lifecycle.ts +4 -1
  41. package/src/codex/account-namespace-match.ts +63 -0
  42. package/src/codex/account-namespaces.ts +149 -0
  43. package/src/codex/account-pause.ts +20 -0
  44. package/src/codex/account-store.ts +2 -0
  45. package/src/codex/account-usability.ts +6 -1
  46. package/src/codex/app-server-processes.ts +511 -0
  47. package/src/codex/auth-api.ts +293 -34
  48. package/src/codex/auth-collision.ts +2 -1
  49. package/src/codex/auth-context.ts +60 -17
  50. package/src/codex/catalog/bundled.ts +9 -2
  51. package/src/codex/catalog/parsing.ts +42 -2
  52. package/src/codex/catalog/provider-fetch.ts +264 -70
  53. package/src/codex/catalog/sync.ts +45 -8
  54. package/src/codex/catalog.ts +2 -2
  55. package/src/codex/features.ts +524 -5
  56. package/src/codex/history-provider.ts +145 -1
  57. package/src/codex/inject.ts +114 -14
  58. package/src/codex/main-account.ts +2 -8
  59. package/src/codex/pool-rotation.ts +186 -0
  60. package/src/codex/quota.ts +92 -2
  61. package/src/codex/routing.ts +695 -106
  62. package/src/codex/runtime.ts +10 -1
  63. package/src/codex/shim.ts +4 -1
  64. package/src/codex/subagent-defaults.ts +550 -0
  65. package/src/codex/subagent-model-fallback.ts +2 -0
  66. package/src/codex/sync.ts +3 -0
  67. package/src/config.ts +574 -25
  68. package/src/generated/jawcode-model-metadata.ts +12 -12
  69. package/src/github/star-state.ts +191 -0
  70. package/src/images/artifacts.ts +516 -0
  71. package/src/images/fulfill-video.ts +163 -0
  72. package/src/images/fulfill.ts +111 -0
  73. package/src/images/index.ts +4 -0
  74. package/src/images/loop.ts +789 -0
  75. package/src/images/plan.ts +133 -0
  76. package/src/images/synthetic-tool.ts +133 -0
  77. package/src/images/types.ts +41 -0
  78. package/src/images/xai-client.ts +141 -0
  79. package/src/images/xai-video-client.ts +163 -0
  80. package/src/lib/admin-secrets.ts +25 -0
  81. package/src/lib/bun-binary-validator.d.mts +3 -0
  82. package/src/lib/bun-binary-validator.mjs +18 -0
  83. package/src/lib/bun-runtime.ts +6 -20
  84. package/src/lib/config-ownership.ts +327 -0
  85. package/src/lib/crash-guard.ts +2 -0
  86. package/src/lib/destination-policy.ts +132 -7
  87. package/src/lib/pinned-http.ts +151 -0
  88. package/src/lib/process-control.ts +2 -2
  89. package/src/lib/provider-outbound.ts +167 -0
  90. package/src/lib/provider-url.ts +14 -0
  91. package/src/lib/proxy-env.ts +18 -0
  92. package/src/lib/shadow-call.ts +30 -0
  93. package/src/lib/test-home-guard.ts +90 -0
  94. package/src/lib/win-exec.ts +12 -2
  95. package/src/lib/windows-elevation.ts +81 -3
  96. package/src/lib/windows-secret-acl.ts +189 -12
  97. package/src/lib/winsw.ts +2 -0
  98. package/src/oauth/anthropic-routing.ts +570 -0
  99. package/src/oauth/health.ts +6 -0
  100. package/src/oauth/index.ts +310 -75
  101. package/src/oauth/key-providers.ts +38 -8
  102. package/src/oauth/kimi.ts +2 -0
  103. package/src/oauth/kiro-credentials.ts +373 -12
  104. package/src/oauth/kiro.ts +424 -43
  105. package/src/oauth/login-cli.ts +33 -6
  106. package/src/oauth/store.ts +56 -4
  107. package/src/oauth/types.ts +11 -0
  108. package/src/providers/alibaba-region-migration.ts +16 -3
  109. package/src/providers/antigravity-models.ts +3 -0
  110. package/src/providers/api-keys.ts +13 -6
  111. package/src/providers/derive.ts +8 -2
  112. package/src/providers/key-failover.ts +24 -4
  113. package/src/providers/model-discovery.ts +356 -0
  114. package/src/providers/quota.ts +233 -29
  115. package/src/providers/registry.ts +125 -3
  116. package/src/responses/parser.ts +11 -0
  117. package/src/responses/state.ts +22 -8
  118. package/src/responses/tool-groups.ts +19 -0
  119. package/src/router.ts +19 -7
  120. package/src/server/auth-cors.ts +114 -24
  121. package/src/server/claude-messages.ts +8 -1
  122. package/src/server/gui-static.ts +30 -6
  123. package/src/server/images.ts +303 -9
  124. package/src/server/index.ts +77 -9
  125. package/src/server/lifecycle.ts +25 -1
  126. package/src/server/live.ts +75 -25
  127. package/src/server/management/agent-settings-routes.ts +106 -8
  128. package/src/server/management/combo-routes.ts +7 -0
  129. package/src/server/management/config-routes.ts +22 -7
  130. package/src/server/management/context.ts +11 -1
  131. package/src/server/management/logs-usage-routes.ts +167 -3
  132. package/src/server/management/model-routes.ts +46 -13
  133. package/src/server/management/oauth-account-routes.ts +163 -17
  134. package/src/server/management/provider-routes.ts +73 -10
  135. package/src/server/management/shared.ts +2 -2
  136. package/src/server/management/sidebar-routes.ts +39 -0
  137. package/src/server/management/system-restart.ts +172 -0
  138. package/src/server/management/system-routes.ts +33 -10
  139. package/src/server/management-api.ts +5 -3
  140. package/src/server/management-auth.ts +216 -0
  141. package/src/server/proxy-liveness.ts +14 -3
  142. package/src/server/responses/compact.ts +21 -13
  143. package/src/server/responses/core.ts +614 -172
  144. package/src/server/responses/upstream-error.ts +48 -0
  145. package/src/server/responses-image-gen-repair.ts +118 -0
  146. package/src/server/responses-item-id-repair.ts +10 -85
  147. package/src/server/sse-payload-rewrite.ts +116 -0
  148. package/src/server/startup-action-control.ts +30 -14
  149. package/src/server/system-env.ts +28 -10
  150. package/src/service.ts +284 -19
  151. package/src/storage/cleanup-job.ts +57 -0
  152. package/src/storage/cleanup.ts +1504 -28
  153. package/src/storage/policy-job.ts +387 -0
  154. package/src/storage/policy-scheduler.ts +40 -0
  155. package/src/storage/policy-worker.ts +53 -0
  156. package/src/storage/policy.ts +522 -0
  157. package/src/storage/restore-job.ts +253 -0
  158. package/src/storage/restore-worker.ts +52 -0
  159. package/src/storage/storage-mutation-coordinator.ts +109 -0
  160. package/src/storage/worker-lifecycle.ts +81 -0
  161. package/src/tray/windows.ts +34 -4
  162. package/src/types.ts +107 -1
  163. package/src/update/badge.ts +72 -0
  164. package/src/update/index.ts +36 -18
  165. package/src/update/job.ts +111 -16
  166. package/src/update/npm-invocation.d.mts +23 -0
  167. package/src/update/npm-invocation.mjs +94 -0
  168. package/src/usage/debug.ts +2 -0
  169. package/src/usage/expected-prices.ts +6 -5
  170. package/src/usage/log.ts +12 -0
  171. package/src/web-search/loop.ts +57 -16
  172. package/gui/dist/assets/index-CjKFJHSC.js +0 -65
  173. package/gui/dist/assets/index-DfVGuN88.css +0 -1
@@ -0,0 +1,133 @@
1
+ import { createInterface } from "node:readline/promises";
2
+
3
+ /**
4
+ * Inline yes/no selector for interactive CLI prompts.
5
+ *
6
+ * Both choices are drawn on one line: the user moves between them with the
7
+ * arrow keys (or Tab), confirms with Enter, or answers straight away with
8
+ * `y`/`n`. Escape and Ctrl-C resolve to "no", so backing out never counts as
9
+ * consent.
10
+ *
11
+ * The highlighted choice is caller-supplied and is what a bare Enter returns.
12
+ * Whatever the default, the selector always shows which side is highlighted, so
13
+ * Enter never does something the screen did not already say it would.
14
+ */
15
+
16
+ export interface InteractiveConfirmOptions {
17
+ /** Question text rendered before the choices. May contain ANSI styling. */
18
+ question: string;
19
+ /** Which choice starts highlighted, and therefore what a bare Enter returns. */
20
+ defaultYes: boolean;
21
+ /** Key hint shown after the choices. */
22
+ hint?: string;
23
+ /** Overridable for tests; defaults to the process streams. */
24
+ input?: NodeJS.ReadStream;
25
+ output?: NodeJS.WriteStream;
26
+ }
27
+
28
+ // The highlight sets an explicit black-on-white pair rather than bare reverse
29
+ // video (\x1b[7m). Reverse alone inherits whatever foreground colour is in
30
+ // effect, so on some themes the selected label rendered as black text on a black
31
+ // block and the choice became invisible.
32
+ const REVERSE = "\x1b[30;47m";
33
+ const DIM = "\x1b[2m";
34
+ const RESET = "\x1b[0m";
35
+ const CLEAR_LINE = "\r\x1b[K";
36
+
37
+ const KEY_ENTER = new Set(["\r", "\n"]);
38
+ const KEY_YES_SIDE = new Set(["\x1b[D", "\x1b[A", "\x1bOD", "\x1bOA"]); // left / up
39
+ const KEY_NO_SIDE = new Set(["\x1b[C", "\x1b[B", "\x1bOC", "\x1bOB"]); // right / down
40
+ const KEY_ESCAPE = "\x1b";
41
+ const KEY_INTERRUPT = "\x03";
42
+ const KEY_TAB = "\t";
43
+
44
+ function renderChoices(question: string, yes: boolean, hint: string): string {
45
+ const yesLabel = yes ? `${REVERSE} Yes ${RESET}` : `${DIM} Yes ${RESET}`;
46
+ const noLabel = yes ? `${DIM} No ${RESET}` : `${REVERSE} No ${RESET}`;
47
+ return `${CLEAR_LINE}${question} ${yesLabel} ${noLabel} ${DIM}${hint}${RESET}`;
48
+ }
49
+
50
+ function renderAnswer(question: string, yes: boolean): string {
51
+ return `${CLEAR_LINE}${question} ${yes ? "Yes" : "No"}\n`;
52
+ }
53
+
54
+ /** Fallback for terminals without raw mode: a plain typed answer. */
55
+ async function readlineConfirm(
56
+ options: InteractiveConfirmOptions,
57
+ input: NodeJS.ReadStream,
58
+ output: NodeJS.WriteStream,
59
+ ): Promise<boolean> {
60
+ const suffix = options.defaultYes ? "[Y/n]" : "[y/N]";
61
+ const rl = createInterface({ input, output });
62
+ try {
63
+ const answer = (await rl.question(`${options.question} ${suffix} `)).trim().toLowerCase();
64
+ if (answer === "") return options.defaultYes;
65
+ return answer === "y" || answer === "yes";
66
+ } finally {
67
+ rl.close();
68
+ }
69
+ }
70
+
71
+ /**
72
+ * Ask a yes/no question with an inline arrow-key selector. Resolves to the
73
+ * user's choice; never throws for input handling and always restores the
74
+ * terminal mode it changed.
75
+ */
76
+ export async function interactiveConfirm(options: InteractiveConfirmOptions): Promise<boolean> {
77
+ const input = options.input ?? process.stdin;
78
+ const output = options.output ?? process.stdout;
79
+ const hint = options.hint ?? "←/→ move · y/n · enter";
80
+
81
+ // Raw mode is what makes single-keypress navigation possible. Without it
82
+ // (pipes, some CI shells, Windows consoles without a TTY) fall back to a
83
+ // typed answer rather than silently swallowing the question.
84
+ if (typeof input.setRawMode !== "function") {
85
+ return await readlineConfirm(options, input, output);
86
+ }
87
+
88
+ return await new Promise<boolean>(resolve => {
89
+ let yes = options.defaultYes;
90
+ const wasRaw = input.isRaw === true;
91
+ const hadOtherReaders = input.listenerCount("data") > 0;
92
+
93
+ const paint = () => {
94
+ output.write(renderChoices(options.question, yes, hint));
95
+ };
96
+
97
+ const finish = (answer: boolean, interrupted: boolean) => {
98
+ input.off("data", onData);
99
+ if (!wasRaw) input.setRawMode(false);
100
+ if (!hadOtherReaders) input.pause();
101
+ output.write(renderAnswer(options.question, answer));
102
+ resolve(answer);
103
+ // A Ctrl-C during the prompt is still a Ctrl-C: hand it back to the
104
+ // process so the normal shutdown path runs instead of being eaten here.
105
+ if (interrupted) process.kill(process.pid, "SIGINT");
106
+ };
107
+
108
+ const onData = (chunk: Buffer | string) => {
109
+ const key = typeof chunk === "string" ? chunk : chunk.toString("utf8");
110
+ if (key === KEY_INTERRUPT) return finish(false, true);
111
+ if (key === KEY_ESCAPE) return finish(false, false);
112
+ if (KEY_ENTER.has(key)) return finish(yes, false);
113
+ const lower = key.toLowerCase();
114
+ if (lower === "y") return finish(true, false);
115
+ if (lower === "n") return finish(false, false);
116
+ if (KEY_YES_SIDE.has(key)) {
117
+ yes = true;
118
+ paint();
119
+ return;
120
+ }
121
+ if (KEY_NO_SIDE.has(key) || key === KEY_TAB) {
122
+ yes = key === KEY_TAB ? !yes : false;
123
+ paint();
124
+ return;
125
+ }
126
+ };
127
+
128
+ input.setRawMode(true);
129
+ input.resume();
130
+ input.on("data", onData);
131
+ paint();
132
+ });
133
+ }