zidane 9.1.11 → 9.1.13
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-CxFKfjZ7.js → acp-Cz5mFUjB.js} +3 -3
- package/dist/{acp-CxFKfjZ7.js.map → acp-Cz5mFUjB.js.map} +1 -1
- package/dist/acp-cli.js +4 -4
- package/dist/acp.js +1 -1
- package/dist/{auth-store-port-8BMUBfqw.js → auth-store-port-CDJa8Q8U.js} +2 -2
- package/dist/{auth-store-port-8BMUBfqw.js.map → auth-store-port-CDJa8Q8U.js.map} +1 -1
- package/dist/{auto-update-restart-_S0w600V.js → auto-update-restart-B4pU7Qgf.js} +10 -10
- package/dist/{auto-update-restart-_S0w600V.js.map → auto-update-restart-B4pU7Qgf.js.map} +1 -1
- package/dist/chat.js +9 -9
- package/dist/{cli-shared-C6qeun-_.js → cli-shared-BVtiiICW.js} +3 -3
- package/dist/{cli-shared-C6qeun-_.js.map → cli-shared-BVtiiICW.js.map} +1 -1
- package/dist/{credentials-BPG17Xuo.js → credentials-axv5VvMR.js} +2 -2
- package/dist/{credentials-BPG17Xuo.js.map → credentials-axv5VvMR.js.map} +1 -1
- package/dist/daemon-cli.js +2 -2
- package/dist/{discovery-DWH6e_zd.js → discovery-D7qVZWzq.js} +4 -4
- package/dist/{discovery-DWH6e_zd.js.map → discovery-D7qVZWzq.js.map} +1 -1
- package/dist/{engine-C_Ndjp0u.js → engine-DjM5NPIf.js} +3 -3
- package/dist/{engine-C_Ndjp0u.js.map → engine-DjM5NPIf.js.map} +1 -1
- package/dist/{executor-BUWZhsfn.js → executor-DlW7qAeN.js} +2 -2
- package/dist/{executor-BUWZhsfn.js.map → executor-DlW7qAeN.js.map} +1 -1
- package/dist/extensions/testing.js +2 -2
- package/dist/{extensions-D4psC965.js → extensions-D7DeZNpn.js} +6 -6
- package/dist/{extensions-D4psC965.js.map → extensions-D7DeZNpn.js.map} +1 -1
- package/dist/extensions.js +5 -5
- package/dist/{google-CTQu7Zz-.js → google-D1zjAViO.js} +2 -2
- package/dist/{google-CTQu7Zz-.js.map → google-D1zjAViO.js.map} +1 -1
- package/dist/{host-D-sOuh0K.js → host-Ds3RDlG5.js} +9 -9
- package/dist/{host-D-sOuh0K.js.map → host-Ds3RDlG5.js.map} +1 -1
- package/dist/{host-signals-Dlxd0YYP.js → host-signals-C8x5Yso0.js} +5 -5
- package/dist/{host-signals-Dlxd0YYP.js.map → host-signals-C8x5Yso0.js.map} +1 -1
- package/dist/{host-version-smAFds1j.js → host-version-BGZumnpZ.js} +2 -2
- package/dist/{host-version-smAFds1j.js.map → host-version-BGZumnpZ.js.map} +1 -1
- package/dist/index.js +5 -5
- package/dist/ipc/remote.js +3 -3
- package/dist/{ipc-DnSKoy00.js → ipc-DGfuNEfR.js} +4 -4
- package/dist/{ipc-DnSKoy00.js.map → ipc-DGfuNEfR.js.map} +1 -1
- package/dist/ipc.js +4 -4
- package/dist/{links-BcfGBoRt.js → links-D_1RhPh5.js} +8 -8
- package/dist/{links-BcfGBoRt.js.map → links-D_1RhPh5.js.map} +1 -1
- package/dist/{loaded-entry-C0h8OMwN.js → loaded-entry-CLva6GQT.js} +2 -2
- package/dist/{loaded-entry-C0h8OMwN.js.map → loaded-entry-CLva6GQT.js.map} +1 -1
- package/dist/{memory-CZNbjYxJ.js → memory-CaFXUvQs.js} +15 -15
- package/dist/{memory-CZNbjYxJ.js.map → memory-CaFXUvQs.js.map} +1 -1
- package/dist/{path-display-DfFjoqUy.js → path-display-ZIWdFaTI.js} +3 -3
- package/dist/{path-display-DfFjoqUy.js.map → path-display-ZIWdFaTI.js.map} +1 -1
- package/dist/providers/google.js +1 -1
- package/dist/{providers-CCPHw25p.js → providers-CsYrxuX1.js} +2 -2
- package/dist/{providers-CCPHw25p.js.map → providers-CsYrxuX1.js.map} +1 -1
- package/dist/providers.js +1 -1
- package/dist/{registry-C-U_tMPi.js → registry-BY45AOA-.js} +2 -2
- package/dist/{registry-C-U_tMPi.js.map → registry-BY45AOA-.js.map} +1 -1
- package/dist/{registry-d-R3YZs1.js → registry-DTotchq6.js} +2 -2
- package/dist/{registry-d-R3YZs1.js.map → registry-DTotchq6.js.map} +1 -1
- package/dist/{registry-DHSQ4fdV.js → registry-Dl6261Xh.js} +2 -2
- package/dist/{registry-DHSQ4fdV.js.map → registry-Dl6261Xh.js.map} +1 -1
- package/dist/{remote-hosts-D77F5uTa.js → remote-hosts-usqMiMbs.js} +4 -4
- package/dist/{remote-hosts-D77F5uTa.js.map → remote-hosts-usqMiMbs.js.map} +1 -1
- package/dist/{setting-Cog4WQc1.js → setting-DzTMJIV3.js} +2 -2
- package/dist/{setting-Cog4WQc1.js.map → setting-DzTMJIV3.js.map} +1 -1
- package/dist/{settings-keys-B1q2NwvM.js → settings-keys-DDrfnBHi.js} +2 -2
- package/dist/{settings-keys-B1q2NwvM.js.map → settings-keys-DDrfnBHi.js.map} +1 -1
- package/dist/{system-freeze-CMY7QnoD.js → system-freeze-CY4Hc9WX.js} +2 -2
- package/dist/{system-freeze-CMY7QnoD.js.map → system-freeze-CY4Hc9WX.js.map} +1 -1
- package/dist/tui.js +15 -15
- package/dist/{version-DiGN0H-_.js → version-Bu3Nc8-U.js} +2 -2
- package/dist/{version-DiGN0H-_.js.map → version-Bu3Nc8-U.js.map} +1 -1
- package/dist/{wire-D4NlIUMg.js → wire-BKcREhuL.js} +2 -2
- package/dist/{wire-D4NlIUMg.js.map → wire-BKcREhuL.js.map} +1 -1
- package/dist/{ws-6EUa8pzM.js → ws-DriNRyP-.js} +4 -4
- package/dist/{ws-6EUa8pzM.js.map → ws-DriNRyP-.js.map} +1 -1
- package/dist/{ws-client-5i2lbQnC.js → ws-client-PZdbO0fj.js} +2 -2
- package/dist/{ws-client-5i2lbQnC.js.map → ws-client-PZdbO0fj.js.map} +1 -1
- package/docs/RELEASE.md +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers-CCPHw25p.js","names":[],"sources":["../src/extensions/runtime/domains/sessions.ts","../src/extensions/catalog/clone.ts","../src/extensions/catalog/engine.ts","../src/extensions/catalog/domain.ts","../src/extensions/catalog/models.ts","../src/extensions/catalog/providers.ts"],"sourcesContent":["/**\n * `ctx.sessions` (extension API): the orchestration verbs mapped 1:1,\n * plus the lifecycle verbs. Everything goes through the host's\n * session control, acting as the extension, so what it creates is tagged\n * with the extension id. Without a host, or when the host lacks a verb, the\n * call rejects with a message naming both.\n */\n\nimport type { CommandOutputBlock } from '../../../chat/commands'\nimport type { SessionQuery, SessionQueryIssue, SessionSort } from '../../../chat/session-query'\nimport type { SessionListQuery, SessionListRow, SessionsDomain } from '../../api/sessions'\nimport type { ExtensionSessionLifecycleVerbs, ExtensionSessionRow, ExtensionSessionVerbs } from '../../host-runtime'\nimport type { DomainDeps } from '../deps'\nimport type { SessionsPort } from './ports'\nimport { projectNameOf, querySessions, SessionQueryError, validateQuery, validateSort } from '../../../chat/session-query'\nimport { assertUsable } from '../owner'\n\ntype Verbs = ExtensionSessionVerbs & ExtensionSessionLifecycleVerbs\n\n/**\n * Prefixes bare renderer ids of `custom` blocks with the extension id, as\n * `ctx.appendNote` does.\n */\nfunction namespaceBlocks(extensionId: string, blocks: readonly CommandOutputBlock[]): CommandOutputBlock[] {\n return blocks.map(block =>\n block.custom && !block.custom.renderer.includes('/')\n ? { ...block, custom: { ...block.custom, renderer: `${extensionId}/${block.custom.renderer}` } }\n : block)\n}\n\n/** Rows per page of `ctx.sessions.list` when the query names none, and the most it hands out. */\nexport const SESSION_LIST_DEFAULT_LIMIT = 30\n/** The most rows one `ctx.sessions.list` page holds. */\nexport const SESSION_LIST_MAX_LIMIT = 100\n\n/** A list query with its defaults filled, as the host's `query` verb gets it. */\nexport type NormalizedSessionListQuery = Parameters<NonNullable<ExtensionSessionLifecycleVerbs['query']>>[0]\n\n/**\n * Checks a `ctx.sessions.list` query and fills its defaults. Throws a\n * `SessionQueryError` naming every problem.\n *\n * @param query - The query as the extension gave it.\n */\nexport function normalizeSessionListQuery(query: unknown): NormalizedSessionListQuery {\n if (query === undefined)\n query = {}\n if (typeof query === 'number')\n throw new SessionQueryError([{ path: 'query', message: `list takes a query object now: call list({ limit: ${query} })` }])\n if (!query || typeof query !== 'object' || Array.isArray(query))\n throw new SessionQueryError([{ path: 'query', message: 'must be { where?, sort?, limit?, cursor?, archived? }' }])\n const q = query as Record<string, unknown>\n const issues: SessionQueryIssue[] = []\n for (const key of Object.keys(q)) {\n if (!['where', 'sort', 'limit', 'cursor', 'archived'].includes(key))\n issues.push({ path: key, message: 'unknown key; a list query holds where, sort, limit, cursor and archived' })\n }\n if (q.where !== undefined)\n issues.push(...validateQuery(q.where))\n if (q.sort !== undefined)\n issues.push(...validateSort(q.sort))\n const limit = q.limit ?? SESSION_LIST_DEFAULT_LIMIT\n if (!Number.isInteger(limit) || (limit as number) < 1 || (limit as number) > SESSION_LIST_MAX_LIMIT)\n issues.push({ path: 'limit', message: `must be a whole number from 1 to ${SESSION_LIST_MAX_LIMIT}` })\n if (q.cursor !== undefined && (typeof q.cursor !== 'string' || q.cursor.length === 0))\n issues.push({ path: 'cursor', message: 'must be the cursor of a previous page' })\n if (q.archived !== undefined && typeof q.archived !== 'boolean' && q.archived !== 'all')\n issues.push({ path: 'archived', message: 'must be true, false or \\'all\\'' })\n if (issues.length > 0)\n throw new SessionQueryError(issues)\n return {\n ...(q.where !== undefined ? { where: q.where as NonNullable<SessionListQuery['where']> } : {}),\n sort: (q.sort as SessionListQuery['sort']) ?? [{ field: 'updatedAt', dir: 'desc' }],\n limit: limit as number,\n ...(q.cursor !== undefined ? { cursor: q.cursor as string } : {}),\n archived: (q.archived as SessionListQuery['archived']) ?? false,\n }\n}\n\n/**\n * Every field path a query reads (conditions at any depth) and a sort reads,\n * as written (`facet.<ext>.<key>` paths whole).\n *\n * @param where - The query.\n * @param sort - The sort keys.\n */\nexport function fieldsReadBy(where: SessionQuery | undefined, sort: readonly SessionSort[] = []): Set<string> {\n const out = new Set<string>(sort.map(s => s.field))\n const walk = (q: SessionQuery): void => {\n if ('field' in q)\n out.add(q.field)\n else if ('all' in q)\n q.all.forEach(walk)\n else if ('any' in q)\n q.any.forEach(walk)\n else if ('not' in q)\n walk(q.not)\n }\n if (where)\n walk(where)\n return out\n}\n\n/** The fields an orchestration row fills (`orchestrationRow`): what a host without the `query` verb can filter and sort on. */\nconst ORCHESTRATION_FIELDS: ReadonlySet<string> = new Set(['id', 'title', 'cwd', 'projectName', 'status', 'updatedAt', 'archived'])\n\nfunction isDefaultSort(sort: readonly SessionSort[]): boolean {\n return sort.length === 1 && sort[0]!.field === 'updatedAt' && sort[0]!.dir === 'desc'\n}\n\n/** An orchestration row as a list row: the fields it has, no facets. */\nfunction orchestrationRow(row: ExtensionSessionRow): SessionListRow {\n return { id: row.sessionId, title: row.title, projectRoot: null, projectName: projectNameOf({ cwd: row.cwd }) ?? '', cwd: row.cwd, status: row.state, updatedAt: row.updatedAt, archived: false, worker: row.worker, facets: {} }\n}\n\n/**\n * Creates one extension's `ctx.sessions`.\n *\n * @param deps - The extension's id, owner, guard and logger.\n * @param port - The host's session control and prompt bridge.\n * @returns The domain without `facets` (the context adds them). Every call rejects with `DisposedError` once the owner is torn down (an unload waits for the calls in flight first).\n */\nexport function createSessionsDomain(deps: DomainDeps, port: SessionsPort): Omit<SessionsDomain, 'facets'> {\n const { extensionId, owner } = deps\n\n const verbs = (method: string): Verbs => {\n assertUsable(owner, `sessions.${method}`)\n const control = port.sessionControl()\n if (!control)\n throw new Error(`sessions.${method}: no chat host is attached (extension \"${extensionId}\").`)\n return control.verbs(extensionId)\n }\n\n /** The lifecycle verb `method`, or a rejection when the host does not implement it. */\n const lifecycle = <K extends keyof ExtensionSessionLifecycleVerbs>(method: K): NonNullable<Verbs[K]> => {\n const all = verbs(method)\n const verb = all[method]\n if (typeof verb !== 'function')\n throw new Error(`sessions.${method}: this host does not support it (extension \"${extensionId}\").`)\n return verb.bind(all) as NonNullable<Verbs[K]>\n }\n\n return {\n create: async params => verbs('create').create(params),\n list: async (query) => {\n const all = verbs('list')\n const q = normalizeSessionListQuery(query)\n if (typeof all.query === 'function')\n return all.query(q)\n // A host without the query verb: its newest orchestration rows, filtered here. A query that needs more fails rather than answering wrong.\n const unsupported = (why: string): Error => new Error(`sessions.list: this host does not support queries (extension \"${extensionId}\"): ${why}.`)\n const missing = [...fieldsReadBy(q.where, q.sort)].filter(f => !ORCHESTRATION_FIELDS.has(f))\n if (missing.length > 0)\n throw unsupported(`it lists only ${[...ORCHESTRATION_FIELDS].join(', ')}, not ${missing.join(', ')}`)\n if (q.archived !== false)\n throw unsupported('it lists no archived sessions')\n const listed = await all.list(SESSION_LIST_MAX_LIMIT)\n const truncated = listed.length >= SESSION_LIST_MAX_LIMIT\n if (truncated && (q.where !== undefined || !isDefaultSort(q.sort)))\n throw unsupported(`it lists only its ${SESSION_LIST_MAX_LIMIT} newest sessions, so it can only page them newest first, unfiltered`)\n const page = querySessions(listed.map(orchestrationRow), { ...q, scope: q.archived })\n // A page that ends exactly at the last listed row is whole (no cursor); one cut short by the end of the list may miss older sessions.\n if (truncated && page.cursor === undefined && page.rows.length < q.limit)\n throw unsupported(`it lists only its ${SESSION_LIST_MAX_LIMIT} newest sessions; this page reaches past them`)\n return page\n },\n read: async sessionId => verbs('read').read(sessionId),\n send: async (sessionId, prompt) => verbs('send').send(sessionId, prompt),\n steer: async (sessionId, message) => verbs('steer').steer(sessionId, message),\n cancel: async sessionId => verbs('cancel').cancel(sessionId),\n transcript: async (sessionId, limit) => verbs('transcript').transcript(sessionId, limit),\n wait: async (sessionId, timeoutSec) => verbs('wait').wait(sessionId, timeoutSec),\n events: async query => verbs('events').events(query),\n pending: async sessionId => verbs('pending').pending(sessionId),\n answer: async (requestId, response) => verbs('answer').answer(requestId, response),\n approve: async (requestId, decision) => verbs('approve').approve(requestId, decision),\n\n get: async sessionId => lifecycle('get')(sessionId),\n remove: async sessionId => lifecycle('remove')(sessionId),\n compact: async sessionId => lifecycle('compact')(sessionId),\n switchModel: async (sessionId, model) => lifecycle('switchModel')(sessionId, model),\n switchAgent: async (sessionId, agentId) => lifecycle('switchAgent')(sessionId, agentId),\n setThinking: async (sessionId, level) => lifecycle('setThinking')(sessionId, level),\n synthetic: async (sessionId, message) => lifecycle('synthetic')(sessionId, message),\n note: async (sessionId, blocks) => lifecycle('note')(sessionId, namespaceBlocks(extensionId, blocks)),\n\n submit: async (text, opts = {}) => {\n const delivery = opts.delivery ? { delivery: opts.delivery } : undefined\n if (opts.sessionId !== undefined)\n return lifecycle('submit')(opts.sessionId, text, delivery)\n // The session in view: the host's prompt pipeline, as `ctx.submitPrompt`.\n assertUsable(owner, 'sessions.submit')\n if (!port.promptBridge)\n throw new Error(`sessions.submit: this host has no prompt pipeline; pass a sessionId (extension \"${extensionId}\").`)\n return port.promptBridge.submit(text, delivery)\n },\n }\n}\n","/**\n * Copy-on-edit cloning for catalog items. Items mix plain data (specs,\n * presets, labels) with functions and class instances (`execute`,\n * `factory`, OAuth providers, zod schemas). Only the plain data is copied;\n * everything else is shared by reference, so an edit never reaches a value\n * an earlier read handed out.\n */\n\n/** `true` for arrays and objects whose prototype is `Object.prototype` or `null`. */\nfunction isPlain(value: unknown): value is Record<string, unknown> | unknown[] {\n if (Array.isArray(value))\n return true\n if (value === null || typeof value !== 'object')\n return false\n const proto = Object.getPrototypeOf(value)\n return proto === Object.prototype || proto === null\n}\n\n/**\n * Deep-copies arrays and plain objects. Functions, class instances, Maps,\n * Sets and primitives are kept as they are. Cycles are preserved.\n */\nexport function clonePlain<T>(value: T): T {\n const seen = new Map<object, unknown>()\n const walk = (v: unknown): unknown => {\n if (!isPlain(v))\n return v\n const hit = seen.get(v)\n if (hit !== undefined)\n return hit\n if (Array.isArray(v)) {\n const out: unknown[] = []\n seen.set(v, out)\n for (const item of v)\n out.push(walk(item))\n return out\n }\n const out: Record<string, unknown> = Object.create(Object.getPrototypeOf(v))\n seen.set(v, out)\n for (const key of Object.keys(v))\n out[key] = walk(v[key])\n return out\n }\n return walk(value) as T\n}\n","/**\n * The catalog transform engine shared by every extension catalog (tools, agents,\n * models, providers, MCP servers, skills).\n *\n * A catalog value is rebuilt by replay: the base items (built-ins, config),\n * then registrations in the order they were made, then every transform in\n * extension load order. The result is memoized until a registration,\n * transform or `reload()` changes it. Each item records who added,\n * modified or removed it, so Settings can name the extension, and disposing\n * the extension's registrations restores the item on the next read.\n *\n * Edits are copy-on-edit: `update` clones the item before the transform\n * sees it, so a value an earlier read handed out is never mutated. A\n * transform that throws is rolled back as a whole and reported.\n */\n\nimport type { Disposable, ItemOrigin } from '../api'\nimport type { Guard } from '../runtime/deps'\nimport { clonePlain } from './clone'\n\n/** An item with the origin a base or registration gives it. */\nexport interface Sourced<T> {\n /** The item. */\n readonly item: T\n /** Who put it in the catalog. */\n readonly origin: ItemOrigin\n}\n\n/** One keyed collection inside a catalog. */\nexport interface SectionSpec<T, C> {\n /** The id of an item. Must be a non-empty string. */\n key: (item: T) => string\n /** The base items for a context: built-ins and config. Cached until `reload()`. */\n base: (context: C) => readonly Sourced<T>[]\n /** Copy used by `update`. Default: {@link clonePlain}. */\n clone?: (item: T) => T\n}\n\n/** Catalog-wide state beside the sections (a default id, auto-invoked names). */\nexport interface StateSpec<X, C> {\n /** The state before any transform. */\n base: (context: C) => X\n /** Copy taken before each transform, restored when it throws. */\n clone: (state: X) => X\n}\n\n/** Who touched one id. Removed ids keep theirs with `removedBy`. */\nexport interface Provenance {\n /** The item id. */\n readonly id: string\n /** Who put the item in the catalog. A transform's `add` makes it `{ kind: 'extension' }`. */\n readonly origin: ItemOrigin\n /** The origin of an item this one replaced at registration (same id). */\n readonly replaced?: ItemOrigin\n /** The extension whose transform added the item. */\n readonly addedBy?: string\n /** Extensions whose transforms edited the item, in replay order. */\n readonly modifiedBy: readonly string[]\n /** The extension whose transform removed the item. */\n readonly removedBy?: string\n}\n\n/** A transform that threw during replay; its edits were rolled back. */\nexport interface TransformFailure {\n /** The extension that registered the transform. */\n readonly extensionId: string\n /** The guard label it ran under. */\n readonly label: string\n}\n\n/** One section of a replayed catalog value. Frozen. */\nexport interface SectionValue<T> {\n /** The items, in insertion order. */\n readonly items: readonly T[]\n /** The item with this id. */\n get: (id: string) => T | undefined\n /** The origin of a present item. */\n origin: (id: string) => ItemOrigin | undefined\n /** Who touched an id, present or removed. */\n provenance: (id: string) => Provenance | undefined\n /** Provenance of every id, present ones first, then removed ones. */\n readonly entries: readonly Provenance[]\n}\n\n/** A replayed catalog value. Never mutated after it is returned. */\nexport interface CatalogValue<S extends Sections, X> {\n /** Every section after replay. */\n readonly sections: { readonly [K in keyof S]: SectionValue<S[K]> }\n /** The state after replay. */\n readonly state: Readonly<X>\n /** Transforms that threw and were skipped. */\n readonly failures: readonly TransformFailure[]\n}\n\n/** The section item types of a catalog, by section name (an object type such as `{ tools: NamedTool }`). */\nexport type Sections = object\n\n/** The editable form of a section that a transform works on. */\nexport interface SectionDraft<T> {\n /** Present items, in order. Treat them as read-only; edit through `update`. */\n list: () => readonly T[]\n /** The item with this id. Read-only, like `list`. */\n get: (id: string) => T | undefined\n /** Origin of a present item. */\n origin: (id: string) => ItemOrigin | undefined\n /** Adds an item, or replaces the one with the same id. */\n add: (item: T) => void\n /** Edits a clone of the item. A missing id is a no-op. The edit must keep the id. */\n update: (id: string, edit: (item: T) => void) => void\n /** Puts `item` in place of the item with its id (or adds it), marking it modified. */\n replace: (item: T) => void\n /** Removes an item. A missing id is a no-op. */\n remove: (id: string) => void\n /** A clone of an item, for callbacks that may mutate what they get. */\n cloneOf: (id: string) => T | undefined\n}\n\n/** What a transform gets: every section, the state, and who is editing. */\nexport interface CatalogDraft<S extends Sections, X, C> {\n /** The sections. */\n readonly sections: { readonly [K in keyof S]: SectionDraft<S[K]> }\n /** The state. Replace or mutate it; it is cloned before each transform. */\n state: X\n /** The context the catalog is read for. */\n readonly context: C\n /** The extension whose transform is running. */\n readonly extensionId: string\n /** Throws when the transform already returned (an editor kept past its call). */\n assertOpen: () => void\n}\n\n/** A transform registration. */\nexport interface TransformRegistration<S extends Sections, X, C> {\n /** The extension that owns the transform (orders replay and attributes edits). */\n extensionId: string\n /** Runs the transform with error attribution. */\n guard: Guard\n /** Guard label. Default: `<catalog>.transform`. */\n label?: string\n /** Edits the draft. */\n apply: (draft: CatalogDraft<S, X, C>) => void\n}\n\n/** Options shared by every catalog. */\nexport interface CatalogOptions {\n /** Load-order rank of an extension; lower replays first. Ties keep registration order. */\n order?: (extensionId: string) => number\n /** Most memoized values kept (one per context key). Default 32. */\n cacheSize?: number\n}\n\n/** Spec of a multi-section catalog. */\nexport interface CatalogSetSpec<S extends Sections, X, C> extends CatalogOptions {\n /** Name used in guard labels and errors. */\n name: string\n /** The sections. */\n sections: { [K in keyof S]: SectionSpec<S[K], C> }\n /** Optional catalog-wide state. */\n state?: StateSpec<X, C>\n /** Memo key of a context. `undefined` means \"don't memoize\". Default: one key for all. */\n contextKey?: (context: C) => string | undefined\n}\n\n/** A shared catalog: registrations, transforms, replayed reads. */\nexport interface CatalogSet<S extends Sections, X, C> {\n /** Catalog name. */\n readonly name: string\n /** Adds an item to a section after the base. A later registration of the same id replaces an earlier one. */\n register: <K extends keyof S>(section: K, item: S[K], origin: ItemOrigin) => Disposable\n /** Adds a transform. Replays in `order`, then registration order. */\n transform: (registration: TransformRegistration<S, X, C>) => Disposable\n /** Drops the cached base and every memoized value, then notifies. */\n reload: () => void\n /** The replayed value for a context, memoized until the next change. */\n read: (context: C) => CatalogValue<S, X>\n /** Calls `listener` after each change (the next `read` replays). Returns the unsubscribe. */\n subscribe: (listener: () => void) => () => void\n}\n\ninterface Entry<T> extends Provenance { readonly item: T }\n\ninterface Gate { open: boolean, extensionId: string }\n\nconst BUILTIN: ItemOrigin = Object.freeze({ kind: 'builtin' })\n\nfunction withExtension(list: readonly string[], extensionId: string): readonly string[] {\n return list.includes(extensionId) ? list : [...list, extensionId]\n}\n\nfunction provenanceOf<T>(entry: Entry<T>): Provenance {\n const { item: _item, ...rest } = entry\n return rest\n}\n\nclass SectionDraftImpl<T> implements SectionDraft<T> {\n entries = new Map<string, Entry<T>>()\n removed = new Map<string, Provenance>()\n\n constructor(private readonly name: string, private readonly spec: SectionSpec<T, unknown>, private readonly gate: Gate) {}\n\n idOf(item: T): string {\n const id = this.spec.key(item)\n if (typeof id !== 'string' || id.length === 0)\n throw new TypeError(`${this.name}: item needs a non-empty string id`)\n return id\n }\n\n seed(item: T, origin: ItemOrigin): void {\n const id = this.idOf(item)\n const prev = this.entries.get(id)\n this.entries.set(id, { id, item, origin, modifiedBy: [], ...(prev ? { replaced: prev.origin } : {}) })\n }\n\n private check(): void {\n if (!this.gate.open)\n throw new Error(`${this.name}: the editor was used after its transform returned`)\n }\n\n private cloneItem(item: T): T {\n return (this.spec.clone ?? clonePlain)(item)\n }\n\n list = (): readonly T[] => {\n this.check()\n return [...this.entries.values()].map(entry => entry.item)\n }\n\n get = (id: string): T | undefined => {\n this.check()\n return this.entries.get(id)?.item\n }\n\n origin = (id: string): ItemOrigin | undefined => {\n this.check()\n return this.entries.get(id)?.origin\n }\n\n cloneOf = (id: string): T | undefined => {\n this.check()\n const entry = this.entries.get(id)\n return entry ? this.cloneItem(entry.item) : undefined\n }\n\n add = (item: T): void => {\n this.check()\n const id = this.idOf(item)\n const ext = this.gate.extensionId\n const prev = this.entries.get(id) ?? this.removed.get(id)\n this.removed.delete(id)\n if (prev) {\n const { removedBy: _removedBy, ...rest } = provenanceOf(prev as Entry<T>)\n this.entries.set(id, { ...rest, item, modifiedBy: withExtension(prev.modifiedBy, ext) })\n return\n }\n this.entries.set(id, { id, item, origin: { kind: 'extension', id: ext }, addedBy: ext, modifiedBy: [] })\n }\n\n update = (id: string, edit: (item: T) => void): void => {\n this.check()\n const prev = this.entries.get(id)\n if (!prev)\n return\n const copy = this.cloneItem(prev.item)\n edit(copy)\n if (this.idOf(copy) !== id)\n throw new Error(`${this.name}: update must not change the id of \"${id}\"`)\n this.entries.set(id, { ...prev, item: copy, modifiedBy: withExtension(prev.modifiedBy, this.gate.extensionId) })\n }\n\n replace = (item: T): void => {\n this.check()\n const id = this.idOf(item)\n const prev = this.entries.get(id)\n if (!prev) {\n this.add(item)\n return\n }\n this.entries.set(id, { ...prev, item, modifiedBy: withExtension(prev.modifiedBy, this.gate.extensionId) })\n }\n\n remove = (id: string): void => {\n this.check()\n const prev = this.entries.get(id)\n if (!prev)\n return\n this.entries.delete(id)\n this.removed.set(id, { ...provenanceOf(prev), removedBy: this.gate.extensionId })\n }\n\n checkpoint(): () => void {\n const entries = new Map(this.entries)\n const removed = new Map(this.removed)\n return () => {\n this.entries = entries\n this.removed = removed\n }\n }\n\n freeze(): SectionValue<T> {\n const entries = new Map(this.entries)\n const provenance = new Map<string, Provenance>()\n for (const [id, entry] of entries)\n provenance.set(id, Object.freeze(provenanceOf(entry)))\n for (const [id, prov] of this.removed)\n provenance.set(id, Object.freeze(prov))\n return Object.freeze({\n items: Object.freeze([...entries.values()].map(entry => entry.item)),\n get: (id: string) => entries.get(id)?.item,\n origin: (id: string) => entries.get(id)?.origin,\n provenance: (id: string) => provenance.get(id),\n entries: Object.freeze([...provenance.values()]),\n })\n }\n}\n\ninterface StoredRegistration { seq: number, section: PropertyKey, item: unknown, origin: ItemOrigin }\ninterface StoredTransform<S extends Sections, X, C> extends TransformRegistration<S, X, C> { seq: number }\n\n/** Creates a catalog with several sections and optional state. */\nexport function createCatalogSet<S extends Sections, X = undefined, C = void>(spec: CatalogSetSpec<S, X, C>): CatalogSet<S, X, C> {\n const sectionNames = Object.keys(spec.sections) as (keyof S & string)[]\n const registrations: StoredRegistration[] = []\n const transforms: StoredTransform<S, X, C>[] = []\n const baseCache = new Map<string, { [K in keyof S]: readonly Sourced<S[K]>[] }>()\n const valueCache = new Map<string, CatalogValue<S, X>>()\n const listeners = new Set<() => void>()\n const cacheSize = spec.cacheSize ?? 32\n let seq = 0\n\n const notify = (): void => {\n for (const listener of [...listeners]) {\n try {\n listener()\n }\n catch {\n // A host listener must not break other listeners or the registration.\n }\n }\n }\n\n const invalidate = (): void => {\n valueCache.clear()\n notify()\n }\n\n const baseFor = (context: C, key: string | undefined): { [K in keyof S]: readonly Sourced<S[K]>[] } => {\n const hit = key === undefined ? undefined : baseCache.get(key)\n if (hit)\n return hit\n const base = {} as { [K in keyof S]: readonly Sourced<S[K]>[] }\n for (const name of sectionNames)\n base[name] = spec.sections[name].base(context)\n if (key !== undefined)\n baseCache.set(key, base)\n return base\n }\n\n const rank = (extensionId: string): number => {\n const value = spec.order?.(extensionId)\n return typeof value === 'number' && Number.isFinite(value) ? value : Number.MAX_SAFE_INTEGER\n }\n\n const build = (context: C, key: string | undefined): CatalogValue<S, X> => {\n const gate: Gate = { open: false, extensionId: '' }\n const drafts = {} as { [K in keyof S]: SectionDraftImpl<S[K]> }\n const base = baseFor(context, key)\n for (const name of sectionNames) {\n const draft = new SectionDraftImpl<S[typeof name]>(`${spec.name}.${name}`, spec.sections[name] as SectionSpec<S[typeof name], unknown>, gate)\n for (const { item, origin } of base[name])\n draft.seed(item, origin ?? BUILTIN)\n drafts[name] = draft\n }\n for (const reg of registrations)\n (drafts[reg.section as keyof S] as SectionDraftImpl<unknown>).seed(reg.item, reg.origin)\n\n const draft: CatalogDraft<S, X, C> = {\n sections: drafts,\n state: (spec.state ? spec.state.base(context) : undefined) as X,\n context,\n get extensionId() { return gate.extensionId },\n assertOpen: () => {\n if (!gate.open)\n throw new Error(`${spec.name}: the editor was used after its transform returned`)\n },\n }\n\n const failures: TransformFailure[] = []\n const ordered = [...transforms].sort((a, b) => rank(a.extensionId) - rank(b.extensionId) || a.seq - b.seq)\n for (const transform of ordered) {\n const restores = sectionNames.map(name => drafts[name].checkpoint())\n const savedState = spec.state ? spec.state.clone(draft.state) : draft.state\n const label = transform.label ?? `${spec.name}.transform`\n gate.open = true\n gate.extensionId = transform.extensionId\n let ok = false\n try {\n ok = transform.guard.callSync(label, () => {\n transform.apply(draft)\n return true\n }, { fallback: false }) === true\n }\n catch {\n ok = false\n }\n finally {\n gate.open = false\n }\n if (!ok) {\n for (const restore of restores)\n restore()\n draft.state = savedState\n failures.push(Object.freeze({ extensionId: transform.extensionId, label }))\n }\n }\n\n const sections = {} as { [K in keyof S]: SectionValue<S[K]> }\n for (const name of sectionNames)\n sections[name] = drafts[name].freeze()\n return Object.freeze({ sections: Object.freeze(sections), state: draft.state, failures: Object.freeze(failures) })\n }\n\n return {\n name: spec.name,\n register(section, item, origin) {\n if (!sectionNames.includes(section as keyof S & string))\n throw new TypeError(`${spec.name}: unknown section \"${String(section)}\"`)\n const id = spec.sections[section].key(item)\n if (typeof id !== 'string' || id.length === 0)\n throw new TypeError(`${spec.name}.${String(section)}: item needs a non-empty string id`)\n const stored: StoredRegistration = { seq: seq++, section, item, origin }\n registrations.push(stored)\n invalidate()\n return once(() => {\n const index = registrations.indexOf(stored)\n if (index >= 0) {\n registrations.splice(index, 1)\n invalidate()\n }\n })\n },\n transform(registration) {\n if (typeof registration.apply !== 'function')\n throw new TypeError(`${spec.name}: transform must be a function`)\n const stored: StoredTransform<S, X, C> = { ...registration, seq: seq++ }\n transforms.push(stored)\n invalidate()\n return once(() => {\n const index = transforms.indexOf(stored)\n if (index >= 0) {\n transforms.splice(index, 1)\n invalidate()\n }\n })\n },\n reload() {\n baseCache.clear()\n invalidate()\n },\n read(context) {\n const key = spec.contextKey ? spec.contextKey(context) : ''\n if (key !== undefined) {\n const hit = valueCache.get(key)\n if (hit)\n return hit\n }\n const value = build(context, key)\n if (key !== undefined) {\n valueCache.set(key, value)\n if (valueCache.size > cacheSize)\n valueCache.delete(valueCache.keys().next().value as string)\n }\n return value\n },\n subscribe(listener) {\n listeners.add(listener)\n return () => {\n listeners.delete(listener)\n }\n },\n }\n}\n\n/** Spec of a single-section catalog. */\nexport interface CatalogSpec<T> extends CatalogOptions {\n /** Name used in guard labels and errors. Default `'catalog'`. */\n name?: string\n /** The id of an item. */\n key: (item: T) => string\n /** The base items. Plain items are `builtin`; give `Sourced` entries for another origin. */\n base: () => readonly (T | Sourced<T>)[]\n /** Copy used by `update`. Default: {@link clonePlain}. */\n clone?: (item: T) => T\n /** Tells a `Sourced` entry from a plain item. Default: an object with exactly `item` and `origin`. */\n isSourced?: (entry: T | Sourced<T>) => entry is Sourced<T>\n}\n\n/** A single-section catalog. */\nexport interface Catalog<T> {\n /** Adds an item after the base. */\n register: (item: T, origin: ItemOrigin) => Disposable\n /** Adds a transform owned by `extensionId`, run through `guard`. */\n transform: (fn: (editor: SectionDraft<T>) => void, extensionId: string, guard: Guard) => Disposable\n /** Re-reads the base and replays. */\n reload: () => void\n /** The replayed items, memoized until the next change. */\n read: () => readonly T[]\n /** The replayed section, with provenance. */\n value: () => SectionValue<T>\n /** Transforms that threw on the last replay. */\n failures: () => readonly TransformFailure[]\n /** Calls `listener` after each change. */\n subscribe: (listener: () => void) => () => void\n}\n\nfunction defaultIsSourced<T>(entry: T | Sourced<T>): entry is Sourced<T> {\n if (entry === null || typeof entry !== 'object')\n return false\n const keys = Object.keys(entry)\n return keys.length === 2 && keys.includes('item') && keys.includes('origin')\n}\n\n/** Creates a catalog with one keyed collection: the generic transform engine. */\nexport function createCatalog<T>(spec: CatalogSpec<T>): Catalog<T> {\n const isSourced = spec.isSourced ?? defaultIsSourced\n const set = createCatalogSet<{ items: T }, undefined, void>({\n name: spec.name ?? 'catalog',\n order: spec.order,\n cacheSize: spec.cacheSize,\n sections: {\n items: {\n key: spec.key,\n clone: spec.clone,\n base: () => spec.base().map(entry => isSourced(entry) ? entry : { item: entry, origin: BUILTIN }),\n },\n },\n })\n return {\n register: (item, origin) => set.register('items', item, origin),\n transform: (fn, extensionId, guard) => set.transform({ extensionId, guard, apply: draft => fn(draft.sections.items) }),\n reload: set.reload,\n read: () => set.read().sections.items.items,\n value: () => set.read().sections.items,\n failures: () => set.read().failures,\n subscribe: set.subscribe,\n }\n}\n\n/** Wraps a function so it runs at most once: the Disposable contract. */\nexport function once(fn: () => void): Disposable {\n let done = false\n return {\n dispose() {\n if (done)\n return\n done = true\n fn()\n },\n }\n}\n","/**\n * Glue between the shared catalogs and one extension's domain: owner\n * binding, guarded transforms, extension origins.\n */\n\nimport type { Disposable, ItemOrigin, Transform } from '../api'\nimport type { DomainDeps } from '../runtime/deps'\nimport type { CatalogDraft, CatalogSet, Sections } from './engine'\nimport { DisposedError } from '../api'\nimport { once } from './engine'\n\n/** A host port that can re-read external data before a catalog replays. */\nexport interface RefreshablePort {\n /** Re-reads the base (config files, a server list). `reload()` awaits it before replaying. */\n refresh?: () => Promise<void>\n}\n\n/** The origin of items the extension registers. */\nexport function extensionOrigin(deps: DomainDeps): ItemOrigin {\n return { kind: 'extension', id: deps.extensionId }\n}\n\n/**\n * Makes a registration through the extension's owner: refused once the owner\n * is disposed, withdrawn when it is, and withdrawable on its own.\n */\nexport function owned(deps: DomainDeps, what: string, make: () => Disposable): Disposable {\n if (deps.owner.disposed)\n throw new DisposedError(what)\n const inner = make()\n let cleanup: Disposable | undefined\n const handle = once(() => {\n cleanup?.dispose()\n inner.dispose()\n })\n cleanup = deps.owner.onCleanup(() => handle.dispose())\n return handle\n}\n\n/** Registers `fn` as a guarded transform of `set`, with the editor `makeEditor` builds. */\nexport function addTransform<S extends Sections, X, C, E>(\n deps: DomainDeps,\n set: CatalogSet<S, X, C>,\n what: string,\n makeEditor: (draft: CatalogDraft<S, X, C>) => E,\n fn: Transform<E>,\n): Disposable {\n if (typeof fn !== 'function')\n throw new TypeError(`${what}: transform must be a function`)\n return owned(deps, what, () => set.transform({\n extensionId: deps.extensionId,\n guard: deps.guard,\n label: what,\n apply: draft => fn(makeEditor(draft)),\n }))\n}\n\n/** `reload()` of a catalog domain: refresh the port, then drop the cached base. */\nexport function reloadWith(set: { reload: () => void }, port: RefreshablePort): () => Promise<void> {\n return async () => {\n await port.refresh?.()\n set.reload()\n }\n}\n","/**\n * The models catalog: `ctx.models`. Models of the active providers, keyed\n * by provider and model id, plus the default selection. Models are not added\n * here: a provider brings them (see `ctx.providers`).\n */\n\nimport type { Disposable, ItemOrigin, ModelEditor, ModelInfo, ModelsDomain } from '../api'\nimport type { DomainDeps } from '../runtime/deps'\nimport type { RefreshablePort } from './domain'\nimport type { CatalogDraft, CatalogOptions, CatalogValue, Sourced } from './engine'\nimport { addTransform, reloadWith } from './domain'\nimport { createCatalogSet } from './engine'\n\n/** The catalog id of a model: `<providerId>/<modelId>`. */\nexport function modelKey(providerId: string, modelId: string): string {\n return `${providerId}/${modelId}`\n}\n\n/** A model selection. */\nexport interface ModelSelection {\n /** Provider id. */\n readonly providerId: string\n /** Model id. */\n readonly modelId: string\n}\n\n/** Supplies the base models and default. The host connects the active providers (after `providers` transforms). */\nexport interface ModelsCatalogPort extends RefreshablePort {\n /** Models of the active providers. */\n models: () => readonly Sourced<ModelInfo>[]\n /** The configured default selection. */\n default?: () => ModelSelection | undefined\n}\n\n/** Catalog-wide model state. */\nexport interface ModelsState {\n /** The default selection. */\n default?: ModelSelection\n /** The extension whose transform set it. */\n defaultSetBy?: string\n}\n\n/** Section item types of the models catalog. */\nexport interface ModelsSections {\n /** Models, by {@link modelKey}. */\n models: ModelInfo\n}\n\n/** A replayed models value. `state.default` is cleared when its model is gone. */\nexport type ModelsValue = CatalogValue<ModelsSections, ModelsState>\n\n/** The shared models catalog a host builds once. */\nexport interface ModelsCatalog {\n /** The replayed value. */\n read: () => ModelsValue\n /** Adds a model outside the provider base (host use; extensions go through providers). */\n register: (model: ModelInfo, origin: ItemOrigin) => Disposable\n /** Re-reads the base and replays. */\n reload: () => Promise<void>\n /** Calls `listener` after each change. */\n subscribe: (listener: () => void) => () => void\n /**\n * Engine access for the domain factory.\n *\n * @internal\n */\n readonly engine: ReturnType<typeof createModelsEngine>\n}\n\nfunction createModelsEngine(port: ModelsCatalogPort, options: CatalogOptions) {\n return createCatalogSet<ModelsSections, ModelsState, void>({\n ...options,\n name: 'models',\n sections: { models: { key: model => modelKey(model.providerId, model.id), base: () => port.models() } },\n state: {\n base: () => {\n const selection = port.default?.()\n return selection ? { default: { ...selection } } : {}\n },\n clone: state => ({ ...state }),\n },\n })\n}\n\nfunction modelEditor(draft: CatalogDraft<ModelsSections, ModelsState, void>): ModelEditor {\n const models = draft.sections.models\n return {\n list: providerId => providerId === undefined ? models.list() : models.list().filter(model => model.providerId === providerId),\n get: (providerId, modelId) => models.get(modelKey(providerId, modelId)),\n update: (providerId, modelId, edit) => models.update(modelKey(providerId, modelId), edit),\n remove: (providerId, modelId) => models.remove(modelKey(providerId, modelId)),\n default: {\n get: () => {\n draft.assertOpen()\n return draft.state.default ? { ...draft.state.default } : undefined\n },\n set: (providerId, modelId) => {\n draft.assertOpen()\n if (!models.get(modelKey(providerId, modelId)))\n throw new Error(`models.default.set: no model \"${modelKey(providerId, modelId)}\"`)\n draft.state = { default: { providerId, modelId }, defaultSetBy: draft.extensionId }\n },\n },\n }\n}\n\n/** Creates the shared models catalog. */\nexport function createModelsCatalog(port: ModelsCatalogPort, options: CatalogOptions = {}): ModelsCatalog {\n const engine = createModelsEngine(port, options)\n return {\n engine,\n read: () => {\n const value = engine.read()\n const selection = value.state.default\n if (!selection || value.sections.models.get(modelKey(selection.providerId, selection.modelId)))\n return value\n return Object.freeze({ ...value, state: Object.freeze({}) })\n },\n register: (model, origin) => engine.register('models', model, origin),\n reload: reloadWith(engine, port),\n subscribe: engine.subscribe,\n }\n}\n\n/** Creates one extension's `ctx.models` over the shared catalog. */\nexport function createModelsDomain(deps: DomainDeps, catalog: ModelsCatalog): ModelsDomain {\n return {\n transform: fn => addTransform(deps, catalog.engine, 'models.transform', modelEditor, fn),\n reload: catalog.reload,\n list: () => catalog.read().sections.models.items,\n default: () => {\n const selection = catalog.read().state.default\n return selection ? { providerId: selection.providerId, modelId: selection.modelId } : undefined\n },\n }\n}\n","/**\n * The providers catalog: `ctx.providers`. Provider descriptors (active or\n * not) and the models each provider offers, edited together by one\n * {@link ProviderEditor} per transform. Removing a provider removes its\n * models. The host feeds the models of active providers into the models catalog.\n *\n * A provider can also hold a model list per account (`models.set(id, list,\n * { account })`): the list a picker shows for that account. Accounts without\n * one fall back to the provider's own list. Provider transforms read accounts,\n * so hosts re-run them when accounts change ({@link watchProviderAccounts}).\n */\n\nimport type { ProviderDescriptor } from '../../chat/providers'\nimport type { Disposable, ItemOrigin, ModelInfo, ProviderEditor, ProvidersDomain } from '../api'\nimport type { IntegrationRegistry } from '../integrations/registry'\nimport type { DomainDeps } from '../runtime/deps'\nimport type { RefreshablePort } from './domain'\nimport type { CatalogDraft, CatalogOptions, CatalogValue, Sourced } from './engine'\nimport { addTransform, extensionOrigin, owned, reloadWith } from './domain'\nimport { createCatalogSet } from './engine'\nimport { modelKey } from './models'\n\n/** Supplies the base descriptors and their models. The host connects the provider registry. */\nexport interface ProvidersCatalogPort extends RefreshablePort {\n /** Built-in and config provider descriptors. */\n providers: () => readonly Sourced<ProviderDescriptor>[]\n /** Models of those providers. */\n models?: () => readonly Sourced<ModelInfo>[]\n}\n\n/** Section item types of the providers catalog. */\nexport interface ProvidersSections {\n /** Descriptors, by `key`. */\n providers: ProviderDescriptor\n /** Models, by `<providerId>/<modelId>` (see {@link modelKey}). */\n models: ModelInfo\n /** Account-scoped models, by {@link accountModelKey}. */\n accountModels: AccountModelInfo\n}\n\n/** A model of one account's list (`models.set(providerId, list, { account })`). */\nexport interface AccountModelInfo extends ModelInfo {\n /** The account whose list holds it. */\n account: string\n}\n\n/**\n * The catalog id of an account-scoped model: `<providerId>@<account>/<modelId>`.\n *\n * @param providerId - Provider id.\n * @param account - The account the list belongs to.\n * @param modelId - Model id.\n */\nexport function accountModelKey(providerId: string, account: string, modelId: string): string {\n return `${providerId}@${account}/${modelId}`\n}\n\n/** A replayed providers value. */\nexport type ProvidersValue = CatalogValue<ProvidersSections, undefined>\n\n/** The shared providers catalog a host builds once. */\nexport interface ProvidersCatalog {\n /** The replayed value. */\n read: () => ProvidersValue\n /**\n * Models of one provider (or all), after transforms. With `account` (and a\n * provider): that account's own list when it has one, else the provider's.\n */\n models: (providerId?: string, opts?: { account?: string }) => readonly ModelInfo[]\n /** The accounts of a provider that have their own model list, in insertion order. */\n accounts: (providerId: string) => readonly string[]\n /** Adds a descriptor. */\n register: (descriptor: ProviderDescriptor, origin: ItemOrigin) => Disposable\n /** Re-reads the base and replays. */\n reload: () => Promise<void>\n /** Calls `listener` after each change. */\n subscribe: (listener: () => void) => () => void\n /**\n * Engine access for the domain factory.\n *\n * @internal\n */\n readonly engine: ReturnType<typeof createProvidersEngine>\n}\n\nfunction createProvidersEngine(port: ProvidersCatalogPort, options: CatalogOptions) {\n return createCatalogSet<ProvidersSections, undefined, void>({\n ...options,\n name: 'providers',\n sections: {\n providers: { key: descriptor => descriptor.key, base: () => port.providers() },\n models: { key: model => modelKey(model.providerId, model.id), base: () => port.models?.() ?? [] },\n accountModels: { key: model => accountModelKey(model.providerId, model.account, model.id), base: () => [] },\n },\n })\n}\n\nfunction providerEditor(draft: CatalogDraft<ProvidersSections, undefined, void>): ProviderEditor {\n const providers = draft.sections.providers\n const models = draft.sections.models\n const accountModels = draft.sections.accountModels\n const modelsOf = (providerId: string) => models.list().filter(model => model.providerId === providerId)\n const accountModelsOf = (providerId: string, account?: string) => accountModels.list().filter(model => model.providerId === providerId && (account === undefined || model.account === account))\n const checkOwner = (providerId: string, next: readonly ModelInfo[]): void => {\n for (const model of next) {\n if (model.providerId !== providerId)\n throw new Error(`providers.models.set: model \"${model.id}\" belongs to \"${model.providerId}\", not \"${providerId}\"`)\n }\n }\n return {\n list: providers.list,\n get: providers.get,\n origin: providers.origin,\n add: providers.add,\n update: providers.update,\n remove: (id) => {\n providers.remove(id)\n for (const model of modelsOf(id))\n models.remove(modelKey(id, model.id))\n for (const model of accountModelsOf(id))\n accountModels.remove(accountModelKey(id, model.account, model.id))\n },\n models: {\n set: (providerId, next, opts) => {\n checkOwner(providerId, next)\n const wanted = new Set(next.map(model => model.id))\n const account = opts?.account\n if (account !== undefined) {\n if (typeof account !== 'string' || account.length === 0)\n throw new TypeError('providers.models.set: account must be a non-empty string')\n for (const model of accountModelsOf(providerId, account)) {\n if (!wanted.has(model.id))\n accountModels.remove(accountModelKey(providerId, account, model.id))\n }\n for (const model of next)\n accountModels.replace({ ...model, account })\n return\n }\n for (const model of modelsOf(providerId)) {\n if (!wanted.has(model.id))\n models.remove(modelKey(providerId, model.id))\n }\n for (const model of next)\n models.replace(model)\n },\n // An edit by id applies to every list that holds the model: the provider's and each account's.\n update: (providerId, modelId, edit) => {\n models.update(modelKey(providerId, modelId), edit)\n for (const model of accountModelsOf(providerId)) {\n if (model.id === modelId)\n accountModels.update(accountModelKey(providerId, model.account, modelId), edit)\n }\n },\n remove: (providerId, modelId) => {\n models.remove(modelKey(providerId, modelId))\n for (const model of accountModelsOf(providerId)) {\n if (model.id === modelId)\n accountModels.remove(accountModelKey(providerId, model.account, modelId))\n }\n },\n },\n }\n}\n\n/** Creates the shared providers catalog. */\nexport function createProvidersCatalog(port: ProvidersCatalogPort, options: CatalogOptions = {}): ProvidersCatalog {\n const engine = createProvidersEngine(port, options)\n return {\n engine,\n read: () => engine.read(),\n models: (providerId, opts) => {\n const value = engine.read()\n if (providerId === undefined)\n return value.sections.models.items\n const account = opts?.account\n if (account !== undefined) {\n const own = value.sections.accountModels.items.filter(model => model.providerId === providerId && model.account === account)\n if (own.length > 0)\n return own.map(({ account: _account, ...model }) => model)\n }\n return value.sections.models.items.filter(model => model.providerId === providerId)\n },\n accounts: (providerId) => {\n const out = new Set<string>()\n for (const model of engine.read().sections.accountModels.items) {\n if (model.providerId === providerId)\n out.add(model.account)\n }\n return [...out]\n },\n register: (descriptor, origin) => engine.register('providers', descriptor, origin),\n reload: reloadWith(engine, port),\n subscribe: engine.subscribe,\n }\n}\n\n/** Creates one extension's `ctx.providers` over the shared catalog. */\nexport function createProvidersDomain(deps: DomainDeps, catalog: ProvidersCatalog): ProvidersDomain {\n return {\n register(descriptor) {\n if (!descriptor || typeof descriptor.key !== 'string' || descriptor.key.length === 0)\n throw new TypeError('providers.register: descriptor needs a non-empty key')\n if (typeof descriptor.factory !== 'function')\n throw new TypeError(`providers.register: \"${descriptor.key}\" needs a factory`)\n return owned(deps, 'providers.register', () => catalog.register(descriptor, extensionOrigin(deps)))\n },\n transform: fn => addTransform(deps, catalog.engine, 'providers.transform', providerEditor, fn),\n reload: catalog.reload,\n list: () => catalog.read().sections.providers.items,\n }\n}\n\n/** Something that says when provider accounts change. Returns the unsubscribe. */\nexport type AccountChangeSource = (listener: () => void) => () => void\n\n/**\n * Re-runs provider transforms (`catalog.reload()`) when accounts change: any\n * integration connection (connect, disconnect, a new default) and any other\n * source the host passes (its stored provider accounts). Changes in one turn\n * of the event loop reload once. Returns the unsubscribe.\n *\n * @param catalog - The providers catalog.\n * @param integrations - The integration registry, when the host has one.\n * @param sources - Other account change sources (the credentials file).\n */\nexport function watchProviderAccounts(catalog: Pick<ProvidersCatalog, 'reload'>, integrations: Pick<IntegrationRegistry, 'subscribe'> | undefined, sources: readonly AccountChangeSource[] = []): () => void {\n let queued = false\n let stopped = false\n const changed = (): void => {\n if (queued || stopped)\n return\n queued = true\n queueMicrotask(() => {\n queued = false\n if (!stopped)\n void catalog.reload()\n })\n }\n const offs = [...(integrations ? [integrations.subscribe(changed)] : []), ...sources.map(source => source(changed))]\n return () => {\n stopped = true\n for (const off of offs)\n off()\n }\n}\n"],"mappings":";;;;;;;;AAuBA,SAAS,gBAAgB,aAAqB,QAA6D;CACzG,OAAO,OAAO,KAAI,UAChB,MAAM,UAAU,CAAC,MAAM,OAAO,SAAS,SAAS,GAAG,IAC/C;EAAE,GAAG;EAAO,QAAQ;GAAE,GAAG,MAAM;GAAQ,UAAU,GAAG,YAAY,GAAG,MAAM,OAAO;EAAW;CAAE,IAC7F,KAAK;AACb;;;;;;;AAgBA,SAAgB,0BAA0B,OAA4C;CACpF,IAAI,UAAU,KAAA,GACZ,QAAQ,CAAC;CACX,IAAI,OAAO,UAAU,UACnB,MAAM,IAAI,kBAAkB,CAAC;EAAE,MAAM;EAAS,SAAS,qDAAqD,MAAM;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AAM;EACjF,QAAQ,WAAW,QAAQ,IAAI;EAC/B,WAAW,OAAO;CACpB;AACF;;AAGA,SAAgB,sBAAsB,MAAkB,SAA4C;CAClG,OAAO;EACL,SAAS,YAAY;GACnB,IAAI,CAAC,cAAc,OAAO,WAAW,QAAQ,YAAY,WAAW,IAAI,WAAW,GACjF,MAAM,IAAI,UAAU,sDAAsD;GAC5E,IAAI,OAAO,WAAW,YAAY,YAChC,MAAM,IAAI,UAAU,wBAAwB,WAAW,IAAI,kBAAkB;GAC/E,OAAO,MAAM,MAAM,4BAA4B,QAAQ,SAAS,YAAY,gBAAgB,IAAI,CAAC,CAAC;EACpG;EACA,YAAW,OAAM,aAAa,MAAM,QAAQ,QAAQ,uBAAuB,gBAAgB,EAAE;EAC7F,QAAQ,QAAQ;EAChB,YAAY,QAAQ,KAAK,CAAC,CAAC,SAAS,UAAU;CAChD;AACF;;;;;;;;;;;AAeA,SAAgB,sBAAsB,SAA2C,cAAkE,UAA0C,CAAC,GAAe;CAC3M,IAAI,SAAS;CACb,IAAI,UAAU;CACd,MAAM,gBAAsB;EAC1B,IAAI,UAAU,SACZ;EACF,SAAS;EACT,qBAAqB;GACnB,SAAS;GACT,IAAI,CAAC,SACH,QAAa,OAAO;EACxB,CAAC;CACH;CACA,MAAM,OAAO,CAAC,GAAI,eAAe,CAAC,aAAa,UAAU,OAAO,CAAC,IAAI,CAAC,GAAI,GAAG,QAAQ,KAAI,WAAU,OAAO,OAAO,CAAC,CAAC;CACnH,aAAa;EACX,UAAU;EACV,KAAK,MAAM,OAAO,MAChB,IAAI;CACR;AACF"}
|
|
1
|
+
{"version":3,"file":"providers-CsYrxuX1.js","names":[],"sources":["../src/extensions/runtime/domains/sessions.ts","../src/extensions/catalog/clone.ts","../src/extensions/catalog/engine.ts","../src/extensions/catalog/domain.ts","../src/extensions/catalog/models.ts","../src/extensions/catalog/providers.ts"],"sourcesContent":["/**\n * `ctx.sessions` (extension API): the orchestration verbs mapped 1:1,\n * plus the lifecycle verbs. Everything goes through the host's\n * session control, acting as the extension, so what it creates is tagged\n * with the extension id. Without a host, or when the host lacks a verb, the\n * call rejects with a message naming both.\n */\n\nimport type { CommandOutputBlock } from '../../../chat/commands'\nimport type { SessionQuery, SessionQueryIssue, SessionSort } from '../../../chat/session-query'\nimport type { SessionListQuery, SessionListRow, SessionsDomain } from '../../api/sessions'\nimport type { ExtensionSessionLifecycleVerbs, ExtensionSessionRow, ExtensionSessionVerbs } from '../../host-runtime'\nimport type { DomainDeps } from '../deps'\nimport type { SessionsPort } from './ports'\nimport { projectNameOf, querySessions, SessionQueryError, validateQuery, validateSort } from '../../../chat/session-query'\nimport { assertUsable } from '../owner'\n\ntype Verbs = ExtensionSessionVerbs & ExtensionSessionLifecycleVerbs\n\n/**\n * Prefixes bare renderer ids of `custom` blocks with the extension id, as\n * `ctx.appendNote` does.\n */\nfunction namespaceBlocks(extensionId: string, blocks: readonly CommandOutputBlock[]): CommandOutputBlock[] {\n return blocks.map(block =>\n block.custom && !block.custom.renderer.includes('/')\n ? { ...block, custom: { ...block.custom, renderer: `${extensionId}/${block.custom.renderer}` } }\n : block)\n}\n\n/** Rows per page of `ctx.sessions.list` when the query names none, and the most it hands out. */\nexport const SESSION_LIST_DEFAULT_LIMIT = 30\n/** The most rows one `ctx.sessions.list` page holds. */\nexport const SESSION_LIST_MAX_LIMIT = 100\n\n/** A list query with its defaults filled, as the host's `query` verb gets it. */\nexport type NormalizedSessionListQuery = Parameters<NonNullable<ExtensionSessionLifecycleVerbs['query']>>[0]\n\n/**\n * Checks a `ctx.sessions.list` query and fills its defaults. Throws a\n * `SessionQueryError` naming every problem.\n *\n * @param query - The query as the extension gave it.\n */\nexport function normalizeSessionListQuery(query: unknown): NormalizedSessionListQuery {\n if (query === undefined)\n query = {}\n if (typeof query === 'number')\n throw new SessionQueryError([{ path: 'query', message: `list takes a query object now: call list({ limit: ${query} })` }])\n if (!query || typeof query !== 'object' || Array.isArray(query))\n throw new SessionQueryError([{ path: 'query', message: 'must be { where?, sort?, limit?, cursor?, archived? }' }])\n const q = query as Record<string, unknown>\n const issues: SessionQueryIssue[] = []\n for (const key of Object.keys(q)) {\n if (!['where', 'sort', 'limit', 'cursor', 'archived'].includes(key))\n issues.push({ path: key, message: 'unknown key; a list query holds where, sort, limit, cursor and archived' })\n }\n if (q.where !== undefined)\n issues.push(...validateQuery(q.where))\n if (q.sort !== undefined)\n issues.push(...validateSort(q.sort))\n const limit = q.limit ?? SESSION_LIST_DEFAULT_LIMIT\n if (!Number.isInteger(limit) || (limit as number) < 1 || (limit as number) > SESSION_LIST_MAX_LIMIT)\n issues.push({ path: 'limit', message: `must be a whole number from 1 to ${SESSION_LIST_MAX_LIMIT}` })\n if (q.cursor !== undefined && (typeof q.cursor !== 'string' || q.cursor.length === 0))\n issues.push({ path: 'cursor', message: 'must be the cursor of a previous page' })\n if (q.archived !== undefined && typeof q.archived !== 'boolean' && q.archived !== 'all')\n issues.push({ path: 'archived', message: 'must be true, false or \\'all\\'' })\n if (issues.length > 0)\n throw new SessionQueryError(issues)\n return {\n ...(q.where !== undefined ? { where: q.where as NonNullable<SessionListQuery['where']> } : {}),\n sort: (q.sort as SessionListQuery['sort']) ?? [{ field: 'updatedAt', dir: 'desc' }],\n limit: limit as number,\n ...(q.cursor !== undefined ? { cursor: q.cursor as string } : {}),\n archived: (q.archived as SessionListQuery['archived']) ?? false,\n }\n}\n\n/**\n * Every field path a query reads (conditions at any depth) and a sort reads,\n * as written (`facet.<ext>.<key>` paths whole).\n *\n * @param where - The query.\n * @param sort - The sort keys.\n */\nexport function fieldsReadBy(where: SessionQuery | undefined, sort: readonly SessionSort[] = []): Set<string> {\n const out = new Set<string>(sort.map(s => s.field))\n const walk = (q: SessionQuery): void => {\n if ('field' in q)\n out.add(q.field)\n else if ('all' in q)\n q.all.forEach(walk)\n else if ('any' in q)\n q.any.forEach(walk)\n else if ('not' in q)\n walk(q.not)\n }\n if (where)\n walk(where)\n return out\n}\n\n/** The fields an orchestration row fills (`orchestrationRow`): what a host without the `query` verb can filter and sort on. */\nconst ORCHESTRATION_FIELDS: ReadonlySet<string> = new Set(['id', 'title', 'cwd', 'projectName', 'status', 'updatedAt', 'archived'])\n\nfunction isDefaultSort(sort: readonly SessionSort[]): boolean {\n return sort.length === 1 && sort[0]!.field === 'updatedAt' && sort[0]!.dir === 'desc'\n}\n\n/** An orchestration row as a list row: the fields it has, no facets. */\nfunction orchestrationRow(row: ExtensionSessionRow): SessionListRow {\n return { id: row.sessionId, title: row.title, projectRoot: null, projectName: projectNameOf({ cwd: row.cwd }) ?? '', cwd: row.cwd, status: row.state, updatedAt: row.updatedAt, archived: false, worker: row.worker, facets: {} }\n}\n\n/**\n * Creates one extension's `ctx.sessions`.\n *\n * @param deps - The extension's id, owner, guard and logger.\n * @param port - The host's session control and prompt bridge.\n * @returns The domain without `facets` (the context adds them). Every call rejects with `DisposedError` once the owner is torn down (an unload waits for the calls in flight first).\n */\nexport function createSessionsDomain(deps: DomainDeps, port: SessionsPort): Omit<SessionsDomain, 'facets'> {\n const { extensionId, owner } = deps\n\n const verbs = (method: string): Verbs => {\n assertUsable(owner, `sessions.${method}`)\n const control = port.sessionControl()\n if (!control)\n throw new Error(`sessions.${method}: no chat host is attached (extension \"${extensionId}\").`)\n return control.verbs(extensionId)\n }\n\n /** The lifecycle verb `method`, or a rejection when the host does not implement it. */\n const lifecycle = <K extends keyof ExtensionSessionLifecycleVerbs>(method: K): NonNullable<Verbs[K]> => {\n const all = verbs(method)\n const verb = all[method]\n if (typeof verb !== 'function')\n throw new Error(`sessions.${method}: this host does not support it (extension \"${extensionId}\").`)\n return verb.bind(all) as NonNullable<Verbs[K]>\n }\n\n return {\n create: async params => verbs('create').create(params),\n list: async (query) => {\n const all = verbs('list')\n const q = normalizeSessionListQuery(query)\n if (typeof all.query === 'function')\n return all.query(q)\n // A host without the query verb: its newest orchestration rows, filtered here. A query that needs more fails rather than answering wrong.\n const unsupported = (why: string): Error => new Error(`sessions.list: this host does not support queries (extension \"${extensionId}\"): ${why}.`)\n const missing = [...fieldsReadBy(q.where, q.sort)].filter(f => !ORCHESTRATION_FIELDS.has(f))\n if (missing.length > 0)\n throw unsupported(`it lists only ${[...ORCHESTRATION_FIELDS].join(', ')}, not ${missing.join(', ')}`)\n if (q.archived !== false)\n throw unsupported('it lists no archived sessions')\n const listed = await all.list(SESSION_LIST_MAX_LIMIT)\n const truncated = listed.length >= SESSION_LIST_MAX_LIMIT\n if (truncated && (q.where !== undefined || !isDefaultSort(q.sort)))\n throw unsupported(`it lists only its ${SESSION_LIST_MAX_LIMIT} newest sessions, so it can only page them newest first, unfiltered`)\n const page = querySessions(listed.map(orchestrationRow), { ...q, scope: q.archived })\n // A page that ends exactly at the last listed row is whole (no cursor); one cut short by the end of the list may miss older sessions.\n if (truncated && page.cursor === undefined && page.rows.length < q.limit)\n throw unsupported(`it lists only its ${SESSION_LIST_MAX_LIMIT} newest sessions; this page reaches past them`)\n return page\n },\n read: async sessionId => verbs('read').read(sessionId),\n send: async (sessionId, prompt) => verbs('send').send(sessionId, prompt),\n steer: async (sessionId, message) => verbs('steer').steer(sessionId, message),\n cancel: async sessionId => verbs('cancel').cancel(sessionId),\n transcript: async (sessionId, limit) => verbs('transcript').transcript(sessionId, limit),\n wait: async (sessionId, timeoutSec) => verbs('wait').wait(sessionId, timeoutSec),\n events: async query => verbs('events').events(query),\n pending: async sessionId => verbs('pending').pending(sessionId),\n answer: async (requestId, response) => verbs('answer').answer(requestId, response),\n approve: async (requestId, decision) => verbs('approve').approve(requestId, decision),\n\n get: async sessionId => lifecycle('get')(sessionId),\n remove: async sessionId => lifecycle('remove')(sessionId),\n compact: async sessionId => lifecycle('compact')(sessionId),\n switchModel: async (sessionId, model) => lifecycle('switchModel')(sessionId, model),\n switchAgent: async (sessionId, agentId) => lifecycle('switchAgent')(sessionId, agentId),\n setThinking: async (sessionId, level) => lifecycle('setThinking')(sessionId, level),\n synthetic: async (sessionId, message) => lifecycle('synthetic')(sessionId, message),\n note: async (sessionId, blocks) => lifecycle('note')(sessionId, namespaceBlocks(extensionId, blocks)),\n\n submit: async (text, opts = {}) => {\n const delivery = opts.delivery ? { delivery: opts.delivery } : undefined\n if (opts.sessionId !== undefined)\n return lifecycle('submit')(opts.sessionId, text, delivery)\n // The session in view: the host's prompt pipeline, as `ctx.submitPrompt`.\n assertUsable(owner, 'sessions.submit')\n if (!port.promptBridge)\n throw new Error(`sessions.submit: this host has no prompt pipeline; pass a sessionId (extension \"${extensionId}\").`)\n return port.promptBridge.submit(text, delivery)\n },\n }\n}\n","/**\n * Copy-on-edit cloning for catalog items. Items mix plain data (specs,\n * presets, labels) with functions and class instances (`execute`,\n * `factory`, OAuth providers, zod schemas). Only the plain data is copied;\n * everything else is shared by reference, so an edit never reaches a value\n * an earlier read handed out.\n */\n\n/** `true` for arrays and objects whose prototype is `Object.prototype` or `null`. */\nfunction isPlain(value: unknown): value is Record<string, unknown> | unknown[] {\n if (Array.isArray(value))\n return true\n if (value === null || typeof value !== 'object')\n return false\n const proto = Object.getPrototypeOf(value)\n return proto === Object.prototype || proto === null\n}\n\n/**\n * Deep-copies arrays and plain objects. Functions, class instances, Maps,\n * Sets and primitives are kept as they are. Cycles are preserved.\n */\nexport function clonePlain<T>(value: T): T {\n const seen = new Map<object, unknown>()\n const walk = (v: unknown): unknown => {\n if (!isPlain(v))\n return v\n const hit = seen.get(v)\n if (hit !== undefined)\n return hit\n if (Array.isArray(v)) {\n const out: unknown[] = []\n seen.set(v, out)\n for (const item of v)\n out.push(walk(item))\n return out\n }\n const out: Record<string, unknown> = Object.create(Object.getPrototypeOf(v))\n seen.set(v, out)\n for (const key of Object.keys(v))\n out[key] = walk(v[key])\n return out\n }\n return walk(value) as T\n}\n","/**\n * The catalog transform engine shared by every extension catalog (tools, agents,\n * models, providers, MCP servers, skills).\n *\n * A catalog value is rebuilt by replay: the base items (built-ins, config),\n * then registrations in the order they were made, then every transform in\n * extension load order. The result is memoized until a registration,\n * transform or `reload()` changes it. Each item records who added,\n * modified or removed it, so Settings can name the extension, and disposing\n * the extension's registrations restores the item on the next read.\n *\n * Edits are copy-on-edit: `update` clones the item before the transform\n * sees it, so a value an earlier read handed out is never mutated. A\n * transform that throws is rolled back as a whole and reported.\n */\n\nimport type { Disposable, ItemOrigin } from '../api'\nimport type { Guard } from '../runtime/deps'\nimport { clonePlain } from './clone'\n\n/** An item with the origin a base or registration gives it. */\nexport interface Sourced<T> {\n /** The item. */\n readonly item: T\n /** Who put it in the catalog. */\n readonly origin: ItemOrigin\n}\n\n/** One keyed collection inside a catalog. */\nexport interface SectionSpec<T, C> {\n /** The id of an item. Must be a non-empty string. */\n key: (item: T) => string\n /** The base items for a context: built-ins and config. Cached until `reload()`. */\n base: (context: C) => readonly Sourced<T>[]\n /** Copy used by `update`. Default: {@link clonePlain}. */\n clone?: (item: T) => T\n}\n\n/** Catalog-wide state beside the sections (a default id, auto-invoked names). */\nexport interface StateSpec<X, C> {\n /** The state before any transform. */\n base: (context: C) => X\n /** Copy taken before each transform, restored when it throws. */\n clone: (state: X) => X\n}\n\n/** Who touched one id. Removed ids keep theirs with `removedBy`. */\nexport interface Provenance {\n /** The item id. */\n readonly id: string\n /** Who put the item in the catalog. A transform's `add` makes it `{ kind: 'extension' }`. */\n readonly origin: ItemOrigin\n /** The origin of an item this one replaced at registration (same id). */\n readonly replaced?: ItemOrigin\n /** The extension whose transform added the item. */\n readonly addedBy?: string\n /** Extensions whose transforms edited the item, in replay order. */\n readonly modifiedBy: readonly string[]\n /** The extension whose transform removed the item. */\n readonly removedBy?: string\n}\n\n/** A transform that threw during replay; its edits were rolled back. */\nexport interface TransformFailure {\n /** The extension that registered the transform. */\n readonly extensionId: string\n /** The guard label it ran under. */\n readonly label: string\n}\n\n/** One section of a replayed catalog value. Frozen. */\nexport interface SectionValue<T> {\n /** The items, in insertion order. */\n readonly items: readonly T[]\n /** The item with this id. */\n get: (id: string) => T | undefined\n /** The origin of a present item. */\n origin: (id: string) => ItemOrigin | undefined\n /** Who touched an id, present or removed. */\n provenance: (id: string) => Provenance | undefined\n /** Provenance of every id, present ones first, then removed ones. */\n readonly entries: readonly Provenance[]\n}\n\n/** A replayed catalog value. Never mutated after it is returned. */\nexport interface CatalogValue<S extends Sections, X> {\n /** Every section after replay. */\n readonly sections: { readonly [K in keyof S]: SectionValue<S[K]> }\n /** The state after replay. */\n readonly state: Readonly<X>\n /** Transforms that threw and were skipped. */\n readonly failures: readonly TransformFailure[]\n}\n\n/** The section item types of a catalog, by section name (an object type such as `{ tools: NamedTool }`). */\nexport type Sections = object\n\n/** The editable form of a section that a transform works on. */\nexport interface SectionDraft<T> {\n /** Present items, in order. Treat them as read-only; edit through `update`. */\n list: () => readonly T[]\n /** The item with this id. Read-only, like `list`. */\n get: (id: string) => T | undefined\n /** Origin of a present item. */\n origin: (id: string) => ItemOrigin | undefined\n /** Adds an item, or replaces the one with the same id. */\n add: (item: T) => void\n /** Edits a clone of the item. A missing id is a no-op. The edit must keep the id. */\n update: (id: string, edit: (item: T) => void) => void\n /** Puts `item` in place of the item with its id (or adds it), marking it modified. */\n replace: (item: T) => void\n /** Removes an item. A missing id is a no-op. */\n remove: (id: string) => void\n /** A clone of an item, for callbacks that may mutate what they get. */\n cloneOf: (id: string) => T | undefined\n}\n\n/** What a transform gets: every section, the state, and who is editing. */\nexport interface CatalogDraft<S extends Sections, X, C> {\n /** The sections. */\n readonly sections: { readonly [K in keyof S]: SectionDraft<S[K]> }\n /** The state. Replace or mutate it; it is cloned before each transform. */\n state: X\n /** The context the catalog is read for. */\n readonly context: C\n /** The extension whose transform is running. */\n readonly extensionId: string\n /** Throws when the transform already returned (an editor kept past its call). */\n assertOpen: () => void\n}\n\n/** A transform registration. */\nexport interface TransformRegistration<S extends Sections, X, C> {\n /** The extension that owns the transform (orders replay and attributes edits). */\n extensionId: string\n /** Runs the transform with error attribution. */\n guard: Guard\n /** Guard label. Default: `<catalog>.transform`. */\n label?: string\n /** Edits the draft. */\n apply: (draft: CatalogDraft<S, X, C>) => void\n}\n\n/** Options shared by every catalog. */\nexport interface CatalogOptions {\n /** Load-order rank of an extension; lower replays first. Ties keep registration order. */\n order?: (extensionId: string) => number\n /** Most memoized values kept (one per context key). Default 32. */\n cacheSize?: number\n}\n\n/** Spec of a multi-section catalog. */\nexport interface CatalogSetSpec<S extends Sections, X, C> extends CatalogOptions {\n /** Name used in guard labels and errors. */\n name: string\n /** The sections. */\n sections: { [K in keyof S]: SectionSpec<S[K], C> }\n /** Optional catalog-wide state. */\n state?: StateSpec<X, C>\n /** Memo key of a context. `undefined` means \"don't memoize\". Default: one key for all. */\n contextKey?: (context: C) => string | undefined\n}\n\n/** A shared catalog: registrations, transforms, replayed reads. */\nexport interface CatalogSet<S extends Sections, X, C> {\n /** Catalog name. */\n readonly name: string\n /** Adds an item to a section after the base. A later registration of the same id replaces an earlier one. */\n register: <K extends keyof S>(section: K, item: S[K], origin: ItemOrigin) => Disposable\n /** Adds a transform. Replays in `order`, then registration order. */\n transform: (registration: TransformRegistration<S, X, C>) => Disposable\n /** Drops the cached base and every memoized value, then notifies. */\n reload: () => void\n /** The replayed value for a context, memoized until the next change. */\n read: (context: C) => CatalogValue<S, X>\n /** Calls `listener` after each change (the next `read` replays). Returns the unsubscribe. */\n subscribe: (listener: () => void) => () => void\n}\n\ninterface Entry<T> extends Provenance { readonly item: T }\n\ninterface Gate { open: boolean, extensionId: string }\n\nconst BUILTIN: ItemOrigin = Object.freeze({ kind: 'builtin' })\n\nfunction withExtension(list: readonly string[], extensionId: string): readonly string[] {\n return list.includes(extensionId) ? list : [...list, extensionId]\n}\n\nfunction provenanceOf<T>(entry: Entry<T>): Provenance {\n const { item: _item, ...rest } = entry\n return rest\n}\n\nclass SectionDraftImpl<T> implements SectionDraft<T> {\n entries = new Map<string, Entry<T>>()\n removed = new Map<string, Provenance>()\n\n constructor(private readonly name: string, private readonly spec: SectionSpec<T, unknown>, private readonly gate: Gate) {}\n\n idOf(item: T): string {\n const id = this.spec.key(item)\n if (typeof id !== 'string' || id.length === 0)\n throw new TypeError(`${this.name}: item needs a non-empty string id`)\n return id\n }\n\n seed(item: T, origin: ItemOrigin): void {\n const id = this.idOf(item)\n const prev = this.entries.get(id)\n this.entries.set(id, { id, item, origin, modifiedBy: [], ...(prev ? { replaced: prev.origin } : {}) })\n }\n\n private check(): void {\n if (!this.gate.open)\n throw new Error(`${this.name}: the editor was used after its transform returned`)\n }\n\n private cloneItem(item: T): T {\n return (this.spec.clone ?? clonePlain)(item)\n }\n\n list = (): readonly T[] => {\n this.check()\n return [...this.entries.values()].map(entry => entry.item)\n }\n\n get = (id: string): T | undefined => {\n this.check()\n return this.entries.get(id)?.item\n }\n\n origin = (id: string): ItemOrigin | undefined => {\n this.check()\n return this.entries.get(id)?.origin\n }\n\n cloneOf = (id: string): T | undefined => {\n this.check()\n const entry = this.entries.get(id)\n return entry ? this.cloneItem(entry.item) : undefined\n }\n\n add = (item: T): void => {\n this.check()\n const id = this.idOf(item)\n const ext = this.gate.extensionId\n const prev = this.entries.get(id) ?? this.removed.get(id)\n this.removed.delete(id)\n if (prev) {\n const { removedBy: _removedBy, ...rest } = provenanceOf(prev as Entry<T>)\n this.entries.set(id, { ...rest, item, modifiedBy: withExtension(prev.modifiedBy, ext) })\n return\n }\n this.entries.set(id, { id, item, origin: { kind: 'extension', id: ext }, addedBy: ext, modifiedBy: [] })\n }\n\n update = (id: string, edit: (item: T) => void): void => {\n this.check()\n const prev = this.entries.get(id)\n if (!prev)\n return\n const copy = this.cloneItem(prev.item)\n edit(copy)\n if (this.idOf(copy) !== id)\n throw new Error(`${this.name}: update must not change the id of \"${id}\"`)\n this.entries.set(id, { ...prev, item: copy, modifiedBy: withExtension(prev.modifiedBy, this.gate.extensionId) })\n }\n\n replace = (item: T): void => {\n this.check()\n const id = this.idOf(item)\n const prev = this.entries.get(id)\n if (!prev) {\n this.add(item)\n return\n }\n this.entries.set(id, { ...prev, item, modifiedBy: withExtension(prev.modifiedBy, this.gate.extensionId) })\n }\n\n remove = (id: string): void => {\n this.check()\n const prev = this.entries.get(id)\n if (!prev)\n return\n this.entries.delete(id)\n this.removed.set(id, { ...provenanceOf(prev), removedBy: this.gate.extensionId })\n }\n\n checkpoint(): () => void {\n const entries = new Map(this.entries)\n const removed = new Map(this.removed)\n return () => {\n this.entries = entries\n this.removed = removed\n }\n }\n\n freeze(): SectionValue<T> {\n const entries = new Map(this.entries)\n const provenance = new Map<string, Provenance>()\n for (const [id, entry] of entries)\n provenance.set(id, Object.freeze(provenanceOf(entry)))\n for (const [id, prov] of this.removed)\n provenance.set(id, Object.freeze(prov))\n return Object.freeze({\n items: Object.freeze([...entries.values()].map(entry => entry.item)),\n get: (id: string) => entries.get(id)?.item,\n origin: (id: string) => entries.get(id)?.origin,\n provenance: (id: string) => provenance.get(id),\n entries: Object.freeze([...provenance.values()]),\n })\n }\n}\n\ninterface StoredRegistration { seq: number, section: PropertyKey, item: unknown, origin: ItemOrigin }\ninterface StoredTransform<S extends Sections, X, C> extends TransformRegistration<S, X, C> { seq: number }\n\n/** Creates a catalog with several sections and optional state. */\nexport function createCatalogSet<S extends Sections, X = undefined, C = void>(spec: CatalogSetSpec<S, X, C>): CatalogSet<S, X, C> {\n const sectionNames = Object.keys(spec.sections) as (keyof S & string)[]\n const registrations: StoredRegistration[] = []\n const transforms: StoredTransform<S, X, C>[] = []\n const baseCache = new Map<string, { [K in keyof S]: readonly Sourced<S[K]>[] }>()\n const valueCache = new Map<string, CatalogValue<S, X>>()\n const listeners = new Set<() => void>()\n const cacheSize = spec.cacheSize ?? 32\n let seq = 0\n\n const notify = (): void => {\n for (const listener of [...listeners]) {\n try {\n listener()\n }\n catch {\n // A host listener must not break other listeners or the registration.\n }\n }\n }\n\n const invalidate = (): void => {\n valueCache.clear()\n notify()\n }\n\n const baseFor = (context: C, key: string | undefined): { [K in keyof S]: readonly Sourced<S[K]>[] } => {\n const hit = key === undefined ? undefined : baseCache.get(key)\n if (hit)\n return hit\n const base = {} as { [K in keyof S]: readonly Sourced<S[K]>[] }\n for (const name of sectionNames)\n base[name] = spec.sections[name].base(context)\n if (key !== undefined)\n baseCache.set(key, base)\n return base\n }\n\n const rank = (extensionId: string): number => {\n const value = spec.order?.(extensionId)\n return typeof value === 'number' && Number.isFinite(value) ? value : Number.MAX_SAFE_INTEGER\n }\n\n const build = (context: C, key: string | undefined): CatalogValue<S, X> => {\n const gate: Gate = { open: false, extensionId: '' }\n const drafts = {} as { [K in keyof S]: SectionDraftImpl<S[K]> }\n const base = baseFor(context, key)\n for (const name of sectionNames) {\n const draft = new SectionDraftImpl<S[typeof name]>(`${spec.name}.${name}`, spec.sections[name] as SectionSpec<S[typeof name], unknown>, gate)\n for (const { item, origin } of base[name])\n draft.seed(item, origin ?? BUILTIN)\n drafts[name] = draft\n }\n for (const reg of registrations)\n (drafts[reg.section as keyof S] as SectionDraftImpl<unknown>).seed(reg.item, reg.origin)\n\n const draft: CatalogDraft<S, X, C> = {\n sections: drafts,\n state: (spec.state ? spec.state.base(context) : undefined) as X,\n context,\n get extensionId() { return gate.extensionId },\n assertOpen: () => {\n if (!gate.open)\n throw new Error(`${spec.name}: the editor was used after its transform returned`)\n },\n }\n\n const failures: TransformFailure[] = []\n const ordered = [...transforms].sort((a, b) => rank(a.extensionId) - rank(b.extensionId) || a.seq - b.seq)\n for (const transform of ordered) {\n const restores = sectionNames.map(name => drafts[name].checkpoint())\n const savedState = spec.state ? spec.state.clone(draft.state) : draft.state\n const label = transform.label ?? `${spec.name}.transform`\n gate.open = true\n gate.extensionId = transform.extensionId\n let ok = false\n try {\n ok = transform.guard.callSync(label, () => {\n transform.apply(draft)\n return true\n }, { fallback: false }) === true\n }\n catch {\n ok = false\n }\n finally {\n gate.open = false\n }\n if (!ok) {\n for (const restore of restores)\n restore()\n draft.state = savedState\n failures.push(Object.freeze({ extensionId: transform.extensionId, label }))\n }\n }\n\n const sections = {} as { [K in keyof S]: SectionValue<S[K]> }\n for (const name of sectionNames)\n sections[name] = drafts[name].freeze()\n return Object.freeze({ sections: Object.freeze(sections), state: draft.state, failures: Object.freeze(failures) })\n }\n\n return {\n name: spec.name,\n register(section, item, origin) {\n if (!sectionNames.includes(section as keyof S & string))\n throw new TypeError(`${spec.name}: unknown section \"${String(section)}\"`)\n const id = spec.sections[section].key(item)\n if (typeof id !== 'string' || id.length === 0)\n throw new TypeError(`${spec.name}.${String(section)}: item needs a non-empty string id`)\n const stored: StoredRegistration = { seq: seq++, section, item, origin }\n registrations.push(stored)\n invalidate()\n return once(() => {\n const index = registrations.indexOf(stored)\n if (index >= 0) {\n registrations.splice(index, 1)\n invalidate()\n }\n })\n },\n transform(registration) {\n if (typeof registration.apply !== 'function')\n throw new TypeError(`${spec.name}: transform must be a function`)\n const stored: StoredTransform<S, X, C> = { ...registration, seq: seq++ }\n transforms.push(stored)\n invalidate()\n return once(() => {\n const index = transforms.indexOf(stored)\n if (index >= 0) {\n transforms.splice(index, 1)\n invalidate()\n }\n })\n },\n reload() {\n baseCache.clear()\n invalidate()\n },\n read(context) {\n const key = spec.contextKey ? spec.contextKey(context) : ''\n if (key !== undefined) {\n const hit = valueCache.get(key)\n if (hit)\n return hit\n }\n const value = build(context, key)\n if (key !== undefined) {\n valueCache.set(key, value)\n if (valueCache.size > cacheSize)\n valueCache.delete(valueCache.keys().next().value as string)\n }\n return value\n },\n subscribe(listener) {\n listeners.add(listener)\n return () => {\n listeners.delete(listener)\n }\n },\n }\n}\n\n/** Spec of a single-section catalog. */\nexport interface CatalogSpec<T> extends CatalogOptions {\n /** Name used in guard labels and errors. Default `'catalog'`. */\n name?: string\n /** The id of an item. */\n key: (item: T) => string\n /** The base items. Plain items are `builtin`; give `Sourced` entries for another origin. */\n base: () => readonly (T | Sourced<T>)[]\n /** Copy used by `update`. Default: {@link clonePlain}. */\n clone?: (item: T) => T\n /** Tells a `Sourced` entry from a plain item. Default: an object with exactly `item` and `origin`. */\n isSourced?: (entry: T | Sourced<T>) => entry is Sourced<T>\n}\n\n/** A single-section catalog. */\nexport interface Catalog<T> {\n /** Adds an item after the base. */\n register: (item: T, origin: ItemOrigin) => Disposable\n /** Adds a transform owned by `extensionId`, run through `guard`. */\n transform: (fn: (editor: SectionDraft<T>) => void, extensionId: string, guard: Guard) => Disposable\n /** Re-reads the base and replays. */\n reload: () => void\n /** The replayed items, memoized until the next change. */\n read: () => readonly T[]\n /** The replayed section, with provenance. */\n value: () => SectionValue<T>\n /** Transforms that threw on the last replay. */\n failures: () => readonly TransformFailure[]\n /** Calls `listener` after each change. */\n subscribe: (listener: () => void) => () => void\n}\n\nfunction defaultIsSourced<T>(entry: T | Sourced<T>): entry is Sourced<T> {\n if (entry === null || typeof entry !== 'object')\n return false\n const keys = Object.keys(entry)\n return keys.length === 2 && keys.includes('item') && keys.includes('origin')\n}\n\n/** Creates a catalog with one keyed collection: the generic transform engine. */\nexport function createCatalog<T>(spec: CatalogSpec<T>): Catalog<T> {\n const isSourced = spec.isSourced ?? defaultIsSourced\n const set = createCatalogSet<{ items: T }, undefined, void>({\n name: spec.name ?? 'catalog',\n order: spec.order,\n cacheSize: spec.cacheSize,\n sections: {\n items: {\n key: spec.key,\n clone: spec.clone,\n base: () => spec.base().map(entry => isSourced(entry) ? entry : { item: entry, origin: BUILTIN }),\n },\n },\n })\n return {\n register: (item, origin) => set.register('items', item, origin),\n transform: (fn, extensionId, guard) => set.transform({ extensionId, guard, apply: draft => fn(draft.sections.items) }),\n reload: set.reload,\n read: () => set.read().sections.items.items,\n value: () => set.read().sections.items,\n failures: () => set.read().failures,\n subscribe: set.subscribe,\n }\n}\n\n/** Wraps a function so it runs at most once: the Disposable contract. */\nexport function once(fn: () => void): Disposable {\n let done = false\n return {\n dispose() {\n if (done)\n return\n done = true\n fn()\n },\n }\n}\n","/**\n * Glue between the shared catalogs and one extension's domain: owner\n * binding, guarded transforms, extension origins.\n */\n\nimport type { Disposable, ItemOrigin, Transform } from '../api'\nimport type { DomainDeps } from '../runtime/deps'\nimport type { CatalogDraft, CatalogSet, Sections } from './engine'\nimport { DisposedError } from '../api'\nimport { once } from './engine'\n\n/** A host port that can re-read external data before a catalog replays. */\nexport interface RefreshablePort {\n /** Re-reads the base (config files, a server list). `reload()` awaits it before replaying. */\n refresh?: () => Promise<void>\n}\n\n/** The origin of items the extension registers. */\nexport function extensionOrigin(deps: DomainDeps): ItemOrigin {\n return { kind: 'extension', id: deps.extensionId }\n}\n\n/**\n * Makes a registration through the extension's owner: refused once the owner\n * is disposed, withdrawn when it is, and withdrawable on its own.\n */\nexport function owned(deps: DomainDeps, what: string, make: () => Disposable): Disposable {\n if (deps.owner.disposed)\n throw new DisposedError(what)\n const inner = make()\n let cleanup: Disposable | undefined\n const handle = once(() => {\n cleanup?.dispose()\n inner.dispose()\n })\n cleanup = deps.owner.onCleanup(() => handle.dispose())\n return handle\n}\n\n/** Registers `fn` as a guarded transform of `set`, with the editor `makeEditor` builds. */\nexport function addTransform<S extends Sections, X, C, E>(\n deps: DomainDeps,\n set: CatalogSet<S, X, C>,\n what: string,\n makeEditor: (draft: CatalogDraft<S, X, C>) => E,\n fn: Transform<E>,\n): Disposable {\n if (typeof fn !== 'function')\n throw new TypeError(`${what}: transform must be a function`)\n return owned(deps, what, () => set.transform({\n extensionId: deps.extensionId,\n guard: deps.guard,\n label: what,\n apply: draft => fn(makeEditor(draft)),\n }))\n}\n\n/** `reload()` of a catalog domain: refresh the port, then drop the cached base. */\nexport function reloadWith(set: { reload: () => void }, port: RefreshablePort): () => Promise<void> {\n return async () => {\n await port.refresh?.()\n set.reload()\n }\n}\n","/**\n * The models catalog: `ctx.models`. Models of the active providers, keyed\n * by provider and model id, plus the default selection. Models are not added\n * here: a provider brings them (see `ctx.providers`).\n */\n\nimport type { Disposable, ItemOrigin, ModelEditor, ModelInfo, ModelsDomain } from '../api'\nimport type { DomainDeps } from '../runtime/deps'\nimport type { RefreshablePort } from './domain'\nimport type { CatalogDraft, CatalogOptions, CatalogValue, Sourced } from './engine'\nimport { addTransform, reloadWith } from './domain'\nimport { createCatalogSet } from './engine'\n\n/** The catalog id of a model: `<providerId>/<modelId>`. */\nexport function modelKey(providerId: string, modelId: string): string {\n return `${providerId}/${modelId}`\n}\n\n/** A model selection. */\nexport interface ModelSelection {\n /** Provider id. */\n readonly providerId: string\n /** Model id. */\n readonly modelId: string\n}\n\n/** Supplies the base models and default. The host connects the active providers (after `providers` transforms). */\nexport interface ModelsCatalogPort extends RefreshablePort {\n /** Models of the active providers. */\n models: () => readonly Sourced<ModelInfo>[]\n /** The configured default selection. */\n default?: () => ModelSelection | undefined\n}\n\n/** Catalog-wide model state. */\nexport interface ModelsState {\n /** The default selection. */\n default?: ModelSelection\n /** The extension whose transform set it. */\n defaultSetBy?: string\n}\n\n/** Section item types of the models catalog. */\nexport interface ModelsSections {\n /** Models, by {@link modelKey}. */\n models: ModelInfo\n}\n\n/** A replayed models value. `state.default` is cleared when its model is gone. */\nexport type ModelsValue = CatalogValue<ModelsSections, ModelsState>\n\n/** The shared models catalog a host builds once. */\nexport interface ModelsCatalog {\n /** The replayed value. */\n read: () => ModelsValue\n /** Adds a model outside the provider base (host use; extensions go through providers). */\n register: (model: ModelInfo, origin: ItemOrigin) => Disposable\n /** Re-reads the base and replays. */\n reload: () => Promise<void>\n /** Calls `listener` after each change. */\n subscribe: (listener: () => void) => () => void\n /**\n * Engine access for the domain factory.\n *\n * @internal\n */\n readonly engine: ReturnType<typeof createModelsEngine>\n}\n\nfunction createModelsEngine(port: ModelsCatalogPort, options: CatalogOptions) {\n return createCatalogSet<ModelsSections, ModelsState, void>({\n ...options,\n name: 'models',\n sections: { models: { key: model => modelKey(model.providerId, model.id), base: () => port.models() } },\n state: {\n base: () => {\n const selection = port.default?.()\n return selection ? { default: { ...selection } } : {}\n },\n clone: state => ({ ...state }),\n },\n })\n}\n\nfunction modelEditor(draft: CatalogDraft<ModelsSections, ModelsState, void>): ModelEditor {\n const models = draft.sections.models\n return {\n list: providerId => providerId === undefined ? models.list() : models.list().filter(model => model.providerId === providerId),\n get: (providerId, modelId) => models.get(modelKey(providerId, modelId)),\n update: (providerId, modelId, edit) => models.update(modelKey(providerId, modelId), edit),\n remove: (providerId, modelId) => models.remove(modelKey(providerId, modelId)),\n default: {\n get: () => {\n draft.assertOpen()\n return draft.state.default ? { ...draft.state.default } : undefined\n },\n set: (providerId, modelId) => {\n draft.assertOpen()\n if (!models.get(modelKey(providerId, modelId)))\n throw new Error(`models.default.set: no model \"${modelKey(providerId, modelId)}\"`)\n draft.state = { default: { providerId, modelId }, defaultSetBy: draft.extensionId }\n },\n },\n }\n}\n\n/** Creates the shared models catalog. */\nexport function createModelsCatalog(port: ModelsCatalogPort, options: CatalogOptions = {}): ModelsCatalog {\n const engine = createModelsEngine(port, options)\n return {\n engine,\n read: () => {\n const value = engine.read()\n const selection = value.state.default\n if (!selection || value.sections.models.get(modelKey(selection.providerId, selection.modelId)))\n return value\n return Object.freeze({ ...value, state: Object.freeze({}) })\n },\n register: (model, origin) => engine.register('models', model, origin),\n reload: reloadWith(engine, port),\n subscribe: engine.subscribe,\n }\n}\n\n/** Creates one extension's `ctx.models` over the shared catalog. */\nexport function createModelsDomain(deps: DomainDeps, catalog: ModelsCatalog): ModelsDomain {\n return {\n transform: fn => addTransform(deps, catalog.engine, 'models.transform', modelEditor, fn),\n reload: catalog.reload,\n list: () => catalog.read().sections.models.items,\n default: () => {\n const selection = catalog.read().state.default\n return selection ? { providerId: selection.providerId, modelId: selection.modelId } : undefined\n },\n }\n}\n","/**\n * The providers catalog: `ctx.providers`. Provider descriptors (active or\n * not) and the models each provider offers, edited together by one\n * {@link ProviderEditor} per transform. Removing a provider removes its\n * models. The host feeds the models of active providers into the models catalog.\n *\n * A provider can also hold a model list per account (`models.set(id, list,\n * { account })`): the list a picker shows for that account. Accounts without\n * one fall back to the provider's own list. Provider transforms read accounts,\n * so hosts re-run them when accounts change ({@link watchProviderAccounts}).\n */\n\nimport type { ProviderDescriptor } from '../../chat/providers'\nimport type { Disposable, ItemOrigin, ModelInfo, ProviderEditor, ProvidersDomain } from '../api'\nimport type { IntegrationRegistry } from '../integrations/registry'\nimport type { DomainDeps } from '../runtime/deps'\nimport type { RefreshablePort } from './domain'\nimport type { CatalogDraft, CatalogOptions, CatalogValue, Sourced } from './engine'\nimport { addTransform, extensionOrigin, owned, reloadWith } from './domain'\nimport { createCatalogSet } from './engine'\nimport { modelKey } from './models'\n\n/** Supplies the base descriptors and their models. The host connects the provider registry. */\nexport interface ProvidersCatalogPort extends RefreshablePort {\n /** Built-in and config provider descriptors. */\n providers: () => readonly Sourced<ProviderDescriptor>[]\n /** Models of those providers. */\n models?: () => readonly Sourced<ModelInfo>[]\n}\n\n/** Section item types of the providers catalog. */\nexport interface ProvidersSections {\n /** Descriptors, by `key`. */\n providers: ProviderDescriptor\n /** Models, by `<providerId>/<modelId>` (see {@link modelKey}). */\n models: ModelInfo\n /** Account-scoped models, by {@link accountModelKey}. */\n accountModels: AccountModelInfo\n}\n\n/** A model of one account's list (`models.set(providerId, list, { account })`). */\nexport interface AccountModelInfo extends ModelInfo {\n /** The account whose list holds it. */\n account: string\n}\n\n/**\n * The catalog id of an account-scoped model: `<providerId>@<account>/<modelId>`.\n *\n * @param providerId - Provider id.\n * @param account - The account the list belongs to.\n * @param modelId - Model id.\n */\nexport function accountModelKey(providerId: string, account: string, modelId: string): string {\n return `${providerId}@${account}/${modelId}`\n}\n\n/** A replayed providers value. */\nexport type ProvidersValue = CatalogValue<ProvidersSections, undefined>\n\n/** The shared providers catalog a host builds once. */\nexport interface ProvidersCatalog {\n /** The replayed value. */\n read: () => ProvidersValue\n /**\n * Models of one provider (or all), after transforms. With `account` (and a\n * provider): that account's own list when it has one, else the provider's.\n */\n models: (providerId?: string, opts?: { account?: string }) => readonly ModelInfo[]\n /** The accounts of a provider that have their own model list, in insertion order. */\n accounts: (providerId: string) => readonly string[]\n /** Adds a descriptor. */\n register: (descriptor: ProviderDescriptor, origin: ItemOrigin) => Disposable\n /** Re-reads the base and replays. */\n reload: () => Promise<void>\n /** Calls `listener` after each change. */\n subscribe: (listener: () => void) => () => void\n /**\n * Engine access for the domain factory.\n *\n * @internal\n */\n readonly engine: ReturnType<typeof createProvidersEngine>\n}\n\nfunction createProvidersEngine(port: ProvidersCatalogPort, options: CatalogOptions) {\n return createCatalogSet<ProvidersSections, undefined, void>({\n ...options,\n name: 'providers',\n sections: {\n providers: { key: descriptor => descriptor.key, base: () => port.providers() },\n models: { key: model => modelKey(model.providerId, model.id), base: () => port.models?.() ?? [] },\n accountModels: { key: model => accountModelKey(model.providerId, model.account, model.id), base: () => [] },\n },\n })\n}\n\nfunction providerEditor(draft: CatalogDraft<ProvidersSections, undefined, void>): ProviderEditor {\n const providers = draft.sections.providers\n const models = draft.sections.models\n const accountModels = draft.sections.accountModels\n const modelsOf = (providerId: string) => models.list().filter(model => model.providerId === providerId)\n const accountModelsOf = (providerId: string, account?: string) => accountModels.list().filter(model => model.providerId === providerId && (account === undefined || model.account === account))\n const checkOwner = (providerId: string, next: readonly ModelInfo[]): void => {\n for (const model of next) {\n if (model.providerId !== providerId)\n throw new Error(`providers.models.set: model \"${model.id}\" belongs to \"${model.providerId}\", not \"${providerId}\"`)\n }\n }\n return {\n list: providers.list,\n get: providers.get,\n origin: providers.origin,\n add: providers.add,\n update: providers.update,\n remove: (id) => {\n providers.remove(id)\n for (const model of modelsOf(id))\n models.remove(modelKey(id, model.id))\n for (const model of accountModelsOf(id))\n accountModels.remove(accountModelKey(id, model.account, model.id))\n },\n models: {\n set: (providerId, next, opts) => {\n checkOwner(providerId, next)\n const wanted = new Set(next.map(model => model.id))\n const account = opts?.account\n if (account !== undefined) {\n if (typeof account !== 'string' || account.length === 0)\n throw new TypeError('providers.models.set: account must be a non-empty string')\n for (const model of accountModelsOf(providerId, account)) {\n if (!wanted.has(model.id))\n accountModels.remove(accountModelKey(providerId, account, model.id))\n }\n for (const model of next)\n accountModels.replace({ ...model, account })\n return\n }\n for (const model of modelsOf(providerId)) {\n if (!wanted.has(model.id))\n models.remove(modelKey(providerId, model.id))\n }\n for (const model of next)\n models.replace(model)\n },\n // An edit by id applies to every list that holds the model: the provider's and each account's.\n update: (providerId, modelId, edit) => {\n models.update(modelKey(providerId, modelId), edit)\n for (const model of accountModelsOf(providerId)) {\n if (model.id === modelId)\n accountModels.update(accountModelKey(providerId, model.account, modelId), edit)\n }\n },\n remove: (providerId, modelId) => {\n models.remove(modelKey(providerId, modelId))\n for (const model of accountModelsOf(providerId)) {\n if (model.id === modelId)\n accountModels.remove(accountModelKey(providerId, model.account, modelId))\n }\n },\n },\n }\n}\n\n/** Creates the shared providers catalog. */\nexport function createProvidersCatalog(port: ProvidersCatalogPort, options: CatalogOptions = {}): ProvidersCatalog {\n const engine = createProvidersEngine(port, options)\n return {\n engine,\n read: () => engine.read(),\n models: (providerId, opts) => {\n const value = engine.read()\n if (providerId === undefined)\n return value.sections.models.items\n const account = opts?.account\n if (account !== undefined) {\n const own = value.sections.accountModels.items.filter(model => model.providerId === providerId && model.account === account)\n if (own.length > 0)\n return own.map(({ account: _account, ...model }) => model)\n }\n return value.sections.models.items.filter(model => model.providerId === providerId)\n },\n accounts: (providerId) => {\n const out = new Set<string>()\n for (const model of engine.read().sections.accountModels.items) {\n if (model.providerId === providerId)\n out.add(model.account)\n }\n return [...out]\n },\n register: (descriptor, origin) => engine.register('providers', descriptor, origin),\n reload: reloadWith(engine, port),\n subscribe: engine.subscribe,\n }\n}\n\n/** Creates one extension's `ctx.providers` over the shared catalog. */\nexport function createProvidersDomain(deps: DomainDeps, catalog: ProvidersCatalog): ProvidersDomain {\n return {\n register(descriptor) {\n if (!descriptor || typeof descriptor.key !== 'string' || descriptor.key.length === 0)\n throw new TypeError('providers.register: descriptor needs a non-empty key')\n if (typeof descriptor.factory !== 'function')\n throw new TypeError(`providers.register: \"${descriptor.key}\" needs a factory`)\n return owned(deps, 'providers.register', () => catalog.register(descriptor, extensionOrigin(deps)))\n },\n transform: fn => addTransform(deps, catalog.engine, 'providers.transform', providerEditor, fn),\n reload: catalog.reload,\n list: () => catalog.read().sections.providers.items,\n }\n}\n\n/** Something that says when provider accounts change. Returns the unsubscribe. */\nexport type AccountChangeSource = (listener: () => void) => () => void\n\n/**\n * Re-runs provider transforms (`catalog.reload()`) when accounts change: any\n * integration connection (connect, disconnect, a new default) and any other\n * source the host passes (its stored provider accounts). Changes in one turn\n * of the event loop reload once. Returns the unsubscribe.\n *\n * @param catalog - The providers catalog.\n * @param integrations - The integration registry, when the host has one.\n * @param sources - Other account change sources (the credentials file).\n */\nexport function watchProviderAccounts(catalog: Pick<ProvidersCatalog, 'reload'>, integrations: Pick<IntegrationRegistry, 'subscribe'> | undefined, sources: readonly AccountChangeSource[] = []): () => void {\n let queued = false\n let stopped = false\n const changed = (): void => {\n if (queued || stopped)\n return\n queued = true\n queueMicrotask(() => {\n queued = false\n if (!stopped)\n void catalog.reload()\n })\n }\n const offs = [...(integrations ? [integrations.subscribe(changed)] : []), ...sources.map(source => source(changed))]\n return () => {\n stopped = true\n for (const off of offs)\n off()\n }\n}\n"],"mappings":";;;;;;;;AAuBA,SAAS,gBAAgB,aAAqB,QAA6D;CACzG,OAAO,OAAO,KAAI,UAChB,MAAM,UAAU,CAAC,MAAM,OAAO,SAAS,SAAS,GAAG,IAC/C;EAAE,GAAG;EAAO,QAAQ;GAAE,GAAG,MAAM;GAAQ,UAAU,GAAG,YAAY,GAAG,MAAM,OAAO;EAAW;CAAE,IAC7F,KAAK;AACb;;;;;;;AAgBA,SAAgB,0BAA0B,OAA4C;CACpF,IAAI,UAAU,KAAA,GACZ,QAAQ,CAAC;CACX,IAAI,OAAO,UAAU,UACnB,MAAM,IAAI,kBAAkB,CAAC;EAAE,MAAM;EAAS,SAAS,qDAAqD,MAAM;CAAK,CAAC,CAAC;CAC3H,IAAI,CAAC,SAAS,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,GAC5D,MAAM,IAAI,kBAAkB,CAAC;EAAE,MAAM;EAAS,SAAS;CAAwD,CAAC,CAAC;CACnH,MAAM,IAAI;CACV,MAAM,SAA8B,CAAC;CAC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ACjF,MAAM,IAAI,UAAU,sDAAsD;GAC5E,IAAI,OAAO,WAAW,YAAY,YAChC,MAAM,IAAI,UAAU,wBAAwB,WAAW,IAAI,kBAAkB;GAC/E,OAAO,MAAM,MAAM,4BAA4B,QAAQ,SAAS,YAAY,gBAAgB,IAAI,CAAC,CAAC;EACpG;EACA,YAAW,OAAM,aAAa,MAAM,QAAQ,QAAQ,uBAAuB,gBAAgB,EAAE;EAC7F,QAAQ,QAAQ;EAChB,YAAY,QAAQ,KAAK,CAAC,CAAC,SAAS,UAAU;CAChD;AACF;;;;;;;;;;;AAeA,SAAgB,sBAAsB,SAA2C,cAAkE,UAA0C,CAAC,GAAe;CAC3M,IAAI,SAAS;CACb,IAAI,UAAU;CACd,MAAM,gBAAsB;EAC1B,IAAI,UAAU,SACZ;EACF,SAAS;EACT,qBAAqB;GACnB,SAAS;GACT,IAAI,CAAC,SACH,QAAa,OAAO;EACxB,CAAC;CACH;CACA,MAAM,OAAO,CAAC,GAAI,eAAe,CAAC,aAAa,UAAU,OAAO,CAAC,IAAI,CAAC,GAAI,GAAG,QAAQ,KAAI,WAAU,OAAO,OAAO,CAAC,CAAC;CACnH,aAAa;EACX,UAAU;EACV,KAAK,MAAM,OAAO,MAChB,IAAI;CACR;AACF"}
|
package/dist/providers.js
CHANGED
|
@@ -5,7 +5,7 @@ import { arcee } from "./providers/arcee.js";
|
|
|
5
5
|
import { baseten, planBasetenReasoning } from "./providers/baseten.js";
|
|
6
6
|
import { cerebras } from "./providers/cerebras.js";
|
|
7
7
|
import { a as cursor, i as planMistralReasoning, n as zai, r as mistral, t as planZaiReasoning } from "./providers-B3c8NX_8.js";
|
|
8
|
-
import { a as googleCompatible, i as google, l as GOOGLE_IMAGE_MODELS, o as googleVertex, r as classifyGoogleError } from "./google-
|
|
8
|
+
import { a as googleCompatible, i as google, l as GOOGLE_IMAGE_MODELS, o as googleVertex, r as classifyGoogleError } from "./google-D1zjAViO.js";
|
|
9
9
|
import { n as MAX_IMAGES_PER_REQUEST, t as IMAGE_ASPECT_RATIOS } from "./types-JzccL5GE.js";
|
|
10
10
|
import { o as OPENAI_IMAGE_MODELS, r as openai } from "./openai-OxUGZ4q2.js";
|
|
11
11
|
import { a as openrouterImageModels, r as openrouter } from "./openrouter-7EcfTAju.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.js";
|
|
2
2
|
import { g as errorMessage, n as AgentAuthError } from "./errors-BuX_vK2H.js";
|
|
3
3
|
import { l as resolveOAuthApiKey } from "./oauth-HKL8zPcd.js";
|
|
4
|
-
import "./auth-store-port-
|
|
4
|
+
import "./auth-store-port-CDJa8Q8U.js";
|
|
5
5
|
//#region src/extensions/integrations/oauth.ts
|
|
6
6
|
/** A token endpoint refused a request. */
|
|
7
7
|
var OAuthTokenError = class extends Error {
|
|
@@ -1031,4 +1031,4 @@ function integrationRegistry() {
|
|
|
1031
1031
|
//#endregion
|
|
1032
1032
|
export { integrationRegistry as n, registry_exports as r, createIntegrationRegistry as t };
|
|
1033
1033
|
|
|
1034
|
-
//# sourceMappingURL=registry-
|
|
1034
|
+
//# sourceMappingURL=registry-BY45AOA-.js.map
|