@astrosheep/keiyaku 4.5.7 → 4.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/build/integrations/marketplace/plugins/keiyaku/.claude-plugin/plugin.json +1 -1
- package/build/integrations/marketplace/plugins/keiyaku/.codex-plugin/plugin.json +1 -1
- package/build/integrations/marketplace/plugins/keiyaku/opencode.js +3 -2
- package/build/integrations/marketplace/plugins/keiyaku/package.json +1 -1
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +12 -11
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +33 -12
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-babysit/SKILL.md +35 -96
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/SKILL.md +28 -49
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-task/SKILL.md +21 -15
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +148 -89
- package/build/src/akuma/abort.d.ts +2 -1
- package/build/src/akuma/abort.js +6 -23
- package/build/src/akuma/akuma-handle.js +4 -2
- package/build/src/akuma/akuma-observe.d.ts +2 -0
- package/build/src/akuma/akuma-observe.js +1 -0
- package/build/src/akuma/akuma-product.js +9 -7
- package/build/src/akuma/akuma.d.ts +392 -9
- package/build/src/akuma/akuma.js +31 -1
- package/build/src/akuma/allowed.d.ts +1 -1
- package/build/src/akuma/allowed.js +1 -0
- package/build/src/akuma/archetype.js +1 -1
- package/build/src/akuma/body.d.ts +8 -5
- package/build/src/akuma/body.js +12 -5
- package/build/src/akuma/call-request.d.ts +80 -0
- package/build/src/akuma/call-request.js +211 -0
- package/build/src/akuma/heart/facts.d.ts +16 -78
- package/build/src/akuma/heart/facts.js +11 -0
- package/build/src/akuma/heart/index.d.ts +3 -2
- package/build/src/akuma/heart/index.js +4 -1
- package/build/src/akuma/heart/request-authority.d.ts +5 -4
- package/build/src/akuma/heart/request-authority.js +20 -34
- package/build/src/akuma/heart/request-rows.js +12 -23
- package/build/src/akuma/heart/schema.d.ts +1 -1
- package/build/src/akuma/heart/schema.js +5 -13
- package/build/src/akuma/index.d.ts +1 -1
- package/build/src/akuma/index.js +1 -1
- package/build/src/akuma/projection-read.d.ts +1 -0
- package/build/src/akuma/projection-read.js +8 -1
- package/build/src/akuma/projection.d.ts +907 -137
- package/build/src/akuma/projection.js +193 -9
- package/build/src/akuma/provider.d.ts +30 -3
- package/build/src/akuma/provider.js +111 -0
- package/build/src/akuma/providers/acp/core.d.ts +2 -2
- package/build/src/akuma/providers/acp/core.js +13 -6
- package/build/src/akuma/providers/acp/index.js +5 -4
- package/build/src/akuma/providers/claude/events.d.ts +2 -2
- package/build/src/akuma/providers/claude/events.js +16 -3
- package/build/src/akuma/providers/claude/index.d.ts +3 -3
- package/build/src/akuma/providers/claude/index.js +16 -5
- package/build/src/akuma/providers/codex-app-server/events.d.ts +2 -2
- package/build/src/akuma/providers/codex-app-server/events.js +25 -4
- package/build/src/akuma/providers/codex-app-server/index.js +18 -6
- package/build/src/akuma/providers/grok-build/index.js +5 -4
- package/build/src/akuma/providers/opencode-sdk/index.js +66 -25
- package/build/src/akuma/providers/opencode-sdk/session.d.ts +3 -2
- package/build/src/akuma/providers/opencode-sdk/session.js +28 -11
- package/build/src/akuma/providers/pi/index.js +72 -58
- package/build/src/akuma/request-lifecycle.d.ts +4 -10
- package/build/src/akuma/request-lifecycle.js +7 -5
- package/build/src/akuma/request-rendezvous.d.ts +26 -0
- package/build/src/akuma/request-rendezvous.js +100 -0
- package/build/src/akuma/request-serve.d.ts +6 -66
- package/build/src/akuma/request-serve.js +83 -210
- package/build/src/akuma/request-wire.d.ts +109 -115
- package/build/src/akuma/request-wire.js +63 -318
- package/build/src/akuma/requests.d.ts +19 -47
- package/build/src/akuma/requests.js +51 -107
- package/build/src/akuma/turn-drive.d.ts +5 -3
- package/build/src/akuma/turn-drive.js +39 -11
- package/build/src/akuma-body.d.ts +7 -2
- package/build/src/akuma-body.js +68 -46
- package/build/src/body/amend.js +18 -19
- package/build/src/cli/accepted.d.ts +1 -1
- package/build/src/cli/accepted.js +2 -2
- package/build/src/cli/commands/akuma-invoke.d.ts +2 -0
- package/build/src/cli/commands/akuma-invoke.js +17 -9
- package/build/src/cli/commands/akuma.js +8 -8
- package/build/src/cli/commands/contract-invoke.d.ts +3 -2
- package/build/src/cli/commands/contract-invoke.js +42 -30
- package/build/src/cli/commands/contract.d.ts +16 -20
- package/build/src/cli/commands/contract.js +58 -25
- package/build/src/cli/commands/install.d.ts +2 -1
- package/build/src/cli/commands/install.js +3 -2
- package/build/src/cli/commands/task-invoke.d.ts +3 -0
- package/build/src/cli/commands/task-invoke.js +23 -140
- package/build/src/cli/commands/task.js +54 -20
- package/build/src/cli/invoke.js +39 -25
- package/build/src/cli/main.js +2 -1
- package/build/src/cli/parse.d.ts +2 -2
- package/build/src/cli/parse.js +56 -27
- package/build/src/cli/render/akuma-activity.d.ts +3 -0
- package/build/src/cli/render/akuma-activity.js +45 -29
- package/build/src/cli/render/akuma-tool.d.ts +5 -1
- package/build/src/cli/render/akuma.js +4 -8
- package/build/src/cli/render/audit.js +1 -1
- package/build/src/cli/render/catalog.js +80 -21
- package/build/src/cli/render/contract-observation.d.ts +2 -0
- package/build/src/cli/render/contract-observation.js +11 -0
- package/build/src/cli/render/contract.js +35 -62
- package/build/src/cli/render/kanshi-akuma.d.ts +8 -0
- package/build/src/cli/render/kanshi-akuma.js +132 -0
- package/build/src/cli/render/kanshi.js +131 -213
- package/build/src/cli/render/receipt.d.ts +1 -2
- package/build/src/cli/render/receipt.js +76 -26
- package/build/src/cli/render/refusal.js +2 -10
- package/build/src/cli/render/region.js +5 -2
- package/build/src/cli/render/settings.d.ts +1 -1
- package/build/src/cli/render/settings.js +27 -8
- package/build/src/cli/render/task.js +22 -5
- package/build/src/cli/render/terminal.d.ts +32 -1
- package/build/src/cli/render/terminal.js +77 -1
- package/build/src/cli/result.d.ts +3 -3
- package/build/src/cli/runtime.js +4 -2
- package/build/src/cli/selectors.d.ts +2 -1
- package/build/src/cli/selectors.js +4 -3
- package/build/src/cli/square-edge.js +120 -36
- package/build/src/cli/usage.js +2 -1
- package/build/src/contract-guidance.d.ts +5 -0
- package/build/src/contract-guidance.js +121 -0
- package/build/src/contract-worktree.d.ts +0 -1
- package/build/src/contract-worktree.js +32 -83
- package/build/src/coordination/sqlite-transaction-lock.d.ts +1 -0
- package/build/src/coordination/sqlite-transaction-lock.js +5 -0
- package/build/src/core/facts/codec.d.ts +2 -0
- package/build/src/core/facts/codec.js +4 -0
- package/build/src/core/verbs/placement.d.ts +6 -1
- package/build/src/core/verbs/placement.js +5 -3
- package/build/src/dispatch/index.d.ts +0 -2
- package/build/src/dispatch/index.js +54 -55
- package/build/src/git/admission.js +2 -2
- package/build/src/git/hooks.d.ts +9 -15
- package/build/src/git/hooks.js +23 -317
- package/build/src/git/nuke.d.ts +2 -1
- package/build/src/git/nuke.js +39 -21
- package/build/src/git/private-state-seat.d.ts +12 -0
- package/build/src/git/private-state-seat.js +39 -0
- package/build/src/git/process.d.ts +6 -0
- package/build/src/git/process.js +26 -11
- package/build/src/git/read-observation.js +29 -20
- package/build/src/git/reconcile.d.ts +13 -1
- package/build/src/git/reconcile.js +70 -11
- package/build/src/git/ref-migration.d.ts +22 -0
- package/build/src/git/ref-migration.js +55 -0
- package/build/src/git/repository.d.ts +10 -6
- package/build/src/git/repository.js +16 -8
- package/build/src/git/target-placement.d.ts +1 -0
- package/build/src/git/target-placement.js +5 -0
- package/build/src/git/tender.d.ts +1 -0
- package/build/src/git/terminal-reconcile.d.ts +1 -1
- package/build/src/git/terminal-reconcile.js +22 -20
- package/build/src/git/workspace.d.ts +14 -0
- package/build/src/git/workspace.js +44 -0
- package/build/src/kanshi/index.d.ts +1 -1
- package/build/src/kanshi/read.js +16 -16
- package/build/src/kanshi/report.d.ts +2 -2
- package/build/src/library/address.d.ts +9 -3
- package/build/src/library/address.js +3 -2
- package/build/src/library/akuma-creation.d.ts +4 -3
- package/build/src/library/akuma-creation.js +19 -13
- package/build/src/library/audit.d.ts +14 -6
- package/build/src/library/audit.js +13 -23
- package/build/src/library/catalog.d.ts +3 -1
- package/build/src/library/catalog.js +20 -6
- package/build/src/library/composition.d.ts +385 -0
- package/build/src/library/composition.js +28 -0
- package/build/src/library/configuration.js +8 -2
- package/build/src/library/continuation.js +66 -30
- package/build/src/library/contract-bind.js +10 -2
- package/build/src/library/contract-forwarding-reconciliation-result.d.ts +102 -0
- package/build/src/library/contract-forwarding-reconciliation-result.js +92 -0
- package/build/src/library/contract-forwarding-result.d.ts +4464 -0
- package/build/src/library/contract-forwarding-result.js +521 -0
- package/build/src/library/contract-forwarding.d.ts +71 -0
- package/build/src/library/contract-forwarding.js +114 -0
- package/build/src/library/contract-handle.d.ts +38 -0
- package/build/src/library/contract-handle.js +314 -0
- package/build/src/library/contract-operations.d.ts +214 -69
- package/build/src/library/contract-operations.js +189 -118
- package/build/src/library/contract-types.d.ts +7 -3
- package/build/src/library/contract.d.ts +21 -34
- package/build/src/library/contract.js +29 -287
- package/build/src/library/fleet-result.d.ts +1580 -0
- package/build/src/library/fleet-result.js +98 -0
- package/build/src/library/fleet.d.ts +112 -54
- package/build/src/library/fleet.js +211 -71
- package/build/src/library/input.d.ts +3 -1
- package/build/src/library/input.js +11 -1
- package/build/src/library/keiyaku.d.ts +388 -20
- package/build/src/library/keiyaku.js +13 -21
- package/build/src/library/mutation.d.ts +3 -3
- package/build/src/library/mutation.js +5 -9
- package/build/src/library/nuke.d.ts +1 -1
- package/build/src/library/nuke.js +4 -3
- package/build/src/library/reconcile.d.ts +4 -0
- package/build/src/library/reconcile.js +2 -0
- package/build/src/library/refusal.d.ts +0 -9
- package/build/src/library/refusal.js +0 -7
- package/build/src/protocol/amend.js +56 -50
- package/build/src/protocol/attempt.d.ts +2 -0
- package/build/src/protocol/attempt.js +8 -1
- package/build/src/protocol/completion.js +7 -0
- package/build/src/protocol/deliver.js +6 -2
- package/build/src/protocol/operations.d.ts +4 -1
- package/build/src/protocol/operations.js +5 -2
- package/build/src/protocol/placement.d.ts +1 -0
- package/build/src/protocol/placement.js +52 -38
- package/build/src/protocol/read/observation.d.ts +1 -4
- package/build/src/protocol/read/observation.js +2 -15
- package/build/src/protocol/reintegrate.js +62 -58
- package/build/src/protocol/review.js +5 -0
- package/build/src/protocol/run.js +17 -13
- package/build/src/runtime/proc/run.d.ts +9 -0
- package/build/src/runtime/proc/run.js +51 -4
- package/build/src/runtime/proc/termination.js +26 -22
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/build/src/settlement/holder.d.ts +2 -1
- package/build/src/settlement/holder.js +15 -4
- package/build/src/settlement/settle.js +99 -33
- package/build/src/task/board.d.ts +68 -27
- package/build/src/task/board.js +31 -1
- package/build/src/task/catalog.d.ts +4 -0
- package/build/src/task/catalog.js +23 -0
- package/build/src/task/compose-language.js +33 -7
- package/build/src/task/compose-parser.d.ts +1 -1
- package/build/src/task/compose-parser.js +1 -1
- package/build/src/task/compose.js +2 -0
- package/build/src/task/index.d.ts +12 -4
- package/build/src/task/index.js +97 -16
- package/build/src/task/mutation-result.d.ts +923 -0
- package/build/src/task/mutation-result.js +140 -0
- package/build/src/task/mutation.d.ts +552 -28
- package/build/src/task/mutation.js +304 -97
- package/build/src/task/operations.d.ts +1 -4
- package/build/src/task/operations.js +0 -6
- package/build/src/task/public.d.ts +2 -0
- package/build/src/task/public.js +1 -0
- package/build/src/workspace-place.d.ts +7 -2
- package/build/src/workspace-place.js +34 -24
- package/build/src/world.d.ts +1 -0
- package/build/src/world.js +11 -0
- package/package.json +8 -6
- package/build/src/akuma/request-execution.d.ts +0 -8
- package/build/src/akuma/request-execution.js +0 -98
|
@@ -1,57 +1,44 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { actorOption } from "./input.js";
|
|
2
|
+
import { worktreeHooksOption } from "./configuration.js";
|
|
3
|
+
import type { RegionOverlap } from "./region.js";
|
|
2
4
|
import { type ChangeId, type FactKind, type ContractId, type ContractState, type SnapshotId } from "../core/facts/types.js";
|
|
3
5
|
export { AuthorityCorruptionError } from "../core/facts/errors.js";
|
|
4
|
-
import { type PlacementStop, type
|
|
6
|
+
import { type PlacementStop, type VerificationStop, type DeliveryPreparationRefusal } from "../protocol/operations.js";
|
|
5
7
|
import type { ContractBoard, ContractDisposition, ContractGateCurrent, ContractGateReport, ContractObservation, ContractPhase, ContractRow, AfterEndpointObservation, ContractAfterEdge, ContractDependent, ContractWorkspaceObservation } from "../protocol/read/status.js";
|
|
6
8
|
import type { AuditReport } from "../protocol/audit.js";
|
|
7
9
|
import type { IntegrationConflictMaterialized, VerificationReuse } from "../protocol/deliver.js";
|
|
8
10
|
import type { TaskId } from "../task/identity.js";
|
|
9
|
-
import { type
|
|
10
|
-
import {
|
|
11
|
+
import { type ExecutionContext } from "../akuma/requests.js";
|
|
12
|
+
import type { AuditInput } from "./audit.js";
|
|
11
13
|
import { Delivery } from "./delivery.js";
|
|
12
14
|
import { type ContinuationReport } from "./continuation.js";
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
import {
|
|
15
|
+
import type { MutationResult } from "./mutation.js";
|
|
16
|
+
export { KeiyakuHandle } from "./contract-handle.js";
|
|
17
|
+
import { KeiyakuHandle } from "./contract-handle.js";
|
|
18
|
+
import type { AbandonInput, AmendInput, AmendResult, ArcInput, BindInput, BindResult, ContractListInput, ContractObservationInput, DeliverInput, ForkBindInput, KeiyakuOfInput, LocalContractComposition, MarkdownBindInput, ReconcileReport, ReviewInput, ContractHistory, ContractHistoryEvent, Fact, Lag, TopologyEffect } from "./contract-types.js";
|
|
19
|
+
import type { AttestationVerdict as OperationAttestationVerdict, Review as OperationReview } from "./contract-operations.js";
|
|
16
20
|
import { KeiyakuRetry, type KeiyakuRefusal, type KeiyakuRetryReason } from "./refusal.js";
|
|
17
21
|
export { KeiyakuRefused } from "./refusal.js";
|
|
18
22
|
export { KeiyakuRetry, type KeiyakuRefusal, type KeiyakuRetryReason };
|
|
19
|
-
export { executeForwardedDeliver, executeForwardedReview } from "./contract-operations.js";
|
|
20
23
|
export { gatesFrom, requireBranchesToBeUpToDateFrom, SettingsError } from "./configuration.js";
|
|
21
24
|
export type { Gate, GatesFromInput, HookCommand, RequireBranchesToBeUpToDateFromInput, WorktreeHooks, } from "./configuration.js";
|
|
22
|
-
export type { AbandonInput, AmendInput, AmendResult, ArcInput, AuditInput, AuditReport, ChangeId, ContinuationReport, ContractBoard, ContractDisposition, ContractGateCurrent, ContractGateReport, ContractAfterEdge, ContractId, ContractHistory, ContractHistoryEvent, ContractDependent, ContractObservation, ContractPhase, ContractRow, ContractState, ContractWorkspaceObservation, BindInput, BindResult, ContractListInput, ContractObservationInput, DeliverInput, ForkBindInput, KeiyakuOfInput, MarkdownBindInput, ReconcileReport, ReviewInput, DeliveryPreparationRefusal, Fact, FactKind, IntegrationConflictMaterialized, Lag, MutationResult, PlacementStop, RegionOverlap, SnapshotId, TaskId, TopologyEffect, VerificationReuse, VerificationStop, };
|
|
25
|
+
export type { AbandonInput, AmendInput, AmendResult, ArcInput, AuditInput, AuditReport, ChangeId, ContinuationReport, ContractBoard, ContractDisposition, ContractGateCurrent, ContractGateReport, ContractAfterEdge, ContractId, ContractHistory, ContractHistoryEvent, ContractDependent, ContractObservation, ContractPhase, ContractRow, ContractState, ContractWorkspaceObservation, BindInput, BindResult, ContractListInput, ContractObservationInput, DeliverInput, ForkBindInput, KeiyakuOfInput, MarkdownBindInput, ReconcileReport, ReviewInput, DeliveryPreparationRefusal, Fact, FactKind, IntegrationConflictMaterialized, Lag, LocalContractComposition, MutationResult, PlacementStop, RegionOverlap, SnapshotId, TaskId, TopologyEffect, VerificationReuse, VerificationStop, };
|
|
23
26
|
export type { AfterEndpointObservation };
|
|
24
27
|
export type ActorId = string;
|
|
25
28
|
export type AttestationVerdict = OperationAttestationVerdict;
|
|
26
29
|
export type Review = OperationReview;
|
|
27
30
|
export { Delivery };
|
|
28
31
|
export type { SettlementAction, SettlementLag, SettlementReport } from "../settlement/settle.js";
|
|
29
|
-
export declare class KeiyakuHandle {
|
|
30
|
-
private readonly id;
|
|
31
|
-
private readonly scope;
|
|
32
|
-
constructor(id: ContractId, scope: RepositoryScope);
|
|
33
|
-
state(): Promise<ContractState>;
|
|
34
|
-
history(): Promise<ContractHistory>;
|
|
35
|
-
guidance(): Promise<string>;
|
|
36
|
-
delivery(): Promise<Delivery | null>;
|
|
37
|
-
amend(input: AmendInput): Promise<AmendResult>;
|
|
38
|
-
deliver(input?: DeliverInput): Promise<MutationResult<Delivery> | IntegrationConflictMaterialized>;
|
|
39
|
-
review(input: ReviewInput): Promise<MutationResult<Review>>;
|
|
40
|
-
abandon(input?: AbandonInput): Promise<MutationResult<void>>;
|
|
41
|
-
arc(input: ArcInput): Promise<MutationResult<void>>;
|
|
42
|
-
audit(input?: AuditInput): Promise<MutationResult<AuditReport>>;
|
|
43
|
-
reconcile(input?: ReconcileInput): Promise<ReconcileReport>;
|
|
44
|
-
private deliveryHandle;
|
|
45
|
-
}
|
|
46
|
-
/** Internal package composition capability; not exported from the package root. */
|
|
47
|
-
export declare function seatForKeiyaku(value: unknown): Readonly<{
|
|
48
|
-
id: ContractId;
|
|
49
|
-
scope: RepositoryScope;
|
|
50
|
-
}>;
|
|
51
32
|
export type Keiyaku = KeiyakuHandle;
|
|
52
|
-
export
|
|
33
|
+
export type LocalContractCompositionCapture = Readonly<{
|
|
34
|
+
actor?: NonNullable<ReturnType<typeof actorOption>["actor"]>;
|
|
35
|
+
hooks: ReturnType<typeof worktreeHooksOption>;
|
|
36
|
+
requireBranchesToBeUpToDate: boolean;
|
|
37
|
+
}>;
|
|
38
|
+
export declare function captureLocalContractComposition(input?: LocalContractComposition): LocalContractCompositionCapture;
|
|
39
|
+
export declare function keiyakuOf(input: KeiyakuOfInput, execution?: ExecutionContext, composition?: LocalContractCompositionCapture): Keiyaku;
|
|
53
40
|
export declare function listKeiyaku(input: ContractListInput): Promise<ContractBoard>;
|
|
54
41
|
export declare function observeKeiyaku(input: ContractObservationInput): Promise<ContractObservation>;
|
|
55
|
-
export declare function bindKeiyaku(input: BindInput): Promise<BindResult>;
|
|
42
|
+
export declare function bindKeiyaku(input: BindInput, execution?: ExecutionContext, composition?: LocalContractCompositionCapture): Promise<BindResult>;
|
|
56
43
|
/** Internal CLI composition; not exported from the package root. */
|
|
57
|
-
export declare function bindFromCli(input: BindInput): Promise<BindResult>;
|
|
44
|
+
export declare function bindFromCli(input: BindInput, execution?: ExecutionContext): Promise<BindResult>;
|
|
@@ -1,299 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { decodeArcDocument } from "../body/arc.js";
|
|
4
|
-
import { decodeContractDocument } from "../body/decode.js";
|
|
5
|
-
import { renderContractGuidance } from "../contract-worktree.js";
|
|
6
|
-
import { actorOption, contractTerms, documentDerivation, normalizedGates, normalizedList, optionalBoolean, optionalNonblank, optionalSignal, requireInput, requireMarkdown, } from "./input.js";
|
|
7
|
-
import { observeChangedRegion } from "./region.js";
|
|
1
|
+
// Contract's static facade deliberately depends only on construction and observation.
|
|
2
|
+
import { actorOption, optionalBoolean, requireInput } from "./input.js";
|
|
8
3
|
import { worktreeHooksOption } from "./configuration.js";
|
|
9
4
|
import { contractId, } from "../core/facts/types.js";
|
|
10
5
|
export { AuthorityCorruptionError } from "../core/facts/errors.js";
|
|
11
|
-
import { contractObservationOperation, contractsOperation,
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { mintSnapshotId } from "../git/identity.js";
|
|
17
|
-
import { observeContractsForAdmissionInObservationAt } from "../git/observe.js";
|
|
18
|
-
import { withGitDecodeChannel, withGitReadObservation } from "../git/read-observation.js";
|
|
19
|
-
import { releaseTaskHolder, releaseTaskHolderWithFence, taskHolderObservationSelection } from "../settlement/holder.js";
|
|
20
|
-
import { reconcileInput, scopeForRepo } from "./repo.js";
|
|
21
|
-
import { injectedBodyRequests, requestBodyDeliver, requestBodyReview } from "../akuma/requests.js";
|
|
22
|
-
import { auditContract } from "./audit.js";
|
|
23
|
-
import { Delivery, deliveryHandle } from "./delivery.js";
|
|
24
|
-
import { completionInput, completeHolderMutation, completeMutation } from "./mutation.js";
|
|
25
|
-
import { completeReconcile } from "./reconcile.js";
|
|
6
|
+
import { contractObservationOperation, contractsOperation, } from "../protocol/operations.js";
|
|
7
|
+
import { withGitDecodeChannel } from "../git/read-observation.js";
|
|
8
|
+
import { scopeForRepo } from "./repo.js";
|
|
9
|
+
import { localExecutionContext } from "../akuma/requests.js";
|
|
10
|
+
import { Delivery } from "./delivery.js";
|
|
26
11
|
import { bindFromCli as bindFromCliImplementation, bindKeiyaku as bindKeiyakuImplementation } from "./contract-bind.js";
|
|
27
|
-
|
|
28
|
-
import {
|
|
12
|
+
export { KeiyakuHandle } from "./contract-handle.js";
|
|
13
|
+
import { KeiyakuHandle } from "./contract-handle.js";
|
|
14
|
+
import { KeiyakuRetry } from "./refusal.js";
|
|
29
15
|
export { KeiyakuRefused } from "./refusal.js";
|
|
30
16
|
export { KeiyakuRetry };
|
|
31
|
-
export { executeForwardedDeliver, executeForwardedReview } from "./contract-operations.js";
|
|
32
17
|
export { gatesFrom, requireBranchesToBeUpToDateFrom, SettingsError } from "./configuration.js";
|
|
33
18
|
export { Delivery };
|
|
34
|
-
export
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
contractId: this.id,
|
|
47
|
-
}));
|
|
48
|
-
}
|
|
49
|
-
async history() {
|
|
50
|
-
return withGitDecodeChannel(this.scope, (channel) => withGitReadObservation(this.scope, channel, async (observation) => {
|
|
51
|
-
const [journals, dispatches] = await Promise.all([
|
|
52
|
-
observeContractsForAdmissionInObservationAt(observation, [this.id]),
|
|
53
|
-
readDispatchesAt(observation),
|
|
54
|
-
]);
|
|
55
|
-
const record = journals.journals.get(this.id);
|
|
56
|
-
if (record === undefined)
|
|
57
|
-
throw new Error(`missing requested contract observation: ${this.id}`);
|
|
58
|
-
if (record.state === null)
|
|
59
|
-
throw new KeiyakuRefused({ kind: "contract-missing", contractId: this.id });
|
|
60
|
-
const commit = observation.snapshot.commit;
|
|
61
|
-
if (commit === null)
|
|
62
|
-
throw new Error("contract history requires a keiyaku-state snapshot");
|
|
63
|
-
const recordedAt = (event) => event.source === "journal" ? event.fact.at : event.dispatch.dispatchedAt;
|
|
64
|
-
const events = [
|
|
65
|
-
...record.entries.map((fact) => ({ source: "journal", fact })),
|
|
66
|
-
...dispatches
|
|
67
|
-
.filter((dispatch) => dispatch.contractId === this.id)
|
|
68
|
-
.map((dispatch) => ({ source: "dispatch", dispatch })),
|
|
69
|
-
].sort((left, right) => {
|
|
70
|
-
const leftAt = recordedAt(left);
|
|
71
|
-
const rightAt = recordedAt(right);
|
|
72
|
-
if (leftAt !== rightAt)
|
|
73
|
-
return leftAt < rightAt ? -1 : 1;
|
|
74
|
-
if (left.source !== right.source)
|
|
75
|
-
return left.source === "journal" ? -1 : 1;
|
|
76
|
-
return 0;
|
|
77
|
-
});
|
|
78
|
-
return { id: this.id, state: mintSnapshotId(commit), events };
|
|
79
|
-
}));
|
|
80
|
-
}
|
|
81
|
-
async guidance() {
|
|
82
|
-
return withGitDecodeChannel(this.scope, async (channel) => {
|
|
83
|
-
const observed = await contractObservationOperation({ scope: this.scope, channel, contractId: this.id });
|
|
84
|
-
if (observed.kind === "missing")
|
|
85
|
-
throw new KeiyakuRefused({ kind: "contract-missing", contractId: this.id });
|
|
86
|
-
return renderContractGuidance(await stateOperation({ scope: this.scope, channel, contractId: this.id }));
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
async delivery() {
|
|
90
|
-
const delivery = await withGitDecodeChannel(this.scope, (channel) => deliveryOperation({
|
|
91
|
-
scope: this.scope,
|
|
92
|
-
channel,
|
|
93
|
-
contractId: this.id,
|
|
94
|
-
}));
|
|
95
|
-
return delivery === null ? null : this.deliveryHandle(delivery);
|
|
96
|
-
}
|
|
97
|
-
async amend(input) {
|
|
98
|
-
const values = requireInput(input, "amend input");
|
|
99
|
-
const hooks = worktreeHooksOption(values.hooks);
|
|
100
|
-
const markdown = values.markdown === undefined ? undefined : requireMarkdown(values.markdown);
|
|
101
|
-
const actor = actorOption(values.actor);
|
|
102
|
-
const gates = values.gates === undefined ? undefined : normalizedGates(values.gates);
|
|
103
|
-
const prerequisites = values.after === undefined ? undefined : normalizedList(values.after, "after", contractId);
|
|
104
|
-
if (markdown === undefined && gates === undefined && prerequisites === undefined) {
|
|
105
|
-
throw new TypeError("amend requires markdown, after, or gates");
|
|
106
|
-
}
|
|
107
|
-
const amendment = await withGitDecodeChannel(this.scope, async (channel) => {
|
|
108
|
-
let changedSections;
|
|
109
|
-
const accepted = requireAccepted(await amendOperation({
|
|
110
|
-
scope: this.scope,
|
|
111
|
-
channel,
|
|
112
|
-
contractId: this.id,
|
|
113
|
-
...actor,
|
|
114
|
-
deriveAmendment: (source) => {
|
|
115
|
-
const amendment = markdown === undefined
|
|
116
|
-
? undefined
|
|
117
|
-
: applyAmendDocument(markdown, decodeContractDocument(source.document.bytes));
|
|
118
|
-
changedSections = amendment?.changedSections;
|
|
119
|
-
const document = amendment === undefined
|
|
120
|
-
? decodeContractDocument(source.document.bytes)
|
|
121
|
-
: decodeContractDocument(amendment.document);
|
|
122
|
-
const terms = markdown === undefined
|
|
123
|
-
? {
|
|
124
|
-
document: source.document,
|
|
125
|
-
segments: source.segments,
|
|
126
|
-
gates: gates ?? source.gates,
|
|
127
|
-
after: prerequisites ?? source.after,
|
|
128
|
-
}
|
|
129
|
-
: contractTerms(document, gates ?? source.gates, prerequisites ?? source.after);
|
|
130
|
-
return {
|
|
131
|
-
terms,
|
|
132
|
-
verification: documentDerivation(document, terms.gates, this.id).verification,
|
|
133
|
-
};
|
|
134
|
-
},
|
|
135
|
-
}));
|
|
136
|
-
const completed = await completeMutation({
|
|
137
|
-
...completionInput(this.scope, channel, this.id, () => undefined, hooks),
|
|
138
|
-
accepted,
|
|
139
|
-
});
|
|
140
|
-
return {
|
|
141
|
-
completed,
|
|
142
|
-
document: decodeContractDocument(accepted.value.terms.document.bytes),
|
|
143
|
-
changedSections,
|
|
144
|
-
documentDiff: documentDiff("before", "after", accepted.value.source.document.bytes, accepted.value.terms.document.bytes),
|
|
145
|
-
};
|
|
146
|
-
});
|
|
147
|
-
const regionObservation = await observeChangedRegion(this.scope, this.id, amendment.changedSections, amendment.document.region);
|
|
148
|
-
return {
|
|
149
|
-
...amendment.completed,
|
|
150
|
-
documentDiff: amendment.documentDiff,
|
|
151
|
-
...regionObservation,
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
async deliver(input) {
|
|
155
|
-
const values = input === undefined ? undefined : requireInput(input, "deliver input");
|
|
156
|
-
const hooks = worktreeHooksOption(values?.hooks);
|
|
157
|
-
const message = optionalNonblank(values?.message, "deliver message");
|
|
158
|
-
const requireBranchesToBeUpToDate = optionalBoolean(values?.requireBranchesToBeUpToDate, "requireBranchesToBeUpToDate") ?? false;
|
|
159
|
-
const includeDirty = optionalBoolean(values?.includeDirty, "includeDirty") ?? false;
|
|
160
|
-
const materializeConflict = optionalBoolean(values?.materializeConflict, "materializeConflict") ?? false;
|
|
161
|
-
const actor = actorOption(values?.actor);
|
|
162
|
-
const signal = optionalSignal(values?.signal);
|
|
163
|
-
const requests = injectedBodyRequests();
|
|
164
|
-
const result = requests === null
|
|
165
|
-
? await executeLocalDelivery({
|
|
166
|
-
scope: this.scope,
|
|
167
|
-
contractId: this.id,
|
|
168
|
-
...actor,
|
|
169
|
-
...(message === undefined ? {} : { message }),
|
|
170
|
-
requireBranchesToBeUpToDate,
|
|
171
|
-
includeDirty,
|
|
172
|
-
materializeConflict,
|
|
173
|
-
...(signal === undefined ? {} : { signal }),
|
|
174
|
-
hooks,
|
|
175
|
-
})
|
|
176
|
-
: requireForwarded(forwardedReceipt(await requestBodyDeliver({
|
|
177
|
-
directory: requests,
|
|
178
|
-
repoRoot: this.scope.primaryWorktree,
|
|
179
|
-
contractId: this.id,
|
|
180
|
-
...(message === undefined ? {} : { message }),
|
|
181
|
-
includeDirty,
|
|
182
|
-
materializeConflict,
|
|
183
|
-
...(signal === undefined ? {} : { signal }),
|
|
184
|
-
}), "deliver"));
|
|
185
|
-
return "facts" in result ? { ...result, value: this.deliveryHandle(result.value) } : result;
|
|
186
|
-
}
|
|
187
|
-
async review(input) {
|
|
188
|
-
const values = requireInput(input, "review input");
|
|
189
|
-
const hooks = worktreeHooksOption(values.hooks);
|
|
190
|
-
const verdict = values.verdict;
|
|
191
|
-
if (verdict !== "satisfied" && verdict !== "unsatisfied") {
|
|
192
|
-
throw new TypeError("verdict must be satisfied or unsatisfied");
|
|
193
|
-
}
|
|
194
|
-
const summary = optionalNonblank(values.summary, "review summary");
|
|
195
|
-
const actor = actorOption(values.actor);
|
|
196
|
-
const requests = injectedBodyRequests();
|
|
197
|
-
if (requests !== null) {
|
|
198
|
-
return requireForwarded(forwardedReceipt(await requestBodyReview({
|
|
199
|
-
directory: requests,
|
|
200
|
-
repoRoot: this.scope.primaryWorktree,
|
|
201
|
-
contractId: this.id,
|
|
202
|
-
verdict,
|
|
203
|
-
...(summary === undefined ? {} : { summary }),
|
|
204
|
-
}), "review"));
|
|
205
|
-
}
|
|
206
|
-
return await executeLocalReview({
|
|
207
|
-
scope: this.scope,
|
|
208
|
-
contractId: this.id,
|
|
209
|
-
...actor,
|
|
210
|
-
verdict,
|
|
211
|
-
...(summary === undefined ? {} : { summary }),
|
|
212
|
-
hooks,
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
async abandon(input) {
|
|
216
|
-
const values = input === undefined ? undefined : requireInput(input, "abandon input");
|
|
217
|
-
const hooks = worktreeHooksOption(values?.hooks);
|
|
218
|
-
const note = optionalNonblank(values?.note, "abandon note");
|
|
219
|
-
return withGitDecodeChannel(this.scope, async (channel) => {
|
|
220
|
-
const admission = await releaseTaskHolderWithFence(this.scope, channel, this.id, () => abandonOperation({
|
|
221
|
-
scope: this.scope,
|
|
222
|
-
channel,
|
|
223
|
-
contractId: this.id,
|
|
224
|
-
...actorOption(values?.actor),
|
|
225
|
-
...(note === undefined ? {} : { note }),
|
|
226
|
-
observationSelection: taskHolderObservationSelection(),
|
|
227
|
-
decorateOffer: async ({ observation, contractId: owner }) => {
|
|
228
|
-
const companion = await releaseTaskHolder(channel, observation, owner);
|
|
229
|
-
return companion === null ? [] : [companion];
|
|
230
|
-
},
|
|
231
|
-
}));
|
|
232
|
-
return completeHolderMutation({
|
|
233
|
-
completion: completionInput(this.scope, channel, this.id, () => undefined, hooks),
|
|
234
|
-
admission,
|
|
235
|
-
requireAccepted,
|
|
236
|
-
});
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
async arc(input) {
|
|
240
|
-
const values = requireInput(input, "arc input");
|
|
241
|
-
const hooks = worktreeHooksOption(values.hooks);
|
|
242
|
-
const chapter = decodeArcDocument(requireMarkdown(values.markdown));
|
|
243
|
-
return withGitDecodeChannel(this.scope, async (channel) => {
|
|
244
|
-
const accepted = requireAccepted(await arcOperation({
|
|
245
|
-
scope: this.scope,
|
|
246
|
-
channel,
|
|
247
|
-
contractId: this.id,
|
|
248
|
-
...actorOption(values.actor),
|
|
249
|
-
chapter,
|
|
250
|
-
}));
|
|
251
|
-
return completeMutation({
|
|
252
|
-
...completionInput(this.scope, channel, this.id, () => undefined, hooks),
|
|
253
|
-
accepted,
|
|
254
|
-
});
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
async audit(input) {
|
|
258
|
-
return auditContract({
|
|
259
|
-
scope: this.scope,
|
|
260
|
-
contractId: this.id,
|
|
261
|
-
...(input === undefined ? {} : { input }),
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
async reconcile(input) {
|
|
265
|
-
const options = reconcileInput(input);
|
|
266
|
-
return withGitDecodeChannel(this.scope, (channel) => completeReconcile({
|
|
267
|
-
scope: this.scope,
|
|
268
|
-
channel,
|
|
269
|
-
contractId: this.id,
|
|
270
|
-
...options,
|
|
271
|
-
}));
|
|
272
|
-
}
|
|
273
|
-
deliveryHandle(delivery) {
|
|
274
|
-
return deliveryHandle(delivery, () => deliveryDiffOperation({
|
|
275
|
-
scope: this.scope,
|
|
276
|
-
integrationPredecessor: delivery.integration.predecessor,
|
|
277
|
-
integrationSnapshot: delivery.integration.snapshot,
|
|
278
|
-
}));
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
const KEIYAKU_SEATS = new WeakMap();
|
|
282
|
-
/** Internal package composition capability; not exported from the package root. */
|
|
283
|
-
export function seatForKeiyaku(value) {
|
|
284
|
-
if (!(value instanceof KeiyakuHandle))
|
|
285
|
-
throw new TypeError("contract must be a Keiyaku");
|
|
286
|
-
const seat = KEIYAKU_SEATS.get(value);
|
|
287
|
-
if (seat === undefined)
|
|
288
|
-
throw new TypeError("contract must be a Keiyaku");
|
|
289
|
-
return seat;
|
|
19
|
+
export function captureLocalContractComposition(input) {
|
|
20
|
+
const values = requireInput(input ?? {}, "Keiyaku.withLocal input", [
|
|
21
|
+
"actor",
|
|
22
|
+
"hooks",
|
|
23
|
+
"requireBranchesToBeUpToDate",
|
|
24
|
+
]);
|
|
25
|
+
const actor = actorOption(values.actor).actor;
|
|
26
|
+
return Object.freeze({
|
|
27
|
+
...(actor === undefined ? {} : { actor }),
|
|
28
|
+
hooks: worktreeHooksOption(values.hooks),
|
|
29
|
+
requireBranchesToBeUpToDate: optionalBoolean(values.requireBranchesToBeUpToDate, "Keiyaku.withLocal requireBranchesToBeUpToDate") ?? false,
|
|
30
|
+
});
|
|
290
31
|
}
|
|
291
|
-
export function keiyakuOf(input) {
|
|
32
|
+
export function keiyakuOf(input, execution = localExecutionContext(), composition = captureLocalContractComposition()) {
|
|
292
33
|
const values = requireInput(input, "Keiyaku.of input");
|
|
293
34
|
const scope = scopeForRepo(values.repo);
|
|
294
35
|
if (typeof values.id !== "string")
|
|
295
36
|
throw new TypeError("contract ID must be a string");
|
|
296
|
-
return new KeiyakuHandle(contractId(values.id), scope);
|
|
37
|
+
return new KeiyakuHandle(contractId(values.id), scope, execution, composition);
|
|
297
38
|
}
|
|
298
39
|
export async function listKeiyaku(input) {
|
|
299
40
|
const values = requireInput(input, "Keiyaku.list input");
|
|
@@ -320,10 +61,11 @@ export async function observeKeiyaku(input) {
|
|
|
320
61
|
}
|
|
321
62
|
return withGitDecodeChannel(scope, (channel) => contractObservationOperation({ scope, channel, contractId: id }));
|
|
322
63
|
}
|
|
323
|
-
export async function bindKeiyaku(input) {
|
|
324
|
-
return bindKeiyakuImplementation(input, (id, scope) => new KeiyakuHandle(id, scope));
|
|
64
|
+
export async function bindKeiyaku(input, execution = localExecutionContext(), composition = captureLocalContractComposition()) {
|
|
65
|
+
return bindKeiyakuImplementation(input, (id, scope) => new KeiyakuHandle(id, scope, execution, composition));
|
|
325
66
|
}
|
|
326
67
|
/** Internal CLI composition; not exported from the package root. */
|
|
327
|
-
export async function bindFromCli(input) {
|
|
328
|
-
|
|
68
|
+
export async function bindFromCli(input, execution = localExecutionContext()) {
|
|
69
|
+
const composition = captureLocalContractComposition();
|
|
70
|
+
return bindFromCliImplementation(input, (id, scope) => new KeiyakuHandle(id, scope, execution, composition));
|
|
329
71
|
}
|