@phyzess/pappra 0.0.0-stage → 0.1.0-beta.2

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 (221) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +80 -2
  3. package/THIRD_PARTY_NOTICES.md +16 -0
  4. package/assets/integrations/skills/pappra/SKILL.md +68 -0
  5. package/assets/integrations/skills/pappra/references/hosts.md +30 -0
  6. package/assets/integrations/skills/pappra/references/lifecycle.md +37 -0
  7. package/assets/integrations/skills/pappra/references/operations.md +14 -0
  8. package/assets/manifest.json +4 -0
  9. package/dist/app/collaboration.d.ts +170 -0
  10. package/dist/app/collaboration.js +1650 -0
  11. package/dist/app/doctor.d.ts +9 -0
  12. package/dist/app/doctor.js +1030 -0
  13. package/dist/app/init.d.ts +143 -0
  14. package/dist/app/init.js +1111 -0
  15. package/dist/cli/commands/code.d.ts +16 -0
  16. package/dist/cli/commands/code.js +127 -0
  17. package/dist/cli/commands/collaboration.d.ts +13 -0
  18. package/dist/cli/commands/collaboration.js +186 -0
  19. package/dist/cli/commands/continuity.d.ts +29 -0
  20. package/dist/cli/commands/continuity.js +133 -0
  21. package/dist/cli/commands/docs.d.ts +11 -0
  22. package/dist/cli/commands/docs.js +133 -0
  23. package/dist/cli/commands/doctor.d.ts +14 -0
  24. package/dist/cli/commands/doctor.js +57 -0
  25. package/dist/cli/commands/host.d.ts +13 -0
  26. package/dist/cli/commands/host.js +125 -0
  27. package/dist/cli/commands/init.d.ts +51 -0
  28. package/dist/cli/commands/init.js +668 -0
  29. package/dist/cli/main.d.ts +2 -0
  30. package/dist/cli/main.js +10 -0
  31. package/dist/cli/output.d.ts +4 -0
  32. package/dist/cli/output.js +1 -0
  33. package/dist/cli/run.d.ts +2 -0
  34. package/dist/cli/run.js +597 -0
  35. package/dist/code/budget.d.ts +14 -0
  36. package/dist/code/budget.js +39 -0
  37. package/dist/code/exec.d.ts +23 -0
  38. package/dist/code/exec.js +133 -0
  39. package/dist/code/identity.d.ts +13 -0
  40. package/dist/code/identity.js +214 -0
  41. package/dist/code/index.d.ts +6 -0
  42. package/dist/code/index.js +3 -0
  43. package/dist/code/providers/codegraph.d.ts +59 -0
  44. package/dist/code/providers/codegraph.js +567 -0
  45. package/dist/code/registration.d.ts +9 -0
  46. package/dist/code/registration.js +293 -0
  47. package/dist/code/service.d.ts +53 -0
  48. package/dist/code/service.js +633 -0
  49. package/dist/code/text.d.ts +3 -0
  50. package/dist/code/text.js +202 -0
  51. package/dist/collab/admission.d.ts +450 -0
  52. package/dist/collab/admission.js +797 -0
  53. package/dist/collab/canonical.d.ts +26 -0
  54. package/dist/collab/canonical.js +136 -0
  55. package/dist/collab/contracts.d.ts +73 -0
  56. package/dist/collab/contracts.js +76 -0
  57. package/dist/collab/envelope.d.ts +52 -0
  58. package/dist/collab/envelope.js +241 -0
  59. package/dist/collab/fingerprint.d.ts +7 -0
  60. package/dist/collab/fingerprint.js +58 -0
  61. package/dist/collab/handoff.d.ts +350 -0
  62. package/dist/collab/handoff.js +513 -0
  63. package/dist/collab/index.d.ts +9 -0
  64. package/dist/collab/index.js +8 -0
  65. package/dist/collab/lifecycle.d.ts +449 -0
  66. package/dist/collab/lifecycle.js +534 -0
  67. package/dist/collab/messages.d.ts +148 -0
  68. package/dist/collab/messages.js +583 -0
  69. package/dist/collab/notify.d.ts +47 -0
  70. package/dist/collab/notify.js +140 -0
  71. package/dist/collab/preflight.d.ts +31 -0
  72. package/dist/collab/preflight.js +271 -0
  73. package/dist/collab/resources.d.ts +119 -0
  74. package/dist/collab/resources.js +451 -0
  75. package/dist/collab/store.d.ts +143 -0
  76. package/dist/collab/store.js +606 -0
  77. package/dist/collab/types.d.ts +354 -0
  78. package/dist/collab/types.js +1 -0
  79. package/dist/collab/validation.d.ts +10 -0
  80. package/dist/collab/validation.js +303 -0
  81. package/dist/continuity/context.d.ts +24 -0
  82. package/dist/continuity/context.js +179 -0
  83. package/dist/continuity/index.d.ts +3 -0
  84. package/dist/continuity/index.js +1 -0
  85. package/dist/continuity/paths.d.ts +37 -0
  86. package/dist/continuity/paths.js +258 -0
  87. package/dist/continuity/service.d.ts +59 -0
  88. package/dist/continuity/service.js +1258 -0
  89. package/dist/hosts/claude/native.d.ts +79 -0
  90. package/dist/hosts/claude/native.js +853 -0
  91. package/dist/hosts/codex/native.d.ts +345 -0
  92. package/dist/hosts/codex/native.js +1528 -0
  93. package/dist/hosts/codex/protocol.d.ts +51 -0
  94. package/dist/hosts/codex/protocol.js +42 -0
  95. package/dist/hosts/detect.d.ts +28 -0
  96. package/dist/hosts/detect.js +73 -0
  97. package/dist/hosts/index.d.ts +10 -0
  98. package/dist/hosts/index.js +10 -0
  99. package/dist/hosts/integration/bundle.d.ts +16 -0
  100. package/dist/hosts/integration/bundle.js +81 -0
  101. package/dist/hosts/integration/hook-entry.d.ts +1 -0
  102. package/dist/hosts/integration/hook-entry.js +68 -0
  103. package/dist/hosts/integration/hook.d.ts +32 -0
  104. package/dist/hosts/integration/hook.js +781 -0
  105. package/dist/hosts/integration/pi-extension-runtime.d.ts +18 -0
  106. package/dist/hosts/integration/pi-extension-runtime.js +89 -0
  107. package/dist/hosts/integration/pi-template.d.ts +3 -0
  108. package/dist/hosts/integration/pi-template.js +5 -0
  109. package/dist/hosts/integration/service.d.ts +41 -0
  110. package/dist/hosts/integration/service.js +1381 -0
  111. package/dist/hosts/integration/support.d.ts +36 -0
  112. package/dist/hosts/integration/support.js +41 -0
  113. package/dist/hosts/integration/templates.d.ts +22 -0
  114. package/dist/hosts/integration/templates.js +70 -0
  115. package/dist/hosts/pi/protocol.d.ts +22 -0
  116. package/dist/hosts/pi/protocol.js +28 -0
  117. package/dist/hosts/pi/query-result.d.ts +22 -0
  118. package/dist/hosts/pi/query-result.js +710 -0
  119. package/dist/hosts/pi/rpc.d.ts +937 -0
  120. package/dist/hosts/pi/rpc.js +1621 -0
  121. package/dist/hosts/pilot.d.ts +485 -0
  122. package/dist/hosts/pilot.js +593 -0
  123. package/dist/index.d.ts +5 -0
  124. package/dist/index.js +4 -0
  125. package/dist/infra/fs.d.ts +27 -0
  126. package/dist/infra/fs.js +130 -0
  127. package/dist/infra/git.d.ts +60 -0
  128. package/dist/infra/git.js +358 -0
  129. package/dist/infra/owned-process-group.d.ts +173 -0
  130. package/dist/infra/owned-process-group.js +571 -0
  131. package/dist/install/apply.d.ts +65 -0
  132. package/dist/install/apply.js +663 -0
  133. package/dist/install/index.d.ts +5 -0
  134. package/dist/install/index.js +5 -0
  135. package/dist/install/ownership.d.ts +85 -0
  136. package/dist/install/ownership.js +430 -0
  137. package/dist/install/plan.d.ts +39 -0
  138. package/dist/install/plan.js +97 -0
  139. package/dist/install/rollback.d.ts +18 -0
  140. package/dist/install/rollback.js +544 -0
  141. package/dist/install/runtime.d.ts +76 -0
  142. package/dist/install/runtime.js +1145 -0
  143. package/dist/knowledge/catalog.d.ts +47 -0
  144. package/dist/knowledge/catalog.js +308 -0
  145. package/dist/knowledge/context.d.ts +28 -0
  146. package/dist/knowledge/context.js +61 -0
  147. package/dist/knowledge/index.d.ts +3 -0
  148. package/dist/knowledge/index.js +1 -0
  149. package/dist/knowledge/journal.d.ts +16 -0
  150. package/dist/knowledge/journal.js +109 -0
  151. package/dist/knowledge/lifecycle.d.ts +8 -0
  152. package/dist/knowledge/lifecycle.js +1001 -0
  153. package/dist/knowledge/paths.d.ts +37 -0
  154. package/dist/knowledge/paths.js +236 -0
  155. package/dist/knowledge/refs.d.ts +36 -0
  156. package/dist/knowledge/refs.js +267 -0
  157. package/dist/knowledge/service.d.ts +21 -0
  158. package/dist/knowledge/service.js +393 -0
  159. package/dist/knowledge/types.d.ts +171 -0
  160. package/dist/knowledge/types.js +1 -0
  161. package/dist/knowledge/write.d.ts +8 -0
  162. package/dist/knowledge/write.js +1223 -0
  163. package/dist/package-info.d.ts +6 -0
  164. package/dist/package-info.js +19 -0
  165. package/dist/schemas/code.d.ts +377 -0
  166. package/dist/schemas/code.js +145 -0
  167. package/dist/schemas/collaboration.d.ts +115 -0
  168. package/dist/schemas/collaboration.js +106 -0
  169. package/dist/schemas/continuity.d.ts +315 -0
  170. package/dist/schemas/continuity.js +199 -0
  171. package/dist/schemas/diagnostics.d.ts +28 -0
  172. package/dist/schemas/diagnostics.js +27 -0
  173. package/dist/schemas/doctor.d.ts +157 -0
  174. package/dist/schemas/doctor.js +75 -0
  175. package/dist/schemas/document.d.ts +644 -0
  176. package/dist/schemas/document.js +296 -0
  177. package/dist/schemas/errors.d.ts +177 -0
  178. package/dist/schemas/errors.js +176 -0
  179. package/dist/schemas/evidence.d.ts +24 -0
  180. package/dist/schemas/evidence.js +16 -0
  181. package/dist/schemas/host.d.ts +436 -0
  182. package/dist/schemas/host.js +201 -0
  183. package/dist/schemas/index.d.ts +15 -0
  184. package/dist/schemas/index.js +15 -0
  185. package/dist/schemas/init.d.ts +121 -0
  186. package/dist/schemas/init.js +94 -0
  187. package/dist/schemas/install.d.ts +213 -0
  188. package/dist/schemas/install.js +139 -0
  189. package/dist/schemas/machine.d.ts +43 -0
  190. package/dist/schemas/machine.js +96 -0
  191. package/dist/schemas/outcome.d.ts +23 -0
  192. package/dist/schemas/outcome.js +17 -0
  193. package/dist/schemas/paths.d.ts +19 -0
  194. package/dist/schemas/paths.js +63 -0
  195. package/dist/schemas/workspace.d.ts +120 -0
  196. package/dist/schemas/workspace.js +201 -0
  197. package/dist/workspace/config-file.d.ts +36 -0
  198. package/dist/workspace/config-file.js +237 -0
  199. package/dist/workspace/config.d.ts +28 -0
  200. package/dist/workspace/config.js +79 -0
  201. package/dist/workspace/discover.d.ts +34 -0
  202. package/dist/workspace/discover.js +195 -0
  203. package/dist/workspace/documents.d.ts +21 -0
  204. package/dist/workspace/documents.js +395 -0
  205. package/dist/workspace/ignore.d.ts +10 -0
  206. package/dist/workspace/ignore.js +48 -0
  207. package/dist/workspace/index.d.ts +7 -0
  208. package/dist/workspace/index.js +3 -0
  209. package/dist/workspace/repositories.d.ts +24 -0
  210. package/dist/workspace/repositories.js +411 -0
  211. package/dist/workspace/resolve.d.ts +24 -0
  212. package/dist/workspace/resolve.js +268 -0
  213. package/dist/workspace/types.d.ts +71 -0
  214. package/dist/workspace/types.js +1 -0
  215. package/dist/workspace/validation.d.ts +18 -0
  216. package/dist/workspace/validation.js +197 -0
  217. package/package.json +105 -4
  218. package/skills/pappra/SKILL.md +68 -0
  219. package/skills/pappra/references/hosts.md +30 -0
  220. package/skills/pappra/references/lifecycle.md +37 -0
  221. package/skills/pappra/references/operations.md +14 -0
