@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
@@ -1,26 +1,50 @@
1
1
  import { createIntegrationRouter } from './integration/index.js';
2
2
  import { createLogRouter } from './log.js';
3
3
  import { createPlatformRouter } from './platform.js';
4
+ import { createRecordsRouter } from './records.js';
5
+ import { createCaseOrchestratorToolsRouter } from './case-orchestrator-tools.js';
4
6
  export declare function createAppRouter(modules: {
5
7
  integration: ReturnType<typeof createIntegrationRouter>;
6
8
  platform: ReturnType<typeof createPlatformRouter>;
7
9
  log: ReturnType<typeof createLogRouter>;
10
+ caseOrchestratorTools: ReturnType<typeof createCaseOrchestratorToolsRouter>;
11
+ records: ReturnType<typeof createRecordsRouter>;
8
12
  }): import("@trpc/server").TRPCBuiltRouter<{
9
13
  ctx: import("./trpc-init.js").RpcContext;
10
14
  meta: object;
11
- errorShape: import("@trpc/server").TRPCDefaultErrorShape;
15
+ errorShape: import("@trpc/server").TRPCDefaultErrorShape | {
16
+ message: string;
17
+ code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
18
+ data: {
19
+ code: import("@trpc/server").TRPC_ERROR_CODE_KEY;
20
+ httpStatus: number;
21
+ path?: string;
22
+ stack?: string;
23
+ reason: string;
24
+ };
25
+ };
12
26
  transformer: false;
13
27
  }, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
14
28
  integration: import("@trpc/server").TRPCBuiltRouter<{
15
29
  ctx: import("./trpc-init.js").RpcContext;
16
30
  meta: object;
17
- errorShape: import("@trpc/server").TRPCDefaultErrorShape;
31
+ errorShape: import("@trpc/server").TRPCDefaultErrorShape | {
32
+ message: string;
33
+ code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
34
+ data: {
35
+ code: import("@trpc/server").TRPC_ERROR_CODE_KEY;
36
+ httpStatus: number;
37
+ path?: string;
38
+ stack?: string;
39
+ reason: string;
40
+ };
41
+ };
18
42
  transformer: false;
19
43
  }, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
