bdy 1.25.32-dev → 1.25.34-beta
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/distTs/package.json +1 -1
- package/distTs/src/api/client.js +111 -0
- package/distTs/src/cliIndex.js +2 -0
- package/distTs/src/command/integration/exec/call.js +89 -0
- package/distTs/src/command/integration/exec/kill.js +35 -0
- package/distTs/src/command/integration/exec/list.js +50 -0
- package/distTs/src/command/integration/exec/logs.js +39 -0
- package/distTs/src/command/integration/exec/status.js +40 -0
- package/distTs/src/command/integration/exec/tool.js +47 -0
- package/distTs/src/command/integration/exec/tools.js +39 -0
- package/distTs/src/command/integration/exec.js +30 -0
- package/distTs/src/command/integration/mcp.js +221 -0
- package/distTs/src/command/integration.js +2 -0
- package/distTs/src/command/variable/create.js +55 -0
- package/distTs/src/command/variable/delete.js +37 -0
- package/distTs/src/command/variable/get.js +51 -0
- package/distTs/src/command/variable/list.js +56 -0
- package/distTs/src/command/variable/scope.js +161 -0
- package/distTs/src/command/variable/update.js +92 -0
- package/distTs/src/command/variable.js +20 -0
- package/distTs/src/input.js +65 -0
- package/distTs/src/texts.js +272 -28
- package/distTs/src/utils.js +15 -3
- package/package.json +1 -1
package/distTs/package.json
CHANGED
package/distTs/src/api/client.js
CHANGED
|
@@ -750,6 +750,67 @@ class ApiClient {
|
|
|
750
750
|
...line,
|
|
751
751
|
});
|
|
752
752
|
}
|
|
753
|
+
// Variable methods
|
|
754
|
+
variableScopeQuery(scope) {
|
|
755
|
+
const query = {};
|
|
756
|
+
if (scope.project)
|
|
757
|
+
query.project_name = scope.project;
|
|
758
|
+
if (scope.pipelineId)
|
|
759
|
+
query.pipeline_id = scope.pipelineId.toString();
|
|
760
|
+
if (scope.environmentId)
|
|
761
|
+
query.environment_id = scope.environmentId;
|
|
762
|
+
if (scope.sandboxId)
|
|
763
|
+
query.sandbox_id = scope.sandboxId;
|
|
764
|
+
return query;
|
|
765
|
+
}
|
|
766
|
+
async getVariables(workspace, scope = {}) {
|
|
767
|
+
return await this.request({
|
|
768
|
+
method: 'GET',
|
|
769
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/variables`,
|
|
770
|
+
query: this.variableScopeQuery(scope),
|
|
771
|
+
parseResponseBody: true,
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
async getVariable(workspace, variableId) {
|
|
775
|
+
return await this.request({
|
|
776
|
+
method: 'GET',
|
|
777
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/variables/${encodeURIComponent(variableId)}`,
|
|
778
|
+
parseResponseBody: true,
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
// The scope goes in the body as the owning object, not as query params
|
|
782
|
+
async createVariable(workspace, scope, body) {
|
|
783
|
+
const data = { ...body };
|
|
784
|
+
if (scope.pipelineId)
|
|
785
|
+
data.pipeline = { id: scope.pipelineId };
|
|
786
|
+
else if (scope.environmentId)
|
|
787
|
+
data.environment = { id: scope.environmentId };
|
|
788
|
+
else if (scope.sandboxId)
|
|
789
|
+
data.sandbox = { id: scope.sandboxId };
|
|
790
|
+
else if (scope.project)
|
|
791
|
+
data.project = { name: scope.project };
|
|
792
|
+
return await this.request({
|
|
793
|
+
method: 'POST',
|
|
794
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/variables`,
|
|
795
|
+
body: data,
|
|
796
|
+
parseResponseBody: true,
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
async updateVariable(workspace, variableId, body) {
|
|
800
|
+
return await this.request({
|
|
801
|
+
method: 'PATCH',
|
|
802
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/variables/${encodeURIComponent(variableId)}`,
|
|
803
|
+
body,
|
|
804
|
+
parseResponseBody: true,
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
async deleteVariable(workspace, variableId) {
|
|
808
|
+
return await this.request({
|
|
809
|
+
method: 'DELETE',
|
|
810
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/variables/${encodeURIComponent(variableId)}`,
|
|
811
|
+
parseResponseBody: false,
|
|
812
|
+
});
|
|
813
|
+
}
|
|
753
814
|
// Environment methods
|
|
754
815
|
async getEnvironments(workspace, project) {
|
|
755
816
|
const query = {};
|
|
@@ -1377,6 +1438,56 @@ class ApiClient {
|
|
|
1377
1438
|
parseResponseBody: false,
|
|
1378
1439
|
});
|
|
1379
1440
|
}
|
|
1441
|
+
async executeIntegration(workspace, hashId, body) {
|
|
1442
|
+
return await this.request({
|
|
1443
|
+
method: 'POST',
|
|
1444
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/integrations/${encodeURIComponent(hashId)}/execs`,
|
|
1445
|
+
body,
|
|
1446
|
+
parseResponseBody: true,
|
|
1447
|
+
});
|
|
1448
|
+
}
|
|
1449
|
+
async getIntegrationExecs(workspace, hashId, limit) {
|
|
1450
|
+
const query = {};
|
|
1451
|
+
if (limit)
|
|
1452
|
+
query.limit = limit.toString();
|
|
1453
|
+
return await this.request({
|
|
1454
|
+
method: 'GET',
|
|
1455
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/integrations/${encodeURIComponent(hashId)}/execs`,
|
|
1456
|
+
query,
|
|
1457
|
+
parseResponseBody: true,
|
|
1458
|
+
});
|
|
1459
|
+
}
|
|
1460
|
+
async getIntegrationExec(workspace, hashId, execId, wait) {
|
|
1461
|
+
const query = {};
|
|
1462
|
+
if (wait)
|
|
1463
|
+
query.wait = wait.toString();
|
|
1464
|
+
return await this.request({
|
|
1465
|
+
method: 'GET',
|
|
1466
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/integrations/${encodeURIComponent(hashId)}/execs/${encodeURIComponent(execId)}`,
|
|
1467
|
+
query,
|
|
1468
|
+
parseResponseBody: true,
|
|
1469
|
+
});
|
|
1470
|
+
}
|
|
1471
|
+
async cancelIntegrationExec(workspace, hashId, execId) {
|
|
1472
|
+
return await this.request({
|
|
1473
|
+
method: 'DELETE',
|
|
1474
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/integrations/${encodeURIComponent(hashId)}/execs/${encodeURIComponent(execId)}`,
|
|
1475
|
+
parseResponseBody: false,
|
|
1476
|
+
});
|
|
1477
|
+
}
|
|
1478
|
+
async getIntegrationExecLog(workspace, hashId, execId, offset, limit) {
|
|
1479
|
+
const query = {};
|
|
1480
|
+
if (offset)
|
|
1481
|
+
query.offset = offset.toString();
|
|
1482
|
+
if (limit)
|
|
1483
|
+
query.limit = limit.toString();
|
|
1484
|
+
return await this.request({
|
|
1485
|
+
method: 'GET',
|
|
1486
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/integrations/${encodeURIComponent(hashId)}/execs/${encodeURIComponent(execId)}/log`,
|
|
1487
|
+
query,
|
|
1488
|
+
parseResponseBody: true,
|
|
1489
|
+
});
|
|
1490
|
+
}
|
|
1380
1491
|
async getIntegrationByIdentifier(workspace, identifier, line = {}) {
|
|
1381
1492
|
return await this.getResourceByIdentifier(workspace, {
|
|
1382
1493
|
integration: identifier,
|
package/distTs/src/cliIndex.js
CHANGED
|
@@ -28,6 +28,7 @@ const distro_1 = __importDefault(require("./command/distro"));
|
|
|
28
28
|
const target_1 = __importDefault(require("./command/target"));
|
|
29
29
|
const environment_1 = __importDefault(require("./command/environment"));
|
|
30
30
|
const integration_1 = __importDefault(require("./command/integration"));
|
|
31
|
+
const variable_1 = __importDefault(require("./command/variable"));
|
|
31
32
|
const register_1 = __importDefault(require("./command/register"));
|
|
32
33
|
const mcp_1 = __importDefault(require("./command/mcp"));
|
|
33
34
|
const discover_1 = __importDefault(require("./command/discover"));
|
|
@@ -68,6 +69,7 @@ function cliIndex() {
|
|
|
68
69
|
program.addCommand(target_1.default);
|
|
69
70
|
program.addCommand(environment_1.default);
|
|
70
71
|
program.addCommand(integration_1.default);
|
|
72
|
+
program.addCommand(variable_1.default);
|
|
71
73
|
program.addCommand(login_1.default);
|
|
72
74
|
program.addCommand(register_1.default);
|
|
73
75
|
program.addCommand(whoami_1.default);
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const texts_1 = require("../../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../../output"));
|
|
9
|
+
const input_1 = __importDefault(require("../../../input"));
|
|
10
|
+
const cliError_1 = __importDefault(require("../../../cliError"));
|
|
11
|
+
const scope_1 = require("../scope");
|
|
12
|
+
const mcp_1 = require("../mcp");
|
|
13
|
+
const commandIntegrationExecCall = (0, utils_1.newCommand)('call', texts_1.DESC_COMMAND_INTEGRATION_EXEC_CALL, {
|
|
14
|
+
requiredScopes: [utils_1.REST_API_SCOPE.INTEGRATION_USE],
|
|
15
|
+
examples: texts_1.EXAMPLE_INTEGRATION_EXEC_CALL,
|
|
16
|
+
helpText: texts_1.HELP_INTEGRATION_EXEC,
|
|
17
|
+
});
|
|
18
|
+
(0, mcp_1.integrationExecOptions)(commandIntegrationExecCall);
|
|
19
|
+
commandIntegrationExecCall.argument('<tool>', texts_1.OPTION_INTEGRATION_EXEC_TOOL);
|
|
20
|
+
commandIntegrationExecCall.option('--args <json|@path|->', texts_1.OPTION_INTEGRATION_EXEC_ARGS);
|
|
21
|
+
commandIntegrationExecCall.option('--no-validate', texts_1.OPTION_INTEGRATION_EXEC_NO_VALIDATE);
|
|
22
|
+
commandIntegrationExecCall.option('-f, --force', texts_1.OPTION_INTEGRATION_EXEC_FORCE);
|
|
23
|
+
commandIntegrationExecCall.option('--async', texts_1.OPTION_INTEGRATION_EXEC_ASYNC);
|
|
24
|
+
commandIntegrationExecCall.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
25
|
+
// The tool definition (one GET_TOOL execution) is fetched only when it is
|
|
26
|
+
// needed: to validate the arguments, or to ask before a destructive tool.
|
|
27
|
+
// --no-validate together with -f calls the tool straight away.
|
|
28
|
+
commandIntegrationExecCall.action(async (identifier, toolName, options) => {
|
|
29
|
+
output_1.default.handleSignals();
|
|
30
|
+
const args = (0, mcp_1.parseToolArgs)(options.args);
|
|
31
|
+
const json = options.format === 'json';
|
|
32
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
33
|
+
const client = input_1.default.restApiTokenClient();
|
|
34
|
+
const hash_id = await (0, scope_1.resolveIntegrationId)(client, workspace, identifier, options);
|
|
35
|
+
const ref = (0, mcp_1.integrationRef)(identifier, options);
|
|
36
|
+
if (options.validate || !options.force) {
|
|
37
|
+
const tool = await (0, mcp_1.runMcp)(client, workspace, hash_id, { operation: 'GET_TOOL', tool: toolName }, ref);
|
|
38
|
+
const errors = options.validate ? (0, mcp_1.validateToolArgs)(tool, args) : null;
|
|
39
|
+
if (errors?.length) {
|
|
40
|
+
throw new cliError_1.default('usage_error', (0, texts_1.ERR_INTEGRATION_EXEC_ARGS_INVALID)(toolName, errors), (0, texts_1.HINT_INTEGRATION_EXEC_TOOL)(ref, toolName));
|
|
41
|
+
}
|
|
42
|
+
if ((0, mcp_1.isDestructiveTool)(tool)) {
|
|
43
|
+
const confirmed = await output_1.default.confirmDestructive(options.force, (0, texts_1.TXT_INTEGRATION_EXEC_DESTRUCTIVE_CONFIRM)(toolName), json);
|
|
44
|
+
if (!confirmed)
|
|
45
|
+
output_1.default.exitResult(json, { called: null });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const started = await (0, mcp_1.startMcp)(client, workspace, hash_id, {
|
|
49
|
+
operation: 'CALL_TOOL',
|
|
50
|
+
tool: toolName,
|
|
51
|
+
arguments: args,
|
|
52
|
+
});
|
|
53
|
+
if (options.async) {
|
|
54
|
+
if (json)
|
|
55
|
+
output_1.default.json(started);
|
|
56
|
+
else {
|
|
57
|
+
output_1.default.note((0, texts_1.TXT_INTEGRATION_EXEC_BACKGROUND)(ref, started.execution_id));
|
|
58
|
+
output_1.default.data(started.execution_id);
|
|
59
|
+
}
|
|
60
|
+
output_1.default.exitNormal();
|
|
61
|
+
}
|
|
62
|
+
const { exec, output } = await (0, mcp_1.finishMcp)(client, workspace, hash_id, started);
|
|
63
|
+
const succeeded = exec.status === utils_1.TARGET_EXEC_STATUS.SUCCESSFUL;
|
|
64
|
+
if (json) {
|
|
65
|
+
// the execution as the API returns it, with the tool result parsed out
|
|
66
|
+
// of its log; error_message carries the reason when it failed. A log
|
|
67
|
+
// that is not JSON (plain text, cut off) still returns the execution -
|
|
68
|
+
// its id is what `exec logs` needs - with result null and exit 1.
|
|
69
|
+
let result = null;
|
|
70
|
+
if (succeeded) {
|
|
71
|
+
try {
|
|
72
|
+
result = (0, mcp_1.parseMcpOutput)(output);
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
result = null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
output_1.default.json({ ...exec, result });
|
|
79
|
+
output_1.default.exitCode(result && !result.isError ? 0 : 1);
|
|
80
|
+
}
|
|
81
|
+
(0, mcp_1.assertMcpSucceeded)(exec, output, ref);
|
|
82
|
+
const result = (0, mcp_1.parseMcpOutput)(output);
|
|
83
|
+
if (result?.isError) {
|
|
84
|
+
throw new cliError_1.default('command_failed', `${(0, texts_1.ERR_INTEGRATION_EXEC_TOOL_ERROR)(toolName)}: ${(0, mcp_1.callResultText)(result)}`);
|
|
85
|
+
}
|
|
86
|
+
output_1.default.data((0, mcp_1.callResultText)(result));
|
|
87
|
+
output_1.default.exitNormal();
|
|
88
|
+
});
|
|
89
|
+
exports.default = commandIntegrationExecCall;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const texts_1 = require("../../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../../output"));
|
|
9
|
+
const input_1 = __importDefault(require("../../../input"));
|
|
10
|
+
const scope_1 = require("../scope");
|
|
11
|
+
const mcp_1 = require("../mcp");
|
|
12
|
+
const commandIntegrationExecKill = (0, utils_1.newCommand)('kill', texts_1.DESC_COMMAND_INTEGRATION_EXEC_KILL, {
|
|
13
|
+
requiredScopes: [utils_1.REST_API_SCOPE.INTEGRATION_USE],
|
|
14
|
+
examples: texts_1.EXAMPLE_INTEGRATION_EXEC_KILL,
|
|
15
|
+
});
|
|
16
|
+
(0, mcp_1.integrationExecOptions)(commandIntegrationExecKill);
|
|
17
|
+
commandIntegrationExecKill.argument('<exec-id>', texts_1.OPTION_TARGET_EXEC_ID);
|
|
18
|
+
commandIntegrationExecKill.option('-f, --force', texts_1.OPTION_CONFIRM_FORCE);
|
|
19
|
+
commandIntegrationExecKill.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
20
|
+
commandIntegrationExecKill.action(async (identifier, execId, options) => {
|
|
21
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
22
|
+
const client = input_1.default.restApiTokenClient();
|
|
23
|
+
const hash_id = await (0, scope_1.resolveIntegrationId)(client, workspace, identifier, options);
|
|
24
|
+
// as in target exec kill: a bad id fails the same with and without -f
|
|
25
|
+
if (!options.force) {
|
|
26
|
+
await client.getIntegrationExec(workspace, hash_id, execId);
|
|
27
|
+
}
|
|
28
|
+
const json = options.format === 'json';
|
|
29
|
+
const confirmed = await output_1.default.confirmDestructive(options.force, (0, texts_1.TXT_TARGET_EXEC_KILL_CONFIRM)(execId), json);
|
|
30
|
+
if (!confirmed)
|
|
31
|
+
output_1.default.exitResult(json, { killed: null });
|
|
32
|
+
await client.cancelIntegrationExec(workspace, hash_id, execId);
|
|
33
|
+
output_1.default.exitResult(json, { killed: execId }, (0, texts_1.TXT_TARGET_EXEC_KILLED)(execId));
|
|
34
|
+
});
|
|
35
|
+
exports.default = commandIntegrationExecKill;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const texts_1 = require("../../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../../output"));
|
|
9
|
+
const input_1 = __importDefault(require("../../../input"));
|
|
10
|
+
const scope_1 = require("../scope");
|
|
11
|
+
const mcp_1 = require("../mcp");
|
|
12
|
+
const commandIntegrationExecList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_INTEGRATION_EXEC_LIST, {
|
|
13
|
+
requiredScopes: [utils_1.REST_API_SCOPE.INTEGRATION_READ],
|
|
14
|
+
examples: texts_1.EXAMPLE_INTEGRATION_EXEC_LIST,
|
|
15
|
+
});
|
|
16
|
+
commandIntegrationExecList.alias('ls');
|
|
17
|
+
(0, mcp_1.integrationExecOptions)(commandIntegrationExecList);
|
|
18
|
+
commandIntegrationExecList.option('--limit <n>', texts_1.OPTION_TARGET_EXEC_LIMIT);
|
|
19
|
+
commandIntegrationExecList.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
20
|
+
commandIntegrationExecList.action(async (identifier, options) => {
|
|
21
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
22
|
+
const client = input_1.default.restApiTokenClient();
|
|
23
|
+
const hash_id = await (0, scope_1.resolveIntegrationId)(client, workspace, identifier, options);
|
|
24
|
+
const limit = options.limit ? parseInt(options.limit, 10) : undefined;
|
|
25
|
+
const execs = await client.getIntegrationExecs(workspace, hash_id, limit);
|
|
26
|
+
if (options.format === 'json') {
|
|
27
|
+
output_1.default.json(execs);
|
|
28
|
+
output_1.default.exitNormal();
|
|
29
|
+
}
|
|
30
|
+
if (execs.length === 0)
|
|
31
|
+
output_1.default.exitNormal(texts_1.ERR_INTEGRATION_NO_EXECS);
|
|
32
|
+
const data = [
|
|
33
|
+
['EXEC ID', 'STATUS', 'OPERATION', 'STARTED', 'FINISHED'],
|
|
34
|
+
];
|
|
35
|
+
for (const exec of execs) {
|
|
36
|
+
data.push([
|
|
37
|
+
exec.execution_id || '-',
|
|
38
|
+
exec.failure_reason
|
|
39
|
+
? `${exec.status} (${exec.failure_reason})`
|
|
40
|
+
: exec.status || '-',
|
|
41
|
+
// the MCP operation as canonical JSON
|
|
42
|
+
(0, utils_1.truncate)(exec.command || '-', 60),
|
|
43
|
+
exec.started_at || '-',
|
|
44
|
+
exec.finished_at || '-',
|
|
45
|
+
]);
|
|
46
|
+
}
|
|
47
|
+
output_1.default.table(data);
|
|
48
|
+
output_1.default.exitNormal();
|
|
49
|
+
});
|
|
50
|
+
exports.default = commandIntegrationExecList;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const texts_1 = require("../../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../../output"));
|
|
9
|
+
const input_1 = __importDefault(require("../../../input"));
|
|
10
|
+
const execLog_1 = require("../../../execLog");
|
|
11
|
+
const scope_1 = require("../scope");
|
|
12
|
+
const mcp_1 = require("../mcp");
|
|
13
|
+
const commandIntegrationExecLogs = (0, utils_1.newCommand)('logs', texts_1.DESC_COMMAND_INTEGRATION_EXEC_LOGS, {
|
|
14
|
+
requiredScopes: [utils_1.REST_API_SCOPE.INTEGRATION_READ],
|
|
15
|
+
examples: texts_1.EXAMPLE_INTEGRATION_EXEC_LOGS,
|
|
16
|
+
});
|
|
17
|
+
(0, mcp_1.integrationExecOptions)(commandIntegrationExecLogs);
|
|
18
|
+
commandIntegrationExecLogs.argument('<exec-id>', texts_1.OPTION_TARGET_EXEC_ID);
|
|
19
|
+
commandIntegrationExecLogs.option('--offset <n>', texts_1.OPTION_TARGET_EXEC_LOG_OFFSET);
|
|
20
|
+
commandIntegrationExecLogs.option('--limit <n>', texts_1.OPTION_TARGET_EXEC_LOG_LIMIT);
|
|
21
|
+
commandIntegrationExecLogs.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
22
|
+
// The log of an MCP execution is its result (or the error), so json mode
|
|
23
|
+
// returns the lines as one array rather than a record per line.
|
|
24
|
+
commandIntegrationExecLogs.action(async (identifier, execId, options) => {
|
|
25
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
26
|
+
const client = input_1.default.restApiTokenClient();
|
|
27
|
+
const hash_id = await (0, scope_1.resolveIntegrationId)(client, workspace, identifier, options);
|
|
28
|
+
const offset = options.offset ? parseInt(options.offset, 10) : 0;
|
|
29
|
+
const limit = options.limit ? parseInt(options.limit, 10) : undefined;
|
|
30
|
+
const json = options.format === 'json';
|
|
31
|
+
const lines = [];
|
|
32
|
+
const { truncated } = await (0, execLog_1.forwardExecLog)((from, pageLimit) => client.getIntegrationExecLog(workspace, hash_id, execId, from, pageLimit), offset, json ? (page) => lines.push(...page) : undefined, limit);
|
|
33
|
+
if (json)
|
|
34
|
+
output_1.default.json({ execution_id: execId, lines, truncated });
|
|
35
|
+
else if (truncated)
|
|
36
|
+
output_1.default.noteWarning(texts_1.WARN_TARGET_EXEC_TRUNCATED);
|
|
37
|
+
output_1.default.exitNormal();
|
|
38
|
+
});
|
|
39
|
+
exports.default = commandIntegrationExecLogs;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const texts_1 = require("../../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../../output"));
|
|
9
|
+
const input_1 = __importDefault(require("../../../input"));
|
|
10
|
+
const scope_1 = require("../scope");
|
|
11
|
+
const mcp_1 = require("../mcp");
|
|
12
|
+
const commandIntegrationExecStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_INTEGRATION_EXEC_STATUS, {
|
|
13
|
+
requiredScopes: [utils_1.REST_API_SCOPE.INTEGRATION_READ],
|
|
14
|
+
examples: texts_1.EXAMPLE_INTEGRATION_EXEC_STATUS,
|
|
15
|
+
});
|
|
16
|
+
(0, mcp_1.integrationExecOptions)(commandIntegrationExecStatus);
|
|
17
|
+
commandIntegrationExecStatus.argument('<exec-id>', texts_1.OPTION_TARGET_EXEC_ID);
|
|
18
|
+
commandIntegrationExecStatus.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
19
|
+
commandIntegrationExecStatus.action(async (identifier, execId, options) => {
|
|
20
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
21
|
+
const client = input_1.default.restApiTokenClient();
|
|
22
|
+
const hash_id = await (0, scope_1.resolveIntegrationId)(client, workspace, identifier, options);
|
|
23
|
+
const exec = await client.getIntegrationExec(workspace, hash_id, execId);
|
|
24
|
+
if (options.format === 'json') {
|
|
25
|
+
output_1.default.json(exec);
|
|
26
|
+
output_1.default.exitNormal();
|
|
27
|
+
}
|
|
28
|
+
output_1.default.table([
|
|
29
|
+
['Property', 'Value'],
|
|
30
|
+
['Execution ID', exec.execution_id || '-'],
|
|
31
|
+
['Operation', (0, utils_1.truncate)(exec.command || '-', 100)],
|
|
32
|
+
['Status', exec.status || '-'],
|
|
33
|
+
['Failure Reason', exec.failure_reason || '-'],
|
|
34
|
+
['Error', (0, utils_1.truncate)(exec.error_message || '-', 200)],
|
|
35
|
+
['Started', exec.started_at || '-'],
|
|
36
|
+
['Finished', exec.finished_at || '-'],
|
|
37
|
+
]);
|
|
38
|
+
output_1.default.exitNormal();
|
|
39
|
+
});
|
|
40
|
+
exports.default = commandIntegrationExecStatus;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const texts_1 = require("../../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../../output"));
|
|
9
|
+
const input_1 = __importDefault(require("../../../input"));
|
|
10
|
+
const scope_1 = require("../scope");
|
|
11
|
+
const mcp_1 = require("../mcp");
|
|
12
|
+
const commandIntegrationExecTool = (0, utils_1.newCommand)('tool', texts_1.DESC_COMMAND_INTEGRATION_EXEC_TOOL, {
|
|
13
|
+
requiredScopes: [utils_1.REST_API_SCOPE.INTEGRATION_USE],
|
|
14
|
+
examples: texts_1.EXAMPLE_INTEGRATION_EXEC_TOOL,
|
|
15
|
+
});
|
|
16
|
+
(0, mcp_1.integrationExecOptions)(commandIntegrationExecTool);
|
|
17
|
+
commandIntegrationExecTool.argument('<tool>', texts_1.OPTION_INTEGRATION_EXEC_TOOL);
|
|
18
|
+
commandIntegrationExecTool.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
19
|
+
commandIntegrationExecTool.action(async (identifier, toolName, options) => {
|
|
20
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
21
|
+
const client = input_1.default.restApiTokenClient();
|
|
22
|
+
const hash_id = await (0, scope_1.resolveIntegrationId)(client, workspace, identifier, options);
|
|
23
|
+
const tool = await (0, mcp_1.runMcp)(client, workspace, hash_id, { operation: 'GET_TOOL', tool: toolName }, (0, mcp_1.integrationRef)(identifier, options));
|
|
24
|
+
if (options.format === 'json') {
|
|
25
|
+
output_1.default.json(tool);
|
|
26
|
+
output_1.default.exitNormal();
|
|
27
|
+
}
|
|
28
|
+
const annotations = tool.annotations || {};
|
|
29
|
+
output_1.default.table([
|
|
30
|
+
['Field', 'Value'],
|
|
31
|
+
['Name', tool.name],
|
|
32
|
+
['Title', tool.title || '-'],
|
|
33
|
+
['Read only', annotations.readOnlyHint ? 'true' : 'false'],
|
|
34
|
+
['Destructive', (0, mcp_1.isDestructiveTool)(tool) ? 'true' : 'false'],
|
|
35
|
+
]);
|
|
36
|
+
if (tool.description) {
|
|
37
|
+
output_1.default.normal('');
|
|
38
|
+
output_1.default.normal(tool.description);
|
|
39
|
+
}
|
|
40
|
+
const rows = (0, mcp_1.toolArgumentRows)(tool);
|
|
41
|
+
if (rows.length) {
|
|
42
|
+
output_1.default.normal('');
|
|
43
|
+
output_1.default.table([['ARGUMENT', 'TYPE', 'REQUIRED', 'DESCRIPTION'], ...rows]);
|
|
44
|
+
}
|
|
45
|
+
output_1.default.exitNormal();
|
|
46
|
+
});
|
|
47
|
+
exports.default = commandIntegrationExecTool;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const texts_1 = require("../../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../../output"));
|
|
9
|
+
const input_1 = __importDefault(require("../../../input"));
|
|
10
|
+
const scope_1 = require("../scope");
|
|
11
|
+
const mcp_1 = require("../mcp");
|
|
12
|
+
const commandIntegrationExecTools = (0, utils_1.newCommand)('tools', texts_1.DESC_COMMAND_INTEGRATION_EXEC_TOOLS, {
|
|
13
|
+
requiredScopes: [utils_1.REST_API_SCOPE.INTEGRATION_USE],
|
|
14
|
+
examples: texts_1.EXAMPLE_INTEGRATION_EXEC_TOOLS,
|
|
15
|
+
});
|
|
16
|
+
(0, mcp_1.integrationExecOptions)(commandIntegrationExecTools);
|
|
17
|
+
commandIntegrationExecTools.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
18
|
+
commandIntegrationExecTools.action(async (identifier, options) => {
|
|
19
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
20
|
+
const client = input_1.default.restApiTokenClient();
|
|
21
|
+
const hash_id = await (0, scope_1.resolveIntegrationId)(client, workspace, identifier, options);
|
|
22
|
+
const result = await (0, mcp_1.runMcp)(client, workspace, hash_id, { operation: 'LIST_TOOLS' }, (0, mcp_1.integrationRef)(identifier, options));
|
|
23
|
+
if (options.format === 'json') {
|
|
24
|
+
output_1.default.json(result);
|
|
25
|
+
output_1.default.exitNormal();
|
|
26
|
+
}
|
|
27
|
+
const tools = (0, mcp_1.mcpToolsOf)(result);
|
|
28
|
+
if (tools.length === 0)
|
|
29
|
+
output_1.default.exitNormal(texts_1.TXT_INTEGRATION_EXEC_NO_TOOLS);
|
|
30
|
+
const data = [['NAME', 'DESCRIPTION']];
|
|
31
|
+
for (const tool of tools) {
|
|
32
|
+
// first line only: descriptions are often whole prompts for a model
|
|
33
|
+
const description = (tool.description || '-').split('\n')[0];
|
|
34
|
+
data.push([tool.name, (0, utils_1.truncate)(description, 100)]);
|
|
35
|
+
}
|
|
36
|
+
output_1.default.table(data);
|
|
37
|
+
output_1.default.exitNormal();
|
|
38
|
+
});
|
|
39
|
+
exports.default = commandIntegrationExecTools;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
const texts_1 = require("../../texts");
|
|
8
|
+
const tools_1 = __importDefault(require("./exec/tools"));
|
|
9
|
+
const tool_1 = __importDefault(require("./exec/tool"));
|
|
10
|
+
const call_1 = __importDefault(require("./exec/call"));
|
|
11
|
+
const list_1 = __importDefault(require("./exec/list"));
|
|
12
|
+
const status_1 = __importDefault(require("./exec/status"));
|
|
13
|
+
const logs_1 = __importDefault(require("./exec/logs"));
|
|
14
|
+
const kill_1 = __importDefault(require("./exec/kill"));
|
|
15
|
+
const commandIntegrationExec = (0, utils_1.newCommand)('exec', texts_1.DESC_COMMAND_INTEGRATION_EXEC, {
|
|
16
|
+
examples: [
|
|
17
|
+
...texts_1.EXAMPLE_INTEGRATION_EXEC_TOOLS,
|
|
18
|
+
...texts_1.EXAMPLE_INTEGRATION_EXEC_TOOL,
|
|
19
|
+
...texts_1.EXAMPLE_INTEGRATION_EXEC_CALL,
|
|
20
|
+
],
|
|
21
|
+
helpText: texts_1.HELP_INTEGRATION_EXEC,
|
|
22
|
+
});
|
|
23
|
+
commandIntegrationExec.addCommand(tools_1.default);
|
|
24
|
+
commandIntegrationExec.addCommand(tool_1.default);
|
|
25
|
+
commandIntegrationExec.addCommand(call_1.default);
|
|
26
|
+
commandIntegrationExec.addCommand(list_1.default);
|
|
27
|
+
commandIntegrationExec.addCommand(status_1.default);
|
|
28
|
+
commandIntegrationExec.addCommand(logs_1.default);
|
|
29
|
+
commandIntegrationExec.addCommand(kill_1.default);
|
|
30
|
+
exports.default = commandIntegrationExec;
|