@indigoai-us/hq-cli 5.345.214 → 5.345.215
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 +93 -0
- package/assets/scaffold/core/scripts/hq-delegate-verify.sh +5 -2
- package/dist/command-catalog.generated.d.ts +180 -13
- package/dist/command-catalog.generated.js +221 -13
- package/dist/commands/agents.d.ts +51 -1
- package/dist/commands/agents.js +154 -2
- package/dist/commands/bot-jobs.d.ts +2 -15
- package/dist/commands/bot-jobs.js +2 -94
- package/dist/commands/bot-runtime.d.ts +46 -5
- package/dist/commands/bot-runtime.js +228 -18
- package/dist/commands/bot.d.ts +16 -9
- package/dist/commands/bot.js +231 -55
- package/dist/commands/capacity.d.ts +4 -1
- package/dist/commands/capacity.js +46 -10
- package/dist/commands/cloud.d.ts +66 -13
- package/dist/commands/cloud.js +121 -40
- package/dist/commands/company-restore.d.ts +23 -0
- package/dist/commands/company-restore.js +128 -0
- package/dist/commands/company.js +2 -0
- package/dist/commands/core-delegate-w1b.js +15 -1
- package/dist/commands/core-policy.js +67 -8
- package/dist/commands/daemon.js +5 -0
- package/dist/commands/files-browse.d.ts +11 -4
- package/dist/commands/files-browse.js +21 -4
- package/dist/commands/files.d.ts +1 -1
- package/dist/commands/files.js +25 -11
- package/dist/commands/integrations-auth-rules.d.ts +27 -0
- package/dist/commands/integrations-auth-rules.js +79 -0
- package/dist/commands/integrations-connect.d.ts +10 -3
- package/dist/commands/integrations-connect.js +87 -13
- package/dist/commands/integrations-import.js +124 -12
- package/dist/commands/lanes.js +28 -11
- package/dist/commands/mesh.d.ts +2 -0
- package/dist/commands/mesh.js +60 -35
- package/dist/commands/sources.js +6 -0
- package/dist/commands/storage-offload.d.ts +12 -0
- package/dist/commands/storage-offload.js +41 -3
- package/dist/commands/sync-held.js +5 -2
- package/dist/commands/sync-mode.js +5 -0
- package/dist/commands/whoami.js +4 -0
- package/dist/lazy-commands.js +3 -5
- package/dist/lib/bot/config.d.ts +1 -0
- package/dist/lib/bot/config.js +10 -0
- package/dist/lib/bot/eventbridge-cron.d.ts +22 -0
- package/dist/lib/bot/eventbridge-cron.js +104 -0
- package/dist/lib/bot/fleet-cron.d.ts +8 -0
- package/dist/lib/bot/fleet-cron.js +35 -3
- package/dist/lib/bot/fleet-daemon.d.ts +46 -0
- package/dist/lib/bot/fleet-daemon.js +99 -1
- package/dist/lib/bot/fleet-local.d.ts +33 -1
- package/dist/lib/bot/fleet-local.js +215 -31
- package/dist/lib/bot/fleet-python.d.ts +3 -0
- package/dist/lib/bot/fleet-python.js +34 -4
- package/dist/lib/bot/fleet-runtime-sources.d.ts +15 -0
- package/dist/lib/bot/fleet-runtime-sources.js +30 -0
- package/dist/lib/bot/legacy-provider-login.d.ts +8 -0
- package/dist/lib/bot/legacy-provider-login.js +19 -2
- package/dist/lib/bot/probe.js +7 -1
- package/dist/lib/bot/prompt.js +1 -1
- package/dist/lib/bot/readiness.d.ts +8 -0
- package/dist/lib/bot/readiness.js +17 -3
- package/dist/lib/bot/run.js +20 -1
- package/dist/lib/bot/runtime/codex.js +1 -1
- package/dist/lib/bot/runtime/grok-acp.d.ts +5 -1
- package/dist/lib/bot/runtime/grok-acp.js +6 -3
- package/dist/lib/bot/runtime/index.js +19 -9
- package/dist/lib/bot/runtime/messages-stream.js +2 -2
- package/dist/lib/bot/runtime/types.d.ts +15 -0
- package/dist/lib/bot/runtime/types.js +9 -0
- package/dist/lib/bot/runtime-auth.d.ts +30 -0
- package/dist/lib/bot/runtime-auth.js +94 -3
- package/dist/lib/bot/runtime-failure.d.ts +23 -0
- package/dist/lib/bot/runtime-failure.js +43 -1
- package/dist/lib/bot/status.d.ts +2 -0
- package/dist/lib/capacity/accounts.d.ts +8 -0
- package/dist/lib/capacity/accounts.js +19 -0
- package/dist/lib/capacity/available.d.ts +154 -0
- package/dist/lib/capacity/available.js +905 -0
- package/dist/lib/capacity/codex-availability.d.ts +14 -1
- package/dist/lib/capacity/codex-availability.js +26 -1
- package/dist/lib/capacity/collectors/claude-oauth.d.ts +29 -2
- package/dist/lib/capacity/collectors/claude-oauth.js +104 -7
- package/dist/lib/capacity/collectors/codex.js +10 -7
- package/dist/lib/capacity/collectors/grok-refresh.d.ts +80 -0
- package/dist/lib/capacity/collectors/grok-refresh.js +189 -0
- package/dist/lib/capacity/collectors/grok.d.ts +5 -0
- package/dist/lib/capacity/collectors/grok.js +56 -5
- package/dist/lib/capacity/ledger.d.ts +37 -1
- package/dist/lib/capacity/ledger.js +207 -30
- package/dist/lib/capacity/project.d.ts +26 -0
- package/dist/lib/capacity/project.js +137 -8
- package/dist/lib/capacity/refusal-rows.d.ts +31 -0
- package/dist/lib/capacity/refusal-rows.js +61 -0
- package/dist/lib/capacity/refusal.d.ts +53 -2
- package/dist/lib/capacity/refusal.js +284 -65
- package/dist/lib/capacity/route.js +46 -11
- package/dist/lib/capacity/widget.d.ts +12 -1
- package/dist/lib/capacity/widget.js +91 -3
- package/dist/lib/daemon/catalog.js +11 -1
- package/dist/lib/daemon/resolver.d.ts +2 -0
- package/dist/lib/daemon/resolver.js +3 -0
- package/dist/lib/daemon/run.d.ts +9 -0
- package/dist/lib/daemon/run.js +54 -1
- package/dist/lib/daemon/server.d.ts +2 -0
- package/dist/lib/daemon/server.js +10 -1
- package/dist/lib/daemon/tcc-eperm.d.ts +153 -0
- package/dist/lib/daemon/tcc-eperm.js +310 -0
- package/dist/lib/db/sqlite-binding.d.ts +1 -0
- package/dist/lib/db/sqlite-binding.js +1 -1
- package/dist/lib/delivery/admission.d.ts +86 -0
- package/dist/lib/delivery/admission.js +148 -0
- package/dist/lib/delivery/artifacts.d.ts +105 -0
- package/dist/lib/delivery/artifacts.js +567 -0
- package/dist/lib/delivery/attempt-id.d.ts +13 -0
- package/dist/lib/delivery/attempt-id.js +16 -0
- package/dist/lib/delivery/backup.d.ts +78 -0
- package/dist/lib/delivery/backup.js +343 -0
- package/dist/lib/delivery/cache.d.ts +29 -0
- package/dist/lib/delivery/cache.js +33 -0
- package/dist/lib/delivery/contracts.d.ts +142 -0
- package/dist/lib/delivery/contracts.js +289 -0
- package/dist/lib/delivery/credentials.d.ts +54 -0
- package/dist/lib/delivery/credentials.js +119 -0
- package/dist/lib/delivery/disposable-target.d.ts +42 -0
- package/dist/lib/delivery/disposable-target.js +111 -0
- package/dist/lib/delivery/effects.d.ts +136 -0
- package/dist/lib/delivery/effects.js +541 -0
- package/dist/lib/delivery/enrollment.d.ts +146 -0
- package/dist/lib/delivery/enrollment.js +460 -0
- package/dist/lib/delivery/escalations.d.ts +51 -0
- package/dist/lib/delivery/escalations.js +60 -0
- package/dist/lib/delivery/identity.d.ts +25 -0
- package/dist/lib/delivery/identity.js +82 -0
- package/dist/lib/delivery/inbox.d.ts +116 -0
- package/dist/lib/delivery/inbox.js +260 -0
- package/dist/lib/delivery/lease.d.ts +80 -0
- package/dist/lib/delivery/lease.js +134 -0
- package/dist/lib/delivery/migrations.d.ts +255 -0
- package/dist/lib/delivery/migrations.js +823 -0
- package/dist/lib/delivery/mqtt-adapter.d.ts +50 -0
- package/dist/lib/delivery/mqtt-adapter.js +242 -0
- package/dist/lib/delivery/mqtt.d.ts +63 -0
- package/dist/lib/delivery/mqtt.js +119 -0
- package/dist/lib/delivery/outbox.d.ts +95 -0
- package/dist/lib/delivery/outbox.js +187 -0
- package/dist/lib/delivery/provenance.d.ts +129 -0
- package/dist/lib/delivery/provenance.js +93 -0
- package/dist/lib/delivery/reconciler.d.ts +215 -0
- package/dist/lib/delivery/reconciler.js +703 -0
- package/dist/lib/delivery/restore.d.ts +35 -0
- package/dist/lib/delivery/restore.js +134 -0
- package/dist/lib/delivery/rpc/client.d.ts +22 -0
- package/dist/lib/delivery/rpc/client.js +159 -0
- package/dist/lib/delivery/rpc/port.d.ts +40 -0
- package/dist/lib/delivery/rpc/port.js +16 -0
- package/dist/lib/delivery/rpc/server.d.ts +30 -0
- package/dist/lib/delivery/rpc/server.js +205 -0
- package/dist/lib/delivery/rpc/wire.d.ts +85 -0
- package/dist/lib/delivery/rpc/wire.js +143 -0
- package/dist/lib/delivery/store.d.ts +163 -0
- package/dist/lib/delivery/store.js +944 -0
- package/dist/lib/delivery/windows-service-install.d.ts +262 -0
- package/dist/lib/delivery/windows-service-install.js +892 -0
- package/dist/lib/delivery/workers/macos-job-helper.d.ts +103 -0
- package/dist/lib/delivery/workers/macos-job-helper.js +927 -0
- package/dist/lib/delivery/workers/macos.d.ts +191 -0
- package/dist/lib/delivery/workers/macos.js +943 -0
- package/dist/lib/delivery/workers/windows-job-helper.d.ts +35 -0
- package/dist/lib/delivery/workers/windows-job-helper.js +264 -0
- package/dist/lib/delivery/workers/windows-service-live.d.ts +121 -0
- package/dist/lib/delivery/workers/windows-service-live.js +711 -0
- package/dist/lib/delivery/workers/windows-service-runner.d.ts +33 -0
- package/dist/lib/delivery/workers/windows-service-runner.js +82 -0
- package/dist/lib/delivery/workers/windows-service.d.ts +140 -0
- package/dist/lib/delivery/workers/windows-service.js +584 -0
- package/dist/lib/delivery/workers/windows.d.ts +251 -0
- package/dist/lib/delivery/workers/windows.js +594 -0
- package/dist/lib/hot-channels/adapters/meetings.d.ts +15 -0
- package/dist/lib/hot-channels/adapters/meetings.js +36 -3
- package/dist/lib/hot-channels/signals-pass.d.ts +10 -0
- package/dist/lib/hot-channels/signals-pass.js +71 -2
- package/dist/lib/hot-channels/signals-redo.js +10 -2
- package/dist/lib/install/provider-wrappers.d.ts +2 -0
- package/dist/lib/install/provider-wrappers.js +68 -3
- package/dist/lib/lanes/watcher.js +35 -0
- package/dist/lib/signals/steps/extract.js +40 -4
- package/dist/schemas/hq-available-ai.v1.schema.json +76 -0
- package/dist/utils/catalog-runtime-paths.d.ts +34 -0
- package/dist/utils/catalog-runtime-paths.js +53 -0
- package/dist/utils/cognito-callback-port.d.ts +14 -0
- package/dist/utils/cognito-callback-port.js +24 -0
- package/dist/utils/cognito-session.js +3 -3
- package/dist/utils/deleted-company-notice.d.ts +59 -0
- package/dist/utils/deleted-company-notice.js +156 -0
- package/dist/utils/files-browse-acl.js +1 -1
- package/dist/utils/login-browser.d.ts +1 -1
- package/dist/utils/login-browser.js +7 -5
- package/dist/utils/resident-package-preload.js +30 -15
- package/dist/utils/vault-api.js +7 -0
- package/package.json +7 -7
|
@@ -16,6 +16,8 @@ export declare class SignalsPassError extends Error {
|
|
|
16
16
|
readonly code: SignalsPassErrorCode;
|
|
17
17
|
/** Signals this pass call had already written before it failed. */
|
|
18
18
|
written: number;
|
|
19
|
+
/** Set on bad output that another call cannot fix, so the document is not sent again. */
|
|
20
|
+
noRetry: boolean;
|
|
19
21
|
constructor(code: SignalsPassErrorCode, message: string);
|
|
20
22
|
}
|
|
21
23
|
/** Signal types the pass accepts; the same type folders existing signals use. */
|
|
@@ -40,6 +42,14 @@ export declare const AUTH_PREFLIGHT_TIMEOUT_MS = 10000;
|
|
|
40
42
|
export declare const WORKLIST_TIMEOUT_MS = 60000;
|
|
41
43
|
/** Documents one pass sends to claude across all adapters of a run. */
|
|
42
44
|
export declare const DEFAULT_MAX_SIGNAL_DOCS = 20;
|
|
45
|
+
/**
|
|
46
|
+
* Claude calls per document when the reply is unusable (`claude-bad-output`).
|
|
47
|
+
* The reply differs from call to call, so a document whose first reply has a
|
|
48
|
+
* JSON syntax error usually parses on the next. Other failures are not retried.
|
|
49
|
+
*/
|
|
50
|
+
export declare const BAD_OUTPUT_ATTEMPTS = 3;
|
|
51
|
+
/** Documents in a row with unusable replies after which the pass stops. */
|
|
52
|
+
export declare const BAD_OUTPUT_STOP_AFTER = 3;
|
|
43
53
|
/** Payload bytes sent to claude per document (200 KB). A longer payload is cut with a marker. */
|
|
44
54
|
export declare const MAX_PAYLOAD_BYTES: number;
|
|
45
55
|
export interface BoundedRun {
|
|
@@ -36,6 +36,16 @@ import { prepareSignalPublication, flushSignalPublications } from "../bot/jobs/s
|
|
|
36
36
|
* cut, to `warn`. The reason stays out of the ledger because the ledger syncs
|
|
37
37
|
* with the company vault. A failed document is never marked done, so a later
|
|
38
38
|
* run picks it up. No account is picked and no other provider is called here.
|
|
39
|
+
*
|
|
40
|
+
* Unusable replies: a document whose reply is `claude-bad-output` is sent
|
|
41
|
+
* again, up to BAD_OUTPUT_ATTEMPTS calls in all. If every reply is unusable the
|
|
42
|
+
* pass leaves that document for a later run, goes on to the next one, and
|
|
43
|
+
* fails with `claude-bad-output` at the end. Every other failure class stops
|
|
44
|
+
* the pass at once, because it would fail the next document the same way. A
|
|
45
|
+
* reply with no stdout is not sent again, and BAD_OUTPUT_STOP_AFTER documents
|
|
46
|
+
* in a row with unusable replies stop the pass, for the same reason. So a run
|
|
47
|
+
* makes at most the document cap (`maxDocs`) × BAD_OUTPUT_ATTEMPTS calls, and
|
|
48
|
+
* BAD_OUTPUT_STOP_AFTER × BAD_OUTPUT_ATTEMPTS when every reply is unusable.
|
|
39
49
|
*/
|
|
40
50
|
import { isRuntimeUsageLimit } from "../bot/runtime-failure.js";
|
|
41
51
|
import { redactErrorText } from "../../utils/redact-error-text.js";
|
|
@@ -58,6 +68,8 @@ export class SignalsPassError extends Error {
|
|
|
58
68
|
code;
|
|
59
69
|
/** Signals this pass call had already written before it failed. */
|
|
60
70
|
written = 0;
|
|
71
|
+
/** Set on bad output that another call cannot fix, so the document is not sent again. */
|
|
72
|
+
noRetry = false;
|
|
61
73
|
constructor(code, message) {
|
|
62
74
|
super(message);
|
|
63
75
|
this.name = "SignalsPassError";
|
|
@@ -103,6 +115,14 @@ export const AUTH_PREFLIGHT_TIMEOUT_MS = 10_000;
|
|
|
103
115
|
export const WORKLIST_TIMEOUT_MS = 60_000;
|
|
104
116
|
/** Documents one pass sends to claude across all adapters of a run. */
|
|
105
117
|
export const DEFAULT_MAX_SIGNAL_DOCS = 20;
|
|
118
|
+
/**
|
|
119
|
+
* Claude calls per document when the reply is unusable (`claude-bad-output`).
|
|
120
|
+
* The reply differs from call to call, so a document whose first reply has a
|
|
121
|
+
* JSON syntax error usually parses on the next. Other failures are not retried.
|
|
122
|
+
*/
|
|
123
|
+
export const BAD_OUTPUT_ATTEMPTS = 3;
|
|
124
|
+
/** Documents in a row with unusable replies after which the pass stops. */
|
|
125
|
+
export const BAD_OUTPUT_STOP_AFTER = 3;
|
|
106
126
|
/** Payload bytes sent to claude per document (200 KB). A longer payload is cut with a marker. */
|
|
107
127
|
export const MAX_PAYLOAD_BYTES = 200 * 1024;
|
|
108
128
|
/** Output kept per child stream. A longer reply is bad output. */
|
|
@@ -689,6 +709,20 @@ export function createClaudeSignalsPass(options) {
|
|
|
689
709
|
return { items: dated.map((d) => d.item), pending: true };
|
|
690
710
|
};
|
|
691
711
|
const extract = async (item, input) => {
|
|
712
|
+
for (let attempt = 1;; attempt += 1) {
|
|
713
|
+
try {
|
|
714
|
+
return await extractOnce(item, input);
|
|
715
|
+
}
|
|
716
|
+
catch (err) {
|
|
717
|
+
if (!(err instanceof SignalsPassError) || err.code !== "claude-bad-output")
|
|
718
|
+
throw err;
|
|
719
|
+
if (err.noRetry || attempt >= BAD_OUTPUT_ATTEMPTS)
|
|
720
|
+
throw err;
|
|
721
|
+
warn(`signals pass: ${item.file}: ${err.message}; sending it again (call ${attempt + 1} of ${BAD_OUTPUT_ATTEMPTS})`);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
};
|
|
725
|
+
const extractOnce = async (item, input) => {
|
|
692
726
|
prompt ??= fs.readFile(promptFile, "utf8");
|
|
693
727
|
const run = await runBounded(claude, ["-p", await prompt, ...CLAUDE_ISOLATION_ARGS, "--output-format", "json", "--max-turns", "1"], {
|
|
694
728
|
timeoutMs,
|
|
@@ -709,7 +743,12 @@ export function createClaudeSignalsPass(options) {
|
|
|
709
743
|
if (err instanceof SignalsPassError && err.code === "claude-bad-output") {
|
|
710
744
|
// Only sizes and stderr: stdout is model output built from the document.
|
|
711
745
|
const stderr = run.stderr.trim() ? `, stderr${providerReason(run.stderr)}` : "";
|
|
712
|
-
|
|
746
|
+
const bad = new SignalsPassError("claude-bad-output", `${err.message} (stdout ${Buffer.byteLength(run.stdout)} bytes${stderr})`);
|
|
747
|
+
// No stdout means claude printed nothing or went over MAX_OUTPUT_BYTES
|
|
748
|
+
// (runBounded drops an oversized reply). The same document would do
|
|
749
|
+
// the same again.
|
|
750
|
+
bad.noRetry = run.stdout.length === 0;
|
|
751
|
+
throw bad;
|
|
713
752
|
}
|
|
714
753
|
throw err;
|
|
715
754
|
}
|
|
@@ -767,6 +806,12 @@ export function createClaudeSignalsPass(options) {
|
|
|
767
806
|
const beforeWrite = guard?.beforeWrite ?? (async () => undefined);
|
|
768
807
|
await beforeWrite();
|
|
769
808
|
flushSignalPublications(options.hqRoot, options.company);
|
|
809
|
+
let badOutput;
|
|
810
|
+
let badDocs = 0;
|
|
811
|
+
let badInARow = 0;
|
|
812
|
+
const badOutputFailure = () => badDocs === 1 && badOutput !== undefined
|
|
813
|
+
? badOutput
|
|
814
|
+
: new SignalsPassError("claude-bad-output", `${badDocs} documents had unusable claude replies; first: ${badOutput?.message ?? ""}`);
|
|
770
815
|
const byChannel = new Map();
|
|
771
816
|
// The adapter's own channel is listed even when this run landed nothing
|
|
772
817
|
// there, so items an earlier run left over the cap still get processed.
|
|
@@ -811,7 +856,29 @@ export function createClaudeSignalsPass(options) {
|
|
|
811
856
|
if (input.fallback !== undefined) {
|
|
812
857
|
warn(`signals pass: ${item.file}: ${input.fallback} for payload_ref ${JSON.stringify(input.fallbackRef)}; sent the pointer only`);
|
|
813
858
|
}
|
|
814
|
-
|
|
859
|
+
let signals;
|
|
860
|
+
try {
|
|
861
|
+
signals = await extract(item, input);
|
|
862
|
+
}
|
|
863
|
+
catch (err) {
|
|
864
|
+
if (!(err instanceof SignalsPassError) || err.code !== "claude-bad-output")
|
|
865
|
+
throw err;
|
|
866
|
+
// One document's unusable reply must not hold back the documents
|
|
867
|
+
// behind it. It stays unmarked (or pending) for a later run, and the
|
|
868
|
+
// pass still fails once the rest are done.
|
|
869
|
+
badOutput ??= err;
|
|
870
|
+
badDocs += 1;
|
|
871
|
+
badInARow += 1;
|
|
872
|
+
warn(`signals pass: ${item.file}: ${err.message}; left for a later run`);
|
|
873
|
+
// Several documents in a row means the cause is not one document
|
|
874
|
+
// (an unrecognised provider message, a changed reply format), so
|
|
875
|
+
// the rest would fail the same way.
|
|
876
|
+
if (badInARow >= BAD_OUTPUT_STOP_AFTER)
|
|
877
|
+
throw badOutputFailure();
|
|
878
|
+
continue;
|
|
879
|
+
}
|
|
880
|
+
badInARow = 0;
|
|
881
|
+
progress.written += await write(item, input, signals, beforeWrite);
|
|
815
882
|
if (item.fromWorklist) {
|
|
816
883
|
await runWorklist(["--company", options.company, "--channel", channel, "--mark-done", item.file]);
|
|
817
884
|
}
|
|
@@ -821,6 +888,8 @@ export function createClaudeSignalsPass(options) {
|
|
|
821
888
|
}
|
|
822
889
|
}
|
|
823
890
|
}
|
|
891
|
+
if (badOutput !== undefined)
|
|
892
|
+
throw badOutputFailure();
|
|
824
893
|
};
|
|
825
894
|
return async (result, guard) => {
|
|
826
895
|
const progress = { written: 0 };
|
|
@@ -147,7 +147,7 @@ export async function selectSignalsRedo(input) {
|
|
|
147
147
|
}
|
|
148
148
|
for (const name of names) {
|
|
149
149
|
const key = `sources/${channel}/${name}`;
|
|
150
|
-
if (channelOf(key) !== channel
|
|
150
|
+
if (channelOf(key) !== channel)
|
|
151
151
|
continue;
|
|
152
152
|
let text;
|
|
153
153
|
try {
|
|
@@ -156,7 +156,15 @@ export async function selectSignalsRedo(input) {
|
|
|
156
156
|
catch {
|
|
157
157
|
continue;
|
|
158
158
|
}
|
|
159
|
-
|
|
159
|
+
const frontmatter = splitFrontmatter(text).frontmatter;
|
|
160
|
+
const alias = frontmatter.signal_source_ref;
|
|
161
|
+
// The pass indexes meeting pointers under `meeting:<id>`, not the landed
|
|
162
|
+
// file path. Treat either form as already signalled so `--since` does
|
|
163
|
+
// not re-queue a document the pass just wrote (feedback_1bdd2f65).
|
|
164
|
+
if (signalled.has(key) || (typeof alias === "string" && alias.length > 0 && signalled.has(alias))) {
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
if (landedDocTime(frontmatter) >= since)
|
|
160
168
|
add(selection.pending, channel, key);
|
|
161
169
|
}
|
|
162
170
|
}
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export declare function assertProviderWrappersInstallable(binDir: string): void;
|
|
6
6
|
export declare function providerWrapperInstallPaths(home: string): string[];
|
|
7
|
+
/** Env var the installed wrapper sets when it hands a run to another wrapper script. */
|
|
8
|
+
export declare function providerWrapperGuardVar(provider: 'claude' | 'codex'): string;
|
|
7
9
|
export declare function installProviderWrappers(binDir: string, home?: string): string[];
|
|
8
10
|
export declare function removeProviderWrappers(binDir: string): string[];
|
|
9
11
|
//# sourceMappingURL=provider-wrappers.d.ts.map
|
|
@@ -35,6 +35,10 @@ export function providerWrapperInstallPaths(home) {
|
|
|
35
35
|
}
|
|
36
36
|
return paths;
|
|
37
37
|
}
|
|
38
|
+
/** Env var the installed wrapper sets when it hands a run to another wrapper script. */
|
|
39
|
+
export function providerWrapperGuardVar(provider) {
|
|
40
|
+
return `HQ_ANYWHERE_${provider.toUpperCase()}_WRAPPER_ACTIVE`;
|
|
41
|
+
}
|
|
38
42
|
function wrapperSource(provider) {
|
|
39
43
|
const pretty = provider === 'claude' ? 'Claude Code' : 'Codex';
|
|
40
44
|
const login = provider === 'claude' ? 'claude /login' : 'codex login';
|
|
@@ -45,6 +49,12 @@ function wrapperSource(provider) {
|
|
|
45
49
|
const runAuthFailure = provider === 'codex'
|
|
46
50
|
? 'HTTP error: *401|status 401|401 Unauthorized|websocket.*auth|not logged in|signed out|not authenticated|authentication required|unauthenticated'
|
|
47
51
|
: 'HTTP error: *401|status 401|401 Unauthorized|not logged in|signed out|not authenticated|authentication required|unauthenticated';
|
|
52
|
+
// Install locations of the real provider executable, checked when PATH holds no
|
|
53
|
+
// executable that is not a shell script.
|
|
54
|
+
const knownInstalls = provider === 'claude'
|
|
55
|
+
? ['"${HOME:-}/.local/bin/claude"', '"${HOME:-}/.claude/local/node_modules/.bin/claude"']
|
|
56
|
+
: [];
|
|
57
|
+
const guard = providerWrapperGuardVar(provider);
|
|
48
58
|
return [
|
|
49
59
|
'#!/bin/sh',
|
|
50
60
|
`${marker}: ${provider}`,
|
|
@@ -55,18 +65,73 @@ function wrapperSource(provider) {
|
|
|
55
65
|
`login='${login}'`,
|
|
56
66
|
`provider='${provider}'`,
|
|
57
67
|
'',
|
|
58
|
-
'#
|
|
68
|
+
'# Locate the provider. Other tools (cmux, for example) put their own provider',
|
|
69
|
+
'# wrapper on PATH, and that wrapper runs the next provider it finds on PATH. To',
|
|
70
|
+
'# keep those wrappers working without starting each other forever:',
|
|
71
|
+
'# - Without the guard, run the next provider on PATH after this wrapper (any',
|
|
72
|
+
`# kind except another HQ wrapper). When that is a shell script, set ${guard}`,
|
|
73
|
+
'# so a script that runs this wrapper again lands in the branch below.',
|
|
74
|
+
'# - With the guard set, never run another wrapper: run the real executable (the',
|
|
75
|
+
'# first provider on PATH that is not a shell script, then the known install',
|
|
76
|
+
'# locations) directly, or stop.',
|
|
77
|
+
'hq_shell_script() {',
|
|
78
|
+
" hq_first=$(LC_ALL=C head -c 256 \"$1\" 2>/dev/null | LC_ALL=C tr -d '\\000' | LC_ALL=C head -n 1)",
|
|
79
|
+
' case "$hq_first" in',
|
|
80
|
+
" '#!'*/sh|'#!'*/sh\\ *|'#!'*' sh'|'#!'*' sh '*|'#!'*bash*|'#!'*zsh*|'#!'*dash*|'#!'*ksh*) return 0 ;;",
|
|
81
|
+
' esac',
|
|
82
|
+
' return 1',
|
|
83
|
+
'}',
|
|
84
|
+
'hq_managed_wrapper() {',
|
|
85
|
+
` LC_ALL=C head -c 256 "$1" 2>/dev/null | LC_ALL=C tr -d '\\000' | grep -q '^${marker}'`,
|
|
86
|
+
'}',
|
|
87
|
+
'hq_known_install() {',
|
|
88
|
+
' known=',
|
|
89
|
+
...(knownInstalls.length > 0
|
|
90
|
+
? [
|
|
91
|
+
` for candidate in ${knownInstalls.join(' ')}; do`,
|
|
92
|
+
' if [ -f "$candidate" ] && [ -x "$candidate" ] && [ "$candidate" != "$self" ] && ! hq_shell_script "$candidate"; then known=$candidate; return 0; fi',
|
|
93
|
+
' done',
|
|
94
|
+
]
|
|
95
|
+
: []),
|
|
96
|
+
' return 1',
|
|
97
|
+
'}',
|
|
59
98
|
'self=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)/$(basename -- "$0")',
|
|
60
|
-
'
|
|
99
|
+
'next=',
|
|
100
|
+
'first=',
|
|
101
|
+
'binary=',
|
|
102
|
+
'seen_self=0',
|
|
61
103
|
'old_ifs=$IFS',
|
|
62
104
|
'IFS=:',
|
|
63
105
|
'for dir in $PATH; do',
|
|
64
106
|
' [ -n "$dir" ] || dir=.',
|
|
65
107
|
' candidate=$(CDPATH= cd -- "$dir" 2>/dev/null && pwd -P)/$name',
|
|
66
|
-
' if [
|
|
108
|
+
' if [ "$candidate" = "$self" ]; then seen_self=1; continue; fi',
|
|
109
|
+
' if [ ! -f "$candidate" ] || [ ! -x "$candidate" ] || hq_managed_wrapper "$candidate"; then continue; fi',
|
|
110
|
+
' if [ -z "$binary" ] && ! hq_shell_script "$candidate"; then binary=$candidate; fi',
|
|
111
|
+
' if [ "$seen_self" = 1 ]; then',
|
|
112
|
+
' [ -n "$next" ] || next=$candidate',
|
|
113
|
+
' if [ -n "$binary" ]; then break; fi',
|
|
114
|
+
' elif [ -z "$first" ]; then',
|
|
115
|
+
' first=$candidate',
|
|
116
|
+
' fi',
|
|
67
117
|
'done',
|
|
68
118
|
'IFS=$old_ifs',
|
|
119
|
+
'',
|
|
120
|
+
`if [ -n "\${${guard}:-}" ]; then`,
|
|
121
|
+
' # Another wrapper ran this one again. The real executable does not get the guard,',
|
|
122
|
+
' # so a session it starts treats its own nested provider calls as new runs.',
|
|
123
|
+
' if [ -z "$binary" ] && hq_known_install; then binary=$known; fi',
|
|
124
|
+
` if [ -n "$binary" ]; then unset ${guard}; exec "$binary" "$@"; fi`,
|
|
125
|
+
` printf '%s CLI was not found: every ${provider} on PATH is a wrapper script that runs this HQ wrapper (%s) again.\\nInstall %s, or put the directory that holds the real ${provider} executable on PATH.\\n' "$pretty" "$self" "$pretty" >&2`,
|
|
126
|
+
' exit 127',
|
|
127
|
+
'fi',
|
|
128
|
+
'# Invoked by a path that is not on PATH: the first provider on PATH is the next one.',
|
|
129
|
+
'if [ "$seen_self" = 0 ]; then next=$first; first=; fi',
|
|
130
|
+
'real=$next',
|
|
131
|
+
'if [ -z "$real" ] && hq_known_install; then real=$known; fi',
|
|
132
|
+
'[ -n "$real" ] || real=$first',
|
|
69
133
|
'if [ -z "$real" ]; then printf \'%s CLI was not found on PATH.\\n\' "$pretty" >&2; exit 127; fi',
|
|
134
|
+
`if hq_shell_script "$real"; then ${guard}=1; export ${guard}; fi`,
|
|
70
135
|
'',
|
|
71
136
|
'# The flag override is part of the existing hq-anywhere-runtime flag contract.',
|
|
72
137
|
'case "${HQ_FLAG_HQ_ANYWHERE_RUNTIME:-}" in false|0) exec "$real" "$@" ;; esac',
|
|
@@ -47,6 +47,9 @@ import { applyDefaultQuotaHold, clearAccountQuotaAfterSuccessfulTurnBestEffort,
|
|
|
47
47
|
import { deliverQuotaNotice as deliverQuotaNoticeToSenior, quotaLaneNotice } from "./quota-notice.js";
|
|
48
48
|
import { PROVIDER_REJECTED_REASON, QUOTA_STATUS, isProviderLoginFailure, providerRejectionDetails, readProviderRejection, } from "./provider-rejection.js";
|
|
49
49
|
import { appendDropboxMessageAtPath, dropboxInboxHasMessages, readToolActivity, toolActivityPath } from "./dropbox.js";
|
|
50
|
+
import { usageLimitWindow } from "../bot/runtime-failure.js";
|
|
51
|
+
import { recordRefusalForHome } from "../capacity/refusal.js";
|
|
52
|
+
import { effectiveAccountHome } from "./account-home.js";
|
|
50
53
|
import { loadLanesConfig, providerProgressEventMinIntervalMs, providerQuotaDefaultHoldMs } from "./config.js";
|
|
51
54
|
import { resolveAdmissionHost as resolveProcessAdmissionHost } from "./admission-host.js";
|
|
52
55
|
import { createLaneMesh, emitLaneDecisionEvents, emitLaneProgressEvent, emitLaneTerminalStateEvent, laneStoryStatusSuppressionKey, progressEventDue, } from "./mesh-events.js";
|
|
@@ -356,6 +359,36 @@ export function clearLaneStalled(hqRoot, laneId) {
|
|
|
356
359
|
return { ...current, stalled: undefined, stalled_at: undefined, stalled_reason: undefined };
|
|
357
360
|
});
|
|
358
361
|
}
|
|
362
|
+
/**
|
|
363
|
+
* A lane the provider refused corrects the ledger. Only these classified reasons
|
|
364
|
+
* count: a timeout or a crash says nothing about the account's usage. The quota
|
|
365
|
+
* signal's `quota_reset_at` is the lane's own capped hold, so the provider's reset
|
|
366
|
+
* comes first. A rate limit lasts the provider's configured hold.
|
|
367
|
+
*/
|
|
368
|
+
function recordLaneRefusal(hqRoot, lane, classification, quota) {
|
|
369
|
+
const quotaExhausted = classification.reason === "account_quota_exhausted";
|
|
370
|
+
if (!quotaExhausted && classification.reason !== "provider_rate_limited")
|
|
371
|
+
return;
|
|
372
|
+
if (!lane.provider || !lane.account)
|
|
373
|
+
return;
|
|
374
|
+
try {
|
|
375
|
+
const provider = loadLanesConfig(hqRoot).providers[lane.provider];
|
|
376
|
+
const account = provider?.accounts?.[lane.account];
|
|
377
|
+
if (!provider || !account)
|
|
378
|
+
return;
|
|
379
|
+
recordRefusalForHome({
|
|
380
|
+
provider: lane.provider,
|
|
381
|
+
home: effectiveAccountHome(account).home,
|
|
382
|
+
window: quotaExhausted ? usageLimitWindow(quota?.provider_text) : { kind: "rate_limit" },
|
|
383
|
+
// Kept when the text names a window. With none, recordRefusalForHome uses it only on a repeat.
|
|
384
|
+
resetsAt: quotaExhausted ? quota?.provider_reset_at ?? quota?.quota_reset_at : undefined,
|
|
385
|
+
holdMs: providerQuotaDefaultHoldMs(provider),
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
catch (err) {
|
|
389
|
+
process.stderr.write(`hq lanes watcher: refusal not recorded for ${lane.lane_id}: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
359
392
|
export function applyTerminalToLane(hqRoot, laneId, classification, opts = {}) {
|
|
360
393
|
return applyTerminalToLaneWithResult(hqRoot, laneId, classification, opts).record;
|
|
361
394
|
}
|
|
@@ -573,6 +606,8 @@ function applyTerminalToLaneWithResult(hqRoot, laneId, classification, opts = {}
|
|
|
573
606
|
provider: updated.provider,
|
|
574
607
|
account: updated.account,
|
|
575
608
|
});
|
|
609
|
+
if (changed)
|
|
610
|
+
recordLaneRefusal(hqRoot, updated, effectiveClassification, opts.quota);
|
|
576
611
|
return {
|
|
577
612
|
record: updated,
|
|
578
613
|
changed,
|
|
@@ -183,6 +183,8 @@ export function claudeAllowedTools(channelDir, wrapperPath) {
|
|
|
183
183
|
// A rule path that starts with `//` is absolute.
|
|
184
184
|
return [`Read(/${channelDir}/**)`, `Bash(bash ${wrapperPath} *)`];
|
|
185
185
|
}
|
|
186
|
+
/** The result subtype claude prints when --max-budget-usd ends the turn. Only claude is given a budget. */
|
|
187
|
+
const CLAUDE_BUDGET_STOP_SUBTYPE = "error_max_budget_usd";
|
|
186
188
|
/** The Executive bot's runtime (lib/bot/executive.ts), or null when there is no personal bot. */
|
|
187
189
|
export function defaultResolveBotRuntime(root = botsRoot()) {
|
|
188
190
|
const main = resolveExecutiveBot({ root })?.config ?? null;
|
|
@@ -1091,6 +1093,12 @@ function runTurn(ctx, runtime, prompt, scope, budgetUsd, opts) {
|
|
|
1091
1093
|
return { ok: false, error: `${runtime} timed out after ${opts.turnTimeoutMs}ms`, errorKind: "transient", turns: parsed.turns, costUsd: parsed.costUsd };
|
|
1092
1094
|
return { ok: false, error: `${runtime} could not start: ${res.error.message}`.slice(0, 300), errorKind: "other", turns: 0, costUsd: 0 };
|
|
1093
1095
|
}
|
|
1096
|
+
// The runtime stopped the turn at its own budget cap (claude: result subtype
|
|
1097
|
+
// error_max_budget_usd, with a non-zero exit). That is the run's budget stop,
|
|
1098
|
+
// not a failed item.
|
|
1099
|
+
if (runtime === "claude" && parsed.result?.subtype === CLAUDE_BUDGET_STOP_SUBTYPE) {
|
|
1100
|
+
return { ok: false, error: "budget-exceeded", budgetExceeded: true, turns: parsed.turns, costUsd: parsed.costUsd };
|
|
1101
|
+
}
|
|
1094
1102
|
if (res.status !== 0) {
|
|
1095
1103
|
const c = classifyFailure(all, `${runtime} exited ${String(res.status)}: ${res.stderr.trim().slice(0, 200)}`);
|
|
1096
1104
|
return { ok: false, ...c, turns: parsed.turns, costUsd: parsed.costUsd };
|
|
@@ -1198,6 +1206,8 @@ export function createExtractStep(options = {}) {
|
|
|
1198
1206
|
let skipped = 0;
|
|
1199
1207
|
let processedAny = false;
|
|
1200
1208
|
let budgetStop = false;
|
|
1209
|
+
/** The source a runtime budget stop cut short, named in the record so a source that never fits is findable. */
|
|
1210
|
+
let budgetStoppedAt;
|
|
1201
1211
|
let errorKind;
|
|
1202
1212
|
const failures = unrunRedo.map((file) => ({
|
|
1203
1213
|
file,
|
|
@@ -1333,13 +1343,27 @@ export function createExtractStep(options = {}) {
|
|
|
1333
1343
|
spent += turn.costUsd;
|
|
1334
1344
|
lastCost = turn.costUsd;
|
|
1335
1345
|
const created = [...allCandidateFiles(ctx.hqRoot)].filter((f) => !before.has(f));
|
|
1336
|
-
if (!turn.ok && priorSignals.length) {
|
|
1346
|
+
if (!turn.ok && (priorSignals.length || turn.budgetExceeded)) {
|
|
1337
1347
|
// Failed model turns must not leave structured duplicates for garden.
|
|
1348
|
+
// A budget-stopped source runs again next time and would write its
|
|
1349
|
+
// candidates a second time, so the stopped turn's are removed too:
|
|
1350
|
+
// its signal candidates and its entity candidates. A failed turn
|
|
1351
|
+
// with prior signals keeps the scope it had, signal candidates only.
|
|
1352
|
+
const stores = turn.budgetExceeded ? ["signals", "ontology"] : ["signals"];
|
|
1338
1353
|
for (const file of created) {
|
|
1339
1354
|
const rel = realRelPath(ctx.hqRoot, file);
|
|
1340
|
-
if (rel
|
|
1341
|
-
|
|
1355
|
+
if (!rel || !stores.some((store) => rel.startsWith(`companies/${ctx.company}/${store}/_candidates/`)))
|
|
1356
|
+
continue;
|
|
1357
|
+
let text;
|
|
1358
|
+
try {
|
|
1359
|
+
text = fs.readFileSync(file, "utf8");
|
|
1360
|
+
}
|
|
1361
|
+
catch {
|
|
1362
|
+
// Gone already (a concurrent garden moved it), or unreadable; nothing to remove.
|
|
1363
|
+
continue;
|
|
1342
1364
|
}
|
|
1365
|
+
if (frontmatter(text)?.source_ref === sourceRef)
|
|
1366
|
+
guardedRemove(ctx.hqRoot, rel, { company: ctx.company });
|
|
1343
1367
|
}
|
|
1344
1368
|
}
|
|
1345
1369
|
const v = validateNewCandidates(created, item.audience_key, { hqRoot: ctx.hqRoot, company: ctx.company, sourceRef }, turn.ok ? priorSignals : [], ctx.now());
|
|
@@ -1355,8 +1379,20 @@ export function createExtractStep(options = {}) {
|
|
|
1355
1379
|
failures.push({ file: item.file, error: `candidate written outside ${ctx.company} (deleted): ${v.foreign.join(", ")}`.slice(0, 300) });
|
|
1356
1380
|
if (!errorKind)
|
|
1357
1381
|
errorKind = "other";
|
|
1382
|
+
if (turn.budgetExceeded) {
|
|
1383
|
+
// The breach is recorded above; the runtime's budget stop still ends the run.
|
|
1384
|
+
budgetStoppedAt = item.file;
|
|
1385
|
+
budgetStop = true;
|
|
1386
|
+
break outer;
|
|
1387
|
+
}
|
|
1358
1388
|
continue;
|
|
1359
1389
|
}
|
|
1390
|
+
if (!turn.ok && turn.budgetExceeded) {
|
|
1391
|
+
// The item is not marked done, so the next run takes it again.
|
|
1392
|
+
budgetStoppedAt = item.file;
|
|
1393
|
+
budgetStop = true;
|
|
1394
|
+
break outer;
|
|
1395
|
+
}
|
|
1360
1396
|
if (!turn.ok) {
|
|
1361
1397
|
failures.push({ file: item.file, error: turn.error ?? "turn failed" });
|
|
1362
1398
|
if (turn.errorKind === "signed-out" || !errorKind)
|
|
@@ -1383,7 +1419,7 @@ export function createExtractStep(options = {}) {
|
|
|
1383
1419
|
...(failures.length ? { failures } : {}),
|
|
1384
1420
|
...(skippedItems.length ? { skippedItems } : {}),
|
|
1385
1421
|
...(rejected ? { rejectedCandidates: rejected } : {}),
|
|
1386
|
-
detail: { new: itemsOut, updated, skipped, runtime, ...(choice.fallback ? { fallback: choice.fallback } : {}) },
|
|
1422
|
+
detail: { new: itemsOut, updated, skipped, runtime, ...(choice.fallback ? { fallback: choice.fallback } : {}), ...(budgetStoppedAt ? { budgetStoppedAt } : {}) },
|
|
1387
1423
|
};
|
|
1388
1424
|
if (budgetStop) {
|
|
1389
1425
|
result.status = "partial";
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "hq-available-ai.v1",
|
|
4
|
+
"title": "hq-available-ai.v1",
|
|
5
|
+
"description": "What AI can run on this computer right now. Holds no credential. It lists the organization names of every account across the companies signed in on this machine, so the file is written mode 0600 (owner-only) to keep those names off other local users. freshness is about the view and is never a failure; failure classes stay in hq capacity doctor and logs.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"required": ["schemaVersion", "generatedAt", "freshness", "best", "nextBackAt", "options"],
|
|
9
|
+
"properties": {
|
|
10
|
+
"schemaVersion": { "const": "hq-available-ai.v1" },
|
|
11
|
+
"generatedAt": { "type": "string" },
|
|
12
|
+
"freshness": { "enum": ["fresh", "refreshing", "stale"] },
|
|
13
|
+
"best": { "type": ["string", "null"], "description": "optionId of an account enabled for work, never a paid tranche. Null only when nothing can run." },
|
|
14
|
+
"nextBackAt": { "type": ["string", "null"] },
|
|
15
|
+
"options": {
|
|
16
|
+
"type": "array",
|
|
17
|
+
"items": {
|
|
18
|
+
"type": "object",
|
|
19
|
+
"additionalProperties": false,
|
|
20
|
+
"required": ["optionId", "provider", "account", "tranche", "availability", "leftPercent", "backAt", "reading", "usableBy", "holder", "models", "reason", "nextStep"],
|
|
21
|
+
"properties": {
|
|
22
|
+
"optionId": { "type": "string", "minLength": 1 },
|
|
23
|
+
"provider": { "enum": ["claude", "codex", "grok"] },
|
|
24
|
+
"account": {
|
|
25
|
+
"type": "object",
|
|
26
|
+
"additionalProperties": false,
|
|
27
|
+
"required": ["id", "label", "organization"],
|
|
28
|
+
"properties": {
|
|
29
|
+
"id": { "type": "string" },
|
|
30
|
+
"label": { "type": "string" },
|
|
31
|
+
"organization": { "type": ["string", "null"] }
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"tranche": {
|
|
35
|
+
"type": "object",
|
|
36
|
+
"additionalProperties": false,
|
|
37
|
+
"required": ["kind", "scope", "paid"],
|
|
38
|
+
"properties": {
|
|
39
|
+
"kind": { "enum": ["plan", "scoped_model", "extra_usage", "credits", "api_key"] },
|
|
40
|
+
"scope": { "type": ["string", "null"] },
|
|
41
|
+
"paid": { "type": "boolean" }
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"availability": { "enum": ["ready", "likely_ready", "low", "used_up", "needs_sign_in", "not_installed"] },
|
|
45
|
+
"leftPercent": { "type": ["number", "null"] },
|
|
46
|
+
"backAt": { "type": ["string", "null"] },
|
|
47
|
+
"reading": {
|
|
48
|
+
"type": "object",
|
|
49
|
+
"additionalProperties": false,
|
|
50
|
+
"required": ["ageSeconds", "confidence"],
|
|
51
|
+
"properties": {
|
|
52
|
+
"ageSeconds": { "type": ["number", "null"] },
|
|
53
|
+
"confidence": { "enum": ["fetched", "observed", "inferred", "unknown"] }
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"usableBy": {
|
|
57
|
+
"type": "array",
|
|
58
|
+
"items": { "enum": ["model_cli", "lane", "fleet"] }
|
|
59
|
+
},
|
|
60
|
+
"holder": { "enum": ["cli_home", "bot_own", "none"] },
|
|
61
|
+
"models": { "type": "array", "items": { "type": "string" } },
|
|
62
|
+
"reason": { "type": "string" },
|
|
63
|
+
"nextStep": {
|
|
64
|
+
"type": "object",
|
|
65
|
+
"additionalProperties": false,
|
|
66
|
+
"required": ["kind", "label"],
|
|
67
|
+
"properties": {
|
|
68
|
+
"kind": { "enum": ["use", "sign_in", "wait", "install"] },
|
|
69
|
+
"label": { "type": "string" }
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Machine-independent runtime paths for the generated command catalog.
|
|
3
|
+
*
|
|
4
|
+
* scripts/generate-command-catalog.mjs records help text with this machine's
|
|
5
|
+
* home folder (and absolute option defaults) replaced by a token, so the
|
|
6
|
+
* checked-in catalog is the same on every machine. On Windows the text after
|
|
7
|
+
* the token used backslashes (`<runtime-home>\.hq\x.json`), and the catalog
|
|
8
|
+
* then differed from the one generated on macOS and Linux, so `pnpm run build`
|
|
9
|
+
* failed its `--check` there. The path after a token is now always written with
|
|
10
|
+
* `/`, and turned back into this platform's separator when the catalog is read
|
|
11
|
+
* (src/lazy-commands.ts), so help text is unchanged on every platform.
|
|
12
|
+
*/
|
|
13
|
+
export declare const RUNTIME_HOME_TOKEN = "<runtime-home>";
|
|
14
|
+
export declare const RUNTIME_PATH_TOKEN = "<runtime-path>";
|
|
15
|
+
/**
|
|
16
|
+
* Replace each runtime path in `text` with its token and write the rest of
|
|
17
|
+
* that path with `/`. `homeDir` gets `<runtime-home>`; any other entry of
|
|
18
|
+
* `runtimePaths` gets `<runtime-path>`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function stableRuntimeText(text: string, runtimePaths: readonly string[], homeDir: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Put this machine's paths back in place of the tokens, with the path after a
|
|
23
|
+
* token in this platform's separator.
|
|
24
|
+
*/
|
|
25
|
+
export declare function restoreRuntimeText(text: string, roots: {
|
|
26
|
+
home: string;
|
|
27
|
+
hqRoot: () => string;
|
|
28
|
+
}, separator: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* True when the catalog on disk is the generated text. A Windows checkout with
|
|
31
|
+
* core.autocrlf=true has CRLF line endings, which are not a difference.
|
|
32
|
+
*/
|
|
33
|
+
export declare function catalogTextMatches(onDisk: string, generated: string): boolean;
|
|
34
|
+
//# sourceMappingURL=catalog-runtime-paths.d.ts.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Machine-independent runtime paths for the generated command catalog.
|
|
3
|
+
*
|
|
4
|
+
* scripts/generate-command-catalog.mjs records help text with this machine's
|
|
5
|
+
* home folder (and absolute option defaults) replaced by a token, so the
|
|
6
|
+
* checked-in catalog is the same on every machine. On Windows the text after
|
|
7
|
+
* the token used backslashes (`<runtime-home>\.hq\x.json`), and the catalog
|
|
8
|
+
* then differed from the one generated on macOS and Linux, so `pnpm run build`
|
|
9
|
+
* failed its `--check` there. The path after a token is now always written with
|
|
10
|
+
* `/`, and turned back into this platform's separator when the catalog is read
|
|
11
|
+
* (src/lazy-commands.ts), so help text is unchanged on every platform.
|
|
12
|
+
*/
|
|
13
|
+
export const RUNTIME_HOME_TOKEN = "<runtime-home>";
|
|
14
|
+
export const RUNTIME_PATH_TOKEN = "<runtime-path>";
|
|
15
|
+
/** Characters that end a path inside help text. */
|
|
16
|
+
const PATH_TAIL = String.raw `(?:[\\/][^\s"'\x60()\[\],;]*)?`;
|
|
17
|
+
function escapeRegExp(text) {
|
|
18
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Replace each runtime path in `text` with its token and write the rest of
|
|
22
|
+
* that path with `/`. `homeDir` gets `<runtime-home>`; any other entry of
|
|
23
|
+
* `runtimePaths` gets `<runtime-path>`.
|
|
24
|
+
*/
|
|
25
|
+
export function stableRuntimeText(text, runtimePaths, homeDir) {
|
|
26
|
+
return runtimePaths.reduce((current, runtimePath) => {
|
|
27
|
+
if (!runtimePath)
|
|
28
|
+
return current;
|
|
29
|
+
const token = runtimePath === homeDir ? RUNTIME_HOME_TOKEN : RUNTIME_PATH_TOKEN;
|
|
30
|
+
const pattern = new RegExp(escapeRegExp(runtimePath) + `(${PATH_TAIL})`, "g");
|
|
31
|
+
return current.replace(pattern, (_match, tail) => token + tail.replaceAll("\\", "/"));
|
|
32
|
+
}, text);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Put this machine's paths back in place of the tokens, with the path after a
|
|
36
|
+
* token in this platform's separator.
|
|
37
|
+
*/
|
|
38
|
+
export function restoreRuntimeText(text, roots, separator) {
|
|
39
|
+
const tokens = new RegExp(`(${escapeRegExp(RUNTIME_HOME_TOKEN)}|${escapeRegExp(RUNTIME_PATH_TOKEN)})(${PATH_TAIL})`, "g");
|
|
40
|
+
let hqRoot;
|
|
41
|
+
return text.replace(tokens, (_match, token, tail) => {
|
|
42
|
+
const root = token === RUNTIME_HOME_TOKEN ? roots.home : (hqRoot ??= roots.hqRoot());
|
|
43
|
+
return root + (separator === "/" ? tail : tail.replaceAll("/", separator));
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* True when the catalog on disk is the generated text. A Windows checkout with
|
|
48
|
+
* core.autocrlf=true has CRLF line endings, which are not a difference.
|
|
49
|
+
*/
|
|
50
|
+
export function catalogTextMatches(onDisk, generated) {
|
|
51
|
+
return onDisk.replace(/\r\n/g, "\n") === generated.replace(/\r\n/g, "\n");
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=catalog-runtime-paths.js.map
|
|
@@ -14,4 +14,18 @@ export declare function resetStrayPortWarningForTests(): void;
|
|
|
14
14
|
export declare function resolveCognitoCallbackPort(raw: string | number | undefined, warn?: PortWarn): number;
|
|
15
15
|
/** Return `config` with its callback port forced into the registered set. */
|
|
16
16
|
export declare function withRegisteredCallbackPort<T extends CognitoAuthConfig>(config: T, warn?: PortWarn): T;
|
|
17
|
+
/** Default OIDC prompt for a browser sign-in: the provider shows its account chooser. */
|
|
18
|
+
export declare const DEFAULT_COGNITO_LOGIN_PROMPT = "select_account";
|
|
19
|
+
/** HQ_COGNITO_PROMPT overrides the sign-in prompt; an empty value sends no prompt. */
|
|
20
|
+
export declare function resolveCognitoLoginPrompt(env?: NodeJS.ProcessEnv): string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Config for an interactive browser sign-in: a registered callback port plus
|
|
23
|
+
* the account-chooser prompt. Cognito forwards `prompt` to the identity
|
|
24
|
+
* provider, so a person with several Google accounts picks one instead of
|
|
25
|
+
* being signed in silently with whichever the browser used last.
|
|
26
|
+
*
|
|
27
|
+
* Use this only for a sign-in a person completes in a browser. Token refresh
|
|
28
|
+
* keeps passing DEFAULT_COGNITO itself, which never carries a prompt.
|
|
29
|
+
*/
|
|
30
|
+
export declare function interactiveLoginConfig<T extends CognitoAuthConfig>(config: T, warn?: PortWarn): T;
|
|
17
31
|
//# sourceMappingURL=cognito-callback-port.d.ts.map
|