@superpanel-sdk/runtime 0.2.2 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (274) hide show
  1. package/README.md +28 -8
  2. package/dist/builder/codegen/emit.d.ts +29 -11
  3. package/dist/builder/codegen/emit.js +328 -61
  4. package/dist/builder/codegen/generate.d.ts +21 -0
  5. package/dist/builder/codegen/generate.js +152 -20
  6. package/dist/builder/company-import-graph.d.ts +2 -0
  7. package/dist/builder/company-import-graph.js +40 -8
  8. package/dist/builder/company-imports.d.ts +24 -0
  9. package/dist/builder/company-imports.js +114 -0
  10. package/dist/builder/compile/compile-sequence.d.ts +59 -8
  11. package/dist/builder/compile/compile-sequence.js +279 -77
  12. package/dist/builder/compile/function-code.d.ts +12 -2
  13. package/dist/builder/compile/function-code.js +87 -39
  14. package/dist/builder/compile/registry.d.ts +7 -3
  15. package/dist/builder/compile/registry.js +24 -23
  16. package/dist/builder/load.d.ts +70 -10
  17. package/dist/builder/load.js +250 -61
  18. package/dist/builder/paths.d.ts +3 -0
  19. package/dist/builder/paths.js +16 -0
  20. package/dist/builder/schedules.d.ts +23 -0
  21. package/dist/builder/schedules.js +102 -0
  22. package/dist/builder/slot-schema-validation.d.ts +4 -0
  23. package/dist/builder/slot-schema-validation.js +10 -0
  24. package/dist/builder/typecheck.d.ts +8 -0
  25. package/dist/builder/typecheck.js +105 -0
  26. package/dist/builder/types.d.ts +91 -19
  27. package/dist/builder/types.js +2 -1
  28. package/dist/cli/auth/auth.d.ts +37 -0
  29. package/dist/cli/auth/auth.js +211 -0
  30. package/dist/cli/auth/backend-url.d.ts +5 -0
  31. package/dist/cli/auth/backend-url.js +25 -0
  32. package/dist/cli/auth/clipboard.d.ts +9 -0
  33. package/dist/cli/auth/clipboard.js +38 -0
  34. package/dist/cli/auth/http.d.ts +20 -0
  35. package/dist/cli/auth/http.js +27 -0
  36. package/dist/cli/auth/index.d.ts +10 -0
  37. package/dist/cli/auth/index.js +27 -0
  38. package/dist/cli/auth/progress.d.ts +12 -0
  39. package/dist/cli/auth/progress.js +15 -0
  40. package/dist/cli/auth/serve-login.d.ts +8 -0
  41. package/dist/cli/auth/serve-login.js +24 -0
  42. package/dist/cli/compile/index.js +3 -0
  43. package/dist/cli/config.d.ts +10 -0
  44. package/dist/cli/config.js +52 -0
  45. package/dist/cli/index.js +28 -8
  46. package/dist/cli/serve/index.d.ts +73 -3
  47. package/dist/cli/serve/index.js +410 -113
  48. package/dist/cli/type-gen/index.js +9 -8
  49. package/dist/compiler.d.ts +7 -0
  50. package/dist/compiler.js +7 -0
  51. package/dist/compute-host/compute-host.d.ts +15 -23
  52. package/dist/compute-host/compute-host.js +25 -28
  53. package/dist/compute-host/index.d.ts +2 -2
  54. package/dist/compute-host/index.js +1 -1
  55. package/dist/compute-host/source-compute-host.d.ts +11 -9
  56. package/dist/compute-host/source-compute-host.js +50 -31
  57. package/dist/core/case-orchestrator/contact-hours.d.ts +50 -0
  58. package/dist/core/case-orchestrator/contact-hours.js +108 -0
  59. package/dist/core/case-orchestrator/follow-ups.d.ts +31 -0
  60. package/dist/core/case-orchestrator/follow-ups.js +103 -0
  61. package/dist/core/case-orchestrator/index.d.ts +6 -0
  62. package/dist/core/case-orchestrator/index.js +6 -0
  63. package/dist/core/case-orchestrator/render.d.ts +75 -0
  64. package/dist/core/case-orchestrator/render.js +239 -0
  65. package/dist/core/case-orchestrator/time.d.ts +11 -0
  66. package/dist/core/case-orchestrator/time.js +29 -0
  67. package/dist/core/case-orchestrator/tools.d.ts +29 -0
  68. package/dist/core/case-orchestrator/tools.js +31 -0
  69. package/dist/core/case-orchestrator/types.d.ts +753 -0
  70. package/dist/core/case-orchestrator/types.js +46 -0
  71. package/dist/core/case-orchestrator/validate.d.ts +11 -0
  72. package/dist/core/case-orchestrator/validate.js +63 -0
  73. package/dist/core/context/call.d.ts +291 -0
  74. package/dist/core/context/call.js +94 -0
  75. package/dist/core/context/channels.d.ts +60 -0
  76. package/dist/core/context/channels.js +35 -0
  77. package/dist/core/context/contact.d.ts +96 -6
  78. package/dist/core/context/contact.js +48 -2
  79. package/dist/core/context/email-message.d.ts +159 -0
  80. package/dist/core/context/email-message.js +59 -0
  81. package/dist/core/context/email.d.ts +97 -0
  82. package/dist/core/context/email.js +91 -0
  83. package/dist/core/context/exchanges.d.ts +142 -0
  84. package/dist/core/context/exchanges.js +63 -0
  85. package/dist/core/context/instances.d.ts +278 -0
  86. package/dist/core/context/instances.js +123 -0
  87. package/dist/core/context/kv.d.ts +113 -0
  88. package/dist/core/context/kv.js +60 -0
  89. package/dist/core/context/platform-registry.d.ts +509 -4
  90. package/dist/core/context/platform-registry.js +14 -2
  91. package/dist/core/context/platform.d.ts +2 -1
  92. package/dist/core/context/sms.d.ts +147 -0
  93. package/dist/core/context/sms.js +57 -0
  94. package/dist/core/context/types.d.ts +51 -30
  95. package/dist/core/context/types.js +1 -7
  96. package/dist/core/conversation/index.d.ts +31 -0
  97. package/dist/core/conversation/index.js +14 -0
  98. package/dist/core/functions/define/bind.d.ts +25 -0
  99. package/dist/core/functions/define/bind.js +14 -0
  100. package/dist/core/functions/define/case.d.ts +9 -0
  101. package/dist/core/functions/define/case.js +13 -0
  102. package/dist/core/functions/define/events.d.ts +20 -0
  103. package/dist/core/functions/define/events.js +21 -0
  104. package/dist/core/functions/define/no-case.d.ts +4 -0
  105. package/dist/core/functions/define/no-case.js +9 -0
  106. package/dist/core/functions/events.d.ts +247 -0
  107. package/dist/core/functions/events.js +32 -0
  108. package/dist/core/functions/func-ref.d.ts +11 -2
  109. package/dist/core/functions/schedules.d.ts +51 -0
  110. package/dist/core/functions/schedules.js +20 -0
  111. package/dist/core/functions/types.d.ts +62 -51
  112. package/dist/core/functions/types.js +6 -1
  113. package/dist/core/office-hours/index.d.ts +39 -0
  114. package/dist/core/office-hours/index.js +187 -0
  115. package/dist/core/page/define.d.ts +834 -0
  116. package/dist/core/page/define.js +477 -0
  117. package/dist/core/page/ops.d.ts +58 -0
  118. package/dist/core/page/ops.js +220 -0
  119. package/dist/core/page/render.d.ts +253 -0
  120. package/dist/core/page/render.js +840 -0
  121. package/dist/core/page/time-format.d.ts +19 -0
  122. package/dist/core/page/time-format.js +41 -0
  123. package/dist/core/page/timeline.d.ts +40 -0
  124. package/dist/core/page/timeline.js +2 -0
  125. package/dist/core/page/typed.d.ts +642 -0
  126. package/dist/core/page/typed.js +2 -0
  127. package/dist/core/page/workspace.d.ts +33 -0
  128. package/dist/core/page/workspace.js +231 -0
  129. package/dist/core/party/index.d.ts +3 -0
  130. package/dist/core/party/index.js +3 -0
  131. package/dist/core/party/schema.d.ts +137 -0
  132. package/dist/core/party/schema.js +80 -0
  133. package/dist/core/party/types.d.ts +40 -0
  134. package/dist/core/party/types.js +15 -0
  135. package/dist/core/sequence/define.d.ts +57 -0
  136. package/dist/core/sequence/define.js +10 -0
  137. package/dist/core/sequence/index.d.ts +63 -0
  138. package/dist/core/sequence/index.js +231 -0
  139. package/dist/core/slot/binding.d.ts +40 -0
  140. package/dist/core/slot/binding.js +2 -0
  141. package/dist/core/slot/company-metadata.d.ts +113 -0
  142. package/dist/core/slot/company-metadata.js +563 -0
  143. package/dist/core/slot/compile-schema.d.ts +19 -13
  144. package/dist/core/slot/compile-schema.js +51 -248
  145. package/dist/core/slot/contact-timezone.d.ts +110 -0
  146. package/dist/core/slot/contact-timezone.js +186 -0
  147. package/dist/core/slot/field.d.ts +2 -24
  148. package/dist/core/slot/field.js +0 -69
  149. package/dist/core/slot/id-ref.d.ts +17 -2
  150. package/dist/core/slot/id-ref.js +16 -8
  151. package/dist/core/slot/index.d.ts +12 -13
  152. package/dist/core/slot/index.js +11 -12
  153. package/dist/core/slot/naming.d.ts +15 -0
  154. package/dist/core/slot/naming.js +96 -0
  155. package/dist/core/slot/platform-fields.d.ts +119 -0
  156. package/dist/core/slot/platform-fields.js +121 -0
  157. package/dist/core/slot/ref.d.ts +16 -0
  158. package/dist/core/slot/ref.js +14 -0
  159. package/dist/core/slot/row.d.ts +2 -9
  160. package/dist/core/slot/row.js +13 -23
  161. package/dist/core/slot/schema-compat.d.ts +16 -0
  162. package/dist/core/slot/schema-compat.js +112 -0
  163. package/dist/core/slot/schema.d.ts +409 -76
  164. package/dist/core/slot/schema.js +178 -10
  165. package/dist/core/slot/types.d.ts +27 -92
  166. package/dist/core/slot/value.d.ts +26 -3
  167. package/dist/core/slot/value.js +89 -57
  168. package/dist/dev-overlay/protocol.d.ts +41 -8
  169. package/dist/fn-context/build-context.d.ts +3 -1
  170. package/dist/fn-context/build-context.js +20 -10
  171. package/dist/fn-context/fake/empty-api.js +9 -28
  172. package/dist/fn-context/fake/index.d.ts +11 -4
  173. package/dist/fn-context/fake/index.js +27 -2
  174. package/dist/fn-context/fn-params.d.ts +6 -0
  175. package/dist/fn-context/fn-params.js +13 -0
  176. package/dist/fn-context/index.d.ts +5 -5
  177. package/dist/fn-context/index.js +4 -4
  178. package/dist/fn-context/log.js +2 -2
  179. package/dist/fn-context/make-ctx.d.ts +11 -0
  180. package/dist/fn-context/make-ctx.js +18 -8
  181. package/dist/fn-context/rpc/case-orchestrator-tools.d.ts +24 -0
  182. package/dist/fn-context/rpc/case-orchestrator-tools.js +13 -0
  183. package/dist/fn-context/rpc/index.d.ts +3 -1
  184. package/dist/fn-context/rpc/index.js +3 -1
  185. package/dist/fn-context/rpc/integration/index.d.ts +4 -4
  186. package/dist/fn-context/rpc/integration/index.js +1 -1
  187. package/dist/fn-context/rpc/integration/list-surfaces.d.ts +21 -0
  188. package/dist/fn-context/rpc/integration/{list-bindings.js → list-surfaces.js} +4 -4
  189. package/dist/fn-context/rpc/platform.d.ts +2 -2
  190. package/dist/fn-context/rpc/platform.js +1 -1
  191. package/dist/fn-context/rpc/records.d.ts +78 -0
  192. package/dist/fn-context/rpc/records.js +26 -0
  193. package/dist/fn-context/rpc/trpc-client.d.ts +2 -2
  194. package/dist/fn-context/rpc/trpc-client.js +89 -5
  195. package/dist/fn-context/rpc/trpc-init.d.ts +2 -2
  196. package/dist/fn-context/rpc/trpc-router-factory.d.ts +49 -3
  197. package/dist/fn-context/rpc/trpc-router-factory.js +2 -0
  198. package/dist/fn-context/run-scope.d.ts +4 -0
  199. package/dist/fn-context/run-scope.js +9 -0
  200. package/dist/fn-context/types.d.ts +36 -3
  201. package/dist/index.d.ts +37 -46
  202. package/dist/index.js +33 -33
  203. package/dist/logger.d.ts +7 -0
  204. package/dist/logger.js +41 -0
  205. package/dist/platform.d.ts +76 -0
  206. package/dist/platform.js +56 -0
  207. package/dist/voice-service/actions.d.ts +71 -4
  208. package/dist/voice-service/types.d.ts +42 -2
  209. package/dist/worker.d.ts +10 -0
  210. package/dist/worker.js +10 -0
  211. package/package.json +38 -19
  212. package/dist/builder/compile/compile-agenda.d.ts +0 -15
  213. package/dist/builder/compile/compile-agenda.js +0 -59
  214. package/dist/builder/merge.d.ts +0 -4
  215. package/dist/builder/merge.js +0 -19
  216. package/dist/core/context/db.d.ts +0 -69
  217. package/dist/core/context/db.js +0 -44
  218. package/dist/core/context/docusign.d.ts +0 -134
  219. package/dist/core/context/docusign.js +0 -108
  220. package/dist/core/context/filevine.d.ts +0 -323
  221. package/dist/core/context/filevine.js +0 -254
  222. package/dist/core/context/http.d.ts +0 -9
  223. package/dist/core/context/http.js +0 -4
  224. package/dist/core/context/hubspot.d.ts +0 -250
  225. package/dist/core/context/hubspot.js +0 -191
  226. package/dist/core/context/twilio.d.ts +0 -50
  227. package/dist/core/context/twilio.js +0 -42
  228. package/dist/core/functions/define/case-context.d.ts +0 -14
  229. package/dist/core/functions/define/case-context.js +0 -15
  230. package/dist/core/functions/define/compute.d.ts +0 -7
  231. package/dist/core/functions/define/compute.js +0 -17
  232. package/dist/core/functions/define/custom.d.ts +0 -4
  233. package/dist/core/functions/define/custom.js +0 -8
  234. package/dist/core/functions/define/system.d.ts +0 -7
  235. package/dist/core/functions/define/system.js +0 -12
  236. package/dist/core/slot/deps.d.ts +0 -15
  237. package/dist/core/slot/deps.js +0 -88
  238. package/dist/core/slot/derived.d.ts +0 -32
  239. package/dist/core/slot/derived.js +0 -115
  240. package/dist/core/slot/platform-session-fields.d.ts +0 -38
  241. package/dist/core/slot/platform-session-fields.js +0 -48
  242. package/dist/core/slot/sf-schema.d.ts +0 -23
  243. package/dist/core/slot/sf-schema.js +0 -125
  244. package/dist/core/slot/sf-validate.d.ts +0 -14
  245. package/dist/core/slot/sf-validate.js +0 -132
  246. package/dist/core/slot/snapshot.d.ts +0 -18
  247. package/dist/core/slot/snapshot.js +0 -138
  248. package/dist/core/slot/write.d.ts +0 -41
  249. package/dist/core/slot/write.js +0 -319
  250. package/dist/core/stage/builders.d.ts +0 -36
  251. package/dist/core/stage/builders.js +0 -28
  252. package/dist/core/stage/condition.d.ts +0 -17
  253. package/dist/core/stage/condition.js +0 -198
  254. package/dist/core/stage/drive.d.ts +0 -43
  255. package/dist/core/stage/drive.js +0 -77
  256. package/dist/core/stage/finish-when.d.ts +0 -20
  257. package/dist/core/stage/finish-when.js +0 -82
  258. package/dist/core/stage/flatten.d.ts +0 -27
  259. package/dist/core/stage/flatten.js +0 -464
  260. package/dist/core/stage/index.d.ts +0 -11
  261. package/dist/core/stage/index.js +0 -10
  262. package/dist/core/stage/simulate.d.ts +0 -24
  263. package/dist/core/stage/simulate.js +0 -33
  264. package/dist/core/stage/transfer-fields.d.ts +0 -14
  265. package/dist/core/stage/transfer-fields.js +0 -88
  266. package/dist/core/stage/types.d.ts +0 -177
  267. package/dist/core/stage/types.js +0 -2
  268. package/dist/core/stage/validate.d.ts +0 -11
  269. package/dist/core/stage/validate.js +0 -226
  270. package/dist/core/stage/walk.d.ts +0 -34
  271. package/dist/core/stage/walk.js +0 -96
  272. package/dist/fn-context/rpc/integration/list-bindings.d.ts +0 -21
  273. package/dist/fn-context/system-args.d.ts +0 -6
  274. package/dist/fn-context/system-args.js +0 -14
