@noodleseed/assistant 1.25.0 → 1.25.1

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.js CHANGED
@@ -2,8 +2,8 @@ import {
2
2
  ASSISTANT_TAG_NAME,
3
3
  NoodleAssistantElement,
4
4
  registerNoodleAssistant
5
- } from "./chunk-SGMECNNU.js";
6
- import "./chunk-P32MAR4K.js";
5
+ } from "./chunk-FJYPE4GC.js";
6
+ import "./chunk-CF2SCDLF.js";
7
7
  import "./chunk-7BQHW37I.js";
8
8
  import "./chunk-P223CYPO.js";
9
9
  import "./chunk-3YYTUJPJ.js";
package/dist/react.cjs CHANGED
@@ -21798,15 +21798,6 @@ var E = class {
21798
21798
  sessionId;
21799
21799
  setProtocolVersion;
21800
21800
  };
21801
- function AZ(X2) {
21802
- if (!X2) return "";
21803
- let Y = [];
21804
- if (X2.camera) Y.push("camera");
21805
- if (X2.microphone) Y.push("microphone");
21806
- if (X2.geolocation) Y.push("geolocation");
21807
- if (X2.clipboardWrite) Y.push("clipboard-write");
21808
- return Y.join("; ");
21809
- }
21810
21801
  var KX = [j];
