zidane 6.5.0 → 6.5.2

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.
Files changed (125) hide show
  1. package/dist/{acp-B-AOovHz.js → acp-565X8nVP.js} +6 -7
  2. package/dist/{acp-B-AOovHz.js.map → acp-565X8nVP.js.map} +1 -1
  3. package/dist/acp-cli.js +6 -6
  4. package/dist/acp.d.ts +1 -1
  5. package/dist/acp.d.ts.map +1 -1
  6. package/dist/acp.js +1 -1
  7. package/dist/{agent-SQ6rxfpT.js → agent-CvO7UOxv.js} +1427 -610
  8. package/dist/agent-CvO7UOxv.js.map +1 -0
  9. package/dist/agent.d.ts +1 -1
  10. package/dist/agent.js +1 -2
  11. package/dist/{anthropic-D3lkw5mv.js → anthropic-Dov2mC5e.js} +3 -3
  12. package/dist/{anthropic-D3lkw5mv.js.map → anthropic-Dov2mC5e.js.map} +1 -1
  13. package/dist/{auth-BzYbbdN_.js → auth-B8ZuBcKC.js} +5 -5
  14. package/dist/{auth-BzYbbdN_.js.map → auth-B8ZuBcKC.js.map} +1 -1
  15. package/dist/chat/pure.d.ts +4 -4
  16. package/dist/chat/pure.js +3 -3
  17. package/dist/chat.d.ts +114 -5
  18. package/dist/chat.d.ts.map +1 -1
  19. package/dist/chat.js +6 -6
  20. package/dist/context-segments-1mcqSCM3.js +494 -0
  21. package/dist/context-segments-1mcqSCM3.js.map +1 -0
  22. package/dist/{context-transport-CDBatvQc.js → context-transport-ClvadrlH.js} +3 -3
  23. package/dist/{context-transport-CDBatvQc.js.map → context-transport-ClvadrlH.js.map} +1 -1
  24. package/dist/contexts/daytona.d.ts +1 -1
  25. package/dist/contexts/e2b.d.ts +1 -1
  26. package/dist/eval.d.ts +1 -1
  27. package/dist/eval.js +1 -1
  28. package/dist/extensions.d.ts +1 -1
  29. package/dist/extensions.js +1 -1
  30. package/dist/headless.d.ts +1 -1
  31. package/dist/headless.js +3 -3
  32. package/dist/{index-CWBSrqI6.d.ts → index-DfERTrql.d.ts} +178 -6
  33. package/dist/index-DfERTrql.d.ts.map +1 -0
  34. package/dist/index.d.ts +2 -2
  35. package/dist/index.js +9 -10
  36. package/dist/index.js.map +1 -1
  37. package/dist/{login-XZDS4K2o.js → login-Cl6ML2XN.js} +2 -2
  38. package/dist/{login-XZDS4K2o.js.map → login-Cl6ML2XN.js.map} +1 -1
  39. package/dist/{mcp-D27rP47I.js → mcp-DdntU47g.js} +3 -3
  40. package/dist/{mcp-D27rP47I.js.map → mcp-DdntU47g.js.map} +1 -1
  41. package/dist/mcp.d.ts +1 -1
  42. package/dist/mcp.js +1 -1
  43. package/dist/{messages-C01kKGj0.js → messages-C_H9soi5.js} +2 -3
  44. package/dist/{messages-C01kKGj0.js.map → messages-C_H9soi5.js.map} +1 -1
  45. package/dist/{openai-compat-B3c_hzwf.js → openai-compat-CnHeo4Lz.js} +216 -3
  46. package/dist/openai-compat-CnHeo4Lz.js.map +1 -0
  47. package/dist/output/stream-json.d.ts +1 -1
  48. package/dist/output/terminal.d.ts +1 -1
  49. package/dist/plugins.d.ts +1 -1
  50. package/dist/presets.d.ts +1 -1
  51. package/dist/presets.js +1 -1
  52. package/dist/providers/anthropic.d.ts +1 -1
  53. package/dist/providers/anthropic.js +1 -1
  54. package/dist/providers/arcee.d.ts +1 -1
  55. package/dist/providers/arcee.js +1 -1
  56. package/dist/providers/baseten.d.ts +1 -1
  57. package/dist/providers/baseten.js +1 -1
  58. package/dist/providers/cerebras.d.ts +1 -1
  59. package/dist/providers/cerebras.js +1 -1
  60. package/dist/providers/local.d.ts +1 -1
  61. package/dist/providers/local.js +1 -1
  62. package/dist/providers/openai-compat.d.ts +1 -1
  63. package/dist/providers/openai-compat.js +1 -1
  64. package/dist/providers/openai.d.ts +1 -1
  65. package/dist/providers/openai.js +2 -2
  66. package/dist/providers/openrouter.d.ts +1 -1
  67. package/dist/providers/openrouter.js +1 -1
  68. package/dist/providers/xai.d.ts +1 -1
  69. package/dist/providers/xai.js +1 -1
  70. package/dist/{providers-z1vU0b2Q.js → providers-B6mFe7OD.js} +3 -3
  71. package/dist/{providers-z1vU0b2Q.js.map → providers-B6mFe7OD.js.map} +1 -1
  72. package/dist/providers.d.ts +2 -2
  73. package/dist/providers.js +4 -4
  74. package/dist/restate.d.ts +178 -2
  75. package/dist/restate.d.ts.map +1 -1
  76. package/dist/restate.js +458 -4
  77. package/dist/restate.js.map +1 -1
  78. package/dist/session/sqlite.d.ts +1 -1
  79. package/dist/{session-cr9VdoEO.js → session-VpLrNaFQ.js} +2 -2
  80. package/dist/{session-cr9VdoEO.js.map → session-VpLrNaFQ.js.map} +1 -1
  81. package/dist/session.d.ts +1 -1
  82. package/dist/session.js +2 -2
  83. package/dist/skills.d.ts +1 -1
  84. package/dist/{stdio-O-m9WVkE.js → stdio-BQeCMmuK.js} +2 -2
  85. package/dist/{stdio-O-m9WVkE.js.map → stdio-BQeCMmuK.js.map} +1 -1
  86. package/dist/{stdio-loader-BSGQmG4L.js → stdio-loader-BN1l1ZAG.js} +2 -2
  87. package/dist/{stdio-loader-BSGQmG4L.js.map → stdio-loader-BN1l1ZAG.js.map} +1 -1
  88. package/dist/{tool-formatters-gFqQbzPY.d.ts → tool-formatters-B2gBbKaS.d.ts} +2 -2
  89. package/dist/{tool-formatters-gFqQbzPY.d.ts.map → tool-formatters-B2gBbKaS.d.ts.map} +1 -1
  90. package/dist/tools/fetch-url.d.ts +1 -1
  91. package/dist/tools/web-search.d.ts +1 -1
  92. package/dist/tools.d.ts +1 -1
  93. package/dist/tools.js +1 -2
  94. package/dist/{transcript-anchors-qCs3wZpu.d.ts → transcript-anchors-CeIxhKP7.d.ts} +2 -2
  95. package/dist/{transcript-anchors-qCs3wZpu.d.ts.map → transcript-anchors-CeIxhKP7.d.ts.map} +1 -1
  96. package/dist/{transcript-anchors-D4IxJifV.js → transcript-anchors-CmFKUw8M.js} +139 -19
  97. package/dist/transcript-anchors-CmFKUw8M.js.map +1 -0
  98. package/dist/tui.d.ts +74 -3
  99. package/dist/tui.d.ts.map +1 -1
  100. package/dist/tui.js +819 -83
  101. package/dist/tui.js.map +1 -1
  102. package/dist/{turn-operations-M9-jUyDd.d.ts → turn-operations-Dyv3Z-Ff.d.ts} +3 -3
  103. package/dist/{turn-operations-M9-jUyDd.d.ts.map → turn-operations-Dyv3Z-Ff.d.ts.map} +1 -1
  104. package/dist/{turn-operations-CAvi8NYt.js → turn-operations-iGu5J08j.js} +2 -2
  105. package/dist/{turn-operations-CAvi8NYt.js.map → turn-operations-iGu5J08j.js.map} +1 -1
  106. package/dist/types.d.ts +1 -1
  107. package/dist/{xai-BPwMQSuF.js → xai-Du6Wfnlb.js} +2 -2
  108. package/dist/{xai-BPwMQSuF.js.map → xai-Du6Wfnlb.js.map} +1 -1
  109. package/docs/CHAT.md +42 -1
  110. package/docs/INTERACTIONS.md +39 -0
  111. package/docs/RESTATE.md +102 -3
  112. package/docs/TUI.md +28 -2
  113. package/package.json +1 -1
  114. package/dist/agent-SQ6rxfpT.js.map +0 -1
  115. package/dist/aliasing-lVFbm81n.js +0 -217
  116. package/dist/aliasing-lVFbm81n.js.map +0 -1
  117. package/dist/context-breakdown-Dzo25N45.js +0 -155
  118. package/dist/context-breakdown-Dzo25N45.js.map +0 -1
  119. package/dist/edit-utils-EGosADZq.js +0 -234
  120. package/dist/edit-utils-EGosADZq.js.map +0 -1
  121. package/dist/index-CWBSrqI6.d.ts.map +0 -1
  122. package/dist/openai-compat-B3c_hzwf.js.map +0 -1
  123. package/dist/tool-state-DTs-3ZHH.js +0 -653
  124. package/dist/tool-state-DTs-3ZHH.js.map +0 -1
  125. package/dist/transcript-anchors-D4IxJifV.js.map +0 -1