20
- listBindings: import("@trpc/server").TRPCQueryProcedure<{
44
+ listSurfaces: import("@trpc/server").TRPCQueryProcedure<{
21
45
  input: void;
22
46
  output: {
23
- surfaceKey: "docusigns" | "envs" | "filevines" | "hubspots" | "twilios";
47
+ surfaceKey: "emails" | "envs";
24
48
  target: {
25
49
  kind: "account" | "resource";
26
50
  id: string;
@@ -48,14 +72,24 @@ export declare function createAppRouter(modules: {
48
72
  platform: import("@trpc/server").TRPCBuiltRouter<{
49
73
  ctx: import("./trpc-init.js").RpcContext;
50
74
  meta: object;
51
- errorShape: import("@trpc/server").TRPCDefaultErrorShape;
75
+ errorShape: import("@trpc/server").TRPCDefaultErrorShape | {
76
+ message: string;
77
+ code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
78
+ data: {
79
+ code: import("@trpc/server").TRPC_ERROR_CODE_KEY;
80
+ httpStatus: number;
81
+ path?: string;
82
+ stack?: string;
83
+ reason: string;
84
+ };
85
+ };
52
86
  transformer: false;
53
87
  }, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
54
88
  invoke: import("@trpc/server").TRPCMutationProcedure<{
55
89
  input: {
56
90
  surface: string;
57
91
  method: string;
58
- params?: Record<string, unknown> | undefined;
92
+ params?: unknown;
59
93
  };
60
94
  output: unknown;
61
95
  meta: object;
@@ -64,7 +98,17 @@ export declare function createAppRouter(modules: {
64
98
  log: import("@trpc/server").TRPCBuiltRouter<{
65
99
  ctx: import("./trpc-init.js").RpcContext;
66
100
  meta: object;
67
- errorShape: import("@trpc/server").TRPCDefaultErrorShape;
101
+ errorShape: import("@trpc/server").TRPCDefaultErrorShape | {
102
+ message: string;
103
+ code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
104
+ data: {
105
+ code: import("@trpc/server").TRPC_ERROR_CODE_KEY;
106
+ httpStatus: number;
107
+ path?: string;
108
+ stack?: string;
109
+ reason: string;
110
+ };
111
+ };
68
112
  transformer: false;
69
113
  }, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
70
114
  emit: import("@trpc/server").TRPCMutationProcedure<{
@@ -80,6 +124,66 @@ export declare function createAppRouter(modules: {
80
124
  meta: object;
81
125
  }>;
82
126
  }>>;
127
+ caseOrchestratorTools: import("@trpc/server").TRPCBuiltRouter<{
128
+ ctx: import("./trpc-init.js").RpcContext;
129
+ meta: object;
130
+ errorShape: import("@trpc/server").TRPCDefaultErrorShape | {
131
+ message: string;
132
+ code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
133
+ data: {
134
+ code: import("@trpc/server").TRPC_ERROR_CODE_KEY;
135
+ httpStatus: number;
136
+ path?: string;
137
+ stack?: string;
138
+ reason: string;
139
+ };
140
+ };
141
+ transformer: false;
142
+ }, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
143
+ invoke: import("@trpc/server").TRPCMutationProcedure<{
144
+ input: {
145
+ tool: string;
146
+ input: unknown;
147
+ };
148
+ output: unknown;
149
+ meta: object;
150
+ }>;
151
+ }>>;
152
+ records: import("@trpc/server").TRPCBuiltRouter<{
153
+ ctx: import("./trpc-init.js").RpcContext;
154
+ meta: object;
155
+ errorShape: import("@trpc/server").TRPCDefaultErrorShape | {
156
+ message: string;
157
+ code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
158
+ data: {
159
+ code: import("@trpc/server").TRPC_ERROR_CODE_KEY;
160
+ httpStatus: number;
161
+ path?: string;
162
+ stack?: string;
163
+ reason: string;
164
+ };
165
+ };
166
+ transformer: false;
167
+ }, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
168
+ read: import("@trpc/server").TRPCMutationProcedure<{
169
+ input: {
170
+ table: string;
171
+ method: "count" | "findFirst" | "findMany" | "findUnique";
172
+ args: unknown;
173
+ };
174
+ output: import("./records.js").RecordsResult;
175
+ meta: object;
176
+ }>;
177
+ write: import("@trpc/server").TRPCMutationProcedure<{
178
+ input: {
179
+ table: string;
180
+ method: "create" | "delete" | "update" | "upsert";
181
+ args: unknown;
182
+ };
183
+ output: import("./records.js").RecordsResult;
184
+ meta: object;
185
+ }>;
186
+ }>>;
83
187
  }>>;
84
188
  export type AppRouter = ReturnType<typeof createAppRouter>;
85
189
  //# sourceMappingURL=trpc-router-factory.d.ts.map
@@ -4,6 +4,8 @@ export function createAppRouter(modules) {
4
4
  integration: modules.integration,
5
5
  platform: modules.platform,
6
6
  log: modules.log,
7
+ caseOrchestratorTools: modules.caseOrchestratorTools,
8
+ records: modules.records,
7
9
  });
8
10
  }
9
11
  //# sourceMappingURL=trpc-router-factory.js.map
@@ -0,0 +1,4 @@
1
+ import type { CaseOrchestratorRunScope, RunClaims } from './types.js';
2
+ /** The Case Orchestrator scope of a run, or null when it is not a complete Case Orchestrator run. */
3
+ export declare function asCaseOrchestratorRun(run: RunClaims): CaseOrchestratorRunScope | null;
4
+ //# sourceMappingURL=run-scope.d.ts.map
@@ -0,0 +1,9 @@
1
+ import { ORCHESTRATOR_ENTRY } from '../core/case-orchestrator/types.js';
2
+ /** The Case Orchestrator scope of a run, or null when it is not a complete Case Orchestrator run. */
3
+ export function asCaseOrchestratorRun(run) {
4
+ const scoped = run;
5
+ if (run.entry !== ORCHESTRATOR_ENTRY || !scoped.instanceId || !scoped.orchestratorTaskId)
6
+ return null;
7
+ return run;
8
+ }
9
+ //# sourceMappingURL=run-scope.js.map
@@ -1,17 +1,64 @@
1
- import type { SystemContext } from '../core/context/types.js';
1
+ import type { ORCHESTRATOR_ENTRY, CaseOrchestratorApi, CaseOrchestratorContext } from '../core/case-orchestrator/types.js';
2
+ import type { IntegrationSurfaceMeta, SystemContext } from '../core/context/types.js';
2
3
  /** Alias for {@link SystemContext} (08 ActionContext shape). */
3
4
  export type ActionContext = SystemContext;
4
- /** JSON-serializable data slice of ActionContext (no `api`). */
5
- export type ActionDataSlice = Pick<ActionContext, 'time' | 'meta' | 'config'>;
5
+ /**
6
+ * JSON-serializable data slice of ActionContext (no `api`, no `time.format` / `time.day`: added where the
7
+ * function runs). Its ids are plain strings on the wire; the function's `ctx.meta` types them.
8
+ */
9
+ export type ActionDataSlice = Pick<ActionContext, 'config'> & {
10
+ /** `ignore` absent (a platform before 68 §6.2): nothing is ignored. */
11
+ time: Omit<ActionContext['time'], 'format' | 'day' | 'at' | 'parts' | 'ignore'> & Partial<Pick<ActionContext['time'], 'ignore'>>;
12
+ meta: ActionContext['meta'];
13
+ /**
14
+ * What `ctx.api.integration` offers this run (its connections and mailboxes, with their credentials),
15
+ * listed by the platform as it calls the function: the host builds the api from it instead of asking
16
+ * the backend first. Not part of `ctx` itself.
17
+ */
18
+ surfaces?: IntegrationSurfaceMeta[];
19
+ };
20
+ /** What the call brought for the api ({@link ActionDataSlice.surfaces}): a host lists what is left out. */
21
+ export type ApiGiven = {
22
+ surfaces?: IntegrationSurfaceMeta[];
23
+ };
6
24
  /** Identity / scope for a single function invocation (ApiHost may key caches on this). */
7
25
  export type RunScope = {
8
26
  companyId: string;
9
27
  environmentId: string;
10
- sequenceId: string;
11
28
  entry: string;
29
+ /** The instance a case-bound run works on; absent on nocase runs. */
30
+ instanceId?: string;
31
+ /**
32
+ * The AI run (`AgentRun`) that called the function, with `instanceId` the case it is on (21 §6.5): what
33
+ * the function writes back through the platform is that run's. Set by the platform only.
34
+ */
35
+ agentRunId?: string;
36
+ /**
37
+ * The published company build (`ReleaseBuildBatch`) the run started on: one run uses one build (22 §5),
38
+ * so `ctx.api` reads the schema from it, not from whatever release is live by then. Absent on the serve
39
+ * overlay, which is not pinned. Set by the platform only.
40
+ */
41
+ buildId?: string;
12
42
  };
13
43
  /** Who fulfills `ctx.api` (Fake local vs Rpc remote). */
14
44
  export type ApiHost = {
15
- buildApi(run: RunScope): Promise<ActionContext['api']>;
45
+ buildApi(run: RunScope, given?: ApiGiven): Promise<ActionContext['api']>;
46
+ };
47
+ /** `ctx` of `orchestrator` before the host adds `params`. */
48
+ export type CaseOrchestratorActionContext = Omit<CaseOrchestratorContext, 'params'>;
49
+ /** Who fulfills the Case Orchestrator's `ctx.api` (Fake local vs Rpc remote). */
50
+ export type CaseOrchestratorApiHost = {
51
+ buildCaseOrchestratorApi(run: RunScope, given?: ApiGiven): Promise<CaseOrchestratorApi>;
52
+ };
53
+ /**
54
+ * Run scope of an Orchestrator call: the instance it is limited to and the `OrchestratorTask` it runs
55
+ * for (40 §2.3: no `AgentRun`), refused once that task stops running.
56
+ */
57
+ export type CaseOrchestratorRunScope = RunScope & {
58
+ entry: typeof ORCHESTRATOR_ENTRY;
59
+ instanceId: string;
60
+ orchestratorTaskId: string;
16
61
  };
62
+ /** A verified run token's scope; narrow with {@link asCaseOrchestratorRun}. */
63
+ export type RunClaims = RunScope | CaseOrchestratorRunScope;
17
64
  //# sourceMappingURL=types.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,47 +1,37 @@
1
- export type { CompanyDerivedFieldDef, CompanyFieldDef, CompanyNormalFieldDef, CompanySchema, CompanyTableDef, DataType, EffectiveFieldDef, EffectiveSchema, EffectiveTableDef, FieldOverride, SequenceCompanyTableView, SequenceSlots, NormalFieldCore, SessionTableDef, } from './core/slot/schema.js';
2
- export { ROW_ID_FIELD, idField, idFieldCore } from './core/slot/schema.js';
3
- export { integrationSurfaceKeys } from './core/context/types.js';
4
- export { idRef } from './core/slot/id-ref.js';
5
- export type { HubspotApi, HubspotAssociationListOutput, HubspotCreateContactInput, HubspotCreateContactOutput, HubspotCreateDealInput, HubspotCreateDealOutput, HubspotCreateNoteInput, HubspotCreateTaskInput, HubspotEngagementOutput, HubspotGetAssociatedContactsInput, HubspotGetAssociatedDealsInput, HubspotGetContactInput, HubspotGetContactOutput, HubspotGetCrmUrlInput, HubspotGetCrmUrlOutput, HubspotGetDealInput, HubspotGetDealOutput, HubspotGetOwnerInput, HubspotGetOwnerOutput, HubspotLogCallInput, HubspotLogEmailInput, HubspotLogSmsInput, HubspotRecord, HubspotSearchContactsInput, HubspotSearchContactsOutput, HubspotService, HubspotUpdateContactInput, HubspotUpdateContactOutput, HubspotUpdateDealInput, HubspotUpdateDealOutput, HubspotUpsertContactInput, HubspotUpsertContactOutput, } from './core/context/hubspot.js';
6
- export type { DocusignApi, DocusignCreateEnvelopeFromTemplateInput, DocusignCreateEnvelopeFromTemplateOutput, DocusignCreateRecipientViewFromTemplateInput, DocusignCreateRecipientViewFromTemplateOutput, DocusignEnvelopeIdInput, DocusignGetEnvelopeRecipientsOutput, DocusignGetEnvelopeSigningStatusOutput, DocusignGetEnvelopeStatusOutput, DocusignListRecentEnvelopesInput, DocusignListRecentEnvelopesOutput, DocusignListTemplatesOutput, DocusignRecentEnvelope, DocusignRecipient, DocusignSearchEnvelopesByEmailInput, DocusignSearchEnvelopesByEmailOutput, DocusignService, } from './core/context/docusign.js';
7
- export type { FilevineAddHashtagToProjectInput, FilevineAddHashtagToProjectOutput, FilevineApi, FilevineCollectionItemInput, FilevineCommentOutput, FilevineCreateCommentInput, FilevineCreateContactInput, FilevineCreateContactOutput, FilevineCreateNoteInput, FilevineCreateNoteWithCommentInput, FilevineCreateNoteWithCommentOutput, FilevineCreateProjectCollectionItemInput, FilevineCreateProjectCollectionItemOutput, FilevineCreateProjectInput, FilevineCreateProjectOutput, FilevineDeleteProjectCollectionItemInput, FilevineDeleteProjectCollectionItemOutput, FilevineFolder, FilevineGetAssociatedProjectsInput, FilevineGetAssociatedProjectsOutput, FilevineGetContactInput, FilevineGetContactOutput, FilevineGetCrmUrlInput, FilevineGetCrmUrlOutput, FilevineGetProjectCollectionItemInput, FilevineGetProjectCollectionItemOutput, FilevineGetProjectCollectionItemsInput, FilevineGetProjectCollectionItemsOutput, FilevineGetProjectFoldersInput, FilevineGetProjectFoldersOutput, FilevineGetProjectInput, FilevineGetProjectOutput, FilevineLogCallInput, FilevineLogEmailInput, FilevineLogSmsInput, FilevineNoteOutput, FilevineProperties, FilevineRecord, FilevineSearchContactsInput, FilevineSearchContactsOutput, FilevineService, FilevineUpdateContactInput, FilevineUpdateContactOutput, FilevineUpdateProjectCollectionItemInput, FilevineUpdateProjectCollectionItemOutput, FilevineUpdateProjectInput, FilevineUpdateProjectOutput, FilevineUploadDocumentInput, FilevineUploadDocumentOutput, } from './core/context/filevine.js';
8
- export type { CaseContext, ContactApi, BoundIntegrationMeta, EnvApi, EnvService, FieldState, HttpApi, IntegrationAccountFields, IntegrationApi, IntegrationStub, IntegrationSurfaceKey, IntegrationTarget, TwilioApi, TwilioCreateCallInput, TwilioCreateCallOutput, TwilioIncomingNumber, TwilioListIncomingNumbersOutput, TwilioSendSmsInput, TwilioSendSmsOutput, TwilioService, Logger, MakeCtxOverrides, Slots, SystemContext, FieldWrites, RowWrite, StructuredWrites, Writes, } from './core/context/types.js';
9
- export { CONTACT_PAGE_LIMIT_MAX, contactListInput, contactListOutput, contactMockService, contactSummary, contactSurface, type ContactListParams, type ContactListResult, type ContactSummary, } from './core/context/contact.js';
10
- export { dbDelInput, dbDelOutput, dbGetInput, dbGetOutput, dbMockService, dbSetInput, dbSetOutput, dbSurface, KV_KEY_MAX, KV_TTL_SECONDS_MAX, KV_VALUE_MAX, type DbApi, type DbDelInput, type DbDelOutput, type DbGetInput, type DbGetOutput, type DbSetInput, type DbSetOutput, } from './core/context/db.js';
11
- export { bindEnvService, envMockService, readEnvGet } from './core/context/env.js';
12
- export type { AnyPlatformSurface, PlatformApiShape, PlatformImpl, PlatformSurface } from './core/context/platform.js';
13
- export { platformSurfaces, type PlatformApis, type PlatformSurfaceKey } from './core/context/platform-registry.js';
14
- export { defaultHttpApi } from './core/context/http.js';
15
- export { hubspotAssociationListOutput, hubspotCreateContactInput, hubspotCreateContactOutput, hubspotCreateDealInput, hubspotCreateDealOutput, hubspotCreateNoteInput, hubspotCreateTaskInput, hubspotEngagementOutput, hubspotGetAssociatedContactsInput, hubspotGetAssociatedDealsInput, hubspotGetContactInput, hubspotGetContactOutput, hubspotGetCrmUrlInput, hubspotGetCrmUrlOutput, hubspotGetDealInput, hubspotGetDealOutput, hubspotGetOwnerInput, hubspotGetOwnerOutput, hubspotLogCallInput, hubspotLogEmailInput, hubspotLogSmsInput, hubspotMockService, hubspotSearchContactsInput, hubspotSearchContactsOutput, hubspotUpdateContactInput, hubspotUpdateContactOutput, hubspotUpdateDealInput, hubspotUpdateDealOutput, hubspotUpsertContactInput, hubspotUpsertContactOutput, } from './core/context/hubspot.js';
16
- export { docusignCreateEnvelopeFromTemplateInput, docusignCreateEnvelopeFromTemplateOutput, docusignCreateRecipientViewFromTemplateInput, docusignCreateRecipientViewFromTemplateOutput, docusignEnvelopeIdInput, docusignGetEnvelopeRecipientsOutput, docusignGetEnvelopeSigningStatusOutput, docusignGetEnvelopeStatusOutput, docusignListRecentEnvelopesInput, docusignListRecentEnvelopesOutput, docusignListTemplatesOutput, docusignMockService, docusignSearchEnvelopesByEmailInput, docusignSearchEnvelopesByEmailOutput, } from './core/context/docusign.js';
17
- export { filevineAddHashtagToProjectInput, filevineAddHashtagToProjectOutput, filevineCollectionItemInput, filevineCommentOutput, filevineCreateCommentInput, filevineCreateContactInput, filevineCreateContactOutput, filevineCreateNoteInput, filevineCreateNoteWithCommentInput, filevineCreateNoteWithCommentOutput, filevineCreateProjectCollectionItemInput, filevineCreateProjectCollectionItemOutput, filevineCreateProjectInput, filevineCreateProjectOutput, filevineDeleteProjectCollectionItemInput, filevineDeleteProjectCollectionItemOutput, filevineGetAssociatedProjectsInput, filevineGetAssociatedProjectsOutput, filevineGetContactInput, filevineGetContactOutput, filevineGetCrmUrlInput, filevineGetCrmUrlOutput, filevineGetProjectCollectionItemInput, filevineGetProjectCollectionItemOutput, filevineGetProjectCollectionItemsInput, filevineGetProjectCollectionItemsOutput, filevineGetProjectFoldersInput, filevineGetProjectFoldersOutput, filevineGetProjectInput, filevineGetProjectOutput, filevineLogCallInput, filevineLogEmailInput, filevineLogSmsInput, filevineMockService, filevineNoteOutput, filevineSearchContactsInput, filevineSearchContactsOutput, filevineUpdateContactInput, filevineUpdateContactOutput, filevineUpdateProjectCollectionItemInput, filevineUpdateProjectCollectionItemOutput, filevineUpdateProjectInput, filevineUpdateProjectOutput, filevineUploadDocumentInput, filevineUploadDocumentOutput, } from './core/context/filevine.js';
18
- export { twilioCreateCallInput, twilioCreateCallOutput, twilioIncomingNumber, twilioListIncomingNumbersOutput, twilioMockService, twilioSendSmsInput, twilioSendSmsOutput, } from './core/context/twilio.js';
19
- export type { ApplyWritesOptions, ApplyWritesResult, CompiledSlotSchema, ExtractedField, FieldHistoryEntry, FieldValue, HistoryAppend, MultiRowProjection, MultiRowRecord, MultiRowTableData, RecomputeResult, RuntimeDerivedFieldDef, RuntimeFieldDef, RuntimeNormalFieldDef, RuntimeSlotsSnapshot, RuntimeTableDef, SingleRowProjection, SingleRowTableData, SlotCurrent, SlotFillingOutput, SlotFillingValidateResult, TableData, UpdatedBy, ValidationIssue, ValidationResult, WriteSource, } from './core/slot/types.js';
20
- export type { FuncRef } from './core/functions/func-ref.js';
21
- export { resolveFuncName } from './core/functions/func-ref.js';
22
- export type { RuntimePackageSource, SequenceBuild } from './builder/types.js';
23
- export type { CaseContextViewRegistryEntry, ComputeFn, CustomFn, DefinedFunc, FuncMap, FuncOptions, FuncRegistration, FunctionCall, FunctionCtx, FunctionRegistry, FunctionRegistryEntry, GetFirstMessageFunction, GetFirstMessageParams, SystemFuncMap, WebHookFunction, WebHookFunctionParams, } from './core/functions/types.js';
24
- export { toFuncRegistrations } from './core/functions/types.js';
25
- export { toCaseContextViewRegistry, toFunctionRegistry } from './builder/compile/registry.js';
26
- export { compileFunctionCode } from './builder/compile/function-code.js';
27
- export { compileAll, compileSequence, runtimePackageSource, runtimePackageVersion, snapshotCompanySchema, type CompileSequenceOptions, type CompileSequenceResult, } from './builder/compile/compile-sequence.js';
28
- export { compileSequenceAgendas, fatalAgendaIssues } from './builder/compile/compile-agenda.js';
29
- export { loadSequenceCaseContextView, loadSequenceFunctions } from './builder/load.js';
30
- export { findTsModule } from './builder/paths.js';
31
- export type { OverlayClientMessage, OverlayExecuteMessage, OverlayExecuteResultMessage, OverlayAuthErrorMessage, OverlayAuthMessage, OverlayAuthOkMessage, OverlayMessage, OverlayPushMessage, OverlayReplacedMessage, OverlayServerMessage, } from './dev-overlay/protocol.js';
32
- export { encodeOverlayMessage, OVERLAY_REPLACED_CLOSE_CODE, parseOverlayMessage } from './dev-overlay/protocol.js';
33
- export { buildActionContext, bindLogMeta, createFakeApiHost, defaultPlatformApis, emptyIntegration, createRpcApiHost, LOG_TAGS_HEADER, REQUEST_ID_HEADER, RUNTIME_VERSION_HEADER, encodeLogTagsHeader, formatRuntimeVersion, readLogTagsHeader, readRequestIdHeader, readRuntimeVersionHeader, makeCtx, makeCtxAsync, noopLog, type ActionContext, type ActionDataSlice, type ApiHost, type FakeApiHostOptions, type RunScope, } from './fn-context/index.js';
34
- export { createAppRouter, createIntegrationRouter, createListBindingsProcedure, createLogRouter, createPlatformRouter, isRpcCodedError, parseScriptInput, ScriptInputError, type AppRouter, type RpcCodedError, type RpcErrorCode, type IntegrationInvokeHandler, type LogEmitHandler, type PlatformInvokeHandler, type RpcContext, } from './fn-context/rpc/index.js';
35
- export * from './compute-host/index.js';
36
- export { defineBoolComputeFunc, defineComputeFunc } from './core/functions/define/compute.js';
37
- export { defineCaseContext, resolveCaseContextViewFn, type CaseContextOf, type CaseContextViewFn, type DefinedCaseContextView, } from './core/functions/define/case-context.js';
38
- export { defineCustomFunc } from './core/functions/define/custom.js';
39
- export { defineSystemFunc } from './core/functions/define/system.js';
40
- export { mergeEffectiveSchema } from './builder/merge.js';
41
- export { emitCaseContextSource, emitSlotsSource } from './builder/codegen/emit.js';
42
- export { affectedDerivedFields, applyFieldPatch, applyFieldPatchAndRecompute, applySlotFilling, applySlotFillingAndRecompute, applyWrites, applyWritesAndRecompute, buildDependencyGraph, buildFieldCatalog, buildSlotFillingJsonSchema, cloneSnapshot, commitFieldWrite, compiledTableEntries, compileSlotSchema, emptyFieldValue, emptyMultiRow, emptySlotRow, fieldChanged, formatFieldPath, getCompiledTable, getFieldState, getFieldValue, getLastThreeValues, getRowField, getSingleField, getSnapshotTable, isFieldValue, isReservedTableName, isResolved, isRowIdField, mintRowId, SNAPSHOT_CURRENT_KEY, isSnapshotSingleRow, isValidDataTypeValue, listConversationFields, makeFieldValue, markAskedUnknown, isRowWrite, isStructuredWrites, normalizeWrites, parseFieldPath, recomputeDerived, requireFieldPath, rowValueEntries, slotFieldEntries, slotFieldNames, snapshotFrom, toEffectiveSchema, toHistoryEntry, validateBareValue, validateExtractedField, validateFieldRefs, validateSlotFillingOutput, } from './core/slot/index.js';
43
- export type { ApplySlotFillingOptions, DependencyGraphResult, FieldPatchInput, FieldPath, ParsedFieldPath, RecomputeOptions, SfSchemaOptions, SlotRow, SnapshotSeed, ValidateSlotFillingOptions, } from './core/slot/index.js';
44
- export type { ActionBlock, ActionNode, AgendaBlock, AgendaConfig, AgendaHeader, AgendaTree, ApplyWhen, AuthoringNode, AuthoringWhen, BranchNode, Channel, CompiledActionBlock, CompiledAgenda, CompiledAgendaBlock, CompiledTopicBlock, CompiledIvrBlock, CompiledTransferBlock, CompiledWhen, Condition, ConditionEval, FirstMessage, FinishWhen, FinishWhenEval, FlatActionItem, FlatAgendaItem, FlatIvrItem, FlatNodePlacement, FlatTopicItem, FlatTransferItem, DtmfResult, IvrAttemptResult, IvrBlock, IvrDigit, IvrFallbackAction, IvrNode, FlattenOptions, FlattenResult, Interrupt, SpokenLanguage, SequenceAgendas, JsonRulesCondition, NodePlacement, OnNoProgress, OtherwiseSentinel, Placement, SectionNode, SectionPlacement, SimulateResult, SimulatedItem, SimulatedItemStatus, SwitchOnNode, TopicBlock, TopicNode, TransferArguments, TransferBlock, TransferCallerIdShown, TransferConfirmKey, TransferConfirmMethod, TransferDial, TransferFallbackAction, TransferInterruptAction, TransferMode, TransferNode, TransferSay, ValidateAgendaOptions, WalkDecision, WalkHitReason, WalkOptions, WalkResult, WalkSkip, WalkStats, WalkSkipReason, When, WhenEval, AdvanceResult, StageDriveHooks, StageDriveResult, StageDriveState, } from './core/stage/index.js';
45
- export { DEFAULT_MAX_ACTIONS_PER_TURN, CASE_LAST_TRANSFER_AT, CASE_LAST_TRANSFER_RESULT, CASE_TRANSFER_ATTEMPT_COUNT, E164_NUMBER, LAST_TRANSFER_RESULT_FIELD, CONTACT_LANGUAGE_FIELD, getContactLang, inboundIvrCollect, ivrAttempted, ivrOf, ivrResultField, languageFieldOf, RESERVED_INTERRUPT_TOOL_NAMES, SIP_URI, action, advanceAgenda, agenda, andCompiledWhen, branch, collectJsonRulesFacts, collectTransferBlocks, collectTransferInterruptHeaders, compileAuthoringWhen, compileFinishWhen, compileWhen, driveAgenda, evaluateFinishWhen, evaluateJsonRules, evaluateWhen, extractBlocksFromTree, extractTemplateFields, finishWhenFields, flattenAgendaConfig, flattenAgendaPlacements, flattenAgendaTree, headerHasTransferInterrupt, ivr, interpolateFromSnapshot, interpolateTemplate, isTransferDestinationLiteral, isAgendaTree, isSequenceAgendas, isOtherwise, isSpokenLanguage, jsonRules, looksLikeJsonRules, normalizeJsonRules, normalizeSequenceAgendas, notAnyWhen, otherwise, parseJsonRules, registerIvrSessionFields, collectIvrBlocks, registerTransferSessionFields, resolveTransferArguments, resolveTransferDestinations, resolveTransferSay, section, simulateAgenda, switchOn, topic, transfer, transferArgumentsJson, transferFieldKey, transferResultField, transferWrites, validateTransferDestinations, treeToPlacements, unresolvedFinishWhenFields, validateCompiledAgenda, validateInterrupts, walkAgenda, watchdogHint, whenFields, } from './core/stage/index.js';
46
- export * from './voice-service/index.js';
1
+ /**
2
+ * The company API: everything company code may import from `@superpanel-sdk/runtime`, and nothing else
3
+ * (09-runtime-compat §6). Company code runs in three places: the compile's Node, the Worker, and the
4
+ * page's QuickJS sandbox. So what is here behaves the same in all three: it imports no package and no
5
+ * Node module, and no module it reaches does work at load. The compile bundles it into each code string
6
+ * as it is; there is no stand-in.
7
+ *
8
+ * Named exports only, from the module that defines each: an `export *` lets whatever a module adds
9
+ * reach company code. `company-api.test.ts` holds the list and checks the entry stays pure. The
10
+ * platform imports `./platform` (`platform.ts`), which this package resolves only under the
11
+ * `superpanel-platform` condition.
12
+ */
13
+ export { defineSequence, defineVariables, json, type JsonVariableType, type SequenceDefinition, type VariableDecl, type VariableDecls, type VariablesOf, } from './core/sequence/define.js';
14
+ export { defineSchedules, type Schedules } from './core/functions/schedules.js';
15
+ export type { Ctx } from './core/functions/types.js';
16
+ export type { EventHandlers, WebhookHandler } from './core/functions/events.js';
17
+ export type { CodeErrorEvent, OnError } from './core/functions/errors.js';
18
+ export { PlatformUnavailableError } from './core/functions/errors.js';
19
+ export { choose, definePage, lastActionRun, tried, type PageChannel, type PageFaqEntry, type PageRuns, } from './core/page/define.js';
20
+ /** A fixed line said to the customer, per language (66 §2). */
21
+ export type { Spoken, SpokenTag } from './core/conversation/index.js';
22
+ export { announce, backgroundTransfer, block, button, cancelFollowUp, coldTransfer, convertTime, createRow, data, deleteRow, doNow, end, field, functionHandles, actionHandles, keypad, list, page, pressKeypad, refField, run, scheduleFollowUp, text, toolbox, voicemail, warmTransfer, type Action, type BlockNode, type ButtonNode, type DataNode, type DoNode, type FieldNode, type FunctionHandle, type ListNode, type PageActionHandle, type PageContent, type PageItem, type PageNode, type TextNode, type Tool, type ToolboxNode, } from './core/page/fns.js';
23
+ export type { Email, Id, IsoDate, IsoDateTime, Phone, TimeOfDay, RowOf, TypedActionContext, TypedDb, TypedPageContext, TypedPageModule, TypedPageFns, FunctionHandles, ActionHandles, PageResult, TypedReadDb, } from './core/page/typed.js';
24
+ export { render } from './core/case-orchestrator/render.js';
25
+ export type { CaseActivity, CaseOrchestrator, CaseOrchestratorArgs, ContactActionView, RunTrigger, ScheduledActionView, } from './core/case-orchestrator/types.js';
26
+ export type { CompanyResolve, Resolve } from './core/party/types.js';
27
+ export { contactScheduleHours, everyDay, nextContactTime, withinContactHours, type ContactHours, type ContactHoursIgnore, type ContactHoursRange, type ContactHoursWeekday, } from './core/case-orchestrator/contact-hours.js';
28
+ export { randomTimeBetween } from './core/case-orchestrator/time.js';
29
+ export { contactTimezone } from './core/slot/contact-timezone.js';
30
+ export type { OfficeHours } from './core/office-hours/index.js';
31
+ export { PLATFORM_CONTACT_FIELDS, PLATFORM_SESSION_FIELDS } from './core/slot/platform-fields.js';
32
+ export { lookupRef, parentRef } from './core/slot/id-ref.js';
33
+ export type { CompanySchema, ContactSchedule, SessionSchema } from './core/slot/schema.js';
34
+ export type { CellBinding, RowRef } from './core/slot/binding.js';
35
+ export type { FieldValue } from './core/slot/types.js';
36
+ export type { EnvApi } from './core/context/env.js';
47
37
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,34 +1,31 @@
1
- export { ROW_ID_FIELD, idField, idFieldCore } from './core/slot/schema.js';
2
- export { integrationSurfaceKeys } from './core/context/types.js';
3
- export { idRef } from './core/slot/id-ref.js';
4
- export { CONTACT_PAGE_LIMIT_MAX, contactListInput, contactListOutput, contactMockService, contactSummary, contactSurface, } from './core/context/contact.js';
5
- export { dbDelInput, dbDelOutput, dbGetInput, dbGetOutput, dbMockService, dbSetInput, dbSetOutput, dbSurface, KV_KEY_MAX, KV_TTL_SECONDS_MAX, KV_VALUE_MAX, } from './core/context/db.js';
6
- export { bindEnvService, envMockService, readEnvGet } from './core/context/env.js';
7
- export { platformSurfaces } from './core/context/platform-registry.js';
8
- export { defaultHttpApi } from './core/context/http.js';
9
- export { hubspotAssociationListOutput, hubspotCreateContactInput, hubspotCreateContactOutput, hubspotCreateDealInput, hubspotCreateDealOutput, hubspotCreateNoteInput, hubspotCreateTaskInput, hubspotEngagementOutput, hubspotGetAssociatedContactsInput, hubspotGetAssociatedDealsInput, hubspotGetContactInput, hubspotGetContactOutput, hubspotGetCrmUrlInput, hubspotGetCrmUrlOutput, hubspotGetDealInput, hubspotGetDealOutput, hubspotGetOwnerInput, hubspotGetOwnerOutput, hubspotLogCallInput, hubspotLogEmailInput, hubspotLogSmsInput, hubspotMockService, hubspotSearchContactsInput, hubspotSearchContactsOutput, hubspotUpdateContactInput, hubspotUpdateContactOutput, hubspotUpdateDealInput, hubspotUpdateDealOutput, hubspotUpsertContactInput, hubspotUpsertContactOutput, } from './core/context/hubspot.js';
10
- export { docusignCreateEnvelopeFromTemplateInput, docusignCreateEnvelopeFromTemplateOutput, docusignCreateRecipientViewFromTemplateInput, docusignCreateRecipientViewFromTemplateOutput, docusignEnvelopeIdInput, docusignGetEnvelopeRecipientsOutput, docusignGetEnvelopeSigningStatusOutput, docusignGetEnvelopeStatusOutput, docusignListRecentEnvelopesInput, docusignListRecentEnvelopesOutput, docusignListTemplatesOutput, docusignMockService, docusignSearchEnvelopesByEmailInput, docusignSearchEnvelopesByEmailOutput, } from './core/context/docusign.js';
11
- export { filevineAddHashtagToProjectInput, filevineAddHashtagToProjectOutput, filevineCollectionItemInput, filevineCommentOutput, filevineCreateCommentInput, filevineCreateContactInput, filevineCreateContactOutput, filevineCreateNoteInput, filevineCreateNoteWithCommentInput, filevineCreateNoteWithCommentOutput, filevineCreateProjectCollectionItemInput, filevineCreateProjectCollectionItemOutput, filevineCreateProjectInput, filevineCreateProjectOutput, filevineDeleteProjectCollectionItemInput, filevineDeleteProjectCollectionItemOutput, filevineGetAssociatedProjectsInput, filevineGetAssociatedProjectsOutput, filevineGetContactInput, filevineGetContactOutput, filevineGetCrmUrlInput, filevineGetCrmUrlOutput, filevineGetProjectCollectionItemInput, filevineGetProjectCollectionItemOutput, filevineGetProjectCollectionItemsInput, filevineGetProjectCollectionItemsOutput, filevineGetProjectFoldersInput, filevineGetProjectFoldersOutput, filevineGetProjectInput, filevineGetProjectOutput, filevineLogCallInput, filevineLogEmailInput, filevineLogSmsInput, filevineMockService, filevineNoteOutput, filevineSearchContactsInput, filevineSearchContactsOutput, filevineUpdateContactInput, filevineUpdateContactOutput, filevineUpdateProjectCollectionItemInput, filevineUpdateProjectCollectionItemOutput, filevineUpdateProjectInput, filevineUpdateProjectOutput, filevineUploadDocumentInput, filevineUploadDocumentOutput, } from './core/context/filevine.js';
12
- export { twilioCreateCallInput, twilioCreateCallOutput, twilioIncomingNumber, twilioListIncomingNumbersOutput, twilioMockService, twilioSendSmsInput, twilioSendSmsOutput, } from './core/context/twilio.js';
13
- export { resolveFuncName } from './core/functions/func-ref.js';
14
- export { toFuncRegistrations } from './core/functions/types.js';
15
- export { toCaseContextViewRegistry, toFunctionRegistry } from './builder/compile/registry.js';
16
- export { compileFunctionCode } from './builder/compile/function-code.js';
17
- export { compileAll, compileSequence, runtimePackageSource, runtimePackageVersion, snapshotCompanySchema, } from './builder/compile/compile-sequence.js';
18
- export { compileSequenceAgendas, fatalAgendaIssues } from './builder/compile/compile-agenda.js';
19
- export { loadSequenceCaseContextView, loadSequenceFunctions } from './builder/load.js';
20
- export { findTsModule } from './builder/paths.js';
21
- export { encodeOverlayMessage, OVERLAY_REPLACED_CLOSE_CODE, parseOverlayMessage } from './dev-overlay/protocol.js';
22
- export { buildActionContext, bindLogMeta, createFakeApiHost, defaultPlatformApis, emptyIntegration, createRpcApiHost, LOG_TAGS_HEADER, REQUEST_ID_HEADER, RUNTIME_VERSION_HEADER, encodeLogTagsHeader, formatRuntimeVersion, readLogTagsHeader, readRequestIdHeader, readRuntimeVersionHeader, makeCtx, makeCtxAsync, noopLog, } from './fn-context/index.js';
23
- export { createAppRouter, createIntegrationRouter, createListBindingsProcedure, createLogRouter, createPlatformRouter, isRpcCodedError, parseScriptInput, ScriptInputError, } from './fn-context/rpc/index.js';
24
- export * from './compute-host/index.js';
25
- export { defineBoolComputeFunc, defineComputeFunc } from './core/functions/define/compute.js';
26
- export { defineCaseContext, resolveCaseContextViewFn, } from './core/functions/define/case-context.js';
27
- export { defineCustomFunc } from './core/functions/define/custom.js';
28
- export { defineSystemFunc } from './core/functions/define/system.js';
29
- export { mergeEffectiveSchema } from './builder/merge.js';
30
- export { emitCaseContextSource, emitSlotsSource } from './builder/codegen/emit.js';
31
- export { affectedDerivedFields, applyFieldPatch, applyFieldPatchAndRecompute, applySlotFilling, applySlotFillingAndRecompute, applyWrites, applyWritesAndRecompute, buildDependencyGraph, buildFieldCatalog, buildSlotFillingJsonSchema, cloneSnapshot, commitFieldWrite, compiledTableEntries, compileSlotSchema, emptyFieldValue, emptyMultiRow, emptySlotRow, fieldChanged, formatFieldPath, getCompiledTable, getFieldState, getFieldValue, getLastThreeValues, getRowField, getSingleField, getSnapshotTable, isFieldValue, isReservedTableName, isResolved, isRowIdField, mintRowId, SNAPSHOT_CURRENT_KEY, isSnapshotSingleRow, isValidDataTypeValue, listConversationFields, makeFieldValue, markAskedUnknown, isRowWrite, isStructuredWrites, normalizeWrites, parseFieldPath, recomputeDerived, requireFieldPath, rowValueEntries, slotFieldEntries, slotFieldNames, snapshotFrom, toEffectiveSchema, toHistoryEntry, validateBareValue, validateExtractedField, validateFieldRefs, validateSlotFillingOutput, } from './core/slot/index.js';
32
- export { DEFAULT_MAX_ACTIONS_PER_TURN, CASE_LAST_TRANSFER_AT, CASE_LAST_TRANSFER_RESULT, CASE_TRANSFER_ATTEMPT_COUNT, E164_NUMBER, LAST_TRANSFER_RESULT_FIELD, CONTACT_LANGUAGE_FIELD, getContactLang, inboundIvrCollect, ivrAttempted, ivrOf, ivrResultField, languageFieldOf, RESERVED_INTERRUPT_TOOL_NAMES, SIP_URI, action, advanceAgenda, agenda, andCompiledWhen, branch, collectJsonRulesFacts, collectTransferBlocks, collectTransferInterruptHeaders, compileAuthoringWhen, compileFinishWhen, compileWhen, driveAgenda, evaluateFinishWhen, evaluateJsonRules, evaluateWhen, extractBlocksFromTree, extractTemplateFields, finishWhenFields, flattenAgendaConfig, flattenAgendaPlacements, flattenAgendaTree, headerHasTransferInterrupt, ivr, interpolateFromSnapshot, interpolateTemplate, isTransferDestinationLiteral, isAgendaTree, isSequenceAgendas, isOtherwise, isSpokenLanguage, jsonRules, looksLikeJsonRules, normalizeJsonRules, normalizeSequenceAgendas, notAnyWhen, otherwise, parseJsonRules, registerIvrSessionFields, collectIvrBlocks, registerTransferSessionFields, resolveTransferArguments, resolveTransferDestinations, resolveTransferSay, section, simulateAgenda, switchOn, topic, transfer, transferArgumentsJson, transferFieldKey, transferResultField, transferWrites, validateTransferDestinations, treeToPlacements, unresolvedFinishWhenFields, validateCompiledAgenda, validateInterrupts, walkAgenda, watchdogHint, whenFields, } from './core/stage/index.js';
33
- export * from './voice-service/index.js';
1
+ /**
2
+ * The company API: everything company code may import from `@superpanel-sdk/runtime`, and nothing else
3
+ * (09-runtime-compat §6). Company code runs in three places: the compile's Node, the Worker, and the
4
+ * page's QuickJS sandbox. So what is here behaves the same in all three: it imports no package and no
5
+ * Node module, and no module it reaches does work at load. The compile bundles it into each code string
6
+ * as it is; there is no stand-in.
7
+ *
8
+ * Named exports only, from the module that defines each: an `export *` lets whatever a module adds
9
+ * reach company code. `company-api.test.ts` holds the list and checks the entry stays pure. The
10
+ * platform imports `./platform` (`platform.ts`), which this package resolves only under the
11
+ * `superpanel-platform` condition.
12
+ */
13
+ // Sequence declarations: `index.ts`, `variables.ts`.
14
+ export { defineSequence, defineVariables, json, } from './core/sequence/define.js';
15
+ // Functions, events, the webhook and schedules (`__gen` binds them to the company's tables).
16
+ export { defineSchedules } from './core/functions/schedules.js';
17
+ export { PlatformUnavailableError } from './core/functions/errors.js';
18
+ // The page (the sequence's `__gen` binds them to its tables).
19
+ export { choose, definePage, lastActionRun, tried, } from './core/page/define.js';
20
+ // The page in functions (76): nodes, actions, page actions, tools (`__gen` binds the table-bound ones).
21
+ export { announce, backgroundTransfer, block, button, cancelFollowUp, coldTransfer, convertTime, createRow, data, deleteRow, doNow, end, field, functionHandles, actionHandles, keypad, list, page, pressKeypad, refField, run, scheduleFollowUp, text, toolbox, voicemail, warmTransfer, } from './core/page/fns.js';
22
+ // The Orchestrator.
23
+ export { render } from './core/case-orchestrator/render.js';
24
+ // When a contact may be reached, and in which time zone.
25
+ export { contactScheduleHours, everyDay, nextContactTime, withinContactHours, } from './core/case-orchestrator/contact-hours.js';
26
+ export { randomTimeBetween } from './core/case-orchestrator/time.js';
27
+ export { contactTimezone } from './core/slot/contact-timezone.js';
28
+ // The company schema: `schema/`.
29
+ export { PLATFORM_CONTACT_FIELDS, PLATFORM_SESSION_FIELDS } from './core/slot/platform-fields.js';
30
+ export { lookupRef, parentRef } from './core/slot/id-ref.js';
34
31
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,11 @@
1
+ type LogLevel = 'INFO' | 'WARN' | 'ERROR';
2
+ /** The least level the runtime's own lines are written at: `exec` keeps the RPC's routine lines out of a snippet's output. */
3
+ export declare function setRuntimeLogLevel(level: LogLevel): void;
4
+ export declare function getLogger(tags?: readonly string[]): {
5
+ log(...args: unknown[]): void;
6
+ info(...args: unknown[]): void;
7
+ warn(...args: unknown[]): void;
8
+ error(...args: unknown[]): void;
9
+ };
10
+ export {};
11
+ //# sourceMappingURL=logger.d.ts.map
package/dist/logger.js ADDED
@@ -0,0 +1,49 @@
1
+ function formatArgument(value) {
2
+ if (value instanceof Error)
3
+ return value.stack ?? value.message;
4
+ if (typeof value === 'string')
5
+ return value;
6
+ if (typeof value !== 'object' || value === null)
7
+ return String(value);
8
+ try {
9
+ return JSON.stringify(value);
10
+ }
11
+ catch {
12
+ return '[unserializable]';
13
+ }
14
+ }
15
+ const RANK = { INFO: 0, WARN: 1, ERROR: 2 };
16
+ let least = 'INFO';
17
+ /** The least level the runtime's own lines are written at: `exec` keeps the RPC's routine lines out of a snippet's output. */
18
+ export function setRuntimeLogLevel(level) {
19
+ least = level;
20
+ }
21
+ function write(level, tags, args) {
22
+ if (RANK[level] < RANK[least])
23
+ return;
24
+ const label = tags.length > 0 ? `[${tags.join(',')}] ` : '';
25
+ const line = `${new Date().toISOString()} ${level.padEnd(5)} ${label}${args.map(formatArgument).join(' ')}`;
26
+ if (level === 'ERROR')
27
+ console.error(line);
28
+ else if (level === 'WARN')
29
+ console.warn(line);
30
+ else
31
+ console.info(line);
32
+ }
33
+ export function getLogger(tags = []) {
34
+ return {
35
+ log(...args) {
36
+ write('INFO', tags, args);
37
+ },
38
+ info(...args) {
39
+ write('INFO', tags, args);
40
+ },
41
+ warn(...args) {
42
+ write('WARN', tags, args);
43
+ },
44
+ error(...args) {
45
+ write('ERROR', tags, args);
46
+ },
47
+ };
48
+ }
49
+ //# sourceMappingURL=logger.js.map