@cargo-ai/cdk 1.0.5 → 1.0.7

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 (64) hide show
  1. package/README.md +59 -9
  2. package/build/src/cli/commands/from.d.ts +65 -0
  3. package/build/src/cli/commands/from.d.ts.map +1 -0
  4. package/build/src/cli/commands/from.js +275 -0
  5. package/build/src/cli/commands/init.d.ts +1 -1
  6. package/build/src/cli/commands/init.d.ts.map +1 -1
  7. package/build/src/cli/commands/init.js +32 -13
  8. package/build/src/cli/commands/types.d.ts.map +1 -1
  9. package/build/src/cli/commands/types.js +75 -37
  10. package/build/src/core.d.ts +1 -1
  11. package/build/src/core.d.ts.map +1 -1
  12. package/build/src/deploy/apply.d.ts +6 -0
  13. package/build/src/deploy/apply.d.ts.map +1 -1
  14. package/build/src/deploy/apply.js +4 -0
  15. package/build/src/deploy/destroy.d.ts.map +1 -1
  16. package/build/src/deploy/destroy.js +33 -0
  17. package/build/src/deploy/executors.live.d.ts.map +1 -1
  18. package/build/src/deploy/executors.live.js +157 -1
  19. package/build/src/deploy/readers.live.d.ts.map +1 -1
  20. package/build/src/deploy/readers.live.js +34 -1
  21. package/build/src/index.d.ts +11 -7
  22. package/build/src/index.d.ts.map +1 -1
  23. package/build/src/index.js +6 -4
  24. package/build/src/refs.d.ts +22 -0
  25. package/build/src/refs.d.ts.map +1 -1
  26. package/build/src/refs.js +11 -2
  27. package/build/src/resources/actions.d.ts +39 -19
  28. package/build/src/resources/actions.d.ts.map +1 -1
  29. package/build/src/resources/actions.js +60 -33
  30. package/build/src/resources/agent.d.ts +33 -23
  31. package/build/src/resources/agent.d.ts.map +1 -1
  32. package/build/src/resources/agent.js +24 -24
  33. package/build/src/resources/app.d.ts +3 -1
  34. package/build/src/resources/app.d.ts.map +1 -1
  35. package/build/src/resources/app.js +2 -1
  36. package/build/src/resources/capacity.d.ts +11 -0
  37. package/build/src/resources/capacity.d.ts.map +1 -1
  38. package/build/src/resources/capacity.js +81 -0
  39. package/build/src/resources/connector.d.ts +10 -0
  40. package/build/src/resources/connector.d.ts.map +1 -1
  41. package/build/src/resources/connector.js +18 -1
  42. package/build/src/resources/customIntegration.d.ts +12 -0
  43. package/build/src/resources/customIntegration.d.ts.map +1 -0
  44. package/build/src/resources/customIntegration.js +18 -0
  45. package/build/src/resources/mcpServer.d.ts +8 -10
  46. package/build/src/resources/mcpServer.d.ts.map +1 -1
  47. package/build/src/resources/mcpServer.js +4 -7
  48. package/build/src/resources/model.d.ts +47 -4
  49. package/build/src/resources/model.d.ts.map +1 -1
  50. package/build/src/resources/model.js +38 -1
  51. package/build/src/resources/relationship.d.ts +21 -0
  52. package/build/src/resources/relationship.d.ts.map +1 -0
  53. package/build/src/resources/relationship.js +39 -0
  54. package/build/src/resources/worker.d.ts +13 -1
  55. package/build/src/resources/worker.d.ts.map +1 -1
  56. package/build/src/resources/worker.js +3 -1
  57. package/build/tsconfig.tsbuildinfo +1 -1
  58. package/package.json +5 -5
  59. package/templates/blank/cargo.ts +17 -22
  60. package/templates/full/README.md +7 -4
  61. package/templates/full/agents/sdr.ts +12 -8
  62. package/templates/full/connectors/hunter.ts +10 -0
  63. package/templates/full/mcp/crm.ts +9 -6
  64. package/templates/full/tools/enrich.ts +28 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cargo-ai/cdk",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
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",
@@ -57,10 +57,10 @@
57
57
  "format:check": "prettier --check ."
