@harnessio/ai-chat-core 0.0.20 → 0.0.22

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
@@ -1,36 +1,36 @@
1
1
  var H = Object.defineProperty;
2
- var J = (a, n, t) => n in a ? H(a, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[n] = t;
3
- var u = (a, n, t) => J(a, typeof n != "symbol" ? n + "" : n, t);
4
- import U, { createContext as B, useContext as q, useState as b, useEffect as w, useReducer as z, useCallback as C, useMemo as V } from "react";
2
+ var J = (n, s, t) => s in n ? H(n, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[s] = t;
3
+ var u = (n, s, t) => J(n, typeof s != "symbol" ? s + "" : s, t);
4
+ import q, { createContext as U, useContext as B, useState as y, useEffect as m, useReducer as V, useCallback as C, useMemo as z } from "react";
5
5
  class G {
6
6
  constructor() {
7
7
  u(this, "plugins", /* @__PURE__ */ new Map());
8
8
  u(this, "renderersByType", /* @__PURE__ */ new Map());
9
9
  }
10
- registerPlugin(n) {
11
- this.plugins.has(n.id), this.plugins.set(n.id, n), n.renderers.forEach((t) => {
10
+ registerPlugin(s) {
11
+ this.plugins.has(s.id), this.plugins.set(s.id, s), s.renderers.forEach((t) => {
12
12
  const e = this.renderersByType.get(t.type) || [];
13
- e.push(t), e.sort((s, r) => ((r == null ? void 0 : r.priority) ?? 0) - ((s == null ? void 0 : s.priority) ?? 0)), this.renderersByType.set(t.type, e);
13
+ e.push(t), e.sort((i, r) => ((r == null ? void 0 : r.priority) ?? 0) - ((i == null ? void 0 : i.priority) ?? 0)), this.renderersByType.set(t.type, e);
14
14
  });
15
15
  }
16
- unregisterPlugin(n) {
17
- const t = this.plugins.get(n);
16
+ unregisterPlugin(s) {
17
+ const t = this.plugins.get(s);
18
18
  return t ? (t.renderers.forEach((e) => {
19
- const r = (this.renderersByType.get(e.type) || []).filter((i) => !t.renderers.includes(i));
19
+ const r = (this.renderersByType.get(e.type) || []).filter((a) => !t.renderers.includes(a));
20
20
  r.length === 0 ? this.renderersByType.delete(e.type) : this.renderersByType.set(e.type, r);
21
- }), this.plugins.delete(n)) : !1;
21
+ }), this.plugins.delete(s)) : !1;
22
22
  }
23
- getPlugin(n) {
24
- return this.plugins.get(n);
23
+ getPlugin(s) {
24
+ return this.plugins.get(s);
25
25
  }
26
26
  getAllPlugins() {
27
27
  return Array.from(this.plugins.values());
28
28
  }
29
- getRenderersByType(n) {
30
- return this.renderersByType.get(n) || [];
29
+ getRenderersByType(s) {
30
+ return this.renderersByType.get(s) || [];
31
31
  }
32
- getBestRendererForType(n) {
33
- return this.getRenderersByType(n)[0];
32
+ getBestRendererForType(s) {
33
+ return this.getRenderersByType(s)[0];
34
34
  }
35
35
  clear() {
36
36
  this.plugins.clear(), this.renderersByType.clear();
@@ -41,36 +41,36 @@ class Y {
41
41
  u(this, "handlers", /* @__PURE__ */ new Map());
42
42
  u(this, "renderers", /* @__PURE__ */ new Map());
43
43
  }
44
- registerHandler(n, t, e = 0) {
45
- const s = this.handlers.get(n) || [], r = { handler: t, priority: e }, i = s.findIndex((o) => o.priority < e);
46
- i === -1 ? s.push(r) : s.splice(i, 0, r), this.handlers.set(n, s);
44
+ registerHandler(s, t, e = 0) {
45
+ const i = this.handlers.get(s) || [], r = { handler: t, priority: e }, a = i.findIndex((o) => o.priority < e);
46
+ a === -1 ? i.push(r) : i.splice(a, 0, r), this.handlers.set(s, i);
47
47
  }
48
- registerRenderer(n, t, e = 0) {
49
- const s = this.renderers.get(n) || [], r = { renderer: t, priority: e }, i = s.findIndex((o) => o.priority < e);
50
- i === -1 ? s.push(r) : s.splice(i, 0, r), this.renderers.set(n, s);
48
+ registerRenderer(s, t, e = 0) {
49
+ const i = this.renderers.get(s) || [], r = { renderer: t, priority: e }, a = i.findIndex((o) => o.priority < e);
50
+ a === -1 ? i.push(r) : i.splice(a, 0, r), this.renderers.set(s, i);
51
51
  }
52
- unregister(n) {
53
- this.handlers.delete(n), this.renderers.delete(n);
52
+ unregister(s) {
53
+ this.handlers.delete(s), this.renderers.delete(s);
54
54
  }
55
- getHandler(n) {
55
+ getHandler(s) {
56
56
  var e;
57
- const t = this.handlers.get(n);
57
+ const t = this.handlers.get(s);
58
58
  return (e = t == null ? void 0 : t[0]) == null ? void 0 : e.handler;
59
59
  }
60
- getRenderer(n) {
60
+ getRenderer(s) {
61
61
  var e;
62
- const t = this.renderers.get(n);
62
+ const t = this.renderers.get(s);
63
63
  return (e = t == null ? void 0 : t[0]) == null ? void 0 : e.renderer;
64
64
  }
65
65
  getStrategy() {
66
66
  return "queue";
67
67
  }
68
- hasHandler(n) {
69
- const t = this.handlers.get(n);
68
+ hasHandler(s) {
69
+ const t = this.handlers.get(s);
70
70
  return t !== void 0 && t.length > 0;
71
71
  }
72
- hasRenderer(n) {
73
- const t = this.renderers.get(n);
72
+ hasRenderer(s) {
73
+ const t = this.renderers.get(s);
74
74
  return t !== void 0 && t.length > 0;
75
75
  }
76
76
  clear() {
@@ -81,27 +81,27 @@ class Y {
81
81
  }
82
82
  }
83
83
  class K {
84
- constructor(n) {
84
+ constructor(s) {
85
85
  u(this, "executions", /* @__PURE__ */ new Map());
86
86
  u(this, "executionQueue", []);
87
87
  u(this, "isProcessing", !1);
88
88
  u(this, "runningByName", /* @__PURE__ */ new Map());
89
89
  u(this, "subscribers", /* @__PURE__ */ new Set());
90
90
  u(this, "getHandler");
91
- this.getHandler = n;
91
+ this.getHandler = s;
92
92
  }
93
- async executeCapability(n, t, e, s, r = "queue") {
94
- if (!this.getHandler(n)) {
95
- console.warn(`No handler registered for capability: ${n}`);
93
+ async executeCapability(s, t, e, i, r = "queue") {
94
+ if (!this.getHandler(s)) {
95
+ console.warn(`No handler registered for capability: ${s}`);
96
96
  return;
97
97
  }
98
98
  const o = {
99
99
  id: t,
100
- name: n,
100
+ name: s,
101
101
  args: e,
102
102
  status: { type: "queued" },
103
103
  timestamp: Date.now(),
104
- messageId: s
104
+ messageId: i
105
105
  };
106
106
  switch (this.executions.set(t, o), this.notifySubscribers(t), r) {
107
107
  case "queue":
@@ -114,64 +114,207 @@ class K {
114
114
  async processQueue() {
115
115
  if (!(this.isProcessing || this.executionQueue.length === 0)) {
116
116
  for (this.isProcessing = !0; this.executionQueue.length > 0; ) {
117
- const n = this.executionQueue.shift(), t = this.executions.get(n);
117
+ const s = this.executionQueue.shift(), t = this.executions.get(s);
118
118
  if (!t) continue;
119
119
  const e = this.getHandler(t.name);
120
120
  if (!e) continue;
121
- t.status = { type: "running" }, this.notifySubscribers(n);
122
- const s = this.runningByName.get(t.name) || [];
123
- s.push(n), this.runningByName.set(t.name, s);
121
+ t.status = { type: "running" }, this.notifySubscribers(s);
122
+ const i = this.runningByName.get(t.name) || [];
123
+ i.push(s), this.runningByName.set(t.name, i);
124
124
  try {
125
125
  const r = await e.execute(t.args, {
126
126
  messageId: t.messageId,
127
- capabilityId: n
127
+ capabilityId: s
128
128
  });
129
129
  t.status = { type: "complete", result: r }, t.result = r;
130
130
  } catch (r) {
131
- const i = r instanceof Error ? r.message : "Unknown error";
132
- t.status = { type: "error", error: i }, t.error = i;
131
+ const a = r instanceof Error ? r.message : "Unknown error";
132
+ t.status = { type: "error", error: a }, t.error = a;
133
133
  } finally {
134
- const r = this.runningByName.get(t.name) || [], i = r.indexOf(n);
135
- i > -1 && r.splice(i, 1), r.length === 0 ? this.runningByName.delete(t.name) : this.runningByName.set(t.name, r), this.notifySubscribers(n);
134
+ const r = this.runningByName.get(t.name) || [], a = r.indexOf(s);
135
+ a > -1 && r.splice(a, 1), r.length === 0 ? this.runningByName.delete(t.name) : this.runningByName.set(t.name, r), this.notifySubscribers(s);
136
136
  }
137
137
  }
138
138
  this.isProcessing = !1;
139
139
  }
140
140
  }
141
- getExecution(n) {
142
- return this.executions.get(n);
141
+ getExecution(s) {
142
+ return this.executions.get(s);
143
143
  }
144
- getExecutionsByMessage(n) {
145
- return Array.from(this.executions.values()).filter((t) => t.messageId === n);
144
+ getExecutionsByMessage(s) {
145
+ return Array.from(this.executions.values()).filter((t) => t.messageId === s);
146
146
  }
147
- subscribe(n) {
148
- return this.subscribers.add(n), () => this.subscribers.delete(n);
147
+ subscribe(s) {
148
+ return this.subscribers.add(s), () => this.subscribers.delete(s);
149
149
  }
150
- notifySubscribers(n) {
151
- this.subscribers.forEach((t) => t(n));
150
+ notifySubscribers(s) {
151
+ this.subscribers.forEach((t) => t(s));
152
152
  }
153
153
  clear() {
154
154
  this.executions.clear(), this.executionQueue = [], this.runningByName.clear();
155
155
  }
156
156
  }
157
- class m {
157
+ class X {
158
+ constructor() {
159
+ u(this, "scopes", /* @__PURE__ */ new Map());
160
+ u(this, "scopeStack", []);
161
+ this.scopes.set("global", {
162
+ mode: "merge",
163
+ actions: /* @__PURE__ */ new Map()
164
+ }), this.scopeStack.push("global");
165
+ }
166
+ /**
167
+ * Activate a scope with the specified mode.
168
+ * This pushes the scope onto the stack, making it active.
169
+ */
170
+ activateScope(s, t = "merge") {
171
+ if (!this.scopes.has(s))
172
+ this.scopes.set(s, {
173
+ mode: t,
174
+ actions: /* @__PURE__ */ new Map()
175
+ });
176
+ else {
177
+ const e = this.scopes.get(s);
178
+ e.mode = t;
179
+ }
180
+ this.scopeStack.includes(s) || this.scopeStack.push(s);
181
+ }
182
+ /**
183
+ * Deactivate a scope, removing it from the stack.
184
+ * This restores the previous scope as active.
185
+ */
186
+ deactivateScope(s) {
187
+ const t = this.scopeStack.indexOf(s);
188
+ t !== -1 && s !== "global" && this.scopeStack.splice(t, 1);
189
+ }
190
+ /**
191
+ * Get the currently active scope (top of stack).
192
+ */
193
+ getActiveScope() {
194
+ return this.scopeStack[this.scopeStack.length - 1] || "global";
195
+ }
196
+ /**
197
+ * Get the full scope stack.
198
+ */
199
+ getScopeStack() {
200
+ return [...this.scopeStack];
201
+ }
202
+ /**
203
+ * Register a quick action in the specified scope.
204
+ */
205
+ register(s, t = "global") {
206
+ const e = s.priority ?? 0;
207
+ this.scopes.has(t) || this.scopes.set(t, {
208
+ mode: "merge",
209
+ actions: /* @__PURE__ */ new Map()
210
+ });
211
+ const i = this.scopes.get(t);
212
+ i.actions.has(s.id) && console.warn(`QuickAction with id "${s.id}" is already registered in scope "${t}". Overwriting.`), i.actions.set(s.id, {
213
+ config: s,
214
+ priority: e
215
+ });
216
+ }
217
+ /**
218
+ * Unregister a quick action from the specified scope.
219
+ */
220
+ unregister(s, t = "global") {
221
+ const e = this.scopes.get(t);
222
+ return e ? e.actions.delete(s) : !1;
223
+ }
224
+ /**
225
+ * Clear all actions in the specified scope.
226
+ */
227
+ clearScope(s) {
228
+ const t = this.scopes.get(s);
229
+ t && t.actions.clear();
230
+ }
231
+ /**
232
+ * Get all visible quick actions based on the active scope and its mode.
233
+ */
234
+ async getVisible(s) {
235
+ const t = this.getActiveScope(), e = this.scopes.get(t);
236
+ if (!e)
237
+ return [];
238
+ const i = e.mode;
239
+ let r = [];
240
+ if (i === "replace")
241
+ r = Array.from(e.actions.values());
242
+ else if (i === "append")
243
+ for (const c of this.scopeStack) {
244
+ const h = this.scopes.get(c);
245
+ h && r.push(...Array.from(h.actions.values()));
246
+ }
247
+ else {
248
+ const c = this.scopes.get("global");
249
+ c && r.push(...Array.from(c.actions.values())), t !== "global" && r.push(...Array.from(e.actions.values()));
250
+ }
251
+ let o = (await Promise.all(
252
+ r.map(async (c) => {
253
+ if (!c.config.condition)
254
+ return { entry: c, visible: !0 };
255
+ try {
256
+ const h = await c.config.condition();
257
+ return { entry: c, visible: h };
258
+ } catch (h) {
259
+ return console.error(`Error evaluating condition for quick action "${c.config.id}":`, h), { entry: c, visible: !1 };
260
+ }
261
+ })
262
+ )).filter((c) => c.visible).map((c) => c.entry);
263
+ return o.sort((c, h) => h.priority - c.priority), s != null && s.scope && (o = o.filter((c) => c.config.scope === s.scope)), o.map((c) => ({
264
+ id: c.config.id,
265
+ label: c.config.label,
266
+ prompt: c.config.prompt,
267
+ icon: c.config.icon,
268
+ description: c.config.description,
269
+ priority: c.config.priority,
270
+ scope: c.config.scope
271
+ }));
272
+ }
273
+ /**
274
+ * Get a single quick action by ID from the specified scope.
275
+ */
276
+ get(s, t = "global") {
277
+ const e = this.scopes.get(t);
278
+ if (!e)
279
+ return;
280
+ const i = e.actions.get(s);
281
+ if (i)
282
+ return {
283
+ id: i.config.id,
284
+ label: i.config.label,
285
+ prompt: i.config.prompt,
286
+ icon: i.config.icon,
287
+ description: i.config.description,
288
+ priority: i.config.priority,
289
+ scope: i.config.scope
290
+ };
291
+ }
292
+ /**
293
+ * Check if a quick action exists in the specified scope.
294
+ */
295
+ has(s, t = "global") {
296
+ const e = this.scopes.get(t);
297
+ return e ? e.actions.has(s) : !1;
298
+ }
299
+ }
300
+ class _ {
158
301
  constructor() {
159
302
  u(this, "_subscriptions", /* @__PURE__ */ new Set());
160
303
  }
161
- subscribe(n) {
162
- return this._subscriptions.add(n), () => {
163
- this._subscriptions.delete(n);
304
+ subscribe(s) {
305
+ return this._subscriptions.add(s), () => {
306
+ this._subscriptions.delete(s);
164
307
  };
165
308
  }
166
309
  notifySubscribers() {
167
- for (const n of this._subscriptions)
168
- n();
310
+ for (const s of this._subscriptions)
311
+ s();
169
312
  }
170
313
  getSubscriberCount() {
171
314
  return this._subscriptions.size;
172
315
  }
173
316
  }
174
- class X extends m {
317
+ class Z extends _ {
175
318
  constructor() {
176
319
  super(...arguments);
177
320
  u(this, "_state", {
@@ -204,14 +347,14 @@ class X extends m {
204
347
  get focusedContentIndex() {
205
348
  return this._state.focusedContentIndex;
206
349
  }
207
- focus(t, e, s, r = "detail") {
350
+ focus(t, e, i, r = "detail") {
208
351
  this._state = {
209
352
  isActive: !0,
210
353
  context: r,
211
354
  focusedContent: t,
212
355
  focusedMessage: e,
213
356
  focusedMessageId: e.id,
214
- focusedContentIndex: s
357
+ focusedContentIndex: i
215
358
  }, this.notifySubscribers();
216
359
  }
217
360
  blur() {
@@ -224,8 +367,8 @@ class X extends m {
224
367
  focusedContentIndex: null
225
368
  }, this.notifySubscribers();
226
369
  }
227
- toggle(t, e, s, r = "detail") {
228
- this._state.isActive && this._state.focusedMessageId === e.id && this._state.focusedContentIndex === s && this._state.context === r ? this.blur() : this.focus(t, e, s, r);
370
+ toggle(t, e, i, r = "detail") {
371
+ this._state.isActive && this._state.focusedMessageId === e.id && this._state.focusedContentIndex === i && this._state.context === r ? this.blur() : this.focus(t, e, i, r);
229
372
  }
230
373
  switchContext(t) {
231
374
  this._state.isActive && this._state.focusedContent && (this._state = {
@@ -235,46 +378,46 @@ class X extends m {
235
378
  }
236
379
  focusNext(t) {
237
380
  if (!this._state.focusedMessageId || !t.length) return;
238
- const e = t.findIndex((i) => i.id === this._state.focusedMessageId);
381
+ const e = t.findIndex((a) => a.id === this._state.focusedMessageId);
239
382
  if (e === -1) return;
240
- const s = t[e], r = this._state.focusedContentIndex ?? 0;
241
- if (r + 1 < s.content.length) {
242
- const i = s.content[r + 1];
243
- this.focus(i, s, r + 1, this._state.context || "detail");
383
+ const i = t[e], r = this._state.focusedContentIndex ?? 0;
384
+ if (r + 1 < i.content.length) {
385
+ const a = i.content[r + 1];
386
+ this.focus(a, i, r + 1, this._state.context || "detail");
244
387
  return;
245
388
  }
246
389
  if (e + 1 < t.length) {
247
- const i = t[e + 1];
248
- i.content.length > 0 && this.focus(i.content[0], i, 0, this._state.context || "detail");
390
+ const a = t[e + 1];
391
+ a.content.length > 0 && this.focus(a.content[0], a, 0, this._state.context || "detail");
249
392
  }
250
393
  }
251
394
  focusPrevious(t) {
252
395
  if (!this._state.focusedMessageId || !t.length) return;
253
- const e = t.findIndex((i) => i.id === this._state.focusedMessageId);
396
+ const e = t.findIndex((a) => a.id === this._state.focusedMessageId);
254
397
  if (e === -1) return;
255
- const s = t[e], r = this._state.focusedContentIndex ?? 0;
398
+ const i = t[e], r = this._state.focusedContentIndex ?? 0;
256
399
  if (r > 0) {
257
- const i = s.content[r - 1];
258
- this.focus(i, s, r - 1, this._state.context || "detail");
400
+ const a = i.content[r - 1];
401
+ this.focus(a, i, r - 1, this._state.context || "detail");
259
402
  return;
260
403
  }
261
404
  if (e > 0) {
262
- const i = t[e - 1];
263
- if (i.content.length > 0) {
264
- const o = i.content.length - 1;
265
- this.focus(i.content[o], i, o, this._state.context || "detail");
405
+ const a = t[e - 1];
406
+ if (a.content.length > 0) {
407
+ const o = a.content.length - 1;
408
+ this.focus(a.content[o], a, o, this._state.context || "detail");
266
409
  }
267
410
  }
268
411
  }
269
412
  }
270
- let Z = 0, tt = 0;
271
- function T() {
272
- return `msg-${Date.now()}-${++Z}`;
413
+ let tt = 0, et = 0;
414
+ function v() {
415
+ return `msg-${Date.now()}-${++tt}`;
273
416
  }
274
- function N() {
275
- return `thread-${Date.now()}-${++tt}`;
417
+ function k() {
418
+ return `thread-${Date.now()}-${++et}`;
276
419
  }
277
- class v extends m {
420
+ class T extends _ {
278
421
  constructor(t) {
279
422
  super();
280
423
  u(this, "_state");
@@ -302,7 +445,7 @@ class v extends m {
302
445
  return super.subscribe(t);
303
446
  }
304
447
  }
305
- class et extends m {
448
+ class st extends _ {
306
449
  constructor() {
307
450
  super(...arguments);
308
451
  u(this, "_text", "");
@@ -330,11 +473,11 @@ class et extends m {
330
473
  this._isSubmitting = t, this.notifySubscribers();
331
474
  }
332
475
  }
333
- class R extends m {
476
+ class R extends _ {
334
477
  constructor(t) {
335
478
  super();
336
479
  u(this, "composer");
337
- this._core = t, this.composer = new et(), this._core.subscribe(() => {
480
+ this._core = t, this.composer = new st(), this._core.subscribe(() => {
338
481
  this.notifySubscribers();
339
482
  });
340
483
  }
@@ -395,11 +538,20 @@ class R extends m {
395
538
  }
396
539
  }
397
540
  }
541
+ /**
542
+ * Dispatches a system event (e.g. a user click on an elicitation card).
543
+ *
544
+ * Prior to this change, this method wrapped startSystemEventRun in a
545
+ * try/catch that silently swallowed the "A run is already in progress"
546
+ * error thrown by the core when _isRunning was still true — causing
547
+ * clicks fired during the tail of the previous run to disappear.
548
+ *
549
+ * Now we await waitForIdle() before dispatching so the event is
550
+ * reliably delivered as soon as the in-flight run completes. Callers
551
+ * do not need their own queueing primitive.
552
+ */
398
553
  async sendSystemEvent(t) {
399
- try {
400
- await this._core.startSystemEventRun(t);
401
- } catch {
402
- }
554
+ await this._core.waitForIdle(), await this._core.startSystemEventRun(t);
403
555
  }
404
556
  cancelRun() {
405
557
  this._core.cancelRun();
@@ -416,11 +568,14 @@ class R extends m {
416
568
  setTitle(t) {
417
569
  this._core.setTitle(t);
418
570
  }
571
+ updateMessageContent(t, e) {
572
+ this._core.updateMessageContent(t, e);
573
+ }
419
574
  subscribe(t) {
420
575
  return super.subscribe(t);
421
576
  }
422
577
  }
423
- class E extends m {
578
+ class M extends _ {
424
579
  constructor(t) {
425
580
  super();
426
581
  u(this, "_messages", []);
@@ -431,6 +586,11 @@ class E extends m {
431
586
  u(this, "_abortController", null);
432
587
  u(this, "_conversationId");
433
588
  u(this, "_title");
589
+ // Resolvers waiting for _isRunning to flip to false. Drained in the
590
+ // finally block of every run path so callers can serialize their
591
+ // dispatch against an in-progress run instead of having their error
592
+ // swallowed by the caller's try/catch.
593
+ u(this, "_idleWaiters", []);
434
594
  // Track current part being accumulated
435
595
  u(this, "_currentPart", null);
436
596
  this.config = t, t.initialMessages && (this._messages = [...t.initialMessages]);
@@ -467,12 +627,12 @@ class E extends m {
467
627
  };
468
628
  }
469
629
  updateMessages(t) {
470
- var e, s;
471
- this._messages = t, (s = (e = this.config).onMessagesChange) == null || s.call(e, this._messages), this.notifySubscribers();
630
+ var e, i;
631
+ this._messages = t, (i = (e = this.config).onMessagesChange) == null || i.call(e, this._messages), this.notifySubscribers();
472
632
  }
473
633
  append(t) {
474
634
  const e = {
475
- id: t.id || T(),
635
+ id: t.id || v(),
476
636
  parentId: t.parentId,
477
637
  role: t.role,
478
638
  content: t.content,
@@ -482,18 +642,41 @@ class E extends m {
482
642
  };
483
643
  this.updateMessages([...this._messages, e]);
484
644
  }
645
+ /**
646
+ * Resolves when _isRunning flips to false. Use this to queue a
647
+ * follow-on dispatch (e.g. a system event from a card click that
648
+ * fires during the tail of the previous run) without racing the
649
+ * in-progress run's guard.
650
+ *
651
+ * Resolves immediately if nothing is running.
652
+ */
653
+ waitForIdle() {
654
+ return this._isRunning ? new Promise((t) => {
655
+ this._idleWaiters.push(t);
656
+ }) : Promise.resolve();
657
+ }
658
+ drainIdleWaiters() {
659
+ if (this._idleWaiters.length === 0) return;
660
+ const t = this._idleWaiters;
661
+ this._idleWaiters = [];
662
+ for (const e of t)
663
+ try {
664
+ e();
665
+ } catch {
666
+ }
667
+ }
485
668
  async startSystemEventRun(t) {
486
669
  if (this._isRunning)
487
670
  throw new Error("A run is already in progress");
488
671
  this._isWaitingForUser = !1, this._pendingCapability = null, this._isRunning = !0, this._abortController = new AbortController(), this._currentPart = null;
489
- const e = T(), s = {
672
+ const e = v(), i = {
490
673
  id: e,
491
674
  role: "assistant",
492
675
  content: [],
493
676
  status: { type: "running" },
494
677
  timestamp: Date.now()
495
678
  };
496
- this.updateMessages([...this._messages, s]);
679
+ this.updateMessages([...this._messages, i]);
497
680
  try {
498
681
  const r = this.config.streamAdapter.stream({
499
682
  messages: this._messages,
@@ -501,68 +684,68 @@ class E extends m {
501
684
  signal: this._abortController.signal,
502
685
  systemEvent: t
503
686
  });
504
- for await (const i of r) {
687
+ for await (const a of r) {
505
688
  if (this._abortController.signal.aborted)
506
689
  break;
507
- this.handleStreamEvent(e, i.event);
690
+ this.handleStreamEvent(e, a.event);
508
691
  }
509
692
  this.updateMessageStatus(e, { type: "complete" });
510
693
  } catch (r) {
511
694
  if (r instanceof Error && r.name === "AbortError")
512
695
  this.completeStreamingContent(e), this.updateMessageStatus(e, { type: "cancelled" });
513
696
  else {
514
- const i = r instanceof Error ? r.message : "Unknown error";
697
+ const a = r instanceof Error ? r.message : "Unknown error";
515
698
  this.completeStreamingContent(e), this.updateMessageStatus(e, {
516
699
  type: "error",
517
- error: i
700
+ error: a
518
701
  });
519
702
  }
520
703
  } finally {
521
- this._isRunning = !1, this._abortController = null, this._currentPart = null, this.notifySubscribers();
704
+ this._isRunning = !1, this._abortController = null, this._currentPart = null, this.notifySubscribers(), this.drainIdleWaiters();
522
705
  }
523
706
  }
524
707
  async startRun(t) {
525
708
  if (this._isRunning)
526
709
  throw new Error("A run is already in progress");
527
710
  this._isWaitingForUser = !1, this._pendingCapability = null, this.append(t), this._isRunning = !0, this._abortController = new AbortController(), this._currentPart = null;
528
- const e = T(), s = {
711
+ const e = v(), i = {
529
712
  id: e,
530
713
  role: "assistant",
531
714
  content: [],
532
715
  status: { type: "running" },
533
716
  timestamp: Date.now()
534
717
  };
535
- this.updateMessages([...this._messages, s]);
718
+ this.updateMessages([...this._messages, i]);
536
719
  try {
537
720
  const r = this.config.streamAdapter.stream({
538
721
  messages: this._messages,
539
722
  conversationId: this._conversationId,
540
723
  signal: this._abortController.signal
541
724
  });
542
- for await (const i of r) {
725
+ for await (const a of r) {
543
726
  if (this._abortController.signal.aborted)
544
727
  break;
545
- this.handleStreamEvent(e, i.event);
728
+ this.handleStreamEvent(e, a.event);
546
729
  }
547
730
  this.updateMessageStatus(e, { type: "complete" });
548
731
  } catch (r) {
549
732
  if (r instanceof Error && r.name === "AbortError")
550
733
  this.completeStreamingContent(e), this.updateMessageStatus(e, { type: "cancelled" });
551
734
  else {
552
- const i = r instanceof Error ? r.message : "Unknown error";
735
+ const a = r instanceof Error ? r.message : "Unknown error";
553
736
  this.completeStreamingContent(e), this.updateMessageStatus(e, {
554
737
  type: "error",
555
- error: i
738
+ error: a
556
739
  });
557
740
  }
558
741
  } finally {
559
- this._isRunning = !1, this._abortController = null, this._currentPart = null, this.notifySubscribers();
742
+ this._isRunning = !1, this._abortController = null, this._currentPart = null, this.notifySubscribers(), this.drainIdleWaiters();
560
743
  }
561
744
  }
562
745
  handleStreamEvent(t, e) {
563
- const s = this._messages.findIndex((o) => o.id === t);
564
- if (s === -1) return;
565
- const r = this._messages[s];
746
+ const i = this._messages.findIndex((o) => o.id === t);
747
+ if (i === -1) return;
748
+ const r = this._messages[i];
566
749
  if (e.type === "part-start")
567
750
  this.handlePartStart(r, e);
568
751
  else if (e.type === "text-delta" || e.type === "assistant_thought")
@@ -584,15 +767,15 @@ class E extends m {
584
767
  args: o.args
585
768
  };
586
769
  r.content.push(c);
587
- const d = o.artifact;
588
- d && r.content.push({
770
+ const h = o.artifact;
771
+ h && r.content.push({
589
772
  type: "artifact",
590
773
  data: {
591
774
  capabilityName: o.capabilityName,
592
775
  originalArgs: o.args,
593
776
  displayData: {
594
- name: d.displayName,
595
- type: d.displayType
777
+ name: h.displayName,
778
+ type: h.displayType
596
779
  }
597
780
  }
598
781
  }), this.config.capabilityExecutionManager && this.config.capabilityExecutionManager.executeCapability(
@@ -625,15 +808,15 @@ class E extends m {
625
808
  }
626
809
  ];
627
810
  }
628
- const i = [
629
- ...this._messages.slice(0, s),
811
+ const a = [
812
+ ...this._messages.slice(0, i),
630
813
  { ...r, timestamp: Date.now() },
631
- ...this._messages.slice(s + 1)
814
+ ...this._messages.slice(i + 1)
632
815
  ];
633
- this.updateMessages(i);
816
+ this.updateMessages(a);
634
817
  }
635
818
  handlePartStart(t, e) {
636
- const s = t.content.length;
819
+ const i = t.content.length;
637
820
  let r;
638
821
  switch (e.part.type) {
639
822
  case "assistant_thought":
@@ -661,7 +844,7 @@ class E extends m {
661
844
  }
662
845
  t.content = [...t.content, r], this._currentPart = {
663
846
  messageId: t.id,
664
- contentIndex: s,
847
+ contentIndex: i,
665
848
  type: e.part.type,
666
849
  parentId: e.part.parentId
667
850
  };
@@ -671,8 +854,8 @@ class E extends m {
671
854
  console.warn("Received text-delta without part-start");
672
855
  return;
673
856
  }
674
- const s = t.content[this._currentPart.contentIndex];
675
- s.type === "assistant_thought" ? (Array.isArray(s.data) || (s.data = []), e.delta.trim() && s.data.push(e.delta.trim())) : s.data = (s.data || "") + e.delta;
857
+ const i = t.content[this._currentPart.contentIndex];
858
+ i.type === "assistant_thought" ? (Array.isArray(i.data) || (i.data = []), e.delta.trim() && i.data.push(e.delta.trim())) : i.data = (i.data || "") + e.delta;
676
859
  }
677
860
  handlePartFinish() {
678
861
  if (!this._currentPart) {
@@ -681,9 +864,9 @@ class E extends m {
681
864
  }
682
865
  const t = this._messages.findIndex((e) => e.id === this._currentPart.messageId);
683
866
  if (t !== -1) {
684
- const e = this._messages[t], s = e.content[this._currentPart.contentIndex];
685
- if (s) {
686
- s.status = { type: "complete" };
867
+ const e = this._messages[t], i = e.content[this._currentPart.contentIndex];
868
+ if (i) {
869
+ i.status = { type: "complete" };
687
870
  const r = [
688
871
  ...this._messages.slice(0, t),
689
872
  { ...e, timestamp: Date.now() },
@@ -695,32 +878,32 @@ class E extends m {
695
878
  this._currentPart = null;
696
879
  }
697
880
  updateMessageStatus(t, e) {
698
- const s = this._messages.findIndex((i) => i.id === t);
699
- if (s === -1) return;
881
+ const i = this._messages.findIndex((a) => a.id === t);
882
+ if (i === -1) return;
700
883
  const r = [
701
- ...this._messages.slice(0, s),
884
+ ...this._messages.slice(0, i),
702
885
  {
703
- ...this._messages[s],
886
+ ...this._messages[i],
704
887
  status: e
705
888
  },
706
- ...this._messages.slice(s + 1)
889
+ ...this._messages.slice(i + 1)
707
890
  ];
708
891
  this.updateMessages(r);
709
892
  }
710
893
  completeStreamingContent(t) {
711
894
  const e = this._messages.findIndex((c) => c.id === t);
712
895
  if (e === -1) return;
713
- const s = this._messages[e];
714
- if (!s.content.some((c) => {
715
- var d;
716
- return ((d = c.status) == null ? void 0 : d.type) === "streaming";
896
+ const i = this._messages[e];
897
+ if (!i.content.some((c) => {
898
+ var h;
899
+ return ((h = c.status) == null ? void 0 : h.type) === "streaming";
717
900
  })) return;
718
- const i = s.content.map((c) => {
719
- var d;
720
- return ((d = c.status) == null ? void 0 : d.type) === "streaming" ? { ...c, status: { type: "complete" } } : c;
901
+ const a = i.content.map((c) => {
902
+ var h;
903
+ return ((h = c.status) == null ? void 0 : h.type) === "streaming" ? { ...c, status: { type: "complete" } } : c;
721
904
  }), o = [
722
905
  ...this._messages.slice(0, e),
723
- { ...s, content: i, timestamp: Date.now() },
906
+ { ...i, content: a, timestamp: Date.now() },
724
907
  ...this._messages.slice(e + 1)
725
908
  ];
726
909
  this.updateMessages(o);
@@ -740,8 +923,18 @@ class E extends m {
740
923
  setTitle(t) {
741
924
  this._title = t, this.notifySubscribers();
742
925
  }
926
+ updateMessageContent(t, e) {
927
+ const i = this._messages.findIndex((c) => c.id === t);
928
+ if (i === -1) return;
929
+ const r = this._messages[i], a = e(r.content), o = [
930
+ ...this._messages.slice(0, i),
931
+ { ...r, content: a, timestamp: Date.now() },
932
+ ...this._messages.slice(i + 1)
933
+ ];
934
+ this.updateMessages(o);
935
+ }
743
936
  }
744
- class st extends m {
937
+ class it extends _ {
745
938
  constructor(t) {
746
939
  super();
747
940
  u(this, "_mainThreadId");
@@ -752,13 +945,13 @@ class st extends m {
752
945
  u(this, "_searchQuery");
753
946
  u(this, "_abortController", null);
754
947
  u(this, "main");
755
- this.config = t, this._mainThreadId = N();
756
- const e = new E({
948
+ this.config = t, this._mainThreadId = k();
949
+ const e = new M({
757
950
  streamAdapter: t.streamAdapter,
758
951
  capabilityExecutionManager: t.capabilityExecutionManager
759
952
  });
760
953
  this.main = new R(e), this._threads.set(this._mainThreadId, this.main);
761
- const s = {
954
+ const i = {
762
955
  id: this._mainThreadId,
763
956
  title: "New Chat",
764
957
  status: { type: "regular" },
@@ -766,9 +959,9 @@ class st extends m {
766
959
  createdAt: Date.now(),
767
960
  updatedAt: Date.now()
768
961
  };
769
- this._threadStates.set(this._mainThreadId, s);
770
- const r = new v({
771
- state: s,
962
+ this._threadStates.set(this._mainThreadId, i);
963
+ const r = new T({
964
+ state: i,
772
965
  onSwitchTo: this.switchToThread.bind(this),
773
966
  onRename: this.renameThread.bind(this),
774
967
  onDelete: this.deleteThread.bind(this)
@@ -787,8 +980,8 @@ class st extends m {
787
980
  }
788
981
  getState() {
789
982
  const t = [], e = {};
790
- for (const [s, r] of this._threadStates)
791
- e[s] = r, r.status.type === "regular" && t.push(s);
983
+ for (const [i, r] of this._threadStates)
984
+ e[i] = r, r.status.type === "regular" && t.push(i);
792
985
  return {
793
986
  mainThreadId: this._mainThreadId,
794
987
  threads: t,
@@ -798,12 +991,12 @@ class st extends m {
798
991
  };
799
992
  }
800
993
  async switchToThread(t) {
801
- var i, o;
994
+ var a, o;
802
995
  const e = this._threads.get(t);
803
996
  if (!e)
804
997
  throw new Error(`Thread ${t} not found`);
805
- const s = this._threadStates.get(this._mainThreadId);
806
- s && (s.isMain = !1, this._threadStates.set(this._mainThreadId, s), (i = this._threadItems.get(this._mainThreadId)) == null || i.updateState(s)), this._mainThreadId = t;
998
+ const i = this._threadStates.get(this._mainThreadId);
999
+ i && (i.isMain = !1, this._threadStates.set(this._mainThreadId, i), (a = this._threadItems.get(this._mainThreadId)) == null || a.updateState(i)), this._mainThreadId = t;
807
1000
  const r = this._threadStates.get(t);
808
1001
  if (r && (r.isMain = !0, this._threadStates.set(t, r), (o = this._threadItems.get(t)) == null || o.updateState(r), e.setConversationId(r.conversationId), e.setTitle(r.title)), this.config.threadListAdapter && (r != null && r.conversationId)) {
809
1002
  this._isLoading = !0, this.notifySubscribers();
@@ -819,11 +1012,11 @@ class st extends m {
819
1012
  this.notifySubscribers();
820
1013
  }
821
1014
  async switchToNewThread() {
822
- const t = N(), e = new E({
1015
+ const t = k(), e = new M({
823
1016
  streamAdapter: this.config.streamAdapter,
824
1017
  capabilityExecutionManager: this.config.capabilityExecutionManager
825
- }), s = new R(e);
826
- this._threads.set(t, s);
1018
+ }), i = new R(e);
1019
+ this._threads.set(t, i);
827
1020
  const r = {
828
1021
  id: t,
829
1022
  title: "New Chat",
@@ -833,18 +1026,18 @@ class st extends m {
833
1026
  updatedAt: Date.now()
834
1027
  };
835
1028
  this._threadStates.set(t, r);
836
- const i = new v({
1029
+ const a = new T({
837
1030
  state: r,
838
1031
  onSwitchTo: this.switchToThread.bind(this),
839
1032
  onRename: this.renameThread.bind(this),
840
1033
  onDelete: this.deleteThread.bind(this)
841
1034
  });
842
- if (this._threadItems.set(t, i), s.subscribe(() => {
843
- this.syncThreadStateFromRuntime(t, s), this.notifySubscribers();
1035
+ if (this._threadItems.set(t, a), i.subscribe(() => {
1036
+ this.syncThreadStateFromRuntime(t, i), this.notifySubscribers();
844
1037
  }), this.config.threadListAdapter)
845
1038
  try {
846
1039
  const o = await this.config.threadListAdapter.createThread();
847
- r.conversationId = o.conversationId, this._threadStates.set(t, r), i.updateState(r);
1040
+ r.conversationId = o.conversationId, this._threadStates.set(t, r), a.updateState(r);
848
1041
  } catch (o) {
849
1042
  console.error("Failed to create thread:", o);
850
1043
  }
@@ -856,29 +1049,29 @@ class st extends m {
856
1049
  if (this._isLoading)
857
1050
  return [];
858
1051
  if (this._abortController && this._abortController.abort(), this._abortController = new AbortController(), (t == null ? void 0 : t.query) !== void 0 && (this._searchQuery = t.query), t != null && t.replace) {
859
- const e = Array.from(this._threads.keys()).filter((s) => s !== this._mainThreadId);
860
- for (const s of e)
861
- this._threads.delete(s), this._threadItems.delete(s), this._threadStates.delete(s);
1052
+ const e = Array.from(this._threads.keys()).filter((i) => i !== this._mainThreadId);
1053
+ for (const i of e)
1054
+ this._threads.delete(i), this._threadItems.delete(i), this._threadStates.delete(i);
862
1055
  }
863
1056
  this._isLoading = !0, this.notifySubscribers();
864
1057
  try {
865
1058
  const e = await this.config.threadListAdapter.loadThreads(t);
866
- for (const s of e) {
867
- if (this._threadStates.has(s.id))
1059
+ for (const i of e) {
1060
+ if (this._threadStates.has(i.id))
868
1061
  continue;
869
- const r = new E({
1062
+ const r = new M({
870
1063
  streamAdapter: this.config.streamAdapter,
871
1064
  capabilityExecutionManager: this.config.capabilityExecutionManager
872
- }), i = new R(r);
873
- this._threads.set(s.id, i), this._threadStates.set(s.id, s);
874
- const o = new v({
875
- state: s,
1065
+ }), a = new R(r);
1066
+ this._threads.set(i.id, a), this._threadStates.set(i.id, i);
1067
+ const o = new T({
1068
+ state: i,
876
1069
  onSwitchTo: this.switchToThread.bind(this),
877
1070
  onRename: this.renameThread.bind(this),
878
1071
  onDelete: this.deleteThread.bind(this)
879
1072
  });
880
- this._threadItems.set(s.id, o), i.subscribe(() => {
881
- this.syncThreadStateFromRuntime(s.id, i), this.notifySubscribers();
1073
+ this._threadItems.set(i.id, o), a.subscribe(() => {
1074
+ this.syncThreadStateFromRuntime(i.id, a), this.notifySubscribers();
882
1075
  });
883
1076
  }
884
1077
  return e;
@@ -893,18 +1086,18 @@ class st extends m {
893
1086
  */
894
1087
  syncThreadStateFromRuntime(t, e) {
895
1088
  var r;
896
- const s = this._threadStates.get(t);
897
- s && (s.conversationId !== e.conversationId || s.title !== e.title) && (s.conversationId = e.conversationId, s.title = e.title || s.title, s.updatedAt = Date.now(), this._threadStates.set(t, s), (r = this._threadItems.get(t)) == null || r.updateState(s));
1089
+ const i = this._threadStates.get(t);
1090
+ i && (i.conversationId !== e.conversationId || i.title !== e.title) && (i.conversationId = e.conversationId, i.title = e.title || i.title, i.updatedAt = Date.now(), this._threadStates.set(t, i), (r = this._threadItems.get(t)) == null || r.updateState(i));
898
1091
  }
899
1092
  async renameThread(t, e) {
900
1093
  var r;
901
- const s = this._threadStates.get(t);
902
- if (s) {
903
- if (s.title = e, s.updatedAt = Date.now(), this._threadStates.set(t, s), (r = this._threadItems.get(t)) == null || r.updateState(s), this.config.threadListAdapter)
1094
+ const i = this._threadStates.get(t);
1095
+ if (i) {
1096
+ if (i.title = e, i.updatedAt = Date.now(), this._threadStates.set(t, i), (r = this._threadItems.get(t)) == null || r.updateState(i), this.config.threadListAdapter)
904
1097
  try {
905
1098
  await this.config.threadListAdapter.updateThread(t, { title: e });
906
- } catch (i) {
907
- console.error("Failed to rename thread:", i);
1099
+ } catch (a) {
1100
+ console.error("Failed to rename thread:", a);
908
1101
  }
909
1102
  this.notifySubscribers();
910
1103
  }
@@ -913,7 +1106,7 @@ class st extends m {
913
1106
  if (t === this._mainThreadId && this._threads.size === 1)
914
1107
  throw new Error("Cannot delete the last thread");
915
1108
  if (t === this._mainThreadId) {
916
- const e = Array.from(this._threads.keys()).find((s) => s !== t);
1109
+ const e = Array.from(this._threads.keys()).find((i) => i !== t);
917
1110
  e && await this.switchToThread(e);
918
1111
  }
919
1112
  if (this._threads.delete(t), this._threadItems.delete(t), this._threadStates.delete(t), this.config.threadListAdapter)
@@ -925,22 +1118,23 @@ class st extends m {
925
1118
  this.notifySubscribers();
926
1119
  }
927
1120
  }
928
- class bt extends m {
1121
+ class yt extends _ {
929
1122
  constructor(t) {
930
1123
  super();
931
1124
  u(this, "threads");
932
1125
  u(this, "pluginRegistry");
933
1126
  u(this, "capabilityRegistry");
934
1127
  u(this, "capabilityExecutionManager");
1128
+ u(this, "quickActionRegistry");
935
1129
  u(this, "_contentFocusRuntime");
936
1130
  u(this, "_currentThreadUnsubscribe");
937
1131
  this.pluginRegistry = new G(), t.plugins && t.plugins.forEach((e) => {
938
1132
  this.pluginRegistry.registerPlugin(e);
939
- }), this.capabilityRegistry = new Y(), this.capabilityExecutionManager = new K((e) => this.capabilityRegistry.getHandler(e)), this.threads = new st({
1133
+ }), this.capabilityRegistry = new Y(), this.capabilityExecutionManager = new K((e) => this.capabilityRegistry.getHandler(e)), this.quickActionRegistry = new X(), this.threads = new it({
940
1134
  streamAdapter: t.streamAdapter,
941
1135
  threadListAdapter: t.threadListAdapter,
942
1136
  capabilityExecutionManager: this.capabilityExecutionManager
943
- }), this._contentFocusRuntime = new X(), this._contentFocusRuntime.subscribe(() => {
1137
+ }), this._contentFocusRuntime = new Z(), this._contentFocusRuntime.subscribe(() => {
944
1138
  this.notifySubscribers();
945
1139
  }), this.threads.subscribe(() => {
946
1140
  this.subscribeToCurrentThread(), this.notifySubscribers();
@@ -986,20 +1180,20 @@ class bt extends m {
986
1180
  autoFocusLastContent(t) {
987
1181
  var e;
988
1182
  if (t.length !== 0)
989
- for (let s = t.length - 1; s >= 0; s--) {
990
- const r = t[s];
1183
+ for (let i = t.length - 1; i >= 0; i--) {
1184
+ const r = t[i];
991
1185
  if (r.role === "assistant")
992
- for (let i = r.content.length - 1; i >= 0; i--) {
993
- const o = r.content[i], c = this.pluginRegistry.getRenderersByType(o.type);
1186
+ for (let a = r.content.length - 1; a >= 0; a--) {
1187
+ const o = r.content[a], c = this.pluginRegistry.getRenderersByType(o.type);
994
1188
  if (c.length > 0 && ((e = c[0].capabilities) != null && e.supportsFocus)) {
995
- this._contentFocusRuntime.isActive && this._contentFocusRuntime.focusedMessageId === r.id && this._contentFocusRuntime.focusedContentIndex === i || this._contentFocusRuntime.focus(o, r, i, "detail");
1189
+ this._contentFocusRuntime.isActive && this._contentFocusRuntime.focusedMessageId === r.id && this._contentFocusRuntime.focusedContentIndex === a || this._contentFocusRuntime.focus(o, r, a, "detail");
996
1190
  return;
997
1191
  }
998
1192
  }
999
1193
  }
1000
1194
  }
1001
1195
  }
1002
- var M = { exports: {} }, x = {};
1196
+ var E = { exports: {} }, x = {};
1003
1197
  /*
1004
1198
  object-assign
1005
1199
  (c) Sindre Sorhus
@@ -1009,43 +1203,43 @@ var A, D;
1009
1203
  function rt() {
1010
1204
  if (D) return A;
1011
1205
  D = 1;
1012
- var a = Object.getOwnPropertySymbols, n = Object.prototype.hasOwnProperty, t = Object.prototype.propertyIsEnumerable;
1206
+ var n = Object.getOwnPropertySymbols, s = Object.prototype.hasOwnProperty, t = Object.prototype.propertyIsEnumerable;
1013
1207
  function e(r) {
1014
1208
  if (r == null)
1015
1209
  throw new TypeError("Object.assign cannot be called with null or undefined");
1016
1210
  return Object(r);
1017
1211
  }
1018
- function s() {
1212
+ function i() {
1019
1213
  try {
1020
1214
  if (!Object.assign)
1021
1215
  return !1;
1022
1216
  var r = new String("abc");
1023
1217
  if (r[5] = "de", Object.getOwnPropertyNames(r)[0] === "5")
1024
1218
  return !1;
1025
- for (var i = {}, o = 0; o < 10; o++)
1026
- i["_" + String.fromCharCode(o)] = o;
1027
- var c = Object.getOwnPropertyNames(i).map(function(l) {
1028
- return i[l];
1219
+ for (var a = {}, o = 0; o < 10; o++)
1220
+ a["_" + String.fromCharCode(o)] = o;
1221
+ var c = Object.getOwnPropertyNames(a).map(function(l) {
1222
+ return a[l];
1029
1223
  });
1030
1224
  if (c.join("") !== "0123456789")
1031
1225
  return !1;
1032
- var d = {};
1226
+ var h = {};
1033
1227
  return "abcdefghijklmnopqrst".split("").forEach(function(l) {
1034
- d[l] = l;
1035
- }), Object.keys(Object.assign({}, d)).join("") === "abcdefghijklmnopqrst";
1228
+ h[l] = l;
1229
+ }), Object.keys(Object.assign({}, h)).join("") === "abcdefghijklmnopqrst";
1036
1230
  } catch {
1037
1231
  return !1;
1038
1232
  }
1039
1233
  }
1040
- return A = s() ? Object.assign : function(r, i) {
1041
- for (var o, c = e(r), d, l = 1; l < arguments.length; l++) {
1234
+ return A = i() ? Object.assign : function(r, a) {
1235
+ for (var o, c = e(r), h, l = 1; l < arguments.length; l++) {
1042
1236
  o = Object(arguments[l]);
1043
- for (var h in o)
1044
- n.call(o, h) && (c[h] = o[h]);
1045
- if (a) {
1046
- d = a(o);
1047
- for (var g = 0; g < d.length; g++)
1048
- t.call(o, d[g]) && (c[d[g]] = o[d[g]]);
1237
+ for (var d in o)
1238
+ s.call(o, d) && (c[d] = o[d]);
1239
+ if (n) {
1240
+ h = n(o);
1241
+ for (var p = 0; p < h.length; p++)
1242
+ t.call(o, h[p]) && (c[h[p]] = o[h[p]]);
1049
1243
  }
1050
1244
  }
1051
1245
  return c;
@@ -1059,72 +1253,72 @@ function rt() {
1059
1253
  * This source code is licensed under the MIT license found in the
1060
1254
  * LICENSE file in the root directory of this source tree.
1061
1255
  */
1062
- var j;
1256
+ var N;
1063
1257
  function nt() {
1064
- if (j) return x;
1065
- j = 1, rt();
1066
- var a = U, n = 60103;
1258
+ if (N) return x;
1259
+ N = 1, rt();
1260
+ var n = q, s = 60103;
1067
1261
  if (x.Fragment = 60107, typeof Symbol == "function" && Symbol.for) {
1068
1262
  var t = Symbol.for;
1069
- n = t("react.element"), x.Fragment = t("react.fragment");
1263
+ s = t("react.element"), x.Fragment = t("react.fragment");
1070
1264
  }
1071
- var e = a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = Object.prototype.hasOwnProperty, r = { key: !0, ref: !0, __self: !0, __source: !0 };
1072
- function i(o, c, d) {
1073
- var l, h = {}, g = null, p = null;
1074
- d !== void 0 && (g = "" + d), c.key !== void 0 && (g = "" + c.key), c.ref !== void 0 && (p = c.ref);
1075
- for (l in c) s.call(c, l) && !r.hasOwnProperty(l) && (h[l] = c[l]);
1076
- if (o && o.defaultProps) for (l in c = o.defaultProps, c) h[l] === void 0 && (h[l] = c[l]);
1077
- return { $$typeof: n, type: o, key: g, ref: p, props: h, _owner: e.current };
1265
+ var e = n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = Object.prototype.hasOwnProperty, r = { key: !0, ref: !0, __self: !0, __source: !0 };
1266
+ function a(o, c, h) {
1267
+ var l, d = {}, p = null, g = null;
1268
+ h !== void 0 && (p = "" + h), c.key !== void 0 && (p = "" + c.key), c.ref !== void 0 && (g = c.ref);
1269
+ for (l in c) i.call(c, l) && !r.hasOwnProperty(l) && (d[l] = c[l]);
1270
+ if (o && o.defaultProps) for (l in c = o.defaultProps, c) d[l] === void 0 && (d[l] = c[l]);
1271
+ return { $$typeof: s, type: o, key: p, ref: g, props: d, _owner: e.current };
1078
1272
  }
1079
- return x.jsx = i, x.jsxs = i, x;
1273
+ return x.jsx = a, x.jsxs = a, x;
1080
1274
  }
1081
1275
  var O;
1082
- function it() {
1083
- return O || (O = 1, M.exports = nt()), M.exports;
1276
+ function at() {
1277
+ return O || (O = 1, E.exports = nt()), E.exports;
1084
1278
  }
1085
- var S = it();
1086
- const W = B(null);
1087
- function mt({ runtime: a, children: n }) {
1088
- return /* @__PURE__ */ S.jsx(W.Provider, { value: a, children: n });
1279
+ var w = at();
1280
+ const W = U(null);
1281
+ function _t({ runtime: n, children: s }) {
1282
+ return /* @__PURE__ */ w.jsx(W.Provider, { value: n, children: s });
1089
1283
  }
1090
- function at() {
1091
- const a = q(W);
1092
- if (!a)
1284
+ function ot() {
1285
+ const n = B(W);
1286
+ if (!n)
1093
1287
  throw new Error("useAssistantRuntimeContext must be used within AssistantRuntimeProvider");
1094
- return a;
1288
+ return n;
1095
1289
  }
1096
1290
  function f() {
1097
- return at();
1291
+ return ot();
1098
1292
  }
1099
- function _t() {
1100
- const a = f();
1293
+ function St() {
1294
+ const n = f();
1101
1295
  return {
1102
- switchToThread: (n) => a.threads.switchToThread(n),
1103
- switchToNewThread: () => a.threads.switchToNewThread(),
1104
- loadThreads: (n) => a.threads.loadThreads(n),
1105
- renameThread: (n, t) => {
1106
- var e, s;
1107
- return (s = (e = a.threads).renameThread) == null ? void 0 : s.call(e, n, t);
1296
+ switchToThread: (s) => n.threads.switchToThread(s),
1297
+ switchToNewThread: () => n.threads.switchToNewThread(),
1298
+ loadThreads: (s) => n.threads.loadThreads(s),
1299
+ renameThread: (s, t) => {
1300
+ var e, i;
1301
+ return (i = (e = n.threads).renameThread) == null ? void 0 : i.call(e, s, t);
1108
1302
  },
1109
- deleteThread: (n) => {
1303
+ deleteThread: (s) => {
1110
1304
  var t, e;
1111
- return (e = (t = a.threads).deleteThread) == null ? void 0 : e.call(t, n);
1305
+ return (e = (t = n.threads).deleteThread) == null ? void 0 : e.call(t, s);
1112
1306
  }
1113
1307
  };
1114
1308
  }
1115
1309
  function xt() {
1116
- const a = f(), [n, t] = b(a.threads.getState());
1117
- return w(() => a.threads.subscribe(() => {
1118
- t(a.threads.getState());
1119
- }), [a]), n;
1310
+ const n = f(), [s, t] = y(n.threads.getState());
1311
+ return m(() => n.threads.subscribe(() => {
1312
+ t(n.threads.getState());
1313
+ }), [n]), s;
1120
1314
  }
1121
- function ot() {
1122
- const n = f().threads.getMainThread(), [, t] = b({});
1123
- return w(() => n.subscribe(() => {
1315
+ function ct() {
1316
+ const s = f().threads.getMainThread(), [, t] = y({});
1317
+ return m(() => s.subscribe(() => {
1124
1318
  t({});
1125
- }), [n]), n;
1319
+ }), [s]), s;
1126
1320
  }
1127
- var F = { exports: {} }, P = {};
1321
+ var P = { exports: {} }, F = {};
1128
1322
  /**
1129
1323
  * @license React
1130
1324
  * use-sync-external-store-shim.production.js
@@ -1134,87 +1328,87 @@ var F = { exports: {} }, P = {};
1134
1328
  * This source code is licensed under the MIT license found in the
1135
1329
  * LICENSE file in the root directory of this source tree.
1136
1330
  */
1137
- var L;
1138
- function ct() {
1139
- if (L) return P;
1140
- L = 1;
1141
- var a = U;
1142
- function n(h, g) {
1143
- return h === g && (h !== 0 || 1 / h === 1 / g) || h !== h && g !== g;
1144
- }
1145
- var t = typeof Object.is == "function" ? Object.is : n, e = a.useState, s = a.useEffect, r = a.useLayoutEffect, i = a.useDebugValue;
1146
- function o(h, g) {
1147
- var p = g(), _ = e({ inst: { value: p, getSnapshot: g } }), y = _[0].inst, I = _[1];
1331
+ var j;
1332
+ function ut() {
1333
+ if (j) return F;
1334
+ j = 1;
1335
+ var n = q;
1336
+ function s(d, p) {
1337
+ return d === p && (d !== 0 || 1 / d === 1 / p) || d !== d && p !== p;
1338
+ }
1339
+ var t = typeof Object.is == "function" ? Object.is : s, e = n.useState, i = n.useEffect, r = n.useLayoutEffect, a = n.useDebugValue;
1340
+ function o(d, p) {
1341
+ var g = p(), S = e({ inst: { value: g, getSnapshot: p } }), b = S[0].inst, I = S[1];
1148
1342
  return r(
1149
1343
  function() {
1150
- y.value = p, y.getSnapshot = g, c(y) && I({ inst: y });
1344
+ b.value = g, b.getSnapshot = p, c(b) && I({ inst: b });
1151
1345
  },
1152
- [h, p, g]
1153
- ), s(
1346
+ [d, g, p]
1347
+ ), i(
1154
1348
  function() {
1155
- return c(y) && I({ inst: y }), h(function() {
1156
- c(y) && I({ inst: y });
1349
+ return c(b) && I({ inst: b }), d(function() {
1350
+ c(b) && I({ inst: b });
1157
1351
  });
1158
1352
  },
1159
- [h]
1160
- ), i(p), p;
1353
+ [d]
1354
+ ), a(g), g;
1161
1355
  }
1162
- function c(h) {
1163
- var g = h.getSnapshot;
1164
- h = h.value;
1356
+ function c(d) {
1357
+ var p = d.getSnapshot;
1358
+ d = d.value;
1165
1359
  try {
1166
- var p = g();
1167
- return !t(h, p);
1360
+ var g = p();
1361
+ return !t(d, g);
1168
1362
  } catch {
1169
1363
  return !0;
1170
1364
  }
1171
1365
  }
1172
- function d(h, g) {
1173
- return g();
1366
+ function h(d, p) {
1367
+ return p();
1174
1368
  }
1175
- var l = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? d : o;
1176
- return P.useSyncExternalStore = a.useSyncExternalStore !== void 0 ? a.useSyncExternalStore : l, P;
1369
+ var l = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? h : o;
1370
+ return F.useSyncExternalStore = n.useSyncExternalStore !== void 0 ? n.useSyncExternalStore : l, F;
1177
1371
  }
1178
- var k;
1179
- function ut() {
1180
- return k || (k = 1, F.exports = ct()), F.exports;
1372
+ var L;
1373
+ function ht() {
1374
+ return L || (L = 1, P.exports = ut()), P.exports;
1181
1375
  }
1182
- var ht = ut();
1183
- function St() {
1184
- const a = f();
1185
- return ht.useSyncExternalStore(
1186
- (n) => a.subscribe(() => {
1187
- n();
1376
+ var dt = ht();
1377
+ function wt() {
1378
+ const n = f();
1379
+ return dt.useSyncExternalStore(
1380
+ (s) => n.subscribe(() => {
1381
+ s();
1188
1382
  }),
1189
- () => a.thread.messages,
1190
- () => a.thread.messages
1383
+ () => n.thread.messages,
1384
+ () => n.thread.messages
1191
1385
  );
1192
1386
  }
1193
- function wt() {
1194
- const a = ot(), [n, t] = b(""), [e, s] = b(!1);
1387
+ function Ct() {
1388
+ const n = ct(), [s, t] = y(""), [e, i] = y(!1);
1195
1389
  return {
1196
- text: n,
1390
+ text: s,
1197
1391
  setText: t,
1198
1392
  isSubmitting: e,
1199
- send: async (i) => {
1200
- if (i == null || i.preventDefault(), !n.trim() || e) return;
1201
- const o = n;
1202
- t(""), s(!0);
1393
+ send: async (a) => {
1394
+ if (a == null || a.preventDefault(), !s.trim() || e) return;
1395
+ const o = s;
1396
+ t(""), i(!0);
1203
1397
  try {
1204
- await a.send(o);
1398
+ await n.send(o);
1205
1399
  } catch (c) {
1206
1400
  console.error("Failed to send message:", c), t(o);
1207
1401
  } finally {
1208
- s(!1);
1402
+ i(!1);
1209
1403
  }
1210
1404
  },
1211
1405
  clear: () => t(""),
1212
- append: (i) => t((o) => o + i)
1406
+ append: (a) => t((o) => o + a)
1213
1407
  };
1214
1408
  }
1215
- function $(a, n) {
1216
- var r, i, o, c;
1217
- const e = f().pluginRegistry.getBestRendererForType(a);
1409
+ function Q(n, s) {
1410
+ var r, a, o, c;
1411
+ const e = f().pluginRegistry.getBestRendererForType(n);
1218
1412
  if (!e)
1219
1413
  return {
1220
1414
  component: null,
@@ -1223,222 +1417,253 @@ function $(a, n) {
1223
1417
  supportsPreview: !1,
1224
1418
  supportsFullscreen: !1
1225
1419
  };
1226
- const s = n ? (r = e.auxiliary) == null ? void 0 : r[n] : null;
1420
+ const i = s ? (r = e.auxiliary) == null ? void 0 : r[s] : null;
1227
1421
  return {
1228
1422
  component: e.component,
1229
- auxiliaryComponent: s,
1230
- supportsFocus: ((i = e.capabilities) == null ? void 0 : i.supportsFocus) ?? !1,
1423
+ auxiliaryComponent: i,
1424
+ supportsFocus: ((a = e.capabilities) == null ? void 0 : a.supportsFocus) ?? !1,
1231
1425
  supportsPreview: ((o = e.capabilities) == null ? void 0 : o.supportsPreview) ?? !1,
1232
1426
  supportsFullscreen: ((c = e.capabilities) == null ? void 0 : c.supportsFullscreen) ?? !1
1233
1427
  };
1234
1428
  }
1235
- function Ct() {
1236
- const a = f(), [n, t] = b(a.contentFocus.state);
1237
- return w(() => a.contentFocus.subscribe(() => {
1238
- t(a.contentFocus.state);
1239
- }), [a]), {
1240
- ...n,
1241
- focus: (e, s, r, i) => a.contentFocus.focus(e, s, r, i),
1242
- blur: () => a.contentFocus.blur(),
1243
- toggle: (e, s, r, i) => a.contentFocus.toggle(e, s, r, i),
1244
- switchContext: (e) => a.contentFocus.switchContext(e),
1245
- focusNext: () => a.contentFocus.focusNext(a.thread.messages),
1246
- focusPrevious: () => a.contentFocus.focusPrevious(a.thread.messages)
1429
+ function It() {
1430
+ const n = f(), [s, t] = y(n.contentFocus.state);
1431
+ return m(() => n.contentFocus.subscribe(() => {
1432
+ t(n.contentFocus.state);
1433
+ }), [n]), {
1434
+ ...s,
1435
+ focus: (e, i, r, a) => n.contentFocus.focus(e, i, r, a),
1436
+ blur: () => n.contentFocus.blur(),
1437
+ toggle: (e, i, r, a) => n.contentFocus.toggle(e, i, r, a),
1438
+ switchContext: (e) => n.contentFocus.switchContext(e),
1439
+ focusNext: () => n.contentFocus.focusNext(n.thread.messages),
1440
+ focusPrevious: () => n.contentFocus.focusPrevious(n.thread.messages)
1247
1441
  };
1248
1442
  }
1249
- function dt(a) {
1250
- const n = f();
1251
- w(() => {
1252
- const t = a.priority ?? 0;
1253
- return a.execute && n.capabilityRegistry.registerHandler(a.name, { execute: a.execute }, t), a.render && n.capabilityRegistry.registerRenderer(
1254
- a.name,
1443
+ function lt(n) {
1444
+ const s = f();
1445
+ m(() => {
1446
+ const t = n.priority ?? 0;
1447
+ return n.execute && s.capabilityRegistry.registerHandler(n.name, { execute: n.execute }, t), n.render && s.capabilityRegistry.registerRenderer(
1448
+ n.name,
1255
1449
  {
1256
- component: a.render
1450
+ component: n.render
1257
1451
  },
1258
1452
  t
1259
1453
  ), () => {
1260
- n.capabilityRegistry.unregister(a.name);
1454
+ s.capabilityRegistry.unregister(n.name);
1261
1455
  };
1262
- }, [a.name, n]);
1456
+ }, [n.name, s]);
1263
1457
  }
1264
- function lt(a) {
1265
- const n = f(), [t, e] = b(
1266
- () => n.capabilityExecutionManager.getExecution(a)
1267
- ), [, s] = z((r) => r + 1, 0);
1268
- return w(() => {
1269
- const r = n.capabilityExecutionManager.getExecution(a);
1270
- return e(r), n.capabilityExecutionManager.subscribe((o) => {
1271
- if (o === a) {
1272
- const c = n.capabilityExecutionManager.getExecution(a);
1273
- e(c), s();
1458
+ function pt(n) {
1459
+ const s = f(), [t, e] = y(
1460
+ () => s.capabilityExecutionManager.getExecution(n)
1461
+ ), [, i] = V((r) => r + 1, 0);
1462
+ return m(() => {
1463
+ const r = s.capabilityExecutionManager.getExecution(n);
1464
+ return e(r), s.capabilityExecutionManager.subscribe((o) => {
1465
+ if (o === n) {
1466
+ const c = s.capabilityExecutionManager.getExecution(n);
1467
+ e(c), i();
1274
1468
  }
1275
1469
  });
1276
- }, [a, n]), t;
1470
+ }, [n, s]), t;
1277
1471
  }
1278
- const Q = B(void 0);
1279
- function It({ children: a }) {
1280
- const [n, t] = b({}), e = C((c, d) => {
1472
+ const $ = U(void 0);
1473
+ function vt({ children: n }) {
1474
+ const [s, t] = y({}), e = C((c, h) => {
1281
1475
  t((l) => {
1282
- if (d === null) {
1283
- const { [c]: h, ...g } = l;
1284
- return g;
1476
+ if (h === null) {
1477
+ const { [c]: d, ...p } = l;
1478
+ return p;
1285
1479
  }
1286
1480
  return {
1287
1481
  ...l,
1288
- [c]: { id: c, ...d }
1482
+ [c]: { id: c, ...h }
1289
1483
  };
1290
1484
  });
1291
- }, []), s = C((c) => {
1292
- t((d) => {
1293
- const { [c]: l, ...h } = d;
1294
- return h;
1485
+ }, []), i = C((c) => {
1486
+ t((h) => {
1487
+ const { [c]: l, ...d } = h;
1488
+ return d;
1295
1489
  });
1296
- }, []), r = C(() => Object.values(n).reduce(
1297
- (c, d) => {
1298
- const l = Object.entries(d.data).reduce(
1299
- (h, [g, p]) => ({
1300
- ...h,
1301
- [g]: typeof p == "string" ? p : JSON.stringify(p)
1490
+ }, []), r = C(() => Object.values(s).reduce(
1491
+ (c, h) => {
1492
+ const l = Object.entries(h.data).reduce(
1493
+ (d, [p, g]) => ({
1494
+ ...d,
1495
+ [p]: typeof g == "string" ? g : JSON.stringify(g)
1302
1496
  }),
1303
1497
  {}
1304
1498
  );
1305
1499
  return { ...c, ...l };
1306
1500
  },
1307
1501
  {}
1308
- ), [n]), i = C(() => {
1502
+ ), [s]), a = C(() => {
1309
1503
  t({});
1310
- }, []), o = V(
1504
+ }, []), o = z(
1311
1505
  () => ({
1312
- contexts: n,
1506
+ contexts: s,
1313
1507
  setContext: e,
1314
- removeContext: s,
1508
+ removeContext: i,
1315
1509
  getContextData: r,
1316
- clearContexts: i
1510
+ clearContexts: a
1317
1511
  }),
1318
- [n, e, s, r, i]
1512
+ [s, e, i, r, a]
1319
1513
  );
1320
- return /* @__PURE__ */ S.jsx(Q.Provider, { value: o, children: a });
1514
+ return /* @__PURE__ */ w.jsx($.Provider, { value: o, children: n });
1321
1515
  }
1322
1516
  function gt() {
1323
- const a = q(Q);
1324
- if (!a)
1517
+ const n = B($);
1518
+ if (!n)
1325
1519
  throw new Error("useChatContext must be used within a ChatContextProvider");
1326
- return a;
1520
+ return n;
1327
1521
  }
1328
- function Tt(a) {
1329
- const { setContext: n, removeContext: t } = gt(), { id: e = "currentPage", ...s } = a;
1330
- w(() => (n(e, s), () => {
1522
+ function Tt(n) {
1523
+ const { setContext: s, removeContext: t } = gt(), { id: e = "currentPage", ...i } = n;
1524
+ m(() => (s(e, i), () => {
1331
1525
  t(e);
1332
- }), [e, s.displayName, JSON.stringify(s.data), s.priority, s.icon]);
1526
+ }), [e, i.displayName, JSON.stringify(i.data), i.priority, i.icon]);
1333
1527
  }
1334
- function pt({ message: a, content: n }) {
1335
- const t = f(), e = n, s = lt(e.capabilityId), r = t.capabilityRegistry.getRenderer(e.capabilityName);
1336
- if (!r || !s)
1528
+ function Rt(n, s = "merge") {
1529
+ const t = f();
1530
+ m(() => (t.quickActionRegistry.activateScope(n, s), () => {
1531
+ t.quickActionRegistry.deactivateScope(n);
1532
+ }), [n, s, t]);
1533
+ }
1534
+ function Mt(n, s) {
1535
+ const t = f();
1536
+ m(() => {
1537
+ const e = s || t.quickActionRegistry.getActiveScope();
1538
+ return t.quickActionRegistry.register(n, e), () => {
1539
+ t.quickActionRegistry.unregister(n.id, e);
1540
+ };
1541
+ }, [
1542
+ n.id,
1543
+ n.label,
1544
+ n.prompt,
1545
+ n.icon,
1546
+ n.description,
1547
+ n.priority,
1548
+ n.scope,
1549
+ s,
1550
+ t
1551
+ ]);
1552
+ }
1553
+ function Et(n) {
1554
+ const s = f(), [t, e] = y([]);
1555
+ return m(() => (s.quickActionRegistry.getVisible(n).then(e), s.subscribe(() => {
1556
+ s.quickActionRegistry.getVisible(n).then(e);
1557
+ })), [s, n == null ? void 0 : n.scope]), t;
1558
+ }
1559
+ function ft({ message: n, content: s }) {
1560
+ const t = f(), e = s, i = pt(e.capabilityId), r = t.capabilityRegistry.getRenderer(e.capabilityName);
1561
+ if (!r || !i)
1337
1562
  return null;
1338
- const i = r.component;
1339
- return /* @__PURE__ */ S.jsx(
1340
- i,
1563
+ const a = r.component;
1564
+ return /* @__PURE__ */ w.jsx(
1565
+ a,
1341
1566
  {
1342
- capabilityName: s.name,
1343
- capabilityId: s.id,
1344
- args: s.args,
1345
- result: s.result,
1346
- status: s.status,
1347
- message: a
1567
+ capabilityName: i.name,
1568
+ capabilityId: i.id,
1569
+ args: i.args,
1570
+ result: i.result,
1571
+ status: i.status,
1572
+ message: n
1348
1573
  }
1349
1574
  );
1350
1575
  }
1351
- function vt({ message: a, content: n }) {
1352
- const { component: t } = $(n.type);
1353
- if (n.type === "capability")
1354
- return /* @__PURE__ */ S.jsx(pt, { message: a, content: n });
1576
+ function At({ message: n, content: s }) {
1577
+ const { component: t } = Q(s.type);
1578
+ if (s.type === "capability")
1579
+ return /* @__PURE__ */ w.jsx(ft, { message: n, content: s });
1355
1580
  if (!t)
1356
1581
  return null;
1357
1582
  const e = t;
1358
- return /* @__PURE__ */ S.jsx(e, { content: n, message: a });
1583
+ return /* @__PURE__ */ w.jsx(e, { content: s, message: n });
1359
1584
  }
1360
- function Rt({
1361
- message: a,
1362
- content: n,
1585
+ function Pt({
1586
+ message: n,
1587
+ content: s,
1363
1588
  context: t,
1364
1589
  onClose: e,
1365
- onNavigate: s,
1590
+ onNavigate: i,
1366
1591
  onSwitchContext: r
1367
1592
  }) {
1368
- const { auxiliaryComponent: i } = $(n.type, t);
1369
- if (!i)
1593
+ const { auxiliaryComponent: a } = Q(s.type, t);
1594
+ if (!a)
1370
1595
  return null;
1371
- const o = i;
1372
- return /* @__PURE__ */ S.jsx(
1596
+ const o = a;
1597
+ return /* @__PURE__ */ w.jsx(
1373
1598
  o,
1374
1599
  {
1375
- content: n,
1376
- message: a,
1600
+ content: s,
1601
+ message: n,
1377
1602
  context: t,
1378
1603
  onClose: e,
1379
- onNavigate: s,
1604
+ onNavigate: i,
1380
1605
  onSwitchContext: r
1381
1606
  }
1382
1607
  );
1383
1608
  }
1384
- function Et(a) {
1385
- const n = () => (dt(a), null);
1386
- return n.displayName = `Capability(${a.name})`, n;
1609
+ function Ft(n) {
1610
+ const s = () => (lt(n), null);
1611
+ return s.displayName = `Capability(${n.name})`, s;
1387
1612
  }
1388
- class Mt {
1613
+ class kt {
1389
1614
  getAllowedEvents() {
1390
1615
  return null;
1391
1616
  }
1392
- shouldProcessEvent(n) {
1617
+ shouldProcessEvent(s) {
1393
1618
  const t = this.getAllowedEvents();
1394
- return t ? t.includes(n) : !0;
1619
+ return t ? t.includes(s) : !0;
1395
1620
  }
1396
- async *stream(n) {
1397
- const { signal: t } = n, { url: e, options: s } = this.prepareRequest(n), r = await fetch(e, { ...s, signal: t });
1621
+ async *stream(s) {
1622
+ const { signal: t } = s, { url: e, options: i } = this.prepareRequest(s), r = await fetch(e, { ...i, signal: t });
1398
1623
  if (!r.ok)
1399
1624
  throw new Error(`HTTP error! status: ${r.status}`);
1400
1625
  if (!r.body)
1401
1626
  throw new Error("Response body is null");
1402
1627
  yield* this.parseSSEStream(r.body, t);
1403
1628
  }
1404
- async *parseSSEStream(n, t) {
1405
- const e = n.getReader(), s = new TextDecoder();
1406
- let r = "", i = null;
1629
+ async *parseSSEStream(s, t) {
1630
+ const e = s.getReader(), i = new TextDecoder();
1631
+ let r = "", a = null;
1407
1632
  try {
1408
1633
  for (; ; ) {
1409
1634
  const { done: o, value: c } = await e.read();
1410
1635
  if (o || t != null && t.aborted) break;
1411
- r += s.decode(c, { stream: !0 });
1412
- const d = r.split(`
1636
+ r += i.decode(c, { stream: !0 });
1637
+ const h = r.split(`
1413
1638
  `);
1414
- r = d.pop() || "";
1415
- for (const l of d) {
1416
- const h = l.trim();
1417
- if (!h) {
1418
- i = null;
1639
+ r = h.pop() || "";
1640
+ for (const l of h) {
1641
+ const d = l.trim();
1642
+ if (!d) {
1643
+ a = null;
1419
1644
  continue;
1420
1645
  }
1421
- if (h !== ": ping") {
1422
- if (h.startsWith("event:")) {
1423
- i = h.substring(6).trim();
1646
+ if (d !== ": ping") {
1647
+ if (d.startsWith("event:")) {
1648
+ a = d.substring(6).trim();
1424
1649
  continue;
1425
1650
  }
1426
- if (h.startsWith("data:")) {
1427
- const g = h.substring(5).trim();
1428
- if (g === "eof" || h === "eof")
1651
+ if (d.startsWith("data:")) {
1652
+ const p = d.substring(5).trim();
1653
+ if (p === "eof" || d === "eof")
1429
1654
  break;
1430
1655
  try {
1431
- const p = JSON.parse(g);
1432
- if (i && this.shouldProcessEvent(i)) {
1433
- const _ = this.convertEvent({
1434
- event: i,
1435
- data: p
1656
+ const g = JSON.parse(p);
1657
+ if (a && this.shouldProcessEvent(a)) {
1658
+ const S = this.convertEvent({
1659
+ event: a,
1660
+ data: g
1436
1661
  });
1437
- _ && (yield _);
1662
+ S && (yield S);
1438
1663
  }
1439
1664
  } catch {
1440
1665
  }
1441
- i = null;
1666
+ a = null;
1442
1667
  }
1443
1668
  }
1444
1669
  }
@@ -1449,34 +1674,38 @@ class Mt {
1449
1674
  }
1450
1675
  }
1451
1676
  export {
1452
- bt as AssistantRuntime,
1453
- mt as AssistantRuntimeProvider,
1454
- Rt as AuxiliaryRenderer,
1455
- Mt as BaseSSEStreamAdapter,
1677
+ yt as AssistantRuntime,
1678
+ _t as AssistantRuntimeProvider,
1679
+ Pt as AuxiliaryRenderer,
1680
+ kt as BaseSSEStreamAdapter,
1456
1681
  K as CapabilityExecutionManager,
1457
1682
  Y as CapabilityRegistry,
1458
- pt as CapabilityRendererComp,
1459
- It as ChatContextProvider,
1460
- et as ComposerRuntime,
1461
- vt as ContentRenderer,
1683
+ ft as CapabilityRendererComp,
1684
+ vt as ChatContextProvider,
1685
+ st as ComposerRuntime,
1686
+ At as ContentRenderer,
1462
1687
  G as PluginRegistry,
1463
- v as ThreadListItemRuntime,
1464
- st as ThreadListRuntime,
1688
+ X as QuickActionRegistry,
1689
+ T as ThreadListItemRuntime,
1690
+ it as ThreadListRuntime,
1465
1691
  R as ThreadRuntime,
1466
- E as ThreadRuntimeCore,
1467
- T as generateMessageId,
1468
- Et as makeCapability,
1692
+ M as ThreadRuntimeCore,
1693
+ v as generateMessageId,
1694
+ Ft as makeCapability,
1469
1695
  f as useAssistantRuntime,
1470
- dt as useCapability,
1471
- lt as useCapabilityExecution,
1696
+ lt as useCapability,
1697
+ pt as useCapabilityExecution,
1472
1698
  gt as useChatContext,
1473
- wt as useComposer,
1474
- Ct as useContentFocus,
1475
- $ as useContentRenderer,
1476
- ot as useCurrentThread,
1477
- St as useMessages,
1699
+ Ct as useComposer,
1700
+ It as useContentFocus,
1701
+ Q as useContentRenderer,
1702
+ ct as useCurrentThread,
1703
+ wt as useMessages,
1478
1704
  Tt as usePageContext,
1479
- _t as useThreadList,
1705
+ Mt as useQuickAction,
1706
+ Rt as useQuickActionScope,
1707
+ Et as useQuickActions,
1708
+ St as useThreadList,
1480
1709
  xt as useThreadListState
1481
1710
  };
1482
1711
  //# sourceMappingURL=index.js.map