@astrosheep/keiyaku 4.6.31 → 4.6.32
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 +34 -17
- package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +16 -11
- package/build/plugins/claude/skills/keiyaku-babysit/SKILL.md +5 -3
- 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 +4 -3
- package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +16 -11
- package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +5 -3
- 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 +4 -3
- package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +16 -11
- package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +5 -3
- 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 +4 -3
- package/build/plugins/pi/README.md +16 -18
- package/build/plugins/pi/akuma-tools.ts +31 -38
- package/build/plugins/pi/keiyaku.ts +15 -4
- package/build/skills/keiyaku-akuma/SKILL.md +16 -11
- package/build/skills/keiyaku-babysit/SKILL.md +5 -3
- 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 +4 -3
- 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 +39 -303
- package/build/src/akuma/akuma-instance.js +48 -48
- package/build/src/akuma/akuma-observe.d.ts +5 -4
- package/build/src/akuma/akuma-observe.js +1 -7
- 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 +22 -19
- package/build/src/akuma/akuma-selection-execution.js +71 -124
- package/build/src/akuma/akuma-wait.d.ts +3 -3
- package/build/src/akuma/akuma.d.ts +47 -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 +31 -26
- package/build/src/akuma/call-initial-tell.d.ts +4 -1
- package/build/src/akuma/call-initial-tell.js +9 -1
- 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/facts.d.ts +5 -4
- package/build/src/akuma/heart/facts.js +5 -5
- package/build/src/akuma/heart/soul.js +20 -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.d.ts +3 -0
- package/build/src/akuma/provider-recipe.js +3 -2
- package/build/src/akuma/providers/acp/config.js +11 -10
- 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/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 +16 -14
- 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 +281 -240
- package/build/src/akuma/selection-observation.js +122 -68
- package/build/src/akuma/status-projection.d.ts +49 -285
- package/build/src/akuma/status-projection.js +178 -138
- package/build/src/body/amend.js +2 -1
- package/build/src/body/arc.js +3 -2
- package/build/src/body/criteria.js +4 -3
- package/build/src/body/decode.js +2 -1
- package/build/src/body/envelope.js +2 -1
- package/build/src/body/region.d.ts +1 -3
- package/build/src/body/region.js +3 -8
- 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 +109 -66
- package/build/src/cli/commands/akuma-grammar.js +75 -95
- package/build/src/cli/commands/akuma.d.ts +8 -3
- package/build/src/cli/commands/akuma.js +63 -122
- package/build/src/cli/commands/contract-grammar.d.ts +3 -135
- package/build/src/cli/commands/contract-grammar.js +125 -218
- package/build/src/cli/commands/contract-help.d.ts +24 -21
- package/build/src/cli/commands/contract-help.js +43 -35
- package/build/src/cli/commands/contract.d.ts +6 -18
- package/build/src/cli/commands/contract.js +65 -272
- package/build/src/cli/commands/debt-grammar.d.ts +2 -4
- package/build/src/cli/commands/debt-grammar.js +22 -190
- 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 -16
- package/build/src/cli/render/akuma-activity.d.ts +19 -24
- package/build/src/cli/render/akuma-activity.js +164 -259
- package/build/src/cli/render/akuma.d.ts +3 -3
- package/build/src/cli/render/akuma.js +36 -43
- package/build/src/cli/render/catalog.d.ts +2 -5
- package/build/src/cli/render/catalog.js +2 -33
- package/build/src/cli/render/contract-history.js +1 -2
- package/build/src/cli/render/contract-observation.d.ts +0 -7
- package/build/src/cli/render/contract-observation.js +0 -3
- package/build/src/cli/render/contract.d.ts +7 -9
- package/build/src/cli/render/contract.js +35 -64
- package/build/src/cli/render/debt.d.ts +3 -11
- package/build/src/cli/render/debt.js +17 -88
- package/build/src/cli/render/delivery-preview.js +4 -4
- package/build/src/cli/render/kanshi-akuma.d.ts +5 -3
- package/build/src/cli/render/kanshi-akuma.js +22 -18
- package/build/src/cli/render/kanshi.d.ts +1 -3
- package/build/src/cli/render/kanshi.js +16 -39
- package/build/src/cli/render/receipt.d.ts +21 -12
- package/build/src/cli/render/receipt.js +49 -44
- package/build/src/cli/render/refusal.d.ts +4 -3
- package/build/src/cli/render/refusal.js +15 -17
- package/build/src/cli/render/settings.d.ts +1 -1
- package/build/src/cli/render/terminal.d.ts +9 -8
- package/build/src/cli/render/terminal.js +48 -32
- package/build/src/cli/render/verbs.d.ts +3 -1
- package/build/src/cli/render/verbs.js +74 -116
- package/build/src/cli/runtime.js +66 -65
- 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 +9 -23
- package/build/src/core/facts/errors.d.ts +2 -1
- package/build/src/core/facts/errors.js +3 -3
- package/build/src/core/facts/types.d.ts +2 -13
- package/build/src/core/facts/types.js +1 -6
- package/build/src/core/verbs/abandon.d.ts +1 -2
- package/build/src/core/verbs/amend.d.ts +1 -2
- 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 -219
- package/build/src/debt/index.js +61 -110
- package/build/src/debt/input.d.ts +19 -5
- package/build/src/debt/input.js +51 -177
- 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/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/observe.d.ts +3 -0
- package/build/src/git/observe.js +19 -5
- package/build/src/git/reconcile.d.ts +3 -16
- package/build/src/git/reconcile.js +0 -18
- package/build/src/git/repository.d.ts +2 -1
- package/build/src/git/repository.js +3 -3
- 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/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 +34 -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 +22 -7
- package/build/src/kanshi/index.js +30 -4
- package/build/src/kanshi/read.d.ts +81 -270
- package/build/src/kanshi/read.js +39 -199
- package/build/src/kanshi/report.d.ts +340 -1619
- package/build/src/kanshi/report.js +19 -31
- package/build/src/library/address.d.ts +11 -11
- package/build/src/library/address.js +34 -27
- package/build/src/library/akuma-creation.d.ts +210 -79
- package/build/src/library/akuma-creation.js +201 -242
- 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 +141 -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 +33 -34
- package/build/src/library/contract-outcomes.d.ts +1278 -806
- package/build/src/library/contract-outcomes.js +11 -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 +42 -67
- package/build/src/library/contract-types.js +15 -56
- package/build/src/library/contract-wait.d.ts +40 -3
- package/build/src/library/contract-wait.js +28 -21
- package/build/src/library/delivery.d.ts +366 -389
- package/build/src/library/delivery.js +5 -25
- package/build/src/library/input.d.ts +31 -5
- package/build/src/library/input.js +40 -40
- 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 +459 -19
- 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 +40 -59
- 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 +8 -157
- package/build/src/library/keiyaku-identity.js +5 -4
- package/build/src/library/keiyaku-verbs.d.ts +4004 -3885
- package/build/src/library/keiyaku-verbs.js +309 -271
- package/build/src/library/keiyaku.d.ts +30 -860
- package/build/src/library/keiyaku.js +169 -256
- 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 +167 -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 +20 -28
- package/build/src/library/refusal.js +1 -11
- package/build/src/library/repo.js +4 -3
- package/build/src/library/selection.d.ts +32 -21
- package/build/src/library/selection.js +63 -87
- package/build/src/mcp/adapter.d.ts +6 -0
- package/build/src/mcp/adapter.js +177 -42
- package/build/src/mcp/help.d.ts +1 -1
- package/build/src/mcp/help.js +12 -7
- package/build/src/mcp/output.d.ts +385 -0
- package/build/src/mcp/output.js +193 -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 +1 -1
- package/build/src/protocol/amend.js +2 -2
- package/build/src/protocol/bind.d.ts +5 -7
- package/build/src/protocol/bind.js +3 -3
- package/build/src/protocol/completion.d.ts +158 -195
- package/build/src/protocol/completion.js +55 -19
- package/build/src/protocol/deliver.d.ts +11 -6
- package/build/src/protocol/deliver.js +30 -30
- package/build/src/protocol/delivery-preview.d.ts +13 -11
- package/build/src/protocol/delivery-preview.js +2 -2
- package/build/src/protocol/execution-observation.d.ts +5 -13
- package/build/src/protocol/intent.d.ts +6 -9
- package/build/src/protocol/intent.js +18 -31
- package/build/src/protocol/operations.d.ts +48 -53
- package/build/src/protocol/operations.js +16 -25
- package/build/src/protocol/outcome.d.ts +3 -1
- package/build/src/protocol/placement.d.ts +1 -2
- package/build/src/protocol/placement.js +1 -1
- package/build/src/protocol/progress.d.ts +1 -0
- package/build/src/protocol/read/status.d.ts +29 -112
- package/build/src/protocol/read/status.js +52 -78
- package/build/src/protocol/reintegrate.d.ts +1 -2
- package/build/src/protocol/reintegrate.js +0 -1
- package/build/src/protocol/result-leaves.d.ts +11 -32
- package/build/src/protocol/result-leaves.js +18 -57
- package/build/src/protocol/result-reasons.d.ts +6 -6
- package/build/src/protocol/review.js +0 -1
- package/build/src/protocol/verify.d.ts +192 -146
- package/build/src/protocol/verify.js +60 -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 +0 -4
- 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 +1 -1
- 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 +16 -18
- package/plugins/pi/akuma-tools.ts +31 -38
- package/plugins/pi/keiyaku.ts +15 -4
- package/skills/keiyaku-akuma/SKILL.md +16 -11
- package/skills/keiyaku-babysit/SKILL.md +5 -3
- package/skills/keiyaku-bind/SKILL.md +4 -3
- package/skills/keiyaku-debt/SKILL.md +17 -17
- package/skills/keiyaku-workflow/SKILL.md +4 -3
- 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/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/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
|
@@ -1,54 +1,41 @@
|
|
|
1
1
|
import { AkumaNotBornError } from "../akuma/akuma-errors.js";
|
|
2
|
-
import {
|
|
2
|
+
import { AkumaNameError } from "../akuma/archetype.js";
|
|
3
3
|
import { AkumaAddressError, AkumaWorldScopeError } from "./address.js";
|
|
4
|
-
import { KeiyakuArcDocumentError
|
|
5
|
-
import {
|
|
4
|
+
import { KeiyakuArcDocumentError } from "./keiyaku-coordinates.js";
|
|
5
|
+
import { errorCategory } from "../errors.js";
|
|
6
|
+
import { contractOutcomeDisposition, invocationIssueIsFailure, resetIssueIsRequired } from "./outcome.js";
|
|
6
7
|
function classifyDebt(result) {
|
|
7
|
-
if ("items" in result)
|
|
8
|
-
|
|
9
|
-
return "retryable";
|
|
10
|
-
return result.items.some((item) => item.kind === "refused" || item.kind === "missing") ? "refused" : "accepted";
|
|
11
|
-
}
|
|
8
|
+
if ("items" in result)
|
|
9
|
+
return result.kind === "debt-complete" ? "accepted" : "refused";
|
|
12
10
|
if (result.kind === "retry")
|
|
13
11
|
return "retryable";
|
|
14
|
-
if (result.kind === "refused" ||
|
|
15
|
-
result.kind === "absent" ||
|
|
16
|
-
result.kind === "missing" ||
|
|
17
|
-
result.kind === "invalid-namespace-context")
|
|
12
|
+
if (result.kind === "refused" || result.kind === "absent")
|
|
18
13
|
return "refused";
|
|
19
14
|
return "issues" in result && (result.issues?.length ?? 0) > 0 ? "failed" : "accepted";
|
|
20
15
|
}
|
|
21
16
|
function classifyThrown(name, error) {
|
|
22
|
-
if (spawnFailureReceipt(error) !== undefined || (error instanceof KeiyakuError && error.outcome !== undefined))
|
|
23
|
-
return "failed";
|
|
24
|
-
if (error instanceof KeiyakuUsageError)
|
|
25
|
-
return "usage";
|
|
26
17
|
if (error instanceof AkumaAddressError ||
|
|
27
18
|
error instanceof AkumaNotBornError ||
|
|
28
19
|
error instanceof AkumaWorldScopeError ||
|
|
29
20
|
error instanceof KeiyakuArcDocumentError ||
|
|
30
|
-
(name === "spawn" && error instanceof
|
|
21
|
+
(name === "spawn" && error instanceof AkumaNameError))
|
|
31
22
|
return "refused";
|
|
32
|
-
return "failed";
|
|
33
|
-
}
|
|
34
|
-
function classifySpawn(result) {
|
|
35
|
-
return result.failure !== undefined ||
|
|
36
|
-
result.dispatchFailure !== undefined ||
|
|
37
|
-
(result.alias !== undefined && result.alias.kind !== "moved") ||
|
|
38
|
-
result.wake?.kind === "failed" ||
|
|
39
|
-
result.input?.kind === "failed" ||
|
|
40
|
-
result.input?.kind === "invalid-output"
|
|
41
|
-
? "failed"
|
|
42
|
-
: "accepted";
|
|
43
|
-
}
|
|
44
|
-
function classifyFork(result) {
|
|
45
|
-
if (result.kind === "forked")
|
|
46
|
-
return result.dispatchFailure === undefined ? "accepted" : "failed";
|
|
47
|
-
return result.kind === "fork-failed" || result.kind === "provider-forked-local-birth-failed" ? "failed" : "refused";
|
|
48
|
-
}
|
|
49
|
-
function classifyStatus(value) {
|
|
50
|
-
return "kind" in value && value.kind === "contract-missing" ? "refused" : "accepted";
|
|
23
|
+
return errorCategory(error) === "invalid-input" ? "usage" : "failed";
|
|
51
24
|
}
|
|
25
|
+
const akumaCallDisposition = {
|
|
26
|
+
spawned: "accepted",
|
|
27
|
+
admitted: "accepted",
|
|
28
|
+
forked: "accepted",
|
|
29
|
+
answered: "accepted",
|
|
30
|
+
unanswered: "accepted",
|
|
31
|
+
deadline: "accepted",
|
|
32
|
+
failed: "failed",
|
|
33
|
+
"invalid-output": "failed",
|
|
34
|
+
"fork-failed": "failed",
|
|
35
|
+
"provider-forked-local-birth-failed": "failed",
|
|
36
|
+
"provider-cannot-fork": "refused",
|
|
37
|
+
"unknown-history": "refused",
|
|
38
|
+
};
|
|
52
39
|
function classifyRegion(value) {
|
|
53
40
|
return value.kind === "contract-missing" || value.kind === "contract-terminal" ? "refused" : "accepted";
|
|
54
41
|
}
|
|
@@ -80,46 +67,30 @@ function classifyNuke(result) {
|
|
|
80
67
|
return result.issues?.some(resetIssueIsRequired) === true ? "retryable" : "accepted";
|
|
81
68
|
}
|
|
82
69
|
/** Classify the native completion without changing or reconstructing its evidence. */
|
|
83
|
-
export function classifyVerb(name,
|
|
70
|
+
export function classifyVerb(name, _input, completion) {
|
|
84
71
|
if (completion.kind === "threw")
|
|
85
72
|
return classifyThrown(name, completion.error);
|
|
86
73
|
const value = completion.value;
|
|
87
74
|
switch (name) {
|
|
88
|
-
case "ls":
|
|
89
|
-
return input.of === "debt" ? classifyDebt(value) : "accepted";
|
|
90
75
|
case "debt.add":
|
|
91
76
|
case "debt.addDocument":
|
|
92
77
|
case "debt.update":
|
|
93
|
-
case "debt.show":
|
|
94
|
-
case "debt.done":
|
|
95
|
-
case "debt.drop":
|
|
96
|
-
case "debt.ready":
|
|
97
|
-
case "debt.blocked":
|
|
98
|
-
case "debt.query":
|
|
99
|
-
case "debt.tree":
|
|
100
78
|
case "debt.doctor":
|
|
101
|
-
case "debt.context":
|
|
102
79
|
return classifyDebt(value);
|
|
103
80
|
case "bind":
|
|
104
81
|
case "amend":
|
|
105
82
|
case "arc":
|
|
106
83
|
case "deliver":
|
|
107
|
-
case "deliver.preview":
|
|
108
84
|
case "verify":
|
|
109
85
|
case "review":
|
|
110
86
|
case "abandon": {
|
|
111
87
|
return contractOutcomeDisposition(value);
|
|
112
88
|
}
|
|
113
89
|
case "spawn":
|
|
114
|
-
return classifySpawn(value);
|
|
115
90
|
case "fork":
|
|
116
|
-
return classifyFork(value);
|
|
117
91
|
case "tell":
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const reason = value.kind;
|
|
121
|
-
return reason === "failed" || reason === "invalid-output" ? "failed" : "accepted";
|
|
122
|
-
}
|
|
92
|
+
case "ask":
|
|
93
|
+
return akumaCallDisposition[value.kind];
|
|
123
94
|
case "kill":
|
|
124
95
|
return value.results.some(({ outcome }) => outcome === "unavailable" || outcome === "hung" || outcome === "untidy")
|
|
125
96
|
? "failed"
|
|
@@ -128,10 +99,20 @@ export function classifyVerb(name, input, completion) {
|
|
|
128
99
|
return classifyWait(value);
|
|
129
100
|
case "history":
|
|
130
101
|
return classifyHistory(value);
|
|
131
|
-
case "show":
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
102
|
+
case "show": {
|
|
103
|
+
const result = value;
|
|
104
|
+
if (result.kind === "present")
|
|
105
|
+
return "accepted";
|
|
106
|
+
return result.kind === "missing" ? "refused" : classifyDebt(result);
|
|
107
|
+
}
|
|
108
|
+
case "ls": {
|
|
109
|
+
const result = value;
|
|
110
|
+
return result.kind === "debt-catalogue" && "absent" in result ? "refused" : "accepted";
|
|
111
|
+
}
|
|
112
|
+
case "status": {
|
|
113
|
+
const result = value;
|
|
114
|
+
return result.kind === "contract-missing" ? "refused" : result.kind === "contract-failed" ? "failed" : "accepted";
|
|
115
|
+
}
|
|
135
116
|
case "region":
|
|
136
117
|
return classifyRegion(value);
|
|
137
118
|
case "reconcile":
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { KeiyakuError } from "../errors.js";
|
|
1
2
|
import { type WorldRoot } from "../world.js";
|
|
2
3
|
import { Repo } from "./repo.js";
|
|
3
4
|
import type { ContractId } from "../core/facts/types.js";
|
|
4
5
|
/** Invalid arc material retains the resolved subject for the process-edge refusal. */
|
|
5
|
-
export declare class KeiyakuArcDocumentError extends
|
|
6
|
+
export declare class KeiyakuArcDocumentError extends KeiyakuError {
|
|
6
7
|
readonly contract: ContractId;
|
|
7
8
|
constructor(contract: ContractId, cause: Error);
|
|
8
9
|
}
|
|
9
|
-
export declare class KeiyakuUsageError extends
|
|
10
|
+
export declare class KeiyakuUsageError extends KeiyakuError {
|
|
10
11
|
constructor(message: string);
|
|
11
12
|
}
|
|
12
13
|
export type InvocationCoordinates = Readonly<{
|
|
@@ -14,12 +15,6 @@ export type InvocationCoordinates = Readonly<{
|
|
|
14
15
|
repo?: Repo;
|
|
15
16
|
world: WorldRoot | null;
|
|
16
17
|
candidateWorld: WorldRoot | null;
|
|
17
|
-
debtContext: Readonly<{
|
|
18
|
-
directory: string;
|
|
19
|
-
boundary: string;
|
|
20
|
-
writeRoot: string;
|
|
21
|
-
managed: boolean;
|
|
22
|
-
}>;
|
|
23
18
|
establishWorld: () => Promise<WorldRoot>;
|
|
24
19
|
}>;
|
|
25
20
|
export declare function invocationCoordinates(input: Readonly<{
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { KeiyakuError } from "../errors.js";
|
|
2
|
+
import { realpath } from "node:fs/promises";
|
|
2
3
|
import { resolve } from "node:path";
|
|
3
4
|
import { World, WorldError } from "../world.js";
|
|
4
5
|
import { NoGitWorldError, Repo } from "./repo.js";
|
|
5
6
|
/** Invalid arc material retains the resolved subject for the process-edge refusal. */
|
|
6
|
-
export class KeiyakuArcDocumentError extends
|
|
7
|
+
export class KeiyakuArcDocumentError extends KeiyakuError {
|
|
7
8
|
contract;
|
|
8
9
|
constructor(contract, cause) {
|
|
9
|
-
super(cause.message, { cause });
|
|
10
|
+
super("invalid-input", cause.message, { cause });
|
|
10
11
|
this.contract = contract;
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
|
-
export class KeiyakuUsageError extends
|
|
14
|
+
export class KeiyakuUsageError extends KeiyakuError {
|
|
14
15
|
constructor(message) {
|
|
15
|
-
super(message);
|
|
16
|
-
this.name = "KeiyakuUsageError";
|
|
16
|
+
super("invalid-input", message);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
async function discoverRepo(path, gitPath) {
|
|
@@ -26,18 +26,6 @@ async function discoverRepo(path, gitPath) {
|
|
|
26
26
|
throw error;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
async function managedContractWorktree(root) {
|
|
30
|
-
try {
|
|
31
|
-
const stat = await lstat(resolve(root, ".keiyaku", "KEIYAKU.md"));
|
|
32
|
-
return stat.isFile() && !stat.isSymbolicLink();
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
if (error.code === "ENOENT")
|
|
36
|
-
return false;
|
|
37
|
-
throw error;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
// eslint-disable-next-line complexity -- coordinate discovery preserves independent Repo and World policies.
|
|
41
29
|
export async function invocationCoordinates(input) {
|
|
42
30
|
const gitPath = input.environment.KEIYAKU_GIT_PATH;
|
|
43
31
|
if (gitPath !== undefined && gitPath.trim() === "")
|
|
@@ -62,7 +50,6 @@ export async function invocationCoordinates(input) {
|
|
|
62
50
|
...(repo === undefined ? {} : { repo }),
|
|
63
51
|
world: null,
|
|
64
52
|
candidateWorld: null,
|
|
65
|
-
debtContext: { directory: cwd, boundary: cwd, writeRoot: cwd, managed: false },
|
|
66
53
|
establishWorld: async () => {
|
|
67
54
|
throw new Error("Contract wait has no World");
|
|
68
55
|
},
|
|
@@ -71,18 +58,11 @@ export async function invocationCoordinates(input) {
|
|
|
71
58
|
const worldRepo = invocation?.kind === "present" ? invocation.repo : undefined;
|
|
72
59
|
try {
|
|
73
60
|
const world = await World.resolve({ cwd, ...(worldRepo === undefined ? {} : { repositoryRoot: worldRepo.root }) });
|
|
74
|
-
const boundary = worldRepo === undefined ? (world.root ?? world.candidate ?? cwd) : worldRepo.cwd;
|
|
75
61
|
return {
|
|
76
62
|
cwd,
|
|
77
63
|
...(repo === undefined ? {} : { repo }),
|
|
78
64
|
world: world.root,
|
|
79
65
|
candidateWorld: world.candidate,
|
|
80
|
-
debtContext: {
|
|
81
|
-
directory: cwd,
|
|
82
|
-
boundary,
|
|
83
|
-
writeRoot: worldRepo === undefined ? boundary : cwd,
|
|
84
|
-
managed: await managedContractWorktree(boundary),
|
|
85
|
-
},
|
|
86
66
|
establishWorld: async () => {
|
|
87
67
|
try {
|
|
88
68
|
return await world.establish();
|
|
@@ -1,50 +1,16 @@
|
|
|
1
|
-
import { type AddDebtInput, type AddDebtDocumentInput, type UpdateDebtInput, type
|
|
1
|
+
import { type AddDebtInput, type AddDebtDocumentInput, type UpdateDebtInput, type DebtAbsent, type DebtShowResult } from "../debt/index.js";
|
|
2
2
|
import type { KeiyakuAt } from "./keiyaku.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
scope?: "namespace" | "world";
|
|
6
|
-
namespace?: readonly string[];
|
|
3
|
+
type DebtListInvocation = Readonly<{
|
|
4
|
+
selection?: "active" | "closed" | "all";
|
|
7
5
|
limit?: number;
|
|
8
6
|
}>;
|
|
9
|
-
export type DebtLsInvocation = DebtReadScope & Readonly<{
|
|
10
|
-
of: "debt";
|
|
11
|
-
selection?: DebtSelection;
|
|
12
|
-
}>;
|
|
13
|
-
export type DebtReadyInvocation = DebtReadScope & Readonly<{
|
|
14
|
-
parent?: string;
|
|
15
|
-
}>;
|
|
16
|
-
export type DebtQueryInvocation = DebtReadScope & Readonly<{
|
|
17
|
-
selection?: DebtSelection;
|
|
18
|
-
where?: DebtQueryExpression;
|
|
19
|
-
sort?: DebtQuerySort;
|
|
20
|
-
}>;
|
|
21
7
|
export type DebtUpdateInvocation = UpdateDebtInput & Readonly<{
|
|
22
8
|
id: string;
|
|
23
9
|
}>;
|
|
24
|
-
export type DebtCloseInvocation = Readonly<{
|
|
25
|
-
ids: readonly string[];
|
|
26
|
-
note?: string;
|
|
27
|
-
signal?: AbortSignal;
|
|
28
|
-
}>;
|
|
29
|
-
export type DebtShowInvocation = Readonly<{
|
|
30
|
-
id: string;
|
|
31
|
-
ids?: never;
|
|
32
|
-
}> | Readonly<{
|
|
33
|
-
ids: readonly string[];
|
|
34
|
-
id?: never;
|
|
35
|
-
}>;
|
|
36
|
-
export type DebtContextInvocation = Readonly<{
|
|
37
|
-
namespace?: readonly string[];
|
|
38
|
-
}>;
|
|
39
|
-
declare const absent: DebtAbsent;
|
|
40
10
|
export declare function debtAdd(at: KeiyakuAt, input: AddDebtInput | AddDebtDocumentInput, document: boolean): Promise<Readonly<{
|
|
41
11
|
kind: "refused";
|
|
42
12
|
reason: "invalid-graph";
|
|
43
13
|
diagnostic: string;
|
|
44
|
-
}> | Readonly<{
|
|
45
|
-
kind: "refused";
|
|
46
|
-
reason: "invalid-namespace-context";
|
|
47
|
-
path?: string;
|
|
48
14
|
}> | Readonly<{
|
|
49
15
|
kind: "retry";
|
|
50
16
|
reason: "busy" | "concurrent-modification";
|
|
@@ -60,52 +26,28 @@ export declare function debtUpdate(at: KeiyakuAt, input: DebtUpdateInvocation):
|
|
|
60
26
|
kind: "refused";
|
|
61
27
|
reason: "invalid-graph";
|
|
62
28
|
diagnostic: string;
|
|
63
|
-
}> | Readonly<{
|
|
64
|
-
kind: "refused";
|
|
65
|
-
reason: "relation-owned-by-other";
|
|
66
|
-
related: `debt/${string}`;
|
|
67
29
|
}> | Readonly<{
|
|
68
30
|
kind: "retry";
|
|
69
31
|
reason: "busy" | "concurrent-modification";
|
|
70
32
|
}> | Readonly<{
|
|
71
33
|
kind: "accepted";
|
|
72
|
-
changes?: readonly ("
|
|
34
|
+
changes?: readonly ("title" | "state" | "note" | "body" | "priority" | "needs")[];
|
|
73
35
|
warning?: string;
|
|
74
36
|
}>>;
|
|
75
|
-
export declare function debtShow(at: KeiyakuAt,
|
|
76
|
-
export declare function
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
warning?: string;
|
|
90
|
-
}>)[];
|
|
91
|
-
}>>;
|
|
92
|
-
export declare function debtList(at: KeiyakuAt, input: DebtLsInvocation): Promise<DebtCatalogue>;
|
|
93
|
-
export declare function debtReady(at: KeiyakuAt, input: DebtReadyInvocation, blocked: false): Promise<import("../debt/index.js").DebtReadyList | typeof absent>;
|
|
94
|
-
export declare function debtReady(at: KeiyakuAt, input: DebtReadyInvocation, blocked: true): Promise<import("../debt/index.js").BlockedDebtList | typeof absent>;
|
|
95
|
-
export declare function debtQuery(at: KeiyakuAt, input: DebtQueryInvocation): Promise<import("../debt/index.js").DebtQueryResult>;
|
|
96
|
-
export declare function debtTree(at: KeiyakuAt, input: Readonly<{
|
|
97
|
-
id: string;
|
|
98
|
-
}>): Promise<Readonly<{
|
|
99
|
-
kind: "absent";
|
|
100
|
-
}> | Readonly<{
|
|
101
|
-
title: string;
|
|
102
|
-
state: "open" | "drop" | "done";
|
|
103
|
-
priority: 0 | 1 | 2 | 3;
|
|
104
|
-
kind: "present";
|
|
105
|
-
children?: readonly import("../debt/board.js").DebtTreeNode[];
|
|
106
|
-
}> | Readonly<{
|
|
107
|
-
kind: "missing";
|
|
108
|
-
}>>;
|
|
37
|
+
export declare function debtShow(at: KeiyakuAt, id: string): Promise<DebtShowResult | DebtAbsent>;
|
|
38
|
+
export declare function debtLs(at: KeiyakuAt, input: DebtListInvocation): Promise<Readonly<{
|
|
39
|
+
kind: "debt-catalogue";
|
|
40
|
+
rows?: readonly Readonly<{
|
|
41
|
+
id: `debt/${string}`;
|
|
42
|
+
title: string;
|
|
43
|
+
priority: import("../debt/document.js").DebtPriority;
|
|
44
|
+
disposition: "ready" | "blocked" | "drop" | "done";
|
|
45
|
+
}>[];
|
|
46
|
+
more?: true;
|
|
47
|
+
}> | {
|
|
48
|
+
readonly kind: "debt-catalogue";
|
|
49
|
+
readonly absent: true;
|
|
50
|
+
}>;
|
|
109
51
|
export declare function debtDoctor(at: KeiyakuAt): Promise<Readonly<{
|
|
110
52
|
kind: "absent";
|
|
111
53
|
}> | Readonly<{
|
|
@@ -113,30 +55,16 @@ export declare function debtDoctor(at: KeiyakuAt): Promise<Readonly<{
|
|
|
113
55
|
issues?: readonly (Readonly<{
|
|
114
56
|
kind: "missing-target";
|
|
115
57
|
debtId: `debt/${string}`;
|
|
116
|
-
relation: "
|
|
58
|
+
relation: "needs";
|
|
117
59
|
target: `debt/${string}`;
|
|
118
60
|
}> | Readonly<{
|
|
119
61
|
kind: "self-relation";
|
|
120
62
|
debtId: `debt/${string}`;
|
|
121
|
-
relation: "
|
|
63
|
+
relation: "needs";
|
|
122
64
|
}> | Readonly<{
|
|
123
65
|
kind: "cycle";
|
|
124
|
-
relation: "
|
|
66
|
+
relation: "needs";
|
|
125
67
|
debts: readonly `debt/${string}`[];
|
|
126
68
|
}>)[];
|
|
127
69
|
}>>;
|
|
128
|
-
export declare function debtContext(at: KeiyakuAt, input: DebtContextInvocation): Promise<{
|
|
129
|
-
readonly kind: "present";
|
|
130
|
-
readonly source: "default-root";
|
|
131
|
-
readonly path?: never;
|
|
132
|
-
} | {
|
|
133
|
-
readonly kind: "refused";
|
|
134
|
-
readonly path: string;
|
|
135
|
-
readonly source?: never;
|
|
136
|
-
} | {
|
|
137
|
-
readonly namespace?: string;
|
|
138
|
-
readonly kind: "present";
|
|
139
|
-
readonly source: "contract-installed" | "local-override";
|
|
140
|
-
readonly path?: never;
|
|
141
|
-
}>;
|
|
142
70
|
export {};
|
|
@@ -1,54 +1,18 @@
|
|
|
1
1
|
import { Debts, debtRowViewLimit, } from "../debt/index.js";
|
|
2
2
|
import { addDebt, addDebtDocument } from "../debt/operations.js";
|
|
3
|
-
import { addInput, addDocumentInput,
|
|
3
|
+
import { addInput, addDocumentInput, record, debtId, updateInput } from "../debt/input.js";
|
|
4
4
|
import { parseDebtCreationDocument } from "../debt/document.js";
|
|
5
|
-
import {
|
|
6
|
-
import { installNamespaceContext, resolveDebtNamespaceContext, validateNamespaceContext } from "../debt/context.js";
|
|
7
|
-
import { invocationCoordinates, KeiyakuUsageError } from "./keiyaku-coordinates.js";
|
|
8
|
-
import { resolveActor } from "./keiyaku-attribution.js";
|
|
5
|
+
import { invocationCoordinates } from "./keiyaku-coordinates.js";
|
|
9
6
|
const coordinates = (at) => invocationCoordinates({ ...at, use: "none" });
|
|
10
7
|
const absent = { kind: "absent" };
|
|
11
8
|
const missing = () => ({ kind: "refused", reason: "debt-missing" });
|
|
12
|
-
function selection(value) {
|
|
13
|
-
if (value === undefined)
|
|
14
|
-
return "active";
|
|
15
|
-
if (value !== "active" && value !== "closed" && value !== "all")
|
|
16
|
-
throw new TypeError("selection must be active, closed, or all");
|
|
17
|
-
return value;
|
|
18
|
-
}
|
|
19
|
-
function readInput(input, label, extra) {
|
|
20
|
-
const v = record(input, `${label} input`);
|
|
21
|
-
closed(v, ["scope", "namespace", "limit", ...extra], `${label} input`);
|
|
22
|
-
if (v.scope !== undefined && v.scope !== "namespace" && v.scope !== "world")
|
|
23
|
-
throw new TypeError("scope must be namespace or world");
|
|
24
|
-
const ns = namespace(v.namespace);
|
|
25
|
-
if (v.scope === "world" && ns !== undefined)
|
|
26
|
-
throw new TypeError("namespace and world scope are mutually exclusive");
|
|
27
|
-
debtRowViewLimit(v.limit);
|
|
28
|
-
return v;
|
|
29
|
-
}
|
|
30
|
-
async function selectedScope(at, input) {
|
|
31
|
-
if (input.scope === "world")
|
|
32
|
-
return { scope: "world" };
|
|
33
|
-
if (input.namespace !== undefined)
|
|
34
|
-
return { namespace: input.namespace };
|
|
35
|
-
const context = await resolveDebtNamespaceContext(at.debtContext);
|
|
36
|
-
return "kind" in context
|
|
37
|
-
? { kind: "refused", reason: context.kind, path: context.path }
|
|
38
|
-
: { namespace: context.namespace };
|
|
39
|
-
}
|
|
40
9
|
export async function debtAdd(at, input, document) {
|
|
41
10
|
const parsed = document ? addDocumentInput(input) : addInput(input);
|
|
42
11
|
if (document)
|
|
43
12
|
parseDebtCreationDocument(parsed.markdown);
|
|
44
|
-
const actor = resolveActor({ env: at.environment, ...(parsed.actor === undefined ? {} : { actor: parsed.actor }) });
|
|
45
13
|
const coord = await coordinates(at);
|
|
46
14
|
const world = coord.world ?? (await coord.establishWorld());
|
|
47
|
-
|
|
48
|
-
if ("kind" in scope)
|
|
49
|
-
return scope;
|
|
50
|
-
const composed = { ...parsed, ...scope, ...(actor === undefined ? {} : { actor }) };
|
|
51
|
-
return document ? addDebtDocument(world, composed) : addDebt(world, composed);
|
|
15
|
+
return document ? addDebtDocument(world, parsed) : addDebt(world, parsed);
|
|
52
16
|
}
|
|
53
17
|
export async function debtUpdate(at, input) {
|
|
54
18
|
const { id: raw, ...rest } = record(input, "update input");
|
|
@@ -60,129 +24,16 @@ export async function debtUpdate(at, input) {
|
|
|
60
24
|
updateInput(rest).signal?.throwIfAborted();
|
|
61
25
|
return missing();
|
|
62
26
|
}
|
|
63
|
-
export async function debtShow(at,
|
|
64
|
-
const v = record(input, "show input");
|
|
65
|
-
closed(v, ["id", "ids"], "show input");
|
|
66
|
-
if ((v.id === undefined) === (v.ids === undefined))
|
|
67
|
-
throw new TypeError("show requires id or ids");
|
|
68
|
-
const plural = v.ids !== undefined;
|
|
69
|
-
if (plural && (!Array.isArray(v.ids) || v.ids.length === 0))
|
|
70
|
-
throw new TypeError("ids requires at least one DebtId");
|
|
71
|
-
const ids = plural ? v.ids.map(debtId) : [debtId(v.id)];
|
|
72
|
-
const coord = await coordinates(at);
|
|
73
|
-
if (coord.world === null)
|
|
74
|
-
return absent;
|
|
75
|
-
const items = [];
|
|
76
|
-
for (const id of ids) {
|
|
77
|
-
const result = await Debts.of(coord.world).debt({ id }).read();
|
|
78
|
-
items.push(result.kind === "present" ? { ...result, kind: "found" } : result);
|
|
79
|
-
}
|
|
80
|
-
return { kind: "present", items };
|
|
81
|
-
}
|
|
82
|
-
export async function debtClose(at, input, verb) {
|
|
83
|
-
const v = record(input, "close input");
|
|
84
|
-
closed(v, ["ids", "note", "signal"], "close input");
|
|
85
|
-
const coord = await coordinates(at);
|
|
86
|
-
if (coord.world !== null)
|
|
87
|
-
return Debts.of(coord.world).batch({ ...input, verb });
|
|
88
|
-
const ids = debtIds(v.ids, "ids");
|
|
89
|
-
if (ids === undefined || ids.length === 0)
|
|
90
|
-
throw new TypeError("ids requires at least one DebtId");
|
|
91
|
-
text(v.note, "note");
|
|
92
|
-
signal(v.signal)?.throwIfAborted();
|
|
93
|
-
return { items: ids.map(() => missing()) };
|
|
94
|
-
}
|
|
95
|
-
export async function debtList(at, input) {
|
|
96
|
-
const v = readInput(input, "list", ["of", "selection"]);
|
|
97
|
-
if (v.of !== "debt")
|
|
98
|
-
throw new TypeError("of must be debt");
|
|
99
|
-
const selected = selection(v.selection), coord = await coordinates(at);
|
|
100
|
-
if (coord.world === null)
|
|
101
|
-
return absent;
|
|
102
|
-
const scope = await selectedScope(coord, input);
|
|
103
|
-
if ("kind" in scope)
|
|
104
|
-
return { kind: scope.reason, path: scope.path };
|
|
105
|
-
return Debts.of(coord.world).list({
|
|
106
|
-
...scope,
|
|
107
|
-
selection: selected,
|
|
108
|
-
...(input.limit === undefined ? {} : { limit: input.limit }),
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
export async function debtReady(at, input, blocked) {
|
|
112
|
-
const v = readInput(input, blocked ? "blocked" : "ready", ["parent"]);
|
|
113
|
-
if (v.parent !== undefined)
|
|
114
|
-
debtId(v.parent);
|
|
27
|
+
export async function debtShow(at, id) {
|
|
115
28
|
const coord = await coordinates(at);
|
|
116
|
-
|
|
117
|
-
return absent;
|
|
118
|
-
const scope = await selectedScope(coord, input);
|
|
119
|
-
if ("kind" in scope)
|
|
120
|
-
return scope;
|
|
121
|
-
const args = {
|
|
122
|
-
...scope,
|
|
123
|
-
...(input.parent === undefined ? {} : { parent: input.parent }),
|
|
124
|
-
...(input.limit === undefined ? {} : { limit: input.limit }),
|
|
125
|
-
};
|
|
126
|
-
return blocked ? Debts.of(coord.world).blocked(args) : Debts.of(coord.world).ready(args);
|
|
29
|
+
return coord.world === null ? absent : Debts.of(coord.world).read({ ids: [id] });
|
|
127
30
|
}
|
|
128
|
-
export async function
|
|
129
|
-
|
|
130
|
-
const selected = selection(v.selection);
|
|
131
|
-
if (v.where !== undefined)
|
|
132
|
-
normalizeDebtQuery(v.where);
|
|
133
|
-
sort(v.sort);
|
|
31
|
+
export async function debtLs(at, input) {
|
|
32
|
+
debtRowViewLimit(input.limit);
|
|
134
33
|
const coord = await coordinates(at);
|
|
135
|
-
|
|
136
|
-
return absent;
|
|
137
|
-
const scope = await selectedScope(coord, input);
|
|
138
|
-
if ("kind" in scope)
|
|
139
|
-
return scope;
|
|
140
|
-
return Debts.of(coord.world).query({
|
|
141
|
-
...scope,
|
|
142
|
-
where: debtQuerySelection(selected, input.where),
|
|
143
|
-
...(input.sort === undefined ? {} : { sort: input.sort }),
|
|
144
|
-
...(input.limit === undefined ? {} : { limit: input.limit }),
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
export async function debtTree(at, input) {
|
|
148
|
-
const v = record(input, "tree input");
|
|
149
|
-
closed(v, ["id"], "tree input");
|
|
150
|
-
const id = debtId(v.id), coord = await coordinates(at);
|
|
151
|
-
return coord.world === null ? absent : Debts.of(coord.world).debt({ id }).tree();
|
|
34
|
+
return coord.world === null ? { kind: "debt-catalogue", absent: true } : Debts.of(coord.world).list(input);
|
|
152
35
|
}
|
|
153
36
|
export async function debtDoctor(at) {
|
|
154
37
|
const coord = await coordinates(at);
|
|
155
38
|
return coord.world === null ? absent : Debts.of(coord.world).doctor();
|
|
156
39
|
}
|
|
157
|
-
export async function debtContext(at, input) {
|
|
158
|
-
const v = record(input, "context input");
|
|
159
|
-
closed(v, ["namespace"], "context input");
|
|
160
|
-
if (v.namespace !== undefined) {
|
|
161
|
-
try {
|
|
162
|
-
validateNamespaceContext(v.namespace);
|
|
163
|
-
}
|
|
164
|
-
catch (error) {
|
|
165
|
-
if (error instanceof TypeError)
|
|
166
|
-
throw new KeiyakuUsageError(error.message);
|
|
167
|
-
throw error;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
const coord = await coordinates(at);
|
|
171
|
-
if (v.namespace !== undefined) {
|
|
172
|
-
if (coord.world === null)
|
|
173
|
-
await coord.establishWorld();
|
|
174
|
-
await installNamespaceContext(coord.debtContext.writeRoot, v.namespace);
|
|
175
|
-
}
|
|
176
|
-
else if (coord.world === null)
|
|
177
|
-
return { kind: "present", source: "default-root" };
|
|
178
|
-
const resolved = await resolveDebtNamespaceContext(coord.debtContext);
|
|
179
|
-
if ("kind" in resolved)
|
|
180
|
-
return { kind: "refused", path: resolved.path };
|
|
181
|
-
if (resolved.source === "default-root")
|
|
182
|
-
return { kind: "present", source: resolved.source };
|
|
183
|
-
return {
|
|
184
|
-
kind: "present",
|
|
185
|
-
source: resolved.source,
|
|
186
|
-
...(resolved.namespace.length === 0 ? {} : { namespace: resolved.namespace.join("/") }),
|
|
187
|
-
};
|
|
188
|
-
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { contractIdSchema } from "../git/identity.js";
|
|
4
4
|
import { AkumaOwner } from "../akuma/akuma-owner.js";
|
|
5
|
+
import { KeiyakuError } from "../errors.js";
|
|
5
6
|
import { readHeart, readLatestTurnForBody } from "../akuma/heart/index.js";
|
|
6
7
|
import { akumaIdSchema, parseAkumaId, pathsForAkumaId } from "../akuma/identity.js";
|
|
7
8
|
import { Keis } from "./contract-composition.js";
|
|
@@ -15,7 +16,7 @@ export async function akumaCallerFromEnvironment(environment) {
|
|
|
15
16
|
const id = environment.KEIYAKU_ACTOR_ID;
|
|
16
17
|
const world = environment.KEIYAKU_ACTOR_WORLD;
|
|
17
18
|
if ((id === undefined) !== (world === undefined)) {
|
|
18
|
-
throw new
|
|
19
|
+
throw new KeiyakuError("invalid-input", "Akuma caller requires both KEIYAKU_ACTOR_ID and KEIYAKU_ACTOR_WORLD");
|
|
19
20
|
}
|
|
20
21
|
if (id !== undefined && world !== undefined) {
|
|
21
22
|
const resolved = await World.resolve({ cwd: world, repositoryRoot: world });
|
|
@@ -27,7 +28,7 @@ export async function akumaCallerFromEnvironment(environment) {
|
|
|
27
28
|
{ integration: "claude", variable: "CLAUDE_CODE_SESSION_ID", id: environment.CLAUDE_CODE_SESSION_ID },
|
|
28
29
|
].filter(({ id }) => id !== undefined && id !== "");
|
|
29
30
|
if (hosts.length > 1) {
|
|
30
|
-
throw new
|
|
31
|
+
throw new KeiyakuError("invalid-input", `Ambiguous native host caller: ${hosts.map(({ variable }) => variable).join(", ")}`);
|
|
31
32
|
}
|
|
32
33
|
if (hosts[0])
|
|
33
34
|
return decodeAkumaCaller({ kind: "external", integration: hosts[0].integration, id: hosts[0].id });
|
|
@@ -36,7 +37,7 @@ export async function akumaCallerFromEnvironment(environment) {
|
|
|
36
37
|
return undefined;
|
|
37
38
|
const colon = external.indexOf(":");
|
|
38
39
|
if (colon < 0)
|
|
39
|
-
throw new
|
|
40
|
+
throw new KeiyakuError("invalid-input", "KEIYAKU_EXTERNAL_CALLER must be <integration>:<id>");
|
|
40
41
|
return decodeAkumaCaller({ kind: "external", integration: external.slice(0, colon), id: external.slice(colon + 1) });
|
|
41
42
|
}
|
|
42
43
|
const unavailableSchema = z.strictObject({ kind: z.literal("unavailable"), diagnostic: z.string() }).readonly();
|
|
@@ -136,7 +137,7 @@ async function callerProfile(caller, coordinates, environment) {
|
|
|
136
137
|
const id = parseAkumaId(caller.akumaId);
|
|
137
138
|
const [status, aliases, repo] = await Promise.all([
|
|
138
139
|
new AkumaOwner(id.id, caller.world).status(),
|
|
139
|
-
observeNamedAddress({ world: caller.world, repo: null }),
|
|
140
|
+
observeNamedAddress({ world: caller.world, repo: null, selectors: [] }),
|
|
140
141
|
callerRepo(caller.world, coordinates, environment),
|
|
141
142
|
]);
|
|
142
143
|
if (aliases.aliases.kind !== "present") {
|