@noodleseed/assistant 1.23.0 → 1.24.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.
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
- import { a as AssistantViewAvailableDetail, g as AssistantClientEvent, c as AssistantContext, f as AssistantModelContextUpdate, b as AssistantPageContext, h as AssistantInteractionResponse } from './client-uo57Swlm.cjs';
2
- export { e as AssistantErrorDetail, i as AssistantEvent, j as AssistantViewAvailableEvent } from './client-uo57Swlm.cjs';
3
- import './appearance-Cc-eqSbp.cjs';
1
+ import { a as AssistantViewAvailableDetail, g as AssistantClientEvent, c as AssistantContext, f as AssistantModelContextUpdate, b as AssistantPageContext, h as AssistantInteractionResponse } from './client-By4gqB1k.cjs';
2
+ export { e as AssistantErrorDetail, i as AssistantEvent, j as AssistantViewAvailableEvent } from './client-By4gqB1k.cjs';
3
+ import './appearance-0nS2LFjb.cjs';
4
4
  import 'ai';
5
5
 
6
6
  interface AssistantSurfaceAppearance {
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { a as AssistantViewAvailableDetail, g as AssistantClientEvent, c as AssistantContext, f as AssistantModelContextUpdate, b as AssistantPageContext, h as AssistantInteractionResponse } from './client-Bp_VKpMg.js';
2
- export { e as AssistantErrorDetail, i as AssistantEvent, j as AssistantViewAvailableEvent } from './client-Bp_VKpMg.js';
3
- import './appearance-Cc-eqSbp.js';
1
+ import { a as AssistantViewAvailableDetail, g as AssistantClientEvent, c as AssistantContext, f as AssistantModelContextUpdate, b as AssistantPageContext, h as AssistantInteractionResponse } from './client-Cf38TgwN.js';
2
+ export { e as AssistantErrorDetail, i as AssistantEvent, j as AssistantViewAvailableEvent } from './client-Cf38TgwN.js';
3
+ import './appearance-0nS2LFjb.js';
4
4
  import 'ai';
5
5
 
6
6
  interface AssistantSurfaceAppearance {
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  ASSISTANT_TAG_NAME,
3
3
  NoodleAssistantElement,
4
4
  registerNoodleAssistant
5
- } from "./chunk-X7UQDIGS.js";
5
+ } from "./chunk-6PVDV7SO.js";
6
6
  import "./chunk-XKTUXFGX.js";
7
7
  import "./chunk-IBDP6PXQ.js";
8
8
  import "./chunk-P223CYPO.js";
@@ -1,5 +1,5 @@
1
- import { b as AssistantPageContext, c as AssistantContext, C as CreateAssistantClientOptions, d as AssistantChatState, A as AssistantClient } from '../client-uo57Swlm.cjs';
2
- import '../appearance-Cc-eqSbp.cjs';
1
+ import { b as AssistantPageContext, c as AssistantContext, C as CreateAssistantClientOptions, d as AssistantChatState, A as AssistantClient } from '../client-By4gqB1k.cjs';
2
+ import '../appearance-0nS2LFjb.cjs';
3
3
  import 'ai';
4
4
 
