@cargo-ai/cli 1.0.14 → 1.0.16
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/README.md +2 -1
- package/build/commands/connection/customIntegration.d.ts +4 -0
- package/build/commands/connection/customIntegration.d.ts.map +1 -0
- package/build/commands/connection/customIntegration.js +98 -0
- package/build/commands/connection/index.d.ts.map +1 -1
- package/build/commands/connection/index.js +2 -0
- package/build/commands/context/{skill.d.ts → graph.d.ts} +2 -2
- package/build/commands/context/graph.d.ts.map +1 -0
- package/build/commands/context/graph.js +14 -0
- package/build/commands/context/index.js +5 -5
- package/build/commands/context/runtime.d.ts +4 -0
- package/build/commands/context/runtime.d.ts.map +1 -0
- package/build/commands/context/runtime.js +80 -0
- package/build/commands/{orchestration/log.d.ts → hosting/app.d.ts} +2 -2
- package/build/commands/hosting/app.d.ts.map +1 -0
- package/build/commands/hosting/app.js +190 -0
- package/build/commands/hosting/deployment.d.ts +4 -0
- package/build/commands/hosting/deployment.d.ts.map +1 -0
- package/build/commands/hosting/deployment.js +125 -0
- package/build/commands/hosting/index.d.ts +4 -0
- package/build/commands/hosting/index.d.ts.map +1 -0
- package/build/commands/hosting/index.js +11 -0
- package/build/commands/hosting/templateUtils.d.ts +6 -0
- package/build/commands/hosting/templateUtils.d.ts.map +1 -0
- package/build/commands/hosting/templateUtils.js +30 -0
- package/build/commands/hosting/worker.d.ts +4 -0
- package/build/commands/hosting/worker.d.ts.map +1 -0
- package/build/commands/hosting/worker.js +174 -0
- package/build/commands/orchestration/index.d.ts.map +1 -1
- package/build/commands/orchestration/index.js +4 -2
- package/build/commands/orchestration/query.js +2 -2
- package/build/commands/{context/file.d.ts → orchestration/span.d.ts} +2 -2
- package/build/commands/orchestration/span.d.ts.map +1 -0
- package/build/commands/orchestration/{log.js → span.js} +8 -8
- package/build/commands/orchestration/trace.d.ts +4 -0
- package/build/commands/orchestration/trace.d.ts.map +1 -0
- package/build/commands/orchestration/trace.js +56 -0
- package/build/commands/storage/query.d.ts.map +1 -1
- package/build/commands/storage/query.js +23 -0
- package/build/commands/storage/record.d.ts.map +1 -1
- package/build/commands/storage/record.js +51 -0
- package/build/index.js +2 -0
- package/package.json +5 -3
- package/build/commands/context/file.d.ts.map +0 -1
- package/build/commands/context/file.js +0 -39
- package/build/commands/context/skill.d.ts.map +0 -1
- package/build/commands/context/skill.js +0 -21
- package/build/commands/orchestration/log.d.ts.map +0 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { promises as fs } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
export const listTemplates = async (root) => {
|
|
4
|
+
try {
|
|
5
|
+
const entries = await fs.readdir(root, { withFileTypes: true });
|
|
6
|
+
return entries
|
|
7
|
+
.filter((entry) => entry.isDirectory() === true)
|
|
8
|
+
.map((entry) => entry.name)
|
|
9
|
+
.filter((name) => name.startsWith("_") === false);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
export const copyDirectory = async (src, dest, rename) => {
|
|
16
|
+
const entries = await fs.readdir(src, { withFileTypes: true });
|
|
17
|
+
await fs.mkdir(dest, { recursive: true });
|
|
18
|
+
for (const entry of entries) {
|
|
19
|
+
const srcPath = path.join(src, entry.name);
|
|
20
|
+
const destPath = path.join(dest, entry.name);
|
|
21
|
+
if (entry.isDirectory() === true) {
|
|
22
|
+
await copyDirectory(srcPath, destPath, rename);
|
|
23
|
+
}
|
|
24
|
+
else if (entry.isFile() === true) {
|
|
25
|
+
const raw = await fs.readFile(srcPath, "utf-8");
|
|
26
|
+
const replaced = rename.reduce((current, { from, to }) => current.split(from).join(to), raw);
|
|
27
|
+
await fs.writeFile(destPath, replaced, "utf-8");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../../src/commands/hosting/worker.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAMxC,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,MAAM,GAAG,GAChB,IAAI,CA8MN"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { promises as fs } from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { handleApiCall, outputJson } from "../runHandler.js";
|
|
6
|
+
import { copyDirectory, listTemplates } from "./templateUtils.js";
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
export function registerWorkerCommands(parent, getApi) {
|
|
9
|
+
const worker = parent
|
|
10
|
+
.command("worker")
|
|
11
|
+
.description("Manage Cargo Hosting workers (serverless HTTP handlers running on the edge)");
|
|
12
|
+
worker
|
|
13
|
+
.command("list")
|
|
14
|
+
.description("List workers in the current workspace")
|
|
15
|
+
.option("--folder-uuid <uuid>", "Filter by folder UUID")
|
|
16
|
+
.action(async (opts) => {
|
|
17
|
+
const api = getApi();
|
|
18
|
+
const result = await handleApiCall(() => api.hosting.worker.list({
|
|
19
|
+
folderUuid: opts.folderUuid,
|
|
20
|
+
}));
|
|
21
|
+
outputJson(result);
|
|
22
|
+
});
|
|
23
|
+
worker
|
|
24
|
+
.command("get <uuid>")
|
|
25
|
+
.description("Show details of a single worker")
|
|
26
|
+
.action(async (uuid) => {
|
|
27
|
+
const api = getApi();
|
|
28
|
+
const result = await handleApiCall(() => api.hosting.worker.get(uuid));
|
|
29
|
+
outputJson(result);
|
|
30
|
+
});
|
|
31
|
+
worker
|
|
32
|
+
.command("create")
|
|
33
|
+
.description("Create a new worker slot")
|
|
34
|
+
.requiredOption("--name <name>", "Display name for the worker")
|
|
35
|
+
.requiredOption("--slug <slug>", "URL slug (must be globally unique within the hosting domain)")
|
|
36
|
+
.option("--folder-uuid <uuid>", "Optional folder UUID")
|
|
37
|
+
.action(async (opts) => {
|
|
38
|
+
const api = getApi();
|
|
39
|
+
const result = await handleApiCall(() => api.hosting.worker.create({
|
|
40
|
+
name: opts.name,
|
|
41
|
+
slug: opts.slug,
|
|
42
|
+
folderUuid: opts.folderUuid,
|
|
43
|
+
}));
|
|
44
|
+
outputJson(result);
|
|
45
|
+
});
|
|
46
|
+
worker
|
|
47
|
+
.command("update")
|
|
48
|
+
.description("Update an existing worker (name, folder)")
|
|
49
|
+
.requiredOption("--uuid <uuid>", "Worker UUID")
|
|
50
|
+
.option("--name <name>", "New display name")
|
|
51
|
+
.option("--folder-uuid <uuid>", "New folder UUID (pass 'null' to move to the workspace root)")
|
|
52
|
+
.action(async (opts) => {
|
|
53
|
+
const api = getApi();
|
|
54
|
+
const result = await handleApiCall(() => api.hosting.worker.update({
|
|
55
|
+
uuid: opts.uuid,
|
|
56
|
+
name: opts.name,
|
|
57
|
+
folderUuid: opts.folderUuid === "null" ? null : opts.folderUuid,
|
|
58
|
+
}));
|
|
59
|
+
outputJson(result);
|
|
60
|
+
});
|
|
61
|
+
worker
|
|
62
|
+
.command("remove <uuid>")
|
|
63
|
+
.description("Remove a worker (also removes its deployments)")
|
|
64
|
+
.action(async (uuid) => {
|
|
65
|
+
const api = getApi();
|
|
66
|
+
await handleApiCall(() => api.hosting.worker.remove(uuid));
|
|
67
|
+
outputJson({ ok: true });
|
|
68
|
+
});
|
|
69
|
+
worker
|
|
70
|
+
.command("init <directory>")
|
|
71
|
+
.description("Scaffold a new Cargo Hosting worker locally from a template (edge `fetch(request, env)` handler).")
|
|
72
|
+
.option("--template <slug>", "Template slug (default: blank)", "blank")
|
|
73
|
+
.option("--name <name>", "Worker name written into package.json (default: directory name)")
|
|
74
|
+
.option("--list-templates", "Print available templates and exit")
|
|
75
|
+
.action(async (directory, opts) => {
|
|
76
|
+
const templatesRoot = findWorkerTemplatesRoot();
|
|
77
|
+
if (opts.listTemplates === true) {
|
|
78
|
+
const slugs = await listTemplates(templatesRoot);
|
|
79
|
+
if (slugs.length === 0) {
|
|
80
|
+
console.error(JSON.stringify({ error: "No templates found", templatesRoot }));
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|
|
83
|
+
console.log(JSON.stringify(slugs.map((slug) => ({
|
|
84
|
+
slug,
|
|
85
|
+
description: WORKER_TEMPLATE_DESCRIPTIONS[slug] !== undefined
|
|
86
|
+
? WORKER_TEMPLATE_DESCRIPTIONS[slug]
|
|
87
|
+
: "",
|
|
88
|
+
})), null, 2));
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const templateDir = path.join(templatesRoot, opts.template);
|
|
92
|
+
try {
|
|
93
|
+
const stat = await fs.stat(templateDir);
|
|
94
|
+
if (stat.isDirectory() === false) {
|
|
95
|
+
throw new Error("Template path is not a directory");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
const slugs = await listTemplates(templatesRoot);
|
|
100
|
+
console.error(JSON.stringify({
|
|
101
|
+
error: `Unknown template "${opts.template}"`,
|
|
102
|
+
available: slugs,
|
|
103
|
+
}));
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
const targetDir = path.resolve(directory);
|
|
107
|
+
try {
|
|
108
|
+
const stat = await fs.stat(targetDir);
|
|
109
|
+
if (stat.isDirectory() === true) {
|
|
110
|
+
const entries = await fs.readdir(targetDir);
|
|
111
|
+
if (entries.length > 0) {
|
|
112
|
+
console.error(JSON.stringify({
|
|
113
|
+
error: `Target directory ${targetDir} is not empty.`,
|
|
114
|
+
}));
|
|
115
|
+
process.exit(1);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
// Target does not exist yet — that's fine.
|
|
121
|
+
}
|
|
122
|
+
const workerName = opts.name !== undefined ? opts.name : path.basename(targetDir);
|
|
123
|
+
await copyDirectory(templateDir, targetDir, [
|
|
124
|
+
{ from: "__APP_NAME__", to: workerName },
|
|
125
|
+
{ from: "__TEMPLATE_SLUG__", to: opts.template },
|
|
126
|
+
]);
|
|
127
|
+
const nextSteps = [
|
|
128
|
+
`cd ${path.relative(process.cwd(), targetDir)}`,
|
|
129
|
+
"npm install",
|
|
130
|
+
`cargo-ai hosting worker create --name '${workerName}' --slug '<your-slug>'`,
|
|
131
|
+
"npm run build",
|
|
132
|
+
"cargo-ai hosting deployment create --worker-uuid <workerUuid> --source ./dist",
|
|
133
|
+
"cargo-ai hosting deployment promote --uuid <deploymentUuid>",
|
|
134
|
+
];
|
|
135
|
+
if (opts.template === "custom-integration") {
|
|
136
|
+
nextSteps.push("cargo-ai connection custom-integration create --kind worker --worker-uuid <workerUuid>");
|
|
137
|
+
}
|
|
138
|
+
console.log(JSON.stringify({
|
|
139
|
+
ok: true,
|
|
140
|
+
directory: targetDir,
|
|
141
|
+
template: opts.template,
|
|
142
|
+
name: workerName,
|
|
143
|
+
nextSteps,
|
|
144
|
+
}, null, 2));
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
const WORKER_TEMPLATE_DESCRIPTIONS = {
|
|
148
|
+
blank: "Edge worker built on @cargo-ai/worker-sdk with automatic OpenAPI 3.1 spec at /openapi.json and Swagger UI at /docs.",
|
|
149
|
+
"custom-integration": "Cargo Custom Integration worker built on @cargo-ai/worker-sdk — manifest / actions / extractors / autocompletes / dynamic schemas with automatic /openapi.json.",
|
|
150
|
+
};
|
|
151
|
+
const findWorkerTemplatesRoot = () => {
|
|
152
|
+
// Worker templates live in `@cargo-ai/worker-sdk/templates`. Resolve via
|
|
153
|
+
// require so we work whether the user installed both packages globally or
|
|
154
|
+
// both came from the monorepo.
|
|
155
|
+
try {
|
|
156
|
+
const workerSdkPackageJson = require.resolve("@cargo-ai/worker-sdk/package.json");
|
|
157
|
+
return path.join(path.dirname(workerSdkPackageJson), "templates");
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
const here = fileURLToPath(import.meta.url);
|
|
161
|
+
let cursor = path.dirname(here);
|
|
162
|
+
for (let i = 0; i < 6; i += 1) {
|
|
163
|
+
const candidate = path.join(cursor, "packages/worker-sdk/templates");
|
|
164
|
+
try {
|
|
165
|
+
require("node:fs").accessSync(candidate);
|
|
166
|
+
return candidate;
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
cursor = path.dirname(cursor);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
throw new Error("Could not locate @cargo-ai/worker-sdk templates. Make sure @cargo-ai/worker-sdk is installed alongside @cargo-ai/cli.");
|
|
173
|
+
}
|
|
174
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/orchestration/index.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":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/orchestration/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAgBxC,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,MAAM,GAAG,GAChB,IAAI,CAmBN"}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { registerActionCommands } from "./action.js";
|
|
2
2
|
import { registerBatchCommands } from "./batch.js";
|
|
3
3
|
import { registerDraftReleaseCommands } from "./draftRelease.js";
|
|
4
|
-
import { registerLogCommands } from "./log.js";
|
|
5
4
|
import { registerNodeCommands } from "./node.js";
|
|
6
5
|
import { registerPlayCommands } from "./play.js";
|
|
7
6
|
import { registerQueryCommands } from "./query.js";
|
|
8
7
|
import { registerRecordCommands } from "./record.js";
|
|
9
8
|
import { registerReleaseCommands } from "./release.js";
|
|
10
9
|
import { registerRunCommands } from "./run.js";
|
|
10
|
+
import { registerSpanCommands } from "./span.js";
|
|
11
11
|
import { registerTemplateCommands } from "./template.js";
|
|
12
12
|
import { registerToolCommands } from "./tool.js";
|
|
13
|
+
import { registerTraceCommands } from "./trace.js";
|
|
13
14
|
import { registerWorkflowCommands } from "./workflow.js";
|
|
14
15
|
export function registerOrchestrationCommands(parent, getApi) {
|
|
15
16
|
const orchestration = parent
|
|
@@ -20,7 +21,8 @@ export function registerOrchestrationCommands(parent, getApi) {
|
|
|
20
21
|
registerPlayCommands(orchestration, getApi);
|
|
21
22
|
registerRunCommands(orchestration, getApi);
|
|
22
23
|
registerBatchCommands(orchestration, getApi);
|
|
23
|
-
|
|
24
|
+
registerSpanCommands(orchestration, getApi);
|
|
25
|
+
registerTraceCommands(orchestration, getApi);
|
|
24
26
|
registerReleaseCommands(orchestration, getApi);
|
|
25
27
|
registerDraftReleaseCommands(orchestration, getApi);
|
|
26
28
|
registerToolCommands(orchestration, getApi);
|
|
@@ -8,12 +8,12 @@ export function registerQueryCommands(parent, getApi) {
|
|
|
8
8
|
.description("Execute a read-only SQL query")
|
|
9
9
|
.argument("<sql>", "SQL query string")
|
|
10
10
|
.addHelpText("after", `
|
|
11
|
-
Available tables:
|
|
11
|
+
Available tables: spans, runs, batches, records
|
|
12
12
|
|
|
13
13
|
Examples:
|
|
14
14
|
$ cargo-ai orchestration query execute "SELECT count() FROM runs"
|
|
15
15
|
$ cargo-ai orchestration query execute "SELECT status, count() FROM batches GROUP BY status"
|
|
16
|
-
$ cargo-ai orchestration query execute "SELECT * FROM
|
|
16
|
+
$ cargo-ai orchestration query execute "SELECT * FROM spans ORDER BY execution_started_at DESC LIMIT 10"
|
|
17
17
|
$ cargo-ai orchestration query execute "WITH recent AS (SELECT * FROM runs WHERE created_at > now() - INTERVAL 1 DAY) SELECT status, count() FROM recent GROUP BY status"`)
|
|
18
18
|
.action(async (sql) => {
|
|
19
19
|
const api = getApi();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Command } from "commander";
|
|
2
2
|
import type { Api } from "../../api.js";
|
|
3
|
-
export declare function
|
|
4
|
-
//# sourceMappingURL=
|
|
3
|
+
export declare function registerSpanCommands(parent: Command, getApi: () => Api): void;
|
|
4
|
+
//# sourceMappingURL=span.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"span.d.ts","sourceRoot":"","sources":["../../../src/commands/orchestration/span.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAGxC,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,GAAG,IAAI,CAwO7E"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { handleApiCall, outputJson } from "../runHandler.js";
|
|
2
|
-
export function
|
|
3
|
-
const
|
|
4
|
-
|
|
2
|
+
export function registerSpanCommands(parent, getApi) {
|
|
3
|
+
const span = parent.command("span").description("Execution span operations");
|
|
4
|
+
span
|
|
5
5
|
.command("list")
|
|
6
|
-
.description("List execution
|
|
6
|
+
.description("List execution spans")
|
|
7
7
|
.option("--workflow-uuid <uuid>", "Workflow UUID (omit to include all workflows in the workspace)")
|
|
8
8
|
.option("--batch-uuid <uuid>", "Batch UUID")
|
|
9
9
|
.option("--run-uuid <uuid>", "Run UUID")
|
|
@@ -29,7 +29,7 @@ export function registerLogCommands(parent, getApi) {
|
|
|
29
29
|
.option("--offset <n>", "Offset", "0")
|
|
30
30
|
.action(async (opts) => {
|
|
31
31
|
const api = getApi();
|
|
32
|
-
const result = await handleApiCall(() => api.orchestration.
|
|
32
|
+
const result = await handleApiCall(() => api.orchestration.span.list({
|
|
33
33
|
workflowUuid: opts.workflowUuid,
|
|
34
34
|
batchUuid: opts.batchUuid,
|
|
35
35
|
runUuid: opts.runUuid,
|
|
@@ -62,9 +62,9 @@ export function registerLogCommands(parent, getApi) {
|
|
|
62
62
|
}));
|
|
63
63
|
outputJson(result);
|
|
64
64
|
});
|
|
65
|
-
|
|
65
|
+
span
|
|
66
66
|
.command("count")
|
|
67
|
-
.description("Count execution
|
|
67
|
+
.description("Count execution spans")
|
|
68
68
|
.option("--workflow-uuid <uuid>", "Workflow UUID (omit to include all workflows in the workspace)")
|
|
69
69
|
.option("--batch-uuid <uuid>", "Batch UUID")
|
|
70
70
|
.option("--run-uuid <uuid>", "Run UUID")
|
|
@@ -88,7 +88,7 @@ export function registerLogCommands(parent, getApi) {
|
|
|
88
88
|
.option("--execution-started-before <date>", "Execution started on or before (ISO date)")
|
|
89
89
|
.action(async (opts) => {
|
|
90
90
|
const api = getApi();
|
|
91
|
-
const result = await handleApiCall(() => api.orchestration.
|
|
91
|
+
const result = await handleApiCall(() => api.orchestration.span.count({
|
|
92
92
|
workflowUuid: opts.workflowUuid,
|
|
93
93
|
batchUuid: opts.batchUuid,
|
|
94
94
|
runUuid: opts.runUuid,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../../../src/commands/orchestration/trace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAGxC,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,MAAM,GAAG,GAChB,IAAI,CAiHN"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { handleApiCall, outputJson } from "../runHandler.js";
|
|
2
|
+
export function registerTraceCommands(parent, getApi) {
|
|
3
|
+
const trace = parent
|
|
4
|
+
.command("trace")
|
|
5
|
+
.description("Trace operations (per-execution aggregation across the run lineage)");
|
|
6
|
+
trace
|
|
7
|
+
.command("list")
|
|
8
|
+
.description("List traces (aggregated over their spans)")
|
|
9
|
+
.option("--workflow-uuid <uuid>", "Workflow UUID (omit to include all workflows in the workspace)")
|
|
10
|
+
.option("--statuses <list>", "Comma-separated trace statuses (pending, error, success)")
|
|
11
|
+
.requiredOption("--started-after <date>", "Trace's first span started after (ISO date)")
|
|
12
|
+
.option("--started-before <date>", "Trace's first span started on or before (ISO date)")
|
|
13
|
+
.option("--limit <n>", "Limit", "30")
|
|
14
|
+
.option("--offset <n>", "Offset", "0")
|
|
15
|
+
.action(async (opts) => {
|
|
16
|
+
const api = getApi();
|
|
17
|
+
const result = await handleApiCall(() => api.orchestration.trace.list({
|
|
18
|
+
workflowUuid: opts.workflowUuid,
|
|
19
|
+
statuses: opts.statuses !== undefined
|
|
20
|
+
? opts.statuses.split(",").map((s) => s.trim())
|
|
21
|
+
: undefined,
|
|
22
|
+
startedAfter: opts.startedAfter,
|
|
23
|
+
startedBefore: opts.startedBefore,
|
|
24
|
+
limit: opts.limit !== undefined ? parseInt(opts.limit, 10) : undefined,
|
|
25
|
+
offset: opts.offset !== undefined ? parseInt(opts.offset, 10) : undefined,
|
|
26
|
+
}));
|
|
27
|
+
outputJson(result);
|
|
28
|
+
});
|
|
29
|
+
trace
|
|
30
|
+
.command("count")
|
|
31
|
+
.description("Count traces matching the filter")
|
|
32
|
+
.option("--workflow-uuid <uuid>", "Workflow UUID (omit to include all workflows in the workspace)")
|
|
33
|
+
.option("--statuses <list>", "Comma-separated trace statuses (pending, error, success)")
|
|
34
|
+
.requiredOption("--started-after <date>", "Trace's first span started after (ISO date)")
|
|
35
|
+
.option("--started-before <date>", "Trace's first span started on or before (ISO date)")
|
|
36
|
+
.action(async (opts) => {
|
|
37
|
+
const api = getApi();
|
|
38
|
+
const result = await handleApiCall(() => api.orchestration.trace.count({
|
|
39
|
+
workflowUuid: opts.workflowUuid,
|
|
40
|
+
statuses: opts.statuses !== undefined
|
|
41
|
+
? opts.statuses.split(",").map((s) => s.trim())
|
|
42
|
+
: undefined,
|
|
43
|
+
startedAfter: opts.startedAfter,
|
|
44
|
+
startedBefore: opts.startedBefore,
|
|
45
|
+
}));
|
|
46
|
+
outputJson(result);
|
|
47
|
+
});
|
|
48
|
+
trace
|
|
49
|
+
.command("get <uuid>")
|
|
50
|
+
.description("Get a single trace by UUID")
|
|
51
|
+
.action(async (uuid) => {
|
|
52
|
+
const api = getApi();
|
|
53
|
+
const result = await handleApiCall(() => api.orchestration.trace.get(uuid));
|
|
54
|
+
outputJson(result);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/commands/storage/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAGxC,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,MAAM,GAAG,GAChB,IAAI,
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/commands/storage/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAGxC,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,MAAM,GAAG,GAChB,IAAI,CA4DN"}
|
|
@@ -20,4 +20,27 @@ Examples:
|
|
|
20
20
|
const result = await handleApiCall(() => api.storage.query.execute({ query: sql }));
|
|
21
21
|
outputJson(result);
|
|
22
22
|
});
|
|
23
|
+
query
|
|
24
|
+
.command("download")
|
|
25
|
+
.description("Download the result of a SQL query against storage models as files")
|
|
26
|
+
.requiredOption("--query <sql>", "SQL query string")
|
|
27
|
+
.option("--format <format>", "Download format (csv or parquet)", "csv")
|
|
28
|
+
.addHelpText("after", `
|
|
29
|
+
Tables must be referenced as [datasetSlug].[modelSlug] and are rewritten
|
|
30
|
+
to the underlying warehouse table under the hood. Returns signed URLs to
|
|
31
|
+
download the resulting files.
|
|
32
|
+
|
|
33
|
+
Examples:
|
|
34
|
+
$ cargo-ai storage query download --query "SELECT * FROM my_dataset.my_model"
|
|
35
|
+
$ cargo-ai storage query download --query "SELECT * FROM sales.accounts" --format parquet`)
|
|
36
|
+
.action(async (opts) => {
|
|
37
|
+
const api = getApi();
|
|
38
|
+
const format = opts.format === "parquet"
|
|
39
|
+
? "parquet"
|
|
40
|
+
: opts.format === "csv"
|
|
41
|
+
? "csv"
|
|
42
|
+
: undefined;
|
|
43
|
+
const result = await handleApiCall(() => api.storage.query.download({ query: opts.query, format }));
|
|
44
|
+
outputJson(result);
|
|
45
|
+
});
|
|
23
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../../src/commands/storage/record.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAGxC,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,MAAM,GAAG,GAChB,IAAI,
|
|
1
|
+
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../../src/commands/storage/record.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAGxC,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,MAAM,GAAG,GAChB,IAAI,CAsON"}
|
|
@@ -100,4 +100,55 @@ Example:
|
|
|
100
100
|
}));
|
|
101
101
|
outputJson({ ok: true });
|
|
102
102
|
});
|
|
103
|
+
record
|
|
104
|
+
.command("create-bulk")
|
|
105
|
+
.description("Create multiple storage records in a single call")
|
|
106
|
+
.requiredOption("--model-uuid <uuid>", "Model UUID (string, required)")
|
|
107
|
+
.requiredOption("--records <json>", 'JSON array of record entries: [{ "data": { ... } }, ...]')
|
|
108
|
+
.addHelpText("after", `
|
|
109
|
+
Example:
|
|
110
|
+
$ cargo-ai storage record create-bulk --model-uuid 550e8400-... \\
|
|
111
|
+
--records '[{"data":{"name":"Ada"}},{"data":{"name":"Lin"}}]'`)
|
|
112
|
+
.action(async (opts) => {
|
|
113
|
+
const api = getApi();
|
|
114
|
+
const result = await handleApiCall(() => api.storage.record.createBulk({
|
|
115
|
+
modelUuid: opts.modelUuid,
|
|
116
|
+
records: parseJson(opts.records, "--records"),
|
|
117
|
+
}));
|
|
118
|
+
outputJson(result);
|
|
119
|
+
});
|
|
120
|
+
record
|
|
121
|
+
.command("update-bulk")
|
|
122
|
+
.description("Update multiple storage records in a single call")
|
|
123
|
+
.requiredOption("--model-uuid <uuid>", "Model UUID (string, required)")
|
|
124
|
+
.requiredOption("--records <json>", 'JSON array of record entries: [{ "id": "rec_1", "data": { ... } }, ...]')
|
|
125
|
+
.addHelpText("after", `
|
|
126
|
+
Example:
|
|
127
|
+
$ cargo-ai storage record update-bulk --model-uuid 550e8400-... \\
|
|
128
|
+
--records '[{"id":"rec_1","data":{"status":"done"}},{"id":"rec_2","data":{"status":"done"}}]'`)
|
|
129
|
+
.action(async (opts) => {
|
|
130
|
+
const api = getApi();
|
|
131
|
+
const result = await handleApiCall(() => api.storage.record.updateBulk({
|
|
132
|
+
modelUuid: opts.modelUuid,
|
|
133
|
+
records: parseJson(opts.records, "--records"),
|
|
134
|
+
}));
|
|
135
|
+
outputJson(result);
|
|
136
|
+
});
|
|
137
|
+
record
|
|
138
|
+
.command("remove-bulk")
|
|
139
|
+
.description("Remove multiple storage records in a single call")
|
|
140
|
+
.requiredOption("--model-uuid <uuid>", "Model UUID (string, required)")
|
|
141
|
+
.requiredOption("--ids <json>", 'JSON array of record IDs: ["rec_1", "rec_2", ...]')
|
|
142
|
+
.addHelpText("after", `
|
|
143
|
+
Example:
|
|
144
|
+
$ cargo-ai storage record remove-bulk --model-uuid 550e8400-... \\
|
|
145
|
+
--ids '["rec_1","rec_2","rec_3"]'`)
|
|
146
|
+
.action(async (opts) => {
|
|
147
|
+
const api = getApi();
|
|
148
|
+
await handleApiCall(() => api.storage.record.removeBulk({
|
|
149
|
+
modelUuid: opts.modelUuid,
|
|
150
|
+
ids: parseJson(opts.ids, "--ids"),
|
|
151
|
+
}));
|
|
152
|
+
outputJson({ ok: true });
|
|
153
|
+
});
|
|
103
154
|
}
|
package/build/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import { registerBillingCommands } from "./commands/billing/index.js";
|
|
|
8
8
|
import { registerConnectionCommands } from "./commands/connection/index.js";
|
|
9
9
|
import { registerContextCommands } from "./commands/context/index.js";
|
|
10
10
|
import { registerExpressionCommands } from "./commands/expression/index.js";
|
|
11
|
+
import { registerHostingCommands } from "./commands/hosting/index.js";
|
|
11
12
|
import { registerInitCommand } from "./commands/init.js";
|
|
12
13
|
import { registerOrchestrationCommands } from "./commands/orchestration/index.js";
|
|
13
14
|
import { registerRevenueOrganizationCommands } from "./commands/revenueOrganization/index.js";
|
|
@@ -65,6 +66,7 @@ registerExpressionCommands(program, getApi);
|
|
|
65
66
|
registerSystemOfRecordIntegrationCommands(program, getApi);
|
|
66
67
|
registerUserManagementCommands(program, getApi);
|
|
67
68
|
registerAiCommands(program, getApi);
|
|
69
|
+
registerHostingCommands(program, getApi);
|
|
68
70
|
program.parseAsync().catch((err) => {
|
|
69
71
|
failWith(err instanceof Error ? err.message : String(err));
|
|
70
72
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cargo-ai/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.16",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Command-line interface for the Cargo API",
|
|
6
6
|
"engines": {
|
|
@@ -28,8 +28,10 @@
|
|
|
28
28
|
"format:check": "prettier --check ."
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"
|
|
32
|
-
"@cargo-ai/
|
|
31
|
+
"@cargo-ai/api": "^1.0.24",
|
|
32
|
+
"@cargo-ai/app-sdk": "^1.0.0",
|
|
33
|
+
"@cargo-ai/worker-sdk": "^1.0.0",
|
|
34
|
+
"commander": "^12.1.0"
|
|
33
35
|
},
|
|
34
36
|
"devDependencies": {
|
|
35
37
|
"@cargo-ai/eslint-config": "*",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../../src/commands/context/file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAGxC,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,GAAG,IAAI,CAqD7E"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { handleApiCall, outputJson } from "../runHandler.js";
|
|
2
|
-
export function registerFileCommands(parent, getApi) {
|
|
3
|
-
const file = parent.command("file").description("Context file operations");
|
|
4
|
-
file
|
|
5
|
-
.command("browse")
|
|
6
|
-
.description("Browse files in the context repository")
|
|
7
|
-
.option("--path <path>", "Path to browse (omit for root)")
|
|
8
|
-
.action(async (opts) => {
|
|
9
|
-
const api = getApi();
|
|
10
|
-
const result = await handleApiCall(() => api.context.file.browse({ path: opts.path }));
|
|
11
|
-
outputJson(result);
|
|
12
|
-
});
|
|
13
|
-
file
|
|
14
|
-
.command("read")
|
|
15
|
-
.description("Read a file from the context repository")
|
|
16
|
-
.requiredOption("--path <path>", "Full path to the file")
|
|
17
|
-
.action(async (opts) => {
|
|
18
|
-
const api = getApi();
|
|
19
|
-
const result = await handleApiCall(() => api.context.file.read({ path: opts.path }));
|
|
20
|
-
outputJson(result);
|
|
21
|
-
});
|
|
22
|
-
file
|
|
23
|
-
.command("write")
|
|
24
|
-
.description("Write a file to the context repository")
|
|
25
|
-
.requiredOption("--path <path>", "Full path to the file")
|
|
26
|
-
.requiredOption("--content <content>", "Content to write")
|
|
27
|
-
.option("--commit-message <message>", "Commit message")
|
|
28
|
-
.option("--sha <sha>", "SHA of the existing file to update")
|
|
29
|
-
.action(async (opts) => {
|
|
30
|
-
const api = getApi();
|
|
31
|
-
const result = await handleApiCall(() => api.context.file.write({
|
|
32
|
-
path: opts.path,
|
|
33
|
-
content: opts.content,
|
|
34
|
-
commitMessage: opts.commitMessage,
|
|
35
|
-
sha: opts.sha,
|
|
36
|
-
}));
|
|
37
|
-
outputJson(result);
|
|
38
|
-
});
|
|
39
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"skill.d.ts","sourceRoot":"","sources":["../../../src/commands/context/skill.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAGxC,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,MAAM,GAAG,GAChB,IAAI,CAuBN"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { handleApiCall, outputJson } from "../runHandler.js";
|
|
2
|
-
export function registerSkillCommands(parent, getApi) {
|
|
3
|
-
const skill = parent.command("skill").description("Context skill operations");
|
|
4
|
-
skill
|
|
5
|
-
.command("list")
|
|
6
|
-
.description("List all skills in the context repository")
|
|
7
|
-
.action(async () => {
|
|
8
|
-
const api = getApi();
|
|
9
|
-
const result = await handleApiCall(() => api.context.skill.list());
|
|
10
|
-
outputJson(result);
|
|
11
|
-
});
|
|
12
|
-
skill
|
|
13
|
-
.command("get")
|
|
14
|
-
.description("Get a skill by slug")
|
|
15
|
-
.requiredOption("--slug <slug>", "Skill slug (path in the repository)")
|
|
16
|
-
.action(async (opts) => {
|
|
17
|
-
const api = getApi();
|
|
18
|
-
const result = await handleApiCall(() => api.context.skill.get({ slug: opts.slug }));
|
|
19
|
-
outputJson(result);
|
|
20
|
-
});
|
|
21
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../src/commands/orchestration/log.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAGxC,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,GAAG,IAAI,CAwO5E"}
|