@superpanel-sdk/runtime 0.2.3 → 0.7.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 (319) hide show
  1. package/README.md +30 -10
  2. package/dist/builder/codegen/emit.d.ts +25 -12
  3. package/dist/builder/codegen/emit.js +339 -78
  4. package/dist/builder/codegen/generate.d.ts +21 -2
  5. package/dist/builder/codegen/generate.js +147 -34
  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 +29 -0
  9. package/dist/builder/company-imports.js +122 -0
  10. package/dist/builder/compile/compile-sequence.d.ts +61 -8
  11. package/dist/builder/compile/compile-sequence.js +334 -80
  12. package/dist/builder/compile/function-code.d.ts +19 -3
  13. package/dist/builder/compile/function-code.js +123 -45
  14. package/dist/builder/compile/registry.d.ts +7 -3
  15. package/dist/builder/compile/registry.js +30 -27
  16. package/dist/builder/errors.d.ts +9 -0
  17. package/dist/builder/errors.js +17 -0
  18. package/dist/builder/function-params.d.ts +10 -0
  19. package/dist/builder/function-params.js +203 -0
  20. package/dist/builder/load.d.ts +70 -10
  21. package/dist/builder/load.js +258 -67
  22. package/dist/builder/paths.d.ts +9 -1
  23. package/dist/builder/paths.js +32 -2
  24. package/dist/builder/schedules.d.ts +25 -0
  25. package/dist/builder/schedules.js +101 -0
  26. package/dist/builder/slot-schema-validation.d.ts +4 -0
  27. package/dist/builder/slot-schema-validation.js +10 -0
  28. package/dist/builder/typecheck.d.ts +8 -0
  29. package/dist/builder/typecheck.js +102 -0
  30. package/dist/builder/types.d.ts +127 -19
  31. package/dist/builder/types.js +21 -1
  32. package/dist/cli/auth/auth.d.ts +37 -0
  33. package/dist/cli/auth/auth.js +211 -0
  34. package/dist/cli/auth/backend-url.d.ts +5 -0
  35. package/dist/cli/auth/backend-url.js +25 -0
  36. package/dist/cli/auth/clipboard.d.ts +9 -0
  37. package/dist/cli/auth/clipboard.js +38 -0
  38. package/dist/cli/auth/http.d.ts +20 -0
  39. package/dist/cli/auth/http.js +27 -0
  40. package/dist/cli/auth/index.d.ts +10 -0
  41. package/dist/cli/auth/index.js +27 -0
  42. package/dist/cli/auth/progress.d.ts +12 -0
  43. package/dist/cli/auth/progress.js +15 -0
  44. package/dist/cli/auth/serve-login.d.ts +8 -0
  45. package/dist/cli/auth/serve-login.js +24 -0
  46. package/dist/cli/calls/index.d.ts +177 -0
  47. package/dist/cli/calls/index.js +96 -0
  48. package/dist/cli/compile/index.js +3 -0
  49. package/dist/cli/config.d.ts +10 -0
  50. package/dist/cli/config.js +52 -0
  51. package/dist/cli/debug/index.d.ts +31 -0
  52. package/dist/cli/debug/index.js +119 -0
  53. package/dist/cli/exec/index.d.ts +39 -0
  54. package/dist/cli/exec/index.js +138 -0
  55. package/dist/cli/exec/session.d.ts +48 -0
  56. package/dist/cli/exec/session.js +82 -0
  57. package/dist/cli/exec/trace.d.ts +18 -0
  58. package/dist/cli/exec/trace.js +52 -0
  59. package/dist/cli/index.js +112 -9
  60. package/dist/cli/logs/index.d.ts +47 -0
  61. package/dist/cli/logs/index.js +113 -0
  62. package/dist/cli/mobile/index.d.ts +12 -0
  63. package/dist/cli/mobile/index.js +405 -0
  64. package/dist/cli/serve/index.d.ts +109 -3
  65. package/dist/cli/serve/index.js +506 -118
  66. package/dist/cli/turns/index.d.ts +105 -0
  67. package/dist/cli/turns/index.js +128 -0
  68. package/dist/cli/turns/run.d.ts +13 -0
  69. package/dist/cli/turns/run.js +57 -0
  70. package/dist/cli/turns/shadow.d.ts +112 -0
  71. package/dist/cli/turns/shadow.js +54 -0
  72. package/dist/cli/type-gen/index.js +9 -9
  73. package/dist/compiler.d.ts +7 -0
  74. package/dist/compiler.js +7 -0
  75. package/dist/compute-host/compute-host.d.ts +14 -23
  76. package/dist/compute-host/compute-host.js +18 -30
  77. package/dist/compute-host/index.d.ts +2 -4
  78. package/dist/compute-host/index.js +1 -2
  79. package/dist/compute-host/source-compute-host.d.ts +10 -10
  80. package/dist/compute-host/source-compute-host.js +33 -40
  81. package/dist/core/case-orchestrator/contact-hours.d.ts +70 -0
  82. package/dist/core/case-orchestrator/contact-hours.js +127 -0
  83. package/dist/core/case-orchestrator/index.d.ts +3 -0
  84. package/dist/core/case-orchestrator/index.js +3 -0
  85. package/dist/core/case-orchestrator/render.d.ts +75 -0
  86. package/dist/core/case-orchestrator/render.js +244 -0
  87. package/dist/core/case-orchestrator/time.d.ts +11 -0
  88. package/dist/core/case-orchestrator/time.js +29 -0
  89. package/dist/core/case-orchestrator/types.d.ts +708 -0
  90. package/dist/core/case-orchestrator/types.js +42 -0
  91. package/dist/core/context/call.d.ts +291 -0
  92. package/dist/core/context/call.js +94 -0
  93. package/dist/core/context/channels.d.ts +60 -0
  94. package/dist/core/context/channels.js +35 -0
  95. package/dist/core/context/contact.d.ts +96 -6
  96. package/dist/core/context/contact.js +48 -2
  97. package/dist/core/context/email-message.d.ts +198 -0
  98. package/dist/core/context/email-message.js +86 -0
  99. package/dist/core/context/email.d.ts +109 -0
  100. package/dist/core/context/email.js +90 -0
  101. package/dist/core/context/exchanges.d.ts +167 -0
  102. package/dist/core/context/exchanges.js +81 -0
  103. package/dist/core/context/instances.d.ts +307 -0
  104. package/dist/core/context/instances.js +137 -0
  105. package/dist/core/context/kv.d.ts +113 -0
  106. package/dist/core/context/kv.js +60 -0
  107. package/dist/core/context/platform-registry.d.ts +544 -4
  108. package/dist/core/context/platform-registry.js +14 -2
  109. package/dist/core/context/platform.d.ts +2 -1
  110. package/dist/core/context/sms.d.ts +177 -0
  111. package/dist/core/context/sms.js +77 -0
  112. package/dist/core/context/types.d.ts +79 -48
  113. package/dist/core/context/types.js +1 -7
  114. package/dist/core/conversation/index.d.ts +85 -0
  115. package/dist/core/conversation/index.js +133 -0
  116. package/dist/core/functions/errors.d.ts +74 -0
  117. package/dist/core/functions/errors.js +26 -0
  118. package/dist/core/functions/events.d.ts +192 -0
  119. package/dist/core/functions/events.js +23 -0
  120. package/dist/core/functions/schedules.d.ts +50 -0
  121. package/dist/core/functions/schedules.js +20 -0
  122. package/dist/core/functions/types.d.ts +29 -73
  123. package/dist/core/functions/types.js +1 -4
  124. package/dist/core/office-hours/index.d.ts +39 -0
  125. package/dist/core/office-hours/index.js +187 -0
  126. package/dist/core/page/define.d.ts +904 -0
  127. package/dist/core/page/define.js +518 -0
  128. package/dist/core/page/envelope.d.ts +55 -0
  129. package/dist/core/page/envelope.js +4 -0
  130. package/dist/core/page/fns.d.ts +448 -0
  131. package/dist/core/page/fns.js +539 -0
  132. package/dist/core/page/memory-reader.d.ts +27 -0
  133. package/dist/core/page/memory-reader.js +299 -0
  134. package/dist/core/page/ops.d.ts +58 -0
  135. package/dist/core/page/ops.js +220 -0
  136. package/dist/core/page/page-host.d.ts +20 -0
  137. package/dist/core/page/page-host.js +57 -0
  138. package/dist/core/page/records-query.d.ts +234 -0
  139. package/dist/core/page/records-query.js +780 -0
  140. package/dist/core/page/render.d.ts +295 -0
  141. package/dist/core/page/render.js +1060 -0
  142. package/dist/core/page/sandbox.d.ts +85 -0
  143. package/dist/core/page/sandbox.js +357 -0
  144. package/dist/core/page/time-format.d.ts +46 -0
  145. package/dist/core/page/time-format.js +125 -0
  146. package/dist/core/page/timeline.d.ts +40 -0
  147. package/dist/core/page/timeline.js +2 -0
  148. package/dist/core/page/typed.d.ts +648 -0
  149. package/dist/core/page/typed.js +2 -0
  150. package/dist/core/page/workspace.d.ts +57 -0
  151. package/dist/core/page/workspace.js +266 -0
  152. package/dist/core/party/index.d.ts +3 -0
  153. package/dist/core/party/index.js +3 -0
  154. package/dist/core/party/schema.d.ts +208 -0
  155. package/dist/core/party/schema.js +113 -0
  156. package/dist/core/party/types.d.ts +35 -0
  157. package/dist/core/party/types.js +15 -0
  158. package/dist/core/sequence/define.d.ts +56 -0
  159. package/dist/core/sequence/define.js +10 -0
  160. package/dist/core/sequence/index.d.ts +63 -0
  161. package/dist/core/sequence/index.js +231 -0
  162. package/dist/core/slot/binding.d.ts +40 -0
  163. package/dist/core/slot/binding.js +2 -0
  164. package/dist/core/slot/company-metadata.d.ts +102 -0
  165. package/dist/core/slot/company-metadata.js +536 -0
  166. package/dist/core/slot/compile-schema.d.ts +19 -13
  167. package/dist/core/slot/compile-schema.js +51 -248
  168. package/dist/core/slot/contact-timezone.d.ts +110 -0
  169. package/dist/core/slot/contact-timezone.js +186 -0
  170. package/dist/core/slot/field.d.ts +2 -25
  171. package/dist/core/slot/field.js +0 -71
  172. package/dist/core/slot/id-ref.d.ts +17 -2
  173. package/dist/core/slot/id-ref.js +16 -8
  174. package/dist/core/slot/index.d.ts +12 -13
  175. package/dist/core/slot/index.js +11 -12
  176. package/dist/core/slot/naming.d.ts +15 -0
  177. package/dist/core/slot/naming.js +96 -0
  178. package/dist/core/slot/platform-fields.d.ts +119 -0
  179. package/dist/core/slot/platform-fields.js +121 -0
  180. package/dist/core/slot/ref.d.ts +16 -0
  181. package/dist/core/slot/ref.js +14 -0
  182. package/dist/core/slot/row.d.ts +2 -9
  183. package/dist/core/slot/row.js +13 -23
  184. package/dist/core/slot/schema-compat.d.ts +17 -0
  185. package/dist/core/slot/schema-compat.js +103 -0
  186. package/dist/core/slot/schema.d.ts +353 -76
  187. package/dist/core/slot/schema.js +163 -10
  188. package/dist/core/slot/types.d.ts +30 -103
  189. package/dist/core/slot/value.d.ts +28 -3
  190. package/dist/core/slot/value.js +93 -57
  191. package/dist/dev-overlay/protocol.d.ts +74 -8
  192. package/dist/fn-context/build-context.d.ts +3 -1
  193. package/dist/fn-context/build-context.js +26 -10
  194. package/dist/fn-context/fake/empty-api.js +9 -28
  195. package/dist/fn-context/fake/index.d.ts +13 -4
  196. package/dist/fn-context/fake/index.js +29 -2
  197. package/dist/fn-context/fn-params.d.ts +3 -0
  198. package/dist/fn-context/fn-params.js +10 -0
  199. package/dist/fn-context/index.d.ts +5 -5
  200. package/dist/fn-context/index.js +4 -4
  201. package/dist/fn-context/log.js +2 -2
  202. package/dist/fn-context/make-ctx.d.ts +11 -0
  203. package/dist/fn-context/make-ctx.js +20 -9
  204. package/dist/fn-context/rpc/case-orchestrator-tools.d.ts +32 -0
  205. package/dist/fn-context/rpc/case-orchestrator-tools.js +12 -0
  206. package/dist/fn-context/rpc/errors.d.ts +13 -0
  207. package/dist/fn-context/rpc/errors.js +22 -0
  208. package/dist/fn-context/rpc/index.d.ts +4 -2
  209. package/dist/fn-context/rpc/index.js +4 -2
  210. package/dist/fn-context/rpc/integration/index.d.ts +15 -5
  211. package/dist/fn-context/rpc/integration/index.js +1 -1
  212. package/dist/fn-context/rpc/integration/list-surfaces.d.ts +21 -0
  213. package/dist/fn-context/rpc/integration/{list-bindings.js → list-surfaces.js} +4 -4
  214. package/dist/fn-context/rpc/log.d.ts +11 -1
  215. package/dist/fn-context/rpc/platform.d.ts +13 -3
  216. package/dist/fn-context/rpc/platform.js +1 -1
  217. package/dist/fn-context/rpc/records.d.ts +85 -0
  218. package/dist/fn-context/rpc/records.js +24 -0
  219. package/dist/fn-context/rpc/trpc-client.d.ts +44 -2
  220. package/dist/fn-context/rpc/trpc-client.js +222 -12
  221. package/dist/fn-context/rpc/trpc-init.d.ts +21 -3
  222. package/dist/fn-context/rpc/trpc-init.js +10 -4
  223. package/dist/fn-context/rpc/trpc-router-factory.d.ts +111 -7
  224. package/dist/fn-context/rpc/trpc-router-factory.js +2 -0
  225. package/dist/fn-context/run-scope.d.ts +4 -0
  226. package/dist/fn-context/run-scope.js +9 -0
  227. package/dist/fn-context/types.d.ts +52 -5
  228. package/dist/index.d.ts +36 -46
  229. package/dist/index.js +30 -33
  230. package/dist/logger.d.ts +11 -0
  231. package/dist/logger.js +49 -0
  232. package/dist/platform.d.ts +75 -0
  233. package/dist/platform.js +57 -0
  234. package/dist/testing-compile-child.d.ts +2 -0
  235. package/dist/testing-compile-child.js +20 -0
  236. package/dist/testing.d.ts +368 -0
  237. package/dist/testing.js +439 -0
  238. package/dist/voice-service/actions.d.ts +50 -6
  239. package/dist/voice-service/index.d.ts +2 -0
  240. package/dist/voice-service/index.js +2 -0
  241. package/dist/voice-service/protocol.d.ts +604 -0
  242. package/dist/voice-service/protocol.js +67 -0
  243. package/dist/voice-service/types.d.ts +55 -8
  244. package/dist/worker.d.ts +11 -0
  245. package/dist/worker.js +11 -0
  246. package/package.json +38 -15
  247. package/dist/builder/compile/compile-agenda.d.ts +0 -15
  248. package/dist/builder/compile/compile-agenda.js +0 -64
  249. package/dist/builder/merge.d.ts +0 -4
  250. package/dist/builder/merge.js +0 -19
  251. package/dist/compute-host/read-only-cache.d.ts +0 -20
  252. package/dist/compute-host/read-only-cache.js +0 -61
  253. package/dist/core/context/db.d.ts +0 -69
  254. package/dist/core/context/db.js +0 -44
  255. package/dist/core/context/docusign.d.ts +0 -134
  256. package/dist/core/context/docusign.js +0 -108
  257. package/dist/core/context/filevine.d.ts +0 -323
  258. package/dist/core/context/filevine.js +0 -254
  259. package/dist/core/context/http.d.ts +0 -9
  260. package/dist/core/context/http.js +0 -4
  261. package/dist/core/context/hubspot.d.ts +0 -250
  262. package/dist/core/context/hubspot.js +0 -191
  263. package/dist/core/context/twilio.d.ts +0 -50
  264. package/dist/core/context/twilio.js +0 -42
  265. package/dist/core/functions/define/case-context.d.ts +0 -14
  266. package/dist/core/functions/define/case-context.js +0 -15
  267. package/dist/core/functions/define/compute.d.ts +0 -7
  268. package/dist/core/functions/define/compute.js +0 -17
  269. package/dist/core/functions/define/custom.d.ts +0 -4
  270. package/dist/core/functions/define/custom.js +0 -8
  271. package/dist/core/functions/define/system.d.ts +0 -7
  272. package/dist/core/functions/define/system.js +0 -12
  273. package/dist/core/functions/func-ref.d.ts +0 -16
  274. package/dist/core/functions/func-ref.js +0 -20
  275. package/dist/core/slot/deps.d.ts +0 -15
  276. package/dist/core/slot/deps.js +0 -88
  277. package/dist/core/slot/derived.d.ts +0 -32
  278. package/dist/core/slot/derived.js +0 -115
  279. package/dist/core/slot/platform-session-fields.d.ts +0 -38
  280. package/dist/core/slot/platform-session-fields.js +0 -48
  281. package/dist/core/slot/sf-schema.d.ts +0 -23
  282. package/dist/core/slot/sf-schema.js +0 -125
  283. package/dist/core/slot/sf-validate.d.ts +0 -14
  284. package/dist/core/slot/sf-validate.js +0 -132
  285. package/dist/core/slot/snapshot.d.ts +0 -18
  286. package/dist/core/slot/snapshot.js +0 -138
  287. package/dist/core/slot/write.d.ts +0 -48
  288. package/dist/core/slot/write.js +0 -426
  289. package/dist/core/stage/builders.d.ts +0 -54
  290. package/dist/core/stage/builders.js +0 -31
  291. package/dist/core/stage/condition.d.ts +0 -17
  292. package/dist/core/stage/condition.js +0 -198
  293. package/dist/core/stage/drive.d.ts +0 -43
  294. package/dist/core/stage/drive.js +0 -78
  295. package/dist/core/stage/finish-when.d.ts +0 -20
  296. package/dist/core/stage/finish-when.js +0 -82
  297. package/dist/core/stage/flatten.d.ts +0 -27
  298. package/dist/core/stage/flatten.js +0 -466
  299. package/dist/core/stage/index.d.ts +0 -15
  300. package/dist/core/stage/index.js +0 -13
  301. package/dist/core/stage/interrupts.d.ts +0 -28
  302. package/dist/core/stage/interrupts.js +0 -120
  303. package/dist/core/stage/ivr-fields.d.ts +0 -9
  304. package/dist/core/stage/ivr-fields.js +0 -75
  305. package/dist/core/stage/simulate.d.ts +0 -24
  306. package/dist/core/stage/simulate.js +0 -33
  307. package/dist/core/stage/transfer-fields.d.ts +0 -19
  308. package/dist/core/stage/transfer-fields.js +0 -129
  309. package/dist/core/stage/transfer-spec.d.ts +0 -48
  310. package/dist/core/stage/transfer-spec.js +0 -113
  311. package/dist/core/stage/types.d.ts +0 -208
  312. package/dist/core/stage/types.js +0 -2
  313. package/dist/core/stage/validate.d.ts +0 -11
  314. package/dist/core/stage/validate.js +0 -330
  315. package/dist/core/stage/walk.d.ts +0 -39
  316. package/dist/core/stage/walk.js +0 -119
  317. package/dist/fn-context/rpc/integration/list-bindings.d.ts +0 -21
  318. package/dist/fn-context/system-args.d.ts +0 -6
  319. package/dist/fn-context/system-args.js +0 -14
