@indigoai-us/hq-cli 5.345.247 → 5.345.250
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 +95 -0
- package/assets/lanes-hooks/hq-lanes-drain.sh +1 -1
- package/contracts/host-canary-release.json +14 -0
- package/dist/command-catalog.generated.d.ts +1198 -0
- package/dist/command-catalog.generated.js +1476 -0
- package/dist/command-registration-plan.d.ts +6 -0
- package/dist/command-registration-plan.js +1 -0
- 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-hold.js +7 -7
- package/dist/commands/lanes-resume.js +2 -2
- package/dist/commands/lanes-review.js +1 -1
- package/dist/commands/lanes-session-start.d.ts +1 -1
- package/dist/commands/lanes-session-start.js +3 -3
- package/dist/commands/lanes-shared.d.ts +1 -1
- package/dist/commands/lanes.d.ts +2 -2
- package/dist/commands/lanes.js +50 -50
- package/dist/commands/mesh.d.ts +25 -0
- package/dist/commands/mesh.js +48 -8
- package/dist/commands/ontology-graph.d.ts +63 -0
- package/dist/commands/ontology-graph.js +470 -0
- 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 +48 -1
- package/dist/lanes-monitor-check-argv.d.ts +1 -1
- package/dist/lanes-monitor-check-argv.js +1 -1
- package/dist/lanes-monitor-check-fast.d.ts +1 -1
- package/dist/lanes-monitor-check-fast.js +1 -1
- package/dist/lanes-session-start-argv.d.ts +1 -1
- package/dist/lanes-session-start-argv.js +1 -1
- package/dist/lib/capacity/sign-in.d.ts +1 -1
- package/dist/lib/capacity/sign-in.js +1 -1
- package/dist/lib/daemon/hook-requests-conduct-link.js +2 -2
- 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/lanes-monitor-state.d.ts +2 -2
- package/dist/lib/daemon/lanes-monitor-state.js +2 -2
- 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/merge-sections.d.ts +3 -3
- package/dist/lib/daemon/merge-sections.js +7 -7
- package/dist/lib/daemon/remote-control-pools.js +1 -1
- package/dist/lib/daemon/run.d.ts +3 -1
- package/dist/lib/daemon/run.js +49 -6
- package/dist/lib/daemon/state-file.d.ts +1 -1
- package/dist/lib/daemon/state-file.js +1 -1
- 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-snapshot-file.d.ts +2 -0
- package/dist/lib/flag-snapshot-file.js +118 -48
- package/dist/lib/hook-engine/canary-gate.d.ts +57 -3
- package/dist/lib/hook-engine/canary-gate.js +138 -6
- package/dist/lib/hook-engine/coverage.d.ts +82 -13
- package/dist/lib/hook-engine/coverage.js +214 -18
- 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 +105 -0
- package/dist/lib/hot-channels/graph-context.js +380 -0
- package/dist/lib/hot-channels/signals-pass.js +27 -1
- package/dist/lib/lanes/claude-credential.d.ts +1 -1
- package/dist/lib/lanes/claude-credential.js +1 -1
- package/dist/lib/lanes/delivery-core.d.ts +1 -1
- package/dist/lib/lanes/delivery-core.js +1 -1
- package/dist/lib/lanes/delivery.d.ts +10 -10
- package/dist/lib/lanes/delivery.js +8 -8
- package/dist/lib/lanes/dropbox.d.ts +1 -1
- package/dist/lib/lanes/dropbox.js +1 -1
- package/dist/lib/lanes/hooks-install.js +2 -2
- package/dist/lib/lanes/index.d.ts +1 -1
- package/dist/lib/lanes/index.js +1 -1
- package/dist/lib/lanes/monitor.js +1 -1
- package/dist/lib/lanes/quota-notice.js +1 -1
- package/dist/lib/lanes/quota.d.ts +1 -1
- package/dist/lib/lanes/quota.js +1 -1
- package/dist/lib/lanes/repo-merge-hold.d.ts +2 -2
- package/dist/lib/lanes/repo-merge-hold.js +2 -2
- package/dist/lib/lanes/spawn.d.ts +4 -4
- package/dist/lib/lanes/spawn.js +5 -5
- package/dist/lib/mesh/live/company-flag-refresh.d.ts +61 -0
- package/dist/lib/mesh/live/company-flag-refresh.js +159 -0
- package/dist/lib/mesh/live/company-reporting-gaps.d.ts +61 -0
- package/dist/lib/mesh/live/company-reporting-gaps.js +238 -0
- package/dist/lib/mesh/live/daemon/duplicate-unit.d.ts +156 -0
- package/dist/lib/mesh/live/daemon/duplicate-unit.js +616 -0
- package/dist/lib/mesh/live/daemon/run.d.ts +13 -0
- package/dist/lib/mesh/live/daemon/run.js +35 -2
- package/dist/lib/mesh/live/direct-drain.js +1 -1
- package/dist/lib/mesh/live/emit.d.ts +3 -0
- package/dist/lib/mesh/live/emit.js +32 -9
- package/dist/lib/mesh/live/flush.d.ts +3 -0
- package/dist/lib/mesh/live/flush.js +115 -32
- package/dist/lib/mesh/live/liveness-carry.d.ts +1 -1
- package/dist/lib/mesh/live/liveness-carry.js +1 -1
- package/dist/lib/mesh/live/reporting-privacy.d.ts +119 -3
- package/dist/lib/mesh/live/reporting-privacy.js +235 -11
- package/dist/lib/mesh/live/spool.d.ts +17 -2
- package/dist/lib/mesh/live/spool.js +22 -6
- package/dist/lib/ontology-graph/legacy/coverage.d.ts +67 -0
- package/dist/lib/ontology-graph/legacy/coverage.js +192 -0
- package/dist/lib/ontology-graph/legacy/index.d.ts +199 -0
- package/dist/lib/ontology-graph/legacy/index.js +1150 -0
- package/dist/lib/ontology-graph/legacy/parse.d.ts +49 -0
- package/dist/lib/ontology-graph/legacy/parse.js +126 -0
- package/dist/lib/ontology-graph/legacy/report.d.ts +14 -0
- package/dist/lib/ontology-graph/legacy/report.js +254 -0
- package/dist/lib/ontology-graph/legacy/verb-map.d.ts +35 -0
- package/dist/lib/ontology-graph/legacy/verb-map.js +84 -0
- package/dist/lib/ontology-graph/lint/checks.d.ts +140 -0
- package/dist/lib/ontology-graph/lint/checks.js +717 -0
- package/dist/lib/ontology-graph/lint/coverage.d.ts +106 -0
- package/dist/lib/ontology-graph/lint/coverage.js +241 -0
- package/dist/lib/ontology-graph/lint/daily-job.d.ts +259 -0
- package/dist/lib/ontology-graph/lint/daily-job.js +595 -0
- package/dist/lib/ontology-graph/lint/index.d.ts +65 -0
- package/dist/lib/ontology-graph/lint/index.js +176 -0
- package/dist/lib/ontology-graph/model/files.d.ts +20 -0
- package/dist/lib/ontology-graph/model/files.js +89 -0
- package/dist/lib/ontology-graph/model/index.d.ts +65 -0
- package/dist/lib/ontology-graph/model/index.js +100 -0
- package/dist/lib/ontology-graph/model/pass-tasks.d.ts +156 -0
- package/dist/lib/ontology-graph/model/pass-tasks.js +345 -0
- package/dist/lib/ontology-graph/model/pass.d.ts +109 -0
- package/dist/lib/ontology-graph/model/pass.js +958 -0
- package/dist/lib/ontology-graph/model/runner.d.ts +50 -0
- package/dist/lib/ontology-graph/model/runner.js +160 -0
- package/dist/lib/ontology-graph/model/step.d.ts +197 -0
- package/dist/lib/ontology-graph/model/step.js +526 -0
- package/dist/lib/ontology-graph/model/tasks.d.ts +183 -0
- package/dist/lib/ontology-graph/model/tasks.js +349 -0
- package/dist/lib/ontology-graph/not-implemented.d.ts +5 -0
- package/dist/lib/ontology-graph/not-implemented.js +8 -0
- package/dist/lib/ontology-graph/org/compare.d.ts +28 -0
- package/dist/lib/ontology-graph/org/compare.js +239 -0
- package/dist/lib/ontology-graph/org/derive.d.ts +67 -0
- package/dist/lib/ontology-graph/org/derive.js +359 -0
- package/dist/lib/ontology-graph/org/index.d.ts +102 -0
- package/dist/lib/ontology-graph/org/index.js +630 -0
- package/dist/lib/ontology-graph/org/load.d.ts +31 -0
- package/dist/lib/ontology-graph/org/load.js +476 -0
- package/dist/lib/ontology-graph/org/role.d.ts +38 -0
- package/dist/lib/ontology-graph/org/role.js +268 -0
- package/dist/lib/ontology-graph/org/structure.d.ts +63 -0
- package/dist/lib/ontology-graph/org/structure.js +437 -0
- package/dist/lib/ontology-graph/org/text.d.ts +97 -0
- package/dist/lib/ontology-graph/org/text.js +321 -0
- package/dist/lib/ontology-graph/org/types.d.ts +457 -0
- package/dist/lib/ontology-graph/org/types.js +80 -0
- package/dist/lib/ontology-graph/pages/index.d.ts +64 -0
- package/dist/lib/ontology-graph/pages/index.js +193 -0
- package/dist/lib/ontology-graph/pages/render.d.ts +144 -0
- package/dist/lib/ontology-graph/pages/render.js +688 -0
- package/dist/lib/ontology-graph/proposals/apply.d.ts +109 -0
- package/dist/lib/ontology-graph/proposals/apply.js +468 -0
- package/dist/lib/ontology-graph/proposals/group.d.ts +63 -0
- package/dist/lib/ontology-graph/proposals/group.js +232 -0
- package/dist/lib/ontology-graph/proposals/index.d.ts +173 -0
- package/dist/lib/ontology-graph/proposals/index.js +474 -0
- package/dist/lib/ontology-graph/proposals/model.d.ts +162 -0
- package/dist/lib/ontology-graph/proposals/model.js +196 -0
- package/dist/lib/ontology-graph/proposals/org-chart.d.ts +82 -0
- package/dist/lib/ontology-graph/proposals/org-chart.js +340 -0
- package/dist/lib/ontology-graph/read/brief.d.ts +26 -0
- package/dist/lib/ontology-graph/read/brief.js +254 -0
- package/dist/lib/ontology-graph/read/graph-index.d.ts +76 -0
- package/dist/lib/ontology-graph/read/graph-index.js +198 -0
- package/dist/lib/ontology-graph/read/index.d.ts +59 -0
- package/dist/lib/ontology-graph/read/index.js +803 -0
- package/dist/lib/ontology-graph/read/member.d.ts +7 -0
- package/dist/lib/ontology-graph/read/member.js +34 -0
- package/dist/lib/ontology-graph/read/names.d.ts +49 -0
- package/dist/lib/ontology-graph/read/names.js +297 -0
- package/dist/lib/ontology-graph/read/reader-setting.d.ts +19 -0
- package/dist/lib/ontology-graph/read/reader-setting.js +62 -0
- package/dist/lib/ontology-graph/read/test-graph.d.ts +37 -0
- package/dist/lib/ontology-graph/read/test-graph.js +150 -0
- package/dist/lib/ontology-graph/replay/buffered-store.d.ts +33 -0
- package/dist/lib/ontology-graph/replay/buffered-store.js +50 -0
- package/dist/lib/ontology-graph/replay/config.d.ts +41 -0
- package/dist/lib/ontology-graph/replay/config.js +105 -0
- package/dist/lib/ontology-graph/replay/engine.d.ts +146 -0
- package/dist/lib/ontology-graph/replay/engine.js +1240 -0
- package/dist/lib/ontology-graph/replay/extractors.d.ts +59 -0
- package/dist/lib/ontology-graph/replay/extractors.js +1555 -0
- package/dist/lib/ontology-graph/replay/index.d.ts +91 -0
- package/dist/lib/ontology-graph/replay/index.js +220 -0
- package/dist/lib/ontology-graph/replay/listing-manifest.d.ts +66 -0
- package/dist/lib/ontology-graph/replay/listing-manifest.js +242 -0
- package/dist/lib/ontology-graph/replay/member.d.ts +19 -0
- package/dist/lib/ontology-graph/replay/member.js +65 -0
- package/dist/lib/ontology-graph/replay/mentions.d.ts +58 -0
- package/dist/lib/ontology-graph/replay/mentions.js +239 -0
- package/dist/lib/ontology-graph/replay/readers.d.ts +98 -0
- package/dist/lib/ontology-graph/replay/readers.js +1251 -0
- package/dist/lib/ontology-graph/replay/rules.d.ts +127 -0
- package/dist/lib/ontology-graph/replay/rules.js +374 -0
- package/dist/lib/ontology-graph/replay/scope.d.ts +35 -0
- package/dist/lib/ontology-graph/replay/scope.js +115 -0
- package/dist/lib/ontology-graph/replay/transcripts.d.ts +39 -0
- package/dist/lib/ontology-graph/replay/transcripts.js +224 -0
- package/dist/lib/ontology-graph/replay/util.d.ts +55 -0
- package/dist/lib/ontology-graph/replay/util.js +256 -0
- package/dist/lib/ontology-graph/resolve/entity-index.d.ts +159 -0
- package/dist/lib/ontology-graph/resolve/entity-index.js +652 -0
- package/dist/lib/ontology-graph/resolve/index.d.ts +113 -0
- package/dist/lib/ontology-graph/resolve/index.js +214 -0
- package/dist/lib/ontology-graph/resolve/machine.d.ts +34 -0
- package/dist/lib/ontology-graph/resolve/machine.js +95 -0
- package/dist/lib/ontology-graph/resolve/normalize.d.ts +35 -0
- package/dist/lib/ontology-graph/resolve/normalize.js +124 -0
- package/dist/lib/ontology-graph/resolve/org-chart.d.ts +107 -0
- package/dist/lib/ontology-graph/resolve/org-chart.js +578 -0
- package/dist/lib/ontology-graph/resolve/org-layer.d.ts +78 -0
- package/dist/lib/ontology-graph/resolve/org-layer.js +159 -0
- package/dist/lib/ontology-graph/resolve/org-seed.d.ts +141 -0
- package/dist/lib/ontology-graph/resolve/org-seed.js +631 -0
- package/dist/lib/ontology-graph/resolve/org-sources.d.ts +165 -0
- package/dist/lib/ontology-graph/resolve/org-sources.js +634 -0
- package/dist/lib/ontology-graph/resolve/roster.d.ts +76 -0
- package/dist/lib/ontology-graph/resolve/roster.js +226 -0
- package/dist/lib/ontology-graph/resolve/seed.d.ts +267 -0
- package/dist/lib/ontology-graph/resolve/seed.js +1198 -0
- package/dist/lib/ontology-graph/resolve/upsert.d.ts +58 -0
- package/dist/lib/ontology-graph/resolve/upsert.js +139 -0
- package/dist/lib/ontology-graph/resolve/writer.d.ts +128 -0
- package/dist/lib/ontology-graph/resolve/writer.js +351 -0
- package/dist/lib/ontology-graph/schema/authority.d.ts +107 -0
- package/dist/lib/ontology-graph/schema/authority.js +186 -0
- package/dist/lib/ontology-graph/schema/default-schema.d.ts +10 -0
- package/dist/lib/ontology-graph/schema/default-schema.js +242 -0
- package/dist/lib/ontology-graph/schema/grammar.d.ts +57 -0
- package/dist/lib/ontology-graph/schema/grammar.js +409 -0
- package/dist/lib/ontology-graph/schema/index.d.ts +12 -0
- package/dist/lib/ontology-graph/schema/index.js +10 -0
- package/dist/lib/ontology-graph/schema/validate.d.ts +13 -0
- package/dist/lib/ontology-graph/schema/validate.js +132 -0
- package/dist/lib/ontology-graph/store/files.d.ts +34 -0
- package/dist/lib/ontology-graph/store/files.js +207 -0
- package/dist/lib/ontology-graph/store/fs.d.ts +30 -0
- package/dist/lib/ontology-graph/store/fs.js +101 -0
- package/dist/lib/ontology-graph/store/graph-store.d.ts +14 -0
- package/dist/lib/ontology-graph/store/graph-store.js +520 -0
- package/dist/lib/ontology-graph/store/index.d.ts +18 -0
- package/dist/lib/ontology-graph/store/index.js +15 -0
- package/dist/lib/ontology-graph/store/ingest.d.ts +37 -0
- package/dist/lib/ontology-graph/store/ingest.js +323 -0
- package/dist/lib/ontology-graph/store/paths.d.ts +114 -0
- package/dist/lib/ontology-graph/store/paths.js +232 -0
- package/dist/lib/ontology-graph/types.d.ts +1190 -0
- package/dist/lib/ontology-graph/types.js +131 -0
- package/dist/lib/secret-scan/gitleaks-rules.generated.js +1 -1
- 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/frontmatter.d.ts +14 -0
- package/dist/utils/frontmatter.js +18 -0
- package/dist/utils/hook-engine-rollup.d.ts +96 -0
- package/dist/utils/hook-engine-rollup.js +725 -0
- package/dist/utils/interactive-caller.js +1 -1
- package/package.json +9 -9
- package/scripts/install-hook-engine.mjs +4 -0
- package/assets/scaffold/core/scripts/knowledge-prefs.sh +0 -55
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { openGraphStore, claimGraphRootFor } from "../store/index.js";
|
|
2
|
+
import { declinedProposalIds, fileProposals, groupNameVariantProposals, readOpenProposals } from "../proposals/index.js";
|
|
3
|
+
import { LINT_CLASSES, STALE_AGE_DAYS, runChecks, scanGraph } from "./checks.js";
|
|
4
|
+
import { coverageCommand } from "./coverage.js";
|
|
5
|
+
export { UNINFORMATIVE_STAGES, coverageCommand, lastMonths, measureCoverage, renderCoverage, runCoverage } from "./coverage.js";
|
|
6
|
+
export { CLOSED_STATUS_VALUES, EXTRA_LINT_KINDS, LINT_CLASSES, STALE_AGE_DAYS, closedEntities, runChecks, scanGraph, sourceScope, } from "./checks.js";
|
|
7
|
+
/** Environment switch for `--strict`, for callers that cannot pass the flag. */
|
|
8
|
+
export const LINT_STRICT_ENV = "HQ_ONTOLOGY_LINT_STRICT";
|
|
9
|
+
const compareText = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
10
|
+
/** Model-free. Runs at the end of every update. */
|
|
11
|
+
export async function runLint(context, options) {
|
|
12
|
+
const started = Date.now();
|
|
13
|
+
const now = options.now ?? new Date();
|
|
14
|
+
const day = now.toISOString().slice(0, 10);
|
|
15
|
+
const store = openGraphStore(context.graphRoot, { company: context.company });
|
|
16
|
+
const only = options.entities ? new Set(options.entities) : undefined;
|
|
17
|
+
const scan = scanGraph(store, only ? { only } : {});
|
|
18
|
+
const declined = declinedProposalIds(context);
|
|
19
|
+
const found = runChecks(scan, {
|
|
20
|
+
today: day,
|
|
21
|
+
filedAt: now.toISOString(),
|
|
22
|
+
staleAgeDays: { ...STALE_AGE_DAYS, ...(options.staleAgeDays ?? {}) },
|
|
23
|
+
});
|
|
24
|
+
const counts = Object.fromEntries(LINT_CLASSES.map((entry) => [entry.kind, 0]));
|
|
25
|
+
const findings = [];
|
|
26
|
+
const proposals = [];
|
|
27
|
+
let declinedCount = 0;
|
|
28
|
+
for (const item of found) {
|
|
29
|
+
if (item.proposal && declined.has(item.proposal.id)) {
|
|
30
|
+
declinedCount += 1;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
counts[item.finding.kind] = (counts[item.finding.kind] ?? 0) + 1;
|
|
34
|
+
findings.push(item.finding);
|
|
35
|
+
if (item.proposal)
|
|
36
|
+
proposals.push(item.proposal);
|
|
37
|
+
}
|
|
38
|
+
const errors = findings.filter((entry) => entry.severity === "error").length;
|
|
39
|
+
let proposalsFiled = 0;
|
|
40
|
+
let proposalsHeld = 0;
|
|
41
|
+
let nameVariantGroups = 0;
|
|
42
|
+
let nameVariantPairsReplaced = 0;
|
|
43
|
+
if (options.fileProposals) {
|
|
44
|
+
const cap = options.maxProposalsPerKind ?? 200;
|
|
45
|
+
const open = new Set(readOpenProposals(context).map((proposal) => proposal.id));
|
|
46
|
+
const perKind = new Map();
|
|
47
|
+
const toFile = [];
|
|
48
|
+
for (const proposal of proposals) {
|
|
49
|
+
if (open.has(proposal.id))
|
|
50
|
+
continue;
|
|
51
|
+
const used = perKind.get(proposal.kind) ?? 0;
|
|
52
|
+
if (used >= cap) {
|
|
53
|
+
proposalsHeld += 1;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
perKind.set(proposal.kind, used + 1);
|
|
57
|
+
toFile.push(proposal);
|
|
58
|
+
}
|
|
59
|
+
proposalsFiled = fileProposals(context, toFile);
|
|
60
|
+
// One proposal per person for name variants at one company, in place of one per pair.
|
|
61
|
+
// A scoped run that filed nothing has no new pair to fold.
|
|
62
|
+
if (!only || proposalsFiled > 0) {
|
|
63
|
+
const grouped = groupNameVariantProposals(context, { store, now });
|
|
64
|
+
nameVariantGroups = grouped.filed;
|
|
65
|
+
nameVariantPairsReplaced = grouped.replaced;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const seconds = Math.round((Date.now() - started) / 10) / 100;
|
|
69
|
+
const report = {
|
|
70
|
+
counts: counts,
|
|
71
|
+
findings,
|
|
72
|
+
errors,
|
|
73
|
+
proposalsFiled,
|
|
74
|
+
graphRoot: context.graphRoot,
|
|
75
|
+
day,
|
|
76
|
+
entities: scan.entities.size,
|
|
77
|
+
scope: only ? "touched" : "all",
|
|
78
|
+
rows: scan.rowCount,
|
|
79
|
+
audiences: scan.audiences,
|
|
80
|
+
warnings: findings.length - errors,
|
|
81
|
+
declined: declinedCount,
|
|
82
|
+
proposalsHeld,
|
|
83
|
+
openProposals: readOpenProposals(context).length,
|
|
84
|
+
nameVariantGroups,
|
|
85
|
+
nameVariantPairsReplaced,
|
|
86
|
+
seconds,
|
|
87
|
+
};
|
|
88
|
+
if (options.fileProposals) {
|
|
89
|
+
claimGraphRootFor(context.graphRoot, context.company, context.companyRoot);
|
|
90
|
+
store.init();
|
|
91
|
+
const summary = LINT_CLASSES.filter((entry) => counts[entry.kind] > 0).map((entry) => `${entry.kind} ${counts[entry.kind]}`);
|
|
92
|
+
store.appendLog({
|
|
93
|
+
date: day,
|
|
94
|
+
op: "lint",
|
|
95
|
+
subject: "lint",
|
|
96
|
+
touched: [],
|
|
97
|
+
rowsAdded: 0,
|
|
98
|
+
rowsClosed: 0,
|
|
99
|
+
note: `${only ? `${scan.entities.size} touched entities: ` : ""}${summary.length > 0 ? summary.join(", ") : "no findings"}; proposals filed ${proposalsFiled}`,
|
|
100
|
+
});
|
|
101
|
+
store.appendLedger({
|
|
102
|
+
run: `lint-${now.toISOString()}`,
|
|
103
|
+
command: "lint",
|
|
104
|
+
day,
|
|
105
|
+
inputs: {},
|
|
106
|
+
rowsAdded: 0,
|
|
107
|
+
rowsClosed: 0,
|
|
108
|
+
entitiesCreated: 0,
|
|
109
|
+
modelCalls: 0,
|
|
110
|
+
cacheHits: 0,
|
|
111
|
+
inputTokens: 0,
|
|
112
|
+
outputTokens: 0,
|
|
113
|
+
pending: 0,
|
|
114
|
+
seconds,
|
|
115
|
+
at: now.toISOString(),
|
|
116
|
+
counters: Object.fromEntries([...Object.entries(counts), ["proposals_filed", proposalsFiled], ...(only ? [["scoped_entities", scan.entities.size]] : [])].sort(([a], [b]) => compareText(a, b))),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return report;
|
|
120
|
+
}
|
|
121
|
+
function renderText(report, strict, wroteProposals) {
|
|
122
|
+
const count = (kind) => report.counts[kind] ?? 0;
|
|
123
|
+
const lines = [
|
|
124
|
+
`Ontology graph lint: ${report.graphRoot}`,
|
|
125
|
+
`${report.entities} entities${report.scope === "touched" ? " (only the ones asked for)" : ""}, ${report.rows} rows, ${report.audiences.length} audience folder${report.audiences.length === 1 ? "" : "s"}, ${report.seconds}s`,
|
|
126
|
+
"",
|
|
127
|
+
`Errors: ${report.errors}${strict ? "" : " (these fail the run only with --strict)"}`,
|
|
128
|
+
];
|
|
129
|
+
for (const entry of LINT_CLASSES.filter((item) => item.severity === "error")) {
|
|
130
|
+
lines.push(` ${entry.kind.padEnd(20)}${String(count(entry.kind)).padStart(7)} ${entry.label}`);
|
|
131
|
+
}
|
|
132
|
+
lines.push("", `Warnings: ${report.warnings}`);
|
|
133
|
+
for (const entry of LINT_CLASSES.filter((item) => item.severity === "warn")) {
|
|
134
|
+
lines.push(` ${entry.kind.padEnd(20)}${String(count(entry.kind)).padStart(7)} ${entry.label}`);
|
|
135
|
+
}
|
|
136
|
+
if (report.declined > 0)
|
|
137
|
+
lines.push("", `${report.declined} finding${report.declined === 1 ? "" : "s"} left out: a member answered "nope".`);
|
|
138
|
+
const perClass = 5;
|
|
139
|
+
const shown = [];
|
|
140
|
+
for (const entry of LINT_CLASSES) {
|
|
141
|
+
const ofKind = report.findings.filter((item) => item.kind === entry.kind);
|
|
142
|
+
for (const item of ofKind.slice(0, perClass)) {
|
|
143
|
+
const rows = item.rows.length > 0 ? ` [row ${item.rows.join(", ")}]` : "";
|
|
144
|
+
shown.push(` ${entry.kind}: ${item.message}${rows}`);
|
|
145
|
+
}
|
|
146
|
+
if (ofKind.length > perClass)
|
|
147
|
+
shown.push(` ${entry.kind}: ... ${ofKind.length - perClass} more (--json lists all)`);
|
|
148
|
+
}
|
|
149
|
+
if (shown.length > 0)
|
|
150
|
+
lines.push("", "Findings", ...shown);
|
|
151
|
+
lines.push("");
|
|
152
|
+
if (wroteProposals) {
|
|
153
|
+
lines.push(`Proposals: ${report.proposalsFiled} new, ${report.openProposals} open${report.proposalsHeld > 0 ? `, ${report.proposalsHeld} held for the next run` : ""}. Review: hq ontology proposals list`);
|
|
154
|
+
if (report.nameVariantGroups > 0) {
|
|
155
|
+
lines.push(`Name variants: ${report.nameVariantGroups} new group${report.nameVariantGroups === 1 ? "" : "s"} in place of ${report.nameVariantPairsReplaced} pair proposal${report.nameVariantPairsReplaced === 1 ? "" : "s"}. Review: hq ontology proposals list --set "name variants"`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
lines.push("Report only: no proposals filed, nothing written.");
|
|
160
|
+
}
|
|
161
|
+
return lines.join("\n");
|
|
162
|
+
}
|
|
163
|
+
/** `hq ontology lint`: a count per class and the findings; exit code 1 only with `--strict` and an error-class finding. */
|
|
164
|
+
export async function lintCommand(context, options) {
|
|
165
|
+
if (options.coverage)
|
|
166
|
+
return coverageCommand(context, { ...(options.now ? { now: options.now } : {}) });
|
|
167
|
+
const strict = options.strict ?? /^(1|true|yes)$/i.test(process.env[LINT_STRICT_ENV] ?? "");
|
|
168
|
+
const report = await runLint(context, options);
|
|
169
|
+
const failed = strict && report.errors > 0;
|
|
170
|
+
return {
|
|
171
|
+
text: renderText(report, strict, options.fileProposals),
|
|
172
|
+
json: { ...report, strict, ok: report.errors === 0 },
|
|
173
|
+
...(failed ? { exitCode: 1 } : {}),
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Paths relative to the graph root, forward slashes. Additions to the layout in CONTRACT.md section 1. */
|
|
2
|
+
export declare const MODEL_STATE_PATHS: {
|
|
3
|
+
readonly cache: ".state/cache";
|
|
4
|
+
readonly callLedger: ".state/model-ledger.jsonl";
|
|
5
|
+
readonly pending: ".state/model-pending.json";
|
|
6
|
+
readonly parked: ".state/model-parked.jsonl";
|
|
7
|
+
};
|
|
8
|
+
export declare function statePath(graphRoot: string, relative: string): string;
|
|
9
|
+
export declare function sha256Hex(text: string): string;
|
|
10
|
+
/** Temp file beside the target, then a rename over it. Creates parent folders. */
|
|
11
|
+
export declare function writeFileAtomicSync(file: string, text: string): void;
|
|
12
|
+
export declare function readTextIfPresent(file: string): string | null;
|
|
13
|
+
export declare function appendJsonLineSync(file: string, value: unknown): void;
|
|
14
|
+
/** A missing file is an empty list. A torn or unparseable line is skipped. */
|
|
15
|
+
export declare function readJsonLinesSync<T>(file: string): T[];
|
|
16
|
+
/** JSON with object keys sorted at every level, so equal values give equal bytes. */
|
|
17
|
+
export declare function stableStringify(value: unknown): string;
|
|
18
|
+
/** Token estimate when the CLI reports no usage: bytes / 4, rounded up. */
|
|
19
|
+
export declare function estimateTokens(text: string): number;
|
|
20
|
+
//# sourceMappingURL=files.d.ts.map
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WP-D: small synchronous file helpers for the model step's own state files
|
|
3
|
+
* (cache, pending markers, parked items, call ledger). They live beside the
|
|
4
|
+
* store's files in `.state/` but are written only by this package.
|
|
5
|
+
*/
|
|
6
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
7
|
+
import * as fs from "node:fs";
|
|
8
|
+
import * as path from "node:path";
|
|
9
|
+
/** Paths relative to the graph root, forward slashes. Additions to the layout in CONTRACT.md section 1. */
|
|
10
|
+
export const MODEL_STATE_PATHS = {
|
|
11
|
+
cache: ".state/cache",
|
|
12
|
+
callLedger: ".state/model-ledger.jsonl",
|
|
13
|
+
pending: ".state/model-pending.json",
|
|
14
|
+
parked: ".state/model-parked.jsonl",
|
|
15
|
+
};
|
|
16
|
+
export function statePath(graphRoot, relative) {
|
|
17
|
+
return path.join(graphRoot, ...relative.split("/"));
|
|
18
|
+
}
|
|
19
|
+
export function sha256Hex(text) {
|
|
20
|
+
return createHash("sha256").update(text, "utf8").digest("hex");
|
|
21
|
+
}
|
|
22
|
+
/** Temp file beside the target, then a rename over it. Creates parent folders. */
|
|
23
|
+
export function writeFileAtomicSync(file, text) {
|
|
24
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
25
|
+
const temp = `${file}.${process.pid}.${randomBytes(4).toString("hex")}.tmp`;
|
|
26
|
+
fs.writeFileSync(temp, text, "utf8");
|
|
27
|
+
try {
|
|
28
|
+
fs.renameSync(temp, file);
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
fs.rmSync(temp, { force: true });
|
|
32
|
+
throw err;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export function readTextIfPresent(file) {
|
|
36
|
+
try {
|
|
37
|
+
return fs.readFileSync(file, "utf8");
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
if (err.code === "ENOENT")
|
|
41
|
+
return null;
|
|
42
|
+
throw err;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export function appendJsonLineSync(file, value) {
|
|
46
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
47
|
+
fs.appendFileSync(file, `${JSON.stringify(value)}\n`, "utf8");
|
|
48
|
+
}
|
|
49
|
+
/** A missing file is an empty list. A torn or unparseable line is skipped. */
|
|
50
|
+
export function readJsonLinesSync(file) {
|
|
51
|
+
const text = readTextIfPresent(file);
|
|
52
|
+
if (text === null)
|
|
53
|
+
return [];
|
|
54
|
+
const out = [];
|
|
55
|
+
for (const line of text.split("\n")) {
|
|
56
|
+
if (line.trim() === "")
|
|
57
|
+
continue;
|
|
58
|
+
try {
|
|
59
|
+
out.push(JSON.parse(line));
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
// A torn last line from a killed run.
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
/** JSON with object keys sorted at every level, so equal values give equal bytes. */
|
|
68
|
+
export function stableStringify(value) {
|
|
69
|
+
return JSON.stringify(sortKeys(value));
|
|
70
|
+
}
|
|
71
|
+
function sortKeys(value) {
|
|
72
|
+
if (Array.isArray(value))
|
|
73
|
+
return value.map(sortKeys);
|
|
74
|
+
if (value !== null && typeof value === "object") {
|
|
75
|
+
const out = {};
|
|
76
|
+
for (const key of Object.keys(value).sort()) {
|
|
77
|
+
const inner = value[key];
|
|
78
|
+
if (inner !== undefined)
|
|
79
|
+
out[key] = sortKeys(inner);
|
|
80
|
+
}
|
|
81
|
+
return out;
|
|
82
|
+
}
|
|
83
|
+
return value;
|
|
84
|
+
}
|
|
85
|
+
/** Token estimate when the CLI reports no usage: bytes / 4, rounded up. */
|
|
86
|
+
export function estimateTokens(text) {
|
|
87
|
+
return Math.ceil(Buffer.byteLength(text, "utf8") / 4);
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { GraphContext, ModelBudget, ModelRunner, ModelStepRequest } from "../types.js";
|
|
2
|
+
import { type BatchModelStep } from "./step.js";
|
|
3
|
+
export * from "./runner.js";
|
|
4
|
+
export * from "./step.js";
|
|
5
|
+
export * from "./tasks.js";
|
|
6
|
+
export * from "./pass-tasks.js";
|
|
7
|
+
export * from "./pass.js";
|
|
8
|
+
export { MODEL_STATE_PATHS, estimateTokens } from "./files.js";
|
|
9
|
+
export interface CreateModelStepOptions {
|
|
10
|
+
/** Per-day budget. Model calls stop when either side is spent. */
|
|
11
|
+
budget: ModelBudget;
|
|
12
|
+
/** Per-run budget, counted from when the step is created. Default: no cap. */
|
|
13
|
+
runBudget?: ModelBudget;
|
|
14
|
+
/** Default: `resolveModel(context)`, which is Haiku unless the one setting raises it. */
|
|
15
|
+
model?: string;
|
|
16
|
+
/** Default: the tool-less `claude -p` turn. Injected in tests. */
|
|
17
|
+
runner?: ModelRunner;
|
|
18
|
+
/** Never call the model; cache misses return `pending`. */
|
|
19
|
+
dryRun?: boolean;
|
|
20
|
+
/** Send items an earlier run parked for bad output again. Default false. */
|
|
21
|
+
retryParked?: boolean;
|
|
22
|
+
/** Run id written to `.state/model-ledger.jsonl`. */
|
|
23
|
+
runId?: string;
|
|
24
|
+
/** Clock for ledger and marker timestamps. */
|
|
25
|
+
now?: () => Date;
|
|
26
|
+
/** Folder for the cache and the step's other state files. Default: `resolveModelStateDir(context)`. */
|
|
27
|
+
stateDir?: string;
|
|
28
|
+
/** Model turns in flight at once. Default 1. */
|
|
29
|
+
concurrency?: number;
|
|
30
|
+
}
|
|
31
|
+
/** Environment variable that raises (or pins) the model for one run. */
|
|
32
|
+
export declare const ONTOLOGY_MODEL_ENV = "HQ_ONTOLOGY_MODEL";
|
|
33
|
+
/** Company setting file and key: `companies/<slug>/settings/ontology.yaml`, `model: <name>`. */
|
|
34
|
+
export declare const ONTOLOGY_SETTINGS_FILE = "settings/ontology.yaml";
|
|
35
|
+
/**
|
|
36
|
+
* The model the step calls. Order: the explicit option, then
|
|
37
|
+
* `HQ_ONTOLOGY_MODEL`, then `model` in the company's `settings/ontology.yaml`,
|
|
38
|
+
* then Haiku. That file's `model` key is the one setting that raises it for
|
|
39
|
+
* every run on the machine.
|
|
40
|
+
*/
|
|
41
|
+
export declare function resolveModel(context: Pick<GraphContext, "companyRoot">, explicit?: string, env?: NodeJS.ProcessEnv): string;
|
|
42
|
+
/** Environment variable that names the folder for the model cache and the step's other state files. */
|
|
43
|
+
export declare const ONTOLOGY_MODEL_STATE_ENV = "HQ_ONTOLOGY_MODEL_STATE";
|
|
44
|
+
/** Beside the default graph folder, inside the same never-synced `.hq` folder. */
|
|
45
|
+
export declare const MODEL_STATE_SIBLING = "ontology-graph-model";
|
|
46
|
+
/**
|
|
47
|
+
* Where the cache, call ledger, pending markers and parked items live. Order:
|
|
48
|
+
* the explicit option, then `HQ_ONTOLOGY_MODEL_STATE`, then, for a company's
|
|
49
|
+
* default graph folder, the sibling `.hq/ontology-graph-model` (a rebuild that
|
|
50
|
+
* moves the graph folder aside keeps every model reply), else
|
|
51
|
+
* `<graphRoot>/.state` (tests and one-off graph roots stay self-contained).
|
|
52
|
+
*/
|
|
53
|
+
export declare function resolveModelStateDir(context: Pick<GraphContext, "companyRoot" | "graphRoot">, explicit?: string, env?: NodeJS.ProcessEnv): string;
|
|
54
|
+
/** Cache lives in `<model state dir>/cache/{sha256}.json` (see `resolveModelStateDir`). */
|
|
55
|
+
export declare function createModelStep(context: GraphContext, options: CreateModelStepOptions): BatchModelStep;
|
|
56
|
+
/**
|
|
57
|
+
* `sha256(promptVersion + "\n" + kind + "\n" + input)`, hex. With `model`, the
|
|
58
|
+
* model name is part of the key (`promptVersion + "\n" + model + "\n" + kind +
|
|
59
|
+
* "\n" + input`); the step always passes it, so raising the model never reuses
|
|
60
|
+
* a cheaper model's replies.
|
|
61
|
+
*/
|
|
62
|
+
export declare function modelCacheKey(request: Pick<ModelStepRequest, "promptVersion" | "kind" | "input"> & {
|
|
63
|
+
model?: string;
|
|
64
|
+
}): string;
|
|
65
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WP-D entry point: the cached, budgeted model step (design 5, cost rules).
|
|
3
|
+
* Signatures are fixed by CONTRACT.md. The step this package returns is a
|
|
4
|
+
* superset of the contract's `ModelStep`: it also runs batches (step.ts) and
|
|
5
|
+
* the four tasks in tasks.ts are built on that.
|
|
6
|
+
*/
|
|
7
|
+
import * as fs from "node:fs";
|
|
8
|
+
import * as path from "node:path";
|
|
9
|
+
import yaml from "js-yaml";
|
|
10
|
+
import { defaultGraphRoot } from "../store/index.js";
|
|
11
|
+
import { DEFAULT_ONTOLOGY_MODEL, createClaudeCliRunner } from "./runner.js";
|
|
12
|
+
import { cacheKeyFor, createBatchModelStep } from "./step.js";
|
|
13
|
+
export * from "./runner.js";
|
|
14
|
+
export * from "./step.js";
|
|
15
|
+
export * from "./tasks.js";
|
|
16
|
+
export * from "./pass-tasks.js";
|
|
17
|
+
export * from "./pass.js";
|
|
18
|
+
export { MODEL_STATE_PATHS, estimateTokens } from "./files.js";
|
|
19
|
+
/** Environment variable that raises (or pins) the model for one run. */
|
|
20
|
+
export const ONTOLOGY_MODEL_ENV = "HQ_ONTOLOGY_MODEL";
|
|
21
|
+
/** Company setting file and key: `companies/<slug>/settings/ontology.yaml`, `model: <name>`. */
|
|
22
|
+
export const ONTOLOGY_SETTINGS_FILE = "settings/ontology.yaml";
|
|
23
|
+
const MODEL_NAME = /^[a-z0-9][a-z0-9.[\]-]{0,63}$/i;
|
|
24
|
+
/**
|
|
25
|
+
* The model the step calls. Order: the explicit option, then
|
|
26
|
+
* `HQ_ONTOLOGY_MODEL`, then `model` in the company's `settings/ontology.yaml`,
|
|
27
|
+
* then Haiku. That file's `model` key is the one setting that raises it for
|
|
28
|
+
* every run on the machine.
|
|
29
|
+
*/
|
|
30
|
+
export function resolveModel(context, explicit, env = process.env) {
|
|
31
|
+
const accept = (value) => (typeof value === "string" && MODEL_NAME.test(value.trim()) ? value.trim() : null);
|
|
32
|
+
const fromOption = accept(explicit);
|
|
33
|
+
if (fromOption)
|
|
34
|
+
return fromOption;
|
|
35
|
+
const fromEnv = accept(env[ONTOLOGY_MODEL_ENV]);
|
|
36
|
+
if (fromEnv)
|
|
37
|
+
return fromEnv;
|
|
38
|
+
try {
|
|
39
|
+
const parsed = yaml.load(fs.readFileSync(path.join(context.companyRoot, ...ONTOLOGY_SETTINGS_FILE.split("/")), "utf8"));
|
|
40
|
+
if (parsed && typeof parsed === "object") {
|
|
41
|
+
const record = parsed;
|
|
42
|
+
const nested = record.ontology && typeof record.ontology === "object" ? record.ontology.model : undefined;
|
|
43
|
+
const fromFile = accept(record.model) ?? accept(nested);
|
|
44
|
+
if (fromFile)
|
|
45
|
+
return fromFile;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// No settings file, or one that does not parse: the default stands.
|
|
50
|
+
}
|
|
51
|
+
return DEFAULT_ONTOLOGY_MODEL;
|
|
52
|
+
}
|
|
53
|
+
/** Environment variable that names the folder for the model cache and the step's other state files. */
|
|
54
|
+
export const ONTOLOGY_MODEL_STATE_ENV = "HQ_ONTOLOGY_MODEL_STATE";
|
|
55
|
+
/** Beside the default graph folder, inside the same never-synced `.hq` folder. */
|
|
56
|
+
export const MODEL_STATE_SIBLING = "ontology-graph-model";
|
|
57
|
+
/**
|
|
58
|
+
* Where the cache, call ledger, pending markers and parked items live. Order:
|
|
59
|
+
* the explicit option, then `HQ_ONTOLOGY_MODEL_STATE`, then, for a company's
|
|
60
|
+
* default graph folder, the sibling `.hq/ontology-graph-model` (a rebuild that
|
|
61
|
+
* moves the graph folder aside keeps every model reply), else
|
|
62
|
+
* `<graphRoot>/.state` (tests and one-off graph roots stay self-contained).
|
|
63
|
+
*/
|
|
64
|
+
export function resolveModelStateDir(context, explicit, env = process.env) {
|
|
65
|
+
if (explicit && explicit.trim() !== "")
|
|
66
|
+
return path.resolve(explicit);
|
|
67
|
+
const fromEnv = env[ONTOLOGY_MODEL_STATE_ENV];
|
|
68
|
+
if (typeof fromEnv === "string" && fromEnv.trim() !== "")
|
|
69
|
+
return path.resolve(fromEnv.trim());
|
|
70
|
+
if (path.resolve(context.graphRoot) === path.resolve(defaultGraphRoot(context.companyRoot))) {
|
|
71
|
+
return path.join(path.dirname(path.resolve(context.graphRoot)), MODEL_STATE_SIBLING);
|
|
72
|
+
}
|
|
73
|
+
return path.join(context.graphRoot, ".state");
|
|
74
|
+
}
|
|
75
|
+
/** Cache lives in `<model state dir>/cache/{sha256}.json` (see `resolveModelStateDir`). */
|
|
76
|
+
export function createModelStep(context, options) {
|
|
77
|
+
return createBatchModelStep({
|
|
78
|
+
graphRoot: context.graphRoot,
|
|
79
|
+
model: resolveModel(context, options.model),
|
|
80
|
+
budget: options.budget,
|
|
81
|
+
...(options.runBudget ? { runBudget: options.runBudget } : {}),
|
|
82
|
+
runner: options.runner ?? createClaudeCliRunner(),
|
|
83
|
+
...(options.dryRun !== undefined ? { dryRun: options.dryRun } : {}),
|
|
84
|
+
...(options.retryParked !== undefined ? { retryParked: options.retryParked } : {}),
|
|
85
|
+
...(options.runId !== undefined ? { runId: options.runId } : {}),
|
|
86
|
+
...(options.now ? { now: options.now } : {}),
|
|
87
|
+
stateDir: resolveModelStateDir(context, options.stateDir),
|
|
88
|
+
...(options.concurrency !== undefined ? { concurrency: options.concurrency } : {}),
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* `sha256(promptVersion + "\n" + kind + "\n" + input)`, hex. With `model`, the
|
|
93
|
+
* model name is part of the key (`promptVersion + "\n" + model + "\n" + kind +
|
|
94
|
+
* "\n" + input`); the step always passes it, so raising the model never reuses
|
|
95
|
+
* a cheaper model's replies.
|
|
96
|
+
*/
|
|
97
|
+
export function modelCacheKey(request) {
|
|
98
|
+
return cacheKeyFor(request);
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import type { IsoDate, SourceRef } from "../types.js";
|
|
2
|
+
import type { BatchSpec } from "./step.js";
|
|
3
|
+
export declare function clipText(text: string, max: number): string;
|
|
4
|
+
/** Lower case, whitespace collapsed, quotes and dashes folded: what a quote is compared on. */
|
|
5
|
+
export declare function squash(text: string): string;
|
|
6
|
+
/** Where a quote sits in a text: 1-based first and last line. Null when the text does not hold it. */
|
|
7
|
+
export declare function locateQuote(text: string, quote: string): {
|
|
8
|
+
from: number;
|
|
9
|
+
to: number;
|
|
10
|
+
} | null;
|
|
11
|
+
export interface DigestItem {
|
|
12
|
+
/** Cited by every row made from the digest. Not sent to the model. */
|
|
13
|
+
src: SourceRef;
|
|
14
|
+
kind: "meeting" | "slack";
|
|
15
|
+
date: IsoDate;
|
|
16
|
+
title: string;
|
|
17
|
+
/** The whole source file, frontmatter included, so quotes map to file lines. */
|
|
18
|
+
fileText: string;
|
|
19
|
+
}
|
|
20
|
+
export interface DigestTopic {
|
|
21
|
+
name: string;
|
|
22
|
+
type: string;
|
|
23
|
+
quote: string;
|
|
24
|
+
}
|
|
25
|
+
export interface DigestDecision {
|
|
26
|
+
text: string;
|
|
27
|
+
by: string;
|
|
28
|
+
topic: string;
|
|
29
|
+
quote: string;
|
|
30
|
+
}
|
|
31
|
+
export interface DigestAction {
|
|
32
|
+
owner: string;
|
|
33
|
+
text: string;
|
|
34
|
+
quote: string;
|
|
35
|
+
}
|
|
36
|
+
export interface DigestPerson {
|
|
37
|
+
name: string;
|
|
38
|
+
employer: string;
|
|
39
|
+
role: string;
|
|
40
|
+
quote: string;
|
|
41
|
+
}
|
|
42
|
+
export interface SourceDigest {
|
|
43
|
+
summary: {
|
|
44
|
+
text: string;
|
|
45
|
+
quote: string;
|
|
46
|
+
} | null;
|
|
47
|
+
topics: DigestTopic[];
|
|
48
|
+
decisions: DigestDecision[];
|
|
49
|
+
actions: DigestAction[];
|
|
50
|
+
people: DigestPerson[];
|
|
51
|
+
/** Entries the model wrote whose quote is not in the source, or that had no text. */
|
|
52
|
+
dropped: number;
|
|
53
|
+
}
|
|
54
|
+
/** Characters of source text sent. A longer source keeps its start and its end, where outcomes are stated. */
|
|
55
|
+
export declare const MAX_DIGEST_CHARS = 90000;
|
|
56
|
+
/**
|
|
57
|
+
* The source as sent: speaker turns as `Name: text`, time stamps and markup
|
|
58
|
+
* removed, consecutive turns of one speaker joined. About a third smaller than
|
|
59
|
+
* the file, and every utterance keeps its words, so quotes still match.
|
|
60
|
+
*/
|
|
61
|
+
export declare function compactSource(fileText: string): string;
|
|
62
|
+
export declare const DIGEST_PROMPT_VERSION = "digest-source.v2";
|
|
63
|
+
export declare function digestSpec(day: IsoDate): BatchSpec<DigestItem, SourceDigest>;
|
|
64
|
+
export interface ProfileLine {
|
|
65
|
+
label: string;
|
|
66
|
+
date: IsoDate;
|
|
67
|
+
text: string;
|
|
68
|
+
}
|
|
69
|
+
export interface ProfileItem {
|
|
70
|
+
/** Graph id. Not sent to the model. */
|
|
71
|
+
ref: string;
|
|
72
|
+
name: string;
|
|
73
|
+
type: "person" | "company";
|
|
74
|
+
lines: ProfileLine[];
|
|
75
|
+
}
|
|
76
|
+
export interface CitedValue {
|
|
77
|
+
value: string;
|
|
78
|
+
/** Label of the line the answer rests on. */
|
|
79
|
+
cite: string;
|
|
80
|
+
quote: string;
|
|
81
|
+
}
|
|
82
|
+
export interface EntityProfile {
|
|
83
|
+
role: CitedValue | null;
|
|
84
|
+
employer: CitedValue | null;
|
|
85
|
+
stage: CitedValue | null;
|
|
86
|
+
contacts: (CitedValue & {
|
|
87
|
+
role: string;
|
|
88
|
+
})[];
|
|
89
|
+
dropped: number;
|
|
90
|
+
}
|
|
91
|
+
export declare const CUSTOMER_STAGES: readonly ["prospect", "evaluating", "onboarding", "active", "at_risk", "churned"];
|
|
92
|
+
export declare const PROFILE_PROMPT_VERSION = "profile-entity.v2";
|
|
93
|
+
export declare function profileSpec(day: IsoDate): BatchSpec<ProfileItem, EntityProfile>;
|
|
94
|
+
export interface RetypeOption {
|
|
95
|
+
/** `a` when the edge reads a -> b, `b` when it reads b -> a. */
|
|
96
|
+
subject: "a" | "b";
|
|
97
|
+
verb: string;
|
|
98
|
+
}
|
|
99
|
+
export interface RetypeItem {
|
|
100
|
+
/** Graph ids and the legacy row. Not sent to the model. */
|
|
101
|
+
a: {
|
|
102
|
+
ref: string;
|
|
103
|
+
name: string;
|
|
104
|
+
type: string;
|
|
105
|
+
};
|
|
106
|
+
b: {
|
|
107
|
+
ref: string;
|
|
108
|
+
name: string;
|
|
109
|
+
type: string;
|
|
110
|
+
};
|
|
111
|
+
rowId: string;
|
|
112
|
+
/** The old free-text label. */
|
|
113
|
+
was: string;
|
|
114
|
+
options: RetypeOption[];
|
|
115
|
+
evidence: {
|
|
116
|
+
src: SourceRef;
|
|
117
|
+
date: IsoDate;
|
|
118
|
+
text: string;
|
|
119
|
+
}[];
|
|
120
|
+
}
|
|
121
|
+
export interface RetypeAnswer {
|
|
122
|
+
/** Index into the item's options, or -1 for none. */
|
|
123
|
+
option: number;
|
|
124
|
+
/** Index into the item's evidence. */
|
|
125
|
+
evidence: number;
|
|
126
|
+
quote: string;
|
|
127
|
+
}
|
|
128
|
+
export declare const RETYPE_PROMPT_VERSION = "retype-edge.v1";
|
|
129
|
+
export declare function retypeSpec(day: IsoDate): BatchSpec<RetypeItem, RetypeAnswer>;
|
|
130
|
+
export interface SupersessionDecision {
|
|
131
|
+
/** Graph id. Not sent to the model. */
|
|
132
|
+
ref: string;
|
|
133
|
+
date: IsoDate;
|
|
134
|
+
text: string;
|
|
135
|
+
}
|
|
136
|
+
export interface SupersessionItem {
|
|
137
|
+
/** Graph id of the topic. Not sent to the model. */
|
|
138
|
+
topicRef: string;
|
|
139
|
+
topic: string;
|
|
140
|
+
/** Oldest first. */
|
|
141
|
+
decisions: SupersessionDecision[];
|
|
142
|
+
}
|
|
143
|
+
export interface SupersessionPair {
|
|
144
|
+
/** Indexes into the item's decisions. `newer` replaces or repeats `older`. */
|
|
145
|
+
newer: number;
|
|
146
|
+
older: number;
|
|
147
|
+
kind: "supersedes" | "duplicate";
|
|
148
|
+
quote: string;
|
|
149
|
+
}
|
|
150
|
+
export interface SupersessionAnswer {
|
|
151
|
+
pairs: SupersessionPair[];
|
|
152
|
+
dropped: number;
|
|
153
|
+
}
|
|
154
|
+
export declare const SUPERSESSION_PROMPT_VERSION = "decision-supersession.v1";
|
|
155
|
+
export declare function supersessionSpec(day: IsoDate): BatchSpec<SupersessionItem, SupersessionAnswer>;
|
|
156
|
+
//# sourceMappingURL=pass-tasks.d.ts.map
|