@bitkyc08/opencodex 2.100.6 → 2.100.7

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 (103) hide show
  1. package/gui/dist/assets/App-BfoDjNBU.js +65 -0
  2. package/gui/dist/assets/App-hklyKJR5.css +1 -0
  3. package/gui/dist/assets/{Tray-CVqm4S4W.js → Tray-BN6pxM_V.js} +1 -1
  4. package/gui/dist/assets/brand-mark-CDZQ-wa9.js +1 -0
  5. package/gui/dist/assets/index-B85uU8rK.css +2 -0
  6. package/gui/dist/assets/index-Bt9ze3XN.js +138 -0
  7. package/gui/dist/assets/{segment-thumb-features-COdzmORE.js → segment-thumb-features-BM5n8NMX.js} +1 -1
  8. package/gui/dist/classic/assets/App-D4cjNg2I.js +64 -0
  9. package/gui/dist/classic/assets/App-DSivR528.css +1 -0
  10. package/gui/dist/classic/assets/{Tray-BDlcOLDK.js → Tray-DTgGR7wt.js} +1 -1
  11. package/gui/dist/classic/assets/index-ALDeKRg9.js +138 -0
  12. package/gui/dist/classic/assets/usage-companion-chart-BC-Nos9Q.js +1 -0
  13. package/gui/dist/classic/index.html +1 -1
  14. package/gui/dist/index.html +2 -2
  15. package/package.json +2 -2
  16. package/src/adapters/coding-agent/process-tree.ts +30 -0
  17. package/src/adapters/coding-agent/profile.ts +1 -1
  18. package/src/adapters/coding-agent/turn.ts +2 -9
  19. package/src/adapters/command-code-decision-guard.ts +25 -0
  20. package/src/adapters/cursor/catalog.ts +14 -0
  21. package/src/adapters/cursor/effort-map.ts +3 -0
  22. package/src/adapters/google-usage.ts +28 -0
  23. package/src/adapters/google.ts +9 -26
  24. package/src/adapters/qoder/adapter.ts +197 -13
  25. package/src/adapters/registry.ts +13 -0
  26. package/src/adapters/step-cli/adapter.ts +401 -0
  27. package/src/adapters/step-cli/constants.ts +11 -0
  28. package/src/adapters/step-cli/conversation.ts +159 -0
  29. package/src/adapters/step-cli/env.ts +49 -0
  30. package/src/adapters/step-cli/errors.ts +76 -0
  31. package/src/adapters/step-cli/events.ts +227 -0
  32. package/src/adapters/step-cli/profiles.ts +134 -0
  33. package/src/adapters/step-cli/projection.ts +242 -0
  34. package/src/adapters/step-cli/registry.ts +181 -0
  35. package/src/adapters/step-cli/session-pool.ts +225 -0
  36. package/src/adapters/step-cli/session.ts +842 -0
  37. package/src/adapters/step-cli/stdio-frames.ts +330 -0
  38. package/src/adapters/step-cli/tool-bridge.ts +92 -0
  39. package/src/cli/claude.ts +5 -2
  40. package/src/client/link-management-relay.ts +11 -0
  41. package/src/client/machine-listener.ts +6 -2
  42. package/src/codex/account-label.ts +1 -1
  43. package/src/codex/catalog/gather-capture.ts +2 -1
  44. package/src/codex/catalog/metadata.ts +48 -2
  45. package/src/codex/catalog/model-hints.ts +19 -5
  46. package/src/codex/catalog/model-visibility.ts +4 -7
  47. package/src/codex/catalog/native-ultrafast.ts +8 -6
  48. package/src/generated/compatibility-version.json +137 -61
  49. package/src/generated/model-metadata.ts +1 -1
  50. package/src/lib/client-error-body.ts +2 -0
  51. package/src/lib/messages-error-body.ts +3 -1
  52. package/src/lib/optional-shutdown-hooks.ts +55 -5
  53. package/src/lib/process-control.ts +3 -2
  54. package/src/lib/shutdown-budget.ts +5 -0
  55. package/src/link/remote-platform.ts +24 -9
  56. package/src/link/ssh-argv.ts +8 -2
  57. package/src/link/ssh-runner.ts +15 -2
  58. package/src/oauth/m365-copilot-web-session.ts +28 -4
  59. package/src/protocols/dto.ts +24 -12
  60. package/src/protocols/settings.ts +20 -16
  61. package/src/protocols/shadow.ts +2 -3
  62. package/src/protocols/trace.ts +24 -2
  63. package/src/providers/command-code-decision-models.ts +65 -0
  64. package/src/providers/quota.ts +4 -4
  65. package/src/providers/registry/entries-core.ts +18 -7
  66. package/src/providers/registry/entries-extended.ts +41 -0
  67. package/src/providers/registry/model-seeds.ts +42 -0
  68. package/src/providers/resolved-model-policy-merge.ts +8 -0
  69. package/src/providers/resolved-model-policy.ts +185 -165
  70. package/src/providers/slug-codec.ts +5 -0
  71. package/src/server/chat-native-eligibility.ts +5 -0
  72. package/src/server/credential-recovery-attempt.ts +2 -2
  73. package/src/server/gemini-inbound.ts +15 -11
  74. package/src/server/gemini-native-catalog.ts +27 -2
  75. package/src/server/gemini-native-wire.ts +71 -6
  76. package/src/server/gemini-native.ts +129 -34
  77. package/src/server/index/gemini-routes.ts +6 -1
  78. package/src/server/lifecycle.ts +2 -1
  79. package/src/server/management/agent-settings-routes.ts +26 -28
  80. package/src/server/management/api-access.ts +5 -3
  81. package/src/server/management/protocol-routes.ts +3 -1
  82. package/src/server/management/protocol-settings-patch.ts +25 -10
  83. package/src/server/management/shared.ts +20 -5
  84. package/src/server/messages-native-eligibility.ts +4 -0
  85. package/src/server/messages-native-tool-guard.ts +18 -5
  86. package/src/server/request-log-generation-window.ts +7 -2
  87. package/src/server/responses/command-code-decision-refusal.ts +24 -0
  88. package/src/server/responses/compact.ts +2 -2
  89. package/src/server/responses/core-combo.ts +18 -3
  90. package/src/server/responses/core-pipeline.ts +6 -0
  91. package/src/server/responses/sidecar-execution.ts +10 -7
  92. package/src/types/config.ts +2 -0
  93. package/src/usage/expected-prices.ts +17 -0
  94. package/src/usage/telemetry-contract.ts +3 -0
  95. package/gui/dist/assets/App-BI8LQ7Qk.css +0 -1
  96. package/gui/dist/assets/App-CsZ1Gr7S.js +0 -60
  97. package/gui/dist/assets/brand-mark-BebhnAtV.js +0 -1
  98. package/gui/dist/assets/index-BtwVlpeQ.css +0 -2
  99. package/gui/dist/assets/index-CEeMegqE.js +0 -138
  100. package/gui/dist/classic/assets/App-BJgUWNJ8.js +0 -59
  101. package/gui/dist/classic/assets/App-CoiVLRW3.css +0 -1
  102. package/gui/dist/classic/assets/index-B9Jgli_W.js +0 -138
  103. package/gui/dist/classic/assets/usage-companion-chart-vbzDcND0.js +0 -1
