@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.
Files changed (186) hide show
  1. package/CHANGELOG.md +214 -0
  2. package/assets/scaffold/core/scripts/hq-session.sh +9 -0
  3. package/contracts/host-canary-release.json +9 -3
  4. package/dist/command-catalog.generated.d.ts +316 -2
  5. package/dist/command-catalog.generated.js +389 -2
  6. package/dist/commands/bot.js +12 -3
  7. package/dist/commands/core-bucket-c-work-mesh-offer-native.js +1 -1
  8. package/dist/commands/core-hq-session-binding.d.ts +140 -0
  9. package/dist/commands/core-hq-session-binding.js +363 -0
  10. package/dist/commands/core-hq-session-native.d.ts +23 -0
  11. package/dist/commands/core-hq-session-native.js +59 -9
  12. package/dist/commands/core-stop-autosave.js +1 -1
  13. package/dist/commands/core.js +10 -0
  14. package/dist/commands/doctor.d.ts +5 -1
  15. package/dist/commands/doctor.js +42 -5
  16. package/dist/commands/files.js +1 -1
  17. package/dist/commands/install-global.js +4 -2
  18. package/dist/commands/lanes.d.ts +2 -0
  19. package/dist/commands/lanes.js +9 -4
  20. package/dist/commands/logout.js +4 -0
  21. package/dist/commands/ontology-graph.d.ts +11 -2
  22. package/dist/commands/ontology-graph.js +130 -4
  23. package/dist/commands/report.js +35 -2
  24. package/dist/commands/sources.js +26 -8
  25. package/dist/commands/storage-gate.js +1 -1
  26. package/dist/commands/vault-retention-flag.js +2 -1
  27. package/dist/commands/whoami.js +1 -1
  28. package/dist/hq-cloud-sync-runner/bin/sync-runner.js +238 -221
  29. package/dist/hq-cloud-sync-runner/package.json +1 -1
  30. package/dist/index.js +3 -1
  31. package/dist/lib/agent-kit/inbox-poll-backoff-flag.js +1 -1
  32. package/dist/lib/agent-kit/mcp/tools.js +48 -0
  33. package/dist/lib/bot/fleet-bots-update-pass.js +1 -1
  34. package/dist/lib/bot/fleet-cron.d.ts +37 -0
  35. package/dist/lib/bot/fleet-cron.js +59 -12
  36. package/dist/lib/bot/fleet-local.d.ts +18 -0
  37. package/dist/lib/bot/fleet-local.js +51 -5
  38. package/dist/lib/bot/inbox-poll-backoff-flag.js +1 -1
  39. package/dist/lib/bot/signals-engine-flag.d.ts +1 -1
  40. package/dist/lib/bot/signals-engine-flag.js +1 -1
  41. package/dist/lib/cli-invite-nudge.js +1 -1
  42. package/dist/lib/client-version.d.ts +2 -0
  43. package/dist/lib/client-version.js +24 -0
  44. package/dist/lib/company-flag-gate.d.ts +30 -0
  45. package/dist/lib/company-flag-gate.js +104 -0
  46. package/dist/lib/core-utils/hook-timeout-debug-context-flag.js +1 -1
  47. package/dist/lib/daemon/flag.js +2 -1
  48. package/dist/lib/daemon/legacy-journal-gate.js +3 -1
  49. package/dist/lib/daemon/shared-flag-reads.js +1 -1
  50. package/dist/lib/doctor/checks/host-core.js +22 -4
  51. package/dist/lib/doctor/checks/jq.d.ts +27 -6
  52. package/dist/lib/doctor/checks/jq.js +46 -8
  53. package/dist/lib/doctor/client-health-reason-codes-flag.js +1 -1
  54. package/dist/lib/doctor/fix/refresh-sync-handoff.d.ts +1 -1
  55. package/dist/lib/doctor/fix/refresh-sync-handoff.js +1 -1
  56. package/dist/lib/flag-client-gate-headers.d.ts +38 -0
  57. package/dist/lib/flag-client-gate-headers.js +62 -0
  58. package/dist/lib/flag-client-headers.d.ts +15 -0
  59. package/dist/lib/flag-client-headers.js +25 -0
  60. package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
  61. package/dist/lib/flag-registry-worker-source.generated.js +1 -1
  62. package/dist/lib/flag-registry-worker.js +35 -0
  63. package/dist/lib/flag-registry.d.ts +1 -20
  64. package/dist/lib/flag-registry.js +5 -81
  65. package/dist/lib/hook-engine/adapter-core-pin.d.ts +29 -0
  66. package/dist/lib/hook-engine/adapter-core-pin.js +29 -0
  67. package/dist/lib/hook-engine/coverage.d.ts +68 -8
  68. package/dist/lib/hook-engine/coverage.js +167 -25
  69. package/dist/lib/hook-engine/native-stop-compatibility.json +9 -4
  70. package/dist/lib/hook-engine/reconcile.js +3 -2
  71. package/dist/lib/hot-channels/graph-context.d.ts +26 -1
  72. package/dist/lib/hot-channels/graph-context.js +76 -9
  73. package/dist/lib/hot-channels/prompts/signals-pass.md +20 -0
  74. package/dist/lib/hot-channels/run.d.ts +1 -0
  75. package/dist/lib/hot-channels/signal-changes.d.ts +228 -0
  76. package/dist/lib/hot-channels/signal-changes.js +683 -0
  77. package/dist/lib/hot-channels/signals-pass.d.ts +24 -0
  78. package/dist/lib/hot-channels/signals-pass.js +240 -15
  79. package/dist/lib/lanes/outpost-worktree-pruner-flag.d.ts +1 -1
  80. package/dist/lib/lanes/outpost-worktree-pruner-flag.js +1 -1
  81. package/dist/lib/lanes/registry-flag.js +2 -1
  82. package/dist/lib/lanes/spawn.js +11 -1
  83. package/dist/lib/mesh/live/binding-intent.d.ts +61 -0
  84. package/dist/lib/mesh/live/binding-intent.js +201 -0
  85. package/dist/lib/mesh/live/binding-receipt.d.ts +157 -0
  86. package/dist/lib/mesh/live/binding-receipt.js +365 -0
  87. package/dist/lib/mesh/live/company-flag-refresh.js +1 -1
  88. package/dist/lib/mesh/live/daemon/doctor-telemetry.d.ts +39 -0
  89. package/dist/lib/mesh/live/daemon/doctor-telemetry.js +58 -0
  90. package/dist/lib/mesh/live/daemon/install.js +2 -1
  91. package/dist/lib/mesh/live/daemon/presence.js +9 -0
  92. package/dist/lib/mesh/live/daemon/run.d.ts +3 -0
  93. package/dist/lib/mesh/live/daemon/run.js +33 -1
  94. package/dist/lib/ontology-graph/lineage/index.d.ts +401 -0
  95. package/dist/lib/ontology-graph/lineage/index.js +1027 -0
  96. package/dist/lib/ontology-graph/model/files.d.ts +4 -0
  97. package/dist/lib/ontology-graph/model/files.js +23 -0
  98. package/dist/lib/ontology-graph/model/index.d.ts +65 -1
  99. package/dist/lib/ontology-graph/model/index.js +154 -18
  100. package/dist/lib/ontology-graph/model/pass-tasks.d.ts +84 -1
  101. package/dist/lib/ontology-graph/model/pass-tasks.js +173 -4
  102. package/dist/lib/ontology-graph/model/pass.d.ts +11 -0
  103. package/dist/lib/ontology-graph/model/pass.js +17 -10
  104. package/dist/lib/ontology-graph/model/pending-items.d.ts +39 -0
  105. package/dist/lib/ontology-graph/model/pending-items.js +136 -0
  106. package/dist/lib/ontology-graph/model/step.d.ts +47 -2
  107. package/dist/lib/ontology-graph/model/step.js +202 -36
  108. package/dist/lib/ontology-graph/model/tasks.d.ts +28 -4
  109. package/dist/lib/ontology-graph/model/tasks.js +48 -15
  110. package/dist/lib/ontology-graph/pages/render.d.ts +1 -1
  111. package/dist/lib/ontology-graph/pages/render.js +4 -3
  112. package/dist/lib/ontology-graph/read/brief.d.ts +13 -3
  113. package/dist/lib/ontology-graph/read/brief.js +349 -67
  114. package/dist/lib/ontology-graph/read/index.d.ts +5 -1
  115. package/dist/lib/ontology-graph/read/index.js +174 -30
  116. package/dist/lib/ontology-graph/read/lineage.d.ts +101 -0
  117. package/dist/lib/ontology-graph/read/lineage.js +262 -0
  118. package/dist/lib/ontology-graph/read/reader-setting.d.ts +2 -0
  119. package/dist/lib/ontology-graph/read/reader-setting.js +4 -1
  120. package/dist/lib/ontology-graph/remodel/index.d.ts +174 -0
  121. package/dist/lib/ontology-graph/remodel/index.js +450 -0
  122. package/dist/lib/ontology-graph/replay/buffered-store.js +17 -0
  123. package/dist/lib/ontology-graph/replay/engine.d.ts +32 -1
  124. package/dist/lib/ontology-graph/replay/engine.js +213 -8
  125. package/dist/lib/ontology-graph/replay/extractors.d.ts +26 -0
  126. package/dist/lib/ontology-graph/replay/extractors.js +25 -1
  127. package/dist/lib/ontology-graph/replay/index.d.ts +2 -0
  128. package/dist/lib/ontology-graph/replay/index.js +120 -8
  129. package/dist/lib/ontology-graph/replay/signal-changes.d.ts +118 -0
  130. package/dist/lib/ontology-graph/replay/signal-changes.js +687 -0
  131. package/dist/lib/ontology-graph/schema/authority.d.ts +14 -5
  132. package/dist/lib/ontology-graph/schema/authority.js +13 -3
  133. package/dist/lib/ontology-graph/schema/decision-status.d.ts +18 -0
  134. package/dist/lib/ontology-graph/schema/decision-status.js +20 -0
  135. package/dist/lib/ontology-graph/schema/index.d.ts +2 -1
  136. package/dist/lib/ontology-graph/schema/index.js +2 -1
  137. package/dist/lib/ontology-graph/setup/index.d.ts +88 -0
  138. package/dist/lib/ontology-graph/setup/index.js +499 -0
  139. package/dist/lib/ontology-graph/types.d.ts +21 -0
  140. package/dist/lib/ontology-graph/types.js +5 -0
  141. package/dist/lib/search-index/index.d.ts +33 -1
  142. package/dist/lib/search-index/index.js +180 -25
  143. package/dist/lib/search-index/qmd-exit-diagnostics.d.ts +7 -0
  144. package/dist/lib/search-index/qmd-exit-diagnostics.js +25 -1
  145. package/dist/lib/signals/adapters-catalog.js +1 -1
  146. package/dist/lib/signals/failure-alert.js +4 -5
  147. package/dist/lib/signals/steps/adapters.js +3 -0
  148. package/dist/lib/sync-core/engine-holds.d.ts +1 -0
  149. package/dist/lib/sync-core/engine-holds.js +26 -0
  150. package/dist/lib/sync-core/engine-home.d.ts +3 -0
  151. package/dist/lib/sync-core/engine-home.js +41 -1
  152. package/dist/lib/sync-core/flag.js +2 -1
  153. package/dist/lib/sync-core/legacy-journal-export-child.js +5 -3
  154. package/dist/lib/sync-core/legacy-journal-export.d.ts +23 -4
  155. package/dist/lib/sync-core/legacy-journal-export.js +120 -55
  156. package/dist/lib/sync-core/reconcile.d.ts +2 -1
  157. package/dist/lib/sync-core/reconcile.js +30 -5
  158. package/dist/lib/sync-invalid-entity-warning.js +2 -1
  159. package/dist/lib/windows/install-followup.d.ts +41 -0
  160. package/dist/lib/windows/install-followup.js +87 -0
  161. package/dist/lib/windows/jq.d.ts +59 -0
  162. package/dist/lib/windows/jq.js +154 -3
  163. package/dist/lib/windows/user-path.d.ts +5 -0
  164. package/dist/lib/windows/user-path.js +1 -1
  165. package/dist/lib/work-context/auto-bind.d.ts +12 -0
  166. package/dist/lib/work-context/auto-bind.js +49 -3
  167. package/dist/lib/work-context/organize.d.ts +4 -2
  168. package/dist/lib/work-context/organize.js +18 -8
  169. package/dist/lib/work-context/reconcile.js +16 -1
  170. package/dist/main.js +12 -1
  171. package/dist/utils/client-health-contract.d.ts +30 -0
  172. package/dist/utils/client-health-contract.js +111 -0
  173. package/dist/utils/client-health.d.ts +5 -2
  174. package/dist/utils/client-health.js +74 -5
  175. package/dist/utils/exclusive-lock.d.ts +5 -1
  176. package/dist/utils/exclusive-lock.js +9 -2
  177. package/dist/utils/host-registration.d.ts +7 -0
  178. package/dist/utils/host-registration.js +10 -1
  179. package/dist/utils/pid.d.ts +31 -0
  180. package/dist/utils/pid.js +65 -0
  181. package/dist/utils/resident-package-preload.js +12 -4
  182. package/dist/utils/sentry-fingerprint.js +3 -0
  183. package/dist/utils/sync-person.d.ts +15 -0
  184. package/dist/utils/sync-person.js +74 -0
  185. package/package.json +8 -8
  186. package/scripts/install-hook-engine.mjs +5 -3
