@astrosheep/keiyaku 4.6.30 → 4.6.31
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 +5 -5
- package/build/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/build/plugins/claude/skills/keiyaku/SKILL.md +12 -12
- package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +16 -16
- package/build/plugins/claude/skills/keiyaku-akuma/references/automation.md +14 -14
- package/build/plugins/claude/skills/keiyaku-babysit/SKILL.md +10 -10
- package/build/plugins/claude/skills/keiyaku-bind/SKILL.md +15 -15
- package/build/plugins/claude/skills/keiyaku-debt/SKILL.md +16 -16
- package/build/plugins/claude/skills/keiyaku-workflow/SKILL.md +21 -21
- package/build/plugins/codex/.codex-plugin/plugin.json +1 -1
- package/build/plugins/codex/skills/keiyaku/SKILL.md +12 -12
- package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +16 -16
- package/build/plugins/codex/skills/keiyaku-akuma/references/automation.md +14 -14
- package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +10 -10
- package/build/plugins/codex/skills/keiyaku-bind/SKILL.md +15 -15
- package/build/plugins/codex/skills/keiyaku-debt/SKILL.md +16 -16
- package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +21 -21
- package/build/plugins/opencode/package.json +1 -1
- package/build/plugins/opencode/skills/keiyaku/SKILL.md +12 -12
- package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +16 -16
- package/build/plugins/opencode/skills/keiyaku-akuma/references/automation.md +14 -14
- package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +10 -10
- package/build/plugins/opencode/skills/keiyaku-bind/SKILL.md +15 -15
- package/build/plugins/opencode/skills/keiyaku-debt/SKILL.md +16 -16
- package/build/plugins/opencode/skills/keiyaku-workflow/SKILL.md +21 -21
- package/build/plugins/pi/README.md +5 -5
- package/build/plugins/pi/akuma-tools.ts +17 -23
- package/build/skills/keiyaku/SKILL.md +12 -12
- package/build/skills/keiyaku-akuma/SKILL.md +16 -16
- package/build/skills/keiyaku-akuma/references/automation.md +14 -14
- package/build/skills/keiyaku-babysit/SKILL.md +10 -10
- package/build/skills/keiyaku-bind/SKILL.md +15 -15
- package/build/skills/keiyaku-debt/SKILL.md +16 -16
- package/build/skills/keiyaku-workflow/SKILL.md +21 -21
- package/build/src/akuma/akuma-call.d.ts +1 -1
- package/build/src/akuma/akuma-call.js +9 -9
- package/build/src/akuma/akuma-errors.d.ts +5 -5
- package/build/src/akuma/akuma-instance.d.ts +355 -12
- package/build/src/akuma/akuma-instance.js +20 -20
- package/build/src/akuma/akuma-observe.d.ts +11 -12
- package/build/src/akuma/akuma-observe.js +34 -26
- package/build/src/akuma/akuma-owner.d.ts +32 -11
- package/build/src/akuma/akuma-owner.js +35 -16
- package/build/src/akuma/akuma-probe.d.ts +3 -3
- package/build/src/akuma/akuma-probe.js +2 -2
- package/build/src/akuma/akuma-selection-execution.d.ts +985 -1
- package/build/src/akuma/akuma-selection-execution.js +42 -18
- package/build/src/akuma/akuma-stream.d.ts +2 -2
- package/build/src/akuma/akuma-stream.js +1 -1
- package/build/src/akuma/akuma-wait.d.ts +5 -5
- package/build/src/akuma/akuma-wait.js +52 -14
- package/build/src/akuma/akuma.d.ts +245 -271
- package/build/src/akuma/akuma.js +98 -46
- package/build/src/akuma/archetype.d.ts +19 -6
- package/build/src/akuma/archetype.js +25 -9
- package/build/src/akuma/body-launch.d.ts +2 -2
- package/build/src/akuma/body.js +4 -4
- package/build/src/akuma/call-initial-tell.d.ts +60 -44
- package/build/src/akuma/call-initial-tell.js +41 -2
- package/build/src/akuma/caller.d.ts +26 -17
- package/build/src/akuma/caller.js +22 -9
- package/build/src/akuma/coordinate.d.ts +9 -0
- package/build/src/akuma/coordinate.js +13 -0
- package/build/src/akuma/detached-body.js +2 -2
- package/build/src/akuma/dispatch-association.d.ts +4 -4
- package/build/src/akuma/dispatch-association.js +12 -3
- package/build/src/akuma/execution-instructions.js +2 -2
- package/build/src/akuma/heart/facts.d.ts +29 -7
- package/build/src/akuma/heart/facts.js +13 -0
- package/build/src/akuma/heart/index.d.ts +0 -3
- package/build/src/akuma/heart/index.js +3 -6
- package/build/src/akuma/heart/rows.js +2 -2
- package/build/src/akuma/heart/soul.js +5 -5
- package/build/src/akuma/identity.d.ts +17 -16
- package/build/src/akuma/identity.js +20 -19
- package/build/src/akuma/index.d.ts +1 -2
- package/build/src/akuma/lineage-cache.d.ts +4 -4
- package/build/src/akuma/lineage-cache.js +10 -10
- package/build/src/akuma/projection-read.d.ts +2 -5
- package/build/src/akuma/projection-read.js +34 -47
- package/build/src/akuma/projection.d.ts +659 -569
- package/build/src/akuma/projection.js +203 -94
- package/build/src/akuma/providers/acp/index.js +1 -1
- package/build/src/akuma/providers/execution-environment.d.ts +1 -3
- package/build/src/akuma/providers/execution-environment.js +0 -4
- package/build/src/akuma/publication.d.ts +2 -2
- package/build/src/akuma/publication.js +3 -3
- package/build/src/akuma/retention.js +2 -2
- package/build/src/akuma/selection-observation.d.ts +507 -43
- package/build/src/akuma/selection-observation.js +153 -1
- package/build/src/akuma/status-projection.d.ts +288 -0
- package/build/src/akuma/status-projection.js +154 -0
- package/build/src/akuma/turn-drive.js +0 -3
- package/build/src/alias/index.d.ts +9 -4
- package/build/src/alias/index.js +11 -9
- package/build/src/bounded-list.d.ts +8 -0
- package/build/src/bounded-list.js +9 -0
- package/build/src/cli/commands/akuma-grammar.d.ts +2 -2
- package/build/src/cli/commands/akuma-grammar.js +21 -21
- package/build/src/cli/commands/akuma.d.ts +1 -2
- package/build/src/cli/commands/akuma.js +115 -251
- package/build/src/cli/commands/contract-grammar.d.ts +4 -3
- package/build/src/cli/commands/contract-grammar.js +39 -22
- package/build/src/cli/commands/contract-help.d.ts +3 -1
- package/build/src/cli/commands/contract-help.js +4 -3
- package/build/src/cli/commands/contract.d.ts +6 -3
- package/build/src/cli/commands/contract.js +203 -434
- package/build/src/cli/commands/debt.d.ts +2 -3
- package/build/src/cli/commands/debt.js +101 -317
- package/build/src/cli/commands/report.js +11 -28
- package/build/src/cli/commands/whoami.d.ts +3 -43
- package/build/src/cli/commands/whoami.js +8 -121
- package/build/src/cli/coordinates.d.ts +4 -35
- package/build/src/cli/coordinates.js +13 -129
- package/build/src/cli/parse.d.ts +0 -6
- package/build/src/cli/parse.js +5 -48
- package/build/src/cli/render/akuma-activity.d.ts +31 -16
- package/build/src/cli/render/akuma-activity.js +157 -149
- package/build/src/cli/render/akuma-tool.d.ts +3 -6
- package/build/src/cli/render/akuma-tool.js +20 -14
- package/build/src/cli/render/akuma.d.ts +25 -26
- package/build/src/cli/render/akuma.js +100 -129
- package/build/src/cli/render/catalog.d.ts +4 -7
- package/build/src/cli/render/catalog.js +52 -99
- package/build/src/cli/render/contract-history.d.ts +3 -1
- package/build/src/cli/render/contract-history.js +140 -215
- package/build/src/cli/render/contract-observation.d.ts +43 -30
- package/build/src/cli/render/contract-observation.js +64 -31
- package/build/src/cli/render/contract-wait.js +6 -6
- package/build/src/cli/render/contract.d.ts +41 -6
- package/build/src/cli/render/contract.js +274 -370
- package/build/src/cli/render/debt.d.ts +9 -19
- package/build/src/cli/render/debt.js +120 -185
- package/build/src/cli/render/delivery-preview.d.ts +4 -3
- package/build/src/cli/render/delivery-preview.js +68 -96
- package/build/src/cli/render/kanshi-akuma.d.ts +4 -4
- package/build/src/cli/render/kanshi-akuma.js +70 -59
- package/build/src/cli/render/kanshi.d.ts +4 -4
- package/build/src/cli/render/kanshi.js +205 -221
- package/build/src/cli/render/marks.d.ts +11 -2
- package/build/src/cli/render/marks.js +13 -3
- package/build/src/cli/render/nuke.d.ts +3 -3
- package/build/src/cli/render/nuke.js +13 -16
- package/build/src/cli/render/receipt.d.ts +37 -43
- package/build/src/cli/render/receipt.js +313 -236
- package/build/src/cli/render/reconcile.d.ts +6 -4
- package/build/src/cli/render/reconcile.js +53 -137
- package/build/src/cli/render/refusal.d.ts +3 -2
- package/build/src/cli/render/refusal.js +73 -54
- package/build/src/cli/render/region.d.ts +11 -2
- package/build/src/cli/render/region.js +17 -23
- package/build/src/cli/render/settings.d.ts +0 -1
- package/build/src/cli/render/settings.js +8 -17
- package/build/src/cli/render/terminal.d.ts +2 -0
- package/build/src/cli/render/verbs.d.ts +4 -0
- package/build/src/cli/render/verbs.js +312 -0
- package/build/src/cli/render/whoami.d.ts +1 -1
- package/build/src/cli/render/whoami.js +24 -31
- package/build/src/cli/runtime.d.ts +3 -11
- package/build/src/cli/runtime.js +96 -79
- package/build/src/cli/scan.d.ts +1 -1
- package/build/src/cli/streams.js +1 -0
- package/build/src/contract-guidance.js +2 -2
- package/build/src/contract-worktree.d.ts +2 -15
- package/build/src/contract-worktree.js +19 -35
- package/build/src/core/facts/observation.d.ts +4 -5
- package/build/src/core/facts/observation.js +7 -9
- package/build/src/core/verbs/amend.d.ts +0 -1
- package/build/src/core/verbs/amend.js +3 -3
- package/build/src/core/verbs/bind.d.ts +0 -1
- package/build/src/core/verbs/bind.js +5 -5
- package/build/src/core/verbs/deliver.d.ts +3 -2
- package/build/src/core/verbs/deliver.js +2 -2
- package/build/src/core/verbs/placement.d.ts +0 -5
- package/build/src/core/verbs/placement.js +4 -6
- package/build/src/core/verbs/reintegrate.d.ts +0 -1
- package/build/src/core/verbs/reintegrate.js +2 -2
- package/build/src/debt/board.d.ts +132 -116
- package/build/src/debt/board.js +138 -94
- package/build/src/debt/catalog.d.ts +4 -4
- package/build/src/debt/catalog.js +2 -18
- package/build/src/debt/context.d.ts +15 -3
- package/build/src/debt/context.js +12 -1
- package/build/src/debt/created-observation.d.ts +5 -17
- package/build/src/debt/created-observation.js +14 -6
- package/build/src/debt/document.d.ts +20 -15
- package/build/src/debt/document.js +18 -1
- package/build/src/debt/index.d.ts +346 -23
- package/build/src/debt/index.js +68 -22
- package/build/src/debt/input.d.ts +2 -1
- package/build/src/debt/input.js +14 -0
- package/build/src/debt/lifecycle-operations.d.ts +2 -2
- package/build/src/debt/lifecycle-operations.js +14 -22
- package/build/src/debt/operation-types.d.ts +188 -66
- package/build/src/debt/operation-types.js +113 -1
- package/build/src/debt/operations.d.ts +11 -10
- package/build/src/debt/operations.js +46 -71
- package/build/src/debt/query.d.ts +14 -10
- package/build/src/debt/query.js +3 -12
- package/build/src/debt/store.d.ts +4 -2
- package/build/src/debt/store.js +8 -8
- package/build/src/debt/view.d.ts +0 -3
- package/build/src/debt/view.js +0 -4
- package/build/src/dispatch/index.d.ts +22 -5
- package/build/src/dispatch/index.js +46 -37
- package/build/src/git/admission.d.ts +2 -2
- package/build/src/git/admission.js +2 -1
- package/build/src/git/hooks.d.ts +14 -35
- package/build/src/git/hooks.js +45 -25
- package/build/src/git/integration.d.ts +6 -24
- package/build/src/git/integration.js +10 -16
- package/build/src/git/private-state-seat.d.ts +2 -2
- package/build/src/git/private-state-seat.js +2 -1
- package/build/src/git/reconcile.d.ts +17 -79
- package/build/src/git/reconcile.js +37 -52
- package/build/src/git/scratch.d.ts +3 -3
- package/build/src/git/scratch.js +4 -1
- package/build/src/git/target-placement.d.ts +23 -31
- package/build/src/git/target-placement.js +42 -27
- package/build/src/git/target.d.ts +2 -2
- package/build/src/git/target.js +2 -1
- package/build/src/git/tender.d.ts +7 -39
- package/build/src/git/tender.js +21 -54
- package/build/src/git/terminal-reconcile.js +15 -18
- package/build/src/git/terminal-seal.d.ts +2 -4
- package/build/src/git/terminal-seal.js +7 -33
- package/build/src/git/workspace.d.ts +65 -41
- package/build/src/git/workspace.js +45 -14
- package/build/src/identity/selector.d.ts +2 -0
- package/build/src/identity/selector.js +13 -3
- package/build/src/index.d.ts +48 -54
- package/build/src/index.js +31 -43
- package/build/src/kanshi/counts.d.ts +42 -8
- package/build/src/kanshi/counts.js +13 -2
- package/build/src/kanshi/index.d.ts +5 -5
- package/build/src/kanshi/index.js +4 -3
- package/build/src/kanshi/read.d.ts +489 -6
- package/build/src/kanshi/read.js +334 -483
- package/build/src/kanshi/report.d.ts +2504 -103
- package/build/src/kanshi/report.js +165 -1
- package/build/src/kanshi/select.d.ts +0 -8
- package/build/src/kanshi/select.js +20 -59
- package/build/src/library/address.d.ts +8 -8
- package/build/src/library/address.js +7 -7
- package/build/src/library/akuma-creation.d.ts +690 -84
- package/build/src/library/akuma-creation.js +202 -142
- package/build/src/library/akuma-retention.d.ts +2 -2
- package/build/src/library/akuma-retention.js +2 -2
- package/build/src/library/akumas.d.ts +10 -6
- package/build/src/library/akumas.js +24 -7
- package/build/src/library/bind.d.ts +28 -54
- package/build/src/library/bind.js +6 -4
- package/build/src/library/continuation.d.ts +197 -479
- package/build/src/library/continuation.js +40 -23
- package/build/src/library/contract-address.d.ts +6 -5
- package/build/src/library/contract-address.js +5 -7
- package/build/src/library/contract-composition.d.ts +18 -12
- package/build/src/library/contract-composition.js +55 -47
- package/build/src/library/contract-creation.d.ts +3 -2
- package/build/src/library/contract-creation.js +38 -32
- package/build/src/library/contract-execution.js +77 -38
- package/build/src/library/contract-outcomes.d.ts +1877 -27
- package/build/src/library/contract-outcomes.js +93 -10
- package/build/src/library/contract-settings.d.ts +2 -2
- package/build/src/library/contract-settings.js +18 -14
- package/build/src/library/contract-types.d.ts +238 -61
- package/build/src/library/contract-types.js +131 -1
- package/build/src/library/contract-wait.d.ts +38 -17
- package/build/src/library/contract-wait.js +40 -10
- package/build/src/library/delivery.d.ts +588 -36
- package/build/src/library/delivery.js +35 -27
- package/build/src/library/input.d.ts +1 -1
- package/build/src/library/input.js +1 -2
- package/build/src/library/invocation.d.ts +11 -7
- package/build/src/library/invocation.js +42 -51
- package/build/src/library/kei.d.ts +48 -0
- package/build/src/library/kei.js +256 -0
- package/build/src/library/keiyaku-attribution.d.ts +11 -0
- package/build/src/{cli/delivery-identity.js → library/keiyaku-attribution.js} +12 -1
- package/build/src/library/keiyaku-classify.d.ts +11 -0
- package/build/src/library/keiyaku-classify.js +146 -0
- package/build/src/library/keiyaku-coordinates.d.ts +31 -0
- package/build/src/library/keiyaku-coordinates.js +103 -0
- package/build/src/library/keiyaku-debt.d.ts +142 -0
- package/build/src/library/keiyaku-debt.js +188 -0
- package/build/src/library/keiyaku-identity.d.ts +58 -0
- package/build/src/library/keiyaku-identity.js +176 -0
- package/build/src/library/keiyaku-policy.d.ts +27 -0
- package/build/src/library/keiyaku-policy.js +44 -0
- package/build/src/library/keiyaku-status.d.ts +1487 -0
- package/build/src/library/keiyaku-status.js +92 -0
- package/build/src/library/keiyaku-verbs.d.ts +6774 -0
- package/build/src/library/keiyaku-verbs.js +458 -0
- package/build/src/library/keiyaku.d.ts +871 -38
- package/build/src/library/keiyaku.js +677 -127
- package/build/src/library/nuke.d.ts +22 -0
- package/build/src/library/nuke.js +4 -1
- package/build/src/library/outcome.d.ts +706 -692
- package/build/src/library/outcome.js +582 -167
- package/build/src/library/reconcile.d.ts +464 -116
- package/build/src/library/reconcile.js +174 -102
- package/build/src/library/refusal.d.ts +113 -577
- package/build/src/library/refusal.js +64 -51
- package/build/src/library/region.d.ts +5 -24
- package/build/src/library/region.js +6 -21
- package/build/src/library/selection.d.ts +181 -32
- package/build/src/library/selection.js +99 -64
- package/build/src/mcp/adapter.d.ts +11 -0
- package/build/src/mcp/adapter.js +106 -0
- package/build/src/mcp/help.d.ts +1 -0
- package/build/src/mcp/help.js +26 -0
- package/build/src/mcp/index.d.ts +2 -0
- package/build/src/mcp/index.js +37 -0
- package/build/src/plugin/public.d.ts +1 -1
- package/build/src/plugin/runtime.js +17 -14
- package/build/src/protocol/arc.d.ts +4 -1
- package/build/src/protocol/arc.js +7 -1
- package/build/src/protocol/attempt.d.ts +2 -3
- package/build/src/protocol/attempt.js +1 -10
- package/build/src/protocol/bind.d.ts +6 -7
- package/build/src/protocol/bind.js +9 -5
- package/build/src/protocol/completion.d.ts +448 -12
- package/build/src/protocol/completion.js +164 -26
- package/build/src/protocol/deliver.d.ts +26 -24
- package/build/src/protocol/deliver.js +24 -52
- package/build/src/protocol/delivery-preview.d.ts +97 -247
- package/build/src/protocol/delivery-preview.js +132 -128
- package/build/src/protocol/execution-observation.d.ts +146 -123
- package/build/src/protocol/execution-observation.js +9 -6
- package/build/src/protocol/intent.d.ts +9 -48
- package/build/src/protocol/intent.js +32 -46
- package/build/src/protocol/operations.d.ts +207 -505
- package/build/src/protocol/operations.js +81 -134
- package/build/src/protocol/placement.d.ts +0 -1
- package/build/src/protocol/placement.js +5 -2
- package/build/src/protocol/progress.d.ts +7 -97
- package/build/src/protocol/progress.js +7 -55
- package/build/src/protocol/read/observation.d.ts +13 -6
- package/build/src/protocol/read/observation.js +10 -9
- package/build/src/protocol/read/status.d.ts +464 -93
- package/build/src/protocol/read/status.js +372 -85
- package/build/src/protocol/reconcile.d.ts +2 -0
- package/build/src/protocol/reconcile.js +12 -11
- package/build/src/protocol/reintegrate.d.ts +0 -1
- package/build/src/protocol/reintegrate.js +4 -4
- package/build/src/protocol/result-leaves.d.ts +528 -0
- package/build/src/protocol/result-leaves.js +195 -0
- package/build/src/protocol/result-reasons.d.ts +129 -0
- package/build/src/protocol/result-reasons.js +87 -0
- package/build/src/protocol/review.d.ts +14 -11
- package/build/src/protocol/review.js +30 -14
- package/build/src/protocol/run.d.ts +4 -4
- package/build/src/protocol/run.js +4 -1
- package/build/src/protocol/verify.d.ts +359 -30
- package/build/src/protocol/verify.js +118 -28
- package/build/src/region.d.ts +26 -0
- package/build/src/region.js +28 -0
- package/build/src/runtime/proc/diagnostic.d.ts +11 -0
- package/build/src/runtime/proc/diagnostic.js +20 -0
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/build/src/settings.d.ts +126 -32
- package/build/src/settings.js +107 -34
- package/build/src/settlement/settle.d.ts +29 -12
- package/build/src/settlement/settle.js +22 -15
- package/build/src/verification/declaration.d.ts +1 -3
- package/build/src/verification/declaration.js +2 -5
- package/build/src/verification/execution.d.ts +7 -19
- package/build/src/verification/execution.js +37 -16
- package/build/src/verification/observation.d.ts +13 -13
- package/build/src/verification/observation.js +9 -7
- package/build/src/world.d.ts +8 -0
- package/build/src/world.js +7 -0
- package/package.json +6 -5
- package/plugins/paseo/plugin/server/keiyaku.ts +13 -46
- package/plugins/paseo/plugin/server/message.ts +8 -30
- package/plugins/paseo/plugin/server/mirror.ts +16 -20
- package/plugins/paseo/plugin/server/provider.ts +1 -1
- package/plugins/paseo/plugin/server/sdk.ts +14 -6
- package/plugins/pi/README.md +5 -5
- package/plugins/pi/akuma-tools.ts +17 -23
- package/skills/keiyaku/SKILL.md +12 -12
- package/skills/keiyaku-akuma/SKILL.md +16 -16
- package/skills/keiyaku-akuma/references/automation.md +14 -14
- package/skills/keiyaku-babysit/SKILL.md +10 -10
- package/skills/keiyaku-bind/SKILL.md +15 -15
- package/skills/keiyaku-debt/SKILL.md +16 -16
- package/skills/keiyaku-workflow/SKILL.md +21 -21
- package/build/src/cli/actor.d.ts +0 -10
- package/build/src/cli/actor.js +0 -24
- package/build/src/cli/akuma-caller.d.ts +0 -3
- package/build/src/cli/akuma-caller.js +0 -31
- package/build/src/cli/delivery-identity.d.ts +0 -3
- package/build/src/cli/render/effects.d.ts +0 -26
- package/build/src/cli/render/effects.js +0 -41
- package/build/src/cli/selectors.d.ts +0 -10
- package/build/src/cli/selectors.js +0 -42
- package/build/src/markdown/diff.d.ts +0 -1
- package/build/src/markdown/diff.js +0 -4
|
@@ -1,133 +1,683 @@
|
|
|
1
1
|
/** @architectureCompositionRoot */
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
import { isAbsolute, resolve } from "node:path";
|
|
3
|
+
import { ZodError } from "zod";
|
|
4
|
+
import { Schema } from "../akuma/schema.js";
|
|
5
|
+
import { verbs, } from "./keiyaku-verbs.js";
|
|
6
|
+
import { canonicalBirthCwd } from "../akuma/call-input.js";
|
|
7
|
+
import { World, WorldError } from "../world.js";
|
|
8
|
+
import { Akuma } from "../akuma/akuma-instance.js";
|
|
9
|
+
import { kanshi } from "../kanshi/index.js";
|
|
10
|
+
import { Akumas, } from "./akumas.js";
|
|
11
|
+
import { deliveryOwner, resolveActor } from "./keiyaku-attribution.js";
|
|
12
|
+
import { akumaCallerFromEnvironment } from "./keiyaku-identity.js";
|
|
13
|
+
import { settings } from "../settings.js";
|
|
14
|
+
import { Keis } from "./contract-composition.js";
|
|
15
|
+
import { validateArcMarkdown } from "./input.js";
|
|
16
|
+
import { KeiyakuError } from "./outcome.js";
|
|
17
|
+
import { invocationCoordinates, KeiyakuArcDocumentError, KeiyakuUsageError } from "./keiyaku-coordinates.js";
|
|
18
|
+
import { whoami } from "./keiyaku-identity.js";
|
|
19
|
+
import { nukeKeiyaku } from "./nuke.js";
|
|
20
|
+
import { statusAt } from "./keiyaku-status.js";
|
|
21
|
+
import { listArchetypeDefinitions } from "../akuma/archetype.js";
|
|
22
|
+
import * as debt from "./keiyaku-debt.js";
|
|
23
|
+
export { KeiyakuArcDocumentError, KeiyakuUsageError } from "./keiyaku-coordinates.js";
|
|
16
24
|
export class Keiyaku {
|
|
17
|
-
static
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
static verbs = verbs;
|
|
26
|
+
#input;
|
|
27
|
+
constructor(input) {
|
|
28
|
+
this.#input = { ...input, environment: { ...input.environment } };
|
|
29
|
+
}
|
|
30
|
+
static at(input) {
|
|
31
|
+
if (typeof input?.cwd !== "string" || !isAbsolute(input.cwd))
|
|
32
|
+
throw new TypeError("cwd must be an absolute string");
|
|
33
|
+
if (typeof input.environment !== "object" ||
|
|
34
|
+
input.environment === null ||
|
|
35
|
+
Array.isArray(input.environment) ||
|
|
36
|
+
Object.values(input.environment).some((value) => value !== undefined && typeof value !== "string"))
|
|
37
|
+
throw new TypeError("environment must be a string record");
|
|
38
|
+
if (input.home !== undefined && typeof input.home !== "string")
|
|
39
|
+
throw new TypeError("home must be a string");
|
|
40
|
+
if (input.repo !== undefined && typeof input.repo !== "string")
|
|
41
|
+
throw new TypeError("repo must be a string");
|
|
42
|
+
return new Keiyaku(input);
|
|
43
|
+
}
|
|
44
|
+
async run(name, input, run) {
|
|
45
|
+
let parsed;
|
|
46
|
+
try {
|
|
47
|
+
parsed = verbs[name].input.parse(input);
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
if (error instanceof ZodError)
|
|
51
|
+
throw new KeiyakuUsageError(error.message);
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
return (await this.#dispatch({ name, input: parsed }, run));
|
|
55
|
+
}
|
|
56
|
+
async #dispatch(request, run) {
|
|
57
|
+
const signal = run?.signal === undefined ? {} : { signal: run.signal };
|
|
58
|
+
const observe = run?.observe;
|
|
59
|
+
const notify = (event) => {
|
|
60
|
+
try {
|
|
61
|
+
const result = observe?.(event);
|
|
62
|
+
if (result !== undefined)
|
|
63
|
+
void Promise.resolve(result).catch(() => undefined);
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
/* Observation cannot affect execution. */
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
switch (request.name) {
|
|
70
|
+
case "bind":
|
|
71
|
+
return this.#bind(request.input);
|
|
72
|
+
case "amend":
|
|
73
|
+
return this.#amend(request.input);
|
|
74
|
+
case "arc":
|
|
75
|
+
return this.#arc(request.input);
|
|
76
|
+
case "deliver":
|
|
77
|
+
return this.#deliver({ ...request.input, ...signal }, observe === undefined ? undefined : { observe: (event) => notify(event) });
|
|
78
|
+
case "deliver.preview":
|
|
79
|
+
return this.#previewDelivery({ ...request.input, ...signal }, observe === undefined ? undefined : { observe: (event) => notify(event) });
|
|
80
|
+
case "verify":
|
|
81
|
+
return this.#verify({ ...request.input, ...signal }, observe === undefined ? undefined : { observe: (event) => notify(event) });
|
|
82
|
+
case "review":
|
|
83
|
+
return this.#review({ ...request.input, ...signal }, observe === undefined ? undefined : { observe: (event) => notify(event) });
|
|
84
|
+
case "abandon":
|
|
85
|
+
return this.#abandon(request.input);
|
|
86
|
+
case "show":
|
|
87
|
+
return this.#show(request.input);
|
|
88
|
+
case "reconcile":
|
|
89
|
+
return this.#reconcile(request.input);
|
|
90
|
+
case "spawn":
|
|
91
|
+
case "fork":
|
|
92
|
+
case "tell":
|
|
93
|
+
case "ask":
|
|
94
|
+
case "kill":
|
|
95
|
+
case "wait":
|
|
96
|
+
case "history":
|
|
97
|
+
case "report":
|
|
98
|
+
return this.#dispatchAkuma(request, run, notify);
|
|
99
|
+
case "whoami":
|
|
100
|
+
return this.#whoami();
|
|
101
|
+
case "settings":
|
|
102
|
+
return this.#settings();
|
|
103
|
+
case "nuke":
|
|
104
|
+
return this.#nuke(request.input);
|
|
105
|
+
case "status":
|
|
106
|
+
return this.#status(request.input);
|
|
107
|
+
case "region":
|
|
108
|
+
return this.#region(request.input);
|
|
109
|
+
case "ls":
|
|
110
|
+
return this.#ls(request.input);
|
|
111
|
+
case "debt.add":
|
|
112
|
+
case "debt.addDocument":
|
|
113
|
+
case "debt.update":
|
|
114
|
+
case "debt.show":
|
|
115
|
+
case "debt.done":
|
|
116
|
+
case "debt.drop":
|
|
117
|
+
case "debt.ready":
|
|
118
|
+
case "debt.blocked":
|
|
119
|
+
case "debt.query":
|
|
120
|
+
case "debt.tree":
|
|
121
|
+
case "debt.doctor":
|
|
122
|
+
case "debt.context":
|
|
123
|
+
return this.#dispatchDebt(request, signal);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
#dispatchAkuma(request, run, notify) {
|
|
127
|
+
const signal = run?.signal === undefined ? {} : { signal: run.signal };
|
|
128
|
+
const observe = run?.observe;
|
|
129
|
+
switch (request.name) {
|
|
130
|
+
case "spawn": {
|
|
131
|
+
const { schema, ...input } = request.input;
|
|
132
|
+
const decode = run?.decode ?? ((value) => value);
|
|
133
|
+
return this.#spawn({
|
|
134
|
+
...input,
|
|
135
|
+
...signal,
|
|
136
|
+
...(schema === undefined ? {} : { schema: Schema.json(schema, decode) }),
|
|
137
|
+
...(observe === undefined
|
|
138
|
+
? {}
|
|
139
|
+
: {
|
|
140
|
+
observe: {
|
|
141
|
+
admitted: (tell, id, head) => notify({ kind: "admitted", tell, id, head }),
|
|
142
|
+
observe: (observation) => notify({ kind: "live", observation }),
|
|
143
|
+
},
|
|
144
|
+
}),
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
case "fork":
|
|
148
|
+
return this.#fork(request.input);
|
|
149
|
+
case "tell":
|
|
150
|
+
return this.#tell({ ...request.input, ...signal });
|
|
151
|
+
case "ask": {
|
|
152
|
+
const { schema, ...input } = request.input;
|
|
153
|
+
const decode = run?.decode ?? ((value) => value);
|
|
154
|
+
return this.#ask({
|
|
155
|
+
...input,
|
|
156
|
+
...signal,
|
|
157
|
+
...(schema === undefined ? {} : { schema: Schema.json(schema, decode) }),
|
|
158
|
+
...(observe === undefined
|
|
159
|
+
? {}
|
|
160
|
+
: {
|
|
161
|
+
observe: {
|
|
162
|
+
admitted: (tell, id) => notify({ kind: "admitted", tell, id }),
|
|
163
|
+
observe: (observation) => notify({ kind: "live", observation }),
|
|
164
|
+
},
|
|
165
|
+
}),
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
case "kill":
|
|
169
|
+
return this.#kill({ ...request.input, ...signal });
|
|
170
|
+
case "wait":
|
|
171
|
+
return this.#wait({ ...request.input, ...signal });
|
|
172
|
+
case "history":
|
|
173
|
+
return this.#history(request.input);
|
|
174
|
+
case "report":
|
|
175
|
+
return this.#report({ ...request.input, ...signal });
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
#dispatchDebt(request, signal) {
|
|
179
|
+
switch (request.name) {
|
|
180
|
+
case "debt.add":
|
|
181
|
+
return debt.debtAdd(this.#input, { ...request.input, ...signal }, false);
|
|
182
|
+
case "debt.addDocument":
|
|
183
|
+
return debt.debtAdd(this.#input, { ...request.input, ...signal }, true);
|
|
184
|
+
case "debt.update":
|
|
185
|
+
return debt.debtUpdate(this.#input, { ...request.input, ...signal });
|
|
186
|
+
case "debt.show":
|
|
187
|
+
return debt.debtShow(this.#input, request.input);
|
|
188
|
+
case "debt.done":
|
|
189
|
+
return debt.debtClose(this.#input, { ...request.input, ...signal }, "done");
|
|
190
|
+
case "debt.drop":
|
|
191
|
+
return debt.debtClose(this.#input, { ...request.input, ...signal }, "drop");
|
|
192
|
+
case "debt.ready":
|
|
193
|
+
return debt.debtReady(this.#input, request.input, false);
|
|
194
|
+
case "debt.blocked":
|
|
195
|
+
return debt.debtReady(this.#input, request.input, true);
|
|
196
|
+
case "debt.query":
|
|
197
|
+
return debt.debtQuery(this.#input, request.input);
|
|
198
|
+
case "debt.tree":
|
|
199
|
+
return debt.debtTree(this.#input, request.input);
|
|
200
|
+
case "debt.doctor":
|
|
201
|
+
return debt.debtDoctor(this.#input);
|
|
202
|
+
case "debt.context":
|
|
203
|
+
return debt.debtContext(this.#input, request.input);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
bind(input) {
|
|
207
|
+
return this.run("bind", input);
|
|
208
|
+
}
|
|
209
|
+
amend(input) {
|
|
210
|
+
return this.run("amend", input);
|
|
211
|
+
}
|
|
212
|
+
arc(input) {
|
|
213
|
+
return this.run("arc", input);
|
|
214
|
+
}
|
|
215
|
+
deliver(input, run) {
|
|
216
|
+
return this.run("deliver", input, run);
|
|
217
|
+
}
|
|
218
|
+
previewDelivery(input, run) {
|
|
219
|
+
return this.run("deliver.preview", input, run);
|
|
220
|
+
}
|
|
221
|
+
verify(input, run) {
|
|
222
|
+
return this.run("verify", input, run);
|
|
223
|
+
}
|
|
224
|
+
review(input, run) {
|
|
225
|
+
return this.run("review", input, run);
|
|
226
|
+
}
|
|
227
|
+
abandon(input) {
|
|
228
|
+
return this.run("abandon", input);
|
|
229
|
+
}
|
|
230
|
+
show(input = {}) {
|
|
231
|
+
return this.run("show", input);
|
|
232
|
+
}
|
|
233
|
+
reconcile(input = {}) {
|
|
234
|
+
return this.run("reconcile", input);
|
|
235
|
+
}
|
|
236
|
+
spawn({ schema, ...input }, run) {
|
|
237
|
+
return this.run("spawn", { ...input, ...(schema === undefined ? {} : { schema: schema.jsonSchema }) }, {
|
|
238
|
+
...run,
|
|
239
|
+
...(schema === undefined ? {} : { decode: schema.decode }),
|
|
35
240
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
241
|
+
}
|
|
242
|
+
fork(input) {
|
|
243
|
+
return this.run("fork", input);
|
|
244
|
+
}
|
|
245
|
+
tell(input, run) {
|
|
246
|
+
return this.run("tell", input, run);
|
|
247
|
+
}
|
|
248
|
+
ask({ schema, ...input }, run) {
|
|
249
|
+
return this.run("ask", { ...input, ...(schema === undefined ? {} : { schema: schema.jsonSchema }) }, {
|
|
250
|
+
...run,
|
|
251
|
+
...(schema === undefined ? {} : { decode: schema.decode }),
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
kill(input, run) {
|
|
255
|
+
return this.run("kill", input, run);
|
|
256
|
+
}
|
|
257
|
+
wait(input, run) {
|
|
258
|
+
return this.run("wait", input, run);
|
|
259
|
+
}
|
|
260
|
+
history(input) {
|
|
261
|
+
return this.run("history", input);
|
|
262
|
+
}
|
|
263
|
+
report(input, run) {
|
|
264
|
+
return this.run("report", input, run);
|
|
265
|
+
}
|
|
266
|
+
ls(input) {
|
|
267
|
+
return this.run("ls", input);
|
|
268
|
+
}
|
|
269
|
+
debtAdd({ signal, ...input }) {
|
|
270
|
+
return this.run("debt.add", input, signal === undefined ? {} : { signal });
|
|
271
|
+
}
|
|
272
|
+
debtAddDocument({ signal, ...input }) {
|
|
273
|
+
return this.run("debt.addDocument", input, signal === undefined ? {} : { signal });
|
|
274
|
+
}
|
|
275
|
+
debtUpdate({ signal, ...input }) {
|
|
276
|
+
return this.run("debt.update", input, signal === undefined ? {} : { signal });
|
|
277
|
+
}
|
|
278
|
+
debtShow(input) {
|
|
279
|
+
return this.run("debt.show", input);
|
|
280
|
+
}
|
|
281
|
+
debtDone({ signal, ...input }) {
|
|
282
|
+
return this.run("debt.done", input, signal === undefined ? {} : { signal });
|
|
283
|
+
}
|
|
284
|
+
debtDrop({ signal, ...input }) {
|
|
285
|
+
return this.run("debt.drop", input, signal === undefined ? {} : { signal });
|
|
286
|
+
}
|
|
287
|
+
debtReady(input = {}) {
|
|
288
|
+
return this.run("debt.ready", input);
|
|
289
|
+
}
|
|
290
|
+
debtBlocked(input = {}) {
|
|
291
|
+
return this.run("debt.blocked", input);
|
|
292
|
+
}
|
|
293
|
+
debtQuery(input = {}) {
|
|
294
|
+
return this.run("debt.query", input);
|
|
295
|
+
}
|
|
296
|
+
debtTree(input) {
|
|
297
|
+
return this.run("debt.tree", input);
|
|
298
|
+
}
|
|
299
|
+
debtDoctor() {
|
|
300
|
+
return this.run("debt.doctor", {});
|
|
301
|
+
}
|
|
302
|
+
debtContext(input = {}) {
|
|
303
|
+
return this.run("debt.context", input);
|
|
304
|
+
}
|
|
305
|
+
status(input = {}) {
|
|
306
|
+
return this.run("status", input);
|
|
307
|
+
}
|
|
308
|
+
region(input = {}) {
|
|
309
|
+
return this.run("region", input);
|
|
310
|
+
}
|
|
311
|
+
whoami() {
|
|
312
|
+
return this.run("whoami", {});
|
|
313
|
+
}
|
|
314
|
+
settings() {
|
|
315
|
+
return this.run("settings", {});
|
|
316
|
+
}
|
|
317
|
+
nuke(input = {}) {
|
|
318
|
+
return this.run("nuke", input);
|
|
319
|
+
}
|
|
320
|
+
#coordinates(use, contractWait = false) {
|
|
321
|
+
return invocationCoordinates({ ...this.#input, use, contractWait });
|
|
322
|
+
}
|
|
323
|
+
#actor(explicit) {
|
|
324
|
+
try {
|
|
325
|
+
const actor = resolveActor({
|
|
326
|
+
env: this.#input.environment,
|
|
327
|
+
...(explicit === undefined ? {} : { actor: explicit }),
|
|
77
328
|
});
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
async
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
329
|
+
return actor === undefined ? {} : { actor };
|
|
330
|
+
}
|
|
331
|
+
catch (error) {
|
|
332
|
+
throw new KeiyakuUsageError(error instanceof Error ? error.message : String(error));
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
async #keis(actor) {
|
|
336
|
+
const at = await this.#coordinates("required");
|
|
337
|
+
if (at.repo === undefined)
|
|
338
|
+
throw new KeiyakuUsageError("this command requires a resolved Repo");
|
|
339
|
+
const configuration = await settings({
|
|
340
|
+
...(at.world === null ? {} : { root: at.world }),
|
|
341
|
+
...(this.#input.home === undefined ? {} : { home: this.#input.home }),
|
|
342
|
+
});
|
|
343
|
+
const selected = this.#actor(actor);
|
|
344
|
+
return {
|
|
345
|
+
cwd: at.cwd,
|
|
346
|
+
actor: selected,
|
|
347
|
+
library: Keis.of(at.repo, { settings: configuration, ...selected }),
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
#fullId(library, value) {
|
|
351
|
+
try {
|
|
352
|
+
library.kei({ id: value });
|
|
353
|
+
return value;
|
|
354
|
+
}
|
|
355
|
+
catch (error) {
|
|
356
|
+
throw new KeiyakuUsageError(error instanceof Error ? error.message : String(error));
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
async #resolve(library, selector, cwd) {
|
|
360
|
+
const result = await library.resolve({ ...(selector === undefined ? {} : { selector }), cwd });
|
|
361
|
+
if (result.kind === "resolved")
|
|
362
|
+
return result.id;
|
|
363
|
+
const refusal = result.refusal;
|
|
364
|
+
switch (refusal.kind) {
|
|
365
|
+
case "invalid-selector":
|
|
366
|
+
throw new KeiyakuUsageError(refusal.diagnostic);
|
|
367
|
+
case "redundant-short-selector":
|
|
368
|
+
throw new KeiyakuUsageError(`redundant short contract selector: ${refusal.selector}`);
|
|
369
|
+
case "unknown-short-selector":
|
|
370
|
+
throw new KeiyakuUsageError(`unknown contract selector: ${refusal.selector}`);
|
|
371
|
+
case "ambiguous-selector":
|
|
372
|
+
throw new KeiyakuUsageError("selector" in refusal
|
|
373
|
+
? `ambiguous contract selector: ${refusal.selector}`
|
|
374
|
+
: "ambiguous managed worktree contract selector");
|
|
375
|
+
case "no-contextual-match":
|
|
376
|
+
throw new KeiyakuUsageError("an explicit full or @ contract selector is required outside a managed worktree");
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
async #selected(selector, actor) {
|
|
380
|
+
const { cwd, library, actor: selectedActor } = await this.#keis(actor);
|
|
381
|
+
const id = await this.#resolve(library, selector, cwd);
|
|
382
|
+
return { id, contract: library.kei({ id }), actor: selectedActor };
|
|
383
|
+
}
|
|
384
|
+
async #bind(input) {
|
|
385
|
+
const { library, actor } = await this.#keis(input.actor);
|
|
386
|
+
if ("forkOf" in input)
|
|
387
|
+
return await library.bind({
|
|
388
|
+
...input,
|
|
389
|
+
forkOf: this.#fullId(library, input.forkOf),
|
|
390
|
+
...actor,
|
|
391
|
+
});
|
|
392
|
+
const { after, ...rest } = input;
|
|
393
|
+
return await library.bind({
|
|
394
|
+
...rest,
|
|
395
|
+
...(after === undefined ? {} : { after: after.map((id) => this.#fullId(library, id)) }),
|
|
396
|
+
...actor,
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
async #amend({ contract, ...input }) {
|
|
400
|
+
const { cwd, library, actor } = await this.#keis(input.actor);
|
|
401
|
+
const id = await this.#resolve(library, contract, cwd);
|
|
402
|
+
const { after, ...rest } = input;
|
|
403
|
+
return await library.kei({ id }).amend({
|
|
404
|
+
...rest,
|
|
405
|
+
...(after === undefined ? {} : { after: after.map((value) => this.#fullId(library, value)) }),
|
|
406
|
+
...actor,
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
async #arc({ contract, ...input }) {
|
|
410
|
+
const selected = await this.#selected(contract, input.actor);
|
|
411
|
+
try {
|
|
412
|
+
validateArcMarkdown(input.markdown);
|
|
413
|
+
}
|
|
414
|
+
catch (error) {
|
|
415
|
+
if (error instanceof TypeError || (error instanceof KeiyakuError && error.category === "invalid-input"))
|
|
416
|
+
throw new KeiyakuArcDocumentError(selected.id, error);
|
|
417
|
+
throw error;
|
|
418
|
+
}
|
|
419
|
+
return await selected.contract.arc({ ...input, ...selected.actor });
|
|
420
|
+
}
|
|
421
|
+
async #deliver({ contract, ...input }, progress) {
|
|
422
|
+
return await (await this.#selected(contract)).contract.deliver(input, progress);
|
|
423
|
+
}
|
|
424
|
+
async #previewDelivery({ contract, ...input }, progress) {
|
|
425
|
+
return await (await this.#selected(contract)).contract.previewDelivery(input, progress);
|
|
426
|
+
}
|
|
427
|
+
async #verify({ contract, ...input }, progress) {
|
|
428
|
+
return await (await this.#selected(contract)).contract.verify(input, progress);
|
|
429
|
+
}
|
|
430
|
+
async #review({ contract, ...input }, progress) {
|
|
431
|
+
const selected = await this.#selected(contract, input.actor);
|
|
432
|
+
return await selected.contract.review({ ...input, ...selected.actor }, progress);
|
|
433
|
+
}
|
|
434
|
+
async #abandon({ contract, ...input }) {
|
|
435
|
+
const selected = await this.#selected(contract, input.actor);
|
|
436
|
+
return await selected.contract.abandon({ ...input, ...selected.actor });
|
|
437
|
+
}
|
|
438
|
+
async #show(input = {}) {
|
|
439
|
+
return await (await this.#selected(input.contract)).contract.guidance();
|
|
440
|
+
}
|
|
441
|
+
async #reconcile(input = {}) {
|
|
442
|
+
const { cwd, library } = await this.#keis();
|
|
443
|
+
if (input.contract === undefined)
|
|
444
|
+
return await library.reconcile(input);
|
|
445
|
+
const id = await this.#resolve(library, input.contract, cwd);
|
|
446
|
+
return await library.reconcile({ ...input, contract: id });
|
|
447
|
+
}
|
|
448
|
+
async #spawn({ prompt, contract, workdir, writableDirectories, observe, ...input }) {
|
|
449
|
+
if (prompt !== undefined && prompt.trim() === "")
|
|
450
|
+
throw new KeiyakuUsageError("spawn requires a nonblank prompt");
|
|
451
|
+
const at = await this.#coordinates(contract === undefined ? "none" : "required");
|
|
452
|
+
const cwd = workdir === undefined
|
|
453
|
+
? at.cwd
|
|
454
|
+
: await canonicalBirthCwd(resolve(at.cwd, workdir), `workdir is not an existing directory: ${workdir}`);
|
|
455
|
+
const directories = writableDirectories === undefined
|
|
456
|
+
? undefined
|
|
457
|
+
: await Promise.all(writableDirectories.map((path) => {
|
|
458
|
+
if (path.trim() === "")
|
|
459
|
+
throw new TypeError("--add-dir requires a nonblank directory");
|
|
460
|
+
return canonicalBirthCwd(resolve(at.cwd, path));
|
|
461
|
+
}));
|
|
462
|
+
const caller = await this.#caller();
|
|
463
|
+
const initiator = deliveryOwner(this.#input.environment);
|
|
464
|
+
const world = at.candidateWorld ?? (await at.establishWorld());
|
|
465
|
+
await World.at(world);
|
|
466
|
+
const configuration = await settings({
|
|
467
|
+
root: world,
|
|
468
|
+
...(this.#input.home === undefined ? {} : { home: this.#input.home }),
|
|
469
|
+
});
|
|
470
|
+
const selected = contract === undefined ? undefined : Keis.of(at.repo).kei({ id: this.#fullId(Keis.of(at.repo), contract) });
|
|
471
|
+
return await Akumas.of(world).spawn({
|
|
472
|
+
...input,
|
|
473
|
+
cwd,
|
|
474
|
+
settings: configuration,
|
|
475
|
+
...(this.#input.home === undefined ? {} : { home: this.#input.home }),
|
|
476
|
+
...(prompt === undefined ? {} : { body: prompt }),
|
|
477
|
+
...(directories === undefined ? {} : { writableDirectories: directories }),
|
|
478
|
+
...(selected === undefined ? {} : { contract: selected }),
|
|
479
|
+
...(caller === undefined ? {} : { caller }),
|
|
480
|
+
...(initiator === undefined ? {} : { initiator }),
|
|
481
|
+
...(observe === undefined
|
|
482
|
+
? {}
|
|
483
|
+
: {
|
|
484
|
+
observe: {
|
|
485
|
+
...(observe.observe === undefined ? {} : { observe: observe.observe }),
|
|
486
|
+
...(observe.admitted === undefined
|
|
487
|
+
? {}
|
|
488
|
+
: {
|
|
489
|
+
admitted: (tell, id, head) => observe.admitted(tell, id, { ...head, cwd }),
|
|
490
|
+
}),
|
|
491
|
+
},
|
|
492
|
+
}),
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
async #caller() {
|
|
496
|
+
try {
|
|
497
|
+
return await akumaCallerFromEnvironment(this.#input.environment);
|
|
498
|
+
}
|
|
499
|
+
catch (error) {
|
|
500
|
+
if (error instanceof TypeError)
|
|
501
|
+
throw new KeiyakuUsageError(error.message);
|
|
502
|
+
throw error;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
async #akumas(use = "optional") {
|
|
506
|
+
const at = await this.#coordinates(use);
|
|
507
|
+
if (at.world === null)
|
|
508
|
+
throw new KeiyakuUsageError("no Keiyaku world contains the invocation cwd");
|
|
509
|
+
return { at, akumas: Akumas.of(at.world) };
|
|
510
|
+
}
|
|
511
|
+
async #fork(input) {
|
|
512
|
+
const { at, akumas } = await this.#akumas();
|
|
513
|
+
const caller = await this.#caller();
|
|
514
|
+
const initiator = deliveryOwner(this.#input.environment);
|
|
515
|
+
return await akumas.fork({
|
|
516
|
+
...input,
|
|
517
|
+
...(at.repo === undefined ? {} : { repo: at.repo }),
|
|
518
|
+
...(caller === undefined ? {} : { caller }),
|
|
519
|
+
...(initiator === undefined ? {} : { initiator }),
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
async #tell({ prompt, ...input }) {
|
|
523
|
+
if (prompt.trim() === "")
|
|
524
|
+
throw new KeiyakuUsageError("tell requires a nonblank prompt");
|
|
525
|
+
const { at, akumas } = await this.#akumas();
|
|
526
|
+
const initiator = deliveryOwner(this.#input.environment);
|
|
527
|
+
return await akumas.tell({
|
|
528
|
+
...input,
|
|
529
|
+
body: prompt,
|
|
530
|
+
...(at.repo === undefined ? {} : { repo: at.repo }),
|
|
531
|
+
...(initiator === undefined ? {} : { initiator }),
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
async #ask({ prompt, ...input }) {
|
|
535
|
+
if (prompt.trim() === "")
|
|
536
|
+
throw new KeiyakuUsageError("ask requires a nonblank prompt");
|
|
537
|
+
const { at, akumas } = await this.#akumas();
|
|
538
|
+
const initiator = deliveryOwner(this.#input.environment);
|
|
539
|
+
return await akumas.ask({
|
|
540
|
+
...input,
|
|
541
|
+
body: prompt,
|
|
542
|
+
...(at.repo === undefined ? {} : { repo: at.repo }),
|
|
543
|
+
...(initiator === undefined ? {} : { initiator }),
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
async #kill(input) {
|
|
547
|
+
const { at, akumas } = await this.#akumas();
|
|
548
|
+
return await akumas.kill({ ...input, ...(at.repo === undefined ? {} : { repo: at.repo }) });
|
|
549
|
+
}
|
|
550
|
+
async #wait({ selectors, ...input }) {
|
|
551
|
+
const contracts = selectors.filter((selector) => selector.startsWith("kei/"));
|
|
552
|
+
if (contracts.length > 0 && contracts.length !== selectors.length)
|
|
553
|
+
throw new KeiyakuUsageError("wait cannot mix Contract and Akuma selectors");
|
|
554
|
+
if (contracts.length > 0) {
|
|
555
|
+
const at = await this.#coordinates("required", true);
|
|
556
|
+
if (at.repo === undefined)
|
|
557
|
+
throw new KeiyakuUsageError("Contract wait requires a repository");
|
|
558
|
+
return await Keis.of(at.repo).wait({ contracts, ...input });
|
|
559
|
+
}
|
|
560
|
+
const { at, akumas } = await this.#akumas();
|
|
561
|
+
return await akumas.wait({ akuma: selectors, ...input, ...(at.repo === undefined ? {} : { repo: at.repo }) });
|
|
562
|
+
}
|
|
563
|
+
async #history({ selector, full, ...input }) {
|
|
564
|
+
if (selector.startsWith("kei/")) {
|
|
565
|
+
const at = await this.#coordinates("required");
|
|
566
|
+
if (at.repo === undefined)
|
|
567
|
+
throw new KeiyakuUsageError("this command requires a resolved Repo");
|
|
568
|
+
const library = Keis.of(at.repo);
|
|
569
|
+
return await library
|
|
570
|
+
.kei({ id: this.#fullId(library, selector) })
|
|
571
|
+
.history(full === undefined ? undefined : { full });
|
|
572
|
+
}
|
|
573
|
+
const { at, akumas } = await this.#akumas();
|
|
574
|
+
return await akumas.history({ akuma: selector, ...input, ...(at.repo === undefined ? {} : { repo: at.repo }) });
|
|
575
|
+
}
|
|
576
|
+
async #report(input) {
|
|
577
|
+
await this.#coordinates("none");
|
|
578
|
+
const environment = this.#input.environment;
|
|
579
|
+
if (typeof input.text !== "string" || input.text.trim() === "")
|
|
580
|
+
throw new KeiyakuUsageError("report requires nonblank text");
|
|
581
|
+
if (environment.KEIYAKU_ACTOR_ID === undefined || environment.KEIYAKU_ACTOR_WORLD === undefined)
|
|
582
|
+
throw new KeiyakuUsageError("report requires explicit KEIYAKU_ACTOR_ID and KEIYAKU_ACTOR_WORLD");
|
|
583
|
+
let caller;
|
|
584
|
+
try {
|
|
585
|
+
caller = await akumaCallerFromEnvironment(environment);
|
|
586
|
+
}
|
|
587
|
+
catch (error) {
|
|
588
|
+
if (error instanceof TypeError || error instanceof WorldError)
|
|
589
|
+
throw new KeiyakuUsageError(error.message);
|
|
590
|
+
throw error;
|
|
591
|
+
}
|
|
592
|
+
if (caller?.kind !== "akuma")
|
|
593
|
+
throw new KeiyakuUsageError("report requires explicit Akuma identity");
|
|
594
|
+
return Akuma.select(caller.world, caller.akumaId).report(input.text, input.signal === undefined ? {} : { signal: input.signal });
|
|
595
|
+
}
|
|
596
|
+
async #resolveLsCaller(selection, world) {
|
|
597
|
+
if (selection === undefined)
|
|
598
|
+
return undefined;
|
|
599
|
+
if (selection.kind === "external")
|
|
600
|
+
return selection.caller;
|
|
601
|
+
if (selection.kind === "akuma")
|
|
602
|
+
return { kind: "akuma", world, akumaId: selection.akumaId };
|
|
603
|
+
let caller;
|
|
604
|
+
try {
|
|
605
|
+
caller = await akumaCallerFromEnvironment(this.#input.environment);
|
|
606
|
+
}
|
|
607
|
+
catch (error) {
|
|
608
|
+
throw new KeiyakuUsageError(error instanceof Error ? error.message : String(error));
|
|
609
|
+
}
|
|
610
|
+
if (caller === undefined) {
|
|
611
|
+
throw new KeiyakuUsageError("--mine requires a caller identity; set KEIYAKU_ACTOR_ID and KEIYAKU_ACTOR_WORLD or run inside a calling host");
|
|
612
|
+
}
|
|
613
|
+
return caller;
|
|
614
|
+
}
|
|
615
|
+
async #ls(input) {
|
|
616
|
+
if (input.of === "debt")
|
|
617
|
+
return debt.debtList(this.#input, input);
|
|
618
|
+
const at = await this.#coordinates(input.of === "kei" ? "required" : "none");
|
|
619
|
+
const limit = input.limit === undefined ? {} : { limit: input.limit };
|
|
620
|
+
if (input.of === "kei") {
|
|
621
|
+
if (at.repo === undefined)
|
|
622
|
+
throw new KeiyakuUsageError("this command requires a resolved Repo");
|
|
623
|
+
return Keis.of(at.repo).list(limit);
|
|
624
|
+
}
|
|
625
|
+
if (input.of === "akuma-name") {
|
|
626
|
+
return listArchetypeDefinitions({
|
|
627
|
+
...(at.world === null ? {} : { project: at.world }),
|
|
628
|
+
...(this.#input.home === undefined ? {} : { home: this.#input.home }),
|
|
629
|
+
...limit,
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
if (at.world === null)
|
|
633
|
+
throw new KeiyakuUsageError("no Keiyaku world contains the invocation cwd");
|
|
634
|
+
const caller = await this.#resolveLsCaller(input.caller, at.world);
|
|
635
|
+
return Akumas.of(at.world).list({
|
|
636
|
+
...limit,
|
|
637
|
+
...(input.akumaName === undefined ? {} : { akumaName: input.akumaName }),
|
|
638
|
+
...(caller === undefined ? {} : { caller }),
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
async #status(input = {}) {
|
|
642
|
+
return await statusAt(await this.#coordinates("optional"), input);
|
|
643
|
+
}
|
|
644
|
+
async #region(input = {}) {
|
|
645
|
+
const at = await this.#coordinates("required");
|
|
646
|
+
if (at.repo === undefined)
|
|
647
|
+
throw new KeiyakuUsageError("this command requires a resolved Repo");
|
|
648
|
+
const repo = at.repo;
|
|
649
|
+
let selected;
|
|
650
|
+
if (input.paths !== undefined) {
|
|
651
|
+
const [first, ...rest] = input.paths;
|
|
652
|
+
if (first === undefined)
|
|
653
|
+
throw new TypeError("Region query requires one or more path patterns");
|
|
654
|
+
selected = { kind: "path", patterns: [first, ...rest] };
|
|
655
|
+
}
|
|
656
|
+
else {
|
|
657
|
+
selected =
|
|
658
|
+
input.contract === undefined
|
|
659
|
+
? { kind: "declarations" }
|
|
660
|
+
: { kind: "contract", contract: await this.#resolve(Keis.of(repo), input.contract, at.cwd) };
|
|
661
|
+
}
|
|
662
|
+
const result = await kanshi({ world: at.world, repo, region: selected });
|
|
663
|
+
if (result.kind === "absent")
|
|
664
|
+
throw new Error("Region observation with a Repo cannot be absent");
|
|
665
|
+
return result;
|
|
666
|
+
}
|
|
667
|
+
async #whoami() {
|
|
668
|
+
return await whoami(await this.#coordinates("optional"), this.#input.environment);
|
|
669
|
+
}
|
|
670
|
+
async #settings() {
|
|
671
|
+
const at = await this.#coordinates("none");
|
|
672
|
+
return await settings({
|
|
673
|
+
...(at.world === null ? {} : { root: at.world }),
|
|
674
|
+
...(this.#input.home === undefined ? {} : { home: this.#input.home }),
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
async #nuke(input = {}) {
|
|
678
|
+
const at = await this.#coordinates("none");
|
|
679
|
+
if (at.world === null)
|
|
680
|
+
throw new KeiyakuUsageError("no Keiyaku world contains the invocation cwd");
|
|
681
|
+
return await nukeKeiyaku({ world: at.world, ...input });
|
|
122
682
|
}
|
|
123
|
-
}
|
|
124
|
-
/** Internal constructor capability; callers select a Contract through Keiyaku.with. */
|
|
125
|
-
export function createKeiyakuHandle(id, scope, composition) {
|
|
126
|
-
return new Keiyaku(KEIYAKU_HANDLE, id, scope, composition);
|
|
127
|
-
}
|
|
128
|
-
/** Internal package composition capability; not exported from the package root. */
|
|
129
|
-
export function seatForKeiyaku(value) {
|
|
130
|
-
return value !== null && (typeof value === "object" || typeof value === "function")
|
|
131
|
-
? (KEIYAKU_SEATS.get(value) ?? null)
|
|
132
|
-
: null;
|
|
133
683
|
}
|