@indigoai-us/hq-cli 5.345.247 → 5.345.248
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 +54 -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 +1113 -0
- package/dist/command-catalog.generated.js +1370 -0
- package/dist/command-registration-plan.d.ts +6 -0
- package/dist/command-registration-plan.js +1 -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 +62 -0
- package/dist/commands/ontology-graph.js +439 -0
- package/dist/index.js +1 -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/lanes-monitor-state.d.ts +2 -2
- package/dist/lib/daemon/lanes-monitor-state.js +2 -2
- 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.js +1 -1
- package/dist/lib/daemon/state-file.d.ts +1 -1
- package/dist/lib/daemon/state-file.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/hot-channels/graph-context.d.ts +105 -0
- package/dist/lib/hot-channels/graph-context.js +377 -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 +195 -0
- package/dist/lib/ontology-graph/model/step.js +523 -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 +65 -0
- package/dist/lib/ontology-graph/org/derive.js +352 -0
- package/dist/lib/ontology-graph/org/index.d.ts +73 -0
- package/dist/lib/ontology-graph/org/index.js +513 -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 +95 -0
- package/dist/lib/ontology-graph/org/text.js +315 -0
- package/dist/lib/ontology-graph/org/types.d.ts +452 -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 +142 -0
- package/dist/lib/ontology-graph/pages/render.js +682 -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 +251 -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 +792 -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 +44 -0
- package/dist/lib/ontology-graph/read/names.js +292 -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 +100 -0
- package/dist/lib/ontology-graph/replay/engine.js +1174 -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 +90 -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 +73 -0
- package/dist/lib/ontology-graph/schema/authority.js +157 -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 +1183 -0
- package/dist/lib/ontology-graph/types.js +131 -0
- package/dist/lib/secret-scan/gitleaks-rules.generated.js +1 -1
- package/dist/utils/frontmatter.d.ts +14 -0
- package/dist/utils/frontmatter.js +18 -0
- package/dist/utils/interactive-caller.js +1 -1
- package/package.json +8 -8
|
@@ -0,0 +1,523 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
2
|
+
import { MODEL_STATE_PATHS, appendJsonLineSync, estimateTokens, readJsonLinesSync, readTextIfPresent, sha256Hex, stableStringify, statePath, writeFileAtomicSync, } from "./files.js";
|
|
3
|
+
import { ModelRunnerError } from "./runner.js";
|
|
4
|
+
/** Tokens a `claude -p` turn adds on top of our prompt and input (system prompt). Measured at about 3,000. */
|
|
5
|
+
export const CLI_OVERHEAD_TOKENS = 3_000;
|
|
6
|
+
const DEFAULT_MAX_ITEMS = 20;
|
|
7
|
+
const DEFAULT_MAX_INPUT_BYTES = 48_000;
|
|
8
|
+
/** Timeouts or provider errors in a row after which calls stop for the run. */
|
|
9
|
+
const ERRORS_BEFORE_HALT = 3;
|
|
10
|
+
const RETRY_NOTE = "\n\nYour previous reply could not be used. Reply with the one JSON object described above and nothing else.";
|
|
11
|
+
/**
|
|
12
|
+
* `sha256(promptVersion + "\n" + model + "\n" + kind + "\n" + input)`, hex.
|
|
13
|
+
* Without a model it is the contract's original form
|
|
14
|
+
* `sha256(promptVersion + "\n" + kind + "\n" + input)`.
|
|
15
|
+
*/
|
|
16
|
+
export function cacheKeyFor(parts) {
|
|
17
|
+
const head = parts.model === undefined ? parts.promptVersion : `${parts.promptVersion}\n${parts.model}`;
|
|
18
|
+
return sha256Hex(`${head}\n${parts.kind}\n${parts.input}`);
|
|
19
|
+
}
|
|
20
|
+
/** The reply as one JSON object, or null. One code fence around the object is tolerated; prose is not. */
|
|
21
|
+
export function parseStrictJsonObject(reply) {
|
|
22
|
+
let text = reply.trim();
|
|
23
|
+
const fenced = /^```(?:json)?\s*\n([\s\S]*?)\n```$/.exec(text);
|
|
24
|
+
if (fenced)
|
|
25
|
+
text = fenced[1].trim();
|
|
26
|
+
if (!text.startsWith("{") || !text.endsWith("}"))
|
|
27
|
+
return null;
|
|
28
|
+
try {
|
|
29
|
+
const parsed = JSON.parse(text);
|
|
30
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function zero() {
|
|
37
|
+
return { inputTokens: 0, outputTokens: 0 };
|
|
38
|
+
}
|
|
39
|
+
function add(into, usage) {
|
|
40
|
+
into.inputTokens += usage.inputTokens;
|
|
41
|
+
into.outputTokens += usage.outputTokens;
|
|
42
|
+
}
|
|
43
|
+
export function createBatchModelStep(config) {
|
|
44
|
+
const now = config.now ?? (() => new Date());
|
|
45
|
+
const runId = config.runId ?? `model-${now().toISOString().replace(/[-:.]/g, "").slice(0, 15)}Z-${process.pid}`;
|
|
46
|
+
const at = (relative) => config.stateDir ? path.join(config.stateDir, ...relative.replace(/^\.state\//, "").split("/")) : statePath(config.graphRoot, relative);
|
|
47
|
+
const cacheDir = at(MODEL_STATE_PATHS.cache);
|
|
48
|
+
const ledgerFile = at(MODEL_STATE_PATHS.callLedger);
|
|
49
|
+
const pendingFile = at(MODEL_STATE_PATHS.pending);
|
|
50
|
+
const parkedFile = at(MODEL_STATE_PATHS.parked);
|
|
51
|
+
const concurrency = Math.max(1, Math.floor(config.concurrency ?? 1));
|
|
52
|
+
// Per-day use, seeded from the ledger so the day cap holds across runs. The cap is per model: a
|
|
53
|
+
// step on a stronger model for two small tasks is not refused because the cheap model's day is spent.
|
|
54
|
+
const dayUsed = new Map();
|
|
55
|
+
for (const line of readJsonLinesSync(ledgerFile)) {
|
|
56
|
+
if (line.type !== "call" || typeof line.day !== "string")
|
|
57
|
+
continue;
|
|
58
|
+
if (typeof line.model === "string" && line.model !== config.model)
|
|
59
|
+
continue;
|
|
60
|
+
const used = dayUsed.get(line.day) ?? zero();
|
|
61
|
+
add(used, { inputTokens: Number(line.inputTokens) || 0, outputTokens: Number(line.outputTokens) || 0 });
|
|
62
|
+
dayUsed.set(line.day, used);
|
|
63
|
+
}
|
|
64
|
+
const pendingMarkers = new Map();
|
|
65
|
+
const pendingText = readTextIfPresent(pendingFile);
|
|
66
|
+
if (pendingText !== null) {
|
|
67
|
+
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);
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
// An unreadable marker file loses nothing: callers submit their items again.
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
let pendingDirty = false;
|
|
78
|
+
const savePending = () => {
|
|
79
|
+
if (!pendingDirty)
|
|
80
|
+
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`);
|
|
83
|
+
pendingDirty = false;
|
|
84
|
+
};
|
|
85
|
+
const parkedRecords = new Map();
|
|
86
|
+
for (const record of readJsonLinesSync(parkedFile)) {
|
|
87
|
+
if (record && typeof record.key === "string")
|
|
88
|
+
parkedRecords.set(record.key, record);
|
|
89
|
+
}
|
|
90
|
+
let window = {
|
|
91
|
+
calls: 0, cacheHits: 0, pending: 0, errors: 0, used: zero(),
|
|
92
|
+
};
|
|
93
|
+
const total = { calls: 0, cacheHits: 0, pending: 0, parked: 0, errors: 0, used: zero(), estimatedCalls: 0, wallMs: 0, sent: 0 };
|
|
94
|
+
let haltReason = null;
|
|
95
|
+
let budgetStopped = false;
|
|
96
|
+
let errorsInARow = 0;
|
|
97
|
+
const readCache = (key) => {
|
|
98
|
+
const text = readTextIfPresent(`${cacheDir}/${key}.json`);
|
|
99
|
+
if (text === null)
|
|
100
|
+
return null;
|
|
101
|
+
try {
|
|
102
|
+
const parsed = JSON.parse(text);
|
|
103
|
+
return typeof parsed.output === "string" ? parsed.output : null;
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const writeCache = (key, kind, promptVersion, output) => {
|
|
110
|
+
const file = { v: 1, key, kind, promptVersion, model: config.model, at: now().toISOString(), output };
|
|
111
|
+
writeFileAtomicSync(`${cacheDir}/${key}.json`, `${JSON.stringify(file)}\n`);
|
|
112
|
+
};
|
|
113
|
+
const clearPending = (key) => {
|
|
114
|
+
if (pendingMarkers.delete(key))
|
|
115
|
+
pendingDirty = true;
|
|
116
|
+
};
|
|
117
|
+
const markPending = (marker) => {
|
|
118
|
+
const existing = pendingMarkers.get(marker.key);
|
|
119
|
+
pendingMarkers.set(marker.key, { ...marker, at: existing?.at ?? now().toISOString() });
|
|
120
|
+
pendingDirty = true;
|
|
121
|
+
window.pending += 1;
|
|
122
|
+
total.pending += 1;
|
|
123
|
+
};
|
|
124
|
+
const park = (record) => {
|
|
125
|
+
const full = { ...record, at: now().toISOString() };
|
|
126
|
+
parkedRecords.set(record.key, full);
|
|
127
|
+
appendJsonLineSync(parkedFile, full);
|
|
128
|
+
total.parked += 1;
|
|
129
|
+
clearPending(record.key);
|
|
130
|
+
};
|
|
131
|
+
// Once a cap refuses a call, calls stay stopped for that day (or the run), so
|
|
132
|
+
// a smaller batch later in the same day does not slip past the cap.
|
|
133
|
+
const stoppedDays = new Set();
|
|
134
|
+
let runStopped = false;
|
|
135
|
+
/** Null when the call fits; otherwise why it does not. */
|
|
136
|
+
const refusal = (day, estimateIn) => {
|
|
137
|
+
if (config.dryRun)
|
|
138
|
+
return "dry-run";
|
|
139
|
+
if (haltReason)
|
|
140
|
+
return haltReason;
|
|
141
|
+
if (runStopped)
|
|
142
|
+
return "budget-run";
|
|
143
|
+
if (stoppedDays.has(day))
|
|
144
|
+
return "budget-day";
|
|
145
|
+
const used = dayUsed.get(day) ?? zero();
|
|
146
|
+
if (used.inputTokens + estimateIn > config.budget.inputTokens || used.outputTokens >= config.budget.outputTokens) {
|
|
147
|
+
stoppedDays.add(day);
|
|
148
|
+
budgetStopped = true;
|
|
149
|
+
return "budget-day";
|
|
150
|
+
}
|
|
151
|
+
if (config.runBudget && (total.used.inputTokens + estimateIn > config.runBudget.inputTokens || total.used.outputTokens >= config.runBudget.outputTokens)) {
|
|
152
|
+
runStopped = true;
|
|
153
|
+
return "budget-run";
|
|
154
|
+
}
|
|
155
|
+
return null;
|
|
156
|
+
};
|
|
157
|
+
/** One turn. Charges the budget and writes the ledger line; never throws. */
|
|
158
|
+
const call = async (spec, prompt, input, items, attempt, judge, maxOutputTokens) => {
|
|
159
|
+
const started = Date.now();
|
|
160
|
+
let outcome;
|
|
161
|
+
let usage;
|
|
162
|
+
let output;
|
|
163
|
+
let failure;
|
|
164
|
+
try {
|
|
165
|
+
const reply = await config.runner({ model: config.model, prompt, input, ...(maxOutputTokens !== undefined ? { maxOutputTokens } : {}) });
|
|
166
|
+
output = reply.output;
|
|
167
|
+
usage = reply.usage;
|
|
168
|
+
if (!Number.isFinite(usage.inputTokens) || !Number.isFinite(usage.outputTokens) || usage.inputTokens + usage.outputTokens <= 0) {
|
|
169
|
+
usage = { inputTokens: estimateTokens(`${prompt}\n${input}`), outputTokens: estimateTokens(output), estimated: true };
|
|
170
|
+
}
|
|
171
|
+
outcome = judge(output);
|
|
172
|
+
errorsInARow = 0;
|
|
173
|
+
}
|
|
174
|
+
catch (err) {
|
|
175
|
+
failure = err instanceof ModelRunnerError ? err.failure : "provider-error";
|
|
176
|
+
outcome = `error:${failure}`;
|
|
177
|
+
// A timeout or provider error may have used tokens: charge an estimate of
|
|
178
|
+
// the request. A sign-out or a usage limit is refused before any are used.
|
|
179
|
+
usage =
|
|
180
|
+
failure === "logged-out" || failure === "usage-limit"
|
|
181
|
+
? { inputTokens: 0, outputTokens: 0, estimated: true }
|
|
182
|
+
: { inputTokens: estimateTokens(`${prompt}\n${input}`), outputTokens: 0, estimated: true };
|
|
183
|
+
window.errors += 1;
|
|
184
|
+
total.errors += 1;
|
|
185
|
+
errorsInARow += 1;
|
|
186
|
+
if (failure === "usage-limit" || failure === "logged-out" || errorsInARow >= ERRORS_BEFORE_HALT)
|
|
187
|
+
haltReason = failure;
|
|
188
|
+
}
|
|
189
|
+
const ms = Date.now() - started;
|
|
190
|
+
window.calls += 1;
|
|
191
|
+
total.calls += 1;
|
|
192
|
+
total.wallMs += ms;
|
|
193
|
+
if (usage.estimated)
|
|
194
|
+
total.estimatedCalls += 1;
|
|
195
|
+
add(window.used, usage);
|
|
196
|
+
add(total.used, usage);
|
|
197
|
+
const used = dayUsed.get(spec.day) ?? zero();
|
|
198
|
+
add(used, usage);
|
|
199
|
+
dayUsed.set(spec.day, used);
|
|
200
|
+
const line = {
|
|
201
|
+
type: "call",
|
|
202
|
+
at: now().toISOString(),
|
|
203
|
+
run: runId,
|
|
204
|
+
day: spec.day,
|
|
205
|
+
kind: spec.kind,
|
|
206
|
+
model: config.model,
|
|
207
|
+
promptVersion: spec.promptVersion,
|
|
208
|
+
items,
|
|
209
|
+
attempt,
|
|
210
|
+
outcome,
|
|
211
|
+
inputTokens: usage.inputTokens,
|
|
212
|
+
outputTokens: usage.outputTokens,
|
|
213
|
+
estimated: usage.estimated === true,
|
|
214
|
+
...(usage.cacheReadTokens !== undefined ? { cacheReadTokens: usage.cacheReadTokens } : {}),
|
|
215
|
+
...(usage.cacheCreationTokens !== undefined ? { cacheCreationTokens: usage.cacheCreationTokens } : {}),
|
|
216
|
+
...(usage.thinkingTokens !== undefined ? { thinkingTokens: usage.thinkingTokens } : {}),
|
|
217
|
+
...(usage.costUsd !== undefined ? { costUsd: usage.costUsd } : {}),
|
|
218
|
+
...(usage.servedBy !== undefined ? { servedBy: usage.servedBy } : {}),
|
|
219
|
+
promptBytes: Buffer.byteLength(prompt, "utf8"),
|
|
220
|
+
inputBytes: Buffer.byteLength(input, "utf8"),
|
|
221
|
+
outputBytes: output === undefined ? 0 : Buffer.byteLength(output, "utf8"),
|
|
222
|
+
ms,
|
|
223
|
+
};
|
|
224
|
+
appendJsonLineSync(ledgerFile, line);
|
|
225
|
+
return { ...(output !== undefined ? { output } : {}), usage, ...(failure ? { failure } : {}) };
|
|
226
|
+
};
|
|
227
|
+
const stats = () => ({
|
|
228
|
+
calls: window.calls,
|
|
229
|
+
cacheHits: window.cacheHits,
|
|
230
|
+
pending: window.pending,
|
|
231
|
+
errors: window.errors,
|
|
232
|
+
used: { ...window.used },
|
|
233
|
+
budget: { ...config.budget },
|
|
234
|
+
exhausted: budgetStopped || runStopped || haltReason !== null,
|
|
235
|
+
});
|
|
236
|
+
const run = async (request) => {
|
|
237
|
+
const cacheKey = cacheKeyFor({ promptVersion: request.promptVersion, kind: request.kind, input: request.input, model: config.model });
|
|
238
|
+
const cached = readCache(cacheKey);
|
|
239
|
+
if (cached !== null) {
|
|
240
|
+
window.cacheHits += 1;
|
|
241
|
+
total.cacheHits += 1;
|
|
242
|
+
clearPending(cacheKey);
|
|
243
|
+
savePending();
|
|
244
|
+
return { status: "cached", cacheKey, output: cached, usage: zero() };
|
|
245
|
+
}
|
|
246
|
+
const estimateIn = estimateTokens(`${request.prompt}\n${request.input}`) + CLI_OVERHEAD_TOKENS;
|
|
247
|
+
const refused = refusal(request.day, estimateIn);
|
|
248
|
+
if (refused) {
|
|
249
|
+
markPending({
|
|
250
|
+
key: cacheKey, kind: request.kind, itemKey: cacheKey.slice(0, 12), day: request.day, reason: refused,
|
|
251
|
+
promptVersion: request.promptVersion, payload: { input: request.input },
|
|
252
|
+
});
|
|
253
|
+
savePending();
|
|
254
|
+
return { status: "pending", cacheKey, usage: zero() };
|
|
255
|
+
}
|
|
256
|
+
total.sent += 1;
|
|
257
|
+
const outcome = await call(request, request.prompt, request.input, 1, 1, () => "ok", request.maxOutputTokens);
|
|
258
|
+
if (outcome.failure || outcome.output === undefined) {
|
|
259
|
+
markPending({
|
|
260
|
+
key: cacheKey, kind: request.kind, itemKey: cacheKey.slice(0, 12), day: request.day, reason: outcome.failure ?? "provider-error",
|
|
261
|
+
promptVersion: request.promptVersion, payload: { input: request.input },
|
|
262
|
+
});
|
|
263
|
+
savePending();
|
|
264
|
+
return { status: "error", cacheKey, usage: { inputTokens: outcome.usage.inputTokens, outputTokens: outcome.usage.outputTokens }, error: outcome.failure ?? "provider-error" };
|
|
265
|
+
}
|
|
266
|
+
writeCache(cacheKey, request.kind, request.promptVersion, outcome.output);
|
|
267
|
+
clearPending(cacheKey);
|
|
268
|
+
savePending();
|
|
269
|
+
return { status: "ok", cacheKey, output: outcome.output, usage: { inputTokens: outcome.usage.inputTokens, outputTokens: outcome.usage.outputTokens } };
|
|
270
|
+
};
|
|
271
|
+
const runBatch = async (spec, items) => {
|
|
272
|
+
const started = Date.now();
|
|
273
|
+
const results = new Array(items.length);
|
|
274
|
+
const batchStats = { items: items.length, cacheHits: 0, calls: 0, ok: 0, pending: 0, parked: 0, usage: zero(), estimated: false, seconds: 0 };
|
|
275
|
+
const toSend = [];
|
|
276
|
+
const seen = new Map();
|
|
277
|
+
const duplicates = [];
|
|
278
|
+
items.forEach((item, index) => {
|
|
279
|
+
const input = stableStringify(spec.renderItem(item));
|
|
280
|
+
const cacheKey = cacheKeyFor({ promptVersion: spec.promptVersion, kind: spec.kind, input, model: config.model });
|
|
281
|
+
const itemKey = spec.itemKey(item);
|
|
282
|
+
const first = seen.get(cacheKey);
|
|
283
|
+
if (first !== undefined) {
|
|
284
|
+
duplicates.push({ index, of: first });
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
seen.set(cacheKey, index);
|
|
288
|
+
const cached = readCache(cacheKey);
|
|
289
|
+
if (cached !== null) {
|
|
290
|
+
try {
|
|
291
|
+
results[index] = { item, itemKey, cacheKey, status: "cached", value: JSON.parse(cached), usage: zero() };
|
|
292
|
+
window.cacheHits += 1;
|
|
293
|
+
total.cacheHits += 1;
|
|
294
|
+
batchStats.cacheHits += 1;
|
|
295
|
+
clearPending(cacheKey);
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
catch {
|
|
299
|
+
// A damaged cache file is a miss.
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
const parkedRecord = parkedRecords.get(cacheKey);
|
|
303
|
+
if (parkedRecord && !config.retryParked) {
|
|
304
|
+
results[index] = { item, itemKey, cacheKey, status: "parked", reason: parkedRecord.reason, usage: zero() };
|
|
305
|
+
batchStats.parked += 1;
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
toSend.push({ item, itemKey, cacheKey, input, bytes: Buffer.byteLength(input, "utf8"), index });
|
|
309
|
+
});
|
|
310
|
+
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 });
|
|
312
|
+
results[entry.index] = { item: entry.item, itemKey: entry.itemKey, cacheKey: entry.cacheKey, status: "pending", reason, usage };
|
|
313
|
+
batchStats.pending += 1;
|
|
314
|
+
};
|
|
315
|
+
const setParked = (entry, reason, attempts, usage) => {
|
|
316
|
+
park({ key: entry.cacheKey, kind: spec.kind, itemKey: entry.itemKey, day: spec.day, reason, attempts });
|
|
317
|
+
results[entry.index] = { item: entry.item, itemKey: entry.itemKey, cacheKey: entry.cacheKey, status: "parked", reason, usage };
|
|
318
|
+
batchStats.parked += 1;
|
|
319
|
+
};
|
|
320
|
+
const maxItems = Math.max(1, spec.maxItems ?? DEFAULT_MAX_ITEMS);
|
|
321
|
+
const maxBytes = Math.max(1, spec.maxInputBytes ?? DEFAULT_MAX_INPUT_BYTES);
|
|
322
|
+
const chunks = [];
|
|
323
|
+
let current = [];
|
|
324
|
+
let currentBytes = 0;
|
|
325
|
+
for (const entry of toSend) {
|
|
326
|
+
if (current.length > 0 && (current.length >= maxItems || currentBytes + entry.bytes > maxBytes)) {
|
|
327
|
+
chunks.push(current);
|
|
328
|
+
current = [];
|
|
329
|
+
currentBytes = 0;
|
|
330
|
+
}
|
|
331
|
+
current.push(entry);
|
|
332
|
+
currentBytes += entry.bytes;
|
|
333
|
+
}
|
|
334
|
+
if (current.length > 0)
|
|
335
|
+
chunks.push(current);
|
|
336
|
+
/** Sends one turn. Returns each entry's parsed answer (or a reason), and what the turn cost per entry. */
|
|
337
|
+
const sendTurn = async (entries, attempt, prompt) => {
|
|
338
|
+
const input = `{"items":[${entries.map((entry, i) => `{"id":"i${i + 1}","data":${entry.input}}`).join(",")}]}`;
|
|
339
|
+
const refused = refusal(spec.day, estimateTokens(`${prompt}\n${input}`) + CLI_OVERHEAD_TOKENS);
|
|
340
|
+
if (refused)
|
|
341
|
+
return { refused };
|
|
342
|
+
const answers = new Map();
|
|
343
|
+
const state = { parsed: false };
|
|
344
|
+
const judge = (output) => {
|
|
345
|
+
const object = parseStrictJsonObject(output);
|
|
346
|
+
const list = object && Array.isArray(object.results) ? object.results : null;
|
|
347
|
+
if (!list)
|
|
348
|
+
return "bad-json";
|
|
349
|
+
state.parsed = true;
|
|
350
|
+
const byId = new Map();
|
|
351
|
+
for (const raw of list) {
|
|
352
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
353
|
+
continue;
|
|
354
|
+
const id = raw.id;
|
|
355
|
+
if (typeof id === "string" && !byId.has(id))
|
|
356
|
+
byId.set(id, raw);
|
|
357
|
+
}
|
|
358
|
+
let good = 0;
|
|
359
|
+
entries.forEach((entry, i) => {
|
|
360
|
+
const raw = byId.get(`i${i + 1}`);
|
|
361
|
+
if (!raw) {
|
|
362
|
+
answers.set(entry.index, { ok: false, reason: "no answer for the item" });
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
let verdict;
|
|
366
|
+
try {
|
|
367
|
+
verdict = spec.validate(entry.item, raw);
|
|
368
|
+
}
|
|
369
|
+
catch (err) {
|
|
370
|
+
verdict = { ok: false, reason: `validator threw: ${err instanceof Error ? err.message : String(err)}` };
|
|
371
|
+
}
|
|
372
|
+
answers.set(entry.index, verdict);
|
|
373
|
+
if (verdict.ok)
|
|
374
|
+
good += 1;
|
|
375
|
+
});
|
|
376
|
+
return good === entries.length ? "ok" : "partial";
|
|
377
|
+
};
|
|
378
|
+
total.sent += entries.length;
|
|
379
|
+
const outcome = await call(spec, prompt, input, entries.length, attempt, judge);
|
|
380
|
+
batchStats.calls += 1;
|
|
381
|
+
add(batchStats.usage, outcome.usage);
|
|
382
|
+
if (outcome.usage.estimated)
|
|
383
|
+
batchStats.estimated = true;
|
|
384
|
+
const totalBytes = entries.reduce((sum, entry) => sum + entry.bytes, 0) || 1;
|
|
385
|
+
const share = new Map();
|
|
386
|
+
for (const entry of entries) {
|
|
387
|
+
share.set(entry.index, {
|
|
388
|
+
inputTokens: (outcome.usage.inputTokens * entry.bytes) / totalBytes,
|
|
389
|
+
outputTokens: (outcome.usage.outputTokens * entry.bytes) / totalBytes,
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
if (outcome.failure)
|
|
393
|
+
return { failure: outcome.failure, share };
|
|
394
|
+
if (!state.parsed)
|
|
395
|
+
return { badJson: true, share };
|
|
396
|
+
return { answers, share };
|
|
397
|
+
};
|
|
398
|
+
const processChunk = async (chunk) => {
|
|
399
|
+
const spent = new Map(chunk.map((entry) => [entry.index, zero()]));
|
|
400
|
+
const charge = (share) => {
|
|
401
|
+
for (const [index, usage] of share)
|
|
402
|
+
add(spent.get(index) ?? zero(), usage);
|
|
403
|
+
};
|
|
404
|
+
const accept = (entry, value) => {
|
|
405
|
+
writeCache(entry.cacheKey, spec.kind, spec.promptVersion, JSON.stringify(value));
|
|
406
|
+
clearPending(entry.cacheKey);
|
|
407
|
+
results[entry.index] = { item: entry.item, itemKey: entry.itemKey, cacheKey: entry.cacheKey, status: "ok", value, usage: spent.get(entry.index) ?? zero() };
|
|
408
|
+
batchStats.ok += 1;
|
|
409
|
+
};
|
|
410
|
+
const first = await sendTurn(chunk, 1, spec.prompt);
|
|
411
|
+
if ("refused" in first) {
|
|
412
|
+
for (const entry of chunk)
|
|
413
|
+
setPending(entry, first.refused, zero());
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
charge(first.share);
|
|
417
|
+
if ("failure" in first) {
|
|
418
|
+
for (const entry of chunk)
|
|
419
|
+
setPending(entry, first.failure, spent.get(entry.index) ?? zero());
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
let retry;
|
|
423
|
+
const reasons = new Map();
|
|
424
|
+
if ("badJson" in first) {
|
|
425
|
+
retry = [...chunk];
|
|
426
|
+
for (const entry of chunk)
|
|
427
|
+
reasons.set(entry.index, "the reply was not a JSON object");
|
|
428
|
+
}
|
|
429
|
+
else {
|
|
430
|
+
retry = [];
|
|
431
|
+
for (const entry of chunk) {
|
|
432
|
+
const answer = first.answers.get(entry.index);
|
|
433
|
+
if (answer?.ok)
|
|
434
|
+
accept(entry, answer.value);
|
|
435
|
+
else {
|
|
436
|
+
retry.push(entry);
|
|
437
|
+
reasons.set(entry.index, answer?.reason ?? "no answer for the item");
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
if (retry.length === 0)
|
|
442
|
+
return;
|
|
443
|
+
const second = await sendTurn(retry, 2, `${spec.prompt}${RETRY_NOTE}`);
|
|
444
|
+
if ("refused" in second) {
|
|
445
|
+
for (const entry of retry)
|
|
446
|
+
setPending(entry, second.refused, spent.get(entry.index) ?? zero());
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
charge(second.share);
|
|
450
|
+
if ("failure" in second) {
|
|
451
|
+
for (const entry of retry)
|
|
452
|
+
setPending(entry, second.failure, spent.get(entry.index) ?? zero());
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
for (const entry of retry) {
|
|
456
|
+
const answer = "badJson" in second ? undefined : second.answers.get(entry.index);
|
|
457
|
+
if (answer?.ok)
|
|
458
|
+
accept(entry, answer.value);
|
|
459
|
+
else {
|
|
460
|
+
const reason = "badJson" in second ? "the reply was not a JSON object, twice" : (answer?.reason ?? reasons.get(entry.index) ?? "invalid answer");
|
|
461
|
+
setParked(entry, reason, 2, spent.get(entry.index) ?? zero());
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
// A small pool: `concurrency` turns in flight. State changes happen between awaits, on one thread.
|
|
466
|
+
let nextChunk = 0;
|
|
467
|
+
const worker = async () => {
|
|
468
|
+
while (nextChunk < chunks.length) {
|
|
469
|
+
const chunk = chunks[nextChunk];
|
|
470
|
+
nextChunk += 1;
|
|
471
|
+
await processChunk(chunk);
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
await Promise.all(Array.from({ length: Math.min(concurrency, chunks.length) }, () => worker()));
|
|
475
|
+
for (const duplicate of duplicates) {
|
|
476
|
+
const original = results[duplicate.of];
|
|
477
|
+
results[duplicate.index] = { ...original, item: items[duplicate.index], usage: zero() };
|
|
478
|
+
}
|
|
479
|
+
savePending();
|
|
480
|
+
batchStats.seconds = (Date.now() - started) / 1000;
|
|
481
|
+
return { results, stats: batchStats };
|
|
482
|
+
};
|
|
483
|
+
return {
|
|
484
|
+
model: config.model,
|
|
485
|
+
runId,
|
|
486
|
+
run,
|
|
487
|
+
runBatch,
|
|
488
|
+
stats,
|
|
489
|
+
resetDay(_day) {
|
|
490
|
+
const closed = stats();
|
|
491
|
+
window = { calls: 0, cacheHits: 0, pending: 0, errors: 0, used: zero() };
|
|
492
|
+
// A new day has its own cap. A run cap, a usage limit or a sign-out still holds.
|
|
493
|
+
budgetStopped = false;
|
|
494
|
+
return closed;
|
|
495
|
+
},
|
|
496
|
+
pending(kind) {
|
|
497
|
+
const all = [...pendingMarkers.values()].sort((a, b) => (a.at !== b.at ? (a.at < b.at ? -1 : 1) : a.key < b.key ? -1 : 1));
|
|
498
|
+
return kind ? all.filter((marker) => marker.kind === kind) : all;
|
|
499
|
+
},
|
|
500
|
+
parked(kind) {
|
|
501
|
+
const all = [...parkedRecords.values()];
|
|
502
|
+
return kind ? all.filter((record) => record.kind === kind) : all;
|
|
503
|
+
},
|
|
504
|
+
totals() {
|
|
505
|
+
const asked = total.cacheHits + total.sent;
|
|
506
|
+
return {
|
|
507
|
+
calls: total.calls,
|
|
508
|
+
cacheHits: total.cacheHits,
|
|
509
|
+
pending: total.pending,
|
|
510
|
+
parked: total.parked,
|
|
511
|
+
errors: total.errors,
|
|
512
|
+
used: { ...total.used },
|
|
513
|
+
estimatedCalls: total.estimatedCalls,
|
|
514
|
+
wallMs: total.wallMs,
|
|
515
|
+
cacheHitRate: asked === 0 ? 1 : total.cacheHits / asked,
|
|
516
|
+
};
|
|
517
|
+
},
|
|
518
|
+
halted() {
|
|
519
|
+
return haltReason;
|
|
520
|
+
},
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
//# sourceMappingURL=step.js.map
|