@ai-ecoverse/slicc-spectrum 1.86.7 → 1.87.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-X4C3AZJT.js";
9
+ } from "./chunk-VRFAMBWK.js";
10
10
  import {
11
11
  Emitter
12
12
  } from "./chunk-T5NHW4KC.js";
package/dist/slicc-ui.js CHANGED
@@ -31531,15 +31531,32 @@ function actionLabel(action, handlers, messageId) {
31531
31531
  const count = action === "drop-turn" ? handlers.dropping(messageId) : 1;
31532
31532
  return count > 1 ? `Drop ${count} failed turns` : actionLabels[action];
31533
31533
  }
31534
+ var signedIn = "Signed in. Retry to send it again.";
31535
+ function stopSigningIn(event2, handlers, account, id) {
31536
+ const main2 = event2.currentTarget.nextElementSibling;
31537
+ main2.focus();
31538
+ handlers.cancelLogin?.(account, id);
31539
+ }
31540
+ function fixButton(fix, item2, handlers, login) {
31541
+ const id = item2.id ?? "";
31542
+ const signing = login?.state === "signing-in";
31543
+ const shown4 = login?.state === "connected" ? "retry" : fix;
31544
+ const cancel = signing && login.cancel;
31545
+ return b`${cancel ? b`<swc-button size="s" variant="secondary" fill-style="outline" data-action="cancel-login" @click=${(event2) => stopSigningIn(event2, handlers, item2.account, id)}>Cancel</swc-button>` : A}<swc-button size="s" variant="secondary" fill-style="outline" data-action=${shown4} ?pending=${signing} ?disabled=${handlers.readOnly} @click=${() => handlers.action(shown4, item2.id, item2.account)}>${signing ? "Signing in\u2026" : actionLabel(shown4, handlers, id)}</swc-button>`;
31546
+ }
31534
31547
  function errorCard(item2, handlers) {
31535
31548
  const id = item2.id ?? "";
31536
31549
  const fix = handlers.seat === void 0 ? item2.action : void 0;
31537
- const action = fix ? b`<swc-button size="s" variant="secondary" fill-style="outline" data-action=${fix} ?disabled=${handlers.readOnly} @click=${() => handlers.action(fix, item2.id)}>${actionLabel(fix, handlers, id)}</swc-button>` : A;
31538
- return b`<div class="error-card" role="alert" data-id=${id || A}>
31539
- <swc-icon-alert-diamond class="icon" size="s" aria-hidden="true"></swc-icon-alert-diamond>
31540
- <span class="sr">Error: </span><span class="lead">${item2.title}</span>
31541
- ${item2.text ? b`<span class="detail">${item2.text}</span>` : A}
31542
- ${action}
31550
+ const login = fix === "login" && item2.account && !handlers.readOnly ? handlers.login?.(item2.account, id) : void 0;
31551
+ const resolved = login?.state === "connected";
31552
+ const text2 = resolved ? signedIn : item2.text;
31553
+ const failure2 = login?.state === "idle" ? login.error : void 0;
31554
+ return b`<div class="error-card" role=${resolved ? A : "alert"} aria-atomic=${resolved ? A : "false"} data-id=${id || A} data-login=${login?.state ?? A}>
31555
+ ${resolved ? b`<swc-icon-info-circle class="icon" size="s" aria-hidden="true"></swc-icon-info-circle>` : b`<swc-icon-alert-diamond class="icon" size="s" aria-hidden="true"></swc-icon-alert-diamond>`}
31556
+ ${resolved ? A : b`<span class="sr">Error: </span>`}<span class="lead">${item2.title}</span>
31557
+ ${text2 ? b`<span class="detail" role=${login ? "status" : A}>${text2}</span>` : A}
31558
+ ${fix ? b`<div class="fix" aria-live="off">${fixButton(fix, item2, handlers, login)}</div>` : A}
31559
+ ${failure2 ? b`<div class="help" data-error="login"><sp-help-text size="s" variant="negative" icon>${failure2}</sp-help-text><swc-action-button size="s" quiet data-action="settings" @click=${() => handlers.action("settings", item2.id, item2.account)}>Open settings</swc-action-button></div>` : A}
31543
31560
  </div>`;
31544
31561
  }
31545
31562
  function time(at) {
@@ -31755,7 +31772,7 @@ function part(entry, handlers) {
31755
31772
  return b`<div class="link-text">${entry.title}</div>`;
31756
31773
  default:
31757
31774
  return errorCard(
31758
- { title: entry.message, text: entry.detail, action: entry.action },
31775
+ { title: entry.message, text: entry.detail, action: entry.action, account: entry.account },
31759
31776
  handlers
31760
31777
  );
31761
31778
  }
@@ -31905,7 +31922,9 @@ function assistant(message, name, model, handlers, showThinking, suggestion = nu
31905
31922
  message.parts,
31906
31923
  {
31907
31924
  ...handlers,
31908
- action: (action) => handlers.action(action, message.id),
31925
+ action: (action, _id, account) => handlers.action(action, message.id, account),
31926
+ login: (account) => handlers.login?.(account, message.id),
31927
+ cancelLogin: (account) => handlers.cancelLogin?.(account, message.id),
31909
31928
  dropping: () => handlers.dropping(message.id)
31910
31929
  },
31911
31930
  showThinking,
@@ -31983,7 +32002,8 @@ function system(message, handlers) {
31983
32002
  id: message.id,
31984
32003
  title: message.title ?? "Error",
31985
32004
  text: message.text,
31986
- action: message.action
32005
+ action: message.action,
32006
+ account: message.account
31987
32007
  },
31988
32008
  handlers
31989
32009
  )
@@ -32794,6 +32814,9 @@ var messageCss = i`
32794
32814
  grid-row: span 2;
32795
32815
  color: var(--swc-negative-visual-color);
32796
32816
  }
