@astrosheep/keiyaku 4.5.8 → 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.
Files changed (79) hide show
  1. package/README.md +1 -1
  2. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +2 -2
  3. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +15 -15
  4. package/build/src/akuma/akuma.d.ts +24 -4
  5. package/build/src/akuma/archetype.js +1 -1
  6. package/build/src/akuma/body.d.ts +2 -1
  7. package/build/src/akuma/body.js +7 -2
  8. package/build/src/akuma/call-request.js +1 -1
  9. package/build/src/akuma/heart/facts.d.ts +10 -0
  10. package/build/src/akuma/heart/facts.js +11 -0
  11. package/build/src/akuma/heart/index.d.ts +3 -2
  12. package/build/src/akuma/heart/index.js +4 -1
  13. package/build/src/akuma/projection.d.ts +63 -12
  14. package/build/src/akuma/projection.js +5 -11
  15. package/build/src/akuma/provider.js +8 -1
  16. package/build/src/akuma/providers/claude/events.d.ts +2 -2
  17. package/build/src/akuma/providers/claude/events.js +16 -3
  18. package/build/src/akuma/providers/codex-app-server/events.d.ts +2 -2
  19. package/build/src/akuma/providers/codex-app-server/events.js +25 -4
  20. package/build/src/akuma/providers/pi/index.js +55 -69
  21. package/build/src/akuma/request-lifecycle.d.ts +1 -1
  22. package/build/src/akuma/request-lifecycle.js +3 -1
  23. package/build/src/akuma/request-serve.d.ts +1 -1
  24. package/build/src/akuma/request-serve.js +4 -4
  25. package/build/src/akuma/turn-drive.js +8 -2
  26. package/build/src/body/amend.js +18 -19
  27. package/build/src/cli/commands/akuma.js +2 -2
  28. package/build/src/cli/commands/contract-invoke.js +27 -22
  29. package/build/src/cli/commands/contract.d.ts +6 -10
  30. package/build/src/cli/commands/contract.js +29 -11
  31. package/build/src/cli/commands/install.d.ts +1 -0
  32. package/build/src/cli/commands/install.js +2 -1
  33. package/build/src/cli/parse.js +23 -9
  34. package/build/src/cli/render/akuma-activity.d.ts +1 -1
  35. package/build/src/cli/render/akuma-activity.js +4 -3
  36. package/build/src/cli/render/akuma.js +1 -1
  37. package/build/src/cli/render/catalog.js +1 -1
  38. package/build/src/cli/render/contract.js +13 -0
  39. package/build/src/cli/render/kanshi-akuma.js +26 -5
  40. package/build/src/cli/render/kanshi.js +26 -3
  41. package/build/src/cli/render/terminal.d.ts +4 -1
  42. package/build/src/cli/render/terminal.js +12 -1
  43. package/build/src/cli/runtime.js +1 -1
  44. package/build/src/git/nuke.js +3 -3
  45. package/build/src/git/process.js +7 -4
  46. package/build/src/git/read-observation.js +1 -1
  47. package/build/src/git/reconcile.d.ts +2 -1
  48. package/build/src/git/reconcile.js +6 -0
  49. package/build/src/git/ref-migration.d.ts +22 -0
  50. package/build/src/git/ref-migration.js +55 -0
  51. package/build/src/git/repository.d.ts +4 -4
  52. package/build/src/git/repository.js +8 -8
  53. package/build/src/library/audit.d.ts +13 -5
  54. package/build/src/library/audit.js +9 -21
  55. package/build/src/library/composition.d.ts +41 -27
  56. package/build/src/library/composition.js +3 -3
  57. package/build/src/library/contract-forwarding-reconciliation-result.d.ts +17 -11
  58. package/build/src/library/contract-forwarding-reconciliation-result.js +11 -2
  59. package/build/src/library/contract-forwarding-result.d.ts +1628 -3887
  60. package/build/src/library/contract-forwarding-result.js +1 -1
  61. package/build/src/library/contract-forwarding.d.ts +12 -13
  62. package/build/src/library/contract-forwarding.js +17 -28
  63. package/build/src/library/contract-handle.d.ts +3 -1
  64. package/build/src/library/contract-handle.js +23 -22
  65. package/build/src/library/contract-operations.d.ts +61 -893
  66. package/build/src/library/contract-operations.js +2 -3
  67. package/build/src/library/contract-types.d.ts +7 -3
  68. package/build/src/library/contract.d.ts +12 -4
  69. package/build/src/library/contract.js +21 -6
  70. package/build/src/library/fleet-result.d.ts +138 -12
  71. package/build/src/library/fleet-result.js +2 -0
  72. package/build/src/library/input.d.ts +1 -1
  73. package/build/src/library/input.js +7 -1
  74. package/build/src/library/keiyaku.d.ts +44 -27
  75. package/build/src/library/keiyaku.js +6 -1
  76. package/build/src/runtime/proc/run.d.ts +1 -0
  77. package/build/src/runtime/proc/run.js +25 -5
  78. package/build/src/runtime/proc/windows-launch.exe +0 -0
  79. package/package.json +1 -1
