@cargo-ai/cdk 0.1.1

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 (122) hide show
  1. package/README.md +187 -0
  2. package/build/src/core.d.ts +83 -0
  3. package/build/src/core.d.ts.map +1 -0
  4. package/build/src/core.js +205 -0
  5. package/build/src/deploy/apply.d.ts +55 -0
  6. package/build/src/deploy/apply.d.ts.map +1 -0
  7. package/build/src/deploy/apply.js +219 -0
  8. package/build/src/deploy/audit.d.ts +14 -0
  9. package/build/src/deploy/audit.d.ts.map +1 -0
  10. package/build/src/deploy/audit.js +25 -0
  11. package/build/src/deploy/compile.d.ts +36 -0
  12. package/build/src/deploy/compile.d.ts.map +1 -0
  13. package/build/src/deploy/compile.js +99 -0
  14. package/build/src/deploy/destroy.d.ts +20 -0
  15. package/build/src/deploy/destroy.d.ts.map +1 -0
  16. package/build/src/deploy/destroy.js +153 -0
  17. package/build/src/deploy/executors.live.d.ts +4 -0
  18. package/build/src/deploy/executors.live.d.ts.map +1 -0
  19. package/build/src/deploy/executors.live.js +623 -0
  20. package/build/src/deploy/import.d.ts +13 -0
  21. package/build/src/deploy/import.d.ts.map +1 -0
  22. package/build/src/deploy/import.js +87 -0
  23. package/build/src/deploy/index.d.ts +39 -0
  24. package/build/src/deploy/index.d.ts.map +1 -0
  25. package/build/src/deploy/index.js +51 -0
  26. package/build/src/deploy/load.d.ts +7 -0
  27. package/build/src/deploy/load.d.ts.map +1 -0
  28. package/build/src/deploy/load.js +58 -0
  29. package/build/src/deploy/lock.d.ts +10 -0
  30. package/build/src/deploy/lock.d.ts.map +1 -0
  31. package/build/src/deploy/lock.js +101 -0
  32. package/build/src/deploy/plan.d.ts +3 -0
  33. package/build/src/deploy/plan.d.ts.map +1 -0
  34. package/build/src/deploy/plan.js +39 -0
  35. package/build/src/deploy/readers.live.d.ts +4 -0
  36. package/build/src/deploy/readers.live.d.ts.map +1 -0
  37. package/build/src/deploy/readers.live.js +273 -0
  38. package/build/src/deploy/refresh.d.ts +32 -0
  39. package/build/src/deploy/refresh.d.ts.map +1 -0
  40. package/build/src/deploy/refresh.js +76 -0
  41. package/build/src/deploy/state.d.ts +23 -0
  42. package/build/src/deploy/state.d.ts.map +1 -0
  43. package/build/src/deploy/state.js +107 -0
  44. package/build/src/index.d.ts +30 -0
  45. package/build/src/index.d.ts.map +1 -0
  46. package/build/src/index.js +30 -0
  47. package/build/src/refs.d.ts +28 -0
  48. package/build/src/refs.d.ts.map +1 -0
  49. package/build/src/refs.js +34 -0
  50. package/build/src/resources/actions.d.ts +31 -0
  51. package/build/src/resources/actions.d.ts.map +1 -0
  52. package/build/src/resources/actions.js +44 -0
  53. package/build/src/resources/agent.d.ts +71 -0
  54. package/build/src/resources/agent.d.ts.map +1 -0
  55. package/build/src/resources/agent.js +96 -0
  56. package/build/src/resources/app.d.ts +18 -0
  57. package/build/src/resources/app.d.ts.map +1 -0
  58. package/build/src/resources/app.js +33 -0
  59. package/build/src/resources/bundle.d.ts +15 -0
  60. package/build/src/resources/bundle.d.ts.map +1 -0
  61. package/build/src/resources/bundle.js +61 -0
  62. package/build/src/resources/connector.d.ts +30 -0
  63. package/build/src/resources/connector.d.ts.map +1 -0
  64. package/build/src/resources/connector.js +41 -0
  65. package/build/src/resources/context.d.ts +15 -0
  66. package/build/src/resources/context.d.ts.map +1 -0
  67. package/build/src/resources/context.js +58 -0
  68. package/build/src/resources/file.d.ts +15 -0
  69. package/build/src/resources/file.d.ts.map +1 -0
  70. package/build/src/resources/file.js +35 -0
  71. package/build/src/resources/folder.d.ts +20 -0
  72. package/build/src/resources/folder.d.ts.map +1 -0
  73. package/build/src/resources/folder.js +28 -0
  74. package/build/src/resources/mcpServer.d.ts +25 -0
  75. package/build/src/resources/mcpServer.d.ts.map +1 -0
  76. package/build/src/resources/mcpServer.js +34 -0
  77. package/build/src/resources/model.d.ts +34 -0
  78. package/build/src/resources/model.d.ts.map +1 -0
  79. package/build/src/resources/model.js +43 -0
  80. package/build/src/resources/play.d.ts +35 -0
  81. package/build/src/resources/play.d.ts.map +1 -0
  82. package/build/src/resources/play.js +49 -0
  83. package/build/src/resources/tool.d.ts +40 -0
  84. package/build/src/resources/tool.d.ts.map +1 -0
  85. package/build/src/resources/tool.js +36 -0
  86. package/build/src/resources/worker.d.ts +18 -0
  87. package/build/src/resources/worker.d.ts.map +1 -0
  88. package/build/src/resources/worker.js +40 -0
  89. package/build/tsconfig.tsbuildinfo +1 -0
  90. package/package.json +71 -0
  91. package/templates/blank/README.md +24 -0
  92. package/templates/blank/cargo.ts +44 -0
  93. package/templates/blank/package.json +17 -0
  94. package/templates/blank/tsconfig.json +14 -0
  95. package/templates/full/README.md +69 -0
  96. package/templates/full/agents/enricher.ts +13 -0
  97. package/templates/full/agents/sdr.ts +28 -0
  98. package/templates/full/apps/dashboard/index.html +12 -0
  99. package/templates/full/apps/dashboard/package-lock.json +1080 -0
  100. package/templates/full/apps/dashboard/package.json +15 -0
  101. package/templates/full/apps/dashboard/src/main.tsx +12 -0
  102. package/templates/full/apps/dashboard/tsconfig.json +13 -0
  103. package/templates/full/apps/dashboard.ts +9 -0
  104. package/templates/full/connectors/hubspot.ts +12 -0
  105. package/templates/full/connectors/openai.ts +9 -0
  106. package/templates/full/context/context.ts +7 -0
  107. package/templates/full/context/icp.md +22 -0
  108. package/templates/full/context/personas/head-of-growth.md +26 -0
  109. package/templates/full/files/playbook.md +19 -0
  110. package/templates/full/files/playbook.ts +8 -0
  111. package/templates/full/folders/crm.ts +14 -0
  112. package/templates/full/mcp/crm.ts +15 -0
  113. package/templates/full/models/contacts.ts +15 -0
  114. package/templates/full/package.json +17 -0
  115. package/templates/full/plays/onboarding.ts +41 -0
  116. package/templates/full/tools/enrich.ts +34 -0
  117. package/templates/full/tsconfig.json +17 -0
  118. package/templates/full/workers/webhook/index.js +12 -0
  119. package/templates/full/workers/webhook/manifest.json +1 -0
  120. package/templates/full/workers/webhook/package-lock.json +12 -0
  121. package/templates/full/workers/webhook/package.json +6 -0
  122. package/templates/full/workers/webhook.ts +13 -0
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "dashboard",
3
+ "private": true,
4
+ "type": "module",
5
+ "scripts": {
6
+ "build": "vite build"
7
+ },
8
+ "dependencies": {
9
+ "react": "^18.3.1",
10
+ "react-dom": "^18.3.1"
11
+ },
12
+ "devDependencies": {
13
+ "vite": "^5.4.0"
14
+ }
15
+ }
@@ -0,0 +1,12 @@
1
+ import { StrictMode } from "react";
2
+ import { createRoot } from "react-dom/client";
3
+
4
+ function App() {
5
+ return <h1>Pipeline Dashboard</h1>;
6
+ }
7
+
8
+ createRoot(document.getElementById("root")!).render(
9
+ <StrictMode>
10
+ <App />
11
+ </StrictMode>,
12
+ );
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
5
+ "module": "ESNext",
6
+ "moduleResolution": "Bundler",
7
+ "jsx": "react-jsx",
8
+ "strict": true,
9
+ "skipLibCheck": true,
10
+ "noEmit": true
11
+ },
12
+ "include": ["src"]
13
+ }
@@ -0,0 +1,9 @@
1
+ import { defineApp } from "@cargo-ai/cdk";
2
+
3
+ // A hosted Cargo app, deployed from a Vite app directory. On deploy the
4
+ // reconciler uploads the bundle and the backend builds + promotes it. The live
5
+ // URL is available as `dashboard.url`.
6
+ export const dashboard = defineApp("dashboard", {
7
+ path: new URL("./dashboard", import.meta.url).pathname,
8
+ description: "Pipeline overview for the sales team.",
9
+ });
@@ -0,0 +1,12 @@
1
+ import { defineConnector, secret } from "@cargo-ai/cdk";
2
+
3
+ // A data-source connector. Creating it auto-creates a dataset, which data models
4
+ // source from (via `dataset: hubspot`). HubSpot's config is a discriminated
5
+ // union — a Private App access token (here) or OAuth refresh token. `secret()`
6
+ // reads the value from the environment at deploy time and keeps it out of the
7
+ // content hash, so rotating the token doesn't read as drift.
8
+
9
+ export const hubspot = defineConnector("hubspot", {
10
+ integration: "hubspot",
11
+ config: { method: "privateApp", accessToken: secret("HUBSPOT_API_KEY") },
12
+ });
@@ -0,0 +1,9 @@
1
+ import { defineConnector } from "@cargo-ai/cdk";
2
+
3
+ // The LLM provider connector. OAuth/key-based connectors that can't be declared
4
+ // in code use `adopt: true` — the reconciler links the existing authenticated
5
+ // connector by slug instead of creating one. Agents reference it by handle: `openai`.
6
+ export const openai = defineConnector("open_ai", {
7
+ integration: "openAi",
8
+ adopt: true,
9
+ });
@@ -0,0 +1,7 @@
1
+ import { defineContext } from "@cargo-ai/cdk";
2
+
3
+ // The workspace's context repository (its GTM knowledge base) as code. `dir`
4
+ // syncs this folder's markdown/MDX into the repo on deploy — additive, so files
5
+ // added in the UI are left in place. Edit a doc and it re-syncs; new `.md`/`.mdx`
6
+ // files are picked up automatically.
7
+ export const context = defineContext({ dir: "context" });
@@ -0,0 +1,22 @@
1
+ ---
2
+ title: Ideal Customer Profile
3
+ tags: [icp, targeting]
4
+ ---
5
+
6
+ # Ideal Customer Profile
7
+
8
+ B2B SaaS companies, **50–500 employees**, with a dedicated revenue/GTM team.
9
+
10
+ ## Firmographics
11
+
12
+ - Industry: SaaS, fintech, developer tools
13
+ - Region: North America + Western Europe
14
+ - Signals: recent funding, hiring for sales/RevOps, using a modern CRM
15
+
16
+ ## Qualifying questions
17
+
18
+ 1. Do they run outbound today?
19
+ 2. Is there an owner for GTM data quality?
20
+ 3. Are they enriching or scoring leads already?
21
+
22
+ Related: [[personas/head-of-growth]]
@@ -0,0 +1,26 @@
1
+ ---
2
+ title: Head of Growth
3
+ tags: [persona]
4
+ ---
5
+
6
+ # Persona — Head of Growth
7
+
8
+ The economic buyer for a GTM automation platform.
9
+
10
+ ## Goals
11
+
12
+ - Predictable pipeline from outbound + inbound
13
+ - Clean, enriched, deduplicated CRM data
14
+ - Fast experimentation on sequences and scoring
15
+
16
+ ## Pains
17
+
18
+ - Reps waste time on manual research and data entry
19
+ - Lead data is stale, incomplete, or duplicated
20
+ - No single place to encode GTM playbooks
21
+
22
+ ## Message
23
+
24
+ "Encode your GTM motion once — enrichment, scoring, routing — and let it run."
25
+
26
+ Fits: [[../icp]]
@@ -0,0 +1,19 @@
1
+ # SDR Playbook
2
+
3
+ ## Qualification
4
+
5
+ A lead is **hot** when all of the following hold:
6
+
7
+ - Work email verified
8
+ - Company has 50+ employees
9
+ - Title contains one of: VP, Director, Head, Chief
10
+
11
+ ## Routing
12
+
13
+ - Hot leads → notify `#sales` in Slack within 5 minutes.
14
+ - Warm leads → enqueue for nurture sequence.
15
+ - Cold leads → enrich and re-score weekly.
16
+
17
+ ## Tone
18
+
19
+ Be concise, specific, and never overpromise.
@@ -0,0 +1,8 @@
1
+ import { defineFile } from "@cargo-ai/cdk";
2
+
3
+ // A content file uploaded from a local path. The content is read + hashed at
4
+ // define time, so editing playbook.md shows as drift on the next deploy.
5
+ export const playbook = defineFile("playbook", {
6
+ path: new URL("./playbook.md", import.meta.url).pathname,
7
+ name: "SDR Playbook",
8
+ });
@@ -0,0 +1,14 @@
1
+ import { defineFolder } from "@cargo-ai/cdk";
2
+
3
+ // Folders organize resources and are per-kind, so a "models" folder and an
4
+ // "agents" folder are separate resources. Other resources reference them via
5
+ // their `folder`.
6
+ export const modelsFolder = defineFolder("crm-models", {
7
+ kind: "model",
8
+ name: "CRM",
9
+ });
10
+
11
+ export const agentsFolder = defineFolder("crm-agents", {
12
+ kind: "agent",
13
+ name: "CRM",
14
+ });
@@ -0,0 +1,15 @@
1
+ import { defineMcpServer } from "@cargo-ai/cdk";
2
+
3
+ import { sdr } from "../agents/sdr";
4
+ import { contacts } from "../models/contacts";
5
+ import { enrich } from "../tools/enrich";
6
+
7
+ // An MCP server bundles tools, agents, and data models behind one MCP endpoint.
8
+ // Each is referenced by handle (bare, or `{ ref, …options }` for options), so
9
+ // the reconciler resolves each to its deployed action/resource.
10
+ export const crmServer = defineMcpServer("crm", {
11
+ description: "CRM tools and data for assistants.",
12
+ tools: [enrich],
13
+ agents: [sdr],
14
+ models: [{ ref: contacts, readOnly: true }],
15
+ });
@@ -0,0 +1,15 @@
1
+ import { defineModel } from "@cargo-ai/cdk";
2
+
3
+ import { hubspot } from "../connectors/hubspot";
4
+ import { modelsFolder } from "../folders/crm";
5
+
6
+ // A data model: a table sourced from a connector's dataset by an extractor.
7
+ // `dataset` wires it to the connector (deployed first, its dataset injected);
8
+ // `folder` places it in the CRM models folder.
9
+ export const contacts = defineModel("contacts", {
10
+ dataset: hubspot,
11
+ extractSlug: "fetchRecords",
12
+ config: { objectType: "contacts", columnSelectionMode: "all" },
13
+ folder: modelsFolder,
14
+ schedule: { type: "cron", cron: "0 * * * *" }, // refresh hourly
15
+ });
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "__APP_NAME__",
3
+ "private": true,
4
+ "type": "module",
5
+ "scripts": {
6
+ "types": "cargo-ai cdk types",
7
+ "plan": "cargo-ai cdk plan",
8
+ "deploy": "cargo-ai cdk deploy"
9
+ },
10
+ "dependencies": {
11
+ "@cargo-ai/cdk": "^0.1.0",
12
+ "zod": "^4.4.3"
13
+ },
14
+ "devDependencies": {
15
+ "typescript": "^5.3.2"
16
+ }
17
+ }
@@ -0,0 +1,41 @@
1
+ import { definePlay, defineWorkflow } from "@cargo-ai/cdk";
2
+ import { z } from "zod";
3
+
4
+ import { contacts } from "../models/contacts";
5
+ import { enrich } from "../tools/enrich";
6
+
7
+ // The per-row automation run for each contact the play emits — deployed as the
8
+ // play's release. `defineWorkflow` compiles the logic; it is never executed at
9
+ // build time.
10
+ //
11
+ // `uses` forward-references the `enrich` tool by handle, so the body runs it for
12
+ // each row (`uses.enrich(...)`) and the CDK wires the deploy dependency. `ai(...)`
13
+ // then drafts a welcome, interpolating the tool's result.
14
+ const onboardRow = defineWorkflow(
15
+ "onboard-contact",
16
+ {
17
+ input: z.object({ email: z.string() }),
18
+ output: z.object({ welcomed: z.boolean(), message: z.string() }),
19
+ uses: { enrich },
20
+ },
21
+ ({ input, uses, ai }) => {
22
+ // `uses.enrich(...)` is typed to the tool's output, so `enriched.company`
23
+ // is a `Ref<string>` — member access is checked.
24
+ const enriched = uses.enrich({ email: input.email });
25
+
26
+ const message = ai(
27
+ `Draft a one-line welcome message for ${input.email} at ${enriched.company}.`,
28
+ );
29
+ return { welcomed: true, message };
30
+ },
31
+ );
32
+
33
+ // A play runs over a data model and emits runs as its rows change. Here it fires
34
+ // when a contact is added or updated, running `onboardRow` for each.
35
+ export const onboarding = definePlay("onboarding", {
36
+ model: contacts,
37
+ workflow: onboardRow,
38
+ changeKinds: ["added", "updated"],
39
+ runCreationRule: "always",
40
+ schedule: { type: "watch" },
41
+ });
@@ -0,0 +1,34 @@
1
+ import { defineTool, defineWorkflow } from "@cargo-ai/cdk";
2
+ import { z } from "zod";
3
+
4
+ import { enricher } from "../agents/enricher";
5
+
6
+ // A tool is backed by a workflow. `defineWorkflow` compiles the logic; `defineTool`
7
+ // creates the tool + deploys that workflow as its release.
8
+ //
9
+ // `uses` forward-references other resources by handle — here the `enricher` agent.
10
+ // The body calls it as `uses.enricher(...)`, and because the handle carries a
11
+ // deferred `uuid` token, the CDK both orders the deploy (enricher first) and
12
+ // injects the real uuid into the emitted node. The body is parsed and lowered to
13
+ // workflow nodes — never executed at build time.
14
+ const enrichFlow = defineWorkflow(
15
+ "enrich-contact",
16
+ {
17
+ input: z.object({ email: z.string() }),
18
+ output: z.object({ company: z.string(), enriched: z.boolean() }),
19
+ uses: { enricher },
20
+ },
21
+ ({ input, uses }) => {
22
+ const company = uses.enricher({
23
+ prompt: `Which company owns the email domain of ${input.email}? Reply with just the company name.`,
24
+ });
25
+ return { company, enriched: true };
26
+ },
27
+ );
28
+
29
+ export const enrich = defineTool("enrich", {
30
+ workflow: enrichFlow,
31
+ description: "Enrich a contact with firmographic data.",
32
+ emojiSlug: "mag",
33
+ triggers: [{ cron: "0 9 * * 1", name: "Weekly enrichment" }],
34
+ });
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Bundler",
6
+ "strict": true,
7
+ "skipLibCheck": true,
8
+ "noEmit": true,
9
+ "types": []
10
+ },
11
+ // The resource files plus `.cargo-ai` (types generated by `cargo-ai cdk types`)
12
+ // — including it here is what makes defineConnector/defineModel config typed.
13
+ // The app/worker bundle sub-projects are self-contained (own tsconfig), so they
14
+ // are excluded from this project.
15
+ "include": ["**/*.ts", ".cargo-ai/**/*.d.ts"],
16
+ "exclude": ["node_modules", "apps/*/**", "workers/*/**"]
17
+ }
@@ -0,0 +1,12 @@
1
+ // A worker bundle is deployed *built*: the hosting build runs `npm ci` then
2
+ // esbuild's this `index.js` (no TS transpile). Author in TS with
3
+ // `createWorker` from @cargo-ai/worker-sdk if you like, but `defineWorker` must
4
+ // point at a directory whose root has the built `index.js` plus `manifest.json`,
5
+ // `package.json` and `package-lock.json`.
6
+ export default {
7
+ fetch() {
8
+ return new Response(JSON.stringify({ accepted: true }), {
9
+ headers: { "content-type": "application/json" },
10
+ });
11
+ },
12
+ };
@@ -0,0 +1 @@
1
+ { "outboundAllowlist": [] }
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "webhook",
3
+ "version": "1.0.0",
4
+ "lockfileVersion": 3,
5
+ "requires": true,
6
+ "packages": {
7
+ "": {
8
+ "name": "webhook",
9
+ "version": "1.0.0"
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "webhook",
3
+ "version": "1.0.0",
4
+ "private": true,
5
+ "type": "module"
6
+ }
@@ -0,0 +1,13 @@
1
+ import { defineWorker } from "@cargo-ai/cdk";
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`.
10
+ export const webhook = defineWorker("webhook", {
11
+ path: new URL("./webhook", import.meta.url).pathname,
12
+ description: "Receives inbound lead webhooks.",
13
+ });