@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
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Akuma, AkumaNotBornError, defaultWaitComplete } from "./akuma.js";
|
|
2
|
+
import { readBudgetedStatus, tellAkumaWithId } from "./akuma.js";
|
|
3
|
+
import { NO_DISPATCH_ASSOCIATION } from "../dispatch/association.js";
|
|
4
|
+
import { EMPTY_CREATED_TASK_OBSERVATION } from "../task/created-observation.js";
|
|
5
|
+
import { fleetResultSchemas, parseAkumaObservation, } from "./fleet-observation.js";
|
|
6
|
+
function source(path) {
|
|
7
|
+
return Akuma.of(path);
|
|
8
|
+
}
|
|
9
|
+
function observationDiagnostic(error) {
|
|
10
|
+
return error instanceof Error ? error.message : String(error);
|
|
11
|
+
}
|
|
12
|
+
const SHARED_ORDINARY_BUDGET = 30;
|
|
13
|
+
const POLL_MS = 100;
|
|
14
|
+
function akumaOnlyObservation(status) {
|
|
15
|
+
return parseAkumaObservation({
|
|
16
|
+
status,
|
|
17
|
+
contract: NO_DISPATCH_ASSOCIATION,
|
|
18
|
+
createdTasks: EMPTY_CREATED_TASK_OBSERVATION,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
async function observeWaitRound(path, ids, signal) {
|
|
22
|
+
signal?.throwIfAborted();
|
|
23
|
+
if (ids.length <= 1) {
|
|
24
|
+
return {
|
|
25
|
+
statuses: await Promise.all(ids.map(async (id) => await source(path).of({ id }).status())),
|
|
26
|
+
unobserved: [],
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
let remaining = SHARED_ORDINARY_BUDGET;
|
|
30
|
+
const statuses = [];
|
|
31
|
+
const unobserved = [];
|
|
32
|
+
for (const id of ids) {
|
|
33
|
+
signal?.throwIfAborted();
|
|
34
|
+
try {
|
|
35
|
+
const observed = await readBudgetedStatus(path, id, { aperture: "monitoring", ordinaryBudget: remaining });
|
|
36
|
+
statuses.push(observed.status);
|
|
37
|
+
remaining -= observed.ordinarySelected;
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
if (error instanceof AkumaNotBornError)
|
|
41
|
+
throw error;
|
|
42
|
+
unobserved.push({ id, diagnostic: observationDiagnostic(error) });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return { statuses, unobserved };
|
|
46
|
+
}
|
|
47
|
+
function delay(milliseconds, signal) {
|
|
48
|
+
return new Promise((resolve, reject) => {
|
|
49
|
+
let timer;
|
|
50
|
+
const done = () => {
|
|
51
|
+
signal?.removeEventListener("abort", abort);
|
|
52
|
+
resolve();
|
|
53
|
+
};
|
|
54
|
+
const abort = () => {
|
|
55
|
+
clearTimeout(timer);
|
|
56
|
+
signal?.removeEventListener("abort", abort);
|
|
57
|
+
reject(signal?.reason ?? new Error("upstream request aborted"));
|
|
58
|
+
};
|
|
59
|
+
timer = setTimeout(done, milliseconds);
|
|
60
|
+
if (signal?.aborted)
|
|
61
|
+
abort();
|
|
62
|
+
else
|
|
63
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
export async function executeWaitAkuma(input) {
|
|
67
|
+
const deadline = input.timeoutMs === undefined ? undefined : performance.now() + input.timeoutMs;
|
|
68
|
+
for (;;) {
|
|
69
|
+
const round = await observeWaitRound(input.path, input.ids, input.signal);
|
|
70
|
+
const settled = round.statuses.map(defaultWaitComplete);
|
|
71
|
+
const completed = round.statuses.length > 0 &&
|
|
72
|
+
(input.completion === "any" ? settled.some(Boolean) : round.unobserved.length === 0 && settled.every(Boolean));
|
|
73
|
+
if (completed || (deadline !== undefined && performance.now() >= deadline)) {
|
|
74
|
+
return fleetResultSchemas.wait.parse({
|
|
75
|
+
completion: input.completion,
|
|
76
|
+
observations: round.statuses.map(akumaOnlyObservation),
|
|
77
|
+
unobserved: round.unobserved,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
await delay(deadline === undefined ? POLL_MS : Math.min(POLL_MS, Math.max(0, deadline - performance.now())), input.signal);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export async function executeTellAkuma(input) {
|
|
84
|
+
input.signal?.throwIfAborted();
|
|
85
|
+
const handle = source(input.path).of({ id: input.id });
|
|
86
|
+
const tell = input.tellId === undefined
|
|
87
|
+
? await handle.tell(input.body)
|
|
88
|
+
: await tellAkumaWithId({
|
|
89
|
+
worldPath: input.path,
|
|
90
|
+
id: input.id,
|
|
91
|
+
body: input.body,
|
|
92
|
+
tellId: input.tellId,
|
|
93
|
+
...(input.recordedAt === undefined ? {} : { recordedAt: input.recordedAt }),
|
|
94
|
+
});
|
|
95
|
+
input.signal?.throwIfAborted();
|
|
96
|
+
return fleetResultSchemas.tell.parse({
|
|
97
|
+
akuma: input.id,
|
|
98
|
+
tell,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
export async function executeKillAkuma(input) {
|
|
102
|
+
input.signal?.throwIfAborted();
|
|
103
|
+
const handles = input.ids.map((id) => source(input.path).of({ id }));
|
|
104
|
+
const evidence = await Promise.all(handles.map(async (handle) => await handle.kill()));
|
|
105
|
+
input.signal?.throwIfAborted();
|
|
106
|
+
return fleetResultSchemas.kill.parse({
|
|
107
|
+
results: input.ids.map((id, index) => ({ id, evidence: evidence[index] })),
|
|
108
|
+
});
|
|
109
|
+
}
|
|
@@ -1,48 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
declare const dispatchAssociationSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
3
|
-
kind: z.ZodLiteral<"none">;
|
|
4
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
5
|
-
kind: z.ZodLiteral<"associated">;
|
|
6
|
-
contractId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").ContractId, string>>;
|
|
7
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
8
|
-
kind: z.ZodLiteral<"failed">;
|
|
9
|
-
diagnostic: z.ZodString;
|
|
10
|
-
}, z.core.$strict>]>;
|
|
11
|
-
declare const createdTaskObservationSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
12
|
-
kind: z.ZodLiteral<"present">;
|
|
13
|
-
rows: z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
14
|
-
id: z.ZodPipe<z.ZodString, z.ZodTransform<`task/${string}`, string>>;
|
|
15
|
-
title: z.ZodString;
|
|
16
|
-
state: z.ZodEnum<{
|
|
17
|
-
open: "open";
|
|
18
|
-
in_progress: "in_progress";
|
|
19
|
-
on_hold: "on_hold";
|
|
20
|
-
done: "done";
|
|
21
|
-
drop: "drop";
|
|
22
|
-
}>;
|
|
23
|
-
priority: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>]>;
|
|
24
|
-
disposition: z.ZodEnum<{
|
|
25
|
-
in_progress: "in_progress";
|
|
26
|
-
on_hold: "on_hold";
|
|
27
|
-
done: "done";
|
|
28
|
-
drop: "drop";
|
|
29
|
-
ready: "ready";
|
|
30
|
-
blocked: "blocked";
|
|
31
|
-
}>;
|
|
32
|
-
updatedAt: z.ZodString;
|
|
33
|
-
bodyPresent: z.ZodBoolean;
|
|
34
|
-
children: z.ZodOptional<z.ZodObject<{
|
|
35
|
-
live: z.ZodNumber;
|
|
36
|
-
total: z.ZodNumber;
|
|
37
|
-
}, z.core.$strict>>;
|
|
38
|
-
}, z.core.$strict>>>;
|
|
39
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
40
|
-
kind: z.ZodLiteral<"failed">;
|
|
41
|
-
diagnostic: z.ZodString;
|
|
42
|
-
}, z.core.$strict>]>;
|
|
43
2
|
declare const akumaObservationSchema: z.ZodObject<{
|
|
44
3
|
status: z.ZodObject<{
|
|
45
|
-
id: z.ZodPipe<z.ZodString, z.ZodTransform<import("
|
|
4
|
+
id: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identity.js").AkuId, string>>;
|
|
46
5
|
life: z.ZodEnum<{
|
|
47
6
|
killed: "killed";
|
|
48
7
|
hung: "hung";
|
|
@@ -429,7 +388,7 @@ declare const akumaObservationSchema: z.ZodObject<{
|
|
|
429
388
|
kind: z.ZodLiteral<"none">;
|
|
430
389
|
}, z.core.$strict>, z.ZodObject<{
|
|
431
390
|
kind: z.ZodLiteral<"associated">;
|
|
432
|
-
contractId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../
|
|
391
|
+
contractId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../index.js").ContractId, string>>;
|
|
433
392
|
}, z.core.$strict>, z.ZodObject<{
|
|
434
393
|
kind: z.ZodLiteral<"failed">;
|
|
435
394
|
diagnostic: z.ZodString;
|
|
@@ -468,7 +427,7 @@ declare const akumaObservationSchema: z.ZodObject<{
|
|
|
468
427
|
}, z.core.$strict>]>;
|
|
469
428
|
}, z.core.$strict>;
|
|
470
429
|
declare const akumaUnobservedSchema: z.ZodObject<{
|
|
471
|
-
id: z.ZodPipe<z.ZodString, z.ZodTransform<import("
|
|
430
|
+
id: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identity.js").AkuId, string>>;
|
|
472
431
|
diagnostic: z.ZodString;
|
|
473
432
|
}, z.core.$strict>;
|
|
474
433
|
declare const akumaWaitResultSchema: z.ZodObject<{
|
|
@@ -478,7 +437,7 @@ declare const akumaWaitResultSchema: z.ZodObject<{
|
|
|
478
437
|
}>;
|
|
479
438
|
observations: z.ZodArray<z.ZodObject<{
|
|
480
439
|
status: z.ZodObject<{
|
|
481
|
-
id: z.ZodPipe<z.ZodString, z.ZodTransform<import("
|
|
440
|
+
id: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identity.js").AkuId, string>>;
|
|
482
441
|
life: z.ZodEnum<{
|
|
483
442
|
killed: "killed";
|
|
484
443
|
hung: "hung";
|
|
@@ -865,7 +824,7 @@ declare const akumaWaitResultSchema: z.ZodObject<{
|
|
|
865
824
|
kind: z.ZodLiteral<"none">;
|
|
866
825
|
}, z.core.$strict>, z.ZodObject<{
|
|
867
826
|
kind: z.ZodLiteral<"associated">;
|
|
868
|
-
contractId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../
|
|
827
|
+
contractId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../index.js").ContractId, string>>;
|
|
869
828
|
}, z.core.$strict>, z.ZodObject<{
|
|
870
829
|
kind: z.ZodLiteral<"failed">;
|
|
871
830
|
diagnostic: z.ZodString;
|
|
@@ -904,13 +863,13 @@ declare const akumaWaitResultSchema: z.ZodObject<{
|
|
|
904
863
|
}, z.core.$strict>]>;
|
|
905
864
|
}, z.core.$strict>>;
|
|
906
865
|
unobserved: z.ZodArray<z.ZodObject<{
|
|
907
|
-
id: z.ZodPipe<z.ZodString, z.ZodTransform<import("
|
|
866
|
+
id: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identity.js").AkuId, string>>;
|
|
908
867
|
diagnostic: z.ZodString;
|
|
909
868
|
}, z.core.$strict>>;
|
|
910
869
|
}, z.core.$strict>;
|
|
911
870
|
declare const akumaKillResultSchema: z.ZodObject<{
|
|
912
871
|
results: z.ZodArray<z.ZodObject<{
|
|
913
|
-
id: z.ZodPipe<z.ZodString, z.ZodTransform<import("
|
|
872
|
+
id: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identity.js").AkuId, string>>;
|
|
914
873
|
evidence: z.ZodEnum<{
|
|
915
874
|
unavailable: "unavailable";
|
|
916
875
|
killed: "killed";
|
|
@@ -922,7 +881,7 @@ declare const akumaKillResultSchema: z.ZodObject<{
|
|
|
922
881
|
}, z.core.$strict>>;
|
|
923
882
|
}, z.core.$strict>;
|
|
924
883
|
declare const akumaTellResultSchema: z.ZodObject<{
|
|
925
|
-
akuma: z.ZodPipe<z.ZodString, z.ZodTransform<import("
|
|
884
|
+
akuma: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identity.js").AkuId, string>>;
|
|
926
885
|
tell: z.ZodObject<{
|
|
927
886
|
admission: z.ZodObject<{
|
|
928
887
|
fact: z.ZodLiteral<"recorded">;
|
|
@@ -1010,8 +969,6 @@ declare const akumaTellResultSchema: z.ZodObject<{
|
|
|
1010
969
|
}>>]>;
|
|
1011
970
|
}, z.core.$strict>;
|
|
1012
971
|
}, z.core.$strict>;
|
|
1013
|
-
export type CreatedTaskObservation = z.infer<typeof createdTaskObservationSchema>;
|
|
1014
|
-
export type DispatchAssociation = z.infer<typeof dispatchAssociationSchema>;
|
|
1015
972
|
export type AkumaObservation = z.infer<typeof akumaObservationSchema>;
|
|
1016
973
|
export type AkumaObservationStage = (Readonly<{
|
|
1017
974
|
kind: "observed";
|
|
@@ -1023,7 +980,6 @@ export type AkumaUnobserved = z.infer<typeof akumaUnobservedSchema>;
|
|
|
1023
980
|
export type AkumaWaitResult = z.infer<typeof akumaWaitResultSchema>;
|
|
1024
981
|
export type AkumaKillResult = z.infer<typeof akumaKillResultSchema>;
|
|
1025
982
|
export type AkumaTellResult = z.infer<typeof akumaTellResultSchema>;
|
|
1026
|
-
export declare function parseCreatedTaskObservation(value: unknown): CreatedTaskObservation;
|
|
1027
983
|
export declare function parseAkumaObservation(value: unknown): AkumaObservation;
|
|
1028
984
|
export declare function isWaitResult(value: unknown): value is AkumaWaitResult;
|
|
1029
985
|
export declare function isKillResult(value: unknown): value is AkumaKillResult;
|
|
@@ -1036,7 +992,7 @@ export declare const fleetResultSchemas: {
|
|
|
1036
992
|
}>;
|
|
1037
993
|
observations: z.ZodArray<z.ZodObject<{
|
|
1038
994
|
status: z.ZodObject<{
|
|
1039
|
-
id: z.ZodPipe<z.ZodString, z.ZodTransform<import("
|
|
995
|
+
id: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identity.js").AkuId, string>>;
|
|
1040
996
|
life: z.ZodEnum<{
|
|
1041
997
|
killed: "killed";
|
|
1042
998
|
hung: "hung";
|
|
@@ -1423,7 +1379,7 @@ export declare const fleetResultSchemas: {
|
|
|
1423
1379
|
kind: z.ZodLiteral<"none">;
|
|
1424
1380
|
}, z.core.$strict>, z.ZodObject<{
|
|
1425
1381
|
kind: z.ZodLiteral<"associated">;
|
|
1426
|
-
contractId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../
|
|
1382
|
+
contractId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../index.js").ContractId, string>>;
|
|
1427
1383
|
}, z.core.$strict>, z.ZodObject<{
|
|
1428
1384
|
kind: z.ZodLiteral<"failed">;
|
|
1429
1385
|
diagnostic: z.ZodString;
|
|
@@ -1462,12 +1418,12 @@ export declare const fleetResultSchemas: {
|
|
|
1462
1418
|
}, z.core.$strict>]>;
|
|
1463
1419
|
}, z.core.$strict>>;
|
|
1464
1420
|
unobserved: z.ZodArray<z.ZodObject<{
|
|
1465
|
-
id: z.ZodPipe<z.ZodString, z.ZodTransform<import("
|
|
1421
|
+
id: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identity.js").AkuId, string>>;
|
|
1466
1422
|
diagnostic: z.ZodString;
|
|
1467
1423
|
}, z.core.$strict>>;
|
|
1468
1424
|
}, z.core.$strict>;
|
|
1469
1425
|
tell: z.ZodObject<{
|
|
1470
|
-
akuma: z.ZodPipe<z.ZodString, z.ZodTransform<import("
|
|
1426
|
+
akuma: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identity.js").AkuId, string>>;
|
|
1471
1427
|
tell: z.ZodObject<{
|
|
1472
1428
|
admission: z.ZodObject<{
|
|
1473
1429
|
fact: z.ZodLiteral<"recorded">;
|
|
@@ -1557,7 +1513,7 @@ export declare const fleetResultSchemas: {
|
|
|
1557
1513
|
}, z.core.$strict>;
|
|
1558
1514
|
kill: z.ZodObject<{
|
|
1559
1515
|
results: z.ZodArray<z.ZodObject<{
|
|
1560
|
-
id: z.ZodPipe<z.ZodString, z.ZodTransform<import("
|
|
1516
|
+
id: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identity.js").AkuId, string>>;
|
|
1561
1517
|
evidence: z.ZodEnum<{
|
|
1562
1518
|
unavailable: "unavailable";
|
|
1563
1519
|
killed: "killed";
|
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
import { akumaIdSchema, akumaStatusSchema } from "
|
|
2
|
-
import { tellRowSchema } from "
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { akumaIdSchema, akumaStatusSchema } from "./akuma.js";
|
|
2
|
+
import { tellRowSchema } from "./projection.js";
|
|
3
|
+
import { dispatchAssociationSchema } from "../dispatch/association.js";
|
|
4
|
+
import { createdTaskObservationSchema } from "../task/created-observation.js";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
const nonblankTextSchema = z.string().refine((value) => value.trim() !== "");
|
|
7
|
-
const contractIdSchema = z.string().transform((value, context) => {
|
|
8
|
-
try {
|
|
9
|
-
return contractId(value);
|
|
10
|
-
}
|
|
11
|
-
catch {
|
|
12
|
-
context.addIssue({ code: "custom", message: "expected ContractId" });
|
|
13
|
-
return z.NEVER;
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
7
|
const killEvidenceSchema = z.enum([
|
|
17
8
|
"killed",
|
|
18
9
|
"already-killed",
|
|
@@ -21,15 +12,6 @@ const killEvidenceSchema = z.enum([
|
|
|
21
12
|
"untidy",
|
|
22
13
|
"unavailable",
|
|
23
14
|
]);
|
|
24
|
-
const dispatchAssociationSchema = z.union([
|
|
25
|
-
z.object({ kind: z.literal("none") }).strict(),
|
|
26
|
-
z.object({ kind: z.literal("associated"), contractId: contractIdSchema }).strict(),
|
|
27
|
-
z.object({ kind: z.literal("failed"), diagnostic: z.string() }).strict(),
|
|
28
|
-
]);
|
|
29
|
-
const createdTaskObservationSchema = z.union([
|
|
30
|
-
z.object({ kind: z.literal("present"), rows: taskRowsSchema }).strict(),
|
|
31
|
-
z.object({ kind: z.literal("failed"), diagnostic: z.string() }).strict(),
|
|
32
|
-
]);
|
|
33
15
|
const akumaObservationSchema = z
|
|
34
16
|
.object({
|
|
35
17
|
status: akumaStatusSchema,
|
|
@@ -75,9 +57,6 @@ const akumaWaitResultSchema = z
|
|
|
75
57
|
.strict();
|
|
76
58
|
const akumaKillResultSchema = z.object({ results: z.array(akumaKillResultItemSchema) }).strict();
|
|
77
59
|
const akumaTellResultSchema = z.object({ akuma: akumaIdSchema, tell: tellResultSchema }).strict();
|
|
78
|
-
export function parseCreatedTaskObservation(value) {
|
|
79
|
-
return createdTaskObservationSchema.parse(value);
|
|
80
|
-
}
|
|
81
60
|
export function parseAkumaObservation(value) {
|
|
82
61
|
return akumaObservationSchema.parse(value);
|
|
83
62
|
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { KillEvidence } from "./heart/index.js";
|
|
2
|
+
import { type ErasedRequestCommand, type RequestProtocol, type ServiceRequestCommand } from "./request-wire.js";
|
|
3
|
+
import type { AkumaStatus } from "./akuma.js";
|
|
4
|
+
import { type AkumaKillResult, type AkumaTellResult, type AkumaWaitResult } from "./fleet-observation.js";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
declare const waitRequestSchema: z.ZodPipe<z.ZodObject<{
|
|
7
|
+
targets: z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<import("./identity.js").AkuId, string>>>;
|
|
8
|
+
completion: z.ZodEnum<{
|
|
9
|
+
any: "any";
|
|
10
|
+
all: "all";
|
|
11
|
+
}>;
|
|
12
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
13
|
+
}, z.core.$strict>, z.ZodTransform<{
|
|
14
|
+
timeoutMs?: number;
|
|
15
|
+
targets: import("./identity.js").AkuId[];
|
|
16
|
+
completion: "any" | "all";
|
|
17
|
+
action: "akuma.wait";
|
|
18
|
+
}, {
|
|
19
|
+
targets: import("./identity.js").AkuId[];
|
|
20
|
+
completion: "any" | "all";
|
|
21
|
+
timeoutMs?: number | undefined;
|
|
22
|
+
}>>;
|
|
23
|
+
declare const tellRequestSchema: z.ZodPipe<z.ZodObject<{
|
|
24
|
+
target: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identity.js").AkuId, string>>;
|
|
25
|
+
body: z.ZodString;
|
|
26
|
+
}, z.core.$strict>, z.ZodTransform<{
|
|
27
|
+
target: import("./identity.js").AkuId;
|
|
28
|
+
body: string;
|
|
29
|
+
action: "akuma.tell";
|
|
30
|
+
}, {
|
|
31
|
+
target: import("./identity.js").AkuId;
|
|
32
|
+
body: string;
|
|
33
|
+
}>>;
|
|
34
|
+
declare const killRequestSchema: z.ZodPipe<z.ZodObject<{
|
|
35
|
+
targets: z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<import("./identity.js").AkuId, string>>>;
|
|
36
|
+
}, z.core.$strict>, z.ZodTransform<{
|
|
37
|
+
targets: import("./identity.js").AkuId[];
|
|
38
|
+
action: "akuma.kill";
|
|
39
|
+
}, {
|
|
40
|
+
targets: import("./identity.js").AkuId[];
|
|
41
|
+
}>>;
|
|
42
|
+
declare const waitServiceSchema: z.ZodObject<{
|
|
43
|
+
action: z.ZodLiteral<"akuma.wait">;
|
|
44
|
+
}, z.core.$strict>;
|
|
45
|
+
declare const tellServiceSchema: z.ZodObject<{
|
|
46
|
+
action: z.ZodLiteral<"akuma.tell">;
|
|
47
|
+
target: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identity.js").AkuId, string>>;
|
|
48
|
+
tellId: z.ZodString;
|
|
49
|
+
}, z.core.$strict>;
|
|
50
|
+
declare const killServiceSchema: z.ZodObject<{
|
|
51
|
+
action: z.ZodLiteral<"akuma.kill">;
|
|
52
|
+
results: z.ZodArray<z.ZodObject<{
|
|
53
|
+
id: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identity.js").AkuId, string>>;
|
|
54
|
+
evidence: z.ZodEnum<{
|
|
55
|
+
unavailable: "unavailable";
|
|
56
|
+
killed: "killed";
|
|
57
|
+
"already-killed": "already-killed";
|
|
58
|
+
"already-stopped": "already-stopped";
|
|
59
|
+
hung: "hung";
|
|
60
|
+
untidy: "untidy";
|
|
61
|
+
}>;
|
|
62
|
+
}, z.core.$strict>>;
|
|
63
|
+
}, z.core.$strict>;
|
|
64
|
+
export type FleetRequest = (Omit<z.infer<typeof waitRequestSchema>, "targets"> & Readonly<{
|
|
65
|
+
targets: readonly AkumaStatus["id"][];
|
|
66
|
+
}>) | z.infer<typeof tellRequestSchema> | (Omit<z.infer<typeof killRequestSchema>, "targets"> & Readonly<{
|
|
67
|
+
targets: readonly AkumaStatus["id"][];
|
|
68
|
+
}>);
|
|
69
|
+
export type FleetService = z.infer<typeof waitServiceSchema> | z.infer<typeof tellServiceSchema> | (Omit<z.infer<typeof killServiceSchema>, "results"> & Readonly<{
|
|
70
|
+
results: readonly Readonly<{
|
|
71
|
+
id: AkumaStatus["id"];
|
|
72
|
+
evidence: KillEvidence;
|
|
73
|
+
}>[];
|
|
74
|
+
}>);
|
|
75
|
+
export type FleetRequestPort = Readonly<{
|
|
76
|
+
wait(input: Readonly<{
|
|
77
|
+
targets: readonly AkumaStatus["id"][];
|
|
78
|
+
completion: "any" | "all";
|
|
79
|
+
timeoutMs?: number;
|
|
80
|
+
signal: AbortSignal;
|
|
81
|
+
}>): Promise<AkumaWaitResult>;
|
|
82
|
+
tell(input: Readonly<{
|
|
83
|
+
target: AkumaStatus["id"];
|
|
84
|
+
body: string;
|
|
85
|
+
tellId: string;
|
|
86
|
+
recordedAt: string;
|
|
87
|
+
signal: AbortSignal;
|
|
88
|
+
}>): Promise<AkumaTellResult>;
|
|
89
|
+
kill(input: Readonly<{
|
|
90
|
+
targets: readonly AkumaStatus["id"][];
|
|
91
|
+
signal: AbortSignal;
|
|
92
|
+
}>): Promise<AkumaKillResult | Readonly<{
|
|
93
|
+
result: unknown;
|
|
94
|
+
service: readonly Readonly<{
|
|
95
|
+
id: AkumaStatus["id"];
|
|
96
|
+
evidence: KillEvidence;
|
|
97
|
+
}>[];
|
|
98
|
+
}>>;
|
|
99
|
+
}>;
|
|
100
|
+
/** Akuma owns Body Request payload, live result, and durable service codecs for wait/tell/kill. */
|
|
101
|
+
export declare function fleetRequestProtocol(action: FleetRequest["action"]): RequestProtocol<FleetRequest, unknown, FleetService>;
|
|
102
|
+
export declare function fleetRequestCommand(action: FleetRequest["action"], port: FleetRequestPort): ServiceRequestCommand<FleetRequest, unknown, FleetService, FleetService>;
|
|
103
|
+
export declare function fleetRequestCommands(port: FleetRequestPort): Readonly<Record<"akuma.wait" | "akuma.tell" | "akuma.kill", ErasedRequestCommand>>;
|
|
104
|
+
export declare function requestForwardedFleetWait(input: Readonly<{
|
|
105
|
+
directory: string;
|
|
106
|
+
targets: readonly AkumaStatus["id"][];
|
|
107
|
+
completion: "any" | "all";
|
|
108
|
+
timeoutMs?: number;
|
|
109
|
+
signal?: AbortSignal;
|
|
110
|
+
}>): Promise<AkumaWaitResult>;
|
|
111
|
+
export declare function requestForwardedFleetTell(input: Readonly<{
|
|
112
|
+
directory: string;
|
|
113
|
+
target: AkumaStatus["id"];
|
|
114
|
+
body: string;
|
|
115
|
+
signal?: AbortSignal;
|
|
116
|
+
}>): Promise<AkumaTellResult>;
|
|
117
|
+
export declare function requestForwardedFleetKill(input: Readonly<{
|
|
118
|
+
directory: string;
|
|
119
|
+
targets: readonly AkumaStatus["id"][];
|
|
120
|
+
signal?: AbortSignal;
|
|
121
|
+
}>): Promise<AkumaKillResult>;
|
|
122
|
+
export {};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { akumaIdSchema } from "./akuma.js";
|
|
2
|
+
import { requestBodyCommand } from "./request-rendezvous.js";
|
|
3
|
+
import { eraseRequestCommand, } from "./request-wire.js";
|
|
4
|
+
import { fleetResultSchemas, isKillResult, isTellResult, isWaitResult, } from "./fleet-observation.js";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
const nonblankTextSchema = z.string().refine((value) => value.trim() !== "");
|
|
7
|
+
const fleetTargetsSchema = z
|
|
8
|
+
.array(akumaIdSchema)
|
|
9
|
+
.min(1)
|
|
10
|
+
.superRefine((ids, context) => {
|
|
11
|
+
if (ids.some((id, index) => index > 0 && ids[index - 1] >= id))
|
|
12
|
+
context.addIssue({ code: "custom", message: "expected a strictly ordered target set" });
|
|
13
|
+
});
|
|
14
|
+
const waitRequestSchema = z
|
|
15
|
+
.object({
|
|
16
|
+
targets: fleetTargetsSchema,
|
|
17
|
+
completion: z.enum(["any", "all"]),
|
|
18
|
+
timeoutMs: z.number().int().nonnegative().optional(),
|
|
19
|
+
})
|
|
20
|
+
.strict()
|
|
21
|
+
.transform(({ timeoutMs, ...request }) => ({
|
|
22
|
+
action: "akuma.wait",
|
|
23
|
+
...request,
|
|
24
|
+
...(timeoutMs === undefined ? {} : { timeoutMs }),
|
|
25
|
+
}));
|
|
26
|
+
const tellRequestSchema = z
|
|
27
|
+
.object({ target: akumaIdSchema, body: z.string() })
|
|
28
|
+
.strict()
|
|
29
|
+
.transform((request) => ({ action: "akuma.tell", ...request }));
|
|
30
|
+
const killRequestSchema = z
|
|
31
|
+
.object({ targets: fleetTargetsSchema })
|
|
32
|
+
.strict()
|
|
33
|
+
.transform((request) => ({ action: "akuma.kill", ...request }));
|
|
34
|
+
const waitServiceSchema = z.object({ action: z.literal("akuma.wait") }).strict();
|
|
35
|
+
const tellServiceSchema = z
|
|
36
|
+
.object({ action: z.literal("akuma.tell"), target: akumaIdSchema, tellId: nonblankTextSchema })
|
|
37
|
+
.strict();
|
|
38
|
+
const killServiceSchema = z
|
|
39
|
+
.object({
|
|
40
|
+
action: z.literal("akuma.kill"),
|
|
41
|
+
results: z.array(z.object({ id: akumaIdSchema, evidence: fleetResultSchemas.killEvidence }).strict()),
|
|
42
|
+
})
|
|
43
|
+
.strict();
|
|
44
|
+
function decodeFleetRequest(action, value) {
|
|
45
|
+
const schema = action === "akuma.wait" ? waitRequestSchema : action === "akuma.tell" ? tellRequestSchema : killRequestSchema;
|
|
46
|
+
const parsed = schema.safeParse(value);
|
|
47
|
+
return parsed.success ? parsed.data : null;
|
|
48
|
+
}
|
|
49
|
+
function decodeFleetService(action, value) {
|
|
50
|
+
const schema = action === "akuma.wait" ? waitServiceSchema : action === "akuma.tell" ? tellServiceSchema : killServiceSchema;
|
|
51
|
+
const parsed = schema.safeParse(value);
|
|
52
|
+
if (!parsed.success)
|
|
53
|
+
throw new Error("malformed stored Fleet service evidence");
|
|
54
|
+
return parsed.data;
|
|
55
|
+
}
|
|
56
|
+
function decodedFleetResult(action, value) {
|
|
57
|
+
const schema = action === "akuma.wait"
|
|
58
|
+
? fleetResultSchemas.wait
|
|
59
|
+
: action === "akuma.tell"
|
|
60
|
+
? fleetResultSchemas.tell
|
|
61
|
+
: fleetResultSchemas.kill;
|
|
62
|
+
const parsed = schema.safeParse(value);
|
|
63
|
+
if (!parsed.success)
|
|
64
|
+
throw new Error(`Akuma body request returned an invalid live result for ${action}`);
|
|
65
|
+
return parsed.data;
|
|
66
|
+
}
|
|
67
|
+
/** Akuma owns Body Request payload, live result, and durable service codecs for wait/tell/kill. */
|
|
68
|
+
export function fleetRequestProtocol(action) {
|
|
69
|
+
return {
|
|
70
|
+
action,
|
|
71
|
+
encodeRequest: (request) => {
|
|
72
|
+
const { action: _action, ...payload } = request;
|
|
73
|
+
return payload;
|
|
74
|
+
},
|
|
75
|
+
decodeRequest: (payload) => decodeFleetRequest(action, payload),
|
|
76
|
+
encodeResult: (result) => result,
|
|
77
|
+
decodeResult: (result) => decodedFleetResult(action, result),
|
|
78
|
+
decodeReference: (reference) => decodeFleetService(action, reference),
|
|
79
|
+
isPermitted: (allowed) => action === "akuma.wait" || allowed.includes(action),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
export function fleetRequestCommand(action, port) {
|
|
83
|
+
return {
|
|
84
|
+
completion: "service",
|
|
85
|
+
protocol: fleetRequestProtocol(action),
|
|
86
|
+
encodeService: (service) => decodeFleetService(action, service),
|
|
87
|
+
decodeService: (service) => decodeFleetService(action, service),
|
|
88
|
+
projectService: (service) => decodeFleetService(action, service),
|
|
89
|
+
execute: async (request, facts) => {
|
|
90
|
+
if (request.action === "akuma.wait") {
|
|
91
|
+
return {
|
|
92
|
+
result: await port.wait({ ...request, signal: facts.signal }),
|
|
93
|
+
service: { action: request.action },
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
if (request.action === "akuma.tell") {
|
|
97
|
+
return {
|
|
98
|
+
result: await port.tell({
|
|
99
|
+
target: request.target,
|
|
100
|
+
body: request.body,
|
|
101
|
+
tellId: facts.id,
|
|
102
|
+
recordedAt: facts.admittedAt,
|
|
103
|
+
signal: facts.signal,
|
|
104
|
+
}),
|
|
105
|
+
service: { action: request.action, target: request.target, tellId: facts.id },
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
const result = await port.kill({ targets: request.targets, signal: facts.signal });
|
|
109
|
+
if ("result" in result)
|
|
110
|
+
return { result: result.result, service: { action: request.action, results: result.service } };
|
|
111
|
+
return {
|
|
112
|
+
result,
|
|
113
|
+
service: { action: request.action, results: result.results.map(({ id, evidence }) => ({ id, evidence })) },
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
export function fleetRequestCommands(port) {
|
|
119
|
+
return {
|
|
120
|
+
"akuma.wait": eraseRequestCommand(fleetRequestCommand("akuma.wait", port)),
|
|
121
|
+
"akuma.tell": eraseRequestCommand(fleetRequestCommand("akuma.tell", port)),
|
|
122
|
+
"akuma.kill": eraseRequestCommand(fleetRequestCommand("akuma.kill", port)),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function forwardedFleetCommandResult(response, action) {
|
|
126
|
+
if (response.kind === "returned") {
|
|
127
|
+
if (action === "akuma.wait" && isWaitResult(response.result))
|
|
128
|
+
return response.result;
|
|
129
|
+
if (action === "akuma.tell" && isTellResult(response.result))
|
|
130
|
+
return response.result;
|
|
131
|
+
if (action === "akuma.kill" && isKillResult(response.result))
|
|
132
|
+
return response.result;
|
|
133
|
+
throw new Error(`transport integrity: request Fleet ${action} returned an invalid live result`);
|
|
134
|
+
}
|
|
135
|
+
throw new Error("Akuma body request terminal Fleet reference cannot reproduce an expired live result");
|
|
136
|
+
}
|
|
137
|
+
export async function requestForwardedFleetWait(input) {
|
|
138
|
+
const response = await requestBodyCommand({
|
|
139
|
+
directory: input.directory,
|
|
140
|
+
command: fleetRequestProtocol("akuma.wait"),
|
|
141
|
+
value: {
|
|
142
|
+
action: "akuma.wait",
|
|
143
|
+
targets: input.targets,
|
|
144
|
+
completion: input.completion,
|
|
145
|
+
...(input.timeoutMs === undefined ? {} : { timeoutMs: input.timeoutMs }),
|
|
146
|
+
},
|
|
147
|
+
...(input.signal === undefined ? {} : { signal: input.signal }),
|
|
148
|
+
});
|
|
149
|
+
return forwardedFleetCommandResult(response, "akuma.wait");
|
|
150
|
+
}
|
|
151
|
+
export async function requestForwardedFleetTell(input) {
|
|
152
|
+
const response = await requestBodyCommand({
|
|
153
|
+
directory: input.directory,
|
|
154
|
+
command: fleetRequestProtocol("akuma.tell"),
|
|
155
|
+
value: { action: "akuma.tell", target: input.target, body: input.body },
|
|
156
|
+
...(input.signal === undefined ? {} : { signal: input.signal }),
|
|
157
|
+
});
|
|
158
|
+
return forwardedFleetCommandResult(response, "akuma.tell");
|
|
159
|
+
}
|
|
160
|
+
export async function requestForwardedFleetKill(input) {
|
|
161
|
+
const response = await requestBodyCommand({
|
|
162
|
+
directory: input.directory,
|
|
163
|
+
command: fleetRequestProtocol("akuma.kill"),
|
|
164
|
+
value: { action: "akuma.kill", targets: input.targets },
|
|
165
|
+
...(input.signal === undefined ? {} : { signal: input.signal }),
|
|
166
|
+
});
|
|
167
|
+
return forwardedFleetCommandResult(response, "akuma.kill");
|
|
168
|
+
}
|