@astrosheep/keiyaku 4.5.28 → 4.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +0 -13
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +47 -78
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/references/automation.md +54 -41
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-babysit/SKILL.md +10 -0
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/SKILL.md +27 -9
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +68 -71
- package/build/src/akuma/akuma-call.d.ts +53 -0
- package/build/src/akuma/akuma-call.js +113 -0
- package/build/src/akuma/akuma-instance.d.ts +20 -19
- package/build/src/akuma/akuma-instance.js +65 -177
- package/build/src/akuma/akuma-observe.d.ts +3 -21
- package/build/src/akuma/akuma-observe.js +7 -25
- package/build/src/akuma/{akuma-handle.d.ts → akuma-owner.d.ts} +60 -25
- package/build/src/akuma/{akuma-handle.js → akuma-owner.js} +43 -29
- package/build/src/akuma/akuma-selection-execution.d.ts +51 -0
- package/build/src/akuma/akuma-selection-execution.js +134 -0
- package/build/src/akuma/{fleet-execution.d.ts → akuma-wait.d.ts} +24 -32
- package/build/src/akuma/akuma-wait.js +113 -0
- package/build/src/akuma/akuma.d.ts +35 -97
- package/build/src/akuma/akuma.js +148 -35
- package/build/src/akuma/archetype.d.ts +18 -6
- package/build/src/akuma/archetype.js +52 -34
- package/build/src/akuma/body.d.ts +79 -61
- package/build/src/akuma/body.js +101 -50
- package/build/src/akuma/call-initial-tell.d.ts +164 -0
- package/build/src/akuma/call-initial-tell.js +62 -0
- package/build/src/akuma/call-input.d.ts +0 -3
- package/build/src/akuma/call-input.js +0 -7
- package/build/src/akuma/call-request.d.ts +247 -38
- package/build/src/akuma/call-request.js +77 -92
- package/build/src/akuma/coordinate.d.ts +15 -5
- package/build/src/akuma/coordinate.js +12 -22
- package/build/src/akuma/dispatch-association.d.ts +1 -1
- package/build/src/akuma/dispatch-association.js +1 -10
- package/build/src/akuma/heart/activity-schema.d.ts +325 -0
- package/build/src/akuma/heart/activity-schema.js +53 -0
- package/build/src/akuma/heart/facts.d.ts +3 -9
- package/build/src/akuma/heart/index.d.ts +3 -1
- package/build/src/akuma/heart/index.js +4 -1
- package/build/src/akuma/heart/rows.d.ts +49 -2
- package/build/src/akuma/heart/rows.js +16 -2
- package/build/src/akuma/heart/soul.d.ts +1 -0
- package/build/src/akuma/heart/soul.js +7 -10
- package/build/src/akuma/heart/tells.d.ts +1 -0
- package/build/src/akuma/heart/tells.js +18 -0
- package/build/src/akuma/identity.d.ts +10 -7
- package/build/src/akuma/identity.js +23 -0
- package/build/src/akuma/index.d.ts +10 -8
- package/build/src/akuma/index.js +2 -2
- package/build/src/akuma/nuke.d.ts +3 -0
- package/build/src/akuma/nuke.js +13 -7
- package/build/src/akuma/projection-read.js +1 -2
- package/build/src/akuma/projection.d.ts +0 -5
- package/build/src/akuma/projection.js +22 -43
- package/build/src/akuma/provider-recipe.d.ts +58 -23
- package/build/src/akuma/provider-recipe.js +62 -103
- package/build/src/akuma/provider.d.ts +7 -78
- package/build/src/akuma/provider.js +11 -219
- package/build/src/akuma/providers/acp/config.d.ts +2 -0
- package/build/src/akuma/providers/acp/config.js +26 -1
- package/build/src/akuma/providers/acp/core.d.ts +7 -0
- package/build/src/akuma/providers/acp/core.js +49 -18
- package/build/src/akuma/providers/acp/index.js +14 -17
- package/build/src/akuma/providers/claude/index.js +2 -14
- package/build/src/akuma/providers/codex-app-server/index.js +0 -22
- package/build/src/akuma/providers/grok-build/index.js +44 -24
- package/build/src/akuma/providers/index.d.ts +3 -3
- package/build/src/akuma/providers/index.js +2 -13
- package/build/src/akuma/providers/opencode-sdk/event-stream.d.ts +28 -0
- package/build/src/akuma/providers/opencode-sdk/event-stream.js +92 -0
- package/build/src/akuma/providers/opencode-sdk/events.d.ts +0 -1
- package/build/src/akuma/providers/opencode-sdk/index.js +200 -74
- package/build/src/akuma/providers/opencode-sdk/session.d.ts +41 -1
- package/build/src/akuma/providers/opencode-sdk/session.js +69 -2
- package/build/src/akuma/providers/pi/events.js +5 -2
- package/build/src/akuma/providers/pi/index.js +70 -24
- package/build/src/akuma/publication.d.ts +84 -3
- package/build/src/akuma/publication.js +145 -2
- package/build/src/akuma/read-pool.d.ts +2 -0
- package/build/src/akuma/read-pool.js +15 -0
- package/build/src/akuma/request-rendezvous.js +10 -0
- package/build/src/akuma/request-serve.js +7 -0
- package/build/src/akuma/request-wire.d.ts +14 -26
- package/build/src/akuma/request-wire.js +4 -0
- package/build/src/akuma/requests.d.ts +0 -3
- package/build/src/akuma/requests.js +0 -24
- package/build/src/akuma/{fleet-observation.d.ts → selection-observation.d.ts} +61 -52
- package/build/src/akuma/selection-observation.js +65 -0
- package/build/src/akuma/{fleet-owner-port.d.ts → selection-owner-port.d.ts} +3 -3
- package/build/src/akuma/{fleet-owner-port.js → selection-owner-port.js} +11 -17
- package/build/src/akuma/{fleet-request.d.ts → selection-request.d.ts} +42 -82
- package/build/src/akuma/{fleet-request.js → selection-request.js} +92 -136
- package/build/src/akuma/turn-drive.d.ts +3 -0
- package/build/src/akuma/turn-drive.js +75 -16
- package/build/src/akuma-body.js +91 -56
- package/build/src/body/amend.d.ts +5 -0
- package/build/src/body/amend.js +26 -50
- package/build/src/body/arc.d.ts +4 -2
- package/build/src/body/arc.js +19 -26
- package/build/src/body/criteria.d.ts +6 -0
- package/build/src/body/criteria.js +37 -0
- package/build/src/body/decode.js +5 -42
- package/build/src/body/region.d.ts +5 -0
- package/build/src/body/region.js +45 -2
- package/build/src/body/render.js +2 -4
- package/build/src/cli/activity.d.ts +26 -0
- package/build/src/cli/activity.js +75 -0
- package/build/src/cli/actor.d.ts +3 -1
- package/build/src/cli/actor.js +15 -2
- package/build/src/cli/commands/akuma-grammar.d.ts +75 -0
- package/build/src/cli/commands/akuma-grammar.js +414 -0
- package/build/src/cli/commands/akuma.d.ts +5 -69
- package/build/src/cli/commands/akuma.js +352 -312
- package/build/src/cli/commands/amend.d.ts +4 -5
- package/build/src/cli/commands/amend.js +1 -2
- package/build/src/cli/commands/bind.d.ts +4 -5
- package/build/src/cli/commands/bind.js +5 -9
- package/build/src/cli/commands/contract-grammar.d.ts +112 -0
- package/build/src/cli/commands/contract-grammar.js +282 -0
- package/build/src/cli/commands/contract-help.d.ts +28 -30
- package/build/src/cli/commands/contract-help.js +69 -96
- package/build/src/cli/commands/contract.d.ts +18 -97
- package/build/src/cli/commands/contract.js +620 -237
- package/build/src/cli/commands/install.d.ts +1 -1
- package/build/src/cli/commands/install.js +2 -2
- package/build/src/cli/commands/task-grammar.d.ts +19 -0
- package/build/src/cli/commands/task-grammar.js +438 -0
- package/build/src/cli/commands/task-query.js +23 -104
- package/build/src/cli/commands/task.d.ts +5 -20
- package/build/src/cli/commands/task.js +415 -333
- package/build/src/cli/coordinates.d.ts +10 -0
- package/build/src/cli/coordinates.js +20 -0
- package/build/src/cli/draft.d.ts +7 -1
- package/build/src/cli/main.js +10 -1
- package/build/src/cli/parse.d.ts +8 -9
- package/build/src/cli/parse.js +63 -61
- package/build/src/cli/render/akuma-activity.d.ts +88 -39
- package/build/src/cli/render/akuma-activity.js +465 -263
- package/build/src/cli/render/akuma-tool.d.ts +15 -5
- package/build/src/cli/render/akuma-tool.js +40 -27
- package/build/src/cli/render/akuma.d.ts +40 -24
- package/build/src/cli/render/akuma.js +108 -205
- package/build/src/cli/render/audit.d.ts +6 -2
- package/build/src/cli/render/audit.js +61 -30
- package/build/src/cli/render/catalog.d.ts +11 -2
- package/build/src/cli/render/catalog.js +75 -94
- package/build/src/cli/render/contract-history.d.ts +3 -1
- package/build/src/cli/render/contract-history.js +215 -22
- package/build/src/cli/render/contract-observation.d.ts +10 -5
- package/build/src/cli/render/contract-observation.js +29 -46
- package/build/src/cli/render/contract.d.ts +10 -3
- package/build/src/cli/render/contract.js +255 -106
- package/build/src/cli/render/effects.d.ts +26 -0
- package/build/src/cli/render/effects.js +41 -0
- package/build/src/cli/render/execution-progress.d.ts +18 -6
- package/build/src/cli/render/execution-progress.js +34 -31
- package/build/src/cli/render/kanshi-akuma.d.ts +1 -2
- package/build/src/cli/render/kanshi-akuma.js +5 -26
- package/build/src/cli/render/kanshi.js +108 -129
- package/build/src/cli/render/marks.d.ts +13 -0
- package/build/src/cli/render/marks.js +74 -0
- package/build/src/cli/render/nuke.js +18 -7
- package/build/src/cli/render/receipt.d.ts +10 -4
- package/build/src/cli/render/receipt.js +126 -46
- package/build/src/cli/render/reconcile.d.ts +5 -0
- package/build/src/cli/render/reconcile.js +152 -0
- package/build/src/cli/render/refusal.d.ts +21 -4
- package/build/src/cli/render/refusal.js +61 -34
- package/build/src/cli/render/region.js +3 -2
- package/build/src/cli/render/settings.js +4 -14
- package/build/src/cli/render/task.d.ts +37 -6
- package/build/src/cli/render/task.js +162 -158
- package/build/src/cli/render/terminal.d.ts +25 -1
- package/build/src/cli/render/terminal.js +105 -18
- package/build/src/cli/runtime.d.ts +32 -8
- package/build/src/cli/runtime.js +161 -163
- package/build/src/cli/selectors.d.ts +5 -2
- package/build/src/cli/selectors.js +11 -3
- package/build/src/cli/streams.d.ts +11 -0
- package/build/src/cli/streams.js +32 -0
- package/build/src/cli/usage.d.ts +2 -0
- package/build/src/cli/usage.js +12 -8
- package/build/src/contract-guidance.js +3 -7
- package/build/src/contract-worktree.d.ts +20 -28
- package/build/src/contract-worktree.js +18 -70
- package/build/src/coordination/durable-file.d.ts +2 -2
- package/build/src/coordination/durable-file.js +0 -27
- package/build/src/core/facts/codec.d.ts +1 -2
- package/build/src/core/facts/codec.js +6 -7
- package/build/src/core/facts/gate.d.ts +0 -1
- package/build/src/core/facts/gate.js +0 -82
- package/build/src/core/facts/types.d.ts +1 -2
- package/build/src/core/verbs/abandon.d.ts +2 -6
- package/build/src/core/verbs/abandon.js +0 -16
- package/build/src/core/verbs/amend.d.ts +0 -1
- package/build/src/core/verbs/amend.js +0 -20
- package/build/src/core/verbs/arc.d.ts +7 -8
- package/build/src/core/verbs/arc.js +2 -19
- package/build/src/core/verbs/attestation.d.ts +2 -6
- package/build/src/core/verbs/attestation.js +0 -16
- package/build/src/core/verbs/bind.d.ts +0 -1
- package/build/src/core/verbs/bind.js +0 -16
- package/build/src/core/verbs/deliver.d.ts +0 -1
- package/build/src/core/verbs/deliver.js +0 -16
- package/build/src/core/verbs/placement.d.ts +2 -1
- package/build/src/core/verbs/placement.js +10 -59
- package/build/src/git/admission.d.ts +6 -4
- package/build/src/git/admission.js +4 -0
- package/build/src/git/hooks.d.ts +55 -30
- package/build/src/git/hooks.js +30 -3
- package/build/src/git/identity.d.ts +6 -0
- package/build/src/git/identity.js +47 -0
- package/build/src/git/integration.d.ts +31 -13
- package/build/src/git/integration.js +32 -1
- package/build/src/git/nuke.d.ts +10 -1
- package/build/src/git/nuke.js +31 -11
- package/build/src/git/observe.js +2 -15
- package/build/src/git/private-state-seat.d.ts +6 -7
- package/build/src/git/private-state-seat.js +8 -6
- package/build/src/git/read-observation.d.ts +6 -1
- package/build/src/git/read-observation.js +81 -46
- package/build/src/git/reconcile.d.ts +117 -40
- package/build/src/git/reconcile.js +169 -40
- package/build/src/git/scratch.d.ts +7 -4
- package/build/src/git/scratch.js +28 -6
- package/build/src/git/target-placement.d.ts +53 -38
- package/build/src/git/target-placement.js +69 -54
- package/build/src/git/tender.d.ts +37 -28
- package/build/src/git/tender.js +39 -0
- package/build/src/git/terminal-reconcile.js +21 -23
- package/build/src/git/terminal-seal.d.ts +8 -6
- package/build/src/git/terminal-seal.js +10 -0
- package/build/src/git/workspace.d.ts +29 -15
- package/build/src/git/workspace.js +28 -2
- package/build/src/identity/normalize.js +19 -6
- package/build/src/index.d.ts +78 -6
- package/build/src/index.js +52 -3
- package/build/src/kanshi/read.d.ts +3 -3
- package/build/src/kanshi/read.js +21 -21
- package/build/src/kanshi/report.d.ts +9 -8
- package/build/src/kanshi/roster.d.ts +2 -0
- package/build/src/kanshi/roster.js +2 -0
- package/build/src/kanshi/select.js +7 -3
- package/build/src/library/address.d.ts +3 -7
- package/build/src/library/address.js +7 -7
- package/build/src/library/akuma-creation.d.ts +35 -33
- package/build/src/library/akuma-creation.js +184 -167
- package/build/src/library/akumas.d.ts +40 -0
- package/build/src/library/akumas.js +84 -0
- package/build/src/library/bind.d.ts +107 -13
- package/build/src/library/bind.js +29 -23
- package/build/src/library/continuation.d.ts +556 -28
- package/build/src/library/continuation.js +29 -54
- package/build/src/library/contract-composition.d.ts +40 -0
- package/build/src/library/contract-composition.js +105 -0
- package/build/src/library/contract-creation.d.ts +7 -0
- package/build/src/library/contract-creation.js +192 -0
- package/build/src/library/contract-execution.d.ts +29 -40
- package/build/src/library/contract-execution.js +503 -128
- package/build/src/library/contract-operations.d.ts +275 -134
- package/build/src/library/contract-operations.js +83 -92
- package/build/src/library/contract-outcomes.d.ts +71 -0
- package/build/src/library/contract-outcomes.js +32 -0
- package/build/src/library/contract-settings.d.ts +25 -0
- package/build/src/library/contract-settings.js +135 -0
- package/build/src/library/contract-types.d.ts +24 -38
- package/build/src/library/delivery.d.ts +530 -10
- package/build/src/library/delivery.js +20 -45
- package/build/src/library/input.d.ts +3 -1
- package/build/src/library/input.js +11 -16
- package/build/src/library/invocation.d.ts +87 -0
- package/build/src/library/invocation.js +290 -0
- package/build/src/library/keiyaku.d.ts +44 -437
- package/build/src/library/keiyaku.js +132 -20
- package/build/src/library/nuke.d.ts +2 -11
- package/build/src/library/nuke.js +70 -57
- package/build/src/library/outcome.d.ts +13196 -0
- package/build/src/library/outcome.js +487 -0
- package/build/src/library/reconcile.d.ts +96 -24
- package/build/src/library/reconcile.js +102 -42
- package/build/src/library/refusal.d.ts +470 -42
- package/build/src/library/refusal.js +55 -143
- package/build/src/library/region.d.ts +15 -7
- package/build/src/library/region.js +23 -3
- package/build/src/library/repo.d.ts +2 -12
- package/build/src/library/repo.js +1 -22
- package/build/src/library/selection.d.ts +121 -0
- package/build/src/library/{fleet.js → selection.js} +177 -160
- package/build/src/plugin/public.d.ts +2 -0
- package/build/src/protocol/abandon.d.ts +2 -2
- package/build/src/protocol/abandon.js +1 -0
- package/build/src/protocol/amend.js +1 -0
- package/build/src/protocol/arc.d.ts +6 -4
- package/build/src/protocol/attempt.d.ts +4 -2
- package/build/src/protocol/attempt.js +10 -0
- package/build/src/protocol/audit.d.ts +255 -52
- package/build/src/protocol/audit.js +63 -5
- package/build/src/protocol/bind.d.ts +18 -17
- package/build/src/protocol/bind.js +9 -28
- package/build/src/protocol/completion.d.ts +256 -22
- package/build/src/protocol/completion.js +100 -12
- package/build/src/protocol/deliver.d.ts +34 -23
- package/build/src/protocol/deliver.js +39 -25
- package/build/src/protocol/execution-observation.d.ts +36 -37
- package/build/src/protocol/execution-observation.js +7 -9
- package/build/src/protocol/intent.d.ts +101 -30
- package/build/src/protocol/intent.js +74 -1
- package/build/src/protocol/operations.d.ts +570 -64
- package/build/src/protocol/operations.js +189 -9
- package/build/src/protocol/outcome.d.ts +2 -1
- package/build/src/protocol/placement.d.ts +2 -2
- package/build/src/protocol/placement.js +3 -1
- package/build/src/protocol/progress.d.ts +108 -65
- package/build/src/protocol/progress.js +82 -132
- package/build/src/protocol/read/status.d.ts +4 -3
- package/build/src/protocol/read/status.js +6 -5
- package/build/src/protocol/reconcile.d.ts +3 -3
- package/build/src/protocol/reconcile.js +4 -0
- package/build/src/protocol/reintegrate.d.ts +2 -2
- package/build/src/protocol/review.d.ts +30 -12
- package/build/src/protocol/review.js +15 -24
- package/build/src/protocol/run.d.ts +34 -5
- package/build/src/protocol/run.js +24 -12
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/build/src/settings.d.ts +0 -10
- package/build/src/settings.js +0 -76
- package/build/src/settlement/holder.d.ts +1 -1
- package/build/src/settlement/settle.d.ts +25 -16
- package/build/src/settlement/settle.js +80 -20
- package/build/src/task/board.d.ts +3 -1
- package/build/src/task/board.js +13 -17
- package/build/src/task/catalog.d.ts +0 -4
- package/build/src/task/catalog.js +0 -15
- package/build/src/task/compose-language.d.ts +19 -9
- package/build/src/task/compose-language.js +30 -20
- package/build/src/task/compose.d.ts +7 -37
- package/build/src/task/compose.js +20 -2
- package/build/src/task/created-observation.d.ts +0 -1
- package/build/src/task/created-observation.js +1 -4
- package/build/src/task/document.d.ts +12 -2
- package/build/src/task/document.js +4 -0
- package/build/src/task/identity.d.ts +4 -1
- package/build/src/task/identity.js +21 -17
- package/build/src/task/index.d.ts +36 -16
- package/build/src/task/index.js +103 -96
- package/build/src/task/lifecycle-operations.d.ts +1 -1
- package/build/src/task/mutation-result.d.ts +647 -586
- package/build/src/task/mutation-result.js +79 -46
- package/build/src/task/mutation.d.ts +298 -270
- package/build/src/task/mutation.js +93 -110
- package/build/src/task/operation-types.d.ts +6 -49
- package/build/src/task/operations.d.ts +2 -1
- package/build/src/task/operations.js +35 -12
- package/build/src/task/query.d.ts +9 -3
- package/build/src/task/query.js +42 -16
- package/build/src/task/store.d.ts +2 -1
- package/build/src/task/store.js +10 -14
- package/build/src/verification/declaration.d.ts +0 -1
- package/build/src/verification/declaration.js +1 -18
- package/build/src/verification/execution.d.ts +6 -2
- package/build/src/verification/observation.d.ts +1 -1
- package/package.json +2 -14
- package/build/src/akuma/akuma-product-symbols.d.ts +0 -1
- package/build/src/akuma/akuma-product-symbols.js +0 -1
- package/build/src/akuma/akuma-product.d.ts +0 -62
- package/build/src/akuma/akuma-product.js +0 -293
- package/build/src/akuma/fleet-execution.js +0 -181
- package/build/src/akuma/fleet-observation.js +0 -91
- package/build/src/cli/accepted.d.ts +0 -24
- package/build/src/cli/accepted.js +0 -167
- package/build/src/cli/commands/akuma-invoke.d.ts +0 -114
- package/build/src/cli/commands/akuma-invoke.js +0 -402
- package/build/src/cli/commands/contract-invoke.d.ts +0 -34
- package/build/src/cli/commands/contract-invoke.js +0 -259
- package/build/src/cli/commands/nuke.d.ts +0 -10
- package/build/src/cli/commands/nuke.js +0 -20
- package/build/src/cli/commands/status-set.d.ts +0 -4
- package/build/src/cli/commands/status-set.js +0 -52
- package/build/src/cli/commands/task-invoke.d.ts +0 -49
- package/build/src/cli/commands/task-invoke.js +0 -306
- package/build/src/cli/invoke.d.ts +0 -27
- package/build/src/cli/invoke.js +0 -484
- package/build/src/cli/render/board.d.ts +0 -3
- package/build/src/cli/render/board.js +0 -25
- package/build/src/cli/render/status-set.d.ts +0 -5
- package/build/src/cli/render/status-set.js +0 -19
- package/build/src/cli/render/text.d.ts +0 -3
- package/build/src/cli/render/text.js +0 -33
- package/build/src/cli/result.d.ts +0 -240
- package/build/src/cli/result.js +0 -1
- package/build/src/git/result-codec.d.ts +0 -29
- package/build/src/git/result-codec.js +0 -309
- package/build/src/kanshi/fleet.d.ts +0 -6
- package/build/src/kanshi/fleet.js +0 -27
- package/build/src/library/audit.d.ts +0 -29
- package/build/src/library/audit.js +0 -41
- package/build/src/library/catalog.d.ts +0 -68
- package/build/src/library/catalog.js +0 -130
- package/build/src/library/composition.d.ts +0 -403
- package/build/src/library/composition.js +0 -29
- package/build/src/library/configuration.d.ts +0 -4
- package/build/src/library/configuration.js +0 -2
- package/build/src/library/contract-bind.d.ts +0 -31
- package/build/src/library/contract-bind.js +0 -140
- package/build/src/library/contract-forwarding.d.ts +0 -55
- package/build/src/library/contract-forwarding.js +0 -67
- package/build/src/library/contract-handle.d.ts +0 -45
- package/build/src/library/contract-handle.js +0 -373
- package/build/src/library/contract.d.ts +0 -53
- package/build/src/library/contract.js +0 -91
- package/build/src/library/execution-result.d.ts +0 -243
- package/build/src/library/execution-result.js +0 -101
- package/build/src/library/execution.d.ts +0 -8
- package/build/src/library/execution.js +0 -102
- package/build/src/library/fleet.d.ts +0 -83
- package/build/src/library/mutation.d.ts +0 -501
- package/build/src/library/mutation.js +0 -248
- package/build/src/library/result-codec.d.ts +0 -2
- package/build/src/library/result-codec.js +0 -12
- package/build/src/protocol/result-codec.d.ts +0 -23
- package/build/src/protocol/result-codec.js +0 -488
- package/build/src/settlement/result-codec.d.ts +0 -2
- package/build/src/settlement/result-codec.js +0 -56
- package/build/src/task/public.d.ts +0 -2
- package/build/src/task/public.js +0 -1
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { writeCliStream } from "./streams.js";
|
|
2
|
+
/**
|
|
3
|
+
* The one process-facing activity driver for observing Call, Ask and Wait. It owns the live frame's
|
|
4
|
+
* whole lifetime — settled-row emission, redrawable frame, one conclusion and honest close — so the
|
|
5
|
+
* three modes supply only their typed observation port and their native conclusion, never a second frame.
|
|
6
|
+
*/
|
|
7
|
+
export class ActivityDriver {
|
|
8
|
+
stream;
|
|
9
|
+
lines = [];
|
|
10
|
+
concluded = false;
|
|
11
|
+
constructor(stream = process.stderr) {
|
|
12
|
+
this.stream = stream;
|
|
13
|
+
}
|
|
14
|
+
/** Emit one settled row block, then redraw the retained live frame beneath it. */
|
|
15
|
+
settle(rows, frame) {
|
|
16
|
+
if (rows.length > 0) {
|
|
17
|
+
this.clear();
|
|
18
|
+
this.write(rows.join("\n"));
|
|
19
|
+
}
|
|
20
|
+
this.redraw(frame);
|
|
21
|
+
}
|
|
22
|
+
/** Replace the redrawable live frame. Non-TTY streams keep settled rows only. */
|
|
23
|
+
redraw(frame) {
|
|
24
|
+
this.clear();
|
|
25
|
+
this.lines = frame;
|
|
26
|
+
this.draw();
|
|
27
|
+
}
|
|
28
|
+
/** Conclude the frame once with its final body and release it. */
|
|
29
|
+
conclude(body) {
|
|
30
|
+
if (this.concluded)
|
|
31
|
+
return;
|
|
32
|
+
this.concluded = true;
|
|
33
|
+
this.clear();
|
|
34
|
+
this.lines = [];
|
|
35
|
+
if (body.length > 0)
|
|
36
|
+
this.write(body);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Close on failure or cancellation without inventing a conclusion. Any still-in-flight rows are
|
|
40
|
+
* emitted with their unresolved marks so the terminal shows what never settled, then the frame is
|
|
41
|
+
* released; a mode that already concluded contributes no rows and this is a no-op.
|
|
42
|
+
*/
|
|
43
|
+
close(inFlight = []) {
|
|
44
|
+
if (this.concluded)
|
|
45
|
+
return;
|
|
46
|
+
this.concluded = true;
|
|
47
|
+
this.clear();
|
|
48
|
+
this.lines = [];
|
|
49
|
+
if (inFlight.length > 0)
|
|
50
|
+
this.write(inFlight.join("\n"));
|
|
51
|
+
}
|
|
52
|
+
write(body) {
|
|
53
|
+
writeCliStream(this.stream, body);
|
|
54
|
+
}
|
|
55
|
+
draw() {
|
|
56
|
+
if (this.stream.isTTY !== true || this.lines.length === 0)
|
|
57
|
+
return;
|
|
58
|
+
this.stream.write(this.lines.join("\n"));
|
|
59
|
+
}
|
|
60
|
+
clear() {
|
|
61
|
+
if (this.stream.isTTY !== true || this.lines.length === 0)
|
|
62
|
+
return;
|
|
63
|
+
if (this.lines.length > 1)
|
|
64
|
+
this.stream.write(`\u001b[${this.lines.length - 1}A`);
|
|
65
|
+
this.stream.write("\r");
|
|
66
|
+
for (let index = 0; index < this.lines.length; index += 1) {
|
|
67
|
+
this.stream.write("\u001b[2K");
|
|
68
|
+
if (index < this.lines.length - 1)
|
|
69
|
+
this.stream.write("\n");
|
|
70
|
+
}
|
|
71
|
+
if (this.lines.length > 1)
|
|
72
|
+
this.stream.write(`\u001b[${this.lines.length - 1}A`);
|
|
73
|
+
this.stream.write("\r");
|
|
74
|
+
}
|
|
75
|
+
}
|
package/build/src/cli/actor.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ActorId } from "../index.js";
|
|
2
2
|
type ActorResolutionInput = Readonly<{
|
|
3
3
|
env?: Readonly<Record<string, string | undefined>>;
|
|
4
4
|
actor?: string;
|
|
5
5
|
}>;
|
|
6
6
|
/** Resolve optional caller testimony from the current CLI edge vocabulary. */
|
|
7
7
|
export declare function resolveActor(input?: ActorResolutionInput): ActorId | undefined;
|
|
8
|
+
/** Resolve edge actor testimony, refusing malformed caller input as usage. */
|
|
9
|
+
export declare function actorFromEdge(actor: string | undefined, environment: Readonly<Record<string, string | undefined>>): ActorId | undefined;
|
|
8
10
|
export {};
|
package/build/src/cli/actor.js
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
|
+
import { actorId as mintActorId } from "../index.js";
|
|
2
|
+
import { CliUsageError } from "./usage.js";
|
|
1
3
|
const ACTOR_ID_ENV = "KEIYAKU_ACTOR_ID";
|
|
2
4
|
/** Resolve optional caller testimony from the current CLI edge vocabulary. */
|
|
3
5
|
export function resolveActor(input = {}) {
|
|
4
6
|
if (input.actor !== undefined) {
|
|
5
7
|
if (input.actor.trim().length === 0)
|
|
6
8
|
throw new TypeError("actor must be a nonblank string");
|
|
7
|
-
return input.actor;
|
|
9
|
+
return mintActorId(input.actor);
|
|
8
10
|
}
|
|
9
11
|
const actorId = input.env?.[ACTOR_ID_ENV];
|
|
10
|
-
return actorId !== undefined && actorId.trim().length > 0 ? actorId : undefined;
|
|
12
|
+
return actorId !== undefined && actorId.trim().length > 0 ? mintActorId(actorId) : undefined;
|
|
13
|
+
}
|
|
14
|
+
/** Resolve edge actor testimony, refusing malformed caller input as usage. */
|
|
15
|
+
export function actorFromEdge(actor, environment) {
|
|
16
|
+
try {
|
|
17
|
+
return resolveActor({ env: environment, ...(actor === undefined ? {} : { actor }) });
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (error instanceof Error && "executionReceipt" in error)
|
|
21
|
+
throw error;
|
|
22
|
+
throw new CliUsageError(error instanceof Error ? error.message : String(error));
|
|
23
|
+
}
|
|
11
24
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { type CliUsageGuide } from "../usage.js";
|
|
2
|
+
import { type AkumaAlias } from "../../identity/selector.js";
|
|
3
|
+
import { type AllowedActions } from "../../akuma/allowed.js";
|
|
4
|
+
type Output = Readonly<{
|
|
5
|
+
output: "text" | "json";
|
|
6
|
+
}>;
|
|
7
|
+
type Addressed = Readonly<{
|
|
8
|
+
akuma: string;
|
|
9
|
+
}>;
|
|
10
|
+
export type AkumaPromptSource = Readonly<{
|
|
11
|
+
kind: "argument";
|
|
12
|
+
value: string;
|
|
13
|
+
}> | Readonly<{
|
|
14
|
+
kind: "stdin";
|
|
15
|
+
}>;
|
|
16
|
+
type Prompted = Readonly<{
|
|
17
|
+
prompt: AkumaPromptSource;
|
|
18
|
+
}>;
|
|
19
|
+
export type ParsedAkumaCommand = Output & ((Readonly<{
|
|
20
|
+
command: "call";
|
|
21
|
+
archetype: string;
|
|
22
|
+
contract?: string;
|
|
23
|
+
alias?: AkumaAlias;
|
|
24
|
+
mode: "wait" | "detach";
|
|
25
|
+
timeoutMs?: number;
|
|
26
|
+
allowed?: AllowedActions;
|
|
27
|
+
schema?: string;
|
|
28
|
+
}> & Readonly<{
|
|
29
|
+
prompt?: AkumaPromptSource;
|
|
30
|
+
}>) | Readonly<{
|
|
31
|
+
command: "kill";
|
|
32
|
+
akuma: readonly string[];
|
|
33
|
+
}> | Readonly<{
|
|
34
|
+
command: "wait";
|
|
35
|
+
akuma: readonly string[];
|
|
36
|
+
completion?: "any" | "all";
|
|
37
|
+
timeoutMs?: number;
|
|
38
|
+
}> | (Readonly<{
|
|
39
|
+
command: "tell";
|
|
40
|
+
interrupt: boolean;
|
|
41
|
+
}> & Addressed & Prompted) | (Readonly<{
|
|
42
|
+
command: "ask";
|
|
43
|
+
interrupt: boolean;
|
|
44
|
+
schema?: string;
|
|
45
|
+
timeoutMs?: number;
|
|
46
|
+
}> & Addressed & Prompted) | (Readonly<{
|
|
47
|
+
command: "history";
|
|
48
|
+
last: boolean;
|
|
49
|
+
id?: string;
|
|
50
|
+
before?: number;
|
|
51
|
+
since?: number;
|
|
52
|
+
limit?: number;
|
|
53
|
+
full?: never;
|
|
54
|
+
}> & Addressed) | Readonly<{
|
|
55
|
+
command: "history";
|
|
56
|
+
contract: string;
|
|
57
|
+
full: boolean;
|
|
58
|
+
}> | (Readonly<{
|
|
59
|
+
command: "fork";
|
|
60
|
+
at: string;
|
|
61
|
+
}> & Addressed));
|
|
62
|
+
export type InvokedAkumaCommand = Exclude<ParsedAkumaCommand, {
|
|
63
|
+
command: "history";
|
|
64
|
+
contract: string;
|
|
65
|
+
}>;
|
|
66
|
+
export type AkumaAction = ParsedAkumaCommand["command"];
|
|
67
|
+
export declare function isAkumaAction(value: string | undefined): value is AkumaAction;
|
|
68
|
+
export declare function isParsedAkumaCommand(command: Readonly<{
|
|
69
|
+
command: string;
|
|
70
|
+
}>): command is InvokedAkumaCommand;
|
|
71
|
+
export declare function renderAkumaRootRows(): readonly string[];
|
|
72
|
+
export declare function renderAkumaHelp(action: AkumaAction): string;
|
|
73
|
+
export declare function akumaUsageGuide(action: AkumaAction): CliUsageGuide;
|
|
74
|
+
export declare function parseAkumaCommand(argv: readonly string[]): ParsedAkumaCommand;
|
|
75
|
+
export {};
|
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
import { CliUsageError, commandGuide, isBlankInput, usageLine } from "../usage.js";
|
|
2
|
+
import { parseDuration as decodeDuration } from "../../duration.js";
|
|
3
|
+
import { parseAkumaAlias, parseAkumaGlob } from "../../identity/selector.js";
|
|
4
|
+
import { ALLOWED_ACTIONS, DEFAULT_ALLOWED_ACTIONS, decodeAllowedActions, } from "../../akuma/allowed.js";
|
|
5
|
+
import { parsePublicHistoryId } from "../../akuma/identity.js";
|
|
6
|
+
const EXTRA_ALLOWED_ACTIONS = ALLOWED_ACTIONS.filter((action) => !DEFAULT_ALLOWED_ACTIONS.includes(action));
|
|
7
|
+
const AKUMA_COMMAND_SPECS = {
|
|
8
|
+
call: {
|
|
9
|
+
arity: 1,
|
|
10
|
+
stdin: true,
|
|
11
|
+
flags: {
|
|
12
|
+
contract: "value",
|
|
13
|
+
alias: "value",
|
|
14
|
+
wait: "value",
|
|
15
|
+
allowed: "repeatable",
|
|
16
|
+
json: "boolean",
|
|
17
|
+
schema: "value",
|
|
18
|
+
},
|
|
19
|
+
usage: "call <akuma-name> [--contract <kei/...>] [--workdir <path>] [--alias <name>] [--allowed <product.action>]... [--schema <file>] [--wait <duration>] [<prompt> | -]",
|
|
20
|
+
purpose: "Call an Akuma into the world.",
|
|
21
|
+
details: [
|
|
22
|
+
"Use keiyaku ls aku/ to find visible Akuma names; hidden definitions can still be called by name.",
|
|
23
|
+
"Omit the prompt to birth without a Tell; otherwise give <prompt> as one argument, or use - to read stdin.",
|
|
24
|
+
"--schema and --wait require a prompt.",
|
|
25
|
+
"By default, call returns after birth and optional first Tell admission; --wait also waits for its first answer, up to the given duration.",
|
|
26
|
+
"--contract assigns the Akuma work from that Contract; it does not choose where the Akuma works.",
|
|
27
|
+
"--workdir selects where the Akuma works; relative paths start from your current directory. Without it, the current directory is used.",
|
|
28
|
+
"--alias <name> gives the new Akuma the selector @name; use it instead of aku/<id>.",
|
|
29
|
+
`Default actions: ${DEFAULT_ALLOWED_ACTIONS.join(", ")}.`,
|
|
30
|
+
...(EXTRA_ALLOWED_ACTIONS.length === 0
|
|
31
|
+
? []
|
|
32
|
+
: [`Also available with --allowed: ${EXTRA_ALLOWED_ACTIONS.join(", ")}.`]),
|
|
33
|
+
"Repeated --allowed adds actions to the selected Akuma's allowed actions; it cannot remove inherited permissions.",
|
|
34
|
+
"If no actions are configured, defaults apply; an explicitly empty list allows none.",
|
|
35
|
+
"An Akuma started by another Akuma can use only actions its parent can use. status <aku/...|@alias> shows that Akuma's allowed actions.",
|
|
36
|
+
"--schema checks the Akuma's answer against a JSON Schema file; stdin is still the prompt source.",
|
|
37
|
+
"On success, the Akuma is assigned to the Contract; if @name is already in use, --alias reassigns it to this Akuma.",
|
|
38
|
+
"With --wait, completed activity streams on stderr and the final answer is written to stdout once.",
|
|
39
|
+
].join("\n"),
|
|
40
|
+
},
|
|
41
|
+
wait: {
|
|
42
|
+
arity: "one-or-more",
|
|
43
|
+
stdin: false,
|
|
44
|
+
flags: { any: "boolean", all: "boolean", timeout: "value", json: "boolean" },
|
|
45
|
+
usage: "wait <aku/...|@alias>... [--any | --all] [--timeout <duration>]",
|
|
46
|
+
purpose: "Wait for one or more Akumas to finish work.",
|
|
47
|
+
details: [
|
|
48
|
+
"The default mode is any; --all waits until every selected Akuma completes.",
|
|
49
|
+
"An already completed member counts immediately, so repeating a selection can return at once.",
|
|
50
|
+
"Akuma names, completed activity, and the final result stream on stderr.",
|
|
51
|
+
"A streamed plural wait leaves stdout empty, and so does a single wait with no answer.",
|
|
52
|
+
"Only a single selected Akuma that answered writes to stdout, exactly its answer.",
|
|
53
|
+
"With --json nothing streams and stdout carries the result document.",
|
|
54
|
+
].join("\n"),
|
|
55
|
+
},
|
|
56
|
+
tell: {
|
|
57
|
+
arity: 1,
|
|
58
|
+
stdin: true,
|
|
59
|
+
flags: { interrupt: "boolean", schema: "value", wait: "value", json: "boolean" },
|
|
60
|
+
usage: "tell <aku/...|@alias> [--interrupt] (<prompt> | -)",
|
|
61
|
+
purpose: "Tell an Akuma something without waiting for its answer.",
|
|
62
|
+
details: [
|
|
63
|
+
"Give <prompt> as one argument, or use - to read stdin.",
|
|
64
|
+
"--interrupt ends the Akuma's current work before accepting the new prompt and waking it again.",
|
|
65
|
+
"Use ask to block for the answer or supply a schema.",
|
|
66
|
+
].join("\n"),
|
|
67
|
+
},
|
|
68
|
+
ask: {
|
|
69
|
+
arity: 1,
|
|
70
|
+
stdin: true,
|
|
71
|
+
flags: { interrupt: "boolean", schema: "value", wait: "value", json: "boolean" },
|
|
72
|
+
usage: "ask <aku/...|@alias> [--interrupt] [--schema <file>] [--wait <duration>] (<prompt> | -)",
|
|
73
|
+
purpose: "Ask an Akuma and block until it answers.",
|
|
74
|
+
details: [
|
|
75
|
+
"Give <prompt> as one argument, or use - to read stdin.",
|
|
76
|
+
"--interrupt ends the Akuma's current work before accepting the new prompt and waking it again.",
|
|
77
|
+
"--schema reads a JSON Schema file for the answer contract; stdin remains the prompt source.",
|
|
78
|
+
"--wait bounds how long to block for the answer; the Tell stays admitted past the deadline.",
|
|
79
|
+
"Completed activity streams on stderr and the final answer is written to stdout once.",
|
|
80
|
+
].join("\n"),
|
|
81
|
+
},
|
|
82
|
+
history: {
|
|
83
|
+
arity: 1,
|
|
84
|
+
stdin: false,
|
|
85
|
+
flags: {
|
|
86
|
+
id: "value",
|
|
87
|
+
before: "value",
|
|
88
|
+
since: "value",
|
|
89
|
+
limit: "value",
|
|
90
|
+
last: "boolean",
|
|
91
|
+
full: "boolean",
|
|
92
|
+
json: "boolean",
|
|
93
|
+
},
|
|
94
|
+
usage: "history <aku/...|@alias> [--id <historyId> | --before <index> | --since <index>] [--limit <count>] [--last]\nhistory <kei/...> [--full]",
|
|
95
|
+
purpose: "Read an Akuma's answers and activity, or a Contract's history of changes and assigned work.",
|
|
96
|
+
details: [
|
|
97
|
+
"--id reads the exact retained answered turn (turn/<number>).",
|
|
98
|
+
"--before <index> pages older rows before that sequence; --since <index> pages newer rows after it.",
|
|
99
|
+
"--limit bounds page size (default 12); without --since, the latest rows are shown.",
|
|
100
|
+
"With --since, paging starts at the earliest newer rows.",
|
|
101
|
+
"--last returns only the most recent answer, if one exists; it is not a history page.",
|
|
102
|
+
"Contract history defaults to a causal skeleton; --full prints every event with complete fields.",
|
|
103
|
+
].join("\n"),
|
|
104
|
+
},
|
|
105
|
+
fork: {
|
|
106
|
+
arity: 1,
|
|
107
|
+
stdin: false,
|
|
108
|
+
flags: { at: "value", json: "boolean" },
|
|
109
|
+
usage: "fork <aku/...|@alias> --at <historyId>",
|
|
110
|
+
purpose: "Create a new Akuma from an answered turn.",
|
|
111
|
+
details: "--at takes a retained answered turn id (turn/<n>); find one with history.",
|
|
112
|
+
},
|
|
113
|
+
kill: {
|
|
114
|
+
arity: "one-or-more",
|
|
115
|
+
stdin: false,
|
|
116
|
+
flags: { json: "boolean" },
|
|
117
|
+
usage: "kill <aku/...|@alias>...",
|
|
118
|
+
purpose: "Stop the selected Akuma's current work; it can be woken again with tell.",
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
export function isAkumaAction(value) {
|
|
122
|
+
return value !== undefined && Object.hasOwn(AKUMA_COMMAND_SPECS, value);
|
|
123
|
+
}
|
|
124
|
+
export function isParsedAkumaCommand(command) {
|
|
125
|
+
return isAkumaAction(command.command) && !("contract" in command && command.command === "history");
|
|
126
|
+
}
|
|
127
|
+
export function renderAkumaRootRows() {
|
|
128
|
+
return Object.entries(AKUMA_COMMAND_SPECS).map(([action, spec]) => ` ${action.padEnd(10)} ${spec.purpose}`);
|
|
129
|
+
}
|
|
130
|
+
export function renderAkumaHelp(action) {
|
|
131
|
+
const spec = AKUMA_COMMAND_SPECS[action];
|
|
132
|
+
return `${spec.purpose}\n\n${usageLine(spec.usage)}${spec.details === undefined ? "" : `\n\n${spec.details}`}`;
|
|
133
|
+
}
|
|
134
|
+
export function akumaUsageGuide(action) {
|
|
135
|
+
return commandGuide(action, AKUMA_COMMAND_SPECS[action].usage);
|
|
136
|
+
}
|
|
137
|
+
function stringFlag(value, diagnostic, fail) {
|
|
138
|
+
if (typeof value !== "string")
|
|
139
|
+
fail(diagnostic);
|
|
140
|
+
return value;
|
|
141
|
+
}
|
|
142
|
+
function parseDuration(raw, option, fail) {
|
|
143
|
+
if (typeof raw !== "string")
|
|
144
|
+
fail(`${option} requires an integer duration with unit ms, s, m, or h`);
|
|
145
|
+
const duration = decodeDuration(raw);
|
|
146
|
+
if (duration.kind === "invalid")
|
|
147
|
+
fail(`${option} requires an integer duration with unit ms, s, m, or h`);
|
|
148
|
+
if (duration.kind === "overflow")
|
|
149
|
+
fail(`${option} duration exceeds the safe millisecond range`);
|
|
150
|
+
return duration.milliseconds;
|
|
151
|
+
}
|
|
152
|
+
function scanNamedOption(input, flags, fail) {
|
|
153
|
+
const token = input.argv[input.index];
|
|
154
|
+
const name = token.slice(2);
|
|
155
|
+
const kind = input.spec.flags[name];
|
|
156
|
+
if (kind === undefined)
|
|
157
|
+
fail(`option ${token} is not valid for ${input.action}`);
|
|
158
|
+
if (kind !== "repeatable" && flags[name] !== undefined)
|
|
159
|
+
fail(`duplicate option: ${token}`);
|
|
160
|
+
if (kind === "boolean") {
|
|
161
|
+
flags[name] = true;
|
|
162
|
+
return input.index;
|
|
163
|
+
}
|
|
164
|
+
const value = input.argv[input.index + 1];
|
|
165
|
+
if (value === undefined || value === "-" || value === "-d" || value.startsWith("--")) {
|
|
166
|
+
fail(`${token} requires a value`);
|
|
167
|
+
}
|
|
168
|
+
if (isBlankInput(value))
|
|
169
|
+
fail(`${token} requires a nonblank value`);
|
|
170
|
+
flags[name] = kind === "repeatable" ? [...(Array.isArray(flags[name]) ? flags[name] : []), value] : value;
|
|
171
|
+
return input.index + 1;
|
|
172
|
+
}
|
|
173
|
+
function scanAkuma(action, argv, fail) {
|
|
174
|
+
const spec = AKUMA_COMMAND_SPECS[action];
|
|
175
|
+
const flags = {};
|
|
176
|
+
const positionals = [];
|
|
177
|
+
let stdin = false;
|
|
178
|
+
let positionalOnly = false;
|
|
179
|
+
for (let index = 1; index < argv.length; index += 1) {
|
|
180
|
+
const token = argv[index];
|
|
181
|
+
if (!positionalOnly && token === "--") {
|
|
182
|
+
positionalOnly = true;
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
if (positionalOnly) {
|
|
186
|
+
if (isBlankInput(token))
|
|
187
|
+
fail(`${action} requires a nonblank value`);
|
|
188
|
+
positionals.push(token);
|
|
189
|
+
}
|
|
190
|
+
else if (token === "-") {
|
|
191
|
+
if (!spec.stdin)
|
|
192
|
+
fail(`stdin marker '-' is not valid for ${action}`);
|
|
193
|
+
if (stdin)
|
|
194
|
+
fail("stdin marker '-' may appear only once");
|
|
195
|
+
stdin = true;
|
|
196
|
+
}
|
|
197
|
+
else if (token === "-d") {
|
|
198
|
+
fail(`option ${token} is not valid for ${action}`);
|
|
199
|
+
}
|
|
200
|
+
else if (!token.startsWith("--")) {
|
|
201
|
+
if (isBlankInput(token))
|
|
202
|
+
fail(`${action} requires a nonblank value`);
|
|
203
|
+
positionals.push(token);
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
if (action === "tell" && (token === "--wait" || token === "--schema"))
|
|
207
|
+
fail(`tell ${token} is not supported; use ask ${token}`);
|
|
208
|
+
index = scanNamedOption({ action, spec, argv, index }, flags, fail);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return { flags, positionals, stdin };
|
|
212
|
+
}
|
|
213
|
+
function positiveIndex(raw, option, fail) {
|
|
214
|
+
if (typeof raw !== "string" || !/^[1-9][0-9]*$/u.test(raw))
|
|
215
|
+
fail(`${option} requires a positive integer`);
|
|
216
|
+
const value = Number(raw);
|
|
217
|
+
if (!Number.isSafeInteger(value) || value <= 0)
|
|
218
|
+
fail(`${option} exceeds the safe integer range`);
|
|
219
|
+
return value;
|
|
220
|
+
}
|
|
221
|
+
function validateDirect(value, _fail) {
|
|
222
|
+
// Address validation belongs to the operation boundary so callers receive
|
|
223
|
+
// the compact Akuma refusal instead of a generic usage page.
|
|
224
|
+
return value;
|
|
225
|
+
}
|
|
226
|
+
function validateSet(value, fail) {
|
|
227
|
+
if (value.startsWith("kei/"))
|
|
228
|
+
return value;
|
|
229
|
+
if (value.includes("*")) {
|
|
230
|
+
try {
|
|
231
|
+
parseAkumaGlob(value);
|
|
232
|
+
}
|
|
233
|
+
catch (error) {
|
|
234
|
+
fail(error instanceof Error ? error.message : `invalid Akuma glob: ${value}`);
|
|
235
|
+
}
|
|
236
|
+
return value;
|
|
237
|
+
}
|
|
238
|
+
return validateDirect(value, fail);
|
|
239
|
+
}
|
|
240
|
+
function parseWait(rawSelectors, flags, output, fail) {
|
|
241
|
+
if (flags.any === true && flags.all === true)
|
|
242
|
+
fail("wait --any and --all are mutually exclusive");
|
|
243
|
+
const completion = flags.any === true ? "any" : flags.all === true ? "all" : undefined;
|
|
244
|
+
return {
|
|
245
|
+
command: "wait",
|
|
246
|
+
akuma: rawSelectors.map((value) => validateSet(value, fail)),
|
|
247
|
+
...(completion === undefined ? {} : { completion }),
|
|
248
|
+
...(flags.timeout === undefined ? {} : { timeoutMs: parseDuration(flags.timeout, "--timeout", fail) }),
|
|
249
|
+
output,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
function parseHistory(selector, flags, output, fail) {
|
|
253
|
+
if (selector.startsWith("kei/")) {
|
|
254
|
+
if ([flags.id, flags.before, flags.since, flags.limit, flags.last].some((value) => value !== undefined)) {
|
|
255
|
+
fail("history kei/... does not accept --id, --before, --since, --limit, or --last");
|
|
256
|
+
}
|
|
257
|
+
return { command: "history", contract: selector, full: flags.full === true, output };
|
|
258
|
+
}
|
|
259
|
+
return parseAkumaHistory(selector, flags, output, fail);
|
|
260
|
+
}
|
|
261
|
+
function refuseHistoryIdConflict(flags, bounded, fail) {
|
|
262
|
+
if (flags.id !== undefined && (flags.last === true || bounded))
|
|
263
|
+
fail("history --id cannot be combined with --last, --before, --since, or --limit");
|
|
264
|
+
}
|
|
265
|
+
function parseAkumaHistory(selector, flags, output, fail) {
|
|
266
|
+
if (flags.full === true)
|
|
267
|
+
fail("history --full is only valid for kei/...");
|
|
268
|
+
const bounded = flags.before !== undefined || flags.since !== undefined || flags.limit !== undefined;
|
|
269
|
+
if (flags.before !== undefined && flags.since !== undefined)
|
|
270
|
+
fail("history --before and --since are mutually exclusive");
|
|
271
|
+
refuseHistoryIdConflict(flags, bounded, fail);
|
|
272
|
+
if (flags.last === true && bounded)
|
|
273
|
+
fail("history --last cannot be combined with --before, --since, or --limit");
|
|
274
|
+
const limit = flags.limit === undefined ? undefined : positiveIndex(flags.limit, "--limit", fail);
|
|
275
|
+
if (limit !== undefined && limit > 5_000)
|
|
276
|
+
fail("--limit must be no greater than 5000");
|
|
277
|
+
const id = flags.id === undefined ? undefined : stringFlag(flags.id, "history --id requires a nonblank historyId", fail);
|
|
278
|
+
if (id !== undefined && parsePublicHistoryId(id) === null)
|
|
279
|
+
fail("history --id requires turn/<positive safe integer>");
|
|
280
|
+
return {
|
|
281
|
+
command: "history",
|
|
282
|
+
akuma: validateDirect(selector, fail),
|
|
283
|
+
...(id === undefined ? {} : { id }),
|
|
284
|
+
last: flags.last === true,
|
|
285
|
+
...(flags.before === undefined ? {} : { before: positiveIndex(flags.before, "--before", fail) }),
|
|
286
|
+
...(flags.since === undefined ? {} : { since: positiveIndex(flags.since, "--since", fail) }),
|
|
287
|
+
...(limit === undefined ? {} : { limit }),
|
|
288
|
+
output,
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
function parseAddressed(action, rawSelectors, flags, output, fail) {
|
|
292
|
+
if (action === "kill")
|
|
293
|
+
return { command: action, akuma: rawSelectors.map((value) => validateSet(value, fail)), output };
|
|
294
|
+
if (action === "wait")
|
|
295
|
+
return parseWait(rawSelectors, flags, output, fail);
|
|
296
|
+
if (action === "history") {
|
|
297
|
+
const selector = rawSelectors[0];
|
|
298
|
+
if (selector.includes("*"))
|
|
299
|
+
fail("history accepts one complete aku/..., @alias, or kei/... selector");
|
|
300
|
+
return parseHistory(selector, flags, output, fail);
|
|
301
|
+
}
|
|
302
|
+
const akuma = validateDirect(rawSelectors[0], fail);
|
|
303
|
+
const at = stringFlag(flags.at, "fork requires --at <historyId>", fail);
|
|
304
|
+
return { command: action, akuma, at, output };
|
|
305
|
+
}
|
|
306
|
+
function parsePrompted(action, positionals, stdin, fail) {
|
|
307
|
+
if (positionals.length < 1 || positionals.length > 2)
|
|
308
|
+
fail(`${action} has invalid positional arguments`);
|
|
309
|
+
const argument = positionals[1];
|
|
310
|
+
if (stdin && argument !== undefined)
|
|
311
|
+
fail(`${action} accepts either a prompt argument or stdin, not both`);
|
|
312
|
+
if (action !== "call" && !stdin && argument === undefined)
|
|
313
|
+
fail(`${action} requires a prompt argument or stdin`);
|
|
314
|
+
return {
|
|
315
|
+
subject: positionals[0],
|
|
316
|
+
...(stdin
|
|
317
|
+
? { prompt: { kind: "stdin" } }
|
|
318
|
+
: argument === undefined
|
|
319
|
+
? {}
|
|
320
|
+
: { prompt: { kind: "argument", value: argument } }),
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
function parseTell(flags, subject, prompt, output, fail) {
|
|
324
|
+
return {
|
|
325
|
+
command: "tell",
|
|
326
|
+
akuma: validateDirect(subject, fail),
|
|
327
|
+
interrupt: flags.interrupt === true,
|
|
328
|
+
prompt,
|
|
329
|
+
output,
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
function parseAsk(flags, subject, prompt, output, fail) {
|
|
333
|
+
const schema = flags.schema === undefined ? undefined : stringFlag(flags.schema, "ask --schema requires a file", fail);
|
|
334
|
+
return {
|
|
335
|
+
command: "ask",
|
|
336
|
+
akuma: validateDirect(subject, fail),
|
|
337
|
+
interrupt: flags.interrupt === true,
|
|
338
|
+
...(schema === undefined ? {} : { schema }),
|
|
339
|
+
...(flags.wait === undefined ? {} : { timeoutMs: parseDuration(flags.wait, "--wait", fail) }),
|
|
340
|
+
prompt,
|
|
341
|
+
output,
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
function parseAllowedFlag(raw, fail) {
|
|
345
|
+
if (raw === undefined)
|
|
346
|
+
return undefined;
|
|
347
|
+
if (!Array.isArray(raw))
|
|
348
|
+
fail("--allowed requires a value");
|
|
349
|
+
const selected = raw;
|
|
350
|
+
try {
|
|
351
|
+
return decodeAllowedActions(selected, "--allowed");
|
|
352
|
+
}
|
|
353
|
+
catch (error) {
|
|
354
|
+
fail(error instanceof Error ? error.message : "invalid --allowed action");
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
function parseCall(flags, archetype, prompt, output, fail) {
|
|
358
|
+
let alias;
|
|
359
|
+
if (flags.alias !== undefined) {
|
|
360
|
+
try {
|
|
361
|
+
const name = stringFlag(flags.alias, "--alias requires a name", fail);
|
|
362
|
+
alias = parseAkumaAlias(name.startsWith("@") ? name : `@${name}`);
|
|
363
|
+
}
|
|
364
|
+
catch (error) {
|
|
365
|
+
fail(error instanceof Error ? error.message : "invalid Akuma alias");
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
const mode = flags.wait === undefined ? "detach" : "wait";
|
|
369
|
+
const timeoutMs = flags.wait === undefined ? undefined : parseDuration(flags.wait, "--wait", fail);
|
|
370
|
+
const allowed = parseAllowedFlag(flags.allowed, fail);
|
|
371
|
+
const schema = flags.schema === undefined ? undefined : stringFlag(flags.schema, "call --schema requires a file", fail);
|
|
372
|
+
if (prompt === undefined && schema !== undefined)
|
|
373
|
+
fail("call --schema requires a prompt");
|
|
374
|
+
if (prompt === undefined && flags.wait !== undefined)
|
|
375
|
+
fail("call --wait requires a prompt");
|
|
376
|
+
return {
|
|
377
|
+
command: "call",
|
|
378
|
+
archetype,
|
|
379
|
+
...(typeof flags.contract === "string" ? { contract: flags.contract } : {}),
|
|
380
|
+
...(alias === undefined ? {} : { alias }),
|
|
381
|
+
mode,
|
|
382
|
+
...(timeoutMs === undefined ? {} : { timeoutMs }),
|
|
383
|
+
...(allowed === undefined ? {} : { allowed }),
|
|
384
|
+
...(schema === undefined ? {} : { schema }),
|
|
385
|
+
...(prompt === undefined ? {} : { prompt }),
|
|
386
|
+
output,
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
export function parseAkumaCommand(argv) {
|
|
390
|
+
const candidate = argv[0];
|
|
391
|
+
if (!isAkumaAction(candidate))
|
|
392
|
+
throw new CliUsageError(`unknown command: ${candidate ?? ""}`);
|
|
393
|
+
const action = candidate;
|
|
394
|
+
const spec = AKUMA_COMMAND_SPECS[action];
|
|
395
|
+
const fail = (message) => {
|
|
396
|
+
throw new CliUsageError(message, akumaUsageGuide(action));
|
|
397
|
+
};
|
|
398
|
+
const { flags, positionals, stdin } = scanAkuma(action, argv, fail);
|
|
399
|
+
const output = flags.json === true ? "json" : "text";
|
|
400
|
+
if (action === "call" || action === "tell" || action === "ask") {
|
|
401
|
+
const parsed = parsePrompted(action, positionals, stdin, fail);
|
|
402
|
+
return action === "call"
|
|
403
|
+
? parseCall(flags, parsed.subject, parsed.prompt, output, fail)
|
|
404
|
+
: action === "tell"
|
|
405
|
+
? parseTell(flags, parsed.subject, parsed.prompt, output, fail)
|
|
406
|
+
: parseAsk(flags, parsed.subject, parsed.prompt, output, fail);
|
|
407
|
+
}
|
|
408
|
+
if (spec.arity === "one-or-more" ? positionals.length === 0 : positionals.length !== spec.arity) {
|
|
409
|
+
fail(`${action} has invalid positional arguments`);
|
|
410
|
+
}
|
|
411
|
+
if (stdin)
|
|
412
|
+
fail(`${action} reads no stdin`);
|
|
413
|
+
return parseAddressed(action, positionals, flags, output, fail);
|
|
414
|
+
}
|
|
@@ -1,69 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}>;
|
|
7
|
-
type Addressed = Readonly<{
|
|
8
|
-
akuma: string;
|
|
9
|
-
}>;
|
|
10
|
-
export type AkumaPromptSource = Readonly<{
|
|
11
|
-
kind: "argument";
|
|
12
|
-
value: string;
|
|
13
|
-
}> | Readonly<{
|
|
14
|
-
kind: "stdin";
|
|
15
|
-
}>;
|
|
16
|
-
type Prompted = Readonly<{
|
|
17
|
-
prompt: AkumaPromptSource;
|
|
18
|
-
}>;
|
|
19
|
-
export type ParsedAkumaCommand = Output & ((Readonly<{
|
|
20
|
-
command: "call";
|
|
21
|
-
archetype: string;
|
|
22
|
-
contract?: string;
|
|
23
|
-
alias?: AkumaAlias;
|
|
24
|
-
mode: "wait" | "detach";
|
|
25
|
-
timeoutMs?: number;
|
|
26
|
-
allowed?: AllowedActions;
|
|
27
|
-
schema?: string;
|
|
28
|
-
}> & Prompted) | Readonly<{
|
|
29
|
-
command: "kill";
|
|
30
|
-
akuma: readonly string[];
|
|
31
|
-
}> | Readonly<{
|
|
32
|
-
command: "wait";
|
|
33
|
-
akuma: readonly string[];
|
|
34
|
-
completion?: "any" | "all";
|
|
35
|
-
timeoutMs?: number;
|
|
36
|
-
}> | (Readonly<{
|
|
37
|
-
command: "tell";
|
|
38
|
-
interrupt: boolean;
|
|
39
|
-
schema?: string;
|
|
40
|
-
timeoutMs?: number;
|
|
41
|
-
}> & Addressed & Prompted) | (Readonly<{
|
|
42
|
-
command: "history";
|
|
43
|
-
last: boolean;
|
|
44
|
-
id?: string;
|
|
45
|
-
before?: number;
|
|
46
|
-
since?: number;
|
|
47
|
-
limit?: number;
|
|
48
|
-
}> & Addressed) | Readonly<{
|
|
49
|
-
command: "history";
|
|
50
|
-
contract: string;
|
|
51
|
-
}> | (Readonly<{
|
|
52
|
-
command: "fork";
|
|
53
|
-
at: string;
|
|
54
|
-
}> & Addressed));
|
|
55
|
-
export type InvokedAkumaCommand = Exclude<ParsedAkumaCommand, {
|
|
56
|
-
command: "history";
|
|
57
|
-
contract: string;
|
|
58
|
-
}>;
|
|
59
|
-
export type AkumaAction = ParsedAkumaCommand["command"];
|
|
60
|
-
export declare function isAkumaAction(value: string | undefined): value is AkumaAction;
|
|
61
|
-
export declare function isParsedAkumaCommand(command: Readonly<{
|
|
62
|
-
command: string;
|
|
63
|
-
}>): command is InvokedAkumaCommand;
|
|
64
|
-
export declare function renderAkumaRootRows(): readonly string[];
|
|
65
|
-
export declare function renderAkumaHelp(action: AkumaAction): string;
|
|
66
|
-
export declare function renderAkumaUsage(action: AkumaAction): string;
|
|
67
|
-
export declare function akumaUsageGuide(action: AkumaAction): CliUsageGuide;
|
|
68
|
-
export declare function parseAkumaCommand(argv: readonly string[]): ParsedAkumaCommand;
|
|
69
|
-
export {};
|
|
1
|
+
import type { InvokedAkumaCommand } from "./akuma-grammar.js";
|
|
2
|
+
import type { CliCoordinates } from "../coordinates.js";
|
|
3
|
+
import type { CliRuntime } from "../runtime.js";
|
|
4
|
+
export { isParsedAkumaCommand, renderAkumaHelp } from "./akuma-grammar.js";
|
|
5
|
+
export declare function runAkumaCommand(command: InvokedAkumaCommand, coordinates: CliCoordinates, workdir: string | undefined, runtime: CliRuntime): Promise<number>;
|