@interf/compiler 0.9.5 → 0.13.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 (214) hide show
  1. package/README.md +96 -92
  2. package/TRADEMARKS.md +2 -13
  3. package/agent-skills/interf-actions/SKILL.md +95 -36
  4. package/agent-skills/interf-actions/references/cli.md +118 -51
  5. package/builtin-methods/interf-default/README.md +3 -4
  6. package/builtin-methods/interf-default/compile/stages/shape/SKILL.md +2 -2
  7. package/builtin-methods/interf-default/compile/stages/summarize/SKILL.md +2 -1
  8. package/builtin-methods/interf-default/improve/SKILL.md +1 -1
  9. package/builtin-methods/interf-default/method.json +10 -4
  10. package/builtin-methods/interf-default/method.schema.json +0 -9
  11. package/builtin-methods/interf-default/use/query/SKILL.md +5 -5
  12. package/dist/cli/commands/compile.d.ts +8 -25
  13. package/dist/cli/commands/compile.js +75 -360
  14. package/dist/cli/commands/doctor.js +1 -1
  15. package/dist/cli/commands/login.d.ts +7 -0
  16. package/dist/cli/commands/login.js +39 -0
  17. package/dist/cli/commands/logout.d.ts +2 -0
  18. package/dist/cli/commands/logout.js +16 -0
  19. package/dist/cli/commands/method.d.ts +2 -0
  20. package/dist/cli/commands/method.js +113 -0
  21. package/dist/cli/commands/prep.d.ts +2 -0
  22. package/dist/cli/commands/prep.js +134 -0
  23. package/dist/cli/commands/reset.d.ts +8 -1
  24. package/dist/cli/commands/reset.js +47 -26
  25. package/dist/cli/commands/runs.d.ts +2 -0
  26. package/dist/cli/commands/runs.js +120 -0
  27. package/dist/cli/commands/status.d.ts +6 -1
  28. package/dist/cli/commands/status.js +68 -111
  29. package/dist/cli/commands/test.d.ts +6 -14
  30. package/dist/cli/commands/test.js +65 -181
  31. package/dist/cli/commands/web.d.ts +0 -9
  32. package/dist/cli/commands/web.js +147 -120
  33. package/dist/cli/commands/wizard.d.ts +9 -0
  34. package/dist/cli/commands/wizard.js +442 -0
  35. package/dist/cli/index.d.ts +7 -6
  36. package/dist/cli/index.js +13 -10
  37. package/dist/compiler-ui/404.html +1 -1
  38. package/dist/compiler-ui/__next.__PAGE__.txt +2 -2
  39. package/dist/compiler-ui/__next._full.txt +3 -3
  40. package/dist/compiler-ui/__next._head.txt +1 -1
  41. package/dist/compiler-ui/__next._index.txt +2 -2
  42. package/dist/compiler-ui/__next._tree.txt +2 -2
  43. package/dist/compiler-ui/_next/static/chunks/{18a8f2jkv3z.c.css → 045gole2ojo3g.css} +1 -1
  44. package/dist/compiler-ui/_next/static/chunks/{177mvn4rse235.js → 17t-lulmyawg5.js} +9 -9
  45. package/dist/compiler-ui/_not-found/__next._full.txt +2 -2
  46. package/dist/compiler-ui/_not-found/__next._head.txt +1 -1
  47. package/dist/compiler-ui/_not-found/__next._index.txt +2 -2
  48. package/dist/compiler-ui/_not-found/__next._not-found.__PAGE__.txt +1 -1
  49. package/dist/compiler-ui/_not-found/__next._not-found.txt +1 -1
  50. package/dist/compiler-ui/_not-found/__next._tree.txt +2 -2
  51. package/dist/compiler-ui/_not-found.html +1 -1
  52. package/dist/compiler-ui/_not-found.txt +2 -2
  53. package/dist/compiler-ui/index.html +1 -1
  54. package/dist/compiler-ui/index.txt +3 -3
  55. package/dist/packages/agents/lib/shells.d.ts +1 -1
  56. package/dist/packages/agents/lib/shells.js +111 -52
  57. package/dist/packages/agents/lib/user-config.d.ts +4 -2
  58. package/dist/packages/agents/lib/user-config.js +15 -7
  59. package/dist/packages/compiler/compiled-paths.d.ts +9 -2
  60. package/dist/packages/compiler/compiled-paths.js +30 -15
  61. package/dist/packages/compiler/compiled-pipeline.js +23 -3
  62. package/dist/packages/compiler/compiled-stage-plan.js +4 -0
  63. package/dist/packages/compiler/compiled-target.d.ts +1 -1
  64. package/dist/packages/compiler/compiled-target.js +1 -1
  65. package/dist/packages/compiler/index.d.ts +1 -0
  66. package/dist/packages/compiler/index.js +1 -0
  67. package/dist/packages/compiler/lib/schema.d.ts +26 -31
  68. package/dist/packages/compiler/lib/schema.js +1 -12
  69. package/dist/packages/compiler/method-runs.d.ts +2 -3
  70. package/dist/packages/compiler/method-runs.js +2 -3
  71. package/dist/packages/compiler/reset.js +3 -1
  72. package/dist/packages/compiler/runtime-contracts.js +0 -3
  73. package/dist/packages/compiler/runtime-prompt.js +1 -1
  74. package/dist/packages/compiler/source-files.d.ts +46 -0
  75. package/dist/packages/compiler/source-files.js +149 -0
  76. package/dist/packages/compiler/state-artifacts.d.ts +3 -2
  77. package/dist/packages/compiler/state-artifacts.js +4 -3
  78. package/dist/packages/compiler/state-io.d.ts +3 -2
  79. package/dist/packages/compiler/state-io.js +11 -5
  80. package/dist/packages/compiler/state-paths.d.ts +2 -1
  81. package/dist/packages/compiler/state-paths.js +6 -3
  82. package/dist/packages/compiler/state-view.d.ts +3 -2
  83. package/dist/packages/compiler/state-view.js +18 -28
  84. package/dist/packages/compiler/state.d.ts +4 -4
  85. package/dist/packages/compiler/state.js +3 -3
  86. package/dist/packages/contracts/index.d.ts +1 -1
  87. package/dist/packages/contracts/lib/preparation-paths.d.ts +117 -0
  88. package/dist/packages/contracts/lib/preparation-paths.js +177 -0
  89. package/dist/packages/contracts/lib/schema.d.ts +85 -5
  90. package/dist/packages/contracts/lib/schema.js +46 -1
  91. package/dist/packages/execution/lib/schema.d.ts +50 -50
  92. package/dist/packages/execution/lib/schema.js +1 -1
  93. package/dist/packages/local-service/action-definitions.d.ts +14 -14
  94. package/dist/packages/local-service/action-definitions.js +27 -28
  95. package/dist/packages/local-service/action-planner.js +2 -1
  96. package/dist/packages/local-service/client.d.ts +51 -52
  97. package/dist/packages/local-service/client.js +132 -140
  98. package/dist/packages/local-service/connection-config.d.ts +38 -0
  99. package/dist/packages/local-service/connection-config.js +75 -0
  100. package/dist/packages/local-service/index.d.ts +11 -7
  101. package/dist/packages/local-service/index.js +6 -4
  102. package/dist/packages/local-service/instance-paths.d.ts +100 -0
  103. package/dist/packages/local-service/instance-paths.js +165 -0
  104. package/dist/packages/local-service/lib/schema.d.ts +405 -2297
  105. package/dist/packages/local-service/lib/schema.js +146 -62
  106. package/dist/packages/local-service/native-run-handlers.js +3 -3
  107. package/dist/packages/local-service/preparation-store.d.ts +92 -0
  108. package/dist/packages/local-service/preparation-store.js +171 -0
  109. package/dist/packages/local-service/routes.d.ts +33 -16
  110. package/dist/packages/local-service/routes.js +44 -20
  111. package/dist/packages/local-service/run-observability.js +11 -11
  112. package/dist/packages/local-service/runtime-caches.d.ts +76 -0
  113. package/dist/packages/local-service/runtime-caches.js +191 -0
  114. package/dist/packages/local-service/runtime-event-applier.d.ts +12 -0
  115. package/dist/packages/local-service/runtime-event-applier.js +177 -0
  116. package/dist/packages/local-service/runtime-persistence.d.ts +47 -0
  117. package/dist/packages/local-service/runtime-persistence.js +137 -0
  118. package/dist/packages/local-service/runtime-proposal-helpers.d.ts +35 -0
  119. package/dist/packages/local-service/runtime-proposal-helpers.js +251 -0
  120. package/dist/packages/local-service/runtime-resource-builders.d.ts +52 -0
  121. package/dist/packages/local-service/runtime-resource-builders.js +149 -0
  122. package/dist/packages/local-service/runtime.d.ts +197 -43
  123. package/dist/packages/local-service/runtime.js +800 -974
  124. package/dist/packages/local-service/server.d.ts +15 -0
  125. package/dist/packages/local-service/server.js +641 -273
  126. package/dist/packages/local-service/service-registry.d.ts +47 -0
  127. package/dist/packages/local-service/service-registry.js +137 -0
  128. package/dist/packages/method-authoring/method-authoring.d.ts +1 -1
  129. package/dist/packages/method-authoring/method-authoring.js +2 -2
  130. package/dist/packages/method-authoring/method-improvement.js +1 -1
  131. package/dist/packages/method-package/builtin-compiled-method.d.ts +4 -5
  132. package/dist/packages/method-package/builtin-compiled-method.js +8 -14
  133. package/dist/packages/method-package/context-interface.d.ts +4 -40
  134. package/dist/packages/method-package/context-interface.js +1 -23
  135. package/dist/packages/method-package/interf-method-package.d.ts +4 -4
  136. package/dist/packages/method-package/interf-method-package.js +21 -33
  137. package/dist/packages/method-package/local-methods.d.ts +10 -6
  138. package/dist/packages/method-package/local-methods.js +57 -39
  139. package/dist/packages/method-package/method-definitions.d.ts +8 -34
  140. package/dist/packages/method-package/method-definitions.js +49 -37
  141. package/dist/packages/method-package/method-helpers.d.ts +1 -13
  142. package/dist/packages/method-package/method-helpers.js +8 -42
  143. package/dist/packages/method-package/method-stage-runner.js +2 -2
  144. package/dist/packages/method-package/user-methods.d.ts +17 -0
  145. package/dist/packages/method-package/user-methods.js +77 -0
  146. package/dist/packages/project-model/index.d.ts +0 -1
  147. package/dist/packages/project-model/index.js +0 -1
  148. package/dist/packages/project-model/interf-detect.d.ts +8 -3
  149. package/dist/packages/project-model/interf-detect.js +34 -34
  150. package/dist/packages/project-model/interf-scaffold.d.ts +3 -3
  151. package/dist/packages/project-model/interf-scaffold.js +23 -32
  152. package/dist/packages/project-model/lib/schema.js +38 -1
  153. package/dist/packages/project-model/preparation-entries.d.ts +5 -5
  154. package/dist/packages/project-model/preparation-entries.js +14 -14
  155. package/dist/packages/project-model/source-config.d.ts +11 -11
  156. package/dist/packages/project-model/source-config.js +74 -46
  157. package/dist/packages/project-model/source-folders.d.ts +5 -5
  158. package/dist/packages/project-model/source-folders.js +14 -14
  159. package/dist/packages/shared/filesystem.d.ts +7 -0
  160. package/dist/packages/shared/filesystem.js +97 -10
  161. package/dist/packages/testing/lib/schema.d.ts +10 -10
  162. package/dist/packages/testing/lib/schema.js +2 -2
  163. package/dist/packages/testing/readiness-check-run.d.ts +4 -4
  164. package/dist/packages/testing/readiness-check-run.js +36 -36
  165. package/dist/packages/testing/test-execution.js +6 -6
  166. package/dist/packages/testing/test-paths.js +4 -3
  167. package/dist/packages/testing/test-sandbox.d.ts +0 -1
  168. package/dist/packages/testing/test-sandbox.js +14 -30
  169. package/dist/packages/testing/test-targets.d.ts +1 -1
  170. package/dist/packages/testing/test-targets.js +6 -6
  171. package/dist/packages/testing/test.d.ts +1 -1
  172. package/dist/packages/testing/test.js +1 -1
  173. package/package.json +3 -4
  174. package/CHANGELOG.md +0 -93
  175. package/LICENSE +0 -183
  176. package/dist/cli/commands/action-input-cli.d.ts +0 -25
  177. package/dist/cli/commands/action-input-cli.js +0 -73
  178. package/dist/cli/commands/control-path.d.ts +0 -11
  179. package/dist/cli/commands/control-path.js +0 -72
  180. package/dist/cli/commands/create-method-wizard.d.ts +0 -64
  181. package/dist/cli/commands/create-method-wizard.js +0 -434
  182. package/dist/cli/commands/create.d.ts +0 -6
  183. package/dist/cli/commands/create.js +0 -183
  184. package/dist/cli/commands/default.d.ts +0 -2
  185. package/dist/cli/commands/default.js +0 -39
  186. package/dist/cli/commands/executor-flow.d.ts +0 -29
  187. package/dist/cli/commands/executor-flow.js +0 -163
  188. package/dist/cli/commands/init.d.ts +0 -26
  189. package/dist/cli/commands/init.js +0 -771
  190. package/dist/cli/commands/list.d.ts +0 -2
  191. package/dist/cli/commands/list.js +0 -30
  192. package/dist/cli/commands/preparation-action.d.ts +0 -8
  193. package/dist/cli/commands/preparation-action.js +0 -29
  194. package/dist/cli/commands/preparation-picker.d.ts +0 -5
  195. package/dist/cli/commands/preparation-picker.js +0 -36
  196. package/dist/cli/commands/preparation-selection.d.ts +0 -6
  197. package/dist/cli/commands/preparation-selection.js +0 -11
  198. package/dist/cli/commands/service-action-flow.d.ts +0 -9
  199. package/dist/cli/commands/service-action-flow.js +0 -19
  200. package/dist/cli/commands/source-config-wizard.d.ts +0 -51
  201. package/dist/cli/commands/source-config-wizard.js +0 -670
  202. package/dist/cli/commands/verify.d.ts +0 -2
  203. package/dist/cli/commands/verify.js +0 -94
  204. package/dist/packages/compiler/raw-snapshot.d.ts +0 -49
  205. package/dist/packages/compiler/raw-snapshot.js +0 -101
  206. package/dist/packages/method-package/index.d.ts +0 -11
  207. package/dist/packages/method-package/index.js +0 -11
  208. package/dist/packages/method-package/method-stage-policy.d.ts +0 -5
  209. package/dist/packages/method-package/method-stage-policy.js +0 -31
  210. package/dist/packages/project-model/project-paths.d.ts +0 -12
  211. package/dist/packages/project-model/project-paths.js +0 -33
  212. /package/dist/compiler-ui/_next/static/{84FaeF3EzBF9kKTMjSEVN → C6vVfy3aeYuIO3d2AoNvC}/_buildManifest.js +0 -0
  213. /package/dist/compiler-ui/_next/static/{84FaeF3EzBF9kKTMjSEVN → C6vVfy3aeYuIO3d2AoNvC}/_clientMiddlewareManifest.js +0 -0
  214. /package/dist/compiler-ui/_next/static/{84FaeF3EzBF9kKTMjSEVN → C6vVfy3aeYuIO3d2AoNvC}/_ssgManifest.js +0 -0