@@ -13,12 +13,104 @@ import { buildQoderConversationInput, qoderCnImageInputSupported } from "./image
13
13
 
14
14
  export type QoderAdapterDeps = CodingAgentDeps;
15
15
 
16
- function classifyQoderFailure(failure: CodingAgentFailure): Extract<AdapterEvent, { type: "error" }> {
16
+ type QoderErrorEvent = Extract<AdapterEvent, { type: "error" }>;
17
+ export type QoderRecoverableNoticeReason = "auth" | "daily_limit" | "personal_credits" | "cn_pricing_url";
18
+
19
+ function hasExplicitErrorCode(raw: unknown): boolean {
20
+ if (raw === undefined || raw === null) return false;
21
+ if (typeof raw === "string") return raw.trim().length > 0;
22
+ return true;
23
+ }
24
+
25
+ // qodercli 1.1.91 may serialize numeric vendor error_code values as strings (e.g. "110", "114").
26
+ function parseQoderErrorCode(raw: unknown): number | undefined {
27
+ if (typeof raw === "number" && Number.isFinite(raw)) return raw;
28
+ if (typeof raw === "string") {
29
+ const trimmed = raw.trim();
30
+ if (/^\d+$/.test(trimmed)) {
31
+ const parsed = Number(trimmed);
32
+ if (Number.isSafeInteger(parsed)) return parsed;
33
+ }
34
+ }
35
+ return undefined;
36
+ }
37
+
38
+ function isPlainRecord(value: unknown): value is Record<string, unknown> {
39
+ return value !== null && typeof value === "object" && !Array.isArray(value);
40
+ }
41
+
42
+ const CN_REMOTE_CHAT_403_RE = /^inference\.remoteChat\.stream failed \(403\):\s*(\{[\s\S]*\})$/;
43
+ const EMBEDDED_ERROR_CODE_KEYS = [
44
+ "code", "error_code", "errorCode", "err_code", "errCode", "biz_code", "bizCode", "statusCode", "status_code", "status",
45
+ ] as const;
46
+
47
+ function hasEmbeddedNon403ErrorCode(record: Record<string, unknown>): boolean {
48
+ for (const key of EMBEDDED_ERROR_CODE_KEYS) {
49
+ const value = record[key];
50
+ if (hasExplicitErrorCode(value) && parseQoderErrorCode(value) !== 403) return true;
51
+ }
52
+ return false;
53
+ }
54
+
55
+ // Only the verified exhaustion shape is evidence: the pricing URL plus, at most, 403 codes. Any
56
+ // explanatory text (a lock, a ban, a permission denial) is a different 403, and rotating keys for
57
+ // it would only cool down healthy ones, so recovery is an allowlist, never a deny-word list.
58
+ const CN_PRICING_ONLY_KEYS: ReadonlySet<string> = new Set(["pricingUrl", ...EMBEDDED_ERROR_CODE_KEYS]);
59
+
60
+ function isPricingOnlyRecord(record: Record<string, unknown>): boolean {
61
+ return Object.keys(record).every(key => CN_PRICING_ONLY_KEYS.has(key));
62
+ }
63
+
64
+ function isCnPricingUrl(value: unknown): boolean {
65
+ if (typeof value !== "string") return false;
66
+ let url: URL;
67
+ try {
68
+ url = new URL(value);
69
+ } catch {
70
+ return false;
71
+ }
72
+ return url.protocol === "https:"
73
+ && url.hostname === "qoder.com.cn"
74
+ && url.port === ""
75
+ && url.username === ""
76
+ && url.password === ""
77
+ && url.pathname === "/pricing";
78
+ }
79
+
80
+ // qoder-cn surfaces account-level resource-pack exhaustion as a 403 remoteChat stream failure
81
+ // whose JSON response body carries the exact CN /pricing URL and no non-403 vendor error code.
82
+ // Parse that exact 403 JSON payload so embedded business codes (e.g. 114), wrong paths
83
+ // (/pricing-policy), or unrelated text never trigger key recovery.
84
+ function isCnQuotaPricingFailure(message: string): boolean {
85
+ const match = CN_REMOTE_CHAT_403_RE.exec(message.trim());
86
+ if (!match) return false;
87
+ let payload: unknown;
88
+ try {
89
+ payload = JSON.parse(match[1]!);
90
+ } catch {
91
+ return false;
92
+ }
93
+ if (!isPlainRecord(payload)) return false;
94
+ if (hasEmbeddedNon403ErrorCode(payload)) return false;
95
+ if (isPlainRecord(payload.error) && hasEmbeddedNon403ErrorCode(payload.error)) return false;
96
+ if (isPlainRecord(payload.data) && hasEmbeddedNon403ErrorCode(payload.data)) return false;
97
+ if (!isPricingOnlyRecord(payload)) return false;
98
+ return isCnPricingUrl(payload.pricingUrl);
99
+ }
100
+
101
+ function classifyQoderFailure(
102
+ failure: CodingAgentFailure,
103
+ recordReason?: (reason: QoderRecoverableNoticeReason | undefined) => void,
104
+ ): QoderErrorEvent {
105
+ recordReason?.(undefined);
17
106
  const { error, profile } = failure;
18
- const auth = (): typeof error => ({
19
- ...error, status: 401, errorType: "authentication_error", code: "invalid_api_key",
20
- retryable: false, apiKeyRecovery: true,
21
- });
107
+ const auth = (noticeReason?: QoderRecoverableNoticeReason): QoderErrorEvent => {
108
+ if (noticeReason) recordReason?.(noticeReason);
109
+ return {
110
+ ...error, status: 401, errorType: "authentication_error", code: "invalid_api_key",
111
+ retryable: false, apiKeyRecovery: true,
112
+ };
113
+ };
22
114
  if (failure.source === "process-exit") {
23
115
  return failure.exitCode === 41 || (failure.exitCode === 1
24
116
  && failure.stderr.includes("QoderAuthError")
@@ -26,28 +118,52 @@ function classifyQoderFailure(failure: CodingAgentFailure): Extract<AdapterEvent
26
118
  && /token (?:that )?was rejected/i.test(failure.stderr))
27
119
  ? auth() : error;
28
120
  }
29
- const code = failure.frame.error_code;
30
- if (code === 105) return auth();
121
+ const rawCode = failure.frame.error_code;
122
+ const explicitErrorCode = hasExplicitErrorCode(rawCode);
123
+ const code = parseQoderErrorCode(rawCode);
124
+ if (code === 105) return auth("auth");
31
125
  if (code === 114) return {
32
126
  ...error, status: 403, errorType: "permission_error", code: "permission_denied", retryable: false,
33
127
  };
34
128
  if (typeof code === "number" && [110, 113, 115, 116, 117, 118, 119, 122].includes(code)) {
35
- return {
129
+ const classified: QoderErrorEvent = {
36
130
  ...error, status: 429, errorType: "insufficient_quota", code: "insufficient_quota", retryable: false,
37
131
  ...(code === 110 || code === 118 ? { apiKeyRecovery: true as const } : {}),
38
132
  };
133
+ if (code === 110) recordReason?.("daily_limit");
134
+ else if (code === 118) recordReason?.("personal_credits");
135
+ return classified;
39
136
  }
40
- if (typeof code === "number") return error;
137
+ // Live qodercn 1.1.91 captures emit error_code "112" (credit usage limit) alongside the 403
138
+ // pricing-URL body on exhausted CN accounts, whereas older/wrapper surfaces may emit 403/"403"
139
+ // or no code. Any other explicit error_code (including non-numeric codes such as
140
+ // "PERMISSION_DENIED", oversized integer strings, and non-recoverable vendor codes such as
141
+ // 114/130) takes precedence over CN pricing-URL and text fallbacks.
142
+ if (explicitErrorCode && code !== 403 && code !== 112) return error;
143
+ if (profile.region === "cn" && isCnQuotaPricingFailure(error.message)) {
144
+ recordReason?.("cn_pricing_url");
145
+ return {
146
+ ...error, status: 429, errorType: "insufficient_quota", code: "insufficient_quota",
147
+ retryable: false, apiKeyRecovery: true as const,
148
+ };
149
+ }
150
+ if (explicitErrorCode) return error;
41
151
  if (/daily usage limit|credit usage limit/i.test(error.message)) {
42
- const isAccountDaily = /^You've reached your daily usage limit for Chat\b/i.test(error.message.trim())
152
+ const trimmed = error.message.trim();
153
+ // qodercli 1.1.81 reworded the per-key daily limit; both wordings stay account-scoped.
154
+ const isAccountDaily = (/^You've reached your daily usage limit for Chat\b/i.test(trimmed)
155
+ || /^You have reached the daily usage limit\b/i.test(trimmed))
43
156
  && !/\b(?:team|model|shared)\b/i.test(error.message);
157
+ if (isAccountDaily) recordReason?.("daily_limit");
44
158
  return {
45
159
  ...error, status: 429, errorType: "insufficient_quota", code: "insufficient_quota",
46
160
  retryable: false,
47
161
  ...(isAccountDaily ? { apiKeyRecovery: true as const } : {}),
48
162
  };
49
163
  }
50
- if (/\binvalid (?:personal access )?token\b|\btoken (?:was |that was )?rejected\b|\bqoder authentication rejected\b/i.test(error.message)) return auth();
164
+ if (/\binvalid (?:personal access )?token\b|\btoken (?:was |that was )?rejected\b|\bqoder authentication rejected\b/i.test(error.message)) {
165
+ return auth("auth");
166
+ }
51
167
  return error;
52
168
  }
53
169
 
@@ -56,6 +172,69 @@ const QODER_MCP_SERVER_PATH = fileURLToPath(new URL("../coding-agent/mcp-server.
56
172
  const MAX_PENDING_BOUNDARY_CHARS = 64 * 1024;
57
173
  const MAX_PENDING_BOUNDARY_EVENTS = 1024;
58
174
 
175
+ // qodercli prints its own API-error notice as an ordinary assistant text frame just before the
176
+ // error result. Forwarding it counts as turn output and bars preflight key recovery, so hold the
177
+ // exact notices for key-recoverable failures (105/110/118, plus the qoder-cn 403 pricing-URL
178
+ // exhaustion signature) downstream of the scaffolding guard and drop a complete held notice only
179
+ // when a key-recoverable error terminal matching that same failure reason follows; once any other
180
+ // client-visible output flows, pass everything through unchanged.
181
+ const QODER_RECOVERABLE_ERROR_NOTICES: ReadonlyArray<{
182
+ readonly text: string;
183
+ readonly reason: QoderRecoverableNoticeReason;
184
+ }> = [
185
+ { text: "Your authentication has expired. Please sign in again.", reason: "auth" },
186
+ { text: "You have reached the daily usage limit. Please try again later.", reason: "daily_limit" },
187
+ { text: "Your personal Credits have been exhausted. Please check your plan.", reason: "personal_credits" },
188
+ { text: 'inference.remoteChat.stream failed (403): {"pricingUrl":"https://qoder.com.cn/pricing?client=qoder"}', reason: "cn_pricing_url" },
189
+ ];
190
+
191
+ export function suppressQoderErrorPreamble(
192
+ emit: (event: AdapterEvent) => void,
193
+ getFailureReason?: () => QoderRecoverableNoticeReason | undefined,
194
+ ): (event: AdapterEvent) => void {
195
+ let held = "";
196
+ let passthrough = false;
197
+ const flush = (): void => {
198
+ passthrough = true;
199
+ if (held) emit({ type: "text_delta", text: held });
200
+ held = "";
201
+ };
202
+ return (event: AdapterEvent): void => {
203
+ if (passthrough) {
204
+ emit(event);
205
+ return;
206
+ }
207
+ if (event.type === "text_delta") {
208
+ const candidate = held + event.text;
209
+ if (QODER_RECOVERABLE_ERROR_NOTICES.some(notice => notice.text.startsWith(candidate))) {
210
+ held = candidate;
211
+ return;
212
+ }
213
+ flush();
214
+ emit(event);
215
+ return;
216
+ }
217
+ if (event.type === "error") {
218
+ const matchedNotice = QODER_RECOVERABLE_ERROR_NOTICES.find(notice => notice.text === held);
219
+ const errorReason = event.apiKeyRecovery === true ? getFailureReason?.() : undefined;
220
+ if (matchedNotice && errorReason === matchedNotice.reason) {
221
+ held = "";
222
+ passthrough = true;
223
+ } else {
224
+ flush();
225
+ }
226
+ emit(event);
227
+ return;
228
+ }
229
+ if (event.type === "heartbeat") {
230
+ emit(event);
231
+ return;
232
+ }
233
+ flush();
234
+ emit(event);
235
+ };
236
+ }
237
+
59
238
  export function buildQoderChildEnv(profile: QoderProfile, apiKey: string, systemPrompt?: string): Record<string, string> {
60
239
  // Each build reads its own brand prefix with no fallback: qodercn ignores QODER_EXPOSE_TOKEN_USAGE.
61
240
  const envPrefix = profile.region === "cn" ? "QODERCN_" : "QODER_";
@@ -347,14 +526,19 @@ export function createQoderAdapter(provider: OcxProviderConfig, deps: QoderAdapt
347
526
  : undefined;
348
527
  // Keep the folded prompt out of argv and never inherit an ambient vendor prompt.
349
528
  const system = buildSystemPrompt(parsed);
529
+ // Keep the classified failure reason in a per-turn closure instead of attaching it to the
530
+ // error object: runCodingAgentTurn redacts and clones error events before emitting them.
531
+ let classifiedFailureReason: QoderRecoverableNoticeReason | undefined;
350
532
  await runCodingAgentTurn({
351
533
  profiles: QODER_PROFILES,
352
534
  conversationInput: buildQoderConversationInput,
353
- classifyFailure: classifyQoderFailure,
535
+ classifyFailure: failure => classifyQoderFailure(failure, reason => {
536
+ classifiedFailureReason = reason;
537
+ }),
354
538
  provider,
355
539
  parsed,
356
540
  incoming,
357
- emit: guardQoderScaffolding(emit),
541
+ emit: guardQoderScaffolding(suppressQoderErrorPreamble(emit, () => classifiedFailureReason)),
358
542
  buildArgs: (_profile, req, prov) => buildQoderArgs(req, prov),
359
543
  buildEnv: (profile, apiKey) => buildQoderChildEnv(profile as QoderProfile, apiKey, system),
360
544
  deps,
@@ -9,6 +9,7 @@ import { withClinePassDeepSeekV4ToolReplayCompatibility } from "./cline-pass-dee
9
9
  import { withUniqueToolCallIds } from "./unique-tool-call-ids";
10
10
  import { createCodeBuddyAdapter } from "./codebuddy/adapter";
11
11
  import { createQoderAdapter } from "./qoder/adapter";
12
+ import { createStepCliAdapter } from "./step-cli/adapter";
12
13
  import { createCommandCodeAdapter } from "./command-code";
13
14
  import { createCursorAdapter } from "./cursor";
14
15
  import { createDevinAdapter } from "./devin";
@@ -23,6 +24,7 @@ import { createZedAdapter } from "./zed";
23
24
  import type { OcxProviderConfig } from "../types";
24
25
  import { createAdapterTierMetadata } from "../providers/fastwire";
25
26
  import { withInputMediaGuard } from "./input-media-guard";
27
+ import { withCommandCodeDecisionModelGuard } from "./command-code-decision-guard";
26
28
 
27
29
  export type AdapterCacheRetention = "none" | "short" | "long";
28
30
 
@@ -42,6 +44,7 @@ export interface AdapterFactoryContext {
42
44
 
43
45
  export type AdapterWire =
44
46
  | "codebuddy"
47
+ | "step-cli"
45
48
  | "command-code"
46
49
  | "openai-chat"
47
50
  | "ollama-native"
@@ -174,6 +177,15 @@ export const ADAPTER_REGISTRY = {
174
177
  contractParent: "codebuddy",
175
178
  create: (provider: OcxProviderConfig, _context: AdapterFactoryContext) => createClaudeCliAdapter(provider),
176
179
  },
180
+ "step-cli": {
181
+ // StepCode's SDK stdio host speaks its own length-prefixed envelope rather than the Anthropic
182
+ // stream-json this repo parses for CodeBuddy, Qoder and Claude Code, so it states its own wire
183
+ // contract. The family owns its args, env and framing, and the CLI owns the credential: the
184
+ // adapter stores and injects none.
185
+ wire: "step-cli",
186
+ mutation: "codex-owned",
187
+ create: (provider: OcxProviderConfig, _context: AdapterFactoryContext) => createStepCliAdapter(provider),
188
+ },
177
189
  "dsh-account": {
178
190
  contractParent: "anthropic",
179
191
  create: (provider: OcxProviderConfig, context: AdapterFactoryContext) => createDshAccountAdapter(provider, context),
@@ -225,6 +237,7 @@ export function createRegisteredAdapter(
225
237
  if (wire !== "openai-responses") {
226
238
  withInputMediaGuard(adapter, wire);
227
239
  }
240
+ withCommandCodeDecisionModelGuard(adapter, provider);
228
241
  const buildRequest = adapter.buildRequest.bind(adapter);
229
242
  adapter.buildRequest = (parsed, incoming) => {
230
243
  const attachTierMetadata = (request: Awaited<ReturnType<ProviderAdapter["buildRequest"]>>) => {