@shumkov/orchestra 0.13.2 → 0.15.0
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/docs/PER_CHAT_CLAUDE_CONTEXT_CACHE_SPEC.md +40 -0
- package/lib/codex/app-server-client.js +132 -4
- package/lib/codex/protocol-schema.json +6 -2
- package/lib/process/cli-process.js +109 -26
- package/lib/process/codex-process.js +130 -0
- package/lib/process/factory.js +44 -7
- package/lib/process/process-manager.js +744 -118
- package/lib/process/sdk-process.js +28 -3
- package/lib/tmux/tmux-runner.js +6 -0
- package/package.json +1 -1
|
@@ -474,7 +474,10 @@ class SdkProcess extends Process {
|
|
|
474
474
|
sessionId: msg.session_id,
|
|
475
475
|
cost: msg.total_cost_usd,
|
|
476
476
|
duration: msg.duration_ms,
|
|
477
|
-
error:
|
|
477
|
+
error: isError ? (msg.error || msg.subtype) : null,
|
|
478
|
+
...(isError
|
|
479
|
+
? { replaySafe: !head.firstAssistantSeen && !head.hadFoldedInput && (head.inputIds?.size ?? 0) <= 1 }
|
|
480
|
+
: {}),
|
|
478
481
|
metrics: {
|
|
479
482
|
inputTokens: usageTotals.input_tokens,
|
|
480
483
|
outputTokens: usageTotals.output_tokens,
|
|
@@ -752,6 +755,8 @@ class SdkProcess extends Process {
|
|
|
752
755
|
priority: 'now',
|
|
753
756
|
shouldQuery,
|
|
754
757
|
});
|
|
758
|
+
const head = this.pendingQueue?.[0];
|
|
759
|
+
if (head) head.hadFoldedInput = true;
|
|
755
760
|
this._logEvent('steer', {
|
|
756
761
|
session_key: this.sessionKey,
|
|
757
762
|
chat_id: this.chatId,
|
|
@@ -793,7 +798,10 @@ class SdkProcess extends Process {
|
|
|
793
798
|
if (shouldQuery !== undefined) msg.shouldQuery = shouldQuery;
|
|
794
799
|
this.inputController.push(msg);
|
|
795
800
|
const head = this.pendingQueue?.[0];
|
|
796
|
-
if (head)
|
|
801
|
+
if (head) {
|
|
802
|
+
head.pendingSteerCausesNewBubble = true;
|
|
803
|
+
head.hadFoldedInput = true;
|
|
804
|
+
}
|
|
797
805
|
this._logEvent('inject-user-message', {
|
|
798
806
|
session_key: this.sessionKey,
|
|
799
807
|
chat_id: this.chatId,
|
|
@@ -905,11 +913,28 @@ class SdkProcess extends Process {
|
|
|
905
913
|
// ─── Helpers ────────────────────────────────────────────────────
|
|
906
914
|
|
|
907
915
|
_failAllPendings(err) {
|
|
916
|
+
const clonePerPending = this.pendingQueue.length > 1;
|
|
908
917
|
while (this.pendingQueue.length > 0) {
|
|
909
918
|
const p = this.pendingQueue.shift();
|
|
910
919
|
this._retirePendingInput(p);
|
|
911
920
|
p.clearTimers?.();
|
|
912
|
-
|
|
921
|
+
const replaySafe = !p.firstAssistantSeen && !p.hadFoldedInput && (p.inputIds?.size ?? 0) <= 1;
|
|
922
|
+
let rejection = err;
|
|
923
|
+
if (err && typeof err === 'object') {
|
|
924
|
+
if (clonePerPending || !Object.isExtensible(err)) {
|
|
925
|
+
if (err instanceof Error) {
|
|
926
|
+
rejection = new Error(err.message, { cause: err });
|
|
927
|
+
rejection.name = err.name;
|
|
928
|
+
for (const key of Object.keys(err)) {
|
|
929
|
+
rejection[key] = err[key];
|
|
930
|
+
}
|
|
931
|
+
} else {
|
|
932
|
+
rejection = { ...err };
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
try { rejection.replaySafe = replaySafe; } catch { /* frozen */ }
|
|
936
|
+
}
|
|
937
|
+
try { p.reject(rejection); } catch { /* swallow */ }
|
|
913
938
|
}
|
|
914
939
|
this.inFlight = false;
|
|
915
940
|
}
|
package/lib/tmux/tmux-runner.js
CHANGED
|
@@ -239,6 +239,12 @@ function createTmuxRunner({
|
|
|
239
239
|
const sessArgs = ['new-session', '-d', '-s', name];
|
|
240
240
|
if (cwd) sessArgs.push('-c', cwd);
|
|
241
241
|
for (const [k, v] of Object.entries(envExtras)) {
|
|
242
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(k)) {
|
|
243
|
+
throw new TypeError(`Invalid envExtras key: ${JSON.stringify(k)}`);
|
|
244
|
+
}
|
|
245
|
+
if (typeof v !== 'string' || v.includes('\0')) {
|
|
246
|
+
throw new TypeError(`envExtras.${k} must be a string without NUL characters`);
|
|
247
|
+
}
|
|
242
248
|
sessArgs.push('-e', `${k}=${v}`);
|
|
243
249
|
}
|
|
244
250
|
sessArgs.push(command, ...args);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shumkov/orchestra",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Transport-agnostic session engine for Claude Code and the native Codex app-server: spawn, steer, supervise, observe turns, and recover.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "index.js",
|