@indigoai-us/hq-cli 5.345.263 → 5.345.267
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 +116 -0
- package/assets/scaffold/core/scripts/hq-delegate-grant.sh +4 -48
- package/assets/scaffold/core/scripts/hq-delegate-secrets.sh +16 -10
- package/assets/scaffold/core/scripts/hq-delegate-send.sh +17 -1
- package/contracts/host-canary-release.json +7 -7
- package/dist/command-catalog.generated.d.ts +67 -1
- package/dist/command-catalog.generated.js +83 -1
- package/dist/command-registration-plan.d.ts +6 -0
- package/dist/command-registration-plan.js +1 -0
- package/dist/commands/bot.d.ts +2 -0
- package/dist/commands/bot.js +4 -3
- package/dist/commands/core-delegate-w1b.js +21 -40
- package/dist/commands/core-delegate.js +11 -8
- package/dist/commands/files-browse.d.ts +83 -4
- package/dist/commands/files-browse.js +404 -54
- package/dist/commands/groups.js +2 -2
- package/dist/commands/skill.js +15 -0
- package/dist/commands/sync-held.d.ts +11 -0
- package/dist/commands/sync-held.js +65 -1
- package/dist/commands/sync-telemetry-report.d.ts +5 -0
- package/dist/commands/sync-telemetry-report.js +239 -0
- package/dist/commands/sync-telemetry.d.ts +47 -0
- package/dist/commands/sync-telemetry.js +309 -0
- package/dist/index.js +107 -43
- package/dist/lib/agent-kit/mcp/tools.js +2 -2
- package/dist/lib/agent-kit/skills.js +12 -6
- package/dist/lib/bot/runnable.d.ts +17 -7
- package/dist/lib/bot/runnable.js +17 -10
- package/dist/lib/capacity/available.js +6 -2
- package/dist/lib/capacity/collectors/claude-oauth.d.ts +10 -256
- package/dist/lib/capacity/collectors/claude-oauth.js +19 -1078
- package/dist/lib/capacity/ledger.d.ts +12 -1
- package/dist/lib/capacity/ledger.js +15 -5
- package/dist/lib/capacity/route.d.ts +2 -0
- package/dist/lib/capacity/route.js +21 -4
- package/dist/lib/capacity/scheduler.js +2 -3
- package/dist/lib/capacity/sign-in.js +4 -4
- package/dist/lib/daemon/merge-sections.d.ts +44 -9
- package/dist/lib/daemon/merge-sections.js +234 -37
- package/dist/lib/daemon/ops/skill-command.d.ts +2 -0
- package/dist/lib/daemon/ops/skill-command.js +7 -1
- package/dist/lib/daemon/run.js +1 -0
- package/dist/lib/doctor/checks/antigravity-wiring.d.ts +2 -1
- package/dist/lib/doctor/checks/antigravity-wiring.js +75 -3
- package/dist/lib/doctor/checks/hook-engine.d.ts +2 -0
- package/dist/lib/doctor/checks/hook-engine.js +100 -1
- package/dist/lib/doctor/checks/host-core.d.ts +1 -1
- package/dist/lib/doctor/checks/host-core.js +19 -7
- package/dist/lib/doctor/fix/process-identity.d.ts +2 -0
- package/dist/lib/doctor/fix/process-identity.js +5 -2
- package/dist/lib/hook-engine/coverage.d.ts +19 -10
- package/dist/lib/hook-engine/coverage.js +116 -25
- package/dist/lib/hook-engine/native-precompact-compatibility.json +8 -1
- package/dist/lib/hook-engine/native-stop-compatibility.json +8 -4
- package/dist/lib/hook-engine/reconcile.js +60 -2
- package/dist/lib/install/antigravity-targets.d.ts +22 -0
- package/dist/lib/install/antigravity-targets.js +82 -0
- package/dist/lib/signals/reply.js +25 -5
- package/dist/lib/signals/steps/extract.d.ts +28 -4
- package/dist/lib/signals/steps/extract.js +124 -10
- package/dist/lib/sync-core/release.d.ts +1 -1
- package/dist/lib/sync-core/release.js +2 -2
- package/dist/main.js +8 -3
- package/dist/sentry-init.d.ts +7 -1
- package/dist/sentry-init.js +6 -2
- package/dist/sentry.d.ts +7 -0
- package/dist/sentry.js +16 -1
- package/dist/started-version.d.ts +13 -0
- package/dist/started-version.js +34 -0
- package/dist/startup-registration.d.ts +9 -9
- package/dist/startup-registration.js +42 -18
- package/dist/utils/client-health.d.ts +1 -0
- package/dist/utils/client-health.js +54 -11
- package/dist/utils/core-next-kill.d.ts +9 -0
- package/dist/utils/core-next-kill.js +22 -0
- package/dist/utils/host-registration.d.ts +4 -2
- package/dist/utils/host-registration.js +55 -7
- package/dist/utils/install-tree-recovery-markers.d.ts +45 -0
- package/dist/utils/install-tree-recovery-markers.js +70 -0
- package/dist/utils/install-tree-torn.d.ts +102 -5
- package/dist/utils/install-tree-torn.js +199 -2
- package/dist/utils/sentry-fingerprint.js +3 -0
- package/package.json +7 -7
package/dist/lib/bot/runnable.js
CHANGED
|
@@ -16,20 +16,27 @@
|
|
|
16
16
|
*
|
|
17
17
|
* The rule here is the runtime's rule, asked before anything is written: the
|
|
18
18
|
* bot must run on a computer (`computeMode: "local"`), and the kind this
|
|
19
|
-
* installation would run it as
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
19
|
+
* installation would run it as must be the kind the cloud record says it is.
|
|
20
|
+
*
|
|
21
|
+
* When the cloud kept no settings, adopt/restore take the kind from the
|
|
22
|
+
* record (`botKind`), not the personal default. That is what `hq bot run`
|
|
23
|
+
* then checks. The old personal default is what produced the dead LaunchAgent
|
|
24
|
+
* above; refusing every company bot with no saved settings then made
|
|
25
|
+
* `hq bot status` recommend `hq bot adopt` for a command that always refused.
|
|
26
|
+
* A saved `kind: "personal"` on a company record is still a real mismatch and
|
|
27
|
+
* is still refused.
|
|
24
28
|
*/
|
|
25
29
|
import { effectiveBotKind } from "./config.js";
|
|
26
30
|
import { parseBotLocalConfig } from "./local-config.js";
|
|
27
31
|
import { BOT_RESTORE_DEFAULTS } from "./local-config.js";
|
|
28
|
-
/**
|
|
29
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Kind this installation would write into bot.json, then run. Missing saved
|
|
34
|
+
* settings follow the cloud record, not the personal restore default.
|
|
35
|
+
*/
|
|
36
|
+
export function restoreKindForRecord(bot) {
|
|
30
37
|
const local = parseBotLocalConfig(bot.localConfig);
|
|
31
38
|
return effectiveBotKind({
|
|
32
|
-
kind: local?.kind ?? BOT_RESTORE_DEFAULTS.kind,
|
|
39
|
+
kind: local?.kind ?? (bot.botKind === "company" ? "company" : BOT_RESTORE_DEFAULTS.kind),
|
|
33
40
|
...(local?.workerId ? { workerId: local.workerId } : {}),
|
|
34
41
|
});
|
|
35
42
|
}
|
|
@@ -38,7 +45,7 @@ function sentence(reason, name) {
|
|
|
38
45
|
if (reason === "cloud-compute")
|
|
39
46
|
return `${subject} runs in the cloud, not on a computer, so there is nothing to bring back here.`;
|
|
40
47
|
if (reason === "company-bot") {
|
|
41
|
-
return `${subject} is a company bot
|
|
48
|
+
return `${subject} is a company bot, but the settings HQ kept for it would run it as a personal bot, so this computer cannot start it.`;
|
|
42
49
|
}
|
|
43
50
|
return `${subject} is not set up as the kind of bot this computer can run, so there is nothing to bring back here.`;
|
|
44
51
|
}
|
|
@@ -51,7 +58,7 @@ export function remoteBotRunnability(bot, name) {
|
|
|
51
58
|
return { runnable: false, reason: "cloud-compute", message: sentence("cloud-compute", name) };
|
|
52
59
|
}
|
|
53
60
|
const record = bot.botKind === "company" ? "company" : "personal";
|
|
54
|
-
const here =
|
|
61
|
+
const here = restoreKindForRecord(bot);
|
|
55
62
|
if (record !== here) {
|
|
56
63
|
const reason = record === "company" ? "company-bot" : "kind-mismatch";
|
|
57
64
|
return { runnable: false, reason, message: sentence(reason, name) };
|
|
@@ -30,6 +30,8 @@ export const AVAILABLE_FILE_NAME = "available.json";
|
|
|
30
30
|
export const FRESH_WAIT_MS = 3_000;
|
|
31
31
|
export const STATUS_PROBE_TIMEOUT_MS = 2_500;
|
|
32
32
|
export const COLLECT_MARK = ".available-collect.lock";
|
|
33
|
+
/** Reason for a signed-in account whose access token expired and has no reading since. */
|
|
34
|
+
const EXPIRED_UNREAD_REASON = "Sign-in expired, and it renews on next use. Usage has not been read since.";
|
|
33
35
|
export const COLLECT_MARK_TTL_MS = 60_000;
|
|
34
36
|
const FRESH_POLL_MS = 100;
|
|
35
37
|
/**
|
|
@@ -168,7 +170,9 @@ function planRow(context, result) {
|
|
|
168
170
|
leftPercent: null,
|
|
169
171
|
backAt: null,
|
|
170
172
|
reading: { ageSeconds: reading.ageSeconds, confidence: "unknown" },
|
|
171
|
-
reason:
|
|
173
|
+
reason: ranked.token_expired
|
|
174
|
+
? EXPIRED_UNREAD_REASON
|
|
175
|
+
: "Signed in. Reading usage.",
|
|
172
176
|
nextStep: { kind: "use", label: `Use ${name}` },
|
|
173
177
|
};
|
|
174
178
|
}
|
|
@@ -253,7 +257,7 @@ function planRow(context, result) {
|
|
|
253
257
|
reason: reasonText === SKIP_STALE_READING
|
|
254
258
|
? "No usage reading in the last 24 hours."
|
|
255
259
|
: account.authState === "expired"
|
|
256
|
-
?
|
|
260
|
+
? EXPIRED_UNREAD_REASON
|
|
257
261
|
: "Signed in. Reading usage.",
|
|
258
262
|
nextStep: { kind: "use", label: `Use ${name}` },
|
|
259
263
|
};
|
|
@@ -8,22 +8,9 @@
|
|
|
8
8
|
* header. This module does not invoke the claude CLI except
|
|
9
9
|
* `claude --version` when the caller does not pass cliVersion.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* FAIL CLOSED: an error, a timeout, or an unexpected JSON shape returns an
|
|
15
|
-
* error-signalling throw and the caller records `skipped-live` /
|
|
16
|
-
* `skipped-process` and does NOT rotate the refresh token.
|
|
17
|
-
*
|
|
18
|
-
* Residual blind spot on darwin: `ps -axo pid=,command=` cannot read a
|
|
19
|
-
* child process's environment, so on darwin a running `claude` process is
|
|
20
|
-
* conservatively treated as holding the DEFAULT home AND blocking any
|
|
21
|
-
* non-default home refresh. A sibling that sets `CLAUDE_CONFIG_DIR` to a
|
|
22
|
-
* different home still blocks the gate; this is the safe side of the
|
|
23
|
-
* precision/safety tradeoff. On linux `/proc/<pid>/environ` lets the gate
|
|
24
|
-
* read the per-process `CLAUDE_CONFIG_DIR`, so it only blocks the matching
|
|
25
|
-
* home. Windows and other platforms get no process gate; the lane gate is
|
|
26
|
-
* authoritative there.
|
|
11
|
+
* It never refreshes a token. Claude refresh tokens are single use, so a
|
|
12
|
+
* refresh from here raced Claude Code's own refresh and signed accounts out.
|
|
13
|
+
* An expired access token is reported as expired until Claude Code renews it.
|
|
27
14
|
*
|
|
28
15
|
* The legacy shape (seven_day_opus populated, no limits[]) is drift.
|
|
29
16
|
* observedAt is the response time. One collect appends every account's
|
|
@@ -52,20 +39,13 @@ export declare const CLAUDE_OAUTH_FETCH_TIMEOUT_MS = 10000;
|
|
|
52
39
|
export declare const CLAUDE_OAUTH_SECURITY_TIMEOUT_MS = 5000;
|
|
53
40
|
export declare const CLAUDE_OAUTH_POLL_FILE = "claude-oauth-last-call.json";
|
|
54
41
|
export declare const CLAUDE_KEYCHAIN_SERVICE = "Claude Code-credentials";
|
|
55
|
-
/** Claude Code's refresh endpoint. The URL and the client_id are the ones Claude Code itself posts. */
|
|
56
|
-
export declare const CLAUDE_OAUTH_REFRESH_URL = "https://console.anthropic.com/v1/oauth/token";
|
|
57
|
-
export declare const CLAUDE_OAUTH_REFRESH_CLIENT_ID = "9d1c250a-e61b-44d9-88ed-5944d1962f5e";
|
|
58
|
-
/** Minimum gap between refresh attempts for one home when the previous attempt did not revoke. */
|
|
59
|
-
export declare const CLAUDE_OAUTH_REFRESH_BACKOFF_MS: number;
|
|
60
|
-
/** Minimum gap between refresh attempts for one home after an invalid_grant. */
|
|
61
|
-
export declare const CLAUDE_OAUTH_REFRESH_REVOKED_BACKOFF_MS: number;
|
|
62
|
-
/** Try a refresh when the token is this close to expiry, so one tick does not land on a stale token. */
|
|
63
|
-
export declare const CLAUDE_OAUTH_REFRESH_PREFLIGHT_MS: number;
|
|
64
42
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
43
|
+
* A token this close to expiry is treated as expired and not sent. A usage
|
|
44
|
+
* 401 marks the account revoked; a token sent in its last seconds (or under
|
|
45
|
+
* clock skew) could be refused while its refresh token still works, and the
|
|
46
|
+
* collector would sign out a healthy account.
|
|
67
47
|
*/
|
|
68
|
-
export declare const
|
|
48
|
+
export declare const CLAUDE_OAUTH_EXPIRY_SKEW_MS: number;
|
|
69
49
|
export declare const CLAUDE_OAUTH_REFRESH_LAST_FILE = "claude-oauth-refresh-last.json";
|
|
70
50
|
export interface ClaudeOAuthFetchInit {
|
|
71
51
|
method: "GET";
|
|
@@ -80,21 +60,6 @@ export type ClaudeOAuthFetch = (url: string, init: ClaudeOAuthFetchInit) => Prom
|
|
|
80
60
|
get(name: string): string | null;
|
|
81
61
|
};
|
|
82
62
|
}>;
|
|
83
|
-
export interface ClaudeOAuthRefreshFetchInit {
|
|
84
|
-
method: "POST";
|
|
85
|
-
headers: Record<string, string>;
|
|
86
|
-
body: string;
|
|
87
|
-
redirect: "manual";
|
|
88
|
-
signal?: AbortSignal;
|
|
89
|
-
}
|
|
90
|
-
/** Separate seam from the usage fetch: POST + body, same response shape. */
|
|
91
|
-
export type ClaudeOAuthRefreshFetch = (url: string, init: ClaudeOAuthRefreshFetchInit) => Promise<{
|
|
92
|
-
status: number;
|
|
93
|
-
text: () => Promise<string>;
|
|
94
|
-
headers?: {
|
|
95
|
-
get(name: string): string | null;
|
|
96
|
-
};
|
|
97
|
-
}>;
|
|
98
63
|
export interface SecurityExecResult {
|
|
99
64
|
status: number | null;
|
|
100
65
|
stdout: string;
|
|
@@ -110,9 +75,9 @@ export interface ClaudeCredentialAccount {
|
|
|
110
75
|
expiresAt?: number | null;
|
|
111
76
|
scopes?: readonly string[] | null;
|
|
112
77
|
planType?: string | null;
|
|
113
|
-
/** Opaque refresh token. Never logged, never surfaced.
|
|
78
|
+
/** Opaque refresh token. Never logged, never surfaced. Only fingerprinted for the revoked marker. */
|
|
114
79
|
refreshToken?: string | null;
|
|
115
|
-
/** Full parsed credential JSON.
|
|
80
|
+
/** Full parsed credential JSON. Read only. */
|
|
116
81
|
credentialDocument?: Record<string, unknown> | null;
|
|
117
82
|
/** The config dir this credential belongs to; needed to resolve the Keychain service or file path. */
|
|
118
83
|
home?: string | null;
|
|
@@ -122,82 +87,6 @@ export interface ReadClaudeCredentialsResult {
|
|
|
122
87
|
accounts: ClaudeCredentialAccount[];
|
|
123
88
|
}
|
|
124
89
|
export type ReadClaudeCredentials = () => ReadClaudeCredentialsResult;
|
|
125
|
-
export interface WriteClaudeCredentialsRequest {
|
|
126
|
-
home: string;
|
|
127
|
-
/** macOS Keychain service name; empty on non-darwin. */
|
|
128
|
-
service: string;
|
|
129
|
-
platform: NodeJS.Platform;
|
|
130
|
-
/** The full new credential JSON object. The caller preserved sibling keys. */
|
|
131
|
-
document: Record<string, unknown>;
|
|
132
|
-
/** The refreshToken we read before POSTing to the token endpoint. Used to detect rotation races. */
|
|
133
|
-
previousRefreshToken: string | null;
|
|
134
|
-
}
|
|
135
|
-
export interface WriteClaudeCredentialsResult {
|
|
136
|
-
ok: boolean;
|
|
137
|
-
/** True when the on-disk refresh token no longer matches `previousRefreshToken`. */
|
|
138
|
-
raceDetected?: boolean;
|
|
139
|
-
invalidGrant?: boolean;
|
|
140
|
-
/** Human-readable, already scrubbed of tokens. */
|
|
141
|
-
error?: string;
|
|
142
|
-
}
|
|
143
|
-
export type WriteClaudeCredentials = (request: WriteClaudeCredentialsRequest) => Promise<WriteClaudeCredentialsResult>;
|
|
144
|
-
/**
|
|
145
|
-
* Reads the refresh token currently stored for a home. `null` = stored item has no
|
|
146
|
-
* refresh token; `undefined` = the item could not be read. Never logged.
|
|
147
|
-
*/
|
|
148
|
-
export type ReadStoredClaudeRefreshToken = (request: {
|
|
149
|
-
home: string;
|
|
150
|
-
service: string;
|
|
151
|
-
platform: NodeJS.Platform;
|
|
152
|
-
}) => string | null | undefined;
|
|
153
|
-
/**
|
|
154
|
-
* One row per lane the gate must consider.
|
|
155
|
-
* - `isLive` is true for state ∈ {queued, running, awaiting_input}: a running
|
|
156
|
-
* Claude Code may hold the home; a refresh would race and get invalid_grant.
|
|
157
|
-
* - `isAuthFailed` is true when the lane terminated with reason
|
|
158
|
-
* `provider_auth_failed` (src/lib/lanes/watcher.ts classifies 401/403 that
|
|
159
|
-
* way). The refresh gate no longer treats this as proof of revocation: the
|
|
160
|
-
* lane may have failed on an older token. Only invalid_grant from the token
|
|
161
|
-
* endpoint marks a refresh token revoked.
|
|
162
|
-
* - `home` is the resolved per-host provider home for the account; the gate
|
|
163
|
-
* compares it to the home being refreshed with `canonicalHomePath` (realpath,
|
|
164
|
-
* lower case on darwin) so symlinks and case differences do not slip through;
|
|
165
|
-
* a home that cannot be resolved blocks. `null` is accepted only when the row
|
|
166
|
-
* is not live.
|
|
167
|
-
*/
|
|
168
|
-
export interface LiveLane {
|
|
169
|
-
home: string | null;
|
|
170
|
-
account: string | null;
|
|
171
|
-
provider: string;
|
|
172
|
-
state: string;
|
|
173
|
-
reason: string | null;
|
|
174
|
-
isLive: boolean;
|
|
175
|
-
isAuthFailed: boolean;
|
|
176
|
-
}
|
|
177
|
-
/** Fail-closed: throw on error/timeout/unexpected shape; the caller skips refresh. */
|
|
178
|
-
export type ListLiveLanes = () => Promise<readonly LiveLane[]>;
|
|
179
|
-
/**
|
|
180
|
-
* One row per Claude Code process the gate must consider.
|
|
181
|
-
* - `probe === "env"` means the probe read `/proc/<pid>/environ` and the
|
|
182
|
-
* `env.CLAUDE_CONFIG_DIR` field is authoritative (undefined means default).
|
|
183
|
-
* - `probe === "command-only"` means we only saw the command line (darwin
|
|
184
|
-
* `ps -axo pid=,command=`), with no visibility into the process env. The
|
|
185
|
-
* gate treats such a row as a conservative blocker for every home.
|
|
186
|
-
*/
|
|
187
|
-
export interface ClaudeProcess {
|
|
188
|
-
pid: number;
|
|
189
|
-
/**
|
|
190
|
-
* `HOME` is set when the probe read it. Claude Code resolves its default config dir as
|
|
191
|
-
* HOME/.claude, so a process with HOME set and no CLAUDE_CONFIG_DIR holds that dir.
|
|
192
|
-
*/
|
|
193
|
-
env: {
|
|
194
|
-
CLAUDE_CONFIG_DIR?: string;
|
|
195
|
-
HOME?: string;
|
|
196
|
-
};
|
|
197
|
-
probe: "env" | "command-only";
|
|
198
|
-
}
|
|
199
|
-
/** Fail-closed: throw on error/timeout; the caller skips refresh. */
|
|
200
|
-
export type ListProcesses = () => Promise<readonly ClaudeProcess[]>;
|
|
201
90
|
export interface ClaudeOAuthCollectResult {
|
|
202
91
|
readings: ReadingInput[];
|
|
203
92
|
failures: ParserFailureEvent[];
|
|
@@ -233,25 +122,6 @@ export interface CollectClaudeOAuthOptions {
|
|
|
233
122
|
}[];
|
|
234
123
|
/** One-shot collect reads while the resident collector stays disabled. */
|
|
235
124
|
allowDisabled?: boolean;
|
|
236
|
-
/**
|
|
237
|
-
* Writes a refreshed credential back to disk / Keychain. Default implementation uses
|
|
238
|
-
* `security add-generic-password -U` on darwin and tmp+rename at mode 0600 on linux,
|
|
239
|
-
* preserving all sibling fields (including `mcpOAuth`).
|
|
240
|
-
*/
|
|
241
|
-
writeCredentials?: WriteClaudeCredentials;
|
|
242
|
-
/**
|
|
243
|
-
* Re-reads the stored refresh token before an invalid_grant is recorded as revoked,
|
|
244
|
-
* so a token another process rotated in the meantime is not marked dead.
|
|
245
|
-
*/
|
|
246
|
-
readStoredRefreshToken?: ReadStoredClaudeRefreshToken;
|
|
247
|
-
/** Returns homes that live lanes are using. Default implementation reads `hq runners list --json`. */
|
|
248
|
-
listLiveLanes?: ListLiveLanes;
|
|
249
|
-
/** Returns processes whose `CLAUDE_CONFIG_DIR` identifies a home. Default reads `ps -ewwo pid,command`. */
|
|
250
|
-
listProcesses?: ListProcesses;
|
|
251
|
-
/** Overrides the Claude Code refresh endpoint. Tests set this to a 127.0.0.1 stub. */
|
|
252
|
-
tokenEndpoint?: string;
|
|
253
|
-
/** Overrides the POST transport for the refresh. Default wraps `fetch` with a 10s abort. */
|
|
254
|
-
refreshFetch?: ClaudeOAuthRefreshFetch;
|
|
255
125
|
}
|
|
256
126
|
interface MapOptions {
|
|
257
127
|
observedAt: string;
|
|
@@ -362,121 +232,5 @@ export declare function isRefreshTokenRevoked(root: string, refreshToken: string
|
|
|
362
232
|
* revoked the usage fetch will set a fingerprinted marker on the next 401.
|
|
363
233
|
*/
|
|
364
234
|
export declare function revokedMarkerForCurrentCredential(root: string, accountId: string, refreshToken: string | null | undefined): "match" | "stale" | "none";
|
|
365
|
-
/**
|
|
366
|
-
* Shape of a single lane row emitted by `hq runners list --json`.
|
|
367
|
-
* See src/commands/lanes.ts (withoutProviderHome strips `provider_home_at_spawn`
|
|
368
|
-
* from CLI output; we must consult the accounts registry to map
|
|
369
|
-
* account id -> effective_home).
|
|
370
|
-
*
|
|
371
|
-
* Note: the lane watcher writes a provider-auth-failed signal to the
|
|
372
|
-
* `terminal_reason` field (watcher.ts:~729). The `terminal_details` record
|
|
373
|
-
* carries the structured `account` and `provider` of the rejection
|
|
374
|
-
* (provider-rejection.ts:providerRejectionDetails). Lane records never
|
|
375
|
-
* surface a top-level `reason` for the auth-failed state, so this is the
|
|
376
|
-
* only shape we read.
|
|
377
|
-
*/
|
|
378
|
-
interface RawLaneRow {
|
|
379
|
-
state?: unknown;
|
|
380
|
-
account?: unknown;
|
|
381
|
-
provider?: unknown;
|
|
382
|
-
terminal_reason?: unknown;
|
|
383
|
-
terminal_details?: unknown;
|
|
384
|
-
}
|
|
385
|
-
interface RawAccountRow {
|
|
386
|
-
id?: unknown;
|
|
387
|
-
home?: unknown;
|
|
388
|
-
effective_home?: unknown;
|
|
389
|
-
auth_state?: unknown;
|
|
390
|
-
provider?: unknown;
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* How to re-invoke the running hq CLI without a PATH lookup. When argv[1] is
|
|
394
|
-
* the entry of an installed hq-cli package, run it with the same node binary;
|
|
395
|
-
* the collector runs under launchd and lane workers where PATH may be empty.
|
|
396
|
-
* Falls back to `hq` on PATH when this process is not the hq CLI (tests,
|
|
397
|
-
* embedders). Exported for tests.
|
|
398
|
-
*/
|
|
399
|
-
export declare function resolveHqInvocation(argv?: readonly string[], execPath?: string, execArgv?: readonly string[]): {
|
|
400
|
-
command: string;
|
|
401
|
-
args: string[];
|
|
402
|
-
};
|
|
403
|
-
/**
|
|
404
|
-
* Run `hq ... --json` and parse stdout. Async on purpose: the collector runs inside the mesh
|
|
405
|
-
* daemon, and a synchronous read that takes 15-30 s on a loaded machine froze the daemon's
|
|
406
|
-
* event loop (MQTT keepalive, owner heartbeat) for the whole read.
|
|
407
|
-
* Exported for tests; `invocation` defaults to {@link resolveHqInvocation}.
|
|
408
|
-
*/
|
|
409
|
-
export declare function execHqJson(args: readonly string[], invocation?: {
|
|
410
|
-
command: string;
|
|
411
|
-
args: string[];
|
|
412
|
-
}, env?: NodeJS.ProcessEnv): Promise<unknown>;
|
|
413
|
-
/**
|
|
414
|
-
* Parse `hq runners list --json` payload into typed rows.
|
|
415
|
-
* Exported for tests; fail-closed semantics live in defaultListLiveLanes.
|
|
416
|
-
*/
|
|
417
|
-
export declare function parseLanesListPayload(payload: unknown): readonly RawLaneRow[];
|
|
418
|
-
/**
|
|
419
|
-
* Parse `hq runners accounts list --json` payload into typed rows.
|
|
420
|
-
* Exported for tests; fail-closed semantics live in defaultListLiveLanes.
|
|
421
|
-
*/
|
|
422
|
-
export declare function parseAccountsListPayload(payload: unknown): readonly RawAccountRow[];
|
|
423
|
-
/**
|
|
424
|
-
* Join lanes rows against accounts rows to produce LiveLane records.
|
|
425
|
-
* Exported for tests.
|
|
426
|
-
*/
|
|
427
|
-
export declare function buildLiveLanesFromPayloads(lanes: readonly RawLaneRow[], accounts: readonly RawAccountRow[]): readonly LiveLane[];
|
|
428
|
-
/**
|
|
429
|
-
* Share one lane read across every home in a collect. Without this each expired home ran its
|
|
430
|
-
* own pair of `hq runners ... --json` reads, so one slow machine turned into N timeouts per
|
|
431
|
-
* collect. A failure is shared too: the next home fails closed without waiting again.
|
|
432
|
-
* Exported for tests.
|
|
433
|
-
*/
|
|
434
|
-
export declare function memoizeListLiveLanes(list: ListLiveLanes): ListLiveLanes;
|
|
435
|
-
/**
|
|
436
|
-
* Parse `ps -axo pid=,command=` into rows that mention the `claude` executable.
|
|
437
|
-
* Exported for tests. Returned rows carry `probe: "command-only"` so the gate
|
|
438
|
-
* knows it cannot read per-process CLAUDE_CONFIG_DIR on darwin.
|
|
439
|
-
*/
|
|
440
|
-
export declare function parsePsClaudeOutput(stdout: string): readonly ClaudeProcess[];
|
|
441
|
-
/** Pid to full command line, from `ps -ww -o pid=,command= -p <pids>`. Exported for tests. */
|
|
442
|
-
export declare function parsePsCommandLines(stdout: string): ReadonlyMap<number, string>;
|
|
443
|
-
export interface PsEnvProbeOptions {
|
|
444
|
-
isDirectory?: (dir: string) => boolean;
|
|
445
|
-
/** False only when the pid is known to be gone (ESRCH). Unknown counts as alive. */
|
|
446
|
-
isAlive?: (pid: number) => boolean;
|
|
447
|
-
}
|
|
448
|
-
/**
|
|
449
|
-
* Upgrade darwin command-only rows with each process's environment. `ps -wwE` prints a
|
|
450
|
-
* same-user process's command line followed by its environment, unquoted and space separated.
|
|
451
|
-
* Only the text after the exact command line (read separately with `ps -ww`) is treated as the
|
|
452
|
-
* environment, so a prompt argument that mentions CLAUDE_CONFIG_DIR= or HOME= is never read as
|
|
453
|
-
* env. A row becomes `probe: "env"` only when:
|
|
454
|
-
* - the `-E` line starts with the command line plus a space, and the rest starts with NAME=;
|
|
455
|
-
* - CLAUDE_CONFIG_DIR= appears at most once in that rest, and its value is absolute and
|
|
456
|
-
* names an existing directory (the value runs to the next ` NAME=` or the end of line).
|
|
457
|
-
* Anything else stays command-only, which blocks every home. A pid missing from the output
|
|
458
|
-
* is dropped only when it is known to have exited; otherwise it stays command-only.
|
|
459
|
-
* Exported for tests.
|
|
460
|
-
*/
|
|
461
|
-
export declare function parsePsEnvOutput(envStdout: string, commandLines: ReadonlyMap<number, string>, rows: readonly ClaudeProcess[], options?: PsEnvProbeOptions): readonly ClaudeProcess[];
|
|
462
|
-
/** Default config dir of an env-probed process with CLAUDE_CONFIG_DIR unset. Exported for tests. */
|
|
463
|
-
export declare function processDefaultConfigDir(proc: ClaudeProcess): string;
|
|
464
|
-
/**
|
|
465
|
-
* Canonical form of a home directory for comparison: symlinks resolved by the OS, and lower
|
|
466
|
-
* case on darwin, where APFS is case-insensitive by default. Null when the path cannot be
|
|
467
|
-
* resolved. Exported for tests.
|
|
468
|
-
*/
|
|
469
|
-
export declare function canonicalHomePath(dir: string, platform?: NodeJS.Platform): string | null;
|
|
470
|
-
export interface ClaudeTokenRefreshResult {
|
|
471
|
-
outcome: "refreshed" | "revoked" | "error" | "skipped-race" | "skipped-live" | "skipped-live-check-failed" | "skipped-process" | "skipped-process-check-failed" | "skipped-backoff" | "skipped-revoked";
|
|
472
|
-
newAccessToken?: string;
|
|
473
|
-
newExpiresAt?: number;
|
|
474
|
-
newRefreshToken?: string;
|
|
475
|
-
newScopes?: readonly string[] | null;
|
|
476
|
-
errorMessage?: string;
|
|
477
|
-
errorClass?: ClaudeRefreshErrorClass;
|
|
478
|
-
httpStatus?: number | null;
|
|
479
|
-
}
|
|
480
|
-
export type ClaudeRefreshErrorClass = "invalid_grant" | "revoked" | "server_error" | "timeout" | "network" | "shape";
|
|
481
235
|
export {};
|
|
482
236
|
//# sourceMappingURL=claude-oauth.d.ts.map
|