conductor-node-mcp 14.2.1 → 14.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/README.md +3 -3
  2. package/auth.d.mts +6 -0
  3. package/auth.d.mts.map +1 -0
  4. package/auth.d.ts +6 -0
  5. package/auth.d.ts.map +1 -0
  6. package/auth.js +37 -0
  7. package/auth.js.map +1 -0
  8. package/{headers.js → auth.mjs} +16 -6
  9. package/auth.mjs.map +1 -0
  10. package/code-tool-paths.cjs +8 -0
  11. package/code-tool-paths.cjs.map +1 -0
  12. package/code-tool-paths.d.cts +2 -0
  13. package/code-tool-paths.d.cts.map +1 -0
  14. package/code-tool-types.d.mts.map +1 -1
  15. package/code-tool-types.d.ts.map +1 -1
  16. package/code-tool-worker.d.mts +5 -0
  17. package/code-tool-worker.d.mts.map +1 -0
  18. package/code-tool-worker.d.ts +5 -0
  19. package/code-tool-worker.d.ts.map +1 -0
  20. package/code-tool-worker.js +518 -0
  21. package/code-tool-worker.js.map +1 -0
  22. package/code-tool-worker.mjs +480 -0
  23. package/code-tool-worker.mjs.map +1 -0
  24. package/code-tool.d.mts +11 -2
  25. package/code-tool.d.mts.map +1 -1
  26. package/code-tool.d.ts +11 -2
  27. package/code-tool.d.ts.map +1 -1
  28. package/code-tool.js +281 -40
  29. package/code-tool.js.map +1 -1
  30. package/code-tool.mjs +249 -41
  31. package/code-tool.mjs.map +1 -1
  32. package/docs-search-tool.d.mts +11 -3
  33. package/docs-search-tool.d.mts.map +1 -1
  34. package/docs-search-tool.d.ts +11 -3
  35. package/docs-search-tool.d.ts.map +1 -1
  36. package/docs-search-tool.js +58 -5
  37. package/docs-search-tool.js.map +1 -1
  38. package/docs-search-tool.mjs +57 -5
  39. package/docs-search-tool.mjs.map +1 -1
  40. package/http.d.mts +6 -3
  41. package/http.d.mts.map +1 -1
  42. package/http.d.ts +6 -3
  43. package/http.d.ts.map +1 -1
  44. package/http.js +130 -28
  45. package/http.js.map +1 -1
  46. package/http.mjs +130 -28
  47. package/http.mjs.map +1 -1
  48. package/index.js +17 -12
  49. package/index.js.map +1 -1
  50. package/index.mjs +17 -12
  51. package/index.mjs.map +1 -1
  52. package/instructions.d.mts +5 -0
  53. package/instructions.d.mts.map +1 -0
  54. package/instructions.d.ts +5 -0
  55. package/instructions.d.ts.map +1 -0
  56. package/instructions.js +61 -0
  57. package/instructions.js.map +1 -0
  58. package/instructions.mjs +55 -0
  59. package/instructions.mjs.map +1 -0
  60. package/local-docs-search.d.mts +28 -0
  61. package/local-docs-search.d.mts.map +1 -0
  62. package/local-docs-search.d.ts +28 -0
  63. package/local-docs-search.d.ts.map +1 -0
  64. package/local-docs-search.js +9219 -0
  65. package/local-docs-search.js.map +1 -0
  66. package/local-docs-search.mjs +9179 -0
  67. package/local-docs-search.mjs.map +1 -0
  68. package/logger.d.mts +7 -0
  69. package/logger.d.mts.map +1 -0
  70. package/logger.d.ts +7 -0
  71. package/logger.d.ts.map +1 -0
  72. package/logger.js +29 -0
  73. package/logger.js.map +1 -0
  74. package/logger.mjs +22 -0
  75. package/logger.mjs.map +1 -0
  76. package/methods.d.mts +10 -0
  77. package/methods.d.mts.map +1 -0
  78. package/methods.d.ts +10 -0
  79. package/methods.d.ts.map +1 -0
  80. package/methods.js +1577 -0
  81. package/methods.js.map +1 -0
  82. package/methods.mjs +1573 -0
  83. package/methods.mjs.map +1 -0
  84. package/options.d.mts +12 -0
  85. package/options.d.mts.map +1 -1
  86. package/options.d.ts +12 -0
  87. package/options.d.ts.map +1 -1
  88. package/options.js +81 -12
  89. package/options.js.map +1 -1
  90. package/options.mjs +81 -12
  91. package/options.mjs.map +1 -1
  92. package/package.json +89 -15
  93. package/server.d.mts +18 -10
  94. package/server.d.mts.map +1 -1
  95. package/server.d.ts +18 -10
  96. package/server.d.ts.map +1 -1
  97. package/server.js +89 -42
  98. package/server.js.map +1 -1
  99. package/server.mjs +88 -39
  100. package/server.mjs.map +1 -1
  101. package/src/{headers.ts → auth.ts} +18 -1
  102. package/src/code-tool-paths.cts +5 -0
  103. package/src/code-tool-types.ts +1 -0
  104. package/src/code-tool-worker.ts +531 -0
  105. package/src/code-tool.ts +335 -48
  106. package/src/docs-search-tool.ts +86 -7
  107. package/src/http.ts +154 -33
  108. package/src/index.ts +19 -13
  109. package/src/instructions.ts +83 -0
  110. package/src/local-docs-search.ts +10667 -0
  111. package/src/logger.ts +28 -0
  112. package/src/methods.ts +1598 -0
  113. package/src/options.ts +105 -12
  114. package/src/server.ts +111 -50
  115. package/src/stdio.ts +9 -4
  116. package/src/types.ts +15 -4
  117. package/src/util.ts +25 -0
  118. package/stdio.d.mts +2 -1
  119. package/stdio.d.mts.map +1 -1
  120. package/stdio.d.ts +2 -1
  121. package/stdio.d.ts.map +1 -1
  122. package/stdio.js +8 -4
  123. package/stdio.js.map +1 -1
  124. package/stdio.mjs +8 -4
  125. package/stdio.mjs.map +1 -1
  126. package/types.d.mts +14 -1
  127. package/types.d.mts.map +1 -1
  128. package/types.d.ts +14 -1
  129. package/types.d.ts.map +1 -1
  130. package/types.js.map +1 -1
  131. package/types.mjs.map +1 -1
  132. package/util.d.mts +4 -0
  133. package/util.d.mts.map +1 -0
  134. package/util.d.ts +4 -0
  135. package/util.d.ts.map +1 -0
  136. package/util.js +30 -0
  137. package/util.js.map +1 -0
  138. package/util.mjs +24 -0
  139. package/util.mjs.map +1 -0
  140. package/headers.d.mts +0 -4
  141. package/headers.d.mts.map +0 -1
  142. package/headers.d.ts +0 -4
  143. package/headers.d.ts.map +0 -1
  144. package/headers.js.map +0 -1
  145. package/headers.mjs +0 -18
  146. package/headers.mjs.map +0 -1