5
5
  type UseNoodleAssistantOptions<TPageContext extends AssistantPageContext = AssistantContext> = CreateAssistantClientOptions<TPageContext> & {
@@ -1,5 +1,5 @@
1
- import { b as AssistantPageContext, c as AssistantContext, C as CreateAssistantClientOptions, d as AssistantChatState, A as AssistantClient } from '../client-Bp_VKpMg.js';
2
- import '../appearance-Cc-eqSbp.js';
1
+ import { b as AssistantPageContext, c as AssistantContext, C as CreateAssistantClientOptions, d as AssistantChatState, A as AssistantClient } from '../client-Cf38TgwN.js';
2
+ import '../appearance-0nS2LFjb.js';
3
3
  import 'ai';
4
4
 
5
5
  type UseNoodleAssistantOptions<TPageContext extends AssistantPageContext = AssistantContext> = CreateAssistantClientOptions<TPageContext> & {
package/dist/react.cjs CHANGED
@@ -22451,6 +22451,7 @@ var DEFAULT_APPEARANCE = {
22451
22451
  copy: "Copy",
22452
22452
  newMessages: "New messages",
22453
22453
  reconnect: "Reconnect",
22454
+ newConversation: "New conversation",
22454
22455
  retry: "Try again",
22455
22456
  unavailable: "The assistant is temporarily unavailable.",
22456
22457
  sessionExpired: "Your assistant session expired. Reopen it to continue.",
@@ -28160,6 +28161,27 @@ function appInteractionStopped(action) {
28160
28161
  };
28161
28162
  }
28162
28163
 
28164
+ // src/conversation-recovery.ts
28165
+ function appendConversationRecovery(input) {
28166
+ if (!input.messages) return;
28167
+ input.messages.querySelector(".conversation-error")?.remove();
28168
+ const error51 = document.createElement("section");
28169
+ error51.className = "conversation-error";
28170
+ error51.setAttribute("role", input.action ? "alert" : "status");
28171
+ const text3 = document.createElement("p");
28172
+ text3.textContent = input.message;
28173
+ error51.append(text3);
28174
+ if (input.action) {
28175
+ const button2 = document.createElement("button");
28176
+ button2.type = "button";
28177
+ button2.textContent = input.action.label;
28178
+ button2.addEventListener("click", input.action.run);
28179
+ error51.append(button2);
28180
+ }
28181
+ input.messages.append(error51);
28182
+ input.revealLatest();
28183
+ }
28184
+
28163
28185
  // src/input-request-card.ts
28164
28186
  function createInputRequestCard(options) {
28165
28187
  const card = document.createElement("section");
@@ -32846,33 +32868,28 @@ var NoodleAssistantElement = class extends HTMLElementBase {
32846
32868
  this.#setSessionState("error");
32847
32869
  }
32848
32870
  const detail = error51 instanceof AssistantClientError ? error51.detail : { code: fallbackCode, retryable: false };
32849
- this.#appendRecoveryError(
32850
- detail.code === "session_expired" ? this.#appearance.labels.sessionExpired : this.#appearance.labels.unavailable,
32871
+ const startNewConversation = detail.serviceCode === "session_turn_budget_exhausted";
32872
+ const reconnect = detail.retryable !== false || detail.serviceCode === void 0;
32873
+ const recoveryAction = startNewConversation ? {
32874
+ label: this.#appearance.labels.newConversation,
32875
+ run: () => this.#startNewConversation()
32876
+ } : reconnect ? { label: this.#appearance.labels.reconnect, run: () => this.reconnect() } : void 0;
32877
+ appendConversationRecovery({
32878
+ messages: this.#messages,
32879
+ message: detail.code === "session_expired" ? this.#appearance.labels.sessionExpired : this.#appearance.labels.unavailable,
32851
32880
  // A spent or switched-off daily budget offers no retry. Reconnecting cannot succeed, and every
32852
32881
  // open tab trying is exactly the load the cap was set to refuse — so the button goes, not just
32853
32882
  // the alarming words. A spent *session* keeps it: reconnect mints a fresh one, which is the fix.
32854
- detail.retryable !== false || detail.serviceCode === void 0
32855
- );
32883
+ ...recoveryAction === void 0 ? {} : { action: recoveryAction },
32884
+ revealLatest: () => this.#revealLatest()
32885
+ });
32856
32886
  this.#dispatchError(detail);
32857
32887
  }
32858
- #appendRecoveryError(message, offerRetry = true) {
32859
- if (!this.#messages) return;
32860
- this.#messages.querySelector(".conversation-error")?.remove();
32861
- const error51 = document.createElement("section");
32862
- error51.className = "conversation-error";
32863
- error51.setAttribute("role", offerRetry ? "alert" : "status");
32864
- const text3 = document.createElement("p");
32865
- text3.textContent = message;
32866
- error51.append(text3);
32867
- if (offerRetry) {
32868
- const retry = document.createElement("button");
32869
- retry.type = "button";
32870
- retry.textContent = this.#appearance.labels.reconnect;
32871
- retry.addEventListener("click", () => this.reconnect());
32872
- error51.append(retry);
32873
- }
32874
- this.#messages.append(error51);
32875
- this.#revealLatest();
32888
+ #startNewConversation() {
32889
+ this.resetSession();
32890
+ this.#setSessionState("loading");
32891
+ this.#primeSession();
32892
+ this.dispatchEvent(new CustomEvent("assistant-new-conversation"));
32876
32893
  }
32877
32894
  #resolvedMode() {
32878
32895
  const configured = this.getAttribute("theme") ?? this.#appearance.theme.defaultMode;