@noodleseed/assistant 1.15.0 → 1.16.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.
@@ -3,7 +3,7 @@ import {
3
3
  copyAssistantModelContext,
4
4
  createAssistantClient,
5
5
  sessionSourceKey
6
- } from "./chunk-RRJIK473.js";
6
+ } from "./chunk-NPV64PUX.js";
7
7
  import {
8
8
  _enum,
9
9
  _null,
@@ -6623,6 +6623,28 @@ function renderMarkdown(text2) {
6623
6623
  });
6624
6624
  }
6625
6625
 
6626
+ // src/sign-in-card.ts
6627
+ function createSignInCard(options) {
6628
+ const card = document.createElement("div");
6629
+ card.className = "noodle-assistant-card noodle-assistant-sign-in";
6630
+ card.dataset.tool = options.tool;
6631
+ card.setAttribute("role", "status");
6632
+ const heading = document.createElement("p");
6633
+ heading.className = "noodle-assistant-card-heading";
6634
+ heading.textContent = options.labels.heading;
6635
+ card.append(heading);
6636
+ const action = document.createElement("button");
6637
+ action.type = "button";
6638
+ action.className = "noodle-assistant-card-action";
6639
+ action.textContent = options.labels.action;
6640
+ action.addEventListener("click", () => {
6641
+ action.disabled = true;
6642
+ options.onSignIn();
6643
+ });
6644
+ card.append(action);
6645
+ return card;
6646
+ }
6647
+
6626
6648
  // src/element-event-controller.ts
6627
6649
  var AssistantElementEventController = class {
6628
6650
  #host;
@@ -6717,6 +6739,15 @@ var AssistantElementEventController = class {
6717
6739
  );
6718
6740
  return;
6719
6741
  }
6742
+ if (name === "auth_requested" && typeof data.continuation === "string") {
6743
+ this.#appendSignInRequest(
6744
+ String(data.id ?? ""),
6745
+ String(data.tool ?? "this"),
6746
+ data.continuation,
6747
+ String(data.expiresAt ?? "")
6748
+ );
6749
+ return;
6750
+ }
6720
6751
  if (name === "input_requested" && isRecord(data.requestedSchema)) {
6721
6752
  this.#appendInputRequest(
6722
6753
  String(data.id ?? ""),
@@ -6802,6 +6833,40 @@ var AssistantElementEventController = class {
6802
6833
  })
6803
6834
  );
6804
6835
  }
6836
+ /**
6837
+ * The host application owns the login. This renders the prompt and raises
6838
+ * `assistant-sign-in-requested`; the page signs the visitor in however it already does, then its
6839
+ * backend spends the continuation. Nothing here talks to an identity provider.
6840
+ */
6841
+ #appendSignInRequest(id, tool, continuation, expiresAt) {
6842
+ const messages = this.#host.messages();
6843
+ if (!messages) return;
6844
+ this.#proposalCards.get(id)?.remove();
6845
+ const card = createSignInCard({
6846
+ tool,
6847
+ continuation,
6848
+ expiresAt,
6849
+ labels: {
6850
+ heading: "Sign in to continue",
6851
+ action: "Sign in"
6852
+ },
6853
+ onSignIn: () => this.#host.element.dispatchEvent(
6854
+ new CustomEvent("assistant-sign-in-requested", {
6855
+ detail: { id, tool, continuation, expiresAt },
6856
+ bubbles: true,
6857
+ composed: true
6858
+ })
6859
+ )
6860
+ });
6861
+ messages.append(card);
6862
+ this.#proposalCards.set(id, card);
6863
+ this.#host.revealLatest();
6864
+ this.#host.element.dispatchEvent(
6865
+ new CustomEvent("assistant-sign-in-required", {
6866
+ detail: { id, tool, continuation, expiresAt }
6867
+ })
6868
+ );
6869
+ }
6805
6870
  #appendInputRequest(id, message, requestedSchema) {
6806
6871
  const messages = this.#host.messages();
6807
6872
  if (!messages || !id) return;
@@ -8240,4 +8305,4 @@ export {
8240
8305
  dompurify/dist/purify.es.mjs:
8241
8306
  (*! @license DOMPurify 3.4.11 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.11/LICENSE *)
8242
8307
  */
8243
- //# sourceMappingURL=chunk-SUHNNWKP.js.map
8308
+ //# sourceMappingURL=chunk-7L52WJ2E.js.map