@zivis/mcp 0.1.0-alpha.26 → 0.1.0-alpha.4

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 (328) hide show
  1. package/dist/api-client.d.ts +24 -1
  2. package/dist/api-client.js +52 -29
  3. package/dist/api-client.js.map +1 -0
  4. package/dist/auth/index.d.ts +22 -1
  5. package/dist/auth/index.js +38 -17
  6. package/dist/auth/index.js.map +1 -0
  7. package/dist/auth/jwt.d.ts +16 -0
  8. package/dist/auth/jwt.js +13 -0
  9. package/dist/auth/jwt.js.map +1 -0
  10. package/dist/auth/keychain.d.ts +32 -6
  11. package/dist/auth/keychain.js +114 -83
  12. package/dist/auth/keychain.js.map +1 -0
  13. package/dist/auth/oauth.d.ts +42 -1
  14. package/dist/auth/oauth.js +50 -13
  15. package/dist/auth/oauth.js.map +1 -0
  16. package/dist/auth/sessions.d.ts +25 -5
  17. package/dist/auth/sessions.js +39 -20
  18. package/dist/auth/sessions.js.map +1 -0
  19. package/dist/auth/token-refresh.d.ts +22 -2
  20. package/dist/auth/token-refresh.js +35 -32
  21. package/dist/auth/token-refresh.js.map +1 -0
  22. package/dist/cli.d.ts +18 -1
  23. package/dist/cli.js +908 -30
  24. package/dist/cli.js.map +1 -0
  25. package/dist/index.d.ts +6 -0
  26. package/dist/index.js +7 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/project-binding.d.ts +19 -2
  29. package/dist/project-binding.js +21 -38
  30. package/dist/project-binding.js.map +1 -0
  31. package/dist/resolve-application-id.d.ts +4 -0
  32. package/dist/resolve-application-id.js +5 -0
  33. package/dist/resolve-application-id.js.map +1 -0
  34. package/dist/sanitize.d.ts +21 -0
  35. package/dist/sanitize.js +41 -0
  36. package/dist/sanitize.js.map +1 -0
  37. package/dist/server.d.ts +13 -1
  38. package/dist/server.js +247 -122
  39. package/dist/server.js.map +1 -0
  40. package/dist/tools/check-project.d.ts +18 -5
  41. package/dist/tools/check-project.js +110 -122
  42. package/dist/tools/check-project.js.map +1 -0
  43. package/dist/tools/check-repo-trust.d.ts +19 -4
  44. package/dist/tools/check-repo-trust.js +47 -56
  45. package/dist/tools/check-repo-trust.js.map +1 -0
  46. package/dist/tools/create-diagram.d.ts +5 -0
  47. package/dist/tools/create-diagram.js +10 -0
  48. package/dist/tools/create-diagram.js.map +1 -0
  49. package/dist/tools/create-document.d.ts +5 -0
  50. package/dist/tools/create-document.js +6 -0
  51. package/dist/tools/create-document.js.map +1 -0
  52. package/dist/tools/discover-local-infra.d.ts +10 -0
  53. package/dist/tools/discover-local-infra.js +73 -3
  54. package/dist/tools/discover-local-infra.js.map +1 -0
  55. package/dist/tools/enterprise/capture-evidence.d.ts +54 -0
  56. package/dist/tools/enterprise/capture-evidence.js +72 -0
  57. package/dist/tools/enterprise/capture-evidence.js.map +1 -0
  58. package/dist/tools/enterprise/create-report-ticket.d.ts +34 -0
  59. package/dist/tools/enterprise/create-report-ticket.js +44 -0
  60. package/dist/tools/enterprise/create-report-ticket.js.map +1 -0
  61. package/dist/tools/enterprise/end-pentest-session.d.ts +33 -0
  62. package/dist/tools/enterprise/end-pentest-session.js +42 -0
  63. package/dist/tools/enterprise/end-pentest-session.js.map +1 -0
  64. package/dist/tools/enterprise/generate-report.d.ts +55 -0
  65. package/dist/tools/enterprise/generate-report.js +111 -0
  66. package/dist/tools/enterprise/generate-report.js.map +1 -0
  67. package/dist/tools/enterprise/get-org-zat.d.ts +5 -0
  68. package/dist/tools/enterprise/get-org-zat.js +6 -0
  69. package/dist/tools/enterprise/get-org-zat.js.map +1 -0
  70. package/dist/tools/enterprise/get-report-status.d.ts +27 -0
  71. package/dist/tools/enterprise/get-report-status.js +38 -0
  72. package/dist/tools/enterprise/get-report-status.js.map +1 -0
  73. package/dist/tools/enterprise/get-threat-model.d.ts +6 -1
  74. package/dist/tools/enterprise/get-threat-model.js +17 -52
  75. package/dist/tools/enterprise/get-threat-model.js.map +1 -0
  76. package/dist/tools/enterprise/list-agents.d.ts +42 -0
  77. package/dist/tools/enterprise/list-agents.js +95 -0
  78. package/dist/tools/enterprise/list-agents.js.map +1 -0
  79. package/dist/tools/enterprise/list-report-issues.d.ts +36 -0
  80. package/dist/tools/enterprise/list-report-issues.js +50 -0
  81. package/dist/tools/enterprise/list-report-issues.js.map +1 -0
  82. package/dist/tools/enterprise/list-threat-models.d.ts +5 -0
  83. package/dist/tools/enterprise/list-threat-models.js +8 -0
  84. package/dist/tools/enterprise/list-threat-models.js.map +1 -0
  85. package/dist/tools/enterprise/manage-actor.d.ts +6 -1
  86. package/dist/tools/enterprise/manage-actor.js +7 -14
  87. package/dist/tools/enterprise/manage-actor.js.map +1 -0
  88. package/dist/tools/enterprise/manage-attack-scenario.d.ts +6 -1
  89. package/dist/tools/enterprise/manage-attack-scenario.js +7 -13
  90. package/dist/tools/enterprise/manage-attack-scenario.js.map +1 -0
  91. package/dist/tools/enterprise/manage-component.d.ts +6 -1
  92. package/dist/tools/enterprise/manage-component.js +7 -20
  93. package/dist/tools/enterprise/manage-component.js.map +1 -0
  94. package/dist/tools/enterprise/manage-data-asset.d.ts +7 -2
  95. package/dist/tools/enterprise/manage-data-asset.js +7 -17
  96. package/dist/tools/enterprise/manage-data-asset.js.map +1 -0
  97. package/dist/tools/enterprise/manage-data-flow.d.ts +7 -2
  98. package/dist/tools/enterprise/manage-data-flow.js +7 -19
  99. package/dist/tools/enterprise/manage-data-flow.js.map +1 -0
  100. package/dist/tools/enterprise/manage-finding.d.ts +69 -0
  101. package/dist/tools/enterprise/manage-finding.js +106 -0
  102. package/dist/tools/enterprise/manage-finding.js.map +1 -0
  103. package/dist/tools/enterprise/manage-security-control.d.ts +6 -1
  104. package/dist/tools/enterprise/manage-security-control.js +7 -18
  105. package/dist/tools/enterprise/manage-security-control.js.map +1 -0
  106. package/dist/tools/enterprise/manage-test-case.d.ts +7 -2
  107. package/dist/tools/enterprise/manage-test-case.js +6 -8
  108. package/dist/tools/enterprise/manage-test-case.js.map +1 -0
  109. package/dist/tools/enterprise/promote-finding-to-issue.d.ts +36 -0
  110. package/dist/tools/enterprise/promote-finding-to-issue.js +65 -0
  111. package/dist/tools/enterprise/promote-finding-to-issue.js.map +1 -0
  112. package/dist/tools/enterprise/publish-report-version.d.ts +34 -0
  113. package/dist/tools/enterprise/publish-report-version.js +75 -0
  114. package/dist/tools/enterprise/publish-report-version.js.map +1 -0
  115. package/dist/tools/enterprise/publish-test-to-library.d.ts +31 -0
  116. package/dist/tools/enterprise/publish-test-to-library.js +40 -0
  117. package/dist/tools/enterprise/publish-test-to-library.js.map +1 -0
  118. package/dist/tools/enterprise/record-test-result.d.ts +67 -0
  119. package/dist/tools/enterprise/record-test-result.js +75 -0
  120. package/dist/tools/enterprise/record-test-result.js.map +1 -0
  121. package/dist/tools/enterprise/start-pentest-session.d.ts +35 -0
  122. package/dist/tools/enterprise/start-pentest-session.js +50 -0
  123. package/dist/tools/enterprise/start-pentest-session.js.map +1 -0
  124. package/dist/tools/enterprise/sync-report-section.d.ts +41 -0
  125. package/dist/tools/enterprise/sync-report-section.js +79 -0
  126. package/dist/tools/enterprise/sync-report-section.js.map +1 -0
  127. package/dist/tools/enterprise/update-report-issue.d.ts +55 -0
  128. package/dist/tools/enterprise/update-report-issue.js +69 -0
  129. package/dist/tools/enterprise/update-report-issue.js.map +1 -0
  130. package/dist/tools/generate-diagram.d.ts +6 -0
  131. package/dist/tools/generate-diagram.js +9 -0
  132. package/dist/tools/generate-diagram.js.map +1 -0
  133. package/dist/tools/get-agent-test-results.d.ts +41 -0
  134. package/dist/tools/get-agent-test-results.js +86 -0
  135. package/dist/tools/get-agent-test-results.js.map +1 -0
  136. package/dist/tools/get-application-overview.d.ts +5 -0
  137. package/dist/tools/get-application-overview.js +6 -0
  138. package/dist/tools/get-application-overview.js.map +1 -0
  139. package/dist/tools/get-application.d.ts +5 -0
  140. package/dist/tools/get-application.js +6 -0
  141. package/dist/tools/get-application.js.map +1 -0
  142. package/dist/tools/get-artifact-content.d.ts +29 -0
  143. package/dist/tools/get-artifact-content.js +86 -0
  144. package/dist/tools/get-artifact-content.js.map +1 -0
  145. package/dist/tools/get-diagram.d.ts +5 -0
  146. package/dist/tools/get-diagram.js +11 -1
  147. package/dist/tools/get-diagram.js.map +1 -0
  148. package/dist/tools/get-document.d.ts +5 -0
  149. package/dist/tools/get-document.js +6 -0
  150. package/dist/tools/get-document.js.map +1 -0
  151. package/dist/tools/get-finding-details.d.ts +28 -0
  152. package/dist/tools/get-finding-details.js +43 -0
  153. package/dist/tools/get-finding-details.js.map +1 -0
  154. package/dist/tools/get-findings.d.ts +57 -0
  155. package/dist/tools/get-findings.js +103 -0
  156. package/dist/tools/get-findings.js.map +1 -0
  157. package/dist/tools/get-oss-zat.d.ts +5 -0
  158. package/dist/tools/get-oss-zat.js +7 -0
  159. package/dist/tools/get-oss-zat.js.map +1 -0
  160. package/dist/tools/get-recon-scan.d.ts +27 -0
  161. package/dist/tools/get-recon-scan.js +46 -0
  162. package/dist/tools/get-recon-scan.js.map +1 -0
  163. package/dist/tools/get-scan-output.d.ts +27 -0
  164. package/dist/tools/get-scan-output.js +64 -0
  165. package/dist/tools/get-scan-output.js.map +1 -0
  166. package/dist/tools/get-scenario-details.d.ts +27 -0
  167. package/dist/tools/get-scenario-details.js +46 -0
  168. package/dist/tools/get-scenario-details.js.map +1 -0
  169. package/dist/tools/get-test-case-results.d.ts +37 -0
  170. package/dist/tools/get-test-case-results.js +66 -0
  171. package/dist/tools/get-test-case-results.js.map +1 -0
  172. package/dist/tools/get-test-details.d.ts +29 -0
  173. package/dist/tools/get-test-details.js +49 -0
  174. package/dist/tools/get-test-details.js.map +1 -0
  175. package/dist/tools/get-trust-keys.d.ts +5 -0
  176. package/dist/tools/get-trust-keys.js +6 -0
  177. package/dist/tools/get-trust-keys.js.map +1 -0
  178. package/dist/tools/import-openapi-endpoints.d.ts +5 -0
  179. package/dist/tools/import-openapi-endpoints.js +6 -0
  180. package/dist/tools/import-openapi-endpoints.js.map +1 -0
  181. package/dist/tools/inspect-zat.d.ts +5 -0
  182. package/dist/tools/inspect-zat.js +19 -0
  183. package/dist/tools/inspect-zat.js.map +1 -0
  184. package/dist/tools/list-agent-test-cases.d.ts +41 -0
  185. package/dist/tools/list-agent-test-cases.js +73 -0
  186. package/dist/tools/list-agent-test-cases.js.map +1 -0
  187. package/dist/tools/list-applications.d.ts +6 -1
  188. package/dist/tools/list-applications.js +6 -0
  189. package/dist/tools/list-applications.js.map +1 -0
  190. package/dist/tools/list-diagrams.d.ts +5 -0
  191. package/dist/tools/list-diagrams.js +6 -0
  192. package/dist/tools/list-diagrams.js.map +1 -0
  193. package/dist/tools/list-documents.d.ts +5 -0
  194. package/dist/tools/list-documents.js +6 -0
  195. package/dist/tools/list-documents.js.map +1 -0
  196. package/dist/tools/list-endpoints.d.ts +5 -0
  197. package/dist/tools/list-endpoints.js +6 -0
  198. package/dist/tools/list-endpoints.js.map +1 -0
  199. package/dist/tools/list-recon-scans.d.ts +36 -0
  200. package/dist/tools/list-recon-scans.js +74 -0
  201. package/dist/tools/list-recon-scans.js.map +1 -0
  202. package/dist/tools/list-scan-artifacts.d.ts +41 -0
  203. package/dist/tools/list-scan-artifacts.js +63 -0
  204. package/dist/tools/list-scan-artifacts.js.map +1 -0
  205. package/dist/tools/list-scans.d.ts +44 -0
  206. package/dist/tools/list-scans.js +91 -0
  207. package/dist/tools/list-scans.js.map +1 -0
  208. package/dist/tools/list-test-library.d.ts +44 -0
  209. package/dist/tools/list-test-library.js +83 -0
  210. package/dist/tools/list-test-library.js.map +1 -0
  211. package/dist/tools/list-test-scenarios.d.ts +31 -0
  212. package/dist/tools/list-test-scenarios.js +66 -0
  213. package/dist/tools/list-test-scenarios.js.map +1 -0
  214. package/dist/tools/local-scan.d.ts +40 -0
  215. package/dist/tools/local-scan.js +261 -0
  216. package/dist/tools/local-scan.js.map +1 -0
  217. package/dist/tools/manage-diagram.d.ts +5 -0
  218. package/dist/tools/manage-diagram.js +16 -0
  219. package/dist/tools/manage-diagram.js.map +1 -0
  220. package/dist/tools/open-in-ide.d.ts +13 -1
  221. package/dist/tools/open-in-ide.js +13 -0
  222. package/dist/tools/open-in-ide.js.map +1 -0
  223. package/dist/tools/run-test-scenario.d.ts +37 -0
  224. package/dist/tools/run-test-scenario.js +70 -0
  225. package/dist/tools/run-test-scenario.js.map +1 -0
  226. package/dist/tools/scan-pr.d.ts +27 -0
  227. package/dist/tools/scan-pr.js +51 -0
  228. package/dist/tools/scan-pr.js.map +1 -0
  229. package/dist/tools/security-review.d.ts +16 -0
  230. package/dist/tools/security-review.js +77 -63
  231. package/dist/tools/security-review.js.map +1 -0
  232. package/dist/tools/setup-red-team-target.d.ts +79 -0
  233. package/dist/tools/setup-red-team-target.js +430 -0
  234. package/dist/tools/setup-red-team-target.js.map +1 -0
  235. package/dist/tools/triage-finding.d.ts +47 -0
  236. package/dist/tools/triage-finding.js +116 -0
  237. package/dist/tools/triage-finding.js.map +1 -0
  238. package/dist/tools/update-document.d.ts +5 -0
  239. package/dist/tools/update-document.js +6 -0
  240. package/dist/tools/update-document.js.map +1 -0
  241. package/dist/tools/update-endpoint.d.ts +5 -0
  242. package/dist/tools/update-endpoint.js +7 -0
  243. package/dist/tools/update-endpoint.js.map +1 -0
  244. package/dist/tools/update-mermaid-source.d.ts +13 -0
  245. package/dist/tools/update-mermaid-source.js +14 -0
  246. package/dist/tools/update-mermaid-source.js.map +1 -0
  247. package/dist/tools/verify-trust-mark.d.ts +5 -0
  248. package/dist/tools/verify-trust-mark.js +6 -0
  249. package/dist/tools/verify-trust-mark.js.map +1 -0
  250. package/dist/types.d.ts +14 -14
  251. package/dist/types.js +28 -22
  252. package/dist/types.js.map +1 -0
  253. package/package.json +4 -24
  254. package/LICENSE +0 -201
  255. package/README.md +0 -19
  256. package/dist/lib/inspect-cache.d.ts +0 -10
  257. package/dist/lib/inspect-cache.js +0 -75
  258. package/dist/lib/next-steps.d.ts +0 -27
  259. package/dist/lib/next-steps.js +0 -21
  260. package/dist/matcher/ast-eval.d.ts +0 -8
  261. package/dist/matcher/ast-eval.js +0 -95
  262. package/dist/matcher/finding.d.ts +0 -55
  263. package/dist/matcher/finding.js +0 -1
  264. package/dist/matcher/index.d.ts +0 -8
  265. package/dist/matcher/index.js +0 -202
  266. package/dist/matcher/inference-candidates.d.ts +0 -26
  267. package/dist/matcher/inference-candidates.js +0 -81
  268. package/dist/matcher/walker.d.ts +0 -7
  269. package/dist/matcher/walker.js +0 -71
  270. package/dist/pattern-pack/index.d.ts +0 -125
  271. package/dist/pattern-pack/index.js +0 -189
  272. package/dist/pattern-packs/zivis-public-0.2.0/capsules/agents/privilege-separation.yaml +0 -224
  273. package/dist/pattern-packs/zivis-public-0.2.0/capsules/prompting/self-consistency-no-isolation.yaml +0 -237
  274. package/dist/pattern-packs/zivis-public-0.2.0/capsules/retrieval/context-injection-no-validator.yaml +0 -348
  275. package/dist/pattern-packs/zivis-public-0.2.0/capsules/security/late-org-filter.yaml +0 -266
  276. package/dist/pattern-packs/zivis-public-0.2.0/controls/external_validator_on_facts.yaml +0 -37
  277. package/dist/pattern-packs/zivis-public-0.2.0/controls/fact_validator_present.yaml +0 -68
  278. package/dist/pattern-packs/zivis-public-0.2.0/controls/human_approval_gate.yaml +0 -44
  279. package/dist/pattern-packs/zivis-public-0.2.0/controls/langgraph_state_machine_with_per_node_tools.yaml +0 -35
  280. package/dist/pattern-packs/zivis-public-0.2.0/controls/per_sample_retrieval_diversification.yaml +0 -38
  281. package/dist/pattern-packs/zivis-public-0.2.0/controls/prisma_extension_or_middleware_attaching_org_filter.yaml +0 -31
  282. package/dist/pattern-packs/zivis-public-0.2.0/controls/row_level_security_policy.yaml +0 -37
  283. package/dist/pattern-packs/zivis-public-0.2.0/controls/source_attribution_present.yaml +0 -58
  284. package/dist/pattern-packs/zivis-public-0.2.0/manifest.json +0 -167
  285. package/dist/pattern-packs/zivis-public-0.2.0/prompts/agents/privilege-separation/identify.md +0 -54
  286. package/dist/pattern-packs/zivis-public-0.2.0/prompts/prompting/self-consistency-no-isolation/identify.md +0 -60
  287. package/dist/pattern-packs/zivis-public-0.2.0/prompts/retrieval/context-injection-no-validator/identify.md +0 -109
  288. package/dist/pattern-packs/zivis-public-0.2.0/prompts/security/late-org-filter/identify.md +0 -78
  289. package/dist/prompts/audit-dependencies.d.ts +0 -2
  290. package/dist/prompts/audit-dependencies.js +0 -47
  291. package/dist/prompts/getting-started.d.ts +0 -2
  292. package/dist/prompts/getting-started.js +0 -37
  293. package/dist/prompts/index.d.ts +0 -2
  294. package/dist/prompts/index.js +0 -6
  295. package/dist/tools/enterprise/get-threat-model-artifact.d.ts +0 -24
  296. package/dist/tools/enterprise/get-threat-model-artifact.js +0 -68
  297. package/dist/tools/enterprise/list-attack-scenarios.d.ts +0 -24
  298. package/dist/tools/enterprise/list-attack-scenarios.js +0 -63
  299. package/dist/tools/enterprise/list-attack-step-library-tests.d.ts +0 -24
  300. package/dist/tools/enterprise/list-attack-step-library-tests.js +0 -55
  301. package/dist/tools/enterprise/list-threat-model-artifacts.d.ts +0 -55
  302. package/dist/tools/enterprise/list-threat-model-artifacts.js +0 -108
  303. package/dist/tools/enterprise/list-threat-model-review-items.d.ts +0 -30
  304. package/dist/tools/enterprise/list-threat-model-review-items.js +0 -54
  305. package/dist/tools/enterprise/list-threat-model-versions.d.ts +0 -24
  306. package/dist/tools/enterprise/list-threat-model-versions.js +0 -54
  307. package/dist/tools/enterprise/manage-threat-model-analysis.d.ts +0 -44
  308. package/dist/tools/enterprise/manage-threat-model-analysis.js +0 -83
  309. package/dist/tools/enterprise/manage-threat-model-review.d.ts +0 -38
  310. package/dist/tools/enterprise/manage-threat-model-review.js +0 -72
  311. package/dist/tools/get-started.d.ts +0 -18
  312. package/dist/tools/get-started.js +0 -470
  313. package/dist/tools/inspect.d.ts +0 -21
  314. package/dist/tools/inspect.js +0 -222
  315. package/dist/tools/manage-application.d.ts +0 -64
  316. package/dist/tools/manage-application.js +0 -129
  317. package/dist/tools/manage-endpoint-lifecycle.d.ts +0 -80
  318. package/dist/tools/manage-endpoint-lifecycle.js +0 -180
  319. package/dist/tools/threat-get-capsule.d.ts +0 -15
  320. package/dist/tools/threat-get-capsule.js +0 -53
  321. package/dist/tools/threat-get-inference-prompt.d.ts +0 -15
  322. package/dist/tools/threat-get-inference-prompt.js +0 -73
  323. package/dist/tools/threat-guide.d.ts +0 -28
  324. package/dist/tools/threat-guide.js +0 -175
  325. package/dist/tools/threat-list-relevant-capsules.d.ts +0 -17
  326. package/dist/tools/threat-list-relevant-capsules.js +0 -158
  327. package/dist/tools/threat-run-matcher.d.ts +0 -17
  328. package/dist/tools/threat-run-matcher.js +0 -145
