@cargo-ai/cdk 1.0.3 → 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.
Files changed (63) hide show
  1. package/README.md +64 -35
  2. package/build/src/cli/auth.d.ts +9 -0
  3. package/build/src/cli/auth.d.ts.map +1 -0
  4. package/build/src/cli/auth.js +100 -0
  5. package/build/src/cli/bin.d.ts +3 -0
  6. package/build/src/cli/bin.d.ts.map +1 -0
  7. package/build/src/cli/bin.js +9 -0
  8. package/build/src/cli/commands/deploy.d.ts +4 -0
  9. package/build/src/cli/commands/deploy.d.ts.map +1 -0
  10. package/build/src/cli/commands/deploy.js +531 -0
  11. package/build/src/cli/commands/index.d.ts +4 -0
  12. package/build/src/cli/commands/index.d.ts.map +1 -0
  13. package/build/src/cli/commands/index.js +11 -0
  14. package/build/src/cli/commands/init.d.ts +3 -0
  15. package/build/src/cli/commands/init.d.ts.map +1 -0
  16. package/build/src/cli/commands/init.js +76 -0
  17. package/build/src/cli/commands/inputTypes.d.ts +24 -0
  18. package/build/src/cli/commands/inputTypes.d.ts.map +1 -0
  19. package/build/src/cli/commands/inputTypes.js +273 -0
  20. package/build/src/cli/commands/templates.d.ts +6 -0
  21. package/build/src/cli/commands/templates.d.ts.map +1 -0
  22. package/build/src/cli/commands/templates.js +33 -0
  23. package/build/src/cli/commands/types.d.ts +4 -0
  24. package/build/src/cli/commands/types.d.ts.map +1 -0
  25. package/build/src/cli/commands/types.js +385 -0
  26. package/build/src/cli/index.d.ts +4 -0
  27. package/build/src/cli/index.d.ts.map +1 -0
  28. package/build/src/cli/index.js +20 -0
  29. package/build/src/cli/io.d.ts +38 -0
  30. package/build/src/cli/io.d.ts.map +1 -0
  31. package/build/src/cli/io.js +226 -0
  32. package/build/src/cli/version.d.ts +2 -0
  33. package/build/src/cli/version.d.ts.map +1 -0
  34. package/build/src/cli/version.js +25 -0
  35. package/build/src/deploy/executors.live.d.ts.map +1 -1
  36. package/build/src/deploy/executors.live.js +15 -3
  37. package/build/src/resources/bundle.d.ts +4 -2
  38. package/build/src/resources/bundle.d.ts.map +1 -1
  39. package/build/src/resources/bundle.js +11 -2
  40. package/build/src/resources/connector.d.ts.map +1 -1
  41. package/build/src/resources/connector.js +3 -2
  42. package/build/src/resources/worker.d.ts.map +1 -1
  43. package/build/src/resources/worker.js +14 -7
  44. package/build/tsconfig.tsbuildinfo +1 -1
  45. package/package.json +14 -4
  46. package/templates/blank/package.json +3 -3
  47. package/templates/full/README.md +21 -20
  48. package/templates/full/apps/dashboard/index.html +1 -1
  49. package/templates/full/apps/dashboard/package.json +18 -3
  50. package/templates/full/apps/dashboard/src/App.tsx +57 -0
  51. package/templates/full/apps/dashboard/src/index.css +4 -0
  52. package/templates/full/apps/dashboard/src/main.tsx +13 -7
  53. package/templates/full/apps/dashboard/tailwind.config.ts +13 -0
  54. package/templates/full/apps/dashboard/tsconfig.json +10 -3
  55. package/templates/full/apps/dashboard/vite.config.ts +22 -0
  56. package/templates/full/package.json +3 -3
  57. package/templates/full/workers/webhook/package.json +12 -1
  58. package/templates/full/workers/webhook/src/index.ts +53 -0
  59. package/templates/full/workers/webhook/tsconfig.json +14 -0
  60. package/templates/full/workers/webhook.ts +9 -7
  61. package/templates/full/apps/dashboard/package-lock.json +0 -1080
  62. package/templates/full/workers/webhook/index.js +0 -12
  63. package/templates/full/workers/webhook/package-lock.json +0 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cargo-ai/cdk",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Cargo CDK — define every Cargo resource (connectors, models, plays, tools, agents, MCP servers, folders, files, workers, apps) in code and deploy it declaratively: plan, apply, refresh, import and destroy over a repo of definitions.",
