@superpanel-sdk/runtime 0.2.3 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (282) hide show
  1. package/README.md +28 -8
  2. package/dist/builder/codegen/emit.d.ts +29 -11
  3. package/dist/builder/codegen/emit.js +328 -61
  4. package/dist/builder/codegen/generate.d.ts +21 -0
  5. package/dist/builder/codegen/generate.js +152 -20
  6. package/dist/builder/company-import-graph.d.ts +2 -0
  7. package/dist/builder/company-import-graph.js +40 -8
  8. package/dist/builder/company-imports.d.ts +24 -0
  9. package/dist/builder/company-imports.js +114 -0
  10. package/dist/builder/compile/compile-sequence.d.ts +59 -8
  11. package/dist/builder/compile/compile-sequence.js +279 -77
  12. package/dist/builder/compile/function-code.d.ts +12 -2
  13. package/dist/builder/compile/function-code.js +87 -39
  14. package/dist/builder/compile/registry.d.ts +7 -3
  15. package/dist/builder/compile/registry.js +24 -23
  16. package/dist/builder/load.d.ts +70 -10
  17. package/dist/builder/load.js +250 -61
  18. package/dist/builder/paths.d.ts +3 -0
  19. package/dist/builder/paths.js +16 -0
  20. package/dist/builder/schedules.d.ts +23 -0
  21. package/dist/builder/schedules.js +102 -0
  22. package/dist/builder/slot-schema-validation.d.ts +4 -0
  23. package/dist/builder/slot-schema-validation.js +10 -0
  24. package/dist/builder/typecheck.d.ts +8 -0
  25. package/dist/builder/typecheck.js +105 -0
  26. package/dist/builder/types.d.ts +91 -19
  27. package/dist/builder/types.js +2 -1
  28. package/dist/cli/auth/auth.d.ts +37 -0
  29. package/dist/cli/auth/auth.js +211 -0
  30. package/dist/cli/auth/backend-url.d.ts +5 -0
  31. package/dist/cli/auth/backend-url.js +25 -0
  32. package/dist/cli/auth/clipboard.d.ts +9 -0
  33. package/dist/cli/auth/clipboard.js +38 -0
  34. package/dist/cli/auth/http.d.ts +20 -0
  35. package/dist/cli/auth/http.js +27 -0
  36. package/dist/cli/auth/index.d.ts +10 -0
  37. package/dist/cli/auth/index.js +27 -0
  38. package/dist/cli/auth/progress.d.ts +12 -0
  39. package/dist/cli/auth/progress.js +15 -0
  40. package/dist/cli/auth/serve-login.d.ts +8 -0
  41. package/dist/cli/auth/serve-login.js +24 -0
  42. package/dist/cli/compile/index.js +3 -0
  43. package/dist/cli/config.d.ts +10 -0
  44. package/dist/cli/config.js +52 -0
  45. package/dist/cli/index.js +28 -8
  46. package/dist/cli/serve/index.d.ts +73 -3
  47. package/dist/cli/serve/index.js +365 -116
  48. package/dist/cli/type-gen/index.js +9 -8
  49. package/dist/compiler.d.ts +7 -0
  50. package/dist/compiler.js +7 -0
  51. package/dist/compute-host/compute-host.d.ts +15 -23
  52. package/dist/compute-host/compute-host.js +25 -28
  53. package/dist/compute-host/index.d.ts +2 -4
  54. package/dist/compute-host/index.js +1 -2
  55. package/dist/compute-host/source-compute-host.d.ts +11 -9
  56. package/dist/compute-host/source-compute-host.js +46 -32
  57. package/dist/core/case-orchestrator/contact-hours.d.ts +50 -0
  58. package/dist/core/case-orchestrator/contact-hours.js +108 -0
  59. package/dist/core/case-orchestrator/follow-ups.d.ts +31 -0
  60. package/dist/core/case-orchestrator/follow-ups.js +103 -0
  61. package/dist/core/case-orchestrator/index.d.ts +6 -0
  62. package/dist/core/case-orchestrator/index.js +6 -0
  63. package/dist/core/case-orchestrator/render.d.ts +75 -0
  64. package/dist/core/case-orchestrator/render.js +239 -0
  65. package/dist/core/case-orchestrator/time.d.ts +11 -0
  66. package/dist/core/case-orchestrator/time.js +29 -0
  67. package/dist/core/case-orchestrator/tools.d.ts +29 -0
  68. package/dist/core/case-orchestrator/tools.js +31 -0
  69. package/dist/core/case-orchestrator/types.d.ts +753 -0
  70. package/dist/core/case-orchestrator/types.js +46 -0
  71. package/dist/core/case-orchestrator/validate.d.ts +11 -0
  72. package/dist/core/case-orchestrator/validate.js +63 -0
  73. package/dist/core/context/call.d.ts +291 -0
  74. package/dist/core/context/call.js +94 -0
  75. package/dist/core/context/channels.d.ts +60 -0
  76. package/dist/core/context/channels.js +35 -0
  77. package/dist/core/context/contact.d.ts +96 -6
  78. package/dist/core/context/contact.js +48 -2
  79. package/dist/core/context/email-message.d.ts +159 -0
  80. package/dist/core/context/email-message.js +59 -0
  81. package/dist/core/context/email.d.ts +97 -0
  82. package/dist/core/context/email.js +91 -0
  83. package/dist/core/context/exchanges.d.ts +142 -0
  84. package/dist/core/context/exchanges.js +63 -0
  85. package/dist/core/context/instances.d.ts +278 -0
  86. package/dist/core/context/instances.js +123 -0
  87. package/dist/core/context/kv.d.ts +113 -0
  88. package/dist/core/context/kv.js +60 -0
  89. package/dist/core/context/platform-registry.d.ts +509 -4
  90. package/dist/core/context/platform-registry.js +14 -2
  91. package/dist/core/context/platform.d.ts +2 -1
  92. package/dist/core/context/sms.d.ts +147 -0
  93. package/dist/core/context/sms.js +57 -0
  94. package/dist/core/context/types.d.ts +51 -48
  95. package/dist/core/context/types.js +1 -7
  96. package/dist/core/conversation/index.d.ts +31 -0
  97. package/dist/core/conversation/index.js +14 -0
  98. package/dist/core/functions/define/bind.d.ts +25 -0
  99. package/dist/core/functions/define/bind.js +14 -0
  100. package/dist/core/functions/define/case.d.ts +9 -0
  101. package/dist/core/functions/define/case.js +13 -0
  102. package/dist/core/functions/define/events.d.ts +20 -0
  103. package/dist/core/functions/define/events.js +21 -0
  104. package/dist/core/functions/define/no-case.d.ts +4 -0
  105. package/dist/core/functions/define/no-case.js +9 -0
  106. package/dist/core/functions/events.d.ts +247 -0
  107. package/dist/core/functions/events.js +32 -0
  108. package/dist/core/functions/func-ref.d.ts +11 -2
  109. package/dist/core/functions/schedules.d.ts +51 -0
  110. package/dist/core/functions/schedules.js +20 -0
  111. package/dist/core/functions/types.d.ts +62 -51
  112. package/dist/core/functions/types.js +6 -1
  113. package/dist/core/office-hours/index.d.ts +39 -0
  114. package/dist/core/office-hours/index.js +187 -0
  115. package/dist/core/page/define.d.ts +834 -0
  116. package/dist/core/page/define.js +477 -0
  117. package/dist/core/page/ops.d.ts +58 -0
  118. package/dist/core/page/ops.js +220 -0
  119. package/dist/core/page/render.d.ts +253 -0
  120. package/dist/core/page/render.js +840 -0
  121. package/dist/core/page/time-format.d.ts +19 -0
  122. package/dist/core/page/time-format.js +41 -0
  123. package/dist/core/page/timeline.d.ts +40 -0
  124. package/dist/core/page/timeline.js +2 -0
  125. package/dist/core/page/typed.d.ts +642 -0
  126. package/dist/core/page/typed.js +2 -0
  127. package/dist/core/page/workspace.d.ts +33 -0
  128. package/dist/core/page/workspace.js +231 -0
  129. package/dist/core/party/index.d.ts +3 -0
  130. package/dist/core/party/index.js +3 -0
  131. package/dist/core/party/schema.d.ts +137 -0
  132. package/dist/core/party/schema.js +80 -0
  133. package/dist/core/party/types.d.ts +40 -0
  134. package/dist/core/party/types.js +15 -0
  135. package/dist/core/sequence/define.d.ts +57 -0
  136. package/dist/core/sequence/define.js +10 -0
  137. package/dist/core/sequence/index.d.ts +63 -0
  138. package/dist/core/sequence/index.js +231 -0
  139. package/dist/core/slot/binding.d.ts +40 -0
  140. package/dist/core/slot/binding.js +2 -0
  141. package/dist/core/slot/company-metadata.d.ts +113 -0
  142. package/dist/core/slot/company-metadata.js +563 -0
  143. package/dist/core/slot/compile-schema.d.ts +19 -13
  144. package/dist/core/slot/compile-schema.js +51 -248
  145. package/dist/core/slot/contact-timezone.d.ts +110 -0
  146. package/dist/core/slot/contact-timezone.js +186 -0
  147. package/dist/core/slot/field.d.ts +2 -24
  148. package/dist/core/slot/field.js +0 -69
  149. package/dist/core/slot/id-ref.d.ts +17 -2
  150. package/dist/core/slot/id-ref.js +16 -8
  151. package/dist/core/slot/index.d.ts +12 -13
  152. package/dist/core/slot/index.js +11 -12
  153. package/dist/core/slot/naming.d.ts +15 -0
  154. package/dist/core/slot/naming.js +96 -0
  155. package/dist/core/slot/platform-fields.d.ts +119 -0
  156. package/dist/core/slot/platform-fields.js +121 -0
  157. package/dist/core/slot/ref.d.ts +16 -0
  158. package/dist/core/slot/ref.js +14 -0
  159. package/dist/core/slot/row.d.ts +2 -9
  160. package/dist/core/slot/row.js +13 -23
  161. package/dist/core/slot/schema-compat.d.ts +16 -0
  162. package/dist/core/slot/schema-compat.js +112 -0
  163. package/dist/core/slot/schema.d.ts +409 -76
  164. package/dist/core/slot/schema.js +178 -10
  165. package/dist/core/slot/types.d.ts +27 -94
  166. package/dist/core/slot/value.d.ts +26 -3
  167. package/dist/core/slot/value.js +89 -57
  168. package/dist/dev-overlay/protocol.d.ts +41 -8
  169. package/dist/fn-context/build-context.d.ts +3 -1
  170. package/dist/fn-context/build-context.js +20 -10
  171. package/dist/fn-context/fake/empty-api.js +9 -28
  172. package/dist/fn-context/fake/index.d.ts +11 -4
  173. package/dist/fn-context/fake/index.js +27 -2
  174. package/dist/fn-context/fn-params.d.ts +6 -0
  175. package/dist/fn-context/fn-params.js +13 -0
  176. package/dist/fn-context/index.d.ts +5 -5
  177. package/dist/fn-context/index.js +4 -4
  178. package/dist/fn-context/log.js +2 -2
  179. package/dist/fn-context/make-ctx.d.ts +11 -0
  180. package/dist/fn-context/make-ctx.js +18 -8
  181. package/dist/fn-context/rpc/case-orchestrator-tools.d.ts +24 -0
  182. package/dist/fn-context/rpc/case-orchestrator-tools.js +13 -0
  183. package/dist/fn-context/rpc/index.d.ts +3 -1
  184. package/dist/fn-context/rpc/index.js +3 -1
  185. package/dist/fn-context/rpc/integration/index.d.ts +4 -4
  186. package/dist/fn-context/rpc/integration/index.js +1 -1
  187. package/dist/fn-context/rpc/integration/list-surfaces.d.ts +21 -0
  188. package/dist/fn-context/rpc/integration/{list-bindings.js → list-surfaces.js} +4 -4
  189. package/dist/fn-context/rpc/platform.d.ts +2 -2
  190. package/dist/fn-context/rpc/platform.js +1 -1
  191. package/dist/fn-context/rpc/records.d.ts +78 -0
  192. package/dist/fn-context/rpc/records.js +26 -0
  193. package/dist/fn-context/rpc/trpc-client.d.ts +2 -2
  194. package/dist/fn-context/rpc/trpc-client.js +88 -7
  195. package/dist/fn-context/rpc/trpc-init.d.ts +2 -2
  196. package/dist/fn-context/rpc/trpc-router-factory.d.ts +49 -3
  197. package/dist/fn-context/rpc/trpc-router-factory.js +2 -0
  198. package/dist/fn-context/run-scope.d.ts +4 -0
  199. package/dist/fn-context/run-scope.js +9 -0
  200. package/dist/fn-context/types.d.ts +36 -3
  201. package/dist/index.d.ts +37 -46
  202. package/dist/index.js +33 -33
  203. package/dist/logger.d.ts +7 -0
  204. package/dist/logger.js +41 -0
  205. package/dist/platform.d.ts +76 -0
  206. package/dist/platform.js +56 -0
  207. package/dist/voice-service/actions.d.ts +71 -4
  208. package/dist/voice-service/types.d.ts +42 -5
  209. package/dist/worker.d.ts +10 -0
  210. package/dist/worker.js +10 -0
  211. package/package.json +38 -19
  212. package/dist/builder/compile/compile-agenda.d.ts +0 -15
  213. package/dist/builder/compile/compile-agenda.js +0 -64
  214. package/dist/builder/merge.d.ts +0 -4
  215. package/dist/builder/merge.js +0 -19
  216. package/dist/compute-host/read-only-cache.d.ts +0 -20
  217. package/dist/compute-host/read-only-cache.js +0 -61
  218. package/dist/core/context/db.d.ts +0 -69
  219. package/dist/core/context/db.js +0 -44
  220. package/dist/core/context/docusign.d.ts +0 -134
  221. package/dist/core/context/docusign.js +0 -108
  222. package/dist/core/context/filevine.d.ts +0 -323
  223. package/dist/core/context/filevine.js +0 -254
  224. package/dist/core/context/http.d.ts +0 -9
  225. package/dist/core/context/http.js +0 -4
  226. package/dist/core/context/hubspot.d.ts +0 -250
  227. package/dist/core/context/hubspot.js +0 -191
  228. package/dist/core/context/twilio.d.ts +0 -50
  229. package/dist/core/context/twilio.js +0 -42
  230. package/dist/core/functions/define/case-context.d.ts +0 -14
  231. package/dist/core/functions/define/case-context.js +0 -15
  232. package/dist/core/functions/define/compute.d.ts +0 -7
  233. package/dist/core/functions/define/compute.js +0 -17
  234. package/dist/core/functions/define/custom.d.ts +0 -4
  235. package/dist/core/functions/define/custom.js +0 -8
  236. package/dist/core/functions/define/system.d.ts +0 -7
  237. package/dist/core/functions/define/system.js +0 -12
  238. package/dist/core/slot/deps.d.ts +0 -15
  239. package/dist/core/slot/deps.js +0 -88
  240. package/dist/core/slot/derived.d.ts +0 -32
  241. package/dist/core/slot/derived.js +0 -115
  242. package/dist/core/slot/platform-session-fields.d.ts +0 -38
  243. package/dist/core/slot/platform-session-fields.js +0 -48
  244. package/dist/core/slot/sf-schema.d.ts +0 -23
  245. package/dist/core/slot/sf-schema.js +0 -125
  246. package/dist/core/slot/sf-validate.d.ts +0 -14
  247. package/dist/core/slot/sf-validate.js +0 -132
  248. package/dist/core/slot/snapshot.d.ts +0 -18
  249. package/dist/core/slot/snapshot.js +0 -138
  250. package/dist/core/slot/write.d.ts +0 -48
  251. package/dist/core/slot/write.js +0 -426
  252. package/dist/core/stage/builders.d.ts +0 -54
  253. package/dist/core/stage/builders.js +0 -31
  254. package/dist/core/stage/condition.d.ts +0 -17
  255. package/dist/core/stage/condition.js +0 -198
  256. package/dist/core/stage/drive.d.ts +0 -43
  257. package/dist/core/stage/drive.js +0 -78
  258. package/dist/core/stage/finish-when.d.ts +0 -20
  259. package/dist/core/stage/finish-when.js +0 -82
  260. package/dist/core/stage/flatten.d.ts +0 -27
  261. package/dist/core/stage/flatten.js +0 -466
  262. package/dist/core/stage/index.d.ts +0 -15
  263. package/dist/core/stage/index.js +0 -13
  264. package/dist/core/stage/interrupts.d.ts +0 -28
  265. package/dist/core/stage/interrupts.js +0 -120
  266. package/dist/core/stage/ivr-fields.d.ts +0 -9
  267. package/dist/core/stage/ivr-fields.js +0 -75
  268. package/dist/core/stage/simulate.d.ts +0 -24
  269. package/dist/core/stage/simulate.js +0 -33
  270. package/dist/core/stage/transfer-fields.d.ts +0 -19
  271. package/dist/core/stage/transfer-fields.js +0 -129
  272. package/dist/core/stage/transfer-spec.d.ts +0 -48
  273. package/dist/core/stage/transfer-spec.js +0 -113
  274. package/dist/core/stage/types.d.ts +0 -208
  275. package/dist/core/stage/types.js +0 -2
  276. package/dist/core/stage/validate.d.ts +0 -11
  277. package/dist/core/stage/validate.js +0 -330
  278. package/dist/core/stage/walk.d.ts +0 -39
  279. package/dist/core/stage/walk.js +0 -119
  280. package/dist/fn-context/rpc/integration/list-bindings.d.ts +0 -21
  281. package/dist/fn-context/system-args.d.ts +0 -6
  282. package/dist/fn-context/system-args.js +0 -14
