@astrosheep/keiyaku 4.6.33 → 4.6.34
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/README.md +10 -1
- package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +5 -2
- package/build/plugins/claude/skills/keiyaku-debt/SKILL.md +2 -1
- package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +5 -2
- package/build/plugins/codex/skills/keiyaku-debt/SKILL.md +2 -1
- package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +5 -2
- package/build/plugins/opencode/skills/keiyaku-debt/SKILL.md +2 -1
- package/build/plugins/pi/keiyaku.ts +1 -135
- package/build/skills/keiyaku-akuma/SKILL.md +5 -2
- package/build/skills/keiyaku-debt/SKILL.md +2 -1
- package/build/src/akuma/akuma-observe.d.ts +8 -0
- package/build/src/akuma/akuma-observe.js +8 -0
- package/build/src/akuma/akuma-owner.d.ts +1 -0
- package/build/src/akuma/akuma-owner.js +3 -5
- package/build/src/akuma/akuma-wait.d.ts +117 -2
- package/build/src/akuma/akuma-wait.js +53 -22
- package/build/src/akuma/akuma.d.ts +6 -1
- package/build/src/akuma/akuma.js +37 -18
- package/build/src/akuma/heart/facts.d.ts +1 -0
- package/build/src/akuma/heart/facts.js +14 -0
- package/build/src/akuma/heart/index.d.ts +6 -0
- package/build/src/akuma/heart/index.js +27 -9
- package/build/src/akuma/heart/rows.d.ts +1 -0
- package/build/src/akuma/heart/rows.js +4 -0
- package/build/src/akuma/lineage-cache.d.ts +7 -2
- package/build/src/akuma/lineage-cache.js +48 -24
- package/build/src/akuma/projection-read.js +4 -9
- package/build/src/akuma/selection-observation.d.ts +622 -0
- package/build/src/akuma/selection-observation.js +7 -3
- package/build/src/bounded-list.d.ts +8 -0
- package/build/src/bounded-list.js +10 -0
- package/build/src/cli/commands/akuma-grammar.d.ts +2 -3
- package/build/src/cli/commands/akuma-grammar.js +32 -39
- package/build/src/cli/commands/akuma.js +6 -3
- package/build/src/cli/commands/contract-grammar.js +32 -31
- package/build/src/cli/commands/contract-help.d.ts +3 -3
- package/build/src/cli/commands/contract-help.js +10 -8
- package/build/src/cli/commands/contract.d.ts +3 -3
- package/build/src/cli/commands/contract.js +11 -10
- package/build/src/cli/parse.d.ts +4 -10
- package/build/src/cli/parse.js +1 -1
- package/build/src/cli/render/akuma-activity.d.ts +9 -19
- package/build/src/cli/render/akuma-activity.js +83 -110
- package/build/src/cli/render/catalog.js +3 -2
- package/build/src/cli/render/contract-history.d.ts +1 -3
- package/build/src/cli/render/contract-history.js +68 -49
- package/build/src/cli/render/contract-wait.js +9 -1
- package/build/src/cli/render/kanshi-akuma.d.ts +4 -3
- package/build/src/cli/render/kanshi-akuma.js +26 -21
- package/build/src/cli/render/kanshi.js +34 -43
- package/build/src/cli/render/verbs.js +20 -17
- package/build/src/cli/runtime.js +9 -23
- package/build/src/debt/board.d.ts +2 -1
- package/build/src/debt/board.js +3 -3
- package/build/src/debt/catalog.js +2 -1
- package/build/src/debt/document.d.ts +1 -0
- package/build/src/debt/document.js +3 -0
- package/build/src/debt/index.d.ts +2 -1
- package/build/src/debt/index.js +3 -3
- package/build/src/debt/operations.d.ts +2 -1
- package/build/src/git/observe.d.ts +4 -3
- package/build/src/git/observe.js +8 -7
- package/build/src/history.d.ts +26 -0
- package/build/src/history.js +43 -0
- package/build/src/index.d.ts +4 -3
- package/build/src/kanshi/counts.d.ts +15 -1
- package/build/src/kanshi/counts.js +14 -3
- package/build/src/kanshi/index.d.ts +3 -3
- package/build/src/kanshi/index.js +2 -2
- package/build/src/kanshi/read.js +5 -2
- package/build/src/library/akumas.d.ts +5 -1
- package/build/src/library/akumas.js +11 -5
- package/build/src/library/contract-composition.js +10 -10
- package/build/src/library/contract-creation.js +2 -2
- package/build/src/library/contract-types.d.ts +215 -25
- package/build/src/library/contract-types.js +31 -13
- package/build/src/library/contract-wait.d.ts +205 -0
- package/build/src/library/contract-wait.js +15 -3
- package/build/src/library/input.d.ts +3 -3
- package/build/src/library/input.js +5 -5
- package/build/src/library/kei.js +134 -76
- package/build/src/library/keiyaku-attribution.d.ts +1 -1
- package/build/src/library/keiyaku-attribution.js +3 -1
- package/build/src/library/keiyaku-classify.js +5 -1
- package/build/src/library/keiyaku-debt.d.ts +8 -7
- package/build/src/library/keiyaku-identity.d.ts +4 -3
- package/build/src/library/keiyaku-identity.js +30 -7
- package/build/src/library/keiyaku-verbs.d.ts +515 -44
- package/build/src/library/keiyaku-verbs.js +84 -79
- package/build/src/library/keiyaku-wait.d.ts +570 -0
- package/build/src/library/keiyaku-wait.js +25 -8
- package/build/src/library/keiyaku.d.ts +3110 -31
- package/build/src/library/keiyaku.js +335 -407
- package/build/src/library/model-tools.d.ts +268 -70
- package/build/src/library/model-tools.js +110 -95
- package/build/src/library/selection.d.ts +6 -5
- package/build/src/library/selection.js +10 -3
- package/build/src/mcp/adapter.js +1 -1
- package/build/src/mcp/help.d.ts +1 -1
- package/build/src/mcp/help.js +4 -3
- package/build/src/pi/index.d.ts +2 -0
- package/build/src/pi/index.js +23 -7
- package/build/src/pi/status.d.ts +12 -0
- package/build/src/pi/status.js +140 -0
- package/build/src/protocol/operations.d.ts +2 -0
- package/build/src/protocol/operations.js +1 -1
- package/build/src/protocol/read/status.d.ts +12 -4
- package/build/src/protocol/read/status.js +19 -12
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/package.json +1 -1
- package/plugins/paseo/plugin/index.server.ts +6 -2
- package/plugins/paseo/plugin/server/attach.ts +68 -48
- package/plugins/paseo/plugin/server/directory.ts +259 -0
- package/plugins/paseo/plugin/server/mirror-identity.ts +3 -32
- package/plugins/paseo/plugin/server/reopen.ts +52 -38
- package/plugins/pi/keiyaku.ts +1 -135
- package/skills/keiyaku-akuma/SKILL.md +5 -2
- package/skills/keiyaku-debt/SKILL.md +2 -1
|
@@ -1,64 +1,49 @@
|
|
|
1
1
|
import { contractAttentionFacts, abbreviateGitIds, afterWording, displayGitId, gateGlyph, requirementDisplayName, gateRequirementFacts, gitIdsInDetail, lifecycleWord, mergeSummary, progressStrip, targetMoved, targetMovementFacts, workspaceState, } from "./contract-observation.js";
|
|
2
|
-
import { DEFAULT_CLI_COLUMNS,
|
|
3
|
-
import { associationFact, formatAge, NARROW_COLUMNS,
|
|
2
|
+
import { DEFAULT_CLI_COLUMNS, entityLines, identityLine, renderBoundedPayload, renderSectionBlock, safeText, tone, } from "./terminal.js";
|
|
3
|
+
import { associationFact, formatAge, NARROW_COLUMNS, renderAkumaBoard, akumaLabel, akumaRowLines, } from "./kanshi-akuma.js";
|
|
4
4
|
import { contractDetailMark, contractMark, debtDispositionMark } from "./marks.js";
|
|
5
5
|
import { dispositionText } from "./debt.js";
|
|
6
|
-
const REVIEW_ATTENTION_MS = 15 * 60 * 1_000;
|
|
7
|
-
const PENDING_ATTENTION_MS = 60 * 60 * 1_000;
|
|
8
6
|
function contractHasError(row) {
|
|
9
7
|
return (row.title === undefined ||
|
|
10
8
|
row.attention !== undefined ||
|
|
11
9
|
(row.gates ?? []).some((gate) => gate.verdict === "unsatisfied"));
|
|
12
10
|
}
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
return "alert";
|
|
16
|
-
const phaseAge = elapsedMilliseconds(row.phaseAt, observedAt);
|
|
17
|
-
if (phaseAge === null)
|
|
18
|
-
return null;
|
|
19
|
-
if (row.delivered === true && phaseAge >= REVIEW_ATTENTION_MS)
|
|
20
|
-
return "attention";
|
|
21
|
-
return row.delivered !== true && phaseAge >= PENDING_ATTENTION_MS ? "attention" : null;
|
|
22
|
-
}
|
|
23
|
-
/** Summary associations name their observed owner identity; unavailable authority stays explicit. */
|
|
24
|
-
function associationFacts(associations) {
|
|
25
|
-
return associations.map((association) => {
|
|
11
|
+
function contractSummaryFacts(row) {
|
|
12
|
+
const associations = (row.associations ?? []).flatMap((association) => {
|
|
26
13
|
if (association.kind === "unavailable")
|
|
27
|
-
return `${association.source} association unavailable
|
|
28
|
-
|
|
29
|
-
return `debt ${association.debtId}`;
|
|
30
|
-
if (association.aliases !== undefined)
|
|
31
|
-
return `akuma ${association.akumaId} (${association.aliases.join(" ")})`;
|
|
32
|
-
return association.aliasesUnavailable === true
|
|
33
|
-
? `akuma ${association.akumaId} (aliases unavailable)`
|
|
34
|
-
: `akuma ${association.akumaId}`;
|
|
14
|
+
return [`${association.source} association unavailable`];
|
|
15
|
+
return association.kind === "debt" ? [`debt ${association.debtId}`] : [];
|
|
35
16
|
});
|
|
36
|
-
}
|
|
37
|
-
function contractSummaryFacts(row) {
|
|
38
|
-
const associations = row.associations === undefined ? [] : associationFacts(row.associations);
|
|
39
17
|
return [progressStrip(row), ...contractAttentionFacts(row), ...associations];
|
|
40
18
|
}
|
|
41
19
|
function renderWorldContractRow(row, observedAt, context) {
|
|
42
|
-
const statusTone =
|
|
20
|
+
const statusTone = contractHasError(row) ? "alert" : null;
|
|
43
21
|
return entityLines({
|
|
44
22
|
mark: statusTone === null ? contractMark(row) : tone(contractMark(row), statusTone, context.color),
|
|
45
23
|
identity: row.id,
|
|
46
|
-
state: formatAge(row.phaseAt, observedAt)
|
|
24
|
+
state: `${lifecycleWord(row.phase)} · ${formatAge(row.phaseAt, observedAt)}`,
|
|
47
25
|
title: row.title ?? "title unavailable",
|
|
48
26
|
facts: contractSummaryFacts(row),
|
|
49
27
|
context,
|
|
50
28
|
});
|
|
51
29
|
}
|
|
52
30
|
/** The World omits an empty Contract section. */
|
|
53
|
-
function contractBoardRows(board, observedAt, context) {
|
|
31
|
+
function contractBoardRows(board, observedAt, context, children, aliasesUnavailable) {
|
|
32
|
+
const nestedContext = { ...context, columns: Math.max(1, context.columns - 2) };
|
|
54
33
|
const rendered = renderSectionBlock({
|
|
55
34
|
name: "CONTRACTS",
|
|
56
|
-
rows: (board.rows ?? []).map((row) =>
|
|
35
|
+
rows: (board.rows ?? []).map((row) => [
|
|
36
|
+
...renderWorldContractRow(row, observedAt, context),
|
|
37
|
+
...(children.get(row.id) ?? []).flatMap((child) => {
|
|
38
|
+
const { contract: _contract, ...facts } = child;
|
|
39
|
+
return akumaRowLines(facts, aliasesUnavailable, observedAt, nestedContext).map((line) => ` ${line}`);
|
|
40
|
+
}),
|
|
41
|
+
]),
|
|
57
42
|
hasMore: board.more === true,
|
|
58
43
|
});
|
|
59
44
|
return ["CONTRACTS // recent", ...rendered.slice(1)];
|
|
60
45
|
}
|
|
61
|
-
function renderContractBoard(section, observedAt, context) {
|
|
46
|
+
function renderContractBoard(section, observedAt, context, children, aliasesUnavailable) {
|
|
62
47
|
if (section.kind === "absent")
|
|
63
48
|
return ["CONTRACTS // absent"];
|
|
64
49
|
if (section.kind === "failed") {
|
|
@@ -66,7 +51,7 @@ function renderContractBoard(section, observedAt, context) {
|
|
|
66
51
|
}
|
|
67
52
|
if ((section.rows ?? []).length === 0)
|
|
68
53
|
return [];
|
|
69
|
-
return contractBoardRows(section, observedAt, context);
|
|
54
|
+
return contractBoardRows(section, observedAt, context, children, aliasesUnavailable);
|
|
70
55
|
}
|
|
71
56
|
function detailHasError(row) {
|
|
72
57
|
if (row.title === undefined)
|
|
@@ -125,13 +110,8 @@ function linkedAkumaRows(row) {
|
|
|
125
110
|
if ("kind" in roster)
|
|
126
111
|
return [" akuma association unavailable"];
|
|
127
112
|
return roster.map((attached) => {
|
|
128
|
-
const aliases = attached.
|
|
129
|
-
|
|
130
|
-
: attached.aliasesUnavailable === true
|
|
131
|
-
? "aliases unavailable"
|
|
132
|
-
: "";
|
|
133
|
-
const identity = [safeText(attached.id), aliases.length === 0 ? "" : `(${aliases})`].filter(Boolean).join(" ");
|
|
134
|
-
return ` akuma ${identity}`;
|
|
113
|
+
const aliases = safeText(akumaLabel(attached, attached.aliasesUnavailable === true));
|
|
114
|
+
return ` akuma ${safeText(attached.id)}${aliases === "" ? "" : ` ${aliases}`}`;
|
|
135
115
|
});
|
|
136
116
|
}
|
|
137
117
|
function mergeFacts(row) {
|
|
@@ -244,12 +224,23 @@ function renderDebts(report, context) {
|
|
|
244
224
|
}
|
|
245
225
|
return (section.rows ?? []).length === 0 ? [] : debtBoardRows(section, context);
|
|
246
226
|
}
|
|
227
|
+
function renderUngroupedAkumas(report, rows, context) {
|
|
228
|
+
return renderAkumaBoard(report.akumas, report.observedAt, context, [], rows);
|
|
229
|
+
}
|
|
247
230
|
export function renderKanshiText(report, context = { columns: DEFAULT_CLI_COLUMNS, color: false }) {
|
|
248
231
|
if (!("contracts" in report))
|
|
249
232
|
return renderSelectedContract(report, context).join("\n");
|
|
233
|
+
const children = new Map(report.contracts.kind === "present" ? (report.contracts.rows ?? []).map((row) => [row.id, []]) : []);
|
|
234
|
+
const ungrouped = [];
|
|
235
|
+
if (report.akumas.kind === "present") {
|
|
236
|
+
for (const row of report.akumas.rows ?? []) {
|
|
237
|
+
const group = row.contract?.kind === "associated" ? children.get(row.contract.contractId) : undefined;
|
|
238
|
+
(group ?? ungrouped).push(row);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
250
241
|
const blocks = [
|
|
251
|
-
renderContractBoard(report.contracts, report.observedAt, context),
|
|
252
|
-
|
|
242
|
+
renderContractBoard(report.contracts, report.observedAt, context, children, report.akumas.kind === "present" && report.akumas.aliasesError !== undefined),
|
|
243
|
+
renderUngroupedAkumas(report, ungrouped, context),
|
|
253
244
|
renderDebts(report, context),
|
|
254
245
|
].filter((block) => block.length > 0);
|
|
255
246
|
return blocks.length === 0 ? "○ world empty" : blocks.map((block) => block.join("\n")).join("\n\n");
|
|
@@ -125,28 +125,30 @@ function renderWait(input, result, context) {
|
|
|
125
125
|
return [result.reason, ...rows].join("\n");
|
|
126
126
|
}
|
|
127
127
|
function renderHistory(query, result, context) {
|
|
128
|
-
const options = query;
|
|
129
128
|
if (query.selector.startsWith("kei/")) {
|
|
130
129
|
if (result.kind === "contract-missing")
|
|
131
|
-
return missing("history",
|
|
132
|
-
if (result.kind
|
|
130
|
+
return missing("history", result.contractId, context);
|
|
131
|
+
if (result.kind === "contract-unknown-history")
|
|
132
|
+
return `${result.contractId} has no matching history at ${"item" in query ? query.item : ""}`;
|
|
133
|
+
if (result.kind !== "contract" && result.kind !== "contract-exact")
|
|
133
134
|
throw new Error("Contract history returned a non-Contract result");
|
|
134
|
-
return renderContractHistory(result
|
|
135
|
+
return renderContractHistory(result);
|
|
135
136
|
}
|
|
136
|
-
if (result.kind === "contract" ||
|
|
137
|
+
if (result.kind === "contract" ||
|
|
138
|
+
result.kind === "contract-exact" ||
|
|
139
|
+
result.kind === "contract-unknown-history" ||
|
|
140
|
+
result.kind === "contract-missing")
|
|
137
141
|
throw new Error("Akuma history returned a non-Akuma result");
|
|
138
|
-
const
|
|
139
|
-
const
|
|
142
|
+
const answer = "item" in query && query.item === "answer";
|
|
143
|
+
const id = "item" in query && !answer ? query.item : undefined;
|
|
140
144
|
const selectedAlias = aliasSelector(query.selector);
|
|
141
145
|
return (historyRawAnswer(result, id) ??
|
|
142
|
-
(
|
|
143
|
-
?
|
|
144
|
-
:
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
last,
|
|
149
|
-
}, context)));
|
|
146
|
+
historyText(result, {
|
|
147
|
+
...(selectedAlias === undefined ? {} : { alias: selectedAlias }),
|
|
148
|
+
...(id === undefined ? {} : { id }),
|
|
149
|
+
...("since" in query && query.since !== undefined ? { since: query.since } : {}),
|
|
150
|
+
answer,
|
|
151
|
+
}, context));
|
|
150
152
|
}
|
|
151
153
|
function renderDebtVerb(name, input, value, context) {
|
|
152
154
|
switch (name) {
|
|
@@ -194,7 +196,7 @@ function renderShow(input, result, context) {
|
|
|
194
196
|
if (result.kind === "present")
|
|
195
197
|
return result.guidance;
|
|
196
198
|
if (result.kind === "missing")
|
|
197
|
-
return missing("show", input.
|
|
199
|
+
return missing("show", input.selector, context);
|
|
198
200
|
return renderDebtShow(result, context);
|
|
199
201
|
}
|
|
200
202
|
/** Render native completion values without observing the World or parsing output. */
|
|
@@ -245,8 +247,9 @@ export function renderVerb(name, input, completion, context) {
|
|
|
245
247
|
return renderKanshiText(value, context);
|
|
246
248
|
case "status": {
|
|
247
249
|
const result = value;
|
|
250
|
+
const alias = aliasSelector(input.selector);
|
|
248
251
|
return result.kind === "akuma"
|
|
249
|
-
? snapshotText(result, context,
|
|
252
|
+
? snapshotText(result, context, alias === undefined ? {} : { alias })
|
|
250
253
|
: result.kind === "contract-missing"
|
|
251
254
|
? missing("status", result.id, context)
|
|
252
255
|
: renderKanshiText(result, context);
|
package/build/src/cli/runtime.js
CHANGED
|
@@ -2,7 +2,7 @@ import { resolve } from "node:path";
|
|
|
2
2
|
import { AkumaNotBornError, AkumaObservationError } from "../akuma/akuma-errors.js";
|
|
3
3
|
import { AkumaNameError, Keiyaku } from "../index.js";
|
|
4
4
|
import { errorCategory } from "../errors.js";
|
|
5
|
-
import { AkumaAddressError, AkumaWorldScopeError
|
|
5
|
+
import { AkumaAddressError, AkumaWorldScopeError } from "../library/address.js";
|
|
6
6
|
import { projectFailure, KeiyakuError } from "../library/outcome.js";
|
|
7
7
|
import { classifyVerb } from "../library/keiyaku-verbs.js";
|
|
8
8
|
import { acquireAkumaRequest, runAsk, runAkumaHistory } from "./commands/akuma.js";
|
|
@@ -158,7 +158,7 @@ async function runCommand(invocation, input) {
|
|
|
158
158
|
assertExplicitRepoUse(command, invocation.repo);
|
|
159
159
|
const runtime = {
|
|
160
160
|
environment,
|
|
161
|
-
facet: Keiyaku.
|
|
161
|
+
facet: Keiyaku.for({
|
|
162
162
|
cwd: resolve(input.cwd ?? process.cwd(), invocation.cwd ?? "."),
|
|
163
163
|
environment,
|
|
164
164
|
...(home === undefined ? {} : { home }),
|
|
@@ -182,35 +182,21 @@ async function runCommand(invocation, input) {
|
|
|
182
182
|
}
|
|
183
183
|
if (command.name === "bind" && "acquire" in command) {
|
|
184
184
|
await admitBindMarkdown({
|
|
185
|
-
|
|
185
|
+
terms: await runtime.readStdin(),
|
|
186
186
|
processCwd: input.cwd ?? process.cwd(),
|
|
187
187
|
...(invocation.cwd === undefined ? {} : { cwd: invocation.cwd }),
|
|
188
188
|
});
|
|
189
189
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
const authority = await observeNamedAddress({ world, repo: repo ?? null, selectors: [selector] });
|
|
196
|
-
const address = resolveNamedAddress({ selector, ...authority });
|
|
197
|
-
if (address.kind === "akuma")
|
|
198
|
-
selectedAlias = selector;
|
|
199
|
-
request = { name: "status", input: { id: address.id }, output: command.output };
|
|
200
|
-
}
|
|
201
|
-
else {
|
|
202
|
-
request =
|
|
203
|
-
"acquire" in command
|
|
204
|
-
? command.name === "spawn" || command.name === "tell" || command.name === "ask"
|
|
205
|
-
? await acquireAkumaRequest(command, invocation.workdir, runtime)
|
|
206
|
-
: await acquireContractRequest(command, runtime)
|
|
207
|
-
: command;
|
|
208
|
-
}
|
|
190
|
+
const request = "acquire" in command
|
|
191
|
+
? command.name === "spawn" || command.name === "tell" || command.name === "ask"
|
|
192
|
+
? await acquireAkumaRequest(command, invocation.workdir, runtime)
|
|
193
|
+
: await acquireContractRequest(command, runtime)
|
|
194
|
+
: command;
|
|
209
195
|
if (request.name === "ask")
|
|
210
196
|
return await runAsk(request, runtime);
|
|
211
197
|
if (request.name === "history" && !request.input.selector.startsWith("kei/"))
|
|
212
198
|
return await runAkumaHistory(request, runtime);
|
|
213
|
-
return await runContractRequest(request, runtime
|
|
199
|
+
return await runContractRequest(request, runtime);
|
|
214
200
|
}
|
|
215
201
|
catch (error) {
|
|
216
202
|
return writeFailure(error, command);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type DebtDocument } from "./document.js";
|
|
2
2
|
import { type DebtId } from "./identity.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
+
import type { LifecycleSelection } from "../bounded-list.js";
|
|
4
5
|
export declare const debtRefSchema: z.ZodReadonly<z.ZodObject<{
|
|
5
6
|
id: z.ZodPipe<z.ZodString, z.ZodTransform<`debt/${string}`, string>>;
|
|
6
7
|
state: z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -90,7 +91,7 @@ export declare function debtDisposition(board: DebtBoard, debt: DebtDocument): D
|
|
|
90
91
|
export declare function debtBlocked(board: DebtBoard, debt: DebtDocument): boolean;
|
|
91
92
|
export declare function projectDebtDetail(board: DebtBoard, id: DebtId): DebtDetail | null;
|
|
92
93
|
export declare function projectDebtSummary(board: DebtBoard, debt: DebtDocument): DebtSummary;
|
|
93
|
-
export declare function projectRows(board: DebtBoard, selection:
|
|
94
|
+
export declare function projectRows(board: DebtBoard, selection: LifecycleSelection): readonly DebtSummary[];
|
|
94
95
|
export declare function projectBlocked(board: DebtBoard): readonly BlockedDebtRow[];
|
|
95
96
|
export declare function relationProblem(board: DebtBoard, before: DebtDocument | null, after: DebtDocument): string | null;
|
|
96
97
|
export declare function diagnoseBoard(board: DebtBoard): readonly DebtDoctorIssue[];
|
package/build/src/debt/board.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { debtNonblankTextSchema, debtStateSchema, debtPrioritySchema, } from "./document.js";
|
|
1
|
+
import { debtNonblankTextSchema, debtStateSchema, debtLifecycle, debtPrioritySchema, } from "./document.js";
|
|
2
2
|
import { debtIdSchema } from "./identity.js";
|
|
3
3
|
import { nonEmptyDebtValues, nonEmptyDebtArraySchema } from "./operation-types.js";
|
|
4
4
|
import { z } from "zod";
|
|
@@ -64,7 +64,7 @@ export const debtDoctorIssueSchema = z.union([
|
|
|
64
64
|
})
|
|
65
65
|
.readonly(),
|
|
66
66
|
]);
|
|
67
|
-
const terminal = (state) => state === "
|
|
67
|
+
const terminal = (state) => debtLifecycle(state) === "settled";
|
|
68
68
|
const sorted = (values) => [...values].sort((a, b) => Buffer.compare(Buffer.from(a.id), Buffer.from(b.id)));
|
|
69
69
|
export function debtRef(board, id) {
|
|
70
70
|
const debt = board.debts.get(id);
|
|
@@ -110,7 +110,7 @@ export function projectDebtSummary(board, debt) {
|
|
|
110
110
|
}
|
|
111
111
|
export function projectRows(board, selection) {
|
|
112
112
|
return [...board.debts.values()]
|
|
113
|
-
.filter((debt) => selection === "all" || (
|
|
113
|
+
.filter((debt) => selection === "all" || debtLifecycle(debt.state) === selection)
|
|
114
114
|
.map((debt) => projectDebtSummary(board, debt))
|
|
115
115
|
.sort(compareDebtRows);
|
|
116
116
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { debtLifecycle } from "./document.js";
|
|
1
2
|
import { readRecentDebtDocuments, readDebtDocument } from "./store.js";
|
|
2
3
|
function terminal(debt) {
|
|
3
|
-
return debt
|
|
4
|
+
return debt !== undefined && debtLifecycle(debt.state) === "settled";
|
|
4
5
|
}
|
|
5
6
|
async function catalogRow(world, debt, documents) {
|
|
6
7
|
const needs = await Promise.all(debt.needs.map(async (id) => documents.get(id) ?? (await readDebtDocument(world, id))));
|
|
@@ -10,6 +10,7 @@ export declare const debtStateSchema: z.ZodEnum<{
|
|
|
10
10
|
export type DebtPriority = 0 | 1 | 2 | 3;
|
|
11
11
|
export declare const debtPrioritySchema: z.ZodType<DebtPriority, DebtPriority>;
|
|
12
12
|
export type DebtState = z.infer<typeof debtStateSchema>;
|
|
13
|
+
export declare function debtLifecycle(state: DebtState): "active" | "settled";
|
|
13
14
|
export declare const debtDocumentSchema: z.ZodReadonly<z.ZodObject<{
|
|
14
15
|
id: z.ZodPipe<z.ZodString, z.ZodTransform<`debt/${string}`, string>>;
|
|
15
16
|
title: z.ZodString;
|
|
@@ -6,6 +6,9 @@ export const debtNonblankTextSchema = z.string().refine((value) => value.trim()
|
|
|
6
6
|
export const debtStateSchema = z.enum(["open", "done", "drop"]);
|
|
7
7
|
// Integer bounds prove the finite priority type without a four-branch wire union.
|
|
8
8
|
export const debtPrioritySchema = z.number().int().min(0).max(3);
|
|
9
|
+
export function debtLifecycle(state) {
|
|
10
|
+
return state === "open" ? "active" : "settled";
|
|
11
|
+
}
|
|
9
12
|
export const debtDocumentSchema = z
|
|
10
13
|
.strictObject({
|
|
11
14
|
id: debtIdSchema,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type LifecycleSelection } from "../bounded-list.js";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
import { debtRefSchema, blockedDebtRowSchema, readyDebtRowSchema, debtDoctorIssueSchema, debtSummarySchema, debtDispositionSchema, debtDetailSchema, type BlockedDebtRow, type DebtDetail, type DebtDoctorIssue, type DebtRef, type DebtSummary, type ReadyDebtRow } from "./board.js";
|
|
3
4
|
import { debtWarningSchema, debtRefusalSchema, debtRetrySchema, debtReadPageSchema, debtMutationResultSchema, debtMutationNormalResultSchema, debtUpdateResultSchema, debtChangeSchema, type DebtWarning, type DebtRefusal, type DebtRetry, type DebtReadPage, type DebtMutationResult, type DebtUpdateResult, type DebtChange } from "./operation-types.js";
|
|
@@ -253,7 +254,7 @@ declare class DebtsHandle {
|
|
|
253
254
|
add(input: AddDebtInput): Promise<DebtMutationResult>;
|
|
254
255
|
addDocument(input: AddDebtDocumentInput): Promise<DebtMutationResult>;
|
|
255
256
|
list(input?: Readonly<{
|
|
256
|
-
selection?:
|
|
257
|
+
selection?: LifecycleSelection;
|
|
257
258
|
limit?: number;
|
|
258
259
|
}>): Promise<DebtList>;
|
|
259
260
|
ready(input?: Readonly<{
|
package/build/src/debt/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { KeiyakuError } from "../errors.js";
|
|
2
|
+
import { lifecycleSelection } from "../bounded-list.js";
|
|
2
3
|
import { z } from "zod";
|
|
3
4
|
import { debtRefSchema, blockedDebtRowSchema, readyDebtRowSchema, debtDoctorIssueSchema, debtSummarySchema, debtDispositionSchema, debtDetailSchema, diagnoseBoard, projectDebtDetail, } from "./board.js";
|
|
4
5
|
import { debtWarningSchema, debtRefusalSchema, debtRetrySchema, debtReadPageSchema, nonEmptyDebtValues, nonEmptyDebtArraySchema, debtMutationResultSchema, debtMutationNormalResultSchema, debtUpdateResultSchema, debtChangeSchema, } from "./operation-types.js";
|
|
@@ -88,10 +89,9 @@ class DebtsHandle {
|
|
|
88
89
|
}
|
|
89
90
|
async list(input = {}) {
|
|
90
91
|
const v = fields(input, ["selection", "limit"], "list input");
|
|
91
|
-
|
|
92
|
-
throw new KeiyakuError("invalid-input", "selection must be active, closed, or all");
|
|
92
|
+
const selection = lifecycleSelection(v.selection);
|
|
93
93
|
return {
|
|
94
|
-
...(await listDebts(this.world,
|
|
94
|
+
...(await listDebts(this.world, selection, boundedListLimit(v.limit))),
|
|
95
95
|
kind: "debt-catalogue",
|
|
96
96
|
};
|
|
97
97
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type BlockedDebtRow, type DebtDetail, type DebtSummary, type ReadyDebtRow } from "./board.js";
|
|
2
2
|
import { type DebtId } from "./identity.js";
|
|
3
3
|
import type { WorldRoot } from "../world.js";
|
|
4
|
+
import { type LifecycleSelection } from "../bounded-list.js";
|
|
4
5
|
export type { AddDebtDocumentInput, AddDebtInput, DebtMutationResult, DebtReadPage, DebtRefusal, DebtRetry, DebtUpdateResult, SettledDebtResult, UpdateDebtInput, } from "./operation-types.js";
|
|
5
6
|
import type { AddDebtDocumentInput, AddDebtInput, DebtMutationResult, DebtReadPage, DebtUpdateResult, UpdateDebtInput } from "./operation-types.js";
|
|
6
7
|
export declare function nukeDebt(world: WorldRoot, options?: Readonly<{
|
|
@@ -11,7 +12,7 @@ export declare function addDebt(world: WorldRoot, input: AddDebtInput): Promise<
|
|
|
11
12
|
export declare function addDebtDocument(world: WorldRoot, input: AddDebtDocumentInput): Promise<DebtMutationResult>;
|
|
12
13
|
export declare function updateDebt(world: WorldRoot, id: DebtId, input: UpdateDebtInput): Promise<DebtUpdateResult>;
|
|
13
14
|
export { settleDebt } from "./lifecycle-operations.js";
|
|
14
|
-
export declare function listDebts(world: WorldRoot, selection:
|
|
15
|
+
export declare function listDebts(world: WorldRoot, selection: LifecycleSelection, limit?: number): Promise<Extract<DebtReadPage<DebtSummary>, {
|
|
15
16
|
kind: "present";
|
|
16
17
|
}>>;
|
|
17
18
|
export declare function readDebtDetail(world: WorldRoot, id: DebtId): Promise<DebtDetail | null>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ContractId, type ContractState, type ContractTarget, type JournalEntry, type SnapshotId } from "../core/facts/types.js";
|
|
2
2
|
import type { ContractsObservation } from "../core/facts/observation.js";
|
|
3
|
+
import { type ContractJournalClass } from "./identity.js";
|
|
3
4
|
import { type GitSnapshot, type GitOid } from "./repository.js";
|
|
4
5
|
import { type GitRepository } from "./process.js";
|
|
5
6
|
import { type GitDecodeChannel, type GitReadObservation, type GitTreeSelection } from "./read-observation.js";
|
|
@@ -61,9 +62,9 @@ export declare function normalizeTargetBranch(repository: GitRepository, input:
|
|
|
61
62
|
* which coordinate it wants observed.
|
|
62
63
|
*/
|
|
63
64
|
export declare function observeBindCoordinates(repository: GitRepository, selection: BindTargetSelection): Promise<BindCoordinatesObservation | UnbornHeadObservation | null>;
|
|
64
|
-
export declare function
|
|
65
|
-
/** Observe
|
|
66
|
-
export declare function
|
|
65
|
+
export declare function observedContractJournalPaths(observation: GitReadObservation, journalClass?: ContractJournalClass): readonly string[];
|
|
66
|
+
/** Observe selected journal classes without following their prerequisite edges. */
|
|
67
|
+
export declare function observeContractJournals(observation: GitReadObservation, journalClass?: ContractJournalClass): Promise<ReadonlyMap<ContractId, GitJournalRecord>>;
|
|
67
68
|
export declare function observeActiveContractWorld(observation: GitReadObservation): Promise<ActiveContractWorldObservation>;
|
|
68
69
|
export declare function observeContractWorld(observation: GitReadObservation, requested?: readonly ContractId[]): Promise<ContractWorldObservation>;
|
|
69
70
|
export declare function observeContractsForAdmissionAt(repository: GitRepository, channel: GitDecodeChannel, ids: readonly ContractId[], selection?: GitTreeSelection): Promise<GitDecisionObservation>;
|
package/build/src/git/observe.js
CHANGED
|
@@ -205,9 +205,10 @@ function enumerateContractObservations(git, blobs, journalClass) {
|
|
|
205
205
|
}
|
|
206
206
|
return observations;
|
|
207
207
|
}
|
|
208
|
-
export function
|
|
208
|
+
export function observedContractJournalPaths(observation, journalClass) {
|
|
209
209
|
return [...observation.snapshot.paths].flatMap(([path, entry]) => {
|
|
210
|
-
|
|
210
|
+
const matched = CONTRACT_JOURNAL_PATH.exec(path)?.[1];
|
|
211
|
+
if (matched === undefined || (journalClass !== undefined && matched !== journalClass))
|
|
211
212
|
return [];
|
|
212
213
|
if (entry.type !== "blob")
|
|
213
214
|
throw new AuthorityCorruptionError(`journal path is not a blob: ${path}`);
|
|
@@ -225,14 +226,14 @@ async function readJournalBlobs(entries, readBlobsAt) {
|
|
|
225
226
|
}
|
|
226
227
|
return blobs;
|
|
227
228
|
}
|
|
228
|
-
/** Observe
|
|
229
|
-
export async function
|
|
229
|
+
/** Observe selected journal classes without following their prerequisite edges. */
|
|
230
|
+
export async function observeContractJournals(observation, journalClass) {
|
|
230
231
|
const git = observation.snapshot;
|
|
231
|
-
const journals =
|
|
232
|
-
return enumerateContractObservations(git, await readJournalBlobs(journals, observation.readBlobs),
|
|
232
|
+
const journals = observedContractJournalPaths(observation, journalClass).map((path) => [path, git.paths.get(path)]);
|
|
233
|
+
return enumerateContractObservations(git, await readJournalBlobs(journals, observation.readBlobs), journalClass);
|
|
233
234
|
}
|
|
234
235
|
export async function observeActiveContractWorld(observation) {
|
|
235
|
-
const contracts = await
|
|
236
|
+
const contracts = await observeContractJournals(observation, "active");
|
|
236
237
|
const prerequisites = [...new Set([...contracts.values()].flatMap((record) => record.state?.terms.after ?? []))];
|
|
237
238
|
const dependencyRecords = await observeTargetedContractsAt(observation, prerequisites);
|
|
238
239
|
return {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** One copyable history address: a positive safe integer written canonically as a decimal string. */
|
|
3
|
+
export declare const canonicalDecimalSchema: z.ZodString;
|
|
4
|
+
/** The page leaves both history families accept: before/limit, then since/limit. */
|
|
5
|
+
export declare const historyPageSchemas: readonly [z.ZodObject<{
|
|
6
|
+
before: z.ZodExactOptional<z.ZodNumber>;
|
|
7
|
+
limit: z.ZodExactOptional<z.ZodNumber>;
|
|
8
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
9
|
+
since: z.ZodNumber;
|
|
10
|
+
limit: z.ZodExactOptional<z.ZodNumber>;
|
|
11
|
+
}, z.core.$strict>];
|
|
12
|
+
/** One family's requested timeline window; cursors are strictly exclusive. */
|
|
13
|
+
export type HistoryCursor = Readonly<{
|
|
14
|
+
before?: number;
|
|
15
|
+
since?: number;
|
|
16
|
+
limit?: number;
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* Select one page of native-sequence-ordered rows. A `before` or omitted cursor
|
|
20
|
+
* takes the most recent eligible rows, `since` the earliest newer ones, and
|
|
21
|
+
* every answer stays in ascending native sequence order.
|
|
22
|
+
*/
|
|
23
|
+
export declare function selectHistoryPage<Row>(rows: readonly Row[], sequence: (row: Row) => number, cursor: HistoryCursor): Readonly<{
|
|
24
|
+
rows: readonly Row[];
|
|
25
|
+
omitted: number;
|
|
26
|
+
}>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** One copyable history address: a positive safe integer written canonically as a decimal string. */
|
|
3
|
+
export const canonicalDecimalSchema = z
|
|
4
|
+
.string()
|
|
5
|
+
.regex(/^[1-9][0-9]*$/u)
|
|
6
|
+
.refine((value) => Number.isSafeInteger(Number(value)), {
|
|
7
|
+
message: "must be a positive safe integer written canonically as a decimal string",
|
|
8
|
+
});
|
|
9
|
+
const historySequence = z.number().int().positive().safe();
|
|
10
|
+
const historyLimit = historySequence
|
|
11
|
+
.max(5_000)
|
|
12
|
+
.exactOptional()
|
|
13
|
+
.describe("Maximum timeline entries (1..5000, default 12).");
|
|
14
|
+
/** The page leaves both history families accept: before/limit, then since/limit. */
|
|
15
|
+
export const historyPageSchemas = [
|
|
16
|
+
z.strictObject({
|
|
17
|
+
before: historySequence
|
|
18
|
+
.exactOptional()
|
|
19
|
+
.describe("Read the most recent entries strictly before this sequence; omit for the latest entries. Cannot be combined with since or item."),
|
|
20
|
+
limit: historyLimit,
|
|
21
|
+
}),
|
|
22
|
+
z.strictObject({
|
|
23
|
+
since: historySequence.describe("Read the earliest entries strictly after this sequence. Cannot be combined with before or item."),
|
|
24
|
+
limit: historyLimit,
|
|
25
|
+
}),
|
|
26
|
+
];
|
|
27
|
+
/** Both families default to the latest twelve timeline entries. */
|
|
28
|
+
const DEFAULT_HISTORY_LIMIT = 12;
|
|
29
|
+
/**
|
|
30
|
+
* Select one page of native-sequence-ordered rows. A `before` or omitted cursor
|
|
31
|
+
* takes the most recent eligible rows, `since` the earliest newer ones, and
|
|
32
|
+
* every answer stays in ascending native sequence order.
|
|
33
|
+
*/
|
|
34
|
+
export function selectHistoryPage(rows, sequence, cursor) {
|
|
35
|
+
const eligible = rows.filter((row) => cursor.before !== undefined
|
|
36
|
+
? sequence(row) < cursor.before
|
|
37
|
+
: cursor.since !== undefined
|
|
38
|
+
? sequence(row) > cursor.since
|
|
39
|
+
: true);
|
|
40
|
+
const limit = cursor.limit ?? DEFAULT_HISTORY_LIMIT;
|
|
41
|
+
const selected = cursor.since !== undefined ? eligible.slice(0, limit) : eligible.slice(-limit);
|
|
42
|
+
return { rows: selected, omitted: Math.max(0, eligible.length - selected.length) };
|
|
43
|
+
}
|
package/build/src/index.d.ts
CHANGED
|
@@ -8,8 +8,9 @@ export { AuthorityCorruptionError } from "./core/facts/errors.js";
|
|
|
8
8
|
export { Kei } from "./library/kei.js";
|
|
9
9
|
export type { Guidance } from "./library/kei.js";
|
|
10
10
|
export type { Delivery } from "./library/delivery.js";
|
|
11
|
+
export type { LifecycleSelection } from "./bounded-list.js";
|
|
11
12
|
export { Keiyaku, KeiyakuArcDocumentError, KeiyakuUsageError } from "./library/keiyaku.js";
|
|
12
|
-
export type {
|
|
13
|
+
export type { KeiyakuFor } from "./library/keiyaku.js";
|
|
13
14
|
export type { InvocationWaitMember, InvocationWaitResult } from "./library/keiyaku-wait.js";
|
|
14
15
|
export type { KeiyakuRunOptions, VerbEntry, VerbName, VerbInput, VerbOutput, VerbProgress, VerbRun, VerbRunFor, VerbDisposition, VerbCompletion, } from "./library/keiyaku-verbs.js";
|
|
15
16
|
export { Keis } from "./library/contract-composition.js";
|
|
@@ -29,13 +30,13 @@ export type { WhoamiFacts } from "./library/keiyaku-identity.js";
|
|
|
29
30
|
export type { ChangeId, ContractHead, ContractId, ContractState, ContractTarget, JournalEntry as Fact, FactKind, SnapshotId, } from "./core/facts/types.js";
|
|
30
31
|
export type { GateStaleReason } from "./core/facts/gate.js";
|
|
31
32
|
export { Kanshi } from "./kanshi/index.js";
|
|
32
|
-
export type { KanshiScopeInput, KanshiBoardOptions, KanshiCountsReport, AkumaKanshiRow, AkumaKanshiWorld, ContractEndpointObservation, ContractHolderObservation, ContractKanshiBoard, ContractKanshiDetail, KanshiContractReport, KanshiResult, KanshiRegionSelection, KanshiReport, RegionDeclaration, RegionRead, Section, DebtKanshiRow, DebtKanshiWorld, } from "./kanshi/index.js";
|
|
33
|
+
export type { KanshiScopeInput, KanshiBoardOptions, KanshiCountsReport, KanshiCountsOptions, AkumaKanshiRow, AkumaKanshiWorld, ContractEndpointObservation, ContractHolderObservation, ContractKanshiBoard, ContractKanshiDetail, KanshiContractReport, KanshiResult, KanshiRegionSelection, KanshiReport, RegionDeclaration, RegionRead, Section, DebtKanshiRow, DebtKanshiWorld, } from "./kanshi/index.js";
|
|
33
34
|
export { AkumaAddressError, AkumaWorldScopeError, Akumas } from "./library/akumas.js";
|
|
34
35
|
export type { AliasBinding, AkumaAddressInput, AkumaNamesInput, AkumaAliasesInput, AkumaAskInput, AkumaHistoryInput, AkumaHistoryResult, AkumaKillInput, AkumaKillResult, AkumaList, AkumaListInput, AkumaObservation, AkumaTellInput, AkumaWaitInput, AkumaWaitResult, AkumaWorldScopeRefusal, DispatchAssociation, ForkInput, ForkResult, SpawnInput, SpawnResult, SpawnWaitHead, } from "./library/akumas.js";
|
|
35
36
|
export type { ContinuationReport } from "./library/continuation.js";
|
|
36
37
|
export type { ContractWaitInput, ContractWaitOptions, ContractWaitMember, ContractWaitResult, } from "./library/contract-wait.js";
|
|
37
38
|
export type { AbandonOutcome, AmendOutcome, ArcOutcome, DeliveryPreviewInput, DeliveryPreviewOutcome, BindOutcome, DeliverOutcome, MutationObservation, ReviewOutcome, VerifyOutcome, } from "./library/contract-outcomes.js";
|
|
38
|
-
export type { AbandonInput, AmendInput, ArcInput, BindInput, ContractHistory, ContractHistoryInput, ContractHistoryEvent, ContractList, ContractListInput, ContractObservationInput, ContractResolveInput, ContractResolution, ContractSelectorRefusal, DeliverInput, KeisOptions, ReviewInput, VerifyInput, Gate, } from "./library/contract-types.js";
|
|
39
|
+
export type { AbandonInput, AmendInput, ArcInput, BindInput, ContractHistory, ContractHistoryInput, ContractHistoryEvent, ContractJournalRow, ContractDispatchRow, ContractList, ContractListInput, ContractObservationInput, ContractResolveInput, ContractResolution, ContractSelectorRefusal, DeliverInput, KeisOptions, ReviewInput, VerifyInput, Gate, } from "./library/contract-types.js";
|
|
39
40
|
export { nukeKeiyaku as nuke } from "./library/nuke.js";
|
|
40
41
|
export type { NukeInput, NukeResult } from "./library/nuke.js";
|
|
41
42
|
export type { InvocationIssue, ResetCounts, ResetIssue, PartialOutcomeEnvelope, HandoffOutcome, ReconciliationLag, Review, Verify, } from "./library/outcome.js";
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { KanshiCoordinates } from "./read.js";
|
|
3
3
|
export type KanshiCountsReport = z.output<typeof kanshiCountsReportSchema>;
|
|
4
|
+
declare const countsOptionsSchema: z.ZodReadonly<z.ZodObject<{
|
|
5
|
+
akumaCaller: z.ZodExactOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodReadonly<z.ZodObject<{
|
|
6
|
+
kind: z.ZodLiteral<"akuma">;
|
|
7
|
+
world: z.ZodPipe<z.ZodString, z.ZodCustom<import("../world.js").WorldRoot, import("../world.js").WorldRoot>>;
|
|
8
|
+
akumaId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../index.js").AkumaId, string>>;
|
|
9
|
+
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
10
|
+
kind: z.ZodLiteral<"external">;
|
|
11
|
+
integration: z.ZodString;
|
|
12
|
+
id: z.ZodString;
|
|
13
|
+
}, z.core.$strict>>]>>>;
|
|
14
|
+
}, z.core.$strict>>;
|
|
15
|
+
/** Omit akumaCaller for exact World totals; null marks only that section unavailable. */
|
|
16
|
+
export type KanshiCountsOptions = z.output<typeof countsOptionsSchema>;
|
|
4
17
|
export declare const kanshiCountsReportSchema: z.ZodReadonly<z.ZodObject<{
|
|
5
18
|
root: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<import("../world.js").WorldRoot, string>>>;
|
|
6
19
|
observedAt: z.ZodString;
|
|
@@ -41,4 +54,5 @@ export declare const kanshiCountsReportSchema: z.ZodReadonly<z.ZodObject<{
|
|
|
41
54
|
}, z.core.$strict>>;
|
|
42
55
|
}, z.core.$strict>>]>;
|
|
43
56
|
}, z.core.$strict>>;
|
|
44
|
-
export declare function kanshiCounts(input: KanshiCoordinates): Promise<KanshiCountsReport>;
|
|
57
|
+
export declare function kanshiCounts(input: KanshiCoordinates, options?: KanshiCountsOptions): Promise<KanshiCountsReport>;
|
|
58
|
+
export {};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { countRunningAkuma } from "../akuma/akuma.js";
|
|
2
|
+
import { countCallerRunningAkuma, countRunningAkuma } from "../akuma/akuma.js";
|
|
3
|
+
import { akumaCallerSchema } from "../akuma/caller.js";
|
|
4
|
+
import { KeiyakuError } from "../errors.js";
|
|
3
5
|
import { DebtAuthorityCorruptionError } from "../debt/index.js";
|
|
4
6
|
import { observeDebtBoard } from "../debt/operations.js";
|
|
5
7
|
import { withGitDecodeChannel, withGitTargetedReadObservation } from "../git/read-observation.js";
|
|
@@ -7,6 +9,7 @@ import { scopeForRepo } from "../library/repo.js";
|
|
|
7
9
|
import { readContractCount } from "../protocol/read/status.js";
|
|
8
10
|
import { World, worldRootSchema } from "../world.js";
|
|
9
11
|
import { sectionSchema } from "./report.js";
|
|
12
|
+
const countsOptionsSchema = z.strictObject({ akumaCaller: akumaCallerSchema.nullable().exactOptional() }).readonly();
|
|
10
13
|
export const kanshiCountsReportSchema = z
|
|
11
14
|
.strictObject({
|
|
12
15
|
root: worldRootSchema.nullable(),
|
|
@@ -33,7 +36,11 @@ async function section(read) {
|
|
|
33
36
|
};
|
|
34
37
|
}
|
|
35
38
|
}
|
|
36
|
-
export async function kanshiCounts(input) {
|
|
39
|
+
export async function kanshiCounts(input, options = {}) {
|
|
40
|
+
const parsed = countsOptionsSchema.safeParse(options);
|
|
41
|
+
if (!parsed.success)
|
|
42
|
+
throw new KeiyakuError("invalid-input", `Invalid Kanshi counts options: ${parsed.error.message}`);
|
|
43
|
+
const { akumaCaller } = parsed.data;
|
|
37
44
|
const world = input.world === null ? null : await World.prove(input.world);
|
|
38
45
|
const observedAt = new Date().toISOString();
|
|
39
46
|
const absent = { kind: "absent" };
|
|
@@ -59,7 +66,11 @@ export async function kanshiCounts(input) {
|
|
|
59
66
|
if (!established)
|
|
60
67
|
return [absent, absent];
|
|
61
68
|
return Promise.all([
|
|
62
|
-
section(() =>
|
|
69
|
+
section(async () => {
|
|
70
|
+
if (akumaCaller === null)
|
|
71
|
+
throw new Error("Akuma caller selection unavailable");
|
|
72
|
+
return akumaCaller === undefined ? countRunningAkuma(world) : countCallerRunningAkuma(world, akumaCaller);
|
|
73
|
+
}),
|
|
63
74
|
section(async () => (await observeDebtBoard(world)).filter((row) => row.disposition === "ready" || row.disposition === "blocked")
|
|
64
75
|
.length),
|
|
65
76
|
]);
|