@@ -1,222 +0,0 @@
1
- import { z } from "zod";
2
- import * as fs from "node:fs/promises";
3
- import * as fssync from "node:fs";
4
- import * as path from "node:path";
5
- import { spawn } from "node:child_process";
6
- import { fileURLToPath } from "node:url";
7
- import { detectProjectBinding } from "../project-binding.js";
8
- import { runMatcher } from "../matcher/index.js";
9
- import { buildInferenceBundle } from "../matcher/inference-candidates.js";
10
- import { withNextSteps, withNextStepsError } from "../lib/next-steps.js";
11
- export const INSPECT_NAME = "zivis_inspect";
12
- export const INSPECT_DESCRIPTION = `Build a local repo graph and run the local pattern matcher to emit threat-model findings. The threat-model-first conversion event.
13
-
14
- Prefer zivis_get_started or zivis_threat_guide first — they read the local inspect cache and only call this tool when a fresh artifact is missing. Calling zivis_inspect directly always re-runs (no idempotency at this layer); reach for it when the user explicitly says "re-inspect" / "rebuild the graph" / "/inspect" or when an entry tool tells you to.
15
-
16
- Use this when the user says any of:
17
- - "model this app" / "threat model this repo"
18
- - "what should we be worried about in this code"
19
- - "set up security for this project" (after auth/binding is done)
20
- - "/inspect"
21
-
22
- What it does, all locally (no source code leaves the machine):
23
- 1. Spawns 'zivis inspect' to walk the repo and produce a typed graph artifact
24
- (services, endpoints, external dependencies; auth boundaries + dataflow are Phase 1.5)
25
- 2. Runs the local matcher against the public pattern pack:
26
- - AST strategies fire via @ast-grep/napi for TS/JS/Python/Go
27
- - META strategies fire via the controls library (when no defending control is present)
28
- - INFER strategies emit candidates the host LLM picks up via zivis_threat_get_inference_prompt
29
- 3. Returns normalized findings with lane (trusted/inferred), confidence, and evidence spans
30
-
31
- Trusted-lane findings are evidence-backed (deterministic strategies fired) and ready for the threat model. Inferred-lane findings need host-LLM confirmation via zivis_threat_get_inference_prompt before promotion. Proprietary platform-side eval (Phase 4 cloud upload) and trust-promoted aggregation are separate steps.
32
-
33
- This is the conversion moment for the threat-model-first sidekick — the user sees specific patterns naming specific files in their repo, in their IDE, in under 30 seconds.`;
34
- export const INSPECT_SCHEMA = {
35
- cwd: z
36
- .string()
37
- .optional()
38
- .describe("Working directory to inspect (defaults to server working directory)."),
39
- application_id: z
40
- .string()
41
- .optional()
42
- .describe("Target application id. If omitted, /inspect resolves it from the project binding. " +
43
- "Required if the binding is ambiguous or maps to multiple applications."),
44
- skip_matcher: z
45
- .boolean()
46
- .optional()
47
- .describe("If true, only build the graph artifact; do not run the matcher. Default: false (matcher runs)."),
48
- };
49
- export function createInspectHandler(_apiClient, _config) {
50
- return async (params) => {
51
- const cwd = params.cwd || process.cwd();
52
- const detected = detectProjectBinding(cwd);
53
- if (!detected) {
54
- return withNextStepsError("No .zivis/project.json found for this directory. /inspect needs a project binding so the resulting threat model attaches to the correct application and org.", [
55
- {
56
- id: "run_auth_init",
57
- label: "Connect this project to your ZIVIS org",
58
- tool: "zivis_check_project",
59
- why: "Run 'zivis auth init' or 'zivis auth login' to create the binding, then re-run /inspect.",
60
- },
61
- ], "Project not bound — run zivis auth login then re-run /inspect.");
62
- }
63
- let inspectStderr = "";
64
- let artifactPath;
65
- try {
66
- const result = await spawnInspect(cwd, params.application_id ?? detected.binding.applicationId);
67
- inspectStderr = result.stderr;
68
- artifactPath = parseArtifactPath(result.stderr);
69
- }
70
- catch (err) {
71
- return withNextStepsError(`Could not run 'zivis inspect': ${err.message}`, [
72
- {
73
- id: "install_cli",
74
- label: "Install the ZIVIS CLI globally",
75
- tool: "zivis_inspect",
76
- why: "Inspect needs the 'zivis' CLI on PATH (or set ZIVIS_CLI_BIN). pnpm add -g @zivis/cli.",
77
- },
78
- ], "Install or surface the ZIVIS CLI binary, then retry.");
79
- }
80
- if (!artifactPath) {
81
- return withNextStepsError(`'zivis inspect' completed but no artifact path was reported. stderr tail:\n${inspectStderr.slice(-500)}`, [], "Inspect ran but produced no artifact path; check the CLI output.");
82
- }
83
- if (params.skip_matcher) {
84
- return withNextSteps({
85
- status: "graph_only",
86
- binding: {
87
- orgName: detected.binding.orgName,
88
- workosOrgId: detected.binding.workosOrgId,
89
- applicationId: params.application_id ?? detected.binding.applicationId ?? null,
90
- },
91
- artifact_path: artifactPath,
92
- inspect_stderr_tail: inspectStderr.split("\n").slice(-6).join("\n"),
93
- }, [
94
- {
95
- id: "run_matcher_now",
96
- label: "Run the matcher against this artifact",
97
- tool: "zivis_threat_run_matcher",
98
- why: "Emit the threat findings deterministic + inference strategies produce.",
99
- },
100
- ], "Graph artifact built; matcher skipped per request.");
101
- }
102
- const matcherResult = await runMatcher({ artifactPath, cwd });
103
- const inferenceBundle = await buildInferenceBundle(matcherResult.findings);
104
- const headline = matcherResult.summary.total === 0
105
- ? `Inspected ${matcherResult.ast_files_scanned} files. No public-pack threat patterns fired against this repo.`
106
- : `Inspected ${matcherResult.ast_files_scanned} files. Found ${matcherResult.summary.total} threat${matcherResult.summary.total === 1 ? "" : "s"} (${matcherResult.summary.trusted_count} trusted, ${matcherResult.summary.inferred_count} inferred). ` +
107
- (inferenceBundle.inference_candidates.length > 0
108
- ? `IMPORTANT: ${inferenceBundle.inference_candidates.length} inference_candidate${inferenceBundle.inference_candidates.length === 1 ? "" : "s"} require host-side execution before findings are presented to the user — see host_required_action.`
109
- : "");
110
- return withNextSteps({
111
- status: "complete",
112
- binding: {
113
- orgName: detected.binding.orgName,
114
- workosOrgId: detected.binding.workosOrgId,
115
- applicationId: params.application_id ?? detected.binding.applicationId ?? null,
116
- },
117
- artifact_path: artifactPath,
118
- matcher: matcherResult,
119
- host_required_action: inferenceBundle.host_required_action,
120
- inference_candidates: inferenceBundle.inference_candidates,
121
- boundary: {
122
- local_only: "Repo walk, graph IR construction, public-pack matching, and inference candidate emission all run on this machine. Inference EXECUTION is by your IDE host model (Mode A); no LLM is invoked by ZIVIS itself.",
123
- sent_to_platform: "Nothing yet — proprietary platform-side evaluation (Phase 4) ships graph features + match candidates, not raw source.",
124
- stays_on_platform: "Proprietary pattern definitions and final scoring logic.",
125
- },
126
- }, matcherResult.summary.trusted_count > 0
127
- ? [
128
- {
129
- id: "review_trusted_findings",
130
- label: `Review the ${matcherResult.summary.trusted_count} trusted-lane finding${matcherResult.summary.trusted_count === 1 ? "" : "s"}`,
131
- tool: "zivis_threat_get_capsule",
132
- why: "Trusted findings are evidence-backed and ready to land in the threat model. Pull each capsule for the full threat narrative + repair contract.",
133
- },
134
- ...(matcherResult.summary.inferred_count > 0
135
- ? [
136
- {
137
- id: "host_runs_inference",
138
- label: `Confirm the ${matcherResult.summary.inferred_count} inferred-lane finding${matcherResult.summary.inferred_count === 1 ? "" : "s"} via your model`,
139
- tool: "zivis_threat_get_inference_prompt",
140
- why: "Inferred findings need host-LLM confirmation. Pull the prompt bundle, run inference, and the JSON output enters the inferred lane until promotion.",
141
- },
142
- ]
143
- : []),
144
- ]
145
- : matcherResult.summary.inferred_count > 0
146
- ? [
147
- {
148
- id: "host_runs_inference",
149
- label: `Confirm the ${matcherResult.summary.inferred_count} inferred-lane finding${matcherResult.summary.inferred_count === 1 ? "" : "s"} via your model`,
150
- tool: "zivis_threat_get_inference_prompt",
151
- why: "Inferred findings need host-LLM confirmation before they can land in the threat model.",
152
- },
153
- ]
154
- : [
155
- {
156
- id: "expand_via_platform",
157
- label: "Public pack found nothing — proprietary patterns evaluated server-side may still apply",
158
- tool: "zivis_inspect",
159
- why: "Phase 4 sends the artifact to the platform for proprietary pattern evaluation; that path is queued.",
160
- },
161
- ], headline);
162
- };
163
- }
164
- async function spawnInspect(cwd, applicationId) {
165
- const bin = await findZivisCliBin();
166
- const args = ["inspect", "--root", cwd];
167
- if (applicationId) {
168
- args.push("--application", applicationId);
169
- }
170
- return new Promise((resolve, reject) => {
171
- const child = spawn(bin.command, [...bin.prefixArgs, ...args], { cwd });
172
- let stdout = "";
173
- let stderr = "";
174
- child.stdout.on("data", (d) => (stdout += d.toString()));
175
- child.stderr.on("data", (d) => (stderr += d.toString()));
176
- child.on("error", (err) => reject(err));
177
- child.on("close", (code) => {
178
- if (code !== 0) {
179
- reject(new Error(`zivis inspect exited ${code}\n${stderr.slice(-500)}`));
180
- return;
181
- }
182
- resolve({ stdout, stderr, code: code ?? 0 });
183
- });
184
- });
185
- }
186
- async function findZivisCliBin() {
187
- const envBin = process.env.ZIVIS_CLI_BIN;
188
- if (envBin) {
189
- if (fssync.existsSync(envBin)) {
190
- return { command: process.execPath, prefixArgs: [envBin] };
191
- }
192
- throw new Error(`ZIVIS_CLI_BIN points to ${envBin} which does not exist`);
193
- }
194
- const sibling = await tryResolveZivisCli();
195
- if (sibling) {
196
- return { command: process.execPath, prefixArgs: [sibling] };
197
- }
198
- return { command: "zivis", prefixArgs: [] };
199
- }
200
- async function tryResolveZivisCli() {
201
- try {
202
- const here = path.dirname(fileURLToPath(import.meta.url));
203
- const candidates = [
204
- path.resolve(here, "../../../zivis-cli/dist/index.js"),
205
- path.resolve(here, "../../node_modules/@zivis/cli/dist/index.js"),
206
- path.resolve(here, "../../../node_modules/@zivis/cli/dist/index.js"),
207
- ];
208
- for (const c of candidates) {
209
- if (fssync.existsSync(c))
210
- return c;
211
- }
212
- }
213
- catch {
214
- }
215
- return undefined;
216
- }
217
- function parseArtifactPath(stderr) {
218
- const match = stderr.match(/wrote\s+(\S+\.json)/);
219
- return match?.[1];
220
- }
221
- void parseArtifactPath;
222
- void fs;
@@ -1,64 +0,0 @@
1
- import { z } from "zod";
2
- import type { ApiClient } from "../api-client.js";
3
- export declare const MANAGE_APPLICATION_NAME = "zivis_manage_application";
4
- export declare const MANAGE_APPLICATION_DESCRIPTION = "Create, update, or delete a target application.\n\nActions:\n- create: requires at least name, base_url, auth_type\n- update: patch an existing application (requires application_id)\n- delete: remove an application (requires application_id)";
5
- export declare const MANAGE_APPLICATION_SCHEMA: {
6
- action: z.ZodEnum<{
7
- create: "create";
8
- update: "update";
9
- delete: "delete";
10
- }>;
11
- application_id: z.ZodOptional<z.ZodString>;
12
- name: z.ZodOptional<z.ZodString>;
13
- description: z.ZodOptional<z.ZodString>;
14
- base_url: z.ZodOptional<z.ZodString>;
15
- api_url: z.ZodOptional<z.ZodString>;
16
- auth_type: z.ZodOptional<z.ZodEnum<{
17
- none: "none";
18
- oauth_pkce: "oauth_pkce";
19
- static_token: "static_token";
20
- client_credentials: "client_credentials";
21
- bearer_refresh: "bearer_refresh";
22
- }>>;
23
- has_rag: z.ZodOptional<z.ZodBoolean>;
24
- has_tools: z.ZodOptional<z.ZodBoolean>;
25
- has_memory: z.ZodOptional<z.ZodBoolean>;
26
- is_multi_turn: z.ZodOptional<z.ZodBoolean>;
27
- system_context: z.ZodOptional<z.ZodString>;
28
- type: z.ZodOptional<z.ZodEnum<{
29
- api: "api";
30
- chat: "chat";
31
- sse: "sse";
32
- validation: "validation";
33
- web: "web";
34
- }>>;
35
- use_ephemeral_creds: z.ZodOptional<z.ZodBoolean>;
36
- };
37
- export declare function createManageApplicationHandler(apiClient: ApiClient): (params: {
38
- action: "create" | "update" | "delete";
39
- application_id?: string;
40
- name?: string;
41
- description?: string;
42
- base_url?: string;
43
- api_url?: string;
44
- auth_type?: "none" | "oauth_pkce" | "static_token" | "client_credentials" | "bearer_refresh";
45
- has_rag?: boolean;
46
- has_tools?: boolean;
47
- has_memory?: boolean;
48
- is_multi_turn?: boolean;
49
- system_context?: string;
50
- type?: "api" | "chat" | "sse" | "validation" | "web";
51
- use_ephemeral_creds?: boolean;
52
- }) => Promise<{
53
- content: {
54
- type: "text";
55
- text: string;
56
- }[];
57
- isError: boolean;
58
- } | {
59
- content: {
60
- type: "text";
61
- text: string;
62
- }[];
63
- isError?: undefined;
64
- }>;
@@ -1,129 +0,0 @@
1
- import { z } from "zod";
2
- import { requireApplicationId } from "../resolve-application-id.js";
3
- import { sanitizeResponse } from "../sanitize.js";
4
- export const MANAGE_APPLICATION_NAME = "zivis_manage_application";
5
- export const MANAGE_APPLICATION_DESCRIPTION = `Create, update, or delete a target application.
6
-
7
- Actions:
8
- - create: requires at least name, base_url, auth_type
9
- - update: patch an existing application (requires application_id)
10
- - delete: remove an application (requires application_id)`;
11
- export const MANAGE_APPLICATION_SCHEMA = {
12
- action: z.enum(["create", "update", "delete"]).describe("CRUD action"),
13
- application_id: z
14
- .string()
15
- .optional()
16
- .describe("Required for update/delete. Optional for create."),
17
- name: z.string().optional().describe("Application name"),
18
- description: z.string().optional().describe("Application description"),
19
- base_url: z.string().optional().describe("Base URL, e.g. https://api.example.com"),
20
- api_url: z.string().optional().describe("Explicit API URL"),
21
- auth_type: z
22
- .enum(["none", "oauth_pkce", "static_token", "client_credentials", "bearer_refresh"])
23
- .optional()
24
- .describe("Application auth type (required for create)"),
25
- has_rag: z.boolean().optional().describe("LLM capability flag"),
26
- has_tools: z.boolean().optional().describe("LLM capability flag"),
27
- has_memory: z.boolean().optional().describe("LLM capability flag"),
28
- is_multi_turn: z.boolean().optional().describe("LLM capability flag"),
29
- system_context: z.string().optional().describe("System context/prompt context"),
30
- type: z
31
- .enum(["api", "chat", "sse", "validation", "web"])
32
- .optional()
33
- .describe("Application type"),
34
- use_ephemeral_creds: z
35
- .boolean()
36
- .optional()
37
- .describe("Whether ephemeral credentials are enabled"),
38
- };
39
- export function createManageApplicationHandler(apiClient) {
40
- return async (params) => {
41
- try {
42
- const { action } = params;
43
- let data;
44
- if (action === "create") {
45
- if (!params.name || !params.base_url || !params.auth_type) {
46
- return {
47
- content: [
48
- {
49
- type: "text",
50
- text: "Error: create requires name, base_url, and auth_type",
51
- },
52
- ],
53
- isError: true,
54
- };
55
- }
56
- data = await apiClient.post("/api/rt/applications", {
57
- name: params.name,
58
- description: params.description,
59
- baseUrl: params.base_url,
60
- apiUrl: params.api_url,
61
- authType: params.auth_type,
62
- hasRag: params.has_rag,
63
- hasTools: params.has_tools,
64
- hasMemory: params.has_memory,
65
- isMultiTurn: params.is_multi_turn,
66
- systemContext: params.system_context,
67
- type: params.type,
68
- useEphemeralCreds: params.use_ephemeral_creds,
69
- });
70
- }
71
- else {
72
- const req = requireApplicationId(params.application_id);
73
- if (!req.ok) {
74
- return {
75
- content: [{ type: "text", text: `Error: ${req.message}` }],
76
- isError: true,
77
- };
78
- }
79
- if (action === "delete") {
80
- data = await apiClient.del(`/api/rt/applications/${req.id}`);
81
- }
82
- else {
83
- const body = {};
84
- if (params.name !== undefined)
85
- body.name = params.name;
86
- if (params.description !== undefined)
87
- body.description = params.description;
88
- if (params.base_url !== undefined)
89
- body.baseUrl = params.base_url;
90
- if (params.api_url !== undefined)
91
- body.apiUrl = params.api_url;
92
- if (params.auth_type !== undefined)
93
- body.authType = params.auth_type;
94
- if (params.has_rag !== undefined)
95
- body.hasRag = params.has_rag;
96
- if (params.has_tools !== undefined)
97
- body.hasTools = params.has_tools;
98
- if (params.has_memory !== undefined)
99
- body.hasMemory = params.has_memory;
100
- if (params.is_multi_turn !== undefined)
101
- body.isMultiTurn = params.is_multi_turn;
102
- if (params.system_context !== undefined)
103
- body.systemContext = params.system_context;
104
- if (params.type !== undefined)
105
- body.type = params.type;
106
- if (params.use_ephemeral_creds !== undefined) {
107
- body.useEphemeralCreds = params.use_ephemeral_creds;
108
- }
109
- data = await apiClient.patch(`/api/rt/applications/${req.id}`, body);
110
- }
111
- }
112
- const sanitized = sanitizeResponse({
113
- action,
114
- application_id: params.application_id,
115
- result: data,
116
- });
117
- return {
118
- content: [{ type: "text", text: JSON.stringify(sanitized, null, 2) }],
119
- };
120
- }
121
- catch (err) {
122
- const message = err instanceof Error ? err.message : "Failed to manage application";
123
- return {
124
- content: [{ type: "text", text: `Error: ${message}` }],
125
- isError: true,
126
- };
127
- }
128
- };
129
- }
@@ -1,80 +0,0 @@
1
- import { z } from "zod";
2
- import type { ApiClient } from "../api-client.js";
3
- export declare const MANAGE_ENDPOINT_LIFECYCLE_NAME = "zivis_manage_endpoint_lifecycle";
4
- export declare const MANAGE_ENDPOINT_LIFECYCLE_DESCRIPTION = "Manage endpoint lifecycle for an application.\n\nActions:\n- create: create a single endpoint\n- update: patch an endpoint\n- delete: delete a single endpoint\n- bulk_delete: delete endpoints by source (e.g., openapi)\n- import_openapi: import endpoints from an OpenAPI spec";
5
- export declare const MANAGE_ENDPOINT_LIFECYCLE_SCHEMA: {
6
- application_id: z.ZodOptional<z.ZodString>;
7
- action: z.ZodEnum<{
8
- create: "create";
9
- update: "update";
10
- delete: "delete";
11
- bulk_delete: "bulk_delete";
12
- import_openapi: "import_openapi";
13
- }>;
14
- endpoint_id: z.ZodOptional<z.ZodString>;
15
- path: z.ZodOptional<z.ZodString>;
16
- method: z.ZodOptional<z.ZodEnum<{
17
- POST: "POST";
18
- GET: "GET";
19
- PATCH: "PATCH";
20
- DELETE: "DELETE";
21
- PUT: "PUT";
22
- HEAD: "HEAD";
23
- OPTIONS: "OPTIONS";
24
- }>>;
25
- summary: z.ZodOptional<z.ZodString>;
26
- description: z.ZodOptional<z.ZodString>;
27
- tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
28
- auth_required: z.ZodOptional<z.ZodBoolean>;
29
- deprecated: z.ZodOptional<z.ZodBoolean>;
30
- endpoint_type: z.ZodOptional<z.ZodEnum<{
31
- api: "api";
32
- chat: "chat";
33
- sse: "sse";
34
- validation: "validation";
35
- web: "web";
36
- }>>;
37
- request_template: z.ZodOptional<z.ZodString>;
38
- response_path: z.ZodOptional<z.ZodString>;
39
- streaming_enabled: z.ZodOptional<z.ZodBoolean>;
40
- source: z.ZodOptional<z.ZodEnum<{
41
- openapi: "openapi";
42
- manual: "manual";
43
- discovery: "discovery";
44
- }>>;
45
- spec_url: z.ZodOptional<z.ZodString>;
46
- spec_content: z.ZodOptional<z.ZodString>;
47
- replace_existing: z.ZodOptional<z.ZodBoolean>;
48
- };
49
- export declare function createManageEndpointLifecycleHandler(apiClient: ApiClient): (params: {
50
- application_id?: string;
51
- action: "create" | "update" | "delete" | "bulk_delete" | "import_openapi";
52
- endpoint_id?: string;
53
- path?: string;
54
- method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
55
- summary?: string;
56
- description?: string;
57
- tags?: string[];
58
- auth_required?: boolean;
59
- deprecated?: boolean;
60
- endpoint_type?: "api" | "chat" | "sse" | "validation" | "web";
61
- request_template?: string;
62
- response_path?: string;
63
- streaming_enabled?: boolean;
64
- source?: "openapi" | "manual" | "discovery";
65
- spec_url?: string;
66
- spec_content?: string;
67
- replace_existing?: boolean;
68
- }) => Promise<{
69
- content: {
70
- type: "text";
71
- text: string;
72
- }[];
73
- isError: boolean;
74
- } | {
75
- content: {
76
- type: "text";
77
- text: string;
78
- }[];
79
- isError?: undefined;
80
- }>;
@@ -1,180 +0,0 @@
1
- import { z } from "zod";
2
- import { requireApplicationId } from "../resolve-application-id.js";
3
- import { sanitizeResponse } from "../sanitize.js";
4
- export const MANAGE_ENDPOINT_LIFECYCLE_NAME = "zivis_manage_endpoint_lifecycle";
5
- export const MANAGE_ENDPOINT_LIFECYCLE_DESCRIPTION = `Manage endpoint lifecycle for an application.
6
-
7
- Actions:
8
- - create: create a single endpoint
9
- - update: patch an endpoint
10
- - delete: delete a single endpoint
11
- - bulk_delete: delete endpoints by source (e.g., openapi)
12
- - import_openapi: import endpoints from an OpenAPI spec`;
13
- export const MANAGE_ENDPOINT_LIFECYCLE_SCHEMA = {
14
- application_id: z
15
- .string()
16
- .optional()
17
- .describe("Application UUID. If omitted, uses applicationId from .zivis/project.json when set."),
18
- action: z
19
- .enum(["create", "update", "delete", "bulk_delete", "import_openapi"])
20
- .describe("Endpoint lifecycle action"),
21
- endpoint_id: z.string().optional().describe("Required for update/delete actions"),
22
- path: z.string().optional().describe("Endpoint path, e.g. /api/chat"),
23
- method: z
24
- .enum(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"])
25
- .optional()
26
- .describe("HTTP method"),
27
- summary: z.string().optional().describe("Endpoint summary"),
28
- description: z.string().optional().describe("Endpoint description"),
29
- tags: z.array(z.string()).optional().describe("Endpoint tags"),
30
- auth_required: z.boolean().optional().describe("Whether auth is required"),
31
- deprecated: z.boolean().optional().describe("Whether endpoint is deprecated"),
32
- endpoint_type: z
33
- .enum(["api", "chat", "sse", "validation", "web"])
34
- .optional()
35
- .describe("Endpoint type"),
36
- request_template: z
37
- .string()
38
- .optional()
39
- .describe("AI request template, usually includes {{message}}"),
40
- response_path: z
41
- .string()
42
- .optional()
43
- .describe("JSON path to pull response text"),
44
- streaming_enabled: z.boolean().optional().describe("Whether streaming is enabled"),
45
- source: z
46
- .enum(["openapi", "manual", "discovery"])
47
- .optional()
48
- .describe("Source filter for bulk_delete"),
49
- spec_url: z.string().optional().describe("OpenAPI spec URL for import_openapi"),
50
- spec_content: z.string().optional().describe("Raw OpenAPI spec content"),
51
- replace_existing: z
52
- .boolean()
53
- .optional()
54
- .describe("When import_openapi, remove previous openapi endpoints first"),
55
- };
56
- export function createManageEndpointLifecycleHandler(apiClient) {
57
- return async (params) => {
58
- const req = requireApplicationId(params.application_id);
59
- if (!req.ok) {
60
- return {
61
- content: [{ type: "text", text: `Error: ${req.message}` }],
62
- isError: true,
63
- };
64
- }
65
- const applicationId = req.id;
66
- const action = params.action;
67
- try {
68
- let data;
69
- if (action === "create") {
70
- if (!params.path || !params.method) {
71
- return {
72
- content: [
73
- {
74
- type: "text",
75
- text: "Error: create requires path and method",
76
- },
77
- ],
78
- isError: true,
79
- };
80
- }
81
- data = await apiClient.post(`/api/rt/applications/${applicationId}/endpoints`, {
82
- path: params.path,
83
- method: params.method,
84
- summary: params.summary,
85
- description: params.description,
86
- tags: params.tags,
87
- authRequired: params.auth_required,
88
- deprecated: params.deprecated,
89
- endpointType: params.endpoint_type,
90
- requestTemplate: params.request_template,
91
- responsePath: params.response_path,
92
- streamingEnabled: params.streaming_enabled,
93
- });
94
- }
95
- else if (action === "update") {
96
- if (!params.endpoint_id) {
97
- return {
98
- content: [
99
- { type: "text", text: "Error: endpoint_id is required for update" },
100
- ],
101
- isError: true,
102
- };
103
- }
104
- const body = {};
105
- if (params.path !== undefined)
106
- body.path = params.path;
107
- if (params.method !== undefined)
108
- body.method = params.method;
109
- if (params.summary !== undefined)
110
- body.summary = params.summary;
111
- if (params.description !== undefined)
112
- body.description = params.description;
113
- if (params.tags !== undefined)
114
- body.tags = params.tags;
115
- if (params.auth_required !== undefined)
116
- body.authRequired = params.auth_required;
117
- if (params.deprecated !== undefined)
118
- body.deprecated = params.deprecated;
119
- if (params.endpoint_type !== undefined)
120
- body.endpointType = params.endpoint_type;
121
- if (params.request_template !== undefined)
122
- body.requestTemplate = params.request_template;
123
- if (params.response_path !== undefined)
124
- body.responsePath = params.response_path;
125
- if (params.streaming_enabled !== undefined) {
126
- body.streamingEnabled = params.streaming_enabled;
127
- }
128
- data = await apiClient.patch(`/api/rt/applications/${applicationId}/endpoints/${params.endpoint_id}`, body);
129
- }
130
- else if (action === "delete") {
131
- if (!params.endpoint_id) {
132
- return {
133
- content: [
134
- { type: "text", text: "Error: endpoint_id is required for delete" },
135
- ],
136
- isError: true,
137
- };
138
- }
139
- data = await apiClient.del(`/api/rt/applications/${applicationId}/endpoints/${params.endpoint_id}`);
140
- }
141
- else if (action === "bulk_delete") {
142
- if (!params.source) {
143
- return {
144
- content: [
145
- {
146
- type: "text",
147
- text: "Error: source is required for bulk_delete (openapi/manual/discovery)",
148
- },
149
- ],
150
- isError: true,
151
- };
152
- }
153
- data = await apiClient.del(`/api/rt/applications/${applicationId}/endpoints?source=${encodeURIComponent(params.source)}`);
154
- }
155
- else {
156
- data = await apiClient.post(`/api/rt/applications/${applicationId}/endpoints/import-openapi`, {
157
- specUrl: params.spec_url,
158
- specContent: params.spec_content,
159
- replaceExisting: params.replace_existing ?? false,
160
- });
161
- }
162
- const sanitized = sanitizeResponse({
163
- action,
164
- application_id: applicationId,
165
- endpoint_id: params.endpoint_id,
166
- result: data,
167
- });
168
- return {
169
- content: [{ type: "text", text: JSON.stringify(sanitized, null, 2) }],
170
- };
171
- }
172
- catch (err) {
173
- const message = err instanceof Error ? err.message : "Failed to manage endpoint lifecycle";
174
- return {
175
- content: [{ type: "text", text: `Error: ${message}` }],
176
- isError: true,
177
- };
178
- }
179
- };
180
- }