@copado/agentia-cli 1.2.0 → 1.4.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 (302) hide show
  1. package/CHANGELOG.md +58 -1
  2. package/README.md +2299 -1615
  3. package/dist/commands/auth/get.js +21 -1
  4. package/dist/commands/auth/set.js +13 -0
  5. package/dist/commands/auth/unset.js +37 -0
  6. package/dist/commands/cicd/cloud/commit.js +6 -5
  7. package/dist/commands/cicd/cloud/promote.js +44 -8
  8. package/dist/commands/cicd/credential/auth/status.js +2 -2
  9. package/dist/commands/cicd/credential/auth/web/login.js +2 -2
  10. package/dist/commands/cicd/credential/create.js +2 -2
  11. package/dist/commands/cicd/credential/list.js +4 -3
  12. package/dist/commands/cicd/credential/open.js +2 -2
  13. package/dist/commands/cicd/credential/update.js +2 -2
  14. package/dist/commands/cicd/data/commit/create.js +2 -2
  15. package/dist/commands/cicd/data/commit/list.js +2 -2
  16. package/dist/commands/cicd/data/dataset-file/content.js +2 -2
  17. package/dist/commands/cicd/data/dataset-file/list.js +2 -2
  18. package/dist/commands/cicd/data/filter/add.js +2 -2
  19. package/dist/commands/cicd/data/filter/delete.js +2 -2
  20. package/dist/commands/cicd/data/filter/list.js +2 -2
  21. package/dist/commands/cicd/data/filter/update.js +2 -2
  22. package/dist/commands/cicd/data/formula/create.js +2 -2
  23. package/dist/commands/cicd/data/formula/list.js +2 -2
  24. package/dist/commands/cicd/data/formula/update.js +2 -2
  25. package/dist/commands/cicd/data/records/match.js +2 -2
  26. package/dist/commands/cicd/data/records/search.js +2 -2
  27. package/dist/commands/cicd/data/sobject/fields.js +2 -2
  28. package/dist/commands/cicd/data/sobject/relationships.js +2 -2
  29. package/dist/commands/cicd/data/sync/apply.js +2 -2
  30. package/dist/commands/cicd/data/sync/preview-updates.js +2 -2
  31. package/dist/commands/cicd/data/template/convert-old.js +2 -2
  32. package/dist/commands/cicd/data/template/create.js +2 -2
  33. package/dist/commands/cicd/data/template/delete.js +2 -2
  34. package/dist/commands/cicd/data/template/get-detail.js +2 -2
  35. package/dist/commands/cicd/data/template/get.js +2 -2
  36. package/dist/commands/cicd/data/template/list.js +2 -2
  37. package/dist/commands/cicd/data/template/open.js +2 -2
  38. package/dist/commands/cicd/data/template/save-detail.js +2 -2
  39. package/dist/commands/cicd/environment/auth/status.js +2 -2
  40. package/dist/commands/cicd/environment/auth/web/login.js +2 -2
  41. package/dist/commands/cicd/environment/create.js +2 -2
  42. package/dist/commands/cicd/environment/get.js +2 -2
  43. package/dist/commands/cicd/environment/list.js +4 -3
  44. package/dist/commands/cicd/environment/open.js +2 -2
  45. package/dist/commands/cicd/environment/update.js +2 -2
  46. package/dist/commands/cicd/extension/create.js +2 -2
  47. package/dist/commands/cicd/extension/install.js +2 -2
  48. package/dist/commands/cicd/extension/package.js +2 -2
  49. package/dist/commands/cicd/extension/publish.js +2 -2
  50. package/dist/commands/cicd/extension/uninstall.js +2 -2
  51. package/dist/commands/cicd/extension/validate.js +2 -2
  52. package/dist/commands/cicd/extension-configuration/get.js +2 -2
  53. package/dist/commands/cicd/extension-configuration/list.js +4 -3
  54. package/dist/commands/cicd/extension-configuration/open.js +2 -2
  55. package/dist/commands/cicd/function/defaults.js +2 -2
  56. package/dist/commands/cicd/function/delete.js +2 -2
  57. package/dist/commands/cicd/function/get.js +2 -2
  58. package/dist/commands/cicd/function/list.js +12 -15
  59. package/dist/commands/cicd/function/open.js +2 -2
  60. package/dist/commands/cicd/function/result/get.js +2 -2
  61. package/dist/commands/cicd/function/result/log/get.js +2 -2
  62. package/dist/commands/cicd/function/run-local.js +2 -2
  63. package/dist/commands/cicd/function/run.js +2 -2
  64. package/dist/commands/cicd/function/upsert.js +2 -2
  65. package/dist/commands/cicd/health-check.js +2 -2
  66. package/dist/commands/cicd/job/get.js +2 -2
  67. package/dist/commands/cicd/job/kill.js +2 -2
  68. package/dist/commands/cicd/job/list.js +4 -3
  69. package/dist/commands/cicd/job/log/get.js +2 -2
  70. package/dist/commands/cicd/job/open.js +2 -2
  71. package/dist/commands/cicd/job/pause.js +2 -2
  72. package/dist/commands/cicd/job/result-file/get.js +13 -8
  73. package/dist/commands/cicd/job/result-file/list.js +2 -2
  74. package/dist/commands/cicd/job/resume.js +2 -2
  75. package/dist/commands/cicd/job/run.js +2 -2
  76. package/dist/commands/cicd/metadata/content/compare.js +2 -2
  77. package/dist/commands/cicd/metadata/content/get.js +2 -2
  78. package/dist/commands/cicd/metadata/dependency/list.js +44 -21
  79. package/dist/commands/cicd/metadata/explore.js +2 -2
  80. package/dist/commands/cicd/metadata/index/compare.js +2 -2
  81. package/dist/commands/cicd/metadata/list.js +2 -2
  82. package/dist/commands/cicd/metadata/refresh/deleted.js +2 -2
  83. package/dist/commands/cicd/metadata/refresh/run.js +2 -2
  84. package/dist/commands/cicd/metadata/refresh/status.js +2 -2
  85. package/dist/commands/cicd/notification/configure.js +2 -2
  86. package/dist/commands/cicd/notification/get.js +2 -2
  87. package/dist/commands/cicd/pipeline/automation/activate.js +2 -2
  88. package/dist/commands/cicd/pipeline/automation/create.js +2 -2
  89. package/dist/commands/cicd/pipeline/automation/deactivate.js +2 -2
  90. package/dist/commands/cicd/pipeline/automation/delete.js +2 -2
  91. package/dist/commands/cicd/pipeline/automation/get.js +2 -2
  92. package/dist/commands/cicd/pipeline/automation/list.js +4 -3
  93. package/dist/commands/cicd/pipeline/automation/open.js +2 -2
  94. package/dist/commands/cicd/pipeline/automation/update.js +2 -2
  95. package/dist/commands/cicd/pipeline/connection/create.js +2 -2
  96. package/dist/commands/cicd/pipeline/connection/delete.js +2 -2
  97. package/dist/commands/cicd/pipeline/connection/list.js +2 -2
  98. package/dist/commands/cicd/pipeline/connection/open.js +2 -2
  99. package/dist/commands/cicd/pipeline/connection/update.js +2 -2
  100. package/dist/commands/cicd/pipeline/create.js +2 -2
  101. package/dist/commands/cicd/pipeline/get.js +2 -2
  102. package/dist/commands/cicd/pipeline/list.js +4 -3
  103. package/dist/commands/cicd/pipeline/open.js +2 -2
  104. package/dist/commands/cicd/pipeline/quality-gate/activate.js +2 -2
  105. package/dist/commands/cicd/pipeline/quality-gate/create.js +2 -2
  106. package/dist/commands/cicd/pipeline/quality-gate/deactivate.js +2 -2
  107. package/dist/commands/cicd/pipeline/quality-gate/delete.js +2 -2
  108. package/dist/commands/cicd/pipeline/quality-gate/get.js +2 -2
  109. package/dist/commands/cicd/pipeline/quality-gate/list.js +4 -3
  110. package/dist/commands/cicd/pipeline/quality-gate/open.js +2 -2
  111. package/dist/commands/cicd/pipeline/quality-gate/update.js +2 -2
  112. package/dist/commands/cicd/pipeline/stage-connection/create.js +2 -2
  113. package/dist/commands/cicd/pipeline/stage-connection/delete.js +2 -2
  114. package/dist/commands/cicd/pipeline/stage-connection/list.js +2 -2
  115. package/dist/commands/cicd/pipeline/stage-connection/open.js +2 -2
  116. package/dist/commands/cicd/pipeline/stage-connection/update.js +2 -2
  117. package/dist/commands/cicd/pipeline/update.js +2 -2
  118. package/dist/commands/cicd/project/create.js +2 -2
  119. package/dist/commands/cicd/project/default/get.js +2 -2
  120. package/dist/commands/cicd/project/default/set.js +2 -2
  121. package/dist/commands/cicd/project/default/unset.js +2 -2
  122. package/dist/commands/cicd/project/delete.js +2 -2
  123. package/dist/commands/cicd/project/get.js +2 -2
  124. package/dist/commands/cicd/project/list.js +4 -3
  125. package/dist/commands/cicd/project/open.js +2 -2
  126. package/dist/commands/cicd/project/update.js +2 -2
  127. package/dist/commands/cicd/promotion/conflict/get.js +2 -2
  128. package/dist/commands/cicd/promotion/conflict/list.js +2 -2
  129. package/dist/commands/cicd/promotion/conflict/resolve.js +2 -2
  130. package/dist/commands/cicd/promotion/conflict/unresolve.js +2 -2
  131. package/dist/commands/cicd/promotion/get.js +2 -2
  132. package/dist/commands/cicd/promotion/job-step/update.js +2 -2
  133. package/dist/commands/cicd/promotion/list.js +4 -3
  134. package/dist/commands/cicd/promotion/open.js +2 -2
  135. package/dist/commands/cicd/promotion/queue/list.js +28 -0
  136. package/dist/commands/cicd/promotion/queue/remove.js +37 -0
  137. package/dist/commands/cicd/promotion/run.js +2 -2
  138. package/dist/commands/cicd/promotion/status.js +29 -0
  139. package/dist/commands/cicd/repository/auth/https/configure.js +2 -2
  140. package/dist/commands/cicd/repository/auth/oauth/login.js +2 -2
  141. package/dist/commands/cicd/repository/auth/setup.js +2 -2
  142. package/dist/commands/cicd/repository/auth/ssh/configure.js +2 -2
  143. package/dist/commands/cicd/repository/create.js +2 -2
  144. package/dist/commands/cicd/repository/delete.js +2 -2
  145. package/dist/commands/cicd/repository/get.js +2 -2
  146. package/dist/commands/cicd/repository/list.js +7 -10
  147. package/dist/commands/cicd/repository/open.js +2 -2
  148. package/dist/commands/cicd/repository/reset.js +2 -2
  149. package/dist/commands/cicd/repository/update.js +2 -2
  150. package/dist/commands/cicd/repository/validate.js +2 -2
  151. package/dist/commands/cicd/stage/create.js +2 -2
  152. package/dist/commands/cicd/stage/delete.js +2 -2
  153. package/dist/commands/cicd/stage/get.js +2 -2
  154. package/dist/commands/cicd/stage/list.js +4 -3
  155. package/dist/commands/cicd/stage/open.js +2 -2
  156. package/dist/commands/cicd/stage/update.js +2 -2
  157. package/dist/commands/cicd/template/defaults.js +2 -2
  158. package/dist/commands/cicd/template/delete.js +2 -2
  159. package/dist/commands/cicd/template/get.js +2 -2
  160. package/dist/commands/cicd/template/list.js +11 -14
  161. package/dist/commands/cicd/template/upsert.js +2 -2
  162. package/dist/commands/cicd/user/get.js +2 -2
  163. package/dist/commands/cicd/work/ahead-behind.js +2 -2
  164. package/dist/commands/cicd/work/create.js +2 -2
  165. package/dist/commands/cicd/work/delete.js +4 -4
  166. package/dist/commands/cicd/work/deployment-step/create.js +2 -2
  167. package/dist/commands/cicd/work/deployment-step/delete.js +2 -2
  168. package/dist/commands/cicd/work/deployment-step/list.js +2 -2
  169. package/dist/commands/cicd/work/deployment-step/reorder.js +2 -2
  170. package/dist/commands/cicd/work/deployment-step/salesforce-flows.js +2 -2
  171. package/dist/commands/cicd/work/deployment-step/types.js +2 -2
  172. package/dist/commands/cicd/work/deployment-step/update.js +2 -2
  173. package/dist/commands/cicd/work/done.js +2 -2
  174. package/dist/commands/cicd/work/environment-sync.js +140 -64
  175. package/dist/commands/cicd/work/get.js +4 -4
  176. package/dist/commands/cicd/work/list.js +4 -3
  177. package/dist/commands/cicd/work/open.js +2 -2
  178. package/dist/commands/cicd/work/promote.js +2 -2
  179. package/dist/commands/cicd/work/publish.js +2 -2
  180. package/dist/commands/cicd/work/push.js +2 -2
  181. package/dist/commands/cicd/work/set.js +2 -2
  182. package/dist/commands/cicd/work/status.js +2 -2
  183. package/dist/commands/cicd/work/submit.js +2 -2
  184. package/dist/commands/cicd/work/test/apex.js +20 -35
  185. package/dist/commands/cicd/work/test.js +116 -11
  186. package/dist/commands/cicd/work/update.js +4 -4
  187. package/dist/commands/help-agent.js +15 -0
  188. package/dist/commands/help.js +38 -0
  189. package/dist/commands/history/clear.js +42 -0
  190. package/dist/commands/history/list.js +50 -0
  191. package/dist/commands/support.js +15 -0
  192. package/dist/commands/testing/browser/execute.js +49 -0
  193. package/dist/commands/testing/browser/history.js +49 -0
  194. package/dist/commands/testing/browser/inspect.js +35 -0
  195. package/dist/commands/testing/browser/recorder.js +52 -0
  196. package/dist/commands/testing/browser/screenshot.js +27 -0
  197. package/dist/commands/testing/browser/set-options.js +35 -0
  198. package/dist/commands/testing/browser/start.js +51 -0
  199. package/dist/commands/testing/browser/status.js +26 -0
  200. package/dist/commands/testing/browser/stop.js +34 -0
  201. package/dist/commands/testing/browser/view.js +35 -0
  202. package/dist/commands/testing/job/runs/abort.js +1 -1
  203. package/dist/commands/testing/job/runs/get.js +1 -1
  204. package/dist/commands/testing/job/runs/list.js +1 -1
  205. package/dist/commands/testing/job/runs/logs.js +1 -1
  206. package/dist/commands/testing/job/runs/search.js +1 -1
  207. package/dist/hooks/init/cicd-connection.js +59 -0
  208. package/dist/lib/agentia-command.js +69 -6
  209. package/dist/lib/cicd-command.js +3 -0
  210. package/dist/lib/cicd-connection.js +22 -0
  211. package/dist/lib/cicd-gateway.js +2 -1
  212. package/dist/lib/command-history-sanitization.js +9 -0
  213. package/dist/lib/command-history.js +11 -0
  214. package/dist/lib/command-output-buffer.js +6 -1
  215. package/dist/lib/defaults-store.js +5 -1
  216. package/dist/lib/dependency-from-changes.js +3 -1
  217. package/dist/lib/dependency-source-context.js +3 -0
  218. package/dist/lib/function-list.js +3 -0
  219. package/dist/lib/git-worktree.js +4 -1
  220. package/dist/lib/help-agent-command.js +3 -0
  221. package/dist/lib/help-agent-interaction-history.js +10 -0
  222. package/dist/lib/help-agent-session.js +3 -0
  223. package/dist/lib/job-get.js +2 -1
  224. package/dist/lib/job-types.js +2 -1
  225. package/dist/lib/list-pagination.js +6 -1
  226. package/dist/lib/local-quality-gates.js +4 -1
  227. package/dist/lib/mcp/result.js +41 -3
  228. package/dist/lib/mcp/server.js +3 -2
  229. package/dist/lib/mcp/testing-browser-tools.js +179 -0
  230. package/dist/lib/mcp/testing-tools.js +4 -3
  231. package/dist/lib/mcp/tool-annotations.js +31 -12
  232. package/dist/lib/mcp/tools.js +115 -59
  233. package/dist/lib/mcp/work-tools.js +100 -47
  234. package/dist/lib/promotion-queue.js +5 -0
  235. package/dist/lib/promotion-run.js +4 -1
  236. package/dist/lib/promotion-status.js +12 -0
  237. package/dist/lib/quality-gates.js +13 -0
  238. package/dist/lib/repository-list.js +3 -0
  239. package/dist/lib/runtime.js +1 -1
  240. package/dist/lib/stock-quality-gates.js +2 -1
  241. package/dist/lib/support-ai-context.js +11 -0
  242. package/dist/lib/support-ai-stream-parser.js +4 -0
  243. package/dist/lib/support-ai.js +9 -0
  244. package/dist/lib/template-list.js +3 -0
  245. package/dist/lib/testing-browser-command.js +6 -0
  246. package/dist/lib/testing-browser-operations.js +16 -0
  247. package/dist/lib/testing-browser-requests.js +11 -0
  248. package/dist/lib/testing-browser-robot.js +9 -0
  249. package/dist/lib/testing-browser-session.js +13 -0
  250. package/dist/lib/testing-browser-state.js +17 -0
  251. package/dist/lib/testing-browser-stream.js +7 -0
  252. package/dist/lib/testing-browser-types.js +3 -0
  253. package/dist/lib/testing-browser-viewer-key.js +7 -0
  254. package/dist/lib/testing-gateway.js +2 -1
  255. package/dist/lib/testing-operations.js +21 -1
  256. package/dist/lib/testing-sanitization.js +2 -1
  257. package/dist/lib/work-apex-test-failures.js +2 -1
  258. package/dist/lib/work-environment-sync-ready.js +7 -1
  259. package/dist/lib/work-environment-sync.js +8 -1
  260. package/dist/lib/work-local-run-tests.js +2 -1
  261. package/dist/lib/work-promote-deploy.js +3 -1
  262. package/dist/lib/work-promote.js +2 -1
  263. package/dist/lib/work-types.js +3 -1
  264. package/oclif.manifest.json +3544 -1828
  265. package/package.json +11 -4
  266. package/templates/skills/agentia-ai/SKILL.md +6 -2
  267. package/templates/skills/agentia-ai/references/ai-agents.md +19 -1
  268. package/templates/skills/agentia-cicd/SKILL.md +6 -5
  269. package/templates/skills/agentia-cicd/references/environments-and-credentials.md +16 -0
  270. package/templates/skills/agentia-cicd/references/jobs.md +3 -2
  271. package/templates/skills/agentia-cicd/references/promotions.md +26 -5
  272. package/templates/skills/agentia-cicd/references/work.md +25 -11
  273. package/templates/skills/agentia-metadata/SKILL.md +9 -3
  274. package/templates/skills/agentia-metadata/references/metadata-dependency.md +70 -0
  275. package/templates/skills/agentia-metadata/references/metadata-explore.md +8 -4
  276. package/templates/skills/agentia-testing/SKILL.md +9 -4
  277. package/templates/skills/agentia-testing/references/browser-testing.md +92 -0
  278. package/templates/skills/agentia-testing/references/flow-automation.md +112 -0
  279. package/templates/skills/agentia-testing/references/qforce.md +88 -0
  280. package/templates/skills/agentia-testing/references/qweb.md +103 -0
  281. package/templates/skills/agentia-testing/references/tests.md +17 -9
  282. package/vendor/java/var-replace-command.jar +0 -0
  283. package/dist/commands/testing/live/continue.js +0 -16
  284. package/dist/commands/testing/live/execute.js +0 -43
  285. package/dist/commands/testing/live/history.js +0 -40
  286. package/dist/commands/testing/live/inspect.js +0 -31
  287. package/dist/commands/testing/live/interrupt.js +0 -16
  288. package/dist/commands/testing/live/recorder.js +0 -42
  289. package/dist/commands/testing/live/reports.js +0 -31
  290. package/dist/commands/testing/live/screenshot.js +0 -25
  291. package/dist/commands/testing/live/set-options.js +0 -35
  292. package/dist/commands/testing/live/start.js +0 -58
  293. package/dist/commands/testing/live/status.js +0 -24
  294. package/dist/commands/testing/live/stop.js +0 -36
  295. package/dist/commands/testing/live/view.js +0 -36
  296. package/dist/lib/mcp/testing-live-tools.js +0 -226
  297. package/dist/lib/testing-live-command.js +0 -8
  298. package/dist/lib/testing-live-operations.js +0 -25
  299. package/dist/lib/testing-live-recorder.js +0 -11
  300. package/dist/lib/testing-live-robot.js +0 -9
  301. package/dist/lib/testing-live-state.js +0 -12
  302. package/dist/lib/testing-live-types.js +0 -3
