@bitkyc08/opencodex 2.98.0-preview.20261107 → 2.99.0-preview.20261108
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.
- package/bin/ocx.mjs +6 -19
- package/gui/dist/assets/{App-6TFtZsUF.css → App-C1hGwaN1.css} +1 -1
- package/gui/dist/assets/App-CWz0areF.js +59 -0
- package/gui/dist/assets/Tray-BosDoskm.js +1 -0
- package/gui/dist/assets/{brand-mark-VPhzz-WE.js → brand-mark-DpiBmFGI.js} +1 -1
- package/gui/dist/assets/{index-BWKBeK77.js → index-CAxjGWkm.js} +13 -13
- package/gui/dist/assets/index-bnUWypyz.css +2 -0
- package/gui/dist/assets/{segment-thumb-features-BQYzrze9.js → segment-thumb-features-JcszQ18T.js} +1 -1
- package/gui/dist/classic/assets/App-BOEsFmiN.js +58 -0
- package/gui/dist/classic/assets/Tray-5v86r9Az.js +1 -0
- package/gui/dist/classic/assets/{index-Dp2j8bSc.js → index-ClZ_zZ77.js} +13 -13
- package/gui/dist/classic/assets/{quota-summary-CvamtHjB.js → quota-summary-xwvDtvu7.js} +1 -1
- package/gui/dist/classic/index.html +1 -1
- package/gui/dist/index.html +2 -2
- package/package.json +1 -1
- package/src/adapters/coding-agent/protocol.ts +8 -3
- package/src/adapters/coding-agent/turn.ts +6 -2
- package/src/adapters/command-code.ts +8 -5
- package/src/adapters/devin.ts +11 -1
- package/src/adapters/kiro/stream.ts +5 -4
- package/src/adapters/openai-chat/destination-policy.ts +25 -0
- package/src/adapters/openai-chat/native-content.ts +32 -0
- package/src/adapters/openai-chat/passthrough.ts +14 -1
- package/src/adapters/openai-chat/reasoning-wire.ts +42 -1
- package/src/adapters/openai-chat.ts +2 -2
- package/src/adapters/qoder/adapter.ts +9 -0
- package/src/bridge/response-json.ts +13 -1
- package/src/bridge/sse.ts +112 -22
- package/src/cli/account-affinity-reset.ts +42 -0
- package/src/cli/account.ts +5 -0
- package/src/cli/capabilities-accounts.ts +8 -0
- package/src/cli/capabilities-agents-routing.ts +5 -4
- package/src/cli/message-command.ts +1 -1
- package/src/cli/message-mcp-command.ts +8 -5
- package/src/client/orphan-token-recovery.ts +1 -1
- package/src/codex/autostart-health.ts +4 -2
- package/src/generated/compatibility-version.json +128 -76
- package/src/lib/desktop-cli-handoff.mjs +5 -8
- package/src/lib/failure-detail.ts +5 -2
- package/src/lib/launcher-signal-forwarding.d.mts +8 -0
- package/src/lib/launcher-signal-forwarding.mjs +36 -0
- package/src/lib/privacy.ts +6 -0
- package/src/lib/request-execution-budget.ts +188 -33
- package/src/lib/upstream-validation-detail.ts +47 -0
- package/src/lib/workflow-budget.ts +35 -16
- package/src/messaging/mcp-queue-rpc.ts +7 -3
- package/src/messaging/mcp-queue-server.ts +6 -0
- package/src/messaging/mcp-reply-cursor.ts +34 -0
- package/src/messaging/mcp-reply-tools.ts +93 -0
- package/src/oauth/anthropic-routing.ts +46 -3
- package/src/oauth/anthropic-session-affinity-store.ts +23 -10
- package/src/protocols/codecs/ollama.ts +22 -12
- package/src/providers/registry/entries-extended.ts +14 -0
- package/src/remote/hub-usage.ts +7 -0
- package/src/responses/parser.ts +27 -0
- package/src/responses/reasoning-envelope.ts +4 -0
- package/src/responses/schema.ts +1 -0
- package/src/server/chat-completions.ts +3 -0
- package/src/server/chat-native-sse.ts +14 -10
- package/src/server/chat-native.ts +24 -11
- package/src/server/index/websocket-handler.ts +12 -1
- package/src/server/management/oauth-account-routes.ts +65 -13
- package/src/server/management/route-registry.ts +1 -0
- package/src/server/messages-native.ts +21 -5
- package/src/server/request-log-attempt-recovery.ts +17 -0
- package/src/server/request-log-failure-detail.ts +18 -1
- package/src/server/request-log.ts +5 -18
- package/src/server/responses/account-auto-pause-recovery.ts +29 -1
- package/src/server/responses/adapter-continuation.ts +12 -5
- package/src/server/responses/adapter-dispatch.ts +50 -51
- package/src/server/responses/antigravity-model-denial-recovery.ts +4 -2
- package/src/server/responses/codex-ws-exchange.ts +13 -4
- package/src/server/responses/combo-required-tool-contract.ts +22 -3
- package/src/server/responses/core-codex-account.ts +92 -86
- package/src/server/responses/core-combo-failure.ts +7 -0
- package/src/server/responses/core-combo.ts +11 -4
- package/src/server/responses/core-lifetime.ts +3 -0
- package/src/server/responses/deferred-send-reporter.ts +18 -1
- package/src/server/responses/fetch-helpers.ts +9 -3
- package/src/server/responses/native-continuation-refusal.ts +8 -0
- package/src/server/responses/native-continuation-send.ts +34 -0
- package/src/server/responses/passthrough-delivery.ts +6 -2
- package/src/server/responses/passthrough-dispatch.ts +48 -33
- package/src/server/responses/passthrough-execution.ts +1 -0
- package/src/server/responses/policy-fallback.ts +32 -5
- package/src/server/responses/policy-request-scope.ts +26 -0
- package/src/server/responses/request-prepare.ts +11 -2
- package/src/server/responses/request-send-budget.ts +96 -14
- package/src/server/responses/request-spend-target.ts +19 -0
- package/src/server/responses/request-spend.ts +80 -28
- package/src/server/responses/request-transport.ts +106 -53
- package/src/server/responses/run-turn-execution.ts +3 -0
- package/src/server/responses/sidecar-execution.ts +2 -1
- package/src/server/responses/ws-upstream.ts +2 -1
- package/src/server/workflow-refusal.ts +38 -4
- package/src/server/ws-bridge.ts +10 -3
- package/src/service/desktop-startup.ts +76 -13
- package/src/types/request.ts +2 -1
- package/src/usage/app-breakdown.ts +23 -0
- package/src/usage/summary.ts +34 -1
- package/src/web-search/anthropic-executor.ts +25 -9
- package/src/web-search/loop.ts +3 -1
- package/src/web-search/passthrough-bridge.ts +3 -0
- package/src/web-search/run-turn-loop.ts +3 -1
- package/gui/dist/assets/App-B8_sOxoz.js +0 -59
- package/gui/dist/assets/Tray-DpWEp6ee.js +0 -1
- package/gui/dist/assets/index-5REODpG3.css +0 -2
- package/gui/dist/classic/assets/App-Bz65x1J6.js +0 -58
- package/gui/dist/classic/assets/Tray-kk7mdO6I.js +0 -1
|
@@ -217,6 +217,7 @@ function buildResponseJSONWithBudget(
|
|
|
217
217
|
let rawReasoningForNextToolCall = "";
|
|
218
218
|
// Anthropic extended-thinking round-trip (batch): see bridgeToResponsesSSE counterpart.
|
|
219
219
|
let batchSignature: string | undefined;
|
|
220
|
+
let batchSignatureAfter: string | undefined;
|
|
220
221
|
let batchSignatureBytes = 0;
|
|
221
222
|
let batchRedacted: string[] = [];
|
|
222
223
|
let batchRedactedBytes = 0;
|
|
@@ -276,12 +277,14 @@ function buildResponseJSONWithBudget(
|
|
|
276
277
|
if (!summaryText && !batchSignature && batchRedacted.length === 0) return;
|
|
277
278
|
const envelope: ReasoningEnvelope = {};
|
|
278
279
|
if (batchSignature) envelope.sig = batchSignature;
|
|
280
|
+
if (batchSignatureAfter) envelope.aft = batchSignatureAfter;
|
|
279
281
|
if (batchRedacted.length > 0) envelope.red = batchRedacted;
|
|
280
282
|
const hidden = options?.hideThinkingSummary === true;
|
|
281
283
|
if (hidden && summaryText && (envelope.sig || envelope.red)) envelope.txt = summaryText;
|
|
282
284
|
const encrypted = envelope.sig || envelope.red || envelope.txt ? encodeReasoningEnvelope(envelope, budget) : undefined;
|
|
283
285
|
const sourceBytes = currentSummaryReasoning.bytes + batchSignatureBytes + batchRedactedBytes;
|
|
284
286
|
batchSignature = undefined;
|
|
287
|
+
batchSignatureAfter = undefined;
|
|
285
288
|
batchSignatureBytes = 0;
|
|
286
289
|
batchRedacted = [];
|
|
287
290
|
batchRedactedBytes = 0;
|
|
@@ -440,12 +443,21 @@ function buildResponseJSONWithBudget(
|
|
|
440
443
|
);
|
|
441
444
|
}
|
|
442
445
|
break;
|
|
443
|
-
case "thinking_signature":
|
|
446
|
+
case "thinking_signature": {
|
|
444
447
|
// Like streaming, retain the latest signature update until the next semantic
|
|
445
448
|
// event. Flushing every update would manufacture signature-only siblings.
|
|
446
449
|
batchSignatureBytes = replaceBatchRetainedString(batchSignatureBytes, e.signature, "reasoning");
|
|
447
450
|
batchSignature = e.signature;
|
|
451
|
+
const lastOutput = output[output.length - 1];
|
|
452
|
+
// Open outputs still flush after their reasoning, preserving legacy ordering.
|
|
453
|
+
// An explicitly late signature for an already-closed output needs a back-reference.
|
|
454
|
+
batchSignatureAfter = e.afterOutput && !currentText.bytes && !currentToolCallId
|
|
455
|
+
&& !currentSummaryReasoning.bytes && lastOutput
|
|
456
|
+
&& (["message", "function_call", "custom_tool_call"].includes(lastOutput.type)
|
|
457
|
+
|| (lastOutput.type === "tool_search_call" && lastOutput.execution === "client"))
|
|
458
|
+
? lastOutput.id : undefined;
|
|
448
459
|
break;
|
|
460
|
+
}
|
|
449
461
|
case "redacted_thinking":
|
|
450
462
|
flushText("commentary");
|
|
451
463
|
flushSummaryReasoning();
|
package/src/bridge/sse.ts
CHANGED
|
@@ -390,13 +390,16 @@ export function bridgeToResponsesSSE(
|
|
|
390
390
|
// item as an ocxr1 encrypted_content envelope on close. hiddenThinkingText collects the
|
|
391
391
|
// suppressed text under hideThinkingSummary so the signed text still round-trips.
|
|
392
392
|
let pendingSignature: string | undefined;
|
|
393
|
+
let pendingSignatureAfter: string | undefined;
|
|
394
|
+
let pendingSignatureAfterOutput = false;
|
|
393
395
|
let pendingSignatureBytes = 0;
|
|
394
396
|
let pendingRedacted: string[] = [];
|
|
395
397
|
let hiddenThinking = emptyChunks();
|
|
396
|
-
const takeReasoningEnvelope = (hiddenText?: string): string | undefined => {
|
|
398
|
+
const takeReasoningEnvelope = (hiddenText?: string, after?: string): string | undefined => {
|
|
397
399
|
if (!pendingSignature && pendingRedacted.length === 0) return undefined;
|
|
398
400
|
const envelope: ReasoningEnvelope = {};
|
|
399
401
|
if (pendingSignature) envelope.sig = pendingSignature;
|
|
402
|
+
if (after ?? pendingSignatureAfter) envelope.aft = after ?? pendingSignatureAfter;
|
|
400
403
|
if (pendingRedacted.length > 0) envelope.red = pendingRedacted;
|
|
401
404
|
if (hiddenText) envelope.txt = hiddenText;
|
|
402
405
|
const previousBytes = pendingSignatureBytes
|
|
@@ -405,25 +408,84 @@ export function bridgeToResponsesSSE(
|
|
|
405
408
|
const encoded = encodeReasoningEnvelope(envelope, budget);
|
|
406
409
|
const reservation = budget?.reserveTransient(bytesOf(encoded), { kind: "reasoning" });
|
|
407
410
|
pendingSignature = undefined;
|
|
411
|
+
pendingSignatureAfter = undefined;
|
|
412
|
+
pendingSignatureAfterOutput = false;
|
|
408
413
|
pendingSignatureBytes = 0;
|
|
409
414
|
pendingRedacted = [];
|
|
410
415
|
reservation?.commitRetained();
|
|
411
416
|
budget?.releaseRetained(previousBytes, { kind: "reasoning" });
|
|
412
417
|
return encoded;
|
|
413
418
|
};
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
const
|
|
419
|
+
let deferredHiddenReasoning: string[] = [];
|
|
420
|
+
let deferredHiddenReasoningIndex = 0;
|
|
421
|
+
const deferredReasoningEntryBytes = 32; // Queue bookkeeping, in addition to each retained payload.
|
|
422
|
+
/** Release unconsumed queue payloads and entry overhead on cancellation or translation overflow. */
|
|
423
|
+
const discardDeferredHiddenReasoning = () => {
|
|
424
|
+
for (let i = deferredHiddenReasoningIndex; i < deferredHiddenReasoning.length; i++) {
|
|
425
|
+
budget?.releaseRetained(bytesOf(deferredHiddenReasoning[i]!) + deferredReasoningEntryBytes, { kind: "reasoning" });
|
|
426
|
+
}
|
|
427
|
+
deferredHiddenReasoning = [];
|
|
428
|
+
deferredHiddenReasoningIndex = 0;
|
|
429
|
+
};
|
|
430
|
+
/** Transfer a retained envelope into a closed item; release failed direct sends, while queues own theirs. */
|
|
431
|
+
const emitHiddenReasoningEnvelope = (encrypted: string, queued = false): boolean => {
|
|
432
|
+
let transferred = false;
|
|
433
|
+
try {
|
|
434
|
+
if (closed) return false;
|
|
435
|
+
const itemId = outputItemId("reasoning", "rs");
|
|
436
|
+
const item = { type: "reasoning", id: itemId, summary: [] as never[], encrypted_content: encrypted };
|
|
437
|
+
emit("response.output_item.added", { output_index: outputIndex, item });
|
|
438
|
+
if (closed) return false;
|
|
439
|
+
emit("response.output_item.done", { output_index: outputIndex, item });
|
|
440
|
+
if (closed) return false;
|
|
441
|
+
retainFinishedItem(item as OutputItem, bytesOf(encrypted), "reasoning");
|
|
442
|
+
transferred = true;
|
|
443
|
+
outputIndex++;
|
|
444
|
+
return true;
|
|
445
|
+
} finally {
|
|
446
|
+
if (!transferred && !queued) budget?.releaseRetained(bytesOf(encrypted), { kind: "reasoning" });
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
/** Drain independent hidden blocks only after the open tool has safely released its index. */
|
|
450
|
+
const flushDeferredHiddenReasoning = () => {
|
|
451
|
+
if (currentToolCall) return;
|
|
452
|
+
while (deferredHiddenReasoningIndex < deferredHiddenReasoning.length) {
|
|
453
|
+
if (!emitHiddenReasoningEnvelope(deferredHiddenReasoning[deferredHiddenReasoningIndex]!, true)) {
|
|
454
|
+
discardDeferredHiddenReasoning();
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
budget?.releaseRetained(deferredReasoningEntryBytes, { kind: "reasoning" });
|
|
458
|
+
deferredHiddenReasoning[deferredHiddenReasoningIndex++] = "";
|
|
459
|
+
}
|
|
460
|
+
deferredHiddenReasoning = [];
|
|
461
|
+
deferredHiddenReasoningIndex = 0;
|
|
462
|
+
};
|
|
463
|
+
/** Queue retained raw/ordinary envelopes behind an open tool, prioritizing a safely closed owner's trailer. */
|
|
464
|
+
const deliverHiddenReasoningEnvelope = (encrypted: string, afterOutput = false) => {
|
|
465
|
+
if (currentToolCall) {
|
|
466
|
+
try {
|
|
467
|
+
budget?.chargeRetained(deferredReasoningEntryBytes, { kind: "reasoning" });
|
|
468
|
+
deferredHiddenReasoning.push(encrypted);
|
|
469
|
+
} catch (error) {
|
|
470
|
+
budget?.releaseRetained(bytesOf(encrypted), { kind: "reasoning" });
|
|
471
|
+
throw error;
|
|
472
|
+
}
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
// A turn-level trailer must stay adjacent to its owner, ahead of ordinary hidden blocks.
|
|
476
|
+
if (afterOutput) emitHiddenReasoningEnvelope(encrypted);
|
|
477
|
+
flushDeferredHiddenReasoning();
|
|
478
|
+
if (!afterOutput) emitHiddenReasoningEnvelope(encrypted);
|
|
479
|
+
};
|
|
480
|
+
/** Seal hidden thinking without issuing an unfinished call; explicit late trailers wait for owner closure. */
|
|
481
|
+
const flushHiddenReasoningEnvelope = (after?: string) => {
|
|
482
|
+
if (currentToolCall && pendingSignatureAfterOutput) return;
|
|
417
483
|
const hiddenText = joinChunks(hiddenThinking);
|
|
418
|
-
const
|
|
484
|
+
const afterOutput = pendingSignatureAfterOutput;
|
|
485
|
+
const encrypted = takeReasoningEnvelope(hiddenText || undefined, after);
|
|
419
486
|
hiddenThinking = emptyChunks();
|
|
420
|
-
if (
|
|
421
|
-
|
|
422
|
-
const item = { type: "reasoning", id: itemId, summary: [] as never[], encrypted_content: encrypted };
|
|
423
|
-
emit("response.output_item.added", { output_index: outputIndex, item });
|
|
424
|
-
emit("response.output_item.done", { output_index: outputIndex, item });
|
|
425
|
-
retainFinishedItem(item as OutputItem, bytesOf(encrypted), "reasoning");
|
|
426
|
-
outputIndex++;
|
|
487
|
+
if (encrypted) deliverHiddenReasoningEnvelope(encrypted, afterOutput);
|
|
488
|
+
else flushDeferredHiddenReasoning();
|
|
427
489
|
};
|
|
428
490
|
// hideThinkingSummary for RAW reasoning (openai-chat reasoning_content, kiro tags): no
|
|
429
491
|
// visible reasoning item is emitted — the app renders nothing, so tool cells keep grouping
|
|
@@ -447,12 +509,7 @@ export function bridgeToResponsesSSE(
|
|
|
447
509
|
hiddenRawReasoning = emptyChunks();
|
|
448
510
|
reservation?.commitRetained();
|
|
449
511
|
budget?.releaseRetained(previousBytes, { kind: "reasoning" });
|
|
450
|
-
|
|
451
|
-
const item = { type: "reasoning", id: itemId, summary: [] as never[], encrypted_content: encrypted };
|
|
452
|
-
emit("response.output_item.added", { output_index: outputIndex, item });
|
|
453
|
-
emit("response.output_item.done", { output_index: outputIndex, item });
|
|
454
|
-
retainFinishedItem(item as OutputItem, bytesOf(encrypted), "reasoning");
|
|
455
|
-
outputIndex++;
|
|
512
|
+
deliverHiddenReasoningEnvelope(encrypted);
|
|
456
513
|
};
|
|
457
514
|
// Kiro reasoning round-trip. Kiro sends its encrypted blob at the END of a turn, while the
|
|
458
515
|
// assistant message is still open, so this CANNOT emit on arrival: the open message still
|
|
@@ -544,6 +601,7 @@ export function bridgeToResponsesSSE(
|
|
|
544
601
|
retainFinishedItem(item as OutputItem, currentMsg.text.bytes + bytesOf(JSON.stringify(annotations)));
|
|
545
602
|
outputIndex++;
|
|
546
603
|
currentMsg = null;
|
|
604
|
+
if (pendingSignatureAfterOutput) flushHiddenReasoningEnvelope(item.id);
|
|
547
605
|
};
|
|
548
606
|
|
|
549
607
|
const closeCurrentReasoning = () => {
|
|
@@ -643,6 +701,8 @@ export function bridgeToResponsesSSE(
|
|
|
643
701
|
budget?.closeCall(currentToolCall.callId);
|
|
644
702
|
outputIndex++;
|
|
645
703
|
currentToolCall = null;
|
|
704
|
+
if (pendingSignatureAfterOutput) flushHiddenReasoningEnvelope(item.id);
|
|
705
|
+
flushDeferredHiddenReasoning();
|
|
646
706
|
};
|
|
647
707
|
|
|
648
708
|
// Terminal-error / incomplete path for an open tool call (#765 remainder).
|
|
@@ -683,6 +743,8 @@ export function bridgeToResponsesSSE(
|
|
|
683
743
|
budget?.closeCall(currentToolCall.callId);
|
|
684
744
|
outputIndex++;
|
|
685
745
|
currentToolCall = null;
|
|
746
|
+
if (pendingSignatureAfterOutput) flushHiddenReasoningEnvelope(item.id);
|
|
747
|
+
flushDeferredHiddenReasoning();
|
|
686
748
|
};
|
|
687
749
|
|
|
688
750
|
const abortCurrentToolCallForTranslatorOverflow = () => {
|
|
@@ -788,6 +850,7 @@ export function bridgeToResponsesSSE(
|
|
|
788
850
|
const usage = (error as AdapterEvent | null | undefined)?.type === "error"
|
|
789
851
|
? (error as Extract<AdapterEvent, { type: "error" }>).usage : undefined;
|
|
790
852
|
if (usage) options?.onUsage?.(usage);
|
|
853
|
+
discardDeferredHiddenReasoning();
|
|
791
854
|
abortCurrentToolCallForTranslatorOverflow();
|
|
792
855
|
currentWebSearch = null;
|
|
793
856
|
releasePendingWebSources();
|
|
@@ -884,9 +947,18 @@ export function bridgeToResponsesSSE(
|
|
|
884
947
|
// Anthropic signature_delta supplies the latest signature, not an append-only
|
|
885
948
|
// fragment (anthropic-sdk-typescript MessageStream). Keep consecutive updates
|
|
886
949
|
// together; the next semantic event belongs to the following block.
|
|
887
|
-
if (pendingSignature !== undefined && event.type !== "thinking_signature" && event.type !== "heartbeat"
|
|
950
|
+
if (pendingSignature !== undefined && event.type !== "thinking_signature" && event.type !== "heartbeat"
|
|
951
|
+
&& !["done", "error", "incomplete", "tool_call_end"].includes(event.type)) {
|
|
952
|
+
// Terminal/tool-end handlers decide whether an open call completed safely.
|
|
888
953
|
if (currentReasoning) closeCurrentReasoning();
|
|
889
|
-
else
|
|
954
|
+
else if (!pendingSignatureAfterOutput) {
|
|
955
|
+
// Hidden thinking cannot issue an unfinished tool. Seal each block independently
|
|
956
|
+
// and let the tool's safe close drain its deferred carriers at fresh indexes.
|
|
957
|
+
closeCurrentMessage("commentary");
|
|
958
|
+
if (!options?.hideThinkingSummary) closeCurrentToolCall();
|
|
959
|
+
flushHiddenReasoningEnvelope();
|
|
960
|
+
} else if (!currentMsg && !currentToolCall) flushHiddenReasoningEnvelope();
|
|
961
|
+
// Explicit late turn signatures wait for the open output's close helper.
|
|
890
962
|
}
|
|
891
963
|
switch (event.type) {
|
|
892
964
|
case "assistant_boundary": {
|
|
@@ -927,6 +999,7 @@ export function bridgeToResponsesSSE(
|
|
|
927
999
|
}
|
|
928
1000
|
if (currentReasoning) closeCurrentReasoning();
|
|
929
1001
|
if (currentRawReasoning) closeCurrentRawReasoning();
|
|
1002
|
+
if (currentMsg && hiddenRawReasoning.bytes > 0) closeCurrentMessage("commentary");
|
|
930
1003
|
flushHiddenRawReasoning();
|
|
931
1004
|
// Reasoning consumed by a REAL text turn, not a tool call: no cache target.
|
|
932
1005
|
// Empty text deltas must not wipe reasoning that precedes a tool call
|
|
@@ -974,6 +1047,7 @@ export function bridgeToResponsesSSE(
|
|
|
974
1047
|
break;
|
|
975
1048
|
}
|
|
976
1049
|
case "thinking_delta": {
|
|
1050
|
+
if (currentMsg) closeCurrentMessage("commentary");
|
|
977
1051
|
if (options?.hideThinkingSummary) {
|
|
978
1052
|
// The hidden branch returns early, so flush any raw reasoning
|
|
979
1053
|
// that preceded the thinking block and clear the replay-cache
|
|
@@ -988,7 +1062,6 @@ export function bridgeToResponsesSSE(
|
|
|
988
1062
|
);
|
|
989
1063
|
break;
|
|
990
1064
|
}
|
|
991
|
-
if (currentMsg) closeCurrentMessage("commentary");
|
|
992
1065
|
if (currentRawReasoning) closeCurrentRawReasoning();
|
|
993
1066
|
flushHiddenRawReasoning();
|
|
994
1067
|
if (event.thinking.length > 0) rawReasoningForNextToolCall = "";
|
|
@@ -1017,6 +1090,14 @@ export function bridgeToResponsesSSE(
|
|
|
1017
1090
|
case "thinking_signature": {
|
|
1018
1091
|
pendingSignatureBytes = replaceRetainedString(pendingSignatureBytes, event.signature, "reasoning");
|
|
1019
1092
|
pendingSignature = event.signature;
|
|
1093
|
+
const lastOutput = finishedItems[finishedItems.length - 1];
|
|
1094
|
+
pendingSignatureAfterOutput = event.afterOutput === true;
|
|
1095
|
+
pendingSignatureAfter = event.afterOutput
|
|
1096
|
+
? currentMsg?.itemId ?? currentToolCall?.itemId
|
|
1097
|
+
?? (!currentReasoning && lastOutput
|
|
1098
|
+
&& (["message", "function_call", "custom_tool_call"].includes(lastOutput.type)
|
|
1099
|
+
|| (lastOutput.type === "tool_search_call" && lastOutput.execution === "client")) ? lastOutput.id : undefined)
|
|
1100
|
+
: undefined;
|
|
1020
1101
|
// Delay closing until the next semantic event so a signature update cannot
|
|
1021
1102
|
// create another block or become attached to the following thinking text.
|
|
1022
1103
|
break;
|
|
@@ -1026,7 +1107,7 @@ export function bridgeToResponsesSSE(
|
|
|
1026
1107
|
if (currentReasoning) closeCurrentReasoning();
|
|
1027
1108
|
if (currentRawReasoning) closeCurrentRawReasoning();
|
|
1028
1109
|
flushHiddenRawReasoning();
|
|
1029
|
-
if (currentToolCall) closeCurrentToolCall();
|
|
1110
|
+
if (currentToolCall && !options?.hideThinkingSummary) closeCurrentToolCall();
|
|
1030
1111
|
budget?.chargeRetained(bytesOf(event.data), { kind: "reasoning" });
|
|
1031
1112
|
pendingRedacted.push(event.data);
|
|
1032
1113
|
// A redacted block is complete at content_block_start. Emit it here,
|
|
@@ -1202,6 +1283,7 @@ export function bridgeToResponsesSSE(
|
|
|
1202
1283
|
&& !toolCallArgumentsUsable(currentToolCall.args)
|
|
1203
1284
|
) {
|
|
1204
1285
|
failCurrentToolCall();
|
|
1286
|
+
flushHiddenReasoningEnvelope();
|
|
1205
1287
|
const failure = responseError(
|
|
1206
1288
|
502,
|
|
1207
1289
|
"upstream_error",
|
|
@@ -1394,6 +1476,7 @@ export function bridgeToResponsesSSE(
|
|
|
1394
1476
|
if (currentToolCall) failCurrentToolCall();
|
|
1395
1477
|
if (currentWebSearch) closeCurrentWebSearch("failed", []);
|
|
1396
1478
|
releasePendingWebSources();
|
|
1479
|
+
flushHiddenReasoningEnvelope();
|
|
1397
1480
|
const failure = adapterFailureFromEvent(event);
|
|
1398
1481
|
if (event.usage) options?.onUsage?.(event.usage);
|
|
1399
1482
|
await awaitThoughtSignatureDurability();
|
|
@@ -1431,10 +1514,14 @@ export function bridgeToResponsesSSE(
|
|
|
1431
1514
|
}
|
|
1432
1515
|
if (!terminated) {
|
|
1433
1516
|
if (!attemptTerminationCleanup(() => {
|
|
1517
|
+
if (currentMsg) closeCurrentMessage();
|
|
1518
|
+
if (currentReasoning) closeCurrentReasoning();
|
|
1519
|
+
if (currentRawReasoning) closeCurrentRawReasoning();
|
|
1434
1520
|
flushHiddenRawReasoning();
|
|
1435
1521
|
if (currentToolCall) failCurrentToolCall();
|
|
1436
1522
|
if (currentWebSearch) closeCurrentWebSearch("failed", []);
|
|
1437
1523
|
releasePendingWebSources();
|
|
1524
|
+
flushHiddenReasoningEnvelope();
|
|
1438
1525
|
})) return;
|
|
1439
1526
|
const failure = responseError(
|
|
1440
1527
|
500,
|
|
@@ -1473,6 +1560,7 @@ export function bridgeToResponsesSSE(
|
|
|
1473
1560
|
if (currentToolCall) failCurrentToolCall();
|
|
1474
1561
|
if (currentWebSearch) closeCurrentWebSearch("failed", []);
|
|
1475
1562
|
releasePendingWebSources();
|
|
1563
|
+
flushHiddenReasoningEnvelope();
|
|
1476
1564
|
})) return;
|
|
1477
1565
|
options?.onUsage?.(undefined);
|
|
1478
1566
|
await awaitThoughtSignatureDurability();
|
|
@@ -1528,6 +1616,7 @@ export function bridgeToResponsesSSE(
|
|
|
1528
1616
|
if (currentToolCall) failCurrentToolCall();
|
|
1529
1617
|
if (currentWebSearch) closeCurrentWebSearch("failed", []);
|
|
1530
1618
|
releasePendingWebSources();
|
|
1619
|
+
flushHiddenReasoningEnvelope();
|
|
1531
1620
|
})) return;
|
|
1532
1621
|
// #1926 gap 2 residual: this beat callback is synchronous, so the durability
|
|
1533
1622
|
// barrier is not awaited on the stall-timeout kill path. The in-memory store is
|
|
@@ -1583,6 +1672,7 @@ export function bridgeToResponsesSSE(
|
|
|
1583
1672
|
if (beat !== undefined) clearBeatInterval(beat);
|
|
1584
1673
|
cancelUpstreamOnce();
|
|
1585
1674
|
releasePendingWebSources();
|
|
1675
|
+
discardDeferredHiddenReasoning();
|
|
1586
1676
|
disposeOwnedBudget();
|
|
1587
1677
|
},
|
|
1588
1678
|
}));
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { isAnthropicOAuthInstance } from "../providers/anthropic-instance";
|
|
2
|
+
import { apiJson, LINK_HOME_BASE, resolveBaseUrl, type AccountDeps } from "./account-api";
|
|
3
|
+
|
|
4
|
+
/** Provider-only recovery remains available after the last account was removed. */
|
|
5
|
+
export async function cmdResetAffinity(args: string[], deps: AccountDeps): Promise<number> {
|
|
6
|
+
const wantsJson = args.includes("--json");
|
|
7
|
+
const positional = args.filter(arg => arg !== "--json");
|
|
8
|
+
const provider = positional[0]?.trim().toLowerCase() ?? "";
|
|
9
|
+
const fail = (code: string, message: string, exit = 1, retryable = false): number => {
|
|
10
|
+
if (wantsJson) console.log(JSON.stringify({ ok: false, code, retryable }));
|
|
11
|
+
else console.error(message);
|
|
12
|
+
return exit;
|
|
13
|
+
};
|
|
14
|
+
if (positional.length !== 1 || !isAnthropicOAuthInstance(provider) || args.filter(arg => arg === "--json").length > 1) {
|
|
15
|
+
return fail("invalid_arguments", "Usage: ocx account reset-affinity <anthropic|anthropic2> [--json]");
|
|
16
|
+
}
|
|
17
|
+
if (!deps.baseUrl || deps.baseUrl === LINK_HOME_BASE) {
|
|
18
|
+
const refusal = (await import("./link-child")).linkChildProviderChangeRefusal("ocx account reset-affinity");
|
|
19
|
+
if (refusal) {
|
|
20
|
+
if (wantsJson) console.log(JSON.stringify({ ok: false, code: "link_child_management_unavailable", retryable: false, message: refusal }));
|
|
21
|
+
else console.error(refusal);
|
|
22
|
+
return 1;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const baseUrl = await resolveBaseUrl(deps);
|
|
26
|
+
if (!baseUrl) return fail("proxy_unreachable", "Proxy not reachable. Start it with 'ocx start' or 'ocx ensure'.");
|
|
27
|
+
const response = await apiJson(deps, baseUrl, "PUT", "/api/oauth/accounts/affinity-reset", { provider });
|
|
28
|
+
if (response.status === 0) return fail("proxy_unreachable", "Proxy not reachable; affinity reset was not confirmed.");
|
|
29
|
+
const result = response.json;
|
|
30
|
+
if (response.status !== 200) {
|
|
31
|
+
const pending = result?.code === "affinity_reset_not_persisted" && result.retryable === true;
|
|
32
|
+
return fail(pending ? "affinity_reset_not_persisted" : "affinity_reset_failed",
|
|
33
|
+
pending ? "Session-affinity reset was not persisted; retry this command." : `Affinity reset failed (HTTP ${response.status}).`,
|
|
34
|
+
response.status === 404 ? 4 : response.status === 409 ? 5 : 1, pending);
|
|
35
|
+
}
|
|
36
|
+
if (result?.ok !== true || result.provider !== provider || result.affinityResetConfirmed !== true) {
|
|
37
|
+
return fail("affinity_reset_unconfirmed", "Server did not confirm the session-affinity reset; success is unknown.");
|
|
38
|
+
}
|
|
39
|
+
if (wantsJson) console.log(JSON.stringify({ ok: true, provider, affinityResetConfirmed: true }));
|
|
40
|
+
else console.log(`${provider}: session-affinity reset confirmed; account selection and pause state unchanged.`);
|
|
41
|
+
return 0;
|
|
42
|
+
}
|
package/src/cli/account.ts
CHANGED
|
@@ -58,6 +58,7 @@ const ACCOUNT_USAGE = `Usage:
|
|
|
58
58
|
ocx account priority <provider> <account-id|alias|main> [<-100..100|first|earlier|normal|later|last|reset>] [--json]
|
|
59
59
|
ocx account pause <provider> <account-id|alias|main> [--json]
|
|
60
60
|
ocx account resume <provider> <account-id|alias|main> [--json]
|
|
61
|
+
ocx account reset-affinity <anthropic|anthropic2> [--json]
|
|
61
62
|
ocx account pause-exhausted <provider> [--json]
|
|
62
63
|
ocx account strategy <provider> [<quota|round-robin|fill-first|least-loaded|reset-first>] [--json]
|
|
63
64
|
ocx account sticky <provider> [<1-100>] [--json]
|
|
@@ -487,6 +488,10 @@ export async function cmdAccount(args: string[], deps: AccountDeps = {}): Promis
|
|
|
487
488
|
// dashboard-only capabilities.
|
|
488
489
|
if (sub === "pause") return await cmdPause(rest, deps, true);
|
|
489
490
|
if (sub === "resume") return await cmdPause(rest, deps, false);
|
|
491
|
+
if (sub === "reset-affinity") {
|
|
492
|
+
const { cmdResetAffinity } = await import("./account-affinity-reset");
|
|
493
|
+
return await cmdResetAffinity(rest, deps);
|
|
494
|
+
}
|
|
490
495
|
if (sub === "pause-exhausted") return await cmdPauseExhausted(rest, deps);
|
|
491
496
|
if (sub === "strategy") return await cmdStrategy(rest, deps);
|
|
492
497
|
if (sub === "sticky") return await cmdSticky(rest, deps);
|
|
@@ -2,6 +2,14 @@ import type { Capability } from "./capability-types";
|
|
|
2
2
|
|
|
3
3
|
/** Account pool operations and physical native-login profiles have separate owners. */
|
|
4
4
|
export const ACCOUNT_CAPABILITIES: readonly Capability[] = [
|
|
5
|
+
{
|
|
6
|
+
command: ["account", "reset-affinity"], summary: "Confirm a provider-wide Anthropic session-affinity reset.",
|
|
7
|
+
usage: "ocx account reset-affinity <anthropic|anthropic2> [--json]",
|
|
8
|
+
routes: [{ method: "PUT", path: "/api/oauth/accounts/affinity-reset" }],
|
|
9
|
+
flags: [{ name: "--json", value: "boolean", summary: "Emit the confirmed reset or failure receipt." }],
|
|
10
|
+
mutates: true, json: "envelope",
|
|
11
|
+
details: ["Clears all provider session bindings, including bindings formed after an earlier failed reset. Works with an empty roster; never selects or resumes an account. Sends once and requires an explicit durable confirmation."],
|
|
12
|
+
},
|
|
5
13
|
{
|
|
6
14
|
command: ["account", "preserve-signed-in"], summary: "Prefer other Codex identities and reserve the native sign-in as fallback.",
|
|
7
15
|
usage: "ocx account preserve-signed-in openai [on|off|status] [--apply-to-bound] [--json]",
|
|
@@ -27,13 +27,14 @@ export const AGENT_ROUTING_CAPABILITIES: readonly Capability[] = [
|
|
|
27
27
|
"Exit 0: queued; 1: not sent; 3: unknown; 64: invalid usage. No Claude transport, native lifecycle mutation or skill installation."],
|
|
28
28
|
},
|
|
29
29
|
{
|
|
30
|
-
command: ["message", "mcp"], usage: "ocx message mcp --codex <absolute-cli-path> --codex-home <absolute-existing-home>",
|
|
31
|
-
summary: "Serve
|
|
30
|
+
command: ["message", "mcp"], usage: "ocx message mcp --codex <absolute-cli-path> --codex-home <absolute-existing-home> [--allow-reply-read]",
|
|
31
|
+
summary: "Serve MCP tools for stored Codex metadata, queued text and explicitly enabled stored-turn reply reads.",
|
|
32
32
|
routes: [], mutates: true, json: "none",
|
|
33
33
|
flags: [{ name: "--codex", value: "string", required: true, summary: "Explicit local Codex CLI executable." },
|
|
34
|
-
{ name: "--codex-home", value: "string", required: true, summary: "Explicit existing Codex home; no creation or login." }
|
|
34
|
+
{ name: "--codex-home", value: "string", required: true, summary: "Explicit existing Codex home; no creation or login." },
|
|
35
|
+
{ name: "--allow-reply-read", value: "boolean", summary: "Explicitly expose stored final-turn text through codex_read_reply; disabled by default." }],
|
|
35
36
|
details: ["macOS/Linux only. No proxy/control socket required. Starts bounded stdio helpers only when a tool is called; existing sessions/send behavior stays unchanged.",
|
|
36
|
-
"Stored threads are not verified live sessions. queued is not processing; unknown is never replayed. No daemon start, thread resume, steer, automatic replies or registration."],
|
|
37
|
+
"Stored threads are not verified live sessions. queued is not processing; unknown is never replayed. --allow-reply-read exposes bounded same-turn final text, not exclusive reply ownership or goal completion. No daemon start, thread resume, steer, automatic replies or registration."],
|
|
37
38
|
},
|
|
38
39
|
{
|
|
39
40
|
command: ["advisor"],
|
|
@@ -12,7 +12,7 @@ export async function runMessageCommand(argv: readonly string[], env: NodeJS.Pro
|
|
|
12
12
|
if (remote) return (await import("./message-remote-command")).runRemoteMessageCommand(remote, env);
|
|
13
13
|
const args = parseMessageArgs(argv);
|
|
14
14
|
if (!args) {
|
|
15
|
-
console.error("Usage: ocx message sessions [--host <peer>] [--json] | send (--thread <uuid> | --name <exact-name>) --stdin [--host <peer>] [--kind request|response|notification] [--in-reply-to <uuid>] [--json] | mcp --codex <absolute-cli-path> --codex-home <absolute-existing-home> | enable [--port <port>] | disable | status | hosts <probe|add|list|remove|abandon|allow-inbound|deny-inbound> | serve [--host <peer>]...");
|
|
15
|
+
console.error("Usage: ocx message sessions [--host <peer>] [--json] | send (--thread <uuid> | --name <exact-name>) --stdin [--host <peer>] [--kind request|response|notification] [--in-reply-to <uuid>] [--json] | mcp --codex <absolute-cli-path> --codex-home <absolute-existing-home> [--allow-reply-read] | enable [--port <port>] | disable | status | hosts <probe|add|list|remove|abandon|allow-inbound|deny-inbound> | serve [--host <peer>]...");
|
|
16
16
|
return 64;
|
|
17
17
|
}
|
|
18
18
|
const controller = new AbortController();
|
|
@@ -3,21 +3,24 @@ import type { QueueMcpOptions } from "../messaging/mcp-queue-rpc";
|
|
|
3
3
|
|
|
4
4
|
/** Validate all syntax before importing the MCP host or resolving any executable/home. */
|
|
5
5
|
export function parseQueueMcpArgs(argv: readonly string[]): QueueMcpOptions | null {
|
|
6
|
-
|
|
6
|
+
const reads = argv.filter(arg => arg === "--allow-reply-read").length;
|
|
7
|
+
if (reads > 1) return null;
|
|
8
|
+
const paths = argv.filter(arg => arg !== "--allow-reply-read");
|
|
9
|
+
if (paths.length !== 4) return null;
|
|
7
10
|
const values: Record<string, string> = {};
|
|
8
|
-
for (let i = 0; i <
|
|
9
|
-
const flag =
|
|
11
|
+
for (let i = 0; i < paths.length; i += 2) {
|
|
12
|
+
const flag = paths[i]!, value = paths[i + 1]!;
|
|
10
13
|
if (!["--codex", "--codex-home"].includes(flag) || values[flag] !== undefined
|
|
11
14
|
|| !value || !isAbsolute(value) || /[\x00-\x1f]/.test(value)) return null;
|
|
12
15
|
values[flag] = value;
|
|
13
16
|
}
|
|
14
|
-
return values["--codex"] && values["--codex-home"] ? { codex: values["--codex"], codexHome: values["--codex-home"] } : null;
|
|
17
|
+
return values["--codex"] && values["--codex-home"] ? { codex: values["--codex"], codexHome: values["--codex-home"], ...(reads ? { allowReplyRead: true } : {}) } : null;
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
export async function runMessageMcpCommand(argv: readonly string[]): Promise<number> {
|
|
18
21
|
const options = parseQueueMcpArgs(argv);
|
|
19
22
|
if (!options) {
|
|
20
|
-
console.error("Usage: ocx message mcp --codex <absolute-cli-path> --codex-home <absolute-existing-home>");
|
|
23
|
+
console.error("Usage: ocx message mcp --codex <absolute-cli-path> --codex-home <absolute-existing-home> [--allow-reply-read]");
|
|
21
24
|
return 64;
|
|
22
25
|
}
|
|
23
26
|
if (process.platform === "win32") {
|
|
@@ -149,7 +149,7 @@ function openSource(path: string, name: string): OpenSource | null {
|
|
|
149
149
|
catch (error) { if ((error as NodeJS.ErrnoException).code === "ENOENT") return null; throw error; }
|
|
150
150
|
if (entry.isFile() && !entry.isSymbolicLink() && entry.nlink > 1) {
|
|
151
151
|
// An interrupted Windows recovery leaves its identity pin linked to the original.
|
|
152
|
-
throw new Error(`orphan recovery refused: unsafe token file (another hard link exists;
|
|
152
|
+
throw new Error(`orphan recovery refused: unsafe token file (another hard link exists; an interrupted earlier recovery may have left a .${name}.identity pin in an orphaned-token-* backup folder. Remove such a pin only if it is a hard link of this token file and keep any other pin, then inspect any remaining hard links to this file before retrying)`);
|
|
153
153
|
}
|
|
154
154
|
if (!entry.isFile() || entry.isSymbolicLink() || entry.nlink !== 1 || entry.size > 4096
|
|
155
155
|
|| (process.platform !== "win32" && entry.uid !== process.getuid?.())) throw new Error("orphan recovery refused: unsafe token file");
|
|
@@ -125,7 +125,7 @@ export function deriveStartupHealth(inputs: StartupHealthInputs): StartupHealth
|
|
|
125
125
|
const recommendedAction = status === "at-risk" && ownsLocalRouting && inputs.desktop !== undefined
|
|
126
126
|
? inputs.diagnosticStale || inputs.desktop.loginEnabled
|
|
127
127
|
? "Reopen OpenCodex and check Start at Login."
|
|
128
|
-
: "
|
|
128
|
+
: "Check Start at Login in the OpenCodex menu and follow its guidance."
|
|
129
129
|
: null;
|
|
130
130
|
return {
|
|
131
131
|
...inputs,
|
|
@@ -225,7 +225,9 @@ function classifyStartupHealthSummary(health: StartupHealth): string {
|
|
|
225
225
|
const command = health.recommendedCommand ?? health.commands.restoreNative;
|
|
226
226
|
if (health.routingKind === "unknown") return `AT RISK after restart (Codex routing could not be verified; run '${command}')`;
|
|
227
227
|
if (health.routingKind === "custom-local") return `AT RISK after restart (custom local gateway lifecycle is not managed by opencodex; run '${command}')`;
|
|
228
|
-
if (health.desktop?.supervisor && !health.desktop.loginEnabled && !health.diagnosticStale) return
|
|
228
|
+
if (health.desktop?.supervisor && !health.desktop.loginEnabled && !health.diagnosticStale) return health.desktop.loginState === "disabled"
|
|
229
|
+
? "AT RISK after restart (OpenCodex Desktop runs this proxy; Start at Login is disabled; check the OpenCodex menu)"
|
|
230
|
+
: "AT RISK after restart (OpenCodex Desktop runs this proxy; Start at Login could not be verified; check the OpenCodex menu)";
|
|
229
231
|
if (health.desktop) return "AT RISK after restart (desktop startup could not be verified; reopen OpenCodex and check Start at Login)";
|
|
230
232
|
if (health.shimCoverage === "cli-only") return `AT RISK for Codex Desktop after restart (launcher shim covers CLI scripts only; run '${command}')`;
|
|
231
233
|
if (health.serviceConflict) return `AT RISK after restart (background service managers conflict; run '${command}')`;
|