@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.
- package/README.md +187 -0
- package/build/src/core.d.ts +83 -0
- package/build/src/core.d.ts.map +1 -0
- package/build/src/core.js +205 -0
- package/build/src/deploy/apply.d.ts +55 -0
- package/build/src/deploy/apply.d.ts.map +1 -0
- package/build/src/deploy/apply.js +219 -0
- package/build/src/deploy/audit.d.ts +14 -0
- package/build/src/deploy/audit.d.ts.map +1 -0
- package/build/src/deploy/audit.js +25 -0
- package/build/src/deploy/compile.d.ts +36 -0
- package/build/src/deploy/compile.d.ts.map +1 -0
- package/build/src/deploy/compile.js +99 -0
- package/build/src/deploy/destroy.d.ts +20 -0
- package/build/src/deploy/destroy.d.ts.map +1 -0
- package/build/src/deploy/destroy.js +153 -0
- package/build/src/deploy/executors.live.d.ts +4 -0
- package/build/src/deploy/executors.live.d.ts.map +1 -0
- package/build/src/deploy/executors.live.js +623 -0
- package/build/src/deploy/import.d.ts +13 -0
- package/build/src/deploy/import.d.ts.map +1 -0
- package/build/src/deploy/import.js +87 -0
- package/build/src/deploy/index.d.ts +39 -0
- package/build/src/deploy/index.d.ts.map +1 -0
- package/build/src/deploy/index.js +51 -0
- package/build/src/deploy/load.d.ts +7 -0
- package/build/src/deploy/load.d.ts.map +1 -0
- package/build/src/deploy/load.js +58 -0
- package/build/src/deploy/lock.d.ts +10 -0
- package/build/src/deploy/lock.d.ts.map +1 -0
- package/build/src/deploy/lock.js +101 -0
- package/build/src/deploy/plan.d.ts +3 -0
- package/build/src/deploy/plan.d.ts.map +1 -0
- package/build/src/deploy/plan.js +39 -0
- package/build/src/deploy/readers.live.d.ts +4 -0
- package/build/src/deploy/readers.live.d.ts.map +1 -0
- package/build/src/deploy/readers.live.js +273 -0
- package/build/src/deploy/refresh.d.ts +32 -0
- package/build/src/deploy/refresh.d.ts.map +1 -0
- package/build/src/deploy/refresh.js +76 -0
- package/build/src/deploy/state.d.ts +23 -0
- package/build/src/deploy/state.d.ts.map +1 -0
- package/build/src/deploy/state.js +107 -0
- package/build/src/index.d.ts +30 -0
- package/build/src/index.d.ts.map +1 -0
- package/build/src/index.js +30 -0
- package/build/src/refs.d.ts +28 -0
- package/build/src/refs.d.ts.map +1 -0
- package/build/src/refs.js +34 -0
- package/build/src/resources/actions.d.ts +31 -0
- package/build/src/resources/actions.d.ts.map +1 -0
- package/build/src/resources/actions.js +44 -0
- package/build/src/resources/agent.d.ts +71 -0
- package/build/src/resources/agent.d.ts.map +1 -0
- package/build/src/resources/agent.js +96 -0
- package/build/src/resources/app.d.ts +18 -0
- package/build/src/resources/app.d.ts.map +1 -0
- package/build/src/resources/app.js +33 -0
- package/build/src/resources/bundle.d.ts +15 -0
- package/build/src/resources/bundle.d.ts.map +1 -0
- package/build/src/resources/bundle.js +61 -0
- package/build/src/resources/connector.d.ts +30 -0
- package/build/src/resources/connector.d.ts.map +1 -0
- package/build/src/resources/connector.js +41 -0
- package/build/src/resources/context.d.ts +15 -0
- package/build/src/resources/context.d.ts.map +1 -0
- package/build/src/resources/context.js +58 -0
- package/build/src/resources/file.d.ts +15 -0
- package/build/src/resources/file.d.ts.map +1 -0
- package/build/src/resources/file.js +35 -0
- package/build/src/resources/folder.d.ts +20 -0
- package/build/src/resources/folder.d.ts.map +1 -0
- package/build/src/resources/folder.js +28 -0
- package/build/src/resources/mcpServer.d.ts +25 -0
- package/build/src/resources/mcpServer.d.ts.map +1 -0
- package/build/src/resources/mcpServer.js +34 -0
- package/build/src/resources/model.d.ts +34 -0
- package/build/src/resources/model.d.ts.map +1 -0
- package/build/src/resources/model.js +43 -0
- package/build/src/resources/play.d.ts +35 -0
- package/build/src/resources/play.d.ts.map +1 -0
- package/build/src/resources/play.js +49 -0
- package/build/src/resources/tool.d.ts +40 -0
- package/build/src/resources/tool.d.ts.map +1 -0
- package/build/src/resources/tool.js +36 -0
- package/build/src/resources/worker.d.ts +18 -0
- package/build/src/resources/worker.d.ts.map +1 -0
- package/build/src/resources/worker.js +40 -0
- package/build/tsconfig.tsbuildinfo +1 -0
- package/package.json +71 -0
- package/templates/blank/README.md +24 -0
- package/templates/blank/cargo.ts +44 -0
- package/templates/blank/package.json +17 -0
- package/templates/blank/tsconfig.json +14 -0
- package/templates/full/README.md +69 -0
- package/templates/full/agents/enricher.ts +13 -0
- package/templates/full/agents/sdr.ts +28 -0
- package/templates/full/apps/dashboard/index.html +12 -0
- package/templates/full/apps/dashboard/package-lock.json +1080 -0
- package/templates/full/apps/dashboard/package.json +15 -0
- package/templates/full/apps/dashboard/src/main.tsx +12 -0
- package/templates/full/apps/dashboard/tsconfig.json +13 -0
- package/templates/full/apps/dashboard.ts +9 -0
- package/templates/full/connectors/hubspot.ts +12 -0
- package/templates/full/connectors/openai.ts +9 -0
- package/templates/full/context/context.ts +7 -0
- package/templates/full/context/icp.md +22 -0
- package/templates/full/context/personas/head-of-growth.md +26 -0
- package/templates/full/files/playbook.md +19 -0
- package/templates/full/files/playbook.ts +8 -0
- package/templates/full/folders/crm.ts +14 -0
- package/templates/full/mcp/crm.ts +15 -0
- package/templates/full/models/contacts.ts +15 -0
- package/templates/full/package.json +17 -0
- package/templates/full/plays/onboarding.ts +41 -0
- package/templates/full/tools/enrich.ts +34 -0
- package/templates/full/tsconfig.json +17 -0
- package/templates/full/workers/webhook/index.js +12 -0
- package/templates/full/workers/webhook/manifest.json +1 -0
- package/templates/full/workers/webhook/package-lock.json +12 -0
- package/templates/full/workers/webhook/package.json +6 -0
- package/templates/full/workers/webhook.ts +13 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# **APP_NAME**
|
|
2
|
+
|
|
3
|
+
A Cargo CDK project — define your Cargo resources in code and deploy them.
|
|
4
|
+
|
|
5
|
+
## Commands
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install
|
|
9
|
+
cargo-ai login # authenticate to your workspace
|
|
10
|
+
cargo-ai cdk types # generate typed connector/model config into .cargo-ai/
|
|
11
|
+
cargo-ai cdk plan # compile the resource tree and diff against cargo.state.json
|
|
12
|
+
cargo-ai cdk deploy # create/update resources and write cargo.state.json
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Layout
|
|
16
|
+
|
|
17
|
+
- `cargo.ts` — your resources (`defineConnector`, `defineModel`, `defineTool`, …).
|
|
18
|
+
- `cargo.state.json` — deploy state (uuids). Commit it: it's the only link from
|
|
19
|
+
code to the play/agent resources it created.
|
|
20
|
+
- `.cargo-ai/` — generated types. Re-run `cargo-ai cdk types` after adding or
|
|
21
|
+
changing workspace integrations.
|
|
22
|
+
|
|
23
|
+
Secrets referenced with `secret("ENV_VAR")` are read from the environment at
|
|
24
|
+
deploy time — export them before running `cargo-ai cdk deploy`.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineConnector,
|
|
3
|
+
defineModel,
|
|
4
|
+
defineTool,
|
|
5
|
+
defineWorkflow,
|
|
6
|
+
secret,
|
|
7
|
+
} from "@cargo-ai/cdk";
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
|
|
10
|
+
// A data-source connector. After `cargo-ai cdk types`, `config` is typed against
|
|
11
|
+
// the integration's schema and `secret()` reads the value from the environment
|
|
12
|
+
// at deploy time (kept out of the committed state + content hash).
|
|
13
|
+
export const hubspot = defineConnector("hubspot", {
|
|
14
|
+
integration: "hubspot",
|
|
15
|
+
config: { method: "privateApp", accessToken: secret("HUBSPOT_API_KEY") },
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// A data model sourced from the connector's dataset by one of its extractors.
|
|
19
|
+
export const contacts = defineModel("contacts", {
|
|
20
|
+
dataset: hubspot,
|
|
21
|
+
extractSlug: "fetchRecords",
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// A tool backed by a workflow. The body is parsed at build time and lowered to
|
|
25
|
+
// workflow nodes — never executed here. `ai(...)` becomes an inference node.
|
|
26
|
+
const enrichFlow = defineWorkflow(
|
|
27
|
+
"enrich-contact",
|
|
28
|
+
{
|
|
29
|
+
input: z.object({ email: z.string() }),
|
|
30
|
+
output: z.object({ company: z.string() }),
|
|
31
|
+
},
|
|
32
|
+
({ input, ai }) => {
|
|
33
|
+
const company = ai(
|
|
34
|
+
`What company owns the email domain of ${input.email}? Reply with just the company name.`,
|
|
35
|
+
);
|
|
36
|
+
return { company };
|
|
37
|
+
},
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
export const enrich = defineTool("enrich", {
|
|
41
|
+
workflow: enrichFlow,
|
|
42
|
+
description: "Enrich a contact with firmographic data.",
|
|
43
|
+
emojiSlug: "mag",
|
|
44
|
+
});
|
|
@@ -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,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
"noEmit": true
|
|
9
|
+
},
|
|
10
|
+
// `.cargo-ai` holds the types `cargo-ai cdk types` generates — the explicit
|
|
11
|
+
// glob is required: a bare `.cargo-ai` (a dot-dir) isn't picked up by
|
|
12
|
+
// TypeScript's default include.
|
|
13
|
+
"include": ["*.ts", ".cargo-ai/**/*.d.ts"]
|
|
14
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# **APP_NAME** — a full GTM growth workspace
|
|
2
|
+
|
|
3
|
+
A complete, runnable Cargo workspace defined entirely in code (the `full` CDK
|
|
4
|
+
template — `cargo-ai cdk init <dir> --template full`). It exercises every resource
|
|
5
|
+
type and wires them together with **handles** — you pass a `define*` handle
|
|
6
|
+
(e.g. `dataset: hubspot`, `models: [{ ref: contacts }]`) into another builder,
|
|
7
|
+
and the reconciler deploys them in dependency order and injects the real uuids.
|
|
8
|
+
|
|
9
|
+
## The graph
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
hubspot (connector) ──dataset──▶ contacts (model) ──model──────────┬─▶ onboarding (play)
|
|
13
|
+
├─▶ sdr (agent)
|
|
14
|
+
openai (connector) ──connector──▶ enricher (agent) ──subAgent──▶ sdr│
|
|
15
|
+
└────────connector──────────────────▶ sdr ─────┘
|
|
16
|
+
enrich (tool, backed by a workflow) ─┐
|
|
17
|
+
sdr (agent) ─────────────────────────┼─▶ crm (mcpServer)
|
|
18
|
+
contacts (model) ────────────────────┘
|
|
19
|
+
playbook (file) webhook (worker) dashboard (app)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## What each file shows
|
|
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`) |
|
|
39
|
+
|
|
40
|
+
`defineWorker` vs `createWorker`: `defineWorker` is the deployable **resource**
|
|
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.
|
|
47
|
+
|
|
48
|
+
## Try it
|
|
49
|
+
|
|
50
|
+
From this project directory:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
cargo-ai login # authenticate to your workspace
|
|
54
|
+
cargo-ai cdk types # type defineConnector/defineModel config against your workspace
|
|
55
|
+
cargo-ai cdk plan # offline: compile the graph and diff against cargo.state.json
|
|
56
|
+
cargo-ai cdk deploy # create everything (needs a selected workspace)
|
|
57
|
+
cargo-ai cdk destroy # tear down everything recorded in state
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Importing a file _is_ registration — there is no manifest. The loader imports
|
|
61
|
+
every `.ts` under this directory (skipping the worker/app bundle sub-dirs), and
|
|
62
|
+
each `define*` call registers itself as a side effect. Deploying writes
|
|
63
|
+
`cargo.state.json` (uuids of what was created) — commit it so the next deploy
|
|
64
|
+
diffs against it.
|
|
65
|
+
|
|
66
|
+
Secrets referenced with `secret("HUBSPOT_API_KEY")` resolve from the environment
|
|
67
|
+
at deploy time — export them before deploying — and stay out of the content hash,
|
|
68
|
+
so rotating a token doesn't read as drift. Only `{hash, uuid, outputs}` land in
|
|
69
|
+
state — secret values never do.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineAgent } from "@cargo-ai/cdk";
|
|
2
|
+
|
|
3
|
+
import { openai } from "../connectors/openai";
|
|
4
|
+
|
|
5
|
+
// A focused sub-agent. The LLM is wired by `connector` (its integration slug is
|
|
6
|
+
// resolved from the connector at deploy) + a `languageModel` slug.
|
|
7
|
+
export const enricher = defineAgent("enricher", {
|
|
8
|
+
connector: openai,
|
|
9
|
+
languageModel: "gpt-4o",
|
|
10
|
+
systemPrompt: "You find and verify a contact's work email. Be precise.",
|
|
11
|
+
maxSteps: 6,
|
|
12
|
+
capabilities: ["webSearch"],
|
|
13
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineAgent } from "@cargo-ai/cdk";
|
|
2
|
+
|
|
3
|
+
import { openai } from "../connectors/openai";
|
|
4
|
+
import { agentsFolder } from "../folders/crm";
|
|
5
|
+
import { contacts } from "../models/contacts";
|
|
6
|
+
import { enrich } from "../tools/enrich";
|
|
7
|
+
import { enricher } from "./enricher";
|
|
8
|
+
|
|
9
|
+
// The main agent. It references a data model (`models`), a tool (`tools`), a
|
|
10
|
+
// sub-agent (`subAgents`), a connector action (`connectorActions`), and the LLM
|
|
11
|
+
// connector — each passed as a handle (bare, or `{ ref, …options }` when it needs
|
|
12
|
+
// per-call options), so the reconciler deploys them first and injects the uuids.
|
|
13
|
+
export const sdr = defineAgent("sdr", {
|
|
14
|
+
color: "blue",
|
|
15
|
+
connector: openai,
|
|
16
|
+
languageModel: "gpt-4o",
|
|
17
|
+
systemPrompt:
|
|
18
|
+
"You qualify inbound leads, enrich missing contact info, and route hot leads to Slack.",
|
|
19
|
+
maxSteps: 12,
|
|
20
|
+
capabilities: ["webSearch", "memory"],
|
|
21
|
+
models: [{ ref: contacts, readOnly: true }],
|
|
22
|
+
tools: [enrich],
|
|
23
|
+
subAgents: [{ ref: enricher, waitUntilFinished: true }],
|
|
24
|
+
connectorActions: [{ integration: "hunter", actionSlug: "emailFinder" }],
|
|
25
|
+
folder: agentsFolder,
|
|
26
|
+
triggers: [{ type: "cron", cron: "0 9 * * *", text: "Daily qualification" }],
|
|
27
|
+
evaluator: { rubric: "Did it correctly qualify the lead?", threshold: 0.8 },
|
|
28
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>Pipeline Dashboard</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="root"></div>
|
|
10
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|