@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
@@ -0,0 +1,76 @@
1
+ /**
2
+ * The whole runtime, for the platform: every other entry (the company API `index.ts`, the Worker shell
3
+ * `worker.ts`, the compiler `compiler.ts`) and the slot and page engines and RPC routers behind them.
4
+ * Platform services, tests and scripts import from here; only the Worker shell takes `./worker` and the
5
+ * compile child `./compiler`, which stay small. Platform-only: the package resolves `./platform` under the
6
+ * `superpanel-platform` condition, so company code cannot import it.
7
+ */
8
+ export type { CompanyFieldDef, CompanyNormalFieldDef, CompiledCompanyMetadata, CompanySchema, CompanyTableDef, DataType, ContactSchedule, LocalTimeRange, ContactWeekday, ScalarDataType, NormalFieldCore, SessionDataType, SessionFieldDef, SessionSchema, TableRef, } from './core/slot/schema.js';
9
+ export { ROW_ID_FIELD, ROW_SYSTEM_KEYS, ROW_TIME_KEYS, isRowTimeKey, type RowSystemKey, type RowTimeKey, idFieldCore, normalFieldCoreSchema, companyNormalFieldDefSchema, tableRefSchema, compiledCompanyMetadataSchema, companyFieldDefSchema, companyTableDefSchema, companySchemaSchema, contactScheduleValueSchema, localTimeRangeSchema, isCompanySchema, EMPTY_SESSION_SCHEMA, sessionFieldDefSchema, sessionSchemaSchema, } from './core/slot/schema.js';
10
+ export { CONTACT_OPT_OUT_FIELDS, CONTACT_TABLE, LIMITS, POLICY_IDS, PLATFORM_CONTACT_FIELDS, PLATFORM_SESSION_FIELDS, PLATFORM_SESSION_SCHEMA, SESSION_TABLE, compileCompanyMetadata, sessionSchemaIssues, isCustomTable, isParentField, isRecordTable, parentOf, subjectTableIssues, compileCompanySchema, type CompileCompanyMetadataResult, type ResponsePolicyId, type SlotFillingPolicyId, type VoiceProfileId, } from './core/slot/company-metadata.js';
11
+ export { STATE_CODES, STATE_TIMEZONES, areaCodeTimezone, contactTimezone, knownTimezone, postalTimezone, stateCode, type StateCode, type TimezoneSource, } from './core/slot/contact-timezone.js';
12
+ export { randomTimeBetween } from './core/case-orchestrator/time.js';
13
+ export { contactHoursOn, contactScheduleHours, everyDay, nextContactTime, withinContactHours, type ContactHours, type ContactHoursRange, type ContactHoursWeekday, type ContactScheduleValue, } from './core/case-orchestrator/contact-hours.js';
14
+ export { integrationSurfaceKeys } from './core/context/types.js';
15
+ export { lookupRef, parentRef } from './core/slot/id-ref.js';
16
+ export type { EmailApi, EmailAttachment, EmailGetAttachmentInput, EmailGetAttachmentOutput, EmailGetMessageInput, EmailGetMessageOutput, EmailListMessagesInput, EmailListMessagesOutput, EmailProvider, EmailSendEmailInput, EmailSendEmailOutput, EmailService, } from './core/context/email.js';
17
+ export { emailGetAttachmentInput, emailGetAttachmentOutput, emailGetMessageInput, emailGetMessageOutput, emailListMessagesInput, emailListMessagesOutput, emailMockService, emailProvider, emailSendEmailInput, emailSendEmailOutput, } from './core/context/email.js';
18
+ export type { ContactApi, IntegrationSurfaceMeta, EnvApi, EnvService, FieldState, IntegrationAccountFields, IntegrationApi, IntegrationStub, IntegrationSurfaceKey, IntegrationTarget, Logger, MakeCtxOverrides, SystemContext, } from './core/context/types.js';
19
+ export { CALL_PAGE_LIMIT_MAX, callDirection, callGetInput, callGetOutput, callListInput, callListOutput, callMockService, callParticipant, callRecord, callSurface, callTranscriptInput, callTranscriptLine, callTranscriptOutput, type CallApi, type CallDirection, type CallListParams, type CallListResult, type CallParticipant, type CallRecord, type CallTranscript, type CallTranscriptLine, } from './core/context/call.js';
20
+ export { CONTACT_PAGE_LIMIT_MAX, contactCreateInput, contactFindInput, contactFindOutput, contactListInput, contactListOutput, contactMockService, contactSummary, contactSurface, slotFieldValue, type ContactCreateParams, type ContactFindParams, type ContactFindResult, type ContactListParams, type ContactListResult, type ContactSummary, type SlotFieldValue, } from './core/context/contact.js';
21
+ export { instanceCloseInput, instanceFindForContactInput, instanceIdInput, instanceListOutput, instanceNotifyInput, instanceNotifyOutput, instanceSetVariablesInput, instanceStartInput, instanceStartOutput, instanceSummary, instancesMockService, instancesSurface, type InstanceCloseParams, type InstanceFindForContactParams, type InstanceIdParams, type InstanceListResult, type InstanceNotifyParams, type InstanceNotifyResult, type InstanceSetVariablesParams, type InstanceStartParams, type InstanceStartResult, type InstanceSummary, type InstancesApi, } from './core/context/instances.js';
22
+ export { channelMailbox, channelPhoneNumber, channelsListInput, channelsListOutput, channelsMockService, channelsSurface, type ChannelMailbox, type ChannelPhoneNumber, type ChannelsApi, type ChannelsListParams, type ChannelsListResult, } from './core/context/channels.js';
23
+ export { exchangeEmailThreadInput, exchangeEmailThreadOutput, exchangeLastInput, exchangeLastOutput, exchangeRef, exchangeSummary, exchangesMockService, exchangesSurface, type ExchangeRef, type ExchangeEmailThreadParams, type ExchangeEmailThreadResult, type ExchangeLastParams, type ExchangeLastResult, type ExchangeSummary, type ExchangesApi, } from './core/context/exchanges.js';
24
+ export { SYSTEM_VARIABLES, compileVariables, defineSequence, defineVariables, isSystemVariable, json, readVariables, startVariables, variableValueIssue, variablesSize, variablesWriteIssues, type CompiledExperiments, type CompiledVariable, type CompiledVariables, type ExperimentDecl, type JsonVariableType, type SequenceDefinition, type SystemVariableName, type VariableDecl, type VariableDecls, type VariablesOf, } from './core/sequence/index.js';
25
+ export { EMAIL_PAGE_LIMIT_MAX, emailDirection, emailGetInput, emailGetOutput, emailHistoryMockService, emailHistorySurface, emailListInput, emailListOutput, emailRecord, type EmailDirection, type EmailHistoryApi, type EmailListParams, type EmailListResult, type EmailRecord, } from './core/context/email-message.js';
26
+ export { KV_KEY_MAX, KV_SCOPES, KV_TTL_SECONDS_MAX, KV_VALUE_MAX, kvDelInput, kvDelOutput, kvGetInput, kvGetOutput, kvMockService, kvScope, kvSetInput, kvSetOutput, kvSurface, type KvApi, type KvDelInput, type KvDelOutput, type KvGetInput, type KvGetOutput, type KvScope, type KvSetInput, type KvSetOutput, } from './core/context/kv.js';
27
+ export { SMS_PAGE_LIMIT_MAX, smsDirection, smsGetInput, smsGetOutput, smsListInput, smsListOutput, smsMockService, smsRecord, smsSurface, type SmsApi, type SmsDirection, type SmsListParams, type SmsListResult, type SmsRecord, } from './core/context/sms.js';
28
+ export { bindEnvService, envMockService, readEnvGet } from './core/context/env.js';
29
+ export type { AnyPlatformSurface, PlatformApiShape, PlatformImpl, PlatformSurface } from './core/context/platform.js';
30
+ export { platformSurfaces, type PlatformApis, type PlatformSurfaceKey } from './core/context/platform-registry.js';
31
+ export type { CompiledSlotSchema, FieldHistoryEntry, FieldValue, MultiRowRecord, MultiRowTableData, RuntimeFieldDef, RuntimeTableDef, SingleRowTableData, SlotValue, UpdatedBy, ValidationIssue, ValidationResult, WriteSource, } from './core/slot/types.js';
32
+ export type { FuncRef } from './core/functions/func-ref.js';
33
+ export { resolveFuncName } from './core/functions/func-ref.js';
34
+ export type { CompanyBuild, CompanyPart, RuntimePackageSource, SequenceBuild } from './builder/types.js';
35
+ export { COMPANY_SCOPE } from './builder/types.js';
36
+ export { parseOfficeHours, resolveOfficeHours, type OfficeHours, type OfficeHoursSnapshot, type ParseOfficeHoursResult, type Weekday, type Window, } from './core/office-hours/index.js';
37
+ export type { CaseFn, DefinedCaseFunc, DefinedCaseOrchestratorFunc, DefinedFunc, DefinedNoCaseFunc, FuncMap, FuncOptions, FuncRegistration, FunctionCtx, FunctionKind, FunctionRegistry, FunctionRegistryEntry, NoCaseFn, WorkerFunctionKind, } from './core/functions/types.js';
38
+ export type { AnyEventHandlers, CallEndedEvent, CallEventBase, CallInboundEvent, CallOutboundEvent, EmailReceivedEvent, EmailEventBase, EmptyEvent, EmailSendRequestedEvent, ConversationHandoffEvent, EventHandler, EventHandlerParams, EventHandlers, SmsReceivedEvent, SmsEventBase, SmsSendRequestedEvent, SystemEventMap, SystemEventName, SystemEventPayload, WebhookEvent, WebhookHandler, WebhookOutcome, WebhookRequest, } from './core/functions/events.js';
39
+ export { defineEvents, defineWebhook } from './core/functions/define/events.js';
40
+ export { isSystemEventName, SYSTEM_EVENT_NAMES, SYSTEM_EVENTS, systemEventKind, WEBHOOK_RECEIVED_FUNCTION, webhookOutcome, } from './core/functions/events.js';
41
+ export { defineSchedules, SCHEDULE_FUNCTION_PREFIX, SCHEDULES_MODULE, scheduleFunctionName, type ScheduleCtx, type ScheduleDefinition, type ScheduleManifest, type Schedules, type ScheduleTick, } from './core/functions/schedules.js';
42
+ export { parseSchedules, scheduleTimingIssue } from './builder/schedules.js';
43
+ export { isWorkerFunctionKind, toFuncRegistrations, WORKER_FUNCTION_KINDS } from './core/functions/types.js';
44
+ export { toEventRegistry, toFunctionRegistry } from './builder/compile/registry.js';
45
+ export { compileFunctionCode } from './builder/compile/function-code.js';
46
+ export { COMPILE_CONCURRENCY, COMPILE_SEQUENCE_TIMEOUT_MS, compileAll, compileCompanyMetadataFromRepo, compileCompanyPart, compileRepo, compileSequence, compileSequenceBuild, runtimePackageSource, runtimePackageVersion, type CompileRepoEvent, type CompileRepoOptions, type CompileRepoSequenceResult, type CompileSequenceBuildResult, type CompileSequenceOptions, type CompileSequenceResult, } from './builder/compile/compile-sequence.js';
47
+ export { loadSequenceEvents, loadSequenceFunctions } from './builder/load.js';
48
+ export { findTsModule } from './builder/paths.js';
49
+ export type { OverlayClientMessage, OverlayExecuteMessage, OverlayExecuteResultMessage, OverlayAuthErrorMessage, OverlayAuthMessage, OverlayAuthOkMessage, OverlayMessage, OverlayNoticeMessage, OverlayPushMessage, OverlayReplacedMessage, OverlayServerMessage, } from './dev-overlay/protocol.js';
50
+ export { encodeOverlayMessage, OVERLAY_REPLACED_CLOSE_CODE, parseOverlayMessage } from './dev-overlay/protocol.js';
51
+ export { asCaseOrchestratorRun, buildActionContext, buildCaseOrchestratorContext, bindLogMeta, createFakeApiHost, defaultPlatformApis, emptyIntegration, createRpcApiHost, LOG_TAGS_HEADER, REQUEST_ID_HEADER, RUNTIME_VERSION_HEADER, encodeLogTagsHeader, formatRuntimeVersion, readLogTagsHeader, readRequestIdHeader, readRuntimeVersionHeader, makeCaseOrchestratorCtx, makeCtx, makeCtxAsync, noopLog, type ActionContext, type ActionDataSlice, type ApiHost, type CaseOrchestratorActionContext, type CaseOrchestratorApiHost, type CaseOrchestratorRunScope, type FakeApiHostOptions, type RunClaims, type RunScope, } from './fn-context/index.js';
52
+ export { createAppRouter, createIntegrationRouter, createListSurfacesProcedure, createLogRouter, createPlatformRouter, createCaseOrchestratorToolsRouter, createRecordsRouter, isRpcCodedError, parseScriptInput, ScriptInputError, type AppRouter, type RpcCodedError, type RpcErrorCode, type IntegrationInvokeHandler, type LogEmitHandler, type PlatformInvokeHandler, type CaseOrchestratorToolInvokeHandler, type RecordsReadInput, type RecordsHandlers, type RecordsResult, type RecordsWriteInput, type RpcContext, } from './fn-context/rpc/index.js';
53
+ export * from './compute-host/index.js';
54
+ export type { BoundRow, Cell, CellBinding, CellRef, RowRef } from './core/slot/binding.js';
55
+ export { announce, createRow, defineAction, definePage, deleteRow, emptyRuns, end, field, keypad, lastActionRun, pageEntry, perform, schemaField, transferTo, isSipUri, runFunction, messages, voicemail, type PageFarEnd, type VoicemailAction, pageFollowUps, choose, isChoose, refField, type RefFieldCell, type RefOption, type ChooseParam, type FunctionAction, type MessageAction, type FollowUpAction, type PageFollowUps, type PageTime, type MessageOptions, type PageMessages, tried, type PageActionRun, type ActionRunScope, type AnnounceAction, type ChannelAction, type DefinedPage, type EndAction, type KeypadAction, type PageChannel, type PageDefinition, type PageFunction, type PagePersona, type PageFollowUp, type PageFaq, type PageFaqEntry, type PageStart, checkPageStart, MAX_FAQ_ENTRIES, type PageRuns, type PageScheduledAction, type PerformAction, type TransferAction, type ActionContext as PageActionContext, type ActionParam, type ActionParameters, type CreateRowAction, type CustomAction, type DefinedAction, type DeleteRowAction, type FieldCell, type FieldOptions, type FindArgs, type Placeable, type SchemaFieldParam, type SchemaFieldOptions, type PageAction as PageScriptAction, type PageContext, type PageContextOf, type PageBaseContext, type PageCallCaps, type PagePreviousCall, type PageChannelCaps, type PageSmsMessage, type PageEmailMessage, PAGE_CHANNELS, type PageConversation, type PageHistory, type PageEntryArg, type PageRow as PageScriptRow, type Db, type ReadDb, type Slot, type SlotRef, type SlotState, type TableReader, type TableWriter, } from './core/page/define.js';
56
+ export { actionKey, runKeyOf, fallbackPage, PageDocumentError, renderDocument, RowNames, type AutoAction, type BlockNode, type PageNode, type PageReads, type InputProperty, type InputSchema, type ReadSlot, type RenderDocumentInput, type RenderedAction, type RenderedCell, type RenderedPage as RenderedPageDocument, } from './core/page/render.js';
57
+ export { TIMELINE_KINDS, type TimelineEntry, type TimelineKind, type TimelineWhere } from './core/page/timeline.js';
58
+ export { blockAt, viewText, workspaceText, type WorkspaceNote, type WorkspaceTextOptions } from './core/page/workspace.js';
59
+ export type { ArgsOf, CreateData, FindManyArgs, FindUniqueArgs, Id, IncludeArg, PageDocumentOf, PageFieldDesc, PageTablesDesc, RowOf, SchemaFieldPath, SelectArg, TypedActionContext, TypedActionParameters, TypedDefinedAction, TypedPageContext, TypedPageModule, TypedDb, TypedReadDb, TypedSchemaFieldParam, TypedSlot, UpdateData, Where, } from './core/page/typed.js';
60
+ export { resolvePageOps, type ActionOp, type DroppedOp, type OpenOp, type PageOp, type PageOpsAllowed, type ResolvedActionOp, type ResolvedOp, type ResolvedOpenOp, type ResolvedSlotOp, type SlotOp, } from './core/page/ops.js';
61
+ export { defineCaseFunc } from './core/functions/define/case.js';
62
+ export { defineNoCaseFunc } from './core/functions/define/no-case.js';
63
+ export { bindDefines, type BoundDefines } from './core/functions/define/bind.js';
64
+ export { emitCaseContextSource, emitSlotsSource } from './builder/codegen/emit.js';
65
+ export { companyMetadataCompatibilityIssues, compiledTableEntries, compileSlotSchema, emptyFieldValue, formatFieldPath, getCompiledTable, getTableField, relationsOf, type TableRelation, isFieldValue, isReservedTableName, isResolved, isRowIdField, mintRowId, SNAPSHOT_CURRENT_KEY, DATE_VALUE_FORMAT, DATE_VALUE_PATTERN, DATETIME_VALUE_FORMAT, DATETIME_VALUE_PATTERN, isValidDataTypeValue, companyFieldToRuntime, makeFieldValue, parseFieldPath, refKind, refValueIssues, requireFieldPath, slotFieldEntries, slotFieldNames, validateBareValue, validateFieldRefs, } from './core/slot/index.js';
66
+ export type { RefKind } from './core/slot/index.js';
67
+ export type { FieldPath, ParsedFieldPath, SlotRow, } from './core/slot/index.js';
68
+ export { CHANNELS, isSpokenLanguage, SPOKEN_LANGUAGES, type Channel, type Direction, type ScheduledContactContext, type SpokenLanguage } from './core/conversation/index.js';
69
+ export * from './core/case-orchestrator/index.js';
70
+ export * from './core/party/index.js';
71
+ export * from './voice-service/index.js';
72
+ export { dayIn, formatTime, type FormatTimeOptions, type TimeStyle } from './core/page/time-format.js';
73
+ export * from './index.js';
74
+ export * from './worker.js';
75
+ export * from './compiler.js';
76
+ //# sourceMappingURL=platform.d.ts.map
@@ -0,0 +1,56 @@
1
+ export { ROW_ID_FIELD, ROW_SYSTEM_KEYS, ROW_TIME_KEYS, isRowTimeKey, idFieldCore, normalFieldCoreSchema, companyNormalFieldDefSchema, tableRefSchema, compiledCompanyMetadataSchema, companyFieldDefSchema, companyTableDefSchema, companySchemaSchema, contactScheduleValueSchema, localTimeRangeSchema, isCompanySchema, EMPTY_SESSION_SCHEMA, sessionFieldDefSchema, sessionSchemaSchema, } from './core/slot/schema.js';
2
+ export { CONTACT_OPT_OUT_FIELDS, CONTACT_TABLE, LIMITS, POLICY_IDS, PLATFORM_CONTACT_FIELDS, PLATFORM_SESSION_FIELDS, PLATFORM_SESSION_SCHEMA, SESSION_TABLE, compileCompanyMetadata, sessionSchemaIssues, isCustomTable, isParentField, isRecordTable, parentOf, subjectTableIssues, compileCompanySchema, } from './core/slot/company-metadata.js';
3
+ export { STATE_CODES, STATE_TIMEZONES, areaCodeTimezone, contactTimezone, knownTimezone, postalTimezone, stateCode, } from './core/slot/contact-timezone.js';
4
+ export { randomTimeBetween } from './core/case-orchestrator/time.js';
5
+ export { contactHoursOn, contactScheduleHours, everyDay, nextContactTime, withinContactHours, } from './core/case-orchestrator/contact-hours.js';
6
+ export { integrationSurfaceKeys } from './core/context/types.js';
7
+ export { lookupRef, parentRef } from './core/slot/id-ref.js';
8
+ export { emailGetAttachmentInput, emailGetAttachmentOutput, emailGetMessageInput, emailGetMessageOutput, emailListMessagesInput, emailListMessagesOutput, emailMockService, emailProvider, emailSendEmailInput, emailSendEmailOutput, } from './core/context/email.js';
9
+ export { CALL_PAGE_LIMIT_MAX, callDirection, callGetInput, callGetOutput, callListInput, callListOutput, callMockService, callParticipant, callRecord, callSurface, callTranscriptInput, callTranscriptLine, callTranscriptOutput, } from './core/context/call.js';
10
+ export { CONTACT_PAGE_LIMIT_MAX, contactCreateInput, contactFindInput, contactFindOutput, contactListInput, contactListOutput, contactMockService, contactSummary, contactSurface, slotFieldValue, } from './core/context/contact.js';
11
+ export { instanceCloseInput, instanceFindForContactInput, instanceIdInput, instanceListOutput, instanceNotifyInput, instanceNotifyOutput, instanceSetVariablesInput, instanceStartInput, instanceStartOutput, instanceSummary, instancesMockService, instancesSurface, } from './core/context/instances.js';
12
+ export { channelMailbox, channelPhoneNumber, channelsListInput, channelsListOutput, channelsMockService, channelsSurface, } from './core/context/channels.js';
13
+ export { exchangeEmailThreadInput, exchangeEmailThreadOutput, exchangeLastInput, exchangeLastOutput, exchangeRef, exchangeSummary, exchangesMockService, exchangesSurface, } from './core/context/exchanges.js';
14
+ export { SYSTEM_VARIABLES, compileVariables, defineSequence, defineVariables, isSystemVariable, json, readVariables, startVariables, variableValueIssue, variablesSize, variablesWriteIssues, } from './core/sequence/index.js';
15
+ export { EMAIL_PAGE_LIMIT_MAX, emailDirection, emailGetInput, emailGetOutput, emailHistoryMockService, emailHistorySurface, emailListInput, emailListOutput, emailRecord, } from './core/context/email-message.js';
16
+ export { KV_KEY_MAX, KV_SCOPES, KV_TTL_SECONDS_MAX, KV_VALUE_MAX, kvDelInput, kvDelOutput, kvGetInput, kvGetOutput, kvMockService, kvScope, kvSetInput, kvSetOutput, kvSurface, } from './core/context/kv.js';
17
+ export { SMS_PAGE_LIMIT_MAX, smsDirection, smsGetInput, smsGetOutput, smsListInput, smsListOutput, smsMockService, smsRecord, smsSurface, } from './core/context/sms.js';
18
+ export { bindEnvService, envMockService, readEnvGet } from './core/context/env.js';
19
+ export { platformSurfaces } from './core/context/platform-registry.js';
20
+ export { resolveFuncName } from './core/functions/func-ref.js';
21
+ export { COMPANY_SCOPE } from './builder/types.js';
22
+ export { parseOfficeHours, resolveOfficeHours, } from './core/office-hours/index.js';
23
+ export { defineEvents, defineWebhook } from './core/functions/define/events.js';
24
+ export { isSystemEventName, SYSTEM_EVENT_NAMES, SYSTEM_EVENTS, systemEventKind, WEBHOOK_RECEIVED_FUNCTION, webhookOutcome, } from './core/functions/events.js';
25
+ export { defineSchedules, SCHEDULE_FUNCTION_PREFIX, SCHEDULES_MODULE, scheduleFunctionName, } from './core/functions/schedules.js';
26
+ export { parseSchedules, scheduleTimingIssue } from './builder/schedules.js';
27
+ export { isWorkerFunctionKind, toFuncRegistrations, WORKER_FUNCTION_KINDS } from './core/functions/types.js';
28
+ export { toEventRegistry, toFunctionRegistry } from './builder/compile/registry.js';
29
+ export { compileFunctionCode } from './builder/compile/function-code.js';
30
+ export { COMPILE_CONCURRENCY, COMPILE_SEQUENCE_TIMEOUT_MS, compileAll, compileCompanyMetadataFromRepo, compileCompanyPart, compileRepo, compileSequence, compileSequenceBuild, runtimePackageSource, runtimePackageVersion, } from './builder/compile/compile-sequence.js';
31
+ export { loadSequenceEvents, loadSequenceFunctions } from './builder/load.js';
32
+ export { findTsModule } from './builder/paths.js';
33
+ export { encodeOverlayMessage, OVERLAY_REPLACED_CLOSE_CODE, parseOverlayMessage } from './dev-overlay/protocol.js';
34
+ export { asCaseOrchestratorRun, buildActionContext, buildCaseOrchestratorContext, bindLogMeta, createFakeApiHost, defaultPlatformApis, emptyIntegration, createRpcApiHost, LOG_TAGS_HEADER, REQUEST_ID_HEADER, RUNTIME_VERSION_HEADER, encodeLogTagsHeader, formatRuntimeVersion, readLogTagsHeader, readRequestIdHeader, readRuntimeVersionHeader, makeCaseOrchestratorCtx, makeCtx, makeCtxAsync, noopLog, } from './fn-context/index.js';
35
+ export { createAppRouter, createIntegrationRouter, createListSurfacesProcedure, createLogRouter, createPlatformRouter, createCaseOrchestratorToolsRouter, createRecordsRouter, isRpcCodedError, parseScriptInput, ScriptInputError, } from './fn-context/rpc/index.js';
36
+ export * from './compute-host/index.js';
37
+ export { announce, createRow, defineAction, definePage, deleteRow, emptyRuns, end, field, keypad, lastActionRun, pageEntry, perform, schemaField, transferTo, isSipUri, runFunction, messages, voicemail, pageFollowUps, choose, isChoose, refField, tried, checkPageStart, MAX_FAQ_ENTRIES, PAGE_CHANNELS, } from './core/page/define.js';
38
+ export { actionKey, runKeyOf, fallbackPage, PageDocumentError, renderDocument, RowNames, } from './core/page/render.js';
39
+ export { TIMELINE_KINDS } from './core/page/timeline.js';
40
+ export { blockAt, viewText, workspaceText } from './core/page/workspace.js';
41
+ export { resolvePageOps, } from './core/page/ops.js';
42
+ export { defineCaseFunc } from './core/functions/define/case.js';
43
+ export { defineNoCaseFunc } from './core/functions/define/no-case.js';
44
+ export { bindDefines } from './core/functions/define/bind.js';
45
+ export { emitCaseContextSource, emitSlotsSource } from './builder/codegen/emit.js';
46
+ export { companyMetadataCompatibilityIssues, compiledTableEntries, compileSlotSchema, emptyFieldValue, formatFieldPath, getCompiledTable, getTableField, relationsOf, isFieldValue, isReservedTableName, isResolved, isRowIdField, mintRowId, SNAPSHOT_CURRENT_KEY, DATE_VALUE_FORMAT, DATE_VALUE_PATTERN, DATETIME_VALUE_FORMAT, DATETIME_VALUE_PATTERN, isValidDataTypeValue, companyFieldToRuntime, makeFieldValue, parseFieldPath, refKind, refValueIssues, requireFieldPath, slotFieldEntries, slotFieldNames, validateBareValue, validateFieldRefs, } from './core/slot/index.js';
47
+ export { CHANNELS, isSpokenLanguage, SPOKEN_LANGUAGES } from './core/conversation/index.js';
48
+ export * from './core/case-orchestrator/index.js';
49
+ export * from './core/party/index.js';
50
+ export * from './voice-service/index.js';
51
+ export { dayIn, formatTime } from './core/page/time-format.js';
52
+ // The other entries in full, so this one holds them by construction (`package-entries.test.ts`).
53
+ export * from './index.js';
54
+ export * from './worker.js';
55
+ export * from './compiler.js';
56
+ //# sourceMappingURL=platform.js.map
@@ -1,20 +1,87 @@
1
1
  import type { CallEndEvent, CallRecordedEvent, CallStatusChangeEvent, ChatItemWithCallSid, FieldCollectResponse, IncomingOutgoingCall, TransferEvent } from './types.js';
