@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
|
@@ -22,7 +22,7 @@ import { regionOverlapSchema } from "./region.js";
|
|
|
22
22
|
// One invocation-wide tagged Effect carrier
|
|
23
23
|
// ---------------------------------------------------------------------------
|
|
24
24
|
const reconciliationEffectSchema = z.union([reconcileEffectSchema, contractFileEffectSchema]);
|
|
25
|
-
const resetOwnerSchema = z.enum(["akuma", "git", "
|
|
25
|
+
const resetOwnerSchema = z.enum(["akuma", "git", "debt", "world"]);
|
|
26
26
|
const resetEffectFields = { world: z.string().min(1), owner: resetOwnerSchema, diagnostic: z.string().min(1) };
|
|
27
27
|
const resetEffectSchema = z.union([
|
|
28
28
|
z.object({ kind: z.literal("reset-owner-stopped"), ...resetEffectFields }).strict(),
|
|
@@ -158,7 +158,7 @@ export function project(operation, snapshot, projection) {
|
|
|
158
158
|
if (operation !== "nuke")
|
|
159
159
|
throw new Error("reset projection requires nuke");
|
|
160
160
|
const effects = snapshot.effects.filter((effect) => effect.kind === "reset-owner-stopped" || effect.kind === "reset-residue");
|
|
161
|
-
const value = { removed: snapshot.reset?.removed ?? { refs: 0, worktrees: 0,
|
|
161
|
+
const value = { removed: snapshot.reset?.removed ?? { refs: 0, worktrees: 0, debts: 0 } };
|
|
162
162
|
const base = { operation, world: projection.world, effects, pending: projectPending(operation, value, effects) };
|
|
163
163
|
if (projection.kind === "failed")
|
|
164
164
|
return {
|
|
@@ -257,6 +257,16 @@ export function errorCategory(error) {
|
|
|
257
257
|
return "aborted";
|
|
258
258
|
return "internal";
|
|
259
259
|
}
|
|
260
|
+
export async function readContractValue(operation) {
|
|
261
|
+
try {
|
|
262
|
+
return await operation();
|
|
263
|
+
}
|
|
264
|
+
catch (error) {
|
|
265
|
+
if (error instanceof KeiyakuError)
|
|
266
|
+
throw error;
|
|
267
|
+
throw new KeiyakuError(errorCategory(error), errorDiagnostic(error), { cause: error });
|
|
268
|
+
}
|
|
269
|
+
}
|
|
260
270
|
function errorDiagnostic(error) {
|
|
261
271
|
return error instanceof Error ? error.message : String(error);
|
|
262
272
|
}
|
|
@@ -394,7 +404,7 @@ const resetCountsSchema = z
|
|
|
394
404
|
.object({
|
|
395
405
|
refs: z.number().int().nonnegative(),
|
|
396
406
|
worktrees: z.number().int().nonnegative(),
|
|
397
|
-
|
|
407
|
+
debts: z.number().int().nonnegative(),
|
|
398
408
|
})
|
|
399
409
|
.strict();
|
|
400
410
|
const resetValueSchema = z.object({ removed: resetCountsSchema }).strict();
|
|
@@ -54,11 +54,8 @@ function registerLag(scope, error) {
|
|
|
54
54
|
function emptySettlement() {
|
|
55
55
|
return { actions: [], lags: [] };
|
|
56
56
|
}
|
|
57
|
-
function isManagedWorktree(state) {
|
|
58
|
-
return state.coordinates.workspace === "worktree";
|
|
59
|
-
}
|
|
60
57
|
function isManagedTerminal(state) {
|
|
61
|
-
return state !== null &&
|
|
58
|
+
return state !== null && state.terminal !== null;
|
|
62
59
|
}
|
|
63
60
|
/**
|
|
64
61
|
* Terminal cleanup retires the appointed worktree. Name its short name only when this
|
|
@@ -76,7 +73,7 @@ function terminalWorktreeOutcome(scope, cleanup, place) {
|
|
|
76
73
|
return undefined;
|
|
77
74
|
}
|
|
78
75
|
function appointableManagedContracts(states) {
|
|
79
|
-
return states.filter((state) =>
|
|
76
|
+
return states.filter((state) => state.terminal === null).map((state) => state.id);
|
|
80
77
|
}
|
|
81
78
|
async function appointPlaces(scope, states) {
|
|
82
79
|
return await appointManagedWorktrees(scope, appointableManagedContracts(states));
|
|
@@ -114,8 +111,6 @@ async function observeState(scope, channel, contractId) {
|
|
|
114
111
|
}
|
|
115
112
|
}
|
|
116
113
|
async function appointForContract(scope, state) {
|
|
117
|
-
if (!isManagedWorktree(state))
|
|
118
|
-
return {};
|
|
119
114
|
try {
|
|
120
115
|
const register = await appointPlaces(scope, [state]);
|
|
121
116
|
const place = register.byContract.get(state.id)?.place;
|
|
@@ -265,16 +260,13 @@ export async function completeRepoReconcile(input) {
|
|
|
265
260
|
if (!isOperationalFailure(error))
|
|
266
261
|
throw error;
|
|
267
262
|
const lag = registerLag(input.scope, error);
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
contracts.
|
|
263
|
+
return {
|
|
264
|
+
kind: "completed",
|
|
265
|
+
contracts: states.map((state) => ({
|
|
271
266
|
contractId: state.id,
|
|
272
|
-
report:
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
return { kind: "completed", contracts };
|
|
267
|
+
report: { effects: [], lag: [lag], settlement: emptySettlement() },
|
|
268
|
+
})),
|
|
269
|
+
};
|
|
278
270
|
}
|
|
279
271
|
const places = new Map(appointed.appointments.map((appointment) => [appointment.contract, appointment.place]));
|
|
280
272
|
const retained = await reconcileAllOperation({
|
|
@@ -177,8 +177,8 @@ export declare const keiyakuRefusalSchema: z.ZodUnion<readonly [z.ZodUnion<reado
|
|
|
177
177
|
}, z.core.$strict>>>;
|
|
178
178
|
}, z.core.$strict>]>, z.ZodObject<{
|
|
179
179
|
kind: z.ZodEnum<{
|
|
180
|
-
"unborn-head": "unborn-head";
|
|
181
180
|
"target-missing": "target-missing";
|
|
181
|
+
"unborn-head": "unborn-head";
|
|
182
182
|
"invalid-target": "invalid-target";
|
|
183
183
|
}>;
|
|
184
184
|
}, z.core.$strict>, z.ZodObject<{
|
|
@@ -302,8 +302,8 @@ export declare const operationRefusalSchemas: {
|
|
|
302
302
|
contractId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../index.js").ContractId, string>>;
|
|
303
303
|
}, z.core.$strict>, z.ZodObject<{
|
|
304
304
|
kind: z.ZodEnum<{
|
|
305
|
-
"unborn-head": "unborn-head";
|
|
306
305
|
"target-missing": "target-missing";
|
|
306
|
+
"unborn-head": "unborn-head";
|
|
307
307
|
"invalid-target": "invalid-target";
|
|
308
308
|
}>;
|
|
309
309
|
}, z.core.$strict>, z.ZodUnion<readonly [z.ZodObject<{
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { type RepositoryScope } from "../protocol/operations.js";
|
|
2
2
|
import { NoGitWorldError } from "../git/repository.js";
|
|
3
3
|
export { NoGitWorldError };
|
|
4
|
+
/** One explicit worktree coordinate. The caller resolves relative and ambient spellings, never this edge. */
|
|
4
5
|
export type RepoAtInput = Readonly<{
|
|
5
|
-
path
|
|
6
|
+
path: string;
|
|
6
7
|
gitPath?: string;
|
|
7
8
|
}>;
|
|
8
9
|
/** One Git world shared by its worktrees; it is coordinate proof and branch observation only. */
|
|
@@ -10,7 +11,7 @@ export declare class Repo {
|
|
|
10
11
|
readonly root: string;
|
|
11
12
|
readonly cwd: string;
|
|
12
13
|
private constructor();
|
|
13
|
-
static at(input
|
|
14
|
+
static at(input: RepoAtInput): Promise<Repo>;
|
|
14
15
|
currentBranch(): Promise<string | null>;
|
|
15
16
|
}
|
|
16
17
|
export declare function scopeForRepo(value: unknown): RepositoryScope;
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { realpath } from "node:fs/promises";
|
|
2
|
-
import {
|
|
2
|
+
import { isAbsolute } from "node:path";
|
|
3
3
|
import { currentBranchOperation, scopeOperation } from "../protocol/operations.js";
|
|
4
4
|
import { NoGitWorldError } from "../git/repository.js";
|
|
5
5
|
import { optionalNonblank, requireInput } from "./input.js";
|
|
6
6
|
export { NoGitWorldError };
|
|
7
7
|
const REPO_SCOPES = new WeakMap();
|
|
8
|
-
async function resolvePinnedScope(
|
|
8
|
+
async function resolvePinnedScope(values) {
|
|
9
|
+
const path = values.path;
|
|
10
|
+
if (typeof path !== "string" || path.trim().length === 0)
|
|
11
|
+
throw new TypeError("repository path must be a nonblank string");
|
|
12
|
+
if (!isAbsolute(path))
|
|
13
|
+
throw new TypeError(`repository path must be absolute: ${path}`);
|
|
14
|
+
const gitPath = optionalNonblank(values.gitPath, "Git executable path");
|
|
9
15
|
return await scopeOperation({
|
|
10
|
-
coordinate: await realpath(
|
|
16
|
+
coordinate: await realpath(path),
|
|
11
17
|
...(gitPath === undefined ? {} : { gitPath }),
|
|
12
18
|
});
|
|
13
19
|
}
|
|
@@ -21,8 +27,7 @@ export class Repo {
|
|
|
21
27
|
REPO_SCOPES.set(this, scope);
|
|
22
28
|
}
|
|
23
29
|
static async at(input) {
|
|
24
|
-
|
|
25
|
-
return new Repo(await resolvePinnedScope(optionalNonblank(values?.path, "repository path"), optionalNonblank(values?.gitPath, "Git executable path")));
|
|
30
|
+
return new Repo(await resolvePinnedScope(requireInput(input, "Repo.at input", ["path", "gitPath"])));
|
|
26
31
|
}
|
|
27
32
|
async currentBranch() {
|
|
28
33
|
return await currentBranchOperation({ scope: scopeForRepo(this) });
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { type AskObserver } from "../akuma/akuma-selection-execution.js";
|
|
2
|
-
import { type WaitObserver } from "../akuma/akuma-wait.js";
|
|
3
2
|
import { type AkumaStatus } from "../akuma/akuma.js";
|
|
4
3
|
import { type ActivityHistory, type OutcomeRow } from "../akuma/projection.js";
|
|
5
4
|
import { type ExecutionContext } from "../akuma/requests.js";
|
|
6
5
|
import { type Schema } from "../akuma/schema.js";
|
|
7
6
|
import type { AkumaAskResult, AkumaKillResult, AkumaObservation, AkumaTellResult, AkumaWaitResult } from "../akuma/selection-observation.js";
|
|
8
|
-
import {
|
|
7
|
+
import type { DispatchAssociation } from "../akuma/dispatch-association.js";
|
|
9
8
|
import type { WorldRoot } from "../world.js";
|
|
10
9
|
import { addressAkuma, addressAkumaSet, type AkumaAddressInput, type AkumaSetAddressInput } from "./address.js";
|
|
11
10
|
import { type Repo } from "./repo.js";
|
|
@@ -28,18 +27,16 @@ type SelectionWaitMode = Readonly<{
|
|
|
28
27
|
export type SelectionSeam = Readonly<{
|
|
29
28
|
addressOne(input: UncheckedSelectionAddress): Promise<AddressedAkuma>;
|
|
30
29
|
addressSet(input: UncheckedSelectionAddress): Promise<AddressedAkumaSet>;
|
|
31
|
-
wait(addressed: AddressedAkumaSet, mode: SelectionWaitMode
|
|
30
|
+
wait(addressed: AddressedAkumaSet, mode: SelectionWaitMode): Promise<AkumaWaitResult>;
|
|
32
31
|
kill(addressed: AddressedAkumaSet, signal?: AbortSignal): Promise<AkumaKillResult>;
|
|
33
32
|
tell(addressed: AddressedAkuma, input: AkumaTellInput, signal?: AbortSignal): Promise<AkumaTellResult>;
|
|
34
33
|
ask<T>(addressed: AddressedAkuma, input: AkumaAskInput<T>, signal?: AbortSignal): Promise<AkumaAskResult<T>>;
|
|
35
34
|
}>;
|
|
36
|
-
export declare function selectionSeam(execution: ExecutionContext): SelectionSeam;
|
|
35
|
+
export declare function selectionSeam(execution: ExecutionContext, reportDiagnostic?: (message: string) => void): SelectionSeam;
|
|
37
36
|
export type AkumaWaitInput = AkumaSetAddressInput & Readonly<{
|
|
38
37
|
completion?: "any" | "all";
|
|
39
38
|
timeoutMs?: number;
|
|
40
39
|
signal?: AbortSignal;
|
|
41
|
-
/** The existing optional live-observation seam, validated here like Ask's. */
|
|
42
|
-
observe?: WaitObserver;
|
|
43
40
|
}>;
|
|
44
41
|
export type AkumaTellInput = AkumaAddressInput & Readonly<{
|
|
45
42
|
body: string;
|
|
@@ -94,7 +91,7 @@ export type AkumaHistoryResult = Readonly<{
|
|
|
94
91
|
}>;
|
|
95
92
|
export declare function statusAkuma(input: AkumaAddressInput & Readonly<{
|
|
96
93
|
path: WorldRoot;
|
|
97
|
-
}
|
|
94
|
+
}>, reportDiagnostic?: (message: string) => void): Promise<AkumaObservation>;
|
|
98
95
|
export declare function waitAkumaOn(seam: SelectionSeam, input: AkumaWaitInput & Readonly<{
|
|
99
96
|
path: WorldRoot;
|
|
100
97
|
}>): Promise<AkumaWaitResult>;
|
|
@@ -109,4 +106,4 @@ export declare function askAkumaOn<T = string>(seam: SelectionSeam, input: Akuma
|
|
|
109
106
|
}>): Promise<AkumaAskResult<T>>;
|
|
110
107
|
export declare function historyAkuma(input: AkumaHistoryInput & Readonly<{
|
|
111
108
|
path: WorldRoot;
|
|
112
|
-
}
|
|
109
|
+
}>, reportDiagnostic?: (message: string) => void): Promise<AkumaHistoryResult>;
|
|
@@ -3,23 +3,22 @@ import { withoutReportedChanges } from "../akuma/projection.js";
|
|
|
3
3
|
import { AkumaNotBornError, AkumaObservationError } from "../akuma/akuma-errors.js";
|
|
4
4
|
import { AkumaOwner } from "../akuma/akuma-owner.js";
|
|
5
5
|
import { decodeAskObservation, executeAskAkuma, executeKillAkuma, executeTellAkuma, } from "../akuma/akuma-selection-execution.js";
|
|
6
|
-
import { executeWaitAkuma
|
|
6
|
+
import { executeWaitAkuma } from "../akuma/akuma-wait.js";
|
|
7
7
|
import { parsePublicHistoryId } from "../akuma/identity.js";
|
|
8
8
|
import { executionChannel } from "../akuma/requests.js";
|
|
9
9
|
import { schemaJsonText } from "../akuma/schema.js";
|
|
10
10
|
import { requestForwardedSelectionAsk, requestForwardedSelectionKill, requestForwardedSelectionTell, requestForwardedSelectionWait, } from "../akuma/selection-request.js";
|
|
11
|
-
import { readAliases } from "../alias/index.js";
|
|
12
11
|
import { observeDispatchAssociations } from "../dispatch/index.js";
|
|
13
12
|
import { observeContractAt } from "../git/observe.js";
|
|
14
13
|
import { withGitDecodeChannel } from "../git/read-observation.js";
|
|
15
|
-
import {
|
|
16
|
-
import { outcomePluginObserver } from "../plugin/akuma-signals.js";
|
|
14
|
+
import { observeCreatedDebtObservations } from "../debt/created-observation.js";
|
|
15
|
+
import { outcomePluginObserver, stderrPluginDiagnostic } from "../plugin/akuma-signals.js";
|
|
17
16
|
import { addressAkuma, addressAkumaSet, resolveAkuma, resolveAkumaSet, } from "./address.js";
|
|
18
17
|
import { requireInput } from "./input.js";
|
|
19
18
|
import { scopeForRepo } from "./repo.js";
|
|
20
|
-
export function selectionSeam(execution) {
|
|
19
|
+
export function selectionSeam(execution, reportDiagnostic = stderrPluginDiagnostic) {
|
|
21
20
|
const channel = executionChannel(execution);
|
|
22
|
-
return channel.kind === "body-request" ? forwardedSelection(channel.directory) : localSelection();
|
|
21
|
+
return channel.kind === "body-request" ? forwardedSelection(channel.directory) : localSelection(reportDiagnostic);
|
|
23
22
|
}
|
|
24
23
|
function forwardedSelection(directory) {
|
|
25
24
|
return {
|
|
@@ -56,11 +55,11 @@ function forwardedSelection(directory) {
|
|
|
56
55
|
},
|
|
57
56
|
};
|
|
58
57
|
}
|
|
59
|
-
function localSelection() {
|
|
58
|
+
function localSelection(reportDiagnostic) {
|
|
60
59
|
return {
|
|
61
60
|
addressOne: addressAkuma,
|
|
62
61
|
addressSet: addressAkumaSet,
|
|
63
|
-
wait: async (addressed, mode
|
|
62
|
+
wait: async (addressed, mode) => await localWait(addressed, mode, reportDiagnostic),
|
|
64
63
|
kill: async (addressed, abort) => await executeKillAkuma({
|
|
65
64
|
path: addressed.path,
|
|
66
65
|
ids: addressed.orderedIds,
|
|
@@ -78,7 +77,7 @@ function localSelection() {
|
|
|
78
77
|
const result = await executeAskAkuma({
|
|
79
78
|
path: addressed.path,
|
|
80
79
|
id: addressed.id,
|
|
81
|
-
outcomeObserved: outcomePluginObserver({ world: addressed.path, reportDiagnostic
|
|
80
|
+
outcomeObserved: outcomePluginObserver({ world: addressed.path, reportDiagnostic }),
|
|
82
81
|
body: input.body,
|
|
83
82
|
...(input.timeoutMs === undefined ? {} : { timeoutMs: input.timeoutMs }),
|
|
84
83
|
...(input.schema === undefined ? {} : { schemaJson: schemaJsonText(input.schema) }),
|
|
@@ -136,43 +135,19 @@ function placementDischarged(repo) {
|
|
|
136
135
|
async function composeObservation(status, contract, discharged) {
|
|
137
136
|
return (await discharged(contract)) ? { ...status, timeline: withoutReportedChanges(status.timeline) } : status;
|
|
138
137
|
}
|
|
139
|
-
async function
|
|
140
|
-
return await
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* One wait's identity-fact resolver: the alias bound to an Akuma in its world and
|
|
144
|
-
* its Dispatch association. The alias index is read once, on the first observed
|
|
145
|
-
* Akuma, and each Akuma's alias is the first binding the canonical order offers.
|
|
146
|
-
* Alias bindings and selected Dispatch associations are read once for this live
|
|
147
|
-
* stage. Final result composition owns a separate, fresh Dispatch observation.
|
|
148
|
-
*/
|
|
149
|
-
function waitIdentityFacts(path, repo, selected) {
|
|
150
|
-
let aliases;
|
|
151
|
-
let contracts;
|
|
152
|
-
return async (id) => {
|
|
153
|
-
if (aliases === undefined) {
|
|
154
|
-
const bound = new Map();
|
|
155
|
-
for (const binding of await readAliases(path)) {
|
|
156
|
-
if (!bound.has(binding.akuId))
|
|
157
|
-
bound.set(binding.akuId, binding.alias);
|
|
158
|
-
}
|
|
159
|
-
aliases = bound;
|
|
160
|
-
}
|
|
161
|
-
contracts ??= await dispatchAssociations(repo, selected);
|
|
162
|
-
const alias = aliases.get(id);
|
|
163
|
-
return { ...(alias === undefined ? {} : { alias }), contract: contracts.get(id) };
|
|
164
|
-
};
|
|
138
|
+
async function createdDebtsFor(path, statuses) {
|
|
139
|
+
return await observeCreatedDebtObservations(path, statuses.map((status) => status.id));
|
|
165
140
|
}
|
|
166
141
|
async function observeAkuma(status, path, repo) {
|
|
167
142
|
return (await composeAkumaAssociations([status], path, repo))[0];
|
|
168
143
|
}
|
|
169
144
|
/**
|
|
170
145
|
* The one upper composition of association-free native status evidence into its
|
|
171
|
-
* public observation shape. It reads Alias-independent Dispatch and
|
|
146
|
+
* public observation shape. It reads Alias-independent Dispatch and Debt
|
|
172
147
|
* associations after the lower values, never before or inside them.
|
|
173
148
|
*/
|
|
174
149
|
async function composeAkumaAssociations(statuses, path, repo) {
|
|
175
|
-
const created = await
|
|
150
|
+
const created = await createdDebtsFor(path, statuses);
|
|
176
151
|
const discharged = placementDischarged(repo);
|
|
177
152
|
const contracts = await dispatchAssociations(repo, statuses.map((status) => status.id));
|
|
178
153
|
return await Promise.all(statuses.map(async (status, index) => {
|
|
@@ -180,7 +155,7 @@ async function composeAkumaAssociations(statuses, path, repo) {
|
|
|
180
155
|
return {
|
|
181
156
|
status: await composeObservation(status, contract, discharged),
|
|
182
157
|
contract,
|
|
183
|
-
|
|
158
|
+
createdDebts: created[index],
|
|
184
159
|
};
|
|
185
160
|
}));
|
|
186
161
|
}
|
|
@@ -214,7 +189,7 @@ async function composeWaitResult(path, repo, result) {
|
|
|
214
189
|
}
|
|
215
190
|
/**
|
|
216
191
|
* Re-attach upper associations after a wait result crosses a forwarded
|
|
217
|
-
* boundary; the serving side must observe its own Dispatch and
|
|
192
|
+
* boundary; the serving side must observe its own Dispatch and Debt state.
|
|
218
193
|
*/
|
|
219
194
|
async function attachWaitAssociations(path, repo, result) {
|
|
220
195
|
return await composeWaitResult(path, repo, {
|
|
@@ -238,10 +213,10 @@ function setAddress(values) {
|
|
|
238
213
|
...(values.repo === undefined ? {} : { repo: values.repo }),
|
|
239
214
|
};
|
|
240
215
|
}
|
|
241
|
-
export async function statusAkuma(input) {
|
|
216
|
+
export async function statusAkuma(input, reportDiagnostic = stderrPluginDiagnostic) {
|
|
242
217
|
const addressed = await addressAkuma(input);
|
|
243
218
|
try {
|
|
244
|
-
return await observeAkuma(await new AkumaOwner(addressed.id, addressed.path, outcomePluginObserver({ world: addressed.path, reportDiagnostic
|
|
219
|
+
return await observeAkuma(await new AkumaOwner(addressed.id, addressed.path, outcomePluginObserver({ world: addressed.path, reportDiagnostic })).status(), addressed.path, input.repo);
|
|
245
220
|
}
|
|
246
221
|
catch (error) {
|
|
247
222
|
throw observationError(addressed.id, error);
|
|
@@ -264,19 +239,15 @@ async function forwardedWait(addressed, input) {
|
|
|
264
239
|
...(input.signal === undefined ? {} : { signal: input.signal }),
|
|
265
240
|
}));
|
|
266
241
|
}
|
|
267
|
-
async function localWait(addressed, input) {
|
|
242
|
+
async function localWait(addressed, input, reportDiagnostic) {
|
|
268
243
|
try {
|
|
269
244
|
return await composeWaitResult(addressed.path, input.repo, await executeWaitAkuma({
|
|
270
245
|
path: addressed.path,
|
|
271
246
|
ids: addressed.orderedIds,
|
|
272
247
|
completion: input.completion,
|
|
273
|
-
outcomeObserved: outcomePluginObserver({ world: addressed.path, reportDiagnostic
|
|
248
|
+
outcomeObserved: outcomePluginObserver({ world: addressed.path, reportDiagnostic }),
|
|
274
249
|
...(input.timeoutMs === undefined ? {} : { timeoutMs: input.timeoutMs }),
|
|
275
250
|
...(input.signal === undefined ? {} : { signal: input.signal }),
|
|
276
|
-
identity: waitIdentityFacts(addressed.path, input.repo, addressed.orderedIds),
|
|
277
|
-
selectionOrder: addressed.orderedIds,
|
|
278
|
-
...(input.observer?.selected === undefined ? {} : { onSelected: input.observer.selected }),
|
|
279
|
-
...(input.observer?.observe === undefined ? {} : { observe: input.observer.observe }),
|
|
280
251
|
}));
|
|
281
252
|
}
|
|
282
253
|
catch (error) {
|
|
@@ -285,35 +256,13 @@ async function localWait(addressed, input) {
|
|
|
285
256
|
throw observationError(addressed.orderedIds[0], error);
|
|
286
257
|
}
|
|
287
258
|
}
|
|
288
|
-
function waitObserver(value) {
|
|
289
|
-
if (value === undefined)
|
|
290
|
-
return undefined;
|
|
291
|
-
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
292
|
-
throw new TypeError("observe must be a WaitObserver");
|
|
293
|
-
const record = value;
|
|
294
|
-
for (const key of Object.keys(record)) {
|
|
295
|
-
if (key !== "selected" && key !== "observe")
|
|
296
|
-
throw new TypeError(`observe has unknown field: ${key}`);
|
|
297
|
-
if (record[key] !== undefined && typeof record[key] !== "function")
|
|
298
|
-
throw new TypeError(`observe.${key} must be a function`);
|
|
299
|
-
}
|
|
300
|
-
return {
|
|
301
|
-
...(record.selected === undefined
|
|
302
|
-
? {}
|
|
303
|
-
: { selected: record.selected }),
|
|
304
|
-
...(record.observe === undefined
|
|
305
|
-
? {}
|
|
306
|
-
: { observe: record.observe }),
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
259
|
export async function waitAkumaOn(seam, input) {
|
|
310
260
|
const values = requireInput(input, "Akumas.wait input");
|
|
311
261
|
for (const key of Object.keys(values)) {
|
|
312
|
-
if (!["path", "akuma", "repo", "completion", "timeoutMs", "signal"
|
|
262
|
+
if (!["path", "akuma", "repo", "completion", "timeoutMs", "signal"].includes(key)) {
|
|
313
263
|
throw new TypeError(`Akumas.wait input has unknown field: ${key}`);
|
|
314
264
|
}
|
|
315
265
|
}
|
|
316
|
-
const observer = waitObserver(values.observe);
|
|
317
266
|
const selected = completionMode(values.completion);
|
|
318
267
|
const timeoutMs = timeout(values.timeoutMs);
|
|
319
268
|
const callerSignal = signal(values.signal);
|
|
@@ -324,7 +273,7 @@ export async function waitAkumaOn(seam, input) {
|
|
|
324
273
|
...(timeoutMs === undefined ? {} : { timeoutMs }),
|
|
325
274
|
...(callerSignal === undefined ? {} : { signal: callerSignal }),
|
|
326
275
|
...(repo === undefined ? {} : { repo }),
|
|
327
|
-
}
|
|
276
|
+
});
|
|
328
277
|
}
|
|
329
278
|
export async function killAkumaOn(seam, input) {
|
|
330
279
|
const values = requireInput(input, "Akumas.kill input");
|
|
@@ -388,12 +337,12 @@ function validateHistoryInput(values) {
|
|
|
388
337
|
(values.last === true || values.before !== undefined || values.since !== undefined || values.limit !== undefined))
|
|
389
338
|
throw new TypeError("id cannot be combined with last, before, since, or limit");
|
|
390
339
|
}
|
|
391
|
-
export async function historyAkuma(input) {
|
|
340
|
+
export async function historyAkuma(input, reportDiagnostic = stderrPluginDiagnostic) {
|
|
392
341
|
const values = requireInput(input, "Akumas.history input");
|
|
393
342
|
validateHistoryInput(values);
|
|
394
343
|
const addressed = await addressAkuma(directAddress(values));
|
|
395
344
|
try {
|
|
396
|
-
const handle = new AkumaOwner(addressed.id, addressed.path, outcomePluginObserver({ world: addressed.path, reportDiagnostic
|
|
345
|
+
const handle = new AkumaOwner(addressed.id, addressed.path, outcomePluginObserver({ world: addressed.path, reportDiagnostic }));
|
|
397
346
|
const contract = (await dispatchAssociations(values.repo, [addressed.id])).get(addressed.id);
|
|
398
347
|
if (values.last === true) {
|
|
399
348
|
const answer = await handle.lastAnswer();
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Settings } from "../settings.js";
|
|
2
2
|
import type { WorldRoot } from "../world.js";
|
|
3
3
|
import type { PluginSignal } from "./public.js";
|
|
4
|
+
/** The local library observation default; CLI and Body supply their own sinks. */
|
|
5
|
+
export declare function stderrPluginDiagnostic(message: string): void;
|
|
4
6
|
type PluginSignalEmission = Readonly<{
|
|
5
7
|
world: WorldRoot;
|
|
6
8
|
settings?: Settings;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { pluginRuntime, reportPluginDiagnostic } from "./runtime.js";
|
|
2
|
+
/** The local library observation default; CLI and Body supply their own sinks. */
|
|
3
|
+
export function stderrPluginDiagnostic(message) {
|
|
4
|
+
console.error(message);
|
|
5
|
+
}
|
|
2
6
|
/**
|
|
3
7
|
* The one producer entry for plugin signals. It owns runtime acquisition, the
|
|
4
8
|
* World Settings fallback, bounded delivery, and failure isolation: a delivery
|
|
@@ -15,13 +15,38 @@ export type PluginOutcome = Readonly<{
|
|
|
15
15
|
reason: string;
|
|
16
16
|
}>;
|
|
17
17
|
export type PluginBodyEnd = "exited" | "broke-off" | "put-down" | "hung";
|
|
18
|
+
export type PluginAkumaOrigin = Readonly<{
|
|
19
|
+
kind: "direct";
|
|
20
|
+
}> | Readonly<{
|
|
21
|
+
kind: "request";
|
|
22
|
+
parent: string;
|
|
23
|
+
requestId: string;
|
|
24
|
+
}> | Readonly<{
|
|
25
|
+
kind: "fork";
|
|
26
|
+
parent: string;
|
|
27
|
+
at: string;
|
|
28
|
+
}>;
|
|
29
|
+
export type PluginAkumaCaller = Readonly<{
|
|
30
|
+
kind: "akuma";
|
|
31
|
+
world: string;
|
|
32
|
+
akuId: string;
|
|
33
|
+
}> | Readonly<{
|
|
34
|
+
kind: "external";
|
|
35
|
+
integration: string;
|
|
36
|
+
id: string;
|
|
37
|
+
}> | Readonly<{
|
|
38
|
+
kind: "unknown";
|
|
39
|
+
}>;
|
|
18
40
|
export type PluginSignalMap = Readonly<{
|
|
19
41
|
"akuma.initiating": Readonly<{
|
|
20
42
|
initiator: string;
|
|
21
43
|
}>;
|
|
22
|
-
"akuma.
|
|
44
|
+
"akuma.born": Readonly<{
|
|
23
45
|
akumaId: string;
|
|
24
|
-
|
|
46
|
+
bodySequence: number;
|
|
47
|
+
origin: PluginAkumaOrigin;
|
|
48
|
+
caller: PluginAkumaCaller;
|
|
49
|
+
initiator?: string;
|
|
25
50
|
contractId?: string;
|
|
26
51
|
}>;
|
|
27
52
|
"akuma.outcome-observed": Readonly<{
|
|
@@ -29,6 +54,11 @@ export type PluginSignalMap = Readonly<{
|
|
|
29
54
|
historyId: string;
|
|
30
55
|
observer?: string;
|
|
31
56
|
}>;
|
|
57
|
+
"akuma.turn-started": Readonly<{
|
|
58
|
+
akumaId: string;
|
|
59
|
+
turnSequence: number;
|
|
60
|
+
initiator?: string;
|
|
61
|
+
}>;
|
|
32
62
|
"akuma.turn-outcome": Readonly<{
|
|
33
63
|
akumaId: string;
|
|
34
64
|
bodySequence: number;
|
|
@@ -7,6 +7,7 @@ const DIAGNOSTIC_LIMIT = 500;
|
|
|
7
7
|
const PLUGIN_ATTEMPT_TIMEOUT_MS = 5_000;
|
|
8
8
|
const PLUGIN_NAMESPACE = "plugins";
|
|
9
9
|
const SQUARE_PLUGIN_PACKAGE = "@astrosheep/keiyaku-plugin-square";
|
|
10
|
+
const BUNDLED_PLUGIN_PACKAGES = new Set([SQUARE_PLUGIN_PACKAGE, "@astrosheep/keiyaku-plugin-paseo"]);
|
|
10
11
|
const BUILTIN_PLUGINS = Object.freeze([
|
|
11
12
|
Object.freeze({ id: "square", package: SQUARE_PLUGIN_PACKAGE, config: undefined }),
|
|
12
13
|
]);
|
|
@@ -22,7 +23,7 @@ export function reportPluginDiagnostic(report, subject, stage, error) {
|
|
|
22
23
|
if (report === undefined)
|
|
23
24
|
return;
|
|
24
25
|
try {
|
|
25
|
-
report(`plugin ${subject} ${stage}: ${message(error)}`.slice(0, DIAGNOSTIC_LIMIT));
|
|
26
|
+
void Promise.resolve(report(`plugin ${subject} ${stage}: ${message(error)}`.slice(0, DIAGNOSTIC_LIMIT))).catch(() => { });
|
|
26
27
|
}
|
|
27
28
|
catch {
|
|
28
29
|
// Diagnostics are optional side effects too.
|
|
@@ -204,8 +205,9 @@ async function writablePaths(world, declarations) {
|
|
|
204
205
|
*/
|
|
205
206
|
const SIGNAL_KINDS = Object.freeze({
|
|
206
207
|
"akuma.initiating": true,
|
|
207
|
-
"akuma.
|
|
208
|
+
"akuma.born": true,
|
|
208
209
|
"akuma.outcome-observed": true,
|
|
210
|
+
"akuma.turn-started": true,
|
|
209
211
|
"akuma.turn-outcome": true,
|
|
210
212
|
"akuma.body-ended": true,
|
|
211
213
|
});
|
|
@@ -245,7 +247,7 @@ function sourceUrl(world, packageName) {
|
|
|
245
247
|
return null;
|
|
246
248
|
}
|
|
247
249
|
async function importFromWorld(world, packageName) {
|
|
248
|
-
if (packageName
|
|
250
|
+
if (BUNDLED_PLUGIN_PACKAGES.has(packageName))
|
|
249
251
|
return (await import(packageName));
|
|
250
252
|
const direct = sourceUrl(world, packageName);
|
|
251
253
|
if (direct !== null)
|
|
@@ -3,7 +3,8 @@ import { withPrivateStatePublicationSeat } from "../git/private-state-seat.js";
|
|
|
3
3
|
import { contractState } from "../core/facts/observation.js";
|
|
4
4
|
import { decideAmend } from "../core/verbs/amend.js";
|
|
5
5
|
import { admitDecidedOffer, mintAttempts } from "./attempt.js";
|
|
6
|
-
import { admitted
|
|
6
|
+
import { admitted } from "./outcome.js";
|
|
7
|
+
import { protocolSeatClose } from "./run.js";
|
|
7
8
|
import { timestamp } from "./operations.js";
|
|
8
9
|
async function extendPrerequisiteClosureAt(channel, observation, seeds) {
|
|
9
10
|
let current = observation;
|
|
@@ -34,7 +35,7 @@ export async function amendOperation(input) {
|
|
|
34
35
|
const amendment = source === undefined || input.deriveAmendment === undefined
|
|
35
36
|
? undefined
|
|
36
37
|
: { source, ...input.deriveAmendment(source) };
|
|
37
|
-
return
|
|
38
|
+
return protocolSeatClose(await withPrivateStatePublicationSeat(input.scope, async (seat) => {
|
|
38
39
|
const attempts = mintAttempts({ entryCount: 1 });
|
|
39
40
|
for (let index = 0; index < attempts.length; index += 1) {
|
|
40
41
|
let observation = await observeContractsForAdmissionAt(input.scope, input.channel, [input.contractId]);
|
|
@@ -65,12 +65,6 @@ function validateOffer(offer, attempt) {
|
|
|
65
65
|
if (actualEntries.size === 0)
|
|
66
66
|
throw new Error("offer requires at least one current-attempt ULID");
|
|
67
67
|
}
|
|
68
|
-
function snapshotFor(append, journals, head) {
|
|
69
|
-
const record = journals.get(append.contractId);
|
|
70
|
-
if (record === undefined)
|
|
71
|
-
throw new Error("accepted offer contract is missing from its observation");
|
|
72
|
-
return foldJournal(append.contractId, [...record.entries, ...append.entries], head);
|
|
73
|
-
}
|
|
74
68
|
function journalFor(append, journals) {
|
|
75
69
|
const record = journals.get(append.contractId);
|
|
76
70
|
if (record === undefined)
|
|
@@ -118,11 +112,12 @@ export async function admitDecidedOffer(input) {
|
|
|
118
112
|
if (admission.kind === "accepted") {
|
|
119
113
|
confirmPrivateStatePublication(seat);
|
|
120
114
|
input.progress?.recordPublication(primaryContract, admission.heads[primary.contractId], offerEntries(offer));
|
|
115
|
+
const journal = journalFor(primary, decisionObservation.journals);
|
|
121
116
|
const accepted = {
|
|
122
117
|
kind: "accepted",
|
|
123
118
|
facts: offerEntries(offer),
|
|
124
|
-
state:
|
|
125
|
-
journal
|
|
119
|
+
state: foldJournal(primary.contractId, journal, admission.heads[primary.contractId]),
|
|
120
|
+
journal,
|
|
126
121
|
};
|
|
127
122
|
input.progress?.recordAdmission(accepted);
|
|
128
123
|
return accepted;
|
|
@@ -11,8 +11,8 @@ export type { BindRefusal } from "../core/verbs/bind.js";
|
|
|
11
11
|
export type { BindTargetSelection };
|
|
12
12
|
export declare const targetInputRefusalSchema: z.ZodObject<{
|
|
13
13
|
kind: z.ZodEnum<{
|
|
14
|
-
"unborn-head": "unborn-head";
|
|
15
14
|
"target-missing": "target-missing";
|
|
15
|
+
"unborn-head": "unborn-head";
|
|
16
16
|
"invalid-target": "invalid-target";
|
|
17
17
|
}>;
|
|
18
18
|
}, z.core.$strict>;
|
|
@@ -27,7 +27,7 @@ type BindOperationInput = Readonly<{
|
|
|
27
27
|
channel: GitDecodeChannel;
|
|
28
28
|
terms: BindData["terms"];
|
|
29
29
|
verification: VerificationDeclarationPreparation;
|
|
30
|
-
targetSelection
|
|
30
|
+
targetSelection: BindTargetSelection;
|
|
31
31
|
workspace: "worktree";
|
|
32
32
|
actor?: ActorId;
|
|
33
33
|
decorateOffer?: CompanionDecorator;
|
|
@@ -67,7 +67,7 @@ async function assembleBindInput(input, selection, seed, prepared) {
|
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
export async function bindOperation(input) {
|
|
70
|
-
let selection = input.targetSelection
|
|
70
|
+
let selection = input.targetSelection;
|
|
71
71
|
if (selection.kind === "explicit") {
|
|
72
72
|
const normalized = await normalizeTargetBranch(input.scope, selection.target);
|
|
73
73
|
if (normalized === null)
|
|
@@ -6,13 +6,13 @@ import { materializeIntegrationSnapshot, materializeJudgedConflict, planIntegrat
|
|
|
6
6
|
import { captureTender, dirtyTenderRefusal, materializeTenderSnapshot, prepareDeliveryCommitMetadata, } from "../git/tender.js";
|
|
7
7
|
import { checkoutDetachedSnapshot, recordConflictHandoff, retireConflictHandoff, workspaceMergeStatePresent, worktreePath, conflictRecovery, } from "../git/workspace.js";
|
|
8
8
|
import { observeContractsForAdmissionAt } from "../git/observe.js";
|
|
9
|
-
import { externalPreparation, privateStateSeatAttempt, runBoundedAttempts, sameWorktreeWitness, STALE_PRIVATE_STATE_PREPARATION, } from "./run.js";
|
|
9
|
+
import { externalPreparation, privateStateSeatAttempt, protocolSeatClose, runBoundedAttempts, sameWorktreeWitness, STALE_PRIVATE_STATE_PREPARATION, } from "./run.js";
|
|
10
10
|
import { contractState } from "../core/facts/observation.js";
|
|
11
11
|
import { decideDeliver } from "../core/verbs/deliver.js";
|
|
12
12
|
import { currentVerifiedAttestation } from "./intent.js";
|
|
13
13
|
import { admitDecidedOffer, mintAttempts } from "./attempt.js";
|
|
14
14
|
import { appointmentFor, readPlaceRegister } from "../workspace-place.js";
|
|
15
|
-
import {
|
|
15
|
+
import { recordedIntegrationSnapshots, timestamp } from "./operations.js";
|
|
16
16
|
export const deliverLeadingSchema = z
|
|
17
17
|
.object({
|
|
18
18
|
kind: z.enum(["admitted-now", "already-admitted"]),
|
|
@@ -418,7 +418,7 @@ async function deliverAttempt(input, attempt) {
|
|
|
418
418
|
if (assembled.kind === "stale")
|
|
419
419
|
return STALE_PRIVATE_STATE_PREPARATION;
|
|
420
420
|
return await decideAndAdmitDelivery(input, attempt, seat, observation, assembled);
|
|
421
|
-
},
|
|
421
|
+
}, protocolSeatClose);
|
|
422
422
|
}
|
|
423
423
|
function isIntegrationConflict(refusal) {
|
|
424
424
|
return refusal.kind === "integration-failed" && refusal.reason === "conflict";
|