@@ -1,191 +0,0 @@
1
- import { z } from 'zod';
2
- export const hubspotPropertyValue = z.union([z.string(), z.number(), z.boolean()]);
3
- export const hubspotPropertiesInput = z.record(z.string(), hubspotPropertyValue);
4
- export const hubspotPropertiesOutput = z.record(z.string(), z.string().nullable());
5
- export const hubspotRecord = z.object({
6
- id: z.string(),
7
- properties: hubspotPropertiesOutput,
8
- });
9
- export const hubspotCreateContactInput = z.object({
10
- properties: hubspotPropertiesInput,
11
- });
12
- export const hubspotCreateContactOutput = hubspotRecord;
13
- export const hubspotUpdateContactInput = z.object({
14
- id: z.string(),
15
- properties: hubspotPropertiesInput,
16
- });
17
- export const hubspotUpdateContactOutput = hubspotRecord;
18
- export const hubspotGetContactInput = z.object({
19
- id: z.string(),
20
- properties: z.array(z.string()).optional(),
21
- });
22
- export const hubspotGetContactOutput = hubspotRecord;
23
- export const hubspotSearchContactsInput = z.object({
24
- query: z.string(),
25
- properties: z.array(z.string()).optional(),
26
- after: z.string().optional(),
27
- });
28
- export const hubspotSearchContactsOutput = z.object({
29
- total: z.number(),
30
- results: z.array(hubspotRecord),
31
- after: z.string().optional(),
32
- });
33
- export const hubspotUpsertContactInput = z.object({
34
- email: z.string(),
35
- properties: hubspotPropertiesInput.optional(),
36
- });
37
- export const hubspotUpsertContactOutput = z.object({
38
- ok: z.literal(true),
39
- id: z.string(),
40
- created: z.boolean(),
41
- });
42
- export const hubspotCreateDealInput = z.object({
43
- properties: hubspotPropertiesInput,
44
- contactId: z.string().optional(),
45
- });
46
- export const hubspotCreateDealOutput = hubspotRecord;
47
- export const hubspotUpdateDealInput = z.object({
48
- id: z.string(),
49
- properties: hubspotPropertiesInput,
50
- });
51
- export const hubspotUpdateDealOutput = hubspotRecord;
52
- export const hubspotGetDealInput = z.object({
53
- id: z.string(),
54
- properties: z.array(z.string()).optional(),
55
- });
56
- export const hubspotGetDealOutput = hubspotRecord;
57
- export const hubspotGetAssociatedDealsInput = z.object({
58
- contactId: z.string(),
59
- });
60
- export const hubspotAssociationListOutput = z.object({
61
- results: z.array(z.object({ id: z.string() })),
62
- });
63
- export const hubspotGetAssociatedContactsInput = z.object({
64
- dealId: z.string(),
65
- });
66
- export const hubspotGetOwnerInput = z.object({
67
- id: z.string(),
68
- });
69
- export const hubspotGetOwnerOutput = z.object({
70
- id: z.string(),
71
- email: z.string().nullable(),
72
- firstName: z.string().nullable(),
73
- lastName: z.string().nullable(),
74
- });
75
- export const hubspotCreateNoteInput = z.object({
76
- contactId: z.string(),
77
- body: z.string(),
78
- });
79
- export const hubspotEngagementOutput = z.object({
80
- id: z.string(),
81
- });
82
- const hubspotAssociateTo = z.object({
83
- kind: z.enum(['contact', 'deal']),
84
- id: z.string(),
85
- });
86
- export const hubspotLogCallInput = z.object({
87
- to: hubspotAssociateTo,
88
- direction: z.enum(['INBOUND', 'OUTBOUND']),
89
- timestamp: z.number(),
90
- title: z.string().optional(),
91
- body: z.string().optional(),
92
- recordingUrl: z.string().optional(),
93
- status: z
94
- .enum([
95
- 'BUSY',
96
- 'CALLING_CRM_USER',
97
- 'CANCELED',
98
- 'COMPLETED',
99
- 'CONNECTING',
100
- 'FAILED',
101
- 'IN_PROGRESS',
102
- 'NO_ANSWER',
103
- 'QUEUED',
104
- 'RINGING',
105
- ])
106
- .optional(),
107
- });
108
- export const hubspotLogEmailInput = z.object({
109
- to: hubspotAssociateTo,
110
- direction: z.enum(['EMAIL', 'INCOMING_EMAIL', 'FORWARDED_EMAIL']),
111
- subject: z.string(),
112
- body: z.string(),
113
- timestamp: z.number(),
114
- });
115
- export const hubspotLogSmsInput = z.object({
116
- to: hubspotAssociateTo,
117
- message: z.string(),
118
- timestamp: z.number(),
119
- prefix: z.string().optional(),
120
- });
121
- export const hubspotCreateTaskInput = z.object({
122
- to: hubspotAssociateTo,
123
- title: z.string(),
124
- description: z.string(),
125
- dueAt: z.number(),
126
- ownerId: z.string(),
127
- priority: z.enum(['HIGH', 'MEDIUM', 'LOW']),
128
- status: z.enum(['NOT_STARTED', 'IN_PROGRESS', 'WAITING', 'COMPLETED', 'DEFERRED']),
129
- });
130
- export const hubspotGetCrmUrlInput = z.object({
131
- type: z.enum(['contact', 'call']),
132
- id: z.string(),
133
- });
134
- export const hubspotGetCrmUrlOutput = z.object({
135
- url: z.string(),
136
- });
137
- const mockRecord = { id: 'mock-hs-1', properties: {} };
138
- export const hubspotMockService = {
139
- async createContact() {
140
- return mockRecord;
141
- },
142
- async updateContact() {
143
- return mockRecord;
144
- },
145
- async getContact() {
146
- return mockRecord;
147
- },
148
- async searchContacts() {
149
- return { total: 0, results: [] };
150
- },
151
- async upsertContact() {
152
- return { ok: true, id: 'mock-hs-1', created: true };
153
- },
154
- async createDeal() {
155
- return mockRecord;
156
- },
157
- async updateDeal() {
158
- return mockRecord;
159
- },
160
- async getDeal() {
161
- return mockRecord;
162
- },
163
- async getAssociatedDeals() {
164
- return { results: [] };
165
- },
166
- async getAssociatedContacts() {
167
- return { results: [] };
168
- },
169
- async getOwner() {
170
- return { id: 'mock-owner', email: null, firstName: null, lastName: null };
171
- },
172
- async createNote() {
173
- return { id: 'mock-note' };
174
- },
175
- async logCall() {
176
- return { id: 'mock-call' };
177
- },
178
- async logEmail() {
179
- return { id: 'mock-email' };
180
- },
181
- async logSms() {
182
- return { id: 'mock-sms' };
183
- },
184
- async createTask() {
185
- return { id: 'mock-task' };
186
- },
187
- async getCrmUrl() {
188
- return { url: 'https://app.hubspot.com/contacts/0/record/0-1/mock-hs-1' };
189
- },
190
- };
191
- //# sourceMappingURL=hubspot.js.map
@@ -1,50 +0,0 @@
1
- import { z } from 'zod';
2
- import type { IntegrationAccountFields } from './account-fields.js';
3
- export declare const twilioSendSmsInput: z.ZodObject<{
4
- to: z.ZodString;
5
- body: z.ZodString;
6
- from: z.ZodOptional<z.ZodString>;
7
- }, z.core.$strip>;
8
- export type TwilioSendSmsInput = z.infer<typeof twilioSendSmsInput>;
9
- export declare const twilioSendSmsOutput: z.ZodObject<{
10
- ok: z.ZodLiteral<true>;
11
- sid: z.ZodString;
12
- status: z.ZodNullable<z.ZodString>;
13
- }, z.core.$strip>;
14
- export type TwilioSendSmsOutput = z.infer<typeof twilioSendSmsOutput>;
15
- export declare const twilioCreateCallInput: z.ZodObject<{
16
- to: z.ZodString;
17
- from: z.ZodString;
18
- url: z.ZodOptional<z.ZodString>;
19
- twiml: z.ZodOptional<z.ZodString>;
20
- }, z.core.$strip>;
21
- export type TwilioCreateCallInput = z.infer<typeof twilioCreateCallInput>;
22
- export declare const twilioCreateCallOutput: z.ZodObject<{
23
- ok: z.ZodLiteral<true>;
24
- sid: z.ZodString;
25
- status: z.ZodNullable<z.ZodString>;
26
- }, z.core.$strip>;
27
- export type TwilioCreateCallOutput = z.infer<typeof twilioCreateCallOutput>;
28
- export declare const twilioIncomingNumber: z.ZodObject<{
29
- sid: z.ZodString;
30
- phoneNumber: z.ZodString;
31
- friendlyName: z.ZodString;
32
- status: z.ZodString;
33
- }, z.core.$strip>;
34
- export type TwilioIncomingNumber = z.infer<typeof twilioIncomingNumber>;
35
- export declare const twilioListIncomingNumbersOutput: z.ZodArray<z.ZodObject<{
36
- sid: z.ZodString;
37
- phoneNumber: z.ZodString;
38
- friendlyName: z.ZodString;
39
- status: z.ZodString;
40
- }, z.core.$strip>>;
41
- export type TwilioListIncomingNumbersOutput = z.infer<typeof twilioListIncomingNumbersOutput>;
42
- export type TwilioService = {
43
- sendSms(input: TwilioSendSmsInput): Promise<TwilioSendSmsOutput>;
44
- createCall(input: TwilioCreateCallInput): Promise<TwilioCreateCallOutput>;
45
- listIncomingNumbers(): Promise<TwilioListIncomingNumbersOutput>;
46
- };
47
- /** Stand-in surface for fake contexts and local runs; never reaches Twilio. */
48
- export declare const twilioMockService: TwilioService;
49
- export type TwilioApi = IntegrationAccountFields & TwilioService;
50
- //# sourceMappingURL=twilio.d.ts.map
@@ -1,42 +0,0 @@
1
- import { z } from 'zod';
2
- export const twilioSendSmsInput = z.object({
3
- to: z.string(),
4
- body: z.string(),
5
- from: z.string().optional(),
6
- });
7
- export const twilioSendSmsOutput = z.object({
8
- ok: z.literal(true),
9
- sid: z.string(),
10
- status: z.string().nullable(),
11
- });
12
- export const twilioCreateCallInput = z.object({
13
- to: z.string(),
14
- from: z.string(),
15
- url: z.string().optional(),
16
- twiml: z.string().optional(),
17
- });
18
- export const twilioCreateCallOutput = z.object({
19
- ok: z.literal(true),
20
- sid: z.string(),
21
- status: z.string().nullable(),
22
- });
23
- export const twilioIncomingNumber = z.object({
24
- sid: z.string(),
25
- phoneNumber: z.string(),
26
- friendlyName: z.string(),
27
- status: z.string(),
28
- });
29
- export const twilioListIncomingNumbersOutput = z.array(twilioIncomingNumber);
30
- /** Stand-in surface for fake contexts and local runs; never reaches Twilio. */
31
- export const twilioMockService = {
32
- async sendSms() {
33
- return { ok: true, sid: 'SM-mock', status: 'queued' };
34
- },
35
- async createCall() {
36
- return { ok: true, sid: 'CA-mock', status: 'queued' };
37
- },
38
- async listIncomingNumbers() {
39
- return [];
40
- },
41
- };
42
- //# sourceMappingURL=twilio.js.map
@@ -1,14 +0,0 @@
1
- /** `(slots) => CaseContext` — pure projection; not persisted. */
2
- export type CaseContextViewFn<S = unknown, C = unknown> = (slots: S) => C;
3
- /** Tagged by {@link defineCaseContext} so compile can find it. */
4
- export type DefinedCaseContextView<S = unknown, C = unknown> = CaseContextViewFn<S, C> & {
5
- kind: 'caseContextView';
6
- main: CaseContextViewFn<S, C>;
7
- };
8
- /** Mark a projector for sequence `view.ts`. */
9
- export declare function defineCaseContext<S, C>(main: CaseContextViewFn<S, C>): DefinedCaseContextView<S, C>;
10
- /** `export type CaseContext = CaseContextOf<typeof caseContextView>` */
11
- export type CaseContextOf<T> = T extends (...args: never) => infer C ? C : never;
12
- /** Unwrap for compile / host (prefers `.main` when tagged). */
13
- export declare function resolveCaseContextViewFn(value: unknown): CaseContextViewFn | undefined;
14
- //# sourceMappingURL=case-context.d.ts.map
@@ -1,15 +0,0 @@
1
- /** Mark a projector for sequence `view.ts`. */
2
- export function defineCaseContext(main) {
3
- return Object.assign(main, { kind: 'caseContextView', main });
4
- }
5
- /** Unwrap for compile / host (prefers `.main` when tagged). */
6
- export function resolveCaseContextViewFn(value) {
7
- if (typeof value !== 'function')
8
- return undefined;
9
- const tagged = value;
10
- if (tagged.kind === 'caseContextView' && typeof tagged.main === 'function') {
11
- return tagged.main;
12
- }
13
- return value;
14
- }
15
- //# sourceMappingURL=case-context.js.map
@@ -1,7 +0,0 @@
1
- import type { ComputeFn, DefinedFunc, FuncOptions } from '../types.js';
2
- import type { CaseContext } from '../../context/types.js';
3
- /** Pure compute / derived field fn. No I/O; no SystemContext. Name = functions-map key. */
4
- export declare function defineComputeFunc<S = CaseContext, R = unknown>(main: ComputeFn<S, R>, options?: FuncOptions): DefinedFunc;
5
- /** Boolean compute (finishWhen / applyWhen helpers). */
6
- export declare function defineBoolComputeFunc<S = CaseContext>(main: ComputeFn<S, boolean>, options?: FuncOptions): DefinedFunc;
7
- //# sourceMappingURL=compute.d.ts.map
@@ -1,17 +0,0 @@
1
- /** Pure compute / derived field fn. No I/O; no SystemContext. Name = functions-map key. */
2
- export function defineComputeFunc(main, options) {
3
- return {
4
- kind: 'compute',
5
- main: main,
6
- ...options,
7
- };
8
- }
9
- /** Boolean compute (finishWhen / applyWhen helpers). */
10
- export function defineBoolComputeFunc(main, options) {
11
- return {
12
- kind: 'boolCompute',
13
- main: main,
14
- ...options,
15
- };
16
- }
17
- //# sourceMappingURL=compute.js.map
@@ -1,4 +0,0 @@
1
- import type { CustomFn, DefinedFunc, FuncOptions } from '../types.js';
2
- import type { CaseContext } from '../../context/types.js';
3
- export declare function defineCustomFunc<S = CaseContext>(main: CustomFn<S>, options?: FuncOptions): DefinedFunc;
4
- //# sourceMappingURL=custom.d.ts.map
@@ -1,8 +0,0 @@
1
- export function defineCustomFunc(main, options) {
2
- return {
3
- kind: 'custom',
4
- main: main,
5
- ...options,
6
- };
7
- }
8
- //# sourceMappingURL=custom.js.map
@@ -1,7 +0,0 @@
1
- import type { DefinedFunc, FuncOptions, FunctionCall, WebHookFunctionParams } from '../types.js';
2
- /**
3
- * Platform lifecycle / webhook entry. Register under the matching key
4
- * (e.g. `webhook: defineSystemFunc(...)`, `getFirstMessage: defineSystemFunc(...)`).
5
- */
6
- export declare function defineSystemFunc<P extends object = WebHookFunctionParams, R = void>(main: FunctionCall<P, R>, options?: FuncOptions): DefinedFunc;
7
- //# sourceMappingURL=system.d.ts.map
@@ -1,12 +0,0 @@
1
- /**
2
- * Platform lifecycle / webhook entry. Register under the matching key
3
- * (e.g. `webhook: defineSystemFunc(...)`, `getFirstMessage: defineSystemFunc(...)`).
4
- */
5
- export function defineSystemFunc(main, options) {
6
- return {
7
- kind: 'system',
8
- main: main,
9
- ...options,
10
- };
11
- }
12
- //# sourceMappingURL=system.js.map
@@ -1,15 +0,0 @@
1
- import type { FieldPath } from './path.js';
2
- import type { RuntimeTableDef, ValidationIssue } from './types.js';
3
- export type DependencyGraphResult = {
4
- derivedOrder: FieldPath[];
5
- reverseDeps: Record<FieldPath, FieldPath[]>;
6
- issues: ValidationIssue[];
7
- };
8
- /**
9
- * Build topological order of derived fields and reverse dependency index.
10
- * Reports cycles instead of throwing.
11
- */
12
- export declare function buildDependencyGraph(tables: Record<string, RuntimeTableDef>): DependencyGraphResult;
13
- /** Collect derived fields affected by changed columns, in topo order. */
14
- export declare function affectedDerivedFields(changed: Iterable<FieldPath>, reverseDeps: Record<FieldPath, FieldPath[]>, derivedOrder: FieldPath[]): FieldPath[];
15
- //# sourceMappingURL=deps.d.ts.map
@@ -1,88 +0,0 @@
1
- import { formatFieldPath, parseFieldPath } from './path.js';
2
- /**
3
- * Build topological order of derived fields and reverse dependency index.
4
- * Reports cycles instead of throwing.
5
- */
6
- export function buildDependencyGraph(tables) {
7
- const issues = [];
8
- const derivedPaths = [];
9
- const edges = new Map();
10
- const reverseDeps = {};
11
- for (const [tableName, table] of Object.entries(tables)) {
12
- for (const [fieldName, field] of Object.entries(table.fields)) {
13
- if (!field.derived)
14
- continue;
15
- const path = formatFieldPath(tableName, fieldName);
16
- derivedPaths.push(path);
17
- const deps = [];
18
- for (const dep of field.dependsOn) {
19
- const parsed = parseFieldPath(dep);
20
- if (!parsed) {
21
- issues.push({
22
- code: 'invalid-depends-on',
23
- message: `Invalid dependsOn path: ${dep}`,
24
- path,
25
- });
26
- continue;
27
- }
28
- deps.push(parsed.path);
29
- if (!reverseDeps[parsed.path])
30
- reverseDeps[parsed.path] = [];
31
- reverseDeps[parsed.path].push(path);
32
- }
33
- edges.set(path, deps);
34
- }
35
- }
36
- // Kahn topological sort over derived nodes only; edges point to dependencies.
37
- const indegree = new Map();
38
- const dependents = new Map();
39
- for (const path of derivedPaths) {
40
- indegree.set(path, 0);
41
- dependents.set(path, []);
42
- }
43
- for (const [path, deps] of edges) {
44
- for (const dep of deps) {
45
- if (!indegree.has(dep))
46
- continue; // dependency is a normal field
47
- indegree.set(path, (indegree.get(path) ?? 0) + 1);
48
- dependents.get(dep).push(path);
49
- }
50
- }
51
- const queue = derivedPaths.filter((p) => (indegree.get(p) ?? 0) === 0);
52
- const derivedOrder = [];
53
- while (queue.length > 0) {
54
- const path = queue.shift();
55
- derivedOrder.push(path);
56
- for (const next of dependents.get(path) ?? []) {
57
- const nextDeg = (indegree.get(next) ?? 0) - 1;
58
- indegree.set(next, nextDeg);
59
- if (nextDeg === 0)
60
- queue.push(next);
61
- }
62
- }
63
- if (derivedOrder.length !== derivedPaths.length) {
64
- const remaining = derivedPaths.filter((p) => !derivedOrder.includes(p));
65
- issues.push({
66
- code: 'cyclic-dependency',
67
- message: `Cyclic derived dependency involving: ${remaining.join(' → ')}`,
68
- path: remaining[0],
69
- });
70
- }
71
- return { derivedOrder, reverseDeps, issues };
72
- }
73
- /** Collect derived fields affected by changed columns, in topo order. */
74
- export function affectedDerivedFields(changed, reverseDeps, derivedOrder) {
75
- const hit = new Set();
76
- const stack = [...changed];
77
- while (stack.length > 0) {
78
- const path = stack.pop();
79
- for (const derived of reverseDeps[path] ?? []) {
80
- if (hit.has(derived))
81
- continue;
82
- hit.add(derived);
83
- stack.push(derived);
84
- }
85
- }
86
- return derivedOrder.filter((path) => hit.has(path));
87
- }
88
- //# sourceMappingURL=deps.js.map
@@ -1,32 +0,0 @@
1
- import type { Writes } from '../context/types.js';
2
- import type { FieldPath } from './path.js';
3
- import type { ApplyWritesOptions, CompiledSlotSchema, RecomputeResult, RuntimeSlotsSnapshot, SlotFillingOutput } from './types.js';
4
- import { createLocalComputeHost, resolveComputeHost, type ComputeFnMap, type ComputeHost, type ComputeHostOrFns, type LocalComputeHostOptions } from '../../compute-host/compute-host.js';
5
- import { createSourceComputeHost } from '../../compute-host/source-compute-host.js';
6
- import { type ApplySlotFillingOptions, type FieldPatchInput } from './write.js';
7
- export type { ComputeFnMap, ComputeHost, ComputeHostOrFns, LocalComputeHostOptions };
8
- export { createLocalComputeHost, createSourceComputeHost, resolveComputeHost };
9
- export type RecomputeOptions = {
10
- now?: number;
11
- /**
12
- * When true, recompute every derived field in topo order (session start heal).
13
- * When false (default), only fields affected by `changed`.
14
- */
15
- all?: boolean;
16
- changed?: Iterable<FieldPath>;
17
- };
18
- /**
19
- * C6: recompute derived fields in topological order via {@link ComputeHost}.
20
- * `null` return means no conclusion yet (stored as filled+null).
21
- */
22
- export declare function recomputeDerived(schema: CompiledSlotSchema, snapshot: RuntimeSlotsSnapshot, hostOrFns: ComputeHostOrFns, options?: RecomputeOptions): Promise<RecomputeResult>;
23
- /** C4→C6: apply normal writes then recompute affected derived fields. */
24
- export declare function applyWritesAndRecompute(schema: CompiledSlotSchema, snapshot: RuntimeSlotsSnapshot, writes: Writes | null | undefined, hostOrFns: ComputeHostOrFns, writeOptions: ApplyWritesOptions): Promise<RecomputeResult>;
25
- /** Apply an explicit-state field edit, then recompute every affected derived field. */
26
- export declare function applyFieldPatchAndRecompute(schema: CompiledSlotSchema, snapshot: RuntimeSlotsSnapshot, patch: FieldPatchInput, hostOrFns: ComputeHostOrFns, options: {
27
- source: ApplyWritesOptions['source'];
28
- now?: number;
29
- }): Promise<RecomputeResult>;
30
- /** C4→C6 for accepted Slot Filling output. */
31
- export declare function applySlotFillingAndRecompute(schema: CompiledSlotSchema, snapshot: RuntimeSlotsSnapshot, output: SlotFillingOutput, hostOrFns: ComputeHostOrFns, options?: ApplySlotFillingOptions): Promise<RecomputeResult>;
32
- //# sourceMappingURL=derived.d.ts.map
@@ -1,115 +0,0 @@
1
- import { getCompiledTable, isSnapshotSingleRow } from './compile-schema.js';
2
- import { createLocalComputeHost, resolveComputeHost, } from '../../compute-host/compute-host.js';
3
- import { createSourceComputeHost } from '../../compute-host/source-compute-host.js';
4
- import { affectedDerivedFields } from './deps.js';
5
- import { commitFieldWrite, makeFieldValue } from './field.js';
6
- import { requireFieldPath } from './path.js';
7
- import { getRowField } from './row.js';
8
- import { cloneSnapshot, getSnapshotTable } from './snapshot.js';
9
- import { validateBareValue } from './value.js';
10
- import { applyFieldPatch, applySlotFilling, applyWrites, } from './write.js';
11
- export { createLocalComputeHost, createSourceComputeHost, resolveComputeHost };
12
- /**
13
- * C6: recompute derived fields in topological order via {@link ComputeHost}.
14
- * `null` return means no conclusion yet (stored as filled+null).
15
- */
16
- export async function recomputeDerived(schema, snapshot, hostOrFns, options = {}) {
17
- const host = resolveComputeHost(hostOrFns);
18
- const now = options.now ?? Date.now();
19
- const next = cloneSnapshot(snapshot);
20
- const changedOut = [];
21
- const history = [];
22
- const targets = options.all
23
- ? schema.derivedOrder
24
- : affectedDerivedFields(options.changed ?? [], schema.reverseDeps, schema.derivedOrder);
25
- for (const path of targets) {
26
- const parsed = requireFieldPath(path);
27
- const table = getCompiledTable(schema, parsed.table);
28
- const field = table?.fields[parsed.field];
29
- if (!table || !field || !field.derived)
30
- continue;
31
- if (!isSnapshotSingleRow(table))
32
- continue;
33
- const raw = await host.execute(field.computeFn, [next]);
34
- const issues = validateBareValue(field, raw, path, { allowNull: true });
35
- if (issues.length > 0) {
36
- throw new Error(`Derived ${path} returned invalid value: ${issues.map((i) => i.message).join('; ')}`);
37
- }
38
- const tableData = getSnapshotTable(next, parsed.table);
39
- const prev = getRowField(tableData, parsed.field);
40
- if (!prev)
41
- continue;
42
- const committed = commitFieldWrite(prev, makeFieldValue({
43
- value: (raw ?? null),
44
- state: 'filled',
45
- reason: null,
46
- updatedBy: 'derived',
47
- updatedAt: now,
48
- }));
49
- tableData[parsed.field] = committed.field;
50
- if (committed.changed) {
51
- changedOut.push(path);
52
- if (committed.historyEntry) {
53
- history.push({ path, entry: committed.historyEntry });
54
- }
55
- }
56
- }
57
- return { snapshot: next, changed: changedOut, history };
58
- }
59
- /** C4→C6: apply normal writes then recompute affected derived fields. */
60
- export async function applyWritesAndRecompute(schema, snapshot, writes, hostOrFns, writeOptions) {
61
- const applied = applyWrites(schema, snapshot, writes, writeOptions);
62
- if (applied.changed.length === 0) {
63
- return {
64
- snapshot: applied.snapshot,
65
- changed: [],
66
- history: applied.history,
67
- };
68
- }
69
- const recomputed = await recomputeDerived(schema, applied.snapshot, hostOrFns, {
70
- now: writeOptions.now,
71
- changed: applied.changed,
72
- });
73
- return {
74
- snapshot: recomputed.snapshot,
75
- changed: [...applied.changed, ...recomputed.changed],
76
- history: [...applied.history, ...recomputed.history],
77
- };
78
- }
79
- /** Apply an explicit-state field edit, then recompute every affected derived field. */
80
- export async function applyFieldPatchAndRecompute(schema, snapshot, patch, hostOrFns, options) {
81
- const applied = applyFieldPatch(schema, snapshot, patch, options);
82
- if (applied.changed.length === 0) {
83
- return { snapshot: applied.snapshot, changed: [], history: applied.history };
84
- }
85
- const recomputed = await recomputeDerived(schema, applied.snapshot, hostOrFns, {
86
- now: options.now,
87
- changed: applied.changed,
88
- });
89
- return {
90
- snapshot: recomputed.snapshot,
91
- changed: [...applied.changed, ...recomputed.changed],
92
- history: [...applied.history, ...recomputed.history],
93
- };
94
- }
95
- /** C4→C6 for accepted Slot Filling output. */
96
- export async function applySlotFillingAndRecompute(schema, snapshot, output, hostOrFns, options = {}) {
97
- const applied = applySlotFilling(schema, snapshot, output, options);
98
- if (applied.changed.length === 0) {
99
- return {
100
- snapshot: applied.snapshot,
101
- changed: [],
102
- history: applied.history,
103
- };
104
- }
105
- const recomputed = await recomputeDerived(schema, applied.snapshot, hostOrFns, {
106
- now: options.now,
107
- changed: applied.changed,
108
- });
109
- return {
110
- snapshot: recomputed.snapshot,
111
- changed: [...applied.changed, ...recomputed.changed],
112
- history: [...applied.history, ...recomputed.history],
113
- };
114
- }
115
- //# sourceMappingURL=derived.js.map
@@ -1,38 +0,0 @@
1
- import type { RuntimeTableDef } from './types.js';
2
- export declare const PLATFORM_SESSION_FIELDS: {
3
- readonly is_inbound_call: {
4
- readonly derived: false;
5
- readonly label: 'Inbound call';
6
- readonly dataType: 'boolean';
7
- readonly source: 'system';
8
- readonly extraction: 'Set by the conversation entry pipeline';
9
- readonly enum: null;
10
- readonly nullable: false;
11
- readonly identifier: null;
12
- readonly ref: null;
13
- };
14
- readonly is_first_call: {
15
- readonly derived: false;
16
- readonly label: 'First call';
17
- readonly dataType: 'boolean';
18
- readonly source: 'system';
19
- readonly extraction: 'No prior session for this case contact';
20
- readonly enum: null;
21
- readonly nullable: false;
22
- readonly identifier: null;
23
- readonly ref: null;
24
- };
25
- readonly is_new_user: {
26
- readonly derived: false;
27
- readonly label: 'New user';
28
- readonly dataType: 'boolean';
29
- readonly source: 'system';
30
- readonly extraction: 'No existing contact for this party';
31
- readonly enum: null;
32
- readonly nullable: false;
33
- readonly identifier: null;
34
- readonly ref: null;
35
- };
36
- };
37
- export declare function createPlatformSessionTable(): RuntimeTableDef;
38
- //# sourceMappingURL=platform-session-fields.d.ts.map