@ordewell/cli 0.6.1 → 0.6.3
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/main.js +27 -8
- package/package.json +3 -3
package/dist/main.js
CHANGED
|
@@ -413,6 +413,8 @@ var ApiClient = class _ApiClient {
|
|
|
413
413
|
static defaultWorkspace;
|
|
414
414
|
port;
|
|
415
415
|
workspace;
|
|
416
|
+
/** A session's open execution stream, so a new one can end it: one run is reported once. */
|
|
417
|
+
executionStreams = /* @__PURE__ */ new Map();
|
|
416
418
|
constructor(port, workspace) {
|
|
417
419
|
this.port = port || DEFAULT_PORT;
|
|
418
420
|
this.workspace = workspace ?? _ApiClient.defaultWorkspace ?? process.cwd();
|
|
@@ -849,26 +851,36 @@ var ApiClient = class _ApiClient {
|
|
|
849
851
|
}
|
|
850
852
|
streamExecution(sessionId, onEvent, onReady) {
|
|
851
853
|
return new Promise((resolve3, reject) => {
|
|
854
|
+
this.executionStreams.get(sessionId)?.();
|
|
852
855
|
const socket = this.openSessionSocket(sessionId);
|
|
853
856
|
let resolved = false;
|
|
854
857
|
let opened = false;
|
|
858
|
+
const forget = () => {
|
|
859
|
+
if (this.executionStreams.get(sessionId) === end) this.executionStreams.delete(sessionId);
|
|
860
|
+
};
|
|
861
|
+
const end = () => {
|
|
862
|
+
forget();
|
|
863
|
+
if (resolved) return;
|
|
864
|
+
resolved = true;
|
|
865
|
+
socket.close();
|
|
866
|
+
resolve3();
|
|
867
|
+
};
|
|
868
|
+
this.executionStreams.set(sessionId, end);
|
|
855
869
|
socket.on("open", () => {
|
|
856
870
|
opened = true;
|
|
857
871
|
onReady?.();
|
|
858
872
|
});
|
|
859
873
|
socket.on("message", (data) => {
|
|
874
|
+
if (resolved) return;
|
|
860
875
|
try {
|
|
861
876
|
const event = JSON.parse(data.toString());
|
|
862
877
|
onEvent(event);
|
|
863
|
-
if (
|
|
864
|
-
resolved = true;
|
|
865
|
-
socket.close();
|
|
866
|
-
resolve3();
|
|
867
|
-
}
|
|
878
|
+
if (event.type === "execution_complete" || event.type === "execution_stopped") end();
|
|
868
879
|
} catch {
|
|
869
880
|
}
|
|
870
881
|
});
|
|
871
882
|
socket.on("error", (err) => {
|
|
883
|
+
forget();
|
|
872
884
|
if (!opened) onReady?.(err);
|
|
873
885
|
if (!resolved) {
|
|
874
886
|
resolved = true;
|
|
@@ -876,6 +888,7 @@ var ApiClient = class _ApiClient {
|
|
|
876
888
|
}
|
|
877
889
|
});
|
|
878
890
|
socket.on("close", () => {
|
|
891
|
+
forget();
|
|
879
892
|
if (!opened) onReady?.(new Error("Execution stream closed before connecting"));
|
|
880
893
|
if (!resolved) {
|
|
881
894
|
resolved = true;
|
|
@@ -1688,6 +1701,11 @@ async function followExecution(api, sessionId, start, onBlocked) {
|
|
|
1688
1701
|
}
|
|
1689
1702
|
}
|
|
1690
1703
|
let pausedAtGate = false;
|
|
1704
|
+
let noteBlocked = () => {
|
|
1705
|
+
};
|
|
1706
|
+
const blockedSeen = new Promise((resolve3) => {
|
|
1707
|
+
noteBlocked = resolve3;
|
|
1708
|
+
});
|
|
1691
1709
|
let settleReady = () => {
|
|
1692
1710
|
};
|
|
1693
1711
|
const streamReady = new Promise((resolve3, reject) => {
|
|
@@ -1726,6 +1744,7 @@ Done. ${summary.completed || 0} completed, ${summary.failed || 0} failed, ${summ
|
|
|
1726
1744
|
if (event.type === "isolation_blocked") {
|
|
1727
1745
|
blocked = event.message;
|
|
1728
1746
|
dirtyRepos = event.repos ?? [];
|
|
1747
|
+
noteBlocked();
|
|
1729
1748
|
}
|
|
1730
1749
|
if (event.type === "isolation_handoff") {
|
|
1731
1750
|
const n = event.landed.length;
|
|
@@ -1743,7 +1762,7 @@ Run finished on ${handoffBranch(event)}${where} \u2014 ${n} task${n === 1 ? "" :
|
|
|
1743
1762
|
void stream.catch(settleReady);
|
|
1744
1763
|
await streamReady.catch(streamFailed);
|
|
1745
1764
|
await start();
|
|
1746
|
-
await stream.catch(streamFailed);
|
|
1765
|
+
await Promise.race([stream, blockedSeen]).catch(streamFailed);
|
|
1747
1766
|
if (blocked === null) return;
|
|
1748
1767
|
if (!onBlocked) {
|
|
1749
1768
|
await api.stopExecution(sessionId);
|
|
@@ -7797,8 +7816,8 @@ async function perform(effect, deps) {
|
|
|
7797
7816
|
await refreshPlan(deps, effect.sessionId);
|
|
7798
7817
|
dispatch({ type: "notice", message: `Removed the run's worktrees and task branches; ${effect.branch} is kept.` });
|
|
7799
7818
|
return;
|
|
7800
|
-
// Spawns runners again, so it needs the stream a run needs
|
|
7801
|
-
//
|
|
7819
|
+
// Spawns runners again, so it needs the stream a run needs. Opening it ends
|
|
7820
|
+
// the blocked run's, which stayed open to show the ops tasks still running.
|
|
7802
7821
|
case "isolationContinue": {
|
|
7803
7822
|
const { sessionId } = effect;
|
|
7804
7823
|
await withExecutionStream(deps, sessionId, () => effect.mode === "stash" ? api.continueWithStash(sessionId) : api.continueWithoutIsolation(sessionId));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ordewell/cli",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "Ordewell CLI and TUI — plan, run and verify coding-agent tasks from the terminal.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Alessandro Costanzo Ciano",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"typecheck": "tsc --noEmit"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@ordewell/core": "^0.6.
|
|
53
|
-
"@ordewell/web": "^0.6.
|
|
52
|
+
"@ordewell/core": "^0.6.3",
|
|
53
|
+
"@ordewell/web": "^0.6.3",
|
|
54
54
|
"string-width": "^7.2.0",
|
|
55
55
|
"ws": "^8.18.0"
|
|
56
56
|
},
|