@astrosheep/keiyaku 4.6.31 → 4.6.33
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 +42 -23
- package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +24 -15
- package/build/plugins/claude/skills/keiyaku-babysit/SKILL.md +12 -8
- package/build/plugins/claude/skills/keiyaku-bind/SKILL.md +4 -3
- package/build/plugins/claude/skills/keiyaku-debt/SKILL.md +17 -17
- package/build/plugins/claude/skills/keiyaku-workflow/SKILL.md +6 -4
- package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +24 -15
- package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +12 -8
- package/build/plugins/codex/skills/keiyaku-bind/SKILL.md +4 -3
- package/build/plugins/codex/skills/keiyaku-debt/SKILL.md +17 -17
- package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +6 -4
- package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +24 -15
- package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +12 -8
- package/build/plugins/opencode/skills/keiyaku-bind/SKILL.md +4 -3
- package/build/plugins/opencode/skills/keiyaku-debt/SKILL.md +17 -17
- package/build/plugins/opencode/skills/keiyaku-workflow/SKILL.md +6 -4
- package/build/plugins/pi/README.md +53 -97
- package/build/plugins/pi/keiyaku.ts +10 -6
- package/build/skills/keiyaku-akuma/SKILL.md +24 -15
- package/build/skills/keiyaku-babysit/SKILL.md +12 -8
- package/build/skills/keiyaku-bind/SKILL.md +4 -3
- package/build/skills/keiyaku-debt/SKILL.md +17 -17
- package/build/skills/keiyaku-workflow/SKILL.md +6 -4
- package/build/src/akuma/akuma-call.d.ts +3 -5
- package/build/src/akuma/akuma-call.js +7 -10
- package/build/src/akuma/akuma-errors.d.ts +7 -4
- package/build/src/akuma/akuma-errors.js +16 -12
- package/build/src/akuma/akuma-instance.d.ts +50 -303
- package/build/src/akuma/akuma-instance.js +48 -49
- package/build/src/akuma/akuma-observe.d.ts +5 -4
- package/build/src/akuma/akuma-observe.js +74 -21
- package/build/src/akuma/akuma-owner.d.ts +14 -6
- package/build/src/akuma/akuma-owner.js +33 -27
- package/build/src/akuma/akuma-selection-execution.d.ts +97 -19
- package/build/src/akuma/akuma-selection-execution.js +79 -133
- package/build/src/akuma/akuma-wait.d.ts +43 -4
- package/build/src/akuma/akuma-wait.js +58 -29
- package/build/src/akuma/akuma.d.ts +58 -384
- package/build/src/akuma/akuma.js +8 -58
- package/build/src/akuma/archetype.d.ts +16 -19
- package/build/src/akuma/archetype.js +48 -49
- package/build/src/akuma/body.js +44 -44
- package/build/src/akuma/call-initial-tell.d.ts +4 -2
- package/build/src/akuma/call-initial-tell.js +9 -2
- package/build/src/akuma/call-input.d.ts +8 -1
- package/build/src/akuma/call-input.js +27 -18
- package/build/src/akuma/caller.js +2 -1
- package/build/src/akuma/detached-body.js +1 -1
- package/build/src/akuma/heart/activity-schema.d.ts +16 -0
- package/build/src/akuma/heart/activity-schema.js +7 -0
- package/build/src/akuma/heart/facts.d.ts +5 -4
- package/build/src/akuma/heart/facts.js +5 -5
- package/build/src/akuma/heart/index.d.ts +1 -1
- package/build/src/akuma/heart/index.js +9 -1
- package/build/src/akuma/heart/soul.js +20 -4
- package/build/src/akuma/heart/timeline.js +4 -4
- package/build/src/akuma/identity.d.ts +1 -1
- package/build/src/akuma/identity.js +9 -4
- package/build/src/akuma/index.d.ts +6 -7
- package/build/src/akuma/index.js +2 -3
- package/build/src/akuma/projection-read.d.ts +4 -2
- package/build/src/akuma/projection-read.js +21 -14
- package/build/src/akuma/projection.d.ts +97 -2
- package/build/src/akuma/projection.js +47 -47
- package/build/src/akuma/provider-recipe.js +3 -2
- package/build/src/akuma/provider.d.ts +2 -2
- package/build/src/akuma/provider.js +27 -20
- package/build/src/akuma/providers/acp/config.js +11 -10
- package/build/src/akuma/providers/acp/core.js +2 -5
- package/build/src/akuma/providers/acp/index.js +2 -1
- package/build/src/akuma/providers/codex-app-server/index.js +7 -1
- package/build/src/akuma/providers/grok-build/index.js +2 -1
- package/build/src/akuma/providers/index.d.ts +0 -1
- package/build/src/akuma/providers/index.js +0 -8
- package/build/src/akuma/providers/opencode-sdk/events.d.ts +2 -1
- package/build/src/akuma/providers/opencode-sdk/events.js +31 -1
- package/build/src/akuma/providers/paseo/index.js +7 -4
- package/build/src/akuma/providers/pi/index.js +4 -3
- package/build/src/akuma/publication.d.ts +1 -2
- package/build/src/akuma/publication.js +19 -16
- package/build/src/akuma/schema.d.ts +3 -49
- package/build/src/akuma/schema.js +6 -147
- package/build/src/akuma/selection-observation.d.ts +304 -240
- package/build/src/akuma/selection-observation.js +135 -70
- package/build/src/akuma/status-projection.d.ts +61 -284
- package/build/src/akuma/status-projection.js +216 -138
- package/build/src/akuma/turn-drive.js +21 -15
- package/build/src/body/amend.js +7 -18
- package/build/src/body/arc.js +3 -2
- package/build/src/body/criteria.js +4 -3
- package/build/src/body/decode.js +13 -2
- package/build/src/body/envelope.d.ts +5 -1
- package/build/src/body/envelope.js +6 -3
- package/build/src/body/region.d.ts +1 -3
- package/build/src/body/region.js +3 -8
- package/build/src/body/render.js +4 -6
- package/build/src/body-host.d.ts +4 -11
- package/build/src/body-host.js +5 -4
- package/build/src/bounded-list.js +2 -1
- package/build/src/cli/commands/akuma-grammar.d.ts +107 -66
- package/build/src/cli/commands/akuma-grammar.js +66 -104
- package/build/src/cli/commands/akuma.d.ts +7 -3
- package/build/src/cli/commands/akuma.js +49 -160
- package/build/src/cli/commands/contract-grammar.d.ts +4 -135
- package/build/src/cli/commands/contract-grammar.js +126 -223
- package/build/src/cli/commands/contract-help.d.ts +26 -22
- package/build/src/cli/commands/contract-help.js +52 -38
- package/build/src/cli/commands/contract.d.ts +6 -18
- package/build/src/cli/commands/contract.js +68 -272
- package/build/src/cli/commands/debt-grammar.d.ts +2 -4
- package/build/src/cli/commands/debt-grammar.js +23 -193
- package/build/src/cli/commands/debt.js +10 -87
- package/build/src/cli/commands/report.d.ts +2 -4
- package/build/src/cli/coordinates.d.ts +1 -1
- package/build/src/cli/coordinates.js +1 -1
- package/build/src/cli/main.js +9 -3
- package/build/src/cli/parse.d.ts +80 -3
- package/build/src/cli/parse.js +76 -19
- package/build/src/cli/render/akuma-activity.d.ts +18 -35
- package/build/src/cli/render/akuma-activity.js +141 -290
- package/build/src/cli/render/akuma.d.ts +2 -8
- package/build/src/cli/render/akuma.js +50 -65
- package/build/src/cli/render/catalog.d.ts +2 -5
- package/build/src/cli/render/catalog.js +3 -37
- package/build/src/cli/render/contract-history.js +3 -2
- package/build/src/cli/render/contract-observation.d.ts +2 -8
- package/build/src/cli/render/contract-observation.js +25 -4
- package/build/src/cli/render/contract-wait.d.ts +2 -2
- package/build/src/cli/render/contract-wait.js +13 -17
- package/build/src/cli/render/contract.d.ts +7 -9
- package/build/src/cli/render/contract.js +46 -72
- package/build/src/cli/render/debt.d.ts +3 -11
- package/build/src/cli/render/debt.js +17 -89
- package/build/src/cli/render/delivery-preview.js +4 -4
- package/build/src/cli/render/execution-progress.js +1 -3
- package/build/src/cli/render/kanshi-akuma.d.ts +5 -3
- package/build/src/cli/render/kanshi-akuma.js +23 -20
- package/build/src/cli/render/kanshi.d.ts +1 -3
- package/build/src/cli/render/kanshi.js +27 -56
- package/build/src/cli/render/receipt.d.ts +21 -12
- package/build/src/cli/render/receipt.js +78 -68
- package/build/src/cli/render/reconcile.js +2 -5
- package/build/src/cli/render/refusal.d.ts +4 -3
- package/build/src/cli/render/refusal.js +17 -22
- package/build/src/cli/render/settings.d.ts +1 -1
- package/build/src/cli/render/terminal.d.ts +11 -12
- package/build/src/cli/render/terminal.js +53 -44
- package/build/src/cli/render/verbs.d.ts +4 -1
- package/build/src/cli/render/verbs.js +88 -128
- package/build/src/cli/runtime.js +65 -70
- package/build/src/cli/streams.d.ts +2 -9
- package/build/src/cli/streams.js +8 -1
- package/build/src/cli/usage.d.ts +2 -1
- package/build/src/cli/usage.js +3 -2
- package/build/src/contract-worktree.js +2 -10
- package/build/src/core/facts/codec.js +16 -25
- package/build/src/core/facts/eligibility.d.ts +4 -4
- package/build/src/core/facts/eligibility.js +11 -0
- package/build/src/core/facts/errors.d.ts +2 -1
- package/build/src/core/facts/errors.js +3 -3
- package/build/src/core/facts/fold.js +9 -5
- package/build/src/core/facts/gate.d.ts +5 -1
- package/build/src/core/facts/gate.js +14 -10
- package/build/src/core/facts/types.d.ts +7 -14
- package/build/src/core/facts/types.js +8 -6
- package/build/src/core/subject.d.ts +4 -1
- package/build/src/core/subject.js +10 -2
- package/build/src/core/verbs/abandon.d.ts +1 -2
- package/build/src/core/verbs/amend.d.ts +16 -6
- package/build/src/core/verbs/amend.js +19 -9
- package/build/src/core/verbs/arc.d.ts +1 -2
- package/build/src/core/verbs/attestation.d.ts +1 -2
- package/build/src/core/verbs/bind.d.ts +1 -2
- package/build/src/core/verbs/deliver.d.ts +1 -2
- package/build/src/core/verbs/placement.d.ts +1 -2
- package/build/src/core/verbs/reintegrate.d.ts +1 -2
- package/build/src/debt/board.d.ts +14 -94
- package/build/src/debt/board.js +25 -160
- package/build/src/debt/catalog.d.ts +0 -2
- package/build/src/debt/catalog.js +1 -22
- package/build/src/debt/document.d.ts +8 -11
- package/build/src/debt/document.js +19 -62
- package/build/src/debt/identity.d.ts +2 -14
- package/build/src/debt/identity.js +19 -49
- package/build/src/debt/index.d.ts +81 -220
- package/build/src/debt/index.js +61 -115
- package/build/src/debt/input.d.ts +21 -6
- package/build/src/debt/input.js +56 -180
- package/build/src/debt/lifecycle-operations.d.ts +1 -3
- package/build/src/debt/lifecycle-operations.js +1 -73
- package/build/src/debt/operation-types.d.ts +24 -128
- package/build/src/debt/operation-types.js +6 -62
- package/build/src/debt/operations.d.ts +8 -17
- package/build/src/debt/operations.js +58 -154
- package/build/src/debt/store.d.ts +0 -2
- package/build/src/debt/store.js +32 -87
- package/build/src/dispatch/index.d.ts +0 -17
- package/build/src/dispatch/index.js +1 -10
- package/build/src/errors.d.ts +28 -0
- package/build/src/errors.js +26 -0
- package/build/src/git/hooks.d.ts +1 -1
- package/build/src/git/identity.js +16 -45
- package/build/src/git/nuke.js +13 -23
- package/build/src/git/observe.d.ts +6 -0
- package/build/src/git/observe.js +40 -24
- package/build/src/git/process.js +11 -18
- package/build/src/git/read-observation.d.ts +5 -4
- package/build/src/git/reconcile.d.ts +3 -16
- package/build/src/git/reconcile.js +0 -18
- package/build/src/git/repository.d.ts +4 -1
- package/build/src/git/repository.js +16 -4
- package/build/src/git/scratch.js +2 -14
- package/build/src/git/target-placement.d.ts +4 -4
- package/build/src/git/target.d.ts +2 -2
- package/build/src/git/tender.d.ts +1 -2
- package/build/src/git/tender.js +5 -12
- package/build/src/git/terminal-reconcile.js +1 -13
- package/build/src/identity/coordinates.d.ts +1 -1
- package/build/src/identity/coordinates.js +3 -2
- package/build/src/identity/normalize.js +2 -1
- package/build/src/identity/selector.js +4 -3
- package/build/src/index.d.ts +36 -57
- package/build/src/index.js +11 -36
- package/build/src/kanshi/counts.d.ts +3 -8
- package/build/src/kanshi/counts.js +6 -14
- package/build/src/kanshi/index.d.ts +21 -7
- package/build/src/kanshi/index.js +29 -4
- package/build/src/kanshi/read.d.ts +101 -269
- package/build/src/kanshi/read.js +41 -200
- package/build/src/kanshi/report.d.ts +443 -1628
- package/build/src/kanshi/report.js +19 -31
- package/build/src/library/address.d.ts +20 -13
- package/build/src/library/address.js +48 -55
- package/build/src/library/akuma-creation.d.ts +249 -79
- package/build/src/library/akuma-creation.js +200 -247
- package/build/src/library/akumas.d.ts +24 -5
- package/build/src/library/akumas.js +96 -29
- package/build/src/library/bind.d.ts +7 -10
- package/build/src/library/bind.js +2 -8
- package/build/src/library/continuation.d.ts +151 -231
- package/build/src/library/continuation.js +22 -31
- package/build/src/library/contract-address.d.ts +6 -9
- package/build/src/library/contract-address.js +11 -16
- package/build/src/library/contract-composition.d.ts +2 -3
- package/build/src/library/contract-composition.js +12 -19
- package/build/src/library/contract-creation.js +35 -37
- package/build/src/library/contract-outcomes.d.ts +1349 -806
- package/build/src/library/contract-outcomes.js +12 -37
- package/build/src/library/contract-settings.d.ts +1 -2
- package/build/src/library/contract-settings.js +5 -7
- package/build/src/library/contract-types.d.ts +60 -67
- package/build/src/library/contract-types.js +17 -56
- package/build/src/library/contract-wait.d.ts +47 -3
- package/build/src/library/contract-wait.js +81 -70
- package/build/src/library/delivery.d.ts +391 -389
- package/build/src/library/delivery.js +5 -25
- package/build/src/library/input.d.ts +13 -5
- package/build/src/library/input.js +43 -38
- package/build/src/library/invocation.d.ts +13 -11
- package/build/src/library/invocation.js +69 -58
- package/build/src/library/kei.d.ts +16 -8
- package/build/src/library/kei.js +484 -25
- package/build/src/library/keiyaku-attribution.d.ts +0 -8
- package/build/src/library/keiyaku-attribution.js +0 -11
- package/build/src/library/keiyaku-classify.d.ts +2 -2
- package/build/src/library/keiyaku-classify.js +43 -62
- package/build/src/library/keiyaku-coordinates.d.ts +3 -8
- package/build/src/library/keiyaku-coordinates.js +6 -26
- package/build/src/library/keiyaku-debt.d.ts +21 -93
- package/build/src/library/keiyaku-debt.js +9 -159
- package/build/src/library/keiyaku-identity.d.ts +3 -3
- package/build/src/library/keiyaku-identity.js +16 -10
- package/build/src/library/keiyaku-verbs.d.ts +4102 -4889
- package/build/src/library/keiyaku-verbs.js +317 -291
- package/build/src/library/keiyaku-wait.d.ts +183 -0
- package/build/src/library/keiyaku-wait.js +213 -0
- package/build/src/library/keiyaku.d.ts +32 -860
- package/build/src/library/keiyaku.js +203 -314
- package/build/src/library/model-tools.d.ts +556 -0
- package/build/src/library/model-tools.js +347 -0
- package/build/src/library/nuke.d.ts +4 -2
- package/build/src/library/nuke.js +5 -1
- package/build/src/library/outcome.d.ts +424 -307
- package/build/src/library/outcome.js +166 -362
- package/build/src/library/reconcile.d.ts +331 -143
- package/build/src/library/reconcile.js +38 -72
- package/build/src/library/refusal.d.ts +45 -29
- package/build/src/library/refusal.js +5 -16
- package/build/src/library/repo.js +4 -3
- package/build/src/library/selection.d.ts +44 -21
- package/build/src/library/selection.js +63 -88
- package/build/src/mcp/adapter.js +37 -51
- package/build/src/mcp/description.d.ts +2 -0
- package/build/src/mcp/description.js +2 -0
- package/build/src/mcp/help.d.ts +1 -1
- package/build/src/mcp/help.js +16 -9
- package/build/src/pi/index.d.ts +3 -0
- package/build/src/pi/index.js +83 -0
- package/build/src/plugin/public.d.ts +4 -0
- package/build/src/plugin/runtime.d.ts +1 -1
- package/build/src/plugin/runtime.js +2 -2
- package/build/src/protocol/amend.d.ts +15 -4
- package/build/src/protocol/amend.js +114 -47
- package/build/src/protocol/bind.d.ts +5 -7
- package/build/src/protocol/bind.js +8 -19
- package/build/src/protocol/completion.d.ts +188 -195
- package/build/src/protocol/completion.js +63 -24
- package/build/src/protocol/deliver.d.ts +11 -6
- package/build/src/protocol/deliver.js +37 -50
- package/build/src/protocol/delivery-preview.d.ts +18 -11
- package/build/src/protocol/delivery-preview.js +2 -2
- package/build/src/protocol/execution-observation.d.ts +13 -13
- package/build/src/protocol/intent.d.ts +7 -9
- package/build/src/protocol/intent.js +22 -32
- package/build/src/protocol/operations.d.ts +102 -69
- package/build/src/protocol/operations.js +33 -56
- package/build/src/protocol/outcome.d.ts +3 -1
- package/build/src/protocol/placement.d.ts +1 -2
- package/build/src/protocol/placement.js +7 -1
- package/build/src/protocol/progress.d.ts +1 -0
- package/build/src/protocol/progress.js +0 -6
- package/build/src/protocol/read/status.d.ts +69 -112
- package/build/src/protocol/read/status.js +59 -88
- package/build/src/protocol/reintegrate.d.ts +1 -2
- package/build/src/protocol/reintegrate.js +2 -3
- package/build/src/protocol/result-leaves.d.ts +67 -40
- package/build/src/protocol/result-leaves.js +28 -58
- package/build/src/protocol/result-reasons.d.ts +6 -6
- package/build/src/protocol/review.js +0 -1
- package/build/src/protocol/run.js +1 -4
- package/build/src/protocol/verify.d.ts +202 -146
- package/build/src/protocol/verify.js +61 -47
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/build/src/settings.d.ts +8 -9
- package/build/src/settings.js +16 -13
- package/build/src/settlement/holder.js +2 -2
- package/build/src/settlement/settle.d.ts +0 -6
- package/build/src/settlement/settle.js +19 -72
- package/build/src/verification/declaration.d.ts +3 -6
- package/build/src/verification/declaration.js +3 -5
- package/build/src/verification/observation.d.ts +2 -2
- package/build/src/world.d.ts +3 -2
- package/build/src/world.js +5 -6
- package/package.json +7 -3
- package/plugins/paseo/plugin/index.server.ts +1 -1
- package/plugins/paseo/plugin/server/attach.ts +74 -67
- package/plugins/paseo/plugin/server/keiyaku.ts +80 -14
- package/plugins/paseo/plugin/server/message.ts +2 -1
- package/plugins/paseo/plugin/server/mirror-identity.ts +6 -4
- package/plugins/paseo/plugin/server/sdk.ts +9 -11
- package/plugins/paseo/plugin/server/transport.ts +24 -1
- package/plugins/pi/README.md +53 -97
- package/plugins/pi/keiyaku.ts +10 -6
- package/skills/keiyaku-akuma/SKILL.md +24 -15
- package/skills/keiyaku-babysit/SKILL.md +12 -8
- package/skills/keiyaku-bind/SKILL.md +4 -3
- package/skills/keiyaku-debt/SKILL.md +17 -17
- package/skills/keiyaku-workflow/SKILL.md +6 -4
- package/build/plugins/pi/akuma-tools.ts +0 -290
- package/build/src/akuma/providers/codex-app-server/configuration.d.ts +0 -5
- package/build/src/akuma/providers/codex-app-server/configuration.js +0 -72
- package/build/src/body/keys.d.ts +0 -4
- package/build/src/body/keys.js +0 -11
- package/build/src/cli/commands/debt-query.d.ts +0 -5
- package/build/src/cli/commands/debt-query.js +0 -194
- package/build/src/cli/render/akuma-tool-command.d.ts +0 -6
- package/build/src/cli/render/akuma-tool-command.js +0 -143
- package/build/src/cli/render/akuma-tool.d.ts +0 -29
- package/build/src/cli/render/akuma-tool.js +0 -225
- package/build/src/debt/context.d.ts +0 -28
- package/build/src/debt/context.js +0 -102
- package/build/src/debt/created-observation.d.ts +0 -26
- package/build/src/debt/created-observation.js +0 -38
- package/build/src/debt/query.d.ts +0 -80
- package/build/src/debt/query.js +0 -283
- package/build/src/kanshi/roster.d.ts +0 -2
- package/build/src/kanshi/roster.js +0 -2
- package/build/src/library/contract-execution.d.ts +0 -28
- package/build/src/library/contract-execution.js +0 -506
- package/build/src/library/keiyaku-policy.d.ts +0 -27
- package/build/src/library/keiyaku-policy.js +0 -44
- package/build/src/library/keiyaku-status.d.ts +0 -1487
- package/build/src/library/keiyaku-status.js +0 -92
- package/plugins/pi/akuma-tools.ts +0 -290
package/build/src/akuma/akuma.js
CHANGED
|
@@ -1,60 +1,16 @@
|
|
|
1
|
+
import { KeiyakuError } from "../errors.js";
|
|
1
2
|
import { akumaBirthSchema, akumaCallerKey, decodeAkumaCaller } from "./caller.js";
|
|
2
3
|
import { readdir, stat } from "node:fs/promises";
|
|
3
4
|
import { z } from "zod";
|
|
4
|
-
import {
|
|
5
|
-
import { akumaAliasSchema } from "../identity/selector.js";
|
|
5
|
+
import { projectBoundedList } from "../bounded-list.js";
|
|
6
6
|
import { rosterListRow } from "./akuma-observe.js";
|
|
7
7
|
import { AkumaOwner } from "./akuma-owner.js";
|
|
8
8
|
import { readSoul } from "./heart/index.js";
|
|
9
9
|
import { akumaIdFromDirectoryName, akumaIdSchema, akumaPaths, akumaRunRoot, parseAkumaId, pathsForAkumaId, } from "./identity.js";
|
|
10
10
|
import { validateAkumaName } from "../identity/normalize.js";
|
|
11
11
|
import { readAkumaLineage, readDirectAkumaLineage, invalidateAkumaLineage, rebuildAkumaLineage, } from "./lineage-cache.js";
|
|
12
|
-
import {
|
|
12
|
+
import { currentWorkSchema } from "./status-projection.js";
|
|
13
13
|
import { PAGE_POOL_SIZE, boundedMap } from "./read-pool.js";
|
|
14
|
-
const bornLifeSchema = z.enum(["running", "asleep", "stranded", "hung", "untidy", "killed"]);
|
|
15
|
-
export const listedBornAkumaSchema = z
|
|
16
|
-
.strictObject({
|
|
17
|
-
id: akumaIdSchema,
|
|
18
|
-
life: bornLifeSchema,
|
|
19
|
-
lifeAt: z.string().exactOptional(),
|
|
20
|
-
lastActivityAt: z.string().exactOptional(),
|
|
21
|
-
pending: z.number().int().positive().exactOptional(),
|
|
22
|
-
aliases: z.array(akumaAliasSchema).nonempty().readonly().exactOptional(),
|
|
23
|
-
parentAkumaId: akumaIdSchema.exactOptional(),
|
|
24
|
-
})
|
|
25
|
-
.readonly();
|
|
26
|
-
export const listedUnbornAkumaSchema = z
|
|
27
|
-
.strictObject({
|
|
28
|
-
id: akumaIdSchema,
|
|
29
|
-
life: z.enum(["unborn", "stillborn"]),
|
|
30
|
-
aliases: z.array(akumaAliasSchema).nonempty().readonly().exactOptional(),
|
|
31
|
-
diagnostic: z.string().exactOptional(),
|
|
32
|
-
})
|
|
33
|
-
.readonly();
|
|
34
|
-
export const listedAkumaSchema = z.union([listedBornAkumaSchema, listedUnbornAkumaSchema]);
|
|
35
|
-
export const akumaListSchema = z
|
|
36
|
-
.strictObject({
|
|
37
|
-
observedAt: z.string(),
|
|
38
|
-
rows: z.array(listedAkumaSchema).nonempty().readonly().exactOptional(),
|
|
39
|
-
more: z.literal(true).exactOptional(),
|
|
40
|
-
})
|
|
41
|
-
.readonly();
|
|
42
|
-
function listedAkuma(row) {
|
|
43
|
-
if (row.kind === "unborn")
|
|
44
|
-
return {
|
|
45
|
-
id: row.id,
|
|
46
|
-
life: row.life,
|
|
47
|
-
...(row.diagnostic === undefined ? {} : { diagnostic: row.diagnostic }),
|
|
48
|
-
};
|
|
49
|
-
return {
|
|
50
|
-
id: row.id,
|
|
51
|
-
life: row.life,
|
|
52
|
-
...(row.lifeAt === undefined ? {} : { lifeAt: row.lifeAt }),
|
|
53
|
-
...(row.lastActivityAt === undefined ? {} : { lastActivityAt: row.lastActivityAt }),
|
|
54
|
-
...(row.pending === undefined ? {} : { pending: row.pending }),
|
|
55
|
-
...(row.caller?.kind === "akuma" ? { parentAkumaId: row.caller.akumaId } : {}),
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
14
|
export const akumaStatusSchema = z
|
|
59
15
|
.object({
|
|
60
16
|
id: akumaIdSchema,
|
|
@@ -64,7 +20,7 @@ export const akumaStatusSchema = z
|
|
|
64
20
|
provider: z.string().exactOptional(),
|
|
65
21
|
model: z.string().exactOptional(),
|
|
66
22
|
lastActivityAt: z.string().exactOptional(),
|
|
67
|
-
|
|
23
|
+
work: currentWorkSchema,
|
|
68
24
|
strandedReason: z.literal("resume-unsupported").exactOptional(),
|
|
69
25
|
})
|
|
70
26
|
.strict()
|
|
@@ -169,13 +125,13 @@ export async function countRunningAkuma(path) {
|
|
|
169
125
|
throw new Error("Cannot classify every recognized Akuma", { cause: observed.failure });
|
|
170
126
|
return observed.rows.filter((row) => row.life === "running").length;
|
|
171
127
|
}
|
|
172
|
-
function rosterInput(input, allowLimit) {
|
|
128
|
+
export function rosterInput(input, allowLimit) {
|
|
173
129
|
if (typeof input !== "object" || input === null || Array.isArray(input))
|
|
174
|
-
throw new
|
|
130
|
+
throw new KeiyakuError("invalid-input", "Akuma list input must be an object");
|
|
175
131
|
const allowed = allowLimit ? ["akumaName", "caller", "limit"] : ["akumaName", "caller"];
|
|
176
132
|
const unknown = Object.keys(input).find((key) => !allowed.includes(key));
|
|
177
133
|
if (unknown !== undefined)
|
|
178
|
-
throw new
|
|
134
|
+
throw new KeiyakuError("invalid-input", `Akuma list input has unknown field: ${unknown}`);
|
|
179
135
|
const caller = decodeAkumaCaller(input.caller);
|
|
180
136
|
return {
|
|
181
137
|
...(input.akumaName === undefined ? {} : { akumaName: validateAkumaName(input.akumaName) }),
|
|
@@ -358,16 +314,10 @@ async function readCallerPage(path, limit, selected, caller) {
|
|
|
358
314
|
function rosterResult(observedAt, rows, more) {
|
|
359
315
|
return {
|
|
360
316
|
observedAt,
|
|
361
|
-
...(rows.length === 0 ? {} : { rows
|
|
317
|
+
...(rows.length === 0 ? {} : { rows }),
|
|
362
318
|
...(more ? { more: true } : {}),
|
|
363
319
|
};
|
|
364
320
|
}
|
|
365
|
-
/** The bounded recent-activity roster input: native membership and observed extent. */
|
|
366
|
-
export async function readAkumaRoster(path, input = {}) {
|
|
367
|
-
const selection = rosterInput(input, true);
|
|
368
|
-
const limit = boundedListLimit(input.limit);
|
|
369
|
-
return observeAkumaRoster(path, limit, selection.akumaName, selection.caller);
|
|
370
|
-
}
|
|
371
321
|
/**
|
|
372
322
|
* The bounded recent-activity roster: native membership, semantic order and
|
|
373
323
|
* observed extent. A caller-scoped roster filters its World-local closure before
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { KeiyakuError } from "../errors.js";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
import type { Settings } from "../settings.js";
|
|
3
4
|
import { type ProviderExecution, type ProviderOptions } from "./provider-recipe.js";
|
|
@@ -9,12 +10,13 @@ type DecodedArchetype = Readonly<{
|
|
|
9
10
|
hidden?: boolean;
|
|
10
11
|
options: ProviderOptions;
|
|
11
12
|
}>;
|
|
12
|
-
export declare const
|
|
13
|
+
export declare const akumaNameCatalogRowSchema: z.ZodReadonly<z.ZodObject<{
|
|
13
14
|
name: z.ZodString;
|
|
14
15
|
model: z.ZodExactOptional<z.ZodString>;
|
|
15
16
|
description: z.ZodExactOptional<z.ZodString>;
|
|
16
17
|
}, z.core.$strict>>;
|
|
17
|
-
export declare const
|
|
18
|
+
export declare const akumaNameCatalogSchema: z.ZodReadonly<z.ZodObject<{
|
|
19
|
+
kind: z.ZodLiteral<"akuma-name-catalogue">;
|
|
18
20
|
rows: z.ZodExactOptional<z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
|
|
19
21
|
name: z.ZodString;
|
|
20
22
|
model: z.ZodExactOptional<z.ZodString>;
|
|
@@ -22,15 +24,15 @@ export declare const archetypeCatalogSchema: z.ZodReadonly<z.ZodObject<{
|
|
|
22
24
|
}, z.core.$strict>>>>>;
|
|
23
25
|
more: z.ZodExactOptional<z.ZodLiteral<true>>;
|
|
24
26
|
}, z.core.$strict>>;
|
|
25
|
-
export type
|
|
27
|
+
export type AkumaNameCatalogRow = Readonly<{
|
|
26
28
|
name: string;
|
|
27
29
|
model?: string;
|
|
28
30
|
description?: string;
|
|
29
31
|
}>;
|
|
30
|
-
export type
|
|
31
|
-
/** One closed catalogue request: omitted
|
|
32
|
-
export type
|
|
33
|
-
|
|
32
|
+
export type AkumaNameCatalog = z.output<typeof akumaNameCatalogSchema>;
|
|
33
|
+
/** One closed catalogue request: omitted cwd means no project scope, never ambient discovery. */
|
|
34
|
+
export type AkumaNameCatalogInput = Readonly<{
|
|
35
|
+
cwd?: string;
|
|
34
36
|
home?: string;
|
|
35
37
|
limit?: number;
|
|
36
38
|
}>;
|
|
@@ -38,24 +40,19 @@ export type ArchetypeCatalogInput = Readonly<{
|
|
|
38
40
|
type PreparedArchetype = Omit<DecodedArchetype, "provider"> & Readonly<{
|
|
39
41
|
provider: ProviderExecution;
|
|
40
42
|
}>;
|
|
41
|
-
export declare class
|
|
43
|
+
export declare class AkumaNameError extends KeiyakuError {
|
|
42
44
|
readonly akumaName: string;
|
|
43
45
|
readonly searched: readonly string[];
|
|
44
46
|
readonly reason: string;
|
|
45
|
-
readonly
|
|
46
|
-
|
|
47
|
+
readonly absent: boolean;
|
|
48
|
+
readonly kind = "akuma-name";
|
|
49
|
+
constructor(akumaName: string, searched: readonly string[], reason: string, absent?: boolean);
|
|
47
50
|
}
|
|
48
|
-
type ArchetypeCoordinates =
|
|
49
|
-
|
|
50
|
-
home?: string;
|
|
51
|
-
}>;
|
|
52
|
-
export declare function listArchetypes(input?: ArchetypeCoordinates): Promise<readonly string[]>;
|
|
53
|
-
export declare function listArchetypeDefinitions(input?: ArchetypeCatalogInput): Promise<ArchetypeCatalog>;
|
|
51
|
+
type ArchetypeCoordinates = Pick<AkumaNameCatalogInput, "cwd" | "home">;
|
|
52
|
+
export declare function listAkumaNameDefinitions(input?: AkumaNameCatalogInput): Promise<AkumaNameCatalog>;
|
|
54
53
|
/** Resolve one akumaName and decode its provider execution, leaving option admission to the caller. */
|
|
55
54
|
export declare function loadPreparedArchetype(input: Readonly<{
|
|
56
55
|
name: string;
|
|
57
|
-
project?: string;
|
|
58
|
-
home?: string;
|
|
59
56
|
settings: Settings;
|
|
60
|
-
}>): Promise<PreparedArchetype>;
|
|
57
|
+
}> & ArchetypeCoordinates): Promise<PreparedArchetype>;
|
|
61
58
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { KeiyakuError, errorCategory } from "../errors.js";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
import { readFile, readdir } from "node:fs/promises";
|
|
3
4
|
import { homedir } from "node:os";
|
|
@@ -6,26 +7,30 @@ import { parseDocument } from "yaml";
|
|
|
6
7
|
import { boundedListLimit } from "../bounded-list.js";
|
|
7
8
|
import { validateAkumaName } from "../identity/normalize.js";
|
|
8
9
|
import { decodeProviderOptions, decodeProviderRecipe, } from "./provider-recipe.js";
|
|
9
|
-
export const
|
|
10
|
+
export const akumaNameCatalogRowSchema = z
|
|
10
11
|
.strictObject({ name: z.string(), model: z.string().exactOptional(), description: z.string().exactOptional() })
|
|
11
12
|
.readonly();
|
|
12
|
-
export const
|
|
13
|
+
export const akumaNameCatalogSchema = z
|
|
13
14
|
.strictObject({
|
|
14
|
-
|
|
15
|
+
kind: z.literal("akuma-name-catalogue"),
|
|
16
|
+
rows: z.array(akumaNameCatalogRowSchema).nonempty().readonly().exactOptional(),
|
|
15
17
|
more: z.literal(true).exactOptional(),
|
|
16
18
|
})
|
|
17
19
|
.readonly();
|
|
18
|
-
export class
|
|
20
|
+
export class AkumaNameError extends KeiyakuError {
|
|
19
21
|
akumaName;
|
|
20
22
|
searched;
|
|
21
23
|
reason;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
absent;
|
|
25
|
+
kind = "akuma-name";
|
|
26
|
+
constructor(akumaName, searched, reason, absent = false) {
|
|
27
|
+
super(absent ? "invalid-input" : "internal", `\`${akumaName}\` ${reason}`, {
|
|
28
|
+
...(absent ? { next: { verb: "ls", input: { selector: "aku/" } } } : {}),
|
|
29
|
+
});
|
|
25
30
|
this.akumaName = akumaName;
|
|
26
31
|
this.searched = searched;
|
|
27
32
|
this.reason = reason;
|
|
28
|
-
this.
|
|
33
|
+
this.absent = absent;
|
|
29
34
|
}
|
|
30
35
|
}
|
|
31
36
|
function projectArchetypeDirectory(project) {
|
|
@@ -35,7 +40,7 @@ function homeArchetypeDirectory(home) {
|
|
|
35
40
|
return join(home ?? join(homedir(), ".keiyaku"), "akumas");
|
|
36
41
|
}
|
|
37
42
|
function archetypeDirectories(input) {
|
|
38
|
-
return [projectArchetypeDirectory(input.
|
|
43
|
+
return [projectArchetypeDirectory(input.cwd), homeArchetypeDirectory(input.home)].filter((directory) => directory !== undefined);
|
|
39
44
|
}
|
|
40
45
|
async function pathsInDirectory(directory) {
|
|
41
46
|
try {
|
|
@@ -70,33 +75,27 @@ async function archetypePaths(input = {}) {
|
|
|
70
75
|
return [...selected.values()].sort((left, right) => Buffer.compare(Buffer.from(left.name), Buffer.from(right.name)));
|
|
71
76
|
}
|
|
72
77
|
function sourceLookups(name, input, source) {
|
|
73
|
-
if (source === "home" || input.
|
|
78
|
+
if (source === "home" || input.cwd === undefined) {
|
|
74
79
|
return [{ path: join(homeArchetypeDirectory(input.home), `${name}.md`), source: "home" }];
|
|
75
80
|
}
|
|
76
81
|
return [
|
|
77
|
-
{ path: join(projectArchetypeDirectory(input.
|
|
82
|
+
{ path: join(projectArchetypeDirectory(input.cwd), `${name}.md`), source: "project" },
|
|
78
83
|
{ path: join(homeArchetypeDirectory(input.home), `${name}.md`), source: "home" },
|
|
79
84
|
];
|
|
80
85
|
}
|
|
81
|
-
function rootLookups(name, input) {
|
|
82
|
-
return input.project === undefined ? sourceLookups(name, input, "home") : sourceLookups(name, input, "project");
|
|
83
|
-
}
|
|
84
86
|
function chainText(chain) {
|
|
85
87
|
return chain.join(" -> ");
|
|
86
88
|
}
|
|
87
|
-
function archetypeError(name, searched, reason, chain,
|
|
89
|
+
function archetypeError(name, searched, reason, chain, absent = false) {
|
|
88
90
|
const withChain = chain.length === 0 ? reason : `${reason} (base chain: ${chainText(chain)})`;
|
|
89
|
-
return new
|
|
90
|
-
}
|
|
91
|
-
export async function listArchetypes(input = {}) {
|
|
92
|
-
return (await archetypePaths(input)).map(({ name }) => name);
|
|
91
|
+
return new AkumaNameError(name, searched, withChain, absent);
|
|
93
92
|
}
|
|
94
93
|
function archetypeField(values, key, required = false) {
|
|
95
94
|
const value = values[key];
|
|
96
95
|
if (value === undefined && !required)
|
|
97
96
|
return undefined;
|
|
98
97
|
if (typeof value !== "string" || value.trim().length === 0) {
|
|
99
|
-
throw new
|
|
98
|
+
throw new KeiyakuError("invalid-input", `Akuma ${key} must be a nonblank string`);
|
|
100
99
|
}
|
|
101
100
|
return value;
|
|
102
101
|
}
|
|
@@ -105,7 +104,7 @@ function archetypeEnum(values, key, allowed) {
|
|
|
105
104
|
if (value === undefined)
|
|
106
105
|
return undefined;
|
|
107
106
|
if (!allowed.includes(value))
|
|
108
|
-
throw new
|
|
107
|
+
throw new KeiyakuError("invalid-input", `Akuma ${key} must be one of ${allowed.join(", ")}`);
|
|
109
108
|
return value;
|
|
110
109
|
}
|
|
111
110
|
function archetypeBoolean(values, key) {
|
|
@@ -113,29 +112,29 @@ function archetypeBoolean(values, key) {
|
|
|
113
112
|
if (value === undefined)
|
|
114
113
|
return undefined;
|
|
115
114
|
if (typeof value !== "boolean")
|
|
116
|
-
throw new
|
|
115
|
+
throw new KeiyakuError("invalid-input", `Akuma ${key} must be a boolean`);
|
|
117
116
|
return value;
|
|
118
117
|
}
|
|
119
118
|
function parseArchetypeFrontmatter(markdown) {
|
|
120
119
|
const lines = markdown.split(/\r?\n/u);
|
|
121
120
|
if (lines[0]?.trim() !== "---")
|
|
122
|
-
throw new
|
|
121
|
+
throw new KeiyakuError("invalid-input", "Akuma file must begin with YAML frontmatter");
|
|
123
122
|
const closing = lines.findIndex((line, index) => index > 0 && line.trim() === "---");
|
|
124
123
|
if (closing < 0)
|
|
125
|
-
throw new
|
|
124
|
+
throw new KeiyakuError("invalid-input", "Akuma frontmatter is not closed");
|
|
126
125
|
const document = parseDocument(lines.slice(1, closing).join("\n"), { uniqueKeys: true });
|
|
127
126
|
if (document.errors.length > 0)
|
|
128
|
-
throw new
|
|
127
|
+
throw new KeiyakuError("invalid-input", `Akuma frontmatter is invalid: ${document.errors[0].message}`);
|
|
129
128
|
const decoded = document.toJS();
|
|
130
129
|
if (decoded === null || typeof decoded !== "object" || Array.isArray(decoded)) {
|
|
131
|
-
throw new
|
|
130
|
+
throw new KeiyakuError("invalid-input", "Akuma frontmatter must be one mapping");
|
|
132
131
|
}
|
|
133
132
|
return { lines, closing, values: decoded };
|
|
134
133
|
}
|
|
135
134
|
function decodeArchetypeFields(values) {
|
|
136
135
|
const unknown = Object.keys(values).find((key) => !["base", "provider", "model", "effort", "network", "description", "hidden", "systemPromptMode"].includes(key));
|
|
137
136
|
if (unknown !== undefined)
|
|
138
|
-
throw new
|
|
137
|
+
throw new KeiyakuError("invalid-input", `Akuma frontmatter has unknown field: ${unknown}`);
|
|
139
138
|
const provider = archetypeField(values, "provider");
|
|
140
139
|
const baseValue = archetypeField(values, "base");
|
|
141
140
|
const base = baseValue === undefined ? undefined : validateAkumaName(baseValue);
|
|
@@ -161,7 +160,7 @@ function decodeArchetype(name, path, markdown) {
|
|
|
161
160
|
const fields = decodeArchetypeFields(values);
|
|
162
161
|
const systemPrompt = lines.slice(closing + 1).join("\n");
|
|
163
162
|
if (fields.systemPromptMode !== undefined && systemPrompt.length === 0) {
|
|
164
|
-
throw new
|
|
163
|
+
throw new KeiyakuError("invalid-input", "Akuma systemPromptMode requires a nonempty Markdown body");
|
|
165
164
|
}
|
|
166
165
|
return Object.freeze({
|
|
167
166
|
name,
|
|
@@ -186,7 +185,7 @@ function decodeArchetype(name, path, markdown) {
|
|
|
186
185
|
function mergeArchetype(base, local) {
|
|
187
186
|
const provider = local.provider ?? base?.provider;
|
|
188
187
|
if (provider === undefined)
|
|
189
|
-
throw new
|
|
188
|
+
throw new KeiyakuError("invalid-input", "Akuma provider must be a nonblank string");
|
|
190
189
|
const options = decodeProviderOptions({ ...(base?.options ?? {}), ...local.options });
|
|
191
190
|
return Object.freeze({
|
|
192
191
|
name: local.name,
|
|
@@ -203,11 +202,10 @@ function mergeArchetype(base, local) {
|
|
|
203
202
|
});
|
|
204
203
|
}
|
|
205
204
|
async function resolveArchetype(name, input, source, chain = []) {
|
|
205
|
+
const lookups = sourceLookups(name, input, source ?? "project");
|
|
206
206
|
if (chain.includes(name)) {
|
|
207
|
-
const lookups = source === undefined ? rootLookups(name, input) : sourceLookups(name, input, source);
|
|
208
207
|
throw archetypeError(name, lookups.map(({ path }) => path), "has a cyclic base reference", [...chain, name]);
|
|
209
208
|
}
|
|
210
|
-
const lookups = source === undefined ? rootLookups(name, input) : sourceLookups(name, input, source);
|
|
211
209
|
const searched = lookups.map(({ path }) => path);
|
|
212
210
|
for (const lookup of lookups) {
|
|
213
211
|
let markdown;
|
|
@@ -238,36 +236,36 @@ async function resolveArchetype(name, input, source, chain = []) {
|
|
|
238
236
|
}
|
|
239
237
|
}
|
|
240
238
|
const missingChain = chain.length === 0 ? chain : [...chain, name];
|
|
241
|
-
throw archetypeError(name, searched, "was not found", missingChain,
|
|
239
|
+
throw archetypeError(name, searched, "was not found", missingChain, true);
|
|
242
240
|
}
|
|
243
241
|
function catalogueCoordinate(value, field) {
|
|
244
242
|
if (value === undefined)
|
|
245
243
|
return undefined;
|
|
246
244
|
if (typeof value !== "string" || value.trim().length === 0) {
|
|
247
|
-
throw new
|
|
245
|
+
throw new KeiyakuError("invalid-input", `Akuma catalogue ${field} must be a nonblank string`);
|
|
248
246
|
}
|
|
249
247
|
if (!isAbsolute(value))
|
|
250
|
-
throw new
|
|
248
|
+
throw new KeiyakuError("invalid-input", `Akuma catalogue ${field} must be absolute: ${value}`);
|
|
251
249
|
return value;
|
|
252
250
|
}
|
|
253
251
|
/** Malformed caller input fails here, before any filesystem observation. */
|
|
254
252
|
function catalogueInput(value) {
|
|
255
253
|
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
256
|
-
throw new
|
|
254
|
+
throw new KeiyakuError("invalid-input", "Akuma catalogue input must be an object");
|
|
257
255
|
}
|
|
258
256
|
const input = value;
|
|
259
|
-
const unknown = Object.keys(input).find((key) => !["
|
|
257
|
+
const unknown = Object.keys(input).find((key) => !["cwd", "home", "limit"].includes(key));
|
|
260
258
|
if (unknown !== undefined)
|
|
261
|
-
throw new
|
|
262
|
-
const
|
|
259
|
+
throw new KeiyakuError("invalid-input", `Akuma catalogue input has unknown field: ${unknown}`);
|
|
260
|
+
const cwd = catalogueCoordinate(input.cwd, "cwd");
|
|
263
261
|
const home = catalogueCoordinate(input.home, "home");
|
|
264
262
|
return {
|
|
265
|
-
...(
|
|
263
|
+
...(cwd === undefined ? {} : { cwd }),
|
|
266
264
|
...(home === undefined ? {} : { home }),
|
|
267
265
|
...(input.limit === undefined ? {} : { limit: boundedListLimit(input.limit) }),
|
|
268
266
|
};
|
|
269
267
|
}
|
|
270
|
-
export async function
|
|
268
|
+
export async function listAkumaNameDefinitions(input = {}) {
|
|
271
269
|
// Reads still run concurrently, but the reported failure is the first invalid
|
|
272
270
|
// definition in catalog byte order, not whichever read happened to finish first.
|
|
273
271
|
const { limit, ...coordinates } = catalogueInput(input);
|
|
@@ -277,9 +275,9 @@ export async function listArchetypeDefinitions(input = {}) {
|
|
|
277
275
|
return await resolveArchetype(name, coordinates, undefined);
|
|
278
276
|
}
|
|
279
277
|
catch (error) {
|
|
280
|
-
if (error instanceof
|
|
278
|
+
if (error instanceof AkumaNameError)
|
|
281
279
|
throw error;
|
|
282
|
-
throw new
|
|
280
|
+
throw new AkumaNameError(name, [path], `is invalid: ${error instanceof Error ? error.message : String(error)}`);
|
|
283
281
|
}
|
|
284
282
|
}));
|
|
285
283
|
const firstInvalid = settled.find((result) => result.status === "rejected");
|
|
@@ -295,6 +293,7 @@ export async function listArchetypeDefinitions(input = {}) {
|
|
|
295
293
|
}));
|
|
296
294
|
const rows = limit === undefined ? visible : visible.slice(0, limit);
|
|
297
295
|
return {
|
|
296
|
+
kind: "akuma-name-catalogue",
|
|
298
297
|
...(rows.length === 0 ? {} : { rows }),
|
|
299
298
|
...(limit !== undefined && visible.length > limit ? { more: true } : {}),
|
|
300
299
|
};
|
|
@@ -309,17 +308,17 @@ function optionalProviderText(value, name, field) {
|
|
|
309
308
|
if (selected === undefined)
|
|
310
309
|
return undefined;
|
|
311
310
|
if (typeof selected !== "string" || selected.trim().length === 0) {
|
|
312
|
-
throw new
|
|
311
|
+
throw new KeiyakuError("invalid-input", `provider ${name} ${field} must be a nonblank string`);
|
|
313
312
|
}
|
|
314
313
|
return selected;
|
|
315
314
|
}
|
|
316
315
|
function configuredProvider(name, selected) {
|
|
317
316
|
const value = record(selected);
|
|
318
317
|
if (value === null)
|
|
319
|
-
throw new
|
|
318
|
+
throw new KeiyakuError("invalid-input", `provider ${name} must be an object`);
|
|
320
319
|
const unknown = Object.keys(value).find((key) => !["kind", "description", "executable", "config", "env"].includes(key));
|
|
321
320
|
if (unknown !== undefined)
|
|
322
|
-
throw new
|
|
321
|
+
throw new KeiyakuError("invalid-input", `provider ${name} has unknown field ${unknown}`);
|
|
323
322
|
optionalProviderText(value, name, "description");
|
|
324
323
|
return decodeProviderRecipe({
|
|
325
324
|
name,
|
|
@@ -348,7 +347,7 @@ const BUILTIN_EXECUTIONS = {
|
|
|
348
347
|
function providerExecution(settings, name) {
|
|
349
348
|
const view = settings.namespace("providers");
|
|
350
349
|
if (view.kind === "failed")
|
|
351
|
-
throw new
|
|
350
|
+
throw new KeiyakuError("invalid-input", view.failures
|
|
352
351
|
.map((failure) => {
|
|
353
352
|
const scope = settings.scopes[failure.scope];
|
|
354
353
|
return `${failure.scope}: ${failure.diagnostic ?? (scope.kind === "failed" ? scope.diagnostic : "providers unavailable")}`;
|
|
@@ -360,7 +359,7 @@ function providerExecution(settings, name) {
|
|
|
360
359
|
const builtin = BUILTIN_EXECUTIONS[name];
|
|
361
360
|
if (builtin !== undefined)
|
|
362
361
|
return decodeProviderRecipe({ name, ...builtin });
|
|
363
|
-
throw new
|
|
362
|
+
throw new KeiyakuError("invalid-input", `unknown provider ${name}`);
|
|
364
363
|
}
|
|
365
364
|
/** Resolve one akumaName and decode its provider execution, leaving option admission to the caller. */
|
|
366
365
|
export async function loadPreparedArchetype(input) {
|
|
@@ -371,8 +370,8 @@ export async function loadPreparedArchetype(input) {
|
|
|
371
370
|
provider = providerExecution(input.settings, definition.provider);
|
|
372
371
|
}
|
|
373
372
|
catch (error) {
|
|
374
|
-
if (error
|
|
375
|
-
throw new
|
|
373
|
+
if (errorCategory(error) === "invalid-input")
|
|
374
|
+
throw new AkumaNameError(definition.name, [definition.path], `uses ${error instanceof Error ? error.message : String(error)}`);
|
|
376
375
|
throw error;
|
|
377
376
|
}
|
|
378
377
|
return Object.freeze({ ...definition, provider });
|
package/build/src/akuma/body.js
CHANGED
|
@@ -128,6 +128,15 @@ export async function recordPluginDiagnostic(paths, occurrence, error) {
|
|
|
128
128
|
/* plugin diagnostic loss never changes Heart truth */
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
+
/** The plugin host bag for one Body occurrence; diagnostics are appended to its log. */
|
|
132
|
+
function pluginHost(launch, world, occurrence) {
|
|
133
|
+
return {
|
|
134
|
+
world,
|
|
135
|
+
reportDiagnostic: (message) => {
|
|
136
|
+
void recordPluginDiagnostic(launch.paths, occurrence, message);
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
131
140
|
async function prepareBodyExecution(launch, leash, runtime, adapter) {
|
|
132
141
|
runtime.signal?.throwIfAborted();
|
|
133
142
|
const birth = await bornSoul(launch, leash, runtime.now());
|
|
@@ -178,12 +187,7 @@ async function prepareBodyStart(paths, leash) {
|
|
|
178
187
|
return true;
|
|
179
188
|
}
|
|
180
189
|
async function emitBodyBirth(launch, soul, world, bodySequence) {
|
|
181
|
-
await emitPluginSignal({
|
|
182
|
-
world,
|
|
183
|
-
reportDiagnostic: (message) => {
|
|
184
|
-
void recordPluginDiagnostic(launch.paths, "birth", message);
|
|
185
|
-
},
|
|
186
|
-
}, {
|
|
190
|
+
await emitPluginSignal(pluginHost(launch, world, "birth"), {
|
|
187
191
|
kind: "akuma.born",
|
|
188
192
|
akumaId: soul.id,
|
|
189
193
|
bodySequence,
|
|
@@ -193,16 +197,13 @@ async function emitBodyBirth(launch, soul, world, bodySequence) {
|
|
|
193
197
|
});
|
|
194
198
|
}
|
|
195
199
|
function turnStartedEmitter(launch, soul, world) {
|
|
196
|
-
const reportDiagnostic = (message) => {
|
|
197
|
-
void recordPluginDiagnostic(launch.paths, "turn started", message);
|
|
198
|
-
};
|
|
199
200
|
return {
|
|
200
201
|
async emit(turnSequence) {
|
|
201
202
|
try {
|
|
202
203
|
const turn = await readTurn(launch.paths, turnSequence);
|
|
203
204
|
if (turn === null)
|
|
204
205
|
throw new Error(`Committed Turn ${turnSequence} is missing from Heart`);
|
|
205
|
-
await emitPluginSignal(
|
|
206
|
+
await emitPluginSignal(pluginHost(launch, world, "turn started"), {
|
|
206
207
|
kind: "akuma.turn-started",
|
|
207
208
|
akumaId: soul.id,
|
|
208
209
|
turnSequence,
|
|
@@ -216,9 +217,6 @@ function turnStartedEmitter(launch, soul, world) {
|
|
|
216
217
|
};
|
|
217
218
|
}
|
|
218
219
|
function turnOutcomeEmitter(launch, soul, world) {
|
|
219
|
-
const reportDiagnostic = (message) => {
|
|
220
|
-
void recordPluginDiagnostic(launch.paths, "turn outcome", message);
|
|
221
|
-
};
|
|
222
220
|
return {
|
|
223
221
|
async emit(turnSequence) {
|
|
224
222
|
try {
|
|
@@ -227,11 +225,12 @@ function turnOutcomeEmitter(launch, soul, world) {
|
|
|
227
225
|
throw new Error(`Committed Turn ${turnSequence} outcome is missing from Heart`);
|
|
228
226
|
const outcome = turn.end.outcome;
|
|
229
227
|
const participants = await readTurnParticipants(launch.paths, turnSequence);
|
|
230
|
-
await emitPluginSignal(
|
|
228
|
+
await emitPluginSignal(pluginHost(launch, world, "turn outcome"), {
|
|
231
229
|
kind: "akuma.turn-outcome",
|
|
232
230
|
akumaId: soul.id,
|
|
233
231
|
bodySequence: turn.bodySequence,
|
|
234
232
|
turnSequence,
|
|
233
|
+
at: turn.end.completedAt,
|
|
235
234
|
...(turn.initiator === undefined ? {} : { initiator: turn.initiator }),
|
|
236
235
|
...(participants.length === 0 ? {} : { participants }),
|
|
237
236
|
outcome: outcome.kind === "answered"
|
|
@@ -249,19 +248,19 @@ function turnOutcomeEmitter(launch, soul, world) {
|
|
|
249
248
|
};
|
|
250
249
|
}
|
|
251
250
|
function bodyEndEmitter(launch, soul, world) {
|
|
252
|
-
const reportDiagnostic = (message) => {
|
|
253
|
-
void recordPluginDiagnostic(launch.paths, "body end", message);
|
|
254
|
-
};
|
|
255
251
|
return async (bodySequence, end, diagnostic) => {
|
|
256
252
|
try {
|
|
257
253
|
const latestTurn = await readLatestTurnForBody(launch.paths, bodySequence);
|
|
254
|
+
const latestBody = (await readHeart(launch.paths)).latestBody;
|
|
255
|
+
const at = latestBody?.sequence === bodySequence ? (latestBody.hung?.at ?? latestBody.endedAt) : undefined;
|
|
258
256
|
const initiator = latestTurn?.initiator;
|
|
259
257
|
const participants = latestTurn === null ? [] : await readTurnParticipants(launch.paths, latestTurn.sequence);
|
|
260
|
-
await emitPluginSignal(
|
|
258
|
+
await emitPluginSignal(pluginHost(launch, world, "body end"), {
|
|
261
259
|
kind: "akuma.body-ended",
|
|
262
260
|
akumaId: soul.id,
|
|
263
261
|
bodySequence,
|
|
264
262
|
end,
|
|
263
|
+
...(at === undefined ? {} : { at }),
|
|
265
264
|
...(initiator === undefined ? {} : { initiator }),
|
|
266
265
|
...(participants.length === 0 ? {} : { participants }),
|
|
267
266
|
...(diagnostic === undefined ? {} : { diagnostic }),
|
|
@@ -505,34 +504,35 @@ async function settledWake(paths, tellId, after) {
|
|
|
505
504
|
}
|
|
506
505
|
return null;
|
|
507
506
|
}
|
|
508
|
-
async function awaitWake(paths, input) {
|
|
509
|
-
const { tellId, after, child, schedule, signal } = input;
|
|
510
|
-
try {
|
|
511
|
-
const result = await observeBodyLaunch(child, async () => await settledWake(paths, tellId, after), schedule, signal);
|
|
512
|
-
if (result.kind === "completed")
|
|
513
|
-
return launchEndWake(result.end);
|
|
514
|
-
child.release();
|
|
515
|
-
return result.value;
|
|
516
|
-
}
|
|
517
|
-
catch (error) {
|
|
518
|
-
child.release();
|
|
519
|
-
throw error;
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
507
|
async function wakePendingTells(paths, tellId, runtime, signal) {
|
|
523
508
|
try {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
509
|
+
for (;;) {
|
|
510
|
+
signal?.throwIfAborted();
|
|
511
|
+
const before = await readHeart(paths);
|
|
512
|
+
if (tellId === undefined && before.pending.length === 0)
|
|
513
|
+
return null;
|
|
514
|
+
const child = await runtime.spawn(paths);
|
|
515
|
+
try {
|
|
516
|
+
const result = await observeBodyLaunch(child, async () => await settledWake(paths, tellId, before.latestBody?.sequence ?? 0), runtime.schedule ?? abortableDelay, signal);
|
|
517
|
+
if (result.kind === "observed") {
|
|
518
|
+
child.release();
|
|
519
|
+
return result.value;
|
|
520
|
+
}
|
|
521
|
+
const wake = launchEndWake(result.end);
|
|
522
|
+
if (wake.kind !== "held")
|
|
523
|
+
return wake;
|
|
524
|
+
const heart = await readHeart(paths);
|
|
525
|
+
if (tellId !== undefined && !heart.pending.some((tell) => tell.id === tellId))
|
|
526
|
+
return { kind: "told" };
|
|
527
|
+
if (heart.pause !== null ||
|
|
528
|
+
(heart.latestBody !== null && heart.latestBody.end === undefined && (await probeLeash(paths)) === "held"))
|
|
529
|
+
return wake;
|
|
530
|
+
}
|
|
531
|
+
catch (error) {
|
|
532
|
+
child.release();
|
|
533
|
+
throw error;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
536
|
}
|
|
537
537
|
catch (error) {
|
|
538
538
|
if (signal?.aborted)
|
|
@@ -2,10 +2,10 @@ import { z } from "zod";
|
|
|
2
2
|
import type { WorldRoot } from "../world.js";
|
|
3
3
|
import { type TellFact } from "./heart/index.js";
|
|
4
4
|
import { type AkumaId } from "./identity.js";
|
|
5
|
+
export declare const BIRTH_TIMEOUT_MS = 30000;
|
|
5
6
|
export type CallInitialTell = Readonly<{
|
|
6
7
|
tellId: string;
|
|
7
8
|
body: string;
|
|
8
|
-
schemaJson?: string;
|
|
9
9
|
initiator?: string;
|
|
10
10
|
}>;
|
|
11
11
|
export type InitialTellAdmissionInput = Readonly<{
|
|
@@ -34,8 +34,8 @@ export declare const tellResultSchema: z.ZodReadonly<z.ZodObject<{
|
|
|
34
34
|
}, z.core.$strict>>;
|
|
35
35
|
row: z.ZodReadonly<z.ZodObject<{
|
|
36
36
|
at: z.ZodString;
|
|
37
|
-
sequence: z.ZodNumber;
|
|
38
37
|
text: z.ZodString;
|
|
38
|
+
sequence: z.ZodNumber;
|
|
39
39
|
}, z.core.$strict>>;
|
|
40
40
|
wake: z.ZodUnion<readonly [z.ZodReadonly<z.ZodObject<{
|
|
41
41
|
kind: z.ZodLiteral<"told">;
|
|
@@ -70,6 +70,8 @@ export declare const tellResultSchema: z.ZodReadonly<z.ZodObject<{
|
|
|
70
70
|
export type TellWake = z.output<typeof tellWakeSchema>;
|
|
71
71
|
/** The progress receipt carries only the Tell coordinates progress needs; Heart keeps the native row. */
|
|
72
72
|
export type TellResult = z.output<typeof tellResultSchema>;
|
|
73
|
+
/** Freeze known admission before waiting for wake; no later read can replace it. */
|
|
74
|
+
export declare function pendingTellReceipt(tell: TellFact): TellResult;
|
|
73
75
|
export type CallInitialTellAdmission = Readonly<{
|
|
74
76
|
kind: "admitted";
|
|
75
77
|
tell: TellFact;
|