5
5
  "keywords": [
6
6
  "cargo",
@@ -20,6 +20,9 @@
20
20
  "node": "22.22.2"
21
21
  },
22
22
  "type": "module",
23
+ "bin": {
24
+ "cargo-cdk": "./build/src/cli/bin.js"
25
+ },
23
26
  "exports": {
24
27
  ".": {
25
28
  "types": "./build/src/index.d.ts",
@@ -29,6 +32,10 @@
29
32
  "types": "./build/src/deploy/index.d.ts",
30
33
  "default": "./build/src/deploy/index.js"
31
34
  },
35
+ "./cli": {
36
+ "types": "./build/src/cli/index.d.ts",
37
+ "default": "./build/src/cli/index.js"
38
+ },
32
39
  "./package.json": "./package.json"
33
40
  },
34
41
  "files": [
@@ -50,10 +57,13 @@
50
57
  "format:check": "prettier --check ."
51
58
  },
52
59
  "dependencies": {
53
- "@cargo-ai/api": "^1.0.32",
54
- "@cargo-ai/types": "^1.0.34",
55
- "@cargo-ai/worker-sdk": "^1.0.2",
60
+ "@cargo-ai/api": "^1.0.34",
61
+ "@cargo-ai/types": "^1.0.37",
62
+ "@cargo-ai/worker-sdk": "^1.0.4",
56
63
  "@cargo-ai/workflow-sdk": "^1.0.1",
64
+ "commander": "^12.1.0",
65
+ "http-proxy-agent": "^9.1.0",
66
+ "https-proxy-agent": "^9.1.0",
57
67
  "tsx": "^4.19.3",
58
68
  "zod": "4.4.3"
59
69
  },
@@ -3,9 +3,9 @@
3
3
  "private": true,
4
4
  "type": "module",
5
5
  "scripts": {
6
- "types": "cargo-ai cdk types",
7
- "plan": "cargo-ai cdk plan",
8
- "deploy": "cargo-ai cdk deploy"
6
+ "types": "cargo-cdk types",
7
+ "plan": "cargo-cdk plan",
8
+ "deploy": "cargo-cdk deploy"
9
9
  },
