@howaboua/pi-codex-conversion 1.5.5-dev.26.0f1b086 → 1.5.5-dev.27.aa95f55
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@howaboua/pi-codex-conversion",
|
|
3
|
-
"version": "1.5.5-dev.
|
|
3
|
+
"version": "1.5.5-dev.27.aa95f55",
|
|
4
4
|
"description": "Codex-oriented tool and prompt adapter for pi coding agent",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -60,9 +60,9 @@
|
|
|
60
60
|
"typebox": "*"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@earendil-works/pi-ai": "^0.
|
|
64
|
-
"@earendil-works/pi-coding-agent": "^0.
|
|
65
|
-
"@earendil-works/pi-tui": "^0.
|
|
63
|
+
"@earendil-works/pi-ai": "^0.75.3",
|
|
64
|
+
"@earendil-works/pi-coding-agent": "^0.75.3",
|
|
65
|
+
"@earendil-works/pi-tui": "^0.75.3",
|
|
66
66
|
"tsx": "^4.20.5",
|
|
67
67
|
"typebox": "^1.1.24",
|
|
68
68
|
"typescript": "^5.9.3"
|
|
@@ -110,6 +110,19 @@ interface SessionWebSocketCacheEntry {
|
|
|
110
110
|
continuation?: CachedWebSocketContinuationState;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
export interface OpenAICodexWebSocketDebugStats {
|
|
114
|
+
requests: number;
|
|
115
|
+
connectionsCreated: number;
|
|
116
|
+
connectionsReused: number;
|
|
117
|
+
cachedContextRequests: number;
|
|
118
|
+
storeTrueRequests: number;
|
|
119
|
+
fullContextRequests: number;
|
|
120
|
+
deltaRequests: number;
|
|
121
|
+
lastInputItems: number;
|
|
122
|
+
lastDeltaInputItems?: number;
|
|
123
|
+
lastPreviousResponseId?: string;
|
|
124
|
+
}
|
|
125
|
+
|
|
113
126
|
interface AcquiredWebSocket {
|
|
114
127
|
socket: WebSocketLike;
|
|
115
128
|
entry?: SessionWebSocketCacheEntry;
|
|
@@ -167,6 +180,38 @@ interface ResponseEnvelope {
|
|
|
167
180
|
type ServiceTier = ResponseCreateParamsStreaming["service_tier"];
|
|
168
181
|
|
|
169
182
|
const websocketSessionCache = new Map<string, SessionWebSocketCacheEntry>();
|
|
183
|
+
const websocketDebugStats = new Map<string, OpenAICodexWebSocketDebugStats>();
|
|
184
|
+
|
|
185
|
+
function getOrCreateWebSocketDebugStats(sessionId: string): OpenAICodexWebSocketDebugStats {
|
|
186
|
+
let stats = websocketDebugStats.get(sessionId);
|
|
187
|
+
if (!stats) {
|
|
188
|
+
stats = {
|
|
189
|
+
requests: 0,
|
|
190
|
+
connectionsCreated: 0,
|
|
191
|
+
connectionsReused: 0,
|
|
192
|
+
cachedContextRequests: 0,
|
|
193
|
+
storeTrueRequests: 0,
|
|
194
|
+
fullContextRequests: 0,
|
|
195
|
+
deltaRequests: 0,
|
|
196
|
+
lastInputItems: 0,
|
|
197
|
+
};
|
|
198
|
+
websocketDebugStats.set(sessionId, stats);
|
|
199
|
+
}
|
|
200
|
+
return stats;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export function getOpenAICodexWebSocketDebugStats(sessionId: string): OpenAICodexWebSocketDebugStats | undefined {
|
|
204
|
+
const stats = websocketDebugStats.get(sessionId);
|
|
205
|
+
return stats ? { ...stats } : undefined;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export function resetOpenAICodexWebSocketDebugStats(sessionId?: string): void {
|
|
209
|
+
if (sessionId) {
|
|
210
|
+
websocketDebugStats.delete(sessionId);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
websocketDebugStats.clear();
|
|
214
|
+
}
|
|
170
215
|
|
|
171
216
|
class NonRetryableProviderError extends Error {}
|
|
172
217
|
|
|
@@ -681,6 +726,7 @@ export function closeOpenAICodexWebSocketSessions(sessionId?: string): void {
|
|
|
681
726
|
const entry = websocketSessionCache.get(sessionId);
|
|
682
727
|
if (entry) closeEntry(entry);
|
|
683
728
|
websocketSessionCache.delete(sessionId);
|
|
729
|
+
websocketDebugStats.delete(sessionId);
|
|
684
730
|
return;
|
|
685
731
|
}
|
|
686
732
|
|
|
@@ -688,6 +734,7 @@ export function closeOpenAICodexWebSocketSessions(sessionId?: string): void {
|
|
|
688
734
|
closeEntry(entry);
|
|
689
735
|
}
|
|
690
736
|
websocketSessionCache.clear();
|
|
737
|
+
websocketDebugStats.clear();
|
|
691
738
|
}
|
|
692
739
|
|
|
693
740
|
|
|
@@ -1231,7 +1278,7 @@ async function processWebSocketStream<TApi extends Api>(
|
|
|
1231
1278
|
let streamStarted = false;
|
|
1232
1279
|
|
|
1233
1280
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
1234
|
-
const { socket, entry, release } = await acquireWebSocket(url, headers, options?.sessionId, options?.signal);
|
|
1281
|
+
const { socket, entry, reused, release } = await acquireWebSocket(url, headers, options?.sessionId, options?.signal);
|
|
1235
1282
|
let keepConnection = true;
|
|
1236
1283
|
let released = false;
|
|
1237
1284
|
let eventCount = 0;
|
|
@@ -1241,6 +1288,24 @@ async function processWebSocketStream<TApi extends Api>(
|
|
|
1241
1288
|
// WebSocket continuation still works via connection-scoped previous_response_id state.
|
|
1242
1289
|
const fullBody = body;
|
|
1243
1290
|
const requestBody = useCachedContext && entry ? buildCachedWebSocketRequestBody(entry, fullBody) : fullBody;
|
|
1291
|
+
const stats = options?.sessionId ? getOrCreateWebSocketDebugStats(options.sessionId) : undefined;
|
|
1292
|
+
if (stats) {
|
|
1293
|
+
stats.requests++;
|
|
1294
|
+
if (reused) stats.connectionsReused++;
|
|
1295
|
+
else stats.connectionsCreated++;
|
|
1296
|
+
if (useCachedContext) stats.cachedContextRequests++;
|
|
1297
|
+
if (requestBody.store === true) stats.storeTrueRequests++;
|
|
1298
|
+
stats.lastInputItems = requestBody.input?.length ?? 0;
|
|
1299
|
+
if (requestBody.previous_response_id) {
|
|
1300
|
+
stats.deltaRequests++;
|
|
1301
|
+
stats.lastDeltaInputItems = requestBody.input?.length ?? 0;
|
|
1302
|
+
stats.lastPreviousResponseId = requestBody.previous_response_id;
|
|
1303
|
+
} else {
|
|
1304
|
+
stats.fullContextRequests++;
|
|
1305
|
+
stats.lastDeltaInputItems = undefined;
|
|
1306
|
+
stats.lastPreviousResponseId = undefined;
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1244
1309
|
|
|
1245
1310
|
const releaseOnce = (releaseOptions?: { keep?: boolean }) => {
|
|
1246
1311
|
if (released) return;
|
|
Binary file
|
|
Binary file
|