@astrosheep/keiyaku 4.5.7 → 4.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- 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/opencode.js +3 -2
- package/build/integrations/marketplace/plugins/keiyaku/package.json +1 -1
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +12 -11
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +33 -12
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-babysit/SKILL.md +35 -96
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/SKILL.md +28 -49
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-task/SKILL.md +21 -15
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +148 -89
- package/build/src/akuma/abort.d.ts +2 -1
- package/build/src/akuma/abort.js +6 -23
- package/build/src/akuma/akuma-handle.js +4 -2
- package/build/src/akuma/akuma-observe.d.ts +2 -0
- package/build/src/akuma/akuma-observe.js +1 -0
- package/build/src/akuma/akuma-product.js +9 -7
- package/build/src/akuma/akuma.d.ts +392 -9
- package/build/src/akuma/akuma.js +31 -1
- package/build/src/akuma/allowed.d.ts +1 -1
- package/build/src/akuma/allowed.js +1 -0
- package/build/src/akuma/archetype.js +1 -1
- package/build/src/akuma/body.d.ts +8 -5
- package/build/src/akuma/body.js +12 -5
- package/build/src/akuma/call-request.d.ts +80 -0
- package/build/src/akuma/call-request.js +211 -0
- package/build/src/akuma/heart/facts.d.ts +16 -78
- package/build/src/akuma/heart/facts.js +11 -0
- package/build/src/akuma/heart/index.d.ts +3 -2
- package/build/src/akuma/heart/index.js +4 -1
- package/build/src/akuma/heart/request-authority.d.ts +5 -4
- package/build/src/akuma/heart/request-authority.js +20 -34
- package/build/src/akuma/heart/request-rows.js +12 -23
- package/build/src/akuma/heart/schema.d.ts +1 -1
- package/build/src/akuma/heart/schema.js +5 -13
- package/build/src/akuma/index.d.ts +1 -1
- package/build/src/akuma/index.js +1 -1
- package/build/src/akuma/projection-read.d.ts +1 -0
- package/build/src/akuma/projection-read.js +8 -1
- package/build/src/akuma/projection.d.ts +907 -137
- package/build/src/akuma/projection.js +193 -9
- package/build/src/akuma/provider.d.ts +30 -3
- package/build/src/akuma/provider.js +111 -0
- package/build/src/akuma/providers/acp/core.d.ts +2 -2
- package/build/src/akuma/providers/acp/core.js +13 -6
- package/build/src/akuma/providers/acp/index.js +5 -4
- package/build/src/akuma/providers/claude/events.d.ts +2 -2
- package/build/src/akuma/providers/claude/events.js +16 -3
- package/build/src/akuma/providers/claude/index.d.ts +3 -3
- package/build/src/akuma/providers/claude/index.js +16 -5
- package/build/src/akuma/providers/codex-app-server/events.d.ts +2 -2
- package/build/src/akuma/providers/codex-app-server/events.js +25 -4
- package/build/src/akuma/providers/codex-app-server/index.js +18 -6
- package/build/src/akuma/providers/grok-build/index.js +5 -4
- package/build/src/akuma/providers/opencode-sdk/index.js +66 -25
- package/build/src/akuma/providers/opencode-sdk/session.d.ts +3 -2
- package/build/src/akuma/providers/opencode-sdk/session.js +28 -11
- package/build/src/akuma/providers/pi/index.js +72 -58
- package/build/src/akuma/request-lifecycle.d.ts +4 -10
- package/build/src/akuma/request-lifecycle.js +7 -5
- package/build/src/akuma/request-rendezvous.d.ts +26 -0
- package/build/src/akuma/request-rendezvous.js +100 -0
- package/build/src/akuma/request-serve.d.ts +6 -66
- package/build/src/akuma/request-serve.js +83 -210
- package/build/src/akuma/request-wire.d.ts +109 -115
- package/build/src/akuma/request-wire.js +63 -318
- package/build/src/akuma/requests.d.ts +19 -47
- package/build/src/akuma/requests.js +51 -107
- package/build/src/akuma/turn-drive.d.ts +5 -3
- package/build/src/akuma/turn-drive.js +39 -11
- package/build/src/akuma-body.d.ts +7 -2
- package/build/src/akuma-body.js +68 -46
- package/build/src/body/amend.js +18 -19
- package/build/src/cli/accepted.d.ts +1 -1
- package/build/src/cli/accepted.js +2 -2
- package/build/src/cli/commands/akuma-invoke.d.ts +2 -0
- package/build/src/cli/commands/akuma-invoke.js +17 -9
- package/build/src/cli/commands/akuma.js +8 -8
- package/build/src/cli/commands/contract-invoke.d.ts +3 -2
- package/build/src/cli/commands/contract-invoke.js +42 -30
- package/build/src/cli/commands/contract.d.ts +16 -20
- package/build/src/cli/commands/contract.js +58 -25
- package/build/src/cli/commands/install.d.ts +2 -1
- package/build/src/cli/commands/install.js +3 -2
- package/build/src/cli/commands/task-invoke.d.ts +3 -0
- package/build/src/cli/commands/task-invoke.js +23 -140
- package/build/src/cli/commands/task.js +54 -20
- package/build/src/cli/invoke.js +39 -25
- package/build/src/cli/main.js +2 -1
- package/build/src/cli/parse.d.ts +2 -2
- package/build/src/cli/parse.js +56 -27
- package/build/src/cli/render/akuma-activity.d.ts +3 -0
- package/build/src/cli/render/akuma-activity.js +45 -29
- package/build/src/cli/render/akuma-tool.d.ts +5 -1
- package/build/src/cli/render/akuma.js +4 -8
- package/build/src/cli/render/audit.js +1 -1
- package/build/src/cli/render/catalog.js +80 -21
- package/build/src/cli/render/contract-observation.d.ts +2 -0
- package/build/src/cli/render/contract-observation.js +11 -0
- package/build/src/cli/render/contract.js +35 -62
- package/build/src/cli/render/kanshi-akuma.d.ts +8 -0
- package/build/src/cli/render/kanshi-akuma.js +132 -0
- package/build/src/cli/render/kanshi.js +131 -213
- package/build/src/cli/render/receipt.d.ts +1 -2
- package/build/src/cli/render/receipt.js +76 -26
- package/build/src/cli/render/refusal.js +2 -10
- package/build/src/cli/render/region.js +5 -2
- package/build/src/cli/render/settings.d.ts +1 -1
- package/build/src/cli/render/settings.js +27 -8
- package/build/src/cli/render/task.js +22 -5
- package/build/src/cli/render/terminal.d.ts +32 -1
- package/build/src/cli/render/terminal.js +77 -1
- package/build/src/cli/result.d.ts +3 -3
- package/build/src/cli/runtime.js +4 -2
- package/build/src/cli/selectors.d.ts +2 -1
- package/build/src/cli/selectors.js +4 -3
- package/build/src/cli/square-edge.js +120 -36
- package/build/src/cli/usage.js +2 -1
- package/build/src/contract-guidance.d.ts +5 -0
- package/build/src/contract-guidance.js +121 -0
- package/build/src/contract-worktree.d.ts +0 -1
- package/build/src/contract-worktree.js +32 -83
- package/build/src/coordination/sqlite-transaction-lock.d.ts +1 -0
- package/build/src/coordination/sqlite-transaction-lock.js +5 -0
- package/build/src/core/facts/codec.d.ts +2 -0
- package/build/src/core/facts/codec.js +4 -0
- package/build/src/core/verbs/placement.d.ts +6 -1
- package/build/src/core/verbs/placement.js +5 -3
- package/build/src/dispatch/index.d.ts +0 -2
- package/build/src/dispatch/index.js +54 -55
- package/build/src/git/admission.js +2 -2
- package/build/src/git/hooks.d.ts +9 -15
- package/build/src/git/hooks.js +23 -317
- package/build/src/git/nuke.d.ts +2 -1
- package/build/src/git/nuke.js +39 -21
- package/build/src/git/private-state-seat.d.ts +12 -0
- package/build/src/git/private-state-seat.js +39 -0
- package/build/src/git/process.d.ts +6 -0
- package/build/src/git/process.js +26 -11
- package/build/src/git/read-observation.js +29 -20
- package/build/src/git/reconcile.d.ts +13 -1
- package/build/src/git/reconcile.js +70 -11
- package/build/src/git/ref-migration.d.ts +22 -0
- package/build/src/git/ref-migration.js +55 -0
- package/build/src/git/repository.d.ts +10 -6
- package/build/src/git/repository.js +16 -8
- package/build/src/git/target-placement.d.ts +1 -0
- package/build/src/git/target-placement.js +5 -0
- package/build/src/git/tender.d.ts +1 -0
- package/build/src/git/terminal-reconcile.d.ts +1 -1
- package/build/src/git/terminal-reconcile.js +22 -20
- package/build/src/git/workspace.d.ts +14 -0
- package/build/src/git/workspace.js +44 -0
- package/build/src/kanshi/index.d.ts +1 -1
- package/build/src/kanshi/read.js +16 -16
- package/build/src/kanshi/report.d.ts +2 -2
- package/build/src/library/address.d.ts +9 -3
- package/build/src/library/address.js +3 -2
- package/build/src/library/akuma-creation.d.ts +4 -3
- package/build/src/library/akuma-creation.js +19 -13
- package/build/src/library/audit.d.ts +14 -6
- package/build/src/library/audit.js +13 -23
- package/build/src/library/catalog.d.ts +3 -1
- package/build/src/library/catalog.js +20 -6
- package/build/src/library/composition.d.ts +385 -0
- package/build/src/library/composition.js +28 -0
- package/build/src/library/configuration.js +8 -2
- package/build/src/library/continuation.js +66 -30
- package/build/src/library/contract-bind.js +10 -2
- package/build/src/library/contract-forwarding-reconciliation-result.d.ts +102 -0
- package/build/src/library/contract-forwarding-reconciliation-result.js +92 -0
- package/build/src/library/contract-forwarding-result.d.ts +4464 -0
- package/build/src/library/contract-forwarding-result.js +521 -0
- package/build/src/library/contract-forwarding.d.ts +71 -0
- package/build/src/library/contract-forwarding.js +114 -0
- package/build/src/library/contract-handle.d.ts +38 -0
- package/build/src/library/contract-handle.js +314 -0
- package/build/src/library/contract-operations.d.ts +214 -69
- package/build/src/library/contract-operations.js +189 -118
- package/build/src/library/contract-types.d.ts +7 -3
- package/build/src/library/contract.d.ts +21 -34
- package/build/src/library/contract.js +29 -287
- package/build/src/library/fleet-result.d.ts +1580 -0
- package/build/src/library/fleet-result.js +98 -0
- package/build/src/library/fleet.d.ts +112 -54
- package/build/src/library/fleet.js +211 -71
- package/build/src/library/input.d.ts +3 -1
- package/build/src/library/input.js +11 -1
- package/build/src/library/keiyaku.d.ts +388 -20
- package/build/src/library/keiyaku.js +13 -21
- package/build/src/library/mutation.d.ts +3 -3
- package/build/src/library/mutation.js +5 -9
- package/build/src/library/nuke.d.ts +1 -1
- package/build/src/library/nuke.js +4 -3
- package/build/src/library/reconcile.d.ts +4 -0
- package/build/src/library/reconcile.js +2 -0
- package/build/src/library/refusal.d.ts +0 -9
- package/build/src/library/refusal.js +0 -7
- package/build/src/protocol/amend.js +56 -50
- package/build/src/protocol/attempt.d.ts +2 -0
- package/build/src/protocol/attempt.js +8 -1
- package/build/src/protocol/completion.js +7 -0
- package/build/src/protocol/deliver.js +6 -2
- package/build/src/protocol/operations.d.ts +4 -1
- package/build/src/protocol/operations.js +5 -2
- package/build/src/protocol/placement.d.ts +1 -0
- package/build/src/protocol/placement.js +52 -38
- package/build/src/protocol/read/observation.d.ts +1 -4
- package/build/src/protocol/read/observation.js +2 -15
- package/build/src/protocol/reintegrate.js +62 -58
- package/build/src/protocol/review.js +5 -0
- package/build/src/protocol/run.js +17 -13
- package/build/src/runtime/proc/run.d.ts +9 -0
- package/build/src/runtime/proc/run.js +51 -4
- package/build/src/runtime/proc/termination.js +26 -22
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/build/src/settlement/holder.d.ts +2 -1
- package/build/src/settlement/holder.js +15 -4
- package/build/src/settlement/settle.js +99 -33
- package/build/src/task/board.d.ts +68 -27
- package/build/src/task/board.js +31 -1
- package/build/src/task/catalog.d.ts +4 -0
- package/build/src/task/catalog.js +23 -0
- package/build/src/task/compose-language.js +33 -7
- package/build/src/task/compose-parser.d.ts +1 -1
- package/build/src/task/compose-parser.js +1 -1
- package/build/src/task/compose.js +2 -0
- package/build/src/task/index.d.ts +12 -4
- package/build/src/task/index.js +97 -16
- package/build/src/task/mutation-result.d.ts +923 -0
- package/build/src/task/mutation-result.js +140 -0
- package/build/src/task/mutation.d.ts +552 -28
- package/build/src/task/mutation.js +304 -97
- package/build/src/task/operations.d.ts +1 -4
- package/build/src/task/operations.js +0 -6
- package/build/src/task/public.d.ts +2 -0
- package/build/src/task/public.js +1 -0
- package/build/src/workspace-place.d.ts +7 -2
- package/build/src/workspace-place.js +34 -24
- package/build/src/world.d.ts +1 -0
- package/build/src/world.js +11 -0
- package/package.json +8 -6
- package/build/src/akuma/request-execution.d.ts +0 -8
- package/build/src/akuma/request-execution.js +0 -98
|
@@ -1,124 +1,118 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
declare const requestEnvelopeSchema: z.ZodObject<{
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
action: z.ZodString;
|
|
5
|
+
payload: z.ZodUnknown;
|
|
6
|
+
}, z.core.$strict>;
|
|
7
|
+
declare const upstreamRequestFailureSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
8
|
+
kind: z.ZodLiteral<"akuma-not-born">;
|
|
9
|
+
id: z.ZodString;
|
|
10
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
11
|
+
kind: z.ZodLiteral<"failed">;
|
|
12
|
+
diagnostic: z.ZodString;
|
|
13
|
+
}, z.core.$strict>]>;
|
|
14
|
+
declare const returnedEnvelopeSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
15
|
+
kind: z.ZodLiteral<"returned">;
|
|
16
|
+
result: z.ZodUnknown;
|
|
17
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
18
|
+
kind: z.ZodLiteral<"failed">;
|
|
19
|
+
failure: z.ZodUnion<readonly [z.ZodObject<{
|
|
20
|
+
kind: z.ZodLiteral<"akuma-not-born">;
|
|
21
|
+
id: z.ZodString;
|
|
22
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
23
|
+
kind: z.ZodLiteral<"failed">;
|
|
24
|
+
diagnostic: z.ZodString;
|
|
25
|
+
}, z.core.$strict>]>;
|
|
26
|
+
}, z.core.$strict>]>;
|
|
27
|
+
declare const receiptEnvelopeSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
28
|
+
id: z.ZodString;
|
|
29
|
+
action: z.ZodString;
|
|
30
|
+
state: z.ZodLiteral<"served">;
|
|
31
|
+
outcome: z.ZodUnion<readonly [z.ZodObject<{
|
|
32
|
+
kind: z.ZodLiteral<"returned">;
|
|
33
|
+
result: z.ZodUnknown;
|
|
34
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
35
|
+
kind: z.ZodLiteral<"failed">;
|
|
36
|
+
failure: z.ZodUnion<readonly [z.ZodObject<{
|
|
37
|
+
kind: z.ZodLiteral<"akuma-not-born">;
|
|
38
|
+
id: z.ZodString;
|
|
39
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
40
|
+
kind: z.ZodLiteral<"failed">;
|
|
41
|
+
diagnostic: z.ZodString;
|
|
42
|
+
}, z.core.$strict>]>;
|
|
43
|
+
}, z.core.$strict>]>;
|
|
44
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
45
|
+
id: z.ZodString;
|
|
46
|
+
action: z.ZodString;
|
|
47
|
+
state: z.ZodLiteral<"served">;
|
|
48
|
+
reference: z.ZodUnknown;
|
|
49
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
50
|
+
id: z.ZodString;
|
|
51
|
+
action: z.ZodString;
|
|
52
|
+
state: z.ZodLiteral<"refused">;
|
|
53
|
+
diagnostic: z.ZodString;
|
|
54
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
55
|
+
id: z.ZodString;
|
|
56
|
+
action: z.ZodString;
|
|
57
|
+
state: z.ZodLiteral<"voided">;
|
|
58
|
+
evidence: z.ZodString;
|
|
59
|
+
failure: z.ZodOptional<z.ZodUnknown>;
|
|
60
|
+
}, z.core.$strict>]>;
|
|
61
|
+
export type RequestEnvelope = z.infer<typeof requestEnvelopeSchema>;
|
|
62
|
+
/**
|
|
63
|
+
* A Body Request operation is owned by the verb that defines its public
|
|
64
|
+
* values. Transport only carries the opaque values produced here.
|
|
65
|
+
*/
|
|
66
|
+
export type RequestCommand<Input, Output, Service, Reference = Service, Context = unknown> = Readonly<{
|
|
67
|
+
action: string;
|
|
68
|
+
encodeRequest(input: Input): unknown;
|
|
69
|
+
decodeRequest(payload: unknown): Input | null;
|
|
70
|
+
encodeResult(result: Output): unknown;
|
|
71
|
+
decodeResult(result: unknown): Output;
|
|
72
|
+
encodeFailure?(error: unknown): unknown | null;
|
|
73
|
+
decodeFailure?(failure: unknown): Error | null;
|
|
74
|
+
encodeService(service: Service): unknown;
|
|
75
|
+
decodeService(service: unknown): Service;
|
|
76
|
+
projectService(service: Service): Reference;
|
|
77
|
+
projectChild?(child: string): Reference;
|
|
78
|
+
decodeReference(reference: unknown): Reference;
|
|
79
|
+
/** The operation owner proves the Body-owned execution capability before use. */
|
|
80
|
+
decodeExecutionContext(value: unknown): Context;
|
|
81
|
+
isPermitted(allowed: readonly string[]): boolean;
|
|
82
|
+
execute(input: Input, context: Context): Promise<Readonly<{
|
|
83
|
+
result: Output;
|
|
84
|
+
}> & (Readonly<{
|
|
85
|
+
service: Service;
|
|
86
|
+
}> | Readonly<{
|
|
87
|
+
child: string;
|
|
88
|
+
}>)>;
|
|
11
89
|
}>;
|
|
12
|
-
export type
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
world: string;
|
|
16
|
-
archetype: string;
|
|
17
|
-
body: string;
|
|
18
|
-
cwd?: string;
|
|
19
|
-
recipe: RequestRecipe;
|
|
90
|
+
export type ErasedRequestCommand = Readonly<{
|
|
91
|
+
action: string;
|
|
92
|
+
resolve(payload: unknown): ErasedRequest | null;
|
|
20
93
|
}>;
|
|
21
|
-
export type
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
94
|
+
export type ErasedRequest = Readonly<{
|
|
95
|
+
payloadJson: string;
|
|
96
|
+
isPermitted(allowed: readonly string[]): boolean;
|
|
97
|
+
execute(context: unknown): Promise<ErasedRequestExecution>;
|
|
98
|
+
encodeFailure(error: unknown): unknown | null;
|
|
99
|
+
projectServiceJson(serviceJson: string): unknown;
|
|
100
|
+
projectChild(child: string): unknown;
|
|
27
101
|
}>;
|
|
28
|
-
export type
|
|
29
|
-
id: string;
|
|
30
|
-
action: "akuma.tell";
|
|
31
|
-
target: AkuId;
|
|
32
|
-
body: string;
|
|
33
|
-
}>;
|
|
34
|
-
export type KillRequestClaim = Readonly<{
|
|
35
|
-
id: string;
|
|
36
|
-
action: "akuma.kill";
|
|
37
|
-
targets: readonly AkuId[];
|
|
38
|
-
}>;
|
|
39
|
-
export type DeliverRequestClaim = Readonly<{
|
|
40
|
-
id: string;
|
|
41
|
-
action: "contract.deliver";
|
|
42
|
-
repoRoot: string;
|
|
43
|
-
contractId: string;
|
|
44
|
-
message?: string;
|
|
45
|
-
includeDirty: boolean;
|
|
46
|
-
materializeConflict: boolean;
|
|
47
|
-
}>;
|
|
48
|
-
export type ReviewRequestClaim = Readonly<{
|
|
49
|
-
id: string;
|
|
50
|
-
action: "contract.review";
|
|
51
|
-
repoRoot: string;
|
|
52
|
-
contractId: string;
|
|
53
|
-
verdict: "satisfied" | "unsatisfied";
|
|
54
|
-
summary?: string;
|
|
55
|
-
}>;
|
|
56
|
-
export type TaskRequestClaim = Readonly<{
|
|
57
|
-
id: string;
|
|
58
|
-
action: TaskMutationAction;
|
|
59
|
-
world: string;
|
|
60
|
-
request: TaskMutationRequest;
|
|
61
|
-
}>;
|
|
62
|
-
export type RequestClaim = CallRequestClaim | WaitRequestClaim | TellRequestClaim | KillRequestClaim | DeliverRequestClaim | ReviewRequestClaim | TaskRequestClaim;
|
|
63
|
-
export type StructuralRequestClaim = (Omit<CallRequestClaim, "recipe"> & Readonly<{
|
|
64
|
-
recipe: unknown;
|
|
65
|
-
}>) | Exclude<RequestClaim, CallRequestClaim>;
|
|
66
|
-
export type UpstreamRequestFailure = Readonly<{
|
|
67
|
-
kind: "akuma-not-born";
|
|
68
|
-
id: AkuId;
|
|
69
|
-
}> | Readonly<{
|
|
70
|
-
kind: "failed";
|
|
71
|
-
diagnostic: string;
|
|
72
|
-
}>;
|
|
73
|
-
export type UpstreamRequestOutcome = Readonly<{
|
|
74
|
-
kind: "returned";
|
|
102
|
+
export type ErasedRequestExecution = Readonly<{
|
|
75
103
|
result: unknown;
|
|
104
|
+
serviceJson: string;
|
|
76
105
|
}> | Readonly<{
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}>;
|
|
80
|
-
export type ForwardedDeliveryReference = Readonly<{
|
|
81
|
-
kind: "accepted-reference";
|
|
82
|
-
repoRoot: string;
|
|
83
|
-
contractId: string;
|
|
84
|
-
deliveryFactId: string;
|
|
85
|
-
}>;
|
|
86
|
-
export type ForwardedReviewReference = Readonly<{
|
|
87
|
-
kind: "accepted-reference";
|
|
88
|
-
repoRoot: string;
|
|
89
|
-
contractId: string;
|
|
90
|
-
reviewFactId: string;
|
|
91
|
-
}>;
|
|
92
|
-
export type ForwardedTaskReference = Readonly<{
|
|
93
|
-
kind: "served-reference";
|
|
94
|
-
action: TaskMutationAction;
|
|
95
|
-
}>;
|
|
96
|
-
type ReceiptBase<A extends RequestClaim["action"], S extends string> = Readonly<{
|
|
97
|
-
id: string;
|
|
98
|
-
action: A;
|
|
99
|
-
state: S;
|
|
106
|
+
result: unknown;
|
|
107
|
+
child: string;
|
|
100
108
|
}>;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
reference: ForwardedTaskReference;
|
|
109
|
-
}>) | (ReceiptBase<Exclude<RequestClaim["action"], "akuma.call">, "served"> & Readonly<{
|
|
110
|
-
outcome: UpstreamRequestOutcome;
|
|
111
|
-
}>) | (ReceiptBase<RequestClaim["action"], "refused"> & Readonly<{
|
|
112
|
-
diagnostic: string;
|
|
113
|
-
}>) | (ReceiptBase<RequestClaim["action"], "voided"> & Readonly<{
|
|
114
|
-
evidence: string;
|
|
115
|
-
}>);
|
|
116
|
-
export declare function absolute(value: unknown): value is string;
|
|
117
|
-
export declare function canonicalAkuId(value: unknown): AkuId | null;
|
|
118
|
-
export declare function decodeRecipe(value: unknown): RequestRecipe | null;
|
|
119
|
-
export declare function decodeClaim(bytes: string, fileId: string): StructuralRequestClaim | null;
|
|
120
|
-
export declare function decodeReceipt(bytes: string, id: string, action: RequestClaim["action"]): RequestReceipt | null;
|
|
121
|
-
export declare function requestPayload(claim: RequestClaim): unknown;
|
|
109
|
+
/** Erases only static TypeScript parameters; each operation codec remains captured by its owner descriptor. */
|
|
110
|
+
export declare function eraseRequestCommand<Input, Output, Service, Reference, Context>(command: RequestCommand<Input, Output, Service, Reference, Context>): ErasedRequestCommand;
|
|
111
|
+
export type UpstreamRequestFailure = z.infer<typeof upstreamRequestFailureSchema>;
|
|
112
|
+
export type ReturnedEnvelope = z.infer<typeof returnedEnvelopeSchema>;
|
|
113
|
+
export type ReceiptEnvelope = z.infer<typeof receiptEnvelopeSchema>;
|
|
114
|
+
export declare function decodeEnvelope(bytes: string, fileId: string): RequestEnvelope | null;
|
|
115
|
+
export declare function decodeReceiptEnvelope(bytes: string, id: string, action: string): ReceiptEnvelope | null;
|
|
122
116
|
export declare function requestPath(directory: string, id: string): string;
|
|
123
117
|
export declare function receiptPath(directory: string, id: string): string;
|
|
124
118
|
export declare function atomicJson(path: string, value: unknown): Promise<void>;
|
|
@@ -1,205 +1,67 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { rename, rm, writeFile } from "node:fs/promises";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { archetypeName, parseAkuId } from "./identity.js";
|
|
6
|
-
import { decodeProviderOptions, decodeReadonlyRestraint } from "./provider-recipe.js";
|
|
7
|
-
import { decodeProviderExecution } from "./providers/index.js";
|
|
8
|
-
import { decodeTaskMutationRequest, isTaskMutationAction, } from "../task/mutation.js";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { z } from "zod";
|
|
9
5
|
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const id = canonicalAkuId(item);
|
|
40
|
-
if (id === null || (ids.length > 0 && Buffer.compare(Buffer.from(ids.at(-1)), Buffer.from(id)) >= 0))
|
|
41
|
-
return null;
|
|
42
|
-
ids.push(id);
|
|
43
|
-
}
|
|
44
|
-
return ids;
|
|
45
|
-
}
|
|
46
|
-
export function decodeRecipe(value) {
|
|
47
|
-
const recipe = object(value);
|
|
48
|
-
if (recipe === null)
|
|
49
|
-
return null;
|
|
50
|
-
const expected = [
|
|
51
|
-
"allowed",
|
|
52
|
-
"options",
|
|
53
|
-
"provider",
|
|
54
|
-
...(recipe.description === undefined ? [] : ["description"]),
|
|
55
|
-
...(recipe.readonly === undefined ? [] : ["readonly"]),
|
|
56
|
-
];
|
|
57
|
-
if (!exactKeys(recipe, expected) ||
|
|
58
|
-
(recipe.description !== undefined &&
|
|
59
|
-
(typeof recipe.description !== "string" || recipe.description.trim().length === 0)))
|
|
60
|
-
return null;
|
|
61
|
-
try {
|
|
62
|
-
const options = decodeProviderOptions(recipe.options);
|
|
63
|
-
const readonly = recipe.readonly === undefined ? undefined : decodeReadonlyRestraint(recipe.readonly);
|
|
64
|
-
if ((options.readonly === true) !== (readonly !== undefined))
|
|
65
|
-
return null;
|
|
66
|
-
return Object.freeze({
|
|
67
|
-
...(recipe.description === undefined ? {} : { description: recipe.description }),
|
|
68
|
-
allowed: decodeAllowedActions(recipe.allowed),
|
|
69
|
-
provider: decodeProviderExecution(recipe.provider),
|
|
70
|
-
options,
|
|
71
|
-
...(readonly === undefined ? {} : { readonly }),
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
catch {
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
function contractId(value) {
|
|
79
|
-
return typeof value === "string" && /^kei\/[^/\s]+$/u.test(value) ? value : null;
|
|
80
|
-
}
|
|
81
|
-
function decodeCall(id, payload) {
|
|
82
|
-
const expected = ["archetype", "body", "recipe", "world", ...(payload.cwd === undefined ? [] : ["cwd"])];
|
|
83
|
-
if (!exactKeys(payload, expected) ||
|
|
84
|
-
typeof payload.body !== "string" ||
|
|
85
|
-
!absolute(payload.world) ||
|
|
86
|
-
(payload.cwd !== undefined && !absolute(payload.cwd)))
|
|
87
|
-
return null;
|
|
88
|
-
try {
|
|
89
|
-
archetypeName(payload.archetype);
|
|
90
|
-
}
|
|
91
|
-
catch {
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
return {
|
|
95
|
-
id,
|
|
96
|
-
action: "akuma.call",
|
|
97
|
-
world: payload.world,
|
|
98
|
-
archetype: payload.archetype,
|
|
99
|
-
body: payload.body,
|
|
100
|
-
recipe: payload.recipe,
|
|
101
|
-
...(payload.cwd === undefined ? {} : { cwd: payload.cwd }),
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
function decodeWait(id, payload) {
|
|
105
|
-
const targets = canonicalTargets(payload.targets);
|
|
106
|
-
const expected = ["completion", "targets", ...(payload.timeoutMs === undefined ? [] : ["timeoutMs"])];
|
|
107
|
-
if (!exactKeys(payload, expected) ||
|
|
108
|
-
targets === null ||
|
|
109
|
-
(payload.completion !== "any" && payload.completion !== "all") ||
|
|
110
|
-
(payload.timeoutMs !== undefined && (!Number.isSafeInteger(payload.timeoutMs) || payload.timeoutMs < 0)))
|
|
111
|
-
return null;
|
|
6
|
+
const requestIdSchema = z.string().regex(UUID);
|
|
7
|
+
const actionSchema = z.string().refine((value) => value.trim() !== "");
|
|
8
|
+
const requestEnvelopeSchema = z.object({ id: requestIdSchema, action: actionSchema, payload: z.unknown() }).strict();
|
|
9
|
+
const upstreamRequestFailureSchema = z.union([
|
|
10
|
+
z.object({ kind: z.literal("akuma-not-born"), id: z.string() }).strict(),
|
|
11
|
+
z.object({ kind: z.literal("failed"), diagnostic: z.string() }).strict(),
|
|
12
|
+
]);
|
|
13
|
+
const returnedEnvelopeSchema = z.union([
|
|
14
|
+
z.object({ kind: z.literal("returned"), result: z.unknown() }).strict(),
|
|
15
|
+
z.object({ kind: z.literal("failed"), failure: upstreamRequestFailureSchema }).strict(),
|
|
16
|
+
]);
|
|
17
|
+
const receiptEnvelopeSchema = z.union([
|
|
18
|
+
z
|
|
19
|
+
.object({ id: requestIdSchema, action: actionSchema, state: z.literal("served"), outcome: returnedEnvelopeSchema })
|
|
20
|
+
.strict(),
|
|
21
|
+
z.object({ id: requestIdSchema, action: actionSchema, state: z.literal("served"), reference: z.unknown() }).strict(),
|
|
22
|
+
z.object({ id: requestIdSchema, action: actionSchema, state: z.literal("refused"), diagnostic: z.string() }).strict(),
|
|
23
|
+
z
|
|
24
|
+
.object({
|
|
25
|
+
id: requestIdSchema,
|
|
26
|
+
action: actionSchema,
|
|
27
|
+
state: z.literal("voided"),
|
|
28
|
+
evidence: z.string(),
|
|
29
|
+
failure: z.unknown().optional(),
|
|
30
|
+
})
|
|
31
|
+
.strict(),
|
|
32
|
+
]);
|
|
33
|
+
/** Erases only static TypeScript parameters; each operation codec remains captured by its owner descriptor. */
|
|
34
|
+
export function eraseRequestCommand(command) {
|
|
112
35
|
return {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
36
|
+
action: command.action,
|
|
37
|
+
resolve: (payload) => {
|
|
38
|
+
const input = command.decodeRequest(payload);
|
|
39
|
+
if (input === null)
|
|
40
|
+
return null;
|
|
41
|
+
return {
|
|
42
|
+
payloadJson: JSON.stringify(command.encodeRequest(input)),
|
|
43
|
+
isPermitted: (allowed) => command.isPermitted(allowed),
|
|
44
|
+
execute: async (context) => {
|
|
45
|
+
const served = await command.execute(input, command.decodeExecutionContext(context));
|
|
46
|
+
return "child" in served
|
|
47
|
+
? { result: command.encodeResult(served.result), child: served.child }
|
|
48
|
+
: {
|
|
49
|
+
result: command.encodeResult(served.result),
|
|
50
|
+
serviceJson: JSON.stringify(command.encodeService(served.service)),
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
encodeFailure: (error) => command.encodeFailure?.(error) ?? null,
|
|
54
|
+
projectServiceJson: (serviceJson) => command.projectService(command.decodeService(JSON.parse(serviceJson))),
|
|
55
|
+
projectChild: (child) => {
|
|
56
|
+
if (command.projectChild === undefined)
|
|
57
|
+
throw new Error(`request ${command.action} has no child reference codec`);
|
|
58
|
+
return command.projectChild(child);
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
},
|
|
118
62
|
};
|
|
119
63
|
}
|
|
120
|
-
function
|
|
121
|
-
const target = canonicalAkuId(payload.target);
|
|
122
|
-
return exactKeys(payload, ["body", "target"]) && target !== null && typeof payload.body === "string"
|
|
123
|
-
? { id, action: "akuma.tell", target, body: payload.body }
|
|
124
|
-
: null;
|
|
125
|
-
}
|
|
126
|
-
function decodeKill(id, payload) {
|
|
127
|
-
const targets = canonicalTargets(payload.targets);
|
|
128
|
-
return exactKeys(payload, ["targets"]) && targets !== null ? { id, action: "akuma.kill", targets } : null;
|
|
129
|
-
}
|
|
130
|
-
function decodeDeliver(id, payload) {
|
|
131
|
-
const valid = exactKeys(payload, [
|
|
132
|
-
"contractId",
|
|
133
|
-
"includeDirty",
|
|
134
|
-
"materializeConflict",
|
|
135
|
-
"repoRoot",
|
|
136
|
-
...(payload.message === undefined ? [] : ["message"]),
|
|
137
|
-
]);
|
|
138
|
-
const selected = contractId(payload.contractId);
|
|
139
|
-
return valid &&
|
|
140
|
-
selected !== null &&
|
|
141
|
-
absolute(payload.repoRoot) &&
|
|
142
|
-
typeof payload.includeDirty === "boolean" &&
|
|
143
|
-
typeof payload.materializeConflict === "boolean" &&
|
|
144
|
-
(payload.message === undefined || (typeof payload.message === "string" && payload.message.trim().length > 0))
|
|
145
|
-
? {
|
|
146
|
-
id,
|
|
147
|
-
action: "contract.deliver",
|
|
148
|
-
repoRoot: payload.repoRoot,
|
|
149
|
-
contractId: selected,
|
|
150
|
-
includeDirty: payload.includeDirty,
|
|
151
|
-
materializeConflict: payload.materializeConflict,
|
|
152
|
-
...(payload.message === undefined ? {} : { message: payload.message }),
|
|
153
|
-
}
|
|
154
|
-
: null;
|
|
155
|
-
}
|
|
156
|
-
function decodeReview(id, payload) {
|
|
157
|
-
const valid = exactKeys(payload, [
|
|
158
|
-
"contractId",
|
|
159
|
-
"repoRoot",
|
|
160
|
-
"verdict",
|
|
161
|
-
...(payload.summary === undefined ? [] : ["summary"]),
|
|
162
|
-
]);
|
|
163
|
-
const selected = contractId(payload.contractId);
|
|
164
|
-
return valid &&
|
|
165
|
-
selected !== null &&
|
|
166
|
-
absolute(payload.repoRoot) &&
|
|
167
|
-
(payload.verdict === "satisfied" || payload.verdict === "unsatisfied") &&
|
|
168
|
-
(payload.summary === undefined || (typeof payload.summary === "string" && payload.summary.trim().length > 0))
|
|
169
|
-
? {
|
|
170
|
-
id,
|
|
171
|
-
action: "contract.review",
|
|
172
|
-
repoRoot: payload.repoRoot,
|
|
173
|
-
contractId: selected,
|
|
174
|
-
verdict: payload.verdict,
|
|
175
|
-
...(payload.summary === undefined ? {} : { summary: payload.summary }),
|
|
176
|
-
}
|
|
177
|
-
: null;
|
|
178
|
-
}
|
|
179
|
-
function decodeTask(id, action, payload) {
|
|
180
|
-
if (!isTaskMutationAction(action) || !exactKeys(payload, ["request", "world"]) || !absolute(payload.world))
|
|
181
|
-
return null;
|
|
182
|
-
try {
|
|
183
|
-
return {
|
|
184
|
-
id,
|
|
185
|
-
action,
|
|
186
|
-
world: payload.world,
|
|
187
|
-
request: decodeTaskMutationRequest(action, payload.request),
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
catch {
|
|
191
|
-
return null;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
const CLAIM_DECODERS = {
|
|
195
|
-
"akuma.call": decodeCall,
|
|
196
|
-
"akuma.wait": decodeWait,
|
|
197
|
-
"akuma.tell": decodeTell,
|
|
198
|
-
"akuma.kill": decodeKill,
|
|
199
|
-
"contract.deliver": decodeDeliver,
|
|
200
|
-
"contract.review": decodeReview,
|
|
201
|
-
};
|
|
202
|
-
export function decodeClaim(bytes, fileId) {
|
|
64
|
+
export function decodeEnvelope(bytes, fileId) {
|
|
203
65
|
let decoded;
|
|
204
66
|
try {
|
|
205
67
|
decoded = JSON.parse(bytes);
|
|
@@ -207,107 +69,10 @@ export function decodeClaim(bytes, fileId) {
|
|
|
207
69
|
catch {
|
|
208
70
|
return null;
|
|
209
71
|
}
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
!exactKeys(value, ["action", "id", "payload"]) ||
|
|
213
|
-
!UUID.test(fileId) ||
|
|
214
|
-
typeof value.id !== "string" ||
|
|
215
|
-
!UUID.test(value.id))
|
|
216
|
-
return null;
|
|
217
|
-
const payload = object(value.payload);
|
|
218
|
-
if (payload === null || typeof value.action !== "string")
|
|
219
|
-
return null;
|
|
220
|
-
const decoder = CLAIM_DECODERS[value.action];
|
|
221
|
-
return decoder === undefined ? decodeTask(value.id, value.action, payload) : decoder(value.id, payload);
|
|
222
|
-
}
|
|
223
|
-
function outcome(value) {
|
|
224
|
-
const input = object(value);
|
|
225
|
-
if (input?.kind === "returned" && exactKeys(input, ["kind", "result"])) {
|
|
226
|
-
return { kind: input.kind, result: input.result };
|
|
227
|
-
}
|
|
228
|
-
const failure = object(input?.failure);
|
|
229
|
-
if (input?.kind !== "failed" || !exactKeys(input, ["failure", "kind"]) || failure === null)
|
|
230
|
-
return null;
|
|
231
|
-
if (failure.kind === "akuma-not-born" && exactKeys(failure, ["id", "kind"])) {
|
|
232
|
-
const id = canonicalAkuId(failure.id);
|
|
233
|
-
return id === null ? null : { kind: input.kind, failure: { kind: failure.kind, id } };
|
|
234
|
-
}
|
|
235
|
-
return failure.kind === "failed" &&
|
|
236
|
-
exactKeys(failure, ["diagnostic", "kind"]) &&
|
|
237
|
-
typeof failure.diagnostic === "string"
|
|
238
|
-
? { kind: input.kind, failure: { kind: failure.kind, diagnostic: failure.diagnostic } }
|
|
239
|
-
: null;
|
|
72
|
+
const parsed = requestEnvelopeSchema.safeParse(decoded);
|
|
73
|
+
return UUID.test(fileId) && parsed.success ? parsed.data : null;
|
|
240
74
|
}
|
|
241
|
-
function
|
|
242
|
-
if (value.state === "refused" &&
|
|
243
|
-
exactKeys(value, ["action", "diagnostic", "id", "state"]) &&
|
|
244
|
-
typeof value.diagnostic === "string") {
|
|
245
|
-
return { id, action, state: value.state, diagnostic: value.diagnostic };
|
|
246
|
-
}
|
|
247
|
-
if (value.state === "voided" &&
|
|
248
|
-
exactKeys(value, ["action", "evidence", "id", "state"]) &&
|
|
249
|
-
typeof value.evidence === "string") {
|
|
250
|
-
return { id, action, state: value.state, evidence: value.evidence };
|
|
251
|
-
}
|
|
252
|
-
if (action !== "akuma.call" && value.state === "served" && exactKeys(value, ["action", "id", "outcome", "state"])) {
|
|
253
|
-
const decoded = outcome(value.outcome);
|
|
254
|
-
return decoded === null ? null : { id, action, state: value.state, outcome: decoded };
|
|
255
|
-
}
|
|
256
|
-
return null;
|
|
257
|
-
}
|
|
258
|
-
function reference(value, action) {
|
|
259
|
-
const input = object(value);
|
|
260
|
-
const field = action === "contract.deliver" ? "deliveryFactId" : "reviewFactId";
|
|
261
|
-
if (input === null ||
|
|
262
|
-
!exactKeys(input, ["contractId", field, "kind", "repoRoot"]) ||
|
|
263
|
-
input.kind !== "accepted-reference" ||
|
|
264
|
-
!absolute(input.repoRoot) ||
|
|
265
|
-
contractId(input.contractId) === null ||
|
|
266
|
-
typeof input[field] !== "string" ||
|
|
267
|
-
input[field].trim().length === 0)
|
|
268
|
-
return null;
|
|
269
|
-
return action === "contract.deliver"
|
|
270
|
-
? {
|
|
271
|
-
kind: input.kind,
|
|
272
|
-
repoRoot: input.repoRoot,
|
|
273
|
-
contractId: input.contractId,
|
|
274
|
-
deliveryFactId: input.deliveryFactId,
|
|
275
|
-
}
|
|
276
|
-
: {
|
|
277
|
-
kind: input.kind,
|
|
278
|
-
repoRoot: input.repoRoot,
|
|
279
|
-
contractId: input.contractId,
|
|
280
|
-
reviewFactId: input.reviewFactId,
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
function decodeCallReceipt(value, id) {
|
|
284
|
-
if (value.state !== "served" || !exactKeys(value, ["action", "child", "id", "state"]))
|
|
285
|
-
return null;
|
|
286
|
-
const child = canonicalAkuId(value.child);
|
|
287
|
-
return child === null ? null : { id, action: "akuma.call", state: value.state, child };
|
|
288
|
-
}
|
|
289
|
-
function decodeContractReceipt(value, id, action) {
|
|
290
|
-
if (value.state !== "served" || !exactKeys(value, ["action", "id", "reference", "state"]))
|
|
291
|
-
return null;
|
|
292
|
-
const selected = reference(value.reference, action);
|
|
293
|
-
if (selected === null)
|
|
294
|
-
return null;
|
|
295
|
-
return action === "contract.deliver"
|
|
296
|
-
? { id, action, state: value.state, reference: selected }
|
|
297
|
-
: { id, action, state: value.state, reference: selected };
|
|
298
|
-
}
|
|
299
|
-
function decodeTaskReceipt(value, id, action) {
|
|
300
|
-
if (value.state !== "served" || !exactKeys(value, ["action", "id", "reference", "state"]))
|
|
301
|
-
return null;
|
|
302
|
-
const selected = object(value.reference);
|
|
303
|
-
if (selected === null ||
|
|
304
|
-
!exactKeys(selected, ["action", "kind"]) ||
|
|
305
|
-
selected.kind !== "served-reference" ||
|
|
306
|
-
selected.action !== action)
|
|
307
|
-
return null;
|
|
308
|
-
return { id, action, state: value.state, reference: { kind: selected.kind, action } };
|
|
309
|
-
}
|
|
310
|
-
export function decodeReceipt(bytes, id, action) {
|
|
75
|
+
export function decodeReceiptEnvelope(bytes, id, action) {
|
|
311
76
|
let decoded;
|
|
312
77
|
try {
|
|
313
78
|
decoded = JSON.parse(bytes);
|
|
@@ -315,28 +80,8 @@ export function decodeReceipt(bytes, id, action) {
|
|
|
315
80
|
catch {
|
|
316
81
|
return null;
|
|
317
82
|
}
|
|
318
|
-
const
|
|
319
|
-
|
|
320
|
-
return null;
|
|
321
|
-
const shared = envelope(value, id, action);
|
|
322
|
-
if (shared !== null)
|
|
323
|
-
return shared;
|
|
324
|
-
if (action === "akuma.call")
|
|
325
|
-
return decodeCallReceipt(value, id);
|
|
326
|
-
if (action === "contract.deliver" || action === "contract.review")
|
|
327
|
-
return decodeContractReceipt(value, id, action);
|
|
328
|
-
if (isTaskMutationAction(action))
|
|
329
|
-
return decodeTaskReceipt(value, id, action);
|
|
330
|
-
return null;
|
|
331
|
-
}
|
|
332
|
-
export function requestPayload(claim) {
|
|
333
|
-
if (isTaskMutationAction(claim.action)) {
|
|
334
|
-
const task = claim;
|
|
335
|
-
const { action: _action, ...request } = task.request;
|
|
336
|
-
return { world: task.world, request };
|
|
337
|
-
}
|
|
338
|
-
const { id: _id, action: _action, ...payload } = claim;
|
|
339
|
-
return payload;
|
|
83
|
+
const parsed = receiptEnvelopeSchema.safeParse(decoded);
|
|
84
|
+
return parsed.success && parsed.data.id === id && parsed.data.action === action ? parsed.data : null;
|
|
340
85
|
}
|
|
341
86
|
export function requestPath(directory, id) {
|
|
342
87
|
return join(directory, `${id}.request.json`);
|