import { type AttemptToolCall as AttemptToolCallValue, AttemptToolCaller, type AttemptToolCatalog as AttemptToolCatalogValue, type AttemptToolCatalogEntry as AttemptToolCatalogEntryValue, type AttemptToolIdentity, type AttemptToolResult as AttemptToolResultValue, type CodemodeDispatchAck as CodemodeDispatchAckValue, type CodemodeDispatchRequest as CodemodeDispatchRequestValue, type CodemodeOperation as CodemodeOperationValue } from "@opengeni/contracts"; import { ToolGateway, ToolGatewayApprovalRequiredError as AttemptToolApprovalRequiredError, ToolGatewayCatalogIntegrityError as AttemptToolCatalogIntegrityError, ToolGatewayCatalogStaleError as AttemptToolCatalogStaleError, ToolGatewayCatalogTooLargeError as AttemptToolCatalogTooLargeError, ToolGatewayInputValidationError as AttemptToolInputValidationError, ToolGatewayOutputValidationError as AttemptToolOutputValidationError, ToolGatewayPathCollisionError as AttemptToolPathCollisionError, ToolGatewayToolNotFoundError as AttemptToolNotFoundError, type PreparedToolGatewayCall, type ToolGatewayArgumentResolver, type ToolGatewayCallLifecycle } from "@opengeni/tool-gateway"; export type { AttemptToolCatalog, AttemptToolCatalogEntry } from "@opengeni/contracts"; export type AttemptToolScope = Pick; export type AttemptToolExecutionContext = { operationId: string; caller: AttemptToolCaller; /** Trusted in-process SDK correlation; not operation identity or approval authority. */ sourceCallId?: string; /** In-process transport metadata; never part of catalog identity or digest. */ transportMeta?: Record | null; signal?: AbortSignal; }; export type AttemptToolDefinition = Omit & { /** Optional human-readable path. Unsafe/colliding segments are normalized. */ codemodePath?: readonly string[]; /** In-process execution lifecycle shared by model MCP and Codemode. */ lifecycle?: ToolGatewayCallLifecycle; execute: (args: Record, context: AttemptToolExecutionContext) => Promise | AttemptToolResultValue; }; export type AttemptToolAuthorization = (input: { call: AttemptToolCallValue; entry: AttemptToolCatalogEntryValue; }) => Promise | void; export type CreateAttemptToolEnvironmentInput = { scope: AttemptToolScope; generation: number; /** Trusted host's accepted native permission set, never caller input. */ firstPartyMcpPermissions?: AttemptToolCatalogValue["firstPartyMcpPermissions"]; definitions: readonly AttemptToolDefinition[]; createdAt?: Date; authorize?: AttemptToolAuthorization; /** Host-only approval projection for one exact model invocation. */ confirmModelApproval?: (input: { modelName: string; subjectId: string; }) => boolean; /** Trusted secret-reference resolution; runs after approval, before execution. */ resolveArguments?: ToolGatewayArgumentResolver; }; export type ModelAttemptToolCall = { operationId?: string; /** Exact SDK call id supplied by the host, never inferred from arguments or metadata. */ sourceCallId?: string; modelName: string; arguments: Record; subjectId: string; transportMeta?: Record | null; signal?: AbortSignal; }; export { AttemptToolCatalogStaleError, AttemptToolNotFoundError, AttemptToolApprovalRequiredError, AttemptToolCatalogIntegrityError, AttemptToolCatalogTooLargeError, AttemptToolInputValidationError, AttemptToolOutputValidationError, AttemptToolPathCollisionError, }; export declare class CodemodeTransportError extends Error { readonly status: number | null; readonly code = "codemode_transport_error"; readonly remoteCode: string | null; readonly retryable: boolean | null; readonly outcomeUnknown: boolean | null; readonly details: Readonly> | null; constructor(message: string, status?: number | null, options?: { code?: string; retryable?: boolean; outcomeUnknown?: boolean; details?: Readonly>; }); } export declare class CodemodeOperationError extends Error { readonly operation: CodemodeOperationValue; readonly code: string; constructor(operation: CodemodeOperationValue, code: string); } /** Compact receipt: payloads remain in the protected operation journal. */ export declare class CodemodeApprovalPendingError extends Error { readonly operationId: string; readonly approvalRequestId: string | undefined; readonly code = "codemode_approval_pending"; readonly state = "waiting_for_approval"; constructor(operationId: string, approvalRequestId: string | undefined); } export type CodemodeTokenProvider = string | (() => string | Promise); export type CodemodeClientOptions = { /** `/v1/workspaces/:workspaceId/codemode` base URL. */ baseUrl: string; token: CodemodeTokenProvider; fetch?: typeof globalThis.fetch; pollIntervalMs?: number; timeoutMs?: number; }; export type CodemodeCallOptions = { operationId?: string; /** Optional public entry pin, checked again after a pre-submission stale refresh. */ expectedDefinitionDigest?: string; /** Stops client observation only; it never cancels an already-created server operation. */ signal?: AbortSignal; timeoutMs?: number; }; export type CodemodeToolFunction = (argumentsValue?: Record, options?: CodemodeCallOptions) => Promise; export type CodemodeToolResult = AttemptToolResultValue; export declare class CodemodeToolCallError extends Error { readonly result: AttemptToolResultValue; readonly code: string; readonly retryable: boolean; constructor(result: AttemptToolResultValue); } export declare class CodemodeToolContractError extends Error { readonly code = "invalid_tool_result"; constructor(message: string); } export interface CodemodeTools { [key: string]: CodemodeTools | CodemodeToolFunction; } /** Persistent, idempotent client for one exact sandbox attempt bearer. */ export declare class CodemodeClient { private readonly options; private readonly baseUrl; private readonly fetchImpl; private readonly pollIntervalMs; private readonly timeoutMs; private catalogSnapshot; constructor(options: CodemodeClientOptions); catalog(options?: { refresh?: boolean; signal?: AbortSignal; }): Promise; tools(options?: { refresh?: boolean; signal?: AbortSignal; }): Promise; call(identity: AttemptToolIdentity, argumentsValue?: Record, options?: CodemodeCallOptions): Promise; private callResolved; /** Resolve and call one exact generated namespace path without parsing a wire name. */ callPath(path: readonly string[], argumentsValue?: Record, options?: CodemodeCallOptions): Promise; /** Return structured content, or a local-image wrapper for typed multimodal results. */ callPathValue(path: readonly string[], argumentsValue?: Record, options?: CodemodeCallOptions): Promise; private submit; /** Observe a durable handle using the current attempt, without resubmitting its payload. */ status(operationId: string, signal?: AbortSignal): Promise<{ operationId: string; state: "cancelled" | "completed" | "failed" | "outcome_unknown" | "queued" | "running" | "waiting_for_approval"; approvalRequestId: string | undefined; result: { [x: string]: unknown; content: ({ [x: string]: unknown; type: "text"; text: string; annotations?: Record | undefined; _meta?: Record | undefined; } | { [x: string]: unknown; type: "image"; data: string; mimeType: string; annotations?: Record | undefined; _meta?: Record | undefined; } | { [x: string]: unknown; type: "audio"; data: string; mimeType: string; annotations?: Record | undefined; _meta?: Record | undefined; } | { [x: string]: unknown; type: "resource_link"; name: string; title?: string | undefined; uri: string; description?: string | undefined; mimeType?: string | undefined; size?: number | undefined; icons?: { src: string; mimeType?: string | undefined; sizes?: string[] | undefined; theme?: "dark" | "light" | undefined; }[] | undefined; annotations?: Record | undefined; _meta?: Record | undefined; } | { [x: string]: unknown; type: "resource"; resource: { [x: string]: unknown; uri: string; mimeType?: string | undefined; text: string; _meta?: Record | undefined; } | { [x: string]: unknown; uri: string; mimeType?: string | undefined; blob: string; _meta?: Record | undefined; }; annotations?: Record | undefined; _meta?: Record | undefined; })[]; structuredContent?: Record | undefined; isError?: boolean | undefined; _meta?: Record | undefined; } | null; errorCode: string | null; errorMessage: string | null; }>; /** Observe continuation after review. Human approval wakes the worker; this never grants permission. */ resume(operationId: string, options?: Omit): Promise; private read; /** The agent's own SDK requests through the Codemode SDK proxy (and the * transport a local Site preview forwards through). The attempt bearer never * enters a page. Validate tenant routing here; ordinary API handlers * authorize the operation under the existing agent proxy permission ceiling. * Requests marked as Site frames are held to the Site operation allowlist * by the preview handler and again by the API. */ sessionRequest(path: string, init: RequestInit): Promise; private request; } export declare function compileCodemodeTools(catalog: AttemptToolCatalogValue, client: CodemodeClient): CodemodeTools; export declare class AttemptToolEnvironment { readonly catalog: AttemptToolCatalogValue; private readonly gateway; constructor(catalog: AttemptToolCatalogValue, gateway: ToolGateway); call(input: AttemptToolCallValue, context?: { transportMeta?: Record | null; signal?: AbortSignal; }): Promise; prepareCall(input: AttemptToolCallValue, context?: { transportMeta?: Record | null; signal?: AbortSignal; }): Promise; effectDigest(identity: AttemptToolIdentity): string; callModel(input: ModelAttemptToolCall): Promise; } export declare function createAttemptToolEnvironment(input: CreateAttemptToolEnvironmentInput): AttemptToolEnvironment; export declare function digestAttemptToolCatalog(catalog: Omit): string; export declare function digestCodemodeOperationRequest(input: Pick): string; export declare function codemodeDispatchSubject(workspaceId: string, attemptId: string): string; export declare function encodeCodemodeDispatchRequest(input: CodemodeDispatchRequestValue): Uint8Array; export declare function decodeCodemodeDispatchRequest(input: Uint8Array): CodemodeDispatchRequestValue; export declare function encodeCodemodeDispatchAck(input: CodemodeDispatchAckValue): Uint8Array; export declare function decodeCodemodeDispatchAck(input: Uint8Array): CodemodeDispatchAckValue; export declare function parseVerifiedAttemptToolCatalog(input: unknown): AttemptToolCatalogValue; /** Verifies a catalog and also reports its serialized UTF-8 size. */ export declare function verifyAttemptToolCatalog(input: unknown): { catalog: AttemptToolCatalogValue; byteLength: number; }; /** A server-declared transient failure whose outcome is known: nothing was applied. */ export declare function isTransientCodemodeTransportError(error: unknown): boolean; export * from "./environment.js"; export * from "./interaction.js"; export * from "./images.js"; export * from "./artifacts.js"; export * from "./structured.js"; export * from "./declarations.js"; export * from "./site.js"; export * from "./pagination.js";