@indigoai-us/hq-cli 5.345.212-beta.0 → 5.345.214
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 +40 -1
- package/dist/bin/hq-auth-refresh.js +2 -1
- package/dist/command-catalog.generated.d.ts +308 -43
- package/dist/command-catalog.generated.js +373 -43
- package/dist/command-registration-plan.d.ts +15 -0
- package/dist/command-registration-plan.js +20 -1
- package/dist/commands/agent-inbox.d.ts +11 -1
- package/dist/commands/agent-inbox.js +128 -38
- package/dist/commands/agent-kit.js +2 -2
- package/dist/commands/agents.js +6 -1
- package/dist/commands/billing.js +17 -4
- package/dist/commands/core-handoff.js +1 -0
- package/dist/commands/core-hq-session-native.js +2 -2
- package/dist/commands/core-pin-native.js +1 -1
- package/dist/commands/core-policy.js +1 -1
- package/dist/commands/core-resolve-company-native.js +1 -1
- package/dist/commands/core-sentry-report-fast.d.ts +2 -0
- package/dist/commands/core-sentry-report-fast.js +3 -1
- package/dist/commands/daemon.js +68 -6
- package/dist/commands/files.js +2 -2
- package/dist/commands/integrations-api.d.ts +11 -0
- package/dist/commands/integrations-connect.d.ts +9 -1
- package/dist/commands/integrations-connect.js +154 -18
- package/dist/commands/integrations-core.d.ts +1 -1
- package/dist/commands/integrations-core.js +18 -10
- package/dist/commands/integrations.js +1 -1
- package/dist/commands/lanes-link.js +10 -5
- package/dist/commands/lanes.js +34 -16
- package/dist/commands/rescue.js +13 -0
- package/dist/commands/secrets.d.ts +11 -0
- package/dist/commands/secrets.js +41 -7
- package/dist/index.js +2 -0
- package/dist/lazy-commands.js +6 -1
- package/dist/lib/agent-kit/inbox-fetch.d.ts +122 -1
- package/dist/lib/agent-kit/inbox-fetch.js +215 -3
- package/dist/lib/agent-kit/inbox-redact.js +1 -1
- package/dist/lib/agent-kit/inbox-state.d.ts +98 -1
- package/dist/lib/agent-kit/inbox-state.js +261 -4
- package/dist/lib/agent-kit/mcp/tools.d.ts +3 -3
- package/dist/lib/agent-kit/mcp/tools.js +68 -25
- package/dist/lib/agent-kit/run/inbox.js +4 -2
- package/dist/lib/agent-kit/skills.js +4 -1
- package/dist/lib/agent-kit/wake.d.ts +9 -1
- package/dist/lib/agent-kit/wake.js +10 -3
- package/dist/lib/billing/usage-only.d.ts +4 -1
- package/dist/lib/billing/usage-only.js +7 -2
- package/dist/lib/bot/fleet-cron.js +193 -14
- package/dist/lib/bot/fleet-download.d.ts +2 -0
- package/dist/lib/bot/fleet-download.js +23 -0
- package/dist/lib/bot/fleet-local.d.ts +1 -0
- package/dist/lib/bot/fleet-local.js +41 -8
- package/dist/lib/capacity/ledger.d.ts +7 -0
- package/dist/lib/capacity/ledger.js +31 -1
- package/dist/lib/capacity/project.d.ts +1 -1
- package/dist/lib/capacity/project.js +13 -4
- package/dist/lib/capacity/route.d.ts +10 -0
- package/dist/lib/capacity/route.js +16 -0
- package/dist/lib/core-utils/session-id.d.ts +1 -1
- package/dist/lib/core-utils/session-id.js +4 -0
- package/dist/lib/daemon/install.d.ts +15 -0
- package/dist/lib/daemon/install.js +31 -0
- package/dist/lib/daemon/migrate.js +29 -4
- package/dist/lib/daemon/run.js +9 -1
- package/dist/lib/daemon/updater.d.ts +34 -2
- package/dist/lib/daemon/updater.js +51 -2
- package/dist/lib/doctor/__testing__/run-doctor.js +4 -0
- package/dist/lib/doctor/checks/jq.d.ts +27 -0
- package/dist/lib/doctor/checks/jq.js +82 -0
- package/dist/lib/doctor/checks/release-links.d.ts +50 -8
- package/dist/lib/doctor/checks/release-links.js +260 -24
- package/dist/lib/doctor/fix/apply.js +24 -8
- package/dist/lib/doctor/fix/remediation.js +15 -5
- package/dist/lib/doctor/registry.js +4 -0
- package/dist/lib/flag-snapshot-file.js +36 -8
- package/dist/lib/install/codex-targets.d.ts +52 -1
- package/dist/lib/install/codex-targets.js +77 -2
- package/dist/lib/lanes/autopilot-registry.d.ts +14 -0
- package/dist/lib/lanes/autopilot-registry.js +59 -7
- package/dist/lib/lanes/links.d.ts +14 -0
- package/dist/lib/lanes/links.js +320 -25
- package/dist/lib/lanes/monitor.d.ts +4 -1
- package/dist/lib/lanes/monitor.js +47 -10
- package/dist/lib/lanes/outpost-pruner-install.d.ts +10 -0
- package/dist/lib/lanes/outpost-pruner-install.js +4 -3
- package/dist/lib/lanes/spawn.js +8 -1
- package/dist/lib/lanes/watch.js +31 -0
- package/dist/lib/onboarding/checkpoint.d.ts +6 -0
- package/dist/lib/onboarding/checkpoint.js +6 -0
- package/dist/lib/onboarding/orchestrator.d.ts +3 -1
- package/dist/lib/onboarding/orchestrator.js +62 -9
- package/dist/lib/onboarding/types.d.ts +8 -0
- package/dist/lib/work-context/organize.d.ts +23 -1
- package/dist/lib/work-context/organize.js +25 -3
- package/dist/lib/work-context/reconcile.js +3 -2
- package/dist/main.js +3 -1
- package/dist/secrets-env-action.js +7 -5
- package/dist/sentry-init.d.ts +2 -0
- package/dist/sentry-init.js +13 -2
- package/dist/sentry.d.ts +2 -0
- package/dist/sentry.js +5 -1
- package/dist/startup-registration.js +7 -2
- package/dist/utils/billing-gate.d.ts +12 -16
- package/dist/utils/billing-gate.js +17 -18
- package/dist/utils/cli-network-lifecycle.d.ts +9 -0
- package/dist/utils/cli-network-lifecycle.js +52 -0
- package/dist/utils/install-tree-torn.d.ts +22 -4
- package/dist/utils/install-tree-torn.js +24 -0
- package/dist/utils/registration-plan-error.d.ts +22 -0
- package/dist/utils/registration-plan-error.js +27 -0
- package/dist/utils/safe-link.d.ts +63 -0
- package/dist/utils/safe-link.js +246 -0
- package/dist/utils/sentry-fingerprint.js +3 -0
- package/dist/utils/sentry-keepalive-transport.d.ts +28 -0
- package/dist/utils/sentry-keepalive-transport.js +70 -0
- package/dist/utils/unauthorized-error.d.ts +36 -0
- package/dist/utils/unauthorized-error.js +105 -0
- package/dist/utils/vault-api.js +7 -5
- package/package.json +7 -7
- package/scripts/install-hook-engine.mjs +17 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { AuthError } from "./auth-error.js";
|
|
2
|
+
/** A machine identity this process signs in as, or null for a person. */
|
|
3
|
+
export interface MachineAuthCaller {
|
|
4
|
+
kind: "company-outpost" | "machine";
|
|
5
|
+
/** The machine's entity uid (out_… / agt_…) when the local state names one. */
|
|
6
|
+
entityUid?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Which machine identity, if any, this process authenticates as. Local state
|
|
10
|
+
* only (env and the machine credential files), no network. A delegated
|
|
11
|
+
* session file always means a machine caller, even when the file is
|
|
12
|
+
* unreadable: the parent that set it chose a machine identity, and a person
|
|
13
|
+
* login could never be the fix.
|
|
14
|
+
*/
|
|
15
|
+
export declare function machineAuthCaller(env?: NodeJS.ProcessEnv): MachineAuthCaller | null;
|
|
16
|
+
/**
|
|
17
|
+
* The machine-readable code from a 401 body, when it carries one. Reads the
|
|
18
|
+
* REST shape (`{ error, code }`) and the JSON-RPC shapes (`error.code`,
|
|
19
|
+
* `error.data.code`). Only an upper-snake-case code is returned.
|
|
20
|
+
*/
|
|
21
|
+
export declare function unauthorizedServerCode(body: unknown): string | undefined;
|
|
22
|
+
/** Message for a 401 a company Outpost job gets. */
|
|
23
|
+
export declare function companyOutpostUnauthorizedMessage(caller: MachineAuthCaller, code?: string): string;
|
|
24
|
+
/** Message for a 401 any other machine identity (agent box, external bot) gets. */
|
|
25
|
+
export declare function machineUnauthorizedMessage(caller: MachineAuthCaller, code?: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* The AuthError for an HTTP 401 from hq-pro. A person keeps the `hq login`
|
|
28
|
+
* message; a company Outpost or other machine identity gets its own recovery
|
|
29
|
+
* and the server's code. Still an AuthError, so the top-level handler prints
|
|
30
|
+
* it and exits non-zero without a Sentry crash report.
|
|
31
|
+
*/
|
|
32
|
+
export declare function unauthorizedError(opts?: {
|
|
33
|
+
body?: unknown;
|
|
34
|
+
env?: NodeJS.ProcessEnv;
|
|
35
|
+
}): AuthError;
|
|
36
|
+
//# sourceMappingURL=unauthorized-error.d.ts.map
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// src/utils/unauthorized-error.ts
|
|
2
|
+
//
|
|
3
|
+
// One place that turns an HTTP 401 from hq-pro into the right AuthError for
|
|
4
|
+
// the identity this process signs in as (feedback_dfc0bb49).
|
|
5
|
+
//
|
|
6
|
+
// A person on a laptop fixes an expired or missing session with `hq login`.
|
|
7
|
+
// A machine identity cannot: a company Outpost job signs in with the Outpost's
|
|
8
|
+
// own machine credentials (the job runner hands it HQ_MACHINE_SESSION_FILE),
|
|
9
|
+
// and an agent box signs in from its machine credentials file. Telling either
|
|
10
|
+
// to run `hq login` sent support chasing a sign-in problem for four days in
|
|
11
|
+
// the Ridge company Outpost incident, when hq-pro was rejecting the Outpost
|
|
12
|
+
// principal itself (OUTPOST_PRINCIPAL_INVALID). So a 401 for a machine caller
|
|
13
|
+
// says the server rejected the machine identity, names the server's code, and
|
|
14
|
+
// gives the recovery that exists for that identity.
|
|
15
|
+
import { DELEGATED_MACHINE_SESSION_ENV, delegatedMachineSessionFilePath, loadMachineCreds, } from "@indigoai-us/hq-cloud";
|
|
16
|
+
import { AuthError } from "./auth-error.js";
|
|
17
|
+
import { wantsMachineCognitoTokens } from "./machine-principal-state.js";
|
|
18
|
+
const ENTITY_UID_PATTERN = /^(out|agt)_[0-9A-Za-z]{10,40}$/;
|
|
19
|
+
// Server codes are upper snake case (OUTPOST_PRINCIPAL_INVALID). Anything else
|
|
20
|
+
// in the body is server text and is not echoed into the message.
|
|
21
|
+
const SERVER_CODE_PATTERN = /^[A-Z][A-Z0-9_]{2,63}$/;
|
|
22
|
+
/**
|
|
23
|
+
* Which machine identity, if any, this process authenticates as. Local state
|
|
24
|
+
* only (env and the machine credential files), no network. A delegated
|
|
25
|
+
* session file always means a machine caller, even when the file is
|
|
26
|
+
* unreadable: the parent that set it chose a machine identity, and a person
|
|
27
|
+
* login could never be the fix.
|
|
28
|
+
*/
|
|
29
|
+
export function machineAuthCaller(env = process.env) {
|
|
30
|
+
try {
|
|
31
|
+
const delegated = delegatedMachineSessionFilePath() !== null;
|
|
32
|
+
if (!delegated && !wantsMachineCognitoTokens({}, env))
|
|
33
|
+
return null;
|
|
34
|
+
const creds = loadMachineCreds();
|
|
35
|
+
const entityUid = typeof creds?.entityUid === "string" && ENTITY_UID_PATTERN.test(creds.entityUid)
|
|
36
|
+
? creds.entityUid
|
|
37
|
+
: undefined;
|
|
38
|
+
const kind = creds?.entityType === "company-outpost" || (delegated && creds === null)
|
|
39
|
+
? "company-outpost"
|
|
40
|
+
: "machine";
|
|
41
|
+
return entityUid ? { kind, entityUid } : { kind };
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The machine-readable code from a 401 body, when it carries one. Reads the
|
|
49
|
+
* REST shape (`{ error, code }`) and the JSON-RPC shapes (`error.code`,
|
|
50
|
+
* `error.data.code`). Only an upper-snake-case code is returned.
|
|
51
|
+
*/
|
|
52
|
+
export function unauthorizedServerCode(body) {
|
|
53
|
+
const record = (value) => value !== null && typeof value === "object" && !Array.isArray(value)
|
|
54
|
+
? value
|
|
55
|
+
: undefined;
|
|
56
|
+
const root = record(body);
|
|
57
|
+
const error = record(root?.error);
|
|
58
|
+
const data = record(error?.data);
|
|
59
|
+
for (const candidate of [root?.code, error?.code, data?.code]) {
|
|
60
|
+
if (typeof candidate === "string" && SERVER_CODE_PATTERN.test(candidate))
|
|
61
|
+
return candidate;
|
|
62
|
+
}
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
function rejectedLine(what, code) {
|
|
66
|
+
return `HQ rejected ${what} (HTTP 401${code ? `, ${code}` : ""}).`;
|
|
67
|
+
}
|
|
68
|
+
/** Message for a 401 a company Outpost job gets. */
|
|
69
|
+
export function companyOutpostUnauthorizedMessage(caller, code) {
|
|
70
|
+
const who = caller.entityUid ? `this company Outpost's identity (${caller.entityUid})` : "this company Outpost's identity";
|
|
71
|
+
return [
|
|
72
|
+
rejectedLine(who, code),
|
|
73
|
+
"This is not a sign-in problem: an Outpost signs in with its own machine credentials, and `hq login` does not apply here.",
|
|
74
|
+
`The job runner gives each run a fresh session through ${DELEGATED_MACHINE_SESSION_ENV}, so re-run the job first.`,
|
|
75
|
+
"If it keeps failing, a company owner or admin runs `hq outposts status --company <company>` and then " +
|
|
76
|
+
"`hq outposts refresh-config --company <company>` from their own machine. If it still fails, report it " +
|
|
77
|
+
`to HQ support${code ? ` with the code ${code}` : ""}.`,
|
|
78
|
+
].join(" ");
|
|
79
|
+
}
|
|
80
|
+
/** Message for a 401 any other machine identity (agent box, external bot) gets. */
|
|
81
|
+
export function machineUnauthorizedMessage(caller, code) {
|
|
82
|
+
const who = caller.entityUid ? `this machine identity (${caller.entityUid})` : "this machine identity";
|
|
83
|
+
return [
|
|
84
|
+
rejectedLine(who, code),
|
|
85
|
+
"It signs in with its machine credentials (HQ_MACHINE_CREDS_FILE), so `hq login` does not apply.",
|
|
86
|
+
"Check that its credentials are current, or ask the operator who provisioned it to re-issue them" +
|
|
87
|
+
`${code ? `, and quote the code ${code}` : ""}.`,
|
|
88
|
+
].join(" ");
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The AuthError for an HTTP 401 from hq-pro. A person keeps the `hq login`
|
|
92
|
+
* message; a company Outpost or other machine identity gets its own recovery
|
|
93
|
+
* and the server's code. Still an AuthError, so the top-level handler prints
|
|
94
|
+
* it and exits non-zero without a Sentry crash report.
|
|
95
|
+
*/
|
|
96
|
+
export function unauthorizedError(opts = {}) {
|
|
97
|
+
const caller = machineAuthCaller(opts.env);
|
|
98
|
+
if (!caller)
|
|
99
|
+
return new AuthError();
|
|
100
|
+
const code = unauthorizedServerCode(opts.body);
|
|
101
|
+
return new AuthError(caller.kind === "company-outpost"
|
|
102
|
+
? companyOutpostUnauthorizedMessage(caller, code)
|
|
103
|
+
: machineUnauthorizedMessage(caller, code));
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=unauthorized-error.js.map
|
package/dist/utils/vault-api.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DEFAULT_VAULT_API_URL, cognitoCachePrincipalUid } from './cognito-session.js';
|
|
2
2
|
import { CLI_VERSION } from '../cli-version.js';
|
|
3
|
-
import {
|
|
3
|
+
import { unauthorizedError } from './unauthorized-error.js';
|
|
4
4
|
import { CompanySelectionError } from './company-selection-error.js';
|
|
5
5
|
import { networkTransportErrorCode } from './network-transport-error.js';
|
|
6
6
|
import { markExpectedUserError } from './expected-cli-error.js';
|
|
@@ -413,12 +413,14 @@ export function looksLikePersonVaultUid(ref) {
|
|
|
413
413
|
return ref.startsWith(PERSON_VAULT_UID_PREFIX);
|
|
414
414
|
}
|
|
415
415
|
// A 401 from ANY vault resolution call means the caller's HQ session is
|
|
416
|
-
// expired or
|
|
417
|
-
//
|
|
418
|
-
//
|
|
416
|
+
// expired, missing or rejected — an expected auth state, not a code defect.
|
|
417
|
+
// Raise a typed AuthError so the top-level handler prints an actionable
|
|
418
|
+
// message and skips Sentry capture (HQ-CLI-8). The message fits the caller: a
|
|
419
|
+
// person runs `hq login`; a company Outpost or other machine identity gets its
|
|
420
|
+
// own recovery (feedback_dfc0bb49).
|
|
419
421
|
function raiseIfUnauthorized(res) {
|
|
420
422
|
if (res.status === 401)
|
|
421
|
-
throw
|
|
423
|
+
throw unauthorizedError();
|
|
422
424
|
}
|
|
423
425
|
async function resolveCompanyByUid(token, uid, baseUrl) {
|
|
424
426
|
const res = await vaultApiFetch({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@indigoai-us/hq-cli",
|
|
3
|
-
"version": "5.345.
|
|
3
|
+
"version": "5.345.214",
|
|
4
4
|
"description": "HQ by Indigo management CLI — modules and cloud sync",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -117,11 +117,11 @@
|
|
|
117
117
|
"*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}": "eslint --cache --no-error-on-unmatched-pattern"
|
|
118
118
|
},
|
|
119
119
|
"optionalDependencies": {
|
|
120
|
-
"@indigoai-us/hq-hook-win32-x64": "5.345.
|
|
121
|
-
"@indigoai-us/hq-hook-win32-arm64": "5.345.
|
|
122
|
-
"@indigoai-us/hq-hook-darwin-x64": "5.345.
|
|
123
|
-
"@indigoai-us/hq-hook-darwin-arm64": "5.345.
|
|
124
|
-
"@indigoai-us/hq-hook-linux-x64": "5.345.
|
|
125
|
-
"@indigoai-us/hq-hook-linux-arm64": "5.345.
|
|
120
|
+
"@indigoai-us/hq-hook-win32-x64": "5.345.214",
|
|
121
|
+
"@indigoai-us/hq-hook-win32-arm64": "5.345.214",
|
|
122
|
+
"@indigoai-us/hq-hook-darwin-x64": "5.345.214",
|
|
123
|
+
"@indigoai-us/hq-hook-darwin-arm64": "5.345.214",
|
|
124
|
+
"@indigoai-us/hq-hook-linux-x64": "5.345.214",
|
|
125
|
+
"@indigoai-us/hq-hook-linux-arm64": "5.345.214"
|
|
126
126
|
}
|
|
127
127
|
}
|
|
@@ -24,3 +24,20 @@ try {
|
|
|
24
24
|
} catch (error) {
|
|
25
25
|
console.warn(`HQ PowerShell launcher cleanup skipped: ${error instanceof Error ? error.message : String(error)}. If PowerShell blocks hq, run hq.cmd doctor --fix.`);
|
|
26
26
|
}
|
|
27
|
+
// Windows: hq-core's master-hook blocks every tool call when jq is missing
|
|
28
|
+
// (hq-core-staging PR 1882), and nothing installs jq on Windows. Warn only:
|
|
29
|
+
// never install jq here and never fail the install. Keep the hint equal to
|
|
30
|
+
// JQ_WINDOWS_INSTALL_HINT in src/lib/doctor/checks/jq.ts. Self-contained so it
|
|
31
|
+
// still runs when dist is missing.
|
|
32
|
+
try {
|
|
33
|
+
if (process.platform === 'win32') {
|
|
34
|
+
const { join } = await import('node:path');
|
|
35
|
+
const dirs = (process.env.PATH ?? '').split(';').map(dir => dir.trim().replace(/^"(.*)"$/, '$1')).filter(Boolean);
|
|
36
|
+
// Git Bash runs the hooks: it can run jq.exe but not a jq.cmd or jq.bat.
|
|
37
|
+
if (!dirs.some(dir => existsSync(join(dir, 'jq.exe')))) {
|
|
38
|
+
console.warn('jq not found on PATH. Install jq (Windows: winget install jqlang.jq) and open a new terminal; HQ hooks block tool calls until jq is on PATH.');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
} catch {
|
|
42
|
+
// A PATH scan failure must not fail the install.
|
|
43
|
+
}
|