@mmerterden/multi-agent-pipeline 23.2.0 → 23.4.0
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 +50 -0
- package/README.md +25 -6
- package/README.tr.md +26 -7
- package/docs/adr/0008-installer-modularization-and-secret-leak-defense.md +1 -1
- package/docs/adr/0010-own-code-graph.md +299 -8
- package/docs/architecture.md +3 -3
- package/docs/ecosystem.md +10 -10
- package/docs/engineering.md +4 -4
- package/docs/facts.json +8 -8
- package/docs/features.md +6 -6
- package/docs/performance.md +17 -17
- package/install/_dev-only-files.mjs +9 -0
- package/install/claude.mjs +28 -2
- package/install/templates/claude-hooks.json +32 -1
- package/manifest.json +229 -161
- package/package.json +11 -3
- package/pipeline/commands/multi-agent/SKILL.md +1 -1
- package/pipeline/commands/multi-agent/design-check/SKILL.md +2 -2
- package/pipeline/commands/multi-agent/diff-explain/SKILL.md +3 -3
- package/pipeline/commands/multi-agent/fable-status/SKILL.md +1 -1
- package/pipeline/commands/multi-agent/graph/SKILL.md +57 -24
- package/pipeline/commands/multi-agent/pair/SKILL.md +92 -0
- package/pipeline/commands/multi-agent/prune-prompts/SKILL.md +1 -1
- package/pipeline/commands/multi-agent/search/SKILL.md +7 -1
- package/pipeline/commands/multi-agent/status/SKILL.md +4 -0
- package/pipeline/commands/multi-agent/sync/SKILL.md +3 -3
- package/pipeline/contract/CHANGELOG.md +49 -0
- package/pipeline/contract/build.mjs +13 -1
- package/pipeline/contract/fixtures/error-invalid-request.json +1 -1
- package/pipeline/contract/fixtures/error-unauthorized.json +1 -1
- package/pipeline/contract/fixtures/runs-awaiting-question.json +4 -1
- package/pipeline/contract/fixtures/runs-empty.json +1 -1
- package/pipeline/contract/fixtures/runs-failed.json +4 -1
- package/pipeline/contract/fixtures/runs-old-schema.json +3 -0
- package/pipeline/contract/fixtures/runs-pr-opened-redacted.json +4 -1
- package/pipeline/contract/fixtures/runs-pr-opened.json +4 -1
- package/pipeline/contract/fixtures/runs-running.json +4 -1
- package/pipeline/contract/manifest.json +28 -15
- package/pipeline/contract/types/index.d.ts +55 -3
- package/pipeline/lib/detach-self.mjs +95 -0
- package/pipeline/lib/model-rung.sh +1 -1
- package/pipeline/lib/public-mcp-servers.mjs +33 -0
- package/pipeline/lib/rotated-log.mjs +93 -0
- package/pipeline/lib/tls-trust.mjs +29 -0
- package/pipeline/lib/usage-lifecycle.mjs +9 -11
- package/pipeline/lib/usage-names.generated.mjs +614 -0
- package/pipeline/lib/usage-run-key.mjs +235 -0
- package/pipeline/lib/usage-vocab.mjs +210 -0
- package/pipeline/multi-agent-refs/analysis/intake.md +2 -2
- package/pipeline/multi-agent-refs/analysis/render.md +1 -1
- package/pipeline/multi-agent-refs/channels/generator.md +4 -5
- package/pipeline/multi-agent-refs/cross-cli-contract.md +4 -4
- package/pipeline/multi-agent-refs/design-check/scope-and-ledger.md +1 -1
- package/pipeline/multi-agent-refs/features/code-graph.md +146 -11
- package/pipeline/multi-agent-refs/features/code-intelligence.md +16 -14
- package/pipeline/multi-agent-refs/features/dev-critic.md +7 -7
- package/pipeline/multi-agent-refs/features/model-fallback.md +9 -7
- package/pipeline/multi-agent-refs/features/remote-control.md +252 -0
- package/pipeline/multi-agent-refs/features/review-delta.md +1 -1
- package/pipeline/multi-agent-refs/features/review-file-set.md +3 -3
- package/pipeline/multi-agent-refs/features/review-multi-repo.md +1 -1
- package/pipeline/multi-agent-refs/features/session-brief.md +42 -0
- package/pipeline/multi-agent-refs/features/skill-conformance.md +3 -3
- package/pipeline/multi-agent-refs/features/usage-reporting.md +252 -24
- package/pipeline/multi-agent-refs/help/en.md +3 -2
- package/pipeline/multi-agent-refs/help/tr.md +3 -2
- package/pipeline/multi-agent-refs/knowledge.md +1 -1
- package/pipeline/multi-agent-refs/orchestrator/copilot-pipeline.md +1 -1
- package/pipeline/multi-agent-refs/orchestrator/dispatcher.md +1 -1
- package/pipeline/multi-agent-refs/phases/operations.md +2 -2
- package/pipeline/multi-agent-refs/phases/phase-0-init.md +13 -12
- package/pipeline/multi-agent-refs/phases/phase-1-plan.md +4 -4
- package/pipeline/multi-agent-refs/phases/phase-3-review.md +5 -3
- package/pipeline/multi-agent-refs/phases/phase-5-report.md +1 -1
- package/pipeline/multi-agent-refs/platform-parity.md +2 -2
- package/pipeline/multi-agent-refs/review/panel.md +1 -1
- package/pipeline/multi-agent-refs/wiki-capture.md +3 -17
- package/pipeline/office/index.html +1207 -233
- package/pipeline/office/toolkit.json +1 -1
- package/pipeline/rules/outside-the-pipeline.md +1 -1
- package/pipeline/schemas/activity.schema.json +23 -0
- package/pipeline/schemas/agent-state.schema.json +6 -1
- package/pipeline/schemas/code-graph-calls.schema.json +254 -0
- package/pipeline/schemas/code-graph-docs.schema.json +223 -0
- package/pipeline/schemas/code-graph-infra.schema.json +227 -0
- package/pipeline/schemas/code-graph.schema.json +2 -2
- package/pipeline/schemas/examples/design-check-config.json +27 -0
- package/pipeline/schemas/learning-curve.schema.json +67 -0
- package/pipeline/schemas/office-jobs.json +69 -2
- package/pipeline/schemas/office-jobs.schema.json +8 -1
- package/pipeline/schemas/phases.json +5 -0
- package/pipeline/schemas/phases.schema.json +8 -0
- package/pipeline/schemas/prefs.schema.json +46 -12
- package/pipeline/schemas/runs-index.schema.json +17 -0
- package/pipeline/schemas/toolkit-path-params.json +84 -8
- package/pipeline/scripts/README.md +1 -0
- package/pipeline/scripts/_code-graph.mjs +184 -103
- package/pipeline/scripts/_contract-core.mjs +1 -1
- package/pipeline/scripts/_contract-routes-office.mjs +21 -0
- package/pipeline/scripts/_diff-impact.mjs +21 -2
- package/pipeline/scripts/_graph-sidecars.mjs +372 -0
- package/pipeline/scripts/_http-post.mjs +103 -115
- package/pipeline/scripts/_safe-read.mjs +57 -0
- package/pipeline/scripts/_skill-practices.mjs +26 -0
- package/pipeline/scripts/_strip-code.mjs +380 -0
- package/pipeline/scripts/activity-snapshot.mjs +13 -1
- package/pipeline/scripts/aggregate-metrics.mjs +3 -5
- package/pipeline/scripts/call-graph/index.mjs +78 -0
- package/pipeline/scripts/call-graph/lang/cpp.mjs +308 -0
- package/pipeline/scripts/call-graph/lang/csharp.mjs +130 -0
- package/pipeline/scripts/call-graph/lang/go.mjs +303 -0
- package/pipeline/scripts/call-graph/lang/java.mjs +370 -0
- package/pipeline/scripts/call-graph/lang/kotlin.mjs +397 -0
- package/pipeline/scripts/call-graph/lang/python.mjs +399 -0
- package/pipeline/scripts/call-graph/lang/rust.mjs +345 -0
- package/pipeline/scripts/call-graph/lang/shared.mjs +230 -0
- package/pipeline/scripts/call-graph/lang/swift.mjs +432 -0
- package/pipeline/scripts/call-graph/lang/typescript.mjs +692 -0
- package/pipeline/scripts/call-graph/lex.mjs +396 -0
- package/pipeline/scripts/call-graph/platform.mjs +86 -0
- package/pipeline/scripts/call-graph/profiles.mjs +89 -0
- package/pipeline/scripts/call-graph/resolve.mjs +1125 -0
- package/pipeline/scripts/call-graph/scan.mjs +267 -0
- package/pipeline/scripts/code-graph-rules/android.json +7 -2
- package/pipeline/scripts/code-graph-rules/cpp.json +99 -0
- package/pipeline/scripts/code-graph-rules/csharp.json +102 -0
- package/pipeline/scripts/code-graph-rules/go.json +2 -1
- package/pipeline/scripts/code-graph-rules/ios.json +3 -1
- package/pipeline/scripts/code-graph-rules/java.json +76 -0
- package/pipeline/scripts/code-graph-rules/node.json +7 -2
- package/pipeline/scripts/code-graph-rules/python.json +6 -2
- package/pipeline/scripts/code-graph-rules/rust.json +105 -0
- package/pipeline/scripts/contract-server.mjs +1 -0
- package/pipeline/scripts/cost-table.json +6 -5
- package/pipeline/scripts/feedback-send.mjs +26 -26
- package/pipeline/scripts/gate-ledger.mjs +2 -1
- package/pipeline/scripts/gen-usage-names.mjs +124 -0
- package/pipeline/scripts/graph-affected.mjs +109 -20
- package/pipeline/scripts/graph-build.mjs +95 -15
- package/pipeline/scripts/graph-export.mjs +272 -0
- package/pipeline/scripts/graph-hint.mjs +15 -2
- package/pipeline/scripts/graph-query.mjs +305 -26
- package/pipeline/scripts/graph-report.mjs +187 -1
- package/pipeline/scripts/health-report.mjs +3 -4
- package/pipeline/scripts/infra/docs.mjs +317 -0
- package/pipeline/scripts/infra/extract.mjs +998 -0
- package/pipeline/scripts/infra/graph.mjs +245 -0
- package/pipeline/scripts/infra/yaml-lite.mjs +311 -0
- package/pipeline/scripts/job-launch.mjs +67 -2
- package/pipeline/scripts/learning-curve.mjs +288 -178
- package/pipeline/scripts/log-metric.sh +10 -1
- package/pipeline/scripts/note-agent-event.mjs +3 -4
- package/pipeline/scripts/note-command-use.mjs +333 -0
- package/pipeline/scripts/note-command-use.sh +126 -0
- package/pipeline/scripts/note-mcp-call.sh +89 -0
- package/pipeline/scripts/note-mcp-failure.mjs +272 -1
- package/pipeline/scripts/note-session.sh +62 -3
- package/pipeline/scripts/note-skill-use.mjs +58 -2
- package/pipeline/scripts/office-build.mjs +115 -1
- package/pipeline/scripts/office-memory.mjs +14 -5
- package/pipeline/scripts/pair.mjs +333 -0
- package/pipeline/scripts/pre-push-check.sh +1 -1
- package/pipeline/scripts/remote/cbor.mjs +128 -0
- package/pipeline/scripts/remote/contract.mjs +98 -0
- package/pipeline/scripts/remote/handler.mjs +317 -0
- package/pipeline/scripts/remote/handles.mjs +57 -0
- package/pipeline/scripts/remote/lifecycle.mjs +186 -0
- package/pipeline/scripts/remote/listener.mjs +204 -0
- package/pipeline/scripts/remote/lockout.mjs +103 -0
- package/pipeline/scripts/remote/nonces.mjs +61 -0
- package/pipeline/scripts/remote/pairing.mjs +519 -0
- package/pipeline/scripts/remote/qr-encode.mjs +459 -0
- package/pipeline/scripts/remote/store.mjs +188 -0
- package/pipeline/scripts/remote/transport.mjs +211 -0
- package/pipeline/scripts/remote/verbs.json +70 -0
- package/pipeline/scripts/remote/verbs.mjs +217 -0
- package/pipeline/scripts/remote/webauthn.mjs +169 -0
- package/pipeline/scripts/remote/wire.mjs +364 -0
- package/pipeline/scripts/remote-listener.mjs +83 -0
- package/pipeline/scripts/route-learn.mjs +4 -4
- package/pipeline/scripts/run-kill.mjs +1 -1
- package/pipeline/scripts/run-write.mjs +13 -2
- package/pipeline/scripts/runs-index.mjs +30 -3
- package/pipeline/scripts/search-logs.sh +9 -0
- package/pipeline/scripts/session-brief.mjs +458 -0
- package/pipeline/scripts/session-brief.sh +130 -0
- package/pipeline/scripts/test-gap-rules/cpp.json +25 -0
- package/pipeline/scripts/test-gap-rules/csharp.json +20 -0
- package/pipeline/scripts/test-gap-rules/java.json +20 -0
- package/pipeline/scripts/test-gap-rules/rust.json +14 -0
- package/pipeline/scripts/token-budget-report.mjs +3 -2
- package/pipeline/scripts/uninstall.mjs +29 -0
- package/pipeline/scripts/usage-access.mjs +16 -31
- package/pipeline/scripts/usage-health.mjs +31 -62
- package/pipeline/scripts/usage-register-beacon.mjs +11 -22
- package/pipeline/scripts/usage-register.mjs +39 -29
- package/pipeline/scripts/usage-report.mjs +579 -178
- package/pipeline/scripts/validate-code-graph.mjs +361 -111
- package/pipeline/scripts/write-state.mjs +39 -0
- package/pipeline/skills/.skill-manifest.json +22 -18
- package/pipeline/skills/.skills-index.json +13 -2
- package/pipeline/skills/shared/README.md +5 -4
- package/pipeline/skills/shared/core/multi-agent-design-check/SKILL.md +1 -1
- package/pipeline/skills/shared/core/multi-agent-diff-explain/SKILL.md +3 -3
- package/pipeline/skills/shared/core/multi-agent-fable-status/SKILL.md +1 -1
- package/pipeline/skills/shared/core/multi-agent-graph/SKILL.md +55 -21
- package/pipeline/skills/shared/core/multi-agent-pair/SKILL.md +41 -0
- package/pipeline/skills/shared/core/multi-agent-prune-prompts/SKILL.md +1 -1
- package/pipeline/skills/shared/core/multi-agent-sync/SKILL.md +3 -3
- package/pipeline/skills/shared/external/app-store-optimization/SKILL.md +2 -3
- package/pipeline/skills/shared/external/app-store-optimization/references/keyword-research-methodology.md +2 -2
- package/pipeline/skills/shared/external/app-store-optimization/references/product-page-variants.md +2 -2
- package/pipeline/skills/shared/external/app-store-review/SKILL.md +11 -4
- package/pipeline/skills/shared/external/build-settings-audit/SKILL.md +1 -1
- package/pipeline/skills/shared/external/build-time-benchmark/SKILL.md +5 -5
- package/pipeline/skills/shared/external/build-time-fixes/SKILL.md +5 -5
- package/pipeline/skills/shared/external/build-time-optimizer/SKILL.md +6 -6
- package/pipeline/skills/shared/external/free-llm-apis/references/providers.md +1 -0
- package/pipeline/skills/shared/external/ios-coding-standard/references/STANDARD.md +2 -2
- package/pipeline/skills/shared/external/ios-haptics/references/core-haptics.md +1 -1
- package/pipeline/skills/shared/external/localization-reuse-map/references/publish-and-snapshot.md +1 -1
- package/pipeline/skills/shared/external/package-build-audit/SKILL.md +3 -3
- package/pipeline/skills/shared/external/reverse-engineer-own-app/SKILL.md +2 -3
- package/pipeline/skills/shared/external/swift-compile-hotspots/SKILL.md +2 -2
- package/pipeline/skills/shared/external/weatherkit/SKILL.md +5 -6
- package/pipeline/skills/skills-index.md +3 -2
- package/docs/FIGMA_PIPELINE.md +0 -137
- package/pipeline/lib/identifier-scan.mjs +0 -156
- package/pipeline/scripts/publish-staged.mjs +0 -324
- package/pipeline/skills/shared/external/ios-coding-standard/scripts/check_structure.py +0 -765
|
@@ -22,6 +22,7 @@ import fs from "node:fs";
|
|
|
22
22
|
import os from "node:os";
|
|
23
23
|
import path from "node:path";
|
|
24
24
|
import { rowPhase } from "../lib/phase-schema.mjs";
|
|
25
|
+
import { readRotatedLines, rotatedExists } from "../lib/rotated-log.mjs";
|
|
25
26
|
import { exitOnHelp } from "../lib/cli-help.mjs";
|
|
26
27
|
import { parseArgs } from "../lib/args.mjs";
|
|
27
28
|
|
|
@@ -38,13 +39,13 @@ const PERIOD_DAYS = { daily: 1, weekly: 7, monthly: 30 };
|
|
|
38
39
|
const periodDays = PERIOD_DAYS[args.period] || 1;
|
|
39
40
|
const cutoffMs = Date.now() - periodDays * 24 * 3600 * 1000;
|
|
40
41
|
|
|
41
|
-
if (!
|
|
42
|
+
if (!rotatedExists(METRICS)) {
|
|
42
43
|
console.error(`metrics file not found: ${METRICS}`);
|
|
43
44
|
console.error("(no telemetry has been emitted yet - run a task first)");
|
|
44
45
|
process.exit(args.json ? 0 : 2);
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
const lines =
|
|
48
|
+
const lines = readRotatedLines(METRICS);
|
|
48
49
|
const events = lines
|
|
49
50
|
.map((l) => {
|
|
50
51
|
try {
|
|
@@ -450,6 +450,34 @@ function stopOffice() {
|
|
|
450
450
|
}
|
|
451
451
|
}
|
|
452
452
|
|
|
453
|
+
/**
|
|
454
|
+
* Stop the remote-control listener and forget its paired devices before the
|
|
455
|
+
* scripts it runs from are deleted. Works offline; nothing installed means
|
|
456
|
+
* nothing to stop.
|
|
457
|
+
*/
|
|
458
|
+
function stopRemote() {
|
|
459
|
+
const candidates = [
|
|
460
|
+
HOME && join(HOME, ".claude", "scripts", "pair.mjs"),
|
|
461
|
+
join(dirname(fileURLToPath(import.meta.url)), "pair.mjs"),
|
|
462
|
+
].filter(Boolean);
|
|
463
|
+
const script = candidates.find((p) => existsSync(p));
|
|
464
|
+
if (!script) return;
|
|
465
|
+
if (dryRun) {
|
|
466
|
+
report("would run", "pair.mjs --off (stop the remote-control listener)");
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
try {
|
|
470
|
+
execFileSync(process.execPath, [script, "--off"], {
|
|
471
|
+
stdio: "ignore",
|
|
472
|
+
timeout: 20_000,
|
|
473
|
+
env: { ...process.env, HOME: HOME || process.env.HOME },
|
|
474
|
+
});
|
|
475
|
+
console.log(" stopped: remote-control listener");
|
|
476
|
+
} catch {
|
|
477
|
+
console.log(" note: pair.mjs --off failed; stop it with /multi-agent:pair --off");
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
453
481
|
/**
|
|
454
482
|
* --all-data only. Deleted through the credential store so the value is never
|
|
455
483
|
* read; its output is discarded.
|
|
@@ -1138,6 +1166,7 @@ export async function main() {
|
|
|
1138
1166
|
console.log("");
|
|
1139
1167
|
console.log(" [Office]");
|
|
1140
1168
|
stopOffice();
|
|
1169
|
+
stopRemote();
|
|
1141
1170
|
if (!dryRun && HOME) {
|
|
1142
1171
|
const warning = legacyWarning(retireOfficeRemote({ ...process.env, HOME }));
|
|
1143
1172
|
if (warning) console.log(` note: ${warning}`);
|
|
@@ -27,8 +27,7 @@
|
|
|
27
27
|
*
|
|
28
28
|
* It fails open: a network error, a timeout, a non-200 answer or a body that
|
|
29
29
|
* is not the shape above (an unknown reason included) all allow the run. The
|
|
30
|
-
* request has one ACCESS_TIMEOUT_MS deadline (postWithin)
|
|
31
|
-
* whole seconds, so it ends within one second more at most. A `blocked`
|
|
30
|
+
* request has one ACCESS_TIMEOUT_MS deadline (postWithin). A `blocked`
|
|
32
31
|
* answer is remembered in ~/.claude/logs/multi-agent/access-state.json (mode
|
|
33
32
|
* 0600: the login, when it was blocked and the owner's message, never a
|
|
34
33
|
* token) and honoured for BLOCK_TTL_MS, for that login only, while the site
|
|
@@ -55,13 +54,14 @@ import { mkdirSync, readFileSync } from "node:fs";
|
|
|
55
54
|
import { homedir } from "node:os";
|
|
56
55
|
import { join } from "node:path";
|
|
57
56
|
|
|
58
|
-
import {
|
|
57
|
+
import { postJson } from "./_http-post.mjs";
|
|
59
58
|
import { pipelineVersion } from "./usage-register-beacon.mjs";
|
|
60
59
|
import { LOGIN_RE } from "./usage-identity.mjs";
|
|
61
60
|
import { DEFAULT_ENDPOINT, canonicalEndpoint, registerUrlAllowed } from "../lib/usage-endpoint.mjs";
|
|
62
61
|
import { prefsPath as prefsPathOf } from "../lib/prefs-value.mjs";
|
|
63
62
|
import { resolveUsageToken } from "../lib/usage-token.mjs";
|
|
64
63
|
import { exitOnHelp } from "../lib/cli-help.mjs";
|
|
64
|
+
import { versionOrUnknown } from "../lib/usage-vocab.mjs";
|
|
65
65
|
import { invokedDirectly } from "../lib/invoked-directly.mjs";
|
|
66
66
|
import { lockTimeoutFrom, updateJsonFileSync } from "../lib/json-file-lock.mjs";
|
|
67
67
|
|
|
@@ -163,6 +163,11 @@ export function deniedLine({ reason, message = null, url = null, invitation = nu
|
|
|
163
163
|
return reason === "blocked" && message ? `${base} ${message}` : base;
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
+
/** The exact body the access check sends: the login (or null) and the release version (or `unknown`). */
|
|
167
|
+
export function accessBody(login, home) {
|
|
168
|
+
return { login: login ?? null, v: versionOrUnknown(pipelineVersion(home)) };
|
|
169
|
+
}
|
|
170
|
+
|
|
166
171
|
/** The login the request names: pinned, then declared, then the cached identity. */
|
|
167
172
|
function loginOf(usageLog) {
|
|
168
173
|
for (const v of [usageLog?.registeredAs, usageLog?.declaredLogin, usageLog?.login]) {
|
|
@@ -199,32 +204,13 @@ function underTest(env) {
|
|
|
199
204
|
return Boolean(env.NODE_TEST_CONTEXT || env.MULTI_AGENT_SMOKE);
|
|
200
205
|
}
|
|
201
206
|
|
|
202
|
-
/** Below this many milliseconds left, the curl fallback is not started. */
|
|
203
|
-
const MIN_CURL_MS = 250;
|
|
204
|
-
|
|
205
207
|
/**
|
|
206
|
-
* postJson under one deadline
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
* does not answer costs the run `timeoutMs`, not a fetch timeout plus a curl
|
|
210
|
-
* timeout.
|
|
208
|
+
* postJson under the request's one deadline: a site that does not answer costs
|
|
209
|
+
* the run `timeoutMs` and nothing more, since there is no second client to
|
|
210
|
+
* retry through.
|
|
211
211
|
*/
|
|
212
|
-
export
|
|
213
|
-
{ url, headers, body, timeoutMs }
|
|
214
|
-
{ fetchImpl = fetch, curl = curlPost } = {},
|
|
215
|
-
) {
|
|
216
|
-
const deadline = Date.now() + timeoutMs;
|
|
217
|
-
return postJson({
|
|
218
|
-
url,
|
|
219
|
-
headers,
|
|
220
|
-
body,
|
|
221
|
-
timeoutMs,
|
|
222
|
-
fetchImpl,
|
|
223
|
-
curl: (opts) => {
|
|
224
|
-
const left = deadline - Date.now();
|
|
225
|
-
return left < MIN_CURL_MS ? { failure: "timeout" } : curl({ ...opts, timeoutMs: left });
|
|
226
|
-
},
|
|
227
|
-
});
|
|
212
|
+
export function postWithin({ url, headers, body, timeoutMs }, { send } = {}) {
|
|
213
|
+
return postJson({ url, headers, body, timeoutMs, ...(send ? { send } : {}) });
|
|
228
214
|
}
|
|
229
215
|
|
|
230
216
|
/**
|
|
@@ -235,9 +221,8 @@ export async function postWithin(
|
|
|
235
221
|
export async function checkRunAccess({
|
|
236
222
|
home = homedir(),
|
|
237
223
|
env = process.env,
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
post = (opts) => postWithin(opts, { fetchImpl, curl }),
|
|
224
|
+
send,
|
|
225
|
+
post = (opts) => postWithin(opts, { send }),
|
|
241
226
|
now = Date.now(),
|
|
242
227
|
timeoutMs = ACCESS_TIMEOUT_MS,
|
|
243
228
|
} = {}) {
|
|
@@ -289,7 +274,7 @@ export async function checkRunAccess({
|
|
|
289
274
|
r = await post({
|
|
290
275
|
url,
|
|
291
276
|
headers: token ? { "X-Usage-Token": token } : {},
|
|
292
|
-
body: JSON.stringify(
|
|
277
|
+
body: JSON.stringify(accessBody(login, home)),
|
|
293
278
|
timeoutMs,
|
|
294
279
|
});
|
|
295
280
|
} catch {
|
|
@@ -26,12 +26,16 @@
|
|
|
26
26
|
* { generatedAt, overall: "green"|"yellow"|"red",
|
|
27
27
|
* items: [{ id, status, reason }] } at most MAX_ITEMS, ids from SECTION_IDS
|
|
28
28
|
*
|
|
29
|
-
* A reason is the section's message
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* becomes `
|
|
33
|
-
*
|
|
34
|
-
*
|
|
29
|
+
* A reason is not text. It is the id of the section's message in
|
|
30
|
+
* health-messages.mjs (`errors.recurring`, `services.refused`), and only an id
|
|
31
|
+
* from that catalogue's section families (HEALTH_REASONS) is kept; anything
|
|
32
|
+
* else becomes `other`. The parameters of the message (names of services,
|
|
33
|
+
* hosts, branches, counts) never leave the machine, whatever shape they have,
|
|
34
|
+
* because no part of the sentence is sent. The panel renders the id in its own
|
|
35
|
+
* language. The cache is re-validated through the same list when it is read, so
|
|
36
|
+
* a hand-edited file cannot smuggle anything past it. --probe is never used: no
|
|
37
|
+
* network.
|
|
38
|
+
*
|
|
35
39
|
*
|
|
36
40
|
* Env: MULTI_AGENT_USAGE_HEALTH=cache uses the cache and never starts a
|
|
37
41
|
* refresher; MULTI_AGENT_USAGE_HEALTH=off leaves the field out entirely.
|
|
@@ -50,9 +54,9 @@ import { dirname, join } from "node:path";
|
|
|
50
54
|
import { fileURLToPath } from "node:url";
|
|
51
55
|
|
|
52
56
|
import { exitOnHelp } from "../lib/cli-help.mjs";
|
|
53
|
-
import {
|
|
57
|
+
import { HEALTH_MESSAGES } from "../lib/health-messages.mjs";
|
|
54
58
|
import { invokedDirectly } from "../lib/invoked-directly.mjs";
|
|
55
|
-
import {
|
|
59
|
+
import { isoTimestamp } from "../lib/usage-vocab.mjs";
|
|
56
60
|
|
|
57
61
|
exitOnHelp(import.meta.url);
|
|
58
62
|
|
|
@@ -62,7 +66,6 @@ export const WAIT_MS = 5000;
|
|
|
62
66
|
export const LOCK_STALE_MS = 3 * 60 * 1000;
|
|
63
67
|
export const REFRESH_LIMIT_MS = 150_000;
|
|
64
68
|
export const MAX_ITEMS = 30;
|
|
65
|
-
export const MAX_REASON = 200;
|
|
66
69
|
export const HEALTH_IDS = [
|
|
67
70
|
"services",
|
|
68
71
|
"toolkit",
|
|
@@ -75,6 +78,17 @@ export const HEALTH_IDS = [
|
|
|
75
78
|
"errors",
|
|
76
79
|
];
|
|
77
80
|
const STATUSES = ["green", "yellow", "red"];
|
|
81
|
+
|
|
82
|
+
const FAMILIES = [...HEALTH_IDS.map((id) => `${id}.`), "section."];
|
|
83
|
+
/** The message ids a health item's reason may be: the catalogue's section families. */
|
|
84
|
+
export const HEALTH_REASONS = Object.freeze(
|
|
85
|
+
Object.keys(HEALTH_MESSAGES.en).filter((id) => FAMILIES.some((f) => id.startsWith(f))),
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
/** A reason id from the catalogue, else `other`. */
|
|
89
|
+
export function reasonId(value) {
|
|
90
|
+
return typeof value === "string" && HEALTH_REASONS.includes(value) ? value : "other";
|
|
91
|
+
}
|
|
78
92
|
const POLL_MS = 200;
|
|
79
93
|
const SELF = fileURLToPath(import.meta.url);
|
|
80
94
|
|
|
@@ -83,60 +97,16 @@ export function healthFile(home = homedir()) {
|
|
|
83
97
|
return join(home, ".claude", "logs", "multi-agent", HEALTH_FILE);
|
|
84
98
|
}
|
|
85
99
|
|
|
86
|
-
// The shared credential list first, then looser shapes: a known prefix with a
|
|
87
|
-
// short tail, an email address, and a long run mixing letters and digits.
|
|
88
|
-
const TOKEN_SHAPES = [
|
|
89
|
-
...SECRET_PATTERNS.map((p) => new RegExp(p.re.source, p.re.flags)),
|
|
90
|
-
/\b(?:gh[pousr]_|github_pat_|glpat-|figu_|figd_|xox[abprs]-|npm_|sk-|AKIA)[A-Za-z0-9_-]{6,}/g,
|
|
91
|
-
/\b[A-Za-z0-9._%+-]{1,64}@[A-Za-z0-9.-]{1,255}\.[A-Za-z]{2,63}\b/g,
|
|
92
|
-
/\b(?=[A-Za-z0-9_+=-]*\d)(?=[A-Za-z0-9_+=-]*[A-Za-z])[A-Za-z0-9_+=-]{32,}/g,
|
|
93
|
-
];
|
|
94
|
-
const ABSOLUTE_PATH = /(^|[\s(=:'"`,[])(\/[^\s'"`,)\]]+|[A-Za-z]:\\[^\s'"`,)\]]*)/g;
|
|
95
|
-
|
|
96
|
-
// The home directory only as a whole path component: followed by "/", the
|
|
97
|
-
// end, or a character that cannot continue a directory name. `/Users/ann2`
|
|
98
|
-
// is not under `/Users/ann`, so it is left to the absolute-path rule.
|
|
99
|
-
const homePattern = (home) =>
|
|
100
|
-
new RegExp(
|
|
101
|
-
`${home.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?=/|$|[^A-Za-z0-9._-]|\\.(?![A-Za-z0-9_-]))`,
|
|
102
|
-
"g",
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* One plain line safe to leave the machine, at most MAX_REASON characters.
|
|
107
|
-
*
|
|
108
|
-
* @param {unknown} text
|
|
109
|
-
* @param {string} [home]
|
|
110
|
-
* @returns {string}
|
|
111
|
-
*/
|
|
112
|
-
export function scrubReason(text, home = homedir()) {
|
|
113
|
-
let s = String(text ?? "")
|
|
114
|
-
.replace(/\p{Cc}+/gu, " ")
|
|
115
|
-
.replace(/\s+/g, " ")
|
|
116
|
-
.trim();
|
|
117
|
-
if (home && home.length > 1) s = s.replace(homePattern(home), "~");
|
|
118
|
-
for (const shape of TOKEN_SHAPES) s = s.replace(shape, "[redacted]");
|
|
119
|
-
s = s.replace(ABSOLUTE_PATH, (_, lead) => `${lead}[path]`);
|
|
120
|
-
if (s.length > MAX_REASON) s = `${s.slice(0, MAX_REASON - 3).trimEnd()}...`;
|
|
121
|
-
return s;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
100
|
const RANK = { green: 0, yellow: 1, red: 2 };
|
|
125
101
|
const worst = (items) => items.reduce((w, i) => (RANK[i.status] > RANK[w] ? i.status : w), "green");
|
|
126
102
|
|
|
127
|
-
function validDate(value) {
|
|
128
|
-
if (typeof value !== "string") return null;
|
|
129
|
-
const t = Date.parse(value);
|
|
130
|
-
return Number.isNaN(t) ? null : new Date(t).toISOString();
|
|
131
|
-
}
|
|
132
|
-
|
|
133
103
|
/**
|
|
134
104
|
* Brings anything shaped like a summary to the contract: known ids only, once
|
|
135
|
-
* each, a valid status, a
|
|
105
|
+
* each, a valid status, a reason id from HEALTH_REASONS. Null when nothing usable is left.
|
|
136
106
|
*/
|
|
137
|
-
export function normalizeSummary(raw,
|
|
107
|
+
export function normalizeSummary(raw, _opts = {}) {
|
|
138
108
|
if (!raw || typeof raw !== "object" || !Array.isArray(raw.items)) return null;
|
|
139
|
-
const generatedAt =
|
|
109
|
+
const generatedAt = isoTimestamp(raw.generatedAt);
|
|
140
110
|
if (!generatedAt) return null;
|
|
141
111
|
const seen = new Set();
|
|
142
112
|
const items = [];
|
|
@@ -145,7 +115,7 @@ export function normalizeSummary(raw, { home = homedir() } = {}) {
|
|
|
145
115
|
if (!it || typeof it !== "object") continue;
|
|
146
116
|
if (!HEALTH_IDS.includes(it.id) || seen.has(it.id) || !STATUSES.includes(it.status)) continue;
|
|
147
117
|
seen.add(it.id);
|
|
148
|
-
items.push({ id: it.id, status: it.status, reason:
|
|
118
|
+
items.push({ id: it.id, status: it.status, reason: reasonId(it.reason) });
|
|
149
119
|
}
|
|
150
120
|
if (items.length === 0) return null;
|
|
151
121
|
const overall = STATUSES.includes(raw.overall) ? raw.overall : worst(items);
|
|
@@ -154,17 +124,16 @@ export function normalizeSummary(raw, { home = homedir() } = {}) {
|
|
|
154
124
|
|
|
155
125
|
/**
|
|
156
126
|
* health-report's document mapped to the contract: one item per section, the
|
|
157
|
-
* reason
|
|
158
|
-
* when it carries no message).
|
|
127
|
+
* reason being the id of the section's message (`other` when it carries none).
|
|
159
128
|
*/
|
|
160
|
-
export function summaryFromReport(doc,
|
|
129
|
+
export function summaryFromReport(doc, _opts = {}) {
|
|
161
130
|
if (!doc || typeof doc !== "object" || !Array.isArray(doc.sections)) return null;
|
|
162
131
|
const items = doc.sections.map((s) => ({
|
|
163
132
|
id: s?.id,
|
|
164
133
|
status: s?.status,
|
|
165
|
-
reason: s?.message
|
|
134
|
+
reason: s?.message?.id,
|
|
166
135
|
}));
|
|
167
|
-
return normalizeSummary({ generatedAt: doc.generatedAt, overall: doc.status, items }
|
|
136
|
+
return normalizeSummary({ generatedAt: doc.generatedAt, overall: doc.status, items });
|
|
168
137
|
}
|
|
169
138
|
|
|
170
139
|
/**
|
|
@@ -26,6 +26,7 @@ import { join } from "node:path";
|
|
|
26
26
|
import { pathToFileURL } from "node:url";
|
|
27
27
|
import { postJson } from "./_http-post.mjs";
|
|
28
28
|
import { exitOnHelp } from "../lib/cli-help.mjs";
|
|
29
|
+
import { releaseVersion, versionOrUnknown } from "../lib/usage-vocab.mjs";
|
|
29
30
|
|
|
30
31
|
exitOnHelp(import.meta.url);
|
|
31
32
|
|
|
@@ -52,29 +53,18 @@ export const REASONS = Object.freeze([
|
|
|
52
53
|
]);
|
|
53
54
|
|
|
54
55
|
const LOGIN_RE = /^[A-Za-z0-9][A-Za-z0-9_-]{0,38}$/;
|
|
55
|
-
const VERSION_RE = /^v?\d{1,5}\.\d{1,5}\.\d{1,5}(-[0-9A-Za-z.-]{1,24})?$/;
|
|
56
56
|
|
|
57
|
-
const
|
|
57
|
+
const TLS_FAILURE =
|
|
58
58
|
/CERT|SELF_SIGNED|UNABLE_TO_GET_ISSUER|UNABLE_TO_VERIFY|DEPTH_ZERO|ERR_TLS|ERR_SSL|EPROTO/;
|
|
59
|
-
const TLS_CURL = new Set([35, 51, 53, 54, 58, 59, 60, 64, 66, 77, 80, 82, 83, 90, 91]);
|
|
60
|
-
const PROXY_CURL = new Set([5, 56, 97]);
|
|
61
|
-
|
|
62
|
-
function curlExit(failure) {
|
|
63
|
-
const m = /^curl-exit-(\d+)$/.exec(String(failure ?? ""));
|
|
64
|
-
return m ? Number(m[1]) : null;
|
|
65
|
-
}
|
|
66
59
|
|
|
67
60
|
/**
|
|
68
|
-
* The reason for a request that reached no HTTP answer, from the
|
|
69
|
-
*
|
|
70
|
-
*
|
|
61
|
+
* The reason for a request that reached no HTTP answer, from the failure code
|
|
62
|
+
* _http-post.mjs reports (the socket's or the certificate check's own code, or
|
|
63
|
+
* `timeout`).
|
|
71
64
|
*/
|
|
72
|
-
export function transportReason(
|
|
73
|
-
|
|
74
|
-
if (
|
|
75
|
-
if (exit !== null && TLS_CURL.has(exit)) return "tls-untrusted";
|
|
76
|
-
if (exit === 28 || fetchFailure === "timeout") return "timeout";
|
|
77
|
-
if (TLS_FETCH.test(String(fetchFailure ?? ""))) return "tls-untrusted";
|
|
65
|
+
export function transportReason(failure) {
|
|
66
|
+
if (failure === "timeout") return "timeout";
|
|
67
|
+
if (TLS_FAILURE.test(String(failure ?? ""))) return "tls-untrusted";
|
|
78
68
|
return "endpoint-unreachable";
|
|
79
69
|
}
|
|
80
70
|
|
|
@@ -102,7 +92,7 @@ export function pipelineVersion(home = homedir()) {
|
|
|
102
92
|
for (const root of [".claude", ".copilot", ".codex"]) {
|
|
103
93
|
try {
|
|
104
94
|
const v = readFileSync(join(home, root, ".pipeline-version"), "utf8").trim();
|
|
105
|
-
if (
|
|
95
|
+
if (releaseVersion(v)) return v;
|
|
106
96
|
} catch {
|
|
107
97
|
/* no stamp for this host */
|
|
108
98
|
}
|
|
@@ -111,7 +101,7 @@ export function pipelineVersion(home = homedir()) {
|
|
|
111
101
|
const v = JSON.parse(
|
|
112
102
|
readFileSync(join(import.meta.dirname, "..", "..", "package.json"), "utf8"),
|
|
113
103
|
).version;
|
|
114
|
-
if (
|
|
104
|
+
if (releaseVersion(v)) return v;
|
|
115
105
|
} catch {
|
|
116
106
|
/* not inside a package */
|
|
117
107
|
}
|
|
@@ -121,9 +111,8 @@ export function pipelineVersion(home = homedir()) {
|
|
|
121
111
|
/** The exact body sent, or null when any field would be refused. */
|
|
122
112
|
export function beaconBody({ login, version, reason, os = process.platform }) {
|
|
123
113
|
if (typeof login !== "string" || !LOGIN_RE.test(login)) return null;
|
|
124
|
-
if (typeof version !== "string" || !VERSION_RE.test(version)) return null;
|
|
125
114
|
if (!REASONS.includes(reason)) return null;
|
|
126
|
-
const body = { u: login, v: version
|
|
115
|
+
const body = { u: login, v: versionOrUnknown(version), reason };
|
|
127
116
|
if (os === "darwin") body.os = os;
|
|
128
117
|
return body;
|
|
129
118
|
}
|
|
@@ -102,7 +102,7 @@ import { spawn, spawnSync } from "node:child_process";
|
|
|
102
102
|
import { randomBytes } from "node:crypto";
|
|
103
103
|
import { join } from "node:path";
|
|
104
104
|
import { homedir, hostname, tmpdir } from "node:os";
|
|
105
|
-
import { pathToFileURL } from "node:url";
|
|
105
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
106
106
|
import { hostCommand } from "../lib/user-facing.mjs";
|
|
107
107
|
import { DEFAULT_ENDPOINT, canonicalEndpoint, registerUrlAllowed } from "../lib/usage-endpoint.mjs";
|
|
108
108
|
import {
|
|
@@ -126,6 +126,9 @@ import {
|
|
|
126
126
|
import { PREFS_ENV, prefsFileIn } from "../lib/prefs-value.mjs";
|
|
127
127
|
import { credentialStores } from "../lib/usage-token.mjs";
|
|
128
128
|
import { exitOnHelp } from "../lib/cli-help.mjs";
|
|
129
|
+
import { hostDigest, loadRunKey } from "../lib/usage-run-key.mjs";
|
|
130
|
+
import { versionOrUnknown } from "../lib/usage-vocab.mjs";
|
|
131
|
+
import { detachSelf, shouldDetach } from "../lib/detach-self.mjs";
|
|
129
132
|
import { parseArgs } from "../lib/args.mjs";
|
|
130
133
|
import { isUnattended } from "../lib/unattended.mjs";
|
|
131
134
|
|
|
@@ -248,22 +251,19 @@ function storedToken(prefs, stores) {
|
|
|
248
251
|
*/
|
|
249
252
|
export { registerUrlAllowed };
|
|
250
253
|
|
|
251
|
-
// Transport goes through _http-post.mjs,
|
|
252
|
-
//
|
|
253
|
-
//
|
|
254
|
+
// Transport goes through _http-post.mjs (node:https, certificates always
|
|
255
|
+
// verified, no second client). The failure text keeps the cause so a blocked
|
|
256
|
+
// corporate network is diagnosable.
|
|
254
257
|
async function postJson(url, body, bearer = null, extra = {}) {
|
|
255
258
|
const headers = { ...extra, ...(bearer ? { Authorization: `Bearer ${bearer}` } : {}) };
|
|
256
259
|
const r = await postHttp({ url, headers, body: JSON.stringify(body), timeoutMs: TIMEOUT_MS });
|
|
257
260
|
if (r.failure) {
|
|
258
|
-
const
|
|
259
|
-
.filter(Boolean)
|
|
260
|
-
.join(", ");
|
|
261
|
-
const what = r.fetchFailure === "timeout" ? "endpoint timed out" : "endpoint unreachable";
|
|
261
|
+
const what = r.failure === "timeout" ? "endpoint timed out" : "endpoint unreachable";
|
|
262
262
|
return {
|
|
263
263
|
res: null,
|
|
264
264
|
json: null,
|
|
265
|
-
failure: `${what} (${
|
|
266
|
-
reason: transportReason(r.
|
|
265
|
+
failure: `${what} (${r.failure})`,
|
|
266
|
+
reason: transportReason(r.failure),
|
|
267
267
|
};
|
|
268
268
|
}
|
|
269
269
|
if (r.status >= 300 && r.status < 400) {
|
|
@@ -414,11 +414,6 @@ export async function checkStoredTokenDetailed(
|
|
|
414
414
|
return { verdict: "unknown", account: null };
|
|
415
415
|
}
|
|
416
416
|
|
|
417
|
-
/** The verdict alone; see checkStoredTokenDetailed. */
|
|
418
|
-
export async function checkStoredToken(url, token, post = postHttp) {
|
|
419
|
-
return (await checkStoredTokenDetailed(url, token, post)).verdict;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
417
|
async function requestToken(url, body, proof, method, extra = {}) {
|
|
423
418
|
const { res, json, failure, reason } = await postJson(url, body, proof, extra);
|
|
424
419
|
if (failure) return { token: null, why: failure, reason };
|
|
@@ -603,7 +598,14 @@ const CLAIM_RETRY_MS = 24 * 3600 * 1000;
|
|
|
603
598
|
* random suffix kept in prefs (`usageLog.claimNonce`). The server replaces a login's token for the same
|
|
604
599
|
* label, so a label nobody else can guess keeps a stranger from replacing it.
|
|
605
600
|
*/
|
|
606
|
-
function
|
|
601
|
+
export function registrationContext(home) {
|
|
602
|
+
return {
|
|
603
|
+
v: versionOrUnknown(pipelineVersion(home)),
|
|
604
|
+
...(["darwin", "linux"].includes(process.platform) ? { os: process.platform } : {}),
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
export function claimLabel(prefsPath, usageLog, host) {
|
|
607
609
|
let nonce = usageLog?.claimNonce;
|
|
608
610
|
if (typeof nonce !== "string" || !/^[0-9a-f]{8,32}$/.test(nonce)) {
|
|
609
611
|
nonce = randomBytes(6).toString("hex");
|
|
@@ -914,7 +916,7 @@ export async function register(argv, { ingestRejected = false } = {}) {
|
|
|
914
916
|
login: null,
|
|
915
917
|
};
|
|
916
918
|
parseArgs(argv, {
|
|
917
|
-
booleans: ["quiet", "json", "dry-run", "feedback", "refresh", "status-line"],
|
|
919
|
+
booleans: ["quiet", "json", "dry-run", "feedback", "refresh", "status-line", "detach"],
|
|
918
920
|
values: ["prefs", "login"],
|
|
919
921
|
unknown: "positional",
|
|
920
922
|
equals: false,
|
|
@@ -1101,9 +1103,12 @@ export async function register(argv, { ingestRejected = false } = {}) {
|
|
|
1101
1103
|
});
|
|
1102
1104
|
if (!decision.act) {
|
|
1103
1105
|
const repairable = ["token in environment", "token in prefs", "token already onboarded"];
|
|
1104
|
-
|
|
1106
|
+
const optedOut = current.global?.usageLog?.optOut === true;
|
|
1107
|
+
if (repairable.includes(decision.reason) && !optedOut) {
|
|
1105
1108
|
// Already has a token: make sure the switch is actually on. A token with
|
|
1106
|
-
// enabled:false is the other half of the same silence.
|
|
1109
|
+
// enabled:false is the other half of the same silence. An opted-out
|
|
1110
|
+
// machine keeps it off: a feedback run reaches this point for the token
|
|
1111
|
+
// alone, and optOut covers passive collection.
|
|
1107
1112
|
if (current.global?.usageLog?.enabled !== true && !opts.dryRun) {
|
|
1108
1113
|
const name = current.global?.keychainMapping?.usage_ingest || null;
|
|
1109
1114
|
if (persistPrefs(prefsPath, name)) {
|
|
@@ -1118,7 +1123,8 @@ export async function register(argv, { ingestRejected = false } = {}) {
|
|
|
1118
1123
|
}
|
|
1119
1124
|
if (
|
|
1120
1125
|
decision.reason === "token already onboarded" &&
|
|
1121
|
-
current.global?.usageLog?.enabled === true
|
|
1126
|
+
current.global?.usageLog?.enabled === true &&
|
|
1127
|
+
!optedOut
|
|
1122
1128
|
) {
|
|
1123
1129
|
sendInstalledVersion(prefsPath);
|
|
1124
1130
|
}
|
|
@@ -1129,9 +1135,12 @@ export async function register(argv, { ingestRejected = false } = {}) {
|
|
|
1129
1135
|
|
|
1130
1136
|
const url = registerUrl(current.global?.usageLog?.endpoint);
|
|
1131
1137
|
const user = who.login;
|
|
1138
|
+
// The panel needs to tell this machine from another, not to know its name:
|
|
1139
|
+
// the label is a digest of the short host name, keyed with the install's
|
|
1140
|
+
// secret. Without the secret it is the constant `unknown`.
|
|
1132
1141
|
let host = "unknown";
|
|
1133
1142
|
try {
|
|
1134
|
-
host = hostname().split(".")[0] || "unknown";
|
|
1143
|
+
host = hostDigest(hostname().split(".")[0] || "unknown", loadRunKey()) ?? "unknown";
|
|
1135
1144
|
} catch {
|
|
1136
1145
|
/* a nameless host is still a host */
|
|
1137
1146
|
}
|
|
@@ -1150,11 +1159,7 @@ export async function register(argv, { ingestRejected = false } = {}) {
|
|
|
1150
1159
|
|
|
1151
1160
|
// The version and platform go with the request so a failure the site
|
|
1152
1161
|
// answers itself is recorded with them.
|
|
1153
|
-
const
|
|
1154
|
-
const context = {
|
|
1155
|
-
...(version ? { v: version } : {}),
|
|
1156
|
-
...(["darwin", "linux"].includes(process.platform) ? { os: process.platform } : {}),
|
|
1157
|
-
};
|
|
1162
|
+
const context = registrationContext(HOME);
|
|
1158
1163
|
let result;
|
|
1159
1164
|
if (who.method === "claim") {
|
|
1160
1165
|
const failedAt = Date.parse(current.global?.usageLog?.claimFailedAt ?? "");
|
|
@@ -1257,7 +1262,12 @@ function isEntrypoint() {
|
|
|
1257
1262
|
}
|
|
1258
1263
|
|
|
1259
1264
|
if (isEntrypoint()) {
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1265
|
+
const argv = process.argv.slice(2);
|
|
1266
|
+
if (!argv.includes("--dry-run") && shouldDetach(argv)) {
|
|
1267
|
+
detachSelf(fileURLToPath(import.meta.url), argv);
|
|
1268
|
+
} else {
|
|
1269
|
+
register(argv).then(() => {
|
|
1270
|
+
process.exitCode = 0;
|
|
1271
|
+
});
|
|
1272
|
+
}
|
|
1263
1273
|
}
|