@superpanel-sdk/runtime 0.2.3 → 0.5.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 (282) hide show
  1. package/README.md +28 -8
  2. package/dist/builder/codegen/emit.d.ts +29 -11
  3. package/dist/builder/codegen/emit.js +328 -61
  4. package/dist/builder/codegen/generate.d.ts +21 -0
  5. package/dist/builder/codegen/generate.js +152 -20
  6. package/dist/builder/company-import-graph.d.ts +2 -0
  7. package/dist/builder/company-import-graph.js +40 -8
  8. package/dist/builder/company-imports.d.ts +24 -0
  9. package/dist/builder/company-imports.js +114 -0
  10. package/dist/builder/compile/compile-sequence.d.ts +59 -8
  11. package/dist/builder/compile/compile-sequence.js +279 -77
  12. package/dist/builder/compile/function-code.d.ts +12 -2
  13. package/dist/builder/compile/function-code.js +87 -39
  14. package/dist/builder/compile/registry.d.ts +7 -3
  15. package/dist/builder/compile/registry.js +24 -23
  16. package/dist/builder/load.d.ts +70 -10
  17. package/dist/builder/load.js +250 -61
  18. package/dist/builder/paths.d.ts +3 -0
  19. package/dist/builder/paths.js +16 -0
  20. package/dist/builder/schedules.d.ts +23 -0
  21. package/dist/builder/schedules.js +102 -0
  22. package/dist/builder/slot-schema-validation.d.ts +4 -0
  23. package/dist/builder/slot-schema-validation.js +10 -0
  24. package/dist/builder/typecheck.d.ts +8 -0
  25. package/dist/builder/typecheck.js +105 -0
  26. package/dist/builder/types.d.ts +91 -19
  27. package/dist/builder/types.js +2 -1
  28. package/dist/cli/auth/auth.d.ts +37 -0
  29. package/dist/cli/auth/auth.js +211 -0
  30. package/dist/cli/auth/backend-url.d.ts +5 -0
  31. package/dist/cli/auth/backend-url.js +25 -0
  32. package/dist/cli/auth/clipboard.d.ts +9 -0
  33. package/dist/cli/auth/clipboard.js +38 -0
  34. package/dist/cli/auth/http.d.ts +20 -0
  35. package/dist/cli/auth/http.js +27 -0
  36. package/dist/cli/auth/index.d.ts +10 -0
  37. package/dist/cli/auth/index.js +27 -0
  38. package/dist/cli/auth/progress.d.ts +12 -0
  39. package/dist/cli/auth/progress.js +15 -0
  40. package/dist/cli/auth/serve-login.d.ts +8 -0
  41. package/dist/cli/auth/serve-login.js +24 -0
  42. package/dist/cli/compile/index.js +3 -0
  43. package/dist/cli/config.d.ts +10 -0
  44. package/dist/cli/config.js +52 -0
  45. package/dist/cli/index.js +28 -8
  46. package/dist/cli/serve/index.d.ts +73 -3
  47. package/dist/cli/serve/index.js +365 -116
  48. package/dist/cli/type-gen/index.js +9 -8
  49. package/dist/compiler.d.ts +7 -0
  50. package/dist/compiler.js +7 -0
  51. package/dist/compute-host/compute-host.d.ts +15 -23
  52. package/dist/compute-host/compute-host.js +25 -28
  53. package/dist/compute-host/index.d.ts +2 -4
  54. package/dist/compute-host/index.js +1 -2
  55. package/dist/compute-host/source-compute-host.d.ts +11 -9
  56. package/dist/compute-host/source-compute-host.js +46 -32
  57. package/dist/core/case-orchestrator/contact-hours.d.ts +50 -0
  58. package/dist/core/case-orchestrator/contact-hours.js +108 -0
  59. package/dist/core/case-orchestrator/follow-ups.d.ts +31 -0
  60. package/dist/core/case-orchestrator/follow-ups.js +103 -0
  61. package/dist/core/case-orchestrator/index.d.ts +6 -0
  62. package/dist/core/case-orchestrator/index.js +6 -0
  63. package/dist/core/case-orchestrator/render.d.ts +75 -0
  64. package/dist/core/case-orchestrator/render.js +239 -0
  65. package/dist/core/case-orchestrator/time.d.ts +11 -0
  66. package/dist/core/case-orchestrator/time.js +29 -0
  67. package/dist/core/case-orchestrator/tools.d.ts +29 -0
  68. package/dist/core/case-orchestrator/tools.js +31 -0
  69. package/dist/core/case-orchestrator/types.d.ts +753 -0
  70. package/dist/core/case-orchestrator/types.js +46 -0
  71. package/dist/core/case-orchestrator/validate.d.ts +11 -0
  72. package/dist/core/case-orchestrator/validate.js +63 -0
  73. package/dist/core/context/call.d.ts +291 -0
  74. package/dist/core/context/call.js +94 -0
  75. package/dist/core/context/channels.d.ts +60 -0
  76. package/dist/core/context/channels.js +35 -0
  77. package/dist/core/context/contact.d.ts +96 -6
  78. package/dist/core/context/contact.js +48 -2
  79. package/dist/core/context/email-message.d.ts +159 -0
  80. package/dist/core/context/email-message.js +59 -0
  81. package/dist/core/context/email.d.ts +97 -0
  82. package/dist/core/context/email.js +91 -0
  83. package/dist/core/context/exchanges.d.ts +142 -0
  84. package/dist/core/context/exchanges.js +63 -0
  85. package/dist/core/context/instances.d.ts +278 -0
  86. package/dist/core/context/instances.js +123 -0
  87. package/dist/core/context/kv.d.ts +113 -0
  88. package/dist/core/context/kv.js +60 -0
  89. package/dist/core/context/platform-registry.d.ts +509 -4
  90. package/dist/core/context/platform-registry.js +14 -2
  91. package/dist/core/context/platform.d.ts +2 -1
  92. package/dist/core/context/sms.d.ts +147 -0
  93. package/dist/core/context/sms.js +57 -0
  94. package/dist/core/context/types.d.ts +51 -48
  95. package/dist/core/context/types.js +1 -7
  96. package/dist/core/conversation/index.d.ts +31 -0
  97. package/dist/core/conversation/index.js +14 -0
  98. package/dist/core/functions/define/bind.d.ts +25 -0
  99. package/dist/core/functions/define/bind.js +14 -0
  100. package/dist/core/functions/define/case.d.ts +9 -0
  101. package/dist/core/functions/define/case.js +13 -0
  102. package/dist/core/functions/define/events.d.ts +20 -0
  103. package/dist/core/functions/define/events.js +21 -0
  104. package/dist/core/functions/define/no-case.d.ts +4 -0
  105. package/dist/core/functions/define/no-case.js +9 -0
  106. package/dist/core/functions/events.d.ts +247 -0
  107. package/dist/core/functions/events.js +32 -0
  108. package/dist/core/functions/func-ref.d.ts +11 -2
  109. package/dist/core/functions/schedules.d.ts +51 -0
  110. package/dist/core/functions/schedules.js +20 -0
  111. package/dist/core/functions/types.d.ts +62 -51
  112. package/dist/core/functions/types.js +6 -1
  113. package/dist/core/office-hours/index.d.ts +39 -0
  114. package/dist/core/office-hours/index.js +187 -0
  115. package/dist/core/page/define.d.ts +834 -0
  116. package/dist/core/page/define.js +477 -0
  117. package/dist/core/page/ops.d.ts +58 -0
  118. package/dist/core/page/ops.js +220 -0
  119. package/dist/core/page/render.d.ts +253 -0
  120. package/dist/core/page/render.js +840 -0
  121. package/dist/core/page/time-format.d.ts +19 -0
  122. package/dist/core/page/time-format.js +41 -0
  123. package/dist/core/page/timeline.d.ts +40 -0
  124. package/dist/core/page/timeline.js +2 -0
  125. package/dist/core/page/typed.d.ts +642 -0
  126. package/dist/core/page/typed.js +2 -0
  127. package/dist/core/page/workspace.d.ts +33 -0
  128. package/dist/core/page/workspace.js +231 -0
  129. package/dist/core/party/index.d.ts +3 -0
  130. package/dist/core/party/index.js +3 -0
  131. package/dist/core/party/schema.d.ts +137 -0
  132. package/dist/core/party/schema.js +80 -0
  133. package/dist/core/party/types.d.ts +40 -0
  134. package/dist/core/party/types.js +15 -0
  135. package/dist/core/sequence/define.d.ts +57 -0
  136. package/dist/core/sequence/define.js +10 -0
  137. package/dist/core/sequence/index.d.ts +63 -0
  138. package/dist/core/sequence/index.js +231 -0
  139. package/dist/core/slot/binding.d.ts +40 -0
  140. package/dist/core/slot/binding.js +2 -0
  141. package/dist/core/slot/company-metadata.d.ts +113 -0
  142. package/dist/core/slot/company-metadata.js +563 -0
  143. package/dist/core/slot/compile-schema.d.ts +19 -13
  144. package/dist/core/slot/compile-schema.js +51 -248
  145. package/dist/core/slot/contact-timezone.d.ts +110 -0
  146. package/dist/core/slot/contact-timezone.js +186 -0
  147. package/dist/core/slot/field.d.ts +2 -24
  148. package/dist/core/slot/field.js +0 -69
  149. package/dist/core/slot/id-ref.d.ts +17 -2
  150. package/dist/core/slot/id-ref.js +16 -8
  151. package/dist/core/slot/index.d.ts +12 -13
  152. package/dist/core/slot/index.js +11 -12
  153. package/dist/core/slot/naming.d.ts +15 -0
  154. package/dist/core/slot/naming.js +96 -0
  155. package/dist/core/slot/platform-fields.d.ts +119 -0
  156. package/dist/core/slot/platform-fields.js +121 -0
  157. package/dist/core/slot/ref.d.ts +16 -0
  158. package/dist/core/slot/ref.js +14 -0
  159. package/dist/core/slot/row.d.ts +2 -9
  160. package/dist/core/slot/row.js +13 -23
  161. package/dist/core/slot/schema-compat.d.ts +16 -0
  162. package/dist/core/slot/schema-compat.js +112 -0
  163. package/dist/core/slot/schema.d.ts +409 -76
  164. package/dist/core/slot/schema.js +178 -10
  165. package/dist/core/slot/types.d.ts +27 -94
  166. package/dist/core/slot/value.d.ts +26 -3
  167. package/dist/core/slot/value.js +89 -57
  168. package/dist/dev-overlay/protocol.d.ts +41 -8
  169. package/dist/fn-context/build-context.d.ts +3 -1
  170. package/dist/fn-context/build-context.js +20 -10
  171. package/dist/fn-context/fake/empty-api.js +9 -28
  172. package/dist/fn-context/fake/index.d.ts +11 -4
  173. package/dist/fn-context/fake/index.js +27 -2
  174. package/dist/fn-context/fn-params.d.ts +6 -0
  175. package/dist/fn-context/fn-params.js +13 -0
  176. package/dist/fn-context/index.d.ts +5 -5
  177. package/dist/fn-context/index.js +4 -4
  178. package/dist/fn-context/log.js +2 -2
  179. package/dist/fn-context/make-ctx.d.ts +11 -0
  180. package/dist/fn-context/make-ctx.js +18 -8
  181. package/dist/fn-context/rpc/case-orchestrator-tools.d.ts +24 -0
  182. package/dist/fn-context/rpc/case-orchestrator-tools.js +13 -0
  183. package/dist/fn-context/rpc/index.d.ts +3 -1
  184. package/dist/fn-context/rpc/index.js +3 -1
  185. package/dist/fn-context/rpc/integration/index.d.ts +4 -4
  186. package/dist/fn-context/rpc/integration/index.js +1 -1
  187. package/dist/fn-context/rpc/integration/list-surfaces.d.ts +21 -0
  188. package/dist/fn-context/rpc/integration/{list-bindings.js → list-surfaces.js} +4 -4
  189. package/dist/fn-context/rpc/platform.d.ts +2 -2
  190. package/dist/fn-context/rpc/platform.js +1 -1
  191. package/dist/fn-context/rpc/records.d.ts +78 -0
  192. package/dist/fn-context/rpc/records.js +26 -0
  193. package/dist/fn-context/rpc/trpc-client.d.ts +2 -2
  194. package/dist/fn-context/rpc/trpc-client.js +88 -7
  195. package/dist/fn-context/rpc/trpc-init.d.ts +2 -2
  196. package/dist/fn-context/rpc/trpc-router-factory.d.ts +49 -3
  197. package/dist/fn-context/rpc/trpc-router-factory.js +2 -0
  198. package/dist/fn-context/run-scope.d.ts +4 -0
  199. package/dist/fn-context/run-scope.js +9 -0
  200. package/dist/fn-context/types.d.ts +36 -3
  201. package/dist/index.d.ts +37 -46
  202. package/dist/index.js +33 -33
  203. package/dist/logger.d.ts +7 -0
  204. package/dist/logger.js +41 -0
  205. package/dist/platform.d.ts +76 -0
  206. package/dist/platform.js +56 -0
  207. package/dist/voice-service/actions.d.ts +71 -4
  208. package/dist/voice-service/types.d.ts +42 -5
  209. package/dist/worker.d.ts +10 -0
  210. package/dist/worker.js +10 -0
  211. package/package.json +38 -19
  212. package/dist/builder/compile/compile-agenda.d.ts +0 -15
  213. package/dist/builder/compile/compile-agenda.js +0 -64
  214. package/dist/builder/merge.d.ts +0 -4
  215. package/dist/builder/merge.js +0 -19
  216. package/dist/compute-host/read-only-cache.d.ts +0 -20
  217. package/dist/compute-host/read-only-cache.js +0 -61
  218. package/dist/core/context/db.d.ts +0 -69
  219. package/dist/core/context/db.js +0 -44
  220. package/dist/core/context/docusign.d.ts +0 -134
  221. package/dist/core/context/docusign.js +0 -108
  222. package/dist/core/context/filevine.d.ts +0 -323
  223. package/dist/core/context/filevine.js +0 -254
  224. package/dist/core/context/http.d.ts +0 -9
  225. package/dist/core/context/http.js +0 -4
  226. package/dist/core/context/hubspot.d.ts +0 -250
  227. package/dist/core/context/hubspot.js +0 -191
  228. package/dist/core/context/twilio.d.ts +0 -50
  229. package/dist/core/context/twilio.js +0 -42
  230. package/dist/core/functions/define/case-context.d.ts +0 -14
  231. package/dist/core/functions/define/case-context.js +0 -15
  232. package/dist/core/functions/define/compute.d.ts +0 -7
  233. package/dist/core/functions/define/compute.js +0 -17
  234. package/dist/core/functions/define/custom.d.ts +0 -4
  235. package/dist/core/functions/define/custom.js +0 -8
  236. package/dist/core/functions/define/system.d.ts +0 -7
  237. package/dist/core/functions/define/system.js +0 -12
  238. package/dist/core/slot/deps.d.ts +0 -15
  239. package/dist/core/slot/deps.js +0 -88
  240. package/dist/core/slot/derived.d.ts +0 -32
  241. package/dist/core/slot/derived.js +0 -115
  242. package/dist/core/slot/platform-session-fields.d.ts +0 -38
  243. package/dist/core/slot/platform-session-fields.js +0 -48
  244. package/dist/core/slot/sf-schema.d.ts +0 -23
  245. package/dist/core/slot/sf-schema.js +0 -125
  246. package/dist/core/slot/sf-validate.d.ts +0 -14
  247. package/dist/core/slot/sf-validate.js +0 -132
  248. package/dist/core/slot/snapshot.d.ts +0 -18
  249. package/dist/core/slot/snapshot.js +0 -138
  250. package/dist/core/slot/write.d.ts +0 -48
  251. package/dist/core/slot/write.js +0 -426
  252. package/dist/core/stage/builders.d.ts +0 -54
  253. package/dist/core/stage/builders.js +0 -31
  254. package/dist/core/stage/condition.d.ts +0 -17
  255. package/dist/core/stage/condition.js +0 -198
  256. package/dist/core/stage/drive.d.ts +0 -43
  257. package/dist/core/stage/drive.js +0 -78
  258. package/dist/core/stage/finish-when.d.ts +0 -20
  259. package/dist/core/stage/finish-when.js +0 -82
  260. package/dist/core/stage/flatten.d.ts +0 -27
  261. package/dist/core/stage/flatten.js +0 -466
  262. package/dist/core/stage/index.d.ts +0 -15
  263. package/dist/core/stage/index.js +0 -13
  264. package/dist/core/stage/interrupts.d.ts +0 -28
  265. package/dist/core/stage/interrupts.js +0 -120
  266. package/dist/core/stage/ivr-fields.d.ts +0 -9
  267. package/dist/core/stage/ivr-fields.js +0 -75
  268. package/dist/core/stage/simulate.d.ts +0 -24
  269. package/dist/core/stage/simulate.js +0 -33
  270. package/dist/core/stage/transfer-fields.d.ts +0 -19
  271. package/dist/core/stage/transfer-fields.js +0 -129
  272. package/dist/core/stage/transfer-spec.d.ts +0 -48
  273. package/dist/core/stage/transfer-spec.js +0 -113
  274. package/dist/core/stage/types.d.ts +0 -208
  275. package/dist/core/stage/types.js +0 -2
  276. package/dist/core/stage/validate.d.ts +0 -11
  277. package/dist/core/stage/validate.js +0 -330
  278. package/dist/core/stage/walk.d.ts +0 -39
  279. package/dist/core/stage/walk.js +0 -119
  280. package/dist/fn-context/rpc/integration/list-bindings.d.ts +0 -21
  281. package/dist/fn-context/system-args.d.ts +0 -6
  282. package/dist/fn-context/system-args.js +0 -14
