@ccpocket/bridge 1.80.0 → 1.80.2
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/dist/codex-process.d.ts +7 -0
- package/dist/codex-process.js +55 -21
- package/dist/codex-process.js.map +1 -1
- package/dist/codex-service-tier.d.ts +2 -0
- package/dist/codex-service-tier.js +14 -0
- package/dist/codex-service-tier.js.map +1 -0
- package/dist/session.d.ts +6 -1
- package/dist/session.js +59 -8
- package/dist/session.js.map +1 -1
- package/dist/sessions-index.js +20 -11
- package/dist/sessions-index.js.map +1 -1
- package/dist/websocket.d.ts +1 -0
- package/dist/websocket.js +43 -5
- package/dist/websocket.js.map +1 -1
- package/package.json +1 -1
package/dist/codex-process.d.ts
CHANGED
|
@@ -112,6 +112,9 @@ export declare class CodexProcess extends EventEmitter<CodexProcessEvents> {
|
|
|
112
112
|
private _agentRole;
|
|
113
113
|
private stopped;
|
|
114
114
|
private startModel;
|
|
115
|
+
private readiness;
|
|
116
|
+
private readinessError;
|
|
117
|
+
private readinessWaiters;
|
|
115
118
|
private inputResolve;
|
|
116
119
|
private pendingTurnId;
|
|
117
120
|
private pendingTurnCompletion;
|
|
@@ -243,6 +246,7 @@ export declare class CodexProcess extends EventEmitter<CodexProcessEvents> {
|
|
|
243
246
|
listAvailableModelMetadata(): Promise<CodexModelMetadata[]>;
|
|
244
247
|
start(projectPath: string, options?: CodexStartOptions): void;
|
|
245
248
|
initializeOnly(projectPath: string): Promise<void>;
|
|
249
|
+
waitUntilReady(): Promise<void>;
|
|
246
250
|
stop(): void;
|
|
247
251
|
private prepareLaunch;
|
|
248
252
|
private launchAppServer;
|
|
@@ -355,6 +359,9 @@ export declare class CodexProcess extends EventEmitter<CodexProcessEvents> {
|
|
|
355
359
|
private respondToServerRequestError;
|
|
356
360
|
private writeEnvelope;
|
|
357
361
|
private rejectAllPending;
|
|
362
|
+
private resetReadiness;
|
|
363
|
+
private resolveReadiness;
|
|
364
|
+
private rejectReadiness;
|
|
358
365
|
private setStatus;
|
|
359
366
|
private emitMessage;
|
|
360
367
|
private extractToolUseId;
|
package/dist/codex-process.js
CHANGED
|
@@ -6,6 +6,7 @@ import { dirname, join } from "node:path";
|
|
|
6
6
|
import { rm, writeFile } from "node:fs/promises";
|
|
7
7
|
import { createCodexTransport, buildCodexSpawnSpec, } from "./codex-transport.js";
|
|
8
8
|
import { codexCliJoinTarget } from "./codex-app-server-config.js";
|
|
9
|
+
import { normalizeCodexServiceTierForClient, normalizeCodexServiceTierForRpc, } from "./codex-service-tier.js";
|
|
9
10
|
import { resolvePlatformPath } from "./path-utils.js";
|
|
10
11
|
export { buildCodexSpawnSpec };
|
|
11
12
|
const DEFAULT_CODEX_MODEL = "gpt-5.5";
|
|
@@ -32,7 +33,7 @@ export function isCodexThreadWriterConflict(error) {
|
|
|
32
33
|
}
|
|
33
34
|
export function codexErrorMessage(error) {
|
|
34
35
|
if (isCodexThreadWriterConflict(error)) {
|
|
35
|
-
return "This Codex thread is already open in
|
|
36
|
+
return "This Codex thread is already open in Codex Desktop or the Codex App. Close it there, then try again.";
|
|
36
37
|
}
|
|
37
38
|
return error instanceof Error ? error.message : String(error);
|
|
38
39
|
}
|
|
@@ -63,6 +64,9 @@ export class CodexProcess extends EventEmitter {
|
|
|
63
64
|
_agentRole = null;
|
|
64
65
|
stopped = false;
|
|
65
66
|
startModel;
|
|
67
|
+
readiness = "pending";
|
|
68
|
+
readinessError;
|
|
69
|
+
readinessWaiters = new Set();
|
|
66
70
|
inputResolve = null;
|
|
67
71
|
pendingTurnId = null;
|
|
68
72
|
pendingTurnCompletion = null;
|
|
@@ -186,7 +190,7 @@ export class CodexProcess extends EventEmitter {
|
|
|
186
190
|
}
|
|
187
191
|
/** Update Codex speed for the next turn without restarting the thread. */
|
|
188
192
|
setServiceTier(serviceTier) {
|
|
189
|
-
this._runtimeServiceTier =
|
|
193
|
+
this._runtimeServiceTier = normalizeCodexServiceTierForRpc(serviceTier);
|
|
190
194
|
console.log(`[codex-process] Speed changed to: ${this.serviceTier}`);
|
|
191
195
|
}
|
|
192
196
|
/**
|
|
@@ -406,6 +410,7 @@ export class CodexProcess extends EventEmitter {
|
|
|
406
410
|
if (this.transport) {
|
|
407
411
|
this.stop();
|
|
408
412
|
}
|
|
413
|
+
this.resetReadiness();
|
|
409
414
|
this.prepareLaunch(projectPath, options);
|
|
410
415
|
this.launchAppServer(projectPath, options);
|
|
411
416
|
void this.bootstrap(projectPath, options);
|
|
@@ -414,13 +419,32 @@ export class CodexProcess extends EventEmitter {
|
|
|
414
419
|
if (this.transport) {
|
|
415
420
|
this.stop();
|
|
416
421
|
}
|
|
417
|
-
this.
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
422
|
+
this.resetReadiness();
|
|
423
|
+
try {
|
|
424
|
+
this.prepareLaunch(projectPath);
|
|
425
|
+
this.launchAppServer(projectPath);
|
|
426
|
+
await this.initializeRpcConnection();
|
|
427
|
+
this.setStatus("idle");
|
|
428
|
+
this.resolveReadiness();
|
|
429
|
+
}
|
|
430
|
+
catch (error) {
|
|
431
|
+
this.rejectReadiness(error);
|
|
432
|
+
throw error;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
waitUntilReady() {
|
|
436
|
+
if (this.readiness === "ready")
|
|
437
|
+
return Promise.resolve();
|
|
438
|
+
if (this.readiness === "failed") {
|
|
439
|
+
return Promise.reject(this.readinessError);
|
|
440
|
+
}
|
|
441
|
+
return new Promise((resolve, reject) => {
|
|
442
|
+
this.readinessWaiters.add({ resolve, reject });
|
|
443
|
+
});
|
|
421
444
|
}
|
|
422
445
|
stop() {
|
|
423
446
|
this.stopped = true;
|
|
447
|
+
this.rejectReadiness(new Error("codex app-server stopped"));
|
|
424
448
|
if (this.inputResolve) {
|
|
425
449
|
this.inputResolve({ text: "" });
|
|
426
450
|
this.inputResolve = null;
|
|
@@ -453,7 +477,7 @@ export class CodexProcess extends EventEmitter {
|
|
|
453
477
|
this._runtimeServiceTier =
|
|
454
478
|
options?.serviceTier === undefined
|
|
455
479
|
? undefined
|
|
456
|
-
:
|
|
480
|
+
: normalizeCodexServiceTierForRpc(options.serviceTier);
|
|
457
481
|
this._approvalPolicy = options?.approvalPolicy;
|
|
458
482
|
this._approvalsReviewer =
|
|
459
483
|
options?.approvalsReviewer === undefined
|
|
@@ -996,7 +1020,7 @@ export class CodexProcess extends EventEmitter {
|
|
|
996
1020
|
if (requestedModel)
|
|
997
1021
|
threadParams.model = requestedModel;
|
|
998
1022
|
if (options?.serviceTier !== undefined) {
|
|
999
|
-
threadParams.serviceTier =
|
|
1023
|
+
threadParams.serviceTier = normalizeCodexServiceTierForRpc(options.serviceTier);
|
|
1000
1024
|
}
|
|
1001
1025
|
if (requestedReasoningEffort) {
|
|
1002
1026
|
// app-server applies reasoning effort on thread start via config overrides,
|
|
@@ -1094,7 +1118,7 @@ export class CodexProcess extends EventEmitter {
|
|
|
1094
1118
|
: requestedReasoningEffort
|
|
1095
1119
|
? { modelReasoningEffort: requestedReasoningEffort }
|
|
1096
1120
|
: {}),
|
|
1097
|
-
serviceTier:
|
|
1121
|
+
serviceTier: normalizeCodexServiceTierForClient(resolvedSettings.serviceTier ?? options?.serviceTier),
|
|
1098
1122
|
...(resolvedSettings.networkAccessEnabled !== undefined
|
|
1099
1123
|
? { networkAccessEnabled: resolvedSettings.networkAccessEnabled }
|
|
1100
1124
|
: {}),
|
|
@@ -1107,6 +1131,7 @@ export class CodexProcess extends EventEmitter {
|
|
|
1107
1131
|
...(cliJoin ? { codexCliJoin: cliJoin } : {}),
|
|
1108
1132
|
});
|
|
1109
1133
|
this.setStatus("idle");
|
|
1134
|
+
this.resolveReadiness();
|
|
1110
1135
|
// Fetch completion entities in background (non-blocking).
|
|
1111
1136
|
this._projectPath = projectPath;
|
|
1112
1137
|
setTimeout(() => {
|
|
@@ -1117,6 +1142,7 @@ export class CodexProcess extends EventEmitter {
|
|
|
1117
1142
|
await this.runInputLoop(options);
|
|
1118
1143
|
}
|
|
1119
1144
|
catch (err) {
|
|
1145
|
+
this.rejectReadiness(err);
|
|
1120
1146
|
if (!this.stopped) {
|
|
1121
1147
|
const message = codexErrorMessage(err);
|
|
1122
1148
|
console.error("[codex-process] bootstrap error:", err);
|
|
@@ -2543,6 +2569,26 @@ export class CodexProcess extends EventEmitter {
|
|
|
2543
2569
|
this.pendingTurnCompletion = null;
|
|
2544
2570
|
}
|
|
2545
2571
|
}
|
|
2572
|
+
resetReadiness() {
|
|
2573
|
+
this.rejectReadiness(new Error("codex app-server restarted"));
|
|
2574
|
+
this.readiness = "pending";
|
|
2575
|
+
this.readinessError = undefined;
|
|
2576
|
+
}
|
|
2577
|
+
resolveReadiness() {
|
|
2578
|
+
if (this.readiness !== "pending")
|
|
2579
|
+
return;
|
|
2580
|
+
this.readiness = "ready";
|
|
2581
|
+
for (const waiter of this.readinessWaiters)
|
|
2582
|
+
waiter.resolve();
|
|
2583
|
+
this.readinessWaiters.clear();
|
|
2584
|
+
}
|
|
2585
|
+
rejectReadiness(error) {
|
|
2586
|
+
this.readiness = "failed";
|
|
2587
|
+
this.readinessError = error;
|
|
2588
|
+
for (const waiter of this.readinessWaiters)
|
|
2589
|
+
waiter.reject(error);
|
|
2590
|
+
this.readinessWaiters.clear();
|
|
2591
|
+
}
|
|
2546
2592
|
setStatus(status) {
|
|
2547
2593
|
if (this._status !== status) {
|
|
2548
2594
|
this._status = status;
|
|
@@ -2893,18 +2939,6 @@ function extractServiceTiers(raw) {
|
|
|
2893
2939
|
}
|
|
2894
2940
|
return tiers;
|
|
2895
2941
|
}
|
|
2896
|
-
function normalizeServiceTier(value) {
|
|
2897
|
-
const normalized = value.trim();
|
|
2898
|
-
return !normalized || normalized === "standard" || normalized === "default"
|
|
2899
|
-
? null
|
|
2900
|
-
: normalized;
|
|
2901
|
-
}
|
|
2902
|
-
function normalizeServiceTierForClient(value) {
|
|
2903
|
-
if (typeof value !== "string")
|
|
2904
|
-
return "standard";
|
|
2905
|
-
const normalized = value.trim();
|
|
2906
|
-
return !normalized || normalized === "default" ? "standard" : normalized;
|
|
2907
|
-
}
|
|
2908
2942
|
function sanitizeCodexModel(value) {
|
|
2909
2943
|
if (typeof value !== "string")
|
|
2910
2944
|
return undefined;
|