@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.
@@ -1,4 +1,4 @@
1
- import { A as AssistantClient, a as AssistantViewAvailableDetail, e as AssistantErrorDetail } from './client-Bp_VKpMg.js';
1
+ import { A as AssistantClient, a as AssistantViewAvailableDetail, e as AssistantErrorDetail } from './client-Cf38TgwN.js';
2
2
 
3
3
  declare const APP_VIEW_TAG_NAME = "noodle-app-view";
4
4
  interface AssistantAppViewErrorDetail {
@@ -1,4 +1,4 @@
1
- import { A as AssistantClient, a as AssistantViewAvailableDetail, e as AssistantErrorDetail } from './client-uo57Swlm.cjs';
1
+ import { A as AssistantClient, a as AssistantViewAvailableDetail, e as AssistantErrorDetail } from './client-By4gqB1k.cjs';
2
2
 
3
3
  declare const APP_VIEW_TAG_NAME = "noodle-app-view";
4
4
  interface AssistantAppViewErrorDetail {
@@ -1,6 +1,6 @@
1
- export { A as APP_VIEW_TAG_NAME, a as AssistantAppViewErrorDetail, N as NoodleAppViewElement } from './app-view-element-1i_w6FDf.cjs';
2
- export { A as AssistantClient, a as AssistantViewAvailableDetail } from './client-uo57Swlm.cjs';
3
- import './appearance-Cc-eqSbp.cjs';
1
+ export { A as APP_VIEW_TAG_NAME, a as AssistantAppViewErrorDetail, N as NoodleAppViewElement } from './app-view-element-DSPtyEul.cjs';
2
+ export { A as AssistantClient, a as AssistantViewAvailableDetail } from './client-By4gqB1k.cjs';
3
+ import './appearance-0nS2LFjb.cjs';
4
4
  import 'ai';
5
5
 
6
6
  /** Register the framework-neutral MCP App host. Safe to call more than once or during SSR. */
@@ -1,6 +1,6 @@
1
- export { A as APP_VIEW_TAG_NAME, a as AssistantAppViewErrorDetail, N as NoodleAppViewElement } from './app-view-element-7ZQZLYbL.js';
2
- export { A as AssistantClient, a as AssistantViewAvailableDetail } from './client-Bp_VKpMg.js';
3
- import './appearance-Cc-eqSbp.js';
1
+ export { A as APP_VIEW_TAG_NAME, a as AssistantAppViewErrorDetail, N as NoodleAppViewElement } from './app-view-element-DDtXu08a.js';
2
+ export { A as AssistantClient, a as AssistantViewAvailableDetail } from './client-Cf38TgwN.js';
3
+ import './appearance-0nS2LFjb.js';
4
4
  import 'ai';
5
5
 
6
6
  /** Register the framework-neutral MCP App host. Safe to call more than once or during SSR. */
@@ -124,6 +124,7 @@ interface AssistantLabels {
124
124
  readonly copy: string;
125
125
  readonly newMessages: string;
126
126
  readonly reconnect: string;
127
+ readonly newConversation: string;
127
128
  readonly retry: string;
128
129
  readonly unavailable: string;
129
130
  readonly sessionExpired: string;
@@ -124,6 +124,7 @@ interface AssistantLabels {
124
124
  readonly copy: string;
125
125
  readonly newMessages: string;
126
126
  readonly reconnect: string;
127
+ readonly newConversation: string;
127
128
  readonly retry: string;
128
129
  readonly unavailable: string;
129
130
  readonly sessionExpired: string;
@@ -118,6 +118,7 @@ var DEFAULT_APPEARANCE = {
118
118
  copy: "Copy",
119
119
  newMessages: "New messages",
120
120
  reconnect: "Reconnect",
121
+ newConversation: "New conversation",
121
122
  retry: "Try again",
122
123
  unavailable: "The assistant is temporarily unavailable.",
123
124
  sessionExpired: "Your assistant session expired. Reopen it to continue.",
@@ -393,6 +394,27 @@ function decodeUtf8(bytes, truncated) {
393
394
  }
394
395
  }
395
396
 
397
+ // src/conversation-recovery.ts
398
+ function appendConversationRecovery(input) {
399
+ if (!input.messages) return;
400
+ input.messages.querySelector(".conversation-error")?.remove();
401
+ const error = document.createElement("section");
402
+ error.className = "conversation-error";
403
+ error.setAttribute("role", input.action ? "alert" : "status");
404
+ const text2 = document.createElement("p");
405
+ text2.textContent = input.message;
406
+ error.append(text2);
407
+ if (input.action) {
408
+ const button2 = document.createElement("button");
409
+ button2.type = "button";
410
+ button2.textContent = input.action.label;
411
+ button2.addEventListener("click", input.action.run);
412
+ error.append(button2);
413
+ }
414
+ input.messages.append(error);
415
+ input.revealLatest();
416
+ }
417
+
396
418
  // src/input-request-card.ts
397
419
  function createInputRequestCard(options) {
398
420
  const card = document.createElement("section");
@@ -5056,33 +5078,28 @@ var NoodleAssistantElement = class extends HTMLElementBase {
5056
5078
  this.#setSessionState("error");
5057
5079
  }
5058
5080
  const detail = error instanceof AssistantClientError ? error.detail : { code: fallbackCode, retryable: false };
5059
- this.#appendRecoveryError(
5060
- detail.code === "session_expired" ? this.#appearance.labels.sessionExpired : this.#appearance.labels.unavailable,
5081
+ const startNewConversation = detail.serviceCode === "session_turn_budget_exhausted";
5082
+ const reconnect = detail.retryable !== false || detail.serviceCode === void 0;
5083
+ const recoveryAction = startNewConversation ? {
5084
+ label: this.#appearance.labels.newConversation,
5085
+ run: () => this.#startNewConversation()
5086
+ } : reconnect ? { label: this.#appearance.labels.reconnect, run: () => this.reconnect() } : void 0;
5087
+ appendConversationRecovery({
5088
+ messages: this.#messages,
5089
+ message: detail.code === "session_expired" ? this.#appearance.labels.sessionExpired : this.#appearance.labels.unavailable,
5061
5090
  // A spent or switched-off daily budget offers no retry. Reconnecting cannot succeed, and every
5062
5091
  // open tab trying is exactly the load the cap was set to refuse — so the button goes, not just
5063
5092
  // the alarming words. A spent *session* keeps it: reconnect mints a fresh one, which is the fix.
5064
- detail.retryable !== false || detail.serviceCode === void 0
5065
- );
5093
+ ...recoveryAction === void 0 ? {} : { action: recoveryAction },
5094
+ revealLatest: () => this.#revealLatest()
5095
+ });
5066
5096
  this.#dispatchError(detail);
5067
5097
  }
5068
- #appendRecoveryError(message, offerRetry = true) {
5069
- if (!this.#messages) return;
5070
- this.#messages.querySelector(".conversation-error")?.remove();
5071
- const error = document.createElement("section");
5072
- error.className = "conversation-error";
5073
- error.setAttribute("role", offerRetry ? "alert" : "status");
5074
- const text2 = document.createElement("p");
5075
- text2.textContent = message;
5076
- error.append(text2);
5077
- if (offerRetry) {
5078
- const retry = document.createElement("button");
5079
- retry.type = "button";
5080
- retry.textContent = this.#appearance.labels.reconnect;
5081
- retry.addEventListener("click", () => this.reconnect());
5082
- error.append(retry);
5083
- }
5084
- this.#messages.append(error);
5085
- this.#revealLatest();
5098
+ #startNewConversation() {
5099
+ this.resetSession();
5100
+ this.#setSessionState("loading");
5101
+ this.#primeSession();
5102
+ this.dispatchEvent(new CustomEvent("assistant-new-conversation"));
5086
5103
  }
5087
5104
  #resolvedMode() {
5088
5105
  const configured = this.getAttribute("theme") ?? this.#appearance.theme.defaultMode;
@@ -5268,4 +5285,4 @@ export {
5268
5285
  dompurify/dist/purify.es.mjs:
5269
5286
  (*! @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 *)
5270
5287
  */
5271
- //# sourceMappingURL=chunk-X7UQDIGS.js.map
5288
+ //# sourceMappingURL=chunk-6PVDV7SO.js.map