2
2
  /** Superpanel SDK-owned action dispatch types. Do not add to types.ts — that file is overwritten from Mars. */
3
- export type VoiceServiceActionName = 'fetchTwilioConfig' | 'onInbound' | 'onCallStart' | 'onCallEnd' | 'onCallStatusChanged' | 'onChatItem' | 'onOutbound' | 'onTransferEvents' | 'onFieldCollectCompleted' | 'onCallRecorded';
3
+ export type VoiceServiceActionName = 'fetchTwilioConfig' | 'onInbound' | 'onCallStart' | 'onCallEnd' | 'onCallStatusChanged' | 'onChatItem' | 'onOutbound' | 'onTransferEvents' | 'onFieldCollectCompleted' | 'onFarEnd' | 'onCallRecorded' | 'onSms';
4
4
  export type VoiceServiceActionMap = {
5
5
  fetchTwilioConfig: IncomingOutgoingCall;
6
6
  onInbound: IncomingOutgoingCall;
7
7
  onCallStart: IncomingOutgoingCall;
8
8
  onCallEnd: CallEndEvent;
9
9
  onCallStatusChanged: CallStatusChangeEvent;
10
- onChatItem: ChatItemWithCallSid;
10
+ onChatItem: ChatItemWithCallSid & WithEventId;
11
11
  onOutbound: IncomingOutgoingCall;
12
- onTransferEvents: TransferEvent;
13
- onFieldCollectCompleted: FieldCollectResponse;
12
+ onTransferEvents: TransferEvent & WithEventId;
13
+ onFieldCollectCompleted: FieldCollectResponse & WithEventId;
14
+ onFarEnd: FarEndEvent & WithEventId;
14
15
  onCallRecorded: CallRecordedEvent;
16
+ onSms: {
17
+ MessageSid: string;
18
+ AccountSid: string;
19
+ From: string;
20
+ To: string;
21
+ Body: string;
22
+ [key: string]: string | undefined;
23
+ };
15
24
  };
