@taxdao/fintax-mcp 0.2.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 (341) hide show
  1. package/README.md +220 -0
  2. package/dist/app/create-server.d.ts +18 -0
  3. package/dist/app/create-server.js +80 -0
  4. package/dist/app/create-server.js.map +1 -0
  5. package/dist/app/register-tools.d.ts +4 -0
  6. package/dist/app/register-tools.js +18 -0
  7. package/dist/app/register-tools.js.map +1 -0
  8. package/dist/audit/audit-context.d.ts +38 -0
  9. package/dist/audit/audit-context.js +167 -0
  10. package/dist/audit/audit-context.js.map +1 -0
  11. package/dist/audit/audit-sink.d.ts +20 -0
  12. package/dist/audit/audit-sink.js +6 -0
  13. package/dist/audit/audit-sink.js.map +1 -0
  14. package/dist/audit/file-audit-sink.d.ts +6 -0
  15. package/dist/audit/file-audit-sink.js +18 -0
  16. package/dist/audit/file-audit-sink.js.map +1 -0
  17. package/dist/auth/auth-session.d.ts +63 -0
  18. package/dist/auth/auth-session.js +226 -0
  19. package/dist/auth/auth-session.js.map +1 -0
  20. package/dist/auth/credentials.d.ts +6 -0
  21. package/dist/auth/credentials.js +12 -0
  22. package/dist/auth/credentials.js.map +1 -0
  23. package/dist/auth/org-token-provider.d.ts +15 -0
  24. package/dist/auth/org-token-provider.js +62 -0
  25. package/dist/auth/org-token-provider.js.map +1 -0
  26. package/dist/capabilities/capability.d.ts +100 -0
  27. package/dist/capabilities/capability.js +26 -0
  28. package/dist/capabilities/capability.js.map +1 -0
  29. package/dist/capabilities/create-capabilities.d.ts +2 -0
  30. package/dist/capabilities/create-capabilities.js +37 -0
  31. package/dist/capabilities/create-capabilities.js.map +1 -0
  32. package/dist/capabilities/define-capability.d.ts +39 -0
  33. package/dist/capabilities/define-capability.js +64 -0
  34. package/dist/capabilities/define-capability.js.map +1 -0
  35. package/dist/capabilities/definitions/accounting-balances.d.ts +4 -0
  36. package/dist/capabilities/definitions/accounting-balances.js +98 -0
  37. package/dist/capabilities/definitions/accounting-balances.js.map +1 -0
  38. package/dist/capabilities/definitions/accounting-context.d.ts +2 -0
  39. package/dist/capabilities/definitions/accounting-context.js +17 -0
  40. package/dist/capabilities/definitions/accounting-context.js.map +1 -0
  41. package/dist/capabilities/definitions/assets.d.ts +2 -0
  42. package/dist/capabilities/definitions/assets.js +367 -0
  43. package/dist/capabilities/definitions/assets.js.map +1 -0
  44. package/dist/capabilities/definitions/business-documents.d.ts +9 -0
  45. package/dist/capabilities/definitions/business-documents.js +386 -0
  46. package/dist/capabilities/definitions/business-documents.js.map +1 -0
  47. package/dist/capabilities/definitions/dashboard.d.ts +2 -0
  48. package/dist/capabilities/definitions/dashboard.js +153 -0
  49. package/dist/capabilities/definitions/dashboard.js.map +1 -0
  50. package/dist/capabilities/definitions/extended-operation-contracts.d.ts +597 -0
  51. package/dist/capabilities/definitions/extended-operation-contracts.js +1180 -0
  52. package/dist/capabilities/definitions/extended-operation-contracts.js.map +1 -0
  53. package/dist/capabilities/definitions/extended-operations.d.ts +2 -0
  54. package/dist/capabilities/definitions/extended-operations.js +699 -0
  55. package/dist/capabilities/definitions/extended-operations.js.map +1 -0
  56. package/dist/capabilities/definitions/financial-reports.d.ts +2 -0
  57. package/dist/capabilities/definitions/financial-reports.js +100 -0
  58. package/dist/capabilities/definitions/financial-reports.js.map +1 -0
  59. package/dist/capabilities/definitions/fnd-import.d.ts +34 -0
  60. package/dist/capabilities/definitions/fnd-import.js +282 -0
  61. package/dist/capabilities/definitions/fnd-import.js.map +1 -0
  62. package/dist/capabilities/definitions/fund-accounts.d.ts +2 -0
  63. package/dist/capabilities/definitions/fund-accounts.js +188 -0
  64. package/dist/capabilities/definitions/fund-accounts.js.map +1 -0
  65. package/dist/capabilities/definitions/fund-balances.d.ts +2 -0
  66. package/dist/capabilities/definitions/fund-balances.js +84 -0
  67. package/dist/capabilities/definitions/fund-balances.js.map +1 -0
  68. package/dist/capabilities/definitions/journals.d.ts +10 -0
  69. package/dist/capabilities/definitions/journals.js +224 -0
  70. package/dist/capabilities/definitions/journals.js.map +1 -0
  71. package/dist/capabilities/definitions/master-data.d.ts +2 -0
  72. package/dist/capabilities/definitions/master-data.js +451 -0
  73. package/dist/capabilities/definitions/master-data.js.map +1 -0
  74. package/dist/capabilities/definitions/pnl.d.ts +2 -0
  75. package/dist/capabilities/definitions/pnl.js +139 -0
  76. package/dist/capabilities/definitions/pnl.js.map +1 -0
  77. package/dist/capabilities/definitions/reference-data.d.ts +2 -0
  78. package/dist/capabilities/definitions/reference-data.js +169 -0
  79. package/dist/capabilities/definitions/reference-data.js.map +1 -0
  80. package/dist/capabilities/definitions/transaction-drafts.d.ts +2 -0
  81. package/dist/capabilities/definitions/transaction-drafts.js +157 -0
  82. package/dist/capabilities/definitions/transaction-drafts.js.map +1 -0
  83. package/dist/capabilities/definitions/transactions.d.ts +168 -0
  84. package/dist/capabilities/definitions/transactions.js +79 -0
  85. package/dist/capabilities/definitions/transactions.js.map +1 -0
  86. package/dist/capabilities/executor.d.ts +19 -0
  87. package/dist/capabilities/executor.js +134 -0
  88. package/dist/capabilities/executor.js.map +1 -0
  89. package/dist/capabilities/registry.d.ts +7 -0
  90. package/dist/capabilities/registry.js +51 -0
  91. package/dist/capabilities/registry.js.map +1 -0
  92. package/dist/clients/base-client.d.ts +5 -0
  93. package/dist/clients/base-client.js +13 -0
  94. package/dist/clients/base-client.js.map +1 -0
  95. package/dist/clients/http-client.d.ts +29 -0
  96. package/dist/clients/http-client.js +167 -0
  97. package/dist/clients/http-client.js.map +1 -0
  98. package/dist/clients/suite-client.d.ts +5 -0
  99. package/dist/clients/suite-client.js +5 -0
  100. package/dist/clients/suite-client.js.map +1 -0
  101. package/dist/concurrency/lock-manager.d.ts +4 -0
  102. package/dist/concurrency/lock-manager.js +23 -0
  103. package/dist/concurrency/lock-manager.js.map +1 -0
  104. package/dist/config/load-config.d.ts +2 -0
  105. package/dist/config/load-config.js +18 -0
  106. package/dist/config/load-config.js.map +1 -0
  107. package/dist/config/schema.d.ts +24 -0
  108. package/dist/config/schema.js +85 -0
  109. package/dist/config/schema.js.map +1 -0
  110. package/dist/errors/fintax-error.d.ts +24 -0
  111. package/dist/errors/fintax-error.js +21 -0
  112. package/dist/errors/fintax-error.js.map +1 -0
  113. package/dist/errors/normalize-error.d.ts +3 -0
  114. package/dist/errors/normalize-error.js +67 -0
  115. package/dist/errors/normalize-error.js.map +1 -0
  116. package/dist/files/artifact-store.d.ts +17 -0
  117. package/dist/files/artifact-store.js +74 -0
  118. package/dist/files/artifact-store.js.map +1 -0
  119. package/dist/files/input-policy.d.ts +28 -0
  120. package/dist/files/input-policy.js +109 -0
  121. package/dist/files/input-policy.js.map +1 -0
  122. package/dist/files/roots-provider.d.ts +14 -0
  123. package/dist/files/roots-provider.js +47 -0
  124. package/dist/files/roots-provider.js.map +1 -0
  125. package/dist/index.d.ts +2 -0
  126. package/dist/index.js +49 -0
  127. package/dist/index.js.map +1 -0
  128. package/dist/logging/logger.d.ts +3 -0
  129. package/dist/logging/logger.js +13 -0
  130. package/dist/logging/logger.js.map +1 -0
  131. package/dist/policies/idempotency.d.ts +32 -0
  132. package/dist/policies/idempotency.js +155 -0
  133. package/dist/policies/idempotency.js.map +1 -0
  134. package/dist/policies/job-reference.d.ts +16 -0
  135. package/dist/policies/job-reference.js +62 -0
  136. package/dist/policies/job-reference.js.map +1 -0
  137. package/dist/policies/operation-plan.d.ts +27 -0
  138. package/dist/policies/operation-plan.js +99 -0
  139. package/dist/policies/operation-plan.js.map +1 -0
  140. package/dist/policies/redaction.d.ts +2 -0
  141. package/dist/policies/redaction.js +29 -0
  142. package/dist/policies/redaction.js.map +1 -0
  143. package/dist/policies/retry.d.ts +8 -0
  144. package/dist/policies/retry.js +19 -0
  145. package/dist/policies/retry.js.map +1 -0
  146. package/dist/responses/tool-response.d.ts +4 -0
  147. package/dist/responses/tool-response.js +24 -0
  148. package/dist/responses/tool-response.js.map +1 -0
  149. package/dist/schemas/common.d.ts +226 -0
  150. package/dist/schemas/common.js +133 -0
  151. package/dist/schemas/common.js.map +1 -0
  152. package/dist/schemas/domains/accounting-balances.d.ts +497 -0
  153. package/dist/schemas/domains/accounting-balances.js +226 -0
  154. package/dist/schemas/domains/accounting-balances.js.map +1 -0
  155. package/dist/schemas/domains/accounting-context.d.ts +118 -0
  156. package/dist/schemas/domains/accounting-context.js +54 -0
  157. package/dist/schemas/domains/accounting-context.js.map +1 -0
  158. package/dist/schemas/domains/assets.d.ts +2508 -0
  159. package/dist/schemas/domains/assets.js +960 -0
  160. package/dist/schemas/domains/assets.js.map +1 -0
  161. package/dist/schemas/domains/business-documents.d.ts +4406 -0
  162. package/dist/schemas/domains/business-documents.js +1153 -0
  163. package/dist/schemas/domains/business-documents.js.map +1 -0
  164. package/dist/schemas/domains/configuration.d.ts +518 -0
  165. package/dist/schemas/domains/configuration.js +504 -0
  166. package/dist/schemas/domains/configuration.js.map +1 -0
  167. package/dist/schemas/domains/dashboard.d.ts +339 -0
  168. package/dist/schemas/domains/dashboard.js +211 -0
  169. package/dist/schemas/domains/dashboard.js.map +1 -0
  170. package/dist/schemas/domains/extended-operation-results.d.ts +1588 -0
  171. package/dist/schemas/domains/extended-operation-results.js +275 -0
  172. package/dist/schemas/domains/extended-operation-results.js.map +1 -0
  173. package/dist/schemas/domains/extended-operations.d.ts +1061 -0
  174. package/dist/schemas/domains/extended-operations.js +567 -0
  175. package/dist/schemas/domains/extended-operations.js.map +1 -0
  176. package/dist/schemas/domains/extended-query-results.d.ts +1688 -0
  177. package/dist/schemas/domains/extended-query-results.js +337 -0
  178. package/dist/schemas/domains/extended-query-results.js.map +1 -0
  179. package/dist/schemas/domains/financial-reports.d.ts +540 -0
  180. package/dist/schemas/domains/financial-reports.js +206 -0
  181. package/dist/schemas/domains/financial-reports.js.map +1 -0
  182. package/dist/schemas/domains/fnd-import.d.ts +912 -0
  183. package/dist/schemas/domains/fnd-import.js +396 -0
  184. package/dist/schemas/domains/fnd-import.js.map +1 -0
  185. package/dist/schemas/domains/fund-accounts.d.ts +1092 -0
  186. package/dist/schemas/domains/fund-accounts.js +410 -0
  187. package/dist/schemas/domains/fund-accounts.js.map +1 -0
  188. package/dist/schemas/domains/fund-balances.d.ts +476 -0
  189. package/dist/schemas/domains/fund-balances.js +233 -0
  190. package/dist/schemas/domains/fund-balances.js.map +1 -0
  191. package/dist/schemas/domains/journals.d.ts +1619 -0
  192. package/dist/schemas/domains/journals.js +615 -0
  193. package/dist/schemas/domains/journals.js.map +1 -0
  194. package/dist/schemas/domains/master-data.d.ts +2010 -0
  195. package/dist/schemas/domains/master-data.js +799 -0
  196. package/dist/schemas/domains/master-data.js.map +1 -0
  197. package/dist/schemas/domains/pnl.d.ts +837 -0
  198. package/dist/schemas/domains/pnl.js +469 -0
  199. package/dist/schemas/domains/pnl.js.map +1 -0
  200. package/dist/schemas/domains/reference-data.d.ts +227 -0
  201. package/dist/schemas/domains/reference-data.js +144 -0
  202. package/dist/schemas/domains/reference-data.js.map +1 -0
  203. package/dist/schemas/domains/transaction-drafts.d.ts +903 -0
  204. package/dist/schemas/domains/transaction-drafts.js +242 -0
  205. package/dist/schemas/domains/transaction-drafts.js.map +1 -0
  206. package/dist/schemas/domains/transactions.d.ts +910 -0
  207. package/dist/schemas/domains/transactions.js +266 -0
  208. package/dist/schemas/domains/transactions.js.map +1 -0
  209. package/dist/schemas/primitives.d.ts +6 -0
  210. package/dist/schemas/primitives.js +11 -0
  211. package/dist/schemas/primitives.js.map +1 -0
  212. package/dist/schemas/public-input.d.ts +3 -0
  213. package/dist/schemas/public-input.js +524 -0
  214. package/dist/schemas/public-input.js.map +1 -0
  215. package/dist/tools/core-edit/idempotent-write.d.ts +23 -0
  216. package/dist/tools/core-edit/idempotent-write.js +58 -0
  217. package/dist/tools/core-edit/idempotent-write.js.map +1 -0
  218. package/dist/tools/core-edit/save-asset.d.ts +5 -0
  219. package/dist/tools/core-edit/save-asset.js +334 -0
  220. package/dist/tools/core-edit/save-asset.js.map +1 -0
  221. package/dist/tools/core-edit/save-business-document-draft.d.ts +2 -0
  222. package/dist/tools/core-edit/save-business-document-draft.js +128 -0
  223. package/dist/tools/core-edit/save-business-document-draft.js.map +1 -0
  224. package/dist/tools/core-edit/save-fund-account.d.ts +2 -0
  225. package/dist/tools/core-edit/save-fund-account.js +138 -0
  226. package/dist/tools/core-edit/save-fund-account.js.map +1 -0
  227. package/dist/tools/core-edit/save-journal-draft.d.ts +2 -0
  228. package/dist/tools/core-edit/save-journal-draft.js +122 -0
  229. package/dist/tools/core-edit/save-journal-draft.js.map +1 -0
  230. package/dist/tools/core-edit/save-master-data.d.ts +2 -0
  231. package/dist/tools/core-edit/save-master-data.js +153 -0
  232. package/dist/tools/core-edit/save-master-data.js.map +1 -0
  233. package/dist/tools/core-edit/save-transaction-draft.d.ts +2 -0
  234. package/dist/tools/core-edit/save-transaction-draft.js +128 -0
  235. package/dist/tools/core-edit/save-transaction-draft.js.map +1 -0
  236. package/dist/tools/core-read/export-business-documents.d.ts +2 -0
  237. package/dist/tools/core-read/export-business-documents.js +67 -0
  238. package/dist/tools/core-read/export-business-documents.js.map +1 -0
  239. package/dist/tools/core-read/export-journals.d.ts +2 -0
  240. package/dist/tools/core-read/export-journals.js +56 -0
  241. package/dist/tools/core-read/export-journals.js.map +1 -0
  242. package/dist/tools/core-read/export-transactions.d.ts +2 -0
  243. package/dist/tools/core-read/export-transactions.js +67 -0
  244. package/dist/tools/core-read/export-transactions.js.map +1 -0
  245. package/dist/tools/core-read/query-accounting-balances.d.ts +2 -0
  246. package/dist/tools/core-read/query-accounting-balances.js +135 -0
  247. package/dist/tools/core-read/query-accounting-balances.js.map +1 -0
  248. package/dist/tools/core-read/query-accounting-context.d.ts +2 -0
  249. package/dist/tools/core-read/query-accounting-context.js +76 -0
  250. package/dist/tools/core-read/query-accounting-context.js.map +1 -0
  251. package/dist/tools/core-read/query-assets.d.ts +2 -0
  252. package/dist/tools/core-read/query-assets.js +425 -0
  253. package/dist/tools/core-read/query-assets.js.map +1 -0
  254. package/dist/tools/core-read/query-business-documents.d.ts +9 -0
  255. package/dist/tools/core-read/query-business-documents.js +620 -0
  256. package/dist/tools/core-read/query-business-documents.js.map +1 -0
  257. package/dist/tools/core-read/query-dashboard.d.ts +2 -0
  258. package/dist/tools/core-read/query-dashboard.js +144 -0
  259. package/dist/tools/core-read/query-dashboard.js.map +1 -0
  260. package/dist/tools/core-read/query-financial-reports.d.ts +2 -0
  261. package/dist/tools/core-read/query-financial-reports.js +171 -0
  262. package/dist/tools/core-read/query-financial-reports.js.map +1 -0
  263. package/dist/tools/core-read/query-fund-accounts.d.ts +2 -0
  264. package/dist/tools/core-read/query-fund-accounts.js +140 -0
  265. package/dist/tools/core-read/query-fund-accounts.js.map +1 -0
  266. package/dist/tools/core-read/query-fund-balances.d.ts +2 -0
  267. package/dist/tools/core-read/query-fund-balances.js +150 -0
  268. package/dist/tools/core-read/query-fund-balances.js.map +1 -0
  269. package/dist/tools/core-read/query-journals.d.ts +2 -0
  270. package/dist/tools/core-read/query-journals.js +277 -0
  271. package/dist/tools/core-read/query-journals.js.map +1 -0
  272. package/dist/tools/core-read/query-master-data.d.ts +2 -0
  273. package/dist/tools/core-read/query-master-data.js +363 -0
  274. package/dist/tools/core-read/query-master-data.js.map +1 -0
  275. package/dist/tools/core-read/query-pnl.d.ts +2 -0
  276. package/dist/tools/core-read/query-pnl.js +244 -0
  277. package/dist/tools/core-read/query-pnl.js.map +1 -0
  278. package/dist/tools/core-read/query-reference-data.d.ts +2 -0
  279. package/dist/tools/core-read/query-reference-data.js +293 -0
  280. package/dist/tools/core-read/query-reference-data.js.map +1 -0
  281. package/dist/tools/core-read/query-transactions.d.ts +2 -0
  282. package/dist/tools/core-read/query-transactions.js +58 -0
  283. package/dist/tools/core-read/query-transactions.js.map +1 -0
  284. package/dist/tools/create-tools.d.ts +3 -0
  285. package/dist/tools/create-tools.js +88 -0
  286. package/dist/tools/create-tools.js.map +1 -0
  287. package/dist/tools/extended/asset-operation-tools.d.ts +9 -0
  288. package/dist/tools/extended/asset-operation-tools.js +419 -0
  289. package/dist/tools/extended/asset-operation-tools.js.map +1 -0
  290. package/dist/tools/extended/automation-tools.d.ts +7 -0
  291. package/dist/tools/extended/automation-tools.js +333 -0
  292. package/dist/tools/extended/automation-tools.js.map +1 -0
  293. package/dist/tools/extended/configuration-tools.d.ts +14 -0
  294. package/dist/tools/extended/configuration-tools.js +871 -0
  295. package/dist/tools/extended/configuration-tools.js.map +1 -0
  296. package/dist/tools/extended/period-end-tools.d.ts +11 -0
  297. package/dist/tools/extended/period-end-tools.js +480 -0
  298. package/dist/tools/extended/period-end-tools.js.map +1 -0
  299. package/dist/tools/extended/query-output.d.ts +2589 -0
  300. package/dist/tools/extended/query-output.js +610 -0
  301. package/dist/tools/extended/query-output.js.map +1 -0
  302. package/dist/tools/extended/tool-support.d.ts +56 -0
  303. package/dist/tools/extended/tool-support.js +198 -0
  304. package/dist/tools/extended/tool-support.js.map +1 -0
  305. package/dist/tools/extended/workflow-tools.d.ts +10 -0
  306. package/dist/tools/extended/workflow-tools.js +678 -0
  307. package/dist/tools/extended/workflow-tools.js.map +1 -0
  308. package/dist/tools/fnd-import/execute-import.d.ts +2 -0
  309. package/dist/tools/fnd-import/execute-import.js +201 -0
  310. package/dist/tools/fnd-import/execute-import.js.map +1 -0
  311. package/dist/tools/fnd-import/get-import-template.d.ts +2 -0
  312. package/dist/tools/fnd-import/get-import-template.js +66 -0
  313. package/dist/tools/fnd-import/get-import-template.js.map +1 -0
  314. package/dist/tools/fnd-import/get-job-status.d.ts +8 -0
  315. package/dist/tools/fnd-import/get-job-status.js +201 -0
  316. package/dist/tools/fnd-import/get-job-status.js.map +1 -0
  317. package/dist/tools/fnd-import/prepare-import.d.ts +31 -0
  318. package/dist/tools/fnd-import/prepare-import.js +214 -0
  319. package/dist/tools/fnd-import/prepare-import.js.map +1 -0
  320. package/dist/tools/fnd-import/public-import-result.d.ts +18 -0
  321. package/dist/tools/fnd-import/public-import-result.js +35 -0
  322. package/dist/tools/fnd-import/public-import-result.js.map +1 -0
  323. package/dist/tools/tool-definition.d.ts +45 -0
  324. package/dist/tools/tool-definition.js +11 -0
  325. package/dist/tools/tool-definition.js.map +1 -0
  326. package/dist/tools/tool-handler.d.ts +27 -0
  327. package/dist/tools/tool-handler.js +196 -0
  328. package/dist/tools/tool-handler.js.map +1 -0
  329. package/dist/tools/transaction-item.d.ts +225 -0
  330. package/dist/tools/transaction-item.js +109 -0
  331. package/dist/tools/transaction-item.js.map +1 -0
  332. package/dist/transport/draining-transport.d.ts +14 -0
  333. package/dist/transport/draining-transport.js +36 -0
  334. package/dist/transport/draining-transport.js.map +1 -0
  335. package/dist/transport/stdio.d.ts +2 -0
  336. package/dist/transport/stdio.js +5 -0
  337. package/dist/transport/stdio.js.map +1 -0
  338. package/dist/version.d.ts +2 -0
  339. package/dist/version.js +3 -0
  340. package/dist/version.js.map +1 -0
  341. package/package.json +49 -0
