@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
package/README.md
CHANGED
|
@@ -112,7 +112,8 @@ cargo-ai orchestration workflow --help
|
|
|
112
112
|
| **system-of-record** | System of record, client, logs | `cargo-ai system-of-record sor list`, `cargo-ai system-of-record log list --payload '{}'` |
|
|
113
113
|
| **user-management** | Current user (no workspace context) | `cargo-ai user-management user get-current` |
|
|
114
114
|
| **ai** | AI templates, agents, releases, chats, MCP, files | `cargo-ai ai template list`, `cargo-ai ai agent list`, `cargo-ai ai file list` |
|
|
115
|
-
| **context** | Context repository,
|
|
115
|
+
| **context** | Context repository, runtime sandbox, and knowledge graph | `cargo-ai context repository get`, `cargo-ai context runtime browse --path <path>`, `cargo-ai context graph get` |
|
|
116
|
+
| **hosting** | Cargo Hosting apps (Vite SPAs), workers, and deployments | `cargo-ai hosting app list`, `cargo-ai hosting worker list`, `cargo-ai hosting deployment list --payload '{}'` |
|
|
116
117
|
|
|
117
118
|
Commands that accept complex payloads use a `--payload <json>` option (e.g. `cargo-ai orchestration play create --payload '{"name":"My Play",...}'`). Use `--help` on any subcommand for options.
|
|
118
119
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customIntegration.d.ts","sourceRoot":"","sources":["../../../src/commands/connection/customIntegration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAGxC,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,MAAM,GAAG,GAChB,IAAI,CAqJN"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { handleApiCall, outputJson } from "../runHandler.js";
|
|
2
|
+
export function registerCustomIntegrationCommands(parent, getApi) {
|
|
3
|
+
const customIntegration = parent
|
|
4
|
+
.command("custom-integration")
|
|
5
|
+
.description("Manage custom integrations (external HTTP servers or worker-backed integrations)");
|
|
6
|
+
customIntegration
|
|
7
|
+
.command("list")
|
|
8
|
+
.description("List custom integrations in the current workspace")
|
|
9
|
+
.action(async () => {
|
|
10
|
+
const api = getApi();
|
|
11
|
+
const result = await handleApiCall(() => api.connection.customIntegration.list());
|
|
12
|
+
outputJson(result);
|
|
13
|
+
});
|
|
14
|
+
customIntegration
|
|
15
|
+
.command("get <uuid>")
|
|
16
|
+
.description("Get a custom integration by UUID")
|
|
17
|
+
.action(async (uuid) => {
|
|
18
|
+
const api = getApi();
|
|
19
|
+
const result = await handleApiCall(() => api.connection.customIntegration.get({ uuid }));
|
|
20
|
+
outputJson(result);
|
|
21
|
+
});
|
|
22
|
+
customIntegration
|
|
23
|
+
.command("create")
|
|
24
|
+
.description("Register a custom integration (kind=external for an externally hosted server, kind=worker for a Cargo Hosting worker)")
|
|
25
|
+
.requiredOption("--kind <kind>", 'Integration kind: "external" or "worker"')
|
|
26
|
+
.option("--base-url <url>", "Base URL of the externally hosted integration server (required when --kind external)")
|
|
27
|
+
.option("--worker-uuid <uuid>", "UUID of the Cargo Hosting worker that backs the integration (required when --kind worker)")
|
|
28
|
+
.addHelpText("after", `
|
|
29
|
+
Examples:
|
|
30
|
+
$ cargo-ai connection custom-integration create --kind external --base-url https://abc123.ngrok.io
|
|
31
|
+
$ cargo-ai connection custom-integration create --kind worker --worker-uuid 11111111-2222-3333-4444-555555555555`)
|
|
32
|
+
.action(async (opts) => {
|
|
33
|
+
if (opts.kind !== "external" && opts.kind !== "worker") {
|
|
34
|
+
console.error(JSON.stringify({
|
|
35
|
+
error: `Invalid --kind "${opts.kind}". Expected "external" or "worker".`,
|
|
36
|
+
}));
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
if (opts.kind === "external" && opts.baseUrl === undefined) {
|
|
40
|
+
console.error(JSON.stringify({
|
|
41
|
+
error: "--base-url is required when --kind is external.",
|
|
42
|
+
}));
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
if (opts.kind === "worker" && opts.workerUuid === undefined) {
|
|
46
|
+
console.error(JSON.stringify({
|
|
47
|
+
error: "--worker-uuid is required when --kind is worker.",
|
|
48
|
+
}));
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
const api = getApi();
|
|
52
|
+
const result = await handleApiCall(() => opts.kind === "external"
|
|
53
|
+
? api.connection.customIntegration.create({
|
|
54
|
+
kind: "external",
|
|
55
|
+
baseUrl: opts.baseUrl,
|
|
56
|
+
})
|
|
57
|
+
: api.connection.customIntegration.create({
|
|
58
|
+
kind: "worker",
|
|
59
|
+
workerUuid: opts.workerUuid,
|
|
60
|
+
}));
|
|
61
|
+
outputJson(result);
|
|
62
|
+
});
|
|
63
|
+
customIntegration
|
|
64
|
+
.command("update")
|
|
65
|
+
.description("Update a custom integration's base URL or worker (kind cannot change)")
|
|
66
|
+
.requiredOption("--uuid <uuid>", "Custom integration UUID")
|
|
67
|
+
.option("--base-url <url>", "New base URL (only valid when the integration was created with kind=external)")
|
|
68
|
+
.option("--worker-uuid <uuid>", "New worker UUID (only valid when the integration was created with kind=worker)")
|
|
69
|
+
.action(async (opts) => {
|
|
70
|
+
if (opts.baseUrl === undefined && opts.workerUuid === undefined) {
|
|
71
|
+
console.error(JSON.stringify({
|
|
72
|
+
error: "Provide at least one of --base-url or --worker-uuid.",
|
|
73
|
+
}));
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
if (opts.baseUrl !== undefined && opts.workerUuid !== undefined) {
|
|
77
|
+
console.error(JSON.stringify({
|
|
78
|
+
error: "--base-url and --worker-uuid are mutually exclusive.",
|
|
79
|
+
}));
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
const api = getApi();
|
|
83
|
+
const result = await handleApiCall(() => api.connection.customIntegration.update({
|
|
84
|
+
uuid: opts.uuid,
|
|
85
|
+
baseUrl: opts.baseUrl,
|
|
86
|
+
workerUuid: opts.workerUuid,
|
|
87
|
+
}));
|
|
88
|
+
outputJson(result);
|
|
89
|
+
});
|
|
90
|
+
customIntegration
|
|
91
|
+
.command("remove <uuid>")
|
|
92
|
+
.description("Remove a custom integration")
|
|
93
|
+
.action(async (uuid) => {
|
|
94
|
+
const api = getApi();
|
|
95
|
+
await handleApiCall(() => api.connection.customIntegration.remove(uuid));
|
|
96
|
+
outputJson({ ok: true });
|
|
97
|
+
});
|
|
98
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/connection/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/connection/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAMxC,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,MAAM,GAAG,GAChB,IAAI,CASN"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { registerConnectorCommands } from "./connector.js";
|
|
2
|
+
import { registerCustomIntegrationCommands } from "./customIntegration.js";
|
|
2
3
|
import { registerIntegrationCommands } from "./integration.js";
|
|
3
4
|
import { registerNativeIntegrationCommands } from "./nativeIntegration.js";
|
|
4
5
|
export function registerConnectionCommands(parent, getApi) {
|
|
@@ -8,4 +9,5 @@ export function registerConnectionCommands(parent, getApi) {
|
|
|
8
9
|
registerConnectorCommands(connection, getApi);
|
|
9
10
|
registerIntegrationCommands(connection, getApi);
|
|
10
11
|
registerNativeIntegrationCommands(connection, getApi);
|
|
12
|
+
registerCustomIntegrationCommands(connection, getApi);
|
|
11
13
|
}
|
|
@@ -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 registerGraphCommands(parent: Command, getApi: () => Api): void;
|
|
4
|
+
//# sourceMappingURL=graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../../src/commands/context/graph.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,CAeN"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { handleApiCall, outputJson } from "../runHandler.js";
|
|
2
|
+
export function registerGraphCommands(parent, getApi) {
|
|
3
|
+
const graph = parent
|
|
4
|
+
.command("graph")
|
|
5
|
+
.description("Inspect the context knowledge graph for the workspace");
|
|
6
|
+
graph
|
|
7
|
+
.command("get")
|
|
8
|
+
.description("Build (or load from cache) the knowledge graph of all markdown/MDX files in the context repo")
|
|
9
|
+
.action(async () => {
|
|
10
|
+
const api = getApi();
|
|
11
|
+
const result = await handleApiCall(() => api.context.graph.get());
|
|
12
|
+
outputJson(result);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { registerGraphCommands } from "./graph.js";
|
|
2
2
|
import { registerRepositoryCommands } from "./repository.js";
|
|
3
|
-
import {
|
|
3
|
+
import { registerRuntimeCommands } from "./runtime.js";
|
|
4
4
|
export function registerContextCommands(parent, getApi) {
|
|
5
5
|
const context = parent
|
|
6
6
|
.command("context")
|
|
7
|
-
.description("Context repository
|
|
7
|
+
.description("Context repository and runtime sandbox operations");
|
|
8
8
|
registerRepositoryCommands(context, getApi);
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
registerRuntimeCommands(context, getApi);
|
|
10
|
+
registerGraphCommands(context, getApi);
|
|
11
11
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/commands/context/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAGxC,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,MAAM,GAAG,GAChB,IAAI,CAmIN"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { handleApiCall, outputJson } from "../runHandler.js";
|
|
2
|
+
export function registerRuntimeCommands(parent, getApi) {
|
|
3
|
+
const runtime = parent
|
|
4
|
+
.command("runtime")
|
|
5
|
+
.description("Read, write, edit, browse, and execute against the workspace runtime sandbox");
|
|
6
|
+
runtime
|
|
7
|
+
.command("browse")
|
|
8
|
+
.description("List entries in the runtime sandbox")
|
|
9
|
+
.option("--path <path>", "Path to browse (omit to browse the root)")
|
|
10
|
+
.action(async (opts) => {
|
|
11
|
+
const api = getApi();
|
|
12
|
+
const result = await handleApiCall(() => api.context.runtime.browse({ path: opts.path }));
|
|
13
|
+
outputJson(result);
|
|
14
|
+
});
|
|
15
|
+
runtime
|
|
16
|
+
.command("read")
|
|
17
|
+
.description("Read a file from the runtime sandbox")
|
|
18
|
+
.requiredOption("--path <path>", "Path to the file")
|
|
19
|
+
.option("--start-line <line>", "1-indexed inclusive start line (defaults to first line)")
|
|
20
|
+
.option("--end-line <line>", "1-indexed inclusive end line (defaults to last line)")
|
|
21
|
+
.action(async (opts) => {
|
|
22
|
+
const api = getApi();
|
|
23
|
+
const startLine = opts.startLine !== undefined ? Number(opts.startLine) : undefined;
|
|
24
|
+
const endLine = opts.endLine !== undefined ? Number(opts.endLine) : undefined;
|
|
25
|
+
const result = await handleApiCall(() => api.context.runtime.read({
|
|
26
|
+
path: opts.path,
|
|
27
|
+
startLine,
|
|
28
|
+
endLine,
|
|
29
|
+
}));
|
|
30
|
+
outputJson(result);
|
|
31
|
+
});
|
|
32
|
+
runtime
|
|
33
|
+
.command("write")
|
|
34
|
+
.description("Write a file in the runtime sandbox and push to the default branch")
|
|
35
|
+
.requiredOption("--path <path>", "Path to the file")
|
|
36
|
+
.requiredOption("--content <content>", "File content")
|
|
37
|
+
.option("--commit-message <message>", "Commit message override")
|
|
38
|
+
.action(async (opts) => {
|
|
39
|
+
const api = getApi();
|
|
40
|
+
const result = await handleApiCall(() => api.context.runtime.write({
|
|
41
|
+
path: opts.path,
|
|
42
|
+
content: opts.content,
|
|
43
|
+
commitMessage: opts.commitMessage,
|
|
44
|
+
}));
|
|
45
|
+
outputJson(result);
|
|
46
|
+
});
|
|
47
|
+
runtime
|
|
48
|
+
.command("edit")
|
|
49
|
+
.description("Replace a single occurrence of oldString with newString and push to the default branch")
|
|
50
|
+
.requiredOption("--path <path>", "Path to the file")
|
|
51
|
+
.requiredOption("--old-string <old>", "Exact substring to replace (must occur once)")
|
|
52
|
+
.requiredOption("--new-string <new>", "Replacement string (may be empty to delete the match)")
|
|
53
|
+
.option("--commit-message <message>", "Commit message override")
|
|
54
|
+
.action(async (opts) => {
|
|
55
|
+
const api = getApi();
|
|
56
|
+
const result = await handleApiCall(() => api.context.runtime.edit({
|
|
57
|
+
path: opts.path,
|
|
58
|
+
oldString: opts.oldString,
|
|
59
|
+
newString: opts.newString,
|
|
60
|
+
commitMessage: opts.commitMessage,
|
|
61
|
+
}));
|
|
62
|
+
outputJson(result);
|
|
63
|
+
});
|
|
64
|
+
runtime
|
|
65
|
+
.command("execute")
|
|
66
|
+
.description("Run a shell command in the runtime sandbox (changes are NOT pushed to GitHub)")
|
|
67
|
+
.requiredOption("--command <command>", "Shell command to run")
|
|
68
|
+
.option("--args <json>", "JSON array of arguments")
|
|
69
|
+
.action(async (opts) => {
|
|
70
|
+
const api = getApi();
|
|
71
|
+
const args = opts.args !== undefined
|
|
72
|
+
? JSON.parse(opts.args)
|
|
73
|
+
: undefined;
|
|
74
|
+
const result = await handleApiCall(() => api.context.runtime.execute({
|
|
75
|
+
command: opts.command,
|
|
76
|
+
args,
|
|
77
|
+
}));
|
|
78
|
+
outputJson(result);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
@@ -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 registerAppCommands(parent: Command, getApi: () => Api): void;
|
|
4
|
+
//# sourceMappingURL=app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/commands/hosting/app.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAMxC,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,GAAG,IAAI,CAsO5E"}
|
|
@@ -0,0 +1,190 @@
|
|
|
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 registerAppCommands(parent, getApi) {
|
|
9
|
+
const app = parent
|
|
10
|
+
.command("app")
|
|
11
|
+
.description("Manage Cargo Hosting apps (Vite SPAs served on *.cargo.app)");
|
|
12
|
+
app
|
|
13
|
+
.command("list")
|
|
14
|
+
.description("List apps 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.app.list({
|
|
19
|
+
folderUuid: opts.folderUuid,
|
|
20
|
+
}));
|
|
21
|
+
outputJson(result);
|
|
22
|
+
});
|
|
23
|
+
app
|
|
24
|
+
.command("get <uuid>")
|
|
25
|
+
.description("Show details of a single app")
|
|
26
|
+
.action(async (uuid) => {
|
|
27
|
+
const api = getApi();
|
|
28
|
+
const result = await handleApiCall(() => api.hosting.app.get(uuid));
|
|
29
|
+
outputJson(result);
|
|
30
|
+
});
|
|
31
|
+
app
|
|
32
|
+
.command("create")
|
|
33
|
+
.description("Create a new app slot")
|
|
34
|
+
.requiredOption("--name <name>", "Display name for the app")
|
|
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.app.create({
|
|
40
|
+
name: opts.name,
|
|
41
|
+
slug: opts.slug,
|
|
42
|
+
folderUuid: opts.folderUuid,
|
|
43
|
+
}));
|
|
44
|
+
outputJson(result);
|
|
45
|
+
});
|
|
46
|
+
app
|
|
47
|
+
.command("update")
|
|
48
|
+
.description("Update an existing app (name, folder)")
|
|
49
|
+
.requiredOption("--uuid <uuid>", "App 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.app.update({
|
|
55
|
+
uuid: opts.uuid,
|
|
56
|
+
name: opts.name,
|
|
57
|
+
folderUuid: opts.folderUuid === "null" ? null : opts.folderUuid,
|
|
58
|
+
}));
|
|
59
|
+
outputJson(result);
|
|
60
|
+
});
|
|
61
|
+
app
|
|
62
|
+
.command("remove <uuid>")
|
|
63
|
+
.description("Remove an app (also removes its deployments)")
|
|
64
|
+
.action(async (uuid) => {
|
|
65
|
+
const api = getApi();
|
|
66
|
+
await handleApiCall(() => api.hosting.app.remove(uuid));
|
|
67
|
+
outputJson({ ok: true });
|
|
68
|
+
});
|
|
69
|
+
app
|
|
70
|
+
.command("env <appUuid>")
|
|
71
|
+
.description("Print the .env.local lines a local copy of the app needs (Cargo OAuth + workspace + app UUID + API URL).")
|
|
72
|
+
.option("--api-url <url>", "Override the API URL written to the .env (default: https://api.getcargo.io)")
|
|
73
|
+
.action(async (appUuid, opts) => {
|
|
74
|
+
const api = getApi();
|
|
75
|
+
const { app: resolvedApp } = await handleApiCall(() => api.hosting.app.get(appUuid));
|
|
76
|
+
const lines = [
|
|
77
|
+
"# Generated by `cargo-ai hosting app env`. Do not commit secrets.",
|
|
78
|
+
"VITE_CARGO_OAUTH_DOMAIN=<set-by-cargo-hosting-at-deploy-time>",
|
|
79
|
+
"VITE_CARGO_OAUTH_CLIENT_ID=<set-by-cargo-hosting-at-deploy-time>",
|
|
80
|
+
"VITE_CARGO_OAUTH_AUDIENCE=<set-by-cargo-hosting-at-deploy-time>",
|
|
81
|
+
`VITE_CARGO_API_URL=${opts.apiUrl !== undefined ? opts.apiUrl : "https://api.getcargo.io"}`,
|
|
82
|
+
`VITE_CARGO_WORKSPACE_UUID=${resolvedApp.workspaceUuid}`,
|
|
83
|
+
`VITE_CARGO_APP_UUID=${resolvedApp.uuid}`,
|
|
84
|
+
"VITE_CARGO_DEPLOYMENT_UUID=<set-by-cargo-hosting-at-deploy-time>",
|
|
85
|
+
"VITE_APP_BASE_PATH=/",
|
|
86
|
+
"",
|
|
87
|
+
];
|
|
88
|
+
process.stdout.write(lines.join("\n"));
|
|
89
|
+
});
|
|
90
|
+
app
|
|
91
|
+
.command("init <directory>")
|
|
92
|
+
.description("Scaffold a new Cargo Hosting app locally from a template (Vite + @cargo-ai/app-sdk).")
|
|
93
|
+
.option("--template <slug>", "Template slug (default: blank)", "blank")
|
|
94
|
+
.option("--name <name>", "App name written into package.json (default: directory name)")
|
|
95
|
+
.option("--list-templates", "Print available templates and exit")
|
|
96
|
+
.action(async (directory, opts) => {
|
|
97
|
+
const templatesRoot = findTemplatesRoot();
|
|
98
|
+
if (opts.listTemplates === true) {
|
|
99
|
+
const slugs = await listTemplates(templatesRoot);
|
|
100
|
+
if (slugs.length === 0) {
|
|
101
|
+
console.error(JSON.stringify({ error: "No templates found", templatesRoot }));
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
console.log(JSON.stringify(slugs.map((slug) => ({
|
|
105
|
+
slug,
|
|
106
|
+
description: TEMPLATE_DESCRIPTIONS[slug] !== undefined
|
|
107
|
+
? TEMPLATE_DESCRIPTIONS[slug]
|
|
108
|
+
: "",
|
|
109
|
+
})), null, 2));
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const templateDir = path.join(templatesRoot, opts.template);
|
|
113
|
+
try {
|
|
114
|
+
const stat = await fs.stat(templateDir);
|
|
115
|
+
if (stat.isDirectory() === false) {
|
|
116
|
+
throw new Error("Template path is not a directory");
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
const slugs = await listTemplates(templatesRoot);
|
|
121
|
+
console.error(JSON.stringify({
|
|
122
|
+
error: `Unknown template "${opts.template}"`,
|
|
123
|
+
available: slugs,
|
|
124
|
+
}));
|
|
125
|
+
process.exit(1);
|
|
126
|
+
}
|
|
127
|
+
const targetDir = path.resolve(directory);
|
|
128
|
+
try {
|
|
129
|
+
const stat = await fs.stat(targetDir);
|
|
130
|
+
if (stat.isDirectory() === true) {
|
|
131
|
+
const entries = await fs.readdir(targetDir);
|
|
132
|
+
if (entries.length > 0) {
|
|
133
|
+
console.error(JSON.stringify({
|
|
134
|
+
error: `Target directory ${targetDir} is not empty.`,
|
|
135
|
+
}));
|
|
136
|
+
process.exit(1);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
// Target does not exist yet — that's fine.
|
|
142
|
+
}
|
|
143
|
+
const appName = opts.name !== undefined ? opts.name : path.basename(targetDir);
|
|
144
|
+
await copyDirectory(path.join(templatesRoot, opts.template), targetDir, [
|
|
145
|
+
{ from: "__APP_NAME__", to: appName },
|
|
146
|
+
{ from: "__TEMPLATE_SLUG__", to: opts.template },
|
|
147
|
+
]);
|
|
148
|
+
console.log(JSON.stringify({
|
|
149
|
+
ok: true,
|
|
150
|
+
directory: targetDir,
|
|
151
|
+
template: opts.template,
|
|
152
|
+
name: appName,
|
|
153
|
+
nextSteps: [
|
|
154
|
+
`cd ${path.relative(process.cwd(), targetDir)}`,
|
|
155
|
+
"npm install",
|
|
156
|
+
"cargo-ai hosting app create --name '<App name>' --slug '<your-slug>'",
|
|
157
|
+
"cargo-ai hosting app env <appUuid> > .env.local",
|
|
158
|
+
"npm run dev",
|
|
159
|
+
],
|
|
160
|
+
}, null, 2));
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
const TEMPLATE_DESCRIPTIONS = {
|
|
164
|
+
blank: "Minimal Vite + refine app with one route, getCargoEnv() + CargoWorkspaceBadge wired (use as a starting point).",
|
|
165
|
+
"territories-overview": "Read-only grid of revenue organization territories. Demonstrates useCargoApi() + react-query + the SDK shadcn primitives.",
|
|
166
|
+
};
|
|
167
|
+
const findTemplatesRoot = () => {
|
|
168
|
+
// The CLI is published as `@cargo-ai/cli`. Templates live in
|
|
169
|
+
// `@cargo-ai/app-sdk/templates`. Resolve via require so we work whether the
|
|
170
|
+
// user installed both packages globally or both came from the monorepo.
|
|
171
|
+
try {
|
|
172
|
+
const appSdkPackageJson = require.resolve("@cargo-ai/app-sdk/package.json");
|
|
173
|
+
return path.join(path.dirname(appSdkPackageJson), "templates");
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
const here = fileURLToPath(import.meta.url);
|
|
177
|
+
let cursor = path.dirname(here);
|
|
178
|
+
for (let i = 0; i < 6; i += 1) {
|
|
179
|
+
const candidate = path.join(cursor, "packages/app-sdk/templates");
|
|
180
|
+
try {
|
|
181
|
+
require("node:fs").accessSync(candidate);
|
|
182
|
+
return candidate;
|
|
183
|
+
}
|
|
184
|
+
catch {
|
|
185
|
+
cursor = path.dirname(cursor);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
throw new Error("Could not locate @cargo-ai/app-sdk templates. Make sure @cargo-ai/app-sdk is installed alongside @cargo-ai/cli.");
|
|
189
|
+
}
|
|
190
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deployment.d.ts","sourceRoot":"","sources":["../../../src/commands/hosting/deployment.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAGxC,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,MAAM,GAAG,GAChB,IAAI,CA6JN"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { promises as fs } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { handleApiCall, outputJson } from "../runHandler.js";
|
|
4
|
+
export function registerDeploymentCommands(parent, getApi) {
|
|
5
|
+
const deployment = parent
|
|
6
|
+
.command("deployment")
|
|
7
|
+
.description("Inspect, create, and promote deployments");
|
|
8
|
+
deployment
|
|
9
|
+
.command("list")
|
|
10
|
+
.description("List deployments for a given app or worker")
|
|
11
|
+
.option("--app-uuid <uuid>", "App UUID")
|
|
12
|
+
.option("--worker-uuid <uuid>", "Worker UUID")
|
|
13
|
+
.action(async (opts) => {
|
|
14
|
+
if (opts.appUuid === undefined && opts.workerUuid === undefined) {
|
|
15
|
+
console.error(JSON.stringify({
|
|
16
|
+
error: "Either --app-uuid or --worker-uuid must be provided.",
|
|
17
|
+
}));
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
const api = getApi();
|
|
21
|
+
const result = await handleApiCall(() => api.hosting.deployment.list({
|
|
22
|
+
appUuid: opts.appUuid,
|
|
23
|
+
workerUuid: opts.workerUuid,
|
|
24
|
+
}));
|
|
25
|
+
outputJson(result);
|
|
26
|
+
});
|
|
27
|
+
deployment
|
|
28
|
+
.command("get <uuid>")
|
|
29
|
+
.description("Show a single deployment's status and metadata")
|
|
30
|
+
.action(async (uuid) => {
|
|
31
|
+
const api = getApi();
|
|
32
|
+
const result = await handleApiCall(() => api.hosting.deployment.get(uuid));
|
|
33
|
+
outputJson(result);
|
|
34
|
+
});
|
|
35
|
+
deployment
|
|
36
|
+
.command("get-promoted")
|
|
37
|
+
.description("Show the currently promoted deployment for an app or worker")
|
|
38
|
+
.option("--app-uuid <uuid>", "App UUID")
|
|
39
|
+
.option("--worker-uuid <uuid>", "Worker UUID")
|
|
40
|
+
.action(async (opts) => {
|
|
41
|
+
if (opts.appUuid === undefined && opts.workerUuid === undefined) {
|
|
42
|
+
console.error(JSON.stringify({
|
|
43
|
+
error: "Either --app-uuid or --worker-uuid must be provided.",
|
|
44
|
+
}));
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
const api = getApi();
|
|
48
|
+
const result = await handleApiCall(() => api.hosting.deployment.getPromoted({
|
|
49
|
+
appUuid: opts.appUuid,
|
|
50
|
+
workerUuid: opts.workerUuid,
|
|
51
|
+
}));
|
|
52
|
+
outputJson(result);
|
|
53
|
+
});
|
|
54
|
+
deployment
|
|
55
|
+
.command("create")
|
|
56
|
+
.description("Create a new deployment by uploading a local source directory. For apps the backend runs `npm ci && vite build` in a sandbox; for workers it bundles the entrypoint.")
|
|
57
|
+
.option("--app-uuid <uuid>", "App UUID (mutually exclusive with --worker-uuid)")
|
|
58
|
+
.option("--worker-uuid <uuid>", "Worker UUID (mutually exclusive with --app-uuid)")
|
|
59
|
+
.requiredOption("--source <dir>", "Path to the source directory (typically the package root, not dist/)")
|
|
60
|
+
.option("--ignore <list>", "Comma-separated names to ignore (default: node_modules,dist,build,.git,.next)", "node_modules,dist,build,.git,.next")
|
|
61
|
+
.action(async (opts) => {
|
|
62
|
+
if ((opts.appUuid === undefined && opts.workerUuid === undefined) ||
|
|
63
|
+
(opts.appUuid !== undefined && opts.workerUuid !== undefined)) {
|
|
64
|
+
console.error(JSON.stringify({
|
|
65
|
+
error: "Exactly one of --app-uuid or --worker-uuid must be provided.",
|
|
66
|
+
}));
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
const api = getApi();
|
|
70
|
+
const sourceDir = path.resolve(opts.source);
|
|
71
|
+
const ignore = new Set(opts.ignore.split(",").map((entry) => entry.trim()));
|
|
72
|
+
const files = await collectFiles(sourceDir, { ignore });
|
|
73
|
+
if (files.length === 0) {
|
|
74
|
+
console.error(JSON.stringify({
|
|
75
|
+
error: `No files to deploy under ${sourceDir}`,
|
|
76
|
+
}));
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
const payload = opts.appUuid !== undefined
|
|
80
|
+
? { kind: "app", appUuid: opts.appUuid, files }
|
|
81
|
+
: {
|
|
82
|
+
kind: "worker",
|
|
83
|
+
workerUuid: opts.workerUuid,
|
|
84
|
+
files,
|
|
85
|
+
};
|
|
86
|
+
const result = await handleApiCall(() => api.hosting.deployment.create(payload));
|
|
87
|
+
outputJson({
|
|
88
|
+
...result,
|
|
89
|
+
stats: { fileCount: files.length },
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
deployment
|
|
93
|
+
.command("promote")
|
|
94
|
+
.description("Promote a deployment to the live URL")
|
|
95
|
+
.requiredOption("--uuid <uuid>", "Deployment UUID to promote")
|
|
96
|
+
.action(async (opts) => {
|
|
97
|
+
const api = getApi();
|
|
98
|
+
const result = await handleApiCall(() => api.hosting.deployment.promote({
|
|
99
|
+
uuid: opts.uuid,
|
|
100
|
+
}));
|
|
101
|
+
outputJson(result);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
const collectFiles = async (rootDir, options) => {
|
|
105
|
+
const results = [];
|
|
106
|
+
const walk = async (dir, relative) => {
|
|
107
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
108
|
+
for (const entry of entries) {
|
|
109
|
+
if (options.ignore.has(entry.name)) {
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
const absolute = path.join(dir, entry.name);
|
|
113
|
+
const rel = relative.length === 0 ? entry.name : `${relative}/${entry.name}`;
|
|
114
|
+
if (entry.isDirectory() === true) {
|
|
115
|
+
await walk(absolute, rel);
|
|
116
|
+
}
|
|
117
|
+
else if (entry.isFile() === true) {
|
|
118
|
+
const content = await fs.readFile(absolute, "utf-8");
|
|
119
|
+
results.push({ path: rel, content });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
await walk(rootDir, "");
|
|
124
|
+
return results;
|
|
125
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/hosting/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAKxC,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,MAAM,GAAG,GAChB,IAAI,CAUN"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { registerAppCommands } from "./app.js";
|
|
2
|
+
import { registerDeploymentCommands } from "./deployment.js";
|
|
3
|
+
import { registerWorkerCommands } from "./worker.js";
|
|
4
|
+
export function registerHostingCommands(parent, getApi) {
|
|
5
|
+
const hosting = parent
|
|
6
|
+
.command("hosting")
|
|
7
|
+
.description("Cargo Hosting: apps (Vite SPAs), workers (edge HTTP handlers), and deployments");
|
|
8
|
+
registerAppCommands(hosting, getApi);
|
|
9
|
+
registerWorkerCommands(hosting, getApi);
|
|
10
|
+
registerDeploymentCommands(hosting, getApi);
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templateUtils.d.ts","sourceRoot":"","sources":["../../../src/commands/hosting/templateUtils.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa,SAAgB,MAAM,KAAG,QAAQ,MAAM,EAAE,CAUlE,CAAC;AAEF,eAAO,MAAM,aAAa,QACnB,MAAM,QACL,MAAM,UACJ;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,EAAE,KACrC,QAAQ,IAAI,CAmBd,CAAC"}
|