@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
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { World } from "../world.js";
|
|
2
2
|
import { requestBodyCommand } from "../akuma/request-rendezvous.js";
|
|
3
3
|
import { eraseRequestCommand, } from "../akuma/request-wire.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { taskBatchResultSchema, taskCompositionResultSchema, taskMutationIdSchema, taskMutationResultSchema, taskUpdateResultSchema, isTaskMutationExecutionResult, } from "./mutation-result.js";
|
|
4
|
+
import { taskIdsSchema, taskNamespaceSchema } from "./identity.js";
|
|
5
|
+
import { taskNonblankTextSchema, taskStateSchema, taskPrioritySchema } from "./document.js";
|
|
6
|
+
import { taskBatchResultSchema, taskCompositionResultSchema, taskMutationIdSchema, taskMutationResultSchema, taskUpdateResultSchema, } from "./mutation-result.js";
|
|
8
7
|
import { z } from "zod";
|
|
9
8
|
export const TASK_MUTATION_ACTIONS = Object.freeze([
|
|
10
9
|
"task.add",
|
|
@@ -18,20 +17,12 @@ export const TASK_MUTATION_ACTIONS = Object.freeze([
|
|
|
18
17
|
"task.stop",
|
|
19
18
|
"task.update",
|
|
20
19
|
]);
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const taskIdsBaseSchema = z.array(taskMutationIdSchema).superRefine((ids, context) => {
|
|
24
|
-
if (new Set(ids).size !== ids.length)
|
|
25
|
-
context.addIssue({ code: "custom", message: "TaskIds must be unique" });
|
|
26
|
-
});
|
|
27
|
-
const taskIdsSchema = taskIdsBaseSchema.readonly();
|
|
28
|
-
const nonemptyTaskIdsSchema = taskIdsBaseSchema.min(1).readonly();
|
|
29
|
-
const taskStateSchema = z.enum(["open", "in_progress", "on_hold", "done", "drop"]);
|
|
30
|
-
const taskPrioritySchema = z.union([z.literal(0), z.literal(1), z.literal(2), z.literal(3)]);
|
|
20
|
+
const taskMutationActionSchema = z.enum(TASK_MUTATION_ACTIONS);
|
|
21
|
+
const nonemptyTaskIdsSchema = taskIdsSchema.unwrap().min(1).readonly();
|
|
31
22
|
const addInputSchema = z
|
|
32
23
|
.object({
|
|
33
|
-
title:
|
|
34
|
-
namespace:
|
|
24
|
+
title: taskNonblankTextSchema,
|
|
25
|
+
namespace: taskNamespaceSchema,
|
|
35
26
|
body: z.string().optional(),
|
|
36
27
|
note: z.string().optional(),
|
|
37
28
|
state: taskStateSchema.optional(),
|
|
@@ -44,7 +35,7 @@ const addInputSchema = z
|
|
|
44
35
|
.strict();
|
|
45
36
|
const updateInputSchema = z
|
|
46
37
|
.object({
|
|
47
|
-
title:
|
|
38
|
+
title: taskNonblankTextSchema.optional(),
|
|
48
39
|
body: z.string().optional(),
|
|
49
40
|
appendBody: z.string().optional(),
|
|
50
41
|
note: z.string().optional(),
|
|
@@ -72,11 +63,11 @@ const addRequestSchema = z
|
|
|
72
63
|
.strict()
|
|
73
64
|
.transform(({ input }) => ({ action: "task.add", input }));
|
|
74
65
|
const addDocumentRequestSchema = z
|
|
75
|
-
.object({ input: z.object({ markdown: z.string(), namespace:
|
|
66
|
+
.object({ input: z.object({ markdown: z.string(), namespace: taskNamespaceSchema }).strict() })
|
|
76
67
|
.strict()
|
|
77
68
|
.transform(({ input }) => ({ action: "task.addDocument", input }));
|
|
78
69
|
const composeRequestSchema = z
|
|
79
|
-
.object({ markdown: z.string(), namespace:
|
|
70
|
+
.object({ markdown: z.string(), namespace: taskNamespaceSchema })
|
|
80
71
|
.strict()
|
|
81
72
|
.transform((request) => ({ action: "task.compose", ...request }));
|
|
82
73
|
const updateRequestSchema = z
|
|
@@ -93,10 +84,6 @@ const singleOrBatchRequestSchema = (action) => z.union([
|
|
|
93
84
|
.strict()
|
|
94
85
|
.transform(({ ids }) => ({ action, ids })),
|
|
95
86
|
]);
|
|
96
|
-
const singleRequestSchema = (action) => z
|
|
97
|
-
.object({ id: taskMutationIdSchema })
|
|
98
|
-
.strict()
|
|
99
|
-
.transform((request) => ({ action, ...request }));
|
|
100
87
|
const terminalRequestSchema = (action) => z.union([
|
|
101
88
|
z
|
|
102
89
|
.object({ id: taskMutationIdSchema, note: z.string().optional() })
|
|
@@ -114,30 +101,21 @@ const taskRequestSchemas = {
|
|
|
114
101
|
"task.done": terminalRequestSchema("task.done"),
|
|
115
102
|
"task.drop": terminalRequestSchema("task.drop"),
|
|
116
103
|
"task.hold": singleOrBatchRequestSchema("task.hold"),
|
|
117
|
-
"task.resume":
|
|
104
|
+
"task.resume": singleOrBatchRequestSchema("task.resume"),
|
|
118
105
|
"task.start": singleOrBatchRequestSchema("task.start"),
|
|
119
|
-
"task.stop":
|
|
106
|
+
"task.stop": singleOrBatchRequestSchema("task.stop"),
|
|
120
107
|
"task.update": updateRequestSchema,
|
|
121
108
|
};
|
|
122
109
|
const worldPathSchema = z.string().min(1);
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
"task.done": z.object({ world: worldPathSchema, request: taskRequestSchemas["task.done"] }).strict(),
|
|
128
|
-
"task.drop": z.object({ world: worldPathSchema, request: taskRequestSchemas["task.drop"] }).strict(),
|
|
129
|
-
"task.hold": z.object({ world: worldPathSchema, request: taskRequestSchemas["task.hold"] }).strict(),
|
|
130
|
-
"task.resume": z.object({ world: worldPathSchema, request: taskRequestSchemas["task.resume"] }).strict(),
|
|
131
|
-
"task.start": z.object({ world: worldPathSchema, request: taskRequestSchemas["task.start"] }).strict(),
|
|
132
|
-
"task.stop": z.object({ world: worldPathSchema, request: taskRequestSchemas["task.stop"] }).strict(),
|
|
133
|
-
"task.update": z.object({ world: worldPathSchema, request: taskRequestSchemas["task.update"] }).strict(),
|
|
134
|
-
};
|
|
135
|
-
export const taskMutationServiceSchema = z.object({ action: z.enum(TASK_MUTATION_ACTIONS) }).strict();
|
|
110
|
+
const taskBodyRequestSchema = z
|
|
111
|
+
.object({ world: worldPathSchema, request: z.union(Object.values(taskRequestSchemas)) })
|
|
112
|
+
.strict();
|
|
113
|
+
export const taskMutationServiceSchema = z.object({ action: taskMutationActionSchema }).strict();
|
|
136
114
|
export const forwardedTaskReferenceSchema = z
|
|
137
|
-
.object({ kind: z.literal("served-reference"), action:
|
|
115
|
+
.object({ kind: z.literal("served-reference"), action: taskMutationActionSchema })
|
|
138
116
|
.strict();
|
|
139
117
|
function decodeTaskBodyRequest(action, value) {
|
|
140
|
-
const parsed =
|
|
118
|
+
const parsed = taskBodyRequestSchema.extend({ request: taskRequestSchemas[action] }).safeParse(value);
|
|
141
119
|
return parsed.success ? parsed.data : null;
|
|
142
120
|
}
|
|
143
121
|
function decodeTaskService(action, value) {
|
|
@@ -153,7 +131,7 @@ function decodeTaskReference(action, value) {
|
|
|
153
131
|
return parsed.data;
|
|
154
132
|
}
|
|
155
133
|
/** Task owns forwarded mutation payload, live result, and durable service evidence. */
|
|
156
|
-
export function taskMutationRequestProtocol(action) {
|
|
134
|
+
export function taskMutationRequestProtocol(action, batch) {
|
|
157
135
|
return {
|
|
158
136
|
action,
|
|
159
137
|
encodeRequest: (input) => {
|
|
@@ -163,10 +141,19 @@ export function taskMutationRequestProtocol(action) {
|
|
|
163
141
|
decodeRequest: (value) => decodeTaskBodyRequest(action, value),
|
|
164
142
|
encodeResult: (result) => result,
|
|
165
143
|
decodeResult: (result) => {
|
|
166
|
-
|
|
144
|
+
const schema = action === "task.compose"
|
|
145
|
+
? taskCompositionResultSchema
|
|
146
|
+
: action === "task.update"
|
|
147
|
+
? taskUpdateResultSchema
|
|
148
|
+
: batch === undefined
|
|
149
|
+
? z.union([taskMutationResultSchema, taskBatchResultSchema])
|
|
150
|
+
: batch
|
|
151
|
+
? taskBatchResultSchema
|
|
152
|
+
: taskMutationResultSchema;
|
|
153
|
+
const parsed = schema.safeParse(result);
|
|
154
|
+
if (!parsed.success)
|
|
167
155
|
throw new Error(`transport integrity: Task ${action} returned an invalid live result`);
|
|
168
|
-
|
|
169
|
-
return result;
|
|
156
|
+
return parsed.data;
|
|
170
157
|
},
|
|
171
158
|
decodeReference: (reference) => decodeTaskReference(action, reference),
|
|
172
159
|
isPermitted: (allowed) => allowed.includes(action),
|
|
@@ -176,49 +163,86 @@ export function taskMutationRequestCommand(action, port) {
|
|
|
176
163
|
return {
|
|
177
164
|
completion: "service",
|
|
178
165
|
protocol: taskMutationRequestProtocol(action),
|
|
179
|
-
encodeService: (service) =>
|
|
166
|
+
encodeService: (service) => service,
|
|
180
167
|
decodeService: (service) => decodeTaskService(action, service),
|
|
181
|
-
projectService: (service) =>
|
|
168
|
+
projectService: (service) => ({ kind: "served-reference", action: service.action }),
|
|
182
169
|
execute: async (request, facts) => {
|
|
183
170
|
const world = await World.prove(request.world);
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
171
|
+
const action = request.request.action;
|
|
172
|
+
let result;
|
|
173
|
+
switch (action) {
|
|
174
|
+
case "task.add":
|
|
175
|
+
result = await port.add({
|
|
176
|
+
world,
|
|
177
|
+
options: addTaskOptions(request.request.input, facts.requester, facts.signal),
|
|
178
|
+
});
|
|
179
|
+
break;
|
|
180
|
+
case "task.addDocument":
|
|
181
|
+
result = await port.addDocument({
|
|
182
|
+
world,
|
|
183
|
+
document: { ...request.request.input, actor: facts.requester, signal: facts.signal },
|
|
184
|
+
});
|
|
185
|
+
break;
|
|
186
|
+
case "task.compose":
|
|
187
|
+
result = await port.compose({
|
|
188
|
+
world,
|
|
189
|
+
markdown: request.request.markdown,
|
|
190
|
+
defaultNamespace: request.request.namespace,
|
|
191
|
+
actor: facts.requester,
|
|
192
|
+
signal: facts.signal,
|
|
193
|
+
});
|
|
194
|
+
break;
|
|
195
|
+
case "task.update":
|
|
196
|
+
result = await port.update({
|
|
197
|
+
world,
|
|
198
|
+
id: request.request.id,
|
|
199
|
+
options: updateTaskOptions(request.request.input, facts.signal),
|
|
200
|
+
});
|
|
201
|
+
break;
|
|
202
|
+
case "task.start":
|
|
203
|
+
case "task.stop":
|
|
204
|
+
case "task.hold":
|
|
205
|
+
case "task.resume":
|
|
206
|
+
case "task.done":
|
|
207
|
+
case "task.drop": {
|
|
208
|
+
const verb = action.slice("task.".length);
|
|
209
|
+
const note = "note" in request.request ? request.request.note : undefined;
|
|
210
|
+
result =
|
|
211
|
+
"ids" in request.request
|
|
212
|
+
? await port.batch({
|
|
213
|
+
world,
|
|
214
|
+
verb,
|
|
215
|
+
ids: request.request.ids,
|
|
216
|
+
...(note === undefined ? {} : { note }),
|
|
217
|
+
signal: facts.signal,
|
|
218
|
+
})
|
|
219
|
+
: await port.lifecycle({
|
|
220
|
+
world,
|
|
221
|
+
verb,
|
|
222
|
+
id: request.request.id,
|
|
223
|
+
...(note === undefined ? {} : { note }),
|
|
224
|
+
signal: facts.signal,
|
|
225
|
+
});
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return { kind: "served", result, service: { action } };
|
|
193
230
|
},
|
|
194
231
|
};
|
|
195
232
|
}
|
|
196
233
|
export function taskMutationRequestCommands(port) {
|
|
197
234
|
return Object.fromEntries(TASK_MUTATION_ACTIONS.map((action) => [action, eraseRequestCommand(taskMutationRequestCommand(action, port))]));
|
|
198
235
|
}
|
|
199
|
-
function taskResultForRequest(request, value) {
|
|
200
|
-
const schema = request.action === "task.compose"
|
|
201
|
-
? taskCompositionResultSchema
|
|
202
|
-
: request.action === "task.update"
|
|
203
|
-
? taskUpdateResultSchema
|
|
204
|
-
: "ids" in request
|
|
205
|
-
? taskBatchResultSchema
|
|
206
|
-
: taskMutationResultSchema;
|
|
207
|
-
return schema.safeParse(value).success;
|
|
208
|
-
}
|
|
209
236
|
export async function requestForwardedTask(input) {
|
|
210
237
|
const response = await requestBodyCommand({
|
|
211
238
|
directory: input.directory,
|
|
212
239
|
...(input.id === undefined ? {} : { id: input.id }),
|
|
213
|
-
command: taskMutationRequestProtocol(input.request.action),
|
|
240
|
+
command: taskMutationRequestProtocol(input.request.action, "ids" in input.request),
|
|
214
241
|
value: { world: input.world, request: input.request },
|
|
215
242
|
...(input.signal === undefined ? {} : { signal: input.signal }),
|
|
216
243
|
});
|
|
217
244
|
if (response.kind === "reference")
|
|
218
245
|
return response.reference;
|
|
219
|
-
if (!taskResultForRequest(input.request, response.result)) {
|
|
220
|
-
throw new Error(`transport integrity: request Task ${input.request.action} returned an invalid live result`);
|
|
221
|
-
}
|
|
222
246
|
return response.result;
|
|
223
247
|
}
|
|
224
248
|
export function decodeTaskMutationRequest(action, value) {
|
|
@@ -264,44 +288,3 @@ function updateTaskOptions(input, signal) {
|
|
|
264
288
|
...(signal === undefined ? {} : { signal }),
|
|
265
289
|
};
|
|
266
290
|
}
|
|
267
|
-
export async function executeTaskMutation(input) {
|
|
268
|
-
const { world, request, signal } = input;
|
|
269
|
-
const withSignal = signal === undefined ? {} : { signal };
|
|
270
|
-
switch (request.action) {
|
|
271
|
-
case "task.add":
|
|
272
|
-
return await addTask(world, addTaskOptions(request.input, input.requester, signal));
|
|
273
|
-
case "task.addDocument":
|
|
274
|
-
return await addTaskDocument(world, { ...request.input, actor: input.requester, ...withSignal });
|
|
275
|
-
case "task.compose":
|
|
276
|
-
return await composeTasks({
|
|
277
|
-
world,
|
|
278
|
-
markdown: request.markdown,
|
|
279
|
-
defaultNamespace: request.namespace,
|
|
280
|
-
actor: input.requester,
|
|
281
|
-
planOnly: false,
|
|
282
|
-
...withSignal,
|
|
283
|
-
});
|
|
284
|
-
case "task.update":
|
|
285
|
-
return await updateTask(world, request.id, updateTaskOptions(request.input, signal));
|
|
286
|
-
case "task.start":
|
|
287
|
-
if ("ids" in request)
|
|
288
|
-
return await batchTasks(world, "start", request.ids, signal);
|
|
289
|
-
return await lifecycleTask(world, request.id, "start", signal);
|
|
290
|
-
case "task.stop":
|
|
291
|
-
return await lifecycleTask(world, request.id, "stop", signal);
|
|
292
|
-
case "task.resume":
|
|
293
|
-
return await lifecycleTask(world, request.id, "resume", signal);
|
|
294
|
-
case "task.hold":
|
|
295
|
-
if ("ids" in request)
|
|
296
|
-
return await batchTasks(world, "hold", request.ids, signal);
|
|
297
|
-
return await lifecycleTask(world, request.id, "hold", signal);
|
|
298
|
-
case "task.done":
|
|
299
|
-
if ("ids" in request)
|
|
300
|
-
return await batchTasks(world, "done", request.ids, signal, request.note);
|
|
301
|
-
return await lifecycleTask(world, request.id, "done", signal, request.note);
|
|
302
|
-
case "task.drop":
|
|
303
|
-
if ("ids" in request)
|
|
304
|
-
return await batchTasks(world, "drop", request.ids, signal, request.note);
|
|
305
|
-
return await lifecycleTask(world, request.id, "drop", signal, request.note);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
@@ -1,41 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TaskPriority, TaskState } from "./document.js";
|
|
2
2
|
import type { TaskId } from "./identity.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}>;
|
|
6
|
-
export type TaskCleanupFailure = Readonly<{
|
|
7
|
-
kind: "lock-release-failed";
|
|
8
|
-
diagnostics: readonly string[];
|
|
9
|
-
}>;
|
|
10
|
-
export type TaskCompositionDiagnostic = Readonly<{
|
|
11
|
-
line: number;
|
|
12
|
-
reason: string;
|
|
13
|
-
token: string;
|
|
14
|
-
}>;
|
|
15
|
-
export type TaskRefusal = Readonly<{
|
|
16
|
-
kind: "task-missing";
|
|
17
|
-
taskId: TaskId;
|
|
18
|
-
}> | Readonly<{
|
|
19
|
-
kind: "invalid-lifecycle-transition";
|
|
20
|
-
taskId: TaskId;
|
|
21
|
-
state: TaskState;
|
|
22
|
-
verb: TaskLifecycleVerb;
|
|
23
|
-
}> | Readonly<{
|
|
24
|
-
kind: "invalid-graph";
|
|
25
|
-
diagnostic: string;
|
|
26
|
-
}> | Readonly<{
|
|
27
|
-
kind: "invalid-namespace-context";
|
|
28
|
-
path: string;
|
|
29
|
-
}> | Readonly<{
|
|
30
|
-
kind: "relation-owned-by-other";
|
|
31
|
-
taskId: TaskId;
|
|
32
|
-
related: TaskId;
|
|
33
|
-
declaringTask: TaskId;
|
|
34
|
-
}> | Readonly<{
|
|
35
|
-
kind: "invalid-composition";
|
|
36
|
-
diagnostics: readonly TaskCompositionDiagnostic[];
|
|
37
|
-
}>;
|
|
38
|
-
export type TaskRetry = "busy" | "concurrent-modification";
|
|
3
|
+
import type { TaskCleanupFailure, TaskRefusal, TaskRetry, TaskView } from "./mutation-result.js";
|
|
4
|
+
export type { TaskView, TaskCleanupFailure, TaskCompositionDiagnostic, TaskRefusal, TaskRetry, TaskMutationResult, TaskUpdateResult, TaskBatchResult, } from "./mutation-result.js";
|
|
39
5
|
export type TaskOutcome<A> = Readonly<{
|
|
40
6
|
kind: "accepted";
|
|
41
7
|
value: A;
|
|
@@ -47,18 +13,9 @@ export type TaskOutcome<A> = Readonly<{
|
|
|
47
13
|
kind: "retry";
|
|
48
14
|
reason: TaskRetry;
|
|
49
15
|
}>;
|
|
50
|
-
export type
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
documentDiff: string;
|
|
54
|
-
}>>;
|
|
55
|
-
export type TaskLifecycleVerb = "start" | "stop" | "hold" | "resume" | "done" | "drop";
|
|
56
|
-
export type TaskBatchResult = Readonly<{
|
|
57
|
-
items: readonly Readonly<{
|
|
58
|
-
id: TaskId;
|
|
59
|
-
outcome: TaskMutationResult;
|
|
60
|
-
}>[];
|
|
61
|
-
}>;
|
|
16
|
+
export type TaskLifecycleVerb = Extract<TaskRefusal, {
|
|
17
|
+
kind: "invalid-lifecycle-transition";
|
|
18
|
+
}>["verb"];
|
|
62
19
|
export type SettledTaskAction = "done";
|
|
63
20
|
export type SettledTaskResult = Readonly<{
|
|
64
21
|
kind: "changed";
|
|
@@ -7,7 +7,8 @@ export type { AddTaskDocumentInput, AddTaskInput, TaskCleanupFailure, SettledTas
|
|
|
7
7
|
import type { AddTaskDocumentInput, AddTaskInput, TaskMutationResult, TaskOutcome, TaskUpdateResult, TaskView, UpdateTaskInput } from "./operation-types.js";
|
|
8
8
|
export declare function nukeTask(world: WorldRoot, options?: Readonly<{
|
|
9
9
|
timeoutMs?: number;
|
|
10
|
-
|
|
10
|
+
onRemoved?(count: number): void;
|
|
11
|
+
}>): Promise<number>;
|
|
11
12
|
export type { TaskState } from "./document.js";
|
|
12
13
|
export declare function addTask(world: WorldRoot, input: AddTaskInput): Promise<TaskMutationResult>;
|
|
13
14
|
export declare function addTaskDocument(world: WorldRoot, input: AddTaskDocumentInput): Promise<TaskMutationResult>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { SqliteTransactionLockError } from "../coordination/sqlite-transaction-lock.js";
|
|
1
2
|
import { documentDiff } from "../markdown/diff.js";
|
|
2
|
-
import { createTaskRelations, projectOwnedDetailFacts, projectTaskBoardObservation, relationProblem, projectBlocked, projectRows, } from "./board.js";
|
|
3
|
+
import { createTaskRelations, projectOwnedDetailFacts, projectTaskBoardObservation, relationProblem, projectBlocked, projectRows, occupiedLocalIds, } from "./board.js";
|
|
3
4
|
import { parseTaskCreationDocument, serializeTaskDocument, } from "./document.js";
|
|
4
|
-
import { allocateLocalId, deriveLocalStem, formatTaskId
|
|
5
|
+
import { allocateLocalId, deriveLocalStem, formatTaskId } from "./identity.js";
|
|
5
6
|
import { nukeTaskAuthority, readBoard, readTaskDocument, replaceAuthority, withTaskLocks } from "./store.js";
|
|
6
7
|
import { projectBoundedList } from "../bounded-list.js";
|
|
7
8
|
import { taskRowViewLimit } from "./input.js";
|
|
@@ -9,8 +10,10 @@ import { projectQuery, projectQueryRows, queryUnderTargets, underExpression, } f
|
|
|
9
10
|
import { advanceTaskTimestamp, taskView } from "./view.js";
|
|
10
11
|
export { advanceTaskTimestamp, taskView } from "./view.js";
|
|
11
12
|
export async function nukeTask(world, options) {
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
const result = await nukeTaskAuthority(world, options);
|
|
14
|
+
if (result === "busy")
|
|
15
|
+
throw new SqliteTransactionLockError("Task reset lock contention", "timeout");
|
|
16
|
+
return result;
|
|
14
17
|
}
|
|
15
18
|
function refused(refusal) {
|
|
16
19
|
return { kind: "refused", refusal };
|
|
@@ -18,18 +21,12 @@ function refused(refusal) {
|
|
|
18
21
|
function retry(reason) {
|
|
19
22
|
return { kind: "retry", reason };
|
|
20
23
|
}
|
|
21
|
-
function occupied(board, namespace) {
|
|
22
|
-
return new Set([...board.tasks.values()].flatMap((task) => {
|
|
23
|
-
const coordinate = parseTaskId(task.id);
|
|
24
|
-
return sameNamespace(coordinate.namespace, namespace) ? [coordinate.localId] : [];
|
|
25
|
-
}));
|
|
26
|
-
}
|
|
27
24
|
function currentTimestamp() {
|
|
28
25
|
return new Date().toISOString();
|
|
29
26
|
}
|
|
30
27
|
/** Internal Task timestamp rule shared by ordinary mutations and compose. */
|
|
31
28
|
function addDocument(base, namespace, board, at, actor) {
|
|
32
|
-
const localId = allocateLocalId(deriveLocalStem(base.title),
|
|
29
|
+
const localId = allocateLocalId(deriveLocalStem(base.title), occupiedLocalIds(board, namespace));
|
|
33
30
|
return {
|
|
34
31
|
...base,
|
|
35
32
|
id: formatTaskId({ namespace, localId }),
|
|
@@ -123,6 +120,28 @@ function updateDocument(board, current, input) {
|
|
|
123
120
|
relates: listChange(current.relates, input.relates, input.addRelates, input.dropRelates),
|
|
124
121
|
};
|
|
125
122
|
}
|
|
123
|
+
function updateFieldChanges(current, next, input) {
|
|
124
|
+
const changes = [];
|
|
125
|
+
for (const field of ["title", "body", "note", "priority", "needs", "parent", "supersedes", "relates"]) {
|
|
126
|
+
const before = current[field];
|
|
127
|
+
const after = next[field];
|
|
128
|
+
if (Array.isArray(before) && Array.isArray(after) ? before.join("\0") === after.join("\0") : before === after)
|
|
129
|
+
continue;
|
|
130
|
+
const action = field === "body" && input.appendBody !== undefined && input.body === undefined
|
|
131
|
+
? "appended"
|
|
132
|
+
: typeof before === "string" && typeof after === "string"
|
|
133
|
+
? after.length === 0
|
|
134
|
+
? "cleared"
|
|
135
|
+
: before.length === 0
|
|
136
|
+
? "added"
|
|
137
|
+
: "replaced"
|
|
138
|
+
: field === "parent" && after === null
|
|
139
|
+
? "cleared"
|
|
140
|
+
: "changed";
|
|
141
|
+
changes.push({ field, action });
|
|
142
|
+
}
|
|
143
|
+
return changes;
|
|
144
|
+
}
|
|
126
145
|
export async function updateTask(world, id, input) {
|
|
127
146
|
const result = await withTaskLocks({ world, allocation: false, ids: [id], ...(input.signal === undefined ? {} : { signal: input.signal }) }, async () => {
|
|
128
147
|
const snapshot = await readBoard(world), current = snapshot.board.tasks.get(id);
|
|
@@ -151,7 +170,11 @@ export async function updateTask(world, id, input) {
|
|
|
151
170
|
const label = `${id}.md`;
|
|
152
171
|
return {
|
|
153
172
|
kind: "accepted",
|
|
154
|
-
value: {
|
|
173
|
+
value: {
|
|
174
|
+
task: taskView(next),
|
|
175
|
+
documentDiff: documentDiff(label, label, before, after),
|
|
176
|
+
changedFields: updateFieldChanges(current, next, input),
|
|
177
|
+
},
|
|
155
178
|
};
|
|
156
179
|
});
|
|
157
180
|
return result === "busy" ? { kind: "retry", reason: "busy" } : result;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TaskPriority, TaskState } from "./document.js";
|
|
2
2
|
import { type TaskId } from "./identity.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { TaskBoard, TaskRef, TaskRelationProjection, TaskRow } from "./board.js";
|
|
4
4
|
import { type BoundedList } from "../bounded-list.js";
|
|
5
5
|
export declare const TASK_RELATION_PREDICATE_FIELDS: readonly ["under", "needs", "blocks"];
|
|
6
6
|
export type TaskRelationPredicateField = (typeof TASK_RELATION_PREDICATE_FIELDS)[number];
|
|
@@ -53,7 +53,15 @@ export type TaskQueryRow = TaskRow & Readonly<{
|
|
|
53
53
|
updatedAt: string;
|
|
54
54
|
}>;
|
|
55
55
|
export type TaskPage<Row> = BoundedList<Row>;
|
|
56
|
+
/** Semantic refusals identify the caller input part; textual offsets belong to the CLI. */
|
|
57
|
+
export declare class TaskQueryPredicateError extends TypeError {
|
|
58
|
+
readonly part: "field" | "operator" | "value";
|
|
59
|
+
constructor(message: string, part: "field" | "operator" | "value");
|
|
60
|
+
}
|
|
61
|
+
export declare function normalizeTaskQueryPredicate(value: unknown): TaskQueryPredicate;
|
|
56
62
|
export declare function normalizeTaskQuery(value: unknown): TaskQueryExpression;
|
|
63
|
+
/** CLI selection and native default share Task-owned terminal-state semantics. */
|
|
64
|
+
export declare function taskQuerySelection(selection?: "active" | "closed" | "all", where?: TaskQueryExpression): TaskQueryExpression;
|
|
57
65
|
export declare function projectQueryRows(board: TaskBoard, relations: TaskRelationProjection, input: Readonly<{
|
|
58
66
|
scope: readonly string[] | null;
|
|
59
67
|
expression: TaskQueryExpression;
|
|
@@ -67,5 +75,3 @@ export declare function projectQuery(board: TaskBoard, relations: TaskRelationPr
|
|
|
67
75
|
}>): TaskPage<TaskQueryRow>;
|
|
68
76
|
export declare function underExpression(parent: TaskId): TaskQueryExpression;
|
|
69
77
|
export declare function queryUnderTargets(expression: TaskQueryExpression): readonly TaskId[];
|
|
70
|
-
export type TaskQueryPage = TaskPage<TaskQueryRow>;
|
|
71
|
-
export type TaskBlockedPage = TaskPage<BlockedTaskRow>;
|
package/build/src/task/query.js
CHANGED
|
@@ -20,58 +20,69 @@ function closed(value, fields, label) {
|
|
|
20
20
|
if (!fields.includes(key))
|
|
21
21
|
fail(`${label} has unknown field: ${key}`);
|
|
22
22
|
}
|
|
23
|
+
/** Semantic refusals identify the caller input part; textual offsets belong to the CLI. */
|
|
24
|
+
export class TaskQueryPredicateError extends TypeError {
|
|
25
|
+
part;
|
|
26
|
+
constructor(message, part) {
|
|
27
|
+
super(message);
|
|
28
|
+
this.part = part;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function invalidPredicate(message, part = "value") {
|
|
32
|
+
throw new TaskQueryPredicateError(message, part);
|
|
33
|
+
}
|
|
23
34
|
function taskId(value, label) {
|
|
24
35
|
if (typeof value !== "string")
|
|
25
|
-
|
|
36
|
+
invalidPredicate(`${label} must be a TaskId`);
|
|
26
37
|
try {
|
|
27
38
|
const coordinate = parseTaskId(value);
|
|
28
39
|
if (formatTaskId(coordinate) !== value)
|
|
29
|
-
|
|
40
|
+
invalidPredicate(`${label} must be a canonical TaskId`);
|
|
30
41
|
}
|
|
31
42
|
catch {
|
|
32
|
-
|
|
43
|
+
invalidPredicate(`${label} must be a canonical TaskId`);
|
|
33
44
|
}
|
|
34
45
|
return value;
|
|
35
46
|
}
|
|
36
47
|
function comparison(value) {
|
|
37
48
|
if (typeof value !== "string" || !comparisons.includes(value))
|
|
38
|
-
|
|
49
|
+
invalidPredicate("query operator is invalid", "operator");
|
|
39
50
|
return value;
|
|
40
51
|
}
|
|
41
52
|
function timestamp(value, field) {
|
|
42
53
|
if (typeof value !== "string" ||
|
|
43
54
|
!Number.isFinite(Date.parse(value)) ||
|
|
44
55
|
new Date(Date.parse(value)).toISOString() !== value) {
|
|
45
|
-
|
|
56
|
+
invalidPredicate(`${field} must be a canonical UTC ISO timestamp`);
|
|
46
57
|
}
|
|
47
58
|
return value;
|
|
48
59
|
}
|
|
49
60
|
function equalityOperator(operator, field) {
|
|
50
61
|
if (operator !== "=" && operator !== "!=")
|
|
51
|
-
|
|
62
|
+
invalidPredicate(`${field} supports only = and !=`, "operator");
|
|
52
63
|
return operator;
|
|
53
64
|
}
|
|
54
65
|
function orderedOperator(operator, field) {
|
|
55
66
|
if (operator === "~")
|
|
56
|
-
|
|
67
|
+
invalidPredicate(`${field} does not support ~`, "operator");
|
|
57
68
|
return operator;
|
|
58
69
|
}
|
|
59
70
|
function normalizeStatePredicate(input, operator) {
|
|
60
71
|
if (typeof input.value !== "string" || !states.includes(input.value))
|
|
61
|
-
|
|
72
|
+
invalidPredicate("state value is invalid");
|
|
62
73
|
return { field: "state", operator: equalityOperator(operator, "state"), value: input.value };
|
|
63
74
|
}
|
|
64
75
|
function normalizePriorityPredicate(input, operator) {
|
|
65
76
|
if (typeof input.value !== "number" || !Number.isInteger(input.value) || input.value < 0 || input.value > 3) {
|
|
66
|
-
|
|
77
|
+
invalidPredicate("priority value must be 0..3");
|
|
67
78
|
}
|
|
68
79
|
return { field: "priority", operator: orderedOperator(operator, "priority"), value: input.value };
|
|
69
80
|
}
|
|
70
81
|
function normalizeTextPredicate(input, field, operator) {
|
|
71
82
|
if (typeof input.value !== "string" || input.value.length === 0)
|
|
72
|
-
|
|
83
|
+
invalidPredicate(`${field} value must be nonblank`);
|
|
73
84
|
if (operator !== "=" && operator !== "!=" && operator !== "~")
|
|
74
|
-
|
|
85
|
+
invalidPredicate(`${field} supports only =, !=, and ~`, "operator");
|
|
75
86
|
if (field === "id" && operator !== "~")
|
|
76
87
|
taskId(input.value, "id value");
|
|
77
88
|
return { field, operator, value: input.value };
|
|
@@ -85,18 +96,18 @@ function normalizeRelationPredicate(input, field, operator) {
|
|
|
85
96
|
}
|
|
86
97
|
function normalizeBooleanPredicate(input, field, operator) {
|
|
87
98
|
if (typeof input.value !== "boolean")
|
|
88
|
-
|
|
99
|
+
invalidPredicate(`${field} value must be boolean`);
|
|
89
100
|
return { field, operator: equalityOperator(operator, field), value: input.value };
|
|
90
101
|
}
|
|
91
102
|
function normalizeTimestampPredicate(input, field, operator) {
|
|
92
103
|
return { field, operator: orderedOperator(operator, field), value: timestamp(input.value, `${field} value`) };
|
|
93
104
|
}
|
|
94
|
-
function
|
|
105
|
+
export function normalizeTaskQueryPredicate(value) {
|
|
95
106
|
const input = object(value, "query predicate");
|
|
96
107
|
closed(input, ["field", "operator", "value"], "query predicate");
|
|
97
108
|
const field = input.field;
|
|
98
109
|
if (typeof field !== "string")
|
|
99
|
-
|
|
110
|
+
invalidPredicate("query predicate field is required", "field");
|
|
100
111
|
const operator = comparison(input.operator);
|
|
101
112
|
switch (field) {
|
|
102
113
|
case "state":
|
|
@@ -120,14 +131,14 @@ function predicate(value) {
|
|
|
120
131
|
default:
|
|
121
132
|
if (isTaskRelationPredicateField(field))
|
|
122
133
|
return normalizeRelationPredicate(input, field, operator);
|
|
123
|
-
return
|
|
134
|
+
return invalidPredicate(`unknown query field: ${field}`, "field");
|
|
124
135
|
}
|
|
125
136
|
}
|
|
126
137
|
export function normalizeTaskQuery(value) {
|
|
127
138
|
const input = object(value, "query expression");
|
|
128
139
|
if (input.kind === "predicate") {
|
|
129
140
|
closed(input, ["kind", "predicate"], "query expression");
|
|
130
|
-
return { kind: "predicate", predicate:
|
|
141
|
+
return { kind: "predicate", predicate: normalizeTaskQueryPredicate(input.predicate) };
|
|
131
142
|
}
|
|
132
143
|
if (input.kind === "not") {
|
|
133
144
|
closed(input, ["kind", "term"], "query expression");
|
|
@@ -141,6 +152,21 @@ export function normalizeTaskQuery(value) {
|
|
|
141
152
|
}
|
|
142
153
|
fail("query expression kind is invalid");
|
|
143
154
|
}
|
|
155
|
+
/** CLI selection and native default share Task-owned terminal-state semantics. */
|
|
156
|
+
export function taskQuerySelection(selection = "active", where) {
|
|
157
|
+
if (selection === "all" && where !== undefined)
|
|
158
|
+
return where;
|
|
159
|
+
const state = (value, operator) => ({
|
|
160
|
+
kind: "predicate",
|
|
161
|
+
predicate: { field: "state", operator, value },
|
|
162
|
+
});
|
|
163
|
+
const selected = selection === "all"
|
|
164
|
+
? { kind: "or", terms: [state("done", "="), state("done", "!=")] }
|
|
165
|
+
: selection === "closed"
|
|
166
|
+
? { kind: "or", terms: [state("done", "="), state("drop", "=")] }
|
|
167
|
+
: { kind: "and", terms: [state("done", "!="), state("drop", "!=")] };
|
|
168
|
+
return where === undefined ? selected : { kind: "and", terms: [selected, where] };
|
|
169
|
+
}
|
|
144
170
|
function compare(left, operator, right) {
|
|
145
171
|
if (operator === "=")
|
|
146
172
|
return left === right;
|
|
@@ -24,7 +24,8 @@ export declare function replaceAuthority(input: Readonly<{
|
|
|
24
24
|
export declare function authorityBytesMatch(world: WorldRoot, id: TaskId, expected: Uint8Array | null): Promise<boolean>;
|
|
25
25
|
export declare function nukeTaskAuthority(world: WorldRoot, options?: Readonly<{
|
|
26
26
|
timeoutMs?: number;
|
|
27
|
-
|
|
27
|
+
onRemoved?(count: number): void;
|
|
28
|
+
}>): Promise<number | "busy">;
|
|
28
29
|
export declare function withTaskLocks<T>(input: Readonly<{
|
|
29
30
|
world: WorldRoot;
|
|
30
31
|
allocation: boolean;
|