@runloop/agent-axon-client
    Preparing search index...

    Interface Query

    Query interface with methods for controlling query execution. Extends AsyncGenerator and has methods, so not serializable.

    interface Query {
        "[asyncIterator]"(): AsyncGenerator<SDKMessage, void, any>;
        accountInfo(): Promise<AccountInfo>;
        applyFlagSettings(settings: Settings): Promise<void>;
        close(): void;
        getContextUsage(): Promise<SDKControlGetContextUsageResponse>;
        initializationResult(): Promise<SDKControlInitializeResponse>;
        interrupt(): Promise<void>;
        mcpServerStatus(): Promise<McpServerStatus[]>;
        next(
            ...__namedParameters: [] | [any],
        ): Promise<IteratorResult<SDKMessage, void>>;
        reconnectMcpServer(serverName: string): Promise<void>;
        reloadPlugins(): Promise<SDKControlReloadPluginsResponse>;
        return(
            value: void | PromiseLike<void>,
        ): Promise<IteratorResult<SDKMessage, void>>;
        rewindFiles(
            userMessageId: string,
            options?: { dryRun?: boolean },
        ): Promise<RewindFilesResult>;
        seedReadState(path: string, mtime: number): Promise<void>;
        setMaxThinkingTokens(maxThinkingTokens: number | null): Promise<void>;
        setMcpServers(
            servers: Record<string, McpServerConfig>,
        ): Promise<McpSetServersResult>;
        setModel(model?: string): Promise<void>;
        setPermissionMode(mode: PermissionMode): Promise<void>;
        stopTask(taskId: string): Promise<void>;
        streamInput(stream: AsyncIterable<SDKUserMessage>): Promise<void>;
        supportedAgents(): Promise<AgentInfo[]>;
        supportedCommands(): Promise<SlashCommand[]>;
        supportedModels(): Promise<ModelInfo[]>;
        throw(e: any): Promise<IteratorResult<SDKMessage, void>>;
        toggleMcpServer(serverName: string, enabled: boolean): Promise<void>;
    }

    Hierarchy

    Index

    Claude SDK

    • Returns AsyncGenerator<SDKMessage, void, any>

    • Get information about the authenticated account.

      Returns Promise<AccountInfo>

      Account information including email, organization, and subscription type

    • Merge the provided settings into the flag settings layer, dynamically updating the active configuration. Top-level keys are shallow-merged across successive calls — a second call with {permissions: {...}} replaces the entire permissions object from a prior call. The resulting flag settings are then deep-merged with file-based settings at read time.

      Equivalent to passing an object to the settings option of query(), but applies mid-session. Only available in streaming input mode.

      Parameters

      • settings: Settings

        A partial settings object to merge into the flag settings

      Returns Promise<void>

    • Close the query and terminate the underlying process. This forcefully ends the query, cleaning up all resources including pending requests, MCP transports, and the CLI subprocess.

      Use this when you need to abort a query that is still running. After calling close(), no further messages will be received.

      Returns void

    • Get a breakdown of current context window usage by category (system prompt, tools, messages, MCP tools, memory files, etc.).

      Returns Promise<SDKControlGetContextUsageResponse>

      Context usage breakdown including token counts per category and total usage

    • Get the full initialization result, including supported commands, models, account info, and output style configuration.

      Returns Promise<SDKControlInitializeResponse>

      The complete initialization response

    • Interrupt the current query execution. The query will stop processing and return control to the caller.

      Returns Promise<void>

    • Get the current status of all configured MCP servers.

      Returns Promise<McpServerStatus[]>

      Array of MCP server statuses (connected, failed, needs-auth, pending)

    • Parameters

      • ...__namedParameters: [] | [any]

      Returns Promise<IteratorResult<SDKMessage, void>>

    • Reconnect an MCP server by name. Throws on failure.

      Parameters

      • serverName: string

        The name of the MCP server to reconnect

      Returns Promise<void>

    • Reload plugins from disk and return the refreshed commands, agents, plugins, and MCP server status.

      Returns Promise<SDKControlReloadPluginsResponse>

      The refreshed session components after plugin reload

    • Parameters

      • value: void | PromiseLike<void>

      Returns Promise<IteratorResult<SDKMessage, void>>

    • Rewind tracked files to their state at a specific user message. Requires file checkpointing to be enabled via the enableFileCheckpointing option.

      Parameters

      • userMessageId: string

        UUID of the user message to rewind to

      • Optionaloptions: { dryRun?: boolean }

        Options object with optional dryRun boolean to preview changes without modifying files

      Returns Promise<RewindFilesResult>

      Object with canRewind boolean, optional error message, and file change statistics

    • Seed the CLI's readFileState cache with a path+mtime entry. Use when the client observed a Read that has since been removed from context (e.g. by snip), so a subsequent Edit won't fail "file not read yet". If the file changed on disk since the given mtime, the seed is skipped and Edit will correctly require a fresh Read.

      Parameters

      • path: string

        Path to the file that was previously Read

      • mtime: number

        File mtime (floored ms) at the time of the observed Read

      Returns Promise<void>

    • Set the maximum number of thinking tokens the model is allowed to use when generating its response. This can be used to limit the amount of tokens the model uses for its response, which can help control cost and latency.

      Use null to clear any previously set limit and allow the model to use the default maximum thinking tokens.

      Parameters

      • maxThinkingTokens: number | null

        Maximum tokens for thinking, or null to clear the limit

      Returns Promise<void>

      Use the thinking option in query() instead. On Opus 4.6, this is treated as on/off (0 = disabled, any other value = adaptive). For explicit control, use thinking: { type: 'adaptive' } or thinking: { type: 'enabled', budgetTokens: N }.

    • Dynamically set the MCP servers for this session. This replaces the current set of dynamically-added MCP servers with the provided set. Servers that are removed will be disconnected, and new servers will be connected.

      Supports both process-based servers (stdio, sse, http) and SDK servers (in-process). SDK servers are handled locally in the SDK process, while process-based servers are managed by the CLI subprocess.

      Note: This only affects servers added dynamically via this method or the SDK. Servers configured via settings files are not affected.

      Parameters

      • servers: Record<string, McpServerConfig>

        Record of server name to configuration. Pass an empty object to remove all dynamic servers.

      Returns Promise<McpSetServersResult>

      Information about which servers were added, removed, and any connection errors

    • Change the model used for subsequent responses. Only available in streaming input mode.

      Parameters

      • Optionalmodel: string

        The model identifier to use, or undefined to use the default

      Returns Promise<void>

    • Change the permission mode for the current session. Only available in streaming input mode.

      Parameters

      Returns Promise<void>

    • Stop a running task. A task_notification with status 'stopped' will be emitted.

      Parameters

      • taskId: string

        The task ID from task_notification events

      Returns Promise<void>

    • Stream input messages to the query. Used internally for multi-turn conversations.

      Parameters

      • stream: AsyncIterable<SDKUserMessage>

        Async iterable of user messages to send

      Returns Promise<void>

    • Get the list of available subagents for the current session.

      Returns Promise<AgentInfo[]>

      Array of available agents with their names, descriptions, and configuration

    • Get the list of available skills for the current session.

      Returns Promise<SlashCommand[]>

      Array of available skills with their names and descriptions

    • Get the list of available models.

      Returns Promise<ModelInfo[]>

      Array of model information including display names and descriptions

    • Parameters

      • e: any

      Returns Promise<IteratorResult<SDKMessage, void>>

    • Enable or disable an MCP server by name. Throws on failure.

      Parameters

      • serverName: string

        The name of the MCP server to toggle

      • enabled: boolean

        Whether the server should be enabled

      Returns Promise<void>