@ai-ecoverse/slicc-spectrum 1.97.0 → 1.98.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.
@@ -6,7 +6,7 @@ import {
6
6
  DummySettings,
7
7
  clock,
8
8
  dummySettingsKey
9
- } from "./chunk-YUDOYEMB.js";
9
+ } from "./chunk-LOQJK2JE.js";
10
10
  import {
11
11
  Emitter
12
12
  } from "./chunk-T5NHW4KC.js";
package/dist/slicc-ui.js CHANGED
@@ -43540,7 +43540,7 @@ function shield(text5) {
43540
43540
  return out;
43541
43541
  }
43542
43542
  function quoted(segment2) {
43543
- const words = [];
43543
+ const words2 = [];
43544
43544
  let word = "";
43545
43545
  let quote = "";
43546
43546
  for (let index2 = 0; index2 < segment2.length; index2++) {
@@ -43553,20 +43553,20 @@ function quoted(segment2) {
43553
43553
  } else if (char === "'" || char === '"') quote = char;
43554
43554
  else if (char === "\\") word += segment2[++index2] ?? "";
43555
43555
  else if (/[\s<>=]/.test(char)) {
43556
- words.push(word);
43556
+ words2.push(word);
43557
43557
  word = "";
43558
43558
  } else word += char;
43559
43559
  }
43560
- return [...words, word];
43560
+ return [...words2, word];
43561
43561
  }
