terse-cli 0.3.8 → 0.4.1

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 (270) hide show
  1. package/dist/cliUi.js +1 -1
  2. package/dist/cliUi.js.map +1 -1
  3. package/dist/commands/deploy.d.ts.map +1 -1
  4. package/dist/commands/deploy.js +138 -22
  5. package/dist/commands/deploy.js.map +1 -1
  6. package/dist/providers/typescript/TypeScriptProvider.js +2 -2
  7. package/dist/providers/typescript/TypeScriptProvider.js.map +1 -1
  8. package/dist/providers/typescript/durableRuntime.d.ts +1 -1
  9. package/dist/providers/typescript/durableRuntime.d.ts.map +1 -1
  10. package/dist/providers/typescript/durableRuntime.js +7 -6
  11. package/dist/providers/typescript/durableRuntime.js.map +1 -1
  12. package/dist/providers/typescript/workflowShim.d.ts +2 -0
  13. package/dist/providers/typescript/workflowShim.d.ts.map +1 -0
  14. package/dist/providers/typescript/workflowShim.js +51 -0
  15. package/dist/providers/typescript/workflowShim.js.map +1 -0
  16. package/package.json +5 -5
  17. package/templates/typescript/init/package.json.hbs +1 -1
  18. package/templates/typescript/workflow-shim/api.js +5 -0
  19. package/templates/typescript/workflow-shim/index.js +2 -0
  20. package/templates/typescript/workflow-shim/internal/builtins.js +83 -0
  21. package/templates/typescript/workflow-shim/internal/class-serialization.js +1 -0
  22. package/templates/typescript/workflow-shim/runtime.js +1 -0
  23. package/templates/typescript/workflow-shim/stdlib.js +18 -0
  24. package/templates/typescript/workflow-shim/workflow.js +2 -0
  25. package/dist/_tmp_create_project.d.ts +0 -2
  26. package/dist/_tmp_create_project.d.ts.map +0 -1
  27. package/dist/_tmp_create_project.js +0 -17
  28. package/dist/_tmp_create_project.js.map +0 -1
  29. package/dist/_tmp_delete_agent.d.ts +0 -2
  30. package/dist/_tmp_delete_agent.d.ts.map +0 -1
  31. package/dist/_tmp_delete_agent.js +0 -14
  32. package/dist/_tmp_delete_agent.js.map +0 -1
  33. package/dist/_tmp_manual_trigger.d.ts +0 -2
  34. package/dist/_tmp_manual_trigger.d.ts.map +0 -1
  35. package/dist/_tmp_manual_trigger.js +0 -17
  36. package/dist/_tmp_manual_trigger.js.map +0 -1
  37. package/dist/_tmp_patch_active.d.ts +0 -2
  38. package/dist/_tmp_patch_active.d.ts.map +0 -1
  39. package/dist/_tmp_patch_active.js +0 -21
  40. package/dist/_tmp_patch_active.js.map +0 -1
  41. package/dist/attach.d.ts +0 -3
  42. package/dist/attach.d.ts.map +0 -1
  43. package/dist/attach.js +0 -61
  44. package/dist/attach.js.map +0 -1
  45. package/dist/auth.d.ts +0 -15
  46. package/dist/auth.d.ts.map +0 -1
  47. package/dist/auth.js +0 -169
  48. package/dist/auth.js.map +0 -1
  49. package/dist/codegen.d.ts +0 -135
  50. package/dist/codegen.d.ts.map +0 -1
  51. package/dist/codegen.js +0 -1196
  52. package/dist/codegen.js.map +0 -1
  53. package/dist/commands/deployTheme.d.ts +0 -28
  54. package/dist/commands/deployTheme.d.ts.map +0 -1
  55. package/dist/commands/deployTheme.js +0 -68
  56. package/dist/commands/deployTheme.js.map +0 -1
  57. package/dist/commands/dev.d.ts +0 -3
  58. package/dist/commands/dev.d.ts.map +0 -1
  59. package/dist/commands/dev.js +0 -47
  60. package/dist/commands/dev.js.map +0 -1
  61. package/dist/commands/fsExec.d.ts +0 -8
  62. package/dist/commands/fsExec.d.ts.map +0 -1
  63. package/dist/commands/fsExec.js +0 -46
  64. package/dist/commands/fsExec.js.map +0 -1
  65. package/dist/commands/metaAdsScope.d.ts +0 -12
  66. package/dist/commands/metaAdsScope.d.ts.map +0 -1
  67. package/dist/commands/metaAdsScope.js +0 -120
  68. package/dist/commands/metaAdsScope.js.map +0 -1
  69. package/dist/commands/serve.d.ts +0 -1
  70. package/dist/commands/serve.d.ts.map +0 -1
  71. package/dist/commands/serve.js +0 -2
  72. package/dist/commands/serve.js.map +0 -1
  73. package/dist/commands/terseCliTheme.d.ts +0 -28
  74. package/dist/commands/terseCliTheme.d.ts.map +0 -1
  75. package/dist/commands/terseCliTheme.js +0 -68
  76. package/dist/commands/terseCliTheme.js.map +0 -1
  77. package/dist/commands/tool.d.ts +0 -6
  78. package/dist/commands/tool.d.ts.map +0 -1
  79. package/dist/commands/tool.js +0 -34
  80. package/dist/commands/tool.js.map +0 -1
  81. package/dist/data/standardSlackEmoji.d.ts +0 -2
  82. package/dist/data/standardSlackEmoji.d.ts.map +0 -1
  83. package/dist/data/standardSlackEmoji.js +0 -1978
  84. package/dist/data/standardSlackEmoji.js.map +0 -1
  85. package/dist/data/standardSlackEmoji.json +0 -1974
  86. package/dist/deploy.d.ts +0 -3
  87. package/dist/deploy.d.ts.map +0 -1
  88. package/dist/deploy.js +0 -124
  89. package/dist/deploy.js.map +0 -1
  90. package/dist/generate.d.ts +0 -3
  91. package/dist/generate.d.ts.map +0 -1
  92. package/dist/generate.js +0 -282
  93. package/dist/generate.js.map +0 -1
  94. package/dist/init.d.ts +0 -3
  95. package/dist/init.d.ts.map +0 -1
  96. package/dist/init.js +0 -98
  97. package/dist/init.js.map +0 -1
  98. package/dist/integrate.d.ts +0 -3
  99. package/dist/integrate.d.ts.map +0 -1
  100. package/dist/integrate.js +0 -214
  101. package/dist/integrate.js.map +0 -1
  102. package/dist/nonInteractive.d.ts +0 -20
  103. package/dist/nonInteractive.d.ts.map +0 -1
  104. package/dist/nonInteractive.js +0 -60
  105. package/dist/nonInteractive.js.map +0 -1
  106. package/dist/perf.d.ts +0 -9
  107. package/dist/perf.d.ts.map +0 -1
  108. package/dist/perf.js +0 -59
  109. package/dist/perf.js.map +0 -1
  110. package/dist/providers/codegen.test.d.ts +0 -2
  111. package/dist/providers/codegen.test.d.ts.map +0 -1
  112. package/dist/providers/codegen.test.js +0 -45
  113. package/dist/providers/codegen.test.js.map +0 -1
  114. package/dist/providers/python/PythonProvider.d.ts +0 -51
  115. package/dist/providers/python/PythonProvider.d.ts.map +0 -1
  116. package/dist/providers/python/PythonProvider.js +0 -414
  117. package/dist/providers/python/PythonProvider.js.map +0 -1
  118. package/dist/providers/python/PythonProvider.test.d.ts +0 -2
  119. package/dist/providers/python/PythonProvider.test.d.ts.map +0 -1
  120. package/dist/providers/python/PythonProvider.test.js +0 -169
  121. package/dist/providers/python/PythonProvider.test.js.map +0 -1
  122. package/dist/providers/python/preparePythonCodegenData.d.ts +0 -139
  123. package/dist/providers/python/preparePythonCodegenData.d.ts.map +0 -1
  124. package/dist/providers/python/preparePythonCodegenData.js +0 -452
  125. package/dist/providers/python/preparePythonCodegenData.js.map +0 -1
  126. package/dist/providers/python/pythonTemplateEngine.d.ts +0 -3
  127. package/dist/providers/python/pythonTemplateEngine.d.ts.map +0 -1
  128. package/dist/providers/python/pythonTemplateEngine.js +0 -30
  129. package/dist/providers/python/pythonTemplateEngine.js.map +0 -1
  130. package/dist/providers/shared/shellUtils.d.ts +0 -2
  131. package/dist/providers/shared/shellUtils.d.ts.map +0 -1
  132. package/dist/providers/shared/shellUtils.js +0 -25
  133. package/dist/providers/shared/shellUtils.js.map +0 -1
  134. package/dist/providers/typescript/attioProjection.d.ts +0 -50
  135. package/dist/providers/typescript/attioProjection.d.ts.map +0 -1
  136. package/dist/providers/typescript/attioProjection.js +0 -358
  137. package/dist/providers/typescript/attioProjection.js.map +0 -1
  138. package/dist/providers/typescript/modules/cursor/CursorModule.d.ts +0 -20
  139. package/dist/providers/typescript/modules/cursor/CursorModule.d.ts.map +0 -1
  140. package/dist/providers/typescript/modules/cursor/CursorModule.js +0 -27
  141. package/dist/providers/typescript/modules/cursor/CursorModule.js.map +0 -1
  142. package/dist/providers/typescript/prepareCodegenData.d.ts +0 -166
  143. package/dist/providers/typescript/prepareCodegenData.d.ts.map +0 -1
  144. package/dist/providers/typescript/prepareCodegenData.js +0 -1431
  145. package/dist/providers/typescript/prepareCodegenData.js.map +0 -1
  146. package/dist/providers/typescript/prepareCodegenData.test.d.ts +0 -2
  147. package/dist/providers/typescript/prepareCodegenData.test.d.ts.map +0 -1
  148. package/dist/providers/typescript/prepareCodegenData.test.js +0 -54
  149. package/dist/providers/typescript/prepareCodegenData.test.js.map +0 -1
  150. package/dist/providers/typescript/projectedTypes.d.ts +0 -11
  151. package/dist/providers/typescript/projectedTypes.d.ts.map +0 -1
  152. package/dist/providers/typescript/projectedTypes.js +0 -53
  153. package/dist/providers/typescript/projectedTypes.js.map +0 -1
  154. package/dist/providers/typescript/projectionPrinter.d.ts +0 -26
  155. package/dist/providers/typescript/projectionPrinter.d.ts.map +0 -1
  156. package/dist/providers/typescript/projectionPrinter.js +0 -110
  157. package/dist/providers/typescript/projectionPrinter.js.map +0 -1
  158. package/dist/providers/typescript/replayLogDedupe.d.ts +0 -6
  159. package/dist/providers/typescript/replayLogDedupe.d.ts.map +0 -1
  160. package/dist/providers/typescript/replayLogDedupe.js +0 -156
  161. package/dist/providers/typescript/replayLogDedupe.js.map +0 -1
  162. package/dist/providers/typescript/triggerPayloads.d.ts +0 -7
  163. package/dist/providers/typescript/triggerPayloads.d.ts.map +0 -1
  164. package/dist/providers/typescript/triggerPayloads.js +0 -60
  165. package/dist/providers/typescript/triggerPayloads.js.map +0 -1
  166. package/dist/providers/typescript/triggerTypeRegistry.d.ts +0 -7
  167. package/dist/providers/typescript/triggerTypeRegistry.d.ts.map +0 -1
  168. package/dist/providers/typescript/triggerTypeRegistry.js +0 -198
  169. package/dist/providers/typescript/triggerTypeRegistry.js.map +0 -1
  170. package/dist/run.d.ts +0 -3
  171. package/dist/run.d.ts.map +0 -1
  172. package/dist/run.js +0 -72
  173. package/dist/run.js.map +0 -1
  174. package/dist/sampleEventCache.d.ts +0 -9
  175. package/dist/sampleEventCache.d.ts.map +0 -1
  176. package/dist/sampleEventCache.js +0 -47
  177. package/dist/sampleEventCache.js.map +0 -1
  178. package/dist/sampleEventId.d.ts +0 -9
  179. package/dist/sampleEventId.d.ts.map +0 -1
  180. package/dist/sampleEventId.js +0 -16
  181. package/dist/sampleEventId.js.map +0 -1
  182. package/dist/shared/ApiRoutes.d.ts +0 -348
  183. package/dist/shared/ApiRoutes.d.ts.map +0 -1
  184. package/dist/shared/ApiRoutes.js +0 -325
  185. package/dist/shared/ApiRoutes.js.map +0 -1
  186. package/dist/shared/ApprovalTypes.d.ts +0 -29
  187. package/dist/shared/ApprovalTypes.d.ts.map +0 -1
  188. package/dist/shared/ApprovalTypes.js +0 -8
  189. package/dist/shared/ApprovalTypes.js.map +0 -1
  190. package/dist/shared/ClientBoundTools.d.ts +0 -37
  191. package/dist/shared/ClientBoundTools.d.ts.map +0 -1
  192. package/dist/shared/ClientBoundTools.js +0 -37
  193. package/dist/shared/ClientBoundTools.js.map +0 -1
  194. package/dist/shared/Configs.d.ts +0 -488
  195. package/dist/shared/Configs.d.ts.map +0 -1
  196. package/dist/shared/Configs.js +0 -785
  197. package/dist/shared/Configs.js.map +0 -1
  198. package/dist/shared/DonatedState.d.ts +0 -5
  199. package/dist/shared/DonatedState.d.ts.map +0 -1
  200. package/dist/shared/DonatedState.js +0 -13
  201. package/dist/shared/DonatedState.js.map +0 -1
  202. package/dist/shared/Entities.d.ts +0 -8
  203. package/dist/shared/Entities.d.ts.map +0 -1
  204. package/dist/shared/Entities.js +0 -9
  205. package/dist/shared/Entities.js.map +0 -1
  206. package/dist/shared/FrontendRoutes.d.ts +0 -54
  207. package/dist/shared/FrontendRoutes.d.ts.map +0 -1
  208. package/dist/shared/FrontendRoutes.js +0 -54
  209. package/dist/shared/FrontendRoutes.js.map +0 -1
  210. package/dist/shared/Integrations.d.ts +0 -235
  211. package/dist/shared/Integrations.d.ts.map +0 -1
  212. package/dist/shared/Integrations.js +0 -143
  213. package/dist/shared/Integrations.js.map +0 -1
  214. package/dist/shared/InvalidationKeys.d.ts +0 -53
  215. package/dist/shared/InvalidationKeys.d.ts.map +0 -1
  216. package/dist/shared/InvalidationKeys.js +0 -166
  217. package/dist/shared/InvalidationKeys.js.map +0 -1
  218. package/dist/shared/ModelEvents.d.ts +0 -176
  219. package/dist/shared/ModelEvents.d.ts.map +0 -1
  220. package/dist/shared/ModelEvents.js +0 -29
  221. package/dist/shared/ModelEvents.js.map +0 -1
  222. package/dist/shared/Notifications.d.ts +0 -43
  223. package/dist/shared/Notifications.d.ts.map +0 -1
  224. package/dist/shared/Notifications.js +0 -6
  225. package/dist/shared/Notifications.js.map +0 -1
  226. package/dist/shared/RunHistoryTypes.d.ts +0 -95
  227. package/dist/shared/RunHistoryTypes.d.ts.map +0 -1
  228. package/dist/shared/RunHistoryTypes.js +0 -11
  229. package/dist/shared/RunHistoryTypes.js.map +0 -1
  230. package/dist/shared/SentNotifications.d.ts +0 -30
  231. package/dist/shared/SentNotifications.d.ts.map +0 -1
  232. package/dist/shared/SentNotifications.js +0 -13
  233. package/dist/shared/SentNotifications.js.map +0 -1
  234. package/dist/shared/SocketEvents.d.ts +0 -49
  235. package/dist/shared/SocketEvents.d.ts.map +0 -1
  236. package/dist/shared/SocketEvents.js +0 -53
  237. package/dist/shared/SocketEvents.js.map +0 -1
  238. package/dist/shared/Survey.d.ts +0 -10
  239. package/dist/shared/Survey.d.ts.map +0 -1
  240. package/dist/shared/Survey.js +0 -2
  241. package/dist/shared/Survey.js.map +0 -1
  242. package/dist/shared/TicketSystem.d.ts +0 -154
  243. package/dist/shared/TicketSystem.d.ts.map +0 -1
  244. package/dist/shared/TicketSystem.js +0 -21
  245. package/dist/shared/TicketSystem.js.map +0 -1
  246. package/dist/shared/ToolDisplayUtils.d.ts +0 -30
  247. package/dist/shared/ToolDisplayUtils.d.ts.map +0 -1
  248. package/dist/shared/ToolDisplayUtils.js +0 -1163
  249. package/dist/shared/ToolDisplayUtils.js.map +0 -1
  250. package/dist/shared/ToolsTypes.d.ts +0 -18
  251. package/dist/shared/ToolsTypes.d.ts.map +0 -1
  252. package/dist/shared/ToolsTypes.js +0 -2
  253. package/dist/shared/ToolsTypes.js.map +0 -1
  254. package/dist/shared/types.d.ts +0 -1732
  255. package/dist/shared/types.d.ts.map +0 -1
  256. package/dist/shared/types.js +0 -17
  257. package/dist/shared/types.js.map +0 -1
  258. package/dist/test.d.ts +0 -3
  259. package/dist/test.d.ts.map +0 -1
  260. package/dist/test.js +0 -82
  261. package/dist/test.js.map +0 -1
  262. package/dist/triggerParseDetail.d.ts +0 -8
  263. package/dist/triggerParseDetail.d.ts.map +0 -1
  264. package/dist/triggerParseDetail.js +0 -30
  265. package/dist/triggerParseDetail.js.map +0 -1
  266. package/dist/util.d.ts +0 -3
  267. package/dist/util.d.ts.map +0 -1
  268. package/dist/util.js +0 -5
  269. package/dist/util.js.map +0 -1
  270. package/templates/typescript/codegen/.impeccable/hook.cache.json +0 -1
