@indigoai-us/hq-cli 5.345.248 → 5.345.251
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 +143 -0
- package/contracts/host-canary-release.json +3 -3
- package/dist/command-catalog.generated.d.ts +288 -9
- package/dist/command-catalog.generated.js +355 -9
- package/dist/commands/bot.js +5 -1
- package/dist/commands/core-job-run-native.js +4 -0
- package/dist/commands/core-knowledge-prefs.d.ts +1 -1
- package/dist/commands/core-knowledge-prefs.js +1 -16
- package/dist/commands/core.js +0 -2
- package/dist/commands/daemon.js +21 -0
- package/dist/commands/lanes.d.ts +2 -0
- package/dist/commands/lanes.js +9 -4
- package/dist/commands/ontology-graph.d.ts +11 -3
- package/dist/commands/ontology-graph.js +138 -14
- package/dist/commands/sources.js +26 -8
- package/dist/commands/sync-core.js +6 -0
- package/dist/fast-scaffold.js +1 -3
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +281 -256
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.js +47 -0
- package/dist/lib/bot/fleet-cron.d.ts +2 -0
- package/dist/lib/bot/fleet-cron.js +5 -0
- package/dist/lib/daemon/installed-cli-restart.d.ts +57 -0
- package/dist/lib/daemon/installed-cli-restart.js +114 -0
- package/dist/lib/daemon/legacy-journal-gate.d.ts +32 -0
- package/dist/lib/daemon/legacy-journal-gate.js +102 -0
- package/dist/lib/daemon/machine-checks.d.ts +7 -0
- package/dist/lib/daemon/machine-checks.js +10 -0
- package/dist/lib/daemon/run.d.ts +3 -1
- package/dist/lib/daemon/run.js +48 -5
- package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
- package/dist/lib/flag-registry-worker-source.generated.js +1 -1
- package/dist/lib/hook-engine/coverage.d.ts +99 -19
- package/dist/lib/hook-engine/coverage.js +269 -35
- package/dist/lib/hook-engine/native-stop-compatibility.json +9 -4
- package/dist/lib/hook-engine/registration-identity.d.ts +5 -0
- package/dist/lib/hook-engine/registration-identity.js +1 -1
- package/dist/lib/hook-engine/resolve.d.ts +23 -0
- package/dist/lib/hook-engine/resolve.js +48 -1
- package/dist/lib/hook-engine/stable-heal.d.ts +87 -0
- package/dist/lib/hook-engine/stable-heal.js +214 -0
- package/dist/lib/hot-channels/graph-context.d.ts +26 -1
- package/dist/lib/hot-channels/graph-context.js +80 -10
- package/dist/lib/hot-channels/run.d.ts +1 -0
- package/dist/lib/hot-channels/signals-pass.js +9 -4
- 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 +11 -1
- package/dist/lib/ontology-graph/model/index.js +42 -18
- package/dist/lib/ontology-graph/model/pass-tasks.d.ts +9 -1
- package/dist/lib/ontology-graph/model/pass-tasks.js +7 -4
- package/dist/lib/ontology-graph/model/pass.d.ts +5 -0
- package/dist/lib/ontology-graph/model/pass.js +8 -8
- package/dist/lib/ontology-graph/model/pending-items.d.ts +31 -0
- package/dist/lib/ontology-graph/model/pending-items.js +113 -0
- package/dist/lib/ontology-graph/model/step.d.ts +48 -1
- package/dist/lib/ontology-graph/model/step.js +205 -36
- package/dist/lib/ontology-graph/model/tasks.d.ts +17 -1
- package/dist/lib/ontology-graph/model/tasks.js +28 -8
- package/dist/lib/ontology-graph/org/derive.d.ts +2 -0
- package/dist/lib/ontology-graph/org/derive.js +9 -2
- package/dist/lib/ontology-graph/org/index.d.ts +35 -6
- package/dist/lib/ontology-graph/org/index.js +136 -19
- package/dist/lib/ontology-graph/org/text.d.ts +2 -0
- package/dist/lib/ontology-graph/org/text.js +6 -0
- package/dist/lib/ontology-graph/org/types.d.ts +5 -0
- package/dist/lib/ontology-graph/pages/render.d.ts +2 -0
- package/dist/lib/ontology-graph/pages/render.js +11 -4
- package/dist/lib/ontology-graph/read/brief.d.ts +13 -3
- package/dist/lib/ontology-graph/read/brief.js +312 -62
- package/dist/lib/ontology-graph/read/index.d.ts +1 -1
- package/dist/lib/ontology-graph/read/index.js +14 -3
- package/dist/lib/ontology-graph/read/names.d.ts +6 -1
- package/dist/lib/ontology-graph/read/names.js +8 -3
- 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/engine.d.ts +47 -1
- package/dist/lib/ontology-graph/replay/engine.js +68 -2
- package/dist/lib/ontology-graph/replay/index.d.ts +2 -1
- package/dist/lib/ontology-graph/replay/index.js +114 -8
- package/dist/lib/ontology-graph/schema/authority.d.ts +43 -0
- package/dist/lib/ontology-graph/schema/authority.js +39 -0
- package/dist/lib/ontology-graph/schema/index.d.ts +1 -1
- package/dist/lib/ontology-graph/schema/index.js +1 -1
- package/dist/lib/ontology-graph/setup/index.d.ts +88 -0
- package/dist/lib/ontology-graph/setup/index.js +489 -0
- package/dist/lib/ontology-graph/types.d.ts +28 -0
- package/dist/lib/ontology-graph/types.js +5 -0
- 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 -1
- package/dist/lib/sync-core/engine-holds.js +12 -2
- package/dist/lib/sync-core/hand-back.d.ts +2 -1
- package/dist/lib/sync-core/hand-back.js +16 -2
- package/dist/lib/sync-core/legacy-journal-export-child.d.ts +2 -0
- package/dist/lib/sync-core/legacy-journal-export-child.js +24 -0
- package/dist/lib/sync-core/legacy-journal-export.d.ts +39 -0
- package/dist/lib/sync-core/legacy-journal-export.js +241 -0
- package/dist/lib/sync-core/legacy-journal-reader.d.ts +15 -0
- package/dist/lib/sync-core/legacy-journal-reader.js +56 -0
- package/dist/lib/sync-core/reconcile.d.ts +3 -0
- package/dist/lib/sync-core/reconcile.js +43 -3
- package/dist/utils/cli-telemetry.d.ts +1 -0
- package/dist/utils/cli-telemetry.js +6 -3
- package/dist/utils/hook-engine-rollup.d.ts +96 -0
- package/dist/utils/hook-engine-rollup.js +725 -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 +4 -0
- package/assets/scaffold/core/scripts/knowledge-prefs.sh +0 -55
|
@@ -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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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(
|
|
69
|
-
for (const marker of parsed.markers ?? [])
|
|
70
|
-
if (marker
|
|
71
|
-
|
|
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
|
-
|
|
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
|
-
|
|
82
|
-
writeFileAtomicSync(pendingFile, `${JSON.stringify({ version:
|
|
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,8 @@ 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 };
|
|
213
|
+
const pendingByReason = {};
|
|
94
214
|
let haltReason = null;
|
|
95
215
|
let budgetStopped = false;
|
|
96
216
|
let errorsInARow = 0;
|
|
@@ -110,23 +230,39 @@ export function createBatchModelStep(config) {
|
|
|
110
230
|
const file = { v: 1, key, kind, promptVersion, model: config.model, at: now().toISOString(), output };
|
|
111
231
|
writeFileAtomicSync(`${cacheDir}/${key}.json`, `${JSON.stringify(file)}\n`);
|
|
112
232
|
};
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
+
}
|
|
116
241
|
};
|
|
117
242
|
const markPending = (marker) => {
|
|
118
|
-
const existing = pendingMarkers.get(marker.
|
|
119
|
-
|
|
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);
|
|
120
249
|
pendingDirty = true;
|
|
121
250
|
window.pending += 1;
|
|
122
251
|
total.pending += 1;
|
|
252
|
+
pendingByReason[marker.reason] = (pendingByReason[marker.reason] ?? 0) + 1;
|
|
123
253
|
};
|
|
124
|
-
const park = (record) => {
|
|
254
|
+
const park = (record, id) => {
|
|
125
255
|
const full = { ...record, at: now().toISOString() };
|
|
126
256
|
parkedRecords.set(record.key, full);
|
|
127
|
-
|
|
257
|
+
if (!config.readOnly)
|
|
258
|
+
appendJsonLineSync(parkedFile, full);
|
|
128
259
|
total.parked += 1;
|
|
129
|
-
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;
|
|
130
266
|
};
|
|
131
267
|
// Once a cap refuses a call, calls stay stopped for that day (or the run), so
|
|
132
268
|
// a smaller batch later in the same day does not slip past the cap.
|
|
@@ -235,19 +371,22 @@ export function createBatchModelStep(config) {
|
|
|
235
371
|
});
|
|
236
372
|
const run = async (request) => {
|
|
237
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);
|
|
238
376
|
const cached = readCache(cacheKey);
|
|
239
377
|
if (cached !== null) {
|
|
240
378
|
window.cacheHits += 1;
|
|
241
379
|
total.cacheHits += 1;
|
|
242
|
-
clearPending(cacheKey);
|
|
380
|
+
clearPending(id, cacheKey);
|
|
243
381
|
savePending();
|
|
244
382
|
return { status: "cached", cacheKey, output: cached, usage: zero() };
|
|
245
383
|
}
|
|
246
384
|
const estimateIn = estimateTokens(`${request.prompt}\n${request.input}`) + CLI_OVERHEAD_TOKENS;
|
|
247
385
|
const refused = refusal(request.day, estimateIn);
|
|
248
386
|
if (refused) {
|
|
387
|
+
noteUnsent(1, estimateIn);
|
|
249
388
|
markPending({
|
|
250
|
-
key: cacheKey, kind: request.kind, itemKey:
|
|
389
|
+
id, key: cacheKey, kind: request.kind, itemKey: id.slice(-12), day: request.day, reason: refused,
|
|
251
390
|
promptVersion: request.promptVersion, payload: { input: request.input },
|
|
252
391
|
});
|
|
253
392
|
savePending();
|
|
@@ -257,14 +396,14 @@ export function createBatchModelStep(config) {
|
|
|
257
396
|
const outcome = await call(request, request.prompt, request.input, 1, 1, () => "ok", request.maxOutputTokens);
|
|
258
397
|
if (outcome.failure || outcome.output === undefined) {
|
|
259
398
|
markPending({
|
|
260
|
-
key: cacheKey, kind: request.kind, itemKey:
|
|
399
|
+
id, key: cacheKey, kind: request.kind, itemKey: id.slice(-12), day: request.day, reason: outcome.failure ?? "provider-error",
|
|
261
400
|
promptVersion: request.promptVersion, payload: { input: request.input },
|
|
262
401
|
});
|
|
263
402
|
savePending();
|
|
264
403
|
return { status: "error", cacheKey, usage: { inputTokens: outcome.usage.inputTokens, outputTokens: outcome.usage.outputTokens }, error: outcome.failure ?? "provider-error" };
|
|
265
404
|
}
|
|
266
405
|
writeCache(cacheKey, request.kind, request.promptVersion, outcome.output);
|
|
267
|
-
clearPending(cacheKey);
|
|
406
|
+
clearPending(id, cacheKey);
|
|
268
407
|
savePending();
|
|
269
408
|
return { status: "ok", cacheKey, output: outcome.output, usage: { inputTokens: outcome.usage.inputTokens, outputTokens: outcome.usage.outputTokens } };
|
|
270
409
|
};
|
|
@@ -273,18 +412,20 @@ export function createBatchModelStep(config) {
|
|
|
273
412
|
const results = new Array(items.length);
|
|
274
413
|
const batchStats = { items: items.length, cacheHits: 0, calls: 0, ok: 0, pending: 0, parked: 0, usage: zero(), estimated: false, seconds: 0 };
|
|
275
414
|
const toSend = [];
|
|
276
|
-
const
|
|
415
|
+
const firstIndex = new Map();
|
|
277
416
|
const duplicates = [];
|
|
278
417
|
items.forEach((item, index) => {
|
|
279
418
|
const input = stableStringify(spec.renderItem(item));
|
|
280
419
|
const cacheKey = cacheKeyFor({ promptVersion: spec.promptVersion, kind: spec.kind, input, model: config.model });
|
|
281
420
|
const itemKey = spec.itemKey(item);
|
|
282
|
-
const
|
|
421
|
+
const id = pendingItemId(spec.promptVersion, input);
|
|
422
|
+
seen.add(id);
|
|
423
|
+
const first = firstIndex.get(cacheKey);
|
|
283
424
|
if (first !== undefined) {
|
|
284
425
|
duplicates.push({ index, of: first });
|
|
285
426
|
return;
|
|
286
427
|
}
|
|
287
|
-
|
|
428
|
+
firstIndex.set(cacheKey, index);
|
|
288
429
|
const cached = readCache(cacheKey);
|
|
289
430
|
if (cached !== null) {
|
|
290
431
|
try {
|
|
@@ -292,7 +433,7 @@ export function createBatchModelStep(config) {
|
|
|
292
433
|
window.cacheHits += 1;
|
|
293
434
|
total.cacheHits += 1;
|
|
294
435
|
batchStats.cacheHits += 1;
|
|
295
|
-
clearPending(cacheKey);
|
|
436
|
+
clearPending(id, cacheKey);
|
|
296
437
|
return;
|
|
297
438
|
}
|
|
298
439
|
catch {
|
|
@@ -305,15 +446,15 @@ export function createBatchModelStep(config) {
|
|
|
305
446
|
batchStats.parked += 1;
|
|
306
447
|
return;
|
|
307
448
|
}
|
|
308
|
-
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 });
|
|
309
450
|
});
|
|
310
451
|
const setPending = (entry, reason, usage) => {
|
|
311
|
-
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 });
|
|
312
453
|
results[entry.index] = { item: entry.item, itemKey: entry.itemKey, cacheKey: entry.cacheKey, status: "pending", reason, usage };
|
|
313
454
|
batchStats.pending += 1;
|
|
314
455
|
};
|
|
315
456
|
const setParked = (entry, reason, attempts, usage) => {
|
|
316
|
-
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);
|
|
317
458
|
results[entry.index] = { item: entry.item, itemKey: entry.itemKey, cacheKey: entry.cacheKey, status: "parked", reason, usage };
|
|
318
459
|
batchStats.parked += 1;
|
|
319
460
|
};
|
|
@@ -336,9 +477,12 @@ export function createBatchModelStep(config) {
|
|
|
336
477
|
/** Sends one turn. Returns each entry's parsed answer (or a reason), and what the turn cost per entry. */
|
|
337
478
|
const sendTurn = async (entries, attempt, prompt) => {
|
|
338
479
|
const input = `{"items":[${entries.map((entry, i) => `{"id":"i${i + 1}","data":${entry.input}}`).join(",")}]}`;
|
|
339
|
-
const
|
|
340
|
-
|
|
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);
|
|
341
484
|
return { refused };
|
|
485
|
+
}
|
|
342
486
|
const answers = new Map();
|
|
343
487
|
const state = { parsed: false };
|
|
344
488
|
const judge = (output) => {
|
|
@@ -403,7 +547,7 @@ export function createBatchModelStep(config) {
|
|
|
403
547
|
};
|
|
404
548
|
const accept = (entry, value) => {
|
|
405
549
|
writeCache(entry.cacheKey, spec.kind, spec.promptVersion, JSON.stringify(value));
|
|
406
|
-
clearPending(entry.cacheKey);
|
|
550
|
+
clearPending(entry.id, entry.cacheKey);
|
|
407
551
|
results[entry.index] = { item: entry.item, itemKey: entry.itemKey, cacheKey: entry.cacheKey, status: "ok", value, usage: spent.get(entry.index) ?? zero() };
|
|
408
552
|
batchStats.ok += 1;
|
|
409
553
|
};
|
|
@@ -494,7 +638,8 @@ export function createBatchModelStep(config) {
|
|
|
494
638
|
return closed;
|
|
495
639
|
},
|
|
496
640
|
pending(kind) {
|
|
497
|
-
|
|
641
|
+
syncPending();
|
|
642
|
+
const all = sortedPending();
|
|
498
643
|
return kind ? all.filter((marker) => marker.kind === kind) : all;
|
|
499
644
|
},
|
|
500
645
|
parked(kind) {
|
|
@@ -513,11 +658,35 @@ export function createBatchModelStep(config) {
|
|
|
513
658
|
estimatedCalls: total.estimatedCalls,
|
|
514
659
|
wallMs: total.wallMs,
|
|
515
660
|
cacheHitRate: asked === 0 ? 1 : total.cacheHits / asked,
|
|
661
|
+
pendingByReason: { ...pendingByReason },
|
|
662
|
+
unsentItems: total.unsentItems,
|
|
663
|
+
unsentInputTokens: total.unsentInputTokens,
|
|
516
664
|
};
|
|
517
665
|
},
|
|
518
666
|
halted() {
|
|
519
667
|
return haltReason;
|
|
520
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
|
+
},
|
|
521
690
|
};
|
|
522
691
|
}
|
|
523
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
|
-
/**
|
|
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;
|
|
@@ -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
|
-
|
|
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
|
-
/**
|
|
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
|
|
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:
|
|
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:
|
|
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) {
|
|
@@ -44,6 +44,8 @@ export interface Derived {
|
|
|
44
44
|
/** Subjects named by so many decisions that sharing one says nothing. */
|
|
45
45
|
genericSubjects: Set<EntityRef>;
|
|
46
46
|
}
|
|
47
|
+
/** Engineering's share of a commit to a repository named for another kind of work. */
|
|
48
|
+
export declare const COMMIT_ENGINEERING_SHARE_NAMED_REPO = 0.25;
|
|
47
49
|
/** How much of a decision's wording an action item must share before it counts as carrying that decision out. */
|
|
48
50
|
export declare const CARRIES_OUT_SIMILARITY = 0.15;
|
|
49
51
|
/** The weight of a class as evidence about `person`. */
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { DECISION_DIRECTS, NameIndex, addDays, areasOf, clip, continuesWithSecondOwner, directHits, excerptAt, similarity, looksAutomated, namesSubject, ownsAction, saysLed, saysPresented, } from "./text.js";
|
|
2
2
|
import { ACTIVITY_KINDS, AREAS, ORG_WINDOWS, SKEW_WEIGHTS, WINDOW_DAYS, } from "./types.js";
|
|
3
|
+
/** Engineering's share of a commit to a repository named for another kind of work. */
|
|
4
|
+
export const COMMIT_ENGINEERING_SHARE_NAMED_REPO = 0.25;
|
|
3
5
|
const DIRECT_TYPES = new Set(["action_item", "decision", "participant_contribution", "summary", "commitment", "key_point", "question"]);
|
|
4
6
|
/** How much one act says about the person's area of work. */
|
|
5
7
|
const AREA_WEIGHT = { decision: 1, action: 1, commitment: 1, contribution: 0.5, thread: 0.5, question: 0.3, attended: 0.3, external: 0.6, session: 0.5 };
|
|
@@ -52,9 +54,14 @@ export function deriveActs(graph) {
|
|
|
52
54
|
delete about.engineering;
|
|
53
55
|
const others = Object.entries(about);
|
|
54
56
|
const total = others.reduce((sum, [, share]) => sum + share, 0);
|
|
55
|
-
|
|
57
|
+
// A repository whose own name says what it is for (a marketing site, a design system) holds
|
|
58
|
+
// that kind of work first: the commit is the means, and engineering keeps a quarter of it.
|
|
59
|
+
const repoAbout = areasOf(commit.repo.replace(/[-_]/g, " "));
|
|
60
|
+
delete repoAbout.engineering;
|
|
61
|
+
const base = others.length === 0 ? 1 : Object.keys(repoAbout).length > 0 ? COMMIT_ENGINEERING_SHARE_NAMED_REPO : 0.5;
|
|
62
|
+
const areas = { engineering: base };
|
|
56
63
|
for (const [area, share] of others)
|
|
57
|
-
areas[area] = (
|
|
64
|
+
areas[area] = ((1 - base) * share) / total;
|
|
58
65
|
act({
|
|
59
66
|
person: commit.person, kind: "commits", date: commit.date, text: commit.text, src: commit.src, cls: "code", count: commit.count,
|
|
60
67
|
subjects: commit.project ? [commit.project] : [], repo: commit.repo, areas, areaWeight: Math.min(5, Math.log2(1 + commit.count)) * (automated ? 0.1 : 1),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AudienceKey, CommandOutput, GraphContext, GraphStore } from "../types.js";
|
|
2
|
-
import { type DerivedRow, type ObservedOrg, type ObservedPerson, type OrgOptions, type OrgPersonOptions, type OrgView } from "./types.js";
|
|
2
|
+
import { type DerivedRow, type ObservedOrg, type ObservedPerson, type OrgOptions, type OrgPersonOptions, type OrgView, type OrgWindow } from "./types.js";
|
|
3
3
|
import type { RosterFile } from "../resolve/roster.js";
|
|
4
4
|
export * from "./types.js";
|
|
5
5
|
export { loadOrgGraph, audiencesOf, classifySource, planFolds } from "./load.js";
|
|
@@ -25,8 +25,24 @@ export declare const KNOWN_LIMITS: readonly string[];
|
|
|
25
25
|
export declare function hedgedRole(person: ObservedPerson): string;
|
|
26
26
|
/** Computes the observed org for one view. Writes nothing. */
|
|
27
27
|
export declare function buildObservedOrg(contextIn: GraphContext, options?: OrgOptions, internals?: BuildInternals): Promise<ObservedOrg>;
|
|
28
|
-
/**
|
|
29
|
-
export declare
|
|
28
|
+
/** Row kinds that state a role, a line of direction or a stated-versus-observed finding. Kept out unless roles are asked for. */
|
|
29
|
+
export declare const ROLE_ROW_KINDS: ReadonlySet<DerivedRow["kind"]>;
|
|
30
|
+
/** The part of an observed org that is about what people do: no role lines, no direction edges, no stated claims. */
|
|
31
|
+
export declare function activityOnly(org: ObservedOrg): Omit<ObservedOrg, "people" | "owners" | "directs" | "disagreements" | "stated"> & {
|
|
32
|
+
people: (Omit<ObservedPerson, "role"> & {
|
|
33
|
+
mainAreas: ObservedPerson["role"]["mainAreas"];
|
|
34
|
+
change: ObservedPerson["role"]["change"];
|
|
35
|
+
})[];
|
|
36
|
+
owners: Omit<ObservedOrg["owners"][number], "listed" | "agrees">[];
|
|
37
|
+
};
|
|
38
|
+
/** Kinds of act that say who directs or approves whose work. Shown and stored only when roles are asked for. */
|
|
39
|
+
export declare const DIRECTION_KINDS: ReadonlySet<string>;
|
|
40
|
+
/** A person with every count and example of a direction or approval kind taken out. */
|
|
41
|
+
export declare function withoutDirection(person: ObservedPerson): ObservedPerson;
|
|
42
|
+
/** Flattens an observed org into derived rows. Pure. Role, direction and disagreement rows only with `roles`. */
|
|
43
|
+
export declare function derivedRows(org: ObservedOrg, options?: {
|
|
44
|
+
roles?: boolean;
|
|
45
|
+
}): DerivedRow[];
|
|
30
46
|
export declare function derivedDir(graphRoot: string, audience: AudienceKey): string;
|
|
31
47
|
export interface WriteResult {
|
|
32
48
|
dir: string;
|
|
@@ -38,7 +54,9 @@ export interface WriteResult {
|
|
|
38
54
|
* Like every writer it first claims the folder for the company, and refuses a
|
|
39
55
|
* folder that belongs to another company or an observed org built for another one.
|
|
40
56
|
*/
|
|
41
|
-
export declare function writeObservedOrg(context: Pick<GraphContext, "graphRoot" | "company" | "companyRoot">, org: ObservedOrg
|
|
57
|
+
export declare function writeObservedOrg(context: Pick<GraphContext, "graphRoot" | "company" | "companyRoot">, org: ObservedOrg, options?: {
|
|
58
|
+
roles?: boolean;
|
|
59
|
+
}): WriteResult;
|
|
42
60
|
/** The derived rows a reader may see: the company folder, and the member's folder only when the reader is that member. */
|
|
43
61
|
export declare function readDerivedRows(context: Pick<GraphContext, "graphRoot" | "company" | "companyRoot">, audiences: readonly AudienceKey[]): DerivedRow[];
|
|
44
62
|
/**
|
|
@@ -61,9 +79,20 @@ export declare function directsOf(org: ObservedOrg, ref: string): {
|
|
|
61
79
|
export declare function collaboratorsOf(org: ObservedOrg, ref: string, limit?: number): string[];
|
|
62
80
|
export declare function renderHeader(org: ObservedOrg): string[];
|
|
63
81
|
export declare function renderObservedTable(org: ObservedOrg): string[];
|
|
64
|
-
|
|
82
|
+
/** The kinds of work seen for a person in one window, each with its count. */
|
|
83
|
+
export declare function workLine(person: ObservedPerson, window?: OrgWindow): string;
|
|
84
|
+
export declare function shipsLine(person: ObservedPerson, window?: OrgWindow): string;
|
|
85
|
+
export declare function ownsLine(org: ObservedOrg, ref: string): string;
|
|
86
|
+
/** The default table: what each person does. No role line and no direction between people. */
|
|
87
|
+
export declare function renderActivityTable(org: ObservedOrg): string[];
|
|
88
|
+
export declare const ROLES_LEFT_OUT = "Role lines, direction between people and the stated-versus-observed comparison are left out. Add --roles to see the first two, or --compare for the comparison.";
|
|
89
|
+
export declare function renderObserved(org: ObservedOrg, options?: {
|
|
90
|
+
roles?: boolean;
|
|
91
|
+
}): string;
|
|
65
92
|
export declare function renderCompare(org: ObservedOrg, limit?: number): string;
|
|
66
|
-
export declare function renderPerson(org: ObservedOrg, person: ObservedPerson
|
|
93
|
+
export declare function renderPerson(org: ObservedOrg, person: ObservedPerson, options?: {
|
|
94
|
+
roles?: boolean;
|
|
95
|
+
}): string;
|
|
67
96
|
/** `hq ontology org observed`: compute and print the observed org. Stores the derived rows only when `write` is set. */
|
|
68
97
|
export declare function orgObservedCommand(context: GraphContext, options?: OrgOptions): Promise<CommandOutput>;
|
|
69
98
|
/** `hq ontology org compare`: stated versus observed. Writes nothing unless `write` is set. */
|