@indigoai-us/hq-cli 5.345.215-beta.0 → 5.345.217
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 +206 -1
- package/README.md +45 -0
- package/assets/scaffold/core/scripts/hq-delegate-verify.sh +5 -2
- package/assets/scaffold/core/scripts/lib/epochrealtime.sh +30 -0
- package/assets/scaffold/core/scripts/lib/work-mesh-enqueue.sh +12 -5
- package/dist/command-catalog.generated.d.ts +105 -10
- package/dist/command-catalog.generated.js +127 -10
- package/dist/command-help.js +3 -1
- package/dist/command-registration-plan.d.ts +6 -0
- package/dist/command-registration-plan.js +1 -0
- package/dist/commands/auth.d.ts +1 -1
- package/dist/commands/auth.js +11 -52
- package/dist/commands/bot.js +75 -10
- package/dist/commands/capacity.d.ts +4 -1
- package/dist/commands/capacity.js +46 -10
- package/dist/commands/cloud-demote.d.ts +19 -4
- package/dist/commands/cloud-demote.js +85 -12
- package/dist/commands/cloud-provision.d.ts +5 -1
- package/dist/commands/cloud-provision.js +6 -2
- package/dist/commands/cloud.d.ts +36 -0
- package/dist/commands/cloud.js +110 -27
- package/dist/commands/core-delegate-w1b.js +15 -1
- package/dist/commands/core-policy.js +67 -8
- package/dist/commands/core.js +1 -0
- package/dist/commands/daemon.js +9 -1
- package/dist/commands/dm.js +7 -0
- package/dist/commands/doctor-usage.d.ts +8 -0
- package/dist/commands/doctor-usage.js +20 -0
- package/dist/commands/doctor.js +7 -1
- package/dist/commands/env.d.ts +18 -0
- package/dist/commands/env.js +82 -0
- package/dist/commands/files-browse.d.ts +11 -4
- package/dist/commands/files-browse.js +21 -4
- package/dist/commands/files.d.ts +1 -1
- package/dist/commands/files.js +25 -11
- package/dist/commands/install-global.js +2 -2
- package/dist/commands/integrations-auth-rules.d.ts +27 -0
- package/dist/commands/integrations-auth-rules.js +79 -0
- package/dist/commands/integrations-import.js +124 -12
- package/dist/commands/lanes.js +102 -26
- package/dist/commands/logout.d.ts +7 -0
- package/dist/commands/logout.js +41 -34
- package/dist/commands/mesh.d.ts +2 -0
- package/dist/commands/mesh.js +60 -35
- package/dist/commands/sources.d.ts +8 -2
- package/dist/commands/sources.js +65 -9
- package/dist/commands/sync-held.js +5 -2
- package/dist/commands/whoami.js +26 -1
- package/dist/data/command-states.json +15 -0
- package/dist/index.js +52 -4
- package/dist/lazy-commands.js +5 -6
- package/dist/lib/anywhere-person-setting.d.ts +2 -0
- package/dist/lib/anywhere-person-setting.js +6 -3
- package/dist/lib/billing/usage-card.d.ts +25 -4
- package/dist/lib/billing/usage-card.js +76 -9
- package/dist/lib/billing/usage-cost.d.ts +3 -3
- package/dist/lib/billing/usage-cost.js +35 -13
- package/dist/lib/billing/usage-only.js +4 -2
- package/dist/lib/billing/usage-rate-card.d.ts +2 -2
- package/dist/lib/billing/usage-rate-card.js +3 -0
- package/dist/lib/bot/fleet-cron.d.ts +8 -0
- package/dist/lib/bot/fleet-cron.js +126 -7
- package/dist/lib/bot/fleet-daemon.d.ts +46 -0
- package/dist/lib/bot/fleet-daemon.js +99 -1
- package/dist/lib/bot/inflight.d.ts +9 -0
- package/dist/lib/bot/inflight.js +10 -0
- package/dist/lib/bot/jobs/hot-signal-sync.js +12 -1
- package/dist/lib/bot/probe.js +7 -1
- package/dist/lib/bot/run.js +20 -1
- package/dist/lib/bot/runtime/codex.js +1 -1
- package/dist/lib/bot/runtime/grok-acp.d.ts +6 -1
- package/dist/lib/bot/runtime/grok-acp.js +32 -14
- package/dist/lib/bot/runtime/grok.js +1 -1
- package/dist/lib/bot/runtime/index.js +19 -9
- package/dist/lib/bot/runtime/messages-stream.js +2 -2
- package/dist/lib/bot/runtime/types.d.ts +15 -0
- package/dist/lib/bot/runtime/types.js +9 -0
- package/dist/lib/bot/runtime-failure.d.ts +23 -0
- package/dist/lib/bot/runtime-failure.js +43 -1
- package/dist/lib/capacity/accounts.d.ts +8 -0
- package/dist/lib/capacity/accounts.js +19 -0
- package/dist/lib/capacity/available.d.ts +154 -0
- package/dist/lib/capacity/available.js +905 -0
- package/dist/lib/capacity/codex-availability.d.ts +14 -1
- package/dist/lib/capacity/codex-availability.js +26 -1
- package/dist/lib/capacity/collectors/claude-oauth.d.ts +29 -2
- package/dist/lib/capacity/collectors/claude-oauth.js +104 -7
- package/dist/lib/capacity/collectors/codex.js +10 -7
- package/dist/lib/capacity/ledger.d.ts +37 -1
- package/dist/lib/capacity/ledger.js +207 -30
- package/dist/lib/capacity/project.d.ts +26 -0
- package/dist/lib/capacity/project.js +137 -8
- package/dist/lib/capacity/refusal-rows.d.ts +31 -0
- package/dist/lib/capacity/refusal-rows.js +61 -0
- package/dist/lib/capacity/refusal.d.ts +53 -2
- package/dist/lib/capacity/refusal.js +284 -65
- package/dist/lib/capacity/route.js +46 -11
- package/dist/lib/capacity/widget.d.ts +12 -1
- package/dist/lib/capacity/widget.js +91 -3
- package/dist/lib/daemon/flag-monitor.d.ts +8 -0
- package/dist/lib/daemon/flag-monitor.js +17 -6
- package/dist/lib/daemon/flag.d.ts +65 -1
- package/dist/lib/daemon/flag.js +190 -40
- package/dist/lib/daemon/ops/policy.js +62 -5
- package/dist/lib/daemon/paths.d.ts +72 -2
- package/dist/lib/daemon/paths.js +154 -3
- package/dist/lib/daemon/resolver.d.ts +2 -0
- package/dist/lib/daemon/resolver.js +3 -0
- package/dist/lib/daemon/run.d.ts +9 -0
- package/dist/lib/daemon/run.js +79 -21
- package/dist/lib/daemon/selfcheck.d.ts +22 -0
- package/dist/lib/daemon/selfcheck.js +40 -1
- package/dist/lib/daemon/server.d.ts +5 -1
- package/dist/lib/daemon/server.js +17 -23
- package/dist/lib/daemon/state-file-switch.d.ts +57 -0
- package/dist/lib/daemon/state-file-switch.js +88 -0
- package/dist/lib/daemon/state-file.d.ts +198 -0
- package/dist/lib/daemon/state-file.js +419 -0
- package/dist/lib/daemon/tcc-eperm.d.ts +153 -0
- package/dist/lib/daemon/tcc-eperm.js +310 -0
- package/dist/lib/daemon/timed-flag-monitors.d.ts +47 -0
- package/dist/lib/daemon/timed-flag-monitors.js +75 -0
- package/dist/lib/delivery/admission.d.ts +86 -0
- package/dist/lib/delivery/admission.js +148 -0
- package/dist/lib/delivery/artifacts.d.ts +7 -1
- package/dist/lib/delivery/artifacts.js +29 -10
- package/dist/lib/delivery/attempt-id.d.ts +13 -0
- package/dist/lib/delivery/attempt-id.js +16 -0
- package/dist/lib/delivery/disposable-target.d.ts +42 -0
- package/dist/lib/delivery/disposable-target.js +111 -0
- package/dist/lib/delivery/effects.d.ts +136 -0
- package/dist/lib/delivery/effects.js +541 -0
- package/dist/lib/delivery/enrollment.d.ts +21 -17
- package/dist/lib/delivery/enrollment.js +83 -5
- package/dist/lib/delivery/escalations.d.ts +51 -0
- package/dist/lib/delivery/escalations.js +60 -0
- package/dist/lib/delivery/lease.d.ts +80 -0
- package/dist/lib/delivery/lease.js +134 -0
- package/dist/lib/delivery/migrations.d.ts +120 -4
- package/dist/lib/delivery/migrations.js +215 -15
- package/dist/lib/delivery/mqtt.d.ts +2 -0
- package/dist/lib/delivery/mqtt.js +7 -0
- package/dist/lib/delivery/reconciler.d.ts +65 -1
- package/dist/lib/delivery/reconciler.js +224 -13
- package/dist/lib/delivery/rpc/client.d.ts +22 -0
- package/dist/lib/delivery/rpc/client.js +159 -0
- package/dist/lib/delivery/rpc/port.d.ts +40 -0
- package/dist/lib/delivery/rpc/port.js +16 -0
- package/dist/lib/delivery/rpc/server.d.ts +30 -0
- package/dist/lib/delivery/rpc/server.js +205 -0
- package/dist/lib/delivery/rpc/wire.d.ts +85 -0
- package/dist/lib/delivery/rpc/wire.js +143 -0
- package/dist/lib/delivery/store.d.ts +2 -0
- package/dist/lib/delivery/store.js +4 -0
- package/dist/lib/delivery/windows-service-install.d.ts +262 -0
- package/dist/lib/delivery/windows-service-install.js +892 -0
- package/dist/lib/delivery/workers/macos.d.ts +16 -1
- package/dist/lib/delivery/workers/macos.js +54 -12
- package/dist/lib/delivery/workers/windows-service-live.d.ts +121 -0
- package/dist/lib/delivery/workers/windows-service-live.js +711 -0
- package/dist/lib/delivery/workers/windows-service-runner.d.ts +33 -0
- package/dist/lib/delivery/workers/windows-service-runner.js +82 -0
- package/dist/lib/delivery/workers/windows-service.d.ts +140 -0
- package/dist/lib/delivery/workers/windows-service.js +584 -0
- package/dist/lib/delivery/workers/windows.d.ts +32 -22
- package/dist/lib/delivery/workers/windows.js +50 -64
- package/dist/lib/doctor/checks/host-core.d.ts +50 -0
- package/dist/lib/doctor/checks/host-core.js +269 -0
- package/dist/lib/doctor/checks/replay-recorder.d.ts +39 -0
- package/dist/lib/doctor/checks/replay-recorder.js +261 -0
- package/dist/lib/doctor/registry.js +4 -0
- package/dist/lib/environment/profile.d.ts +239 -0
- package/dist/lib/environment/profile.js +251 -0
- package/dist/lib/hook-engine/reconcile.js +39 -13
- package/dist/lib/hook-engine/registration.d.ts +9 -0
- package/dist/lib/hook-engine/registration.js +19 -0
- package/dist/lib/hot-channels/adapters/meetings.d.ts +15 -0
- package/dist/lib/hot-channels/adapters/meetings.js +36 -3
- package/dist/lib/hot-channels/adapters/slack.d.ts +21 -5
- package/dist/lib/hot-channels/adapters/slack.js +64 -21
- package/dist/lib/hot-channels/alert.d.ts +2 -0
- package/dist/lib/hot-channels/alert.js +8 -1
- package/dist/lib/hot-channels/contract.d.ts +12 -0
- package/dist/lib/hot-channels/contract.js +7 -0
- package/dist/lib/hot-channels/loop.js +1 -0
- package/dist/lib/hot-channels/run.d.ts +6 -0
- package/dist/lib/hot-channels/run.js +4 -0
- package/dist/lib/hot-channels/signals-pass.d.ts +74 -1
- package/dist/lib/hot-channels/signals-pass.js +82 -41
- package/dist/lib/hot-channels/signals-redo.js +10 -2
- package/dist/lib/install/claude-targets.d.ts +12 -1
- package/dist/lib/install/claude-targets.js +57 -5
- package/dist/lib/install/codex-targets.d.ts +2 -2
- package/dist/lib/install/codex-targets.js +36 -6
- package/dist/lib/install/hook-target.d.ts +3 -0
- package/dist/lib/install/hook-target.js +11 -0
- package/dist/lib/lanes/canonical-host.d.ts +35 -0
- package/dist/lib/lanes/canonical-host.js +65 -0
- package/dist/lib/lanes/host-capacity.d.ts +30 -0
- package/dist/lib/lanes/host-capacity.js +29 -3
- package/dist/lib/lanes/watcher.js +35 -0
- package/dist/lib/mesh/live/daemon/run.d.ts +2 -0
- package/dist/lib/mesh/live/daemon/run.js +5 -2
- package/dist/lib/mesh/live/flush.d.ts +5 -1
- package/dist/lib/mesh/live/flush.js +12 -6
- package/dist/lib/mesh/live/reporting-privacy.d.ts +32 -0
- package/dist/lib/mesh/live/reporting-privacy.js +56 -1
- package/dist/lib/mesh/live/spool.d.ts +7 -0
- package/dist/lib/mesh/live/spool.js +25 -0
- package/dist/lib/person-setting-cache.d.ts +38 -0
- package/dist/lib/person-setting-cache.js +98 -0
- package/dist/lib/safe-store.d.ts +245 -0
- package/dist/lib/safe-store.js +777 -0
- package/dist/lib/signals/engine.d.ts +29 -2
- package/dist/lib/signals/engine.js +103 -4
- package/dist/lib/signals/reply.js +73 -18
- package/dist/lib/signals/steps/adapters.js +7 -2
- package/dist/lib/signals/steps/extract.d.ts +13 -0
- package/dist/lib/signals/steps/extract.js +122 -6
- package/dist/main.js +46 -3
- package/dist/schemas/hq-available-ai.v1.schema.json +76 -0
- package/dist/schemas/hq-environment-profile.v1.schema.json +438 -0
- package/dist/utils/auth-expiry.d.ts +8 -0
- package/dist/utils/auth-expiry.js +53 -0
- package/dist/utils/catalog-runtime-paths.d.ts +34 -0
- package/dist/utils/catalog-runtime-paths.js +53 -0
- package/dist/utils/cli-telemetry.d.ts +21 -0
- package/dist/utils/cli-telemetry.js +34 -0
- package/dist/utils/command-usage.d.ts +275 -0
- package/dist/utils/command-usage.js +797 -0
- package/dist/utils/files-browse-acl.js +1 -1
- package/dist/utils/hook-trust.d.ts +7 -0
- package/dist/utils/hook-trust.js +31 -4
- package/dist/utils/host-registration.d.ts +126 -0
- package/dist/utils/host-registration.js +378 -0
- package/dist/utils/resident-package-preload.js +2 -0
- package/package.json +10 -8
- package/scripts/bench-core.mjs +1096 -0
- package/scripts/check-function-manifest.mjs +702 -0
- package/dist/lib/delivery/workers/windows-boundary.d.ts +0 -453
- package/dist/lib/delivery/workers/windows-boundary.js +0 -693
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `hq env`: environment profiles (hq-environment-profile.v1).
|
|
3
|
+
*
|
|
4
|
+
* This release has one subcommand, `hq env validate <file>`. It reads one
|
|
5
|
+
* file and checks it against the schema. The command itself writes nothing,
|
|
6
|
+
* calls no service and needs no sign-in; the CLI's usual start-up state files
|
|
7
|
+
* are still written, as for every hq command.
|
|
8
|
+
*/
|
|
9
|
+
import { readFileSync, statSync } from "node:fs";
|
|
10
|
+
/** A profile is a few kilobytes; nothing larger than this is read. */
|
|
11
|
+
export const ENV_VALIDATE_MAX_BYTES = 5 * 1024 * 1024;
|
|
12
|
+
export function registerEnvCommand(program, overrides = {}) {
|
|
13
|
+
const deps = {
|
|
14
|
+
print: (line) => console.log(line),
|
|
15
|
+
printError: (line) => console.error(line),
|
|
16
|
+
setExitCode: (code) => { process.exitCode = code; },
|
|
17
|
+
...overrides,
|
|
18
|
+
};
|
|
19
|
+
const env = program
|
|
20
|
+
.command("env")
|
|
21
|
+
.description("Environment profiles: the places that can do work (hq-environment-profile.v1)");
|
|
22
|
+
env
|
|
23
|
+
.command("validate")
|
|
24
|
+
.description("Check an environment profile file against hq-environment-profile.v1 (read-only; exit 1 when it is rejected; files up to 5 MB)")
|
|
25
|
+
.argument("<file>", "Path to a profile JSON file")
|
|
26
|
+
.option("--json", "Print the result as JSON")
|
|
27
|
+
.action(async (file, opts) => {
|
|
28
|
+
const { parseEnvironmentProfile } = await import("../lib/environment/profile.js");
|
|
29
|
+
const refuse = (code, message) => {
|
|
30
|
+
if (opts.json)
|
|
31
|
+
deps.print(JSON.stringify({ ok: false, code, message, issues: [], issues_omitted: 0 }, null, 2));
|
|
32
|
+
else
|
|
33
|
+
deps.printError(message);
|
|
34
|
+
deps.setExitCode(1);
|
|
35
|
+
};
|
|
36
|
+
let text;
|
|
37
|
+
try {
|
|
38
|
+
const { size } = statSync(file);
|
|
39
|
+
if (size > ENV_VALIDATE_MAX_BYTES) {
|
|
40
|
+
refuse("too_large", `${file} is too large: ${size} bytes; hq env validate reads files up to ${ENV_VALIDATE_MAX_BYTES} bytes`);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
text = readFileSync(file, "utf8");
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
const code = error.code ?? "error";
|
|
47
|
+
refuse("unreadable", `cannot read ${file} (${code})`);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const result = parseEnvironmentProfile(text);
|
|
51
|
+
if (result.ok) {
|
|
52
|
+
const { declared, view } = result.profile;
|
|
53
|
+
if (opts.json) {
|
|
54
|
+
deps.print(JSON.stringify({
|
|
55
|
+
ok: true,
|
|
56
|
+
schema_version: result.profile.schema_version,
|
|
57
|
+
id: declared.id,
|
|
58
|
+
kind: declared.kind,
|
|
59
|
+
state: declared.state,
|
|
60
|
+
company: view.company,
|
|
61
|
+
}, null, 2));
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
deps.print(`valid ${result.profile.schema_version} ${declared.id} (${declared.kind}, ${declared.state}, company ${view.company})`);
|
|
65
|
+
}
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (opts.json) {
|
|
69
|
+
deps.print(JSON.stringify(result, null, 2));
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
deps.printError(`${file}: ${result.message}`);
|
|
73
|
+
for (const issue of result.issues)
|
|
74
|
+
deps.printError(` ${issue.path || "/"}: ${issue.message}`);
|
|
75
|
+
if (result.issues_omitted > 0)
|
|
76
|
+
deps.printError(` and ${result.issues_omitted} more`);
|
|
77
|
+
}
|
|
78
|
+
deps.setExitCode(1);
|
|
79
|
+
});
|
|
80
|
+
return env;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=env.js.map
|
|
@@ -111,10 +111,14 @@ export type CompanyBrowseClientFactory = (input: {
|
|
|
111
111
|
companyUid: string;
|
|
112
112
|
}) => FilesBrowseS3Client;
|
|
113
113
|
/**
|
|
114
|
-
* ACL provenance for a single listed key
|
|
114
|
+
* ACL provenance for a single listed key: how the CALLER can read it, not
|
|
115
|
+
* who else can.
|
|
115
116
|
* - `shared-with-you`: an explicit grant the caller holds covers the key.
|
|
116
|
-
* - `creator`:
|
|
117
|
-
* key
|
|
117
|
+
* - `creator`: the caller's creator grant (or its folder marker) covers the
|
|
118
|
+
* key and none of the caller's shared grants does; this is explicit
|
|
119
|
+
* creator access, not an owner/admin role bypass. It does not mean the
|
|
120
|
+
* caller is the only reader: browse sees only the caller's own grants,
|
|
121
|
+
* so other members' grants on the same key are not visible here.
|
|
118
122
|
* - `role-bypass`: the caller has no covering explicit grant, but
|
|
119
123
|
* owner/admin role widened the browse-vend policy to include it.
|
|
120
124
|
* - `personal-vault`: the key lives in the caller's own person-entity
|
|
@@ -154,7 +158,10 @@ export declare function toBucketRelative(pathOrPrefix: string, slug: string): st
|
|
|
154
158
|
export declare function toCompanyAnchored(bucketRelKey: string, slug: string): string;
|
|
155
159
|
/**
|
|
156
160
|
* Classify a single company-relative S3 key against the caller's
|
|
157
|
-
* raw explicit-grant patterns
|
|
161
|
+
* raw explicit-grant patterns (the caller's own grants only, so the result
|
|
162
|
+
* says how the caller can read the key, not who else can). When several of
|
|
163
|
+
* the caller's grants cover the key, a shared grant beats a creator grant
|
|
164
|
+
* regardless of order. `foo/*` covers all keys below `foo/`, while
|
|
158
165
|
* `foo/` is the private folder itself and never covers a child key. Otherwise
|
|
159
166
|
* the key is visible only via the owner/admin role-bypass the `/sts/vend`
|
|
160
167
|
* policy applied. An empty-string prefix is a company-wide grant and matches
|
|
@@ -100,7 +100,10 @@ export function toCompanyAnchored(bucketRelKey, slug) {
|
|
|
100
100
|
}
|
|
101
101
|
/**
|
|
102
102
|
* Classify a single company-relative S3 key against the caller's
|
|
103
|
-
* raw explicit-grant patterns
|
|
103
|
+
* raw explicit-grant patterns (the caller's own grants only, so the result
|
|
104
|
+
* says how the caller can read the key, not who else can). When several of
|
|
105
|
+
* the caller's grants cover the key, a shared grant beats a creator grant
|
|
106
|
+
* regardless of order. `foo/*` covers all keys below `foo/`, while
|
|
104
107
|
* `foo/` is the private folder itself and never covers a child key. Otherwise
|
|
105
108
|
* the key is visible only via the owner/admin role-bypass the `/sts/vend`
|
|
106
109
|
* policy applied. An empty-string prefix is a company-wide grant and matches
|
|
@@ -114,25 +117,39 @@ export function classifyAclSource(bucketRelKey, grantPatterns) {
|
|
|
114
117
|
const normalized = grantPatterns.map((entry) => typeof entry === "string"
|
|
115
118
|
? { pattern: entry, source: undefined }
|
|
116
119
|
: entry);
|
|
120
|
+
// A creator match does not end the scan: the caller can hold both a
|
|
121
|
+
// creator grant on the key and a shared grant (person, group, email or
|
|
122
|
+
// open) that covers it, and the server does not order them. The shared
|
|
123
|
+
// grant wins, so a team-readable file is not labelled as creator access
|
|
124
|
+
// just because its creator grant came first (feedback 10ed97a5).
|
|
125
|
+
let creatorMatch = false;
|
|
117
126
|
for (const entry of normalized) {
|
|
118
127
|
const pattern = entry.pattern;
|
|
119
128
|
if (pattern === "" || pattern === "*")
|
|
120
129
|
return "shared-with-you";
|
|
121
130
|
if (pattern.endsWith("/*")) {
|
|
122
131
|
if (bucketRelKey.startsWith(pattern.slice(0, -1))) {
|
|
123
|
-
|
|
132
|
+
if (entry.source !== "creator")
|
|
133
|
+
return "shared-with-you";
|
|
134
|
+
creatorMatch = true;
|
|
124
135
|
}
|
|
125
136
|
continue;
|
|
126
137
|
}
|
|
127
138
|
if (isPrivateFolderPattern(pattern)) {
|
|
128
|
-
|
|
139
|
+
// Keep the existing precedence: a creator match seen earlier still
|
|
140
|
+
// wins over a later private-folder row for the same key.
|
|
141
|
+
if (bucketRelKey === pattern && !creatorMatch)
|
|
129
142
|
return "private-folder";
|
|
130
143
|
continue;
|
|
131
144
|
}
|
|
132
145
|
if (bucketRelKey === pattern) {
|
|
133
|
-
|
|
146
|
+
if (entry.source !== "creator")
|
|
147
|
+
return "shared-with-you";
|
|
148
|
+
creatorMatch = true;
|
|
134
149
|
}
|
|
135
150
|
}
|
|
151
|
+
if (creatorMatch)
|
|
152
|
+
return "creator";
|
|
136
153
|
// The server can expose a creator-owned child row without returning the
|
|
137
154
|
// creator's original `foo/` row. Keep the zero-byte `foo/` marker visible
|
|
138
155
|
// and label it as creator access when a creator grant is underneath it.
|
package/dist/commands/files.d.ts
CHANGED
|
@@ -324,7 +324,7 @@ export declare function runFilesPurge(params: {
|
|
|
324
324
|
confirm?: ConfirmFn;
|
|
325
325
|
now?: () => Date;
|
|
326
326
|
}): Promise<FilesPurgeResult | undefined>;
|
|
327
|
-
/** Cancel a scheduled purge (hq-pro action "
|
|
327
|
+
/** Cancel a scheduled purge (hq-pro action "cancel_purge"). */
|
|
328
328
|
export declare function runFilesPurgeCancel(params: {
|
|
329
329
|
key: string;
|
|
330
330
|
versionId: string;
|
package/dist/commands/files.js
CHANGED
|
@@ -1926,7 +1926,7 @@ async function postPurgeAction(params, action) {
|
|
|
1926
1926
|
if (!res.ok) {
|
|
1927
1927
|
const errBody = (await res.json().catch(() => ({})));
|
|
1928
1928
|
const err = new FilesRecoveryHttpError(res.status, errBody.message ?? errBody.error ?? res.statusText, errBody.code);
|
|
1929
|
-
if (action === "
|
|
1929
|
+
if (action === "cancel_purge" && res.status === 400) {
|
|
1930
1930
|
throw new Error("The server rejected the cancellation: " + err.message + ". If the server predates the 7-day purge window it cannot cancel. Check `hq files versions` to see whether the version still exists.");
|
|
1931
1931
|
}
|
|
1932
1932
|
throw new Error(formatFilesRecoveryError(err, params.key));
|
|
@@ -1960,11 +1960,19 @@ export async function runFilesPurge(params, deps = {}) {
|
|
|
1960
1960
|
}
|
|
1961
1961
|
const data = await postPurgeAction(params, "purge");
|
|
1962
1962
|
const key = typeof data.key === "string" ? data.key : params.key;
|
|
1963
|
-
|
|
1963
|
+
// hq-pro answers a scheduled purge with `purged: false`, `purgeScheduled:
|
|
1964
|
+
// true`, `status: "pending_purge"` and echoes the target as `purgedVersionId`.
|
|
1965
|
+
// Older builds said `status: "scheduled"` / `scheduled: true` with
|
|
1966
|
+
// `purgeVersionId`. Any of these means the version still exists.
|
|
1967
|
+
const saysScheduled = data.status === "scheduled" ||
|
|
1968
|
+
data.status === "pending_purge" ||
|
|
1969
|
+
data.scheduled === true ||
|
|
1970
|
+
data.purgeScheduled === true;
|
|
1971
|
+
const echoedVersionId = data.purgeVersionId ?? data.purgedVersionId;
|
|
1964
1972
|
const scheduled = saysScheduled &&
|
|
1965
1973
|
typeof data.purgeAt === "string" &&
|
|
1966
1974
|
!Number.isNaN(new Date(data.purgeAt).getTime()) &&
|
|
1967
|
-
|
|
1975
|
+
echoedVersionId === params.versionId;
|
|
1968
1976
|
if (saysScheduled && !scheduled) {
|
|
1969
1977
|
// The server says something is scheduled but the response is incomplete.
|
|
1970
1978
|
// Do not report "nothing happened": a deletion may be pending.
|
|
@@ -1973,27 +1981,33 @@ export async function runFilesPurge(params, deps = {}) {
|
|
|
1973
1981
|
}
|
|
1974
1982
|
if (scheduled) {
|
|
1975
1983
|
const purgeAt = data.purgeAt;
|
|
1976
|
-
console.log(chalk.green("Version '" + params.versionId + "' of '" + key + "'
|
|
1977
|
-
formatPurgeDate(purgeAt) + ". It can be cancelled
|
|
1984
|
+
console.log(chalk.green("Version '" + params.versionId + "' of '" + key + "' is scheduled for deletion on " +
|
|
1985
|
+
formatPurgeDate(purgeAt) + ". It stays listed and readable until then, and the purge can be cancelled with:"));
|
|
1978
1986
|
console.log(chalk.dim(" " + formatPurgeCancelCommand(params)));
|
|
1979
1987
|
return { key, versionId: params.versionId, status: "scheduled", purgeAt };
|
|
1980
1988
|
}
|
|
1981
|
-
// Older server: it purged at once and echoes purgedVersionId.
|
|
1982
|
-
|
|
1989
|
+
// Older server: it purged at once and echoes purgedVersionId. Only reached
|
|
1990
|
+
// with no scheduled signal and `purged` not explicitly false.
|
|
1991
|
+
if (data.purged !== false && data.purgedVersionId === params.versionId) {
|
|
1983
1992
|
console.log(chalk.yellow("The server deleted version '" + params.versionId + "' of '" + key +
|
|
1984
1993
|
"' immediately (it does not support the 7-day purge window yet). This cannot be cancelled."));
|
|
1985
1994
|
return { key, versionId: params.versionId, status: "purged" };
|
|
1986
1995
|
}
|
|
1987
1996
|
throw new Error("The server did not confirm the purge (it may not support purge yet). Check `hq files versions` before retrying.");
|
|
1988
1997
|
}
|
|
1989
|
-
/** Cancel a scheduled purge (hq-pro action "
|
|
1998
|
+
/** Cancel a scheduled purge (hq-pro action "cancel_purge"). */
|
|
1990
1999
|
export async function runFilesPurgeCancel(params) {
|
|
1991
2000
|
assertExactRecoveryKey(params.key);
|
|
1992
2001
|
assertPurgeVersionId(params.versionId);
|
|
1993
|
-
const data = await postPurgeAction(params, "
|
|
2002
|
+
const data = await postPurgeAction(params, "cancel_purge");
|
|
1994
2003
|
const key = typeof data.key === "string" ? data.key : params.key;
|
|
1995
|
-
|
|
1996
|
-
|
|
2004
|
+
// hq-pro answers a cancel with `purgeCancelled: true`, `status: "kept"` and
|
|
2005
|
+
// `versionId`; older builds said `status: "cancelled"` with `purgeVersionId`.
|
|
2006
|
+
const confirmed = (data.status === "cancelled" ||
|
|
2007
|
+
data.status === "kept" ||
|
|
2008
|
+
data.cancelled === true ||
|
|
2009
|
+
data.purgeCancelled === true) &&
|
|
2010
|
+
(data.purgeVersionId ?? data.versionId) === params.versionId;
|
|
1997
2011
|
if (!confirmed) {
|
|
1998
2012
|
throw new Error("The server did not confirm the cancellation (it may not support the 7-day purge window yet). Check `hq files versions` to see whether the version still exists.");
|
|
1999
2013
|
}
|
|
@@ -605,7 +605,7 @@ export function installGlobalClaude(opts) {
|
|
|
605
605
|
if (pluginSource)
|
|
606
606
|
log(` plugin: ${pluginSource.pluginId} installed from ${pluginSource.sourceDir}; direct hooks and MCP entries removed`);
|
|
607
607
|
else {
|
|
608
|
-
log(` hooks: ${typeof hookTarget === 'object' ? hookTarget.engine : hookTarget === 'shim' ? 'hqd-hook-shim.sh' : 'master-hook.sh'} registered in ${t.settingsJson}`);
|
|
608
|
+
log(` hooks: ${typeof hookTarget === 'object' ? ('coreNext' in hookTarget ? hookTarget.coreNext : hookTarget.engine) : hookTarget === 'shim' ? 'hqd-hook-shim.sh' : 'master-hook.sh'} registered in ${t.settingsJson}`);
|
|
609
609
|
log(` MCP: "${HQ_MCP_SERVER_NAME}" registered in ${t.claudeJson}`);
|
|
610
610
|
}
|
|
611
611
|
log(` registry: ${seeded.length} manifest entr${seeded.length === 1 ? 'y' : 'ies'} seeded`);
|
|
@@ -984,7 +984,7 @@ export function installGlobalCodex(opts) {
|
|
|
984
984
|
log(` skills linked: ${skills.link.length} new, ${skills.already.length} already present, ${skills.skipped.length} skipped`);
|
|
985
985
|
reportSkillCopies(linkKinds, log);
|
|
986
986
|
reportSkippedSkills(skills, log, false);
|
|
987
|
-
log(` hooks: ${typeof hookTarget === 'object' ? hookTarget.engine : hookTarget === 'shim' ? shimPath(hqRoot) : codexAdapterPath(hqRoot)} registered in ${t.hooksJson}`);
|
|
987
|
+
log(` hooks: ${typeof hookTarget === 'object' ? ('coreNext' in hookTarget ? hookTarget.coreNext : hookTarget.engine) : hookTarget === 'shim' ? shimPath(hqRoot) : codexAdapterPath(hqRoot)} registered in ${t.hooksJson}`);
|
|
988
988
|
log(` MCP: "${HQ_MCP_SERVER_NAME}" registered in ${t.configToml}`);
|
|
989
989
|
return touched;
|
|
990
990
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* feedback_950d8abe: hq-pro's save-time rules for an API key and the header it
|
|
3
|
+
* is sent in (hq-pro src/integration-factory/api-key-characters.ts). The CLI
|
|
4
|
+
* applies the same rules before it sends a key, so a key or header name hq-pro
|
|
5
|
+
* would refuse with a 400 is caught locally with a plain message, and one
|
|
6
|
+
* hq-pro accepts is never refused here.
|
|
7
|
+
*
|
|
8
|
+
* Nothing in this module echoes a key or any part of it.
|
|
9
|
+
*/
|
|
10
|
+
/** hq-pro stores a custom key header name of at most this many characters. */
|
|
11
|
+
export declare const MAX_AUTH_HEADER_LENGTH = 64;
|
|
12
|
+
/**
|
|
13
|
+
* True when hq-pro refuses to send a key in this (token-valid) header name.
|
|
14
|
+
* Authorization is allowed: a header placement named Authorization is the one
|
|
15
|
+
* way to send a raw key with no prefix.
|
|
16
|
+
*/
|
|
17
|
+
export declare function isDeniedAuthHeader(name: string): boolean;
|
|
18
|
+
export type AuthHeaderProblem = "invalid" | "denied" | "too-long";
|
|
19
|
+
/** Why hq-pro would refuse this custom key header name, or null when it is accepted. */
|
|
20
|
+
export declare function authHeaderProblem(name: string): AuthHeaderProblem | null;
|
|
21
|
+
/**
|
|
22
|
+
* hq-pro's rule for a Bearer, prefix or custom-header key: visible ASCII only
|
|
23
|
+
* (0x21-0x7E), so no inner space. An HTTP Basic password is base64 encoded
|
|
24
|
+
* before it is sent and has its own, looser rule on hq-pro.
|
|
25
|
+
*/
|
|
26
|
+
export declare function apiKeyIsSendable(key: string): boolean;
|
|
27
|
+
//# sourceMappingURL=integrations-auth-rules.d.ts.map
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* feedback_950d8abe: hq-pro's save-time rules for an API key and the header it
|
|
3
|
+
* is sent in (hq-pro src/integration-factory/api-key-characters.ts). The CLI
|
|
4
|
+
* applies the same rules before it sends a key, so a key or header name hq-pro
|
|
5
|
+
* would refuse with a 400 is caught locally with a plain message, and one
|
|
6
|
+
* hq-pro accepts is never refused here.
|
|
7
|
+
*
|
|
8
|
+
* Nothing in this module echoes a key or any part of it.
|
|
9
|
+
*/
|
|
10
|
+
/** hq-pro stores a custom key header name of at most this many characters. */
|
|
11
|
+
export const MAX_AUTH_HEADER_LENGTH = 64;
|
|
12
|
+
/** RFC 7230 token characters accepted for an HTTP field name. */
|
|
13
|
+
const HEADER_NAME_TOKEN = /^[A-Za-z0-9!#$%&'*+.^_`|~-]+$/;
|
|
14
|
+
const DENIED_AUTH_HEADER_NAMES = new Set([
|
|
15
|
+
// hop-by-hop, framing and request target
|
|
16
|
+
"connection",
|
|
17
|
+
"keep-alive",
|
|
18
|
+
"proxy-connection",
|
|
19
|
+
"proxy-authorization",
|
|
20
|
+
"proxy-authenticate",
|
|
21
|
+
"te",
|
|
22
|
+
"trailer",
|
|
23
|
+
"transfer-encoding",
|
|
24
|
+
"upgrade",
|
|
25
|
+
"http2-settings",
|
|
26
|
+
"content-length",
|
|
27
|
+
"expect",
|
|
28
|
+
"host",
|
|
29
|
+
"content-encoding",
|
|
30
|
+
// cookies, auth challenges, forwarding and client-IP headers
|
|
31
|
+
"cookie",
|
|
32
|
+
"set-cookie",
|
|
33
|
+
"www-authenticate",
|
|
34
|
+
"forwarded",
|
|
35
|
+
"via",
|
|
36
|
+
"x-real-ip",
|
|
37
|
+
"true-client-ip",
|
|
38
|
+
"cf-connecting-ip",
|
|
39
|
+
"x-original-url",
|
|
40
|
+
// set by HQ's MCP client itself
|
|
41
|
+
"accept",
|
|
42
|
+
"accept-encoding",
|
|
43
|
+
"content-type",
|
|
44
|
+
"user-agent",
|
|
45
|
+
"mcp-protocol-version",
|
|
46
|
+
"mcp-session-id",
|
|
47
|
+
"last-event-id",
|
|
48
|
+
]);
|
|
49
|
+
/** Case-insensitive: Proxy-Authorization, Proxy-Authenticate, every X-Forwarded-*. */
|
|
50
|
+
const DENIED_AUTH_HEADER_PREFIXES = ["proxy-", "x-forwarded-"];
|
|
51
|
+
/**
|
|
52
|
+
* True when hq-pro refuses to send a key in this (token-valid) header name.
|
|
53
|
+
* Authorization is allowed: a header placement named Authorization is the one
|
|
54
|
+
* way to send a raw key with no prefix.
|
|
55
|
+
*/
|
|
56
|
+
export function isDeniedAuthHeader(name) {
|
|
57
|
+
const lower = name.toLowerCase();
|
|
58
|
+
return (DENIED_AUTH_HEADER_NAMES.has(lower) ||
|
|
59
|
+
DENIED_AUTH_HEADER_PREFIXES.some((prefix) => lower.startsWith(prefix)));
|
|
60
|
+
}
|
|
61
|
+
/** Why hq-pro would refuse this custom key header name, or null when it is accepted. */
|
|
62
|
+
export function authHeaderProblem(name) {
|
|
63
|
+
if (!HEADER_NAME_TOKEN.test(name))
|
|
64
|
+
return "invalid";
|
|
65
|
+
if (isDeniedAuthHeader(name))
|
|
66
|
+
return "denied";
|
|
67
|
+
if (name.length > MAX_AUTH_HEADER_LENGTH)
|
|
68
|
+
return "too-long";
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* hq-pro's rule for a Bearer, prefix or custom-header key: visible ASCII only
|
|
73
|
+
* (0x21-0x7E), so no inner space. An HTTP Basic password is base64 encoded
|
|
74
|
+
* before it is sent and has its own, looser rule on hq-pro.
|
|
75
|
+
*/
|
|
76
|
+
export function apiKeyIsSendable(key) {
|
|
77
|
+
return /^[\x21-\x7e]+$/.test(key);
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=integrations-auth-rules.js.map
|
|
@@ -16,6 +16,7 @@ import { installIntegration, startOAuth } from "./integrations-api.js";
|
|
|
16
16
|
import { loadRevealedSecrets } from "./secrets.js";
|
|
17
17
|
import { registerServer } from "./mcp-registration.js";
|
|
18
18
|
import { personalConnectorSettingsEnabled } from "./personal-connector-settings-flag.js";
|
|
19
|
+
import { apiKeyIsSendable, authHeaderProblem, MAX_AUTH_HEADER_LENGTH } from "./integrations-auth-rules.js";
|
|
19
20
|
const OAUTH_REQUIRED_CODE = "INTEGRATION_FACTORY_OAUTH_REQUIRED";
|
|
20
21
|
/** Claude Desktop's documented connector-config location for the current OS. */
|
|
21
22
|
export function claudeDesktopConfigPath(platform = process.platform, home = os.homedir(), env = process.env) {
|
|
@@ -128,6 +129,63 @@ function isLocal(entry) {
|
|
|
128
129
|
function isRemote(entry) {
|
|
129
130
|
return typeof entry.url === "string";
|
|
130
131
|
}
|
|
132
|
+
const MAX_BASIC_USERNAME_LENGTH = 256;
|
|
133
|
+
const CONNECT_INSTEAD = "connect it with `hq integrations connect`";
|
|
134
|
+
const KEY_UNSENDABLE_REASON = `its key has a space or a character HQ can't send in a header; copy the key again and ${CONNECT_INSTEAD}`;
|
|
135
|
+
/**
|
|
136
|
+
* feedback_950d8abe: `Authorization: Basic <base64 user:password>` maps to
|
|
137
|
+
* hq-pro's Basic scheme ({ placement: authorization, format: basic }), which
|
|
138
|
+
* stores the password as the key and the username beside it, and rebuilds the
|
|
139
|
+
* same header when it calls the app. Before, the whole `Basic <base64>` value
|
|
140
|
+
* was sent as a raw key with an inner space, which hq-pro refuses.
|
|
141
|
+
*/
|
|
142
|
+
function basicCredential(encoded, header) {
|
|
143
|
+
const invalid = { unimportable: "its Authorization: Basic value is not base64-encoded user:password" };
|
|
144
|
+
const unpadded = encoded.replace(/=+$/, "");
|
|
145
|
+
if (!/^[A-Za-z0-9+/]+$/.test(unpadded))
|
|
146
|
+
return invalid;
|
|
147
|
+
const bytes = Buffer.from(unpadded, "base64");
|
|
148
|
+
if (bytes.toString("base64").replace(/=+$/, "") !== unpadded)
|
|
149
|
+
return invalid;
|
|
150
|
+
let pair;
|
|
151
|
+
try {
|
|
152
|
+
pair = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
return invalid;
|
|
156
|
+
}
|
|
157
|
+
const colon = pair.indexOf(":");
|
|
158
|
+
if (colon < 0)
|
|
159
|
+
return invalid;
|
|
160
|
+
const username = pair.slice(0, colon);
|
|
161
|
+
const password = pair.slice(colon + 1);
|
|
162
|
+
const secrets = [header, encoded, unpadded, pair, password];
|
|
163
|
+
// hq-pro refuses control characters (a pasted line break, tab or NUL) in a
|
|
164
|
+
// Basic username or password.
|
|
165
|
+
if (/\p{Cc}/u.test(pair))
|
|
166
|
+
return { unimportable: KEY_UNSENDABLE_REASON };
|
|
167
|
+
if (username === "") {
|
|
168
|
+
// hq-pro's Basic scheme with no username sends `<key>:`, so an empty
|
|
169
|
+
// username with a password has no equivalent there.
|
|
170
|
+
return { unimportable: `its Basic credentials have no username, which HQ can't store; ${CONNECT_INSTEAD}` };
|
|
171
|
+
}
|
|
172
|
+
// hq-pro stores a Basic username of at most this many characters.
|
|
173
|
+
if (username.length > MAX_BASIC_USERNAME_LENGTH) {
|
|
174
|
+
return {
|
|
175
|
+
unimportable: `its Basic username is longer than ${MAX_BASIC_USERNAME_LENGTH} characters, which HQ can't store; ${CONNECT_INSTEAD}`,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
if (password === "") {
|
|
179
|
+
return { value: username, authScheme: { placement: "authorization", format: "basic" }, secrets };
|
|
180
|
+
}
|
|
181
|
+
return { value: password, authScheme: { placement: "authorization", format: "basic", username }, secrets };
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Read the connector's static key and how hq-pro should send it. Applies
|
|
185
|
+
* hq-pro's header-name and key rules first (feedback_950d8abe), so a key hq-pro
|
|
186
|
+
* would refuse skips this one connector instead of sending a request that
|
|
187
|
+
* comes back as a 400.
|
|
188
|
+
*/
|
|
131
189
|
function staticCredential(entry) {
|
|
132
190
|
if (!entry.headers || typeof entry.headers !== "object" || Array.isArray(entry.headers))
|
|
133
191
|
return undefined;
|
|
@@ -136,13 +194,57 @@ function staticCredential(entry) {
|
|
|
136
194
|
continue;
|
|
137
195
|
if (!/(authorization|api[-_]?key|token|secret)/i.test(key))
|
|
138
196
|
continue;
|
|
139
|
-
|
|
140
|
-
|
|
197
|
+
const value = raw.trim();
|
|
198
|
+
if (/^authorization$/i.test(key)) {
|
|
199
|
+
if (/^Bearer\s+/i.test(value)) {
|
|
200
|
+
const bearer = value.replace(/^Bearer\s+/i, "");
|
|
201
|
+
return apiKeyIsSendable(bearer) ? { value: bearer, secrets: [value, bearer] } : { unimportable: KEY_UNSENDABLE_REASON };
|
|
202
|
+
}
|
|
203
|
+
const basic = /^Basic\s+(\S+)$/i.exec(value);
|
|
204
|
+
if (basic)
|
|
205
|
+
return basicCredential(basic[1], value);
|
|
206
|
+
if (/^Basic\s/i.test(value))
|
|
207
|
+
return basicCredential("", value);
|
|
208
|
+
if (/^\S+\s+\S/.test(value)) {
|
|
209
|
+
return {
|
|
210
|
+
unimportable: `its Authorization header uses a scheme HQ can't import (only Bearer and Basic are imported); ${CONNECT_INSTEAD}`,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
141
213
|
}
|
|
142
|
-
|
|
214
|
+
switch (authHeaderProblem(key)) {
|
|
215
|
+
case "invalid":
|
|
216
|
+
return { unimportable: "its credential header name is not a valid HTTP header name" };
|
|
217
|
+
case "denied":
|
|
218
|
+
return {
|
|
219
|
+
unimportable: `HQ can't send a key in the ${key} header; ${CONNECT_INSTEAD} and the header name from the app's docs, such as X-API-Key`,
|
|
220
|
+
};
|
|
221
|
+
case "too-long":
|
|
222
|
+
return {
|
|
223
|
+
unimportable: `its credential header name is longer than ${MAX_AUTH_HEADER_LENGTH} characters, which HQ can't store`,
|
|
224
|
+
};
|
|
225
|
+
case null:
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
if (!apiKeyIsSendable(value))
|
|
229
|
+
return { unimportable: KEY_UNSENDABLE_REASON };
|
|
230
|
+
return { value, authScheme: { placement: "header", header: key }, secrets: [value] };
|
|
143
231
|
}
|
|
144
232
|
return undefined;
|
|
145
233
|
}
|
|
234
|
+
/** hq-pro's message for a refused install, with the connector's key scrubbed out. */
|
|
235
|
+
function refusalReason(error, credential) {
|
|
236
|
+
// hq-pro never quotes a key; scrub every string derived from the header (raw
|
|
237
|
+
// value, base64 with and without padding, decoded pair, password, key) anyway
|
|
238
|
+
// so a future message can't leak it. Any length: a short key is still a key.
|
|
239
|
+
const secrets = [...new Set([credential?.value, ...(credential?.secrets ?? [])])]
|
|
240
|
+
.filter((secret) => typeof secret === "string" && secret !== "")
|
|
241
|
+
.sort((a, b) => b.length - a.length);
|
|
242
|
+
// One pass, longest alternative first: scrubbing one secret at a time lets a
|
|
243
|
+
// short secret match inside an earlier "[redacted]" marker and split it.
|
|
244
|
+
const pattern = secrets.map((secret) => secret.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
245
|
+
const message = pattern ? error.message.replace(new RegExp(pattern, "g"), "[redacted]") : error.message;
|
|
246
|
+
return `HQ refused this connector${error.code ? ` (${error.code})` : ""}: ${message}`;
|
|
247
|
+
}
|
|
146
248
|
function oauthRequired(error) {
|
|
147
249
|
return error instanceof IntegrationsCliError &&
|
|
148
250
|
(error.code === OAUTH_REQUIRED_CODE || error.oauthProtected === true);
|
|
@@ -190,9 +292,12 @@ function writeLocalConnector(hqRoot, name, company, personal, entry) {
|
|
|
190
292
|
}
|
|
191
293
|
async function importRemote(token, companyUid, name, entry, dryRun) {
|
|
192
294
|
const provider = providerSlug(name);
|
|
295
|
+
const credential = staticCredential(entry);
|
|
296
|
+
if (credential && "unimportable" in credential) {
|
|
297
|
+
return { name, status: "skipped", provider, reason: credential.unimportable };
|
|
298
|
+
}
|
|
193
299
|
if (dryRun)
|
|
194
300
|
return { name, status: "imported", reason: "would connect remote MCP endpoint", provider };
|
|
195
|
-
const credential = staticCredential(entry);
|
|
196
301
|
try {
|
|
197
302
|
return await installRemote(token, companyUid, name, provider, entry, credential);
|
|
198
303
|
}
|
|
@@ -200,14 +305,21 @@ async function importRemote(token, companyUid, name, entry, dryRun) {
|
|
|
200
305
|
// Members may import connectors, but not over an app someone else already
|
|
201
306
|
// connected for the company. Skip that one connector and keep importing
|
|
202
307
|
// the rest rather than aborting the whole run.
|
|
203
|
-
if (
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
308
|
+
if (reconnectForbidden(error)) {
|
|
309
|
+
return {
|
|
310
|
+
name,
|
|
311
|
+
status: "skipped",
|
|
312
|
+
provider,
|
|
313
|
+
reason: "already connected by someone else; ask a company owner or admin to reconnect it",
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
// feedback_950d8abe: hq-pro refuses one connector's settings (a header or
|
|
317
|
+
// key the checks above did not catch, a bad URL) with a 400. Skip that
|
|
318
|
+
// connector and keep importing the rest.
|
|
319
|
+
if (error instanceof IntegrationsCliError && error.status === 400) {
|
|
320
|
+
return { name, status: "skipped", provider, reason: refusalReason(error, credential) };
|
|
321
|
+
}
|
|
322
|
+
throw error;
|
|
211
323
|
}
|
|
212
324
|
}
|
|
213
325
|
async function installRemote(token, companyUid, name, provider, entry, credential) {
|