@indigoai-us/hq-cli 5.345.250 → 5.345.252
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 +214 -0
- package/assets/scaffold/core/scripts/hq-session.sh +9 -0
- package/contracts/host-canary-release.json +9 -3
- package/dist/command-catalog.generated.d.ts +316 -2
- package/dist/command-catalog.generated.js +389 -2
- package/dist/commands/bot.js +12 -3
- package/dist/commands/core-bucket-c-work-mesh-offer-native.js +1 -1
- package/dist/commands/core-hq-session-binding.d.ts +140 -0
- package/dist/commands/core-hq-session-binding.js +363 -0
- package/dist/commands/core-hq-session-native.d.ts +23 -0
- package/dist/commands/core-hq-session-native.js +59 -9
- package/dist/commands/core-stop-autosave.js +1 -1
- package/dist/commands/core.js +10 -0
- package/dist/commands/doctor.d.ts +5 -1
- package/dist/commands/doctor.js +42 -5
- package/dist/commands/files.js +1 -1
- package/dist/commands/install-global.js +4 -2
- package/dist/commands/lanes.d.ts +2 -0
- package/dist/commands/lanes.js +9 -4
- package/dist/commands/logout.js +4 -0
- package/dist/commands/ontology-graph.d.ts +11 -2
- package/dist/commands/ontology-graph.js +130 -4
- package/dist/commands/report.js +35 -2
- package/dist/commands/sources.js +26 -8
- package/dist/commands/storage-gate.js +1 -1
- package/dist/commands/vault-retention-flag.js +2 -1
- package/dist/commands/whoami.js +1 -1
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +238 -221
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/index.js +3 -1
- package/dist/lib/agent-kit/inbox-poll-backoff-flag.js +1 -1
- package/dist/lib/agent-kit/mcp/tools.js +48 -0
- package/dist/lib/bot/fleet-bots-update-pass.js +1 -1
- package/dist/lib/bot/fleet-cron.d.ts +37 -0
- package/dist/lib/bot/fleet-cron.js +59 -12
- package/dist/lib/bot/fleet-local.d.ts +18 -0
- package/dist/lib/bot/fleet-local.js +51 -5
- package/dist/lib/bot/inbox-poll-backoff-flag.js +1 -1
- package/dist/lib/bot/signals-engine-flag.d.ts +1 -1
- package/dist/lib/bot/signals-engine-flag.js +1 -1
- package/dist/lib/cli-invite-nudge.js +1 -1
- package/dist/lib/client-version.d.ts +2 -0
- package/dist/lib/client-version.js +24 -0
- package/dist/lib/company-flag-gate.d.ts +30 -0
- package/dist/lib/company-flag-gate.js +104 -0
- package/dist/lib/core-utils/hook-timeout-debug-context-flag.js +1 -1
- package/dist/lib/daemon/flag.js +2 -1
- package/dist/lib/daemon/legacy-journal-gate.js +3 -1
- package/dist/lib/daemon/shared-flag-reads.js +1 -1
- package/dist/lib/doctor/checks/host-core.js +22 -4
- package/dist/lib/doctor/checks/jq.d.ts +27 -6
- package/dist/lib/doctor/checks/jq.js +46 -8
- package/dist/lib/doctor/client-health-reason-codes-flag.js +1 -1
- package/dist/lib/doctor/fix/refresh-sync-handoff.d.ts +1 -1
- package/dist/lib/doctor/fix/refresh-sync-handoff.js +1 -1
- package/dist/lib/flag-client-gate-headers.d.ts +38 -0
- package/dist/lib/flag-client-gate-headers.js +62 -0
- package/dist/lib/flag-client-headers.d.ts +15 -0
- package/dist/lib/flag-client-headers.js +25 -0
- 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/flag-registry-worker.js +35 -0
- package/dist/lib/flag-registry.d.ts +1 -20
- package/dist/lib/flag-registry.js +5 -81
- package/dist/lib/hook-engine/adapter-core-pin.d.ts +29 -0
- package/dist/lib/hook-engine/adapter-core-pin.js +29 -0
- package/dist/lib/hook-engine/coverage.d.ts +68 -8
- package/dist/lib/hook-engine/coverage.js +167 -25
- package/dist/lib/hook-engine/native-stop-compatibility.json +9 -4
- package/dist/lib/hook-engine/reconcile.js +3 -2
- package/dist/lib/hot-channels/graph-context.d.ts +26 -1
- package/dist/lib/hot-channels/graph-context.js +76 -9
- package/dist/lib/hot-channels/prompts/signals-pass.md +20 -0
- package/dist/lib/hot-channels/run.d.ts +1 -0
- package/dist/lib/hot-channels/signal-changes.d.ts +228 -0
- package/dist/lib/hot-channels/signal-changes.js +683 -0
- package/dist/lib/hot-channels/signals-pass.d.ts +24 -0
- package/dist/lib/hot-channels/signals-pass.js +240 -15
- package/dist/lib/lanes/outpost-worktree-pruner-flag.d.ts +1 -1
- package/dist/lib/lanes/outpost-worktree-pruner-flag.js +1 -1
- package/dist/lib/lanes/registry-flag.js +2 -1
- package/dist/lib/lanes/spawn.js +11 -1
- package/dist/lib/mesh/live/binding-intent.d.ts +61 -0
- package/dist/lib/mesh/live/binding-intent.js +201 -0
- package/dist/lib/mesh/live/binding-receipt.d.ts +157 -0
- package/dist/lib/mesh/live/binding-receipt.js +365 -0
- package/dist/lib/mesh/live/company-flag-refresh.js +1 -1
- package/dist/lib/mesh/live/daemon/doctor-telemetry.d.ts +39 -0
- package/dist/lib/mesh/live/daemon/doctor-telemetry.js +58 -0
- package/dist/lib/mesh/live/daemon/install.js +2 -1
- package/dist/lib/mesh/live/daemon/presence.js +9 -0
- package/dist/lib/mesh/live/daemon/run.d.ts +3 -0
- package/dist/lib/mesh/live/daemon/run.js +33 -1
- package/dist/lib/ontology-graph/lineage/index.d.ts +401 -0
- package/dist/lib/ontology-graph/lineage/index.js +1027 -0
- package/dist/lib/ontology-graph/model/files.d.ts +4 -0
- package/dist/lib/ontology-graph/model/files.js +23 -0
- package/dist/lib/ontology-graph/model/index.d.ts +65 -1
- package/dist/lib/ontology-graph/model/index.js +154 -18
- package/dist/lib/ontology-graph/model/pass-tasks.d.ts +84 -1
- package/dist/lib/ontology-graph/model/pass-tasks.js +173 -4
- package/dist/lib/ontology-graph/model/pass.d.ts +11 -0
- package/dist/lib/ontology-graph/model/pass.js +17 -10
- package/dist/lib/ontology-graph/model/pending-items.d.ts +39 -0
- package/dist/lib/ontology-graph/model/pending-items.js +136 -0
- package/dist/lib/ontology-graph/model/step.d.ts +47 -2
- package/dist/lib/ontology-graph/model/step.js +202 -36
- package/dist/lib/ontology-graph/model/tasks.d.ts +28 -4
- package/dist/lib/ontology-graph/model/tasks.js +48 -15
- package/dist/lib/ontology-graph/pages/render.d.ts +1 -1
- package/dist/lib/ontology-graph/pages/render.js +4 -3
- package/dist/lib/ontology-graph/read/brief.d.ts +13 -3
- package/dist/lib/ontology-graph/read/brief.js +349 -67
- package/dist/lib/ontology-graph/read/index.d.ts +5 -1
- package/dist/lib/ontology-graph/read/index.js +174 -30
- package/dist/lib/ontology-graph/read/lineage.d.ts +101 -0
- package/dist/lib/ontology-graph/read/lineage.js +262 -0
- package/dist/lib/ontology-graph/read/reader-setting.d.ts +2 -0
- package/dist/lib/ontology-graph/read/reader-setting.js +4 -1
- package/dist/lib/ontology-graph/remodel/index.d.ts +174 -0
- package/dist/lib/ontology-graph/remodel/index.js +450 -0
- package/dist/lib/ontology-graph/replay/buffered-store.js +17 -0
- package/dist/lib/ontology-graph/replay/engine.d.ts +32 -1
- package/dist/lib/ontology-graph/replay/engine.js +213 -8
- package/dist/lib/ontology-graph/replay/extractors.d.ts +26 -0
- package/dist/lib/ontology-graph/replay/extractors.js +25 -1
- package/dist/lib/ontology-graph/replay/index.d.ts +2 -0
- package/dist/lib/ontology-graph/replay/index.js +120 -8
- package/dist/lib/ontology-graph/replay/signal-changes.d.ts +118 -0
- package/dist/lib/ontology-graph/replay/signal-changes.js +687 -0
- package/dist/lib/ontology-graph/schema/authority.d.ts +14 -5
- package/dist/lib/ontology-graph/schema/authority.js +13 -3
- package/dist/lib/ontology-graph/schema/decision-status.d.ts +18 -0
- package/dist/lib/ontology-graph/schema/decision-status.js +20 -0
- package/dist/lib/ontology-graph/schema/index.d.ts +2 -1
- package/dist/lib/ontology-graph/schema/index.js +2 -1
- package/dist/lib/ontology-graph/setup/index.d.ts +88 -0
- package/dist/lib/ontology-graph/setup/index.js +499 -0
- package/dist/lib/ontology-graph/types.d.ts +21 -0
- package/dist/lib/ontology-graph/types.js +5 -0
- package/dist/lib/search-index/index.d.ts +33 -1
- package/dist/lib/search-index/index.js +180 -25
- package/dist/lib/search-index/qmd-exit-diagnostics.d.ts +7 -0
- package/dist/lib/search-index/qmd-exit-diagnostics.js +25 -1
- package/dist/lib/signals/adapters-catalog.js +1 -1
- package/dist/lib/signals/failure-alert.js +4 -5
- package/dist/lib/signals/steps/adapters.js +3 -0
- package/dist/lib/sync-core/engine-holds.d.ts +1 -0
- package/dist/lib/sync-core/engine-holds.js +26 -0
- package/dist/lib/sync-core/engine-home.d.ts +3 -0
- package/dist/lib/sync-core/engine-home.js +41 -1
- package/dist/lib/sync-core/flag.js +2 -1
- package/dist/lib/sync-core/legacy-journal-export-child.js +5 -3
- package/dist/lib/sync-core/legacy-journal-export.d.ts +23 -4
- package/dist/lib/sync-core/legacy-journal-export.js +120 -55
- package/dist/lib/sync-core/reconcile.d.ts +2 -1
- package/dist/lib/sync-core/reconcile.js +30 -5
- package/dist/lib/sync-invalid-entity-warning.js +2 -1
- package/dist/lib/windows/install-followup.d.ts +41 -0
- package/dist/lib/windows/install-followup.js +87 -0
- package/dist/lib/windows/jq.d.ts +59 -0
- package/dist/lib/windows/jq.js +154 -3
- package/dist/lib/windows/user-path.d.ts +5 -0
- package/dist/lib/windows/user-path.js +1 -1
- package/dist/lib/work-context/auto-bind.d.ts +12 -0
- package/dist/lib/work-context/auto-bind.js +49 -3
- package/dist/lib/work-context/organize.d.ts +4 -2
- package/dist/lib/work-context/organize.js +18 -8
- package/dist/lib/work-context/reconcile.js +16 -1
- package/dist/main.js +12 -1
- package/dist/utils/client-health-contract.d.ts +30 -0
- package/dist/utils/client-health-contract.js +111 -0
- package/dist/utils/client-health.d.ts +5 -2
- package/dist/utils/client-health.js +74 -5
- package/dist/utils/exclusive-lock.d.ts +5 -1
- package/dist/utils/exclusive-lock.js +9 -2
- package/dist/utils/host-registration.d.ts +7 -0
- package/dist/utils/host-registration.js +10 -1
- package/dist/utils/pid.d.ts +31 -0
- package/dist/utils/pid.js +65 -0
- package/dist/utils/resident-package-preload.js +12 -4
- package/dist/utils/sentry-fingerprint.js +3 -0
- package/dist/utils/sync-person.d.ts +15 -0
- package/dist/utils/sync-person.js +74 -0
- package/package.json +8 -8
- package/scripts/install-hook-engine.mjs +5 -3
|
@@ -8,6 +8,12 @@ export declare const PASS_TASKS: readonly PassTask[];
|
|
|
8
8
|
* output was graded against the sources (indigo, 2026-11-22), and the model that passed.
|
|
9
9
|
* A caller that wants the measured choice builds a second step with this model and passes it in `taskSteps`.
|
|
10
10
|
*/
|
|
11
|
+
/** The pass tasks a company's `model_tasks` setting leaves on: `digest` is extraction, `retype` is typing. */
|
|
12
|
+
export declare function passTasksFor(setting: {
|
|
13
|
+
extraction: boolean;
|
|
14
|
+
typing: boolean;
|
|
15
|
+
summaries: boolean;
|
|
16
|
+
}): PassTask[];
|
|
11
17
|
export declare const PASS_TASK_MODELS: Partial<Record<PassTask, string>>;
|
|
12
18
|
/** One line per model-written row: what it rests on. Written beside the graph's other state files. */
|
|
13
19
|
export declare const MODEL_ROWS_FILE = ".state/model-rows.jsonl";
|
|
@@ -34,6 +40,11 @@ export interface ModelPassOptions {
|
|
|
34
40
|
day?: IsoDate;
|
|
35
41
|
/** Digest sources this many days back. Default 90. */
|
|
36
42
|
windowDays?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Source refs digested whatever their age: sources an earlier run queued while they were inside the window
|
|
45
|
+
* and could not send. Without this a digest left pending would age out of the window unanswered.
|
|
46
|
+
*/
|
|
47
|
+
keepSources?: ReadonlySet<string>;
|
|
37
48
|
/** Rows from these audiences only. Default: every audience in the graph folder. */
|
|
38
49
|
audiences?: readonly AudienceKey[];
|
|
39
50
|
/**
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import * as fs from "node:fs";
|
|
18
18
|
import * as path from "node:path";
|
|
19
|
-
import { effectiveFacts, isOpen, isSingleValued, originTier, parseEntityRef, rowId, slugify, validateRow } from "../schema/index.js";
|
|
19
|
+
import { effectiveFacts, endsDecision, isOpen, isSingleValued, originTier, parseEntityRef, rowId, slugify, validateRow } from "../schema/index.js";
|
|
20
20
|
import { appendJsonLine, applyIngest, openGraphStore } from "../store/index.js";
|
|
21
21
|
import { createResolver } from "../resolve/index.js";
|
|
22
22
|
import { sha256Hex } from "./files.js";
|
|
@@ -28,6 +28,10 @@ export const PASS_TASKS = ["digest", "profile", "retype", "supersede", "summarie
|
|
|
28
28
|
* output was graded against the sources (indigo, 2026-11-22), and the model that passed.
|
|
29
29
|
* A caller that wants the measured choice builds a second step with this model and passes it in `taskSteps`.
|
|
30
30
|
*/
|
|
31
|
+
/** The pass tasks a company's `model_tasks` setting leaves on: `digest` is extraction, `retype` is typing. */
|
|
32
|
+
export function passTasksFor(setting) {
|
|
33
|
+
return PASS_TASKS.filter((task) => (task === "digest" ? setting.extraction : task === "retype" ? setting.typing : task === "summaries" ? setting.summaries : true));
|
|
34
|
+
}
|
|
31
35
|
export const PASS_TASK_MODELS = { retype: "sonnet", supersede: "sonnet" };
|
|
32
36
|
/** One line per model-written row: what it rests on. Written beside the graph's other state files. */
|
|
33
37
|
export const MODEL_ROWS_FILE = ".state/model-rows.jsonl";
|
|
@@ -334,7 +338,7 @@ export function signalledSources(companyRoot) {
|
|
|
334
338
|
return out;
|
|
335
339
|
}
|
|
336
340
|
const SOURCE_PATH = /^source:(sources\/(meetings|slack)\/([A-Za-z0-9._-]+)\.md)$/;
|
|
337
|
-
function digestCandidates(context, snapshot, day, windowDays, report) {
|
|
341
|
+
function digestCandidates(context, snapshot, day, windowDays, report, keep) {
|
|
338
342
|
const signalled = signalledSources(context.companyRoot);
|
|
339
343
|
const found = new Map();
|
|
340
344
|
for (const [ref, rows] of snapshot.rows) {
|
|
@@ -373,7 +377,7 @@ function digestCandidates(context, snapshot, day, windowDays, report) {
|
|
|
373
377
|
bump(report.skipped, "has signals");
|
|
374
378
|
continue;
|
|
375
379
|
}
|
|
376
|
-
if (slot.date < since) {
|
|
380
|
+
if (slot.date < since && !keep?.has(`source:${slot.relPath}`)) {
|
|
377
381
|
bump(report.skipped, `older than ${windowDays} days`);
|
|
378
382
|
continue;
|
|
379
383
|
}
|
|
@@ -389,7 +393,7 @@ function digestCandidates(context, snapshot, day, windowDays, report) {
|
|
|
389
393
|
bump(report.skipped, "file not on this machine");
|
|
390
394
|
continue;
|
|
391
395
|
}
|
|
392
|
-
const item = { src: `source:${slot.relPath}`, kind: slot.kind, date: slot.date, title: slot.title, fileText };
|
|
396
|
+
const item = { src: `source:${slot.relPath}`, kind: slot.kind, date: slot.date, title: slot.title, fileText, entities: [...slot.touched].sort(byCode) };
|
|
393
397
|
const size = compactSource(fileText).length;
|
|
394
398
|
if (size < (slot.kind === "meeting" ? 300 : 120)) {
|
|
395
399
|
bump(report.skipped, "too short to hold anything");
|
|
@@ -590,7 +594,7 @@ function applyProfile(candidate, profile, snapshot, resolve, writer, report) {
|
|
|
590
594
|
if (profile.role) {
|
|
591
595
|
const stored = cited(profile.role.cite);
|
|
592
596
|
if (stored)
|
|
593
|
-
push(stored, ref, writer.fact("role_title", profile.role.value, stored.row.date, stored.row.src), profile.role.quote);
|
|
597
|
+
push(stored, ref, writer.fact("role_title", profile.role.value, stored.row.date, stored.row.src, profile.role.conf), profile.role.quote);
|
|
594
598
|
}
|
|
595
599
|
if (profile.employer && employerOnRecord(snapshot, ref))
|
|
596
600
|
bump(report.skipped, EMPLOYER_ON_RECORD);
|
|
@@ -599,7 +603,7 @@ function applyProfile(candidate, profile, snapshot, resolve, writer, report) {
|
|
|
599
603
|
if (stored) {
|
|
600
604
|
const company = resolve(profile.employer.value, ["company"]);
|
|
601
605
|
if (company)
|
|
602
|
-
push(stored, ref, writer.edge("works_at", company, stored.row.date, stored.row.src), profile.employer.quote);
|
|
606
|
+
push(stored, ref, writer.edge("works_at", company, stored.row.date, stored.row.src, profile.employer.conf), profile.employer.quote);
|
|
603
607
|
else
|
|
604
608
|
push(stored, ref, writer.fact("affiliation", profile.employer.value, stored.row.date, stored.row.src, 0.5), profile.employer.quote);
|
|
605
609
|
}
|
|
@@ -607,7 +611,7 @@ function applyProfile(candidate, profile, snapshot, resolve, writer, report) {
|
|
|
607
611
|
if (profile.stage) {
|
|
608
612
|
const stored = cited(profile.stage.cite);
|
|
609
613
|
if (stored)
|
|
610
|
-
push(stored, ref, writer.fact("stage", profile.stage.value, stored.row.date, stored.row.src), profile.stage.quote);
|
|
614
|
+
push(stored, ref, writer.fact("stage", profile.stage.value, stored.row.date, stored.row.src, profile.stage.conf), profile.stage.quote);
|
|
611
615
|
}
|
|
612
616
|
for (const contact of profile.contacts) {
|
|
613
617
|
const stored = cited(contact.cite);
|
|
@@ -620,7 +624,7 @@ function applyProfile(candidate, profile, snapshot, resolve, writer, report) {
|
|
|
620
624
|
bump(report.skipped, EMPLOYER_ON_RECORD);
|
|
621
625
|
continue;
|
|
622
626
|
}
|
|
623
|
-
push(stored, who, writer.edge("works_at", ref, stored.row.date, stored.row.src), contact.quote);
|
|
627
|
+
push(stored, who, writer.edge("works_at", ref, stored.row.date, stored.row.src, contact.conf), contact.quote);
|
|
624
628
|
const hasRole = (snapshot.rows.get(who) ?? []).some((row) => row.row.kind === "F" && row.row.field === "role_title" && isOpen(row.row));
|
|
625
629
|
if (contact.role !== "" && !hasRole)
|
|
626
630
|
push(stored, who, writer.fact("role_title", contact.role, stored.row.date, stored.row.src, 0.5), contact.quote);
|
|
@@ -745,8 +749,11 @@ function supersessionCandidates(snapshot, report) {
|
|
|
745
749
|
bump(report.skipped, "statement under 5 words");
|
|
746
750
|
continue;
|
|
747
751
|
}
|
|
748
|
-
|
|
752
|
+
// A decision that is already replaced, reversed or withdrawn is not asked about again.
|
|
753
|
+
if (rows.some((stored) => stored.row.kind === "F" && stored.row.field === "status" && isOpen(stored.row) && endsDecision(stored.row.value))) {
|
|
754
|
+
bump(report.skipped, "already replaced, reversed or withdrawn");
|
|
749
755
|
continue;
|
|
756
|
+
}
|
|
750
757
|
const decidedOn = rows.find((stored) => stored.row.kind === "F" && stored.row.field === "decided_on" && isOpen(stored.row));
|
|
751
758
|
const date = decidedOn && decidedOn.row.kind === "F" && /^\d{4}-\d{2}-\d{2}$/.test(decidedOn.row.value) ? decidedOn.row.value : statement.row.valid.from;
|
|
752
759
|
for (const stored of rows) {
|
|
@@ -839,7 +846,7 @@ export async function runModelPass(context, options) {
|
|
|
839
846
|
const writer = new RowWriter(store, schema, snapshot, report, by, day, context.graphRoot);
|
|
840
847
|
const resolve = nameResolver(store, schema, options.audiences, report);
|
|
841
848
|
if (task === "digest") {
|
|
842
|
-
const candidates = digestCandidates(context, snapshot, day, options.windowDays ?? 90, report).slice(0, limit);
|
|
849
|
+
const candidates = digestCandidates(context, snapshot, day, options.windowDays ?? 90, report, options.keepSources).slice(0, limit);
|
|
843
850
|
const run = await step.runBatch(digestSpec(day), candidates.map((candidate) => candidate.item));
|
|
844
851
|
record(report, run.results, run.stats);
|
|
845
852
|
run.results.forEach((result, i) => {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { EntityRef, GraphSchema } from "../types.js";
|
|
2
|
+
import type { PassTask } from "./pass.js";
|
|
3
|
+
import { type ModelTaskKind, type PendingMarker } from "./step.js";
|
|
4
|
+
/** `ModelStepConfig.pendingItem` for a graph with this schema. A payload its task cannot render makes the task throw; the step treats that as unknown. */
|
|
5
|
+
export declare function pendingItemRenderer(schema: GraphSchema): (marker: PendingMarker) => {
|
|
6
|
+
rendered: unknown;
|
|
7
|
+
kind: ModelTaskKind;
|
|
8
|
+
} | null;
|
|
9
|
+
/**
|
|
10
|
+
* True for a marker the graph pass left (its follow-up work): anything that is
|
|
11
|
+
* not one of the replay's own three tasks. The replay sends its own markers
|
|
12
|
+
* again from their payloads (`resumePending`); the pass builds its items from
|
|
13
|
+
* the graph, so its markers say where to look, not what to send.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isFollowUpMarker(marker: Pick<PendingMarker, "kind" | "promptVersion">): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* The entities a follow-up marker is about. A pass scoped to them builds the
|
|
18
|
+
* marker's item again when the graph still asks the question. Empty for a
|
|
19
|
+
* marker that names none (a digest left before digests recorded their entities).
|
|
20
|
+
*/
|
|
21
|
+
export declare function followUpEntities(marker: Pick<PendingMarker, "kind" | "promptVersion" | "payload" | "itemKey">): EntityRef[];
|
|
22
|
+
/** The pass task a follow-up marker belongs to, or null. */
|
|
23
|
+
export declare function followUpTask(marker: Pick<PendingMarker, "kind" | "promptVersion">): PassTask | null;
|
|
24
|
+
type GovernedTask = "extraction" | "typing" | "summaries";
|
|
25
|
+
/** The `model_tasks` setting a pending marker falls under, or null for work the setting does not govern. */
|
|
26
|
+
export declare function markerModelTask(marker: Pick<PendingMarker, "kind" | "promptVersion">): GovernedTask | null;
|
|
27
|
+
/** True for a marker whose task the setting switches off: it is kept and counted, and nothing is sent for it. */
|
|
28
|
+
export declare function isHeldMarker(marker: Pick<PendingMarker, "kind" | "promptVersion">, setting: Record<GovernedTask, boolean>): boolean;
|
|
29
|
+
/** How many pending markers each switched-off task holds. A task that is on, or holds none, is absent. */
|
|
30
|
+
export declare function heldMarkerCounts(markers: readonly Pick<PendingMarker, "kind" | "promptVersion">[], setting: Record<GovernedTask, boolean>): Partial<Record<GovernedTask, number>>;
|
|
31
|
+
/** Every entity the follow-up markers in a list are about. */
|
|
32
|
+
export declare function followUpScope(markers: readonly Pick<PendingMarker, "kind" | "promptVersion" | "payload" | "itemKey">[]): Set<EntityRef>;
|
|
33
|
+
/**
|
|
34
|
+
* The markers of a pending file as they are on disk, without opening a step: a look that costs one
|
|
35
|
+
* read, for a run that has to decide whether there is anything to do. An unreadable file is empty.
|
|
36
|
+
*/
|
|
37
|
+
export declare function peekPendingMarkers(file: string): PendingMarker[];
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=pending-items.d.ts.map
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WP-D: what a pending marker's item is, for every task that leaves markers.
|
|
3
|
+
*
|
|
4
|
+
* The step keeps markers by item, not by model (`pendingItemId` in step.ts).
|
|
5
|
+
* To give a marker its id, and to see that another model already answered the
|
|
6
|
+
* item, the step needs the item in the canonical form its task sends. The
|
|
7
|
+
* tasks know that form; this file maps a marker to its task by the family of
|
|
8
|
+
* its prompt version and renders the payload with that task's own `renderItem`.
|
|
9
|
+
*
|
|
10
|
+
* It also says which entities a follow-up marker (profile, retype, decision
|
|
11
|
+
* supersession, page summary, digest) is about, so an update with nothing new
|
|
12
|
+
* can still look for that work on those entities.
|
|
13
|
+
*/
|
|
14
|
+
import { isEntityRef } from "../schema/index.js";
|
|
15
|
+
import { readTextIfPresent } from "./files.js";
|
|
16
|
+
import { digestSpec, lineageSpec, profileSpec, retypeSpec, supersessionSpec } from "./pass-tasks.js";
|
|
17
|
+
import { promptFamily } from "./step.js";
|
|
18
|
+
import { extractSourceSpec, fuzzySpec, isReplayMarker, relationshipSpec, summarizeSpec } from "./tasks.js";
|
|
19
|
+
/** The day a spec charges its calls to plays no part in how it renders an item. */
|
|
20
|
+
const ANY_DAY = "1970-01-01";
|
|
21
|
+
/** `ModelStepConfig.pendingItem` for a graph with this schema. A payload its task cannot render makes the task throw; the step treats that as unknown. */
|
|
22
|
+
export function pendingItemRenderer(schema) {
|
|
23
|
+
const specs = new Map();
|
|
24
|
+
for (const spec of [
|
|
25
|
+
relationshipSpec(schema, ANY_DAY),
|
|
26
|
+
fuzzySpec(ANY_DAY),
|
|
27
|
+
extractSourceSpec(schema, ANY_DAY),
|
|
28
|
+
summarizeSpec(ANY_DAY),
|
|
29
|
+
digestSpec(ANY_DAY),
|
|
30
|
+
profileSpec(ANY_DAY),
|
|
31
|
+
retypeSpec(ANY_DAY),
|
|
32
|
+
supersessionSpec(ANY_DAY),
|
|
33
|
+
lineageSpec(ANY_DAY),
|
|
34
|
+
]) {
|
|
35
|
+
specs.set(promptFamily(spec.promptVersion), spec);
|
|
36
|
+
}
|
|
37
|
+
return (marker) => {
|
|
38
|
+
const spec = specs.get(promptFamily(String(marker.promptVersion ?? "")));
|
|
39
|
+
if (!spec || marker.payload === null || typeof marker.payload !== "object")
|
|
40
|
+
return null;
|
|
41
|
+
return { rendered: spec.renderItem(marker.payload), kind: spec.kind };
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* True for a marker the graph pass left (its follow-up work): anything that is
|
|
46
|
+
* not one of the replay's own three tasks. The replay sends its own markers
|
|
47
|
+
* again from their payloads (`resumePending`); the pass builds its items from
|
|
48
|
+
* the graph, so its markers say where to look, not what to send.
|
|
49
|
+
*/
|
|
50
|
+
export function isFollowUpMarker(marker) {
|
|
51
|
+
return !isReplayMarker(marker);
|
|
52
|
+
}
|
|
53
|
+
function refs(values) {
|
|
54
|
+
return values.filter((value) => typeof value === "string" && isEntityRef(value));
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The entities a follow-up marker is about. A pass scoped to them builds the
|
|
58
|
+
* marker's item again when the graph still asks the question. Empty for a
|
|
59
|
+
* marker that names none (a digest left before digests recorded their entities).
|
|
60
|
+
*/
|
|
61
|
+
export function followUpEntities(marker) {
|
|
62
|
+
if (!isFollowUpMarker(marker))
|
|
63
|
+
return [];
|
|
64
|
+
const payload = marker.payload !== null && typeof marker.payload === "object" ? marker.payload : {};
|
|
65
|
+
const family = promptFamily(String(marker.promptVersion ?? ""));
|
|
66
|
+
const inner = (value) => (value !== null && typeof value === "object" ? value.ref : undefined);
|
|
67
|
+
if (family === "profile-entity" || family === "summarize-page")
|
|
68
|
+
return refs([payload.ref, marker.itemKey]);
|
|
69
|
+
if (family === "retype-edge")
|
|
70
|
+
return refs([inner(payload.a), inner(payload.b)]);
|
|
71
|
+
if (family === "decision-supersession")
|
|
72
|
+
return refs(Array.isArray(payload.decisions) ? payload.decisions.map(inner) : []);
|
|
73
|
+
if (family === "digest-source")
|
|
74
|
+
return refs(Array.isArray(payload.entities) ? payload.entities : []);
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
const FOLLOW_UP_TASK = {
|
|
78
|
+
"digest-source": "digest",
|
|
79
|
+
"profile-entity": "profile",
|
|
80
|
+
"retype-edge": "retype",
|
|
81
|
+
"decision-supersession": "supersede",
|
|
82
|
+
"summarize-page": "summaries",
|
|
83
|
+
};
|
|
84
|
+
/** The pass task a follow-up marker belongs to, or null. */
|
|
85
|
+
export function followUpTask(marker) {
|
|
86
|
+
if (!isFollowUpMarker(marker))
|
|
87
|
+
return null;
|
|
88
|
+
return FOLLOW_UP_TASK[promptFamily(String(marker.promptVersion ?? ""))] ?? null;
|
|
89
|
+
}
|
|
90
|
+
/** The `model_tasks` setting a pending marker falls under, or null for work the setting does not govern. */
|
|
91
|
+
export function markerModelTask(marker) {
|
|
92
|
+
if (isReplayMarker(marker))
|
|
93
|
+
return marker.kind === "type-relationship" ? "typing" : marker.kind === "extract-source" ? "extraction" : null;
|
|
94
|
+
const task = followUpTask(marker);
|
|
95
|
+
return task === "digest" ? "extraction" : task === "retype" ? "typing" : task === "summaries" ? "summaries" : null;
|
|
96
|
+
}
|
|
97
|
+
/** True for a marker whose task the setting switches off: it is kept and counted, and nothing is sent for it. */
|
|
98
|
+
export function isHeldMarker(marker, setting) {
|
|
99
|
+
const task = markerModelTask(marker);
|
|
100
|
+
return task !== null && !setting[task];
|
|
101
|
+
}
|
|
102
|
+
/** How many pending markers each switched-off task holds. A task that is on, or holds none, is absent. */
|
|
103
|
+
export function heldMarkerCounts(markers, setting) {
|
|
104
|
+
const counts = {};
|
|
105
|
+
for (const marker of markers) {
|
|
106
|
+
const task = markerModelTask(marker);
|
|
107
|
+
if (task !== null && !setting[task])
|
|
108
|
+
counts[task] = (counts[task] ?? 0) + 1;
|
|
109
|
+
}
|
|
110
|
+
return counts;
|
|
111
|
+
}
|
|
112
|
+
/** Every entity the follow-up markers in a list are about. */
|
|
113
|
+
export function followUpScope(markers) {
|
|
114
|
+
const scope = new Set();
|
|
115
|
+
for (const marker of markers)
|
|
116
|
+
for (const ref of followUpEntities(marker))
|
|
117
|
+
scope.add(ref);
|
|
118
|
+
return scope;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The markers of a pending file as they are on disk, without opening a step: a look that costs one
|
|
122
|
+
* read, for a run that has to decide whether there is anything to do. An unreadable file is empty.
|
|
123
|
+
*/
|
|
124
|
+
export function peekPendingMarkers(file) {
|
|
125
|
+
try {
|
|
126
|
+
const text = readTextIfPresent(file);
|
|
127
|
+
if (text === null)
|
|
128
|
+
return [];
|
|
129
|
+
const parsed = JSON.parse(text);
|
|
130
|
+
return Array.isArray(parsed.markers) ? parsed.markers.filter((marker) => marker !== null && typeof marker === "object") : [];
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
return [];
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=pending-items.js.map
|
|
@@ -17,17 +17,26 @@
|
|
|
17
17
|
* account is out of usage or signed out, calls stop and every unsent item
|
|
18
18
|
* gets a pending marker (`.state/model-pending.json`) that the next run picks
|
|
19
19
|
* up. A run never fails because of the model.
|
|
20
|
+
* - Pending markers are kept by item, not by model (`pendingItemId`): an item
|
|
21
|
+
* answered on any model is no longer pending. Opening the file drops every
|
|
22
|
+
* marker whose item some model has already answered, and joins the copies
|
|
23
|
+
* of one item that runs on different models left.
|
|
20
24
|
* - Ledger: one line per call in `.state/model-ledger.jsonl` with input and
|
|
21
25
|
* output tokens and wall time. Tokens are the CLI's numbers; when the CLI
|
|
22
26
|
* reports none they are bytes / 4 and the line says `estimated: true`.
|
|
23
27
|
*/
|
|
24
28
|
import type { IsoDate, ModelBudget, ModelRunner, ModelStep, ModelStepKind, ModelUsage } from "../types.js";
|
|
25
29
|
/** The contract's kinds plus the graph pass's own (pass-tasks.ts). The kind is part of the cache key and names the task in the call ledger. */
|
|
26
|
-
export type ModelTaskKind = ModelStepKind | "extract-source" | "digest-source" | "profile-entity" | "retype-edge" | "decision-supersession";
|
|
30
|
+
export type ModelTaskKind = ModelStepKind | "extract-source" | "digest-source" | "profile-entity" | "retype-edge" | "decision-supersession" | "decision-lineage";
|
|
27
31
|
export type PendingReason = "budget-day" | "budget-run" | "dry-run" | "usage-limit" | "logged-out" | "timeout" | "provider-error";
|
|
28
32
|
/** Left for the next run when an item could not be sent. */
|
|
29
33
|
export interface PendingMarker {
|
|
30
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* The item itself, whatever model was asked: `pendingItemId`. The file holds one marker per id. A marker
|
|
36
|
+
* written before markers were kept by item has none in the file and is given one when the file is opened.
|
|
37
|
+
*/
|
|
38
|
+
id: string;
|
|
39
|
+
/** The item's cache key on the model that could not be asked. */
|
|
31
40
|
key: string;
|
|
32
41
|
kind: ModelTaskKind;
|
|
33
42
|
/** The task's own id for the item (an entity ref, a pair id, a source ref). */
|
|
@@ -141,6 +150,18 @@ export interface RunTotals {
|
|
|
141
150
|
cacheHitRate: number;
|
|
142
151
|
/** Items this step left pending, by why. `budget-day` is the daily cap, `budget-run` the run's own cap. */
|
|
143
152
|
pendingByReason: Partial<Record<PendingReason, number>>;
|
|
153
|
+
/** Items in the turns a cap or a dry run refused, and an estimate of the input tokens those turns would have sent. */
|
|
154
|
+
unsentItems: number;
|
|
155
|
+
unsentInputTokens: number;
|
|
156
|
+
}
|
|
157
|
+
/** What opening the pending file did. */
|
|
158
|
+
export interface PendingCleanup {
|
|
159
|
+
/** Markers in the file, after the copies of one item were joined. */
|
|
160
|
+
held: number;
|
|
161
|
+
/** Markers dropped because some model had already answered the item. */
|
|
162
|
+
finished: number;
|
|
163
|
+
/** Markers that were a second copy of an item another marker already named (the same item, left by another model). */
|
|
164
|
+
merged: number;
|
|
144
165
|
}
|
|
145
166
|
/** The step as this package's tasks use it. A superset of the contract's `ModelStep`. */
|
|
146
167
|
export interface BatchModelStep extends ModelStep {
|
|
@@ -154,6 +175,11 @@ export interface BatchModelStep extends ModelStep {
|
|
|
154
175
|
totals(): RunTotals;
|
|
155
176
|
/** Why calls have stopped for the rest of this run, if they have. */
|
|
156
177
|
halted(): PendingReason | null;
|
|
178
|
+
/** Ids (`PendingMarker.id`) of every item this step was handed since it was created, whatever became of it. */
|
|
179
|
+
seenItems(): ReadonlySet<string>;
|
|
180
|
+
/** Drops markers by id: items the graph no longer asks about. Returns how many were held. */
|
|
181
|
+
dropPending(ids: readonly string[]): number;
|
|
182
|
+
pendingCleanup(): PendingCleanup;
|
|
157
183
|
}
|
|
158
184
|
export interface ModelStepConfig {
|
|
159
185
|
graphRoot: string;
|
|
@@ -177,7 +203,26 @@ export interface ModelStepConfig {
|
|
|
177
203
|
stateDir?: string;
|
|
178
204
|
/** Turns in flight at once. Default 1. */
|
|
179
205
|
concurrency?: number;
|
|
206
|
+
/**
|
|
207
|
+
* The canonical form of a marker's item (what its task's `renderItem` gives for the payload) and the kind
|
|
208
|
+
* the task files under now, or null for a marker of no known task. With it, a marker written before markers
|
|
209
|
+
* were kept by item gets its id, and opening the file can tell that another model already answered an item.
|
|
210
|
+
*/
|
|
211
|
+
pendingItem?: (marker: PendingMarker) => {
|
|
212
|
+
rendered: unknown;
|
|
213
|
+
kind: ModelTaskKind;
|
|
214
|
+
} | null;
|
|
215
|
+
/** Write no state file: no marker, no parked record. For a dry run that must leave the folder as it found it. */
|
|
216
|
+
readOnly?: boolean;
|
|
180
217
|
}
|
|
218
|
+
/** `extract-source.v2+2e2d68fa` -> `extract-source`: the task a prompt belongs to, whatever its version. */
|
|
219
|
+
export declare function promptFamily(promptVersion: string): string;
|
|
220
|
+
/**
|
|
221
|
+
* What a pending marker is kept under: the task (the prompt's family) and a hash of the item's canonical
|
|
222
|
+
* input. No model name and no prompt version, so the same item is one marker whichever model could not be asked, and the marker is
|
|
223
|
+
* cleared whichever model answers.
|
|
224
|
+
*/
|
|
225
|
+
export declare function pendingItemId(promptVersion: string, input: string): string;
|
|
181
226
|
/** Tokens a `claude -p` turn adds on top of our prompt and input (system prompt). Measured at about 3,000. */
|
|
182
227
|
export declare const CLI_OVERHEAD_TOKENS = 3000;
|
|
183
228
|
/**
|