@respan/cli 0.6.6 → 0.6.8
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/hooks/gemini-cli.cjs +31 -3
- package/dist/hooks/gemini-cli.js +37 -4
- package/oclif.manifest.json +549 -549
- package/package.json +1 -1
|
@@ -664,6 +664,8 @@ function processBeforeTool(hookData) {
|
|
|
664
664
|
const pending = state.pending_tools ?? [];
|
|
665
665
|
pending.push({ name: toolName, input: toolInput, start_time: nowISO() });
|
|
666
666
|
state.pending_tools = pending;
|
|
667
|
+
state.send_version = (state.send_version ?? 0) + 1;
|
|
668
|
+
state.tool_turns = (state.tool_turns ?? 0) + 1;
|
|
667
669
|
saveStreamState(sessionId, state);
|
|
668
670
|
}
|
|
669
671
|
function processAfterTool(hookData) {
|
|
@@ -812,10 +814,8 @@ function processChunk(hookData) {
|
|
|
812
814
|
debug(`Delayed send (version=${state.send_version}, delay=${SEND_DELAY}s), ${state.accumulated_text.length} chars`);
|
|
813
815
|
launchDelayedSend(sessionId, state.send_version, spans, creds.apiKey, creds.baseUrl);
|
|
814
816
|
}
|
|
815
|
-
function
|
|
817
|
+
function mainWorker(raw) {
|
|
816
818
|
try {
|
|
817
|
-
const raw = fs2.readFileSync(0, "utf-8");
|
|
818
|
-
process.stdout.write("{}\n");
|
|
819
819
|
if (!raw.trim()) return;
|
|
820
820
|
const hookData = JSON.parse(raw);
|
|
821
821
|
const event = String(hookData.hook_event_name ?? "");
|
|
@@ -839,4 +839,32 @@ function main() {
|
|
|
839
839
|
}
|
|
840
840
|
}
|
|
841
841
|
}
|
|
842
|
+
function main() {
|
|
843
|
+
if (process.env._RESPAN_GEM_WORKER === "1") {
|
|
844
|
+
const raw2 = process.env._RESPAN_GEM_DATA ?? "";
|
|
845
|
+
mainWorker(raw2);
|
|
846
|
+
return;
|
|
847
|
+
}
|
|
848
|
+
let raw = "";
|
|
849
|
+
try {
|
|
850
|
+
raw = fs2.readFileSync(0, "utf-8");
|
|
851
|
+
} catch {
|
|
852
|
+
}
|
|
853
|
+
process.stdout.write("{}\n");
|
|
854
|
+
if (!raw.trim()) {
|
|
855
|
+
process.exit(0);
|
|
856
|
+
}
|
|
857
|
+
try {
|
|
858
|
+
const scriptPath = __filename || process.argv[1];
|
|
859
|
+
const child = (0, import_node_child_process.execFile)("node", [scriptPath], {
|
|
860
|
+
env: { ...process.env, _RESPAN_GEM_WORKER: "1", _RESPAN_GEM_DATA: raw },
|
|
861
|
+
stdio: "ignore",
|
|
862
|
+
detached: true
|
|
863
|
+
});
|
|
864
|
+
child.unref();
|
|
865
|
+
} catch (e) {
|
|
866
|
+
mainWorker(raw);
|
|
867
|
+
}
|
|
868
|
+
process.exit(0);
|
|
869
|
+
}
|
|
842
870
|
main();
|
package/dist/hooks/gemini-cli.js
CHANGED
|
@@ -387,6 +387,10 @@ function processBeforeTool(hookData) {
|
|
|
387
387
|
const pending = state.pending_tools ?? [];
|
|
388
388
|
pending.push({ name: toolName, input: toolInput, start_time: nowISO() });
|
|
389
389
|
state.pending_tools = pending;
|
|
390
|
+
// Increment send_version to cancel any pending delayed sends —
|
|
391
|
+
// the turn isn't done yet, a tool is about to execute.
|
|
392
|
+
state.send_version = (state.send_version ?? 0) + 1;
|
|
393
|
+
state.tool_turns = (state.tool_turns ?? 0) + 1;
|
|
390
394
|
saveStreamState(sessionId, state);
|
|
391
395
|
}
|
|
392
396
|
function processAfterTool(hookData) {
|
|
@@ -549,11 +553,8 @@ function processChunk(hookData) {
|
|
|
549
553
|
launchDelayedSend(sessionId, state.send_version, spans, creds.apiKey, creds.baseUrl);
|
|
550
554
|
}
|
|
551
555
|
// ── Main ──────────────────────────────────────────────────────────
|
|
552
|
-
function
|
|
556
|
+
function mainWorker(raw) {
|
|
553
557
|
try {
|
|
554
|
-
const raw = fs.readFileSync(0, 'utf-8');
|
|
555
|
-
// Respond to Gemini CLI immediately so it doesn't block
|
|
556
|
-
process.stdout.write('{}\n');
|
|
557
558
|
if (!raw.trim())
|
|
558
559
|
return;
|
|
559
560
|
const hookData = JSON.parse(raw);
|
|
@@ -583,4 +584,36 @@ function main() {
|
|
|
583
584
|
}
|
|
584
585
|
}
|
|
585
586
|
}
|
|
587
|
+
function main() {
|
|
588
|
+
// Worker mode: re-invoked as detached subprocess
|
|
589
|
+
if (process.env._RESPAN_GEM_WORKER === '1') {
|
|
590
|
+
const raw = process.env._RESPAN_GEM_DATA ?? '';
|
|
591
|
+
mainWorker(raw);
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
// Read stdin synchronously, respond immediately, fork worker, exit
|
|
595
|
+
let raw = '';
|
|
596
|
+
try {
|
|
597
|
+
raw = fs.readFileSync(0, 'utf-8');
|
|
598
|
+
}
|
|
599
|
+
catch { }
|
|
600
|
+
process.stdout.write('{}\n');
|
|
601
|
+
if (!raw.trim()) {
|
|
602
|
+
process.exit(0);
|
|
603
|
+
}
|
|
604
|
+
try {
|
|
605
|
+
const scriptPath = __filename || process.argv[1];
|
|
606
|
+
const child = execFile('node', [scriptPath], {
|
|
607
|
+
env: { ...process.env, _RESPAN_GEM_WORKER: '1', _RESPAN_GEM_DATA: raw },
|
|
608
|
+
stdio: 'ignore',
|
|
609
|
+
detached: true,
|
|
610
|
+
});
|
|
611
|
+
child.unref();
|
|
612
|
+
}
|
|
613
|
+
catch (e) {
|
|
614
|
+
// Fallback: run inline
|
|
615
|
+
mainWorker(raw);
|
|
616
|
+
}
|
|
617
|
+
process.exit(0);
|
|
618
|
+
}
|
|
586
619
|
main();
|