@skillstate/codex 2.0.5 → 2.0.6
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/README.md +144 -46
- package/dist/codex-adapter.d.ts +90 -94
- package/dist/codex-adapter.d.ts.map +1 -1
- package/dist/codex-adapter.js +432 -322
- package/dist/codex-adapter.js.map +1 -1
- package/dist/fork-trim.d.ts +168 -0
- package/dist/fork-trim.d.ts.map +1 -0
- package/dist/fork-trim.js +478 -0
- package/dist/fork-trim.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @non-paper programmatic O(1) path for Codex — `codex app-server` client.
|
|
3
|
+
*
|
|
4
|
+
* Codex hooks cannot trim host history (hook outputs are limited to
|
|
5
|
+
* additionalContext / decision / systemMessage). For NON-INTERACTIVE runs
|
|
6
|
+
* history can be trimmed programmatically through the app-server JSON-RPC
|
|
7
|
+
* API: `thread/fork { beforeTurnId }` forks the thread "before" a turn —
|
|
8
|
+
* "excluding that turn and all later turns" — and the session continues in
|
|
9
|
+
* the forked thread. The forked thread's prompt holds only what happened
|
|
10
|
+
* before the fork: instructions + state file + the newest turn → O(1).
|
|
11
|
+
*
|
|
12
|
+
* Wire protocol (verified against codex-rs `app-server-protocol`, tag
|
|
13
|
+
* rust-v0.142.5):
|
|
14
|
+
* - transport: stdio, NEWLINE-DELIMITED JSON (`app-server-transport`
|
|
15
|
+
* writes `json + "\n"` and reads line by line); messages carry NO
|
|
16
|
+
* `jsonrpc` field — requests are `{ id, method, params }`, responses
|
|
17
|
+
* `{ id, result }` / `{ id, error: { code, message } }`, notifications
|
|
18
|
+
* `{ method, params }`;
|
|
19
|
+
* - `initialize` — params `{ clientInfo: { name, title, version },
|
|
20
|
+
* capabilities? }` (v1), response has `userAgent`, `codexHome`,
|
|
21
|
+
* `platformFamily`, `platformOs`;
|
|
22
|
+
* - `thread/start` — params `ThreadStartParams { cwd?, model?,
|
|
23
|
+
* developerInstructions?, ... }`, response `ThreadStartResponse
|
|
24
|
+
* { thread: { id, ... }, ... }`;
|
|
25
|
+
* - `turn/start` — params `{ threadId, input: [{ type: "text", text }] }`,
|
|
26
|
+
* response `{ turn }`; the FINAL state of the turn arrives as the
|
|
27
|
+
* `turn/completed` notification `{ threadId, turn: { id, status
|
|
28
|
+
* ("completed" | "interrupted" | "failed"), items?, error? } }`;
|
|
29
|
+
* - `thread/fork` — params `{ threadId, beforeTurnId }`, response has the
|
|
30
|
+
* forked `thread` (0.142 `ThreadForkParams.beforeTurnId` — "Optional
|
|
31
|
+
* turn id to fork before, excluding that turn and all later turns");
|
|
32
|
+
* - `thread/rollback` — params `{ threadId, numTurns }` (numTurns >= 1),
|
|
33
|
+
* in-place trim of the CURRENT thread;
|
|
34
|
+
* - `error` notification — `{ error: { message }, willRetry, threadId,
|
|
35
|
+
* turnId }`; a failed turn ultimately arrives as `turn/completed` with
|
|
36
|
+
* `status: "failed"`.
|
|
37
|
+
*
|
|
38
|
+
* State persists in the same per-project file the hooks and the MCP server
|
|
39
|
+
* use (`<cwd>/.skillstate/skillstate.json`), so the hooks, the MCP tools
|
|
40
|
+
* and this session share one state.
|
|
41
|
+
*/
|
|
42
|
+
import { spawn } from 'node:child_process';
|
|
43
|
+
import * as fs from 'node:fs';
|
|
44
|
+
import { resolveStateForCwd } from './codex-adapter.js';
|
|
45
|
+
/** Wire constant from codex-rs `rpc.rs` (the field itself is never sent). */
|
|
46
|
+
export const APP_SERVER_JSONRPC_VERSION = '2.0';
|
|
47
|
+
/** Parse a `turn/completed` payload into its essential parts (null if not one). */
|
|
48
|
+
export function parseTurnCompleted(params) {
|
|
49
|
+
if (params === undefined || params === null)
|
|
50
|
+
return null;
|
|
51
|
+
const threadId = params['threadId'];
|
|
52
|
+
const turn = params['turn'];
|
|
53
|
+
if (typeof threadId !== 'string' ||
|
|
54
|
+
typeof turn !== 'object' ||
|
|
55
|
+
turn === null ||
|
|
56
|
+
Array.isArray(turn)) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
const record = turn;
|
|
60
|
+
const id = record['id'];
|
|
61
|
+
if (typeof id !== 'string')
|
|
62
|
+
return null;
|
|
63
|
+
const error = typeof record['error'] === 'object' && record['error'] !== null
|
|
64
|
+
? record['error']
|
|
65
|
+
: null;
|
|
66
|
+
return {
|
|
67
|
+
threadId,
|
|
68
|
+
turn: {
|
|
69
|
+
id,
|
|
70
|
+
status: record['status'] === 'completed' ||
|
|
71
|
+
record['status'] === 'interrupted' ||
|
|
72
|
+
record['status'] === 'failed'
|
|
73
|
+
? record['status']
|
|
74
|
+
: undefined,
|
|
75
|
+
items: Array.isArray(record['items'])
|
|
76
|
+
? record['items']
|
|
77
|
+
: undefined,
|
|
78
|
+
error,
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/** Concatenate the `agentMessage` item texts of a turn (camelCase tag). */
|
|
83
|
+
export function extractAgentMessage(turn) {
|
|
84
|
+
const chunks = [];
|
|
85
|
+
for (const item of turn.items ?? []) {
|
|
86
|
+
if (item['type'] === 'agentMessage' && typeof item['text'] === 'string') {
|
|
87
|
+
chunks.push(item['text']);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return chunks.join('');
|
|
91
|
+
}
|
|
92
|
+
/** Resolve the default codex binary: `$CODEX_BIN`, else `codex`. */
|
|
93
|
+
export function defaultCodexBin() {
|
|
94
|
+
return process.env['CODEX_BIN'] ?? 'codex';
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Default developer instructions injected via `thread/start`:
|
|
98
|
+
* the state file is authoritative, persist via the skillstate MCP tools
|
|
99
|
+
* (`state.patch`) or a fenced `state_patch` block in a Bash tool call.
|
|
100
|
+
*/
|
|
101
|
+
export function defaultDeveloperInstructions(statePath) {
|
|
102
|
+
return [
|
|
103
|
+
'You run in state-based execution mode (skillstate).',
|
|
104
|
+
`Your execution state is persisted in ${statePath}. The injected state is`,
|
|
105
|
+
'authoritative; conversation history is not reliable and may be trimmed',
|
|
106
|
+
'between turns.',
|
|
107
|
+
'After every step persist what matters: call the skillstate MCP tool',
|
|
108
|
+
'`state.patch` with a sparse patch (null deletes a key), or print a fenced',
|
|
109
|
+
'```json block with {"state_patch": {...}, "action": "..."} inside a Bash',
|
|
110
|
+
'tool call so the PostToolUse hook merges it.',
|
|
111
|
+
].join('\n');
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Read the state file (missing/corrupt → `{}`); unwraps the
|
|
115
|
+
* `{ version: 1, state }` envelope the hooks and the CLI write.
|
|
116
|
+
*/
|
|
117
|
+
export function readState(statePath) {
|
|
118
|
+
try {
|
|
119
|
+
const parsed = JSON.parse(fs.readFileSync(statePath, 'utf-8'));
|
|
120
|
+
if (typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed)) {
|
|
121
|
+
const envelope = parsed;
|
|
122
|
+
const state = envelope['state'];
|
|
123
|
+
if (typeof state === 'object' && state !== null && !Array.isArray(state)) {
|
|
124
|
+
return state;
|
|
125
|
+
}
|
|
126
|
+
return parsed;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
// Missing or corrupt state file — empty state.
|
|
131
|
+
}
|
|
132
|
+
return {};
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Programmatic O(1) Codex session over `codex app-server` (newline-delimited
|
|
136
|
+
* JSON-RPC over stdio, no `jsonrpc` field on the wire).
|
|
137
|
+
*
|
|
138
|
+
* Lifecycle: `start()` → `step(action)` per turn → `forkBefore(turnId)` /
|
|
139
|
+
* `trim(keepTurns)` / `rollback(n)` to drop history → `close()`.
|
|
140
|
+
*/
|
|
141
|
+
export class CodexForkSession {
|
|
142
|
+
cwd;
|
|
143
|
+
codexBin;
|
|
144
|
+
home;
|
|
145
|
+
requestTimeoutMs;
|
|
146
|
+
developerInstructions;
|
|
147
|
+
child = null;
|
|
148
|
+
closed = false;
|
|
149
|
+
nextId = 1;
|
|
150
|
+
pending = new Map();
|
|
151
|
+
lineQueue = [];
|
|
152
|
+
lineWaiters = [];
|
|
153
|
+
wakeWaiter(waiter) {
|
|
154
|
+
waiter(null);
|
|
155
|
+
}
|
|
156
|
+
stderrTail = [];
|
|
157
|
+
threadId = null;
|
|
158
|
+
/** Turn ids completed in the current thread, in order. */
|
|
159
|
+
turnIds = [];
|
|
160
|
+
completions = [];
|
|
161
|
+
constructor(options) {
|
|
162
|
+
this.cwd = options.cwd;
|
|
163
|
+
this.codexBin = options.codexBin ?? defaultCodexBin();
|
|
164
|
+
this.home = options.home ?? process.env['HOME'] ?? '';
|
|
165
|
+
this.requestTimeoutMs = options.requestTimeoutMs ?? 300_000;
|
|
166
|
+
const instructions = options.developerInstructions === undefined
|
|
167
|
+
? defaultDeveloperInstructions(this.statePath)
|
|
168
|
+
: options.developerInstructions;
|
|
169
|
+
this.developerInstructions = instructions === null ? undefined : instructions;
|
|
170
|
+
}
|
|
171
|
+
/** Per-project state file for the session cwd (same resolver as the hooks). */
|
|
172
|
+
get statePath() {
|
|
173
|
+
return resolveStateForCwd(this.cwd, this.home || undefined);
|
|
174
|
+
}
|
|
175
|
+
/** Thread id of the current (possibly forked) thread; null before start. */
|
|
176
|
+
get currentThreadId() {
|
|
177
|
+
return this.threadId;
|
|
178
|
+
}
|
|
179
|
+
/** Turn ids completed in the current thread since the last fork. */
|
|
180
|
+
get completedTurnIds() {
|
|
181
|
+
return this.turnIds;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Spawn `codex app-server`, negotiate `initialize`, and start the thread
|
|
185
|
+
* (`thread/start` with the session cwd + developer instructions).
|
|
186
|
+
* Returns the started thread object.
|
|
187
|
+
*/
|
|
188
|
+
async start() {
|
|
189
|
+
if (this.child !== null) {
|
|
190
|
+
throw new Error('CodexForkSession.start called twice');
|
|
191
|
+
}
|
|
192
|
+
const child = this.spawnServer();
|
|
193
|
+
this.child = child;
|
|
194
|
+
// stdio: pipe guarantees both streams exist; the fake transport provides
|
|
195
|
+
// a no-op setEncoding so the same calls run against both.
|
|
196
|
+
child.stdout.setEncoding('utf-8');
|
|
197
|
+
child.stdout.on('data', (chunk) => this.onData(chunk));
|
|
198
|
+
child.stderr.setEncoding('utf-8');
|
|
199
|
+
child.stderr.on('data', (chunk) => this.onStderr(chunk));
|
|
200
|
+
child.once('exit', (code) => this.onClosed(`codex app-server exited (code ${code})`));
|
|
201
|
+
child.once('error', (error) => this.onClosed(`codex app-server failed to start: ${error.message}`));
|
|
202
|
+
// Dispatch loop: every incoming wire message must reach
|
|
203
|
+
// handleMessage (responses resolve pendings, notifications queue).
|
|
204
|
+
void this.dispatchLoop();
|
|
205
|
+
try {
|
|
206
|
+
await this.request('initialize', {
|
|
207
|
+
clientInfo: { name: 'skillstate-fork-trim', title: 'skillstate', version: '1.0.0' },
|
|
208
|
+
});
|
|
209
|
+
const response = (await this.request('thread/start', {
|
|
210
|
+
cwd: this.cwd,
|
|
211
|
+
...(this.developerInstructions !== undefined
|
|
212
|
+
? { developerInstructions: this.developerInstructions }
|
|
213
|
+
: {}),
|
|
214
|
+
}));
|
|
215
|
+
const threadId = response.thread?.id;
|
|
216
|
+
if (typeof threadId !== 'string') {
|
|
217
|
+
throw new Error('thread/start returned no thread id');
|
|
218
|
+
}
|
|
219
|
+
this.threadId = threadId;
|
|
220
|
+
return response.thread;
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
this.onClosed(`codex app-server startup failed: ${error.message}`);
|
|
224
|
+
child.kill();
|
|
225
|
+
this.child = null;
|
|
226
|
+
throw error;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Spawn the app-server process. Protected so tests can substitute a fake
|
|
231
|
+
* transport (mock streams) instead of a live `codex` binary.
|
|
232
|
+
*/
|
|
233
|
+
spawnServer() {
|
|
234
|
+
return spawn(this.codexBin, ['app-server'], {
|
|
235
|
+
cwd: this.cwd,
|
|
236
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Run one turn: `turn/start` with the user text, wait for the
|
|
241
|
+
* `turn/completed` notification, record the turn id, and read the state
|
|
242
|
+
* file. Throws when the turn reports `status: "failed"`.
|
|
243
|
+
*/
|
|
244
|
+
async step(action) {
|
|
245
|
+
const threadId = this.requireThread('step');
|
|
246
|
+
const started = (await this.request('turn/start', {
|
|
247
|
+
threadId,
|
|
248
|
+
input: [{ type: 'text', text: action }],
|
|
249
|
+
}));
|
|
250
|
+
const requestedTurnId = typeof started.turn?.id === 'string' ? started.turn.id : undefined;
|
|
251
|
+
const completed = await this.waitTurnCompleted(threadId, requestedTurnId);
|
|
252
|
+
if (completed.turn.status === 'failed') {
|
|
253
|
+
throw new Error(`turn failed: ${completed.turn.error?.message ?? 'unknown error'}`);
|
|
254
|
+
}
|
|
255
|
+
this.turnIds.push(completed.turn.id);
|
|
256
|
+
return {
|
|
257
|
+
observation: extractAgentMessage(completed.turn),
|
|
258
|
+
state: readState(this.statePath),
|
|
259
|
+
turnId: completed.turn.id,
|
|
260
|
+
threadId: completed.threadId,
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* O(1) trim: fork the thread BEFORE `turnId` (that turn and everything
|
|
265
|
+
* after it is dropped) and continue in the forked thread. The forked
|
|
266
|
+
* thread's history holds only the turns completed before `turnId`.
|
|
267
|
+
*/
|
|
268
|
+
async forkBefore(turnId) {
|
|
269
|
+
const threadId = this.requireThread('forkBefore');
|
|
270
|
+
const response = (await this.request('thread/fork', {
|
|
271
|
+
threadId,
|
|
272
|
+
beforeTurnId: turnId,
|
|
273
|
+
}));
|
|
274
|
+
const forkedId = response.thread?.id;
|
|
275
|
+
if (typeof forkedId !== 'string') {
|
|
276
|
+
throw new Error('thread/fork returned no thread id');
|
|
277
|
+
}
|
|
278
|
+
this.threadId = forkedId;
|
|
279
|
+
this.turnIds.length = 0;
|
|
280
|
+
return response.thread;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Drop all but the last `keepTurns` turns by forking before the first
|
|
284
|
+
* kept turn (`keepTurns` defaults to 0 — the state file carries
|
|
285
|
+
* everything). No-op (returns null) when there is nothing to trim.
|
|
286
|
+
*/
|
|
287
|
+
async trim(keepTurns = 0) {
|
|
288
|
+
if (!Number.isInteger(keepTurns) || keepTurns < 0) {
|
|
289
|
+
throw new Error('trim requires a non-negative integer keepTurns');
|
|
290
|
+
}
|
|
291
|
+
const dropFromIndex = this.turnIds.length - keepTurns - 1;
|
|
292
|
+
const dropFrom = dropFromIndex >= 0 ? this.turnIds[dropFromIndex] : undefined;
|
|
293
|
+
if (dropFrom === undefined)
|
|
294
|
+
return null;
|
|
295
|
+
return this.forkBefore(dropFrom);
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Trim the CURRENT thread in place with `thread/rollback` — drop the last
|
|
299
|
+
* `numTurns` turns without forking (codex-rs: "The number of turns to
|
|
300
|
+
* drop from the end of the thread. Must be >= 1").
|
|
301
|
+
*/
|
|
302
|
+
async rollback(numTurns) {
|
|
303
|
+
const threadId = this.requireThread('rollback');
|
|
304
|
+
if (!Number.isInteger(numTurns) || numTurns < 1) {
|
|
305
|
+
throw new Error('thread/rollback requires an integer numTurns >= 1');
|
|
306
|
+
}
|
|
307
|
+
const response = (await this.request('thread/rollback', {
|
|
308
|
+
threadId,
|
|
309
|
+
numTurns,
|
|
310
|
+
}));
|
|
311
|
+
if (typeof response.thread !== 'object' || response.thread === null) {
|
|
312
|
+
throw new Error('thread/rollback returned no thread');
|
|
313
|
+
}
|
|
314
|
+
for (let i = 0; i < numTurns && this.turnIds.length > 0; i += 1) {
|
|
315
|
+
this.turnIds.pop();
|
|
316
|
+
}
|
|
317
|
+
return response.thread;
|
|
318
|
+
}
|
|
319
|
+
/** Kill the app-server process and reject pending requests. */
|
|
320
|
+
close() {
|
|
321
|
+
this.onClosed('codex app-server session closed');
|
|
322
|
+
this.child?.kill();
|
|
323
|
+
this.child = null;
|
|
324
|
+
}
|
|
325
|
+
/* ------------------------------------------------------------------ */
|
|
326
|
+
/* Transport + JSON-RPC (exposed for tests: feedLine / handleMessage) */
|
|
327
|
+
/* ------------------------------------------------------------------ */
|
|
328
|
+
onData(chunk) {
|
|
329
|
+
for (const line of chunk.split('\n')) {
|
|
330
|
+
this.feedLine(line);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
/** Feed one raw wire line (public for tests). */
|
|
334
|
+
feedLine(line) {
|
|
335
|
+
if (this.closed)
|
|
336
|
+
return;
|
|
337
|
+
const trimmed = line.trim();
|
|
338
|
+
if (trimmed.length === 0)
|
|
339
|
+
return;
|
|
340
|
+
this.lineQueue.push(trimmed);
|
|
341
|
+
this.releaseWaiters();
|
|
342
|
+
}
|
|
343
|
+
onStderr(chunk) {
|
|
344
|
+
this.stderrTail.push(chunk);
|
|
345
|
+
if (this.stderrTail.length > 20) {
|
|
346
|
+
this.stderrTail = this.stderrTail.slice(-20);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
stderrText() {
|
|
350
|
+
return this.stderrTail.join('').trim().slice(-2000);
|
|
351
|
+
}
|
|
352
|
+
onClosed(reason) {
|
|
353
|
+
if (this.closed)
|
|
354
|
+
return;
|
|
355
|
+
this.closed = true;
|
|
356
|
+
const error = new Error(`${reason}; stderr: ${this.stderrText()}`);
|
|
357
|
+
for (const pending of [...this.pending.values()]) {
|
|
358
|
+
clearTimeout(pending.timer);
|
|
359
|
+
pending.reject(error);
|
|
360
|
+
}
|
|
361
|
+
this.pending.clear();
|
|
362
|
+
this.releaseWaiters();
|
|
363
|
+
}
|
|
364
|
+
releaseWaiters() {
|
|
365
|
+
while (this.lineQueue.length > 0 && this.lineWaiters.length > 0) {
|
|
366
|
+
// Wake one waiter; it re-reads the queue (single-consumer loop).
|
|
367
|
+
this.wakeWaiter(this.lineWaiters.shift());
|
|
368
|
+
}
|
|
369
|
+
if (this.closed) {
|
|
370
|
+
while (this.lineWaiters.length > 0) {
|
|
371
|
+
this.wakeWaiter(this.lineWaiters.shift());
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
/** Dispatch one parsed wire message (public for tests). */
|
|
376
|
+
handleMessage(message) {
|
|
377
|
+
if (typeof message.id === 'number' && this.pending.has(message.id)) {
|
|
378
|
+
const pending = this.pending.get(message.id);
|
|
379
|
+
clearTimeout(pending.timer);
|
|
380
|
+
this.pending.delete(message.id);
|
|
381
|
+
if (message.error !== undefined) {
|
|
382
|
+
pending.reject(new Error(`codex app-server error: ${message.error.message ?? JSON.stringify(message.error)}`));
|
|
383
|
+
}
|
|
384
|
+
else {
|
|
385
|
+
pending.resolve(message.result);
|
|
386
|
+
}
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
if (typeof message.method === 'string' && message.method === 'turn/completed') {
|
|
390
|
+
const parsed = parseTurnCompleted(message.params);
|
|
391
|
+
if (parsed !== null) {
|
|
392
|
+
this.completions.push(parsed);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
async nextMessage() {
|
|
397
|
+
for (;;) {
|
|
398
|
+
if (this.lineQueue.length > 0) {
|
|
399
|
+
const line = this.lineQueue.shift();
|
|
400
|
+
try {
|
|
401
|
+
return JSON.parse(line);
|
|
402
|
+
}
|
|
403
|
+
catch {
|
|
404
|
+
continue;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
if (this.closed)
|
|
408
|
+
return null;
|
|
409
|
+
await new Promise((resolve) => {
|
|
410
|
+
this.lineWaiters.push(resolve);
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
async request(method, params) {
|
|
415
|
+
const child = this.child;
|
|
416
|
+
if (child === null || child.stdin === null) {
|
|
417
|
+
throw new Error('codex app-server is not running');
|
|
418
|
+
}
|
|
419
|
+
const id = this.nextId;
|
|
420
|
+
this.nextId += 1;
|
|
421
|
+
const timer = setTimeout(() => {
|
|
422
|
+
// Every removal path (response, close, this timer) clears the timer, so
|
|
423
|
+
// a firing timer always still owns its pending entry.
|
|
424
|
+
const pending = this.pending.get(id);
|
|
425
|
+
this.pending.delete(id);
|
|
426
|
+
pending.reject(new Error(`codex app-server request ${method} timed out`));
|
|
427
|
+
}, this.requestTimeoutMs);
|
|
428
|
+
const promise = new Promise((resolve, reject) => {
|
|
429
|
+
this.pending.set(id, { resolve, reject, timer });
|
|
430
|
+
});
|
|
431
|
+
const payload = {
|
|
432
|
+
id,
|
|
433
|
+
method,
|
|
434
|
+
...(params !== undefined ? { params } : {}),
|
|
435
|
+
};
|
|
436
|
+
child.stdin.on('error', () => {
|
|
437
|
+
/* EPIPE after the server dies — the exit handler rejects pendings. */
|
|
438
|
+
});
|
|
439
|
+
child.stdin.write(`${JSON.stringify(payload)}\n`);
|
|
440
|
+
return promise;
|
|
441
|
+
}
|
|
442
|
+
async waitTurnCompleted(threadId, requestedTurnId) {
|
|
443
|
+
// The dispatch loop is the single wire consumer: it routes responses to
|
|
444
|
+
// pending requests and turn/completed notifications into `completions`.
|
|
445
|
+
// Waiting here is therefore a plain poll on that queue.
|
|
446
|
+
for (;;) {
|
|
447
|
+
const index = this.completions.findIndex((entry) => entry.threadId === threadId &&
|
|
448
|
+
(requestedTurnId === undefined || entry.turn.id === requestedTurnId));
|
|
449
|
+
if (index !== -1) {
|
|
450
|
+
return this.completions.splice(index, 1)[0];
|
|
451
|
+
}
|
|
452
|
+
if (this.closed) {
|
|
453
|
+
throw new Error(`codex app-server closed before turn/completed; stderr: ${this.stderrText()}`);
|
|
454
|
+
}
|
|
455
|
+
await new Promise((resolve) => setTimeout(resolve, 5));
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
requireThread(operation) {
|
|
459
|
+
if (this.threadId === null) {
|
|
460
|
+
throw new Error(`CodexForkSession.${operation} called before start()`);
|
|
461
|
+
}
|
|
462
|
+
return this.threadId;
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Single consumer for the wire queue: pulls messages and dispatches them
|
|
466
|
+
* (responses resolve pending requests, notifications are queued). Runs for
|
|
467
|
+
* the lifetime of the session; exits when the transport closes.
|
|
468
|
+
*/
|
|
469
|
+
async dispatchLoop() {
|
|
470
|
+
for (;;) {
|
|
471
|
+
const message = await this.nextMessage();
|
|
472
|
+
if (message === null)
|
|
473
|
+
return;
|
|
474
|
+
this.handleMessage(message);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
//# sourceMappingURL=fork-trim.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fork-trim.js","sourceRoot":"","sources":["../src/fork-trim.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,6EAA6E;AAC7E,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,CAAC;AAwDhD,mFAAmF;AACnF,MAAM,UAAU,kBAAkB,CAChC,MAA2C;IAE3C,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IACzD,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;IACpC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5B,IACE,OAAO,QAAQ,KAAK,QAAQ;QAC5B,OAAO,IAAI,KAAK,QAAQ;QACxB,IAAI,KAAK,IAAI;QACb,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EACnB,CAAC;QACD,OAAO,IA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CAAC,CAAC;QACzE,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACK,KAAK,CAAC,YAAY;QACxB,SAAS,CAAC;YACR,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;YACzC,IAAI,OAAO,KAAK,IAAI;gBAAE,OAAO;YAC7B,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,yBAAyB;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC"}
|