@jskit-ai/assistant-core 0.2.0 → 0.2.1
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/package.json
CHANGED
|
@@ -829,12 +829,28 @@ export function createClaudeConversationOwner({
|
|
|
829
829
|
closing = true;
|
|
830
830
|
try {
|
|
831
831
|
await account.queries.invalidate().catch(account.failure);
|
|
832
|
-
return await
|
|
832
|
+
return await stopRetained(application);
|
|
833
833
|
} finally {
|
|
834
834
|
closing = input.reason === "server-shutdown";
|
|
835
835
|
}
|
|
836
836
|
}
|
|
837
837
|
|
|
838
|
+
// Account changes and shutdown stop only what this server runs: a Claude
|
|
839
|
+
// process cannot outlive the server that started it, so retained entries
|
|
840
|
+
// hold every one. Saved conversations are not reopened just to be stopped.
|
|
841
|
+
async function stopRetained(application) {
|
|
842
|
+
const sessions = new Map([...entries.values()].map(entry => [entry.context.key, entry.context.sessionId]));
|
|
843
|
+
let closed = 0;
|
|
844
|
+
let ok = true;
|
|
845
|
+
for (const [key, sessionId] of sessions) {
|
|
846
|
+
closed += (await drain(key)).length;
|
|
847
|
+
const terminal = await application.terminals.close(sessionId);
|
|
848
|
+
closed += Number(terminal?.closed || 0);
|
|
849
|
+
ok &&= terminal?.ok !== false;
|
|
850
|
+
}
|
|
851
|
+
return { ok, closed };
|
|
852
|
+
}
|
|
853
|
+
|
|
838
854
|
async function drain(key) {
|
|
839
855
|
const selected = [...entries.values()].filter(entry => entry.context.key === key);
|
|
840
856
|
// Startup already lends cleanup before initialization completes. Stop it
|
package/test/claudeTurn.test.js
CHANGED
|
@@ -916,6 +916,23 @@ test("Claude active status still rejects account replacement", async t => {
|
|
|
916
916
|
assert.equal(f.entry.process, null);
|
|
917
917
|
});
|
|
918
918
|
|
|
919
|
+
test("Claude account change stops running processes without reopening saved conversations", async t => {
|
|
920
|
+
const f = await publishedClaudeFixture(t);
|
|
921
|
+
f.context.sessionId = "session-a";
|
|
922
|
+
await f.send();
|
|
923
|
+
const closedTerminals = [];
|
|
924
|
+
// A saved conversation can belong to an archived session whose context no longer resolves.
|
|
925
|
+
const application = {
|
|
926
|
+
readContext: async () => { throw new Error("A saved conversation was reopened"); },
|
|
927
|
+
terminals: { close: async sessionId => { closedTerminals.push(sessionId); return { ok: true, closed: 0 }; } }
|
|
928
|
+
};
|
|
929
|
+
const result = await f.owner.invalidateRuntimes({ provider: "claude", reason: "claude-auth-change" }, application,
|
|
930
|
+
{ queries: { invalidate: async () => {} }, failure: error => { throw error; } });
|
|
931
|
+
assert.equal(result.ok, true);
|
|
932
|
+
assert.equal(f.entry.process, null, "the running process stopped");
|
|
933
|
+
assert.deepEqual(closedTerminals, ["session-a"], "the session's Claude terminals closed");
|
|
934
|
+
});
|
|
935
|
+
|
|
919
936
|
test("Claude continuation supersedes an older completion checkpoint", { timeout: 10_000 }, async t => {
|
|
920
937
|
const f = await publishedClaudeFixture(t);
|
|
921
938
|
await f.send();
|