@astrosheep/keiyaku 4.6.32 → 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 +18 -7
- package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +18 -11
- package/build/plugins/claude/skills/keiyaku-babysit/SKILL.md +8 -6
- package/build/plugins/claude/skills/keiyaku-debt/SKILL.md +2 -1
- package/build/plugins/claude/skills/keiyaku-workflow/SKILL.md +2 -1
- package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +18 -11
- package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +8 -6
- package/build/plugins/codex/skills/keiyaku-debt/SKILL.md +2 -1
- package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +2 -1
- package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +18 -11
- package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +8 -6
- package/build/plugins/opencode/skills/keiyaku-debt/SKILL.md +2 -1
- package/build/plugins/opencode/skills/keiyaku-workflow/SKILL.md +2 -1
- package/build/plugins/pi/README.md +55 -97
- package/build/plugins/pi/keiyaku.ts +1 -142
- package/build/skills/keiyaku-akuma/SKILL.md +18 -11
- package/build/skills/keiyaku-babysit/SKILL.md +8 -6
- package/build/skills/keiyaku-debt/SKILL.md +2 -1
- package/build/skills/keiyaku-workflow/SKILL.md +2 -1
- package/build/src/akuma/akuma-instance.d.ts +11 -0
- package/build/src/akuma/akuma-instance.js +1 -2
- package/build/src/akuma/akuma-observe.d.ts +8 -0
- package/build/src/akuma/akuma-observe.js +81 -14
- package/build/src/akuma/akuma-owner.d.ts +1 -0
- package/build/src/akuma/akuma-owner.js +3 -5
- package/build/src/akuma/akuma-selection-execution.d.ts +82 -7
- package/build/src/akuma/akuma-selection-execution.js +26 -27
- package/build/src/akuma/akuma-wait.d.ts +155 -1
- package/build/src/akuma/akuma-wait.js +94 -34
- package/build/src/akuma/akuma.d.ts +17 -1
- package/build/src/akuma/akuma.js +37 -18
- package/build/src/akuma/body.js +13 -18
- package/build/src/akuma/call-initial-tell.d.ts +0 -1
- package/build/src/akuma/call-initial-tell.js +0 -1
- package/build/src/akuma/heart/activity-schema.d.ts +16 -0
- package/build/src/akuma/heart/activity-schema.js +7 -0
- 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 +7 -1
- package/build/src/akuma/heart/index.js +35 -9
- package/build/src/akuma/heart/rows.d.ts +1 -0
- package/build/src/akuma/heart/rows.js +4 -0
- package/build/src/akuma/heart/timeline.js +4 -4
- 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.d.ts +4 -2
- package/build/src/akuma/projection-read.js +25 -23
- package/build/src/akuma/projection.d.ts +94 -2
- package/build/src/akuma/projection.js +47 -47
- package/build/src/akuma/provider.d.ts +2 -2
- package/build/src/akuma/provider.js +27 -20
- package/build/src/akuma/providers/acp/core.js +2 -5
- package/build/src/akuma/providers/opencode-sdk/events.d.ts +2 -1
- package/build/src/akuma/providers/opencode-sdk/events.js +31 -1
- package/build/src/akuma/publication.js +3 -2
- package/build/src/akuma/selection-observation.d.ts +645 -0
- package/build/src/akuma/selection-observation.js +22 -7
- package/build/src/akuma/status-projection.d.ts +14 -1
- package/build/src/akuma/status-projection.js +40 -2
- package/build/src/akuma/turn-drive.js +21 -15
- package/build/src/body/amend.js +5 -17
- package/build/src/body/decode.js +11 -1
- package/build/src/body/envelope.d.ts +5 -1
- package/build/src/body/envelope.js +4 -2
- package/build/src/body/render.js +4 -6
- 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 +5 -8
- package/build/src/cli/commands/akuma-grammar.js +52 -77
- package/build/src/cli/commands/akuma.d.ts +1 -2
- package/build/src/cli/commands/akuma.js +12 -61
- package/build/src/cli/commands/contract-grammar.d.ts +1 -0
- package/build/src/cli/commands/contract-grammar.js +39 -42
- package/build/src/cli/commands/contract-help.d.ts +6 -5
- package/build/src/cli/commands/contract-help.js +21 -13
- package/build/src/cli/commands/contract.d.ts +3 -3
- package/build/src/cli/commands/contract.js +13 -9
- package/build/src/cli/commands/debt-grammar.js +2 -4
- package/build/src/cli/parse.d.ts +4 -10
- package/build/src/cli/parse.js +2 -5
- package/build/src/cli/render/akuma-activity.d.ts +12 -34
- package/build/src/cli/render/akuma-activity.js +99 -180
- package/build/src/cli/render/akuma.d.ts +5 -11
- package/build/src/cli/render/akuma.js +22 -30
- package/build/src/cli/render/catalog.js +4 -6
- package/build/src/cli/render/contract-history.d.ts +1 -3
- package/build/src/cli/render/contract-history.js +70 -49
- package/build/src/cli/render/contract-observation.d.ts +2 -1
- package/build/src/cli/render/contract-observation.js +25 -1
- package/build/src/cli/render/contract-wait.d.ts +2 -2
- package/build/src/cli/render/contract-wait.js +21 -17
- package/build/src/cli/render/contract.js +12 -9
- package/build/src/cli/render/debt.js +1 -2
- package/build/src/cli/render/execution-progress.js +1 -3
- package/build/src/cli/render/kanshi-akuma.d.ts +4 -3
- package/build/src/cli/render/kanshi-akuma.js +27 -23
- package/build/src/cli/render/kanshi.js +45 -60
- package/build/src/cli/render/receipt.d.ts +1 -1
- package/build/src/cli/render/receipt.js +33 -28
- package/build/src/cli/render/reconcile.js +2 -5
- package/build/src/cli/render/refusal.js +3 -6
- package/build/src/cli/render/terminal.d.ts +2 -4
- package/build/src/cli/render/terminal.js +10 -17
- package/build/src/cli/render/verbs.d.ts +1 -0
- package/build/src/cli/render/verbs.js +39 -34
- package/build/src/cli/runtime.js +12 -32
- package/build/src/core/facts/codec.js +7 -2
- package/build/src/core/facts/eligibility.d.ts +4 -4
- package/build/src/core/facts/eligibility.js +11 -0
- package/build/src/core/facts/fold.js +9 -5
- package/build/src/core/facts/gate.d.ts +5 -1
- package/build/src/core/facts/gate.js +14 -10
- package/build/src/core/facts/types.d.ts +5 -1
- package/build/src/core/facts/types.js +7 -0
- package/build/src/core/subject.d.ts +4 -1
- package/build/src/core/subject.js +10 -2
- package/build/src/core/verbs/amend.d.ts +15 -4
- package/build/src/core/verbs/amend.js +19 -9
- 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 -2
- package/build/src/debt/index.js +9 -14
- package/build/src/debt/input.d.ts +2 -1
- package/build/src/debt/input.js +6 -4
- package/build/src/debt/operations.d.ts +2 -1
- package/build/src/dispatch/index.d.ts +0 -17
- package/build/src/dispatch/index.js +1 -10
- package/build/src/git/identity.js +16 -45
- package/build/src/git/nuke.js +13 -23
- package/build/src/git/observe.d.ts +7 -3
- package/build/src/git/observe.js +29 -26
- package/build/src/git/process.js +11 -18
- package/build/src/git/read-observation.d.ts +5 -4
- package/build/src/git/repository.d.ts +2 -0
- package/build/src/git/repository.js +13 -1
- package/build/src/git/scratch.js +2 -14
- package/build/src/git/terminal-reconcile.js +1 -13
- package/build/src/history.d.ts +26 -0
- package/build/src/history.js +43 -0
- package/build/src/index.d.ts +6 -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 -4
- package/build/src/kanshi/index.js +2 -3
- package/build/src/kanshi/read.d.ts +21 -0
- package/build/src/kanshi/read.js +7 -3
- package/build/src/kanshi/report.d.ts +94 -0
- package/build/src/library/address.d.ts +12 -5
- package/build/src/library/address.js +18 -32
- package/build/src/library/akuma-creation.d.ts +39 -0
- package/build/src/library/akuma-creation.js +3 -9
- package/build/src/library/akumas.d.ts +5 -1
- package/build/src/library/akumas.js +11 -5
- package/build/src/library/continuation.d.ts +10 -0
- package/build/src/library/contract-composition.js +10 -10
- package/build/src/library/contract-creation.js +12 -13
- package/build/src/library/contract-outcomes.d.ts +72 -1
- package/build/src/library/contract-outcomes.js +1 -0
- package/build/src/library/contract-types.d.ts +233 -25
- package/build/src/library/contract-types.js +32 -12
- package/build/src/library/contract-wait.d.ts +212 -0
- package/build/src/library/contract-wait.js +65 -49
- package/build/src/library/delivery.d.ts +25 -0
- package/build/src/library/input.d.ts +8 -26
- package/build/src/library/input.js +17 -12
- package/build/src/library/kei.js +167 -90
- 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 +8 -4
- package/build/src/library/keiyaku-debt.d.ts +8 -7
- package/build/src/library/keiyaku-debt.js +1 -2
- package/build/src/library/keiyaku-identity.d.ts +4 -3
- package/build/src/library/keiyaku-identity.js +35 -7
- package/build/src/library/keiyaku-verbs.d.ts +974 -1409
- package/build/src/library/keiyaku-verbs.js +154 -161
- package/build/src/library/keiyaku-wait.d.ts +753 -0
- package/build/src/library/keiyaku-wait.js +230 -0
- package/build/src/library/keiyaku.d.ts +3110 -29
- package/build/src/library/keiyaku.js +342 -438
- package/build/src/library/model-tools.d.ts +754 -0
- package/build/src/library/model-tools.js +362 -0
- package/build/src/library/outcome.js +5 -6
- package/build/src/library/refusal.d.ts +25 -1
- package/build/src/library/refusal.js +4 -5
- package/build/src/library/selection.d.ts +18 -5
- package/build/src/library/selection.js +11 -5
- package/build/src/mcp/adapter.d.ts +0 -6
- package/build/src/mcp/adapter.js +11 -160
- package/build/src/mcp/description.d.ts +2 -0
- package/build/src/mcp/description.js +2 -0
- package/build/src/mcp/help.d.ts +1 -1
- package/build/src/mcp/help.js +10 -7
- package/build/src/pi/index.d.ts +5 -0
- package/build/src/pi/index.js +99 -0
- package/build/src/pi/status.d.ts +12 -0
- package/build/src/pi/status.js +140 -0
- package/build/src/protocol/amend.d.ts +14 -3
- package/build/src/protocol/amend.js +113 -46
- package/build/src/protocol/bind.d.ts +1 -1
- package/build/src/protocol/bind.js +5 -16
- package/build/src/protocol/completion.d.ts +30 -0
- package/build/src/protocol/completion.js +8 -5
- package/build/src/protocol/deliver.js +7 -20
- package/build/src/protocol/delivery-preview.d.ts +5 -0
- package/build/src/protocol/execution-observation.d.ts +8 -0
- package/build/src/protocol/intent.d.ts +1 -0
- package/build/src/protocol/intent.js +4 -1
- package/build/src/protocol/operations.d.ts +56 -16
- package/build/src/protocol/operations.js +18 -32
- package/build/src/protocol/placement.js +7 -1
- package/build/src/protocol/progress.js +0 -6
- package/build/src/protocol/read/status.d.ts +52 -4
- package/build/src/protocol/read/status.js +26 -22
- package/build/src/protocol/reintegrate.js +2 -2
- package/build/src/protocol/result-leaves.d.ts +56 -8
- package/build/src/protocol/result-leaves.js +11 -2
- package/build/src/protocol/run.js +1 -4
- package/build/src/protocol/verify.d.ts +10 -0
- package/build/src/protocol/verify.js +1 -0
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/build/src/settlement/settle.js +19 -68
- package/package.json +7 -3
- 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/README.md +55 -97
- package/plugins/pi/keiyaku.ts +1 -142
- package/skills/keiyaku-akuma/SKILL.md +18 -11
- package/skills/keiyaku-babysit/SKILL.md +8 -6
- package/skills/keiyaku-debt/SKILL.md +2 -1
- package/skills/keiyaku-workflow/SKILL.md +2 -1
- package/build/plugins/pi/akuma-tools.ts +0 -283
- package/build/src/body/keys.d.ts +0 -4
- package/build/src/body/keys.js +0 -11
- package/build/src/kanshi/roster.d.ts +0 -2
- package/build/src/kanshi/roster.js +0 -2
- package/build/src/mcp/output.d.ts +0 -385
- package/build/src/mcp/output.js +0 -193
- package/plugins/pi/akuma-tools.ts +0 -283
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import { contractIdSchema } from "../git/identity.js";
|
|
4
2
|
import { AuthorityCorruptionError } from "../core/facts/errors.js";
|
|
5
3
|
import { contractId } from "../core/facts/types.js";
|
|
6
|
-
import {
|
|
4
|
+
import { parseAkumaId } from "../akuma/identity.js";
|
|
7
5
|
import { appendPrivateStateSeatClose, confirmPrivateStatePublication, mergePrivateStateSeatClose, withPrivateStatePublicationSeat, } from "../git/private-state-seat.js";
|
|
8
6
|
import { GIT_FORMAT_BYTES, GIT_FORMAT_PATH, GIT_REF, readBlob, readGitPaths, updateGitTree, updateRefsAtomically, writeBlob, writeStateCommit, } from "../git/repository.js";
|
|
9
7
|
import { withGitDecodeChannel, withGitReadObservation, withGitTargetedReadObservation, } from "../git/read-observation.js";
|
|
@@ -11,13 +9,6 @@ import { NO_DISPATCH_ASSOCIATION } from "../akuma/dispatch-association.js";
|
|
|
11
9
|
const DISPATCH_ROOT = "dispatch";
|
|
12
10
|
const DISPATCH_PREFIX = `${DISPATCH_ROOT}/`;
|
|
13
11
|
const DISPATCH_SUFFIX = ".json";
|
|
14
|
-
export const dispatchSchema = z
|
|
15
|
-
.strictObject({ akumaId: akumaIdSchema, contractId: contractIdSchema, dispatchedAt: z.string() })
|
|
16
|
-
.readonly();
|
|
17
|
-
export const dispatchFailureSchema = z.union([
|
|
18
|
-
z.strictObject({ kind: z.literal("conflict"), current: dispatchSchema }).readonly(),
|
|
19
|
-
z.strictObject({ kind: z.literal("publication-failed"), diagnostic: z.string() }).readonly(),
|
|
20
|
-
]);
|
|
21
12
|
function pathFor(akumaId) {
|
|
22
13
|
return `${DISPATCH_PREFIX}${createHash("sha256").update(akumaId).digest("hex")}${DISPATCH_SUFFIX}`;
|
|
23
14
|
}
|
|
@@ -1,52 +1,23 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
3
|
import { changeId, contractHead, contractId, snapshotId, } from "../core/facts/types.js";
|
|
4
|
+
function validatedString(validate, message) {
|
|
5
|
+
return z.string().transform((value, context) => {
|
|
6
|
+
try {
|
|
7
|
+
return validate(value);
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
context.addIssue({ code: "custom", message });
|
|
11
|
+
return z.NEVER;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
}
|
|
4
15
|
// Structural admission reuses the pure identity constructors; physical minting remains distinct.
|
|
5
|
-
export const contractIdSchema =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
context.addIssue({ code: "custom", message: "invalid contractId" });
|
|
11
|
-
return z.NEVER;
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
export const snapshotIdSchema = z.string().transform((value, context) => {
|
|
15
|
-
try {
|
|
16
|
-
return snapshotId(value);
|
|
17
|
-
}
|
|
18
|
-
catch {
|
|
19
|
-
context.addIssue({ code: "custom", message: "invalid snapshotId" });
|
|
20
|
-
return z.NEVER;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
export const contractHeadSchema = z.string().transform((value, context) => {
|
|
24
|
-
try {
|
|
25
|
-
return contractHead(value);
|
|
26
|
-
}
|
|
27
|
-
catch {
|
|
28
|
-
context.addIssue({ code: "custom", message: "invalid ContractHead" });
|
|
29
|
-
return z.NEVER;
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
export const changeIdSchema = z.string().transform((value, context) => {
|
|
33
|
-
try {
|
|
34
|
-
return changeId(value);
|
|
35
|
-
}
|
|
36
|
-
catch {
|
|
37
|
-
context.addIssue({ code: "custom", message: "invalid changeId" });
|
|
38
|
-
return z.NEVER;
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
export const mintedSnapshotInputSchema = z.string().transform((value, context) => {
|
|
42
|
-
try {
|
|
43
|
-
return mintSnapshotId(value);
|
|
44
|
-
}
|
|
45
|
-
catch {
|
|
46
|
-
context.addIssue({ code: "custom", message: "invalid mintSnapshotId" });
|
|
47
|
-
return z.NEVER;
|
|
48
|
-
}
|
|
49
|
-
});
|
|
16
|
+
export const contractIdSchema = validatedString(contractId, "invalid contractId");
|
|
17
|
+
export const snapshotIdSchema = validatedString(snapshotId, "invalid snapshotId");
|
|
18
|
+
export const contractHeadSchema = validatedString(contractHead, "invalid ContractHead");
|
|
19
|
+
export const changeIdSchema = validatedString(changeId, "invalid changeId");
|
|
20
|
+
export const mintedSnapshotInputSchema = validatedString(mintSnapshotId, "invalid mintSnapshotId");
|
|
50
21
|
const GIT_OBJECT_ID = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;
|
|
51
22
|
function locator(value) {
|
|
52
23
|
return createHash("sha256").update(value, "utf8").digest("hex");
|
package/build/src/git/nuke.js
CHANGED
|
@@ -56,31 +56,27 @@ async function unregisteredResidueBelongsToRepository(repository, path) {
|
|
|
56
56
|
throw error;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
/** Residue presence follows access: a path whose target is gone is already removed. */
|
|
60
|
+
async function residuePresent(path) {
|
|
61
61
|
try {
|
|
62
|
-
await access(
|
|
62
|
+
await access(path);
|
|
63
|
+
return true;
|
|
63
64
|
}
|
|
64
65
|
catch (error) {
|
|
65
66
|
if (error.code === "ENOENT")
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
throw error;
|
|
67
|
+
return false;
|
|
68
|
+
throw error;
|
|
69
69
|
}
|
|
70
|
-
|
|
70
|
+
}
|
|
71
|
+
async function removeUnregisteredResidue(repository, entry) {
|
|
72
|
+
if (!(await residuePresent(entry.path)))
|
|
71
73
|
return true;
|
|
72
74
|
if (!(await unregisteredResidueBelongsToRepository(repository, entry.path))) {
|
|
73
75
|
throw new GitResetStopError(`managed Place path has foreign custody: ${entry.path}`);
|
|
74
76
|
}
|
|
75
77
|
await rm(entry.path, { recursive: true, force: true });
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
catch (error) {
|
|
80
|
-
if (error.code === "ENOENT")
|
|
81
|
-
return true;
|
|
82
|
-
throw error;
|
|
83
|
-
}
|
|
78
|
+
if (!(await residuePresent(entry.path)))
|
|
79
|
+
return true;
|
|
84
80
|
throw new GitResetStopError(`managed Place worktree remains present: ${entry.path}`);
|
|
85
81
|
}
|
|
86
82
|
async function removeManagedWorktree(repository, entry) {
|
|
@@ -93,14 +89,8 @@ async function removeManagedWorktree(repository, entry) {
|
|
|
93
89
|
if ((await registeredWorktrees(repository)).some((candidate) => candidate.path === entry.path)) {
|
|
94
90
|
throw new GitResetStopError(`managed Place worktree remains registered: ${entry.path}`);
|
|
95
91
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
catch (error) {
|
|
100
|
-
if (error.code === "ENOENT")
|
|
101
|
-
return true;
|
|
102
|
-
throw error;
|
|
103
|
-
}
|
|
92
|
+
if (!(await residuePresent(entry.path)))
|
|
93
|
+
return true;
|
|
104
94
|
throw new GitResetStopError(`managed Place worktree remains present: ${entry.path}`);
|
|
105
95
|
}
|
|
106
96
|
async function deleteRefAt(repository, ref, expectedOid) {
|
|
@@ -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";
|
|
@@ -51,6 +52,9 @@ export type BindTargetSelection = Readonly<{
|
|
|
51
52
|
}> | Readonly<{
|
|
52
53
|
kind: "targetless";
|
|
53
54
|
}>;
|
|
55
|
+
export declare function selectExplicitTarget(repository: GitRepository, input: string): Promise<Extract<BindTargetSelection, {
|
|
56
|
+
kind: "explicit" | "contract";
|
|
57
|
+
}> | null>;
|
|
54
58
|
export declare function normalizeTargetBranch(repository: GitRepository, input: string): Promise<string | null>;
|
|
55
59
|
/**
|
|
56
60
|
* Observe bind's tender start and optional reward target without creating persistent state.
|
|
@@ -58,9 +62,9 @@ export declare function normalizeTargetBranch(repository: GitRepository, input:
|
|
|
58
62
|
* which coordinate it wants observed.
|
|
59
63
|
*/
|
|
60
64
|
export declare function observeBindCoordinates(repository: GitRepository, selection: BindTargetSelection): Promise<BindCoordinatesObservation | UnbornHeadObservation | null>;
|
|
61
|
-
export declare function
|
|
62
|
-
/** Observe
|
|
63
|
-
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>>;
|
|
64
68
|
export declare function observeActiveContractWorld(observation: GitReadObservation): Promise<ActiveContractWorldObservation>;
|
|
65
69
|
export declare function observeContractWorld(observation: GitReadObservation, requested?: readonly ContractId[]): Promise<ContractWorldObservation>;
|
|
66
70
|
export declare function observeContractsForAdmissionAt(repository: GitRepository, channel: GitDecodeChannel, ids: readonly ContractId[], selection?: GitTreeSelection): Promise<GitDecisionObservation>;
|
package/build/src/git/observe.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { decodeJournal } from "../core/facts/codec.js";
|
|
2
2
|
import { AuthorityCorruptionError } from "../core/facts/errors.js";
|
|
3
3
|
import { foldJournal } from "../core/facts/fold.js";
|
|
4
|
+
import { contractId, } from "../core/facts/types.js";
|
|
4
5
|
import { resolveContractTarget } from "./target.js";
|
|
5
6
|
import { contractJournalPath, contractJournalPaths, mintContractHead, mintSnapshotId, } from "./identity.js";
|
|
6
7
|
import { currentBranch, isKeiyakuOwnedRef } from "./repository.js";
|
|
@@ -34,6 +35,18 @@ export function deliveryTargetObserver(observation) {
|
|
|
34
35
|
return { head, drift: unavailable || (integration !== null && head !== expected) };
|
|
35
36
|
};
|
|
36
37
|
}
|
|
38
|
+
export async function selectExplicitTarget(repository, input) {
|
|
39
|
+
if (input.startsWith("kei/")) {
|
|
40
|
+
try {
|
|
41
|
+
return { kind: "contract", contractId: contractId(input) };
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const target = await normalizeTargetBranch(repository, input);
|
|
48
|
+
return target === null ? null : { kind: "explicit", target };
|
|
49
|
+
}
|
|
37
50
|
const TARGET_COORDINATES_FORMAT = "%(refname)%00%(objectname)%00";
|
|
38
51
|
export async function normalizeTargetBranch(repository, input) {
|
|
39
52
|
if (input.includes("\0"))
|
|
@@ -192,31 +205,35 @@ function enumerateContractObservations(git, blobs, journalClass) {
|
|
|
192
205
|
}
|
|
193
206
|
return observations;
|
|
194
207
|
}
|
|
195
|
-
export function
|
|
208
|
+
export function observedContractJournalPaths(observation, journalClass) {
|
|
196
209
|
return [...observation.snapshot.paths].flatMap(([path, entry]) => {
|
|
197
|
-
|
|
210
|
+
const matched = CONTRACT_JOURNAL_PATH.exec(path)?.[1];
|
|
211
|
+
if (matched === undefined || (journalClass !== undefined && matched !== journalClass))
|
|
198
212
|
return [];
|
|
199
213
|
if (entry.type !== "blob")
|
|
200
214
|
throw new AuthorityCorruptionError(`journal path is not a blob: ${path}`);
|
|
201
215
|
return [path];
|
|
202
216
|
});
|
|
203
217
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
const git = observation.snapshot;
|
|
207
|
-
const journals = activeContractJournalPaths(observation).map((path) => [path, git.paths.get(path)]);
|
|
208
|
-
const results = await observation.readBlobs(journals.map(([, entry]) => entry.oid));
|
|
218
|
+
async function readJournalBlobs(entries, readBlobsAt) {
|
|
219
|
+
const results = await readBlobsAt(entries.map(([, entry]) => entry.oid));
|
|
209
220
|
const blobs = new Map();
|
|
210
|
-
for (const [path, entry] of
|
|
221
|
+
for (const [path, entry] of entries) {
|
|
211
222
|
const result = results.get(entry.oid);
|
|
212
223
|
if (result?.kind !== "present")
|
|
213
224
|
throw new AuthorityCorruptionError(`missing Git journal object: ${path}`);
|
|
214
225
|
blobs.set(entry.oid, result.bytes);
|
|
215
226
|
}
|
|
216
|
-
return
|
|
227
|
+
return blobs;
|
|
228
|
+
}
|
|
229
|
+
/** Observe selected journal classes without following their prerequisite edges. */
|
|
230
|
+
export async function observeContractJournals(observation, journalClass) {
|
|
231
|
+
const git = observation.snapshot;
|
|
232
|
+
const journals = observedContractJournalPaths(observation, journalClass).map((path) => [path, git.paths.get(path)]);
|
|
233
|
+
return enumerateContractObservations(git, await readJournalBlobs(journals, observation.readBlobs), journalClass);
|
|
217
234
|
}
|
|
218
235
|
export async function observeActiveContractWorld(observation) {
|
|
219
|
-
const contracts = await
|
|
236
|
+
const contracts = await observeContractJournals(observation, "active");
|
|
220
237
|
const prerequisites = [...new Set([...contracts.values()].flatMap((record) => record.state?.terms.after ?? []))];
|
|
221
238
|
const dependencyRecords = await observeTargetedContractsAt(observation, prerequisites);
|
|
222
239
|
return {
|
|
@@ -230,14 +247,7 @@ export async function observeActiveContractWorld(observation) {
|
|
|
230
247
|
export async function observeContractWorld(observation, requested = []) {
|
|
231
248
|
const git = observation.snapshot;
|
|
232
249
|
const journals = [...git.paths].filter(([path, entry]) => /^contracts\/(?:active|terminal)\//u.test(path) && path.endsWith(".jsonl") && entry.type === "blob");
|
|
233
|
-
const
|
|
234
|
-
const blobs = new Map();
|
|
235
|
-
for (const [path, entry] of journals) {
|
|
236
|
-
const result = results.get(entry.oid);
|
|
237
|
-
if (result?.kind !== "present")
|
|
238
|
-
throw new AuthorityCorruptionError(`missing Git journal object: ${path}`);
|
|
239
|
-
blobs.set(entry.oid, result.bytes);
|
|
240
|
-
}
|
|
250
|
+
const blobs = await readJournalBlobs(journals, observation.readBlobs);
|
|
241
251
|
const contracts = new Map(enumerateContractObservations(git, blobs));
|
|
242
252
|
for (const id of requested) {
|
|
243
253
|
if (!contracts.has(id))
|
|
@@ -257,14 +267,7 @@ async function observeTargetedContractsFromSnapshotAt(snapshot, readBlobsAt, ids
|
|
|
257
267
|
const journal = snapshot.paths.get(path);
|
|
258
268
|
return journal?.type === "blob" ? [[path, journal]] : [];
|
|
259
269
|
});
|
|
260
|
-
const
|
|
261
|
-
const blobs = new Map();
|
|
262
|
-
for (const [path, entry] of entries) {
|
|
263
|
-
const result = results.get(entry.oid);
|
|
264
|
-
if (result?.kind !== "present")
|
|
265
|
-
throw new AuthorityCorruptionError(`missing Git journal object: ${path}`);
|
|
266
|
-
blobs.set(entry.oid, result.bytes);
|
|
267
|
-
}
|
|
270
|
+
const blobs = await readJournalBlobs(entries, readBlobsAt);
|
|
268
271
|
const contracts = new Map();
|
|
269
272
|
for (const id of ids)
|
|
270
273
|
contracts.set(id, observeFromGit(snapshot, id, blobs));
|
package/build/src/git/process.js
CHANGED
|
@@ -30,6 +30,14 @@ export function gitChildEnvironment(environment) {
|
|
|
30
30
|
}
|
|
31
31
|
return { ...inherited, ...environment };
|
|
32
32
|
}
|
|
33
|
+
function gitProcessOptions(repository, args, environment) {
|
|
34
|
+
return {
|
|
35
|
+
argv: [repository.gitPath, ...args],
|
|
36
|
+
cwd: repository.effectiveCwd,
|
|
37
|
+
env: gitChildEnvironment(environment),
|
|
38
|
+
...(repository.signal === undefined ? {} : { signal: repository.signal }),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
33
41
|
function commandError(command, error) {
|
|
34
42
|
const candidate = error;
|
|
35
43
|
const stderr = candidate.stderr === undefined ? Buffer.alloc(0) : Buffer.from(candidate.stderr);
|
|
@@ -51,12 +59,7 @@ export async function executeGit(repository, args, input, environment) {
|
|
|
51
59
|
const stderr = [];
|
|
52
60
|
let stderrBytes = 0;
|
|
53
61
|
let inputError;
|
|
54
|
-
const owned = spawnCancellableProcess(
|
|
55
|
-
argv: [repository.gitPath, ...args],
|
|
56
|
-
cwd: repository.effectiveCwd,
|
|
57
|
-
env: gitChildEnvironment(environment),
|
|
58
|
-
...(repository.signal === undefined ? {} : { signal: repository.signal }),
|
|
59
|
-
});
|
|
62
|
+
const owned = spawnCancellableProcess(gitProcessOptions(repository, args, environment));
|
|
60
63
|
const child = owned.child;
|
|
61
64
|
child.stdout.on("data", (chunk) => stdout.push(chunk));
|
|
62
65
|
child.stderr.on("data", (chunk) => {
|
|
@@ -127,12 +130,7 @@ export async function runGitPipe(repository, sourceArgs, sinkArgs) {
|
|
|
127
130
|
const processes = [];
|
|
128
131
|
const pending = [];
|
|
129
132
|
const start = (args) => {
|
|
130
|
-
const owned = spawnCancellableProcess(
|
|
131
|
-
argv: [repository.gitPath, ...args],
|
|
132
|
-
cwd: repository.effectiveCwd,
|
|
133
|
-
env: gitChildEnvironment(),
|
|
134
|
-
...(repository.signal === undefined ? {} : { signal: repository.signal }),
|
|
135
|
-
});
|
|
133
|
+
const owned = spawnCancellableProcess(gitProcessOptions(repository, args));
|
|
136
134
|
processes.push(owned);
|
|
137
135
|
const { child } = owned;
|
|
138
136
|
const stderr = [];
|
|
@@ -199,12 +197,7 @@ export async function runGitPipe(repository, sourceArgs, sinkArgs) {
|
|
|
199
197
|
}
|
|
200
198
|
}
|
|
201
199
|
export async function consumeGitStdout(repository, args, consume) {
|
|
202
|
-
const result = await consumeProcessStdout(
|
|
203
|
-
argv: [repository.gitPath, ...args],
|
|
204
|
-
cwd: repository.effectiveCwd,
|
|
205
|
-
env: gitChildEnvironment(),
|
|
206
|
-
...(repository.signal === undefined ? {} : { signal: repository.signal }),
|
|
207
|
-
}, consume);
|
|
200
|
+
const result = await consumeProcessStdout(gitProcessOptions(repository, args), consume);
|
|
208
201
|
const { outcome } = result;
|
|
209
202
|
if (outcome.kind === "terminal" && outcome.code === 0)
|
|
210
203
|
return;
|
|
@@ -28,14 +28,15 @@ export type GitDecodeChannel = Readonly<{
|
|
|
28
28
|
readonly [gitDecodeChannelBrand]: true;
|
|
29
29
|
readObjects(oids: readonly GitOid[]): Promise<ReadonlyMap<GitOid, GitObjectResult>>;
|
|
30
30
|
}>;
|
|
31
|
+
type TreeObservation = Readonly<{
|
|
32
|
+
paths: ReadonlyMap<string, TreeEntry>;
|
|
33
|
+
directories: ReadonlyMap<string, ReadonlyMap<string, TreeEntry>>;
|
|
34
|
+
}>;
|
|
31
35
|
export type GitTreeSelection = Readonly<{
|
|
32
36
|
paths?: readonly string[];
|
|
33
37
|
subtrees?: readonly string[];
|
|
34
38
|
}>;
|
|
35
|
-
export declare function readGitTreeSelection(channel: GitDecodeChannel, root: GitOid, selection: GitTreeSelection): Promise<
|
|
36
|
-
paths: ReadonlyMap<string, TreeEntry>;
|
|
37
|
-
directories: ReadonlyMap<string, ReadonlyMap<string, TreeEntry>>;
|
|
38
|
-
}>>;
|
|
39
|
+
export declare function readGitTreeSelection(channel: GitDecodeChannel, root: GitOid, selection: GitTreeSelection): Promise<TreeObservation>;
|
|
39
40
|
export declare function withGitDecodeChannel<Value>(repository: GitRepository, consume: (channel: GitDecodeChannel) => Value | PromiseLike<Value>, onRetirementFailure?: (error: unknown) => void): Promise<Value>;
|
|
40
41
|
/**
|
|
41
42
|
* Blob-only reads over a decode channel: a missing object stays missing, and a present
|
|
@@ -37,6 +37,8 @@ type RegisteredWorktree = Readonly<{
|
|
|
37
37
|
}>;
|
|
38
38
|
export declare function registeredWorktrees(repository: GitRepository): Promise<readonly RegisteredWorktree[]>;
|
|
39
39
|
export declare function registeredWorktreePaths(repository: GitRepository): Promise<readonly string[]>;
|
|
40
|
+
/** Absence is ENOENT on the path entry itself: a dangling symlink is present residue, not a missing path. */
|
|
41
|
+
export declare function pathExists(path: string): Promise<boolean>;
|
|
40
42
|
export declare function repositoryAt(cwd: string, gitPath?: string): Promise<GitRepository>;
|
|
41
43
|
export declare function commonGitDirectory(repository: GitRepository): string;
|
|
42
44
|
/** Read one worktree's attached branch, or null for detached HEAD. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { KeiyakuError } from "../errors.js";
|
|
2
2
|
import { isAbsolute, resolve } from "node:path";
|
|
3
|
-
import { realpath } from "node:fs/promises";
|
|
3
|
+
import { lstat, realpath } from "node:fs/promises";
|
|
4
4
|
import { AuthorityCorruptionError } from "../core/facts/errors.js";
|
|
5
5
|
import { gitObjectId } from "./identity.js";
|
|
6
6
|
import { executeGit, GitPlumbingError } from "./process.js";
|
|
@@ -82,6 +82,18 @@ export async function registeredWorktrees(repository) {
|
|
|
82
82
|
export async function registeredWorktreePaths(repository) {
|
|
83
83
|
return (await registeredWorktrees(repository)).map((worktree) => worktree.path);
|
|
84
84
|
}
|
|
85
|
+
/** Absence is ENOENT on the path entry itself: a dangling symlink is present residue, not a missing path. */
|
|
86
|
+
export async function pathExists(path) {
|
|
87
|
+
try {
|
|
88
|
+
await lstat(path);
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
if (error.code === "ENOENT")
|
|
93
|
+
return false;
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
85
97
|
export async function repositoryAt(cwd, gitPath = "git") {
|
|
86
98
|
if (typeof cwd !== "string" || cwd.length === 0) {
|
|
87
99
|
throw new Error("repository path must be a nonempty string");
|
package/build/src/git/scratch.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { createHash, randomBytes } from "node:crypto";
|
|
3
|
-
import {
|
|
3
|
+
import { realpath, unlink } from "node:fs/promises";
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
5
|
import { basename, dirname, join } from "node:path";
|
|
6
6
|
import { acquireSqliteTransactionLock, tryAcquireSqliteTransactionLock, } from "../coordination/sqlite-transaction-lock.js";
|
|
7
7
|
import { contractLocator, gitRefLocator, gitObjectIdForSnapshot } from "./identity.js";
|
|
8
8
|
import { executeGit } from "./process.js";
|
|
9
|
-
import { registeredWorktreePaths } from "./repository.js";
|
|
9
|
+
import { pathExists, registeredWorktreePaths } from "./repository.js";
|
|
10
10
|
const SCRATCH_PREFIX = "keiyaku-v4-verify-";
|
|
11
11
|
const SCRATCH_ROOT = await realpath(tmpdir());
|
|
12
12
|
const SCRATCH_PATTERN = /^keiyaku-v4-verify-([0-9a-f]{24}|[0-9a-f]{64}-[0-9a-f]{64}-[0-9a-f]{64})$/;
|
|
@@ -59,18 +59,6 @@ async function* collectableScratchWorktrees(paths, terminalPrefix) {
|
|
|
59
59
|
yield { path, lockPath, release: () => lock.close() };
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
/** Absence is ENOENT on the path entry itself: a dangling symlink is present residue, not a missing path. */
|
|
63
|
-
async function pathExists(path) {
|
|
64
|
-
try {
|
|
65
|
-
await lstat(path);
|
|
66
|
-
return true;
|
|
67
|
-
}
|
|
68
|
-
catch (error) {
|
|
69
|
-
if (error.code === "ENOENT")
|
|
70
|
-
return false;
|
|
71
|
-
throw error;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
62
|
async function removeScratch(repository, path) {
|
|
75
63
|
const removal = AbortSignal.timeout(SCRATCH_REMOVAL_TIMEOUT_MS);
|
|
76
64
|
const retirementRepository = { ...repository, signal: removal };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CANDIDATE_PIN_REF_NAMESPACE, isKeiyakuOwnedRef, readRef, writeCommit } from "./repository.js";
|
|
1
|
+
import { CANDIDATE_PIN_REF_NAMESPACE, isKeiyakuOwnedRef, pathExists, readRef, writeCommit, } from "./repository.js";
|
|
3
2
|
import { contractPhysicalName, gitObjectIdForSnapshot, mintSnapshotId } from "./identity.js";
|
|
4
3
|
import { withGitReadObservation } from "./read-observation.js";
|
|
5
4
|
import { observeContractWorld } from "./observe.js";
|
|
@@ -8,17 +7,6 @@ import { runDestroyHooks } from "./hooks.js";
|
|
|
8
7
|
import { terminalSealExpectations as decodeTerminalSealExpectations, terminalSealSnapshots, observeTerminalWorkspace, } from "./terminal-seal.js";
|
|
9
8
|
import { GitPlumbingError, executeGit } from "./process.js";
|
|
10
9
|
import { worktreePath } from "./workspace.js";
|
|
11
|
-
async function pathExists(path) {
|
|
12
|
-
try {
|
|
13
|
-
await lstat(path);
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
catch (error) {
|
|
17
|
-
if (error.code === "ENOENT")
|
|
18
|
-
return false;
|
|
19
|
-
throw error;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
10
|
/** Attempt removal once. Retention is a lag carrying its reason; no effect claims the worktree state after it. */
|
|
23
11
|
async function removeTerminalWorktree(repository, topology, path) {
|
|
24
12
|
const registered = topology.paths.has(path);
|
|
@@ -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,10 @@ 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";
|
|
14
|
+
export type { InvocationWaitMember, InvocationWaitResult } from "./library/keiyaku-wait.js";
|
|
13
15
|
export type { KeiyakuRunOptions, VerbEntry, VerbName, VerbInput, VerbOutput, VerbProgress, VerbRun, VerbRunFor, VerbDisposition, VerbCompletion, } from "./library/keiyaku-verbs.js";
|
|
14
16
|
export { Keis } from "./library/contract-composition.js";
|
|
15
17
|
export type { KeisReconcile, ReconcileInput } from "./library/contract-composition.js";
|
|
@@ -26,14 +28,15 @@ export type { AkumaAddressRefusal, AkumaSetAddressInput } from "./library/addres
|
|
|
26
28
|
export type { SpawnProgress, SpawnWaitObserver } from "./library/akuma-creation.js";
|
|
27
29
|
export type { WhoamiFacts } from "./library/keiyaku-identity.js";
|
|
28
30
|
export type { ChangeId, ContractHead, ContractId, ContractState, ContractTarget, JournalEntry as Fact, FactKind, SnapshotId, } from "./core/facts/types.js";
|
|
31
|
+
export type { GateStaleReason } from "./core/facts/gate.js";
|
|
29
32
|
export { Kanshi } from "./kanshi/index.js";
|
|
30
|
-
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";
|
|
31
34
|
export { AkumaAddressError, AkumaWorldScopeError, Akumas } from "./library/akumas.js";
|
|
32
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";
|
|
33
36
|
export type { ContinuationReport } from "./library/continuation.js";
|
|
34
37
|
export type { ContractWaitInput, ContractWaitOptions, ContractWaitMember, ContractWaitResult, } from "./library/contract-wait.js";
|
|
35
38
|
export type { AbandonOutcome, AmendOutcome, ArcOutcome, DeliveryPreviewInput, DeliveryPreviewOutcome, BindOutcome, DeliverOutcome, MutationObservation, ReviewOutcome, VerifyOutcome, } from "./library/contract-outcomes.js";
|
|
36
|
-
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";
|
|
37
40
|
export { nukeKeiyaku as nuke } from "./library/nuke.js";
|
|
38
41
|
export type { NukeInput, NukeResult } from "./library/nuke.js";
|
|
39
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
|
]);
|