@indigoai-us/hq-cli 5.345.238 → 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 +74 -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/hq-delegate-repo.sh +7 -1
- package/assets/scaffold/core/scripts/hq-delegate-secrets.sh +95 -20
- package/assets/scaffold/core/scripts/hq-delegate-transfer.sh +57 -9
- package/assets/scaffold/core/scripts/lib/delegate-engine.sh +77 -0
- package/dist/command-catalog.generated.d.ts +212 -10
- package/dist/command-catalog.generated.js +260 -10
- package/dist/command-registration-plan.d.ts +6 -0
- package/dist/command-registration-plan.js +1 -0
- package/dist/commands/cloud-off-gate.d.ts +9 -8
- package/dist/commands/cloud-off-gate.js +41 -40
- package/dist/commands/cloud.d.ts +17 -2
- package/dist/commands/cloud.js +126 -24
- package/dist/commands/core-delegate-w1b.js +333 -27
- package/dist/commands/core-delegate.d.ts +2 -1
- package/dist/commands/core-delegate.js +209 -48
- 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/deploy-comments.js +8 -2
- package/dist/commands/deploy-events.d.ts +40 -0
- package/dist/commands/deploy-events.js +300 -0
- package/dist/commands/doctor.d.ts +4 -4
- package/dist/commands/doctor.js +2 -2
- package/dist/commands/feedback.js +2 -3
- 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/keyed-sync-pull.d.ts +12 -0
- package/dist/commands/keyed-sync-pull.js +151 -0
- 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/library-add.d.ts +5 -2
- package/dist/commands/library-add.js +22 -9
- package/dist/commands/mcp-registration.d.ts +4 -18
- package/dist/commands/mcp-registration.js +9 -29
- package/dist/commands/mesh.d.ts +4 -0
- package/dist/commands/mesh.js +25 -5
- package/dist/commands/pack-install.d.ts +2 -3
- package/dist/commands/pack-install.js +6 -8
- 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/secrets.d.ts +3 -4
- package/dist/commands/secrets.js +3 -20
- 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 +1830 -1468
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/lib/bot/api.d.ts +2 -1
- package/dist/lib/bot/api.js +2 -15
- package/dist/lib/capacity/accounts.d.ts +1 -1
- package/dist/lib/capacity/accounts.js +1 -1
- package/dist/lib/capacity/collectors/claude-oauth.d.ts +0 -2
- package/dist/lib/capacity/collectors/claude-oauth.js +0 -5
- 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/core-utils/delegate-helper-paths.d.ts +26 -0
- package/dist/lib/core-utils/delegate-helper-paths.js +33 -0
- 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/jq-provision.d.ts +63 -0
- package/dist/lib/daemon/jq-provision.js +155 -0
- package/dist/lib/daemon/lanes-reconcile-guard.d.ts +4 -3
- package/dist/lib/daemon/lanes-reconcile-guard.js +4 -4
- package/dist/lib/daemon/mesh-owner.d.ts +4 -0
- package/dist/lib/daemon/mesh-owner.js +20 -0
- package/dist/lib/daemon/ops/policy.d.ts +3 -0
- package/dist/lib/daemon/ops/policy.js +32 -4
- package/dist/lib/daemon/run.js +17 -22
- package/dist/lib/daemon/server.d.ts +6 -0
- package/dist/lib/daemon/server.js +5 -0
- package/dist/lib/daemon/verified-jq.d.ts +96 -0
- package/dist/lib/daemon/verified-jq.js +337 -0
- package/dist/lib/doctor/checks/jq.js +16 -0
- package/dist/lib/doctor/deep/executor.d.ts +7 -0
- package/dist/lib/doctor/deep/executor.js +1 -1
- package/dist/lib/doctor/deep/parity.js +1 -27
- package/dist/lib/doctor/deep/sandbox.d.ts +2 -2
- package/dist/lib/doctor/deep/sandbox.js +3 -19
- package/dist/lib/doctor/fix/refresh-sync-handoff.js +52 -21
- package/dist/lib/doctor/fixtures/discover.d.ts +2 -0
- package/dist/lib/doctor/fixtures/discover.js +1 -1
- package/dist/lib/doctor/json-output.d.ts +1 -1
- package/dist/lib/doctor/registry.d.ts +6 -7
- package/dist/lib/doctor/registry.js +6 -7
- package/dist/lib/doctor/report.d.ts +9 -10
- package/dist/lib/doctor/report.js +4 -4
- 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/jq/install.d.ts +27 -0
- package/dist/lib/jq/install.js +156 -0
- 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/outpost-dispatch.d.ts +1 -1
- package/dist/lib/lanes/outpost-dispatch.js +13 -13
- package/dist/lib/lanes/outpost-pruner-install.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/mesh/live/daemon/doctor.js +7 -1
- package/dist/lib/mesh/live/daemon/install.d.ts +4 -0
- package/dist/lib/mesh/live/daemon/install.js +10 -0
- package/dist/lib/mesh/live/daemon/run.js +17 -0
- package/dist/lib/mesh/live/emit-retry.d.ts +20 -2
- package/dist/lib/mesh/live/emit-retry.js +57 -4
- package/dist/lib/mesh/live/emit.js +25 -4
- package/dist/lib/mesh/live/flush.d.ts +2 -0
- package/dist/lib/mesh/live/flush.js +21 -8
- package/dist/lib/mesh/live/spool.d.ts +9 -1
- package/dist/lib/mesh/live/spool.js +41 -29
- 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 +11 -1
- package/dist/lib/sync-core/rollout-state.js +40 -4
- package/dist/lib/vault-sync-switches.d.ts +14 -0
- package/dist/lib/vault-sync-switches.js +22 -0
- package/dist/lib/windows/jq.d.ts +4 -0
- package/dist/lib/windows/jq.js +10 -39
- package/dist/lib/workers-registry/index.d.ts +1 -1
- package/dist/lib/workers-registry/index.js +8 -12
- package/dist/utils/callback-port-busy.d.ts +2 -2
- package/dist/utils/callback-port-busy.js +2 -2
- package/dist/utils/cli-network-lifecycle.js +1 -0
- package/dist/utils/client-health-contract.d.ts +2 -0
- package/dist/utils/client-health-contract.js +1 -1
- package/dist/utils/client-health.js +1 -9
- package/dist/utils/cognito-config.js +5 -0
- package/dist/utils/cognito-session.d.ts +4 -6
- package/dist/utils/cognito-session.js +4 -24
- package/dist/utils/github-tag-fallback.d.ts +16 -0
- package/dist/utils/github-tag-fallback.js +126 -0
- package/dist/utils/incomplete-install-error.js +1 -11
- package/dist/utils/install-tree-torn.d.ts +11 -0
- package/dist/utils/install-tree-torn.js +1 -1
- package/dist/utils/resident-package-preload.js +2 -1
- package/dist/utils/version-report.d.ts +2 -1
- package/dist/utils/version-report.js +40 -27
- package/docs/anywhere-runtime.md +8 -0
- package/package.json +9 -9
|
@@ -14,6 +14,8 @@ import { resolveLiveRoot } from "../utils/hq-roots.js";
|
|
|
14
14
|
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
|
+
import { delegateBoardPath, delegateRepoDirectory, secretsSourcePaths } from "../lib/core-utils/delegate-helper-paths.js";
|
|
18
|
+
import { raiseAccessRefresh } from "../lib/sync-core/access-refresh.js";
|
|
17
19
|
export const CORE_NATIVE_DELEGATE_FLAG = "core-native-delegate";
|
|
18
20
|
const SCRIPT_ASSETS = {
|
|
19
21
|
resolve: "core/scripts/hq-delegate-resolve.sh",
|
|
@@ -54,8 +56,8 @@ const USAGE_TEXT = {
|
|
|
54
56
|
// Preserve the companion usage function’s historical raw source lines.
|
|
55
57
|
pickup: "# hq-core: public\n# hq-delegate-pickup.sh — close the delegation loop with a receipt or a FAILED\n# state (2026-09-07).\n#\n# Why: the delegate pipeline ended at \"sent\", which is a send receipt, not a\n# delivery receipt. Seven delegations sat at sent/building with no way to tell\n# whether the recipient could act. This script adds the two missing states:\n#\n# sent --(evidence)--> picked-up recipient demonstrably has the work\n# sent --(silence past window)--> failed nobody picked it up; sender is told why\n#\n# Evidence, checked in order (any one suffices):\n# 1. --ack \"<text>\" an explicit acknowledgement (DM reply, chat) —\n# recorded verbatim with a timestamp\n# 2. repo branch has a commit by the recipient after sentAt\n# (manifest.repo.path + repo.branch, author email == to.principal)\n# 3. --evidence \"<free text>\" any other proof the operator observed\n#\n# Usage:\n# hq-delegate-pickup.sh --manifest <path> --ack \"<text>\" # record receipt\n# hq-delegate-pickup.sh --manifest <path> --evidence \"<text>\" # record receipt\n# hq-delegate-pickup.sh --manifest <path> --check [--window-hours N] # probe repo; fail if silent past window (default 72)\n# hq-delegate-pickup.sh --manifest <path> --status # print state line\n#\n# Exit 0: picked-up (or already). Exit 5: failed (window elapsed, no evidence).\n# Exit 6: still waiting (inside window, no evidence). Exit 2: usage/precondition.\nset -uo pipefail\n",
|
|
56
58
|
repo: "hq-delegate-repo.sh — code/branch handover for a delegation: make sure the\nproject's branch exists on the remote, record uncommitted work as NOT\ntransferred, and verify the recipient's repository access read-only.\n\nUsage:\n core/scripts/hq-delegate-repo.sh --manifest <path> [--yes] [--github-user <login>]\n\nBehavior (driven by the manifest's repo{} block; no-op when repo is null):\n - records remote URL and the branch's headSha into the manifest\n - a branch that exists only locally requires confirmation: without --yes\n the helper prints the plan and exits 2; with --yes it pushes via an\n explicitly anchored `git -C <abs path> push -u origin <branch>`\n - dirty/untracked files are captured into repo.dirtyFiles[] and appended\n to BRIEF.md as work NOT transferred — never silently dropped\n - recipient access is checked read-only via gh when --github-user is\n given; otherwise (or on a gh failure) repo.accessVerified stays false\n and the brief says so plainly — the helper never claims unverified access\n - never touches vaultPrefixes[] and never pushes repo content to the vault\n\nEnv: HQ_ROOT — HQ root override (default: resolved from script location)\n",
|
|
57
|
-
secrets: "hq-delegate-secrets.sh — grant a delegation recipient access to the secrets\na project needs, BY NAME ONLY. No command in this helper ever reads,\nprints, logs, or interpolates a secret value.\n\nUsage:\n core/scripts/hq-delegate-secrets.sh --manifest <path> [--yes] [--no-secrets]\n [--env-schema <path>]\n\nBehavior:\n - derives required secret NAMES from the project's
|
|
58
|
-
transfer: "hq-delegate-transfer.sh — make a delegation real everywhere HQ tracks\nownership: board entry, PRD metadata, work mesh, and the project journal.\n\nUsage:\n core/scripts/hq-delegate-transfer.sh --manifest <path>\n\nBehavior (mode \"transfer\"; mode \"share\" skips every mutation):\n 1. companies/<co>/board.json — the project's entry gets owner=<recipient>\n and a bumped updated_at; created (once) if absent. A brainstorm-stage\n entry (status exploring, brainstorm_path set) is matched by\n brainstorm_path and keeps its status.\n 2. prd.json metadata gains owner, delegatedFrom, delegatedAt; for a\n brainstorm-stage project the same three keys land in the\n brainstorm.md frontmatter (owner, delegated_from, delegated_at)\n 3. work-mesh: `
|
|
59
|
+
secrets: "hq-delegate-secrets.sh — grant a delegation recipient access to the secrets\na project needs, BY NAME ONLY. No command in this helper ever reads,\nprints, logs, or interpolates a secret value.\n\nUsage:\n core/scripts/hq-delegate-secrets.sh --manifest <path> [--yes] [--no-secrets]\n [--env-schema <path>]\n\nBehavior:\n - derives required secret NAMES from, in order: --env-schema, the project\n folder's .env.schema, prd.json metadata.secrets, then the repo's\n .env.schema (the widest source, used only when the project declares\n nothing); no source -> records secrets: [] and says so plainly rather\n than guessing at credentials. The plan output names the source.\n - before sharing anything, every name is checked against\n `hq secrets list --company <co>` (names only); one missing name aborts\n the whole step with nothing shared\n - without --yes: prints a full-prose confirmation listing every name and\n the principal, then exits 2 granting nothing — this step is a privilege\n handover and gets its own confirmation, separate from the file grants\n - with --yes: hq secrets --company <co> share <NAME> --with <principal>\n --permission read (agent/person uids use the grant step's grantPrincipal)\n",
|
|
60
|
+
transfer: "hq-delegate-transfer.sh — make a delegation real everywhere HQ tracks\nownership: board entry, PRD metadata, work mesh, and the project journal.\n\nUsage:\n core/scripts/hq-delegate-transfer.sh --manifest <path>\n\nBehavior (mode \"transfer\"; mode \"share\" skips every mutation):\n 1. companies/<co>/board.json — the project's entry gets owner=<recipient>\n and a bumped updated_at; created (once) if absent. A brainstorm-stage\n entry (status exploring, brainstorm_path set) is matched by\n brainstorm_path and keeps its status.\n 2. prd.json metadata gains owner, delegatedFrom, delegatedAt; for a\n brainstorm-stage project the same three keys land in the\n brainstorm.md frontmatter (owner, delegated_from, delegated_at)\n 3. work-mesh: a thread note broadcasts the reassignment and\n `hq mesh project reassign` transfers project ownership and the\n delegator's open stories; manifest workMeshOwnership becomes\n \"confirmed\" only on a server receipt naming the recipient. Silently\n skipped when hq is unavailable — the transfer still succeeds\n 4. a dated \"Delegated\" stanza is appended to the project journal naming\n the recipient, delegation id, and transferred scope\n\nIdempotent: re-running updates owner/timestamps in place — never a\n",
|
|
59
61
|
};
|
|
60
62
|
function usage(name) {
|
|
61
63
|
return USAGE_TEXT[name];
|
|
@@ -504,6 +506,7 @@ function runPickup(args, context) {
|
|
|
504
506
|
pickedUpAt: now,
|
|
505
507
|
pickup: { kind, detail, recordedAt: now },
|
|
506
508
|
}, true);
|
|
509
|
+
raiseAccessRefresh({ companySlug: jqRawPath(document, "company") });
|
|
507
510
|
writeOut(`hq-delegate-pickup: ${name} picked up the delegation (${kind}) — status advanced to 'picked-up'\n`);
|
|
508
511
|
return 0;
|
|
509
512
|
};
|
|
@@ -663,8 +666,8 @@ function runRepo(args, context) {
|
|
|
663
666
|
writeErr(`${prefix} manifest repo block has no path\n`);
|
|
664
667
|
return 1;
|
|
665
668
|
}
|
|
666
|
-
const repoDir =
|
|
667
|
-
const gitDir =
|
|
669
|
+
const repoDir = delegateRepoDirectory(root, repoRel);
|
|
670
|
+
const gitDir = `${repoDir}/.git`;
|
|
668
671
|
let isGitDir = false;
|
|
669
672
|
try {
|
|
670
673
|
isGitDir = fs.statSync(gitDir).isDirectory();
|
|
@@ -787,6 +790,48 @@ function updateSecretsManifest(file, document, names, skipped, grantedAt) {
|
|
|
787
790
|
document.secretsGrantedAt = grantedAt;
|
|
788
791
|
writeJsonAtomically(file, document);
|
|
789
792
|
}
|
|
793
|
+
export { delegateBoardPath, delegateRepoDirectory, secretsSourcePaths };
|
|
794
|
+
const SECRET_NAME_PATTERN = /^[A-Z][A-Z0-9_]*(\/[A-Z][A-Z0-9_]+)*$/;
|
|
795
|
+
/**
|
|
796
|
+
* The principal `hq secrets share` accepts for this recipient. Secret ACLs
|
|
797
|
+
* take an email, grp_<id>, out_<id> or @all, so an agent or person uid shares
|
|
798
|
+
* through the principal the grant step recorded: the per-agent delegation
|
|
799
|
+
* group for an agent, the mapped email for a person uid. Empty when none is
|
|
800
|
+
* recorded, so the caller refuses before any share.
|
|
801
|
+
*/
|
|
802
|
+
function secretSharePrincipal(principal, document) {
|
|
803
|
+
if (!principal.startsWith("agt_") && !principal.startsWith("prs_"))
|
|
804
|
+
return principal;
|
|
805
|
+
const recorded = jqRawPath(document, "grantPrincipal").replaceAll("\r", "");
|
|
806
|
+
if (principal.startsWith("agt_") && recorded.startsWith("grp_dlg"))
|
|
807
|
+
return recorded;
|
|
808
|
+
if (principal.startsWith("prs_") && /^.+@.+$/s.test(recorded))
|
|
809
|
+
return recorded;
|
|
810
|
+
return "";
|
|
811
|
+
}
|
|
812
|
+
/** prd.json metadata.secrets names, one per line as `jq -r` prints them, sorted and unique. */
|
|
813
|
+
function prdSecretNames(entries) {
|
|
814
|
+
const lines = [];
|
|
815
|
+
for (const entry of entries) {
|
|
816
|
+
const value = isRecord(entry) ? entry.name : entry;
|
|
817
|
+
if (isRecord(entry) && (value === undefined || value === null || value === false))
|
|
818
|
+
continue;
|
|
819
|
+
if (typeof value === "string")
|
|
820
|
+
lines.push(...value.split("\n"));
|
|
821
|
+
else
|
|
822
|
+
lines.push(JSON.stringify(value) ?? "null");
|
|
823
|
+
}
|
|
824
|
+
return [...new Set(lines)].sort();
|
|
825
|
+
}
|
|
826
|
+
function readableSchemaNames(file) {
|
|
827
|
+
try {
|
|
828
|
+
fs.accessSync(file, fs.constants.R_OK);
|
|
829
|
+
}
|
|
830
|
+
catch {
|
|
831
|
+
return undefined;
|
|
832
|
+
}
|
|
833
|
+
return scanSecretFiles(file);
|
|
834
|
+
}
|
|
790
835
|
function runSecrets(args, context) {
|
|
791
836
|
const loaded = existingManifest("secrets", args, context);
|
|
792
837
|
if (loaded.code !== undefined)
|
|
@@ -797,85 +842,148 @@ function runSecrets(args, context) {
|
|
|
797
842
|
throw new TypeError("Cannot read secrets from a non-object delegation manifest");
|
|
798
843
|
const options = loaded.parsed.values;
|
|
799
844
|
const prefix = "hq-delegate-secrets:";
|
|
845
|
+
const die = (message) => { writeErr(`${prefix} ${message}\n`); return 1; };
|
|
800
846
|
const company = jqRawPath(document, "company");
|
|
801
847
|
const principal = jqRawPath(document, "to.principal");
|
|
802
848
|
const project = jqRawPath(document, "project.name");
|
|
803
|
-
if (!company)
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
writeErr(`${prefix} manifest has no to.principal\n`);
|
|
809
|
-
return 1;
|
|
810
|
-
}
|
|
849
|
+
if (!company)
|
|
850
|
+
return die("manifest has no company");
|
|
851
|
+
if (!principal)
|
|
852
|
+
return die("manifest has no to.principal");
|
|
853
|
+
const sharePrincipal = secretSharePrincipal(principal, document);
|
|
811
854
|
if (options.noSecrets) {
|
|
812
855
|
updateSecretsManifest(file, document, [], true);
|
|
813
856
|
writeOut(`${prefix} skipped (--no-secrets) — no credential access granted\n`);
|
|
814
857
|
return 0;
|
|
815
858
|
}
|
|
816
|
-
|
|
817
|
-
|
|
859
|
+
// Narrowest declaration first: --env-schema, the project's .env.schema,
|
|
860
|
+
// prd.json metadata.secrets, then the repo's .env.schema, which names
|
|
861
|
+
// everything the whole repo needs and is used only when the project
|
|
862
|
+
// declares nothing. An unreadable schema stops the step; it never falls
|
|
863
|
+
// through to a wider source.
|
|
864
|
+
const { projectSchema, prdFile, repoSchema } = secretsSourcePaths(context.root, company, project, jqRawPath(document, "repo.path"));
|
|
865
|
+
const envSchema = String(options.envSchema ?? "");
|
|
866
|
+
let sourceKind = "";
|
|
867
|
+
let sourcePath = "";
|
|
868
|
+
let readPath = "";
|
|
869
|
+
let names = [];
|
|
870
|
+
let prdEntries;
|
|
871
|
+
if (!envSchema && !isRegularFile(projectSchema) && isRegularFile(prdFile)) {
|
|
872
|
+
try {
|
|
873
|
+
const prd = readJsonFile(prdFile);
|
|
874
|
+
const declared = isRecord(prd) && isRecord(prd.metadata) ? prd.metadata.secrets : undefined;
|
|
875
|
+
if (Array.isArray(declared) && declared.length > 0)
|
|
876
|
+
prdEntries = declared;
|
|
877
|
+
}
|
|
878
|
+
catch { /* an unreadable or invalid prd.json declares nothing, as jq -e reports */ }
|
|
879
|
+
}
|
|
818
880
|
if (envSchema) {
|
|
819
|
-
|
|
820
|
-
if (isRegularFile(
|
|
821
|
-
|
|
881
|
+
readPath = path.resolve(context.cwd, envSchema);
|
|
882
|
+
if (!isRegularFile(readPath))
|
|
883
|
+
return die(`--env-schema not found: ${envSchema}`);
|
|
884
|
+
sourceKind = "--env-schema";
|
|
885
|
+
sourcePath = envSchema;
|
|
886
|
+
}
|
|
887
|
+
else if (isRegularFile(projectSchema)) {
|
|
888
|
+
sourceKind = "project .env.schema";
|
|
889
|
+
sourcePath = projectSchema;
|
|
890
|
+
readPath = projectSchema;
|
|
891
|
+
}
|
|
892
|
+
else if (prdEntries) {
|
|
893
|
+
sourceKind = "prd.json metadata.secrets";
|
|
894
|
+
sourcePath = prdFile;
|
|
895
|
+
const lines = prdSecretNames(prdEntries);
|
|
896
|
+
const bad = lines.filter((line) => line !== "" && !SECRET_NAME_PATTERN.test(line));
|
|
897
|
+
if (bad.length > 0) {
|
|
898
|
+
return die(`prd.json metadata.secrets has an entry that is not a secret name: ${bad.join(" ")}— nothing granted`);
|
|
899
|
+
}
|
|
900
|
+
names = lines.filter((line) => line !== "");
|
|
822
901
|
}
|
|
823
902
|
else {
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
903
|
+
if (repoSchema && isRegularFile(repoSchema)) {
|
|
904
|
+
sourceKind = "repo .env.schema";
|
|
905
|
+
sourcePath = repoSchema;
|
|
906
|
+
readPath = repoSchema;
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
if (readPath) {
|
|
910
|
+
const scanned = readableSchemaNames(readPath);
|
|
911
|
+
if (scanned === undefined) {
|
|
912
|
+
writeErr(`${prefix} cannot read ${sourcePath} — nothing granted\n`);
|
|
913
|
+
return 2;
|
|
914
|
+
}
|
|
915
|
+
if (scanned.length === 0) {
|
|
916
|
+
// The shell's pipefail exits on grep's status 1 before its empty-name
|
|
917
|
+
// handling branch; leave the manifest untouched to retain that behavior.
|
|
918
|
+
return 1;
|
|
838
919
|
}
|
|
920
|
+
names = scanned;
|
|
839
921
|
}
|
|
840
|
-
if (!
|
|
922
|
+
if (!sourcePath) {
|
|
841
923
|
updateSecretsManifest(file, document, [], false);
|
|
842
|
-
writeOut(`${prefix} no .env.schema found for this project or its repo — no secret names to grant. If the project needs credentials, add
|
|
924
|
+
writeOut(`${prefix} no .env.schema found for this project or its repo, and prd.json declares no metadata.secrets — no secret names to grant. If the project needs credentials, add a project .env.schema (or prd.json metadata.secrets) and re-run, or grant them manually with 'hq secrets share'.\n`);
|
|
843
925
|
return 0;
|
|
844
926
|
}
|
|
845
927
|
if (names.length === 0) {
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
return
|
|
928
|
+
updateSecretsManifest(file, document, [], false);
|
|
929
|
+
writeOut(`${prefix} ${sourcePath} declares no secret names — nothing to grant\n`);
|
|
930
|
+
return 0;
|
|
849
931
|
}
|
|
850
|
-
const schemaName = path.basename(
|
|
932
|
+
const schemaName = path.basename(sourcePath);
|
|
851
933
|
writeOut("Secret access handover — this grants the recipient the ability to use these credentials.\n\n");
|
|
934
|
+
writeOut(`Source: ${sourceKind} (${sourcePath})\n`);
|
|
935
|
+
if (sourceKind === "repo .env.schema") {
|
|
936
|
+
writeOut("The project declares no secrets of its own, so the repo-wide schema is used. Narrow it with a project .env.schema or prd.json metadata.secrets if the lane needs fewer.\n");
|
|
937
|
+
}
|
|
938
|
+
writeOut("\n");
|
|
852
939
|
writeOut(`The following ${names.length} secret name(s), declared by ${schemaName} for project '${project}', will be shared with read permission to '${principal}' in company '${company}':\n\n`);
|
|
853
940
|
writeOut(`${names.map((name) => ` - ${name}`).join("\n")}\n\n`);
|
|
941
|
+
if (sharePrincipal !== principal) {
|
|
942
|
+
if (sharePrincipal)
|
|
943
|
+
writeOut(`Access flows through '${sharePrincipal}', the principal the grant step resolved for '${principal}'.\n`);
|
|
944
|
+
else
|
|
945
|
+
writeOut(`Access will flow through the principal the grant step records for '${principal}' (run hq-delegate-grant.sh --yes first).\n`);
|
|
946
|
+
writeOut("\n");
|
|
947
|
+
}
|
|
854
948
|
writeOut("Only the names are granted and recorded; no secret value is read, printed, or transmitted by this step. The recipient consumes them through 'hq run' / 'hq secrets exec'.\n");
|
|
855
949
|
if (!options.yes) {
|
|
856
950
|
writeOut("\n");
|
|
857
951
|
writeErr(`${prefix} confirmation required — re-run with --yes after the user approves (or --no-secrets to skip)\n`);
|
|
858
952
|
return 2;
|
|
859
953
|
}
|
|
954
|
+
if (!sharePrincipal) {
|
|
955
|
+
return die(`recipient '${principal}' cannot be a secret-ACL principal and the manifest has no usable grantPrincipal — run hq-delegate-grant.sh --yes first; nothing granted`);
|
|
956
|
+
}
|
|
957
|
+
// Every name must exist in the company vault before any share runs, so a
|
|
958
|
+
// typo or an undeclared secret never leaves a partial grant behind. Names
|
|
959
|
+
// only: `hq secrets list` prints no values.
|
|
960
|
+
const listed = subprocess("hq", ["secrets", "list", "--company", company], context.cwd, { stderr: "ignore" });
|
|
961
|
+
if (listed.code !== 0) {
|
|
962
|
+
return die(`could not list secret names for company '${company}' (hq secrets list failed) — nothing granted`);
|
|
963
|
+
}
|
|
964
|
+
const listedNames = new Set((listed.stdout ?? "").split("\n").map((line) => line.trim().split(/[ \t]+/)[0] ?? "").filter(Boolean));
|
|
965
|
+
const missing = names.filter((name) => !listedNames.has(name));
|
|
966
|
+
if (missing.length > 0) {
|
|
967
|
+
return die(`these name(s) from ${sourceKind} do not exist in company '${company}':${missing.map((name) => ` ${name}`).join("")} — nothing granted; add them with 'hq secrets set' or remove them from ${sourcePath}, then re-run`);
|
|
968
|
+
}
|
|
860
969
|
const namesDir = fs.mkdtempSync(path.join(os.tmpdir(), "hq-delegate-secret-names-"));
|
|
861
970
|
const namesFile = path.join(namesDir, "names");
|
|
862
971
|
let namesFd;
|
|
863
972
|
try {
|
|
864
973
|
// The shell's `while read` and each hq child share the same input stream.
|
|
865
974
|
// A child that reads stdin advances the next loop read just as it does in
|
|
866
|
-
// the
|
|
975
|
+
// the staging script; normal hq commands leave the name stream untouched.
|
|
867
976
|
fs.writeFileSync(namesFile, `${names.join("\n")}\n`, { mode: 0o600 });
|
|
868
977
|
namesFd = fs.openSync(namesFile, "r");
|
|
869
978
|
let name = readLineFromFd(namesFd);
|
|
870
979
|
while (name !== undefined) {
|
|
871
|
-
const share = subprocess("hq", ["secrets", "share", name, "--with",
|
|
980
|
+
const share = subprocess("hq", ["secrets", "--company", company, "share", name, "--with", sharePrincipal, "--permission", "read"], context.cwd, { stdinFd: namesFd, stdout: "inherit" });
|
|
872
981
|
if (share.code !== 0) {
|
|
873
982
|
if (share.stderr)
|
|
874
983
|
writeErr(share.stderr);
|
|
875
|
-
|
|
876
|
-
return 1;
|
|
984
|
+
return die(`failed to grant '${name}' to '${sharePrincipal}' — aborting; manifest not updated`);
|
|
877
985
|
}
|
|
878
|
-
writeOut(`${prefix} granted read on '${name}' to '${
|
|
986
|
+
writeOut(`${prefix} granted read on '${name}' to '${sharePrincipal}'\n`);
|
|
879
987
|
name = readLineFromFd(namesFd);
|
|
880
988
|
}
|
|
881
989
|
}
|
|
@@ -889,6 +997,53 @@ function runSecrets(args, context) {
|
|
|
889
997
|
writeOut(`${prefix} ${names.length} secret name(s) granted and recorded (names only)\n`);
|
|
890
998
|
return 0;
|
|
891
999
|
}
|
|
1000
|
+
/**
|
|
1001
|
+
* Move Work Mesh project ownership and the delegator's open stories to the
|
|
1002
|
+
* recipient with `hq mesh project reassign`. "confirmed" only when the server
|
|
1003
|
+
* names the recipient as owner; "not-registered" when the project has no
|
|
1004
|
+
* board; otherwise "unconfirmed" and the transfer continues.
|
|
1005
|
+
*/
|
|
1006
|
+
function reassignMeshProject(document, prd, company, project, delegationId, context, prefix) {
|
|
1007
|
+
let toUid = jqRawPaths(document, ["to.uid", "to.personUid", "to.agentUid", "to.principal"]);
|
|
1008
|
+
let meshProject = project;
|
|
1009
|
+
if (prd !== undefined) {
|
|
1010
|
+
const metadata = isRecord(prd) && isRecord(prd.metadata) ? prd.metadata : {};
|
|
1011
|
+
for (const key of ["workMeshProjectId", "projectId"]) {
|
|
1012
|
+
if (jqTruthy(metadata[key])) {
|
|
1013
|
+
meshProject = rawJsonValue(metadata[key]);
|
|
1014
|
+
break;
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
// The mesh directory matches uids, not emails: look up the personUid from
|
|
1019
|
+
// company membership first, and pass the email through if that fails.
|
|
1020
|
+
if (toUid.includes("@")) {
|
|
1021
|
+
const resolved = subprocess("hq", ["people", "resolve", toUid, "--company", company, "--membership-only", "--json"], context.cwd, { stderr: "ignore" });
|
|
1022
|
+
try {
|
|
1023
|
+
const body = readJsonText(resolved.stdout ?? "");
|
|
1024
|
+
const uid = isRecord(body) && body.status === "found" && isRecord(body.person) ? body.person.personUid : undefined;
|
|
1025
|
+
if (typeof uid === "string" && uid.startsWith("prs_"))
|
|
1026
|
+
toUid = uid;
|
|
1027
|
+
}
|
|
1028
|
+
catch { /* not found or not JSON: keep the email */ }
|
|
1029
|
+
}
|
|
1030
|
+
const reassign = subprocess("hq", ["mesh", "project", "reassign", meshProject, "--company", company, "--to", toUid, "--include-open-stories", "--note", `Delegated via /delegate (${delegationId})`, "--json"], context.cwd, { stderr: "pipe" });
|
|
1031
|
+
let confirmed = false;
|
|
1032
|
+
try {
|
|
1033
|
+
const body = readJsonText(reassign.stdout ?? "");
|
|
1034
|
+
const owner = isRecord(body) && typeof body.ownerUid === "string" ? body.ownerUid : "";
|
|
1035
|
+
confirmed = isRecord(body) && body.ok !== false && owner !== "" && (owner === toUid || toUid.includes("@"));
|
|
1036
|
+
}
|
|
1037
|
+
catch { /* no JSON answer: not confirmed */ }
|
|
1038
|
+
if (confirmed)
|
|
1039
|
+
return "confirmed";
|
|
1040
|
+
if (/PROJECT_(VIEW|THREAD)_NOT_FOUND/.test(`${reassign.stdout ?? ""}\n${reassign.stderr ?? ""}`)) {
|
|
1041
|
+
writeErr(`${prefix} project ${meshProject} has no Work Mesh board; local ownership is authoritative; nothing to reassign. To track it on the board, register it with \`hq mesh project register\` (see \`hq mesh project --help\`)\n`);
|
|
1042
|
+
return "not-registered";
|
|
1043
|
+
}
|
|
1044
|
+
writeErr(`${prefix} hq mesh project reassign did not confirm; Work Mesh ownership remains unconfirmed\n`);
|
|
1045
|
+
return "unconfirmed";
|
|
1046
|
+
}
|
|
892
1047
|
function runTransfer(args, context) {
|
|
893
1048
|
const loaded = existingManifest("transfer", args, context);
|
|
894
1049
|
if (loaded.code !== undefined)
|
|
@@ -938,7 +1093,7 @@ function runTransfer(args, context) {
|
|
|
938
1093
|
const brainstormPath = `companies/${company}/projects/${project}/brainstorm.md`;
|
|
939
1094
|
const brainstormAbs = path.join(root, brainstormPath);
|
|
940
1095
|
const projectDir = path.join(root, "companies", company, "projects", project);
|
|
941
|
-
const board =
|
|
1096
|
+
const board = delegateBoardPath(root, company);
|
|
942
1097
|
if (stage !== "prd" && stage !== "brainstorm") {
|
|
943
1098
|
writeErr(`${prefix} manifest project.stage is '${stage}' — expected prd or brainstorm\n`);
|
|
944
1099
|
return 1;
|
|
@@ -1013,11 +1168,17 @@ function runTransfer(args, context) {
|
|
|
1013
1168
|
brainstormFrontmatterSet(brainstormAbs, "delegated_from", from);
|
|
1014
1169
|
brainstormFrontmatterSet(brainstormAbs, "delegated_at", now);
|
|
1015
1170
|
}
|
|
1171
|
+
let meshOwnership = "unconfirmed";
|
|
1016
1172
|
if (commandExists("hq", context.cwd)) {
|
|
1017
|
-
|
|
1173
|
+
// The mesh keys session ownership on (company, sessionId). A shared
|
|
1174
|
+
// literal is owned by whoever delegated first in the company, and every
|
|
1175
|
+
// later delegator is rejected with SESSION_OWNER_MISMATCH, so the session
|
|
1176
|
+
// id is unique per delegation.
|
|
1177
|
+
const sessionId = process.env.HQ_SESSION_ID || delegationId;
|
|
1018
1178
|
const mesh = subprocess("hq", ["mesh", "session", "note", "--enqueue", "--session-id", sessionId, "--seq", "1", "--harness", "claude-code", "--adapter-version", "1.0.0", "--company-slug", company, "--project", project, "--summary", `Delegated to ${display} (${principal}) — delegation ${delegationId}; ownership transferred`], context.cwd, { stdout: "inherit" });
|
|
1019
1179
|
if (mesh.code !== 0)
|
|
1020
1180
|
writeErr(`${prefix} mesh note failed; authoritative mesh ownership remains unconfirmed\n`);
|
|
1181
|
+
meshOwnership = reassignMeshProject(document, stage === "prd" ? prd : undefined, company, project, delegationId, context, prefix);
|
|
1021
1182
|
}
|
|
1022
1183
|
const journalDir = path.join(projectDir, "journal");
|
|
1023
1184
|
const journal = path.join(journalDir, "delegations.md");
|
|
@@ -1030,16 +1191,16 @@ function runTransfer(args, context) {
|
|
|
1030
1191
|
const vaultPrefixes = Array.isArray(prefixesValue) ? prefixesValue : [];
|
|
1031
1192
|
const scope = vaultPrefixes.map((entry) => jqRawPath(entry, "prefix")).join(", ");
|
|
1032
1193
|
const ownershipLine = stage === "prd"
|
|
1033
|
-
?
|
|
1034
|
-
:
|
|
1194
|
+
? `Local board and PRD ownership updated; Work Mesh ownership is ${meshOwnership}. Existing delegator access is unchanged.`
|
|
1195
|
+
: `Brainstorm-stage project (no PRD yet). Local board and brainstorm.md ownership updated; Work Mesh ownership is ${meshOwnership}. Existing delegator access is unchanged.`;
|
|
1035
1196
|
fs.appendFileSync(journal, `\n## ${today} — Delegated to ${display}\n\n- Delegation: \`${delegationId}\`\n- From: ${from}\n- To: ${display} (${principal})\n- Transferred scope: ${scope}\n- ${ownershipLine}\n`);
|
|
1036
1197
|
}
|
|
1037
1198
|
document.ownershipTransferredAt = now;
|
|
1038
|
-
document.workMeshOwnership =
|
|
1199
|
+
document.workMeshOwnership = meshOwnership;
|
|
1039
1200
|
writeJsonAtomically(file, document);
|
|
1040
1201
|
const sourceLabel = stage === "prd" ? "PRD" : "brainstorm.md";
|
|
1041
1202
|
const stageLabel = stage === "prd" ? "" : " (brainstorm stage)";
|
|
1042
|
-
writeOut(`${prefix} ownership of '${project}'${stageLabel} transferred to ${display} (${principal}) — local board, ${sourceLabel}, and journal updated; Work Mesh ownership
|
|
1203
|
+
writeOut(`${prefix} ownership of '${project}'${stageLabel} transferred to ${display} (${principal}) — local board, ${sourceLabel}, and journal updated; Work Mesh ownership ${meshOwnership}\n`);
|
|
1043
1204
|
return 0;
|
|
1044
1205
|
}
|
|
1045
1206
|
function runNativeUnlocked(name, args, context) {
|
|
@@ -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
|