@astrosheep/keiyaku 4.0.1 → 4.0.2
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 +137 -5
- package/build/integrations/marketplace/plugins/keiyaku/.claude-plugin/plugin.json +1 -1
- package/build/integrations/marketplace/plugins/keiyaku/.codex-plugin/plugin.json +1 -1
- package/build/integrations/marketplace/plugins/keiyaku/package.json +1 -1
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +3 -3
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +91 -35
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/SKILL.md +98 -58
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +152 -53
- package/build/src/akuma/abort.d.ts +2 -0
- package/build/src/akuma/abort.js +50 -0
- package/build/src/akuma/akuma.d.ts +23 -14
- package/build/src/akuma/akuma.js +120 -104
- package/build/src/akuma/archetype.d.ts +7 -6
- package/build/src/akuma/archetype.js +68 -41
- package/build/src/akuma/body.d.ts +3 -5
- package/build/src/akuma/body.js +408 -213
- package/build/src/akuma/heart/facts.d.ts +25 -34
- package/build/src/akuma/heart/facts.js +18 -7
- package/build/src/akuma/heart/index.d.ts +39 -42
- package/build/src/akuma/heart/index.js +134 -93
- package/build/src/akuma/heart/rows.d.ts +9 -31
- package/build/src/akuma/heart/rows.js +26 -44
- package/build/src/akuma/heart/schema.d.ts +1 -1
- package/build/src/akuma/heart/schema.js +7 -15
- package/build/src/akuma/heart/soul.d.ts +8 -0
- package/build/src/akuma/heart/soul.js +136 -0
- package/build/src/akuma/heart/storage.d.ts +28 -14
- package/build/src/akuma/heart/storage.js +86 -26
- package/build/src/akuma/identity.d.ts +2 -2
- package/build/src/akuma/identity.js +9 -9
- package/build/src/akuma/index.d.ts +6 -1
- package/build/src/akuma/index.js +6 -0
- package/build/src/akuma/projection.d.ts +117 -38
- package/build/src/akuma/projection.js +208 -97
- package/build/src/akuma/provider-recipe.d.ts +24 -0
- package/build/src/akuma/provider-recipe.js +100 -0
- package/build/src/akuma/provider.d.ts +12 -4
- package/build/src/akuma/provider.js +117 -70
- package/build/src/akuma/providers/acp/core.d.ts +19 -0
- package/build/src/akuma/providers/acp/core.js +159 -0
- package/build/src/akuma/providers/acp/events.d.ts +20 -0
- package/build/src/akuma/providers/acp/events.js +73 -0
- package/build/src/akuma/providers/acp/index.d.ts +12 -0
- package/build/src/akuma/providers/acp/index.js +94 -0
- package/build/src/akuma/providers/claude/events.js +66 -13
- package/build/src/akuma/providers/claude/index.d.ts +2 -1
- package/build/src/akuma/providers/claude/index.js +35 -21
- package/build/src/akuma/providers/codex-app-server/events.js +4 -1
- package/build/src/akuma/providers/codex-app-server/index.d.ts +3 -3
- package/build/src/akuma/providers/codex-app-server/index.js +24 -31
- package/build/src/akuma/providers/grok-build/index.d.ts +4 -0
- package/build/src/akuma/providers/grok-build/index.js +70 -0
- package/build/src/akuma/providers/index.d.ts +5 -3
- package/build/src/akuma/providers/index.js +24 -59
- package/build/src/akuma/providers/opencode-sdk/events.d.ts +40 -34
- package/build/src/akuma/providers/opencode-sdk/events.js +220 -101
- package/build/src/akuma/providers/opencode-sdk/index.d.ts +3 -2
- package/build/src/akuma/providers/opencode-sdk/index.js +233 -128
- package/build/src/akuma/providers/opencode-sdk/session.d.ts +11 -26
- package/build/src/akuma/providers/opencode-sdk/session.js +10 -9
- package/build/src/akuma/providers/pi/events.js +49 -11
- package/build/src/akuma/providers/pi/index.d.ts +1 -1
- package/build/src/akuma/providers/pi/index.js +50 -21
- package/build/src/akuma/publication.d.ts +3 -3
- package/build/src/akuma/publication.js +28 -40
- package/build/src/akuma/requests.d.ts +9 -7
- package/build/src/akuma/requests.js +92 -65
- package/build/src/alias/index.d.ts +2 -2
- package/build/src/alias/index.js +10 -10
- package/build/src/body/decode.js +7 -1
- package/build/src/body/region.d.ts +2 -0
- package/build/src/body/region.js +77 -7
- package/build/src/cli/accepted.d.ts +17 -13
- package/build/src/cli/accepted.js +72 -34
- package/build/src/cli/actor.js +3 -3
- package/build/src/cli/commands/akuma-invoke.d.ts +4 -3
- package/build/src/cli/commands/akuma-invoke.js +14 -9
- package/build/src/cli/commands/akuma.d.ts +13 -3
- package/build/src/cli/commands/akuma.js +67 -34
- package/build/src/cli/commands/contract.d.ts +18 -5
- package/build/src/cli/commands/contract.js +9 -3
- package/build/src/cli/commands/task-invoke.d.ts +17 -4
- package/build/src/cli/commands/task-invoke.js +43 -20
- package/build/src/cli/commands/task-query.d.ts +5 -0
- package/build/src/cli/commands/task-query.js +247 -0
- package/build/src/cli/commands/task.d.ts +3 -1
- package/build/src/cli/commands/task.js +51 -13
- package/build/src/cli/coordinates.d.ts +18 -0
- package/build/src/cli/coordinates.js +120 -0
- package/build/src/cli/draft.d.ts +8 -0
- package/build/src/cli/draft.js +96 -0
- package/build/src/cli/invoke.d.ts +4 -3
- package/build/src/cli/invoke.js +160 -179
- package/build/src/cli/main.js +34 -6
- package/build/src/cli/parse.d.ts +9 -2
- package/build/src/cli/parse.js +29 -7
- package/build/src/cli/render/akuma-tool-command.d.ts +6 -0
- package/build/src/cli/render/akuma-tool-command.js +144 -0
- package/build/src/cli/render/akuma-tool.d.ts +2 -2
- package/build/src/cli/render/akuma-tool.js +30 -4
- package/build/src/cli/render/akuma.d.ts +1 -0
- package/build/src/cli/render/akuma.js +211 -116
- package/build/src/cli/render/audit.d.ts +3 -0
- package/build/src/cli/render/audit.js +104 -0
- package/build/src/cli/render/contract.d.ts +3 -3
- package/build/src/cli/render/contract.js +192 -79
- package/build/src/cli/render/kanshi.js +263 -168
- package/build/src/cli/render/receipt.d.ts +19 -0
- package/build/src/cli/render/receipt.js +106 -0
- package/build/src/cli/render/refusal.d.ts +16 -2
- package/build/src/cli/render/refusal.js +88 -20
- package/build/src/cli/render/region.d.ts +2 -0
- package/build/src/cli/render/region.js +17 -0
- package/build/src/cli/render/task.d.ts +2 -1
- package/build/src/cli/render/task.js +223 -60
- package/build/src/cli/render/terminal.d.ts +7 -0
- package/build/src/cli/render/terminal.js +46 -0
- package/build/src/cli/render/text.js +6 -3
- package/build/src/cli/result.d.ts +115 -20
- package/build/src/cli/usage.d.ts +1 -0
- package/build/src/cli/usage.js +3 -0
- package/build/src/contract-worktree.d.ts +6 -5
- package/build/src/contract-worktree.js +95 -57
- package/build/src/coordination/durable-file.d.ts +4 -3
- package/build/src/coordination/durable-file.js +29 -25
- package/build/src/coordination/sqlite-transaction-lock.d.ts +4 -0
- package/build/src/coordination/sqlite-transaction-lock.js +22 -5
- package/build/src/core/facts/fold.js +1 -6
- package/build/src/core/facts/gate.d.ts +1 -0
- package/build/src/core/facts/gate.js +1 -0
- package/build/src/core/verbs/amend.d.ts +1 -1
- package/build/src/core/verbs/amend.js +0 -11
- package/build/src/core/verbs/deliver.d.ts +1 -1
- package/build/src/core/verbs/deliver.js +1 -7
- package/build/src/core/verbs/placement.d.ts +1 -1
- package/build/src/core/verbs/placement.js +4 -1
- package/build/src/dispatch/index.d.ts +2 -2
- package/build/src/dispatch/index.js +17 -17
- package/build/src/git/admission.d.ts +1 -1
- package/build/src/git/admission.js +11 -11
- package/build/src/git/hooks.js +13 -13
- package/build/src/git/integration.d.ts +14 -15
- package/build/src/git/integration.js +80 -44
- package/build/src/git/observe.d.ts +5 -3
- package/build/src/git/observe.js +18 -12
- package/build/src/git/read-observation.js +9 -9
- package/build/src/git/reconcile.d.ts +2 -0
- package/build/src/git/reconcile.js +138 -95
- package/build/src/git/repository.d.ts +27 -19
- package/build/src/git/repository.js +155 -83
- package/build/src/git/scratch.d.ts +7 -3
- package/build/src/git/scratch.js +44 -37
- package/build/src/git/target-placement.d.ts +40 -4
- package/build/src/git/target-placement.js +221 -101
- package/build/src/git/tender.d.ts +6 -5
- package/build/src/git/tender.js +24 -43
- package/build/src/git/terminal-seal.d.ts +1 -1
- package/build/src/git/terminal-seal.js +7 -5
- package/build/src/git/workspace.d.ts +36 -4
- package/build/src/git/workspace.js +53 -18
- package/build/src/identity/selector.js +1 -1
- package/build/src/index.d.ts +3 -3
- package/build/src/index.js +1 -1
- package/build/src/kanshi/index.d.ts +2 -2
- package/build/src/kanshi/index.js +1 -1
- package/build/src/kanshi/read.d.ts +2 -1
- package/build/src/kanshi/read.js +118 -27
- package/build/src/kanshi/report.d.ts +50 -0
- package/build/src/kanshi/select.d.ts +5 -0
- package/build/src/kanshi/select.js +32 -0
- package/build/src/library/address.d.ts +12 -3
- package/build/src/library/address.js +77 -46
- package/build/src/library/akuma-creation.d.ts +6 -1
- package/build/src/library/akuma-creation.js +86 -13
- package/build/src/library/audit.d.ts +18 -0
- package/build/src/library/audit.js +44 -0
- package/build/src/library/bind.js +4 -4
- package/build/src/library/catalog.d.ts +1 -1
- package/build/src/library/catalog.js +5 -8
- package/build/src/library/contract.d.ts +5 -6
- package/build/src/library/contract.js +11 -35
- package/build/src/library/delivery.d.ts +2 -1
- package/build/src/library/fleet.d.ts +2 -2
- package/build/src/library/fleet.js +35 -71
- package/build/src/library/keiyaku.d.ts +3 -2
- package/build/src/library/keiyaku.js +1 -0
- package/build/src/library/mutation.d.ts +7 -6
- package/build/src/library/mutation.js +23 -25
- package/build/src/library/reconcile.d.ts +29 -0
- package/build/src/library/reconcile.js +179 -0
- package/build/src/library/region.d.ts +12 -0
- package/build/src/library/region.js +15 -1
- package/build/src/library/repo.d.ts +4 -16
- package/build/src/library/repo.js +13 -38
- package/build/src/protocol/attempt.js +6 -6
- package/build/src/protocol/bind.js +4 -4
- package/build/src/protocol/intent.d.ts +15 -2
- package/build/src/protocol/intent.js +21 -6
- package/build/src/protocol/operations.d.ts +73 -22
- package/build/src/protocol/operations.js +292 -88
- package/build/src/protocol/outcome.d.ts +9 -3
- package/build/src/protocol/outcome.js +3 -1
- package/build/src/protocol/placement.d.ts +15 -4
- package/build/src/protocol/placement.js +58 -25
- package/build/src/protocol/read/status.d.ts +8 -1
- package/build/src/protocol/read/status.js +61 -14
- package/build/src/runtime/proc/line-rpc.d.ts +3 -8
- package/build/src/runtime/proc/line-rpc.js +16 -43
- package/build/src/runtime/proc/run.d.ts +15 -29
- package/build/src/runtime/proc/run.js +113 -105
- package/build/src/runtime/proc/stdio.d.ts +18 -0
- package/build/src/runtime/proc/stdio.js +58 -0
- package/build/src/settings.d.ts +2 -2
- package/build/src/settings.js +8 -8
- package/build/src/settlement/fence.d.ts +0 -4
- package/build/src/settlement/fence.js +0 -9
- package/build/src/settlement/holder.d.ts +11 -1
- package/build/src/settlement/holder.js +25 -0
- package/build/src/settlement/settle.d.ts +1 -1
- package/build/src/settlement/settle.js +52 -89
- package/build/src/task/board.d.ts +3 -3
- package/build/src/task/board.js +6 -9
- package/build/src/task/compose.d.ts +1 -1
- package/build/src/task/compose.js +18 -10
- package/build/src/task/context.d.ts +3 -3
- package/build/src/task/context.js +14 -14
- package/build/src/task/document.d.ts +2 -1
- package/build/src/task/document.js +15 -5
- package/build/src/task/index.d.ts +19 -7
- package/build/src/task/index.js +42 -23
- package/build/src/task/operations.d.ts +15 -9
- package/build/src/task/operations.js +78 -48
- package/build/src/task/query.d.ts +67 -0
- package/build/src/task/query.js +279 -0
- package/build/src/task/store.d.ts +2 -2
- package/build/src/task/store.js +40 -25
- package/build/src/verification/execution.d.ts +4 -2
- package/build/src/verification/execution.js +9 -5
- package/build/src/workspace-place.d.ts +41 -0
- package/build/src/workspace-place.js +386 -0
- package/build/src/world.d.ts +13 -2
- package/build/src/world.js +81 -48
- package/package.json +3 -2
- package/build/src/protocol/read/audit.d.ts +0 -31
- package/build/src/protocol/read/audit.js +0 -55
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readFile, readdir } from "node:fs/promises";
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
3
|
import { parseDocument } from "yaml";
|
|
4
4
|
import { archetypeName } from "./identity.js";
|
|
5
|
-
import { decodeProviderOptions } from "./provider.js";
|
|
6
|
-
import {
|
|
5
|
+
import { decodeProviderOptions, decodeProviderRecipe, } from "./provider-recipe.js";
|
|
6
|
+
import { resolveProviderExecution } from "./providers/index.js";
|
|
7
7
|
export class AkumaArchetypeError extends Error {
|
|
8
8
|
archetype;
|
|
9
9
|
searched;
|
|
10
10
|
reason;
|
|
11
11
|
kind = "akuma-archetype";
|
|
12
|
-
constructor(archetype, searched, reason) {
|
|
13
|
-
super(
|
|
12
|
+
constructor(archetype, searched, reason, guidance) {
|
|
13
|
+
super([`\`${archetype}\` ${reason}`, ...(guidance === undefined ? [] : [guidance])].join("\n"));
|
|
14
14
|
this.archetype = archetype;
|
|
15
15
|
this.searched = searched;
|
|
16
16
|
this.reason = reason;
|
|
@@ -21,12 +21,12 @@ function archetypeDirectory(settings) {
|
|
|
21
21
|
const userPath = settings.scopes.user.path;
|
|
22
22
|
return userPath === undefined ? null : join(dirname(userPath), "akuma");
|
|
23
23
|
}
|
|
24
|
-
function archetypePaths(settings) {
|
|
24
|
+
async function archetypePaths(settings) {
|
|
25
25
|
const directory = archetypeDirectory(settings);
|
|
26
26
|
if (directory === null)
|
|
27
27
|
return [];
|
|
28
28
|
try {
|
|
29
|
-
return
|
|
29
|
+
return (await readdir(directory, { withFileTypes: true }))
|
|
30
30
|
.flatMap((entry) => {
|
|
31
31
|
if (!entry.isFile() || !entry.name.endsWith(".md"))
|
|
32
32
|
return [];
|
|
@@ -46,15 +46,15 @@ function archetypePaths(settings) {
|
|
|
46
46
|
throw error;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
export function listArchetypes(input) {
|
|
50
|
-
return archetypePaths(input.settings).map(({ name }) => name);
|
|
49
|
+
export async function listArchetypes(input) {
|
|
50
|
+
return (await archetypePaths(input.settings)).map(({ name }) => name);
|
|
51
51
|
}
|
|
52
52
|
function archetypeField(values, key, required = false) {
|
|
53
53
|
const value = values[key];
|
|
54
54
|
if (value === undefined && !required)
|
|
55
55
|
return undefined;
|
|
56
56
|
if (typeof value !== "string" || value.trim().length === 0) {
|
|
57
|
-
throw new TypeError(`
|
|
57
|
+
throw new TypeError(`Akuma ${key} must be a nonblank string`);
|
|
58
58
|
}
|
|
59
59
|
return value;
|
|
60
60
|
}
|
|
@@ -63,28 +63,37 @@ function archetypeEnum(values, key, allowed) {
|
|
|
63
63
|
if (value === undefined)
|
|
64
64
|
return undefined;
|
|
65
65
|
if (!allowed.includes(value))
|
|
66
|
-
throw new TypeError(`
|
|
66
|
+
throw new TypeError(`Akuma ${key} must be one of ${allowed.join(", ")}`);
|
|
67
67
|
return value;
|
|
68
68
|
}
|
|
69
|
+
function archetypeReadonly(values) {
|
|
70
|
+
if (!("readonly" in values))
|
|
71
|
+
return undefined;
|
|
72
|
+
if (values.readonly !== true)
|
|
73
|
+
throw new TypeError("Akuma readonly must be true");
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
69
76
|
function decodeArchetype(name, path, markdown) {
|
|
70
77
|
const lines = markdown.split(/\r?\n/u);
|
|
71
78
|
if (lines[0]?.trim() !== "---")
|
|
72
|
-
throw new TypeError("
|
|
79
|
+
throw new TypeError("Akuma configuration must begin with YAML frontmatter");
|
|
73
80
|
const closing = lines.findIndex((line, index) => index > 0 && line.trim() === "---");
|
|
74
81
|
if (closing < 0)
|
|
75
|
-
throw new TypeError("
|
|
82
|
+
throw new TypeError("Akuma frontmatter is not closed");
|
|
76
83
|
const document = parseDocument(lines.slice(1, closing).join("\n"), { uniqueKeys: true });
|
|
77
84
|
if (document.errors.length > 0)
|
|
78
|
-
throw new TypeError(`
|
|
85
|
+
throw new TypeError(`Akuma frontmatter is invalid: ${document.errors[0].message}`);
|
|
79
86
|
const decoded = document.toJS();
|
|
80
87
|
if (decoded === null || typeof decoded !== "object" || Array.isArray(decoded)) {
|
|
81
|
-
throw new TypeError("
|
|
88
|
+
throw new TypeError("Akuma frontmatter must be one mapping");
|
|
82
89
|
}
|
|
83
90
|
const values = decoded;
|
|
84
91
|
const provider = archetypeField(values, "provider", true);
|
|
92
|
+
if ("access" in values)
|
|
93
|
+
throw new TypeError("Akuma access is not supported; use readonly: true");
|
|
85
94
|
const model = archetypeField(values, "model");
|
|
86
95
|
const effort = archetypeField(values, "effort");
|
|
87
|
-
const
|
|
96
|
+
const readonly = archetypeReadonly(values);
|
|
88
97
|
const network = archetypeEnum(values, "network", ["disabled", "enabled"]);
|
|
89
98
|
const description = archetypeField(values, "description");
|
|
90
99
|
const systemPrompt = lines.slice(closing + 1).join("\n");
|
|
@@ -96,16 +105,18 @@ function decodeArchetype(name, path, markdown) {
|
|
|
96
105
|
options: decodeProviderOptions({
|
|
97
106
|
...(model === undefined ? {} : { model }),
|
|
98
107
|
...(effort === undefined ? {} : { effort }),
|
|
99
|
-
...(
|
|
108
|
+
...(readonly === undefined ? {} : { readonly }),
|
|
100
109
|
...(network === undefined ? {} : { network }),
|
|
101
|
-
systemPrompt,
|
|
110
|
+
...(systemPrompt.length === 0 ? {} : { systemPrompt }),
|
|
102
111
|
}),
|
|
103
112
|
});
|
|
104
113
|
}
|
|
105
|
-
export function listArchetypeDefinitions(input) {
|
|
106
|
-
|
|
114
|
+
export async function listArchetypeDefinitions(input) {
|
|
115
|
+
// Reads still run concurrently, but the reported failure is the first invalid
|
|
116
|
+
// definition in catalog byte order, not whichever read happened to finish first.
|
|
117
|
+
const settled = await Promise.allSettled((await archetypePaths(input.settings)).map(async ({ name, path }) => {
|
|
107
118
|
try {
|
|
108
|
-
const definition = decodeArchetype(name, path,
|
|
119
|
+
const definition = decodeArchetype(name, path, await readFile(path, "utf8"));
|
|
109
120
|
return Object.freeze({
|
|
110
121
|
name: definition.name,
|
|
111
122
|
...(definition.options.model === undefined ? {} : { model: definition.options.model }),
|
|
@@ -115,7 +126,11 @@ export function listArchetypeDefinitions(input) {
|
|
|
115
126
|
catch (error) {
|
|
116
127
|
throw new AkumaArchetypeError(name, [path], `is invalid: ${error instanceof Error ? error.message : String(error)}`);
|
|
117
128
|
}
|
|
118
|
-
});
|
|
129
|
+
}));
|
|
130
|
+
const firstInvalid = settled.find((result) => result.status === "rejected");
|
|
131
|
+
if (firstInvalid !== undefined)
|
|
132
|
+
throw firstInvalid.reason;
|
|
133
|
+
return settled.map((result) => result.value);
|
|
119
134
|
}
|
|
120
135
|
function record(value) {
|
|
121
136
|
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
@@ -138,7 +153,7 @@ function configuredProvider(name, selected) {
|
|
|
138
153
|
if (unknown !== undefined)
|
|
139
154
|
throw new TypeError(`provider ${name} has unknown field ${unknown}`);
|
|
140
155
|
optionalProviderText(value, name, "description");
|
|
141
|
-
return
|
|
156
|
+
return decodeProviderRecipe({
|
|
142
157
|
name,
|
|
143
158
|
kind: value.kind,
|
|
144
159
|
...(value.executable === undefined ? {} : { executable: value.executable }),
|
|
@@ -146,6 +161,16 @@ function configuredProvider(name, selected) {
|
|
|
146
161
|
...(value.env === undefined ? {} : { env: value.env }),
|
|
147
162
|
});
|
|
148
163
|
}
|
|
164
|
+
const BUILTIN_EXECUTIONS = {
|
|
165
|
+
claude: { kind: "claude-agent-sdk" },
|
|
166
|
+
"codex-app-server": { kind: "codex-app-server" },
|
|
167
|
+
"opencode-sdk": { kind: "opencode-sdk" },
|
|
168
|
+
pi: { kind: "pi" },
|
|
169
|
+
"grok-build": {
|
|
170
|
+
kind: "grok-build",
|
|
171
|
+
executable: "grok",
|
|
172
|
+
},
|
|
173
|
+
};
|
|
149
174
|
function providerExecution(settings, name) {
|
|
150
175
|
const view = settings.namespace("providers");
|
|
151
176
|
if (view.kind === "failed")
|
|
@@ -153,47 +178,49 @@ function providerExecution(settings, name) {
|
|
|
153
178
|
const selected = view.entries.find((entry) => entry.name === name)?.value;
|
|
154
179
|
if (selected !== undefined)
|
|
155
180
|
return configuredProvider(name, selected);
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
return Object.freeze({ name, kind: "codex-app-server" });
|
|
160
|
-
if (name === "opencode-sdk")
|
|
161
|
-
return Object.freeze({ name, kind: "opencode-sdk" });
|
|
162
|
-
if (name === "pi")
|
|
163
|
-
return Object.freeze({ name, kind: "pi" });
|
|
181
|
+
const builtin = BUILTIN_EXECUTIONS[name];
|
|
182
|
+
if (builtin !== undefined)
|
|
183
|
+
return decodeProviderRecipe({ name, ...builtin });
|
|
164
184
|
throw new TypeError(`unknown provider ${name}`);
|
|
165
185
|
}
|
|
166
186
|
function admitArchetype(archetype, settings) {
|
|
167
|
-
let
|
|
187
|
+
let selected;
|
|
168
188
|
try {
|
|
169
|
-
|
|
189
|
+
selected = resolveProviderExecution(providerExecution(settings, archetype.provider));
|
|
170
190
|
}
|
|
171
191
|
catch (error) {
|
|
172
192
|
if (error instanceof TypeError)
|
|
173
193
|
throw new AkumaArchetypeError(archetype.name, [archetype.path], `uses ${error.message}`);
|
|
174
194
|
throw error;
|
|
175
195
|
}
|
|
176
|
-
const
|
|
196
|
+
const execution = selected.execution;
|
|
197
|
+
const adapter = selected.adapter;
|
|
177
198
|
const admission = adapter.admitOptions(archetype.options);
|
|
178
199
|
if (admission.kind === "refused") {
|
|
179
200
|
throw new AkumaArchetypeError(archetype.name, [archetype.path], `is unsupported: ${admission.diagnostic}`);
|
|
180
201
|
}
|
|
181
|
-
return Object.freeze({
|
|
202
|
+
return Object.freeze({
|
|
203
|
+
...archetype,
|
|
204
|
+
provider: execution,
|
|
205
|
+
adapter,
|
|
206
|
+
options: admission.options,
|
|
207
|
+
...(admission.readonly === undefined ? {} : { readonly: admission.readonly }),
|
|
208
|
+
});
|
|
182
209
|
}
|
|
183
|
-
export function loadArchetype(input) {
|
|
210
|
+
export async function loadArchetype(input) {
|
|
184
211
|
const name = archetypeName(input.name);
|
|
185
212
|
const directory = archetypeDirectory(input.settings);
|
|
213
|
+
const missing = () => new AkumaArchetypeError(name, directory === null ? [] : [join(directory, `${name}.md`)], "was not found", "use `keiyaku ls aku/` to list available Akuma");
|
|
186
214
|
if (directory === null)
|
|
187
|
-
throw
|
|
215
|
+
throw missing();
|
|
188
216
|
const path = join(directory, `${name}.md`);
|
|
189
217
|
let markdown;
|
|
190
218
|
try {
|
|
191
|
-
markdown =
|
|
219
|
+
markdown = await readFile(path, "utf8");
|
|
192
220
|
}
|
|
193
221
|
catch (error) {
|
|
194
|
-
if (error.code === "ENOENT")
|
|
195
|
-
throw
|
|
196
|
-
}
|
|
222
|
+
if (error.code === "ENOENT")
|
|
223
|
+
throw missing();
|
|
197
224
|
throw new AkumaArchetypeError(name, [path], `could not be read: ${error instanceof Error ? error.message : String(error)}`);
|
|
198
225
|
}
|
|
199
226
|
try {
|
|
@@ -2,7 +2,7 @@ import { type SessionFact, type Soul } from "./heart/index.js";
|
|
|
2
2
|
import type { AkumaPaths } from "./identity.js";
|
|
3
3
|
import { type ProviderAdapter } from "./provider.js";
|
|
4
4
|
import { type RequestChildLaunch } from "./requests.js";
|
|
5
|
-
|
|
5
|
+
export declare const CONTROL_RESPONSE_MS = 1000;
|
|
6
6
|
export type BodyLaunch = Readonly<{
|
|
7
7
|
paths: AkumaPaths;
|
|
8
8
|
seed?: Omit<Soul, "createdAt">;
|
|
@@ -10,11 +10,9 @@ export type BodyLaunch = Readonly<{
|
|
|
10
10
|
initialBody?: string;
|
|
11
11
|
}>;
|
|
12
12
|
type BodyRuntime = Readonly<{
|
|
13
|
-
collar: ProcessCollar;
|
|
14
13
|
now(): string;
|
|
15
|
-
|
|
16
|
-
spawnChild?(launch: RequestChildLaunch): Promise<ProcessCollar>;
|
|
14
|
+
spawnChild?(launch: RequestChildLaunch): Promise<void>;
|
|
17
15
|
}>;
|
|
18
16
|
export declare function driveAkumaBody(launch: BodyLaunch, adapter?: ProviderAdapter, runtime?: BodyRuntime): Promise<void>;
|
|
19
|
-
export declare function spawnAkumaBody(launch: BodyLaunch): Promise<
|
|
17
|
+
export declare function spawnAkumaBody(launch: BodyLaunch): Promise<void>;
|
|
20
18
|
export {};
|