@@ -0,0 +1,354 @@
1
+ /** Legacy protocol data. Unknown extension fields are preserved without being executed. */
2
+ export interface Identity {
3
+ agent_id: string;
4
+ session_id: string;
5
+ harness: string | null;
6
+ cwd?: string;
7
+ }
8
+ export interface Coordinator extends Identity {
9
+ owner_epoch: number;
10
+ since: string;
11
+ previous?: Pick<Coordinator, 'agent_id' | 'session_id' | 'owner_epoch'> | null;
12
+ }
13
+ export interface ResourceInput {
14
+ kind?: string;
15
+ path?: string;
16
+ scope?: string;
17
+ port?: number;
18
+ value?: string;
19
+ label?: string;
20
+ origin?: string;
21
+ derived?: boolean;
22
+ shared?: boolean;
23
+ }
24
+ export interface Resource {
25
+ kind: string;
26
+ scope: string;
27
+ key: string;
28
+ path?: string | null;
29
+ port?: number | null;
30
+ existing?: boolean;
31
+ label: string;
32
+ origin?: string;
33
+ derived_from?: string | null;
34
+ }
35
+ export interface Claim extends Resource {
36
+ claim_id: string;
37
+ access: string;
38
+ holder: Identity;
39
+ resource_epoch: number;
40
+ claimed_at: string;
41
+ released_at: string | null;
42
+ subtask_id: string | null;
43
+ attempt: number | null;
44
+ note: string | null;
45
+ cancel_pending?: boolean;
46
+ released_by?: string;
47
+ release_reason?: string | null;
48
+ transferred_from?: Identity;
49
+ transferred_at?: string;
50
+ }
51
+ export interface MessageBody {
52
+ [key: string]: unknown;
53
+ assignment_ref?: string | null;
54
+ assignment_digest?: string | null;
55
+ input_revision?: string | null;
56
+ approval?: {
57
+ approved_by: string;
58
+ reason: string;
59
+ };
60
+ status?: string;
61
+ kind?: string;
62
+ phase?: string;
63
+ handoff_id?: string;
64
+ resources?: string[];
65
+ reason?: string | null;
66
+ outputs?: unknown[];
67
+ native_ref?: unknown;
68
+ evidence_ref?: string | null;
69
+ stop_evidence?: unknown;
70
+ }
71
+ export interface Message {
72
+ [key: string]: unknown;
73
+ schema: string;
74
+ message_id: string;
75
+ type: string;
76
+ task_id: string;
77
+ from: Identity;
78
+ to: Identity;
79
+ reply_to: string | null;
80
+ subtask_id: string | null;
81
+ attempt: number | null;
82
+ owner_epoch: number | null;
83
+ created_at: string;
84
+ content_digest: string | null;
85
+ body: MessageBody;
86
+ }
87
+ export type MessageInput = Pick<Message, 'type' | 'task_id' | 'from' | 'to'> & Partial<Pick<Message, 'message_id' | 'reply_to' | 'subtask_id' | 'attempt' | 'owner_epoch' | 'created_at' | 'body'>>;
88
+ export interface Transition {
89
+ from: string | null;
90
+ to: string;
91
+ at: string;
92
+ actor: string;
93
+ reason: string | null;
94
+ evidence: unknown;
95
+ forced?: boolean | undefined;
96
+ }
97
+ export interface NativeBinding {
98
+ runner: string | null;
99
+ session_id: string | null;
100
+ run_id: string | null;
101
+ mission_id: string | null;
102
+ observation: string;
103
+ observed_at: string | null;
104
+ evidence_ref: string | null;
105
+ manager?: string;
106
+ launch_kind?: string;
107
+ mode?: string;
108
+ identity_status?: string;
109
+ }
110
+ export interface Attempt {
111
+ subtask_id: string;
112
+ attempt: number;
113
+ state: string;
114
+ owner_epoch: number | null;
115
+ assignee: Identity;
116
+ assignment_message_id: string;
117
+ assignment_ref: string | null;
118
+ assignment_digest: string | null;
119
+ input_revision: string | null;
120
+ created_at: string;
121
+ updated_at: string;
122
+ native: NativeBinding;
123
+ approval: MessageBody['approval'] | null;
124
+ transitions: Transition[];
125
+ closed_at?: string;
126
+ awaiting?: string;
127
+ ownership?: string;
128
+ cancel_requested_at?: string;
129
+ cwd?: string;
130
+ }
131
+ export interface ResultEntry {
132
+ schema: string;
133
+ subtask_id: string;
134
+ attempt: number;
135
+ status: string;
136
+ message_id: string;
137
+ input_revision: string | null;
138
+ outputs: unknown[];
139
+ native_ref: unknown;
140
+ recorded_at: string;
141
+ evidence_ref: string | null;
142
+ classification: string;
143
+ reason: string | null;
144
+ }
145
+ export interface Uncertainty {
146
+ uncertainty_id: string;
147
+ kind: string;
148
+ subtask_id: string | null;
149
+ attempt: number | null;
150
+ detail: string | null;
151
+ evidence_ref: string | null;
152
+ resolution_hint: string | null;
153
+ opened_at: string;
154
+ resolved_at: string | null;
155
+ resolution: string | null;
156
+ resolution_evidence: unknown;
157
+ auto_restart: boolean;
158
+ resolved_by?: string;
159
+ resolution_source?: string;
160
+ }
161
+ export interface OwnershipSnapshot {
162
+ claim_id: string;
163
+ holder?: Identity | null;
164
+ resource_epoch?: number | null;
165
+ released_at?: string | null;
166
+ missing?: boolean;
167
+ }
168
+ export interface HandoffStep {
169
+ [key: string]: unknown;
170
+ state: string;
171
+ at: string;
172
+ actor: string;
173
+ }
174
+ export interface Handoff {
175
+ schema: string;
176
+ handoff_id: string;
177
+ kind: string;
178
+ subtask_id: string | null;
179
+ attempt: number | null;
180
+ from: Identity;
181
+ to: Identity;
182
+ resources: string[];
183
+ ownership_snapshot: OwnershipSnapshot[];
184
+ state: string;
185
+ owner_epoch: number;
186
+ created_at: string;
187
+ updated_at: string;
188
+ reason: string | null;
189
+ steps: HandoffStep[];
190
+ partial_outputs: unknown[];
191
+ inflight: unknown[];
192
+ pending_approvals: unknown[];
193
+ confirmation_message_id: string | null;
194
+ snapshot_at?: string;
195
+ previous_coordinator?: Coordinator | null;
196
+ resource_transfers?: {
197
+ claim_id: string;
198
+ resource_epoch: number;
199
+ from: Identity;
200
+ }[];
201
+ }
202
+ export interface AppliedMessage {
203
+ message_id: string;
204
+ type: string;
205
+ subtask_id: string | null;
206
+ attempt: number | null;
207
+ from: Identity;
208
+ to: Identity | null;
209
+ reply_to: string | null;
210
+ owner_epoch: number | null;
211
+ content_digest: string;
212
+ at: string;
213
+ applied_at: string;
214
+ state: string;
215
+ detail: string;
216
+ body_kind: string | null;
217
+ }
218
+ export interface Notification {
219
+ schema: string;
220
+ kind: string;
221
+ origin_session: string;
222
+ target_session: string;
223
+ depth?: number;
224
+ task_id: string;
225
+ subtask_id?: string | null;
226
+ attempt?: number | null;
227
+ event?: unknown;
228
+ }
229
+ export interface NotificationEntry {
230
+ notification_id: string;
231
+ key: string;
232
+ kind: string;
233
+ task_id: string;
234
+ subtask_id: string | null;
235
+ attempt: number | null;
236
+ origin_session: string;
237
+ target_session: string;
238
+ depth: number;
239
+ at: string;
240
+ decision: string;
241
+ reason: string | null;
242
+ }
243
+ export interface TaskRecord {
244
+ [key: string]: unknown;
245
+ schema: string;
246
+ task_id: string;
247
+ domain_id: string;
248
+ domain_root: string;
249
+ task_root: string;
250
+ created_at: string;
251
+ updated_at: string;
252
+ state_revision: number;
253
+ coordinator: Coordinator | null;
254
+ input_revision: string | null;
255
+ policy: {
256
+ [key: string]: unknown;
257
+ };
258
+ attempts: Attempt[];
259
+ messages: AppliedMessage[];
260
+ claims: Claim[];
261
+ handoffs: Handoff[];
262
+ uncertainty: Uncertainty[];
263
+ results: ResultEntry[];
264
+ native: unknown[];
265
+ dispatch_frozen?: boolean;
266
+ dispatch_released_at?: string;
267
+ dispatch_released_by?: string;
268
+ notifications?: NotificationEntry[];
269
+ notifications_trimmed?: number;
270
+ launch_reservations?: LaunchReservation[];
271
+ }
272
+ export interface ReservationInput {
273
+ reservation_id: string;
274
+ subtask_id: string;
275
+ attempt: number;
276
+ kind: string;
277
+ mode: string;
278
+ holder: Identity;
279
+ requested_session_id: string | null;
280
+ phase?: string;
281
+ pid?: number;
282
+ resume_selector?: string | null;
283
+ transport?: string;
284
+ [key: string]: unknown;
285
+ }
286
+ export interface LaunchReservation extends ReservationInput {
287
+ reserved_at: string;
288
+ released_at: string | null;
289
+ outcome: string | null;
290
+ exit_code?: number | null;
291
+ session_id?: string | null;
292
+ run_id?: string | null;
293
+ detail?: string | null;
294
+ identity_status?: string;
295
+ expected_identity?: string | null;
296
+ observed_identity?: string | null;
297
+ }
298
+ export interface Failure {
299
+ ok: false;
300
+ reason: string;
301
+ record?: never;
302
+ result?: never;
303
+ commit?: never;
304
+ [key: string]: unknown;
305
+ }
306
+ export interface UnreadableRecord {
307
+ task_id: string;
308
+ __unreadable: true;
309
+ claims: Claim[];
310
+ }
311
+ export interface Mutation<T = unknown> {
312
+ ok?: boolean;
313
+ commit?: boolean;
314
+ record: TaskRecord;
315
+ op?: string;
316
+ summary?: unknown;
317
+ result?: T;
318
+ [key: string]: unknown;
319
+ }
320
+ export interface MessageEffect {
321
+ [key: string]: unknown;
322
+ entry?: ResultEntry;
323
+ }
324
+ export type TransactionResult<T> = {
325
+ ok: true;
326
+ state_revision: number;
327
+ result: T | null;
328
+ op: string;
329
+ } | {
330
+ ok: false;
331
+ reason: string;
332
+ [key: string]: unknown;
333
+ };
334
+ export interface LockHolder {
335
+ schema: string;
336
+ nonce: string;
337
+ actor: string;
338
+ purpose: string;
339
+ pid: number;
340
+ hostname: string;
341
+ acquired_at: string;
342
+ }
343
+ export interface TransactionFile {
344
+ file: string;
345
+ revision: unknown;
346
+ purpose: unknown;
347
+ actor: unknown;
348
+ }
349
+ export interface Finding {
350
+ code: string;
351
+ severity: string;
352
+ detail: string;
353
+ [key: string]: unknown;
354
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { TaskRecord, LockHolder, Message, Notification } from './types.js';
2
+ /** Decode external JSON as unknown; protocol validators establish the usable shape. */
3
+ export declare function object(value: unknown): value is Record<string, unknown>;
4
+ export declare function text(value: unknown): value is string;
5
+ export declare function errorCode(error: unknown): string | undefined;
6
+ export declare function parseJson(text: string): unknown;
7
+ export declare function isTaskRecord(value: unknown): value is TaskRecord;
8
+ export declare function isLockHolder(value: unknown): value is LockHolder;
9
+ export declare function isMessage(value: unknown): value is Message;
10
+ export declare function isNotification(value: unknown): value is Notification;
@@ -0,0 +1,303 @@
1
+ /** Decode external JSON as unknown; protocol validators establish the usable shape. */
2
+ export function object(value) {
3
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
4
+ }
5
+ export function text(value) {
6
+ return typeof value === 'string' && value.trim().length > 0;
7
+ }
8
+ export function errorCode(error) {
9
+ return object(error) && typeof error['code'] === 'string'
10
+ ? error['code']
11
+ : undefined;
12
+ }
13
+ export function parseJson(text) {
14
+ return JSON.parse(text);
15
+ }
16
+ const string = (value) => typeof value === 'string';
17
+ const number = (value) => typeof value === 'number' && Number.isSafeInteger(value);
18
+ const nullable = (test) => (value) => value === null || test(value);
19
+ const optional = (test) => (value) => value === undefined || test(value);
20
+ const array = (test) => (value) => Array.isArray(value) && value.every(test);
21
+ function shape(value, fields) {
22
+ return (object(value) &&
23
+ Object.entries(fields).every(([key, test]) => test(value[key])));
24
+ }
25
+ const identity = (value) => shape(value, {
26
+ agent_id: string,
27
+ session_id: string,
28
+ harness: nullable(string),
29
+ cwd: optional(string),
30
+ });
31
+ const coordinator = (value) => identity(value) &&
32
+ shape(value, {
33
+ owner_epoch: number,
34
+ since: string,
35
+ previous: optional(nullable((item) => shape(item, {
36
+ agent_id: string,
37
+ session_id: string,
38
+ owner_epoch: number,
39
+ }))),
40
+ });
41
+ const native = (value) => shape(value, {
42
+ runner: nullable(string),
43
+ session_id: nullable(string),
44
+ run_id: nullable(string),
45
+ mission_id: nullable(string),
46
+ observation: string,
47
+ observed_at: nullable(string),
48
+ evidence_ref: nullable(string),
49
+ manager: optional(string),
50
+ launch_kind: optional(string),
51
+ mode: optional(string),
52
+ identity_status: optional(string),
53
+ });
54
+ const transition = (value) => shape(value, {
55
+ from: nullable(string),
56
+ to: string,
57
+ at: string,
58
+ actor: string,
59
+ reason: nullable(string),
60
+ });
61
+ const approval = (value) => shape(value, { approved_by: string, reason: string });
62
+ const attempt = (value) => shape(value, {
63
+ subtask_id: string,
64
+ attempt: number,
65
+ state: string,
66
+ owner_epoch: nullable(number),
67
+ assignee: identity,
68
+ assignment_message_id: string,
69
+ assignment_ref: nullable(string),
70
+ assignment_digest: nullable(string),
71
+ input_revision: nullable(string),
72
+ created_at: string,
73
+ updated_at: string,
74
+ native,
75
+ approval: nullable(approval),
76
+ transitions: array(transition),
77
+ closed_at: optional(string),
78
+ awaiting: optional(string),
79
+ ownership: optional(string),
80
+ cancel_requested_at: optional(string),
81
+ cwd: optional(string),
82
+ });
83
+ const claim = (value) => shape(value, {
84
+ claim_id: string,
85
+ key: string,
86
+ kind: string,
87
+ scope: string,
88
+ label: string,
89
+ path: optional(nullable(string)),
90
+ port: optional(nullable(number)),
91
+ origin: optional(string),
92
+ derived_from: optional(nullable(string)),
93
+ access: string,
94
+ holder: identity,
95
+ resource_epoch: number,
96
+ claimed_at: string,
97
+ released_at: nullable(string),
98
+ subtask_id: nullable(string),
99
+ attempt: nullable(number),
100
+ note: nullable(string),
101
+ cancel_pending: optional((item) => typeof item === 'boolean'),
102
+ released_by: optional(string),
103
+ release_reason: optional(nullable(string)),
104
+ transferred_from: optional(identity),
105
+ transferred_at: optional(string),
106
+ });
107
+ const appliedMessage = (value) => shape(value, {
108
+ message_id: string,
109
+ type: string,
110
+ subtask_id: nullable(string),
111
+ attempt: nullable(number),
112
+ from: identity,
113
+ to: nullable(identity),
114
+ reply_to: nullable(string),
115
+ owner_epoch: nullable(number),
116
+ content_digest: string,
117
+ at: string,
118
+ applied_at: string,
119
+ state: string,
120
+ detail: string,
121
+ body_kind: nullable(string),
122
+ });
123
+ const uncertainty = (value) => shape(value, {
124
+ uncertainty_id: string,
125
+ kind: string,
126
+ subtask_id: nullable(string),
127
+ attempt: nullable(number),
128
+ detail: nullable(string),
129
+ evidence_ref: nullable(string),
130
+ resolution_hint: nullable(string),
131
+ opened_at: string,
132
+ resolved_at: nullable(string),
133
+ resolution: nullable(string),
134
+ auto_restart: (item) => typeof item === 'boolean',
135
+ resolved_by: optional(string),
136
+ resolution_source: optional(string),
137
+ });
138
+ const result = (value) => shape(value, {
139
+ schema: string,
140
+ subtask_id: string,
141
+ attempt: number,
142
+ status: string,
143
+ message_id: string,
144
+ input_revision: nullable(string),
145
+ outputs: Array.isArray,
146
+ recorded_at: string,
147
+ evidence_ref: nullable(string),
148
+ classification: string,
149
+ reason: nullable(string),
150
+ });
151
+ const snapshot = (value) => shape(value, {
152
+ claim_id: string,
153
+ holder: optional(nullable(identity)),
154
+ resource_epoch: optional(nullable(number)),
155
+ released_at: optional(nullable(string)),
156
+ missing: optional((item) => typeof item === 'boolean'),
157
+ });
158
+ const handoff = (value) => shape(value, {
159
+ schema: string,
160
+ handoff_id: string,
161
+ kind: string,
162
+ subtask_id: nullable(string),
163
+ attempt: nullable(number),
164
+ from: identity,
165
+ to: identity,
166
+ resources: array(string),
167
+ ownership_snapshot: array(snapshot),
168
+ state: string,
169
+ owner_epoch: number,
170
+ created_at: string,
171
+ updated_at: string,
172
+ reason: nullable(string),
173
+ steps: array((item) => shape(item, { state: string, at: string, actor: string })),
174
+ partial_outputs: Array.isArray,
175
+ inflight: Array.isArray,
176
+ pending_approvals: Array.isArray,
177
+ confirmation_message_id: nullable(string),
178
+ snapshot_at: optional(string),
179
+ previous_coordinator: optional(nullable(coordinator)),
180
+ resource_transfers: optional(array((item) => shape(item, {
181
+ claim_id: string,
182
+ resource_epoch: number,
183
+ from: identity,
184
+ }))),
185
+ });
186
+ const notificationEntry = (value) => shape(value, {
187
+ notification_id: string,
188
+ key: string,
189
+ kind: string,
190
+ task_id: string,
191
+ subtask_id: nullable(string),
192
+ attempt: nullable(number),
193
+ origin_session: string,
194
+ target_session: string,
195
+ depth: number,
196
+ at: string,
197
+ decision: string,
198
+ reason: nullable(string),
199
+ });
200
+ const reservation = (value) => shape(value, {
201
+ reservation_id: string,
202
+ subtask_id: string,
203
+ attempt: number,
204
+ kind: string,
205
+ mode: string,
206
+ holder: identity,
207
+ requested_session_id: nullable(string),
208
+ reserved_at: string,
209
+ released_at: nullable(string),
210
+ outcome: nullable(string),
211
+ phase: optional(string),
212
+ pid: optional(number),
213
+ resume_selector: optional(nullable(string)),
214
+ transport: optional(string),
215
+ exit_code: optional(nullable(number)),
216
+ session_id: optional(nullable(string)),
217
+ run_id: optional(nullable(string)),
218
+ detail: optional(nullable(string)),
219
+ identity_status: optional(string),
220
+ expected_identity: optional(nullable(string)),
221
+ observed_identity: optional(nullable(string)),
222
+ });
223
+ export function isTaskRecord(value) {
224
+ return shape(value, {
225
+ schema: string,
226
+ task_id: string,
227
+ domain_id: string,
228
+ domain_root: string,
229
+ task_root: string,
230
+ created_at: string,
231
+ updated_at: string,
232
+ state_revision: number,
233
+ coordinator: nullable(coordinator),
234
+ input_revision: nullable(string),
235
+ policy: object,
236
+ attempts: array(attempt),
237
+ messages: array(appliedMessage),
238
+ claims: array(claim),
239
+ handoffs: array(handoff),
240
+ uncertainty: array(uncertainty),
241
+ results: array(result),
242
+ native: Array.isArray,
243
+ dispatch_frozen: optional((item) => typeof item === 'boolean'),
244
+ dispatch_released_at: optional(string),
245
+ dispatch_released_by: optional(string),
246
+ notifications: optional(array(notificationEntry)),
247
+ notifications_trimmed: optional(number),
248
+ launch_reservations: optional(array(reservation)),
249
+ });
250
+ }
251
+ export function isLockHolder(value) {
252
+ return shape(value, {
253
+ schema: string,
254
+ nonce: string,
255
+ actor: string,
256
+ purpose: string,
257
+ pid: number,
258
+ hostname: string,
259
+ acquired_at: string,
260
+ });
261
+ }
262
+ export function isMessage(value) {
263
+ return shape(value, {
264
+ schema: string,
265
+ message_id: string,
266
+ type: string,
267
+ task_id: string,
268
+ from: identity,
269
+ to: identity,
270
+ reply_to: nullable(string),
271
+ subtask_id: nullable(string),
272
+ attempt: nullable(number),
273
+ owner_epoch: nullable(number),
274
+ created_at: string,
275
+ content_digest: nullable(string),
276
+ body: (body) => shape(body, {
277
+ assignment_ref: optional(nullable(string)),
278
+ assignment_digest: optional(nullable(string)),
279
+ input_revision: optional(nullable(string)),
280
+ approval: optional(approval),
281
+ status: optional(string),
282
+ kind: optional(string),
283
+ phase: optional(string),
284
+ handoff_id: optional(string),
285
+ resources: optional(array(string)),
286
+ reason: optional(nullable(string)),
287
+ outputs: optional(Array.isArray),
288
+ evidence_ref: optional(nullable(string)),
289
+ }),
290
+ });
291
+ }
292
+ export function isNotification(value) {
293
+ return shape(value, {
294
+ schema: string,
295
+ kind: string,
296
+ origin_session: string,
297
+ target_session: string,
298
+ task_id: string,
299
+ depth: optional(number),
300
+ subtask_id: optional(nullable(string)),
301
+ attempt: optional(nullable(number)),
302
+ });
303
+ }
@@ -0,0 +1,24 @@
1
+ import type { Diagnostic } from '../schemas/diagnostics.js';
2
+ import type { Checkpoint } from '../schemas/continuity.js';
3
+ import type { MachineConfig } from '../schemas/machine.js';
4
+ import type { WorkspaceConfig } from '../schemas/workspace.js';
5
+ import type { DiscoveredRepository } from '../workspace/types.js';
6
+ export interface ContinuityWorkspace {
7
+ readonly root: string;
8
+ readonly config: WorkspaceConfig;
9
+ readonly machine: MachineConfig | null;
10
+ readonly repositories: readonly DiscoveredRepository[];
11
+ readonly diagnostics: readonly Diagnostic[];
12
+ }
13
+ export interface ContinuityWorkspaceResult {
14
+ readonly ok: boolean;
15
+ readonly workspace: ContinuityWorkspace | null;
16
+ readonly diagnostics: readonly Diagnostic[];
17
+ }
18
+ export interface RepositorySnapshot {
19
+ readonly record: Checkpoint['repositories'][number];
20
+ readonly patchBytes: Buffer | null;
21
+ }
22
+ export declare function loadContinuityWorkspace(root: string): Promise<ContinuityWorkspaceResult>;
23
+ export declare function snapshotRepository(workspace: ContinuityWorkspace, repository: DiscoveredRepository, index: number): Promise<RepositorySnapshot>;
24
+ export declare function continuityDiagnostic(message: string, source: string, hint: string): Diagnostic;