10
10
  "dependencies": {
11
11
  "@cargo-ai/cdk": "^0.1.0",
@@ -21,29 +21,30 @@ playbook (file) webhook (worker) dashboard (app)
21
21
 
22
22
  ## What each file shows
23
23
 
24
- | File | Resource | Highlights |
25
- | --------------------------------------- | ------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
26
- | `connectors/hubspot.ts` | `defineConnector` | discriminated-union config + `secret()`; auto-creates a dataset |
27
- | `connectors/openai.ts` | `defineConnector` | `adopt: true` to link an existing OAuth connector |
28
- | `folders/crm.ts` | `defineFolder` | per-kind folders (model vs agent) |
29
- | `models/contacts.ts` | `defineModel` | `dataset` handle + `extractSlug` + cron schedule |
30
- | `tools/enrich.ts` | `defineWorkflow` + `defineTool` | a tool backed by a workflow, with a cron trigger |
31
- | `agents/enricher.ts` | `defineAgent` | a focused sub-agent (LLM via `connector`) |
32
- | `agents/sdr.ts` | `defineAgent` | data model, sub-agent, trigger, evaluator |
33
- | `plays/onboarding.ts` | `definePlay` + `defineWorkflow` | runs a per-row workflow as contacts change |
34
- | `mcp/crm.ts` | `defineMcpServer` | bundles tool + agent + model behind one endpoint |
35
- | `context/context.ts` (+ `context/*.md`) | `defineContext` | syncs the GTM knowledge base (markdown/MDX) into the workspace's context repo |
36
- | `files/playbook.ts` | `defineFile` | content uploaded from a local path |
37
- | `workers/webhook.ts` (+ `webhook/`) | `defineWorker` | the worker _resource_; points at a built bundle (`index.js` + `manifest.json` + `package.json` + `package-lock.json`) |
38
- | `apps/dashboard.ts` (+ `dashboard/`) | `defineApp` | a hosted Vite app (`index.html` + `package.json` + `package-lock.json`) |
24
+ | File | Resource | Highlights |
25
+ | --------------------------------------- | ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
26
+ | `connectors/hubspot.ts` | `defineConnector` | discriminated-union config + `secret()`; auto-creates a dataset |
27
+ | `connectors/openai.ts` | `defineConnector` | `adopt: true` to link an existing OAuth connector |
28
+ | `folders/crm.ts` | `defineFolder` | per-kind folders (model vs agent) |
29
+ | `models/contacts.ts` | `defineModel` | `dataset` handle + `extractSlug` + cron schedule |
30
+ | `tools/enrich.ts` | `defineWorkflow` + `defineTool` | a tool backed by a workflow, with a cron trigger |
31
+ | `agents/enricher.ts` | `defineAgent` | a focused sub-agent (LLM via `connector`) |
32
+ | `agents/sdr.ts` | `defineAgent` | data model, sub-agent, trigger, evaluator |
33
+ | `plays/onboarding.ts` | `definePlay` + `defineWorkflow` | runs a per-row workflow as contacts change |
34
+ | `mcp/crm.ts` | `defineMcpServer` | bundles tool + agent + model behind one endpoint |
35
+ | `context/context.ts` (+ `context/*.md`) | `defineContext` | syncs the GTM knowledge base (markdown/MDX) into the workspace's context repo |
36
+ | `files/playbook.ts` | `defineFile` | content uploaded from a local path |
37
+ | `workers/webhook.ts` (+ `webhook/`) | `defineWorker` | the worker _resource_; points at a TS source bundle (`src/index.ts` + `manifest.json` + `package.json` + `package-lock.json`) |
38
+ | `apps/dashboard.ts` (+ `dashboard/`) | `defineApp` | a hosted Vite app (`index.html` + `package.json` + `package-lock.json`) |
39
39
 
40
40
  `defineWorker` vs `createWorker`: `defineWorker` is the deployable **resource**
41
41
  (the hosted slot). `createWorker` (from `@cargo-ai/worker-sdk`) is what you use to
42
- author the worker's **runtime code** the hosting build esbuilds the bundle's
43
- `index.js`, so author in TS and build to `index.js` before deploying. The CDK
44
- checks the required bundle files exist at define time. The worker/app
45
- sub-directories each have their own `package.json`, so the loader treats them as
46
- bundles to upload, not as resource files to import.
42
+ author the worker's **runtime code** at `src/index.ts`. Like an app, the worker
43
+ is uploaded as source and built by Cargo Hosting (the build runs `npm ci` then
44
+ esbuilds the entry esbuild transpiles TypeScript natively), so there's no local
45
+ build step. The CDK checks the required bundle files exist at define time. The
46
+ worker/app sub-directories each have their own `package.json`, so the loader
47
+ treats them as bundles to upload, not as resource files to import.
47
48
 
48
49
  ## Try it
49
50
 
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>Pipeline Dashboard</title>
7
7
  </head>
8
- <body>
8
+ <body class="bg-background text-foreground">
9
9
  <div id="root"></div>
10
10
  <script type="module" src="/src/main.tsx"></script>
11
11
  </body>
@@ -1,15 +1,30 @@
1
1
  {
2
2
  "name": "dashboard",
3
3
  "private": true,
4
+ "version": "1.0.0",
4
5
  "type": "module",
5
6
  "scripts": {
6
- "build": "vite build"
7
+ "dev": "vite",
8
+ "build": "vite build",
9
+ "preview": "vite preview",
10
+ "type:check": "tsc --noEmit"
7
11
  },
8
12
  "dependencies": {
9
- "react": "^18.3.1",
10
- "react-dom": "^18.3.1"
13
+ "@auth0/auth0-react": "^2.11.0",
14
+ "@cargo-ai/api": "^1.0.32",
15
+ "@cargo-ai/app-sdk": "^1.0.2",
16
+ "react": "18.3.1",
17
+ "react-dom": "18.3.1",
18
+ "react-router-dom": "^6.30.0"
11
19
  },
12
20
  "devDependencies": {
21
+ "@types/react": "^18.3.25",
22
+ "@types/react-dom": "^18.3.7",
23
+ "@vitejs/plugin-react": "^4.3.0",
24
+ "autoprefixer": "^10.4.21",
25
+ "postcss": "^8.5.10",
26
+ "tailwindcss": "^3.4.0",
27
+ "typescript": "5.3.2",
13
28
  "vite": "^5.4.0"
14
29
  }
15
30
  }
@@ -0,0 +1,57 @@
1
+ import {
2
+ Card,
3
+ CardContent,
4
+ CardDescription,
5
+ CardHeader,
6
+ CargoEmpty,
7
+ CargoRefineApp,
8
+ CargoSiderLayout,
9
+ CargoWorkspaceBadge,
10
+ getCargoEnv,
11
+ } from "@cargo-ai/app-sdk";
12
+ import { LayoutDashboard } from "lucide-react";
13
+ import React from "react";
14
+ import { Route, Routes } from "react-router-dom";
15
+
16
+ const resources = [
17
+ {
18
+ name: "pipeline",
19
+ list: "/",
20
+ meta: {
21
+ label: "Pipeline",
22
+ icon: <LayoutDashboard className="h-4 w-4" />,
23
+ },
24
+ },
25
+ ];
26
+
27
+ const Home: React.FC = () => {
28
+ const env = getCargoEnv();
29
+
30
+ return (
31
+ <div className="flex flex-col gap-4 p-6">
32
+ <CargoWorkspaceBadge />
33
+ <Card>
34
+ <CardHeader>
35
+ <CardDescription>App UUID</CardDescription>
36
+ </CardHeader>
37
+ <CardContent className="font-mono text-xs">{env.appUuid}</CardContent>
38
+ </Card>
39
+ <CargoEmpty
40
+ title="Pipeline overview for the sales team"
41
+ description="Wire up `useCargoApi()` + react-query to render your pipeline here."
42
+ />
43
+ </div>
44
+ );
45
+ };
46
+
47
+ export const App: React.FC = () => {
48
+ return (
49
+ <CargoRefineApp resources={resources}>
50
+ <CargoSiderLayout title="Pipeline Dashboard">
51
+ <Routes>
52
+ <Route path="/" element={<Home />} />
53
+ </Routes>
54
+ </CargoSiderLayout>
55
+ </CargoRefineApp>
56
+ );
57
+ };
@@ -0,0 +1,4 @@
1
+ @import "@cargo-ai/app-sdk/styles.css";
2
+ @tailwind base;
3
+ @tailwind components;
4
+ @tailwind utilities;
@@ -1,12 +1,18 @@
1
- import { StrictMode } from "react";
2
- import { createRoot } from "react-dom/client";
1
+ import React from "react";
2
+ import ReactDOM from "react-dom/client";
3
3
 
4
- function App() {
5
- return <h1>Pipeline Dashboard</h1>;
4
+ import { App } from "./App";
5
+
6
+ import "./index.css";
7
+
8
+ const rootElement = document.getElementById("root");
9
+
10
+ if (rootElement === null) {
11
+ throw new Error("Root element #root not found in index.html");
6
12
  }
7
13
 
8
- createRoot(document.getElementById("root")!).render(
9
- <StrictMode>
14
+ ReactDOM.createRoot(rootElement).render(
15
+ <React.StrictMode>
10
16
  <App />
11
- </StrictMode>,
17
+ </React.StrictMode>,
12
18
  );
@@ -0,0 +1,13 @@
1
+ import cargoPreset from "@cargo-ai/app-sdk/tailwind-preset";
2
+ import type { Config } from "tailwindcss";
3
+
4
+ const config: Config = {
5
+ presets: [cargoPreset],
6
+ content: [
7
+ "./index.html",
8
+ "./src/**/*.{ts,tsx}",
9
+ "./node_modules/@cargo-ai/app-sdk/build/**/*.js",
10
+ ],
11
+ };
12
+
13
+ export default config;
@@ -1,13 +1,20 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "target": "ES2022",
4
+ "useDefineForClassFields": true,
4
5
  "lib": ["ES2022", "DOM", "DOM.Iterable"],
5
6
  "module": "ESNext",
6
- "moduleResolution": "Bundler",
7
+ "skipLibCheck": true,
8
+ "moduleResolution": "bundler",
9
+ "allowImportingTsExtensions": true,
10
+ "resolveJsonModule": true,
11
+ "isolatedModules": true,
12
+ "noEmit": true,
7
13
  "jsx": "react-jsx",
8
14
  "strict": true,
9
- "skipLibCheck": true,
10
- "noEmit": true
15
+ "noUnusedLocals": true,
16
+ "noUnusedParameters": true,
17
+ "noFallthroughCasesInSwitch": true
11
18
  },
12
19
  "include": ["src"]
13
20
  }
@@ -0,0 +1,22 @@
1
+ import react from "@vitejs/plugin-react";
2
+ import autoprefixer from "autoprefixer";
3
+ import tailwindcss from "tailwindcss";
4
+ import { defineConfig } from "vite";
5
+
6
+ // Cargo Hosting bakes VITE_APP_BASE_PATH into the env so apps can be served
7
+ // from a subpath in dev. In production deployments base="/" works because each
8
+ // app gets its own subdomain.
9
+ const base =
10
+ process.env["VITE_APP_BASE_PATH"] !== undefined
11
+ ? process.env["VITE_APP_BASE_PATH"]
12
+ : "/";
13
+
14
+ export default defineConfig({
15
+ plugins: [react()],
16
+ base,
17
+ css: {
18
+ postcss: {
19
+ plugins: [tailwindcss, autoprefixer],
20
+ },
21
+ },
22
+ });
@@ -3,9 +3,9 @@
3
3
  "private": true,
4
4
  "type": "module",
5
5
  "scripts": {
6
- "types": "cargo-ai cdk types",
7
- "plan": "cargo-ai cdk plan",
8
- "deploy": "cargo-ai cdk deploy"
6
+ "types": "cargo-cdk types",
7
+ "plan": "cargo-cdk plan",
8
+ "deploy": "cargo-cdk deploy"
9
9
  },
10
10
  "dependencies": {
11
11
  "@cargo-ai/cdk": "^0.1.0",
@@ -2,5 +2,16 @@
2
2
  "name": "webhook",
3
3
  "version": "1.0.0",
4
4
  "private": true,
5
- "type": "module"
5
+ "type": "module",
6
+ "scripts": {
7
+ "type:check": "tsc --noEmit"
8
+ },
9
+ "dependencies": {
10
+ "@cargo-ai/worker-sdk": "^1.0.3",
11
+ "zod": "4.4.3"
12
+ },
13
+ "devDependencies": {
14
+ "@types/node": "^20.10.8",
15
+ "typescript": "5.3.2"
16
+ }
6
17
  }
@@ -0,0 +1,53 @@
1
+ // The worker is uploaded as *source* and built by Cargo Hosting: the build
2
+ // runs `npm ci` then esbuilds this entry (esbuild transpiles TypeScript
3
+ // natively), so author in TS — no local build step needed.
4
+ //
5
+ // `createWorker` from @cargo-ai/worker-sdk (Hono + Chanfana) means every route
6
+ // registered on `openapi` is described in the generated OpenAPI 3.1 spec
7
+ // (served at `/openapi.json`) and browsable at `/docs`.
8
+ import { type Context, createWorker, OpenAPIRoute } from "@cargo-ai/worker-sdk";
9
+ import { z } from "zod";
10
+
11
+ const { app, openapi } = createWorker({
12
+ title: "webhook",
13
+ description: "Receives inbound lead webhooks.",
14
+ });
15
+
16
+ class ReceiveLead extends OpenAPIRoute {
17
+ override schema = {
18
+ tags: ["leads"],
19
+ summary: "Receive an inbound lead.",
20
+ request: {
21
+ body: {
22
+ content: {
23
+ "application/json": {
24
+ schema: z.object({
25
+ email: z.string().email().describe("Lead's email address."),
26
+ name: z.string().optional().describe("Lead's full name."),
27
+ company: z.string().optional().describe("Lead's company."),
28
+ }),
29
+ },
30
+ },
31
+ },
32
+ },
33
+ responses: {
34
+ 200: {
35
+ description: "Lead accepted.",
36
+ content: {
37
+ "application/json": {
38
+ schema: z.object({ accepted: z.literal(true) }),
39
+ },
40
+ },
41
+ },
42
+ },
43
+ };
44
+
45
+ override async handle(c: Context): Promise<Response> {
46
+ await this.getValidatedData<typeof this.schema>();
47
+ return c.json({ accepted: true as const });
48
+ }
49
+ }
50
+
51
+ openapi.post("/", ReceiveLead);
52
+
53
+ export default app;
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "NodeNext",
5
+ "moduleResolution": "nodenext",
6
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
7
+ "strict": true,
8
+ "skipLibCheck": true,
9
+ "esModuleInterop": true,
10
+ "resolveJsonModule": true,
11
+ "noEmit": true
12
+ },
13
+ "include": ["src/**/*.ts"]
14
+ }
@@ -1,12 +1,14 @@
1
1
  import { defineWorker } from "@cargo-ai/cdk";
