@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.
@@ -1,4 +1,4 @@
1
- import { A as AssistantPageContext, a as AssistantContext, C as CreateAssistantClientOptions, b as AssistantChatState, c as AssistantClient } from '../client-B_l59rWg.cjs';
1
+ import { A as AssistantPageContext, a as AssistantContext, C as CreateAssistantClientOptions, b as AssistantChatState, c as AssistantClient } from '../client-401BAJqk.cjs';
2
2
  import '../appearance-Cc-eqSbp.cjs';
3
3
  import 'ai';
4
4
 
@@ -1,4 +1,4 @@
1
- import { A as AssistantPageContext, a as AssistantContext, C as CreateAssistantClientOptions, b as AssistantChatState, c as AssistantClient } from '../client-MnLfiyo2.js';
1
+ import { A as AssistantPageContext, a as AssistantContext, C as CreateAssistantClientOptions, b as AssistantChatState, c as AssistantClient } from '../client-Ii_xTV09.js';
2
2
  import '../appearance-Cc-eqSbp.js';
3
3
  import 'ai';
4
4
 
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  createAssistantClient
4
- } from "../chunk-RRJIK473.js";
4
+ } from "../chunk-NPV64PUX.js";
5
5
  import "../chunk-3YYTUJPJ.js";
6
6
  import "../chunk-5FUTL2UF.js";
7
7
 
package/dist/react.cjs CHANGED
@@ -27095,6 +27095,11 @@ function toAssistantClientEvent(event) {
27095
27095
  return event;
27096
27096
  }
27097
27097
  break;
27098
+ case "auth_requested":
27099
+ if (hasString(value, "id") && hasString(value, "tool") && hasString(value, "continuation") && hasString(value, "expiresAt") && hasOptionalTurnId(value)) {
27100
+ return event;
27101
+ }
27102
+ break;
27098
27103
  case "interaction_resolved":
27099
27104
  if (hasString(value, "id") && (value.action === void 0 || isInteractionAction(value.action)) && hasOptionalTurnId(value)) {
27100
27105
  return event;
@@ -31044,6 +31049,28 @@ function renderMarkdown(text3) {
31044
31049
  });
31045
31050
  }
31046
31051
 
31052
+ // src/sign-in-card.ts
31053
+ function createSignInCard(options) {
31054
+ const card = document.createElement("div");
31055
+ card.className = "noodle-assistant-card noodle-assistant-sign-in";
31056
+ card.dataset.tool = options.tool;
31057
+ card.setAttribute("role", "status");
31058
+ const heading = document.createElement("p");
31059
+ heading.className = "noodle-assistant-card-heading";
31060
+ heading.textContent = options.labels.heading;
31061
+ card.append(heading);
31062
+ const action = document.createElement("button");
31063
+ action.type = "button";
31064
+ action.className = "noodle-assistant-card-action";
31065
+ action.textContent = options.labels.action;
31066
+ action.addEventListener("click", () => {
31067
+ action.disabled = true;
31068
+ options.onSignIn();
31069
+ });
31070
+ card.append(action);
31071
+ return card;
31072
+ }
31073
+
31047
31074
  // src/element-event-controller.ts
31048
31075
  var AssistantElementEventController = class {
31049
31076
  #host;
@@ -31138,6 +31165,15 @@ var AssistantElementEventController = class {
31138
31165
  );
31139
31166
  return;
31140
31167
  }
31168
+ if (name21 === "auth_requested" && typeof data.continuation === "string") {
31169
+ this.#appendSignInRequest(
31170
+ String(data.id ?? ""),
31171
+ String(data.tool ?? "this"),
31172
+ data.continuation,
31173
+ String(data.expiresAt ?? "")
31174
+ );
31175
+ return;
31176
+ }
31141
31177
  if (name21 === "input_requested" && isRecord5(data.requestedSchema)) {
31142
31178
  this.#appendInputRequest(
31143
31179
  String(data.id ?? ""),
@@ -31223,6 +31259,40 @@ var AssistantElementEventController = class {
31223
31259
  })
31224
31260
  );
31225
31261
  }
31262
+ /**
31263
+ * The host application owns the login. This renders the prompt and raises
31264
+ * `assistant-sign-in-requested`; the page signs the visitor in however it already does, then its
31265
+ * backend spends the continuation. Nothing here talks to an identity provider.
31266
+ */
31267
+ #appendSignInRequest(id, tool, continuation, expiresAt) {
31268
+ const messages = this.#host.messages();
31269
+ if (!messages) return;
31270
+ this.#proposalCards.get(id)?.remove();
31271
+ const card = createSignInCard({
31272
+ tool,
31273
+ continuation,
31274
+ expiresAt,
31275
+ labels: {
31276
+ heading: "Sign in to continue",
31277
+ action: "Sign in"
31278
+ },
31279
+ onSignIn: () => this.#host.element.dispatchEvent(
31280
+ new CustomEvent("assistant-sign-in-requested", {
31281
+ detail: { id, tool, continuation, expiresAt },
31282
+ bubbles: true,
31283
+ composed: true
31284
+ })
31285
+ )
31286
+ });
31287
+ messages.append(card);
31288
+ this.#proposalCards.set(id, card);
31289
+ this.#host.revealLatest();
31290
+ this.#host.element.dispatchEvent(
31291
+ new CustomEvent("assistant-sign-in-required", {
31292
+ detail: { id, tool, continuation, expiresAt }
31293
+ })
31294
+ );
31295
+ }
31226
31296
  #appendInputRequest(id, message, requestedSchema) {
31227
31297
  const messages = this.#host.messages();
31228
31298
  if (!messages || !id) return;