jg-agent-hq 8.0.2 → 9.0.0

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 (232) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +18 -37
  3. package/api/README.md +51 -243
  4. package/dist/actions/actions.d.ts +5 -50
  5. package/dist/actions/actions.js +49 -190
  6. package/dist/actions/reads.d.ts +3 -2
  7. package/dist/actions/reads.js +12 -5
  8. package/dist/actions/waits/index.d.ts +1 -0
  9. package/dist/actions/waits/index.js +2 -0
  10. package/dist/actions/waits/waits.d.ts +37 -0
  11. package/dist/actions/waits/waits.js +107 -0
  12. package/dist/cli/cli.js +6 -56
  13. package/dist/contracts/actions/index.d.ts +2 -4
  14. package/dist/contracts/actions/index.js +1 -3
  15. package/dist/contracts/actions/types.d.ts +135 -142
  16. package/dist/contracts/actions/types.js +12 -22
  17. package/dist/contracts/browser/types.d.ts +12 -605
  18. package/dist/contracts/browser/types.js +2 -5
  19. package/dist/contracts/evidence/types.d.ts +4 -7
  20. package/dist/contracts/evidence/types.js +2 -8
  21. package/dist/contracts/index.d.ts +5 -16
  22. package/dist/contracts/index.js +4 -15
  23. package/dist/contracts/locks/index.d.ts +2 -0
  24. package/dist/contracts/locks/index.js +2 -0
  25. package/dist/contracts/locks/types.d.ts +50 -0
  26. package/dist/contracts/locks/types.js +36 -0
  27. package/dist/contracts/providers/types.d.ts +0 -38
  28. package/dist/contracts/providers/types.js +0 -1
  29. package/dist/contracts/results/types.js +1 -1
  30. package/dist/contracts/sessions/types.d.ts +2 -0
  31. package/dist/contracts/sessions/types.js +7 -1
  32. package/dist/contracts/skills/types.d.ts +1 -0
  33. package/dist/contracts/skills/types.js +5 -0
  34. package/dist/contracts/types.d.ts +4526 -12307
  35. package/dist/contracts/types.js +13 -12
  36. package/dist/index.d.ts +0 -3
  37. package/dist/index.js +0 -2
  38. package/dist/providers/claude/adapter.js +1 -11
  39. package/dist/providers/claude/claude.d.ts +6 -3
  40. package/dist/providers/claude/claude.js +49 -9
  41. package/dist/providers/claude/control/control.d.ts +2 -20
  42. package/dist/providers/claude/control/control.js +88 -155
  43. package/dist/providers/claude/control/permissions.d.ts +0 -9
  44. package/dist/providers/claude/control/permissions.js +0 -22
  45. package/dist/providers/claude/control/skills.js +1 -0
  46. package/dist/providers/claude/control/stream.js +1 -34
  47. package/dist/providers/claude/control/types.d.ts +0 -3
  48. package/dist/providers/claude/history/history.model.d.ts +9 -0
  49. package/dist/providers/claude/history/history.model.js +77 -43
  50. package/dist/providers/claude/history/types.d.ts +284 -3045
  51. package/dist/providers/claude/history/types.js +1 -0
  52. package/dist/providers/claude/rpc.d.ts +0 -5
  53. package/dist/providers/claude/rpc.js +0 -3
  54. package/dist/providers/codex/adapter.js +2 -12
  55. package/dist/providers/codex/codex.d.ts +1 -2
  56. package/dist/providers/codex/codex.js +2 -100
  57. package/dist/providers/codex/types.d.ts +2 -4
  58. package/dist/providers/registry/registry.d.ts +0 -2
  59. package/dist/providers/registry/registry.js +0 -7
  60. package/dist/providers/types.d.ts +4 -6
  61. package/dist/providers/types.js +3 -2
  62. package/dist/runtime/runtime.js +10 -81
  63. package/dist/runtime/types.d.ts +1 -18
  64. package/dist/runtime/types.js +0 -1
  65. package/dist/sessions/sessions.js +0 -1
  66. package/dist/skills/skills.js +3 -0
  67. package/dist/snapshots/archive/archive.js +2 -23
  68. package/dist/snapshots/capture.d.ts +2 -5
  69. package/dist/snapshots/capture.js +4 -85
  70. package/dist/snapshots/constants.d.ts +0 -1
  71. package/dist/snapshots/constants.js +1 -6
  72. package/dist/snapshots/database.d.ts +2 -3
  73. package/dist/snapshots/database.js +9 -114
  74. package/dist/snapshots/fences.d.ts +3 -5
  75. package/dist/snapshots/fences.js +3 -15
  76. package/dist/snapshots/files.d.ts +3 -1
  77. package/dist/snapshots/files.js +15 -4
  78. package/dist/snapshots/snapshots.d.ts +6 -7
  79. package/dist/snapshots/snapshots.js +9 -16
  80. package/dist/snapshots/types.d.ts +5 -81
  81. package/dist/snapshots/types.js +7 -30
  82. package/dist/storage/constants.d.ts +1 -0
  83. package/dist/storage/constants.js +5 -1
  84. package/dist/storage/types.d.ts +1 -0
  85. package/dist/storage/types.js +1 -0
  86. package/dist/store/control/constants.d.ts +3 -2
  87. package/dist/store/control/constants.js +3 -1
  88. package/dist/store/control/control.model.d.ts +1 -11
  89. package/dist/store/control/control.model.js +10 -131
  90. package/dist/store/control/transformers.d.ts +6 -3
  91. package/dist/store/control/transformers.js +6 -5
  92. package/dist/store/control/types.d.ts +91 -170
  93. package/dist/store/control/types.js +5 -7
  94. package/dist/store/schema.js +1 -1
  95. package/dist/store/schema.sql +3 -360
  96. package/dist/store/sessions/sessions.model.d.ts +10 -6
  97. package/dist/store/sessions/sessions.model.js +19 -2
  98. package/dist/store/snapshot.d.ts +10 -0
  99. package/dist/store/snapshot.js +37 -0
  100. package/dist/store/store.js +1 -54
  101. package/dist/store/store.worker.js +5 -97
  102. package/dist/store/types.d.ts +241 -4802
  103. package/dist/store/types.js +1 -44
  104. package/docs/recovery.md +10 -6
  105. package/errors/README.md +29 -39
  106. package/package.json +3 -4
  107. package/dist/agent-tools/agent-tools.d.ts +0 -6
  108. package/dist/agent-tools/agent-tools.js +0 -181
  109. package/dist/agent-tools/constants.d.ts +0 -7
  110. package/dist/agent-tools/constants.js +0 -45
  111. package/dist/agent-tools/index.d.ts +0 -4
  112. package/dist/agent-tools/index.js +0 -4
  113. package/dist/agent-tools/mcp/index.d.ts +0 -1
  114. package/dist/agent-tools/mcp/index.js +0 -2
  115. package/dist/agent-tools/mcp/mcp.d.ts +0 -7
  116. package/dist/agent-tools/mcp/mcp.js +0 -50
  117. package/dist/agent-tools/types.d.ts +0 -64
  118. package/dist/agent-tools/types.js +0 -1
  119. package/dist/agent-tools/utilities.d.ts +0 -13
  120. package/dist/agent-tools/utilities.js +0 -37
  121. package/dist/collaboration/collaboration.d.ts +0 -7
  122. package/dist/collaboration/collaboration.js +0 -119
  123. package/dist/collaboration/constants.d.ts +0 -2
  124. package/dist/collaboration/constants.js +0 -3
  125. package/dist/collaboration/dispatch/dispatch.d.ts +0 -12
  126. package/dist/collaboration/dispatch/dispatch.js +0 -148
  127. package/dist/collaboration/dispatch/index.d.ts +0 -3
  128. package/dist/collaboration/dispatch/index.js +0 -4
  129. package/dist/collaboration/dispatch/types.d.ts +0 -632
  130. package/dist/collaboration/dispatch/types.js +0 -44
  131. package/dist/collaboration/grants/grants.d.ts +0 -45
  132. package/dist/collaboration/grants/grants.js +0 -131
  133. package/dist/collaboration/grants/index.d.ts +0 -1
  134. package/dist/collaboration/grants/index.js +0 -2
  135. package/dist/collaboration/identity/credentials.d.ts +0 -17
  136. package/dist/collaboration/identity/credentials.js +0 -182
  137. package/dist/collaboration/identity/index.d.ts +0 -4
  138. package/dist/collaboration/identity/index.js +0 -4
  139. package/dist/collaboration/identity/types.d.ts +0 -171
  140. package/dist/collaboration/identity/types.js +0 -87
  141. package/dist/collaboration/index.d.ts +0 -3
  142. package/dist/collaboration/index.js +0 -3
  143. package/dist/collaboration/types.d.ts +0 -25
  144. package/dist/collaboration/types.js +0 -1
  145. package/dist/contracts/agent-tools/index.d.ts +0 -2
  146. package/dist/contracts/agent-tools/index.js +0 -2
  147. package/dist/contracts/agent-tools/types.d.ts +0 -697
  148. package/dist/contracts/agent-tools/types.js +0 -125
  149. package/dist/contracts/collaboration/index.d.ts +0 -4
  150. package/dist/contracts/collaboration/index.js +0 -4
  151. package/dist/contracts/collaboration/reports/constants.d.ts +0 -1
  152. package/dist/contracts/collaboration/reports/constants.js +0 -2
  153. package/dist/contracts/collaboration/reports/index.d.ts +0 -3
  154. package/dist/contracts/collaboration/reports/index.js +0 -3
  155. package/dist/contracts/collaboration/reports/types.d.ts +0 -69
  156. package/dist/contracts/collaboration/reports/types.js +0 -53
  157. package/dist/contracts/collaboration/types.d.ts +0 -6734
  158. package/dist/contracts/collaboration/types.js +0 -696
  159. package/dist/contracts/plans/index.d.ts +0 -6
  160. package/dist/contracts/plans/index.js +0 -6
  161. package/dist/contracts/plans/types.d.ts +0 -1788
  162. package/dist/contracts/plans/types.js +0 -278
  163. package/dist/plans/admission.d.ts +0 -288
  164. package/dist/plans/admission.js +0 -393
  165. package/dist/plans/authority.d.ts +0 -21
  166. package/dist/plans/authority.js +0 -207
  167. package/dist/plans/documents.d.ts +0 -80
  168. package/dist/plans/documents.js +0 -238
  169. package/dist/plans/evidence.d.ts +0 -11
  170. package/dist/plans/evidence.js +0 -211
  171. package/dist/plans/files.d.ts +0 -55
  172. package/dist/plans/files.js +0 -264
  173. package/dist/plans/finalization.d.ts +0 -11
  174. package/dist/plans/finalization.js +0 -30
  175. package/dist/plans/index.d.ts +0 -5
  176. package/dist/plans/index.js +0 -6
  177. package/dist/plans/plans.d.ts +0 -325
  178. package/dist/plans/plans.js +0 -803
  179. package/dist/plans/projections.d.ts +0 -13
  180. package/dist/plans/projections.js +0 -67
  181. package/dist/plans/revisions.d.ts +0 -50
  182. package/dist/plans/revisions.js +0 -181
  183. package/dist/plans/types.d.ts +0 -114
  184. package/dist/plans/types.js +0 -43
  185. package/dist/plans/utilities.d.ts +0 -36
  186. package/dist/plans/utilities.js +0 -62
  187. package/dist/snapshots/artifacts.d.ts +0 -16
  188. package/dist/snapshots/artifacts.js +0 -75
  189. package/dist/store/collaboration/authority.d.ts +0 -228
  190. package/dist/store/collaboration/authority.js +0 -128
  191. package/dist/store/collaboration/collaboration.model.d.ts +0 -412
  192. package/dist/store/collaboration/collaboration.model.js +0 -254
  193. package/dist/store/collaboration/constants.d.ts +0 -13
  194. package/dist/store/collaboration/constants.js +0 -14
  195. package/dist/store/collaboration/dispatch.d.ts +0 -19
  196. package/dist/store/collaboration/dispatch.js +0 -197
  197. package/dist/store/collaboration/identity.d.ts +0 -21
  198. package/dist/store/collaboration/identity.js +0 -146
  199. package/dist/store/collaboration/index.d.ts +0 -3
  200. package/dist/store/collaboration/index.js +0 -5
  201. package/dist/store/collaboration/invocation.d.ts +0 -21
  202. package/dist/store/collaboration/invocation.js +0 -162
  203. package/dist/store/collaboration/messages.d.ts +0 -54
  204. package/dist/store/collaboration/messages.js +0 -157
  205. package/dist/store/collaboration/outcomes.d.ts +0 -11
  206. package/dist/store/collaboration/outcomes.js +0 -216
  207. package/dist/store/collaboration/queries.d.ts +0 -23
  208. package/dist/store/collaboration/queries.js +0 -259
  209. package/dist/store/collaboration/reports.d.ts +0 -37
  210. package/dist/store/collaboration/reports.js +0 -117
  211. package/dist/store/collaboration/requests.d.ts +0 -22
  212. package/dist/store/collaboration/requests.js +0 -111
  213. package/dist/store/collaboration/search.d.ts +0 -13
  214. package/dist/store/collaboration/search.js +0 -58
  215. package/dist/store/collaboration/spawn.d.ts +0 -33
  216. package/dist/store/collaboration/spawn.js +0 -96
  217. package/dist/store/collaboration/streams.d.ts +0 -13
  218. package/dist/store/collaboration/streams.js +0 -100
  219. package/dist/store/collaboration/tasks.d.ts +0 -20
  220. package/dist/store/collaboration/tasks.js +0 -169
  221. package/dist/store/collaboration/transformers.d.ts +0 -56
  222. package/dist/store/collaboration/transformers.js +0 -179
  223. package/dist/store/collaboration/types.d.ts +0 -25
  224. package/dist/store/collaboration/types.js +0 -8
  225. package/dist/store/collaboration/utilities.d.ts +0 -23
  226. package/dist/store/collaboration/utilities.js +0 -77
  227. package/dist/store/collaboration/waits.d.ts +0 -26
  228. package/dist/store/collaboration/waits.js +0 -114
  229. package/dist/store/plans/index.d.ts +0 -1
  230. package/dist/store/plans/index.js +0 -2
  231. package/dist/store/plans/plans.model.d.ts +0 -47
  232. package/dist/store/plans/plans.model.js +0 -179