@@ -2,9 +2,9 @@
2
2
  import { z } from 'zod';
3
3
  import { buildMetadataCompareFileRequests } from '../../commands/cicd/metadata/content/compare.js';
4
4
  import { buildMetadataContentRequest } from '../../commands/cicd/metadata/content/get.js';
5
+ import { buildDependencyRequest, enrichDependencyResult, } from '../../commands/cicd/metadata/dependency/list.js';
5
6
  import { buildMetadataCompareRequest } from '../../commands/cicd/metadata/index/compare.js';
6
7
  import { buildMetadataIndexRequest } from '../../commands/cicd/metadata/list.js';
7
- import { AI_METADATA_ACTIONS, buildAiMetadataToolRequest, callAiMetadataTool, } from '../metadata-explore.js';
8
8
  import { assertRequired } from '../assert.js';
9
9
  import { applyAuthSet, getAiAuthStatus, getCicdAuthStatus, getCrtAuthStatus } from '../auth-config.js';
10
10
  import { CicdGateway } from '../cicd-gateway.js';
@@ -17,12 +17,14 @@ import { createEnvironmentCredential, listCredentials, resolveEnvironmentOrgType
17
17
  import { buildCreatePayload, buildMutationPayload, ENVIRONMENT_STRING_VALIDATION_KEYS, validateNonEmptyStringFields, } from '../environment-flags.js';
18
18
  import { fetchEnvironment, fetchEnvironments } from '../environment-get.js';
19
19
  import { DEFAULT_ENVIRONMENT_PLATFORM, DEFAULT_ENVIRONMENT_TYPE, ENVIRONMENT_TYPES, environmentEndpoint, } from '../environment-types.js';
20
+ import { fetchFunctions } from '../function-list.js';
20
21
  import { executeLocalFunctionRun } from '../function-local-run.js';
21
- import { FUNCTION_LIST_TYPES, FUNCTION_RUNTIMES, functionEndpoint, functionResultEndpoint, functionResultLogEndpoint, functionRunEndpoint, functionsEndpoint, normalizeFunction, normalizeFunctionResultStatus, normalizeFunctionRunResult, normalizeFunctionsListPage, normalizeFunctionUpsertPayload, } from '../function-types.js';
22
- import { fetchJob, fetchJobs } from '../job-get.js';
22
+ import { FUNCTION_LIST_TYPES, FUNCTION_RUNTIMES, functionEndpoint, functionResultEndpoint, functionResultLogEndpoint, functionRunEndpoint, functionsEndpoint, normalizeFunction, normalizeFunctionResultStatus, normalizeFunctionRunResult, normalizeFunctionUpsertPayload, } from '../function-types.js';
23
+ import { fetchJob, fetchJobs, resolveJobResultFileId } from '../job-get.js';
23
24
  import { jobEndpoint, jobKillEndpoint, jobPauseEndpoint, jobResultFileContentEndpoint, jobResultFilesEndpoint, jobResultLogEndpoint, jobResumeEndpoint, jobRunEndpoint, normalizeJob, normalizeJobOperation, normalizeJobResultFileContent, normalizeJobResultFiles, resolveJobStepForLog, } from '../job-types.js';
24
25
  import { listPaginationZodFields, mcpPaginatedListPayload } from '../list-pagination.js';
25
26
  import { COMPARISON_MODES, CONTENT_SOURCES, contentResultToCompareSide, createUnifiedDiff, INDEX_SOURCES, MODULE_TYPES, ORDER_DIRECTIONS, PLATFORM_EXPERIENCES, RETRIEVE_MODES, sourceSideLabel, } from '../metadata-common.js';
27
+ import { AI_METADATA_ACTIONS, buildAiMetadataToolRequest, callAiMetadataTool, } from '../metadata-explore.js';
26
28
  import { buildRefreshDeletedRequest, buildRefreshIndexRequest, refreshStatusEndpoint, resolveRefreshSourceFromEnv, } from '../metadata-refresh.js';
27
29
  import { NAVIGATION_RESOURCE_TYPES, resolveNavigationTarget } from '../navigation.js';
28
30
  import { configureNotification, NOTIFICATION_DESTINATION_TYPES, NOTIFICATION_EVENTS, NOTIFICATION_SUBSCRIPTIONS, withNotificationConfigureErrorTranslation, } from '../notifications-configure.js';
@@ -41,14 +43,18 @@ import { normalizeProject, projectEndpoint, projectsListEndpoint, } from '../pro
41
43
  import { buildPromotionConflictResolutionRequest, normalizePromotionConflicts, PROMOTION_CONFLICT_MODES, promotionConflictContentEndpoint, promotionConflictResolveEndpoint, promotionConflictsEndpoint, promotionConflictUndoEndpoint, withPromotionConflictErrorTranslation, } from '../promotion-conflicts.js';
42
44
  import { fetchPromotion, fetchPromotions } from '../promotion-get.js';
43
45
  import { buildPromotionManualTaskUpdatePayload, PROMOTION_MANUAL_TASK_STATUSES, promotionManualTaskEndpoint, } from '../promotion-job-steps.js';
46
+ import { fetchPromotionQueue, removePromotionQueueItems } from '../promotion-queue.js';
44
47
  import { performPromotionResume, performPromotionRun, PROMOTION_OPERATIONS, PROMOTION_RUN_DEFAULT_TIMEOUT_SECONDS, } from '../promotion-run.js';
48
+ import { fetchPromotionStatus } from '../promotion-status.js';
45
49
  import { REPOSITORY_STRING_VALIDATION_KEYS, validateNonEmptyStringFields as validateRepositoryNonEmptyStringFields, } from '../repository-flags.js';
46
- import { normalizeRepositoriesListPage, normalizeRepository, normalizeRepositoryValidateResult, repositoriesEndpoint, REPOSITORY_PROVIDERS, REPOSITORY_SOURCE_FORMATS, repositoryEndpoint, repositoryHttpsAuthEndpoint, repositoryResetEndpoint, repositorySshAuthEndpoint, repositoryValidateEndpoint, } from '../repository-types.js';
50
+ import { fetchRepositories } from '../repository-list.js';
51
+ import { normalizeRepository, normalizeRepositoryValidateResult, repositoriesEndpoint, REPOSITORY_PROVIDERS, REPOSITORY_SOURCE_FORMATS, repositoryEndpoint, repositoryHttpsAuthEndpoint, repositoryResetEndpoint, repositorySshAuthEndpoint, repositoryValidateEndpoint, } from '../repository-types.js';
47
52
  import { buildStageMutationPayload, validateStagePayload } from '../stage-flags.js';
48
53
  import { fetchStages } from '../stage-list.js';
49
54
  import { normalizePipelineStageConnection, normalizeStage, pipelineStageConnectionEndpoint, pipelineStageConnectionsEndpoint, STAGE_META_STAGE_SUGGESTIONS, stageEndpoint, stagesEndpoint, } from '../stage-types.js';
50
55
  import { buildTemplateDefaultsQuery } from '../template-flags.js';
51
- import { normalizeTemplate, normalizeTemplatesListPage, normalizeTemplateUpsertPayload, TEMPLATE_LIST_TYPES, templateDefaultsEndpoint, templateEndpoint, templatesEndpoint, } from '../template-types.js';
56
+ import { fetchTemplates } from '../template-list.js';
57
+ import { normalizeTemplate, normalizeTemplateUpsertPayload, TEMPLATE_LIST_TYPES, templateDefaultsEndpoint, templateEndpoint, } from '../template-types.js';
52
58
  import { getUserContext } from '../user-context.js';
53
59
  import { fetchUser } from '../user-get.js';
54
60
  import { DEFAULT_USER_ID } from '../user-types.js';
@@ -81,6 +87,9 @@ async function promotionList(args = {}) {
81
87
  async function promotionGet(args) {
82
88
  return { promotion: await fetchPromotion(assertRequired(args.id, 'id')) };
83
89
  }
90
+ async function promotionStatus(args) {
91
+ return { status: await fetchPromotionStatus(assertRequired(args.id, 'id')) };
92
+ }
84
93
  async function promotionRun(args) {
85
94
  const waitTimeout = args.waitTimeout ?? PROMOTION_RUN_DEFAULT_TIMEOUT_SECONDS;
86
95
  if (!Number.isInteger(waitTimeout) || waitTimeout <= 0) {
@@ -287,6 +296,12 @@ async function jobPause(args) {
287
296
  });
288
297
  return { result: normalizeJobOperation(result) };
289
298
  }
299
+ async function promotionQueueList(args) {
300
+ return { queue: await fetchPromotionQueue(assertRequired(args.promotion, 'promotion')) };
301
+ }
302
+ async function promotionQueueRemove(args) {
303
+ return { queue: await removePromotionQueueItems(assertRequired(args.promotion, 'promotion'), args.itemIds) };
304
+ }
290
305
  async function pipelineList(args = {}) {
291
306
  return mcpPaginatedListPayload('pipelines', await fetchPipelines(args));
292
307
  }
@@ -504,11 +519,7 @@ async function projectList(args = {}) {
504
519
  return mcpPaginatedListPayload('projects', await fetchProjects(args));
505
520
  }
506
521
  async function repositoryList(args = {}) {
507
- const response = await CicdGateway.call({
508
- endpoint: repositoriesEndpoint(args),
509
- method: 'GET',
510
- });
511
- return mcpPaginatedListPayload('repositories', normalizeRepositoriesListPage(response));
522
+ return mcpPaginatedListPayload('repositories', await fetchRepositories(args));
512
523
  }
513
524
  async function repositoryGet(args) {
514
525
  const response = await CicdGateway.call({
@@ -597,11 +608,7 @@ async function repositoryValidate(args) {
597
608
  return { validation: normalizeRepositoryValidateResult(response) };
598
609
  }
599
610
  async function functionList(args = {}) {
600
- const response = await CicdGateway.call({
601
- endpoint: functionsEndpoint({ ...args, type: args.type ?? 'custom' }),
602
- method: 'GET',
603
- });
604
- return mcpPaginatedListPayload('functions', normalizeFunctionsListPage(response));
611
+ return mcpPaginatedListPayload('functions', await fetchFunctions({ ...args, type: args.type ?? 'custom' }));
605
612
  }
606
613
  async function functionGet(args) {
607
614
  const response = await CicdGateway.call({
@@ -647,11 +654,7 @@ async function functionDelete(args) {
647
654
  return { apiName };
648
655
  }
649
656
  async function templateList(args = {}) {
650
- const response = await CicdGateway.call({
651
- endpoint: templatesEndpoint({ ...args, type: args.type ?? 'custom' }),
652
- method: 'GET',
653
- });
654
- return mcpPaginatedListPayload('templates', normalizeTemplatesListPage(response));
657
+ return mcpPaginatedListPayload('templates', await fetchTemplates({ ...args, type: args.type ?? 'custom' }));
655
658
  }
656
659
  async function templateGet(args) {
657
660
  const response = await CicdGateway.call({
@@ -999,44 +1002,47 @@ async function metadataExplore(args) {
999
1002
  output,
1000
1003
  };
1001
1004
  }
1002
- async function metadataDependencyList(args) {
1003
- const selection = {
1004
- name: assertRequired(args.metadataName, 'metadataName'),
1005
- type: assertRequired(args.metadataType, 'metadataType'),
1006
- };
1007
- if (args.metadataCategory) {
1008
- selection.category = args.metadataCategory;
1009
- }
1010
- const body = {
1011
- compareOptions: {
1012
- sourceCredentialId: assertRequired(args.sourceCredentialId, 'sourceCredentialId'),
1013
- sourceOrgId: assertRequired(args.sourceOrgId, 'sourceOrgId'),
1014
- },
1015
- metadataSelections: [selection],
1016
- pipelineId: assertRequired(args.pipelineId, 'pipelineId'),
1017
- };
1018
- if (args.targetOrgId) {
1019
- body.compareOptions.targetOrgId = args.targetOrgId;
1020
- }
1021
- if (args.retrieveMode) {
1022
- body.compareOptions.retrieveMode = args.retrieveMode;
1023
- }
1024
- if (args.moduleType) {
1025
- body.moduleType = args.moduleType;
1005
+ function normalizeDependencyPathArg(path) {
1006
+ if (path === undefined) {
1007
+ return undefined;
1026
1008
  }
1027
- if (args.resultId) {
1028
- body.resultId = args.resultId;
1009
+ const paths = (Array.isArray(path) ? path : [path]).map((entry) => entry.trim()).filter(Boolean);
1010
+ return paths.length > 0 ? paths : undefined;
1011
+ }
1012
+ async function metadataDependencyList(args) {
1013
+ const paths = normalizeDependencyPathArg(args.path);
1014
+ if (paths && (args.metadataName || args.metadataType)) {
1015
+ throw new Error('Use either path or metadataName/metadataType, not both.');
1029
1016
  }
1030
- const platformExperience = args.platformExperience ?? 'salesforce';
1031
- const result = await CicdGateway.call({
1017
+ const { body, localPathsBySelection, platformExperience } = await buildDependencyRequest({
1018
+ 'base-ref': 'origin/main',
1019
+ 'from-changes': false,
1020
+ 'metadata-category': args.metadataCategory,
1021
+ 'metadata-name': args.metadataName,
1022
+ 'metadata-type': args.metadataType,
1023
+ 'module-type': args.moduleType,
1024
+ path: paths,
1025
+ 'pipeline-id': args.pipelineId,
1026
+ 'platform-experience': args.platformExperience,
1027
+ 'result-id': args.resultId,
1028
+ 'retrieve-mode': args.retrieveMode,
1029
+ 'source-credential-id': args.sourceCredentialId,
1030
+ 'source-org-id': args.sourceOrgId,
1031
+ stdin: false,
1032
+ 'target-org-id': args.targetOrgId,
1033
+ });
1034
+ const gatewayResult = await CicdGateway.call({
1032
1035
  body,
1033
1036
  endpoint: '/release/metadata/dependencies',
1034
1037
  headers: {
1035
1038
  'Content-Type': 'application/json',
1036
- 'platform-experience': platformExperience,
1039
+ ...(platformExperience === undefined ? {} : { 'platform-experience': platformExperience }),
1037
1040
  },
1038
1041
  method: 'POST',
1039
1042
  });
1043
+ const result = localPathsBySelection
1044
+ ? await enrichDependencyResult(gatewayResult, localPathsBySelection, args.moduleType)
1045
+ : gatewayResult;
1040
1046
  return { result };
1041
1047
  }
1042
1048
  function authCredentialResult(type) {
@@ -1108,8 +1114,9 @@ async function jobResultFileList(args) {
1108
1114
  }
1109
1115
  async function jobResultFileGet(args) {
1110
1116
  const resultId = assertRequired(args.resultId, 'resultId');
1117
+ const fileId = await resolveJobResultFileId(resultId, assertRequired(args.fileId, 'fileId'));
1111
1118
  const response = await CicdGateway.call({
1112
- endpoint: jobResultFileContentEndpoint(resultId, assertRequired(args.fileId, 'fileId')),
1119
+ endpoint: jobResultFileContentEndpoint(resultId, fileId),
1113
1120
  method: 'GET',
1114
1121
  });
1115
1122
  return { file: { ...normalizeJobResultFileContent(response), resultId } };
@@ -1353,6 +1360,8 @@ export const agentiaMcpToolHandlers = wrapMcpToolHandlers({
1353
1360
  promotionGet,
1354
1361
  promotionJobStepUpdate,
1355
1362
  promotionList,
1363
+ promotionQueueList,
1364
+ promotionQueueRemove,
1356
1365
  promotionRun,
1357
1366
  repositoryCreate,
1358
1367
  repositoryDelete,
@@ -1546,6 +1555,13 @@ export function registerAgentiaMcpTools(server) {
1546
1555
  },
1547
1556
  title: 'Agentia Promotion Get',
1548
1557
  }, (args) => safelyHandleTool(() => promotionGet(args)));
1558
+ server.registerTool('agentia_promotion_status', {
1559
+ description: 'Get actionable Copado promotion status: user stories, current job step, queue summary, and Manual Task or queue action-needed. Prefer this when the user asks whether a promotion is blocked or what is running.',
1560
+ inputSchema: {
1561
+ id: z.string().describe('Copado promotion Id.'),
1562
+ },
1563
+ title: 'Agentia Promotion Status',
1564
+ }, (args) => safelyHandleTool(() => promotionStatus(args)));
1549
1565
  server.registerTool('agentia_promotion_run', {
1550
1566
  description: 'Preflight, start, and optionally wait for a Copado promotion. Can also resume an existing execution without starting a duplicate run.',
1551
1567
  inputSchema: {
@@ -1643,6 +1659,19 @@ export function registerAgentiaMcpTools(server) {
1643
1659
  },
1644
1660
  title: 'Agentia Job Pause',
1645
1661
  }, (args) => safelyHandleTool(() => jobPause(args)));
1662
+ server.registerTool('agentia_promotion_queue_list', {
1663
+ description: 'List the promotion queue for a Copado promotion via the CICD gateway.',
1664
+ inputSchema: { promotion: z.string().describe('Copado promotion ID or name.') },
1665
+ title: 'Agentia Promotion Queue List',
1666
+ }, (args) => safelyHandleTool(() => promotionQueueList(args)));
1667
+ server.registerTool('agentia_promotion_queue_remove', {
1668
+ description: 'Remove items from a Copado promotion promotion queue via the CICD gateway (requires the Manage Queue permission).',
1669
+ inputSchema: {
1670
+ itemIds: z.array(z.string()).min(1).describe('Queue item IDs to remove (from agentia_promotion_queue_list).'),
1671
+ promotion: z.string().describe('Copado promotion ID or name.'),
1672
+ },
1673
+ title: 'Agentia Promotion Queue Remove',
1674
+ }, (args) => safelyHandleTool(() => promotionQueueRemove(args)));
1646
1675
  server.registerTool('agentia_pipeline_list', {
1647
1676
  description: 'List Copado pipelines via the CICD gateway.',
1648
1677
  inputSchema: {
@@ -1956,19 +1985,44 @@ export function registerAgentiaMcpTools(server) {
1956
1985
  title: 'Agentia Metadata Content Compare',
1957
1986
  }, (args) => safelyHandleTool(() => metadataContentCompare(args)));
1958
1987
  server.registerTool('agentia_metadata_dependency_list', {
1959
- description: 'Retrieve metadata dependencies.',
1988
+ description: 'Retrieve metadata dependencies. Provide either path (one or more local Salesforce source files) or both metadataName and metadataType. pipelineId, sourceCredentialId, sourceOrgId, and platformExperience default from the active work item or project defaults when omitted; targetOrgId is never inferred.',
1960
1989
  inputSchema: {
1961
1990
  metadataCategory: z.string().optional().describe('Optional metadata category.'),
1962
- metadataName: z.string().describe('Metadata API name.'),
1963
- metadataType: z.string().describe('Metadata type, for example ApexClass.'),
1991
+ metadataName: z
1992
+ .string()
1993
+ .optional()
1994
+ .describe('Metadata API name. Required with metadataType when path is omitted.'),
1995
+ metadataType: z
1996
+ .string()
1997
+ .optional()
1998
+ .describe('Metadata type, for example ApexClass. Required with metadataName when path is omitted.'),
1964
1999
  moduleType: z.enum(MODULE_TYPES).optional().describe('Optional addon module type.'),
1965
- pipelineId: z.string().describe('Pipeline Id.'),
1966
- platformExperience: z.enum(PLATFORM_EXPERIENCES).optional().describe('Platform experience header.'),
2000
+ path: z
2001
+ .union([z.string(), z.array(z.string())])
2002
+ .optional()
2003
+ .describe('Local Salesforce source file path(s) resolved into metadata selections. Mutually exclusive with metadataName/metadataType.'),
2004
+ pipelineId: z
2005
+ .string()
2006
+ .optional()
2007
+ .describe('Pipeline Id. Defaults to the active work item pipelineId or the project default pipeline.'),
2008
+ platformExperience: z
2009
+ .enum(PLATFORM_EXPERIENCES)
2010
+ .optional()
2011
+ .describe('Platform experience header. Defaults to the active work item platform, then sfdx.'),
1967
2012
  resultId: z.string().optional().describe('Optional result Id from a prior metadata operation.'),
1968
2013
  retrieveMode: z.enum(RETRIEVE_MODES).optional().describe('Dependency retrieve mode.'),
1969
- sourceCredentialId: z.string().describe('Source org credential Id.'),
1970
- sourceOrgId: z.string().describe('Source org Id.'),
1971
- targetOrgId: z.string().optional().describe('Optional target org Id.'),
2014
+ sourceCredentialId: z
2015
+ .string()
2016
+ .optional()
2017
+ .describe('Source org credential Id. Defaults to the active work item source credential or the project default credential.'),
2018
+ sourceOrgId: z
2019
+ .string()
2020
+ .optional()
2021
+ .describe('Source org Id. Defaults to the active work item sourceOrgId or orgId from the resolved credential/environment.'),
2022
+ targetOrgId: z
2023
+ .string()
2024
+ .optional()
2025
+ .describe('Optional target org Id. Not inferred from work item or project defaults.'),
1972
2026
  },
1973
2027
  title: 'Agentia Metadata Dependency List',
1974
2028
  }, (args) => safelyHandleTool(() => metadataDependencyList(args)));
@@ -2028,7 +2082,9 @@ export function registerAgentiaMcpTools(server) {
2028
2082
  server.registerTool('agentia_job_result_file_get', {
2029
2083
  description: 'Get a File linked to a Copado job Result.',
2030
2084
  inputSchema: {
2031
- fileId: z.string().describe('File ID returned by result-file list.'),
2085
+ fileId: z
2086
+ .string()
2087
+ .describe('fileId returned by result-file list (068...); contentDocumentId (069...) is resolved automatically'),
2032
2088
  resultId: z.string().describe('Copado Result ID.'),
2033
2089
  },
2034
2090
  title: 'Agentia Job Result File Get',
@@ -9,20 +9,22 @@ import { listPaginationZodFields, mcpPaginatedListPayload } from '../list-pagina
9
9
  import { LocalQualityGatesError, parseQualityGatesEnvAssignments, runLocalQualityGates, } from '../local-quality-gates.js';
10
10
  import { FULL_METADATA_SELECTION_TYPES_HELP } from '../nested-metadata-registry.js';
11
11
  import { PROJECT_DEFAULT_KEYS } from '../project-defaults.js';
12
- import { performPromotionRun, PROMOTION_RUN_DEFAULT_TIMEOUT_SECONDS, resolvePromotionIdForWorkItem, } from '../promotion-run.js';
13
- import { runWorkTestLocalQualityGates } from '../stock-quality-gates.js';
12
+ import { performPromotionRun, PROMOTION_RUN_DEFAULT_TIMEOUT_SECONDS, PromotionRunValidationError, resolveOrCreatePromotionForWorkItem, } from '../promotion-run.js';
13
+ import { isApexOnlySelection, resolveQualityGateSelection } from '../quality-gates.js';
14
+ import { listLocalQualityGates, runWorkTestLocalQualityGates } from '../stock-quality-gates.js';
14
15
  import { getUserContext } from '../user-context.js';
15
16
  import { resolveWorkItemId } from '../work-active.js';
16
- import { planWorkApexTestRun, recordWorkApexTestOutcome } from '../work-apex-test-failures.js';
17
- import { DEFAULT_APEX_TEST_WAIT_MINUTES, parseApexTestClassNames, runWorkApexTests, skippedWorkApexTestResult, validateApexTestWaitMinutes, WorkApexTestError, } from '../work-apex-test.js';
17
+ import { executeWorkApexTestRun } from '../work-apex-test-failures.js';
18
+ import { DEFAULT_APEX_TEST_WAIT_MINUTES, parseApexTestClassNames, validateApexTestWaitMinutes, WorkApexTestError, } from '../work-apex-test.js';
18
19
  import { buildWorkCommitRequest, normalizeWorkCommitInput, performWorkCommit, resolveWorkCommitPlatformExperience, WORK_COMMIT_ACTIONS, WORK_COMMIT_CHANGES_HELP, WORK_COMMIT_DEFAULT_TIMEOUT_SECONDS, WORK_COMMIT_METADATA_CATEGORY_HELP, } from '../work-commit.js';
19
20
  import { buildWorkCreatePayload } from '../work-defaults.js';
20
21
  import { normalizeWorkCustomFields, validateWorkMutationPayload, WORK_LONG_TEXT_MAX_LENGTH, WORK_SHORT_TEXT_MAX_LENGTH, } from '../work-flags.js';
21
22
  import { fetchWorkItems, fetchWorkItemWithOptions } from '../work-get.js';
22
23
  import { performWorkLocalCommit } from '../work-local-commit.js';
23
- import { reportLocalQualityGatesFailure, reportLocalQualityGatesOutcome, } from '../work-local-run-tests.js';
24
+ import { reportApexGateRun, reportLocalQualityGatesFailure, reportLocalQualityGatesOutcome, } from '../work-local-run-tests.js';
24
25
  import { capturingWorkPushHooks, performWorkPush, resolveActiveFeatureWorkItem, resolveWorkPushContext, resolveWorkPushNeed, uploadCapturedPublishLogsBestEffort, } from '../work-push.js';
25
26
  import { performWorkSetNone } from '../work-set-none.js';
27
+ import { WorkPromoteValidationError } from '../work-promote.js';
26
28
  import { isWorkSetWarning, parseWorkSetSelection, toWorkSetWarningResult, writeWorkSetWarningSelection, } from '../work-set-selection.js';
27
29
  import { reportSubmitUserStoriesAheadBehind } from '../work-submit-ahead-behind.js';
28
30
  import { waitForPendingCommitJobIfNeeded } from '../work-submit-wait.js';
@@ -403,11 +405,35 @@ async function workTest(args = {}) {
403
405
  throw new Error('Cloud quality gates are not implemented yet. Pass local: true or omit cloud to run project-root quality gates.');
404
406
  }
405
407
  parseQualityGatesEnvAssignments(args.env);
408
+ const selection = resolveQualityGateSelection({ all: args.all, gates: args.gates });
409
+ if (args.listGates === true) {
410
+ const catalog = await listLocalQualityGates();
411
+ return { gates: catalog.gates, local: true, qualityGates: { ran: false, skipped: false } };
412
+ }
413
+ if (isApexOnlySelection(selection)) {
414
+ let apex;
415
+ try {
416
+ apex = await workTestApex({
417
+ apexTestClasses: args.apexTestClasses,
418
+ rerunFailedApexTests: args.rerunFailedApexTests,
419
+ wait: args.wait,
420
+ });
421
+ }
422
+ catch (error) {
423
+ if (error instanceof WorkApexTestError) {
424
+ await reportApexGateRunBestEffort(error.result, true);
425
+ }
426
+ throw error;
427
+ }
428
+ await reportApexGateRunBestEffort(apex, false);
429
+ return { apex, local: true, qualityGates: { ran: apex.skipped !== true, skipped: false } };
430
+ }
406
431
  let qualityGates;
407
432
  try {
408
433
  qualityGates = await runWorkTestLocalQualityGates({
409
434
  apexTestClasses: args.apexTestClasses,
410
435
  env: args.env,
436
+ gates: selection.gates,
411
437
  onOutput() {
412
438
  // Capture output for the tool result/error; do not stream to the MCP stdio transport.
413
439
  },
@@ -442,28 +468,22 @@ async function workTest(args = {}) {
442
468
  qualityGates,
443
469
  };
444
470
  }
445
- async function workTestApex(args) {
446
- const classNames = parseApexTestClassNames(args.apexTestClasses);
447
- const waitMinutes = validateApexTestWaitMinutes(args.wait ?? DEFAULT_APEX_TEST_WAIT_MINUTES);
448
- const plan = await planWorkApexTestRun({
449
- requestedClassNames: classNames,
450
- rerunFailed: args.rerunFailedApexTests === true,
451
- });
452
- if (plan.kind === 'skip') {
453
- return skippedWorkApexTestResult(waitMinutes);
454
- }
471
+ async function reportApexGateRunBestEffort(result, failed) {
455
472
  try {
456
- const result = await runWorkApexTests({ classNames: plan.classNames, waitMinutes });
457
- await recordWorkApexTestOutcome({ failed: false, result, userStory: plan.userStory });
458
- return result;
473
+ const { workItem } = await requireFeatureBranchWorkItem();
474
+ await reportApexGateRun({ failed, result, workItem });
459
475
  }
460
- catch (error) {
461
- if (error instanceof WorkApexTestError) {
462
- await recordWorkApexTestOutcome({ failed: true, result: error.result, userStory: plan.userStory });
463
- }
464
- throw error;
476
+ catch {
477
+ // Best-effort reporting; never mask the Apex outcome.
465
478
  }
466
479
  }
480
+ async function workTestApex(args) {
481
+ return executeWorkApexTestRun({
482
+ requestedClassNames: parseApexTestClassNames(args.apexTestClasses),
483
+ rerunFailed: args.rerunFailedApexTests === true,
484
+ waitMinutes: validateApexTestWaitMinutes(args.wait ?? DEFAULT_APEX_TEST_WAIT_MINUTES),
485
+ });
486
+ }
467
487
  function hasMcpSimpleCommitArgs(args) {
468
488
  return (args.action !== undefined ||
469
489
  args.metadataCategory !== undefined ||
@@ -579,21 +599,37 @@ async function cloudPromote(args = {}) {
579
599
  throw new Error('waitTimeout must be a positive integer.');
580
600
  }
581
601
  const workItemId = await resolveWorkItemId(args.id);
582
- const promotionId = await resolvePromotionIdForWorkItem(workItemId, args.promotionId);
583
- const result = await performPromotionRun({
584
- deploymentStepIds: args.deploymentStepIds,
585
- hooks: {
586
- log() { },
587
- withSpinner: async (_message, action) => action(),
588
- },
589
- ignoredMetadata: args.ignoredMetadata,
590
- operation: args.deploy === true ? 'merge_and_deploy' : 'merge',
591
- promotionId,
592
- recreatePromotionBranch: args.recreatePromotionBranch,
593
- timeoutSeconds: waitTimeout,
594
- wait: args.wait ?? true,
595
- });
596
- return { ...result, workItemId };
602
+ let createdPromotion;
603
+ try {
604
+ const resolved = await resolveOrCreatePromotionForWorkItem(workItemId, args.promotionId);
605
+ createdPromotion = resolved.createdPromotion;
606
+ const promotionId = resolved.promotionId;
607
+ const result = await performPromotionRun({
608
+ deploymentStepIds: args.deploymentStepIds,
609
+ hooks: {
610
+ log() { },
611
+ withSpinner: async (_message, action) => action(),
612
+ },
613
+ ignoredMetadata: args.ignoredMetadata,
614
+ operation: args.deploy === true ? 'merge_and_deploy' : 'merge',
615
+ promotionId,
616
+ recreatePromotionBranch: args.recreatePromotionBranch,
617
+ timeoutSeconds: waitTimeout,
618
+ wait: args.wait ?? true,
619
+ });
620
+ return {
621
+ ...result,
622
+ ...(createdPromotion === undefined ? {} : { createdPromotion }),
623
+ workItemId,
624
+ };
625
+ }
626
+ catch (error) {
627
+ // Map validation errors to plain Error messages for MCP clients.
628
+ if (error instanceof PromotionRunValidationError || error instanceof WorkPromoteValidationError) {
629
+ throw new Error(error.message);
630
+ }
631
+ throw error;
632
+ }
597
633
  }
598
634
  /** Compatibility alias of agentia_work_submit with done=true. Prefer agentia_work_submit({ done: true }). */
599
635
  async function workDone(args = {}) {
@@ -646,7 +682,7 @@ const workMutationSchema = {
646
682
  plannedPoints: z.number().int().optional().describe('Planned points.'),
647
683
  priority: z.number().int().optional().describe('Priority.'),
648
684
  project: z.string().optional().describe('Project ID.'),
649
- recordType: z.string().optional().describe('Record type.'),
685
+ recordType: z.string().optional().describe('Record type DeveloperName.'),
650
686
  releaseId: z.string().optional().describe('Release ID.'),
651
687
  soThat: z.string().max(WORK_SHORT_TEXT_MAX_LENGTH).optional().describe('User story "so that" clause (maximum 255 characters).'),
652
688
  sourceCredential: z.string().optional().describe('Source credential ID. When set, sourceEnvironment is sent as null so Salesforce assigns the environment from the credential.'),
@@ -686,7 +722,7 @@ export function registerAgentiaMcpWorkTools(server) {
686
722
  .boolean()
687
723
  .optional()
688
724
  .describe('When true, also include the Story committed metadata list as committedMetadata in the result.'),
689
- id: z.string().optional().describe('User story Id. Defaults to the active work item from work set.'),
725
+ id: z.string().optional().describe('User story Id or name. Defaults to the active work item from work set.'),
690
726
  },
691
727
  title: 'Agentia Work Get',
692
728
  }, (args) => safelyHandleTool(() => workGet(args || {})));
@@ -699,14 +735,14 @@ export function registerAgentiaMcpWorkTools(server) {
699
735
  description: 'Update a Copado user story by Id via the CICD gateway. Omit Id to use the active work item from work set.',
700
736
  inputSchema: {
701
737
  ...workMutationSchema,
702
- id: z.string().optional().describe('User story Id. Defaults to the active work item from work set.'),
738
+ id: z.string().optional().describe('User story Id or name. Defaults to the active work item from work set.'),
703
739
  },
704
740
  title: 'Agentia Work Update',
705
741
  }, (args) => safelyHandleTool(() => workUpdate(args)));
706
742
  server.registerTool('agentia_work_delete', {
707
743
  description: 'Delete a Copado user story by Id via the CICD gateway.',
708
744
  inputSchema: {
709
- id: z.string().describe('User story Id.'),
745
+ id: z.string().describe('User story Id or name.'),
710
746
  },
711
747
  title: 'Agentia Work Delete',
712
748
  }, (args) => safelyHandleTool(() => workDelete(args)));
@@ -799,7 +835,7 @@ export function registerAgentiaMcpWorkTools(server) {
799
835
  promotionId: z
800
836
  .string()
801
837
  .optional()
802
- .describe('Explicit 18-character Promotion ID when the User Story belongs to multiple promotions.'),
838
+ .describe('Explicit 18-character Promotion ID when the User Story belongs to multiple promotions. Used as is; never creates a promotion.'),
803
839
  recreatePromotionBranch: z.boolean().optional().describe('Recreate the promotion branch before execution.'),
804
840
  wait: z.boolean().optional().describe('Poll all created executions to terminal status. Defaults to true.'),
805
841
  waitTimeout: z
@@ -825,7 +861,7 @@ export function registerAgentiaMcpWorkTools(server) {
825
861
  title: 'Agentia Work Commit',
826
862
  }, (args) => safelyHandleTool(() => workCommit(args || {})));
827
863
  server.registerTool('agentia_cloud_promote', {
828
- description: 'Resolve a Promotion from an explicit or active User Story, then preflight, start, and optionally wait for the cloud promotion.',
864
+ description: 'Resolve a Promotion from an explicit or active User Story, then preflight, start, and optionally wait for the cloud promotion. When no promotion contains the story, creates a forward Draft promotion, adds the story, then runs. Returns createdPromotion when a promotion was created. promotionId is used as is and never creates a promotion.',
829
865
  inputSchema: cloudPromoteInputSchema,
830
866
  title: 'Agentia Cloud Promote',
831
867
  }, (args) => safelyHandleTool(() => cloudPromote(args || {})));
@@ -853,8 +889,12 @@ export function registerAgentiaMcpWorkTools(server) {
853
889
  title: 'Agentia Work Submit',
854
890
  }, (args) => safelyHandleTool(() => workSubmit(args || {})));
855
891
  server.registerTool('agentia_work_test', {
856
- description: 'Run quality gates for the current work item. With local=true (the default when cloud is omitted), runs project-root .agentia_quality_gates.sh (macOS/Linux) or .agentia_quality_gates.cmd (Windows) when present. When no project script exists, warns and runs the stock Agentia setup sample from a temporary file. With cloud=true, runs remote Copado quality gates (not implemented yet). Optional env is an array of NAME=value strings injected into the quality-gate script environment (same as CLI -e/--env).',
892
+ description: 'Run quality gates for the current work item. With local=true (the default when cloud is omitted), runs project-root .agentia_quality_gates.sh (macOS/Linux) or .agentia_quality_gates.cmd (Windows) when present. When no project script exists, warns and runs the stock Agentia setup sample from a temporary file. With cloud=true, runs remote Copado quality gates (not implemented yet). By default every gate runs; pass gates to run a subset (scripts declare gates with `# agentia-gate: <id> - <description>`) or listGates to list them. Optional env is an array of NAME=value strings injected into the quality-gate script environment (same as CLI -e/--env).',
857
893
  inputSchema: {
894
+ all: z
895
+ .boolean()
896
+ .optional()
897
+ .describe('Run every gate in the quality-gates script (default when gates is omitted). Mutually exclusive with gates.'),
858
898
  apexTestClasses: z
859
899
  .string()
860
900
  .optional()
@@ -867,6 +907,14 @@ export function registerAgentiaMcpWorkTools(server) {
867
907
  .array(z.string())
868
908
  .optional()
869
909
  .describe('Extra environment variables for the quality-gate script as NAME=value strings (same as CLI -e/--env). Applied before reserved AGENTIA_APEX_* variables.'),
910
+ gates: z
911
+ .array(z.string())
912
+ .optional()
913
+ .describe('Run only these gate ids (standard: apex, lint, lwc; or custom ids declared in the script). Exported as AGENTIA_GATES. Only ["apex"] skips the script and runs the Apex tests directly.'),
914
+ listGates: z
915
+ .boolean()
916
+ .optional()
917
+ .describe('List the gates declared in the quality-gates script (or the stock sample) and return without running anything.'),
870
918
  local: z
871
919
  .boolean()
872
920
  .optional()
@@ -874,12 +922,17 @@ export function registerAgentiaMcpWorkTools(server) {
874
922
  rerunFailedApexTests: z
875
923
  .boolean()
876
924
  .optional()
877
- .describe('Pass AGENTIA_APEX_RERUN_FAILED=--rerun-failed-apex-tests to local quality gates so sample scripts forward that flag to work test apex.'),
925
+ .describe('Pass AGENTIA_APEX_RERUN_FAILED=--rerun-failed-apex-tests to local quality gates so sample scripts forward that flag to the apex gate.'),
926
+ wait: z
927
+ .number()
928
+ .int()
929
+ .optional()
930
+ .describe(`Minutes to wait for Apex test results when gates is ["apex"]. Defaults to ${DEFAULT_APEX_TEST_WAIT_MINUTES}.`),
878
931
  },
879
932
  title: 'Agentia Work Test',
880
933
  }, (args) => safelyHandleTool(() => workTest(args || {})));
881
934
  server.registerTool('agentia_work_test_apex', {
882
- description: 'Run specified Apex test classes via Salesforce CLI (`sf apex run test`) with code coverage. Usually run from project-root local quality gates (`.agentia_quality_gates.sh` / `.agentia_quality_gates.cmd`) when those scripts are configured. When apexTestClasses is omitted or empty, skips Salesforce CLI and returns skipped=true. Failed runs save `.agentia/apex.tests.<user-story>.json`; successful runs delete that file. rerunFailedApexTests runs the previously failed classes. Returns the test-run summary when the run passes. Failed runs include failing tests with Message and StackTrace.',
935
+ description: 'Run specified Apex test classes via Salesforce CLI (`sf apex run test`) with code coverage. Equivalent to agentia_work_test with gates ["apex"]. When apexTestClasses is omitted or empty, skips Salesforce CLI and returns skipped=true. Failed runs save `.agentia/apex.tests.<user-story>.json`; successful runs delete that file. rerunFailedApexTests runs the previously failed classes. Returns the test-run summary when the run passes. Failed runs include failing tests with Message and StackTrace.',
883
936
  inputSchema: {
884
937
  apexTestClasses: z
885
938
  .string()
@@ -0,0 +1,5 @@
1
+ import {modules} from './runtime.js';
2
+ const fetchPromotionQueue = modules["promotion-queue.js"]["fetchPromotionQueue"]
3
+ const formatPromotionQueueTable = modules["promotion-queue.js"]["formatPromotionQueueTable"]
4
+ const removePromotionQueueItems = modules["promotion-queue.js"]["removePromotionQueueItems"]
5
+ export {fetchPromotionQueue, formatPromotionQueueTable, removePromotionQueueItems};
@@ -1,4 +1,5 @@
1
1
  import {modules} from './runtime.js';
2
+ const NoPromotionForUserStoryError = modules["promotion-run.js"]["NoPromotionForUserStoryError"]
2
3
  const PROMOTION_OPERATIONS = modules["promotion-run.js"]["PROMOTION_OPERATIONS"]
3
4
  const PROMOTION_RUN_DEFAULT_TIMEOUT_SECONDS = modules["promotion-run.js"]["PROMOTION_RUN_DEFAULT_TIMEOUT_SECONDS"]
4
5
  const PromotionRunIncompleteResponseError = modules["promotion-run.js"]["PromotionRunIncompleteResponseError"]
@@ -22,6 +23,8 @@ const promotionRunErrorJson = modules["promotion-run.js"]["promotionRunErrorJson
22
23
  const promotionValidateResolutionEndpoint = modules["promotion-run.js"]["promotionValidateResolutionEndpoint"]
23
24
  const requirePromotionId = modules["promotion-run.js"]["requirePromotionId"]
24
25
  const resetPromotionRunSleepForTests = modules["promotion-run.js"]["resetPromotionRunSleepForTests"]
26
+ const resolveOrCreatePromotionForWorkItem = modules["promotion-run.js"]["resolveOrCreatePromotionForWorkItem"]
25
27
  const resolvePromotionIdForWorkItem = modules["promotion-run.js"]["resolvePromotionIdForWorkItem"]
26
28
  const setPromotionRunSleepForTests = modules["promotion-run.js"]["setPromotionRunSleepForTests"]
27
- export {PROMOTION_OPERATIONS, PROMOTION_RUN_DEFAULT_TIMEOUT_SECONDS, PromotionRunIncompleteResponseError, PromotionRunJobFailedError, PromotionRunTimeoutError, PromotionRunValidationError, assertPromotionContextReady, formatPromotionRunResult, isPromotionRunExecutionError, parseIgnoredMetadataJson, performPromotionResume, performPromotionRun, promotionContextEndpoint, promotionDeploymentStepsEndpoint, promotionIgnoredMetadataEndpoint, promotionJobMonitorEndpoint, promotionResumeEndpoint, promotionRunDetailEndpoint, promotionRunEndpoint, promotionRunErrorJson, promotionValidateResolutionEndpoint, requirePromotionId, resetPromotionRunSleepForTests, resolvePromotionIdForWorkItem, setPromotionRunSleepForTests};
29
+ const waitForPromotionDeploymentExecution = modules["promotion-run.js"]["waitForPromotionDeploymentExecution"]
30
+ export {NoPromotionForUserStoryError, PROMOTION_OPERATIONS, PROMOTION_RUN_DEFAULT_TIMEOUT_SECONDS, PromotionRunIncompleteResponseError, PromotionRunJobFailedError, PromotionRunTimeoutError, PromotionRunValidationError, assertPromotionContextReady, formatPromotionRunResult, isPromotionRunExecutionError, parseIgnoredMetadataJson, performPromotionResume, performPromotionRun, promotionContextEndpoint, promotionDeploymentStepsEndpoint, promotionIgnoredMetadataEndpoint, promotionJobMonitorEndpoint, promotionResumeEndpoint, promotionRunDetailEndpoint, promotionRunEndpoint, promotionRunErrorJson, promotionValidateResolutionEndpoint, requirePromotionId, resetPromotionRunSleepForTests, resolveOrCreatePromotionForWorkItem, resolvePromotionIdForWorkItem, setPromotionRunSleepForTests, waitForPromotionDeploymentExecution};
@@ -0,0 +1,12 @@
1
+ import {modules} from './runtime.js';
2
+ const buildPromotionActionNeeded = modules["promotion-status.js"]["buildPromotionActionNeeded"]
3
+ const buildPromotionStatusSnapshot = modules["promotion-status.js"]["buildPromotionStatusSnapshot"]
4
+ const fetchPromotionStatus = modules["promotion-status.js"]["fetchPromotionStatus"]
5
+ const formatPromotionStatus = modules["promotion-status.js"]["formatPromotionStatus"]
6
+ const isManualTaskStep = modules["promotion-status.js"]["isManualTaskStep"]
7
+ const isPendingManualTaskStep = modules["promotion-status.js"]["isPendingManualTaskStep"]
8
+ const pickCurrentJobStep = modules["promotion-status.js"]["pickCurrentJobStep"]
9
+ const pickPendingManualTaskStep = modules["promotion-status.js"]["pickPendingManualTaskStep"]
10
+ const resolvePromotionStatusJobId = modules["promotion-status.js"]["resolvePromotionStatusJobId"]
11
+ const toPromotionStatusStep = modules["promotion-status.js"]["toPromotionStatusStep"]
12
+ export {buildPromotionActionNeeded, buildPromotionStatusSnapshot, fetchPromotionStatus, formatPromotionStatus, isManualTaskStep, isPendingManualTaskStep, pickCurrentJobStep, pickPendingManualTaskStep, resolvePromotionStatusJobId, toPromotionStatusStep};
@@ -0,0 +1,13 @@
1
+ import {modules} from './runtime.js';
2
+ const AGENTIA_GATES_ALL = modules["quality-gates.js"]["AGENTIA_GATES_ALL"]
3
+ const AGENTIA_GATES_ENV = modules["quality-gates.js"]["AGENTIA_GATES_ENV"]
4
+ const APEX_QUALITY_GATE_ID = modules["quality-gates.js"]["APEX_QUALITY_GATE_ID"]
5
+ const STANDARD_QUALITY_GATE_IDS = modules["quality-gates.js"]["STANDARD_QUALITY_GATE_IDS"]
6
+ const UnknownQualityGateError = modules["quality-gates.js"]["UnknownQualityGateError"]
7
+ const formatDeclaredQualityGates = modules["quality-gates.js"]["formatDeclaredQualityGates"]
8
+ const isApexOnlySelection = modules["quality-gates.js"]["isApexOnlySelection"]
9
+ const parseDeclaredQualityGates = modules["quality-gates.js"]["parseDeclaredQualityGates"]
10
+ const parseQualityGateIds = modules["quality-gates.js"]["parseQualityGateIds"]
11
+ const qualityGatesEnvValue = modules["quality-gates.js"]["qualityGatesEnvValue"]
12
+ const resolveQualityGateSelection = modules["quality-gates.js"]["resolveQualityGateSelection"]
13
+ export {AGENTIA_GATES_ALL, AGENTIA_GATES_ENV, APEX_QUALITY_GATE_ID, STANDARD_QUALITY_GATE_IDS, UnknownQualityGateError, formatDeclaredQualityGates, isApexOnlySelection, parseDeclaredQualityGates, parseQualityGateIds, qualityGatesEnvValue, resolveQualityGateSelection};
@@ -0,0 +1,3 @@
1
+ import {modules} from './runtime.js';
2
+ const fetchRepositories = modules["repository-list.js"]["fetchRepositories"]
3
+ export {fetchRepositories};