@noodleseed/assistant 1.9.0 → 1.11.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-CsmtpD1z.cjs';
1
+ import { A as AssistantPageContext, a as AssistantContext, C as CreateAssistantClientOptions, b as AssistantChatState, c as AssistantClient } from '../client-BKIeuSVS.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-B803xZVn.js';
1
+ import { A as AssistantPageContext, a as AssistantContext, C as CreateAssistantClientOptions, b as AssistantChatState, c as AssistantClient } from '../client-BccAX_om.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-RYQBXTLR.js";
4
+ } from "../chunk-KRB2SXFD.js";
5
5
  import "../chunk-3YYTUJPJ.js";
6
6
  import "../chunk-5FUTL2UF.js";
7
7
 
package/dist/react.cjs CHANGED
@@ -22155,6 +22155,7 @@ function mountAssistantApp(detail, actions, options = {}) {
22155
22155
  let mountedTransport;
22156
22156
  let destroyed = false;
22157
22157
  let initialized = false;
22158
+ let hostContext = createAssistantAppHostContext(actions.theme);
22158
22159
  let destroyPromise;
22159
22160
  const renderTimer = setTimeout(() => {
22160
22161
  if (initialized || !frame.isConnected) return;
@@ -22181,7 +22182,7 @@ function mountAssistantApp(detail, actions, options = {}) {
22181
22182
  message: { text: {} }
22182
22183
  },
22183
22184
  {
22184
- hostContext: createAssistantAppHostContext(actions.theme)
22185
+ hostContext
22185
22186
  }
22186
22187
  );
22187
22188
  mountedBridge = bridge;
@@ -22256,6 +22257,7 @@ function mountAssistantApp(detail, actions, options = {}) {
22256
22257
  if (destroyed) return;
22257
22258
  initialized = true;
22258
22259
  clearTimeout(renderTimer);
22260
+ bridge.setHostContext(hostContext);
22259
22261
  const current = options.getDetail?.() ?? detail;
22260
22262
  void bridge.sendToolInput({ arguments: current.arguments ?? {} });
22261
22263
  void bridge.sendToolResult({
@@ -22271,6 +22273,11 @@ function mountAssistantApp(detail, actions, options = {}) {
22271
22273
  },
22272
22274
  { once: true }
22273
22275
  );
22276
+ const updateTheme = (theme) => {
22277
+ if (destroyed) return;
22278
+ hostContext = createAssistantAppHostContext(theme);
22279
+ if (initialized) mountedBridge?.setHostContext(hostContext);
22280
+ };
22274
22281
  const destroy = () => {
22275
22282
  if (destroyPromise) return destroyPromise;
22276
22283
  destroyed = true;
@@ -22289,9 +22296,12 @@ function mountAssistantApp(detail, actions, options = {}) {
22289
22296
  })();
22290
22297
  return destroyPromise;
22291
22298
  };
22292
- mountedApps.set(card, { destroy });
22299
+ mountedApps.set(card, { destroy, updateTheme });
22293
22300
  return card;
22294
22301
  }
22302
+ function updateAssistantAppTheme(card, theme) {
22303
+ mountedApps.get(card)?.updateTheme(theme);
22304
+ }
22295
22305
  function unmountAssistantApp(card) {
22296
22306
  return mountedApps.get(card)?.destroy() ?? Promise.resolve();
22297
22307
  }
@@ -27062,6 +27072,11 @@ function toAssistantClientEvent(event) {
27062
27072
  return event;
27063
27073
  }
27064
27074
  break;
27075
+ case "tool_started":
27076
+ if (hasString(value, "id") && hasString(value, "tool") && hasOptionalTurnId(value)) {
27077
+ return event;
27078
+ }
27079
+ break;
27065
27080
  case "tool_proposed":
27066
27081
  if (hasString(value, "id") && hasString(value, "tool") && hasOptionalString(value.title) && hasOptionalString(value.description) && hasOptionalJson(value.arguments) && (value.reviewSchema === void 0 || isRecord2(value.reviewSchema)) && hasOptionalString(value.expiresAt) && (value.requiresConfirmation === void 0 || value.requiresConfirmation === true) && hasOptionalTurnId(value)) {
27067
27082
  return event;
@@ -31426,7 +31441,7 @@ function contrastWarnings(theme, mode) {
31426
31441
  for (const [role, foreground, background] of pairs) {
31427
31442
  if (!foreground || !background) continue;
31428
31443
  const ratio = contrastRatio2(foreground, background);
31429
- if (ratio >= 4.5) continue;
31444
+ if (ratio === void 0 || ratio >= 4.5) continue;
31430
31445
  warnings.push({
31431
31446
  code: "low_contrast",
31432
31447
  theme: mode,
@@ -31440,13 +31455,16 @@ function contrastWarnings(theme, mode) {
31440
31455
  return warnings;
31441
31456
  }
31442
31457
  function contrastRatio2(first, second) {
31443
- const lighter = Math.max(luminance(first), luminance(second));
31444
- const darker = Math.min(luminance(first), luminance(second));
31458
+ const firstLuminance = luminance(first);
31459
+ const secondLuminance = luminance(second);
31460
+ if (firstLuminance === void 0 || secondLuminance === void 0) return void 0;
31461
+ const lighter = Math.max(firstLuminance, secondLuminance);
31462
+ const darker = Math.min(firstLuminance, secondLuminance);
31445
31463
  return (lighter + 0.05) / (darker + 0.05);
31446
31464
  }
31447
31465
  function luminance(color) {
31448
31466
  const match = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(color);
31449
- if (!match) return 1;
31467
+ if (!match) return void 0;
31450
31468
  const values = match.slice(1).map((value) => {
31451
31469
  const channel = Number.parseInt(value, 16) / 255;
31452
31470
  return channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4;
@@ -32279,6 +32297,9 @@ var NoodleAssistantElement = class extends HTMLElementBase {
32279
32297
  })
32280
32298
  );
32281
32299
  }
32300
+ for (const app of this.shadowRoot?.querySelectorAll(".noodle-app-card") ?? []) {
32301
+ updateAssistantAppTheme(app, mode);
32302
+ }
32282
32303
  }
32283
32304
  #setSessionState(state) {
32284
32305
  this.#sessionState = state;
@@ -32462,6 +32483,7 @@ function NoodleAppView({
32462
32483
  onError
32463
32484
  }) {
32464
32485
  const container = (0, import_react.useRef)(null);
32486
+ const mounted = (0, import_react.useRef)(null);
32465
32487
  const current = (0, import_react.useRef)({ view, theme, onError });
32466
32488
  const viewId = view.id;
32467
32489
  const resourceUri = view.resourceUri;
@@ -32488,11 +32510,16 @@ function NoodleAppView({
32488
32510
  }
32489
32511
  );
32490
32512
  if (!card) return;
32513
+ mounted.current = card;
32491
32514
  host.replaceChildren(card);
32492
32515
  return () => {
32516
+ if (mounted.current === card) mounted.current = null;
32493
32517
  void unmountAssistantApp(card);
32494
32518
  };
32495
32519
  }, [client, resourceUri, viewId]);
32520
+ (0, import_react.useEffect)(() => {
32521
+ if (mounted.current) updateAssistantAppTheme(mounted.current, theme);
32522
+ }, [theme]);
32496
32523
  return (0, import_react.createElement)("div", { ref: container, className });
32497
32524
  }
32498
32525