refactor: enrich sdk runtime session types
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
import type { CallToolResult, ToolAnnotations } from '@modelcontextprotocol/sdk/types.js'
|
||||
import type { ZodTypeAny } from 'zod/v4'
|
||||
import type {
|
||||
SDKMessage,
|
||||
SDKResultMessage,
|
||||
SDKSessionInfo as CoreSDKSessionInfo,
|
||||
SDKUserMessage,
|
||||
} from './coreTypes.ts'
|
||||
|
||||
export type EffortLevel = 'low' | 'medium' | 'high' | 'max'
|
||||
|
||||
@@ -19,17 +25,33 @@ export type SdkMcpToolDefinition<Schema extends AnyZodRawShape> = {
|
||||
alwaysLoad?: boolean
|
||||
}
|
||||
|
||||
export type McpSdkServerConfigWithInstance = Record<string, unknown>
|
||||
|
||||
export type Options = Record<string, unknown>
|
||||
export type InternalOptions = Options
|
||||
|
||||
export type SDKSessionOptions = Options & {
|
||||
model?: string
|
||||
export type McpSdkServerConfigWithInstance = Record<string, unknown> & {
|
||||
name?: string
|
||||
version?: string
|
||||
instance?: unknown
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
tools?: Array<SdkMcpToolDefinition<any>>
|
||||
}
|
||||
|
||||
export type Query = AsyncIterable<unknown>
|
||||
export type InternalQuery = AsyncIterable<unknown>
|
||||
export type Options = Record<string, unknown> & {
|
||||
cwd?: string
|
||||
model?: string
|
||||
permissionMode?: string
|
||||
maxThinkingTokens?: number | null
|
||||
}
|
||||
|
||||
export type InternalOptions = Options & {
|
||||
systemPrompt?: string
|
||||
appendSystemPrompt?: string
|
||||
}
|
||||
|
||||
export type SDKSessionOptions = Options & {
|
||||
cwd?: string
|
||||
resume?: boolean
|
||||
}
|
||||
|
||||
export type Query = AsyncIterable<SDKMessage>
|
||||
export type InternalQuery = AsyncIterable<SDKMessage>
|
||||
|
||||
export type SessionMutationOptions = {
|
||||
dir?: string
|
||||
@@ -48,7 +70,10 @@ export type GetSessionMessagesOptions = SessionMutationOptions & {
|
||||
includeSystemMessages?: boolean
|
||||
}
|
||||
|
||||
export type ForkSessionOptions = SessionMutationOptions
|
||||
export type ForkSessionOptions = SessionMutationOptions & {
|
||||
upToMessageId?: string
|
||||
title?: string
|
||||
}
|
||||
|
||||
export type ForkSessionResult = {
|
||||
sessionId: string
|
||||
@@ -56,4 +81,13 @@ export type ForkSessionResult = {
|
||||
|
||||
export type SDKSession = {
|
||||
id: string
|
||||
query(
|
||||
prompt: string | AsyncIterable<SDKUserMessage>,
|
||||
options?: Options,
|
||||
): Query
|
||||
interrupt(): void
|
||||
}
|
||||
|
||||
export type SessionMessage = SDKMessage
|
||||
|
||||
export type SDKSessionInfo = CoreSDKSessionInfo
|
||||
|
||||
Reference in New Issue
Block a user