@copado/agentia-cli 1.2.0 → 1.3.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 (281) hide show
  1. package/CHANGELOG.md +30 -1
  2. package/README.md +2205 -1530
  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 +2 -2
  7. package/dist/commands/cicd/cloud/promote.js +19 -5
  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 +2 -2
  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 +2 -2
  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 +2 -2
  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 +2 -2
  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 +2 -2
  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 +2 -2
  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 +2 -2
  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 +2 -2
  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 +2 -2
  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 +2 -2
  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 +2 -2
  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/repository/auth/https/configure.js +2 -2
  139. package/dist/commands/cicd/repository/auth/oauth/login.js +2 -2
  140. package/dist/commands/cicd/repository/auth/setup.js +2 -2
  141. package/dist/commands/cicd/repository/auth/ssh/configure.js +2 -2
  142. package/dist/commands/cicd/repository/create.js +2 -2
  143. package/dist/commands/cicd/repository/delete.js +2 -2
  144. package/dist/commands/cicd/repository/get.js +2 -2
  145. package/dist/commands/cicd/repository/list.js +2 -2
  146. package/dist/commands/cicd/repository/open.js +2 -2
  147. package/dist/commands/cicd/repository/reset.js +2 -2
  148. package/dist/commands/cicd/repository/update.js +2 -2
  149. package/dist/commands/cicd/repository/validate.js +2 -2
  150. package/dist/commands/cicd/stage/create.js +2 -2
  151. package/dist/commands/cicd/stage/delete.js +2 -2
  152. package/dist/commands/cicd/stage/get.js +2 -2
  153. package/dist/commands/cicd/stage/list.js +2 -2
  154. package/dist/commands/cicd/stage/open.js +2 -2
  155. package/dist/commands/cicd/stage/update.js +2 -2
  156. package/dist/commands/cicd/template/defaults.js +2 -2
  157. package/dist/commands/cicd/template/delete.js +2 -2
  158. package/dist/commands/cicd/template/get.js +2 -2
  159. package/dist/commands/cicd/template/list.js +2 -2
  160. package/dist/commands/cicd/template/upsert.js +2 -2
  161. package/dist/commands/cicd/user/get.js +2 -2
  162. package/dist/commands/cicd/work/ahead-behind.js +2 -2
  163. package/dist/commands/cicd/work/create.js +2 -2
  164. package/dist/commands/cicd/work/delete.js +2 -2
  165. package/dist/commands/cicd/work/deployment-step/create.js +2 -2
  166. package/dist/commands/cicd/work/deployment-step/delete.js +2 -2
  167. package/dist/commands/cicd/work/deployment-step/list.js +2 -2
  168. package/dist/commands/cicd/work/deployment-step/reorder.js +2 -2
  169. package/dist/commands/cicd/work/deployment-step/salesforce-flows.js +2 -2
  170. package/dist/commands/cicd/work/deployment-step/types.js +2 -2
  171. package/dist/commands/cicd/work/deployment-step/update.js +2 -2
  172. package/dist/commands/cicd/work/done.js +2 -2
  173. package/dist/commands/cicd/work/environment-sync.js +2 -2
  174. package/dist/commands/cicd/work/get.js +2 -2
  175. package/dist/commands/cicd/work/list.js +2 -2
  176. package/dist/commands/cicd/work/open.js +2 -2
  177. package/dist/commands/cicd/work/promote.js +2 -2
  178. package/dist/commands/cicd/work/publish.js +2 -2
  179. package/dist/commands/cicd/work/push.js +2 -2
  180. package/dist/commands/cicd/work/set.js +2 -2
  181. package/dist/commands/cicd/work/status.js +2 -2
  182. package/dist/commands/cicd/work/submit.js +2 -2
  183. package/dist/commands/cicd/work/test/apex.js +2 -2
  184. package/dist/commands/cicd/work/test.js +2 -2
  185. package/dist/commands/cicd/work/update.js +2 -2
  186. package/dist/commands/help-agent.js +15 -0
  187. package/dist/commands/help.js +38 -0
  188. package/dist/commands/history/clear.js +42 -0
  189. package/dist/commands/history/list.js +50 -0
  190. package/dist/commands/support.js +15 -0
  191. package/dist/commands/testing/browser/execute.js +49 -0
  192. package/dist/commands/testing/browser/history.js +49 -0
  193. package/dist/commands/testing/browser/inspect.js +35 -0
  194. package/dist/commands/testing/browser/recorder.js +52 -0
  195. package/dist/commands/testing/browser/reports.js +33 -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 +3 -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/help-agent-command.js +3 -0
  219. package/dist/lib/help-agent-interaction-history.js +10 -0
  220. package/dist/lib/help-agent-session.js +3 -0
  221. package/dist/lib/mcp/result.js +41 -3
  222. package/dist/lib/mcp/server.js +3 -2
  223. package/dist/lib/mcp/testing-browser-tools.js +194 -0
  224. package/dist/lib/mcp/testing-tools.js +4 -3
  225. package/dist/lib/mcp/tool-annotations.js +32 -12
  226. package/dist/lib/mcp/tools.js +88 -37
  227. package/dist/lib/promotion-queue.js +5 -0
  228. package/dist/lib/promotion-run.js +2 -1
  229. package/dist/lib/runtime.js +1 -1
  230. package/dist/lib/support-ai-context.js +11 -0
  231. package/dist/lib/support-ai-stream-parser.js +4 -0
  232. package/dist/lib/support-ai.js +9 -0
  233. package/dist/lib/testing-browser-command.js +6 -0
  234. package/dist/lib/testing-browser-operations.js +17 -0
  235. package/dist/lib/testing-browser-requests.js +11 -0
  236. package/dist/lib/testing-browser-robot.js +9 -0
  237. package/dist/lib/testing-browser-session.js +14 -0
  238. package/dist/lib/testing-browser-state.js +17 -0
  239. package/dist/lib/testing-browser-stream.js +7 -0
  240. package/dist/lib/testing-browser-types.js +3 -0
  241. package/dist/lib/testing-browser-viewer-key.js +7 -0
  242. package/dist/lib/testing-gateway.js +2 -1
  243. package/dist/lib/testing-operations.js +21 -1
  244. package/dist/lib/testing-sanitization.js +2 -1
  245. package/dist/lib/work-promote.js +2 -1
  246. package/oclif.manifest.json +3108 -1450
  247. package/package.json +11 -4
  248. package/templates/skills/agentia-ai/SKILL.md +6 -2
  249. package/templates/skills/agentia-ai/references/ai-agents.md +19 -1
  250. package/templates/skills/agentia-cicd/SKILL.md +2 -2
  251. package/templates/skills/agentia-cicd/references/environments-and-credentials.md +16 -0
  252. package/templates/skills/agentia-cicd/references/promotions.md +10 -1
  253. package/templates/skills/agentia-metadata/SKILL.md +9 -3
  254. package/templates/skills/agentia-metadata/references/metadata-dependency.md +70 -0
  255. package/templates/skills/agentia-metadata/references/metadata-explore.md +8 -4
  256. package/templates/skills/agentia-testing/SKILL.md +9 -4
  257. package/templates/skills/agentia-testing/references/browser-testing.md +93 -0
  258. package/templates/skills/agentia-testing/references/flow-automation.md +112 -0
  259. package/templates/skills/agentia-testing/references/qforce.md +88 -0
  260. package/templates/skills/agentia-testing/references/qweb.md +103 -0
  261. package/templates/skills/agentia-testing/references/tests.md +17 -9
  262. package/dist/commands/testing/live/continue.js +0 -16
  263. package/dist/commands/testing/live/execute.js +0 -43
  264. package/dist/commands/testing/live/history.js +0 -40
  265. package/dist/commands/testing/live/inspect.js +0 -31
  266. package/dist/commands/testing/live/interrupt.js +0 -16
  267. package/dist/commands/testing/live/recorder.js +0 -42
  268. package/dist/commands/testing/live/reports.js +0 -31
  269. package/dist/commands/testing/live/screenshot.js +0 -25
  270. package/dist/commands/testing/live/set-options.js +0 -35
  271. package/dist/commands/testing/live/start.js +0 -58
  272. package/dist/commands/testing/live/status.js +0 -24
  273. package/dist/commands/testing/live/stop.js +0 -36
  274. package/dist/commands/testing/live/view.js +0 -36
  275. package/dist/lib/mcp/testing-live-tools.js +0 -226
  276. package/dist/lib/testing-live-command.js +0 -8
  277. package/dist/lib/testing-live-operations.js +0 -25
  278. package/dist/lib/testing-live-recorder.js +0 -11
  279. package/dist/lib/testing-live-robot.js +0 -9
  280. package/dist/lib/testing-live-state.js +0 -12
  281. package/dist/lib/testing-live-types.js +0 -3
