@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
@@ -299,10 +299,7 @@ export interface FishTTSConfig {
299
299
  export interface AssistantConfig {
300
300
  minNumberOfWordsToInterrupt: number;
301
301
  interruptProtectionMs: number;
302
- endSpeakTimeoutMs: number;
303
- sttProvider: STTProvider;
304
302
  ttsProvider: TTSProvider;
305
- goodbyePatterns: string[];
306
303
  defaultTransferingMessage: string;
307
304
  defaultTransferFailedMessage: string;
308
305
  shuttingDownMessage: string;
@@ -320,6 +317,8 @@ export interface VoiceMailConfig {
320
317
  voiceMailSpeakTimeoutMs: number;
321
318
  voiceMailAutoHangupDelayMs: number;
322
319
  voiceMailPrompt?: string;
320
+ /** Tell the backend who answered (voicemail, screening, IVR, human) and let it decide (25 §13), instead of acting alone. */
321
+ reportFarEnd?: boolean;
323
322
  }
324
323
  export interface UserSilenceConfig {
325
324
  silenceTimeoutMs: number[];
@@ -360,6 +359,8 @@ export interface LoopConfirmConfig {
360
359
  export interface TransferConfig extends LoopConfirmConfig {
361
360
  confirmLlmPrompt: string;
362
361
  withoutBriefing: boolean;
362
+ /** Warm and async-warm only. Set per hop when the transfer names `callerIdShown`. */
363
+ inboundCallTransferCallerId?: 'customer' | 'assistant';
363
364
  warmTransferWaitingMusicURL?: string;
364
365
  warmTransferWaitingMusicVolume?: number;
365
366
  }
@@ -369,9 +370,6 @@ export interface FieldCollectConfig extends LoopConfirmConfig {
369
370
  unsuccessSayText: string | null;
370
371
  validateDigits: DtmfDigit[];
371
372
  digitsValueMap: Record<string, string>;
372
- finishOnKey?: DtmfDigit;
373
- minDigits?: number;
374
- maxDigits?: number;
375
373
  }
376
374
  export interface WarmTransferSession {
377
375
  conferenceName: string;
@@ -445,6 +443,8 @@ export interface VoiceAssistantConfig {
445
443
  twilio: {
446
444
  accountSid: string;
447
445
  authToken: string;
446
+ /** Twilio REST requests go here instead of `*.twilio.com` (a test environment's stand-in). */
447
+ apiBaseUrl?: string;
448
448
  };
449
449
  language: string;
450
450
  }
@@ -467,6 +467,19 @@ export type TwilioCredentials = VoiceAssistantConfig['twilio'];
467
467
  export interface AppAction {
468
468
  callSid: string;
469
469
  }
470
+ /**
471
+ * A SIP call's own facts, as the voice service parses Twilio's SIP Domain webhook: the URIs as they came,
472
+ * the domain, and the `X-` headers (and `User-to-User`) the far end sent, by name without `SipHeader_`.
473
+ */
474
+ export interface IncomingSipInfo {
475
+ fromUri?: string;
476
+ toUri?: string;
477
+ domain?: string;
478
+ domainSid?: string;
479
+ callId?: string;
480
+ sourceIp?: string;
481
+ headers: Record<string, string>;
482
+ }
470
483
  export interface IncomingOutgoingCall extends AppAction {
471
484
  fromNumber: string;
472
485
  toNumber: string;
@@ -475,6 +488,22 @@ export interface IncomingOutgoingCall extends AppAction {
475
488
  appId: string;
476
489
  startTs: Date;
477
490
  status?: TwilioCallStatus;
491
+ /**
492
+ * How the call came in: `sip` through our SIP Domain. A SIP URI's user that is a phone number is given
493
+ * as the number (`fromNumber` / `toNumber`); any other stays the URI.
494
+ */
495
+ source?: 'pstn' | 'sip';
496
+ sip?: IncomingSipInfo;
497
+ /**
498
+ * Inbound: the voice service's own dependencies that its last health check found down (`deepgram`,
499
+ * `cartesia`, …). The AI cannot take the call: it goes to the fallback number.
500
+ */
501
+ unavailableServices?: string[];
502
+ /**
503
+ * Outbound: the id of the `Call` the Backend wrote before it asked for the dial (`make-call`'s `callId`),
504
+ * sent back as it came: the Backend finds the call by it (74 §3.1).
505
+ */
506
+ callId?: string;
478
507
  }
479
508
  export interface ChatWebsocketStartMessage extends IncomingOutgoingCall {
480
509
  voiceServiceUrl: string;
@@ -496,6 +525,11 @@ export type ApplicationConfig = {
496
525
  language: string;
497
526
  reason?: CallFailedReason;
498
527
  cfg: VoiceAssistantConfig;
528
+ /**
529
+ * A call that came in on no number of ours (a call to one of our SIP addresses): the number the voice
530
+ * service shows as the caller ID when it transfers (the SIP address's caller-ID number).
531
+ */
532
+ serviceNumber?: string;
499
533
  };
500
534
  export type ApplicationConfigResponse = Omit<Partial<ApplicationConfig>, 'cfg'> & {
501
535
  cfg?: OptionalVoiceAssistantConfig;
@@ -630,6 +664,10 @@ export interface TransferEvt extends AppAction {
630
664
  interruptSay: boolean;
631
665
  requestor: Requestor;
632
666
  warmBriefingPrompt: string;
667
+ /** Warm and background: the page's whisper, looped to the person before they confirm (76 §2.9). */
668
+ whisper?: string;
669
+ /** The language of the person taking the call (BCP-47; English when absent): what they hear, and how they are heard (48 §10.3). */
670
+ agentLanguage?: string;
633
671
  transferType?: TransferType;
634
672
  warmTransferConfirmMode?: WarmTransferConfirmMethod[];
635
673
  warmTransferConfirmKeypad?: DtmfDigit;
@@ -644,6 +682,8 @@ export interface MakeCallRequest extends MakeCallOptions {
644
682
  type: 'make-call';
645
683
  fromNumber: string;
646
684
  toNumber: string;
685
+ /** The Backend's `Call` for this dial; the voice service sends it back on `onOutbound` (74 §3.1). */
686
+ callId?: string;
647
687
  options: MakeCallOptions;
648
688
  }
649
689
  export interface GlobalInterruptibleRequest extends AppAction {
@@ -677,7 +717,9 @@ export interface ReloadAppConfigResponse extends AppAction {
677
717
  export interface VoiceServiceResponse {
678
718
  success: boolean;
679
719
  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';
720
+ failedReason?: 'max-outbound-calls-reached' | 'service-unavailable' | 'twilio-api-error' | 'voice-service-internal-error' | 'on-outbound-request-error' | 'network-error'
721
+ /** The voice service answered with an HTTP error status (`statusCode`): set by the Backend's client. */
722
+ | 'http-error' | 'fetch-twilio-config-error';
681
723
  message?: string;
682
724
  errorCode?: number;
683
725
  statusCode?: number;
@@ -714,7 +756,7 @@ export interface DispatchRule {
714
756
  phoneNumber: string;
715
757
  agentServiceUrl: string;
716
758
  }
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';
759
+ 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
760
  export interface CallStatusChangeEvent extends AppAction {
719
761
  ctx: IncomingOutgoingCall;
720
762
  status: TwilioCallStatusCallback;
@@ -1009,5 +1051,10 @@ export interface RealtimeChatRequest extends AppAction {
1009
1051
  type: 'realtime-chat';
1010
1052
  payload: Omit<RealtimeChatActionPayload, 'callSid'>;
1011
1053
  }
1054
+ export interface SayRequest extends AppAction {
1055
+ type: 'say';
1056
+ text: string;
1057
+ interruptable?: boolean;
1058
+ }
1012
1059
  export {};
1013
1060
  //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,11 @@
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 { parseComputeInvocation, type FunctionInvocation } from './compute-host/compute-host.js';
9
+ export { ORCHESTRATOR_FUNCTION } from './core/case-orchestrator/types.js';
10
+ export { functionScriptFile } from './builder/types.js';
11
+ //# sourceMappingURL=worker.d.ts.map
package/dist/worker.js ADDED
@@ -0,0 +1,11 @@
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 { parseComputeInvocation } from './compute-host/compute-host.js';
9
+ export { ORCHESTRATOR_FUNCTION } from './core/case-orchestrator/types.js';
10
+ export { functionScriptFile } from './builder/types.js';
11
+ //# sourceMappingURL=worker.js.map
package/package.json CHANGED
@@ -1,11 +1,11 @@
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.7.0",
4
+ "description": "Slot + page runtime: schema, writes, page compile",
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
11
  "superpanel-sdk-runtime": "./bin/superpanel-sdk-runtime.mjs"
@@ -16,35 +16,58 @@
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
+ "./testing": {
20
+ "types": "./dist/testing.d.ts",
21
+ "import": "./dist/testing.js",
22
+ "default": "./dist/testing.js"
23
+ },
24
+ "./platform": {
25
+ "superpanel-platform": {
26
+ "types": "./dist/platform.d.ts",
27
+ "import": "./dist/platform.js",
28
+ "default": "./dist/platform.js"
29
+ }
30
+ },
31
+ "./worker": {
32
+ "superpanel-platform": {
33
+ "types": "./dist/worker.d.ts",
34
+ "import": "./dist/worker.js",
35
+ "default": "./dist/worker.js"
36
+ }
37
+ },
38
+ "./compiler": {
39
+ "superpanel-platform": {
40
+ "types": "./dist/compiler.d.ts",
41
+ "import": "./dist/compiler.js",
42
+ "default": "./dist/compiler.js"
43
+ }
23
44
  },
24
45
  "./package.json": "./package.json"
25
46
  },
47
+ "sideEffects": false,
26
48
  "files": [
27
49
  "bin/**/*.mjs",
28
50
  "dist/**/*.js",
29
51
  "dist/**/*.d.ts"
30
52
  ],
31
53
  "publishConfig": {
32
- "access": "public",
33
- "tag": "next"
54
+ "access": "public"
34
55
  },
35
56
  "dependencies": {
36
- "@trpc/client": "^11.7.2",
37
- "@trpc/server": "^11.7.2",
57
+ "@clack/prompts": "^1.8.1",
58
+ "@trpc/client": "11.18.0",
59
+ "@trpc/server": "11.18.0",
38
60
  "chokidar": "^4.0.3",
39
61
  "commander": "^15.0.0",
62
+ "cron-parser": "5.10.0",
40
63
  "esbuild": "^0.25.12",
41
- "json-rules-engine": "^7.3.1",
64
+ "quickjs-emscripten": "^0.32.0",
42
65
  "tsx": "^4.23.1",
43
- "zod": "^4.4.3"
66
+ "typescript": "7.0.2",
67
+ "zod": "4.4.3"
44
68
  },
45
69
  "devDependencies": {
46
- "@types/node": "^26.1.1",
47
- "typescript": "^7.0.2"
70
+ "@types/node": "^26.1.1"
48
71
  },
49
72
  "scripts": {
50
73
  "build": "tsc -p tsconfig.json",
@@ -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
@@ -1,61 +0,0 @@
1
- const READ_ONLY_KINDS = new Set(['compute', 'boolCompute', 'caseContextView']);
2
- /** Names safe to cache: `caseContextView` plus every compute / boolCompute. */
3
- export function readOnlyComputeNames(functions) {
4
- const names = new Set(['caseContextView']);
5
- if (!functions)
6
- return names;
7
- for (const [name, entry] of Object.entries(functions)) {
8
- if (READ_ONLY_KINDS.has(entry.kind))
9
- names.add(name);
10
- }
11
- return names;
12
- }
13
- /**
14
- * Cache read-only `execute` results by function name + the single input object.
15
- * Calls with extra args bypass the cache so a shared snapshot cannot alias
16
- * two different argument lists.
17
- *
18
- * Do not wrap a host used by derived recompute: that path mutates one snapshot
19
- * in place between `compute` calls. Stage walk / when-eval is safe (new snapshot
20
- * after writes).
21
- */
22
- export function withReadOnlyComputeCache(host, options) {
23
- const allow = resolveAllow(options?.readOnly);
24
- const cache = new WeakMap();
25
- return {
26
- async execute(name, args = []) {
27
- const input = args[0];
28
- if (!allow(name) || args.length !== 1 || input == null || typeof input !== 'object') {
29
- return host.execute(name, args);
30
- }
31
- let byName = cache.get(input);
32
- if (!byName) {
33
- byName = new Map();
34
- cache.set(input, byName);
35
- }
36
- const hit = byName.get(name);
37
- if (hit)
38
- return hit;
39
- const pending = host.execute(name, args);
40
- byName.set(name, pending);
41
- try {
42
- return await pending;
43
- }
44
- catch (error) {
45
- if (byName.get(name) === pending)
46
- byName.delete(name);
47
- throw error;
48
- }
49
- },
50
- dispose() {
51
- host.dispose();
52
- },
53
- };
54
- }
55
- function resolveAllow(readOnly) {
56
- if (typeof readOnly === 'function')
57
- return readOnly;
58
- const names = new Set(readOnly ?? ['caseContextView']);
59
- return (name) => names.has(name);
60
- }
61
- //# sourceMappingURL=read-only-cache.js.map
@@ -1,69 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const KV_KEY_MAX = 512;
3
- export declare const KV_VALUE_MAX = 65536;
4
- export declare const KV_TTL_SECONDS_MAX: number;
5
- export declare const dbGetInput: z.ZodObject<{
6
- key: z.ZodString;
7
- }, z.core.$strip>;
8
- export type DbGetInput = z.infer<typeof dbGetInput>;
9
- export declare const dbGetOutput: z.ZodObject<{
10
- value: z.ZodNullable<z.ZodString>;
11
- }, z.core.$strip>;
12
- export type DbGetOutput = z.infer<typeof dbGetOutput>;
13
- export declare const dbSetInput: z.ZodObject<{
14
- key: z.ZodString;
15
- value: z.ZodString;
16
- ttlSeconds: z.ZodOptional<z.ZodNumber>;
17
- }, z.core.$strip>;
18
- export type DbSetInput = z.infer<typeof dbSetInput>;
19
- export declare const dbSetOutput: z.ZodObject<{
20
- ok: z.ZodLiteral<true>;
21
- }, z.core.$strip>;
22
- export type DbSetOutput = z.infer<typeof dbSetOutput>;
23
- export declare const dbDelInput: z.ZodObject<{
24
- key: z.ZodString;
25
- }, z.core.$strip>;
26
- export type DbDelInput = z.infer<typeof dbDelInput>;
27
- export declare const dbDelOutput: z.ZodObject<{
28
- deleted: z.ZodBoolean;
29
- }, z.core.$strip>;
30
- export type DbDelOutput = z.infer<typeof dbDelOutput>;
31
- /** Platform KV, reached from scripts as `ctx.api.db`. */
32
- export type DbApi = {
33
- get(input: DbGetInput): Promise<DbGetOutput>;
34
- set(input: DbSetInput): Promise<DbSetOutput>;
35
- del(input: DbDelInput): Promise<DbDelOutput>;
36
- };
37
- export declare const dbMockService: DbApi;
38
- export declare const dbSurface: {
39
- methods: {
40
- get: {
41
- input: z.ZodObject<{
42
- key: z.ZodString;
43
- }, z.core.$strip>;
44
- output: z.ZodObject<{
45
- value: z.ZodNullable<z.ZodString>;
46
- }, z.core.$strip>;
47
- };
48
- set: {
49
- input: z.ZodObject<{
50
- key: z.ZodString;
51
- value: z.ZodString;
52
- ttlSeconds: z.ZodOptional<z.ZodNumber>;
53
- }, z.core.$strip>;
54
- output: z.ZodObject<{
55
- ok: z.ZodLiteral<true>;
56
- }, z.core.$strip>;
57
- };
58
- del: {
59
- input: z.ZodObject<{
60
- key: z.ZodString;
61
- }, z.core.$strip>;
62
- output: z.ZodObject<{
63
- deleted: z.ZodBoolean;
64
- }, z.core.$strip>;
65
- };
66
- };
67
- mock: DbApi;
68
- };
69
- //# sourceMappingURL=db.d.ts.map
@@ -1,44 +0,0 @@
1
- import { z } from 'zod';
2
- export const KV_KEY_MAX = 512;
3
- export const KV_VALUE_MAX = 65_536;
4
- export const KV_TTL_SECONDS_MAX = 60 * 60 * 24 * 365 * 5;
5
- export const dbGetInput = z.object({
6
- key: z.string().min(1).max(KV_KEY_MAX),
7
- });
8
- export const dbGetOutput = z.object({
9
- value: z.string().nullable(),
10
- });
11
- export const dbSetInput = z.object({
12
- key: z.string().min(1).max(KV_KEY_MAX),
13
- value: z.string().max(KV_VALUE_MAX),
14
- ttlSeconds: z.number().int().min(1).max(KV_TTL_SECONDS_MAX).optional(),
15
- });
16
- export const dbSetOutput = z.object({
17
- ok: z.literal(true),
18
- });
19
- export const dbDelInput = z.object({
20
- key: z.string().min(1).max(KV_KEY_MAX),
21
- });
22
- export const dbDelOutput = z.object({
23
- deleted: z.boolean(),
24
- });
25
- export const dbMockService = {
26
- async get() {
27
- return { value: null };
28
- },
29
- async set() {
30
- return { ok: true };
31
- },
32
- async del() {
33
- return { deleted: false };
34
- },
35
- };
36
- export const dbSurface = {
37
- methods: {
38
- get: { input: dbGetInput, output: dbGetOutput },
39
- set: { input: dbSetInput, output: dbSetOutput },
40
- del: { input: dbDelInput, output: dbDelOutput },
41
- },
42
- mock: dbMockService,
43
- };
44
- //# sourceMappingURL=db.js.map