@astrosheep/keiyaku 4.0.0 → 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 +133 -8
- package/build/integrations/marketplace/plugins/keiyaku/.claude-plugin/plugin.json +2 -2
- package/build/integrations/marketplace/plugins/keiyaku/.codex-plugin/plugin.json +4 -4
- package/build/integrations/marketplace/plugins/keiyaku/opencode.js +2 -2
- package/build/integrations/marketplace/plugins/keiyaku/package.json +2 -2
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +13 -5
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +91 -32
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/SKILL.md +134 -0
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/agents/openai.yaml +4 -0
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-task/SKILL.md +41 -6
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +262 -46
- package/build/src/akuma/abort.d.ts +2 -0
- package/build/src/akuma/abort.js +50 -0
- package/build/src/akuma/akuma.d.ts +50 -33
- package/build/src/akuma/akuma.js +175 -127
- package/build/src/akuma/archetype.d.ts +14 -5
- package/build/src/akuma/archetype.js +85 -39
- package/build/src/akuma/body.d.ts +3 -5
- package/build/src/akuma/body.js +490 -183
- package/build/src/akuma/coordinate.d.ts +9 -0
- package/build/src/akuma/coordinate.js +22 -0
- package/build/src/akuma/heart/facts.d.ts +88 -45
- package/build/src/akuma/heart/facts.js +19 -8
- package/build/src/akuma/heart/index.d.ts +64 -55
- package/build/src/akuma/heart/index.js +172 -252
- package/build/src/akuma/heart/rows.d.ts +38 -83
- package/build/src/akuma/heart/rows.js +117 -155
- package/build/src/akuma/heart/schema.d.ts +1 -1
- package/build/src/akuma/heart/schema.js +61 -22
- 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 +47 -0
- package/build/src/akuma/heart/storage.js +224 -0
- package/build/src/akuma/heart/tells.d.ts +12 -0
- package/build/src/akuma/heart/tells.js +79 -0
- package/build/src/akuma/heart/timeline.d.ts +15 -0
- package/build/src/akuma/heart/timeline.js +86 -0
- package/build/src/akuma/identity.d.ts +2 -2
- package/build/src/akuma/identity.js +9 -9
- package/build/src/akuma/index.d.ts +10 -3
- package/build/src/akuma/index.js +7 -1
- package/build/src/akuma/projection.d.ts +176 -0
- package/build/src/akuma/projection.js +256 -0
- 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 +67 -13
- package/build/src/akuma/provider.js +172 -105
- 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.d.ts → claude/events.d.ts} +9 -41
- package/build/src/akuma/providers/claude/events.js +238 -0
- package/build/src/akuma/providers/claude/index.d.ts +47 -0
- package/build/src/akuma/providers/claude/index.js +279 -0
- package/build/src/akuma/providers/claude/input.d.ts +13 -0
- package/build/src/akuma/providers/claude/input.js +109 -0
- package/build/src/akuma/providers/codex-app-server/events.d.ts +1 -1
- package/build/src/akuma/providers/codex-app-server/events.js +15 -12
- package/build/src/akuma/providers/codex-app-server/index.d.ts +15 -13
- package/build/src/akuma/providers/codex-app-server/index.js +77 -33
- 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 +35 -56
- package/build/src/akuma/providers/opencode-sdk/events.d.ts +54 -0
- package/build/src/akuma/providers/opencode-sdk/events.js +235 -0
- package/build/src/akuma/providers/opencode-sdk/index.d.ts +33 -0
- package/build/src/akuma/providers/opencode-sdk/index.js +308 -0
- package/build/src/akuma/providers/opencode-sdk/session.d.ts +26 -0
- package/build/src/akuma/providers/opencode-sdk/session.js +63 -0
- package/build/src/akuma/providers/pi/events.d.ts +33 -0
- package/build/src/akuma/providers/pi/events.js +166 -0
- package/build/src/akuma/providers/pi/index.d.ts +11 -0
- package/build/src/akuma/providers/pi/index.js +191 -0
- 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 -6
- package/build/src/akuma/requests.js +95 -65
- package/build/src/alias/index.d.ts +4 -3
- package/build/src/alias/index.js +12 -13
- 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/body/render.js +2 -1
- package/build/src/body/shape.js +7 -1
- package/build/src/body/verification.js +19 -4
- package/build/src/cli/accepted.d.ts +18 -12
- package/build/src/cli/accepted.js +73 -34
- package/build/src/cli/actor.js +3 -3
- package/build/src/cli/commands/akuma-invoke.d.ts +44 -19
- package/build/src/cli/commands/akuma-invoke.js +101 -52
- package/build/src/cli/commands/akuma.d.ts +27 -9
- package/build/src/cli/commands/akuma.js +151 -80
- package/build/src/cli/commands/contract.d.ts +155 -0
- package/build/src/cli/commands/contract.js +20 -0
- package/build/src/cli/commands/install.js +2 -0
- package/build/src/cli/commands/task-invoke.d.ts +19 -4
- package/build/src/cli/commands/task-invoke.js +65 -17
- 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 +52 -14
- 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 +9 -3
- package/build/src/cli/invoke.js +287 -108
- package/build/src/cli/main.js +54 -7
- package/build/src/cli/parse.d.ts +21 -117
- package/build/src/cli/parse.js +79 -84
- 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 +4 -2
- package/build/src/cli/render/akuma-tool.js +35 -5
- package/build/src/cli/render/akuma.d.ts +3 -1
- package/build/src/cli/render/akuma.js +247 -212
- package/build/src/cli/render/audit.d.ts +3 -0
- package/build/src/cli/render/audit.js +104 -0
- package/build/src/cli/render/catalog.d.ts +2 -0
- package/build/src/cli/render/catalog.js +16 -0
- package/build/src/cli/render/contract.d.ts +3 -3
- package/build/src/cli/render/contract.js +200 -54
- package/build/src/cli/render/kanshi.js +272 -129
- 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 -3
- 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 +20 -0
- package/build/src/cli/render/terminal.js +121 -0
- package/build/src/cli/render/text.js +11 -3
- package/build/src/cli/result.d.ts +126 -19
- package/build/src/cli/usage.d.ts +1 -0
- package/build/src/cli/usage.js +3 -0
- package/build/src/contract-worktree.d.ts +44 -0
- package/build/src/contract-worktree.js +251 -0
- package/build/src/coordination/durable-file.d.ts +5 -1
- package/build/src/coordination/durable-file.js +57 -10
- 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/codec.js +23 -4
- package/build/src/core/facts/eligibility.d.ts +1 -10
- package/build/src/core/facts/eligibility.js +0 -49
- 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/facts/observation.d.ts +3 -0
- package/build/src/core/facts/observation.js +12 -0
- package/build/src/core/facts/types.d.ts +10 -3
- package/build/src/core/subject.js +2 -2
- package/build/src/core/verbs/amend.d.ts +1 -1
- package/build/src/core/verbs/amend.js +3 -18
- package/build/src/core/verbs/bind.js +2 -16
- package/build/src/core/verbs/deliver.d.ts +1 -1
- package/build/src/core/verbs/deliver.js +14 -4
- package/build/src/core/verbs/placement.d.ts +1 -1
- package/build/src/core/verbs/placement.js +7 -9
- package/build/src/dispatch/index.d.ts +5 -3
- package/build/src/dispatch/index.js +30 -21
- package/build/src/duration.d.ts +10 -0
- package/build/src/duration.js +22 -0
- package/build/src/git/admission.d.ts +2 -2
- package/build/src/git/admission.js +33 -23
- package/build/src/git/hooks.d.ts +15 -0
- package/build/src/git/hooks.js +70 -18
- package/build/src/git/identity.d.ts +5 -1
- package/build/src/git/identity.js +23 -4
- package/build/src/git/integration.d.ts +48 -0
- package/build/src/git/integration.js +250 -0
- package/build/src/git/observe.d.ts +29 -15
- package/build/src/git/observe.js +185 -76
- package/build/src/git/read-observation.d.ts +41 -0
- package/build/src/git/read-observation.js +361 -0
- package/build/src/git/reconcile.d.ts +17 -5
- package/build/src/git/reconcile.js +305 -109
- package/build/src/git/repository.d.ts +41 -18
- package/build/src/git/repository.js +220 -114
- package/build/src/git/scratch.d.ts +17 -0
- package/build/src/git/scratch.js +73 -0
- package/build/src/git/target-placement.d.ts +92 -0
- package/build/src/git/target-placement.js +375 -0
- package/build/src/git/tender.d.ts +49 -0
- package/build/src/git/tender.js +63 -0
- package/build/src/git/terminal-seal.d.ts +24 -0
- package/build/src/git/terminal-seal.js +89 -0
- package/build/src/git/tree.d.ts +2 -2
- package/build/src/git/tree.js +4 -0
- package/build/src/git/workspace.d.ts +53 -0
- package/build/src/git/workspace.js +139 -0
- package/build/src/identity/selector.d.ts +6 -0
- package/build/src/identity/selector.js +19 -0
- package/build/src/index.d.ts +4 -2
- package/build/src/index.js +2 -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 +7 -3
- package/build/src/kanshi/read.js +245 -45
- package/build/src/kanshi/report.d.ts +81 -6
- package/build/src/kanshi/select.d.ts +5 -0
- package/build/src/kanshi/select.js +33 -1
- package/build/src/library/address.d.ts +57 -0
- package/build/src/library/address.js +165 -0
- package/build/src/library/akuma-creation.d.ts +16 -7
- package/build/src/library/akuma-creation.js +96 -22
- package/build/src/library/audit.d.ts +18 -0
- package/build/src/library/audit.js +44 -0
- package/build/src/library/bind.d.ts +21 -0
- package/build/src/library/bind.js +56 -0
- package/build/src/library/catalog.d.ts +58 -0
- package/build/src/library/catalog.js +69 -0
- package/build/src/library/configuration.d.ts +6 -15
- package/build/src/library/configuration.js +14 -17
- package/build/src/library/contract.d.ts +23 -49
- package/build/src/library/contract.js +171 -185
- package/build/src/library/delivery.d.ts +24 -0
- package/build/src/library/delivery.js +21 -0
- package/build/src/library/fleet.d.ts +65 -0
- package/build/src/library/fleet.js +153 -0
- package/build/src/library/input.d.ts +3 -0
- package/build/src/library/input.js +19 -0
- package/build/src/library/keiyaku.d.ts +18 -3
- package/build/src/library/keiyaku.js +12 -1
- package/build/src/library/mutation.d.ts +39 -0
- package/build/src/library/mutation.js +37 -0
- package/build/src/library/reconcile.d.ts +29 -0
- package/build/src/library/reconcile.js +179 -0
- package/build/src/library/refusal.d.ts +21 -0
- package/build/src/library/refusal.js +29 -0
- package/build/src/library/region.d.ts +14 -1
- package/build/src/library/region.js +18 -4
- package/build/src/library/repo.d.ts +4 -13
- package/build/src/library/repo.js +14 -24
- package/build/src/protocol/attempt.d.ts +16 -3
- package/build/src/protocol/attempt.js +41 -10
- package/build/src/protocol/bind.d.ts +9 -2
- package/build/src/protocol/bind.js +48 -40
- package/build/src/protocol/intent.d.ts +57 -20
- package/build/src/protocol/intent.js +55 -79
- package/build/src/protocol/operations.d.ts +152 -43
- package/build/src/protocol/operations.js +482 -166
- package/build/src/protocol/outcome.d.ts +14 -3
- package/build/src/protocol/outcome.js +11 -3
- package/build/src/protocol/placement.d.ts +41 -0
- package/build/src/protocol/placement.js +147 -0
- package/build/src/protocol/read/documents.d.ts +2 -2
- package/build/src/protocol/read/documents.js +4 -4
- package/build/src/protocol/read/status.d.ts +18 -5
- package/build/src/protocol/read/status.js +73 -13
- package/build/src/protocol/run.d.ts +49 -7
- package/build/src/protocol/run.js +53 -25
- package/build/src/runtime/proc/line-rpc.d.ts +4 -8
- package/build/src/runtime/proc/line-rpc.js +22 -28
- package/build/src/runtime/proc/run.d.ts +23 -21
- package/build/src/runtime/proc/run.js +123 -89
- 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 +7 -1
- package/build/src/settings.js +32 -17
- package/build/src/settlement/fence.d.ts +5 -0
- package/build/src/settlement/fence.js +14 -0
- package/build/src/settlement/holder.d.ts +35 -4
- package/build/src/settlement/holder.js +127 -28
- package/build/src/settlement/settle.d.ts +9 -1
- package/build/src/settlement/settle.js +74 -37
- package/build/src/task/board.d.ts +23 -5
- package/build/src/task/board.js +17 -10
- package/build/src/task/compose.d.ts +2 -2
- package/build/src/task/compose.js +18 -10
- package/build/src/task/context.d.ts +3 -3
- package/build/src/task/context.js +15 -20
- package/build/src/task/document.d.ts +2 -1
- package/build/src/task/document.js +15 -5
- package/build/src/task/index.d.ts +27 -15
- package/build/src/task/index.js +57 -35
- package/build/src/task/operations.d.ts +38 -13
- package/build/src/task/operations.js +80 -46
- package/build/src/task/query.d.ts +67 -0
- package/build/src/task/query.js +279 -0
- package/build/src/task/store.d.ts +5 -7
- package/build/src/task/store.js +43 -28
- package/build/src/verification/declaration.d.ts +1 -0
- package/build/src/verification/execution.d.ts +51 -0
- package/build/src/verification/execution.js +108 -0
- package/build/src/workspace-place.d.ts +41 -0
- package/build/src/workspace-place.js +386 -0
- package/build/src/world.d.ts +24 -0
- package/build/src/world.js +136 -0
- package/package.json +8 -4
- package/build/src/akuma/activity.d.ts +0 -66
- package/build/src/akuma/activity.js +0 -139
- package/build/src/akuma/providers/claude.js +0 -305
- package/build/src/context-root.d.ts +0 -4
- package/build/src/context-root.js +0 -15
- package/build/src/git/delivery.d.ts +0 -20
- package/build/src/git/delivery.js +0 -109
- package/build/src/git/verification.d.ts +0 -14
- package/build/src/git/verification.js +0 -56
- package/build/src/protocol/read/audit.d.ts +0 -25
- package/build/src/protocol/read/audit.js +0 -39
- package/build/src/verification/producer.d.ts +0 -23
- package/build/src/verification/producer.js +0 -54
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import { type ContractId, type MutationResult } from "../index.js";
|
|
2
|
-
import type { AcceptedResult, InvocationResult } from "./result.js";
|
|
1
|
+
import { type AmendResult, type AuditReport, type BindResult, type ContractId, type Delivery, type MutationResult, type Review } from "../index.js";
|
|
2
|
+
import type { AcceptedAbandonResult, AcceptedAmendResult, AcceptedArcResult, AcceptedAuditResult, AcceptedBindResult, AcceptedDeliverResult, AcceptedResult, AcceptedReviewResult, InvocationResult } from "./result.js";
|
|
3
3
|
type MutationObservation = Pick<MutationResult<unknown>, "facts" | "head" | "effects" | "lags" | "settlement">;
|
|
4
|
-
type
|
|
4
|
+
type MutationCallOptions = Readonly<{
|
|
5
5
|
coordinate?: ContractId;
|
|
6
|
-
|
|
7
|
-
report?: import("../index.js").AuditReport;
|
|
8
|
-
obligations?: Pick<AcceptedResult, "verification" | "placement" | "leak">;
|
|
9
|
-
diff?: AcceptedResult["diff"];
|
|
6
|
+
projectRefusal?: (refusal: unknown) => unknown;
|
|
10
7
|
}>;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export declare function
|
|
8
|
+
export declare function acceptedBind(result: BindResult, target: string | null): AcceptedBindResult;
|
|
9
|
+
export declare function acceptedAmend(result: AmendResult, coordinate: ContractId): AcceptedAmendResult;
|
|
10
|
+
export declare function acceptedDeliver(result: MutationResult<Delivery>, coordinate: ContractId): AcceptedDeliverResult;
|
|
11
|
+
export declare function acceptedReview(result: MutationResult<Review>, coordinate: ContractId): AcceptedReviewResult;
|
|
12
|
+
export declare function acceptedArc(result: MutationResult<void>, coordinate: ContractId): AcceptedArcResult;
|
|
13
|
+
export declare function acceptedAbandon(result: MutationResult<void>, coordinate: ContractId): AcceptedAbandonResult;
|
|
14
|
+
export declare function acceptedAudit(result: MutationResult<AuditReport>, coordinate: ContractId): AcceptedAuditResult;
|
|
15
|
+
export declare function resultFromMutationCall<const Verb extends AcceptedResult["verb"], Result extends MutationObservation>(verb: Verb, call: () => Promise<Result>, project: (result: Result) => Extract<AcceptedResult, {
|
|
16
|
+
verb: NoInfer<Verb>;
|
|
17
|
+
}>, options?: MutationCallOptions): Promise<Extract<AcceptedResult, {
|
|
18
|
+
verb: Verb;
|
|
19
|
+
}> | Extract<InvocationResult, {
|
|
20
|
+
kind: "refused" | "retry";
|
|
21
|
+
}>>;
|
|
16
22
|
export {};
|
|
@@ -1,47 +1,86 @@
|
|
|
1
1
|
import { KeiyakuRefused, KeiyakuRetry, } from "../index.js";
|
|
2
|
-
function
|
|
3
|
-
return
|
|
2
|
+
function acceptedFacts(result) {
|
|
3
|
+
return result.facts.map((fact) => ({
|
|
4
|
+
contract: fact.contract,
|
|
5
|
+
entry: fact.entry,
|
|
6
|
+
kind: fact.kind,
|
|
7
|
+
}));
|
|
4
8
|
}
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function hasDocumentDiff(value) {
|
|
9
|
-
return "documentDiff" in value && typeof value.documentDiff === "string";
|
|
10
|
-
}
|
|
11
|
-
function resultFromMutation(verb, result, options) {
|
|
12
|
-
const acceptedContract = options.coordinate ?? result.facts[0]?.contract;
|
|
13
|
-
if (acceptedContract === undefined)
|
|
9
|
+
function acceptedEnvelope(result, coordinate) {
|
|
10
|
+
const contract = coordinate ?? result.facts[0]?.contract;
|
|
11
|
+
if (contract === undefined)
|
|
14
12
|
throw new Error("accepted mutation is missing its contract identity");
|
|
13
|
+
const firstLag = result.lags[0];
|
|
15
14
|
return {
|
|
16
15
|
kind: "accepted",
|
|
17
|
-
|
|
18
|
-
contract: acceptedContract,
|
|
16
|
+
contract,
|
|
19
17
|
head: result.head,
|
|
20
|
-
facts: result
|
|
21
|
-
contract: fact.contract,
|
|
22
|
-
entry: fact.entry,
|
|
23
|
-
kind: fact.kind,
|
|
24
|
-
})),
|
|
18
|
+
facts: acceptedFacts(result),
|
|
25
19
|
effects: result.effects,
|
|
26
20
|
settlement: result.settlement,
|
|
27
|
-
...(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
21
|
+
...(result.lags.length === 0 || firstLag === undefined ? {} : { lag: [firstLag, ...result.lags.slice(1)] }),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function acceptedRegion(result) {
|
|
25
|
+
if (result.overlapFailure !== undefined)
|
|
26
|
+
return { overlapFailure: result.overlapFailure };
|
|
27
|
+
return { overlaps: result.overlaps };
|
|
28
|
+
}
|
|
29
|
+
export function acceptedBind(result, target) {
|
|
30
|
+
return {
|
|
31
|
+
...acceptedEnvelope(result, undefined),
|
|
32
|
+
verb: "bind",
|
|
33
|
+
target,
|
|
34
|
+
...acceptedRegion(result),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export function acceptedAmend(result, coordinate) {
|
|
38
|
+
return {
|
|
39
|
+
...acceptedEnvelope(result, coordinate),
|
|
40
|
+
verb: "amend",
|
|
41
|
+
diff: result.documentDiff,
|
|
42
|
+
...acceptedRegion(result),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export function acceptedDeliver(result, coordinate) {
|
|
46
|
+
const value = result.value;
|
|
47
|
+
return {
|
|
48
|
+
...acceptedEnvelope(result, coordinate),
|
|
49
|
+
verb: "deliver",
|
|
50
|
+
...(value.verification === undefined ? {} : { verification: value.verification }),
|
|
51
|
+
...(value.verificationReuse === undefined ? {} : { verificationReuse: value.verificationReuse }),
|
|
52
|
+
...(value.placement === undefined ? {} : { placement: value.placement }),
|
|
53
|
+
...(value.cleanup === undefined ? {} : { cleanup: value.cleanup }),
|
|
54
|
+
...(value.leak === undefined ? {} : { leak: value.leak }),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export function acceptedReview(result, coordinate) {
|
|
58
|
+
const value = result.value;
|
|
59
|
+
return {
|
|
60
|
+
...acceptedEnvelope(result, coordinate),
|
|
61
|
+
verb: "review",
|
|
62
|
+
...(value.placement === undefined ? {} : { placement: value.placement }),
|
|
63
|
+
...(value.workspace === undefined ? {} : { workspace: value.workspace }),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export function acceptedArc(result, coordinate) {
|
|
67
|
+
return { ...acceptedEnvelope(result, coordinate), verb: "arc" };
|
|
68
|
+
}
|
|
69
|
+
export function acceptedAbandon(result, coordinate) {
|
|
70
|
+
return { ...acceptedEnvelope(result, coordinate), verb: "abandon" };
|
|
71
|
+
}
|
|
72
|
+
export function acceptedAudit(result, coordinate) {
|
|
73
|
+
return {
|
|
74
|
+
...acceptedEnvelope(result, coordinate),
|
|
75
|
+
verb: "audit",
|
|
76
|
+
report: result.value,
|
|
77
|
+
...(result.cleanup === undefined ? {} : { cleanup: result.cleanup }),
|
|
78
|
+
...(result.leak === undefined ? {} : { leak: result.leak }),
|
|
35
79
|
};
|
|
36
80
|
}
|
|
37
|
-
export async function resultFromMutationCall(verb, call, options = {}) {
|
|
81
|
+
export async function resultFromMutationCall(verb, call, project, options = {}) {
|
|
38
82
|
try {
|
|
39
|
-
|
|
40
|
-
const projected = options.project === undefined ? {} : await options.project(result);
|
|
41
|
-
return resultFromMutation(verb, result, {
|
|
42
|
-
...projected,
|
|
43
|
-
...(options.coordinate === undefined ? {} : { coordinate: options.coordinate }),
|
|
44
|
-
});
|
|
83
|
+
return project(await call());
|
|
45
84
|
}
|
|
46
85
|
catch (error) {
|
|
47
86
|
if (error instanceof KeiyakuRefused) {
|
|
@@ -49,7 +88,7 @@ export async function resultFromMutationCall(verb, call, options = {}) {
|
|
|
49
88
|
kind: "refused",
|
|
50
89
|
verb,
|
|
51
90
|
...(options.coordinate === undefined ? {} : { contract: options.coordinate }),
|
|
52
|
-
refusal: error.refusal,
|
|
91
|
+
refusal: options.projectRefusal === undefined ? error.refusal : options.projectRefusal(error.refusal),
|
|
53
92
|
};
|
|
54
93
|
}
|
|
55
94
|
if (error instanceof KeiyakuRetry) {
|
package/build/src/cli/actor.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const ACTOR_ID_ENV = "KEIYAKU_ACTOR_ID";
|
|
2
2
|
/** Resolve optional caller testimony from the current CLI edge vocabulary. */
|
|
3
3
|
export function resolveActor(input = {}) {
|
|
4
4
|
if (input.actor !== undefined) {
|
|
@@ -6,6 +6,6 @@ export function resolveActor(input = {}) {
|
|
|
6
6
|
throw new TypeError("actor must be a nonblank string");
|
|
7
7
|
return input.actor;
|
|
8
8
|
}
|
|
9
|
-
const
|
|
10
|
-
return
|
|
9
|
+
const actorId = input.env?.[ACTOR_ID_ENV];
|
|
10
|
+
return actorId !== undefined && actorId.trim().length > 0 ? actorId : undefined;
|
|
11
11
|
}
|
|
@@ -1,53 +1,78 @@
|
|
|
1
|
-
import { type AkuId, type
|
|
2
|
-
import type
|
|
3
|
-
import { type CallResult, type ForkResult, type Keiyaku as KeiyakuContract, type Repo } from "../../index.js";
|
|
1
|
+
import { type AkuId, type ActivityHistory } from "../../akuma/index.js";
|
|
2
|
+
import { Keiyaku, type AkumaKillResult, type AkumaHistoryResult, type AkumaStatusView, type AkumaTellResult, type AkumaWaitResult, type CallResult, type ForkResult, type Keiyaku as KeiyakuContract, type Repo } from "../../index.js";
|
|
4
3
|
import type { Settings } from "../../settings.js";
|
|
4
|
+
import type { WorldRoot } from "../../world.js";
|
|
5
5
|
import type { ParsedAkumaCommand } from "./akuma.js";
|
|
6
6
|
export type AkumaInvocationResult = Readonly<{
|
|
7
7
|
kind: "akuma";
|
|
8
8
|
action: "call";
|
|
9
9
|
result: CallResult;
|
|
10
|
+
world: WorldRoot;
|
|
10
11
|
}> | Readonly<{
|
|
11
12
|
kind: "akuma";
|
|
12
13
|
action: "status";
|
|
13
|
-
status:
|
|
14
|
+
status: AkumaStatusView;
|
|
15
|
+
alias?: string;
|
|
14
16
|
}> | Readonly<{
|
|
15
17
|
kind: "akuma";
|
|
16
18
|
action: "wait";
|
|
17
|
-
|
|
19
|
+
result: AkumaWaitResult;
|
|
20
|
+
alias?: string;
|
|
18
21
|
}> | Readonly<{
|
|
19
22
|
kind: "akuma";
|
|
20
23
|
action: "tell";
|
|
24
|
+
mode: "ordinary";
|
|
25
|
+
result: AkumaTellResult;
|
|
26
|
+
body: string;
|
|
27
|
+
alias?: string;
|
|
28
|
+
}> | Readonly<{
|
|
29
|
+
kind: "akuma";
|
|
30
|
+
action: "tell";
|
|
31
|
+
mode: "interrupt";
|
|
32
|
+
result: Awaited<ReturnType<typeof Keiyaku.interrupt>>;
|
|
33
|
+
body: string;
|
|
34
|
+
alias?: string;
|
|
35
|
+
}> | Readonly<{
|
|
36
|
+
kind: "akuma";
|
|
37
|
+
action: "history";
|
|
21
38
|
akuma: AkuId;
|
|
22
|
-
|
|
23
|
-
|
|
39
|
+
mode: "page";
|
|
40
|
+
history: ActivityHistory;
|
|
41
|
+
historyResult: AkumaHistoryResult;
|
|
42
|
+
alias?: string;
|
|
24
43
|
}> | Readonly<{
|
|
25
44
|
kind: "akuma";
|
|
26
|
-
action: "
|
|
45
|
+
action: "history";
|
|
27
46
|
akuma: AkuId;
|
|
28
|
-
|
|
47
|
+
mode: "last";
|
|
48
|
+
answer: string;
|
|
49
|
+
historyResult: AkumaHistoryResult;
|
|
50
|
+
alias?: string;
|
|
29
51
|
}> | Readonly<{
|
|
30
52
|
kind: "akuma";
|
|
31
53
|
action: "history";
|
|
32
54
|
akuma: AkuId;
|
|
33
|
-
|
|
34
|
-
|
|
55
|
+
mode: "no-answer";
|
|
56
|
+
historyResult: AkumaHistoryResult;
|
|
57
|
+
alias?: string;
|
|
35
58
|
}> | Readonly<{
|
|
36
59
|
kind: "akuma";
|
|
37
60
|
action: "fork";
|
|
38
|
-
akuma: AkuId;
|
|
39
61
|
receipt: ForkResult;
|
|
40
62
|
}> | Readonly<{
|
|
41
63
|
kind: "akuma";
|
|
42
64
|
action: "kill";
|
|
43
|
-
|
|
44
|
-
|
|
65
|
+
result: AkumaKillResult;
|
|
66
|
+
alias?: string;
|
|
45
67
|
}>;
|
|
46
|
-
|
|
47
|
-
path:
|
|
68
|
+
type InvokeInput = Readonly<{
|
|
69
|
+
path: WorldRoot;
|
|
70
|
+
executionCwd?: string;
|
|
48
71
|
settings: Settings;
|
|
49
72
|
contract?: KeiyakuContract;
|
|
50
73
|
repo?: Repo;
|
|
51
|
-
readStdin(): string
|
|
52
|
-
}
|
|
53
|
-
export declare function
|
|
74
|
+
readStdin(): Promise<string>;
|
|
75
|
+
}>;
|
|
76
|
+
export declare function invokeAkuma(command: ParsedAkumaCommand, input: InvokeInput): Promise<AkumaInvocationResult>;
|
|
77
|
+
export declare function invokeAkumaStatus(path: WorldRoot, akuma: string, settings: Settings, alias?: string, repo?: Repo): Promise<AkumaInvocationResult>;
|
|
78
|
+
export {};
|
|
@@ -1,68 +1,117 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { Keiyaku, } from "../../index.js";
|
|
2
|
+
function inputAlias(selector) {
|
|
3
|
+
return selector.startsWith("@") ? selector : undefined;
|
|
4
|
+
}
|
|
5
|
+
async function promptBody(command, input) {
|
|
6
|
+
return command.prompt.kind === "stdin" ? await input.readStdin() : command.prompt.value;
|
|
7
|
+
}
|
|
8
|
+
async function invokeWait(command, input) {
|
|
9
|
+
const alias = command.akuma.length === 1 ? inputAlias(command.akuma[0]) : undefined;
|
|
10
|
+
return {
|
|
11
|
+
kind: "akuma",
|
|
12
|
+
action: "wait",
|
|
13
|
+
result: await Keiyaku.wait({
|
|
14
|
+
path: input.path,
|
|
15
|
+
akuma: command.akuma,
|
|
16
|
+
settings: input.settings,
|
|
17
|
+
...(input.repo === undefined ? {} : { repo: input.repo }),
|
|
18
|
+
...(command.completion === undefined ? {} : { completion: command.completion }),
|
|
19
|
+
...(command.timeoutMs === undefined ? {} : { timeoutMs: command.timeoutMs }),
|
|
20
|
+
}),
|
|
21
|
+
...(alias === undefined ? {} : { alias }),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
async function invokeTell(command, input) {
|
|
25
|
+
const body = await promptBody(command, input);
|
|
26
|
+
if (command.interrupt) {
|
|
27
|
+
const result = await Keiyaku.interrupt({ path: input.path, akuma: command.akuma, settings: input.settings, body, ...(input.repo === undefined ? {} : { repo: input.repo }) });
|
|
28
|
+
const alias = inputAlias(command.akuma);
|
|
29
|
+
return { kind: "akuma", action: "tell", mode: "interrupt", result, body, ...(alias === undefined ? {} : { alias }) };
|
|
30
|
+
}
|
|
31
|
+
const result = await Keiyaku.tell({ path: input.path, akuma: command.akuma, settings: input.settings, body, ...(input.repo === undefined ? {} : { repo: input.repo }) });
|
|
32
|
+
const alias = inputAlias(command.akuma);
|
|
33
|
+
return { kind: "akuma", action: "tell", mode: "ordinary", result, body, ...(alias === undefined ? {} : { alias }) };
|
|
34
|
+
}
|
|
35
|
+
async function invokeHistory(command, input) {
|
|
36
|
+
const result = await Keiyaku.history({
|
|
37
|
+
path: input.path,
|
|
38
|
+
akuma: command.akuma,
|
|
39
|
+
settings: input.settings,
|
|
40
|
+
...(input.repo === undefined ? {} : { repo: input.repo }),
|
|
41
|
+
...(command.before === undefined ? {} : { before: command.before }),
|
|
42
|
+
...(command.since === undefined ? {} : { since: command.since }),
|
|
43
|
+
...(command.limit === undefined ? {} : { limit: command.limit }),
|
|
44
|
+
last: command.last,
|
|
45
|
+
});
|
|
46
|
+
return {
|
|
47
|
+
kind: "akuma",
|
|
48
|
+
action: "history",
|
|
49
|
+
akuma: result.id,
|
|
50
|
+
historyResult: result,
|
|
51
|
+
...(inputAlias(command.akuma) === undefined ? {} : { alias: command.akuma }),
|
|
52
|
+
...(result.kind === "history"
|
|
53
|
+
? { mode: "page", history: result.history }
|
|
54
|
+
: result.kind === "last"
|
|
55
|
+
? { mode: "last", answer: result.answer }
|
|
56
|
+
: { mode: "no-answer" }),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
async function invokeFork(command, input) {
|
|
60
|
+
return {
|
|
61
|
+
kind: "akuma",
|
|
62
|
+
action: "fork",
|
|
63
|
+
receipt: await Keiyaku.fork({
|
|
64
|
+
path: input.path,
|
|
65
|
+
akuma: command.akuma,
|
|
66
|
+
at: command.at,
|
|
67
|
+
settings: input.settings,
|
|
68
|
+
...(input.repo === undefined ? {} : { repo: input.repo }),
|
|
69
|
+
}),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
async function invokeKill(command, input) {
|
|
73
|
+
const alias = command.akuma.length === 1 ? inputAlias(command.akuma[0]) : undefined;
|
|
74
|
+
return {
|
|
75
|
+
kind: "akuma",
|
|
76
|
+
action: "kill",
|
|
77
|
+
result: await Keiyaku.kill({
|
|
78
|
+
path: input.path,
|
|
79
|
+
akuma: command.akuma,
|
|
80
|
+
settings: input.settings,
|
|
81
|
+
...(input.repo === undefined ? {} : { repo: input.repo }),
|
|
82
|
+
}),
|
|
83
|
+
...(alias === undefined ? {} : { alias }),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
4
86
|
export async function invokeAkuma(command, input) {
|
|
5
|
-
const world = () => Akuma.at({ path: input.path, settings: input.settings });
|
|
6
87
|
switch (command.command) {
|
|
7
88
|
case "call": {
|
|
89
|
+
const body = await promptBody(command, input);
|
|
8
90
|
const result = await Keiyaku.call({
|
|
9
91
|
path: input.path,
|
|
10
92
|
archetype: command.archetype,
|
|
11
|
-
body
|
|
93
|
+
body,
|
|
12
94
|
settings: input.settings,
|
|
13
|
-
...(
|
|
95
|
+
...(input.executionCwd === undefined ? {} : { cwd: input.executionCwd }),
|
|
14
96
|
mode: command.mode,
|
|
15
97
|
...(command.timeoutMs === undefined ? {} : { timeoutMs: command.timeoutMs }),
|
|
16
98
|
...(input.contract === undefined ? {} : { contract: input.contract }),
|
|
17
99
|
...(command.alias === undefined ? {} : { alias: command.alias }),
|
|
18
100
|
});
|
|
19
|
-
return { kind: "akuma", action: "call", result };
|
|
20
|
-
}
|
|
21
|
-
case "wait": return {
|
|
22
|
-
kind: "akuma",
|
|
23
|
-
action: "wait",
|
|
24
|
-
status: await world().of({ id: command.id }).wait(undefined, command.timeoutMs === undefined ? {} : { timeoutMs: command.timeoutMs }),
|
|
25
|
-
};
|
|
26
|
-
case "tell": {
|
|
27
|
-
const handle = world().of({ id: command.id });
|
|
28
|
-
const receipt = await handle.tell(input.readStdin());
|
|
29
|
-
return { kind: "akuma", action: "tell", akuma: command.id, receipt, status: handle.status() };
|
|
30
|
-
}
|
|
31
|
-
case "interrupt": return {
|
|
32
|
-
kind: "akuma",
|
|
33
|
-
action: "interrupt",
|
|
34
|
-
akuma: command.id,
|
|
35
|
-
receipt: await world().of({ id: command.id }).interrupt(input.readStdin()),
|
|
36
|
-
};
|
|
37
|
-
case "history": {
|
|
38
|
-
const handle = world().of({ id: command.id });
|
|
39
|
-
const history = handle.history({
|
|
40
|
-
...(command.before === undefined ? {} : { before: command.before }),
|
|
41
|
-
...(command.since === undefined ? {} : { since: command.since }),
|
|
42
|
-
});
|
|
43
|
-
return {
|
|
44
|
-
kind: "akuma",
|
|
45
|
-
action: "history",
|
|
46
|
-
akuma: command.id,
|
|
47
|
-
history,
|
|
48
|
-
...(command.last ? { answer: handle.lastAnswer() } : {}),
|
|
49
|
-
};
|
|
101
|
+
return { kind: "akuma", action: "call", result, world: input.path };
|
|
50
102
|
}
|
|
51
|
-
case "
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
path: input.path,
|
|
57
|
-
akuma: command.id,
|
|
58
|
-
at: command.at,
|
|
59
|
-
settings: input.settings,
|
|
60
|
-
...(input.repo === undefined ? {} : { repo: input.repo }),
|
|
61
|
-
}),
|
|
62
|
-
};
|
|
63
|
-
case "kill": return { kind: "akuma", action: "kill", id: command.id, evidence: await world().of({ id: command.id }).kill() };
|
|
103
|
+
case "wait": return await invokeWait(command, input);
|
|
104
|
+
case "tell": return await invokeTell(command, input);
|
|
105
|
+
case "history": return await invokeHistory(command, input);
|
|
106
|
+
case "fork": return await invokeFork(command, input);
|
|
107
|
+
case "kill": return await invokeKill(command, input);
|
|
64
108
|
}
|
|
65
109
|
}
|
|
66
|
-
export function invokeAkumaStatus(path,
|
|
67
|
-
return {
|
|
110
|
+
export async function invokeAkumaStatus(path, akuma, settings, alias, repo) {
|
|
111
|
+
return {
|
|
112
|
+
kind: "akuma",
|
|
113
|
+
action: "status",
|
|
114
|
+
status: await Keiyaku.status({ path, akuma, settings, ...(repo === undefined ? {} : { repo }) }),
|
|
115
|
+
...(alias === undefined ? {} : { alias }),
|
|
116
|
+
};
|
|
68
117
|
}
|
|
@@ -1,31 +1,43 @@
|
|
|
1
1
|
import { type AkumaAlias } from "../../identity/selector.js";
|
|
2
|
-
import { type AkuId } from "../../akuma/identity.js";
|
|
3
2
|
type Output = Readonly<{
|
|
4
3
|
output: "text" | "json";
|
|
5
4
|
}>;
|
|
6
5
|
type Addressed = Readonly<{
|
|
7
|
-
|
|
6
|
+
akuma: string;
|
|
8
7
|
}>;
|
|
9
|
-
export type
|
|
8
|
+
export type AkumaPromptSource = Readonly<{
|
|
9
|
+
kind: "argument";
|
|
10
|
+
value: string;
|
|
11
|
+
}> | Readonly<{
|
|
12
|
+
kind: "stdin";
|
|
13
|
+
}>;
|
|
14
|
+
type Prompted = Readonly<{
|
|
15
|
+
prompt: AkumaPromptSource;
|
|
16
|
+
}>;
|
|
17
|
+
export type ParsedAkumaCommand = Output & ((Readonly<{
|
|
10
18
|
command: "call";
|
|
11
19
|
archetype: string;
|
|
12
|
-
workdir?: string;
|
|
13
20
|
contract?: string;
|
|
14
21
|
alias?: AkumaAlias;
|
|
15
22
|
mode: "wait" | "detach";
|
|
16
23
|
timeoutMs?: number;
|
|
17
|
-
}> |
|
|
24
|
+
}> & Prompted) | Readonly<{
|
|
18
25
|
command: "kill";
|
|
19
|
-
|
|
26
|
+
akuma: readonly string[];
|
|
27
|
+
}> | Readonly<{
|
|
20
28
|
command: "wait";
|
|
29
|
+
akuma: readonly string[];
|
|
30
|
+
completion?: "any" | "all";
|
|
21
31
|
timeoutMs?: number;
|
|
22
|
-
}>
|
|
23
|
-
command: "tell"
|
|
24
|
-
|
|
32
|
+
}> | (Readonly<{
|
|
33
|
+
command: "tell";
|
|
34
|
+
interrupt: boolean;
|
|
35
|
+
}> & Addressed & Prompted) | (Readonly<{
|
|
25
36
|
command: "history";
|
|
26
37
|
last: boolean;
|
|
27
38
|
before?: number;
|
|
28
39
|
since?: number;
|
|
40
|
+
limit?: number;
|
|
29
41
|
}> & Addressed) | (Readonly<{
|
|
30
42
|
command: "fork";
|
|
31
43
|
at: string;
|
|
@@ -38,5 +50,11 @@ export declare function isParsedAkumaCommand(command: Readonly<{
|
|
|
38
50
|
export declare function renderAkumaRootRows(): readonly string[];
|
|
39
51
|
export declare function renderAkumaHelp(action: AkumaAction): string;
|
|
40
52
|
export declare function renderAkumaUsage(action: AkumaAction): string;
|
|
53
|
+
export declare function parseAkumaCatalogPath(value: string): Readonly<{
|
|
54
|
+
kind: "archetypes";
|
|
55
|
+
} | {
|
|
56
|
+
kind: "akuma";
|
|
57
|
+
archetype?: string;
|
|
58
|
+
}> | null;
|
|
41
59
|
export declare function parseAkumaCommand(argv: readonly string[]): ParsedAkumaCommand;
|
|
42
60
|
export {};
|