@kehto/paja 0.35.3 → 0.36.0

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.
@@ -1,3 +1,61 @@
1
+ // src/multiplayer-config.ts
2
+ import { normalizePermissionScope } from "@kehto/firewall";
3
+ var HEX = /^[0-9a-f]{64}$/u;
4
+ function record(value) {
5
+ return value !== null && typeof value === "object" && !Array.isArray(value);
6
+ }
7
+ function text(value) {
8
+ if (typeof value !== "string" || !value.trim() || value.length > 256) throw new Error("Expected nonempty text (at most 256 characters).");
9
+ return value;
10
+ }
11
+ function relayUrls(value) {
12
+ if (!Array.isArray(value) || !value.length || value.length > 16) throw new Error("Configure 1\u201316 relay URLs.");
13
+ return [...new Set(value.map((item) => {
14
+ if (typeof item !== "string") throw new Error("Invalid relay URL.");
15
+ const url = new URL(item);
16
+ if (!["ws:", "wss:"].includes(url.protocol) || !url.hostname || url.username || url.password || url.search || url.hash || url.pathname !== "/") throw new Error("Relay URLs must be WS(S) origins without credentials.");
17
+ return url.origin;
18
+ }))];
19
+ }
20
+ function family(value) {
21
+ if (!record(value) || !record(value.server) || typeof value.server.pubkey !== "string" || !HEX.test(value.server.pubkey)) throw new Error("Each registry family needs a provider public key.");
22
+ if (!Array.isArray(value.tools) || !value.tools.length || value.tools.length > 64) throw new Error("Each family needs 1\u201364 tool name/hash pins.");
23
+ const tools = value.tools.map((tool) => {
24
+ if (!record(tool) || typeof tool.schemaHash !== "string" || !HEX.test(tool.schemaHash)) throw new Error("Each tool needs its CEP-15 schema hash.");
25
+ return { name: text(tool.name), schemaHash: tool.schemaHash };
26
+ });
27
+ if (new Set(tools.map((tool) => tool.name)).size !== tools.length) throw new Error("Family tool names must be unique.");
28
+ return {
29
+ family: text(value.family),
30
+ server: { pubkey: value.server.pubkey, relays: relayUrls(value.server.relays) },
31
+ tools,
32
+ ...value.description === void 0 ? {} : { description: text(value.description) },
33
+ ...value.categories === void 0 ? {} : { categories: Array.isArray(value.categories) ? value.categories.map(text) : (() => {
34
+ throw new Error("Categories must be a text list.");
35
+ })() }
36
+ };
37
+ }
38
+ function iceServer(value) {
39
+ if (!record(value) || !Array.isArray(value.urls) || !value.urls.length || value.urls.length > 8) throw new Error("Each ICE server needs 1\u20138 URLs.");
40
+ const urls = value.urls.map((url) => normalizePermissionScope({ kind: "ice", value: url }).value);
41
+ if (value.username !== void 0 && typeof value.username !== "string") throw new Error("Invalid ICE username.");
42
+ if (value.credential !== void 0 && typeof value.credential !== "string") throw new Error("Invalid ICE credential.");
43
+ return { urls, ...value.username === void 0 ? {} : { username: value.username }, ...value.credential === void 0 ? {} : { credential: value.credential } };
44
+ }
45
+ function normalizePajaMultiplayer(value) {
46
+ if (value === void 0) return void 0;
47
+ if (!record(value) || value.profile !== "soy-rtc/1") throw new Error("Select a supported multiplayer signaling profile.");
48
+ if (!Array.isArray(value.registry) || value.registry.length > 16) throw new Error("Configure at most 16 registry families.");
49
+ if (value.iceServers !== void 0 && (!Array.isArray(value.iceServers) || value.iceServers.length > 8)) throw new Error("Configure at most 8 ICE servers.");
50
+ return {
51
+ profile: value.profile,
52
+ relays: relayUrls(value.relays),
53
+ registry: value.registry.map(family),
54
+ ...Array.isArray(value.iceServers) ? { iceServers: value.iceServers.map(iceServer) } : {},
55
+ ...value.developmentNamespace === void 0 ? {} : { developmentNamespace: text(value.developmentNamespace) }
56
+ };
57
+ }
58
+
1
59
  // src/config-file.ts