@@ -0,0 +1,295 @@
1
+ import type { CompiledSlotSchema, RuntimeFieldDef } from '../slot/types.js';
2
+ import { type ActionParameters, type PageToolName } from './define.js';
3
+ import type { ChannelAction, PageAction, PageChannel, SlotRef, SlotState } from './define.js';
4
+ import { type Spoken } from '../conversation/index.js';
5
+ /**
6
+ * `table:` and the last 12 hex digits of the row's uuid (33): what the row is called in logs, the
7
+ * timeline and the database too, so the same in every conversation and every process; nothing to keep.
8
+ * A name comes from the id alone, never from which row came first: two rows of a table alike in those
9
+ * digits (one page of n rows: about n² / 2⁴⁹) are both named by their whole id from then on, and the
10
+ * short name they share resolves to neither. So a name from an earlier conversation, or another
11
+ * process, means the row it meant or no row (the AI is told), never another row. A name resolves only
12
+ * to a row named here, and the AI's names are checked against the page's own (`one-of`, `enum`) first.
13
+ */
14
+ export declare class RowNames {
15
+ /** The rows named here: id → table. */
16
+ private readonly tables;
17
+ /** A short name → the ids of its table ending in its digits. */
18
+ private readonly byShort;
19
+ name(table: string, id: string): string;
20
+ resolve(name: string): {
21
+ table: string;
22
+ id: string;
23
+ } | undefined;
24
+ nameOf(id: string): string | undefined;
25
+ }
26
+ export type ReadSlot = {
27
+ value: unknown;
28
+ state: SlotState;
29
+ reason: string | null;
30
+ updatedAt: string | null;
31
+ };
32
+ export type PageReads = {
33
+ /** A row this run read, with its true slots; undefined when it was not read. */
34
+ row(id: string): {
35
+ table: string;
36
+ slots: Record<string, ReadSlot>;
37
+ } | undefined;
38
+ /** The ids new rows of `table` would hang under, from the parent conditions of this run's reads. */
39
+ parentsOf(table: string): readonly string[];
40
+ };
41
+ /** A block. Only the root has `guide` (24 §2.1): what to do now and how, the page's words. */
42
+ export type BlockNode = {
43
+ kind: 'block';
44
+ key: string;
45
+ path: string;
46
+ title?: string;
47
+ description?: string;
48
+ list: boolean;
49
+ children: PageNode[];
50
+ guide?: string;
51
+ };
52
+ export type PageNode = BlockNode
53
+ /** `expand`: shown with its definition (24 §2.2). */
54
+ | {
55
+ kind: 'cell';
56
+ key: string;
57
+ path: string;
58
+ slotId: string;
59
+ readOnly: boolean;
60
+ expand?: boolean;
61
+ } | {
62
+ kind: 'text';
63
+ key: string;
64
+ path: string;
65
+ value: string | number | boolean | null;
66
+ } | {
67
+ kind: 'action';
68
+ key: string;
69
+ path: string;
70
+ actionId: string;
71
+ };
72
+ export type RenderedCell = {
73
+ slotId: string;
74
+ ref: SlotRef;
75
+ /** The row's page name, `table:<uuid tail>`. */
76
+ row: string;
77
+ /** A ref's value, by its row's name (33). */
78
+ valueRow?: string;
79
+ label: string;
80
+ description?: string;
81
+ /** The schema's; the page's `$extraction` for its `table.field` replaces it (`RenderedPage.extractions`). */
82
+ extraction?: string;
83
+ /** The field's type; `ref` for a lookup (26 §16.2 #7), as a row argument's. */
84
+ type: RuntimeFieldDef['dataType'] | 'ref';
85
+ /** A `select` / `multi_select` field's options; null on every other type. */
86
+ choices: string[] | null;
87
+ /** For a lookup (`refField`): the rows the page offers, by page name, in its order. */
88
+ options?: string[];
89
+ /** For a lookup: what the AI sees of each row the page offered, by page name (26 §16.2 #7). */
90
+ optionLabels?: Record<string, string>;
91
+ value: unknown;
92
+ state: SlotState;
93
+ reason: string | null;
94
+ updatedAt: string | null;
95
+ /** Writable in at least one place on the page (schema allows, page did not tighten everywhere). */
96
+ writable: boolean;
97
+ paths: string[];
98
+ };
99
+ /**
100
+ * A field type a `schemaField` argument keeps, named as the field's definition names it and checked as a
101
+ * fill of the field is (`string`, `number` and `boolean` are the plain ones below).
102
+ */
103
+ export type FieldArgType = 'text' | 'phone' | 'email' | 'date' | 'datetime' | 'time' | 'select';
104
+ /**
105
+ * One argument as the AI fills it. Never sent to a model as a schema: the page shows it as `<arg>` and
106
+ * the platform checks what the AI passed against it. A `schemaField` argument has its field's type
107
+ * (26 §15.8: the same names as a field's definition); a row choice is `ref`, its `enum` the rows' page
108
+ * names, and the platform hands `run` the row's id. The rest is plain JSON Schema, as the action wrote it.
109
+ */
110
+ export type InputProperty = {
111
+ type: 'string';
112
+ description?: string;
113
+ enum?: Array<string | number>;
114
+ } | {
115
+ type: 'number' | 'integer' | 'boolean';
116
+ description?: string;
117
+ enum?: Array<string | number>;
118
+ } | {
119
+ type: FieldArgType;
120
+ description?: string;
121
+ enum?: string[];
122
+ } | {
123
+ type: 'multi_select';
124
+ enum: string[];
125
+ description?: string;
126
+ } | {
127
+ type: 'ref';
128
+ table: string;
129
+ enum: string[];
130
+ description?: string; /** What the AI sees of each row (`choose`), by page name. */
131
+ labels?: Record<string, string>;
132
+ } | {
133
+ type: 'array';
134
+ items: InputProperty;
135
+ description?: string;
136
+ } | {
137
+ type: 'object';
138
+ properties: Record<string, InputProperty>;
139
+ required?: string[];
140
+ description?: string;
141
+ /** May also be null. */
142
+ nullable?: true;
143
+ /** A field value with its own checks: the argument is validated as one (`contact_schedule`). */
144
+ 'x-type'?: 'contact_schedule';
145
+ };
146
+ export type InputSchema = {
147
+ type: 'object';
148
+ properties: Record<string, InputProperty>;
149
+ required: string[];
150
+ };
151
+ export type RenderedAction = {
152
+ id: string;
153
+ kind: PageAction['$action'];
154
+ name: string;
155
+ description: string;
156
+ /** JSON Schema of the arguments the AI fills (prefilled ones left out); null: nothing to fill. */
157
+ input: InputSchema | null;
158
+ /** Server-only: what running it needs. Never shown to the AI. */
159
+ server: {
160
+ kind: 'createRow';
161
+ table: string;
162
+ parentId: string | null;
163
+ set: Record<string, unknown>;
164
+ fields: string[];
165
+ required: string[]; /** The run key, when the page named one. */
166
+ key?: string;
167
+ } | {
168
+ kind: 'deleteRow';
169
+ table: string;
170
+ rowId: string;
171
+ reason?: string; /** The run key, when the page named one. */
172
+ key?: string;
173
+ } | {
174
+ kind: 'custom';
175
+ name: string;
176
+ prefill: Record<string, unknown>; /** The run key, when the page named one. */
177
+ key?: string;
178
+ } | {
179
+ kind: 'channel';
180
+ spec: ChannelAction;
181
+ }
182
+ /**
183
+ * Book the case's next step (40 §2.2) on one of `channels`; `prefill`: what the page fixed (the
184
+ * channel, the contact's id), not asked of the AI.
185
+ */
186
+ | {
187
+ kind: 'followUp';
188
+ key: string;
189
+ channels: Array<'call' | 'sms' | 'email'>;
190
+ prefill: {
191
+ channel?: 'call' | 'sms' | 'email';
192
+ contactId?: string;
193
+ };
194
+ }
195
+ /** Cancel the case's next step (40 §2.2), with why. */
196
+ | {
197
+ kind: 'cancelFollowUp';
198
+ key: string;
199
+ }
200
+ /** A platform tool (76 §2.18): the platform runs it, the AI reads the result next turn. */
201
+ | {
202
+ kind: 'tool';
203
+ tool: PageToolName;
204
+ }
205
+ /** A company function (20 §6.2): run on the Worker by the platform, waited for, with the page's prefilled arguments. */
206
+ | {
207
+ kind: 'function';
208
+ name: string; /** Per language (66): the engine says the call's. */
209
+ say?: Spoken;
210
+ prefill?: Record<string, unknown>; /** The run key, when the page named one. */
211
+ key?: string;
212
+ };
213
+ };
214
+ /**
215
+ * The page function returned an action to run now instead of a page (17b §9.8): `action` is rendered
216
+ * as a button would be (its rows checked), `key` names its runs.
217
+ */
218
+ export type AutoAction = {
219
+ action: RenderedAction;
220
+ key: string;
221
+ wait: boolean;
222
+ };
223
+ export type RenderedPage = {
224
+ root: BlockNode;
225
+ /** Set when the page function returned an action to run now: the page then has nothing else. */
226
+ auto?: AutoAction;
227
+ cells: Record<string, RenderedCell>;
228
+ actions: Record<string, RenderedAction>;
229
+ /**
230
+ * Set on a stand-in page when the page script failed (15 §10.9): the last good page marked stale and
231
+ * read-only, or an empty page. Nothing on it can be written, and it has no actions.
232
+ */
233
+ fallback?: {
234
+ reason: string;
235
+ stale: boolean;
236
+ };
237
+ /** Every row on the page, by page name; `parentId` is its parent. */
238
+ rows: Record<string, {
239
+ table: string;
240
+ id: string;
241
+ parentId: string | null;
242
+ }>;
243
+ /** The page's `$extraction` (26 §15.3): how to fill a field on this page, by `table.field`; replaces the schema's. */
244
+ extractions?: Record<string, string>;
245
+ /** The voice the page asks for (`page({ voice })`, 76). */
246
+ voice?: unknown;
247
+ warnings: string[];
248
+ };
249
+ export declare class PageDocumentError extends Error {
250
+ constructor(message: string);
251
+ }
252
+ export type RenderDocumentInput = {
253
+ document: unknown;
254
+ schema: CompiledSlotSchema;
255
+ reads: PageReads;
256
+ names: RowNames;
257
+ /** The conversation's channel: a button the channel cannot do (a transfer by text) is an error (20 §5.2). */
258
+ channel?: PageChannel;
259
+ /** The sequence's functions' parameters, from their `args` types (38 §2.4): a function button's. */
260
+ functions?: Readonly<Record<string, {
261
+ parameters?: ActionParameters;
262
+ }>>;
263
+ /** The page's actions' parameters, from their `args` types (38 §2.9): a page action button's. */
264
+ actions?: Readonly<Record<string, {
265
+ parameters?: ActionParameters;
266
+ }>>;
267
+ };
268
+ export declare function renderDocument(input: RenderDocumentInput): RenderedPage;
269
+ /**
270
+ * The buttons' ids (46 §2.1), in page order: what each does (its run key's words: a function's name,
271
+ * `add:injury`, `remove`, `transfer`, …); where several on the page do the same, the rows that tell them
272
+ * apart, by page name (`voidInjury@injury:3f9a2c1d7e04`); where that still leaves two alike, `#2`, `#3`
273
+ * after the first. Unique on the page, and the same from one render to the next while the button does
274
+ * the same thing to the same rows.
275
+ */
276
+ export declare function buttonIds(buttons: readonly RenderedAction[], rows: RenderedPage['rows']): string[];
277
+ /**
278
+ * The button the AI means by `id` on this page (46 §2.1), or null. Its own id first; else an id it read
279
+ * on an earlier page, where alike buttons needed their rows (`bookSlot@slot_option:d12f648904ec`) and now
280
+ * one is left (`bookSlot`): the one button doing that to those rows. Never a guess among several.
281
+ */
282
+ export declare function pressedButton(page: RenderedPage, id: string): string | null;
283
+ /**
284
+ * The run key of a button on the page (17b §7): the action's own key, whoever runs it — the model
285
+ * pressing it, or the page function returning it — not its place on the page, which moves with rows.
286
+ */
287
+ export declare function runKeyOf(action: RenderedAction): string;
288
+ /** The run key of an action the page function returned, when it names none. */
289
+ export declare function actionKey(action: PageAction): string;
290
+ /**
291
+ * The page to show when the page script failed (15 §10.9): the last good page, every cell read-only
292
+ * and no actions, marked stale; without one, an empty page.
293
+ */
294
+ export declare function fallbackPage(last: RenderedPage | null, reason: string): RenderedPage;
295
+ //# sourceMappingURL=render.d.ts.map