@@ -1,1431 +0,0 @@
1
- import { IntegrationType, ToolDefinitions, toolsWithIntegrationId } from "terse-types";
2
- import { z } from "zod";
3
- function toPascalCase(value) {
4
- return value
5
- .replace(/[^a-zA-Z0-9]+/g, " ")
6
- .trim()
7
- .split(/\s+/)
8
- .filter(Boolean)
9
- .map(word => word.charAt(0).toUpperCase() + word.slice(1))
10
- .join("");
11
- }
12
- export function escapeString(value) {
13
- return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
14
- }
15
- function toGeneratedIdentifier(raw, fallback) {
16
- let name = toPascalCase(raw || fallback);
17
- if (!name)
18
- name = fallback;
19
- if (/^\d/.test(name))
20
- name = `_${name}`;
21
- return name;
22
- }
23
- export function toCamelCase(value) {
24
- const pascal = toPascalCase(value);
25
- return pascal.charAt(0).toLowerCase() + pascal.slice(1);
26
- }
27
- function toolNameToInterfaceName(name) {
28
- return (name
29
- .split("_")
30
- .map(word => word.charAt(0).toUpperCase() + word.slice(1))
31
- .join("") + "Params");
32
- }
33
- function buildResourceClassContext(className, fields, staticNameField, items) {
34
- const constructorParams = fields.map(field => `public readonly ${field.classField}: ${field.type}`).join(", ");
35
- const entries = [];
36
- const usedNames = new Set();
37
- for (const item of items) {
38
- const source = item;
39
- let name = toPascalCase(String(source[staticNameField] || "Unknown"));
40
- if (!name || /^\d/.test(name))
41
- name = `_${name}`;
42
- while (usedNames.has(name))
43
- name += "_";
44
- usedNames.add(name);
45
- const argsText = fields
46
- .map(field => {
47
- const value = source[field.sourceField];
48
- if (typeof value === "number")
49
- return String(value);
50
- return `"${escapeString(String(value ?? ""))}"`;
51
- })
52
- .join(", ");
53
- entries.push({
54
- staticName: name,
55
- argsText
56
- });
57
- }
58
- return {
59
- className,
60
- constructorParams,
61
- items: entries
62
- };
63
- }
64
- function sectionData(imports, data) {
65
- return { imports: new Set(imports), data };
66
- }
67
- function isProbablyAttioMultiValue(attr) {
68
- const slug = (attr.api_slug || "").toLowerCase();
69
- const type = (attr.type || "").toLowerCase();
70
- return (type.includes("multi") ||
71
- type.includes("array") ||
72
- type.includes("list") ||
73
- slug === "email_addresses" ||
74
- slug === "domains" ||
75
- slug === "phone_numbers" ||
76
- slug === "social_profiles" ||
77
- slug === "links" ||
78
- slug === "tags" ||
79
- slug.endsWith("_addresses") ||
80
- slug.endsWith("_ids"));
81
- }
82
- function attioAttributeBaseType(attr) {
83
- const slug = (attr.api_slug || "").toLowerCase();
84
- const type = (attr.type || "").toLowerCase();
85
- if (type.includes("checkbox") || type.includes("boolean"))
86
- return "boolean";
87
- if (type.includes("number") || type.includes("currency") || type.includes("rating") || type.includes("percent")) {
88
- return "number";
89
- }
90
- if (type.includes("date") || type.includes("time"))
91
- return "string";
92
- if (type.includes("email") ||
93
- type.includes("domain") ||
94
- type.includes("phone") ||
95
- type.includes("url") ||
96
- type.includes("select") ||
97
- type.includes("status") ||
98
- type.includes("text") ||
99
- type.includes("string") ||
100
- type.includes("name")) {
101
- return "string";
102
- }
103
- if (type.includes("location") || type.includes("address") || type.includes("reference") || type.includes("record") || type.includes("actor")) {
104
- return "Record<string, unknown>";
105
- }
106
- if (slug === "email_addresses" || slug === "domains" || slug === "phone_numbers" || slug === "name") {
107
- return "string";
108
- }
109
- return "unknown";
110
- }
111
- function attioValueTypeLines(objects = [], lists = []) {
112
- const lines = [
113
- "export type AttioSelectOption = {",
114
- " id: string",
115
- " title: string",
116
- " is_archived: boolean",
117
- "}",
118
- "",
119
- 'export type AttioActorReferenceInput = string | { workspace_member_email_address: string } | { referenced_actor_type: "workspace-member"; referenced_actor_id: string }',
120
- "export type AttioRecordReferenceInput = { target_object: string; target_record_id: string } | Record<string, unknown>",
121
- "export type AttioActorReference = { referenced_actor_type: string; referenced_actor_id: string | null }",
122
- "export type AttioRecordReferenceValue = { target_object: string; target_record_id: string }",
123
- "export type AttioCurrencyValue = { currency_value: number; currency_code: string | null }"
124
- ];
125
- const usedConstNames = new Set();
126
- for (const object of [...objects, ...lists]) {
127
- for (const attr of object.attributes) {
128
- if (!attr.options || attr.options.length === 0)
129
- continue;
130
- let attrName = toGeneratedIdentifier(attr.title || attr.api_slug, "Attribute");
131
- if (attrName.startsWith(object.staticName) && attrName.length > object.staticName.length) {
132
- attrName = attrName.slice(object.staticName.length);
133
- }
134
- let constName = `Attio${object.staticName}${attrName}`;
135
- while (usedConstNames.has(constName))
136
- constName += "_";
137
- usedConstNames.add(constName);
138
- lines.push("", `export const ${constName} = {`);
139
- const usedKeys = new Set();
140
- for (const title of attr.options) {
141
- let key = toGeneratedIdentifier(title, "Option");
142
- while (usedKeys.has(key))
143
- key += "_";
144
- usedKeys.add(key);
145
- lines.push(` ${key}: "${escapeString(title)}",`);
146
- }
147
- lines.push("} as const");
148
- }
149
- }
150
- return lines;
151
- }
152
- function attioIsMultiValue(attr) {
153
- if (typeof attr.is_multiselect === "boolean")
154
- return attr.is_multiselect;
155
- return isProbablyAttioMultiValue(attr);
156
- }
157
- function attioAttributeInputBaseType(attr) {
158
- const type = (attr.type || "").toLowerCase();
159
- if (type.includes("actor"))
160
- return "AttioActorReferenceInput";
161
- if (type.includes("record") && type.includes("reference"))
162
- return "AttioRecordReferenceInput";
163
- if ((type.includes("select") || type.includes("status")) && attr.options && attr.options.length > 0) {
164
- return renderStringLiteralUnion(attr.options);
165
- }
166
- return attioAttributeBaseType(attr);
167
- }
168
- function attioAttributeRecordBaseType(attr) {
169
- const type = (attr.type || "").toLowerCase();
170
- if (type.includes("select") || type.includes("status"))
171
- return "AttioSelectOption";
172
- if (type.includes("actor"))
173
- return "AttioActorReference";
174
- if (type.includes("record") && type.includes("reference"))
175
- return "AttioRecordReferenceValue";
176
- if (type.includes("currency"))
177
- return "AttioCurrencyValue";
178
- return attioAttributeBaseType(attr);
179
- }
180
- function attioAttributeInputTsType(attr) {
181
- const baseType = attioAttributeInputBaseType(attr);
182
- if (!attioIsMultiValue(attr))
183
- return baseType;
184
- return baseType.includes("|") ? `(${baseType})[]` : `${baseType}[]`;
185
- }
186
- function attioAttributeRecordTsType(attr) {
187
- const baseType = attioAttributeRecordBaseType(attr);
188
- if (!attioIsMultiValue(attr))
189
- return baseType;
190
- return baseType.includes("|") ? `(${baseType})[]` : `${baseType}[]`;
191
- }
192
- function renderAttioObjectValueShape(attributes, mode) {
193
- if (attributes.length === 0)
194
- return "Record<string, unknown>";
195
- const lines = attributes.map(attr => {
196
- const valueType = mode === "input" ? attioAttributeInputTsType(attr) : attioAttributeRecordTsType(attr);
197
- return ` "${escapeString(attr.api_slug || "")}"?: ${valueType}`;
198
- });
199
- return `{\n${lines.join("\n")}\n}`;
200
- }
201
- function toolIntegrationToIntegrationType(toolIntegration) {
202
- return toolIntegration;
203
- }
204
- function renderStringLiteralUnion(values) {
205
- if (values.length === 0)
206
- return "never";
207
- return values.map(value => `"${escapeString(value)}"`).join(" | ");
208
- }
209
- function buildSkillToolTypeForIntegration(tools, integrationType) {
210
- const toolNames = tools
211
- .filter(tool => toolIntegrationToIntegrationType(tool.integration.toLowerCase()) === integrationType)
212
- .filter(tool => !tool.isReadOnly || tool.supportsApproval)
213
- .map(tool => tool.name)
214
- .sort();
215
- return renderStringLiteralUnion(toolNames);
216
- }
217
- function prepareGitHubSection(inst, tools) {
218
- if (!inst)
219
- return sectionData([]);
220
- const imports = [
221
- "GitHubConfig",
222
- "GitHubEventType",
223
- "TypedTrigger",
224
- "TypedSkill",
225
- "GithubPROpenedTrigger",
226
- "GithubPRMergedTrigger",
227
- "GithubPRClosedTrigger",
228
- "GithubPRSynchronizedTrigger",
229
- "GithubPRTrigger",
230
- "GithubPushTrigger",
231
- "GithubIssueCommentCreatedTrigger",
232
- "GithubTrigger"
233
- ];
234
- const skillToolType = buildSkillToolTypeForIntegration(tools, "github");
235
- const repositoriesWithFullName = inst.repositories.map(repo => {
236
- const owner = repo.owner || "UnknownOwner";
237
- const fullName = repo.owner && repo.name ? `${repo.owner}/${repo.name}` : repo.name;
238
- return { ...repo, owner, fullName };
239
- });
240
- const ownerEntries = new Map();
241
- const usedOwnerNames = new Set();
242
- for (const repo of repositoriesWithFullName) {
243
- if (!ownerEntries.has(repo.owner)) {
244
- let ownerStaticName = toGeneratedIdentifier(repo.owner, "UnknownOwner");
245
- while (usedOwnerNames.has(ownerStaticName))
246
- ownerStaticName += "_";
247
- usedOwnerNames.add(ownerStaticName);
248
- ownerEntries.set(repo.owner, { staticName: ownerStaticName, repos: [] });
249
- }
250
- ownerEntries.get(repo.owner).repos.push(repo);
251
- }
252
- const owners = Array.from(ownerEntries.entries()).map(([name, data]) => ({
253
- name,
254
- staticName: data.staticName
255
- }));
256
- const repoGroups = Array.from(ownerEntries.values()).map(group => {
257
- const usedRepoNames = new Set();
258
- return {
259
- ownerStaticName: group.staticName,
260
- repos: group.repos.map(repo => {
261
- let staticName = toGeneratedIdentifier(repo.name, "Repos");
262
- while (usedRepoNames.has(staticName))
263
- staticName += "_";
264
- usedRepoNames.add(staticName);
265
- return {
266
- id: repo.id,
267
- name: repo.name,
268
- fullName: repo.fullName,
269
- staticName
270
- };
271
- })
272
- };
273
- });
274
- return sectionData(imports, {
275
- id: inst.integration.id,
276
- skillToolType,
277
- owners,
278
- repoGroups
279
- });
280
- }
281
- function prepareGmailSection(inst, tools) {
282
- if (!inst)
283
- return sectionData([]);
284
- return sectionData(["GmailConfig", "GmailOutputConfig", "GmailDraftOutputConfig", "TypedSkill", "TypedTrigger", "GmailEventType", "GmailTrigger"], {
285
- id: inst.id,
286
- skillToolType: buildSkillToolTypeForIntegration(tools, "gmail")
287
- });
288
- }
289
- function prepareSlackSection(inst, tools) {
290
- if (!inst)
291
- return sectionData([]);
292
- return sectionData(["SlackAppMentionTrigger", "SlackConfig", "SlackMessageTrigger", "SlackOutputConfig", "SlackReactionAddedTrigger", "TypedSkill", "SlackEventType", "TypedTrigger", "SlackTrigger"], {
293
- id: inst.id,
294
- skillToolType: buildSkillToolTypeForIntegration(tools, "slack"),
295
- channelClass: buildResourceClassContext("SlackChannel", [
296
- { classField: "channelId", type: "string", sourceField: "id" },
297
- { classField: "name", type: "string", sourceField: "name" }
298
- ], "name", inst.channels),
299
- userClass: buildResourceClassContext("SlackUser", [
300
- { classField: "userId", type: "string", sourceField: "id" },
301
- { classField: "name", type: "string", sourceField: "name" }
302
- ], "name", inst.users)
303
- });
304
- }
305
- function prepareLinearSection(inst, tools) {
306
- if (!inst)
307
- return sectionData([]);
308
- return sectionData([
309
- "LinearInputConfig",
310
- "LinearOutputConfig",
311
- "TypedSkill",
312
- "TypedTrigger",
313
- "LinearEventType",
314
- "LinearIssueCreatedTrigger",
315
- "LinearIssueUpdatedTrigger",
316
- "LinearCommentCreatedTrigger",
317
- "LinearTrigger"
318
- ], {
319
- id: inst.id,
320
- skillToolType: buildSkillToolTypeForIntegration(tools, "linear"),
321
- teamClass: buildResourceClassContext("LinearTeam", [
322
- { classField: "teamId", type: "string", sourceField: "id" },
323
- { classField: "name", type: "string", sourceField: "name" },
324
- { classField: "key", type: "string", sourceField: "key" }
325
- ], "name", inst.teams),
326
- projectClass: buildResourceClassContext("LinearProject", [
327
- { classField: "projectId", type: "string", sourceField: "id" },
328
- { classField: "name", type: "string", sourceField: "name" }
329
- ], "name", inst.projects)
330
- });
331
- }
332
- function prepareNotionSection(inst, tools) {
333
- if (!inst)
334
- return sectionData([]);
335
- return sectionData(["NotionConfig", "TypedSkill"], {
336
- id: inst.id,
337
- skillToolType: buildSkillToolTypeForIntegration(tools, "notion"),
338
- databaseClass: buildResourceClassContext("NotionDatabase", [
339
- { classField: "databaseId", type: "string", sourceField: "id" },
340
- { classField: "title", type: "string", sourceField: "title" }
341
- ], "title", inst.databases),
342
- pageClass: buildResourceClassContext("NotionPage", [
343
- { classField: "pageId", type: "string", sourceField: "id" },
344
- { classField: "title", type: "string", sourceField: "title" }
345
- ], "title", inst.pages)
346
- });
347
- }
348
- function preparePosthogSection(inst, tools) {
349
- if (!inst)
350
- return sectionData([]);
351
- return sectionData(["PosthogConfig", "TypedSkill"], {
352
- id: inst.id,
353
- skillToolType: buildSkillToolTypeForIntegration(tools, "posthog"),
354
- projectClass: buildResourceClassContext("PosthogProject", [
355
- { classField: "projectId", type: "string", sourceField: "id" },
356
- { classField: "name", type: "string", sourceField: "name" }
357
- ], "name", inst.projects),
358
- eventNames: [...new Set(inst.projects.flatMap(project => project.events))]
359
- });
360
- }
361
- function prepareDatadogSection(inst, tools) {
362
- if (!inst)
363
- return sectionData([]);
364
- return sectionData(["DatadogConfig", "TypedSkill"], {
365
- id: inst.id,
366
- skillToolType: buildSkillToolTypeForIntegration(tools, "datadog"),
367
- indexClass: buildResourceClassContext("DatadogIndex", [{ classField: "name", type: "string", sourceField: "name" }], "name", inst.indexes)
368
- });
369
- }
370
- function prepareLaunchDarklySection(inst, tools) {
371
- if (!inst)
372
- return sectionData([]);
373
- return sectionData(["LaunchDarklyConfig", "TypedSkill"], {
374
- id: inst.id,
375
- skillToolType: buildSkillToolTypeForIntegration(tools, "launchdarkly"),
376
- projectClass: buildResourceClassContext("LaunchDarklyProject", [
377
- { classField: "projectKey", type: "string", sourceField: "key" },
378
- { classField: "name", type: "string", sourceField: "name" }
379
- ], "name", inst.projects)
380
- });
381
- }
382
- function prepareWorkOSSection(inst, tools) {
383
- if (!inst)
384
- return sectionData([]);
385
- return sectionData([
386
- "WorkOSInputConfig",
387
- "WorkOSOutputConfig",
388
- "WorkOSEventType",
389
- "TypedSkill",
390
- "TypedTrigger",
391
- "WorkOSTrigger",
392
- "WorkOSUserCreatedTrigger",
393
- "WorkOSUserUpdatedTrigger",
394
- "WorkOSUserDeletedTrigger",
395
- "WorkOSUserTrigger",
396
- "WorkOSOrganizationMembershipCreatedTrigger",
397
- "WorkOSOrganizationMembershipUpdatedTrigger",
398
- "WorkOSOrganizationMembershipDeletedTrigger",
399
- "WorkOSMembershipTrigger",
400
- "WorkOSInvitationCreatedTrigger",
401
- "WorkOSInvitationAcceptedTrigger",
402
- "WorkOSInvitationResentTrigger",
403
- "WorkOSInvitationRevokedTrigger",
404
- "WorkOSInvitationTrigger",
405
- "WorkOSOrganizationTrigger"
406
- ], {
407
- id: inst.id,
408
- skillToolType: buildSkillToolTypeForIntegration(tools, "workos")
409
- });
410
- }
411
- function buildGeneratedAttioObjects(inst) {
412
- const objects = inst?.objects ?? [];
413
- const usedNames = new Set();
414
- return objects.map(object => {
415
- let staticName = toGeneratedIdentifier(object.singular_noun || object.api_slug || "Object", "AttioObject");
416
- while (usedNames.has(staticName))
417
- staticName += "_";
418
- usedNames.add(staticName);
419
- const attributes = (object.attributes || []).filter((attr) => !!attr.api_slug);
420
- return {
421
- staticName,
422
- apiSlug: object.api_slug,
423
- objectId: object.id.object_id,
424
- singularNoun: object.singular_noun,
425
- attributeSource: renderAttioAttributeSource(attributes),
426
- recordValuesType: renderAttioObjectValueShape(attributes, "record"),
427
- inputValuesType: renderAttioObjectValueShape(attributes, "input"),
428
- attributes
429
- };
430
- });
431
- }
432
- function buildGeneratedAttioLists(inst) {
433
- const lists = inst?.lists ?? [];
434
- const usedNames = new Set();
435
- return lists.map(list => {
436
- let staticName = toGeneratedIdentifier(list.name || list.api_slug || "List", "AttioList");
437
- while (usedNames.has(staticName))
438
- staticName += "_";
439
- usedNames.add(staticName);
440
- const attributes = (list.attributes || []).filter((attr) => !!attr.api_slug);
441
- const parentObject = Array.isArray(list.parent_object) ? list.parent_object[0] || "" : list.parent_object || "";
442
- return {
443
- staticName,
444
- apiSlug: list.api_slug,
445
- name: list.name,
446
- listId: list.id.list_id,
447
- parentObject,
448
- attributeSource: renderAttioAttributeSource(attributes),
449
- entryValuesType: renderAttioObjectValueShape(attributes, "input"),
450
- entryRecordValuesType: renderAttioObjectValueShape(attributes, "record"),
451
- attributes
452
- };
453
- });
454
- }
455
- function renderAttioAttributeSource(attributes) {
456
- if (attributes.length === 0)
457
- return "[]";
458
- return `[\n${attributes
459
- .map(attr => {
460
- const fields = [
461
- `apiSlug: "${escapeString(attr.api_slug)}"`,
462
- attr.title ? `title: "${escapeString(attr.title)}"` : undefined,
463
- attr.type ? `type: "${escapeString(attr.type)}"` : undefined,
464
- attr.is_required !== undefined ? `isRequired: ${attr.is_required ? "true" : "false"}` : undefined,
465
- attr.is_unique !== undefined ? `isUnique: ${attr.is_unique ? "true" : "false"}` : undefined
466
- ]
467
- .filter(Boolean)
468
- .join(", ");
469
- return ` { ${fields} }`;
470
- })
471
- .join(",\n")}\n ]`;
472
- }
473
- function buildAttioRuntimeLines(objects, lists) {
474
- const lines = [];
475
- lines.push("const __attioMetadataKeys = new Set([");
476
- lines.push(' "active_from",');
477
- lines.push(' "active_until",');
478
- lines.push(' "attribute_type",');
479
- lines.push(' "created_by_actor",');
480
- lines.push("])");
481
- lines.push("");
482
- lines.push("const __attioMultiValueAttributeSlugsByObject: Record<string, readonly string[]> = {");
483
- for (const object of objects) {
484
- const multiValueSlugs = object.attributes
485
- .filter(attioIsMultiValue)
486
- .map(attr => `"${escapeString(attr.api_slug)}"`)
487
- .join(", ");
488
- lines.push(` "${escapeString(object.apiSlug)}": [${multiValueSlugs}],`);
489
- }
490
- lines.push("}");
491
- lines.push("");
492
- lines.push("const __attioObjectSlugByObjectId: Record<string, string> = {");
493
- for (const object of objects) {
494
- lines.push(` "${escapeString(object.objectId)}": "${escapeString(object.apiSlug)}",`);
495
- }
496
- lines.push("}");
497
- lines.push("");
498
- lines.push("function __flattenAttioLeafValue(value: unknown): unknown {");
499
- lines.push(" if (value === null || value === undefined) return value");
500
- lines.push(" if (Array.isArray(value)) return value.map(entry => __flattenAttioLeafValue(entry))");
501
- lines.push(' if (typeof value !== "object") return value');
502
- lines.push(" const rawObject = value as Record<string, unknown>");
503
- lines.push(' if (rawObject.attribute_type === "status") return __toAttioSelectOption(rawObject.status)');
504
- lines.push(' if (rawObject.attribute_type === "select") return __toAttioSelectOption(rawObject.option)');
505
- lines.push(' if (typeof rawObject.full_name === "string") return rawObject.full_name');
506
- lines.push(' if (typeof rawObject.email_address === "string") return rawObject.email_address');
507
- lines.push(' if (typeof rawObject.domain === "string") return rawObject.domain');
508
- lines.push(' if (typeof rawObject.phone_number === "string") return rawObject.phone_number');
509
- lines.push(' if ("value" in rawObject) return __flattenAttioLeafValue(rawObject.value)');
510
- lines.push(" const dataEntries = Object.entries(rawObject).filter(([key]) => !__attioMetadataKeys.has(key))");
511
- lines.push(" if (dataEntries.length === 0) return rawObject");
512
- lines.push(" if (dataEntries.length === 1) return __flattenAttioLeafValue(dataEntries[0][1])");
513
- lines.push(" return Object.fromEntries(dataEntries.map(([key, entryValue]) => [key, __flattenAttioLeafValue(entryValue)]))");
514
- lines.push("}");
515
- lines.push("");
516
- lines.push("function __toAttioSelectOption(option: unknown): unknown {");
517
- lines.push(' if (!option || typeof option !== "object") return option');
518
- lines.push(" const rawOption = option as Record<string, unknown>");
519
- lines.push(' const rawId = rawOption.id && typeof rawOption.id === "object" ? (rawOption.id as Record<string, unknown>) : undefined');
520
- lines.push(" const id = rawId?.status_id ?? rawId?.option_id ?? rawOption.id");
521
- lines.push(" return {");
522
- lines.push(' id: typeof id === "string" ? id : "",');
523
- lines.push(' title: typeof rawOption.title === "string" ? rawOption.title : "",');
524
- lines.push(" is_archived: rawOption.is_archived === true,");
525
- lines.push(" } satisfies AttioSelectOption");
526
- lines.push("}");
527
- lines.push("");
528
- lines.push("function __flattenAttioAttributeValue(rawValue: unknown, preferArray: boolean): unknown {");
529
- lines.push(" if (!Array.isArray(rawValue)) return __flattenAttioLeafValue(rawValue)");
530
- lines.push(" const flattened = rawValue.map(entry => __flattenAttioLeafValue(entry)).filter(entry => entry !== undefined)");
531
- lines.push(" return preferArray ? flattened : flattened[0]");
532
- lines.push("}");
533
- lines.push("");
534
- lines.push("function __isAttioMultiValueAttribute(objectSlug: string, attributeSlug: string): boolean {");
535
- lines.push(" return (__attioMultiValueAttributeSlugsByObject[objectSlug] || []).includes(attributeSlug)");
536
- lines.push("}");
537
- lines.push("");
538
- lines.push("function __getAttioRecordValues<TValues extends Record<string, unknown>>(objectSlug: string, record: unknown): TValues {");
539
- lines.push(' const rawValues = record && typeof record === "object" ? (record as { values?: unknown }).values : undefined');
540
- lines.push(' if (!rawValues || typeof rawValues !== "object" || Array.isArray(rawValues)) return {} as TValues');
541
- lines.push(" const flattenedValues: Record<string, unknown> = {}");
542
- lines.push(" for (const [attributeSlug, rawValue] of Object.entries(rawValues)) {");
543
- lines.push(" flattenedValues[attributeSlug] = __flattenAttioAttributeValue(rawValue, __isAttioMultiValueAttribute(objectSlug, attributeSlug))");
544
- lines.push(" }");
545
- lines.push(" return flattenedValues as TValues");
546
- lines.push("}");
547
- lines.push("");
548
- lines.push("const __attioMultiValueEntrySlugsByList: Record<string, readonly string[]> = {");
549
- for (const list of lists) {
550
- const multiValueSlugs = list.attributes
551
- .filter(attioIsMultiValue)
552
- .map(attr => `"${escapeString(attr.api_slug)}"`)
553
- .join(", ");
554
- lines.push(` "${escapeString(list.apiSlug)}": [${multiValueSlugs}],`);
555
- lines.push(` "${escapeString(list.listId)}": [${multiValueSlugs}],`);
556
- }
557
- lines.push("}");
558
- lines.push("");
559
- lines.push("function __getAttioEntryValues<TValues extends Record<string, unknown>>(listKey: string, rawEntryValues: unknown): TValues {");
560
- lines.push(' if (!rawEntryValues || typeof rawEntryValues !== "object" || Array.isArray(rawEntryValues)) return {} as TValues');
561
- lines.push(" const flattenedValues: Record<string, unknown> = {}");
562
- lines.push(" const multiValueSlugs = __attioMultiValueEntrySlugsByList[listKey] || []");
563
- lines.push(" for (const [attributeSlug, rawValue] of Object.entries(rawEntryValues)) {");
564
- lines.push(" flattenedValues[attributeSlug] = __flattenAttioAttributeValue(rawValue, multiValueSlugs.includes(attributeSlug))");
565
- lines.push(" }");
566
- lines.push(" return flattenedValues as TValues");
567
- lines.push("}");
568
- lines.push("");
569
- lines.push("function __requireAttioListParentObject(list: unknown, parentObjectSlug: string | null | undefined): string {");
570
- lines.push(" if (parentObjectSlug) return parentObjectSlug");
571
- lines.push(' if (list && typeof list === "object" && "parentObject" in (list as Record<string, unknown>)) {');
572
- lines.push(" const parentObject = (list as { parentObject?: unknown }).parentObject");
573
- lines.push(' if (typeof parentObject === "string" && parentObject.length > 0) return parentObject');
574
- lines.push(" }");
575
- lines.push(' throw new Error("parentObjectSlug is required when the list is passed as a plain ID/slug rather than a generated AttioList constant.")');
576
- lines.push("}");
577
- lines.push("");
578
- lines.push("function __enhanceAttioListEntry<TList>(list: TList, entry: unknown): AttioListEntryFor<TList> {");
579
- lines.push(' const raw = (entry && typeof entry === "object" ? entry : {}) as { entry_values?: unknown }');
580
- lines.push(" return { ...(raw as object), entry_values: __getAttioEntryValues(__normalizeAttioObjectSlug(list), raw.entry_values) } as AttioListEntryFor<TList>");
581
- lines.push("}");
582
- lines.push("");
583
- lines.push('function __enhanceAttioListEntriesResult<TList>(list: TList, result: ToolOutputByName["attio_read_list_entries"]): AttioListEntriesResult<TList> {');
584
- lines.push(" const entries = (result.entries || []).map(entry => __enhanceAttioListEntry(list, entry))");
585
- lines.push(" return { entries, count: entries.length, offset: result.offset ?? 0 }");
586
- lines.push("}");
587
- lines.push("");
588
- lines.push('function __enhanceAttioListEntryResult<TList>(list: TList, result: ToolOutputByName["attio_read_list_entries"]): AttioListEntryResult<TList> {');
589
- lines.push(' if (!result.entry) throw new Error("Attio returned a response without the expected list entry payload.")');
590
- lines.push(" return __enhanceAttioListEntry(list, result.entry)");
591
- lines.push("}");
592
- lines.push("");
593
- lines.push('function __enhanceAttioHistoryResult<TValue>(result: ToolOutputByName["attio_read_records"]): AttioAttributeHistoryResult<TValue> {');
594
- lines.push(" const history = (result.history || []).map(entry => ({ active_from: entry.active_from, active_until: entry.active_until, value: __flattenAttioLeafValue(entry) as TValue }))");
595
- lines.push(" return { history, count: history.length }");
596
- lines.push("}");
597
- lines.push("");
598
- lines.push('registerEventTransform("attio", (event) => {');
599
- lines.push(" const e = event as { record?: { values?: unknown }; resourceIds?: { object_id?: string } }");
600
- lines.push(" if (!e?.record?.values) return event");
601
- lines.push(" const objectId = e.resourceIds?.object_id");
602
- lines.push(" const slug = objectId ? __attioObjectSlugByObjectId[objectId] : undefined");
603
- lines.push(" if (!slug) return event");
604
- lines.push(" return { ...e, record: { ...e.record, values: __getAttioRecordValues(slug, e.record) } }");
605
- lines.push("})");
606
- return lines;
607
- }
608
- function prepareAttioSection(inst, tools) {
609
- if (!inst)
610
- return sectionData([]);
611
- const objects = buildGeneratedAttioObjects(inst);
612
- const lists = buildGeneratedAttioLists(inst);
613
- return sectionData([
614
- "registerEventTransform",
615
- "AttioOutputConfig",
616
- "TypedSkill",
617
- "AttioInputConfig",
618
- "AttioEventType",
619
- "TypedTrigger",
620
- "AttioTrigger",
621
- "AttioCallRecordingCreatedTrigger",
622
- "AttioCommentCreatedTrigger",
623
- "AttioCommentResolvedTrigger",
624
- "AttioCommentUnresolvedTrigger",
625
- "AttioCommentDeletedTrigger",
626
- "AttioListCreatedTrigger",
627
- "AttioListUpdatedTrigger",
628
- "AttioListDeletedTrigger",
629
- "AttioListAttributeCreatedTrigger",
630
- "AttioListAttributeUpdatedTrigger",
631
- "AttioListEntryCreatedTrigger",
632
- "AttioListEntryUpdatedTrigger",
633
- "AttioListEntryDeletedTrigger",
634
- "AttioObjectAttributeCreatedTrigger",
635
- "AttioObjectAttributeUpdatedTrigger",
636
- "AttioNoteCreatedTrigger",
637
- "AttioNoteContentUpdatedTrigger",
638
- "AttioNoteUpdatedTrigger",
639
- "AttioNoteDeletedTrigger",
640
- "AttioRecordCreatedTrigger",
641
- "AttioRecordMergedTrigger",
642
- "AttioRecordUpdatedTrigger",
643
- "AttioRecordDeletedTrigger",
644
- "AttioTaskCreatedTrigger",
645
- "AttioTaskUpdatedTrigger",
646
- "AttioTaskDeletedTrigger",
647
- "AttioWorkspaceMemberCreatedTrigger"
648
- ], {
649
- id: inst.id,
650
- skillToolType: buildSkillToolTypeForIntegration(tools, "attio"),
651
- objects,
652
- lists,
653
- valueTypeLines: attioValueTypeLines(objects, lists),
654
- runtimeLines: buildAttioRuntimeLines(objects, lists)
655
- });
656
- }
657
- function prepareSnowflakeSection(inst, tools) {
658
- if (!inst)
659
- return sectionData([]);
660
- return sectionData(["SnowflakeOutputConfig", "TypedSkill"], {
661
- id: inst.id,
662
- skillToolType: buildSkillToolTypeForIntegration(tools, "snowflake")
663
- });
664
- }
665
- function prepareHeyReachSection(inst) {
666
- if (!inst)
667
- return sectionData([]);
668
- return sectionData([
669
- "HeyReachInputConfig",
670
- "HeyReachEventType",
671
- "TypedTrigger",
672
- "HeyReachTrigger",
673
- "HeyReachConnectionRequestSentTrigger",
674
- "HeyReachConnectionRequestAcceptedTrigger",
675
- "HeyReachMessageSentTrigger",
676
- "HeyReachMessageReplyReceivedTrigger",
677
- "HeyReachInmailSentTrigger",
678
- "HeyReachInmailReplyReceivedTrigger",
679
- "HeyReachFollowSentTrigger",
680
- "HeyReachLikedPostTrigger",
681
- "HeyReachViewedProfileTrigger",
682
- "HeyReachCampaignCompletedTrigger",
683
- "HeyReachLeadTagUpdatedTrigger"
684
- ], {
685
- id: inst.id,
686
- campaignClass: buildResourceClassContext("HeyReachCampaign", [
687
- { classField: "campaignId", type: "string", sourceField: "id" },
688
- { classField: "name", type: "string", sourceField: "name" }
689
- ], "name", inst.campaigns)
690
- });
691
- }
692
- function prepareResendSection(instance, tools) {
693
- if (!instance)
694
- return sectionData([]);
695
- const usedNames = new Set();
696
- const templates = instance.templates.map(template => {
697
- let staticName = toGeneratedIdentifier(template.alias || template.name || "Template", "Template");
698
- while (usedNames.has(staticName))
699
- staticName += "_";
700
- usedNames.add(staticName);
701
- const fields = template.variables.map(variable => {
702
- const optional = variable.fallbackValue !== null ? "?" : "";
703
- return `"${escapeString(variable.key)}"${optional}: ${variable.type}`;
704
- });
705
- const variablesType = fields.length > 0 ? `{ ${fields.join("; ")} }` : "Record<string, never>";
706
- const variablesMetadata = template.variables
707
- .map(variable => JSON.stringify({
708
- key: variable.key,
709
- type: variable.type,
710
- required: variable.fallbackValue === null,
711
- fallbackValue: variable.fallbackValue
712
- }))
713
- .join(", ");
714
- return { staticName, id: template.id, alias: template.alias, name: template.name, variablesType, variablesMetadata };
715
- });
716
- const sectionImports = templates.length > 0 ? ["ResendOutputConfig", "TypedSkill", "ToolInputByName"] : ["ResendOutputConfig", "TypedSkill"];
717
- return sectionData(sectionImports, {
718
- id: instance.id,
719
- skillToolType: buildSkillToolTypeForIntegration(tools, "resend"),
720
- templates
721
- });
722
- }
723
- function prepareToolsSection(tools, input, active) {
724
- if (tools.length === 0)
725
- return sectionData([]);
726
- const imports = new Set(["TerseAgent", "ToolInputByName", "ToolOutputByName"]);
727
- const attioPreludeLines = [];
728
- const activeIdByIntegration = new Map([
729
- ["slack", active.slack?.id],
730
- ["github", active.github?.integration.id],
731
- ["gmail", active.gmail?.id],
732
- ["linear", active.linear?.id],
733
- ["notion", active.notion?.id],
734
- ["posthog", active.posthog?.id],
735
- ["datadog", active.datadog?.id],
736
- ["launchdarkly", active.launchdarkly?.id],
737
- ["workos", active.workos?.id],
738
- ["attio", active.attio?.id],
739
- ["snowflake", active.snowflake?.id],
740
- ["resend", active.resend?.id]
741
- ]);
742
- const byIntegration = new Map();
743
- for (const tool of tools) {
744
- const key = tool.integration.toLowerCase();
745
- if (!byIntegration.has(key))
746
- byIntegration.set(key, []);
747
- byIntegration.get(key).push(tool);
748
- }
749
- const hasAutoFillId = (tool) => toolsWithIntegrationId.has(tool.name);
750
- const normalizeGitHubReposParams = (toolName) => {
751
- switch (toolName) {
752
- case "readGitHubFile":
753
- case "listGitHubPullRequests":
754
- case "listGitHubDirectory":
755
- case "listGitHubCommits":
756
- case "summarizeGitHubPullRequestDiff":
757
- return "{ ...params, repository: __normalizeGitHubRepos((params).repository) }";
758
- case "searchGitHubCode":
759
- case "grepGitHubCode":
760
- return "{ ...params, repositoryNames: __normalizeGitHubReposNames((params).repositoryNames) }";
761
- default:
762
- return "params";
763
- }
764
- };
765
- const isAttioTool = (tool) => tool.integration.toLowerCase() === "attio";
766
- const attioGeneratedObjects = buildGeneratedAttioObjects(active.attio);
767
- if (tools.some(isAttioTool)) {
768
- if (!active.attio) {
769
- attioPreludeLines.push(...attioValueTypeLines());
770
- attioPreludeLines.push("");
771
- }
772
- attioPreludeLines.push("type __AttioPrimitive = string | number | boolean | null");
773
- attioPreludeLines.push("type __AttioStructuredValue = Record<string, unknown>");
774
- attioPreludeLines.push("type __AttioValue = __AttioPrimitive | __AttioStructuredValue | (__AttioPrimitive | __AttioStructuredValue)[]");
775
- attioPreludeLines.push("type __AttioFilterAtom<T> = T extends AttioSelectOption ? string : T extends AttioActorReference ? string : T extends AttioRecordReferenceValue ? string : T extends AttioCurrencyValue ? number : T");
776
- attioPreludeLines.push("type __AttioFilterShorthand<T> = T extends (infer U)[] ? __AttioFilterAtom<U> | __AttioFilterAtom<U>[] : __AttioFilterAtom<T>");
777
- attioPreludeLines.push("type __AttioFilterValue<T> = __AttioFilterShorthand<T> | { $eq?: __AttioFilterShorthand<T>; $contains?: string; $starts_with?: string; $ends_with?: string } | Record<string, unknown>");
778
- attioPreludeLines.push("type __AttioFilterExpression<TValues extends Record<string, unknown>> = Partial<{ [K in keyof TValues]: __AttioFilterValue<TValues[K]> }> & { $and?: Array<__AttioFilterExpression<TValues>>; $or?: Array<__AttioFilterExpression<TValues>> }");
779
- attioPreludeLines.push("type __AttioRecordBase = { id?: { workspace_id?: string; object_id?: string; record_id?: string }; record_id?: string; web_url?: string; created_at?: string }");
780
- attioPreludeLines.push("type __AttioRecordWithValues<TValues extends Record<string, unknown>> = __AttioRecordBase & TValues & { values: TValues; attributes: TValues }");
781
- attioPreludeLines.push("");
782
- if (attioGeneratedObjects.length > 0) {
783
- attioPreludeLines.push("export type AttioInputValuesByObject = {");
784
- for (const object of attioGeneratedObjects) {
785
- const inputShape = object.attributes.length === 0 ? "Record<string, __AttioValue>" : renderAttioObjectValueShape(object.attributes, "input");
786
- attioPreludeLines.push(` "${escapeString(object.apiSlug)}": ${inputShape}`);
787
- }
788
- attioPreludeLines.push("}");
789
- attioPreludeLines.push("");
790
- attioPreludeLines.push("export type AttioRecordValuesByObject = {");
791
- for (const object of attioGeneratedObjects) {
792
- const recordShape = object.attributes.length === 0 ? "Record<string, __AttioValue>" : renderAttioObjectValueShape(object.attributes, "record");
793
- attioPreludeLines.push(` "${escapeString(object.apiSlug)}": ${recordShape}`);
794
- }
795
- attioPreludeLines.push("}");
796
- attioPreludeLines.push("");
797
- attioPreludeLines.push("export type AttioFilterByObject = {");
798
- for (const object of attioGeneratedObjects) {
799
- attioPreludeLines.push(` "${escapeString(object.apiSlug)}": __AttioFilterExpression<AttioRecordValuesByObject["${escapeString(object.apiSlug)}"]>`);
800
- }
801
- attioPreludeLines.push("}");
802
- attioPreludeLines.push("");
803
- attioPreludeLines.push("export type AttioRecordByObject = {");
804
- for (const object of attioGeneratedObjects) {
805
- attioPreludeLines.push(` "${escapeString(object.apiSlug)}": __AttioRecordWithValues<AttioRecordValuesByObject["${escapeString(object.apiSlug)}"]>`);
806
- }
807
- attioPreludeLines.push("}");
808
- }
809
- else {
810
- attioPreludeLines.push("export type AttioInputValuesByObject = Record<string, Record<string, __AttioValue>>");
811
- attioPreludeLines.push("export type AttioRecordValuesByObject = Record<string, Record<string, __AttioValue>>");
812
- attioPreludeLines.push("export type AttioFilterByObject = Record<string, __AttioFilterExpression<Record<string, __AttioValue>>>");
813
- attioPreludeLines.push("export type AttioRecordByObject = Record<string, __AttioRecordWithValues<Record<string, __AttioValue>>>");
814
- }
815
- attioPreludeLines.push("");
816
- attioPreludeLines.push('export type AttioValuesFor<TObject extends GeneratedAttioObject = GeneratedAttioObject> = TObject extends { __inputValues: infer TInputValues } ? TInputValues : AttioInputValuesByObject[TObject["apiSlug"]]');
817
- attioPreludeLines.push('export type AttioRecordValuesFor<TObject extends GeneratedAttioObject = GeneratedAttioObject> = TObject extends { __recordValues: infer TRecordValues } ? TRecordValues : AttioRecordValuesByObject[TObject["apiSlug"]]');
818
- attioPreludeLines.push("export type AttioAttributeSlug<TObject extends GeneratedAttioObject = GeneratedAttioObject> = Extract<keyof AttioValuesFor<TObject>, string>");
819
- attioPreludeLines.push("export type AttioFilterFor<TObject extends GeneratedAttioObject = GeneratedAttioObject> = __AttioFilterExpression<AttioRecordValuesFor<TObject>>");
820
- attioPreludeLines.push("export type AttioRecordFor<TObject extends GeneratedAttioObject = GeneratedAttioObject> = __AttioRecordWithValues<AttioRecordValuesFor<TObject>>");
821
- attioPreludeLines.push("export type AttioQueryRecordsParams<TObject extends GeneratedAttioObject = GeneratedAttioObject> = { object: TObject; filter?: AttioFilterFor<TObject> | null; limit?: number | null; offset?: number | null }");
822
- attioPreludeLines.push("export type AttioSearchRecordsParams<TObject extends GeneratedAttioObject = GeneratedAttioObject> = { object: TObject; query: string; limit?: number | null }");
823
- attioPreludeLines.push("export type AttioGetRecordParams<TObject extends GeneratedAttioObject = GeneratedAttioObject> = { object: TObject; recordId: string }");
824
- attioPreludeLines.push("export type AttioCreateRecordParams<TObject extends GeneratedAttioObject = GeneratedAttioObject> = { object: TObject; values: AttioValuesFor<TObject> }");
825
- attioPreludeLines.push('export type AttioUpdateRecordParams<TObject extends GeneratedAttioObject = GeneratedAttioObject> = { object: TObject; recordId: string; values: Partial<AttioValuesFor<TObject>>; multiselectMode?: "overwrite" | "append" | null }');
826
- attioPreludeLines.push("export type AttioUpsertRecordParams<TObject extends GeneratedAttioObject = GeneratedAttioObject> = { object: TObject; matchingAttribute: AttioAttributeSlug<TObject>; records: AttioValuesFor<TObject>[] }");
827
- attioPreludeLines.push("export type AttioDeleteRecordParams<TObject extends GeneratedAttioObject = GeneratedAttioObject> = { object: TObject; recordId: string }");
828
- attioPreludeLines.push("export type AttioGetAttributeHistoryParams<TObject extends GeneratedAttioObject = GeneratedAttioObject> = { object: TObject; recordId: string; attribute: AttioAttributeSlug<TObject>; limit?: number | null; offset?: number | null }");
829
- attioPreludeLines.push('export type AttioWorkspaceMembersResult = ToolOutputByName["attio_workspace_members"]');
830
- attioPreludeLines.push('export type AttioRecordsResult = ToolOutputByName["attio_read_records"]');
831
- attioPreludeLines.push("export type AttioQueryRecordsResult<TObject extends GeneratedAttioObject = GeneratedAttioObject> = { records: Array<AttioRecordFor<TObject>>; count: number; offset: number }");
832
- attioPreludeLines.push('export type AttioSearchRecordsResult = { matches: NonNullable<AttioRecordsResult["matches"]>; count: number }');
833
- attioPreludeLines.push("export type AttioUpsertRecordResult<TObject extends GeneratedAttioObject = GeneratedAttioObject> = { records: Array<AttioRecordFor<TObject>>; count: number }");
834
- attioPreludeLines.push("export type AttioSingleRecordResult<TObject extends GeneratedAttioObject = GeneratedAttioObject> = AttioRecordFor<TObject>");
835
- attioPreludeLines.push('export type AttioListsResult = ToolOutputByName["attio_read_lists"]');
836
- attioPreludeLines.push("export type AttioEntryValuesFor<TList> = TList extends { __entryValues: infer TValues } ? TValues : Record<string, unknown>");
837
- attioPreludeLines.push("export type AttioEntryRecordValuesFor<TList> = TList extends { __entryRecordValues: infer TValues extends Record<string, unknown> } ? TValues : Record<string, unknown>");
838
- attioPreludeLines.push("export type AttioEntryFilterFor<TList> = __AttioFilterExpression<AttioEntryRecordValuesFor<TList>>");
839
- attioPreludeLines.push("export type AttioListEntryFor<TList> = { id: { workspace_id: string; list_id: string; entry_id: string }; parent_record_id: string; parent_object: string; created_at: string; entry_values: AttioEntryRecordValuesFor<TList> }");
840
- attioPreludeLines.push("export type AttioListEntriesResult<TList> = { entries: Array<AttioListEntryFor<TList>>; count: number; offset: number }");
841
- attioPreludeLines.push("export type AttioListEntryResult<TList> = AttioListEntryFor<TList>");
842
- attioPreludeLines.push("type __AttioSingleValue<T> = T extends (infer U)[] ? U : T");
843
- attioPreludeLines.push("export type AttioAttributeHistoryEntryFor<TValue> = { active_from: string; active_until: string | null; value: TValue }");
844
- attioPreludeLines.push("export type AttioAttributeHistoryResult<TValue = unknown> = { history: Array<AttioAttributeHistoryEntryFor<TValue>>; count: number }");
845
- attioPreludeLines.push("");
846
- attioPreludeLines.push("function __normalizeAttioObjectSlug(object: unknown): string {");
847
- attioPreludeLines.push(' if (object && typeof object === "object" && "apiSlug" in (object as Record<string, unknown>)) {');
848
- attioPreludeLines.push(" const apiSlug = (object as { apiSlug?: unknown }).apiSlug");
849
- attioPreludeLines.push(' if (typeof apiSlug === "string" && apiSlug.length > 0) return apiSlug');
850
- attioPreludeLines.push(" }");
851
- attioPreludeLines.push(' return typeof object === "string" ? object : ""');
852
- attioPreludeLines.push("}");
853
- attioPreludeLines.push("");
854
- attioPreludeLines.push("function __serializeAttioFilter(filter: unknown): string | null {");
855
- attioPreludeLines.push(" if (filter === undefined || filter === null) return null");
856
- attioPreludeLines.push(" return JSON.stringify(filter)");
857
- attioPreludeLines.push("}");
858
- attioPreludeLines.push("");
859
- attioPreludeLines.push("function __serializeAttioValues(values: unknown): string {");
860
- attioPreludeLines.push(" return JSON.stringify(values ?? {})");
861
- attioPreludeLines.push("}");
862
- attioPreludeLines.push("");
863
- attioPreludeLines.push("function __serializeAttioRecords(records: unknown): string {");
864
- attioPreludeLines.push(" if (!Array.isArray(records)) return JSON.stringify([])");
865
- attioPreludeLines.push(' return JSON.stringify(records.filter((record): record is Record<string, unknown> => typeof record === "object" && record !== null && !Array.isArray(record)))');
866
- attioPreludeLines.push("}");
867
- attioPreludeLines.push("");
868
- attioPreludeLines.push("function __enhanceAttioRecord<TObject extends GeneratedAttioObject>(object: TObject, record: unknown): __AttioRecordWithValues<AttioRecordValuesFor<TObject>> | undefined {");
869
- attioPreludeLines.push(' if (!record || typeof record !== "object") return undefined');
870
- attioPreludeLines.push(" const values = __getAttioRecordValues<AttioRecordValuesFor<TObject>>(__normalizeAttioObjectSlug(object), record)");
871
- attioPreludeLines.push(" return { ...values, ...(record as __AttioRecordBase), values, attributes: values } as __AttioRecordWithValues<AttioRecordValuesFor<TObject>>");
872
- attioPreludeLines.push("}");
873
- attioPreludeLines.push("");
874
- attioPreludeLines.push("function __requireAttioPayload<T>(value: T | null | undefined, what: string): T {");
875
- attioPreludeLines.push(' if (value === null || value === undefined) throw new Error("Attio returned a response without the expected " + what + " payload.")');
876
- attioPreludeLines.push(" return value");
877
- attioPreludeLines.push("}");
878
- attioPreludeLines.push("");
879
- attioPreludeLines.push('function __enhanceAttioQueryResult<TObject extends GeneratedAttioObject>(object: TObject, result: ToolOutputByName["attio_read_records"]): AttioQueryRecordsResult<TObject> {');
880
- attioPreludeLines.push(" const records = (result.records || []).map(record => __enhanceAttioRecord(object, record)).filter(Boolean) as Array<AttioRecordFor<TObject>>");
881
- attioPreludeLines.push(" return { records, count: records.length, offset: result.offset ?? 0 }");
882
- attioPreludeLines.push("}");
883
- attioPreludeLines.push("");
884
- attioPreludeLines.push('function __enhanceAttioSearchResult(result: ToolOutputByName["attio_read_records"]): AttioSearchRecordsResult {');
885
- attioPreludeLines.push(" const matches = result.matches ?? []");
886
- attioPreludeLines.push(" return { matches, count: matches.length }");
887
- attioPreludeLines.push("}");
888
- attioPreludeLines.push("");
889
- attioPreludeLines.push('function __enhanceAttioUpsertResult<TObject extends GeneratedAttioObject>(object: TObject, result: ToolOutputByName["attio_upsert_record"]): AttioUpsertRecordResult<TObject> {');
890
- attioPreludeLines.push(" const records = (result.records || []).map(record => __enhanceAttioRecord(object, record)).filter(Boolean) as Array<AttioRecordFor<TObject>>");
891
- attioPreludeLines.push(" return { records, count: records.length }");
892
- attioPreludeLines.push("}");
893
- attioPreludeLines.push("");
894
- attioPreludeLines.push('function __enhanceAttioSingleRecordResult<TObject extends GeneratedAttioObject>(object: TObject, result: ToolOutputByName["attio_read_records"]): AttioSingleRecordResult<TObject> {');
895
- attioPreludeLines.push(' return __requireAttioPayload(__enhanceAttioRecord(object, result.record), "record")');
896
- attioPreludeLines.push("}");
897
- attioPreludeLines.push("");
898
- }
899
- const hasPosthogEventNames = (input.posthog[0]?.projects ?? []).some(project => project.events.length > 0);
900
- const hasResendTemplates = (active.resend?.templates.length ?? 0) > 0;
901
- const paramTypes = [];
902
- for (const tool of tools) {
903
- if (isAttioTool(tool))
904
- continue;
905
- // Emitted by the Resend section as a per-template discriminated union
906
- if (tool.name === "resend_send_template" && hasResendTemplates)
907
- continue;
908
- const key = `"${escapeString(tool.name)}"`;
909
- let tsType = hasAutoFillId(tool) ? `Omit<ToolInputByName[${key}], "integrationId">` : `ToolInputByName[${key}]`;
910
- if (tool.name === "searchPosthogEvents" && hasPosthogEventNames) {
911
- // Custom events type-check against the generated union; $-prefixed builtins are always allowed
912
- tsType = `Omit<ToolInputByName[${key}], "integrationId" | "eventName"> & { eventName?: PosthogEventName | \`$\${string}\` | null }`;
913
- }
914
- paramTypes.push({
915
- description: tool.description || undefined,
916
- typeName: toolNameToInterfaceName(tool.name),
917
- tsType
918
- });
919
- }
920
- const rawGroups = [];
921
- for (const [integration, integrationTools] of byIntegration.entries()) {
922
- const needsAutoFill = integrationTools.some(hasAutoFillId);
923
- if (needsAutoFill) {
924
- const integrationId = activeIdByIntegration.get(integration);
925
- if (!integrationId)
926
- continue;
927
- rawGroups.push({ key: integration, integration, tools: integrationTools, integrationId });
928
- }
929
- else {
930
- rawGroups.push({ key: integration, integration, tools: integrationTools });
931
- }
932
- }
933
- rawGroups.sort((a, b) => a.key.localeCompare(b.key));
934
- const githubRepoMappings = [];
935
- if (rawGroups.some(group => group.integration === "github")) {
936
- const githubRepoFullNames = Array.from(new Set(input.github.flatMap(inst => inst.repositories.map(repo => (repo.owner && repo.name ? `${repo.owner}/${repo.name}` : repo.name).trim()).filter(Boolean))));
937
- const nameToFullName = new Map();
938
- const ambiguousNames = new Set();
939
- for (const fullName of githubRepoFullNames) {
940
- const [, repoName = fullName] = fullName.split("/", 2);
941
- if (nameToFullName.has(repoName) && nameToFullName.get(repoName) !== fullName) {
942
- ambiguousNames.add(repoName);
943
- nameToFullName.delete(repoName);
944
- }
945
- else if (!ambiguousNames.has(repoName)) {
946
- nameToFullName.set(repoName, fullName);
947
- }
948
- }
949
- for (const [name, fullName] of Array.from(nameToFullName.entries()).sort((a, b) => a[0].localeCompare(b[0]))) {
950
- githubRepoMappings.push({ name, fullName });
951
- }
952
- }
953
- const groups = rawGroups.map(group => ({
954
- key: group.key,
955
- integrationType: toolIntegrationToIntegrationType(group.integration),
956
- methods: group.tools.flatMap(tool => {
957
- const methodName = toCamelCase(tool.displayName);
958
- const paramsType = toolNameToInterfaceName(tool.name);
959
- const normalizedParamsExpr = group.integration === "github" ? normalizeGitHubReposParams(tool.name) : "params";
960
- if (group.integration === "attio" && group.integrationId) {
961
- const attioMethods = buildAttioToolMethods(group.integrationId, tool);
962
- if (attioMethods)
963
- return attioMethods;
964
- }
965
- const generatedSignature = `${methodName}(params: ${paramsType}): Promise<ToolOutputByName["${escapeString(tool.name)}"]>`;
966
- let runtimeLines;
967
- if (group.integrationId && hasAutoFillId(tool)) {
968
- runtimeLines = [
969
- `${methodName}: (params: ${paramsType}) =>`,
970
- ` TerseAgent.executeTool<ToolOutputByName["${escapeString(tool.name)}"]>("${escapeString(tool.name)}", { ...(${normalizedParamsExpr}), integrationId: "${escapeString(group.integrationId)}" }),`
971
- ];
972
- }
973
- else {
974
- runtimeLines = [
975
- `${methodName}: (params: ${paramsType}) =>`,
976
- ` TerseAgent.executeTool<ToolOutputByName["${escapeString(tool.name)}"]>("${escapeString(tool.name)}", ${normalizedParamsExpr}),`
977
- ];
978
- }
979
- return [
980
- {
981
- description: tool.description || undefined,
982
- generatedSignature,
983
- runtimeLines
984
- }
985
- ];
986
- })
987
- }));
988
- return {
989
- imports,
990
- data: {
991
- attioPreludeLines,
992
- paramTypes,
993
- githubRepoMappings,
994
- groups
995
- }
996
- };
997
- }
998
- function buildAttioRecordsMethods(integrationId, tool) {
999
- const id = escapeString(integrationId);
1000
- const toolName = tool.name;
1001
- const call = (requestExpr) => `TerseAgent.executeTool<ToolOutputByName["${toolName}"]>("${toolName}", { integrationId: "${id}", request: ${requestExpr} })`;
1002
- const objectSlug = "objectSlug: __normalizeAttioObjectSlug(params.object)";
1003
- switch (toolName) {
1004
- case "attio_read_records":
1005
- return [
1006
- {
1007
- description: attioActionDescription(toolName, "query"),
1008
- generatedSignature: "queryRecords<TObject extends GeneratedAttioObject>(params: AttioQueryRecordsParams<TObject>): Promise<AttioQueryRecordsResult<TObject>>",
1009
- runtimeLines: [
1010
- "queryRecords: <TObject extends GeneratedAttioObject>(params: AttioQueryRecordsParams<TObject>) =>",
1011
- ` ${call(`{ action: "query", ${objectSlug}, filter: __serializeAttioFilter(params.filter), limit: params.limit ?? null, offset: params.offset ?? null }`)}.then(result => __enhanceAttioQueryResult(params.object, result)),`
1012
- ]
1013
- },
1014
- {
1015
- description: attioActionDescription(toolName, "search"),
1016
- generatedSignature: "searchRecords<TObject extends GeneratedAttioObject>(params: AttioSearchRecordsParams<TObject>): Promise<AttioSearchRecordsResult>",
1017
- runtimeLines: [
1018
- "searchRecords: <TObject extends GeneratedAttioObject>(params: AttioSearchRecordsParams<TObject>) =>",
1019
- ` ${call(`{ action: "search", ${objectSlug}, query: params.query, limit: params.limit ?? null }`)}.then(result => __enhanceAttioSearchResult(result)),`
1020
- ]
1021
- },
1022
- {
1023
- description: attioActionDescription(toolName, "get"),
1024
- generatedSignature: "getRecord<TObject extends GeneratedAttioObject>(params: AttioGetRecordParams<TObject>): Promise<AttioSingleRecordResult<TObject>>",
1025
- runtimeLines: [
1026
- "getRecord: <TObject extends GeneratedAttioObject>(params: AttioGetRecordParams<TObject>) =>",
1027
- ` ${call(`{ action: "get", ${objectSlug}, recordId: params.recordId }`)}.then(result => __enhanceAttioSingleRecordResult(params.object, result)),`
1028
- ]
1029
- },
1030
- {
1031
- description: attioActionDescription(toolName, "get_attribute_history"),
1032
- generatedSignature: "getAttributeHistory<TObject extends GeneratedAttioObject, TAttr extends AttioAttributeSlug<TObject>>(params: AttioGetAttributeHistoryParams<TObject> & { attribute: TAttr }): Promise<AttioAttributeHistoryResult<__AttioSingleValue<NonNullable<AttioRecordValuesFor<TObject>[TAttr & keyof AttioRecordValuesFor<TObject>]>>>>",
1033
- runtimeLines: [
1034
- "getAttributeHistory: <TObject extends GeneratedAttioObject, TAttr extends AttioAttributeSlug<TObject>>(params: AttioGetAttributeHistoryParams<TObject> & { attribute: TAttr }) =>",
1035
- ` ${call(`{ action: "get_attribute_history", ${objectSlug}, recordId: params.recordId, attributeSlug: params.attribute, limit: params.limit ?? null, offset: params.offset ?? null }`)}.then(result => __enhanceAttioHistoryResult<__AttioSingleValue<NonNullable<AttioRecordValuesFor<TObject>[TAttr & keyof AttioRecordValuesFor<TObject>]>>>(result)),`
1036
- ]
1037
- }
1038
- ];
1039
- case "attio_create_record":
1040
- return [
1041
- {
1042
- description: tool.description || undefined,
1043
- generatedSignature: "createRecord<TObject extends GeneratedAttioObject>(params: AttioCreateRecordParams<TObject>): Promise<AttioSingleRecordResult<TObject>>",
1044
- runtimeLines: [
1045
- "createRecord: <TObject extends GeneratedAttioObject>(params: AttioCreateRecordParams<TObject>) =>",
1046
- ` ${call(`{ ${objectSlug}, values: JSON.stringify(params.values) }`)}.then(result => __enhanceAttioSingleRecordResult(params.object, result)),`
1047
- ]
1048
- }
1049
- ];
1050
- case "attio_update_record":
1051
- return [
1052
- {
1053
- description: tool.description || undefined,
1054
- generatedSignature: "updateRecord<TObject extends GeneratedAttioObject>(params: AttioUpdateRecordParams<TObject>): Promise<AttioSingleRecordResult<TObject>>",
1055
- runtimeLines: [
1056
- "updateRecord: <TObject extends GeneratedAttioObject>(params: AttioUpdateRecordParams<TObject>) =>",
1057
- ` ${call(`{ ${objectSlug}, recordId: params.recordId, values: JSON.stringify(params.values), multiselectMode: params.multiselectMode ?? null }`)}.then(result => __enhanceAttioSingleRecordResult(params.object, result)),`
1058
- ]
1059
- }
1060
- ];
1061
- case "attio_upsert_record":
1062
- return [
1063
- {
1064
- description: tool.description || undefined,
1065
- generatedSignature: "upsertRecord<TObject extends GeneratedAttioObject>(params: AttioUpsertRecordParams<TObject>): Promise<AttioUpsertRecordResult<TObject>>",
1066
- runtimeLines: [
1067
- "upsertRecord: <TObject extends GeneratedAttioObject>(params: AttioUpsertRecordParams<TObject>) =>",
1068
- ` ${call(`{ ${objectSlug}, matchingAttribute: params.matchingAttribute, records: __serializeAttioRecords(params.records) }`)}.then(result => __enhanceAttioUpsertResult(params.object, result)),`
1069
- ]
1070
- }
1071
- ];
1072
- case "attio_delete_record":
1073
- return [
1074
- {
1075
- description: tool.description || undefined,
1076
- generatedSignature: "deleteRecord<TObject extends GeneratedAttioObject>(params: AttioDeleteRecordParams<TObject>): Promise<void>",
1077
- runtimeLines: [
1078
- "deleteRecord: <TObject extends GeneratedAttioObject>(params: AttioDeleteRecordParams<TObject>) =>",
1079
- ` ${call(`{ ${objectSlug}, recordId: params.recordId }`)}.then(() => undefined),`
1080
- ]
1081
- }
1082
- ];
1083
- default:
1084
- return [];
1085
- }
1086
- }
1087
- function buildAttioToolMethods(integrationId, tool) {
1088
- switch (tool.name) {
1089
- case "attio_read_records":
1090
- case "attio_create_record":
1091
- case "attio_update_record":
1092
- case "attio_upsert_record":
1093
- case "attio_delete_record":
1094
- return buildAttioRecordsMethods(integrationId, tool);
1095
- case "attio_read_lists":
1096
- case "attio_create_list":
1097
- case "attio_update_list":
1098
- case "attio_read_list_entries":
1099
- case "attio_add_list_entry":
1100
- case "attio_upsert_list_entry":
1101
- case "attio_update_list_entry":
1102
- case "attio_remove_list_entry":
1103
- return buildAttioListsMethods(integrationId, tool);
1104
- default: {
1105
- const specs = ATTIO_RESOURCE_METHOD_SPECS[tool.name];
1106
- return specs ? buildAttioResourceMethods(integrationId, tool, specs) : null;
1107
- }
1108
- }
1109
- }
1110
- // Method TSDoc is single-sourced: single-op tools inherit the tool description, action-mapped
1111
- // methods inherit the zod action literal's description.
1112
- function attioActionDescription(toolName, action) {
1113
- if (!isKnownToolName(toolName))
1114
- return undefined;
1115
- const parsed = attioRequestUnionJsonSchema.safeParse(z.toJSONSchema(ToolDefinitions[toolName].inputSchema));
1116
- if (!parsed.success)
1117
- return undefined;
1118
- const request = parsed.data.properties.request;
1119
- for (const branch of request.oneOf ?? request.anyOf ?? []) {
1120
- const actionBranch = attioActionBranchJsonSchema.safeParse(branch);
1121
- if (actionBranch.success && actionBranch.data.properties.action.const === action) {
1122
- return actionBranch.data.properties.action.description;
1123
- }
1124
- }
1125
- return undefined;
1126
- }
1127
- function isKnownToolName(name) {
1128
- return name in ToolDefinitions;
1129
- }
1130
- const attioRequestUnionJsonSchema = z.object({
1131
- properties: z.object({ request: z.object({ oneOf: z.array(z.unknown()).optional(), anyOf: z.array(z.unknown()).optional() }) })
1132
- });
1133
- const attioActionBranchJsonSchema = z.object({
1134
- properties: z.object({ action: z.object({ const: z.string(), description: z.string().optional() }) })
1135
- });
1136
- const ATTIO_RESOURCE_METHOD_SPECS = {
1137
- attio_workspace_members: [
1138
- { action: "list", methodName: "listWorkspaceMembers", emptyParams: true, result: { kind: "list", key: "members" } },
1139
- { action: "get", methodName: "getWorkspaceMember", result: { kind: "single", key: "member", what: "workspace member" } }
1140
- ],
1141
- attio_read_tasks: [
1142
- { action: "list", methodName: "listTasks", emptyParams: true, result: { kind: "list", key: "tasks" } },
1143
- { action: "get", methodName: "getTask", result: { kind: "single", key: "task" } }
1144
- ],
1145
- attio_create_task: [{ methodName: "createTask", result: { kind: "single", key: "task" } }],
1146
- attio_update_task: [{ methodName: "updateTask", result: { kind: "single", key: "task" } }],
1147
- attio_delete_task: [{ methodName: "deleteTask", result: { kind: "void" } }],
1148
- attio_read_notes: [
1149
- { action: "list", methodName: "listNotes", emptyParams: true, result: { kind: "list", key: "notes" } },
1150
- { action: "get", methodName: "getNote", result: { kind: "single", key: "note" } }
1151
- ],
1152
- attio_create_note: [{ methodName: "createNote", result: { kind: "single", key: "note" } }],
1153
- attio_delete_note: [{ methodName: "deleteNote", result: { kind: "void" } }],
1154
- attio_read_comments: [
1155
- { action: "get", methodName: "getComment", result: { kind: "single", key: "comment" } },
1156
- { action: "list_threads", methodName: "listThreads", emptyParams: true, result: { kind: "list", key: "threads" } },
1157
- { action: "get_thread", methodName: "getThread", result: { kind: "single", key: "thread" } }
1158
- ],
1159
- attio_create_comment: [{ methodName: "createComment", result: { kind: "single", key: "comment" } }],
1160
- attio_delete_comment: [{ methodName: "deleteComment", result: { kind: "void" } }],
1161
- attio_meetings: [
1162
- { action: "list", methodName: "listMeetings", emptyParams: true, result: { kind: "list", key: "meetings", cursor: true } },
1163
- { action: "get", methodName: "getMeeting", result: { kind: "single", key: "meeting" } },
1164
- { action: "list_recordings", methodName: "listCallRecordings", result: { kind: "list", key: "recordings", cursor: true } },
1165
- { action: "get_transcript", methodName: "getCallTranscript", result: { kind: "singleWithCursor", key: "transcript" } }
1166
- ],
1167
- attio_read_files: [
1168
- { action: "list", methodName: "listFiles", result: { kind: "list", key: "files", cursor: true } },
1169
- { action: "get", methodName: "getFile", result: { kind: "single", key: "file" } },
1170
- { action: "get_download_url", methodName: "getFileDownloadUrl", result: { kind: "single", key: "downloadUrl", what: "download URL" } }
1171
- ],
1172
- attio_upload_file: [{ methodName: "uploadFile", result: { kind: "single", key: "file" } }],
1173
- attio_delete_file: [{ methodName: "deleteFile", result: { kind: "void" } }],
1174
- attio_read_schema: [
1175
- { action: "list_objects", methodName: "listObjects", emptyParams: true, result: { kind: "list", key: "objects" } },
1176
- { action: "get_object", methodName: "getObject", result: { kind: "single", key: "object" } },
1177
- { action: "list_attributes", methodName: "listAttributes", result: { kind: "list", key: "attributes" } },
1178
- { action: "list_statuses", methodName: "listStatuses", result: { kind: "list", key: "statuses" } },
1179
- { action: "list_select_options", methodName: "listSelectOptions", result: { kind: "list", key: "selectOptions" } }
1180
- ],
1181
- attio_modify_schema: [
1182
- { action: "create_object", methodName: "createObject", result: { kind: "single", key: "object" } },
1183
- { action: "update_object", methodName: "updateObject", result: { kind: "single", key: "object" } },
1184
- { action: "create_attribute", methodName: "createAttribute", result: { kind: "single", key: "attribute" } },
1185
- { action: "update_attribute", methodName: "updateAttribute", result: { kind: "single", key: "attribute" } },
1186
- { action: "create_status", methodName: "createStatus", result: { kind: "single", key: "status" } },
1187
- { action: "update_status", methodName: "updateStatus", result: { kind: "single", key: "status" } },
1188
- { action: "create_select_option", methodName: "createSelectOption", result: { kind: "single", key: "selectOption" } },
1189
- { action: "update_select_option", methodName: "updateSelectOption", result: { kind: "single", key: "selectOption" } }
1190
- ]
1191
- };
1192
- // Each method narrows the wire result to its action's payload at runtime: singles unwrap to the bare
1193
- // entity (throwing if absent), lists rebuild a { items, count, nextCursor? } wrapper, deletes resolve void.
1194
- function attioResultParts(toolName, result) {
1195
- const base = `ToolOutputByName["${toolName}"]`;
1196
- switch (result.kind) {
1197
- case "single":
1198
- return {
1199
- resultType: `NonNullable<${base}["${result.key}"]>`,
1200
- thenExpr: `.then(result => __requireAttioPayload(result.${result.key}, "${result.what ?? result.key}"))`
1201
- };
1202
- case "singleWithCursor":
1203
- return {
1204
- resultType: `{ ${result.key}: NonNullable<${base}["${result.key}"]>; nextCursor: string | null }`,
1205
- thenExpr: `.then(result => ({ ${result.key}: __requireAttioPayload(result.${result.key}, "${result.what ?? result.key}"), nextCursor: result.nextCursor ?? null }))`
1206
- };
1207
- case "list": {
1208
- const cursorType = result.cursor ? "; nextCursor: string | null" : "";
1209
- const cursorValue = result.cursor ? ", nextCursor: result.nextCursor ?? null" : "";
1210
- return {
1211
- resultType: `{ ${result.key}: NonNullable<${base}["${result.key}"]>; count: number${cursorType} }`,
1212
- thenExpr: `.then(result => ({ ${result.key}: result.${result.key} ?? [], count: (result.${result.key} ?? []).length${cursorValue} }))`
1213
- };
1214
- }
1215
- case "void":
1216
- return { resultType: "void", thenExpr: ".then(() => undefined)" };
1217
- default:
1218
- throw result;
1219
- }
1220
- }
1221
- function buildAttioResourceMethods(integrationId, tool, specs) {
1222
- const id = escapeString(integrationId);
1223
- const toolName = tool.name;
1224
- return specs.map(spec => {
1225
- const paramsType = spec.action ? `Omit<Extract<ToolInputByName["${toolName}"]["request"], { action: "${spec.action}" }>, "action">` : `ToolInputByName["${toolName}"]["request"]`;
1226
- const requestExpr = spec.action ? `{ action: "${spec.action}", ...params }` : "params";
1227
- const { resultType, thenExpr } = attioResultParts(toolName, spec.result);
1228
- return {
1229
- description: spec.action ? attioActionDescription(toolName, spec.action) : tool.description || undefined,
1230
- generatedSignature: `${spec.methodName}(${spec.emptyParams ? `params?: ${paramsType}` : `params: ${paramsType}`}): Promise<${resultType}>`,
1231
- runtimeLines: [
1232
- `${spec.methodName}: (params: ${paramsType}${spec.emptyParams ? " = {}" : ""}) =>`,
1233
- ` TerseAgent.executeTool<ToolOutputByName["${toolName}"]>("${toolName}", { integrationId: "${id}", request: ${requestExpr} })${thenExpr},`
1234
- ]
1235
- };
1236
- });
1237
- }
1238
- function buildAttioListsMethods(integrationId, tool) {
1239
- const id = escapeString(integrationId);
1240
- const toolName = tool.name;
1241
- const call = (requestExpr) => `TerseAgent.executeTool<ToolOutputByName["${toolName}"]>("${toolName}", { integrationId: "${id}", request: ${requestExpr} })`;
1242
- const listKey = "listIdOrSlug: __normalizeAttioObjectSlug(params.list)";
1243
- const listParam = "list: GeneratedAttioList | string";
1244
- switch (toolName) {
1245
- case "attio_read_lists":
1246
- return [
1247
- {
1248
- description: attioActionDescription(toolName, "list"),
1249
- generatedSignature: 'listLists(): Promise<{ lists: NonNullable<AttioListsResult["lists"]>; count: number }>',
1250
- runtimeLines: ["listLists: () =>", ` ${call('{ action: "list" }')}.then(result => ({ lists: result.lists ?? [], count: (result.lists ?? []).length })),`]
1251
- },
1252
- {
1253
- description: attioActionDescription(toolName, "get"),
1254
- generatedSignature: `getList(params: { ${listParam} }): Promise<NonNullable<AttioListsResult["list"]>>`,
1255
- runtimeLines: [`getList: (params: { ${listParam} }) =>`, ` ${call(`{ action: "get", ${listKey} }`)}.then(result => __requireAttioPayload(result.list, "list")),`]
1256
- }
1257
- ];
1258
- case "attio_create_list":
1259
- return [
1260
- {
1261
- description: tool.description || undefined,
1262
- generatedSignature: 'createList(params: ToolInputByName["attio_create_list"]["request"]): Promise<NonNullable<AttioListsResult["list"]>>',
1263
- runtimeLines: ['createList: (params: ToolInputByName["attio_create_list"]["request"]) =>', ` ${call("params")}.then(result => __requireAttioPayload(result.list, "list")),`]
1264
- }
1265
- ];
1266
- case "attio_update_list":
1267
- return [
1268
- {
1269
- description: tool.description || undefined,
1270
- generatedSignature: `updateList(params: { ${listParam}; name: string }): Promise<NonNullable<AttioListsResult["list"]>>`,
1271
- runtimeLines: [
1272
- `updateList: (params: { ${listParam}; name: string }) =>`,
1273
- ` ${call(`{ ${listKey}, name: params.name }`)}.then(result => __requireAttioPayload(result.list, "list")),`
1274
- ]
1275
- }
1276
- ];
1277
- case "attio_read_list_entries":
1278
- return [
1279
- {
1280
- description: attioActionDescription(toolName, "query_entries"),
1281
- generatedSignature: "queryListEntries<TList extends GeneratedAttioList | string>(params: { list: TList; filter?: AttioEntryFilterFor<TList> | null; parentRecordId?: string | null; parentObjectSlug?: string; limit?: number | null; offset?: number | null }): Promise<AttioListEntriesResult<TList>>",
1282
- runtimeLines: [
1283
- "queryListEntries: <TList extends GeneratedAttioList | string>(params: { list: TList; filter?: AttioEntryFilterFor<TList> | null; parentRecordId?: string | null; parentObjectSlug?: string; limit?: number | null; offset?: number | null }) =>",
1284
- ` ${call('{ action: "query_entries", listIdOrSlug: __normalizeAttioObjectSlug(params.list), filter: __serializeAttioFilter(params.filter), parentRecordId: params.parentRecordId ?? null, parentObjectSlug: params.parentRecordId ? __requireAttioListParentObject(params.list, params.parentObjectSlug) : null, limit: params.limit ?? null, offset: params.offset ?? null }')}.then(result => __enhanceAttioListEntriesResult(params.list, result)),`
1285
- ]
1286
- },
1287
- {
1288
- description: attioActionDescription(toolName, "get_entry"),
1289
- generatedSignature: "getListEntry<TList extends GeneratedAttioList | string>(params: { list: TList; entryId: string }): Promise<AttioListEntryResult<TList>>",
1290
- runtimeLines: [
1291
- "getListEntry: <TList extends GeneratedAttioList | string>(params: { list: TList; entryId: string }) =>",
1292
- ` ${call('{ action: "get_entry", listIdOrSlug: __normalizeAttioObjectSlug(params.list), entryId: params.entryId }')}.then(result => __enhanceAttioListEntryResult(params.list, result)),`
1293
- ]
1294
- }
1295
- ];
1296
- case "attio_add_list_entry":
1297
- return [
1298
- {
1299
- description: tool.description || undefined,
1300
- generatedSignature: "addListEntry<TList extends GeneratedAttioList | string>(params: { list: TList; parentRecordId: string; parentObjectSlug?: string; entryValues?: AttioEntryValuesFor<TList> | null }): Promise<AttioListEntryResult<TList>>",
1301
- runtimeLines: [
1302
- "addListEntry: <TList extends GeneratedAttioList | string>(params: { list: TList; parentRecordId: string; parentObjectSlug?: string; entryValues?: AttioEntryValuesFor<TList> | null }) =>",
1303
- ` ${call("{ listIdOrSlug: __normalizeAttioObjectSlug(params.list), parentObjectSlug: __requireAttioListParentObject(params.list, params.parentObjectSlug), parentRecordId: params.parentRecordId, entryValues: __serializeAttioValues(params.entryValues) }")}.then(result => __enhanceAttioListEntryResult(params.list, result)),`
1304
- ]
1305
- }
1306
- ];
1307
- case "attio_upsert_list_entry":
1308
- return [
1309
- {
1310
- description: tool.description || undefined,
1311
- generatedSignature: "upsertListEntry<TList extends GeneratedAttioList | string>(params: { list: TList; parentRecordId: string; parentObjectSlug?: string; entryValues?: AttioEntryValuesFor<TList> | null }): Promise<AttioListEntryResult<TList>>",
1312
- runtimeLines: [
1313
- "upsertListEntry: <TList extends GeneratedAttioList | string>(params: { list: TList; parentRecordId: string; parentObjectSlug?: string; entryValues?: AttioEntryValuesFor<TList> | null }) =>",
1314
- ` ${call("{ listIdOrSlug: __normalizeAttioObjectSlug(params.list), parentObjectSlug: __requireAttioListParentObject(params.list, params.parentObjectSlug), parentRecordId: params.parentRecordId, entryValues: __serializeAttioValues(params.entryValues) }")}.then(result => __enhanceAttioListEntryResult(params.list, result)),`
1315
- ]
1316
- }
1317
- ];
1318
- case "attio_update_list_entry":
1319
- return [
1320
- {
1321
- description: tool.description || undefined,
1322
- generatedSignature: 'updateListEntry<TList extends GeneratedAttioList | string>(params: { list: TList; entryId: string; entryValues: Partial<AttioEntryValuesFor<TList>>; multiselectMode?: "overwrite" | "append" | null }): Promise<AttioListEntryResult<TList>>',
1323
- runtimeLines: [
1324
- 'updateListEntry: <TList extends GeneratedAttioList | string>(params: { list: TList; entryId: string; entryValues: Partial<AttioEntryValuesFor<TList>>; multiselectMode?: "overwrite" | "append" | null }) =>',
1325
- ` ${call("{ listIdOrSlug: __normalizeAttioObjectSlug(params.list), entryId: params.entryId, entryValues: __serializeAttioValues(params.entryValues), multiselectMode: params.multiselectMode ?? null }")}.then(result => __enhanceAttioListEntryResult(params.list, result)),`
1326
- ]
1327
- }
1328
- ];
1329
- case "attio_remove_list_entry":
1330
- return [
1331
- {
1332
- description: tool.description || undefined,
1333
- generatedSignature: `removeListEntry(params: { ${listParam}; entryId: string }): Promise<void>`,
1334
- runtimeLines: [
1335
- `removeListEntry: (params: { ${listParam}; entryId: string }) =>`,
1336
- ` ${call("{ listIdOrSlug: __normalizeAttioObjectSlug(params.list), entryId: params.entryId }")}.then(() => undefined),`
1337
- ]
1338
- }
1339
- ];
1340
- default:
1341
- return [];
1342
- }
1343
- }
1344
- function prepareSystemSection() {
1345
- return sectionData([
1346
- "TimeTriggerConfig",
1347
- "WebConfig",
1348
- "ImageEditConfig",
1349
- "MemoryConfig",
1350
- "TypedSkill",
1351
- "WebhookInputConfig",
1352
- "WebhookTrigger",
1353
- "CronTrigger",
1354
- "TypedTrigger",
1355
- "WebMonitorConfig",
1356
- "WebMonitorTrigger",
1357
- "FrequencyUnit",
1358
- "InferStructuredOutput"
1359
- ], {});
1360
- }
1361
- export function prepareTemplateContext(input) {
1362
- const allImports = new Set();
1363
- const active = resolveActiveInstances(input);
1364
- const github = prepareGitHubSection(active.github, input.tools);
1365
- const gmail = prepareGmailSection(active.gmail, input.tools);
1366
- const slack = prepareSlackSection(active.slack, input.tools);
1367
- const linear = prepareLinearSection(active.linear, input.tools);
1368
- const notion = prepareNotionSection(active.notion, input.tools);
1369
- const posthog = preparePosthogSection(active.posthog, input.tools);
1370
- const datadog = prepareDatadogSection(active.datadog, input.tools);
1371
- const launchdarkly = prepareLaunchDarklySection(active.launchdarkly, input.tools);
1372
- const workos = prepareWorkOSSection(active.workos, input.tools);
1373
- const attio = prepareAttioSection(active.attio, input.tools);
1374
- const snowflake = prepareSnowflakeSection(active.snowflake, input.tools);
1375
- const heyreach = prepareHeyReachSection(active.heyreach);
1376
- const resend = prepareResendSection(active.resend, input.tools);
1377
- const tools = prepareToolsSection(input.tools, input, active);
1378
- const system = prepareSystemSection();
1379
- const sections = [github, gmail, slack, linear, notion, posthog, datadog, launchdarkly, workos, attio, snowflake, heyreach, resend, tools, system];
1380
- for (const section of sections) {
1381
- section.imports.forEach(value => allImports.add(value));
1382
- }
1383
- const imports = [...allImports].sort();
1384
- return {
1385
- imports,
1386
- useMultilineImports: imports.length > 3,
1387
- availableIntegrations: input.availableIntegrations.length > 0 ? input.availableIntegrations.join(", ") : undefined,
1388
- github: github.data,
1389
- gmail: gmail.data,
1390
- slack: slack.data,
1391
- linear: linear.data,
1392
- notion: notion.data,
1393
- posthog: posthog.data,
1394
- datadog: datadog.data,
1395
- launchdarkly: launchdarkly.data,
1396
- workos: workos.data,
1397
- attio: attio.data,
1398
- snowflake: snowflake.data,
1399
- heyreach: heyreach.data,
1400
- resend: resend.data,
1401
- tools: tools.data,
1402
- system: system.data
1403
- };
1404
- }
1405
- function resolveActiveInstances(input) {
1406
- const pins = input.activeConnections;
1407
- return {
1408
- github: selectActiveInstance(input.github, pins[IntegrationType.GITHUB], data => data.integration.id),
1409
- gmail: selectActiveInstance(input.gmail, pins[IntegrationType.GMAIL], data => data.id),
1410
- slack: selectActiveInstance(input.slack, pins[IntegrationType.SLACK], data => data.id),
1411
- linear: selectActiveInstance(input.linear, pins[IntegrationType.LINEAR], data => data.id),
1412
- notion: selectActiveInstance(input.notion, pins[IntegrationType.NOTION], data => data.id),
1413
- posthog: selectActiveInstance(input.posthog, pins[IntegrationType.POSTHOG], data => data.id),
1414
- datadog: selectActiveInstance(input.datadog, pins[IntegrationType.DATADOG], data => data.id),
1415
- launchdarkly: selectActiveInstance(input.launchdarkly, pins[IntegrationType.LAUNCHDARKLY], data => data.id),
1416
- workos: selectActiveInstance(input.workos, pins[IntegrationType.WORKOS], data => data.id),
1417
- attio: selectActiveInstance(input.attio, pins[IntegrationType.ATTIO], data => data.id),
1418
- snowflake: selectActiveInstance(input.snowflake, pins[IntegrationType.SNOWFLAKE], data => data.id),
1419
- heyreach: selectActiveInstance(input.heyreach, pins[IntegrationType.HEY_REACH], data => data.id),
1420
- resend: selectActiveInstance(input.resend, pins[IntegrationType.RESEND], data => data.id)
1421
- };
1422
- }
1423
- function selectActiveInstance(instances, activeConnectionId, idOf) {
1424
- if (activeConnectionId) {
1425
- const match = instances.find(instance => idOf(instance) === activeConnectionId);
1426
- if (match)
1427
- return match;
1428
- }
1429
- return instances[0];
1430
- }
1431
- //# sourceMappingURL=prepareCodegenData.js.map