16
25
  export type VoiceServiceActionRequest<A extends VoiceServiceActionName = VoiceServiceActionName> = {
17
26
  action: A;
18
27
  params: VoiceServiceActionMap[A];
19
28
  };
29
+ /** A call event's id: the same event sent again (a resend after reconnecting, a retry) is handled once. */
30
+ export type WithEventId = {
31
+ eventId?: string;
32
+ };
33
+ /**
34
+ * A call event the voice service sends on the call's socket (`{ action: 'event', params }`), answered with
35
+ * `eventAck` once handled and saved. Once the call's socket is gone it goes by HTTP as its own action.
36
+ */
37
+ export type VoiceCallEvent = {
38
+ eventId: string;
39
+ name: 'chatItem';
40
+ payload: ChatItemWithCallSid;
41
+ } | {
42
+ eventId: string;
43
+ name: 'fieldCollectCompleted';
44
+ payload: FieldCollectResponse;
45
+ } | {
46
+ eventId: string;
47
+ name: 'transferEvent';
48
+ payload: TransferEvent;
49
+ } | {
50
+ eventId: string;
51
+ name: 'farEnd';
52
+ payload: FarEndEvent;
53
+ };
54
+ /**
55
+ * Who answered an outbound call (25 §13): a person, a voicemail greeting, a call-screening assistant
56
+ * ("say your name and why you are calling"), or a phone menu. The voice service tells; the page decides.
57
+ */
58
+ export type FarEndKind = 'human' | 'voicemail' | 'screening' | 'ivr';
59
+ /** The voice service's verdict on the far end, with what it said. */
60
+ export type FarEndEvent = {
61
+ callSid: string;
62
+ kind: FarEndKind;
63
+ said: string;
64
+ };
65
+ /**
66
+ * The backend's answer to a far end (25 §13): `handled` — the page took it (it leaves a message, speaks to
67
+ * the screener, presses keys, ends), so the voice service does not do its own thing (and, screened,
68
+ * waits longer in silence); `default` — the voice service does what it did before (hang up on a machine).
69
+ */
70
+ export type FarEndDecisionRequest = {
71
+ callSid: string;
72
+ type: 'far-end-decision';
73
+ kind: FarEndKind;
74
+ decision: 'default' | 'handled';
75
+ };
76
+ /** Leave this message on the voicemail, after its beep, word for word, then hang up (25 §13). */
77
+ export type LeaveVoicemailRequest = {
78
+ callSid: string;
79
+ type: 'leave-voicemail';
80
+ text: string;
81
+ };
82
+ /** The answer to a call event: handled, or failed with `error` (not sent again either way). */
83
+ export type VoiceCallEventAck = {
84
+ eventId: string;
85
+ error?: string;
86
+ };
20
87
  //# sourceMappingURL=actions.d.ts.map
