@tbox-dev-js/sdk 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/constant.ts","../src/error.ts","../src/core.ts","../src/resource.ts","../src/resources/knowledge/documents.ts","../src/resources/knowledge/index.ts","../src/schema.ts","../src/resources/knowledge/schema.ts","../src/tbox-api.ts","../src/knowledge-client.ts","../src/http.ts","../src/plugin.ts","../src/conversation.ts","../src/app.ts","../src/amap.ts","../src/knowledge.ts","../src/llm.ts"],"sourcesContent":["/**\n * @tbox/sdk — 常量定义\n */\n\n/** 默认 API 基础 URL */\nexport const TBOX_BASE_URL = 'https://o.tbox.cn';\n\n/** SDK 版本号 */\nexport const SDK_VERSION = '1.0.0';\n\n/** SDK 版本标识 header key */\nexport const SDK_VERSION_HEADER = 'X-Tbox-SDK-Version';\n","/**\n * @tbox/sdk — 分层错误体系\n *\n * 对齐 coze-js 的 error.ts 设计:\n * TboxError → APIError → 按 HTTP 状态码的子类\n */\n\n/** 所有 SDK 错误的基类 */\nexport class TboxError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'TboxError';\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** 服务端原始响应结构(用于错误工厂) */\ninterface RawErrorBody {\n success?: boolean;\n errorCode?: string;\n code?: string | number;\n resultCode?: string;\n errorMsg?: string;\n msg?: string;\n resultDesc?: string;\n traceId?: string;\n}\n\n/** API 调用错误,包含 HTTP 状态码和业务错误信息 */\nexport class APIError extends TboxError {\n readonly status: number;\n readonly errorCode?: string;\n readonly errorMsg?: string;\n readonly traceId?: string;\n readonly rawResponse?: unknown;\n\n constructor(\n status: number,\n errorCode: string | undefined,\n errorMsg: string | undefined,\n traceId: string | undefined,\n rawResponse?: unknown,\n ) {\n const message = errorMsg ?? `API error (status ${status})`;\n super(message);\n this.name = 'APIError';\n this.status = status;\n this.errorCode = errorCode;\n this.errorMsg = errorMsg;\n this.traceId = traceId;\n this.rawResponse = rawResponse;\n }\n\n /**\n * Factory: create the appropriate error subclass based on HTTP status code.\n */\n static generate(status: number, body?: RawErrorBody): APIError {\n const errorCode = body?.errorCode ?? (body?.code != null ? String(body.code) : undefined) ?? body?.resultCode;\n const errorMsg = body?.errorMsg ?? body?.msg ?? body?.resultDesc;\n const traceId = body?.traceId;\n\n switch (status) {\n case 400:\n return new BadRequestError(errorCode, errorMsg, traceId, body);\n case 401:\n return new AuthenticationError(errorCode, errorMsg, traceId, body);\n case 403:\n return new ForbiddenError(errorCode, errorMsg, traceId, body);\n case 404:\n return new NotFoundError(errorCode, errorMsg, traceId, body);\n case 429:\n return new RateLimitError(errorCode, errorMsg, traceId, body);\n case 500:\n return new InternalServerError(errorCode, errorMsg, traceId, body);\n case 502:\n return new GatewayError(errorCode, errorMsg, traceId, body);\n default:\n return new APIError(status, errorCode, errorMsg, traceId, body);\n }\n }\n}\n\nexport class BadRequestError extends APIError {\n constructor(errorCode?: string, errorMsg?: string, traceId?: string, rawResponse?: unknown) {\n super(400, errorCode, errorMsg, traceId, rawResponse);\n this.name = 'BadRequestError';\n }\n}\n\nexport class AuthenticationError extends APIError {\n constructor(errorCode?: string, errorMsg?: string, traceId?: string, rawResponse?: unknown) {\n super(401, errorCode, errorMsg, traceId, rawResponse);\n this.name = 'AuthenticationError';\n }\n}\n\nexport class ForbiddenError extends APIError {\n constructor(errorCode?: string, errorMsg?: string, traceId?: string, rawResponse?: unknown) {\n super(403, errorCode, errorMsg, traceId, rawResponse);\n this.name = 'ForbiddenError';\n }\n}\n\nexport class NotFoundError extends APIError {\n constructor(errorCode?: string, errorMsg?: string, traceId?: string, rawResponse?: unknown) {\n super(404, errorCode, errorMsg, traceId, rawResponse);\n this.name = 'NotFoundError';\n }\n}\n\nexport class RateLimitError extends APIError {\n constructor(errorCode?: string, errorMsg?: string, traceId?: string, rawResponse?: unknown) {\n super(429, errorCode, errorMsg, traceId, rawResponse);\n this.name = 'RateLimitError';\n }\n}\n\nexport class InternalServerError extends APIError {\n constructor(errorCode?: string, errorMsg?: string, traceId?: string, rawResponse?: unknown) {\n super(500, errorCode, errorMsg, traceId, rawResponse);\n this.name = 'InternalServerError';\n }\n}\n\nexport class GatewayError extends APIError {\n constructor(errorCode?: string, errorMsg?: string, traceId?: string, rawResponse?: unknown) {\n super(502, errorCode, errorMsg, traceId, rawResponse);\n this.name = 'GatewayError';\n }\n}\n\n/** Network unreachable error */\nexport class NetworkError extends TboxError {\n readonly cause?: Error;\n\n constructor(message: string, cause?: Error) {\n super(message);\n this.name = 'NetworkError';\n this.cause = cause;\n }\n}\n\n/** Request timeout error */\nexport class TimeoutError extends TboxError {\n readonly timeout: number;\n\n constructor(timeout: number) {\n super(`Request timed out after ${timeout}ms`);\n this.name = 'TimeoutError';\n this.timeout = timeout;\n }\n}\n\n/** JSON parse error */\nexport class ParseError extends TboxError {\n readonly responseText?: string;\n\n constructor(message: string, responseText?: string) {\n super(message);\n this.name = 'ParseError';\n this.responseText = responseText;\n }\n}\n","/**\n * @tbox/sdk — APIClient 核心基类\n *\n * 对齐 coze-js 的 core.ts 设计:\n * - Token 管理(静态字符串 / 动态函数)\n * - 请求构建(JSON / FormData / SSE)\n * - 响应解包(兼容多种服务端格式)\n * - 错误映射(HTTP 状态码 → 错误子类)\n */\n\nimport { TBOX_BASE_URL, SDK_VERSION, SDK_VERSION_HEADER } from './constant';\nimport {\n APIError,\n NetworkError,\n TimeoutError,\n ParseError,\n} from './error';\n\n/** SDK 初始化配置 */\nexport interface ClientOptions {\n /**\n * API Key or dynamic token function.\n * String is used directly as Bearer Token; function is called before each request.\n */\n token: string | (() => string | Promise<string>);\n\n /** API base URL. @default \"https://o.tbox.cn\" */\n baseURL?: string;\n\n /** Request timeout in milliseconds. @default undefined (no timeout) */\n timeout?: number;\n\n /** Enable debug logging. @default false */\n debug?: boolean;\n\n /** Custom headers merged into every request. */\n headers?: Record<string, string>;\n}\n\n/** Per-request option overrides */\nexport interface RequestOptions {\n timeout?: number;\n headers?: Record<string, string>;\n debug?: boolean;\n signal?: AbortSignal;\n baseURL?: string;\n}\n\n/** SSE event object */\nexport interface SSEEvent {\n data: string;\n event?: string;\n id?: string;\n retry?: number;\n}\n\n/**\n * Raw API response structure — compatible with multiple server-side formats.\n */\ninterface RawApiResponse {\n success?: boolean;\n data?: unknown;\n resultObj?: unknown;\n result?: unknown;\n errorCode?: string;\n code?: string | number;\n resultCode?: string;\n errorMsg?: string;\n msg?: string;\n resultDesc?: string;\n traceId?: string;\n hostName?: string;\n}\n\n/**\n * Check if a result field is a knowledge-style nested wrapper:\n * { response: {...}, success: boolean, errorType?: string }\n */\nfunction isKnowledgeWrapper(value: unknown): value is { response?: unknown; success?: boolean; errorType?: string } {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'response' in value &&\n 'success' in value\n );\n}\n\n/**\n * Core request engine. All Resource classes call methods on this via `this._client`.\n */\nexport class APIClient {\n protected baseURL: string;\n protected token: string | (() => string | Promise<string>);\n protected timeout?: number;\n protected debug: boolean;\n protected defaultHeaders?: Record<string, string>;\n\n constructor(options: ClientOptions) {\n this.baseURL = (options.baseURL ?? TBOX_BASE_URL).replace(/\\/$/, '');\n this.token = options.token;\n this.timeout = options.timeout;\n this.debug = options.debug ?? false;\n this.defaultHeaders = options.headers;\n }\n\n /** Resolve the current token value (supports async token functions). */\n protected async getToken(): Promise<string> {\n if (typeof this.token === 'function') {\n return this.token();\n }\n return this.token;\n }\n\n /** JSON POST request — returns unwrapped business data. */\n async post<Rsp>(path: string, body?: unknown, options?: RequestOptions): Promise<Rsp> {\n const url = this.buildUrl(path, options);\n const headers = await this.buildHeaders(options, 'application/json;charset=UTF-8');\n\n this.debugLog(options, `POST ${url}`, body);\n\n const response = await this.fetchWithTimeout(url, {\n method: 'POST',\n headers,\n body: body != null ? JSON.stringify(body) : undefined,\n signal: options?.signal,\n }, options);\n\n return this.parseAndUnwrap<Rsp>(response, options);\n }\n\n /** GET request — query params auto-appended to URL. */\n async get<Rsp>(\n path: string,\n params?: Record<string, string | number | boolean | undefined>,\n options?: RequestOptions,\n ): Promise<Rsp> {\n let url = this.buildUrl(path, options);\n\n if (params) {\n const searchParams = new URLSearchParams();\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n searchParams.append(key, String(value));\n }\n }\n const queryString = searchParams.toString();\n if (queryString) {\n url += `?${queryString}`;\n }\n }\n\n const headers = await this.buildHeaders(options);\n\n this.debugLog(options, `GET ${url}`);\n\n const response = await this.fetchWithTimeout(url, {\n method: 'GET',\n headers,\n signal: options?.signal,\n }, options);\n\n return this.parseAndUnwrap<Rsp>(response, options);\n }\n\n /** FormData POST request (file uploads). Content-Type is set automatically by fetch. */\n async postFormData<Rsp>(path: string, formData: FormData, options?: RequestOptions): Promise<Rsp> {\n const url = this.buildUrl(path, options);\n const headers = await this.buildHeaders(options);\n // Do NOT set Content-Type — fetch/browser will set multipart/form-data with boundary\n delete (headers as Record<string, string>)['Content-Type'];\n\n this.debugLog(options, `POST (FormData) ${url}`);\n\n const response = await this.fetchWithTimeout(url, {\n method: 'POST',\n headers,\n body: formData,\n signal: options?.signal,\n }, options);\n\n return this.parseAndUnwrap<Rsp>(response, options);\n }\n\n /** SSE streaming POST request — yields SSEEvent objects. */\n async *postStream(path: string, body?: unknown, options?: RequestOptions): AsyncGenerator<SSEEvent> {\n const url = this.buildUrl(path, options);\n const headers = await this.buildHeaders(options, 'application/json;charset=UTF-8');\n\n this.debugLog(options, `POST (stream) ${url}`, body);\n\n const response = await this.fetchWithTimeout(url, {\n method: 'POST',\n headers,\n body: body != null ? JSON.stringify(body) : undefined,\n signal: options?.signal,\n }, options);\n\n if (!response.ok) {\n const raw = await this.safeParseJson(response);\n throw APIError.generate(response.status, raw ?? undefined);\n }\n\n if (!response.body) {\n throw new ParseError('Response body is null — streaming not supported');\n }\n\n yield* this.parseSSEStream(response);\n }\n\n // ================================================================\n // Internal helpers\n // ================================================================\n\n private buildUrl(path: string, options?: RequestOptions): string {\n const base = options?.baseURL?.replace(/\\/$/, '') ?? this.baseURL;\n return `${base}${path}`;\n }\n\n private async buildHeaders(\n options?: RequestOptions,\n contentType?: string,\n ): Promise<Record<string, string>> {\n const token = await this.getToken();\n\n const headers: Record<string, string> = {\n Authorization: token,\n [SDK_VERSION_HEADER]: SDK_VERSION,\n ...this.defaultHeaders,\n ...options?.headers,\n };\n\n if (contentType) {\n headers['Content-Type'] = contentType;\n }\n\n return headers;\n }\n\n private async fetchWithTimeout(\n url: string,\n init: RequestInit,\n options?: RequestOptions,\n ): Promise<Response> {\n const timeoutMs = options?.timeout ?? this.timeout;\n\n if (!timeoutMs) {\n try {\n return await fetch(url, init);\n } catch (error) {\n throw new NetworkError(\n 'Network request failed',\n error instanceof Error ? error : undefined,\n );\n }\n }\n\n const controller = new AbortController();\n const existingSignal = init.signal;\n\n // Merge external signal with timeout signal\n if (existingSignal) {\n existingSignal.addEventListener('abort', () => controller.abort(existingSignal.reason));\n }\n\n const timer = setTimeout(() => controller.abort('timeout'), timeoutMs);\n\n try {\n return await fetch(url, { ...init, signal: controller.signal });\n } catch (error) {\n if (controller.signal.aborted && controller.signal.reason === 'timeout') {\n throw new TimeoutError(timeoutMs);\n }\n throw new NetworkError(\n 'Network request failed',\n error instanceof Error ? error : undefined,\n );\n } finally {\n clearTimeout(timer);\n }\n }\n\n private async parseAndUnwrap<Rsp>(response: Response, options?: RequestOptions): Promise<Rsp> {\n if (!response.ok) {\n const raw = await this.safeParseJson(response);\n throw APIError.generate(response.status, raw ?? undefined);\n }\n\n const raw = await this.parseJsonResponse<RawApiResponse>(response);\n\n this.debugLog(options, 'Response:', raw);\n\n return this.unwrapResponse<Rsp>(raw, response.status);\n }\n\n /**\n * Unwrap server response — extract business data from various envelope formats.\n *\n * Priority: data > resultObj > result.response (knowledge) > result > raw\n */\n private unwrapResponse<Rsp>(raw: RawApiResponse, httpStatus: number): Rsp {\n // Check outer success flag\n if (raw.success === false) {\n throw APIError.generate(httpStatus, raw);\n }\n\n // Priority 1: data field\n if (raw.data !== undefined) {\n return raw.data as Rsp;\n }\n\n // Priority 2: resultObj field\n if (raw.resultObj !== undefined) {\n return raw.resultObj as Rsp;\n }\n\n // Priority 3: result field (may be knowledge wrapper)\n if (raw.result !== undefined) {\n if (isKnowledgeWrapper(raw.result)) {\n if (raw.result.success === false) {\n throw APIError.generate(httpStatus, {\n ...raw,\n errorMsg: raw.result.errorType ?? raw.errorMsg,\n });\n }\n return raw.result.response as Rsp;\n }\n return raw.result as Rsp;\n }\n\n // Fallback: return the entire raw response if it has meaningful fields,\n // otherwise throw a ParseError to avoid silently returning an unexpected shape.\n if (raw.success !== undefined || raw.code !== undefined || raw.resultCode !== undefined) {\n return raw as unknown as Rsp;\n }\n throw new ParseError('Unexpected response format — unable to extract business data', JSON.stringify(raw));\n }\n\n /** Parse JSON response using ArrayBuffer + TextDecoder for correct UTF-8 handling. */\n private async parseJsonResponse<T>(response: Response): Promise<T> {\n let text: string;\n try {\n const buffer = await response.arrayBuffer();\n text = new TextDecoder('utf-8').decode(buffer);\n } catch {\n throw new ParseError('Failed to read response body');\n }\n\n try {\n return JSON.parse(text) as T;\n } catch {\n throw new ParseError('Failed to parse response JSON', text);\n }\n }\n\n /** Safely parse JSON without throwing (for error responses). */\n private async safeParseJson(response: Response): Promise<RawApiResponse | null> {\n try {\n const buffer = await response.arrayBuffer();\n const text = new TextDecoder('utf-8').decode(buffer);\n return JSON.parse(text) as RawApiResponse;\n } catch {\n return null;\n }\n }\n\n /** Parse SSE stream from ReadableStream. */\n private async *parseSSEStream(response: Response): AsyncGenerator<SSEEvent> {\n const reader = response.body!.getReader();\n const decoder = new TextDecoder();\n let buffer = '';\n\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n\n buffer += decoder.decode(value, { stream: true });\n const lines = buffer.split('\\n');\n buffer = lines.pop() ?? '';\n\n for (const line of lines) {\n const trimmed = line.trim();\n if (trimmed.startsWith('data: ')) {\n const data = trimmed.slice(6).trim();\n if (data === '[DONE]') return;\n yield { data };\n }\n }\n }\n } finally {\n reader.releaseLock();\n }\n }\n\n /** Output debug log when debug mode is enabled. */\n protected debugLog(options: RequestOptions | undefined, ...messages: unknown[]): void {\n const isDebug = options?.debug ?? this.debug;\n if (isDebug) {\n console.log('[TboxSDK]', ...messages);\n }\n }\n}\n","/**\n * @tbox/sdk — APIResource 基类\n *\n * 所有 Resource 子类(Knowledge、Plugins 等)继承此类,\n * 通过 this._client 引用 APIClient 发起请求。\n */\n\nimport type { APIClient } from './core';\n\nexport class APIResource {\n protected _client: APIClient;\n\n constructor(client: APIClient) {\n this._client = client;\n }\n}\n","/**\n * @tbox/sdk — Knowledge Documents sub-resource\n *\n * Handles knowledge base creation and update (multipart/form-data uploads).\n */\n\nimport { APIResource } from '../../resource';\nimport type { RequestOptions } from '../../core';\nimport type {\n DocumentCreateParams,\n DocumentCreateResult,\n DocumentUpdateParams,\n DocumentUpdateResult,\n} from './types';\n\n/** Build FormData for knowledge base creation. */\nfunction buildCreateFormData(params: DocumentCreateParams): FormData {\n const formData = new FormData();\n\n formData.append('file', params.file);\n formData.append('type', params.type);\n\n if (params.tableSchema) {\n formData.append('tableSchema', JSON.stringify(params.tableSchema));\n }\n\n if (params.indexColumns) {\n for (const col of params.indexColumns) {\n formData.append('indexColumns', col);\n }\n }\n\n return formData;\n}\n\n/** Build FormData for knowledge base update. */\nfunction buildUpdateFormData(params: DocumentUpdateParams): FormData {\n const formData = new FormData();\n\n formData.append('documentId', params.documentId);\n formData.append('file', params.file);\n formData.append('type', params.type);\n\n if (params.updateMode) {\n formData.append('updateMode', params.updateMode);\n }\n\n if (params.tableSchema) {\n formData.append('tableSchema', JSON.stringify(params.tableSchema));\n }\n\n if (params.indexColumns) {\n for (const col of params.indexColumns) {\n formData.append('indexColumns', col);\n }\n }\n\n return formData;\n}\n\nexport class Documents extends APIResource {\n /**\n * Create a knowledge base by uploading a file.\n *\n * POST /openapi/v1/knowledge/createKnowledgeBaseByDataSet\n * Content-Type: multipart/form-data\n */\n async create(params: DocumentCreateParams, options?: RequestOptions): Promise<DocumentCreateResult> {\n const formData = buildCreateFormData(params);\n return this._client.postFormData<DocumentCreateResult>(\n '/openapi/v1/knowledge/createKnowledgeBaseByDataSet',\n formData,\n options,\n );\n }\n\n /**\n * Update an existing knowledge base document.\n *\n * POST /openapi/v1/knowledge/updateDocument\n * Content-Type: multipart/form-data\n */\n async update(params: DocumentUpdateParams, options?: RequestOptions): Promise<DocumentUpdateResult> {\n const formData = buildUpdateFormData(params);\n return this._client.postFormData<DocumentUpdateResult>(\n '/openapi/v1/knowledge/updateDocument',\n formData,\n options,\n );\n }\n}\n","/**\n * @tbox/sdk — Knowledge Resource\n *\n * Provides knowledge base list, semantic retrieval, and document management.\n */\n\nimport { APIResource } from '../../resource';\nimport type { APIClient, RequestOptions } from '../../core';\nimport { Documents } from './documents';\nimport type {\n DatasetListParams,\n DatasetListResult,\n RetrieveParams,\n RetrieveResult,\n} from './types';\n\nexport class Knowledge extends APIResource {\n /** Document management sub-resource (create / update). */\n readonly documents: Documents;\n\n constructor(client: APIClient) {\n super(client);\n this.documents = new Documents(client);\n }\n\n /**\n * Query knowledge base list.\n *\n * GET /api/datasets/queryDatasetsList\n */\n async list(params?: DatasetListParams, options?: RequestOptions): Promise<DatasetListResult> {\n return this._client.get<DatasetListResult>(\n '/api/datasets/queryDatasetsList',\n params as Record<string, string | number | boolean | undefined>,\n options,\n );\n }\n\n /**\n * Semantic retrieval against a knowledge base.\n *\n * POST /api/datasets/retrieve\n */\n async retrieve(params: RetrieveParams, options?: RequestOptions): Promise<RetrieveResult> {\n return this._client.post<RetrieveResult>(\n '/api/datasets/retrieve',\n params,\n options,\n );\n }\n}\n\nexport { Documents } from './documents';\nexport type {\n DatasetListParams,\n DatasetListResult,\n DatasetInfo,\n RetrieveParams,\n RetrieveResult,\n RetrieveRecord,\n DocumentCreateParams,\n DocumentCreateResult,\n DocumentUpdateParams,\n DocumentUpdateResult,\n TableSchema,\n ColumnSchema,\n} from './types';\n","/**\n * @tbox/sdk — ResourceSchema 类型体系\n *\n * 用 JSON Schema 风格统一描述所有 API 资源的入参、出参和元信息,\n * 端侧可据此动态渲染表单、校验参数、生成配置。\n *\n * 设计原则:\n * - 对齐 JSON Schema Draft 7 的 property 描述格式\n * - 每个 API 操作(Operation)独立描述入参 + 出参 schema\n * - 所有资源通过 ResourceDefinition 统一注册\n * - 支持嵌套子资源(如 knowledge.documents)\n */\n\n// ================================================================\n// Property Schema — 单个字段的描述\n// ================================================================\n\n/** Supported JSON Schema types */\nexport type SchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'file';\n\n/** Single property descriptor — aligned with JSON Schema property format */\nexport interface PropertySchema {\n /** JSON Schema type */\n type: SchemaType;\n\n /** Human-readable description */\n description: string;\n\n /** Whether this field is required */\n required?: boolean;\n\n /** Default value */\n default?: unknown;\n\n /** Allowed values (enum constraint) */\n enum?: unknown[];\n\n /** For array type: schema of each item */\n items?: PropertySchema | ObjectSchema;\n\n /** For object type: nested properties */\n properties?: Record<string, PropertySchema>;\n\n /** Display format hint for UI rendering (e.g. \"textarea\", \"select\", \"file-upload\") */\n format?: string;\n\n /** Example value for documentation */\n example?: unknown;\n\n /** Minimum value (for number/integer) */\n minimum?: number;\n\n /** Maximum value (for number/integer) */\n maximum?: number;\n\n /** Min length (for string/array) */\n minLength?: number;\n\n /** Max length (for string/array) */\n maxLength?: number;\n\n /** Regex pattern (for string) */\n pattern?: string;\n}\n\n/** Object schema — a collection of named properties */\nexport interface ObjectSchema {\n type: 'object';\n description?: string;\n properties: Record<string, PropertySchema>;\n required?: string[];\n}\n\n// ================================================================\n// Operation Schema — 单个 API 操作的完整描述\n// ================================================================\n\n/** HTTP method */\nexport type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';\n\n/** Content type for request body */\nexport type ContentType = 'application/json' | 'multipart/form-data' | 'none';\n\n/** Complete description of a single API operation */\nexport interface OperationSchema {\n /** Operation identifier (e.g. \"list\", \"retrieve\", \"create\", \"update\") */\n operationId: string;\n\n /** Human-readable summary */\n summary: string;\n\n /** Detailed description */\n description?: string;\n\n /** HTTP method */\n method: HttpMethod;\n\n /** API path (relative to baseURL) */\n path: string;\n\n /** Request content type */\n contentType: ContentType;\n\n /** Input parameters schema */\n params: ObjectSchema;\n\n /** Response data schema (the unwrapped business data, not the raw envelope) */\n response: ObjectSchema;\n\n /** Tags for grouping/filtering */\n tags?: string[];\n}\n\n// ================================================================\n// Resource Definition — 一个资源模块的完整描述\n// ================================================================\n\n/** Complete definition of a resource module */\nexport interface ResourceDefinition {\n /** Resource name (e.g. \"knowledge\", \"plugins\", \"chat\") */\n name: string;\n\n /** Human-readable display name */\n displayName: string;\n\n /** Resource description */\n description: string;\n\n /** API operations provided by this resource */\n operations: OperationSchema[];\n\n /** Nested sub-resources (e.g. knowledge.documents) */\n subResources?: ResourceDefinition[];\n}\n\n// ================================================================\n// Schema Registry — 统一注册和查询\n// ================================================================\n\n/** Registry that holds all resource definitions */\nexport class SchemaRegistry {\n private resources: Map<string, ResourceDefinition> = new Map();\n\n /** Register a resource definition */\n register(definition: ResourceDefinition): void {\n this.resources.set(definition.name, definition);\n }\n\n /** Get a resource definition by name */\n get(name: string): ResourceDefinition | undefined {\n return this.resources.get(name);\n }\n\n /** Get all registered resource definitions */\n list(): ResourceDefinition[] {\n return Array.from(this.resources.values());\n }\n\n /** Get a specific operation by resource name and operation ID */\n getOperation(resourceName: string, operationId: string): OperationSchema | undefined {\n const resource = this.resources.get(resourceName);\n if (!resource) return undefined;\n\n const operation = resource.operations.find(op => op.operationId === operationId);\n if (operation) return operation;\n\n // Search in sub-resources\n for (const subResource of resource.subResources ?? []) {\n const subOperation = subResource.operations.find(op => op.operationId === operationId);\n if (subOperation) return subOperation;\n }\n\n return undefined;\n }\n\n /** Export all schemas as a plain JSON-serializable object */\n toJSON(): Record<string, ResourceDefinition> {\n const result: Record<string, ResourceDefinition> = {};\n for (const [name, definition] of this.resources) {\n result[name] = definition;\n }\n return result;\n }\n}\n","/**\n * @tbox/sdk — Knowledge 模块 ResourceSchema 定义\n *\n * 用 JSON Schema 风格描述知识库的 4 个核心 API 操作,\n * 端侧可据此动态渲染表单、校验参数、生成配置。\n */\n\nimport type { ResourceDefinition } from '../../schema';\n\n/** Knowledge documents sub-resource schema */\nconst documentsResource: ResourceDefinition = {\n name: 'documents',\n displayName: '知识库文档',\n description: '知识库文档的创建和更新(文件上传)',\n operations: [\n {\n operationId: 'create',\n summary: '创建知识库',\n description: '上传文件创建新的知识库,支持结构化(STRUCTURED)和非结构化(UNSTRUCTURED)两种类型',\n method: 'POST',\n path: '/openapi/v1/knowledge/createKnowledgeBaseByDataSet',\n contentType: 'multipart/form-data',\n params: {\n type: 'object',\n properties: {\n file: {\n type: 'file',\n description: '上传的文件(如 .xlsx、.csv、.pdf 等)',\n required: true,\n format: 'file-upload',\n },\n type: {\n type: 'string',\n description: '知识库类型',\n required: true,\n enum: ['STRUCTURED', 'UNSTRUCTURED'],\n default: 'STRUCTURED',\n format: 'select',\n },\n tableSchema: {\n type: 'object',\n description: '表结构定义(STRUCTURED 类型必填),JSON 格式',\n required: false,\n format: 'json-editor',\n properties: {\n name: {\n type: 'string',\n description: '表名',\n required: true,\n },\n description: {\n type: 'string',\n description: '表描述',\n required: false,\n },\n columns: {\n type: 'array',\n description: '列定义列表',\n required: true,\n items: {\n type: 'object',\n properties: {\n name: {\n type: 'string',\n description: '列名',\n required: true,\n },\n dataType: {\n type: 'string',\n description: '数据类型',\n enum: ['STRING', 'INTEGER', 'FLOAT', 'BOOLEAN', 'DATE'],\n default: 'STRING',\n },\n primaryKey: {\n type: 'boolean',\n description: '是否主键',\n default: false,\n },\n required: {\n type: 'boolean',\n description: '是否必填',\n default: false,\n },\n description: {\n type: 'string',\n description: '列描述',\n },\n defaultValue: {\n type: 'string',\n description: '默认值',\n },\n order: {\n type: 'integer',\n description: '排序序号',\n minimum: 0,\n },\n },\n },\n },\n },\n },\n indexColumns: {\n type: 'array',\n description: '索引列名列表',\n required: false,\n items: {\n type: 'string',\n description: '列名',\n },\n },\n },\n required: ['file', 'type'],\n },\n response: {\n type: 'object',\n properties: {\n documentId: {\n type: 'string',\n description: '创建后的文档 ID,用于后续更新操作',\n },\n },\n required: ['documentId'],\n },\n tags: ['knowledge', 'write'],\n },\n {\n operationId: 'update',\n summary: '更新知识库文档',\n description: '上传新文件更新已有的知识库文档,支持覆盖(OVERWRITE)和增量(UPSERT)两种模式',\n method: 'POST',\n path: '/openapi/v1/knowledge/updateDocument',\n contentType: 'multipart/form-data',\n params: {\n type: 'object',\n properties: {\n documentId: {\n type: 'string',\n description: '要更新的文档 ID(从创建响应中获取)',\n required: true,\n },\n file: {\n type: 'file',\n description: '上传的新文件',\n required: true,\n format: 'file-upload',\n },\n type: {\n type: 'string',\n description: '知识库类型',\n required: true,\n enum: ['STRUCTURED', 'UNSTRUCTURED'],\n format: 'select',\n },\n updateMode: {\n type: 'string',\n description: '更新模式',\n required: false,\n enum: ['OVERWRITE', 'UPSERT'],\n default: 'UPSERT',\n format: 'select',\n },\n tableSchema: {\n type: 'object',\n description: '表结构定义(同创建接口的 tableSchema)',\n required: false,\n format: 'json-editor',\n properties: {\n name: { type: 'string', description: '表名', required: true },\n description: { type: 'string', description: '表描述' },\n columns: {\n type: 'array',\n description: '列定义列表',\n required: true,\n items: {\n type: 'object',\n properties: {\n name: { type: 'string', description: '列名', required: true },\n dataType: { type: 'string', description: '数据类型', enum: ['STRING', 'INTEGER', 'FLOAT', 'BOOLEAN', 'DATE'] },\n primaryKey: { type: 'boolean', description: '是否主键' },\n required: { type: 'boolean', description: '是否必填' },\n description: { type: 'string', description: '列描述' },\n defaultValue: { type: 'string', description: '默认值' },\n order: { type: 'integer', description: '排序序号', minimum: 0 },\n },\n },\n },\n },\n },\n indexColumns: {\n type: 'array',\n description: '索引列名列表',\n required: false,\n items: { type: 'string', description: '列名' },\n },\n },\n required: ['documentId', 'file', 'type'],\n },\n response: {\n type: 'object',\n properties: {\n documentId: {\n type: 'string',\n description: '更新后的文档 ID',\n },\n },\n required: ['documentId'],\n },\n tags: ['knowledge', 'write'],\n },\n ],\n};\n\n/** Knowledge resource schema — the complete definition */\nexport const knowledgeSchema: ResourceDefinition = {\n name: 'knowledge',\n displayName: '知识库',\n description: '知识库管理,包括列表查询、语义检索、文档创建和更新',\n operations: [\n {\n operationId: 'list',\n summary: '查询知识库列表',\n description: '分页查询当前账号下的知识库列表,支持按名称模糊搜索',\n method: 'GET',\n path: '/api/datasets/queryDatasetsList',\n contentType: 'none',\n params: {\n type: 'object',\n properties: {\n name: {\n type: 'string',\n description: '知识库名称(模糊搜索)',\n required: false,\n },\n pageNo: {\n type: 'integer',\n description: '页码,从 1 开始',\n required: false,\n default: 1,\n minimum: 1,\n },\n pageSize: {\n type: 'integer',\n description: '每页条数',\n required: false,\n default: 10,\n minimum: 1,\n maximum: 100,\n },\n },\n },\n response: {\n type: 'object',\n properties: {\n data: {\n type: 'array',\n description: '知识库列表',\n items: {\n type: 'object',\n properties: {\n datasetId: { type: 'string', description: '知识库 ID' },\n name: { type: 'string', description: '知识库名称' },\n description: { type: 'string', description: '知识库描述' },\n type: { type: 'string', description: '知识库类型', enum: ['STRUCTURED', 'UNSTRUCTURED'] },\n documentCount: { type: 'integer', description: '文档数量' },\n storageSize: { type: 'number', description: '存储大小' },\n createdAt: { type: 'string', description: '创建时间' },\n updatedAt: { type: 'string', description: '更新时间' },\n },\n },\n },\n totalCount: {\n type: 'integer',\n description: '总条数',\n },\n },\n required: ['data', 'totalCount'],\n },\n tags: ['knowledge', 'read'],\n },\n {\n operationId: 'retrieve',\n summary: '语义检索',\n description: '对指定知识库进行语义检索,返回与查询文本最相关的文档片段',\n method: 'POST',\n path: '/api/datasets/retrieve',\n contentType: 'application/json',\n params: {\n type: 'object',\n properties: {\n datasetId: {\n type: 'string',\n description: '知识库 ID',\n required: true,\n },\n query: {\n type: 'string',\n description: '检索查询文本',\n required: true,\n format: 'textarea',\n },\n topK: {\n type: 'integer',\n description: '返回结果数量上限',\n required: false,\n default: 5,\n minimum: 1,\n maximum: 50,\n },\n scoreThreshold: {\n type: 'number',\n description: '最低相关度分数阈值 (0~1)',\n required: false,\n minimum: 0,\n maximum: 1,\n example: 0.5,\n },\n },\n required: ['datasetId', 'query'],\n },\n response: {\n type: 'object',\n properties: {\n data: {\n type: 'array',\n description: '检索结果列表',\n items: {\n type: 'object',\n properties: {\n content: { type: 'string', description: '文档片段内容' },\n score: { type: 'number', description: '相关度分数 (0~1)' },\n originFileName: { type: 'string', description: '来源文件名' },\n documentId: { type: 'string', description: '来源文档 ID' },\n metadata: { type: 'object', description: '元数据', properties: {} },\n },\n },\n },\n },\n required: ['data'],\n },\n tags: ['knowledge', 'read'],\n },\n ],\n subResources: [documentsResource],\n};\n","/**\n * @tbox/sdk — TboxAPI 入口类\n *\n * SDK 的唯一入口,继承 APIClient,通过属性访问子模块。\n * 内置 SchemaRegistry,自动注册所有资源的 JSON Schema 定义。\n */\n\nimport { APIClient } from './core';\nimport type { ClientOptions } from './core';\nimport { Knowledge } from './resources/knowledge/index';\nimport { SchemaRegistry } from './schema';\nimport { knowledgeSchema } from './resources/knowledge/schema';\n\nexport class TboxAPI extends APIClient {\n /** Knowledge base management (list, retrieve, documents.create, documents.update). */\n readonly knowledge: Knowledge;\n\n /** Schema registry — JSON Schema definitions for all resources, available for client-side parsing. */\n readonly schemas: SchemaRegistry;\n\n constructor(options: ClientOptions) {\n super(options);\n this.knowledge = new Knowledge(this);\n\n // Initialize schema registry with all resource schemas\n this.schemas = new SchemaRegistry();\n this.schemas.register(knowledgeSchema);\n }\n}\n","/**\n * @tbox/sdk — KnowledgeClient\n *\n * Configuration-driven, multi-knowledge-base client.\n * Reuses the unified ClientOptions (token/baseURL/timeout) from core.ts.\n *\n * Supports multiple named knowledge bases via knowledges map in knowledge.json:\n * client.use(\"产品数据\").retrieve(\"查询文本\")\n * client.retrieve(\"产品数据\", \"查询文本\")\n */\n\nimport { TboxAPI } from './tbox-api';\nimport type { ClientOptions } from './core';\nimport type {\n DatasetListParams,\n DatasetListResult,\n RetrieveParams,\n RetrieveResult,\n DocumentCreateParams,\n DocumentCreateResult,\n DocumentUpdateParams,\n DocumentUpdateResult,\n TableSchema,\n} from './resources/knowledge/types';\n\n/** Allowed tool names that can be declared in knowledge.json */\nexport type KnowledgeTool = 'list' | 'retrieve' | 'create' | 'update';\n\n/** knowledge.json — config section: shared service parameters across all knowledge bases */\nexport interface KnowledgeServiceConfig {\n type?: 'STRUCTURED' | 'UNSTRUCTURED';\n topK?: number;\n scoreThreshold?: number;\n updateMode?: 'OVERWRITE' | 'UPSERT';\n pageSize?: number;\n}\n\n/** knowledge.json — per-knowledge-base instance config inside the knowledges map */\nexport interface KnowledgeInstanceConfig {\n datasetId?: string;\n documentId?: string;\n tableSchema?: TableSchema;\n indexColumns?: string[];\n /** Per-knowledge config overrides. Falls back to global config if not set. */\n config?: KnowledgeServiceConfig;\n}\n\n/** Merged runtime config (service defaults + instance config) */\nexport interface KnowledgeConfig extends KnowledgeServiceConfig, KnowledgeInstanceConfig {}\n\n/** Complete structure of knowledge.json — exported for external JSON validation */\nexport interface KnowledgeJsonSchema {\n config?: KnowledgeServiceConfig;\n tools?: KnowledgeTool[];\n knowledges?: Record<string, KnowledgeInstanceConfig>;\n}\n\n/** KnowledgeClient initialization options (extends ClientOptions) */\nexport interface KnowledgeClientOptions extends ClientOptions {\n /**\n * Knowledge config. Three input modes:\n * - String: path to knowledge.json file (Node.js only)\n * - Object: pass KnowledgeConfig directly (single knowledge base)\n * - Omitted: uses default empty config\n */\n config?: KnowledgeConfig | string;\n}\n\n/** Scoped handle returned by client.use(name), bound to a specific knowledge base */\nexport class KnowledgeScopedClient {\n /** Effective config: instance config > global config (merged at construction) */\n private effectiveConfig: KnowledgeServiceConfig;\n private currentDocumentId: string | undefined;\n\n constructor(\n private tbox: TboxAPI,\n globalConfig: KnowledgeServiceConfig,\n private instanceConfig: Readonly<KnowledgeInstanceConfig>,\n private allowedTools?: ReadonlySet<KnowledgeTool>,\n ) {\n const local = instanceConfig.config;\n this.effectiveConfig = {\n type: local?.type ?? globalConfig.type,\n topK: local?.topK ?? globalConfig.topK,\n scoreThreshold: local?.scoreThreshold ?? globalConfig.scoreThreshold,\n updateMode: local?.updateMode ?? globalConfig.updateMode,\n pageSize: local?.pageSize ?? globalConfig.pageSize,\n };\n this.currentDocumentId = instanceConfig.documentId;\n }\n\n /** Get the effective merged config for this knowledge base */\n getConfig(): Readonly<KnowledgeConfig> {\n return { ...this.effectiveConfig, ...this.instanceConfig, documentId: this.currentDocumentId };\n }\n\n /** Get the current documentId (may be auto-filled after create()) */\n getDocumentId(): string | undefined {\n return this.currentDocumentId;\n }\n\n /** Semantic retrieval against this knowledge base */\n async retrieve(\n query: string,\n options?: { topK?: number; scoreThreshold?: number },\n ): Promise<RetrieveResult> {\n this.assertToolAllowed('retrieve');\n\n const datasetId = this.instanceConfig.datasetId;\n if (!datasetId) {\n throw new Error('datasetId is not configured for this knowledge base.');\n }\n\n const params: RetrieveParams = {\n datasetId,\n query,\n topK: options?.topK ?? this.effectiveConfig.topK,\n scoreThreshold: options?.scoreThreshold ?? this.effectiveConfig.scoreThreshold,\n };\n\n return this.tbox.knowledge.retrieve(params);\n }\n\n /**\n * Create this knowledge base by uploading a file.\n *\n * Side effect: on success, the returned documentId is cached in this scoped client\n * so that subsequent update() calls can use it automatically.\n * The original instanceConfig is NOT mutated.\n */\n async create(\n file: Blob,\n options?: { type?: 'STRUCTURED' | 'UNSTRUCTURED'; tableSchema?: TableSchema; indexColumns?: string[] },\n ): Promise<DocumentCreateResult> {\n this.assertToolAllowed('create');\n\n const params: DocumentCreateParams = {\n file,\n type: options?.type ?? this.effectiveConfig.type ?? 'STRUCTURED',\n tableSchema: options?.tableSchema ?? this.instanceConfig.tableSchema,\n indexColumns: options?.indexColumns ?? this.instanceConfig.indexColumns,\n };\n\n const result = await this.tbox.knowledge.documents.create(params);\n\n if (result.documentId) {\n this.currentDocumentId = result.documentId;\n }\n\n return result;\n }\n\n /** Update this knowledge base document */\n async update(\n file: Blob,\n options?: { updateMode?: 'OVERWRITE' | 'UPSERT'; tableSchema?: TableSchema; indexColumns?: string[] },\n ): Promise<DocumentUpdateResult> {\n this.assertToolAllowed('update');\n\n const documentId = this.currentDocumentId;\n if (!documentId) {\n throw new Error('documentId is not configured. Call create() first or set it in knowledge.json.');\n }\n\n const params: DocumentUpdateParams = {\n documentId,\n file,\n type: this.effectiveConfig.type ?? 'STRUCTURED',\n updateMode: options?.updateMode ?? this.effectiveConfig.updateMode ?? 'UPSERT',\n tableSchema: options?.tableSchema ?? this.instanceConfig.tableSchema,\n indexColumns: options?.indexColumns ?? this.instanceConfig.indexColumns,\n };\n\n return this.tbox.knowledge.documents.update(params);\n }\n\n /** Throw if the tool is not in the allowed set (when tools are configured) */\n private assertToolAllowed(tool: KnowledgeTool): void {\n if (this.allowedTools && !this.allowedTools.has(tool)) {\n const allowed = Array.from(this.allowedTools).join(', ');\n throw new Error(`Tool \"${tool}\" is not allowed. Configured tools: [${allowed}]`);\n }\n }\n}\n\n/**\n * Configuration-driven, multi-knowledge-base client.\n *\n * Usage patterns:\n * // Scoped: bind to a named knowledge base, then call methods\n * const product = client.use(\"产品数据\");\n * await product.retrieve(\"查询文本\");\n *\n * // Direct: pass name as first arg\n * await client.retrieve(\"产品数据\", \"查询文本\");\n *\n * // List: shared across all knowledge bases\n * await client.list(\"搜索关键词\");\n */\nexport class KnowledgeClient {\n private tbox: TboxAPI;\n private serviceConfig: KnowledgeServiceConfig;\n private knowledges: Map<string, KnowledgeInstanceConfig>;\n private allowedTools?: ReadonlySet<KnowledgeTool>;\n\n constructor(options: KnowledgeClientOptions) {\n const { config, ...clientOptions } = options;\n this.tbox = new TboxAPI(clientOptions);\n this.serviceConfig = {};\n this.knowledges = new Map();\n this.resolveConfig(config);\n }\n\n /** Create from an existing TboxAPI instance */\n static fromTboxAPI(tbox: TboxAPI, config?: KnowledgeConfig | string): KnowledgeClient {\n const instance = Object.create(KnowledgeClient.prototype) as KnowledgeClient;\n instance.tbox = tbox;\n instance.serviceConfig = {};\n instance.knowledges = new Map();\n instance.resolveConfig(config);\n return instance;\n }\n\n /**\n * Load config from a knowledge.json file asynchronously (ESM-compatible).\n * Use this in ESM environments instead of passing a file path to the constructor.\n */\n static async fromFile(options: Omit<KnowledgeClientOptions, 'config'>, filePath: string): Promise<KnowledgeClient> {\n const client = new KnowledgeClient(options);\n await client.loadConfigFromFileAsync(filePath);\n return client;\n }\n\n /** Resolve config from object, file path, or default */\n private resolveConfig(config?: KnowledgeConfig | string): void {\n if (!config) {\n this.serviceConfig = { type: 'STRUCTURED' };\n return;\n }\n\n if (typeof config === 'string') {\n this.loadConfigFromFileSync(config);\n return;\n }\n\n // Single knowledge config passed as object — store as \"default\"\n this.serviceConfig = {\n type: config.type,\n topK: config.topK,\n scoreThreshold: config.scoreThreshold,\n updateMode: config.updateMode,\n pageSize: config.pageSize,\n };\n this.knowledges.set('default', {\n datasetId: config.datasetId,\n documentId: config.documentId,\n tableSchema: config.tableSchema,\n indexColumns: config.indexColumns,\n });\n }\n\n /** Apply parsed JSON schema to this client */\n private applyJsonSchema(parsed: KnowledgeJsonSchema): void {\n this.serviceConfig = parsed.config ?? { type: 'STRUCTURED' };\n\n if (parsed.tools && parsed.tools.length > 0) {\n this.allowedTools = new Set(parsed.tools);\n }\n\n if (parsed.knowledges) {\n for (const [name, instanceConfig] of Object.entries(parsed.knowledges)) {\n this.knowledges.set(name, { ...instanceConfig });\n }\n }\n }\n\n /** Load config from knowledge.json file synchronously (CJS environments) */\n private loadConfigFromFileSync(filePath: string): void {\n try {\n // eslint-disable-next-line @typescript-eslint/no-implied-eval -- dynamic require for CJS compat\n const dynamicRequire = new Function('id', 'return require(id)') as (id: string) => unknown;\n const fs = dynamicRequire('fs') as { readFileSync: (path: string, encoding: string) => string };\n const raw = fs.readFileSync(filePath, 'utf-8');\n const parsed = JSON.parse(raw) as KnowledgeJsonSchema;\n this.applyJsonSchema(parsed);\n } catch (error) {\n throw new Error(\n `Failed to load knowledge config from \"${filePath}\": ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n\n /** Load config from knowledge.json file asynchronously (ESM-compatible) */\n private async loadConfigFromFileAsync(filePath: string): Promise<void> {\n try {\n // Dynamic import avoids bundler static analysis and works in both CJS and ESM\n const fsModule = await (Function('return import(\"node:fs/promises\")')() as Promise<{ readFile: (path: string, encoding: string) => Promise<string> }>);\n const raw = await fsModule.readFile(filePath, 'utf-8');\n const parsed = JSON.parse(raw) as KnowledgeJsonSchema;\n this.applyJsonSchema(parsed);\n } catch (error) {\n throw new Error(\n `Failed to load knowledge config from \"${filePath}\": ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n\n /** Get all registered knowledge base names */\n names(): string[] {\n return Array.from(this.knowledges.keys());\n }\n\n /** Get the allowed tools set (undefined means all tools are allowed) */\n getAllowedTools(): ReadonlySet<KnowledgeTool> | undefined {\n return this.allowedTools;\n }\n\n /** Get the shared service config */\n getServiceConfig(): Readonly<KnowledgeServiceConfig> {\n return { ...this.serviceConfig };\n }\n\n /** Get instance config for a named knowledge base */\n getInstanceConfig(name: string): Readonly<KnowledgeInstanceConfig> | undefined {\n const config = this.knowledges.get(name);\n return config ? { ...config } : undefined;\n }\n\n /**\n * Get a scoped client bound to a named knowledge base.\n * All subsequent calls on the returned handle use that knowledge base's config.\n */\n use(name: string): KnowledgeScopedClient {\n const instanceConfig = this.knowledges.get(name);\n if (!instanceConfig) {\n const available = this.names().join(', ');\n throw new Error(\n `Knowledge base \"${name}\" not found. Available: [${available}]`,\n );\n }\n\n return new KnowledgeScopedClient(this.tbox, this.serviceConfig, instanceConfig, this.allowedTools);\n }\n\n /** Query knowledge base list (shared, not scoped to a specific knowledge base) */\n async list(name?: string, pageNo?: number, pageSize?: number): Promise<DatasetListResult> {\n this.assertToolAllowed('list');\n\n const params: DatasetListParams = {};\n if (name !== undefined) params.name = name;\n if (pageNo !== undefined) params.pageNo = pageNo;\n params.pageSize = pageSize ?? this.serviceConfig.pageSize;\n\n return this.tbox.knowledge.list(params);\n }\n\n /** Semantic retrieval — pass knowledge base name as first arg to route */\n async retrieve(\n knowledgeName: string,\n query: string,\n options?: { topK?: number; scoreThreshold?: number },\n ): Promise<RetrieveResult> {\n return this.use(knowledgeName).retrieve(query, options);\n }\n\n /** Create a knowledge base by name */\n async create(\n knowledgeName: string,\n file: Blob,\n options?: { type?: 'STRUCTURED' | 'UNSTRUCTURED'; tableSchema?: TableSchema; indexColumns?: string[] },\n ): Promise<DocumentCreateResult> {\n return this.use(knowledgeName).create(file, options);\n }\n\n /** Update a knowledge base by name */\n async update(\n knowledgeName: string,\n file: Blob,\n options?: { updateMode?: 'OVERWRITE' | 'UPSERT'; tableSchema?: TableSchema; indexColumns?: string[] },\n ): Promise<DocumentUpdateResult> {\n return this.use(knowledgeName).update(file, options);\n }\n\n /** Throw if the tool is not in the allowed set (when tools are configured) */\n private assertToolAllowed(tool: KnowledgeTool): void {\n if (this.allowedTools && !this.allowedTools.has(tool)) {\n const allowed = Array.from(this.allowedTools).join(', ');\n throw new Error(`Tool \"${tool}\" is not allowed. Configured tools: [${allowed}]`);\n }\n }\n}\n","/**\n * 百宝箱插件服务 SDK - 底层 HTTP 请求封装\n */\n\nimport type { SdkResponse } from './types';\n\n/** 默认调用域名 */\nexport const DEFAULT_BASE_URL = 'https://o.tbox.cn';\n\n/** 内部 HTTP 客户端配置 */\nexport interface HttpClientConfig {\n baseUrl: string;\n apiKey: string;\n timeout?: number;\n}\n\n/**\n * 服务端返回的原始响应结构(APIServiceResult)\n * 兼容多种字段命名风格:\n * - errorCode / errorMsg(标准)\n * - code / msg(网关层)\n * - resultCode / resultDesc(部分旧接口)\n */\ninterface RawApiResponse<T> {\n success?: boolean;\n /** 标准错误码 */\n errorCode?: string;\n /** 标准错误信息 */\n errorMsg?: string;\n /** 网关层错误码(兼容) */\n code?: string;\n /** 网关层错误信息(兼容) */\n msg?: string;\n /** 旧接口错误码(兼容) */\n resultCode?: string;\n /** 旧接口错误信息(兼容) */\n resultDesc?: string;\n data?: T;\n /** 部分接口用 resultObj */\n resultObj?: T;\n /** 部分接口用 result(如 generate_session) */\n result?: T;\n}\n\n/**\n * 将服务端原始响应统一转换为 SdkResponse\n */\nfunction normalizeResponse<T>(raw: RawApiResponse<T>): SdkResponse<T> {\n const success = raw.success !== false;\n const data = raw.data ?? raw.resultObj ?? raw.result;\n // 按优先级兼容多种错误码字段\n const errorCode = raw.errorCode ?? raw.code ?? raw.resultCode;\n const errorMsg = raw.errorMsg ?? raw.msg ?? raw.resultDesc;\n\n if (success) {\n return { success: true, data };\n }\n return { success: false, errorCode, errorMsg };\n}\n\n/**\n * 底层 HTTP 客户端\n */\nexport class HttpClient {\n private readonly baseUrl: string;\n private readonly apiKey: string;\n private readonly timeout?: number;\n\n constructor(config: HttpClientConfig) {\n this.baseUrl = config.baseUrl.replace(/\\/$/, '');\n this.apiKey = config.apiKey;\n this.timeout = config.timeout;\n }\n\n /** 构建通用请求头 */\n private buildHeaders(extra?: Record<string, string>): Record<string, string> {\n return {\n 'Content-Type': 'application/json;charset=UTF-8',\n Authorization: this.apiKey,\n ...extra,\n };\n }\n\n /** 构建 FormData 请求头(不设置 Content-Type,让浏览器自动处理 boundary) */\n private buildHeadersForFormData(extra?: Record<string, string>): Record<string, string> {\n return {\n Authorization: this.apiKey,\n ...extra,\n };\n }\n\n /** 发起 fetch,支持可选超时 */\n private async fetchWithTimeout(\n url: string,\n init: RequestInit,\n ): Promise<Response> {\n if (!this.timeout) {\n return fetch(url, init);\n }\n\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), this.timeout);\n try {\n return await fetch(url, { ...init, signal: controller.signal });\n } finally {\n clearTimeout(timer);\n }\n }\n\n /**\n * POST 请求\n */\n async post<T>(\n path: string,\n body: unknown,\n queryParams?: Record<string, string>,\n ): Promise<SdkResponse<T>> {\n const url = this.buildUrl(path, queryParams);\n let response: Response;\n try {\n response = await this.fetchWithTimeout(url, {\n method: 'POST',\n headers: this.buildHeaders(),\n body: JSON.stringify(body),\n });\n } catch (err) {\n return {\n success: false,\n errorCode: 'NETWORK_ERROR',\n errorMsg: err instanceof Error ? err.message : String(err),\n };\n }\n\n return this.parseResponse<T>(response);\n }\n\n /**\n * POST FormData 请求(用于文件上传)\n */\n async postFormData<T>(\n path: string,\n formData: FormData,\n queryParams?: Record<string, string>,\n ): Promise<SdkResponse<T>> {\n const url = this.buildUrl(path, queryParams);\n let response: Response;\n try {\n // FormData 请求不设置 Content-Type,让浏览器自动设置 multipart/form-data 边界\n response = await this.fetchWithTimeout(url, {\n method: 'POST',\n headers: this.buildHeadersForFormData(),\n body: formData,\n });\n } catch (err) {\n return {\n success: false,\n errorCode: 'NETWORK_ERROR',\n errorMsg: err instanceof Error ? err.message : String(err),\n };\n }\n\n return this.parseResponse<T>(response);\n }\n\n /**\n * GET 请求\n */\n async get<T>(\n path: string,\n queryParams?: Record<string, string>,\n ): Promise<SdkResponse<T>> {\n const url = this.buildUrl(path, queryParams);\n let response: Response;\n try {\n response = await this.fetchWithTimeout(url, {\n method: 'GET',\n headers: this.buildHeaders(),\n });\n } catch (err) {\n return {\n success: false,\n errorCode: 'NETWORK_ERROR',\n errorMsg: err instanceof Error ? err.message : String(err),\n };\n }\n\n return this.parseResponse<T>(response);\n }\n\n /** 构建完整 URL(含 query string) */\n private buildUrl(path: string, queryParams?: Record<string, string>): string {\n // 如果 path 已经是完整 URL(以 http:// 或 https:// 开头),直接使用\n let base: string;\n if (path.startsWith('http://') || path.startsWith('https://')) {\n base = path;\n } else {\n base = `${this.baseUrl}${path}`;\n }\n\n if (!queryParams || Object.keys(queryParams).length === 0) {\n return base;\n }\n const qs = new URLSearchParams(queryParams).toString();\n return `${base}?${qs}`;\n }\n\n /** 解析响应体 */\n private async parseResponse<T>(response: Response): Promise<SdkResponse<T>> {\n if (!response.ok) {\n return {\n success: false,\n errorCode: `HTTP_${response.status}`,\n errorMsg: `HTTP error: ${response.status} ${response.statusText}`,\n };\n }\n\n let json: RawApiResponse<T>;\n try {\n // 使用 arrayBuffer + TextDecoder 确保多字节 UTF-8 字符(如中文)正确解码\n const buffer = await response.arrayBuffer();\n const text = new TextDecoder('utf-8').decode(buffer);\n json = JSON.parse(text) as RawApiResponse<T>;\n } catch {\n return {\n success: false,\n errorCode: 'PARSE_ERROR',\n errorMsg: 'Failed to parse response JSON',\n };\n }\n\n return normalizeResponse(json);\n }\n}\n","/**\n * 百宝箱插件服务 SDK - PluginClient 核心类\n *\n * 封装 /openapi/v1/plugin 下的全部接口\n */\n\nimport { HttpClient, DEFAULT_BASE_URL } from './http';\nimport type {\n TboxPluginClientConfig,\n TtsRequest,\n TtsResponse,\n AsrRequest,\n AsrResponse,\n PluginToolExecRequest,\n PluginExecResult,\n PluginInfo,\n WebSearchRequest,\n WebSearchResponse,\n WebSearchItem,\n SdkResponse,\n} from './types';\n\n/** API 路径前缀 */\nconst API_PREFIX = '/openapi/v1/plugin';\n\n/**\n * 百宝箱插件服务客户端\n *\n * @example\n * ```ts\n * import { TboxPluginClient } from '@tbox/plugin-sdk';\n *\n * const client = new TboxPluginClient({ apiKey: 'your-api-key' });\n *\n * // 执行插件工具\n * const result = await client.run('tool-id-xxx', { params: { key: 'value' } });\n * ```\n */\nexport class TboxPluginClient {\n private readonly http: HttpClient;\n\n constructor(config: TboxPluginClientConfig) {\n this.http = new HttpClient({\n baseUrl: config.baseUrl ?? DEFAULT_BASE_URL,\n apiKey: config.apiKey,\n timeout: config.timeout,\n });\n }\n\n // ============================================================\n // TTS - 文字转语音\n // ============================================================\n\n /**\n * 文字转语音\n *\n * POST /openapi/v1/plugin/doTts\n *\n * @param request - TTS 请求参数\n * @returns 音频数据(Base64 或 URL)\n *\n * @example\n * ```ts\n * const res = await client.doTts({ text: '你好,世界' });\n * if (res.success) {\n * console.log(res.data?.audioBase64);\n * }\n * ```\n */\n async doTts(request: TtsRequest): Promise<SdkResponse<TtsResponse>> {\n return this.http.post<TtsResponse>(`${API_PREFIX}/doTts`, request);\n }\n\n // ============================================================\n // ASR - 语音转文字\n // ============================================================\n\n /**\n * 语音转文字(Base64 音频输入)\n *\n * POST /openapi/v1/plugin/asrBase64V2\n *\n * @param request - ASR 请求参数,音频以 Base64 格式传入\n * @returns 识别出的文本\n *\n * @example\n * ```ts\n * const res = await client.asrBase64({ audioBase64: '<base64-string>', format: 'mp3' });\n * if (res.success) {\n * console.log(res.data?.text);\n * }\n * ```\n */\n async asrBase64(request: AsrRequest): Promise<SdkResponse<AsrResponse>> {\n return this.http.post<AsrResponse>(`${API_PREFIX}/asrBase64V2`, request);\n }\n\n // ============================================================\n // 插件工具执行\n // ============================================================\n\n /**\n * 按工具 ID 执行插件工具\n *\n * POST /openapi/v1/plugin/run/{pluginToolId}\n *\n * 适用于已知工具 ID 的场景,调用更直接、性能更好。\n *\n * @param pluginToolId - 插件工具 ID\n * @param request - 工具执行请求(含输入参数)\n * @returns 工具执行结果\n *\n * @example\n * ```ts\n * const res = await client.run('tool-id-xxx', {\n * inputs: { city: '杭州' },\n * });\n * if (res.success) {\n * console.log(res.data?.output);\n * }\n * ```\n */\n async run(\n pluginToolId: string,\n request: PluginToolExecRequest,\n ): Promise<SdkResponse<PluginExecResult>> {\n return this.http.post<PluginExecResult>(\n `${API_PREFIX}/run/${encodeURIComponent(pluginToolId)}`,\n request,\n );\n }\n\n // ============================================================\n // 插件信息查询\n // ============================================================\n\n /**\n * 查询插件配置信息(含工具集)\n *\n * GET /openapi/v1/plugin/info/{pluginId}\n *\n * @param pluginId - 插件 ID\n * @returns 插件信息,包含插件名称、描述及工具列表\n *\n * @example\n * ```ts\n * const res = await client.getPluginInfo('plugin-id');\n * if (res.success) {\n * console.log(res.data?.pluginToolList);\n * }\n * ```\n */\n async getPluginInfo(pluginId: string): Promise<SdkResponse<PluginInfo>> {\n return this.http.get<PluginInfo>(\n `${API_PREFIX}/info/${encodeURIComponent(pluginId)}`,\n );\n }\n\n // ============================================================\n // 网络搜索\n // ============================================================\n\n /** 网络搜索工具的固定工具 ID */\n private static readonly WEB_SEARCH_TOOL_ID = '20240611204600000001';\n\n /**\n * 网络搜索\n *\n * 内部调用 run('20240611204600000001', ...) 实现,对外屏蔽工具 ID 细节。\n * 服务端响应层级:result.result.result.data[],SDK 自动解包为扁平的 items 列表。\n *\n * @param request - 搜索请求,包含关键词 q\n * @returns 搜索结果列表\n *\n * @example\n * ```ts\n * const res = await client.webSearch({ q: '上海今天天气' });\n * if (res.success) {\n * for (const item of res.data?.items ?? []) {\n * console.log(item.title, item.url);\n * }\n * }\n * ```\n */\n async webSearch(request: WebSearchRequest): Promise<SdkResponse<WebSearchResponse>> {\n // 按服务端约定,搜索关键词放在 params.q\n const raw = await this.run(TboxPluginClient.WEB_SEARCH_TOOL_ID, {\n params: { q: request.q },\n });\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n // 深层解包:raw.data → result.data[]\n // 服务端实际结构:{ cost, result: { data: [...], success, message } }\n const inner = (raw.data as Record<string, unknown> | undefined);\n const level1 = inner?.['result'] as Record<string, unknown> | undefined;\n const dataArr = level1?.['data'];\n\n const items: WebSearchItem[] = Array.isArray(dataArr)\n ? (dataArr as WebSearchItem[])\n : [];\n\n return {\n success: true,\n data: { items },\n };\n }\n\n}\n","/**\n * 百宝箱会话管理 SDK - ConversationClient 核心类\n *\n * 封装 /openapi/v1/conversation 下的全部接口\n */\n\nimport { HttpClient, DEFAULT_BASE_URL } from './http';\nimport type {\n TboxPluginClientConfig,\n MessageQueryRequest,\n MessageInfo,\n ConversationQueryRequest,\n ConversationInfo,\n ConversationCreateRequest,\n MessageSaveRequest,\n PaginationResult,\n SdkResponse,\n} from './types';\n\n/** API 路径前缀 */\nconst API_PREFIX = '/openapi/v1/conversation';\n\n/**\n * 百宝箱会话管理客户端\n *\n * @example\n * ```ts\n * import { TboxConversationClient } from '@tbox/plugin-sdk';\n *\n * const client = new TboxConversationClient({ apiKey: 'your-api-key' });\n *\n * // 创建新会话\n * const res = await client.createConversation({ agentId: 'app-id', userId: 'user-id' });\n * if (res.success) {\n * console.log('会话 ID:', res.data);\n * }\n * ```\n */\nexport class TboxConversationClient {\n private readonly http: HttpClient;\n\n constructor(config: TboxPluginClientConfig) {\n this.http = new HttpClient({\n baseUrl: config.baseUrl ?? DEFAULT_BASE_URL,\n apiKey: config.apiKey,\n timeout: config.timeout,\n });\n }\n\n // ============================================================\n // 会话管理\n // ============================================================\n\n /**\n * 创建新会话\n *\n * POST /openapi/v1/conversation/create\n *\n * @param request - 创建会话请求,包含 agentId 和 userId\n * @returns 新会话 ID(字符串)\n *\n * @example\n * ```ts\n * const res = await client.createConversation({\n * agentId: 'your-app-id',\n * userId: 'user-123',\n * });\n * if (res.success) {\n * const conversationId = res.data;\n * }\n * ```\n */\n async createConversation(\n request: ConversationCreateRequest,\n ): Promise<SdkResponse<string>> {\n return this.http.post<string>(`${API_PREFIX}/create`, request);\n }\n\n /**\n * 查询会话列表(分页)\n *\n * POST /openapi/v1/conversation/list\n *\n * @param request - 查询请求,支持按 agentId、userId 过滤,支持分页\n * @returns 分页会话列表\n *\n * @example\n * ```ts\n * const res = await client.listConversations({\n * agentId: 'your-app-id',\n * userId: 'user-123',\n * pageNum: 1,\n * pageSize: 20,\n * });\n * if (res.success) {\n * console.log(res.data?.list);\n * }\n * ```\n */\n async listConversations(\n request: ConversationQueryRequest,\n ): Promise<SdkResponse<PaginationResult<ConversationInfo>>> {\n return this.http.post<PaginationResult<ConversationInfo>>(\n `${API_PREFIX}/list`,\n request,\n );\n }\n\n // ============================================================\n // 消息管理\n // ============================================================\n\n /**\n * 查询消息列表(分页)\n *\n * POST /openapi/v1/conversation/message/list\n *\n * @param request - 查询请求,支持按 conversationId、agentId、userId 过滤,支持分页\n * @returns 分页消息列表\n *\n * @example\n * ```ts\n * const res = await client.listMessages({\n * conversationId: 'conv-id-xxx',\n * pageNum: 1,\n * pageSize: 20,\n * });\n * if (res.success) {\n * console.log(res.data?.list);\n * }\n * ```\n */\n async listMessages(\n request: MessageQueryRequest,\n ): Promise<SdkResponse<PaginationResult<MessageInfo>>> {\n return this.http.post<PaginationResult<MessageInfo>>(\n `${API_PREFIX}/message/list`,\n request,\n );\n }\n\n /**\n * 新增会话消息\n *\n * POST /openapi/v1/conversation/message/save\n *\n * 将一条对话消息(问题 + 回答)保存到指定会话中。\n *\n * @param request - 保存消息请求\n * @returns 消息 ID(字符串)\n *\n * @example\n * ```ts\n * const res = await client.saveMessage({\n * conversationId: 'conv-id-xxx',\n * query: '今天天气怎么样?',\n * answer: '今天杭州晴天,25°C。',\n * });\n * if (res.success) {\n * const messageId = res.data;\n * }\n * ```\n */\n async saveMessage(\n request: MessageSaveRequest,\n ): Promise<SdkResponse<string>> {\n return this.http.post<string>(`${API_PREFIX}/message/save`, request);\n }\n}\n","/**\n * 百宝箱插件服务 SDK - 应用服务客户端\n *\n * 封装 /openapi/v1/app 下的接口\n */\n\nimport { HttpClient, DEFAULT_BASE_URL } from './http';\nimport type { SdkResponse, AppGenerateSessionRequest, AppSessionResult, TboxPluginClientConfig } from './types';\n\n/**\n * 百宝箱应用服务客户端\n *\n * @example\n * ```ts\n * const client = new TboxAppClient({ apiKey: 'your-api-key' });\n *\n * // 生成 sessionId,用于免登录访问百宝箱应用\n * const result = await client.generateSession({\n * appId: 'your-app-id',\n * userId: 'user-123',\n * userInfo: [\n * { infoType: 'name', infoValue: '张三' },\n * ],\n * deviceInfo: {\n * platform: 'IOS',\n * appVersion: '1.0.0',\n * },\n * });\n *\n * if (result.success) {\n * console.log('sessionId:', result.data?.sessionId);\n * console.log('channel:', result.data?.channel);\n * }\n * ```\n */\nexport class TboxAppClient {\n private readonly http: HttpClient;\n\n constructor(config: TboxPluginClientConfig) {\n this.http = new HttpClient({\n baseUrl: config.baseUrl ?? DEFAULT_BASE_URL,\n apiKey: config.apiKey,\n timeout: config.timeout,\n });\n }\n\n /**\n * 根据用户信息生成 sessionId 和 channel\n *\n * 接口:POST /openapi/v1/app/generate_session\n *\n * 生成的 sessionId 可用于拼接百宝箱 H5 访问链接,实现免登录跳转。\n *\n * @param request 请求参数,appId 和 userId 为必填\n * @returns sessionId 和 channel\n */\n async generateSession(\n request: AppGenerateSessionRequest,\n ): Promise<SdkResponse<AppSessionResult>> {\n return this.http.post<AppSessionResult>(\n '/openapi/v1/app/generate_session',\n request,\n );\n }\n}\n","/**\n * 高德地图 SDK - AmapClient 核心类\n *\n * 封装高德地图天气查询工具(amap_weather),\n * 通过百宝箱插件服务 /openapi/v1/plugin/run/{pluginToolId} 接口调用。\n */\n\nimport { HttpClient, DEFAULT_BASE_URL } from './http';\nimport type {\n AmapClientConfig,\n AmapConvertRequest,\n AmapConvertResponse,\n AmapCyclingRouteRequest,\n AmapCyclingRouteResponse,\n AmapDistrictRequest,\n AmapDistrictResponse,\n AmapDrivingRouteRequest,\n AmapDrivingRouteResponse,\n AmapEbikeRouteRequest,\n AmapEbikeRouteResponse,\n AmapGeocodeRequest,\n AmapGeocodeResponse,\n AmapIpLocationRequest,\n AmapIpLocationResponse,\n AmapPeripheralSearchRequest,\n AmapPeripheralSearchResponse,\n AmapPoiSearchRequest,\n AmapPoiSearchResponse,\n AmapRegeocodeRequest,\n AmapRegeocodeResponse,\n AmapTransitRouteRequest,\n AmapTransitRouteResponse,\n AmapWalkingRouteRequest,\n AmapWalkingRouteResponse,\n AmapWeatherRequest,\n AmapWeatherResponse,\n PluginExecResult,\n SdkResponse,\n} from './types';\n\n/** API 路径前缀 */\nconst API_PREFIX = '/openapi/v1/plugin';\n\n/**\n * 高德地图客户端\n *\n * @example\n * ```ts\n * import { AmapClient } from '@tbox/plugin-sdk';\n *\n * const client = new AmapClient({ apiKey: 'your-api-key' });\n *\n * // 查询实况天气\n * const res = await client.weather({ city: '杭州市' });\n * if (res.success) {\n * console.log(res.data?.lives?.[0]?.weather);\n * }\n *\n * // 查询预报天气\n * const forecast = await client.weather({ city: '上海市', extensions: 'all' });\n * if (forecast.success) {\n * console.log(forecast.data?.forecasts?.[0]?.casts);\n * }\n * ```\n */\nexport class AmapClient {\n private readonly http: HttpClient;\n\n /** 高德天气查询工具的固定工具 ID */\n private static readonly AMAP_WEATHER_TOOL_ID = '20240627231800002183';\n\n /** 高德地址转经纬度工具的固定工具 ID */\n private static readonly AMAP_GEOCODE_TOOL_ID = '20240627233200002185';\n\n /** 高德骑行路线规划工具的固定工具 ID */\n private static readonly AMAP_CYCLING_ROUTE_TOOL_ID = '20240627233900002186';\n\n /** 高德 IP 定位工具的固定工具 ID */\n private static readonly AMAP_IP_LOCATION_TOOL_ID = '20240627235900002187';\n\n /** 高德周边搜索工具的固定工具 ID */\n private static readonly AMAP_PERIPHERAL_SEARCH_TOOL_ID = '20240628000200002188';\n\n /** 高德步行路线规划工具的固定工具 ID */\n private static readonly AMAP_WALKING_ROUTE_TOOL_ID = '20240628000400002189';\n\n /** 高德驾车路线规划工具的固定工具 ID */\n private static readonly AMAP_DRIVING_ROUTE_TOOL_ID = '20240628000900002190';\n\n /** 高德电动车路线规划工具的固定工具 ID */\n private static readonly AMAP_EBIKE_ROUTE_TOOL_ID = '20240628001000002191';\n\n /** 高德公交路线规划工具的固定工具 ID */\n private static readonly AMAP_TRANSIT_ROUTE_TOOL_ID = '20240628001100002192';\n\n /** 高德行政区域查询工具的固定工具 ID */\n private static readonly AMAP_DISTRICT_TOOL_ID = '20240628001200002193';\n\n /** 高德经纬度转地址工具的固定工具 ID */\n private static readonly AMAP_REGEOCODE_TOOL_ID = '20240629202400006671';\n\n /** 高德坐标转换工具的固定工具 ID */\n private static readonly AMAP_CONVERT_TOOL_ID = '20251110ArTR04496110';\n\n /** 高德 POI 关键字搜索工具的固定工具 ID */\n private static readonly AMAP_POI_SEARCH_TOOL_ID = '20251110crvO04497983';\n\n constructor(config: AmapClientConfig) {\n this.http = new HttpClient({\n baseUrl: config.baseUrl ?? DEFAULT_BASE_URL,\n apiKey: config.apiKey,\n timeout: config.timeout,\n });\n }\n\n // ============================================================\n // 天气查询\n // ============================================================\n\n /**\n * 查询天气(实况或预报)\n *\n * 内部调用 run('20240627231800002183', ...) 实现,对外屏蔽工具 ID 细节。\n * 数据来源于中国气象局。\n *\n * @param request - 天气查询请求\n * - `city`(必填):省份名、市名、区/县/镇、乡/村或具体地点\n * - `extensions`(可选):`base`(实况,默认)或 `all`(预报)\n * @returns 天气查询结果\n * - `extensions=base` 时,`data.lives` 包含实况天气数据\n * - `extensions=all` 时,`data.forecasts` 包含逐日预报数据\n *\n * @example\n * ```ts\n * // 查询实况天气\n * const live = await client.weather({ city: '西湖区' });\n * if (live.success) {\n * const w = live.data?.lives?.[0];\n * console.log(`${w?.city} ${w?.weather} ${w?.temperature}℃`);\n * }\n *\n * // 查询未来几天预报\n * const forecast = await client.weather({ city: '北京市', extensions: 'all' });\n * if (forecast.success) {\n * for (const cast of forecast.data?.forecasts?.[0]?.casts ?? []) {\n * console.log(`${cast.date} 白天:${cast.dayweather} 夜间:${cast.nightweather}`);\n * }\n * }\n * ```\n */\n async weather(request: AmapWeatherRequest): Promise<SdkResponse<AmapWeatherResponse>> {\n const params: Record<string, unknown> = { city: request.city };\n if (request.extensions !== undefined) {\n params['extensions'] = request.extensions;\n }\n\n const raw = await this.http.post<PluginExecResult>(\n `${API_PREFIX}/run/${encodeURIComponent(AmapClient.AMAP_WEATHER_TOOL_ID)}`,\n { params },\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n // 从 raw.data.result 中解包天气数据\n // 服务端实际结构:{ success, result: { status, info, infocode, count, lives?, forecasts? }, cost, traceId }\n const execResult = raw.data as PluginExecResult | undefined;\n const weatherData = execResult?.result as AmapWeatherResponse | undefined;\n\n return {\n success: true,\n data: weatherData ?? {},\n };\n }\n\n // ============================================================\n // 地址转经纬度\n // ============================================================\n\n /**\n * 地址转经纬度(地理编码)\n *\n * 将详细的地名,转换为经纬度坐标。\n * 内部调用 run('20240627233200002185', ...) 实现,对外屏蔽工具 ID 细节。\n *\n * @param request - 地址转经纬度请求\n * - `address`(必填):详细地址信息(国家、省份、城市、区县、城镇、乡村、街道、门牌号)\n * - `city`(可选):查询的城市,指定可提高查询精度\n * @returns 地理编码结果\n * - `data.geocodes` 包含地理编码信息列表\n *\n * @example\n * ```ts\n * // 地址转经纬度\n * const res = await client.geocode({ address: '北京市朝阳区阜通东大街6号', city: '北京' });\n * if (res.success) {\n * const geo = res.data?.geocodes?.[0];\n * console.log(`地址: ${geo?.formatted_address}`);\n * console.log(`经纬度: ${geo?.location}`);\n * console.log(`区域编码: ${geo?.adcode}`);\n * }\n * ```\n */\n async geocode(request: AmapGeocodeRequest): Promise<SdkResponse<AmapGeocodeResponse>> {\n const params: Record<string, unknown> = { address: request.address };\n if (request.city !== undefined) {\n params['city'] = request.city;\n }\n\n const raw = await this.http.post<PluginExecResult>(\n `${API_PREFIX}/run/${encodeURIComponent(AmapClient.AMAP_GEOCODE_TOOL_ID)}`,\n { params },\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n // 从 raw.data.result 中解包地理编码数据\n // 服务端实际结构:{ success, result: { code, status, infocode, count, geocodes? }, cost, traceId }\n const execResult = raw.data as PluginExecResult | undefined;\n const geocodeData = execResult?.result as AmapGeocodeResponse | undefined;\n\n return {\n success: true,\n data: geocodeData ?? {},\n };\n }\n\n // ============================================================\n // 骑行路线规划\n // ============================================================\n\n /**\n * 骑行路线规划\n *\n * 提供起点和终点的位置,返回骑行路线,支持多条路线。\n *\n * @param request - 骑行路线规划请求\n * - `origin`(必填):起点位置名称\n * - `destination`(必填):终点位置名称\n * @returns 骑行路线规划结果\n *\n * @example\n * ```ts\n * const res = await client.cyclingRoute({\n * origin: '杭州市西湖区',\n * destination: '杭州市余杭区'\n * });\n * if (res.success) {\n * const path = res.data?.route?.paths?.[0];\n * console.log(`距离: ${path?.distance}米, 时间: ${path?.duration}秒`);\n * }\n * ```\n */\n async cyclingRoute(\n request: AmapCyclingRouteRequest,\n ): Promise<SdkResponse<AmapCyclingRouteResponse>> {\n const params: Record<string, unknown> = {\n origin: request.origin,\n destination: request.destination,\n };\n\n const raw = await this.http.post<PluginExecResult>(\n `${API_PREFIX}/run/${encodeURIComponent(AmapClient.AMAP_CYCLING_ROUTE_TOOL_ID)}`,\n { params },\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n const execResult = raw.data as PluginExecResult | undefined;\n const routeData = execResult?.result as AmapCyclingRouteResponse | undefined;\n\n return {\n success: true,\n data: routeData ?? {},\n };\n }\n\n // ============================================================\n // IP 定位\n // ============================================================\n\n /**\n * IP 定位\n *\n * 定位输入的 IP 所在的地理位置(暂不支持 IPv6)。\n *\n * @param request - IP 定位请求\n * - `ip`(必填):需要定位的 IP 地址\n * @returns IP 定位结果\n *\n * @example\n * ```ts\n * const res = await client.ipLocation({ ip: '114.114.114.114' });\n * if (res.success) {\n * console.log(`省份: ${res.data?.province}, 城市: ${res.data?.city}`);\n * }\n * ```\n */\n async ipLocation(request: AmapIpLocationRequest): Promise<SdkResponse<AmapIpLocationResponse>> {\n const params: Record<string, unknown> = { ip: request.ip };\n\n const raw = await this.http.post<PluginExecResult>(\n `${API_PREFIX}/run/${encodeURIComponent(AmapClient.AMAP_IP_LOCATION_TOOL_ID)}`,\n { params },\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n const execResult = raw.data as PluginExecResult | undefined;\n const locationData = execResult?.result as AmapIpLocationResponse | undefined;\n\n return {\n success: true,\n data: locationData ?? {},\n };\n }\n\n // ============================================================\n // 周边搜索\n // ============================================================\n\n /**\n * 周边搜索\n *\n * 根据指定地点和关键词,搜索周边景点、美食、酒店、运动场所等。\n *\n * @param request - 周边搜索请求\n * - `address`(必填):中心点地址信息\n * - `keyword`(必填):检索关键词(景点、美食、游玩区域等,不超过 80 字符)\n * - `count`(可选):返回条数,默认 5\n * - `radius`(可选):搜索半径(米),范围 0-50000\n * @returns 周边搜索结果\n *\n * @example\n * ```ts\n * const res = await client.peripheralSearch({\n * address: '杭州市西湖区',\n * keyword: '美食',\n * count: 10,\n * radius: 1000\n * });\n * if (res.success) {\n * for (const poi of res.data?.pois ?? []) {\n * console.log(`${poi.name} - ${poi.address}`);\n * }\n * }\n * ```\n */\n async peripheralSearch(\n request: AmapPeripheralSearchRequest,\n ): Promise<SdkResponse<AmapPeripheralSearchResponse>> {\n const params: Record<string, unknown> = {\n address: request.address,\n keyword: request.keyword,\n };\n if (request.count !== undefined) {\n params['count'] = request.count;\n }\n if (request.radius !== undefined) {\n params['radius'] = request.radius;\n }\n\n const raw = await this.http.post<PluginExecResult>(\n `${API_PREFIX}/run/${encodeURIComponent(AmapClient.AMAP_PERIPHERAL_SEARCH_TOOL_ID)}`,\n { params },\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n const execResult = raw.data as PluginExecResult | undefined;\n const searchData = execResult?.result as AmapPeripheralSearchResponse | undefined;\n\n return {\n success: true,\n data: searchData ?? {},\n };\n }\n\n // ============================================================\n // 步行路线规划\n // ============================================================\n\n /**\n * 步行路线规划\n *\n * 提供起点和终点的位置,返回步行路线,支持多条路线。\n *\n * @param request - 步行路线规划请求\n * - `origin`(必填):起点地址\n * - `destination`(必填):终点地址\n * @returns 步行路线规划结果\n *\n * @example\n * ```ts\n * const res = await client.walkingRoute({\n * origin: '杭州市西湖区古荡',\n * destination: '杭州市西湖区西溪湿地'\n * });\n * if (res.success) {\n * const path = res.data?.route?.paths?.[0];\n * console.log(`距离: ${path?.distance}米, 时间: ${path?.duration}秒`);\n * }\n * ```\n */\n async walkingRoute(\n request: AmapWalkingRouteRequest,\n ): Promise<SdkResponse<AmapWalkingRouteResponse>> {\n const params: Record<string, unknown> = {\n origin: request.origin,\n destination: request.destination,\n };\n\n const raw = await this.http.post<PluginExecResult>(\n `${API_PREFIX}/run/${encodeURIComponent(AmapClient.AMAP_WALKING_ROUTE_TOOL_ID)}`,\n { params },\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n const execResult = raw.data as PluginExecResult | undefined;\n const routeData = execResult?.result as AmapWalkingRouteResponse | undefined;\n\n return {\n success: true,\n data: routeData ?? {},\n };\n }\n\n // ============================================================\n // 驾车路线规划\n // ============================================================\n\n /**\n * 驾车路线规划\n *\n * 提供起点和终点的位置,返回驾车路线,支持多条路线。\n *\n * @param request - 驾车路线规划请求\n * - `origin`(必填):起点地址或经纬度\n * - `destination`(必填):终点地址或经纬度\n * @returns 驾车路线规划结果\n *\n * @example\n * ```ts\n * const res = await client.drivingRoute({\n * origin: '杭州西溪湿地',\n * destination: '绍兴市'\n * });\n * if (res.success) {\n * const path = res.data?.route?.paths?.[0];\n * console.log(`距离: ${path?.distance}米, 时间: ${path?.duration}秒`);\n * console.log(`出租车费用: ${res.data?.route?.taxi_cost}元`);\n * }\n * ```\n */\n async drivingRoute(\n request: AmapDrivingRouteRequest,\n ): Promise<SdkResponse<AmapDrivingRouteResponse>> {\n const params: Record<string, unknown> = {\n origin: request.origin,\n destination: request.destination,\n };\n\n const raw = await this.http.post<PluginExecResult>(\n `${API_PREFIX}/run/${encodeURIComponent(AmapClient.AMAP_DRIVING_ROUTE_TOOL_ID)}`,\n { params },\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n const execResult = raw.data as PluginExecResult | undefined;\n const routeData = execResult?.result as AmapDrivingRouteResponse | undefined;\n\n return {\n success: true,\n data: routeData ?? {},\n };\n }\n\n // ============================================================\n // 电动车路线规划\n // ============================================================\n\n /**\n * 电动车路线规划\n *\n * 提供起点和终点的位置,返回电动车骑行路线,支持多条路线。\n *\n * @param request - 电动车路线规划请求\n * - `origin`(必填):起点地址或经纬度\n * - `destination`(必填):终点地址或经纬度\n * @returns 电动车路线规划结果\n *\n * @example\n * ```ts\n * const res = await client.ebikeRoute({\n * origin: '杭州市西湖区',\n * destination: '杭州市余杭区'\n * });\n * if (res.success) {\n * const path = res.data?.route?.paths?.[0];\n * console.log(`距离: ${path?.distance}米, 时间: ${path?.duration}秒`);\n * }\n * ```\n */\n async ebikeRoute(\n request: AmapEbikeRouteRequest,\n ): Promise<SdkResponse<AmapEbikeRouteResponse>> {\n const params: Record<string, unknown> = {\n origin: request.origin,\n destination: request.destination,\n };\n\n const raw = await this.http.post<PluginExecResult>(\n `${API_PREFIX}/run/${encodeURIComponent(AmapClient.AMAP_EBIKE_ROUTE_TOOL_ID)}`,\n { params },\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n const execResult = raw.data as PluginExecResult | undefined;\n const routeData = execResult?.result as AmapEbikeRouteResponse | undefined;\n\n return {\n success: true,\n data: routeData ?? {},\n };\n }\n\n // ============================================================\n // 公交路线规划\n // ============================================================\n\n /**\n * 公交路线规划\n *\n * 提供起点和终点的位置,返回公交换乘方案,支持多条路线。\n *\n * @param request - 公交路线规划请求\n * - `origin`(必填):起点地址或经纬度\n * - `destination`(必填):终点地址或经纬度\n * @returns 公交路线规划结果\n *\n * @example\n * ```ts\n * const res = await client.transitRoute({\n * origin: '杭州火车站',\n * destination: '西湖'\n * });\n * if (res.success) {\n * for (const transit of res.data?.route?.transits ?? []) {\n * console.log(`费用: ${transit.cost}元, 时间: ${transit.duration}秒`);\n * }\n * }\n * ```\n */\n async transitRoute(\n request: AmapTransitRouteRequest,\n ): Promise<SdkResponse<AmapTransitRouteResponse>> {\n const params: Record<string, unknown> = {\n origin: request.origin,\n destination: request.destination,\n };\n\n const raw = await this.http.post<PluginExecResult>(\n `${API_PREFIX}/run/${encodeURIComponent(AmapClient.AMAP_TRANSIT_ROUTE_TOOL_ID)}`,\n { params },\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n const execResult = raw.data as PluginExecResult | undefined;\n const routeData = execResult?.result as AmapTransitRouteResponse | undefined;\n\n return {\n success: true,\n data: routeData ?? {},\n };\n }\n\n // ============================================================\n // 行政区域查询\n // ============================================================\n\n /**\n * 行政区域查询\n *\n * 根据用户输入,快速查找特定的行政区域信息。\n *\n * @param request - 行政区域查询请求\n * - `keywords`(必填):查询关键字(行政区名称、citycode、adcode)\n * @returns 行政区域查询结果\n *\n * @example\n * ```ts\n * const res = await client.district({ keywords: '成都市' });\n * if (res.success) {\n * for (const district of res.data?.districts ?? []) {\n * console.log(`${district.name} (${district.adcode})`);\n * }\n * }\n * ```\n */\n async district(request: AmapDistrictRequest): Promise<SdkResponse<AmapDistrictResponse>> {\n const params: Record<string, unknown> = { keywords: request.keywords };\n\n const raw = await this.http.post<PluginExecResult>(\n `${API_PREFIX}/run/${encodeURIComponent(AmapClient.AMAP_DISTRICT_TOOL_ID)}`,\n { params },\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n const execResult = raw.data as PluginExecResult | undefined;\n const districtData = execResult?.result as AmapDistrictResponse | undefined;\n\n return {\n success: true,\n data: districtData ?? {},\n };\n }\n\n // ============================================================\n // 经纬度转地址(逆地理编码)\n // ============================================================\n\n /**\n * 经纬度转地址(逆地理编码)\n *\n * 将经纬度转换为详细的地址,且返回附近周边的 POI、AOI 信息。\n *\n * @param request - 经纬度转地址请求\n * - `location`(必填):经纬度坐标(经度在前,纬度在后,英文逗号分隔)\n * - `extensions`(可选):base(基本地址)/ all(详细信息)\n * @returns 逆地理编码结果\n *\n * @example\n * ```ts\n * const res = await client.regeocode({\n * location: '116.480881,39.989410',\n * extensions: 'base'\n * });\n * if (res.success) {\n * console.log(`地址: ${res.data?.regeocode?.formatted_address}`);\n * }\n * ```\n */\n async regeocode(request: AmapRegeocodeRequest): Promise<SdkResponse<AmapRegeocodeResponse>> {\n const params: Record<string, unknown> = { location: request.location };\n if (request.extensions !== undefined) {\n params['extensions'] = request.extensions;\n }\n\n const raw = await this.http.post<PluginExecResult>(\n `${API_PREFIX}/run/${encodeURIComponent(AmapClient.AMAP_REGEOCODE_TOOL_ID)}`,\n { params },\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n const execResult = raw.data as PluginExecResult | undefined;\n const regeocodeData = execResult?.result as AmapRegeocodeResponse | undefined;\n\n return {\n success: true,\n data: regeocodeData ?? {},\n };\n }\n\n // ============================================================\n // 坐标转换\n // ============================================================\n\n /**\n * 坐标转换\n *\n * 将非高德坐标(GPS、mapbar、baidu 坐标)转换成高德坐标。\n *\n * @param request - 坐标转换请求\n * - `locations`(必填):坐标点(经纬度用逗号分隔,多个坐标用 \"|\" 分隔,最多 40 个)\n * - `coordsys`(必填):原坐标系(gps / mapbar / baidu / autonavi)\n * @returns 坐标转换结果\n *\n * @example\n * ```ts\n * const res = await client.convert({\n * locations: '116.481488,39.990464',\n * coordsys: 'baidu'\n * });\n * if (res.success) {\n * console.log(`转换后的坐标: ${res.data?.locations}`);\n * }\n * ```\n */\n async convert(request: AmapConvertRequest): Promise<SdkResponse<AmapConvertResponse>> {\n const params: Record<string, unknown> = {\n locations: request.locations,\n coordsys: request.coordsys,\n };\n\n const raw = await this.http.post<PluginExecResult>(\n `${API_PREFIX}/run/${encodeURIComponent(AmapClient.AMAP_CONVERT_TOOL_ID)}`,\n { params },\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n const execResult = raw.data as PluginExecResult | undefined;\n const convertData = execResult?.result as AmapConvertResponse | undefined;\n\n return {\n success: true,\n data: convertData ?? {},\n };\n }\n\n // ============================================================\n // POI 关键字搜索\n // ============================================================\n\n /**\n * POI 关键字搜索\n *\n * 通过文本关键字搜索地点信息,支持结构化地址和 POI 名称搜索。\n *\n * @param request - POI 关键字搜索请求\n * - `keywords`(可选):查询关键字\n * - `types`(可选):指定地点类型\n * - `region`(可选):搜索区划(默认全国)\n * - `city_limit`(可选):是否限制在 region 内(true / false)\n * - `page_size`(可选):每页数据条数(1-25)\n * - `page_num`(可选):分页页码(1-100)\n * @returns POI 搜索结果\n *\n * @example\n * ```ts\n * const res = await client.poiSearch({\n * keywords: '首开广场',\n * region: '北京',\n * page_size: '10',\n * page_num: '1'\n * });\n * if (res.success) {\n * for (const poi of res.data?.pois ?? []) {\n * console.log(`${poi.name} - ${poi.address}`);\n * }\n * }\n * ```\n */\n async poiSearch(request: AmapPoiSearchRequest): Promise<SdkResponse<AmapPoiSearchResponse>> {\n const params: Record<string, unknown> = {};\n if (request.keywords !== undefined) {\n params['keywords'] = request.keywords;\n }\n if (request.types !== undefined) {\n params['types'] = request.types;\n }\n if (request.region !== undefined) {\n params['region'] = request.region;\n }\n if (request.city_limit !== undefined) {\n params['city_limit'] = request.city_limit;\n }\n if (request.page_size !== undefined) {\n params['page_size'] = request.page_size;\n }\n if (request.page_num !== undefined) {\n params['page_num'] = request.page_num;\n }\n\n const raw = await this.http.post<PluginExecResult>(\n `${API_PREFIX}/run/${encodeURIComponent(AmapClient.AMAP_POI_SEARCH_TOOL_ID)}`,\n { params },\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n const execResult = raw.data as PluginExecResult | undefined;\n const poiData = execResult?.result as AmapPoiSearchResponse | undefined;\n\n return {\n success: true,\n data: poiData ?? {},\n };\n }\n}\n","/**\n * 知识库 SDK - KnowledgeClient 核心类\n *\n * 封装知识库管理功能,通过百宝箱服务接口实现知识库的创建和管理。\n */\n\nimport { HttpClient, DEFAULT_BASE_URL } from './http';\nimport type {\n KnowledgeClientConfig,\n KnowledgeCreateRequest,\n KnowledgeCreateResponse,\n KnowledgeUpdateRequest,\n KnowledgeUpdateResponse,\n KnowledgeQueryListRequest,\n KnowledgeQueryListResponse,\n KnowledgeRetrieveRequest,\n KnowledgeRetrieveResponse,\n SdkResponse,\n} from './types';\n\n/** API 路径前缀 */\nconst API_PREFIX = '/openapi/v1';\n\n/**\n * 知识库客户端\n *\n * @example\n * ```ts\n * import { KnowledgeClient } from '@tbox/plugin-sdk';\n *\n * const client = new KnowledgeClient({ apiKey: 'your-api-key' });\n *\n * // 创建结构化知识库\n * const res = await client.createKnowledgeBase({\n * file: fileBlob,\n * type: 'STRUCTURED',\n * tableSchema: {\n * columns: [\n * { name: 'id', dataType: 'STRING', required: true, order: 1 },\n * { name: 'name', dataType: 'STRING', required: false, order: 2 }\n * ],\n * name: '示例表'\n * },\n * indexColumns: ['id']\n * });\n * if (res.success) {\n * console.log(`文档 ID: ${res.data?.documentId}`);\n * }\n * ```\n */\nexport class KnowledgeClient {\n private readonly http: HttpClient;\n\n constructor(config: KnowledgeClientConfig) {\n this.http = new HttpClient({\n baseUrl: config.baseUrl ?? DEFAULT_BASE_URL,\n apiKey: config.apiKey,\n timeout: config.timeout,\n });\n }\n\n // ============================================================\n // 创建知识库\n // ============================================================\n\n /**\n * 创建知识库\n *\n * 通过上传文件创建知识库,支持结构化和非结构化数据。\n *\n * @param request - 创建知识库请求\n * - `file`(必填):上传的文件(如 .xlsx、.pdf 等)\n * - `type`(必填):数据类型,`STRUCTURED`(结构化)或其他类型\n * - `tableSchema`(条件必填):表格 Schema 定义,当 type = STRUCTURED 时必填\n * - `indexColumns`(条件必填):索引列名列表,当 type = STRUCTURED 时必填\n * @returns 创建知识库结果\n *\n * @example\n * ```ts\n * // 从本地文件创建结构化知识库\n * const fileInput = document.querySelector('input[type=\"file\"]');\n * const file = fileInput.files[0];\n *\n * const res = await client.createKnowledgeBase({\n * file: file,\n * type: 'STRUCTURED',\n * tableSchema: {\n * columns: [\n * { name: 'id', dataType: 'STRING', required: true, order: 1 },\n * { name: 'message_id', dataType: 'STRING', required: false, order: 2 },\n * { name: 'content', dataType: 'STRING', required: false, order: 3 }\n * ],\n * name: '消息记录',\n * description: '用于存储消息数据'\n * },\n * indexColumns: ['id', 'message_id']\n * });\n *\n * if (res.success) {\n * console.log(`创建成功,文档 ID: ${res.data?.documentId}`);\n * } else {\n * console.error(`创建失败: ${res.errorMsg}`);\n * }\n * ```\n */\n async createKnowledgeBase(\n request: KnowledgeCreateRequest,\n ): Promise<SdkResponse<KnowledgeCreateResponse>> {\n // 构建 FormData\n const formData = new FormData();\n formData.append('file', request.file);\n formData.append('type', request.type);\n\n // 当 type 为 STRUCTURED 时,需要添加 tableSchema 和 indexColumns\n if (request.type === 'STRUCTURED') {\n if (request.tableSchema) {\n formData.append('tableSchema', JSON.stringify(request.tableSchema));\n }\n if (request.indexColumns && request.indexColumns.length > 0) {\n // indexColumns 作为数组传递,每个元素单独 append\n for (const col of request.indexColumns) {\n formData.append('indexColumns', col);\n }\n }\n }\n\n const raw = await this.http.postFormData<KnowledgeCreateResponse>(\n `${API_PREFIX}/knowledge/createKnowledgeBaseByDataSet`,\n formData,\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n return {\n success: true,\n data: raw.data,\n };\n }\n\n // ============================================================\n // 更新知识库\n // ============================================================\n\n /**\n * 更新知识库\n *\n * 通过上传文件更新已有的知识库文档,支持覆盖更新和增量更新。\n *\n * @param request - 更新知识库请求\n * - `file`(必填):上传的文件(如 .xlsx、.pdf 等)\n * - `type`(必填):数据类型,`STRUCTURED`(结构化)或其他类型\n * - `documentId`(必填):要更新的文档 ID(从创建响应中获取)\n * - `tableSchema`(可选):表格 Schema 定义,结构化数据需要\n * - `updateMode`(可选):更新模式,`OVERWRITE`(覆盖更新)或 `UPSERT`(增量更新,默认)\n * @returns 更新知识库结果\n *\n * @example\n * ```ts\n * // 覆盖更新知识库\n * const res = await client.updateKnowledgeBase({\n * file: newFile,\n * type: 'STRUCTURED',\n * documentId: '20251128999def29600J6WS04301922',\n * tableSchema: {\n * columns: [\n * { name: 'id', dataType: 'STRING', required: true, order: 1 },\n * { name: 'message_id', dataType: 'STRING', required: false, order: 2 },\n * { name: 'content', dataType: 'STRING', required: false, order: 3 }\n * ],\n * name: '消息记录'\n * },\n * updateMode: 'OVERWRITE'\n * });\n *\n * if (res.success) {\n * console.log(`更新成功,文档 ID: ${res.data?.documentId}`);\n * } else {\n * console.error(`更新失败: ${res.errorMsg}`);\n * }\n * ```\n */\n async updateKnowledgeBase(\n request: KnowledgeUpdateRequest,\n ): Promise<SdkResponse<KnowledgeUpdateResponse>> {\n // 构建 FormData\n const formData = new FormData();\n formData.append('file', request.file);\n formData.append('type', request.type);\n formData.append('documentId', request.documentId);\n\n // 可选:更新模式\n if (request.updateMode) {\n formData.append('updateMode', request.updateMode);\n }\n\n // 可选:tableSchema(结构化数据需要)\n if (request.tableSchema) {\n formData.append('tableSchema', JSON.stringify(request.tableSchema));\n }\n\n const raw = await this.http.postFormData<KnowledgeUpdateResponse>(\n `${API_PREFIX}/knowledge/updateDocument`,\n formData,\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n return {\n success: true,\n data: raw.data,\n };\n }\n\n // ============================================================\n // 查询知识库列表\n // ============================================================\n\n /**\n * 查询知识库列表\n *\n * 通过名称模糊查询知识库,返回知识库 ID 和基本信息。\n *\n * @param request - 查询请求\n * - `name`(可选):知识库名称(支持模糊查询)\n * - `pageNo`(可选):页码,从 1 开始,默认 1\n * - `pageSize`(可选):每页条数,默认 10\n * @returns 知识库列表\n *\n * @example\n * ```ts\n * // 查询知识库列表\n * const res = await client.queryDatasetsList({\n * name: '用户知识库'\n * });\n *\n * if (res.success) {\n * for (const item of res.data?.datasets ?? []) {\n * console.log(`ID: ${item.datasetId}, 名称: ${item.name}`);\n * }\n * } else {\n * console.error(`查询失败: ${res.errorMsg}`);\n * }\n * ```\n */\n async queryDatasetsList(\n request: KnowledgeQueryListRequest = {},\n ): Promise<SdkResponse<KnowledgeQueryListResponse>> {\n // 构建查询参数\n const queryParams: Record<string, string> = {};\n if (request.name) {\n queryParams.name = request.name;\n }\n if (request.pageNo !== undefined) {\n queryParams.pageNo = String(request.pageNo);\n }\n if (request.pageSize !== undefined) {\n queryParams.pageSize = String(request.pageSize);\n }\n\n // 查询知识库列表接口使用不同的域名 api.tbox.cn\n const raw = await this.http.get<KnowledgeQueryListResponse>(\n `https://api.tbox.cn/api/datasets/queryDatasetsList`,\n queryParams,\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n return {\n success: true,\n data: raw.data,\n };\n }\n\n // ============================================================\n // 检索知识库\n // ============================================================\n\n /**\n * 检索知识库\n *\n * 通过自然语言查询知识库内容,返回相关度最高的内容片段。\n * 支持两种方式获取知识库:\n * 1. 直接传入 datasetId\n * 2. 传入 name,SDK 会自动查询获取 datasetId\n *\n * @param request - 检索知识库请求\n * - `name`(可选):知识库名称,SDK 会自动查询获取 datasetId\n * - `datasetId`(可选):知识库 ID(优先使用)\n * - `query`(必填):查询内容(自然语言描述)\n * @returns 检索结果\n *\n * @example\n * ```ts\n * // 方式 1: 通过名称自动查询\n * const res = await client.retrieve({\n * name: '用户知识库',\n * query: '消防安全管理制度'\n * });\n *\n * // 方式 2: 直接传入 datasetId\n * const res = await client.retrieve({\n * datasetId: '20251024999def29600U6J302721040',\n * query: '消防安全管理制度'\n * });\n *\n * if (res.success) {\n * for (const item of res.data?.data ?? []) {\n * console.log(`文件: ${item.originFileName}`);\n * console.log(`内容: ${item.content}`);\n * console.log(`相关度: ${item.score}`);\n * }\n * } else {\n * console.error(`检索失败: ${res.errorMsg}`);\n * }\n * ```\n */\n async retrieve(\n request: KnowledgeRetrieveRequest,\n ): Promise<SdkResponse<KnowledgeRetrieveResponse>> {\n let datasetId = request.datasetId;\n\n // 如果没有直接传入 datasetId,通过 name 查询\n if (!datasetId && request.name) {\n const queryRes = await this.queryDatasetsList({ name: request.name });\n if (!queryRes.success) {\n return {\n success: false,\n errorCode: queryRes.errorCode,\n errorMsg: queryRes.errorMsg,\n };\n }\n\n const datasets = queryRes.data?.datasets ?? [];\n if (datasets.length === 0) {\n return {\n success: false,\n errorCode: 'KNOWLEDGE_NOT_FOUND',\n errorMsg: `未找到名称为 \"${request.name}\" 的知识库`,\n };\n }\n\n datasetId = datasets[0].datasetId;\n }\n\n if (!datasetId) {\n return {\n success: false,\n errorCode: 'INVALID_REQUEST',\n errorMsg: '必须提供datasetId 参数',\n };\n }\n\n // 检索接口使用不同的域名 api.tbox.cn\n const raw = await this.http.post<KnowledgeRetrieveResponse>(\n `https://api.tbox.cn/api/datasets/retrieve`,\n {\n datasetId,\n query: request.query,\n },\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n return {\n success: true,\n data: raw.data,\n };\n }\n}\n","/**\n * LLM SDK - LlmClient 核心类\n *\n * 封装大语言模型调用功能,提供 OpenAI 兼容的 Chat Completions 接口。\n */\n\nimport { HttpClient, DEFAULT_BASE_URL } from './http';\nimport type {\n LlmClientConfig,\n ChatCompletionRequest,\n ChatCompletionResponse,\n ChatCompletionChunk,\n ChatMessage,\n} from './types';\n\n/** API 路径前缀 */\nconst API_PREFIX = '/compat/openai/v1';\n\n/**\n * LLM 客户端\n *\n * 提供大语言模型调用能力,支持流式和非流式输出。\n *\n * @example\n * ```ts\n * import { LlmClient } from '@tbox/plugin-sdk';\n *\n * const client = new LlmClient({ apiKey: 'your-api-key' });\n *\n * // 流式调用\n * const stream = await client.chatCompletions({\n * model: 'kimi-k2.5',\n * messages: [{ role: 'user', content: '你好' }],\n * stream: true\n * });\n *\n * for await (const chunk of stream) {\n * process.stdout.write(chunk.choices[0]?.delta?.content ?? '');\n * }\n * ```\n */\nexport class LlmClient {\n private readonly http: HttpClient;\n\n constructor(config: LlmClientConfig) {\n this.http = new HttpClient({\n baseUrl: config.baseUrl ?? DEFAULT_BASE_URL,\n apiKey: config.apiKey,\n timeout: config.timeout,\n });\n }\n\n // ============================================================\n // Chat Completions\n // ============================================================\n\n /**\n * Chat Completions 对话补全\n *\n * 支持流式和非流式两种模式:\n * - 流式(stream=true):返回 AsyncIterable<ChatCompletionChunk>\n * - 非流式(stream=false):返回 ChatCompletionResponse\n *\n * @param request - 对话补全请求\n * - `model`(必填):模型名称\n * - `messages`(必填):对话消息列表\n * - `stream`(可选):是否流式输出,默认 false\n * - `temperature`(可选):温度参数,范围 0~2\n * - `top_p`(可选):核采样参数,范围 0~1,推荐 0.95\n * - `max_tokens`(可选):最大输出 token 数,推荐 8000\n * - `stream_options`(可选):流式选项,`{ include_usage: true }` 可在末尾返回 token 用量\n * @returns 流式返回 AsyncIterable,非流式返回完整响应\n *\n * @example\n * ```ts\n * // 流式调用\n * const stream = await client.chatCompletions({\n * model: 'kimi-k2.5',\n * messages: [\n * { role: 'system', content: '你是一个有帮助的助手' },\n * { role: 'user', content: '你好,请介绍一下你自己' }\n * ],\n * stream: true,\n * stream_options: { include_usage: true }\n * });\n *\n * for await (const chunk of stream) {\n * const content = chunk.choices[0]?.delta?.content;\n * if (content) {\n * process.stdout.write(content);\n * }\n * // 检查是否结束\n * if (chunk.choices[0]?.finish_reason === 'stop') {\n * console.log('\\n对话结束');\n * }\n * // 获取 token 用量(需要 stream_options.include_usage=true)\n * if (chunk.usage) {\n * console.log(`Token 用量: ${chunk.usage.total_tokens}`);\n * }\n * }\n * ```\n *\n * @example\n * ```ts\n * // 非流式调用\n * const response = await client.chatCompletions({\n * model: 'kimi-k2.5',\n * messages: [\n * { role: 'user', content: '你好' }\n * ],\n * stream: false\n * });\n *\n * console.log(response.choices[0]?.message?.content);\n * ```\n */\n async chatCompletions(\n request: ChatCompletionRequest,\n ): Promise<ChatCompletionResponse | AsyncIterable<ChatCompletionChunk>> {\n // 流式模式\n if (request.stream) {\n return this.streamChatCompletions(request);\n }\n\n // 非流式模式\n const response = await this.http.post<ChatCompletionResponse>(\n `${API_PREFIX}/chat/completions`,\n request,\n );\n\n if (!response.success) {\n throw new Error(response.errorMsg ?? 'Chat completion failed');\n }\n\n return response.data!;\n }\n\n /**\n * 流式调用 Chat Completions\n */\n private async *streamChatCompletions(\n request: ChatCompletionRequest,\n ): AsyncIterable<ChatCompletionChunk> {\n const url = `${this.http['baseUrl']}${API_PREFIX}/chat/completions`;\n\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json;charset=UTF-8',\n Authorization: this.http['apiKey'],\n },\n body: JSON.stringify(request),\n });\n\n if (!response.ok) {\n throw new Error(`HTTP error: ${response.status} ${response.statusText}`);\n }\n\n const reader = response.body?.getReader();\n if (!reader) {\n throw new Error('No response body');\n }\n\n const decoder = new TextDecoder('utf-8');\n let buffer = '';\n\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n\n buffer += decoder.decode(value, { stream: true });\n const lines = buffer.split('\\n');\n buffer = lines.pop() ?? '';\n\n for (const line of lines) {\n const trimmed = line.trim();\n if (!trimmed || !trimmed.startsWith('data:')) continue;\n\n // 支持 \"data:\" 和 \"data: \" 两种格式\n const data = trimmed.startsWith('data: ')\n ? trimmed.slice(6)\n : trimmed.slice(5);\n if (data === '[DONE]') return;\n\n try {\n const chunk = JSON.parse(data) as ChatCompletionChunk;\n yield chunk;\n } catch {\n // 忽略解析错误\n }\n }\n }\n\n // 处理剩余 buffer\n if (buffer.trim()) {\n const trimmed = buffer.trim();\n if (trimmed.startsWith('data:')) {\n const data = trimmed.startsWith('data: ')\n ? trimmed.slice(6)\n : trimmed.slice(5);\n if (data !== '[DONE]') {\n try {\n const chunk = JSON.parse(data) as ChatCompletionChunk;\n yield chunk;\n } catch {\n // 忽略解析错误\n }\n }\n }\n }\n } finally {\n reader.releaseLock();\n }\n }\n\n /**\n * 简化的对话方法\n *\n * 快速发起一次对话,自动处理流式输出。\n *\n * @param model - 模型名称\n * @param messages - 对话消息列表\n * @param options - 可选参数\n * @returns 完整的对话内容(对于推理模型,返回推理内容 + 正式内容)\n *\n * @example\n * ```ts\n * const answer = await client.chat('kimi-k2.5', [\n * { role: 'user', content: '你好' }\n * ]);\n * console.log(answer);\n * ```\n */\n async chat(\n model: string,\n messages: ChatMessage[],\n options?: {\n temperature?: number;\n top_p?: number;\n max_tokens?: number;\n },\n ): Promise<string> {\n const stream = await this.chatCompletions({\n model,\n messages,\n stream: true,\n stream_options: { include_usage: true },\n ...options,\n });\n\n let fullContent = '';\n let reasoningContent = '';\n\n for await (const chunk of stream as AsyncIterable<ChatCompletionChunk>) {\n const content = chunk.choices?.[0]?.delta?.content;\n const reasoning = chunk.choices?.[0]?.delta?.reasoning_content;\n if (content) {\n fullContent += content;\n }\n if (reasoning) {\n reasoningContent += reasoning;\n }\n }\n\n // 如果有推理内容但没有正式内容,返回推理内容\n // 这对于 glm-5v-turbo 等推理模型很重要\n if (!fullContent && reasoningContent) {\n return reasoningContent;\n }\n\n return fullContent;\n }\n}\n"],"names":["API_PREFIX"],"mappings":";;AAAA;;AAEG;AAEH;AACO,MAAM,aAAa,GAAG;AAE7B;AACO,MAAM,WAAW,GAAG;AAE3B;AACO,MAAM,kBAAkB,GAAG,oBAAoB;;ACXtD;;;;;AAKG;AAEH;AACM,MAAO,SAAU,SAAQ,KAAK,CAAA;AAClC,IAAA,WAAA,CAAY,OAAe,EAAA;QACzB,KAAK,CAAC,OAAO,CAAC;AACd,QAAA,IAAI,CAAC,IAAI,GAAG,WAAW;QACvB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC;IACnD;AACD;AAcD;AACM,MAAO,QAAS,SAAQ,SAAS,CAAA;IAOrC,WAAA,CACE,MAAc,EACd,SAA6B,EAC7B,QAA4B,EAC5B,OAA2B,EAC3B,WAAqB,EAAA;AAErB,QAAA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C,OAAO,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO;AAClD,YAAA,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,iBAAiB;YAC9D,IAAI,OAAO,EAAE;gBACX,WAAW,IAAI,OAAO;YACxB;YACA,IAAI,SAAS,EAAE;gBACb,gBAAgB,IAAI,SAAS;YAC/B;QACF;;;AAIA,QAAA,IAAI,CAAC,WAAW,IAAI,gBAAgB,EAAE;AACpC,YAAA,OAAO,gBAAgB;QACzB;AAEA,QAAA,OAAO,WAAW;IACpB;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/constant.ts","../src/error.ts","../src/core.ts","../src/resource.ts","../src/resources/knowledge/documents.ts","../src/resources/knowledge/index.ts","../src/schema.ts","../src/resources/knowledge/schema.ts","../src/tbox-api.ts","../src/knowledge-client.ts","../src/http.ts","../src/plugin.ts","../src/conversation.ts","../src/app.ts","../src/homepage.ts","../src/amap.ts","../src/knowledge.ts","../src/llm.ts"],"sourcesContent":["/**\n * @tbox/sdk — 常量定义\n */\n\n/** 默认 API 基础 URL */\nexport const TBOX_BASE_URL = 'https://o.tbox.cn';\n\n/** SDK 版本号 */\nexport const SDK_VERSION = '1.0.0';\n\n/** SDK 版本标识 header key */\nexport const SDK_VERSION_HEADER = 'X-Tbox-SDK-Version';\n","/**\n * @tbox/sdk — 分层错误体系\n *\n * 对齐 coze-js 的 error.ts 设计:\n * TboxError → APIError → 按 HTTP 状态码的子类\n */\n\n/** 所有 SDK 错误的基类 */\nexport class TboxError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'TboxError';\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** 服务端原始响应结构(用于错误工厂) */\ninterface RawErrorBody {\n success?: boolean;\n errorCode?: string;\n code?: string | number;\n resultCode?: string;\n errorMsg?: string;\n msg?: string;\n resultDesc?: string;\n traceId?: string;\n}\n\n/** API 调用错误,包含 HTTP 状态码和业务错误信息 */\nexport class APIError extends TboxError {\n readonly status: number;\n readonly errorCode?: string;\n readonly errorMsg?: string;\n readonly traceId?: string;\n readonly rawResponse?: unknown;\n\n constructor(\n status: number,\n errorCode: string | undefined,\n errorMsg: string | undefined,\n traceId: string | undefined,\n rawResponse?: unknown,\n ) {\n const message = errorMsg ?? `API error (status ${status})`;\n super(message);\n this.name = 'APIError';\n this.status = status;\n this.errorCode = errorCode;\n this.errorMsg = errorMsg;\n this.traceId = traceId;\n this.rawResponse = rawResponse;\n }\n\n /**\n * Factory: create the appropriate error subclass based on HTTP status code.\n */\n static generate(status: number, body?: RawErrorBody): APIError {\n const errorCode = body?.errorCode ?? (body?.code != null ? String(body.code) : undefined) ?? body?.resultCode;\n const errorMsg = body?.errorMsg ?? body?.msg ?? body?.resultDesc;\n const traceId = body?.traceId;\n\n switch (status) {\n case 400:\n return new BadRequestError(errorCode, errorMsg, traceId, body);\n case 401:\n return new AuthenticationError(errorCode, errorMsg, traceId, body);\n case 403:\n return new ForbiddenError(errorCode, errorMsg, traceId, body);\n case 404:\n return new NotFoundError(errorCode, errorMsg, traceId, body);\n case 429:\n return new RateLimitError(errorCode, errorMsg, traceId, body);\n case 500:\n return new InternalServerError(errorCode, errorMsg, traceId, body);\n case 502:\n return new GatewayError(errorCode, errorMsg, traceId, body);\n default:\n return new APIError(status, errorCode, errorMsg, traceId, body);\n }\n }\n}\n\nexport class BadRequestError extends APIError {\n constructor(errorCode?: string, errorMsg?: string, traceId?: string, rawResponse?: unknown) {\n super(400, errorCode, errorMsg, traceId, rawResponse);\n this.name = 'BadRequestError';\n }\n}\n\nexport class AuthenticationError extends APIError {\n constructor(errorCode?: string, errorMsg?: string, traceId?: string, rawResponse?: unknown) {\n super(401, errorCode, errorMsg, traceId, rawResponse);\n this.name = 'AuthenticationError';\n }\n}\n\nexport class ForbiddenError extends APIError {\n constructor(errorCode?: string, errorMsg?: string, traceId?: string, rawResponse?: unknown) {\n super(403, errorCode, errorMsg, traceId, rawResponse);\n this.name = 'ForbiddenError';\n }\n}\n\nexport class NotFoundError extends APIError {\n constructor(errorCode?: string, errorMsg?: string, traceId?: string, rawResponse?: unknown) {\n super(404, errorCode, errorMsg, traceId, rawResponse);\n this.name = 'NotFoundError';\n }\n}\n\nexport class RateLimitError extends APIError {\n constructor(errorCode?: string, errorMsg?: string, traceId?: string, rawResponse?: unknown) {\n super(429, errorCode, errorMsg, traceId, rawResponse);\n this.name = 'RateLimitError';\n }\n}\n\nexport class InternalServerError extends APIError {\n constructor(errorCode?: string, errorMsg?: string, traceId?: string, rawResponse?: unknown) {\n super(500, errorCode, errorMsg, traceId, rawResponse);\n this.name = 'InternalServerError';\n }\n}\n\nexport class GatewayError extends APIError {\n constructor(errorCode?: string, errorMsg?: string, traceId?: string, rawResponse?: unknown) {\n super(502, errorCode, errorMsg, traceId, rawResponse);\n this.name = 'GatewayError';\n }\n}\n\n/** Network unreachable error */\nexport class NetworkError extends TboxError {\n readonly cause?: Error;\n\n constructor(message: string, cause?: Error) {\n super(message);\n this.name = 'NetworkError';\n this.cause = cause;\n }\n}\n\n/** Request timeout error */\nexport class TimeoutError extends TboxError {\n readonly timeout: number;\n\n constructor(timeout: number) {\n super(`Request timed out after ${timeout}ms`);\n this.name = 'TimeoutError';\n this.timeout = timeout;\n }\n}\n\n/** JSON parse error */\nexport class ParseError extends TboxError {\n readonly responseText?: string;\n\n constructor(message: string, responseText?: string) {\n super(message);\n this.name = 'ParseError';\n this.responseText = responseText;\n }\n}\n","/**\n * @tbox/sdk — APIClient 核心基类\n *\n * 对齐 coze-js 的 core.ts 设计:\n * - Token 管理(静态字符串 / 动态函数)\n * - 请求构建(JSON / FormData / SSE)\n * - 响应解包(兼容多种服务端格式)\n * - 错误映射(HTTP 状态码 → 错误子类)\n */\n\nimport { TBOX_BASE_URL, SDK_VERSION, SDK_VERSION_HEADER } from './constant';\nimport {\n APIError,\n NetworkError,\n TimeoutError,\n ParseError,\n} from './error';\n\n/** SDK 初始化配置 */\nexport interface ClientOptions {\n /**\n * API Key or dynamic token function.\n * String is used directly as Bearer Token; function is called before each request.\n */\n token: string | (() => string | Promise<string>);\n\n /** API base URL. @default \"https://o.tbox.cn\" */\n baseURL?: string;\n\n /** Request timeout in milliseconds. @default undefined (no timeout) */\n timeout?: number;\n\n /** Enable debug logging. @default false */\n debug?: boolean;\n\n /** Custom headers merged into every request. */\n headers?: Record<string, string>;\n}\n\n/** Per-request option overrides */\nexport interface RequestOptions {\n timeout?: number;\n headers?: Record<string, string>;\n debug?: boolean;\n signal?: AbortSignal;\n baseURL?: string;\n}\n\n/** SSE event object */\nexport interface SSEEvent {\n data: string;\n event?: string;\n id?: string;\n retry?: number;\n}\n\n/**\n * Raw API response structure — compatible with multiple server-side formats.\n */\ninterface RawApiResponse {\n success?: boolean;\n data?: unknown;\n resultObj?: unknown;\n result?: unknown;\n errorCode?: string;\n code?: string | number;\n resultCode?: string;\n errorMsg?: string;\n msg?: string;\n resultDesc?: string;\n traceId?: string;\n hostName?: string;\n}\n\n/**\n * Check if a result field is a knowledge-style nested wrapper:\n * { response: {...}, success: boolean, errorType?: string }\n */\nfunction isKnowledgeWrapper(value: unknown): value is { response?: unknown; success?: boolean; errorType?: string } {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'response' in value &&\n 'success' in value\n );\n}\n\n/**\n * Core request engine. All Resource classes call methods on this via `this._client`.\n */\nexport class APIClient {\n protected baseURL: string;\n protected token: string | (() => string | Promise<string>);\n protected timeout?: number;\n protected debug: boolean;\n protected defaultHeaders?: Record<string, string>;\n\n constructor(options: ClientOptions) {\n this.baseURL = (options.baseURL ?? TBOX_BASE_URL).replace(/\\/$/, '');\n this.token = options.token;\n this.timeout = options.timeout;\n this.debug = options.debug ?? false;\n this.defaultHeaders = options.headers;\n }\n\n /** Resolve the current token value (supports async token functions). */\n protected async getToken(): Promise<string> {\n if (typeof this.token === 'function') {\n return this.token();\n }\n return this.token;\n }\n\n /** JSON POST request — returns unwrapped business data. */\n async post<Rsp>(path: string, body?: unknown, options?: RequestOptions): Promise<Rsp> {\n const url = this.buildUrl(path, options);\n const headers = await this.buildHeaders(options, 'application/json;charset=UTF-8');\n\n this.debugLog(options, `POST ${url}`, body);\n\n const response = await this.fetchWithTimeout(url, {\n method: 'POST',\n headers,\n body: body != null ? JSON.stringify(body) : undefined,\n signal: options?.signal,\n }, options);\n\n return this.parseAndUnwrap<Rsp>(response, options);\n }\n\n /** GET request — query params auto-appended to URL. */\n async get<Rsp>(\n path: string,\n params?: Record<string, string | number | boolean | undefined>,\n options?: RequestOptions,\n ): Promise<Rsp> {\n let url = this.buildUrl(path, options);\n\n if (params) {\n const searchParams = new URLSearchParams();\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n searchParams.append(key, String(value));\n }\n }\n const queryString = searchParams.toString();\n if (queryString) {\n url += `?${queryString}`;\n }\n }\n\n const headers = await this.buildHeaders(options);\n\n this.debugLog(options, `GET ${url}`);\n\n const response = await this.fetchWithTimeout(url, {\n method: 'GET',\n headers,\n signal: options?.signal,\n }, options);\n\n return this.parseAndUnwrap<Rsp>(response, options);\n }\n\n /** FormData POST request (file uploads). Content-Type is set automatically by fetch. */\n async postFormData<Rsp>(path: string, formData: FormData, options?: RequestOptions): Promise<Rsp> {\n const url = this.buildUrl(path, options);\n const headers = await this.buildHeaders(options);\n // Do NOT set Content-Type — fetch/browser will set multipart/form-data with boundary\n delete (headers as Record<string, string>)['Content-Type'];\n\n this.debugLog(options, `POST (FormData) ${url}`);\n\n const response = await this.fetchWithTimeout(url, {\n method: 'POST',\n headers,\n body: formData,\n signal: options?.signal,\n }, options);\n\n return this.parseAndUnwrap<Rsp>(response, options);\n }\n\n /** SSE streaming POST request — yields SSEEvent objects. */\n async *postStream(path: string, body?: unknown, options?: RequestOptions): AsyncGenerator<SSEEvent> {\n const url = this.buildUrl(path, options);\n const headers = await this.buildHeaders(options, 'application/json;charset=UTF-8');\n\n this.debugLog(options, `POST (stream) ${url}`, body);\n\n const response = await this.fetchWithTimeout(url, {\n method: 'POST',\n headers,\n body: body != null ? JSON.stringify(body) : undefined,\n signal: options?.signal,\n }, options);\n\n if (!response.ok) {\n const raw = await this.safeParseJson(response);\n throw APIError.generate(response.status, raw ?? undefined);\n }\n\n if (!response.body) {\n throw new ParseError('Response body is null — streaming not supported');\n }\n\n yield* this.parseSSEStream(response);\n }\n\n // ================================================================\n // Internal helpers\n // ================================================================\n\n private buildUrl(path: string, options?: RequestOptions): string {\n const base = options?.baseURL?.replace(/\\/$/, '') ?? this.baseURL;\n return `${base}${path}`;\n }\n\n private async buildHeaders(\n options?: RequestOptions,\n contentType?: string,\n ): Promise<Record<string, string>> {\n const token = await this.getToken();\n\n const headers: Record<string, string> = {\n Authorization: token,\n [SDK_VERSION_HEADER]: SDK_VERSION,\n ...this.defaultHeaders,\n ...options?.headers,\n };\n\n if (contentType) {\n headers['Content-Type'] = contentType;\n }\n\n return headers;\n }\n\n private async fetchWithTimeout(\n url: string,\n init: RequestInit,\n options?: RequestOptions,\n ): Promise<Response> {\n const timeoutMs = options?.timeout ?? this.timeout;\n\n if (!timeoutMs) {\n try {\n return await fetch(url, init);\n } catch (error) {\n throw new NetworkError(\n 'Network request failed',\n error instanceof Error ? error : undefined,\n );\n }\n }\n\n const controller = new AbortController();\n const existingSignal = init.signal;\n\n // Merge external signal with timeout signal\n if (existingSignal) {\n existingSignal.addEventListener('abort', () => controller.abort(existingSignal.reason));\n }\n\n const timer = setTimeout(() => controller.abort('timeout'), timeoutMs);\n\n try {\n return await fetch(url, { ...init, signal: controller.signal });\n } catch (error) {\n if (controller.signal.aborted && controller.signal.reason === 'timeout') {\n throw new TimeoutError(timeoutMs);\n }\n throw new NetworkError(\n 'Network request failed',\n error instanceof Error ? error : undefined,\n );\n } finally {\n clearTimeout(timer);\n }\n }\n\n private async parseAndUnwrap<Rsp>(response: Response, options?: RequestOptions): Promise<Rsp> {\n if (!response.ok) {\n const raw = await this.safeParseJson(response);\n throw APIError.generate(response.status, raw ?? undefined);\n }\n\n const raw = await this.parseJsonResponse<RawApiResponse>(response);\n\n this.debugLog(options, 'Response:', raw);\n\n return this.unwrapResponse<Rsp>(raw, response.status);\n }\n\n /**\n * Unwrap server response — extract business data from various envelope formats.\n *\n * Priority: data > resultObj > result.response (knowledge) > result > raw\n */\n private unwrapResponse<Rsp>(raw: RawApiResponse, httpStatus: number): Rsp {\n // Check outer success flag\n if (raw.success === false) {\n throw APIError.generate(httpStatus, raw);\n }\n\n // Priority 1: data field\n if (raw.data !== undefined) {\n return raw.data as Rsp;\n }\n\n // Priority 2: resultObj field\n if (raw.resultObj !== undefined) {\n return raw.resultObj as Rsp;\n }\n\n // Priority 3: result field (may be knowledge wrapper)\n if (raw.result !== undefined) {\n if (isKnowledgeWrapper(raw.result)) {\n if (raw.result.success === false) {\n throw APIError.generate(httpStatus, {\n ...raw,\n errorMsg: raw.result.errorType ?? raw.errorMsg,\n });\n }\n return raw.result.response as Rsp;\n }\n return raw.result as Rsp;\n }\n\n // Fallback: return the entire raw response if it has meaningful fields,\n // otherwise throw a ParseError to avoid silently returning an unexpected shape.\n if (raw.success !== undefined || raw.code !== undefined || raw.resultCode !== undefined) {\n return raw as unknown as Rsp;\n }\n throw new ParseError('Unexpected response format — unable to extract business data', JSON.stringify(raw));\n }\n\n /** Parse JSON response using ArrayBuffer + TextDecoder for correct UTF-8 handling. */\n private async parseJsonResponse<T>(response: Response): Promise<T> {\n let text: string;\n try {\n const buffer = await response.arrayBuffer();\n text = new TextDecoder('utf-8').decode(buffer);\n } catch {\n throw new ParseError('Failed to read response body');\n }\n\n try {\n return JSON.parse(text) as T;\n } catch {\n throw new ParseError('Failed to parse response JSON', text);\n }\n }\n\n /** Safely parse JSON without throwing (for error responses). */\n private async safeParseJson(response: Response): Promise<RawApiResponse | null> {\n try {\n const buffer = await response.arrayBuffer();\n const text = new TextDecoder('utf-8').decode(buffer);\n return JSON.parse(text) as RawApiResponse;\n } catch {\n return null;\n }\n }\n\n /** Parse SSE stream from ReadableStream. */\n private async *parseSSEStream(response: Response): AsyncGenerator<SSEEvent> {\n const reader = response.body!.getReader();\n const decoder = new TextDecoder();\n let buffer = '';\n\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n\n buffer += decoder.decode(value, { stream: true });\n const lines = buffer.split('\\n');\n buffer = lines.pop() ?? '';\n\n for (const line of lines) {\n const trimmed = line.trim();\n if (trimmed.startsWith('data: ')) {\n const data = trimmed.slice(6).trim();\n if (data === '[DONE]') return;\n yield { data };\n }\n }\n }\n } finally {\n reader.releaseLock();\n }\n }\n\n /** Output debug log when debug mode is enabled. */\n protected debugLog(options: RequestOptions | undefined, ...messages: unknown[]): void {\n const isDebug = options?.debug ?? this.debug;\n if (isDebug) {\n console.log('[TboxSDK]', ...messages);\n }\n }\n}\n","/**\n * @tbox/sdk — APIResource 基类\n *\n * 所有 Resource 子类(Knowledge、Plugins 等)继承此类,\n * 通过 this._client 引用 APIClient 发起请求。\n */\n\nimport type { APIClient } from './core';\n\nexport class APIResource {\n protected _client: APIClient;\n\n constructor(client: APIClient) {\n this._client = client;\n }\n}\n","/**\n * @tbox/sdk — Knowledge Documents sub-resource\n *\n * Handles knowledge base creation and update (multipart/form-data uploads).\n */\n\nimport { APIResource } from '../../resource';\nimport type { RequestOptions } from '../../core';\nimport type {\n DocumentCreateParams,\n DocumentCreateResult,\n DocumentUpdateParams,\n DocumentUpdateResult,\n} from './types';\n\n/** Build FormData for knowledge base creation. */\nfunction buildCreateFormData(params: DocumentCreateParams): FormData {\n const formData = new FormData();\n\n formData.append('file', params.file);\n formData.append('type', params.type);\n\n if (params.tableSchema) {\n formData.append('tableSchema', JSON.stringify(params.tableSchema));\n }\n\n if (params.indexColumns) {\n for (const col of params.indexColumns) {\n formData.append('indexColumns', col);\n }\n }\n\n return formData;\n}\n\n/** Build FormData for knowledge base update. */\nfunction buildUpdateFormData(params: DocumentUpdateParams): FormData {\n const formData = new FormData();\n\n formData.append('documentId', params.documentId);\n formData.append('file', params.file);\n formData.append('type', params.type);\n\n if (params.updateMode) {\n formData.append('updateMode', params.updateMode);\n }\n\n if (params.tableSchema) {\n formData.append('tableSchema', JSON.stringify(params.tableSchema));\n }\n\n if (params.indexColumns) {\n for (const col of params.indexColumns) {\n formData.append('indexColumns', col);\n }\n }\n\n return formData;\n}\n\nexport class Documents extends APIResource {\n /**\n * Create a knowledge base by uploading a file.\n *\n * POST /openapi/v1/knowledge/createKnowledgeBaseByDataSet\n * Content-Type: multipart/form-data\n */\n async create(params: DocumentCreateParams, options?: RequestOptions): Promise<DocumentCreateResult> {\n const formData = buildCreateFormData(params);\n return this._client.postFormData<DocumentCreateResult>(\n '/openapi/v1/knowledge/createKnowledgeBaseByDataSet',\n formData,\n options,\n );\n }\n\n /**\n * Update an existing knowledge base document.\n *\n * POST /openapi/v1/knowledge/updateDocument\n * Content-Type: multipart/form-data\n */\n async update(params: DocumentUpdateParams, options?: RequestOptions): Promise<DocumentUpdateResult> {\n const formData = buildUpdateFormData(params);\n return this._client.postFormData<DocumentUpdateResult>(\n '/openapi/v1/knowledge/updateDocument',\n formData,\n options,\n );\n }\n}\n","/**\n * @tbox/sdk — Knowledge Resource\n *\n * Provides knowledge base list, semantic retrieval, and document management.\n */\n\nimport { APIResource } from '../../resource';\nimport type { APIClient, RequestOptions } from '../../core';\nimport { Documents } from './documents';\nimport type {\n DatasetListParams,\n DatasetListResult,\n RetrieveParams,\n RetrieveResult,\n} from './types';\n\nexport class Knowledge extends APIResource {\n /** Document management sub-resource (create / update). */\n readonly documents: Documents;\n\n constructor(client: APIClient) {\n super(client);\n this.documents = new Documents(client);\n }\n\n /**\n * Query knowledge base list.\n *\n * GET /api/datasets/queryDatasetsList\n */\n async list(params?: DatasetListParams, options?: RequestOptions): Promise<DatasetListResult> {\n return this._client.get<DatasetListResult>(\n '/api/datasets/queryDatasetsList',\n params as Record<string, string | number | boolean | undefined>,\n options,\n );\n }\n\n /**\n * Semantic retrieval against a knowledge base.\n *\n * POST /api/datasets/retrieve\n */\n async retrieve(params: RetrieveParams, options?: RequestOptions): Promise<RetrieveResult> {\n return this._client.post<RetrieveResult>(\n '/api/datasets/retrieve',\n params,\n options,\n );\n }\n}\n\nexport { Documents } from './documents';\nexport type {\n DatasetListParams,\n DatasetListResult,\n DatasetInfo,\n RetrieveParams,\n RetrieveResult,\n RetrieveRecord,\n DocumentCreateParams,\n DocumentCreateResult,\n DocumentUpdateParams,\n DocumentUpdateResult,\n TableSchema,\n ColumnSchema,\n} from './types';\n","/**\n * @tbox/sdk — ResourceSchema 类型体系\n *\n * 用 JSON Schema 风格统一描述所有 API 资源的入参、出参和元信息,\n * 端侧可据此动态渲染表单、校验参数、生成配置。\n *\n * 设计原则:\n * - 对齐 JSON Schema Draft 7 的 property 描述格式\n * - 每个 API 操作(Operation)独立描述入参 + 出参 schema\n * - 所有资源通过 ResourceDefinition 统一注册\n * - 支持嵌套子资源(如 knowledge.documents)\n */\n\n// ================================================================\n// Property Schema — 单个字段的描述\n// ================================================================\n\n/** Supported JSON Schema types */\nexport type SchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'file';\n\n/** Single property descriptor — aligned with JSON Schema property format */\nexport interface PropertySchema {\n /** JSON Schema type */\n type: SchemaType;\n\n /** Human-readable description */\n description: string;\n\n /** Whether this field is required */\n required?: boolean;\n\n /** Default value */\n default?: unknown;\n\n /** Allowed values (enum constraint) */\n enum?: unknown[];\n\n /** For array type: schema of each item */\n items?: PropertySchema | ObjectSchema;\n\n /** For object type: nested properties */\n properties?: Record<string, PropertySchema>;\n\n /** Display format hint for UI rendering (e.g. \"textarea\", \"select\", \"file-upload\") */\n format?: string;\n\n /** Example value for documentation */\n example?: unknown;\n\n /** Minimum value (for number/integer) */\n minimum?: number;\n\n /** Maximum value (for number/integer) */\n maximum?: number;\n\n /** Min length (for string/array) */\n minLength?: number;\n\n /** Max length (for string/array) */\n maxLength?: number;\n\n /** Regex pattern (for string) */\n pattern?: string;\n}\n\n/** Object schema — a collection of named properties */\nexport interface ObjectSchema {\n type: 'object';\n description?: string;\n properties: Record<string, PropertySchema>;\n required?: string[];\n}\n\n// ================================================================\n// Operation Schema — 单个 API 操作的完整描述\n// ================================================================\n\n/** HTTP method */\nexport type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';\n\n/** Content type for request body */\nexport type ContentType = 'application/json' | 'multipart/form-data' | 'none';\n\n/** Complete description of a single API operation */\nexport interface OperationSchema {\n /** Operation identifier (e.g. \"list\", \"retrieve\", \"create\", \"update\") */\n operationId: string;\n\n /** Human-readable summary */\n summary: string;\n\n /** Detailed description */\n description?: string;\n\n /** HTTP method */\n method: HttpMethod;\n\n /** API path (relative to baseURL) */\n path: string;\n\n /** Request content type */\n contentType: ContentType;\n\n /** Input parameters schema */\n params: ObjectSchema;\n\n /** Response data schema (the unwrapped business data, not the raw envelope) */\n response: ObjectSchema;\n\n /** Tags for grouping/filtering */\n tags?: string[];\n}\n\n// ================================================================\n// Resource Definition — 一个资源模块的完整描述\n// ================================================================\n\n/** Complete definition of a resource module */\nexport interface ResourceDefinition {\n /** Resource name (e.g. \"knowledge\", \"plugins\", \"chat\") */\n name: string;\n\n /** Human-readable display name */\n displayName: string;\n\n /** Resource description */\n description: string;\n\n /** API operations provided by this resource */\n operations: OperationSchema[];\n\n /** Nested sub-resources (e.g. knowledge.documents) */\n subResources?: ResourceDefinition[];\n}\n\n// ================================================================\n// Schema Registry — 统一注册和查询\n// ================================================================\n\n/** Registry that holds all resource definitions */\nexport class SchemaRegistry {\n private resources: Map<string, ResourceDefinition> = new Map();\n\n /** Register a resource definition */\n register(definition: ResourceDefinition): void {\n this.resources.set(definition.name, definition);\n }\n\n /** Get a resource definition by name */\n get(name: string): ResourceDefinition | undefined {\n return this.resources.get(name);\n }\n\n /** Get all registered resource definitions */\n list(): ResourceDefinition[] {\n return Array.from(this.resources.values());\n }\n\n /** Get a specific operation by resource name and operation ID */\n getOperation(resourceName: string, operationId: string): OperationSchema | undefined {\n const resource = this.resources.get(resourceName);\n if (!resource) return undefined;\n\n const operation = resource.operations.find(op => op.operationId === operationId);\n if (operation) return operation;\n\n // Search in sub-resources\n for (const subResource of resource.subResources ?? []) {\n const subOperation = subResource.operations.find(op => op.operationId === operationId);\n if (subOperation) return subOperation;\n }\n\n return undefined;\n }\n\n /** Export all schemas as a plain JSON-serializable object */\n toJSON(): Record<string, ResourceDefinition> {\n const result: Record<string, ResourceDefinition> = {};\n for (const [name, definition] of this.resources) {\n result[name] = definition;\n }\n return result;\n }\n}\n","/**\n * @tbox/sdk — Knowledge 模块 ResourceSchema 定义\n *\n * 用 JSON Schema 风格描述知识库的 4 个核心 API 操作,\n * 端侧可据此动态渲染表单、校验参数、生成配置。\n */\n\nimport type { ResourceDefinition } from '../../schema';\n\n/** Knowledge documents sub-resource schema */\nconst documentsResource: ResourceDefinition = {\n name: 'documents',\n displayName: '知识库文档',\n description: '知识库文档的创建和更新(文件上传)',\n operations: [\n {\n operationId: 'create',\n summary: '创建知识库',\n description: '上传文件创建新的知识库,支持结构化(STRUCTURED)和非结构化(UNSTRUCTURED)两种类型',\n method: 'POST',\n path: '/openapi/v1/knowledge/createKnowledgeBaseByDataSet',\n contentType: 'multipart/form-data',\n params: {\n type: 'object',\n properties: {\n file: {\n type: 'file',\n description: '上传的文件(如 .xlsx、.csv、.pdf 等)',\n required: true,\n format: 'file-upload',\n },\n type: {\n type: 'string',\n description: '知识库类型',\n required: true,\n enum: ['STRUCTURED', 'UNSTRUCTURED'],\n default: 'STRUCTURED',\n format: 'select',\n },\n tableSchema: {\n type: 'object',\n description: '表结构定义(STRUCTURED 类型必填),JSON 格式',\n required: false,\n format: 'json-editor',\n properties: {\n name: {\n type: 'string',\n description: '表名',\n required: true,\n },\n description: {\n type: 'string',\n description: '表描述',\n required: false,\n },\n columns: {\n type: 'array',\n description: '列定义列表',\n required: true,\n items: {\n type: 'object',\n properties: {\n name: {\n type: 'string',\n description: '列名',\n required: true,\n },\n dataType: {\n type: 'string',\n description: '数据类型',\n enum: ['STRING', 'INTEGER', 'FLOAT', 'BOOLEAN', 'DATE'],\n default: 'STRING',\n },\n primaryKey: {\n type: 'boolean',\n description: '是否主键',\n default: false,\n },\n required: {\n type: 'boolean',\n description: '是否必填',\n default: false,\n },\n description: {\n type: 'string',\n description: '列描述',\n },\n defaultValue: {\n type: 'string',\n description: '默认值',\n },\n order: {\n type: 'integer',\n description: '排序序号',\n minimum: 0,\n },\n },\n },\n },\n },\n },\n indexColumns: {\n type: 'array',\n description: '索引列名列表',\n required: false,\n items: {\n type: 'string',\n description: '列名',\n },\n },\n },\n required: ['file', 'type'],\n },\n response: {\n type: 'object',\n properties: {\n documentId: {\n type: 'string',\n description: '创建后的文档 ID,用于后续更新操作',\n },\n },\n required: ['documentId'],\n },\n tags: ['knowledge', 'write'],\n },\n {\n operationId: 'update',\n summary: '更新知识库文档',\n description: '上传新文件更新已有的知识库文档,支持覆盖(OVERWRITE)和增量(UPSERT)两种模式',\n method: 'POST',\n path: '/openapi/v1/knowledge/updateDocument',\n contentType: 'multipart/form-data',\n params: {\n type: 'object',\n properties: {\n documentId: {\n type: 'string',\n description: '要更新的文档 ID(从创建响应中获取)',\n required: true,\n },\n file: {\n type: 'file',\n description: '上传的新文件',\n required: true,\n format: 'file-upload',\n },\n type: {\n type: 'string',\n description: '知识库类型',\n required: true,\n enum: ['STRUCTURED', 'UNSTRUCTURED'],\n format: 'select',\n },\n updateMode: {\n type: 'string',\n description: '更新模式',\n required: false,\n enum: ['OVERWRITE', 'UPSERT'],\n default: 'UPSERT',\n format: 'select',\n },\n tableSchema: {\n type: 'object',\n description: '表结构定义(同创建接口的 tableSchema)',\n required: false,\n format: 'json-editor',\n properties: {\n name: { type: 'string', description: '表名', required: true },\n description: { type: 'string', description: '表描述' },\n columns: {\n type: 'array',\n description: '列定义列表',\n required: true,\n items: {\n type: 'object',\n properties: {\n name: { type: 'string', description: '列名', required: true },\n dataType: { type: 'string', description: '数据类型', enum: ['STRING', 'INTEGER', 'FLOAT', 'BOOLEAN', 'DATE'] },\n primaryKey: { type: 'boolean', description: '是否主键' },\n required: { type: 'boolean', description: '是否必填' },\n description: { type: 'string', description: '列描述' },\n defaultValue: { type: 'string', description: '默认值' },\n order: { type: 'integer', description: '排序序号', minimum: 0 },\n },\n },\n },\n },\n },\n indexColumns: {\n type: 'array',\n description: '索引列名列表',\n required: false,\n items: { type: 'string', description: '列名' },\n },\n },\n required: ['documentId', 'file', 'type'],\n },\n response: {\n type: 'object',\n properties: {\n documentId: {\n type: 'string',\n description: '更新后的文档 ID',\n },\n },\n required: ['documentId'],\n },\n tags: ['knowledge', 'write'],\n },\n ],\n};\n\n/** Knowledge resource schema — the complete definition */\nexport const knowledgeSchema: ResourceDefinition = {\n name: 'knowledge',\n displayName: '知识库',\n description: '知识库管理,包括列表查询、语义检索、文档创建和更新',\n operations: [\n {\n operationId: 'list',\n summary: '查询知识库列表',\n description: '分页查询当前账号下的知识库列表,支持按名称模糊搜索',\n method: 'GET',\n path: '/api/datasets/queryDatasetsList',\n contentType: 'none',\n params: {\n type: 'object',\n properties: {\n name: {\n type: 'string',\n description: '知识库名称(模糊搜索)',\n required: false,\n },\n pageNo: {\n type: 'integer',\n description: '页码,从 1 开始',\n required: false,\n default: 1,\n minimum: 1,\n },\n pageSize: {\n type: 'integer',\n description: '每页条数',\n required: false,\n default: 10,\n minimum: 1,\n maximum: 100,\n },\n },\n },\n response: {\n type: 'object',\n properties: {\n data: {\n type: 'array',\n description: '知识库列表',\n items: {\n type: 'object',\n properties: {\n datasetId: { type: 'string', description: '知识库 ID' },\n name: { type: 'string', description: '知识库名称' },\n description: { type: 'string', description: '知识库描述' },\n type: { type: 'string', description: '知识库类型', enum: ['STRUCTURED', 'UNSTRUCTURED'] },\n documentCount: { type: 'integer', description: '文档数量' },\n storageSize: { type: 'number', description: '存储大小' },\n createdAt: { type: 'string', description: '创建时间' },\n updatedAt: { type: 'string', description: '更新时间' },\n },\n },\n },\n totalCount: {\n type: 'integer',\n description: '总条数',\n },\n },\n required: ['data', 'totalCount'],\n },\n tags: ['knowledge', 'read'],\n },\n {\n operationId: 'retrieve',\n summary: '语义检索',\n description: '对指定知识库进行语义检索,返回与查询文本最相关的文档片段',\n method: 'POST',\n path: '/api/datasets/retrieve',\n contentType: 'application/json',\n params: {\n type: 'object',\n properties: {\n datasetId: {\n type: 'string',\n description: '知识库 ID',\n required: true,\n },\n query: {\n type: 'string',\n description: '检索查询文本',\n required: true,\n format: 'textarea',\n },\n topK: {\n type: 'integer',\n description: '返回结果数量上限',\n required: false,\n default: 5,\n minimum: 1,\n maximum: 50,\n },\n scoreThreshold: {\n type: 'number',\n description: '最低相关度分数阈值 (0~1)',\n required: false,\n minimum: 0,\n maximum: 1,\n example: 0.5,\n },\n },\n required: ['datasetId', 'query'],\n },\n response: {\n type: 'object',\n properties: {\n data: {\n type: 'array',\n description: '检索结果列表',\n items: {\n type: 'object',\n properties: {\n content: { type: 'string', description: '文档片段内容' },\n score: { type: 'number', description: '相关度分数 (0~1)' },\n originFileName: { type: 'string', description: '来源文件名' },\n documentId: { type: 'string', description: '来源文档 ID' },\n metadata: { type: 'object', description: '元数据', properties: {} },\n },\n },\n },\n },\n required: ['data'],\n },\n tags: ['knowledge', 'read'],\n },\n ],\n subResources: [documentsResource],\n};\n","/**\n * @tbox/sdk — TboxAPI 入口类\n *\n * SDK 的唯一入口,继承 APIClient,通过属性访问子模块。\n * 内置 SchemaRegistry,自动注册所有资源的 JSON Schema 定义。\n */\n\nimport { APIClient } from './core';\nimport type { ClientOptions } from './core';\nimport { Knowledge } from './resources/knowledge/index';\nimport { SchemaRegistry } from './schema';\nimport { knowledgeSchema } from './resources/knowledge/schema';\n\nexport class TboxAPI extends APIClient {\n /** Knowledge base management (list, retrieve, documents.create, documents.update). */\n readonly knowledge: Knowledge;\n\n /** Schema registry — JSON Schema definitions for all resources, available for client-side parsing. */\n readonly schemas: SchemaRegistry;\n\n constructor(options: ClientOptions) {\n super(options);\n this.knowledge = new Knowledge(this);\n\n // Initialize schema registry with all resource schemas\n this.schemas = new SchemaRegistry();\n this.schemas.register(knowledgeSchema);\n }\n}\n","/**\n * @tbox/sdk — KnowledgeClient\n *\n * Configuration-driven, multi-knowledge-base client.\n * Reuses the unified ClientOptions (token/baseURL/timeout) from core.ts.\n *\n * Supports multiple named knowledge bases via knowledges map in knowledge.json:\n * client.use(\"产品数据\").retrieve(\"查询文本\")\n * client.retrieve(\"产品数据\", \"查询文本\")\n */\n\nimport { TboxAPI } from './tbox-api';\nimport type { ClientOptions } from './core';\nimport type {\n DatasetListParams,\n DatasetListResult,\n RetrieveParams,\n RetrieveResult,\n DocumentCreateParams,\n DocumentCreateResult,\n DocumentUpdateParams,\n DocumentUpdateResult,\n TableSchema,\n} from './resources/knowledge/types';\n\n/** Allowed tool names that can be declared in knowledge.json */\nexport type KnowledgeTool = 'list' | 'retrieve' | 'create' | 'update';\n\n/** knowledge.json — config section: shared service parameters across all knowledge bases */\nexport interface KnowledgeServiceConfig {\n type?: 'STRUCTURED' | 'UNSTRUCTURED';\n topK?: number;\n scoreThreshold?: number;\n updateMode?: 'OVERWRITE' | 'UPSERT';\n pageSize?: number;\n}\n\n/** knowledge.json — per-knowledge-base instance config inside the knowledges map */\nexport interface KnowledgeInstanceConfig {\n datasetId?: string;\n documentId?: string;\n tableSchema?: TableSchema;\n indexColumns?: string[];\n /** Per-knowledge config overrides. Falls back to global config if not set. */\n config?: KnowledgeServiceConfig;\n}\n\n/** Merged runtime config (service defaults + instance config) */\nexport interface KnowledgeConfig extends KnowledgeServiceConfig, KnowledgeInstanceConfig {}\n\n/** Complete structure of knowledge.json — exported for external JSON validation */\nexport interface KnowledgeJsonSchema {\n config?: KnowledgeServiceConfig;\n tools?: KnowledgeTool[];\n knowledges?: Record<string, KnowledgeInstanceConfig>;\n}\n\n/** KnowledgeClient initialization options (extends ClientOptions) */\nexport interface KnowledgeClientOptions extends ClientOptions {\n /**\n * Knowledge config. Three input modes:\n * - String: path to knowledge.json file (Node.js only)\n * - Object: pass KnowledgeConfig directly (single knowledge base)\n * - Omitted: uses default empty config\n */\n config?: KnowledgeConfig | string;\n}\n\n/** Scoped handle returned by client.use(name), bound to a specific knowledge base */\nexport class KnowledgeScopedClient {\n /** Effective config: instance config > global config (merged at construction) */\n private effectiveConfig: KnowledgeServiceConfig;\n private currentDocumentId: string | undefined;\n\n constructor(\n private tbox: TboxAPI,\n globalConfig: KnowledgeServiceConfig,\n private instanceConfig: Readonly<KnowledgeInstanceConfig>,\n private allowedTools?: ReadonlySet<KnowledgeTool>,\n ) {\n const local = instanceConfig.config;\n this.effectiveConfig = {\n type: local?.type ?? globalConfig.type,\n topK: local?.topK ?? globalConfig.topK,\n scoreThreshold: local?.scoreThreshold ?? globalConfig.scoreThreshold,\n updateMode: local?.updateMode ?? globalConfig.updateMode,\n pageSize: local?.pageSize ?? globalConfig.pageSize,\n };\n this.currentDocumentId = instanceConfig.documentId;\n }\n\n /** Get the effective merged config for this knowledge base */\n getConfig(): Readonly<KnowledgeConfig> {\n return { ...this.effectiveConfig, ...this.instanceConfig, documentId: this.currentDocumentId };\n }\n\n /** Get the current documentId (may be auto-filled after create()) */\n getDocumentId(): string | undefined {\n return this.currentDocumentId;\n }\n\n /** Semantic retrieval against this knowledge base */\n async retrieve(\n query: string,\n options?: { topK?: number; scoreThreshold?: number },\n ): Promise<RetrieveResult> {\n this.assertToolAllowed('retrieve');\n\n const datasetId = this.instanceConfig.datasetId;\n if (!datasetId) {\n throw new Error('datasetId is not configured for this knowledge base.');\n }\n\n const params: RetrieveParams = {\n datasetId,\n query,\n topK: options?.topK ?? this.effectiveConfig.topK,\n scoreThreshold: options?.scoreThreshold ?? this.effectiveConfig.scoreThreshold,\n };\n\n return this.tbox.knowledge.retrieve(params);\n }\n\n /**\n * Create this knowledge base by uploading a file.\n *\n * Side effect: on success, the returned documentId is cached in this scoped client\n * so that subsequent update() calls can use it automatically.\n * The original instanceConfig is NOT mutated.\n */\n async create(\n file: Blob,\n options?: { type?: 'STRUCTURED' | 'UNSTRUCTURED'; tableSchema?: TableSchema; indexColumns?: string[] },\n ): Promise<DocumentCreateResult> {\n this.assertToolAllowed('create');\n\n const params: DocumentCreateParams = {\n file,\n type: options?.type ?? this.effectiveConfig.type ?? 'STRUCTURED',\n tableSchema: options?.tableSchema ?? this.instanceConfig.tableSchema,\n indexColumns: options?.indexColumns ?? this.instanceConfig.indexColumns,\n };\n\n const result = await this.tbox.knowledge.documents.create(params);\n\n if (result.documentId) {\n this.currentDocumentId = result.documentId;\n }\n\n return result;\n }\n\n /** Update this knowledge base document */\n async update(\n file: Blob,\n options?: { updateMode?: 'OVERWRITE' | 'UPSERT'; tableSchema?: TableSchema; indexColumns?: string[] },\n ): Promise<DocumentUpdateResult> {\n this.assertToolAllowed('update');\n\n const documentId = this.currentDocumentId;\n if (!documentId) {\n throw new Error('documentId is not configured. Call create() first or set it in knowledge.json.');\n }\n\n const params: DocumentUpdateParams = {\n documentId,\n file,\n type: this.effectiveConfig.type ?? 'STRUCTURED',\n updateMode: options?.updateMode ?? this.effectiveConfig.updateMode ?? 'UPSERT',\n tableSchema: options?.tableSchema ?? this.instanceConfig.tableSchema,\n indexColumns: options?.indexColumns ?? this.instanceConfig.indexColumns,\n };\n\n return this.tbox.knowledge.documents.update(params);\n }\n\n /** Throw if the tool is not in the allowed set (when tools are configured) */\n private assertToolAllowed(tool: KnowledgeTool): void {\n if (this.allowedTools && !this.allowedTools.has(tool)) {\n const allowed = Array.from(this.allowedTools).join(', ');\n throw new Error(`Tool \"${tool}\" is not allowed. Configured tools: [${allowed}]`);\n }\n }\n}\n\n/**\n * Configuration-driven, multi-knowledge-base client.\n *\n * Usage patterns:\n * // Scoped: bind to a named knowledge base, then call methods\n * const product = client.use(\"产品数据\");\n * await product.retrieve(\"查询文本\");\n *\n * // Direct: pass name as first arg\n * await client.retrieve(\"产品数据\", \"查询文本\");\n *\n * // List: shared across all knowledge bases\n * await client.list(\"搜索关键词\");\n */\nexport class KnowledgeClient {\n private tbox: TboxAPI;\n private serviceConfig: KnowledgeServiceConfig;\n private knowledges: Map<string, KnowledgeInstanceConfig>;\n private allowedTools?: ReadonlySet<KnowledgeTool>;\n\n constructor(options: KnowledgeClientOptions) {\n const { config, ...clientOptions } = options;\n this.tbox = new TboxAPI(clientOptions);\n this.serviceConfig = {};\n this.knowledges = new Map();\n this.resolveConfig(config);\n }\n\n /** Create from an existing TboxAPI instance */\n static fromTboxAPI(tbox: TboxAPI, config?: KnowledgeConfig | string): KnowledgeClient {\n const instance = Object.create(KnowledgeClient.prototype) as KnowledgeClient;\n instance.tbox = tbox;\n instance.serviceConfig = {};\n instance.knowledges = new Map();\n instance.resolveConfig(config);\n return instance;\n }\n\n /**\n * Load config from a knowledge.json file asynchronously (ESM-compatible).\n * Use this in ESM environments instead of passing a file path to the constructor.\n */\n static async fromFile(options: Omit<KnowledgeClientOptions, 'config'>, filePath: string): Promise<KnowledgeClient> {\n const client = new KnowledgeClient(options);\n await client.loadConfigFromFileAsync(filePath);\n return client;\n }\n\n /** Resolve config from object, file path, or default */\n private resolveConfig(config?: KnowledgeConfig | string): void {\n if (!config) {\n this.serviceConfig = { type: 'STRUCTURED' };\n return;\n }\n\n if (typeof config === 'string') {\n this.loadConfigFromFileSync(config);\n return;\n }\n\n // Single knowledge config passed as object — store as \"default\"\n this.serviceConfig = {\n type: config.type,\n topK: config.topK,\n scoreThreshold: config.scoreThreshold,\n updateMode: config.updateMode,\n pageSize: config.pageSize,\n };\n this.knowledges.set('default', {\n datasetId: config.datasetId,\n documentId: config.documentId,\n tableSchema: config.tableSchema,\n indexColumns: config.indexColumns,\n });\n }\n\n /** Apply parsed JSON schema to this client */\n private applyJsonSchema(parsed: KnowledgeJsonSchema): void {\n this.serviceConfig = parsed.config ?? { type: 'STRUCTURED' };\n\n if (parsed.tools && parsed.tools.length > 0) {\n this.allowedTools = new Set(parsed.tools);\n }\n\n if (parsed.knowledges) {\n for (const [name, instanceConfig] of Object.entries(parsed.knowledges)) {\n this.knowledges.set(name, { ...instanceConfig });\n }\n }\n }\n\n /** Load config from knowledge.json file synchronously (CJS environments) */\n private loadConfigFromFileSync(filePath: string): void {\n try {\n // eslint-disable-next-line @typescript-eslint/no-implied-eval -- dynamic require for CJS compat\n const dynamicRequire = new Function('id', 'return require(id)') as (id: string) => unknown;\n const fs = dynamicRequire('fs') as { readFileSync: (path: string, encoding: string) => string };\n const raw = fs.readFileSync(filePath, 'utf-8');\n const parsed = JSON.parse(raw) as KnowledgeJsonSchema;\n this.applyJsonSchema(parsed);\n } catch (error) {\n throw new Error(\n `Failed to load knowledge config from \"${filePath}\": ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n\n /** Load config from knowledge.json file asynchronously (ESM-compatible) */\n private async loadConfigFromFileAsync(filePath: string): Promise<void> {\n try {\n // Dynamic import avoids bundler static analysis and works in both CJS and ESM\n const fsModule = await (Function('return import(\"node:fs/promises\")')() as Promise<{ readFile: (path: string, encoding: string) => Promise<string> }>);\n const raw = await fsModule.readFile(filePath, 'utf-8');\n const parsed = JSON.parse(raw) as KnowledgeJsonSchema;\n this.applyJsonSchema(parsed);\n } catch (error) {\n throw new Error(\n `Failed to load knowledge config from \"${filePath}\": ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n\n /** Get all registered knowledge base names */\n names(): string[] {\n return Array.from(this.knowledges.keys());\n }\n\n /** Get the allowed tools set (undefined means all tools are allowed) */\n getAllowedTools(): ReadonlySet<KnowledgeTool> | undefined {\n return this.allowedTools;\n }\n\n /** Get the shared service config */\n getServiceConfig(): Readonly<KnowledgeServiceConfig> {\n return { ...this.serviceConfig };\n }\n\n /** Get instance config for a named knowledge base */\n getInstanceConfig(name: string): Readonly<KnowledgeInstanceConfig> | undefined {\n const config = this.knowledges.get(name);\n return config ? { ...config } : undefined;\n }\n\n /**\n * Get a scoped client bound to a named knowledge base.\n * All subsequent calls on the returned handle use that knowledge base's config.\n */\n use(name: string): KnowledgeScopedClient {\n const instanceConfig = this.knowledges.get(name);\n if (!instanceConfig) {\n const available = this.names().join(', ');\n throw new Error(\n `Knowledge base \"${name}\" not found. Available: [${available}]`,\n );\n }\n\n return new KnowledgeScopedClient(this.tbox, this.serviceConfig, instanceConfig, this.allowedTools);\n }\n\n /** Query knowledge base list (shared, not scoped to a specific knowledge base) */\n async list(name?: string, pageNo?: number, pageSize?: number): Promise<DatasetListResult> {\n this.assertToolAllowed('list');\n\n const params: DatasetListParams = {};\n if (name !== undefined) params.name = name;\n if (pageNo !== undefined) params.pageNo = pageNo;\n params.pageSize = pageSize ?? this.serviceConfig.pageSize;\n\n return this.tbox.knowledge.list(params);\n }\n\n /** Semantic retrieval — pass knowledge base name as first arg to route */\n async retrieve(\n knowledgeName: string,\n query: string,\n options?: { topK?: number; scoreThreshold?: number },\n ): Promise<RetrieveResult> {\n return this.use(knowledgeName).retrieve(query, options);\n }\n\n /** Create a knowledge base by name */\n async create(\n knowledgeName: string,\n file: Blob,\n options?: { type?: 'STRUCTURED' | 'UNSTRUCTURED'; tableSchema?: TableSchema; indexColumns?: string[] },\n ): Promise<DocumentCreateResult> {\n return this.use(knowledgeName).create(file, options);\n }\n\n /** Update a knowledge base by name */\n async update(\n knowledgeName: string,\n file: Blob,\n options?: { updateMode?: 'OVERWRITE' | 'UPSERT'; tableSchema?: TableSchema; indexColumns?: string[] },\n ): Promise<DocumentUpdateResult> {\n return this.use(knowledgeName).update(file, options);\n }\n\n /** Throw if the tool is not in the allowed set (when tools are configured) */\n private assertToolAllowed(tool: KnowledgeTool): void {\n if (this.allowedTools && !this.allowedTools.has(tool)) {\n const allowed = Array.from(this.allowedTools).join(', ');\n throw new Error(`Tool \"${tool}\" is not allowed. Configured tools: [${allowed}]`);\n }\n }\n}\n","/**\n * 百宝箱插件服务 SDK - 底层 HTTP 请求封装\n *\n * 支持两种鉴权模式:\n * - B端:Authorization header(API Key)\n * - C端:TBOXSESSIONID + X-Tbox-Channel + X-Tbox-AppId headers\n */\n\nimport type { SdkResponse, SessionAuth } from './types';\n\n/** 默认调用域名 */\nexport const DEFAULT_BASE_URL = 'https://o.tbox.cn';\n\n/**\n * 鉴权模式\n */\nexport type AuthMode =\n | { type: 'apiKey'; apiKey: string }\n | { type: 'session'; session: SessionAuth };\n\n/** 内部 HTTP 客户端配置 */\nexport interface HttpClientConfig {\n baseUrl: string;\n auth: AuthMode;\n timeout?: number;\n}\n\n/**\n * 旧版配置(向后兼容)\n */\nexport interface LegacyHttpClientConfig {\n baseUrl: string;\n apiKey: string;\n timeout?: number;\n}\n\n/**\n * 服务端返回的原始响应结构(APIServiceResult)\n * 兼容多种字段命名风格:\n * - errorCode / errorMsg(标准)\n * - code / msg(网关层)\n * - resultCode / resultDesc(部分旧接口)\n */\ninterface RawApiResponse<T> {\n success?: boolean;\n /** 标准错误码 */\n errorCode?: string;\n /** 标准错误信息 */\n errorMsg?: string;\n /** 网关层错误码(兼容) */\n code?: string;\n /** 网关层错误信息(兼容) */\n msg?: string;\n /** 旧接口错误码(兼容) */\n resultCode?: string;\n /** 旧接口错误信息(兼容) */\n resultDesc?: string;\n data?: T;\n /** 部分接口用 resultObj */\n resultObj?: T;\n /** 部分接口用 result(如 generate_session) */\n result?: T;\n}\n\n/**\n * 将服务端原始响应统一转换为 SdkResponse\n */\nfunction normalizeResponse<T>(raw: RawApiResponse<T>): SdkResponse<T> {\n const success = raw.success !== false;\n const data = raw.data ?? raw.resultObj ?? raw.result;\n // 按优先级兼容多种错误码字段\n const errorCode = raw.errorCode ?? raw.code ?? raw.resultCode;\n const errorMsg = raw.errorMsg ?? raw.msg ?? raw.resultDesc;\n\n if (success) {\n return { success: true, data };\n }\n return { success: false, errorCode, errorMsg };\n}\n\n/**\n * 底层 HTTP 客户端\n *\n * 支持两种构造方式:\n * - 新版:传入 HttpClientConfig(含 AuthMode)\n * - 旧版:传入 LegacyHttpClientConfig(含 apiKey,向后兼容)\n */\nexport class HttpClient {\n private readonly _baseUrl: string;\n private readonly auth: AuthMode;\n private readonly timeout?: number;\n\n constructor(config: HttpClientConfig | LegacyHttpClientConfig) {\n this._baseUrl = config.baseUrl.replace(/\\/$/, '');\n this.timeout = config.timeout;\n\n if ('auth' in config) {\n this.auth = config.auth;\n } else {\n this.auth = { type: 'apiKey', apiKey: config.apiKey };\n }\n }\n\n /** 获取 base URL */\n get baseUrl(): string {\n return this._baseUrl;\n }\n\n /** 获取鉴权请求头(供外部流式请求等场景使用) */\n getAuthHeaders(): Record<string, string> {\n return this.buildAuthHeaders();\n }\n\n /** 构建鉴权相关的请求头 */\n private buildAuthHeaders(): Record<string, string> {\n if (this.auth.type === 'session') {\n return {\n TBOXSESSIONID: this.auth.session.sessionId,\n 'X-Tbox-Channel': this.auth.session.channel,\n 'X-Tbox-AppId': this.auth.session.appId,\n };\n }\n return { Authorization: this.auth.apiKey };\n }\n\n /** 构建通用请求头 */\n private buildHeaders(extra?: Record<string, string>): Record<string, string> {\n return {\n 'Content-Type': 'application/json;charset=UTF-8',\n ...this.buildAuthHeaders(),\n ...extra,\n };\n }\n\n /** 构建 FormData 请求头(不设置 Content-Type,让浏览器自动处理 boundary) */\n private buildHeadersForFormData(extra?: Record<string, string>): Record<string, string> {\n return {\n ...this.buildAuthHeaders(),\n ...extra,\n };\n }\n\n /** 发起 fetch,支持可选超时 */\n private async fetchWithTimeout(\n url: string,\n init: RequestInit,\n ): Promise<Response> {\n if (!this.timeout) {\n return fetch(url, init);\n }\n\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), this.timeout);\n try {\n return await fetch(url, { ...init, signal: controller.signal });\n } finally {\n clearTimeout(timer);\n }\n }\n\n /**\n * POST 请求\n */\n async post<T>(\n path: string,\n body: unknown,\n queryParams?: Record<string, string>,\n ): Promise<SdkResponse<T>> {\n const url = this.buildUrl(path, queryParams);\n let response: Response;\n try {\n response = await this.fetchWithTimeout(url, {\n method: 'POST',\n headers: this.buildHeaders(),\n body: JSON.stringify(body),\n });\n } catch (err) {\n return {\n success: false,\n errorCode: 'NETWORK_ERROR',\n errorMsg: err instanceof Error ? err.message : String(err),\n };\n }\n\n return this.parseResponse<T>(response);\n }\n\n /**\n * POST FormData 请求(用于文件上传)\n */\n async postFormData<T>(\n path: string,\n formData: FormData,\n queryParams?: Record<string, string>,\n ): Promise<SdkResponse<T>> {\n const url = this.buildUrl(path, queryParams);\n let response: Response;\n try {\n // FormData 请求不设置 Content-Type,让浏览器自动设置 multipart/form-data 边界\n response = await this.fetchWithTimeout(url, {\n method: 'POST',\n headers: this.buildHeadersForFormData(),\n body: formData,\n });\n } catch (err) {\n return {\n success: false,\n errorCode: 'NETWORK_ERROR',\n errorMsg: err instanceof Error ? err.message : String(err),\n };\n }\n\n return this.parseResponse<T>(response);\n }\n\n /**\n * GET 请求\n */\n async get<T>(\n path: string,\n queryParams?: Record<string, string>,\n ): Promise<SdkResponse<T>> {\n const url = this.buildUrl(path, queryParams);\n let response: Response;\n try {\n response = await this.fetchWithTimeout(url, {\n method: 'GET',\n headers: this.buildHeaders(),\n });\n } catch (err) {\n return {\n success: false,\n errorCode: 'NETWORK_ERROR',\n errorMsg: err instanceof Error ? err.message : String(err),\n };\n }\n\n return this.parseResponse<T>(response);\n }\n\n /** 构建完整 URL(含 query string) */\n private buildUrl(path: string, queryParams?: Record<string, string>): string {\n // 如果 path 已经是完整 URL(以 http:// 或 https:// 开头),直接使用\n let base: string;\n if (path.startsWith('http://') || path.startsWith('https://')) {\n base = path;\n } else {\n base = `${this._baseUrl}${path}`;\n }\n\n if (!queryParams || Object.keys(queryParams).length === 0) {\n return base;\n }\n const qs = new URLSearchParams(queryParams).toString();\n return `${base}?${qs}`;\n }\n\n /** 解析响应体 */\n private async parseResponse<T>(response: Response): Promise<SdkResponse<T>> {\n let text: string;\n try {\n const buffer = await response.arrayBuffer();\n text = new TextDecoder('utf-8').decode(buffer);\n } catch {\n return {\n success: false,\n errorCode: `HTTP_${response.status}`,\n errorMsg: `HTTP error: ${response.status} ${response.statusText}`,\n };\n }\n\n // 非 200 时也尝试解析响应体,提取服务端返回的真实错误信息\n if (!response.ok) {\n try {\n const errorJson = JSON.parse(text) as RawApiResponse<T>;\n const errorCode = errorJson.errorCode ?? errorJson.code ?? errorJson.resultCode ?? `HTTP_${response.status}`;\n const errorMsg = errorJson.errorMsg ?? errorJson.msg ?? errorJson.resultDesc ?? `HTTP error: ${response.status} ${response.statusText}`;\n return { success: false, errorCode, errorMsg };\n } catch {\n return {\n success: false,\n errorCode: `HTTP_${response.status}`,\n errorMsg: `HTTP error: ${response.status} ${response.statusText}`,\n };\n }\n }\n\n let json: RawApiResponse<T>;\n try {\n json = JSON.parse(text) as RawApiResponse<T>;\n } catch {\n return {\n success: false,\n errorCode: 'PARSE_ERROR',\n errorMsg: 'Failed to parse response JSON',\n };\n }\n\n return normalizeResponse(json);\n }\n}\n","/**\n * 百宝箱插件服务 SDK - PluginClient 核心类\n *\n * 封装 /openapi/v1/plugin 下的全部接口\n */\n\nimport { HttpClient, DEFAULT_BASE_URL } from './http';\nimport type {\n TboxPluginClientConfig,\n TtsRequest,\n TtsResponse,\n AsrRequest,\n AsrResponse,\n PluginToolExecRequest,\n PluginExecResult,\n PluginInfo,\n WebSearchRequest,\n WebSearchResponse,\n WebSearchItem,\n SdkResponse,\n} from './types';\n\n/** API 路径前缀 */\nconst API_PREFIX = '/openapi/v1/plugin';\n\n/**\n * 百宝箱插件服务客户端\n *\n * @example\n * ```ts\n * import { TboxPluginClient } from '@tbox/plugin-sdk';\n *\n * const client = new TboxPluginClient({ apiKey: 'your-api-key' });\n *\n * // 执行插件工具\n * const result = await client.run('tool-id-xxx', { params: { key: 'value' } });\n * ```\n */\nexport class TboxPluginClient {\n private readonly http: HttpClient;\n\n constructor(config: TboxPluginClientConfig) {\n this.http = new HttpClient({\n baseUrl: config.baseUrl ?? DEFAULT_BASE_URL,\n apiKey: config.apiKey,\n timeout: config.timeout,\n });\n }\n\n // ============================================================\n // TTS - 文字转语音\n // ============================================================\n\n /**\n * 文字转语音\n *\n * POST /openapi/v1/plugin/doTts\n *\n * @param request - TTS 请求参数\n * @returns 音频数据(Base64 或 URL)\n *\n * @example\n * ```ts\n * const res = await client.doTts({ text: '你好,世界' });\n * if (res.success) {\n * console.log(res.data?.audioBase64);\n * }\n * ```\n */\n async doTts(request: TtsRequest): Promise<SdkResponse<TtsResponse>> {\n return this.http.post<TtsResponse>(`${API_PREFIX}/doTts`, request);\n }\n\n // ============================================================\n // ASR - 语音转文字\n // ============================================================\n\n /**\n * 语音转文字(Base64 音频输入)\n *\n * POST /openapi/v1/plugin/asrBase64V2\n *\n * @param request - ASR 请求参数,音频以 Base64 格式传入\n * @returns 识别出的文本\n *\n * @example\n * ```ts\n * const res = await client.asrBase64({ audioBase64: '<base64-string>', format: 'mp3' });\n * if (res.success) {\n * console.log(res.data?.text);\n * }\n * ```\n */\n async asrBase64(request: AsrRequest): Promise<SdkResponse<AsrResponse>> {\n return this.http.post<AsrResponse>(`${API_PREFIX}/asrBase64V2`, request);\n }\n\n // ============================================================\n // 插件工具执行\n // ============================================================\n\n /**\n * 按工具 ID 执行插件工具\n *\n * POST /openapi/v1/plugin/run/{pluginToolId}\n *\n * 适用于已知工具 ID 的场景,调用更直接、性能更好。\n *\n * @param pluginToolId - 插件工具 ID\n * @param request - 工具执行请求(含输入参数)\n * @returns 工具执行结果\n *\n * @example\n * ```ts\n * const res = await client.run('tool-id-xxx', {\n * inputs: { city: '杭州' },\n * });\n * if (res.success) {\n * console.log(res.data?.output);\n * }\n * ```\n */\n async run(\n pluginToolId: string,\n request: PluginToolExecRequest,\n ): Promise<SdkResponse<PluginExecResult>> {\n return this.http.post<PluginExecResult>(\n `${API_PREFIX}/run/${encodeURIComponent(pluginToolId)}`,\n request,\n );\n }\n\n // ============================================================\n // 插件信息查询\n // ============================================================\n\n /**\n * 查询插件配置信息(含工具集)\n *\n * GET /openapi/v1/plugin/info/{pluginId}\n *\n * @param pluginId - 插件 ID\n * @returns 插件信息,包含插件名称、描述及工具列表\n *\n * @example\n * ```ts\n * const res = await client.getPluginInfo('plugin-id');\n * if (res.success) {\n * console.log(res.data?.pluginToolList);\n * }\n * ```\n */\n async getPluginInfo(pluginId: string): Promise<SdkResponse<PluginInfo>> {\n return this.http.get<PluginInfo>(\n `${API_PREFIX}/info/${encodeURIComponent(pluginId)}`,\n );\n }\n\n // ============================================================\n // 网络搜索\n // ============================================================\n\n /** 网络搜索工具的固定工具 ID */\n private static readonly WEB_SEARCH_TOOL_ID = '20240611204600000001';\n\n /**\n * 网络搜索\n *\n * 内部调用 run('20240611204600000001', ...) 实现,对外屏蔽工具 ID 细节。\n * 服务端响应层级:result.result.result.data[],SDK 自动解包为扁平的 items 列表。\n *\n * @param request - 搜索请求,包含关键词 q\n * @returns 搜索结果列表\n *\n * @example\n * ```ts\n * const res = await client.webSearch({ q: '上海今天天气' });\n * if (res.success) {\n * for (const item of res.data?.items ?? []) {\n * console.log(item.title, item.url);\n * }\n * }\n * ```\n */\n async webSearch(request: WebSearchRequest): Promise<SdkResponse<WebSearchResponse>> {\n // 按服务端约定,搜索关键词放在 params.q\n const raw = await this.run(TboxPluginClient.WEB_SEARCH_TOOL_ID, {\n params: { q: request.q },\n });\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n // 深层解包:raw.data → result.data[]\n // 服务端实际结构:{ cost, result: { data: [...], success, message } }\n const inner = (raw.data as Record<string, unknown> | undefined);\n const level1 = inner?.['result'] as Record<string, unknown> | undefined;\n const dataArr = level1?.['data'];\n\n const items: WebSearchItem[] = Array.isArray(dataArr)\n ? (dataArr as WebSearchItem[])\n : [];\n\n return {\n success: true,\n data: { items },\n };\n }\n\n}\n","/**\n * 百宝箱会话管理 SDK - ConversationClient 核心类\n *\n * 封装 /openapi/v1/conversation 下的全部接口\n */\n\nimport { HttpClient, DEFAULT_BASE_URL } from './http';\nimport type {\n TboxPluginClientConfig,\n MessageQueryRequest,\n MessageInfo,\n ConversationQueryRequest,\n ConversationInfo,\n ConversationCreateRequest,\n MessageSaveRequest,\n PaginationResult,\n SdkResponse,\n} from './types';\n\n/** API 路径前缀 */\nconst API_PREFIX = '/openapi/v1/conversation';\n\n/**\n * 百宝箱会话管理客户端\n *\n * @example\n * ```ts\n * import { TboxConversationClient } from '@tbox/plugin-sdk';\n *\n * const client = new TboxConversationClient({ apiKey: 'your-api-key' });\n *\n * // 创建新会话\n * const res = await client.createConversation({ agentId: 'app-id', userId: 'user-id' });\n * if (res.success) {\n * console.log('会话 ID:', res.data);\n * }\n * ```\n */\nexport class TboxConversationClient {\n private readonly http: HttpClient;\n\n constructor(config: TboxPluginClientConfig) {\n this.http = new HttpClient({\n baseUrl: config.baseUrl ?? DEFAULT_BASE_URL,\n apiKey: config.apiKey,\n timeout: config.timeout,\n });\n }\n\n // ============================================================\n // 会话管理\n // ============================================================\n\n /**\n * 创建新会话\n *\n * POST /openapi/v1/conversation/create\n *\n * @param request - 创建会话请求,包含 agentId 和 userId\n * @returns 新会话 ID(字符串)\n *\n * @example\n * ```ts\n * const res = await client.createConversation({\n * agentId: 'your-app-id',\n * userId: 'user-123',\n * });\n * if (res.success) {\n * const conversationId = res.data;\n * }\n * ```\n */\n async createConversation(\n request: ConversationCreateRequest,\n ): Promise<SdkResponse<string>> {\n return this.http.post<string>(`${API_PREFIX}/create`, request);\n }\n\n /**\n * 查询会话列表(分页)\n *\n * POST /openapi/v1/conversation/list\n *\n * @param request - 查询请求,支持按 agentId、userId 过滤,支持分页\n * @returns 分页会话列表\n *\n * @example\n * ```ts\n * const res = await client.listConversations({\n * agentId: 'your-app-id',\n * userId: 'user-123',\n * pageNum: 1,\n * pageSize: 20,\n * });\n * if (res.success) {\n * console.log(res.data?.list);\n * }\n * ```\n */\n async listConversations(\n request: ConversationQueryRequest,\n ): Promise<SdkResponse<PaginationResult<ConversationInfo>>> {\n return this.http.post<PaginationResult<ConversationInfo>>(\n `${API_PREFIX}/list`,\n request,\n );\n }\n\n // ============================================================\n // 消息管理\n // ============================================================\n\n /**\n * 查询消息列表(分页)\n *\n * POST /openapi/v1/conversation/message/list\n *\n * @param request - 查询请求,支持按 conversationId、agentId、userId 过滤,支持分页\n * @returns 分页消息列表\n *\n * @example\n * ```ts\n * const res = await client.listMessages({\n * conversationId: 'conv-id-xxx',\n * pageNum: 1,\n * pageSize: 20,\n * });\n * if (res.success) {\n * console.log(res.data?.list);\n * }\n * ```\n */\n async listMessages(\n request: MessageQueryRequest,\n ): Promise<SdkResponse<PaginationResult<MessageInfo>>> {\n return this.http.post<PaginationResult<MessageInfo>>(\n `${API_PREFIX}/message/list`,\n request,\n );\n }\n\n /**\n * 新增会话消息\n *\n * POST /openapi/v1/conversation/message/save\n *\n * 将一条对话消息(问题 + 回答)保存到指定会话中。\n *\n * @param request - 保存消息请求\n * @returns 消息 ID(字符串)\n *\n * @example\n * ```ts\n * const res = await client.saveMessage({\n * conversationId: 'conv-id-xxx',\n * query: '今天天气怎么样?',\n * answer: '今天杭州晴天,25°C。',\n * });\n * if (res.success) {\n * const messageId = res.data;\n * }\n * ```\n */\n async saveMessage(\n request: MessageSaveRequest,\n ): Promise<SdkResponse<string>> {\n return this.http.post<string>(`${API_PREFIX}/message/save`, request);\n }\n}\n","/**\n * 百宝箱插件服务 SDK - 应用服务客户端\n *\n * 封装 /openapi/v1/app 下的接口\n */\n\nimport { HttpClient, DEFAULT_BASE_URL } from './http';\nimport type { SdkResponse, AppGenerateSessionRequest, AppSessionResult, TboxPluginClientConfig } from './types';\n\n/**\n * 百宝箱应用服务客户端\n *\n * @example\n * ```ts\n * const client = new TboxAppClient({ apiKey: 'your-api-key' });\n *\n * // 生成 sessionId,用于免登录访问百宝箱应用\n * const result = await client.generateSession({\n * appId: 'your-app-id',\n * userId: 'user-123',\n * userInfo: [\n * { infoType: 'name', infoValue: '张三' },\n * ],\n * deviceInfo: {\n * platform: 'IOS',\n * appVersion: '1.0.0',\n * },\n * });\n *\n * if (result.success) {\n * console.log('sessionId:', result.data?.sessionId);\n * console.log('channel:', result.data?.channel);\n * }\n * ```\n */\nexport class TboxAppClient {\n private readonly http: HttpClient;\n\n constructor(config: TboxPluginClientConfig) {\n this.http = new HttpClient({\n baseUrl: config.baseUrl ?? DEFAULT_BASE_URL,\n apiKey: config.apiKey,\n timeout: config.timeout,\n });\n }\n\n /**\n * 根据用户信息生成 sessionId 和 channel\n *\n * 接口:POST /openapi/v1/app/generate_session\n *\n * 生成的 sessionId 可用于拼接百宝箱 H5 访问链接,实现免登录跳转。\n *\n * @param request 请求参数,appId 和 userId 为必填\n * @returns sessionId 和 channel\n */\n async generateSession(\n request: AppGenerateSessionRequest,\n ): Promise<SdkResponse<AppSessionResult>> {\n return this.http.post<AppSessionResult>(\n '/openapi/v1/app/generate_session',\n request,\n );\n }\n}\n","/**\n * 百宝箱首页开场白 SDK - HomepageClient 核心类\n *\n * 封装 /agent/v1/homepage 下的接口。\n * 该接口走 C端鉴权(TBOXSESSIONID + X-Tbox-Channel + X-Tbox-AppId)。\n */\n\nimport { HttpClient, DEFAULT_BASE_URL } from './http';\nimport { TboxAppClient } from './app';\nimport type {\n TboxSessionClientConfig,\n TboxPluginClientConfig,\n CreateSessionClientOptions,\n SdkResponse,\n HomepageGetRequest,\n HomepageGetResponse,\n} from './types';\n\n/** API 路径前缀 */\nconst API_PREFIX = '/agent/v1/homepage';\n\n/**\n * 百宝箱首页开场白客户端(C端鉴权)\n *\n * @example\n * ```ts\n * import { TboxHomepageClient } from '@tbox-dev-js/sdk';\n *\n * // 方式一:自动获取 session(推荐)\n * const client = await TboxHomepageClient.create({\n * apiKey: 'your-api-key',\n * appId: '202508APhciU03604644',\n * userId: 'user-123',\n * });\n *\n * // 方式二:手动传入 session\n * const client = new TboxHomepageClient({\n * session: { sessionId: 'xxx', channel: 'alipay_mini_app', appId: '202508APhciU03604644' },\n * });\n *\n * const result = await client.get({ agentId: '202508APhciU03604644' });\n * if (result.success) {\n * console.log('开场白:', result.data?.prologue);\n * }\n * ```\n */\nexport class TboxHomepageClient {\n private readonly http: HttpClient;\n\n /**\n * 使用 C端 Session 鉴权构造\n */\n constructor(config: TboxSessionClientConfig) {\n this.http = new HttpClient({\n baseUrl: config.baseUrl ?? DEFAULT_BASE_URL,\n auth: { type: 'session', session: config.session },\n timeout: config.timeout,\n });\n }\n\n /**\n * 便捷工厂方法:通过 B端 apiKey 自动获取 session 并创建 C端客户端\n *\n * 内部流程:\n * 1. 使用 apiKey 调用 TboxAppClient.generateSession() 获取 sessionId + channel\n * 2. 用获取到的 session 信息创建 C端鉴权的 HomepageClient\n *\n * @param options - 创建参数(apiKey、appId、userId)\n * @returns 已鉴权的 TboxHomepageClient 实例\n *\n * @example\n * ```ts\n * const client = await TboxHomepageClient.create({\n * apiKey: 'your-api-key',\n * appId: '202508APhciU03604644',\n * userId: 'user-123',\n * });\n * ```\n */\n static async create(options: CreateSessionClientOptions): Promise<TboxHomepageClient> {\n const appClient = new TboxAppClient({\n apiKey: options.apiKey,\n baseUrl: options.baseUrl,\n timeout: options.timeout,\n });\n\n const sessionResult = await appClient.generateSession({\n appId: options.appId,\n userId: options.userId,\n });\n\n if (!sessionResult.success || !sessionResult.data?.sessionId || !sessionResult.data?.channel) {\n throw new Error(\n `Failed to generate session: ${sessionResult.errorCode ?? 'UNKNOWN'} - ${sessionResult.errorMsg ?? 'No session data returned'}`,\n );\n }\n\n return new TboxHomepageClient({\n session: {\n sessionId: sessionResult.data.sessionId,\n channel: sessionResult.data.channel,\n appId: options.appId,\n },\n baseUrl: options.baseUrl,\n timeout: options.timeout,\n });\n }\n\n /**\n * 获取首页开场白\n *\n * POST /agent/v1/homepage/get\n *\n * @param request - 请求参数,agentId 为必填\n * @returns 开场白信息,包含开场白文本、推荐问题等\n *\n * @example\n * ```ts\n * const res = await client.get({\n * agentId: '202508APhciU03604644',\n * extInfo: '{}',\n * });\n * if (res.success) {\n * console.log(res.data?.prologue);\n * }\n * ```\n */\n async get(request: HomepageGetRequest): Promise<SdkResponse<HomepageGetResponse>> {\n return this.http.post<HomepageGetResponse>(`${API_PREFIX}/get`, request);\n }\n}\n","/**\n * 高德地图 SDK - AmapClient 核心类\n *\n * 封装高德地图天气查询工具(amap_weather),\n * 通过百宝箱插件服务 /openapi/v1/plugin/run/{pluginToolId} 接口调用。\n */\n\nimport { HttpClient, DEFAULT_BASE_URL } from './http';\nimport type {\n AmapClientConfig,\n AmapConvertRequest,\n AmapConvertResponse,\n AmapCyclingRouteRequest,\n AmapCyclingRouteResponse,\n AmapDistrictRequest,\n AmapDistrictResponse,\n AmapDrivingRouteRequest,\n AmapDrivingRouteResponse,\n AmapEbikeRouteRequest,\n AmapEbikeRouteResponse,\n AmapGeocodeRequest,\n AmapGeocodeResponse,\n AmapIpLocationRequest,\n AmapIpLocationResponse,\n AmapPeripheralSearchRequest,\n AmapPeripheralSearchResponse,\n AmapPoiSearchRequest,\n AmapPoiSearchResponse,\n AmapRegeocodeRequest,\n AmapRegeocodeResponse,\n AmapTransitRouteRequest,\n AmapTransitRouteResponse,\n AmapWalkingRouteRequest,\n AmapWalkingRouteResponse,\n AmapWeatherRequest,\n AmapWeatherResponse,\n PluginExecResult,\n SdkResponse,\n} from './types';\n\n/** API 路径前缀 */\nconst API_PREFIX = '/openapi/v1/plugin';\n\n/**\n * 高德地图客户端\n *\n * @example\n * ```ts\n * import { AmapClient } from '@tbox/plugin-sdk';\n *\n * const client = new AmapClient({ apiKey: 'your-api-key' });\n *\n * // 查询实况天气\n * const res = await client.weather({ city: '杭州市' });\n * if (res.success) {\n * console.log(res.data?.lives?.[0]?.weather);\n * }\n *\n * // 查询预报天气\n * const forecast = await client.weather({ city: '上海市', extensions: 'all' });\n * if (forecast.success) {\n * console.log(forecast.data?.forecasts?.[0]?.casts);\n * }\n * ```\n */\nexport class AmapClient {\n private readonly http: HttpClient;\n\n /** 高德天气查询工具的固定工具 ID */\n private static readonly AMAP_WEATHER_TOOL_ID = '20240627231800002183';\n\n /** 高德地址转经纬度工具的固定工具 ID */\n private static readonly AMAP_GEOCODE_TOOL_ID = '20240627233200002185';\n\n /** 高德骑行路线规划工具的固定工具 ID */\n private static readonly AMAP_CYCLING_ROUTE_TOOL_ID = '20240627233900002186';\n\n /** 高德 IP 定位工具的固定工具 ID */\n private static readonly AMAP_IP_LOCATION_TOOL_ID = '20240627235900002187';\n\n /** 高德周边搜索工具的固定工具 ID */\n private static readonly AMAP_PERIPHERAL_SEARCH_TOOL_ID = '20240628000200002188';\n\n /** 高德步行路线规划工具的固定工具 ID */\n private static readonly AMAP_WALKING_ROUTE_TOOL_ID = '20240628000400002189';\n\n /** 高德驾车路线规划工具的固定工具 ID */\n private static readonly AMAP_DRIVING_ROUTE_TOOL_ID = '20240628000900002190';\n\n /** 高德电动车路线规划工具的固定工具 ID */\n private static readonly AMAP_EBIKE_ROUTE_TOOL_ID = '20240628001000002191';\n\n /** 高德公交路线规划工具的固定工具 ID */\n private static readonly AMAP_TRANSIT_ROUTE_TOOL_ID = '20240628001100002192';\n\n /** 高德行政区域查询工具的固定工具 ID */\n private static readonly AMAP_DISTRICT_TOOL_ID = '20240628001200002193';\n\n /** 高德经纬度转地址工具的固定工具 ID */\n private static readonly AMAP_REGEOCODE_TOOL_ID = '20240629202400006671';\n\n /** 高德坐标转换工具的固定工具 ID */\n private static readonly AMAP_CONVERT_TOOL_ID = '20251110ArTR04496110';\n\n /** 高德 POI 关键字搜索工具的固定工具 ID */\n private static readonly AMAP_POI_SEARCH_TOOL_ID = '20251110crvO04497983';\n\n constructor(config: AmapClientConfig) {\n this.http = new HttpClient({\n baseUrl: config.baseUrl ?? DEFAULT_BASE_URL,\n apiKey: config.apiKey,\n timeout: config.timeout,\n });\n }\n\n // ============================================================\n // 天气查询\n // ============================================================\n\n /**\n * 查询天气(实况或预报)\n *\n * 内部调用 run('20240627231800002183', ...) 实现,对外屏蔽工具 ID 细节。\n * 数据来源于中国气象局。\n *\n * @param request - 天气查询请求\n * - `city`(必填):省份名、市名、区/县/镇、乡/村或具体地点\n * - `extensions`(可选):`base`(实况,默认)或 `all`(预报)\n * @returns 天气查询结果\n * - `extensions=base` 时,`data.lives` 包含实况天气数据\n * - `extensions=all` 时,`data.forecasts` 包含逐日预报数据\n *\n * @example\n * ```ts\n * // 查询实况天气\n * const live = await client.weather({ city: '西湖区' });\n * if (live.success) {\n * const w = live.data?.lives?.[0];\n * console.log(`${w?.city} ${w?.weather} ${w?.temperature}℃`);\n * }\n *\n * // 查询未来几天预报\n * const forecast = await client.weather({ city: '北京市', extensions: 'all' });\n * if (forecast.success) {\n * for (const cast of forecast.data?.forecasts?.[0]?.casts ?? []) {\n * console.log(`${cast.date} 白天:${cast.dayweather} 夜间:${cast.nightweather}`);\n * }\n * }\n * ```\n */\n async weather(request: AmapWeatherRequest): Promise<SdkResponse<AmapWeatherResponse>> {\n const params: Record<string, unknown> = { city: request.city };\n if (request.extensions !== undefined) {\n params['extensions'] = request.extensions;\n }\n\n const raw = await this.http.post<PluginExecResult>(\n `${API_PREFIX}/run/${encodeURIComponent(AmapClient.AMAP_WEATHER_TOOL_ID)}`,\n { params },\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n // 从 raw.data.result 中解包天气数据\n // 服务端实际结构:{ success, result: { status, info, infocode, count, lives?, forecasts? }, cost, traceId }\n const execResult = raw.data as PluginExecResult | undefined;\n const weatherData = execResult?.result as AmapWeatherResponse | undefined;\n\n return {\n success: true,\n data: weatherData ?? {},\n };\n }\n\n // ============================================================\n // 地址转经纬度\n // ============================================================\n\n /**\n * 地址转经纬度(地理编码)\n *\n * 将详细的地名,转换为经纬度坐标。\n * 内部调用 run('20240627233200002185', ...) 实现,对外屏蔽工具 ID 细节。\n *\n * @param request - 地址转经纬度请求\n * - `address`(必填):详细地址信息(国家、省份、城市、区县、城镇、乡村、街道、门牌号)\n * - `city`(可选):查询的城市,指定可提高查询精度\n * @returns 地理编码结果\n * - `data.geocodes` 包含地理编码信息列表\n *\n * @example\n * ```ts\n * // 地址转经纬度\n * const res = await client.geocode({ address: '北京市朝阳区阜通东大街6号', city: '北京' });\n * if (res.success) {\n * const geo = res.data?.geocodes?.[0];\n * console.log(`地址: ${geo?.formatted_address}`);\n * console.log(`经纬度: ${geo?.location}`);\n * console.log(`区域编码: ${geo?.adcode}`);\n * }\n * ```\n */\n async geocode(request: AmapGeocodeRequest): Promise<SdkResponse<AmapGeocodeResponse>> {\n const params: Record<string, unknown> = { address: request.address };\n if (request.city !== undefined) {\n params['city'] = request.city;\n }\n\n const raw = await this.http.post<PluginExecResult>(\n `${API_PREFIX}/run/${encodeURIComponent(AmapClient.AMAP_GEOCODE_TOOL_ID)}`,\n { params },\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n // 从 raw.data.result 中解包地理编码数据\n // 服务端实际结构:{ success, result: { code, status, infocode, count, geocodes? }, cost, traceId }\n const execResult = raw.data as PluginExecResult | undefined;\n const geocodeData = execResult?.result as AmapGeocodeResponse | undefined;\n\n return {\n success: true,\n data: geocodeData ?? {},\n };\n }\n\n // ============================================================\n // 骑行路线规划\n // ============================================================\n\n /**\n * 骑行路线规划\n *\n * 提供起点和终点的位置,返回骑行路线,支持多条路线。\n *\n * @param request - 骑行路线规划请求\n * - `origin`(必填):起点位置名称\n * - `destination`(必填):终点位置名称\n * @returns 骑行路线规划结果\n *\n * @example\n * ```ts\n * const res = await client.cyclingRoute({\n * origin: '杭州市西湖区',\n * destination: '杭州市余杭区'\n * });\n * if (res.success) {\n * const path = res.data?.route?.paths?.[0];\n * console.log(`距离: ${path?.distance}米, 时间: ${path?.duration}秒`);\n * }\n * ```\n */\n async cyclingRoute(\n request: AmapCyclingRouteRequest,\n ): Promise<SdkResponse<AmapCyclingRouteResponse>> {\n const params: Record<string, unknown> = {\n origin: request.origin,\n destination: request.destination,\n };\n\n const raw = await this.http.post<PluginExecResult>(\n `${API_PREFIX}/run/${encodeURIComponent(AmapClient.AMAP_CYCLING_ROUTE_TOOL_ID)}`,\n { params },\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n const execResult = raw.data as PluginExecResult | undefined;\n const routeData = execResult?.result as AmapCyclingRouteResponse | undefined;\n\n return {\n success: true,\n data: routeData ?? {},\n };\n }\n\n // ============================================================\n // IP 定位\n // ============================================================\n\n /**\n * IP 定位\n *\n * 定位输入的 IP 所在的地理位置(暂不支持 IPv6)。\n *\n * @param request - IP 定位请求\n * - `ip`(必填):需要定位的 IP 地址\n * @returns IP 定位结果\n *\n * @example\n * ```ts\n * const res = await client.ipLocation({ ip: '114.114.114.114' });\n * if (res.success) {\n * console.log(`省份: ${res.data?.province}, 城市: ${res.data?.city}`);\n * }\n * ```\n */\n async ipLocation(request: AmapIpLocationRequest): Promise<SdkResponse<AmapIpLocationResponse>> {\n const params: Record<string, unknown> = { ip: request.ip };\n\n const raw = await this.http.post<PluginExecResult>(\n `${API_PREFIX}/run/${encodeURIComponent(AmapClient.AMAP_IP_LOCATION_TOOL_ID)}`,\n { params },\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n const execResult = raw.data as PluginExecResult | undefined;\n const locationData = execResult?.result as AmapIpLocationResponse | undefined;\n\n return {\n success: true,\n data: locationData ?? {},\n };\n }\n\n // ============================================================\n // 周边搜索\n // ============================================================\n\n /**\n * 周边搜索\n *\n * 根据指定地点和关键词,搜索周边景点、美食、酒店、运动场所等。\n *\n * @param request - 周边搜索请求\n * - `address`(必填):中心点地址信息\n * - `keyword`(必填):检索关键词(景点、美食、游玩区域等,不超过 80 字符)\n * - `count`(可选):返回条数,默认 5\n * - `radius`(可选):搜索半径(米),范围 0-50000\n * @returns 周边搜索结果\n *\n * @example\n * ```ts\n * const res = await client.peripheralSearch({\n * address: '杭州市西湖区',\n * keyword: '美食',\n * count: 10,\n * radius: 1000\n * });\n * if (res.success) {\n * for (const poi of res.data?.pois ?? []) {\n * console.log(`${poi.name} - ${poi.address}`);\n * }\n * }\n * ```\n */\n async peripheralSearch(\n request: AmapPeripheralSearchRequest,\n ): Promise<SdkResponse<AmapPeripheralSearchResponse>> {\n const params: Record<string, unknown> = {\n address: request.address,\n keyword: request.keyword,\n };\n if (request.count !== undefined) {\n params['count'] = request.count;\n }\n if (request.radius !== undefined) {\n params['radius'] = request.radius;\n }\n\n const raw = await this.http.post<PluginExecResult>(\n `${API_PREFIX}/run/${encodeURIComponent(AmapClient.AMAP_PERIPHERAL_SEARCH_TOOL_ID)}`,\n { params },\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n const execResult = raw.data as PluginExecResult | undefined;\n const searchData = execResult?.result as AmapPeripheralSearchResponse | undefined;\n\n return {\n success: true,\n data: searchData ?? {},\n };\n }\n\n // ============================================================\n // 步行路线规划\n // ============================================================\n\n /**\n * 步行路线规划\n *\n * 提供起点和终点的位置,返回步行路线,支持多条路线。\n *\n * @param request - 步行路线规划请求\n * - `origin`(必填):起点地址\n * - `destination`(必填):终点地址\n * @returns 步行路线规划结果\n *\n * @example\n * ```ts\n * const res = await client.walkingRoute({\n * origin: '杭州市西湖区古荡',\n * destination: '杭州市西湖区西溪湿地'\n * });\n * if (res.success) {\n * const path = res.data?.route?.paths?.[0];\n * console.log(`距离: ${path?.distance}米, 时间: ${path?.duration}秒`);\n * }\n * ```\n */\n async walkingRoute(\n request: AmapWalkingRouteRequest,\n ): Promise<SdkResponse<AmapWalkingRouteResponse>> {\n const params: Record<string, unknown> = {\n origin: request.origin,\n destination: request.destination,\n };\n\n const raw = await this.http.post<PluginExecResult>(\n `${API_PREFIX}/run/${encodeURIComponent(AmapClient.AMAP_WALKING_ROUTE_TOOL_ID)}`,\n { params },\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n const execResult = raw.data as PluginExecResult | undefined;\n const routeData = execResult?.result as AmapWalkingRouteResponse | undefined;\n\n return {\n success: true,\n data: routeData ?? {},\n };\n }\n\n // ============================================================\n // 驾车路线规划\n // ============================================================\n\n /**\n * 驾车路线规划\n *\n * 提供起点和终点的位置,返回驾车路线,支持多条路线。\n *\n * @param request - 驾车路线规划请求\n * - `origin`(必填):起点地址或经纬度\n * - `destination`(必填):终点地址或经纬度\n * @returns 驾车路线规划结果\n *\n * @example\n * ```ts\n * const res = await client.drivingRoute({\n * origin: '杭州西溪湿地',\n * destination: '绍兴市'\n * });\n * if (res.success) {\n * const path = res.data?.route?.paths?.[0];\n * console.log(`距离: ${path?.distance}米, 时间: ${path?.duration}秒`);\n * console.log(`出租车费用: ${res.data?.route?.taxi_cost}元`);\n * }\n * ```\n */\n async drivingRoute(\n request: AmapDrivingRouteRequest,\n ): Promise<SdkResponse<AmapDrivingRouteResponse>> {\n const params: Record<string, unknown> = {\n origin: request.origin,\n destination: request.destination,\n };\n\n const raw = await this.http.post<PluginExecResult>(\n `${API_PREFIX}/run/${encodeURIComponent(AmapClient.AMAP_DRIVING_ROUTE_TOOL_ID)}`,\n { params },\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n const execResult = raw.data as PluginExecResult | undefined;\n const routeData = execResult?.result as AmapDrivingRouteResponse | undefined;\n\n return {\n success: true,\n data: routeData ?? {},\n };\n }\n\n // ============================================================\n // 电动车路线规划\n // ============================================================\n\n /**\n * 电动车路线规划\n *\n * 提供起点和终点的位置,返回电动车骑行路线,支持多条路线。\n *\n * @param request - 电动车路线规划请求\n * - `origin`(必填):起点地址或经纬度\n * - `destination`(必填):终点地址或经纬度\n * @returns 电动车路线规划结果\n *\n * @example\n * ```ts\n * const res = await client.ebikeRoute({\n * origin: '杭州市西湖区',\n * destination: '杭州市余杭区'\n * });\n * if (res.success) {\n * const path = res.data?.route?.paths?.[0];\n * console.log(`距离: ${path?.distance}米, 时间: ${path?.duration}秒`);\n * }\n * ```\n */\n async ebikeRoute(\n request: AmapEbikeRouteRequest,\n ): Promise<SdkResponse<AmapEbikeRouteResponse>> {\n const params: Record<string, unknown> = {\n origin: request.origin,\n destination: request.destination,\n };\n\n const raw = await this.http.post<PluginExecResult>(\n `${API_PREFIX}/run/${encodeURIComponent(AmapClient.AMAP_EBIKE_ROUTE_TOOL_ID)}`,\n { params },\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n const execResult = raw.data as PluginExecResult | undefined;\n const routeData = execResult?.result as AmapEbikeRouteResponse | undefined;\n\n return {\n success: true,\n data: routeData ?? {},\n };\n }\n\n // ============================================================\n // 公交路线规划\n // ============================================================\n\n /**\n * 公交路线规划\n *\n * 提供起点和终点的位置,返回公交换乘方案,支持多条路线。\n *\n * @param request - 公交路线规划请求\n * - `origin`(必填):起点地址或经纬度\n * - `destination`(必填):终点地址或经纬度\n * @returns 公交路线规划结果\n *\n * @example\n * ```ts\n * const res = await client.transitRoute({\n * origin: '杭州火车站',\n * destination: '西湖'\n * });\n * if (res.success) {\n * for (const transit of res.data?.route?.transits ?? []) {\n * console.log(`费用: ${transit.cost}元, 时间: ${transit.duration}秒`);\n * }\n * }\n * ```\n */\n async transitRoute(\n request: AmapTransitRouteRequest,\n ): Promise<SdkResponse<AmapTransitRouteResponse>> {\n const params: Record<string, unknown> = {\n origin: request.origin,\n destination: request.destination,\n };\n\n const raw = await this.http.post<PluginExecResult>(\n `${API_PREFIX}/run/${encodeURIComponent(AmapClient.AMAP_TRANSIT_ROUTE_TOOL_ID)}`,\n { params },\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n const execResult = raw.data as PluginExecResult | undefined;\n const routeData = execResult?.result as AmapTransitRouteResponse | undefined;\n\n return {\n success: true,\n data: routeData ?? {},\n };\n }\n\n // ============================================================\n // 行政区域查询\n // ============================================================\n\n /**\n * 行政区域查询\n *\n * 根据用户输入,快速查找特定的行政区域信息。\n *\n * @param request - 行政区域查询请求\n * - `keywords`(必填):查询关键字(行政区名称、citycode、adcode)\n * @returns 行政区域查询结果\n *\n * @example\n * ```ts\n * const res = await client.district({ keywords: '成都市' });\n * if (res.success) {\n * for (const district of res.data?.districts ?? []) {\n * console.log(`${district.name} (${district.adcode})`);\n * }\n * }\n * ```\n */\n async district(request: AmapDistrictRequest): Promise<SdkResponse<AmapDistrictResponse>> {\n const params: Record<string, unknown> = { keywords: request.keywords };\n\n const raw = await this.http.post<PluginExecResult>(\n `${API_PREFIX}/run/${encodeURIComponent(AmapClient.AMAP_DISTRICT_TOOL_ID)}`,\n { params },\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n const execResult = raw.data as PluginExecResult | undefined;\n const districtData = execResult?.result as AmapDistrictResponse | undefined;\n\n return {\n success: true,\n data: districtData ?? {},\n };\n }\n\n // ============================================================\n // 经纬度转地址(逆地理编码)\n // ============================================================\n\n /**\n * 经纬度转地址(逆地理编码)\n *\n * 将经纬度转换为详细的地址,且返回附近周边的 POI、AOI 信息。\n *\n * @param request - 经纬度转地址请求\n * - `location`(必填):经纬度坐标(经度在前,纬度在后,英文逗号分隔)\n * - `extensions`(可选):base(基本地址)/ all(详细信息)\n * @returns 逆地理编码结果\n *\n * @example\n * ```ts\n * const res = await client.regeocode({\n * location: '116.480881,39.989410',\n * extensions: 'base'\n * });\n * if (res.success) {\n * console.log(`地址: ${res.data?.regeocode?.formatted_address}`);\n * }\n * ```\n */\n async regeocode(request: AmapRegeocodeRequest): Promise<SdkResponse<AmapRegeocodeResponse>> {\n const params: Record<string, unknown> = { location: request.location };\n if (request.extensions !== undefined) {\n params['extensions'] = request.extensions;\n }\n\n const raw = await this.http.post<PluginExecResult>(\n `${API_PREFIX}/run/${encodeURIComponent(AmapClient.AMAP_REGEOCODE_TOOL_ID)}`,\n { params },\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n const execResult = raw.data as PluginExecResult | undefined;\n const regeocodeData = execResult?.result as AmapRegeocodeResponse | undefined;\n\n return {\n success: true,\n data: regeocodeData ?? {},\n };\n }\n\n // ============================================================\n // 坐标转换\n // ============================================================\n\n /**\n * 坐标转换\n *\n * 将非高德坐标(GPS、mapbar、baidu 坐标)转换成高德坐标。\n *\n * @param request - 坐标转换请求\n * - `locations`(必填):坐标点(经纬度用逗号分隔,多个坐标用 \"|\" 分隔,最多 40 个)\n * - `coordsys`(必填):原坐标系(gps / mapbar / baidu / autonavi)\n * @returns 坐标转换结果\n *\n * @example\n * ```ts\n * const res = await client.convert({\n * locations: '116.481488,39.990464',\n * coordsys: 'baidu'\n * });\n * if (res.success) {\n * console.log(`转换后的坐标: ${res.data?.locations}`);\n * }\n * ```\n */\n async convert(request: AmapConvertRequest): Promise<SdkResponse<AmapConvertResponse>> {\n const params: Record<string, unknown> = {\n locations: request.locations,\n coordsys: request.coordsys,\n };\n\n const raw = await this.http.post<PluginExecResult>(\n `${API_PREFIX}/run/${encodeURIComponent(AmapClient.AMAP_CONVERT_TOOL_ID)}`,\n { params },\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n const execResult = raw.data as PluginExecResult | undefined;\n const convertData = execResult?.result as AmapConvertResponse | undefined;\n\n return {\n success: true,\n data: convertData ?? {},\n };\n }\n\n // ============================================================\n // POI 关键字搜索\n // ============================================================\n\n /**\n * POI 关键字搜索\n *\n * 通过文本关键字搜索地点信息,支持结构化地址和 POI 名称搜索。\n *\n * @param request - POI 关键字搜索请求\n * - `keywords`(可选):查询关键字\n * - `types`(可选):指定地点类型\n * - `region`(可选):搜索区划(默认全国)\n * - `city_limit`(可选):是否限制在 region 内(true / false)\n * - `page_size`(可选):每页数据条数(1-25)\n * - `page_num`(可选):分页页码(1-100)\n * @returns POI 搜索结果\n *\n * @example\n * ```ts\n * const res = await client.poiSearch({\n * keywords: '首开广场',\n * region: '北京',\n * page_size: '10',\n * page_num: '1'\n * });\n * if (res.success) {\n * for (const poi of res.data?.pois ?? []) {\n * console.log(`${poi.name} - ${poi.address}`);\n * }\n * }\n * ```\n */\n async poiSearch(request: AmapPoiSearchRequest): Promise<SdkResponse<AmapPoiSearchResponse>> {\n const params: Record<string, unknown> = {};\n if (request.keywords !== undefined) {\n params['keywords'] = request.keywords;\n }\n if (request.types !== undefined) {\n params['types'] = request.types;\n }\n if (request.region !== undefined) {\n params['region'] = request.region;\n }\n if (request.city_limit !== undefined) {\n params['city_limit'] = request.city_limit;\n }\n if (request.page_size !== undefined) {\n params['page_size'] = request.page_size;\n }\n if (request.page_num !== undefined) {\n params['page_num'] = request.page_num;\n }\n\n const raw = await this.http.post<PluginExecResult>(\n `${API_PREFIX}/run/${encodeURIComponent(AmapClient.AMAP_POI_SEARCH_TOOL_ID)}`,\n { params },\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n const execResult = raw.data as PluginExecResult | undefined;\n const poiData = execResult?.result as AmapPoiSearchResponse | undefined;\n\n return {\n success: true,\n data: poiData ?? {},\n };\n }\n}\n","/**\n * 知识库 SDK - KnowledgeClient 核心类\n *\n * 封装知识库管理功能,通过百宝箱服务接口实现知识库的创建和管理。\n */\n\nimport { HttpClient, DEFAULT_BASE_URL } from './http';\nimport type {\n KnowledgeClientConfig,\n KnowledgeCreateRequest,\n KnowledgeCreateResponse,\n KnowledgeUpdateRequest,\n KnowledgeUpdateResponse,\n KnowledgeQueryListRequest,\n KnowledgeQueryListResponse,\n KnowledgeRetrieveRequest,\n KnowledgeRetrieveResponse,\n SdkResponse,\n} from './types';\n\n/** API 路径前缀 */\nconst API_PREFIX = '/openapi/v1';\n\n/**\n * 知识库客户端\n *\n * @example\n * ```ts\n * import { KnowledgeClient } from '@tbox/plugin-sdk';\n *\n * const client = new KnowledgeClient({ apiKey: 'your-api-key' });\n *\n * // 创建结构化知识库\n * const res = await client.createKnowledgeBase({\n * file: fileBlob,\n * type: 'STRUCTURED',\n * tableSchema: {\n * columns: [\n * { name: 'id', dataType: 'STRING', required: true, order: 1 },\n * { name: 'name', dataType: 'STRING', required: false, order: 2 }\n * ],\n * name: '示例表'\n * },\n * indexColumns: ['id']\n * });\n * if (res.success) {\n * console.log(`文档 ID: ${res.data?.documentId}`);\n * }\n * ```\n */\nexport class KnowledgeClient {\n private readonly http: HttpClient;\n\n constructor(config: KnowledgeClientConfig) {\n this.http = new HttpClient({\n baseUrl: config.baseUrl ?? DEFAULT_BASE_URL,\n apiKey: config.apiKey,\n timeout: config.timeout,\n });\n }\n\n // ============================================================\n // 创建知识库\n // ============================================================\n\n /**\n * 创建知识库\n *\n * 通过上传文件创建知识库,支持结构化和非结构化数据。\n *\n * @param request - 创建知识库请求\n * - `file`(必填):上传的文件(如 .xlsx、.pdf 等)\n * - `type`(必填):数据类型,`STRUCTURED`(结构化)或其他类型\n * - `tableSchema`(条件必填):表格 Schema 定义,当 type = STRUCTURED 时必填\n * - `indexColumns`(条件必填):索引列名列表,当 type = STRUCTURED 时必填\n * @returns 创建知识库结果\n *\n * @example\n * ```ts\n * // 从本地文件创建结构化知识库\n * const fileInput = document.querySelector('input[type=\"file\"]');\n * const file = fileInput.files[0];\n *\n * const res = await client.createKnowledgeBase({\n * file: file,\n * type: 'STRUCTURED',\n * tableSchema: {\n * columns: [\n * { name: 'id', dataType: 'STRING', required: true, order: 1 },\n * { name: 'message_id', dataType: 'STRING', required: false, order: 2 },\n * { name: 'content', dataType: 'STRING', required: false, order: 3 }\n * ],\n * name: '消息记录',\n * description: '用于存储消息数据'\n * },\n * indexColumns: ['id', 'message_id']\n * });\n *\n * if (res.success) {\n * console.log(`创建成功,文档 ID: ${res.data?.documentId}`);\n * } else {\n * console.error(`创建失败: ${res.errorMsg}`);\n * }\n * ```\n */\n async createKnowledgeBase(\n request: KnowledgeCreateRequest,\n ): Promise<SdkResponse<KnowledgeCreateResponse>> {\n // 构建 FormData\n const formData = new FormData();\n formData.append('file', request.file);\n formData.append('type', request.type);\n\n // 当 type 为 STRUCTURED 时,需要添加 tableSchema 和 indexColumns\n if (request.type === 'STRUCTURED') {\n if (request.tableSchema) {\n formData.append('tableSchema', JSON.stringify(request.tableSchema));\n }\n if (request.indexColumns && request.indexColumns.length > 0) {\n // indexColumns 作为数组传递,每个元素单独 append\n for (const col of request.indexColumns) {\n formData.append('indexColumns', col);\n }\n }\n }\n\n const raw = await this.http.postFormData<KnowledgeCreateResponse>(\n `${API_PREFIX}/knowledge/createKnowledgeBaseByDataSet`,\n formData,\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n return {\n success: true,\n data: raw.data,\n };\n }\n\n // ============================================================\n // 更新知识库\n // ============================================================\n\n /**\n * 更新知识库\n *\n * 通过上传文件更新已有的知识库文档,支持覆盖更新和增量更新。\n *\n * @param request - 更新知识库请求\n * - `file`(必填):上传的文件(如 .xlsx、.pdf 等)\n * - `type`(必填):数据类型,`STRUCTURED`(结构化)或其他类型\n * - `documentId`(必填):要更新的文档 ID(从创建响应中获取)\n * - `tableSchema`(可选):表格 Schema 定义,结构化数据需要\n * - `updateMode`(可选):更新模式,`OVERWRITE`(覆盖更新)或 `UPSERT`(增量更新,默认)\n * @returns 更新知识库结果\n *\n * @example\n * ```ts\n * // 覆盖更新知识库\n * const res = await client.updateKnowledgeBase({\n * file: newFile,\n * type: 'STRUCTURED',\n * documentId: '20251128999def29600J6WS04301922',\n * tableSchema: {\n * columns: [\n * { name: 'id', dataType: 'STRING', required: true, order: 1 },\n * { name: 'message_id', dataType: 'STRING', required: false, order: 2 },\n * { name: 'content', dataType: 'STRING', required: false, order: 3 }\n * ],\n * name: '消息记录'\n * },\n * updateMode: 'OVERWRITE'\n * });\n *\n * if (res.success) {\n * console.log(`更新成功,文档 ID: ${res.data?.documentId}`);\n * } else {\n * console.error(`更新失败: ${res.errorMsg}`);\n * }\n * ```\n */\n async updateKnowledgeBase(\n request: KnowledgeUpdateRequest,\n ): Promise<SdkResponse<KnowledgeUpdateResponse>> {\n // 构建 FormData\n const formData = new FormData();\n formData.append('file', request.file);\n formData.append('type', request.type);\n formData.append('documentId', request.documentId);\n\n // 可选:更新模式\n if (request.updateMode) {\n formData.append('updateMode', request.updateMode);\n }\n\n // 可选:tableSchema(结构化数据需要)\n if (request.tableSchema) {\n formData.append('tableSchema', JSON.stringify(request.tableSchema));\n }\n\n const raw = await this.http.postFormData<KnowledgeUpdateResponse>(\n `${API_PREFIX}/knowledge/updateDocument`,\n formData,\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n return {\n success: true,\n data: raw.data,\n };\n }\n\n // ============================================================\n // 查询知识库列表\n // ============================================================\n\n /**\n * 查询知识库列表\n *\n * 通过名称模糊查询知识库,返回知识库 ID 和基本信息。\n *\n * @param request - 查询请求\n * - `name`(可选):知识库名称(支持模糊查询)\n * - `pageNo`(可选):页码,从 1 开始,默认 1\n * - `pageSize`(可选):每页条数,默认 10\n * @returns 知识库列表\n *\n * @example\n * ```ts\n * // 查询知识库列表\n * const res = await client.queryDatasetsList({\n * name: '用户知识库'\n * });\n *\n * if (res.success) {\n * for (const item of res.data?.datasets ?? []) {\n * console.log(`ID: ${item.datasetId}, 名称: ${item.name}`);\n * }\n * } else {\n * console.error(`查询失败: ${res.errorMsg}`);\n * }\n * ```\n */\n async queryDatasetsList(\n request: KnowledgeQueryListRequest = {},\n ): Promise<SdkResponse<KnowledgeQueryListResponse>> {\n // 构建查询参数\n const queryParams: Record<string, string> = {};\n if (request.name) {\n queryParams.name = request.name;\n }\n if (request.pageNo !== undefined) {\n queryParams.pageNo = String(request.pageNo);\n }\n if (request.pageSize !== undefined) {\n queryParams.pageSize = String(request.pageSize);\n }\n\n // 查询知识库列表接口使用不同的域名 api.tbox.cn\n const raw = await this.http.get<KnowledgeQueryListResponse>(\n `https://api.tbox.cn/api/datasets/queryDatasetsList`,\n queryParams,\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n return {\n success: true,\n data: raw.data,\n };\n }\n\n // ============================================================\n // 检索知识库\n // ============================================================\n\n /**\n * 检索知识库\n *\n * 通过自然语言查询知识库内容,返回相关度最高的内容片段。\n * 支持两种方式获取知识库:\n * 1. 直接传入 datasetId\n * 2. 传入 name,SDK 会自动查询获取 datasetId\n *\n * @param request - 检索知识库请求\n * - `name`(可选):知识库名称,SDK 会自动查询获取 datasetId\n * - `datasetId`(可选):知识库 ID(优先使用)\n * - `query`(必填):查询内容(自然语言描述)\n * @returns 检索结果\n *\n * @example\n * ```ts\n * // 方式 1: 通过名称自动查询\n * const res = await client.retrieve({\n * name: '用户知识库',\n * query: '消防安全管理制度'\n * });\n *\n * // 方式 2: 直接传入 datasetId\n * const res = await client.retrieve({\n * datasetId: '20251024999def29600U6J302721040',\n * query: '消防安全管理制度'\n * });\n *\n * if (res.success) {\n * for (const item of res.data?.data ?? []) {\n * console.log(`文件: ${item.originFileName}`);\n * console.log(`内容: ${item.content}`);\n * console.log(`相关度: ${item.score}`);\n * }\n * } else {\n * console.error(`检索失败: ${res.errorMsg}`);\n * }\n * ```\n */\n async retrieve(\n request: KnowledgeRetrieveRequest,\n ): Promise<SdkResponse<KnowledgeRetrieveResponse>> {\n let datasetId = request.datasetId;\n\n // 如果没有直接传入 datasetId,通过 name 查询\n if (!datasetId && request.name) {\n const queryRes = await this.queryDatasetsList({ name: request.name });\n if (!queryRes.success) {\n return {\n success: false,\n errorCode: queryRes.errorCode,\n errorMsg: queryRes.errorMsg,\n };\n }\n\n const datasets = queryRes.data?.datasets ?? [];\n if (datasets.length === 0) {\n return {\n success: false,\n errorCode: 'KNOWLEDGE_NOT_FOUND',\n errorMsg: `未找到名称为 \"${request.name}\" 的知识库`,\n };\n }\n\n datasetId = datasets[0].datasetId;\n }\n\n if (!datasetId) {\n return {\n success: false,\n errorCode: 'INVALID_REQUEST',\n errorMsg: '必须提供datasetId 参数',\n };\n }\n\n // 检索接口使用不同的域名 api.tbox.cn\n const raw = await this.http.post<KnowledgeRetrieveResponse>(\n `https://api.tbox.cn/api/datasets/retrieve`,\n {\n datasetId,\n query: request.query,\n },\n );\n\n if (!raw.success) {\n return {\n success: false,\n errorCode: raw.errorCode,\n errorMsg: raw.errorMsg,\n };\n }\n\n return {\n success: true,\n data: raw.data,\n };\n }\n}\n","/**\n * LLM SDK - LlmClient 核心类\n *\n * 封装大语言模型调用功能,提供 OpenAI 兼容的 Chat Completions 接口。\n */\n\nimport { HttpClient, DEFAULT_BASE_URL } from './http';\nimport type {\n LlmClientConfig,\n ChatCompletionRequest,\n ChatCompletionResponse,\n ChatCompletionChunk,\n ChatMessage,\n} from './types';\n\n/** API 路径前缀 */\nconst API_PREFIX = '/compat/openai/v1';\n\n/**\n * LLM 客户端\n *\n * 提供大语言模型调用能力,支持流式和非流式输出。\n *\n * @example\n * ```ts\n * import { LlmClient } from '@tbox/plugin-sdk';\n *\n * const client = new LlmClient({ apiKey: 'your-api-key' });\n *\n * // 流式调用\n * const stream = await client.chatCompletions({\n * model: 'kimi-k2.5',\n * messages: [{ role: 'user', content: '你好' }],\n * stream: true\n * });\n *\n * for await (const chunk of stream) {\n * process.stdout.write(chunk.choices[0]?.delta?.content ?? '');\n * }\n * ```\n */\nexport class LlmClient {\n private readonly http: HttpClient;\n\n constructor(config: LlmClientConfig) {\n this.http = new HttpClient({\n baseUrl: config.baseUrl ?? DEFAULT_BASE_URL,\n apiKey: config.apiKey,\n timeout: config.timeout,\n });\n }\n\n // ============================================================\n // Chat Completions\n // ============================================================\n\n /**\n * Chat Completions 对话补全\n *\n * 支持流式和非流式两种模式:\n * - 流式(stream=true):返回 AsyncIterable<ChatCompletionChunk>\n * - 非流式(stream=false):返回 ChatCompletionResponse\n *\n * @param request - 对话补全请求\n * - `model`(必填):模型名称\n * - `messages`(必填):对话消息列表\n * - `stream`(可选):是否流式输出,默认 false\n * - `temperature`(可选):温度参数,范围 0~2\n * - `top_p`(可选):核采样参数,范围 0~1,推荐 0.95\n * - `max_tokens`(可选):最大输出 token 数,推荐 8000\n * - `stream_options`(可选):流式选项,`{ include_usage: true }` 可在末尾返回 token 用量\n * @returns 流式返回 AsyncIterable,非流式返回完整响应\n *\n * @example\n * ```ts\n * // 流式调用\n * const stream = await client.chatCompletions({\n * model: 'kimi-k2.5',\n * messages: [\n * { role: 'system', content: '你是一个有帮助的助手' },\n * { role: 'user', content: '你好,请介绍一下你自己' }\n * ],\n * stream: true,\n * stream_options: { include_usage: true }\n * });\n *\n * for await (const chunk of stream) {\n * const content = chunk.choices[0]?.delta?.content;\n * if (content) {\n * process.stdout.write(content);\n * }\n * // 检查是否结束\n * if (chunk.choices[0]?.finish_reason === 'stop') {\n * console.log('\\n对话结束');\n * }\n * // 获取 token 用量(需要 stream_options.include_usage=true)\n * if (chunk.usage) {\n * console.log(`Token 用量: ${chunk.usage.total_tokens}`);\n * }\n * }\n * ```\n *\n * @example\n * ```ts\n * // 非流式调用\n * const response = await client.chatCompletions({\n * model: 'kimi-k2.5',\n * messages: [\n * { role: 'user', content: '你好' }\n * ],\n * stream: false\n * });\n *\n * console.log(response.choices[0]?.message?.content);\n * ```\n */\n async chatCompletions(\n request: ChatCompletionRequest,\n ): Promise<ChatCompletionResponse | AsyncIterable<ChatCompletionChunk>> {\n // 流式模式\n if (request.stream) {\n return this.streamChatCompletions(request);\n }\n\n // 非流式模式\n const response = await this.http.post<ChatCompletionResponse>(\n `${API_PREFIX}/chat/completions`,\n request,\n );\n\n if (!response.success) {\n throw new Error(response.errorMsg ?? 'Chat completion failed');\n }\n\n return response.data!;\n }\n\n /**\n * 流式调用 Chat Completions\n */\n private async *streamChatCompletions(\n request: ChatCompletionRequest,\n ): AsyncIterable<ChatCompletionChunk> {\n const url = `${this.http.baseUrl}${API_PREFIX}/chat/completions`;\n\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json;charset=UTF-8',\n ...this.http.getAuthHeaders(),\n },\n body: JSON.stringify(request),\n });\n\n if (!response.ok) {\n throw new Error(`HTTP error: ${response.status} ${response.statusText}`);\n }\n\n const reader = response.body?.getReader();\n if (!reader) {\n throw new Error('No response body');\n }\n\n const decoder = new TextDecoder('utf-8');\n let buffer = '';\n\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n\n buffer += decoder.decode(value, { stream: true });\n const lines = buffer.split('\\n');\n buffer = lines.pop() ?? '';\n\n for (const line of lines) {\n const trimmed = line.trim();\n if (!trimmed || !trimmed.startsWith('data:')) continue;\n\n // 支持 \"data:\" 和 \"data: \" 两种格式\n const data = trimmed.startsWith('data: ')\n ? trimmed.slice(6)\n : trimmed.slice(5);\n if (data === '[DONE]') return;\n\n try {\n const chunk = JSON.parse(data) as ChatCompletionChunk;\n yield chunk;\n } catch {\n // 忽略解析错误\n }\n }\n }\n\n // 处理剩余 buffer\n if (buffer.trim()) {\n const trimmed = buffer.trim();\n if (trimmed.startsWith('data:')) {\n const data = trimmed.startsWith('data: ')\n ? trimmed.slice(6)\n : trimmed.slice(5);\n if (data !== '[DONE]') {\n try {\n const chunk = JSON.parse(data) as ChatCompletionChunk;\n yield chunk;\n } catch {\n // 忽略解析错误\n }\n }\n }\n }\n } finally {\n reader.releaseLock();\n }\n }\n\n /**\n * 简化的对话方法\n *\n * 快速发起一次对话,自动处理流式输出。\n *\n * @param model - 模型名称\n * @param messages - 对话消息列表\n * @param options - 可选参数\n * @returns 完整的对话内容(对于推理模型,返回推理内容 + 正式内容)\n *\n * @example\n * ```ts\n * const answer = await client.chat('kimi-k2.5', [\n * { role: 'user', content: '你好' }\n * ]);\n * console.log(answer);\n * ```\n */\n async chat(\n model: string,\n messages: ChatMessage[],\n options?: {\n temperature?: number;\n top_p?: number;\n max_tokens?: number;\n },\n ): Promise<string> {\n const stream = await this.chatCompletions({\n model,\n messages,\n stream: true,\n stream_options: { include_usage: true },\n ...options,\n });\n\n let fullContent = '';\n let reasoningContent = '';\n\n for await (const chunk of stream as AsyncIterable<ChatCompletionChunk>) {\n const content = chunk.choices?.[0]?.delta?.content;\n const reasoning = chunk.choices?.[0]?.delta?.reasoning_content;\n if (content) {\n fullContent += content;\n }\n if (reasoning) {\n reasoningContent += reasoning;\n }\n }\n\n // 如果有推理内容但没有正式内容,返回推理内容\n // 这对于 glm-5v-turbo 等推理模型很重要\n if (!fullContent && reasoningContent) {\n return reasoningContent;\n }\n\n return fullContent;\n }\n}\n"],"names":["API_PREFIX"],"mappings":";;AAAA;;AAEG;AAEH;AACO,MAAM,aAAa,GAAG;AAE7B;AACO,MAAM,WAAW,GAAG;AAE3B;AACO,MAAM,kBAAkB,GAAG,oBAAoB;;ACXtD;;;;;AAKG;AAEH;AACM,MAAO,SAAU,SAAQ,KAAK,CAAA;AAClC,IAAA,WAAA,CAAY,OAAe,EAAA;QACzB,KAAK,CAAC,OAAO,CAAC;AACd,QAAA,IAAI,CAAC,IAAI,GAAG,WAAW;QACvB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC;IACnD;AACD;AAcD;AACM,MAAO,QAAS,SAAQ,SAAS,CAAA;IAOrC,WAAA,CACE,MAAc,EACd,SAA6B,EAC7B,QAA4B,EAC5B,OAA2B,EAC3B,WAAqB,EAAA;AAErB,QAAA,MAAM,OAAO,GAAG,QAAQ,IAAI,CAAA,kBAAA,EAAqB,MAAM,GAAG;QAC1D,KAAK,CAAC,OAAO,CAAC;AACd,QAAA,IAAI,CAAC,IAAI,GAAG,UAAU;AACtB,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;AACpB,QAAA,IAAI,CAAC,SAAS,GAAG,SAAS;AAC1B,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ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