32817
+ .error-card[data-login='connected'] .icon {
32818
+ color: var(--swc-neutral-subdued-content-color-default);
32819
+ }
32797
32820
  .error-card .lead {
32798
32821
  grid-column: 2;
32799
32822
  font-weight: var(--swc-bold-font-weight);
@@ -32803,18 +32826,33 @@ var messageCss = i`
32803
32826
  grid-column: 2;
32804
32827
  overflow-wrap: anywhere;
32805
32828
  }
32806
- .error-card swc-button {
32829
+ .error-card .fix {
32807
32830
  grid-column: 3;
32808
- grid-row: span 2;
32831
+ grid-row: 1 / span 2;
32832
+ display: flex;
32833
+ gap: var(--swc-spacing-100);
32834
+ }
32835
+ .error-card swc-button {
32809
32836
  white-space: nowrap;
32810
32837
  }
32838
+ .error-card .help {
32839
+ grid-column: 2 / -1;
32840
+ display: flex;
32841
+ flex-wrap: wrap;
32842
+ align-items: center;
32843
+ gap: var(--swc-spacing-50) var(--swc-spacing-100);
32844
+ }
32811
32845
  @container (inline-size < 480px) {
32812
32846
  .error-card {
32813
32847
  margin-inline: var(--swc-spacing-300);
32814
32848
  }
32849
+ .error-card .fix {
32850
+ flex-direction: column-reverse;
32851
+ align-items: flex-end;
32852
+ }
32815
32853
  }
32816
32854
  @container (inline-size < 360px) {
32817
- .error-card swc-button {
32855
+ .error-card .fix {
32818
32856
  grid-column: 2;
32819
32857
  grid-row: auto;
32820
32858
  justify-self: start;
@@ -37478,7 +37516,9 @@ var SliccChat = class extends ThemedElement {
37478
37516
  readOnly: false,
37479
37517
  answer: (questionId, answer) => this.model?.agent.answer(this.#id(), questionId, answer),
37480
37518
  resolve: (messageId, state2) => this.model?.agent.resolveLick(this.#id(), messageId, state2),
37481
- action: (action, messageId) => this.#action(action, messageId),
37519
+ action: (action, messageId, account) => this.#action(action, messageId, account),
37520
+ login: (account, messageId) => this.#loginState(account, messageId),
37521
+ cancelLogin: (account, messageId) => this.#cancelLogin(account, messageId),
37482
37522
  dropping: (messageId) => failedTurns(this.model.agent.messages(this.#id()), messageId).length,
37483
37523
  open: (path) => this.dispatchEvent(
37484
37524
  new CustomEvent("open-file", { detail: { path }, bubbles: true, composed: true })
@@ -37729,9 +37769,56 @@ var SliccChat = class extends ThemedElement {
37729
37769
  if (!restored) return;
37730
37770
  this.renderRoot.querySelector("slicc-composer")?.restore(latest ? { text: latest.text, attachments: latest.attachments } : restored);
37731
37771
  }
37732
- #action(action, messageId = "") {
37772
+ #logins = /* @__PURE__ */ new Map();
37773
+ #loginState(accountId, messageId) {
37774
+ const settings = this.model.settings;
37775
+ const account = settings.accounts().find((candidate) => candidate.id === accountId);
37776
+ const local2 = this.#logins.get(`${messageId}:${accountId}`);
37777
+ const cancel = !!settings.cancel;
37778
+ if (account?.status === "signing-in" || local2?.pending) return { state: "signing-in", cancel };
37779
+ if (account?.status === "connected") return { state: "connected" };
37780
+ return { state: "idle", error: local2?.error };
37781
+ }
37782
+ #cancelLogin(accountId, messageId) {
37783
+ const local2 = this.#logins.get(`${messageId}:${accountId}`);
37784
+ if (local2) local2.cancelled = true;
37785
+ this.model?.settings.cancel?.(accountId);
37786
+ }
37787
+ #settings(section) {
37788
+ this.dispatchEvent(
37789
+ new CustomEvent("show-surface", {
37790
+ detail: section ? { id: "settings", section } : { id: "settings" },
37791
+ bubbles: true,
37792
+ composed: true
37793
+ })
37794
+ );
37795
+ }
37796
+ #login(model, messageId, accountId) {
37797
+ const account = model.settings.accounts().find((candidate) => candidate.id === accountId);
37798
+ if (!account || account.auth === "api-key" || account.secret || account.fields?.length) {
37799
+ this.#settings(accountId ?? "accounts");
37800
+ return;
37801
+ }
37802
+ const local2 = { pending: true };
37803
+ this.#logins.set(`${messageId}:${account.id}`, local2);
37804
+ const done2 = (error) => {
37805
+ local2.pending = false;
37806
+ local2.error = local2.cancelled ? void 0 : error;
37807
+ this.requestUpdate();
37808
+ };
37809
+ model.settings.connect(account.id).then(
37810
+ () => done2(),
37811
+ (error) => done2(error.message)
37812
+ );
37813
+ this.requestUpdate();
37814
+ }
37815
+ #action(action, messageId = "", account) {
37733
37816
  const model = this.model;
37734
37817
  if (!model) return;
37818
+ if (action === "login") {
37819
+ this.#login(model, messageId, account);
37820
+ return;
37821
+ }
37735
37822
  const id = this.#id();
37736
37823
  if (action === "drop-turn") {
37737
37824
  void this.#rewind(id, messageId);
@@ -37742,9 +37829,7 @@ var SliccChat = class extends ThemedElement {
37742
37829
  if (last) void model.agent.send(id, { text: last.text, attachments: last.attachments });
37743
37830
  return;
37744
37831
  }
37745
- this.dispatchEvent(
37746
- new CustomEvent("show-surface", { detail: { id: "settings" }, bubbles: true, composed: true })
37747
- );
37832
+ this.#settings(account);
37748
37833
  }
37749
37834
  #message(message, agent, suggestion, changed, extra, owners, stamp, pile) {
37750
37835
  const model = this.model;
@@ -42163,6 +42248,15 @@ var SliccSettings = class extends ThemedElement {
42163
42248
  focus() {
42164
42249
  this.focusOn("sp-picker");
42165
42250
  }
42251
+ reveal(section) {
42252
+ void this.updateComplete.then(() => {
42253
+ const root2 = this.renderRoot;
42254
+ const row = root2.querySelector(`.account[data-id="${CSS.escape(section)}"]`);
42255
+ const target2 = row ?? root2.querySelector("h2[data-section=accounts]");
42256
+ row?.querySelector("swc-button")?.focus();
42257
+ target2?.scrollIntoView({ block: "start" });
42258
+ });
42259
+ }
42166
42260
  #update(patch) {
42167
42261
  this.model?.settings.update(patch);
42168
42262
  }
@@ -42552,7 +42646,7 @@ var SliccSettings = class extends ThemedElement {
42552
42646
  </sp-picker>
42553
42647
  </div>
42554
42648
  </div>
42555
- <h2>Accounts</h2>
42649
+ <h2 data-section="accounts">Accounts</h2>
42556
42650
  <div class="accounts">${providers.map((account) => this.#account(account))}</div>
42557
42651
  ${servers.length ? b`<h2>MCP servers</h2>
42558
42652
  <div class="accounts" data-group="mcp">${servers.map((account) => this.#account(account))}</div>` : A}