@@ -320,6 +320,8 @@ export interface VoiceMailConfig {
320
320
  voiceMailSpeakTimeoutMs: number;
321
321
  voiceMailAutoHangupDelayMs: number;
322
322
  voiceMailPrompt?: string;
323
+ /** Tell the backend who answered (voicemail, screening, IVR, human) and let it decide (25 §13), instead of acting alone. */
324
+ reportFarEnd?: boolean;
323
325
  }
324
326
  export interface UserSilenceConfig {
325
327
  silenceTimeoutMs: number[];
@@ -360,6 +362,8 @@ export interface LoopConfirmConfig {
360
362
  export interface TransferConfig extends LoopConfirmConfig {
361
363
  confirmLlmPrompt: string;
362
364
  withoutBriefing: boolean;
365
+ /** Warm and async-warm only. Set per hop when the transfer names `callerIdShown`. */
366
+ inboundCallTransferCallerId?: 'customer' | 'assistant';
363
367
  warmTransferWaitingMusicURL?: string;
364
368
  warmTransferWaitingMusicVolume?: number;
365
369
  }
@@ -369,9 +373,6 @@ export interface FieldCollectConfig extends LoopConfirmConfig {
369
373
  unsuccessSayText: string | null;
370
374
  validateDigits: DtmfDigit[];
371
375
  digitsValueMap: Record<string, string>;
372
- finishOnKey?: DtmfDigit;
373
- minDigits?: number;
374
- maxDigits?: number;
375
376
  }
376
377
  export interface WarmTransferSession {
377
378
  conferenceName: string;
@@ -445,6 +446,8 @@ export interface VoiceAssistantConfig {
445
446
  twilio: {
446
447
  accountSid: string;
447
448
  authToken: string;
449
+ /** Twilio REST requests go here instead of `*.twilio.com` (a test environment's stand-in). */
450
+ apiBaseUrl?: string;
448
451
  };
449
452
  language: string;
450
453
  }
@@ -467,6 +470,19 @@ export type TwilioCredentials = VoiceAssistantConfig['twilio'];
467
470
  export interface AppAction {
468
471
  callSid: string;
469
472
  }
473
+ /**
474
+ * A SIP call's own facts, as the voice service parses Twilio's SIP Domain webhook: the URIs as they came,
475
+ * the domain, and the `X-` headers (and `User-to-User`) the far end sent, by name without `SipHeader_`.
476
+ */
477
+ export interface IncomingSipInfo {
478
+ fromUri?: string;
479
+ toUri?: string;
480
+ domain?: string;
481
+ domainSid?: string;
482
+ callId?: string;
483
+ sourceIp?: string;
484
+ headers: Record<string, string>;
485
+ }
470
486
  export interface IncomingOutgoingCall extends AppAction {
471
487
  fromNumber: string;
472
488
  toNumber: string;
@@ -475,6 +491,17 @@ export interface IncomingOutgoingCall extends AppAction {
475
491
  appId: string;
476
492
  startTs: Date;
477
493
  status?: TwilioCallStatus;
494
+ /**
495
+ * How the call came in: `sip` through our SIP Domain. A SIP URI's user that is a phone number is given
496
+ * as the number (`fromNumber` / `toNumber`); any other stays the URI.
497
+ */
498
+ source?: 'pstn' | 'sip';
499
+ sip?: IncomingSipInfo;
500
+ /**
501
+ * Inbound: the voice service's own dependencies that its last health check found down (`deepgram`,
502
+ * `cartesia`, …). The AI cannot take the call: it goes to the fallback number.
503
+ */
504
+ unavailableServices?: string[];
478
505
  }
479
506
  export interface ChatWebsocketStartMessage extends IncomingOutgoingCall {
480
507
  voiceServiceUrl: string;
@@ -496,6 +523,11 @@ export type ApplicationConfig = {
496
523
  language: string;
497
524
  reason?: CallFailedReason;
498
525
  cfg: VoiceAssistantConfig;
526
+ /**
527
+ * The number this call is taken as, when it is not the one it came in on (a SIP call routed by its URI,
528
+ * domain or header): the voice service shows it as the caller ID when it transfers.
529
+ */
530
+ serviceNumber?: string;
499
531
  };
500
532
  export type ApplicationConfigResponse = Omit<Partial<ApplicationConfig>, 'cfg'> & {
501
533
  cfg?: OptionalVoiceAssistantConfig;
@@ -677,7 +709,7 @@ export interface ReloadAppConfigResponse extends AppAction {
677
709
  export interface VoiceServiceResponse {
678
710
  success: boolean;
679
711
  callSid?: string;
680
- failedReason?: 'max-outbound-calls-reached' | 'twilio-api-error' | 'voice-service-internal-error' | 'on-outbound-request-error' | 'network-error' | 'fetch-twilio-config-error';
712
+ failedReason?: 'max-outbound-calls-reached' | 'service-unavailable' | 'twilio-api-error' | 'voice-service-internal-error' | 'on-outbound-request-error' | 'network-error' | 'fetch-twilio-config-error';
681
713
  message?: string;
682
714
  errorCode?: number;
683
715
  statusCode?: number;
@@ -714,7 +746,7 @@ export interface DispatchRule {
714
746
  phoneNumber: string;
715
747
  agentServiceUrl: string;
716
748
  }
717
- export type CallEndReason = 'stt-error-exit' | 'voicemail-detected-with-reply' | 'voicemail-detected-no-reply' | 'user-silence-max-reached' | 'user-silence-signal-max-continue-reached' | 'assistant-said-goodbye' | 'instance-shutting-down' | 'customer-ended-call' | 'call-busy' | 'call-no-answer' | 'call-failed' | 'call-canceled' | 'cold-transfer-call-success' | 'cold-transfer-call-success-by-first-action' | 'warm-transfer-call-success' | 'warm-transfer-call-success-by-first-action' | 'warm-transfer-failed-execute-error' | 'warm-transfer-failed-confirm-timeout' | 'warm-transfer-failed-join-conference' | 'warm-transfer-failed-target-no-answer' | 'warm-transfer-failed-target-busy' | 'warm-transfer-failed-target-canceled' | 'warm-transfer-failed-target-hangup' | 'warm-transfer-failed-target-error' | 'warm-transfer-failed-customer-hangup' | 'cold-transfer-failed-no-answer' | 'cold-transfer-failed-busy' | 'cold-transfer-failed-canceled' | 'cold-transfer-failed-error' | 'cold-transfer-failed-customer-hangup' | 'field-collect-failed' | 'field-collect-customer-hangup' | 'user-is-bot' | 'unknown';
749
+ export type CallEndReason = 'stt-error-exit' | 'voicemail-detected-with-reply' | 'voicemail-detected-no-reply' | 'voicemail-left' | 'user-silence-max-reached' | 'user-silence-signal-max-continue-reached' | 'assistant-said-goodbye' | 'instance-shutting-down' | 'customer-ended-call' | 'call-busy' | 'call-no-answer' | 'call-failed' | 'call-canceled' | 'cold-transfer-call-success' | 'cold-transfer-call-success-by-first-action' | 'warm-transfer-call-success' | 'warm-transfer-call-success-by-first-action' | 'warm-transfer-failed-execute-error' | 'warm-transfer-failed-confirm-timeout' | 'warm-transfer-failed-join-conference' | 'warm-transfer-failed-target-no-answer' | 'warm-transfer-failed-target-busy' | 'warm-transfer-failed-target-canceled' | 'warm-transfer-failed-target-hangup' | 'warm-transfer-failed-target-error' | 'warm-transfer-failed-customer-hangup' | 'cold-transfer-failed-no-answer' | 'cold-transfer-failed-busy' | 'cold-transfer-failed-canceled' | 'cold-transfer-failed-error' | 'cold-transfer-failed-customer-hangup' | 'field-collect-failed' | 'field-collect-customer-hangup' | 'user-is-bot' | 'unknown';
718
750
  export interface CallStatusChangeEvent extends AppAction {
719
751
  ctx: IncomingOutgoingCall;
720
752
  status: TwilioCallStatusCallback;
@@ -1009,5 +1041,10 @@ export interface RealtimeChatRequest extends AppAction {
1009
1041
  type: 'realtime-chat';
1010
1042
  payload: Omit<RealtimeChatActionPayload, 'callSid'>;
1011
1043
  }
1044
+ export interface SayRequest extends AppAction {
1045
+ type: 'say';
1046
+ text: string;
1047
+ interruptable?: boolean;
1048
+ }
1012
1049
  export {};
1013
1050
  //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The user Worker's shell (`apps/cf-fn/user-worker-template`): the invocation it receives, the ctx it
3
+ * builds for a function and the RPC client behind `ctx.api`. Platform-only: the package resolves
4
+ * `./worker` under the `superpanel-platform` condition. It pulls in neither the compiler nor Node, so
5
+ * the Worker carries only this.
6
+ */
7
+ export * from './fn-context/index.js';
8
+ export { isWorkerFunctionKind, type WorkerFunctionKind } from './core/functions/types.js';
9
+ export { parseComputeInvocation, type FunctionInvocation } from './compute-host/compute-host.js';
10
+ //# sourceMappingURL=worker.d.ts.map
package/dist/worker.js ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The user Worker's shell (`apps/cf-fn/user-worker-template`): the invocation it receives, the ctx it
3
+ * builds for a function and the RPC client behind `ctx.api`. Platform-only: the package resolves
4
+ * `./worker` under the `superpanel-platform` condition. It pulls in neither the compiler nor Node, so
5
+ * the Worker carries only this.
6
+ */
7
+ export * from './fn-context/index.js';
8
+ export { isWorkerFunctionKind } from './core/functions/types.js';
9
+ export { parseComputeInvocation } from './compute-host/compute-host.js';
10
+ //# sourceMappingURL=worker.js.map
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@superpanel-sdk/runtime",
3
- "version": "0.2.3",
4
- "description": "Slot + Stage runtime: schema, writes, derived recompute, agenda compile/walk/simulate",
3
+ "version": "0.5.0",
4
+ "description": "Slot + page runtime: schema, writes, derived recompute, page compile + todos",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
7
7
  "engines": {
8
- "node": ">=20.12"
8
+ "node": ">=22.15"
9
9
  },
10
10
  "bin": {
11
- "superpanel-sdk-runtime": "./bin/superpanel-sdk-runtime.mjs"
11
+ "superpanel-sdk-runtime": "bin/superpanel-sdk-runtime.mjs"
12
12
  },
13
13
  "exports": {
14
14
  ".": {
@@ -16,13 +16,30 @@
16
16
  "import": "./dist/index.js",
17
17
  "default": "./dist/index.js"
18
18
  },
19
- "./fn-context": {
20
- "types": "./dist/fn-context/index.d.ts",
21
- "import": "./dist/fn-context/index.js",
22
- "default": "./dist/fn-context/index.js"
19
+ "./platform": {
20
+ "superpanel-platform": {
21
+ "types": "./dist/platform.d.ts",
22
+ "import": "./dist/platform.js",
23
+ "default": "./dist/platform.js"
24
+ }
25
+ },
26
+ "./worker": {
27
+ "superpanel-platform": {
28
+ "types": "./dist/worker.d.ts",
29
+ "import": "./dist/worker.js",
30
+ "default": "./dist/worker.js"
31
+ }
32
+ },
33
+ "./compiler": {
34
+ "superpanel-platform": {
35
+ "types": "./dist/compiler.d.ts",
36
+ "import": "./dist/compiler.js",
37
+ "default": "./dist/compiler.js"
38
+ }
23
39
  },
24
40
  "./package.json": "./package.json"
25
41
  },
42
+ "sideEffects": false,
26
43
  "files": [
27
44
  "bin/**/*.mjs",
28
45
  "dist/**/*.js",
@@ -30,26 +47,28 @@
30
47
  ],
31
48
  "publishConfig": {
32
49
  "access": "public",
33
- "tag": "next"
50
+ "tag": "latest"
51
+ },
52
+ "scripts": {
53
+ "build": "tsc -p tsconfig.json",
54
+ "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tests/tsconfig.json --noEmit",
55
+ "test": "tsx --tsconfig tests/tsconfig.json --test tests/**/*.test.ts",
56
+ "dev": "tsc -p tsconfig.json --watch --preserveWatchOutput",
57
+ "prepublishOnly": "rm -rf dist tsconfig.tsbuildinfo && tsc -p tsconfig.json"
34
58
  },
35
59
  "dependencies": {
60
+ "@clack/prompts": "^1.8.1",
36
61
  "@trpc/client": "^11.7.2",
37
62
  "@trpc/server": "^11.7.2",
38
63
  "chokidar": "^4.0.3",
39
64
  "commander": "^15.0.0",
65
+ "cron-parser": "5.10.0",
40
66
  "esbuild": "^0.25.12",
41
- "json-rules-engine": "^7.3.1",
42
67
  "tsx": "^4.23.1",
68
+ "typescript": "7.0.2",
43
69
  "zod": "^4.4.3"
44
70
  },
45
71
  "devDependencies": {
46
- "@types/node": "^26.1.1",
47
- "typescript": "^7.0.2"
48
- },
49
- "scripts": {
50
- "build": "tsc -p tsconfig.json",
51
- "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tests/tsconfig.json --noEmit",
52
- "test": "tsx --tsconfig tests/tsconfig.json --test tests/**/*.test.ts",
53
- "dev": "tsc -p tsconfig.json --watch --preserveWatchOutput"
72
+ "@types/node": "^26.1.1"
54
73
  }
55
- }
74
+ }
@@ -1,15 +0,0 @@
1
- import type { EffectiveSchema } from '../../core/slot/schema.js';
2
- import type { CompiledSlotSchema, ValidationIssue } from '../../core/slot/types.js';
3
- import type { FuncMap } from '../../core/functions/types.js';
4
- import { fatalAgendaIssues, type CompiledAgenda } from '../../core/stage/index.js';
5
- export type CompileAgendasResult = {
6
- schema: CompiledSlotSchema;
7
- effectiveSchema: EffectiveSchema;
8
- agendas: Record<string, CompiledAgenda>;
9
- issues: ValidationIssue[];
10
- };
11
- export declare function compileSequenceAgendas(schema: CompiledSlotSchema, raw: unknown, options?: {
12
- functions?: FuncMap;
13
- }): CompileAgendasResult;
14
- export { fatalAgendaIssues };
15
- //# sourceMappingURL=compile-agenda.d.ts.map
@@ -1,64 +0,0 @@
1
- import { toEffectiveSchema } from '../../core/slot/compile-schema.js';
2
- import { collectIvrBlocks, collectTransferBlocks, collectTransferInterruptHeaders, fatalAgendaIssues, flattenAgendaPlacements, flattenAgendaTree, isAgendaTree, isSequenceAgendas, normalizeSequenceAgendas, registerIvrSessionFields, registerTransferSessionFields, validateCompiledAgenda, } from '../../core/stage/index.js';
3
- function asAgendaTrees(raw) {
4
- if (isAgendaTree(raw))
5
- return [raw];
6
- if (Array.isArray(raw) && raw.length > 0 && raw.every(isAgendaTree))
7
- return raw;
8
- if (raw != null && typeof raw === 'object' && !Array.isArray(raw) && !isSequenceAgendas(raw)) {
9
- const values = Object.values(raw);
10
- if (values.length > 0 && values.every(isAgendaTree))
11
- return values;
12
- }
13
- return null;
14
- }
15
- function compileOneFlat(agendaId, header, flattened, schema, functions, issues) {
16
- issues.push(...flattened.issues);
17
- const agenda = { header, flat: flattened.items };
18
- const validated = validateCompiledAgenda(agenda, { schema, functions, agendaId });
19
- if (!validated.ok)
20
- issues.push(...validated.issues);
21
- return agenda;
22
- }
23
- export function compileSequenceAgendas(schema, raw, options = {}) {
24
- const issues = [];
25
- if (raw == null) {
26
- return { schema, effectiveSchema: toEffectiveSchema(schema), agendas: {}, issues };
27
- }
28
- const trees = asAgendaTrees(raw);
29
- if (trees) {
30
- const nodes = trees.flatMap((tree) => tree.tree);
31
- const transferIds = collectTransferBlocks({}, nodes).map((block) => block.id);
32
- const withTransfer = registerIvrSessionFields(registerTransferSessionFields(schema, transferIds, {
33
- lastResult: collectTransferInterruptHeaders(trees.map((tree) => tree.header)),
34
- }), collectIvrBlocks({}, nodes).map((block) => block.id));
35
- const compiled = {};
36
- for (const tree of trees) {
37
- compiled[tree.id] = compileOneFlat(tree.id, tree.header, flattenAgendaTree(tree.tree, { functions: options.functions }), withTransfer, options.functions, issues);
38
- }
39
- return { schema: withTransfer, effectiveSchema: toEffectiveSchema(withTransfer), agendas: compiled, issues };
40
- }
41
- let agendasInput;
42
- try {
43
- agendasInput = isSequenceAgendas(raw) ? raw : normalizeSequenceAgendas(raw);
44
- }
45
- catch (error) {
46
- issues.push({
47
- code: 'invalid-agendas',
48
- message: error instanceof Error ? error.message : String(error),
49
- path: 'agendas',
50
- });
51
- return { schema, effectiveSchema: toEffectiveSchema(schema), agendas: {}, issues };
52
- }
53
- const transferIds = collectTransferBlocks(agendasInput.blocks).map((block) => block.id);
54
- const withTransfer = registerIvrSessionFields(registerTransferSessionFields(schema, transferIds, {
55
- lastResult: collectTransferInterruptHeaders(Object.values(agendasInput.agendas).map((config) => config.header)),
56
- }), collectIvrBlocks(agendasInput.blocks).map((block) => block.id));
57
- const compiled = {};
58
- for (const [agendaId, config] of Object.entries(agendasInput.agendas)) {
59
- compiled[agendaId] = compileOneFlat(agendaId, config.header, flattenAgendaPlacements(config.placements, agendasInput.blocks, { functions: options.functions }), withTransfer, options.functions, issues);
60
- }
61
- return { schema: withTransfer, effectiveSchema: toEffectiveSchema(withTransfer), agendas: compiled, issues };
62
- }
63
- export { fatalAgendaIssues };
64
- //# sourceMappingURL=compile-agenda.js.map
@@ -1,4 +0,0 @@
1
- import type { CompanySchema, EffectiveSchema, SequenceSlots } from '../core/slot/schema.js';
2
- /** Merge company schema + sequence slots view into effective schema for codegen. */
3
- export declare function mergeEffectiveSchema(company: CompanySchema, sequenceSlots: SequenceSlots): EffectiveSchema;
4
- //# sourceMappingURL=merge.d.ts.map
@@ -1,19 +0,0 @@
1
- import { compileSlotSchema, toEffectiveSchema } from '../core/slot/compile-schema.js';
2
- /** Merge company schema + sequence slots view into effective schema for codegen. */
3
- export function mergeEffectiveSchema(company, sequenceSlots) {
4
- const { schema, validation } = compileSlotSchema(company, sequenceSlots);
5
- if (!validation.ok) {
6
- const fatal = validation.issues.filter((i) => i.code === 'unknown-table' ||
7
- i.code === 'unknown-field' ||
8
- i.code === 'unknown-ref-table' ||
9
- i.code === 'invalid-id-field' ||
10
- i.code === 'missing-id-field' ||
11
- i.code === 'id-cannot-ref' ||
12
- i.code === 'reserved-table-name');
13
- if (fatal.length > 0) {
14
- throw new Error(fatal.map((i) => i.message).join('; '));
15
- }
16
- }
17
- return toEffectiveSchema(schema);
18
- }
19
- //# sourceMappingURL=merge.js.map
@@ -1,20 +0,0 @@
1
- import type { ComputeHost } from './compute-host.js';
2
- /** Names safe to cache: `caseContextView` plus every compute / boolCompute. */
3
- export declare function readOnlyComputeNames(functions?: Record<string, {
4
- kind: string;
5
- }>): Set<string>;
6
- export type ReadOnlyComputeCacheOptions = {
7
- /** Defaults to `caseContextView` only. Pass {@link readOnlyComputeNames} for compute / boolCompute too. */
8
- readOnly?: Iterable<string> | ((name: string) => boolean);
9
- };
10
- /**
11
- * Cache read-only `execute` results by function name + the single input object.
12
- * Calls with extra args bypass the cache so a shared snapshot cannot alias
13
- * two different argument lists.
14
- *
15
- * Do not wrap a host used by derived recompute: that path mutates one snapshot
16
- * in place between `compute` calls. Stage walk / when-eval is safe (new snapshot
17
- * after writes).
18
- */
19
- export declare function withReadOnlyComputeCache(host: ComputeHost, options?: ReadOnlyComputeCacheOptions): ComputeHost;
20
- //# sourceMappingURL=read-only-cache.d.ts.map