@@ -4,12 +4,122 @@ import { SourcePreparationConfigSchema, SourceReadinessCheckSchema, } from "../.
4
4
  import { PreparationNameSchema, ReadinessStateSchema, SourceCompiledMaxAttemptsSchema, SourceCompiledMaxLoopsSchema, MethodIdSchema, } from "../../contracts/lib/schema.js";
5
5
  import { ReadinessCheckRunSchema, TestRunModeSchema, } from "../../testing/lib/schema.js";
6
6
  const JsonObjectSchema = z.record(z.string(), z.unknown());
7
- export const LocalServiceHostSchema = z.string().min(1);
7
+ // ───────────────────────────────────────────────────────────────────────────
8
+ // 0.13 — preparation-first additions
9
+ // ───────────────────────────────────────────────────────────────────────────
10
+ /** Source binding shape on the API (only `local-folder` ships in 0.13). */
11
+ export const SourceBindingSchema = z.object({
12
+ kind: z.enum(["local-folder"]),
13
+ locator: z.string().min(1),
14
+ }).strict();
15
+ /** Discriminated locator for an artifact returned by the API. */
16
+ export const ArtifactLocatorSchema = z.object({
17
+ kind: z.enum(["local-path", "remote-url"]),
18
+ value: z.string().min(1),
19
+ }).strict();
20
+ /** Per-instance metadata from `GET /v1/instance` (replaces /v1/status). */
21
+ export const InstanceResourceSchema = z.object({
22
+ kind: z.literal("interf-instance"),
23
+ version: z.literal(1),
24
+ url: z.string().min(1),
25
+ host: z.string().min(1),
26
+ port: z.number().int().min(1).max(65535),
27
+ started_at: z.string().min(1),
28
+ package_version: z.string().min(1).optional(),
29
+ preparation_count: z.number().int().min(0),
30
+ active_run_count: z.number().int().min(0),
31
+ idle_for_seconds: z.number().int().min(0),
32
+ auth_required: z.boolean(),
33
+ }).strict();
34
+ /** Body of `POST /v1/preparations` — the 0.13 preparation create request. */
35
+ export const PreparationCreateRequestSchema = z.object({
36
+ id: PreparationNameSchema,
37
+ source: SourceBindingSchema,
38
+ method_id: MethodIdSchema,
39
+ about: z.string().min(1).optional(),
40
+ checks: z.array(SourceReadinessCheckSchema).default([]),
41
+ max_attempts: SourceCompiledMaxAttemptsSchema.optional(),
42
+ max_loops: SourceCompiledMaxLoopsSchema.optional(),
43
+ }).strict();
44
+ /** Body of `POST /v1/methods` — install a Method package by path. */
45
+ export const MethodInstallRequestSchema = z.object({
46
+ source_path: z.string().min(1),
47
+ overwrite: z.boolean().default(false),
48
+ }).strict();
49
+ export const MethodInstallResultSchema = z.object({
50
+ method_id: MethodIdSchema,
51
+ installed: z.boolean(),
52
+ path: z.string().min(1),
53
+ }).strict();
54
+ export const PreparationDeleteResponseSchema = z.object({
55
+ deleted: z.boolean(),
56
+ id: PreparationNameSchema,
57
+ }).strict();
58
+ /**
59
+ * The local service must only ever bind to a loopback interface. Any other
60
+ * host (LAN IP, 0.0.0.0, public address) lets a remote browser tab POST at
61
+ * the service, which is the CSRF model we are explicitly rejecting. Keep
62
+ * the allowlist literal — refactoring to a `.refine()` over `z.string()`
63
+ * would lose the static type narrowing.
64
+ */
65
+ export const LOCAL_SERVICE_LOOPBACK_HOSTS = ["127.0.0.1", "localhost", "::1"];
66
+ export const LocalServiceHostSchema = z
67
+ .string()
68
+ .min(1)
69
+ .refine((value) => LOCAL_SERVICE_LOOPBACK_HOSTS.includes(value), {
70
+ message: `Local service host must be one of: ${LOCAL_SERVICE_LOOPBACK_HOSTS.join(", ")}.`,
71
+ });
8
72
  export const LocalServicePortSchema = z.number().int().min(1).max(65535);
