@astrosheep/keiyaku 4.5.19 → 4.5.21
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 +4 -4
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +14 -7
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +53 -20
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/references/automation.md +237 -0
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/SKILL.md +6 -7
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-task/SKILL.md +2 -4
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +3 -3
- package/build/src/akuma/akuma-handle.d.ts +5 -1
- package/build/src/akuma/akuma-handle.js +4 -1
- package/build/src/akuma/akuma-instance.d.ts +7 -2
- package/build/src/akuma/akuma-instance.js +14 -7
- package/build/src/akuma/akuma-observe.d.ts +11 -0
- package/build/src/akuma/akuma-observe.js +23 -0
- package/build/src/akuma/akuma-product.d.ts +2 -0
- package/build/src/akuma/akuma-product.js +6 -0
- package/build/src/akuma/akuma.d.ts +20 -1
- package/build/src/akuma/akuma.js +2 -0
- package/build/src/akuma/allowed.d.ts +20 -0
- package/build/src/akuma/allowed.js +11 -0
- package/build/src/akuma/archetype.js +3 -0
- package/build/src/akuma/body.d.ts +25 -5
- package/build/src/akuma/body.js +70 -31
- package/build/src/akuma/call-request.d.ts +5 -0
- package/build/src/akuma/call-request.js +14 -4
- package/build/src/akuma/fleet-execution.d.ts +28 -0
- package/build/src/akuma/fleet-execution.js +36 -4
- package/build/src/akuma/fleet-observation.d.ts +54 -0
- package/build/src/akuma/fleet-request.d.ts +10 -0
- package/build/src/akuma/fleet-request.js +13 -3
- package/build/src/akuma/heart/facts.d.ts +2 -0
- package/build/src/akuma/heart/index.d.ts +1 -0
- package/build/src/akuma/heart/index.js +4 -1
- package/build/src/akuma/heart/rows.d.ts +2 -0
- package/build/src/akuma/heart/rows.js +7 -5
- package/build/src/akuma/heart/schema.d.ts +1 -1
- package/build/src/akuma/heart/schema.js +3 -1
- package/build/src/akuma/heart/tells.js +6 -5
- package/build/src/akuma/heart/timeline.js +1 -1
- package/build/src/akuma/provider-recipe.d.ts +1 -0
- package/build/src/akuma/provider-recipe.js +5 -0
- package/build/src/akuma/provider.d.ts +1 -1
- package/build/src/akuma/provider.js +1 -1
- package/build/src/akuma/providers/acp/core.js +3 -6
- package/build/src/akuma/providers/acp/index.js +3 -0
- package/build/src/akuma/providers/claude/index.js +10 -10
- package/build/src/akuma/providers/codex-app-server/index.js +12 -11
- package/build/src/akuma/providers/execution-environment.d.ts +6 -0
- package/build/src/akuma/providers/execution-environment.js +24 -0
- package/build/src/akuma/providers/grok-build/index.js +3 -0
- package/build/src/akuma/providers/opencode-sdk/index.js +32 -23
- package/build/src/akuma/providers/opencode-sdk/session.d.ts +8 -1
- package/build/src/akuma/providers/opencode-sdk/session.js +6 -5
- package/build/src/akuma/providers/pi/events.js +7 -2
- package/build/src/akuma/providers/pi/index.js +5 -2
- package/build/src/akuma/request-observation.d.ts +45 -0
- package/build/src/akuma/request-observation.js +162 -0
- package/build/src/akuma/request-rendezvous.d.ts +6 -3
- package/build/src/akuma/request-rendezvous.js +80 -14
- package/build/src/akuma/request-serve.js +27 -4
- package/build/src/akuma/request-wire.d.ts +5 -0
- package/build/src/akuma/request-wire.js +2 -0
- package/build/src/akuma/turn-drive.d.ts +1 -0
- package/build/src/akuma/turn-drive.js +2 -0
- package/build/src/akuma-body.js +5 -0
- package/build/src/body/amend.js +6 -4
- package/build/src/body/decode.d.ts +3 -1
- package/build/src/body/decode.js +53 -17
- package/build/src/body/region.d.ts +9 -1
- package/build/src/body/region.js +87 -12
- package/build/src/body/render.js +1 -1
- package/build/src/body/verification.d.ts +3 -1
- package/build/src/body/verification.js +4 -1
- package/build/src/cli/accepted.js +19 -2
- package/build/src/cli/commands/akuma-invoke.d.ts +3 -1
- package/build/src/cli/commands/akuma-invoke.js +134 -14
- package/build/src/cli/commands/akuma.js +24 -12
- package/build/src/cli/commands/contract-help.d.ts +15 -15
- package/build/src/cli/commands/contract-help.js +45 -19
- package/build/src/cli/commands/contract-invoke.d.ts +3 -0
- package/build/src/cli/commands/contract-invoke.js +25 -11
- package/build/src/cli/commands/contract.js +6 -4
- package/build/src/cli/commands/install.d.ts +1 -1
- package/build/src/cli/commands/install.js +1 -1
- package/build/src/cli/commands/status-set.js +15 -24
- package/build/src/cli/commands/task.js +18 -18
- package/build/src/cli/invoke.d.ts +3 -0
- package/build/src/cli/invoke.js +58 -23
- package/build/src/cli/main.js +5 -0
- package/build/src/cli/parse.d.ts +3 -0
- package/build/src/cli/parse.js +26 -4
- package/build/src/cli/render/akuma-activity.d.ts +100 -2
- package/build/src/cli/render/akuma-activity.js +485 -40
- package/build/src/cli/render/akuma.d.ts +10 -0
- package/build/src/cli/render/akuma.js +31 -21
- package/build/src/cli/render/audit.js +1 -1
- package/build/src/cli/render/board.js +1 -1
- package/build/src/cli/render/catalog.js +16 -13
- package/build/src/cli/render/contract-history.js +39 -10
- package/build/src/cli/render/contract-observation.js +10 -6
- package/build/src/cli/render/contract.js +109 -106
- package/build/src/cli/render/execution-progress.d.ts +26 -0
- package/build/src/cli/render/execution-progress.js +178 -0
- package/build/src/cli/render/kanshi-akuma.js +27 -39
- package/build/src/cli/render/kanshi.js +33 -26
- package/build/src/cli/render/nuke.js +1 -1
- package/build/src/cli/render/receipt.d.ts +1 -1
- package/build/src/cli/render/receipt.js +6 -6
- package/build/src/cli/render/refusal.js +10 -7
- package/build/src/cli/render/region.js +1 -1
- package/build/src/cli/render/settings.js +12 -2
- package/build/src/cli/render/status-line.d.ts +30 -0
- package/build/src/cli/render/status-line.js +58 -0
- package/build/src/cli/render/status-set.js +1 -1
- package/build/src/cli/render/task.d.ts +2 -0
- package/build/src/cli/render/task.js +11 -7
- package/build/src/cli/render/terminal.d.ts +0 -1
- package/build/src/cli/render/terminal.js +47 -15
- package/build/src/cli/result.d.ts +1 -0
- package/build/src/cli/runtime.d.ts +2 -0
- package/build/src/cli/runtime.js +36 -4
- package/build/src/cli/usage.js +2 -2
- package/build/src/cli/version.d.ts +1 -0
- package/build/src/cli/version.js +25 -0
- package/build/src/git/hooks.d.ts +13 -1
- package/build/src/git/hooks.js +2 -1
- package/build/src/git/workspace.d.ts +1 -1
- package/build/src/git/workspace.js +1 -1
- package/build/src/identity/mint.d.ts +13 -0
- package/build/src/identity/mint.js +26 -0
- package/build/src/identity/normalize.d.ts +4 -0
- package/build/src/identity/normalize.js +30 -0
- package/build/src/index.d.ts +2 -0
- package/build/src/index.js +1 -0
- package/build/src/kanshi/read.js +17 -4
- package/build/src/kanshi/report.d.ts +1 -0
- package/build/src/library/akuma-creation.d.ts +2 -0
- package/build/src/library/akuma-creation.js +34 -18
- package/build/src/library/audit.d.ts +2 -0
- package/build/src/library/audit.js +1 -0
- package/build/src/library/bind.js +18 -16
- package/build/src/library/composition.d.ts +1 -0
- package/build/src/library/contract-bind.d.ts +3 -1
- package/build/src/library/contract-bind.js +5 -3
- package/build/src/library/contract-execution.d.ts +2 -0
- package/build/src/library/contract-execution.js +15 -1
- package/build/src/library/contract-forwarding.d.ts +4 -0
- package/build/src/library/contract-forwarding.js +3 -0
- package/build/src/library/contract-handle.d.ts +7 -0
- package/build/src/library/contract-handle.js +25 -0
- package/build/src/library/contract-operations.d.ts +7 -2
- package/build/src/library/contract-operations.js +21 -1
- package/build/src/library/contract-types.d.ts +1 -0
- package/build/src/library/execution-result.d.ts +2 -2
- package/build/src/library/execution.d.ts +8 -0
- package/build/src/library/execution.js +102 -0
- package/build/src/library/fleet.d.ts +4 -1
- package/build/src/library/fleet.js +32 -8
- package/build/src/library/keiyaku.d.ts +2 -0
- package/build/src/library/mutation.js +15 -7
- package/build/src/plugin/akuma-signals.d.ts +6 -0
- package/build/src/plugin/akuma-signals.js +9 -1
- package/build/src/plugin/public.d.ts +6 -2
- package/build/src/plugin/runtime.d.ts +1 -3
- package/build/src/plugin/runtime.js +95 -103
- package/build/src/protocol/amend.js +4 -3
- package/build/src/protocol/attempt.d.ts +2 -0
- package/build/src/protocol/bind.js +41 -14
- package/build/src/protocol/completion.d.ts +3 -0
- package/build/src/protocol/completion.js +35 -11
- package/build/src/protocol/deliver.js +165 -92
- package/build/src/protocol/execution-observation.d.ts +181 -0
- package/build/src/protocol/execution-observation.js +45 -0
- package/build/src/protocol/intent.d.ts +18 -22
- package/build/src/protocol/intent.js +63 -41
- package/build/src/protocol/operations.d.ts +2 -0
- package/build/src/protocol/placement.js +5 -1
- package/build/src/protocol/progress.d.ts +5 -1
- package/build/src/protocol/progress.js +10 -1
- package/build/src/protocol/read/status.d.ts +1 -0
- package/build/src/protocol/read/status.js +10 -2
- package/build/src/protocol/reintegrate.d.ts +1 -1
- package/build/src/protocol/reintegrate.js +70 -43
- package/build/src/protocol/result-codec.js +27 -11
- package/build/src/protocol/review.js +53 -30
- package/build/src/protocol/run.d.ts +83 -36
- package/build/src/protocol/run.js +90 -75
- package/build/src/runtime/proc/run.d.ts +16 -4
- package/build/src/runtime/proc/run.js +64 -22
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/build/src/settings.js +5 -14
- package/build/src/task/document.d.ts +5 -1
- package/build/src/task/document.js +6 -1
- package/build/src/verification/execution.d.ts +10 -2
- package/build/src/verification/execution.js +143 -42
- package/build/src/verification/observation.d.ts +41 -0
- package/build/src/verification/observation.js +29 -0
- package/package.json +3 -1
|
@@ -72,7 +72,9 @@ async function startTurnDrive(input) {
|
|
|
72
72
|
return { kind: "resume-unsupported" };
|
|
73
73
|
const boundTells = drainPendingTells(input.launchTells);
|
|
74
74
|
const schemaJson = input.schemaJson ?? boundTells.find((tell) => tell.schemaJson !== undefined)?.schemaJson;
|
|
75
|
+
const initiator = input.call === undefined ? boundTells[0]?.initiator : input.initiator;
|
|
75
76
|
const turn = await beginTurn(input.paths, {
|
|
77
|
+
...(initiator === undefined ? {} : { initiator }),
|
|
76
78
|
bodySequence: input.bodySequence,
|
|
77
79
|
startedAt: input.now(),
|
|
78
80
|
...(input.call === undefined ? {} : { call: input.call }),
|
package/build/src/akuma-body.js
CHANGED
|
@@ -31,6 +31,7 @@ function contractUpstream(processConfiguration) {
|
|
|
31
31
|
const [repo, configuration] = await contractDependencies(input.repoRoot, processConfiguration);
|
|
32
32
|
return await executeForwardedAudit({
|
|
33
33
|
repo,
|
|
34
|
+
...(input.observe === undefined ? {} : { observe: input.observe }),
|
|
34
35
|
contractId: input.contractId,
|
|
35
36
|
requester: input.requester,
|
|
36
37
|
includeDirty: input.includeDirty,
|
|
@@ -44,6 +45,7 @@ function contractUpstream(processConfiguration) {
|
|
|
44
45
|
const [repo, configuration] = await contractDependencies(input.repoRoot, processConfiguration);
|
|
45
46
|
return await executeForwardedDeliver({
|
|
46
47
|
repo,
|
|
48
|
+
...(input.observe === undefined ? {} : { observe: input.observe }),
|
|
47
49
|
contractId: input.contractId,
|
|
48
50
|
requester: input.requester,
|
|
49
51
|
...(input.message === undefined ? {} : { message: input.message }),
|
|
@@ -58,6 +60,7 @@ function contractUpstream(processConfiguration) {
|
|
|
58
60
|
const [repo, configuration] = await contractDependencies(input.repoRoot, processConfiguration);
|
|
59
61
|
return await executeForwardedReview({
|
|
60
62
|
repo,
|
|
63
|
+
...(input.observe === undefined ? {} : { observe: input.observe }),
|
|
61
64
|
contractId: input.contractId,
|
|
62
65
|
requester: input.requester,
|
|
63
66
|
verdict: input.verdict,
|
|
@@ -83,11 +86,13 @@ function fleetRequestPort(world) {
|
|
|
83
86
|
body: input.body,
|
|
84
87
|
tellId: input.tellId,
|
|
85
88
|
recordedAt: input.recordedAt,
|
|
89
|
+
...(input.initiator === undefined ? {} : { initiator: input.initiator }),
|
|
86
90
|
signal: input.signal,
|
|
87
91
|
}),
|
|
88
92
|
tellAnswer: async (input) => await PublicAkuma.select(world, input.target).tell(input.body, {
|
|
89
93
|
schema: Schema.json(JSON.parse(input.schemaJson), (value) => value),
|
|
90
94
|
...(input.interrupt === undefined ? {} : { interrupt: input.interrupt }),
|
|
95
|
+
...(input.initiator === undefined ? {} : { initiator: input.initiator }),
|
|
91
96
|
}),
|
|
92
97
|
kill: async (input) => {
|
|
93
98
|
const result = await executeKillAkuma({ path: world, ids: input.targets, signal: input.signal });
|
package/build/src/body/amend.js
CHANGED
|
@@ -16,11 +16,13 @@ function sections(document) {
|
|
|
16
16
|
function operationSections(document) {
|
|
17
17
|
if (document.frontmatter !== undefined)
|
|
18
18
|
refusal("amend operations may not contain frontmatter");
|
|
19
|
-
|
|
19
|
+
const openedBy = document.children.find((node) => nonblank(document, node));
|
|
20
|
+
const heading = openedBy?.type === "section" && openedBy.level === 1 ? openedBy : undefined;
|
|
21
|
+
if (indexedHeadings(indexDocument(document), { level: 1 }).length > (heading === undefined ? 0 : 1))
|
|
20
22
|
refusal("amend operations may contain H2 sections only");
|
|
21
|
-
|
|
23
|
+
const outside = [...document.children, ...(heading?.children ?? [])];
|
|
24
|
+
if (outside.some((node) => node.type !== "section" && nonblank(document, node)))
|
|
22
25
|
refusal("amend operations contain bytes outside H2 sections");
|
|
23
|
-
}
|
|
24
26
|
return sections(document).map((section) => {
|
|
25
27
|
const title = section.title.trim();
|
|
26
28
|
const match = /^(Add|Update|Replace|Append|Remove):[ ]+(.+)$/.exec(title);
|
|
@@ -70,7 +72,7 @@ function criteria(document, section) {
|
|
|
70
72
|
}
|
|
71
73
|
function verification(document, section) {
|
|
72
74
|
try {
|
|
73
|
-
return decodeVerificationDeclarations(document, section);
|
|
75
|
+
return decodeVerificationDeclarations(document, section, { requireTimeout: true });
|
|
74
76
|
}
|
|
75
77
|
catch (error) {
|
|
76
78
|
if (error instanceof VerificationDocumentError)
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { DecodedContractDocument } from "./types.js";
|
|
2
2
|
import type { VerificationDefinition } from "../verification/declaration.js";
|
|
3
|
-
export declare function decodeContractDocument(source: string
|
|
3
|
+
export declare function decodeContractDocument(source: string, options?: Readonly<{
|
|
4
|
+
requireTimeout?: boolean;
|
|
5
|
+
}>): DecodedContractDocument;
|
|
4
6
|
export declare function verificationDefinition(document: DecodedContractDocument): VerificationDefinition | null;
|
package/build/src/body/decode.js
CHANGED
|
@@ -2,20 +2,60 @@ import { mintDocumentKey, mintDocumentSegmentKey } from "./keys.js";
|
|
|
2
2
|
import { decodeDocumentEnvelope } from "./envelope.js";
|
|
3
3
|
import { directChildren, normalizeTitle, rawSlice, sectionContent } from "../markdown/query.js";
|
|
4
4
|
import { CONTRACT_SECTIONS, RESERVED_SECTIONS } from "./shape.js";
|
|
5
|
-
import { decodeRegion, RegionDocumentError } from "./region.js";
|
|
5
|
+
import { decodeRegion, regionStructure, RegionDocumentError } from "./region.js";
|
|
6
6
|
import { decodeVerificationDeclarations, VerificationDocumentError } from "./verification.js";
|
|
7
7
|
function refusal(message) {
|
|
8
8
|
throw new TypeError(message);
|
|
9
9
|
}
|
|
10
10
|
function requireSections(sections) {
|
|
11
|
+
const diagnostics = [];
|
|
11
12
|
for (const [name, spec] of Object.entries(CONTRACT_SECTIONS)) {
|
|
12
13
|
if (spec.required && !sections.has(name))
|
|
13
|
-
|
|
14
|
+
diagnostics.push(`contract document is missing ## ${spec.title}`);
|
|
14
15
|
}
|
|
16
|
+
return diagnostics;
|
|
15
17
|
}
|
|
16
18
|
function requiredSection(sections, name) {
|
|
17
19
|
return sections.get(name);
|
|
18
20
|
}
|
|
21
|
+
function criteriaStructure(document, section) {
|
|
22
|
+
const headings = directChildren(section, "heading").filter((heading) => heading.level === 3);
|
|
23
|
+
if (headings.length === 0)
|
|
24
|
+
return "Criteria must contain one or more H3 entries";
|
|
25
|
+
const before = rawSlice(document, { start: section.contentStart, end: headings[0].span.start });
|
|
26
|
+
return before.trim().length === 0 ? null : "Criteria may contain only H3 entries";
|
|
27
|
+
}
|
|
28
|
+
function verificationStructure(document, section) {
|
|
29
|
+
const blocks = directChildren(section, "code_block");
|
|
30
|
+
if (blocks.length === 0)
|
|
31
|
+
return "Verification must contain one or more fenced executor declarations";
|
|
32
|
+
const other = section.children.filter((node) => node.type !== "code_block" && rawSlice(document, node.span).trim().length > 0);
|
|
33
|
+
return other.length === 0 ? null : "Verification may contain only fenced executor declarations";
|
|
34
|
+
}
|
|
35
|
+
// Independent structural rules collect together; each predicate mirrors the
|
|
36
|
+
// fence, heading, or reserved-name check its decoder already enforces so a
|
|
37
|
+
// document with several violations is refused once with every diagnostic.
|
|
38
|
+
function structuralDiagnostics(document, sections) {
|
|
39
|
+
const diagnostics = requireSections(sections);
|
|
40
|
+
for (const name of RESERVED_SECTIONS) {
|
|
41
|
+
if (sections.has(name))
|
|
42
|
+
diagnostics.push(`${name} is not a contract Markdown section`);
|
|
43
|
+
}
|
|
44
|
+
const checks = [
|
|
45
|
+
["region", (_document, section) => regionStructure(section)],
|
|
46
|
+
["criteria", criteriaStructure],
|
|
47
|
+
["verification", verificationStructure],
|
|
48
|
+
];
|
|
49
|
+
for (const [name, check] of checks) {
|
|
50
|
+
const section = sections.get(name);
|
|
51
|
+
if (section === undefined)
|
|
52
|
+
continue;
|
|
53
|
+
const diagnostic = check(document, section);
|
|
54
|
+
if (diagnostic !== null)
|
|
55
|
+
diagnostics.push(diagnostic);
|
|
56
|
+
}
|
|
57
|
+
return diagnostics;
|
|
58
|
+
}
|
|
19
59
|
function prose(document, section) {
|
|
20
60
|
const value = sectionContent(document, section);
|
|
21
61
|
if (value.trim().length === 0)
|
|
@@ -33,12 +73,10 @@ function region(document, section) {
|
|
|
33
73
|
}
|
|
34
74
|
}
|
|
35
75
|
function criteria(document, section) {
|
|
76
|
+
const structural = criteriaStructure(document, section);
|
|
77
|
+
if (structural !== null)
|
|
78
|
+
refusal(structural);
|
|
36
79
|
const headings = directChildren(section, "heading").filter((heading) => heading.level === 3);
|
|
37
|
-
if (headings.length === 0)
|
|
38
|
-
refusal("Criteria must contain one or more H3 entries");
|
|
39
|
-
const before = rawSlice(document, { start: section.contentStart, end: headings[0].span.start });
|
|
40
|
-
if (before.trim().length > 0)
|
|
41
|
-
refusal("Criteria may contain only H3 entries");
|
|
42
80
|
const seen = new Set();
|
|
43
81
|
return headings.map((heading, index) => {
|
|
44
82
|
const title = heading.text.trim();
|
|
@@ -55,9 +93,9 @@ function criteria(document, section) {
|
|
|
55
93
|
return { title, body };
|
|
56
94
|
});
|
|
57
95
|
}
|
|
58
|
-
function verification(document, section) {
|
|
96
|
+
function verification(document, section, options) {
|
|
59
97
|
try {
|
|
60
|
-
return decodeVerificationDeclarations(document, section);
|
|
98
|
+
return decodeVerificationDeclarations(document, section, options);
|
|
61
99
|
}
|
|
62
100
|
catch (error) {
|
|
63
101
|
if (error instanceof VerificationDocumentError)
|
|
@@ -65,7 +103,7 @@ function verification(document, section) {
|
|
|
65
103
|
throw error;
|
|
66
104
|
}
|
|
67
105
|
}
|
|
68
|
-
export function decodeContractDocument(source) {
|
|
106
|
+
export function decodeContractDocument(source, options = {}) {
|
|
69
107
|
let envelope;
|
|
70
108
|
try {
|
|
71
109
|
envelope = decodeDocumentEnvelope(source, "contract");
|
|
@@ -74,11 +112,10 @@ export function decodeContractDocument(source) {
|
|
|
74
112
|
refusal(error instanceof Error ? error.message : String(error));
|
|
75
113
|
}
|
|
76
114
|
const { document, title, sections, sectionNodes } = envelope;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
115
|
+
const structural = structuralDiagnostics(document, sections);
|
|
116
|
+
if (structural.length > 0)
|
|
117
|
+
refusal(structural.join("\n"));
|
|
118
|
+
const verificationSection = sections.get("verification");
|
|
82
119
|
const extensions = [...sections.entries()]
|
|
83
120
|
.filter(([name]) => !Object.hasOwn(CONTRACT_SECTIONS, name))
|
|
84
121
|
.map(([, section]) => {
|
|
@@ -87,7 +124,6 @@ export function decodeContractDocument(source) {
|
|
|
87
124
|
refusal(`extension '${section.title}' is empty`);
|
|
88
125
|
return { title: section.title, content };
|
|
89
126
|
});
|
|
90
|
-
const verificationSection = sections.get("verification");
|
|
91
127
|
const body = {
|
|
92
128
|
title: title.title,
|
|
93
129
|
context: prose(document, requiredSection(sections, "context")),
|
|
@@ -95,7 +131,7 @@ export function decodeContractDocument(source) {
|
|
|
95
131
|
design: prose(document, requiredSection(sections, "design")),
|
|
96
132
|
region: region(document, requiredSection(sections, "region")),
|
|
97
133
|
criteria: criteria(document, requiredSection(sections, "criteria")),
|
|
98
|
-
verification: verificationSection === undefined ? [] : verification(document, verificationSection),
|
|
134
|
+
verification: verificationSection === undefined ? [] : verification(document, verificationSection, options),
|
|
99
135
|
extensions,
|
|
100
136
|
};
|
|
101
137
|
const segments = sectionNodes.map((section) => mintDocumentSegmentKey(document.source, section.span));
|
|
@@ -3,5 +3,13 @@ export declare class RegionDocumentError extends Error {
|
|
|
3
3
|
constructor(message: string);
|
|
4
4
|
}
|
|
5
5
|
export declare function assertRegionPattern(pattern: string): string;
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Structural refusals are separate from pattern compilation so a caller may aggregate every independent failure.
|
|
8
|
+
* The three authoring forms — fenced lines, list items, and bare paragraph lines — union freely. Blank lines never
|
|
9
|
+
* count, and an info string beyond the exact `txt` still implies executable content that belongs to Verification.
|
|
10
|
+
*/
|
|
11
|
+
export declare function regionStructure(section: SectionNode): string | null;
|
|
12
|
+
/** A whitespace-bearing pattern is almost certainly strayed prose; bind warns and proceeds rather than rejecting. */
|
|
13
|
+
export declare function regionWarnings(patterns: readonly string[]): readonly string[];
|
|
14
|
+
export declare function decodeRegion(_document: DocumentNode, section: SectionNode): readonly string[];
|
|
7
15
|
export declare function regionsOverlap(mine: readonly string[], theirs: readonly string[]): readonly [string, string][];
|
package/build/src/body/region.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { directChildren, rawSlice } from "../markdown/query.js";
|
|
2
1
|
export class RegionDocumentError extends Error {
|
|
3
2
|
constructor(message) {
|
|
4
3
|
super(message);
|
|
@@ -8,9 +7,6 @@ export class RegionDocumentError extends Error {
|
|
|
8
7
|
function refusal(message) {
|
|
9
8
|
throw new RegionDocumentError(message);
|
|
10
9
|
}
|
|
11
|
-
function nonblank(document, node) {
|
|
12
|
-
return rawSlice(document, node.span).trim().length > 0;
|
|
13
|
-
}
|
|
14
10
|
function compileSegment(segment, pattern) {
|
|
15
11
|
if (segment === "**")
|
|
16
12
|
return { kind: "deep" };
|
|
@@ -113,15 +109,94 @@ function patternsOverlap(left, right) {
|
|
|
113
109
|
}
|
|
114
110
|
return false;
|
|
115
111
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
112
|
+
const THEMATIC_BREAK = /^ {0,3}(?:(?:-[ \t]*){3,}|(?:\*[ \t]*){3,}|(?:_[ \t]*){3,})$/u;
|
|
113
|
+
const TABLE_DELIMITER = /^ {0,3}\|?[ \t]*:?-+:?[ \t]*(?:\|[ \t]*:?-+:?[ \t]*)*\|?[ \t]*$/u;
|
|
114
|
+
function nonblank(line) {
|
|
115
|
+
return line.trim().length > 0;
|
|
116
|
+
}
|
|
117
|
+
/** The AST has no table, thematic-break, or HTML block kind, so the Region boundary classifies that prose itself. */
|
|
118
|
+
function foreignProseKind(lines) {
|
|
119
|
+
for (const line of lines) {
|
|
120
|
+
if (THEMATIC_BREAK.test(line))
|
|
121
|
+
return "thematic break";
|
|
122
|
+
if (/^ {0,3}</u.test(line))
|
|
123
|
+
return "HTML";
|
|
124
|
+
}
|
|
125
|
+
for (let index = 1; index < lines.length; index += 1) {
|
|
126
|
+
if (lines[index - 1].includes("|") && TABLE_DELIMITER.test(lines[index]))
|
|
127
|
+
return "table";
|
|
128
|
+
}
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
function nodeKind(node) {
|
|
132
|
+
return node.type.replaceAll("_", " ");
|
|
133
|
+
}
|
|
134
|
+
function article(kind) {
|
|
135
|
+
return kind === "HTML" || /^[aeiou]/iu.test(kind) ? "an" : "a";
|
|
136
|
+
}
|
|
137
|
+
function itemLines(item) {
|
|
138
|
+
const lines = [];
|
|
139
|
+
for (const child of item.children) {
|
|
140
|
+
if (child.type === "text")
|
|
141
|
+
lines.push(...child.lines);
|
|
142
|
+
else if (child.type === "list")
|
|
143
|
+
for (const nested of child.items)
|
|
144
|
+
lines.push(...itemLines(nested));
|
|
120
145
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
146
|
+
return lines.filter(nonblank);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Structural refusals are separate from pattern compilation so a caller may aggregate every independent failure.
|
|
150
|
+
* The three authoring forms — fenced lines, list items, and bare paragraph lines — union freely. Blank lines never
|
|
151
|
+
* count, and an info string beyond the exact `txt` still implies executable content that belongs to Verification.
|
|
152
|
+
*/
|
|
153
|
+
export function regionStructure(section) {
|
|
154
|
+
for (const node of section.children) {
|
|
155
|
+
if (node.type === "code_block") {
|
|
156
|
+
if (!node.closed)
|
|
157
|
+
return "Region fence must be closed";
|
|
158
|
+
if (node.info !== "" && node.info !== "txt") {
|
|
159
|
+
return "Region fence may not carry an info string other than the exact 'txt'";
|
|
160
|
+
}
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
if (node.type === "list")
|
|
164
|
+
continue;
|
|
165
|
+
if (node.type === "text") {
|
|
166
|
+
const foreign = foreignProseKind(node.lines);
|
|
167
|
+
if (foreign !== null)
|
|
168
|
+
return `Region may not contain ${article(foreign)} ${foreign} block`;
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
const kind = nodeKind(node);
|
|
172
|
+
return `Region may not contain ${article(kind)} ${kind} block`;
|
|
173
|
+
}
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
function regionPatterns(section) {
|
|
177
|
+
const patterns = [];
|
|
178
|
+
for (const node of section.children) {
|
|
179
|
+
if (node.type === "code_block")
|
|
180
|
+
patterns.push(...node.lines.slice(1, -1).filter(nonblank));
|
|
181
|
+
else if (node.type === "list")
|
|
182
|
+
for (const item of node.items)
|
|
183
|
+
patterns.push(...itemLines(item));
|
|
184
|
+
else if (node.type === "text")
|
|
185
|
+
patterns.push(...node.lines.filter(nonblank));
|
|
186
|
+
}
|
|
187
|
+
return patterns;
|
|
188
|
+
}
|
|
189
|
+
/** A whitespace-bearing pattern is almost certainly strayed prose; bind warns and proceeds rather than rejecting. */
|
|
190
|
+
export function regionWarnings(patterns) {
|
|
191
|
+
return patterns
|
|
192
|
+
.filter((pattern) => /\s/u.test(pattern))
|
|
193
|
+
.map((pattern) => `Region pattern '${pattern}' contains whitespace and will never match a path`);
|
|
194
|
+
}
|
|
195
|
+
export function decodeRegion(_document, section) {
|
|
196
|
+
const structural = regionStructure(section);
|
|
197
|
+
if (structural !== null)
|
|
198
|
+
refusal(structural);
|
|
199
|
+
const patterns = regionPatterns(section);
|
|
125
200
|
if (patterns.length === 0)
|
|
126
201
|
refusal("Region must declare at least one path pattern");
|
|
127
202
|
return patterns.map((pattern) => compileRegionPattern(pattern).source);
|
package/build/src/body/render.js
CHANGED
|
@@ -47,7 +47,7 @@ export function renderContractBody(body, currentArc) {
|
|
|
47
47
|
section(CONTRACT_SECTIONS.context.title, body.context),
|
|
48
48
|
section(CONTRACT_SECTIONS.objective.title, body.objective),
|
|
49
49
|
section(CONTRACT_SECTIONS.design.title, body.design),
|
|
50
|
-
section(CONTRACT_SECTIONS.region.title,
|
|
50
|
+
section(CONTRACT_SECTIONS.region.title, body.region.join("\n")),
|
|
51
51
|
section(CONTRACT_SECTIONS.criteria.title, criteria),
|
|
52
52
|
...(verification.length === 0 ? [] : [section(CONTRACT_SECTIONS.verification.title, verification)]),
|
|
53
53
|
...body.extensions.map((extension) => section(extension.title, extension.content)),
|
|
@@ -4,4 +4,6 @@ export type { VerificationDeclaration, VerificationExecutor } from "../verificat
|
|
|
4
4
|
export declare class VerificationDocumentError extends Error {
|
|
5
5
|
constructor(message: string);
|
|
6
6
|
}
|
|
7
|
-
export declare function decodeVerificationDeclarations(document: DocumentNode, section: SectionNode
|
|
7
|
+
export declare function decodeVerificationDeclarations(document: DocumentNode, section: SectionNode, options?: Readonly<{
|
|
8
|
+
requireTimeout?: boolean;
|
|
9
|
+
}>): readonly VerificationDeclaration[];
|
|
@@ -6,7 +6,7 @@ export class VerificationDocumentError extends Error {
|
|
|
6
6
|
this.name = "VerificationDocumentError";
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
export function decodeVerificationDeclarations(document, section) {
|
|
9
|
+
export function decodeVerificationDeclarations(document, section, options = {}) {
|
|
10
10
|
const blocks = directChildren(section, "code_block");
|
|
11
11
|
if (blocks.length === 0)
|
|
12
12
|
throw new VerificationDocumentError("Verification must contain one or more fenced executor declarations");
|
|
@@ -31,6 +31,9 @@ export function decodeVerificationDeclarations(document, section) {
|
|
|
31
31
|
if (duration?.kind === "parsed" && duration.milliseconds === 0) {
|
|
32
32
|
throw new VerificationDocumentError("Verification timeout must be positive");
|
|
33
33
|
}
|
|
34
|
+
if (options.requireTimeout === true && duration === undefined) {
|
|
35
|
+
throw new VerificationDocumentError("Verification declarations must specify timeout=<duration>");
|
|
36
|
+
}
|
|
34
37
|
return {
|
|
35
38
|
executor: info[1],
|
|
36
39
|
script,
|
|
@@ -24,6 +24,20 @@ function acceptedEnvelope(result, coordinate) {
|
|
|
24
24
|
...(result.executionStops.length === 0 ? {} : { executionStops: result.executionStops }),
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* The completed placement's movement identity — the reference it advanced and the head it advanced from — is part
|
|
29
|
+
* of the public accepted shape, so a receipt states the movement without rebuilding it from facts or folded state.
|
|
30
|
+
*/
|
|
31
|
+
function acceptedCompletion(completion) {
|
|
32
|
+
if (completion === undefined)
|
|
33
|
+
return undefined;
|
|
34
|
+
return {
|
|
35
|
+
integration: completion.integration,
|
|
36
|
+
...(completion.predecessor === undefined ? {} : { predecessor: completion.predecessor }),
|
|
37
|
+
...(completion.target === undefined ? {} : { target: completion.target }),
|
|
38
|
+
...(completion.verification === undefined ? {} : { verification: completion.verification }),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
27
41
|
function acceptedRegion(result) {
|
|
28
42
|
if (result.overlapFailure !== undefined)
|
|
29
43
|
return { overlapFailure: result.overlapFailure };
|
|
@@ -42,6 +56,7 @@ export function acceptedBind(result, coordinates) {
|
|
|
42
56
|
verb: "bind",
|
|
43
57
|
...(result.workspace === undefined ? {} : { workspace: result.workspace }),
|
|
44
58
|
target: coordinates.target ?? null,
|
|
59
|
+
...(result.warnings === undefined ? {} : { warnings: result.warnings }),
|
|
45
60
|
...acceptedRegion(result),
|
|
46
61
|
};
|
|
47
62
|
}
|
|
@@ -56,6 +71,7 @@ export function acceptedAmend(result, coordinate) {
|
|
|
56
71
|
export function acceptedDeliver(result, coordinate) {
|
|
57
72
|
const value = result.value;
|
|
58
73
|
const attestation = attestationFor(result.facts, "verified", coordinate);
|
|
74
|
+
const completion = acceptedCompletion(value.completion);
|
|
59
75
|
const verificationVerdict = value.completion?.verification?.verdict ?? attestation?.data.verdict ?? value.verificationReuse?.verdict;
|
|
60
76
|
return {
|
|
61
77
|
...acceptedEnvelope(result, coordinate),
|
|
@@ -63,7 +79,7 @@ export function acceptedDeliver(result, coordinate) {
|
|
|
63
79
|
tenderSnapshot: value.tenderSnapshot,
|
|
64
80
|
integration: { changeId: value.integration.changeId },
|
|
65
81
|
...(value.leading === undefined ? {} : { leading: value.leading }),
|
|
66
|
-
...(
|
|
82
|
+
...(completion === undefined ? {} : { completion }),
|
|
67
83
|
...(verificationVerdict === undefined ? {} : { verificationVerdict }),
|
|
68
84
|
...(value.verification === undefined ? {} : { verification: value.verification }),
|
|
69
85
|
...(value.verificationReuse === undefined ? {} : { verificationReuse: value.verificationReuse }),
|
|
@@ -78,6 +94,7 @@ export function acceptedReview(result, coordinate) {
|
|
|
78
94
|
if (reviewAttestation === undefined)
|
|
79
95
|
throw new Error("accepted review is missing its attestation fact");
|
|
80
96
|
const verificationAttestation = attestationFor(result.facts, "verified", coordinate);
|
|
97
|
+
const completion = acceptedCompletion(value.completion);
|
|
81
98
|
const verificationVerdict = value.completion?.verification?.verdict ??
|
|
82
99
|
verificationAttestation?.data.verdict ??
|
|
83
100
|
value.verificationReuse?.verdict;
|
|
@@ -85,7 +102,7 @@ export function acceptedReview(result, coordinate) {
|
|
|
85
102
|
...acceptedEnvelope(result, coordinate),
|
|
86
103
|
verb: "review",
|
|
87
104
|
verdict: reviewAttestation.data.verdict,
|
|
88
|
-
...(
|
|
105
|
+
...(completion === undefined ? {} : { completion }),
|
|
89
106
|
...(verificationVerdict === undefined ? {} : { verificationVerdict }),
|
|
90
107
|
...(value.verification === undefined ? {} : { verification: value.verification }),
|
|
91
108
|
...(value.verificationReuse === undefined ? {} : { verificationReuse: value.verificationReuse }),
|
|
@@ -11,6 +11,7 @@ export type AkumaInvocationResult = Readonly<{
|
|
|
11
11
|
result: CallResult;
|
|
12
12
|
world: WorldRoot;
|
|
13
13
|
schemaAnswer?: unknown;
|
|
14
|
+
streamed?: boolean;
|
|
14
15
|
}> | Readonly<{
|
|
15
16
|
kind: "akuma";
|
|
16
17
|
action: "status";
|
|
@@ -21,6 +22,7 @@ export type AkumaInvocationResult = Readonly<{
|
|
|
21
22
|
action: "wait";
|
|
22
23
|
result: AkumaWaitResult;
|
|
23
24
|
alias?: string;
|
|
25
|
+
streamed?: boolean;
|
|
24
26
|
}> | Readonly<{
|
|
25
27
|
kind: "akuma";
|
|
26
28
|
action: "tell";
|
|
@@ -84,7 +86,7 @@ export type AkumaInvocationResult = Readonly<{
|
|
|
84
86
|
}>;
|
|
85
87
|
type InvokeInput = Readonly<{
|
|
86
88
|
path: WorldRoot;
|
|
87
|
-
|
|
89
|
+
executionCwd?: string;
|
|
88
90
|
home?: string;
|
|
89
91
|
settings?: Settings;
|
|
90
92
|
contract?: KeiyakuContract;
|