/** * Copyright (c) 2026, Salesforce, Inc., * All rights reserved. * For full license text, see the LICENSE.txt file */ /** * Shared envelope returned by every typed intent function. The MCP tool * adapter JSON-stringifies this into the tool-call result; library * consumers (CLI, eval harness) use it directly. Per FR-3 of the spec. */ export interface ToolOutput { query: string; variables: VariableInfo[]; types: string; warnings: string[]; } export interface VariableInfo { name: string; type: string; required: boolean; description?: string; } export interface ChildRelationshipSpec { relationshipName: string; fields: string[]; first?: number | string; filter?: Record | string; orderBy?: Record | Record[] | string; } export interface ListSpec { org: string; object: string; fields: string[]; parentFields?: string[]; childRelationships?: ChildRelationshipSpec[]; filter?: Record | string; orderBy?: Record | Record[] | string; first?: number | string; scope?: string; operationName?: string; } export interface DetailSpec { org: string; object: string; fields: string[]; parentFields?: string[]; childRelationships?: ChildRelationshipSpec[]; /** Variable name (without leading `$`) for the record Id; default `"id"`. Declared as `: ID!` per FR-5.5. */ idVariable?: string; /** GraphQL operation name; default `Detail`. */ operationName?: string; } export type AggregationFunction = "count" | "countDistinct" | "sum" | "avg" | "min" | "max"; export declare const GROUP_BY_FUNCTIONS: readonly ["CALENDAR_MONTH", "CALENDAR_QUARTER", "CALENDAR_YEAR", "DAY_IN_MONTH", "DAY_IN_WEEK", "DAY_IN_YEAR", "FISCAL_MONTH", "FISCAL_QUARTER", "FISCAL_YEAR", "HOUR_IN_DAY", "CALENDAR_MONTH_IN_YEAR", "FISCAL_MONTH_IN_YEAR", "WEEK_IN_YEAR"]; export type GroupByFunction = (typeof GROUP_BY_FUNCTIONS)[number]; export interface GroupByDateElement { field: string; function: GroupByFunction; } export type GroupByElement = string | GroupByDateElement; export interface AggregationSpec { function: AggregationFunction; field?: string; alias?: string; } export interface AggregateSpec { org: string; object: string; groupBy?: GroupByElement[]; aggregations?: AggregationSpec[]; filter?: Record | string; orderBy?: Record | Record[] | string; first?: number | string; operationName?: string; } export type DiscoverMode = "list_objects" | "describe_object" | "describe_field"; export interface DiscoverSpec { org: string; mode: DiscoverMode; object?: string; field?: string; search?: string; } export interface FieldDescription { name: string; label: string; type: string; filterable: boolean; sortable: boolean; nameField: boolean; compound: boolean; defaultedOnCreate: boolean; picklistValues?: string[]; } export interface ObjectDescription { name: string; fields: FieldDescription[]; childRelationships: { relationshipName: string; childObject: string; }[]; parentReferences: { field: string; targetObjects: string[]; }[]; filterableFields: string[]; orderByExample: Record; requiredOnCreate: string[]; } export type DiscoverOutput = { mode: "list_objects"; objects: { name: string; label?: string; }[]; warnings?: string[]; } | { mode: "describe_object"; object: ObjectDescription; warnings?: string[]; } | { mode: "describe_field"; field: FieldDescription; warnings?: string[]; }; export interface CreateSpec { org: string; object: string; returnFields?: string[]; inputVariable?: string; operationName?: string; } export interface UpdateSpec { org: string; object: string; returnFields?: string[]; inputVariable?: string; operationName?: string; } export interface DeleteSpec { org: string; object: string; inputVariable?: string; operationName?: string; } export interface ConnectSpec { org: string; /** * Re-download the schema even if it is already cached, coherently clearing * all three caches (on-disk introspection JSON, in-memory parsed schema, and * ObjectInfo). Defaults to false — a plain connect lazily primes on miss. */ forceRefresh?: boolean; } export interface ConnectOutput { org: string; instanceUrl: string; /** True when this call performed a forced re-download. */ refreshed: boolean; /** True when an existing cache satisfied the request (no download performed). */ cached: boolean; durationMs: number; /** * Populated when a refresh failed but a usable cached schema survived — the * staleness-aware message tells the caller the cache is still valid. */ warnings?: string[]; } export type RawOperation = "query" | "mutation" | "aggregate"; export interface RawSpec { org: string; /** * CLI-style commands applied in order to a transient session. v1 supports * `select `, `set [] =`, and * `var $name [default]`. See FR-12. */ commands: string[]; /** Operation root; default `"query"`. Sets the `createSession` operation. */ operation?: RawOperation; /** GraphQL operation name override. Defaults to Raw (FR-12.3). */ typeName?: string; }