73
+ /**
74
+ * Per-instance bearer token. Generated at startup with crypto.randomBytes(32)
75
+ * and rendered as a 64-char hex string. Any deviation should fail validation
76
+ * loud and early.
77
+ */
78
+ export const LocalServiceAuthTokenSchema = z
79
+ .string()
80
+ .regex(/^[0-9a-f]{64}$/i, "Auth token must be a 64-character hex string.");
9
81
  export const LocalServiceConfigSchema = z.object({
10
82
  host: LocalServiceHostSchema.default("127.0.0.1"),
11
83
  port: LocalServicePortSchema.default(4873),
12
84
  }).strict();
85
+ export const ServiceRegistryWorkspaceSchema = z.object({
86
+ control_path: z.string().min(1),
87
+ registered_at: z.string().min(1),
88
+ last_activity: z.string().min(1),
89
+ }).strict();
90
+ export const ServiceRegistryEntrySchema = z.object({
91
+ pid: z.number().int().positive(),
92
+ host: LocalServiceHostSchema,
93
+ port: LocalServicePortSchema,
94
+ url: z.string().min(1),
95
+ started_at: z.string().min(1),
96
+ /**
97
+ * Bearer token mutating clients must send. Optional in the schema so
98
+ * older registry files (pre-0.12.1) keep parsing; the runtime treats a
99
+ * missing token as "open" only when the entry already exists on disk —
100
+ * fresh entries always have one.
101
+ */
102
+ auth_token: LocalServiceAuthTokenSchema.optional(),
103
+ workspaces: z.array(ServiceRegistryWorkspaceSchema).default([]),
104
+ }).strict();
105
+ export const ServiceRegistrySchema = z.object({
106
+ services: z.array(ServiceRegistryEntrySchema).default([]),
107
+ }).strict();
108
+ export const WorkspaceRegistrationRequestSchema = z.object({
109
+ control_path: z.string().min(1),
110
+ }).strict();
111
+ export const WorkspaceRegistrationResponseSchema = z.object({
112
+ workspace: ServiceRegistryWorkspaceSchema,
113
+ service: ServiceRegistryEntrySchema,
114
+ }).strict();
115
+ export const WorkspaceListResponseSchema = z.object({
116
+ workspaces: z.array(ServiceRegistryWorkspaceSchema),
117
+ }).strict();
118
+ export const WorkspaceDeregisterResponseSchema = z.object({
119
+ deregistered: z.boolean(),
120
+ control_path: z.string().min(1),
121
+ remaining_workspaces: z.number().int().min(0),
122
+ }).strict();
13
123
  export const LocalServiceHealthSchema = z.object({
14
124
  kind: z.literal("interf-local-service-health"),
15
125
  version: z.literal(1),
@@ -21,6 +131,10 @@ export const LocalServiceHealthSchema = z.object({
21
131
  source_folder_path: z.string().min(1).nullable().optional(),
22
132
  started_at: z.string().min(1).optional(),
23
133
  package_version: z.string().min(1).optional(),
134
+ instance_started_at: z.string().min(1).optional(),
135
+ registered_workspaces: z.array(ServiceRegistryWorkspaceSchema).default([]),
136
+ active_runs: z.number().int().min(0).default(0),
137
+ idle_for_seconds: z.number().int().min(0).default(0),
24
138
  }).strict();
25
139
  export const LocalServiceErrorSchema = z.object({
26
140
  error: z.object({
@@ -35,8 +149,12 @@ export const LocalServicePointerSchema = z.object({
35
149
  pid: z.number().int().positive(),
36
150
  control_path: z.string().min(1),
37
151
  started_at: z.string().min(1),
152
+ /**
153
+ * Per-workspace copy of the bearer token. Optional so legacy pointer
154
+ * files keep parsing during upgrades; new pointers always include it.
155
+ */
156
+ auth_token: LocalServiceAuthTokenSchema.optional(),
38
157
  }).strict();
39
- export const PreparationReadinessStateSchema = ReadinessStateSchema;
40
158
  export const PortableContextMappingSchema = z.object({
41
159
  preparation: PreparationNameSchema,
42
160
  path: z.string().min(1).nullable(),
@@ -58,7 +176,7 @@ export const PreparationResourceSchema = z.object({
58
176
  checks: z.array(SourceReadinessCheckSchema).default([]),
59
177
  portable_context: PortableContextMappingSchema,
60
178
  portable_context_path: z.string().min(1).nullable(),
61
- readiness: PreparationReadinessStateSchema,
179
+ readiness: ReadinessStateSchema,
62
180
  runs: PreparationRunLinkageSchema,
63
181
  latest_compile_run_id: z.string().min(1).nullable().optional(),
64
182
  latest_test_run_id: z.string().min(1).nullable().optional(),
@@ -110,13 +228,14 @@ export const LocalJobTypeSchema = z.enum([
110
228
  "method-authoring",
111
229
  "method-improvement",
112
230
  ]);
113
- export const LocalJobStatusSchema = z.enum([
231
+ export const RunStatusSchema = z.enum([
114
232
  "queued",
115
233
  "running",
116
234
  "succeeded",
117
235
  "failed",
118
236
  "cancelled",
119
237
  ]);
238
+ export const LocalJobStatusSchema = RunStatusSchema;
120
239
  export const LocalRunHandlerResultSchema = z.object({
121
240
  ok: z.boolean(),
122
241
  error: z.string().min(1).optional(),
@@ -194,6 +313,24 @@ export const PreparationSetupResultSchema = z.object({
194
313
  submitted_run_id: z.string().min(1).nullable().optional(),
195
314
  submitted_run_type: z.literal("compile-run").nullable().optional(),
196
315
  }).strict();
316
+ export const WorkspaceBootstrapCreateRequestSchema = z.object({
317
+ source_folder: z.object({
318
+ path: z.string().min(1),
319
+ }).strict().optional(),
320
+ seed_default_method: z.boolean().default(true),
321
+ }).strict();
322
+ export const WorkspaceBootstrapResultSchema = z.object({
323
+ kind: z.literal("interf-workspace-bootstrap-result"),
324
+ version: z.literal(1),
325
+ control_path: z.string().min(1),
326
+ config_path: z.string().min(1),
327
+ source_folder_path: z.string().min(1).nullable(),
328
+ preparations: z.number().int().min(0),
329
+ seeded_default_method: z.boolean(),
330
+ default_method_id: MethodIdSchema.nullable(),
331
+ changed: z.boolean(),
332
+ message: z.string().min(1),
333
+ }).strict();
197
334
  export const MethodChangeCreateRequestSchema = z.discriminatedUnion("operation", [
198
335
  z.object({
199
336
  action_type: z.literal("method-change").optional(),
@@ -309,13 +446,7 @@ export const LocalJobRunResourceSchema = z.object({
309
446
  result: z.record(z.string(), z.unknown()).nullable().optional(),
310
447
  error: z.string().min(1).nullable().optional(),
311
448
  }).strict();
312
- export const TestRunStatusSchema = z.enum([
313
- "queued",
314
- "running",
315
- "succeeded",
316
- "failed",
317
- "cancelled",
318
- ]);
449
+ export const TestRunStatusSchema = RunStatusSchema;
319
450
  export const TestRunCreateRequestSchema = z.object({
320
451
  preparation: PreparationNameSchema,
321
452
  mode: TestRunModeSchema.default("both"),
@@ -464,7 +595,7 @@ export const PortableContextResourceSchema = z.object({
464
595
  latest_test_run_id: z.string().min(1).nullable().optional(),
465
596
  artifacts: z.array(ArtifactRefSchema).default([]),
466
597
  }).strict();
467
- export const ReadinessResourceSchema = PreparationReadinessStateSchema;
598
+ export const ReadinessResourceSchema = ReadinessStateSchema;
468
599
  export const SourceFileResourceSchema = z.object({
469
600
  preparation: PreparationNameSchema,
470
601
  path: z.string().min(1),
@@ -494,6 +625,7 @@ export const LocalServiceDiscoverySchema = z.object({
494
625
  preparation_setups: z.string().min(1),
495
626
  preparation_changes: z.string().min(1),
496
627
  method_changes: z.string().min(1),
628
+ workspace_bootstraps: z.string().min(1).optional(),
497
629
  readiness_check_drafts: z.string().min(1),
498
630
  method_authoring_runs: z.string().min(1),
499
631
  method_improvement_runs: z.string().min(1),
@@ -501,6 +633,8 @@ export const LocalServiceDiscoverySchema = z.object({
501
633
  test_runs: z.string().min(1),
502
634
  reset: z.string().min(1),
503
635
  executor: z.string().min(1),
636
+ workspaces: z.string().min(1).optional(),
637
+ status: z.string().min(1).optional(),
504
638
  }).strict(),
505
639
  }).strict();
506
640
  export const OpenPathRequestSchema = z.object({
@@ -510,56 +644,6 @@ export const OpenPathResponseSchema = z.object({
510
644
  opened: z.boolean(),
511
645
  path: z.string().min(1),
512
646
  }).strict();
513
- export const LocalServiceResourceSchema = z.discriminatedUnion("kind", [
514
- z.object({
515
- kind: z.literal("preparation"),
516
- value: PreparationResourceSchema,
517
- }).strict(),
518
- z.object({
519
- kind: z.literal("method"),
520
- value: MethodResourceSchema,
521
- }).strict(),
522
- z.object({
523
- kind: z.literal("compile-run"),
524
- value: CompileRunResourceSchema,
525
- }).strict(),
526
- z.object({
527
- kind: z.literal("job-run"),
528
- value: LocalJobRunResourceSchema,
529
- }).strict(),
530
- z.object({
531
- kind: z.literal("test-run"),
532
- value: TestRunResourceSchema,
533
- }).strict(),
534
- z.object({
535
- kind: z.literal("run-observability"),
536
- value: RunObservabilityResourceSchema,
537
- }).strict(),
538
- z.object({
539
- kind: z.literal("executor-status"),
540
- value: LocalExecutorStatusSchema,
541
- }).strict(),
542
- z.object({
543
- kind: z.literal("action-proposal"),
544
- value: ActionProposalResourceSchema,
545
- }).strict(),
546
- z.object({
547
- kind: z.literal("portable-context"),
548
- value: PortableContextResourceSchema,
549
- }).strict(),
550
- z.object({
551
- kind: z.literal("readiness"),
552
- value: ReadinessResourceSchema,
553
- }).strict(),
554
- z.object({
555
- kind: z.literal("source-file"),
556
- value: SourceFileResourceSchema,
557
- }).strict(),
558
- z.object({
559
- kind: z.literal("workspace-file"),
560
- value: WorkspaceFileResourceSchema,
561
- }).strict(),
562
- ]);
563
647
  export const PreparationListResponseSchema = z.object({
564
648
  preparations: z.array(PreparationResourceSchema),
565
649
  }).strict();
@@ -84,7 +84,7 @@ function printSavedReadinessOutcome(prefix, outcome) {
84
84
  function bestVariationRestorePaths(compiledPath) {
85
85
  const schema = readCompiledSchemaFile(methodPackagePathForCompiled(compiledPath));
86
86
  const zonePaths = (schema?.zones ?? [])
87
- .filter((zone) => zone.id !== "raw" && zone.kind !== "runtime")
87
+ .filter((zone) => zone.kind !== "runtime")
88
88
  .map((zone) => zone.path);
89
89
  return [
90
90
  "AGENTS.md",
@@ -551,7 +551,7 @@ export function createNativeLocalServiceRunHandlers(options = {}) {
551
551
  mode: request.mode,
552
552
  executor,
553
553
  });
554
- const missingSourceFiles = (request.mode === "raw" || request.mode === "both") && !result.rawOutcome;
554
+ const missingSourceFiles = (request.mode === "source-files" || request.mode === "both") && !result.sourceFilesOutcome;
555
555
  const missingPortableContext = (request.mode === "compiled" || request.mode === "both") && !result.compiledOutcome;
556
556
  if (missingSourceFiles || missingPortableContext) {
557
557
  return {
@@ -601,7 +601,7 @@ export function createNativeLocalServiceRunHandlers(options = {}) {
601
601
  message: `Using ${executor.displayName} for Method authoring.`,
602
602
  });
603
603
  const result = await runMethodAuthoringDraft({
604
- sourcePath: context.sourcePath,
604
+ prepDataDir: context.sourcePath,
605
605
  sourceFolderPath: request.source_folder_path,
606
606
  baseMethodId: request.reference_method_id ?? request.base_method_id,
607
607
  methodId: request.method_id,
@@ -0,0 +1,92 @@
1
+ /**
2
+ * 0.13 preparation store.
3
+ *
4
+ * Each preparation lives at `~/.interf/preparations/<id>/` and is also
5
+ * registered with the runtime as a synthetic workspace so the existing
6
+ * compile / test / readiness machinery (preparation-keyed under the hood)
7
+ * keeps working without a parallel implementation.
8
+ *
9
+ * ~/.interf/preparations/<id>/
10
+ * interf.json ← preparation config, single preparation entry name=<id>
11
+ * <id>/ ← portable context (matches preparation name)
12
+ *
13
+ * NOTE: We keep the synthetic `interf.json` shape (with a `preparations[]`
14
+ * array of length 1, name=id, path=id) so the existing compile/test
15
+ * machinery stays functional. The doc-shape `config.json` /
16
+ * `portable-context/` from `instance-paths.ts` is aspirational; transitioning
17
+ * the entire compile pipeline to read those names is out of scope for the
18
+ * 0.13 cutover.
19
+ *
20
+ * Public callers reach this through the preparation-keyed HTTP routes.
21
+ */
22
+ import type { SourcePreparationConfig } from "../project-model/lib/schema.js";
23
+ import type { LocalServiceRuntime } from "./runtime.js";
24
+ export interface PreparationCreateInput {
25
+ id: string;
26
+ source: {
27
+ kind: "local-folder";
28
+ locator: string;
29
+ };
30
+ method_id: string;
31
+ about?: string;
32
+ checks?: Array<{
33
+ question: string;
34
+ answer?: string;
35
+ strictness?: string;
36
+ expect?: string;
37
+ }>;
38
+ max_attempts?: number;
39
+ max_loops?: number;
40
+ }
41
+ export interface StoredPreparation {
42
+ id: string;
43
+ prepDataDir: string;
44
+ source: {
45
+ kind: "local-folder";
46
+ locator: string;
47
+ };
48
+ methodId: string;
49
+ about: string | null;
50
+ config: SourcePreparationConfig;
51
+ portableContextPath: string;
52
+ configPath: string;
53
+ }
54
+ /** List every preparation registered under `~/.interf/preparations/`. */
55
+ export declare function listStoredPreparations(): StoredPreparation[];
56
+ /** Read one preparation by id. Returns null when missing. */
57
+ export declare function getStoredPreparation(prepId: string): StoredPreparation | null;
58
+ /**
59
+ * Create a preparation: scaffold its data dir, write the synthetic
60
+ * workspace config, and register it with the runtime so subsequent
61
+ * compile / test / readiness calls find it.
62
+ *
63
+ * Throws on validation errors (bad id, bad method id, source missing).
64
+ */
65
+ export declare function createStoredPreparation(runtime: LocalServiceRuntime, input: PreparationCreateInput): StoredPreparation;
66
+ /**
67
+ * Delete a preparation: deregister its synthetic workspace and remove
68
+ * `~/.interf/preparations/<id>/` from disk. Returns true when something
69
+ * was actually removed.
70
+ */
71
+ export declare function deleteStoredPreparation(runtime: LocalServiceRuntime, prepId: string): boolean;
72
+ /**
73
+ * Re-register every preparation directory with the runtime on startup so
74
+ * synthetic workspaces survive a `interf web` restart.
75
+ */
76
+ export declare function rehydratePreparations(runtime: LocalServiceRuntime): void;
77
+ /** Build the wire shape for `GET /v1/preparations/<id>` given a stored preparation. */
78
+ export declare function preparationWireShape(stored: StoredPreparation): {
79
+ id: string;
80
+ source: {
81
+ kind: string;
82
+ locator: string;
83
+ };
84
+ method_id: string;
85
+ about: string | null;
86
+ config_path: string;
87
+ portable_context: {
88
+ kind: "local-path";
89
+ value: string;
90
+ };
91
+ checks: SourcePreparationConfig["checks"];
92
+ };
@@ -0,0 +1,171 @@
1
+ /**
2
+ * 0.13 preparation store.
3
+ *
4
+ * Each preparation lives at `~/.interf/preparations/<id>/` and is also
5
+ * registered with the runtime as a synthetic workspace so the existing
6
+ * compile / test / readiness machinery (preparation-keyed under the hood)
7
+ * keeps working without a parallel implementation.
8
+ *
9
+ * ~/.interf/preparations/<id>/
10
+ * interf.json ← preparation config, single preparation entry name=<id>
11
+ * <id>/ ← portable context (matches preparation name)
12
+ *
13
+ * NOTE: We keep the synthetic `interf.json` shape (with a `preparations[]`
14
+ * array of length 1, name=id, path=id) so the existing compile/test
15
+ * machinery stays functional. The doc-shape `config.json` /
16
+ * `portable-context/` from `instance-paths.ts` is aspirational; transitioning
17
+ * the entire compile pipeline to read those names is out of scope for the
18
+ * 0.13 cutover.
19
+ *
20
+ * Public callers reach this through the preparation-keyed HTTP routes.
21
+ */
22
+ import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, } from "node:fs";
23
+ import { join, resolve } from "node:path";
24
+ import { PreparationNameSchema, MethodIdSchema, } from "../contracts/lib/schema.js";
25
+ import { preparationDataDir, preparationsRoot, } from "./instance-paths.js";
26
+ import { saveSourceFolderConfig, loadSourceFolderConfig, } from "../project-model/source-config.js";
27
+ function ensurePreparationsRoot() {
28
+ mkdirSync(preparationsRoot(), { recursive: true });
29
+ }
30
+ function readSourceFolderBindingFromInterfJson(prepDataDir) {
31
+ const filePath = join(prepDataDir, "interf.json");
32
+ if (!existsSync(filePath))
33
+ return null;
34
+ try {
35
+ const raw = JSON.parse(readFileSync(filePath, "utf8"));
36
+ const sourceFolder = raw.source_folder;
37
+ if (!sourceFolder?.path)
38
+ return null;
39
+ return { path: sourceFolder.path, about: sourceFolder.about ?? null };
40
+ }
41
+ catch {
42
+ return null;
43
+ }
44
+ }
45
+ function loadStoredPreparation(prepId) {
46
+ const prepDataDir = preparationDataDir(prepId);
47
+ if (!existsSync(prepDataDir) || !statSync(prepDataDir).isDirectory())
48
+ return null;
49
+ const config = loadSourceFolderConfig(prepDataDir);
50
+ if (!config)
51
+ return null;
52
+ const preparation = config.preparations?.find((p) => p.name === prepId);
53
+ if (!preparation)
54
+ return null;
55
+ const binding = readSourceFolderBindingFromInterfJson(prepDataDir);
56
+ if (!binding?.path)
57
+ return null;
58
+ return {
59
+ id: prepId,
60
+ prepDataDir,
61
+ source: { kind: "local-folder", locator: binding.path },
62
+ methodId: preparation.method ?? "interf-default",
63
+ about: binding.about ?? null,
64
+ config: preparation,
65
+ portableContextPath: join(prepDataDir, prepId),
66
+ configPath: join(prepDataDir, "interf.json"),
67
+ };
68
+ }
69
+ /** List every preparation registered under `~/.interf/preparations/`. */
70
+ export function listStoredPreparations() {
71
+ const root = preparationsRoot();
72
+ if (!existsSync(root))
73
+ return [];
74
+ const entries = readdirSync(root, { withFileTypes: true });
75
+ const out = [];
76
+ for (const entry of entries) {
77
+ if (!entry.isDirectory())
78
+ continue;
79
+ const stored = loadStoredPreparation(entry.name);
80
+ if (stored)
81
+ out.push(stored);
82
+ }
83
+ return out.sort((a, b) => a.id.localeCompare(b.id));
84
+ }
85
+ /** Read one preparation by id. Returns null when missing. */
86
+ export function getStoredPreparation(prepId) {
87
+ return loadStoredPreparation(prepId);
88
+ }
89
+ /**
90
+ * Create a preparation: scaffold its data dir, write the synthetic
91
+ * workspace config, and register it with the runtime so subsequent
92
+ * compile / test / readiness calls find it.
93
+ *
94
+ * Throws on validation errors (bad id, bad method id, source missing).
95
+ */
96
+ export function createStoredPreparation(runtime, input) {
97
+ PreparationNameSchema.parse(input.id);
98
+ MethodIdSchema.parse(input.method_id);
99
+ const sourceLocator = resolve(input.source.locator);
100
+ if (!existsSync(sourceLocator)) {
101
+ throw new Error(`Source folder does not exist: ${sourceLocator}`);
102
+ }
103
+ if (!statSync(sourceLocator).isDirectory()) {
104
+ throw new Error(`Source folder is not a directory: ${sourceLocator}`);
105
+ }
106
+ ensurePreparationsRoot();
107
+ const prepDataDir = preparationDataDir(input.id);
108
+ if (existsSync(prepDataDir) && loadStoredPreparation(input.id)) {
109
+ throw new Error(`Preparation already exists: ${input.id}`);
110
+ }
111
+ mkdirSync(prepDataDir, { recursive: true });
112
+ const preparation = {
113
+ name: input.id,
114
+ path: input.id,
115
+ method: input.method_id,
116
+ checks: (input.checks ?? []).map((check) => ({
117
+ question: check.question,
118
+ ...(check.answer ? { answer: check.answer } : {}),
119
+ ...(check.strictness ? { strictness: check.strictness } : {}),
120
+ ...(check.expect ? { expect: check.expect } : {}),
121
+ })),
122
+ ...(input.about ? { about: input.about } : {}),
123
+ ...(input.max_attempts ? { max_attempts: input.max_attempts } : {}),
124
+ ...(input.max_loops ? { max_loops: input.max_loops } : {}),
125
+ };
126
+ saveSourceFolderConfig(prepDataDir, {
127
+ source_folder: { path: sourceLocator, ...(input.about ? { about: input.about } : {}) },
128
+ preparations: [preparation],
129
+ });
130
+ // Hand the synthetic workspace to the runtime so the existing
131
+ // compile/test/readiness paths see it.
132
+ runtime.registerPreparation(prepDataDir);
133
+ const stored = loadStoredPreparation(input.id);
134
+ if (!stored)
135
+ throw new Error(`Failed to load freshly-created preparation ${input.id}`);
136
+ return stored;
137
+ }
138
+ /**
139
+ * Delete a preparation: deregister its synthetic workspace and remove
140
+ * `~/.interf/preparations/<id>/` from disk. Returns true when something
141
+ * was actually removed.
142
+ */
143
+ export function deleteStoredPreparation(runtime, prepId) {
144
+ const prepDataDir = preparationDataDir(prepId);
145
+ if (!existsSync(prepDataDir))
146
+ return false;
147
+ runtime.deregisterPreparation(prepDataDir);
148
+ rmSync(prepDataDir, { recursive: true, force: true });
149
+ return true;
150
+ }
151
+ /**
152
+ * Re-register every preparation directory with the runtime on startup so
153
+ * synthetic workspaces survive a `interf web` restart.
154
+ */
155
+ export function rehydratePreparations(runtime) {
156
+ for (const stored of listStoredPreparations()) {
157
+ runtime.registerPreparation(stored.prepDataDir);
158
+ }
159
+ }
160
+ /** Build the wire shape for `GET /v1/preparations/<id>` given a stored preparation. */
161
+ export function preparationWireShape(stored) {
162
+ return {
163
+ id: stored.id,
164
+ source: stored.source,
165
+ method_id: stored.methodId,
166
+ about: stored.about,
167
+ config_path: stored.configPath,
168
+ portable_context: { kind: "local-path", value: stored.portableContextPath },
169
+ checks: stored.config.checks ?? [],
170
+ };
171
+ }
@@ -1,32 +1,49 @@
1
1
  export declare const LOCAL_SERVICE_DEFAULT_HOST = "127.0.0.1";
2
2
  export declare const LOCAL_SERVICE_DEFAULT_PORT = 4873;
3
- export declare const LOCAL_SERVICE_POINTER_PATH: readonly ["interf", ".service", "local-service.json"];
4
3
  export declare const LOCAL_SERVICE_ROUTES: {
5
4
  readonly root: "/";
6
5
  readonly api: "/v1";
7
6
  readonly health: "/health";
7
+ readonly instance: "/v1/instance";
8
8
  readonly preparations: "/v1/preparations";
9
- readonly workspaceFiles: "/v1/workspace-files";
10
- readonly sourceFiles: "/v1/source-files";
11
9
  readonly methods: "/v1/methods";
12
- readonly preparationSetups: "/v1/preparation-setups";
13
- readonly preparationChanges: "/v1/preparation-changes";
14
- readonly methodChanges: "/v1/method-changes";
15
- readonly jobs: "/v1/jobs";
16
- readonly readinessCheckDrafts: "/v1/readiness-check-drafts";
17
- readonly methodAuthoringRuns: "/v1/method-authoring-runs";
18
- readonly methodImprovementRuns: "/v1/method-improvement-runs";
19
10
  readonly runs: "/v1/runs";
20
- readonly reset: "/v1/reset";
21
- readonly executor: "/v1/executor";
22
11
  readonly actionProposals: "/v1/action-proposals";
23
- readonly compileRuns: "/v1/compile-runs";
24
- readonly testRuns: "/v1/test-runs";
25
- readonly portableContexts: "/v1/portable-contexts";
26
- readonly readiness: "/v1/readiness";
12
+ readonly executor: "/v1/executor";
27
13
  readonly openPath: "/v1/open-path";
28
14
  };
15
+ /** Preparation-scoped sub-resources (relative to /v1/preparations/<id>/). */
16
+ export declare const PREPARATION_SUBRESOURCES: {
17
+ readonly compileRuns: "compile-runs";
18
+ readonly testRuns: "test-runs";
19
+ readonly methodAuthoringRuns: "method-authoring-runs";
20
+ readonly methodImprovementRuns: "method-improvement-runs";
21
+ readonly readinessCheckDrafts: "readiness-check-drafts";
22
+ readonly changes: "changes";
23
+ readonly reset: "reset";
24
+ readonly runs: "runs";
25
+ readonly readiness: "readiness";
26
+ readonly sourceFiles: "source-files";
27
+ readonly portableContext: "portable-context";
28
+ };
29
+ /** Run-scoped sub-resources (relative to /v1/runs/<run-id>/). */
30
+ export declare const RUN_SUBRESOURCES: {
31
+ readonly events: "events";
32
+ readonly cancel: "cancel";
33
+ readonly proof: "proof";
34
+ readonly artifacts: "artifacts";
35
+ };
29
36
  export declare function buildLocalServiceUrl(options?: {
30
37
  host?: string;
31
38
  port?: number;
32
39
  }): string;
40
+ /** Path builder: /v1/preparations/<id>. */
41
+ export declare function preparationResourcePath(prepId: string): string;
42
+ /** Path builder: /v1/preparations/<id>/<subresource>. */
43
+ export declare function preparationSubresourcePath(prepId: string, sub: keyof typeof PREPARATION_SUBRESOURCES): string;
44
+ /** Path builder: /v1/runs/<run-id>. */
45
+ export declare function runResourcePath(runId: string): string;
46
+ /** Path builder: /v1/runs/<run-id>/<subresource>. */
47
+ export declare function runSubresourcePath(runId: string, sub: keyof typeof RUN_SUBRESOURCES): string;
48
+ /** Path builder: /v1/methods/<id>. */
49
+ export declare function methodResourcePath(methodId: string): string;