@astrosheep/keiyaku 4.0.3 → 4.0.5
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/.claude-plugin/plugin.json +1 -1
- package/build/integrations/marketplace/plugins/keiyaku/.codex-plugin/plugin.json +1 -1
- package/build/integrations/marketplace/plugins/keiyaku/package.json +1 -1
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +4 -4
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +1 -1
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/SKILL.md +15 -1
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-task/SKILL.md +3 -1
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +34 -13
- package/build/src/akuma/akuma.d.ts +34 -12
- package/build/src/akuma/akuma.js +118 -63
- package/build/src/akuma/allowed.d.ts +7 -0
- package/build/src/akuma/allowed.js +33 -0
- package/build/src/akuma/archetype.d.ts +7 -4
- package/build/src/akuma/archetype.js +15 -16
- package/build/src/akuma/body.d.ts +6 -1
- package/build/src/akuma/body.js +36 -27
- package/build/src/akuma/heart/facts.d.ts +82 -14
- package/build/src/akuma/heart/index.d.ts +5 -18
- package/build/src/akuma/heart/index.js +14 -84
- package/build/src/akuma/heart/request-authority.d.ts +12 -0
- package/build/src/akuma/heart/request-authority.js +119 -0
- package/build/src/akuma/heart/request-rows.d.ts +16 -0
- package/build/src/akuma/heart/request-rows.js +88 -0
- package/build/src/akuma/heart/rows.d.ts +1 -26
- package/build/src/akuma/heart/rows.js +0 -50
- package/build/src/akuma/heart/schema.d.ts +1 -1
- package/build/src/akuma/heart/schema.js +22 -10
- package/build/src/akuma/heart/soul.js +2 -36
- package/build/src/akuma/heart/storage.d.ts +1 -0
- package/build/src/akuma/heart/storage.js +15 -0
- package/build/src/akuma/heart/timeline.d.ts +1 -5
- package/build/src/akuma/heart/timeline.js +8 -17
- package/build/src/akuma/index.d.ts +5 -2
- package/build/src/akuma/index.js +1 -0
- package/build/src/akuma/projection.d.ts +17 -3
- package/build/src/akuma/projection.js +40 -3
- package/build/src/akuma/provider-recipe.js +1 -11
- package/build/src/akuma/provider.d.ts +2 -7
- package/build/src/akuma/provider.js +2 -1
- package/build/src/akuma/providers/acp/core.d.ts +3 -1
- package/build/src/akuma/providers/acp/core.js +10 -6
- package/build/src/akuma/providers/acp/events.d.ts +11 -3
- package/build/src/akuma/providers/acp/events.js +78 -4
- package/build/src/akuma/providers/acp/index.js +0 -1
- package/build/src/akuma/providers/claude/events.js +62 -3
- package/build/src/akuma/providers/claude/index.d.ts +0 -4
- package/build/src/akuma/providers/claude/index.js +7 -3
- package/build/src/akuma/providers/codex-app-server/events.js +1 -13
- package/build/src/akuma/providers/codex-app-server/index.d.ts +2 -27
- package/build/src/akuma/providers/codex-app-server/index.js +0 -2
- package/build/src/akuma/providers/grok-build/index.d.ts +2 -1
- package/build/src/akuma/providers/grok-build/index.js +72 -3
- package/build/src/akuma/providers/opencode-sdk/events.js +71 -6
- package/build/src/akuma/providers/opencode-sdk/index.d.ts +2 -28
- package/build/src/akuma/providers/opencode-sdk/index.js +8 -4
- package/build/src/akuma/providers/opencode-sdk/session.d.ts +1 -1
- package/build/src/akuma/providers/opencode-sdk/session.js +1 -1
- package/build/src/akuma/providers/pi/events.js +17 -3
- package/build/src/akuma/providers/pi/index.js +11 -4
- package/build/src/akuma/providers/unified-patch.d.ts +4 -0
- package/build/src/akuma/providers/unified-patch.js +14 -0
- package/build/src/akuma/publication.d.ts +1 -1
- package/build/src/akuma/publication.js +1 -1
- package/build/src/akuma/request-serve.d.ts +87 -0
- package/build/src/akuma/request-serve.js +484 -0
- package/build/src/akuma/request-wire.d.ts +124 -0
- package/build/src/akuma/request-wire.js +380 -0
- package/build/src/akuma/requests.d.ts +41 -41
- package/build/src/akuma/requests.js +75 -374
- package/build/src/akuma-body.d.ts +8 -0
- package/build/src/akuma-body.js +84 -0
- package/build/src/body/arc.js +4 -29
- package/build/src/body/decode.js +5 -39
- package/build/src/body/envelope.d.ts +7 -0
- package/build/src/body/envelope.js +37 -0
- package/build/src/cli/accepted.d.ts +4 -1
- package/build/src/cli/accepted.js +39 -9
- package/build/src/cli/commands/akuma-invoke.d.ts +8 -7
- package/build/src/cli/commands/akuma-invoke.js +18 -10
- package/build/src/cli/commands/akuma.d.ts +11 -2
- package/build/src/cli/commands/akuma.js +67 -28
- package/build/src/cli/commands/amend.d.ts +1 -1
- package/build/src/cli/commands/amend.js +1 -1
- package/build/src/cli/commands/contract.d.ts +8 -8
- package/build/src/cli/commands/contract.js +3 -3
- package/build/src/cli/commands/install.js +2 -2
- package/build/src/cli/commands/task-invoke.js +98 -9
- package/build/src/cli/commands/task-query.d.ts +1 -1
- package/build/src/cli/commands/task-query.js +11 -5
- package/build/src/cli/coordinates.d.ts +2 -0
- package/build/src/cli/coordinates.js +12 -5
- package/build/src/cli/invoke.d.ts +1 -0
- package/build/src/cli/invoke.js +116 -75
- package/build/src/cli/main.d.ts +2 -0
- package/build/src/cli/main.js +29 -4
- package/build/src/cli/parse.d.ts +3 -2
- package/build/src/cli/parse.js +25 -8
- package/build/src/cli/render/akuma.d.ts +2 -2
- package/build/src/cli/render/akuma.js +138 -24
- package/build/src/cli/render/audit.js +18 -8
- package/build/src/cli/render/contract.d.ts +2 -0
- package/build/src/cli/render/contract.js +243 -36
- package/build/src/cli/render/kanshi.js +64 -29
- package/build/src/cli/render/receipt.d.ts +2 -1
- package/build/src/cli/render/receipt.js +37 -2
- package/build/src/cli/render/terminal.d.ts +0 -2
- package/build/src/cli/render/terminal.js +0 -29
- package/build/src/cli/render/text.js +3 -1
- package/build/src/cli/result.d.ts +52 -9
- package/build/src/cli/selectors.d.ts +1 -0
- package/build/src/cli/selectors.js +9 -6
- package/build/src/contract-worktree.d.ts +1 -2
- package/build/src/contract-worktree.js +7 -9
- package/build/src/core/facts/codec.js +9 -0
- package/build/src/core/facts/fold.js +13 -1
- package/build/src/core/facts/types.d.ts +8 -1
- package/build/src/core/subject.js +4 -3
- package/build/src/core/verbs/placement.d.ts +9 -1
- package/build/src/core/verbs/placement.js +24 -6
- package/build/src/core/verbs/reintegrate.d.ts +13 -0
- package/build/src/core/verbs/reintegrate.js +24 -0
- package/build/src/dispatch/index.d.ts +1 -1
- package/build/src/dispatch/index.js +50 -39
- package/build/src/git/admission.d.ts +2 -1
- package/build/src/git/hooks.d.ts +0 -4
- package/build/src/git/hooks.js +0 -36
- package/build/src/git/integration.d.ts +7 -8
- package/build/src/git/integration.js +62 -9
- package/build/src/git/observe.d.ts +2 -1
- package/build/src/git/observe.js +6 -5
- package/build/src/git/process.d.ts +26 -0
- package/build/src/git/process.js +94 -0
- package/build/src/git/read-observation.d.ts +2 -1
- package/build/src/git/read-observation.js +3 -2
- package/build/src/git/reconcile.d.ts +8 -2
- package/build/src/git/reconcile.js +63 -14
- package/build/src/git/repository.d.ts +2 -29
- package/build/src/git/repository.js +4 -118
- package/build/src/git/scratch.d.ts +1 -1
- package/build/src/git/scratch.js +1 -1
- package/build/src/git/target-placement.d.ts +1 -1
- package/build/src/git/target-placement.js +9 -7
- package/build/src/git/tender.d.ts +20 -5
- package/build/src/git/tender.js +45 -13
- package/build/src/git/terminal-seal.d.ts +16 -2
- package/build/src/git/terminal-seal.js +15 -5
- package/build/src/git/workspace.d.ts +2 -1
- package/build/src/git/workspace.js +13 -5
- package/build/src/index.d.ts +1 -2
- package/build/src/index.js +1 -1
- package/build/src/kanshi/index.d.ts +1 -1
- package/build/src/kanshi/index.js +1 -1
- package/build/src/kanshi/read.d.ts +9 -1
- package/build/src/kanshi/read.js +91 -37
- package/build/src/kanshi/report.d.ts +1 -0
- package/build/src/library/address.d.ts +5 -14
- package/build/src/library/address.js +27 -23
- package/build/src/library/akuma-creation.d.ts +4 -2
- package/build/src/library/akuma-creation.js +43 -26
- package/build/src/library/audit.d.ts +2 -1
- package/build/src/library/audit.js +1 -1
- package/build/src/library/bind.d.ts +2 -1
- package/build/src/library/bind.js +4 -4
- package/build/src/library/catalog.d.ts +1 -2
- package/build/src/library/catalog.js +11 -6
- package/build/src/library/configuration.d.ts +5 -1
- package/build/src/library/configuration.js +71 -18
- package/build/src/library/contract.d.ts +70 -3
- package/build/src/library/contract.js +213 -27
- package/build/src/library/delivery.d.ts +1 -1
- package/build/src/library/fleet.d.ts +70 -12
- package/build/src/library/fleet.js +236 -56
- package/build/src/library/input.d.ts +0 -1
- package/build/src/library/input.js +1 -5
- package/build/src/library/keiyaku.d.ts +4 -4
- package/build/src/library/keiyaku.js +1 -2
- package/build/src/library/mutation.d.ts +2 -1
- package/build/src/library/reconcile.d.ts +2 -1
- package/build/src/library/reconcile.js +3 -1
- package/build/src/library/region.d.ts +1 -1
- package/build/src/library/repo.d.ts +3 -1
- package/build/src/library/repo.js +8 -4
- package/build/src/protocol/abandon.d.ts +9 -0
- package/build/src/protocol/abandon.js +15 -0
- package/build/src/protocol/amend.d.ts +16 -0
- package/build/src/protocol/amend.js +77 -0
- package/build/src/protocol/arc.d.ts +6 -0
- package/build/src/protocol/arc.js +12 -0
- package/build/src/protocol/attempt.d.ts +2 -1
- package/build/src/protocol/audit.d.ts +53 -0
- package/build/src/protocol/audit.js +140 -0
- package/build/src/protocol/bind.d.ts +2 -3
- package/build/src/protocol/bind.js +2 -16
- package/build/src/protocol/completion.d.ts +32 -0
- package/build/src/protocol/completion.js +130 -0
- package/build/src/protocol/deliver.d.ts +37 -0
- package/build/src/protocol/deliver.js +160 -0
- package/build/src/protocol/intent.d.ts +1 -1
- package/build/src/protocol/intent.js +1 -1
- package/build/src/protocol/operations.d.ts +65 -198
- package/build/src/protocol/operations.js +21 -634
- package/build/src/protocol/placement.d.ts +4 -13
- package/build/src/protocol/placement.js +3 -15
- package/build/src/protocol/read/status.d.ts +4 -2
- package/build/src/protocol/read/status.js +27 -15
- package/build/src/protocol/reconcile.d.ts +35 -0
- package/build/src/protocol/reconcile.js +41 -0
- package/build/src/protocol/reintegrate.d.ts +31 -0
- package/build/src/protocol/reintegrate.js +74 -0
- package/build/src/protocol/review.d.ts +33 -0
- package/build/src/protocol/review.js +148 -0
- package/build/src/protocol/run.d.ts +1 -1
- package/build/src/runtime/proc/run.d.ts +1 -0
- package/build/src/runtime/proc/run.js +9 -2
- package/build/src/settlement/fence.d.ts +1 -1
- package/build/src/settlement/holder.d.ts +1 -1
- package/build/src/settlement/settle.d.ts +2 -1
- package/build/src/settlement/settle.js +4 -1
- package/build/src/task/board.d.ts +18 -4
- package/build/src/task/board.js +73 -29
- package/build/src/task/compose.d.ts +1 -1
- package/build/src/task/compose.js +11 -4
- package/build/src/task/index.d.ts +4 -4
- package/build/src/task/index.js +8 -131
- package/build/src/task/input.d.ts +18 -0
- package/build/src/task/input.js +189 -0
- package/build/src/task/mutation.d.ts +39 -0
- package/build/src/task/mutation.js +85 -0
- package/build/src/task/operations.d.ts +4 -19
- package/build/src/task/operations.js +64 -18
- package/build/src/task/query.d.ts +9 -2
- package/build/src/task/query.js +32 -64
- package/build/src/task/store.js +0 -2
- package/build/src/verification/execution.d.ts +1 -1
- package/build/src/verification/execution.js +2 -1
- package/build/src/workspace-place.d.ts +1 -4
- package/build/src/workspace-place.js +0 -15
- package/package.json +5 -3
|
@@ -8,18 +8,28 @@ import { observeRegion } from "./region.js";
|
|
|
8
8
|
import { worktreeHooksOption } from "./configuration.js";
|
|
9
9
|
import { contractId, } from "../core/facts/types.js";
|
|
10
10
|
export { AuthorityCorruptionError } from "../core/facts/errors.js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { contractObservationOperation, contractsOperation, deliveryDiffOperation, deliveryOperation, stateOperation, } from "../protocol/operations.js";
|
|
12
|
+
import { abandonOperation } from "../protocol/abandon.js";
|
|
13
|
+
import { amendOperation } from "../protocol/amend.js";
|
|
14
|
+
import { arcOperation } from "../protocol/arc.js";
|
|
15
|
+
import { deliverOperation } from "../protocol/deliver.js";
|
|
16
|
+
import { reviewOperation } from "../protocol/review.js";
|
|
17
|
+
import { readDispatchesAt } from "../dispatch/index.js";
|
|
18
|
+
import { mintSnapshotId } from "../git/identity.js";
|
|
19
|
+
import { observeContractsForAdmissionInObservationAt } from "../git/observe.js";
|
|
20
|
+
import { withGitDecodeChannel, withGitReadObservation } from "../git/read-observation.js";
|
|
13
21
|
import { claimTaskHolderWithFence, releaseTaskHolder, releaseTaskHolderWithFence, taskHolderObservationSelection, } from "../settlement/holder.js";
|
|
14
22
|
import { parseTaskId } from "../task/identity.js";
|
|
15
23
|
import { reconcileInput, scopeForRepo } from "./repo.js";
|
|
24
|
+
import { injectedBodyRequests, requestBodyDeliver, requestBodyReview, } from "../akuma/requests.js";
|
|
16
25
|
import { auditContract } from "./audit.js";
|
|
17
26
|
import { Delivery, deliveryHandle } from "./delivery.js";
|
|
18
27
|
import { completeHolderMutation, completeMutation, } from "./mutation.js";
|
|
19
28
|
import { completeReconcile } from "./reconcile.js";
|
|
20
29
|
import { admitBindWithAppointment } from "./bind.js";
|
|
21
|
-
import { KeiyakuRefused, requireAccepted } from "./refusal.js";
|
|
22
|
-
export { KeiyakuRefused,
|
|
30
|
+
import { KeiyakuRefused, KeiyakuRetry, requireAccepted, } from "./refusal.js";
|
|
31
|
+
export { KeiyakuRefused, } from "./refusal.js";
|
|
32
|
+
export { KeiyakuRetry };
|
|
23
33
|
export { gatesFrom, requireBranchesToBeUpToDateFrom, SettingsError } from "./configuration.js";
|
|
24
34
|
export { Delivery };
|
|
25
35
|
function taskOption(value) {
|
|
@@ -38,6 +48,129 @@ function taskOption(value) {
|
|
|
38
48
|
function completion(scope, channel, id, value, hooks) {
|
|
39
49
|
return { scope, channel, contractId: id, value, hooks };
|
|
40
50
|
}
|
|
51
|
+
async function executeLocalDelivery(input) {
|
|
52
|
+
return withGitDecodeChannel(input.scope, async (channel) => {
|
|
53
|
+
const accepted = requireAccepted(await deliverOperation({
|
|
54
|
+
scope: input.scope,
|
|
55
|
+
channel,
|
|
56
|
+
contractId: input.contractId,
|
|
57
|
+
deriveDocument: (state) => documentDerivation(decodeContractDocument(state.terms.document.bytes), state.terms.gates, state.id),
|
|
58
|
+
...(input.actor === undefined ? {} : { actor: input.actor }),
|
|
59
|
+
...(input.message === undefined ? {} : { message: input.message }),
|
|
60
|
+
requireBranchesToBeUpToDate: input.requireBranchesToBeUpToDate,
|
|
61
|
+
includeDirty: input.includeDirty,
|
|
62
|
+
...(input.signal === undefined ? {} : { signal: input.signal }),
|
|
63
|
+
}));
|
|
64
|
+
return completeMutation({
|
|
65
|
+
...completion(input.scope, channel, input.contractId, (delivery) => delivery, input.hooks),
|
|
66
|
+
accepted,
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
async function executeLocalReview(input) {
|
|
71
|
+
return withGitDecodeChannel(input.scope, async (channel) => {
|
|
72
|
+
const accepted = requireAccepted(await reviewOperation({
|
|
73
|
+
scope: input.scope,
|
|
74
|
+
channel,
|
|
75
|
+
contractId: input.contractId,
|
|
76
|
+
deriveDocument: (state) => documentDerivation(decodeContractDocument(state.terms.document.bytes), state.terms.gates, state.id),
|
|
77
|
+
verdict: input.verdict,
|
|
78
|
+
...(input.summary === undefined ? {} : { summary: input.summary }),
|
|
79
|
+
...(input.actor === undefined ? {} : { actor: input.actor }),
|
|
80
|
+
}));
|
|
81
|
+
return completeMutation({
|
|
82
|
+
...completion(input.scope, channel, input.contractId, (review) => review, input.hooks),
|
|
83
|
+
accepted,
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function forwardedReceipt(outcome) {
|
|
88
|
+
if (outcome.kind === "failed") {
|
|
89
|
+
throw new Error(outcome.failure.kind === "failed"
|
|
90
|
+
? outcome.failure.diagnostic
|
|
91
|
+
: `Unexpected Akuma target failure for deliver: ${outcome.failure.id}`);
|
|
92
|
+
}
|
|
93
|
+
return outcome.result;
|
|
94
|
+
}
|
|
95
|
+
function forwardedReviewReceipt(outcome) {
|
|
96
|
+
if (outcome.kind === "failed") {
|
|
97
|
+
throw new Error(outcome.failure.kind === "failed"
|
|
98
|
+
? outcome.failure.diagnostic
|
|
99
|
+
: `Unexpected Akuma target failure for review: ${outcome.failure.id}`);
|
|
100
|
+
}
|
|
101
|
+
return outcome.result;
|
|
102
|
+
}
|
|
103
|
+
function requireForwardedDelivery(receipt) {
|
|
104
|
+
if (receipt.kind === "refused")
|
|
105
|
+
throw new KeiyakuRefused(receipt.refusal);
|
|
106
|
+
if (receipt.kind === "retry")
|
|
107
|
+
throw new KeiyakuRetry(receipt.reason);
|
|
108
|
+
return receipt.result;
|
|
109
|
+
}
|
|
110
|
+
function requireForwardedReview(receipt) {
|
|
111
|
+
if (receipt.kind === "refused")
|
|
112
|
+
throw new KeiyakuRefused(receipt.refusal);
|
|
113
|
+
if (receipt.kind === "retry")
|
|
114
|
+
throw new KeiyakuRetry(receipt.reason);
|
|
115
|
+
return receipt.result;
|
|
116
|
+
}
|
|
117
|
+
export async function executeForwardedDeliver(input) {
|
|
118
|
+
const id = contractId(input.contractId);
|
|
119
|
+
const actor = actorOption(input.requester).actor;
|
|
120
|
+
const message = optionalNonblank(input.message, "deliver message");
|
|
121
|
+
try {
|
|
122
|
+
const result = await executeLocalDelivery({
|
|
123
|
+
scope: scopeForRepo(input.repo),
|
|
124
|
+
contractId: id,
|
|
125
|
+
...(actor === undefined ? {} : { actor }),
|
|
126
|
+
...(message === undefined ? {} : { message }),
|
|
127
|
+
requireBranchesToBeUpToDate: input.requireBranchesToBeUpToDate,
|
|
128
|
+
includeDirty: input.includeDirty,
|
|
129
|
+
...(input.signal === undefined ? {} : { signal: input.signal }),
|
|
130
|
+
hooks: input.hooks,
|
|
131
|
+
});
|
|
132
|
+
const delivery = result.facts.find((fact) => fact.kind === "deliver");
|
|
133
|
+
if (delivery === undefined)
|
|
134
|
+
throw new Error("accepted delivery is missing its journal fact");
|
|
135
|
+
return { result: { kind: "accepted", result }, deliveryFactId: delivery.entry };
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
if (error instanceof KeiyakuRefused)
|
|
139
|
+
return { result: { kind: "refused", refusal: error.refusal } };
|
|
140
|
+
if (error instanceof KeiyakuRetry)
|
|
141
|
+
return { result: { kind: "retry", reason: error.reason } };
|
|
142
|
+
throw error;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
export async function executeForwardedReview(input) {
|
|
146
|
+
const id = contractId(input.contractId);
|
|
147
|
+
const actor = actorOption(input.requester).actor;
|
|
148
|
+
if (input.verdict !== "satisfied" && input.verdict !== "unsatisfied") {
|
|
149
|
+
throw new TypeError("verdict must be satisfied or unsatisfied");
|
|
150
|
+
}
|
|
151
|
+
const summary = optionalNonblank(input.summary, "review summary");
|
|
152
|
+
try {
|
|
153
|
+
const result = await executeLocalReview({
|
|
154
|
+
scope: scopeForRepo(input.repo),
|
|
155
|
+
contractId: id,
|
|
156
|
+
...(actor === undefined ? {} : { actor }),
|
|
157
|
+
verdict: input.verdict,
|
|
158
|
+
...(summary === undefined ? {} : { summary }),
|
|
159
|
+
hooks: input.hooks,
|
|
160
|
+
});
|
|
161
|
+
const review = result.facts.find((fact) => fact.kind === "attestation");
|
|
162
|
+
if (review === undefined)
|
|
163
|
+
throw new Error("accepted review is missing its journal fact");
|
|
164
|
+
return { result: { kind: "accepted", result }, reviewFactId: review.entry };
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
if (error instanceof KeiyakuRefused)
|
|
168
|
+
return { result: { kind: "refused", refusal: error.refusal } };
|
|
169
|
+
if (error instanceof KeiyakuRetry)
|
|
170
|
+
return { result: { kind: "retry", reason: error.reason } };
|
|
171
|
+
throw error;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
41
174
|
export class KeiyakuHandle {
|
|
42
175
|
id;
|
|
43
176
|
scope;
|
|
@@ -53,6 +186,38 @@ export class KeiyakuHandle {
|
|
|
53
186
|
contractId: this.id,
|
|
54
187
|
}));
|
|
55
188
|
}
|
|
189
|
+
async history() {
|
|
190
|
+
return withGitDecodeChannel(this.scope, (channel) => withGitReadObservation(this.scope, channel, async (observation) => {
|
|
191
|
+
const [journals, dispatches] = await Promise.all([
|
|
192
|
+
observeContractsForAdmissionInObservationAt(observation, [this.id]),
|
|
193
|
+
readDispatchesAt(observation),
|
|
194
|
+
]);
|
|
195
|
+
const record = journals.journals.get(this.id);
|
|
196
|
+
if (record === undefined)
|
|
197
|
+
throw new Error(`missing requested contract observation: ${this.id}`);
|
|
198
|
+
if (record.state === null)
|
|
199
|
+
throw new KeiyakuRefused({ kind: "contract-missing", contractId: this.id });
|
|
200
|
+
const commit = observation.snapshot.commit;
|
|
201
|
+
if (commit === null)
|
|
202
|
+
throw new Error("contract history requires a keiyaku-state snapshot");
|
|
203
|
+
const recordedAt = (event) => (event.source === "journal" ? event.fact.at : event.dispatch.dispatchedAt);
|
|
204
|
+
const events = [
|
|
205
|
+
...record.entries.map((fact) => ({ source: "journal", fact })),
|
|
206
|
+
...dispatches
|
|
207
|
+
.filter((dispatch) => dispatch.contractId === this.id)
|
|
208
|
+
.map((dispatch) => ({ source: "dispatch", dispatch })),
|
|
209
|
+
].sort((left, right) => {
|
|
210
|
+
const leftAt = recordedAt(left);
|
|
211
|
+
const rightAt = recordedAt(right);
|
|
212
|
+
if (leftAt !== rightAt)
|
|
213
|
+
return leftAt < rightAt ? -1 : 1;
|
|
214
|
+
if (left.source !== right.source)
|
|
215
|
+
return left.source === "journal" ? -1 : 1;
|
|
216
|
+
return 0;
|
|
217
|
+
});
|
|
218
|
+
return { id: this.id, state: mintSnapshotId(commit), events };
|
|
219
|
+
}));
|
|
220
|
+
}
|
|
56
221
|
async guidance() {
|
|
57
222
|
return withGitDecodeChannel(this.scope, async (channel) => {
|
|
58
223
|
const observed = await contractObservationOperation({ scope: this.scope, channel, contractId: this.id });
|
|
@@ -74,12 +239,15 @@ export class KeiyakuHandle {
|
|
|
74
239
|
async amend(input) {
|
|
75
240
|
const values = requireInput(input, "amend input");
|
|
76
241
|
const hooks = worktreeHooksOption(values.hooks);
|
|
77
|
-
const markdown = requireMarkdown(values.markdown);
|
|
242
|
+
const markdown = values.markdown === undefined ? undefined : requireMarkdown(values.markdown);
|
|
78
243
|
const actor = actorOption(values.actor);
|
|
79
244
|
const gates = values.gates === undefined ? undefined : normalizedGates(values.gates);
|
|
80
245
|
const prerequisites = values.after === undefined
|
|
81
246
|
? undefined
|
|
82
247
|
: normalizedList(values.after, "after", contractId);
|
|
248
|
+
if (markdown === undefined && gates === undefined && prerequisites === undefined) {
|
|
249
|
+
throw new TypeError("amend requires markdown, after, or gates");
|
|
250
|
+
}
|
|
83
251
|
return withGitDecodeChannel(this.scope, async (channel) => {
|
|
84
252
|
const accepted = requireAccepted(await amendOperation({
|
|
85
253
|
scope: this.scope,
|
|
@@ -87,8 +255,17 @@ export class KeiyakuHandle {
|
|
|
87
255
|
contractId: this.id,
|
|
88
256
|
...actor,
|
|
89
257
|
deriveAmendment: (source) => {
|
|
90
|
-
const document =
|
|
91
|
-
|
|
258
|
+
const document = markdown === undefined
|
|
259
|
+
? decodeContractDocument(source.document.bytes)
|
|
260
|
+
: decodeContractDocument(applyAmendDocument(markdown, decodeContractDocument(source.document.bytes)));
|
|
261
|
+
const terms = markdown === undefined
|
|
262
|
+
? {
|
|
263
|
+
document: source.document,
|
|
264
|
+
segments: source.segments,
|
|
265
|
+
gates: gates ?? source.gates,
|
|
266
|
+
after: prerequisites ?? source.after,
|
|
267
|
+
}
|
|
268
|
+
: contractTerms(document, gates ?? source.gates, prerequisites ?? source.after);
|
|
92
269
|
return {
|
|
93
270
|
terms,
|
|
94
271
|
verification: documentDerivation(document, terms.gates, this.id).verification,
|
|
@@ -114,23 +291,27 @@ export class KeiyakuHandle {
|
|
|
114
291
|
const includeDirty = optionalBoolean(values?.includeDirty, "includeDirty") ?? false;
|
|
115
292
|
const actor = actorOption(values?.actor);
|
|
116
293
|
const signal = optionalSignal(values?.signal);
|
|
117
|
-
|
|
118
|
-
|
|
294
|
+
const requests = injectedBodyRequests();
|
|
295
|
+
const result = requests === null
|
|
296
|
+
? await executeLocalDelivery({
|
|
119
297
|
scope: this.scope,
|
|
120
|
-
channel,
|
|
121
298
|
contractId: this.id,
|
|
122
|
-
deriveDocument: (state) => documentDerivation(decodeContractDocument(state.terms.document.bytes), state.terms.gates, state.id),
|
|
123
299
|
...actor,
|
|
124
300
|
...(message === undefined ? {} : { message }),
|
|
125
301
|
requireBranchesToBeUpToDate,
|
|
126
302
|
includeDirty,
|
|
127
303
|
...(signal === undefined ? {} : { signal }),
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
304
|
+
hooks,
|
|
305
|
+
})
|
|
306
|
+
: requireForwardedDelivery(forwardedReceipt(await requestBodyDeliver({
|
|
307
|
+
directory: requests,
|
|
308
|
+
repoRoot: this.scope.primaryWorktree,
|
|
309
|
+
contractId: this.id,
|
|
310
|
+
...(message === undefined ? {} : { message }),
|
|
311
|
+
includeDirty,
|
|
312
|
+
...(signal === undefined ? {} : { signal }),
|
|
313
|
+
})));
|
|
314
|
+
return { ...result, value: this.deliveryHandle(result.value) };
|
|
134
315
|
}
|
|
135
316
|
async review(input) {
|
|
136
317
|
const values = requireInput(input, "review input");
|
|
@@ -140,19 +321,24 @@ export class KeiyakuHandle {
|
|
|
140
321
|
throw new TypeError("verdict must be satisfied or unsatisfied");
|
|
141
322
|
}
|
|
142
323
|
const summary = optionalNonblank(values.summary, "review summary");
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
324
|
+
const actor = actorOption(values.actor);
|
|
325
|
+
const requests = injectedBodyRequests();
|
|
326
|
+
if (requests !== null) {
|
|
327
|
+
return requireForwardedReview(forwardedReviewReceipt(await requestBodyReview({
|
|
328
|
+
directory: requests,
|
|
329
|
+
repoRoot: this.scope.primaryWorktree,
|
|
147
330
|
contractId: this.id,
|
|
148
331
|
verdict,
|
|
149
332
|
...(summary === undefined ? {} : { summary }),
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
333
|
+
})));
|
|
334
|
+
}
|
|
335
|
+
return await executeLocalReview({
|
|
336
|
+
scope: this.scope,
|
|
337
|
+
contractId: this.id,
|
|
338
|
+
...actor,
|
|
339
|
+
verdict,
|
|
340
|
+
...(summary === undefined ? {} : { summary }),
|
|
341
|
+
hooks,
|
|
156
342
|
});
|
|
157
343
|
}
|
|
158
344
|
async abandon(input) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SnapshotId } from "../core/facts/types.js";
|
|
2
|
-
import type { DeliverValue } from "../protocol/
|
|
2
|
+
import type { DeliverValue } from "../protocol/deliver.js";
|
|
3
3
|
declare class DeliveryHandle {
|
|
4
4
|
private readonly readDiff;
|
|
5
5
|
readonly verification?: DeliverValue["verification"];
|
|
@@ -1,23 +1,54 @@
|
|
|
1
1
|
import { type ActivityHistory, type AkumaStatus, type InterruptReceipt, type KillEvidence, type TellResult } from "../akuma/index.js";
|
|
2
2
|
import type { ContractId } from "../core/facts/types.js";
|
|
3
|
+
import type { TaskRow } from "../task/index.js";
|
|
4
|
+
import type { WorldRoot } from "../world.js";
|
|
3
5
|
import { type AkumaAddressInput, type AkumaSetAddressInput } from "./address.js";
|
|
6
|
+
import { type Repo } from "./repo.js";
|
|
7
|
+
export type CreatedTaskObservation = Readonly<{
|
|
8
|
+
kind: "present";
|
|
9
|
+
rows: readonly TaskRow[];
|
|
10
|
+
}> | Readonly<{
|
|
11
|
+
kind: "failed";
|
|
12
|
+
diagnostic: string;
|
|
13
|
+
}>;
|
|
14
|
+
export type DispatchAssociation = Readonly<{
|
|
15
|
+
kind: "none";
|
|
16
|
+
}> | Readonly<{
|
|
17
|
+
kind: "associated";
|
|
18
|
+
contractId: ContractId;
|
|
19
|
+
}> | Readonly<{
|
|
20
|
+
kind: "failed";
|
|
21
|
+
diagnostic: string;
|
|
22
|
+
}>;
|
|
23
|
+
export type AkumaObservation = Readonly<{
|
|
24
|
+
status: AkumaStatus;
|
|
25
|
+
contract: DispatchAssociation;
|
|
26
|
+
createdTasks: CreatedTaskObservation;
|
|
27
|
+
}>;
|
|
28
|
+
export type AkumaObservationStage = (Readonly<{
|
|
29
|
+
kind: "observed";
|
|
30
|
+
}> & AkumaObservation) | Readonly<{
|
|
31
|
+
kind: "unobserved";
|
|
32
|
+
diagnostic: string;
|
|
33
|
+
}>;
|
|
34
|
+
export type AkumaUnobserved = Readonly<{
|
|
35
|
+
id: AkumaStatus["id"];
|
|
36
|
+
diagnostic: string;
|
|
37
|
+
}>;
|
|
4
38
|
export type AkumaWaitInput = AkumaSetAddressInput & Readonly<{
|
|
5
39
|
completion?: "any" | "all";
|
|
6
40
|
timeoutMs?: number;
|
|
7
41
|
}>;
|
|
8
42
|
export type AkumaWaitResult = Readonly<{
|
|
9
43
|
completion: "any" | "all";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export type AkumaStatusView = Readonly<{
|
|
13
|
-
status: AkumaStatus;
|
|
14
|
-
contractId?: ContractId;
|
|
44
|
+
observations: readonly AkumaObservation[];
|
|
45
|
+
unobserved: readonly AkumaUnobserved[];
|
|
15
46
|
}>;
|
|
16
47
|
export type AkumaKillResult = Readonly<{
|
|
17
48
|
results: readonly Readonly<{
|
|
18
49
|
id: AkumaStatus["id"];
|
|
19
50
|
evidence: KillEvidence;
|
|
20
|
-
observation:
|
|
51
|
+
observation: AkumaObservationStage;
|
|
21
52
|
}>[];
|
|
22
53
|
}>;
|
|
23
54
|
export type AkumaTellInput = AkumaAddressInput & Readonly<{
|
|
@@ -26,7 +57,7 @@ export type AkumaTellInput = AkumaAddressInput & Readonly<{
|
|
|
26
57
|
export type AkumaTellResult = Readonly<{
|
|
27
58
|
akuma: AkumaStatus["id"];
|
|
28
59
|
tell: TellResult;
|
|
29
|
-
observation:
|
|
60
|
+
observation: AkumaObservationStage;
|
|
30
61
|
}>;
|
|
31
62
|
export type AkumaInterruptInput = AkumaAddressInput & Readonly<{
|
|
32
63
|
body: string;
|
|
@@ -34,7 +65,7 @@ export type AkumaInterruptInput = AkumaAddressInput & Readonly<{
|
|
|
34
65
|
export type AkumaInterruptResult = Readonly<{
|
|
35
66
|
id: AkumaStatus["id"];
|
|
36
67
|
receipt: InterruptReceipt;
|
|
37
|
-
observation:
|
|
68
|
+
observation: AkumaObservationStage;
|
|
38
69
|
}>;
|
|
39
70
|
export type AkumaHistoryInput = AkumaAddressInput & Readonly<{
|
|
40
71
|
before?: number;
|
|
@@ -46,20 +77,47 @@ export type AkumaHistoryResult = Readonly<{
|
|
|
46
77
|
kind: "history";
|
|
47
78
|
id: AkumaStatus["id"];
|
|
48
79
|
history: ActivityHistory;
|
|
49
|
-
|
|
80
|
+
contract: DispatchAssociation;
|
|
50
81
|
}> | Readonly<{
|
|
51
82
|
kind: "last";
|
|
52
83
|
id: AkumaStatus["id"];
|
|
53
84
|
answer: string;
|
|
54
|
-
|
|
85
|
+
contract: DispatchAssociation;
|
|
55
86
|
}> | Readonly<{
|
|
56
87
|
kind: "no-answer";
|
|
57
88
|
id: AkumaStatus["id"];
|
|
58
|
-
|
|
89
|
+
contract: DispatchAssociation;
|
|
90
|
+
}>;
|
|
91
|
+
type WaitExecutionInput = Readonly<{
|
|
92
|
+
path: WorldRoot;
|
|
93
|
+
ids: readonly AkumaStatus["id"][];
|
|
94
|
+
completion: "any" | "all";
|
|
95
|
+
timeoutMs?: number;
|
|
96
|
+
repo?: Repo;
|
|
97
|
+
signal?: AbortSignal;
|
|
98
|
+
}>;
|
|
99
|
+
export declare function executeWaitAkuma(input: WaitExecutionInput): Promise<AkumaWaitResult>;
|
|
100
|
+
type TellExecutionInput = Readonly<{
|
|
101
|
+
path: WorldRoot;
|
|
102
|
+
id: AkumaStatus["id"];
|
|
103
|
+
body: string;
|
|
104
|
+
tellId?: string;
|
|
105
|
+
recordedAt?: string;
|
|
106
|
+
repo?: Repo;
|
|
107
|
+
signal?: AbortSignal;
|
|
108
|
+
}>;
|
|
109
|
+
export declare function executeTellAkuma(input: TellExecutionInput): Promise<AkumaTellResult>;
|
|
110
|
+
type KillExecutionInput = Readonly<{
|
|
111
|
+
path: WorldRoot;
|
|
112
|
+
ids: readonly AkumaStatus["id"][];
|
|
113
|
+
repo?: Repo;
|
|
114
|
+
signal?: AbortSignal;
|
|
59
115
|
}>;
|
|
60
|
-
export declare function
|
|
116
|
+
export declare function executeKillAkuma(input: KillExecutionInput): Promise<AkumaKillResult>;
|
|
117
|
+
export declare function statusAkuma(input: AkumaAddressInput): Promise<AkumaObservation>;
|
|
61
118
|
export declare function waitAkuma(input: AkumaWaitInput): Promise<AkumaWaitResult>;
|
|
62
119
|
export declare function killAkuma(input: AkumaSetAddressInput): Promise<AkumaKillResult>;
|
|
63
120
|
export declare function tellAkuma(input: AkumaTellInput): Promise<AkumaTellResult>;
|
|
64
121
|
export declare function interruptAkuma(input: AkumaInterruptInput): Promise<AkumaInterruptResult>;
|
|
65
122
|
export declare function historyAkuma(input: AkumaHistoryInput): Promise<AkumaHistoryResult>;
|
|
123
|
+
export {};
|