import { type AiTypes } from "@cargo-ai/types"; import { type EncryptionRef, type Token } from "../core.js"; import { type ConnectorRef, type FolderRef } from "../refs.js"; import { type ActionUse } from "./actions.js"; import type { ConnectorHandle } from "./connector.js"; import type { FolderHandle } from "./folder.js"; export type CapabilitySpec = AiTypes.Capability["slug"] | AiTypes.Capability; export type AgentTriggerSpec = { type: "cron"; cron: string; text: string; name?: string; } | { type: "connector"; integration: string; /** The triggering connector — a handle or `connectorRef(uuid)`. */ connector?: ConnectorHandle | ConnectorRef; config?: Record; name?: string; } | { /** * Fire from a native action that owns an agent — `sendEmail` wakes the * chats this agent has emailed when something happens on the thread. * `config` matches that action's declared trigger schema; omit it and * the action's own defaults apply. */ type: "native"; agentSlug: string; config?: Record; name?: string; }; export interface AgentConnectorTriggerConfigs { } type AgentConnectorTriggerConfigFor = S extends keyof AgentConnectorTriggerConfigs ? AgentConnectorTriggerConfigs[S] : Record; export interface AgentNativeTriggerConfigs { } type AgentNativeTriggerConfigFor = S extends keyof AgentNativeTriggerConfigs ? AgentNativeTriggerConfigs[S] : Record; /** * Build a connector trigger with per-integration typed `config`. TypeScript * can't type a bare trigger object literal inside the `triggers` array — it * can't infer each element's `integration` through the array — so this helper * narrows `config` to the integration's schema from a single argument (the same * single-object inference `defineConnector` relies on): * * agentConnectorTrigger({ connector: slack, config: { channelIds: ["C0XXXX"] } }) * * A `defineConnector` handle names its integration, so it types `config` on its * own. Pass `integration` when there's no handle to read it from — a * `connectorRef(uuid)` carries only a uuid, and a trigger can name an * integration with no connector at all: * * agentConnectorTrigger({ integration: "slack", connector: connectorRef(uuid), * config: { channelIds: ["C0XXXX"] } }) * * A bare `{ type: "connector", … }` object still works too, with `config` left * as a loose `Record`. Config schemas are populated by * `cargo-ai cdk types`; an unsynced/custom integration keeps the loose record. */ export declare function agentConnectorTrigger(spec: { connector: ConnectorHandle; config?: AgentConnectorTriggerConfigFor; name?: string; }): AgentTriggerSpec; export declare function agentConnectorTrigger(spec: { integration: S; connector?: ConnectorHandle | ConnectorRef; config?: AgentConnectorTriggerConfigFor; name?: string; }): AgentTriggerSpec; /** * Build a native trigger with per-agent typed `config`. TypeScript can't type * a bare trigger object literal inside the `triggers` array — it can't infer * each element's `agentSlug` through the array — so this helper narrows * `config` to the native agent's schema from a single argument (the same * single-object inference `agentConnectorTrigger` relies on): * * agentNativeTrigger({ agentSlug: "email", config: { kinds: ["replied"] } }) * * A bare `{ type: "native", agentSlug: "email", … }` object still works too, * with `config` left as a loose `Record`. Config schemas are * populated by `cargo-ai cdk types`; an unknown native agent keeps the loose * record. */ export declare function agentNativeTrigger(spec: { agentSlug: S; config?: AgentNativeTriggerConfigFor; name?: string; }): AgentTriggerSpec; /** * A CDK-side env var: the array form for those who want explicit `type`. A * secret is declared with `secret("NAME")`, which `apply` lowers to the * encryption envelope. * * `workspaceEnv()` is deliberately not accepted: an agent inherits the whole * workspace catalog, so a pointer here could only restate a variable its shell * can already read. */ export type HarnessEnvVarSpec = { key: string; type: "public"; value: string; } | { key: string; type: "secret"; secretValue: EncryptionRef; }; /** * The git workspace a coding harness clones. The wire form carries the GitHub * connector as a bare `connectorUuid`; here it is a `connector` handle (or * `connectorRef(uuid)`), so the connector is a real dependency and gets ordered * before the agent. */ export type AgentHarnessRepositorySpec = { /** The GitHub connector holding the clone/PR token — a handle or `connectorRef(uuid)`. */ connector?: ConnectorHandle | ConnectorRef; /** @deprecated Pass `connector`, whose handle the deploy orders before this agent. */ connectorUuid?: string; /** The repository the agent works on, as an `owner/name` full name. */ repository?: string; /** Base branch cloned into the sandbox and targeted by pull requests. Defaults to "main". */ defaultBranch?: string; /** Subdirectory holding the project the agent works on. Defaults to the repository root. */ rootDirectory?: string; /** * Environment variables for the agent's shell commands (`npm install`, `tsc`, * the test run), keyed by name — the same shape `defineApp` and * `defineWorker` take. * * Use `secret("NAME")` for anything that must not live in the repo: it reads * from the deploying environment at apply time and is excluded from the * content hash, so the plaintext never enters git and rotating it does not * read as code drift. * * Only what the agent needs *on top of* the workspace environment variables, * which it inherits in full — so there is nothing to declare here for a * variable the workspace already holds. * * The array form (`HarnessEnvVarSpec[]`) is also accepted for explicit * `type` control; use `{ key, type: "secret", secretValue: secret("NAME") }`. */ env?: Record | HarnessEnvVarSpec[]; }; export type AgentSpec = { name?: string; description?: string; /** Icon colour. Defaults to "grey". */ color?: AiTypes.AgentIcon["color"]; /** The LLM connector — a handle (e.g. `openai`) or `connectorRef(uuid)`. */ connector?: ConnectorHandle | ConnectorRef; languageModel?: string; systemPrompt: string; temperature?: number; maxSteps?: number; withReasoning?: boolean; capabilities?: CapabilitySpec[]; harness?: AiTypes.HarnessSlug; /** @deprecated Renamed to `harness`, matching `connector` / `languageModel`. */ harnessSlug?: AiTypes.HarnessSlug; /** * The git workspace the harness clones. * * OMIT IT to bind the project's own repository: `plan`/`deploy` read the git * origin of the checkout they run in and fill `repository`, `defaultBranch` * and `rootDirectory`, taking `connector` from the project's GitHub * `defineConnector`. Declared fields always win, so a partial object is * completed the same way — the resolved values are what the plan prints and * what the content hash covers. * * Pass `null` for an unbound agent: an empty sandbox per chat, no clone and * no pull requests, whatever the checkout's origin says. */ repository?: AgentHarnessRepositorySpec | null; triggers?: AgentTriggerSpec[]; /** * Everything the agent can call or read, in one array — tools, sub-agents, * connector actions, native actions, and data models. Each entry is a handle * (bare or `{ ref, …options }`): a `defineTool` / `defineAgent` / `defineModel` * handle, a connector action `connector.`, or a native action * (`sendEmail` / `native.sendEmail` / `nativeActionRef("sendEmail")`). See * `ActionUse`. */ uses?: ActionUse[]; mcpClients?: AiTypes.McpClient[]; suggestedActions?: AiTypes.SuggestedAction[]; output?: AiTypes.Output; heartbeat?: AiTypes.Heartbeat; evaluator?: AiTypes.Evaluator; folder?: FolderHandle | FolderRef; }; export type AgentHandle = { readonly slug: string; readonly uuid: Token; /** Discriminator so an agent handle can be passed to a workflow's `uses`. */ readonly resource: "agent"; }; export declare function defineAgent(slug: string, spec: AgentSpec): AgentHandle; /** * An agent lowered to what `cargo-ai ai message create --file` needs to test it * without deploying: its `slug` plus the parameters `ai message create` accepts * inline — the agent's prompt, LLM binding (or harness), tools, models, * connector actions, and capabilities. Mirrors the release the `agent` * executor deploys, minus the fields a single manual message can't express * (`suggestedActions`, `heartbeat`, `evaluator`, `triggers`), which the CLI * rejects up front so they're never silently dropped. */ export type CompiledAgent = { slug: string; systemPrompt?: string; withReasoning?: boolean; temperature?: number; maxSteps?: number; capabilities: AiTypes.Capability[]; mcpClients: AiTypes.McpClient[]; resources: AiTypes.Resource[]; actions: AiTypes.Action[]; output?: AiTypes.Output; connectorUuid?: string; languageModelSlug?: string; harnessSlug?: AiTypes.HarnessSlug; repository?: AiTypes.Repository; }; /** * Lower an agent spec (as registered by `defineAgent`) into a `CompiledAgent` — * so `cargo-ai ai message create --file` can test an agent without deploying it. * Reuses `mapActions` / `mapResources` so the tools / models / connector actions * it exercises are byte-for-byte what a deploy would wire. The spec may still * carry `@cargo-ai/cdk` handle tokens; the result carries them through * unchanged, so resolve them against state before sending. `connectorUuid` is * the LLM connector's uuid, whose integration slug the caller resolves before * sending. */ export declare function compileAgent(spec: Record): CompiledAgent; export {}; //# sourceMappingURL=agent.d.ts.map