43562
- function commas(words) {
43563
- return words.flatMap((word) => word.includes(",") ? [word, ...word.split(",")] : [word]).filter(Boolean);
43562
+ function commas(words2) {
43563
+ return words2.flatMap((word) => word.includes(",") ? [word, ...word.split(",")] : [word]).filter(Boolean);
43564
43564
  }
43565
- function scan2(words, cwds, whole) {
43565
+ function scan2(words2, cwds, whole) {
43566
43566
  let cd = false;
43567
- for (const [index2, word] of words.entries()) {
43567
+ for (const [index2, word] of words2.entries()) {
43568
43568
  let hit = null;
43569
- if (index2 === 0 || words[index2 - 1] === "-c") {
43569
+ if (index2 === 0 || words2[index2 - 1] === "-c") {
43570
43570
  cd = ["cd", "pushd"].includes(command2(word));
43571
43571
  hit = touched2(cwds, word, whole);
43572
43572
  } else if (!cd) hit = touched2(cwds, word, whole);
@@ -43587,9 +43587,9 @@ function reach2(command3, cwd) {
43587
43587
  const plain2 = text5.split(separators).map((segment2) => commas(segment2.split(/[\s<>=]+/).map((word) => word.replace(/['"\\]/g, ""))));
43588
43588
  const aware = shield(text5).split(separators).map((segment2) => commas(quoted(unshield(segment2))));
43589
43589
  const segments = JSON.stringify(aware) === JSON.stringify(plain2) ? plain2 : [...plain2, ...aware];
43590
- const whole = segments.some((words) => words.length > 0 && !trusted(words[0]));
43591
- for (const words of segments) {
43592
- const hit = scan2(words, cwds, whole);
43590
+ const whole = segments.some((words2) => words2.length > 0 && !trusted(words2[0]));
43591
+ for (const words2 of segments) {
43592
+ const hit = scan2(words2, cwds, whole);
43593
43593
  if (hit) return hit;
43594
43594
  }
43595
43595
  const named2 = segments.flat().find((word) => !word.startsWith("/") && /fnox|secrets-policy/.test(word));
@@ -46704,7 +46704,7 @@ function execLine(exec, argv = []) {
46704
46704
  if (exec === "shell") return "Revealed in every bash";
46705
46705
  if (exec === false) return null;
46706
46706
  if (!argv.length) return "Revealed only to listed commands";
46707
- return `Revealed only to ${list5(argv.map((words) => words.map(shellWord).join(" ")))}`;
46707
+ return `Revealed only to ${list5(argv.map((words2) => words2.map(shellWord).join(" ")))}`;
46708
46708
  }
46709
46709
  function lower(line) {
46710
46710
  return `${line[0].toLowerCase()}${line.slice(1)}`;
@@ -50098,10 +50098,10 @@ function draft(option2) {
50098
50098
  };
50099
50099
  }
50100
50100
  function matchProviders(options2, query) {
50101
- const words = query.trim().toLowerCase().split(/\s+/).filter(Boolean);
50101
+ const words2 = query.trim().toLowerCase().split(/\s+/).filter(Boolean);
50102
50102
  return options2.filter((option2) => {
50103
50103
  const text5 = `${option2.name} ${option2.id} ${option2.description ?? ""}`.toLowerCase();
50104
- return words.every((word) => text5.includes(word));
50104
+ return words2.every((word) => text5.includes(word));
50105
50105
  });
50106
50106
  }
50107
50107
  var mcpRegistrations = "slicc-spectrum.mcp-endpoints";
@@ -50121,6 +50121,9 @@ function register(server, url) {
50121
50121
  } catch {
50122
50122
  }
50123
50123
  }
50124
+ function words(message, word) {
50125
+ return new RegExp(`\\b${word.replace(/[^a-z0-9 ]/gi, "\\$&")}\\b`, "i").test(message);
50126
+ }
50124
50127
  var popup = (account) => account.group === "mcp" && account.auth === "oauth";
50125
50128
  var start = (options2, value) => options2.some((option2) => option2.value === value) ? value : options2[0]?.value ?? "";
50126
50129
  var nothingToChoose = "Nothing to choose from yet. You can connect without it.";
@@ -50553,18 +50556,22 @@ var SliccSettings = class extends ThemedElement {
50553
50556
  const model = this.model;
50554
50557
  const vault = this.#vault(account);
50555
50558
  const { id } = account;
50556
- const problem = valueProblem(value);
50559
+ const keyed = value !== "" || !this.#keyOptional(account);
50560
+ const problem = keyed ? valueProblem(value) : null;
50557
50561
  if (problem) {
50558
50562
  this.#refuse(id, "value", problem);
50559
50563
  return;
50560
50564
  }
50561
50565
  if (vault.status()?.locked) return;
50562
- const options2 = account.group === "mcp" ? { kind: "mcp", server: serverOf(account) } : { kind: "model", provider: account.id };
50566
+ const settings = this.#settingsOf(account, fields);
50567
+ const options2 = account.group === "mcp" ? { kind: "mcp", server: serverOf(account) } : { kind: "model", provider: account.id, ...settings ? { settings } : {} };
50563
50568
  this.#busy(id, true);
50564
50569
  this.failure = null;
50565
50570
  const url = this.#mcpUrl(account);
50571
+ const before = keyed ? void 0 : this.#record(account)?.settings;
50566
50572
  try {
50567
- await vault.put?.(recordName(account), value, void 0, options2);
50573
+ if (keyed) await vault.put?.(recordName(account), value, void 0, options2);
50574
+ else if (settings) await vault.settings?.(recordName(account), "model", settings);
50568
50575
  if (url) {
50569
50576
  const server = serverOf(account);
50570
50577
  const old = registrations2()[server];
@@ -50576,7 +50583,7 @@ var SliccSettings = class extends ThemedElement {
50576
50583
  }
50577
50584
  } catch (error) {
50578
50585
  this.#busy(id, false);
50579
- if (this.model === model) this.#refuse(id, "value", failureText(error));
50586
+ if (this.model === model) this.#refused(account, failureText(error), keyed);
50580
50587
  return;
50581
50588
  }
50582
50589
  if (this.model !== model || this.entering !== id) {
@@ -50584,6 +50591,44 @@ var SliccSettings = class extends ThemedElement {
50584
50591
  return;
50585
50592
  }
50586
50593
  await this.#connectBases(account, void 0, fields, vault);
50594
+ const failed2 = [this.failure, this.problem].some((issue) => issue?.id === id);
50595
+ if (failed2 && settings && !keyed)
50596
+ await vault.settings?.(recordName(account), "model", before ?? {}).catch(() => {
50597
+ });
50598
+ }
50599
+ #settingsOf(account, fields) {
50600
+ const settable = (account.fields ?? []).filter((field) => field.vaultSetting);
50601
+ if (account.group === "mcp" || !settable.length) return void 0;
50602
+ return Object.fromEntries(
50603
+ settable.flatMap((field) => {
50604
+ const value = fields?.[field.name];
50605
+ if (!value || field.customBase && this.#baseOf(value)) return [];
50606
+ return [[field.vaultSetting, value]];
50607
+ })
50608
+ );
50609
+ }
50610
+ #record(account) {
50611
+ const name = recordName(account);
50612
+ return this.model?.vault?.list()?.secrets.find(
50613
+ (secret) => secret.name === name && secret.kind === "model" && secret.state !== "removed"
50614
+ );
50615
+ }
50616
+ #keyOptional(account) {
50617
+ const vault = this.#vault(account);
50618
+ const fields = account.fields ?? [];
50619
+ if (!vault || !fields.some((field) => field.vaultSetting || field.customBase)) return false;
50620
+ if (fields.some((field) => field.vaultSetting) && !vault.settings) return false;
50621
+ return !!this.#record(account);
50622
+ }
50623
+ #refused(account, message, keyed) {
50624
+ const field = (account.fields ?? []).find(
50625
+ (candidate) => [candidate.vaultSetting, candidate.name, candidate.label].some(
50626
+ (word) => word && words(message, word)
50627
+ )
50628
+ );
50629
+ if (field) this.#refuse(account.id, field.name, message);
50630
+ else if (keyed) this.#refuse(account.id, "value", message);
50631
+ else this.failure = { id: account.id, message };
50587
50632
  }
50588
50633
  #baseOf(value) {
50589
50634
  const trimmed = value?.trim() ?? "";
@@ -50653,7 +50698,7 @@ var SliccSettings = class extends ThemedElement {
50653
50698
  const message = this.failure.message;
50654
50699
  const field = (account.fields ?? []).find(
50655
50700
  (candidate) => candidate.customBase && !!fields?.[candidate.name] && [candidate.name, candidate.label, "https", "url", "port", "userinfo"].some(
50656
- (word) => new RegExp(`\\b${word.replace(/[^a-z0-9 ]/gi, "\\$&")}\\b`, "i").test(message)
50701
+ (word) => words(message, word)
50657
50702
  )
50658
50703
  );
50659
50704
  if (!field) return;
@@ -50888,7 +50933,8 @@ var SliccSettings = class extends ThemedElement {
50888
50933
  if (account.blocked) return false;
50889
50934
  if (!this.#offered()) return true;
50890
50935
  const required = (account.fields ?? []).filter((field) => field.required && !field.options);
50891
- return ["value", ...required.map((field) => field.name)].every((name) => this.filled.has(name));
50936
+ const key2 = this.#keyOptional(account) ? [] : ["value"];
50937
+ return [...key2, ...required.map((field) => field.name)].every((name) => this.filled.has(name));
50892
50938
  }
50893
50939
  #fill(event2) {
50894
50940
  const input = event2.target;