@indigoai-us/hq-cli 5.345.241 → 5.345.242
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 +49 -0
- package/assets/scaffold/core/scripts/hq-delegate-grant.sh +170 -8
- package/assets/scaffold/core/scripts/hq-delegate-publish.sh +21 -1
- package/assets/scaffold/core/scripts/lib/delegate-engine.sh +77 -0
- package/dist/command-catalog.generated.d.ts +28 -8
- package/dist/command-catalog.generated.js +33 -8
- package/dist/commands/cloud-off-gate.d.ts +7 -7
- package/dist/commands/cloud-off-gate.js +26 -38
- package/dist/commands/core-delegate-w1b.js +307 -26
- package/dist/commands/core-delegate.js +2 -0
- package/dist/commands/core-handoff.js +1 -1
- package/dist/commands/core-job-model-auth.d.ts +95 -0
- package/dist/commands/core-job-model-auth.js +247 -0
- package/dist/commands/core-job-run-native.js +280 -12
- package/dist/commands/core.js +1 -0
- package/dist/commands/files-browse.js +2 -0
- package/dist/commands/files.js +4 -0
- package/dist/commands/integrations-core.d.ts +11 -0
- package/dist/commands/integrations-core.js +15 -1
- package/dist/commands/lanes-link.js +2 -2
- package/dist/commands/lanes-loop.d.ts +2 -2
- package/dist/commands/lanes-loop.js +5 -5
- package/dist/commands/lanes-questions.js +1 -1
- package/dist/commands/lanes-stories.js +1 -1
- package/dist/commands/lanes.js +80 -14
- package/dist/commands/rescue.d.ts +3 -2
- package/dist/commands/rescue.js +48 -34
- package/dist/commands/search.d.ts +6 -0
- package/dist/commands/search.js +24 -4
- package/dist/commands/sources.js +6 -2
- package/dist/commands/sync-core.d.ts +8 -0
- package/dist/commands/sync-core.js +43 -0
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +1737 -1450
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/lib/capacity/accounts.d.ts +1 -1
- package/dist/lib/capacity/accounts.js +1 -1
- package/dist/lib/capacity/freshness.d.ts +1 -1
- package/dist/lib/capacity/freshness.js +1 -1
- package/dist/lib/capacity/route.js +1 -1
- package/dist/lib/daemon/catalog.d.ts +3 -0
- package/dist/lib/daemon/hook-requests.d.ts +1 -1
- package/dist/lib/daemon/hook-requests.js +4 -2
- package/dist/lib/daemon/run.js +16 -22
- package/dist/lib/environment/work-requirements.d.ts +1 -1
- package/dist/lib/environment/work-requirements.js +1 -1
- package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
- package/dist/lib/flag-registry-worker-source.generated.js +1 -1
- package/dist/lib/hook-engine/coverage.js +11 -3
- package/dist/lib/hook-engine/git-stop-config.json +510 -510
- package/dist/lib/hook-engine/native-precompact-compatibility.json +443 -443
- package/dist/lib/hook-engine/native-stop-compatibility.json +359 -359
- package/dist/lib/hot-channels/adapters/meetings.d.ts +1 -16
- package/dist/lib/hot-channels/adapters/meetings.js +3 -28
- package/dist/lib/hot-channels/adapters/slack.d.ts +3 -1
- package/dist/lib/hot-channels/adapters/slack.js +4 -1
- package/dist/lib/hot-channels/contract.d.ts +14 -0
- package/dist/lib/hot-channels/fleet-complete.d.ts +18 -2
- package/dist/lib/hot-channels/fleet-complete.js +29 -4
- package/dist/lib/hot-channels/meeting-source-ref.d.ts +17 -0
- package/dist/lib/hot-channels/meeting-source-ref.js +32 -0
- package/dist/lib/hot-channels/prompts/signals-pass.md +6 -1
- package/dist/lib/hot-channels/run.d.ts +10 -0
- package/dist/lib/hot-channels/run.js +34 -0
- package/dist/lib/hot-channels/signals-pass.d.ts +27 -0
- package/dist/lib/hot-channels/signals-pass.js +57 -2
- package/dist/lib/hot-channels/signals-runtime.js +3 -2
- package/dist/lib/lanes/accounts.js +2 -2
- package/dist/lib/lanes/claude-balance.d.ts +6 -0
- package/dist/lib/lanes/claude-balance.js +124 -0
- package/dist/lib/lanes/grants.js +15 -2
- package/dist/lib/lanes/hq-root.d.ts +1 -1
- package/dist/lib/lanes/hq-root.js +1 -1
- package/dist/lib/lanes/links.d.ts +1 -1
- package/dist/lib/lanes/liveness.d.ts +3 -0
- package/dist/lib/lanes/liveness.js +61 -7
- package/dist/lib/lanes/models.d.ts +1 -1
- package/dist/lib/lanes/models.js +1 -1
- package/dist/lib/lanes/questions.d.ts +1 -1
- package/dist/lib/lanes/questions.js +2 -2
- package/dist/lib/lanes/spawn.js +4 -6
- package/dist/lib/lanes/store.d.ts +13 -2
- package/dist/lib/lanes/store.js +13 -5
- package/dist/lib/lanes/types.d.ts +7 -7
- package/dist/lib/lanes/types.js +1 -1
- package/dist/lib/lanes/watcher-main.js +1 -1
- package/dist/lib/lanes/watcher.d.ts +1 -1
- package/dist/lib/lanes/watcher.js +1 -1
- package/dist/lib/onboarding/cli/onboard.js +5 -0
- package/dist/lib/signals/sanitize.d.ts +19 -0
- package/dist/lib/signals/sanitize.js +103 -7
- package/dist/lib/signals/steps/upload.d.ts +40 -1
- package/dist/lib/signals/steps/upload.js +122 -6
- package/dist/lib/sync-core/access-refresh.d.ts +29 -0
- package/dist/lib/sync-core/access-refresh.js +97 -0
- package/dist/lib/sync-core/company-adoption.d.ts +33 -0
- package/dist/lib/sync-core/company-adoption.js +223 -0
- package/dist/lib/sync-core/engine-home.d.ts +1 -0
- package/dist/lib/sync-core/engine-owned.d.ts +13 -0
- package/dist/lib/sync-core/engine-owned.js +38 -0
- package/dist/lib/sync-core/hand-back.d.ts +17 -0
- package/dist/lib/sync-core/hand-back.js +23 -0
- package/dist/lib/sync-core/post-apply-reindex.d.ts +33 -0
- package/dist/lib/sync-core/post-apply-reindex.js +149 -0
- package/dist/lib/sync-core/reconcile.d.ts +10 -0
- package/dist/lib/sync-core/reconcile.js +117 -12
- package/dist/lib/sync-core/rollout-state.d.ts +2 -0
- package/dist/lib/sync-core/rollout-state.js +6 -0
- package/dist/lib/vault-sync-switches.d.ts +14 -0
- package/dist/lib/vault-sync-switches.js +22 -0
- package/dist/lib/workers-registry/index.d.ts +1 -1
- package/dist/lib/workers-registry/index.js +1 -1
- package/dist/utils/github-tag-fallback.d.ts +16 -0
- package/dist/utils/github-tag-fallback.js +126 -0
- package/dist/utils/version-report.d.ts +2 -1
- package/dist/utils/version-report.js +40 -27
- package/package.json +8 -8
|
@@ -12,6 +12,7 @@ import { matchingSecretPatterns } from "../lib/core-utils/secret-patterns.js";
|
|
|
12
12
|
import { describeCoreCommand } from "./core-command-catalog.js";
|
|
13
13
|
import { commandExists, delegateDiagnosticPath, isRecord, jsonAt, jqFallback, jqRawPath, jqRawPaths, moveFile, readJsonFile, subprocess, writeJsonAtomically, } from "./core-delegate.js";
|
|
14
14
|
import { resolveLiveRoot } from "../utils/hq-roots.js";
|
|
15
|
+
import { engineOwnedVaultsFromState } from "../lib/sync-core/engine-owned.js";
|
|
15
16
|
import { ACL_SOURCE_DISPLAY_LABELS } from "../utils/files-browse-acl.js";
|
|
16
17
|
import { runBundledScript } from "../utils/run-bundled-script.js";
|
|
17
18
|
import { resolveWindowsBash } from "../utils/windows-bash.js";
|
|
@@ -36,7 +37,7 @@ const DESCRIPTIONS = {
|
|
|
36
37
|
};
|
|
37
38
|
const USAGE = {
|
|
38
39
|
bundle: "hq-delegate-bundle.sh — freeze a project into a portable delegation bundle.\n\nUsage:\n core/scripts/hq-delegate-bundle.sh build \\\n --company <slug> --project <name> --to <principal> \\\n [--to-kind person|agent] [--to-name <display name>] \\\n [--mode transfer|share] [--dry-run]\n\n--dry-run prints the manifest JSON to stdout and writes nothing.\n\nWrites workspace/delegations/<delegationId>/{manifest.json,BRIEF.md} and\n",
|
|
39
|
-
grant: "hq-delegate-grant.sh — materialize a delegation's dossier in the vault and\nwrite the ACL grants its manifest declares, verifying each one landed.\n\nUsage:\n core/scripts/hq-delegate-grant.sh --manifest <path> [--yes]\n\nWithout --yes: prints the full grant plan (prefix, principal, permission —\nthe write grant is a privilege escalation and needs explicit confirmation)\nand exits 2 without mutating anything. The caller (the /delegate skill)\nconfirms with the user, then re-invokes with --yes.\n\nWith --yes:\n 1. hq sync push the project directory so the vault prefix exists\n 2. hq files share each manifest vaultPrefix to the recipient\n 3. read each grant back with hq files acl and match grantee + permission\n 4. advance manifest status building -> granted, stamping verifiedAt\n\nDirect ACL grants ONLY — this helper never mints a share-session URL\n(policy hq-delegate-never-inlines-secrets-or-share-urls).\n\nIdempotent: a prefix whose grant already exists is reported, not an error.\nA failed read-back exits non-zero and leaves manifest status unchanged.\n\n",
|
|
40
|
+
grant: "hq-delegate-grant.sh — materialize a delegation's dossier in the vault and\nwrite the ACL grants its manifest declares, verifying each one landed.\n\nUsage:\n core/scripts/hq-delegate-grant.sh --manifest <path> [--yes]\n\nWithout --yes: prints the full grant plan (prefix, principal, permission —\nthe write grant is a privilege escalation and needs explicit confirmation)\nand exits 2 without mutating anything. The caller (the /delegate skill)\nconfirms with the user, then re-invokes with --yes.\n\nWith --yes:\n 1. hq sync push the project directory so the vault prefix exists\n 2. hq files share each manifest vaultPrefix to the recipient\n 3. read each grant back with hq files acl and match grantee + permission\n 4. advance manifest status building -> granted, stamping verifiedAt\n\nWhen the new sync engine owns the company vault on this machine, the CLI\nrefuses `hq sync push`. Step 1 is then skipped, and after the grants the\nhelper waits for the engine to upload the dossier and referenced files\n(lib/delegate-engine.sh) before it advances the status.\n\nDirect ACL grants ONLY — this helper never mints a share-session URL\n(policy hq-delegate-never-inlines-secrets-or-share-urls).\n\nIdempotent: a prefix whose grant already exists is reported, not an error.\nA failed read-back exits non-zero and leaves manifest status unchanged.\n\n",
|
|
40
41
|
send: "hq-delegate-send.sh — generate the self-sufficient pickup prompt for a\ndelegation and deliver it by DM. The prompt IS the handoff: pasted into a\nfresh agent session on a clean HQ install, it pulls every file on demand\n(hq files get per prefix — no /hq-sync run) and reaches the first\nnext-step with no follow-up question to the delegator.\n\nUsage:\n core/scripts/hq-delegate-send.sh --manifest <path> [--send]\n [--headline <text>] [--note <text>]\n\nWithout --send: (re)generates PICKUP-PROMPT.md next to the manifest and\nprints its path — inspectable, idempotent, sends nothing.\nWith --send: requires manifest status \"verified\" (the US-008 probe must\nhave passed), then delivers ONE `hq dm` with --prompt-file/--details-file\nand advances status to \"sent\", recording the DM eventId.\n\nThe caller (the /delegate skill) humanizes --headline / --note per\ncore/knowledge/public/hq-core/humanize-before-send.md (channel dm, light)\nBEFORE invoking; this helper never rewrites recipients, flags, or the\ngenerated command lines.\n\nFail-closed: the generated prompt is scanned for secret-shaped content and\nshare-session URLs; a match aborts before anything is written or sent\n(policy hq-delegate-never-inlines-secrets-or-share-urls).\n\n",
|
|
41
42
|
verify: "hq-delegate-verify.sh — prove a delegation can actually be picked up\nbefore anyone is told it is theirs, or print the full plan without\ntouching anything.\n\nUsage (probe mode — after grants, before the DM):\n core/scripts/hq-delegate-verify.sh --manifest <path>\n\nProbes every manifest vaultPrefix with `hq files browse` and requires it\nreachable AND non-empty. All pass -> manifest advances granted -> verified\n(send is gated on this). Any failure -> non-zero, the failing prefix and\nlikely cause named, status left at its last successful value so a re-run\nresumes without re-granting.\n\nUsage (dry-run mode — full plan, zero mutation):\n core/scripts/hq-delegate-verify.sh --dry-run \\\n --company <slug> --project <name> --to <principal> [--mode transfer|share]\n\nPrints recipient, mode, project stage (prd, or brainstorm with the dossier\nfiles and the /plan next step), every prefix with its permission, the secret\nnames an .env.schema would grant, repo + branch, and the DM headline that\nwould be sent. Exits 0. Creates nothing under workspace/delegations/ and\ninvokes no mutating command.\n\n",
|
|
42
43
|
publish: "usage: --manifest <path>",
|
|
@@ -495,6 +496,169 @@ function emitJqParseDiagnostic(input, args, context) {
|
|
|
495
496
|
if (diagnostic.length)
|
|
496
497
|
err(diagnostic);
|
|
497
498
|
}
|
|
499
|
+
// The dossier files the grant step compares, re-pushes and waits for, in the
|
|
500
|
+
// order the staging helper walks them.
|
|
501
|
+
const DOSSIER_FILES = ["prd.json", "README.md", "brainstorm.md"];
|
|
502
|
+
function isRegularFile(file) {
|
|
503
|
+
try {
|
|
504
|
+
return fs.statSync(file).isFile();
|
|
505
|
+
}
|
|
506
|
+
catch {
|
|
507
|
+
return false;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
function compareCodePoints(left, right) {
|
|
511
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
512
|
+
}
|
|
513
|
+
function sha256Hex(bytes) {
|
|
514
|
+
return createHash("sha256").update(bytes).digest("hex");
|
|
515
|
+
}
|
|
516
|
+
function asciiLowercase(value) {
|
|
517
|
+
return value.replace(/[A-Z]/gu, (letter) => letter.toLowerCase());
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Maps a prs_ recipient to its one email through `hq people list`, as the
|
|
521
|
+
* staging helper does: the roster's JSON starts at the first line opening with
|
|
522
|
+
* `{` or `[`, and exactly one non-empty email must belong to that personUid.
|
|
523
|
+
*/
|
|
524
|
+
function personUidEmail(principal, company, context) {
|
|
525
|
+
const retry = "set to.principal to the recipient's email and re-run";
|
|
526
|
+
const listed = subprocess("hq", ["people", "list", "--company", company, "--json"], context.cwd, { timeout: 120_000 });
|
|
527
|
+
if (listed.code !== 0)
|
|
528
|
+
return { error: `could not list people to map personUid ${principal} to an email; ${retry}` };
|
|
529
|
+
const lines = (listed.stdout ?? "").split("\n");
|
|
530
|
+
const start = lines.findIndex((line) => /^[\t\n\v\f\r ]*[{[]/u.test(line));
|
|
531
|
+
const body = start < 0 ? "" : lines.slice(start).join("\n");
|
|
532
|
+
const unexpected = { error: `people list returned unexpected JSON while mapping ${principal}; ${retry}` };
|
|
533
|
+
const emails = new Set();
|
|
534
|
+
if (body.trim() !== "") {
|
|
535
|
+
let roster;
|
|
536
|
+
try {
|
|
537
|
+
roster = JSON.parse(body);
|
|
538
|
+
}
|
|
539
|
+
catch {
|
|
540
|
+
return unexpected;
|
|
541
|
+
}
|
|
542
|
+
let people;
|
|
543
|
+
if (Array.isArray(roster))
|
|
544
|
+
people = roster;
|
|
545
|
+
else if (isRecord(roster))
|
|
546
|
+
people = roster.people;
|
|
547
|
+
else
|
|
548
|
+
return unexpected;
|
|
549
|
+
if (people === undefined || people === null || people === false)
|
|
550
|
+
return unexpected;
|
|
551
|
+
let rows;
|
|
552
|
+
if (Array.isArray(people))
|
|
553
|
+
rows = people;
|
|
554
|
+
else if (isRecord(people))
|
|
555
|
+
rows = Object.values(people);
|
|
556
|
+
else
|
|
557
|
+
return unexpected;
|
|
558
|
+
for (const row of rows) {
|
|
559
|
+
if (row === null)
|
|
560
|
+
continue;
|
|
561
|
+
if (!isRecord(row))
|
|
562
|
+
return unexpected;
|
|
563
|
+
if (row.personUid !== principal)
|
|
564
|
+
continue;
|
|
565
|
+
if (typeof row.email === "string" && row.email.length > 0)
|
|
566
|
+
emails.add(asciiLowercase(row.email));
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
const matches = [...emails].sort(compareCodePoints);
|
|
570
|
+
if (matches.length !== 1 || !matches[0]) {
|
|
571
|
+
return { error: `personUid ${principal} maps to ${matches.length} emails in company '${company}' (need exactly 1); ${retry}` };
|
|
572
|
+
}
|
|
573
|
+
return { email: matches[0] };
|
|
574
|
+
}
|
|
575
|
+
/** True when `hq sync-core status --json` lists the company vault in full mode and not held. */
|
|
576
|
+
function engineOwnsVault(company, context) {
|
|
577
|
+
const status = subprocess("hq", ["sync-core", "status", "--json"], context.cwd, { stderr: "ignore", timeout: 120_000 });
|
|
578
|
+
if (status.code !== 0)
|
|
579
|
+
return false;
|
|
580
|
+
let value;
|
|
581
|
+
try {
|
|
582
|
+
value = JSON.parse(status.stdout ?? "");
|
|
583
|
+
}
|
|
584
|
+
catch {
|
|
585
|
+
return false;
|
|
586
|
+
}
|
|
587
|
+
if (!isRecord(value))
|
|
588
|
+
return false;
|
|
589
|
+
const vaults = (Array.isArray(value.vaults) ? value.vaults : isRecord(value.vaults) ? Object.values(value.vaults) : []).filter((vault) => vault !== null);
|
|
590
|
+
const held = value.held === undefined || value.held === null ? [] : value.held;
|
|
591
|
+
if (!vaults.every((vault) => isRecord(vault) && typeof vault.uid === "string"))
|
|
592
|
+
return false;
|
|
593
|
+
if (!Array.isArray(held) || !held.every((entry) => isRecord(entry) && typeof entry.uid === "string"))
|
|
594
|
+
return false;
|
|
595
|
+
const state = { vaults: vaults, held: held };
|
|
596
|
+
return engineOwnedVaultsFromState(state).companies.has(company.trim().toLowerCase());
|
|
597
|
+
}
|
|
598
|
+
/** Adds company-relative paths to <root>/.hq/pins.json, sorted and unique. */
|
|
599
|
+
function pinForEngine(root, company, paths) {
|
|
600
|
+
const file = path.join(root, ".hq", "pins.json");
|
|
601
|
+
try {
|
|
602
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
603
|
+
let pins = { version: 1, pins: {} };
|
|
604
|
+
if (fs.existsSync(file) && fs.statSync(file).size > 0)
|
|
605
|
+
pins = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
606
|
+
if (!isRecord(pins))
|
|
607
|
+
return false;
|
|
608
|
+
if (pins.pins === undefined || pins.pins === null)
|
|
609
|
+
pins.pins = {};
|
|
610
|
+
if (!isRecord(pins.pins))
|
|
611
|
+
return false;
|
|
612
|
+
const existing = pins.pins[company];
|
|
613
|
+
const current = existing === undefined || existing === null || existing === false ? [] : existing;
|
|
614
|
+
if (!Array.isArray(current) || !current.every((entry) => typeof entry === "string"))
|
|
615
|
+
return false;
|
|
616
|
+
pins.pins[company] = [...new Set([...current, ...paths])].sort(compareCodePoints);
|
|
617
|
+
writeJsonAtomically(file, pins, true);
|
|
618
|
+
return true;
|
|
619
|
+
}
|
|
620
|
+
catch {
|
|
621
|
+
return false;
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* True when every local dossier file matches the vault copy byte for byte and
|
|
626
|
+
* at least one was compared; any failed read falls back to the full push.
|
|
627
|
+
*/
|
|
628
|
+
function vaultHasProject(company, project, projectDir, context) {
|
|
629
|
+
let compared = 0;
|
|
630
|
+
for (const dossierFile of DOSSIER_FILES) {
|
|
631
|
+
const local = path.join(projectDir, dossierFile);
|
|
632
|
+
if (!isRegularFile(local))
|
|
633
|
+
continue;
|
|
634
|
+
const remote = subprocess("hq", ["files", "cat", `projects/${project}/${dossierFile}`, "--company", company], context.cwd, { stderr: "ignore", timeout: 120_000 });
|
|
635
|
+
if (remote.code !== 0)
|
|
636
|
+
return false;
|
|
637
|
+
if (sha256Hex(remote.stdoutBytes ?? Buffer.from(remote.stdout ?? "")) !== sha256Hex(fs.readFileSync(local)))
|
|
638
|
+
return false;
|
|
639
|
+
compared += 1;
|
|
640
|
+
}
|
|
641
|
+
return compared > 0;
|
|
642
|
+
}
|
|
643
|
+
/** HQ_DELEGATE_ENGINE_WAIT_SECONDS as whole seconds; 180 when unset or not a whole number (staging lib/delegate-engine.sh). */
|
|
644
|
+
function engineWaitSeconds() {
|
|
645
|
+
const raw = process.env.HQ_DELEGATE_ENGINE_WAIT_SECONDS ?? "";
|
|
646
|
+
return /^[0-9]+$/.test(raw) ? Number(raw) : 180;
|
|
647
|
+
}
|
|
648
|
+
const ENGINE_WAIT_CAUSES = "the engine skips a file an ignore rule matches, a symlink, or a path this machine is not granted";
|
|
649
|
+
/** Polls `hq files cat` until it succeeds and the vault holds exactly the expected bytes. */
|
|
650
|
+
function waitForEngineUpload(company, vaultPath, expected, context) {
|
|
651
|
+
const pollSeconds = Number(process.env.HQ_DELEGATE_ENGINE_POLL_SECONDS || "5");
|
|
652
|
+
const deadline = Date.now() + engineWaitSeconds() * 1000;
|
|
653
|
+
for (;;) {
|
|
654
|
+
const read = subprocess("hq", ["files", "cat", vaultPath, "--company", company], context.cwd, { stderr: "ignore", timeout: 120_000 });
|
|
655
|
+
if (read.code === 0 && sha256Hex(read.stdoutBytes ?? Buffer.from(read.stdout ?? "")) === expected)
|
|
656
|
+
return true;
|
|
657
|
+
if (Date.now() >= deadline)
|
|
658
|
+
return false;
|
|
659
|
+
sleepNative((Number.isFinite(pollSeconds) ? pollSeconds : 5) * 1000);
|
|
660
|
+
}
|
|
661
|
+
}
|
|
498
662
|
const RESOLVE_FOUND_FILTER = '.status == "found" and (.person.personUid | type == "string") and (.person.companyUid | type == "string")';
|
|
499
663
|
const RESOLVE_NOT_FOUND_FILTER = '.status == "not_found"';
|
|
500
664
|
const ACL_FILTER = `
|
|
@@ -570,10 +734,24 @@ function runGrant(args, context) {
|
|
|
570
734
|
}).map((entry) => jqRawPath(entry, "prefix"));
|
|
571
735
|
if (badPrefixes.length)
|
|
572
736
|
return fail("grant", `prefix violates the hq-files prefix conventions (must be company-relative folder form ending in '/'): ${badPrefixes.join("\n")}`);
|
|
737
|
+
// `hq people resolve` matches names and emails only, and `hq files share
|
|
738
|
+
// --with` accepts only email / grp_ / @all. Map a prs_ uid to its one email
|
|
739
|
+
// through the people roster; the membership resolve below must return this
|
|
740
|
+
// exact personUid (staging hq-delegate-grant.sh).
|
|
741
|
+
let resolveKey = principal;
|
|
742
|
+
if (principal.startsWith("prs_")) {
|
|
743
|
+
const mapped = personUidEmail(principal, company, context);
|
|
744
|
+
if ("error" in mapped)
|
|
745
|
+
return fail("grant", mapped.error);
|
|
746
|
+
resolveKey = mapped.email;
|
|
747
|
+
grantPrincipal = mapped.email;
|
|
748
|
+
}
|
|
573
749
|
out(`Delegation grant plan — company '${company}', recipient '${principal}':\n`);
|
|
574
|
-
if (
|
|
750
|
+
if (principal.startsWith("prs_"))
|
|
751
|
+
out(` 0. Person recipient: personUid ${principal} maps to ${grantPrincipal}; grants are shared to that email\n`);
|
|
752
|
+
if (principal.startsWith("agt_"))
|
|
575
753
|
out(` 0. Agent recipient: grants flow through group ${grantPrincipal} (created if absent, containing exactly ${display})\n`);
|
|
576
|
-
out(` 1. Push companies/${company}/projects/${project}/ to the vault (on-conflict keep)\n`);
|
|
754
|
+
out(` 1. Push companies/${company}/projects/${project}/ to the vault (on-conflict keep); where the sync engine owns the vault, pin it in .hq/pins.json and wait for its upload after the grants instead\n`);
|
|
577
755
|
for (const entry of prefixes)
|
|
578
756
|
out(` 2. Grant ${jqRawPath(entry, "permission")} on ${jqRawPath(entry, "prefix")} — ${jqRawPath(entry, "reason")}\n`);
|
|
579
757
|
const writePrefixes = prefixes.map((entry) => jqRawPath(entry, "permission") === "write" ? jqRawPath(entry, "prefix") : "").filter(Boolean);
|
|
@@ -585,24 +763,54 @@ function runGrant(args, context) {
|
|
|
585
763
|
err("hq-delegate-grant: confirmation required — re-run with --yes after the user approves\n");
|
|
586
764
|
return 2;
|
|
587
765
|
}
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
return fail("grant", `vault push failed for companies/${company}/projects/${project}/`);
|
|
766
|
+
const hqRoot = context.root ?? context.cwd;
|
|
767
|
+
const projectDir = path.join(hqRoot, "companies", company, "projects", project);
|
|
591
768
|
const referencePaths = [
|
|
592
769
|
...list(getPath(manifest, "knowledge", [])),
|
|
593
770
|
...list(getPath(manifest, "policies", [])),
|
|
594
771
|
].filter((entry) => typeof entry === "string" && entry.startsWith(`companies/${company}/`));
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
772
|
+
// Where the sync engine owns the company vault, the CLI refuses `hq sync
|
|
773
|
+
// push`: pin the project and referenced files instead, then wait for the
|
|
774
|
+
// engine's upload after the grants (staging lib/delegate-engine.sh).
|
|
775
|
+
const engineOwned = engineOwnsVault(company, context);
|
|
776
|
+
let result;
|
|
777
|
+
if (engineOwned) {
|
|
778
|
+
out(`hq-delegate-grant: the sync engine owns the '${company}' vault on this machine — no push; pinning the project and referenced files so the engine uploads them\n`);
|
|
779
|
+
const pins = [`projects/${project}/`, ...referencePaths.map((entry) => entry.slice(`companies/${company}/`.length))];
|
|
780
|
+
if (!pinForEngine(hqRoot, company, pins))
|
|
781
|
+
return fail("grant", `could not add the project to ${shellDisplayPath(hqRoot)}/.hq/pins.json for the sync engine`);
|
|
782
|
+
}
|
|
783
|
+
else if (vaultHasProject(company, project, projectDir, context)) {
|
|
784
|
+
out(`hq-delegate-grant: vault already has companies/${company}/projects/${project}/ (dossier checksums match) — skipping full-folder push\n`);
|
|
785
|
+
}
|
|
786
|
+
else {
|
|
787
|
+
result = grantHq(["sync", "push", `companies/${company}/projects/${project}/`, "--company", company, "--on-conflict", "keep"], context, "inherit");
|
|
788
|
+
if (result.code !== 0)
|
|
789
|
+
return fail("grant", `vault push failed for companies/${company}/projects/${project}/`);
|
|
790
|
+
// on-conflict keep drops the delegator's fresh local edits when the vault
|
|
791
|
+
// copy differs. The delegator owns the dossier, so push it again with overwrite.
|
|
792
|
+
for (const dossierFile of DOSSIER_FILES) {
|
|
793
|
+
if (!isRegularFile(path.join(projectDir, dossierFile)))
|
|
794
|
+
continue;
|
|
795
|
+
const dossierPath = `companies/${company}/projects/${project}/${dossierFile}`;
|
|
796
|
+
result = grantHq(["sync", "push", dossierPath, "--company", company, "--on-conflict", "overwrite"], context, "inherit");
|
|
598
797
|
if (result.code !== 0)
|
|
599
|
-
return fail("grant", `vault push failed for
|
|
798
|
+
return fail("grant", `vault push failed for dossier file ${dossierPath}`);
|
|
600
799
|
}
|
|
601
|
-
|
|
602
|
-
|
|
800
|
+
}
|
|
801
|
+
if (!engineOwned) {
|
|
802
|
+
for (const reference of referencePaths) {
|
|
803
|
+
if (fs.existsSync(path.join(hqRoot, reference))) {
|
|
804
|
+
result = grantHq(["sync", "push", reference, "--company", company, "--on-conflict", "keep"], context, "inherit");
|
|
805
|
+
if (result.code !== 0)
|
|
806
|
+
return fail("grant", `vault push failed for referenced knowledge: ${reference}`);
|
|
807
|
+
}
|
|
808
|
+
else {
|
|
809
|
+
err(`hq-delegate-grant: referenced path missing locally (cannot push): ${reference} — the verify probe will fail if it is not already in the vault\n`);
|
|
810
|
+
}
|
|
603
811
|
}
|
|
604
812
|
}
|
|
605
|
-
if (
|
|
813
|
+
if (principal.startsWith("agt_")) {
|
|
606
814
|
result = grantHq(["groups", "create", grantPrincipal, "--name", `Delegation: ${display}`, "--company", company], context, "inherit");
|
|
607
815
|
if (result.timedOut)
|
|
608
816
|
return fail("grant", "group creation timed out; retain this manifest and resume");
|
|
@@ -632,7 +840,7 @@ function runGrant(args, context) {
|
|
|
632
840
|
expectedType = "company-wide";
|
|
633
841
|
}
|
|
634
842
|
else {
|
|
635
|
-
const resolved = grantHq(["people", "resolve",
|
|
843
|
+
const resolved = grantHq(["people", "resolve", resolveKey, "--company", company, "--json", "--membership-only"], context);
|
|
636
844
|
let response;
|
|
637
845
|
try {
|
|
638
846
|
response = JSON.parse(resolved.stdout ?? "");
|
|
@@ -651,8 +859,13 @@ function runGrant(args, context) {
|
|
|
651
859
|
expectedType = "person";
|
|
652
860
|
expectedId = response.person.personUid;
|
|
653
861
|
expectedCompany = response.person.companyUid;
|
|
862
|
+
if (principal.startsWith("prs_") && expectedId !== principal) {
|
|
863
|
+
return fail("grant", `personUid ${principal} mapped to ${resolveKey}, but membership resolves that email to ${expectedId}; set to.principal to the recipient's email and re-run`);
|
|
864
|
+
}
|
|
654
865
|
}
|
|
655
866
|
else if (isRecord(response) && response.status === "not_found") {
|
|
867
|
+
if (principal.startsWith("prs_"))
|
|
868
|
+
return fail("grant", `personUid ${principal} (${resolveKey}) is not an active member of company '${company}'`);
|
|
656
869
|
if (principal.includes("@")) {
|
|
657
870
|
expectedType = "email";
|
|
658
871
|
expectedId = principal.toLowerCase().trim();
|
|
@@ -719,18 +932,46 @@ function runGrant(args, context) {
|
|
|
719
932
|
if (!landedAcl)
|
|
720
933
|
return fail("grant", `grant outcome unconfirmed for ${principal} on ${prefix}; retain this manifest and resume`);
|
|
721
934
|
// Full-transfer mode: a more specific rule under the project prefix (for
|
|
722
|
-
// example projects/<name>/design/*) outranks
|
|
723
|
-
// recipient would keep the narrower permission
|
|
724
|
-
//
|
|
725
|
-
//
|
|
935
|
+
// example projects/<name>/design/* or projects/<name>/design) outranks
|
|
936
|
+
// the root grant, so the recipient would keep the narrower permission
|
|
937
|
+
// there, or have none at all. Grant the same permission on every such
|
|
938
|
+
// rule and verify each one. The ACL tree lists rules that carry grants
|
|
939
|
+
// as `children` and rules with no grants only as `masking`, so both are
|
|
940
|
+
// read; a truncated masking list stops the grant rather than leave an
|
|
941
|
+
// unseen rule ungranted. Only rules under the project prefix are
|
|
942
|
+
// considered, so the outside-project check below is defensive.
|
|
726
943
|
if (jqRawPath(manifest, "mode") === "transfer" && prefix.startsWith(`projects/${project}/`)) {
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
944
|
+
if (landedAcl.maskingTruncated === true) {
|
|
945
|
+
return fail("grant", `the ACL tree for ${prefix} lists too many overriding rules to check; grant them by hand, then resume`);
|
|
946
|
+
}
|
|
947
|
+
const underProject = (source) => typeof source === "string"
|
|
948
|
+
&& source.startsWith(prefix) && source !== aclPattern;
|
|
949
|
+
const heldAtLeast = new Set();
|
|
950
|
+
const rank = (value) => value === "admin" ? 3 : value === "write" ? 2 : value === "read" ? 1 : 0;
|
|
951
|
+
const holds = (grant) => isRecord(grant) && grant.granteeType === expectedType
|
|
952
|
+
&& grant.granteeId === expectedId && rank(grant.permission) >= rank(permission);
|
|
953
|
+
const candidates = new Set();
|
|
954
|
+
for (const child of list(landedAcl.children)) {
|
|
955
|
+
if (!isRecord(child) || !underProject(child.sourcePrefix))
|
|
956
|
+
continue;
|
|
957
|
+
candidates.add(child.sourcePrefix);
|
|
958
|
+
if (holds(child))
|
|
959
|
+
heldAtLeast.add(child.sourcePrefix);
|
|
960
|
+
}
|
|
961
|
+
for (const row of list(landedAcl.masking)) {
|
|
962
|
+
if (!isRecord(row) || !underProject(row.path))
|
|
963
|
+
continue;
|
|
964
|
+
candidates.add(row.path);
|
|
965
|
+
if (list(row.grantees).some(holds))
|
|
966
|
+
heldAtLeast.add(row.path);
|
|
967
|
+
}
|
|
968
|
+
for (const child of [...candidates].sort()) {
|
|
732
969
|
if (!child.startsWith(`projects/${project}/`))
|
|
733
970
|
return fail("grant", `more specific rule ${child} is outside projects/${project}/`);
|
|
971
|
+
if (heldAtLeast.has(child)) {
|
|
972
|
+
out(`hq-delegate-grant: ${principal} already holds ${permission} or higher on more specific rule ${child}\n`);
|
|
973
|
+
continue;
|
|
974
|
+
}
|
|
734
975
|
const childShare = grantHq(["files", "share", child, "--with", grantPrincipal, "--permission", permission, "--company", company], context, "inherit");
|
|
735
976
|
if (childShare.timedOut)
|
|
736
977
|
return fail("grant", `share timed out for more specific rule ${child}; retain this manifest and resume`);
|
|
@@ -749,6 +990,30 @@ function runGrant(args, context) {
|
|
|
749
990
|
writeJsonAtomically(manifestPath, manifest, true);
|
|
750
991
|
out(`hq-delegate-grant: verified ${permission} on ${prefix} for ${principal}\n`);
|
|
751
992
|
}
|
|
993
|
+
if (engineOwned) {
|
|
994
|
+
// The pins bring the files into the engine's scope; confirm the exact
|
|
995
|
+
// bytes of the dossier and every referenced company file have landed.
|
|
996
|
+
const companyPrefix = `companies/${company}/`;
|
|
997
|
+
const uploads = new Set();
|
|
998
|
+
for (const dossierFile of DOSSIER_FILES) {
|
|
999
|
+
if (isRegularFile(path.join(projectDir, dossierFile)))
|
|
1000
|
+
uploads.add(`${companyPrefix}projects/${project}/${dossierFile}`);
|
|
1001
|
+
}
|
|
1002
|
+
for (const entry of [...list(getPath(manifest, "project.dossier", [])), ...list(getPath(manifest, "knowledge", [])), ...list(getPath(manifest, "policies", []))]) {
|
|
1003
|
+
if (typeof entry === "string" && entry.startsWith(companyPrefix))
|
|
1004
|
+
uploads.add(entry);
|
|
1005
|
+
}
|
|
1006
|
+
for (const upload of [...uploads].sort(compareCodePoints)) {
|
|
1007
|
+
const local = path.join(hqRoot, upload);
|
|
1008
|
+
if (!isRegularFile(local))
|
|
1009
|
+
continue;
|
|
1010
|
+
const expected = createHash("sha256").update(fs.readFileSync(local)).digest("hex");
|
|
1011
|
+
if (!waitForEngineUpload(company, upload.slice(companyPrefix.length), expected, context)) {
|
|
1012
|
+
return fail("grant", `the sync engine has not uploaded ${upload} after ${engineWaitSeconds()}s (${ENGINE_WAIT_CAUSES}); check 'hq sync-core status', then re-run (grants are idempotent)`);
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
out("hq-delegate-grant: the sync engine uploaded the dossier; vault bytes match\n");
|
|
1016
|
+
}
|
|
752
1017
|
manifest.status = "granted";
|
|
753
1018
|
manifest.grantPrincipal = grantPrincipal;
|
|
754
1019
|
manifest.vaultPrefixes = list(manifest.vaultPrefixes).map((entry) => isRecord(entry) ? { ...entry, verifiedAt: now } : entry);
|
|
@@ -904,15 +1169,31 @@ function runPublish(args, context, legacyHandoff, nativeLock) {
|
|
|
904
1169
|
atomicCopy(stagedBrief, path.join(dest, "BRIEF.md"), 0o600);
|
|
905
1170
|
atomicCopy(stagedManifest, path.join(dest, "manifest.json"), 0o600);
|
|
906
1171
|
atomicCopy(stagedManifest, manifestPath, 0o600);
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
1172
|
+
// Where the sync engine owns the company vault it uploads the files and the
|
|
1173
|
+
// read-back below waits for them. Otherwise push only the dossier paths.
|
|
1174
|
+
const engineOwned = engineOwnsVault(company, context);
|
|
1175
|
+
if (!engineOwned) {
|
|
1176
|
+
const pushTargets = [
|
|
1177
|
+
`${relative}/delegation/${id}/`,
|
|
1178
|
+
...snapshotFiles.filter((file) => fs.existsSync(file)).map((file) => path.relative(root, file).split(path.sep).join("/")),
|
|
1179
|
+
];
|
|
1180
|
+
for (const target of pushTargets) {
|
|
1181
|
+
const push = runHq(["sync", "push", target, "--company", company, "--on-conflict", "keep"], context, "inherit");
|
|
1182
|
+
if (push.code !== 0)
|
|
1183
|
+
return fail("publish", "final dossier push failed; resume publication");
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
910
1186
|
const receipts = { ...hashed };
|
|
911
1187
|
receipts[`${relative}/delegation/${id}/manifest.json`] = checksum(path.join(dest, "manifest.json"));
|
|
912
1188
|
const stagedRemote = path.join(stage, "remote");
|
|
913
1189
|
for (const [file, expected] of Object.entries(receipts)) {
|
|
914
1190
|
let matched = false;
|
|
915
1191
|
const cloudPath = file.startsWith(`companies/${company}/`) ? file.slice(`companies/${company}/`.length) : file;
|
|
1192
|
+
if (engineOwned) {
|
|
1193
|
+
if (waitForEngineUpload(company, cloudPath, expected, context))
|
|
1194
|
+
continue;
|
|
1195
|
+
return fail("publish", `the sync engine has not uploaded ${file} (or the vault holds other bytes) after ${engineWaitSeconds()}s (${ENGINE_WAIT_CAUSES}); check 'hq sync-core status', then resume`);
|
|
1196
|
+
}
|
|
916
1197
|
for (const delay of [0, 1, 2]) {
|
|
917
1198
|
if (delay)
|
|
918
1199
|
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, delay * 1000);
|
|
@@ -15,6 +15,7 @@ import { acquireDelegateLock } from "../utils/delegate-lock.js";
|
|
|
15
15
|
import { runBundledScript } from "../utils/run-bundled-script.js";
|
|
16
16
|
import { brainstormFrontmatterSet, brainstormSummary, brainstormTitle } from "./core-delegate-brainstorm.js";
|
|
17
17
|
import { delegateBoardPath, delegateRepoDirectory, secretsSourcePaths } from "../lib/core-utils/delegate-helper-paths.js";
|
|
18
|
+
import { raiseAccessRefresh } from "../lib/sync-core/access-refresh.js";
|
|
18
19
|
export const CORE_NATIVE_DELEGATE_FLAG = "core-native-delegate";
|
|
19
20
|
const SCRIPT_ASSETS = {
|
|
20
21
|
resolve: "core/scripts/hq-delegate-resolve.sh",
|
|
@@ -505,6 +506,7 @@ function runPickup(args, context) {
|
|
|
505
506
|
pickedUpAt: now,
|
|
506
507
|
pickup: { kind, detail, recordedAt: now },
|
|
507
508
|
}, true);
|
|
509
|
+
raiseAccessRefresh({ companySlug: jqRawPath(document, "company") });
|
|
508
510
|
writeOut(`hq-delegate-pickup: ${name} picked up the delegation (${kind}) — status advanced to 'picked-up'\n`);
|
|
509
511
|
return 0;
|
|
510
512
|
};
|
|
@@ -1874,7 +1874,7 @@ export function runHandoffArchiveDecision(args, context) {
|
|
|
1874
1874
|
return archiveNo("could not verify background work: no session id");
|
|
1875
1875
|
if (invalidSessionId(resolvedSession))
|
|
1876
1876
|
return archiveNo("could not verify background work: invalid session id");
|
|
1877
|
-
const lanes = subprocess("hq", ["
|
|
1877
|
+
const lanes = subprocess("hq", ["runners", "list", "--senior", `session:${resolvedSession}`, "--active", "--json"], cwd, {
|
|
1878
1878
|
stdout: "capture",
|
|
1879
1879
|
stderr: "ignore",
|
|
1880
1880
|
env: { HQ_NO_UPDATE_CHECK: "1" },
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider sign-in failures for the scheduled-job runner.
|
|
3
|
+
*
|
|
4
|
+
* The 2026-11-19 Outpost outage printed "this login reached its time limit
|
|
5
|
+
* and cannot be renewed". That text matched none of the older auth patterns,
|
|
6
|
+
* so the run was not treated as a sign-in failure.
|
|
7
|
+
*
|
|
8
|
+
* A hold remembers the credential file's size, mtime, and inode, plus the
|
|
9
|
+
* expiry epoch when the file has one. It does not store credential bytes.
|
|
10
|
+
* The next run stays held until a local read says that expiry moved, or,
|
|
11
|
+
* when the file has no readable expiry, until the file is replaced. A still
|
|
12
|
+
* expired file does not resume on a rewrite alone. A hold whose credential
|
|
13
|
+
* still reads healthy runs again about an hour later, even when that expiry
|
|
14
|
+
* epoch did not move, so a false hold cannot pause a job for days. Missed
|
|
15
|
+
* runs are not replayed.
|
|
16
|
+
*
|
|
17
|
+
* Job output can still take today's remediation path on a bare "401",
|
|
18
|
+
* "unauthorized", or a loose "be renewed" line. Those lines do not open an
|
|
19
|
+
* episode or a hold. An episode needs a Claude Code or Codex CLI sign-in
|
|
20
|
+
* line, or a local read that says the credential file is missing. A passed
|
|
21
|
+
* expiry date does not open an episode. Lines from HQ, git, and this runner
|
|
22
|
+
* are not the provider CLI.
|
|
23
|
+
*/
|
|
24
|
+
export declare const PROVIDER_SIGN_IN_TIME_LIMIT_MESSAGE = "this login reached its time limit and cannot be renewed";
|
|
25
|
+
/** Values this runner sends as `reason` on POST /outpost/internal/model-auth-failure. */
|
|
26
|
+
export type ModelAuthReportReason = "time_limit" | "missing" | "auth_failure";
|
|
27
|
+
/** A healthy hold may run again after this long even if the expiry epoch did not move. */
|
|
28
|
+
export declare const HEALTHY_HOLD_RETRY_MS: number;
|
|
29
|
+
/** A credential file larger than this is treated as unreadable, not loaded. */
|
|
30
|
+
export declare const MAX_CREDENTIAL_READ_BYTES: number;
|
|
31
|
+
export declare function logTextIsProviderSignInFailure(text: string): boolean;
|
|
32
|
+
/** True only for a provider CLI sign-in line. Not for HQ, git, or this runner. */
|
|
33
|
+
export declare function logTextOpensSignInEpisode(text: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* True when a held job may run again because the credential still reads
|
|
36
|
+
* healthy and the hold is at least an hour old. Expired, missing, and
|
|
37
|
+
* unknown reads stay held until the credential itself changes.
|
|
38
|
+
*/
|
|
39
|
+
export declare function healthyCredentialRetryDue(heldAt: string, nowMs: number, state: LocalCredentialState): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Stable reason code for POST /outpost/internal/model-auth-failure.
|
|
42
|
+
* Never a log line. A missing credential file is reported as `missing` by
|
|
43
|
+
* the caller; this function only distinguishes a time-limit sign-in from
|
|
44
|
+
* any other sign-in failure.
|
|
45
|
+
*/
|
|
46
|
+
export declare function modelAuthFailureReason(text: string): Exclude<ModelAuthReportReason, "missing">;
|
|
47
|
+
/**
|
|
48
|
+
* Non-empty `episodeId` on a 2xx body. Anything else, including
|
|
49
|
+
* `{ ok: true, started: false }` with the field omitted, is not confirmation.
|
|
50
|
+
* The id itself is not logged by the caller.
|
|
51
|
+
*/
|
|
52
|
+
export declare function episodeIdFromReportBody(body: string): string | undefined;
|
|
53
|
+
export type CredentialFingerprintStat = {
|
|
54
|
+
size: number;
|
|
55
|
+
mtimeMs: number;
|
|
56
|
+
ino: number;
|
|
57
|
+
};
|
|
58
|
+
/** `absent` / `empty` / `size:mtimeMs:ino`. No credential bytes. */
|
|
59
|
+
export declare function credentialFingerprint(stat: CredentialFingerprintStat | undefined): string;
|
|
60
|
+
/** True when a later stat is a non-empty file other than the one that was held. */
|
|
61
|
+
export declare function credentialReplaced(heldFingerprint: string, current: string): boolean;
|
|
62
|
+
export type LocalCredentialState = "healthy" | "expired" | "missing" | "unknown";
|
|
63
|
+
export type LocalCredentialRead = {
|
|
64
|
+
state: LocalCredentialState;
|
|
65
|
+
expiresAtMs?: number;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Cheap local read of a credential file's expiry. No model call.
|
|
69
|
+
* `undefined` raw means the file is absent. An unreadable file is `unknown`,
|
|
70
|
+
* so the caller keeps the modified-time fingerprint. Never returns token bytes.
|
|
71
|
+
*
|
|
72
|
+
* Claude: `claudeAiOauth.expiresAt` (milliseconds, seconds, or an ISO instant).
|
|
73
|
+
* Codex: `tokens.expires_at` / `expiresAt`, else the access-token JWT `exp`.
|
|
74
|
+
*/
|
|
75
|
+
export declare function localCredentialState(runtime: "claude" | "codex", raw: string | undefined, nowMs: number): LocalCredentialRead;
|
|
76
|
+
/**
|
|
77
|
+
* Resume when a readable expiry says the sign-in changed and is current, or
|
|
78
|
+
* when no expiry can be read and the file itself was replaced. A still
|
|
79
|
+
* expired or missing file stays held even if its modified time changed.
|
|
80
|
+
*/
|
|
81
|
+
export declare function signInHoldReleased(heldFingerprint: string, currentFingerprint: string, heldExpiresAtMs: number | undefined, current: LocalCredentialRead): boolean;
|
|
82
|
+
export type SignInHold = {
|
|
83
|
+
version: 1;
|
|
84
|
+
reason: "sign-in";
|
|
85
|
+
runtime: "claude" | "codex";
|
|
86
|
+
fingerprint: string;
|
|
87
|
+
reported: boolean;
|
|
88
|
+
/** Stable POST reason code. Not a log line. */
|
|
89
|
+
report_reason: ModelAuthReportReason;
|
|
90
|
+
held_at: string;
|
|
91
|
+
/** Expiry epoch observed when the hold was written. Omitted when unreadable. */
|
|
92
|
+
credential_expires_at_ms?: number;
|
|
93
|
+
};
|
|
94
|
+
export declare function parseSignInHold(text: string): SignInHold | undefined;
|
|
95
|
+
//# sourceMappingURL=core-job-model-auth.d.ts.map
|