@@ -1,8 +1,8 @@
1
+ import { A as mergeCatalogEntry, F as unsupportedMediaError, T as aliasCatalogProviders, _ as userMessage, b as sanitizeToolSpecs, g as toolResultsMessage, k as lookupModel$1, s as assistantMessage, v as createToolNameBoundary, w as fillEstimatedCost } from "../openai-compat-CnHeo4Lz.js";
1
2
  import { i as documentBlockMarker, n as assertResolvedMediaBlock } from "../types-BIarq1qE.js";
2
3
  import { f as isRetryableHttpStatus, l as classifyErrorPrelude, m as matchesToolPairingError, p as matchesContextExceeded } from "../errors-BwBxu3zD.js";
3
- import { A as mergeCatalogEntry, F as unsupportedMediaError, T as aliasCatalogProviders, _ as userMessage, b as sanitizeToolSpecs, g as toolResultsMessage, k as lookupModel$1, s as assistantMessage, v as createToolNameBoundary, w as fillEstimatedCost } from "../openai-compat-B3c_hzwf.js";
4
4
  import { renderSystemForWire } from "../prompt.js";
5
- import { f as reasoningWireAction, n as SYNTHETIC_TOOL_RESULT_PLACEHOLDER } from "../messages-C01kKGj0.js";
5
+ import { f as reasoningWireAction, n as SYNTHETIC_TOOL_RESULT_PLACEHOLDER } from "../messages-C_H9soi5.js";
6
6
  import { r as extractRuntimeCredentials, s as resolveOAuthApiKey } from "../oauth-bkEOybqm.js";
7
7
  import { stream } from "@earendil-works/pi-ai/api/openai-codex-responses";
8
8
  import { stream as stream$1 } from "@earendil-works/pi-ai/api/openai-responses";
@@ -1,2 +1,2 @@
1
- import { $f as openrouter, Qf as normalizeOpenRouterModelId, Zf as OpenRouterParams } from "../index-CWBSrqI6.js";
1
+ import { ap as openrouter, ip as normalizeOpenRouterModelId, rp as OpenRouterParams } from "../index-DfERTrql.js";
2
2
  export { OpenRouterParams, normalizeOpenRouterModelId, openrouter };
@@ -1,4 +1,4 @@
1
- import { m as openaiCompat } from "../openai-compat-B3c_hzwf.js";
1
+ import { m as openaiCompat } from "../openai-compat-CnHeo4Lz.js";
2
2
  //#region src/providers/openrouter.ts
3
3
  const BASE_URL = "https://openrouter.ai/api/v1";
4
4
  const DEFAULT_MODEL = "anthropic/claude-sonnet-4.6";
@@ -1,2 +1,2 @@
1
- import { Gf as xai, Wf as XaiParams } from "../index-CWBSrqI6.js";
1
+ import { Xf as XaiParams, Zf as xai } from "../index-DfERTrql.js";
2
2
  export { XaiParams, xai };
@@ -1,2 +1,2 @@
1
- import { t as xai } from "../xai-BPwMQSuF.js";
1
+ import { t as xai } from "../xai-Du6Wfnlb.js";
2
2
  export { xai };
@@ -1,6 +1,6 @@
1
- import { m as openaiCompat } from "./openai-compat-B3c_hzwf.js";
1
+ import { m as openaiCompat } from "./openai-compat-CnHeo4Lz.js";
2
2
  import { s as resolveOAuthApiKey } from "./oauth-bkEOybqm.js";
3
- import { r as generatePkce } from "./xai-BPwMQSuF.js";
3
+ import { r as generatePkce } from "./xai-Du6Wfnlb.js";
4
4
  //#region src/chat/oauth-page/cursor.ts
5
5
  /** pi-ai / zidane OAuth provider id. Also the credentials-file key. */
6
6
  const CURSOR_OAUTH_PROVIDER_ID = "cursor";
