import type { RequestInit, RequestInfo } from "./internal/builtin-types.js"; import type { PromiseOrValue, MergedRequestInit, FinalizedRequestInit } from "./internal/types.js"; export type { Logger, LogLevel } from "./internal/utils/log.js"; import * as Opts from "./internal/request-options.js"; import * as Errors from "./core/error.js"; import * as Pagination from "./core/pagination.js"; import { type CursorPaginationParams, CursorPaginationResponse } from "./core/pagination.js"; import * as Uploads from "./core/uploads.js"; import * as API from "./resources/index.js"; import { APIPromise } from "./core/api-promise.js"; import { Account, AccountResource } from "./resources/account.js"; import { APIKey, APIKeyCreateParams, APIKeyInfo, APIKeyListParams, APIKeySpec, APIKeyUpdateParams, APIKeys, APIKeysCursorPagination } from "./resources/api-keys.js"; import { DocumentNamespace, DocumentNamespaceCreateParams, DocumentNamespaceListParams, DocumentNamespaceSpec, DocumentNamespaceUpdateParams, DocumentNamespaces, DocumentNamespacesCursorPagination } from "./resources/document-namespaces.js"; import { Any, AnyOrExpression, CallbacksOrReferences, Document, DocumentCreateParams, DocumentListParams, DocumentSpec, DocumentSpecInlineContent, DocumentSpecRemoteSource, DocumentUpdateParams, Documents, DocumentsCursorPagination, Expression, GoogleProtobufAny, HeadersOrReferences, MediaTypes, NamedAny, NamedPathItem, NamedSchemaOrReference, NamedServerVariable, NamedString, OAuthFlow, Reference, SchemaOrReference, Server, ServerVariable, ServerVariables, Strings } from "./resources/documents.js"; import { Model, ModelListParams, ModelSetStatusParams, ModelSpec, Models, ModelsCursorPagination } from "./resources/models.js"; import { Search, SearchSearchToolsOrToolSetsParams, SearchSearchToolsOrToolSetsResponse } from "./resources/search.js"; import { WorkspaceSecret, WorkspaceSecretCreateParams, WorkspaceSecretInfo, WorkspaceSecretListParams, WorkspaceSecretSpec, WorkspaceSecretUpdateParams, WorkspaceSecrets, WorkspaceSecretsCursorPagination } from "./resources/workspace-secrets.js"; import { WorkspaceCreateParams, WorkspaceListParams, WorkspaceSpec, Workspaces } from "./resources/workspaces.js"; import { Agent, AgentCreateParams, AgentInfo, AgentListParams, AgentSpec, AgentUpdateParams, Agents, AgentsCursorPagination, Page } from "./resources/agents/agents.js"; import { AssistantMessage, AssistantToolCall, Objective, ObjectiveCancelParams, ObjectiveContextWindow, ObjectiveContextWindowData, ObjectiveContextWindowsCursorPagination, ObjectiveContinueParams, ObjectiveContinueResponse, ObjectiveCreateParams, ObjectiveData, ObjectiveDataSecret, ObjectiveError, ObjectiveEventData, ObjectiveEventInfo, ObjectiveEventWebhookData, ObjectiveInfo, ObjectiveListContextWindowsParams, ObjectiveListEventsParams, ObjectiveListEventsResponse, ObjectiveListEventsResponsesCursorPagination, ObjectiveListParams, ObjectiveStatus, Objectives, ObjectivesCursorPagination, SubObjectiveCreated, ToolApprovalRequested, ToolApproved, ToolCalled, ToolDenied, ToolError, ToolResult, UserMessage } from "./resources/objectives/objectives.js"; import { McpToolFilter, SyncCompleted, SyncFailed, SyncStarted, ToolSet, ToolSetAdapter, ToolSetAdapterHTTP, ToolSetAdapterMcp, ToolSetCreateParams, ToolSetEvent, ToolSetEventData, ToolSetEventsCursorPagination, ToolSetInfo, ToolSetListEventsParams, ToolSetListParams, ToolSetSpec, ToolSetUpdateParams, ToolSets, ToolSetsCursorPagination } from "./resources/tool-sets/tool-sets.js"; import { type Fetch } from "./internal/builtin-types.js"; import { HeadersLike, NullableHeaders } from "./internal/headers.js"; import { FinalRequestOptions, RequestOptions } from "./internal/request-options.js"; import { type LogLevel, type Logger } from "./internal/utils/log.js"; declare const environments: { staging: string; production: string; }; type Environment = keyof typeof environments; export interface ClientOptions { /** * Defaults to process.env['CADENYA_API_KEY']. */ apiKey?: string | undefined; /** * Specifies the environment to use for the API. * * Each environment maps to a different base URL: * - `staging` corresponds to `https://api.cadenya.dev` * - `production` corresponds to `https://api.cadenya.com` */ environment?: Environment | undefined; /** * Override the default base URL for the API, e.g., "https://api.example.com/v2/" * * Defaults to process.env['CADENYA_BASE_URL']. */ baseURL?: string | null | undefined; /** * The maximum amount of time (in milliseconds) that the client should wait for a response * from the server before timing out a single request. * * Note that request timeouts are retried by default, so in a worst-case scenario you may wait * much longer than this timeout before the promise succeeds or fails. * * @unit milliseconds */ timeout?: number | undefined; /** * Additional `RequestInit` options to be passed to `fetch` calls. * Properties will be overridden by per-request `fetchOptions`. */ fetchOptions?: MergedRequestInit | undefined; /** * Specify a custom `fetch` function implementation. * * If not provided, we expect that `fetch` is defined globally. */ fetch?: Fetch | undefined; /** * The maximum number of times that the client will retry a request in case of a * temporary failure, like a network error or a 5XX error from the server. * * @default 2 */ maxRetries?: number | undefined; /** * Default headers to include with every request to the API. * * These can be removed in individual requests by explicitly setting the * header to `null` in request options. */ defaultHeaders?: HeadersLike | undefined; /** * Default query parameters to include with every request to the API. * * These can be removed in individual requests by explicitly setting the * param to `undefined` in request options. */ defaultQuery?: Record | undefined; /** * Set the log level. * * Defaults to process.env['CADENYA_LOG'] or 'warn' if it isn't set. */ logLevel?: LogLevel | undefined; /** * Set the logger. * * Defaults to globalThis.console. */ logger?: Logger | undefined; } /** * API Client for interfacing with the Cadenya API. */ export declare class Cadenya { #private; apiKey: string; baseURL: string; maxRetries: number; timeout: number; logger: Logger; logLevel: LogLevel | undefined; fetchOptions: MergedRequestInit | undefined; private fetch; protected idempotencyHeader?: string; private _options; /** * API Client for interfacing with the Cadenya API. * * @param {string | undefined} [opts.apiKey=process.env['CADENYA_API_KEY'] ?? undefined] * @param {Environment} [opts.environment=staging] - Specifies the environment URL to use for the API. * @param {string} [opts.baseURL=process.env['CADENYA_BASE_URL'] ?? https://api.cadenya.dev] - Override the default base URL for the API. * @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out. * @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls. * @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation. * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request. * @param {HeadersLike} opts.defaultHeaders - Default headers to include with every request to the API. * @param {Record} opts.defaultQuery - Default query parameters to include with every request to the API. */ constructor({ baseURL, apiKey, ...opts }?: ClientOptions); /** * Create a new client instance re-using the same options given to the current client with optional overriding. */ withOptions(options: Partial): this; protected defaultQuery(): Record | undefined; protected validateHeaders({ values, nulls }: NullableHeaders): void; protected authHeaders(opts: FinalRequestOptions): Promise; /** * Basic re-implementation of `qs.stringify` for primitive types. */ protected stringifyQuery(query: object | Record): string; private getUserAgent; protected defaultIdempotencyKey(): string; protected makeStatusError(status: number, error: Object, message: string | undefined, headers: Headers): Errors.APIError; buildURL(path: string, query: Record | null | undefined, defaultBaseURL?: string | undefined): string; /** * Used as a callback for mutating the given `FinalRequestOptions` object. */ protected prepareOptions(options: FinalRequestOptions): Promise; /** * Used as a callback for mutating the given `RequestInit` object. * * This is useful for cases where you want to add certain headers based off of * the request properties, e.g. `method` or `url`. */ protected prepareRequest(request: RequestInit, { url, options }: { url: string; options: FinalRequestOptions; }): Promise; get(path: string, opts?: PromiseOrValue): APIPromise; post(path: string, opts?: PromiseOrValue): APIPromise; patch(path: string, opts?: PromiseOrValue): APIPromise; put(path: string, opts?: PromiseOrValue): APIPromise; delete(path: string, opts?: PromiseOrValue): APIPromise; private methodRequest; request(options: PromiseOrValue, remainingRetries?: number | null): APIPromise; private makeRequest; getAPIList = Pagination.AbstractPage>(path: string, Page: new (...args: any[]) => PageClass, opts?: PromiseOrValue): Pagination.PagePromise; requestAPIList = Pagination.AbstractPage>(Page: new (...args: ConstructorParameters) => PageClass, options: PromiseOrValue): Pagination.PagePromise; fetchWithTimeout(url: RequestInfo, init: RequestInit | undefined, ms: number, controller: AbortController): Promise; private shouldRetry; private retryRequest; private calculateDefaultRetryTimeoutMillis; buildRequest(inputOptions: FinalRequestOptions, { retryCount }?: { retryCount?: number; }): Promise<{ req: FinalizedRequestInit; url: string; timeout: number; }>; private buildHeaders; private _makeAbort; private buildBody; static Cadenya: typeof Cadenya; static DEFAULT_TIMEOUT: number; static CadenyaError: typeof Errors.CadenyaError; static APIError: typeof Errors.APIError; static APIConnectionError: typeof Errors.APIConnectionError; static APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError; static APIUserAbortError: typeof Errors.APIUserAbortError; static NotFoundError: typeof Errors.NotFoundError; static ConflictError: typeof Errors.ConflictError; static RateLimitError: typeof Errors.RateLimitError; static BadRequestError: typeof Errors.BadRequestError; static AuthenticationError: typeof Errors.AuthenticationError; static InternalServerError: typeof Errors.InternalServerError; static PermissionDeniedError: typeof Errors.PermissionDeniedError; static UnprocessableEntityError: typeof Errors.UnprocessableEntityError; static toFile: typeof Uploads.toFile; /** * AccountService manages account-level operations. * Accounts are the top-level organizational unit in the system. * All operations are scoped to the authenticated account determined by the JWT token. * * Authentication: Bearer token (JWT) * Scope: Account-level operations */ account: API.AccountResource; /** * AgentService manages AI agents at the WORKSPACE level. * Agents are workspace-scoped resources that define AI behavior and tool access. * All operations are implicitly scoped to the workspace determined by the JWT token. * * Authentication: Bearer token (JWT) * Scope: Workspace-level operations */ agents: API.Agents; objectives: API.Objectives; /** * ModelService manages LLM models at the WORKSPACE level. * Models represent available LLM providers and families (e.g., "anthropic/claude-sonnet-4.6"). * Models are seeded into workspaces and can be enabled or disabled. * All operations are implicitly scoped to the workspace determined by the JWT token. * * Authentication: Bearer token (JWT) * Scope: Workspace-level operations */ models: API.Models; search: API.Search; /** * ToolService manages tool sets and tools at the WORKSPACE level. * Tool sets group related tools, and tools define specific capabilities for agents. * All operations are implicitly scoped to the workspace determined by the JWT token. * * Note: When a ToolSet has managed=true, only API Key actors can modify its tools. * Profile actors (humans) are restricted from modifying managed tool sets. * * Authentication: Bearer token (JWT) * Scope: Workspace-level operations */ toolSets: API.ToolSets; /** * APIKeyService manages workspace-scoped API Keys. * Each API key belongs to a single workspace, ensuring isolation between environments. * * Authentication: Bearer token (JWT) * Scope: Workspace-level operations */ apiKeys: API.APIKeys; workspaceSecrets: API.WorkspaceSecrets; /** * WorkspaceService manages workspaces at the ACCOUNT level. * This service is responsible for creating and listing workspaces within an account. * Workspaces provide organizational grouping for resources within an account. * * Authentication: Bearer token (JWT) * Scope: Account-level operations (manages workspaces themselves, not resources within workspaces) */ workspaces: API.Workspaces; /** * DocumentService manages document namespaces and documents at the WORKSPACE level. * Document namespaces categorize documents for use cases such as customer-specific * documents, regionalized documentation, and agent-created episodic memories. * Documents are key primitives of the platform containing knowledge as inline content * or remote sources. Each document belongs to exactly one namespace. * All operations are implicitly scoped to the workspace determined by the JWT token. * * Authentication: Bearer token (JWT) * Scope: Workspace-level operations */ documentNamespaces: API.DocumentNamespaces; /** * DocumentService manages document namespaces and documents at the WORKSPACE level. * Document namespaces categorize documents for use cases such as customer-specific * documents, regionalized documentation, and agent-created episodic memories. * Documents are key primitives of the platform containing knowledge as inline content * or remote sources. Each document belongs to exactly one namespace. * All operations are implicitly scoped to the workspace determined by the JWT token. * * Authentication: Bearer token (JWT) * Scope: Workspace-level operations */ documents: API.Documents; } export declare namespace Cadenya { export type RequestOptions = Opts.RequestOptions; export import CursorPagination = Pagination.CursorPagination; export { type CursorPaginationParams as CursorPaginationParams, type CursorPaginationResponse as CursorPaginationResponse, }; export { AccountResource as AccountResource, type Account as Account }; export { Agents as Agents, type Agent as Agent, type AgentInfo as AgentInfo, type AgentSpec as AgentSpec, type Page as Page, type AgentsCursorPagination as AgentsCursorPagination, type AgentCreateParams as AgentCreateParams, type AgentUpdateParams as AgentUpdateParams, type AgentListParams as AgentListParams, }; export { Objectives as Objectives, type AssistantMessage as AssistantMessage, type AssistantToolCall as AssistantToolCall, type Objective as Objective, type ObjectiveContextWindow as ObjectiveContextWindow, type ObjectiveContextWindowData as ObjectiveContextWindowData, type ObjectiveData as ObjectiveData, type ObjectiveDataSecret as ObjectiveDataSecret, type ObjectiveError as ObjectiveError, type ObjectiveEventData as ObjectiveEventData, type ObjectiveEventInfo as ObjectiveEventInfo, type ObjectiveEventWebhookData as ObjectiveEventWebhookData, type ObjectiveInfo as ObjectiveInfo, type ObjectiveStatus as ObjectiveStatus, type SubObjectiveCreated as SubObjectiveCreated, type ToolApprovalRequested as ToolApprovalRequested, type ToolApproved as ToolApproved, type ToolCalled as ToolCalled, type ToolDenied as ToolDenied, type ToolError as ToolError, type ToolResult as ToolResult, type UserMessage as UserMessage, type ObjectiveContinueResponse as ObjectiveContinueResponse, type ObjectiveListEventsResponse as ObjectiveListEventsResponse, type ObjectivesCursorPagination as ObjectivesCursorPagination, type ObjectiveContextWindowsCursorPagination as ObjectiveContextWindowsCursorPagination, type ObjectiveListEventsResponsesCursorPagination as ObjectiveListEventsResponsesCursorPagination, type ObjectiveCreateParams as ObjectiveCreateParams, type ObjectiveListParams as ObjectiveListParams, type ObjectiveCancelParams as ObjectiveCancelParams, type ObjectiveContinueParams as ObjectiveContinueParams, type ObjectiveListContextWindowsParams as ObjectiveListContextWindowsParams, type ObjectiveListEventsParams as ObjectiveListEventsParams, }; export { Models as Models, type Model as Model, type ModelSpec as ModelSpec, type ModelsCursorPagination as ModelsCursorPagination, type ModelListParams as ModelListParams, type ModelSetStatusParams as ModelSetStatusParams, }; export { Search as Search, type SearchSearchToolsOrToolSetsResponse as SearchSearchToolsOrToolSetsResponse, type SearchSearchToolsOrToolSetsParams as SearchSearchToolsOrToolSetsParams, }; export { ToolSets as ToolSets, type McpToolFilter as McpToolFilter, type SyncCompleted as SyncCompleted, type SyncFailed as SyncFailed, type SyncStarted as SyncStarted, type ToolSet as ToolSet, type ToolSetAdapter as ToolSetAdapter, type ToolSetAdapterHTTP as ToolSetAdapterHTTP, type ToolSetAdapterMcp as ToolSetAdapterMcp, type ToolSetEvent as ToolSetEvent, type ToolSetEventData as ToolSetEventData, type ToolSetInfo as ToolSetInfo, type ToolSetSpec as ToolSetSpec, type ToolSetsCursorPagination as ToolSetsCursorPagination, type ToolSetEventsCursorPagination as ToolSetEventsCursorPagination, type ToolSetCreateParams as ToolSetCreateParams, type ToolSetUpdateParams as ToolSetUpdateParams, type ToolSetListParams as ToolSetListParams, type ToolSetListEventsParams as ToolSetListEventsParams, }; export { APIKeys as APIKeys, type APIKey as APIKey, type APIKeyInfo as APIKeyInfo, type APIKeySpec as APIKeySpec, type APIKeysCursorPagination as APIKeysCursorPagination, type APIKeyCreateParams as APIKeyCreateParams, type APIKeyUpdateParams as APIKeyUpdateParams, type APIKeyListParams as APIKeyListParams, }; export { WorkspaceSecrets as WorkspaceSecrets, type WorkspaceSecret as WorkspaceSecret, type WorkspaceSecretInfo as WorkspaceSecretInfo, type WorkspaceSecretSpec as WorkspaceSecretSpec, type WorkspaceSecretsCursorPagination as WorkspaceSecretsCursorPagination, type WorkspaceSecretCreateParams as WorkspaceSecretCreateParams, type WorkspaceSecretUpdateParams as WorkspaceSecretUpdateParams, type WorkspaceSecretListParams as WorkspaceSecretListParams, }; export { Workspaces as Workspaces, type WorkspaceSpec as WorkspaceSpec, type WorkspaceCreateParams as WorkspaceCreateParams, type WorkspaceListParams as WorkspaceListParams, }; export { DocumentNamespaces as DocumentNamespaces, type DocumentNamespace as DocumentNamespace, type DocumentNamespaceSpec as DocumentNamespaceSpec, type DocumentNamespacesCursorPagination as DocumentNamespacesCursorPagination, type DocumentNamespaceCreateParams as DocumentNamespaceCreateParams, type DocumentNamespaceUpdateParams as DocumentNamespaceUpdateParams, type DocumentNamespaceListParams as DocumentNamespaceListParams, }; export { Documents as Documents, type Any as Any, type AnyOrExpression as AnyOrExpression, type CallbacksOrReferences as CallbacksOrReferences, type Document as Document, type DocumentSpec as DocumentSpec, type DocumentSpecInlineContent as DocumentSpecInlineContent, type DocumentSpecRemoteSource as DocumentSpecRemoteSource, type Expression as Expression, type GoogleProtobufAny as GoogleProtobufAny, type HeadersOrReferences as HeadersOrReferences, type MediaTypes as MediaTypes, type NamedAny as NamedAny, type NamedPathItem as NamedPathItem, type NamedSchemaOrReference as NamedSchemaOrReference, type NamedServerVariable as NamedServerVariable, type NamedString as NamedString, type OAuthFlow as OAuthFlow, type Reference as Reference, type SchemaOrReference as SchemaOrReference, type Server as Server, type ServerVariable as ServerVariable, type ServerVariables as ServerVariables, type Strings as Strings, type DocumentsCursorPagination as DocumentsCursorPagination, type DocumentCreateParams as DocumentCreateParams, type DocumentUpdateParams as DocumentUpdateParams, type DocumentListParams as DocumentListParams, }; export type AccountResourceMetadata = API.AccountResourceMetadata; export type BareMetadata = API.BareMetadata; export type CallableTool = API.CallableTool; export type CreateOperationMetadata = API.CreateOperationMetadata; export type CreateResourceMetadata = API.CreateResourceMetadata; export type OperationMetadata = API.OperationMetadata; export type Profile = API.Profile; export type ProfileSpec = API.ProfileSpec; export type ResourceMetadata = API.ResourceMetadata; export type UpdateResourceMetadata = API.UpdateResourceMetadata; export type Workspace = API.Workspace; } //# sourceMappingURL=client.d.ts.map