@xemahq/kernel-contracts 0.1.0 → 0.2.1

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 (280) hide show
  1. package/LICENSE +201 -0
  2. package/dist/agent-tool-inquiry/index.d.ts +2 -0
  3. package/dist/agent-tool-inquiry/index.d.ts.map +1 -0
  4. package/dist/agent-tool-inquiry/index.js +18 -0
  5. package/dist/agent-tool-inquiry/index.js.map +1 -0
  6. package/dist/agent-tool-inquiry/lib/agent-tool-inquiry.d.ts +43 -0
  7. package/dist/agent-tool-inquiry/lib/agent-tool-inquiry.d.ts.map +1 -0
  8. package/dist/agent-tool-inquiry/lib/agent-tool-inquiry.js +32 -0
  9. package/dist/agent-tool-inquiry/lib/agent-tool-inquiry.js.map +1 -0
  10. package/dist/agent-workspace/awp-spec.json +1 -1
  11. package/dist/app-runtime/index.d.ts +9 -0
  12. package/dist/app-runtime/index.d.ts.map +1 -0
  13. package/dist/app-runtime/index.js +25 -0
  14. package/dist/app-runtime/index.js.map +1 -0
  15. package/dist/app-runtime/lib/app-client.d.ts +11 -0
  16. package/dist/app-runtime/lib/app-client.d.ts.map +1 -0
  17. package/dist/app-runtime/lib/app-client.js +23 -0
  18. package/dist/app-runtime/lib/app-client.js.map +1 -0
  19. package/dist/app-runtime/lib/app-lockfile.d.ts +12 -0
  20. package/dist/app-runtime/lib/app-lockfile.d.ts.map +1 -0
  21. package/dist/app-runtime/lib/app-lockfile.js +17 -0
  22. package/dist/app-runtime/lib/app-lockfile.js.map +1 -0
  23. package/dist/app-runtime/lib/app.d.ts +26 -0
  24. package/dist/app-runtime/lib/app.d.ts.map +1 -0
  25. package/dist/app-runtime/lib/app.js +31 -0
  26. package/dist/app-runtime/lib/app.js.map +1 -0
  27. package/dist/app-runtime/lib/audience-policy.d.ts +31 -0
  28. package/dist/app-runtime/lib/audience-policy.d.ts.map +1 -0
  29. package/dist/app-runtime/lib/audience-policy.js +38 -0
  30. package/dist/app-runtime/lib/audience-policy.js.map +1 -0
  31. package/dist/app-runtime/lib/biome-install.d.ts +9 -0
  32. package/dist/app-runtime/lib/biome-install.d.ts.map +1 -0
  33. package/dist/app-runtime/lib/biome-install.js +13 -0
  34. package/dist/app-runtime/lib/biome-install.js.map +1 -0
  35. package/dist/app-runtime/lib/branding-config.d.ts +9 -0
  36. package/dist/app-runtime/lib/branding-config.d.ts.map +1 -0
  37. package/dist/app-runtime/lib/branding-config.js +24 -0
  38. package/dist/app-runtime/lib/branding-config.js.map +1 -0
  39. package/dist/app-runtime/lib/delegated-session.d.ts +15 -0
  40. package/dist/app-runtime/lib/delegated-session.d.ts.map +1 -0
  41. package/dist/app-runtime/lib/delegated-session.js +29 -0
  42. package/dist/app-runtime/lib/delegated-session.js.map +1 -0
  43. package/dist/app-runtime/lib/external-subject.d.ts +9 -0
  44. package/dist/app-runtime/lib/external-subject.d.ts.map +1 -0
  45. package/dist/app-runtime/lib/external-subject.js +19 -0
  46. package/dist/app-runtime/lib/external-subject.js.map +1 -0
  47. package/dist/connector/index.d.ts +9 -0
  48. package/dist/connector/index.d.ts.map +1 -0
  49. package/dist/connector/index.js +25 -0
  50. package/dist/connector/index.js.map +1 -0
  51. package/dist/connector/lib/adapter-kind.d.ts +8 -0
  52. package/dist/connector/lib/adapter-kind.d.ts.map +1 -0
  53. package/dist/connector/lib/adapter-kind.js +14 -0
  54. package/dist/connector/lib/adapter-kind.js.map +1 -0
  55. package/dist/connector/lib/capability-refs.d.ts +14 -0
  56. package/dist/connector/lib/capability-refs.d.ts.map +1 -0
  57. package/dist/connector/lib/capability-refs.js +15 -0
  58. package/dist/connector/lib/capability-refs.js.map +1 -0
  59. package/dist/connector/lib/capability.d.ts +18 -0
  60. package/dist/connector/lib/capability.d.ts.map +1 -0
  61. package/dist/connector/lib/capability.js +24 -0
  62. package/dist/connector/lib/capability.js.map +1 -0
  63. package/dist/connector/lib/credential-kind.d.ts +42 -0
  64. package/dist/connector/lib/credential-kind.d.ts.map +1 -0
  65. package/dist/connector/lib/credential-kind.js +26 -0
  66. package/dist/connector/lib/credential-kind.js.map +1 -0
  67. package/dist/connector/lib/envelope-schema.d.ts +6 -0
  68. package/dist/connector/lib/envelope-schema.d.ts.map +1 -0
  69. package/dist/connector/lib/envelope-schema.js +150 -0
  70. package/dist/connector/lib/envelope-schema.js.map +1 -0
  71. package/dist/connector/lib/filter-expr-schema.d.ts +4 -0
  72. package/dist/connector/lib/filter-expr-schema.d.ts.map +1 -0
  73. package/dist/connector/lib/filter-expr-schema.js +65 -0
  74. package/dist/connector/lib/filter-expr-schema.js.map +1 -0
  75. package/dist/connector/lib/filter-expr-validate.d.ts +10 -0
  76. package/dist/connector/lib/filter-expr-validate.d.ts.map +1 -0
  77. package/dist/connector/lib/filter-expr-validate.js +58 -0
  78. package/dist/connector/lib/filter-expr-validate.js.map +1 -0
  79. package/dist/connector/lib/filter-expr.d.ts +49 -0
  80. package/dist/connector/lib/filter-expr.d.ts.map +1 -0
  81. package/dist/connector/lib/filter-expr.js +135 -0
  82. package/dist/connector/lib/filter-expr.js.map +1 -0
  83. package/dist/connector/lib/onboarding-manifest.d.ts +45 -0
  84. package/dist/connector/lib/onboarding-manifest.d.ts.map +1 -0
  85. package/dist/connector/lib/onboarding-manifest.js +30 -0
  86. package/dist/connector/lib/onboarding-manifest.js.map +1 -0
  87. package/dist/document-render/index.d.ts +7 -0
  88. package/dist/document-render/index.d.ts.map +1 -0
  89. package/dist/document-render/index.js +23 -0
  90. package/dist/document-render/index.js.map +1 -0
  91. package/dist/document-render/lib/measure-layout.d.ts +44 -0
  92. package/dist/document-render/lib/measure-layout.d.ts.map +1 -0
  93. package/dist/document-render/lib/measure-layout.js +16 -0
  94. package/dist/document-render/lib/measure-layout.js.map +1 -0
  95. package/dist/document-render/lib/render-enums.d.ts +18 -0
  96. package/dist/document-render/lib/render-enums.d.ts.map +1 -0
  97. package/dist/document-render/lib/render-enums.js +24 -0
  98. package/dist/document-render/lib/render-enums.js.map +1 -0
  99. package/dist/document-render/lib/render-record.d.ts +22 -0
  100. package/dist/document-render/lib/render-record.d.ts.map +1 -0
  101. package/dist/document-render/lib/render-record.js +3 -0
  102. package/dist/document-render/lib/render-record.js.map +1 -0
  103. package/dist/document-render/lib/render-request.d.ts +24 -0
  104. package/dist/document-render/lib/render-request.d.ts.map +1 -0
  105. package/dist/document-render/lib/render-request.js +12 -0
  106. package/dist/document-render/lib/render-request.js.map +1 -0
  107. package/dist/document-render/lib/render-source.d.ts +43 -0
  108. package/dist/document-render/lib/render-source.d.ts.map +1 -0
  109. package/dist/document-render/lib/render-source.js +31 -0
  110. package/dist/document-render/lib/render-source.js.map +1 -0
  111. package/dist/document-render/lib/xema-prompt.d.ts +11 -0
  112. package/dist/document-render/lib/xema-prompt.d.ts.map +1 -0
  113. package/dist/document-render/lib/xema-prompt.js +46 -0
  114. package/dist/document-render/lib/xema-prompt.js.map +1 -0
  115. package/dist/inquiry/index.d.ts +7 -0
  116. package/dist/inquiry/index.d.ts.map +1 -0
  117. package/dist/inquiry/index.js +23 -0
  118. package/dist/inquiry/index.js.map +1 -0
  119. package/dist/inquiry/lib/enums.d.ts +36 -0
  120. package/dist/inquiry/lib/enums.d.ts.map +1 -0
  121. package/dist/inquiry/lib/enums.js +45 -0
  122. package/dist/inquiry/lib/enums.js.map +1 -0
  123. package/dist/inquiry/lib/inquiry.d.ts +332 -0
  124. package/dist/inquiry/lib/inquiry.d.ts.map +1 -0
  125. package/dist/inquiry/lib/inquiry.js +102 -0
  126. package/dist/inquiry/lib/inquiry.js.map +1 -0
  127. package/dist/inquiry/lib/kind-registry.d.ts +14 -0
  128. package/dist/inquiry/lib/kind-registry.d.ts.map +1 -0
  129. package/dist/inquiry/lib/kind-registry.js +24 -0
  130. package/dist/inquiry/lib/kind-registry.js.map +1 -0
  131. package/dist/inquiry/lib/policy.d.ts +19 -0
  132. package/dist/inquiry/lib/policy.d.ts.map +1 -0
  133. package/dist/inquiry/lib/policy.js +21 -0
  134. package/dist/inquiry/lib/policy.js.map +1 -0
  135. package/dist/inquiry/lib/recipient.d.ts +111 -0
  136. package/dist/inquiry/lib/recipient.d.ts.map +1 -0
  137. package/dist/inquiry/lib/recipient.js +64 -0
  138. package/dist/inquiry/lib/recipient.js.map +1 -0
  139. package/dist/inquiry/lib/workflow-verdict-evaluator.d.ts +15 -0
  140. package/dist/inquiry/lib/workflow-verdict-evaluator.d.ts.map +1 -0
  141. package/dist/inquiry/lib/workflow-verdict-evaluator.js +145 -0
  142. package/dist/inquiry/lib/workflow-verdict-evaluator.js.map +1 -0
  143. package/dist/org-database/index.d.ts +5 -0
  144. package/dist/org-database/index.d.ts.map +1 -0
  145. package/dist/org-database/index.js +21 -0
  146. package/dist/org-database/index.js.map +1 -0
  147. package/dist/org-database/lib/db-result-event.d.ts +24 -0
  148. package/dist/org-database/lib/db-result-event.d.ts.map +1 -0
  149. package/dist/org-database/lib/db-result-event.js +3 -0
  150. package/dist/org-database/lib/db-result-event.js.map +1 -0
  151. package/dist/org-database/lib/driver.d.ts +43 -0
  152. package/dist/org-database/lib/driver.d.ts.map +1 -0
  153. package/dist/org-database/lib/driver.js +3 -0
  154. package/dist/org-database/lib/driver.js.map +1 -0
  155. package/dist/org-database/lib/enums.d.ts +41 -0
  156. package/dist/org-database/lib/enums.d.ts.map +1 -0
  157. package/dist/org-database/lib/enums.js +51 -0
  158. package/dist/org-database/lib/enums.js.map +1 -0
  159. package/dist/org-database/lib/migration-runner.d.ts +15 -0
  160. package/dist/org-database/lib/migration-runner.d.ts.map +1 -0
  161. package/dist/org-database/lib/migration-runner.js +3 -0
  162. package/dist/org-database/lib/migration-runner.js.map +1 -0
  163. package/dist/project-kit/index.d.ts +2 -0
  164. package/dist/project-kit/index.d.ts.map +1 -0
  165. package/dist/project-kit/index.js +18 -0
  166. package/dist/project-kit/index.js.map +1 -0
  167. package/dist/project-kit/lib/project-kit.d.ts +63 -0
  168. package/dist/project-kit/lib/project-kit.d.ts.map +1 -0
  169. package/dist/project-kit/lib/project-kit.js +32 -0
  170. package/dist/project-kit/lib/project-kit.js.map +1 -0
  171. package/dist/provisioning/index.d.ts +2 -0
  172. package/dist/provisioning/index.d.ts.map +1 -0
  173. package/dist/provisioning/index.js +18 -0
  174. package/dist/provisioning/index.js.map +1 -0
  175. package/dist/provisioning/lib/provisioning.d.ts +256 -0
  176. package/dist/provisioning/lib/provisioning.d.ts.map +1 -0
  177. package/dist/provisioning/lib/provisioning.js +221 -0
  178. package/dist/provisioning/lib/provisioning.js.map +1 -0
  179. package/dist/worker-runtime/index.d.ts +6 -0
  180. package/dist/worker-runtime/index.d.ts.map +1 -0
  181. package/dist/worker-runtime/index.js +22 -0
  182. package/dist/worker-runtime/index.js.map +1 -0
  183. package/dist/worker-runtime/lib/capabilities.d.ts +22 -0
  184. package/dist/worker-runtime/lib/capabilities.d.ts.map +1 -0
  185. package/dist/worker-runtime/lib/capabilities.js +3 -0
  186. package/dist/worker-runtime/lib/capabilities.js.map +1 -0
  187. package/dist/worker-runtime/lib/enums.d.ts +10 -0
  188. package/dist/worker-runtime/lib/enums.d.ts.map +1 -0
  189. package/dist/worker-runtime/lib/enums.js +15 -0
  190. package/dist/worker-runtime/lib/enums.js.map +1 -0
  191. package/dist/worker-runtime/lib/messages.d.ts +33 -0
  192. package/dist/worker-runtime/lib/messages.d.ts.map +1 -0
  193. package/dist/worker-runtime/lib/messages.js +3 -0
  194. package/dist/worker-runtime/lib/messages.js.map +1 -0
  195. package/dist/worker-runtime/lib/runtime.d.ts +35 -0
  196. package/dist/worker-runtime/lib/runtime.d.ts.map +1 -0
  197. package/dist/worker-runtime/lib/runtime.js +3 -0
  198. package/dist/worker-runtime/lib/runtime.js.map +1 -0
  199. package/dist/worker-runtime/lib/schemas.d.ts +87 -0
  200. package/dist/worker-runtime/lib/schemas.d.ts.map +1 -0
  201. package/dist/worker-runtime/lib/schemas.js +57 -0
  202. package/dist/worker-runtime/lib/schemas.js.map +1 -0
  203. package/dist/workspace-storage/index.d.ts +4 -0
  204. package/dist/workspace-storage/index.d.ts.map +1 -0
  205. package/dist/workspace-storage/index.js +20 -0
  206. package/dist/workspace-storage/index.js.map +1 -0
  207. package/dist/workspace-storage/lib/enums.d.ts +34 -0
  208. package/dist/workspace-storage/lib/enums.d.ts.map +1 -0
  209. package/dist/workspace-storage/lib/enums.js +42 -0
  210. package/dist/workspace-storage/lib/enums.js.map +1 -0
  211. package/dist/workspace-storage/lib/schemas.d.ts +56 -0
  212. package/dist/workspace-storage/lib/schemas.d.ts.map +1 -0
  213. package/dist/workspace-storage/lib/schemas.js +59 -0
  214. package/dist/workspace-storage/lib/schemas.js.map +1 -0
  215. package/dist/workspace-storage/lib/types.d.ts +71 -0
  216. package/dist/workspace-storage/lib/types.d.ts.map +1 -0
  217. package/dist/workspace-storage/lib/types.js +3 -0
  218. package/dist/workspace-storage/lib/types.js.map +1 -0
  219. package/package.json +22 -153
  220. package/src/agent-composition/lib/composition-workspace.ts +1 -1
  221. package/src/agent-tool-inquiry/index.ts +16 -0
  222. package/src/agent-tool-inquiry/lib/agent-tool-inquiry.ts +82 -0
  223. package/src/agent-workspace/lib/workspace-spec.ts +1 -1
  224. package/src/app-runtime/index.ts +8 -0
  225. package/src/app-runtime/lib/app-client.ts +44 -0
  226. package/src/app-runtime/lib/app-lockfile.ts +54 -0
  227. package/src/app-runtime/lib/app.ts +84 -0
  228. package/src/app-runtime/lib/audience-policy.ts +87 -0
  229. package/src/app-runtime/lib/biome-install.ts +29 -0
  230. package/src/app-runtime/lib/branding-config.ts +54 -0
  231. package/src/app-runtime/lib/delegated-session.ts +69 -0
  232. package/src/app-runtime/lib/external-subject.ts +34 -0
  233. package/src/connector/index.ts +8 -0
  234. package/src/connector/lib/adapter-kind.ts +37 -0
  235. package/src/connector/lib/capability-refs.ts +29 -0
  236. package/src/connector/lib/capability.ts +38 -0
  237. package/src/connector/lib/credential-kind.ts +120 -0
  238. package/src/connector/lib/envelope-schema.ts +256 -0
  239. package/src/connector/lib/filter-expr-schema.ts +75 -0
  240. package/src/connector/lib/filter-expr-validate.ts +91 -0
  241. package/src/connector/lib/filter-expr.ts +208 -0
  242. package/src/connector/lib/onboarding-manifest.ts +167 -0
  243. package/src/document-render/index.ts +25 -0
  244. package/src/document-render/lib/measure-layout.ts +61 -0
  245. package/src/document-render/lib/render-enums.ts +49 -0
  246. package/src/document-render/lib/render-record.ts +38 -0
  247. package/src/document-render/lib/render-request.ts +16 -0
  248. package/src/document-render/lib/render-source.ts +44 -0
  249. package/src/document-render/lib/xema-prompt.ts +100 -0
  250. package/src/inquiry/index.ts +23 -0
  251. package/src/inquiry/lib/enums.ts +103 -0
  252. package/src/inquiry/lib/inquiry.ts +182 -0
  253. package/src/inquiry/lib/kind-registry.ts +57 -0
  254. package/src/inquiry/lib/policy.ts +27 -0
  255. package/src/inquiry/lib/recipient.ts +188 -0
  256. package/src/inquiry/lib/workflow-verdict-evaluator.ts +220 -0
  257. package/src/org-database/index.ts +4 -0
  258. package/src/org-database/lib/db-result-event.ts +59 -0
  259. package/src/org-database/lib/driver.ts +47 -0
  260. package/src/org-database/lib/enums.ts +51 -0
  261. package/src/org-database/lib/migration-runner.ts +17 -0
  262. package/src/project-kit/index.ts +17 -0
  263. package/src/project-kit/lib/project-kit.ts +227 -0
  264. package/src/provisioning/index.ts +17 -0
  265. package/src/provisioning/lib/provisioning.ts +499 -0
  266. package/src/worker-runtime/index.ts +14 -0
  267. package/src/worker-runtime/lib/capabilities.ts +58 -0
  268. package/src/worker-runtime/lib/enums.ts +33 -0
  269. package/src/worker-runtime/lib/messages.ts +49 -0
  270. package/src/worker-runtime/lib/runtime.ts +109 -0
  271. package/src/worker-runtime/lib/schemas.ts +72 -0
  272. package/src/workflow/lib/activity-outputs.ts +1 -1
  273. package/src/workflow/lib/compiled-run.ts +1 -1
  274. package/src/workflow/lib/compiled-workspace-manifest.ts +1 -1
  275. package/src/workflow/lib/model-ref.ts +1 -1
  276. package/src/workflow/lib/workspace-manifest-enums.ts +1 -1
  277. package/src/workspace-storage/index.ts +12 -0
  278. package/src/workspace-storage/lib/enums.ts +78 -0
  279. package/src/workspace-storage/lib/schemas.ts +75 -0
  280. package/src/workspace-storage/lib/types.ts +145 -0