@@ -1,59 +1,160 @@
1
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
1
+ import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
2
2
  import path from 'node:path';
3
+ import { subjectTableIssues } from '../../core/slot/company-metadata.js';
4
+ import { compileSlotSchema } from '../../core/slot/compile-schema.js';
3
5
  import { withCompanyImportGraph } from '../company-import-graph.js';
4
- import { listSequenceIds, loadCompanySchema, loadSequenceSlots } from '../load.js';
5
- import { mergeEffectiveSchema } from '../merge.js';
6
+ import { assertNoSlotsModule, listSequenceIds, loadCompanySchema, loadSequenceDefinition, loadSessionSchema, } from '../load.js';
6
7
  import { findTsModule, resolveTsModule } from '../paths.js';
7
- import { emitCaseContextSource, emitCaseContextStub, emitSlotsSource, emitSlotsStub } from './emit.js';
8
+ import { fatalSlotSchemaIssues } from '../slot-schema-validation.js';
9
+ import { emitCaseContextSource, emitCaseContextStub, emitCompanyGenIndexSource, emitCompanyTablesSource, emitCompanyTablesStub, emitGenIndexSource, emitSlotsSource, emitSlotsStub, } from './emit.js';
8
10
  export { listSequenceIds };
11
+ /** The repository root's `__gen/`: types for `resolve.ts` and `webhook.ts`, bound to the company's tables. */
12
+ export function companyGenPaths(repoRoot) {
13
+ return {
14
+ tablesOutPath: path.join(repoRoot, '__gen', 'tables.type.ts'),
15
+ indexOutPath: path.join(repoRoot, '__gen', 'index.ts'),
16
+ };
17
+ }
9
18
  function sequenceSlotsGenPath(repoRoot, sequenceId) {
10
19
  return path.join(repoRoot, 'sequences', sequenceId, '__gen', 'slots.type.ts');
11
20
  }
