@astrosheep/keiyaku 4.6.7 → 4.6.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 +46 -16
- package/build/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/build/plugins/claude/skills/keiyaku/SKILL.md +5 -6
- package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +1 -1
- package/build/plugins/claude/skills/keiyaku-akuma/references/automation.md +8 -8
- package/build/plugins/claude/skills/keiyaku-babysit/SKILL.md +1 -1
- package/build/plugins/claude/skills/keiyaku-bind/SKILL.md +9 -9
- package/build/plugins/claude/skills/keiyaku-debt/SKILL.md +91 -0
- package/build/plugins/claude/skills/keiyaku-workflow/SKILL.md +2 -2
- package/build/plugins/codex/.codex-plugin/plugin.json +1 -1
- package/build/plugins/codex/skills/keiyaku/SKILL.md +5 -6
- package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +1 -1
- package/build/plugins/codex/skills/keiyaku-akuma/references/automation.md +8 -8
- package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +1 -1
- package/build/plugins/codex/skills/keiyaku-bind/SKILL.md +9 -9
- package/build/plugins/codex/skills/keiyaku-debt/SKILL.md +91 -0
- package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +2 -2
- package/build/plugins/opencode/index.js +1 -1
- package/build/plugins/opencode/skills/keiyaku/SKILL.md +5 -6
- package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +1 -1
- package/build/plugins/opencode/skills/keiyaku-akuma/references/automation.md +8 -8
- package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +1 -1
- package/build/plugins/opencode/skills/keiyaku-bind/SKILL.md +9 -9
- package/build/plugins/opencode/skills/keiyaku-debt/SKILL.md +91 -0
- package/build/plugins/opencode/skills/keiyaku-workflow/SKILL.md +2 -2
- package/build/plugins/pi/keiyaku.ts +0 -5
- package/build/skills/keiyaku/SKILL.md +5 -6
- package/build/skills/keiyaku-akuma/SKILL.md +1 -1
- package/build/skills/keiyaku-akuma/references/automation.md +8 -8
- package/build/skills/keiyaku-babysit/SKILL.md +1 -1
- package/build/skills/keiyaku-bind/SKILL.md +9 -9
- package/build/skills/keiyaku-debt/SKILL.md +91 -0
- package/build/skills/keiyaku-workflow/SKILL.md +2 -2
- package/build/src/akuma/akuma-call.d.ts +2 -0
- package/build/src/akuma/akuma-call.js +8 -2
- package/build/src/akuma/akuma-instance.d.ts +14 -1
- package/build/src/akuma/akuma-instance.js +37 -7
- package/build/src/akuma/akuma-observe.d.ts +33 -8
- package/build/src/akuma/akuma-observe.js +89 -63
- package/build/src/akuma/akuma-owner.d.ts +14 -2
- package/build/src/akuma/akuma-owner.js +49 -35
- package/build/src/akuma/akuma-selection-execution.js +9 -1
- package/build/src/akuma/akuma-stream.d.ts +22 -0
- package/build/src/akuma/akuma-stream.js +116 -0
- package/build/src/akuma/akuma-wait.d.ts +1 -40
- package/build/src/akuma/akuma-wait.js +23 -84
- package/build/src/akuma/akuma.d.ts +52 -16
- package/build/src/akuma/akuma.js +10 -10
- package/build/src/akuma/allowed.d.ts +7 -12
- package/build/src/akuma/allowed.js +13 -4
- package/build/src/akuma/archetype.d.ts +7 -15
- package/build/src/akuma/archetype.js +36 -35
- package/build/src/akuma/body-supervisor.d.ts +5 -5
- package/build/src/akuma/body-supervisor.js +22 -20
- package/build/src/akuma/body.d.ts +5 -3
- package/build/src/akuma/body.js +57 -8
- package/build/src/akuma/call-request.d.ts +30 -32
- package/build/src/akuma/call-request.js +10 -3
- package/build/src/akuma/caller.d.ts +39 -0
- package/build/src/akuma/caller.js +36 -0
- package/build/src/akuma/dispatch-association.d.ts +0 -1
- package/build/src/akuma/dispatch-association.js +0 -3
- package/build/src/akuma/heart/activity-schema.d.ts +12 -0
- package/build/src/akuma/heart/activity-schema.js +6 -0
- package/build/src/akuma/heart/facts.d.ts +16 -12
- package/build/src/akuma/heart/facts.js +8 -0
- package/build/src/akuma/heart/index.d.ts +61 -9
- package/build/src/akuma/heart/index.js +89 -24
- package/build/src/akuma/heart/rows.d.ts +3 -3
- package/build/src/akuma/heart/rows.js +5 -3
- package/build/src/akuma/heart/soul.d.ts +10 -1
- package/build/src/akuma/heart/soul.js +34 -24
- package/build/src/akuma/heart/storage.d.ts +20 -0
- package/build/src/akuma/heart/storage.js +62 -3
- package/build/src/akuma/heart/timeline.d.ts +7 -0
- package/build/src/akuma/heart/timeline.js +10 -0
- package/build/src/akuma/identity.d.ts +0 -1
- package/build/src/akuma/identity.js +2 -5
- package/build/src/akuma/index.d.ts +6 -2
- package/build/src/akuma/index.js +1 -0
- package/build/src/akuma/nuke.js +6 -28
- package/build/src/akuma/projection.d.ts +25 -11
- package/build/src/akuma/projection.js +24 -7
- package/build/src/akuma/provider-recipe.d.ts +18 -6
- package/build/src/akuma/provider-recipe.js +24 -1
- package/build/src/akuma/provider.d.ts +31 -10
- package/build/src/akuma/provider.js +105 -14
- package/build/src/akuma/providers/acp/events.js +29 -19
- package/build/src/akuma/providers/acp/index.js +2 -3
- package/build/src/akuma/providers/claude/events.js +110 -69
- package/build/src/akuma/providers/claude/index.d.ts +2 -2
- package/build/src/akuma/providers/claude/index.js +4 -8
- package/build/src/akuma/providers/codex-app-server/events.js +17 -2
- package/build/src/akuma/providers/codex-app-server/index.js +17 -11
- package/build/src/akuma/providers/decode.d.ts +33 -0
- package/build/src/akuma/providers/decode.js +65 -0
- package/build/src/akuma/providers/execution-environment.d.ts +2 -1
- package/build/src/akuma/providers/execution-environment.js +3 -0
- package/build/src/akuma/providers/grok-build/index.js +16 -48
- package/build/src/akuma/providers/index.js +2 -0
- package/build/src/akuma/providers/lifecycle.d.ts +9 -0
- package/build/src/akuma/providers/lifecycle.js +10 -0
- package/build/src/akuma/providers/opencode-sdk/event-stream.d.ts +3 -3
- package/build/src/akuma/providers/opencode-sdk/event-stream.js +2 -25
- package/build/src/akuma/providers/opencode-sdk/events.d.ts +7 -43
- package/build/src/akuma/providers/opencode-sdk/events.js +146 -296
- package/build/src/akuma/providers/opencode-sdk/index.js +270 -431
- package/build/src/akuma/providers/opencode-sdk/native-http.d.ts +9 -0
- package/build/src/akuma/providers/opencode-sdk/native-http.js +69 -0
- package/build/src/akuma/providers/opencode-sdk/session.d.ts +42 -36
- package/build/src/akuma/providers/opencode-sdk/session.js +75 -84
- package/build/src/akuma/providers/paseo/events.d.ts +33 -0
- package/build/src/akuma/providers/paseo/events.js +204 -0
- package/build/src/akuma/providers/paseo/index.d.ts +9 -0
- package/build/src/akuma/providers/paseo/index.js +357 -0
- package/build/src/akuma/providers/pi/events.d.ts +2 -0
- package/build/src/akuma/providers/pi/events.js +36 -38
- package/build/src/akuma/providers/pi/index.js +21 -35
- package/build/src/akuma/publication.d.ts +2 -0
- package/build/src/akuma/publication.js +5 -0
- package/build/src/akuma/request-lifecycle.d.ts +4 -2
- package/build/src/akuma/request-lifecycle.js +27 -12
- package/build/src/akuma/request-rendezvous.js +38 -55
- package/build/src/akuma/request-serve.d.ts +1 -1
- package/build/src/akuma/request-serve.js +77 -113
- package/build/src/akuma/requests.d.ts +3 -1
- package/build/src/akuma/requests.js +32 -0
- package/build/src/akuma/selection-observation.d.ts +129 -53
- package/build/src/akuma/selection-observation.js +3 -9
- package/build/src/akuma/turn-drive.d.ts +3 -0
- package/build/src/akuma/turn-drive.js +28 -10
- package/build/src/akuma-body.js +12 -22
- package/build/src/cli/akuma-caller.d.ts +3 -0
- package/build/src/cli/akuma-caller.js +31 -0
- package/build/src/cli/commands/akuma-grammar.js +10 -16
- package/build/src/cli/commands/akuma.js +25 -55
- package/build/src/cli/commands/contract-grammar.d.ts +9 -7
- package/build/src/cli/commands/contract-grammar.js +40 -47
- package/build/src/cli/commands/contract-help.d.ts +17 -7
- package/build/src/cli/commands/contract-help.js +50 -11
- package/build/src/cli/commands/contract.js +34 -63
- package/build/src/cli/commands/debt-grammar.d.ts +19 -0
- package/build/src/cli/commands/debt-grammar.js +323 -0
- package/build/src/cli/commands/debt-query.d.ts +5 -0
- package/build/src/cli/commands/{task-query.js → debt-query.js} +9 -9
- package/build/src/cli/commands/{task.d.ts → debt.d.ts} +2 -2
- package/build/src/cli/commands/{task.js → debt.js} +87 -164
- package/build/src/cli/coordinates.d.ts +1 -1
- package/build/src/cli/coordinates.js +1 -1
- package/build/src/cli/parse.d.ts +5 -5
- package/build/src/cli/parse.js +17 -16
- package/build/src/cli/render/akuma-activity.d.ts +11 -83
- package/build/src/cli/render/akuma-activity.js +20 -382
- package/build/src/cli/render/catalog.d.ts +4 -7
- package/build/src/cli/render/catalog.js +5 -5
- package/build/src/cli/render/contract-history.js +3 -6
- package/build/src/cli/render/contract.js +17 -52
- package/build/src/cli/render/debt.d.ts +28 -0
- package/build/src/cli/render/{task.js → debt.js} +55 -133
- package/build/src/cli/render/kanshi.js +28 -28
- package/build/src/cli/render/marks.d.ts +5 -5
- package/build/src/cli/render/marks.js +4 -10
- package/build/src/cli/render/nuke.js +1 -1
- package/build/src/cli/render/receipt.js +3 -10
- package/build/src/cli/runtime.d.ts +1 -1
- package/build/src/cli/runtime.js +14 -20
- package/build/src/cli/scan.d.ts +1 -1
- package/build/src/cli/selectors.d.ts +3 -6
- package/build/src/cli/selectors.js +22 -53
- package/build/src/cli/usage.d.ts +1 -1
- package/build/src/cli/usage.js +4 -4
- package/build/src/contract-worktree.js +3 -3
- package/build/src/debt/board.d.ts +160 -0
- package/build/src/{task → debt}/board.js +89 -89
- package/build/src/debt/catalog.d.ts +11 -0
- package/build/src/debt/catalog.js +59 -0
- package/build/src/{task → debt}/context.d.ts +1 -1
- package/build/src/{task → debt}/context.js +1 -1
- package/build/src/{task → debt}/created-observation.d.ts +6 -10
- package/build/src/{task → debt}/created-observation.js +7 -7
- package/build/src/debt/document.d.ts +37 -0
- package/build/src/{task → debt}/document.js +37 -37
- package/build/src/debt/identity.d.ts +21 -0
- package/build/src/{task → debt}/identity.js +35 -35
- package/build/src/debt/index.d.ts +111 -0
- package/build/src/debt/index.js +203 -0
- package/build/src/{task → debt}/input.d.ts +8 -8
- package/build/src/{task → debt}/input.js +21 -21
- package/build/src/debt/lifecycle-operations.d.ts +6 -0
- package/build/src/{task → debt}/lifecycle-operations.js +27 -31
- package/build/src/debt/mutation-result.d.ts +981 -0
- package/build/src/debt/mutation-result.js +109 -0
- package/build/src/debt/mutation.d.ts +424 -0
- package/build/src/debt/mutation.js +223 -0
- package/build/src/debt/operation-types.d.ts +71 -0
- package/build/src/debt/operations.d.ts +28 -0
- package/build/src/{task → debt}/operations.js +59 -60
- package/build/src/debt/query.d.ts +76 -0
- package/build/src/{task → debt}/query.js +55 -55
- package/build/src/{task → debt}/store.d.ts +13 -13
- package/build/src/{task → debt}/store.js +58 -49
- package/build/src/debt/view.d.ts +4 -0
- package/build/src/debt/view.js +7 -0
- package/build/src/dispatch/index.d.ts +3 -3
- package/build/src/dispatch/index.js +1 -2
- package/build/src/git/observe.d.ts +6 -2
- package/build/src/git/observe.js +6 -2
- package/build/src/identity/coordinates.d.ts +1 -1
- package/build/src/index.d.ts +17 -17
- package/build/src/index.js +11 -11
- package/build/src/kanshi/index.d.ts +2 -2
- package/build/src/kanshi/read.js +54 -39
- package/build/src/kanshi/report.d.ts +7 -7
- package/build/src/kanshi/select.js +4 -4
- package/build/src/library/address.js +2 -4
- package/build/src/library/akuma-creation.d.ts +5 -1
- package/build/src/library/akuma-creation.js +27 -47
- package/build/src/library/akumas.d.ts +7 -7
- package/build/src/library/akumas.js +13 -9
- package/build/src/library/bind.d.ts +17 -17
- package/build/src/library/bind.js +16 -12
- package/build/src/library/contract-address.d.ts +9 -0
- package/build/src/library/contract-address.js +71 -0
- package/build/src/library/contract-composition.d.ts +4 -7
- package/build/src/library/contract-composition.js +6 -18
- package/build/src/library/contract-creation.d.ts +3 -5
- package/build/src/library/contract-creation.js +24 -22
- package/build/src/library/contract-execution.js +21 -26
- package/build/src/library/contract-outcomes.d.ts +2 -14
- package/build/src/library/contract-outcomes.js +2 -13
- package/build/src/library/contract-types.d.ts +38 -4
- package/build/src/library/delivery.d.ts +0 -2
- package/build/src/library/delivery.js +2 -5
- package/build/src/library/input.d.ts +2 -2
- package/build/src/library/input.js +5 -5
- package/build/src/library/invocation.js +2 -2
- package/build/src/library/keiyaku.d.ts +0 -5
- package/build/src/library/keiyaku.js +6 -12
- package/build/src/library/nuke.js +3 -3
- package/build/src/library/outcome.d.ts +626 -625
- package/build/src/library/outcome.js +13 -3
- package/build/src/library/reconcile.js +8 -16
- package/build/src/library/refusal.d.ts +2 -2
- package/build/src/library/repo.d.ts +3 -2
- package/build/src/library/repo.js +10 -5
- package/build/src/library/selection.d.ts +5 -8
- package/build/src/library/selection.js +22 -73
- package/build/src/plugin/akuma-signals.d.ts +2 -0
- package/build/src/plugin/akuma-signals.js +4 -0
- package/build/src/plugin/public.d.ts +32 -2
- package/build/src/plugin/runtime.js +5 -3
- package/build/src/protocol/amend.js +3 -2
- package/build/src/protocol/attempt.js +3 -8
- package/build/src/protocol/bind.d.ts +2 -2
- package/build/src/protocol/bind.js +1 -1
- package/build/src/protocol/deliver.js +3 -3
- package/build/src/protocol/operations.d.ts +1 -3
- package/build/src/protocol/operations.js +0 -8
- package/build/src/protocol/outcome.d.ts +1 -2
- package/build/src/protocol/outcome.js +1 -13
- package/build/src/protocol/placement.js +3 -10
- package/build/src/protocol/read/status.js +31 -70
- package/build/src/protocol/reintegrate.js +3 -10
- package/build/src/protocol/review.js +3 -3
- package/build/src/protocol/run.d.ts +5 -1
- package/build/src/protocol/run.js +3 -3
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/build/src/settlement/fence.d.ts +3 -3
- package/build/src/settlement/fence.js +4 -4
- package/build/src/settlement/holder.d.ts +16 -16
- package/build/src/settlement/holder.js +69 -63
- package/build/src/settlement/settle.d.ts +5 -5
- package/build/src/settlement/settle.js +53 -53
- package/package.json +19 -9
- package/plugins/paseo/plugin/index.server.ts +17 -0
- package/plugins/paseo/plugin/paseo-plugin.json +4 -0
- package/plugins/paseo/plugin/server/attach.ts +52 -0
- package/plugins/paseo/plugin/server/keiyaku.ts +44 -0
- package/plugins/paseo/plugin/server/message.ts +60 -0
- package/plugins/paseo/plugin/server/mirror.ts +193 -0
- package/plugins/paseo/plugin/server/model.ts +14 -0
- package/plugins/paseo/plugin/server/provider.ts +276 -0
- package/plugins/paseo/plugin/server/sdk-worker.ts +237 -0
- package/plugins/paseo/plugin/server/sdk.ts +289 -0
- package/plugins/paseo/plugin/server/stop.ts +26 -0
- package/plugins/paseo/plugin/server/transport.ts +35 -0
- package/plugins/paseo/plugin/shared/attach-rpc.ts +10 -0
- package/plugins/paseo/plugin/shared/refresh-rpc.ts +6 -0
- package/plugins/paseo/plugin/tsconfig.json +6 -0
- package/plugins/pi/keiyaku.ts +57 -0
- package/skills/keiyaku/SKILL.md +43 -0
- package/skills/keiyaku-akuma/SKILL.md +130 -0
- package/skills/keiyaku-akuma/references/automation.md +269 -0
- package/skills/keiyaku-babysit/SKILL.md +65 -0
- package/skills/keiyaku-bind/SKILL.md +216 -0
- package/skills/keiyaku-bind/agents/openai.yaml +4 -0
- package/skills/keiyaku-debt/SKILL.md +91 -0
- package/skills/keiyaku-workflow/SKILL.md +129 -0
- package/build/plugins/claude/skills/keiyaku-task/SKILL.md +0 -104
- package/build/plugins/codex/skills/keiyaku-task/SKILL.md +0 -104
- package/build/plugins/opencode/skills/keiyaku-task/SKILL.md +0 -104
- package/build/skills/keiyaku-task/SKILL.md +0 -104
- package/build/src/cli/commands/amend.d.ts +0 -12
- package/build/src/cli/commands/amend.js +0 -10
- package/build/src/cli/commands/bind.d.ts +0 -11
- package/build/src/cli/commands/bind.js +0 -23
- package/build/src/cli/commands/task-grammar.d.ts +0 -19
- package/build/src/cli/commands/task-grammar.js +0 -384
- package/build/src/cli/commands/task-query.d.ts +0 -5
- package/build/src/cli/render/task.d.ts +0 -41
- package/build/src/dispatch/association.d.ts +0 -1
- package/build/src/dispatch/association.js +0 -1
- package/build/src/task/board.d.ts +0 -168
- package/build/src/task/catalog.d.ts +0 -11
- package/build/src/task/catalog.js +0 -59
- package/build/src/task/compose-language.d.ts +0 -57
- package/build/src/task/compose-language.js +0 -364
- package/build/src/task/compose-parser.d.ts +0 -32
- package/build/src/task/compose-parser.js +0 -180
- package/build/src/task/compose.d.ts +0 -16
- package/build/src/task/compose.js +0 -189
- package/build/src/task/document.d.ts +0 -39
- package/build/src/task/identity.d.ts +0 -21
- package/build/src/task/index.d.ts +0 -138
- package/build/src/task/index.js +0 -269
- package/build/src/task/lifecycle-operations.d.ts +0 -6
- package/build/src/task/mutation-result.d.ts +0 -1726
- package/build/src/task/mutation-result.js +0 -198
- package/build/src/task/mutation.d.ts +0 -590
- package/build/src/task/mutation.js +0 -262
- package/build/src/task/operation-types.d.ts +0 -71
- package/build/src/task/operations.d.ts +0 -28
- package/build/src/task/query.d.ts +0 -76
- package/build/src/task/view.d.ts +0 -4
- package/build/src/task/view.js +0 -7
- /package/build/src/{task → debt}/operation-types.js +0 -0
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import { decodeAkumaCaller } from "./caller.js";
|
|
1
2
|
import { randomUUID } from "node:crypto";
|
|
2
3
|
import { AkumaNotBornError, AkumaProviderError } from "./akuma-errors.js";
|
|
3
|
-
import {
|
|
4
|
+
import { createLiveStatusReader, bornStatus, defaultWaitComplete, executionProgress, observeOutcomeRows, observeStatusOutcome, waitForObservation, } from "./akuma-observe.js";
|
|
4
5
|
import { executeWaitAkuma } from "./akuma-wait.js";
|
|
6
|
+
import { createAkumaStream } from "./akuma-stream.js";
|
|
5
7
|
import { handoffPendingTells, spawnAkumaBody, wakeRecordedTell, } from "./body.js";
|
|
6
8
|
import { admitCallInitialTell } from "./call-initial-tell.js";
|
|
7
9
|
import { acquireLeash } from "./control.js";
|
|
8
|
-
import { HeldAkumaLeash, activitySlice, projectTell, readForkPoint, readHeart, readKill, readLastAnsweredTurn, readSoul, readTell,
|
|
10
|
+
import { HeldAkumaLeash, activitySlice, projectTell, readForkPoint, readHeart, readKill, readLastAnsweredTurn, readSoul, readTell, recordTell, requestPause, requestStop, } from "./heart/index.js";
|
|
9
11
|
import { parsePublicHistoryId, pathsForAkuId } from "./identity.js";
|
|
10
12
|
import { projectTurns, selectExactHistory, selectHistory } from "./projection.js";
|
|
11
13
|
import { resolveProviderExecution } from "./providers/index.js";
|
|
@@ -83,7 +85,7 @@ export async function killAkumaWithRecovery(paths, recover, signal) {
|
|
|
83
85
|
* The one lower native Akuma owner: standalone identity, plural selection and
|
|
84
86
|
* the request service all consume these same single-target algorithms. It reads
|
|
85
87
|
* only Heart, leash, provider and filesystem state; optional Alias, Dispatch,
|
|
86
|
-
*
|
|
88
|
+
* Debt and Contract associations are composed above this boundary.
|
|
87
89
|
*/
|
|
88
90
|
export class AkumaOwner {
|
|
89
91
|
id;
|
|
@@ -145,6 +147,14 @@ export class AkumaOwner {
|
|
|
145
147
|
await observeOutcomeRows(this.id, history.rows, this.outcomeObserved);
|
|
146
148
|
return history;
|
|
147
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Continuously observe that same retained timeline. Each emission is the whole
|
|
152
|
+
* latest bounded window through the existing history projection, and the
|
|
153
|
+
* operation observes until its caller stops pulling or aborts.
|
|
154
|
+
*/
|
|
155
|
+
stream(options = {}) {
|
|
156
|
+
return createAkumaStream(this.paths, this.id, options, this.outcomeObserved);
|
|
157
|
+
}
|
|
148
158
|
async waitReceipt(predicate = defaultWaitComplete, options = {}) {
|
|
149
159
|
if (options.timeoutMs !== undefined && (!Number.isFinite(options.timeoutMs) || options.timeoutMs < 0)) {
|
|
150
160
|
throw new TypeError("Akuma wait timeoutMs must be a nonnegative finite millisecond duration");
|
|
@@ -223,38 +233,39 @@ export class AkumaOwner {
|
|
|
223
233
|
}
|
|
224
234
|
/** Observe the exact admitted Tell's bound Turn without substituting Akuma-wide idleness. */
|
|
225
235
|
async tellOutcome(tellId, options = {}) {
|
|
226
|
-
const
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
236
|
+
const reader = createLiveStatusReader(this.paths, this.id);
|
|
237
|
+
try {
|
|
238
|
+
const waited = await waitForObservation({
|
|
239
|
+
...(options.timeoutMs === undefined ? {} : { timeoutMs: options.timeoutMs }),
|
|
240
|
+
...(options.signal === undefined ? {} : { signal: options.signal }),
|
|
241
|
+
observe: async () => {
|
|
242
|
+
const currentLife = await reader.execution(options.signal);
|
|
243
|
+
const progress = executionProgress(currentLife, true, options.wake?.());
|
|
244
|
+
const { tell, end } = await reader.tellOutcome(tellId, options.signal);
|
|
245
|
+
if (tell === null)
|
|
246
|
+
throw new AkumaProviderError(`recorded Tell ${tellId} is missing from Heart`);
|
|
247
|
+
if (end !== undefined)
|
|
248
|
+
await this.outcomeObserved?.(this.id, [`turn/${end.turnSequence}`]);
|
|
249
|
+
if (options.observe !== undefined) {
|
|
250
|
+
await options.observe(await reader.read({ aperture: "monitoring", admittedTellId: tellId }, options.signal));
|
|
251
|
+
}
|
|
252
|
+
return {
|
|
253
|
+
outcome: end?.outcome ?? null,
|
|
254
|
+
completedAt: end?.completedAt ?? null,
|
|
255
|
+
terminalWithoutTurn: (tell.state === "told" && tell.binding === undefined) || progress === "stopped",
|
|
256
|
+
};
|
|
257
|
+
},
|
|
258
|
+
complete: (observed) => observed.outcome !== null || observed.terminalWithoutTurn,
|
|
259
|
+
});
|
|
260
|
+
return {
|
|
261
|
+
reason: waited.reason,
|
|
262
|
+
outcome: waited.value.outcome,
|
|
263
|
+
completedAt: waited.value.completedAt,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
finally {
|
|
267
|
+
reader.clear();
|
|
268
|
+
}
|
|
258
269
|
}
|
|
259
270
|
async interrupt(body, options = {}) {
|
|
260
271
|
const admitted = await this.admitInterrupt(body, options);
|
|
@@ -319,6 +330,7 @@ export class AkumaOwner {
|
|
|
319
330
|
};
|
|
320
331
|
}
|
|
321
332
|
async fork(input) {
|
|
333
|
+
const caller = decodeAkumaCaller(input.caller);
|
|
322
334
|
const source = await readSoul(this.paths);
|
|
323
335
|
if (source === null)
|
|
324
336
|
throw new AkumaNotBornError(this.id);
|
|
@@ -366,8 +378,10 @@ export class AkumaOwner {
|
|
|
366
378
|
allowed: source.allowed,
|
|
367
379
|
cwd: source.cwd,
|
|
368
380
|
origin: { kind: "fork", parent: this.id, at: input.at },
|
|
381
|
+
...(caller === undefined ? {} : { caller }),
|
|
369
382
|
},
|
|
370
383
|
birthSession,
|
|
384
|
+
...(input.initiator === undefined ? {} : { birthInitiator: input.initiator }),
|
|
371
385
|
});
|
|
372
386
|
},
|
|
373
387
|
});
|
|
@@ -68,9 +68,12 @@ export async function observeAdmittedAskAkuma(input) {
|
|
|
68
68
|
const tell = input.receipt ?? (await owner.admittedReceipt(input.tellId));
|
|
69
69
|
await input.onObserve?.admitted?.(tell, input.id);
|
|
70
70
|
let settled;
|
|
71
|
+
let wakeError;
|
|
72
|
+
let wakeState = input.wake === undefined ? "settled" : "launching";
|
|
71
73
|
void input.wake?.then((receipt) => {
|
|
72
74
|
settled = receipt;
|
|
73
|
-
|
|
75
|
+
wakeState = receipt.wake.kind === "failed" ? "failed" : "settled";
|
|
76
|
+
}, (error) => { wakeError = { error }; wakeState = "failed"; });
|
|
74
77
|
const admittedAt = Date.parse(tell.row.at);
|
|
75
78
|
const observedAt = performance.timeOrigin + performance.now();
|
|
76
79
|
const elapsed = input.startedAt === undefined
|
|
@@ -79,6 +82,11 @@ export async function observeAdmittedAskAkuma(input) {
|
|
|
79
82
|
: 0
|
|
80
83
|
: Math.max(0, performance.now() - input.startedAt);
|
|
81
84
|
const observed = await owner.tellOutcome(input.tellId, {
|
|
85
|
+
wake: () => {
|
|
86
|
+
if (wakeError !== undefined)
|
|
87
|
+
throw wakeError.error;
|
|
88
|
+
return wakeState;
|
|
89
|
+
},
|
|
82
90
|
...(input.timeoutMs === undefined ? {} : { timeoutMs: Math.max(0, input.timeoutMs - elapsed) }),
|
|
83
91
|
...(input.signal === undefined ? {} : { signal: input.signal }),
|
|
84
92
|
...(input.onObserve?.observe === undefined ? {} : { observe: input.onObserve.observe }),
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type OutcomeObserver } from "./akuma-observe.js";
|
|
2
|
+
import type { AkuId, AkumaPaths } from "./identity.js";
|
|
3
|
+
import { type ActivityHistory } from "./projection.js";
|
|
4
|
+
/** The complete bounded latest timeline window one stream emission carries; never a delta. */
|
|
5
|
+
export type AkumaStreamSnapshot = ActivityHistory;
|
|
6
|
+
/**
|
|
7
|
+
* The one continuous timeline observation as its caller sees it: pull-driven,
|
|
8
|
+
* so a slow consumer accumulates no queue.
|
|
9
|
+
*
|
|
10
|
+
* The observation runs behind this wrapper because a bare async generator
|
|
11
|
+
* cannot honour an end request while a pull is pending: `return()` would queue
|
|
12
|
+
* behind a pull that an idle timeline never settles, and the observation would
|
|
13
|
+
* hold its reader and its polling timer forever. The wrapper owns an internal
|
|
14
|
+
* controller instead, and the observation watches the caller's cancellation
|
|
15
|
+
* composed with it. `return` aborts that controller, which settles the pending
|
|
16
|
+
* poll and lets the loop release its reader in the same turn; because a
|
|
17
|
+
* composed signal keeps the reason of whichever source aborted first, an end
|
|
18
|
+
* request reads as completion while a caller's own abort keeps its own failure.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createAkumaStream(paths: AkumaPaths, id: AkuId, options?: Readonly<{
|
|
21
|
+
signal?: AbortSignal;
|
|
22
|
+
}>, observe?: OutcomeObserver): AsyncIterableIterator<AkumaStreamSnapshot>;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from "node:util";
|
|
2
|
+
import { abortableDelay } from "./abort.js";
|
|
3
|
+
import { AkumaNotBornError } from "./akuma-errors.js";
|
|
4
|
+
import { OBSERVATION_POLL_MS } from "./akuma-observe.js";
|
|
5
|
+
import { createTimelineReader } from "./heart/index.js";
|
|
6
|
+
import { projectTurns, selectHistory } from "./projection.js";
|
|
7
|
+
/** The fixed number of projected rows one window retains. */
|
|
8
|
+
const STREAM_WINDOW = 500;
|
|
9
|
+
/**
|
|
10
|
+
* The private end-of-observation reason. It is deliberately not the caller's
|
|
11
|
+
* abort reason: a returned observation completes, while an aborted one keeps
|
|
12
|
+
* the caller's own failure.
|
|
13
|
+
*/
|
|
14
|
+
const STREAM_RETURN = Symbol("akuma-stream-return");
|
|
15
|
+
/**
|
|
16
|
+
* Announce each retained outcome identity once per observation, keeping only
|
|
17
|
+
* the identities the current window still carries, so a long stream remembers
|
|
18
|
+
* a bounded set rather than every outcome it ever saw.
|
|
19
|
+
*/
|
|
20
|
+
async function announceOutcomes(id, rows, observed, observe) {
|
|
21
|
+
const outcomes = new Set(rows.flatMap((row) => (row.kind === "outcome" ? [row.outcome.historyId] : [])));
|
|
22
|
+
const fresh = [...outcomes].filter((historyId) => !observed.has(historyId));
|
|
23
|
+
if (fresh.length > 0)
|
|
24
|
+
await observe?.(id, fresh);
|
|
25
|
+
return outcomes;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The observation loop itself. It decodes the retained timeline through the
|
|
29
|
+
* existing Turn projection on every pull and answers with the whole latest
|
|
30
|
+
* bounded window, holding only that window and one reader. Complete windows
|
|
31
|
+
* coalesce; they are not lossless event delivery, and the existing retention
|
|
32
|
+
* metadata keeps its honest meaning.
|
|
33
|
+
*/
|
|
34
|
+
async function* observeTimeline(paths, id, signal, observe) {
|
|
35
|
+
const reader = createTimelineReader(paths);
|
|
36
|
+
let released = false;
|
|
37
|
+
const release = () => {
|
|
38
|
+
if (released)
|
|
39
|
+
return;
|
|
40
|
+
released = true;
|
|
41
|
+
reader.clear();
|
|
42
|
+
};
|
|
43
|
+
let observedOutcomes = new Set();
|
|
44
|
+
let previous;
|
|
45
|
+
signal.addEventListener("abort", release, { once: true });
|
|
46
|
+
try {
|
|
47
|
+
for (;;) {
|
|
48
|
+
signal.throwIfAborted();
|
|
49
|
+
const read = await reader.read(signal);
|
|
50
|
+
signal.throwIfAborted();
|
|
51
|
+
if (read.changed) {
|
|
52
|
+
if (!read.born)
|
|
53
|
+
throw new AkumaNotBornError(id);
|
|
54
|
+
const { rows, lowestRetained, highest } = read.slice;
|
|
55
|
+
const snapshot = selectHistory(projectTurns(rows, { lowestRetained, highest }), { limit: STREAM_WINDOW });
|
|
56
|
+
if (previous === undefined || !isDeepStrictEqual(snapshot, previous)) {
|
|
57
|
+
observedOutcomes = await announceOutcomes(id, snapshot.rows, observedOutcomes, observe);
|
|
58
|
+
previous = snapshot;
|
|
59
|
+
yield snapshot;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
await abortableDelay(OBSERVATION_POLL_MS, signal);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
signal.removeEventListener("abort", release);
|
|
67
|
+
release();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The one continuous timeline observation as its caller sees it: pull-driven,
|
|
72
|
+
* so a slow consumer accumulates no queue.
|
|
73
|
+
*
|
|
74
|
+
* The observation runs behind this wrapper because a bare async generator
|
|
75
|
+
* cannot honour an end request while a pull is pending: `return()` would queue
|
|
76
|
+
* behind a pull that an idle timeline never settles, and the observation would
|
|
77
|
+
* hold its reader and its polling timer forever. The wrapper owns an internal
|
|
78
|
+
* controller instead, and the observation watches the caller's cancellation
|
|
79
|
+
* composed with it. `return` aborts that controller, which settles the pending
|
|
80
|
+
* poll and lets the loop release its reader in the same turn; because a
|
|
81
|
+
* composed signal keeps the reason of whichever source aborted first, an end
|
|
82
|
+
* request reads as completion while a caller's own abort keeps its own failure.
|
|
83
|
+
*/
|
|
84
|
+
export function createAkumaStream(paths, id, options = {}, observe) {
|
|
85
|
+
const caller = options.signal;
|
|
86
|
+
const control = new AbortController();
|
|
87
|
+
const signal = caller === undefined ? control.signal : AbortSignal.any([caller, control.signal]);
|
|
88
|
+
const observation = observeTimeline(paths, id, signal, observe);
|
|
89
|
+
let returning;
|
|
90
|
+
const next = async () => {
|
|
91
|
+
if (returning !== undefined)
|
|
92
|
+
return { done: true, value: undefined };
|
|
93
|
+
try {
|
|
94
|
+
return await observation.next();
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
// An end request is completion, not the caller's failure to see.
|
|
98
|
+
if (signal.reason === STREAM_RETURN)
|
|
99
|
+
return { done: true, value: undefined };
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const end = (value) => {
|
|
104
|
+
if (returning === undefined) {
|
|
105
|
+
control.abort(STREAM_RETURN);
|
|
106
|
+
returning = observation.return(value).then((result) => ({ done: true, value: result.value }));
|
|
107
|
+
}
|
|
108
|
+
return returning;
|
|
109
|
+
};
|
|
110
|
+
const iterator = {
|
|
111
|
+
[Symbol.asyncIterator]: () => iterator,
|
|
112
|
+
next,
|
|
113
|
+
return: end,
|
|
114
|
+
};
|
|
115
|
+
return iterator;
|
|
116
|
+
}
|
|
@@ -1,30 +1,7 @@
|
|
|
1
|
-
import type { AkumaAlias } from "../identity/selector.js";
|
|
2
1
|
import type { WorldRoot } from "../world.js";
|
|
3
2
|
import { type OutcomeObserver, type WaitReason } from "./akuma-observe.js";
|
|
4
3
|
import type { AkumaStatus } from "./akuma.js";
|
|
5
|
-
import type { DispatchAssociation } from "./dispatch-association.js";
|
|
6
|
-
import type { ActivityRow } from "./projection.js";
|
|
7
4
|
import type { AkumaUnobserved } from "./selection-observation.js";
|
|
8
|
-
export type WaitIdentityFacts = Readonly<{
|
|
9
|
-
/** The alias currently addressing this Akuma in its world, when one is bound to it. */
|
|
10
|
-
alias?: AkumaAlias;
|
|
11
|
-
/** This Akuma's Dispatch association, read from the observing repository. */
|
|
12
|
-
contract: DispatchAssociation;
|
|
13
|
-
}>;
|
|
14
|
-
/** One observed Akuma as a live wait viewer sees it: its status plus its identity facts. */
|
|
15
|
-
export type WaitObservedAkuma = Readonly<{
|
|
16
|
-
status: AkumaStatus;
|
|
17
|
-
rows: readonly ActivityRow[];
|
|
18
|
-
}> & WaitIdentityFacts;
|
|
19
|
-
/** One selected Akuma's frozen identity, resolved before the first observation round. */
|
|
20
|
-
export type WaitSelectedAkuma = Readonly<{
|
|
21
|
-
id: AkumaStatus["id"];
|
|
22
|
-
}> & WaitIdentityFacts;
|
|
23
|
-
/** A live wait viewer: the frozen selected set, then every observation round. */
|
|
24
|
-
export type WaitObserver = Readonly<{
|
|
25
|
-
selected?: (selected: readonly WaitSelectedAkuma[]) => void;
|
|
26
|
-
observe?: (observed: readonly WaitObservedAkuma[]) => void;
|
|
27
|
-
}>;
|
|
28
5
|
type WaitExecutionInput = Readonly<{
|
|
29
6
|
path: WorldRoot;
|
|
30
7
|
ids: readonly AkumaStatus["id"][];
|
|
@@ -34,14 +11,6 @@ type WaitExecutionInput = Readonly<{
|
|
|
34
11
|
/** Internal custom completion judge over the full final observation where supplied. */
|
|
35
12
|
predicate?: (status: AkumaStatus) => boolean;
|
|
36
13
|
outcomeObserved?: OutcomeObserver;
|
|
37
|
-
/** Resolves one Akuma's identity facts; consulted once per Akuma a viewer first sees. */
|
|
38
|
-
identity?: (id: AkumaStatus["id"]) => Promise<WaitIdentityFacts>;
|
|
39
|
-
/** The selected set in the caller's order; a viewer's head and scoreboard follow it. */
|
|
40
|
-
selectionOrder?: readonly AkumaStatus["id"][];
|
|
41
|
-
/** Reports the frozen selected set before the first round, so a viewer can fix its layout. */
|
|
42
|
-
onSelected?: (selected: readonly WaitSelectedAkuma[]) => void;
|
|
43
|
-
/** Reports every observation round to a live viewer. */
|
|
44
|
-
observe?: (observed: readonly WaitObservedAkuma[]) => void;
|
|
45
14
|
}>;
|
|
46
15
|
/** One wait's association-free native evidence; upper composition attaches cross-product context. */
|
|
47
16
|
export type NativeWaitResult = Readonly<{
|
|
@@ -50,14 +19,6 @@ export type NativeWaitResult = Readonly<{
|
|
|
50
19
|
observations: readonly AkumaStatus[];
|
|
51
20
|
unobserved: readonly AkumaUnobserved[];
|
|
52
21
|
}>;
|
|
53
|
-
/**
|
|
54
|
-
* The one lower set-observation owner for Akuma wait completion. It serves the
|
|
55
|
-
* standalone one-ID association-free face and the plural any/all face with one
|
|
56
|
-
* ordered round algorithm, one shared ordinary-detail budget, transient
|
|
57
|
-
* unreadable peers, and an honest final deadline edge. A silent observation —
|
|
58
|
-
* no live row callback and no custom judge — decides which running rounds to
|
|
59
|
-
* skip with the owner's lightweight completion probe over the selected set; a
|
|
60
|
-
* live viewer or a custom judge always observes full rounds.
|
|
61
|
-
*/
|
|
22
|
+
/** Wait observes completion and returns final status snapshots, never a live stream. */
|
|
62
23
|
export declare function executeWaitAkuma(input: WaitExecutionInput): Promise<NativeWaitResult>;
|
|
63
24
|
export {};
|
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
import { AkumaNotBornError } from "./akuma-errors.js";
|
|
2
|
-
import { createLiveStatusReader, defaultWaitComplete,
|
|
2
|
+
import { createLiveStatusReader, defaultWaitComplete, readWaitComplete, observeStatusOutcome, waitForObservation, } from "./akuma-observe.js";
|
|
3
3
|
import { pathsForAkuId } from "./identity.js";
|
|
4
4
|
const SHARED_ORDINARY_BUDGET = 30;
|
|
5
|
-
async function observeWaitRound(
|
|
6
|
-
const read =
|
|
7
|
-
const options = { aperture: "monitoring", ...(ordinaryBudget === undefined ? {} : { ordinaryBudget }) };
|
|
8
|
-
if (readers === undefined)
|
|
9
|
-
return await readLiveStatus(path, id, options, signal);
|
|
10
|
-
let reader = readers.get(id);
|
|
11
|
-
if (reader === undefined) {
|
|
12
|
-
reader = createLiveStatusReader(pathsForAkuId(path, id), id);
|
|
13
|
-
readers.set(id, reader);
|
|
14
|
-
}
|
|
15
|
-
return await reader.read(options, signal);
|
|
16
|
-
};
|
|
5
|
+
async function observeWaitRound(ids, readerFor, signal) {
|
|
6
|
+
const read = (id, ordinaryBudget) => readerFor(id).read({ aperture: "monitoring", ...(ordinaryBudget === undefined ? {} : { ordinaryBudget }) }, signal);
|
|
17
7
|
signal?.throwIfAborted();
|
|
18
8
|
if (ids.length <= 1) {
|
|
19
9
|
const observations = await Promise.all(ids.map(async (id) => await read(id)));
|
|
@@ -30,8 +20,6 @@ async function observeWaitRound(path, ids, signal, readers) {
|
|
|
30
20
|
remaining -= observed.ordinarySelected;
|
|
31
21
|
}
|
|
32
22
|
catch (error) {
|
|
33
|
-
readers?.get(id)?.clear();
|
|
34
|
-
readers?.delete(id);
|
|
35
23
|
if (error instanceof AkumaNotBornError)
|
|
36
24
|
throw error;
|
|
37
25
|
unobserved.push({ id, diagnostic: diagnostic(error) });
|
|
@@ -45,80 +33,32 @@ function roundComplete(round, completion, predicate) {
|
|
|
45
33
|
return (settled.length > 0 &&
|
|
46
34
|
(completion === "any" ? settled.some(Boolean) : round.unobserved.length === 0 && settled.every(Boolean)));
|
|
47
35
|
}
|
|
48
|
-
/**
|
|
49
|
-
function selectionOrderedIds(ids, order) {
|
|
50
|
-
const present = new Set(ids);
|
|
51
|
-
const seen = new Set();
|
|
52
|
-
const ordered = [];
|
|
53
|
-
for (const id of order) {
|
|
54
|
-
if (present.has(id) && !seen.has(id)) {
|
|
55
|
-
seen.add(id);
|
|
56
|
-
ordered.push(id);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
for (const id of ids) {
|
|
60
|
-
if (!seen.has(id)) {
|
|
61
|
-
seen.add(id);
|
|
62
|
-
ordered.push(id);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return ordered;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* The one lower set-observation owner for Akuma wait completion. It serves the
|
|
69
|
-
* standalone one-ID association-free face and the plural any/all face with one
|
|
70
|
-
* ordered round algorithm, one shared ordinary-detail budget, transient
|
|
71
|
-
* unreadable peers, and an honest final deadline edge. A silent observation —
|
|
72
|
-
* no live row callback and no custom judge — decides which running rounds to
|
|
73
|
-
* skip with the owner's lightweight completion probe over the selected set; a
|
|
74
|
-
* live viewer or a custom judge always observes full rounds.
|
|
75
|
-
*/
|
|
36
|
+
/** Wait observes completion and returns final status snapshots, never a live stream. */
|
|
76
37
|
export async function executeWaitAkuma(input) {
|
|
77
|
-
const readers =
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
input.signal?.throwIfAborted();
|
|
84
|
-
const known = input.identity === undefined ? undefined : await input.identity(id);
|
|
85
|
-
facts.set(id, known ?? { contract: { kind: "none" } });
|
|
86
|
-
}
|
|
87
|
-
const ordered = input.selectionOrder === undefined ? input.ids : selectionOrderedIds(input.ids, input.selectionOrder);
|
|
88
|
-
input.onSelected(ordered.map((id) => ({ id, ...facts.get(id) })));
|
|
38
|
+
const readers = new Map();
|
|
39
|
+
const readerFor = (id) => {
|
|
40
|
+
let reader = readers.get(id);
|
|
41
|
+
if (reader === undefined) {
|
|
42
|
+
reader = createLiveStatusReader(pathsForAkuId(input.path, id), id);
|
|
43
|
+
readers.set(id, reader);
|
|
89
44
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
: observeOutcomeRows(status.id, rows, input.outcomeObserved)));
|
|
94
|
-
if (input.observe === undefined)
|
|
95
|
-
return;
|
|
96
|
-
const observed = [];
|
|
97
|
-
for (const observation of round.observations) {
|
|
98
|
-
input.signal?.throwIfAborted();
|
|
99
|
-
const { status, rows } = observation;
|
|
100
|
-
let known = facts.get(status.id);
|
|
101
|
-
if (known === undefined && input.identity !== undefined) {
|
|
102
|
-
known = await input.identity(status.id);
|
|
103
|
-
facts.set(status.id, known);
|
|
104
|
-
}
|
|
105
|
-
if (known === undefined) {
|
|
106
|
-
observed.push({ status, rows, contract: { kind: "none" } });
|
|
107
|
-
continue;
|
|
108
|
-
}
|
|
109
|
-
observed.push({ status, rows, ...known });
|
|
110
|
-
}
|
|
111
|
-
input.observe(structuredClone(observed));
|
|
112
|
-
};
|
|
45
|
+
return reader;
|
|
46
|
+
};
|
|
47
|
+
try {
|
|
113
48
|
const waited = await waitForObservation({
|
|
49
|
+
pollMs: 250,
|
|
114
50
|
...(input.timeoutMs === undefined ? {} : { timeoutMs: input.timeoutMs }),
|
|
115
51
|
...(input.signal === undefined ? {} : { signal: input.signal }),
|
|
116
|
-
...(input.predicate === undefined
|
|
117
|
-
? {
|
|
52
|
+
...(input.predicate === undefined
|
|
53
|
+
? {
|
|
54
|
+
probe: async () => await readWaitComplete(input.path, input.ids, input.completion, input.signal, (id) => readerFor(id).complete(input.signal)),
|
|
55
|
+
}
|
|
118
56
|
: {}),
|
|
119
|
-
observe: async () => await observeWaitRound(input.
|
|
57
|
+
observe: async () => await observeWaitRound(input.ids, readerFor, input.signal),
|
|
120
58
|
complete: (round) => roundComplete(round, input.completion, input.predicate),
|
|
121
|
-
onObserve: async (round) =>
|
|
59
|
+
onObserve: async (round) => {
|
|
60
|
+
await Promise.all(round.observations.map(({ status }) => observeStatusOutcome(status, input.outcomeObserved)));
|
|
61
|
+
},
|
|
122
62
|
});
|
|
123
63
|
return {
|
|
124
64
|
mode: input.completion,
|
|
@@ -128,9 +68,8 @@ export async function executeWaitAkuma(input) {
|
|
|
128
68
|
};
|
|
129
69
|
}
|
|
130
70
|
finally {
|
|
131
|
-
for (const reader of readers
|
|
71
|
+
for (const reader of readers.values())
|
|
132
72
|
reader.clear();
|
|
133
|
-
readers?.clear();
|
|
134
73
|
}
|
|
135
74
|
}
|
|
136
75
|
function diagnostic(error) {
|
|
@@ -3,7 +3,7 @@ import { type BoundedList } from "../bounded-list.js";
|
|
|
3
3
|
import type { AkumaAlias } from "../identity/selector.js";
|
|
4
4
|
import type { WorldRoot } from "../world.js";
|
|
5
5
|
import type { AkumaLife } from "./heart/index.js";
|
|
6
|
-
import { type AkuId } from "./identity.js";
|
|
6
|
+
import { type AkuId, type AkumaPaths } from "./identity.js";
|
|
7
7
|
export type AkumaListRow = Readonly<{
|
|
8
8
|
id: AkuId;
|
|
9
9
|
archetype: string;
|
|
@@ -34,6 +34,30 @@ export type AkumaListInput = Readonly<{
|
|
|
34
34
|
}>;
|
|
35
35
|
export declare const akumaStatusSchema: z.ZodObject<{
|
|
36
36
|
id: z.ZodPipe<z.ZodString, z.ZodTransform<AkuId, string>>;
|
|
37
|
+
birth: z.ZodObject<{
|
|
38
|
+
origin: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
39
|
+
kind: z.ZodLiteral<"direct">;
|
|
40
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
41
|
+
kind: z.ZodLiteral<"request">;
|
|
42
|
+
parent: z.ZodPipe<z.ZodString, z.ZodTransform<AkuId, string>>;
|
|
43
|
+
requestId: z.ZodString;
|
|
44
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
45
|
+
kind: z.ZodLiteral<"fork">;
|
|
46
|
+
parent: z.ZodPipe<z.ZodString, z.ZodTransform<AkuId, string>>;
|
|
47
|
+
at: z.ZodString;
|
|
48
|
+
}, z.core.$strip>], "kind">;
|
|
49
|
+
caller: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
50
|
+
kind: z.ZodLiteral<"akuma">;
|
|
51
|
+
world: z.ZodCustom<WorldRoot, WorldRoot>;
|
|
52
|
+
akuId: z.ZodPipe<z.ZodString, z.ZodTransform<AkuId, string>>;
|
|
53
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
54
|
+
kind: z.ZodLiteral<"external">;
|
|
55
|
+
integration: z.ZodString;
|
|
56
|
+
id: z.ZodString;
|
|
57
|
+
}, z.core.$strict>], "kind">, z.ZodObject<{
|
|
58
|
+
kind: z.ZodLiteral<"unknown">;
|
|
59
|
+
}, z.core.$strict>]>;
|
|
60
|
+
}, z.core.$strict>;
|
|
37
61
|
life: z.ZodEnum<{
|
|
38
62
|
killed: "killed";
|
|
39
63
|
hung: "hung";
|
|
@@ -43,24 +67,21 @@ export declare const akumaStatusSchema: z.ZodObject<{
|
|
|
43
67
|
stranded: "stranded";
|
|
44
68
|
}>;
|
|
45
69
|
cwd: z.ZodOptional<z.ZodString>;
|
|
70
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
71
|
+
model: z.ZodOptional<z.ZodString>;
|
|
46
72
|
allowed: z.ZodPipe<z.ZodArray<z.ZodEnum<{
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"task.hold": "task.hold";
|
|
53
|
-
"task.resume": "task.resume";
|
|
54
|
-
"task.start": "task.start";
|
|
55
|
-
"task.stop": "task.stop";
|
|
56
|
-
"task.update": "task.update";
|
|
73
|
+
"debt.add": "debt.add";
|
|
74
|
+
"debt.addDocument": "debt.addDocument";
|
|
75
|
+
"debt.done": "debt.done";
|
|
76
|
+
"debt.drop": "debt.drop";
|
|
77
|
+
"debt.update": "debt.update";
|
|
57
78
|
"akuma.call": "akuma.call";
|
|
58
79
|
"akuma.kill": "akuma.kill";
|
|
59
80
|
"akuma.tell": "akuma.tell";
|
|
60
81
|
"contract.audit": "contract.audit";
|
|
61
82
|
"contract.deliver": "contract.deliver";
|
|
62
83
|
"contract.review": "contract.review";
|
|
63
|
-
}>>, z.ZodTransform<import("./allowed.js").AllowedActions, ("
|
|
84
|
+
}>>, z.ZodTransform<import("./allowed.js").AllowedActions, ("debt.add" | "debt.addDocument" | "debt.done" | "debt.drop" | "debt.update" | "akuma.call" | "akuma.kill" | "akuma.tell" | "contract.audit" | "contract.deliver" | "contract.review")[]>>;
|
|
64
85
|
timeline: z.ZodUnion<readonly [z.ZodObject<{
|
|
65
86
|
reportedChanges: z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
66
87
|
sequence: z.ZodNumber;
|
|
@@ -204,6 +225,7 @@ export declare const akumaStatusSchema: z.ZodObject<{
|
|
|
204
225
|
unspecified: "unspecified";
|
|
205
226
|
}>;
|
|
206
227
|
path: z.ZodString;
|
|
228
|
+
patch: z.ZodOptional<z.ZodString>;
|
|
207
229
|
diffstat: z.ZodOptional<z.ZodObject<{
|
|
208
230
|
added: z.ZodNumber;
|
|
209
231
|
removed: z.ZodNumber;
|
|
@@ -218,6 +240,7 @@ export declare const akumaStatusSchema: z.ZodObject<{
|
|
|
218
240
|
}, z.core.$strict>>;
|
|
219
241
|
}, z.core.$strict>]>;
|
|
220
242
|
state: z.ZodLiteral<"active">;
|
|
243
|
+
toolId: z.ZodOptional<z.ZodString>;
|
|
221
244
|
truncated: z.ZodOptional<z.ZodLiteral<true>>;
|
|
222
245
|
}, z.core.$strict>, z.ZodObject<{
|
|
223
246
|
kind: z.ZodLiteral<"tool">;
|
|
@@ -254,6 +277,7 @@ export declare const akumaStatusSchema: z.ZodObject<{
|
|
|
254
277
|
unspecified: "unspecified";
|
|
255
278
|
}>;
|
|
256
279
|
path: z.ZodString;
|
|
280
|
+
patch: z.ZodOptional<z.ZodString>;
|
|
257
281
|
diffstat: z.ZodOptional<z.ZodObject<{
|
|
258
282
|
added: z.ZodNumber;
|
|
259
283
|
removed: z.ZodNumber;
|
|
@@ -273,8 +297,10 @@ export declare const akumaStatusSchema: z.ZodObject<{
|
|
|
273
297
|
ok: "ok";
|
|
274
298
|
}>;
|
|
275
299
|
message: z.ZodOptional<z.ZodString>;
|
|
300
|
+
output: z.ZodOptional<z.ZodString>;
|
|
276
301
|
exitCode: z.ZodOptional<z.ZodNumber>;
|
|
277
302
|
}, z.core.$strict>;
|
|
303
|
+
toolId: z.ZodOptional<z.ZodString>;
|
|
278
304
|
truncated: z.ZodOptional<z.ZodLiteral<true>>;
|
|
279
305
|
}, z.core.$strict>]>;
|
|
280
306
|
}, z.core.$strict>]>>>;
|
|
@@ -307,6 +333,7 @@ export declare const akumaStatusSchema: z.ZodObject<{
|
|
|
307
333
|
kind: z.ZodLiteral<"answered">;
|
|
308
334
|
historyId: z.ZodString;
|
|
309
335
|
answer: z.ZodString;
|
|
336
|
+
foldedSaidSequence: z.ZodOptional<z.ZodNumber>;
|
|
310
337
|
}, z.core.$strict>, z.ZodObject<{
|
|
311
338
|
kind: z.ZodLiteral<"failed">;
|
|
312
339
|
historyId: z.ZodString;
|
|
@@ -412,6 +439,7 @@ export declare const akumaStatusSchema: z.ZodObject<{
|
|
|
412
439
|
unspecified: "unspecified";
|
|
413
440
|
}>;
|
|
414
441
|
path: z.ZodString;
|
|
442
|
+
patch: z.ZodOptional<z.ZodString>;
|
|
415
443
|
diffstat: z.ZodOptional<z.ZodObject<{
|
|
416
444
|
added: z.ZodNumber;
|
|
417
445
|
removed: z.ZodNumber;
|
|
@@ -431,8 +459,10 @@ export declare const akumaStatusSchema: z.ZodObject<{
|
|
|
431
459
|
ok: "ok";
|
|
432
460
|
}>;
|
|
433
461
|
message: z.ZodOptional<z.ZodString>;
|
|
462
|
+
output: z.ZodOptional<z.ZodString>;
|
|
434
463
|
exitCode: z.ZodOptional<z.ZodNumber>;
|
|
435
464
|
}, z.core.$strict>;
|
|
465
|
+
toolId: z.ZodOptional<z.ZodString>;
|
|
436
466
|
truncated: z.ZodOptional<z.ZodLiteral<true>>;
|
|
437
467
|
}, z.core.$strict>]>;
|
|
438
468
|
}, z.core.$strict>]>>>;
|
|
@@ -441,10 +471,16 @@ export declare const akumaStatusSchema: z.ZodObject<{
|
|
|
441
471
|
strandedReason: z.ZodOptional<z.ZodLiteral<"resume-unsupported">>;
|
|
442
472
|
}, z.core.$strict>;
|
|
443
473
|
export type AkumaStatus = z.infer<typeof akumaStatusSchema>;
|
|
444
|
-
|
|
445
|
-
export
|
|
446
|
-
|
|
447
|
-
|
|
474
|
+
/** One recognized Akuma directory under this World's run root. */
|
|
475
|
+
export type KnownAkuma = Readonly<{
|
|
476
|
+
id: AkuId;
|
|
477
|
+
paths: AkumaPaths;
|
|
478
|
+
}>;
|
|
479
|
+
/** Enumerate the recognized Akuma directories under this World's run root. */
|
|
480
|
+
export declare function knownAkuma(path: WorldRoot, selected?: string): Promise<Readonly<{
|
|
481
|
+
runRoot: string;
|
|
482
|
+
rows: readonly KnownAkuma[];
|
|
483
|
+
}>>;
|
|
448
484
|
/**
|
|
449
485
|
* The bounded recent-activity roster: native membership, semantic order and
|
|
450
486
|
* observed extent. World Alias context is attached by the upper composition.
|