@astrosheep/keiyaku 4.6.31 → 4.6.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -17
- package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +16 -11
- package/build/plugins/claude/skills/keiyaku-babysit/SKILL.md +5 -3
- package/build/plugins/claude/skills/keiyaku-bind/SKILL.md +4 -3
- package/build/plugins/claude/skills/keiyaku-debt/SKILL.md +17 -17
- package/build/plugins/claude/skills/keiyaku-workflow/SKILL.md +4 -3
- package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +16 -11
- package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +5 -3
- package/build/plugins/codex/skills/keiyaku-bind/SKILL.md +4 -3
- package/build/plugins/codex/skills/keiyaku-debt/SKILL.md +17 -17
- package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +4 -3
- package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +16 -11
- package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +5 -3
- package/build/plugins/opencode/skills/keiyaku-bind/SKILL.md +4 -3
- package/build/plugins/opencode/skills/keiyaku-debt/SKILL.md +17 -17
- package/build/plugins/opencode/skills/keiyaku-workflow/SKILL.md +4 -3
- package/build/plugins/pi/README.md +16 -18
- package/build/plugins/pi/akuma-tools.ts +31 -38
- package/build/plugins/pi/keiyaku.ts +15 -4
- package/build/skills/keiyaku-akuma/SKILL.md +16 -11
- package/build/skills/keiyaku-babysit/SKILL.md +5 -3
- package/build/skills/keiyaku-bind/SKILL.md +4 -3
- package/build/skills/keiyaku-debt/SKILL.md +17 -17
- package/build/skills/keiyaku-workflow/SKILL.md +4 -3
- package/build/src/akuma/akuma-call.d.ts +3 -5
- package/build/src/akuma/akuma-call.js +7 -10
- package/build/src/akuma/akuma-errors.d.ts +7 -4
- package/build/src/akuma/akuma-errors.js +16 -12
- package/build/src/akuma/akuma-instance.d.ts +39 -303
- package/build/src/akuma/akuma-instance.js +48 -48
- package/build/src/akuma/akuma-observe.d.ts +5 -4
- package/build/src/akuma/akuma-observe.js +1 -7
- package/build/src/akuma/akuma-owner.d.ts +14 -6
- package/build/src/akuma/akuma-owner.js +33 -27
- package/build/src/akuma/akuma-selection-execution.d.ts +22 -19
- package/build/src/akuma/akuma-selection-execution.js +71 -124
- package/build/src/akuma/akuma-wait.d.ts +3 -3
- package/build/src/akuma/akuma.d.ts +47 -384
- package/build/src/akuma/akuma.js +8 -58
- package/build/src/akuma/archetype.d.ts +16 -19
- package/build/src/akuma/archetype.js +48 -49
- package/build/src/akuma/body.js +31 -26
- package/build/src/akuma/call-initial-tell.d.ts +4 -1
- package/build/src/akuma/call-initial-tell.js +9 -1
- package/build/src/akuma/call-input.d.ts +8 -1
- package/build/src/akuma/call-input.js +27 -18
- package/build/src/akuma/caller.js +2 -1
- package/build/src/akuma/detached-body.js +1 -1
- package/build/src/akuma/heart/facts.d.ts +5 -4
- package/build/src/akuma/heart/facts.js +5 -5
- package/build/src/akuma/heart/soul.js +20 -4
- package/build/src/akuma/identity.d.ts +1 -1
- package/build/src/akuma/identity.js +9 -4
- package/build/src/akuma/index.d.ts +6 -7
- package/build/src/akuma/index.js +2 -3
- package/build/src/akuma/projection.d.ts +3 -0
- package/build/src/akuma/provider-recipe.js +3 -2
- package/build/src/akuma/providers/acp/config.js +11 -10
- package/build/src/akuma/providers/acp/index.js +2 -1
- package/build/src/akuma/providers/codex-app-server/index.js +7 -1
- package/build/src/akuma/providers/grok-build/index.js +2 -1
- package/build/src/akuma/providers/index.d.ts +0 -1
- package/build/src/akuma/providers/index.js +0 -8
- package/build/src/akuma/providers/paseo/index.js +7 -4
- package/build/src/akuma/providers/pi/index.js +4 -3
- package/build/src/akuma/publication.d.ts +1 -2
- package/build/src/akuma/publication.js +16 -14
- package/build/src/akuma/schema.d.ts +3 -49
- package/build/src/akuma/schema.js +6 -147
- package/build/src/akuma/selection-observation.d.ts +281 -240
- package/build/src/akuma/selection-observation.js +122 -68
- package/build/src/akuma/status-projection.d.ts +49 -285
- package/build/src/akuma/status-projection.js +178 -138
- package/build/src/body/amend.js +2 -1
- package/build/src/body/arc.js +3 -2
- package/build/src/body/criteria.js +4 -3
- package/build/src/body/decode.js +2 -1
- package/build/src/body/envelope.js +2 -1
- package/build/src/body/region.d.ts +1 -3
- package/build/src/body/region.js +3 -8
- package/build/src/body-host.d.ts +4 -11
- package/build/src/body-host.js +5 -4
- package/build/src/bounded-list.js +2 -1
- package/build/src/cli/commands/akuma-grammar.d.ts +109 -66
- package/build/src/cli/commands/akuma-grammar.js +75 -95
- package/build/src/cli/commands/akuma.d.ts +8 -3
- package/build/src/cli/commands/akuma.js +63 -122
- package/build/src/cli/commands/contract-grammar.d.ts +3 -135
- package/build/src/cli/commands/contract-grammar.js +125 -218
- package/build/src/cli/commands/contract-help.d.ts +24 -21
- package/build/src/cli/commands/contract-help.js +43 -35
- package/build/src/cli/commands/contract.d.ts +6 -18
- package/build/src/cli/commands/contract.js +65 -272
- package/build/src/cli/commands/debt-grammar.d.ts +2 -4
- package/build/src/cli/commands/debt-grammar.js +22 -190
- package/build/src/cli/commands/debt.js +10 -87
- package/build/src/cli/commands/report.d.ts +2 -4
- package/build/src/cli/coordinates.d.ts +1 -1
- package/build/src/cli/coordinates.js +1 -1
- package/build/src/cli/main.js +9 -3
- package/build/src/cli/parse.d.ts +80 -3
- package/build/src/cli/parse.js +76 -16
- package/build/src/cli/render/akuma-activity.d.ts +19 -24
- package/build/src/cli/render/akuma-activity.js +164 -259
- package/build/src/cli/render/akuma.d.ts +3 -3
- package/build/src/cli/render/akuma.js +36 -43
- package/build/src/cli/render/catalog.d.ts +2 -5
- package/build/src/cli/render/catalog.js +2 -33
- package/build/src/cli/render/contract-history.js +1 -2
- package/build/src/cli/render/contract-observation.d.ts +0 -7
- package/build/src/cli/render/contract-observation.js +0 -3
- package/build/src/cli/render/contract.d.ts +7 -9
- package/build/src/cli/render/contract.js +35 -64
- package/build/src/cli/render/debt.d.ts +3 -11
- package/build/src/cli/render/debt.js +17 -88
- package/build/src/cli/render/delivery-preview.js +4 -4
- package/build/src/cli/render/kanshi-akuma.d.ts +5 -3
- package/build/src/cli/render/kanshi-akuma.js +22 -18
- package/build/src/cli/render/kanshi.d.ts +1 -3
- package/build/src/cli/render/kanshi.js +16 -39
- package/build/src/cli/render/receipt.d.ts +21 -12
- package/build/src/cli/render/receipt.js +49 -44
- package/build/src/cli/render/refusal.d.ts +4 -3
- package/build/src/cli/render/refusal.js +15 -17
- package/build/src/cli/render/settings.d.ts +1 -1
- package/build/src/cli/render/terminal.d.ts +9 -8
- package/build/src/cli/render/terminal.js +48 -32
- package/build/src/cli/render/verbs.d.ts +3 -1
- package/build/src/cli/render/verbs.js +74 -116
- package/build/src/cli/runtime.js +66 -65
- package/build/src/cli/streams.d.ts +2 -9
- package/build/src/cli/streams.js +8 -1
- package/build/src/cli/usage.d.ts +2 -1
- package/build/src/cli/usage.js +3 -2
- package/build/src/contract-worktree.js +2 -10
- package/build/src/core/facts/codec.js +9 -23
- package/build/src/core/facts/errors.d.ts +2 -1
- package/build/src/core/facts/errors.js +3 -3
- package/build/src/core/facts/types.d.ts +2 -13
- package/build/src/core/facts/types.js +1 -6
- package/build/src/core/verbs/abandon.d.ts +1 -2
- package/build/src/core/verbs/amend.d.ts +1 -2
- package/build/src/core/verbs/arc.d.ts +1 -2
- package/build/src/core/verbs/attestation.d.ts +1 -2
- package/build/src/core/verbs/bind.d.ts +1 -2
- package/build/src/core/verbs/deliver.d.ts +1 -2
- package/build/src/core/verbs/placement.d.ts +1 -2
- package/build/src/core/verbs/reintegrate.d.ts +1 -2
- package/build/src/debt/board.d.ts +14 -94
- package/build/src/debt/board.js +25 -160
- package/build/src/debt/catalog.d.ts +0 -2
- package/build/src/debt/catalog.js +1 -22
- package/build/src/debt/document.d.ts +8 -11
- package/build/src/debt/document.js +19 -62
- package/build/src/debt/identity.d.ts +2 -14
- package/build/src/debt/identity.js +19 -49
- package/build/src/debt/index.d.ts +81 -219
- package/build/src/debt/index.js +61 -110
- package/build/src/debt/input.d.ts +19 -5
- package/build/src/debt/input.js +51 -177
- package/build/src/debt/lifecycle-operations.d.ts +1 -3
- package/build/src/debt/lifecycle-operations.js +1 -73
- package/build/src/debt/operation-types.d.ts +24 -128
- package/build/src/debt/operation-types.js +6 -62
- package/build/src/debt/operations.d.ts +8 -17
- package/build/src/debt/operations.js +58 -154
- package/build/src/debt/store.d.ts +0 -2
- package/build/src/debt/store.js +32 -87
- package/build/src/errors.d.ts +28 -0
- package/build/src/errors.js +26 -0
- package/build/src/git/hooks.d.ts +1 -1
- package/build/src/git/observe.d.ts +3 -0
- package/build/src/git/observe.js +19 -5
- package/build/src/git/reconcile.d.ts +3 -16
- package/build/src/git/reconcile.js +0 -18
- package/build/src/git/repository.d.ts +2 -1
- package/build/src/git/repository.js +3 -3
- package/build/src/git/target-placement.d.ts +4 -4
- package/build/src/git/target.d.ts +2 -2
- package/build/src/git/tender.d.ts +1 -2
- package/build/src/git/tender.js +5 -12
- package/build/src/identity/coordinates.d.ts +1 -1
- package/build/src/identity/coordinates.js +3 -2
- package/build/src/identity/normalize.js +2 -1
- package/build/src/identity/selector.js +4 -3
- package/build/src/index.d.ts +34 -57
- package/build/src/index.js +11 -36
- package/build/src/kanshi/counts.d.ts +3 -8
- package/build/src/kanshi/counts.js +6 -14
- package/build/src/kanshi/index.d.ts +22 -7
- package/build/src/kanshi/index.js +30 -4
- package/build/src/kanshi/read.d.ts +81 -270
- package/build/src/kanshi/read.js +39 -199
- package/build/src/kanshi/report.d.ts +340 -1619
- package/build/src/kanshi/report.js +19 -31
- package/build/src/library/address.d.ts +11 -11
- package/build/src/library/address.js +34 -27
- package/build/src/library/akuma-creation.d.ts +210 -79
- package/build/src/library/akuma-creation.js +201 -242
- package/build/src/library/akumas.d.ts +24 -5
- package/build/src/library/akumas.js +96 -29
- package/build/src/library/bind.d.ts +7 -10
- package/build/src/library/bind.js +2 -8
- package/build/src/library/continuation.d.ts +141 -231
- package/build/src/library/continuation.js +22 -31
- package/build/src/library/contract-address.d.ts +6 -9
- package/build/src/library/contract-address.js +11 -16
- package/build/src/library/contract-composition.d.ts +2 -3
- package/build/src/library/contract-composition.js +12 -19
- package/build/src/library/contract-creation.js +33 -34
- package/build/src/library/contract-outcomes.d.ts +1278 -806
- package/build/src/library/contract-outcomes.js +11 -37
- package/build/src/library/contract-settings.d.ts +1 -2
- package/build/src/library/contract-settings.js +5 -7
- package/build/src/library/contract-types.d.ts +42 -67
- package/build/src/library/contract-types.js +15 -56
- package/build/src/library/contract-wait.d.ts +40 -3
- package/build/src/library/contract-wait.js +28 -21
- package/build/src/library/delivery.d.ts +366 -389
- package/build/src/library/delivery.js +5 -25
- package/build/src/library/input.d.ts +31 -5
- package/build/src/library/input.js +40 -40
- package/build/src/library/invocation.d.ts +13 -11
- package/build/src/library/invocation.js +69 -58
- package/build/src/library/kei.d.ts +16 -8
- package/build/src/library/kei.js +459 -19
- package/build/src/library/keiyaku-attribution.d.ts +0 -8
- package/build/src/library/keiyaku-attribution.js +0 -11
- package/build/src/library/keiyaku-classify.d.ts +2 -2
- package/build/src/library/keiyaku-classify.js +40 -59
- package/build/src/library/keiyaku-coordinates.d.ts +3 -8
- package/build/src/library/keiyaku-coordinates.js +6 -26
- package/build/src/library/keiyaku-debt.d.ts +21 -93
- package/build/src/library/keiyaku-debt.js +8 -157
- package/build/src/library/keiyaku-identity.js +5 -4
- package/build/src/library/keiyaku-verbs.d.ts +4004 -3885
- package/build/src/library/keiyaku-verbs.js +309 -271
- package/build/src/library/keiyaku.d.ts +30 -860
- package/build/src/library/keiyaku.js +169 -256
- package/build/src/library/nuke.d.ts +4 -2
- package/build/src/library/nuke.js +5 -1
- package/build/src/library/outcome.d.ts +424 -307
- package/build/src/library/outcome.js +167 -362
- package/build/src/library/reconcile.d.ts +331 -143
- package/build/src/library/reconcile.js +38 -72
- package/build/src/library/refusal.d.ts +20 -28
- package/build/src/library/refusal.js +1 -11
- package/build/src/library/repo.js +4 -3
- package/build/src/library/selection.d.ts +32 -21
- package/build/src/library/selection.js +63 -87
- package/build/src/mcp/adapter.d.ts +6 -0
- package/build/src/mcp/adapter.js +177 -42
- package/build/src/mcp/help.d.ts +1 -1
- package/build/src/mcp/help.js +12 -7
- package/build/src/mcp/output.d.ts +385 -0
- package/build/src/mcp/output.js +193 -0
- package/build/src/plugin/public.d.ts +4 -0
- package/build/src/plugin/runtime.d.ts +1 -1
- package/build/src/plugin/runtime.js +2 -2
- package/build/src/protocol/amend.d.ts +1 -1
- package/build/src/protocol/amend.js +2 -2
- package/build/src/protocol/bind.d.ts +5 -7
- package/build/src/protocol/bind.js +3 -3
- package/build/src/protocol/completion.d.ts +158 -195
- package/build/src/protocol/completion.js +55 -19
- package/build/src/protocol/deliver.d.ts +11 -6
- package/build/src/protocol/deliver.js +30 -30
- package/build/src/protocol/delivery-preview.d.ts +13 -11
- package/build/src/protocol/delivery-preview.js +2 -2
- package/build/src/protocol/execution-observation.d.ts +5 -13
- package/build/src/protocol/intent.d.ts +6 -9
- package/build/src/protocol/intent.js +18 -31
- package/build/src/protocol/operations.d.ts +48 -53
- package/build/src/protocol/operations.js +16 -25
- package/build/src/protocol/outcome.d.ts +3 -1
- package/build/src/protocol/placement.d.ts +1 -2
- package/build/src/protocol/placement.js +1 -1
- package/build/src/protocol/progress.d.ts +1 -0
- package/build/src/protocol/read/status.d.ts +29 -112
- package/build/src/protocol/read/status.js +52 -78
- package/build/src/protocol/reintegrate.d.ts +1 -2
- package/build/src/protocol/reintegrate.js +0 -1
- package/build/src/protocol/result-leaves.d.ts +11 -32
- package/build/src/protocol/result-leaves.js +18 -57
- package/build/src/protocol/result-reasons.d.ts +6 -6
- package/build/src/protocol/review.js +0 -1
- package/build/src/protocol/verify.d.ts +192 -146
- package/build/src/protocol/verify.js +60 -47
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/build/src/settings.d.ts +8 -9
- package/build/src/settings.js +16 -13
- package/build/src/settlement/holder.js +2 -2
- package/build/src/settlement/settle.d.ts +0 -6
- package/build/src/settlement/settle.js +0 -4
- package/build/src/verification/declaration.d.ts +3 -6
- package/build/src/verification/declaration.js +3 -5
- package/build/src/verification/observation.d.ts +2 -2
- package/build/src/world.d.ts +3 -2
- package/build/src/world.js +5 -6
- package/package.json +1 -1
- package/plugins/paseo/plugin/index.server.ts +1 -1
- package/plugins/paseo/plugin/server/attach.ts +74 -67
- package/plugins/paseo/plugin/server/keiyaku.ts +80 -14
- package/plugins/paseo/plugin/server/message.ts +2 -1
- package/plugins/paseo/plugin/server/mirror-identity.ts +6 -4
- package/plugins/paseo/plugin/server/sdk.ts +9 -11
- package/plugins/paseo/plugin/server/transport.ts +24 -1
- package/plugins/pi/README.md +16 -18
- package/plugins/pi/akuma-tools.ts +31 -38
- package/plugins/pi/keiyaku.ts +15 -4
- package/skills/keiyaku-akuma/SKILL.md +16 -11
- package/skills/keiyaku-babysit/SKILL.md +5 -3
- package/skills/keiyaku-bind/SKILL.md +4 -3
- package/skills/keiyaku-debt/SKILL.md +17 -17
- package/skills/keiyaku-workflow/SKILL.md +4 -3
- package/build/src/akuma/providers/codex-app-server/configuration.d.ts +0 -5
- package/build/src/akuma/providers/codex-app-server/configuration.js +0 -72
- package/build/src/cli/commands/debt-query.d.ts +0 -5
- package/build/src/cli/commands/debt-query.js +0 -194
- package/build/src/cli/render/akuma-tool-command.d.ts +0 -6
- package/build/src/cli/render/akuma-tool-command.js +0 -143
- package/build/src/cli/render/akuma-tool.d.ts +0 -29
- package/build/src/cli/render/akuma-tool.js +0 -225
- package/build/src/debt/context.d.ts +0 -28
- package/build/src/debt/context.js +0 -102
- package/build/src/debt/created-observation.d.ts +0 -26
- package/build/src/debt/created-observation.js +0 -38
- package/build/src/debt/query.d.ts +0 -80
- package/build/src/debt/query.js +0 -283
- package/build/src/library/contract-execution.d.ts +0 -28
- package/build/src/library/contract-execution.js +0 -506
- package/build/src/library/keiyaku-policy.d.ts +0 -27
- package/build/src/library/keiyaku-policy.js +0 -44
- package/build/src/library/keiyaku-status.d.ts +0 -1487
- package/build/src/library/keiyaku-status.js +0 -92
|
@@ -6,9 +6,11 @@ export declare function rosterListRow(paths: AkumaPaths, expected: AkumaId): Pro
|
|
|
6
6
|
/** Optional semantic seam; the observer composition owns delivery and deduplication. */
|
|
7
7
|
export type OutcomeObserver = (akumaId: AkumaId, historyIds: readonly string[]) => Promise<void>;
|
|
8
8
|
export declare function observeOutcomeRows(id: AkumaId, rows: readonly ActivityRow[], observer?: OutcomeObserver): Promise<void>;
|
|
9
|
-
export declare function observeStatusOutcome(status:
|
|
9
|
+
export declare function observeStatusOutcome(status: LiveStatusObservation["status"], observer?: OutcomeObserver): Promise<void>;
|
|
10
10
|
type BudgetedStatusObservation = Readonly<{
|
|
11
|
-
status: AkumaStatus
|
|
11
|
+
status: Omit<AkumaStatus, "work"> & Readonly<{
|
|
12
|
+
timeline: ActivitySnapshot;
|
|
13
|
+
}>;
|
|
12
14
|
ordinarySelected: number;
|
|
13
15
|
}>;
|
|
14
16
|
/**
|
|
@@ -59,7 +61,7 @@ export declare function readLiveStatus(worldPath: WorldRoot, id: AkumaId, input:
|
|
|
59
61
|
export type ExecutionProgress = "settled" | "advancing" | "stopped";
|
|
60
62
|
/** Pending input is not execution. An owned launch can bridge the admission gap. */
|
|
61
63
|
export declare function executionProgress(life: AkumaStatus["life"], pending: boolean, wake?: "launching" | "settled" | "failed"): ExecutionProgress;
|
|
62
|
-
export declare function defaultWaitComplete(status:
|
|
64
|
+
export declare function defaultWaitComplete(status: LiveStatusObservation["status"]): boolean;
|
|
63
65
|
/** Probe completion only; returned statuses still come from a full observation. */
|
|
64
66
|
export declare function readWaitComplete(worldPath: WorldRoot, ids: readonly AkumaId[], completion: "any" | "all", signal?: AbortSignal, probe?: (id: AkumaId) => Promise<boolean>): Promise<boolean>;
|
|
65
67
|
export type WaitReason = "completed" | "deadline";
|
|
@@ -82,5 +84,4 @@ export declare function waitForObservation<T>(input: Readonly<{
|
|
|
82
84
|
reason: WaitReason;
|
|
83
85
|
value: T;
|
|
84
86
|
}>>;
|
|
85
|
-
export declare function readAkumaBirthCwd(worldPath: WorldRoot, id: AkumaId): Promise<string>;
|
|
86
87
|
export { selectHistory, type ActivityHistory, type ActivitySnapshot };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { realpath } from "node:fs/promises";
|
|
2
2
|
import { projectAkumaBirth } from "./caller.js";
|
|
3
|
-
import { createStatusFactReader, readLifeSnapshot, HeldAkumaLeash, heartExists, isHeartAbsent, life, lifeAt, probeLeash, readHeart, readSeal,
|
|
3
|
+
import { createStatusFactReader, readLifeSnapshot, HeldAkumaLeash, heartExists, isHeartAbsent, life, lifeAt, probeLeash, readHeart, readSeal, } from "./heart/index.js";
|
|
4
4
|
import { pathsForAkumaId } from "./identity.js";
|
|
5
5
|
import { DEFAULT_TAIL, projectTurns, selectHistory, selectSnapshot, } from "./projection.js";
|
|
6
6
|
import { resolveProviderExecution } from "./providers/index.js";
|
|
@@ -240,10 +240,4 @@ export async function waitForObservation(input) {
|
|
|
240
240
|
: Math.min(input.pollMs ?? OBSERVATION_POLL_MS, Math.max(0, deadline - performance.now())), input.signal);
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
|
-
export async function readAkumaBirthCwd(worldPath, id) {
|
|
244
|
-
const soul = await readSoul(pathsForAkumaId(worldPath, id));
|
|
245
|
-
if (soul === null)
|
|
246
|
-
throw new AkumaNotBornError(id);
|
|
247
|
-
return soul.cwd;
|
|
248
|
-
}
|
|
249
243
|
export { selectHistory };
|
|
@@ -2,7 +2,6 @@ import { type AkumaCaller } from "./caller.js";
|
|
|
2
2
|
import type { WorldRoot } from "../world.js";
|
|
3
3
|
import { type OutcomeObserver, type LiveStatusObservation, type WaitReason } from "./akuma-observe.js";
|
|
4
4
|
import { type AkumaStreamSnapshot } from "./akuma-stream.js";
|
|
5
|
-
import type { AkumaStatus } from "./akuma.js";
|
|
6
5
|
import type { BodyLauncher } from "./body-launch.js";
|
|
7
6
|
import { type TellResult, type TellWakeRuntime } from "./body.js";
|
|
8
7
|
import { type CallInitialTell, type CallInitialTellAdmission } from "./call-initial-tell.js";
|
|
@@ -12,6 +11,15 @@ import type { ReportAdmission } from "./heart/facts.js";
|
|
|
12
11
|
import type { ActivityHistory, ExactHistory } from "./projection.js";
|
|
13
12
|
import { z } from "zod";
|
|
14
13
|
import { type PublicSessionCoordinate } from "./coordinate.js";
|
|
14
|
+
export declare const historyInputSchemas: readonly [z.ZodObject<{
|
|
15
|
+
id: z.ZodString;
|
|
16
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
17
|
+
before: z.ZodExactOptional<z.ZodNumber>;
|
|
18
|
+
limit: z.ZodExactOptional<z.ZodNumber>;
|
|
19
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
20
|
+
since: z.ZodNumber;
|
|
21
|
+
limit: z.ZodExactOptional<z.ZodNumber>;
|
|
22
|
+
}, z.core.$strict>];
|
|
15
23
|
export type InterruptReceipt = TellResult | Extract<InterruptTellAdmission, {
|
|
16
24
|
kind: "unavailable";
|
|
17
25
|
}>;
|
|
@@ -97,7 +105,7 @@ export declare class AkumaOwner {
|
|
|
97
105
|
text: string;
|
|
98
106
|
at: string;
|
|
99
107
|
}>, signal?: AbortSignal): Promise<ReportAdmission>;
|
|
100
|
-
status(): Promise<
|
|
108
|
+
status(): Promise<LiveStatusObservation["status"]>;
|
|
101
109
|
history(input?: Readonly<{
|
|
102
110
|
id?: string;
|
|
103
111
|
before?: number;
|
|
@@ -112,17 +120,17 @@ export declare class AkumaOwner {
|
|
|
112
120
|
stream(options?: Readonly<{
|
|
113
121
|
signal?: AbortSignal;
|
|
114
122
|
}>): AsyncIterable<AkumaStreamSnapshot>;
|
|
115
|
-
waitReceipt(predicate?: (status:
|
|
123
|
+
waitReceipt(predicate?: (status: LiveStatusObservation["status"]) => boolean, options?: Readonly<{
|
|
116
124
|
timeoutMs?: number;
|
|
117
125
|
signal?: AbortSignal;
|
|
118
126
|
}>): Promise<Readonly<{
|
|
119
127
|
reason: WaitReason;
|
|
120
|
-
status:
|
|
128
|
+
status: LiveStatusObservation["status"];
|
|
121
129
|
}>>;
|
|
122
|
-
wait(predicate?: (status:
|
|
130
|
+
wait(predicate?: (status: LiveStatusObservation["status"]) => boolean, options?: Readonly<{
|
|
123
131
|
timeoutMs?: number;
|
|
124
132
|
signal?: AbortSignal;
|
|
125
|
-
}>): Promise<
|
|
133
|
+
}>): Promise<LiveStatusObservation["status"]>;
|
|
126
134
|
admitInitialTell(initialTell: CallInitialTell, options: Readonly<{
|
|
127
135
|
signal?: AbortSignal;
|
|
128
136
|
runtime: TellWakeRuntime;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { KeiyakuError } from "../errors.js";
|
|
2
|
+
import { bareOption, durationSchema, validateAkumaInput } from "./call-input.js";
|
|
2
3
|
import { decodeAkumaCaller } from "./caller.js";
|
|
3
4
|
import { randomUUID } from "node:crypto";
|
|
4
5
|
import { AkumaNotBornError, AkumaProviderError } from "./akuma-errors.js";
|
|
@@ -15,6 +16,21 @@ import { resolveProviderExecution } from "./providers/index.js";
|
|
|
15
16
|
import { publishAkuma } from "./publication.js";
|
|
16
17
|
import { z } from "zod";
|
|
17
18
|
import { publicSessionCoordinate, publicSessionCoordinateSchema } from "./coordinate.js";
|
|
19
|
+
const historySequence = z.number().int().positive();
|
|
20
|
+
const historyLimit = historySequence.max(5_000).exactOptional();
|
|
21
|
+
export const historyInputSchemas = [
|
|
22
|
+
z.strictObject({
|
|
23
|
+
id: z
|
|
24
|
+
.string()
|
|
25
|
+
.regex(/^(?:(?:turn|report)\/)?[1-9][0-9]*$/u)
|
|
26
|
+
.refine((id) => parseExactHistorySelector(id) !== null, {
|
|
27
|
+
message: "id must be a positive safe decimal integer, turn/<positive safe integer> or report/<positive safe integer>",
|
|
28
|
+
}),
|
|
29
|
+
}),
|
|
30
|
+
z.strictObject({ before: historySequence.exactOptional(), limit: historyLimit }),
|
|
31
|
+
z.strictObject({ since: historySequence, limit: historyLimit }),
|
|
32
|
+
];
|
|
33
|
+
const historyInputSchema = z.union(historyInputSchemas);
|
|
18
34
|
export const forkFailureSchemas = {
|
|
19
35
|
unsupported: z.strictObject({ kind: z.literal("provider-cannot-fork") }).readonly(),
|
|
20
36
|
unknownHistory: z.strictObject({ kind: z.literal("unknown-history") }).readonly(),
|
|
@@ -140,15 +156,20 @@ export class AkumaOwner {
|
|
|
140
156
|
const slice = await activitySlice(this.paths);
|
|
141
157
|
return projectTurns(slice.rows, { lowestRetained: slice.lowestRetained, highest: slice.highest });
|
|
142
158
|
}
|
|
143
|
-
async exactHistory(
|
|
144
|
-
|
|
145
|
-
throw new TypeError("Akuma history id must be a nonblank string");
|
|
146
|
-
if (input.before !== undefined || input.since !== undefined || input.limit !== undefined)
|
|
147
|
-
throw new TypeError("Akuma history id cannot be combined with before, since, or limit");
|
|
148
|
-
const selector = parseExactHistorySelector(input.id);
|
|
159
|
+
async exactHistory(id) {
|
|
160
|
+
const selector = parseExactHistorySelector(id);
|
|
149
161
|
if (selector === null)
|
|
150
|
-
throw new
|
|
151
|
-
|
|
162
|
+
throw new KeiyakuError("invalid-input", "Akuma history id must be a positive safe decimal integer, turn/<positive safe integer> or report/<positive safe integer>");
|
|
163
|
+
const slice = await activitySlice(this.paths);
|
|
164
|
+
const ledger = projectTurns(slice.rows, { lowestRetained: slice.lowestRetained, highest: slice.highest });
|
|
165
|
+
if (selector.kind !== "activity")
|
|
166
|
+
return selectExactHistory(ledger.rows, { kind: selector.kind, sequence: selector.sequence });
|
|
167
|
+
const fact = slice.rows.find((row) => row.sequence === selector.sequence);
|
|
168
|
+
const row = ledger.rows.find((row) => row.sequence === selector.sequence) ??
|
|
169
|
+
(fact === undefined ? undefined : projectTurns([fact]).rows.find((row) => row.sequence === selector.sequence));
|
|
170
|
+
return row === undefined || row.kind === "turn" || row.kind === "outcome"
|
|
171
|
+
? { kind: "unknown-history", id }
|
|
172
|
+
: { kind: "exact-activity", row };
|
|
152
173
|
}
|
|
153
174
|
async report(input, signal) {
|
|
154
175
|
return await recordReport(this.paths, input, signal);
|
|
@@ -159,27 +180,14 @@ export class AkumaOwner {
|
|
|
159
180
|
return status;
|
|
160
181
|
}
|
|
161
182
|
async history(input = {}) {
|
|
183
|
+
validateAkumaInput(historyInputSchema, input);
|
|
162
184
|
if (input.id !== undefined) {
|
|
163
|
-
const exact = await this.exactHistory(input);
|
|
185
|
+
const exact = await this.exactHistory(input.id);
|
|
164
186
|
if (exact.kind === "exact")
|
|
165
187
|
await this.outcomeObserved?.(this.id, [`turn/${exact.outcome.turnSequence}`]);
|
|
166
188
|
return exact;
|
|
167
189
|
}
|
|
168
|
-
if (input.before !== undefined && input.since !== undefined) {
|
|
169
|
-
throw new TypeError("Akuma history before and since are mutually exclusive");
|
|
170
|
-
}
|
|
171
|
-
for (const [name, value] of [
|
|
172
|
-
["before", input.before],
|
|
173
|
-
["since", input.since],
|
|
174
|
-
]) {
|
|
175
|
-
if (value !== undefined && (!Number.isSafeInteger(value) || value <= 0)) {
|
|
176
|
-
throw new TypeError(`Akuma history ${name} must be a positive safe integer`);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
190
|
const limit = input.limit ?? 12;
|
|
180
|
-
if (!Number.isSafeInteger(limit) || limit <= 0 || limit > 5_000) {
|
|
181
|
-
throw new TypeError("Akuma history limit must be a positive safe integer no greater than 5000");
|
|
182
|
-
}
|
|
183
191
|
const history = selectHistory(await this.projectHistoryTurns(), {
|
|
184
192
|
...(input.before === undefined ? {} : { before: input.before }),
|
|
185
193
|
...(input.since === undefined ? {} : { since: input.since }),
|
|
@@ -197,9 +205,7 @@ export class AkumaOwner {
|
|
|
197
205
|
return createAkumaStream(this.paths, this.id, options, this.outcomeObserved);
|
|
198
206
|
}
|
|
199
207
|
async waitReceipt(predicate = defaultWaitComplete, options = {}) {
|
|
200
|
-
|
|
201
|
-
throw new TypeError("Akuma wait timeoutMs must be a nonnegative finite millisecond duration");
|
|
202
|
-
}
|
|
208
|
+
validateAkumaInput(durationSchema.optional(), options.timeoutMs);
|
|
203
209
|
const waited = await executeWaitAkuma({
|
|
204
210
|
path: this.worldPath,
|
|
205
211
|
ids: [this.id],
|
|
@@ -4,8 +4,7 @@ import type { LiveStatusObservation, OutcomeObserver } from "./akuma-observe.js"
|
|
|
4
4
|
import type { AkumaStatus } from "./akuma.js";
|
|
5
5
|
import { type TellResult } from "./body.js";
|
|
6
6
|
import type { BodyLauncher } from "./body-launch.js";
|
|
7
|
-
import type
|
|
8
|
-
import { type AkumaAskObservation, type AkumaAskResult, type AkumaKillResult, type AkumaTellResult } from "./selection-observation.js";
|
|
7
|
+
import { type AkumaAskResult, type AkumaKillResult, type AkumaTellResult } from "./selection-observation.js";
|
|
9
8
|
export declare const liveStatusObservationSchema: z.ZodReadonly<z.ZodObject<{
|
|
10
9
|
status: z.ZodReadonly<z.ZodObject<{
|
|
11
10
|
id: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identity.js").AkumaId, string>>;
|
|
@@ -29,18 +28,19 @@ export declare const liveStatusObservationSchema: z.ZodReadonly<z.ZodObject<{
|
|
|
29
28
|
kind: z.ZodLiteral<"unknown">;
|
|
30
29
|
}, z.core.$strict>>]>;
|
|
31
30
|
}, z.core.$strict>>;
|
|
31
|
+
cwd: z.ZodExactOptional<z.ZodString>;
|
|
32
|
+
model: z.ZodExactOptional<z.ZodString>;
|
|
33
|
+
provider: z.ZodExactOptional<z.ZodString>;
|
|
34
|
+
lastActivityAt: z.ZodExactOptional<z.ZodString>;
|
|
32
35
|
life: z.ZodEnum<{
|
|
33
|
-
killed: "killed";
|
|
34
36
|
hung: "hung";
|
|
35
37
|
untidy: "untidy";
|
|
38
|
+
killed: "killed";
|
|
36
39
|
running: "running";
|
|
37
40
|
asleep: "asleep";
|
|
38
41
|
stranded: "stranded";
|
|
39
42
|
}>;
|
|
40
|
-
|
|
41
|
-
provider: z.ZodExactOptional<z.ZodString>;
|
|
42
|
-
model: z.ZodExactOptional<z.ZodString>;
|
|
43
|
-
lastActivityAt: z.ZodExactOptional<z.ZodString>;
|
|
43
|
+
strandedReason: z.ZodExactOptional<z.ZodLiteral<"resume-unsupported">>;
|
|
44
44
|
timeline: z.ZodUnion<readonly [z.ZodReadonly<z.ZodObject<{
|
|
45
45
|
reportedChanges: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
|
|
46
46
|
path: z.ZodString;
|
|
@@ -335,7 +335,6 @@ export declare const liveStatusObservationSchema: z.ZodReadonly<z.ZodObject<{
|
|
|
335
335
|
}, z.core.$strict>>]>;
|
|
336
336
|
}, z.core.$strict>>]>>>;
|
|
337
337
|
}, z.core.$strict>>]>;
|
|
338
|
-
strandedReason: z.ZodExactOptional<z.ZodLiteral<"resume-unsupported">>;
|
|
339
338
|
}, z.core.$strict>>;
|
|
340
339
|
ordinarySelected: z.ZodNumber;
|
|
341
340
|
rows: z.ZodReadonly<z.ZodArray<z.ZodUnion<readonly [z.ZodReadonly<z.ZodObject<{
|
|
@@ -482,8 +481,8 @@ export declare const askProgressSchema: z.ZodUnion<readonly [z.ZodReadonly<z.Zod
|
|
|
482
481
|
}, z.core.$strict>>;
|
|
483
482
|
row: z.ZodReadonly<z.ZodObject<{
|
|
484
483
|
at: z.ZodString;
|
|
485
|
-
sequence: z.ZodNumber;
|
|
486
484
|
text: z.ZodString;
|
|
485
|
+
sequence: z.ZodNumber;
|
|
487
486
|
}, z.core.$strict>>;
|
|
488
487
|
wake: z.ZodUnion<readonly [z.ZodReadonly<z.ZodObject<{
|
|
489
488
|
kind: z.ZodLiteral<"told">;
|
|
@@ -541,18 +540,19 @@ export declare const askProgressSchema: z.ZodUnion<readonly [z.ZodReadonly<z.Zod
|
|
|
541
540
|
kind: z.ZodLiteral<"unknown">;
|
|
542
541
|
}, z.core.$strict>>]>;
|
|
543
542
|
}, z.core.$strict>>;
|
|
543
|
+
cwd: z.ZodExactOptional<z.ZodString>;
|
|
544
|
+
model: z.ZodExactOptional<z.ZodString>;
|
|
545
|
+
provider: z.ZodExactOptional<z.ZodString>;
|
|
546
|
+
lastActivityAt: z.ZodExactOptional<z.ZodString>;
|
|
544
547
|
life: z.ZodEnum<{
|
|
545
|
-
killed: "killed";
|
|
546
548
|
hung: "hung";
|
|
547
549
|
untidy: "untidy";
|
|
550
|
+
killed: "killed";
|
|
548
551
|
running: "running";
|
|
549
552
|
asleep: "asleep";
|
|
550
553
|
stranded: "stranded";
|
|
551
554
|
}>;
|
|
552
|
-
|
|
553
|
-
provider: z.ZodExactOptional<z.ZodString>;
|
|
554
|
-
model: z.ZodExactOptional<z.ZodString>;
|
|
555
|
-
lastActivityAt: z.ZodExactOptional<z.ZodString>;
|
|
555
|
+
strandedReason: z.ZodExactOptional<z.ZodLiteral<"resume-unsupported">>;
|
|
556
556
|
timeline: z.ZodUnion<readonly [z.ZodReadonly<z.ZodObject<{
|
|
557
557
|
reportedChanges: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
|
|
558
558
|
path: z.ZodString;
|
|
@@ -847,7 +847,6 @@ export declare const askProgressSchema: z.ZodUnion<readonly [z.ZodReadonly<z.Zod
|
|
|
847
847
|
}, z.core.$strict>>]>;
|
|
848
848
|
}, z.core.$strict>>]>>>;
|
|
849
849
|
}, z.core.$strict>>]>;
|
|
850
|
-
strandedReason: z.ZodExactOptional<z.ZodLiteral<"resume-unsupported">>;
|
|
851
850
|
}, z.core.$strict>>;
|
|
852
851
|
ordinarySelected: z.ZodNumber;
|
|
853
852
|
rows: z.ZodReadonly<z.ZodArray<z.ZodUnion<readonly [z.ZodReadonly<z.ZodObject<{
|
|
@@ -1002,6 +1001,8 @@ type TellExecutionInput = Readonly<{
|
|
|
1002
1001
|
initiator?: string;
|
|
1003
1002
|
signal?: AbortSignal;
|
|
1004
1003
|
interrupt?: boolean;
|
|
1004
|
+
wait?: boolean;
|
|
1005
|
+
timeoutMs?: number;
|
|
1005
1006
|
onObserve?: AskObserver;
|
|
1006
1007
|
outcomeObserved?: OutcomeObserver;
|
|
1007
1008
|
}>;
|
|
@@ -1010,8 +1011,6 @@ type AskExecutionInput = TellExecutionInput & Readonly<{
|
|
|
1010
1011
|
schemaJson?: string;
|
|
1011
1012
|
}>;
|
|
1012
1013
|
export declare function executeTellAkuma(input: TellExecutionInput): Promise<AkumaTellResult>;
|
|
1013
|
-
export declare function decodeAskObservation<T>(observation: AkumaAskResult, schema: Schema<T>): AkumaAskResult<T>;
|
|
1014
|
-
export declare function decodeAskObservation<T>(observation: AkumaAskObservation, schema: Schema<T>): AkumaAskObservation<T>;
|
|
1015
1014
|
export declare function observeAdmittedAskAkuma(input: Readonly<{
|
|
1016
1015
|
path: WorldRoot;
|
|
1017
1016
|
id: AkumaStatus["id"];
|
|
@@ -1029,8 +1028,12 @@ export declare function observeAdmittedAskAkuma(input: Readonly<{
|
|
|
1029
1028
|
receipt?: TellResult;
|
|
1030
1029
|
onObserve?: AskObserver;
|
|
1031
1030
|
outcomeObserved?: OutcomeObserver;
|
|
1032
|
-
}>): Promise<AkumaAskResult
|
|
1033
|
-
|
|
1031
|
+
}>): Promise<AkumaAskResult & {
|
|
1032
|
+
answer?: string;
|
|
1033
|
+
}>;
|
|
1034
|
+
export declare function executeAskAkuma(input: AskExecutionInput): Promise<AkumaAskResult & {
|
|
1035
|
+
answer?: string;
|
|
1036
|
+
}>;
|
|
1034
1037
|
type KillExecutionInput = Readonly<{
|
|
1035
1038
|
spawn: BodyLauncher;
|
|
1036
1039
|
path: WorldRoot;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { akumaStatusSchema } from "./akuma.js";
|
|
3
|
-
import { activityRowSchema } from "./projection.js";
|
|
4
|
-
import { tellResultSchema } from "./call-initial-tell.js";
|
|
3
|
+
import { activityRowSchema, activitySnapshotSchema } from "./projection.js";
|
|
4
|
+
import { tellResultSchema, pendingTellReceipt } from "./call-initial-tell.js";
|
|
5
5
|
import { akumaIdSchema } from "./identity.js";
|
|
6
|
-
import { AkumaNotBornError, AkumaProviderError } from "./akuma-errors.js";
|
|
6
|
+
import { AkumaNotBornError, AkumaProviderError, withTellFailureReceipt } from "./akuma-errors.js";
|
|
7
7
|
import { AkumaOwner } from "./akuma-owner.js";
|
|
8
8
|
import { tellWakeRuntime } from "./body.js";
|
|
9
|
-
import {
|
|
9
|
+
import { tellAdmissionEvidence, completeTell, } from "./selection-observation.js";
|
|
10
10
|
export const liveStatusObservationSchema = z
|
|
11
11
|
.strictObject({
|
|
12
|
-
status: akumaStatusSchema,
|
|
12
|
+
status: akumaStatusSchema.unwrap().omit({ work: true }).extend({ timeline: activitySnapshotSchema }).readonly(),
|
|
13
13
|
ordinarySelected: z.number(),
|
|
14
14
|
rows: z.array(activityRowSchema).readonly(),
|
|
15
15
|
})
|
|
@@ -19,32 +19,35 @@ export const askProgressSchema = z.union([
|
|
|
19
19
|
z.strictObject({ kind: z.literal("live"), observation: liveStatusObservationSchema }).readonly(),
|
|
20
20
|
]);
|
|
21
21
|
export async function executeTellAkuma(input) {
|
|
22
|
+
if (input.wait === true) {
|
|
23
|
+
const { akumaId, tellId, wake, interrupt, ...observation } = await executeAskAkuma(input);
|
|
24
|
+
return completeTell({ akumaId, tellId, ...(wake === undefined ? {} : { wake }), ...(interrupt === undefined ? {} : { interrupt }) }, observation.kind === "invalid-output" ? { kind: "failed", diagnostic: observation.diagnostic } : observation);
|
|
25
|
+
}
|
|
22
26
|
input.signal?.throwIfAborted();
|
|
23
27
|
const owner = new AkumaOwner(input.id, input.path);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
const admission = input.interrupt === true
|
|
29
|
+
? await owner.admitInterrupt(input.body, input)
|
|
30
|
+
: await owner.admitTell(input.body, input.tellId, input.recordedAt, tellWakeRuntime(input.spawn), input);
|
|
31
|
+
if (admission.kind === "not-born")
|
|
32
|
+
throw new AkumaNotBornError(input.id);
|
|
33
|
+
if (admission.kind === "unavailable")
|
|
34
|
+
throw new AkumaProviderError(`Tell interrupt unavailable: ${admission.evidence}`);
|
|
35
|
+
let tell = {
|
|
36
|
+
...pendingTellReceipt(admission.tell),
|
|
37
|
+
...("barrier" in admission && admission.barrier !== undefined
|
|
38
|
+
? { interruption: { kind: "pending", bodySequence: admission.barrier.bodySequence } }
|
|
39
|
+
: {}),
|
|
40
|
+
};
|
|
41
|
+
try {
|
|
42
|
+
tell = await ("wake" in admission
|
|
43
|
+
? admission.wake
|
|
44
|
+
: owner.completeInterruptAdmission(admission, tellWakeRuntime(input.spawn), input.signal));
|
|
45
|
+
input.signal?.throwIfAborted();
|
|
46
|
+
return completeTell(tellAdmissionEvidence(input.id, tell));
|
|
36
47
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
...(input.initiator === undefined ? {} : { initiator: input.initiator }),
|
|
40
|
-
...(input.signal === undefined ? {} : { signal: input.signal }),
|
|
41
|
-
});
|
|
48
|
+
catch (error) {
|
|
49
|
+
throw withTellFailureReceipt(error, completeTell(tellAdmissionEvidence(input.id, tell)), input.signal);
|
|
42
50
|
}
|
|
43
|
-
input.signal?.throwIfAborted();
|
|
44
|
-
const { interrupt, ...compact } = compactTellResult(input.id, tell);
|
|
45
|
-
if (interrupt?.kind === "pending")
|
|
46
|
-
throw new Error("Tell returned an unsettled interruption");
|
|
47
|
-
return { ...compact, ...(interrupt === undefined ? {} : { interrupt }) };
|
|
48
51
|
}
|
|
49
52
|
function askObservation(observed) {
|
|
50
53
|
if (observed.outcome === null)
|
|
@@ -61,37 +64,6 @@ function askObservation(observed) {
|
|
|
61
64
|
answer: observed.outcome.answer,
|
|
62
65
|
};
|
|
63
66
|
}
|
|
64
|
-
export function decodeAskObservation(observation, schema) {
|
|
65
|
-
if (observation.kind !== "answered")
|
|
66
|
-
return observation;
|
|
67
|
-
const { answer: _answer, answerUndefined: _undefined, ...receipt } = observation;
|
|
68
|
-
let value = observation.answer;
|
|
69
|
-
if (typeof value === "string") {
|
|
70
|
-
try {
|
|
71
|
-
value = JSON.parse(value);
|
|
72
|
-
}
|
|
73
|
-
catch (error) {
|
|
74
|
-
return {
|
|
75
|
-
...receipt,
|
|
76
|
-
kind: "invalid-output",
|
|
77
|
-
diagnostic: error instanceof Error ? error.message : "Answer is not valid JSON",
|
|
78
|
-
answer: typeof observation.answer === "string" ? observation.answer : String(observation.answer),
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
try {
|
|
83
|
-
const answer = schema.decode(value);
|
|
84
|
-
return { ...receipt, kind: "answered", ...(answer === undefined ? { answerUndefined: true } : { answer }) };
|
|
85
|
-
}
|
|
86
|
-
catch (error) {
|
|
87
|
-
return {
|
|
88
|
-
...receipt,
|
|
89
|
-
kind: "invalid-output",
|
|
90
|
-
diagnostic: error instanceof Error ? error.message : "Answer failed schema decode",
|
|
91
|
-
answer: typeof observation.answer === "string" ? observation.answer : String(observation.answer),
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
67
|
export async function observeAdmittedAskAkuma(input) {
|
|
96
68
|
const owner = new AkumaOwner(input.id, input.path, input.outcomeObserved);
|
|
97
69
|
const tell = input.receipt ?? (await owner.admittedReceipt(input.tellId));
|
|
@@ -113,92 +85,67 @@ export async function observeAdmittedAskAkuma(input) {
|
|
|
113
85
|
? Math.max(0, observedAt - admittedAt)
|
|
114
86
|
: 0
|
|
115
87
|
: Math.max(0, performance.now() - input.startedAt);
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
88
|
+
let observed;
|
|
89
|
+
try {
|
|
90
|
+
observed = await owner.tellOutcome(input.tellId, {
|
|
91
|
+
wake: () => {
|
|
92
|
+
if (wakeError !== undefined)
|
|
93
|
+
throw wakeError.error;
|
|
94
|
+
return wakeState;
|
|
95
|
+
},
|
|
96
|
+
...(input.timeoutMs === undefined ? {} : { timeoutMs: Math.max(0, input.timeoutMs - elapsed) }),
|
|
97
|
+
...(input.signal === undefined ? {} : { signal: input.signal }),
|
|
98
|
+
...(input.onObserve?.observe === undefined ? {} : { observe: input.onObserve.observe }),
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
throw withTellFailureReceipt(error, completeTell(tellAdmissionEvidence(input.id, settled ?? tell)), input.signal);
|
|
103
|
+
}
|
|
104
|
+
const receipt = tellAdmissionEvidence(input.id, settled ?? tell);
|
|
127
105
|
const observation = askObservation(observed);
|
|
128
106
|
const { wake, ...subject } = receipt;
|
|
129
107
|
return observation.kind === "unanswered" || observation.kind === "deadline"
|
|
130
108
|
? { ...subject, ...(wake === undefined ? {} : { wake }), ...observation }
|
|
131
109
|
: { ...subject, ...(wake?.kind === "failed" ? { wake } : {}), ...observation };
|
|
132
110
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
...(input.tellId === undefined ? {} : { tellId: input.tellId }),
|
|
142
|
-
...(input.recordedAt === undefined ? {} : { recordedAt: input.recordedAt }),
|
|
143
|
-
...(input.schemaJson === undefined ? {} : { schemaJson: input.schemaJson }),
|
|
144
|
-
...(input.initiator === undefined ? {} : { initiator: input.initiator }),
|
|
145
|
-
...(input.signal === undefined ? {} : { signal: input.signal }),
|
|
146
|
-
});
|
|
111
|
+
export async function executeAskAkuma(input) {
|
|
112
|
+
input.signal?.throwIfAborted();
|
|
113
|
+
const owner = new AkumaOwner(input.id, input.path);
|
|
114
|
+
const admission = input.interrupt === true
|
|
115
|
+
? await owner.admitInterrupt(input.body, input)
|
|
116
|
+
: await owner.admitTell(input.body, input.tellId, input.recordedAt, tellWakeRuntime(input.spawn), input);
|
|
117
|
+
if (admission.kind === "not-born")
|
|
118
|
+
throw new AkumaNotBornError(input.id);
|
|
147
119
|
if (admission.kind === "unavailable")
|
|
148
120
|
throw new AkumaProviderError(`Tell interrupt unavailable: ${admission.evidence}`);
|
|
149
121
|
const observing = new AbortController();
|
|
150
122
|
const signal = input.signal === undefined ? observing.signal : AbortSignal.any([input.signal, observing.signal]);
|
|
151
|
-
const wake =
|
|
123
|
+
const wake = "wake" in admission
|
|
124
|
+
? admission.wake
|
|
125
|
+
: owner.completeInterruptAdmission(admission, tellWakeRuntime(input.spawn), signal);
|
|
126
|
+
const receipt = {
|
|
127
|
+
...pendingTellReceipt(admission.tell),
|
|
128
|
+
...("barrier" in admission && admission.barrier !== undefined
|
|
129
|
+
? { interruption: { kind: "pending", bodySequence: admission.barrier.bodySequence } }
|
|
130
|
+
: {}),
|
|
131
|
+
};
|
|
152
132
|
try {
|
|
153
|
-
const receipt = admission.barrier === undefined
|
|
154
|
-
? undefined
|
|
155
|
-
: {
|
|
156
|
-
...(await owner.admittedReceipt(admission.tell.id)),
|
|
157
|
-
interruption: { kind: "pending", bodySequence: admission.barrier.bodySequence },
|
|
158
|
-
};
|
|
159
133
|
return await observeAdmittedAskAkuma({
|
|
160
|
-
|
|
161
|
-
id: input.id,
|
|
134
|
+
...input,
|
|
162
135
|
tellId: admission.tell.id,
|
|
163
|
-
|
|
164
|
-
startedAt: performance.now(),
|
|
136
|
+
receipt,
|
|
165
137
|
wake,
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
...(input.onObserve === undefined ? {} : { onObserve: input.onObserve }),
|
|
169
|
-
...(input.outcomeObserved === undefined ? {} : { outcomeObserved: input.outcomeObserved }),
|
|
138
|
+
signal,
|
|
139
|
+
startedAt: performance.now(),
|
|
170
140
|
});
|
|
171
141
|
}
|
|
172
142
|
finally {
|
|
173
|
-
if (!
|
|
143
|
+
if (!("wake" in admission)) {
|
|
174
144
|
observing.abort(new Error("interrupt observation ended"));
|
|
175
|
-
|
|
145
|
+
await wake.catch(() => undefined);
|
|
146
|
+
}
|
|
176
147
|
}
|
|
177
148
|
}
|
|
178
|
-
export async function executeAskAkuma(input) {
|
|
179
|
-
input.signal?.throwIfAborted();
|
|
180
|
-
const owner = new AkumaOwner(input.id, input.path);
|
|
181
|
-
if (input.interrupt === true)
|
|
182
|
-
return await executeInterruptAskAkuma(input, owner);
|
|
183
|
-
const admission = await owner.admitTell(input.body, input.tellId, input.recordedAt, tellWakeRuntime(input.spawn), {
|
|
184
|
-
...(input.schemaJson === undefined ? {} : { schemaJson: input.schemaJson }),
|
|
185
|
-
...(input.initiator === undefined ? {} : { initiator: input.initiator }),
|
|
186
|
-
...(input.signal === undefined ? {} : { signal: input.signal }),
|
|
187
|
-
});
|
|
188
|
-
if (admission.kind === "not-born")
|
|
189
|
-
throw new AkumaNotBornError(input.id);
|
|
190
|
-
return await observeAdmittedAskAkuma({
|
|
191
|
-
path: input.path,
|
|
192
|
-
id: input.id,
|
|
193
|
-
tellId: admission.tell.id,
|
|
194
|
-
...(input.timeoutMs === undefined ? {} : { timeoutMs: input.timeoutMs }),
|
|
195
|
-
startedAt: performance.now(),
|
|
196
|
-
wake: admission.wake,
|
|
197
|
-
...(input.signal === undefined ? {} : { signal: input.signal }),
|
|
198
|
-
...(input.onObserve === undefined ? {} : { onObserve: input.onObserve }),
|
|
199
|
-
...(input.outcomeObserved === undefined ? {} : { outcomeObserved: input.outcomeObserved }),
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
149
|
export async function executeKillAkuma(input) {
|
|
203
150
|
input.signal?.throwIfAborted();
|
|
204
151
|
const owners = input.ids.map((id) => new AkumaOwner(id, input.path));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { WorldRoot } from "../world.js";
|
|
2
|
-
import { type WaitReason, type OutcomeObserver } from "./akuma-observe.js";
|
|
2
|
+
import { type LiveStatusObservation, type WaitReason, type OutcomeObserver } from "./akuma-observe.js";
|
|
3
3
|
import type { AkumaStatus } from "./akuma.js";
|
|
4
4
|
import type { AkumaWaitItem } from "./selection-observation.js";
|
|
5
5
|
type WaitExecutionInput = Readonly<{
|
|
@@ -9,13 +9,13 @@ type WaitExecutionInput = Readonly<{
|
|
|
9
9
|
timeoutMs?: number;
|
|
10
10
|
signal?: AbortSignal;
|
|
11
11
|
/** Internal custom completion judge over the full final observation where supplied. */
|
|
12
|
-
predicate?: (status:
|
|
12
|
+
predicate?: (status: LiveStatusObservation["status"]) => boolean;
|
|
13
13
|
outcomeObserved?: OutcomeObserver;
|
|
14
14
|
}>;
|
|
15
15
|
/** One wait's association-free native evidence; upper composition attaches cross-product context. */
|
|
16
16
|
export type NativeWaitResult = Readonly<{
|
|
17
17
|
reason: WaitReason;
|
|
18
|
-
observations: readonly
|
|
18
|
+
observations: readonly LiveStatusObservation["status"][];
|
|
19
19
|
results: readonly AkumaWaitItem[];
|
|
20
20
|
}>;
|
|
21
21
|
/** Compact final native evidence, retaining full statuses privately for owner composition. */
|