21
+ /** Generated for `slots.ts`, which was removed (15 §10.17 第 1 条); type:gen deletes a leftover one. */
22
+ function legacySlotsConfigGenPath(repoRoot, sequenceId) {
23
+ return path.join(repoRoot, 'sequences', sequenceId, '__gen', 'slots-config.type.ts');
24
+ }
12
25
  function sequenceCaseContextGenPath(repoRoot, sequenceId) {
13
26
  return path.join(repoRoot, 'sequences', sequenceId, '__gen', 'case-context.type.ts');
14
27
  }
28
+ /** Generated for the declarative load, which was removed (15 §10.15); type:gen deletes a leftover one. */
29
+ function legacyLoadGenPath(repoRoot, sequenceId) {
30
+ return path.join(repoRoot, 'sequences', sequenceId, '__gen', 'load.type.ts');
31
+ }
32
+ function sequenceGenIndexPath(repoRoot, sequenceId) {
33
+ return path.join(repoRoot, 'sequences', sequenceId, '__gen', 'index.ts');
34
+ }
35
+ /** The sequence's `functions` module as `__gen/index.ts` imports it, or `null` when it has none. */
36
+ function functionsImportFor(repoRoot, sequenceId) {
37
+ return moduleImportFor(repoRoot, sequenceId, 'functions');
38
+ }
39
+ /** A module of the sequence (`functions`, `variables`) as `__gen/index.ts` imports it; null when absent. */
40
+ function moduleImportFor(repoRoot, sequenceId, name) {
41
+ const sequenceDir = path.join(repoRoot, 'sequences', sequenceId);
42
+ const found = findTsModule(sequenceDir, name);
43
+ if (!found)
44
+ return null;
45
+ return path.relative(path.join(sequenceDir, '__gen'), found).split(path.sep).join('/');
46
+ }
47
+ function errorMessage(error) {
48
+ return error instanceof Error ? error.message : String(error);
49
+ }
50
+ function throwGenerationFailures(failures) {
51
+ const errors = failures.map(({ sequenceId, error }) => new Error(`Sequence ${sequenceId}: ${errorMessage(error)}`, { cause: error }));
52
+ throw new AggregateError(errors, errors.map((error) => error.message).join('\n'));
53
+ }
15
54
  export async function generateSequence(repoRoot, sequenceId, options = {}) {
16
- return withCompanyImportGraph(repoRoot, () => generateSequenceInGraph(repoRoot, sequenceId, options));
55
+ return withCompanyImportGraph(repoRoot, async () => generateSequenceInGraph(repoRoot, sequenceId, options, await loadCompanySchemas(repoRoot)));
17
56
  }
