zidane 8.2.1 → 8.2.3
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-cli.js +8 -8
- package/dist/{acp-D7Pr8NGt.js → acp-oYRjlh71.js} +6 -6
- package/dist/{acp-D7Pr8NGt.js.map → acp-oYRjlh71.js.map} +1 -1
- package/dist/acp.d.ts +2 -2
- package/dist/acp.js +1 -1
- package/dist/{agent-DecDtKA_.js → agent-CBQglXtH.js} +9 -379
- package/dist/agent-CBQglXtH.js.map +1 -0
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +1 -1
- package/dist/{builtin-artifact-kinds-B_OEgf8b.js → builtin-artifact-kinds-BmorPkgz.js} +36 -9
- package/dist/builtin-artifact-kinds-BmorPkgz.js.map +1 -0
- package/dist/chat/pure.d.ts +4 -4
- package/dist/chat/pure.js +6 -6
- package/dist/chat.d.ts +4 -4
- package/dist/chat.js +15 -15
- package/dist/{cli-shared-Dx4vmif6.js → cli-shared-E5m_pI8A.js} +2 -2
- package/dist/{cli-shared-Dx4vmif6.js.map → cli-shared-E5m_pI8A.js.map} +1 -1
- package/dist/{client-core-imHuBWV3.d.ts → client-core-EEEX_u6D.d.ts} +24 -5
- package/dist/{client-core-imHuBWV3.d.ts.map → client-core-EEEX_u6D.d.ts.map} +1 -1
- package/dist/{connection-loop-CdHt3iQi.d.ts → connection-loop-CpgfUmuw.d.ts} +3 -3
- package/dist/{connection-loop-CdHt3iQi.d.ts.map → connection-loop-CpgfUmuw.d.ts.map} +1 -1
- package/dist/contexts/daytona.d.ts +1 -1
- package/dist/contexts/e2b.d.ts +1 -1
- package/dist/{credentials-Dti61yoi.js → credentials-B9DfBJP9.js} +11 -7
- package/dist/credentials-B9DfBJP9.js.map +1 -0
- package/dist/daemon-cli.js +2 -2
- package/dist/{dispatcher-vy3J6JMA.js → dispatcher-Bv9-c6I2.js} +28 -14
- package/dist/dispatcher-Bv9-c6I2.js.map +1 -0
- package/dist/{engine-BN6PjWAW.js → engine-XmoPPB6U.js} +5 -5
- package/dist/{engine-BN6PjWAW.js.map → engine-XmoPPB6U.js.map} +1 -1
- package/dist/{eval-BaJtxLCW.js → eval-CfQlBR81.js} +2 -2
- package/dist/{eval-BaJtxLCW.js.map → eval-CfQlBR81.js.map} +1 -1
- package/dist/eval.d.ts +1 -1
- package/dist/eval.js +1 -1
- package/dist/{executor-CT4oUkg6.js → executor-BhthPE1q.js} +3 -3
- package/dist/{executor-CT4oUkg6.js.map → executor-BhthPE1q.js.map} +1 -1
- package/dist/{extensions-BKt7lxxv.js → extensions-BgBwogRW.js} +114 -113
- package/dist/extensions-BgBwogRW.js.map +1 -0
- package/dist/extensions.d.ts +1 -1
- package/dist/extensions.js +2 -2
- package/dist/{fold-rules-BYedvsH7.d.ts → fold-rules-DSypi36k.d.ts} +2 -2
- package/dist/{fold-rules-BYedvsH7.d.ts.map → fold-rules-DSypi36k.d.ts.map} +1 -1
- package/dist/google-O6pRnddf.js +881 -0
- package/dist/google-O6pRnddf.js.map +1 -0
- package/dist/{headless-Ebd1ZEzC.js → headless-R4pbpTkm.js} +3 -3
- package/dist/{headless-Ebd1ZEzC.js.map → headless-R4pbpTkm.js.map} +1 -1
- package/dist/headless.d.ts +1 -1
- package/dist/headless.js +1 -1
- package/dist/{host-scoped-settings-Cy_zbmB_.js → host-scoped-settings-C-Nmb6vr.js} +2 -2
- package/dist/{host-scoped-settings-Cy_zbmB_.js.map → host-scoped-settings-C-Nmb6vr.js.map} +1 -1
- package/dist/{host-signals-Cx2IAbHh.js → host-signals-BFudPyCT.js} +5 -5
- package/dist/{host-signals-Cx2IAbHh.js.map → host-signals-BFudPyCT.js.map} +1 -1
- package/dist/{index-pc71ADi6.d.ts → index-AqRZ3gEz.d.ts} +71 -4
- package/dist/index-AqRZ3gEz.d.ts.map +1 -0
- package/dist/{index-Bt_G2Z_2.d.ts → index-CDS7YdUC.d.ts} +5 -5
- package/dist/{index-Bt_G2Z_2.d.ts.map → index-CDS7YdUC.d.ts.map} +1 -1
- package/dist/{index-CidMTcxS.d.ts → index-DyQyDLX1.d.ts} +167 -10
- package/dist/index-DyQyDLX1.d.ts.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +15 -15
- package/dist/ipc/remote.d.ts +5 -5
- package/dist/ipc/remote.js +3 -3
- package/dist/ipc.d.ts +5 -5
- package/dist/ipc.js +7 -7
- package/dist/{links-DSZ4uQ5w.js → links-rFaWqS2Y.js} +10 -10
- package/dist/{links-DSZ4uQ5w.js.map → links-rFaWqS2Y.js.map} +1 -1
- package/dist/{mcp-allowlist-BQ5MvhHi.js → mcp-allowlist-CLXweyxk.js} +14 -3
- package/dist/mcp-allowlist-CLXweyxk.js.map +1 -0
- package/dist/mcp.d.ts +1 -1
- package/dist/{oauth-BSqXgads.js → oauth-7_48zR7n.js} +226 -40
- package/dist/oauth-7_48zR7n.js.map +1 -0
- package/dist/{openai-dTmPxM6T.js → openai-Rh6u5NXF.js} +121 -2
- package/dist/openai-Rh6u5NXF.js.map +1 -0
- package/dist/{openrouter-CtZbQDa0.js → openrouter-Dg0yaI-o.js} +91 -2
- package/dist/openrouter-Dg0yaI-o.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-EzlHyFSi.js → presets-DXeHsd24.js} +3 -3
- package/dist/{presets-EzlHyFSi.js.map → presets-DXeHsd24.js.map} +1 -1
- package/dist/presets.d.ts +1 -1
- package/dist/presets.js +1 -1
- package/dist/{prompts-D2lPHLOV.d.ts → prompts-DmY13jvF.d.ts} +2 -1
- package/dist/prompts-DmY13jvF.d.ts.map +1 -0
- package/dist/protocol-BIv1Yuvl.js.map +1 -1
- package/dist/providers/anthropic.d.ts +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/google.d.ts +1 -1
- package/dist/providers/google.js +1 -784
- package/dist/providers/local.d.ts +1 -1
- package/dist/providers/neuralwatt.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/openrouter.js +1 -1
- package/dist/providers/xai.d.ts +1 -1
- package/dist/providers/xai.js +1 -101
- package/dist/providers.d.ts +2 -2
- package/dist/providers.js +6 -5
- package/dist/{registry-BBaEgTsX.js → registry-eourRLY2.js} +3 -3
- package/dist/{registry-BBaEgTsX.js.map → registry-eourRLY2.js.map} +1 -1
- package/dist/{remote-hosts-bO7wOt44.js → remote-hosts-DY2J07ut.js} +4 -4
- package/dist/{remote-hosts-bO7wOt44.js.map → remote-hosts-DY2J07ut.js.map} +1 -1
- package/dist/restate.d.ts +1 -1
- package/dist/{secret-shapes-Cda65uDH.js → secret-shapes-BjW4l6U0.js} +17 -3
- package/dist/secret-shapes-BjW4l6U0.js.map +1 -0
- package/dist/session/sqlite.d.ts +1 -1
- package/dist/{session-factory-BazyVdzj.js → session-factory-CMwIXE-7.js} +5 -5
- package/dist/{session-factory-BazyVdzj.js.map → session-factory-CMwIXE-7.js.map} +1 -1
- package/dist/session.d.ts +1 -1
- package/dist/{settings-keys-zYaer8DY.js → settings-keys-CPdmkTz7.js} +3 -3
- package/dist/{settings-keys-zYaer8DY.js.map → settings-keys-CPdmkTz7.js.map} +1 -1
- package/dist/{shell-path-od9XHRPt.js → shell-path-B8b3EOtK.js} +3 -3
- package/dist/{shell-path-od9XHRPt.js.map → shell-path-B8b3EOtK.js.map} +1 -1
- package/dist/{skills-use-D68a1gyZ.js → skills-use-CssTEaIj.js} +375 -2
- package/dist/skills-use-CssTEaIj.js.map +1 -0
- package/dist/skills.d.ts +1 -1
- package/dist/store-L01W0gGI.js.map +1 -1
- package/dist/{system-freeze-DXvJpveP.js → system-freeze-Um9ZJiPo.js} +24 -9
- package/dist/system-freeze-Um9ZJiPo.js.map +1 -0
- package/dist/{todo-edits-CmqNFvLJ.js → todo-edits-BERpCRPj.js} +3 -3
- package/dist/{todo-edits-CmqNFvLJ.js.map → todo-edits-BERpCRPj.js.map} +1 -1
- package/dist/tools/fetch-url.d.ts +1 -1
- package/dist/tools/prompts.d.ts +1 -1
- package/dist/tools/prompts.js +7 -0
- package/dist/tools/prompts.js.map +1 -1
- package/dist/tools/web-search.d.ts +1 -1
- package/dist/{tools-9Dpm8F-f.js → tools-pZVFIJ_K.js} +273 -2
- package/dist/tools-pZVFIJ_K.js.map +1 -0
- package/dist/tools.d.ts +3 -3
- package/dist/tools.js +4 -4
- package/dist/{transcript-anchors-B3TFJqr_.js → transcript-anchors-jHrg-r-H.js} +10 -10
- package/dist/{transcript-anchors-B3TFJqr_.js.map → transcript-anchors-jHrg-r-H.js.map} +1 -1
- package/dist/{transcript-reconcile-BC2DbTmp.js → transcript-reconcile-CPdrNbbR.js} +19 -2
- package/dist/{transcript-reconcile-BC2DbTmp.js.map → transcript-reconcile-CPdrNbbR.js.map} +1 -1
- package/dist/tui.d.ts +7 -7
- package/dist/tui.js +25 -23
- package/dist/tui.js.map +1 -1
- package/dist/{turn-operations-CIFoOebZ.d.ts → turn-operations-DuGtKuc_.d.ts} +10 -3
- package/dist/turn-operations-DuGtKuc_.d.ts.map +1 -0
- package/dist/{types-iFLlZKd0.d.ts → types-C0PJmBaO.d.ts} +2 -2
- package/dist/{types-iFLlZKd0.d.ts.map → types-C0PJmBaO.d.ts.map} +1 -1
- package/dist/types-JzccL5GE.js +24 -0
- package/dist/types-JzccL5GE.js.map +1 -0
- package/dist/types.d.ts +2 -2
- package/dist/{url-BTH-HE9Y.js → url-D8KZ7Edw.js} +2 -2
- package/dist/{url-BTH-HE9Y.js.map → url-D8KZ7Edw.js.map} +1 -1
- package/dist/{version-4T82xRxQ.js → version-bd3DQJkc.js} +2 -2
- package/dist/{version-4T82xRxQ.js.map → version-bd3DQJkc.js.map} +1 -1
- package/dist/wire-DH77Z-rr.js +80 -0
- package/dist/wire-DH77Z-rr.js.map +1 -0
- package/dist/{workspace-exec-stream-By8na6vz.js → workspace-exec-stream-CyfYgqAh.js} +4 -4
- package/dist/{workspace-exec-stream-By8na6vz.js.map → workspace-exec-stream-CyfYgqAh.js.map} +1 -1
- package/dist/{write-file-B4vi3SvQ.js → write-file-QYrcDdl3.js} +3 -3
- package/dist/{write-file-B4vi3SvQ.js.map → write-file-QYrcDdl3.js.map} +1 -1
- package/dist/{ws-CS312Jpx.js → ws-CURQ2igk.js} +5 -5
- package/dist/{ws-CS312Jpx.js.map → ws-CURQ2igk.js.map} +1 -1
- package/dist/{ws-client-wWka-Jku.js → ws-client-BVljYbdb.js} +3 -3
- package/dist/{ws-client-wWka-Jku.js.map → ws-client-BVljYbdb.js.map} +1 -1
- package/dist/xai-CStTwCV2.js +182 -0
- package/dist/xai-CStTwCV2.js.map +1 -0
- package/docs/ARCHITECTURE.md +1 -0
- package/docs/ARTIFACTS.md +1 -1
- package/docs/EXTENSIONS.md +9 -5
- package/package.json +2 -2
- package/dist/agent-DecDtKA_.js.map +0 -1
- package/dist/builtin-artifact-kinds-B_OEgf8b.js.map +0 -1
- package/dist/credentials-Dti61yoi.js.map +0 -1
- package/dist/dispatcher-vy3J6JMA.js.map +0 -1
- package/dist/extensions-BKt7lxxv.js.map +0 -1
- package/dist/index-CidMTcxS.d.ts.map +0 -1
- package/dist/index-pc71ADi6.d.ts.map +0 -1
- package/dist/mcp-allowlist-BQ5MvhHi.js.map +0 -1
- package/dist/oauth-BSqXgads.js.map +0 -1
- package/dist/openai-dTmPxM6T.js.map +0 -1
- package/dist/openrouter-CtZbQDa0.js.map +0 -1
- package/dist/prompts-D2lPHLOV.d.ts.map +0 -1
- package/dist/providers/google.js.map +0 -1
- package/dist/providers/xai.js.map +0 -1
- package/dist/secret-shapes-Cda65uDH.js.map +0 -1
- package/dist/skills-use-D68a1gyZ.js.map +0 -1
- package/dist/system-freeze-DXvJpveP.js.map +0 -1
- package/dist/tools-9Dpm8F-f.js.map +0 -1
- package/dist/turn-operations-CIFoOebZ.d.ts.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MS as LocalParams, NS as local } from "../index-DyQyDLX1.js";
|
|
2
2
|
export { LocalParams, local };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DS as neuralwatt, ES as NeuralwattParams, OS as planNeuralwattReasoning, TS as NEURALWATT_DEFAULT_MODEL } from "../index-DyQyDLX1.js";
|
|
2
2
|
export { NEURALWATT_DEFAULT_MODEL, NeuralwattParams, neuralwatt, planNeuralwattReasoning };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $x as
|
|
1
|
+
import { $x as ASSISTANT_TOOL_CALLS_TAG, _S as userMessage, aS as TOOL_RESULTS_TAG, cS as assistantMessage, dS as formatTools, eS as OAIMessage, fS as mapOAIFinishReason, gS as toolResultsMessage, hS as toOAIMessages, iS as OpenAICompatParams, lS as buildAssistantContent, mS as openaiCompat, nS as OpenAICompatAuthHeader, oS as applyOAICacheBreakpoints, pS as openAICompatPromptMessage, rS as OpenAICompatHttpError, sS as applyOAIToolCacheBreakpoint, tS as OAITool, uS as classifyOpenAICompatError, vS as OpenAICompatStreamError, yS as consumeSSE } from "../index-DyQyDLX1.js";
|
|
2
2
|
export { ASSISTANT_TOOL_CALLS_TAG, OAIMessage, OAITool, OpenAICompatAuthHeader, OpenAICompatHttpError, OpenAICompatParams, OpenAICompatStreamError, TOOL_RESULTS_TAG, applyOAICacheBreakpoints, applyOAIToolCacheBreakpoint, assistantMessage, buildAssistantContent, classifyOpenAICompatError, consumeSSE, formatTools, mapOAIFinishReason, openAICompatPromptMessage, openaiCompat, toOAIMessages, toolResultsMessage, userMessage };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CS as openai, SS as mapCodexStopReason, bS as OpenAIParams, wS as toPiMessages, xS as classifyOpenAIError } from "../index-DyQyDLX1.js";
|
|
2
2
|
export { OpenAIParams, classifyOpenAIError, mapCodexStopReason, openai, toPiMessages };
|
package/dist/providers/openai.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as classifyOpenAIError, n as mapCodexStopReason, r as openai, i as toPiMessages } from "../openai-
|
|
1
|
+
export { t as classifyOpenAIError, n as mapCodexStopReason, r as openai, i as toPiMessages } from "../openai-Rh6u5NXF.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Qx as openrouter, Xx as OpenRouterParams, Yx as OPENROUTER_DEFAULT_MODEL, Zx as normalizeOpenRouterModelId } from "../index-DyQyDLX1.js";
|
|
2
2
|
export { OPENROUTER_DEFAULT_MODEL, OpenRouterParams, normalizeOpenRouterModelId, openrouter };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as OPENROUTER_DEFAULT_MODEL, n as normalizeOpenRouterModelId, r as openrouter } from "../openrouter-
|
|
1
|
+
export { t as OPENROUTER_DEFAULT_MODEL, n as normalizeOpenRouterModelId, r as openrouter } from "../openrouter-Dg0yaI-o.js";
|
package/dist/providers/xai.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Hx as XaiParams, Ux as xai } from "../index-DyQyDLX1.js";
|
|
2
2
|
export { XaiParams, xai };
|
package/dist/providers/xai.js
CHANGED
|
@@ -1,101 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { i as isOAuthAccessToken, l as resolveOAuthApiKey, r as extractRuntimeCredentials } from "../oauth-DRrs-65k.js";
|
|
3
|
-
import { r as xaiBaseUrl, t as XAI_OAUTH_PROVIDER_ID } from "../xai-6tBTk6CU.js";
|
|
4
|
-
//#region src/providers/xai.ts
|
|
5
|
-
const DEFAULT_MODEL = "grok-4.6";
|
|
6
|
-
/**
|
|
7
|
-
* xAI Grok provider — supports both a static API key (`XAI_API_KEY`) and the
|
|
8
|
-
* SuperGrok / X Premium+ OAuth subscription.
|
|
9
|
-
*
|
|
10
|
-
* Both auth modes hit the same OpenAI-compatible endpoint (`https://api.x.ai/v1`
|
|
11
|
-
* unless `XAI_BASE_URL` or `PI_XAI_BASE_URL` overrides it),
|
|
12
|
-
* so the wire handling is entirely {@link openaiCompat}. The only difference is
|
|
13
|
-
* the bearer:
|
|
14
|
-
*
|
|
15
|
-
* - **API key**: `XAI_API_KEY` (or `params.apiKey`) → used verbatim.
|
|
16
|
-
* - **OAuth**: no static key → {@link resolveOAuthApiKey} resolves + lazily
|
|
17
|
-
* refreshes the stored `xai-oauth` token on every turn.
|
|
18
|
-
*
|
|
19
|
-
* `resolveOAuthApiKey` unifies the two: a real API key in `XAI_API_KEY` is
|
|
20
|
-
* returned as-is, while an OAuth access token (or no env value at all) falls
|
|
21
|
-
* through to the refreshable stored credentials. So this single factory serves
|
|
22
|
-
* both paths without branching at construction time.
|
|
23
|
-
*
|
|
24
|
-
* @param params - API key or OAuth credentials, default model, capabilities and extra headers.
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```ts
|
|
28
|
-
* import { createAgent } from 'zidane'
|
|
29
|
-
* import { xai } from 'zidane/providers/xai'
|
|
30
|
-
*
|
|
31
|
-
* const agent = createAgent({
|
|
32
|
-
* provider: xai({ apiKey: process.env.XAI_API_KEY }),
|
|
33
|
-
* })
|
|
34
|
-
* await agent.run({ prompt: 'Say hello.' })
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
function xai(params) {
|
|
38
|
-
const defaultModel = params?.defaultModel || DEFAULT_MODEL;
|
|
39
|
-
const baseURL = xaiBaseUrl();
|
|
40
|
-
const capabilities = params?.capabilities ?? {
|
|
41
|
-
vision: true,
|
|
42
|
-
imageInToolResult: false
|
|
43
|
-
};
|
|
44
|
-
const baseCredentials = extractRuntimeCredentials(params);
|
|
45
|
-
let runtimeCredentials = baseCredentials;
|
|
46
|
-
const staticKey = params?.apiKey ?? (params?.account ? void 0 : process.env.XAI_API_KEY);
|
|
47
|
-
const isOAuth = baseCredentials !== void 0 || !staticKey || isOAuthAccessToken(staticKey);
|
|
48
|
-
/**
|
|
49
|
-
* Build the openai-compat delegate for a resolved bearer. Cheap — the factory
|
|
50
|
-
* only wires closures — so we re-create it per turn with the freshly resolved
|
|
51
|
-
* (possibly refreshed) OAuth token rather than baking a stale key in once.
|
|
52
|
-
*/
|
|
53
|
-
function delegateFor(apiKey) {
|
|
54
|
-
return openaiCompat({
|
|
55
|
-
name: "xai",
|
|
56
|
-
label: "xAI",
|
|
57
|
-
apiKey,
|
|
58
|
-
baseURL,
|
|
59
|
-
defaultModel,
|
|
60
|
-
capabilities,
|
|
61
|
-
extraHeaders: params?.extraHeaders
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
const skeleton = delegateFor("placeholder-resolved-at-stream");
|
|
65
|
-
return {
|
|
66
|
-
...skeleton,
|
|
67
|
-
name: "xai",
|
|
68
|
-
meta: {
|
|
69
|
-
...skeleton.meta,
|
|
70
|
-
defaultModel,
|
|
71
|
-
isOAuth
|
|
72
|
-
},
|
|
73
|
-
async stream(options, callbacks) {
|
|
74
|
-
return delegateFor(await resolveOAuthApiKey({
|
|
75
|
-
provider: "xai",
|
|
76
|
-
providerId: XAI_OAUTH_PROVIDER_ID,
|
|
77
|
-
params: runtimeCredentials ? {
|
|
78
|
-
...params,
|
|
79
|
-
...runtimeCredentials
|
|
80
|
-
} : params,
|
|
81
|
-
envKey: "XAI_API_KEY",
|
|
82
|
-
missingError: "No xAI credentials found. Set XAI_API_KEY or run `bun run auth --xai` first.",
|
|
83
|
-
refreshError: (reason) => `xAI OAuth token refresh failed. Run \`bun run auth --xai\` again. ${reason}`
|
|
84
|
-
}, {
|
|
85
|
-
...callbacks,
|
|
86
|
-
async onOAuthRefresh(ctx) {
|
|
87
|
-
if (ctx.source === "params") runtimeCredentials = {
|
|
88
|
-
access: ctx.credentials.access,
|
|
89
|
-
refresh: ctx.credentials.refresh,
|
|
90
|
-
expires: ctx.credentials.expires
|
|
91
|
-
};
|
|
92
|
-
await callbacks.onOAuthRefresh?.(ctx);
|
|
93
|
-
}
|
|
94
|
-
})).stream(options, callbacks);
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
//#endregion
|
|
99
|
-
export { xai };
|
|
100
|
-
|
|
101
|
-
//# sourceMappingURL=xai.js.map
|
|
1
|
+
export { t as xai } from "../xai-CStTwCV2.js";
|
package/dist/providers.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { $
|
|
1
|
+
import { $C as ImageData, $S as loadGoogleWireKit, AC as OAuthParams, AS as mistral, Ax as ProviderDecisions, BC as resolveOAuthApiKey, Bx as planZaiReasoning, CS as openai, Cx as HistoryRepair, DC as PromptCacheKeyOption, DS as neuralwatt, Dx as ProviderDecisionAvailability, EC as PromptCacheKeyContext, ES as NeuralwattParams, Ex as ProviderCapabilities, FC as isOAuthAccessToken, Fx as ToolCall, GS as GoogleVertexParams, Gx as SchemaSanitizeProfile, HS as GoogleStreamFn, Hx as XaiParams, IC as pinnedAccountMissingError, IS as GoogleCompatibleRoute, Ix as ToolResult, JC as openrouterImageModels, JS as classifyGoogleError, Jx as sanitizeToolSpecs, KS as GoogleWireKit, Kx as SchemaSanitizeResult, LC as readAccountOAuthCredential, Lx as ToolSpec, MC as credentialsFilePath, MS as LocalParams, Mx as StreamCallbacks, NC as credentialsFromParams, NS as local, Nx as StreamOptions, OC as derivePromptCacheKey, OS as planNeuralwattReasoning, Ox as ProviderDecisionRequest, PC as extractRuntimeCredentials, Px as TokenCountPayload, QC as ImageAspectRatio, QS as googleVertex, Qx as openrouter, RC as readOAuthCredentials, RS as GoogleParams, Rx as TurnResult, SC as applyAnthropicCacheBreakpoints, TC as AnthropicParams, TS as NEURALWATT_DEFAULT_MODEL, Tx as Provider, US as GoogleStreamOptions, Ux as xai, VC as writeOAuthCredentials, VS as GoogleSharedParams, Vx as zai, WS as GoogleStreams, Wx as SchemaSanitizeOptions, XC as GOOGLE_IMAGE_MODELS, XS as google, Xx as OpenRouterParams, YC as OPENAI_IMAGE_MODELS, ZC as IMAGE_ASPECT_RATIOS, ZS as googleCompatible, aC as CerebrasParams, aO as ModelCatalog, aw as ProviderImages, bS as OpenAIParams, cC as baseten, cO as ModelTier, dC as arcee, ew as ImageModelInfo, fC as anthropic, fS as mapOAIFinishReason, iC as cursor, iS as OpenAICompatParams, iw as ProviderImageResponse, jC as ResolveOAuthApiKeyOptions, jS as planMistralReasoning, jx as ProviderMeta, kC as resolvePromptCacheKey, kS as MistralParams, kx as ProviderDecisionResponse, lC as planBasetenReasoning, lO as getModelCatalog, mS as openaiCompat, nS as OpenAICompatAuthHeader, nw as ProviderImageAvailability, oC as cerebras, oO as ModelCatalogEntry, qC as XAI_IMAGE_MODELS, qS as GoogleWireModel, qx as sanitizeToolSchema, rC as CursorParams, rS as OpenAICompatHttpError, rw as ProviderImageRequest, sC as BasetenParams, sO as ModelCatalogSource, tw as MAX_IMAGES_PER_REQUEST, uC as ArceeParams, uO as setModelCatalog, uS as classifyOpenAICompatError, wx as InputTransformation, zC as registerCustomOAuthProvider, zS as GoogleRequestAuth, zx as ZaiParams } from "./index-DyQyDLX1.js";
|
|
2
2
|
import { a as getOAuthApiKey, c as refreshOpenAICodexToken, i as ensureBundledOAuthFlows, l as registerOAuthProvider, o as getOAuthProvider, r as OAuthProviderInterface, s as refreshAnthropicToken } from "./oauth-callback-page-B3Xo3X2J.js";
|
|
3
|
-
export { type AnthropicParams, type ArceeParams, type BasetenParams, type CerebrasParams, type CursorParams, type GoogleCompatibleRoute, type GoogleParams, type GoogleRequestAuth, type GoogleSharedParams, type GoogleStreamFn, type GoogleStreamOptions, type GoogleStreams, type GoogleVertexParams, type GoogleWireKit, type GoogleWireModel, HistoryRepair, InputTransformation, type LocalParams, type MistralParams, type ModelCatalog, type ModelCatalogEntry, type ModelCatalogSource, type ModelTier, NEURALWATT_DEFAULT_MODEL, type NeuralwattParams, type OAuthParams, type OAuthProviderInterface, type OpenAICompatAuthHeader, OpenAICompatHttpError, type OpenAICompatParams, type OpenAIParams, type OpenRouterParams, type PromptCacheKeyContext, type PromptCacheKeyOption, Provider, ProviderCapabilities, ProviderDecisionAvailability, ProviderDecisionRequest, ProviderDecisionResponse, ProviderDecisions, 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, classifyGoogleError, classifyOpenAICompatError, credentialsFilePath, credentialsFromParams, cursor, derivePromptCacheKey, ensureBundledOAuthFlows, extractRuntimeCredentials, getModelCatalog, getOAuthApiKey, getOAuthProvider, google, googleCompatible, googleVertex, isOAuthAccessToken, loadGoogleWireKit, local, mapOAIFinishReason, mistral, neuralwatt, openai, openaiCompat, openrouter, pinnedAccountMissingError, planBasetenReasoning, planMistralReasoning, planNeuralwattReasoning, planZaiReasoning, readAccountOAuthCredential, readOAuthCredentials, refreshAnthropicToken, refreshOpenAICodexToken, registerCustomOAuthProvider, registerOAuthProvider, resolveOAuthApiKey, resolvePromptCacheKey, sanitizeToolSchema, sanitizeToolSpecs, setModelCatalog, writeOAuthCredentials, xai, zai };
|
|
3
|
+
export { type AnthropicParams, type ArceeParams, type BasetenParams, type CerebrasParams, type CursorParams, GOOGLE_IMAGE_MODELS, type GoogleCompatibleRoute, type GoogleParams, type GoogleRequestAuth, type GoogleSharedParams, type GoogleStreamFn, type GoogleStreamOptions, type GoogleStreams, type GoogleVertexParams, type GoogleWireKit, type GoogleWireModel, HistoryRepair, IMAGE_ASPECT_RATIOS, type ImageAspectRatio, type ImageData, type ImageModelInfo, InputTransformation, type LocalParams, MAX_IMAGES_PER_REQUEST, type MistralParams, type ModelCatalog, type ModelCatalogEntry, type ModelCatalogSource, type ModelTier, NEURALWATT_DEFAULT_MODEL, type NeuralwattParams, type OAuthParams, type OAuthProviderInterface, OPENAI_IMAGE_MODELS, type OpenAICompatAuthHeader, OpenAICompatHttpError, type OpenAICompatParams, type OpenAIParams, type OpenRouterParams, type PromptCacheKeyContext, type PromptCacheKeyOption, Provider, ProviderCapabilities, ProviderDecisionAvailability, ProviderDecisionRequest, ProviderDecisionResponse, ProviderDecisions, type ProviderImageAvailability, type ProviderImageRequest, type ProviderImageResponse, type ProviderImages, ProviderMeta, type ResolveOAuthApiKeyOptions, type SchemaSanitizeOptions, type SchemaSanitizeProfile, type SchemaSanitizeResult, StreamCallbacks, StreamOptions, TokenCountPayload, ToolCall, ToolResult, ToolSpec, TurnResult, XAI_IMAGE_MODELS, type XaiParams, type ZaiParams, anthropic, applyAnthropicCacheBreakpoints, arcee, baseten, cerebras, classifyGoogleError, classifyOpenAICompatError, credentialsFilePath, credentialsFromParams, cursor, derivePromptCacheKey, ensureBundledOAuthFlows, extractRuntimeCredentials, getModelCatalog, getOAuthApiKey, getOAuthProvider, google, googleCompatible, googleVertex, isOAuthAccessToken, loadGoogleWireKit, local, mapOAIFinishReason, mistral, neuralwatt, openai, openaiCompat, openrouter, openrouterImageModels, pinnedAccountMissingError, planBasetenReasoning, planMistralReasoning, planNeuralwattReasoning, planZaiReasoning, readAccountOAuthCredential, readOAuthCredentials, refreshAnthropicToken, refreshOpenAICodexToken, registerCustomOAuthProvider, registerOAuthProvider, resolveOAuthApiKey, resolvePromptCacheKey, sanitizeToolSchema, sanitizeToolSpecs, setModelCatalog, writeOAuthCredentials, xai, zai };
|
package/dist/providers.js
CHANGED
|
@@ -6,10 +6,11 @@ import { arcee } from "./providers/arcee.js";
|
|
|
6
6
|
import { baseten, planBasetenReasoning } from "./providers/baseten.js";
|
|
7
7
|
import { cerebras } from "./providers/cerebras.js";
|
|
8
8
|
import { a as cursor, i as planMistralReasoning, n as zai, r as mistral, t as planZaiReasoning } from "./providers-CYuhNshA.js";
|
|
9
|
-
import {
|
|
9
|
+
import { n as MAX_IMAGES_PER_REQUEST, t as IMAGE_ASPECT_RATIOS } from "./types-JzccL5GE.js";
|
|
10
|
+
import { a as google, c as loadGoogleWireKit, f as GOOGLE_IMAGE_MODELS, o as googleCompatible, r as classifyGoogleError, s as googleVertex } from "./google-O6pRnddf.js";
|
|
11
|
+
import { o as OPENAI_IMAGE_MODELS, r as openai } from "./openai-Rh6u5NXF.js";
|
|
12
|
+
import { a as openrouterImageModels, r as openrouter } from "./openrouter-Dg0yaI-o.js";
|
|
13
|
+
import { n as XAI_IMAGE_MODELS, t as xai } from "./xai-CStTwCV2.js";
|
|
10
14
|
import { local } from "./providers/local.js";
|
|
11
15
|
import { NEURALWATT_DEFAULT_MODEL, neuralwatt, planNeuralwattReasoning } from "./providers/neuralwatt.js";
|
|
12
|
-
|
|
13
|
-
import { r as openrouter } from "./openrouter-CtZbQDa0.js";
|
|
14
|
-
import { xai } from "./providers/xai.js";
|
|
15
|
-
export { NEURALWATT_DEFAULT_MODEL, OpenAICompatHttpError, anthropic, applyAnthropicCacheBreakpoints, arcee, baseten, cerebras, classifyGoogleError, classifyOpenAICompatError, credentialsFilePath, credentialsFromParams, cursor, derivePromptCacheKey, ensureBundledOAuthFlows, extractRuntimeCredentials, getModelCatalog, getOAuthApiKey, getOAuthProvider, google, googleCompatible, googleVertex, isOAuthAccessToken, loadGoogleWireKit, local, mapOAIFinishReason, mistral, neuralwatt, openai, openaiCompat, openrouter, pinnedAccountMissingError, planBasetenReasoning, planMistralReasoning, planNeuralwattReasoning, planZaiReasoning, readAccountOAuthCredential, readOAuthCredentials, refreshAnthropicToken, refreshOpenAICodexToken, registerCustomOAuthProvider, registerOAuthProvider, resolveOAuthApiKey, resolvePromptCacheKey, sanitizeToolSchema, sanitizeToolSpecs, setModelCatalog, writeOAuthCredentials, xai, zai };
|
|
16
|
+
export { GOOGLE_IMAGE_MODELS, IMAGE_ASPECT_RATIOS, MAX_IMAGES_PER_REQUEST, NEURALWATT_DEFAULT_MODEL, OPENAI_IMAGE_MODELS, OpenAICompatHttpError, XAI_IMAGE_MODELS, anthropic, applyAnthropicCacheBreakpoints, arcee, baseten, cerebras, classifyGoogleError, classifyOpenAICompatError, credentialsFilePath, credentialsFromParams, cursor, derivePromptCacheKey, ensureBundledOAuthFlows, extractRuntimeCredentials, getModelCatalog, getOAuthApiKey, getOAuthProvider, google, googleCompatible, googleVertex, isOAuthAccessToken, loadGoogleWireKit, local, mapOAIFinishReason, mistral, neuralwatt, openai, openaiCompat, openrouter, openrouterImageModels, pinnedAccountMissingError, planBasetenReasoning, planMistralReasoning, planNeuralwattReasoning, planZaiReasoning, readAccountOAuthCredential, readOAuthCredentials, refreshAnthropicToken, refreshOpenAICodexToken, registerCustomOAuthProvider, registerOAuthProvider, resolveOAuthApiKey, resolvePromptCacheKey, sanitizeToolSchema, sanitizeToolSpecs, setModelCatalog, writeOAuthCredentials, xai, zai };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as writeJsonFileAtomic, t as OWNER_ONLY } from "./atomic-write-Ijgf2Mhc.js";
|
|
2
|
-
import { _ as writeCredentialEntry, a as readCredentialEntry } from "./credentials-
|
|
2
|
+
import { _ as writeCredentialEntry, a as readCredentialEntry } from "./credentials-B9DfBJP9.js";
|
|
3
3
|
import { t as HostRegistryError } from "./types-CiUp8oom.js";
|
|
4
|
-
import { i as urlCarriesSecrets, n as displayHostUrl, r as parseRemoteHostUrl, t as RemoteHostError } from "./url-
|
|
4
|
+
import { i as urlCarriesSecrets, n as displayHostUrl, r as parseRemoteHostUrl, t as RemoteHostError } from "./url-D8KZ7Edw.js";
|
|
5
5
|
import { existsSync, readFileSync } from "node:fs";
|
|
6
6
|
import { resolve } from "node:path";
|
|
7
7
|
//#region src/chat/hosts/registry.ts
|
|
@@ -218,4 +218,4 @@ function createHostRegistry(options) {
|
|
|
218
218
|
//#endregion
|
|
219
219
|
export { probeUnsavedHost as i, hostCredentialKey as n, hostsFilePath as r, createHostRegistry as t };
|
|
220
220
|
|
|
221
|
-
//# sourceMappingURL=registry-
|
|
221
|
+
//# sourceMappingURL=registry-eourRLY2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry-BBaEgTsX.js","names":[],"sources":["../src/chat/hosts/registry.ts"],"sourcesContent":["/**\n * The client's saved hosts: `<dataDir>/hosts.json` (0600, atomic writes) for\n * the entries, the credentials store (`credentials.json`, entry\n * `hosts:<id>`) for their tokens, so tokens sit with every other secret and\n * never in the listable file.\n *\n * Every call reads the files fresh: TUI and GUI windows on one machine share\n * them. Connecting is injected (`probe`): `src/chat` cannot reach the\n * WebSocket client, `createWsHostRegistry` (`zidane/ipc`) wires it.\n */\nimport type { HostEntry, HostProbe, HostProbeResult, HostTestResult } from './types'\nimport { existsSync, readFileSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport { OWNER_ONLY, writeJsonFileAtomic } from '../../atomic-write'\nimport { readCredentialEntry, writeCredentialEntry } from '../credentials'\nimport { HostRegistryError } from './types'\nimport { displayHostUrl, parseRemoteHostUrl, RemoteHostError, urlCarriesSecrets } from './url'\n\nconst FILE_VERSION = 1\n\ninterface HostsFile {\n version: typeof FILE_VERSION\n hosts: HostEntry[]\n}\n\n/**\n * Returns the path of the file that stores the saved hosts.\n *\n * @param dataDir - Application data directory.\n */\nexport function hostsFilePath(dataDir: string): string {\n return resolve(dataDir, 'hosts.json')\n}\n\n/**\n * Where a host's token lives in the credentials store.\n *\n * @param id - Host id.\n */\nexport function hostCredentialKey(id: string): string {\n return `hosts:${id}`\n}\n\n/** Saved remote hosts and their tokens, persisted under the data directory. */\nexport interface HostRegistry {\n /** Returns every saved host. */\n list: () => HostEntry[]\n /** Returns the saved host with this id, or `undefined`. */\n get: (id: string) => HostEntry | undefined\n /**\n * Verify the host (it must answer as a zidane-server with this token),\n * then save it and its token. Adding a host already saved (same server\n * id) updates its URL and token in place, keeping its name unless one is\n * given. Throws {@link HostRegistryError}.\n */\n add: (input: { url: string, token: string, name?: string }) => Promise<HostEntry>\n /** Forget the entry and its token; `false` when it wasn't saved. */\n remove: (id: string) => boolean\n /** Renames a saved host. Throws {@link HostRegistryError} for an empty name, or when no saved host has this id. */\n rename: (id: string, name: string) => HostEntry\n /** Connect with the saved token and say who answered; refreshes `lastConnectedAt` on success. */\n test: (id: string) => Promise<HostTestResult>\n /** The saved token, for transports. Never display it. */\n token: (id: string) => string | undefined\n}\n\nfunction isEntry(value: unknown): value is HostEntry {\n const e = value as Partial<HostEntry> | null\n return !!e && typeof e === 'object' && typeof e.id === 'string' && typeof e.name === 'string' && typeof e.url === 'string' && typeof e.addedAt === 'number'\n}\n\n/** An entry saved before URLs were checked for credentials: read without them (it fails auth, the user re-adds it). */\nfunction withoutUrlSecrets(entry: HostEntry): HostEntry {\n const raw = entry.url\n return urlCarriesSecrets(raw) ? { ...entry, url: displayHostUrl(raw) } : entry\n}\n\nfunction readHosts(dataDir: string): HostEntry[] {\n const path = hostsFilePath(dataDir)\n if (!existsSync(path))\n return []\n try {\n const parsed = JSON.parse(readFileSync(path, 'utf8')) as Partial<HostsFile>\n return Array.isArray(parsed.hosts) ? parsed.hosts.filter(isEntry).map(withoutUrlSecrets) : []\n }\n catch {\n return []\n }\n}\n\nfunction writeHosts(dataDir: string, hosts: HostEntry[]): void {\n const file: HostsFile = { version: FILE_VERSION, hosts }\n writeJsonFileAtomic(hostsFilePath(dataDir), file, OWNER_ONLY)\n}\n\nfunction cleanName(name: string): string {\n const trimmed = name.trim()\n if (!trimmed)\n throw new HostRegistryError('invalid-name', 'A host needs a name.')\n return trimmed\n}\n\nfunction checkedUrl(raw: string): string {\n try {\n return parseRemoteHostUrl(raw)\n }\n catch (err) {\n throw new HostRegistryError('invalid-url', err instanceof RemoteHostError ? err.message : String(err))\n }\n}\n\n/** The URL and token an `add` (or an unsaved test) takes, checked; throws {@link HostRegistryError}. */\nexport function checkHostInput(input: { url: string, token: string }): { url: string, token: string } {\n const url = checkedUrl(input.url)\n const token = input.token.trim()\n if (!token)\n throw new HostRegistryError('invalid-token', 'A host needs a token (zidane server token create --name <device>).')\n return { url, token }\n}\n\n/** A probe's answer, refused unless a zidane-server answered. */\nfunction asServer(url: string, probed: HostProbeResult): HostProbeResult {\n if (probed.ok && probed.hostRef.kind !== 'server')\n return { ok: false, error: 'protocol', message: `${url} is a ${probed.hostRef.kind} host, not a zidane-server.` }\n return probed\n}\n\n/** The add form's \"test\": `add`'s checks and probe, saving nothing. A refused input or a failed probe comes back as an error result, not a throw. */\nexport async function probeUnsavedHost(probe: HostProbe, input: { url: string, token: string }): Promise<HostProbeResult> {\n let checked: { url: string, token: string }\n try {\n checked = checkHostInput(input)\n }\n catch (err) {\n if (err instanceof HostRegistryError)\n return { ok: false, error: err.code, message: err.message }\n throw err\n }\n return asServer(checked.url, await probe(checked))\n}\n\n/**\n * Creates a host registry backed by `hosts.json` and the credentials store in `options.dataDir`.\n *\n * @param options - Where to store hosts (`dataDir`), how to reach a host (`probe`), and an optional clock (`now`, default `Date.now`).\n * @example\n * ```ts\n * import { createHostRegistry } from 'zidane/chat'\n *\n * const hosts = createHostRegistry({\n * dataDir: '/home/me/.zidane',\n * probe: async () => ({ ok: false, error: 'unreachable', message: 'No transport wired.' }),\n * })\n * console.log(hosts.list())\n * ```\n */\nexport function createHostRegistry(options: { dataDir: string, probe: HostProbe, now?: () => number }): HostRegistry {\n const { dataDir, probe } = options\n const now = options.now ?? Date.now\n const list = (): HostEntry[] => readHosts(dataDir)\n const get = (id: string): HostEntry | undefined => list().find(h => h.id === id)\n const token = (id: string): string | undefined => {\n const cred = readCredentialEntry(dataDir, hostCredentialKey(id))\n return cred?.kind === 'apikey' && cred.value ? cred.value : undefined\n }\n const update = (id: string, patch: (entry: HostEntry) => HostEntry): HostEntry | undefined => {\n const hosts = list()\n const i = hosts.findIndex(h => h.id === id)\n if (i < 0)\n return undefined\n hosts[i] = patch(hosts[i]!)\n writeHosts(dataDir, hosts)\n return hosts[i]\n }\n\n return {\n list,\n get,\n token,\n async add(input) {\n const { url, token: secret } = checkHostInput(input)\n const name = input.name === undefined ? undefined : cleanName(input.name)\n const probed = asServer(url, await probe({ url, token: secret }))\n if (!probed.ok)\n throw new HostRegistryError(probed.error, probed.message)\n const at = now()\n const fresh: Pick<HostEntry, 'url' | 'lastConnectedAt' | 'hostKind' | 'serverName' | 'serverVersion'> = {\n url,\n lastConnectedAt: at,\n hostKind: 'server',\n serverName: probed.hostRef.name,\n ...(probed.serverVersion !== undefined ? { serverVersion: probed.serverVersion } : {}),\n }\n const id = probed.hostRef.id\n // Token first: an entry is never saved without its token.\n writeCredentialEntry(dataDir, hostCredentialKey(id), { kind: 'apikey', value: secret })\n const hosts = list()\n const existing = hosts.find(h => h.id === id)\n const entry: HostEntry = existing\n ? { ...existing, ...fresh, ...(name !== undefined ? { name } : {}) }\n : { id, name: name ?? probed.hostRef.name, addedAt: at, ...fresh }\n writeHosts(dataDir, existing ? hosts.map(h => (h.id === id ? entry : h)) : [...hosts, entry])\n return entry\n },\n remove(id) {\n const hosts = list()\n const kept = hosts.filter(h => h.id !== id)\n const had = kept.length !== hosts.length\n if (had)\n writeHosts(dataDir, kept)\n const hadToken = token(id) !== undefined\n writeCredentialEntry(dataDir, hostCredentialKey(id), undefined)\n return had || hadToken\n },\n rename(id, name) {\n const clean = cleanName(name)\n const entry = update(id, e => ({ ...e, name: clean }))\n if (!entry)\n throw new HostRegistryError('unknown-host', `No host \"${id}\".`)\n return entry\n },\n async test(id) {\n const entry = get(id)\n const secret = entry ? token(id) : undefined\n if (!entry || secret === undefined)\n return { ok: false, error: 'unknown-host', message: entry ? `No token saved for \"${entry.name}\": add it again.` : `No host \"${id}\".` }\n const probed = await probe({ url: entry.url, token: secret })\n if (!probed.ok)\n return probed\n if (probed.hostRef.id !== entry.id)\n return { ok: false, error: 'identity', message: `A different host (\"${probed.hostRef.name}\") answers at ${entry.url}. Remove \"${entry.name}\" and add it again if it was reinstalled.` }\n update(id, e => ({\n ...e,\n lastConnectedAt: now(),\n serverName: probed.hostRef.name,\n ...(probed.serverVersion !== undefined ? { serverVersion: probed.serverVersion } : {}),\n }))\n return probed\n },\n }\n}\n"],"mappings":";;;;;;;AAkBA,MAAM,eAAe;;;;;;AAYrB,SAAgB,cAAc,SAAyB;CACrD,OAAO,QAAQ,SAAS,YAAY;AACtC;;;;;;AAOA,SAAgB,kBAAkB,IAAoB;CACpD,OAAO,SAAS;AAClB;AAyBA,SAAS,QAAQ,OAAoC;CACnD,MAAM,IAAI;CACV,OAAO,CAAC,CAAC,KAAK,OAAO,MAAM,YAAY,OAAO,EAAE,OAAO,YAAY,OAAO,EAAE,SAAS,YAAY,OAAO,EAAE,QAAQ,YAAY,OAAO,EAAE,YAAY;AACrJ;;AAGA,SAAS,kBAAkB,OAA6B;CACtD,MAAM,MAAM,MAAM;CAClB,OAAO,kBAAkB,GAAG,IAAI;EAAE,GAAG;EAAO,KAAK,eAAe,GAAG;CAAE,IAAI;AAC3E;AAEA,SAAS,UAAU,SAA8B;CAC/C,MAAM,OAAO,cAAc,OAAO;CAClC,IAAI,CAAC,WAAW,IAAI,GAClB,OAAO,CAAC;CACV,IAAI;EACF,MAAM,SAAS,KAAK,MAAM,aAAa,MAAM,MAAM,CAAC;EACpD,OAAO,MAAM,QAAQ,OAAO,KAAK,IAAI,OAAO,MAAM,OAAO,OAAO,CAAC,CAAC,IAAI,iBAAiB,IAAI,CAAC;CAC9F,QACM;EACJ,OAAO,CAAC;CACV;AACF;AAEA,SAAS,WAAW,SAAiB,OAA0B;CAC7D,MAAM,OAAkB;EAAE,SAAS;EAAc;CAAM;CACvD,oBAAoB,cAAc,OAAO,GAAG,MAAM,UAAU;AAC9D;AAEA,SAAS,UAAU,MAAsB;CACvC,MAAM,UAAU,KAAK,KAAK;CAC1B,IAAI,CAAC,SACH,MAAM,IAAI,kBAAkB,gBAAgB,sBAAsB;CACpE,OAAO;AACT;AAEA,SAAS,WAAW,KAAqB;CACvC,IAAI;EACF,OAAO,mBAAmB,GAAG;CA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AAM,KAAK,WAAW,MAAM;GAClC,IAAI,KACF,WAAW,SAAS,IAAI;GAC1B,MAAM,WAAW,MAAM,EAAE,MAAM,KAAA;GAC/B,qBAAqB,SAAS,kBAAkB,EAAE,GAAG,KAAA,CAAS;GAC9D,OAAO,OAAO;EAChB;EACA,OAAO,IAAI,MAAM;GACf,MAAM,QAAQ,UAAU,IAAI;GAC5B,MAAM,QAAQ,OAAO,KAAI,OAAM;IAAE,GAAG;IAAG,MAAM;GAAM,EAAE;GACrD,IAAI,CAAC,OACH,MAAM,IAAI,kBAAkB,gBAAgB,YAAY,GAAG,GAAG;GAChE,OAAO;EACT;EACA,MAAM,KAAK,IAAI;GACb,MAAM,QAAQ,IAAI,EAAE;GACpB,MAAM,SAAS,QAAQ,MAAM,EAAE,IAAI,KAAA;GACnC,IAAI,CAAC,SAAS,WAAW,KAAA,GACvB,OAAO;IAAE,IAAI;IAAO,OAAO;IAAgB,SAAS,QAAQ,uBAAuB,MAAM,KAAK,oBAAoB,YAAY,GAAG;GAAI;GACvI,MAAM,SAAS,MAAM,MAAM;IAAE,KAAK,MAAM;IAAK,OAAO;GAAO,CAAC;GAC5D,IAAI,CAAC,OAAO,IACV,OAAO;GACT,IAAI,OAAO,QAAQ,OAAO,MAAM,IAC9B,OAAO;IAAE,IAAI;IAAO,OAAO;IAAY,SAAS,sBAAsB,OAAO,QAAQ,KAAK,gBAAgB,MAAM,IAAI,YAAY,MAAM,KAAK;GAA2C;GACxL,OAAO,KAAI,OAAM;IACf,GAAG;IACH,iBAAiB,IAAI;IACrB,YAAY,OAAO,QAAQ;IAC3B,GAAI,OAAO,kBAAkB,KAAA,IAAY,EAAE,eAAe,OAAO,cAAc,IAAI,CAAC;GACtF,EAAE;GACF,OAAO;EACT;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"registry-eourRLY2.js","names":[],"sources":["../src/chat/hosts/registry.ts"],"sourcesContent":["/**\n * The client's saved hosts: `<dataDir>/hosts.json` (0600, atomic writes) for\n * the entries, the credentials store (`credentials.json`, entry\n * `hosts:<id>`) for their tokens, so tokens sit with every other secret and\n * never in the listable file.\n *\n * Every call reads the files fresh: TUI and GUI windows on one machine share\n * them. Connecting is injected (`probe`): `src/chat` cannot reach the\n * WebSocket client, `createWsHostRegistry` (`zidane/ipc`) wires it.\n */\nimport type { HostEntry, HostProbe, HostProbeResult, HostTestResult } from './types'\nimport { existsSync, readFileSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport { OWNER_ONLY, writeJsonFileAtomic } from '../../atomic-write'\nimport { readCredentialEntry, writeCredentialEntry } from '../credentials'\nimport { HostRegistryError } from './types'\nimport { displayHostUrl, parseRemoteHostUrl, RemoteHostError, urlCarriesSecrets } from './url'\n\nconst FILE_VERSION = 1\n\ninterface HostsFile {\n version: typeof FILE_VERSION\n hosts: HostEntry[]\n}\n\n/**\n * Returns the path of the file that stores the saved hosts.\n *\n * @param dataDir - Application data directory.\n */\nexport function hostsFilePath(dataDir: string): string {\n return resolve(dataDir, 'hosts.json')\n}\n\n/**\n * Where a host's token lives in the credentials store.\n *\n * @param id - Host id.\n */\nexport function hostCredentialKey(id: string): string {\n return `hosts:${id}`\n}\n\n/** Saved remote hosts and their tokens, persisted under the data directory. */\nexport interface HostRegistry {\n /** Returns every saved host. */\n list: () => HostEntry[]\n /** Returns the saved host with this id, or `undefined`. */\n get: (id: string) => HostEntry | undefined\n /**\n * Verify the host (it must answer as a zidane-server with this token),\n * then save it and its token. Adding a host already saved (same server\n * id) updates its URL and token in place, keeping its name unless one is\n * given. Throws {@link HostRegistryError}.\n */\n add: (input: { url: string, token: string, name?: string }) => Promise<HostEntry>\n /** Forget the entry and its token; `false` when it wasn't saved. */\n remove: (id: string) => boolean\n /** Renames a saved host. Throws {@link HostRegistryError} for an empty name, or when no saved host has this id. */\n rename: (id: string, name: string) => HostEntry\n /** Connect with the saved token and say who answered; refreshes `lastConnectedAt` on success. */\n test: (id: string) => Promise<HostTestResult>\n /** The saved token, for transports. Never display it. */\n token: (id: string) => string | undefined\n}\n\nfunction isEntry(value: unknown): value is HostEntry {\n const e = value as Partial<HostEntry> | null\n return !!e && typeof e === 'object' && typeof e.id === 'string' && typeof e.name === 'string' && typeof e.url === 'string' && typeof e.addedAt === 'number'\n}\n\n/** An entry saved before URLs were checked for credentials: read without them (it fails auth, the user re-adds it). */\nfunction withoutUrlSecrets(entry: HostEntry): HostEntry {\n const raw = entry.url\n return urlCarriesSecrets(raw) ? { ...entry, url: displayHostUrl(raw) } : entry\n}\n\nfunction readHosts(dataDir: string): HostEntry[] {\n const path = hostsFilePath(dataDir)\n if (!existsSync(path))\n return []\n try {\n const parsed = JSON.parse(readFileSync(path, 'utf8')) as Partial<HostsFile>\n return Array.isArray(parsed.hosts) ? parsed.hosts.filter(isEntry).map(withoutUrlSecrets) : []\n }\n catch {\n return []\n }\n}\n\nfunction writeHosts(dataDir: string, hosts: HostEntry[]): void {\n const file: HostsFile = { version: FILE_VERSION, hosts }\n writeJsonFileAtomic(hostsFilePath(dataDir), file, OWNER_ONLY)\n}\n\nfunction cleanName(name: string): string {\n const trimmed = name.trim()\n if (!trimmed)\n throw new HostRegistryError('invalid-name', 'A host needs a name.')\n return trimmed\n}\n\nfunction checkedUrl(raw: string): string {\n try {\n return parseRemoteHostUrl(raw)\n }\n catch (err) {\n throw new HostRegistryError('invalid-url', err instanceof RemoteHostError ? err.message : String(err))\n }\n}\n\n/** The URL and token an `add` (or an unsaved test) takes, checked; throws {@link HostRegistryError}. */\nexport function checkHostInput(input: { url: string, token: string }): { url: string, token: string } {\n const url = checkedUrl(input.url)\n const token = input.token.trim()\n if (!token)\n throw new HostRegistryError('invalid-token', 'A host needs a token (zidane server token create --name <device>).')\n return { url, token }\n}\n\n/** A probe's answer, refused unless a zidane-server answered. */\nfunction asServer(url: string, probed: HostProbeResult): HostProbeResult {\n if (probed.ok && probed.hostRef.kind !== 'server')\n return { ok: false, error: 'protocol', message: `${url} is a ${probed.hostRef.kind} host, not a zidane-server.` }\n return probed\n}\n\n/** The add form's \"test\": `add`'s checks and probe, saving nothing. A refused input or a failed probe comes back as an error result, not a throw. */\nexport async function probeUnsavedHost(probe: HostProbe, input: { url: string, token: string }): Promise<HostProbeResult> {\n let checked: { url: string, token: string }\n try {\n checked = checkHostInput(input)\n }\n catch (err) {\n if (err instanceof HostRegistryError)\n return { ok: false, error: err.code, message: err.message }\n throw err\n }\n return asServer(checked.url, await probe(checked))\n}\n\n/**\n * Creates a host registry backed by `hosts.json` and the credentials store in `options.dataDir`.\n *\n * @param options - Where to store hosts (`dataDir`), how to reach a host (`probe`), and an optional clock (`now`, default `Date.now`).\n * @example\n * ```ts\n * import { createHostRegistry } from 'zidane/chat'\n *\n * const hosts = createHostRegistry({\n * dataDir: '/home/me/.zidane',\n * probe: async () => ({ ok: false, error: 'unreachable', message: 'No transport wired.' }),\n * })\n * console.log(hosts.list())\n * ```\n */\nexport function createHostRegistry(options: { dataDir: string, probe: HostProbe, now?: () => number }): HostRegistry {\n const { dataDir, probe } = options\n const now = options.now ?? Date.now\n const list = (): HostEntry[] => readHosts(dataDir)\n const get = (id: string): HostEntry | undefined => list().find(h => h.id === id)\n const token = (id: string): string | undefined => {\n const cred = readCredentialEntry(dataDir, hostCredentialKey(id))\n return cred?.kind === 'apikey' && cred.value ? cred.value : undefined\n }\n const update = (id: string, patch: (entry: HostEntry) => HostEntry): HostEntry | undefined => {\n const hosts = list()\n const i = hosts.findIndex(h => h.id === id)\n if (i < 0)\n return undefined\n hosts[i] = patch(hosts[i]!)\n writeHosts(dataDir, hosts)\n return hosts[i]\n }\n\n return {\n list,\n get,\n token,\n async add(input) {\n const { url, token: secret } = checkHostInput(input)\n const name = input.name === undefined ? undefined : cleanName(input.name)\n const probed = asServer(url, await probe({ url, token: secret }))\n if (!probed.ok)\n throw new HostRegistryError(probed.error, probed.message)\n const at = now()\n const fresh: Pick<HostEntry, 'url' | 'lastConnectedAt' | 'hostKind' | 'serverName' | 'serverVersion'> = {\n url,\n lastConnectedAt: at,\n hostKind: 'server',\n serverName: probed.hostRef.name,\n ...(probed.serverVersion !== undefined ? { serverVersion: probed.serverVersion } : {}),\n }\n const id = probed.hostRef.id\n // Token first: an entry is never saved without its token.\n writeCredentialEntry(dataDir, hostCredentialKey(id), { kind: 'apikey', value: secret })\n const hosts = list()\n const existing = hosts.find(h => h.id === id)\n const entry: HostEntry = existing\n ? { ...existing, ...fresh, ...(name !== undefined ? { name } : {}) }\n : { id, name: name ?? probed.hostRef.name, addedAt: at, ...fresh }\n writeHosts(dataDir, existing ? hosts.map(h => (h.id === id ? entry : h)) : [...hosts, entry])\n return entry\n },\n remove(id) {\n const hosts = list()\n const kept = hosts.filter(h => h.id !== id)\n const had = kept.length !== hosts.length\n if (had)\n writeHosts(dataDir, kept)\n const hadToken = token(id) !== undefined\n writeCredentialEntry(dataDir, hostCredentialKey(id), undefined)\n return had || hadToken\n },\n rename(id, name) {\n const clean = cleanName(name)\n const entry = update(id, e => ({ ...e, name: clean }))\n if (!entry)\n throw new HostRegistryError('unknown-host', `No host \"${id}\".`)\n return entry\n },\n async test(id) {\n const entry = get(id)\n const secret = entry ? token(id) : undefined\n if (!entry || secret === undefined)\n return { ok: false, error: 'unknown-host', message: entry ? `No token saved for \"${entry.name}\": add it again.` : `No host \"${id}\".` }\n const probed = await probe({ url: entry.url, token: secret })\n if (!probed.ok)\n return probed\n if (probed.hostRef.id !== entry.id)\n return { ok: false, error: 'identity', message: `A different host (\"${probed.hostRef.name}\") answers at ${entry.url}. Remove \"${entry.name}\" and add it again if it was reinstalled.` }\n update(id, e => ({\n ...e,\n lastConnectedAt: now(),\n serverName: probed.hostRef.name,\n ...(probed.serverVersion !== undefined ? { serverVersion: probed.serverVersion } : {}),\n }))\n return probed\n },\n }\n}\n"],"mappings":";;;;;;;AAkBA,MAAM,eAAe;;;;;;AAYrB,SAAgB,cAAc,SAAyB;CACrD,OAAO,QAAQ,SAAS,YAAY;AACtC;;;;;;AAOA,SAAgB,kBAAkB,IAAoB;CACpD,OAAO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,QAAQ,OAAO,KAAI,OAAM;IAAE,GAAG;IAAG,MAAM;GAAM,EAAE;GACrD,IAAI,CAAC,OACH,MAAM,IAAI,kBAAkB,gBAAgB,YAAY,GAAG,GAAG;GAChE,OAAO;EACT;EACA,MAAM,KAAK,IAAI;GACb,MAAM,QAAQ,IAAI,EAAE;GACpB,MAAM,SAAS,QAAQ,MAAM,EAAE,IAAI,KAAA;GACnC,IAAI,CAAC,SAAS,WAAW,KAAA,GACvB,OAAO;IAAE,IAAI;IAAO,OAAO;IAAgB,SAAS,QAAQ,uBAAuB,MAAM,KAAK,oBAAoB,YAAY,GAAG;GAAI;GACvI,MAAM,SAAS,MAAM,MAAM;IAAE,KAAK,MAAM;IAAK,OAAO;GAAO,CAAC;GAC5D,IAAI,CAAC,OAAO,IACV,OAAO;GACT,IAAI,OAAO,QAAQ,OAAO,MAAM,IAC9B,OAAO;IAAE,IAAI;IAAO,OAAO;IAAY,SAAS,sBAAsB,OAAO,QAAQ,KAAK,gBAAgB,MAAM,IAAI,YAAY,MAAM,KAAK;GAA2C;GACxL,OAAO,KAAI,OAAM;IACf,GAAG;IACH,iBAAiB,IAAI;IACrB,YAAY,OAAO,QAAQ;IAC3B,GAAI,OAAO,kBAAkB,KAAA,IAAY,EAAE,eAAe,OAAO,cAAc,IAAI,CAAC;GACtF,EAAE;GACF,OAAO;EACT;CACF;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as createSyncEngine } from "./engine-
|
|
2
|
-
import { r as startWsSavedHosts } from "./ws-
|
|
3
|
-
import { i as wsTransport, t as hostSignalHandlers } from "./host-signals-
|
|
1
|
+
import { t as createSyncEngine } from "./engine-XmoPPB6U.js";
|
|
2
|
+
import { r as startWsSavedHosts } from "./ws-CURQ2igk.js";
|
|
3
|
+
import { i as wsTransport, t as hostSignalHandlers } from "./host-signals-BFudPyCT.js";
|
|
4
4
|
//#region src/tui/host/remote-hosts.ts
|
|
5
5
|
/** The TUI's directory, as the shared saved-hosts sync sees it. */
|
|
6
6
|
function savedHostsDirectory(directory) {
|
|
@@ -95,4 +95,4 @@ function startRemoteHosts(options, registry) {
|
|
|
95
95
|
//#endregion
|
|
96
96
|
export { startRemoteHosts };
|
|
97
97
|
|
|
98
|
-
//# sourceMappingURL=remote-hosts-
|
|
98
|
+
//# sourceMappingURL=remote-hosts-DY2J07ut.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-hosts-
|
|
1
|
+
{"version":3,"file":"remote-hosts-DY2J07ut.js","names":[],"sources":["../src/tui/host/remote-hosts.ts"],"sourcesContent":["/**\n * Saved servers in the window's host directory: loaded only when the\n * `remoteHosts` setting is on (`use-remote-hosts` imports this module\n * dynamically), so a window with it off never reads `hosts.json`, never\n * loads the WebSocket client and never dials anything.\n *\n * The registry ↔ directory sync and the connection loops are the shared\n * ones (`startWsSavedHosts`, `src/ipc/hosts`, the GUI's too); this module is\n * the TUI's glue: a directory entry per server carries a WebSocket\n * transport (the session controllers and session data dial through it),\n * and the server's presence and session changes feed the window.\n */\nimport type { HostEntry, HostRegistry } from '../../chat/hosts'\nimport type { SyncEngine, SyncEngineOptions } from '../../chat/sync/engine'\nimport type { SavedHostsController, SavedHostsDirectory } from '../../ipc/hosts'\nimport type { SessionPresence } from '../../ipc/index'\nimport type { HostDirectory } from './host-directory'\nimport { createSyncEngine } from '../../chat/sync/engine'\nimport { startWsSavedHosts } from '../../ipc/hosts'\nimport { wsTransport } from '../runtime/transport'\nimport { hostSignalHandlers } from './host-signals'\n\nexport interface RemoteHostsOptions {\n dataDir: string\n directory: HostDirectory\n onPresence?: (key: string, rows: readonly SessionPresence[]) => void\n /** A server (re)connected: its sessions can be listed. */\n onConnected?: (key: string) => void\n /** A server's sessions changed (another window created, renamed or deleted one). */\n onSessionsChanged?: (key: string) => void\n /** Settings sync to the saved servers (`src/chat/sync`): this computer's files. Absent: no sync. */\n sync?: Omit<SyncEngineOptions, 'dataDir'>\n}\n\nexport type RemoteHostsController = SavedHostsController & {\n /** Settings sync to each saved server (Settings → Hosts → a server → Sync). */\n sync?: SyncEngine | null\n}\n\n/** The TUI's directory, as the shared saved-hosts sync sees it. */\nfunction savedHostsDirectory(directory: HostDirectory): SavedHostsDirectory {\n return {\n saved: () => directory.servers().filter(host => !host.adHoc).map(host => ({ key: host.key, url: host.url ?? '' })),\n upsert: (entry: HostEntry, token) => {\n // Every dial through it (the connection loop, session data, controllers) checks it is still this server.\n const transport = wsTransport({ url: entry.url, expectHostId: entry.id, ...(token ? { token } : {}) })\n const known = directory.get(entry.id)\n if (known) {\n // In place: the entry (and the sessions routed to it) stays.\n directory.update(entry.id, { name: entry.name, url: entry.url, transport, client: null, status: 'connecting', error: undefined })\n return\n }\n directory.put({\n key: entry.id,\n kind: 'server',\n name: entry.name,\n url: entry.url,\n transport,\n client: null,\n status: 'connecting',\n ...(entry.serverName ? { serverName: entry.serverName } : {}),\n ...(entry.serverVersion ? { serverVersion: entry.serverVersion } : {}),\n })\n },\n update: (key, patch) => directory.update(key, patch),\n remove: key => directory.remove(key),\n }\n}\n\nexport function startRemoteHosts(options: RemoteHostsOptions, registry?: HostRegistry): RemoteHostsController {\n const { directory } = options\n /** `--host` already names this server: its saved entry would be a second connection to it. */\n const adHocUrl = directory.servers().find(host => host.adHoc)?.url\n const sync = options.sync ? createSyncEngine({ dataDir: options.dataDir, ...options.sync }) : null\n const handlers = hostSignalHandlers(options)\n const controller = startWsSavedHosts({\n dataDir: options.dataDir,\n ...(registry ? { registry } : {}),\n directory: savedHostsDirectory(directory),\n skip: entry => entry.url === adHocUrl,\n connect: (entry, _token, attempt) => {\n const host = directory.get(entry.id)\n if (!host)\n return Promise.reject(new Error(`${entry.name} is no longer in this window's hosts.`))\n return host.transport.connect({ appVersion: 'tui-hosts', passive: true, ...attempt })\n },\n onSignal: (key, signal) => {\n handlers.onSignal(key, signal)\n if (signal.kind === 'sync:changed')\n sync?.serverChanged(key)\n },\n onConnected: (key, client) => {\n handlers.onConnected(key, client)\n sync?.connected(key, client)\n },\n onDisconnected: (key) => {\n handlers.onDisconnected(key)\n sync?.disconnected(key)\n },\n })\n return {\n ...controller,\n // Removing a server keeps what it has; this computer stops syncing to it.\n remove: (id) => {\n const removed = controller.remove(id)\n if (removed)\n sync?.removed(id)\n return removed\n },\n stop: () => {\n sync?.stop()\n controller.stop()\n },\n sync,\n }\n}\n"],"mappings":";;;;;AAwCA,SAAS,oBAAoB,WAA+C;CAC1E,OAAO;EACL,aAAa,UAAU,QAAQ,CAAC,CAAC,QAAO,SAAQ,CAAC,KAAK,KAAK,CAAC,CAAC,KAAI,UAAS;GAAE,KAAK,KAAK;GAAK,KAAK,KAAK,OAAO;EAAG,EAAE;EACjH,SAAS,OAAkB,UAAU;GAEnC,MAAM,YAAY,YAAY;IAAE,KAAK,MAAM;IAAK,cAAc,MAAM;IAAI,GAAI,QAAQ,EAAE,MAAM,IAAI,CAAC;GAAG,CAAC;GAErG,IADc,UAAU,IAAI,MAAM,EAC1B,GAAG;IAET,UAAU,OAAO,MAAM,IAAI;KAAE,MAAM,MAAM;KAAM,KAAK,MAAM;KAAK;KAAW,QAAQ;KAAM,QAAQ;KAAc,OAAO,KAAA;IAAU,CAAC;IAChI;GACF;GACA,UAAU,IAAI;IACZ,KAAK,MAAM;IACX,MAAM;IACN,MAAM,MAAM;IACZ,KAAK,MAAM;IACX;IACA,QAAQ;IACR,QAAQ;IACR,GAAI,MAAM,aAAa,EAAE,YAAY,MAAM,WAAW,IAAI,CAAC;IAC3D,GAAI,MAAM,gBAAgB,EAAE,eAAe,MAAM,cAAc,IAAI,CAAC;GACtE,CAAC;EACH;EACA,SAAS,KAAK,UAAU,UAAU,OAAO,KAAK,KAAK;EACnD,SAAQ,QAAO,UAAU,OAAO,GAAG;CACrC;AACF;AAEA,SAAgB,iBAAiB,SAA6B,UAAgD;CAC5G,MAAM,EAAE,cAAc;;CAEtB,MAAM,WAAW,UAAU,QAAQ,CAAC,CAAC,MAAK,SAAQ,KAAK,KAAK,CAAC,EAAE;CAC/D,MAAM,OAAO,QAAQ,OAAO,iBAAiB;EAAE,SAAS,QAAQ;EAAS,GAAG,QAAQ;CAAK,CAAC,IAAI;CAC9F,MAAM,WAAW,mBAAmB,OAAO;CAC3C,MAAM,aAAa,kBAAkB;EACnC,SAAS,QAAQ;EACjB,GAAI,WAAW,EAAE,SAAS,IAAI,CAAC;EAC/B,WAAW,oBAAoB,SAAS;EACxC,OAAM,UAAS,MAAM,QAAQ;EAC7B,UAAU,OAAO,QAAQ,YAAY;GACnC,MAAM,OAAO,UAAU,IAAI,MAAM,EAAE;GACnC,IAAI,CAAC,MACH,OAAO,QAAQ,uBAAO,IAAI,MAAM,GAAG,MAAM,KAAK,sCAAsC,CAAC;GACvF,OAAO,KAAK,UAAU,QAAQ;IAAE,YAAY;IAAa,SAAS;IAAM,GAAG;GAAQ,CAAC;EACtF;EACA,WAAW,KAAK,WAAW;GACzB,SAAS,SAAS,KAAK,MAAM;GAC7B,IAAI,OAAO,SAAS,gBAClB,MAAM,cAAc,GAAG;EAC3B;EACA,cAAc,KAAK,WAAW;GAC5B,SAAS,YAAY,KAAK,MAAM;GAChC,MAAM,UAAU,KAAK,MAAM;EAC7B;EACA,iBAAiB,QAAQ;GACvB,SAAS,eAAe,GAAG;GAC3B,MAAM,aAAa,GAAG;EACxB;CACF,CAAC;CACD,OAAO;EACL,GAAG;EAEH,SAAS,OAAO;GACd,MAAM,UAAU,WAAW,OAAO,EAAE;GACpC,IAAI,SACF,MAAM,QAAQ,EAAE;GAClB,OAAO;EACT;EACA,YAAY;GACV,MAAM,KAAK;GACX,WAAW,KAAK;EAClB;EACA;CACF;AACF"}
|
package/dist/restate.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CT as SessionTurn, Mw as AgentClock, Nx as StreamOptions, PE as SessionStore, PT as ToolBatchExecutor, Pw as AgentStats, QT as ToolDef, RT as ToolResultContent, Tx as Provider, Ua as McpToolMeta, Wa as McpToolWrap, ZT as ToolContext, gE as ToolStateStore, jw as AgentBehavior } from "./index-DyQyDLX1.js";
|
|
2
2
|
import { C as TaskExitInfo, S as TaskEntry, g as ExecutionHandle, p as DetachedTasksCapability } from "./isolation-CbGNAEhQ.js";
|
|
3
3
|
//#region src/restate/types.d.ts
|
|
4
4
|
/**
|
|
@@ -80,6 +80,8 @@ const DEFAULT_SETTINGS = {
|
|
|
80
80
|
importRulerConfigs: true,
|
|
81
81
|
hideSubagentOutput: true,
|
|
82
82
|
subagentModels: true,
|
|
83
|
+
imageGeneration: true,
|
|
84
|
+
imageModel: "",
|
|
83
85
|
maxParallelSubagents: 3,
|
|
84
86
|
queueMessages: true,
|
|
85
87
|
theme: "default",
|
|
@@ -1598,6 +1600,7 @@ const SETTINGS_SECTIONS = [
|
|
|
1598
1600
|
title: "Models",
|
|
1599
1601
|
keys: [
|
|
1600
1602
|
"subagentModels",
|
|
1603
|
+
"imageGeneration",
|
|
1601
1604
|
"resumeOnMaxTokens",
|
|
1602
1605
|
"maxOutputTokens",
|
|
1603
1606
|
"retryMaxAttempts",
|
|
@@ -1745,7 +1748,12 @@ const SETTINGS_KEYWORDS = {
|
|
|
1745
1748
|
"gutter",
|
|
1746
1749
|
"timeline"
|
|
1747
1750
|
],
|
|
1748
|
-
showCacheNotices: [
|
|
1751
|
+
showCacheNotices: [
|
|
1752
|
+
"prompt cache",
|
|
1753
|
+
"cache hit",
|
|
1754
|
+
"reasoning dropped",
|
|
1755
|
+
"thinking dropped"
|
|
1756
|
+
],
|
|
1749
1757
|
showThinking: ["reasoning", "thoughts"],
|
|
1750
1758
|
thinkingAutoExpand: [
|
|
1751
1759
|
"reasoning",
|
|
@@ -2023,6 +2031,12 @@ const SETTINGS_TOGGLES = [
|
|
|
2023
2031
|
label: "Allow subagents to use different models",
|
|
2024
2032
|
description: "Let the agent hand work to cheaper models."
|
|
2025
2033
|
},
|
|
2034
|
+
{
|
|
2035
|
+
category: "agent",
|
|
2036
|
+
key: "imageGeneration",
|
|
2037
|
+
label: "Image generation",
|
|
2038
|
+
description: "Let the agent generate images with your providers' image models. Each image is billed by the provider."
|
|
2039
|
+
},
|
|
2026
2040
|
{
|
|
2027
2041
|
category: "agent",
|
|
2028
2042
|
key: "decisions",
|
|
@@ -2120,7 +2134,7 @@ const SETTINGS_TOGGLES = [
|
|
|
2120
2134
|
category: "ui",
|
|
2121
2135
|
key: "showCacheNotices",
|
|
2122
2136
|
label: "Cache notices",
|
|
2123
|
-
description: "Add a row to the chat when the prompt cache expires or resets."
|
|
2137
|
+
description: "Add a row to the chat when the prompt cache expires or resets, or the provider drops earlier reasoning."
|
|
2124
2138
|
},
|
|
2125
2139
|
{
|
|
2126
2140
|
category: "ui",
|
|
@@ -2891,4 +2905,4 @@ function isSecretPathSegment(segment) {
|
|
|
2891
2905
|
//#endregion
|
|
2892
2906
|
export { SETTINGS_DEFAULTS_VERSION_KEY as A, GRUVBOX_LIGHT as C, CATPPUCCIN_MOCHA as D, CATPPUCCIN_MACCHIATO as E, sparseSettingsUpdate as F, isAllowedBrowserUrl as I, isLocalBrowserUrl as L, decisionsEnabled as M, migrateStoredSettings as N, DEFAULT_SETTINGS as O, settingsFromStored as P, normalizeBrowserUrl as R, GRUVBOX_DARK as S, CATPPUCCIN_LATTE as T, BUILTIN_THEMES as _, APPROVAL_MODE_OPTIONS as a, resolveTheme as b, SETTINGS_INPUTS as c, clampFps as d, enforceSettingsInvariants as f, toggleHeldOn as g, settingsSectionOf as h, looksLikeSecret as i, approvalModeFromSafeMode as j, SETTINGS_DEFAULTS_VERSION as k, SETTINGS_SECTIONS as l, settingKeywords as m, isSecretName as n, SETTINGS_CATEGORIES as o, requirementMet as p, isSecretPathSegment as r, SETTINGS_CHOICES as s, KNOWN_TOKEN as t, SETTINGS_TOGGLES as u, DEFAULT_THEME as v, CATPPUCCIN_FRAPPE as w, VAPORWAVE_THEME as x, resolveChipColor as y };
|
|
2893
2907
|
|
|
2894
|
-
//# sourceMappingURL=secret-shapes-
|
|
2908
|
+
//# sourceMappingURL=secret-shapes-BjW4l6U0.js.map
|