zidane 8.2.2 → 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/chat/pure.d.ts +2 -2
- package/dist/chat/pure.js +6 -6
- package/dist/chat.d.ts +2 -2
- package/dist/chat.js +9 -9
- package/dist/{client-core-BdD20sOv.d.ts → client-core-EEEX_u6D.d.ts} +3 -3
- package/dist/{client-core-BdD20sOv.d.ts.map → client-core-EEEX_u6D.d.ts.map} +1 -1
- package/dist/{connection-loop-DTk82YVl.d.ts → connection-loop-CpgfUmuw.d.ts} +3 -3
- package/dist/{connection-loop-DTk82YVl.d.ts.map → connection-loop-CpgfUmuw.d.ts.map} +1 -1
- package/dist/daemon-cli.js +2 -2
- package/dist/{dispatcher-BICXFGiJ.js → dispatcher-Bv9-c6I2.js} +10 -10
- package/dist/{dispatcher-BICXFGiJ.js.map → dispatcher-Bv9-c6I2.js.map} +1 -1
- package/dist/{engine-QCX3GV-i.js → engine-XmoPPB6U.js} +4 -4
- package/dist/{engine-QCX3GV-i.js.map → engine-XmoPPB6U.js.map} +1 -1
- package/dist/{executor-B8GoXaaE.js → executor-BhthPE1q.js} +3 -3
- package/dist/{executor-B8GoXaaE.js.map → executor-BhthPE1q.js.map} +1 -1
- package/dist/{extensions-BeH3D-bq.js → extensions-BgBwogRW.js} +2 -2
- package/dist/{extensions-BeH3D-bq.js.map → extensions-BgBwogRW.js.map} +1 -1
- package/dist/extensions.js +1 -1
- package/dist/{host-scoped-settings-CCnaBkCV.js → host-scoped-settings-C-Nmb6vr.js} +2 -2
- package/dist/{host-scoped-settings-CCnaBkCV.js.map → host-scoped-settings-C-Nmb6vr.js.map} +1 -1
- package/dist/{host-signals-DI9JQvR9.js → host-signals-BFudPyCT.js} +5 -5
- package/dist/{host-signals-DI9JQvR9.js.map → host-signals-BFudPyCT.js.map} +1 -1
- package/dist/{index-BkNeiJYI.d.ts → index-AqRZ3gEz.d.ts} +2 -2
- package/dist/{index-BkNeiJYI.d.ts.map → index-AqRZ3gEz.d.ts.map} +1 -1
- package/dist/{index-lcuvhQfF.d.ts → index-CDS7YdUC.d.ts} +4 -4
- package/dist/{index-lcuvhQfF.d.ts.map → index-CDS7YdUC.d.ts.map} +1 -1
- package/dist/index.js +1 -1
- package/dist/ipc/remote.d.ts +4 -4
- package/dist/ipc/remote.js +3 -3
- package/dist/ipc.d.ts +4 -4
- package/dist/ipc.js +7 -7
- package/dist/{links-CN5JFFde.js → links-rFaWqS2Y.js} +9 -9
- package/dist/{links-CN5JFFde.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/{oauth-TVPPye84.js → oauth-7_48zR7n.js} +75 -19
- package/dist/oauth-7_48zR7n.js.map +1 -0
- package/dist/{registry-PNi9rsGi.js → registry-eourRLY2.js} +2 -2
- package/dist/{registry-PNi9rsGi.js.map → registry-eourRLY2.js.map} +1 -1
- package/dist/{remote-hosts-b6Luwdhu.js → remote-hosts-DY2J07ut.js} +4 -4
- package/dist/{remote-hosts-b6Luwdhu.js.map → remote-hosts-DY2J07ut.js.map} +1 -1
- package/dist/{secret-shapes-CEoGmfEE.js → secret-shapes-BjW4l6U0.js} +8 -3
- package/dist/{secret-shapes-CEoGmfEE.js.map → secret-shapes-BjW4l6U0.js.map} +1 -1
- package/dist/{settings-keys-DssjmqAV.js → settings-keys-CPdmkTz7.js} +3 -3
- package/dist/{settings-keys-DssjmqAV.js.map → settings-keys-CPdmkTz7.js.map} +1 -1
- package/dist/{shell-path-BUFwqU_A.js → shell-path-B8b3EOtK.js} +3 -3
- package/dist/{shell-path-BUFwqU_A.js.map → shell-path-B8b3EOtK.js.map} +1 -1
- package/dist/store-L01W0gGI.js.map +1 -1
- package/dist/{todo-edits-H77ROt6X.js → todo-edits-BERpCRPj.js} +3 -3
- package/dist/{todo-edits-H77ROt6X.js.map → todo-edits-BERpCRPj.js.map} +1 -1
- package/dist/{transcript-anchors-s-yxh0jt.js → transcript-anchors-jHrg-r-H.js} +6 -6
- package/dist/{transcript-anchors-s-yxh0jt.js.map → transcript-anchors-jHrg-r-H.js.map} +1 -1
- package/dist/{transcript-reconcile-DeFLIQ14.js → transcript-reconcile-CPdrNbbR.js} +2 -2
- package/dist/{transcript-reconcile-DeFLIQ14.js.map → transcript-reconcile-CPdrNbbR.js.map} +1 -1
- package/dist/tui.d.ts +5 -5
- package/dist/tui.js +14 -14
- package/dist/{turn-operations-BbGJ-KSt.d.ts → turn-operations-DuGtKuc_.d.ts} +9 -2
- package/dist/turn-operations-DuGtKuc_.d.ts.map +1 -0
- package/dist/{url-CLl0u4Z8.js → url-D8KZ7Edw.js} +2 -2
- package/dist/{url-CLl0u4Z8.js.map → url-D8KZ7Edw.js.map} +1 -1
- package/dist/{version-v77Y4A3C.js → version-bd3DQJkc.js} +2 -2
- package/dist/{version-v77Y4A3C.js.map → version-bd3DQJkc.js.map} +1 -1
- package/dist/{workspace-exec-stream-kqARO8iC.js → workspace-exec-stream-CyfYgqAh.js} +4 -4
- package/dist/{workspace-exec-stream-kqARO8iC.js.map → workspace-exec-stream-CyfYgqAh.js.map} +1 -1
- package/dist/{ws-BD9FN98u.js → ws-CURQ2igk.js} +5 -5
- package/dist/{ws-BD9FN98u.js.map → ws-CURQ2igk.js.map} +1 -1
- package/dist/{ws-client-D7eb2UbH.js → ws-client-BVljYbdb.js} +3 -3
- package/dist/{ws-client-D7eb2UbH.js.map → ws-client-BVljYbdb.js.map} +1 -1
- package/package.json +1 -1
- package/dist/mcp-allowlist-BQ5MvhHi.js.map +0 -1
- package/dist/oauth-TVPPye84.js.map +0 -1
- package/dist/turn-operations-BbGJ-KSt.d.ts.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as writeJsonFileAtomic, t as OWNER_ONLY } from "./atomic-write-Ijgf2Mhc.js";
|
|
2
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-PNi9rsGi.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,aAA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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,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;CAC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AC3B,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,C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B;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"}
|
|
@@ -1748,7 +1748,12 @@ const SETTINGS_KEYWORDS = {
|
|
|
1748
1748
|
"gutter",
|
|
1749
1749
|
"timeline"
|
|
1750
1750
|
],
|
|
1751
|
-
showCacheNotices: [
|
|
1751
|
+
showCacheNotices: [
|
|
1752
|
+
"prompt cache",
|
|
1753
|
+
"cache hit",
|
|
1754
|
+
"reasoning dropped",
|
|
1755
|
+
"thinking dropped"
|
|
1756
|
+
],
|
|
1752
1757
|
showThinking: ["reasoning", "thoughts"],
|
|
1753
1758
|
thinkingAutoExpand: [
|
|
1754
1759
|
"reasoning",
|
|
@@ -2129,7 +2134,7 @@ const SETTINGS_TOGGLES = [
|
|
|
2129
2134
|
category: "ui",
|
|
2130
2135
|
key: "showCacheNotices",
|
|
2131
2136
|
label: "Cache notices",
|
|
2132
|
-
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."
|
|
2133
2138
|
},
|
|
2134
2139
|
{
|
|
2135
2140
|
category: "ui",
|
|
@@ -2900,4 +2905,4 @@ function isSecretPathSegment(segment) {
|
|
|
2900
2905
|
//#endregion
|
|
2901
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 };
|
|
2902
2907
|
|
|
2903
|
-
//# sourceMappingURL=secret-shapes-
|
|
2908
|
+
//# sourceMappingURL=secret-shapes-BjW4l6U0.js.map
|