@parcha/agentrun-harness-claude 0.1.0-beta.60 → 0.1.0-beta.61
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/CHANGELOG.md +5 -0
- package/dist/login.d.ts +18 -6
- package/dist/login.js +63 -18
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## 0.1.0-beta.61 (2026-11-26)
|
|
6
|
+
|
|
7
|
+
- On macOS, when `security` hangs on the delete of the Keychain item a sign-in left under the account `unknown`, signed-in status checks no longer wait on it each time: checks at once share one delete, and after a delete is killed or fails, status checks leave the item for ten minutes (a sign-in still asks at once). The CLI's own sign-out at AgentRun's own folder now removes that leftover item too. <!-- changes/claude-keychain-drop-backoff.md -->
|
|
8
|
+
- On macOS, a delete of the Keychain item a sign-in left under the account `unknown` that is killed at its limit, or fails, is asked again at the next sign-in or status check, until the item is deleted or found gone. Before, the item was marked dealt with before the delete started, so it stayed for the life of the server. The sign-in's end also settles now should that delete throw before it starts. <!-- changes/claude-keychain-drop-retry.md -->
|
|
9
|
+
|
|
5
10
|
## 0.1.0-beta.60 (2026-11-26)
|
|
6
11
|
|
|
7
12
|
- Sign out of Claude on this machine: `POST /v2/settings/claude-login/sign-out` (operation `signOutClaudeLogin`), and a Sign out button on Settings → Model keys' Claude login row. Before, the row had no way to sign out or switch accounts: Turn off kept the login as the CLI holds it, so Turn on read the same account again with no sign-in page. <!-- changes/claude-login-sign-out.md -->
|
package/dist/login.d.ts
CHANGED
|
@@ -132,13 +132,19 @@ export declare const personHome: (login: ClaudeAgentLogin) => string;
|
|
|
132
132
|
* a sign-in left there when the CLI was started with no USER (loginUser), and which nothing reads now: `security
|
|
133
133
|
* delete-generic-password -a unknown -s <the item's service>`, the service the CLI names from the folder (`Claude
|
|
134
134
|
* Code-credentials-<first 8 hex of the folder's sha256>`), in the person's home (personHome), whose login keychain holds
|
|
135
|
-
* it. Called once the item under the person's account is there (the sign-in exited 0, a status check read signed in)
|
|
135
|
+
* it. Called once the item under the person's account is there (the sign-in exited 0, a status check read signed in),
|
|
136
|
+
* and at the CLI's own sign-out (claudeLogout), after which no status check reads signed in to call it.
|
|
136
137
|
* Never at the person's own CLI's places, whose "unknown" item may be theirs, never the item with no suffix, never an
|
|
137
|
-
* item of any other account, and never where the user this server runs as is named "unknown" itself.
|
|
138
|
-
*
|
|
138
|
+
* item of any other account, and never where the user this server runs as is named "unknown" itself. Nothing is thrown.
|
|
139
|
+
* An item deleted, or found gone ("not found", exit 44), is not asked again in this process. One delete runs per item at
|
|
140
|
+
* a time: a call while it runs waits on that one and starts none. One whose delete was killed at its limit, failed or
|
|
141
|
+
* never started is still there: a call that a person made (`asked`: a sign-in that exited 0, a sign-out) asks again at
|
|
142
|
+
* once, a status check only DROP_BACKOFF_MS after that delete ended, measured on `now` (Date.now by default). */
|
|
139
143
|
export declare function dropUnknownItem(login: ClaudeAgentLogin, options: {
|
|
140
144
|
path: string;
|
|
141
145
|
platform?: NodeJS.Platform;
|
|
146
|
+
asked?: boolean;
|
|
147
|
+
now?: () => number;
|
|
142
148
|
}): Promise<void>;
|
|
143
149
|
/** Ask the CLI at `cli` whether it is signed in at `login`: `auth status --json`, with only PATH, the user (loginUser)
|
|
144
150
|
* and the login's variables beside it, in the person's home (personHome) on every place and platform.
|
|
@@ -156,11 +162,13 @@ export declare function dropUnknownItem(login: ClaudeAgentLogin, options: {
|
|
|
156
162
|
* once it has exited or was killed, the check waits STATUS_DRAIN_MS more at most for its output, which a process it
|
|
157
163
|
* started may hold open, and then one more pass of the event loop's reads. So a check settles within its limit, 2 s and
|
|
158
164
|
* that pass, whatever the CLI does. A `timeoutMs` that is no whole number of ms from 1 to 2^31 - 1 throws a RangeError
|
|
159
|
-
* before anything starts.
|
|
165
|
+
* before anything starts. Signed in, it drops an item left under "unknown" (dropUnknownItem), up to DROP_MS more, and
|
|
166
|
+
* not within the back-off after a delete of it was killed or failed, measured on `now` (Date.now by default). */
|
|
160
167
|
export declare function claudeLoginStatus(cli: string, login: ClaudeAgentLogin, options?: {
|
|
161
168
|
timeoutMs?: number;
|
|
162
169
|
path?: string;
|
|
163
170
|
platform?: NodeJS.Platform;
|
|
171
|
+
now?: () => number;
|
|
164
172
|
}): Promise<ClaudeLoginStatus>;
|
|
165
173
|
/** How long the CLI's own sign-in waits for its browser before it is ended. */
|
|
166
174
|
export declare const SIGN_IN_MS: number;
|
|
@@ -194,7 +202,8 @@ export interface ClaudeSignIn {
|
|
|
194
202
|
* waiting on the browser's port. It is not detached: it stays in this process's group, so a terminal's Ctrl-C ends it
|
|
195
203
|
* with the server as before, and nothing here kills a group, which would take a browser the CLI started with it.
|
|
196
204
|
* A sign-in that exits 0 at AgentRun's own folder has the item a sign-in left there under "unknown" deleted before
|
|
197
|
-
* `ended` settles (dropUnknownItem)
|
|
205
|
+
* `ended` settles (dropUnknownItem), at once, whatever back-off a status check's killed delete left: a person is at the
|
|
206
|
+
* machine. `platform`: the one the CLI runs on, this host's. */
|
|
198
207
|
export declare function startClaudeLogin(cli: string, login: ClaudeAgentLogin, options?: {
|
|
199
208
|
timeoutMs?: number;
|
|
200
209
|
path?: string;
|
|
@@ -210,7 +219,10 @@ export declare const LOGOUT_MS = 15000;
|
|
|
210
219
|
* the config dir's `.claude.json`. Nothing of it
|
|
211
220
|
* is read but how it ended: true when it exited 0 within `timeoutMs` (LOGOUT_MS by default), false when it exited
|
|
212
221
|
* otherwise, never started, or was ended at the limit (SIGTERM, then SIGKILL a second later). Never throws.
|
|
213
|
-
*
|
|
222
|
+
* Then, at AgentRun's own folder on macOS, the item a sign-in left there under "unknown", which holds a refresh token,
|
|
223
|
+
* is deleted too (dropUnknownItem, with its refusals), whatever the CLI said and whatever back-off a status check's
|
|
224
|
+
* killed delete left, since a person asked and no status check reads signed in after a sign-out to drop it. The answer
|
|
225
|
+
* waits on that delete DROP_MS at most. `platform`: as signInEnv's. */
|
|
214
226
|
export declare function claudeLogout(cli: string, login: ClaudeAgentLogin, options?: {
|
|
215
227
|
timeoutMs?: number;
|
|
216
228
|
path?: string;
|
package/dist/login.js
CHANGED
|
@@ -301,16 +301,29 @@ export const personHome = (login) => login.userHome ?? login.home ?? homedir();
|
|
|
301
301
|
/** How long the delete of an "unknown" item may take before it is killed (SIGKILL, which a `security` or a wrapper on
|
|
302
302
|
* PATH cannot ignore, as it can SIGTERM) and left (dropUnknownItem): the sign-in's end and the status check wait on it. */
|
|
303
303
|
const DROP_MS = 5_000;
|
|
304
|
-
/**
|
|
304
|
+
/** After a delete of an "unknown" item is killed at its limit or fails, how long a status check leaves that item before
|
|
305
|
+
* it asks again (dropUnknownItem): a `security` that keeps hanging (a login keychain locked, its prompt unanswered)
|
|
306
|
+
* would otherwise cost every signed-in status check DROP_MS. */
|
|
307
|
+
const DROP_BACKOFF_MS = 10 * 60_000;
|
|
308
|
+
/** The items dropUnknownItem has dealt with in this process, by home and service: deleted, or found gone. */
|
|
305
309
|
const dropped = new Set();
|
|
310
|
+
/** The delete running now for each item, by the same key: a call while it runs waits on it and starts none. */
|
|
311
|
+
const dropping = new Map();
|
|
312
|
+
/** For each item whose last delete was killed or failed, by the same key: when a status check may ask again, on the
|
|
313
|
+
* clock of the call that started that delete. */
|
|
314
|
+
const dropAfter = new Map();
|
|
306
315
|
/** On macOS, at AgentRun's own folder (`own`) alone, delete the login's Keychain item under the account "unknown", which
|
|
307
316
|
* a sign-in left there when the CLI was started with no USER (loginUser), and which nothing reads now: `security
|
|
308
317
|
* delete-generic-password -a unknown -s <the item's service>`, the service the CLI names from the folder (`Claude
|
|
309
318
|
* Code-credentials-<first 8 hex of the folder's sha256>`), in the person's home (personHome), whose login keychain holds
|
|
310
|
-
* it. Called once the item under the person's account is there (the sign-in exited 0, a status check read signed in)
|
|
319
|
+
* it. Called once the item under the person's account is there (the sign-in exited 0, a status check read signed in),
|
|
320
|
+
* and at the CLI's own sign-out (claudeLogout), after which no status check reads signed in to call it.
|
|
311
321
|
* Never at the person's own CLI's places, whose "unknown" item may be theirs, never the item with no suffix, never an
|
|
312
|
-
* item of any other account, and never where the user this server runs as is named "unknown" itself.
|
|
313
|
-
*
|
|
322
|
+
* item of any other account, and never where the user this server runs as is named "unknown" itself. Nothing is thrown.
|
|
323
|
+
* An item deleted, or found gone ("not found", exit 44), is not asked again in this process. One delete runs per item at
|
|
324
|
+
* a time: a call while it runs waits on that one and starts none. One whose delete was killed at its limit, failed or
|
|
325
|
+
* never started is still there: a call that a person made (`asked`: a sign-in that exited 0, a sign-out) asks again at
|
|
326
|
+
* once, a status check only DROP_BACKOFF_MS after that delete ended, measured on `now` (Date.now by default). */
|
|
314
327
|
export async function dropUnknownItem(login, options) {
|
|
315
328
|
if ((options.platform ?? process.platform) !== "darwin" || login.own !== true)
|
|
316
329
|
return;
|
|
@@ -323,17 +336,34 @@ export async function dropUnknownItem(login, options) {
|
|
|
323
336
|
const key = JSON.stringify([HOME, service]);
|
|
324
337
|
if (dropped.has(key))
|
|
325
338
|
return;
|
|
326
|
-
|
|
327
|
-
|
|
339
|
+
const running = dropping.get(key);
|
|
340
|
+
if (running)
|
|
341
|
+
return running;
|
|
342
|
+
const now = options.now ?? Date.now;
|
|
343
|
+
if (options.asked !== true && now() < (dropAfter.get(key) ?? -Infinity))
|
|
344
|
+
return;
|
|
345
|
+
const deleting = new Promise((resolve) => {
|
|
346
|
+
const left = () => {
|
|
347
|
+
dropAfter.set(key, now() + DROP_BACKOFF_MS);
|
|
348
|
+
resolve();
|
|
349
|
+
};
|
|
328
350
|
try {
|
|
329
351
|
const child = spawn("security", ["delete-generic-password", "-a", "unknown", "-s", service], { env: { PATH: options.path, HOME, ...user }, stdio: "ignore", timeout: DROP_MS, killSignal: "SIGKILL" });
|
|
330
|
-
child.once("error",
|
|
331
|
-
child.once("close", () =>
|
|
352
|
+
child.once("error", left);
|
|
353
|
+
child.once("close", (code) => {
|
|
354
|
+
if (code !== 0 && code !== 44)
|
|
355
|
+
return left();
|
|
356
|
+
dropped.add(key);
|
|
357
|
+
dropAfter.delete(key);
|
|
358
|
+
resolve();
|
|
359
|
+
});
|
|
332
360
|
}
|
|
333
361
|
catch {
|
|
334
|
-
|
|
362
|
+
left();
|
|
335
363
|
}
|
|
336
|
-
});
|
|
364
|
+
}).finally(() => dropping.delete(key));
|
|
365
|
+
dropping.set(key, deleting);
|
|
366
|
+
return deleting;
|
|
337
367
|
}
|
|
338
368
|
/** Ask the CLI at `cli` whether it is signed in at `login`: `auth status --json`, with only PATH, the user (loginUser)
|
|
339
369
|
* and the login's variables beside it, in the person's home (personHome) on every place and platform.
|
|
@@ -351,7 +381,8 @@ export async function dropUnknownItem(login, options) {
|
|
|
351
381
|
* once it has exited or was killed, the check waits STATUS_DRAIN_MS more at most for its output, which a process it
|
|
352
382
|
* started may hold open, and then one more pass of the event loop's reads. So a check settles within its limit, 2 s and
|
|
353
383
|
* that pass, whatever the CLI does. A `timeoutMs` that is no whole number of ms from 1 to 2^31 - 1 throws a RangeError
|
|
354
|
-
* before anything starts.
|
|
384
|
+
* before anything starts. Signed in, it drops an item left under "unknown" (dropUnknownItem), up to DROP_MS more, and
|
|
385
|
+
* not within the back-off after a delete of it was killed or failed, measured on `now` (Date.now by default). */
|
|
355
386
|
export async function claudeLoginStatus(cli, login, options = {}) {
|
|
356
387
|
const limitMs = options.timeoutMs ?? LOGIN_STATUS_MS;
|
|
357
388
|
// The limit is the check's timer and, with 2 s more, the end it writes for the sweep, which reads only a whole number
|
|
@@ -421,7 +452,7 @@ export async function claudeLoginStatus(cli, login, options = {}) {
|
|
|
421
452
|
// Signed in: the item under the person's account is there, so one a sign-in left under "unknown" goes (AgentRun's
|
|
422
453
|
// own folder alone).
|
|
423
454
|
if (status.signedIn)
|
|
424
|
-
await dropUnknownItem(login, { path: options.path ?? process.env.PATH ?? "/usr/bin:/bin", ...(options.platform ? { platform: options.platform } : {}) });
|
|
455
|
+
await dropUnknownItem(login, { path: options.path ?? process.env.PATH ?? "/usr/bin:/bin", ...(options.platform ? { platform: options.platform } : {}), ...(options.now ? { now: options.now } : {}) });
|
|
425
456
|
return status;
|
|
426
457
|
}
|
|
427
458
|
finally {
|
|
@@ -534,7 +565,8 @@ function startable(cli, path) {
|
|
|
534
565
|
* waiting on the browser's port. It is not detached: it stays in this process's group, so a terminal's Ctrl-C ends it
|
|
535
566
|
* with the server as before, and nothing here kills a group, which would take a browser the CLI started with it.
|
|
536
567
|
* A sign-in that exits 0 at AgentRun's own folder has the item a sign-in left there under "unknown" deleted before
|
|
537
|
-
* `ended` settles (dropUnknownItem)
|
|
568
|
+
* `ended` settles (dropUnknownItem), at once, whatever back-off a status check's killed delete left: a person is at the
|
|
569
|
+
* machine. `platform`: the one the CLI runs on, this host's. */
|
|
538
570
|
export function startClaudeLogin(cli, login, options = {}) {
|
|
539
571
|
// What a browser needs to open on this desktop, when the server has it.
|
|
540
572
|
const display = Object.fromEntries(["DISPLAY", "WAYLAND_DISPLAY", "XDG_RUNTIME_DIR", "DBUS_SESSION_BUS_ADDRESS", "BROWSER"].flatMap((name) => {
|
|
@@ -584,9 +616,11 @@ export function startClaudeLogin(cli, login, options = {}) {
|
|
|
584
616
|
child.once("close", (code, signal) => {
|
|
585
617
|
const result = ending ? { end: ending } : { end: "exited", code, signal };
|
|
586
618
|
// Signed in: the item under the person's account is there, so one a sign-in left under "unknown" goes first
|
|
587
|
-
// (AgentRun's own folder alone).
|
|
619
|
+
// (AgentRun's own folder alone). The end settles however the drop ends: it throws nothing of its own, and should it
|
|
620
|
+
// throw all the same, the sign-in still ended as the CLI exited (a `finally` here would leave that throw unhandled).
|
|
621
|
+
const finished = () => finish(result);
|
|
588
622
|
if (result.end === "exited" && code === 0)
|
|
589
|
-
void dropUnknownItem(login, { path, ...(options.platform ? { platform: options.platform } : {}) }).then(
|
|
623
|
+
void dropUnknownItem(login, { path, asked: true, ...(options.platform ? { platform: options.platform } : {}) }).then(finished, finished);
|
|
590
624
|
else
|
|
591
625
|
finish(result);
|
|
592
626
|
});
|
|
@@ -600,13 +634,24 @@ export const LOGOUT_MS = LOGIN_STATUS_MS;
|
|
|
600
634
|
* the config dir's `.claude.json`. Nothing of it
|
|
601
635
|
* is read but how it ended: true when it exited 0 within `timeoutMs` (LOGOUT_MS by default), false when it exited
|
|
602
636
|
* otherwise, never started, or was ended at the limit (SIGTERM, then SIGKILL a second later). Never throws.
|
|
603
|
-
*
|
|
604
|
-
|
|
637
|
+
* Then, at AgentRun's own folder on macOS, the item a sign-in left there under "unknown", which holds a refresh token,
|
|
638
|
+
* is deleted too (dropUnknownItem, with its refusals), whatever the CLI said and whatever back-off a status check's
|
|
639
|
+
* killed delete left, since a person asked and no status check reads signed in after a sign-out to drop it. The answer
|
|
640
|
+
* waits on that delete DROP_MS at most. `platform`: as signInEnv's. */
|
|
641
|
+
export async function claudeLogout(cli, login, options = {}) {
|
|
642
|
+
const path = options.path ?? process.env.PATH ?? "/usr/bin:/bin";
|
|
643
|
+
// After the CLI's own sign-out, not beside it: both delete in the one login keychain.
|
|
644
|
+
const signedOut = await cliLogout(cli, login, path, options);
|
|
645
|
+
await dropUnknownItem(login, { path, asked: true, ...(options.platform ? { platform: options.platform } : {}) }).catch(() => { });
|
|
646
|
+
return signedOut;
|
|
647
|
+
}
|
|
648
|
+
/** The CLI's own `auth logout` of claudeLogout: true when it exited 0 within its limit. Never throws. */
|
|
649
|
+
function cliLogout(cli, login, path, options) {
|
|
605
650
|
return new Promise((resolve) => {
|
|
606
651
|
let child;
|
|
607
652
|
try {
|
|
608
653
|
child = spawn(cli, ["auth", "logout"], {
|
|
609
|
-
env: { PATH:
|
|
654
|
+
env: { PATH: path, HOME: personHome(login), ...loginUser(), ...signInEnv(login, options.platform), DISABLE_AUTOUPDATER: "1", DISABLE_TELEMETRY: "1", DISABLE_ERROR_REPORTING: "1" },
|
|
610
655
|
stdio: "ignore",
|
|
611
656
|
});
|
|
612
657
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcha/agentrun-harness-claude",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.61",
|
|
4
4
|
"description": "The Claude Agent SDK as an AgentRun harness: the host's tools as its only tools, its model behind a loopback proxy, durable in AgentRun's own store.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentrun",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"test": "node --test --test-concurrency=8 'test/*.test.mjs'"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@parcha/agentrun-kernel": "0.1.0-beta.
|
|
51
|
+
"@parcha/agentrun-kernel": "0.1.0-beta.61"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@anthropic-ai/claude-agent-sdk": "0.3.286",
|
|
@@ -77,6 +77,6 @@
|
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@anthropic-ai/claude-agent-sdk": "0.3.286",
|
|
80
|
-
"@parcha/agentrun-dsl": "0.1.0-beta.
|
|
80
|
+
"@parcha/agentrun-dsl": "0.1.0-beta.61"
|
|
81
81
|
}
|
|
82
82
|
}
|