@indigoai-us/hq-cli 5.345.215-beta.0 → 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 +65 -1
- package/assets/scaffold/core/scripts/hq-delegate-verify.sh +5 -2
- package/dist/command-catalog.generated.d.ts +46 -6
- package/dist/command-catalog.generated.js +53 -6
- package/dist/commands/bot.js +64 -6
- package/dist/commands/capacity.d.ts +4 -1
- package/dist/commands/capacity.js +46 -10
- package/dist/commands/cloud.js +1 -1
- 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-import.js +124 -12
- package/dist/commands/lanes.js +2 -2
- package/dist/commands/mesh.d.ts +2 -0
- package/dist/commands/mesh.js +60 -35
- package/dist/commands/sync-held.js +5 -2
- package/dist/lazy-commands.js +3 -5
- 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/probe.js +7 -1
- package/dist/lib/bot/run.js +20 -1
- package/dist/lib/bot/runtime/codex.js +1 -1
- package/dist/lib/bot/runtime/grok-acp.d.ts +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-failure.d.ts +23 -0
- package/dist/lib/bot/runtime-failure.js +43 -1
- package/dist/lib/capacity/accounts.d.ts +8 -0
- package/dist/lib/capacity/accounts.js +19 -0
- package/dist/lib/capacity/available.d.ts +154 -0
- package/dist/lib/capacity/available.js +905 -0
- package/dist/lib/capacity/codex-availability.d.ts +14 -1
- package/dist/lib/capacity/codex-availability.js +26 -1
- package/dist/lib/capacity/collectors/claude-oauth.d.ts +29 -2
- package/dist/lib/capacity/collectors/claude-oauth.js +104 -7
- package/dist/lib/capacity/collectors/codex.js +10 -7
- package/dist/lib/capacity/ledger.d.ts +37 -1
- package/dist/lib/capacity/ledger.js +207 -30
- package/dist/lib/capacity/project.d.ts +26 -0
- package/dist/lib/capacity/project.js +137 -8
- package/dist/lib/capacity/refusal-rows.d.ts +31 -0
- package/dist/lib/capacity/refusal-rows.js +61 -0
- package/dist/lib/capacity/refusal.d.ts +53 -2
- package/dist/lib/capacity/refusal.js +284 -65
- package/dist/lib/capacity/route.js +46 -11
- package/dist/lib/capacity/widget.d.ts +12 -1
- package/dist/lib/capacity/widget.js +91 -3
- package/dist/lib/daemon/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/delivery/admission.d.ts +86 -0
- package/dist/lib/delivery/admission.js +148 -0
- package/dist/lib/delivery/artifacts.d.ts +7 -1
- package/dist/lib/delivery/artifacts.js +29 -10
- package/dist/lib/delivery/attempt-id.d.ts +13 -0
- package/dist/lib/delivery/attempt-id.js +16 -0
- package/dist/lib/delivery/disposable-target.d.ts +42 -0
- package/dist/lib/delivery/disposable-target.js +111 -0
- package/dist/lib/delivery/effects.d.ts +136 -0
- package/dist/lib/delivery/effects.js +541 -0
- package/dist/lib/delivery/enrollment.d.ts +21 -17
- package/dist/lib/delivery/enrollment.js +83 -5
- package/dist/lib/delivery/escalations.d.ts +51 -0
- package/dist/lib/delivery/escalations.js +60 -0
- package/dist/lib/delivery/lease.d.ts +80 -0
- package/dist/lib/delivery/lease.js +134 -0
- package/dist/lib/delivery/migrations.d.ts +120 -4
- package/dist/lib/delivery/migrations.js +215 -15
- package/dist/lib/delivery/mqtt.d.ts +2 -0
- package/dist/lib/delivery/mqtt.js +7 -0
- package/dist/lib/delivery/reconciler.d.ts +65 -1
- package/dist/lib/delivery/reconciler.js +224 -13
- package/dist/lib/delivery/rpc/client.d.ts +22 -0
- package/dist/lib/delivery/rpc/client.js +159 -0
- package/dist/lib/delivery/rpc/port.d.ts +40 -0
- package/dist/lib/delivery/rpc/port.js +16 -0
- package/dist/lib/delivery/rpc/server.d.ts +30 -0
- package/dist/lib/delivery/rpc/server.js +205 -0
- package/dist/lib/delivery/rpc/wire.d.ts +85 -0
- package/dist/lib/delivery/rpc/wire.js +143 -0
- package/dist/lib/delivery/store.d.ts +2 -0
- package/dist/lib/delivery/store.js +4 -0
- package/dist/lib/delivery/windows-service-install.d.ts +262 -0
- package/dist/lib/delivery/windows-service-install.js +892 -0
- package/dist/lib/delivery/workers/macos.d.ts +16 -1
- package/dist/lib/delivery/workers/macos.js +54 -12
- package/dist/lib/delivery/workers/windows-service-live.d.ts +121 -0
- package/dist/lib/delivery/workers/windows-service-live.js +711 -0
- package/dist/lib/delivery/workers/windows-service-runner.d.ts +33 -0
- package/dist/lib/delivery/workers/windows-service-runner.js +82 -0
- package/dist/lib/delivery/workers/windows-service.d.ts +140 -0
- package/dist/lib/delivery/workers/windows-service.js +584 -0
- package/dist/lib/delivery/workers/windows.d.ts +32 -22
- package/dist/lib/delivery/workers/windows.js +50 -64
- package/dist/lib/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/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/files-browse-acl.js +1 -1
- package/package.json +7 -7
- package/dist/lib/delivery/workers/windows-boundary.d.ts +0 -453
- package/dist/lib/delivery/workers/windows-boundary.js +0 -693
|
@@ -20,19 +20,48 @@
|
|
|
20
20
|
* (passed or failed) and appended once to the result log. Nothing in the
|
|
21
21
|
* store is deleted. Results hold environment keys only, never values.
|
|
22
22
|
*
|
|
23
|
-
* Containment on Windows is the
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* windows-boundary.ts at runtime so it can be bundled without node_modules.
|
|
23
|
+
* Containment on Windows is the proposal 040 service host: the launcher in
|
|
24
|
+
* windows-service.ts submits to the runner over the spool and fails closed
|
|
25
|
+
* when the runner is not live. This module has no compile and no spawn path
|
|
26
|
+
* of its own, and imports only node built-ins at runtime.
|
|
28
27
|
*/
|
|
29
28
|
import { execFileSync } from "node:child_process";
|
|
30
29
|
import { createHash, randomBytes } from "node:crypto";
|
|
31
30
|
import { chmodSync, closeSync, existsSync, fsyncSync, mkdirSync, openSync, readFileSync, renameSync, writeFileSync, writeSync } from "node:fs";
|
|
32
31
|
import { isAbsolute, join } from "node:path";
|
|
33
|
-
import { evaluateBoundary } from "./windows-boundary.js";
|
|
34
32
|
export const EXECUTION_SPEC_VERSION = "hq-delivery.execution.v1";
|
|
35
33
|
export const WORKER_RESULT_VERSION = "hq-delivery.worker-result.v1";
|
|
34
|
+
/**
|
|
35
|
+
* Owner decision 2026-10-28 ("Mark Windows untrusted"). Why Windows results
|
|
36
|
+
* are untrusted, as advertised in the profile and the docs.
|
|
37
|
+
*/
|
|
38
|
+
export const WINDOWS_TRUST_NOTE = "Windows results are not trusted against a hostile job: under proposal 040 the job runs as the shared runner identity (the service's virtual account), so a job can write its own or another job's events and results. Workers are capped at standard trust and their results are never release-eligible. Closing this needs a separate job account (future work).";
|
|
39
|
+
/** The highest trust a Windows worker may hold. */
|
|
40
|
+
export const WINDOWS_MAX_TRUST = "standard";
|
|
41
|
+
function trustCapped(asked) {
|
|
42
|
+
return new WorkerRefusal("WINDOWS_TRUST_CAPPED", `a Windows worker may not hold ${asked} trust; it is capped at ${WINDOWS_MAX_TRUST} because jobs share the runner identity (shared runner identity). ${WINDOWS_TRUST_NOTE}`);
|
|
43
|
+
}
|
|
44
|
+
/** Issue an enrollment ticket for a Windows worker. Release trust is refused with WINDOWS_TRUST_CAPPED; nothing is issued. */
|
|
45
|
+
export function issueWindowsEnrollment(access, scope, request) {
|
|
46
|
+
if (request?.trust !== WINDOWS_MAX_TRUST)
|
|
47
|
+
throw trustCapped(String(request?.trust));
|
|
48
|
+
return access.issueEnrollment(scope, request);
|
|
49
|
+
}
|
|
50
|
+
/** Redeem a Windows enrollment. Release trust is refused with WINDOWS_TRUST_CAPPED, whatever the ticket allows. */
|
|
51
|
+
export function enrollWindowsWorker(access, input) {
|
|
52
|
+
if (input?.trust !== WINDOWS_MAX_TRUST)
|
|
53
|
+
throw trustCapped(String(input?.trust));
|
|
54
|
+
return access.enroll(input);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The promotion gate for Windows results. Every Windows result is untrusted,
|
|
58
|
+
* so this always refuses with WINDOWS_RESULT_UNTRUSTED. Merge point: US-008's
|
|
59
|
+
* shared release-eligibility check (assertJobTrust on the integration branch)
|
|
60
|
+
* should call this for Windows results; this base does not have it.
|
|
61
|
+
*/
|
|
62
|
+
export function assertReleaseEligible(result) {
|
|
63
|
+
throw new WorkerRefusal("WINDOWS_RESULT_UNTRUSTED", `result for job ${result.jobId} (${result.kind}) came from a Windows worker and is ${result.resultTrust ?? "untrusted"}; it cannot be promoted. ${WINDOWS_TRUST_NOTE}`);
|
|
64
|
+
}
|
|
36
65
|
/** What the native launcher contains. A job may require any of these. */
|
|
37
66
|
export const CONTAINMENT_CAPABILITIES = ["job-object-containment", "process-tree-kill", "memory-limit", "process-limit", "cpu-time-limit"];
|
|
38
67
|
export const KNOWN_CAPABILITIES = [...CONTAINMENT_CAPABILITIES, "posix-signals", "git"];
|
|
@@ -65,6 +94,8 @@ export function detectProfile() {
|
|
|
65
94
|
if (git)
|
|
66
95
|
capabilities.push("git");
|
|
67
96
|
cachedProfile = { platform, arch: process.arch, toolchains, capabilities };
|
|
97
|
+
if (platform === "windows")
|
|
98
|
+
cachedProfile.resultTrust = "untrusted";
|
|
68
99
|
return cachedProfile;
|
|
69
100
|
}
|
|
70
101
|
const COMPARATOR = /^(>=|<=|>|<|=|\^|~)?v?(\d+|[xX*])(?:\.(\d+|[xX*]))?(?:\.(\d+|[xX*]))?(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
@@ -392,64 +423,6 @@ export function helperOutcome(h) {
|
|
|
392
423
|
}
|
|
393
424
|
return { reason: "supervisor_lost", detail: `job helper exited ${h.code} without a result` };
|
|
394
425
|
}
|
|
395
|
-
function unavailable(detail, reason) {
|
|
396
|
-
return new WorkerRefusal("CONTAINMENT_UNAVAILABLE", `${detail}: ${reason}`);
|
|
397
|
-
}
|
|
398
|
-
/**
|
|
399
|
-
* The native Windows launcher (proposal 039). A job runs only through the
|
|
400
|
-
* boundary service: the probe must report all seven predicates as passing,
|
|
401
|
-
* fresh and for this installation, and the job goes to the service over the
|
|
402
|
-
* transport. There is no local compile and no same-user fallback; any missing
|
|
403
|
-
* piece is CONTAINMENT_UNAVAILABLE before the claim.
|
|
404
|
-
*/
|
|
405
|
-
export function nativeWindowsLauncher(opts = {}) {
|
|
406
|
-
const platform = opts.platform ?? process.platform;
|
|
407
|
-
// One launch per admission. A worker passes the run to launch; a caller that
|
|
408
|
-
// does not gets the most recent admission.
|
|
409
|
-
const admitted = new Map();
|
|
410
|
-
let latest;
|
|
411
|
-
const key = (run) => JSON.stringify([run.tenantId, run.runId, run.jobId]);
|
|
412
|
-
const check = (run) => {
|
|
413
|
-
if (platform !== "win32")
|
|
414
|
-
throw unavailable("BOUNDARY_SERVICE_UNAVAILABLE", `native Windows containment needs Windows; this host is ${platform}`);
|
|
415
|
-
if (!run)
|
|
416
|
-
throw unavailable("BOUNDARY_RUN_SETUP", "no admitted run");
|
|
417
|
-
const { probe, context, transport } = opts;
|
|
418
|
-
if (!probe || !context)
|
|
419
|
-
throw unavailable("BOUNDARY_SERVICE_UNAVAILABLE", "no boundary service is configured");
|
|
420
|
-
let results;
|
|
421
|
-
try {
|
|
422
|
-
results = probe.probe({ tenantId: run.tenantId, runId: run.runId, jobId: run.jobId });
|
|
423
|
-
}
|
|
424
|
-
catch (err) {
|
|
425
|
-
throw unavailable("BOUNDARY_SERVICE_UNAVAILABLE", `the boundary probe failed: ${err.message.split("\n")[0]}`);
|
|
426
|
-
}
|
|
427
|
-
const verdict = evaluateBoundary(results, context);
|
|
428
|
-
if (!verdict.ok)
|
|
429
|
-
throw unavailable(verdict.detail, verdict.reason);
|
|
430
|
-
if (!transport)
|
|
431
|
-
throw unavailable("BOUNDARY_CHANNEL_IDENTITY", "no authenticated service channel");
|
|
432
|
-
return { run, transport };
|
|
433
|
-
};
|
|
434
|
-
return {
|
|
435
|
-
prepare(run) {
|
|
436
|
-
latest = undefined;
|
|
437
|
-
const ok = check(run).run;
|
|
438
|
-
latest = key(ok);
|
|
439
|
-
admitted.set(latest, { tenantId: ok.tenantId, runId: ok.runId, jobId: ok.jobId });
|
|
440
|
-
},
|
|
441
|
-
launch(req, run) {
|
|
442
|
-
const k = run ? key(run) : latest;
|
|
443
|
-
const entry = k === undefined ? undefined : admitted.get(k);
|
|
444
|
-
if (k !== undefined)
|
|
445
|
-
admitted.delete(k);
|
|
446
|
-
if (k === latest)
|
|
447
|
-
latest = undefined;
|
|
448
|
-
const checked = check(entry);
|
|
449
|
-
return checked.transport.submit(req, checked.run);
|
|
450
|
-
},
|
|
451
|
-
};
|
|
452
|
-
}
|
|
453
426
|
/** A store error carries a string code; checked by shape so no runtime import is needed. */
|
|
454
427
|
function storeCode(err) {
|
|
455
428
|
const code = err?.code;
|
|
@@ -482,6 +455,8 @@ export class WindowsWorker {
|
|
|
482
455
|
startedAt: null,
|
|
483
456
|
finishedAt: this.now(),
|
|
484
457
|
...fields,
|
|
458
|
+
resultTrust: "untrusted",
|
|
459
|
+
releaseEligible: false,
|
|
485
460
|
};
|
|
486
461
|
}
|
|
487
462
|
refuse(spec, code, detail) {
|
|
@@ -517,6 +492,17 @@ export class WindowsWorker {
|
|
|
517
492
|
const invalid = validateSpec(spec);
|
|
518
493
|
if (invalid)
|
|
519
494
|
return this.refuse(spec, "INVALID_SPEC", invalid);
|
|
495
|
+
// Owner decision 2026-10-28: a Windows worker never runs with release trust.
|
|
496
|
+
try {
|
|
497
|
+
const trust = this.opts.access.workerTrust(this.opts.identity);
|
|
498
|
+
if (trust !== WINDOWS_MAX_TRUST) {
|
|
499
|
+
const e = trustCapped(trust);
|
|
500
|
+
return this.refuse(spec, e.code, e.detail);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
catch (err) {
|
|
504
|
+
return this.refuse(spec, storeCode(err) ?? "UNKNOWN_JOB", message(err));
|
|
505
|
+
}
|
|
520
506
|
try {
|
|
521
507
|
const { run, jobs } = this.opts.access.readRun(this.opts.identity, spec.runId);
|
|
522
508
|
if (run.tenantId !== spec.tenantId)
|
|
@@ -72,6 +72,21 @@ export interface MeetingsAdapterOptions {
|
|
|
72
72
|
/** Where a failing provider is reported. Default: a line on stderr. */
|
|
73
73
|
warn?: (message: string) => void;
|
|
74
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* The `signal_source_ref` alias for a bot transcript, or undefined when the
|
|
77
|
+
* transcript carries no id that is a safe path segment.
|
|
78
|
+
*
|
|
79
|
+
* Transcripts without `recall_bot_id` or `transcript_id` (Recall desktop-SDK
|
|
80
|
+
* recordings, legacy exports) fall back to the document `id`, which the
|
|
81
|
+
* meeting pipeline writes as `meeting:<id>`. A leading `meeting:` is stripped
|
|
82
|
+
* once from whichever id is used, so the alias is `meeting:<id>`, not
|
|
83
|
+
* `meeting:meeting:<id>`. An unsafe `recall_bot_id` does not fall back to
|
|
84
|
+
* another field: it names the bot, so a different id would split the
|
|
85
|
+
* transcript's signals from the live rider's. Anything still unsafe
|
|
86
|
+
* (a slash, `..`, another colon) gets no alias: the signals pass then keys the
|
|
87
|
+
* document by its file, and one odd record never fails the whole adapter.
|
|
88
|
+
*/
|
|
89
|
+
export declare function transcriptSignalSourceRef(frontmatter: Record<string, unknown>, transcriptId: string): string | undefined;
|
|
75
90
|
/** The adapter cursor: see the file comment. */
|
|
76
91
|
export interface MeetingsCursor {
|
|
77
92
|
vault: string | null;
|
|
@@ -193,7 +193,32 @@ async function readTranscript(dir, file, names) {
|
|
|
193
193
|
},
|
|
194
194
|
};
|
|
195
195
|
}
|
|
196
|
-
|
|
196
|
+
const MEETING_DOC_ID_PREFIX = "meeting:";
|
|
197
|
+
/**
|
|
198
|
+
* The `signal_source_ref` alias for a bot transcript, or undefined when the
|
|
199
|
+
* transcript carries no id that is a safe path segment.
|
|
200
|
+
*
|
|
201
|
+
* Transcripts without `recall_bot_id` or `transcript_id` (Recall desktop-SDK
|
|
202
|
+
* recordings, legacy exports) fall back to the document `id`, which the
|
|
203
|
+
* meeting pipeline writes as `meeting:<id>`. A leading `meeting:` is stripped
|
|
204
|
+
* once from whichever id is used, so the alias is `meeting:<id>`, not
|
|
205
|
+
* `meeting:meeting:<id>`. An unsafe `recall_bot_id` does not fall back to
|
|
206
|
+
* another field: it names the bot, so a different id would split the
|
|
207
|
+
* transcript's signals from the live rider's. Anything still unsafe
|
|
208
|
+
* (a slash, `..`, another colon) gets no alias: the signals pass then keys the
|
|
209
|
+
* document by its file, and one odd record never fails the whole adapter.
|
|
210
|
+
*/
|
|
211
|
+
export function transcriptSignalSourceRef(frontmatter, transcriptId) {
|
|
212
|
+
const raw = nonEmptyString(frontmatter.recall_bot_id) ?? transcriptId;
|
|
213
|
+
const id = raw.startsWith(MEETING_DOC_ID_PREFIX) ? raw.slice(MEETING_DOC_ID_PREFIX.length) : raw;
|
|
214
|
+
try {
|
|
215
|
+
return meetingSignalSourceRef(id);
|
|
216
|
+
}
|
|
217
|
+
catch {
|
|
218
|
+
return undefined;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
function toEvent(t, warn) {
|
|
197
222
|
const when = new Date(t.tsMs).toISOString();
|
|
198
223
|
const who = nonEmptyString(t.frontmatter.person_uid) ?? "unknown";
|
|
199
224
|
const where = nonEmptyString(t.frontmatter.meeting_platform) ?? "meeting";
|
|
@@ -208,6 +233,10 @@ function toEvent(t) {
|
|
|
208
233
|
`- Transcript: ${payloadRef}`,
|
|
209
234
|
"",
|
|
210
235
|
].join("\n");
|
|
236
|
+
const signalSourceRef = transcriptSignalSourceRef(t.frontmatter, t.transcriptId);
|
|
237
|
+
if (signalSourceRef === undefined) {
|
|
238
|
+
warn(`meetings: ${t.file} has no meeting id that is a safe path segment; landing it without a signal_source_ref`);
|
|
239
|
+
}
|
|
211
240
|
return {
|
|
212
241
|
providerId: t.transcriptId,
|
|
213
242
|
version: `${t.audienceVersion}.${t.bodyDigest}`,
|
|
@@ -219,7 +248,11 @@ function toEvent(t) {
|
|
|
219
248
|
title: t.title,
|
|
220
249
|
body,
|
|
221
250
|
payloadRef,
|
|
222
|
-
frontmatter: {
|
|
251
|
+
frontmatter: {
|
|
252
|
+
audience_source: t.audienceSource,
|
|
253
|
+
provider: MEETINGS_VAULT_SOURCE,
|
|
254
|
+
...(signalSourceRef !== undefined ? { signal_source_ref: signalSourceRef } : {}),
|
|
255
|
+
},
|
|
223
256
|
raw: { transcript: payloadRef, frontmatter: t.frontmatter, audience: [...t.audience], audience_source: t.audienceSource },
|
|
224
257
|
};
|
|
225
258
|
}
|
|
@@ -350,7 +383,7 @@ export function createMeetingsAdapter(options) {
|
|
|
350
383
|
const page = newer.slice(0, end);
|
|
351
384
|
const last = page[page.length - 1];
|
|
352
385
|
return {
|
|
353
|
-
events: [...atCursor, ...page].map(toEvent),
|
|
386
|
+
events: [...atCursor, ...page].map((t) => toEvent(t, warn)),
|
|
354
387
|
cursor: last ? new Date(last.tsMs).toISOString() : cursor,
|
|
355
388
|
hasMore: end < newer.length,
|
|
356
389
|
all,
|
|
@@ -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
|
}
|
|
@@ -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
|
+
}
|