58
58
  },
59
59
  "dependencies": {
60
- "@cargo-ai/api": "^1.0.34",
61
- "@cargo-ai/types": "^1.0.37",
62
- "@cargo-ai/worker-sdk": "^1.0.4",
63
- "@cargo-ai/workflow-sdk": "^1.0.1",
60
+ "@cargo-ai/api": "^1.0.37",
61
+ "@cargo-ai/types": "^1.0.39",
62
+ "@cargo-ai/worker-sdk": "^1.0.6",
63
+ "@cargo-ai/workflow-sdk": "^1.0.3",
64
64
  "commander": "^12.1.0",
65
65
  "http-proxy-agent": "^9.1.0",
66
66
  "https-proxy-agent": "^9.1.0",
@@ -1,28 +1,9 @@
1
- import {
2
- defineConnector,
3
- defineModel,
4
- defineTool,
5
- defineWorkflow,
6
- secret,
7
- } from "@cargo-ai/cdk";
1
+ import { defineTool, defineWorkflow } from "@cargo-ai/cdk";
8
2
  import { z } from "zod";
9
3
 
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
4
  // 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.
5
+ // workflow nodes — never executed here. `ai(...)` becomes an inference node, so
6
+ // this deploys and runs with nothing but your Cargo login — no provider keys.
26
7
  const enrichFlow = defineWorkflow(
27
8
  "enrich-contact",
28
9
  {
@@ -42,3 +23,17 @@ export const enrich = defineTool("enrich", {
42
23
  description: "Enrich a contact with firmographic data.",
43
24
  emojiSlug: "mag",
44
25
  });
26
+
27
+ // Next: wire a data source. A connector + model make rows from your CRM or
28
+ // warehouse available to plays, agents, and tools — see the `full` template
29
+ // (`cargo-ai cdk init --template full`) or https://docs.getcargo.ai/connectors/overview
30
+ //
31
+ // export const hubspot = defineConnector("hubspot", {
32
+ // integration: "hubspot",
33
+ // config: { method: "privateApp", accessToken: secret("HUBSPOT_API_KEY") },
34
+ // });
35
+ //
36
+ // export const contacts = defineModel("contacts", {
37
+ // dataset: hubspot,
38
+ // extractSlug: "fetchRecords",
39
+ // });
@@ -3,8 +3,9 @@
3
3
  A complete, runnable Cargo workspace defined entirely in code (the `full` CDK
4
4
  template — `cargo-ai cdk init <dir> --template full`). It exercises every resource
5
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.
6
+ (e.g. `dataset: hubspot`, or an agent's `uses: [{ ref: contacts }, enrich]`) into
7
+ another builder, and the reconciler deploys them in dependency order and injects
8
+ the real uuids.
8
9
 
9
10
  ## The graph
10
11
 
@@ -13,6 +14,7 @@ hubspot (connector) ──dataset──▶ contacts (model) ──model───
13
14
  ├─▶ sdr (agent)
14
15
  openai (connector) ──connector──▶ enricher (agent) ──subAgent──▶ sdr│
15
16
  └────────connector──────────────────▶ sdr ─────┘
17
+ hunter (connector) ──hunter.actions.findEmail (connector action)──────────▶ sdr
16
18
  enrich (tool, backed by a workflow) ─┐
17
19
  sdr (agent) ─────────────────────────┼─▶ crm (mcpServer)
18
20
  contacts (model) ────────────────────┘
@@ -25,13 +27,14 @@ playbook (file) webhook (worker) dashboard (app)
25
27
  | --------------------------------------- | ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
26
28
  | `connectors/hubspot.ts` | `defineConnector` | discriminated-union config + `secret()`; auto-creates a dataset |
27
29
  | `connectors/openai.ts` | `defineConnector` | `adopt: true` to link an existing OAuth connector |
30
+ | `connectors/hunter.ts` | `defineConnector` | an enrichment connector; its actions (`hunter.actions.findEmail`) feed the agent's `uses` |
28
31
  | `folders/crm.ts` | `defineFolder` | per-kind folders (model vs agent) |
29
32
  | `models/contacts.ts` | `defineModel` | `dataset` handle + `extractSlug` + cron schedule |
30
33
  | `tools/enrich.ts` | `defineWorkflow` + `defineTool` | a tool backed by a workflow, with a cron trigger |
31
34
  | `agents/enricher.ts` | `defineAgent` | a focused sub-agent (LLM via `connector`) |
32
- | `agents/sdr.ts` | `defineAgent` | data model, sub-agent, trigger, evaluator |
35
+ | `agents/sdr.ts` | `defineAgent` | one `uses` array — model + tool + sub-agent + connector action; trigger, evaluator |
33
36
  | `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 |
37
+ | `mcp/crm.ts` | `defineMcpServer` | bundles tool + agent + model (one `uses` array) behind one endpoint |
35
38
  | `context/context.ts` (+ `context/*.md`) | `defineContext` | syncs the GTM knowledge base (markdown/MDX) into the workspace's context repo |
36
39
  | `files/playbook.ts` | `defineFile` | content uploaded from a local path |
37
40
  | `workers/webhook.ts` (+ `webhook/`) | `defineWorker` | the worker _resource_; points at a TS source bundle (`src/index.ts` + `manifest.json` + `package.json` + `package-lock.json`) |
@@ -1,15 +1,17 @@
1
1
  import { defineAgent } from "@cargo-ai/cdk";
2
2
 
3
+ import { hunter } from "../connectors/hunter";
3
4
  import { openai } from "../connectors/openai";
4
5
  import { agentsFolder } from "../folders/crm";
5
6
  import { contacts } from "../models/contacts";
6
7
  import { enrich } from "../tools/enrich";
7
8
  import { enricher } from "./enricher";
8
9
 
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.
10
+ // The main agent. Everything it can call or read is one `uses` array — a data
11
+ // model, a tool, a sub-agent, and a connector action (`hunter.actions.findEmail`) each
12
+ // a handle, bare or `{ ref, …options }` when it needs per-call options. The
13
+ // reconciler deploys each first and injects its uuid. `connector` is separate:
14
+ // it's the LLM provider, not something the agent "uses".
13
15
  export const sdr = defineAgent("sdr", {
14
16
  color: "blue",
15
17
  connector: openai,
@@ -18,10 +20,12 @@ export const sdr = defineAgent("sdr", {
18
20
  "You qualify inbound leads, enrich missing contact info, and route hot leads to Slack.",
19
21
  maxSteps: 12,
20
22
  capabilities: ["webSearch", "memory"],
21
- models: [{ ref: contacts, readOnly: true }],
22
- tools: [enrich],
23
- subAgents: [{ ref: enricher, waitUntilFinished: true }],
24
- connectorActions: [{ integration: "hunter", actionSlug: "emailFinder" }],
23
+ uses: [
24
+ { ref: contacts, readOnly: true }, // a data model
25
+ enrich, // a tool (bare handle)
26
+ { ref: enricher, waitUntilFinished: true }, // a sub-agent
27
+ hunter.actions.findEmail, // a connector action
28
+ ],
25
29
  folder: agentsFolder,
26
30
  triggers: [{ type: "cron", cron: "0 9 * * *", text: "Daily qualification" }],
27
31
  evaluator: { rubric: "Did it correctly qualify the lead?", threshold: 0.8 },
@@ -0,0 +1,10 @@
1
+ import { defineConnector } from "@cargo-ai/cdk";
2
+
3
+ // An enrichment connector. Its actions are exposed under `hunter.actions.*`
4
+ // (`hunter.actions.findEmail`, `hunter.actions.verifyEmail`, …), so an agent or
5
+ // MCP server can reference a specific connector action in its `uses`. Adopted
6
+ // (OAuth/key auth lives outside the repo), like the LLM connector.
7
+ export const hunter = defineConnector("hunter", {
8
+ integration: "hunter",
9
+ adopt: true,
10
+ });
@@ -4,12 +4,15 @@ import { sdr } from "../agents/sdr";
4
4
  import { contacts } from "../models/contacts";
5
5
  import { enrich } from "../tools/enrich";
6
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.
7
+ // An MCP server bundles tools, agents, and data models behind one MCP endpoint
8
+ // all in one `uses` array (the same surface as an agent). Each is a handle, bare
9
+ // or `{ ref, …options }`, so the reconciler resolves each to its deployed
10
+ // action/resource.
10
11
  export const crmServer = defineMcpServer("crm", {
11
12
  description: "CRM tools and data for assistants.",
12
- tools: [enrich],
13
- agents: [sdr],
14
- models: [{ ref: contacts, readOnly: true }],
13
+ uses: [
14
+ enrich, // a tool
15
+ sdr, // an agent
16
+ { ref: contacts, readOnly: true }, // a data model
17
+ ],
15
18
  });
@@ -2,27 +2,46 @@ import { defineTool, defineWorkflow } from "@cargo-ai/cdk";
2
2
  import { z } from "zod";
3
3
 
4
4
  import { enricher } from "../agents/enricher";
5
+ import { hunter } from "../connectors/hunter";
5
6
 
6
7
  // A tool is backed by a workflow. `defineWorkflow` compiles the logic; `defineTool`
7
8
  // creates the tool + deploys that workflow as its release.
8
9
  //
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.
10
+ // `uses` forward-references other resources by handle — here an agent (`enricher`)
11
+ // and a connector (`hunter`). The body calls a tool/agent as `uses.<key>(input)`
12
+ // and a connector's action as `uses.<key>.<action>(input)`. Each handle carries a
13
+ // deferred `uuid` token, so the CDK orders the deploy (dependencies first) and
14
+ // injects the real uuid into the emitted node. Run `cargo-ai cdk types` and a
15
+ // connector's action slugs + their input/output type against your workspace.
16
+ // The body is parsed and lowered to workflow nodes — never executed at build time.
14
17
  const enrichFlow = defineWorkflow(
15
18
  "enrich-contact",
16
19
  {
17
20
  input: z.object({ email: z.string() }),
18
- output: z.object({ company: z.string(), enriched: z.boolean() }),
19
- uses: { enricher },
21
+ output: z.object({
22
+ company: z.string(),
23
+ verification: z.unknown(),
24
+ enriched: z.boolean(),
25
+ }),
26
+ uses: { enricher, hunter },
20
27
  },
21
28
  ({ input, uses }) => {
29
+ // A connector action, called right in the workflow body.
30
+ const verification = uses.hunter.verifyEmail({ email: input.email });
31
+
32
+ // An agent, called by handle. An agent call resolves to `{ answer, evaluation? }`
33
+ // (agents aren't output-schema-typed), so read `.answer` for the response.
22
34
  const company = uses.enricher({
23
35
  prompt: `Which company owns the email domain of ${input.email}? Reply with just the company name.`,
24
- });
25
- return { company, enriched: true };
36
+ }).answer;
37
+
38
+ // Idiomatic `if/else`, lowered to real branching: each arm returns via its own
39
+ // `end` node. `company`/`verification` are the same in both; only `enriched`
40
+ // differs (`{{ true }}` vs `{{ false }}`).
41
+ if (!company) {
42
+ return { company, verification, enriched: false };
43
+ }
44
+ return { company, verification, enriched: true };
26
45
  },
27
46
  );
28
47