@@ -1,6 +1,22 @@
1
1
  import * as path from "node:path";
2
- import { MODEL_STATE_PATHS, appendJsonLineSync, estimateTokens, readJsonLinesSync, readTextIfPresent, sha256Hex, stableStringify, statePath, writeFileAtomicSync, } from "./files.js";
2
+ import { MODEL_STATE_PATHS, appendJsonLineSync, estimateTokens, fileStampSync, listFileNamesSync, readJsonLinesSync, readTextIfPresent, sha256Hex, stableStringify, statePath, writeFileAtomicSync, } from "./files.js";
3
3
  import { ModelRunnerError } from "./runner.js";
4
+ /** `extract-source.v2+2e2d68fa` -> `extract-source`: the task a prompt belongs to, whatever its version. */
5
+ export function promptFamily(promptVersion) {
6
+ const cut = /^(.+?)\.v\d+(?:[+.-].*)?$/.exec(promptVersion);
7
+ return cut ? cut[1] : promptVersion;
8
+ }
9
+ /**
10
+ * What a pending marker is kept under: the task (the prompt's family) and a hash of the item's canonical
11
+ * 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
12
+ * cleared whichever model answers.
13
+ */
14
+ export function pendingItemId(promptVersion, input) {
15
+ const family = promptFamily(promptVersion);
16
+ return `${family}:${sha256Hex(`${family}\n${input}`).slice(0, 32)}`;
17
+ }
18
+ /** Id of a marker whose item cannot be rendered (no `pendingItem`, or a payload of no known task): its own cache key. */
19
+ const LEGACY_ID = "key:";
4
20
  /** Tokens a `claude -p` turn adds on top of our prompt and input (system prompt). Measured at about 3,000. */
