@astrosheep/keiyaku 4.5.11 → 4.5.13
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-workflow/SKILL.md +135 -377
- package/build/integrations/pi/keiyaku.ts +11 -116
- package/build/src/akuma/akuma-errors.d.ts +1 -0
- package/build/src/akuma/akuma-errors.js +1 -0
- package/build/src/akuma/akuma-handle.d.ts +1 -0
- package/build/src/akuma/akuma-handle.js +6 -7
- package/build/src/akuma/akuma-product.d.ts +6 -8
- package/build/src/akuma/akuma-product.js +141 -57
- package/build/src/akuma/akuma.d.ts +5 -7
- package/build/src/akuma/akuma.js +1 -22
- package/build/src/akuma/archetype.d.ts +6 -5
- package/build/src/akuma/archetype.js +137 -38
- package/build/src/akuma/body.d.ts +5 -5
- package/build/src/akuma/body.js +223 -63
- package/build/src/akuma/call-input.d.ts +4 -0
- package/build/src/akuma/call-input.js +21 -0
- package/build/src/akuma/call-request.d.ts +5 -8
- package/build/src/akuma/call-request.js +28 -73
- package/build/src/akuma/fleet-execution.d.ts +26 -0
- package/build/src/akuma/fleet-execution.js +109 -0
- package/build/src/{library/fleet-result.d.ts → akuma/fleet-observation.d.ts} +13 -57
- package/build/src/{library/fleet-result.js → akuma/fleet-observation.js} +4 -25
- package/build/src/akuma/fleet-request.d.ts +122 -0
- package/build/src/akuma/fleet-request.js +168 -0
- package/build/src/akuma/heart/facts.d.ts +23 -0
- package/build/src/akuma/heart/facts.js +7 -0
- package/build/src/akuma/heart/index.d.ts +43 -4
- package/build/src/akuma/heart/index.js +107 -7
- package/build/src/akuma/heart/request-authority.d.ts +2 -0
- package/build/src/akuma/heart/request-authority.js +28 -3
- package/build/src/akuma/heart/request-rows.d.ts +2 -0
- package/build/src/akuma/heart/request-rows.js +24 -5
- package/build/src/akuma/heart/rows.d.ts +4 -1
- package/build/src/akuma/heart/rows.js +46 -19
- package/build/src/akuma/heart/schema.d.ts +1 -1
- package/build/src/akuma/heart/schema.js +28 -6
- package/build/src/akuma/heart/storage.d.ts +1 -1
- package/build/src/akuma/heart/tells.d.ts +29 -0
- package/build/src/akuma/heart/tells.js +136 -5
- package/build/src/akuma/heart/timeline.js +9 -3
- package/build/src/akuma/projection-read.js +36 -3
- package/build/src/akuma/projection.js +3 -4
- package/build/src/akuma/provider.d.ts +4 -0
- package/build/src/akuma/provider.js +56 -3
- package/build/src/akuma/providers/claude/index.js +3 -0
- package/build/src/akuma/providers/codex-app-server/index.js +14 -12
- package/build/src/akuma/providers/pi/index.js +7 -1
- package/build/src/akuma/publication.js +65 -49
- package/build/src/akuma/request-lifecycle.d.ts +5 -4
- package/build/src/akuma/request-lifecycle.js +29 -16
- package/build/src/akuma/request-rendezvous.d.ts +15 -12
- package/build/src/akuma/request-rendezvous.js +80 -51
- package/build/src/akuma/request-serve.d.ts +1 -2
- package/build/src/akuma/request-serve.js +94 -39
- package/build/src/akuma/request-wire.d.ts +57 -26
- package/build/src/akuma/request-wire.js +64 -25
- package/build/src/akuma/turn-drive.d.ts +5 -4
- package/build/src/akuma/turn-drive.js +27 -11
- package/build/src/akuma-body.d.ts +4 -6
- package/build/src/akuma-body.js +19 -17
- package/build/src/bounded-list.d.ts +8 -0
- package/build/src/bounded-list.js +14 -0
- package/build/src/cli/accepted.d.ts +1 -1
- package/build/src/cli/accepted.js +1 -0
- package/build/src/cli/commands/akuma-invoke.js +1 -25
- package/build/src/cli/commands/contract-help.d.ts +5 -2
- package/build/src/cli/commands/contract-help.js +62 -12
- package/build/src/cli/commands/contract-invoke.d.ts +5 -0
- package/build/src/cli/commands/contract-invoke.js +26 -1
- package/build/src/cli/commands/contract.js +50 -18
- package/build/src/cli/commands/task-invoke.js +10 -2
- package/build/src/cli/commands/task-query.js +3 -4
- package/build/src/cli/coordinates.d.ts +13 -0
- package/build/src/cli/coordinates.js +38 -24
- package/build/src/cli/draft.d.ts +1 -1
- package/build/src/cli/invoke.js +14 -1
- package/build/src/cli/render/akuma-activity.d.ts +0 -1
- package/build/src/cli/render/akuma-activity.js +5 -38
- package/build/src/cli/render/akuma.js +4 -1
- package/build/src/cli/render/audit.js +4 -1
- package/build/src/cli/render/catalog.js +13 -39
- package/build/src/cli/render/contract.js +4 -14
- package/build/src/cli/render/kanshi-akuma.js +3 -8
- package/build/src/cli/render/kanshi.js +8 -34
- package/build/src/cli/render/nuke.js +7 -3
- package/build/src/cli/render/receipt.d.ts +1 -0
- package/build/src/cli/render/receipt.js +8 -0
- package/build/src/cli/render/refusal.js +4 -3
- package/build/src/cli/render/task.js +4 -37
- package/build/src/cli/render/terminal.d.ts +2 -6
- package/build/src/cli/render/terminal.js +4 -9
- package/build/src/cli/result.d.ts +2 -1
- package/build/src/contract-guidance.js +13 -3
- package/build/src/contract-worktree.d.ts +1 -0
- package/build/src/contract-worktree.js +26 -2
- package/build/src/core/facts/codec.d.ts +2 -1
- package/build/src/core/facts/codec.js +3 -0
- package/build/src/core/facts/gate.d.ts +2 -1
- package/build/src/core/facts/gate.js +63 -0
- package/build/src/core/verbs/abandon.d.ts +2 -1
- package/build/src/core/verbs/abandon.js +16 -0
- package/build/src/core/verbs/amend.d.ts +2 -1
- package/build/src/core/verbs/amend.js +20 -0
- package/build/src/core/verbs/arc.d.ts +2 -1
- package/build/src/core/verbs/arc.js +16 -0
- package/build/src/core/verbs/attestation.d.ts +2 -1
- package/build/src/core/verbs/attestation.js +16 -0
- package/build/src/core/verbs/bind.d.ts +2 -1
- package/build/src/core/verbs/bind.js +16 -0
- package/build/src/core/verbs/deliver.d.ts +2 -1
- package/build/src/core/verbs/deliver.js +16 -0
- package/build/src/core/verbs/placement.d.ts +2 -1
- package/build/src/core/verbs/placement.js +58 -1
- package/build/src/dispatch/association.d.ts +13 -0
- package/build/src/dispatch/association.js +20 -0
- package/build/src/dispatch/index.d.ts +6 -0
- package/build/src/dispatch/index.js +27 -3
- package/build/src/git/hooks.d.ts +9 -1
- package/build/src/git/hooks.js +79 -1
- package/build/src/git/nuke.d.ts +2 -1
- package/build/src/git/nuke.js +6 -11
- package/build/src/git/private-state-seat.d.ts +26 -1
- package/build/src/git/private-state-seat.js +78 -13
- package/build/src/git/process.d.ts +2 -0
- package/build/src/git/reconcile.d.ts +1 -2
- package/build/src/git/reconcile.js +0 -6
- package/build/src/git/repository.d.ts +0 -2
- package/build/src/git/repository.js +27 -25
- package/build/src/git/result-codec.d.ts +29 -0
- package/build/src/git/result-codec.js +306 -0
- package/build/src/git/target-placement.js +2 -8
- package/build/src/git/workspace.d.ts +2 -0
- package/build/src/git/workspace.js +4 -0
- package/build/src/index.d.ts +1 -0
- package/build/src/kanshi/fleet.js +1 -1
- package/build/src/kanshi/read.js +55 -28
- package/build/src/kanshi/report.d.ts +4 -3
- package/build/src/kanshi/select.js +14 -1
- package/build/src/library/address.d.ts +1 -0
- package/build/src/library/address.js +4 -7
- package/build/src/library/akuma-creation.d.ts +5 -3
- package/build/src/library/akuma-creation.js +90 -33
- package/build/src/library/audit.js +2 -1
- package/build/src/library/catalog.d.ts +10 -2
- package/build/src/library/catalog.js +65 -25
- package/build/src/library/composition.d.ts +1 -0
- package/build/src/library/composition.js +1 -0
- package/build/src/library/configuration.d.ts +4 -21
- package/build/src/library/configuration.js +2 -158
- package/build/src/library/continuation.d.ts +20 -1
- package/build/src/library/continuation.js +36 -0
- package/build/src/library/contract-bind.d.ts +1 -0
- package/build/src/library/contract-bind.js +16 -5
- package/build/src/library/contract-forwarding.d.ts +2 -2
- package/build/src/library/contract-forwarding.js +18 -4
- package/build/src/library/contract-handle.js +4 -3
- package/build/src/library/contract-operations.d.ts +5 -9
- package/build/src/library/contract-operations.js +34 -47
- package/build/src/library/contract.d.ts +11 -2
- package/build/src/library/contract.js +21 -1
- package/build/src/library/delivery.d.ts +4 -1
- package/build/src/library/delivery.js +47 -0
- package/build/src/library/fleet.d.ts +4 -136
- package/build/src/library/fleet.js +31 -315
- package/build/src/library/keiyaku.d.ts +7 -3
- package/build/src/library/keiyaku.js +1 -0
- package/build/src/library/mutation.d.ts +431 -3
- package/build/src/library/mutation.js +192 -19
- package/build/src/library/nuke.d.ts +7 -1
- package/build/src/library/nuke.js +18 -4
- package/build/src/library/reconcile.d.ts +14 -0
- package/build/src/library/reconcile.js +22 -8
- package/build/src/library/refusal.d.ts +9 -1
- package/build/src/library/refusal.js +76 -0
- package/build/src/library/region.d.ts +0 -8
- package/build/src/library/region.js +1 -29
- package/build/src/library/result-codec.d.ts +2 -0
- package/build/src/library/result-codec.js +12 -0
- package/build/src/markdown/lex.js +9 -2
- package/build/src/markdown/types.d.ts +2 -1
- package/build/src/markdown/types.js +3 -1
- package/build/src/plugin/akuma-signals.d.ts +12 -0
- package/build/src/plugin/akuma-signals.js +14 -0
- package/build/src/plugin/public.d.ts +51 -0
- package/build/src/plugin/public.js +1 -0
- package/build/src/plugin/runtime.d.ts +14 -0
- package/build/src/plugin/runtime.js +357 -0
- package/build/src/protocol/amend.js +3 -3
- package/build/src/protocol/attempt.d.ts +2 -1
- package/build/src/protocol/attempt.js +1 -1
- package/build/src/protocol/audit.d.ts +1 -1
- package/build/src/protocol/audit.js +1 -1
- package/build/src/protocol/bind.d.ts +3 -1
- package/build/src/protocol/bind.js +26 -0
- package/build/src/protocol/completion.js +0 -1
- package/build/src/protocol/deliver.d.ts +1 -1
- package/build/src/protocol/deliver.js +136 -57
- package/build/src/protocol/intent.d.ts +0 -1
- package/build/src/protocol/intent.js +0 -1
- package/build/src/protocol/operations.d.ts +9 -2
- package/build/src/protocol/operations.js +16 -1
- package/build/src/protocol/outcome.d.ts +3 -0
- package/build/src/protocol/outcome.js +17 -1
- package/build/src/protocol/placement.js +10 -3
- package/build/src/protocol/read/status.d.ts +8 -0
- package/build/src/protocol/read/status.js +49 -0
- package/build/src/protocol/reintegrate.js +10 -3
- package/build/src/protocol/result-codec.d.ts +22 -0
- package/build/src/protocol/result-codec.js +442 -0
- package/build/src/protocol/review.d.ts +1 -1
- package/build/src/protocol/review.js +81 -46
- package/build/src/protocol/run.d.ts +22 -2
- package/build/src/protocol/run.js +119 -29
- package/build/src/runtime/proc/lifecycle.js +1 -1
- package/build/src/runtime/proc/line-rpc.d.ts +7 -1
- package/build/src/runtime/proc/line-rpc.js +49 -9
- package/build/src/runtime/proc/run.d.ts +0 -1
- package/build/src/runtime/proc/run.js +1 -11
- package/build/src/runtime/proc/termination.d.ts +1 -0
- package/build/src/runtime/proc/termination.js +63 -18
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/build/src/settings.d.ts +10 -0
- package/build/src/settings.js +88 -2
- package/build/src/settlement/result-codec.d.ts +2 -0
- package/build/src/settlement/result-codec.js +56 -0
- package/build/src/settlement/settle.d.ts +5 -12
- package/build/src/settlement/settle.js +60 -55
- package/build/src/task/board.d.ts +3 -0
- package/build/src/task/board.js +22 -4
- package/build/src/task/catalog.d.ts +13 -2
- package/build/src/task/catalog.js +59 -5
- package/build/src/task/compose.d.ts +4 -2
- package/build/src/task/compose.js +56 -30
- package/build/src/task/created-observation.d.ts +39 -0
- package/build/src/task/created-observation.js +26 -0
- package/build/src/task/identity.d.ts +6 -0
- package/build/src/task/identity.js +48 -7
- package/build/src/task/index.d.ts +4 -3
- package/build/src/task/index.js +19 -16
- package/build/src/task/input.d.ts +3 -1
- package/build/src/task/input.js +7 -4
- package/build/src/task/lifecycle-operations.d.ts +6 -0
- package/build/src/task/lifecycle-operations.js +116 -0
- package/build/src/task/mutation-result.d.ts +762 -20
- package/build/src/task/mutation-result.js +34 -9
- package/build/src/task/mutation.d.ts +4 -9
- package/build/src/task/mutation.js +17 -52
- package/build/src/task/operation-types.d.ts +114 -0
- package/build/src/task/operation-types.js +1 -0
- package/build/src/task/operations.d.ts +6 -113
- package/build/src/task/operations.js +75 -117
- package/build/src/task/query.d.ts +8 -11
- package/build/src/task/query.js +7 -14
- package/build/src/task/store.d.ts +11 -1
- package/build/src/task/store.js +169 -55
- package/build/src/task/view.d.ts +4 -0
- package/build/src/task/view.js +7 -0
- package/build/src/verification/declaration.d.ts +1 -0
- package/build/src/verification/declaration.js +18 -1
- package/build/src/verification/execution.d.ts +0 -1
- package/build/src/verification/execution.js +5 -5
- package/build/src/world.d.ts +0 -2
- package/build/src/world.js +3 -7
- package/package.json +17 -5
- package/build/src/cli/square-edge.d.ts +0 -7
- package/build/src/cli/square-edge.js +0 -159
- package/build/src/git/ref-migration.d.ts +0 -22
- package/build/src/git/ref-migration.js +0 -55
- package/build/src/library/contract-forwarding-reconciliation-result.d.ts +0 -102
- package/build/src/library/contract-forwarding-reconciliation-result.js +0 -92
- package/build/src/library/contract-forwarding-result.d.ts +0 -4270
- package/build/src/library/contract-forwarding-result.js +0 -521
|
@@ -1,47 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
import { Akuma, AkumaNotBornError,
|
|
3
|
-
import { readBudgetedStatus
|
|
4
|
-
import { executionChannel, localExecutionContext
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
/** @architectureCompositionRoot */
|
|
2
|
+
import { Akuma, AkumaNotBornError, } from "../akuma/index.js";
|
|
3
|
+
import { readBudgetedStatus } from "../akuma/akuma.js";
|
|
4
|
+
import { executionChannel, localExecutionContext } from "../akuma/requests.js";
|
|
5
|
+
import { requestForwardedFleetKill, requestForwardedFleetTell, requestForwardedFleetWait, } from "../akuma/fleet-request.js";
|
|
6
|
+
import { executeKillAkuma, executeTellAkuma, executeWaitAkuma } from "../akuma/fleet-execution.js";
|
|
7
|
+
import { observeDispatchAssociation } from "../dispatch/index.js";
|
|
8
|
+
import { observeCreatedTaskObservations } from "../task/created-observation.js";
|
|
8
9
|
import { addressAkuma, addressAkumaSet } from "./address.js";
|
|
9
10
|
import { requireInput } from "./input.js";
|
|
10
|
-
import {
|
|
11
|
+
import { fleetResultSchemas, parseAkumaObservation, } from "../akuma/fleet-observation.js";
|
|
11
12
|
import { scopeForRepo } from "./repo.js";
|
|
12
13
|
import { parsePublicHistoryId } from "../akuma/identity.js";
|
|
13
|
-
import { z } from "zod";
|
|
14
14
|
function source(path) {
|
|
15
15
|
return Akuma.of(path);
|
|
16
16
|
}
|
|
17
17
|
function observationDiagnostic(error) {
|
|
18
18
|
return error instanceof Error ? error.message : String(error);
|
|
19
19
|
}
|
|
20
|
-
const NO_DISPATCH = { kind: "none" };
|
|
21
20
|
async function dispatchAssociation(repo, id) {
|
|
22
|
-
|
|
23
|
-
return NO_DISPATCH;
|
|
24
|
-
try {
|
|
25
|
-
const dispatch = await readDispatch(scopeForRepo(repo), id);
|
|
26
|
-
return dispatch === null ? NO_DISPATCH : { kind: "associated", contractId: dispatch.contractId };
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
return { kind: "failed", diagnostic: observationDiagnostic(error) };
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
function createdTaskDiagnostic(error) {
|
|
33
|
-
return observationDiagnostic(error);
|
|
21
|
+
return await observeDispatchAssociation(repo === undefined ? undefined : scopeForRepo(repo), id);
|
|
34
22
|
}
|
|
35
23
|
async function createdTasksFor(path, statuses) {
|
|
36
|
-
|
|
37
|
-
try {
|
|
38
|
-
board = await observeTaskBoard(path);
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
const failed = { kind: "failed", diagnostic: createdTaskDiagnostic(error) };
|
|
42
|
-
return statuses.map(() => failed);
|
|
43
|
-
}
|
|
44
|
-
return statuses.map((status) => parseCreatedTaskObservation({ kind: "present", rows: board.selectCreatedBy(status.id) }));
|
|
24
|
+
return await observeCreatedTaskObservations(path, statuses.map((status) => status.id));
|
|
45
25
|
}
|
|
46
26
|
async function observeAkuma(status, path, repo) {
|
|
47
27
|
return (await observeAkumaSet([status], path, repo))[0];
|
|
@@ -76,269 +56,15 @@ function timeout(value) {
|
|
|
76
56
|
}
|
|
77
57
|
return value;
|
|
78
58
|
}
|
|
79
|
-
function
|
|
80
|
-
|
|
81
|
-
let timer;
|
|
82
|
-
const done = () => {
|
|
83
|
-
signal?.removeEventListener("abort", abort);
|
|
84
|
-
resolve();
|
|
85
|
-
};
|
|
86
|
-
const abort = () => {
|
|
87
|
-
clearTimeout(timer);
|
|
88
|
-
signal?.removeEventListener("abort", abort);
|
|
89
|
-
reject(signal?.reason ?? new Error("upstream request aborted"));
|
|
90
|
-
};
|
|
91
|
-
timer = setTimeout(done, milliseconds);
|
|
92
|
-
if (signal?.aborted)
|
|
93
|
-
abort();
|
|
94
|
-
else
|
|
95
|
-
signal?.addEventListener("abort", abort, { once: true });
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
const SHARED_ORDINARY_BUDGET = 30;
|
|
99
|
-
const POLL_MS = 100;
|
|
100
|
-
async function observeWaitRound(path, ids, signal) {
|
|
101
|
-
signal?.throwIfAborted();
|
|
102
|
-
if (ids.length <= 1) {
|
|
103
|
-
return {
|
|
104
|
-
statuses: await Promise.all(ids.map(async (id) => await source(path).of({ id }).status())),
|
|
105
|
-
unobserved: [],
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
let remaining = SHARED_ORDINARY_BUDGET;
|
|
109
|
-
const statuses = [];
|
|
110
|
-
const unobserved = [];
|
|
111
|
-
for (const id of ids) {
|
|
112
|
-
signal?.throwIfAborted();
|
|
113
|
-
try {
|
|
114
|
-
const observed = await readBudgetedStatus(path, id, { aperture: "monitoring", ordinaryBudget: remaining });
|
|
115
|
-
statuses.push(observed.status);
|
|
116
|
-
remaining -= observed.ordinarySelected;
|
|
117
|
-
}
|
|
118
|
-
catch (error) {
|
|
119
|
-
if (error instanceof AkumaNotBornError)
|
|
120
|
-
throw error;
|
|
121
|
-
unobserved.push({ id, diagnostic: observationDiagnostic(error) });
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return { statuses, unobserved };
|
|
125
|
-
}
|
|
126
|
-
export async function executeWaitAkuma(input) {
|
|
127
|
-
const deadline = input.timeoutMs === undefined ? undefined : performance.now() + input.timeoutMs;
|
|
128
|
-
for (;;) {
|
|
129
|
-
const round = await observeWaitRound(input.path, input.ids, input.signal);
|
|
130
|
-
const settled = round.statuses.map(defaultWaitComplete);
|
|
131
|
-
const completed = round.statuses.length > 0 &&
|
|
132
|
-
(input.completion === "any" ? settled.some(Boolean) : round.unobserved.length === 0 && settled.every(Boolean));
|
|
133
|
-
if (completed || (deadline !== undefined && performance.now() >= deadline)) {
|
|
134
|
-
return fleetResultSchemas.wait.parse({
|
|
135
|
-
completion: input.completion,
|
|
136
|
-
observations: await observeAkumaSet(round.statuses, input.path, input.repo),
|
|
137
|
-
unobserved: round.unobserved,
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
await delay(deadline === undefined ? POLL_MS : Math.min(POLL_MS, Math.max(0, deadline - performance.now())), input.signal);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
export async function executeTellAkuma(input) {
|
|
144
|
-
input.signal?.throwIfAborted();
|
|
145
|
-
const handle = source(input.path).of({ id: input.id });
|
|
146
|
-
const tell = input.tellId === undefined
|
|
147
|
-
? await handle.tell(input.body)
|
|
148
|
-
: await tellAkumaWithId({
|
|
149
|
-
worldPath: input.path,
|
|
150
|
-
id: input.id,
|
|
151
|
-
body: input.body,
|
|
152
|
-
tellId: input.tellId,
|
|
153
|
-
...(input.recordedAt === undefined ? {} : { recordedAt: input.recordedAt }),
|
|
154
|
-
});
|
|
155
|
-
input.signal?.throwIfAborted();
|
|
156
|
-
return fleetResultSchemas.tell.parse({
|
|
157
|
-
akuma: input.id,
|
|
158
|
-
tell,
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
export async function executeKillAkuma(input) {
|
|
162
|
-
input.signal?.throwIfAborted();
|
|
163
|
-
const handles = input.ids.map((id) => source(input.path).of({ id }));
|
|
164
|
-
const evidence = await Promise.all(handles.map(async (handle) => await handle.kill()));
|
|
165
|
-
input.signal?.throwIfAborted();
|
|
166
|
-
return fleetResultSchemas.kill.parse({
|
|
167
|
-
results: input.ids.map((id, index) => ({ id, evidence: evidence[index] })),
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
function forwardedFleetCommandResult(response, action) {
|
|
171
|
-
if (response.kind === "returned") {
|
|
172
|
-
if (action === "akuma.wait" && isWaitResult(response.result))
|
|
173
|
-
return response.result;
|
|
174
|
-
if (action === "akuma.tell" && isTellResult(response.result))
|
|
175
|
-
return response.result;
|
|
176
|
-
if (action === "akuma.kill" && isKillResult(response.result))
|
|
177
|
-
return response.result;
|
|
178
|
-
throw new Error(`transport integrity: request Fleet ${action} returned an invalid live result`);
|
|
179
|
-
}
|
|
180
|
-
throw new Error("Akuma body request terminal Fleet reference cannot reproduce an expired live result");
|
|
181
|
-
}
|
|
182
|
-
const nonblankTextSchema = z.string().refine((value) => value.trim() !== "");
|
|
183
|
-
const fleetTargetsSchema = z
|
|
184
|
-
.array(akumaIdSchema)
|
|
185
|
-
.min(1)
|
|
186
|
-
.superRefine((ids, context) => {
|
|
187
|
-
if (ids.some((id, index) => index > 0 && ids[index - 1] >= id))
|
|
188
|
-
context.addIssue({ code: "custom", message: "expected a strictly ordered target set" });
|
|
189
|
-
});
|
|
190
|
-
const waitRequestSchema = z
|
|
191
|
-
.object({
|
|
192
|
-
targets: fleetTargetsSchema,
|
|
193
|
-
completion: z.enum(["any", "all"]),
|
|
194
|
-
timeoutMs: z.number().int().nonnegative().optional(),
|
|
195
|
-
})
|
|
196
|
-
.strict()
|
|
197
|
-
.transform(({ timeoutMs, ...request }) => ({
|
|
198
|
-
action: "akuma.wait",
|
|
199
|
-
...request,
|
|
200
|
-
...(timeoutMs === undefined ? {} : { timeoutMs }),
|
|
201
|
-
}));
|
|
202
|
-
const tellRequestSchema = z
|
|
203
|
-
.object({ target: akumaIdSchema, body: z.string() })
|
|
204
|
-
.strict()
|
|
205
|
-
.transform((request) => ({ action: "akuma.tell", ...request }));
|
|
206
|
-
const killRequestSchema = z
|
|
207
|
-
.object({ targets: fleetTargetsSchema })
|
|
208
|
-
.strict()
|
|
209
|
-
.transform((request) => ({ action: "akuma.kill", ...request }));
|
|
210
|
-
const waitServiceSchema = z.object({ action: z.literal("akuma.wait") }).strict();
|
|
211
|
-
const tellServiceSchema = z
|
|
212
|
-
.object({ action: z.literal("akuma.tell"), target: akumaIdSchema, tellId: nonblankTextSchema })
|
|
213
|
-
.strict();
|
|
214
|
-
const killServiceSchema = z
|
|
215
|
-
.object({
|
|
216
|
-
action: z.literal("akuma.kill"),
|
|
217
|
-
results: z.array(z.object({ id: akumaIdSchema, evidence: fleetResultSchemas.killEvidence }).strict()),
|
|
218
|
-
})
|
|
219
|
-
.strict();
|
|
220
|
-
function decodeFleetExecutionContext(value) {
|
|
221
|
-
const context = fleetPayload(value);
|
|
222
|
-
if (context === null ||
|
|
223
|
-
typeof context.id !== "string" ||
|
|
224
|
-
context.id.trim() === "" ||
|
|
225
|
-
typeof context.admittedAt !== "string" ||
|
|
226
|
-
!isAbortSignal(context.signal) ||
|
|
227
|
-
!isFleetRequestPort(context.upstream))
|
|
228
|
-
throw new Error("invalid Fleet execution context");
|
|
229
|
-
return {
|
|
230
|
-
id: context.id,
|
|
231
|
-
admittedAt: context.admittedAt,
|
|
232
|
-
signal: context.signal,
|
|
233
|
-
upstream: context.upstream,
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
function isAbortSignal(value) {
|
|
237
|
-
return (value !== null &&
|
|
238
|
-
typeof value === "object" &&
|
|
239
|
-
typeof value.throwIfAborted === "function");
|
|
240
|
-
}
|
|
241
|
-
function isFleetRequestPort(value) {
|
|
242
|
-
const port = fleetPayload(value);
|
|
243
|
-
return (port !== null &&
|
|
244
|
-
typeof port.wait === "function" &&
|
|
245
|
-
typeof port.tell === "function" &&
|
|
246
|
-
typeof port.kill === "function");
|
|
247
|
-
}
|
|
248
|
-
function fleetPayload(value) {
|
|
249
|
-
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
250
|
-
? value
|
|
251
|
-
: null;
|
|
252
|
-
}
|
|
253
|
-
function decodeFleetRequest(action, value) {
|
|
254
|
-
const schema = action === "akuma.wait" ? waitRequestSchema : action === "akuma.tell" ? tellRequestSchema : killRequestSchema;
|
|
255
|
-
const parsed = schema.safeParse(value);
|
|
256
|
-
return parsed.success ? parsed.data : null;
|
|
257
|
-
}
|
|
258
|
-
function decodeFleetService(action, value) {
|
|
259
|
-
const schema = action === "akuma.wait" ? waitServiceSchema : action === "akuma.tell" ? tellServiceSchema : killServiceSchema;
|
|
260
|
-
const parsed = schema.safeParse(value);
|
|
261
|
-
if (!parsed.success)
|
|
262
|
-
throw new Error("malformed stored Fleet service evidence");
|
|
263
|
-
return parsed.data;
|
|
264
|
-
}
|
|
265
|
-
/** Fleet owns its Body Request payload, live result, and durable service codecs. */
|
|
266
|
-
export function fleetRequestCommand(action) {
|
|
267
|
-
return {
|
|
268
|
-
action,
|
|
269
|
-
encodeRequest: (request) => {
|
|
270
|
-
const { action: _action, ...payload } = request;
|
|
271
|
-
return payload;
|
|
272
|
-
},
|
|
273
|
-
decodeRequest: (payload) => decodeFleetRequest(action, payload),
|
|
274
|
-
encodeResult: (result) => result,
|
|
275
|
-
decodeResult: (result) => {
|
|
276
|
-
const schema = action === "akuma.wait"
|
|
277
|
-
? fleetResultSchemas.wait
|
|
278
|
-
: action === "akuma.tell"
|
|
279
|
-
? fleetResultSchemas.tell
|
|
280
|
-
: fleetResultSchemas.kill;
|
|
281
|
-
const parsed = schema.safeParse(result);
|
|
282
|
-
if (!parsed.success)
|
|
283
|
-
throw new Error(`Akuma body request returned an invalid live result for ${action}`);
|
|
284
|
-
return parsed.data;
|
|
285
|
-
},
|
|
286
|
-
encodeService: (service) => decodeFleetService(action, service),
|
|
287
|
-
decodeService: (service) => decodeFleetService(action, service),
|
|
288
|
-
projectService: (service) => decodeFleetService(action, service),
|
|
289
|
-
decodeReference: (reference) => decodeFleetService(action, reference),
|
|
290
|
-
isPermitted: (allowed) => action === "akuma.wait" || allowed.includes(action),
|
|
291
|
-
decodeExecutionContext: decodeFleetExecutionContext,
|
|
292
|
-
execute: async (request, context) => {
|
|
293
|
-
if (request.action === "akuma.wait") {
|
|
294
|
-
return {
|
|
295
|
-
result: await context.upstream.wait({ ...request, signal: context.signal }),
|
|
296
|
-
service: { action: request.action },
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
if (request.action === "akuma.tell") {
|
|
300
|
-
return {
|
|
301
|
-
result: await context.upstream.tell({
|
|
302
|
-
target: request.target,
|
|
303
|
-
body: request.body,
|
|
304
|
-
tellId: context.id,
|
|
305
|
-
recordedAt: context.admittedAt,
|
|
306
|
-
signal: context.signal,
|
|
307
|
-
}),
|
|
308
|
-
service: { action: request.action, target: request.target, tellId: context.id },
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
const result = await context.upstream.kill({ targets: request.targets, signal: context.signal });
|
|
312
|
-
if ("result" in result)
|
|
313
|
-
return { result: result.result, service: { action: request.action, results: result.service } };
|
|
314
|
-
return {
|
|
315
|
-
result,
|
|
316
|
-
service: { action: request.action, results: result.results.map(({ id, evidence }) => ({ id, evidence })) },
|
|
317
|
-
};
|
|
318
|
-
},
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
export function fleetRequestCommands() {
|
|
322
|
-
return {
|
|
323
|
-
"akuma.wait": eraseRequestCommand(fleetRequestCommand("akuma.wait")),
|
|
324
|
-
"akuma.tell": eraseRequestCommand(fleetRequestCommand("akuma.tell")),
|
|
325
|
-
"akuma.kill": eraseRequestCommand(fleetRequestCommand("akuma.kill")),
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
function needsDispatchAttach(association) {
|
|
329
|
-
return association.kind === "none";
|
|
330
|
-
}
|
|
331
|
-
async function attachObservationContract(repo, observation) {
|
|
332
|
-
if (repo === undefined || !needsDispatchAttach(observation.contract))
|
|
333
|
-
return observation;
|
|
334
|
-
return { ...observation, contract: await dispatchAssociation(repo, observation.status.id) };
|
|
335
|
-
}
|
|
336
|
-
async function attachWaitContracts(repo, result) {
|
|
337
|
-
if (repo === undefined)
|
|
338
|
-
return result;
|
|
59
|
+
async function attachWaitAssociations(path, repo, result) {
|
|
60
|
+
const created = await createdTasksFor(path, result.observations.map((observation) => observation.status));
|
|
339
61
|
return fleetResultSchemas.wait.parse({
|
|
340
62
|
...result,
|
|
341
|
-
observations: await Promise.all(result.observations.map((observation) =>
|
|
63
|
+
observations: await Promise.all(result.observations.map(async (observation, index) => parseAkumaObservation({
|
|
64
|
+
status: observation.status,
|
|
65
|
+
contract: await dispatchAssociation(repo, observation.status.id),
|
|
66
|
+
createdTasks: created[index],
|
|
67
|
+
}))),
|
|
342
68
|
});
|
|
343
69
|
}
|
|
344
70
|
function directAddress(values) {
|
|
@@ -377,42 +103,34 @@ export async function waitAkuma(input, execution = localExecutionContext()) {
|
|
|
377
103
|
const selected = completion ?? "all";
|
|
378
104
|
const timeoutMs = timeout(values.timeoutMs);
|
|
379
105
|
const channel = executionChannel(execution);
|
|
106
|
+
const repo = values.repo;
|
|
380
107
|
if (channel.kind === "body-request") {
|
|
381
|
-
|
|
108
|
+
return await attachWaitAssociations(addressed.path, repo, await requestForwardedFleetWait({
|
|
382
109
|
directory: channel.directory,
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
completion: selected,
|
|
388
|
-
...(timeoutMs === undefined ? {} : { timeoutMs }),
|
|
389
|
-
},
|
|
390
|
-
});
|
|
391
|
-
return await attachWaitContracts(values.repo, forwardedFleetCommandResult(response, "akuma.wait"));
|
|
110
|
+
targets: addressed.ids,
|
|
111
|
+
completion: selected,
|
|
112
|
+
...(timeoutMs === undefined ? {} : { timeoutMs }),
|
|
113
|
+
}));
|
|
392
114
|
}
|
|
393
|
-
return await executeWaitAkuma({
|
|
115
|
+
return await attachWaitAssociations(addressed.path, repo, await executeWaitAkuma({
|
|
394
116
|
path: addressed.path,
|
|
395
117
|
ids: addressed.ids,
|
|
396
118
|
completion: selected,
|
|
397
119
|
...(timeoutMs === undefined ? {} : { timeoutMs }),
|
|
398
|
-
|
|
399
|
-
});
|
|
120
|
+
}));
|
|
400
121
|
}
|
|
401
122
|
export async function killAkuma(input, execution = localExecutionContext()) {
|
|
402
123
|
const addressed = await addressAkumaSet(input);
|
|
403
124
|
const channel = executionChannel(execution);
|
|
404
125
|
if (channel.kind === "body-request") {
|
|
405
|
-
|
|
126
|
+
return await requestForwardedFleetKill({
|
|
406
127
|
directory: channel.directory,
|
|
407
|
-
|
|
408
|
-
value: { action: "akuma.kill", targets: addressed.ids },
|
|
128
|
+
targets: addressed.ids,
|
|
409
129
|
});
|
|
410
|
-
return forwardedFleetCommandResult(response, "akuma.kill");
|
|
411
130
|
}
|
|
412
131
|
return await executeKillAkuma({
|
|
413
132
|
path: addressed.path,
|
|
414
133
|
ids: addressed.ids,
|
|
415
|
-
...(input.repo === undefined ? {} : { repo: input.repo }),
|
|
416
134
|
});
|
|
417
135
|
}
|
|
418
136
|
export async function tellAkuma(input, execution = localExecutionContext()) {
|
|
@@ -427,18 +145,16 @@ export async function tellAkuma(input, execution = localExecutionContext()) {
|
|
|
427
145
|
const addressed = await addressAkuma(directAddress(values));
|
|
428
146
|
const channel = executionChannel(execution);
|
|
429
147
|
if (channel.kind === "body-request") {
|
|
430
|
-
|
|
148
|
+
return await requestForwardedFleetTell({
|
|
431
149
|
directory: channel.directory,
|
|
432
|
-
|
|
433
|
-
|
|
150
|
+
target: addressed.id,
|
|
151
|
+
body: values.body,
|
|
434
152
|
});
|
|
435
|
-
return forwardedFleetCommandResult(response, "akuma.tell");
|
|
436
153
|
}
|
|
437
154
|
return await executeTellAkuma({
|
|
438
155
|
path: addressed.path,
|
|
439
156
|
id: addressed.id,
|
|
440
157
|
body: values.body,
|
|
441
|
-
...(values.repo === undefined ? {} : { repo: values.repo }),
|
|
442
158
|
});
|
|
443
159
|
}
|
|
444
160
|
export async function interruptAkuma(input) {
|
|
@@ -3,13 +3,14 @@ import { composeLibrary } from "./composition.js";
|
|
|
3
3
|
import { type LibraryExecution } from "../akuma/requests.js";
|
|
4
4
|
export { AuthorityCorruptionError } from "../core/facts/errors.js";
|
|
5
5
|
export { Delivery, KeiyakuRefused, KeiyakuRetry } from "./contract.js";
|
|
6
|
+
export { projectMutationFinality } from "./contract.js";
|
|
6
7
|
export { NoGitWorldError, Repo } from "./repo.js";
|
|
7
8
|
export { gatesFrom, requireBranchesToBeUpToDateFrom, SettingsError, worktreeHooksFrom } from "./configuration.js";
|
|
8
9
|
export { AkumaWorldScopeError } from "./address.js";
|
|
9
10
|
export { bodyRequestExecution } from "../akuma/requests.js";
|
|
10
11
|
export type { LibraryExecution } from "../akuma/requests.js";
|
|
11
12
|
export type { LocalContractComposition } from "./contract.js";
|
|
12
|
-
export type { AbandonInput, ActorId, AmendInput, AmendResult, ArcInput, AttestationVerdict, AuditInput, AuditReport, DeliveryPreparationRefusal, BindInput, BindResult, AfterEndpointObservation, ContractAfterEdge, ContractBoard, ContractDependent, ContractDisposition, ContractGateCurrent, ContractGateReport, ContractHistory, ContractHistoryEvent, ContractListInput, ContractObservation, ContractObservationInput, ContractPhase, ContractRow, ContractWorkspaceObservation, ContinuationReport, DeliverInput, Fact, IntegrationConflictMaterialized, FactKind, KeiyakuOfInput, KeiyakuRefusal, KeiyakuRetryReason, Lag, MutationResult, PlacementStop, ReconcileReport, Review, ReviewInput, TaskId, TopologyEffect, VerificationReuse, VerificationStop, } from "./contract.js";
|
|
13
|
+
export type { AbandonInput, ActorId, AmendInput, AmendResult, ArcInput, AttestationVerdict, AuditInput, AuditReport, DeliveryPreparationRefusal, BindInput, BindResult, AfterEndpointObservation, ContractAfterEdge, ContractBoard, ContractDependent, ContractDisposition, ContractGateCurrent, ContractGateReport, ContractHistory, ContractHistoryEvent, ContractListInput, ContractObservation, ContractObservationInput, ContractPhase, ContractRow, ContractWorkspaceObservation, ContinuationReport, DeliverInput, Fact, IntegrationConflictMaterialized, FactKind, KeiyakuOfInput, KeiyakuRefusal, KeiyakuRetryReason, Lag, MutationResult, MutationFinality, MutationFinalityInput, MutationFinalitySurface, MutationPendingSurface, PlacementStop, ReconcileReport, Review, ReviewInput, TaskId, TopologyEffect, VerificationReuse, VerificationStop, } from "./contract.js";
|
|
13
14
|
export type { ContractId, ContractState, ChangeId, SnapshotId } from "../core/facts/types.js";
|
|
14
15
|
export type { Gate, GatesFromInput, HookCommand, RequireBranchesToBeUpToDateFromInput, WorktreeHooks, } from "./configuration.js";
|
|
15
16
|
export type { RegionOverlap } from "./region.js";
|
|
@@ -21,13 +22,16 @@ export type { Dispatch, DispatchFailure } from "../dispatch/index.js";
|
|
|
21
22
|
export type { AkumaAlias } from "../identity/selector.js";
|
|
22
23
|
export type { AkumaGlob } from "../identity/selector.js";
|
|
23
24
|
export type { AkuId } from "../akuma/identity.js";
|
|
24
|
-
export type { TellResult, TellWake } from "
|
|
25
|
+
export type { TellResult, TellWake } from "../akuma/index.js";
|
|
25
26
|
export type { AllowedAction, AllowedActions } from "../akuma/allowed.js";
|
|
26
27
|
export type { Catalog, CatalogInput, CatalogQuery } from "./catalog.js";
|
|
27
28
|
export type { NukeInput, NukeResult } from "./nuke.js";
|
|
28
29
|
export type { NukeConfirmationRefusal, NukeConfirmationRequiredRefusal } from "./refusal.js";
|
|
29
30
|
export type { AkumaAddressInput, AkumaSetAddressInput, AkumaWorldScopeRefusal, DirectAkumaSelector, SetAkumaSelector, } from "./address.js";
|
|
30
|
-
export type {
|
|
31
|
+
export type { CreatedTaskObservation } from "../task/created-observation.js";
|
|
32
|
+
export type { DispatchAssociation } from "../dispatch/association.js";
|
|
33
|
+
export type { AkumaKillResult, AkumaObservation, AkumaObservationStage, AkumaTellResult, AkumaUnobserved, AkumaWaitResult, } from "../akuma/fleet-observation.js";
|
|
34
|
+
export type { AkumaHistoryInput, AkumaHistoryResult, AkumaInterruptInput, AkumaInterruptResult, AkumaTellInput, AkumaWaitInput, } from "./fleet.js";
|
|
31
35
|
export type Keiyaku = KeiyakuType;
|
|
32
36
|
export type KeiyakuLibrary = ReturnType<typeof composeLibrary>;
|
|
33
37
|
declare function routedLibrary(input: Readonly<{
|
|
@@ -3,6 +3,7 @@ import { composeLibrary } from "./composition.js";
|
|
|
3
3
|
import { libraryExecutionInput, localExecutionContext } from "../akuma/requests.js";
|
|
4
4
|
export { AuthorityCorruptionError } from "../core/facts/errors.js";
|
|
5
5
|
export { Delivery, KeiyakuRefused, KeiyakuRetry } from "./contract.js";
|
|
6
|
+
export { projectMutationFinality } from "./contract.js";
|
|
6
7
|
export { NoGitWorldError, Repo } from "./repo.js";
|
|
7
8
|
export { gatesFrom, requireBranchesToBeUpToDateFrom, SettingsError, worktreeHooksFrom } from "./configuration.js";
|
|
8
9
|
export { AkumaWorldScopeError } from "./address.js";
|