@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,106 @@
1
+ import { z } from 'zod';
2
+ const taskId = z
3
+ .string()
4
+ .min(1)
5
+ .max(128)
6
+ .regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);
7
+ const absolutePath = z
8
+ .string()
9
+ .min(1)
10
+ .max(4096)
11
+ .refine((value) => value.startsWith('/'), {
12
+ message: 'path must be absolute',
13
+ });
14
+ const identity = z.strictObject({
15
+ agent_id: z.string().min(1).max(128),
16
+ session_id: z.string().min(1).max(256),
17
+ harness: z.string().min(1).max(64),
18
+ });
19
+ const requirements = z.strictObject({
20
+ skills: z
21
+ .array(z.strictObject({
22
+ id: z.string().min(1),
23
+ bundle_digest: z.string().min(1),
24
+ }))
25
+ .max(16),
26
+ tools: z.array(z.string().min(1).max(128)).max(32),
27
+ });
28
+ const resource = z.strictObject({
29
+ path: absolutePath,
30
+ access: z.enum(['read', 'write']),
31
+ });
32
+ export const collaborationGoalSchema = z.strictObject({
33
+ schema: z.literal('pappra/collaboration-goal/1'),
34
+ task_id: taskId,
35
+ subtask_id: taskId,
36
+ attempt: z.number().int().min(1).max(1000),
37
+ phase: z.enum(['discovery', 'implementation', 'review', 'handoff', 'fix']),
38
+ objective: z.string().min(1).max(4000),
39
+ acceptance: z.array(z.string().min(1).max(1000)).min(1).max(32),
40
+ prompt: z.string().min(1).max(20000),
41
+ coordinator: identity.extend({ owner_epoch: z.number().int().min(1) }),
42
+ assignee: identity.extend({
43
+ cwd: absolutePath,
44
+ surface: z.string().min(1).max(64),
45
+ configuration_id: z.string().min(1).max(128),
46
+ }),
47
+ resources: z.array(resource).min(1).max(32),
48
+ required: requirements,
49
+ preferred: requirements.default({ skills: [], tools: [] }),
50
+ });
51
+ export const collaborationPreparedSchema = z.strictObject({
52
+ schema: z.literal('pappra/collaboration-prepared/1'),
53
+ task_id: taskId,
54
+ subtask_id: taskId,
55
+ attempt: z.number().int().min(1),
56
+ phase: z.string().min(1).max(32),
57
+ task_root: absolutePath,
58
+ domain_root: absolutePath,
59
+ prepared_dir: absolutePath,
60
+ assignment_path: absolutePath,
61
+ prompt_path: absolutePath,
62
+ goal_path: absolutePath,
63
+ assignment_digest: z.string().min(1),
64
+ prompt_digest: z.string().min(1),
65
+ resource_epochs: z.record(z.string(), z.number().int().min(1)),
66
+ claim_ids: z.array(z.string().min(1)).max(64),
67
+ state_revision: z.number().int().min(0),
68
+ created_at: z.string().min(1),
69
+ });
70
+ export const collaborationCommandSchema = z.discriminatedUnion('action', [
71
+ z.strictObject({
72
+ schema: z.literal('pappra/collaboration-command/1'),
73
+ action: z.literal('query'),
74
+ request_id: z.string().min(1).max(128),
75
+ }),
76
+ z.strictObject({
77
+ schema: z.literal('pappra/collaboration-command/1'),
78
+ action: z.literal('cancel'),
79
+ request_id: z.string().min(1).max(128),
80
+ }),
81
+ z.strictObject({
82
+ schema: z.literal('pappra/collaboration-command/1'),
83
+ action: z.literal('finish'),
84
+ request_id: z.string().min(1).max(128),
85
+ status: z.enum([
86
+ 'completed',
87
+ 'failed',
88
+ 'cancelled',
89
+ 'needs_input',
90
+ 'unknown',
91
+ ]),
92
+ outputs: z.array(z.unknown()).max(32).default([]),
93
+ native_ref: z.unknown().nullable().default(null),
94
+ evidence_ref: z.string().max(4096).nullable().default(null),
95
+ }),
96
+ ]);
97
+ export const collaborationEventSchema = z.strictObject({
98
+ schema: z.literal('pappra/collaboration-event/1'),
99
+ sequence: z.number().int().min(1),
100
+ request_id: z.string().min(1).max(128).nullable(),
101
+ kind: z.enum(['started', 'query', 'cancel', 'finished', 'refused', 'report']),
102
+ at: z.string().min(1),
103
+ status: z.string().min(1).max(64),
104
+ detail: z.string().max(4096).nullable(),
105
+ data: z.unknown().nullable(),
106
+ });
@@ -0,0 +1,315 @@
1
+ import { z } from 'zod';
2
+ export declare const TASK_CONTEXT_SCHEMA = "pappra/task-context/1";
3
+ export declare const CHECKPOINT_SCHEMA = "pappra/checkpoint/1";
4
+ export declare const CHECKPOINT_POINTER_SCHEMA = "pappra/checkpoint-pointer/1";
5
+ export declare const RESUME_PACKET_SCHEMA = "pappra/resume-packet/1";
6
+ export declare const continuityArtifactPathSchema: z.ZodString;
7
+ export declare const taskContextSchema: z.ZodObject<{
8
+ schema: z.ZodLiteral<"pappra/task-context/1">;
9
+ taskId: z.ZodString;
10
+ workspaceId: z.ZodUUID;
11
+ objective: z.ZodString;
12
+ acceptance: z.ZodArray<z.ZodString>;
13
+ constraints: z.ZodArray<z.ZodString>;
14
+ artifacts: z.ZodArray<z.ZodString>;
15
+ collaborationRecordRef: z.ZodNullable<z.ZodString>;
16
+ createdAt: z.ZodISODateTime;
17
+ updatedAt: z.ZodISODateTime;
18
+ }, z.core.$strict>;
19
+ export type TaskContext = z.infer<typeof taskContextSchema>;
20
+ export declare const checkpointRepositorySchema: z.ZodObject<{
21
+ repoId: z.ZodString;
22
+ checkoutId: z.ZodString;
23
+ root: z.ZodString;
24
+ head: z.ZodNullable<z.ZodString>;
25
+ branch: z.ZodNullable<z.ZodString>;
26
+ dirty: z.ZodNullable<z.ZodBoolean>;
27
+ patchDigest: z.ZodNullable<z.ZodString>;
28
+ captureStatus: z.ZodEnum<{
29
+ complete: "complete";
30
+ partial: "partial";
31
+ unknown: "unknown";
32
+ }>;
33
+ scope: z.ZodEnum<{
34
+ external: "external";
35
+ unknown: "unknown";
36
+ workspace: "workspace";
37
+ }>;
38
+ }, z.core.$strict>;
39
+ export declare const checkpointArtifactSchema: z.ZodObject<{
40
+ path: z.ZodString;
41
+ digest: z.ZodString;
42
+ inputVersion: z.ZodNullable<z.ZodString>;
43
+ observedAt: z.ZodISODateTime;
44
+ }, z.core.$strict>;
45
+ export declare const checkpointValidationSchema: z.ZodObject<{
46
+ id: z.ZodString;
47
+ result: z.ZodEnum<{
48
+ failed: "failed";
49
+ "not-run": "not-run";
50
+ passed: "passed";
51
+ unknown: "unknown";
52
+ }>;
53
+ inputVersion: z.ZodNullable<z.ZodString>;
54
+ observedAt: z.ZodISODateTime;
55
+ }, z.core.$strict>;
56
+ export declare const checkpointNativeRefSchema: z.ZodObject<{
57
+ harness: z.ZodEnum<{
58
+ claude: "claude";
59
+ codex: "codex";
60
+ pi: "pi";
61
+ unknown: "unknown";
62
+ }>;
63
+ sessionId: z.ZodNullable<z.ZodString>;
64
+ turnId: z.ZodNullable<z.ZodString>;
65
+ runId: z.ZodNullable<z.ZodString>;
66
+ scope: z.ZodLiteral<"stored-snapshot">;
67
+ observedAt: z.ZodISODateTime;
68
+ }, z.core.$strict>;
69
+ export declare const checkpointSchema: z.ZodObject<{
70
+ schema: z.ZodLiteral<"pappra/checkpoint/1">;
71
+ checkpointId: z.ZodUUID;
72
+ taskId: z.ZodString;
73
+ workspaceId: z.ZodUUID;
74
+ revision: z.ZodNumber;
75
+ previousDigest: z.ZodNullable<z.ZodString>;
76
+ createdAt: z.ZodISODateTime;
77
+ authorSession: z.ZodNullable<z.ZodString>;
78
+ objective: z.ZodString;
79
+ acceptance: z.ZodArray<z.ZodString>;
80
+ constraints: z.ZodArray<z.ZodString>;
81
+ decisions: z.ZodArray<z.ZodString>;
82
+ attempted: z.ZodArray<z.ZodString>;
83
+ nextActions: z.ZodArray<z.ZodString>;
84
+ limitations: z.ZodArray<z.ZodString>;
85
+ repositories: z.ZodArray<z.ZodObject<{
86
+ repoId: z.ZodString;
87
+ checkoutId: z.ZodString;
88
+ root: z.ZodString;
89
+ head: z.ZodNullable<z.ZodString>;
90
+ branch: z.ZodNullable<z.ZodString>;
91
+ dirty: z.ZodNullable<z.ZodBoolean>;
92
+ patchDigest: z.ZodNullable<z.ZodString>;
93
+ captureStatus: z.ZodEnum<{
94
+ complete: "complete";
95
+ partial: "partial";
96
+ unknown: "unknown";
97
+ }>;
98
+ scope: z.ZodEnum<{
99
+ external: "external";
100
+ unknown: "unknown";
101
+ workspace: "workspace";
102
+ }>;
103
+ }, z.core.$strict>>;
104
+ artifacts: z.ZodArray<z.ZodObject<{
105
+ path: z.ZodString;
106
+ digest: z.ZodString;
107
+ inputVersion: z.ZodNullable<z.ZodString>;
108
+ observedAt: z.ZodISODateTime;
109
+ }, z.core.$strict>>;
110
+ validations: z.ZodArray<z.ZodObject<{
111
+ id: z.ZodString;
112
+ result: z.ZodEnum<{
113
+ failed: "failed";
114
+ "not-run": "not-run";
115
+ passed: "passed";
116
+ unknown: "unknown";
117
+ }>;
118
+ inputVersion: z.ZodNullable<z.ZodString>;
119
+ observedAt: z.ZodISODateTime;
120
+ }, z.core.$strict>>;
121
+ nativeRefs: z.ZodArray<z.ZodObject<{
122
+ harness: z.ZodEnum<{
123
+ claude: "claude";
124
+ codex: "codex";
125
+ pi: "pi";
126
+ unknown: "unknown";
127
+ }>;
128
+ sessionId: z.ZodNullable<z.ZodString>;
129
+ turnId: z.ZodNullable<z.ZodString>;
130
+ runId: z.ZodNullable<z.ZodString>;
131
+ scope: z.ZodLiteral<"stored-snapshot">;
132
+ observedAt: z.ZodISODateTime;
133
+ }, z.core.$strict>>;
134
+ collaborationRecordRef: z.ZodNullable<z.ZodString>;
135
+ contextCompleteness: z.ZodEnum<{
136
+ complete: "complete";
137
+ partial: "partial";
138
+ }>;
139
+ }, z.core.$strict>;
140
+ export type Checkpoint = z.infer<typeof checkpointSchema>;
141
+ export declare const checkpointPointerSchema: z.ZodObject<{
142
+ schema: z.ZodLiteral<"pappra/checkpoint-pointer/1">;
143
+ taskId: z.ZodString;
144
+ workspaceId: z.ZodUUID;
145
+ revision: z.ZodNumber;
146
+ checkpointRef: z.ZodString;
147
+ checkpointDigest: z.ZodString;
148
+ updatedAt: z.ZodISODateTime;
149
+ }, z.core.$strict>;
150
+ export type CheckpointPointer = z.infer<typeof checkpointPointerSchema>;
151
+ export declare const resumePacketSchema: z.ZodObject<{
152
+ schema: z.ZodLiteral<"pappra/resume-packet/1">;
153
+ generatedAt: z.ZodISODateTime;
154
+ taskId: z.ZodString;
155
+ workspaceId: z.ZodUUID;
156
+ checkpoint: z.ZodObject<{
157
+ ref: z.ZodString;
158
+ digest: z.ZodString;
159
+ revision: z.ZodNumber;
160
+ }, z.core.$strict>;
161
+ identityChecks: z.ZodArray<z.ZodObject<{
162
+ name: z.ZodString;
163
+ status: z.ZodEnum<{
164
+ changed: "changed";
165
+ ok: "ok";
166
+ unknown: "unknown";
167
+ }>;
168
+ detail: z.ZodNullable<z.ZodString>;
169
+ }, z.core.$strict>>;
170
+ codeDrift: z.ZodObject<{
171
+ status: z.ZodEnum<{
172
+ changed: "changed";
173
+ relocated: "relocated";
174
+ unchanged: "unchanged";
175
+ unknown: "unknown";
176
+ }>;
177
+ repositories: z.ZodArray<z.ZodObject<{
178
+ repoId: z.ZodString;
179
+ status: z.ZodEnum<{
180
+ changed: "changed";
181
+ missing: "missing";
182
+ relocated: "relocated";
183
+ unchanged: "unchanged";
184
+ unknown: "unknown";
185
+ }>;
186
+ storedHead: z.ZodNullable<z.ZodString>;
187
+ currentHead: z.ZodNullable<z.ZodString>;
188
+ storedDirty: z.ZodNullable<z.ZodBoolean>;
189
+ currentDirty: z.ZodNullable<z.ZodBoolean>;
190
+ storedPatchDigest: z.ZodNullable<z.ZodString>;
191
+ currentPatchDigest: z.ZodNullable<z.ZodString>;
192
+ storedCheckoutId: z.ZodString;
193
+ currentCheckoutId: z.ZodNullable<z.ZodString>;
194
+ storedCaptureStatus: z.ZodEnum<{
195
+ complete: "complete";
196
+ partial: "partial";
197
+ unknown: "unknown";
198
+ }>;
199
+ currentCaptureStatus: z.ZodEnum<{
200
+ complete: "complete";
201
+ partial: "partial";
202
+ unknown: "unknown";
203
+ }>;
204
+ patchStatus: z.ZodEnum<{
205
+ changed: "changed";
206
+ missing: "missing";
207
+ "not-applicable": "not-applicable";
208
+ unchanged: "unchanged";
209
+ unknown: "unknown";
210
+ unsafe: "unsafe";
211
+ }>;
212
+ patchDetail: z.ZodNullable<z.ZodString>;
213
+ detail: z.ZodNullable<z.ZodString>;
214
+ }, z.core.$strict>>;
215
+ }, z.core.$strict>;
216
+ artifactChecks: z.ZodArray<z.ZodObject<{
217
+ path: z.ZodString;
218
+ status: z.ZodEnum<{
219
+ changed: "changed";
220
+ missing: "missing";
221
+ unchanged: "unchanged";
222
+ unknown: "unknown";
223
+ unsafe: "unsafe";
224
+ }>;
225
+ detail: z.ZodNullable<z.ZodString>;
226
+ }, z.core.$strict>>;
227
+ executionObservations: z.ZodArray<z.ZodObject<{
228
+ harness: z.ZodEnum<{
229
+ claude: "claude";
230
+ codex: "codex";
231
+ pi: "pi";
232
+ unknown: "unknown";
233
+ }>;
234
+ sessionId: z.ZodNullable<z.ZodString>;
235
+ turnId: z.ZodNullable<z.ZodString>;
236
+ runId: z.ZodNullable<z.ZodString>;
237
+ scope: z.ZodLiteral<"stored-snapshot">;
238
+ liveStatus: z.ZodLiteral<"unknown">;
239
+ observedAt: z.ZodISODateTime;
240
+ }, z.core.$strict>>;
241
+ collaborationObservation: z.ZodObject<{
242
+ ref: z.ZodNullable<z.ZodString>;
243
+ status: z.ZodEnum<{
244
+ missing: "missing";
245
+ "not-referenced": "not-referenced";
246
+ read: "read";
247
+ unreadable: "unreadable";
248
+ unsupported: "unsupported";
249
+ }>;
250
+ digest: z.ZodNullable<z.ZodString>;
251
+ authority: z.ZodObject<{
252
+ valid: z.ZodBoolean;
253
+ stateRevision: z.ZodNullable<z.ZodNumber>;
254
+ ownerEpoch: z.ZodNullable<z.ZodNumber>;
255
+ dispatchFrozen: z.ZodNullable<z.ZodBoolean>;
256
+ activeAttempts: z.ZodNullable<z.ZodNumber>;
257
+ unreleasedClaims: z.ZodNullable<z.ZodNumber>;
258
+ unresolvedUncertainty: z.ZodNullable<z.ZodNumber>;
259
+ pendingApprovals: z.ZodNullable<z.ZodNumber>;
260
+ blockerCodes: z.ZodArray<z.ZodString>;
261
+ }, z.core.$strict>;
262
+ scope: z.ZodLiteral<"persisted-history">;
263
+ liveStatus: z.ZodLiteral<"unknown">;
264
+ }, z.core.$strict>;
265
+ blockingReasons: z.ZodArray<z.ZodObject<{
266
+ code: z.ZodString;
267
+ message: z.ZodString;
268
+ }, z.core.$strict>>;
269
+ executionAllowed: z.ZodBoolean;
270
+ contextCompleteness: z.ZodEnum<{
271
+ complete: "complete";
272
+ partial: "partial";
273
+ }>;
274
+ verificationStatus: z.ZodEnum<{
275
+ current: "current";
276
+ stale: "stale";
277
+ unknown: "unknown";
278
+ }>;
279
+ boundedContext: z.ZodObject<{
280
+ objective: z.ZodString;
281
+ acceptance: z.ZodArray<z.ZodString>;
282
+ constraints: z.ZodArray<z.ZodString>;
283
+ decisions: z.ZodArray<z.ZodString>;
284
+ attempted: z.ZodArray<z.ZodString>;
285
+ nextActions: z.ZodArray<z.ZodString>;
286
+ limitations: z.ZodArray<z.ZodString>;
287
+ repositories: z.ZodArray<z.ZodObject<{
288
+ repoId: z.ZodString;
289
+ checkoutId: z.ZodString;
290
+ root: z.ZodString;
291
+ head: z.ZodNullable<z.ZodString>;
292
+ branch: z.ZodNullable<z.ZodString>;
293
+ dirty: z.ZodNullable<z.ZodBoolean>;
294
+ patchDigest: z.ZodNullable<z.ZodString>;
295
+ captureStatus: z.ZodEnum<{
296
+ complete: "complete";
297
+ partial: "partial";
298
+ unknown: "unknown";
299
+ }>;
300
+ scope: z.ZodEnum<{
301
+ external: "external";
302
+ unknown: "unknown";
303
+ workspace: "workspace";
304
+ }>;
305
+ }, z.core.$strict>>;
306
+ artifacts: z.ZodArray<z.ZodObject<{
307
+ path: z.ZodString;
308
+ digest: z.ZodString;
309
+ inputVersion: z.ZodNullable<z.ZodString>;
310
+ observedAt: z.ZodISODateTime;
311
+ }, z.core.$strict>>;
312
+ truncated: z.ZodBoolean;
313
+ }, z.core.$strict>;
314
+ }, z.core.$strict>;
315
+ export type ResumePacket = z.infer<typeof resumePacketSchema>;
@@ -0,0 +1,199 @@
1
+ import { z } from 'zod';
2
+ export const TASK_CONTEXT_SCHEMA = 'pappra/task-context/1';
3
+ export const CHECKPOINT_SCHEMA = 'pappra/checkpoint/1';
4
+ export const CHECKPOINT_POINTER_SCHEMA = 'pappra/checkpoint-pointer/1';
5
+ export const RESUME_PACKET_SCHEMA = 'pappra/resume-packet/1';
6
+ const digestSchema = z.string().regex(/^sha256:[0-9a-f]{64}$/);
7
+ const taskIdSchema = z
8
+ .string()
9
+ .min(1)
10
+ .max(64)
11
+ .regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);
12
+ const digestOrNull = digestSchema.nullable();
13
+ const optionalString = z.string().max(4096).nullable();
14
+ export const continuityArtifactPathSchema = z
15
+ .string()
16
+ .min(1)
17
+ .max(2048)
18
+ .refine((value) => !value.includes('\0') && !value.split('/').includes('..'), 'Artifact path must not contain NUL or parent traversal.');
19
+ export const taskContextSchema = z.strictObject({
20
+ schema: z.literal(TASK_CONTEXT_SCHEMA),
21
+ taskId: taskIdSchema,
22
+ workspaceId: z.uuid(),
23
+ objective: z.string().min(1).max(4096),
24
+ acceptance: z.array(z.string().min(1).max(4096)).max(32),
25
+ constraints: z.array(z.string().min(1).max(4096)).max(32),
26
+ artifacts: z.array(continuityArtifactPathSchema).max(64),
27
+ collaborationRecordRef: optionalString,
28
+ createdAt: z.iso.datetime({ offset: true }),
29
+ updatedAt: z.iso.datetime({ offset: true }),
30
+ });
31
+ export const checkpointRepositorySchema = z.strictObject({
32
+ repoId: z.string().min(1).max(64),
33
+ checkoutId: z.string().min(1).max(128),
34
+ root: z.string().min(1).max(4096),
35
+ head: z.string().max(256).nullable(),
36
+ branch: z.string().max(256).nullable(),
37
+ dirty: z.boolean().nullable(),
38
+ patchDigest: digestOrNull,
39
+ captureStatus: z.enum(['complete', 'partial', 'unknown']),
40
+ scope: z.enum(['workspace', 'external', 'unknown']),
41
+ });
42
+ export const checkpointArtifactSchema = z.strictObject({
43
+ path: continuityArtifactPathSchema,
44
+ digest: digestSchema,
45
+ inputVersion: z.string().max(256).nullable(),
46
+ observedAt: z.iso.datetime({ offset: true }),
47
+ });
48
+ export const checkpointValidationSchema = z.strictObject({
49
+ id: z.string().min(1).max(128),
50
+ result: z.enum(['passed', 'failed', 'not-run', 'unknown']),
51
+ inputVersion: z.string().max(256).nullable(),
52
+ observedAt: z.iso.datetime({ offset: true }),
53
+ });
54
+ export const checkpointNativeRefSchema = z.strictObject({
55
+ harness: z.enum(['pi', 'codex', 'claude', 'unknown']),
56
+ sessionId: z.string().max(256).nullable(),
57
+ turnId: z.string().max(256).nullable(),
58
+ runId: z.string().max(256).nullable(),
59
+ scope: z.literal('stored-snapshot'),
60
+ observedAt: z.iso.datetime({ offset: true }),
61
+ });
62
+ export const checkpointSchema = z.strictObject({
63
+ schema: z.literal(CHECKPOINT_SCHEMA),
64
+ checkpointId: z.uuid(),
65
+ taskId: taskIdSchema,
66
+ workspaceId: z.uuid(),
67
+ revision: z.number().int().positive(),
68
+ previousDigest: digestOrNull,
69
+ createdAt: z.iso.datetime({ offset: true }),
70
+ authorSession: z.string().max(256).nullable(),
71
+ objective: z.string().min(1).max(4096),
72
+ acceptance: z.array(z.string().min(1).max(4096)).max(32),
73
+ constraints: z.array(z.string().min(1).max(4096)).max(32),
74
+ decisions: z.array(z.string().min(1).max(4096)).max(64),
75
+ attempted: z.array(z.string().min(1).max(4096)).max(64),
76
+ nextActions: z.array(z.string().min(1).max(4096)).max(64),
77
+ limitations: z.array(z.string().min(1).max(4096)).max(64),
78
+ repositories: z.array(checkpointRepositorySchema).max(64),
79
+ artifacts: z.array(checkpointArtifactSchema).max(64),
80
+ validations: z.array(checkpointValidationSchema).max(64),
81
+ nativeRefs: z.array(checkpointNativeRefSchema).max(32),
82
+ collaborationRecordRef: optionalString,
83
+ contextCompleteness: z.enum(['complete', 'partial']),
84
+ });
85
+ export const checkpointPointerSchema = z.strictObject({
86
+ schema: z.literal(CHECKPOINT_POINTER_SCHEMA),
87
+ taskId: taskIdSchema,
88
+ workspaceId: z.uuid(),
89
+ revision: z.number().int().positive(),
90
+ checkpointRef: z.string().min(1).max(2048),
91
+ checkpointDigest: digestSchema,
92
+ updatedAt: z.iso.datetime({ offset: true }),
93
+ });
94
+ const identityCheckSchema = z.strictObject({
95
+ name: z.string().min(1).max(128),
96
+ status: z.enum(['ok', 'changed', 'unknown']),
97
+ detail: z.string().max(2048).nullable(),
98
+ });
99
+ const repositoryDriftSchema = z.strictObject({
100
+ repoId: z.string().min(1).max(64),
101
+ status: z.enum(['unchanged', 'changed', 'relocated', 'missing', 'unknown']),
102
+ storedHead: z.string().max(256).nullable(),
103
+ currentHead: z.string().max(256).nullable(),
104
+ storedDirty: z.boolean().nullable(),
105
+ currentDirty: z.boolean().nullable(),
106
+ storedPatchDigest: digestOrNull,
107
+ currentPatchDigest: digestOrNull,
108
+ storedCheckoutId: z.string().min(1).max(128),
109
+ currentCheckoutId: z.string().min(1).max(128).nullable(),
110
+ storedCaptureStatus: z.enum(['complete', 'partial', 'unknown']),
111
+ currentCaptureStatus: z.enum(['complete', 'partial', 'unknown']),
112
+ patchStatus: z.enum([
113
+ 'unchanged',
114
+ 'missing',
115
+ 'changed',
116
+ 'unsafe',
117
+ 'not-applicable',
118
+ 'unknown',
119
+ ]),
120
+ patchDetail: z.string().max(2048).nullable(),
121
+ detail: z.string().max(2048).nullable(),
122
+ });
123
+ const artifactCheckSchema = z.strictObject({
124
+ path: continuityArtifactPathSchema,
125
+ status: z.enum(['unchanged', 'changed', 'missing', 'unsafe', 'unknown']),
126
+ detail: z.string().max(2048).nullable(),
127
+ });
128
+ const executionObservationSchema = z.strictObject({
129
+ harness: z.enum(['pi', 'codex', 'claude', 'unknown']),
130
+ sessionId: z.string().max(256).nullable(),
131
+ turnId: z.string().max(256).nullable(),
132
+ runId: z.string().max(256).nullable(),
133
+ scope: z.literal('stored-snapshot'),
134
+ liveStatus: z.literal('unknown'),
135
+ observedAt: z.iso.datetime({ offset: true }),
136
+ });
137
+ const blockingReasonSchema = z.strictObject({
138
+ code: z.string().min(1).max(128),
139
+ message: z.string().min(1).max(2048),
140
+ });
141
+ const collaborationObservationSchema = z.strictObject({
142
+ ref: z.string().max(4096).nullable(),
143
+ status: z.enum([
144
+ 'read',
145
+ 'missing',
146
+ 'unreadable',
147
+ 'unsupported',
148
+ 'not-referenced',
149
+ ]),
150
+ digest: digestSchema.nullable(),
151
+ authority: z.strictObject({
152
+ valid: z.boolean(),
153
+ stateRevision: z.number().int().nonnegative().nullable(),
154
+ ownerEpoch: z.number().int().nonnegative().nullable(),
155
+ dispatchFrozen: z.boolean().nullable(),
156
+ activeAttempts: z.number().int().nonnegative().nullable(),
157
+ unreleasedClaims: z.number().int().nonnegative().nullable(),
158
+ unresolvedUncertainty: z.number().int().nonnegative().nullable(),
159
+ pendingApprovals: z.number().int().nonnegative().nullable(),
160
+ blockerCodes: z.array(z.string().min(1).max(128)).max(32),
161
+ }),
162
+ scope: z.literal('persisted-history'),
163
+ liveStatus: z.literal('unknown'),
164
+ });
165
+ export const resumePacketSchema = z.strictObject({
166
+ schema: z.literal(RESUME_PACKET_SCHEMA),
167
+ generatedAt: z.iso.datetime({ offset: true }),
168
+ taskId: taskIdSchema,
169
+ workspaceId: z.uuid(),
170
+ checkpoint: z.strictObject({
171
+ ref: z.string().min(1).max(2048),
172
+ digest: digestSchema,
173
+ revision: z.number().int().positive(),
174
+ }),
175
+ identityChecks: z.array(identityCheckSchema).max(16),
176
+ codeDrift: z.strictObject({
177
+ status: z.enum(['unchanged', 'changed', 'relocated', 'unknown']),
178
+ repositories: z.array(repositoryDriftSchema).max(64),
179
+ }),
180
+ artifactChecks: z.array(artifactCheckSchema).max(64),
181
+ executionObservations: z.array(executionObservationSchema).max(32),
182
+ collaborationObservation: collaborationObservationSchema,
183
+ blockingReasons: z.array(blockingReasonSchema).max(32),
184
+ executionAllowed: z.boolean(),
185
+ contextCompleteness: z.enum(['complete', 'partial']),
186
+ verificationStatus: z.enum(['current', 'stale', 'unknown']),
187
+ boundedContext: z.strictObject({
188
+ objective: z.string().min(1).max(4096),
189
+ acceptance: z.array(z.string().min(1).max(4096)).max(16),
190
+ constraints: z.array(z.string().min(1).max(4096)).max(16),
191
+ decisions: z.array(z.string().min(1).max(4096)).max(16),
192
+ attempted: z.array(z.string().min(1).max(4096)).max(16),
193
+ nextActions: z.array(z.string().min(1).max(4096)).max(16),
194
+ limitations: z.array(z.string().min(1).max(4096)).max(16),
195
+ repositories: z.array(checkpointRepositorySchema).max(16),
196
+ artifacts: z.array(checkpointArtifactSchema).max(16),
197
+ truncated: z.boolean(),
198
+ }),
199
+ });
@@ -0,0 +1,28 @@
1
+ import type { DiagnosticCode } from './errors.js';
2
+ export type DiagnosticSeverity = 'error' | 'warning' | 'info';
3
+ /**
4
+ * A machine-readable finding. `source` is an absolute file path or an
5
+ * operation label; `pointer` is a JSON pointer inside that source when the
6
+ * finding refers to a specific value.
7
+ */
8
+ export interface Diagnostic {
9
+ readonly code: DiagnosticCode;
10
+ readonly severity: DiagnosticSeverity;
11
+ readonly message: string;
12
+ readonly source: string;
13
+ readonly pointer: string | null;
14
+ readonly hint: string | null;
15
+ }
16
+ export interface DiagnosticInput {
17
+ readonly code: DiagnosticCode;
18
+ readonly severity: DiagnosticSeverity;
19
+ readonly message: string;
20
+ readonly source: string;
21
+ readonly pointer?: string | null;
22
+ readonly hint?: string | null;
23
+ }
24
+ export declare function createDiagnostic(input: DiagnosticInput): Diagnostic;
25
+ export declare function hasErrors(diagnostics: readonly Diagnostic[]): boolean;
26
+ export declare function formatDiagnostic(entry: Diagnostic): string;
27
+ /** Builds a JSON pointer such as `/repositories/0/path`. */
28
+ export declare function pointer(...segments: readonly (string | number)[]): string;
@@ -0,0 +1,27 @@
1
+ export function createDiagnostic(input) {
2
+ return {
3
+ code: input.code,
4
+ severity: input.severity,
5
+ message: input.message,
6
+ source: input.source,
7
+ pointer: input.pointer ?? null,
8
+ hint: input.hint ?? null,
9
+ };
10
+ }
11
+ export function hasErrors(diagnostics) {
12
+ return diagnostics.some((entry) => entry.severity === 'error');
13
+ }
14
+ export function formatDiagnostic(entry) {
15
+ const location = entry.pointer === null ? entry.source : `${entry.source}#${entry.pointer}`;
16
+ const hint = entry.hint === null ? '' : ` Hint: ${entry.hint}`;
17
+ return `${entry.severity.toUpperCase()} ${entry.code} at ${location}: ${entry.message}${hint}`;
18
+ }
19
+ function escapePointerSegment(segment) {
20
+ return segment.replaceAll('~', '~0').replaceAll('/', '~1');
21
+ }
22
+ /** Builds a JSON pointer such as `/repositories/0/path`. */
23
+ export function pointer(...segments) {
24
+ if (segments.length === 0)
25
+ return '';
26
+ return `/${segments.map((segment) => escapePointerSegment(String(segment))).join('/')}`;
27
+ }