5
21
  export const CLI_OVERHEAD_TOKENS = 3_000;
6
22
  const DEFAULT_MAX_ITEMS = 20;
@@ -52,36 +68,139 @@ export function createBatchModelStep(config) {
52
68
  // Per-day use, seeded from the ledger so the day cap holds across runs. The cap is per model: a
53
69
  // step on a stronger model for two small tasks is not refused because the cheap model's day is spent.
54
70
  const dayUsed = new Map();
71
+ /** Every model the call ledger names, and this one: the models that may hold a reply for an item. */
72
+ const knownModels = new Set([config.model]);
55
73
  for (const line of readJsonLinesSync(ledgerFile)) {
56
74
  if (line.type !== "call" || typeof line.day !== "string")
57
75
  continue;
76
+ if (typeof line.model === "string")
77
+ knownModels.add(line.model);
58
78
  if (typeof line.model === "string" && line.model !== config.model)
59
79
  continue;
60
80
  const used = dayUsed.get(line.day) ?? zero();
61
81
  add(used, { inputTokens: Number(line.inputTokens) || 0, outputTokens: Number(line.outputTokens) || 0 });
62
82
  dayUsed.set(line.day, used);
63
83
  }
64
- const pendingMarkers = new Map();
65
- const pendingText = readTextIfPresent(pendingFile);
66
- if (pendingText !== null) {
84
+ // ---- pending markers: one per item (`pendingItemId`), whatever model could not be asked ----
85
+ /** A marker's item as its task renders it. Memoised by cache key while the file is being opened. */
86
+ let renderMemo = new Map();
87
+ const renderMarker = (marker) => {
88
+ const known = renderMemo?.get(marker.key);
89
+ if (known !== undefined)
90
+ return known;
91
+ let out = null;
92
+ const payload = marker.payload;
93
+ if (payload !== null && typeof payload === "object") {
94
+ const keys = Object.keys(payload);
95
+ const input = payload.input;
96
+ if (keys.length === 1 && typeof input === "string")
97
+ out = { input, kind: marker.kind }; // left by `run`
98
+ else if (config.pendingItem) {
99
+ try {
100
+ const item = config.pendingItem(marker);
101
+ if (item)
102
+ out = { input: stableStringify(item.rendered), kind: item.kind };
103
+ }
104
+ catch {
105
+ // A payload its task cannot render: the marker keeps its own cache key as its id.
106
+ }
107
+ }
108
+ }
109
+ renderMemo?.set(marker.key, out);
110
+ return out;
111
+ };
112
+ const idOf = (marker) => {
113
+ // An id is of its own task: one that names another (a marker copied by hand) is worked out again.
114
+ if (typeof marker.id === "string" && marker.id.startsWith(`${promptFamily(String(marker.promptVersion ?? ""))}:`))
115
+ return marker.id;
116
+ const item = renderMarker(marker);
117
+ return item ? pendingItemId(String(marker.promptVersion ?? ""), item.input) : `${LEGACY_ID}${marker.key}`;
118
+ };
119
+ /** The file, one marker per item. Copies of one item (left by different models) are joined: earliest time, latest payload. */
120
+ const readPendingFile = () => {
121
+ const markers = new Map();
122
+ let merged = 0;
123
+ const text = readTextIfPresent(pendingFile);
124
+ if (text === null)
125
+ return { markers, merged };
67
126
  try {
68
- const parsed = JSON.parse(pendingText);
69
- for (const marker of parsed.markers ?? [])
70
- if (marker && typeof marker.key === "string")
71
- pendingMarkers.set(marker.key, marker);
127
+ const parsed = JSON.parse(text);
128
+ for (const marker of parsed.markers ?? []) {
129
+ if (!marker || typeof marker.key !== "string")
130
+ continue;
131
+ const id = idOf(marker);
132
+ const earlier = markers.get(id);
133
+ if (earlier)
134
+ merged += 1;
135
+ markers.set(id, { ...marker, id, at: earlier && earlier.at < marker.at ? earlier.at : marker.at });
136
+ }
72
137
  }
73
138
  catch {
74
139
  // An unreadable marker file loses nothing: callers submit their items again.
75
140
  }
141
+ return { markers, merged };
142
+ };
143
+ const opened = readPendingFile();
144
+ let pendingMarkers = opened.markers;
145
+ /** What this step set (a marker) or cleared (null) since it last wrote the file. */
146
+ const changes = new Map();
147
+ const cleanup = { held: pendingMarkers.size, finished: 0, merged: opened.merged };
148
+ if (pendingMarkers.size > 0) {
149
+ // An item some model has answered is not pending, whichever model the marker was left for.
150
+ const cacheNames = new Set(listFileNamesSync(cacheDir));
151
+ const answered = (marker) => {
152
+ if (cacheNames.has(`${marker.key}.json`))
153
+ return true;
154
+ const item = renderMarker(marker);
155
+ if (!item)
156
+ return false;
157
+ for (const model of knownModels) {
158
+ for (const kind of new Set([marker.kind, item.kind])) {
159
+ if (cacheNames.has(`${cacheKeyFor({ promptVersion: marker.promptVersion, kind, input: item.input, model })}.json`))
160
+ return true;
161
+ }
162
+ }
163
+ return false;
164
+ };
165
+ for (const [id, marker] of [...pendingMarkers]) {
166
+ if (!answered(marker))
167
+ continue;
168
+ pendingMarkers.delete(id);
169
+ changes.set(id, null);
170
+ cleanup.finished += 1;
171
+ }
76
172
  }
77
- let pendingDirty = false;
173
+ renderMemo = null;
174
+ let pendingStamp = fileStampSync(pendingFile);
175
+ let pendingDirty = cleanup.finished > 0 || cleanup.merged > 0;
176
+ /** Another step of this run (a second model for some tasks) may have written the file: start from it, then apply this step's changes. */
177
+ const syncPending = () => {
178
+ if (fileStampSync(pendingFile) === pendingStamp)
179
+ return;
180
+ const fresh = readPendingFile().markers;
181
+ for (const [id, marker] of changes) {
182
+ if (marker === null)
183
+ fresh.delete(id);
184
+ else
185
+ fresh.set(id, marker);
186
+ }
187
+ pendingMarkers = fresh;
188
+ pendingStamp = fileStampSync(pendingFile);
189
+ };
190
+ const sortedPending = () => [...pendingMarkers.values()].sort((a, b) => (a.at !== b.at ? (a.at < b.at ? -1 : 1) : a.key < b.key ? -1 : 1));
78
191
  const savePending = () => {
79
- if (!pendingDirty)
192
+ if (!pendingDirty || config.readOnly)
80
193
  return;
81
- const markers = [...pendingMarkers.values()].sort((a, b) => (a.at !== b.at ? (a.at < b.at ? -1 : 1) : a.key < b.key ? -1 : 1));
82
- writeFileAtomicSync(pendingFile, `${JSON.stringify({ version: 1, markers }, null, 1)}\n`);
194
+ syncPending();
195
+ writeFileAtomicSync(pendingFile, `${JSON.stringify({ version: 2, markers: sortedPending() }, null, 1)}\n`);
196
+ pendingStamp = fileStampSync(pendingFile);
197
+ changes.clear();
83
198
  pendingDirty = false;
84
199
  };
200
+ // The cleanup is written when the file is opened, so the next run (on any model) does not find the stale markers.
201
+ if (!config.dryRun)
202
+ savePending();
203
+ const seen = new Set();
85
204
  const parkedRecords = new Map();
86
205
  for (const record of readJsonLinesSync(parkedFile)) {
87
206
  if (record && typeof record.key === "string")
@@ -90,7 +209,7 @@ export function createBatchModelStep(config) {
90
209
  let window = {
91
210
  calls: 0, cacheHits: 0, pending: 0, errors: 0, used: zero(),
92
211
  };
93
- const total = { calls: 0, cacheHits: 0, pending: 0, parked: 0, errors: 0, used: zero(), estimatedCalls: 0, wallMs: 0, sent: 0 };
212
+ const total = { calls: 0, cacheHits: 0, pending: 0, parked: 0, errors: 0, used: zero(), estimatedCalls: 0, wallMs: 0, sent: 0, unsentItems: 0, unsentInputTokens: 0 };
94
213
  const pendingByReason = {};
95
214
  let haltReason = null;
96
215
  let budgetStopped = false;
@@ -111,24 +230,39 @@ export function createBatchModelStep(config) {
111
230
  const file = { v: 1, key, kind, promptVersion, model: config.model, at: now().toISOString(), output };
112
231
  writeFileAtomicSync(`${cacheDir}/${key}.json`, `${JSON.stringify(file)}\n`);
113
232
  };
114
- const clearPending = (key) => {
115
- if (pendingMarkers.delete(key))
116
- pendingDirty = true;
233
+ /** The item is answered (or parked): no marker for it stays, under its id or under the cache key of an unrendered marker. */
234
+ const clearPending = (id, cacheKey) => {
235
+ for (const each of [id, `${LEGACY_ID}${cacheKey}`]) {
236
+ // Recorded even when this step holds no such marker: the file may, from another step of the run.
237
+ changes.set(each, null);
238
+ if (pendingMarkers.delete(each))
239
+ pendingDirty = true;
240
+ }
117
241
  };
118
242
  const markPending = (marker) => {
119
- const existing = pendingMarkers.get(marker.key);
120
- pendingMarkers.set(marker.key, { ...marker, at: existing?.at ?? now().toISOString() });
243
+ const existing = pendingMarkers.get(marker.id);
244
+ const full = { ...marker, at: existing?.at ?? now().toISOString() };
245
+ pendingMarkers.set(marker.id, full);
246
+ changes.set(marker.id, full);
247
+ if (pendingMarkers.delete(`${LEGACY_ID}${marker.key}`))
248
+ changes.set(`${LEGACY_ID}${marker.key}`, null);
121
249
  pendingDirty = true;
122
250
  window.pending += 1;
123
251
  total.pending += 1;
124
252
  pendingByReason[marker.reason] = (pendingByReason[marker.reason] ?? 0) + 1;
125
253
  };
126
- const park = (record) => {
254
+ const park = (record, id) => {
127
255
  const full = { ...record, at: now().toISOString() };
128
256
  parkedRecords.set(record.key, full);
129
- appendJsonLineSync(parkedFile, full);
257
+ if (!config.readOnly)
258
+ appendJsonLineSync(parkedFile, full);
130
259
  total.parked += 1;
131
- clearPending(record.key);
260
+ clearPending(id, record.key);
261
+ };
262
+ /** A turn a cap or a dry run refused: counted, so a dry run can say what the work would cost. */
263
+ const noteUnsent = (items, estimateIn) => {
264
+ total.unsentItems += items;
265
+ total.unsentInputTokens += estimateIn;
132
266
  };
133
267
  // Once a cap refuses a call, calls stay stopped for that day (or the run), so
134
268
  // a smaller batch later in the same day does not slip past the cap.
@@ -237,19 +371,22 @@ export function createBatchModelStep(config) {
237
371
  });
238
372
  const run = async (request) => {
239
373
  const cacheKey = cacheKeyFor({ promptVersion: request.promptVersion, kind: request.kind, input: request.input, model: config.model });
374
+ const id = pendingItemId(request.promptVersion, request.input);
375
+ seen.add(id);
240
376
  const cached = readCache(cacheKey);
241
377
  if (cached !== null) {
242
378
  window.cacheHits += 1;
243
379
  total.cacheHits += 1;
244
- clearPending(cacheKey);
380
+ clearPending(id, cacheKey);
245
381
  savePending();
246
382
  return { status: "cached", cacheKey, output: cached, usage: zero() };
247
383
  }
248
384
  const estimateIn = estimateTokens(`${request.prompt}\n${request.input}`) + CLI_OVERHEAD_TOKENS;
249
385
  const refused = refusal(request.day, estimateIn);
250
386
  if (refused) {
387
+ noteUnsent(1, estimateIn);
251
388
  markPending({
252
- key: cacheKey, kind: request.kind, itemKey: cacheKey.slice(0, 12), day: request.day, reason: refused,
389
+ id, key: cacheKey, kind: request.kind, itemKey: id.slice(-12), day: request.day, reason: refused,
253
390
  promptVersion: request.promptVersion, payload: { input: request.input },
254
391
  });
255
392
  savePending();
@@ -259,14 +396,14 @@ export function createBatchModelStep(config) {
259
396
  const outcome = await call(request, request.prompt, request.input, 1, 1, () => "ok", request.maxOutputTokens);
260
397
  if (outcome.failure || outcome.output === undefined) {
261
398
  markPending({
262
- key: cacheKey, kind: request.kind, itemKey: cacheKey.slice(0, 12), day: request.day, reason: outcome.failure ?? "provider-error",
399
+ id, key: cacheKey, kind: request.kind, itemKey: id.slice(-12), day: request.day, reason: outcome.failure ?? "provider-error",
263
400
  promptVersion: request.promptVersion, payload: { input: request.input },
264
401
  });
265
402
  savePending();
266
403
  return { status: "error", cacheKey, usage: { inputTokens: outcome.usage.inputTokens, outputTokens: outcome.usage.outputTokens }, error: outcome.failure ?? "provider-error" };
267
404
  }
268
405
  writeCache(cacheKey, request.kind, request.promptVersion, outcome.output);
269
- clearPending(cacheKey);
406
+ clearPending(id, cacheKey);
270
407
  savePending();
271
408
  return { status: "ok", cacheKey, output: outcome.output, usage: { inputTokens: outcome.usage.inputTokens, outputTokens: outcome.usage.outputTokens } };
272
409
  };
@@ -275,18 +412,20 @@ export function createBatchModelStep(config) {
275
412
  const results = new Array(items.length);
276
413
  const batchStats = { items: items.length, cacheHits: 0, calls: 0, ok: 0, pending: 0, parked: 0, usage: zero(), estimated: false, seconds: 0 };
277
414
  const toSend = [];
278
- const seen = new Map();
415
+ const firstIndex = new Map();
279
416
  const duplicates = [];
280
417
  items.forEach((item, index) => {
281
418
  const input = stableStringify(spec.renderItem(item));
282
419
  const cacheKey = cacheKeyFor({ promptVersion: spec.promptVersion, kind: spec.kind, input, model: config.model });
283
420
  const itemKey = spec.itemKey(item);
284
- const first = seen.get(cacheKey);
421
+ const id = pendingItemId(spec.promptVersion, input);
422
+ seen.add(id);
423
+ const first = firstIndex.get(cacheKey);
285
424
  if (first !== undefined) {
286
425
  duplicates.push({ index, of: first });
287
426
  return;
288
427
  }
289
- seen.set(cacheKey, index);
428
+ firstIndex.set(cacheKey, index);
290
429
  const cached = readCache(cacheKey);
291
430
  if (cached !== null) {
292
431
  try {
@@ -294,7 +433,7 @@ export function createBatchModelStep(config) {
294
433
  window.cacheHits += 1;
295
434
  total.cacheHits += 1;
296
435
  batchStats.cacheHits += 1;
297
- clearPending(cacheKey);
436
+ clearPending(id, cacheKey);
298
437
  return;
299
438
  }
300
439
  catch {
@@ -307,15 +446,15 @@ export function createBatchModelStep(config) {
307
446
  batchStats.parked += 1;
308
447
  return;
309
448
  }
310
- toSend.push({ item, itemKey, cacheKey, input, bytes: Buffer.byteLength(input, "utf8"), index });
449
+ toSend.push({ item, itemKey, id, cacheKey, input, bytes: Buffer.byteLength(input, "utf8"), index });
311
450
  });
312
451
  const setPending = (entry, reason, usage) => {
313
- markPending({ key: entry.cacheKey, kind: spec.kind, itemKey: entry.itemKey, day: spec.day, reason, promptVersion: spec.promptVersion, payload: entry.item });
452
+ markPending({ id: entry.id, key: entry.cacheKey, kind: spec.kind, itemKey: entry.itemKey, day: spec.day, reason, promptVersion: spec.promptVersion, payload: entry.item });
314
453
  results[entry.index] = { item: entry.item, itemKey: entry.itemKey, cacheKey: entry.cacheKey, status: "pending", reason, usage };
315
454
  batchStats.pending += 1;
316
455
  };
317
456
  const setParked = (entry, reason, attempts, usage) => {
318
- park({ key: entry.cacheKey, kind: spec.kind, itemKey: entry.itemKey, day: spec.day, reason, attempts });
457
+ park({ key: entry.cacheKey, kind: spec.kind, itemKey: entry.itemKey, day: spec.day, reason, attempts }, entry.id);
319
458
  results[entry.index] = { item: entry.item, itemKey: entry.itemKey, cacheKey: entry.cacheKey, status: "parked", reason, usage };
320
459
  batchStats.parked += 1;
321
460
  };
@@ -338,9 +477,12 @@ export function createBatchModelStep(config) {
338
477
  /** Sends one turn. Returns each entry's parsed answer (or a reason), and what the turn cost per entry. */
339
478
  const sendTurn = async (entries, attempt, prompt) => {
340
479
  const input = `{"items":[${entries.map((entry, i) => `{"id":"i${i + 1}","data":${entry.input}}`).join(",")}]}`;
341
- const refused = refusal(spec.day, estimateTokens(`${prompt}\n${input}`) + CLI_OVERHEAD_TOKENS);
342
- if (refused)
480
+ const estimateIn = estimateTokens(`${prompt}\n${input}`) + CLI_OVERHEAD_TOKENS;
481
+ const refused = refusal(spec.day, estimateIn);
482
+ if (refused) {
483
+ noteUnsent(entries.length, estimateIn);
343
484
  return { refused };
485
+ }
344
486
  const answers = new Map();
345
487
  const state = { parsed: false };
346
488
  const judge = (output) => {
@@ -405,7 +547,7 @@ export function createBatchModelStep(config) {
405
547
  };
406
548
  const accept = (entry, value) => {
407
549
  writeCache(entry.cacheKey, spec.kind, spec.promptVersion, JSON.stringify(value));
408
- clearPending(entry.cacheKey);
550
+ clearPending(entry.id, entry.cacheKey);
409
551
  results[entry.index] = { item: entry.item, itemKey: entry.itemKey, cacheKey: entry.cacheKey, status: "ok", value, usage: spent.get(entry.index) ?? zero() };
410
552
  batchStats.ok += 1;
411
553
  };
@@ -496,7 +638,8 @@ export function createBatchModelStep(config) {
496
638
  return closed;
497
639
  },
498
640
  pending(kind) {
499
- const all = [...pendingMarkers.values()].sort((a, b) => (a.at !== b.at ? (a.at < b.at ? -1 : 1) : a.key < b.key ? -1 : 1));
641
+ syncPending();
642
+ const all = sortedPending();
500
643
  return kind ? all.filter((marker) => marker.kind === kind) : all;
501
644
  },
502
645
  parked(kind) {
@@ -516,11 +659,34 @@ export function createBatchModelStep(config) {
516
659
  wallMs: total.wallMs,
517
660
  cacheHitRate: asked === 0 ? 1 : total.cacheHits / asked,
518
661
  pendingByReason: { ...pendingByReason },
662
+ unsentItems: total.unsentItems,
663
+ unsentInputTokens: total.unsentInputTokens,
519
664
  };
520
665
  },
521
666
  halted() {
522
667
  return haltReason;
523
668
  },
669
+ seenItems() {
670
+ return seen;
671
+ },
672
+ dropPending(ids) {
673
+ syncPending();
674
+ let dropped = 0;
675
+ for (const id of ids) {
676
+ if (!pendingMarkers.delete(id))
677
+ continue;
678
+ changes.set(id, null);
679
+ dropped += 1;
680
+ }
681
+ if (dropped > 0) {
682
+ pendingDirty = true;
683
+ savePending();
684
+ }
685
+ return dropped;
686
+ },
687
+ pendingCleanup() {
688
+ return { ...cleanup };
689
+ },
524
690
  };
525
691
  }
526
692
  //# sourceMappingURL=step.js.map
@@ -7,6 +7,16 @@
7
7
  */
8
8
  import type { AudienceKey, Confidence, EntityRef, GraphEntityType, GraphSchema, IngestRow, IsoDate, SourceRef, Verb } from "../types.js";
9
9
  import type { BatchItemResult, BatchModelStep, BatchRunStats, BatchSpec, PendingMarker } from "./step.js";
10
+ /** Confidence an extraction falls back to when the model gave none it can use. Below the readers' unverified-guess line on purpose. */
11
+ export declare const DEFAULT_EXTRACTED_CONF: Confidence;
12
+ /**
13
+ * A confidence the model stated for one fact: a number from 0 to 1, kept to two
14
+ * decimals. Anything else (missing, text, not finite, outside the range) is not
15
+ * a statement of confidence and gets the default; a 7 is never read as 1.
16
+ */
17
+ export declare function statedConf(value: unknown, fallback?: Confidence): Confidence;
18
+ /** The rubric every extracting prompt gives for its confidence field, so the numbers mean the same thing across tasks. */
19
+ export declare const CONF_RUBRIC: string;
10
20
  /** Verbs the schema allows from a subject type to an object type. Reference verbs are left out unless asked for. */
11
21
  export declare function allowedVerbs(schema: GraphSchema, subject: GraphEntityType, object: GraphEntityType, includeReference?: boolean): Verb[];
12
22
  export interface TaskRun<I, O> {
@@ -90,12 +100,15 @@ export interface ExtractedFact {
90
100
  field: string;
91
101
  value: string;
92
102
  quote: string;
103
+ /** What the model said its confidence is; `DEFAULT_EXTRACTED_CONF` when it gave none. */
104
+ conf: Confidence;
93
105
  }
94
106
  export interface ExtractedEdge {
95
107
  subject: EntityRef;
96
108
  verb: Verb;
97
109
  target: EntityRef;
98
110
  quote: string;
111
+ conf: Confidence;
99
112
  }
100
113
  export interface ExtractedEvent {
101
114
  entity: EntityRef;
@@ -123,7 +136,10 @@ export declare function extractSourceSpec(schema: GraphSchema, day: IsoDate): Ba
123
136
  export declare function extractFromSources(step: BatchModelStep, schema: GraphSchema, items: readonly SourceExtractionItem[], options: {
124
137
  day: IsoDate;
125
138
  }): Promise<TaskRun<SourceExtractionItem, SourceExtraction>>;
126
- /** Forward rows for one extraction. Every row cites the source; `by` is `agent:<model>`. */
139
+ /**
140
+ * Forward rows for one extraction. Every row cites the source; `by` is `agent:<model>`. Each fact and
141
+ * edge keeps the confidence the model gave it; `stamp.conf` replaces them all when a caller sets it.
142
+ */
127
143
  export declare function extractionRows(extraction: SourceExtraction, stamp: {
128
144
  learned: IsoDate;
129
145
  model: string;
@@ -170,14 +186,22 @@ export interface ResumedPending {
170
186
  * handed to a replay task has the wrong shape.
171
187
  */
172
188
  export declare function isReplayMarker(marker: Pick<PendingMarker, "kind" | "promptVersion">): boolean;
173
- /** The pending markers `resumePending` will send. */
174
- export declare function replayPending(step: BatchModelStep): PendingMarker[];
189
+ /** Which of the replay's own tasks a company's `model_tasks` setting leaves on. Absent: both. */
190
+ export interface ResumeTasks {
191
+ typing: boolean;
192
+ extraction: boolean;
193
+ }
194
+ /** The pending markers `resumePending` will send: the replay's own, less those of a task that is switched off. */
195
+ export declare function replayPending(step: BatchModelStep, tasks?: ResumeTasks): PendingMarker[];
175
196
  /**
176
197
  * Sends the items earlier runs left pending, under today's budget. The caller
177
198
  * applies the results as it would for fresh items. Markers that still do not
178
- * fit stay pending.
199
+ * fit stay pending. With `tasks`, the markers of a task that is switched off
200
+ * are not sent and not touched: they stay in the pending file until the task
201
+ * is on again.
179
202
  */
180
203
  export declare function resumePending(step: BatchModelStep, schema: GraphSchema, options: {
181
204
  day: IsoDate;
205
+ tasks?: ResumeTasks;
182
206
  }): Promise<ResumedPending>;
183
207
  //# sourceMappingURL=tasks.d.ts.map
@@ -12,6 +12,21 @@ function conf(value, fallback) {
12
12
  return fallback;
13
13
  return Math.min(1, Math.max(0, Math.round(n * 100) / 100));
14
14
  }
15
+ /** Confidence an extraction falls back to when the model gave none it can use. Below the readers' unverified-guess line on purpose. */
16
+ export const DEFAULT_EXTRACTED_CONF = 0.6;
17
+ /**
18
+ * A confidence the model stated for one fact: a number from 0 to 1, kept to two
19
+ * decimals. Anything else (missing, text, not finite, outside the range) is not
20
+ * a statement of confidence and gets the default; a 7 is never read as 1.
21
+ */
22
+ export function statedConf(value, fallback = DEFAULT_EXTRACTED_CONF) {
23
+ if (typeof value !== "number" || !Number.isFinite(value) || value < 0 || value > 1)
24
+ return fallback;
25
+ return Math.round(value * 100) / 100;
26
+ }
27
+ /** The rubric every extracting prompt gives for its confidence field, so the numbers mean the same thing across tasks. */
28
+ export const CONF_RUBRIC = "0.9 to 1 when the text says it outright in so many words; 0.7 to 0.85 when the text states it but you had to work out who or what is meant; " +
29
+ "0.4 to 0.65 when you inferred it (a signature, a passing mention, who was present, what someone seems to do). An inferred entry is still useful; an overstated one is not.";
15
30
  function typeOf(ref) {
16
31
  const parsed = parseEntityRef(ref);
17
32
  if (!parsed)
@@ -163,11 +178,13 @@ export function extractSourcePrompt(schema) {
163
178
  "Edges: {s: subject id, verb, o: object id}. Allowed verbs with subject types -> object types:",
164
179
  JSON.stringify(vocab.verbs),
165
180
  `Events: {e: entity id, type: one of ${EVENT_TYPES.join(", ")}, text: one line under 160 characters}. At most 6 per item.`,
181
+ `Every fact and every edge also carries \`conf\`, your confidence from 0 to 1: ${CONF_RUBRIC}`,
166
182
  "Leave a list empty when the text states nothing of that kind. Do not restate the entity list.",
167
183
  DATA_RULE,
168
- 'Reply shape: {"results":[{"id":"i1","facts":[{"e":"person/a","field":"role_title","value":"CTO","quote":"..."}],"edges":[{"s":"person/a","verb":"works_on","o":"project/b","quote":"..."}],"events":[{"e":"project/b","type":"decision","text":"...","quote":"..."}]}]}',
184
+ 'Reply shape: {"results":[{"id":"i1","facts":[{"e":"person/a","field":"role_title","value":"CTO","quote":"...","conf":0.95}],"edges":[{"s":"person/a","verb":"works_on","o":"project/b","quote":"...","conf":0.6}],"events":[{"e":"project/b","type":"decision","text":"...","quote":"..."}]}]}',
169
185
  ].join("\n");
170
- return { prompt, promptVersion: `extract-source.v1+${sha256Hex(stableStringify(vocab)).slice(0, 8)}` };
186
+ // v2: every fact and edge carries the model's own confidence (v1 stamped a flat 0.60).
187
+ return { prompt, promptVersion: `extract-source.v2+${sha256Hex(stableStringify(vocab)).slice(0, 8)}` };
171
188
  }
172
189
  function squash(text) {
173
190
  return text.replace(/\s+/g, " ").trim().toLowerCase();
@@ -211,7 +228,7 @@ export function extractSourceSpec(schema, day) {
211
228
  out.dropped += 1;
212
229
  continue;
213
230
  }
214
- out.facts.push({ entity, field, value, quote });
231
+ out.facts.push({ entity, field, value, quote, conf: statedConf(fact.conf) });
215
232
  }
216
233
  for (const entry of raw.edges) {
217
234
  const edge = entry && typeof entry === "object" ? entry : {};
@@ -223,7 +240,7 @@ export function extractSourceSpec(schema, day) {
223
240
  out.dropped += 1;
224
241
  continue;
225
242
  }
226
- out.edges.push({ subject, verb, target, quote });
243
+ out.edges.push({ subject, verb, target, quote, conf: statedConf(edge.conf) });
227
244
  }
228
245
  for (const entry of raw.events.slice(0, 6)) {
229
246
  const event = entry && typeof entry === "object" ? entry : {};
@@ -246,17 +263,20 @@ export async function extractFromSources(step, schema, items, options) {
246
263
  const sendable = items.filter((item) => isSourceRef(item.src) && item.entities.length > 0 && item.text.trim() !== "");
247
264
  return step.runBatch(extractSourceSpec(schema, options.day), sendable);
248
265
  }
249
- /** Forward rows for one extraction. Every row cites the source; `by` is `agent:<model>`. */
266
+ /**
267
+ * Forward rows for one extraction. Every row cites the source; `by` is `agent:<model>`. Each fact and
268
+ * edge keeps the confidence the model gave it; `stamp.conf` replaces them all when a caller sets it.
269
+ */
250
270
  export function extractionRows(extraction, stamp) {
251
271
  const by = `agent:${stamp.model}`;
252
- const confidence = stamp.conf ?? 0.6;
272
+ const confOf = (own) => stamp.conf ?? statedConf(own);
253
273
  const rows = [];
254
274
  for (const fact of extraction.facts) {
255
- const row = { kind: "F", field: fact.field, value: fact.value, valid: { from: extraction.date }, src: extraction.src, learned: stamp.learned, by, conf: confidence };
275
+ const row = { kind: "F", field: fact.field, value: fact.value, valid: { from: extraction.date }, src: extraction.src, learned: stamp.learned, by, conf: confOf(fact.conf) };
256
276
  rows.push({ entity: fact.entity, audience: stamp.audience, row });
257
277
  }
258
278
  for (const edge of extraction.edges) {
259
- const row = { kind: "E", verb: edge.verb, target: edge.target, valid: { from: extraction.date }, src: extraction.src, learned: stamp.learned, by, conf: confidence };
279
+ const row = { kind: "E", verb: edge.verb, target: edge.target, valid: { from: extraction.date }, src: extraction.src, learned: stamp.learned, by, conf: confOf(edge.conf) };
260
280
  rows.push({ entity: edge.subject, audience: stamp.audience, row });
261
281
  }
262
282
  for (const event of extraction.events) {
@@ -329,20 +349,33 @@ export function isReplayMarker(marker) {
329
349
  return version.startsWith("extract-source.");
330
350
  return false;
331
351
  }
332
- /** The pending markers `resumePending` will send. */
333
- export function replayPending(step) {
334
- return step.pending().filter(isReplayMarker);
352
+ /** The pending markers `resumePending` will send: the replay's own, less those of a task that is switched off. */
353
+ export function replayPending(step, tasks) {
354
+ return step.pending().filter((marker) => {
355
+ if (!isReplayMarker(marker))
356
+ return false;
357
+ if (marker.kind === "type-relationship")
358
+ return tasks?.typing !== false;
359
+ if (marker.kind === "extract-source")
360
+ return tasks?.extraction !== false;
361
+ return true;
362
+ });
335
363
  }
336
364
  /**
337
365
  * Sends the items earlier runs left pending, under today's budget. The caller
338
366
  * applies the results as it would for fresh items. Markers that still do not
339
- * fit stay pending.
367
+ * fit stay pending. With `tasks`, the markers of a task that is switched off
368
+ * are not sent and not touched: they stay in the pending file until the task
369
+ * is on again.
340
370
  */
341
371
  export async function resumePending(step, schema, options) {
342
372
  const own = (kind) => step.pending(kind).filter(isReplayMarker);
343
- const relationships = await typeRelationships(step, schema, payloads(own("type-relationship")), options);
344
- const fuzzy = await judgeFuzzyPairs(step, payloads(own("resolve-fuzzy")), options);
345
- const extractions = await extractFromSources(step, schema, payloads(own("extract-source")).filter((item) => Array.isArray(item.entities) && typeof item.text === "string"), options);
373
+ const day = { day: options.day };
374
+ const relationships = await typeRelationships(step, schema, options.tasks?.typing === false ? [] : payloads(own("type-relationship")), day);
375
+ const fuzzy = await judgeFuzzyPairs(step, payloads(own("resolve-fuzzy")), day);
376
+ const extractions = await extractFromSources(step, schema, options.tasks?.extraction === false
377
+ ? []
378
+ : payloads(own("extract-source")).filter((item) => Array.isArray(item.entities) && typeof item.text === "string"), day);
346
379
  const summaryEntities = [...new Set(step.pending("summarize-page").map((marker) => marker.itemKey).filter(isEntityRef))].sort();
347
380
  return { relationships, fuzzy, extractions, summaryEntities };
348
381
  }
@@ -77,7 +77,7 @@ export interface PageModel {
77
77
  };
78
78
  /** Open legacy reference edges (`related_to`, `mentions`) left off the page. */
79
79
  hiddenEdges: number;
80
- /** Open role and affiliation facts a model wrote under the confidence line, left off the page. */
80
+ /** Open role and affiliation facts, and hierarchy relationships, a model wrote under the confidence line, left off the page. */
81
81
  leftOutGuesses: number;
82
82
  /** Closed F and E rows, hidden unless `showClosed`. */
83
83
  closedHidden: number;
@@ -146,10 +146,11 @@ export function buildPageModel(schema, entity, storedRows, nameOf, limits = DEFA
146
146
  unique.set(stored.id, stored);
147
147
  }
148
148
  // An open role or affiliation a model wrote at low confidence is left off the page before any winner or
149
- // conflict is worked out, and counted in the frontmatter. Row counts still count every row. Relationships
150
- // stay: each relationship line names who wrote it, and a customer's contact list is built from them.
149
+ // conflict is worked out, and counted in the frontmatter. Row counts still count every row. So is a
150
+ // model's low-confidence manager, report, team or lead. Employer relationships stay: a customer's
151
+ // contact list is built from model-written `employs` rows, and each line names who wrote it.
151
152
  const everyRow = [...unique.values()];
152
- const { rows, leftOut: leftOutGuesses } = dropUnverifiedGuesses(everyRow);
153
+ const { rows, leftOut: leftOutGuesses } = dropUnverifiedGuesses(everyRow, { edges: "hierarchy" });
153
154
  const audiences = [...new Set(storedRows.map((stored) => stored.audience))].sort();
154
155
  const type = entity.type;
155
156
  const name = entity.canonical_name;
@@ -1,9 +1,15 @@
1
- import { type AudienceKey, type BriefOptions, type CommandOutput, type GraphContext, type GraphStore } from "../types.js";
1
+ import { type AudienceKey, type BriefOptions, type BriefStyle, type CommandOutput, type GraphContext, type GraphStore } from "../types.js";
2
2
  export declare const BRIEF_MAX_TOKENS = 1500;
3
3
  export declare const BRIEF_MAX_PROJECTS = 15;
4
4
  export declare const BRIEF_MAX_CUSTOMERS = 8;
5
5
  export declare const BRIEF_MAX_CHANGES = 12;
6
6
  export declare const BRIEF_WINDOW_DAYS = 7;
7
+ export declare const BRIEF_DEFAULT_STYLE: BriefStyle;
8
+ /** Most names the map lists per kind before the token cap trims further. */
9
+ export declare const MAP_MAX_PROJECTS = 30;
10
+ export declare const MAP_MAX_CUSTOMERS = 15;
11
+ export declare const MAP_MAX_TEAMMATES = 30;
12
+ export declare const MAP_NAME_MAX_CHARS = 60;
7
13
  /**
8
14
  * Upper estimate of the token count. English prose runs near four characters
9
15
  * a token; ids, dates and slugs run shorter, so three is used.
@@ -18,9 +24,13 @@ export interface BriefExtras {
18
24
  store?: GraphStore;
19
25
  /** Token cap. Default `BRIEF_MAX_TOKENS`; a caller may only lower it. */
20
26
  maxTokens?: number;
27
+ /** `map` or `full`. Default: `brief_style` in the reader setting, else `map`. */
28
+ style?: BriefStyle;
21
29
  }
22
- /** Builds the brief text. Pure apart from reads through the store. */
30
+ /** The style a brief is built in: the caller's, else the reader setting's `brief_style`, else `map`. */
31
+ export declare function resolveBriefStyle(hqRoot: string, asked?: BriefStyle): BriefStyle;
32
+ /** Builds the brief text in the asked style. Pure apart from reads through the store. No model call. */
23
33
  export declare function buildBrief(context: GraphContext, extras?: BriefExtras): string;
24
- /** `hq ontology brief`: writes brief.md (1,500 tokens max). */
34
+ /** `hq ontology brief [--style map|full]`: writes brief.md (1,500 tokens max). */
25
35
  export declare function briefCommand(context: GraphContext, options: BriefOptions & BriefExtras): Promise<CommandOutput>;
26
36
  //# sourceMappingURL=brief.d.ts.map