cubefarm 0.3.3 → 0.3.4
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-server/index.js +22 -3
- package/dist-server/index.js.map +3 -3
- package/package.json +1 -1
package/dist-server/index.js
CHANGED
|
@@ -1588,6 +1588,12 @@ function idleHook(live, b) {
|
|
|
1588
1588
|
}
|
|
1589
1589
|
return {};
|
|
1590
1590
|
}
|
|
1591
|
+
function resumableSession(b, exists2) {
|
|
1592
|
+
const id = typeof b.session_id === "string" ? b.session_id : "";
|
|
1593
|
+
const file = typeof b.transcript_path === "string" ? b.transcript_path : "";
|
|
1594
|
+
return id && file && exists2(file) ? id : null;
|
|
1595
|
+
}
|
|
1596
|
+
var lostConversation = (screen) => /No conversation found with session ID/i.test(screen);
|
|
1591
1597
|
function startCliSession(opts, callbacks) {
|
|
1592
1598
|
const term = opts.terminal;
|
|
1593
1599
|
const prev = lives.get(term);
|
|
@@ -1606,6 +1612,7 @@ function startCliSession(opts, callbacks) {
|
|
|
1606
1612
|
const officePrompts = [];
|
|
1607
1613
|
const launched = [];
|
|
1608
1614
|
let mainThread = opts.resumeSessionId ?? null;
|
|
1615
|
+
let kept = opts.resumeSessionId ?? null;
|
|
1609
1616
|
const usageResets = /* @__PURE__ */ new Map();
|
|
1610
1617
|
const warned = /* @__PURE__ */ new Set();
|
|
1611
1618
|
let done = false;
|
|
@@ -1699,6 +1706,13 @@ function startCliSession(opts, callbacks) {
|
|
|
1699
1706
|
const hook = (b) => {
|
|
1700
1707
|
const event = String(b.hook_event_name ?? "");
|
|
1701
1708
|
const sub = typeof b.agent_id === "string" && b.agent_id !== "";
|
|
1709
|
+
if (cli === "claude" && !sub && b.session_id !== kept) {
|
|
1710
|
+
const id = resumableSession(b, fs6.existsSync);
|
|
1711
|
+
if (id) {
|
|
1712
|
+
kept = id;
|
|
1713
|
+
cb.sessionId(id);
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1702
1716
|
switch (event) {
|
|
1703
1717
|
case "PreToolUse": {
|
|
1704
1718
|
const name = String(b.tool_name ?? "");
|
|
@@ -1797,6 +1811,11 @@ function startCliSession(opts, callbacks) {
|
|
|
1797
1811
|
return {};
|
|
1798
1812
|
};
|
|
1799
1813
|
const exited = (exitCode) => {
|
|
1814
|
+
if (cli === "claude" && opts.resumeSessionId && !begun && lostConversation(term.screen())) {
|
|
1815
|
+
cb.sessionId(null);
|
|
1816
|
+
finish({ ok: false, text: "", errors: [`${label} couldn't find the conversation it was resuming, so the next session starts a new one.`] });
|
|
1817
|
+
return;
|
|
1818
|
+
}
|
|
1800
1819
|
const ok = exitCode === 0 && (lastText !== "" || cli !== "claude" && Date.now() - started > 2e4);
|
|
1801
1820
|
finish({ ok, text: lastText, errors: ok ? [] : [`${label} exited${exitCode ? ` with code ${exitCode}` : ""} before finishing.`] });
|
|
1802
1821
|
};
|
|
@@ -1898,7 +1917,7 @@ ${JSON.stringify(opts.outputSchema)}`;
|
|
|
1898
1917
|
env[k] = v;
|
|
1899
1918
|
}
|
|
1900
1919
|
Object.assign(env, { TERM: "xterm-256color", COLORTERM: "truecolor" }, launch2.env);
|
|
1901
|
-
if (cli === "claude") cb.sessionId(sessionId);
|
|
1920
|
+
if (cli === "claude" && opts.resumeSessionId) cb.sessionId(sessionId);
|
|
1902
1921
|
term.note(`\u2500\u2500 ${label}${opts.label ? ` \xB7 ${opts.label}` : ""} \u2500\u2500`);
|
|
1903
1922
|
const resumeId = cli === "claude" ? sessionId : opts.resumeSessionId ?? null;
|
|
1904
1923
|
const l = { agentId: opts.agentId ?? "", cli, term, proc: null, token, dir, resumeId, statusLine, shots: /* @__PURE__ */ new Set(), session: { hook, exited } };
|
|
@@ -5205,7 +5224,7 @@ Note from the manager: ${note}` : ""
|
|
|
5205
5224
|
},
|
|
5206
5225
|
sessionId: (id) => {
|
|
5207
5226
|
a.sessionId = id;
|
|
5208
|
-
a.sessionCli = how.cli ?? "claude";
|
|
5227
|
+
a.sessionCli = id ? how.cli ?? "claude" : null;
|
|
5209
5228
|
},
|
|
5210
5229
|
browserUrl: (url) => {
|
|
5211
5230
|
rt.browserUrl = url;
|
|
@@ -6131,7 +6150,7 @@ ${job.text}` } : job;
|
|
|
6131
6150
|
},
|
|
6132
6151
|
sessionId: (id) => {
|
|
6133
6152
|
a.sessionId = id;
|
|
6134
|
-
a.sessionCli = "claude";
|
|
6153
|
+
a.sessionCli = id ? "claude" : null;
|
|
6135
6154
|
},
|
|
6136
6155
|
browserUrl: () => void 0,
|
|
6137
6156
|
screenshot: () => void 0,
|