@@ -1,278 +0,0 @@
1
- import { z } from 'zod';
2
- // execution revisions are independent of exact file inspection hashes
3
- export const PlanDigestSchema = z.string().regex(/^[a-f0-9]{64}$/);
4
- export const PlanRevisionSchema = z.strictObject({
5
- planDigest: PlanDigestSchema,
6
- breakdownDigest: PlanDigestSchema.nullable(),
7
- });
8
- // plan frontmatter beyond the administrative keys, kept as JSON-safe extensions
9
- export const PlanMetadataSchema = z.strictObject({
10
- extensions: z.record(z.string(), z.json()).default({}),
11
- });
12
- export const PlanTargetSchema = z.strictObject({
13
- directory: z.string().min(1).max(4096),
14
- });
15
- // provenance describes an explicit operator event, never imported feedback or agent text
16
- export const PlanOperatorActionSchema = z.strictObject({
17
- id: z.uuid(),
18
- operatorId: z.string().min(1).max(256),
19
- source: z.strictObject({
20
- kind: z.enum(['user-action', 'user-message']),
21
- reference: z.string().min(1).max(4096),
22
- }),
23
- });
24
- export const PlanMilestoneSchema = z.object({
25
- id: z.uuid().nullable(),
26
- ordinal: z.number().int().positive(),
27
- title: z.string().min(1).max(4096),
28
- status: z.enum(['pending', 'in progress', 'done']),
29
- contractDigest: PlanDigestSchema.nullable(),
30
- });
31
- // actual evidence stays attached to its milestone ID across jg-breakdown revisions
32
- export const PlanCheckSchema = z.strictObject({
33
- command: z.string().min(1).max(4096),
34
- outcome: z.literal('passed'),
35
- reference: z.string().min(1).max(4096),
36
- });
37
- export const PlanCheckoutSchema = z.strictObject({
38
- repository: z.string().min(1).max(128),
39
- directory: z.string().min(1).max(4096),
40
- claimReference: z.string().min(1).max(4096),
41
- paths: z
42
- .array(z.string().min(1).max(4096))
43
- .max(1024)
44
- .refine((paths) => new Set(paths).size === paths.length),
45
- });
46
- export const PlanWorktreeProofSchema = PlanCheckoutSchema.extend({
47
- branch: z.string().nullable(),
48
- head: z.string().regex(/^[a-f0-9]{40}(?:[a-f0-9]{24})?$/),
49
- fingerprint: PlanDigestSchema,
50
- });
51
- export const PlanCompletionSchema = z.strictObject({
52
- id: z.uuid(),
53
- action: PlanOperatorActionSchema,
54
- milestoneId: z.uuid().nullable(),
55
- revision: PlanRevisionSchema,
56
- contractDigest: PlanDigestSchema,
57
- title: z.string().min(1).max(4096),
58
- contract: z.string().max(1_048_576),
59
- sharedDigest: PlanDigestSchema.nullable(),
60
- checkouts: z.array(PlanWorktreeProofSchema).max(128),
61
- checks: z.array(PlanCheckSchema).min(1).max(32),
62
- completedAt: z.number().int(),
63
- // the finalization that found this milestone no longer done; the receipt then stops counting
64
- reopenedBy: z.uuid().nullable(),
65
- });
66
- export const PlanSnapshotMilestoneSchema = PlanMilestoneSchema.extend({
67
- id: z.uuid(),
68
- contractDigest: PlanDigestSchema,
69
- contract: z.string().max(1_048_576),
70
- sharedDigest: PlanDigestSchema,
71
- });
72
- export const PlanCheckpointSchema = z.strictObject({
73
- revision: PlanRevisionSchema,
74
- plan: z.string().max(1_048_576),
75
- milestones: z.string().max(1_048_576).nullable(),
76
- entries: z.array(PlanSnapshotMilestoneSchema).max(1024),
77
- checkouts: z.array(PlanWorktreeProofSchema).max(128),
78
- threadIds: z.array(z.uuid()).max(32),
79
- capturedAt: z.number().int(),
80
- isQuiescent: z.boolean(),
81
- });
82
- export const PlanRevisionWorkflowSchema = z.strictObject({
83
- id: z.uuid(),
84
- action: PlanOperatorActionSchema,
85
- intent: z.enum(['plan', 'breakdown']),
86
- phaseActionId: z.uuid(),
87
- ownerRuntimeEpoch: z.uuid(),
88
- checkpointActionId: z.uuid(),
89
- blockActionId: z.uuid(),
90
- controls: z
91
- .array(z.strictObject({ threadId: z.uuid(), interruptActionId: z.uuid(), closeActionId: z.uuid() }))
92
- .max(32),
93
- phase: z.enum(['quiescing', 'editing', 'awaiting-approval', 'blocked', 'finished']),
94
- reason: z.string().max(4096).nullable(),
95
- threadIds: z.array(z.uuid()).max(32),
96
- checkouts: z.array(PlanCheckoutSchema).max(128),
97
- checkpoint: PlanCheckpointSchema.nullable(),
98
- invocation: z
99
- .strictObject({ action: PlanOperatorActionSchema, skill: z.enum(['jg-plan', 'jg-breakdown']) })
100
- .nullable(),
101
- createdAt: z.number().int(),
102
- hasUncertainEffects: z.boolean(),
103
- });
104
- const MutationFields = {
105
- target: PlanTargetSchema,
106
- action: PlanOperatorActionSchema,
107
- expected: PlanRevisionSchema,
108
- };
109
- export const PlanCommandSchema = z.discriminatedUnion('kind', [
110
- z.strictObject({ kind: z.literal('status'), target: PlanTargetSchema }),
111
- z.strictObject({
112
- kind: z.literal('milestones'),
113
- target: PlanTargetSchema,
114
- limit: z.number().int().min(1).max(128).default(32),
115
- cursor: z.string().min(1).max(16_384).optional(),
116
- }),
117
- z.strictObject({ kind: z.literal('register'), target: PlanTargetSchema }),
118
- z.strictObject({ kind: z.literal('finalize'), ...MutationFields }),
119
- z.strictObject({
120
- kind: z.literal('complete'),
121
- ...MutationFields,
122
- milestoneId: z.uuid().nullable(),
123
- checks: z.array(PlanCheckSchema).min(1).max(32),
124
- checkouts: z.array(PlanCheckoutSchema).max(128),
125
- }),
126
- z.strictObject({
127
- kind: z.literal('begin-revision'),
128
- ...MutationFields,
129
- intent: z.enum(['plan', 'breakdown']),
130
- threadIds: z.array(z.uuid()).max(32),
131
- checkouts: z.array(PlanCheckoutSchema).max(128),
132
- }),
133
- z.strictObject({
134
- kind: z.literal('revision-invoke'),
135
- ...MutationFields,
136
- revisionId: z.uuid(),
137
- skill: z.enum(['jg-plan', 'jg-breakdown']),
138
- }),
139
- z.strictObject({
140
- kind: z.literal('approve'),
141
- ...MutationFields,
142
- scope: z.enum(['plan', 'sequence']),
143
- presentationHash: PlanDigestSchema,
144
- }),
145
- z.strictObject({
146
- kind: z.literal('revoke'),
147
- ...MutationFields,
148
- scope: z.enum(['plan', 'sequence', 'execution', 'all']),
149
- }),
150
- z.strictObject({
151
- kind: z.literal('authorize'),
152
- ...MutationFields,
153
- mode: z.enum(['supervised', 'auto']),
154
- milestoneIds: z
155
- .array(z.uuid())
156
- .max(1024)
157
- .refine((ids) => new Set(ids).size === ids.length),
158
- }),
159
- z.strictObject({
160
- kind: z.literal('check-execution'),
161
- target: PlanTargetSchema,
162
- expected: PlanRevisionSchema,
163
- authorizationId: z.uuid(),
164
- milestoneId: z.uuid().nullable(),
165
- mode: z.enum(['supervised', 'auto']),
166
- }),
167
- ]);
168
- export const PlanApprovalSchema = z.strictObject({
169
- action: PlanOperatorActionSchema,
170
- revision: PlanRevisionSchema,
171
- presentationHash: PlanDigestSchema,
172
- createdAt: z.number().int(),
173
- revokedBy: PlanOperatorActionSchema.nullable(),
174
- });
175
- export const PlanExecutionSchema = z.strictObject({
176
- runtimeEpoch: z.uuid(),
177
- action: PlanOperatorActionSchema,
178
- revision: PlanRevisionSchema,
179
- mode: z.enum(['supervised', 'auto']),
180
- milestoneIds: z.array(z.uuid()).max(1024),
181
- createdAt: z.number().int(),
182
- revokedBy: PlanOperatorActionSchema.nullable(),
183
- });
184
- // finalization records identity bookkeeping without granting any approval
185
- export const PlanFinalizationSchema = z.strictObject({
186
- action: PlanOperatorActionSchema,
187
- revision: PlanRevisionSchema,
188
- fileHash: PlanDigestSchema.nullable(),
189
- createdAt: z.number().int(),
190
- });
191
- export const PlanCoordinationSchema = z.strictObject({
192
- schemaVersion: z.literal(1),
193
- finalized: PlanFinalizationSchema.nullable(),
194
- planApproval: PlanApprovalSchema.nullable(),
195
- sequenceApproval: PlanApprovalSchema.nullable(),
196
- execution: PlanExecutionSchema.nullable(),
197
- lastActionId: z.uuid().nullable(),
198
- completions: z.array(PlanCompletionSchema).max(1024),
199
- revision: PlanRevisionWorkflowSchema.nullable(),
200
- baseline: PlanCheckpointSchema.nullable(),
201
- observedConflict: z
202
- .strictObject({
203
- id: z.uuid(),
204
- revision: PlanRevisionSchema.nullable(),
205
- observedAt: z.number().int(),
206
- ownerRuntimeEpoch: z.uuid(),
207
- phase: z.enum(['quiescing', 'quiescent', 'blocked']),
208
- controls: PlanRevisionWorkflowSchema.shape.controls,
209
- })
210
- .nullable(),
211
- });
212
- // collection bodies remain in the file owner and paged SQLite projections
213
- export const PlanCoordinationSummarySchema = PlanCoordinationSchema.omit({
214
- completions: true,
215
- revision: true,
216
- baseline: true,
217
- }).extend({
218
- completionCount: z.number().int().nonnegative(),
219
- // current receipts whose milestone ID no longer appears in the sequence
220
- unmatchedEvidence: z
221
- .array(PlanCompletionSchema.pick({ id: true, milestoneId: true, title: true, completedAt: true }))
222
- .max(1024),
223
- revision: PlanRevisionWorkflowSchema.omit({
224
- checkpoint: true,
225
- checkouts: true,
226
- controls: true,
227
- checkpointActionId: true,
228
- blockActionId: true,
229
- })
230
- .extend({ hasCheckpoint: z.boolean() })
231
- .nullable(),
232
- });
233
- export const PlanStatusSchema = z.object({
234
- directory: z.string(),
235
- revision: PlanRevisionSchema,
236
- inspection: z.object({
237
- plan: PlanDigestSchema,
238
- milestones: PlanDigestSchema.nullable(),
239
- coordination: PlanDigestSchema.nullable(),
240
- }),
241
- state: z.enum([
242
- 'plan-approval-required',
243
- 'breakdown-required',
244
- 'sequence-approval-required',
245
- 'ready',
246
- 'in-progress',
247
- 'blocked',
248
- 'revising',
249
- 'completed',
250
- ]),
251
- pendingActionId: z.uuid().nullable(),
252
- skillsBinding: z.enum(['absent', 'current', 'stale']),
253
- isFinalized: z.boolean(),
254
- isPlanApproved: z.boolean(),
255
- isSequenceApproved: z.boolean(),
256
- milestoneCount: z.number().int().min(0).max(1024),
257
- coordination: PlanCoordinationSummarySchema,
258
- });
259
- export const PlanResultSchema = z.discriminatedUnion('kind', [
260
- z.object({ kind: z.literal('status'), result: PlanStatusSchema }),
261
- z.object({ kind: z.literal('registered'), result: z.object({ directory: z.string() }) }),
262
- z.object({
263
- kind: z.literal('finalized'),
264
- result: PlanStatusSchema,
265
- content: z.string().max(1_048_576).nullable(),
266
- }),
267
- z.object({
268
- kind: z.literal('milestones'),
269
- result: z.object({
270
- data: z.array(PlanMilestoneSchema).max(128),
271
- nextCursor: z.string().nullable(),
272
- }),
273
- }),
274
- z.object({
275
- kind: z.literal('execution-check'),
276
- result: z.object({ isAuthorized: z.literal(true), authorization: PlanExecutionSchema }),
277
- }),
278
- ]);
@@ -1,288 +0,0 @@
1
- import type { IActionEnvelope } from '../contracts/index.js';
2
- import type { IStore } from '../store/index.js';
3
- import type { IAdmission } from '../store/control/index.js';
4
- import type { IPlanArtifacts, IApplyPlanIntent, IWithPlanDocuments, IPrepareImplementation, IResumeImplementation } from './types.js';
5
- /**
6
- * Keeps native scope admission and queue claims under the plan's canonical short lock.
7
- * @returns The existing action owner's scoped admission and queue operations.
8
- */
9
- export declare const createPlanAdmission: (coordinationRoot: string, store: IStore, runtimeEpoch: string, readPlan: (directory: string, apply: IApplyPlanIntent) => Promise<IPlanArtifacts>, withDocuments: IWithPlanDocuments, prepareImplementation: IPrepareImplementation, resumeImplementation: IResumeImplementation) => {
10
- /**
11
- * Rechecks a dispatched request's exact plan immediately before native submission.
12
- * @returns Completion after the short document/metadata locks have released.
13
- * @throws
14
- * - JG_AGENT_HQ_COLLABORATION_FORBIDDEN: The HQ collaboration operation is not authorized
15
- * - JG_AGENT_HQ_COLLABORATION_CONFLICT: The HQ collaboration operation conflicts with its recorded state
16
- * - JG_AGENT_HQ_TARGET_FORBIDDEN: The HQ target is outside the allowed workspaces
17
- * - JG_AGENT_HQ_ACTION_CONFLICT: The HQ action conflicts with its recorded state
18
- * - JG_AGENT_HQ_PLAN_INVALID: The HQ plan is invalid
19
- * - JG_AGENT_HQ_PLAN_FAILED: The HQ plan operation failed
20
- * - JG_AGENT_HQ_STORE_FAILED: The HQ store failed
21
- * - JG_AGENT_HQ_LOCK_INVALID_ARGUMENTS: The HQ lock acquisition arguments are invalid
22
- * - JG_AGENT_HQ_LOCK_UNSUPPORTED_PLATFORM: The HQ lock requires Linux or macOS
23
- * - JG_AGENT_HQ_RUNTIME_DIRECTORY_INVALID: The HQ runtime directory must be a real directory
24
- * - JG_AGENT_HQ_RUNTIME_DIRECTORY_PERMISSIONS: The HQ runtime directory must be private and owned by the current user
25
- * - JG_AGENT_HQ_LOCK_FILE_INVALID: The HQ lock must be a regular file
26
- * - JG_AGENT_HQ_LOCK_FILE_PERMISSIONS: The HQ lock must be private and owned by the current user
27
- * - JG_AGENT_HQ_LOCK_OWNER_OVERSIZED: The HQ lock owner exceeds the supported size
28
- * - JG_AGENT_HQ_LOCK_OWNER_UNREADABLE: The HQ lock owner could not be read. Inspect .runtime/hq.lock
29
- * - JG_AGENT_HQ_LOCK_OWNER_INCOMPLETE: The HQ lock owner is incomplete. Inspect .runtime/hq.lock and remove it only after its owner stopped
30
- * - JG_AGENT_HQ_LOCK_OWNER_INACTIVE: The HQ lock has an inactive owner
31
- * - JG_AGENT_HQ_LOCK_OWNER_UNVERIFIABLE: The HQ lock owner could not be verified
32
- * - JG_AGENT_HQ_LOCK_TIMEOUT: Timed out waiting for the HQ lock
33
- * - JG_AGENT_HQ_LOCK_OWNERSHIP_CHANGED: HQ lock ownership changed before release
34
- */
35
- validateDispatch(taskId: string, requestId: string, actionId: string): Promise<void>;
36
- /**
37
- * Validates guided scope and admits under the same short lock as revision gate closure.
38
- * @returns The existing action owner's receipt and dispatch identity.
39
- * @throws
40
- * - JG_AGENT_HQ_COLLABORATION_FORBIDDEN: The HQ collaboration operation is not authorized
41
- * - JG_AGENT_HQ_COLLABORATION_CONFLICT: The HQ collaboration operation conflicts with its recorded state
42
- * - JG_AGENT_HQ_TARGET_FORBIDDEN: The HQ target is outside the allowed workspaces
43
- * - JG_AGENT_HQ_ACTION_CONFLICT: The HQ action conflicts with its recorded state
44
- * - JG_AGENT_HQ_PLAN_INVALID: The HQ plan is invalid
45
- * - JG_AGENT_HQ_PLAN_FAILED: The HQ plan operation failed
46
- * - JG_AGENT_HQ_STORE_FAILED: The HQ store failed
47
- * - JG_AGENT_HQ_LOCK_INVALID_ARGUMENTS: The HQ lock acquisition arguments are invalid
48
- * - JG_AGENT_HQ_LOCK_UNSUPPORTED_PLATFORM: The HQ lock requires Linux or macOS
49
- * - JG_AGENT_HQ_RUNTIME_DIRECTORY_INVALID: The HQ runtime directory must be a real directory
50
- * - JG_AGENT_HQ_RUNTIME_DIRECTORY_PERMISSIONS: The HQ runtime directory must be private and owned by the current user
51
- * - JG_AGENT_HQ_LOCK_FILE_INVALID: The HQ lock must be a regular file
52
- * - JG_AGENT_HQ_LOCK_FILE_PERMISSIONS: The HQ lock must be private and owned by the current user
53
- * - JG_AGENT_HQ_LOCK_OWNER_OVERSIZED: The HQ lock owner exceeds the supported size
54
- * - JG_AGENT_HQ_LOCK_OWNER_UNREADABLE: The HQ lock owner could not be read. Inspect .runtime/hq.lock
55
- * - JG_AGENT_HQ_LOCK_OWNER_INCOMPLETE: The HQ lock owner is incomplete. Inspect .runtime/hq.lock and remove it only after its owner stopped
56
- * - JG_AGENT_HQ_LOCK_OWNER_INACTIVE: The HQ lock has an inactive owner
57
- * - JG_AGENT_HQ_LOCK_OWNER_UNVERIFIABLE: The HQ lock owner could not be verified
58
- * - JG_AGENT_HQ_LOCK_TIMEOUT: Timed out waiting for the HQ lock
59
- * - JG_AGENT_HQ_LOCK_OWNERSHIP_CHANGED: HQ lock ownership changed before release
60
- */
61
- admitNative(action: IActionEnvelope, prepared: IAdmission["prepared"]): Promise<{
62
- receipt: {
63
- id: string;
64
- digest: string;
65
- runtimeEpoch: string;
66
- kind: "message" | "interrupt" | "steer" | "account-login" | "account-login-cancel" | "account-logout" | "skills-reload" | "mcp-reload" | "mcp-reconnect" | "mcp-set-enabled" | "mcp-login" | "plugins-reload" | "thread-create" | "thread-adopt" | "thread-resume" | "thread-close" | "thread-fork" | "thread-archive" | "thread-unarchive" | "thread-compact" | "thread-revert" | "thread-recover" | "thread-rename" | "queue" | "queue-send" | "queue-cancel" | "native-reply";
67
- provider: string | null;
68
- controlState: "held" | "accepted" | "applied" | null;
69
- threadId: string | null;
70
- nativeTurnId: string | null;
71
- nativeRequestId: string | null;
72
- delivery: "failed" | "canceled" | "uncertain" | "queued" | "submitted" | "acknowledged";
73
- completion: "completed" | "failed" | "interrupted" | null;
74
- failure: "state-conflict" | "access-denied" | "agent-unavailable" | "operation-failed" | null;
75
- relatedActionId: string | null;
76
- planContext: {
77
- directory: string;
78
- scope: {
79
- kind: "execution";
80
- authorizationId: string;
81
- milestoneId: string | null;
82
- mode: "supervised" | "auto";
83
- revision: {
84
- planDigest: string;
85
- breakdownDigest: string | null;
86
- };
87
- } | {
88
- kind: "planning";
89
- revisionId: string;
90
- invocationId: string;
91
- } | null;
92
- observedRevision: {
93
- planDigest: string;
94
- breakdownDigest: string | null;
95
- };
96
- } | null;
97
- queuedInput: {
98
- text: string;
99
- skill: {
100
- name: string;
101
- path: string | null;
102
- } | null;
103
- files: {
104
- path: string;
105
- mediaType: "image/png" | "image/jpeg" | "image/webp" | "image/gif" | "application/pdf" | "text/plain";
106
- sha256: string;
107
- bytes: number;
108
- }[];
109
- settings: {
110
- model?: string | undefined;
111
- effort?: string | undefined;
112
- outputSchema?: Record<string, import("zod").JSONType> | undefined;
113
- };
114
- } | null;
115
- result: {
116
- state: "completed" | "failed" | "interrupted";
117
- format: "text" | "json-schema";
118
- text: string | null;
119
- structuredOutput: import("zod").JSONType;
120
- isComplete: boolean;
121
- failure: "native-error" | "invalid-structured-output" | "result-too-large" | "missing-result" | null;
122
- usage: {
123
- inputTokens: number | null;
124
- outputTokens: number | null;
125
- cachedInputTokens: number | null;
126
- scope: "turn" | "thread";
127
- } | null;
128
- } | null;
129
- createdAt: number;
130
- updatedAt: number;
131
- };
132
- thread: {
133
- id: string;
134
- provider: string;
135
- nativeId: string | null;
136
- nativeLineage: {
137
- sessionId: string | null;
138
- parentThreadId: string | null;
139
- forkedFromId: string | null;
140
- } | null;
141
- forkedFromThreadId: string | null;
142
- isArchived: boolean;
143
- name: string;
144
- workspaceRoot: string;
145
- ownership: "managed" | "uncertain";
146
- runtimeEpoch: string | null;
147
- activeTurnId: string | null;
148
- state: "unknown" | "idle" | "completed" | "failed" | "interrupted" | "waiting-input" | "running" | "creating" | "inactive" | "starting" | "waiting-approval" | "stopping";
149
- createdAt: number;
150
- updatedAt: number;
151
- } | null;
152
- isNew: boolean;
153
- dispatchActionId: string | null;
154
- }>;
155
- /**
156
- * Claims queued input only after current scope and the editing gate are checked.
157
- * @returns One existing dispatch or null while the plan is paused.
158
- * @throws
159
- * - JG_AGENT_HQ_TARGET_FORBIDDEN: The HQ target is outside the allowed workspaces
160
- * - JG_AGENT_HQ_ACTION_CONFLICT: The HQ action conflicts with its recorded state
161
- * - JG_AGENT_HQ_PLAN_INVALID: The HQ plan is invalid
162
- * - JG_AGENT_HQ_PLAN_FAILED: The HQ plan operation failed
163
- * - JG_AGENT_HQ_STORE_FAILED: The HQ store failed
164
- * - JG_AGENT_HQ_LOCK_INVALID_ARGUMENTS: The HQ lock acquisition arguments are invalid
165
- * - JG_AGENT_HQ_LOCK_UNSUPPORTED_PLATFORM: The HQ lock requires Linux or macOS
166
- * - JG_AGENT_HQ_RUNTIME_DIRECTORY_INVALID: The HQ runtime directory must be a real directory
167
- * - JG_AGENT_HQ_RUNTIME_DIRECTORY_PERMISSIONS: The HQ runtime directory must be private and owned by the current user
168
- * - JG_AGENT_HQ_LOCK_FILE_INVALID: The HQ lock must be a regular file
169
- * - JG_AGENT_HQ_LOCK_FILE_PERMISSIONS: The HQ lock must be private and owned by the current user
170
- * - JG_AGENT_HQ_LOCK_OWNER_OVERSIZED: The HQ lock owner exceeds the supported size
171
- * - JG_AGENT_HQ_LOCK_OWNER_UNREADABLE: The HQ lock owner could not be read. Inspect .runtime/hq.lock
172
- * - JG_AGENT_HQ_LOCK_OWNER_INCOMPLETE: The HQ lock owner is incomplete. Inspect .runtime/hq.lock and remove it only after its owner stopped
173
- * - JG_AGENT_HQ_LOCK_OWNER_INACTIVE: The HQ lock has an inactive owner
174
- * - JG_AGENT_HQ_LOCK_OWNER_UNVERIFIABLE: The HQ lock owner could not be verified
175
- * - JG_AGENT_HQ_LOCK_TIMEOUT: Timed out waiting for the HQ lock
176
- * - JG_AGENT_HQ_LOCK_OWNERSHIP_CHANGED: HQ lock ownership changed before release
177
- */
178
- claimQueued(threadId: string): Promise<{
179
- receipt: {
180
- id: string;
181
- digest: string;
182
- runtimeEpoch: string;
183
- kind: "message" | "interrupt" | "steer" | "account-login" | "account-login-cancel" | "account-logout" | "skills-reload" | "mcp-reload" | "mcp-reconnect" | "mcp-set-enabled" | "mcp-login" | "plugins-reload" | "thread-create" | "thread-adopt" | "thread-resume" | "thread-close" | "thread-fork" | "thread-archive" | "thread-unarchive" | "thread-compact" | "thread-revert" | "thread-recover" | "thread-rename" | "queue" | "queue-send" | "queue-cancel" | "native-reply";
184
- provider: string | null;
185
- controlState: "held" | "accepted" | "applied" | null;
186
- threadId: string | null;
187
- nativeTurnId: string | null;
188
- nativeRequestId: string | null;
189
- delivery: "failed" | "canceled" | "uncertain" | "queued" | "submitted" | "acknowledged";
190
- completion: "completed" | "failed" | "interrupted" | null;
191
- failure: "state-conflict" | "access-denied" | "agent-unavailable" | "operation-failed" | null;
192
- relatedActionId: string | null;
193
- planContext: {
194
- directory: string;
195
- scope: {
196
- kind: "execution";
197
- authorizationId: string;
198
- milestoneId: string | null;
199
- mode: "supervised" | "auto";
200
- revision: {
201
- planDigest: string;
202
- breakdownDigest: string | null;
203
- };
204
- } | {
205
- kind: "planning";
206
- revisionId: string;
207
- invocationId: string;
208
- } | null;
209
- observedRevision: {
210
- planDigest: string;
211
- breakdownDigest: string | null;
212
- };
213
- } | null;
214
- queuedInput: {
215
- text: string;
216
- skill: {
217
- name: string;
218
- path: string | null;
219
- } | null;
220
- files: {
221
- path: string;
222
- mediaType: "image/png" | "image/jpeg" | "image/webp" | "image/gif" | "application/pdf" | "text/plain";
223
- sha256: string;
224
- bytes: number;
225
- }[];
226
- settings: {
227
- model?: string | undefined;
228
- effort?: string | undefined;
229
- outputSchema?: Record<string, import("zod").JSONType> | undefined;
230
- };
231
- } | null;
232
- result: {
233
- state: "completed" | "failed" | "interrupted";
234
- format: "text" | "json-schema";
235
- text: string | null;
236
- structuredOutput: import("zod").JSONType;
237
- isComplete: boolean;
238
- failure: "native-error" | "invalid-structured-output" | "result-too-large" | "missing-result" | null;
239
- usage: {
240
- inputTokens: number | null;
241
- outputTokens: number | null;
242
- cachedInputTokens: number | null;
243
- scope: "turn" | "thread";
244
- } | null;
245
- } | null;
246
- createdAt: number;
247
- updatedAt: number;
248
- };
249
- thread: {
250
- id: string;
251
- provider: string;
252
- nativeId: string | null;
253
- nativeLineage: {
254
- sessionId: string | null;
255
- parentThreadId: string | null;
256
- forkedFromId: string | null;
257
- } | null;
258
- forkedFromThreadId: string | null;
259
- isArchived: boolean;
260
- name: string;
261
- workspaceRoot: string;
262
- ownership: "managed" | "uncertain";
263
- runtimeEpoch: string | null;
264
- activeTurnId: string | null;
265
- state: "unknown" | "idle" | "completed" | "failed" | "interrupted" | "waiting-input" | "running" | "creating" | "inactive" | "starting" | "waiting-approval" | "stopping";
266
- createdAt: number;
267
- updatedAt: number;
268
- };
269
- input: {
270
- text: string;
271
- skill: {
272
- name: string;
273
- path: string | null;
274
- } | null;
275
- files: {
276
- path: string;
277
- mediaType: "image/png" | "image/jpeg" | "image/webp" | "image/gif" | "application/pdf" | "text/plain";
278
- sha256: string;
279
- bytes: number;
280
- }[];
281
- settings: {
282
- model?: string | undefined;
283
- effort?: string | undefined;
284
- outputSchema?: Record<string, import("zod").JSONType> | undefined;
285
- };
286
- };
287
- } | null>;
288
- };