@harnessio/ai-chat-core 0.0.15 → 0.0.17
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 +443 -371
- package/dist/index.js.map +1 -1
- package/dist/runtime/ThreadRuntime/ThreadRuntime.d.ts +7 -0
- package/dist/runtime/ThreadRuntime/ThreadRuntimeCore.d.ts +9 -1
- package/dist/types/adapters.d.ts +13 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/thread.d.ts +1 -0
- package/dist/utils/BaseSSEStreamAdapter.d.ts +3 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var u = (i,
|
|
4
|
-
import
|
|
1
|
+
var H = Object.defineProperty;
|
|
2
|
+
var J = (i, n, t) => n in i ? H(i, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[n] = t;
|
|
3
|
+
var u = (i, n, t) => J(i, 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";
|
|
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(
|
|
11
|
-
this.plugins.has(
|
|
10
|
+
registerPlugin(n) {
|
|
11
|
+
this.plugins.has(n.id), this.plugins.set(n.id, n), n.renderers.forEach((t) => {
|
|
12
12
|
const e = this.renderersByType.get(t.type) || [];
|
|
13
|
-
e.push(t), e.sort((
|
|
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);
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
-
unregisterPlugin(
|
|
17
|
-
const t = this.plugins.get(
|
|
16
|
+
unregisterPlugin(n) {
|
|
17
|
+
const t = this.plugins.get(n);
|
|
18
18
|
return t ? (t.renderers.forEach((e) => {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
}), this.plugins.delete(
|
|
19
|
+
const r = (this.renderersByType.get(e.type) || []).filter((a) => !t.renderers.includes(a));
|
|
20
|
+
r.length === 0 ? this.renderersByType.delete(e.type) : this.renderersByType.set(e.type, r);
|
|
21
|
+
}), this.plugins.delete(n)) : !1;
|
|
22
22
|
}
|
|
23
|
-
getPlugin(
|
|
24
|
-
return this.plugins.get(
|
|
23
|
+
getPlugin(n) {
|
|
24
|
+
return this.plugins.get(n);
|
|
25
25
|
}
|
|
26
26
|
getAllPlugins() {
|
|
27
27
|
return Array.from(this.plugins.values());
|
|
28
28
|
}
|
|
29
|
-
getRenderersByType(
|
|
30
|
-
return this.renderersByType.get(
|
|
29
|
+
getRenderersByType(n) {
|
|
30
|
+
return this.renderersByType.get(n) || [];
|
|
31
31
|
}
|
|
32
|
-
getBestRendererForType(
|
|
33
|
-
return this.getRenderersByType(
|
|
32
|
+
getBestRendererForType(n) {
|
|
33
|
+
return this.getRenderersByType(n)[0];
|
|
34
34
|
}
|
|
35
35
|
clear() {
|
|
36
36
|
this.plugins.clear(), this.renderersByType.clear();
|
|
@@ -41,29 +41,29 @@ class Y {
|
|
|
41
41
|
u(this, "handlers", /* @__PURE__ */ new Map());
|
|
42
42
|
u(this, "renderers", /* @__PURE__ */ new Map());
|
|
43
43
|
}
|
|
44
|
-
registerHandler(
|
|
45
|
-
this.handlers.set(
|
|
44
|
+
registerHandler(n, t) {
|
|
45
|
+
this.handlers.set(n, t);
|
|
46
46
|
}
|
|
47
|
-
registerRenderer(
|
|
48
|
-
this.renderers.set(
|
|
47
|
+
registerRenderer(n, t) {
|
|
48
|
+
this.renderers.set(n, t);
|
|
49
49
|
}
|
|
50
|
-
unregister(
|
|
51
|
-
this.handlers.delete(
|
|
50
|
+
unregister(n) {
|
|
51
|
+
this.handlers.delete(n), this.renderers.delete(n);
|
|
52
52
|
}
|
|
53
|
-
getHandler(
|
|
54
|
-
return this.handlers.get(
|
|
53
|
+
getHandler(n) {
|
|
54
|
+
return this.handlers.get(n);
|
|
55
55
|
}
|
|
56
|
-
getRenderer(
|
|
57
|
-
return this.renderers.get(
|
|
56
|
+
getRenderer(n) {
|
|
57
|
+
return this.renderers.get(n);
|
|
58
58
|
}
|
|
59
59
|
getStrategy() {
|
|
60
60
|
return "queue";
|
|
61
61
|
}
|
|
62
|
-
hasHandler(
|
|
63
|
-
return this.handlers.has(
|
|
62
|
+
hasHandler(n) {
|
|
63
|
+
return this.handlers.has(n);
|
|
64
64
|
}
|
|
65
|
-
hasRenderer(
|
|
66
|
-
return this.renderers.has(
|
|
65
|
+
hasRenderer(n) {
|
|
66
|
+
return this.renderers.has(n);
|
|
67
67
|
}
|
|
68
68
|
clear() {
|
|
69
69
|
this.handlers.clear(), this.renderers.clear();
|
|
@@ -73,29 +73,29 @@ class Y {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
class K {
|
|
76
|
-
constructor(
|
|
76
|
+
constructor(n) {
|
|
77
77
|
u(this, "executions", /* @__PURE__ */ new Map());
|
|
78
78
|
u(this, "executionQueue", []);
|
|
79
79
|
u(this, "isProcessing", !1);
|
|
80
80
|
u(this, "runningByName", /* @__PURE__ */ new Map());
|
|
81
81
|
u(this, "subscribers", /* @__PURE__ */ new Set());
|
|
82
82
|
u(this, "getHandler");
|
|
83
|
-
this.getHandler =
|
|
83
|
+
this.getHandler = n;
|
|
84
84
|
}
|
|
85
|
-
async executeCapability(
|
|
86
|
-
if (!this.getHandler(
|
|
87
|
-
console.warn(`No handler registered for capability: ${
|
|
85
|
+
async executeCapability(n, t, e, s, r = "queue") {
|
|
86
|
+
if (!this.getHandler(n)) {
|
|
87
|
+
console.warn(`No handler registered for capability: ${n}`);
|
|
88
88
|
return;
|
|
89
89
|
}
|
|
90
90
|
const o = {
|
|
91
91
|
id: t,
|
|
92
|
-
name:
|
|
92
|
+
name: n,
|
|
93
93
|
args: e,
|
|
94
94
|
status: { type: "queued" },
|
|
95
95
|
timestamp: Date.now(),
|
|
96
|
-
messageId:
|
|
96
|
+
messageId: s
|
|
97
97
|
};
|
|
98
|
-
switch (this.executions.set(t, o), this.notifySubscribers(t),
|
|
98
|
+
switch (this.executions.set(t, o), this.notifySubscribers(t), r) {
|
|
99
99
|
case "queue":
|
|
100
100
|
default:
|
|
101
101
|
this.executionQueue.push(t);
|
|
@@ -106,64 +106,64 @@ class K {
|
|
|
106
106
|
async processQueue() {
|
|
107
107
|
if (!(this.isProcessing || this.executionQueue.length === 0)) {
|
|
108
108
|
for (this.isProcessing = !0; this.executionQueue.length > 0; ) {
|
|
109
|
-
const
|
|
109
|
+
const n = this.executionQueue.shift(), t = this.executions.get(n);
|
|
110
110
|
if (!t) continue;
|
|
111
111
|
const e = this.getHandler(t.name);
|
|
112
112
|
if (!e) continue;
|
|
113
|
-
t.status = { type: "running" }, this.notifySubscribers(
|
|
114
|
-
const
|
|
115
|
-
|
|
113
|
+
t.status = { type: "running" }, this.notifySubscribers(n);
|
|
114
|
+
const s = this.runningByName.get(t.name) || [];
|
|
115
|
+
s.push(n), this.runningByName.set(t.name, s);
|
|
116
116
|
try {
|
|
117
|
-
const
|
|
117
|
+
const r = await e.execute(t.args, {
|
|
118
118
|
messageId: t.messageId,
|
|
119
|
-
capabilityId:
|
|
119
|
+
capabilityId: n
|
|
120
120
|
});
|
|
121
|
-
t.status = { type: "complete", result:
|
|
122
|
-
} catch (
|
|
123
|
-
const a =
|
|
121
|
+
t.status = { type: "complete", result: r }, t.result = r;
|
|
122
|
+
} catch (r) {
|
|
123
|
+
const a = r instanceof Error ? r.message : "Unknown error";
|
|
124
124
|
t.status = { type: "error", error: a }, t.error = a;
|
|
125
125
|
} finally {
|
|
126
|
-
const
|
|
127
|
-
a > -1 &&
|
|
126
|
+
const r = this.runningByName.get(t.name) || [], a = r.indexOf(n);
|
|
127
|
+
a > -1 && r.splice(a, 1), r.length === 0 ? this.runningByName.delete(t.name) : this.runningByName.set(t.name, r), this.notifySubscribers(n);
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
this.isProcessing = !1;
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
getExecution(
|
|
134
|
-
return this.executions.get(
|
|
133
|
+
getExecution(n) {
|
|
134
|
+
return this.executions.get(n);
|
|
135
135
|
}
|
|
136
|
-
getExecutionsByMessage(
|
|
137
|
-
return Array.from(this.executions.values()).filter((t) => t.messageId ===
|
|
136
|
+
getExecutionsByMessage(n) {
|
|
137
|
+
return Array.from(this.executions.values()).filter((t) => t.messageId === n);
|
|
138
138
|
}
|
|
139
|
-
subscribe(
|
|
140
|
-
return this.subscribers.add(
|
|
139
|
+
subscribe(n) {
|
|
140
|
+
return this.subscribers.add(n), () => this.subscribers.delete(n);
|
|
141
141
|
}
|
|
142
|
-
notifySubscribers(
|
|
143
|
-
this.subscribers.forEach((t) => t(
|
|
142
|
+
notifySubscribers(n) {
|
|
143
|
+
this.subscribers.forEach((t) => t(n));
|
|
144
144
|
}
|
|
145
145
|
clear() {
|
|
146
146
|
this.executions.clear(), this.executionQueue = [], this.runningByName.clear();
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
|
-
class
|
|
149
|
+
class m {
|
|
150
150
|
constructor() {
|
|
151
151
|
u(this, "_subscriptions", /* @__PURE__ */ new Set());
|
|
152
152
|
}
|
|
153
|
-
subscribe(
|
|
154
|
-
return this._subscriptions.add(
|
|
155
|
-
this._subscriptions.delete(
|
|
153
|
+
subscribe(n) {
|
|
154
|
+
return this._subscriptions.add(n), () => {
|
|
155
|
+
this._subscriptions.delete(n);
|
|
156
156
|
};
|
|
157
157
|
}
|
|
158
158
|
notifySubscribers() {
|
|
159
|
-
for (const
|
|
160
|
-
|
|
159
|
+
for (const n of this._subscriptions)
|
|
160
|
+
n();
|
|
161
161
|
}
|
|
162
162
|
getSubscriberCount() {
|
|
163
163
|
return this._subscriptions.size;
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
-
class X extends
|
|
166
|
+
class X extends m {
|
|
167
167
|
constructor() {
|
|
168
168
|
super(...arguments);
|
|
169
169
|
u(this, "_state", {
|
|
@@ -196,14 +196,14 @@ class X extends y {
|
|
|
196
196
|
get focusedContentIndex() {
|
|
197
197
|
return this._state.focusedContentIndex;
|
|
198
198
|
}
|
|
199
|
-
focus(t, e,
|
|
199
|
+
focus(t, e, s, r = "detail") {
|
|
200
200
|
this._state = {
|
|
201
201
|
isActive: !0,
|
|
202
|
-
context:
|
|
202
|
+
context: r,
|
|
203
203
|
focusedContent: t,
|
|
204
204
|
focusedMessage: e,
|
|
205
205
|
focusedMessageId: e.id,
|
|
206
|
-
focusedContentIndex:
|
|
206
|
+
focusedContentIndex: s
|
|
207
207
|
}, this.notifySubscribers();
|
|
208
208
|
}
|
|
209
209
|
blur() {
|
|
@@ -216,8 +216,8 @@ class X extends y {
|
|
|
216
216
|
focusedContentIndex: null
|
|
217
217
|
}, this.notifySubscribers();
|
|
218
218
|
}
|
|
219
|
-
toggle(t, e,
|
|
220
|
-
this._state.isActive && this._state.focusedMessageId === e.id && this._state.focusedContentIndex ===
|
|
219
|
+
toggle(t, e, s, r = "detail") {
|
|
220
|
+
this._state.isActive && this._state.focusedMessageId === e.id && this._state.focusedContentIndex === s && this._state.context === r ? this.blur() : this.focus(t, e, s, r);
|
|
221
221
|
}
|
|
222
222
|
switchContext(t) {
|
|
223
223
|
this._state.isActive && this._state.focusedContent && (this._state = {
|
|
@@ -229,10 +229,10 @@ class X extends y {
|
|
|
229
229
|
if (!this._state.focusedMessageId || !t.length) return;
|
|
230
230
|
const e = t.findIndex((a) => a.id === this._state.focusedMessageId);
|
|
231
231
|
if (e === -1) return;
|
|
232
|
-
const
|
|
233
|
-
if (
|
|
234
|
-
const a =
|
|
235
|
-
this.focus(a,
|
|
232
|
+
const s = t[e], r = this._state.focusedContentIndex ?? 0;
|
|
233
|
+
if (r + 1 < s.content.length) {
|
|
234
|
+
const a = s.content[r + 1];
|
|
235
|
+
this.focus(a, s, r + 1, this._state.context || "detail");
|
|
236
236
|
return;
|
|
237
237
|
}
|
|
238
238
|
if (e + 1 < t.length) {
|
|
@@ -244,10 +244,10 @@ class X extends y {
|
|
|
244
244
|
if (!this._state.focusedMessageId || !t.length) return;
|
|
245
245
|
const e = t.findIndex((a) => a.id === this._state.focusedMessageId);
|
|
246
246
|
if (e === -1) return;
|
|
247
|
-
const
|
|
248
|
-
if (
|
|
249
|
-
const a =
|
|
250
|
-
this.focus(a,
|
|
247
|
+
const s = t[e], r = this._state.focusedContentIndex ?? 0;
|
|
248
|
+
if (r > 0) {
|
|
249
|
+
const a = s.content[r - 1];
|
|
250
|
+
this.focus(a, s, r - 1, this._state.context || "detail");
|
|
251
251
|
return;
|
|
252
252
|
}
|
|
253
253
|
if (e > 0) {
|
|
@@ -260,13 +260,13 @@ class X extends y {
|
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
262
|
let Z = 0, tt = 0;
|
|
263
|
-
function
|
|
263
|
+
function I() {
|
|
264
264
|
return `msg-${Date.now()}-${++Z}`;
|
|
265
265
|
}
|
|
266
|
-
function
|
|
266
|
+
function N() {
|
|
267
267
|
return `thread-${Date.now()}-${++tt}`;
|
|
268
268
|
}
|
|
269
|
-
class
|
|
269
|
+
class v extends m {
|
|
270
270
|
constructor(t) {
|
|
271
271
|
super();
|
|
272
272
|
u(this, "_state");
|
|
@@ -294,7 +294,7 @@ class I extends y {
|
|
|
294
294
|
return super.subscribe(t);
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
|
-
class et extends
|
|
297
|
+
class et extends m {
|
|
298
298
|
constructor() {
|
|
299
299
|
super(...arguments);
|
|
300
300
|
u(this, "_text", "");
|
|
@@ -322,7 +322,7 @@ class et extends y {
|
|
|
322
322
|
this._isSubmitting = t, this.notifySubscribers();
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
|
-
class
|
|
325
|
+
class R extends m {
|
|
326
326
|
constructor(t) {
|
|
327
327
|
super();
|
|
328
328
|
u(this, "composer");
|
|
@@ -339,6 +339,12 @@ class v extends y {
|
|
|
339
339
|
get isDisabled() {
|
|
340
340
|
return this._core.isDisabled;
|
|
341
341
|
}
|
|
342
|
+
get isWaitingForUser() {
|
|
343
|
+
return this._core.isWaitingForUser;
|
|
344
|
+
}
|
|
345
|
+
get pendingCapability() {
|
|
346
|
+
return this._core.pendingCapability;
|
|
347
|
+
}
|
|
342
348
|
get capabilities() {
|
|
343
349
|
return this._core.capabilities;
|
|
344
350
|
}
|
|
@@ -354,6 +360,7 @@ class v extends y {
|
|
|
354
360
|
// Will be set by ThreadListRuntime
|
|
355
361
|
isDisabled: this._core.isDisabled,
|
|
356
362
|
isRunning: this._core.isRunning,
|
|
363
|
+
isWaitingForUser: this._core.isWaitingForUser,
|
|
357
364
|
capabilities: this._core.capabilities,
|
|
358
365
|
conversationId: this._core.conversationId,
|
|
359
366
|
title: this._core.title
|
|
@@ -366,7 +373,11 @@ class v extends y {
|
|
|
366
373
|
if (t.trim()) {
|
|
367
374
|
this.composer.setSubmitting(!0);
|
|
368
375
|
try {
|
|
369
|
-
this.
|
|
376
|
+
this._core.isWaitingForUser && this._core.pendingCapability && await this._core.startSystemEventRun({
|
|
377
|
+
event_type: "action_cancelled",
|
|
378
|
+
capability_id: this._core.pendingCapability.capabilityName,
|
|
379
|
+
result: { success: !1 }
|
|
380
|
+
}), this.composer.clear(), await this._core.startRun({
|
|
370
381
|
role: "user",
|
|
371
382
|
content: [{ type: "text", data: t }]
|
|
372
383
|
});
|
|
@@ -376,6 +387,12 @@ class v extends y {
|
|
|
376
387
|
}
|
|
377
388
|
}
|
|
378
389
|
}
|
|
390
|
+
async sendSystemEvent(t) {
|
|
391
|
+
try {
|
|
392
|
+
await this._core.startSystemEventRun(t);
|
|
393
|
+
} catch {
|
|
394
|
+
}
|
|
395
|
+
}
|
|
379
396
|
cancelRun() {
|
|
380
397
|
this._core.cancelRun();
|
|
381
398
|
}
|
|
@@ -395,12 +412,14 @@ class v extends y {
|
|
|
395
412
|
return super.subscribe(t);
|
|
396
413
|
}
|
|
397
414
|
}
|
|
398
|
-
class
|
|
415
|
+
class E extends m {
|
|
399
416
|
constructor(t) {
|
|
400
417
|
super();
|
|
401
418
|
u(this, "_messages", []);
|
|
402
419
|
u(this, "_isRunning", !1);
|
|
403
420
|
u(this, "_isDisabled", !1);
|
|
421
|
+
u(this, "_isWaitingForUser", !1);
|
|
422
|
+
u(this, "_pendingCapability", null);
|
|
404
423
|
u(this, "_abortController", null);
|
|
405
424
|
u(this, "_conversationId");
|
|
406
425
|
u(this, "_title");
|
|
@@ -417,6 +436,12 @@ class R extends y {
|
|
|
417
436
|
get isDisabled() {
|
|
418
437
|
return this._isDisabled;
|
|
419
438
|
}
|
|
439
|
+
get isWaitingForUser() {
|
|
440
|
+
return this._isWaitingForUser;
|
|
441
|
+
}
|
|
442
|
+
get pendingCapability() {
|
|
443
|
+
return this._pendingCapability;
|
|
444
|
+
}
|
|
420
445
|
get conversationId() {
|
|
421
446
|
return this._conversationId;
|
|
422
447
|
}
|
|
@@ -434,12 +459,12 @@ class R extends y {
|
|
|
434
459
|
};
|
|
435
460
|
}
|
|
436
461
|
updateMessages(t) {
|
|
437
|
-
var e,
|
|
438
|
-
this._messages = t, (
|
|
462
|
+
var e, s;
|
|
463
|
+
this._messages = t, (s = (e = this.config).onMessagesChange) == null || s.call(e, this._messages), this.notifySubscribers();
|
|
439
464
|
}
|
|
440
465
|
append(t) {
|
|
441
466
|
const e = {
|
|
442
|
-
id: t.id ||
|
|
467
|
+
id: t.id || I(),
|
|
443
468
|
parentId: t.parentId,
|
|
444
469
|
role: t.role,
|
|
445
470
|
content: t.content,
|
|
@@ -449,35 +474,74 @@ class R extends y {
|
|
|
449
474
|
};
|
|
450
475
|
this.updateMessages([...this._messages, e]);
|
|
451
476
|
}
|
|
477
|
+
async startSystemEventRun(t) {
|
|
478
|
+
if (this._isRunning)
|
|
479
|
+
throw new Error("A run is already in progress");
|
|
480
|
+
this._isWaitingForUser = !1, this._pendingCapability = null, this._isRunning = !0, this._abortController = new AbortController(), this._currentPart = null;
|
|
481
|
+
const e = I(), s = {
|
|
482
|
+
id: e,
|
|
483
|
+
role: "assistant",
|
|
484
|
+
content: [],
|
|
485
|
+
status: { type: "running" },
|
|
486
|
+
timestamp: Date.now()
|
|
487
|
+
};
|
|
488
|
+
this.updateMessages([...this._messages, s]);
|
|
489
|
+
try {
|
|
490
|
+
const r = this.config.streamAdapter.stream({
|
|
491
|
+
messages: this._messages,
|
|
492
|
+
conversationId: this._conversationId,
|
|
493
|
+
signal: this._abortController.signal,
|
|
494
|
+
systemEvent: t
|
|
495
|
+
});
|
|
496
|
+
for await (const a of r) {
|
|
497
|
+
if (this._abortController.signal.aborted)
|
|
498
|
+
break;
|
|
499
|
+
this.handleStreamEvent(e, a.event);
|
|
500
|
+
}
|
|
501
|
+
this.updateMessageStatus(e, { type: "complete" });
|
|
502
|
+
} catch (r) {
|
|
503
|
+
if (r instanceof Error && r.name === "AbortError")
|
|
504
|
+
this.completeStreamingContent(e), this.updateMessageStatus(e, { type: "cancelled" });
|
|
505
|
+
else {
|
|
506
|
+
const a = r instanceof Error ? r.message : "Unknown error";
|
|
507
|
+
this.completeStreamingContent(e), this.updateMessageStatus(e, {
|
|
508
|
+
type: "error",
|
|
509
|
+
error: a
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
} finally {
|
|
513
|
+
this._isRunning = !1, this._abortController = null, this._currentPart = null, this.notifySubscribers();
|
|
514
|
+
}
|
|
515
|
+
}
|
|
452
516
|
async startRun(t) {
|
|
453
517
|
if (this._isRunning)
|
|
454
518
|
throw new Error("A run is already in progress");
|
|
455
|
-
this.append(t), this._isRunning = !0, this._abortController = new AbortController(), this._currentPart = null;
|
|
456
|
-
const e =
|
|
519
|
+
this._isWaitingForUser = !1, this._pendingCapability = null, this.append(t), this._isRunning = !0, this._abortController = new AbortController(), this._currentPart = null;
|
|
520
|
+
const e = I(), s = {
|
|
457
521
|
id: e,
|
|
458
522
|
role: "assistant",
|
|
459
523
|
content: [],
|
|
460
524
|
status: { type: "running" },
|
|
461
525
|
timestamp: Date.now()
|
|
462
526
|
};
|
|
463
|
-
this.updateMessages([...this._messages,
|
|
527
|
+
this.updateMessages([...this._messages, s]);
|
|
464
528
|
try {
|
|
465
|
-
const
|
|
529
|
+
const r = this.config.streamAdapter.stream({
|
|
466
530
|
messages: this._messages,
|
|
467
531
|
conversationId: this._conversationId,
|
|
468
532
|
signal: this._abortController.signal
|
|
469
533
|
});
|
|
470
|
-
for await (const a of
|
|
534
|
+
for await (const a of r) {
|
|
471
535
|
if (this._abortController.signal.aborted)
|
|
472
536
|
break;
|
|
473
537
|
this.handleStreamEvent(e, a.event);
|
|
474
538
|
}
|
|
475
539
|
this.updateMessageStatus(e, { type: "complete" });
|
|
476
|
-
} catch (
|
|
477
|
-
if (
|
|
540
|
+
} catch (r) {
|
|
541
|
+
if (r instanceof Error && r.name === "AbortError")
|
|
478
542
|
this.completeStreamingContent(e), this.updateMessageStatus(e, { type: "cancelled" });
|
|
479
543
|
else {
|
|
480
|
-
const a =
|
|
544
|
+
const a = r instanceof Error ? r.message : "Unknown error";
|
|
481
545
|
this.completeStreamingContent(e), this.updateMessageStatus(e, {
|
|
482
546
|
type: "error",
|
|
483
547
|
error: a
|
|
@@ -488,19 +552,19 @@ class R extends y {
|
|
|
488
552
|
}
|
|
489
553
|
}
|
|
490
554
|
handleStreamEvent(t, e) {
|
|
491
|
-
const
|
|
492
|
-
if (
|
|
493
|
-
const
|
|
555
|
+
const s = this._messages.findIndex((o) => o.id === t);
|
|
556
|
+
if (s === -1) return;
|
|
557
|
+
const r = this._messages[s];
|
|
494
558
|
if (e.type === "part-start")
|
|
495
|
-
this.handlePartStart(
|
|
559
|
+
this.handlePartStart(r, e);
|
|
496
560
|
else if (e.type === "text-delta" || e.type === "assistant_thought")
|
|
497
|
-
this.handleTextDelta(
|
|
561
|
+
this.handleTextDelta(r, e);
|
|
498
562
|
else if (e.type === "part-finish")
|
|
499
563
|
this.handlePartFinish();
|
|
500
564
|
else if (e.type === "metadata") {
|
|
501
565
|
const o = e;
|
|
502
|
-
|
|
503
|
-
...
|
|
566
|
+
r.metadata = {
|
|
567
|
+
...r.metadata,
|
|
504
568
|
conversationId: o.conversationId,
|
|
505
569
|
interactionId: o.interactionId
|
|
506
570
|
}, o.conversationId && !this._conversationId && (this._conversationId = o.conversationId), o.title && !this._title && (this._title = o.title);
|
|
@@ -511,9 +575,9 @@ class R extends y {
|
|
|
511
575
|
capabilityName: o.capabilityName,
|
|
512
576
|
args: o.args
|
|
513
577
|
};
|
|
514
|
-
|
|
578
|
+
r.content.push(c);
|
|
515
579
|
const d = o.artifact;
|
|
516
|
-
d &&
|
|
580
|
+
d && r.content.push({
|
|
517
581
|
type: "artifact",
|
|
518
582
|
data: {
|
|
519
583
|
capabilityName: o.capabilityName,
|
|
@@ -529,11 +593,14 @@ class R extends y {
|
|
|
529
593
|
o.args,
|
|
530
594
|
t,
|
|
531
595
|
o.strategy
|
|
532
|
-
)
|
|
596
|
+
), o.status === "waiting_for_user" && (this._isWaitingForUser = !0, this._pendingCapability = {
|
|
597
|
+
capabilityId: o.capabilityId,
|
|
598
|
+
capabilityName: o.capabilityName
|
|
599
|
+
});
|
|
533
600
|
} else if (e.type === "error") {
|
|
534
601
|
const o = e;
|
|
535
|
-
|
|
536
|
-
...
|
|
602
|
+
r.content = [
|
|
603
|
+
...r.content,
|
|
537
604
|
{
|
|
538
605
|
type: "error",
|
|
539
606
|
data: o.error
|
|
@@ -541,8 +608,8 @@ class R extends y {
|
|
|
541
608
|
];
|
|
542
609
|
} else {
|
|
543
610
|
const o = e;
|
|
544
|
-
|
|
545
|
-
...
|
|
611
|
+
r.content = [
|
|
612
|
+
...r.content,
|
|
546
613
|
{
|
|
547
614
|
type: o.type,
|
|
548
615
|
data: o.data,
|
|
@@ -551,18 +618,18 @@ class R extends y {
|
|
|
551
618
|
];
|
|
552
619
|
}
|
|
553
620
|
const a = [
|
|
554
|
-
...this._messages.slice(0,
|
|
555
|
-
{ ...
|
|
556
|
-
...this._messages.slice(
|
|
621
|
+
...this._messages.slice(0, s),
|
|
622
|
+
{ ...r, timestamp: Date.now() },
|
|
623
|
+
...this._messages.slice(s + 1)
|
|
557
624
|
];
|
|
558
625
|
this.updateMessages(a);
|
|
559
626
|
}
|
|
560
627
|
handlePartStart(t, e) {
|
|
561
|
-
const
|
|
562
|
-
let
|
|
628
|
+
const s = t.content.length;
|
|
629
|
+
let r;
|
|
563
630
|
switch (e.part.type) {
|
|
564
631
|
case "assistant_thought":
|
|
565
|
-
|
|
632
|
+
r = {
|
|
566
633
|
type: e.part.type,
|
|
567
634
|
data: [],
|
|
568
635
|
parentId: e.part.parentId,
|
|
@@ -570,7 +637,7 @@ class R extends y {
|
|
|
570
637
|
};
|
|
571
638
|
break;
|
|
572
639
|
case "text":
|
|
573
|
-
|
|
640
|
+
r = {
|
|
574
641
|
type: e.part.type,
|
|
575
642
|
data: "",
|
|
576
643
|
parentId: e.part.parentId,
|
|
@@ -578,15 +645,15 @@ class R extends y {
|
|
|
578
645
|
};
|
|
579
646
|
break;
|
|
580
647
|
default:
|
|
581
|
-
|
|
648
|
+
r = {
|
|
582
649
|
type: e.part.type,
|
|
583
650
|
parentId: e.part.parentId,
|
|
584
651
|
status: { type: "streaming" }
|
|
585
652
|
};
|
|
586
653
|
}
|
|
587
|
-
t.content = [...t.content,
|
|
654
|
+
t.content = [...t.content, r], this._currentPart = {
|
|
588
655
|
messageId: t.id,
|
|
589
|
-
contentIndex:
|
|
656
|
+
contentIndex: s,
|
|
590
657
|
type: e.part.type,
|
|
591
658
|
parentId: e.part.parentId
|
|
592
659
|
};
|
|
@@ -596,8 +663,8 @@ class R extends y {
|
|
|
596
663
|
console.warn("Received text-delta without part-start");
|
|
597
664
|
return;
|
|
598
665
|
}
|
|
599
|
-
const
|
|
600
|
-
|
|
666
|
+
const s = t.content[this._currentPart.contentIndex];
|
|
667
|
+
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;
|
|
601
668
|
}
|
|
602
669
|
handlePartFinish() {
|
|
603
670
|
if (!this._currentPart) {
|
|
@@ -606,46 +673,46 @@ class R extends y {
|
|
|
606
673
|
}
|
|
607
674
|
const t = this._messages.findIndex((e) => e.id === this._currentPart.messageId);
|
|
608
675
|
if (t !== -1) {
|
|
609
|
-
const e = this._messages[t],
|
|
610
|
-
if (
|
|
611
|
-
|
|
612
|
-
const
|
|
676
|
+
const e = this._messages[t], s = e.content[this._currentPart.contentIndex];
|
|
677
|
+
if (s) {
|
|
678
|
+
s.status = { type: "complete" };
|
|
679
|
+
const r = [
|
|
613
680
|
...this._messages.slice(0, t),
|
|
614
681
|
{ ...e, timestamp: Date.now() },
|
|
615
682
|
...this._messages.slice(t + 1)
|
|
616
683
|
];
|
|
617
|
-
this.updateMessages(
|
|
684
|
+
this.updateMessages(r);
|
|
618
685
|
}
|
|
619
686
|
}
|
|
620
687
|
this._currentPart = null;
|
|
621
688
|
}
|
|
622
689
|
updateMessageStatus(t, e) {
|
|
623
|
-
const
|
|
624
|
-
if (
|
|
625
|
-
const
|
|
626
|
-
...this._messages.slice(0,
|
|
690
|
+
const s = this._messages.findIndex((a) => a.id === t);
|
|
691
|
+
if (s === -1) return;
|
|
692
|
+
const r = [
|
|
693
|
+
...this._messages.slice(0, s),
|
|
627
694
|
{
|
|
628
|
-
...this._messages[
|
|
695
|
+
...this._messages[s],
|
|
629
696
|
status: e
|
|
630
697
|
},
|
|
631
|
-
...this._messages.slice(
|
|
698
|
+
...this._messages.slice(s + 1)
|
|
632
699
|
];
|
|
633
|
-
this.updateMessages(
|
|
700
|
+
this.updateMessages(r);
|
|
634
701
|
}
|
|
635
702
|
completeStreamingContent(t) {
|
|
636
703
|
const e = this._messages.findIndex((c) => c.id === t);
|
|
637
704
|
if (e === -1) return;
|
|
638
|
-
const
|
|
639
|
-
if (!
|
|
705
|
+
const s = this._messages[e];
|
|
706
|
+
if (!s.content.some((c) => {
|
|
640
707
|
var d;
|
|
641
708
|
return ((d = c.status) == null ? void 0 : d.type) === "streaming";
|
|
642
709
|
})) return;
|
|
643
|
-
const a =
|
|
710
|
+
const a = s.content.map((c) => {
|
|
644
711
|
var d;
|
|
645
712
|
return ((d = c.status) == null ? void 0 : d.type) === "streaming" ? { ...c, status: { type: "complete" } } : c;
|
|
646
713
|
}), o = [
|
|
647
714
|
...this._messages.slice(0, e),
|
|
648
|
-
{ ...
|
|
715
|
+
{ ...s, content: a, timestamp: Date.now() },
|
|
649
716
|
...this._messages.slice(e + 1)
|
|
650
717
|
];
|
|
651
718
|
this.updateMessages(o);
|
|
@@ -666,7 +733,7 @@ class R extends y {
|
|
|
666
733
|
this._title = t, this.notifySubscribers();
|
|
667
734
|
}
|
|
668
735
|
}
|
|
669
|
-
class st extends
|
|
736
|
+
class st extends m {
|
|
670
737
|
constructor(t) {
|
|
671
738
|
super();
|
|
672
739
|
u(this, "_mainThreadId");
|
|
@@ -677,13 +744,13 @@ class st extends y {
|
|
|
677
744
|
u(this, "_searchQuery");
|
|
678
745
|
u(this, "_abortController", null);
|
|
679
746
|
u(this, "main");
|
|
680
|
-
this.config = t, this._mainThreadId =
|
|
681
|
-
const e = new
|
|
747
|
+
this.config = t, this._mainThreadId = N();
|
|
748
|
+
const e = new E({
|
|
682
749
|
streamAdapter: t.streamAdapter,
|
|
683
750
|
capabilityExecutionManager: t.capabilityExecutionManager
|
|
684
751
|
});
|
|
685
|
-
this.main = new
|
|
686
|
-
const
|
|
752
|
+
this.main = new R(e), this._threads.set(this._mainThreadId, this.main);
|
|
753
|
+
const s = {
|
|
687
754
|
id: this._mainThreadId,
|
|
688
755
|
title: "New Chat",
|
|
689
756
|
status: { type: "regular" },
|
|
@@ -691,14 +758,14 @@ class st extends y {
|
|
|
691
758
|
createdAt: Date.now(),
|
|
692
759
|
updatedAt: Date.now()
|
|
693
760
|
};
|
|
694
|
-
this._threadStates.set(this._mainThreadId,
|
|
695
|
-
const
|
|
696
|
-
state:
|
|
761
|
+
this._threadStates.set(this._mainThreadId, s);
|
|
762
|
+
const r = new v({
|
|
763
|
+
state: s,
|
|
697
764
|
onSwitchTo: this.switchToThread.bind(this),
|
|
698
765
|
onRename: this.renameThread.bind(this),
|
|
699
766
|
onDelete: this.deleteThread.bind(this)
|
|
700
767
|
});
|
|
701
|
-
this._threadItems.set(this._mainThreadId,
|
|
768
|
+
this._threadItems.set(this._mainThreadId, r);
|
|
702
769
|
}
|
|
703
770
|
get isLoading() {
|
|
704
771
|
return this._isLoading;
|
|
@@ -712,8 +779,8 @@ class st extends y {
|
|
|
712
779
|
}
|
|
713
780
|
getState() {
|
|
714
781
|
const t = [], e = {};
|
|
715
|
-
for (const [
|
|
716
|
-
e[
|
|
782
|
+
for (const [s, r] of this._threadStates)
|
|
783
|
+
e[s] = r, r.status.type === "regular" && t.push(s);
|
|
717
784
|
return {
|
|
718
785
|
mainThreadId: this._mainThreadId,
|
|
719
786
|
threads: t,
|
|
@@ -727,10 +794,10 @@ class st extends y {
|
|
|
727
794
|
const e = this._threads.get(t);
|
|
728
795
|
if (!e)
|
|
729
796
|
throw new Error(`Thread ${t} not found`);
|
|
730
|
-
const
|
|
731
|
-
|
|
732
|
-
const
|
|
733
|
-
if (
|
|
797
|
+
const s = this._threadStates.get(this._mainThreadId);
|
|
798
|
+
s && (s.isMain = !1, this._threadStates.set(this._mainThreadId, s), (a = this._threadItems.get(this._mainThreadId)) == null || a.updateState(s)), this._mainThreadId = t;
|
|
799
|
+
const r = this._threadStates.get(t);
|
|
800
|
+
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)) {
|
|
734
801
|
this._isLoading = !0, this.notifySubscribers();
|
|
735
802
|
try {
|
|
736
803
|
const c = await this.config.threadListAdapter.loadThread(t);
|
|
@@ -744,12 +811,12 @@ class st extends y {
|
|
|
744
811
|
this.notifySubscribers();
|
|
745
812
|
}
|
|
746
813
|
async switchToNewThread() {
|
|
747
|
-
const t =
|
|
814
|
+
const t = N(), e = new E({
|
|
748
815
|
streamAdapter: this.config.streamAdapter,
|
|
749
816
|
capabilityExecutionManager: this.config.capabilityExecutionManager
|
|
750
|
-
}),
|
|
751
|
-
this._threads.set(t,
|
|
752
|
-
const
|
|
817
|
+
}), s = new R(e);
|
|
818
|
+
this._threads.set(t, s);
|
|
819
|
+
const r = {
|
|
753
820
|
id: t,
|
|
754
821
|
title: "New Chat",
|
|
755
822
|
status: { type: "regular" },
|
|
@@ -757,19 +824,19 @@ class st extends y {
|
|
|
757
824
|
createdAt: Date.now(),
|
|
758
825
|
updatedAt: Date.now()
|
|
759
826
|
};
|
|
760
|
-
this._threadStates.set(t,
|
|
761
|
-
const a = new
|
|
762
|
-
state:
|
|
827
|
+
this._threadStates.set(t, r);
|
|
828
|
+
const a = new v({
|
|
829
|
+
state: r,
|
|
763
830
|
onSwitchTo: this.switchToThread.bind(this),
|
|
764
831
|
onRename: this.renameThread.bind(this),
|
|
765
832
|
onDelete: this.deleteThread.bind(this)
|
|
766
833
|
});
|
|
767
|
-
if (this._threadItems.set(t, a),
|
|
768
|
-
this.syncThreadStateFromRuntime(t,
|
|
834
|
+
if (this._threadItems.set(t, a), s.subscribe(() => {
|
|
835
|
+
this.syncThreadStateFromRuntime(t, s), this.notifySubscribers();
|
|
769
836
|
}), this.config.threadListAdapter)
|
|
770
837
|
try {
|
|
771
838
|
const o = await this.config.threadListAdapter.createThread();
|
|
772
|
-
|
|
839
|
+
r.conversationId = o.conversationId, this._threadStates.set(t, r), a.updateState(r);
|
|
773
840
|
} catch (o) {
|
|
774
841
|
console.error("Failed to create thread:", o);
|
|
775
842
|
}
|
|
@@ -780,25 +847,30 @@ class st extends y {
|
|
|
780
847
|
return console.warn("No threadListAdapter configured"), [];
|
|
781
848
|
if (this._isLoading)
|
|
782
849
|
return [];
|
|
783
|
-
this._abortController && this._abortController.abort(), this._abortController = new AbortController(), (t == null ? void 0 : t.query) !== void 0 && (this._searchQuery = t.query),
|
|
850
|
+
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) {
|
|
851
|
+
const e = Array.from(this._threads.keys()).filter((s) => s !== this._mainThreadId);
|
|
852
|
+
for (const s of e)
|
|
853
|
+
this._threads.delete(s), this._threadItems.delete(s), this._threadStates.delete(s);
|
|
854
|
+
}
|
|
855
|
+
this._isLoading = !0, this.notifySubscribers();
|
|
784
856
|
try {
|
|
785
857
|
const e = await this.config.threadListAdapter.loadThreads(t);
|
|
786
|
-
for (const
|
|
787
|
-
if (this._threadStates.has(
|
|
858
|
+
for (const s of e) {
|
|
859
|
+
if (this._threadStates.has(s.id))
|
|
788
860
|
continue;
|
|
789
|
-
const
|
|
861
|
+
const r = new E({
|
|
790
862
|
streamAdapter: this.config.streamAdapter,
|
|
791
863
|
capabilityExecutionManager: this.config.capabilityExecutionManager
|
|
792
|
-
}), a = new
|
|
793
|
-
this._threads.set(
|
|
794
|
-
const o = new
|
|
795
|
-
state:
|
|
864
|
+
}), a = new R(r);
|
|
865
|
+
this._threads.set(s.id, a), this._threadStates.set(s.id, s);
|
|
866
|
+
const o = new v({
|
|
867
|
+
state: s,
|
|
796
868
|
onSwitchTo: this.switchToThread.bind(this),
|
|
797
869
|
onRename: this.renameThread.bind(this),
|
|
798
870
|
onDelete: this.deleteThread.bind(this)
|
|
799
871
|
});
|
|
800
|
-
this._threadItems.set(
|
|
801
|
-
this.syncThreadStateFromRuntime(
|
|
872
|
+
this._threadItems.set(s.id, o), a.subscribe(() => {
|
|
873
|
+
this.syncThreadStateFromRuntime(s.id, a), this.notifySubscribers();
|
|
802
874
|
});
|
|
803
875
|
}
|
|
804
876
|
return e;
|
|
@@ -812,15 +884,15 @@ class st extends y {
|
|
|
812
884
|
* Syncs conversationId and title from thread runtime to thread state
|
|
813
885
|
*/
|
|
814
886
|
syncThreadStateFromRuntime(t, e) {
|
|
815
|
-
var
|
|
816
|
-
const
|
|
817
|
-
|
|
887
|
+
var r;
|
|
888
|
+
const s = this._threadStates.get(t);
|
|
889
|
+
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));
|
|
818
890
|
}
|
|
819
891
|
async renameThread(t, e) {
|
|
820
|
-
var
|
|
821
|
-
const
|
|
822
|
-
if (
|
|
823
|
-
if (
|
|
892
|
+
var r;
|
|
893
|
+
const s = this._threadStates.get(t);
|
|
894
|
+
if (s) {
|
|
895
|
+
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)
|
|
824
896
|
try {
|
|
825
897
|
await this.config.threadListAdapter.updateThread(t, { title: e });
|
|
826
898
|
} catch (a) {
|
|
@@ -833,7 +905,7 @@ class st extends y {
|
|
|
833
905
|
if (t === this._mainThreadId && this._threads.size === 1)
|
|
834
906
|
throw new Error("Cannot delete the last thread");
|
|
835
907
|
if (t === this._mainThreadId) {
|
|
836
|
-
const e = Array.from(this._threads.keys()).find((
|
|
908
|
+
const e = Array.from(this._threads.keys()).find((s) => s !== t);
|
|
837
909
|
e && await this.switchToThread(e);
|
|
838
910
|
}
|
|
839
911
|
if (this._threads.delete(t), this._threadItems.delete(t), this._threadStates.delete(t), this.config.threadListAdapter)
|
|
@@ -845,7 +917,7 @@ class st extends y {
|
|
|
845
917
|
this.notifySubscribers();
|
|
846
918
|
}
|
|
847
919
|
}
|
|
848
|
-
class bt extends
|
|
920
|
+
class bt extends m {
|
|
849
921
|
constructor(t) {
|
|
850
922
|
super();
|
|
851
923
|
u(this, "threads");
|
|
@@ -906,70 +978,70 @@ class bt extends y {
|
|
|
906
978
|
autoFocusLastContent(t) {
|
|
907
979
|
var e;
|
|
908
980
|
if (t.length !== 0 && !this._contentFocusRuntime.isActive)
|
|
909
|
-
for (let
|
|
910
|
-
const
|
|
911
|
-
if (
|
|
912
|
-
for (let a =
|
|
913
|
-
const o =
|
|
981
|
+
for (let s = t.length - 1; s >= 0; s--) {
|
|
982
|
+
const r = t[s];
|
|
983
|
+
if (r.role === "assistant")
|
|
984
|
+
for (let a = r.content.length - 1; a >= 0; a--) {
|
|
985
|
+
const o = r.content[a], c = this.pluginRegistry.getRenderersByType(o.type);
|
|
914
986
|
if (c.length > 0 && ((e = c[0].capabilities) != null && e.supportsFocus)) {
|
|
915
|
-
this._contentFocusRuntime.focus(o,
|
|
987
|
+
this._contentFocusRuntime.focus(o, r, a, "detail");
|
|
916
988
|
return;
|
|
917
989
|
}
|
|
918
990
|
}
|
|
919
991
|
}
|
|
920
992
|
}
|
|
921
993
|
}
|
|
922
|
-
var
|
|
994
|
+
var M = { exports: {} }, x = {};
|
|
923
995
|
/*
|
|
924
996
|
object-assign
|
|
925
997
|
(c) Sindre Sorhus
|
|
926
998
|
@license MIT
|
|
927
999
|
*/
|
|
928
|
-
var
|
|
1000
|
+
var A, D;
|
|
929
1001
|
function rt() {
|
|
930
|
-
if (D) return
|
|
1002
|
+
if (D) return A;
|
|
931
1003
|
D = 1;
|
|
932
|
-
var i = Object.getOwnPropertySymbols,
|
|
933
|
-
function e(
|
|
934
|
-
if (
|
|
1004
|
+
var i = Object.getOwnPropertySymbols, n = Object.prototype.hasOwnProperty, t = Object.prototype.propertyIsEnumerable;
|
|
1005
|
+
function e(r) {
|
|
1006
|
+
if (r == null)
|
|
935
1007
|
throw new TypeError("Object.assign cannot be called with null or undefined");
|
|
936
|
-
return Object(
|
|
1008
|
+
return Object(r);
|
|
937
1009
|
}
|
|
938
|
-
function
|
|
1010
|
+
function s() {
|
|
939
1011
|
try {
|
|
940
1012
|
if (!Object.assign)
|
|
941
1013
|
return !1;
|
|
942
|
-
var
|
|
943
|
-
if (
|
|
1014
|
+
var r = new String("abc");
|
|
1015
|
+
if (r[5] = "de", Object.getOwnPropertyNames(r)[0] === "5")
|
|
944
1016
|
return !1;
|
|
945
1017
|
for (var a = {}, o = 0; o < 10; o++)
|
|
946
1018
|
a["_" + String.fromCharCode(o)] = o;
|
|
947
|
-
var c = Object.getOwnPropertyNames(a).map(function(
|
|
948
|
-
return a[
|
|
1019
|
+
var c = Object.getOwnPropertyNames(a).map(function(l) {
|
|
1020
|
+
return a[l];
|
|
949
1021
|
});
|
|
950
1022
|
if (c.join("") !== "0123456789")
|
|
951
1023
|
return !1;
|
|
952
1024
|
var d = {};
|
|
953
|
-
return "abcdefghijklmnopqrst".split("").forEach(function(
|
|
954
|
-
d[
|
|
1025
|
+
return "abcdefghijklmnopqrst".split("").forEach(function(l) {
|
|
1026
|
+
d[l] = l;
|
|
955
1027
|
}), Object.keys(Object.assign({}, d)).join("") === "abcdefghijklmnopqrst";
|
|
956
1028
|
} catch {
|
|
957
1029
|
return !1;
|
|
958
1030
|
}
|
|
959
1031
|
}
|
|
960
|
-
return
|
|
961
|
-
for (var o, c = e(
|
|
962
|
-
o = Object(arguments[
|
|
1032
|
+
return A = s() ? Object.assign : function(r, a) {
|
|
1033
|
+
for (var o, c = e(r), d, l = 1; l < arguments.length; l++) {
|
|
1034
|
+
o = Object(arguments[l]);
|
|
963
1035
|
for (var h in o)
|
|
964
|
-
|
|
1036
|
+
n.call(o, h) && (c[h] = o[h]);
|
|
965
1037
|
if (i) {
|
|
966
1038
|
d = i(o);
|
|
967
|
-
for (var
|
|
968
|
-
t.call(o, d[
|
|
1039
|
+
for (var g = 0; g < d.length; g++)
|
|
1040
|
+
t.call(o, d[g]) && (c[d[g]] = o[d[g]]);
|
|
969
1041
|
}
|
|
970
1042
|
}
|
|
971
1043
|
return c;
|
|
972
|
-
},
|
|
1044
|
+
}, A;
|
|
973
1045
|
}
|
|
974
1046
|
/** @license React v17.0.2
|
|
975
1047
|
* react-jsx-runtime.production.min.js
|
|
@@ -979,72 +1051,72 @@ function rt() {
|
|
|
979
1051
|
* This source code is licensed under the MIT license found in the
|
|
980
1052
|
* LICENSE file in the root directory of this source tree.
|
|
981
1053
|
*/
|
|
982
|
-
var
|
|
1054
|
+
var j;
|
|
983
1055
|
function nt() {
|
|
984
|
-
if (
|
|
985
|
-
|
|
986
|
-
var i =
|
|
1056
|
+
if (j) return x;
|
|
1057
|
+
j = 1, rt();
|
|
1058
|
+
var i = U, n = 60103;
|
|
987
1059
|
if (x.Fragment = 60107, typeof Symbol == "function" && Symbol.for) {
|
|
988
1060
|
var t = Symbol.for;
|
|
989
|
-
|
|
1061
|
+
n = t("react.element"), x.Fragment = t("react.fragment");
|
|
990
1062
|
}
|
|
991
|
-
var e = i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,
|
|
1063
|
+
var e = i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = Object.prototype.hasOwnProperty, r = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
992
1064
|
function a(o, c, d) {
|
|
993
|
-
var
|
|
994
|
-
d !== void 0 && (
|
|
995
|
-
for (
|
|
996
|
-
if (o && o.defaultProps) for (
|
|
997
|
-
return { $$typeof:
|
|
1065
|
+
var l, h = {}, g = null, p = null;
|
|
1066
|
+
d !== void 0 && (g = "" + d), c.key !== void 0 && (g = "" + c.key), c.ref !== void 0 && (p = c.ref);
|
|
1067
|
+
for (l in c) s.call(c, l) && !r.hasOwnProperty(l) && (h[l] = c[l]);
|
|
1068
|
+
if (o && o.defaultProps) for (l in c = o.defaultProps, c) h[l] === void 0 && (h[l] = c[l]);
|
|
1069
|
+
return { $$typeof: n, type: o, key: g, ref: p, props: h, _owner: e.current };
|
|
998
1070
|
}
|
|
999
1071
|
return x.jsx = a, x.jsxs = a, x;
|
|
1000
1072
|
}
|
|
1001
1073
|
var O;
|
|
1002
1074
|
function it() {
|
|
1003
|
-
return O || (O = 1,
|
|
1075
|
+
return O || (O = 1, M.exports = nt()), M.exports;
|
|
1004
1076
|
}
|
|
1005
1077
|
var S = it();
|
|
1006
|
-
const
|
|
1007
|
-
function
|
|
1008
|
-
return /* @__PURE__ */ S.jsx(
|
|
1078
|
+
const W = B(null);
|
|
1079
|
+
function mt({ runtime: i, children: n }) {
|
|
1080
|
+
return /* @__PURE__ */ S.jsx(W.Provider, { value: i, children: n });
|
|
1009
1081
|
}
|
|
1010
1082
|
function at() {
|
|
1011
|
-
const i =
|
|
1083
|
+
const i = q(W);
|
|
1012
1084
|
if (!i)
|
|
1013
1085
|
throw new Error("useAssistantRuntimeContext must be used within AssistantRuntimeProvider");
|
|
1014
1086
|
return i;
|
|
1015
1087
|
}
|
|
1016
|
-
function
|
|
1088
|
+
function f() {
|
|
1017
1089
|
return at();
|
|
1018
1090
|
}
|
|
1019
1091
|
function _t() {
|
|
1020
|
-
const i =
|
|
1092
|
+
const i = f();
|
|
1021
1093
|
return {
|
|
1022
|
-
switchToThread: (
|
|
1094
|
+
switchToThread: (n) => i.threads.switchToThread(n),
|
|
1023
1095
|
switchToNewThread: () => i.threads.switchToNewThread(),
|
|
1024
|
-
loadThreads: (
|
|
1025
|
-
renameThread: (
|
|
1026
|
-
var e,
|
|
1027
|
-
return (
|
|
1096
|
+
loadThreads: (n) => i.threads.loadThreads(n),
|
|
1097
|
+
renameThread: (n, t) => {
|
|
1098
|
+
var e, s;
|
|
1099
|
+
return (s = (e = i.threads).renameThread) == null ? void 0 : s.call(e, n, t);
|
|
1028
1100
|
},
|
|
1029
|
-
deleteThread: (
|
|
1101
|
+
deleteThread: (n) => {
|
|
1030
1102
|
var t, e;
|
|
1031
|
-
return (e = (t = i.threads).deleteThread) == null ? void 0 : e.call(t,
|
|
1103
|
+
return (e = (t = i.threads).deleteThread) == null ? void 0 : e.call(t, n);
|
|
1032
1104
|
}
|
|
1033
1105
|
};
|
|
1034
1106
|
}
|
|
1035
1107
|
function xt() {
|
|
1036
|
-
const i =
|
|
1108
|
+
const i = f(), [n, t] = b(i.threads.getState());
|
|
1037
1109
|
return w(() => i.threads.subscribe(() => {
|
|
1038
1110
|
t(i.threads.getState());
|
|
1039
|
-
}), [i]),
|
|
1111
|
+
}), [i]), n;
|
|
1040
1112
|
}
|
|
1041
1113
|
function ot() {
|
|
1042
|
-
const
|
|
1043
|
-
return w(() =>
|
|
1114
|
+
const n = f().threads.getMainThread(), [, t] = b({});
|
|
1115
|
+
return w(() => n.subscribe(() => {
|
|
1044
1116
|
t({});
|
|
1045
|
-
}), [
|
|
1117
|
+
}), [n]), n;
|
|
1046
1118
|
}
|
|
1047
|
-
var
|
|
1119
|
+
var P = { exports: {} }, F = {};
|
|
1048
1120
|
/**
|
|
1049
1121
|
* @license React
|
|
1050
1122
|
* use-sync-external-store-shim.production.js
|
|
@@ -1056,85 +1128,85 @@ var A = { exports: {} }, P = {};
|
|
|
1056
1128
|
*/
|
|
1057
1129
|
var L;
|
|
1058
1130
|
function ct() {
|
|
1059
|
-
if (L) return
|
|
1131
|
+
if (L) return F;
|
|
1060
1132
|
L = 1;
|
|
1061
|
-
var i =
|
|
1062
|
-
function
|
|
1063
|
-
return h ===
|
|
1064
|
-
}
|
|
1065
|
-
var t = typeof Object.is == "function" ? Object.is :
|
|
1066
|
-
function o(h,
|
|
1067
|
-
var
|
|
1068
|
-
return
|
|
1133
|
+
var i = U;
|
|
1134
|
+
function n(h, g) {
|
|
1135
|
+
return h === g && (h !== 0 || 1 / h === 1 / g) || h !== h && g !== g;
|
|
1136
|
+
}
|
|
1137
|
+
var t = typeof Object.is == "function" ? Object.is : n, e = i.useState, s = i.useEffect, r = i.useLayoutEffect, a = i.useDebugValue;
|
|
1138
|
+
function o(h, g) {
|
|
1139
|
+
var p = g(), _ = e({ inst: { value: p, getSnapshot: g } }), y = _[0].inst, T = _[1];
|
|
1140
|
+
return r(
|
|
1069
1141
|
function() {
|
|
1070
|
-
|
|
1142
|
+
y.value = p, y.getSnapshot = g, c(y) && T({ inst: y });
|
|
1071
1143
|
},
|
|
1072
|
-
[h,
|
|
1073
|
-
),
|
|
1144
|
+
[h, p, g]
|
|
1145
|
+
), s(
|
|
1074
1146
|
function() {
|
|
1075
|
-
return c(
|
|
1076
|
-
c(
|
|
1147
|
+
return c(y) && T({ inst: y }), h(function() {
|
|
1148
|
+
c(y) && T({ inst: y });
|
|
1077
1149
|
});
|
|
1078
1150
|
},
|
|
1079
1151
|
[h]
|
|
1080
|
-
), a(
|
|
1152
|
+
), a(p), p;
|
|
1081
1153
|
}
|
|
1082
1154
|
function c(h) {
|
|
1083
|
-
var
|
|
1155
|
+
var g = h.getSnapshot;
|
|
1084
1156
|
h = h.value;
|
|
1085
1157
|
try {
|
|
1086
|
-
var
|
|
1087
|
-
return !t(h,
|
|
1158
|
+
var p = g();
|
|
1159
|
+
return !t(h, p);
|
|
1088
1160
|
} catch {
|
|
1089
1161
|
return !0;
|
|
1090
1162
|
}
|
|
1091
1163
|
}
|
|
1092
|
-
function d(h,
|
|
1093
|
-
return
|
|
1164
|
+
function d(h, g) {
|
|
1165
|
+
return g();
|
|
1094
1166
|
}
|
|
1095
|
-
var
|
|
1096
|
-
return
|
|
1167
|
+
var l = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? d : o;
|
|
1168
|
+
return F.useSyncExternalStore = i.useSyncExternalStore !== void 0 ? i.useSyncExternalStore : l, F;
|
|
1097
1169
|
}
|
|
1098
|
-
var
|
|
1170
|
+
var k;
|
|
1099
1171
|
function ut() {
|
|
1100
|
-
return
|
|
1172
|
+
return k || (k = 1, P.exports = ct()), P.exports;
|
|
1101
1173
|
}
|
|
1102
1174
|
var ht = ut();
|
|
1103
1175
|
function St() {
|
|
1104
|
-
const i =
|
|
1176
|
+
const i = f();
|
|
1105
1177
|
return ht.useSyncExternalStore(
|
|
1106
|
-
(
|
|
1107
|
-
|
|
1178
|
+
(n) => i.subscribe(() => {
|
|
1179
|
+
n();
|
|
1108
1180
|
}),
|
|
1109
1181
|
() => i.thread.messages,
|
|
1110
1182
|
() => i.thread.messages
|
|
1111
1183
|
);
|
|
1112
1184
|
}
|
|
1113
1185
|
function wt() {
|
|
1114
|
-
const i = ot(), [
|
|
1186
|
+
const i = ot(), [n, t] = b(""), [e, s] = b(!1);
|
|
1115
1187
|
return {
|
|
1116
|
-
text:
|
|
1188
|
+
text: n,
|
|
1117
1189
|
setText: t,
|
|
1118
1190
|
isSubmitting: e,
|
|
1119
1191
|
send: async (a) => {
|
|
1120
|
-
if (a == null || a.preventDefault(), !
|
|
1121
|
-
const o =
|
|
1122
|
-
t(""),
|
|
1192
|
+
if (a == null || a.preventDefault(), !n.trim() || e) return;
|
|
1193
|
+
const o = n;
|
|
1194
|
+
t(""), s(!0);
|
|
1123
1195
|
try {
|
|
1124
1196
|
await i.send(o);
|
|
1125
1197
|
} catch (c) {
|
|
1126
1198
|
console.error("Failed to send message:", c), t(o);
|
|
1127
1199
|
} finally {
|
|
1128
|
-
|
|
1200
|
+
s(!1);
|
|
1129
1201
|
}
|
|
1130
1202
|
},
|
|
1131
1203
|
clear: () => t(""),
|
|
1132
1204
|
append: (a) => t((o) => o + a)
|
|
1133
1205
|
};
|
|
1134
1206
|
}
|
|
1135
|
-
function
|
|
1136
|
-
var
|
|
1137
|
-
const e =
|
|
1207
|
+
function $(i, n) {
|
|
1208
|
+
var r, a, o, c;
|
|
1209
|
+
const e = f().pluginRegistry.getBestRendererForType(i);
|
|
1138
1210
|
if (!e)
|
|
1139
1211
|
return {
|
|
1140
1212
|
component: null,
|
|
@@ -1143,190 +1215,190 @@ function Q(i, s) {
|
|
|
1143
1215
|
supportsPreview: !1,
|
|
1144
1216
|
supportsFullscreen: !1
|
|
1145
1217
|
};
|
|
1146
|
-
const
|
|
1218
|
+
const s = n ? (r = e.auxiliary) == null ? void 0 : r[n] : null;
|
|
1147
1219
|
return {
|
|
1148
1220
|
component: e.component,
|
|
1149
|
-
auxiliaryComponent:
|
|
1221
|
+
auxiliaryComponent: s,
|
|
1150
1222
|
supportsFocus: ((a = e.capabilities) == null ? void 0 : a.supportsFocus) ?? !1,
|
|
1151
1223
|
supportsPreview: ((o = e.capabilities) == null ? void 0 : o.supportsPreview) ?? !1,
|
|
1152
1224
|
supportsFullscreen: ((c = e.capabilities) == null ? void 0 : c.supportsFullscreen) ?? !1
|
|
1153
1225
|
};
|
|
1154
1226
|
}
|
|
1155
1227
|
function Ct() {
|
|
1156
|
-
const i =
|
|
1228
|
+
const i = f(), [n, t] = b(i.contentFocus.state);
|
|
1157
1229
|
return w(() => i.contentFocus.subscribe(() => {
|
|
1158
1230
|
t(i.contentFocus.state);
|
|
1159
1231
|
}), [i]), {
|
|
1160
|
-
...
|
|
1161
|
-
focus: (e,
|
|
1232
|
+
...n,
|
|
1233
|
+
focus: (e, s, r, a) => i.contentFocus.focus(e, s, r, a),
|
|
1162
1234
|
blur: () => i.contentFocus.blur(),
|
|
1163
|
-
toggle: (e,
|
|
1235
|
+
toggle: (e, s, r, a) => i.contentFocus.toggle(e, s, r, a),
|
|
1164
1236
|
switchContext: (e) => i.contentFocus.switchContext(e),
|
|
1165
1237
|
focusNext: () => i.contentFocus.focusNext(i.thread.messages),
|
|
1166
1238
|
focusPrevious: () => i.contentFocus.focusPrevious(i.thread.messages)
|
|
1167
1239
|
};
|
|
1168
1240
|
}
|
|
1169
1241
|
function dt(i) {
|
|
1170
|
-
const
|
|
1171
|
-
w(() => (i.execute &&
|
|
1242
|
+
const n = f();
|
|
1243
|
+
w(() => (i.execute && n.capabilityRegistry.registerHandler(i.name, { execute: i.execute }), i.render && n.capabilityRegistry.registerRenderer(i.name, {
|
|
1172
1244
|
component: i.render
|
|
1173
1245
|
}), () => {
|
|
1174
|
-
|
|
1175
|
-
}), [i.name,
|
|
1246
|
+
n.capabilityRegistry.unregister(i.name);
|
|
1247
|
+
}), [i.name, n]);
|
|
1176
1248
|
}
|
|
1177
1249
|
function lt(i) {
|
|
1178
|
-
const
|
|
1179
|
-
() =>
|
|
1180
|
-
), [,
|
|
1250
|
+
const n = f(), [t, e] = b(
|
|
1251
|
+
() => n.capabilityExecutionManager.getExecution(i)
|
|
1252
|
+
), [, s] = z((r) => r + 1, 0);
|
|
1181
1253
|
return w(() => {
|
|
1182
|
-
const
|
|
1183
|
-
return e(
|
|
1254
|
+
const r = n.capabilityExecutionManager.getExecution(i);
|
|
1255
|
+
return e(r), n.capabilityExecutionManager.subscribe((o) => {
|
|
1184
1256
|
if (o === i) {
|
|
1185
|
-
const c =
|
|
1186
|
-
e(c),
|
|
1257
|
+
const c = n.capabilityExecutionManager.getExecution(i);
|
|
1258
|
+
e(c), s();
|
|
1187
1259
|
}
|
|
1188
1260
|
});
|
|
1189
|
-
}, [i,
|
|
1261
|
+
}, [i, n]), t;
|
|
1190
1262
|
}
|
|
1191
|
-
const
|
|
1263
|
+
const Q = B(void 0);
|
|
1192
1264
|
function Tt({ children: i }) {
|
|
1193
|
-
const [
|
|
1194
|
-
t((
|
|
1265
|
+
const [n, t] = b({}), e = C((c, d) => {
|
|
1266
|
+
t((l) => {
|
|
1195
1267
|
if (d === null) {
|
|
1196
|
-
const { [c]: h, ...
|
|
1197
|
-
return
|
|
1268
|
+
const { [c]: h, ...g } = l;
|
|
1269
|
+
return g;
|
|
1198
1270
|
}
|
|
1199
1271
|
return {
|
|
1200
|
-
...
|
|
1272
|
+
...l,
|
|
1201
1273
|
[c]: { id: c, ...d }
|
|
1202
1274
|
};
|
|
1203
1275
|
});
|
|
1204
|
-
}, []),
|
|
1276
|
+
}, []), s = C((c) => {
|
|
1205
1277
|
t((d) => {
|
|
1206
|
-
const { [c]:
|
|
1278
|
+
const { [c]: l, ...h } = d;
|
|
1207
1279
|
return h;
|
|
1208
1280
|
});
|
|
1209
|
-
}, []),
|
|
1281
|
+
}, []), r = C(() => Object.values(n).reduce(
|
|
1210
1282
|
(c, d) => {
|
|
1211
|
-
const
|
|
1212
|
-
(h, [
|
|
1283
|
+
const l = Object.entries(d.data).reduce(
|
|
1284
|
+
(h, [g, p]) => ({
|
|
1213
1285
|
...h,
|
|
1214
|
-
[
|
|
1286
|
+
[g]: typeof p == "string" ? p : JSON.stringify(p)
|
|
1215
1287
|
}),
|
|
1216
1288
|
{}
|
|
1217
1289
|
);
|
|
1218
|
-
return { ...c, ...
|
|
1290
|
+
return { ...c, ...l };
|
|
1219
1291
|
},
|
|
1220
1292
|
{}
|
|
1221
|
-
), [
|
|
1293
|
+
), [n]), a = C(() => {
|
|
1222
1294
|
t({});
|
|
1223
1295
|
}, []), o = V(
|
|
1224
1296
|
() => ({
|
|
1225
|
-
contexts:
|
|
1297
|
+
contexts: n,
|
|
1226
1298
|
setContext: e,
|
|
1227
|
-
removeContext:
|
|
1228
|
-
getContextData:
|
|
1299
|
+
removeContext: s,
|
|
1300
|
+
getContextData: r,
|
|
1229
1301
|
clearContexts: a
|
|
1230
1302
|
}),
|
|
1231
|
-
[
|
|
1303
|
+
[n, e, s, r, a]
|
|
1232
1304
|
);
|
|
1233
|
-
return /* @__PURE__ */ S.jsx(
|
|
1305
|
+
return /* @__PURE__ */ S.jsx(Q.Provider, { value: o, children: i });
|
|
1234
1306
|
}
|
|
1235
|
-
function
|
|
1236
|
-
const i =
|
|
1307
|
+
function gt() {
|
|
1308
|
+
const i = q(Q);
|
|
1237
1309
|
if (!i)
|
|
1238
1310
|
throw new Error("useChatContext must be used within a ChatContextProvider");
|
|
1239
1311
|
return i;
|
|
1240
1312
|
}
|
|
1241
1313
|
function It(i) {
|
|
1242
|
-
const { setContext:
|
|
1243
|
-
w(() => (
|
|
1314
|
+
const { setContext: n, removeContext: t } = gt(), { id: e = "currentPage", ...s } = i;
|
|
1315
|
+
w(() => (n(e, s), () => {
|
|
1244
1316
|
t(e);
|
|
1245
|
-
}), [e,
|
|
1317
|
+
}), [e, s.displayName, JSON.stringify(s.data), s.priority, s.icon]);
|
|
1246
1318
|
}
|
|
1247
|
-
function
|
|
1248
|
-
const t =
|
|
1249
|
-
if (!
|
|
1319
|
+
function pt({ message: i, content: n }) {
|
|
1320
|
+
const t = f(), e = n, s = lt(e.capabilityId), r = t.capabilityRegistry.getRenderer(e.capabilityName);
|
|
1321
|
+
if (!r || !s)
|
|
1250
1322
|
return null;
|
|
1251
|
-
const a =
|
|
1323
|
+
const a = r.component;
|
|
1252
1324
|
return /* @__PURE__ */ S.jsx(
|
|
1253
1325
|
a,
|
|
1254
1326
|
{
|
|
1255
|
-
capabilityName:
|
|
1256
|
-
capabilityId:
|
|
1257
|
-
args:
|
|
1258
|
-
result:
|
|
1259
|
-
status:
|
|
1327
|
+
capabilityName: s.name,
|
|
1328
|
+
capabilityId: s.id,
|
|
1329
|
+
args: s.args,
|
|
1330
|
+
result: s.result,
|
|
1331
|
+
status: s.status,
|
|
1260
1332
|
message: i
|
|
1261
1333
|
}
|
|
1262
1334
|
);
|
|
1263
1335
|
}
|
|
1264
|
-
function vt({ message: i, content:
|
|
1265
|
-
const { component: t } =
|
|
1266
|
-
if (
|
|
1267
|
-
return /* @__PURE__ */ S.jsx(
|
|
1336
|
+
function vt({ message: i, content: n }) {
|
|
1337
|
+
const { component: t } = $(n.type);
|
|
1338
|
+
if (n.type === "capability")
|
|
1339
|
+
return /* @__PURE__ */ S.jsx(pt, { message: i, content: n });
|
|
1268
1340
|
if (!t)
|
|
1269
1341
|
return null;
|
|
1270
1342
|
const e = t;
|
|
1271
|
-
return /* @__PURE__ */ S.jsx(e, { content:
|
|
1343
|
+
return /* @__PURE__ */ S.jsx(e, { content: n, message: i });
|
|
1272
1344
|
}
|
|
1273
1345
|
function Rt({
|
|
1274
1346
|
message: i,
|
|
1275
|
-
content:
|
|
1347
|
+
content: n,
|
|
1276
1348
|
context: t,
|
|
1277
1349
|
onClose: e,
|
|
1278
|
-
onNavigate:
|
|
1279
|
-
onSwitchContext:
|
|
1350
|
+
onNavigate: s,
|
|
1351
|
+
onSwitchContext: r
|
|
1280
1352
|
}) {
|
|
1281
|
-
const { auxiliaryComponent: a } =
|
|
1353
|
+
const { auxiliaryComponent: a } = $(n.type, t);
|
|
1282
1354
|
if (!a)
|
|
1283
1355
|
return null;
|
|
1284
1356
|
const o = a;
|
|
1285
1357
|
return /* @__PURE__ */ S.jsx(
|
|
1286
1358
|
o,
|
|
1287
1359
|
{
|
|
1288
|
-
content:
|
|
1360
|
+
content: n,
|
|
1289
1361
|
message: i,
|
|
1290
1362
|
context: t,
|
|
1291
1363
|
onClose: e,
|
|
1292
|
-
onNavigate:
|
|
1293
|
-
onSwitchContext:
|
|
1364
|
+
onNavigate: s,
|
|
1365
|
+
onSwitchContext: r
|
|
1294
1366
|
}
|
|
1295
1367
|
);
|
|
1296
1368
|
}
|
|
1297
1369
|
function Et(i) {
|
|
1298
|
-
const
|
|
1299
|
-
return
|
|
1370
|
+
const n = () => (dt(i), null);
|
|
1371
|
+
return n.displayName = `Capability(${i.name})`, n;
|
|
1300
1372
|
}
|
|
1301
1373
|
class Mt {
|
|
1302
1374
|
getAllowedEvents() {
|
|
1303
1375
|
return null;
|
|
1304
1376
|
}
|
|
1305
|
-
shouldProcessEvent(
|
|
1377
|
+
shouldProcessEvent(n) {
|
|
1306
1378
|
const t = this.getAllowedEvents();
|
|
1307
|
-
return t ? t.includes(
|
|
1379
|
+
return t ? t.includes(n) : !0;
|
|
1308
1380
|
}
|
|
1309
|
-
async *stream(
|
|
1310
|
-
const { signal: t } =
|
|
1311
|
-
if (!
|
|
1312
|
-
throw new Error(`HTTP error! status: ${
|
|
1313
|
-
if (!
|
|
1381
|
+
async *stream(n) {
|
|
1382
|
+
const { signal: t } = n, { url: e, options: s } = this.prepareRequest(n), r = await fetch(e, { ...s, signal: t });
|
|
1383
|
+
if (!r.ok)
|
|
1384
|
+
throw new Error(`HTTP error! status: ${r.status}`);
|
|
1385
|
+
if (!r.body)
|
|
1314
1386
|
throw new Error("Response body is null");
|
|
1315
|
-
yield* this.parseSSEStream(
|
|
1387
|
+
yield* this.parseSSEStream(r.body, t);
|
|
1316
1388
|
}
|
|
1317
|
-
async *parseSSEStream(
|
|
1318
|
-
const e =
|
|
1319
|
-
let
|
|
1389
|
+
async *parseSSEStream(n, t) {
|
|
1390
|
+
const e = n.getReader(), s = new TextDecoder();
|
|
1391
|
+
let r = "", a = null;
|
|
1320
1392
|
try {
|
|
1321
1393
|
for (; ; ) {
|
|
1322
1394
|
const { done: o, value: c } = await e.read();
|
|
1323
1395
|
if (o || t != null && t.aborted) break;
|
|
1324
|
-
|
|
1325
|
-
const d =
|
|
1396
|
+
r += s.decode(c, { stream: !0 });
|
|
1397
|
+
const d = r.split(`
|
|
1326
1398
|
`);
|
|
1327
|
-
|
|
1328
|
-
for (const
|
|
1329
|
-
const h =
|
|
1399
|
+
r = d.pop() || "";
|
|
1400
|
+
for (const l of d) {
|
|
1401
|
+
const h = l.trim();
|
|
1330
1402
|
if (!h) {
|
|
1331
1403
|
a = null;
|
|
1332
1404
|
continue;
|
|
@@ -1337,15 +1409,15 @@ class Mt {
|
|
|
1337
1409
|
continue;
|
|
1338
1410
|
}
|
|
1339
1411
|
if (h.startsWith("data:")) {
|
|
1340
|
-
const
|
|
1341
|
-
if (
|
|
1412
|
+
const g = h.substring(5).trim();
|
|
1413
|
+
if (g === "eof" || h === "eof")
|
|
1342
1414
|
break;
|
|
1343
1415
|
try {
|
|
1344
|
-
const
|
|
1416
|
+
const p = JSON.parse(g);
|
|
1345
1417
|
if (a && this.shouldProcessEvent(a)) {
|
|
1346
1418
|
const _ = this.convertEvent({
|
|
1347
1419
|
event: a,
|
|
1348
|
-
data:
|
|
1420
|
+
data: p
|
|
1349
1421
|
});
|
|
1350
1422
|
_ && (yield _);
|
|
1351
1423
|
}
|
|
@@ -1363,29 +1435,29 @@ class Mt {
|
|
|
1363
1435
|
}
|
|
1364
1436
|
export {
|
|
1365
1437
|
bt as AssistantRuntime,
|
|
1366
|
-
|
|
1438
|
+
mt as AssistantRuntimeProvider,
|
|
1367
1439
|
Rt as AuxiliaryRenderer,
|
|
1368
1440
|
Mt as BaseSSEStreamAdapter,
|
|
1369
1441
|
K as CapabilityExecutionManager,
|
|
1370
1442
|
Y as CapabilityRegistry,
|
|
1371
|
-
|
|
1443
|
+
pt as CapabilityRendererComp,
|
|
1372
1444
|
Tt as ChatContextProvider,
|
|
1373
1445
|
et as ComposerRuntime,
|
|
1374
1446
|
vt as ContentRenderer,
|
|
1375
1447
|
G as PluginRegistry,
|
|
1376
|
-
|
|
1448
|
+
v as ThreadListItemRuntime,
|
|
1377
1449
|
st as ThreadListRuntime,
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1450
|
+
R as ThreadRuntime,
|
|
1451
|
+
E as ThreadRuntimeCore,
|
|
1452
|
+
I as generateMessageId,
|
|
1381
1453
|
Et as makeCapability,
|
|
1382
|
-
|
|
1454
|
+
f as useAssistantRuntime,
|
|
1383
1455
|
dt as useCapability,
|
|
1384
1456
|
lt as useCapabilityExecution,
|
|
1385
|
-
|
|
1457
|
+
gt as useChatContext,
|
|
1386
1458
|
wt as useComposer,
|
|
1387
1459
|
Ct as useContentFocus,
|
|
1388
|
-
|
|
1460
|
+
$ as useContentRenderer,
|
|
1389
1461
|
ot as useCurrentThread,
|
|
1390
1462
|
St as useMessages,
|
|
1391
1463
|
It as usePageContext,
|