zidane 7.0.19 → 7.0.22
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/{acp-BgNj1-gv.js → acp-BhbXWwj_.js} +2 -2
- package/dist/{acp-BgNj1-gv.js.map → acp-BhbXWwj_.js.map} +1 -1
- package/dist/acp-cli.js +4 -4
- package/dist/acp.d.ts +1 -1
- package/dist/acp.js +1 -1
- package/dist/{agent-Djzx-1kD.js → agent-LC2c1ue-.js} +18 -5
- package/dist/{agent-Djzx-1kD.js.map → agent-LC2c1ue-.js.map} +1 -1
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +1 -1
- package/dist/{anthropic-DATE-m9f.js → anthropic-BSbDiW0J.js} +34 -4
- package/dist/anthropic-BSbDiW0J.js.map +1 -0
- package/dist/{approvals-Jztqzqjk.js → approvals-BnDsgTtD.js} +4 -4
- package/dist/{approvals-Jztqzqjk.js.map → approvals-BnDsgTtD.js.map} +1 -1
- package/dist/{auth-DhkLW1Wu.js → auth-Nq-tSMb9.js} +53 -35
- package/dist/{auth-DhkLW1Wu.js.map → auth-Nq-tSMb9.js.map} +1 -1
- package/dist/chat/pure.d.ts +3 -3
- package/dist/chat/pure.js +2 -2
- package/dist/chat.d.ts +5 -5
- package/dist/chat.js +5 -5
- package/dist/{context-segments-CJCtJ9sU.js → context-segments-BrEsRhA0.js} +11 -3
- package/dist/context-segments-BrEsRhA0.js.map +1 -0
- package/dist/contexts/daytona.d.ts +1 -1
- package/dist/contexts/e2b.d.ts +1 -1
- package/dist/daemon-cli.js +1 -1
- package/dist/eval.d.ts +1 -1
- package/dist/extensions.d.ts +1 -1
- package/dist/extensions.js +1 -1
- package/dist/headless.d.ts +1 -1
- package/dist/headless.js +1 -1
- package/dist/{index-CfEJ5Vf9.d.ts → index-C4mY0oKE.d.ts} +18 -21
- package/dist/index-C4mY0oKE.d.ts.map +1 -0
- package/dist/{index-498gAVpL.d.ts → index-D2JCY11Z.d.ts} +5 -5
- package/dist/index-D2JCY11Z.d.ts.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/{ipc-B4p0P2tz.js → ipc-Oro3uyMP.js} +2 -2
- package/dist/{ipc-B4p0P2tz.js.map → ipc-Oro3uyMP.js.map} +1 -1
- package/dist/ipc.d.ts +15 -5
- package/dist/ipc.d.ts.map +1 -1
- package/dist/ipc.js +3 -3
- package/dist/mcp.d.ts +1 -1
- package/dist/{oauth-D-LZ4ic-.js → oauth-CmtlmCzi.js} +142 -210
- package/dist/oauth-CmtlmCzi.js.map +1 -0
- package/dist/output/stream-json.d.ts +1 -1
- package/dist/output/terminal.d.ts +1 -1
- package/dist/plugins.d.ts +1 -1
- package/dist/presets.d.ts +1 -1
- package/dist/presets.js +1 -1
- package/dist/providers/anthropic.d.ts +1 -1
- package/dist/providers/anthropic.js +1 -1
- package/dist/providers/arcee.d.ts +1 -1
- package/dist/providers/baseten.d.ts +1 -1
- package/dist/providers/cerebras.d.ts +1 -1
- package/dist/providers/local.d.ts +1 -1
- package/dist/providers/openai-compat.d.ts +1 -1
- package/dist/providers/openai.d.ts +1 -1
- package/dist/providers/openai.js +1 -1
- package/dist/providers/openrouter.d.ts +1 -1
- package/dist/providers/xai.d.ts +1 -1
- package/dist/providers/xai.js +1 -1
- package/dist/{providers-Bjdvmpfu.js → providers-ZucqgwU7.js} +2 -2
- package/dist/{providers-Bjdvmpfu.js.map → providers-ZucqgwU7.js.map} +1 -1
- package/dist/providers.d.ts +1 -1
- package/dist/providers.js +3 -3
- package/dist/restate.d.ts +1 -1
- package/dist/restate.js +1 -1
- package/dist/{server-Cccx5jES.js → server-HZdjqDpS.js} +67 -10
- package/dist/server-HZdjqDpS.js.map +1 -0
- package/dist/session/sqlite.d.ts +1 -1
- package/dist/session.d.ts +1 -1
- package/dist/skills.d.ts +1 -1
- package/dist/{tool-formatters-D1rdZOe3.d.ts → tool-formatters-GZHxP824.d.ts} +2 -2
- package/dist/{tool-formatters-D1rdZOe3.d.ts.map → tool-formatters-GZHxP824.d.ts.map} +1 -1
- package/dist/tools/fetch-url.d.ts +1 -1
- package/dist/tools/web-search.d.ts +1 -1
- package/dist/tools.d.ts +1 -1
- package/dist/tools.js +1 -1
- package/dist/{transcript-anchors-pHga6mOC.d.ts → transcript-anchors-CY50AXdF.d.ts} +2 -2
- package/dist/{transcript-anchors-pHga6mOC.d.ts.map → transcript-anchors-CY50AXdF.d.ts.map} +1 -1
- package/dist/tui.d.ts +3 -3
- package/dist/tui.js +6 -6
- package/dist/{turn-operations-Dt5L8smX.js → turn-operations-BgqpLlOG.js} +2 -2
- package/dist/{turn-operations-Dt5L8smX.js.map → turn-operations-BgqpLlOG.js.map} +1 -1
- package/dist/{turn-operations-Dzo-8TKC.d.ts → turn-operations-CAmNETlu.d.ts} +3 -3
- package/dist/{turn-operations-Dzo-8TKC.d.ts.map → turn-operations-CAmNETlu.d.ts.map} +1 -1
- package/dist/types.d.ts +1 -1
- package/docs/CHAT.md +8 -0
- package/docs/IPC.md +10 -0
- package/package.json +1 -1
- package/dist/anthropic-DATE-m9f.js.map +0 -1
- package/dist/context-segments-CJCtJ9sU.js.map +0 -1
- package/dist/index-498gAVpL.d.ts.map +0 -1
- package/dist/index-CfEJ5Vf9.d.ts.map +0 -1
- package/dist/oauth-D-LZ4ic-.js.map +0 -1
- package/dist/server-Cccx5jES.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { m as openaiCompat } from "./openai-compat-cIeLSED_.js";
|
|
2
|
-
import { s as resolveOAuthApiKey } from "./oauth-
|
|
2
|
+
import { s as resolveOAuthApiKey } from "./oauth-CmtlmCzi.js";
|
|
3
3
|
import { t as CURSOR_OAUTH_PROVIDER_ID } from "./cursor-iojRXHF9.js";
|
|
4
4
|
//#region src/providers/cursor.ts
|
|
5
5
|
const DEFAULT_MODEL = "claude-4.6-sonnet";
|
|
@@ -134,4 +134,4 @@ function zai(params) {
|
|
|
134
134
|
//#endregion
|
|
135
135
|
export { cursor as a, planMistralReasoning as i, zai as n, mistral as r, planZaiReasoning as t };
|
|
136
136
|
|
|
137
|
-
//# sourceMappingURL=providers-
|
|
137
|
+
//# sourceMappingURL=providers-ZucqgwU7.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers-Bjdvmpfu.js","names":["BASE_URL","getApiKey"],"sources":["../src/providers/cursor.ts","../src/providers/mistral.ts","../src/providers/zai.ts"],"sourcesContent":["import type { Provider, StreamCallbacks } from '.'\nimport { CURSOR_OAUTH_PROVIDER_ID } from '../chat/oauth-page/cursor'\nimport { resolveOAuthApiKey } from './oauth'\nimport { openaiCompat } from './openai-compat'\n\n/**\n * Cursor provider (OAuth).\n *\n * Auth is fully wired: `bun run auth --cursor` (or the TUI wizard) logs in via\n * Cursor's poll-based PKCE flow and persists credentials; this provider resolves\n * + refreshes the OAuth token on every turn via {@link resolveOAuthApiKey}.\n *\n * Inference is **not** wired yet. Cursor does not expose an OpenAI-compatible\n * HTTP endpoint — it speaks a protobuf/Connect agent protocol over HTTP/2 to\n * `api2.cursor.sh`. Implementing `stream()` requires porting that transport\n * (generated protobuf schemas + an HTTP/2 streaming client) in-process, which\n * is intentionally left as a follow-up. Until then `stream()` resolves the\n * token (proving auth works) and then throws a clear, actionable error.\n *\n * The `openaiCompat` base supplies the message-format helpers (`formatTools`,\n * `userMessage`, `toolResultsMessage`, …) so the provider satisfies the full\n * `Provider` contract and slots into the registry; only `stream` is overridden.\n */\nexport interface CursorParams {\n /** Bypass OAuth resolution with an explicit token (mainly for tests). */\n apiKey?: string\n defaultModel?: string\n /**\n * Extra HTTP headers for the eventual Cursor transport. Accepted for API\n * parity with the other providers and forwarded to the openai-compat base,\n * but inert until Cursor inference is implemented (the `stream` override\n * currently throws before any request is made).\n */\n extraHeaders?: Record<string, string>\n}\n\nconst DEFAULT_MODEL = 'claude-4.6-sonnet'\n\nconst NOT_IMPLEMENTED_MESSAGE\n = 'Cursor OAuth login works, but inference over Cursor is not implemented yet. '\n + 'Cursor uses a protobuf/HTTP-2 agent protocol (not an OpenAI-compatible API), '\n + 'so the streaming transport still needs to be ported. Use another provider for now.'\n\nexport function cursor(params?: CursorParams): Provider {\n const defaultModel = params?.defaultModel || DEFAULT_MODEL\n\n // Base only provides the format/serialization methods; `baseURL` is never\n // hit because we override `stream` below.\n const base = openaiCompat({\n name: 'cursor',\n apiKey: params?.apiKey ?? 'oauth',\n baseURL: 'https://api2.cursor.sh',\n defaultModel,\n capabilities: { vision: true, imageInToolResult: false },\n extraHeaders: params?.extraHeaders,\n })\n\n return {\n ...base,\n meta: { ...base.meta, defaultModel },\n async stream(options, callbacks: StreamCallbacks) {\n // Resolve (and lazily refresh) the OAuth token so auth failures surface\n // here with the right remediation, distinct from the not-implemented path.\n await resolveOAuthApiKey(\n {\n provider: 'cursor',\n providerId: CURSOR_OAUTH_PROVIDER_ID,\n params,\n missingError: 'No Cursor credentials found. Run `bun run auth --cursor` first.',\n refreshError: reason => `Cursor OAuth token refresh failed. Run \\`bun run auth --cursor\\` again. ${reason}`,\n },\n callbacks,\n )\n void options\n throw new Error(NOT_IMPLEMENTED_MESSAGE)\n },\n }\n}\n","import type { Provider, ProviderCapabilities } from '.'\nimport type { ThinkingLevel } from '../types'\nimport { openaiCompat } from './openai-compat'\n\n// Mistral La Plateforme — OpenAI-compatible `/v1/chat/completions`. Model ids\n// are plain slugs (`mistral-medium-latest`, `devstral-2512`, …). Reasoning is\n// NOT a separate wire field here: with `reasoning_effort: 'high'` the response\n// `content` becomes a list of `thinking` / `text` chunks (handled by\n// `openaiCompat`'s content-chunk path), and with `'none'` it stays a plain\n// string. See https://docs.mistral.ai/studio-api/conversations/reasoning.\nconst BASE_URL = 'https://api.mistral.ai/v1'\n\nexport interface MistralParams {\n apiKey?: string\n defaultModel?: string\n /**\n * Override the base URL — e.g. point at a regional endpoint or a gateway in\n * front of La Plateforme.\n */\n baseURL?: string\n /**\n * Provider capability flags. The `mistral-medium` / `mistral-large` /\n * `pixtral` families accept `image_url` parts — default:\n * `{ vision: true, imageInToolResult: false }`. Set `vision: false` when\n * pinning a text-only model (`codestral`, `devstral`, `ministral`).\n */\n capabilities?: ProviderCapabilities\n /**\n * Extra HTTP headers sent on every request. Forwarded to the underlying\n * {@link openaiCompat} client.\n */\n extraHeaders?: Record<string, string>\n}\n\nfunction getApiKey(params?: MistralParams): string {\n // Resolution order aligned with the other providers: explicit > env > fail.\n if (typeof params?.apiKey === 'string' && params.apiKey.length > 0)\n return params.apiKey\n\n if (process.env.MISTRAL_API_KEY)\n return process.env.MISTRAL_API_KEY\n\n throw new Error('No Mistral API key found. Pass `apiKey` or set MISTRAL_API_KEY in your environment.')\n}\n\n/**\n * Model ids that accept `reasoning_effort`. Mistral rejects unknown request\n * fields on some routes, so the knob is sent only for the families that\n * document it (`mistral-small-*`, `mistral-medium-3.5` / `-2604`, and the\n * deprecated-but-live `magistral-*`); `codestral` / `devstral` / `ministral`\n * requests stay byte-identical to what they were without this planner.\n */\nconst REASONING_MODELS = /^(?:magistral-|mistral-small-|mistral-medium-(?:3\\.5|2604))/\n\n/**\n * Map zidane's thinking level to Mistral's `reasoning_effort`. Only the two\n * documented values are emitted — `'none'` (thinking chunk omitted, `content`\n * stays a plain string) and `'high'` (full thinking chunk). `adaptive` sends\n * nothing so the model's own default applies.\n *\n * Exported for tests.\n */\nexport function planMistralReasoning(\n ctx: { model: string, thinking?: ThinkingLevel },\n): Record<string, unknown> | undefined {\n if (!REASONING_MODELS.test(ctx.model))\n return undefined\n if (ctx.thinking === undefined || ctx.thinking === 'adaptive')\n return undefined\n return { reasoning_effort: ctx.thinking === 'off' ? 'none' : 'high' }\n}\n\n/**\n * Mistral provider (La Plateforme).\n *\n * Thin wrapper around {@link openaiCompat} with Mistral-specific defaults\n * (base URL, default model, `reasoning_effort` planner). `supportsReasoning`\n * stays off: Mistral carries thinking inside `content` chunks rather than a\n * `reasoning_content` field, so there is nothing to echo back upstream —\n * thinking streams to the UI and is dropped from subsequent requests.\n */\nexport function mistral(params?: MistralParams): Provider {\n return openaiCompat({\n name: 'mistral',\n apiKey: getApiKey(params),\n baseURL: params?.baseURL || BASE_URL,\n defaultModel: params?.defaultModel || 'mistral-medium-latest',\n capabilities: params?.capabilities ?? { vision: true, imageInToolResult: false },\n planReasoningRequest: planMistralReasoning,\n extraHeaders: params?.extraHeaders,\n })\n}\n","import type { Provider, ProviderCapabilities } from '.'\nimport type { ThinkingLevel } from '../types'\nimport { openaiCompat } from './openai-compat'\n\n// Z.ai (Zhipu) GLM Open Platform — OpenAI-compatible endpoint. Model ids are\n// plain lowercase slugs (`glm-4.7`, `glm-4.7-flash`, …), reasoning streams in\n// the `reasoning_content` delta field, and thinking is toggled via an\n// `extra_body.thinking` object rather than a `reasoning_effort` string.\n// See https://docs.z.ai/guides/develop/http/introduction and\n// https://docs.z.ai/guides/capabilities/thinking-mode.\nconst BASE_URL = 'https://api.z.ai/api/paas/v4'\n\nexport interface ZaiParams {\n apiKey?: string\n defaultModel?: string\n /**\n * Override the base URL — e.g. point at the dedicated Coding Plan endpoint\n * instead of the standard API endpoint.\n */\n baseURL?: string\n /**\n * Provider capability flags. GLM text models are text-only — default:\n * `{ vision: false, imageInToolResult: false }`.\n */\n capabilities?: ProviderCapabilities\n /**\n * Extra HTTP headers sent on every request. Forwarded to the underlying\n * {@link openaiCompat} client.\n */\n extraHeaders?: Record<string, string>\n}\n\nfunction getApiKey(params?: ZaiParams): string {\n // Resolution order aligned with the other providers: explicit > env > fail.\n if (typeof params?.apiKey === 'string' && params.apiKey.length > 0)\n return params.apiKey\n\n if (process.env.ZAI_API_KEY)\n return process.env.ZAI_API_KEY\n\n throw new Error('No Z.ai API key found. Pass `apiKey` or set ZAI_API_KEY in your environment.')\n}\n\n/**\n * Map zidane's thinking level to Z.ai's `extra_body.thinking` request shape.\n * GLM has no depth knob — thinking is a binary switch — so any non-`off`\n * level enables it and `off` explicitly disables it (GLM-5.x/4.7 think by\n * default, so a silent omission would not turn thinking off).\n *\n * Exported for tests.\n */\nexport function planZaiReasoning(\n ctx: { thinking?: ThinkingLevel },\n): Record<string, unknown> {\n const enabled = !!ctx.thinking && ctx.thinking !== 'off'\n return { thinking: { type: enabled ? 'enabled' : 'disabled' } }\n}\n\n/**\n * Z.ai (Zhipu) GLM provider.\n *\n * Thin wrapper around {@link openaiCompat} pinned to the `reasoning_content`\n * round-trip mode: thinking arrives in the `reasoning_content` delta field and\n * is echoed back on assistant messages under the same name, keeping GLM's\n * interleaved/preserved thinking coherent across tool calls.\n */\nexport function zai(params?: ZaiParams): Provider {\n return openaiCompat({\n name: 'zai',\n apiKey: getApiKey(params),\n baseURL: params?.baseURL || BASE_URL,\n defaultModel: params?.defaultModel || 'glm-5.3-flash',\n capabilities: params?.capabilities ?? { vision: false, imageInToolResult: false },\n supportsReasoning: true,\n reasoningMode: 'reasoning_content',\n reasoningContentField: 'reasoning_content',\n planReasoningRequest: planZaiReasoning,\n extraHeaders: params?.extraHeaders,\n })\n}\n"],"mappings":";;;;AAoCA,MAAM,gBAAgB;AAEtB,MAAM,0BACF;AAIJ,SAAgB,OAAO,QAAiC;CACtD,MAAM,eAAe,QAAQ,gBAAgB;CAI7C,MAAM,OAAO,aAAa;EACxB,MAAM;EACN,QAAQ,QAAQ,UAAU;EAC1B,SAAS;EACT;EACA,cAAc;GAAE,QAAQ;GAAM,mBAAmB;EAAM;EACvD,cAAc,QAAQ;CACxB,CAAC;CAED,OAAO;EACL,GAAG;EACH,MAAM;GAAE,GAAG,KAAK;GAAM;EAAa;EACnC,MAAM,OAAO,SAAS,WAA4B;GAGhD,MAAM,mBACJ;IACE,UAAU;IACV,YAAY;IACZ;IACA,cAAc;IACd,eAAc,WAAU,2EAA2E;GACrG,GACA,SACF;GAEA,MAAM,IAAI,MAAM,uBAAuB;EACzC;CACF;AACF;;;ACnEA,MAAMA,aAAW;AAwBjB,SAASC,YAAU,QAAgC;CAEjD,IAAI,OAAO,QAAQ,WAAW,YAAY,OAAO,OAAO,SAAS,GAC/D,OAAO,OAAO;CAEhB,IAAI,QAAQ,IAAI,iBACd,OAAO,QAAQ,IAAI;CAErB,MAAM,IAAI,MAAM,qFAAqF;AACvG;;;;;;;;AASA,MAAM,mBAAmB;;;;;;;;;AAUzB,SAAgB,qBACd,KACqC;CACrC,IAAI,CAAC,iBAAiB,KAAK,IAAI,KAAK,GAClC,OAAO,KAAA;CACT,IAAI,IAAI,aAAa,KAAA,KAAa,IAAI,aAAa,YACjD,OAAO,KAAA;CACT,OAAO,EAAE,kBAAkB,IAAI,aAAa,QAAQ,SAAS,OAAO;AACtE;;;;;;;;;;AAWA,SAAgB,QAAQ,QAAkC;CACxD,OAAO,aAAa;EAClB,MAAM;EACN,QAAQA,YAAU,MAAM;EACxB,SAAS,QAAQ,WAAWD;EAC5B,cAAc,QAAQ,gBAAgB;EACtC,cAAc,QAAQ,gBAAgB;GAAE,QAAQ;GAAM,mBAAmB;EAAM;EAC/E,sBAAsB;EACtB,cAAc,QAAQ;CACxB,CAAC;AACH;;;ACjFA,MAAM,WAAW;AAsBjB,SAAS,UAAU,QAA4B;CAE7C,IAAI,OAAO,QAAQ,WAAW,YAAY,OAAO,OAAO,SAAS,GAC/D,OAAO,OAAO;CAEhB,IAAI,QAAQ,IAAI,aACd,OAAO,QAAQ,IAAI;CAErB,MAAM,IAAI,MAAM,8EAA8E;AAChG;;;;;;;;;AAUA,SAAgB,iBACd,KACyB;CAEzB,OAAO,EAAE,UAAU,EAAE,MADL,CAAC,CAAC,IAAI,YAAY,IAAI,aAAa,QACd,YAAY,WAAW,EAAE;AAChE;;;;;;;;;AAUA,SAAgB,IAAI,QAA8B;CAChD,OAAO,aAAa;EAClB,MAAM;EACN,QAAQ,UAAU,MAAM;EACxB,SAAS,QAAQ,WAAW;EAC5B,cAAc,QAAQ,gBAAgB;EACtC,cAAc,QAAQ,gBAAgB;GAAE,QAAQ;GAAO,mBAAmB;EAAM;EAChF,mBAAmB;EACnB,eAAe;EACf,uBAAuB;EACvB,sBAAsB;EACtB,cAAc,QAAQ;CACxB,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"providers-ZucqgwU7.js","names":["BASE_URL","getApiKey"],"sources":["../src/providers/cursor.ts","../src/providers/mistral.ts","../src/providers/zai.ts"],"sourcesContent":["import type { Provider, StreamCallbacks } from '.'\nimport { CURSOR_OAUTH_PROVIDER_ID } from '../chat/oauth-page/cursor'\nimport { resolveOAuthApiKey } from './oauth'\nimport { openaiCompat } from './openai-compat'\n\n/**\n * Cursor provider (OAuth).\n *\n * Auth is fully wired: `bun run auth --cursor` (or the TUI wizard) logs in via\n * Cursor's poll-based PKCE flow and persists credentials; this provider resolves\n * + refreshes the OAuth token on every turn via {@link resolveOAuthApiKey}.\n *\n * Inference is **not** wired yet. Cursor does not expose an OpenAI-compatible\n * HTTP endpoint — it speaks a protobuf/Connect agent protocol over HTTP/2 to\n * `api2.cursor.sh`. Implementing `stream()` requires porting that transport\n * (generated protobuf schemas + an HTTP/2 streaming client) in-process, which\n * is intentionally left as a follow-up. Until then `stream()` resolves the\n * token (proving auth works) and then throws a clear, actionable error.\n *\n * The `openaiCompat` base supplies the message-format helpers (`formatTools`,\n * `userMessage`, `toolResultsMessage`, …) so the provider satisfies the full\n * `Provider` contract and slots into the registry; only `stream` is overridden.\n */\nexport interface CursorParams {\n /** Bypass OAuth resolution with an explicit token (mainly for tests). */\n apiKey?: string\n defaultModel?: string\n /**\n * Extra HTTP headers for the eventual Cursor transport. Accepted for API\n * parity with the other providers and forwarded to the openai-compat base,\n * but inert until Cursor inference is implemented (the `stream` override\n * currently throws before any request is made).\n */\n extraHeaders?: Record<string, string>\n}\n\nconst DEFAULT_MODEL = 'claude-4.6-sonnet'\n\nconst NOT_IMPLEMENTED_MESSAGE\n = 'Cursor OAuth login works, but inference over Cursor is not implemented yet. '\n + 'Cursor uses a protobuf/HTTP-2 agent protocol (not an OpenAI-compatible API), '\n + 'so the streaming transport still needs to be ported. Use another provider for now.'\n\nexport function cursor(params?: CursorParams): Provider {\n const defaultModel = params?.defaultModel || DEFAULT_MODEL\n\n // Base only provides the format/serialization methods; `baseURL` is never\n // hit because we override `stream` below.\n const base = openaiCompat({\n name: 'cursor',\n apiKey: params?.apiKey ?? 'oauth',\n baseURL: 'https://api2.cursor.sh',\n defaultModel,\n capabilities: { vision: true, imageInToolResult: false },\n extraHeaders: params?.extraHeaders,\n })\n\n return {\n ...base,\n meta: { ...base.meta, defaultModel },\n async stream(options, callbacks: StreamCallbacks) {\n // Resolve (and lazily refresh) the OAuth token so auth failures surface\n // here with the right remediation, distinct from the not-implemented path.\n await resolveOAuthApiKey(\n {\n provider: 'cursor',\n providerId: CURSOR_OAUTH_PROVIDER_ID,\n params,\n missingError: 'No Cursor credentials found. Run `bun run auth --cursor` first.',\n refreshError: reason => `Cursor OAuth token refresh failed. Run \\`bun run auth --cursor\\` again. ${reason}`,\n },\n callbacks,\n )\n void options\n throw new Error(NOT_IMPLEMENTED_MESSAGE)\n },\n }\n}\n","import type { Provider, ProviderCapabilities } from '.'\nimport type { ThinkingLevel } from '../types'\nimport { openaiCompat } from './openai-compat'\n\n// Mistral La Plateforme — OpenAI-compatible `/v1/chat/completions`. Model ids\n// are plain slugs (`mistral-medium-latest`, `devstral-2512`, …). Reasoning is\n// NOT a separate wire field here: with `reasoning_effort: 'high'` the response\n// `content` becomes a list of `thinking` / `text` chunks (handled by\n// `openaiCompat`'s content-chunk path), and with `'none'` it stays a plain\n// string. See https://docs.mistral.ai/studio-api/conversations/reasoning.\nconst BASE_URL = 'https://api.mistral.ai/v1'\n\nexport interface MistralParams {\n apiKey?: string\n defaultModel?: string\n /**\n * Override the base URL — e.g. point at a regional endpoint or a gateway in\n * front of La Plateforme.\n */\n baseURL?: string\n /**\n * Provider capability flags. The `mistral-medium` / `mistral-large` /\n * `pixtral` families accept `image_url` parts — default:\n * `{ vision: true, imageInToolResult: false }`. Set `vision: false` when\n * pinning a text-only model (`codestral`, `devstral`, `ministral`).\n */\n capabilities?: ProviderCapabilities\n /**\n * Extra HTTP headers sent on every request. Forwarded to the underlying\n * {@link openaiCompat} client.\n */\n extraHeaders?: Record<string, string>\n}\n\nfunction getApiKey(params?: MistralParams): string {\n // Resolution order aligned with the other providers: explicit > env > fail.\n if (typeof params?.apiKey === 'string' && params.apiKey.length > 0)\n return params.apiKey\n\n if (process.env.MISTRAL_API_KEY)\n return process.env.MISTRAL_API_KEY\n\n throw new Error('No Mistral API key found. Pass `apiKey` or set MISTRAL_API_KEY in your environment.')\n}\n\n/**\n * Model ids that accept `reasoning_effort`. Mistral rejects unknown request\n * fields on some routes, so the knob is sent only for the families that\n * document it (`mistral-small-*`, `mistral-medium-3.5` / `-2604`, and the\n * deprecated-but-live `magistral-*`); `codestral` / `devstral` / `ministral`\n * requests stay byte-identical to what they were without this planner.\n */\nconst REASONING_MODELS = /^(?:magistral-|mistral-small-|mistral-medium-(?:3\\.5|2604))/\n\n/**\n * Map zidane's thinking level to Mistral's `reasoning_effort`. Only the two\n * documented values are emitted — `'none'` (thinking chunk omitted, `content`\n * stays a plain string) and `'high'` (full thinking chunk). `adaptive` sends\n * nothing so the model's own default applies.\n *\n * Exported for tests.\n */\nexport function planMistralReasoning(\n ctx: { model: string, thinking?: ThinkingLevel },\n): Record<string, unknown> | undefined {\n if (!REASONING_MODELS.test(ctx.model))\n return undefined\n if (ctx.thinking === undefined || ctx.thinking === 'adaptive')\n return undefined\n return { reasoning_effort: ctx.thinking === 'off' ? 'none' : 'high' }\n}\n\n/**\n * Mistral provider (La Plateforme).\n *\n * Thin wrapper around {@link openaiCompat} with Mistral-specific defaults\n * (base URL, default model, `reasoning_effort` planner). `supportsReasoning`\n * stays off: Mistral carries thinking inside `content` chunks rather than a\n * `reasoning_content` field, so there is nothing to echo back upstream —\n * thinking streams to the UI and is dropped from subsequent requests.\n */\nexport function mistral(params?: MistralParams): Provider {\n return openaiCompat({\n name: 'mistral',\n apiKey: getApiKey(params),\n baseURL: params?.baseURL || BASE_URL,\n defaultModel: params?.defaultModel || 'mistral-medium-latest',\n capabilities: params?.capabilities ?? { vision: true, imageInToolResult: false },\n planReasoningRequest: planMistralReasoning,\n extraHeaders: params?.extraHeaders,\n })\n}\n","import type { Provider, ProviderCapabilities } from '.'\nimport type { ThinkingLevel } from '../types'\nimport { openaiCompat } from './openai-compat'\n\n// Z.ai (Zhipu) GLM Open Platform — OpenAI-compatible endpoint. Model ids are\n// plain lowercase slugs (`glm-4.7`, `glm-4.7-flash`, …), reasoning streams in\n// the `reasoning_content` delta field, and thinking is toggled via an\n// `extra_body.thinking` object rather than a `reasoning_effort` string.\n// See https://docs.z.ai/guides/develop/http/introduction and\n// https://docs.z.ai/guides/capabilities/thinking-mode.\nconst BASE_URL = 'https://api.z.ai/api/paas/v4'\n\nexport interface ZaiParams {\n apiKey?: string\n defaultModel?: string\n /**\n * Override the base URL — e.g. point at the dedicated Coding Plan endpoint\n * instead of the standard API endpoint.\n */\n baseURL?: string\n /**\n * Provider capability flags. GLM text models are text-only — default:\n * `{ vision: false, imageInToolResult: false }`.\n */\n capabilities?: ProviderCapabilities\n /**\n * Extra HTTP headers sent on every request. Forwarded to the underlying\n * {@link openaiCompat} client.\n */\n extraHeaders?: Record<string, string>\n}\n\nfunction getApiKey(params?: ZaiParams): string {\n // Resolution order aligned with the other providers: explicit > env > fail.\n if (typeof params?.apiKey === 'string' && params.apiKey.length > 0)\n return params.apiKey\n\n if (process.env.ZAI_API_KEY)\n return process.env.ZAI_API_KEY\n\n throw new Error('No Z.ai API key found. Pass `apiKey` or set ZAI_API_KEY in your environment.')\n}\n\n/**\n * Map zidane's thinking level to Z.ai's `extra_body.thinking` request shape.\n * GLM has no depth knob — thinking is a binary switch — so any non-`off`\n * level enables it and `off` explicitly disables it (GLM-5.x/4.7 think by\n * default, so a silent omission would not turn thinking off).\n *\n * Exported for tests.\n */\nexport function planZaiReasoning(\n ctx: { thinking?: ThinkingLevel },\n): Record<string, unknown> {\n const enabled = !!ctx.thinking && ctx.thinking !== 'off'\n return { thinking: { type: enabled ? 'enabled' : 'disabled' } }\n}\n\n/**\n * Z.ai (Zhipu) GLM provider.\n *\n * Thin wrapper around {@link openaiCompat} pinned to the `reasoning_content`\n * round-trip mode: thinking arrives in the `reasoning_content` delta field and\n * is echoed back on assistant messages under the same name, keeping GLM's\n * interleaved/preserved thinking coherent across tool calls.\n */\nexport function zai(params?: ZaiParams): Provider {\n return openaiCompat({\n name: 'zai',\n apiKey: getApiKey(params),\n baseURL: params?.baseURL || BASE_URL,\n defaultModel: params?.defaultModel || 'glm-5.3-flash',\n capabilities: params?.capabilities ?? { vision: false, imageInToolResult: false },\n supportsReasoning: true,\n reasoningMode: 'reasoning_content',\n reasoningContentField: 'reasoning_content',\n planReasoningRequest: planZaiReasoning,\n extraHeaders: params?.extraHeaders,\n })\n}\n"],"mappings":";;;;AAoCA,MAAM,gBAAgB;AAEtB,MAAM,0BACF;AAIJ,SAAgB,OAAO,QAAiC;CACtD,MAAM,eAAe,QAAQ,gBAAgB;CAI7C,MAAM,OAAO,aAAa;EACxB,MAAM;EACN,QAAQ,QAAQ,UAAU;EAC1B,SAAS;EACT;EACA,cAAc;GAAE,QAAQ;GAAM,mBAAmB;EAAM;EACvD,cAAc,QAAQ;CACxB,CAAC;CAED,OAAO;EACL,GAAG;EACH,MAAM;GAAE,GAAG,KAAK;GAAM;EAAa;EACnC,MAAM,OAAO,SAAS,WAA4B;GAGhD,MAAM,mBACJ;IACE,UAAU;IACV,YAAY;IACZ;IACA,cAAc;IACd,eAAc,WAAU,2EAA2E;GACrG,GACA,SACF;GAEA,MAAM,IAAI,MAAM,uBAAuB;EACzC;CACF;AACF;;;ACnEA,MAAMA,aAAW;AAwBjB,SAASC,YAAU,QAAgC;CAEjD,IAAI,OAAO,QAAQ,WAAW,YAAY,OAAO,OAAO,SAAS,GAC/D,OAAO,OAAO;CAEhB,IAAI,QAAQ,IAAI,iBACd,OAAO,QAAQ,IAAI;CAErB,MAAM,IAAI,MAAM,qFAAqF;AACvG;;;;;;;;AASA,MAAM,mBAAmB;;;;;;;;;AAUzB,SAAgB,qBACd,KACqC;CACrC,IAAI,CAAC,iBAAiB,KAAK,IAAI,KAAK,GAClC,OAAO,KAAA;CACT,IAAI,IAAI,aAAa,KAAA,KAAa,IAAI,aAAa,YACjD,OAAO,KAAA;CACT,OAAO,EAAE,kBAAkB,IAAI,aAAa,QAAQ,SAAS,OAAO;AACtE;;;;;;;;;;AAWA,SAAgB,QAAQ,QAAkC;CACxD,OAAO,aAAa;EAClB,MAAM;EACN,QAAQA,YAAU,MAAM;EACxB,SAAS,QAAQ,WAAWD;EAC5B,cAAc,QAAQ,gBAAgB;EACtC,cAAc,QAAQ,gBAAgB;GAAE,QAAQ;GAAM,mBAAmB;EAAM;EAC/E,sBAAsB;EACtB,cAAc,QAAQ;CACxB,CAAC;AACH;;;ACjFA,MAAM,WAAW;AAsBjB,SAAS,UAAU,QAA4B;CAE7C,IAAI,OAAO,QAAQ,WAAW,YAAY,OAAO,OAAO,SAAS,GAC/D,OAAO,OAAO;CAEhB,IAAI,QAAQ,IAAI,aACd,OAAO,QAAQ,IAAI;CAErB,MAAM,IAAI,MAAM,8EAA8E;AAChG;;;;;;;;;AAUA,SAAgB,iBACd,KACyB;CAEzB,OAAO,EAAE,UAAU,EAAE,MADL,CAAC,CAAC,IAAI,YAAY,IAAI,aAAa,QACd,YAAY,WAAW,EAAE;AAChE;;;;;;;;;AAUA,SAAgB,IAAI,QAA8B;CAChD,OAAO,aAAa;EAClB,MAAM;EACN,QAAQ,UAAU,MAAM;EACxB,SAAS,QAAQ,WAAW;EAC5B,cAAc,QAAQ,gBAAgB;EACtC,cAAc,QAAQ,gBAAgB;GAAE,QAAQ;GAAO,mBAAmB;EAAM;EAChF,mBAAmB;EACnB,eAAe;EACf,uBAAuB;EACvB,sBAAsB;EACtB,cAAc,QAAQ;CACxB,CAAC;AACH"}
|
package/dist/providers.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $h as resolveOAuthApiKey, Ah as anthropic, Am as xai, Ch as ArceeParams, Cm as ToolResult, Dh as AnthropicParams, Dm as planZaiReasoning, Em as ZaiParams, Fm as sanitizeToolSpecs, Gh as OAuthParams, Hh as PromptCacheKeyOption, Hm as OpenAICompatAuthHeader, Im as OpenRouterParams, Jh as credentialsFromParams, Kh as ResolveOAuthApiKeyOptions, Mm as SchemaSanitizeProfile, Nm as SchemaSanitizeResult, Om as zai, Pm as sanitizeToolSchema, Qh as registerCustomOAuthProvider, Rm as openrouter, Sh as planBasetenReasoning, Sm as ToolCall, Sy as setModelCatalog, Tm as TurnResult, Uh as derivePromptCacheKey, Um as OpenAICompatHttpError, Vh as PromptCacheKeyContext, Wh as resolvePromptCacheKey, Wm as OpenAICompatParams, Xh as isOAuthAccessToken, Yh as extractRuntimeCredentials, Zh as readOAuthCredentials, Zm as classifyOpenAICompatError, _h as cursor, _m as ProviderCapabilities, ag as refreshAnthropicToken, bh as BasetenParams, bm as StreamOptions, by as ModelCatalogSource, dh as MistralParams, eg as writeOAuthCredentials, eh as mapOAIFinishReason, fh as mistral, gh as CursorParams, gm as Provider, hh as local, hm as HistoryRepair, ig as getOAuthProvider, jh as applyAnthropicCacheBreakpoints, jm as SchemaSanitizeOptions, km as XaiParams, lh as openai, mh as LocalParams, ng as ensureBundledOAuthFlows, nh as openaiCompat, og as refreshOpenAICodexToken, oh as OpenAIParams, ph as planMistralReasoning, qh as credentialsFilePath, rg as getOAuthApiKey, sg as registerOAuthProvider, tg as OAuthProviderInterface, vh as CerebrasParams, vm as ProviderMeta, vy as ModelCatalog, wh as arcee, wm as ToolSpec, xh as baseten, xm as TokenCountPayload, xy as getModelCatalog, yh as cerebras, ym as StreamCallbacks, yy as ModelCatalogEntry } from "./index-
|
|
1
|
+
import { $h as resolveOAuthApiKey, Ah as anthropic, Am as xai, Ch as ArceeParams, Cm as ToolResult, Dh as AnthropicParams, Dm as planZaiReasoning, Em as ZaiParams, Fm as sanitizeToolSpecs, Gh as OAuthParams, Hh as PromptCacheKeyOption, Hm as OpenAICompatAuthHeader, Im as OpenRouterParams, Jh as credentialsFromParams, Kh as ResolveOAuthApiKeyOptions, Mm as SchemaSanitizeProfile, Nm as SchemaSanitizeResult, Om as zai, Pm as sanitizeToolSchema, Qh as registerCustomOAuthProvider, Rm as openrouter, Sh as planBasetenReasoning, Sm as ToolCall, Sy as setModelCatalog, Tm as TurnResult, Uh as derivePromptCacheKey, Um as OpenAICompatHttpError, Vh as PromptCacheKeyContext, Wh as resolvePromptCacheKey, Wm as OpenAICompatParams, Xh as isOAuthAccessToken, Yh as extractRuntimeCredentials, Zh as readOAuthCredentials, Zm as classifyOpenAICompatError, _h as cursor, _m as ProviderCapabilities, ag as refreshAnthropicToken, bh as BasetenParams, bm as StreamOptions, by as ModelCatalogSource, dh as MistralParams, eg as writeOAuthCredentials, eh as mapOAIFinishReason, fh as mistral, gh as CursorParams, gm as Provider, hh as local, hm as HistoryRepair, ig as getOAuthProvider, jh as applyAnthropicCacheBreakpoints, jm as SchemaSanitizeOptions, km as XaiParams, lh as openai, mh as LocalParams, ng as ensureBundledOAuthFlows, nh as openaiCompat, og as refreshOpenAICodexToken, oh as OpenAIParams, ph as planMistralReasoning, qh as credentialsFilePath, rg as getOAuthApiKey, sg as registerOAuthProvider, tg as OAuthProviderInterface, vh as CerebrasParams, vm as ProviderMeta, vy as ModelCatalog, wh as arcee, wm as ToolSpec, xh as baseten, xm as TokenCountPayload, xy as getModelCatalog, yh as cerebras, ym as StreamCallbacks, yy as ModelCatalogEntry } from "./index-C4mY0oKE.js";
|
|
2
2
|
export { type AnthropicParams, type ArceeParams, type BasetenParams, type CerebrasParams, type CursorParams, HistoryRepair, type LocalParams, type MistralParams, type ModelCatalog, type ModelCatalogEntry, type ModelCatalogSource, type OAuthParams, type OAuthProviderInterface, type OpenAICompatAuthHeader, OpenAICompatHttpError, type OpenAICompatParams, type OpenAIParams, type OpenRouterParams, type PromptCacheKeyContext, type PromptCacheKeyOption, Provider, ProviderCapabilities, ProviderMeta, type ResolveOAuthApiKeyOptions, type SchemaSanitizeOptions, type SchemaSanitizeProfile, type SchemaSanitizeResult, StreamCallbacks, StreamOptions, TokenCountPayload, ToolCall, ToolResult, ToolSpec, TurnResult, type XaiParams, type ZaiParams, anthropic, applyAnthropicCacheBreakpoints, arcee, baseten, cerebras, classifyOpenAICompatError, credentialsFilePath, credentialsFromParams, cursor, derivePromptCacheKey, ensureBundledOAuthFlows, extractRuntimeCredentials, getModelCatalog, getOAuthApiKey, getOAuthProvider, isOAuthAccessToken, local, mapOAIFinishReason, mistral, openai, openaiCompat, openrouter, planBasetenReasoning, planMistralReasoning, planZaiReasoning, readOAuthCredentials, refreshAnthropicToken, refreshOpenAICodexToken, registerCustomOAuthProvider, registerOAuthProvider, resolveOAuthApiKey, resolvePromptCacheKey, sanitizeToolSchema, sanitizeToolSpecs, setModelCatalog, writeOAuthCredentials, xai, zai };
|
package/dist/providers.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { E as getModelCatalog, S as resolvePromptCacheKey, b as sanitizeToolSpecs, f as mapOAIFinishReason, j as setModelCatalog, l as classifyOpenAICompatError, m as openaiCompat, n as OpenAICompatHttpError, x as derivePromptCacheKey, y as sanitizeToolSchema } from "./openai-compat-cIeLSED_.js";
|
|
2
|
-
import { n as anthropic, r as applyAnthropicCacheBreakpoints } from "./anthropic-
|
|
3
|
-
import { a as readOAuthCredentials,
|
|
2
|
+
import { n as anthropic, r as applyAnthropicCacheBreakpoints } from "./anthropic-BSbDiW0J.js";
|
|
3
|
+
import { a as readOAuthCredentials, d as getOAuthApiKey, f as getOAuthProvider, h as registerOAuthProvider, i as isOAuthAccessToken, l as writeOAuthCredentials, m as refreshOpenAICodexToken, n as credentialsFromParams, o as registerCustomOAuthProvider, p as refreshAnthropicToken, r as extractRuntimeCredentials, s as resolveOAuthApiKey, t as credentialsFilePath, u as ensureBundledOAuthFlows } from "./oauth-CmtlmCzi.js";
|
|
4
4
|
import { arcee } from "./providers/arcee.js";
|
|
5
5
|
import { baseten, planBasetenReasoning } from "./providers/baseten.js";
|
|
6
6
|
import { cerebras } from "./providers/cerebras.js";
|
|
7
|
-
import { a as cursor, i as planMistralReasoning, n as zai, r as mistral, t as planZaiReasoning } from "./providers-
|
|
7
|
+
import { a as cursor, i as planMistralReasoning, n as zai, r as mistral, t as planZaiReasoning } from "./providers-ZucqgwU7.js";
|
|
8
8
|
import { local } from "./providers/local.js";
|
|
9
9
|
import { openai } from "./providers/openai.js";
|
|
10
10
|
import { openrouter } from "./providers/openrouter.js";
|
package/dist/restate.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $i as McpToolWrap, L_ as ToolStateStore, Qi as McpToolMeta, S_ as ToolDef, Yg as SessionTurn, bm as StreamOptions, c_ as ToolResultContent, cg as AgentBehavior, dg as AgentStats, ev as SessionStore, gm as Provider, i_ as ToolBatchExecutor, lg as AgentClock, x_ as ToolContext } from "./index-
|
|
1
|
+
import { $i as McpToolWrap, L_ as ToolStateStore, Qi as McpToolMeta, S_ as ToolDef, Yg as SessionTurn, bm as StreamOptions, c_ as ToolResultContent, cg as AgentBehavior, dg as AgentStats, ev as SessionStore, gm as Provider, i_ as ToolBatchExecutor, lg as AgentClock, x_ as ToolContext } from "./index-C4mY0oKE.js";
|
|
2
2
|
import { g as TaskExitInfo, h as TaskEntry, l as ExecutionHandle, o as DetachedTasksCapability } from "./types-U-rIVUDw.js";
|
|
3
3
|
|
|
4
4
|
//#region src/restate/types.d.ts
|
package/dist/restate.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { L as buildAliasMaps } from "./openai-compat-cIeLSED_.js";
|
|
2
2
|
import { i as coerceToolResultContent, l as toolOutputByteLength, u as toolResultToText } from "./types-CWgENVLY.js";
|
|
3
|
-
import { Ot as reserveChildLabel, a as stagedToolState, ar as hydrateReadStateFromSessionAsync, i as isToolStateOps } from "./agent-
|
|
3
|
+
import { Ot as reserveChildLabel, a as stagedToolState, ar as hydrateReadStateFromSessionAsync, i as isToolStateOps } from "./agent-LC2c1ue-.js";
|
|
4
4
|
import { r as formatTokenUsage } from "./stats-DAKBEKjc.js";
|
|
5
5
|
import { createHash } from "node:crypto";
|
|
6
6
|
//#region src/restate/awakeable.ts
|
|
@@ -1,18 +1,57 @@
|
|
|
1
|
-
import { Fn as createExtensionBus, In as serializedPayloadBytes, at as createExtensionHud, gt as createExtensionHostRuntimeBridge, ot as discoverAndBuildExtensionRegistry } from "./agent-
|
|
1
|
+
import { Fn as createExtensionBus, In as serializedPayloadBytes, at as createExtensionHud, gt as createExtensionHostRuntimeBridge, ot as discoverAndBuildExtensionRegistry } from "./agent-LC2c1ue-.js";
|
|
2
2
|
import { S as resolveInlineSuggestion, b as createPathAutocompleteProvider } from "./src-DzzhE2YO.js";
|
|
3
3
|
import { l as normalizeArtifactInput } from "./artifacts-CV2hUKnL.js";
|
|
4
4
|
import { t as writeFileAtomic } from "./atomic-write-B7zr1ddF.js";
|
|
5
5
|
import { p as resolveStorageDirs } from "./plugins-B531Tz5b.js";
|
|
6
6
|
import { a as successResponse, i as errorResponse, n as JsonRpcRemoteError, r as createJsonRpcConnection } from "./json-rpc-rSWMUh9b.js";
|
|
7
|
-
import { It as isMainSession } from "./turn-operations-
|
|
7
|
+
import { It as isMainSession } from "./turn-operations-BgqpLlOG.js";
|
|
8
8
|
import { c as searchSessionHistoryIndexAsync, n as buildSessionSearchIndexAsync, u as searchSessionIndexAsync } from "./history-search-C4bk1Wz_.js";
|
|
9
|
-
import { Gt as modelChainMetadata, In as resolveConfig, It as createChatHost, Kt as sessionModelFallbacks, Lt as toTodosSnapshot, cn as DEFAULT_SETTINGS, fi as deriveSessionTitle, fn as SETTINGS_TOGGLES, ft as createFileMcpCredentialStore, hn as enforceSettingsInvariants, pi as eventsFromTurns } from "./approvals-
|
|
10
|
-
import { d as BUILTIN_PROVIDERS, n as applyApiKeyEnv, r as credentialsPath } from "./auth-
|
|
9
|
+
import { Gt as modelChainMetadata, In as resolveConfig, It as createChatHost, Kt as sessionModelFallbacks, Lt as toTodosSnapshot, cn as DEFAULT_SETTINGS, fi as deriveSessionTitle, fn as SETTINGS_TOGGLES, ft as createFileMcpCredentialStore, hn as enforceSettingsInvariants, pi as eventsFromTurns } from "./approvals-BnDsgTtD.js";
|
|
10
|
+
import { d as BUILTIN_PROVIDERS, n as applyApiKeyEnv, r as credentialsPath } from "./auth-Nq-tSMb9.js";
|
|
11
11
|
import { basename, dirname, join } from "node:path";
|
|
12
12
|
import { chmodSync, existsSync, mkdirSync, readFileSync, readdirSync, statSync, unlinkSync } from "node:fs";
|
|
13
13
|
import { spawn } from "node:child_process";
|
|
14
14
|
import { fileURLToPath } from "node:url";
|
|
15
15
|
import { connect, createServer } from "node:net";
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/version.ts
|
|
18
|
+
/**
|
|
19
|
+
* The version of the zidane code this process is running — `package.json`
|
|
20
|
+
* inlined at build time (Bun `--compile`, tsdown for `dist/`, and Vite for
|
|
21
|
+
* the GUI main all fold JSON imports into the bundle, so this never reads
|
|
22
|
+
* the filesystem at runtime and cannot report a NEIGHBOUR package's version
|
|
23
|
+
* the way a `require('../package.json')` from a bundled chunk can).
|
|
24
|
+
*
|
|
25
|
+
* Used by the daemon handshake: a client running newer code than the daemon
|
|
26
|
+
* retires it, so an upgrade can never leave windows silently executing on a
|
|
27
|
+
* process started from the previous release.
|
|
28
|
+
*/
|
|
29
|
+
const ZIDANE_VERSION = "7.0.22";
|
|
30
|
+
/**
|
|
31
|
+
* Compare two dotted versions (`7.0.19`, `7.1.0-beta.1`): negative when `a`
|
|
32
|
+
* is older, positive when newer, 0 when equal. Pre-release tags are ignored
|
|
33
|
+
* — same release train, same code as far as the daemon fence is concerned.
|
|
34
|
+
* Unparseable input compares equal (never fences on garbage).
|
|
35
|
+
*/
|
|
36
|
+
function compareVersions(a, b) {
|
|
37
|
+
const pa = parse(a);
|
|
38
|
+
const pb = parse(b);
|
|
39
|
+
if (!pa || !pb) return 0;
|
|
40
|
+
for (let i = 0; i < 3; i++) {
|
|
41
|
+
const d = (pa[i] ?? 0) - (pb[i] ?? 0);
|
|
42
|
+
if (d !== 0) return d;
|
|
43
|
+
}
|
|
44
|
+
return 0;
|
|
45
|
+
}
|
|
46
|
+
function parse(v) {
|
|
47
|
+
const m = /^v?(\d+)\.(\d+)\.(\d+)/.exec(v.trim());
|
|
48
|
+
return m ? [
|
|
49
|
+
Number(m[1]),
|
|
50
|
+
Number(m[2]),
|
|
51
|
+
Number(m[3])
|
|
52
|
+
] : null;
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
16
55
|
//#region src/ipc/daemon/lifecycle.ts
|
|
17
56
|
/**
|
|
18
57
|
* Daemon lifecycle: socket-path resolution, liveness probing, stale-socket
|
|
@@ -222,6 +261,13 @@ const IpcErrorCode = {
|
|
|
222
261
|
};
|
|
223
262
|
//#endregion
|
|
224
263
|
//#region src/ipc/client.ts
|
|
264
|
+
function daemonRelease(hello) {
|
|
265
|
+
for (const value of [hello.codeVersion, hello.appVersion]) {
|
|
266
|
+
if (typeof value !== "string") continue;
|
|
267
|
+
const match = /^(?:zidane-gui\/)?(v?\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?)$/.exec(value.trim());
|
|
268
|
+
if (match) return match[1];
|
|
269
|
+
}
|
|
270
|
+
}
|
|
225
271
|
var IpcVersionMismatchError = class extends Error {
|
|
226
272
|
daemon;
|
|
227
273
|
constructor(message, daemon) {
|
|
@@ -282,14 +328,17 @@ async function connectIpcClient(options) {
|
|
|
282
328
|
protocolVersion: 9,
|
|
283
329
|
appVersion: options.appVersion ?? "dev",
|
|
284
330
|
pid: process.pid,
|
|
285
|
-
buildId: options.drainOnMismatch === false ? "unknown" : IPC_BUILD_ID
|
|
331
|
+
buildId: options.drainOnMismatch === false ? "unknown" : IPC_BUILD_ID,
|
|
332
|
+
codeVersion: ZIDANE_VERSION
|
|
286
333
|
}), new Promise((_, reject) => {
|
|
287
334
|
helloTimer = setTimeout(() => reject(/* @__PURE__ */ new Error(`Daemon handshake timed out after ${HELLO_TIMEOUT_MS}ms on ${options.socketPath}.`)), HELLO_TIMEOUT_MS);
|
|
288
335
|
})]);
|
|
289
336
|
} catch (err) {
|
|
290
337
|
if (err instanceof JsonRpcRemoteError && err.code === IpcErrorCode.VersionMismatch) {
|
|
291
|
-
if (options.drainOnMismatch !== false) await Promise.race([connection.sendRequest("daemon.shutdown", {}).catch(() => void 0), new Promise((resolve) => setTimeout(resolve, 1500))]);
|
|
292
338
|
const daemon = err.data?.daemon;
|
|
339
|
+
const daemonIsOlderRelease = typeof daemon?.codeVersion === "string" && compareVersions(daemon.codeVersion, ZIDANE_VERSION) < 0;
|
|
340
|
+
const release = daemon && daemonRelease(daemon);
|
|
341
|
+
if (!(release !== void 0 && compareVersions(release, ZIDANE_VERSION) > 0) && (options.drainOnMismatch !== false || daemonIsOlderRelease)) await Promise.race([connection.sendRequest("daemon.shutdown", {}).catch(() => void 0), new Promise((resolve) => setTimeout(resolve, 1500))]);
|
|
293
342
|
close();
|
|
294
343
|
throw new IpcVersionMismatchError(err.message, daemon);
|
|
295
344
|
}
|
|
@@ -298,6 +347,11 @@ async function connectIpcClient(options) {
|
|
|
298
347
|
} finally {
|
|
299
348
|
clearTimeout(helloTimer);
|
|
300
349
|
}
|
|
350
|
+
const release = daemonRelease(hello);
|
|
351
|
+
if (release !== void 0 && compareVersions(release, ZIDANE_VERSION) < 0) {
|
|
352
|
+
close();
|
|
353
|
+
throw new IpcVersionMismatchError(`Daemon release ${release} is older than client ${ZIDANE_VERSION}. Restart the daemon when active runs have finished.`, hello);
|
|
354
|
+
}
|
|
301
355
|
return {
|
|
302
356
|
hello,
|
|
303
357
|
notify: (method, params) => {
|
|
@@ -1261,12 +1315,14 @@ async function startIpcDaemon(options) {
|
|
|
1261
1315
|
const clientBuild = Number(params.buildId);
|
|
1262
1316
|
const daemonBuild = Number(IPC_BUILD_ID);
|
|
1263
1317
|
const staleBuild = params.buildId !== void 0 && params.buildId !== "unknown" && IPC_BUILD_ID !== "unknown" && Number.isFinite(clientBuild) && Number.isFinite(daemonBuild) && clientBuild > daemonBuild;
|
|
1264
|
-
|
|
1318
|
+
const staleRelease = typeof params.codeVersion === "string" && compareVersions(params.codeVersion, ZIDANE_VERSION) > 0;
|
|
1319
|
+
if (params.protocolVersion !== 9 || staleBuild || staleRelease) return errorResponse(message.id, IpcErrorCode.VersionMismatch, staleRelease ? `Stale daemon: it runs zidane ${ZIDANE_VERSION} but the client runs ${params.codeVersion}. Draining for respawn.` : staleBuild ? `Build mismatch: the daemon was started from an older build (daemon ${IPC_BUILD_ID}, client ${params.buildId}). Draining for respawn.` : `Protocol version mismatch: daemon speaks v9, client sent v${params.protocolVersion ?? "?"}.`, { daemon: {
|
|
1265
1320
|
protocolVersion: 9,
|
|
1266
1321
|
appVersion,
|
|
1267
1322
|
pid: process.pid,
|
|
1268
1323
|
startedAt,
|
|
1269
|
-
buildId: IPC_BUILD_ID
|
|
1324
|
+
buildId: IPC_BUILD_ID,
|
|
1325
|
+
codeVersion: ZIDANE_VERSION
|
|
1270
1326
|
} });
|
|
1271
1327
|
peer.ready = true;
|
|
1272
1328
|
const result = {
|
|
@@ -1274,7 +1330,8 @@ async function startIpcDaemon(options) {
|
|
|
1274
1330
|
appVersion,
|
|
1275
1331
|
pid: process.pid,
|
|
1276
1332
|
startedAt,
|
|
1277
|
-
buildId: IPC_BUILD_ID
|
|
1333
|
+
buildId: IPC_BUILD_ID,
|
|
1334
|
+
codeVersion: ZIDANE_VERSION
|
|
1278
1335
|
};
|
|
1279
1336
|
return successResponse(message.id, result);
|
|
1280
1337
|
}
|
|
@@ -1387,4 +1444,4 @@ async function startIpcDaemon(options) {
|
|
|
1387
1444
|
//#endregion
|
|
1388
1445
|
export { connectIpcClient as a, IpcErrorCode as c, defaultSocketPath as d, ensureDaemonRunning as f, IpcVersionMismatchError as i, IPC_BUILD_ID as l, selfDaemonSpawnCommand as m, createDaemonEnvironment as n, connectOrSpawnDaemon as o, probeSocket as p, createFileApprovalsStore as r, IPC_PROTOCOL_VERSION as s, startIpcDaemon as t, daemonSocketName as u };
|
|
1389
1446
|
|
|
1390
|
-
//# sourceMappingURL=server-
|
|
1447
|
+
//# sourceMappingURL=server-HZdjqDpS.js.map
|