@@ -0,0 +1,480 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ import path from 'node:path';
3
+ import util from 'node:util';
4
+ import Fuse from 'fuse.js';
5
+ import ts from 'typescript';
6
+ import { Conductor } from 'conductor-node';
7
+ async function tseval(code) {
8
+ return import('data:application/typescript;charset=utf-8;base64,' + Buffer.from(code).toString('base64'));
9
+ }
10
+ function getRunFunctionSource(code) {
11
+ const sourceFile = ts.createSourceFile('code.ts', code, ts.ScriptTarget.Latest, true);
12
+ const printer = ts.createPrinter();
13
+ for (const statement of sourceFile.statements) {
14
+ // Check for top-level function declarations
15
+ if (ts.isFunctionDeclaration(statement)) {
16
+ if (statement.name?.text === 'run') {
17
+ return {
18
+ type: 'declaration',
19
+ client: statement.parameters[0]?.name.getText(),
20
+ code: printer.printNode(ts.EmitHint.Unspecified, statement.body, sourceFile),
21
+ };
22
+ }
23
+ }
24
+ // Check for variable declarations: const run = () => {} or const run = function() {}
25
+ if (ts.isVariableStatement(statement)) {
26
+ for (const declaration of statement.declarationList.declarations) {
27
+ if (ts.isIdentifier(declaration.name) &&
28
+ declaration.name.text === 'run' &&
29
+ // Check if it's initialized with a function
30
+ declaration.initializer &&
31
+ (ts.isFunctionExpression(declaration.initializer) || ts.isArrowFunction(declaration.initializer))) {
32
+ return {
33
+ type: 'expression',
34
+ client: declaration.initializer.parameters[0]?.name.getText(),
35
+ code: printer.printNode(ts.EmitHint.Unspecified, declaration.initializer, sourceFile),
36
+ };
37
+ }
38
+ }
39
+ }
40
+ }
41
+ return null;
42
+ }
43
+ function getTSDiagnostics(code) {
44
+ const functionSource = getRunFunctionSource(code);
45
+ const codeWithImport = [
46
+ 'import { Conductor } from "conductor-node";',
47
+ functionSource.type === 'declaration' ?
48
+ `async function run(${functionSource.client}: Conductor)`
49
+ : `const run: (${functionSource.client}: Conductor) => Promise<unknown> =`,
50
+ functionSource.code,
51
+ ].join('\n');
52
+ const sourcePath = path.resolve('code.ts');
53
+ const ast = ts.createSourceFile(sourcePath, codeWithImport, ts.ScriptTarget.Latest, true);
54
+ const options = ts.getDefaultCompilerOptions();
55
+ options.target = ts.ScriptTarget.Latest;
56
+ options.module = ts.ModuleKind.NodeNext;
57
+ options.moduleResolution = ts.ModuleResolutionKind.NodeNext;
58
+ const host = ts.createCompilerHost(options, true);
59
+ const newHost = {
60
+ ...host,
61
+ getSourceFile: (...args) => {
62
+ if (path.resolve(args[0]) === sourcePath) {
63
+ return ast;
64
+ }
65
+ return host.getSourceFile(...args);
66
+ },
67
+ readFile: (...args) => {
68
+ if (path.resolve(args[0]) === sourcePath) {
69
+ return codeWithImport;
70
+ }
71
+ return host.readFile(...args);
72
+ },
73
+ fileExists: (...args) => {
74
+ if (path.resolve(args[0]) === sourcePath) {
75
+ return true;
76
+ }
77
+ return host.fileExists(...args);
78
+ },
79
+ };
80
+ const program = ts.createProgram({
81
+ options,
82
+ rootNames: [sourcePath],
83
+ host: newHost,
84
+ });
85
+ const diagnostics = ts.getPreEmitDiagnostics(program, ast);
86
+ return diagnostics.map((d) => {
87
+ const message = ts.flattenDiagnosticMessageText(d.messageText, '\n');
88
+ if (!d.file || !d.start)
89
+ return `- ${message}`;
90
+ const { line: lineNumber } = ts.getLineAndCharacterOfPosition(d.file, d.start);
91
+ const line = codeWithImport.split('\n').at(lineNumber)?.trim();
92
+ return line ? `- ${message}\n ${line}` : `- ${message}`;
93
+ });
94
+ }
95
+ const fuse = new Fuse([
96
+ 'conductor.authSessions.create',
97
+ 'conductor.endUsers.create',
98
+ 'conductor.endUsers.delete',
99
+ 'conductor.endUsers.list',
100
+ 'conductor.endUsers.passthrough',
101
+ 'conductor.endUsers.retrieve',
102
+ 'conductor.qbd.healthCheck',
103
+ 'conductor.qbd.accountTaxLines.list',
104
+ 'conductor.qbd.accounts.create',
105
+ 'conductor.qbd.accounts.list',
106
+ 'conductor.qbd.accounts.retrieve',
107
+ 'conductor.qbd.accounts.update',
108
+ 'conductor.qbd.billCheckPayments.create',
109
+ 'conductor.qbd.billCheckPayments.delete',
110
+ 'conductor.qbd.billCheckPayments.list',
111
+ 'conductor.qbd.billCheckPayments.retrieve',
112
+ 'conductor.qbd.billCheckPayments.update',
113
+ 'conductor.qbd.billCheckPayments.void',
114
+ 'conductor.qbd.billCreditCardPayments.create',
115
+ 'conductor.qbd.billCreditCardPayments.delete',
116
+ 'conductor.qbd.billCreditCardPayments.list',
117
+ 'conductor.qbd.billCreditCardPayments.retrieve',
118
+ 'conductor.qbd.billCreditCardPayments.void',
119
+ 'conductor.qbd.bills.create',
120
+ 'conductor.qbd.bills.delete',
121
+ 'conductor.qbd.bills.list',
122
+ 'conductor.qbd.bills.retrieve',
123
+ 'conductor.qbd.bills.update',
124
+ 'conductor.qbd.bills.void',
125
+ 'conductor.qbd.billsToPay.list',
126
+ 'conductor.qbd.buildAssemblies.create',
127
+ 'conductor.qbd.buildAssemblies.delete',
128
+ 'conductor.qbd.buildAssemblies.list',
129
+ 'conductor.qbd.buildAssemblies.retrieve',
130
+ 'conductor.qbd.buildAssemblies.update',
131
+ 'conductor.qbd.checks.create',
132
+ 'conductor.qbd.checks.delete',
133
+ 'conductor.qbd.checks.list',
134
+ 'conductor.qbd.checks.retrieve',
135
+ 'conductor.qbd.checks.update',
136
+ 'conductor.qbd.checks.void',
137
+ 'conductor.qbd.classes.create',
138
+ 'conductor.qbd.classes.list',
139
+ 'conductor.qbd.classes.retrieve',
140
+ 'conductor.qbd.classes.update',
141
+ 'conductor.qbd.company.retrieve',
142
+ 'conductor.qbd.creditCardCharges.create',
143
+ 'conductor.qbd.creditCardCharges.delete',
144
+ 'conductor.qbd.creditCardCharges.list',
145
+ 'conductor.qbd.creditCardCharges.retrieve',
146
+ 'conductor.qbd.creditCardCharges.update',
147
+ 'conductor.qbd.creditCardCharges.void',
148
+ 'conductor.qbd.creditCardCredits.create',
149
+ 'conductor.qbd.creditCardCredits.delete',
150
+ 'conductor.qbd.creditCardCredits.list',
151
+ 'conductor.qbd.creditCardCredits.retrieve',
152
+ 'conductor.qbd.creditCardCredits.update',
153
+ 'conductor.qbd.creditCardCredits.void',
154
+ 'conductor.qbd.creditCardRefunds.create',
155
+ 'conductor.qbd.creditCardRefunds.delete',
156
+ 'conductor.qbd.creditCardRefunds.list',
157
+ 'conductor.qbd.creditCardRefunds.retrieve',
158
+ 'conductor.qbd.creditCardRefunds.void',
159
+ 'conductor.qbd.creditMemos.create',
160
+ 'conductor.qbd.creditMemos.delete',
161
+ 'conductor.qbd.creditMemos.list',
162
+ 'conductor.qbd.creditMemos.retrieve',
163
+ 'conductor.qbd.creditMemos.update',
164
+ 'conductor.qbd.creditMemos.void',
165
+ 'conductor.qbd.currencies.create',
166
+ 'conductor.qbd.currencies.list',
167
+ 'conductor.qbd.currencies.retrieve',
168
+ 'conductor.qbd.currencies.update',
169
+ 'conductor.qbd.customerTypes.create',
170
+ 'conductor.qbd.customerTypes.list',
171
+ 'conductor.qbd.customerTypes.retrieve',
172
+ 'conductor.qbd.customers.create',
173
+ 'conductor.qbd.customers.list',
174
+ 'conductor.qbd.customers.retrieve',
175
+ 'conductor.qbd.customers.update',
176
+ 'conductor.qbd.dateDrivenTerms.create',
177
+ 'conductor.qbd.dateDrivenTerms.list',
178
+ 'conductor.qbd.dateDrivenTerms.retrieve',
179
+ 'conductor.qbd.deletedListObjects.list',
180
+ 'conductor.qbd.deletedTransactions.list',
181
+ 'conductor.qbd.deposits.create',
182
+ 'conductor.qbd.deposits.delete',
183
+ 'conductor.qbd.deposits.list',
184
+ 'conductor.qbd.deposits.retrieve',
185
+ 'conductor.qbd.deposits.update',
186
+ 'conductor.qbd.deposits.void',
187
+ 'conductor.qbd.discountItems.create',
188
+ 'conductor.qbd.discountItems.list',
189
+ 'conductor.qbd.discountItems.retrieve',
190
+ 'conductor.qbd.discountItems.update',
191
+ 'conductor.qbd.employees.create',
192
+ 'conductor.qbd.employees.list',
193
+ 'conductor.qbd.employees.retrieve',
194
+ 'conductor.qbd.employees.update',
195
+ 'conductor.qbd.estimates.create',
196
+ 'conductor.qbd.estimates.delete',
197
+ 'conductor.qbd.estimates.list',
198
+ 'conductor.qbd.estimates.retrieve',
199
+ 'conductor.qbd.estimates.update',
200
+ 'conductor.qbd.inventoryAdjustments.create',
201
+ 'conductor.qbd.inventoryAdjustments.delete',
202
+ 'conductor.qbd.inventoryAdjustments.list',
203
+ 'conductor.qbd.inventoryAdjustments.retrieve',
204
+ 'conductor.qbd.inventoryAdjustments.update',
205
+ 'conductor.qbd.inventoryAdjustments.void',
206
+ 'conductor.qbd.inventoryAssemblyItems.create',
207
+ 'conductor.qbd.inventoryAssemblyItems.list',
208
+ 'conductor.qbd.inventoryAssemblyItems.retrieve',
209
+ 'conductor.qbd.inventoryAssemblyItems.update',
210
+ 'conductor.qbd.inventoryItems.create',
211
+ 'conductor.qbd.inventoryItems.list',
212
+ 'conductor.qbd.inventoryItems.retrieve',
213
+ 'conductor.qbd.inventoryItems.update',
214
+ 'conductor.qbd.inventorySites.create',
215
+ 'conductor.qbd.inventorySites.list',
216
+ 'conductor.qbd.inventorySites.retrieve',
217
+ 'conductor.qbd.inventorySites.update',
218
+ 'conductor.qbd.invoices.create',
219
+ 'conductor.qbd.invoices.delete',
220
+ 'conductor.qbd.invoices.list',
221
+ 'conductor.qbd.invoices.retrieve',
222
+ 'conductor.qbd.invoices.update',
223
+ 'conductor.qbd.invoices.void',
224
+ 'conductor.qbd.itemGroups.create',
225
+ 'conductor.qbd.itemGroups.list',
226
+ 'conductor.qbd.itemGroups.retrieve',
227
+ 'conductor.qbd.itemGroups.update',
228
+ 'conductor.qbd.itemReceipts.create',
229
+ 'conductor.qbd.itemReceipts.delete',
230
+ 'conductor.qbd.itemReceipts.list',
231
+ 'conductor.qbd.itemReceipts.retrieve',
232
+ 'conductor.qbd.itemReceipts.update',
233
+ 'conductor.qbd.itemReceipts.void',
234
+ 'conductor.qbd.itemSites.list',
235
+ 'conductor.qbd.itemSites.retrieve',
236
+ 'conductor.qbd.journalEntries.create',
237
+ 'conductor.qbd.journalEntries.delete',
238
+ 'conductor.qbd.journalEntries.list',
239
+ 'conductor.qbd.journalEntries.retrieve',
240
+ 'conductor.qbd.journalEntries.update',
241
+ 'conductor.qbd.journalEntries.void',
242
+ 'conductor.qbd.nonInventoryItems.create',
243
+ 'conductor.qbd.nonInventoryItems.list',
244
+ 'conductor.qbd.nonInventoryItems.retrieve',
245
+ 'conductor.qbd.nonInventoryItems.update',
246
+ 'conductor.qbd.otherChargeItems.create',
247
+ 'conductor.qbd.otherChargeItems.list',
248
+ 'conductor.qbd.otherChargeItems.retrieve',
249
+ 'conductor.qbd.otherChargeItems.update',
250
+ 'conductor.qbd.otherNames.create',
251
+ 'conductor.qbd.otherNames.list',
252
+ 'conductor.qbd.otherNames.retrieve',
253
+ 'conductor.qbd.otherNames.update',
254
+ 'conductor.qbd.paymentMethods.create',
255
+ 'conductor.qbd.paymentMethods.list',
256
+ 'conductor.qbd.paymentMethods.retrieve',
257
+ 'conductor.qbd.paymentsToDeposit.list',
258
+ 'conductor.qbd.payrollWageItems.create',
259
+ 'conductor.qbd.payrollWageItems.list',
260
+ 'conductor.qbd.payrollWageItems.retrieve',
261
+ 'conductor.qbd.preferences.retrieve',
262
+ 'conductor.qbd.priceLevels.create',
263
+ 'conductor.qbd.priceLevels.list',
264
+ 'conductor.qbd.priceLevels.retrieve',
265
+ 'conductor.qbd.priceLevels.update',
266
+ 'conductor.qbd.purchaseOrders.create',
267
+ 'conductor.qbd.purchaseOrders.delete',
268
+ 'conductor.qbd.purchaseOrders.list',
269
+ 'conductor.qbd.purchaseOrders.retrieve',
270
+ 'conductor.qbd.purchaseOrders.update',
271
+ 'conductor.qbd.receivePayments.create',
272
+ 'conductor.qbd.receivePayments.delete',
273
+ 'conductor.qbd.receivePayments.list',
274
+ 'conductor.qbd.receivePayments.retrieve',
275
+ 'conductor.qbd.receivePayments.update',
276
+ 'conductor.qbd.reports.aging',
277
+ 'conductor.qbd.reports.budgetSummary',
278
+ 'conductor.qbd.reports.customDetail',
279
+ 'conductor.qbd.reports.customSummary',
280
+ 'conductor.qbd.reports.generalDetail',
281
+ 'conductor.qbd.reports.generalSummary',
282
+ 'conductor.qbd.reports.job',
283
+ 'conductor.qbd.reports.payrollDetail',
284
+ 'conductor.qbd.reports.payrollSummary',
285
+ 'conductor.qbd.reports.time',
286
+ 'conductor.qbd.salesOrders.create',
287
+ 'conductor.qbd.salesOrders.delete',
288
+ 'conductor.qbd.salesOrders.list',
289
+ 'conductor.qbd.salesOrders.retrieve',
290
+ 'conductor.qbd.salesOrders.update',
291
+ 'conductor.qbd.salesReceipts.create',
292
+ 'conductor.qbd.salesReceipts.delete',
293
+ 'conductor.qbd.salesReceipts.list',
294
+ 'conductor.qbd.salesReceipts.retrieve',
295
+ 'conductor.qbd.salesReceipts.update',
296
+ 'conductor.qbd.salesReceipts.void',
297
+ 'conductor.qbd.salesRepresentatives.create',
298
+ 'conductor.qbd.salesRepresentatives.list',
299
+ 'conductor.qbd.salesRepresentatives.retrieve',
300
+ 'conductor.qbd.salesRepresentatives.update',
301
+ 'conductor.qbd.salesTaxCodes.create',
302
+ 'conductor.qbd.salesTaxCodes.list',
303
+ 'conductor.qbd.salesTaxCodes.retrieve',
304
+ 'conductor.qbd.salesTaxCodes.update',
305
+ 'conductor.qbd.salesTaxItems.create',
306
+ 'conductor.qbd.salesTaxItems.list',
307
+ 'conductor.qbd.salesTaxItems.retrieve',
308
+ 'conductor.qbd.salesTaxItems.update',
309
+ 'conductor.qbd.serviceItems.create',
310
+ 'conductor.qbd.serviceItems.list',
311
+ 'conductor.qbd.serviceItems.retrieve',
312
+ 'conductor.qbd.serviceItems.update',
313
+ 'conductor.qbd.shippingMethods.create',
314
+ 'conductor.qbd.shippingMethods.list',
315
+ 'conductor.qbd.shippingMethods.retrieve',
316
+ 'conductor.qbd.standardTerms.create',
317
+ 'conductor.qbd.standardTerms.list',
318
+ 'conductor.qbd.standardTerms.retrieve',
319
+ 'conductor.qbd.subtotalItems.create',
320
+ 'conductor.qbd.subtotalItems.list',
321
+ 'conductor.qbd.subtotalItems.retrieve',
322
+ 'conductor.qbd.subtotalItems.update',
323
+ 'conductor.qbd.templates.list',
324
+ 'conductor.qbd.timeTrackingActivities.create',
325
+ 'conductor.qbd.timeTrackingActivities.delete',
326
+ 'conductor.qbd.timeTrackingActivities.list',
327
+ 'conductor.qbd.timeTrackingActivities.retrieve',
328
+ 'conductor.qbd.timeTrackingActivities.update',
329
+ 'conductor.qbd.transactions.list',
330
+ 'conductor.qbd.transactions.retrieve',
331
+ 'conductor.qbd.transfers.create',
332
+ 'conductor.qbd.transfers.list',
333
+ 'conductor.qbd.transfers.retrieve',
334
+ 'conductor.qbd.transfers.update',
335
+ 'conductor.qbd.unitOfMeasureSets.create',
336
+ 'conductor.qbd.unitOfMeasureSets.list',
337
+ 'conductor.qbd.unitOfMeasureSets.retrieve',
338
+ 'conductor.qbd.vendorCredits.create',
339
+ 'conductor.qbd.vendorCredits.delete',
340
+ 'conductor.qbd.vendorCredits.list',
341
+ 'conductor.qbd.vendorCredits.retrieve',
342
+ 'conductor.qbd.vendorCredits.update',
343
+ 'conductor.qbd.vendorCredits.void',
344
+ 'conductor.qbd.vendors.create',
345
+ 'conductor.qbd.vendors.list',
346
+ 'conductor.qbd.vendors.retrieve',
347
+ 'conductor.qbd.vendors.update',
348
+ ], { threshold: 1, shouldSort: true });
349
+ function getMethodSuggestions(fullyQualifiedMethodName) {
350
+ return fuse
351
+ .search(fullyQualifiedMethodName)
352
+ .map(({ item }) => item)
353
+ .slice(0, 5);
354
+ }
355
+ const proxyToObj = new WeakMap();
356
+ const objToProxy = new WeakMap();
357
+ function makeSdkProxy(obj, { path, isBelievedBad = false }) {
358
+ let proxy = objToProxy.get(obj);
359
+ if (!proxy) {
360
+ proxy = new Proxy(obj, {
361
+ get(target, prop, receiver) {
362
+ const propPath = [...path, String(prop)];
363
+ const value = Reflect.get(target, prop, receiver);
364
+ if (isBelievedBad || (!(prop in target) && value === undefined)) {
365
+ // If we're accessing a path that doesn't exist, it will probably eventually error.
366
+ // Let's proxy it and mark it bad so that we can control the error message.
367
+ // We proxy an empty class so that an invocation or construction attempt is possible.
368
+ return makeSdkProxy(class {
369
+ }, { path: propPath, isBelievedBad: true });
370
+ }
371
+ if (value !== null && (typeof value === 'object' || typeof value === 'function')) {
372
+ return makeSdkProxy(value, { path: propPath, isBelievedBad });
373
+ }
374
+ return value;
375
+ },
376
+ apply(target, thisArg, args) {
377
+ if (isBelievedBad || typeof target !== 'function') {
378
+ const fullyQualifiedMethodName = path.join('.');
379
+ const suggestions = getMethodSuggestions(fullyQualifiedMethodName);
380
+ throw new Error(`${fullyQualifiedMethodName} is not a function. Did you mean: ${suggestions.join(', ')}`);
381
+ }
382
+ return Reflect.apply(target, proxyToObj.get(thisArg) ?? thisArg, args);
383
+ },
384
+ construct(target, args, newTarget) {
385
+ if (isBelievedBad || typeof target !== 'function') {
386
+ const fullyQualifiedMethodName = path.join('.');
387
+ const suggestions = getMethodSuggestions(fullyQualifiedMethodName);
388
+ throw new Error(`${fullyQualifiedMethodName} is not a constructor. Did you mean: ${suggestions.join(', ')}`);
389
+ }
390
+ return Reflect.construct(target, args, newTarget);
391
+ },
392
+ });
393
+ objToProxy.set(obj, proxy);
394
+ proxyToObj.set(proxy, obj);
395
+ }
396
+ return proxy;
397
+ }
398
+ function parseError(code, error) {
399
+ if (!(error instanceof Error))
400
+ return;
401
+ const cause = error.cause instanceof Error ? `: ${error.cause.message}` : '';
402
+ const message = error.name ? `${error.name}: ${error.message}${cause}` : `${error.message}${cause}`;
403
+ try {
404
+ // Deno uses V8; the first "<anonymous>:LINE:COLUMN" is the top of stack.
405
+ const lineNumber = error.stack?.match(/<anonymous>:([0-9]+):[0-9]+/)?.[1];
406
+ // -1 for the zero-based indexing
407
+ const line = lineNumber &&
408
+ code
409
+ .split('\n')
410
+ .at(parseInt(lineNumber, 10) - 1)
411
+ ?.trim();
412
+ return line ? `${message}\n at line ${lineNumber}\n ${line}` : message;
413
+ }
414
+ catch {
415
+ return message;
416
+ }
417
+ }
418
+ const fetch = async (req) => {
419
+ const { opts, code } = (await req.json());
420
+ const runFunctionSource = code ? getRunFunctionSource(code) : null;
421
+ if (!runFunctionSource) {
422
+ const message = code ?
423
+ 'The code is missing a top-level `run` function.'
424
+ : 'The code argument is missing. Provide one containing a top-level `run` function.';
425
+ return Response.json({
426
+ is_error: true,
427
+ result: `${message} Write code within this template:\n\n\`\`\`\nasync function run(conductor) {\n // Fill this out\n}\n\`\`\``,
428
+ log_lines: [],
429
+ err_lines: [],
430
+ }, { status: 400, statusText: 'Code execution error' });
431
+ }
432
+ const diagnostics = getTSDiagnostics(code);
433
+ if (diagnostics.length > 0) {
434
+ return Response.json({
435
+ is_error: true,
436
+ result: `The code contains TypeScript diagnostics:\n${diagnostics.join('\n')}`,
437
+ log_lines: [],
438
+ err_lines: [],
439
+ }, { status: 400, statusText: 'Code execution error' });
440
+ }
441
+ const conductor = new Conductor({
442
+ ...opts,
443
+ });
444
+ const log_lines = [];
445
+ const err_lines = [];
446
+ const originalConsole = globalThis.console;
447
+ globalThis.console = {
448
+ ...originalConsole,
449
+ log: (...args) => {
450
+ log_lines.push(util.format(...args));
451
+ },
452
+ error: (...args) => {
453
+ err_lines.push(util.format(...args));
454
+ },
455
+ };
456
+ try {
457
+ let run_ = async (conductor) => { };
458
+ run_ = (await tseval(`${code}\nexport default run;`)).default;
459
+ const result = await run_(makeSdkProxy(conductor, { path: ['conductor'] }));
460
+ return Response.json({
461
+ is_error: false,
462
+ result,
463
+ log_lines,
464
+ err_lines,
465
+ });
466
+ }
467
+ catch (e) {
468
+ return Response.json({
469
+ is_error: true,
470
+ result: parseError(code, e),
471
+ log_lines,
472
+ err_lines,
473
+ }, { status: 400, statusText: 'Code execution error' });
474
+ }
475
+ finally {
476
+ globalThis.console = originalConsole;
477
+ }
478
+ };
479
+ export default { fetch };
480
+ //# sourceMappingURL=code-tool-worker.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool-worker.mjs","sourceRoot":"","sources":["src/code-tool-worker.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,E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AQ,EAAE,IAAI;YACd,MAAM,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;YAC3B,SAAS;YACT,SAAS;SACa,EACxB,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,sBAAsB,EAAE,CACpD,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,UAAU,CAAC,OAAO,GAAG,eAAe,CAAC;IACvC,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,EAAE,KAAK,EAAE,CAAC"}
package/code-tool.d.mts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { McpTool } from "./types.mjs";
2
+ import { SdkMethod } from "./methods.mjs";
3
+ import { McpCodeExecutionMode } from "./options.mjs";
2
4
  /**
3
5
  * A tool that runs code against a copy of the SDK.
4
6
  *
@@ -6,7 +8,14 @@ import { McpTool } from "./types.mjs";
6
8
  * we expose a single tool that can be used to search for endpoints by name, resource, operation, or tag, and then
7
9
  * a generic endpoint that can be used to invoke any endpoint with the provided arguments.
8
10
  *
9
- * @param endpoints - The endpoints to include in the list.
11
+ * @param blockedMethods - The methods to block for code execution. Blocking is done by simple string
12
+ * matching, so it is not secure against obfuscation. For stronger security, block in the downstream API
13
+ * with limited API keys.
14
+ * @param codeExecutionMode - Whether to execute code in a local Deno environment or in a remote
15
+ * sandbox environment hosted by Stainless.
10
16
  */