@@ -261,4 +261,4 @@ function zai(params) {
261
261
  //#endregion
262
262
  export { cursor as a, planMistralReasoning as i, zai as n, createCursorOAuthProvider as o, mistral as r, planZaiReasoning as t };
263
263
 
264
- //# sourceMappingURL=providers-z1vU0b2Q.js.map
264
+ //# sourceMappingURL=providers-B6mFe7OD.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"providers-z1vU0b2Q.js","names":["BASE_URL","getApiKey"],"sources":["../src/chat/oauth-page/cursor.ts","../src/providers/cursor.ts","../src/providers/mistral.ts","../src/providers/zai.ts"],"sourcesContent":["/**\n * Cursor OAuth flow.\n *\n * Unlike Anthropic / OpenAI Codex (loopback-redirect PKCE), Cursor uses a\n * **poll-based** PKCE flow with no local callback server:\n *\n * 1. Generate a PKCE verifier + challenge and a random UUID.\n * 2. Open the browser to `cursor.com/loginDeepControl?challenge&uuid&mode&redirectTarget`.\n * 3. Poll `api2.cursor.sh/auth/poll?uuid&verifier` until tokens come back\n * (HTTP 404 = \"not ready yet\", keep polling with backoff).\n * 4. Refresh via `POST api2.cursor.sh/auth/exchange_user_api_key` with\n * `Authorization: Bearer <refresh>`.\n *\n * Token expiry is derived from the access token's JWT `exp` claim (minus a\n * 5-minute safety margin), falling back to +1h when the claim is missing.\n *\n * Flow adapted from https://github.com/ndraiman/pi-cursor-provider, itself\n * derived from https://github.com/ephraimduncan/opencode-cursor.\n *\n * Cursor's auth + inference protocol is unofficial and undocumented — re-verify\n * the endpoints/params below if login starts failing.\n */\n\nimport type {\n OAuthCredentials,\n OAuthLoginCallbacks,\n} from '@earendil-works/pi-ai/oauth'\nimport type { OAuthProviderInterface } from '../../providers/oauth-registry'\nimport { generatePkce } from './pkce'\n\n/** pi-ai / zidane OAuth provider id. Also the credentials-file key. */\nexport const CURSOR_OAUTH_PROVIDER_ID = 'cursor'\n\nconst CURSOR_LOGIN_URL = 'https://cursor.com/loginDeepControl'\nconst CURSOR_POLL_URL = 'https://api2.cursor.sh/auth/poll'\nconst CURSOR_REFRESH_URL = 'https://api2.cursor.sh/auth/exchange_user_api_key'\n\nconst POLL_MAX_ATTEMPTS = 150\nconst POLL_BASE_DELAY_MS = 1000\nconst POLL_MAX_DELAY_MS = 10_000\nconst POLL_BACKOFF_MULTIPLIER = 1.2\nconst POLL_MAX_CONSECUTIVE_ERRORS = 3\n\n/** Fallback lifetime when the JWT carries no `exp`. */\nconst DEFAULT_TOKEN_TTL_MS = 3600 * 1000\n/** Refresh slightly early so requests don't race expiry. */\nconst TOKEN_EXPIRY_SKEW_MS = 5 * 60 * 1000\n\ninterface CursorTokenResponse {\n accessToken: string\n refreshToken: string\n}\n\n/**\n * Derive expiry (epoch ms) from a JWT's `exp` claim, minus a safety skew.\n * Returns `now + 1h` for malformed tokens so a missing claim never wedges\n * refresh into an immediate-expire loop.\n */\nexport function cursorTokenExpiry(token: string): number {\n try {\n const parts = token.split('.')\n const payload = parts[1]\n if (parts.length !== 3 || !payload)\n return Date.now() + DEFAULT_TOKEN_TTL_MS\n\n const json = JSON.parse(atob(payload.replace(/-/g, '+').replace(/_/g, '/'))) as { exp?: unknown }\n if (typeof json.exp === 'number')\n return json.exp * 1000 - TOKEN_EXPIRY_SKEW_MS\n }\n catch {\n // fall through to default\n }\n return Date.now() + DEFAULT_TOKEN_TTL_MS\n}\n\nfunction delay(ms: number): Promise<void> {\n return new Promise(r => setTimeout(r, ms))\n}\n\n/**\n * Poll Cursor's auth endpoint until login completes. `404` means the user\n * hasn't finished the browser flow yet; anything else non-2xx is a hard error.\n */\nasync function pollForTokens(\n uuid: string,\n verifier: string,\n callbacks: OAuthLoginCallbacks,\n): Promise<CursorTokenResponse> {\n let wait = POLL_BASE_DELAY_MS\n let consecutiveErrors = 0\n\n for (let attempt = 0; attempt < POLL_MAX_ATTEMPTS; attempt++) {\n if (callbacks.signal?.aborted)\n throw new Error('Cursor login aborted')\n\n await delay(wait)\n\n try {\n const url = `${CURSOR_POLL_URL}?uuid=${encodeURIComponent(uuid)}&verifier=${encodeURIComponent(verifier)}`\n const response = await fetch(url, { signal: callbacks.signal })\n\n if (response.status === 404) {\n consecutiveErrors = 0\n wait = Math.min(wait * POLL_BACKOFF_MULTIPLIER, POLL_MAX_DELAY_MS)\n continue\n }\n\n if (response.ok) {\n const data = await response.json() as Partial<CursorTokenResponse>\n if (!data.accessToken || !data.refreshToken)\n throw new Error(`Cursor poll response missing tokens: ${JSON.stringify(data)}`)\n return { accessToken: data.accessToken, refreshToken: data.refreshToken }\n }\n\n throw new Error(`Cursor poll failed (${response.status})`)\n }\n catch (err) {\n if (callbacks.signal?.aborted)\n throw new Error('Cursor login aborted')\n consecutiveErrors++\n if (consecutiveErrors >= POLL_MAX_CONSECUTIVE_ERRORS)\n throw err instanceof Error ? err : new Error(String(err))\n callbacks.onProgress?.('Waiting for Cursor login to complete…')\n }\n }\n\n throw new Error('Cursor authentication timed out')\n}\n\nexport async function loginCursor(callbacks: OAuthLoginCallbacks): Promise<OAuthCredentials> {\n const { verifier, challenge } = await generatePkce()\n const uuid = crypto.randomUUID()\n\n const authUrl = new URL(CURSOR_LOGIN_URL)\n authUrl.searchParams.set('challenge', challenge)\n authUrl.searchParams.set('uuid', uuid)\n authUrl.searchParams.set('mode', 'login')\n authUrl.searchParams.set('redirectTarget', 'cli')\n\n callbacks.onAuth({\n url: authUrl.toString(),\n instructions: 'A browser window should open. Complete login in Cursor to finish.',\n })\n\n const tokens = await pollForTokens(uuid, verifier, callbacks)\n\n return {\n access: tokens.accessToken,\n refresh: tokens.refreshToken,\n expires: cursorTokenExpiry(tokens.accessToken),\n }\n}\n\nexport async function refreshCursorToken(credentials: OAuthCredentials): Promise<OAuthCredentials> {\n const response = await fetch(CURSOR_REFRESH_URL, {\n method: 'POST',\n headers: {\n 'Authorization': `Bearer ${credentials.refresh}`,\n 'Content-Type': 'application/json',\n },\n body: '{}',\n })\n\n if (!response.ok) {\n const text = await response.text().catch(() => '')\n throw new Error(`Cursor token refresh failed (${response.status}): ${text || response.statusText}`)\n }\n\n const data = await response.json() as Partial<CursorTokenResponse>\n if (!data.accessToken)\n throw new Error(`Cursor token refresh response missing access token: ${JSON.stringify(data)}`)\n\n return {\n access: data.accessToken,\n // Cursor may omit a rotated refresh token — keep the existing one.\n refresh: data.refreshToken || credentials.refresh,\n expires: cursorTokenExpiry(data.accessToken),\n }\n}\n\n/**\n * Build a Cursor `OAuthProviderInterface`. Shape matches Anthropic / Codex so\n * it drops into `BUILTIN_PROVIDERS` and `src/auth.ts` unchanged.\n *\n * No `renderPage` parameter: Cursor's poll flow has no local callback server,\n * so there is no post-redirect page to theme.\n */\nexport function createCursorOAuthProvider(): OAuthProviderInterface {\n return {\n id: CURSOR_OAUTH_PROVIDER_ID,\n name: 'Cursor',\n usesCallbackServer: false,\n login: loginCursor,\n refreshToken: refreshCursorToken,\n getApiKey: credentials => credentials.access,\n }\n}\n","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-4.7-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?.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AUzB,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-B6mFe7OD.js","names":["BASE_URL","getApiKey"],"sources":["../src/chat/oauth-page/cursor.ts","../src/providers/cursor.ts","../src/providers/mistral.ts","../src/providers/zai.ts"],"sourcesContent":["/**\n * Cursor OAuth flow.\n *\n * Unlike Anthropic / OpenAI Codex (loopback-redirect PKCE), Cursor uses a\n * **poll-based** PKCE flow with no local callback server:\n *\n * 1. Generate a PKCE verifier + challenge and a random UUID.\n * 2. Open the browser to `cursor.com/loginDeepControl?challenge&uuid&mode&redirectTarget`.\n * 3. Poll `api2.cursor.sh/auth/poll?uuid&verifier` until tokens come back\n * (HTTP 404 = \"not ready yet\", keep polling with backoff).\n * 4. Refresh via `POST api2.cursor.sh/auth/exchange_user_api_key` with\n * `Authorization: Bearer <refresh>`.\n *\n * Token expiry is derived from the access token's JWT `exp` claim (minus a\n * 5-minute safety margin), falling back to +1h when the claim is missing.\n *\n * Flow adapted from https://github.com/ndraiman/pi-cursor-provider, itself\n * derived from https://github.com/ephraimduncan/opencode-cursor.\n *\n * Cursor's auth + inference protocol is unofficial and undocumented — re-verify\n * the endpoints/params below if login starts failing.\n */\n\nimport type {\n OAuthCredentials,\n OAuthLoginCallbacks,\n} from '@earendil-works/pi-ai/oauth'\nimport type { OAuthProviderInterface } from '../../providers/oauth-registry'\nimport { generatePkce } from './pkce'\n\n/** pi-ai / zidane OAuth provider id. Also the credentials-file key. */\nexport const CURSOR_OAUTH_PROVIDER_ID = 'cursor'\n\nconst CURSOR_LOGIN_URL = 'https://cursor.com/loginDeepControl'\nconst CURSOR_POLL_URL = 'https://api2.cursor.sh/auth/poll'\nconst CURSOR_REFRESH_URL = 'https://api2.cursor.sh/auth/exchange_user_api_key'\n\nconst POLL_MAX_ATTEMPTS = 150\nconst POLL_BASE_DELAY_MS = 1000\nconst POLL_MAX_DELAY_MS = 10_000\nconst POLL_BACKOFF_MULTIPLIER = 1.2\nconst POLL_MAX_CONSECUTIVE_ERRORS = 3\n\n/** Fallback lifetime when the JWT carries no `exp`. */\nconst DEFAULT_TOKEN_TTL_MS = 3600 * 1000\n/** Refresh slightly early so requests don't race expiry. */\nconst TOKEN_EXPIRY_SKEW_MS = 5 * 60 * 1000\n\ninterface CursorTokenResponse {\n accessToken: string\n refreshToken: string\n}\n\n/**\n * Derive expiry (epoch ms) from a JWT's `exp` claim, minus a safety skew.\n * Returns `now + 1h` for malformed tokens so a missing claim never wedges\n * refresh into an immediate-expire loop.\n */\nexport function cursorTokenExpiry(token: string): number {\n try {\n const parts = token.split('.')\n const payload = parts[1]\n if (parts.length !== 3 || !payload)\n return Date.now() + DEFAULT_TOKEN_TTL_MS\n\n const json = JSON.parse(atob(payload.replace(/-/g, '+').replace(/_/g, '/'))) as { exp?: unknown }\n if (typeof json.exp === 'number')\n return json.exp * 1000 - TOKEN_EXPIRY_SKEW_MS\n }\n catch {\n // fall through to default\n }\n return Date.now() + DEFAULT_TOKEN_TTL_MS\n}\n\nfunction delay(ms: number): Promise<void> {\n return new Promise(r => setTimeout(r, ms))\n}\n\n/**\n * Poll Cursor's auth endpoint until login completes. `404` means the user\n * hasn't finished the browser flow yet; anything else non-2xx is a hard error.\n */\nasync function pollForTokens(\n uuid: string,\n verifier: string,\n callbacks: OAuthLoginCallbacks,\n): Promise<CursorTokenResponse> {\n let wait = POLL_BASE_DELAY_MS\n let consecutiveErrors = 0\n\n for (let attempt = 0; attempt < POLL_MAX_ATTEMPTS; attempt++) {\n if (callbacks.signal?.aborted)\n throw new Error('Cursor login aborted')\n\n await delay(wait)\n\n try {\n const url = `${CURSOR_POLL_URL}?uuid=${encodeURIComponent(uuid)}&verifier=${encodeURIComponent(verifier)}`\n const response = await fetch(url, { signal: callbacks.signal })\n\n if (response.status === 404) {\n consecutiveErrors = 0\n wait = Math.min(wait * POLL_BACKOFF_MULTIPLIER, POLL_MAX_DELAY_MS)\n continue\n }\n\n if (response.ok) {\n const data = await response.json() as Partial<CursorTokenResponse>\n if (!data.accessToken || !data.refreshToken)\n throw new Error(`Cursor poll response missing tokens: ${JSON.stringify(data)}`)\n return { accessToken: data.accessToken, refreshToken: data.refreshToken }\n }\n\n throw new Error(`Cursor poll failed (${response.status})`)\n }\n catch (err) {\n if (callbacks.signal?.aborted)\n throw new Error('Cursor login aborted')\n consecutiveErrors++\n if (consecutiveErrors >= POLL_MAX_CONSECUTIVE_ERRORS)\n throw err instanceof Error ? err : new Error(String(err))\n callbacks.onProgress?.('Waiting for Cursor login to complete…')\n }\n }\n\n throw new Error('Cursor authentication timed out')\n}\n\nexport async function loginCursor(callbacks: OAuthLoginCallbacks): Promise<OAuthCredentials> {\n const { verifier, challenge } = await generatePkce()\n const uuid = crypto.randomUUID()\n\n const authUrl = new URL(CURSOR_LOGIN_URL)\n authUrl.searchParams.set('challenge', challenge)\n authUrl.searchParams.set('uuid', uuid)\n authUrl.searchParams.set('mode', 'login')\n authUrl.searchParams.set('redirectTarget', 'cli')\n\n callbacks.onAuth({\n url: authUrl.toString(),\n instructions: 'A browser window should open. Complete login in Cursor to finish.',\n })\n\n const tokens = await pollForTokens(uuid, verifier, callbacks)\n\n return {\n access: tokens.accessToken,\n refresh: tokens.refreshToken,\n expires: cursorTokenExpiry(tokens.accessToken),\n }\n}\n\nexport async function refreshCursorToken(credentials: OAuthCredentials): Promise<OAuthCredentials> {\n const response = await fetch(CURSOR_REFRESH_URL, {\n method: 'POST',\n headers: {\n 'Authorization': `Bearer ${credentials.refresh}`,\n 'Content-Type': 'application/json',\n },\n body: '{}',\n })\n\n if (!response.ok) {\n const text = await response.text().catch(() => '')\n throw new Error(`Cursor token refresh failed (${response.status}): ${text || response.statusText}`)\n }\n\n const data = await response.json() as Partial<CursorTokenResponse>\n if (!data.accessToken)\n throw new Error(`Cursor token refresh response missing access token: ${JSON.stringify(data)}`)\n\n return {\n access: data.accessToken,\n // Cursor may omit a rotated refresh token — keep the existing one.\n refresh: data.refreshToken || credentials.refresh,\n expires: cursorTokenExpiry(data.accessToken),\n }\n}\n\n/**\n * Build a Cursor `OAuthProviderInterface`. Shape matches Anthropic / Codex so\n * it drops into `BUILTIN_PROVIDERS` and `src/auth.ts` unchanged.\n *\n * No `renderPage` parameter: Cursor's poll flow has no local callback server,\n * so there is no post-redirect page to theme.\n */\nexport function createCursorOAuthProvider(): OAuthProviderInterface {\n return {\n id: CURSOR_OAUTH_PROVIDER_ID,\n name: 'Cursor',\n usesCallbackServer: false,\n login: loginCursor,\n refreshToken: refreshCursorToken,\n getApiKey: credentials => credentials.access,\n }\n}\n","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-4.7-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":";;;;;AA+BA,MAAa,2BAA2B;AAExC,MAAM,mBAAmB;AACzB,MAAM,kBAAkB;AACxB,MAAM,qBAAqB;AAE3B,MAAM,oBAAoB;AAC1B,MAAM,qBAAqB;AAC3B,MAAM,oBAAoB;AAC1B,MAAM,0BAA0B;AAChC,MAAM,8BAA8B;;AAGpC,MAAM,uBAAuB,OAAO;;AAEpC,MAAM,uBAAuB,MAAS;;;;;;AAYtC,SAAgB,kBAAkB,OAAuB;CACvD,IAAI;EACF,MAAM,QAAQ,MAAM,MAAM,GAAG;EAC7B,MAAM,UAAU,MAAM;EACtB,IAAI,MAAM,WAAW,KAAK,CAAC,SACzB,OAAO,KAAK,IAAI,IAAI;EAEtB,MAAM,OAAO,KAAK,MAAM,KAAK,QAAQ,QAAQ,MAAM,GAAG,CAAC,CAAC,QAAQ,MAAM,GAAG,CAAC,CAAC;EAC3E,IAAI,OAAO,KAAK,QAAQ,UACtB,OAAO,KAAK,MAAM,MAAO;CAC7B,QACM,CAEN;CACA,OAAO,KAAK,IAAI,IAAI;AACtB;AAEA,SAAS,MAAM,IAA2B;CACxC,OAAO,IAAI,SAAQ,MAAK,W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O,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,2 +1,2 @@
1
- import { $f as openrouter, Ap as local, Bf as TurnResult, Dp as mistral, Ep as MistralParams, Ff as StreamOptions, Fp as BasetenParams, Gf as xai, Gp as anthropic, Hf as planZaiReasoning, Hp as AnthropicParams, If as TokenCountPayload, Ip as baseten, Jf as SchemaSanitizeResult, Kf as SchemaSanitizeOptions, Kp as applyAnthropicCacheBreakpoints, Lf as ToolCall, Lp as planBasetenReasoning, Mf as Provider, Mp as cursor, Nf as ProviderCapabilities, Np as CerebrasParams, Op as planMistralReasoning, Pf as StreamCallbacks, Pp as cerebras, Rf as ToolResult, Rp as ArceeParams, Uf as zai, Vf as ZaiParams, Wf as XaiParams, Xf as sanitizeToolSpecs, Yf as sanitizeToolSchema, Zf as OpenRouterParams, _p as openaiCompat, am as OAuthParams, ap as OpenAICompatParams, cm as credentialsFromParams, dm as readOAuthCredentials, f_ as ModelCatalog, fm as registerCustomOAuthProvider, fp as classifyOpenAICompatError, g_ as setModelCatalog, h_ as getModelCatalog, hm as OAuthProviderInterface, hp as mapOAIFinishReason, im as resolvePromptCacheKey, ip as OpenAICompatHttpError, jf as HistoryRepair, jp as CursorParams, kp as LocalParams, lm as extractRuntimeCredentials, m_ as ModelCatalogSource, mm as writeOAuthCredentials, nm as PromptCacheKeyOption, om as ResolveOAuthApiKeyOptions, p_ as ModelCatalogEntry, pm as resolveOAuthApiKey, qf as SchemaSanitizeProfile, rm as derivePromptCacheKey, rp as OpenAICompatAuthHeader, sm as credentialsFilePath, tm as PromptCacheKeyContext, um as isOAuthAccessToken, wp as openai, xp as OpenAIParams, zf as ToolSpec, zp as arcee } from "./index-CWBSrqI6.js";
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, 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, extractRuntimeCredentials, getModelCatalog, isOAuthAccessToken, local, mapOAIFinishReason, mistral, openai, openaiCompat, openrouter, planBasetenReasoning, planMistralReasoning, planZaiReasoning, readOAuthCredentials, registerCustomOAuthProvider, resolveOAuthApiKey, resolvePromptCacheKey, sanitizeToolSchema, sanitizeToolSpecs, setModelCatalog, writeOAuthCredentials, xai, zai };
1
+ import { $f as SchemaSanitizeProfile, Ap as openai, Bf as StreamCallbacks, Bp as cerebras, Cp as openaiCompat, Dp as OpenAIParams, Fp as LocalParams, Gf as ToolSpec, Gp as arcee, Hf as TokenCountPayload, Hp as baseten, If as HistoryRepair, Ip as local, Jf as planZaiReasoning, Jp as AnthropicParams, Kf as TurnResult, Lf as Provider, Lp as CursorParams, Mp as MistralParams, Np as mistral, Pp as planMistralReasoning, Qf as SchemaSanitizeOptions, Qp as applyAnthropicCacheBreakpoints, Rf as ProviderCapabilities, Rp as cursor, S_ as setModelCatalog, Uf as ToolCall, Up as planBasetenReasoning, Vf as StreamOptions, Vp as BasetenParams, Wf as ToolResult, Wp as ArceeParams, Xf as XaiParams, Yf as zai, Zf as xai, Zp as anthropic, _m as readOAuthCredentials, ap as openrouter, b_ as ModelCatalogSource, bm as writeOAuthCredentials, cm as PromptCacheKeyOption, dm as OAuthParams, dp as OpenAICompatParams, ep as SchemaSanitizeResult, fm as ResolveOAuthApiKeyOptions, gm as isOAuthAccessToken, hm as extractRuntimeCredentials, lm as derivePromptCacheKey, lp as OpenAICompatAuthHeader, mm as credentialsFromParams, np as sanitizeToolSpecs, pm as credentialsFilePath, qf as ZaiParams, rp as OpenRouterParams, sm as PromptCacheKeyContext, tp as sanitizeToolSchema, um as resolvePromptCacheKey, up as OpenAICompatHttpError, v_ as ModelCatalog, vm as registerCustomOAuthProvider, vp as classifyOpenAICompatError, x_ as getModelCatalog, xm as OAuthProviderInterface, xp as mapOAIFinishReason, y_ as ModelCatalogEntry, ym as resolveOAuthApiKey, zf as ProviderMeta, zp as CerebrasParams } from "./index-DfERTrql.js";
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, extractRuntimeCredentials, getModelCatalog, isOAuthAccessToken, local, mapOAIFinishReason, mistral, openai, openaiCompat, openrouter, planBasetenReasoning, planMistralReasoning, planZaiReasoning, readOAuthCredentials, registerCustomOAuthProvider, resolveOAuthApiKey, resolvePromptCacheKey, sanitizeToolSchema, sanitizeToolSpecs, setModelCatalog, writeOAuthCredentials, xai, zai };
package/dist/providers.js CHANGED
@@ -1,11 +1,11 @@
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-B3c_hzwf.js";
2
- import { n as anthropic, r as applyAnthropicCacheBreakpoints } from "./anthropic-D3lkw5mv.js";
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-CnHeo4Lz.js";
2
+ import { n as anthropic, r as applyAnthropicCacheBreakpoints } from "./anthropic-Dov2mC5e.js";
3
3
  import { a as readOAuthCredentials, c as writeOAuthCredentials, i as isOAuthAccessToken, n as credentialsFromParams, o as registerCustomOAuthProvider, r as extractRuntimeCredentials, s as resolveOAuthApiKey, t as credentialsFilePath } from "./oauth-bkEOybqm.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 { t as xai } from "./xai-BPwMQSuF.js";