2
60
  import { readFileSync } from "fs";
3
61
  import { resolve } from "path";
@@ -110,11 +168,11 @@ function normalizePajaSimulation(raw) {
110
168
  if (identityMode === "fixed" && !isHexPubkey(pubkey)) {
111
169
  throw new PajaSimulationError('Invalid simulation: identity.pubkey must be a 64-character hex string when identity.mode is "fixed".');
112
170
  }
113
- const relayUrls = raw?.relay?.urls ?? DEFAULT_RELAY_URLS;
114
- if (relayMode !== "disabled" && relayUrls.length === 0) {
171
+ const relayUrls2 = raw?.relay?.urls ?? DEFAULT_RELAY_URLS;
172
+ if (relayMode !== "disabled" && relayUrls2.length === 0) {
115
173
  throw new PajaSimulationError("Invalid simulation: relay.urls must contain at least one URL when relay.mode is enabled.");
116
174
  }
117
- for (const url of relayUrls) {
175
+ for (const url of relayUrls2) {
118
176
  if (typeof url !== "string" || url.trim().length === 0) {
119
177
  throw new PajaSimulationError("Invalid simulation: relay.urls entries must be non-empty strings.");
120
178
  }
@@ -155,7 +213,7 @@ function normalizePajaSimulation(raw) {
155
213
  },
156
214
  relay: {
157
215
  mode: relayMode,
158
- urls: relayUrls.map((url) => url.trim()),
216
+ urls: relayUrls2.map((url) => url.trim()),
159
217
  fixtures: raw?.relay?.fixtures ?? []
160
218
  },
161
219
  storage: {
@@ -191,7 +249,8 @@ function normalizePajaSimulation(raw) {
191
249
  },
192
250
  cvm: {
193
251
  enabled: cvmEnabled
194
- }
252
+ },
253
+ ...raw?.multiplayer === void 0 ? {} : { multiplayer: normalizePajaMultiplayer(raw.multiplayer) }
195
254
  };
196
255
  }
197
256
  function summarizePajaSimulation(simulation) {
@@ -316,7 +375,8 @@ function mergeSimulationOptions(base, override) {
316
375
  values: { ...base.theme?.values, ...override.theme?.values }
317
376
  },
318
377
  intent: { ...base.intent, ...override.intent },
319
- cvm: { ...base.cvm, ...override.cvm }
378
+ cvm: { ...base.cvm, ...override.cvm },
379
+ multiplayer: override.multiplayer ?? base.multiplayer
320
380
  };
321
381
  }
322
382
  function isRecord(value) {
@@ -792,6 +852,16 @@ function renderPajaHtml(config) {
792
852
  <div id="paja-resource-servers-status" role="status" aria-live="polite"></div>
793
853
  </form>
794
854
  </div></details>
855
+ <details class="section" id="paja-section-multiplayer" data-paja-section="multiplayer">
856
+ <summary class="section-title">Multiplayer providers<span class="section-chevron" aria-hidden="true">\u203A</span></summary><div class="section-body">
857
+ <form class="resource-servers" id="paja-multiplayer-form">
858
+ <label for="paja-multiplayer-input">Provider configuration (JSON)</label>
859
+ <textarea id="paja-multiplayer-input" rows="8" spellcheck="false" aria-describedby="paja-multiplayer-help paja-multiplayer-status"></textarea>
860
+ <small id="paja-multiplayer-help">Configure signaling relays and CVM families using your provider's settings. Saving reloads all apps. Clear to restore the host default.</small>
861
+ <button type="submit">Save and reload</button>
862
+ <div id="paja-multiplayer-status" role="status" aria-live="polite"></div>
863
+ </form>
864
+ </div></details>
795
865
  <details class="section" id="paja-section-security" data-paja-section="security" open>
796
866
  <summary class="section-title">Security<span class="section-chevron" aria-hidden="true">\u203A</span></summary><div class="section-body">
797
867
  <label class="section-title" for="paja-nested-context-lock">Frame-creation lock (experimental)</label>
@@ -1224,8 +1294,8 @@ function trackRelayConnections(pool, relays, maxWaitMs) {
1224
1294
  };
1225
1295
  }
1226
1296
  function describeRelayFailure(error) {
1227
- const text = error instanceof Error ? error.message : String(error ?? "");
1228
- const trimmed = text.trim();
1297
+ const text2 = error instanceof Error ? error.message : String(error ?? "");
1298
+ const trimmed = text2.trim();
1229
1299
  return (trimmed.length > 0 ? trimmed : "connection failed").slice(0, 160);
1230
1300
  }
1231
1301
  function describeRelayUnreachable(pointerType, connections, maxWaitMs) {
@@ -1583,15 +1653,15 @@ async function sha256Hex(bytes) {
1583
1653
 
1584
1654
  // src/installed-napplet-catalog.ts
1585
1655
  import { manifestToIntentCatalogEntry } from "@kehto/services";
1586
- function matchesInstalledNappletRecord(record, target) {
1587
- return target.id === record.id && target.aggregateHash === record.aggregateHash;
1656
+ function matchesInstalledNappletRecord(record2, target) {
1657
+ return target.id === record2.id && target.aggregateHash === record2.aggregateHash;
1588
1658
  }
1589
1659
  var InstalledNappletCatalog = class {
1590
1660
  records = /* @__PURE__ */ new Map();
1591
1661
  listeners = /* @__PURE__ */ new Set();
1592
1662
  /** Insert or replace a record from an already resolver-verified pointer. */
1593
1663
  install(resolved) {
1594
- const record = freezeRecord({
1664
+ const record2 = freezeRecord({
1595
1665
  id: resolved.manifest.catalogId,
1596
1666
  dTag: resolved.dTag,
1597
1667
  aggregateHash: resolved.aggregateHash,
@@ -1605,10 +1675,10 @@ var InstalledNappletCatalog = class {
1605
1675
  params: [...archetype.params]
1606
1676
  }))
1607
1677
  });
1608
- const previous = this.records.get(record.id);
1609
- this.records.set(record.id, record);
1610
- this.notify(record.id, previous, record);
1611
- return record;
1678
+ const previous = this.records.get(record2.id);
1679
+ this.records.set(record2.id, record2);
1680
+ this.notify(record2.id, previous, record2);
1681
+ return record2;
1612
1682
  }
1613
1683
  /** Remove an artifact explicitly; frame teardown never calls this method. */
1614
1684
  remove(id) {
@@ -1645,10 +1715,10 @@ var InstalledNappletCatalog = class {
1645
1715
  * @returns Named intent candidates usable under the supplied host policy.
1646
1716
  */
1647
1717
  intentCatalog(canReceiveIntent = () => true) {
1648
- return this.installed().filter(canReceiveIntent).map((record) => manifestToIntentCatalogEntry({
1649
- catalogId: record.id,
1650
- ...record.title === void 0 ? {} : { title: record.title },
1651
- archetypes: record.archetypes.map((archetype) => ({
1718
+ return this.installed().filter(canReceiveIntent).map((record2) => manifestToIntentCatalogEntry({
1719
+ catalogId: record2.id,
1720
+ ...record2.title === void 0 ? {} : { title: record2.title },
1721
+ archetypes: record2.archetypes.map((archetype) => ({
1652
1722
  slug: archetype.slug,
1653
1723
  convention: archetype.convention,
1654
1724
  params: [...archetype.params]
@@ -1688,12 +1758,12 @@ function copyPointer(pointer) {
1688
1758
  relays: Object.freeze([...pointer.relays])
1689
1759
  });
1690
1760
  }
1691
- function freezeRecord(record) {
1761
+ function freezeRecord(record2) {
1692
1762
  return Object.freeze({
1693
- ...record,
1694
- requires: Object.freeze([...record.requires]),
1695
- optional: Object.freeze([...record.optional ?? []]),
1696
- archetypes: Object.freeze(record.archetypes.map((archetype) => Object.freeze({ ...archetype, params: Object.freeze([...archetype.params]) })))
1763
+ ...record2,
1764
+ requires: Object.freeze([...record2.requires]),
1765
+ optional: Object.freeze([...record2.optional ?? []]),
1766
+ archetypes: Object.freeze(record2.archetypes.map((archetype) => Object.freeze({ ...archetype, params: Object.freeze([...archetype.params]) })))
1697
1767
  });
1698
1768
  }
1699
1769
 
@@ -2014,8 +2084,8 @@ async function fetchPinnedResource(input, signal) {
2014
2084
  const timer = setTimeout(() => controller.abort(new Error("Resource request timed out")), RESOURCE_TIMEOUT_MS);
2015
2085
  try {
2016
2086
  controller.signal.throwIfAborted();
2017
- const family = isIP(hostname);
2018
- const answers = family ? [{ address: hostname, family }] : await abortable(dnsLookup(hostname, { all: true, verbatim: true }), controller.signal);
2087
+ const family2 = isIP(hostname);
2088
+ const answers = family2 ? [{ address: hostname, family: family2 }] : await abortable(dnsLookup(hostname, { all: true, verbatim: true }), controller.signal);
2019
2089
  controller.signal.throwIfAborted();
2020
2090
  const answer = answers.find((candidate) => isPublicResourceAddress(candidate.address));
2021
2091
  if (!answer) throw new Error("Resource destination resolved to a blocked address");
@@ -2033,7 +2103,7 @@ async function fetchPinnedResource(input, signal) {
2033
2103
  method: "GET",
2034
2104
  agent: false,
2035
2105
  headers: { accept: "*/*", host: url.host },
2036
- ...family ? {} : { servername: hostname },
2106
+ ...family2 ? {} : { servername: hostname },
2037
2107
  lookup(_hostname, options, callback) {
2038
2108
  if (options.all) callback(null, [{ address: answer.address, family: answer.family }]);
2039
2109
  else callback(null, answer.address, answer.family);
@@ -2088,12 +2158,12 @@ function abortable(pending, signal) {
2088
2158
  });
2089
2159
  }
2090
2160
  function isPublicResourceAddress(address) {
2091
- const family = isIP(address);
2092
- if (family === 4) {
2161
+ const family2 = isIP(address);
2162
+ if (family2 === 4) {
2093
2163
  const [a, b, c] = address.split(".").map(Number);
2094
2164
  return a !== 0 && a !== 10 && a !== 127 && a < 224 && !(a === 100 && b >= 64 && b <= 127) && !(a === 169 && b === 254) && !(a === 172 && b >= 16 && b <= 31) && !(a === 192 && (b === 168 || b === 0 && (c === 0 || c === 2) || b === 88 && c === 99)) && !(a === 198 && (b === 18 || b === 19 || b === 51 && c === 100)) && !(a === 203 && b === 0 && c === 113);
2095
2165
  }
2096
- if (family !== 6) return false;
2166
+ if (family2 !== 6) return false;
2097
2167
  let canonical;
2098
2168
  try {
2099
2169
  canonical = new URL(`http://[${address}]/`).hostname.slice(1, -1);
@@ -2453,10 +2523,10 @@ function canonicalToolChoiceModes(tools, requested) {
2453
2523
  return TOOL_CHOICE_ORDER.filter((mode) => mode === "auto" || mode === "none" || wanted.has(mode));
2454
2524
  }
2455
2525
  function normalizeRecord(input) {
2456
- const text = (value) => typeof value === "string" ? value : "";
2457
- const name = text(input.name).trim();
2458
- const model = text(input.model).trim();
2459
- const id = text(input.id);
2526
+ const text2 = (value) => typeof value === "string" ? value : "";
2527
+ const name = text2(input.name).trim();
2528
+ const model = text2(input.model).trim();
2529
+ const id = text2(input.id);
2460
2530
  if (!/^[A-Za-z0-9_-]{1,64}$/.test(id)) throw new Error("Invalid connection id.");
2461
2531
  if (!name || name.length > 64) throw new Error("Enter a connection name of up to 64 characters.");
2462
2532
  if (!model || model.length > 200) throw new Error("Enter the exact provider model identifier.");
@@ -2467,12 +2537,12 @@ function normalizeRecord(input) {
2467
2537
  if (credentialHeader !== void 0 && !CREDENTIAL_HEADERS.has(credentialHeader)) throw new Error("Unknown credential header.");
2468
2538
  if (!["vault", "session", "none"].includes(credentialStorage)) throw new Error("Unknown credential storage.");
2469
2539
  const tools = input.tools === true;
2470
- const record = {
2540
+ const record2 = {
2471
2541
  id,
2472
2542
  name,
2473
- presetId: text(input.presetId).slice(0, 64),
2543
+ presetId: text2(input.presetId).slice(0, 64),
2474
2544
  protocol,
2475
- baseUrl: normalizePajaLlmBaseUrl(text(input.baseUrl)),
2545
+ baseUrl: normalizePajaLlmBaseUrl(text2(input.baseUrl)),
2476
2546
  model,
2477
2547
  images: input.images === true,
2478
2548
  json: input.json === true,
@@ -2481,7 +2551,7 @@ function normalizeRecord(input) {
2481
2551
  credentialStorage,
2482
2552
  ...credentialHeader ? { credentialHeader } : {}
2483
2553
  };
2484
- return Object.freeze(record);
2554
+ return Object.freeze(record2);
2485
2555
  }
2486
2556
  function readRecords(storage) {
2487
2557
  if (!storage) return [];
@@ -2520,9 +2590,9 @@ function createPajaLlmConnectionStore(storage = storageOrNull()) {
2520
2590
  };
2521
2591
  return {
2522
2592
  list: () => records,
2523
- get: (id) => records.find((record) => record.id === id),
2524
- save(record) {
2525
- const normalized = normalizeRecord({ ...record });
2593
+ get: (id) => records.find((record2) => record2.id === id),
2594
+ save(record2) {
2595
+ const normalized = normalizeRecord({ ...record2 });
2526
2596
  const index = records.findIndex((entry) => entry.id === normalized.id);
2527
2597
  if (index === -1 && records.length >= MAX_CONNECTIONS) throw new Error(`Paja keeps at most ${MAX_CONNECTIONS} connections.`);
2528
2598
  records = index === -1 ? [...records, normalized] : records.map((entry, position) => position === index ? normalized : entry);
@@ -2530,7 +2600,7 @@ function createPajaLlmConnectionStore(storage = storageOrNull()) {
2530
2600
  return normalized;
2531
2601
  },
2532
2602
  remove(id) {
2533
- const next = records.filter((record) => record.id !== id);
2603
+ const next = records.filter((record2) => record2.id !== id);
2534
2604
  if (next.length === records.length) return false;
2535
2605
  records = next;
2536
2606
  persist();
@@ -2542,30 +2612,30 @@ function createPajaLlmConnectionStore(storage = storageOrNull()) {
2542
2612
  }
2543
2613
  };
2544
2614
  }
2545
- function describePajaLlmRoute(record) {
2546
- const preset = LLM_PROVIDER_PRESETS.find((entry) => entry.id === record.presetId);
2547
- const origin = new URL(record.baseUrl).origin;
2615
+ function describePajaLlmRoute(record2) {
2616
+ const preset = LLM_PROVIDER_PRESETS.find((entry) => entry.id === record2.presetId);
2617
+ const origin = new URL(record2.baseUrl).origin;
2548
2618
  const label = preset && preset.id !== "custom" ? `${preset.label} at ${origin}` : origin;
2549
2619
  return `Paja (this browser) \u2192 ${label}`;
2550
2620
  }
2551
- function toConnection(record) {
2552
- const tools = record.tools === true;
2621
+ function toConnection(record2) {
2622
+ const tools = record2.tools === true;
2553
2623
  return {
2554
- id: record.id,
2555
- name: record.name,
2556
- model: record.model,
2557
- route: describePajaLlmRoute(record),
2558
- images: record.images,
2559
- json: record.json,
2624
+ id: record2.id,
2625
+ name: record2.name,
2626
+ model: record2.model,
2627
+ route: describePajaLlmRoute(record2),
2628
+ images: record2.images,
2629
+ json: record2.json,
2560
2630
  tools,
2561
- toolChoiceModes: tools ? canonicalToolChoiceModes(true, record.toolChoiceModes) : []
2631
+ toolChoiceModes: tools ? canonicalToolChoiceModes(true, record2.toolChoiceModes) : []
2562
2632
  };
2563
2633
  }
2564
- function meets(record, requirements) {
2565
- if (requirements.model !== void 0 && requirements.model !== record.model) return false;
2566
- if (requirements.images === true && !record.images) return false;
2567
- if (requirements.tools === true && record.tools !== true) return false;
2568
- return !(requirements.json === true && !record.json);
2634
+ function meets(record2, requirements) {
2635
+ if (requirements.model !== void 0 && requirements.model !== record2.model) return false;
2636
+ if (requirements.images === true && !record2.images) return false;
2637
+ if (requirements.tools === true && record2.tools !== true) return false;
2638
+ return !(requirements.json === true && !record2.json);
2569
2639
  }
2570
2640
  function describeRequirements(requirements) {
2571
2641
  const parts = [
@@ -2593,20 +2663,20 @@ function countToolResults(request) {
2593
2663
  function createPajaLlmHost(options) {
2594
2664
  const { store, vault, confirm, getIdentity } = options;
2595
2665
  const provider = options.provider ?? createHttpLlmProvider({ stream: true });
2596
- function endpointFor(record, credential) {
2666
+ function endpointFor(record2, credential) {
2597
2667
  return {
2598
- protocol: record.protocol,
2599
- baseUrl: record.baseUrl,
2600
- model: record.model,
2668
+ protocol: record2.protocol,
2669
+ baseUrl: record2.baseUrl,
2670
+ model: record2.model,
2601
2671
  ...credential === void 0 ? {} : { credential },
2602
- ...record.credentialHeader ? { credentialHeader: record.credentialHeader } : {}
2672
+ ...record2.credentialHeader ? { credentialHeader: record2.credentialHeader } : {}
2603
2673
  };
2604
2674
  }
2605
- async function ensureCredential(record, signal) {
2606
- if (record.credentialStorage === "none") return void 0;
2607
- const existing = vault.getCredential(record.id);
2675
+ async function ensureCredential(record2, signal) {
2676
+ if (record2.credentialStorage === "none") return void 0;
2677
+ const existing = vault.getCredential(record2.id);
2608
2678
  if (existing !== void 0) return existing;
2609
- if (record.credentialStorage === "session") {
2679
+ if (record2.credentialStorage === "session") {
2610
2680
  options.openPanel();
2611
2681
  throw new LlmServiceError("unsupported", "This connection's API key was kept for one session only. Enter it again in Language models.");
2612
2682
  }
@@ -2614,7 +2684,7 @@ function createPajaLlmHost(options) {
2614
2684
  const unlocked = await options.requestUnlock(signal);
2615
2685
  if (!unlocked) throw new LlmServiceError("user-cancelled", "The credential vault stayed locked.");
2616
2686
  }
2617
- const credential = vault.getCredential(record.id);
2687
+ const credential = vault.getCredential(record2.id);
2618
2688
  if (credential === void 0) {
2619
2689
  options.openPanel();
2620
2690
  throw new LlmServiceError("unsupported", "No API key is stored for this connection. Enter it again in Language models.");
@@ -2624,7 +2694,7 @@ function createPajaLlmHost(options) {
2624
2694
  async function select(context, requirements, prompt) {
2625
2695
  const signal = prompt?.signal;
2626
2696
  const napplet = getIdentity(context.windowId);
2627
- const candidates = store.list().filter((record) => meets(record, requirements));
2697
+ const candidates = store.list().filter((record2) => meets(record2, requirements));
2628
2698
  if (candidates.length === 0) {
2629
2699
  const configure = await confirm({ action: "llm-configure", windowId: context.windowId, napplet, requirements: describeRequirements(requirements), configured: store.list().length, ...signal ? { signal } : {} });
2630
2700
  if (!configure) return null;
@@ -2640,24 +2710,24 @@ function createPajaLlmHost(options) {
2640
2710
  isConfigured: () => store.list().length > 0,
2641
2711
  select,
2642
2712
  describe(_context, connectionId) {
2643
- const record = store.get(connectionId);
2644
- return record ? toConnection(record) : null;
2713
+ const record2 = store.get(connectionId);
2714
+ return record2 ? toConnection(record2) : null;
2645
2715
  },
2646
2716
  async authorize(context, connection, request, prompt) {
2647
2717
  const signal = prompt?.signal;
2648
- const record = store.get(connection.id);
2649
- if (!record) throw new LlmServiceError("selection-expired", "The selected connection was removed; select again.");
2650
- buildLlmProviderRequest(endpointFor(record), request, { stream: true });
2651
- await ensureCredential(record, signal);
2718
+ const record2 = store.get(connection.id);
2719
+ if (!record2) throw new LlmServiceError("selection-expired", "The selected connection was removed; select again.");
2720
+ buildLlmProviderRequest(endpointFor(record2), request, { stream: true });
2721
+ await ensureCredential(record2, signal);
2652
2722
  if (signal?.aborted) return false;
2653
2723
  return confirm({
2654
2724
  ...signal ? { signal } : {},
2655
2725
  action: "llm",
2656
2726
  windowId: context.windowId,
2657
2727
  napplet: getIdentity(context.windowId),
2658
- connection: record.name,
2659
- model: record.model,
2660
- route: describePajaLlmRoute(record),
2728
+ connection: record2.name,
2729
+ model: record2.model,
2730
+ route: describePajaLlmRoute(record2),
2661
2731
  messages: request.messages.length,
2662
2732
  characters: countCharacters(request),
2663
2733
  images: countLlmImages(request.messages),
@@ -2668,10 +2738,10 @@ function createPajaLlmHost(options) {
2668
2738
  });
2669
2739
  },
2670
2740
  async generate(_context, connection, request, hooks) {
2671
- const record = store.get(connection.id);
2672
- if (!record) throw new LlmServiceError("selection-expired", "The selected connection was removed; select again.");
2673
- const credential = await ensureCredential(record);
2674
- return provider(endpointFor(record, credential), request, hooks.signal, (event) => hooks.onDelta(event));
2741
+ const record2 = store.get(connection.id);
2742
+ if (!record2) throw new LlmServiceError("selection-expired", "The selected connection was removed; select again.");
2743
+ const credential = await ensureCredential(record2);
2744
+ return provider(endpointFor(record2, credential), request, hooks.signal, (event) => hooks.onDelta(event));
2675
2745
  },
2676
2746
  subscribe(listener) {
2677
2747
  const stopStore = store.subscribe(listener);
@@ -2837,6 +2907,7 @@ function createPajaLlmVault(options = {}) {
2837
2907
  }
2838
2908
 
2839
2909
  export {
2910
+ normalizePajaMultiplayer,
2840
2911
  PajaSimulationError,
2841
2912
  PAJA_SIMULATION_DOMAINS,
2842
2913
  normalizePajaSimulation,
@@ -2898,4 +2969,4 @@ export {
2898
2969
  validatePajaLlmVaultPassword,
2899
2970
  createPajaLlmVault
2900
2971
  };
2901
- //# sourceMappingURL=chunk-HTLBCTIN.js.map
2972
+ //# sourceMappingURL=chunk-DK5RJN5P.js.map