@copado/agentia-cli 1.4.0 → 1.5.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.
- package/CHANGELOG.md +13 -0
- package/README.md +284 -284
- package/dist/lib/mcp/result.js +18 -2
- package/dist/lib/runtime.js +1 -1
- package/dist/lib/support-ai.js +1 -2
- package/oclif.manifest.json +326 -326
- package/package.json +1 -1
- package/templates/skills/agentia-ai/references/ai-agents.md +1 -1
package/dist/lib/mcp/result.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
2
|
import { runWithCicdConnectionOverride } from '../cicd-connection.js';
|
|
3
|
-
import { createTransactionId, runWithGatewayTransactionContext } from '../cicd-gateway.js';
|
|
3
|
+
import { createTransactionId, getGatewayTransactionOrigin, runWithGatewayTransactionContext } from '../cicd-gateway.js';
|
|
4
4
|
import { recordMcpToolHistory } from '../command-history.js';
|
|
5
|
+
import { publishIdeCommandCompleted } from '../ide-command-events.js';
|
|
5
6
|
import { mcpCommandIdFromToolName, mcpToolNameFromHandler } from './command-id.js';
|
|
6
7
|
import { redactErrorMessage, redactSecrets } from './redaction.js';
|
|
7
8
|
const require = createRequire(import.meta.url);
|
|
@@ -12,10 +13,15 @@ export function runWithMcpToolContext(toolName, fn, options = {}) {
|
|
|
12
13
|
const executionId = createTransactionId();
|
|
13
14
|
const commandId = mcpCommandIdFromToolName(toolName);
|
|
14
15
|
const startedAtMs = Date.now();
|
|
16
|
+
// Wrappers can nest; only the outermost call notifies the IDE.
|
|
17
|
+
const notifyIde = getGatewayTransactionOrigin() !== 'mcp';
|
|
15
18
|
return runWithGatewayTransactionContext({ origin: 'mcp', referer: commandId, transactionId }, async () => {
|
|
16
19
|
let error;
|
|
20
|
+
let toolFailed = false;
|
|
17
21
|
try {
|
|
18
|
-
|
|
22
|
+
const result = await runWithCicdConnectionOverride(options.cicdConnection, fn);
|
|
23
|
+
toolFailed = isMcpErrorResult(result);
|
|
24
|
+
return result;
|
|
19
25
|
}
|
|
20
26
|
catch (error_) {
|
|
21
27
|
error = error_;
|
|
@@ -30,9 +36,19 @@ export function runWithMcpToolContext(toolName, fn, options = {}) {
|
|
|
30
36
|
startedAtMs,
|
|
31
37
|
transactionId,
|
|
32
38
|
});
|
|
39
|
+
if (notifyIde) {
|
|
40
|
+
await publishIdeCommandCompleted({
|
|
41
|
+
cliVersion: packageJson.version,
|
|
42
|
+
commandId,
|
|
43
|
+
error: error ?? (toolFailed ? new Error('MCP tool failed') : undefined),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
33
46
|
}
|
|
34
47
|
});
|
|
35
48
|
}
|
|
49
|
+
function isMcpErrorResult(result) {
|
|
50
|
+
return typeof result === 'object' && result !== null && result.isError === true;
|
|
51
|
+
}
|
|
36
52
|
export function cicdConnectionFromToolArgs(args) {
|
|
37
53
|
const first = args[0];
|
|
38
54
|
if (first === null || typeof first !== 'object' || Array.isArray(first))
|