8
- import { a as cursor, i as planMistralReasoning, n as zai, r as mistral, t as planZaiReasoning } from "./providers-z1vU0b2Q.js";
7
+ import { t as xai } from "./xai-Du6Wfnlb.js";
8
+ import { a as cursor, i as planMistralReasoning, n as zai, r as mistral, t as planZaiReasoning } from "./providers-B6mFe7OD.js";
9
9
  import { local } from "./providers/local.js";
10
10
  import { openai } from "./providers/openai.js";
11
11
  import { openrouter } from "./providers/openrouter.js";
package/dist/restate.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Dh as ToolContext, Ff as StreamOptions, Mf as Provider, Oh as ToolDef, Uh as ToolStateStore, Xi as McpToolWrap, Yi as McpToolMeta, _m as AgentClock, gm as AgentBehavior, mh as ToolResultContent, og as SessionStore, uh as ToolBatchExecutor } from "./index-CWBSrqI6.js";
1
+ import { Cm as AgentClock, Lf as Provider, Nh as ToolContext, Ph as ToolDef, Sm as AgentBehavior, Tm as AgentStats, Vf as StreamOptions, Xi as McpToolWrap, Yh as ToolStateStore, Yi as McpToolMeta, bh as ToolResultContent, fg as SessionStore, gh as ToolBatchExecutor, lh as SessionTurn } from "./index-DfERTrql.js";
2
2
  import { g as TaskExitInfo, h as TaskEntry, l as ExecutionHandle, o as DetachedTasksCapability } from "./types-M2DauK2D.js";