@@ -0,0 +1,214 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { baseFileDownloadResponseSchema, baseFileMetadataResponseSchema, baseFileUploadResponseSchema, } from '../../capabilities/definitions/fnd-import.js';
3
+ import { FinTaxError } from '../../errors/fintax-error.js';
4
+ import { hashOperationValue } from '../../policies/operation-plan.js';
5
+ import { fndImportBatchUpstreamSchema, prepareImportInputSchema, prepareImportOutputSchema, } from '../../schemas/domains/fnd-import.js';
6
+ import { publicImportValidationError } from './public-import-result.js';
7
+ async function uploadLocalFile(transactionType, context) {
8
+ const inspected = context.inspectedFile;
9
+ if (inspected === undefined) {
10
+ throw new FinTaxError('VALIDATION_FAILED', 'The local file reference failed the security check');
11
+ }
12
+ const bytes = new Uint8Array(await readFile(inspected.path));
13
+ const current = context.inspectImportBytes(bytes, inspected.fileName);
14
+ if (current.sha256 !== inspected.sha256) {
15
+ throw new FinTaxError('VALIDATION_FAILED', 'The import file changed after the security check; run validation again');
16
+ }
17
+ const uploaded = baseFileUploadResponseSchema.parse(await context.callCapability('base.sys.file.upload', {
18
+ bytes,
19
+ file_name: current.fileName,
20
+ mime_type: current.mimeType,
21
+ source_biz_label: `MCP ${transactionType} account import`,
22
+ }));
23
+ if (uploaded.size_bytes !== current.size ||
24
+ uploaded.checksum_sha256 !== current.sha256) {
25
+ throw new FinTaxError('UPSTREAM_UNAVAILABLE', 'The upload result does not match the local file digest');
26
+ }
27
+ return {
28
+ fileId: uploaded.id,
29
+ inspection: current,
30
+ sourceOperations: ['sys.file.upload'],
31
+ };
32
+ }
33
+ async function resolveUploadedFile(fileId, context) {
34
+ const metadata = baseFileMetadataResponseSchema.parse(await context.callCapability('base.sys.file.metadata', {
35
+ file_id: fileId,
36
+ }));
37
+ if (metadata.source_module !== 'FND' ||
38
+ metadata.source_biz_type !== 'ACCOUNT_TRANSACTION_IMPORT') {
39
+ throw new FinTaxError('VALIDATION_FAILED', 'upload_id is not an FND account-transaction import file');
40
+ }
41
+ const downloaded = baseFileDownloadResponseSchema.parse(await context.callCapability('base.sys.file.download', {
42
+ file_id: fileId,
43
+ }));
44
+ const inspected = context.inspectImportBytes(downloaded.bytes, metadata.file_name);
45
+ if (metadata.size_bytes !== inspected.size) {
46
+ throw new FinTaxError('UPSTREAM_UNAVAILABLE', 'File metadata does not match the actual file size');
47
+ }
48
+ return {
49
+ fileId,
50
+ inspection: inspected,
51
+ sourceOperations: ['sys.file.metadata', 'sys.file.download'],
52
+ };
53
+ }
54
+ export function mapFndImportBatch(batch) {
55
+ return {
56
+ id: batch.id,
57
+ version: batch.version,
58
+ target_mode: batch.target_mode,
59
+ account_id: batch.account_id ?? null,
60
+ sub_account_id: batch.sub_account_id ?? null,
61
+ account_name: batch.account_name ?? null,
62
+ sub_account_name: batch.sub_account_name ?? null,
63
+ transaction_type: batch.transaction_type,
64
+ template_version: batch.template_version,
65
+ total_rows: batch.total_rows,
66
+ valid_rows: batch.valid_rows,
67
+ error_rows: batch.error_rows,
68
+ errors: batch.errors.map(publicImportValidationError),
69
+ preview: batch.preview.map((row) => ({
70
+ row_number: row.row_number,
71
+ biz_date: row.biz_date,
72
+ activity_type: row.activity_type,
73
+ flow_type: row.flow_type ?? null,
74
+ symbol: row.symbol,
75
+ quantity: row.quantity ?? null,
76
+ })),
77
+ };
78
+ }
79
+ export const prepareImportTool = {
80
+ name: 'prepare_import',
81
+ title: 'Validate FinTax Account Import',
82
+ description: 'Safely read or resolve an FND account-transaction file, upload it, and run the native account-import validation without importing business data. The initial release supports only import_type=fund.account. A successful validation returns a short-lived operation plan and confirmation token. The token binds the validation result but does not represent user approval; show the summary and obtain explicit confirmation before execution.',
83
+ risk: 'R1',
84
+ exposurePack: 'fnd-import',
85
+ capabilityIds: [
86
+ 'base.sys.file.upload',
87
+ 'base.sys.file.metadata',
88
+ 'base.sys.file.download',
89
+ 'suite.fnd.account_import.validate',
90
+ ],
91
+ fileAccess: 'read-import',
92
+ inputSchema: prepareImportInputSchema,
93
+ outputSchema: prepareImportOutputSchema,
94
+ annotations: {
95
+ readOnlyHint: false,
96
+ destructiveHint: false,
97
+ idempotentHint: false,
98
+ openWorldHint: false,
99
+ },
100
+ async execute(rawInput, context) {
101
+ const input = prepareImportInputSchema.parse(rawInput);
102
+ const resolved = input.file_ref.kind === 'upload_id'
103
+ ? await resolveUploadedFile(input.file_ref.value, context)
104
+ : await uploadLocalFile(input.context.transaction_type, context);
105
+ const validationContext = {
106
+ target_mode: input.context.target_mode,
107
+ ...(input.context.account_id === undefined
108
+ ? {}
109
+ : { account_id: input.context.account_id }),
110
+ ...(input.context.sub_account_id === undefined
111
+ ? {}
112
+ : { sub_account_id: input.context.sub_account_id }),
113
+ ...(input.context.account_name === undefined
114
+ ? {}
115
+ : { account_name: input.context.account_name }),
116
+ ...(input.context.sub_account_name === undefined
117
+ ? {}
118
+ : { sub_account_name: input.context.sub_account_name }),
119
+ transaction_type: input.context.transaction_type,
120
+ ...(input.context.positive_direction === undefined
121
+ ? {}
122
+ : { positive_direction: input.context.positive_direction }),
123
+ };
124
+ const batch = fndImportBatchUpstreamSchema.parse(await context.callCapability('suite.fnd.account_import.validate', {
125
+ ...validationContext,
126
+ file_id: resolved.fileId,
127
+ }));
128
+ if (batch.status !== 'READY' && batch.status !== 'VALIDATION_FAILED') {
129
+ throw new FinTaxError('UPSTREAM_UNAVAILABLE', 'Import validation returned an unrecognized state');
130
+ }
131
+ const mappedBatch = mapFndImportBatch(batch);
132
+ const base = {
133
+ import_type: input.import_type,
134
+ upstream_batch_id: batch.id,
135
+ file: {
136
+ source_ref_kind: input.file_ref.kind,
137
+ file_name: resolved.inspection.fileName,
138
+ media_type: resolved.inspection.mimeType,
139
+ size_bytes: resolved.inspection.size,
140
+ sha256: resolved.inspection.sha256,
141
+ },
142
+ batch: mappedBatch,
143
+ estimated_impact: {
144
+ transaction_rows_to_create: batch.status === 'READY' ? batch.valid_rows : 0,
145
+ creates_account: batch.target_mode === 'NEW_ACCOUNT',
146
+ creates_sub_account: batch.target_mode !== 'EXISTING_SUB_ACCOUNT',
147
+ },
148
+ };
149
+ const sourceRefs = [
150
+ ...resolved.sourceOperations.map((operation) => ({
151
+ service: 'base',
152
+ operation,
153
+ })),
154
+ { service: 'suite', operation: 'fnd.account_import.validate' },
155
+ { service: 'mcp', operation: 'file.inspect' },
156
+ ];
157
+ if (batch.status === 'VALIDATION_FAILED') {
158
+ return {
159
+ ok: true,
160
+ data: {
161
+ status: batch.status,
162
+ ...base,
163
+ operation_plan_id: null,
164
+ confirmation_token: null,
165
+ expires_at: null,
166
+ },
167
+ warnings: ['Import validation failed; no execution plan was issued.'],
168
+ trace_id: context.traceId,
169
+ source_refs: sourceRefs,
170
+ };
171
+ }
172
+ const identity = await context.getIdentity();
173
+ const issued = context.operationPlans.issue({
174
+ tool: 'execute_import',
175
+ subject_id: batch.id,
176
+ subject_version: String(batch.version),
177
+ user_id: identity.userId,
178
+ tenant_id: identity.tenantId,
179
+ ...(identity.orgId === undefined ? {} : { org_id: identity.orgId }),
180
+ parameter_hash: hashOperationValue({
181
+ import_type: input.import_type,
182
+ context: input.context,
183
+ options: input.options,
184
+ }),
185
+ preview_hash: hashOperationValue(mappedBatch),
186
+ file_id: resolved.fileId,
187
+ file_hash: resolved.inspection.sha256,
188
+ });
189
+ return {
190
+ ok: true,
191
+ data: {
192
+ status: batch.status,
193
+ ...base,
194
+ operation_plan_id: issued.operationPlanId,
195
+ confirmation_token: issued.confirmationToken,
196
+ expires_at: issued.expiresAt,
197
+ },
198
+ warnings: [],
199
+ trace_id: context.traceId,
200
+ source_refs: [
201
+ ...sourceRefs,
202
+ { service: 'mcp', operation: 'operation_plan.issue' },
203
+ ],
204
+ };
205
+ },
206
+ summarize(output) {
207
+ const parsed = prepareImportOutputSchema.parse(output);
208
+ if (parsed.data.status === 'VALIDATION_FAILED') {
209
+ return `Account-import validation failed with ${parsed.data.batch.error_rows} error rows; no execution plan was issued.`;
210
+ }
211
+ return `Account-import validation passed with ${parsed.data.estimated_impact.transaction_rows_to_create} rows expected to be imported; explicit user confirmation is still required before execution.`;
212
+ },
213
+ };
214
+ //# sourceMappingURL=prepare-import.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepare-import.js","sourceRoot":"","sources":["../../../src/tools/fnd-import/prepare-import.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EACL,8BAA8B,EAC9B,8BAA8B,EAC9B,4BAA4B,GAC7B,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,qCAAqC,CAAC;AAG7C,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAQxE,KAAK,UAAU,eAAe,CAC5B,eAAuB,EACvB,OAAoB;IAEpB,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC;IACxC,IAAI,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,UAAU,EAAE,MAAM,CAAC,SAAS;aAC7B;YACD,QAAQ,EAAE,EAAE;YACZ,QAAQ,EAAE,OAAO,CAAC,OAAO;YACzB,WAAW,EAAE;gBACX,GAAG,UAAU;gBACb,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,sBAAsB,EAAE;aACtD;SACF,CAAC;IACJ,CAAC;IACD,SAAS,CAAC,MAAM;QACd,MAAM,MAAM,GAAG,yBAAyB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACvD,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,KAAK,mBAAmB,EAAE,CAAC;YAC/C,OAAO,yCAAyC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,4CAA4C,CAAC;QAC3H,CAAC;QACD,OAAO,yCAAyC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,0BAA0B,+FAA+F,CAAC;IACzM,CAAC;CACF,CAAC"}
@@ -0,0 +1,18 @@
1
+ export interface UpstreamImportValidationError {
2
+ readonly row_number?: number | null | undefined;
3
+ readonly column?: string | null | undefined;
4
+ readonly code?: string | undefined;
5
+ readonly message?: string | undefined;
6
+ }
7
+ export declare function publicImportValidationError(error: UpstreamImportValidationError): {
8
+ readonly row_number: number | null;
9
+ readonly column: string | null;
10
+ readonly code: "IMPORT_ROW_INVALID";
11
+ readonly message: string;
12
+ };
13
+ export declare function publicImportFailure(): {
14
+ readonly code: "IMPORT_FAILED";
15
+ readonly message: "The account import did not complete; inspect the validation result or contact an administrator";
16
+ readonly upstream_error_code: null;
17
+ };
18
+ export declare function publicImportStatus(status: string): string;
@@ -0,0 +1,35 @@
1
+ const SAFE_COLUMN_NAME = /^[\p{L}\p{N}_ -]{1,64}$/u;
2
+ const PUBLIC_IMPORT_STATUSES = new Set([
3
+ 'UPLOADED',
4
+ 'VALIDATION_FAILED',
5
+ 'READY',
6
+ 'IMPORTING',
7
+ 'SUCCEEDED',
8
+ 'FAILED',
9
+ ]);
10
+ export function publicImportValidationError(error) {
11
+ const column = error.column !== undefined &&
12
+ error.column !== null &&
13
+ SAFE_COLUMN_NAME.test(error.column)
14
+ ? error.column
15
+ : null;
16
+ return {
17
+ row_number: error.row_number ?? null,
18
+ column,
19
+ code: 'IMPORT_ROW_INVALID',
20
+ message: column === null
21
+ ? 'The row failed import validation'
22
+ : `Field ${column} failed import validation`,
23
+ };
24
+ }
25
+ export function publicImportFailure() {
26
+ return {
27
+ code: 'IMPORT_FAILED',
28
+ message: 'The account import did not complete; inspect the validation result or contact an administrator',
29
+ upstream_error_code: null,
30
+ };
31
+ }
32
+ export function publicImportStatus(status) {
33
+ return PUBLIC_IMPORT_STATUSES.has(status) ? status : 'UNKNOWN';
34
+ }
35
+ //# sourceMappingURL=public-import-result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public-import-result.js","sourceRoot":"","sources":["../../../src/tools/fnd-import/public-import-result.ts"],"names":[],"mappings":"AAAA,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AACpD,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC;IACrC,UAAU;IACV,mBAAmB;IACnB,OAAO;IACP,WAAW;IACX,WAAW;IACX,QAAQ;CACT,CAAC,CAAC;AASH,MAAM,UAAU,2BAA2B,CACzC,KAAoC;IAEpC,MAAM,MAAM,GACV,KAAK,CAAC,MAAM,KAAK,SAAS;QAC1B,KAAK,CAAC,MAAM,KAAK,IAAI;QACrB,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;QACjC,CAAC,CAAC,KAAK,CAAC,MAAM;QACd,CAAC,CAAC,IAAI,CAAC;IACX,OAAO;QACL,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,IAAI;QACpC,MAAM;QACN,IAAI,EAAE,oBAAoB;QAC1B,OAAO,EACL,MAAM,KAAK,IAAI;YACb,CAAC,CAAC,kCAAkC;YACpC,CAAC,CAAC,SAAS,MAAM,2BAA2B;KACxC,CAAC;AACb,CAAC;AAED,MAAM,UAAU,mBAAmB;IACjC,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,OAAO,EACL,gGAAgG;QAClG,mBAAmB,EAAE,IAAI;KACjB,CAAC;AACb,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,MAAc;IAC/C,OAAO,sBAAsB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AACjE,CAAC"}
@@ -0,0 +1,45 @@
1
+ import type { z } from 'zod/v4';
2
+ import type { AuthIdentity } from '../auth/auth-session.js';
3
+ import type { AuditContext } from '../audit/audit-context.js';
4
+ import type { ArtifactStore } from '../files/artifact-store.js';
5
+ import type { InspectedFile } from '../files/input-policy.js';
6
+ import type { InspectedFileContent } from '../files/input-policy.js';
7
+ import type { OperationPlanManager } from '../policies/operation-plan.js';
8
+ import type { IdempotencyManager } from '../policies/idempotency.js';
9
+ export type RiskLevel = 'R0' | 'R1' | 'R2' | 'R3' | 'R4';
10
+ export declare const EXPOSURE_PACKS: readonly ["core-read", "fnd-import", "core-edit", "workflow", "period-end", "asset-ops", "automation", "configuration"];
11
+ export type ExposurePack = (typeof EXPOSURE_PACKS)[number];
12
+ export type FileAccess = 'none' | 'read-import' | 'write-artifact';
13
+ export interface ToolContext {
14
+ readonly traceId: string;
15
+ readonly orgId?: string;
16
+ readonly inspectedFile?: InspectedFile;
17
+ readonly artifacts: ArtifactStore;
18
+ readonly audit: AuditContext;
19
+ readonly idempotency: IdempotencyManager;
20
+ readonly operationPlans: OperationPlanManager;
21
+ inspectImportBytes(bytes: Uint8Array, fileName: string): InspectedFileContent;
22
+ withResourceLock<T>(key: string, operation: () => Promise<T>): Promise<T>;
23
+ callCapability(capabilityId: string, input: unknown, orgIdOverride?: string): Promise<unknown>;
24
+ getIdentity(orgIdOverride?: string): Promise<AuthIdentity>;
25
+ }
26
+ export interface ToolDefinition {
27
+ readonly name: string;
28
+ readonly title: string;
29
+ readonly description: string;
30
+ readonly risk: RiskLevel;
31
+ readonly exposurePack: ExposurePack;
32
+ readonly capabilityIds: readonly string[];
33
+ readonly fileAccess: FileAccess;
34
+ readonly publicInputSchema?: z.ZodObject;
35
+ readonly inputSchema: z.ZodType;
36
+ readonly outputSchema: z.ZodType;
37
+ readonly annotations: {
38
+ readonly readOnlyHint: boolean;
39
+ readonly destructiveHint: boolean;
40
+ readonly idempotentHint: boolean;
41
+ readonly openWorldHint: boolean;
42
+ };
43
+ execute(input: unknown, context: ToolContext): Promise<unknown>;
44
+ summarize(output: unknown): string;
45
+ }
@@ -0,0 +1,11 @@
1
+ export const EXPOSURE_PACKS = [
2
+ 'core-read',
3
+ 'fnd-import',
4
+ 'core-edit',
5
+ 'workflow',
6
+ 'period-end',
7
+ 'asset-ops',
8
+ 'automation',
9
+ 'configuration',
10
+ ];
11
+ //# sourceMappingURL=tool-definition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-definition.js","sourceRoot":"","sources":["../../src/tools/tool-definition.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,WAAW;IACX,YAAY;IACZ,WAAW;IACX,UAAU;IACV,YAAY;IACZ,WAAW;IACX,YAAY;IACZ,eAAe;CACP,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
2
+ import type { Logger } from 'pino';
3
+ import type { AuditSink } from '../audit/audit-sink.js';
4
+ import type { CapabilityExecutor } from '../capabilities/executor.js';
5
+ import type { ArtifactStore } from '../files/artifact-store.js';
6
+ import type { InputFilePolicy } from '../files/input-policy.js';
7
+ import type { OperationPlanManager } from '../policies/operation-plan.js';
8
+ import type { IdempotencyManager } from '../policies/idempotency.js';
9
+ import type { LockManager } from '../concurrency/lock-manager.js';
10
+ import type { ToolDefinition } from './tool-definition.js';
11
+ export declare class FinTaxToolHandler {
12
+ #private;
13
+ constructor(options: {
14
+ capabilities: CapabilityExecutor;
15
+ files: InputFilePolicy;
16
+ artifacts: ArtifactStore;
17
+ plans: OperationPlanManager;
18
+ idempotency: IdempotencyManager;
19
+ locks: LockManager;
20
+ audit: AuditSink;
21
+ logger: Logger;
22
+ });
23
+ invoke(definition: ToolDefinition, rawInput: unknown): Promise<CallToolResult>;
24
+ stopAccepting(): void;
25
+ drain(): Promise<void>;
26
+ close(): Promise<void>;
27
+ }
@@ -0,0 +1,196 @@
1
+ import { z } from 'zod/v4';
2
+ import { AuditContext } from '../audit/audit-context.js';
3
+ import { FinTaxError } from '../errors/fintax-error.js';
4
+ import { normalizeError } from '../errors/normalize-error.js';
5
+ import { createToolFailure, createToolSuccess, } from '../responses/tool-response.js';
6
+ import { SERVER_VERSION } from '../version.js';
7
+ function getOrgId(input) {
8
+ if (input !== null &&
9
+ typeof input === 'object' &&
10
+ 'context' in input &&
11
+ input.context !== null &&
12
+ typeof input.context === 'object' &&
13
+ 'org_id' in input.context &&
14
+ typeof input.context.org_id === 'string') {
15
+ return input.context.org_id;
16
+ }
17
+ return undefined;
18
+ }
19
+ function getFileReference(input) {
20
+ if (input !== null &&
21
+ typeof input === 'object' &&
22
+ 'file_ref' in input &&
23
+ input.file_ref !== null &&
24
+ typeof input.file_ref === 'object' &&
25
+ 'kind' in input.file_ref &&
26
+ 'value' in input.file_ref &&
27
+ (input.file_ref.kind === 'local_path' ||
28
+ input.file_ref.kind === 'artifact' ||
29
+ input.file_ref.kind === 'upload_id') &&
30
+ typeof input.file_ref.value === 'string') {
31
+ return { kind: input.file_ref.kind, value: input.file_ref.value };
32
+ }
33
+ return undefined;
34
+ }
35
+ function parseToolInput(definition, rawInput) {
36
+ try {
37
+ return definition.inputSchema.parse(rawInput);
38
+ }
39
+ catch (error) {
40
+ if (!(error instanceof z.ZodError))
41
+ throw error;
42
+ throw new FinTaxError('VALIDATION_FAILED', 'Tool input does not satisfy the public contract', {
43
+ fieldErrors: error.issues.map((issue) => ({
44
+ field: issue.path.join('.').slice(0, 160) || '$',
45
+ message: issue.message.slice(0, 240),
46
+ })),
47
+ cause: error,
48
+ });
49
+ }
50
+ }
51
+ export class FinTaxToolHandler {
52
+ #capabilities;
53
+ #files;
54
+ #artifacts;
55
+ #plans;
56
+ #idempotency;
57
+ #locks;
58
+ #audit;
59
+ #logger;
60
+ #inFlight = new Set();
61
+ #closing = false;
62
+ constructor(options) {
63
+ this.#capabilities = options.capabilities;
64
+ this.#files = options.files;
65
+ this.#artifacts = options.artifacts;
66
+ this.#plans = options.plans;
67
+ this.#idempotency = options.idempotency;
68
+ this.#locks = options.locks;
69
+ this.#audit = options.audit;
70
+ this.#logger = options.logger;
71
+ }
72
+ invoke(definition, rawInput) {
73
+ if (this.#closing) {
74
+ return Promise.resolve(createToolFailure(new FinTaxError('UPSTREAM_UNAVAILABLE', 'FinTax MCP is shutting down; call again later', { retryable: true }), crypto.randomUUID()));
75
+ }
76
+ const invocation = this.#invoke(definition, rawInput);
77
+ this.#inFlight.add(invocation);
78
+ void invocation.then(() => this.#inFlight.delete(invocation), () => this.#inFlight.delete(invocation));
79
+ return invocation;
80
+ }
81
+ stopAccepting() {
82
+ this.#closing = true;
83
+ }
84
+ async drain() {
85
+ await Promise.allSettled([...this.#inFlight]);
86
+ }
87
+ async close() {
88
+ await this.#capabilities.close();
89
+ }
90
+ async #invoke(definition, rawInput) {
91
+ const traceId = crypto.randomUUID();
92
+ const started = Date.now();
93
+ const startedAt = new Date(started).toISOString();
94
+ const audit = new AuditContext();
95
+ try {
96
+ const input = parseToolInput(definition, rawInput);
97
+ audit.captureInput(input);
98
+ const orgId = getOrgId(input);
99
+ const fileReference = getFileReference(input);
100
+ const inspectedFile = definition.fileAccess === 'read-import' &&
101
+ fileReference !== undefined &&
102
+ fileReference.kind !== 'upload_id'
103
+ ? await this.#files.inspect(fileReference)
104
+ : undefined;
105
+ if (inspectedFile !== undefined) {
106
+ audit.captureFileChecksum(inspectedFile.sha256);
107
+ }
108
+ const allowed = new Set(definition.capabilityIds);
109
+ const context = {
110
+ traceId,
111
+ ...(orgId === undefined ? {} : { orgId }),
112
+ ...(inspectedFile === undefined ? {} : { inspectedFile }),
113
+ artifacts: this.#artifacts,
114
+ audit,
115
+ idempotency: this.#idempotency,
116
+ operationPlans: this.#plans,
117
+ inspectImportBytes: (bytes, fileName) => {
118
+ const inspected = this.#files.inspectBytes(bytes, fileName);
119
+ audit.captureFileChecksum(inspected.sha256);
120
+ return inspected;
121
+ },
122
+ withResourceLock: (key, operation) => this.#locks.withLock(`resource:${key}`, operation),
123
+ callCapability: (capabilityId, capabilityInput, orgIdOverride) => {
124
+ if (!allowed.has(capabilityId)) {
125
+ throw new Error(`Tool ${definition.name} did not declare capability ${capabilityId}`);
126
+ }
127
+ return this.#capabilities.call(capabilityId, capabilityInput, orgIdOverride ?? orgId, audit);
128
+ },
129
+ getIdentity: (orgIdOverride) => this.#capabilities.getIdentity(orgIdOverride ?? orgId, audit),
130
+ };
131
+ const parsedOutput = definition.outputSchema.parse(await definition.execute(input, context));
132
+ if (parsedOutput === null ||
133
+ typeof parsedOutput !== 'object' ||
134
+ Array.isArray(parsedOutput)) {
135
+ throw new Error(`Tool ${definition.name} output must be an object`);
136
+ }
137
+ const output = parsedOutput;
138
+ await this.#writeAudit({
139
+ definition,
140
+ traceId,
141
+ started,
142
+ startedAt,
143
+ status: 'succeeded',
144
+ audit,
145
+ });
146
+ this.#logger.debug({
147
+ trace_id: traceId,
148
+ tool: definition.name,
149
+ duration_ms: Date.now() - started,
150
+ }, 'tool completed');
151
+ return createToolSuccess(output, definition.summarize(output));
152
+ }
153
+ catch (error) {
154
+ const normalized = normalizeError(error);
155
+ await this.#writeAudit({
156
+ definition,
157
+ traceId,
158
+ started,
159
+ startedAt,
160
+ status: 'failed',
161
+ audit,
162
+ errorCode: normalized.code,
163
+ });
164
+ this.#logger.debug({
165
+ trace_id: traceId,
166
+ tool: definition.name,
167
+ error_code: normalized.code,
168
+ duration_ms: Date.now() - started,
169
+ }, 'tool failed');
170
+ return createToolFailure(normalized, traceId);
171
+ }
172
+ }
173
+ async #writeAudit(options) {
174
+ try {
175
+ await this.#audit.write({
176
+ traceId: options.traceId,
177
+ tool: options.definition.name,
178
+ version: SERVER_VERSION,
179
+ risk: options.definition.risk,
180
+ capabilityIds: options.definition.capabilityIds,
181
+ startedAt: options.startedAt,
182
+ finishedAt: new Date().toISOString(),
183
+ durationMs: Date.now() - options.started,
184
+ status: options.status,
185
+ ...options.audit.snapshot(),
186
+ ...(options.errorCode === undefined
187
+ ? {}
188
+ : { errorCode: options.errorCode }),
189
+ });
190
+ }
191
+ catch (error) {
192
+ this.#logger.warn({ err: error, trace_id: options.traceId }, 'audit write failed');
193
+ }
194
+ }
195
+ }
196
+ //# sourceMappingURL=tool-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-handler.js","sourceRoot":"","sources":["../../src/tools/tool-handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAM9D,OAAO,EACL,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG/C,SAAS,QAAQ,CAAC,KAAc;IAC9B,IACE,KAAK,KAAK,IAAI;QACd,OAAO,KAAK,KAAK,QAAQ;QACzB,SAAS,IAAI,KAAK;QAClB,KAAK,CAAC,OAAO,KAAK,IAAI;QACtB,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ;QACjC,QAAQ,IAAI,KAAK,CAAC,OAAO;QACzB,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,KAAK,QAAQ,EACxC,CAAC;QACD,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;IAC9B,CAAC;IACD,OAAO,SAAS,CAAC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