@cargo-ai/cli 1.0.4 → 1.0.5
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/build/commands/ai/mcpClient.d.ts.map +1 -1
- package/build/commands/ai/mcpClient.js +1 -0
- package/build/commands/orchestration/batch.d.ts.map +1 -1
- package/build/commands/orchestration/batch.js +9 -1
- package/build/commands/orchestration/run.d.ts.map +1 -1
- package/build/commands/orchestration/run.js +9 -1
- package/build/commands/runHandler.d.ts +2 -0
- package/build/commands/runHandler.d.ts.map +1 -1
- package/build/commands/runHandler.js +31 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcpClient.d.ts","sourceRoot":"","sources":["../../../src/commands/ai/mcpClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAGxC,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,MAAM,GAAG,GAChB,IAAI,
|
|
1
|
+
{"version":3,"file":"mcpClient.d.ts","sourceRoot":"","sources":["../../../src/commands/ai/mcpClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAGxC,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,MAAM,GAAG,GAChB,IAAI,CAgDN"}
|
|
@@ -14,6 +14,7 @@ export function registerMcpClientCommands(parent, getApi) {
|
|
|
14
14
|
const api = getApi();
|
|
15
15
|
const result = await handleApiCall(() => api.ai.mcpClient.connect({
|
|
16
16
|
mcpClient: {
|
|
17
|
+
kind: "custom",
|
|
17
18
|
name: opts.name,
|
|
18
19
|
url: opts.url,
|
|
19
20
|
authentication: opts.authentication === undefined
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../../../src/commands/orchestration/batch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../../../src/commands/orchestration/batch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAQxC,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,MAAM,GAAG,GAChB,IAAI,CAwMN"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { handleApiCall, outputJson, parseJson } from "../runHandler.js";
|
|
1
|
+
import { handleApiCall, outputJson, parseJson, pollBatchUntilFinished, } from "../runHandler.js";
|
|
2
2
|
export function registerBatchCommands(parent, getApi) {
|
|
3
3
|
const batch = parent.command("batch").description("Batch operations");
|
|
4
4
|
batch
|
|
@@ -63,6 +63,8 @@ export function registerBatchCommands(parent, getApi) {
|
|
|
63
63
|
.requiredOption("--data <json>", 'Batch data (JSON, e.g. {"kind":"segment","segmentUuid":"..."} or {"kind":"file","s3Filename":"..."})')
|
|
64
64
|
.option("--release-uuid <uuid>", "Release UUID")
|
|
65
65
|
.option("--nodes <json>", 'Custom nodes to override the workflow definition (JSON array). Must include a start node (slug:"start") and an end node (slug:"end"). E.g. [{"uuid":"a","slug":"start","kind":"native","actionSlug":"start","config":{},"childrenUuids":["b"],"fallbackOnFailure":false,"position":{"x":0,"y":0}},{"uuid":"b","slug":"end","kind":"native","actionSlug":"end","config":{},"childrenUuids":[],"fallbackOnFailure":false,"position":{"x":1,"y":0}}]')
|
|
66
|
+
.option("--wait-until-finished", "Poll the batch until it reaches a terminal status before returning")
|
|
67
|
+
.option("--polling-interval <ms>", "Polling interval in milliseconds (used with --wait-until-finished)", "5000")
|
|
66
68
|
.action(async (opts) => {
|
|
67
69
|
const api = getApi();
|
|
68
70
|
const result = await handleApiCall(() => api.orchestration.batch.create({
|
|
@@ -73,6 +75,12 @@ export function registerBatchCommands(parent, getApi) {
|
|
|
73
75
|
: undefined,
|
|
74
76
|
data: parseJson(opts.data, "--data"),
|
|
75
77
|
}));
|
|
78
|
+
if (opts.waitUntilFinished === true) {
|
|
79
|
+
const intervalMs = parseInt(opts.pollingInterval, 10);
|
|
80
|
+
const finalResult = await pollBatchUntilFinished(() => api.orchestration.batch.get(result.batch.uuid), (r) => r.batch.status, intervalMs);
|
|
81
|
+
outputJson(finalResult);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
76
84
|
outputJson(result);
|
|
77
85
|
});
|
|
78
86
|
batch
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/commands/orchestration/run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/commands/orchestration/run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAQxC,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,GAAG,IAAI,CAiV5E"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { handleApiCall, outputJson, parseJson } from "../runHandler.js";
|
|
1
|
+
import { handleApiCall, outputJson, parseJson, pollRunUntilFinished, } from "../runHandler.js";
|
|
2
2
|
export function registerRunCommands(parent, getApi) {
|
|
3
3
|
const run = parent.command("run").description("Run operations");
|
|
4
4
|
run
|
|
@@ -63,6 +63,8 @@ export function registerRunCommands(parent, getApi) {
|
|
|
63
63
|
.requiredOption("--data <json>", "Run data (JSON, e.g. {...})")
|
|
64
64
|
.option("--release-uuid <uuid>", "Release UUID")
|
|
65
65
|
.option("--nodes <json>", 'Custom nodes to override the workflow definition (JSON array). Must include a start node (slug:"start") and an end node (slug:"end"). E.g. [{"uuid":"a","slug":"start","kind":"native","actionSlug":"start","config":{},"childrenUuids":["b"],"fallbackOnFailure":false,"position":{"x":0,"y":0}},{"uuid":"b","slug":"end","kind":"native","actionSlug":"end","config":{},"childrenUuids":[],"fallbackOnFailure":false,"position":{"x":1,"y":0}}]')
|
|
66
|
+
.option("--wait-until-finished", "Poll the run until it reaches a terminal status before returning")
|
|
67
|
+
.option("--polling-interval <ms>", "Polling interval in milliseconds (used with --wait-until-finished)", "5000")
|
|
66
68
|
.action(async (opts) => {
|
|
67
69
|
const data = parseJson(opts.data, "--data");
|
|
68
70
|
const api = getApi();
|
|
@@ -74,6 +76,12 @@ export function registerRunCommands(parent, getApi) {
|
|
|
74
76
|
: undefined,
|
|
75
77
|
data,
|
|
76
78
|
}));
|
|
79
|
+
if (opts.waitUntilFinished === true) {
|
|
80
|
+
const intervalMs = parseInt(opts.pollingInterval, 10);
|
|
81
|
+
const finalResult = await pollRunUntilFinished(() => api.orchestration.run.get(result.run.uuid), (r) => r.run.status, intervalMs);
|
|
82
|
+
outputJson(finalResult);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
77
85
|
outputJson(result);
|
|
78
86
|
});
|
|
79
87
|
run
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export declare function outputJson(value: unknown): void;
|
|
2
2
|
export declare function parseJson(value: string, optionName: string): any;
|
|
3
3
|
export declare function handleApiCall<T>(fn: () => Promise<T>): Promise<T | never>;
|
|
4
|
+
export declare function pollRunUntilFinished<T>(getResult: () => Promise<T>, getStatus: (result: T) => string, intervalMs: number): Promise<T>;
|
|
5
|
+
export declare function pollBatchUntilFinished<T>(getResult: () => Promise<T>, getStatus: (result: T) => string, intervalMs: number): Promise<T>;
|
|
4
6
|
//# sourceMappingURL=runHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runHandler.d.ts","sourceRoot":"","sources":["../../src/commands/runHandler.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAE/C;AAGD,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,GAAG,CAWhE;AAED,wBAAsB,aAAa,CAAC,CAAC,EACnC,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,GAAG,KAAK,CAAC,CAiBpB"}
|
|
1
|
+
{"version":3,"file":"runHandler.d.ts","sourceRoot":"","sources":["../../src/commands/runHandler.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAE/C;AAGD,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,GAAG,CAWhE;AAED,wBAAsB,aAAa,CAAC,CAAC,EACnC,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,GAAG,KAAK,CAAC,CAiBpB;AAoBD,wBAAsB,oBAAoB,CAAC,CAAC,EAC1C,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAC3B,SAAS,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,MAAM,EAChC,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,CAAC,CAAC,CASZ;AAED,wBAAsB,sBAAsB,CAAC,CAAC,EAC5C,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAC3B,SAAS,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,MAAM,EAChC,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,CAAC,CAAC,CASZ"}
|
|
@@ -31,3 +31,34 @@ export async function handleApiCall(fn) {
|
|
|
31
31
|
throw err;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
+
function sleep(ms) {
|
|
35
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
36
|
+
}
|
|
37
|
+
const TERMINAL_RUN_STATUSES = new Set([
|
|
38
|
+
"success",
|
|
39
|
+
"error",
|
|
40
|
+
"cancelled",
|
|
41
|
+
"skipped",
|
|
42
|
+
]);
|
|
43
|
+
const TERMINAL_BATCH_STATUSES = new Set([
|
|
44
|
+
"success",
|
|
45
|
+
"error",
|
|
46
|
+
"cancelled",
|
|
47
|
+
"skipped",
|
|
48
|
+
]);
|
|
49
|
+
export async function pollRunUntilFinished(getResult, getStatus, intervalMs) {
|
|
50
|
+
let result = await handleApiCall(getResult);
|
|
51
|
+
while (!TERMINAL_RUN_STATUSES.has(getStatus(result))) {
|
|
52
|
+
await sleep(intervalMs);
|
|
53
|
+
result = await handleApiCall(getResult);
|
|
54
|
+
}
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
export async function pollBatchUntilFinished(getResult, getStatus, intervalMs) {
|
|
58
|
+
let result = await handleApiCall(getResult);
|
|
59
|
+
while (!TERMINAL_BATCH_STATUSES.has(getStatus(result))) {
|
|
60
|
+
await sleep(intervalMs);
|
|
61
|
+
result = await handleApiCall(getResult);
|
|
62
|
+
}
|
|
63
|
+
return result;
|
|
64
|
+
}
|