noumen 0.5.0 → 0.6.0
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.
- package/dist/a2a/index.d.ts +4 -4
- package/dist/acp/index.d.ts +4 -4
- package/dist/{agent-C3eDRsxs.d.ts → agent-DWE4_P5X.d.ts} +179 -6
- package/dist/{cache-DsRqxx6v.d.ts → cache-BlBwXXPS.d.ts} +1 -1
- package/dist/{chunk-WPCYGZOE.js → chunk-6MMYCGJQ.js} +325 -16
- package/dist/chunk-6MMYCGJQ.js.map +1 -0
- package/dist/{chunk-WTLK2ZAR.js → chunk-7IQCQI2G.js} +1 -1
- package/dist/{chunk-L3L3FG5T.js → chunk-CCM2AXZG.js} +1 -1
- package/dist/{chunk-L3L3FG5T.js.map → chunk-CCM2AXZG.js.map} +1 -1
- package/dist/{chunk-CS6WNDCF.js → chunk-I3JTUFPK.js} +2 -2
- package/dist/chunk-I3JTUFPK.js.map +1 -0
- package/dist/{chunk-EKOGVTBT.js → chunk-ZXSDKBYB.js} +4 -2
- package/dist/chunk-ZXSDKBYB.js.map +1 -0
- package/dist/cli/index.js +6 -6
- package/dist/client/index.d.ts +1 -1
- package/dist/index.d.ts +16 -9
- package/dist/index.js +17 -3
- package/dist/lsp/index.d.ts +3 -3
- package/dist/mcp/index.d.ts +4 -4
- package/dist/{provider-factory-KI7OZUY3.js → provider-factory-TUHU3DIG.js} +2 -2
- package/dist/providers/anthropic.d.ts +3 -3
- package/dist/providers/anthropic.js +4 -3
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/bedrock.d.ts +3 -3
- package/dist/providers/bedrock.js +2 -2
- package/dist/providers/bedrock.js.map +1 -1
- package/dist/providers/gemini.d.ts +2 -2
- package/dist/providers/gemini.js +1 -1
- package/dist/providers/gemini.js.map +1 -1
- package/dist/providers/ollama.d.ts +1 -1
- package/dist/providers/ollama.js +2 -2
- package/dist/providers/openai.d.ts +2 -2
- package/dist/providers/openai.js +2 -2
- package/dist/providers/openrouter.d.ts +1 -1
- package/dist/providers/openrouter.js +2 -2
- package/dist/providers/vertex.d.ts +3 -3
- package/dist/providers/vertex.js +4 -3
- package/dist/providers/vertex.js.map +1 -1
- package/dist/{resolve-GDSHNMG6.js → resolve-6KUZNEYW.js} +2 -2
- package/dist/server/index.d.ts +4 -4
- package/dist/{server-Cu9gv1dk.d.ts → server-BzNGKTP6.d.ts} +1 -1
- package/dist/{types-BA87bHPV.d.ts → types-DhXwOQwD.d.ts} +1 -1
- package/dist/{types-LrU4LRmX.d.ts → types-kiGBF35b.d.ts} +40 -2
- package/package.json +1 -1
- package/dist/chunk-CS6WNDCF.js.map +0 -1
- package/dist/chunk-EKOGVTBT.js.map +0 -1
- package/dist/chunk-WPCYGZOE.js.map +0 -1
- /package/dist/{chunk-WTLK2ZAR.js.map → chunk-7IQCQI2G.js.map} +0 -0
- /package/dist/{provider-factory-KI7OZUY3.js.map → provider-factory-TUHU3DIG.js.map} +0 -0
- /package/dist/{resolve-GDSHNMG6.js.map → resolve-6KUZNEYW.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/providers/types.ts"],"sourcesContent":["import type { ChatMessage } from \"../session/types.js\";\nimport type { ThinkingConfig } from \"../thinking/types.js\";\n\nexport interface ToolParameterProperty {\n type: string;\n description?: string;\n enum?: string[];\n default?: unknown;\n minimum?: number;\n maximum?: number;\n}\n\nexport interface ToolDefinition {\n type: \"function\";\n function: {\n name: string;\n description: string;\n parameters: {\n type: \"object\";\n properties: Record<string, ToolParameterProperty>;\n required?: string[];\n };\n };\n}\n\n// Streaming chunk types (OpenAI-compatible)\n\nexport interface ChatStreamDelta {\n role?: \"assistant\";\n content?: string | null;\n thinking_content?: string | null;\n thinking_signature?: string | null;\n /** Opaque data payload for Anthropic redacted_thinking blocks. */\n redacted_thinking_data?: string | null;\n tool_calls?: Array<{\n index: number;\n id?: string;\n type?: \"function\";\n function?: {\n name?: string;\n arguments?: string;\n };\n }>;\n}\n\nexport interface ChatStreamChoice {\n index: number;\n delta: ChatStreamDelta;\n finish_reason: string | null;\n}\n\nexport interface ChatStreamChunk {\n id: string;\n choices: ChatStreamChoice[];\n model: string;\n usage?: {\n prompt_tokens: number;\n completion_tokens: number;\n total_tokens: number;\n cache_read_tokens?: number;\n cache_creation_tokens?: number;\n thinking_tokens?: number;\n };\n}\n\nexport interface ChatCompletionUsage {\n prompt_tokens: number;\n completion_tokens: number;\n total_tokens: number;\n cache_read_tokens?: number;\n cache_creation_tokens?: number;\n thinking_tokens?: number;\n}\n\n/**\n * Structured output format. When provided, the model is constrained to\n * produce a response matching the given JSON schema.\n *\n * - `json_schema`: the model must produce JSON conforming to the given schema.\n * - `json_object`: the model must produce valid JSON (no specific schema).\n */\nexport type OutputFormat = JsonSchemaOutputFormat | JsonObjectOutputFormat;\n\nexport interface JsonSchemaOutputFormat {\n type: \"json_schema\";\n /** JSON Schema object describing the expected output shape. */\n schema: Record<string, unknown>;\n /** Optional name for the schema (required by some providers). */\n name?: string;\n /** When true, the provider enforces strict schema adherence. */\n strict?: boolean;\n}\n\nexport interface JsonObjectOutputFormat {\n type: \"json_object\";\n}\n\nexport interface ChatParams {\n model: string;\n messages: ChatMessage[];\n tools?: ToolDefinition[];\n max_tokens?: number;\n system?: string;\n temperature?: number;\n thinking?: ThinkingConfig;\n /** Constrain the model to produce structured output matching this schema. */\n outputFormat?: OutputFormat;\n /**\n * When true, the provider should place the cache breakpoint on the\n * second-to-last message instead of the last. Used by subagent forks\n * to avoid writing fork-only tails into the shared prompt cache.\n */\n skipCacheWrite?: boolean;\n /** Abort signal — providers should forward this to cancel in-flight HTTP requests. */\n signal?: AbortSignal;\n}\n\nexport interface AIProvider {\n chat(params: ChatParams): AsyncIterable<ChatStreamChunk>;\n}\n\n/**\n * Extended error type that providers can throw to convey retry-relevant metadata.\n * Consumers (like the retry engine) can inspect these fields without knowing\n * provider-specific SDK error types.\n */\nexport class ChatStreamError extends Error {\n status?: number;\n retryAfter?: string;\n\n constructor(\n message: string,\n opts?: { status?: number; retryAfter?: string; cause?: unknown },\n ) {\n super(message, { cause: opts?.cause });\n this.name = \"ChatStreamError\";\n this.status = opts?.status;\n this.retryAfter = opts?.retryAfter;\n }\n}\n"],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../src/providers/types.ts"],"sourcesContent":["import type { ChatMessage } from \"../session/types.js\";\nimport type { ThinkingConfig } from \"../thinking/types.js\";\n\nexport interface ToolParameterProperty {\n type: string;\n description?: string;\n enum?: string[];\n default?: unknown;\n minimum?: number;\n maximum?: number;\n}\n\nexport interface ToolDefinition {\n type: \"function\";\n function: {\n name: string;\n description: string;\n parameters: {\n type: \"object\";\n properties: Record<string, ToolParameterProperty>;\n required?: string[];\n };\n };\n}\n\n// Streaming chunk types (OpenAI-compatible)\n\nexport interface ChatStreamDelta {\n role?: \"assistant\";\n content?: string | null;\n thinking_content?: string | null;\n thinking_signature?: string | null;\n /** Opaque data payload for Anthropic redacted_thinking blocks. */\n redacted_thinking_data?: string | null;\n tool_calls?: Array<{\n index: number;\n id?: string;\n type?: \"function\";\n function?: {\n name?: string;\n arguments?: string;\n };\n }>;\n}\n\nexport interface ChatStreamChoice {\n index: number;\n delta: ChatStreamDelta;\n finish_reason: string | null;\n}\n\nexport interface ChatStreamChunk {\n id: string;\n choices: ChatStreamChoice[];\n model: string;\n usage?: {\n prompt_tokens: number;\n completion_tokens: number;\n total_tokens: number;\n cache_read_tokens?: number;\n cache_creation_tokens?: number;\n thinking_tokens?: number;\n };\n}\n\nexport interface ChatCompletionUsage {\n prompt_tokens: number;\n completion_tokens: number;\n total_tokens: number;\n cache_read_tokens?: number;\n cache_creation_tokens?: number;\n thinking_tokens?: number;\n}\n\n/**\n * Structured output format. When provided, the model is constrained to\n * produce a response matching the given JSON schema.\n *\n * - `json_schema`: the model must produce JSON conforming to the given schema.\n * - `json_object`: the model must produce valid JSON (no specific schema).\n */\nexport type OutputFormat = JsonSchemaOutputFormat | JsonObjectOutputFormat;\n\nexport interface JsonSchemaOutputFormat {\n type: \"json_schema\";\n /** JSON Schema object describing the expected output shape. */\n schema: Record<string, unknown>;\n /** Optional name for the schema (required by some providers). */\n name?: string;\n /** When true, the provider enforces strict schema adherence. */\n strict?: boolean;\n}\n\nexport interface JsonObjectOutputFormat {\n type: \"json_object\";\n}\n\nexport interface ChatParams {\n model: string;\n messages: ChatMessage[];\n tools?: ToolDefinition[];\n max_tokens?: number;\n system?: string;\n temperature?: number;\n thinking?: ThinkingConfig;\n /** Constrain the model to produce structured output matching this schema. */\n outputFormat?: OutputFormat;\n /**\n * When true, the provider should place the cache breakpoint on the\n * second-to-last message instead of the last. Used by subagent forks\n * to avoid writing fork-only tails into the shared prompt cache.\n */\n skipCacheWrite?: boolean;\n /** Abort signal — providers should forward this to cancel in-flight HTTP requests. */\n signal?: AbortSignal;\n}\n\nexport interface AIProvider {\n chat(params: ChatParams): AsyncIterable<ChatStreamChunk>;\n /**\n * Optional fallback model name, used when no `model` is provided at the\n * Thread / Agent level. Consumers should pass explicit models when they\n * can, but this lets each provider ship a sensible default without\n * forcing Thread to hardcode provider-specific strings.\n */\n readonly defaultModel?: string;\n}\n\n/**\n * Extended error type that providers can throw to convey retry-relevant metadata.\n * Consumers (like the retry engine) can inspect these fields without knowing\n * provider-specific SDK error types.\n */\nexport class ChatStreamError extends Error {\n status?: number;\n retryAfter?: string;\n\n constructor(\n message: string,\n opts?: { status?: number; retryAfter?: string; cause?: unknown },\n ) {\n super(message, { cause: opts?.cause });\n this.name = \"ChatStreamError\";\n this.status = opts?.status;\n this.retryAfter = opts?.retryAfter;\n }\n}\n"],"mappings":";AAqIO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC;AAAA,EACA;AAAA,EAEA,YACE,SACA,MACA;AACA,UAAM,SAAS,EAAE,OAAO,MAAM,MAAM,CAAC;AACrC,SAAK,OAAO;AACZ,SAAK,SAAS,MAAM;AACpB,SAAK,aAAa,MAAM;AAAA,EAC1B;AACF;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ChatStreamError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-CCM2AXZG.js";
|
|
4
4
|
|
|
5
5
|
// src/providers/openai.ts
|
|
6
6
|
import OpenAI from "openai";
|
|
@@ -168,4 +168,4 @@ var OpenAIProvider = class _OpenAIProvider {
|
|
|
168
168
|
export {
|
|
169
169
|
OpenAIProvider
|
|
170
170
|
};
|
|
171
|
-
//# sourceMappingURL=chunk-
|
|
171
|
+
//# sourceMappingURL=chunk-I3JTUFPK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/providers/openai.ts"],"sourcesContent":["import OpenAI from \"openai\";\nimport type {\n AIProvider,\n ChatParams,\n ChatStreamChunk,\n} from \"./types.js\";\nimport { ChatStreamError } from \"./types.js\";\nimport type { ChatMessage, ContentPart } from \"../session/types.js\";\n\nexport interface OpenAIProviderOptions {\n apiKey?: string;\n baseURL?: string;\n model?: string;\n defaultHeaders?: Record<string, string | undefined>;\n /** When true, omits `stream_options` that some OpenAI-compatible endpoints don't support. */\n compatMode?: boolean;\n}\n\nconst O_SERIES_PATTERN = /^o[1-9]/;\n\nexport class OpenAIProvider implements AIProvider {\n private client: OpenAI;\n readonly defaultModel: string;\n protected compatMode: boolean;\n\n constructor(opts: OpenAIProviderOptions) {\n this.client = new OpenAI({\n apiKey: opts.apiKey ?? \"not-needed\",\n baseURL: opts.baseURL,\n defaultHeaders: opts.defaultHeaders,\n maxRetries: 0,\n });\n this.defaultModel = opts.model ?? \"gpt-5.4\";\n this.compatMode = opts.compatMode ?? false;\n }\n\n async *chat(params: ChatParams): AsyncIterable<ChatStreamChunk> {\n const messages = this.buildMessages(params.system, params.messages);\n const model = params.model ?? this.defaultModel;\n const isOSeries = O_SERIES_PATTERN.test(model);\n\n const createParams: OpenAI.ChatCompletionCreateParamsStreaming = {\n model,\n messages: messages as unknown as OpenAI.ChatCompletionMessageParam[],\n tools: params.tools?.map((t) => ({\n type: \"function\" as const,\n function: t.function,\n })),\n stream: true,\n ...(this.compatMode ? {} : { stream_options: { include_usage: true } }),\n };\n\n if (isOSeries) {\n (createParams as unknown as Record<string, unknown>).max_completion_tokens = params.max_tokens ?? 16384;\n if (params.thinking?.type === \"enabled\") {\n (createParams as unknown as Record<string, unknown>).reasoning_effort = \"high\";\n }\n } else {\n createParams.max_tokens = params.max_tokens;\n createParams.temperature = params.temperature;\n }\n\n if (params.outputFormat?.type === \"json_schema\") {\n (createParams as unknown as Record<string, unknown>).response_format = {\n type: \"json_schema\",\n json_schema: {\n name: params.outputFormat.name ?? \"response\",\n schema: params.outputFormat.schema,\n strict: params.outputFormat.strict ?? false,\n },\n };\n } else if (params.outputFormat?.type === \"json_object\") {\n (createParams as unknown as Record<string, unknown>).response_format = {\n type: \"json_object\",\n };\n }\n\n try {\n const stream = await this.client.chat.completions.create(createParams, {\n ...(params.signal ? { signal: params.signal } : {}),\n });\n\n for await (const chunk of stream) {\n const usage = chunk.usage;\n let mappedUsage: ChatStreamChunk[\"usage\"] | undefined;\n if (usage) {\n const u = usage as unknown as Record<string, unknown>;\n const promptDetails = u.prompt_tokens_details as Record<string, unknown> | undefined;\n const completionDetails = u.completion_tokens_details as Record<string, unknown> | undefined;\n mappedUsage = {\n prompt_tokens: usage.prompt_tokens,\n completion_tokens: usage.completion_tokens,\n total_tokens: usage.total_tokens,\n cache_read_tokens: promptDetails?.cached_tokens as number | undefined,\n cache_creation_tokens: promptDetails?.cache_creation_tokens as number | undefined,\n thinking_tokens: completionDetails?.reasoning_tokens as number | undefined,\n };\n }\n\n const choices = chunk.choices ?? [];\n if (choices.length === 0 && mappedUsage) {\n yield { id: chunk.id, model: chunk.model, choices: [], usage: mappedUsage };\n continue;\n }\n\n yield {\n id: chunk.id,\n model: chunk.model,\n choices: choices.map((c) => ({\n index: c.index,\n delta: {\n role: c.delta.role as \"assistant\" | undefined,\n content: c.delta.content,\n thinking_content: (c.delta as Record<string, unknown>).reasoning_content as string | undefined,\n tool_calls: c.delta.tool_calls?.map((tc) => ({\n index: tc.index,\n id: tc.id,\n type: tc.type as \"function\" | undefined,\n function: tc.function\n ? {\n name: tc.function.name,\n arguments: tc.function.arguments,\n }\n : undefined,\n })),\n },\n finish_reason: c.finish_reason,\n })),\n usage: mappedUsage,\n };\n }\n } catch (err: unknown) {\n if (err instanceof ChatStreamError) throw err;\n const apiErr = err as { status?: number; headers?: Record<string, string> & { get?(k: string): string | null } };\n throw new ChatStreamError(\n err instanceof Error ? err.message : String(err),\n {\n status: apiErr.status,\n retryAfter: apiErr.headers?.get?.(\"retry-after\") ?? apiErr.headers?.[\"retry-after\"] ?? undefined,\n cause: err,\n },\n );\n }\n }\n\n private static contentPartsToOpenAI(\n parts: ContentPart[],\n ): Array<Record<string, unknown>> {\n return parts.map((part) => {\n if (part.type === \"text\") {\n return { type: \"text\", text: part.text };\n }\n if (part.type === \"image\") {\n return {\n type: \"image_url\",\n image_url: { url: `data:${part.media_type};base64,${part.data}` },\n };\n }\n // image_url\n return { type: \"image_url\", image_url: { url: part.url } };\n });\n }\n\n private buildMessages(\n system: string | undefined,\n messages: ChatMessage[],\n ): Array<Record<string, unknown>> {\n const result: Array<Record<string, unknown>> = [];\n if (system) {\n result.push({ role: \"system\", content: system });\n }\n for (const msg of messages) {\n if (msg.role === \"tool\") {\n const content = Array.isArray(msg.content)\n ? OpenAIProvider.contentPartsToOpenAI(msg.content as ContentPart[])\n : msg.content;\n result.push({\n role: \"tool\",\n tool_call_id: msg.tool_call_id,\n content,\n });\n } else if (msg.role === \"assistant\") {\n const entry: Record<string, unknown> = {\n role: \"assistant\",\n content: msg.content,\n };\n if (msg.tool_calls) {\n entry.tool_calls = msg.tool_calls;\n }\n result.push(entry);\n } else if (msg.role === \"user\") {\n const content = Array.isArray(msg.content)\n ? OpenAIProvider.contentPartsToOpenAI(msg.content as ContentPart[])\n : msg.content;\n result.push({ role: \"user\", content });\n } else {\n result.push({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I;AAAA,UAClB;AAAA,QACF,CAAC;AAAA,MACH,WAAW,IAAI,SAAS,aAAa;AACnC,cAAM,QAAiC;AAAA,UACrC,MAAM;AAAA,UACN,SAAS,IAAI;AAAA,QACf;AACA,YAAI,IAAI,YAAY;AAClB,gBAAM,aAAa,IAAI;AAAA,QACzB;AACA,eAAO,KAAK,KAAK;AAAA,MACnB,WAAW,IAAI,SAAS,QAAQ;AAC9B,cAAM,UAAU,MAAM,QAAQ,IAAI,OAAO,IACrC,gBAAe,qBAAqB,IAAI,OAAwB,IAChE,IAAI;AACR,eAAO,KAAK,EAAE,MAAM,QAAQ,QAAQ,CAAC;AAAA,MACvC,OAAO;AACL,eAAO,KAAK,EAAE,MAAM,IAAI,MAAM,SAAS,IAAI,QAAQ,CAAC;AAAA,MACtD;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -4,9 +4,10 @@ import {
|
|
|
4
4
|
} from "./chunk-HEQQQGK5.js";
|
|
5
5
|
import {
|
|
6
6
|
ChatStreamError
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-CCM2AXZG.js";
|
|
8
8
|
|
|
9
9
|
// src/providers/anthropic-shared.ts
|
|
10
|
+
var DEFAULT_ANTHROPIC_MODEL = "claude-opus-4-7";
|
|
10
11
|
function buildCacheControlBlock(config) {
|
|
11
12
|
const cc = { type: "ephemeral" };
|
|
12
13
|
if (config?.ttl) cc.ttl = config.ttl;
|
|
@@ -467,6 +468,7 @@ async function* streamAnthropicChat(client, params, defaultModel, cacheConfig) {
|
|
|
467
468
|
}
|
|
468
469
|
|
|
469
470
|
export {
|
|
471
|
+
DEFAULT_ANTHROPIC_MODEL,
|
|
470
472
|
streamAnthropicChat
|
|
471
473
|
};
|
|
472
|
-
//# sourceMappingURL=chunk-
|
|
474
|
+
//# sourceMappingURL=chunk-ZXSDKBYB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/providers/anthropic-shared.ts"],"sourcesContent":["/**\n * Shared Anthropic streaming, message conversion, and tool mapping logic.\n *\n * Used by AnthropicProvider, BedrockAnthropicProvider, and VertexAnthropicProvider.\n * Accepts a generic client shape so it works with all three SDKs without\n * importing any of them directly.\n */\n\nimport type { ChatParams, ChatStreamChunk } from \"./types.js\";\nimport { ChatStreamError } from \"./types.js\";\nimport type { ChatMessage, ContentPart } from \"../session/types.js\";\nimport type { CacheControlConfig } from \"./cache.js\";\nimport { getMessageCacheBreakpointIndex } from \"./cache.js\";\nimport { getMaxOutputTokensForModel } from \"../utils/context.js\";\n\n/**\n * Default model for Anthropic-family providers (direct API + Vertex).\n * Bedrock uses its own ARN-shaped ids so it keeps its own default.\n *\n * Note: Anthropic model ids use hyphens throughout (`claude-opus-4-7`,\n * not `claude-opus-4.7`). A dot-separated fallback silently 404s against\n * the real API, which is especially nasty when the string only surfaces\n * via Thread's fallback path.\n */\nexport const DEFAULT_ANTHROPIC_MODEL = \"claude-opus-4-7\";\n\ninterface AnthropicToolUseBlock {\n type: \"tool_use\";\n id: string;\n name: string;\n input: Record<string, unknown>;\n}\n\ntype CacheControlBlock = {\n type: \"ephemeral\";\n ttl?: \"1h\";\n scope?: \"global\" | \"org\";\n};\n\nexport interface AnthropicStreamClient {\n messages: {\n stream(\n params: Record<string, unknown>,\n options?: { signal?: AbortSignal },\n ): AsyncIterable<Record<string, unknown>>;\n };\n}\n\nexport function buildCacheControlBlock(\n config: CacheControlConfig | undefined,\n): CacheControlBlock {\n const cc: CacheControlBlock = { type: \"ephemeral\" };\n if (config?.ttl) cc.ttl = config.ttl;\n if (config?.scope) cc.scope = config.scope;\n return cc;\n}\n\nfunction isCachingEnabled(config: CacheControlConfig | undefined): boolean {\n return config?.enabled === true;\n}\n\nexport function contentPartsToAnthropic(\n parts: ContentPart[],\n): Record<string, unknown>[] {\n return parts.map((part) => {\n if (part.type === \"text\") {\n return { type: \"text\", text: part.text };\n }\n if (part.type === \"image\") {\n return {\n type: \"image\",\n source: {\n type: \"base64\",\n media_type: part.media_type,\n data: part.data,\n },\n };\n }\n return {\n type: \"image\",\n source: { type: \"url\", url: part.url },\n };\n });\n}\n\nexport function buildAnthropicTools(\n params: ChatParams,\n cacheConfig?: CacheControlConfig,\n): Record<string, unknown>[] | undefined {\n if (!params.tools) return undefined;\n\n const tools = params.tools.map((t) => ({\n name: t.function.name,\n description: t.function.description,\n input_schema: t.function.parameters,\n }));\n\n if (isCachingEnabled(cacheConfig) && tools.length > 0) {\n const lastTool = tools[tools.length - 1] as Record<string, unknown>;\n lastTool.cache_control = buildCacheControlBlock(cacheConfig);\n }\n\n return tools;\n}\n\nexport function buildAnthropicSystemBlocks(\n systemPrompt: string | undefined,\n cacheConfig?: CacheControlConfig,\n): unknown {\n if (!systemPrompt) return undefined;\n if (!isCachingEnabled(cacheConfig)) return systemPrompt;\n\n return [\n {\n type: \"text\",\n text: systemPrompt,\n cache_control: buildCacheControlBlock(cacheConfig),\n },\n ];\n}\n\nexport function convertAnthropicMessages(\n systemPrompt: string | undefined,\n messages: ChatMessage[],\n cacheConfig?: CacheControlConfig,\n skipCacheWrite?: boolean,\n): {\n system: unknown;\n messages: Record<string, unknown>[];\n} {\n const result: Record<string, unknown>[] = [];\n const caching = isCachingEnabled(cacheConfig);\n const cacheBreakpointIdx = caching\n ? getMessageCacheBreakpointIndex(messages, skipCacheWrite)\n : -1;\n\n for (let mi = 0; mi < messages.length; mi++) {\n const msg = messages[mi];\n const addCache = mi === cacheBreakpointIdx;\n\n if (msg.role === \"system\") continue;\n\n if (msg.role === \"user\") {\n const isMultipart = Array.isArray(msg.content);\n if (addCache && caching) {\n const blocks = isMultipart\n ? contentPartsToAnthropic(msg.content as ContentPart[])\n : [{ type: \"text\", text: msg.content as string }];\n const lastBlock = blocks[blocks.length - 1] as Record<string, unknown>;\n lastBlock.cache_control = buildCacheControlBlock(cacheConfig);\n result.push({ role: \"user\", content: blocks });\n } else if (isMultipart) {\n result.push({\n role: \"user\",\n content: contentPartsToAnthropic(msg.content as ContentPart[]),\n });\n } else {\n result.push({ role: \"user\", content: msg.content as string });\n }\n } else if (msg.role === \"assistant\") {\n const content: Record<string, unknown>[] = [];\n if (msg.thinking_content) {\n const thinkingBlock: Record<string, unknown> = {\n type: \"thinking\",\n thinking: msg.thinking_content,\n };\n if (msg.thinking_signature) {\n thinkingBlock.signature = msg.thinking_signature;\n }\n content.push(thinkingBlock);\n }\n if (msg.redacted_thinking_data) {\n content.push({\n type: \"redacted_thinking\",\n data: msg.redacted_thinking_data,\n });\n }\n if (msg.content && (typeof msg.content !== \"string\" || msg.content.trim() !== \"\")) {\n content.push({ type: \"text\", text: msg.content });\n }\n if (msg.tool_calls) {\n for (const tc of msg.tool_calls) {\n let input: Record<string, unknown> = {};\n try {\n input = JSON.parse(tc.function.arguments);\n } catch {\n // malformed JSON from truncated stream — send empty input\n }\n content.push({\n type: \"tool_use\",\n id: tc.id,\n name: tc.function.name,\n input,\n });\n }\n }\n if (content.length === 0) {\n content.push({ type: \"text\", text: \"\" });\n }\n if (addCache && caching && content.length > 0) {\n for (let i = content.length - 1; i >= 0; i--) {\n const block = content[i] as Record<string, unknown>;\n if (block.type !== \"thinking\" && block.type !== \"redacted_thinking\") {\n block.cache_control = buildCacheControlBlock(cacheConfig);\n break;\n }\n }\n }\n result.push({ role: \"assistant\", content });\n } else if (msg.role === \"tool\") {\n const isMultipart = Array.isArray(msg.content);\n let toolContent: string | Record<string, unknown>[];\n\n if (msg.isError && isMultipart) {\n const textOnly = (msg.content as ContentPart[]).filter(\n (p) => p.type === \"text\",\n );\n toolContent =\n textOnly.length > 0\n ? contentPartsToAnthropic(textOnly)\n : String(msg.content);\n } else {\n toolContent = isMultipart\n ? contentPartsToAnthropic(msg.content as ContentPart[])\n : (msg.content as string);\n }\n\n const toolResultBlock: Record<string, unknown> = {\n type: \"tool_result\",\n tool_use_id: msg.tool_call_id,\n content: toolContent,\n };\n if (msg.isError) {\n toolResultBlock.is_error = true;\n }\n if (addCache && caching) {\n toolResultBlock.cache_control = buildCacheControlBlock(cacheConfig);\n }\n\n const prev = result[result.length - 1];\n if (prev && prev.role === \"user\" && Array.isArray(prev.content)) {\n const blocks = prev.content as Record<string, unknown>[];\n if (blocks.length > 0 && blocks[0].type === \"tool_result\") {\n blocks.push(toolResultBlock);\n continue;\n }\n }\n result.push({ role: \"user\", content: [toolResultBlock] });\n }\n }\n\n return {\n system: buildAnthropicSystemBlocks(systemPrompt, cacheConfig),\n messages: result,\n };\n}\n\nexport function makeChunk(\n id: string,\n model: string,\n delta: Record<string, unknown>,\n): ChatStreamChunk {\n return {\n id,\n model,\n choices: [\n {\n index: 0,\n delta: delta as ChatStreamChunk[\"choices\"][0][\"delta\"],\n finish_reason: null,\n },\n ],\n };\n}\n\n// ---------------------------------------------------------------------------\n// buildAnthropicRequestParams — pure param construction\n// ---------------------------------------------------------------------------\n\nexport interface AnthropicRequestParamsResult {\n streamParams: Record<string, unknown>;\n model: string;\n}\n\nexport function buildAnthropicRequestParams(\n params: ChatParams,\n defaultModel: string,\n cacheConfig?: CacheControlConfig,\n): AnthropicRequestParamsResult {\n const { system, messages: inputMessages } = convertAnthropicMessages(\n params.system,\n params.messages,\n cacheConfig,\n params.skipCacheWrite,\n );\n\n const tools = buildAnthropicTools(params, cacheConfig);\n\n const thinkingEnabled =\n params.thinking?.type === \"enabled\" &&\n (params.thinking as { budgetTokens: number }).budgetTokens > 0;\n const budgetTokens = thinkingEnabled\n ? (params.thinking as { type: \"enabled\"; budgetTokens: number }).budgetTokens\n : 0;\n\n const model = params.model ?? defaultModel;\n\n const modelMaxOutput = getMaxOutputTokensForModel(model);\n const maxOutputTokens = thinkingEnabled\n ? (params.max_tokens ?? modelMaxOutput)\n : (params.max_tokens ?? 8192);\n const clampedBudget = thinkingEnabled\n ? Math.min(budgetTokens, maxOutputTokens - 1)\n : 0;\n\n const streamParams: Record<string, unknown> = {\n model,\n max_tokens: maxOutputTokens,\n system,\n messages: inputMessages,\n tools,\n };\n\n if (!thinkingEnabled && params.temperature !== undefined) {\n streamParams.temperature = params.temperature;\n }\n\n if (thinkingEnabled) {\n streamParams.thinking = {\n type: \"enabled\",\n budget_tokens: clampedBudget,\n };\n }\n\n if (params.outputFormat?.type === \"json_schema\") {\n streamParams.output_config = {\n format: {\n type: \"json_schema\",\n json_schema: {\n name: params.outputFormat.name ?? \"response\",\n schema: params.outputFormat.schema,\n },\n },\n };\n const betas: string[] = (streamParams.betas as string[] | undefined) ?? [];\n if (!betas.includes(\"structured-outputs-2025-12-15\")) {\n betas.push(\"structured-outputs-2025-12-15\");\n }\n streamParams.betas = betas;\n } else if (params.outputFormat?.type === \"json_object\") {\n const hint = \"\\n\\nYou MUST respond with valid JSON only. No markdown, no explanation — just a single JSON object.\";\n if (typeof streamParams.system === \"string\") {\n streamParams.system = streamParams.system + hint;\n } else if (Array.isArray(streamParams.system)) {\n const blocks = streamParams.system as Array<Record<string, unknown>>;\n if (blocks.length > 0) {\n const last = blocks[blocks.length - 1];\n if (last.type === \"text\" && typeof last.text === \"string\") {\n last.text = last.text + hint;\n }\n }\n } else if (!streamParams.system) {\n streamParams.system = hint.trim();\n }\n }\n\n return { streamParams, model };\n}\n\n// ---------------------------------------------------------------------------\n// mapAnthropicStopReason — pure stop_reason -> finish_reason mapping\n// ---------------------------------------------------------------------------\n\nexport function mapAnthropicStopReason(\n stopReason: string | undefined,\n hasToolCalls: boolean,\n): string {\n switch (stopReason) {\n case \"end_turn\": return \"stop\";\n case \"tool_use\": return \"tool_calls\";\n case \"max_tokens\": return \"length\";\n case \"model_context_window_exceeded\": return \"length\";\n case \"stop_sequence\": return \"stop\";\n case \"refusal\": return \"content_filter\";\n default: return hasToolCalls ? \"tool_calls\" : \"stop\";\n }\n}\n\n// ---------------------------------------------------------------------------\n// AnthropicStreamState + processAnthropicStreamEvent — reducer pattern\n// ---------------------------------------------------------------------------\n\nexport interface AnthropicStreamState {\n chunkIndex: number;\n toolIndexMap: Map<string, number>;\n blockIndexToToolId: Map<number, string>;\n blockIndexToType: Map<number, string>;\n nextToolIndex: number;\n inputTokens: number;\n outputTokens: number;\n cacheReadTokens: number;\n cacheCreationTokens: number;\n thinkingTokens: number;\n stopReason: string | undefined;\n receivedMessageStop: boolean;\n}\n\nexport function createAnthropicStreamState(): AnthropicStreamState {\n return {\n chunkIndex: 0,\n toolIndexMap: new Map(),\n blockIndexToToolId: new Map(),\n blockIndexToType: new Map(),\n nextToolIndex: 0,\n inputTokens: 0,\n outputTokens: 0,\n cacheReadTokens: 0,\n cacheCreationTokens: 0,\n thinkingTokens: 0,\n stopReason: undefined,\n receivedMessageStop: false,\n };\n}\n\nexport function processAnthropicStreamEvent(\n ev: Record<string, unknown>,\n state: AnthropicStreamState,\n model: string,\n): ChatStreamChunk[] {\n const chunks: ChatStreamChunk[] = [];\n const chunkId = `chatcmpl-${state.chunkIndex++}`;\n\n if (ev.type === \"message_start\") {\n const msg = (ev.message as Record<string, unknown>) ?? {};\n const usage = msg.usage as Record<string, unknown> | undefined;\n if (usage) {\n state.inputTokens = (usage.input_tokens as number) ?? 0;\n state.outputTokens = (usage.output_tokens as number) ?? 0;\n state.cacheReadTokens = (usage.cache_read_input_tokens as number) ?? 0;\n state.cacheCreationTokens = (usage.cache_creation_input_tokens as number) ?? 0;\n if (usage.thinking_tokens) state.thinkingTokens = usage.thinking_tokens as number;\n }\n return chunks;\n }\n\n if (ev.type === \"message_delta\") {\n const delta = ev.delta as Record<string, unknown> | undefined;\n if (delta?.stop_reason) {\n state.stopReason = delta.stop_reason as string;\n }\n const usage = ev.usage as Record<string, unknown> | undefined;\n if (usage?.output_tokens != null && (usage.output_tokens as number) > 0) {\n state.outputTokens = usage.output_tokens as number;\n }\n if (usage?.thinking_tokens != null && (usage.thinking_tokens as number) > 0) {\n state.thinkingTokens = usage.thinking_tokens as number;\n }\n return chunks;\n }\n\n if (ev.type === \"content_block_start\") {\n // Shallow-copy to guard against SDK mutating the original object\n const block = { ...((ev.content_block as Record<string, unknown>) ?? {}) };\n const blockIndex = ev.index as number | undefined;\n if (blockIndex !== undefined) {\n state.blockIndexToType.set(blockIndex, block.type as string);\n }\n\n if (block.type === \"thinking\") {\n chunks.push(makeChunk(chunkId, model, { thinking_content: \"\" }));\n } else if (block.type === \"redacted_thinking\") {\n const redactedData = block.data as string | undefined;\n chunks.push(makeChunk(chunkId, model, { redacted_thinking_data: redactedData ?? \"\" }));\n } else if (block.type === \"text\") {\n chunks.push(makeChunk(chunkId, model, { content: \"\" }));\n } else if (block.type === \"tool_use\") {\n const toolBlock = block as unknown as AnthropicToolUseBlock;\n if (!toolBlock.id || !toolBlock.name) return chunks;\n const idx = state.nextToolIndex++;\n state.toolIndexMap.set(toolBlock.id, idx);\n if (blockIndex !== undefined) {\n state.blockIndexToToolId.set(blockIndex, toolBlock.id);\n }\n chunks.push(makeChunk(chunkId, model, {\n tool_calls: [\n {\n index: idx,\n id: toolBlock.id,\n type: \"function\",\n function: { name: toolBlock.name, arguments: \"\" },\n },\n ],\n }));\n }\n return chunks;\n }\n\n if (ev.type === \"content_block_delta\") {\n if (!ev.delta) return chunks;\n const delta = ev.delta as Record<string, unknown>;\n const deltaType = delta.type;\n const blockIndex = ev.index as number | undefined;\n\n if (deltaType === \"thinking_delta\") {\n chunks.push(makeChunk(chunkId, model, {\n thinking_content: delta.thinking as string,\n }));\n } else if (deltaType === \"text_delta\") {\n chunks.push(makeChunk(chunkId, model, {\n content: delta.text as string,\n }));\n } else if (deltaType === \"signature_delta\") {\n if (blockIndex !== undefined && state.blockIndexToType.get(blockIndex) === \"thinking\") {\n chunks.push(makeChunk(chunkId, model, {\n thinking_signature: delta.signature as string,\n }));\n }\n } else if (deltaType === \"input_json_delta\") {\n const partialJson = (delta.partial_json as string) ?? \"\";\n if (!partialJson) return chunks;\n let toolId: string | undefined;\n if (blockIndex !== undefined) {\n toolId = state.blockIndexToToolId.get(blockIndex);\n }\n if (!toolId) {\n toolId = Array.from(state.toolIndexMap.keys()).pop();\n }\n if (toolId) {\n const idx = state.toolIndexMap.get(toolId)!;\n chunks.push(makeChunk(chunkId, model, {\n tool_calls: [\n {\n index: idx,\n function: { arguments: partialJson },\n },\n ],\n }));\n }\n }\n return chunks;\n }\n\n if (ev.type === \"message_stop\") {\n state.receivedMessageStop = true;\n const finishReason = mapAnthropicStopReason(state.stopReason, state.toolIndexMap.size > 0);\n chunks.push({\n id: chunkId,\n model,\n choices: [\n {\n index: 0,\n delta: {},\n finish_reason: finishReason,\n },\n ],\n usage: {\n prompt_tokens: state.inputTokens,\n completion_tokens: state.outputTokens,\n total_tokens: state.inputTokens + state.outputTokens,\n cache_read_tokens: state.cacheReadTokens || undefined,\n cache_creation_tokens: state.cacheCreationTokens || undefined,\n thinking_tokens: state.thinkingTokens || undefined,\n },\n });\n return chunks;\n }\n\n return chunks;\n}\n\n/**\n * Stream an Anthropic-compatible chat call and yield OpenAI-shaped ChatStreamChunks.\n * Works with Anthropic, AnthropicBedrock, and AnthropicVertex clients.\n */\nexport async function* streamAnthropicChat(\n client: AnthropicStreamClient,\n params: ChatParams,\n defaultModel: string,\n cacheConfig?: CacheControlConfig,\n): AsyncIterable<ChatStreamChunk> {\n const { streamParams, model } = buildAnthropicRequestParams(params, defaultModel, cacheConfig);\n const requestSignal = params.signal;\n\n let stream: AsyncIterable<Record<string, unknown>>;\n try {\n stream = client.messages.stream(\n streamParams,\n requestSignal ? { signal: requestSignal } : undefined,\n );\n } catch (err: unknown) {\n const apiErr = err as { status?: number; headers?: Record<string, string> & { get?(k: string): string | null } };\n throw new ChatStreamError(\n err instanceof Error ? err.message : String(err),\n {\n status: apiErr.status,\n retryAfter: apiErr.headers?.get?.(\"retry-after\") ?? apiErr.headers?.[\"retry-after\"] ?? undefined,\n cause: err,\n },\n );\n }\n\n const state = createAnthropicStreamState();\n\n try {\n for await (const event of stream) {\n const ev = event as Record<string, unknown>;\n for (const chunk of processAnthropicStreamEvent(ev, state, model)) {\n yield chunk;\n }\n }\n\n if (!state.receivedMessageStop && state.chunkIndex > 0) {\n throw new ChatStreamError(\n \"Stream ended without receiving message_stop event\",\n { cause: new Error(\"incomplete_stream\") },\n );\n } else if (state.chunkIndex === 0) {\n throw new ChatStreamError(\n \"Stream returned no events\",\n { cause: new Error(\"empty_stream\") },\n );\n }\n } catch (err: unknown) {\n if (err instanceof ChatStreamError) throw err;\n const apiErr = err as { status?: number; headers?: Record<string, string> & { get?(k: string): string | null } };\n throw new ChatStreamError(\n err instanceof Error ? err.message : String(err),\n {\n status: apiErr.status,\n retryAfter: apiErr.headers?.get?.(\"retry-after\") ?? apiErr.headers?.[\"retry-after\"] ?? undefined,\n cause: err,\n },\n );\n }\n}\n"],"mappings":";;;;;;;;;AAwBO,IAAM,0BAA0B;AAwBhC,SAAS,uBACd,QACmB;AACnB,QAAM,KAAwB,EAAE,MAAM,YAAY;AAClD,MAAI,QAAQ,IAAK,IAAG,MAAM,OAAO;AACjC,MAAI,QAAQ,MAAO,IAAG,QAAQ,OAAO;AACrC,SAAO;AACT;AAEA,SAAS,iBAAiB,QAAiD;AACzE,SAAO,QAAQ,YAAY;AAC7B;AAEO,SAAS,wBACd,OAC2B;AAC3B,SAAO,MAAM,IAAI,CAAC,SAAS;AACzB,QAAI,KAAK,SAAS,QAAQ;AACxB,aAAO,EAAE,MAAM,QAAQ,MAAM,KAAK,KAAK;AAAA,IACzC;AACA,QAAI,KAAK,SAAS,SAAS;AACzB,aAAO;AAAA,QACL,MAAM;AAAA,QACN,QAAQ;AAAA,UACN,MAAM;AAAA,UACN,YAAY,KAAK;AAAA,UACjB,MAAM,KAAK;AAAA,QACb;AAAA,MACF;AAAA,IACF;AACA,WAAO;AAAA,MACL,MAAM;AAAA,MACN,QAAQ,EAAE,MAAM,OAAO,KAAK,KAAK,IAAI;AAAA,IACvC;AAAA,EACF,CAAC;AACH;AAEO,SAAS,oBACd,QACA,aACuC;AACvC,MAAI,CAAC,OAAO,MAAO,QAAO;AAE1B,QAAM,QAAQ,OAAO,MAAM,IAAI,CAAC,OAAO;AAAA,IACrC,MAAM,EA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,QACE,QAAQ,OAAO;AAAA,QACf,YAAY,OAAO,SAAS,MAAM,aAAa,KAAK,OAAO,UAAU,aAAa,KAAK;AAAA,QACvF,OAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AAEA,QAAM,QAAQ,2BAA2B;AAEzC,MAAI;AACF,qBAAiB,SAAS,QAAQ;AAChC,YAAM,KAAK;AACX,iBAAW,SAAS,4BAA4B,IAAI,OAAO,KAAK,GAAG;AACjE,cAAM;AAAA,MACR;AAAA,IACF;AAEA,QAAI,CAAC,MAAM,uBAAuB,MAAM,aAAa,GAAG;AACtD,YAAM,IAAI;AAAA,QACR;AAAA,QACA,EAAE,OAAO,IAAI,MAAM,mBAAmB,EAAE;AAAA,MAC1C;AAAA,IACF,WAAW,MAAM,eAAe,GAAG;AACjC,YAAM,IAAI;AAAA,QACR;AAAA,QACA,EAAE,OAAO,IAAI,MAAM,cAAc,EAAE;AAAA,MACrC;AAAA,IACF;AAAA,EACF,SAAS,KAAc;AACrB,QAAI,eAAe,gBAAiB,OAAM;AAC1C,UAAM,SAAS;AACf,UAAM,IAAI;AAAA,MACR,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAAA,MAC/C;AAAA,QACE,QAAQ,OAAO;AAAA,QACf,YAAY,OAAO,SAAS,MAAM,aAAa,KAAK,OAAO,UAAU,aAAa,KAAK;AAAA,QACvF,OAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/dist/cli/index.js
CHANGED
|
@@ -16,20 +16,20 @@ import {
|
|
|
16
16
|
Agent,
|
|
17
17
|
LocalSandbox,
|
|
18
18
|
UnsandboxedLocal
|
|
19
|
-
} from "../chunk-
|
|
19
|
+
} from "../chunk-6MMYCGJQ.js";
|
|
20
20
|
import {
|
|
21
21
|
DEFAULT_MODELS,
|
|
22
22
|
SUPPORTED_PROVIDERS,
|
|
23
23
|
detectProvider,
|
|
24
24
|
resolveProvider
|
|
25
|
-
} from "../chunk-
|
|
25
|
+
} from "../chunk-7IQCQI2G.js";
|
|
26
26
|
import "../chunk-42PHHZUA.js";
|
|
27
27
|
import "../chunk-XZN4QZLK.js";
|
|
28
28
|
import "../chunk-5GEX6ZSB.js";
|
|
29
29
|
import "../chunk-4SQA2UCV.js";
|
|
30
30
|
import "../chunk-3SK5GCI6.js";
|
|
31
31
|
import "../chunk-HEQQQGK5.js";
|
|
32
|
-
import "../chunk-
|
|
32
|
+
import "../chunk-CCM2AXZG.js";
|
|
33
33
|
import "../chunk-3HEYCV26.js";
|
|
34
34
|
import "../chunk-JACGEMTF.js";
|
|
35
35
|
import "../chunk-DGUM43GV.js";
|
|
@@ -532,7 +532,7 @@ async function runAgent(config) {
|
|
|
532
532
|
const { createInterface: createInterface3 } = await import("readline/promises");
|
|
533
533
|
const rl = createInterface3({ input: process.stdin, output: process.stderr, terminal: true });
|
|
534
534
|
try {
|
|
535
|
-
const { SUPPORTED_PROVIDERS: SUPPORTED_PROVIDERS2, isOllamaRunning: isOllamaRunning2, ollamaBaseURL: ollamaBaseURL2 } = await import("../provider-factory-
|
|
535
|
+
const { SUPPORTED_PROVIDERS: SUPPORTED_PROVIDERS2, isOllamaRunning: isOllamaRunning2, ollamaBaseURL: ollamaBaseURL2 } = await import("../provider-factory-TUHU3DIG.js");
|
|
536
536
|
const providerAnswer = await rl.question(
|
|
537
537
|
` Provider (${SUPPORTED_PROVIDERS2.join(", ")}) [${chalk3.bold("ollama")}]: `
|
|
538
538
|
);
|
|
@@ -589,9 +589,9 @@ async function runAgent(config) {
|
|
|
589
589
|
return runAgent(config);
|
|
590
590
|
}
|
|
591
591
|
if (!config.model) {
|
|
592
|
-
const { DEFAULT_MODELS: DEFAULT_MODELS2 } = await import("../provider-factory-
|
|
592
|
+
const { DEFAULT_MODELS: DEFAULT_MODELS2 } = await import("../provider-factory-TUHU3DIG.js");
|
|
593
593
|
if (providerName === "ollama") {
|
|
594
|
-
const { ollamaBaseURL: ollamaBaseURL2 } = await import("../provider-factory-
|
|
594
|
+
const { ollamaBaseURL: ollamaBaseURL2 } = await import("../provider-factory-TUHU3DIG.js");
|
|
595
595
|
const models = await listLocalOllamaModels(ollamaBaseURL2());
|
|
596
596
|
const preferred = DEFAULT_MODELS2[providerName];
|
|
597
597
|
config.model = models.includes(preferred) ? preferred : models[0] ?? preferred;
|
package/dist/client/index.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { A as Agent, S as SkillDefinition, T as ThreadConfig,
|
|
2
|
-
export {
|
|
3
|
-
import { A as AIProvider, T as ToolDefinition, o as ToolCallContent, S as StreamEvent, e as ContentPart, b as ChatMessage, k as ChatCompletionUsage, M as ModelPricing, h as UsageRecord, a as ChatStreamChunk, p as MemoryProvider, q as MemoryEntry, l as ThinkingConfig, r as AssistantMessage, s as ToolResultMessage, d as FileCheckpointSnapshot, t as ToolResultOverflowEntry, f as ContentReplacementRecord, J as JsonSchemaOutputFormat } from './types-
|
|
4
|
-
export { C as ChatParams,
|
|
1
|
+
import { a as AutoTitleConfig, A as Agent, S as SkillDefinition, T as ThreadConfig, b as SessionStorage, C as ContextFile, P as ProjectContextConfig, c as ContextScope, R as RetryConfig, d as RetryContext, e as RetryEngineOptions, f as Span, g as SpanAttributeValue, h as SpanStatusCode, i as Tracer, j as SpanOptions, k as StoredCostState } from './agent-DWE4_P5X.js';
|
|
2
|
+
export { l as AgentOptions, m as AutoCompactConfig, n as AutoCompactTrackingState, B as BudgetState, o as CLEARED_PLACEHOLDER, p as COMPACTABLE_TOOLS, q as ContentReplacementState, r as CostTracker, D as DEFAULT_AUTO_TITLE_MAX_INPUT_CHARS, s as DEFAULT_AUTO_TITLE_SYSTEM_PROMPT, t as DEFAULT_MODELS, u as DEFAULT_RETRY_CONFIG, v as DiagnoseCheckResult, w as DiagnoseResult, G as GenerateAutoTitleOptions, M as MicrocompactConfig, x as MicrocompactResult, y as ProviderName, z as ReactiveCompactConfig, E as ReactiveCompactResult, F as ResolveProviderOptions, H as RetryEvent, I as RunCallbacks, J as RunResult, K as SUPPORTED_PROVIDERS, L as SnipConfig, N as SnipResult, O as Thread, Q as ThreadOptions, U as ToolResultBudgetConfig, V as ToolResultBudgetResult, W as ToolResultReplacementRecord, X as ToolResultSpillResult, Y as ToolResultStorageConfig, Z as TracingConfig, _ as WebSearchConfig, $ as WebSearchResult, a0 as applyPersistedReplacements, a1 as applySnipRemovals, a2 as canAutoCompact, a3 as createAutoCompactConfig, a4 as createAutoCompactTracking, a5 as createBudgetState, a6 as createContentReplacementState, a7 as createWebSearchTool, a8 as detectProvider, a9 as enforceToolResultBudget, aa as enforceToolResultStorageBudget, ab as extractTitleFromResponse, ac as extractTitleSeedText, ad as generateAutoTitle, ae as microcompactMessages, af as normalizeTitle, ag as persistToolResult, ah as projectSnippedView, ai as reconstructContentReplacementState, aj as recordAutoCompactFailure, ak as recordAutoCompactSuccess, al as resolveProvider, am as shouldAutoCompact, an as snipMessagesByUuids, ao as tryReactiveCompact, ap as webSearchToolPlaceholder } from './agent-DWE4_P5X.js';
|
|
3
|
+
import { A as AIProvider, T as ToolDefinition, o as ToolCallContent, S as StreamEvent, e as ContentPart, b as ChatMessage, k as ChatCompletionUsage, M as ModelPricing, h as UsageRecord, a as ChatStreamChunk, p as MemoryProvider, q as MemoryEntry, l as ThinkingConfig, r as AssistantMessage, s as ToolResultMessage, d as FileCheckpointSnapshot, t as ToolResultOverflowEntry, f as ContentReplacementRecord, J as JsonSchemaOutputFormat } from './types-kiGBF35b.js';
|
|
4
|
+
export { u as AiTitleEntry, C as ChatParams, v as ChatStreamChoice, w as ChatStreamDelta, x as ChatStreamError, c as CheckpointConfig, y as CompactBoundaryEntry, z as ContentReplacementEntry, i as CostSummary, B as CustomTitleEntry, D as DiffStats, E as Entry, G as FileCheckpointBackup, H as FileCheckpointEntry, F as FileCheckpointState, I as ImageContent, K as ImageUrlContent, L as JsonObjectOutputFormat, m as MemoryConfig, N as MemoryType, P as MessageEntry, Q as MetadataEntry, j as ModelUsageSummary, O as OutputFormat, R as RunOptions, V as SerializedMessage, g as SessionInfo, W as SnipBoundaryEntry, X as SummaryEntry, Y as SystemMessage, Z as TextContent, _ as ToolDefParameterProperty, n as ToolResult, $ as UserMessage, a0 as createCheckpointState } from './types-kiGBF35b.js';
|
|
5
5
|
import { S as Sandbox } from './sandbox-9qeMTNrD.js';
|
|
6
6
|
export { L as LocalSandbox, a as LocalSandboxOptions, b as SandboxConfig, c as SandboxedLocalComputer, d as SandboxedLocalComputerOptions, U as UnsandboxedLocal, e as UnsandboxedLocalOptions } from './sandbox-9qeMTNrD.js';
|
|
7
|
-
import { H as HookDefinition, T as Tool, h as ToolContext, g as ToolResult, l as HookEvent, m as HookInput, P as PostToolUseFailureHookInput, n as PostToolUseFailureHookOutput, o as PostToolUseHookInput, p as PostToolUseHookOutput, q as PreToolUseHookInput, r as PreToolUseHookOutput } from './types-
|
|
8
|
-
export { F as FileCheckpointManager, s as FileState, t as FileStateCache, k as FileStateCacheConfig, u as FileWriteHookInput, v as HookOutput, J as JsonSchemaType, b as LspDiagnostic, c as LspLocation, d as LspOperation, L as LspServerConfig, a as LspServerState, f as LspSymbol, M as MemoryUpdateHookInput, w as ModelSwitchHookInput, N as NotificationHookInput, x as PermissionDeniedHookInput, y as PermissionRequestHookInput, R as RetryAttemptHookInput, z as SafeParseResult, A as SessionEndHookInput, B as SessionStartHookInput, S as SubagentConfig, i as SubagentRun, C as SubagentStartHookInput, E as SubagentStopHookInput, G as Task, I as TaskCreateInput, K as TaskStatus, j as TaskStore, O as TaskUpdateInput, Q as ToolParameters, Z as ZodLikeSchema, U as formatZodValidationError, V as registerZodToJsonSchema, W as zodToJsonSchema } from './types-
|
|
7
|
+
import { H as HookDefinition, T as Tool, h as ToolContext, g as ToolResult, l as HookEvent, m as HookInput, P as PostToolUseFailureHookInput, n as PostToolUseFailureHookOutput, o as PostToolUseHookInput, p as PostToolUseHookOutput, q as PreToolUseHookInput, r as PreToolUseHookOutput } from './types-DhXwOQwD.js';
|
|
8
|
+
export { F as FileCheckpointManager, s as FileState, t as FileStateCache, k as FileStateCacheConfig, u as FileWriteHookInput, v as HookOutput, J as JsonSchemaType, b as LspDiagnostic, c as LspLocation, d as LspOperation, L as LspServerConfig, a as LspServerState, f as LspSymbol, M as MemoryUpdateHookInput, w as ModelSwitchHookInput, N as NotificationHookInput, x as PermissionDeniedHookInput, y as PermissionRequestHookInput, R as RetryAttemptHookInput, z as SafeParseResult, A as SessionEndHookInput, B as SessionStartHookInput, S as SubagentConfig, i as SubagentRun, C as SubagentStartHookInput, E as SubagentStopHookInput, G as Task, I as TaskCreateInput, K as TaskStatus, j as TaskStore, O as TaskUpdateInput, Q as ToolParameters, Z as ZodLikeSchema, U as formatZodValidationError, V as registerZodToJsonSchema, W as zodToJsonSchema } from './types-DhXwOQwD.js';
|
|
9
9
|
import { M as McpServerConfig } from './types-2kTLUCnD.js';
|
|
10
10
|
export { b as McpConfig, c as McpConnection, d as McpHttpServerConfig, e as McpOAuthConfig, f as McpSseServerConfig, g as McpStdioServerConfig, h as McpToolInfo, i as McpWebSocketServerConfig, a as OAuthProviderOptions, O as OAuthTokenData, T as TokenStorage } from './types-2kTLUCnD.js';
|
|
11
11
|
export { OpenAIProviderOptions } from './providers/openai.js';
|
|
@@ -18,8 +18,8 @@ export { OllamaProviderOptions } from './providers/ollama.js';
|
|
|
18
18
|
import { a as VirtualFs, R as ReadOptions, F as FileEntry, b as FileStat, V as VirtualComputer, E as ExecOptions, C as CommandResult } from './computer-BPdxSo6X.js';
|
|
19
19
|
import { c as PermissionHandler, e as PermissionContext, f as PermissionBehavior, g as PermissionRule, A as AutoModeConfig, h as PermissionDecision, i as PermissionUpdate } from './types-CD0rUKKT.js';
|
|
20
20
|
export { D as DenialTrackingConfig, j as PermissionAllowResult, k as PermissionAskResult, d as PermissionConfig, l as PermissionDenyResult, a as PermissionMode, m as PermissionPassthroughResult, n as PermissionRequest, P as PermissionResponse, b as PermissionResult, o as PermissionRuleSource, R as RULE_SOURCE_PRECEDENCE } from './types-CD0rUKKT.js';
|
|
21
|
-
export { a as McpClientManagerOptions, b as McpServerOptions, c as buildMcpToolName, g as getMcpPrefix, n as normalizeNameForMCP, p as parseMcpToolName } from './server-
|
|
22
|
-
export { C as CacheControlConfig, a as CacheScope, g as getMessageCacheBreakpointIndex, s as sortToolDefinitionsForCache } from './cache-
|
|
21
|
+
export { a as McpClientManagerOptions, b as McpServerOptions, c as buildMcpToolName, g as getMcpPrefix, n as normalizeNameForMCP, p as parseMcpToolName } from './server-BzNGKTP6.js';
|
|
22
|
+
export { C as CacheControlConfig, a as CacheScope, g as getMessageCacheBreakpointIndex, s as sortToolDefinitionsForCache } from './cache-BlBwXXPS.js';
|
|
23
23
|
export { JsonRpcErrorObject, JsonRpcMessage, JsonRpcNotification, JsonRpcRequest, JsonRpcResponse } from './jsonrpc/index.js';
|
|
24
24
|
export { b as AcpCapabilities, c as AcpInitializeParams, d as AcpInitializeResult, A as AcpTransport } from './types-QwfylltH.js';
|
|
25
25
|
export { e as A2AArtifact, M as A2AMessage, P as A2APart, b as A2ATask, g as A2ATaskStatus, a as AgentCard, A as AgentSkill } from './types-NIyVwQ4h.js';
|
|
@@ -42,6 +42,13 @@ interface PresetOptions {
|
|
|
42
42
|
mcpServers?: Record<string, McpServerConfig>;
|
|
43
43
|
/** Custom system prompt prepended to the built-in prompt. */
|
|
44
44
|
systemPrompt?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Opt-in AI-generated session titles. `true` uses the agent's main
|
|
47
|
+
* provider / model; pass a config object to override the model or
|
|
48
|
+
* provider (typically a cheaper one like Haiku) used for title
|
|
49
|
+
* generation only.
|
|
50
|
+
*/
|
|
51
|
+
autoTitle?: AutoTitleConfig | boolean;
|
|
45
52
|
}
|
|
46
53
|
/**
|
|
47
54
|
* Full-featured coding agent with subagents, tasks, plan mode, auto-compact,
|
|
@@ -1393,4 +1400,4 @@ declare const IMAGE_EXTENSIONS: Set<string>;
|
|
|
1393
1400
|
*/
|
|
1394
1401
|
declare function createImageMetadataText(dims: ImageDimensions): string;
|
|
1395
1402
|
|
|
1396
|
-
export { AIProvider, API_IMAGE_MAX_BASE64_SIZE, Agent, AssistantMessage, AutoModeConfig, type CacheSafeParams, CannotRetryError, ChatCompletionUsage, ChatMessage, ChatStreamChunk, type ClassifiedError, type ClassifierResult, type CommandClassification, CommandResult, type CompactOptions, type CompressedImageResult, ContentPart, ContentReplacementRecord, ContextFile, ContextScope, DEFAULT_PRICING, type DenialLimits, type DenialState, DenialTracker, ExecOptions, type ExtractMemoriesResult, FileCheckpointSnapshot, FileEntry, FileMemoryProvider, FileStat, type FrontmatterData, type GitOperationEvent, type GitOperationType, HookDefinition, HookEvent, HookInput, IMAGE_EXTENSIONS, IMAGE_MAX_HEIGHT, IMAGE_MAX_WIDTH, type ImageDimensions, InProcessBackend, type IndexTruncation, InvariantViolation, JsonSchemaOutputFormat, LocalComputer, type LocalComputerOptions, LocalFs, type LocalFsOptions, Mailbox, McpServerConfig, MemoryEntry, MemoryProvider, ModelPricing, NoopSpan, NoopTracer, OTelTracer, type ParsedFrontmatter, PermissionBehavior, PermissionContext, PermissionDecision, PermissionHandler, PermissionRule, PermissionUpdate, PostToolUseFailureHookInput, PostToolUseFailureHookOutput, PostToolUseHookInput, PostToolUseHookOutput, PreToolUseHookInput, PreToolUseHookOutput, type PresetOptions, ProjectContextConfig, ReadOptions, type ResizedImage, type ResolvePermissionOptions, type ResumePayload, RetryConfig, RetryContext, RetryEngineOptions, STRUCTURED_OUTPUT_TOOL_NAME, Sandbox, type SanitizeResult, type ShellSafetyConfig, SkillDefinition, Span, SpanAttributeValue, SpanOptions, SpanStatusCode, StoredCostState, StreamEvent, type StreamingExecResult, StreamingToolExecutor, type StreamingToolExecutorFn, type SwarmBackend, type SwarmConfig, type SwarmEvents, SwarmManager, type SwarmMember, type SwarmMemberConfig, type SwarmMemberStatus, type SwarmMessage, type SwarmStatus, TOOL_SEARCH_NAME, ThinkingConfig, ThreadConfig, Tool, ToolCallContent, type ToolCallExecResult, type ToolCallExecutor, ToolResult as ToolCallResult, ToolContext, ToolDefinition, ToolRegistry, ToolResultMessage, ToolResultOverflowEntry, type ToolWithDeferral, Tracer, type TurnInterruption, UsageRecord, type UserInputHandler, VirtualComputer, VirtualFs, type WorktreeInfo, activateContextForPaths, activateSkillsForPaths, agentTool, all, applyPermissionUpdate, applyPermissionUpdates, askUserTool, assertValidMessageSequence, bashTool, buildExtractionPrompt, buildMemorySystemPromptSection, buildProjectContextSection, buildSystemPrompt, calculateCost, classifyCommand, classifyError, classifyPermission, codingAgent, commandWritesGitInternals, compactConversation, compressImageBufferWithTokenLimit, contentMatchesRule, contentToString, countOccurrences, createCacheSafeParams, createImageMetadataText, createSkillTool, createStructuredOutputTool, createToolSearchTool, createWorktree, detectGitOperations, detectTurnInterruption, editFileTool, enterPlanModeTool, enterWorktreeTool, estimateCompactionSavings, estimateMessagesTokens, estimateTokens, exitPlanModeTool, exitWorktreeTool, extractCommandName, extractMemories, filterActiveContextFiles, filterOrphanedThinkingMessages, filterUnresolvedToolUses, filterWhitespaceOnlyAssistantMessages, findActualString, findGitRoot, findModelPricing, formatDeferredToolLine, generateMissingToolResults, getActiveSkills, getAutoCompactThreshold, getContextWindowForModel, getEffectiveContextWindow, getLastCacheSafeParams, getMatchingRules, getRetryDelay, getWorktreeChanges, globTool, grepTool, groupMessagesByTurn, hasGitIndexLockError, hasImageContent, isDeferredTool, isGitInternalPath, isPathInWorkingDirectories, isRetryable, listWorktrees, loadProjectContext, loadSkills, looksLikeBareRepo, matchSimpleGlob, maybeResizeAndDownsampleImageBlock, maybeResizeAndDownsampleImageBuffer, normalizeContent, normalizeMessagesForAPI, normalizeQuotes, notebookEditTool, parseAllowedTools, parseFrontmatter, parsePaths, partitionToolCalls, planningAgent, preserveQuoteStyle, readFileTool, registerContextWindows, removeWorktree, resolvePermission, resolveToolFlag, restoreSession, reviewAgent, runNotificationHooks, runPostToolUseFailureHooks, runPostToolUseHooks, runPreToolUseHooks, runToolsBatched, sanitizeForResume, sanitizeWorktreeSlug, saveCacheSafeParams, searchToolsWithKeywords, stripImageContent, stripTrailingWhitespace, taskCreateTool, taskGetTool, taskListTool, taskUpdateTool, tokenCountWithEstimation, toolMatchesRule, truncateHeadForPTLRetry, truncateIndex, webFetchTool, withRetry, writeFileTool };
|
|
1403
|
+
export { AIProvider, API_IMAGE_MAX_BASE64_SIZE, Agent, AssistantMessage, AutoModeConfig, AutoTitleConfig, type CacheSafeParams, CannotRetryError, ChatCompletionUsage, ChatMessage, ChatStreamChunk, type ClassifiedError, type ClassifierResult, type CommandClassification, CommandResult, type CompactOptions, type CompressedImageResult, ContentPart, ContentReplacementRecord, ContextFile, ContextScope, DEFAULT_PRICING, type DenialLimits, type DenialState, DenialTracker, ExecOptions, type ExtractMemoriesResult, FileCheckpointSnapshot, FileEntry, FileMemoryProvider, FileStat, type FrontmatterData, type GitOperationEvent, type GitOperationType, HookDefinition, HookEvent, HookInput, IMAGE_EXTENSIONS, IMAGE_MAX_HEIGHT, IMAGE_MAX_WIDTH, type ImageDimensions, InProcessBackend, type IndexTruncation, InvariantViolation, JsonSchemaOutputFormat, LocalComputer, type LocalComputerOptions, LocalFs, type LocalFsOptions, Mailbox, McpServerConfig, MemoryEntry, MemoryProvider, ModelPricing, NoopSpan, NoopTracer, OTelTracer, type ParsedFrontmatter, PermissionBehavior, PermissionContext, PermissionDecision, PermissionHandler, PermissionRule, PermissionUpdate, PostToolUseFailureHookInput, PostToolUseFailureHookOutput, PostToolUseHookInput, PostToolUseHookOutput, PreToolUseHookInput, PreToolUseHookOutput, type PresetOptions, ProjectContextConfig, ReadOptions, type ResizedImage, type ResolvePermissionOptions, type ResumePayload, RetryConfig, RetryContext, RetryEngineOptions, STRUCTURED_OUTPUT_TOOL_NAME, Sandbox, type SanitizeResult, SessionStorage, type ShellSafetyConfig, SkillDefinition, Span, SpanAttributeValue, SpanOptions, SpanStatusCode, StoredCostState, StreamEvent, type StreamingExecResult, StreamingToolExecutor, type StreamingToolExecutorFn, type SwarmBackend, type SwarmConfig, type SwarmEvents, SwarmManager, type SwarmMember, type SwarmMemberConfig, type SwarmMemberStatus, type SwarmMessage, type SwarmStatus, TOOL_SEARCH_NAME, ThinkingConfig, ThreadConfig, Tool, ToolCallContent, type ToolCallExecResult, type ToolCallExecutor, ToolResult as ToolCallResult, ToolContext, ToolDefinition, ToolRegistry, ToolResultMessage, ToolResultOverflowEntry, type ToolWithDeferral, Tracer, type TurnInterruption, UsageRecord, type UserInputHandler, VirtualComputer, VirtualFs, type WorktreeInfo, activateContextForPaths, activateSkillsForPaths, agentTool, all, applyPermissionUpdate, applyPermissionUpdates, askUserTool, assertValidMessageSequence, bashTool, buildExtractionPrompt, buildMemorySystemPromptSection, buildProjectContextSection, buildSystemPrompt, calculateCost, classifyCommand, classifyError, classifyPermission, codingAgent, commandWritesGitInternals, compactConversation, compressImageBufferWithTokenLimit, contentMatchesRule, contentToString, countOccurrences, createCacheSafeParams, createImageMetadataText, createSkillTool, createStructuredOutputTool, createToolSearchTool, createWorktree, detectGitOperations, detectTurnInterruption, editFileTool, enterPlanModeTool, enterWorktreeTool, estimateCompactionSavings, estimateMessagesTokens, estimateTokens, exitPlanModeTool, exitWorktreeTool, extractCommandName, extractMemories, filterActiveContextFiles, filterOrphanedThinkingMessages, filterUnresolvedToolUses, filterWhitespaceOnlyAssistantMessages, findActualString, findGitRoot, findModelPricing, formatDeferredToolLine, generateMissingToolResults, getActiveSkills, getAutoCompactThreshold, getContextWindowForModel, getEffectiveContextWindow, getLastCacheSafeParams, getMatchingRules, getRetryDelay, getWorktreeChanges, globTool, grepTool, groupMessagesByTurn, hasGitIndexLockError, hasImageContent, isDeferredTool, isGitInternalPath, isPathInWorkingDirectories, isRetryable, listWorktrees, loadProjectContext, loadSkills, looksLikeBareRepo, matchSimpleGlob, maybeResizeAndDownsampleImageBlock, maybeResizeAndDownsampleImageBuffer, normalizeContent, normalizeMessagesForAPI, normalizeQuotes, notebookEditTool, parseAllowedTools, parseFrontmatter, parsePaths, partitionToolCalls, planningAgent, preserveQuoteStyle, readFileTool, registerContextWindows, removeWorktree, resolvePermission, resolveToolFlag, restoreSession, reviewAgent, runNotificationHooks, runPostToolUseFailureHooks, runPostToolUseHooks, runPreToolUseHooks, runToolsBatched, sanitizeForResume, sanitizeWorktreeSlug, saveCacheSafeParams, searchToolsWithKeywords, stripImageContent, stripTrailingWhitespace, taskCreateTool, taskGetTool, taskListTool, taskUpdateTool, tokenCountWithEstimation, toolMatchesRule, truncateHeadForPTLRetry, truncateIndex, webFetchTool, withRetry, writeFileTool };
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,8 @@ import {
|
|
|
4
4
|
COMPACTABLE_TOOLS,
|
|
5
5
|
CannotRetryError,
|
|
6
6
|
CostTracker,
|
|
7
|
+
DEFAULT_AUTO_TITLE_MAX_INPUT_CHARS,
|
|
8
|
+
DEFAULT_AUTO_TITLE_SYSTEM_PROMPT,
|
|
7
9
|
DEFAULT_PRICING,
|
|
8
10
|
DEFAULT_RETRY_CONFIG,
|
|
9
11
|
DenialTracker,
|
|
@@ -21,6 +23,7 @@ import {
|
|
|
21
23
|
OTelTracer,
|
|
22
24
|
STRUCTURED_OUTPUT_TOOL_NAME,
|
|
23
25
|
SandboxedLocalComputer,
|
|
26
|
+
SessionStorage,
|
|
24
27
|
SpanStatusCode,
|
|
25
28
|
StreamingToolExecutor,
|
|
26
29
|
SwarmManager,
|
|
@@ -65,12 +68,15 @@ import {
|
|
|
65
68
|
exitPlanModeTool,
|
|
66
69
|
exitWorktreeTool,
|
|
67
70
|
extractMemories,
|
|
71
|
+
extractTitleFromResponse,
|
|
72
|
+
extractTitleSeedText,
|
|
68
73
|
filterActiveContextFiles,
|
|
69
74
|
filterOrphanedThinkingMessages,
|
|
70
75
|
filterUnresolvedToolUses,
|
|
71
76
|
filterWhitespaceOnlyAssistantMessages,
|
|
72
77
|
findGitRoot,
|
|
73
78
|
findModelPricing,
|
|
79
|
+
generateAutoTitle,
|
|
74
80
|
generateMissingToolResults,
|
|
75
81
|
getActiveSkills,
|
|
76
82
|
getLastCacheSafeParams,
|
|
@@ -83,6 +89,7 @@ import {
|
|
|
83
89
|
loadSkills,
|
|
84
90
|
microcompactMessages,
|
|
85
91
|
normalizeMessagesForAPI,
|
|
92
|
+
normalizeTitle,
|
|
86
93
|
parseAllowedTools,
|
|
87
94
|
parseFrontmatter,
|
|
88
95
|
parsePaths,
|
|
@@ -114,13 +121,13 @@ import {
|
|
|
114
121
|
tryReactiveCompact,
|
|
115
122
|
webSearchToolPlaceholder,
|
|
116
123
|
withRetry
|
|
117
|
-
} from "./chunk-
|
|
124
|
+
} from "./chunk-6MMYCGJQ.js";
|
|
118
125
|
import {
|
|
119
126
|
DEFAULT_MODELS,
|
|
120
127
|
SUPPORTED_PROVIDERS,
|
|
121
128
|
detectProvider,
|
|
122
129
|
resolveProvider
|
|
123
|
-
} from "./chunk-
|
|
130
|
+
} from "./chunk-7IQCQI2G.js";
|
|
124
131
|
import {
|
|
125
132
|
applySnipRemovals,
|
|
126
133
|
projectSnippedView,
|
|
@@ -195,7 +202,7 @@ import {
|
|
|
195
202
|
} from "./chunk-HEQQQGK5.js";
|
|
196
203
|
import {
|
|
197
204
|
ChatStreamError
|
|
198
|
-
} from "./chunk-
|
|
205
|
+
} from "./chunk-CCM2AXZG.js";
|
|
199
206
|
import "./chunk-3HEYCV26.js";
|
|
200
207
|
import {
|
|
201
208
|
contentToString,
|
|
@@ -212,6 +219,8 @@ export {
|
|
|
212
219
|
CannotRetryError,
|
|
213
220
|
ChatStreamError,
|
|
214
221
|
CostTracker,
|
|
222
|
+
DEFAULT_AUTO_TITLE_MAX_INPUT_CHARS,
|
|
223
|
+
DEFAULT_AUTO_TITLE_SYSTEM_PROMPT,
|
|
215
224
|
DEFAULT_MODELS,
|
|
216
225
|
DEFAULT_PRICING,
|
|
217
226
|
DEFAULT_RETRY_CONFIG,
|
|
@@ -235,6 +244,7 @@ export {
|
|
|
235
244
|
STRUCTURED_OUTPUT_TOOL_NAME,
|
|
236
245
|
SUPPORTED_PROVIDERS,
|
|
237
246
|
SandboxedLocalComputer,
|
|
247
|
+
SessionStorage,
|
|
238
248
|
SpanStatusCode,
|
|
239
249
|
StreamingToolExecutor,
|
|
240
250
|
SwarmManager,
|
|
@@ -298,6 +308,8 @@ export {
|
|
|
298
308
|
exitWorktreeTool,
|
|
299
309
|
extractCommandName,
|
|
300
310
|
extractMemories,
|
|
311
|
+
extractTitleFromResponse,
|
|
312
|
+
extractTitleSeedText,
|
|
301
313
|
filterActiveContextFiles,
|
|
302
314
|
filterOrphanedThinkingMessages,
|
|
303
315
|
filterUnresolvedToolUses,
|
|
@@ -307,6 +319,7 @@ export {
|
|
|
307
319
|
findModelPricing,
|
|
308
320
|
formatDeferredToolLine,
|
|
309
321
|
formatZodValidationError,
|
|
322
|
+
generateAutoTitle,
|
|
310
323
|
generateMissingToolResults,
|
|
311
324
|
getActiveSkills,
|
|
312
325
|
getAutoCompactThreshold,
|
|
@@ -339,6 +352,7 @@ export {
|
|
|
339
352
|
normalizeMessagesForAPI,
|
|
340
353
|
normalizeNameForMCP,
|
|
341
354
|
normalizeQuotes,
|
|
355
|
+
normalizeTitle,
|
|
342
356
|
notebookEditTool,
|
|
343
357
|
parseAllowedTools,
|
|
344
358
|
parseFrontmatter,
|
package/dist/lsp/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { L as LspServerConfig, a as LspServerState, b as LspDiagnostic, T as Tool } from '../types-
|
|
2
|
-
export { D as DiagnosticRegistry, c as LspLocation, d as LspOperation, e as LspServerManager, f as LspSymbol } from '../types-
|
|
3
|
-
import '../types-
|
|
1
|
+
import { L as LspServerConfig, a as LspServerState, b as LspDiagnostic, T as Tool } from '../types-DhXwOQwD.js';
|
|
2
|
+
export { D as DiagnosticRegistry, c as LspLocation, d as LspOperation, e as LspServerManager, f as LspSymbol } from '../types-DhXwOQwD.js';
|
|
3
|
+
import '../types-kiGBF35b.js';
|
|
4
4
|
import '../computer-BPdxSo6X.js';
|
|
5
5
|
import '../types-CD0rUKKT.js';
|
|
6
6
|
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { M as McpClientManager } from '../server-
|
|
2
|
-
export { a as McpClientManagerOptions, b as McpServerOptions, c as buildMcpToolName, d as createMcpServer, g as getMcpPrefix, n as normalizeNameForMCP, p as parseMcpToolName } from '../server-
|
|
1
|
+
import { M as McpClientManager } from '../server-BzNGKTP6.js';
|
|
2
|
+
export { a as McpClientManagerOptions, b as McpServerOptions, c as buildMcpToolName, d as createMcpServer, g as getMcpPrefix, n as normalizeNameForMCP, p as parseMcpToolName } from '../server-BzNGKTP6.js';
|
|
3
3
|
import { T as TokenStorage, O as OAuthTokenData, a as OAuthProviderOptions } from '../types-2kTLUCnD.js';
|
|
4
4
|
export { b as McpConfig, c as McpConnection, d as McpHttpServerConfig, e as McpOAuthConfig, M as McpServerConfig, f as McpSseServerConfig, g as McpStdioServerConfig, h as McpToolInfo, i as McpWebSocketServerConfig } from '../types-2kTLUCnD.js';
|
|
5
5
|
import { OAuthClientProvider, OAuthDiscoveryState } from '@modelcontextprotocol/sdk/client/auth.js';
|
|
6
6
|
export { OAuthClientProvider, OAuthDiscoveryState } from '@modelcontextprotocol/sdk/client/auth.js';
|
|
7
7
|
import { OAuthClientMetadata, OAuthClientInformationMixed, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
|
|
8
8
|
export { OAuthClientInformation, OAuthClientInformationFull, OAuthClientInformationMixed, OAuthClientMetadata, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
|
|
9
|
-
import { T as Tool } from '../types-
|
|
9
|
+
import { T as Tool } from '../types-DhXwOQwD.js';
|
|
10
10
|
import '@modelcontextprotocol/sdk/client/index.js';
|
|
11
|
-
import '../types-
|
|
11
|
+
import '../types-kiGBF35b.js';
|
|
12
12
|
import '../computer-BPdxSo6X.js';
|
|
13
13
|
import '../types-CD0rUKKT.js';
|
|
14
14
|
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
SUPPORTED_PROVIDERS,
|
|
8
8
|
detectProvider,
|
|
9
9
|
resolveProvider
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-7IQCQI2G.js";
|
|
11
11
|
import "./chunk-DGUM43GV.js";
|
|
12
12
|
export {
|
|
13
13
|
DEFAULT_MODELS,
|
|
@@ -17,4 +17,4 @@ export {
|
|
|
17
17
|
isOllamaRunning,
|
|
18
18
|
ollamaBaseURL
|
|
19
19
|
};
|
|
20
|
-
//# sourceMappingURL=provider-factory-
|
|
20
|
+
//# sourceMappingURL=provider-factory-TUHU3DIG.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AIProvider, C as ChatParams, a as ChatStreamChunk } from '../types-
|
|
2
|
-
import { C as CacheControlConfig } from '../cache-
|
|
1
|
+
import { A as AIProvider, C as ChatParams, a as ChatStreamChunk } from '../types-kiGBF35b.js';
|
|
2
|
+
import { C as CacheControlConfig } from '../cache-BlBwXXPS.js';
|
|
3
3
|
|
|
4
4
|
interface AnthropicProviderOptions {
|
|
5
5
|
apiKey: string;
|
|
@@ -10,7 +10,7 @@ interface AnthropicProviderOptions {
|
|
|
10
10
|
}
|
|
11
11
|
declare class AnthropicProvider implements AIProvider {
|
|
12
12
|
private client;
|
|
13
|
-
|
|
13
|
+
readonly defaultModel: string;
|
|
14
14
|
private cacheConfig;
|
|
15
15
|
constructor(opts: AnthropicProviderOptions);
|
|
16
16
|
chat(params: ChatParams): AsyncIterable<ChatStreamChunk>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
+
DEFAULT_ANTHROPIC_MODEL,
|
|
2
3
|
streamAnthropicChat
|
|
3
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-ZXSDKBYB.js";
|
|
4
5
|
import "../chunk-HEQQQGK5.js";
|
|
5
|
-
import "../chunk-
|
|
6
|
+
import "../chunk-CCM2AXZG.js";
|
|
6
7
|
import "../chunk-DGUM43GV.js";
|
|
7
8
|
|
|
8
9
|
// src/providers/anthropic.ts
|
|
@@ -17,7 +18,7 @@ var AnthropicProvider = class {
|
|
|
17
18
|
baseURL: opts.baseURL,
|
|
18
19
|
maxRetries: 0
|
|
19
20
|
});
|
|
20
|
-
this.defaultModel = opts.model ??
|
|
21
|
+
this.defaultModel = opts.model ?? DEFAULT_ANTHROPIC_MODEL;
|
|
21
22
|
this.cacheConfig = opts.cacheControl;
|
|
22
23
|
}
|
|
23
24
|
async *chat(params) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/providers/anthropic.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport type {\n AIProvider,\n ChatParams,\n ChatStreamChunk,\n} from \"./types.js\";\nimport type { CacheControlConfig } from \"./cache.js\";\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/providers/anthropic.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport type {\n AIProvider,\n ChatParams,\n ChatStreamChunk,\n} from \"./types.js\";\nimport type { CacheControlConfig } from \"./cache.js\";\nimport {\n streamAnthropicChat,\n type AnthropicStreamClient,\n DEFAULT_ANTHROPIC_MODEL,\n} from \"./anthropic-shared.js\";\n\nexport interface AnthropicProviderOptions {\n apiKey: string;\n baseURL?: string;\n model?: string;\n /** When enabled, injects cache_control markers on system prompt, tools, and messages. */\n cacheControl?: CacheControlConfig;\n}\n\nexport class AnthropicProvider implements AIProvider {\n private client: Anthropic;\n readonly defaultModel: string;\n private cacheConfig: CacheControlConfig | undefined;\n\n constructor(opts: AnthropicProviderOptions) {\n this.client = new Anthropic({\n apiKey: opts.apiKey,\n baseURL: opts.baseURL,\n maxRetries: 0,\n });\n this.defaultModel = opts.model ?? DEFAULT_ANTHROPIC_MODEL;\n this.cacheConfig = opts.cacheControl;\n }\n\n async *chat(params: ChatParams): AsyncIterable<ChatStreamChunk> {\n yield* streamAnthropicChat(\n this.client as unknown as AnthropicStreamClient,\n params,\n this.defaultModel,\n this.cacheConfig,\n );\n }\n}\n"],"mappings":";;;;;;;;;AAAA,OAAO,eAAe;AAqBf,IAAM,oBAAN,MAA8C;AAAA,EAC3C;AAAA,EACC;AAAA,EACD;AAAA,EAER,YAAY,MAAgC;AAC1C,SAAK,SAAS,IAAI,UAAU;AAAA,MAC1B,QAAQ,KAAK;AAAA,MACb,SAAS,KAAK;AAAA,MACd,YAAY;AAAA,IACd,CAAC;AACD,SAAK,eAAe,KAAK,SAAS;AAClC,SAAK,cAAc,KAAK;AAAA,EAC1B;AAAA,EAEA,OAAO,KAAK,QAAoD;AAC9D,WAAO;AAAA,MACL,KAAK;AAAA,MACL;AAAA,MACA,KAAK;AAAA,MACL,KAAK;AAAA,IACP;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AIProvider, C as ChatParams, a as ChatStreamChunk } from '../types-
|
|
2
|
-
import { C as CacheControlConfig } from '../cache-
|
|
1
|
+
import { A as AIProvider, C as ChatParams, a as ChatStreamChunk } from '../types-kiGBF35b.js';
|
|
2
|
+
import { C as CacheControlConfig } from '../cache-BlBwXXPS.js';
|
|
3
3
|
|
|
4
4
|
interface BedrockAnthropicProviderOptions {
|
|
5
5
|
/** AWS region (default: us-east-1). */
|
|
@@ -30,7 +30,7 @@ interface BedrockAnthropicProviderOptions {
|
|
|
30
30
|
*/
|
|
31
31
|
declare class BedrockAnthropicProvider implements AIProvider {
|
|
32
32
|
private client;
|
|
33
|
-
|
|
33
|
+
readonly defaultModel: string;
|
|
34
34
|
private cacheConfig;
|
|
35
35
|
constructor(opts: BedrockAnthropicProviderOptions);
|
|
36
36
|
chat(params: ChatParams): AsyncIterable<ChatStreamChunk>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/providers/bedrock.ts"],"sourcesContent":["import type {\n AIProvider,\n ChatParams,\n ChatStreamChunk,\n} from \"./types.js\";\nimport type { CacheControlConfig } from \"./cache.js\";\nimport { streamAnthropicChat, type AnthropicStreamClient } from \"./anthropic-shared.js\";\n\nexport interface BedrockAnthropicProviderOptions {\n /** AWS region (default: us-east-1). */\n region?: string;\n /** Explicit AWS credentials. If omitted, the SDK uses the default credential chain. */\n credentials?: {\n accessKeyId: string;\n secretAccessKey: string;\n sessionToken?: string;\n };\n /** Model ID in Bedrock format (default: us.anthropic.claude-opus-4.6-v1:0). */\n model?: string;\n /** Custom base URL for a Bedrock-compatible endpoint. */\n baseURL?: string;\n /** Cache control config (same as AnthropicProvider). */\n cacheControl?: CacheControlConfig;\n /**\n * Pre-constructed AnthropicBedrock client. When provided, all other\n * connection options are ignored. Useful for testing or advanced setups.\n */\n client?: unknown;\n}\n\n/**\n * Anthropic provider routed through AWS Bedrock.\n *\n * Requires `@anthropic-ai/bedrock-sdk` as an optional peer dependency.\n * Install it with: `pnpm add @anthropic-ai/bedrock-sdk`\n */\nexport class BedrockAnthropicProvider implements AIProvider {\n private client: AnthropicStreamClient;\n
|
|
1
|
+
{"version":3,"sources":["../../src/providers/bedrock.ts"],"sourcesContent":["import type {\n AIProvider,\n ChatParams,\n ChatStreamChunk,\n} from \"./types.js\";\nimport type { CacheControlConfig } from \"./cache.js\";\nimport { streamAnthropicChat, type AnthropicStreamClient } from \"./anthropic-shared.js\";\n\nexport interface BedrockAnthropicProviderOptions {\n /** AWS region (default: us-east-1). */\n region?: string;\n /** Explicit AWS credentials. If omitted, the SDK uses the default credential chain. */\n credentials?: {\n accessKeyId: string;\n secretAccessKey: string;\n sessionToken?: string;\n };\n /** Model ID in Bedrock format (default: us.anthropic.claude-opus-4.6-v1:0). */\n model?: string;\n /** Custom base URL for a Bedrock-compatible endpoint. */\n baseURL?: string;\n /** Cache control config (same as AnthropicProvider). */\n cacheControl?: CacheControlConfig;\n /**\n * Pre-constructed AnthropicBedrock client. When provided, all other\n * connection options are ignored. Useful for testing or advanced setups.\n */\n client?: unknown;\n}\n\n/**\n * Anthropic provider routed through AWS Bedrock.\n *\n * Requires `@anthropic-ai/bedrock-sdk` as an optional peer dependency.\n * Install it with: `pnpm add @anthropic-ai/bedrock-sdk`\n */\nexport class BedrockAnthropicProvider implements AIProvider {\n private client: AnthropicStreamClient;\n readonly defaultModel: string;\n private cacheConfig: CacheControlConfig | undefined;\n\n constructor(opts: BedrockAnthropicProviderOptions) {\n if (opts.client) {\n this.client = opts.client as AnthropicStreamClient;\n } else {\n let AnthropicBedrock: new (args: Record<string, unknown>) => unknown;\n try {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n AnthropicBedrock = require(\"@anthropic-ai/bedrock-sdk\").AnthropicBedrock;\n } catch {\n throw new Error(\n \"BedrockAnthropicProvider requires @anthropic-ai/bedrock-sdk. \" +\n \"Install it with: pnpm add @anthropic-ai/bedrock-sdk\",\n );\n }\n\n const args: Record<string, unknown> = {\n awsRegion: opts.region ?? \"us-east-1\",\n maxRetries: 0,\n };\n if (opts.baseURL) args.baseURL = opts.baseURL;\n if (opts.credentials) {\n args.awsAccessKey = opts.credentials.accessKeyId;\n args.awsSecretKey = opts.credentials.secretAccessKey;\n if (opts.credentials.sessionToken) {\n args.awsSessionToken = opts.credentials.sessionToken;\n }\n }\n\n this.client = new AnthropicBedrock(args) as unknown as AnthropicStreamClient;\n }\n\n this.defaultModel =\n opts.model ?? \"us.anthropic.claude-opus-4.6-v1:0\";\n this.cacheConfig = opts.cacheControl;\n }\n\n async *chat(params: ChatParams): AsyncIterable<ChatStreamChunk> {\n yield* streamAnthropicChat(\n this.client,\n params,\n this.defaultModel,\n this.cacheConfig,\n );\n }\n}\n"],"mappings":";;;;;;;;;;AAoCO,IAAM,2BAAN,MAAqD;AAAA,EAClD;AAAA,EACC;AAAA,EACD;AAAA,EAER,YAAY,MAAuC;AACjD,QAAI,KAAK,QAAQ;AACf,WAAK,SAAS,KAAK;AAAA,IACrB,OAAO;AACL,UAAI;AACJ,UAAI;AAEF,2BAAmB,UAAQ,2BAA2B,EAAE;AAAA,MAC1D,QAAQ;AACN,cAAM,IAAI;AAAA,UACR;AAAA,QAEF;AAAA,MACF;AAEA,YAAM,OAAgC;AAAA,QACpC,WAAW,KAAK,UAAU;AAAA,QAC1B,YAAY;AAAA,MACd;AACA,UAAI,KAAK,QAAS,MAAK,UAAU,KAAK;AACtC,UAAI,KAAK,aAAa;AACpB,aAAK,eAAe,KAAK,YAAY;AACrC,aAAK,eAAe,KAAK,YAAY;AACrC,YAAI,KAAK,YAAY,cAAc;AACjC,eAAK,kBAAkB,KAAK,YAAY;AAAA,QAC1C;AAAA,MACF;AAEA,WAAK,SAAS,IAAI,iBAAiB,IAAI;AAAA,IACzC;AAEA,SAAK,eACH,KAAK,SAAS;AAChB,SAAK,cAAc,KAAK;AAAA,EAC1B;AAAA,EAEA,OAAO,KAAK,QAAoD;AAC9D,WAAO;AAAA,MACL,KAAK;AAAA,MACL;AAAA,MACA,KAAK;AAAA,MACL,KAAK;AAAA,IACP;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as AIProvider, C as ChatParams, a as ChatStreamChunk } from '../types-
|
|
1
|
+
import { A as AIProvider, C as ChatParams, a as ChatStreamChunk } from '../types-kiGBF35b.js';
|
|
2
2
|
|
|
3
3
|
interface GeminiProviderOptions {
|
|
4
4
|
apiKey: string;
|
|
@@ -7,7 +7,7 @@ interface GeminiProviderOptions {
|
|
|
7
7
|
}
|
|
8
8
|
declare class GeminiProvider implements AIProvider {
|
|
9
9
|
private client;
|
|
10
|
-
|
|
10
|
+
readonly defaultModel: string;
|
|
11
11
|
constructor(opts: GeminiProviderOptions);
|
|
12
12
|
chat(params: ChatParams): AsyncIterable<ChatStreamChunk>;
|
|
13
13
|
private static contentPartsToGemini;
|