@@ -0,0 +1,227 @@
1
+ // ═══════════════════════════════════════════════════════════════════════════
2
+ // Project Kit — attachable, installable units for interactive sessions.
3
+ //
4
+ // A "project kit" is a named, typed, reusable unit that, when attached to a
5
+ // project, gets INSTALLED INTO that project's repo/workspace when an
6
+ // interactive session starts. Unlike a workspace mount (platform-side,
7
+ // ephemeral), a kit is a DURABLE mutation the project carries forward on its
8
+ // own — e.g. an npm dependency that lands in `package.json` + lockfile and is
9
+ // committed, so cloning the repo later and running `npm install` reproduces it.
10
+ //
11
+ // Pure types + enums, zero domain knowledge and zero runtime deps. The catalog
12
+ // lives in `llm-registry-api`; the per-session binding rides `customConfig`;
13
+ // the npm-specific install is the agent-session-api `provision` phase's job
14
+ // (a guard-gated EQUIP step synthesized per kit). This contract only knows
15
+ // the closed shape of a kit, not how any one session type applies it.
16
+ // ═══════════════════════════════════════════════════════════════════════════
17
+
18
+ /**
19
+ * HOW a project kit is installed into the target project. Closed,
20
+ * platform-owned set.
21
+ *
22
+ * `NpmDependency` installs a package (registry or git source) — the produced
23
+ * file mutation is a `dependencies` entry in `package.json` + lockfile.
24
+ *
25
+ * `ShadcnRegistry` is a codegen-style install: the shadcn CLI copies component
26
+ * SOURCE FILES into the project (typically `src/components/ui/<name>.tsx`)
27
+ * plus a `components.json` config and small `lib/utils.ts` helper. Resulting
28
+ * components ARE the project's own code — they are not imported from a library.
29
+ * Distinct from `NpmDependency` because the install mechanism (`npx shadcn
30
+ * init` + `add`), the produced file shape, and the agent's mental model are
31
+ * fundamentally different. The two are mutually exclusive per project.
32
+ *
33
+ * `FileTree` and `CodeSnippet` remain reserved — adding either is a deliberate
34
+ * platform change (a new applicator interpretation in the consuming session
35
+ * type), not a biome extension. The enum stays the single seam.
36
+ */
37
+ export enum ProjectKitKind {
38
+ /** An npm package added to a project's `package.json` (registry or git source). */
39
+ NpmDependency = 'npm-dependency',
40
+ /** A shadcn-style codegen kit: CLI copies component source files into the repo. */
41
+ ShadcnRegistry = 'shadcn-registry',
42
+ }
43
+
44
+ /**
45
+ * WHAT a kit is, from the code-producing agent's point of view. Drives
46
+ * whether the agent receives an enrichment skill.
47
+ *
48
+ * `ComponentLibrary` is a "known concept" — the agent should build WITH it,
49
+ * so the kit carries an `enrichmentSkillSlug`. `GenericDependency` is a plain
50
+ * library the agent simply sees in `package.json`; no extra instruction.
51
+ */
52
+ export enum ProjectKitPurpose {
53
+ ComponentLibrary = 'component-library',
54
+ GenericDependency = 'generic-dependency',
55
+ }
56
+
57
+ /**
58
+ * Where a kit's payload comes from. The semantics depend on the kit kind:
59
+ *
60
+ * - For `NpmDependency` kits: `NpmRegistry` resolves a `package@versionRange`
61
+ * against an npm registry; `Git` resolves `git+<url>#<ref>` directly.
62
+ * - For `ShadcnRegistry` kits: `ShadcnRegistry` carries the shadcn-CLI config
63
+ * (style, baseColor, components list, optional custom registry URLs).
64
+ *
65
+ * Cross-kind sources are rejected by the resolver — e.g. an `NpmDependency`
66
+ * kit cannot carry a `ShadcnRegistry` source, and vice versa. This is enforced
67
+ * at parse time, not at install time, so the failure is loud.
68
+ */
69
+ export enum ProjectKitSourceKind {
70
+ /** Resolved from an npm registry (the public registry, or a scoped private one). */
71
+ NpmRegistry = 'npm-registry',
72
+ /** Resolved directly from a git repository (`npm install git+https://…#ref`). */
73
+ Git = 'git',
74
+ /** A shadcn-CLI config: registry URL, baseline component list, style + theme. */
75
+ ShadcnRegistry = 'shadcn-registry',
76
+ }
77
+
78
+ /**
79
+ * Tier of visibility for a kit and the registry namespace it pulls from. Carried on
80
+ * every `ResolvedProjectKit` so the install path can enforce tenant isolation
81
+ * at the wire layer (System / System-shareable / Org tiers in our hosted npm
82
+ * + container registries) and the FE can render the right badge.
83
+ *
84
+ * Precedence:
85
+ * `System` — only the platform writes AND reads (kernel-internal kits).
86
+ * Never selectable by org users; rejected by the catalog
87
+ * endpoint unless the caller has the platform role.
88
+ * `SystemShareable` — only the platform writes; ANY org reads. Curated kits
89
+ * shipped by Xema (`xema-component-library`, future
90
+ * `@xema/shadcn-presets`). Anonymous-read on our registries.
91
+ * `Org` — the org owns push + pull. Custom kits that point at a
92
+ * private package or git repo bound to the caller's org.
93
+ * Cross-org reads structurally impossible (JWT `x_org_id`
94
+ * scope at the registry layer).
95
+ * `External` — registries the platform does not host. ACLs are
96
+ * whatever the external system enforces (npmjs public,
97
+ * GH Packages private, etc.). Token resolution rides
98
+ * the existing wallet model.
99
+ *
100
+ * The order in the enum reflects "most platform-restricted" → "least platform-
101
+ * controlled" — useful for sorting in the catalog UI.
102
+ */
103
+ export enum RegistryVisibilityTier {
104
+ System = 'system',
105
+ SystemShareable = 'system-shareable',
106
+ Org = 'org',
107
+ External = 'external',
108
+ }
109
+
110
+ /**
111
+ * Auth for a private kit source. The token itself is NEVER stored on the kit
112
+ * — it lives in a wallet. At session start the bootstrap resolves `walletName`
113
+ * and injects that wallet's entries as worker env vars; `tokenEnvVar` names
114
+ * the entry holding the registry/git token. The scaffolder references
115
+ * `${tokenEnvVar}` from `.npmrc` / git config so npm interpolates the token at
116
+ * install time and the raw token is never written into the committed repo.
117
+ */
118
+ export interface ProjectKitAuth {
119
+ /** Name of the wallet (project- or org-scoped) that holds the token. */
120
+ readonly walletName: string;
121
+ /** Env-var key, within the resolved wallet, that holds the auth token. */
122
+ readonly tokenEnvVar: string;
123
+ }
124
+
125
+ /**
126
+ * A package resolved from an npm registry. For the public registry, only
127
+ * `package` + `versionRange` are set. For a scoped private registry,
128
+ * `registryUrl` + `scope` declare the registry and `auth` points at the wallet
129
+ * entry holding the token — referenced from `.npmrc` via `${ENV}`
130
+ * interpolation, never written raw into the committed repo.
131
+ */
132
+ export interface NpmRegistryKitSource {
133
+ readonly kind: ProjectKitSourceKind.NpmRegistry;
134
+ /** Package name, e.g. `@acme/widgets` or `lodash`. */
135
+ readonly package: string;
136
+ /** Semver range stored into `package.json`, e.g. `^1.2.0`. */
137
+ readonly versionRange: string;
138
+ /** Registry URL for a scoped/private package. Omit for the public registry. */
139
+ readonly registryUrl?: string;
140
+ /** npm scope (`@acme`) the `registryUrl` serves. Required when `registryUrl` is set. */
141
+ readonly scope?: string;
142
+ /** Wallet-backed auth for a private registry. Omit for public registries. */
143
+ readonly auth?: ProjectKitAuth;
144
+ }
145
+
146
+ /**
147
+ * A package resolved directly from a git repository. `package.json` records
148
+ * `git+<gitUrl>#<ref>`. For a private repo, `auth` points at the wallet entry
149
+ * holding the git token; the workspace rewrites the clone URL with it via git
150
+ * `insteadOf` so the committed `package.json` URL stays clean.
151
+ */
152
+ export interface GitKitSource {
153
+ readonly kind: ProjectKitSourceKind.Git;
154
+ /** HTTPS git URL, e.g. `https://gitea.example.com/xema/component-library.git`. */
155
+ readonly gitUrl: string;
156
+ /** Tag / branch / commit to pin. Strongly recommended. */
157
+ readonly ref?: string;
158
+ /**
159
+ * The `package.json` `name` the repo publishes — i.e. the key the kit
160
+ * lands under in the consuming repo's `dependencies`. An npm-registry
161
+ * source carries this implicitly as `package`; a git source does not,
162
+ * so it is declared here. When set, the deterministic provisioning
163
+ * `EQUIP` step can guard on `MARKER_ABSENT` (`/dependencies/<packageName>`)
164
+ * and cleanly skip an already-installed kit. When omitted, the EQUIP
165
+ * step falls back to an unconditional (still idempotent) `npm install`.
166
+ */
167
+ readonly packageName?: string;
168
+ /** Wallet-backed auth for a private repository. Omit for public repos. */
169
+ readonly auth?: ProjectKitAuth;
170
+ }
171
+
172
+ /** Discriminated union of every `NpmDependency` kit source. */
173
+ export type ProjectKitSource = NpmRegistryKitSource | GitKitSource;
174
+
175
+ /** Discriminator for how a per-session kit binding was chosen. */
176
+ export enum ProjectKitBindingKind {
177
+ /** A first-party kit picked from the seeded catalog (referenced by slug). */
178
+ Catalog = 'catalog',
179
+ /** A kit the user supplied ad-hoc (an npm name or git URL pasted at create time). */
180
+ Custom = 'custom',
181
+ }
182
+
183
+ /** A binding that references a catalog kit by slug. */
184
+ export interface CatalogProjectKitBinding {
185
+ readonly binding: ProjectKitBindingKind.Catalog;
186
+ readonly slug: string;
187
+ }
188
+
189
+ /** A binding that carries its own inline kit spec (user-provided). */
190
+ export interface CustomProjectKitBinding {
191
+ readonly binding: ProjectKitBindingKind.Custom;
192
+ readonly kitKind: ProjectKitKind;
193
+ /** Defaults to `GenericDependency` when the user does not classify it. */
194
+ readonly purpose?: ProjectKitPurpose;
195
+ readonly source: ProjectKitSource;
196
+ }
197
+
198
+ /**
199
+ * A kit attached to a single interactive session. Persisted on the owning
200
+ * session-domain row (e.g. `WebappStudio.projectKits`) and threaded verbatim
201
+ * through `customConfig.projectKits` to the session.
202
+ */
203
+ export type ProjectKitBinding =
204
+ | CatalogProjectKitBinding
205
+ | CustomProjectKitBinding;
206
+
207
+ /**
208
+ * A kit binding after the session bootstrap has resolved every catalog
209
+ * reference against the kit catalog. The deterministic `provision` phase
210
+ * synthesizes one guard-gated EQUIP step per resolved kit.
211
+ *
212
+ * `compatibleTargets` is an opaque list of tech-stack tags — the consuming
213
+ * session type interprets them (webapp-studio matches them against its
214
+ * `appTarget.kind` values). This contract does not know what the tags mean.
215
+ */
216
+ export interface ResolvedProjectKit {
217
+ /** Stable identifier — the catalog slug, or a derived id for custom bindings. */
218
+ readonly id: string;
219
+ readonly kitKind: ProjectKitKind;
220
+ readonly purpose: ProjectKitPurpose;
221
+ readonly source: ProjectKitSource;
222
+ /** Skill slug the bootstrap mounts so the agent knows how to use the kit. */
223
+ readonly enrichmentSkillSlug?: string;
224
+ /** Opaque tech-stack tags the consuming session type matches against. */
225
+ readonly compatibleTargets: readonly string[];
226
+ }
227
+
@@ -0,0 +1,17 @@
1
+ // ═══════════════════════════════════════════════════════════════════════════
2
+ // @xemahq/provisioning-contracts — Workspace Provisioning wire contracts.
3
+ //
4
+ // Pure types + Zod schemas for the `provision` lifecycle phase (Epic A): the
5
+ // deterministic, guard-gated `SCAFFOLD` / `EQUIP` steps that prepare a
6
+ // session's repo content. agent-session-api's `provisioning-plan-resolver`
7
+ // RESOLVES a plan from biome manifests; workspace-proxy's
8
+ // `provisioning-plan` handler EXECUTES it. Both validate against the schemas
9
+ // here, so the wire shape has exactly one source of truth.
10
+ //
11
+ // A FOCUSED leaf package on purpose (same rationale as
12
+ // `@xemahq/project-kit-contracts`): kept un-nested so any service exposing
13
+ // these enums via `@ApiProperty({ enum })` resolves a clean top-level
14
+ // specifier. Zero runtime deps beyond `zod`.
15
+ // ═══════════════════════════════════════════════════════════════════════════
16
+
17
+ export * from './lib/provisioning';