@@ -1,19 +1,27 @@
1
- import type { ContractId } from "../core/facts/types.js";
1
+ import type { ActorId, ContractId } from "../core/facts/types.js";
2
2
  import { type AuditReport } from "../protocol/audit.js";
3
3
  import { type RepositoryScope } from "../protocol/operations.js";
4
4
  import { type WorktreeHooks } from "./configuration.js";
5
5
  import { type MutationResult } from "./mutation.js";
6
6
  export type AuditInput = Readonly<{
7
- actor?: string;
8
- hooks?: WorktreeHooks;
9
7
  includeDirty?: boolean;
10
8
  showDiff?: boolean;
11
- requireBranchesToBeUpToDate?: boolean;
12
9
  signal?: AbortSignal;
13
10
  }>;
11
+ export type AuditOptions = Readonly<{
12
+ includeDirty: boolean;
13
+ showDiff: boolean;
14
+ signal?: AbortSignal;
15
+ }>;
16
+ export type AuditComposition = Readonly<{
17
+ actor?: ActorId;
18
+ hooks?: WorktreeHooks;
19
+ requireBranchesToBeUpToDate?: boolean;
20
+ }>;
14
21
  /** Normalize public audit input and project the protocol audit operation. */
15
22
  export declare function auditContract(input: Readonly<{
16
23
  scope: RepositoryScope;
17
24
  contractId: ContractId;
18
- input?: AuditInput;
25
+ input: AuditOptions;
26
+ composition?: AuditComposition;
19
27
  }>): Promise<MutationResult<AuditReport>>;
@@ -3,36 +3,24 @@ import { withGitDecodeChannel } from "../git/read-observation.js";
3
3
  import { auditOperation } from "../protocol/audit.js";
4
4
  import { withScopeAbortSignal } from "../protocol/operations.js";
5
5
  import { worktreeHooksOption } from "./configuration.js";
6
- import { actorOption, documentDerivation, optionalBoolean, optionalSignal, requireInput } from "./input.js";
6
+ import { documentDerivation } from "./input.js";
7
7
  import { completeMutation } from "./mutation.js";
8
8
  import { requireAccepted } from "./refusal.js";
9
- function normalizeAuditInput(input) {
10
- const values = input === undefined ? undefined : requireInput(input, "audit input");
11
- const signal = optionalSignal(values?.signal);
12
- return {
13
- hooks: worktreeHooksOption(values?.hooks),
14
- ...actorOption(values?.actor),
15
- includeDirty: optionalBoolean(values?.includeDirty, "includeDirty") ?? false,
16
- showDiff: optionalBoolean(values?.showDiff, "showDiff") ?? false,
17
- requireBranchesToBeUpToDate: optionalBoolean(values?.requireBranchesToBeUpToDate, "requireBranchesToBeUpToDate") ?? false,
18
- ...(signal === undefined ? {} : { signal }),
19
- };
20
- }
21
9
  /** Normalize public audit input and project the protocol audit operation. */