3
3
 
4
4
  //#region src/restate/types.d.ts
@@ -597,6 +597,182 @@ interface RestateSessionStoreOptions {
597
597
  */
598
598
  declare function restateSessionStore(ctx: RestateObjectContextLike, options?: RestateSessionStoreOptions): SessionStore;
599
599
  //#endregion
600
+ //#region src/restate/spawn.d.ts
601
+ /** What the parent hands a child invocation. */
602
+ interface ChildRunRequest {
603
+ /** The child's prompt. */
604
+ task: string;
605
+ /** Session-scoped label the parent reserved (`child-1`, `child-2`, …). */
606
+ label: string;
607
+ /**
608
+ * Identity of the work that spawned this child. Present when the parent has
609
+ * them; forward these to whatever sink the child publishes live events to so
610
+ * a UI can attribute and group them (the parent's own `child:*` events carry
611
+ * the same ids).
612
+ */
613
+ parentRunId?: string;
614
+ parentCallId?: string;
615
+ sessionId?: string;
616
+ /**
617
+ * Subagent depth of the CHILD (parent depth + 1). The handler is responsible
618
+ * for refusing runaway recursion — this tool always dispatches, because a
619
+ * short-circuit would have to return a non-durable promise and the durable
620
+ * fleet rejects those.
621
+ */
622
+ depth: number;
623
+ /** Model override requested by the model, if any. */
624
+ model?: string;
625
+ /** Named subagent type requested by the model, if any. */
626
+ subagentType?: string;
627
+ }
628
+ /**
629
+ * A descendant a child already merged, handed up so the top-level parent can
630
+ * rebuild the whole subtree.
631
+ *
632
+ * Why it exists: a child dispatched to a service runs sessionless, so it has
633
+ * nowhere to write ITS children's turns. Without passing them up, a depth-2
634
+ * fan-out loses the grandchildren entirely — the parent sees the child's `spawn`
635
+ * tool calls and nothing of the work they did. Collect these from
636
+ * {@link RestateSpawnToolOptions.onChildMerged} and return them as
637
+ * {@link ChildRunResult.children}.
638
+ */
639
+ interface MergedChild {
640
+ /** Label this level assigned. The merging parent re-labels from its own session counter. */
641
+ label: string;
642
+ task: string;
643
+ /** Depth relative to the run that merged it (1 for its direct children). */
644
+ depth: number;
645
+ status: 'completed' | 'aborted' | 'timeout' | 'error';
646
+ stats: AgentStats;
647
+ turns: SessionTurn[];
648
+ startedAt?: number;
649
+ endedAt?: number;
650
+ /** Its own merged descendants, recursively. */
651
+ children?: readonly MergedChild[];
652
+ }
653
+ /** What a child invocation returns. */
654
+ interface ChildRunResult {
655
+ status: 'completed' | 'aborted' | 'timeout' | 'error';
656
+ /** The child's final assistant text. */
657
+ text: string;
658
+ /**
659
+ * The child's turns, in order. Merged into the parent's session under a
660
+ * `SessionRun` for this child, so the persisted tree matches what
661
+ * `createSpawnTool({ persist: true })` produces in-process.
662
+ */
663
+ turns: SessionTurn[];
664
+ stats: AgentStats;
665
+ /** Failure detail when `status` is `'error'`. */
666
+ error?: string;
667
+ /**
668
+ * When the child started / finished, measured on the CHILD's clock (e.g.
669
+ * `await restateClock(ctx).now()` around its run).
670
+ *
671
+ * Strongly recommended for durable hosts. These land in the merged
672
+ * `SessionRun`, which the parent persists through a journaled state write, so
673
+ * they must be replay-stable. Values measured inside the child's own
674
+ * invocation are: they arrive in the journaled call result. Omit them and the
675
+ * parent falls back to the child's first / last turn timestamps, then to its
676
+ * own run start.
677
+ */
678
+ startedAt?: number;
679
+ endedAt?: number;
680
+ /**
681
+ * Descendants this child already merged — see {@link MergedChild}. The parent
682
+ * merges them recursively, so a nested fan-out lands in the session with the
683
+ * right depths and emits `child:*` events at every level.
684
+ */
685
+ children?: readonly MergedChild[];
686
+ }
687
+ interface RestateSpawnToolOptions {
688
+ /**
689
+ * Start the child invocation and return the runtime's promise **untouched**
690
+ * (e.g. `ctx.serviceClient(childService).runChild(req)`). Do not wrap it in
691
+ * `then` / `catch` / `race`, and do not `await` it here.
692
+ */
693
+ dispatch: (req: ChildRunRequest, ctx: ToolContext) => Promise<ChildRunResult>;
694
+ /**
695
+ * Merge each child's turns and run record into the parent's session.
696
+ * Default: `true` when the parent has a session.
697
+ *
698
+ * Ordering nuance versus the in-process tool: the merge runs on
699
+ * `tool-results:after`, so a child's turns are appended just AFTER the
700
+ * parent's tool-result turn rather than just before it. Their `createdAt`
701
+ * values still order them correctly for consumers that sort chronologically.
702
+ */
703
+ persist?: boolean;
704
+ /**
705
+ * Called once when the parent aborts with children still in flight. Wire it
706
+ * and an aborted parent stops its children instead of orphaning them.
707
+ *
708
+ * The practical implementation is to cancel the parent's OWN invocation:
709
+ *
710
+ * ```ts
711
+ * onAbort: () => ctx.invocation(ctx.request().id).cancel()
712
+ * ```
713
+ *
714
+ * Restate cancels the whole call tree, so this reaches children at any depth
715
+ * and needs no per-child bookkeeping. `ctx.request().id` is available
716
+ * synchronously and is constant across retries and suspensions. The cost is
717
+ * that the parent invocation ends too — an in-agent abort becomes "stop
718
+ * everything", so persist whatever summary you need BEFORE aborting.
719
+ *
720
+ * Why not per-child ids: the `invocationId` on the runtime's call handle is
721
+ * itself a journal-backed promise (`SingleRestatePromise`, see
722
+ * `@restatedev/restate-sdk` `context_impl.js`), so reading it while the call
723
+ * is in flight registers a second consumer on the SDK's single-consumer
724
+ * progress channel — `awaitNext already pending`, a failed attempt, and a
725
+ * replay on every fan-out. Verified against a real server. Per-child
726
+ * cancellation needs the two-phase (send → id → attach) tool shape, where the
727
+ * id is consumed before the result promise exists.
728
+ *
729
+ * Timing: cancelling appends a journal command, so it must not happen during
730
+ * a replay. Drive aborts through `replayAwareAbort` (see `./replay`), which
731
+ * defers an external abort to the first live boundary.
732
+ */
733
+ onAbort?: (inFlight: readonly InFlightChild[], ctx: ToolContext) => void;
734
+ /**
735
+ * Replay each finished child's transcript onto the parent's hook bus as
736
+ * `child:*` events, so hosts already rendering subagent activity work
737
+ * unchanged. Default: `true`.
738
+ *
739
+ * These are NOT live — hook bubbling cannot cross an invocation boundary, so
740
+ * they fire when the child finishes, in submission order. For live output,
741
+ * publish from the child's own bus inside your handler and correlate with the
742
+ * `parentRunId` / `parentCallId` / `sessionId` carried in
743
+ * {@link ChildRunRequest}; see `docs/RESTATE.md` § Parallel subagents.
744
+ *
745
+ * They re-fire on a parent replay, exactly as the in-process tool's
746
+ * `child:tool:*` does — dedupe by `callId` / `turnId`, or gate on
747
+ * `createReplayTracker`.
748
+ */
749
+ emitChildEvents?: boolean;
750
+ /**
751
+ * Called for each child as it merges, with the subtree it brought along.
752
+ *
753
+ * Sessionless agents (a child dispatched to a service) need this: they have
754
+ * nowhere to persist their own children, so they collect here and hand the
755
+ * result up as {@link ChildRunResult.children}. Without it a nested fan-out
756
+ * loses everything below depth 1.
757
+ */
758
+ onChildMerged?: (merged: MergedChild, ctx: ToolContext) => void;
759
+ /** Override the tool description shown to the model. */
760
+ description?: string;
761
+ }
762
+ /**
763
+ * The `invocationId` half of the runtime's invocation handle. Restate's
764
+ * `ctx.serviceClient(...).method(...)` returns `RestatePromise & { invocationId:
765
+ * Promise<InvocationId> }`; only that field is needed here, so this stays a
766
+ * structural type rather than an SDK import.
767
+ */
768
+ /** A child that was dispatched and has not settled yet. */
769
+ interface InFlightChild {
770
+ label: string;
771
+ task: string;
772
+ depth: number;
773
+ }
774
+ declare function restateSpawnTool(options: RestateSpawnToolOptions): ToolDef;
775
+ //#endregion
600
776
  //#region src/restate/tool.d.ts
601
777
  /**
602
778
  * Opt-in two-phase journaling for long-running, re-attachable tools.
@@ -941,5 +1117,5 @@ declare function restateWaitBackground(options: RestateWaitBackgroundOptions): (
941
1117
  signal?: AbortSignal;
942
1118
  }) => Promise<TaskExitInfo | null>;
943
1119
  //#endregion
944
- export { type AwakeableWithTimeoutOptions, DEFAULT_TOOL_STATE_KEY, type ReplayDoneHooks, type ReplayTracker, type ReplayTrackerOptions, type RestateAwakeable, type RestateAwakeableToolOptions, type RestateClockOptions, type RestateContextLike, type RestateDurableStart, type RestateDurableWait, type RestateMcpToolWrapOptions, type RestateObjectContextLike, type RestatePromiseAllLike, type RestatePromiseLike, type RestatePromiseRaceLike, type RestateProviderOptions, type RestateRunOptions, type RestateSessionStoreOptions, type RestateToolBatchExecutorOptions, type RestateToolOptions, type RestateToolStateStoreOptions, type RestateWaitBackgroundOptions, awakeableWithTimeout, createReplayTracker, deterministicUuid, replayAwareAbort, restateAwakeableTool, restateBehavior, restateClock, restateMcpToolWrap, restateProvider, restateSessionStore, restateTool, restateToolBatchExecutor, restateToolStateStore, restateWaitBackground, shouldRethrowRestateControlError, wrapAgentTools };
1120
+ export { type AwakeableWithTimeoutOptions, type ChildRunRequest, type ChildRunResult, DEFAULT_TOOL_STATE_KEY, type InFlightChild, type MergedChild, type ReplayDoneHooks, type ReplayTracker, type ReplayTrackerOptions, type RestateAwakeable, type RestateAwakeableToolOptions, type RestateClockOptions, type RestateContextLike, type RestateDurableStart, type RestateDurableWait, type RestateMcpToolWrapOptions, type RestateObjectContextLike, type RestatePromiseAllLike, type RestatePromiseLike, type RestatePromiseRaceLike, type RestateProviderOptions, type RestateRunOptions, type RestateSessionStoreOptions, type RestateSpawnToolOptions, type RestateToolBatchExecutorOptions, type RestateToolOptions, type RestateToolStateStoreOptions, type RestateWaitBackgroundOptions, awakeableWithTimeout, createReplayTracker, deterministicUuid, replayAwareAbort, restateAwakeableTool, restateBehavior, restateClock, restateMcpToolWrap, restateProvider, restateSessionStore, restateSpawnTool, restateTool, restateToolBatchExecutor, restateToolStateStore, restateWaitBackground, shouldRethrowRestateControlError, wrapAgentTools };
945
1121
  //# sourceMappingURL=restate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"restate.d.ts","names":[],"sources":["../src/restate/types.ts","../src/restate/awakeable.ts","../src/restate/awakeable-tool.ts","../src/restate/behavior.ts","../src/restate/clock.ts","../src/restate/errors.ts","../src/restate/replay.ts","../src/restate/mcp.ts","../src/restate/parallel.ts","../src/restate/provider.ts","../src/restate/session.ts","../src/restate/tool.ts","../src/restate/tool-state.ts","../src/restate/wait-background.ts"],"mappings":";;;;;;;;AAmBA;;;;;;;;;;;AAYO;AAUP;;UAtBiB,iBAAA;EAwBC;EAtBhB,gBAAA;EAqBA;EAnBA,gBAAA;EAoBS;EAlBT,oBAAA;EAkBkB;EAhBlB,gBAAA;EAuCe;EArCf,mBAAA;EAqCiC;EAnCjC,KAAA;AAAA;;;;;;;;UAUe,gBAAA;EACf,EAAA;EACA,OAAA,EAAS,OAAO,CAAC,CAAA;AAAA;;;;;;;;;;;;;;;;;;;;;UAuBF,kBAAA;EACf,GAAA,MACE,IAAA,UACA,EAAA,QAAU,OAAA,CAAQ,CAAA,IAAK,CAAA,EACvB,OAAA,GAAU,iBAAA,KACP,OAAA,CAAQ,CAAA;EACb,IAAA;IAAQ,GAAA,QAAW,OAAA;EAAA;EACnB,IAAA;IAAQ,MAAA;EAAA;EACR,SAAA,WAAoB,gBAAA,CAAiB,CAAA;EA0BP;;;;;;;;;;;;EAb9B,KAAA,GAAQ,MAAA,aAAmB,OAAA;AAAA;;;;;;AAcP;;UAJL,wBAAA,SAAiC,kBAAA;EAChD,GAAA;EACA,GAAA,MAAS,IAAA,aAAiB,OAAA,CAAQ,CAAA;EAClC,GAAA,MAAS,IAAA,UAAc,KAAA,EAAO,CAAA;EAC9B,KAAA,GAAQ,IAAA;AAAA;;;;;AAtEH;AAUP;;;;;UClBiB,sBAAA,kBAAwC,OAAA,YAAmB,OAAA;EAC1E,IAAA,GAAO,MAAA,WAAiB,QAAA,OAAe,OAAA;AAAA;AAAA,UAG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ClC,OAAA;AP9KiG;;;;ACnHpG;;;;ADmHoG,iBO0pBpF,cAAA,CACd,KAAA,EAAO,MAAA,SAAe,OAAA,GACtB,GAAA,EAAK,kBAAA,EACL,IAAA,GAAM,IAAA,CAAK,kBAAA;EAAwC,OAAA;AAAA,IAClD,MAAA,SAAe,OAAA;;;;cCjvBL,sBAAA;AAAA,UAEI,4BAAA;EZ8CY;EY5C3B,GAAA;EZ4CkC;;;;;;;;EYnClC,aAAa;AAAA;;;;;;;;;;;;;;;;AZmCqB;AAUpC;;;;;;;;;;;;;;;;iBYVgB,qBAAA,CACd,GAAA,EAAK,wBAAA,EACL,OAAA,GAAS,4BAAA,GACR,cAAA;;;UC7Cc,4BAAA;Eb6BsB;Ea3BrC,GAAA,EAAK,kBAAA;EbwCsB;;;;;;EajC3B,KAAA,GAAQ,MAAA,EAAQ,eAAA,EAAiB,MAAA,aAAmB,OAAA,UAAiB,SAAA,eAAwB,SAAA;EbezE;;;;;;EaRpB,QAAA,GAAW,WAAA,UAAqB,MAAA,UAAgB,MAAA,EAAQ,eAAA,KAAoB,OAAA;EbW5E;;;;;EaLA,MAAA,IAAU,WAAA,UAAqB,MAAA,UAAgB,IAAA,EAAM,YAAA,SAAqB,MAAA,EAAQ,eAAA,KAAoB,OAAA;EbO1F;;;;;EaDZ,SAAA;EbckC;AAAA;AAUpC;;;EalBE,QAAA,GAAW,sBAAA;EboBe;EalB1B,UAAA,GAAa,iBAAA;EbgBmC;EadhD,WAAA;EbckE;EaZlE,aAAA,GAAgB,aAAA;AAAA;;;;;;iBAiDF,qBAAA,CACd,OAAA,EAAS,4BAAA,IACP,MAAA,EAAQ,eAAA,EAAiB,MAAA,UAAgB,IAAA;EAAS,SAAA;EAAoB,MAAA,GAAS,WAAA;AAAA,MAAkB,OAAA,CAAQ,YAAA"}
1
+ {"version":3,"file":"restate.d.ts","names":[],"sources":["../src/restate/types.ts","../src/restate/awakeable.ts","../src/restate/awakeable-tool.ts","../src/restate/behavior.ts","../src/restate/clock.ts","../src/restate/errors.ts","../src/restate/replay.ts","../src/restate/mcp.ts","../src/restate/parallel.ts","../src/restate/provider.ts","../src/restate/session.ts","../src/restate/spawn.ts","../src/restate/tool.ts","../src/restate/tool-state.ts","../src/restate/wait-background.ts"],"mappings":";;;;;;;;AAmBA;;;;;;;;;;;AAYO;AAUP;;UAtBiB,iBAAA;EAwBC;EAtBhB,gBAAA;EAqBA;EAnBA,gBAAA;EAoBS;EAlBT,oBAAA;EAkBkB;EAhBlB,gBAAA;EAuCe;EArCf,mBAAA;EAqCiC;EAnCjC,KAAA;AAAA;;;;;;;;UAUe,gBAAA;EACf,EAAA;EACA,OAAA,EAAS,OAAO,CAAC,CAAA;AAAA;;;;;;;;;;;;;;;;;;;;;UAuBF,kBAAA;EACf,GAAA,MACE,IAAA,UACA,EAAA,QAAU,OAAA,CAAQ,CAAA,IAAK,CAAA,EACvB,OAAA,GAAU,iBAAA,KACP,OAAA,CAAQ,CAAA;EACb,IAAA;IAAQ,GAAA,QAAW,OAAA;EAAA;EACnB,IAAA;IAAQ,MAAA;EAAA;EACR,SAAA,WAAoB,gBAAA,CAAiB,CAAA;EA0BP;;;;;;;;;;;;EAb9B,KAAA,GAAQ,MAAA,aAAmB,OAAA;AAAA;;;;;;AAcP;;UAJL,wBAAA,SAAiC,kBAAA;EAChD,GAAA;EACA,GAAA,MAAS,IAAA,aAAiB,OAAA,CAAQ,CAAA;EAClC,GAAA,MAAS,IAAA,UAAc,KAAA,EAAO,CAAA;EAC9B,KAAA,GAAQ,IAAA;AAAA;;;;;AAtEH;AAUP;;;;;UClBiB,sBAAA,kBAAwC,OAAA,YAAmB,OAAA;EAC1E,IAAA,GAAO,MAAA,WAAiB,QAAA,OAAe,OAAA;AAAA;AAAA,UAGxB,2BAAA,kBAA6C,OAAA,YAAmB,OAAA;EDgB7D;AAAA;AAuBpB;;EClCE,SAAA;EDqCoB;;;;;;;EC7BpB,QAAA,GAAW,sBAAA,CAAuB,QAAA;AAAA;;;;;;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