18
- async function generateSequenceInGraph(repoRoot, sequenceId, options) {
57
+ /** The company's tables (`schema/index.ts`) and session fields (`schema/session.ts`). */
58
+ async function loadCompanySchemas(repoRoot) {
19
59
  const schemaPath = resolveTsModule(repoRoot, 'schema', `No company schema found. Expected schema.ts or schema/index.ts under ${repoRoot}`);
20
- const slotsPath = resolveTsModule(path.join(repoRoot, 'sequences', sequenceId), 'slots', `No sequence slots found. Expected sequences/${sequenceId}/slots.ts or sequences/${sequenceId}/slots/index.ts`);
21
- const company = await loadCompanySchema(schemaPath);
22
- const slots = await loadSequenceSlots(slotsPath);
23
- const effective = mergeEffectiveSchema(company, slots);
60
+ return { company: await loadCompanySchema(schemaPath), session: await loadSessionSchema(repoRoot) };
61
+ }
62
+ /** The root `__gen/` texts: the company's tables with no subject, as the company part compiles them. */
63
+ function companyGenSources({ company, session }) {
64
+ const { schema, validation } = compileSlotSchema(company, { session });
65
+ if (!validation.ok) {
66
+ const fatal = fatalSlotSchemaIssues(validation.issues);
67
+ if (fatal.length > 0)
68
+ throw new Error(fatal.map((issue) => issue.message).join('; '));
69
+ }
70
+ return { tablesSource: emitCompanyTablesSource(schema), indexSource: emitCompanyGenIndexSource() };
71
+ }
72
+ function writeCompanyGen(repoRoot, schemas) {
73
+ const { tablesOutPath, indexOutPath } = companyGenPaths(repoRoot);
74
+ const { tablesSource, indexSource } = companyGenSources(schemas);
75
+ mkdirSync(path.dirname(tablesOutPath), { recursive: true });
76
+ writeFileSync(tablesOutPath, tablesSource, 'utf8');
77
+ writeFileSync(indexOutPath, indexSource, 'utf8');
78
+ }
79
+ async function generateSequenceInGraph(repoRoot, sequenceId, options, { company, session }) {
24
80
  const sequenceDir = path.join(repoRoot, 'sequences', sequenceId);
25
- const hasCaseContextView = findTsModule(sequenceDir, 'view') !== undefined;
26
- const source = emitSlotsSource(effective);
27
- const caseContextSource = emitCaseContextSource({ hasCaseContextView });
81
+ assertNoSlotsModule(sequenceDir, sequenceId);
82
+ if (!options.dryRun)
83
+ ensureStub(repoRoot, sequenceId);
84
+ // The table types are the company's (root `__gen`); the sequence only names its subject (28 §2.2).
85
+ const { subject } = await loadSequenceDefinition(sequenceDir);
86
+ const subjectIssues = subjectTableIssues(company, subject);
87
+ if (subjectIssues.length > 0)
88
+ throw new Error(subjectIssues.map((issue) => issue.message).join('; '));
89
+ // The company schema is checked either way; a real run also writes the root `__gen` the sequence's types import.
90
+ const { tablesSource } = companyGenSources({ company, session });
91
+ if (!options.dryRun)
92
+ writeCompanyGen(repoRoot, { company, session });
93
+ // Every sequence has a page script (15 §10.2): the generated page types read it.
94
+ if (findTsModule(sequenceDir, 'context.page') === undefined) {
95
+ throw new Error(`sequences/${sequenceId}: context.page.ts is required (the conversation's page, 15 §10.2)`);
96
+ }
97
+ const source = emitSlotsSource(subject);
98
+ const caseContextSource = emitCaseContextSource();
99
+ const indexSource = emitGenIndexSource(functionsImportFor(repoRoot, sequenceId), moduleImportFor(repoRoot, sequenceId, 'variables'));
28
100
  const outPath = sequenceSlotsGenPath(repoRoot, sequenceId);
29
101
  const caseContextOutPath = sequenceCaseContextGenPath(repoRoot, sequenceId);
102
+ const indexOutPath = sequenceGenIndexPath(repoRoot, sequenceId);
30
103
  if (!options.dryRun) {
31
104
  mkdirSync(path.dirname(outPath), { recursive: true });
32
105
  writeFileSync(outPath, source, 'utf8');
33
106
  writeFileSync(caseContextOutPath, caseContextSource, 'utf8');
107
+ writeFileSync(indexOutPath, indexSource, 'utf8');
108
+ rmSync(legacyLoadGenPath(repoRoot, sequenceId), { force: true });
109
+ rmSync(legacySlotsConfigGenPath(repoRoot, sequenceId), { force: true });
34
110
  }
35
111
  return {
36
112
  sequenceId,
37
113
  outPath,
38
114
  caseContextOutPath,
115
+ indexOutPath,
39
116
  source,
40
117
  caseContextSource,
118
+ indexSource,
119
+ tablesSource,
41
120
  wrote: !options.dryRun,
42
121
  };
43
122
  }
123
+ /**
124
+ * The root `__gen/` alone, from the company schema: what the root code of a repository with no
125
+ * sequence is typed by (22 §11). `generateAll` writes it too, with the sequences.
126
+ */
127
+ export async function generateCompany(repoRoot) {
128
+ return withCompanyImportGraph(repoRoot, async () => writeCompanyGen(repoRoot, await loadCompanySchemas(repoRoot)));
129
+ }
44
130
  export async function generateAll(repoRoot, options = {}) {
45
131
  return withCompanyImportGraph(repoRoot, async () => {
46
132
  const ids = options.sequenceIds ?? listSequenceIds(repoRoot);
47
133
  if (ids.length === 0) {
48
- throw new Error(`No sequences with slots found under ${path.join(repoRoot, 'sequences')} (expected slots.ts or slots/index.ts)`);
134
+ throw new Error(NO_SEQUENCES(repoRoot));
49
135
  }
136
+ const schemas = await loadCompanySchemas(repoRoot);
137
+ // The root's types depend on the schema only: written with every full run (a schema change is one).
138
+ if (!options.dryRun && !options.sequenceIds)
139
+ writeCompanyGen(repoRoot, schemas);
140
+ // Keeps going after failures so valid sequences still regenerate and the caller receives every
141
+ // sequence error in one AggregateError.
142
+ const failures = [];
50
143
  const results = [];
51
144
  for (const sequenceId of ids) {
52
- results.push(await generateSequence(repoRoot, sequenceId, options));
145
+ try {
146
+ results.push(await generateSequenceInGraph(repoRoot, sequenceId, options, schemas));
147
+ }
148
+ catch (error) {
149
+ failures.push({ sequenceId, error });
150
+ }
53
151
  }
152
+ if (failures.length > 0)
153
+ throwGenerationFailures(failures);
54
154
  return results;
55
155
  });
56
156
  }
157
+ const NO_SEQUENCES = (repoRoot) => `No sequences found under ${path.join(repoRoot, 'sequences')} (a sequence is a directory with index.ts)`;
57
158
  function assertFileMatches(outPath, next, repoRoot) {
58
159
  let current = '';
59
160
  try {
@@ -67,20 +168,35 @@ function assertFileMatches(outPath, next, repoRoot) {
67
168
  }
68
169
  }
69
170
  export async function checkSequence(repoRoot, sequenceId) {
70
- const { outPath, caseContextOutPath, source, caseContextSource } = await generateSequence(repoRoot, sequenceId, {
71
- dryRun: true,
72
- });
171
+ const { outPath, caseContextOutPath, indexOutPath, source, caseContextSource, indexSource } = await generateSequence(repoRoot, sequenceId, { dryRun: true });
73
172
  assertFileMatches(outPath, source, repoRoot);
74
173
  assertFileMatches(caseContextOutPath, caseContextSource, repoRoot);
174
+ assertFileMatches(indexOutPath, indexSource, repoRoot);
175
+ }
176
+ /** The root `__gen/` matches the company schema. */
177
+ export async function checkCompany(repoRoot) {
178
+ const { tablesSource, indexSource } = await withCompanyImportGraph(repoRoot, async () => companyGenSources(await loadCompanySchemas(repoRoot)));
179
+ const { tablesOutPath, indexOutPath } = companyGenPaths(repoRoot);
180
+ assertFileMatches(tablesOutPath, tablesSource, repoRoot);
181
+ assertFileMatches(indexOutPath, indexSource, repoRoot);
75
182
  }
76
183
  export async function checkAll(repoRoot) {
77
184
  const ids = listSequenceIds(repoRoot);
78
185
  if (ids.length === 0) {
79
- throw new Error(`No sequences with slots found under ${path.join(repoRoot, 'sequences')} (expected slots.ts or slots/index.ts)`);
186
+ throw new Error(NO_SEQUENCES(repoRoot));
80
187
  }
188
+ await checkCompany(repoRoot);
189
+ const failures = [];
81
190
  for (const sequenceId of ids) {
82
- await checkSequence(repoRoot, sequenceId);
191
+ try {
192
+ await checkSequence(repoRoot, sequenceId);
193
+ }
194
+ catch (error) {
195
+ failures.push({ sequenceId, error });
196
+ }
83
197
  }
198
+ if (failures.length > 0)
199
+ throwGenerationFailures(failures);
84
200
  }
85
201
  export function ensureStub(repoRoot, sequenceId) {
86
202
  const slotsPath = sequenceSlotsGenPath(repoRoot, sequenceId);
@@ -92,5 +208,21 @@ export function ensureStub(repoRoot, sequenceId) {
92
208
  if (!existsSync(caseContextPath)) {
93
209
  writeFileSync(caseContextPath, emitCaseContextStub(), 'utf8');
94
210
  }
211
+ const indexPath = sequenceGenIndexPath(repoRoot, sequenceId);
212
+ if (!existsSync(indexPath)) {
213
+ writeFileSync(indexPath, emitGenIndexSource(functionsImportFor(repoRoot, sequenceId), moduleImportFor(repoRoot, sequenceId, 'variables')), 'utf8');
214
+ }
215
+ }
216
+ /**
217
+ * Writes the root `__gen/` files that are missing (a fresh checkout has none: `__gen/` is gitignored),
218
+ * so `resolve.ts` and `webhook.ts` can import it; existing ones are left untouched.
219
+ */
220
+ export function ensureCompanyStub(repoRoot) {
221
+ const { tablesOutPath, indexOutPath } = companyGenPaths(repoRoot);
222
+ mkdirSync(path.dirname(tablesOutPath), { recursive: true });
223
+ if (!existsSync(tablesOutPath))
224
+ writeFileSync(tablesOutPath, emitCompanyTablesStub(), 'utf8');
225
+ if (!existsSync(indexOutPath))
226
+ writeFileSync(indexOutPath, emitCompanyGenIndexSource(), 'utf8');
95
227
  }
96
228
  //# sourceMappingURL=generate.js.map
@@ -1,3 +1,5 @@
1
+ /** The repository the current company import graph loads, or null outside one. */
2
+ export declare function companyRepoRoot(): string | null;
1
3
  /** Stamp a company-repo entry URL, or return it unchanged outside a graph. */
2
4
  export declare function companyImportGraphHref(fileHref: string): string;
3
5
  /**
@@ -3,6 +3,7 @@ import { realpathSync } from 'node:fs';
3
3
  import { registerHooks } from 'node:module';
4
4
  import path from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
6
+ import { COMMONJS_ISSUE, companyImportError, resolvedIssue, specifierIssue } from './company-imports.js';
6
7
  const COMPANY_GRAPH_GEN_QUERY = 'spgen';
7
8
  const COMPANY_GRAPH_ROOT_QUERY = 'sproot';
8
9
  const graph = new AsyncLocalStorage();
@@ -34,16 +35,23 @@ function inNodeModules(filePath, url) {
34
35
  filePath.includes(`${path.sep}node_modules${path.sep}`));
35
36
  }
36
37
  function stampCompanyResolve(specifier, context, nextResolve) {
37
- const result = nextResolve(specifier, context);
38
- if (!result.url.startsWith('file:'))
39
- return result;
40
- const resolved = new URL(result.url);
41
- if (resolved.searchParams.has(COMPANY_GRAPH_GEN_QUERY))
42
- return result;
43
38
  const parent = context.parentURL ? new URL(context.parentURL) : null;
44
39
  const graphGeneration = parent?.searchParams.get(COMPANY_GRAPH_GEN_QUERY);
45
40
  const repoRoot = parent?.searchParams.get(COMPANY_GRAPH_ROOT_QUERY);
46
- if (!graphGeneration || !repoRoot)
41
+ // A company file's import is checked before it loads: what company code may import (company-imports.ts).
42
+ const importer = parent && graphGeneration && repoRoot ? filePathFromUrl(parent.href) : null;
43
+ if (importer && repoRoot) {
44
+ const issue = specifierIssue(specifier);
45
+ if (issue)
46
+ throw companyImportError(importer, repoRoot, issue);
47
+ }
48
+ const result = nextResolve(specifier, context);
49
+ if (!result.url.startsWith('file:')) {
50
+ if (importer && repoRoot)
51
+ throw companyImportError(importer, repoRoot, `'${specifier}' is not a file of the repository`);
52
+ return result;
53
+ }
54
+ if (!importer || !graphGeneration || !repoRoot)
47
55
  return result;
48
56
  let resolvedFile;
49
57
  try {
@@ -52,6 +60,12 @@ function stampCompanyResolve(specifier, context, nextResolve) {
52
60
  catch {
53
61
  return result;
54
62
  }
63
+ const issue = resolvedIssue(specifier, resolvedFile, repoRoot);
64
+ if (issue)
65
+ throw companyImportError(importer, repoRoot, issue);
66
+ const resolved = new URL(result.url);
67
+ if (resolved.searchParams.has(COMPANY_GRAPH_GEN_QUERY))
68
+ return result;
55
69
  if (inNodeModules(resolvedFile, result.url))
56
70
  return result;
57
71
  if (!underRoot(resolvedFile, repoRoot))
@@ -60,11 +74,29 @@ function stampCompanyResolve(specifier, context, nextResolve) {
60
74
  resolved.searchParams.set(COMPANY_GRAPH_ROOT_QUERY, repoRoot);
61
75
  return { ...result, url: resolved.href };
62
76
  }
77
+ /**
78
+ * A company file Node loads as CommonJS (a `.ts` under a `"type": "commonjs"` package.json; `.cts` and
79
+ * `.cjs` are refused when imported) is refused: its `require` calls would go unchecked.
80
+ */
81
+ const refuseCommonJs = (url, context, nextLoad) => {
82
+ const result = nextLoad(url, context);
83
+ if (result.format !== 'commonjs' && result.format !== 'commonjs-typescript')
84
+ return result;
85
+ const loaded = new URL(url);
86
+ const repoRoot = loaded.searchParams.get(COMPANY_GRAPH_ROOT_QUERY);
87
+ if (!repoRoot || !loaded.searchParams.has(COMPANY_GRAPH_GEN_QUERY))
88
+ return result;
89
+ throw companyImportError(filePathFromUrl(url), repoRoot, COMMONJS_ISSUE);
90
+ };
63
91
  function ensureHookRegistered() {
64
92
  if (registered)
65
93
  return;
66
94
  registered = true;
67
- registerHooks({ resolve: stampCompanyResolve });
95
+ registerHooks({ resolve: stampCompanyResolve, load: refuseCommonJs });
96
+ }
97
+ /** The repository the current company import graph loads, or null outside one. */
98
+ export function companyRepoRoot() {
99
+ return graph.getStore()?.repoRoot ?? null;
68
100
  }
69
101
  /** Stamp a company-repo entry URL, or return it unchanged outside a graph. */
70
102
  export function companyImportGraphHref(fileHref) {
@@ -0,0 +1,24 @@
1
+ /**
2
+ * What company code may import (09-runtime-compat §6): the company API, `@superpanel-sdk/runtime`, and
3
+ * the repository's own files. No other package, no Node module, no other runtime entry and no file of
4
+ * the runtime's own. The compile checks every import of a company file against this twice: in Node,
5
+ * as it loads the repo (`company-import-graph.ts`), and in esbuild, as it bundles a code string
6
+ * (`function-code.ts`). Both use this one rule, so serve, `compile` and a release agree.
7
+ */
8
+ export declare const RUNTIME_PACKAGE = "@superpanel-sdk/runtime";
9
+ export declare function realPath(filePath: string): string;
10
+ /** The directory of the nearest `package.json` above `file`, else the file's own directory. */
11
+ export declare function packageRootOf(file: string): string;
12
+ /** Whether `file` is a runtime package's company API: `dist/index.js`, its types, or `src/index.ts`. */
13
+ export declare function isCompanyApiFile(file: string): boolean;
14
+ /**
15
+ * Why company code may not import `specifier`, known before resolving it; null when only the resolved
16
+ * file can tell (a path, a `#…` import, or the company API).
17
+ */
18
+ export declare function specifierIssue(specifier: string): string | null;
19
+ /** Why `specifier`, resolved to `file`, may not be imported by a file of the company repo at `repoRoot`; null when it may. */
20
+ export declare function resolvedIssue(specifier: string, file: string, repoRoot: string): string | null;
21
+ export declare const COMMONJS_ISSUE = "is CommonJS (.cts, .cjs, or \"type\": \"commonjs\"): company code is ES modules";
22
+ /** The message a refused import fails the compile with: which file, what it imported, and why not. */
23
+ export declare function companyImportError(importer: string, repoRoot: string, issue: string): Error;
24
+ //# sourceMappingURL=company-imports.d.ts.map
@@ -0,0 +1,114 @@
1
+ import { existsSync, readFileSync, realpathSync } from 'node:fs';
2
+ import { isBuiltin } from 'node:module';
3
+ import path from 'node:path';
4
+ /**
5
+ * What company code may import (09-runtime-compat §6): the company API, `@superpanel-sdk/runtime`, and
6
+ * the repository's own files. No other package, no Node module, no other runtime entry and no file of
7
+ * the runtime's own. The compile checks every import of a company file against this twice: in Node,
8
+ * as it loads the repo (`company-import-graph.ts`), and in esbuild, as it bundles a code string
9
+ * (`function-code.ts`). Both use this one rule, so serve, `compile` and a release agree.
10
+ */
11
+ export const RUNTIME_PACKAGE = '@superpanel-sdk/runtime';
12
+ /**
13
+ * The company API's files in a runtime package: built (with its types, which a tsconfig `paths` may
14
+ * name), or the source the runtime's own tests run.
15
+ */
16
+ const COMPANY_API_FILES = new Set([path.join('dist', 'index.js'), path.join('dist', 'index.d.ts'), path.join('src', 'index.ts')]);
17
+ const packageNames = new Map();
18
+ export function realPath(filePath) {
19
+ try {
20
+ return realpathSync(filePath);
21
+ }
22
+ catch {
23
+ return path.resolve(filePath);
24
+ }
25
+ }
26
+ /** The directory of the nearest `package.json` above `file`, else the file's own directory. */
27
+ export function packageRootOf(file) {
28
+ for (let dir = path.dirname(path.resolve(file));; dir = path.dirname(dir)) {
29
+ if (existsSync(path.join(dir, 'package.json')))
30
+ return dir;
31
+ if (path.dirname(dir) === dir)
32
+ return path.dirname(path.resolve(file));
33
+ }
34
+ }
35
+ /** The directory and name of the package that holds `file`: the nearest `package.json` above it. */
36
+ function owningPackage(file) {
37
+ let dir = path.dirname(file);
38
+ for (;;) {
39
+ let name = packageNames.get(dir);
40
+ if (name === undefined) {
41
+ try {
42
+ const pkg = JSON.parse(readFileSync(path.join(dir, 'package.json'), 'utf8'));
43
+ name = typeof pkg.name === 'string' ? pkg.name : null;
44
+ }
45
+ catch {
46
+ name = null;
47
+ }
48
+ packageNames.set(dir, name);
49
+ }
50
+ if (name !== null)
51
+ return { dir, name };
52
+ const parent = path.dirname(dir);
53
+ if (parent === dir)
54
+ return null;
55
+ dir = parent;
56
+ }
57
+ }
58
+ /** Whether `file` is a runtime package's company API: `dist/index.js`, its types, or `src/index.ts`. */
59
+ export function isCompanyApiFile(file) {
60
+ const resolved = realPath(file);
61
+ const owner = owningPackage(resolved);
62
+ return owner?.name === RUNTIME_PACKAGE && COMPANY_API_FILES.has(path.relative(owner.dir, resolved));
63
+ }
64
+ /**
65
+ * A package name or a Node module, as opposed to a path (`./x`, `/x`), a URL (`file:`, `node:`) or a
66
+ * `#…` import the repo's package.json maps (which the resolved file decides, like a path).
67
+ */
68
+ function isBareSpecifier(specifier) {
69
+ return (!specifier.startsWith('.') &&
70
+ !specifier.startsWith('/') &&
71
+ !specifier.startsWith('#') &&
72
+ !/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(specifier));
73
+ }
74
+ /**
75
+ * Why company code may not import `specifier`, known before resolving it; null when only the resolved
76
+ * file can tell (a path, a `#…` import, or the company API).
77
+ */
78
+ export function specifierIssue(specifier) {
79
+ if (isBuiltin(specifier)) {
80
+ return `'${specifier}' is a Node module: company code is bundled into self-contained code that cannot import one, and the page's sandbox has no Node`;
81
+ }
82
+ if (!isBareSpecifier(specifier) || specifier === RUNTIME_PACKAGE)
83
+ return null;
84
+ if (specifier.startsWith(`${RUNTIME_PACKAGE}/`))
85
+ return `'${specifier}' is the platform's; company code imports '${RUNTIME_PACKAGE}'`;
86
+ return `'${specifier}' is a package; company code imports only '${RUNTIME_PACKAGE}' and the repository's own files`;
87
+ }
88
+ /** Why `specifier`, resolved to `file`, may not be imported by a file of the company repo at `repoRoot`; null when it may. */
89
+ export function resolvedIssue(specifier, file, repoRoot) {
90
+ if (specifier === RUNTIME_PACKAGE) {
91
+ return isCompanyApiFile(file) ? null : `'${specifier}' resolves to ${file}, not the runtime's company API`;
92
+ }
93
+ const resolved = realPath(file);
94
+ const relative = path.relative(realPath(repoRoot), resolved);
95
+ const inRepo = relative !== '' && !relative.startsWith('..') && !path.isAbsolute(relative);
96
+ if (!inRepo || relative.split(path.sep).includes('node_modules')) {
97
+ return `'${specifier}' resolves to ${inRepo ? relative : resolved}, outside the repository's own files`;
98
+ }
99
+ if (COMMONJS_EXTENSIONS.has(path.extname(resolved)))
100
+ return `'${specifier}' ${COMMONJS_ISSUE}`;
101
+ return null;
102
+ }
103
+ /**
104
+ * Company code is ES modules. A CommonJS file's `require` calls reach Node's resolve hook without the
105
+ * import graph's stamp, so nothing would check what it loads: the compile refuses the file instead.
106
+ */
107
+ const COMMONJS_EXTENSIONS = new Set(['.cjs', '.cts']);
108
+ export const COMMONJS_ISSUE = 'is CommonJS (.cts, .cjs, or "type": "commonjs"): company code is ES modules';
109
+ /** The message a refused import fails the compile with: which file, what it imported, and why not. */
110
+ export function companyImportError(importer, repoRoot, issue) {
111
+ const where = path.relative(realPath(repoRoot), realPath(importer)) || importer;
112
+ return new Error(`${where}: ${issue} (AGENTS.md, "Imports")`);
113
+ }
114
+ //# sourceMappingURL=company-imports.js.map
@@ -1,18 +1,14 @@
1
- import type { FuncMap } from '../../core/functions/types.js';
2
- import type { CompanySchema } from '../../core/slot/schema.js';
3
- import type { RuntimePackageSource, SequenceBuild } from '../types.js';
4
- /** SequenceBuild / SequenceConfigBuild cache key. Bump when compiled `code` shape changes. */
1
+ import type { CompiledSlotSchema } from '../../core/slot/types.js';
2
+ import type { CompiledCompanyMetadata } from '../../core/slot/schema.js';
3
+ import type { CompanyPart, RuntimePackageSource, SequenceBuild } from '../types.js';
4
+ /** SequenceBuild cache key. Bump when compiled `code` shape changes. */
5
5
  export declare function runtimePackageVersion(): string;
6
6
  export declare function runtimePackageSource(repoRoot: string): RuntimePackageSource;
7
- /** Deep-clone company schema with derived computeFn normalized to string names. */
8
- export declare function snapshotCompanySchema(company: CompanySchema, functions?: FuncMap): CompanySchema;
9
7
  export declare function sequenceBuildPath(repoRoot: string, sequenceId: string): string;
10
8
  export type CompileSequenceOptions = {
11
9
  dryRun?: boolean;
12
10
  /** When false, skip esbuild and omit registry `code` (local serve overlay). Default true. */
13
11
  includeCode?: boolean;
14
- /** Persist on SequenceBuild.sha. Defaults to `local`. */
15
- sha?: string;
16
12
  /** Dependency source captured before deployment rewrites package.json. */
17
13
  runtimeSource?: RuntimePackageSource;
18
14
  };
@@ -20,10 +16,65 @@ export type CompileSequenceResult = {
20
16
  sequenceId: string;
21
17
  outPath: string;
22
18
  build: SequenceBuild;
19
+ /** The company schema the build runs against (28 §2): what the company part of the build carries. */
20
+ schema: CompiledSlotSchema;
21
+ companyMetadata: CompiledCompanyMetadata;
23
22
  wrote: boolean;
24
23
  };
24
+ export type CompileSequenceBuildResult = Omit<CompileSequenceResult, 'companyMetadata'>;
25
+ export declare function compileCompanyMetadataFromRepo(repoRoot: string): Promise<CompiledCompanyMetadata>;
25
26
  export declare function compileSequence(repoRoot: string, sequenceId: string, options?: CompileSequenceOptions): Promise<CompileSequenceResult>;
27
+ export declare function compileSequenceBuild(repoRoot: string, sequenceId: string, options?: CompileSequenceOptions): Promise<CompileSequenceBuildResult>;
26
28
  export declare function compileAll(repoRoot: string, options?: CompileSequenceOptions & {
27
29
  sequenceIds?: string[];
28
30
  }): Promise<CompileSequenceResult[]>;
31
+ /**
32
+ * The company part of the company build (22 §5): the root `resolve.ts` as `companyResolve`, the root
33
+ * `webhook.ts` as `webhook.received`, the root `schedules.ts` as `schedule.<name>` (25 §6.4), and the
34
+ * company schema with no subject. An error in it fails the
35
+ * whole compile.
36
+ */
37
+ export declare function compileCompanyPart(repoRoot: string, options?: {
38
+ includeCode?: boolean;
39
+ runtimeSource?: RuntimePackageSource;
40
+ }): Promise<CompanyPart>;
41
+ export declare const COMPILE_CONCURRENCY = 4;
42
+ export declare const COMPILE_SEQUENCE_TIMEOUT_MS: number;
43
+ export type CompileRepoEvent = {
44
+ type: 'log';
45
+ sequence?: string;
46
+ text: string;
47
+ } | {
48
+ type: 'sequence-started';
49
+ sequence: string;
50
+ } | {
51
+ type: 'sequence-finished';
52
+ sequence: string;
53
+ ok: boolean;
54
+ error?: string;
55
+ };
56
+ export type CompileRepoSequenceResult = {
57
+ ok: true;
58
+ build: SequenceBuild;
59
+ } | {
60
+ ok: false;
61
+ error: string;
62
+ };
63
+ export type CompileRepoOptions = {
64
+ sequences: string[];
65
+ runtimeSource?: RuntimePackageSource;
66
+ concurrency?: number;
67
+ sequenceTimeoutMs?: number;
68
+ onEvent?: (event: CompileRepoEvent) => void;
69
+ };
70
+ /**
71
+ * Compile company metadata once, then every named sequence in this process, then type-check the
72
+ * repository. A sequence error is collected; a company schema error or a type error rejects the whole
73
+ * call, a type error with the tsc output as its message.
74
+ */
75
+ export declare function compileRepo(repoRoot: string, options: CompileRepoOptions): Promise<{
76
+ companyMetadata: CompiledCompanyMetadata;
77
+ company: CompanyPart;
78
+ sequences: Record<string, CompileRepoSequenceResult>;
79
+ }>;
29
80
  //# sourceMappingURL=compile-sequence.d.ts.map