@@ -1,8 +1,10 @@
1
1
  import { Command, Errors, ux } from '@oclif/core';
2
2
  import { format } from 'node:util';
3
- import { createTransactionId, runWithGatewayTransactionContext } from './cicd-gateway.js';
3
+ import { createTransactionId, getGatewayClientOrigin, getGatewayTransactionOrigin, runWithGatewayTransactionContext, } from './cicd-gateway.js';
4
4
  import { colorizeCliSeverityError, colorizeCliSeverityText } from './cli-severity-color.js';
5
- import { isCommandOutputCaptureActive } from './command-output-buffer.js';
5
+ import { COMMAND_HISTORY_TEXT_MAX_BYTES } from './command-history-sanitization.js';
6
+ import { recordCommandHistory } from './command-history.js';
7
+ import { isCommandOutputCaptureActive, runWithCommandOutputCapture, runWithoutCommandOutputCapture, } from './command-output-buffer.js';
6
8
  import { rememberIdeCommandError } from './ide-command-events.js';
7
9
  import { redactErrorMessage, redactSecrets } from './secret-redaction.js';
8
10
  const TRANSACTION_ID_REPORTED = Symbol('agentiaTransactionIdReported');
@@ -49,13 +51,40 @@ export function formatElapsedSecondsMessage(seconds) {
49
51
  export class AgentiaCommand extends Command {
50
52
  static enableJsonFlag = true;
51
53
  static experimental = false;
54
+ commandClientOrigin;
55
+ commandExecutionId;
56
+ commandHistoryCapture;
57
+ commandHistoryError;
58
+ commandHistoryResult;
59
+ commandHistoryStartedAtMs;
60
+ commandHistoryWritten = false;
52
61
  commandTransactionId;
53
62
  async _run() {
54
63
  const transactionId = createTransactionId();
64
+ this.commandClientOrigin = getGatewayTransactionOrigin() ?? getGatewayClientOrigin();
65
+ this.commandExecutionId = createTransactionId();
66
+ this.commandHistoryStartedAtMs = Date.now();
55
67
  this.commandTransactionId = transactionId;
56
- return runWithGatewayTransactionContext({ origin: 'cli', referer: this.id, transactionId }, () => super._run());
68
+ return runWithGatewayTransactionContext({ origin: this.commandClientOrigin, referer: this.id, transactionId }, async () => {
69
+ let caught;
70
+ try {
71
+ const result = await this.runWithHistoryCapture(() => super._run());
72
+ if (this.commandHistoryError === undefined)
73
+ this.commandHistoryResult = result;
74
+ return result;
75
+ }
76
+ catch (error) {
77
+ caught = error instanceof Error ? error : new Error(String(error));
78
+ this.commandHistoryError ??= caught;
79
+ throw error;
80
+ }
81
+ finally {
82
+ await this.recordCommandHistoryOnce(this.commandHistoryError ?? caught);
83
+ }
84
+ });
57
85
  }
58
86
  async catch(error) {
87
+ this.commandHistoryError = error;
59
88
  this.reportHumanErrorTransactionId(error);
60
89
  if (!this.jsonEnabled()) {
61
90
  colorizeCliSeverityError(error, 'error');
@@ -116,6 +145,7 @@ export class AgentiaCommand extends Command {
116
145
  };
117
146
  }
118
147
  toSuccessJson(result) {
148
+ this.commandHistoryResult = result;
119
149
  const warnings = this.jsonWarnings(result);
120
150
  return {
121
151
  result,
@@ -141,14 +171,14 @@ export class AgentiaCommand extends Command {
141
171
  }
142
172
  return action();
143
173
  }
144
- ux.action.start(message);
174
+ runWithoutCommandOutputCapture(() => ux.action.start(message));
145
175
  try {
146
176
  const result = await action();
147
- ux.action.stop();
177
+ runWithoutCommandOutputCapture(() => ux.action.stop());
148
178
  return result;
149
179
  }
150
180
  catch (error) {
151
- ux.action.stop(ux.colorize('red', 'failed'));
181
+ runWithoutCommandOutputCapture(() => ux.action.stop(ux.colorize('red', 'failed')));
152
182
  throw error;
153
183
  }
154
184
  }
@@ -162,6 +192,25 @@ export class AgentiaCommand extends Command {
162
192
  ];
163
193
  return [...new Set(warnings)];
164
194
  }
195
+ async recordCommandHistoryOnce(error) {
196
+ if (this.commandHistoryWritten)
197
+ return;
198
+ this.commandHistoryWritten = true;
199
+ const capture = this.commandHistoryCapture;
200
+ await recordCommandHistory({
201
+ argv: this.argv,
202
+ clientOrigin: this.commandClientOrigin,
203
+ cliVersion: this.config.version,
204
+ commandId: this.id ?? '',
205
+ error,
206
+ executionId: this.commandExecutionId,
207
+ logs: capture?.events,
208
+ result: this.commandHistoryResult,
209
+ startedAtMs: this.commandHistoryStartedAtMs,
210
+ transactionId: this.commandTransactionId,
211
+ truncatedStreams: capture?.truncatedStreams,
212
+ });
213
+ }
165
214
  reportHumanErrorTransactionId(error) {
166
215
  if (this.jsonEnabled() || this.commandTransactionId === undefined) {
167
216
  return;
@@ -180,5 +229,19 @@ export class AgentiaCommand extends Command {
180
229
  const { warnings } = result;
181
230
  return Array.isArray(warnings) ? warnings.filter((warning) => typeof warning === 'string') : [];
182
231
  }
232
+ async runWithHistoryCapture(action) {
233
+ const capture = await runWithCommandOutputCapture(action, {
234
+ captureVisibleToCommand: false,
235
+ forwardStderr: true,
236
+ forwardStdout: true,
237
+ maxBytes: COMMAND_HISTORY_TEXT_MAX_BYTES,
238
+ onCapture: (captured) => {
239
+ this.commandHistoryCapture = captured;
240
+ },
241
+ tail: true,
242
+ trackEvents: true,
243
+ });
244
+ return capture.result;
245
+ }
183
246
  }
184
247
  //# sourceMappingURL=agentia-command.js.map
@@ -0,0 +1,3 @@
1
+ import {modules} from './runtime.js';
2
+ const CicdCommand = modules["cicd-command.js"]["CicdCommand"]
3
+ export {CicdCommand};
@@ -0,0 +1,22 @@
1
+ import {modules} from './runtime.js';
2
+ const CICD_ALLOW_PRODUCTION_ENV = modules["cicd-connection.js"]["CICD_ALLOW_PRODUCTION_ENV"]
3
+ const CICD_CONNECTION_ENV = modules["cicd-connection.js"]["CICD_CONNECTION_ENV"]
4
+ const CICD_CONNECTION_NAME_REGEX = modules["cicd-connection.js"]["CICD_CONNECTION_NAME_REGEX"]
5
+ const activeCicdConnectionOverrideName = modules["cicd-connection.js"]["activeCicdConnectionOverrideName"]
6
+ const assertProductionConnectionAllowed = modules["cicd-connection.js"]["assertProductionConnectionAllowed"]
7
+ const assertValidCicdConnectionKind = modules["cicd-connection.js"]["assertValidCicdConnectionKind"]
8
+ const assertValidCicdConnectionName = modules["cicd-connection.js"]["assertValidCicdConnectionName"]
9
+ const clearProcessCicdConnectionOverride = modules["cicd-connection.js"]["clearProcessCicdConnectionOverride"]
10
+ const deleteCicdNamedConnection = modules["cicd-connection.js"]["deleteCicdNamedConnection"]
11
+ const formatCicdConnectionLabel = modules["cicd-connection.js"]["formatCicdConnectionLabel"]
12
+ const getCicdNamedConnection = modules["cicd-connection.js"]["getCicdNamedConnection"]
13
+ const listCicdNamedConnections = modules["cicd-connection.js"]["listCicdNamedConnections"]
14
+ const parseCicdConnectionFromArgv = modules["cicd-connection.js"]["parseCicdConnectionFromArgv"]
15
+ const productionWritesAllowed = modules["cicd-connection.js"]["productionWritesAllowed"]
16
+ const resolveNamedCicdConnectionCredentials = modules["cicd-connection.js"]["resolveNamedCicdConnectionCredentials"]
17
+ const runWithCicdConnectionOverride = modules["cicd-connection.js"]["runWithCicdConnectionOverride"]
18
+ const setProcessCicdConnectionOverride = modules["cicd-connection.js"]["setProcessCicdConnectionOverride"]
19
+ const setProcessProductionConnectionConfirmed = modules["cicd-connection.js"]["setProcessProductionConnectionConfirmed"]
20
+ const summarizeCicdNamedConnection = modules["cicd-connection.js"]["summarizeCicdNamedConnection"]
21
+ const upsertCicdNamedConnection = modules["cicd-connection.js"]["upsertCicdNamedConnection"]
22
+ export {CICD_ALLOW_PRODUCTION_ENV, CICD_CONNECTION_ENV, CICD_CONNECTION_NAME_REGEX, activeCicdConnectionOverrideName, assertProductionConnectionAllowed, assertValidCicdConnectionKind, assertValidCicdConnectionName, clearProcessCicdConnectionOverride, deleteCicdNamedConnection, formatCicdConnectionLabel, getCicdNamedConnection, listCicdNamedConnections, parseCicdConnectionFromArgv, productionWritesAllowed, resolveNamedCicdConnectionCredentials, runWithCicdConnectionOverride, setProcessCicdConnectionOverride, setProcessProductionConnectionConfirmed, summarizeCicdNamedConnection, upsertCicdNamedConnection};
@@ -25,6 +25,7 @@ const getActiveHttpRequestOptionsForTests = modules["cicd-gateway.js"]["getActiv
25
25
  const getGatewayClientOrigin = modules["cicd-gateway.js"]["getGatewayClientOrigin"]
26
26
  const getGatewayReferer = modules["cicd-gateway.js"]["getGatewayReferer"]
27
27
  const getGatewayTransactionId = modules["cicd-gateway.js"]["getGatewayTransactionId"]
28
+ const getGatewayTransactionOrigin = modules["cicd-gateway.js"]["getGatewayTransactionOrigin"]
28
29
  const isCicdWarningResponseBody = modules["cicd-gateway.js"]["isCicdWarningResponseBody"]
29
30
  const isCicdWarningStatus = modules["cicd-gateway.js"]["isCicdWarningStatus"]
30
31
  const maskUrlSecrets = modules["cicd-gateway.js"]["maskUrlSecrets"]
@@ -42,4 +43,4 @@ const scheduleGatewayEventLog = modules["cicd-gateway.js"]["scheduleGatewayEvent
42
43
  const setGatewayEventLogSenderForTests = modules["cicd-gateway.js"]["setGatewayEventLogSenderForTests"]
43
44
  const setHttpRequestForTests = modules["cicd-gateway.js"]["setHttpRequestForTests"]
44
45
  const tryResolveCicdCredentials = modules["cicd-gateway.js"]["tryResolveCicdCredentials"]
45
- export {ADV_GATEWAY_EVENT_SERVICE, AGENTIA_CLIENT_ORIGIN_ENV, AGENTIA_IDE_VERSION_ENV, AI_GATEWAY_EVENT_SERVICE, CICD_ENV, CRT_GATEWAY_EVENT_SERVICE, CicdGateway, CicdGatewayError, GATEWAY_EVENT_API_CALL, GATEWAY_EVENT_UNKNOWN, MCP_CICD_DEFAULT_REQUEST_TIMEOUT_MS, PLUGIN_GATEWAY_EVENT_SERVICE, buildGatewayEventLogPayload, cicdApiUrl, createTransactionId, discoverCicdBaseUrl, flushGatewayEventLogsForTests, formatCicdGatewayError, formatGatewayEventTimestamp, gatewayEventSource, gatewayRefererHeaders, gatewayUserAgent, getActiveHttpRequestOptionsForTests, getGatewayClientOrigin, getGatewayReferer, getGatewayTransactionId, isCicdWarningResponseBody, isCicdWarningStatus, maskUrlSecrets, maskedCicdApiUrl, normalizeCicdBaseUrl, parseRetryAfterHeader, resetGatewayEventLogSenderForTests, resetHttpRequestForTests, resolveAndValidateCicdEndpoint, resolveCicdCredentials, resolveCicdRequestTimeoutMs, resolveConfiguredCicdBaseUrl, runWithGatewayTransactionContext, scheduleGatewayEventLog, setGatewayEventLogSenderForTests, setHttpRequestForTests, tryResolveCicdCredentials};
46
+ export {ADV_GATEWAY_EVENT_SERVICE, AGENTIA_CLIENT_ORIGIN_ENV, AGENTIA_IDE_VERSION_ENV, AI_GATEWAY_EVENT_SERVICE, CICD_ENV, CRT_GATEWAY_EVENT_SERVICE, CicdGateway, CicdGatewayError, GATEWAY_EVENT_API_CALL, GATEWAY_EVENT_UNKNOWN, MCP_CICD_DEFAULT_REQUEST_TIMEOUT_MS, PLUGIN_GATEWAY_EVENT_SERVICE, buildGatewayEventLogPayload, cicdApiUrl, createTransactionId, discoverCicdBaseUrl, flushGatewayEventLogsForTests, formatCicdGatewayError, formatGatewayEventTimestamp, gatewayEventSource, gatewayRefererHeaders, gatewayUserAgent, getActiveHttpRequestOptionsForTests, getGatewayClientOrigin, getGatewayReferer, getGatewayTransactionId, getGatewayTransactionOrigin, isCicdWarningResponseBody, isCicdWarningStatus, maskUrlSecrets, maskedCicdApiUrl, normalizeCicdBaseUrl, parseRetryAfterHeader, resetGatewayEventLogSenderForTests, resetHttpRequestForTests, resolveAndValidateCicdEndpoint, resolveCicdCredentials, resolveCicdRequestTimeoutMs, resolveConfiguredCicdBaseUrl, runWithGatewayTransactionContext, scheduleGatewayEventLog, setGatewayEventLogSenderForTests, setHttpRequestForTests, tryResolveCicdCredentials};
@@ -0,0 +1,9 @@
1
+ import {modules} from './runtime.js';
2
+ const COMMAND_HISTORY_RESULT_MAX_BYTES = modules["command-history-sanitization.js"]["COMMAND_HISTORY_RESULT_MAX_BYTES"]
3
+ const COMMAND_HISTORY_TEXT_MAX_BYTES = modules["command-history-sanitization.js"]["COMMAND_HISTORY_TEXT_MAX_BYTES"]
4
+ const commandHistoryLogsText = modules["command-history-sanitization.js"]["commandHistoryLogsText"]
5
+ const sanitizeCommandHistoryLogs = modules["command-history-sanitization.js"]["sanitizeCommandHistoryLogs"]
6
+ const sanitizeCommandHistoryParameters = modules["command-history-sanitization.js"]["sanitizeCommandHistoryParameters"]
7
+ const sanitizeCommandHistoryResult = modules["command-history-sanitization.js"]["sanitizeCommandHistoryResult"]
8
+ const sanitizeCommandHistoryText = modules["command-history-sanitization.js"]["sanitizeCommandHistoryText"]
9
+ export {COMMAND_HISTORY_RESULT_MAX_BYTES, COMMAND_HISTORY_TEXT_MAX_BYTES, commandHistoryLogsText, sanitizeCommandHistoryLogs, sanitizeCommandHistoryParameters, sanitizeCommandHistoryResult, sanitizeCommandHistoryText};
@@ -0,0 +1,11 @@
1
+ import {modules} from './runtime.js';
2
+ const COMMAND_HISTORY_DEFAULT_LIST_LIMIT = modules["command-history.js"]["COMMAND_HISTORY_DEFAULT_LIST_LIMIT"]
3
+ const COMMAND_HISTORY_LIMIT = modules["command-history.js"]["COMMAND_HISTORY_LIMIT"]
4
+ const clearCommandHistory = modules["command-history.js"]["clearCommandHistory"]
5
+ const commandHistoryPath = modules["command-history.js"]["commandHistoryPath"]
6
+ const readCommandHistory = modules["command-history.js"]["readCommandHistory"]
7
+ const recordCommandHistory = modules["command-history.js"]["recordCommandHistory"]
8
+ const recordMcpToolHistory = modules["command-history.js"]["recordMcpToolHistory"]
9
+ const setCommandHistoryRootForTests = modules["command-history.js"]["setCommandHistoryRootForTests"]
10
+ const shouldRecordCommandHistory = modules["command-history.js"]["shouldRecordCommandHistory"]
11
+ export {COMMAND_HISTORY_DEFAULT_LIST_LIMIT, COMMAND_HISTORY_LIMIT, clearCommandHistory, commandHistoryPath, readCommandHistory, recordCommandHistory, recordMcpToolHistory, setCommandHistoryRootForTests, shouldRecordCommandHistory};
@@ -6,10 +6,15 @@ const appendCommandOutputLine = modules["command-output-buffer.js"]["appendComma
6
6
  const attachCapturedLogs = modules["command-output-buffer.js"]["attachCapturedLogs"]
7
7
  const attachCapturedOutputLogs = modules["command-output-buffer.js"]["attachCapturedOutputLogs"]
8
8
  const commandStdioCaptureOptions = modules["command-output-buffer.js"]["commandStdioCaptureOptions"]
9
+ const isAnyCommandOutputCaptureActive = modules["command-output-buffer.js"]["isAnyCommandOutputCaptureActive"]
9
10
  const isCommandOutputCaptureActive = modules["command-output-buffer.js"]["isCommandOutputCaptureActive"]
11
+ const readCapturedCommandOutputSnapshot = modules["command-output-buffer.js"]["readCapturedCommandOutputSnapshot"]
10
12
  const readCapturedCommandOutputText = modules["command-output-buffer.js"]["readCapturedCommandOutputText"]
11
13
  const redactCommandOutput = modules["command-output-buffer.js"]["redactCommandOutput"]
12
14
  const runWithCommandOutputCapture = modules["command-output-buffer.js"]["runWithCommandOutputCapture"]
15
+ const runWithoutCommandOutputCapture = modules["command-output-buffer.js"]["runWithoutCommandOutputCapture"]
13
16
  const splitCommandOutputLines = modules["command-output-buffer.js"]["splitCommandOutputLines"]
17
+ const tailUtf8 = modules["command-output-buffer.js"]["tailUtf8"]
18
+ const truncateUtf8 = modules["command-output-buffer.js"]["truncateUtf8"]
14
19
  const withCapturedCommandOutput = modules["command-output-buffer.js"]["withCapturedCommandOutput"]
15
- export {COMMAND_OUTPUT_MAX_BYTES, MCP_STDIO_CAPTURE_OPTIONS, appendCommandOutput, appendCommandOutputLine, attachCapturedLogs, attachCapturedOutputLogs, commandStdioCaptureOptions, isCommandOutputCaptureActive, readCapturedCommandOutputText, redactCommandOutput, runWithCommandOutputCapture, splitCommandOutputLines, withCapturedCommandOutput};
20
+ export {COMMAND_OUTPUT_MAX_BYTES, MCP_STDIO_CAPTURE_OPTIONS, appendCommandOutput, appendCommandOutputLine, attachCapturedLogs, attachCapturedOutputLogs, commandStdioCaptureOptions, isAnyCommandOutputCaptureActive, isCommandOutputCaptureActive, readCapturedCommandOutputSnapshot, readCapturedCommandOutputText, redactCommandOutput, runWithCommandOutputCapture, runWithoutCommandOutputCapture, splitCommandOutputLines, tailUtf8, truncateUtf8, withCapturedCommandOutput};
@@ -10,6 +10,7 @@ const migrateUserSettingsFromProjectConfig = modules["defaults-store.js"]["migra
10
10
  const readCredentialSyncReceipt = modules["defaults-store.js"]["readCredentialSyncReceipt"]
11
11
  const readDefaults = modules["defaults-store.js"]["readDefaults"]
12
12
  const readEnableLocalPromote = modules["defaults-store.js"]["readEnableLocalPromote"]
13
+ const readGlobalConfigDocument = modules["defaults-store.js"]["readGlobalConfigDocument"]
13
14
  const readLastApexTestClassesSelected = modules["defaults-store.js"]["readLastApexTestClassesSelected"]
14
15
  const readLastBaseBranch = modules["defaults-store.js"]["readLastBaseBranch"]
15
16
  const readLastDevOrgBranch = modules["defaults-store.js"]["readLastDevOrgBranch"]
@@ -30,6 +31,7 @@ const resolveDefaults = modules["defaults-store.js"]["resolveDefaults"]
30
31
  const setDefaultsStorePathsForTests = modules["defaults-store.js"]["setDefaultsStorePathsForTests"]
31
32
  const setDefaultsStoreProjectRoot = modules["defaults-store.js"]["setDefaultsStoreProjectRoot"]
32
33
  const unsetDefaults = modules["defaults-store.js"]["unsetDefaults"]
34
+ const updateGlobalConfigDocument = modules["defaults-store.js"]["updateGlobalConfigDocument"]
33
35
  const writeCredentialSyncReceipt = modules["defaults-store.js"]["writeCredentialSyncReceipt"]
34
36
  const writeDefaults = modules["defaults-store.js"]["writeDefaults"]
35
37
  const writeLastCommitSelections = modules["defaults-store.js"]["writeLastCommitSelections"]
@@ -37,4 +39,4 @@ const writeLastEnvironmentSyncName = modules["defaults-store.js"]["writeLastEnvi
37
39
  const writeLastWorkSelection = modules["defaults-store.js"]["writeLastWorkSelection"]
38
40
  const writeUpdateChannel = modules["defaults-store.js"]["writeUpdateChannel"]
39
41
  const writeUserContext = modules["defaults-store.js"]["writeUserContext"]
40
- export {DEFAULT_WORK_PUSH_RETRY_TIMEOUT_SECONDS, clearCredentialSyncReceipt, clearLastEnvironmentSyncName, clearLastKeysFromUserConfig, clearUserContext, getDefaultsStorePaths, isValidUserContext, migrateUserSettingsFromProjectConfig, readCredentialSyncReceipt, readDefaults, readEnableLocalPromote, readLastApexTestClassesSelected, readLastBaseBranch, readLastDevOrgBranch, readLastEnvironmentSyncName, readLastFullMetadataSelected, readLastPermissionSelected, readLastPullRequestBaseUrl, readLastWorkItem, readLastWorkItemId, readLastWorkItemTitle, readSkipNestedMetadataDetection, readSkipPullRequest, readUpdateChannel, readUserContext, readWorkPushRetryTimeoutSeconds, resetDefaultsStorePathsForTests, resolveDefaults, setDefaultsStorePathsForTests, setDefaultsStoreProjectRoot, unsetDefaults, writeCredentialSyncReceipt, writeDefaults, writeLastCommitSelections, writeLastEnvironmentSyncName, writeLastWorkSelection, writeUpdateChannel, writeUserContext};
42
+ export {DEFAULT_WORK_PUSH_RETRY_TIMEOUT_SECONDS, clearCredentialSyncReceipt, clearLastEnvironmentSyncName, clearLastKeysFromUserConfig, clearUserContext, getDefaultsStorePaths, isValidUserContext, migrateUserSettingsFromProjectConfig, readCredentialSyncReceipt, readDefaults, readEnableLocalPromote, readGlobalConfigDocument, readLastApexTestClassesSelected, readLastBaseBranch, readLastDevOrgBranch, readLastEnvironmentSyncName, readLastFullMetadataSelected, readLastPermissionSelected, readLastPullRequestBaseUrl, readLastWorkItem, readLastWorkItemId, readLastWorkItemTitle, readSkipNestedMetadataDetection, readSkipPullRequest, readUpdateChannel, readUserContext, readWorkPushRetryTimeoutSeconds, resetDefaultsStorePathsForTests, resolveDefaults, setDefaultsStorePathsForTests, setDefaultsStoreProjectRoot, unsetDefaults, updateGlobalConfigDocument, writeCredentialSyncReceipt, writeDefaults, writeLastCommitSelections, writeLastEnvironmentSyncName, writeLastWorkSelection, writeUpdateChannel, writeUserContext};
@@ -1,7 +1,9 @@
1
1
  import {modules} from './runtime.js';
2
+ const normalizeDependencyInputPath = modules["dependency-from-changes.js"]["normalizeDependencyInputPath"]
2
3
  const resetGitChangedFilesForTests = modules["dependency-from-changes.js"]["resetGitChangedFilesForTests"]
3
4
  const resolveChangedPath = modules["dependency-from-changes.js"]["resolveChangedPath"]
4
5
  const resolvedSelectionsFromChangedFiles = modules["dependency-from-changes.js"]["resolvedSelectionsFromChangedFiles"]
6
+ const resolvedSelectionsFromPaths = modules["dependency-from-changes.js"]["resolvedSelectionsFromPaths"]
5
7
  const selectionsFromChangedFiles = modules["dependency-from-changes.js"]["selectionsFromChangedFiles"]
6
8
  const setGitChangedFilesForTests = modules["dependency-from-changes.js"]["setGitChangedFilesForTests"]
7
- export {resetGitChangedFilesForTests, resolveChangedPath, resolvedSelectionsFromChangedFiles, selectionsFromChangedFiles, setGitChangedFilesForTests};
9
+ export {normalizeDependencyInputPath, resetGitChangedFilesForTests, resolveChangedPath, resolvedSelectionsFromChangedFiles, resolvedSelectionsFromPaths, selectionsFromChangedFiles, setGitChangedFilesForTests};
@@ -0,0 +1,3 @@
1
+ import {modules} from './runtime.js';
2
+ const resolveDependencySourceContext = modules["dependency-source-context.js"]["resolveDependencySourceContext"]
3
+ export {resolveDependencySourceContext};
@@ -0,0 +1,3 @@
1
+ import {modules} from './runtime.js';
2
+ const runInteractiveHelpAgent = modules["help-agent-command.js"]["runInteractiveHelpAgent"]
3
+ export {runInteractiveHelpAgent};
@@ -0,0 +1,10 @@
1
+ import {modules} from './runtime.js';
2
+ const HELP_AGENT_INTERACTION_LIMIT = modules["help-agent-interaction-history.js"]["HELP_AGENT_INTERACTION_LIMIT"]
3
+ const HELP_AGENT_INTERACTION_TEXT_MAX_BYTES = modules["help-agent-interaction-history.js"]["HELP_AGENT_INTERACTION_TEXT_MAX_BYTES"]
4
+ const HELP_AGENT_INTERACTION_TTL_MS = modules["help-agent-interaction-history.js"]["HELP_AGENT_INTERACTION_TTL_MS"]
5
+ const clearHelpAgentInteractions = modules["help-agent-interaction-history.js"]["clearHelpAgentInteractions"]
6
+ const helpAgentInteractionHistoryPath = modules["help-agent-interaction-history.js"]["helpAgentInteractionHistoryPath"]
7
+ const readHelpAgentInteractions = modules["help-agent-interaction-history.js"]["readHelpAgentInteractions"]
8
+ const recordHelpAgentInteraction = modules["help-agent-interaction-history.js"]["recordHelpAgentInteraction"]
9
+ const setHelpAgentInteractionHistoryRootForTests = modules["help-agent-interaction-history.js"]["setHelpAgentInteractionHistoryRootForTests"]
10
+ export {HELP_AGENT_INTERACTION_LIMIT, HELP_AGENT_INTERACTION_TEXT_MAX_BYTES, HELP_AGENT_INTERACTION_TTL_MS, clearHelpAgentInteractions, helpAgentInteractionHistoryPath, readHelpAgentInteractions, recordHelpAgentInteraction, setHelpAgentInteractionHistoryRootForTests};
@@ -0,0 +1,3 @@
1
+ import {modules} from './runtime.js';
2
+ const runHelpAgentSession = modules["help-agent-session.js"]["runHelpAgentSession"]
3
+ export {runHelpAgentSession};
@@ -1,14 +1,52 @@
1
+ import { createRequire } from 'node:module';
2
+ import { runWithCicdConnectionOverride } from '../cicd-connection.js';
1
3
  import { createTransactionId, runWithGatewayTransactionContext } from '../cicd-gateway.js';
4
+ import { recordMcpToolHistory } from '../command-history.js';
2
5
  import { mcpCommandIdFromToolName, mcpToolNameFromHandler } from './command-id.js';
3
6
  import { redactErrorMessage, redactSecrets } from './redaction.js';
7
+ const require = createRequire(import.meta.url);
8
+ const packageJson = require('../../../package.json');
4
9
  export { mcpToolNameFromHandler } from './command-id.js';
5
- export function runWithMcpToolContext(toolName, fn) {
6
- return runWithGatewayTransactionContext({ origin: 'mcp', referer: mcpCommandIdFromToolName(toolName), transactionId: createTransactionId() }, fn);
10
+ export function runWithMcpToolContext(toolName, fn, options = {}) {
11
+ const transactionId = createTransactionId();
12
+ const executionId = createTransactionId();
13
+ const commandId = mcpCommandIdFromToolName(toolName);
14
+ const startedAtMs = Date.now();
15
+ return runWithGatewayTransactionContext({ origin: 'mcp', referer: commandId, transactionId }, async () => {
16
+ let error;
17
+ try {
18
+ return await runWithCicdConnectionOverride(options.cicdConnection, fn);
19
+ }
20
+ catch (error_) {
21
+ error = error_;
22
+ throw error_;
23
+ }
24
+ finally {
25
+ await recordMcpToolHistory({
26
+ cliVersion: packageJson.version,
27
+ commandId,
28
+ error,
29
+ executionId,
30
+ startedAtMs,
31
+ transactionId,
32
+ });
33
+ }
34
+ });
35
+ }
36
+ export function cicdConnectionFromToolArgs(args) {
37
+ const first = args[0];
38
+ if (first === null || typeof first !== 'object' || Array.isArray(first))
39
+ return undefined;
40
+ const value = first.cicdConnection;
41
+ return typeof value === 'string' && value.trim().length > 0 ? value.trim() : undefined;
7
42
  }
8
43
  export function wrapMcpToolHandlers(handlers) {
9
44
  return Object.fromEntries(Object.entries(handlers).map(([name, handler]) => [
10
45
  name,
11
- (...args) => runWithMcpToolContext(mcpToolNameFromHandler(name), () => handler(...args)),
46
+ (...args) => {
47
+ const cicdConnection = cicdConnectionFromToolArgs(args);
48
+ return runWithMcpToolContext(mcpToolNameFromHandler(name), () => handler(...args), { cicdConnection });
49
+ },
12
50
  ]));
13
51
  }
14
52
  export function toolResult(data) {
@@ -7,7 +7,7 @@ import { logVerboseDebug } from '../debug.js';
7
7
  import { migrateUserSettingsFromProjectConfig } from '../defaults-store.js';
8
8
  import { applyProjectRoot, hasExplicitProjectRoot } from '../project-root.js';
9
9
  import { runWithMcpRequestSignal } from './request-context.js';
10
- import { runWithMcpToolContext } from './result.js';
10
+ import { cicdConnectionFromToolArgs, runWithMcpToolContext } from './result.js';
11
11
  import { withToolAnnotations } from './tool-annotations.js';
12
12
  import { registerAgentiaMcpTools } from './tools.js';
13
13
  const require = createRequire(import.meta.url);
@@ -105,10 +105,11 @@ function wrapMcpToolRegistration(server, lifecycleSignal, projectContextReady =
105
105
  server.registerTool = ((name, config, handler) => registerTool(name, withToolAnnotations(name, config), (...args) => {
106
106
  const extra = args.at(-1);
107
107
  const { dispose, signal } = combineSignals(extra?.signal, lifecycleSignal);
108
+ const cicdConnection = cicdConnectionFromToolArgs(args);
108
109
  return runWithMcpRequestSignal(signal, async () => {
109
110
  try {
110
111
  await projectContextReady;
111
- return await runWithMcpToolContext(name, async () => handler(...args));
112
+ return await runWithMcpToolContext(name, async () => handler(...args), { cicdConnection });
112
113
  }
113
114
  finally {
114
115
  dispose();
@@ -0,0 +1,194 @@
1
+ import { mkdtemp } from 'node:fs/promises';
2
+ import { tmpdir } from 'node:os';
3
+ import { join } from 'node:path';
4
+ import { z } from 'zod';
5
+ import { executeTestingLive, getTestingLiveHistory, getTestingLiveReports, getTestingLiveStatus, inspectTestingLive, saveTestingLiveScreenshot, setTestingLiveOptions, startTestingLive, stopTestingLive, } from '../testing-browser-operations.js';
6
+ import { assertTestingLiveStopConfirmed, normalizeTestingLiveExecuteSource, normalizeTestingLiveRecorderOptions, normalizeTestingLiveStartScreen, shapeTestingLiveHistoryResult, } from '../testing-browser-requests.js';
7
+ import { TESTING_LIVE_LIBRARIES } from '../testing-browser-types.js';
8
+ import { safelyHandleTool } from './result.js';
9
+ async function testingBrowserStart(args) {
10
+ const screen = normalizeTestingLiveStartScreen(args);
11
+ return {
12
+ result: await startTestingLive({
13
+ japIme: args.japIme,
14
+ jobId: args.job,
15
+ library: args.library,
16
+ noBootstrap: args.noBootstrap,
17
+ noBrowser: args.noBrowser,
18
+ projectId: args.project,
19
+ screen,
20
+ timeoutMs: args.timeoutSeconds === undefined ? undefined : args.timeoutSeconds * 1000,
21
+ }),
22
+ };
23
+ }
24
+ async function testingBrowserStop(args) {
25
+ assertTestingLiveStopConfirmed(args.confirm);
26
+ return { result: await stopTestingLive({ jobId: args.job, projectId: args.project, sessionId: args.sessionId }) };
27
+ }
28
+ async function testingBrowserStatus(args) {
29
+ return { result: await getTestingLiveStatus({ jobId: args.job, projectId: args.project, sessionId: args.sessionId }) };
30
+ }
31
+ async function testingBrowserExecute(args) {
32
+ normalizeTestingLiveExecuteSource({ keyword: args.keyword, lines: args.line }, { keyword: 'keyword', line: 'line' });
33
+ return {
34
+ result: await executeTestingLive({
35
+ args: args.argument,
36
+ jobId: args.job,
37
+ keyword: args.keyword,
38
+ lines: args.line,
39
+ projectId: args.project,
40
+ raw: args.raw,
41
+ sessionId: args.sessionId,
42
+ }),
43
+ };
44
+ }
45
+ async function testingBrowserInspect(args) {
46
+ return {
47
+ result: await inspectTestingLive({
48
+ jobId: args.job,
49
+ projectId: args.project,
50
+ sessionId: args.sessionId,
51
+ }),
52
+ };
53
+ }
54
+ async function testingBrowserScreenshot(args) {
55
+ const outputDir = await mkdtemp(join(tmpdir(), 'agentia-mcp-browser-screenshot-'));
56
+ return {
57
+ result: await saveTestingLiveScreenshot({
58
+ jobId: args.job,
59
+ output: join(outputDir, 'screenshot.png'),
60
+ projectId: args.project,
61
+ sessionId: args.sessionId,
62
+ }),
63
+ };
64
+ }
65
+ async function testingBrowserReports(args) {
66
+ return {
67
+ result: await getTestingLiveReports({
68
+ jobId: args.job,
69
+ projectId: args.project,
70
+ sessionId: args.sessionId,
71
+ }),
72
+ };
73
+ }
74
+ async function testingBrowserSetOptions(args) {
75
+ return {
76
+ result: await setTestingLiveOptions({
77
+ jobId: args.job,
78
+ projectId: args.project,
79
+ recorder: normalizeTestingLiveRecorderOptions(args.recorder),
80
+ sessionId: args.sessionId,
81
+ }),
82
+ };
83
+ }
84
+ async function testingBrowserHistory(args) {
85
+ const result = await getTestingLiveHistory({
86
+ includeFailed: args.includeFailed,
87
+ jobId: args.job,
88
+ keyword: args.keyword,
89
+ limit: args.limit,
90
+ projectId: args.project,
91
+ status: args.status,
92
+ });
93
+ return { result: shapeTestingLiveHistoryResult(result, args.linesOnly === true) };
94
+ }
95
+ export const testingBrowserMcpHandlers = {
96
+ testingBrowserExecute,
97
+ testingBrowserHistory,
98
+ testingBrowserInspect,
99
+ testingBrowserReports,
100
+ testingBrowserScreenshot,
101
+ testingBrowserSetOptions,
102
+ testingBrowserStart,
103
+ testingBrowserStatus,
104
+ testingBrowserStop,
105
+ };
106
+ const liveSessionSchema = {
107
+ job: z.number().int().positive().optional().describe('Optional CRT job ID.'),
108
+ project: z.number().int().positive().describe('CRT project ID.'),
109
+ sessionId: z.number().int().positive().optional().describe('Optional active CRT browser session ID.'),
110
+ };
111
+ const liveRecorderOptionsSchema = z.object({
112
+ enabled: z.boolean(),
113
+ enableHealingContext: z.boolean(),
114
+ enableHoverText: z.boolean(),
115
+ enableScrollText: z.boolean(),
116
+ enableSystemState: z.boolean(),
117
+ enableVerifyText: z.boolean(),
118
+ preferTableKeywords: z.boolean(),
119
+ });
120
+ export function registerTestingLiveMcpTools(server) {
121
+ server.registerTool('agentia_testing_browser_start', {
122
+ description: 'Start and bootstrap a CRT browser session.',
123
+ inputSchema: {
124
+ japIme: z.boolean().optional(),
125
+ job: z.number().int().positive().describe('CRT job ID.'),
126
+ library: z.enum(TESTING_LIVE_LIBRARIES).optional(),
127
+ noBootstrap: z.boolean().optional(),
128
+ noBrowser: z.boolean().optional(),
129
+ project: z.number().int().positive().describe('CRT project ID.'),
130
+ screen: z.string().max(100).optional(),
131
+ screenDepth: z.number().int().min(8).max(32).optional(),
132
+ screenHeight: z.number().int().min(240).max(4320).optional(),
133
+ screenWidth: z.number().int().min(320).max(7680).optional(),
134
+ timeoutSeconds: z.number().int().min(1).max(600).optional(),
135
+ viewport: z.string().max(100).optional(),
136
+ },
137
+ title: 'Agentia Testing Browser Start',
138
+ }, (args) => safelyHandleTool(() => testingBrowserStart(args)));
139
+ server.registerTool('agentia_testing_browser_stop', {
140
+ description: 'Stop the active CRT browser session. Requires explicit confirmation.',
141
+ inputSchema: { confirm: z.boolean().describe('Must be true to stop the session.'), ...liveSessionSchema },
142
+ title: 'Agentia Testing Browser Stop',
143
+ }, (args) => safelyHandleTool(() => testingBrowserStop(args)));
144
+ server.registerTool('agentia_testing_browser_status', {
145
+ description: 'Read status for the active CRT browser session.',
146
+ inputSchema: liveSessionSchema,
147
+ title: 'Agentia Testing Browser Status',
148
+ }, (args) => safelyHandleTool(() => testingBrowserStatus(args)));
149
+ server.registerTool('agentia_testing_browser_execute', {
150
+ description: 'Execute Robot Framework keywords in the active CRT browser session.',
151
+ inputSchema: {
152
+ argument: z.array(z.string().max(16_384)).max(100).optional(),
153
+ keyword: z.string().max(16_384).optional(),
154
+ line: z.array(z.string().max(16_384)).max(500).optional(),
155
+ raw: z.boolean().optional(),
156
+ ...liveSessionSchema,
157
+ },
158
+ title: 'Agentia Testing Browser Execute',
159
+ }, (args) => safelyHandleTool(() => testingBrowserExecute(args)));
160
+ server.registerTool('agentia_testing_browser_inspect', {
161
+ description: 'Inspect page state from the active CRT browser session.',
162
+ inputSchema: liveSessionSchema,
163
+ title: 'Agentia Testing Browser Inspect',
164
+ }, (args) => safelyHandleTool(() => testingBrowserInspect(args)));
165
+ server.registerTool('agentia_testing_browser_screenshot', {
166
+ description: 'Save a CRT browser screenshot to a temporary path.',
167
+ inputSchema: liveSessionSchema,
168
+ title: 'Agentia Testing Browser Screenshot',
169
+ }, (args) => safelyHandleTool(() => testingBrowserScreenshot(args)));
170
+ server.registerTool('agentia_testing_browser_reports', {
171
+ description: 'List browser session report metadata.',
172
+ inputSchema: liveSessionSchema,
173
+ title: 'Agentia Testing Browser Reports',
174
+ }, (args) => safelyHandleTool(() => testingBrowserReports(args)));
175
+ server.registerTool('agentia_testing_browser_set_options', {
176
+ description: 'Set CRT browser recorder options.',
177
+ inputSchema: { recorder: liveRecorderOptionsSchema, ...liveSessionSchema },
178
+ title: 'Agentia Testing Browser Set Options',
179
+ }, (args) => safelyHandleTool(() => testingBrowserSetOptions(args)));
180
+ server.registerTool('agentia_testing_browser_history', {
181
+ description: 'Read local CRT browser execution history.',
182
+ inputSchema: {
183
+ includeFailed: z.boolean().optional().describe('Include failed keyword executions.'),
184
+ job: z.number().int().positive().optional().describe('CRT job ID; defaults to the active session.'),
185
+ keyword: z.string().max(200).optional().describe('Filter by Robot Framework keyword name.'),
186
+ limit: z.number().int().min(1).max(500).optional(),
187
+ linesOnly: z.boolean().optional().describe('Flatten history into replayable keyword lines.'),
188
+ project: z.number().int().positive().describe('CRT project ID.'),
189
+ status: z.enum(['completed', 'failed', 'recorded']).optional(),
190
+ },
191
+ title: 'Agentia Testing Browser History',
192
+ }, (args) => safelyHandleTool(() => testingBrowserHistory(args)));
193
+ }
194
+ //# sourceMappingURL=testing-browser-tools.js.map
@@ -1,12 +1,13 @@
1
1
  /* eslint-disable unicorn/text-encoding-identifier-case -- CRT file APIs require the literal utf-8 enum. */
2
2
  import { z } from 'zod';
3
3
  import { createTestingDataTable, deleteTestingDataTable, getTestingDataTable, listTestingDataTables, TESTING_DATA_MAX_CELL_BYTES, TESTING_DATA_MAX_COLUMNS, TESTING_DATA_MAX_ROWS, updateTestingDataTable, } from '../testing-data-table.js';
4
+ import { abortTestingBuild, countTestingBuilds, executeTestingBuildRun, getTestingBuild, getTestingBuildLogs, listTestingBuilds, searchTestingBuilds, } from '../testing-execution.js';
4
5
  import { buildTestingRunOptions } from '../testing-flags.js';
5
- import { abortTestingBuild, countTestingBuilds, createTestingJob, createTestingProject, createTestingRobot, createTestingUserParameter, createTestingVariable, deleteTestingJob, deleteTestingProject, deleteTestingRobot, deleteTestingUserParameter, deleteTestingVariable, downloadTestingJobFiles, executeTestingBuildRun, getTestingBuild, getTestingBuildLogs, getTestingJob, getTestingJobRefs, getTestingJobScheduleStatus, getTestingProject, getTestingProjectPermission, getTestingRobot, getTestingUserParameter, getTestingVariable, listTestingBuilds, listTestingJobFiles, listTestingJobs, listTestingProjectPermissions, listTestingProjects, listTestingRobots, listTestingUserParameters, listTestingVariables, removeTestingJobSchedule, searchTestingBuilds, setTestingJobSchedule, setTestingProjectPermission, updateTestingJob, updateTestingProject, updateTestingRobot, updateTestingUserParameter, updateTestingVariable, uploadTestingJobFiles, } from '../testing-operations.js';
6
+ import { createTestingJob, createTestingProject, createTestingRobot, createTestingUserParameter, createTestingVariable, deleteTestingJob, deleteTestingProject, deleteTestingRobot, deleteTestingUserParameter, deleteTestingVariable, downloadTestingJobFiles, getTestingJob, getTestingJobRefs, getTestingJobScheduleStatus, getTestingProject, getTestingProjectPermission, getTestingRobot, getTestingUserParameter, getTestingVariable, listTestingJobFiles, listTestingJobs, listTestingProjectPermissions, listTestingProjects, listTestingRobots, listTestingUserParameters, listTestingVariables, removeTestingJobSchedule, setTestingJobSchedule, setTestingProjectPermission, updateTestingJob, updateTestingProject, updateTestingRobot, updateTestingUserParameter, updateTestingVariable, uploadTestingJobFiles, } from '../testing-operations.js';
6
7
  import { sanitizeTestingOutput } from '../testing-sanitization.js';
7
8
  import { TESTING_BUILD_STATUSES, TESTING_CONSOLE_COLORS, TESTING_JOB_PARALLEL_MODES, TESTING_JOB_SUITE_TYPES, TESTING_RECORD_BUILD_OPTIONS, TESTING_ROBOT_ACCEPTED_RUN_ENVIRONMENTS, TESTING_ROBOT_REPORTING, TESTING_ROBOT_REPORTING_DESCRIPTION, TESTING_ROBOT_RUN_ENVIRONMENT_DESCRIPTION, TESTING_ROBOT_TYPE_DESCRIPTION, TESTING_ROBOT_TYPES, TESTING_RUN_TYPES, TESTING_VARIABLE_TYPES, } from '../testing-types.js';
8
9
  import { safelyHandleTool } from './result.js';
9
- import { registerTestingLiveMcpTools, testingLiveMcpHandlers } from './testing-live-tools.js';
10
+ import { registerTestingLiveMcpTools, testingBrowserMcpHandlers } from './testing-browser-tools.js';
10
11
  const projectIdSchema = z.number().int().positive().describe('CRT project ID.');
11
12
  const jobIdSchema = z.number().int().positive().describe('CRT job ID.');
12
13
  const optionalJobIdSchema = z.number().int().positive().optional().describe('CRT job ID.');
@@ -444,7 +445,7 @@ export const agentiaMcpTestingToolHandlers = {
444
445
  testingVariableGet,
445
446
  testingVariableList,
446
447
  testingVariableUpdate,
447
- ...testingLiveMcpHandlers,
448
+ ...testingBrowserMcpHandlers,
448
449
  };
449
450
  export function registerAgentiaMcpTestingTools(server) {
450
451
  server.registerTool('agentia_testing_project_list', {