21811
21802
  var DX = class extends _ {
21812
21803
  _client;
@@ -22077,131 +22068,34 @@ function GX(X2, Y) {
22077
22068
  return JSON.stringify(X2) === JSON.stringify(Y);
22078
22069
  }
22079
22070
 
22080
- // src/app-sandbox-policy.ts
22081
- var MAX_DOMAINS_PER_DIRECTIVE = 32;
22082
- function isRecord(value) {
22083
- return typeof value === "object" && value !== null && !Array.isArray(value);
22084
- }
22085
- function isLoopback(hostname3) {
22086
- return hostname3 === "localhost" || hostname3 === "127.0.0.1" || hostname3 === "[::1]";
22087
- }
22088
- function normalizeDomain(value, connect) {
22089
- if (value.length > 512 || /[;\r\n'"\s]/u.test(value)) return void 0;
22090
- try {
22091
- const parsed = new URL(value);
22092
- const secure = parsed.protocol === "https:" || connect && parsed.protocol === "wss:";
22093
- const local = isLoopback(parsed.hostname) && (parsed.protocol === "http:" || connect && parsed.protocol === "ws:");
22094
- if (!secure && !local) return void 0;
22095
- if (parsed.username || parsed.password || parsed.pathname !== "/" || parsed.search || parsed.hash) {
22096
- return void 0;
22097
- }
22098
- return parsed.origin;
22099
- } catch {
22100
- return void 0;
22101
- }
22102
- }
22103
- function normalizeDomains(values, connect) {
22104
- const normalized = [
22105
- ...new Set(
22106
- values.slice(0, MAX_DOMAINS_PER_DIRECTIVE).map((value) => typeof value === "string" ? normalizeDomain(value, connect) : void 0).filter((value) => value !== void 0)
22107
- )
22108
- ];
22109
- return normalized;
22110
- }
22111
- function resolveAssistantAppSandboxPolicy(resourceMeta) {
22112
- if (!isRecord(resourceMeta)) return {};
22113
- const rawCsp = resourceMeta.csp;
22114
- const csp = isRecord(rawCsp) ? {
22115
- ...Array.isArray(rawCsp.connectDomains) ? { connectDomains: normalizeDomains(rawCsp.connectDomains, true) } : {},
22116
- ...Array.isArray(rawCsp.resourceDomains) ? { resourceDomains: normalizeDomains(rawCsp.resourceDomains, false) } : {},
22117
- ...Array.isArray(rawCsp.frameDomains) ? { frameDomains: normalizeDomains(rawCsp.frameDomains, false) } : {},
22118
- ...Array.isArray(rawCsp.baseUriDomains) ? { baseUriDomains: normalizeDomains(rawCsp.baseUriDomains, false) } : {}
22119
- } : void 0;
22120
- const rawPermissions = resourceMeta.permissions;
22121
- const permissions = isRecord(rawPermissions) ? {
22122
- ...isRecord(rawPermissions.camera) ? { camera: {} } : {},
22123
- ...isRecord(rawPermissions.microphone) ? { microphone: {} } : {},
22124
- ...isRecord(rawPermissions.geolocation) ? { geolocation: {} } : {},
22125
- ...isRecord(rawPermissions.clipboardWrite) ? { clipboardWrite: {} } : {}
22126
- } : void 0;
22127
- const allowAttribute = AZ(permissions);
22128
- return {
22129
- ...csp === void 0 ? {} : { csp },
22130
- ...permissions === void 0 ? {} : { permissions },
22131
- ...allowAttribute ? { allowAttribute } : {}
22132
- };
22133
- }
22134
- function assistantAppSandboxUrl(sandboxUrl, policy) {
22135
- const parsed = new URL(sandboxUrl);
22136
- if (policy.csp) parsed.searchParams.set("csp", JSON.stringify(policy.csp));
22137
- const parentOrigin = globalThis.location?.origin;
22138
- if (parentOrigin && parentOrigin !== "null") {
22139
- parsed.hash = new URLSearchParams({ parentOrigin }).toString();
22140
- }
22141
- return parsed.href;
22142
- }
22143
-
22144
22071
  // src/app-host.ts
22145
- var PROXY_DOCUMENT = `<!doctype html><meta charset="utf-8"><style>html,body,iframe{border:0;margin:0;width:100%;height:100%;overflow:hidden}body{background:transparent}</style><body><script>
22146
- let inner,loaded=false;
22147
- if(self===top)throw new Error('The assistant sandbox relay must be embedded');
22148
- const standardSandbox='allow-scripts allow-same-origin allow-forms';
22149
- const rawParentOrigin=new URLSearchParams(location.hash.slice(1)).get('parentOrigin');
22150
- let expectedParentOrigin;
22151
- try{const parsed=new URL(rawParentOrigin||'');if(parsed.origin===rawParentOrigin&&/^https?:$/.test(parsed.protocol))expectedParentOrigin=parsed.origin}catch{}
22152
- const parentTarget=expectedParentOrigin||'*';
22153
- const ownOrigin=self.origin;
22072
+ var PROXY_DOCUMENT = `<!doctype html><meta charset="utf-8"><style>html,body,iframe{border:0;margin:0;width:100%;height:100%;overflow:hidden}body{background:transparent}</style><script>
22073
+ let inner;
22154
22074
  const ready={jsonrpc:'2.0',method:'ui/notifications/sandbox-proxy-ready',params:{}};
22155
22075
  // Re-announce until the host acknowledges with the resource: when this document is hosted
22156
22076
  // cross-origin, the first announcement can arrive before the host's load handler is listening.
22157
- const announce=setInterval(()=>parent.postMessage(ready,parentTarget),120);
22077
+ const announce=setInterval(()=>parent.postMessage(ready,'*'),120);
22158
22078
  setTimeout(()=>clearInterval(announce),15000);
22159
22079
  addEventListener('message',(event)=>{
22160
22080
  if(event.source===parent){
22161
- if(expectedParentOrigin&&event.origin!==expectedParentOrigin)return;
22162
22081
  const message=event.data;
22163
22082
  if(message?.method==='ui/notifications/sandbox-resource-ready'){
22164
22083
  clearInterval(announce);
22165
- if(loaded)return;
22166
- loaded=true;
22167
- const requestedSandbox=message.params?.sandbox;
22084
+ if(inner)return;
22168
22085
  inner=document.createElement('iframe');
22169
- inner.setAttribute('sandbox',requestedSandbox===standardSandbox?standardSandbox:'allow-scripts');
22086
+ inner.setAttribute('sandbox',message.params?.sandbox||'allow-scripts');
22170
22087
  inner.setAttribute('referrerpolicy','no-referrer');
22171
- const permissions=message.params?.permissions;
22172
- const allow=[];
22173
- if(permissions?.camera)allow.push('camera');
22174
- if(permissions?.microphone)allow.push('microphone');
22175
- if(permissions?.geolocation)allow.push('geolocation');
22176
- if(permissions?.clipboardWrite)allow.push('clipboard-write');
22177
- if(allow.length)inner.setAttribute('allow',allow.join('; '));
22178
- document.body.append(inner);
22179
- let html=String(message.params?.html||'');
22180
- const csp=message.params?.csp;
22181
- if(csp&&typeof csp==='object'){
22182
- const list=(value,fallback)=>Array.isArray(value)&&value.length?value.join(' '):fallback;
22183
- const resources=Array.isArray(csp.resourceDomains)?csp.resourceDomains:[];
22184
- const suffix=resources.length?' '+resources.join(' '):'';
22185
- const policy=["default-src 'none'","script-src 'unsafe-inline'"+suffix,"style-src 'unsafe-inline'"+suffix,'img-src data: blob:'+suffix,'font-src data: blob:'+suffix,'media-src data: blob:'+suffix,'worker-src blob:'+suffix,'connect-src '+list(csp.connectDomains,"'none'"),'frame-src '+list(csp.frameDomains,"'none'"),"object-src 'none'","form-action 'none'",'base-uri '+list(csp.baseUriDomains,"'none'")].join('; ');
22186
- const meta='<meta http-equiv="Content-Security-Policy" content="'+policy.replace(/&/g,'&amp;').replace(/"/g,'&quot;')+'">';
22187
- const doctype=html.match(/^\\s*<!doctype[^>]*>/i);
22188
- html=doctype?html.slice(0,doctype[0].length)+meta+html.slice(doctype[0].length):meta+html;
22189
- }
22190
- try{
22191
- const doc=inner.contentDocument||inner.contentWindow?.document;
22192
- if(!doc)throw new Error('document unavailable');
22193
- doc.open();doc.write(html);doc.close();
22194
- }catch{inner.srcdoc=html}
22088
+ inner.srcdoc=String(message.params?.html||'');
22089
+ document.body.replaceChildren(inner);
22195
22090
  return;
22196
22091
  }
22197
22092
  inner?.contentWindow?.postMessage(message,'*');
22198
22093
  } else if(inner && event.source===inner.contentWindow) {
22199
- if(event.origin!==ownOrigin)return;
22200
- parent.postMessage(event.data,parentTarget);
22094
+ parent.postMessage(event.data,'*');
22201
22095
  }
22202
22096
  });
22203
- parent.postMessage(ready,parentTarget);
22204
- </script></body>`;
22097
+ parent.postMessage(ready,'*');
22098
+ </script>`;
22205
22099
  function isAllowedAppLink(value, allowedDomains, baseUrl) {
22206
22100
  try {
22207
22101
  const parsed = new URL(value, baseUrl);
@@ -22228,42 +22122,16 @@ function createAssistantAppHostContext(theme, allowFullscreen = false, displayMo
22228
22122
  }
22229
22123
  var APP_RENDER_TIMEOUT_MS = 1e4;
22230
22124
  var APP_TEARDOWN_TIMEOUT_MS = 1e3;
22231
- var STANDARD_SANDBOX = "allow-scripts allow-same-origin allow-forms";
22232
22125
  var mountedApps = /* @__PURE__ */ new WeakMap();
22233
22126
  function resolveSandboxUrl(value) {
22234
22127
  if (!value) return void 0;
22235
22128
  try {
22236
22129
  const parsed = new URL(value);
22237
- const loopback = parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1" || parsed.hostname === "[::1]";
22238
- const permittedProtocol = parsed.protocol === "https:" || parsed.protocol === "http:" && loopback;
22239
- const embedderOrigin = globalThis.location?.origin;
22240
- if (!permittedProtocol || embedderOrigin && embedderOrigin !== "null" && parsed.origin === embedderOrigin) {
22241
- return void 0;
22242
- }
22243
- return parsed.href;
22130
+ return parsed.protocol === "https:" || parsed.protocol === "http:" ? parsed.href : void 0;
22244
22131
  } catch {
22245
22132
  return void 0;
22246
22133
  }
22247
22134
  }
22248
- function copyAppJson(value, depth = 0) {
22249
- if (depth > 64) throw new Error("App payload nesting exceeds the host limit");
22250
- if (value === null || typeof value === "string" || typeof value === "boolean") return value;
22251
- if (typeof value === "number") {
22252
- if (!Number.isFinite(value)) throw new Error("App payload numbers must be finite");
22253
- return value;
22254
- }
22255
- if (Array.isArray(value)) return value.map((entry) => copyAppJson(entry, depth + 1));
22256
- const copied = {};
22257
- for (const [key, entry] of Object.entries(value)) {
22258
- Object.defineProperty(copied, key, {
22259
- value: copyAppJson(entry, depth + 1),
22260
- enumerable: true,
22261
- configurable: true,
22262
- writable: true
22263
- });
22264
- }
22265
- return copied;
22266
- }
22267
22135
  function mountAssistantApp(detail, actions, options = {}) {
22268
22136
  if (!detail.html) return void 0;
22269
22137
  const card = document.createElement("section");
@@ -22284,25 +22152,16 @@ function mountAssistantApp(detail, actions, options = {}) {
22284
22152
  const frame = document.createElement("iframe");
22285
22153
  frame.className = "noodle-app-frame";
22286
22154
  frame.title = detail.title ?? detail.tool;
22287
- const policy = resolveAssistantAppSandboxPolicy(detail.resourceMeta);
22155
+ frame.setAttribute("sandbox", "allow-scripts");
22288
22156
  frame.setAttribute("referrerpolicy", "no-referrer");
22289
22157
  const sandboxUrl = resolveSandboxUrl(options.sandboxUrl);
22290
- const appliedPolicy = sandboxUrl ? policy : { csp: policy.csp ?? {} };
22291
- if (sandboxUrl) {
22292
- frame.setAttribute("sandbox", STANDARD_SANDBOX);
22293
- if (policy.allowAttribute) frame.setAttribute("allow", policy.allowAttribute);
22294
- frame.src = assistantAppSandboxUrl(sandboxUrl, policy);
22295
- } else {
22296
- frame.setAttribute("sandbox", "allow-scripts");
22297
- frame.srcdoc = PROXY_DOCUMENT;
22298
- }
22158
+ if (sandboxUrl) frame.src = sandboxUrl;
22159
+ else frame.srcdoc = PROXY_DOCUMENT;
22299
22160
  card.append(frame);
22300
22161
  let mountedBridge;
22301
22162
  let mountedTransport;
22302
22163
  let destroyed = false;
22303
22164
  let initialized = false;
22304
- let renderFailed = false;
22305
- let renderStage = "sandbox_load";
22306
22165
  let currentTheme = actions.theme;
22307
22166
  let displayMode = "inline";
22308
22167
  let hostContext = createAssistantAppHostContext(
@@ -22311,15 +22170,6 @@ function mountAssistantApp(detail, actions, options = {}) {
22311
22170
  displayMode
22312
22171
  );
22313
22172
  let destroyPromise;
22314
- let transportClosePromise;
22315
- let renderTimer;
22316
- const closeTransport = () => {
22317
- if (transportClosePromise) return transportClosePromise;
22318
- const closing = mountedTransport?.close().catch(() => {
22319
- }) ?? Promise.resolve();
22320
- transportClosePromise = closing;
22321
- return closing;
22322
- };
22323
22173
  const applyDisplayMode = (requestedMode) => {
22324
22174
  displayMode = requestedMode === "fullscreen" && options.allowFullscreen === true ? "fullscreen" : "inline";
22325
22175
  card.toggleAttribute("data-fullscreen", displayMode === "fullscreen");
@@ -22337,26 +22187,18 @@ function mountAssistantApp(detail, actions, options = {}) {
22337
22187
  applyDisplayMode("inline");
22338
22188
  frame.focus();
22339
22189
  });
22340
- const showRenderFailure = (code) => {
22341
- if (code === "view_render_timeout" && initialized || destroyed || renderFailed || !frame.isConnected)
22342
- return;
22343
- renderFailed = true;
22344
- clearTimeout(renderTimer);
22190
+ const renderTimer = setTimeout(() => {
22191
+ if (initialized || !frame.isConnected) return;
22345
22192
  const note = document.createElement("div");
22346
22193
  note.className = "noodle-app-fallback";
22347
22194
  note.textContent = "This app view could not be displayed.";
22348
22195
  frame.replaceWith(note);
22349
- options.onRenderFailure?.({ code, retryable: false, stage: renderStage });
22350
- void closeTransport();
22351
- };
22352
- renderTimer = setTimeout(() => {
22353
- showRenderFailure("view_render_timeout");
22196
+ options.onRenderFailure?.({ code: "view_render_timeout", retryable: false });
22354
22197
  }, APP_RENDER_TIMEOUT_MS);
22355
22198
  frame.addEventListener(
22356
22199
  "load",
22357
22200
  () => {
22358
- if (destroyed || renderFailed) return;
22359
- renderStage = "sandbox_proxy";
22201
+ if (destroyed) return;
22360
22202
  const target = frame.contentWindow;
22361
22203
  if (!target) return;
22362
22204
  const bridge = new DX(
@@ -22367,11 +22209,7 @@ function mountAssistantApp(detail, actions, options = {}) {
22367
22209
  serverTools: {},
22368
22210
  serverResources: {},
22369
22211
  updateModelContext: { text: {}, structuredContent: {} },
22370
- message: { text: {} },
22371
- sandbox: {
22372
- ...appliedPolicy.csp === void 0 ? {} : { csp: appliedPolicy.csp },
22373
- ...appliedPolicy.permissions === void 0 ? {} : { permissions: appliedPolicy.permissions }
22374
- }
22212
+ message: { text: {} }
22375
22213
  },
22376
22214
  {
22377
22215
  hostContext
@@ -22379,15 +22217,13 @@ function mountAssistantApp(detail, actions, options = {}) {
22379
22217
  );
22380
22218
  mountedBridge = bridge;
22381
22219
  bridge.onsandboxready = () => {
22382
- if (destroyed || renderFailed) return;
22383
- renderStage = "app_initialize";
22220
+ if (destroyed) return;
22384
22221
  const current = options.getDetail?.() ?? detail;
22385
22222
  void bridge.sendSandboxResourceReady({
22386
22223
  html: current.html,
22387
- sandbox: sandboxUrl ? STANDARD_SANDBOX : "allow-scripts",
22388
- ...appliedPolicy.csp === void 0 ? {} : { csp: appliedPolicy.csp },
22389
- ...appliedPolicy.permissions === void 0 ? {} : { permissions: appliedPolicy.permissions }
22390
- }).catch(() => showRenderFailure("view_bridge_error"));
22224
+ sandbox: "allow-scripts",
22225
+ ...current.resourceMeta ?? {}
22226
+ });
22391
22227
  };
22392
22228
  bridge.onsizechange = ({ height }) => {
22393
22229
  if (destroyed) return;
@@ -22451,30 +22287,21 @@ function mountAssistantApp(detail, actions, options = {}) {
22451
22287
  return await actions.client.requestApp("resources/read", params);
22452
22288
  };
22453
22289
  bridge.oninitialized = () => {
22454
- if (destroyed || renderFailed) return;
22455
- try {
22456
- const current = options.getDetail?.() ?? detail;
22457
- const copiedArguments = copyAppJson(current.arguments ?? {});
22458
- const copiedResult = copyAppJson(current.result);
22459
- const argumentsRecord = typeof copiedArguments === "object" && copiedArguments !== null && !Array.isArray(copiedArguments) ? copiedArguments : {};
22460
- initialized = true;
22461
- clearTimeout(renderTimer);
22462
- bridge.setHostContext(hostContext);
22463
- void Promise.all([
22464
- bridge.sendToolInput({ arguments: argumentsRecord }),
22465
- bridge.sendToolResult({
22466
- content: [{ type: "text", text: JSON.stringify(copiedResult) }],
22467
- ...typeof copiedResult === "object" && copiedResult !== null && !Array.isArray(copiedResult) ? { structuredContent: copiedResult } : {}
22468
- })
22469
- ]).catch(() => showRenderFailure("view_bridge_error"));
22470
- } catch {
22471
- showRenderFailure("view_bridge_error");
22472
- }
22290
+ if (destroyed) return;
22291
+ initialized = true;
22292
+ clearTimeout(renderTimer);
22293
+ bridge.setHostContext(hostContext);
22294
+ const current = options.getDetail?.() ?? detail;
22295
+ void bridge.sendToolInput({ arguments: current.arguments ?? {} });
22296
+ void bridge.sendToolResult({
22297
+ content: [{ type: "text", text: JSON.stringify(current.result) }],
22298
+ ...typeof current.result === "object" && current.result !== null && !Array.isArray(current.result) ? { structuredContent: current.result } : {}
22299
+ });
22473
22300
  };
22474
22301
  const transport = new E(target, target);
22475
22302
  mountedTransport = transport;
22476
22303
  void bridge.connect(transport).catch(() => {
22477
- showRenderFailure("view_bridge_error");
22304
+ void destroy();
22478
22305
  });
22479
22306
  },
22480
22307
  { once: true }
@@ -22500,7 +22327,8 @@ function mountAssistantApp(detail, actions, options = {}) {
22500
22327
  }
22501
22328
  } catch {
22502
22329
  }
22503
- await closeTransport();
22330
+ await mountedTransport?.close().catch(() => {
22331
+ });
22504
22332
  card.remove();
22505
22333
  mountedApps.delete(card);
22506
22334
  })();
@@ -27502,14 +27330,14 @@ function toChatError(error51) {
27502
27330
  }
27503
27331
  function readErrorDetail(error51) {
27504
27332
  const detail = Reflect.get(error51, "detail");
27505
- if (!isRecord2(detail) || typeof detail.code !== "string") return void 0;
27333
+ if (!isRecord(detail) || typeof detail.code !== "string") return void 0;
27506
27334
  return {
27507
27335
  code: detail.code,
27508
27336
  ...typeof detail.status === "number" ? { status: detail.status } : {},
27509
27337
  retryable: detail.retryable === true
27510
27338
  };
27511
27339
  }
27512
- function isRecord2(value) {
27340
+ function isRecord(value) {
27513
27341
  return typeof value === "object" && value !== null && !Array.isArray(value);
27514
27342
  }
27515
27343
 
@@ -27536,7 +27364,7 @@ var AssistantClientError = class extends Error {
27536
27364
  }
27537
27365
  };
27538
27366
  function parseSession(value) {
27539
- if (!isRecord3(value) || !isRecord3(value.endpoints)) {
27367
+ if (!isRecord2(value) || !isRecord2(value.endpoints)) {
27540
27368
  throw clientError("session_failed", "Assistant session response is invalid", true);
27541
27369
  }
27542
27370
  const interactions = value.endpoints.interactions;
@@ -27557,11 +27385,11 @@ function parseSession(value) {
27557
27385
  ...typeof sandbox === "string" ? { sandbox } : {},
27558
27386
  ...typeof transcript === "string" ? { transcript } : {}
27559
27387
  },
27560
- ...isRecord3(value.configuration) ? { configuration: value.configuration } : {},
27561
- ...isRecord3(value.resume) && typeof value.resume.tool === "string" ? { resume: { tool: value.resume.tool } } : {}
27388
+ ...isRecord2(value.configuration) ? { configuration: value.configuration } : {},
27389
+ ...isRecord2(value.resume) && typeof value.resume.tool === "string" ? { resume: { tool: value.resume.tool } } : {}
27562
27390
  };
27563
27391
  }
27564
- function isRecord3(value) {
27392
+ function isRecord2(value) {
27565
27393
  return typeof value === "object" && value !== null && !Array.isArray(value);
27566
27394
  }
27567
27395
  async function readStableErrorCode(response) {
@@ -27571,7 +27399,7 @@ async function readStableErrorCode(response) {
27571
27399
  } catch {
27572
27400
  return void 0;
27573
27401
  }
27574
- if (!isRecord3(value) || typeof value.code !== "string") return void 0;
27402
+ if (!isRecord2(value) || typeof value.code !== "string") return void 0;
27575
27403
  return /^[A-Za-z0-9_.-]{1,64}$/.test(value.code) ? value.code : void 0;
27576
27404
  }
27577
27405
  function clientError(code, message, retryable, status, options, serviceCode) {
@@ -27602,12 +27430,12 @@ function toAssistantClientEvent(event) {
27602
27430
  }
27603
27431
  break;
27604
27432
  case "tool_proposed":
27605
- if (hasString(value, "id") && hasString(value, "tool") && hasOptionalString(value.title) && hasOptionalString(value.description) && hasOptionalJson(value.arguments) && (value.reviewSchema === void 0 || isRecord4(value.reviewSchema)) && hasOptionalString(value.expiresAt) && (value.requiresConfirmation === void 0 || value.requiresConfirmation === true) && hasOptionalTurnId(value)) {
27433
+ if (hasString(value, "id") && hasString(value, "tool") && hasOptionalString(value.title) && hasOptionalString(value.description) && hasOptionalJson(value.arguments) && (value.reviewSchema === void 0 || isRecord3(value.reviewSchema)) && hasOptionalString(value.expiresAt) && (value.requiresConfirmation === void 0 || value.requiresConfirmation === true) && hasOptionalTurnId(value)) {
27606
27434
  return event;
27607
27435
  }
27608
27436
  break;
27609
27437
  case "input_requested":
27610
- if (hasString(value, "id") && hasString(value, "message") && isRecord4(value.requestedSchema) && hasString(value, "expiresAt") && hasOptionalTurnId(value)) {
27438
+ if (hasString(value, "id") && hasString(value, "message") && isRecord3(value.requestedSchema) && hasString(value, "expiresAt") && hasOptionalTurnId(value)) {
27611
27439
  return event;
27612
27440
  }
27613
27441
  break;
@@ -27651,7 +27479,7 @@ function toAssistantClientEvent(event) {
27651
27479
  return { event: "unrecognized", data: { name: event.event, payload: value } };
27652
27480
  }
27653
27481
  function isViewAvailableDetail(value) {
27654
- return hasString(value, "id") && hasString(value, "tool") && typeof value.resourceUri === "string" && value.resourceUri.startsWith("ui://") && hasOptionalString(value.title) && (value.replayed === void 0 || value.replayed === true) && isJsonValue(value.result, 0) && hasOptionalJson(value.arguments) && hasOptionalString(value.html) && (value.resourceMeta === void 0 || isRecord4(value.resourceMeta)) && (value.allowedOpenDomains === void 0 || Array.isArray(value.allowedOpenDomains) && value.allowedOpenDomains.every(isHttpsUrl)) && hasOptionalTurnId(value);
27482
+ return hasString(value, "id") && hasString(value, "tool") && typeof value.resourceUri === "string" && value.resourceUri.startsWith("ui://") && hasOptionalString(value.title) && (value.replayed === void 0 || value.replayed === true) && isJsonValue(value.result, 0) && hasOptionalJson(value.arguments) && hasOptionalString(value.html) && (value.resourceMeta === void 0 || isRecord3(value.resourceMeta)) && (value.allowedOpenDomains === void 0 || Array.isArray(value.allowedOpenDomains) && value.allowedOpenDomains.every(isHttpsUrl)) && hasOptionalTurnId(value);
27655
27483
  }
27656
27484
  function isHttpsUrl(value) {
27657
27485
  if (typeof value !== "string") return false;
@@ -27684,11 +27512,11 @@ function isJsonValue(value, depth) {
27684
27512
  if (Array.isArray(value)) {
27685
27513
  return value.length <= 256 && value.every((entry) => isJsonValue(entry, depth + 1));
27686
27514
  }
27687
- if (!isRecord4(value)) return false;
27515
+ if (!isRecord3(value)) return false;
27688
27516
  const entries2 = Object.entries(value);
27689
27517
  return entries2.length <= 256 && entries2.every(([, entry]) => isJsonValue(entry, depth + 1));
27690
27518
  }
27691
- function isRecord4(value) {
27519
+ function isRecord3(value) {
27692
27520
  return typeof value === "object" && value !== null && !Array.isArray(value);
27693
27521
  }
27694
27522
 
@@ -27855,15 +27683,15 @@ function parseFrame(frame) {
27855
27683
  if (event === "done" && !isValidDonePayload(parsed)) {
27856
27684
  throw invalidStream("assistant event stream contained an invalid done event");
27857
27685
  }
27858
- return { event, data: isRecord5(parsed) ? parsed : { value: parsed } };
27686
+ return { event, data: isRecord4(parsed) ? parsed : { value: parsed } };
27859
27687
  }
27860
27688
  function normalizeLineEndings(input) {
27861
27689
  return input.replaceAll("\r\n", "\n").replaceAll("\r", "\n");
27862
27690
  }
27863
27691
  function isValidDonePayload(value) {
27864
- return isRecord5(value) && (value.turnId === void 0 || typeof value.turnId === "string" && value.turnId.length > 0);
27692
+ return isRecord4(value) && (value.turnId === void 0 || typeof value.turnId === "string" && value.turnId.length > 0);
27865
27693
  }
27866
- function isRecord5(value) {
27694
+ function isRecord4(value) {
27867
27695
  return typeof value === "object" && value !== null && !Array.isArray(value);
27868
27696
  }
27869
27697
  function invalidStream(message, cause) {
@@ -28382,10 +28210,10 @@ function authorizedHeaders(token, accept) {
28382
28210
  };
28383
28211
  }
28384
28212
  function parseAppInteraction(value) {
28385
- if (!isRecord3(value) || !isRecord3(value.interaction)) return void 0;
28213
+ if (!isRecord2(value) || !isRecord2(value.interaction)) return void 0;
28386
28214
  const event = value.interaction.event;
28387
28215
  const data = value.interaction.data;
28388
- if (event !== "tool_proposed" && event !== "input_requested" || !isRecord3(data)) {
28216
+ if (event !== "tool_proposed" && event !== "input_requested" || !isRecord2(data)) {
28389
28217
  return void 0;
28390
28218
  }
28391
28219
  const parsed = toAssistantClientEvent({ event, data });
@@ -31584,7 +31412,7 @@ var AssistantElementEventController = class {
31584
31412
  if (event.event === "unrecognized") return;
31585
31413
  const { event: name21, data } = event;
31586
31414
  if (name21 === "session_started") {
31587
- if (isRecord6(data.configuration)) {
31415
+ if (isRecord5(data.configuration)) {
31588
31416
  this.#host.applyConfiguration(data.configuration);
31589
31417
  }
31590
31418
  this.#host.element.dispatchEvent(
@@ -31652,10 +31480,10 @@ var AssistantElementEventController = class {
31652
31480
  this.#appendToolProposal(
31653
31481
  String(data.id ?? ""),
31654
31482
  String(data.tool ?? "action"),
31655
- isRecord6(data.arguments) ? data.arguments : void 0,
31483
+ isRecord5(data.arguments) ? data.arguments : void 0,
31656
31484
  typeof data.title === "string" ? data.title : void 0,
31657
31485
  "description" in data && typeof data.description === "string" ? data.description : void 0,
31658
- "reviewSchema" in data && isRecord6(data.reviewSchema) ? data.reviewSchema : void 0
31486
+ "reviewSchema" in data && isRecord5(data.reviewSchema) ? data.reviewSchema : void 0
31659
31487
  );
31660
31488
  return;
31661
31489
  }
@@ -31668,7 +31496,7 @@ var AssistantElementEventController = class {
31668
31496
  );
31669
31497
  return;
31670
31498
  }
31671
- if (name21 === "input_requested" && isRecord6(data.requestedSchema)) {
31499
+ if (name21 === "input_requested" && isRecord5(data.requestedSchema)) {
31672
31500
  this.#appendInputRequest(
31673
31501
  String(data.id ?? ""),
31674
31502
  String(data.message ?? "More information is required"),
@@ -31839,7 +31667,7 @@ var AssistantElementEventController = class {
31839
31667
  this.#host.revealLatest();
31840
31668
  }
31841
31669
  };
31842
- function isRecord6(value) {
31670
+ function isRecord5(value) {
31843
31671
  return typeof value === "object" && value !== null && !Array.isArray(value);
31844
31672
  }
31845
31673