2
2
 
3
- // `defineWorker` is the *resource* — the hosted worker slot. Its `path` points to
4
- // a *built* bundle directory: a root `index.js` (the hosting build runs `npm ci`
5
- // then esbuild — no TS transpile), plus `manifest.json`, `package.json` and
6
- // `package-lock.json`. The CDK validates those exist at define time. Author in TS
7
- // with `createWorker` from @cargo-ai/worker-sdk and build to `index.js`. On
8
- // deploy the reconciler uploads the bundle, waits for the build, and promotes it.
9
- // The live URL is available as `webhook.url`.
3
+ // `defineWorker` is the *resource* — the hosted worker slot. Its `path` points
4
+ // to a worker source directory: a TS entry (`src/index.ts`) authored with
5
+ // `createWorker` from @cargo-ai/worker-sdk, plus `manifest.json`,
6
+ // `package.json` and `package-lock.json`. Like an app, the worker is uploaded
7
+ // as source and built by Cargo Hosting (the build runs `npm ci` then esbuilds
8
+ // the entry esbuild transpiles TypeScript natively). The CDK validates those
9
+ // files exist at define time. On deploy the reconciler uploads the bundle,
10
+ // waits for the build, and promotes it. The live URL is available as
11
+ // `webhook.url`.
10
12
  export const webhook = defineWorker("webhook", {
11
13
  path: new URL("./webhook", import.meta.url).pathname,
12
14
  description: "Receives inbound lead webhooks.",