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 { CallToolResult, ToolAnnotations } from '@modelcontextprotocol/sdk/types.js'
|
||||||
import type { ZodTypeAny } from 'zod/v4'
|
import type { ZodTypeAny } from 'zod/v4'
|
||||||
|
import type {
|
||||||
|
SDKMessage,
|
||||||
|
SDKResultMessage,
|
||||||
|
SDKSessionInfo as CoreSDKSessionInfo,
|
||||||
|
SDKUserMessage,
|
||||||
|
} from './coreTypes.ts'
|
||||||
|
|
||||||
export type EffortLevel = 'low' | 'medium' | 'high' | 'max'
|
export type EffortLevel = 'low' | 'medium' | 'high' | 'max'
|
||||||
|
|
||||||
@@ -19,17 +25,33 @@ export type SdkMcpToolDefinition<Schema extends AnyZodRawShape> = {
|
|||||||
alwaysLoad?: boolean
|
alwaysLoad?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type McpSdkServerConfigWithInstance = Record<string, unknown>
|
export type McpSdkServerConfigWithInstance = Record<string, unknown> & {
|
||||||
|
name?: string
|
||||||
export type Options = Record<string, unknown>
|
version?: string
|
||||||
export type InternalOptions = Options
|
instance?: unknown
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
export type SDKSessionOptions = Options & {
|
tools?: Array<SdkMcpToolDefinition<any>>
|
||||||
model?: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Query = AsyncIterable<unknown>
|
export type Options = Record<string, unknown> & {
|
||||||
export type InternalQuery = AsyncIterable<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 = {
|
export type SessionMutationOptions = {
|
||||||
dir?: string
|
dir?: string
|
||||||
@@ -48,7 +70,10 @@ export type GetSessionMessagesOptions = SessionMutationOptions & {
|
|||||||
includeSystemMessages?: boolean
|
includeSystemMessages?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ForkSessionOptions = SessionMutationOptions
|
export type ForkSessionOptions = SessionMutationOptions & {
|
||||||
|
upToMessageId?: string
|
||||||
|
title?: string
|
||||||
|
}
|
||||||
|
|
||||||
export type ForkSessionResult = {
|
export type ForkSessionResult = {
|
||||||
sessionId: string
|
sessionId: string
|
||||||
@@ -56,4 +81,13 @@ export type ForkSessionResult = {
|
|||||||
|
|
||||||
export type SDKSession = {
|
export type SDKSession = {
|
||||||
id: string
|
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