@@ -0,0 +1,46 @@
1
+ /** Reserved export of `sequences/<id>/orchestrator.ts` and its name in the build's `functions`. */
2
+ export const ORCHESTRATOR_FUNCTION = 'orchestrator';
3
+ /** `orchestrator.ts`'s required `contacts` export: its name in the build's `functions`. */
4
+ export const ORCHESTRATOR_CONTACTS_FUNCTION = 'orchestratorContacts';
5
+ /** `ctx.meta.entry` / RunScope entry of a Case Orchestrator call. */
6
+ export const ORCHESTRATOR_ENTRY = 'orchestrator';
7
+ /** Platform tools a Run may open. Names, descriptions, schemas and executors belong to the platform. */
8
+ export const CASE_ORCHESTRATOR_TOOL_NAMES = [
9
+ 'readExchange',
10
+ 'searchExchanges',
11
+ 'updateSlots',
12
+ 'scheduleCall',
13
+ 'scheduleSms',
14
+ 'scheduleEmail',
15
+ 'scheduleUpdateSlots',
16
+ 'rescheduleAction',
17
+ 'cancelScheduledAction',
18
+ 'scheduleNextSequence',
19
+ 'closeInstance',
20
+ 'scheduleWake',
21
+ 'cancelWake',
22
+ ];
23
+ export const ACTIVITY_RECENT_LIMIT = 50;
24
+ /** How far back `recentAgreedActions` reaches. */
25
+ export const RECENT_AGREED_ACTIONS_DAYS = 14;
26
+ export const EMPTY_CASE_ACTIVITY = {
27
+ timezone: 'America/New_York',
28
+ all: {
29
+ firstAt: null,
30
+ total: 0,
31
+ dayNumber: 1,
32
+ today: { calls: 0, answeredCalls: 0, smsOut: 0, smsIn: 0, emailsOut: 0, emailsIn: 0 },
33
+ last: {
34
+ exchange: null,
35
+ inbound: null,
36
+ outbound: null,
37
+ call: null,
38
+ answeredCall: null,
39
+ sms: null,
40
+ email: null,
41
+ },
42
+ recent: [],
43
+ },
44
+ byContact: {},
45
+ };
46
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,11 @@
1
+ import { type FinalOrchestrationResult, type ResolvedAgentRequest } from './types.js';
2
+ /** A valid result, with an AgentRequest's `tools` resolved (every platform tool when left out). */
3
+ export type CaseOrchestratorResultCheck = {
4
+ ok: true;
5
+ value: ResolvedAgentRequest | FinalOrchestrationResult;
6
+ } | {
7
+ ok: false;
8
+ issues: string[];
9
+ };
10
+ export declare function validateCaseOrchestratorResult(raw: unknown): CaseOrchestratorResultCheck;
11
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1,63 @@
1
+ import { CASE_ORCHESTRATOR_TOOL_NAMES, } from './types.js';
2
+ const TOOL_NAMES = new Set(CASE_ORCHESTRATOR_TOOL_NAMES);
3
+ const ALL_TOOLS = CASE_ORCHESTRATOR_TOOL_NAMES.map((name) => ({ kind: 'tool', name }));
4
+ function isRecord(value) {
5
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
6
+ }
7
+ function isToolRef(value) {
8
+ return isRecord(value) && value.kind === 'tool' && typeof value.name === 'string' && TOOL_NAMES.has(value.name);
9
+ }
10
+ function validateTools(raw, issues) {
11
+ if (raw === undefined)
12
+ return ALL_TOOLS;
13
+ if (!Array.isArray(raw)) {
14
+ issues.push('tools must be an array of tools.*() references (leave it out for every tool, [] for none)');
15
+ return [];
16
+ }
17
+ const seen = new Set();
18
+ const tools = [];
19
+ raw.forEach((tool, index) => {
20
+ if (!isToolRef(tool)) {
21
+ issues.push(`tools[${index}] is not a registered tool reference`);
22
+ return;
23
+ }
24
+ if (seen.has(tool.name))
25
+ issues.push(`tools[${index}] repeats '${tool.name}'`);
26
+ else {
27
+ seen.add(tool.name);
28
+ tools.push(tool);
29
+ }
30
+ });
31
+ return tools;
32
+ }
33
+ function validateAgent(raw) {
34
+ const issues = [];
35
+ const prompt = typeof raw.prompt === 'string' ? raw.prompt.trim() : '';
36
+ if (!prompt)
37
+ issues.push('prompt must be a non-empty string');
38
+ const tools = validateTools(raw.tools, issues);
39
+ return issues.length > 0 ? { ok: false, issues } : { ok: true, value: { kind: 'agent', prompt, tools } };
40
+ }
41
+ function validateFinal(raw) {
42
+ const issues = [];
43
+ const finalSummary = typeof raw.finalSummary === 'string' ? raw.finalSummary.trim() : '';
44
+ if (finalSummary.length < 1 || finalSummary.length > 1000) {
45
+ issues.push('finalSummary must contain 1-1000 characters');
46
+ }
47
+ return issues.length > 0
48
+ ? { ok: false, issues }
49
+ : {
50
+ ok: true,
51
+ value: { kind: 'final', finalSummary },
52
+ };
53
+ }
54
+ export function validateCaseOrchestratorResult(raw) {
55
+ if (!isRecord(raw))
56
+ return { ok: false, issues: ['orchestrator must return an object'] };
57
+ if (raw.kind === 'agent')
58
+ return validateAgent(raw);
59
+ if (raw.kind === 'final')
60
+ return validateFinal(raw);
61
+ return { ok: false, issues: ["orchestrator result.kind must be 'agent' or 'final'"] };
62
+ }
63
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1,291 @@
1
+ import { z } from 'zod';
2
+ import type { Id } from '../page/typed.js';
3
+ export declare const CALL_PAGE_LIMIT_MAX = 100;
4
+ export declare const callDirection: z.ZodEnum<{
5
+ inbound: "inbound";
6
+ outbound: "outbound";
7
+ }>;
8
+ export type CallDirection = z.infer<typeof callDirection>;
9
+ /** One side of a call (21 §5.3): the AI, or a person on a line. */
10
+ export declare const callParticipant: z.ZodObject<{
11
+ id: z.ZodString;
12
+ kind: z.ZodEnum<{
13
+ ai: "ai";
14
+ party: "party";
15
+ }>;
16
+ address: z.ZodNullable<z.ZodString>;
17
+ contactId: z.ZodNullable<z.ZodString>;
18
+ identifiedReason: z.ZodNullable<z.ZodString>;
19
+ isNewContact: z.ZodBoolean;
20
+ joinedAt: z.ZodString;
21
+ leftAt: z.ZodNullable<z.ZodString>;
22
+ }, z.core.$strip>;
23
+ export type CallParticipant = z.infer<typeof callParticipant>;
24
+ /** Script-facing call projection (27 §5): who was on it; what was said is `transcript(id)`. */
25
+ export declare const callRecord: z.ZodObject<{
26
+ id: z.ZodString;
27
+ sessionId: z.ZodNullable<z.ZodType<Id<"session">, unknown, z.core.$ZodTypeInternals<Id<"session">, unknown>>>;
28
+ instanceId: z.ZodNullable<z.ZodString>;
29
+ instanceIds: z.ZodArray<z.ZodString>;
30
+ contactIds: z.ZodArray<z.ZodString>;
31
+ participants: z.ZodArray<z.ZodObject<{
32
+ id: z.ZodString;
33
+ kind: z.ZodEnum<{
34
+ ai: "ai";
35
+ party: "party";
36
+ }>;
37
+ address: z.ZodNullable<z.ZodString>;
38
+ contactId: z.ZodNullable<z.ZodString>;
39
+ identifiedReason: z.ZodNullable<z.ZodString>;
40
+ isNewContact: z.ZodBoolean;
41
+ joinedAt: z.ZodString;
42
+ leftAt: z.ZodNullable<z.ZodString>;
43
+ }, z.core.$strip>>;
44
+ externalId: z.ZodString;
45
+ direction: z.ZodEnum<{
46
+ inbound: "inbound";
47
+ outbound: "outbound";
48
+ }>;
49
+ from: z.ZodString;
50
+ to: z.ZodString;
51
+ status: z.ZodString;
52
+ outcome: z.ZodNullable<z.ZodString>;
53
+ startedAt: z.ZodString;
54
+ endedAt: z.ZodNullable<z.ZodString>;
55
+ durationSec: z.ZodNullable<z.ZodNumber>;
56
+ recordingUrl: z.ZodNullable<z.ZodString>;
57
+ }, z.core.$strip>;
58
+ export type CallRecord = z.infer<typeof callRecord>;
59
+ export declare const callListInput: z.ZodObject<{
60
+ offset: z.ZodNumber;
61
+ limit: z.ZodNumber;
62
+ instanceId: z.ZodOptional<z.ZodString>;
63
+ contactId: z.ZodOptional<z.ZodString>;
64
+ direction: z.ZodOptional<z.ZodEnum<{
65
+ inbound: "inbound";
66
+ outbound: "outbound";
67
+ }>>;
68
+ status: z.ZodOptional<z.ZodString>;
69
+ }, z.core.$strip>;
70
+ export type CallListParams = z.infer<typeof callListInput>;
71
+ export declare const callListOutput: z.ZodObject<{
72
+ calls: z.ZodArray<z.ZodObject<{
73
+ id: z.ZodString;
74
+ sessionId: z.ZodNullable<z.ZodType<Id<"session">, unknown, z.core.$ZodTypeInternals<Id<"session">, unknown>>>;
75
+ instanceId: z.ZodNullable<z.ZodString>;
76
+ instanceIds: z.ZodArray<z.ZodString>;
77
+ contactIds: z.ZodArray<z.ZodString>;
78
+ participants: z.ZodArray<z.ZodObject<{
79
+ id: z.ZodString;
80
+ kind: z.ZodEnum<{
81
+ ai: "ai";
82
+ party: "party";
83
+ }>;
84
+ address: z.ZodNullable<z.ZodString>;
85
+ contactId: z.ZodNullable<z.ZodString>;
86
+ identifiedReason: z.ZodNullable<z.ZodString>;
87
+ isNewContact: z.ZodBoolean;
88
+ joinedAt: z.ZodString;
89
+ leftAt: z.ZodNullable<z.ZodString>;
90
+ }, z.core.$strip>>;
91
+ externalId: z.ZodString;
92
+ direction: z.ZodEnum<{
93
+ inbound: "inbound";
94
+ outbound: "outbound";
95
+ }>;
96
+ from: z.ZodString;
97
+ to: z.ZodString;
98
+ status: z.ZodString;
99
+ outcome: z.ZodNullable<z.ZodString>;
100
+ startedAt: z.ZodString;
101
+ endedAt: z.ZodNullable<z.ZodString>;
102
+ durationSec: z.ZodNullable<z.ZodNumber>;
103
+ recordingUrl: z.ZodNullable<z.ZodString>;
104
+ }, z.core.$strip>>;
105
+ offset: z.ZodNumber;
106
+ limit: z.ZodNumber;
107
+ }, z.core.$strip>;
108
+ export type CallListResult = z.infer<typeof callListOutput>;
109
+ export declare const callGetInput: z.ZodString;
110
+ export declare const callGetOutput: z.ZodNullable<z.ZodObject<{
111
+ id: z.ZodString;
112
+ sessionId: z.ZodNullable<z.ZodType<Id<"session">, unknown, z.core.$ZodTypeInternals<Id<"session">, unknown>>>;
113
+ instanceId: z.ZodNullable<z.ZodString>;
114
+ instanceIds: z.ZodArray<z.ZodString>;
115
+ contactIds: z.ZodArray<z.ZodString>;
116
+ participants: z.ZodArray<z.ZodObject<{
117
+ id: z.ZodString;
118
+ kind: z.ZodEnum<{
119
+ ai: "ai";
120
+ party: "party";
121
+ }>;
122
+ address: z.ZodNullable<z.ZodString>;
123
+ contactId: z.ZodNullable<z.ZodString>;
124
+ identifiedReason: z.ZodNullable<z.ZodString>;
125
+ isNewContact: z.ZodBoolean;
126
+ joinedAt: z.ZodString;
127
+ leftAt: z.ZodNullable<z.ZodString>;
128
+ }, z.core.$strip>>;
129
+ externalId: z.ZodString;
130
+ direction: z.ZodEnum<{
131
+ inbound: "inbound";
132
+ outbound: "outbound";
133
+ }>;
134
+ from: z.ZodString;
135
+ to: z.ZodString;
136
+ status: z.ZodString;
137
+ outcome: z.ZodNullable<z.ZodString>;
138
+ startedAt: z.ZodString;
139
+ endedAt: z.ZodNullable<z.ZodString>;
140
+ durationSec: z.ZodNullable<z.ZodNumber>;
141
+ recordingUrl: z.ZodNullable<z.ZodString>;
142
+ }, z.core.$strip>>;
143
+ /** One spoken line of a call, oldest first (events such as a transfer or a hang-up left out). */
144
+ export declare const callTranscriptLine: z.ZodObject<{
145
+ at: z.ZodString;
146
+ speaker: z.ZodEnum<{
147
+ ai: "ai";
148
+ party: "party";
149
+ }>;
150
+ participantId: z.ZodNullable<z.ZodString>;
151
+ contactId: z.ZodNullable<z.ZodString>;
152
+ instanceId: z.ZodNullable<z.ZodString>;
153
+ text: z.ZodString;
154
+ interrupted: z.ZodBoolean;
155
+ }, z.core.$strip>;
156
+ export type CallTranscriptLine = z.infer<typeof callTranscriptLine>;
157
+ export declare const callTranscriptInput: z.ZodString;
158
+ export declare const callTranscriptOutput: z.ZodNullable<z.ZodObject<{
159
+ callId: z.ZodString;
160
+ lines: z.ZodArray<z.ZodObject<{
161
+ at: z.ZodString;
162
+ speaker: z.ZodEnum<{
163
+ ai: "ai";
164
+ party: "party";
165
+ }>;
166
+ participantId: z.ZodNullable<z.ZodString>;
167
+ contactId: z.ZodNullable<z.ZodString>;
168
+ instanceId: z.ZodNullable<z.ZodString>;
169
+ text: z.ZodString;
170
+ interrupted: z.ZodBoolean;
171
+ }, z.core.$strip>>;
172
+ }, z.core.$strip>>;
173
+ export type CallTranscript = NonNullable<z.infer<typeof callTranscriptOutput>>;
174
+ /** Platform call-history capability, reached from scripts as `ctx.api.call`. */
175
+ export type CallApi = {
176
+ list(input: CallListParams): Promise<CallListResult>;
177
+ get(id: string): Promise<CallRecord | null>;
178
+ /** What was said on any call of the company and environment (27 §5.3); null when there is no such call. */
179
+ transcript(id: string): Promise<CallTranscript | null>;
180
+ };
181
+ export declare const callMockService: CallApi;
182
+ export declare const callSurface: {
183
+ methods: {
184
+ list: {
185
+ input: z.ZodObject<{
186
+ offset: z.ZodNumber;
187
+ limit: z.ZodNumber;
188
+ instanceId: z.ZodOptional<z.ZodString>;
189
+ contactId: z.ZodOptional<z.ZodString>;
190
+ direction: z.ZodOptional<z.ZodEnum<{
191
+ inbound: "inbound";
192
+ outbound: "outbound";
193
+ }>>;
194
+ status: z.ZodOptional<z.ZodString>;
195
+ }, z.core.$strip>;
196
+ output: z.ZodObject<{
197
+ calls: z.ZodArray<z.ZodObject<{
198
+ id: z.ZodString;
199
+ sessionId: z.ZodNullable<z.ZodType<Id<"session">, unknown, z.core.$ZodTypeInternals<Id<"session">, unknown>>>;
200
+ instanceId: z.ZodNullable<z.ZodString>;
201
+ instanceIds: z.ZodArray<z.ZodString>;
202
+ contactIds: z.ZodArray<z.ZodString>;
203
+ participants: z.ZodArray<z.ZodObject<{
204
+ id: z.ZodString;
205
+ kind: z.ZodEnum<{
206
+ ai: "ai";
207
+ party: "party";
208
+ }>;
209
+ address: z.ZodNullable<z.ZodString>;
210
+ contactId: z.ZodNullable<z.ZodString>;
211
+ identifiedReason: z.ZodNullable<z.ZodString>;
212
+ isNewContact: z.ZodBoolean;
213
+ joinedAt: z.ZodString;
214
+ leftAt: z.ZodNullable<z.ZodString>;
215
+ }, z.core.$strip>>;
216
+ externalId: z.ZodString;
217
+ direction: z.ZodEnum<{
218
+ inbound: "inbound";
219
+ outbound: "outbound";
220
+ }>;
221
+ from: z.ZodString;
222
+ to: z.ZodString;
223
+ status: z.ZodString;
224
+ outcome: z.ZodNullable<z.ZodString>;
225
+ startedAt: z.ZodString;
226
+ endedAt: z.ZodNullable<z.ZodString>;
227
+ durationSec: z.ZodNullable<z.ZodNumber>;
228
+ recordingUrl: z.ZodNullable<z.ZodString>;
229
+ }, z.core.$strip>>;
230
+ offset: z.ZodNumber;
231
+ limit: z.ZodNumber;
232
+ }, z.core.$strip>;
233
+ };
234
+ get: {
235
+ input: z.ZodString;
236
+ output: z.ZodNullable<z.ZodObject<{
237
+ id: z.ZodString;
238
+ sessionId: z.ZodNullable<z.ZodType<Id<"session">, unknown, z.core.$ZodTypeInternals<Id<"session">, unknown>>>;
239
+ instanceId: z.ZodNullable<z.ZodString>;
240
+ instanceIds: z.ZodArray<z.ZodString>;
241
+ contactIds: z.ZodArray<z.ZodString>;
242
+ participants: z.ZodArray<z.ZodObject<{
243
+ id: z.ZodString;
244
+ kind: z.ZodEnum<{
245
+ ai: "ai";
246
+ party: "party";
247
+ }>;
248
+ address: z.ZodNullable<z.ZodString>;
249
+ contactId: z.ZodNullable<z.ZodString>;
250
+ identifiedReason: z.ZodNullable<z.ZodString>;
251
+ isNewContact: z.ZodBoolean;
252
+ joinedAt: z.ZodString;
253
+ leftAt: z.ZodNullable<z.ZodString>;
254
+ }, z.core.$strip>>;
255
+ externalId: z.ZodString;
256
+ direction: z.ZodEnum<{
257
+ inbound: "inbound";
258
+ outbound: "outbound";
259
+ }>;
260
+ from: z.ZodString;
261
+ to: z.ZodString;
262
+ status: z.ZodString;
263
+ outcome: z.ZodNullable<z.ZodString>;
264
+ startedAt: z.ZodString;
265
+ endedAt: z.ZodNullable<z.ZodString>;
266
+ durationSec: z.ZodNullable<z.ZodNumber>;
267
+ recordingUrl: z.ZodNullable<z.ZodString>;
268
+ }, z.core.$strip>>;
269
+ };
270
+ transcript: {
271
+ input: z.ZodString;
272
+ output: z.ZodNullable<z.ZodObject<{
273
+ callId: z.ZodString;
274
+ lines: z.ZodArray<z.ZodObject<{
275
+ at: z.ZodString;
276
+ speaker: z.ZodEnum<{
277
+ ai: "ai";
278
+ party: "party";
279
+ }>;
280
+ participantId: z.ZodNullable<z.ZodString>;
281
+ contactId: z.ZodNullable<z.ZodString>;
282
+ instanceId: z.ZodNullable<z.ZodString>;
283
+ text: z.ZodString;
284
+ interrupted: z.ZodBoolean;
285
+ }, z.core.$strip>>;
286
+ }, z.core.$strip>>;
287
+ };
288
+ };
289
+ mock: CallApi;
290
+ };
291
+ //# sourceMappingURL=call.d.ts.map
@@ -0,0 +1,94 @@
1
+ import { z } from 'zod';
2
+ export const CALL_PAGE_LIMIT_MAX = 100;
3
+ export const callDirection = z.enum(['inbound', 'outbound']);
4
+ /** A session id the platform hands out: typed as one, so `db.session.findUnique({ where: { id } })` takes it. */
5
+ const sessionId = z.string();
6
+ /** One side of a call (21 §5.3): the AI, or a person on a line. */
7
+ export const callParticipant = z.object({
8
+ id: z.string(),
9
+ kind: z.enum(['ai', 'party']),
10
+ /** Their number (E.164) or address; null for the AI. */
11
+ address: z.string().nullable(),
12
+ contactId: z.string().nullable(),
13
+ /** How the contact was found: `address_match` | `resolve` | `verified` | `reconnect`; null when not known. */
14
+ identifiedReason: z.string().nullable(),
15
+ /** The contact was created for this call. */
16
+ isNewContact: z.boolean(),
17
+ joinedAt: z.string(),
18
+ leftAt: z.string().nullable(),
19
+ });
20
+ /** Script-facing call projection (27 §5): who was on it; what was said is `transcript(id)`. */
21
+ export const callRecord = z.object({
22
+ id: z.string(),
23
+ /** Null when the call never became a conversation (no answer). */
24
+ sessionId: sessionId.nullable(),
25
+ /** The call's first case; `instanceIds` all of them (a call can move to another case). */
26
+ instanceId: z.string().nullable(),
27
+ instanceIds: z.array(z.string()),
28
+ /** The contacts of the parties (`participants` of kind `party`). */
29
+ contactIds: z.array(z.string()),
30
+ participants: z.array(callParticipant),
31
+ externalId: z.string(),
32
+ direction: callDirection,
33
+ from: z.string(),
34
+ to: z.string(),
35
+ /** The provider's status of the main line (`in-progress`, `completed`, `no-answer` …). */
36
+ status: z.string(),
37
+ /** How the call ended (21 §5.2): connected | voicemail | no_answer | busy | failed | fallback | apology; null while it goes on. */
38
+ outcome: z.string().nullable(),
39
+ startedAt: z.string(),
40
+ endedAt: z.string().nullable(),
41
+ durationSec: z.number().int().min(0).nullable(),
42
+ recordingUrl: z.string().nullable(),
43
+ });
44
+ export const callListInput = z.object({
45
+ offset: z.number().int().min(0),
46
+ limit: z.number().int().min(1).max(CALL_PAGE_LIMIT_MAX),
47
+ instanceId: z.string().optional(),
48
+ contactId: z.string().optional(),
49
+ direction: callDirection.optional(),
50
+ status: z.string().optional(),
51
+ });
52
+ export const callListOutput = z.object({
53
+ calls: z.array(callRecord),
54
+ offset: z.number().int(),
55
+ limit: z.number().int(),
56
+ });
57
+ export const callGetInput = z.string().min(1);
58
+ export const callGetOutput = callRecord.nullable();
59
+ /** One spoken line of a call, oldest first (events such as a transfer or a hang-up left out). */
60
+ export const callTranscriptLine = z.object({
61
+ /** When it started, ISO 8601. */
62
+ at: z.string(),
63
+ speaker: z.enum(['ai', 'party']),
64
+ /** Who said it (a {@link CallParticipant} id); null when unclear. */
65
+ participantId: z.string().nullable(),
66
+ contactId: z.string().nullable(),
67
+ /** The case the call was on when it was said. */
68
+ instanceId: z.string().nullable(),
69
+ text: z.string(),
70
+ /** The AI was cut off while saying it. */
71
+ interrupted: z.boolean(),
72
+ });
73
+ export const callTranscriptInput = z.string().min(1);
74
+ export const callTranscriptOutput = z.object({ callId: z.string(), lines: z.array(callTranscriptLine) }).nullable();
75
+ export const callMockService = {
76
+ async list(input) {
77
+ return { calls: [], offset: input.offset, limit: input.limit };
78
+ },
79
+ async get() {
80
+ return null;
81
+ },
82
+ async transcript() {
83
+ return null;
84
+ },
85
+ };
86
+ export const callSurface = {
87
+ methods: {
88
+ list: { input: callListInput, output: callListOutput },
89
+ get: { input: callGetInput, output: callGetOutput },
90
+ transcript: { input: callTranscriptInput, output: callTranscriptOutput },
91
+ },
92
+ mock: callMockService,
93
+ };
94
+ //# sourceMappingURL=call.js.map
@@ -0,0 +1,60 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * The environment's numbers and mailboxes (22-sequence-as-business-unit §8), read-only. Code picks one
4
+ * of them when it assigns a contact its own (`assigned_phone_number` / `assigned_mailbox`), e.g. a
5
+ * number local to the contact's area code; `name` is what an explicit `from` takes.
6
+ */
7
+ export declare const channelPhoneNumber: z.ZodObject<{
8
+ number: z.ZodString;
9
+ name: z.ZodNullable<z.ZodString>;
10
+ locality: z.ZodNullable<z.ZodString>;
11
+ region: z.ZodNullable<z.ZodString>;
12
+ }, z.core.$strip>;
13
+ export type ChannelPhoneNumber = z.infer<typeof channelPhoneNumber>;
14
+ export declare const channelMailbox: z.ZodObject<{
15
+ address: z.ZodString;
16
+ name: z.ZodNullable<z.ZodString>;
17
+ }, z.core.$strip>;
18
+ export type ChannelMailbox = z.infer<typeof channelMailbox>;
19
+ export declare const channelsListInput: z.ZodObject<{}, z.core.$strict>;
20
+ export type ChannelsListParams = z.infer<typeof channelsListInput>;
21
+ export declare const channelsListOutput: z.ZodObject<{
22
+ phoneNumbers: z.ZodArray<z.ZodObject<{
23
+ number: z.ZodString;
24
+ name: z.ZodNullable<z.ZodString>;
25
+ locality: z.ZodNullable<z.ZodString>;
26
+ region: z.ZodNullable<z.ZodString>;
27
+ }, z.core.$strip>>;
28
+ mailboxes: z.ZodArray<z.ZodObject<{
29
+ address: z.ZodString;
30
+ name: z.ZodNullable<z.ZodString>;
31
+ }, z.core.$strip>>;
32
+ }, z.core.$strip>;
33
+ export type ChannelsListResult = z.infer<typeof channelsListOutput>;
34
+ /** The environment's active numbers and mailboxes, reached from scripts as `ctx.api.channels`. */
35
+ export type ChannelsApi = {
36
+ list(input: ChannelsListParams): Promise<ChannelsListResult>;
37
+ };
38
+ /** Stand-in surface for fake contexts and local runs; never touches the database. */
39
+ export declare const channelsMockService: ChannelsApi;
40
+ export declare const channelsSurface: {
41
+ methods: {
42
+ list: {
43
+ input: z.ZodObject<{}, z.core.$strict>;
44
+ output: z.ZodObject<{
45
+ phoneNumbers: z.ZodArray<z.ZodObject<{
46
+ number: z.ZodString;
47
+ name: z.ZodNullable<z.ZodString>;
48
+ locality: z.ZodNullable<z.ZodString>;
49
+ region: z.ZodNullable<z.ZodString>;
50
+ }, z.core.$strip>>;
51
+ mailboxes: z.ZodArray<z.ZodObject<{
52
+ address: z.ZodString;
53
+ name: z.ZodNullable<z.ZodString>;
54
+ }, z.core.$strip>>;
55
+ }, z.core.$strip>;
56
+ };
57
+ };
58
+ mock: ChannelsApi;
59
+ };
60
+ //# sourceMappingURL=channels.d.ts.map
@@ -0,0 +1,35 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * The environment's numbers and mailboxes (22-sequence-as-business-unit §8), read-only. Code picks one
4
+ * of them when it assigns a contact its own (`assigned_phone_number` / `assigned_mailbox`), e.g. a
5
+ * number local to the contact's area code; `name` is what an explicit `from` takes.
6
+ */
7
+ export const channelPhoneNumber = z.object({
8
+ /** E.164. */
9
+ number: z.string(),
10
+ name: z.string().nullable(),
11
+ locality: z.string().nullable(),
12
+ region: z.string().nullable(),
13
+ });
14
+ export const channelMailbox = z.object({
15
+ address: z.string(),
16
+ name: z.string().nullable(),
17
+ });
18
+ export const channelsListInput = z.strictObject({});
19
+ export const channelsListOutput = z.object({
20
+ phoneNumbers: z.array(channelPhoneNumber),
21
+ mailboxes: z.array(channelMailbox),
22
+ });
23
+ /** Stand-in surface for fake contexts and local runs; never touches the database. */
24
+ export const channelsMockService = {
25
+ async list() {
26
+ return { phoneNumbers: [], mailboxes: [] };
27
+ },
28
+ };
29
+ export const channelsSurface = {
30
+ methods: {
31
+ list: { input: channelsListInput, output: channelsListOutput },
32
+ },
33
+ mock: channelsMockService,
34
+ };
35
+ //# sourceMappingURL=channels.js.map