22
10
  export async function auditContract(input) {
23
- const normalized = normalizeAuditInput(input.input);
24
- const scope = withScopeAbortSignal(input.scope, normalized.signal);
11
+ const composition = input.composition;
12
+ const scope = withScopeAbortSignal(input.scope, input.input.signal);
25
13
  return withGitDecodeChannel(scope, async (channel) => {
26
14
  const accepted = requireAccepted(await auditOperation({
27
15
  scope,
28
16
  channel,
29
17
  contractId: input.contractId,
30
18
  deriveDocument: (state) => documentDerivation(decodeContractDocument(state.terms.document.bytes), state.terms.gates, state.id),
31
- includeDirty: normalized.includeDirty,
32
- showDiff: normalized.showDiff,
33
- requireBranchesToBeUpToDate: normalized.requireBranchesToBeUpToDate,
34
- ...(normalized.signal === undefined ? {} : { signal: normalized.signal }),
35
- ...(normalized.actor === undefined ? {} : { actor: normalized.actor }),
19
+ includeDirty: input.input.includeDirty,
20
+ showDiff: input.input.showDiff,
21
+ requireBranchesToBeUpToDate: composition?.requireBranchesToBeUpToDate ?? false,
22
+ ...(input.input.signal === undefined ? {} : { signal: input.input.signal }),
23
+ ...(composition?.actor === undefined ? {} : { actor: composition.actor }),
36
24
  }));
37
25
  return completeMutation({
38
26
  scope,
@@ -40,7 +28,7 @@ export async function auditContract(input) {
40
28
  contractId: input.contractId,
41
29
  accepted,
42
30
  value: (report) => report,
43
- hooks: normalized.hooks,
31
+ hooks: composition?.hooks ?? worktreeHooksOption(undefined),
44
32
  });
45
33
  });
46
34
  }
@@ -5,7 +5,7 @@ import { listCatalog } from "./catalog.js";
5
5
  import { nukeKeiyaku } from "./nuke.js";
6
6
  import { type ExecutionContext } from "../akuma/requests.js";
7
7
  /** Internal composition root for one immutable execution channel. */
8
- export declare function composeLibrary(context?: ExecutionContext): Readonly<{
8
+ export declare function composeLibrary(context?: ExecutionContext, composition?: Parameters<typeof bindKeiyaku>[2]): Readonly<{
9
9
  prototype: KeiyakuHandle;
10
10
  [Symbol.hasInstance]: (value: unknown) => boolean;
11
11
  bind: (input: Parameters<typeof bindKeiyaku>[0]) => Promise<import("./contract-types.js").BindResult>;
@@ -43,6 +43,20 @@ export declare function composeLibrary(context?: ExecutionContext): Readonly<{
43
43
  fact: "recorded";
44
44
  tellId: string;
45
45
  };
46
+ row: {
47
+ kind: "tell";
48
+ sequence: number;
49
+ at: string;
50
+ tellId: string;
51
+ text: string;
52
+ state: "pending" | "told";
53
+ deliveries: readonly Readonly<{
54
+ turnSequence: number;
55
+ route: "launch" | "live";
56
+ receipt?: "unavailable" | "required";
57
+ deliveredAt: string;
58
+ }>[];
59
+ };
46
60
  wake: {
47
61
  kind: "failed";
48
62
  diagnostic: string;
@@ -115,31 +129,31 @@ export declare function composeLibrary(context?: ExecutionContext): Readonly<{
115
129
  } | {
116
130
  kind: "row";
117
131
  row: {
118
- kind: "call";
132
+ kind: "tell";
119
133
  sequence: number;
120
- turnSequence: number;
121
134
  at: string;
135
+ tellId: string;
122
136
  text: string;
137
+ state: "pending" | "told";
138
+ deliveries: readonly Readonly<{
139
+ turnSequence: number;
140
+ route: "launch" | "live";
141
+ receipt?: "unavailable" | "required";
142
+ deliveredAt: string;
143
+ }>[];
123
144
  } | {
124
- kind: "note" | "thought" | "said";
145
+ kind: "call";
125
146
  sequence: number;
126
147
  turnSequence: number;
127
148
  at: string;
128
149
  text: string;
129
- truncated?: true | undefined;
130
150
  } | {
131
- kind: "tell";
151
+ kind: "note" | "thought" | "said";
132
152
  sequence: number;
153
+ turnSequence: number;
133
154
  at: string;
134
- tellId: string;
135
155
  text: string;
136
- state: "pending" | "told";
137
- deliveries: readonly {
138
- deliveredAt: string;
139
- route: "live" | "launch";
140
- turnSequence: number;
141
- receipt?: "required" | "unavailable" | undefined;
142
- }[];
156
+ truncated?: true | undefined;
143
157
  } | {
144
158
  kind: "tool";
145
159
  sequence: number;
@@ -240,31 +254,31 @@ export declare function composeLibrary(context?: ExecutionContext): Readonly<{
240
254
  } | {
241
255
  kind: "row";
242
256
  row: {
243
- kind: "call";
257
+ kind: "tell";
244
258
  sequence: number;
245
- turnSequence: number;
246
259
  at: string;
260
+ tellId: string;
247
261
  text: string;
262
+ state: "pending" | "told";
263
+ deliveries: readonly Readonly<{
264
+ turnSequence: number;
265
+ route: "launch" | "live";
266
+ receipt?: "unavailable" | "required";
267
+ deliveredAt: string;
268
+ }>[];
248
269
  } | {
249
- kind: "note" | "thought" | "said";
270
+ kind: "call";
250
271
  sequence: number;
251
272
  turnSequence: number;
252
273
  at: string;
253
274
  text: string;
254
- truncated?: true | undefined;
255
275
  } | {
256
- kind: "tell";
276
+ kind: "note" | "thought" | "said";
257
277
  sequence: number;
278
+ turnSequence: number;
258
279
  at: string;
259
- tellId: string;
260
280
  text: string;
261
- state: "pending" | "told";
262
- deliveries: readonly {
263
- deliveredAt: string;
264
- route: "live" | "launch";
265
- turnSequence: number;
266
- receipt?: "required" | "unavailable" | undefined;
267
- }[];
281
+ truncated?: true | undefined;
268
282
  } | {
269
283
  kind: "tool";
270
284
  sequence: number;
@@ -5,12 +5,12 @@ import { listCatalog } from "./catalog.js";
5
5
  import { nukeKeiyaku } from "./nuke.js";
6
6
  import { executionChannel, localExecutionContext } from "../akuma/requests.js";
7
7
  /** Internal composition root for one immutable execution channel. */
8
- export function composeLibrary(context = localExecutionContext()) {
8
+ export function composeLibrary(context = localExecutionContext(), composition) {
9
9
  const captured = Object.freeze({ channel: executionChannel(context) });
10
10
  return Object.freeze({
11
11
  prototype: KeiyakuHandle.prototype,
12
12
  [Symbol.hasInstance]: (value) => value instanceof KeiyakuHandle,
13
- bind: (input) => bindKeiyaku(input, captured),
13
+ bind: (input) => bindKeiyaku(input, captured, composition),
14
14
  call: (input) => callKeiyaku(input, captured),
15
15
  fork: forkKeiyaku,
16
16
  history: historyAkuma,
@@ -20,7 +20,7 @@ export function composeLibrary(context = localExecutionContext()) {
20
20
  nuke: nukeKeiyaku,
21
21
  list: listKeiyaku,
22
22
  observe: observeKeiyaku,
23
- of: (input) => keiyakuOf(input, captured),
23
+ of: (input) => keiyakuOf(input, captured, composition),
24
24
  status: statusAkuma,
25
25
  tell: (input) => tellAkuma(input, captured),
26
26
  wait: (input) => waitAkuma(input, captured),
@@ -5,8 +5,8 @@ export declare const reconciliationLagSchema: z.ZodUnion<readonly [z.ZodObject<{
5
5
  }, z.core.$strict>, z.ZodPipe<z.ZodObject<{
6
6
  kind: z.ZodLiteral<"worktree-follow-retained">;
7
7
  path: z.ZodString;
8
- tender: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
9
- head: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
8
+ tender: z.ZodPipe<z.ZodString, z.ZodTransform<import("./contract.js").SnapshotId, string>>;
9
+ head: z.ZodPipe<z.ZodString, z.ZodTransform<import("./contract.js").SnapshotId, string>>;
10
10
  reason: z.ZodEnum<{
11
11
  "head-moved": "head-moved";
12
12
  "head-attached": "head-attached";
@@ -17,34 +17,34 @@ export declare const reconciliationLagSchema: z.ZodUnion<readonly [z.ZodObject<{
17
17
  }, z.core.$strict>, z.ZodTransform<{
18
18
  kind: "worktree-follow-retained";
19
19
  path: string;
20
- tender: import("../core/facts/types.js").SnapshotId;
21
- head: import("../core/facts/types.js").SnapshotId;
20
+ tender: import("./contract.js").SnapshotId;
21
+ head: import("./contract.js").SnapshotId;
22
22
  reason: "head-moved" | "head-attached" | "operation-in-progress" | "unsupported-parent-shape";
23
23
  } | {
24
24
  paths: string[];
25
25
  kind: "worktree-follow-retained";
26
26
  path: string;
27
- tender: import("../core/facts/types.js").SnapshotId;
28
- head: import("../core/facts/types.js").SnapshotId;
27
+ tender: import("./contract.js").SnapshotId;
28
+ head: import("./contract.js").SnapshotId;
29
29
  reason: "head-moved" | "head-attached" | "operation-in-progress" | "unsupported-parent-shape";
30
30
  }, {
31
31
  kind: "worktree-follow-retained";
32
32
  path: string;
33
- tender: import("../core/facts/types.js").SnapshotId;
34
- head: import("../core/facts/types.js").SnapshotId;
33
+ tender: import("./contract.js").SnapshotId;
34
+ head: import("./contract.js").SnapshotId;
35
35
  reason: "head-moved" | "head-attached" | "operation-in-progress" | "unsupported-parent-shape";
36
36
  paths?: string[] | undefined;
37
37
  }>>, z.ZodPipe<z.ZodObject<{
38
38
  kind: z.ZodLiteral<"unsealed-bytes">;
39
39
  path: z.ZodString;
40
40
  paths: z.ZodArray<z.ZodString>;
41
- head: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>>;
41
+ head: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("./contract.js").SnapshotId, string>>>;
42
42
  }, z.core.$strict>, z.ZodTransform<{
43
43
  kind: "unsealed-bytes";
44
44
  path: string;
45
45
  paths: string[];
46
46
  } | {
47
- head: import("../core/facts/types.js").SnapshotId;
47
+ head: import("./contract.js").SnapshotId;
48
48
  kind: "unsealed-bytes";
49
49
  path: string;
50
50
  paths: string[];
@@ -52,7 +52,7 @@ export declare const reconciliationLagSchema: z.ZodUnion<readonly [z.ZodObject<{
52
52
  kind: "unsealed-bytes";
53
53
  path: string;
54
54
  paths: string[];
55
- head?: import("../core/facts/types.js").SnapshotId | undefined;
55
+ head?: import("./contract.js").SnapshotId | undefined;
56
56
  }>>, z.ZodObject<{
57
57
  kind: z.ZodLiteral<"target-checkout-retained">;
58
58
  path: z.ZodString;
@@ -65,6 +65,12 @@ export declare const reconciliationLagSchema: z.ZodUnion<readonly [z.ZodObject<{
65
65
  effect: "effect";
66
66
  }>;
67
67
  diagnostic: z.ZodString;
68
+ }, z.core.$strict>, z.ZodObject<{
69
+ kind: z.ZodLiteral<"ref-migration-conflict">;
70
+ legacyRef: z.ZodString;
71
+ legacyOid: z.ZodPipe<z.ZodString, z.ZodTransform<import("./contract.js").SnapshotId, string>>;
72
+ currentRef: z.ZodString;
73
+ currentOid: z.ZodPipe<z.ZodString, z.ZodTransform<import("./contract.js").SnapshotId, string>>;
68
74
  }, z.core.$strict>, z.ZodObject<{
69
75
  kind: z.ZodLiteral<"worktree-hook-failed">;
70
76
  phase: z.ZodEnum<{
@@ -1,8 +1,8 @@
1
- import { snapshotId } from "../core/facts/types.js";
1
+ import { mintSnapshotId } from "../git/identity.js";
2
2
  import { z } from "zod";
3
3
  function canonicalSnapshot(value, context) {
4
4
  try {
5
- return snapshotId(value);
5
+ return mintSnapshotId(value);
6
6
  }
7
7
  catch {
8
8
  context.addIssue({ code: "custom", message: "expected SnapshotId" });
@@ -62,6 +62,15 @@ export const reconciliationLagSchema = z.union([
62
62
  diagnostic: nonblankStringSchema,
63
63
  })
64
64
  .strict(),
65
+ z
66
+ .object({
67
+ kind: z.literal("ref-migration-conflict"),
68
+ legacyRef: nonblankStringSchema,
69
+ legacyOid: snapshotIdSchema,
70
+ currentRef: nonblankStringSchema,
71
+ currentOid: snapshotIdSchema,
72
+ })
73
+ .strict(),
65
74
  z
66
75
  .object({
67
76
  kind: z.literal("worktree-hook-failed"),