import type { AiTypes } from "@cargo-ai/types"; import type { IntegrationAction, Integrations } from "@cargo-ai/workflow-sdk"; import { type ConnectorActionRef, type NativeActionRef, type ResourceRef } from "../refs.js"; import type { ModelHandle } from "./model.js"; /** * A connector action's input type, read from the `Integrations` map that * `cargo-ai cdk types` generates for the workspace (the same map that types * action calls inside workflow bodies). An unsynced integration — or an action * slug it doesn't declare — falls back to a loose record. */ export type ConnectorActionInput = S extends keyof Integrations ? A extends keyof Integrations[S] ? Integrations[S][A] extends IntegrationAction ? TInput : Record : Record : Record; /** * An input whose every leaf may instead be a `{{ … }}` template string, resolved * against the firing context at run time rather than at deploy time — so a * numeric field can still be bound to `"{{event.value}}"`. */ export type Templated = { [K in keyof T]: TemplatedValue; }; type TemplatedValue = V extends (infer U)[] ? TemplatedValue[] : V extends Date ? V | string : V extends object ? Templated | string : V | string; /** Options a use's tool / sub-agent action takes (a connector / native action takes all but `waitUntilFinished`). */ export type ActionOptions = { /** Override the action's display name. */ readonly name?: string; readonly description?: string; /** Allow the action to run in bulk. Defaults to false. */ readonly isBulkAllowed?: boolean; /** Block until the action finishes before continuing. Defaults to true. */ readonly waitUntilFinished?: boolean; /** Lock input fields to fixed values; the agent decides the rest. */ readonly config?: Record; }; /** * A connector / native action runs inline, so there is nothing to not wait for: * the AI release has no `waitUntilFinished` for those kinds, and only tool / * sub-agent actions read it. * * Declared `never` rather than omitted: `ActionUse` is a union, and an object * literal checked against a union may carry any property one of its members has * — so an `Omit` here still let `{ ref: connector.actions.x, waitUntilFinished: * false }` through (the tool member has the field) and lowering dropped it in * silence. `never` is what makes the connector / native member reject it. */ type InlineActionOptions = ActionOptions & { readonly waitUntilFinished?: never; }; /** Per-model options when a use exposes a data model. */ export type ModelActionOptions = { readonly readOnly?: boolean; readonly columns?: string[]; }; /** The data-model references (become the agent's release resources). */ type ModelActionUse = ModelHandle | ResourceRef<"model">; /** * One entry in an agent's / MCP server's `uses` — referenced by handle, bare or * `{ ref, …options }`: * - a `defineTool` / `defineAgent` handle (or `toolRef` / `agentRef`) — options * `name` / `description` / `isBulkAllowed` / `waitUntilFinished`, plus * `config` to fix input fields; * - a connector action — `connector.` (or `connectorActionRef(...)`) * — the same options minus `waitUntilFinished`, which it doesn't have; * - a native action — the branded helper (`sendEmail`) or `nativeActionRef("sendEmail")` * — the same options as a connector action; * - a `defineModel` handle (or `modelRef`) — options `readOnly` / `columns`. * The kind is read from each ref's `resource`, so order doesn't matter. */ export type ActionUse = ResourceRef<"tool"> | ResourceRef<"agent"> | ConnectorActionRef | NativeActionRef | ModelActionUse | (ActionOptions & { readonly ref: ResourceRef<"tool"> | ResourceRef<"agent">; }) | (InlineActionOptions & { readonly ref: ConnectorActionRef; }) | (InlineActionOptions & { readonly ref: NativeActionRef; }) | (ModelActionOptions & { readonly ref: ModelActionUse; }); export type NormalizedUses = { models: unknown[]; tools: unknown[]; subAgents: unknown[]; connectorActions: unknown[]; nativeActions?: unknown[]; }; export declare function normalizeActionUses(rawUses: readonly ActionUse[] | undefined): NormalizedUses; export declare function mapResources(spec: Record): AiTypes.Resource[]; export declare function mapActions(spec: Record): AiTypes.Action[]; export {}; //# sourceMappingURL=actions.d.ts.map