@astrosheep/keiyaku 4.5.11 → 4.5.13
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/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +135 -377
- package/build/integrations/pi/keiyaku.ts +11 -116
- package/build/src/akuma/akuma-errors.d.ts +1 -0
- package/build/src/akuma/akuma-errors.js +1 -0
- package/build/src/akuma/akuma-handle.d.ts +1 -0
- package/build/src/akuma/akuma-handle.js +6 -7
- package/build/src/akuma/akuma-product.d.ts +6 -8
- package/build/src/akuma/akuma-product.js +141 -57
- package/build/src/akuma/akuma.d.ts +5 -7
- package/build/src/akuma/akuma.js +1 -22
- package/build/src/akuma/archetype.d.ts +6 -5
- package/build/src/akuma/archetype.js +137 -38
- package/build/src/akuma/body.d.ts +5 -5
- package/build/src/akuma/body.js +223 -63
- package/build/src/akuma/call-input.d.ts +4 -0
- package/build/src/akuma/call-input.js +21 -0
- package/build/src/akuma/call-request.d.ts +5 -8
- package/build/src/akuma/call-request.js +28 -73
- package/build/src/akuma/fleet-execution.d.ts +26 -0
- package/build/src/akuma/fleet-execution.js +109 -0
- package/build/src/{library/fleet-result.d.ts → akuma/fleet-observation.d.ts} +13 -57
- package/build/src/{library/fleet-result.js → akuma/fleet-observation.js} +4 -25
- package/build/src/akuma/fleet-request.d.ts +122 -0
- package/build/src/akuma/fleet-request.js +168 -0
- package/build/src/akuma/heart/facts.d.ts +23 -0
- package/build/src/akuma/heart/facts.js +7 -0
- package/build/src/akuma/heart/index.d.ts +43 -4
- package/build/src/akuma/heart/index.js +107 -7
- package/build/src/akuma/heart/request-authority.d.ts +2 -0
- package/build/src/akuma/heart/request-authority.js +28 -3
- package/build/src/akuma/heart/request-rows.d.ts +2 -0
- package/build/src/akuma/heart/request-rows.js +24 -5
- package/build/src/akuma/heart/rows.d.ts +4 -1
- package/build/src/akuma/heart/rows.js +46 -19
- package/build/src/akuma/heart/schema.d.ts +1 -1
- package/build/src/akuma/heart/schema.js +28 -6
- package/build/src/akuma/heart/storage.d.ts +1 -1
- package/build/src/akuma/heart/tells.d.ts +29 -0
- package/build/src/akuma/heart/tells.js +136 -5
- package/build/src/akuma/heart/timeline.js +9 -3
- package/build/src/akuma/projection-read.js +36 -3
- package/build/src/akuma/projection.js +3 -4
- package/build/src/akuma/provider.d.ts +4 -0
- package/build/src/akuma/provider.js +56 -3
- package/build/src/akuma/providers/claude/index.js +3 -0
- package/build/src/akuma/providers/codex-app-server/index.js +14 -12
- package/build/src/akuma/providers/pi/index.js +7 -1
- package/build/src/akuma/publication.js +65 -49
- package/build/src/akuma/request-lifecycle.d.ts +5 -4
- package/build/src/akuma/request-lifecycle.js +29 -16
- package/build/src/akuma/request-rendezvous.d.ts +15 -12
- package/build/src/akuma/request-rendezvous.js +80 -51
- package/build/src/akuma/request-serve.d.ts +1 -2
- package/build/src/akuma/request-serve.js +94 -39
- package/build/src/akuma/request-wire.d.ts +57 -26
- package/build/src/akuma/request-wire.js +64 -25
- package/build/src/akuma/turn-drive.d.ts +5 -4
- package/build/src/akuma/turn-drive.js +27 -11
- package/build/src/akuma-body.d.ts +4 -6
- package/build/src/akuma-body.js +19 -17
- package/build/src/bounded-list.d.ts +8 -0
- package/build/src/bounded-list.js +14 -0
- package/build/src/cli/accepted.d.ts +1 -1
- package/build/src/cli/accepted.js +1 -0
- package/build/src/cli/commands/akuma-invoke.js +1 -25
- package/build/src/cli/commands/contract-help.d.ts +5 -2
- package/build/src/cli/commands/contract-help.js +62 -12
- package/build/src/cli/commands/contract-invoke.d.ts +5 -0
- package/build/src/cli/commands/contract-invoke.js +26 -1
- package/build/src/cli/commands/contract.js +50 -18
- package/build/src/cli/commands/task-invoke.js +10 -2
- package/build/src/cli/commands/task-query.js +3 -4
- package/build/src/cli/coordinates.d.ts +13 -0
- package/build/src/cli/coordinates.js +38 -24
- package/build/src/cli/draft.d.ts +1 -1
- package/build/src/cli/invoke.js +14 -1
- package/build/src/cli/render/akuma-activity.d.ts +0 -1
- package/build/src/cli/render/akuma-activity.js +5 -38
- package/build/src/cli/render/akuma.js +4 -1
- package/build/src/cli/render/audit.js +4 -1
- package/build/src/cli/render/catalog.js +13 -39
- package/build/src/cli/render/contract.js +4 -14
- package/build/src/cli/render/kanshi-akuma.js +3 -8
- package/build/src/cli/render/kanshi.js +8 -34
- package/build/src/cli/render/nuke.js +7 -3
- package/build/src/cli/render/receipt.d.ts +1 -0
- package/build/src/cli/render/receipt.js +8 -0
- package/build/src/cli/render/refusal.js +4 -3
- package/build/src/cli/render/task.js +4 -37
- package/build/src/cli/render/terminal.d.ts +2 -6
- package/build/src/cli/render/terminal.js +4 -9
- package/build/src/cli/result.d.ts +2 -1
- package/build/src/contract-guidance.js +13 -3
- package/build/src/contract-worktree.d.ts +1 -0
- package/build/src/contract-worktree.js +26 -2
- package/build/src/core/facts/codec.d.ts +2 -1
- package/build/src/core/facts/codec.js +3 -0
- package/build/src/core/facts/gate.d.ts +2 -1
- package/build/src/core/facts/gate.js +63 -0
- package/build/src/core/verbs/abandon.d.ts +2 -1
- package/build/src/core/verbs/abandon.js +16 -0
- package/build/src/core/verbs/amend.d.ts +2 -1
- package/build/src/core/verbs/amend.js +20 -0
- package/build/src/core/verbs/arc.d.ts +2 -1
- package/build/src/core/verbs/arc.js +16 -0
- package/build/src/core/verbs/attestation.d.ts +2 -1
- package/build/src/core/verbs/attestation.js +16 -0
- package/build/src/core/verbs/bind.d.ts +2 -1
- package/build/src/core/verbs/bind.js +16 -0
- package/build/src/core/verbs/deliver.d.ts +2 -1
- package/build/src/core/verbs/deliver.js +16 -0
- package/build/src/core/verbs/placement.d.ts +2 -1
- package/build/src/core/verbs/placement.js +58 -1
- package/build/src/dispatch/association.d.ts +13 -0
- package/build/src/dispatch/association.js +20 -0
- package/build/src/dispatch/index.d.ts +6 -0
- package/build/src/dispatch/index.js +27 -3
- package/build/src/git/hooks.d.ts +9 -1
- package/build/src/git/hooks.js +79 -1
- package/build/src/git/nuke.d.ts +2 -1
- package/build/src/git/nuke.js +6 -11
- package/build/src/git/private-state-seat.d.ts +26 -1
- package/build/src/git/private-state-seat.js +78 -13
- package/build/src/git/process.d.ts +2 -0
- package/build/src/git/reconcile.d.ts +1 -2
- package/build/src/git/reconcile.js +0 -6
- package/build/src/git/repository.d.ts +0 -2
- package/build/src/git/repository.js +27 -25
- package/build/src/git/result-codec.d.ts +29 -0
- package/build/src/git/result-codec.js +306 -0
- package/build/src/git/target-placement.js +2 -8
- package/build/src/git/workspace.d.ts +2 -0
- package/build/src/git/workspace.js +4 -0
- package/build/src/index.d.ts +1 -0
- package/build/src/kanshi/fleet.js +1 -1
- package/build/src/kanshi/read.js +55 -28
- package/build/src/kanshi/report.d.ts +4 -3
- package/build/src/kanshi/select.js +14 -1
- package/build/src/library/address.d.ts +1 -0
- package/build/src/library/address.js +4 -7
- package/build/src/library/akuma-creation.d.ts +5 -3
- package/build/src/library/akuma-creation.js +90 -33
- package/build/src/library/audit.js +2 -1
- package/build/src/library/catalog.d.ts +10 -2
- package/build/src/library/catalog.js +65 -25
- package/build/src/library/composition.d.ts +1 -0
- package/build/src/library/composition.js +1 -0
- package/build/src/library/configuration.d.ts +4 -21
- package/build/src/library/configuration.js +2 -158
- package/build/src/library/continuation.d.ts +20 -1
- package/build/src/library/continuation.js +36 -0
- package/build/src/library/contract-bind.d.ts +1 -0
- package/build/src/library/contract-bind.js +16 -5
- package/build/src/library/contract-forwarding.d.ts +2 -2
- package/build/src/library/contract-forwarding.js +18 -4
- package/build/src/library/contract-handle.js +4 -3
- package/build/src/library/contract-operations.d.ts +5 -9
- package/build/src/library/contract-operations.js +34 -47
- package/build/src/library/contract.d.ts +11 -2
- package/build/src/library/contract.js +21 -1
- package/build/src/library/delivery.d.ts +4 -1
- package/build/src/library/delivery.js +47 -0
- package/build/src/library/fleet.d.ts +4 -136
- package/build/src/library/fleet.js +31 -315
- package/build/src/library/keiyaku.d.ts +7 -3
- package/build/src/library/keiyaku.js +1 -0
- package/build/src/library/mutation.d.ts +431 -3
- package/build/src/library/mutation.js +192 -19
- package/build/src/library/nuke.d.ts +7 -1
- package/build/src/library/nuke.js +18 -4
- package/build/src/library/reconcile.d.ts +14 -0
- package/build/src/library/reconcile.js +22 -8
- package/build/src/library/refusal.d.ts +9 -1
- package/build/src/library/refusal.js +76 -0
- package/build/src/library/region.d.ts +0 -8
- package/build/src/library/region.js +1 -29
- package/build/src/library/result-codec.d.ts +2 -0
- package/build/src/library/result-codec.js +12 -0
- package/build/src/markdown/lex.js +9 -2
- package/build/src/markdown/types.d.ts +2 -1
- package/build/src/markdown/types.js +3 -1
- package/build/src/plugin/akuma-signals.d.ts +12 -0
- package/build/src/plugin/akuma-signals.js +14 -0
- package/build/src/plugin/public.d.ts +51 -0
- package/build/src/plugin/public.js +1 -0
- package/build/src/plugin/runtime.d.ts +14 -0
- package/build/src/plugin/runtime.js +357 -0
- package/build/src/protocol/amend.js +3 -3
- package/build/src/protocol/attempt.d.ts +2 -1
- package/build/src/protocol/attempt.js +1 -1
- package/build/src/protocol/audit.d.ts +1 -1
- package/build/src/protocol/audit.js +1 -1
- package/build/src/protocol/bind.d.ts +3 -1
- package/build/src/protocol/bind.js +26 -0
- package/build/src/protocol/completion.js +0 -1
- package/build/src/protocol/deliver.d.ts +1 -1
- package/build/src/protocol/deliver.js +136 -57
- package/build/src/protocol/intent.d.ts +0 -1
- package/build/src/protocol/intent.js +0 -1
- package/build/src/protocol/operations.d.ts +9 -2
- package/build/src/protocol/operations.js +16 -1
- package/build/src/protocol/outcome.d.ts +3 -0
- package/build/src/protocol/outcome.js +17 -1
- package/build/src/protocol/placement.js +10 -3
- package/build/src/protocol/read/status.d.ts +8 -0
- package/build/src/protocol/read/status.js +49 -0
- package/build/src/protocol/reintegrate.js +10 -3
- package/build/src/protocol/result-codec.d.ts +22 -0
- package/build/src/protocol/result-codec.js +442 -0
- package/build/src/protocol/review.d.ts +1 -1
- package/build/src/protocol/review.js +81 -46
- package/build/src/protocol/run.d.ts +22 -2
- package/build/src/protocol/run.js +119 -29
- package/build/src/runtime/proc/lifecycle.js +1 -1
- package/build/src/runtime/proc/line-rpc.d.ts +7 -1
- package/build/src/runtime/proc/line-rpc.js +49 -9
- package/build/src/runtime/proc/run.d.ts +0 -1
- package/build/src/runtime/proc/run.js +1 -11
- package/build/src/runtime/proc/termination.d.ts +1 -0
- package/build/src/runtime/proc/termination.js +63 -18
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/build/src/settings.d.ts +10 -0
- package/build/src/settings.js +88 -2
- package/build/src/settlement/result-codec.d.ts +2 -0
- package/build/src/settlement/result-codec.js +56 -0
- package/build/src/settlement/settle.d.ts +5 -12
- package/build/src/settlement/settle.js +60 -55
- package/build/src/task/board.d.ts +3 -0
- package/build/src/task/board.js +22 -4
- package/build/src/task/catalog.d.ts +13 -2
- package/build/src/task/catalog.js +59 -5
- package/build/src/task/compose.d.ts +4 -2
- package/build/src/task/compose.js +56 -30
- package/build/src/task/created-observation.d.ts +39 -0
- package/build/src/task/created-observation.js +26 -0
- package/build/src/task/identity.d.ts +6 -0
- package/build/src/task/identity.js +48 -7
- package/build/src/task/index.d.ts +4 -3
- package/build/src/task/index.js +19 -16
- package/build/src/task/input.d.ts +3 -1
- package/build/src/task/input.js +7 -4
- package/build/src/task/lifecycle-operations.d.ts +6 -0
- package/build/src/task/lifecycle-operations.js +116 -0
- package/build/src/task/mutation-result.d.ts +762 -20
- package/build/src/task/mutation-result.js +34 -9
- package/build/src/task/mutation.d.ts +4 -9
- package/build/src/task/mutation.js +17 -52
- package/build/src/task/operation-types.d.ts +114 -0
- package/build/src/task/operation-types.js +1 -0
- package/build/src/task/operations.d.ts +6 -113
- package/build/src/task/operations.js +75 -117
- package/build/src/task/query.d.ts +8 -11
- package/build/src/task/query.js +7 -14
- package/build/src/task/store.d.ts +11 -1
- package/build/src/task/store.js +169 -55
- package/build/src/task/view.d.ts +4 -0
- package/build/src/task/view.js +7 -0
- package/build/src/verification/declaration.d.ts +1 -0
- package/build/src/verification/declaration.js +18 -1
- package/build/src/verification/execution.d.ts +0 -1
- package/build/src/verification/execution.js +5 -5
- package/build/src/world.d.ts +0 -2
- package/build/src/world.js +3 -7
- package/package.json +17 -5
- package/build/src/cli/square-edge.d.ts +0 -7
- package/build/src/cli/square-edge.js +0 -159
- package/build/src/git/ref-migration.d.ts +0 -22
- package/build/src/git/ref-migration.js +0 -55
- package/build/src/library/contract-forwarding-reconciliation-result.d.ts +0 -102
- package/build/src/library/contract-forwarding-reconciliation-result.js +0 -92
- package/build/src/library/contract-forwarding-result.d.ts +0 -4270
- package/build/src/library/contract-forwarding-result.js +0 -521
|
@@ -19,11 +19,16 @@ export class AkumaArchetypeError extends Error {
|
|
|
19
19
|
this.name = "AkumaArchetypeError";
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function projectArchetypeDirectory(project) {
|
|
23
|
+
return project === undefined ? undefined : join(project, ".keiyaku", "akuma");
|
|
24
|
+
}
|
|
25
|
+
function homeArchetypeDirectory(home) {
|
|
23
26
|
return join(home ?? join(homedir(), ".keiyaku"), "akuma");
|
|
24
27
|
}
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
function archetypeDirectories(input) {
|
|
29
|
+
return [projectArchetypeDirectory(input.project), homeArchetypeDirectory(input.home)].filter((directory) => directory !== undefined);
|
|
30
|
+
}
|
|
31
|
+
async function pathsInDirectory(directory) {
|
|
27
32
|
try {
|
|
28
33
|
return (await readdir(directory, { withFileTypes: true }))
|
|
29
34
|
.flatMap((entry) => {
|
|
@@ -45,8 +50,37 @@ async function archetypePaths(home) {
|
|
|
45
50
|
throw error;
|
|
46
51
|
}
|
|
47
52
|
}
|
|
53
|
+
async function archetypePaths(input = {}) {
|
|
54
|
+
const scopes = await Promise.all(archetypeDirectories(input).map(pathsInDirectory));
|
|
55
|
+
const selected = new Map();
|
|
56
|
+
for (const scope of scopes) {
|
|
57
|
+
for (const entry of scope)
|
|
58
|
+
if (!selected.has(entry.name))
|
|
59
|
+
selected.set(entry.name, entry);
|
|
60
|
+
}
|
|
61
|
+
return [...selected.values()].sort((left, right) => Buffer.compare(Buffer.from(left.name), Buffer.from(right.name)));
|
|
62
|
+
}
|
|
63
|
+
function sourceLookups(name, input, source) {
|
|
64
|
+
if (source === "home" || input.project === undefined) {
|
|
65
|
+
return [{ path: join(homeArchetypeDirectory(input.home), `${name}.md`), source: "home" }];
|
|
66
|
+
}
|
|
67
|
+
return [
|
|
68
|
+
{ path: join(projectArchetypeDirectory(input.project), `${name}.md`), source: "project" },
|
|
69
|
+
{ path: join(homeArchetypeDirectory(input.home), `${name}.md`), source: "home" },
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
function rootLookups(name, input) {
|
|
73
|
+
return input.project === undefined ? sourceLookups(name, input, "home") : sourceLookups(name, input, "project");
|
|
74
|
+
}
|
|
75
|
+
function chainText(chain) {
|
|
76
|
+
return chain.join(" -> ");
|
|
77
|
+
}
|
|
78
|
+
function archetypeError(name, searched, reason, chain, guidance) {
|
|
79
|
+
const withChain = chain.length === 0 ? reason : `${reason} (base chain: ${chainText(chain)})`;
|
|
80
|
+
return new AkumaArchetypeError(name, searched, withChain, guidance);
|
|
81
|
+
}
|
|
48
82
|
export async function listArchetypes(input = {}) {
|
|
49
|
-
return (await archetypePaths(input
|
|
83
|
+
return (await archetypePaths(input)).map(({ name }) => name);
|
|
50
84
|
}
|
|
51
85
|
function archetypeField(values, key, required = false) {
|
|
52
86
|
const value = values[key];
|
|
@@ -72,7 +106,7 @@ function archetypeReadonly(values) {
|
|
|
72
106
|
throw new TypeError("Akuma readonly must be true");
|
|
73
107
|
return true;
|
|
74
108
|
}
|
|
75
|
-
function
|
|
109
|
+
function parseArchetypeFrontmatter(markdown) {
|
|
76
110
|
const lines = markdown.split(/\r?\n/u);
|
|
77
111
|
if (lines[0]?.trim() !== "---")
|
|
78
112
|
throw new TypeError("Akuma file must begin with YAML frontmatter");
|
|
@@ -86,8 +120,12 @@ function decodeArchetype(name, path, markdown) {
|
|
|
86
120
|
if (decoded === null || typeof decoded !== "object" || Array.isArray(decoded)) {
|
|
87
121
|
throw new TypeError("Akuma frontmatter must be one mapping");
|
|
88
122
|
}
|
|
89
|
-
|
|
90
|
-
|
|
123
|
+
return { lines, closing, values: decoded };
|
|
124
|
+
}
|
|
125
|
+
function decodeArchetypeFields(values) {
|
|
126
|
+
const provider = archetypeField(values, "provider");
|
|
127
|
+
const baseValue = archetypeField(values, "base");
|
|
128
|
+
const base = baseValue === undefined ? undefined : archetypeName(baseValue);
|
|
91
129
|
if ("access" in values)
|
|
92
130
|
throw new TypeError("Akuma access is not supported; use readonly: true");
|
|
93
131
|
const model = archetypeField(values, "model");
|
|
@@ -95,38 +133,115 @@ function decodeArchetype(name, path, markdown) {
|
|
|
95
133
|
const readonly = archetypeReadonly(values);
|
|
96
134
|
const network = archetypeEnum(values, "network", ["disabled", "enabled"]);
|
|
97
135
|
const description = archetypeField(values, "description");
|
|
98
|
-
const
|
|
136
|
+
const allowedPresent = "allowed" in values;
|
|
137
|
+
const allowed = allowedPresent ? effectiveAllowedActions(values.allowed) : undefined;
|
|
99
138
|
const systemPromptMode = archetypeEnum(values, "systemPromptMode", ["append", "replace"]);
|
|
139
|
+
return {
|
|
140
|
+
...(base === undefined ? {} : { base }),
|
|
141
|
+
...(provider === undefined ? {} : { provider }),
|
|
142
|
+
...(model === undefined ? {} : { model }),
|
|
143
|
+
...(effort === undefined ? {} : { effort }),
|
|
144
|
+
...(readonly === undefined ? {} : { readonly }),
|
|
145
|
+
...(network === undefined ? {} : { network }),
|
|
146
|
+
...(description === undefined ? {} : { description }),
|
|
147
|
+
...(allowed === undefined ? {} : { allowed }),
|
|
148
|
+
allowedPresent,
|
|
149
|
+
...(systemPromptMode === undefined ? {} : { systemPromptMode }),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function decodeArchetype(name, path, markdown) {
|
|
153
|
+
const { lines, closing, values } = parseArchetypeFrontmatter(markdown);
|
|
154
|
+
const fields = decodeArchetypeFields(values);
|
|
100
155
|
const systemPrompt = lines.slice(closing + 1).join("\n");
|
|
101
|
-
if (systemPromptMode !== undefined && systemPrompt.length === 0) {
|
|
156
|
+
if (fields.systemPromptMode !== undefined && systemPrompt.length === 0) {
|
|
102
157
|
throw new TypeError("Akuma systemPromptMode requires a nonempty Markdown body");
|
|
103
158
|
}
|
|
104
159
|
return Object.freeze({
|
|
105
160
|
name,
|
|
106
161
|
path,
|
|
107
|
-
|
|
108
|
-
...(
|
|
162
|
+
...(fields.base === undefined ? {} : { base: fields.base }),
|
|
163
|
+
...(fields.provider === undefined ? {} : { provider: fields.provider }),
|
|
164
|
+
...(fields.description === undefined ? {} : { description: fields.description }),
|
|
109
165
|
options: decodeProviderOptions({
|
|
110
|
-
...(model === undefined ? {} : { model }),
|
|
111
|
-
...(effort === undefined ? {} : { effort }),
|
|
112
|
-
...(network === undefined ? {} : { network }),
|
|
166
|
+
...(fields.model === undefined ? {} : { model: fields.model }),
|
|
167
|
+
...(fields.effort === undefined ? {} : { effort: fields.effort }),
|
|
168
|
+
...(fields.network === undefined ? {} : { network: fields.network }),
|
|
113
169
|
...(systemPrompt.length === 0
|
|
114
170
|
? {}
|
|
115
171
|
: {
|
|
116
172
|
systemPrompt,
|
|
117
|
-
systemPromptMode: systemPromptMode ?? "append",
|
|
173
|
+
systemPromptMode: fields.systemPromptMode ?? "append",
|
|
118
174
|
}),
|
|
119
175
|
}),
|
|
120
|
-
...(readonly === undefined ? {} : { readonly }),
|
|
176
|
+
...(fields.readonly === undefined ? {} : { readonly: fields.readonly }),
|
|
177
|
+
...(fields.allowed === undefined ? {} : { allowed: fields.allowed }),
|
|
178
|
+
allowedPresent: fields.allowedPresent,
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
function mergeArchetype(base, local) {
|
|
182
|
+
const provider = local.provider ?? base?.provider;
|
|
183
|
+
if (provider === undefined)
|
|
184
|
+
throw new TypeError("Akuma provider must be a nonblank string");
|
|
185
|
+
const options = decodeProviderOptions({ ...(base?.options ?? {}), ...local.options });
|
|
186
|
+
const allowed = local.allowedPresent ? local.allowed : (base?.allowed ?? effectiveAllowedActions(undefined));
|
|
187
|
+
return Object.freeze({
|
|
188
|
+
name: local.name,
|
|
189
|
+
path: local.path,
|
|
190
|
+
provider,
|
|
191
|
+
...(local.description === undefined
|
|
192
|
+
? base?.description === undefined
|
|
193
|
+
? {}
|
|
194
|
+
: { description: base.description }
|
|
195
|
+
: { description: local.description }),
|
|
196
|
+
options,
|
|
197
|
+
...(local.readonly === true || base?.readonly === true ? { readonly: true } : {}),
|
|
121
198
|
allowed,
|
|
122
199
|
});
|
|
123
200
|
}
|
|
201
|
+
async function resolveArchetype(name, input, source, chain = []) {
|
|
202
|
+
if (chain.includes(name)) {
|
|
203
|
+
const lookups = source === undefined ? rootLookups(name, input) : sourceLookups(name, input, source);
|
|
204
|
+
throw archetypeError(name, lookups.map(({ path }) => path), "has a cyclic base reference", [...chain, name]);
|
|
205
|
+
}
|
|
206
|
+
const lookups = source === undefined ? rootLookups(name, input) : sourceLookups(name, input, source);
|
|
207
|
+
const searched = lookups.map(({ path }) => path);
|
|
208
|
+
for (const lookup of lookups) {
|
|
209
|
+
let markdown;
|
|
210
|
+
try {
|
|
211
|
+
markdown = await readFile(lookup.path, "utf8");
|
|
212
|
+
}
|
|
213
|
+
catch (error) {
|
|
214
|
+
if (error.code === "ENOENT")
|
|
215
|
+
continue;
|
|
216
|
+
throw archetypeError(name, [lookup.path], `could not be read: ${error instanceof Error ? error.message : String(error)}`, chain);
|
|
217
|
+
}
|
|
218
|
+
let local;
|
|
219
|
+
try {
|
|
220
|
+
local = decodeArchetype(name, lookup.path, markdown);
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
throw archetypeError(name, [lookup.path], `is invalid: ${error instanceof Error ? error.message : String(error)}`, chain);
|
|
224
|
+
}
|
|
225
|
+
let inherited;
|
|
226
|
+
if (local.base !== undefined) {
|
|
227
|
+
inherited = await resolveArchetype(local.base, input, lookup.source, [...chain, name]);
|
|
228
|
+
}
|
|
229
|
+
try {
|
|
230
|
+
return mergeArchetype(inherited, local);
|
|
231
|
+
}
|
|
232
|
+
catch (error) {
|
|
233
|
+
throw archetypeError(name, [lookup.path], `is invalid: ${error instanceof Error ? error.message : String(error)}`, chain);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
const missingChain = chain.length === 0 ? chain : [...chain, name];
|
|
237
|
+
throw archetypeError(name, searched, "was not found", missingChain, chain.length === 0 ? "use `keiyaku ls aku/` to list available Akuma" : undefined);
|
|
238
|
+
}
|
|
124
239
|
export async function listArchetypeDefinitions(input = {}) {
|
|
125
240
|
// Reads still run concurrently, but the reported failure is the first invalid
|
|
126
241
|
// definition in catalog byte order, not whichever read happened to finish first.
|
|
127
|
-
const settled = await Promise.allSettled((await archetypePaths(input
|
|
242
|
+
const settled = await Promise.allSettled((await archetypePaths(input)).map(async ({ name, path }) => {
|
|
128
243
|
try {
|
|
129
|
-
const definition =
|
|
244
|
+
const definition = await resolveArchetype(name, input, undefined);
|
|
130
245
|
return Object.freeze({
|
|
131
246
|
name: definition.name,
|
|
132
247
|
...(definition.options.model === undefined ? {} : { model: definition.options.model }),
|
|
@@ -134,6 +249,8 @@ export async function listArchetypeDefinitions(input = {}) {
|
|
|
134
249
|
});
|
|
135
250
|
}
|
|
136
251
|
catch (error) {
|
|
252
|
+
if (error instanceof AkumaArchetypeError)
|
|
253
|
+
throw error;
|
|
137
254
|
throw new AkumaArchetypeError(name, [path], `is invalid: ${error instanceof Error ? error.message : String(error)}`);
|
|
138
255
|
}
|
|
139
256
|
}));
|
|
@@ -225,24 +342,6 @@ async function admitArchetype(archetype, settings, callReadonly) {
|
|
|
225
342
|
}
|
|
226
343
|
export async function loadArchetype(input) {
|
|
227
344
|
const name = archetypeName(input.name);
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
const missing = () => new AkumaArchetypeError(name, [path], "was not found", "use `keiyaku ls aku/` to list available Akuma");
|
|
231
|
-
let markdown;
|
|
232
|
-
try {
|
|
233
|
-
markdown = await readFile(path, "utf8");
|
|
234
|
-
}
|
|
235
|
-
catch (error) {
|
|
236
|
-
if (error.code === "ENOENT")
|
|
237
|
-
throw missing();
|
|
238
|
-
throw new AkumaArchetypeError(name, [path], `could not be read: ${error instanceof Error ? error.message : String(error)}`);
|
|
239
|
-
}
|
|
240
|
-
try {
|
|
241
|
-
return await admitArchetype(decodeArchetype(name, path, markdown), input.settings, input.readonly);
|
|
242
|
-
}
|
|
243
|
-
catch (error) {
|
|
244
|
-
if (error instanceof AkumaArchetypeError)
|
|
245
|
-
throw error;
|
|
246
|
-
throw new AkumaArchetypeError(name, [path], `is invalid: ${error instanceof Error ? error.message : String(error)}`);
|
|
247
|
-
}
|
|
345
|
+
const definition = await resolveArchetype(name, input, undefined);
|
|
346
|
+
return await admitArchetype(definition, input.settings, input.readonly);
|
|
248
347
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AkumaCallRequestChildLaunch } from "./call-request.js";
|
|
2
2
|
import { type SessionFact, type Soul, type TellRow } from "./heart/index.js";
|
|
3
3
|
import { type AkumaPaths } from "./identity.js";
|
|
4
|
+
import { type WorldRoot } from "../world.js";
|
|
4
5
|
import type { ProviderAdapter } from "./provider.js";
|
|
5
6
|
import type { ErasedRequestCommand } from "./request-wire.js";
|
|
6
7
|
import { type OwnedProcess, type RunLogReference } from "../runtime/proc/run.js";
|
|
@@ -13,7 +14,6 @@ export type BodyLaunch = Readonly<{
|
|
|
13
14
|
initialBody?: string;
|
|
14
15
|
refuseIfHeld?: boolean;
|
|
15
16
|
completion?: Readonly<{
|
|
16
|
-
participantName?: string;
|
|
17
17
|
contractId?: string;
|
|
18
18
|
}>;
|
|
19
19
|
}>;
|
|
@@ -49,8 +49,8 @@ type BodyRuntime = Readonly<{
|
|
|
49
49
|
now(): string;
|
|
50
50
|
spawnChild?(launch: AkumaCallRequestChildLaunch): Promise<OwnedProcess>;
|
|
51
51
|
spawnBody?(launch: BodyLaunch): Promise<OwnedProcess>;
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
world: WorldRoot;
|
|
53
|
+
externalCommands: Readonly<Record<string, ErasedRequestCommand>>;
|
|
54
54
|
}>;
|
|
55
55
|
export declare function bodyProcessInput(launch: BodyLaunch, bodyModuleUrl?: string): Promise<{
|
|
56
56
|
argv: string[];
|
|
@@ -61,7 +61,7 @@ export declare function bodyProcessInput(launch: BodyLaunch, bodyModuleUrl?: str
|
|
|
61
61
|
log: string;
|
|
62
62
|
}>;
|
|
63
63
|
export declare function handoffPendingTells(paths: AkumaPaths, spawn?: (launch: BodyLaunch) => Promise<OwnedProcess>): Promise<void>;
|
|
64
|
-
export declare function driveAkumaBody(launch: BodyLaunch, adapter?: ProviderAdapter,
|
|
64
|
+
export declare function driveAkumaBody(launch: BodyLaunch, adapter?: ProviderAdapter, runtimeInput?: Partial<BodyRuntime>): Promise<"held" | void>;
|
|
65
65
|
export declare function spawnAkumaBody(launch: BodyLaunch): Promise<OwnedProcess>;
|
|
66
|
-
export declare function runAkumaBody(launch: BodyLaunch,
|
|
66
|
+
export declare function runAkumaBody(launch: BodyLaunch, world: WorldRoot, externalCommands: Readonly<Record<string, ErasedRequestCommand>>): Promise<"held" | void>;
|
|
67
67
|
export declare function wakeRecordedTell(paths: AkumaPaths, tellId: string, runtime?: TellWakeRuntime): Promise<TellResult>;
|