11
- export declare function codeTool(): McpTool;
17
+ export declare function codeTool({ blockedMethods, codeExecutionMode, }: {
18
+ blockedMethods: SdkMethod[] | undefined;
19
+ codeExecutionMode: McpCodeExecutionMode;
20
+ }): McpTool;
12
21
  //# sourceMappingURL=code-tool.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"code-tool.d.mts","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"OAEO,EAAE,OAAO,EAAgE;AA0BhF;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,IAAI,OAAO,CAsElC"}
1
+ {"version":3,"file":"code-tool.d.mts","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,OAAO,EAKR,oBAAgB;AAKjB,OAAO,EAAE,SAAS,EAAE,sBAAkB;AACtC,OAAO,EAAE,oBAAoB,EAAE,sBAAkB;AA0BjD;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CAAC,EACvB,cAAc,EACd,iBAAiB,GAClB,EAAE;IACD,cAAc,EAAE,SAAS,EAAE,GAAG,SAAS,CAAC;IACxC,iBAAiB,EAAE,oBAAoB,CAAC;CACzC,GAAG,OAAO,CAuEV"}
package/code-tool.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { McpTool } from "./types.js";
2
+ import { SdkMethod } from "./methods.js";
3
+ import { McpCodeExecutionMode } from "./options.js";
2
4
  /**
3
5
  * A tool that runs code against a copy of the SDK.
4
6
  *
@@ -6,7 +8,14 @@ import { McpTool } from "./types.js";
6
8
  * we expose a single tool that can be used to search for endpoints by name, resource, operation, or tag, and then
7
9
  * a generic endpoint that can be used to invoke any endpoint with the provided arguments.
8
10
  *
9
- * @param endpoints - The endpoints to include in the list.
11
+ * @param blockedMethods - The methods to block for code execution. Blocking is done by simple string
12
+ * matching, so it is not secure against obfuscation. For stronger security, block in the downstream API
13
+ * with limited API keys.
14
+ * @param codeExecutionMode - Whether to execute code in a local Deno environment or in a remote
15
+ * sandbox environment hosted by Stainless.
10
16
  */
11
- export declare function codeTool(): McpTool;
17
+ export declare function codeTool({ blockedMethods, codeExecutionMode, }: {
18
+ blockedMethods: SdkMethod[] | undefined;
19
+ codeExecutionMode: McpCodeExecutionMode;
20
+ }): McpTool;
12
21
  //# sourceMappingURL=code-tool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"code-tool.d.ts","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"OAEO,EAAE,OAAO,EAAgE;AA0BhF;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,IAAI,OAAO,CAsElC"}
1
+ {"version":3,"file":"code-tool.d.ts","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,OAAO,EAKR,mBAAgB;AAKjB,OAAO,EAAE,SAAS,EAAE,qBAAkB;AACtC,OAAO,EAAE,oBAAoB,EAAE,qBAAkB;AA0BjD;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CAAC,EACvB,cAAc,EACd,iBAAiB,GAClB,EAAE;IACD,cAAc,EAAE,SAAS,EAAE,GAAG,SAAS,CAAC;IACxC,iBAAiB,EAAE,oBAAoB,CAAC;CACzC,GAAG,OAAO,CAuEV"}