@assistant-ui/core 0.3.12 → 0.3.13
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.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/react/client/interactable-model-context.d.ts.map +1 -1
- package/dist/react/client/interactable-model-context.js +5 -1
- package/dist/react/client/interactable-model-context.js.map +1 -1
- package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-runtime.js +5 -1
- package/dist/runtime/api/thread-runtime.js.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.d.ts +25 -0
- package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.js +64 -11
- package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.d.ts +14 -0
- package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.js +31 -0
- package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
- package/dist/runtime/base/default-edit-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/default-edit-composer-runtime-core.js +1 -6
- package/dist/runtime/base/default-edit-composer-runtime-core.js.map +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.js +1 -4
- package/dist/runtime/base/default-thread-composer-runtime-core.js.map +1 -1
- package/dist/runtime/queue/external-thread-queue-adapter.d.ts +15 -0
- package/dist/runtime/queue/external-thread-queue-adapter.d.ts.map +1 -1
- package/dist/runtime/queue/message-queue.js +23 -10
- package/dist/runtime/queue/message-queue.js.map +1 -1
- package/dist/runtimes/external-store/external-store-adapter.d.ts +7 -0
- package/dist/runtimes/external-store/external-store-adapter.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts +3 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js +49 -13
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.js +2 -1
- package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
- package/dist/store/clients/external-thread.d.ts +7 -0
- package/dist/store/clients/external-thread.d.ts.map +1 -1
- package/dist/store/clients/external-thread.js +460 -369
- package/dist/store/clients/external-thread.js.map +1 -1
- package/dist/store/clients/runtime-adapter.d.ts.map +1 -1
- package/dist/store/clients/runtime-adapter.js +5 -2
- package/dist/store/clients/runtime-adapter.js.map +1 -1
- package/dist/store/clients/single-thread-list.d.ts.map +1 -1
- package/dist/store/clients/single-thread-list.js +31 -27
- package/dist/store/clients/single-thread-list.js.map +1 -1
- package/dist/store/clients/suggestions.d.ts +3 -1
- package/dist/store/clients/suggestions.d.ts.map +1 -1
- package/dist/store/clients/suggestions.js +65 -37
- package/dist/store/clients/suggestions.js.map +1 -1
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +1 -1
- package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-list-item-runtime-client.js +64 -50
- package/dist/store/runtime-clients/thread-list-item-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.js +98 -82
- package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -1
- package/dist/store/scope-registration.d.ts +2 -2
- package/dist/store/scopes/suggestions.d.ts +6 -1
- package/dist/store/scopes/suggestions.d.ts.map +1 -1
- package/dist/store/scopes/thread.d.ts +17 -0
- package/dist/store/scopes/thread.d.ts.map +1 -1
- package/dist/types/error.d.ts +15 -1
- package/dist/types/error.d.ts.map +1 -1
- package/dist/types/error.js +18 -1
- package/dist/types/error.js.map +1 -1
- package/dist/types/message.d.ts +2 -0
- package/dist/types/message.d.ts.map +1 -1
- package/dist/types/message.js.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +1 -0
- package/src/react/client/interactable-model-context.ts +6 -1
- package/src/react/runtimes/useExternalStoreRuntime.suggestions.test.tsx +114 -0
- package/src/runtime/api/thread-runtime.ts +8 -1
- package/src/runtime/base/base-composer-runtime-core.ts +100 -8
- package/src/runtime/base/base-thread-runtime-core.ts +36 -0
- package/src/runtime/base/default-edit-composer-runtime-core.ts +1 -15
- package/src/runtime/base/default-thread-composer-runtime-core.ts +1 -11
- package/src/runtime/queue/external-thread-queue-adapter.ts +17 -0
- package/src/runtime/queue/message-queue.ts +26 -9
- package/src/runtimes/external-store/external-store-adapter.ts +7 -0
- package/src/runtimes/external-store/external-store-thread-runtime-core.ts +100 -26
- package/src/runtimes/local/local-thread-runtime-core.ts +4 -1
- package/src/store/clients/external-thread.ts +119 -16
- package/src/store/clients/runtime-adapter.ts +5 -2
- package/src/store/clients/single-thread-list.ts +2 -1
- package/src/store/clients/suggestions.ts +39 -13
- package/src/store/runtime-clients/thread-list-item-runtime-client.ts +13 -28
- package/src/store/runtime-clients/thread-runtime-client.ts +5 -0
- package/src/store/scopes/suggestions.ts +6 -0
- package/src/store/scopes/thread.ts +17 -0
- package/src/tests/append-interactable-snapshots.test.ts +350 -0
- package/src/tests/base-composer-runtime-core-send.test.ts +126 -0
- package/src/tests/base-composer-runtime-core.test.ts +108 -1
- package/src/tests/default-edit-composer-runtime-core.test.ts +0 -68
- package/src/tests/external-store-thread-runtime-core-adapter.test.ts +300 -0
- package/src/tests/external-thread-attachments.test.tsx +214 -0
- package/src/tests/external-thread-parity.test.tsx +54 -0
- package/src/tests/external-thread-refetch.test.tsx +117 -0
- package/src/tests/external-thread-suggestions.test.tsx +59 -0
- package/src/tests/message-queue.test.ts +26 -0
- package/src/tests/thread-message-like.test.ts +39 -0
- package/src/tests/thread-switch-events.test.tsx +136 -0
- package/src/types/error.ts +24 -0
- package/src/types/message.ts +2 -0
- package/src/tests/default-thread-composer-runtime-core.test.ts +0 -82
|
@@ -3,8 +3,8 @@ import { getThreadMessageText } from "../../utils/text.js";
|
|
|
3
3
|
import { toMessagePartStatus } from "../../utils/normalizePartStatus.js";
|
|
4
4
|
import { resolveToolApprovalResponse } from "../../runtime/utils/resolveToolApprovalResponse.js";
|
|
5
5
|
import { isCreateAttachment } from "../../types/attachment.js";
|
|
6
|
+
import { ThreadSuggestions } from "./suggestions.js";
|
|
6
7
|
import { ModelContext } from "./model-context-client.js";
|
|
7
|
-
import { Suggestions } from "./suggestions.js";
|
|
8
8
|
import { DataRenderers } from "../../react/client/DataRenderers.js";
|
|
9
9
|
import { Tools } from "../../react/client/Tools.js";
|
|
10
10
|
import { SingleThreadList } from "./single-thread-list.js";
|
|
@@ -16,6 +16,7 @@ import { Derived, attachTransformScopes, useClientLookup, useClientResource } fr
|
|
|
16
16
|
//#region src/store/clients/external-thread.ts
|
|
17
17
|
const EMPTY_QUEUE_ITEMS = [];
|
|
18
18
|
const EMPTY_BRANCH_IDS = [];
|
|
19
|
+
const EMPTY_SUGGESTIONS = [];
|
|
19
20
|
const COMPLETE_STATUS = Object.freeze({ type: "complete" });
|
|
20
21
|
const derivePartStatus = (message, partIndex, part) => {
|
|
21
22
|
if (!message.status) return COMPLETE_STATUS;
|
|
@@ -352,6 +353,39 @@ const useAttachmentResource = ({ attachment, onRemove }) => {
|
|
|
352
353
|
};
|
|
353
354
|
};
|
|
354
355
|
const AttachmentResource = resource(useAttachmentResource);
|
|
356
|
+
var AttachmentAddOperations = class {
|
|
357
|
+
operations = /* @__PURE__ */ new Set();
|
|
358
|
+
start() {
|
|
359
|
+
const operation = {
|
|
360
|
+
cancelled: false,
|
|
361
|
+
attachmentIds: /* @__PURE__ */ new Set()
|
|
362
|
+
};
|
|
363
|
+
this.operations.add(operation);
|
|
364
|
+
return operation;
|
|
365
|
+
}
|
|
366
|
+
accept(operation, attachmentId) {
|
|
367
|
+
if (operation.cancelled) return false;
|
|
368
|
+
operation.attachmentIds.add(attachmentId);
|
|
369
|
+
return true;
|
|
370
|
+
}
|
|
371
|
+
finish(operation) {
|
|
372
|
+
this.operations.delete(operation);
|
|
373
|
+
}
|
|
374
|
+
isCancelled(operation) {
|
|
375
|
+
return operation.cancelled;
|
|
376
|
+
}
|
|
377
|
+
cancel(attachmentId) {
|
|
378
|
+
for (const operation of [...this.operations]) {
|
|
379
|
+
if (!operation.attachmentIds.has(attachmentId)) continue;
|
|
380
|
+
operation.cancelled = true;
|
|
381
|
+
this.operations.delete(operation);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
cancelAll() {
|
|
385
|
+
for (const operation of this.operations) operation.cancelled = true;
|
|
386
|
+
this.operations.clear();
|
|
387
|
+
}
|
|
388
|
+
};
|
|
355
389
|
const useQueueItemClient = ({ item, onMove, onRemove }) => {
|
|
356
390
|
return {
|
|
357
391
|
getState: () => item,
|
|
@@ -365,8 +399,9 @@ const useQueueItemClient = ({ item, onMove, onRemove }) => {
|
|
|
365
399
|
};
|
|
366
400
|
const QueueItemClient = resource(useQueueItemClient);
|
|
367
401
|
const drainAdapterAdd = async (result, upsert) => {
|
|
368
|
-
if (Symbol.asyncIterator in result)
|
|
369
|
-
|
|
402
|
+
if (Symbol.asyncIterator in result) {
|
|
403
|
+
for await (const attachment of result) if (!upsert(attachment)) break;
|
|
404
|
+
} else upsert(await result);
|
|
370
405
|
};
|
|
371
406
|
const useLiveState = (initial) => {
|
|
372
407
|
const $ = c(3);
|
|
@@ -394,76 +429,84 @@ const useLiveState = (initial) => {
|
|
|
394
429
|
return t1;
|
|
395
430
|
};
|
|
396
431
|
const useComposerClientResource = (t0) => {
|
|
397
|
-
const $ = c(
|
|
398
|
-
const { type, canCancel,
|
|
399
|
-
const
|
|
432
|
+
const $ = c(105);
|
|
433
|
+
const { type, canCancel, isRunning: t1, isSendDisabled: t2, onCancel, onBeginEdit, onSend, message, queue, attachmentAdapter } = t0;
|
|
434
|
+
const isRunning = t1 === void 0 ? false : t1;
|
|
435
|
+
const isSendDisabled = t2 === void 0 ? false : t2;
|
|
400
436
|
const [isEditing, setIsEditing, isEditingRef] = useLiveState(type === "thread");
|
|
401
437
|
const [text, setText, textRef] = useLiveState("");
|
|
402
438
|
const [role, setRole, roleRef] = useLiveState("user");
|
|
403
|
-
let t2;
|
|
404
|
-
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
405
|
-
t2 = {};
|
|
406
|
-
$[0] = t2;
|
|
407
|
-
} else t2 = $[0];
|
|
408
|
-
const [runConfig, setRunConfig, runConfigRef] = useLiveState(t2);
|
|
409
439
|
let t3;
|
|
440
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
441
|
+
t3 = {};
|
|
442
|
+
$[0] = t3;
|
|
443
|
+
} else t3 = $[0];
|
|
444
|
+
const [runConfig, setRunConfig, runConfigRef] = useLiveState(t3);
|
|
445
|
+
let t4;
|
|
410
446
|
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
411
|
-
|
|
412
|
-
$[1] =
|
|
413
|
-
} else
|
|
414
|
-
const [attachments, setAttachments, attachmentsRef] = useLiveState(
|
|
447
|
+
t4 = [];
|
|
448
|
+
$[1] = t4;
|
|
449
|
+
} else t4 = $[1];
|
|
450
|
+
const [attachments, setAttachments, attachmentsRef] = useLiveState(t4);
|
|
415
451
|
const [quote, setQuote, quoteRef] = useLiveState(void 0);
|
|
416
|
-
let
|
|
417
|
-
if ($[2]
|
|
418
|
-
|
|
452
|
+
let t5;
|
|
453
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
454
|
+
t5 = new AttachmentAddOperations();
|
|
455
|
+
$[2] = t5;
|
|
456
|
+
} else t5 = $[2];
|
|
457
|
+
const attachmentAddOperations = t5;
|
|
458
|
+
let t6;
|
|
459
|
+
if ($[3] !== message || $[4] !== setAttachments || $[5] !== setRole || $[6] !== setText) {
|
|
460
|
+
t6 = () => {
|
|
419
461
|
if (!message) return;
|
|
420
462
|
const messageText = message.content.filter(_temp4).map(_temp5).join("\n\n");
|
|
421
463
|
setText(messageText);
|
|
422
464
|
setRole(message.role);
|
|
423
465
|
setAttachments(message.attachments ?? []);
|
|
424
466
|
};
|
|
425
|
-
$[
|
|
426
|
-
$[
|
|
427
|
-
$[
|
|
428
|
-
$[
|
|
429
|
-
$[
|
|
430
|
-
} else
|
|
431
|
-
const updateFromMessage =
|
|
432
|
-
let
|
|
433
|
-
if ($[
|
|
434
|
-
let
|
|
435
|
-
if ($[
|
|
436
|
-
|
|
467
|
+
$[3] = message;
|
|
468
|
+
$[4] = setAttachments;
|
|
469
|
+
$[5] = setRole;
|
|
470
|
+
$[6] = setText;
|
|
471
|
+
$[7] = t6;
|
|
472
|
+
} else t6 = $[7];
|
|
473
|
+
const updateFromMessage = t6;
|
|
474
|
+
let t7;
|
|
475
|
+
if ($[8] !== attachmentAdapter || $[9] !== attachments || $[10] !== setAttachments) {
|
|
476
|
+
let t8;
|
|
477
|
+
if ($[12] !== attachmentAdapter || $[13] !== setAttachments) {
|
|
478
|
+
t8 = (attachment) => withKey(attachment.id, AttachmentResource({
|
|
437
479
|
attachment,
|
|
438
480
|
onRemove: async () => {
|
|
481
|
+
attachmentAddOperations.cancel(attachment.id);
|
|
439
482
|
await attachmentAdapter?.remove(attachment);
|
|
440
483
|
setAttachments((prev) => prev.filter((a) => a.id !== attachment.id));
|
|
441
484
|
}
|
|
442
485
|
}));
|
|
443
|
-
$[
|
|
444
|
-
$[
|
|
445
|
-
$[
|
|
446
|
-
} else
|
|
447
|
-
|
|
448
|
-
$[
|
|
449
|
-
$[
|
|
450
|
-
$[
|
|
451
|
-
$[
|
|
452
|
-
} else
|
|
453
|
-
const attachmentClients = useClientLookup(
|
|
454
|
-
let
|
|
455
|
-
if ($[
|
|
456
|
-
|
|
486
|
+
$[12] = attachmentAdapter;
|
|
487
|
+
$[13] = setAttachments;
|
|
488
|
+
$[14] = t8;
|
|
489
|
+
} else t8 = $[14];
|
|
490
|
+
t7 = attachments.map(t8);
|
|
491
|
+
$[8] = attachmentAdapter;
|
|
492
|
+
$[9] = attachments;
|
|
493
|
+
$[10] = setAttachments;
|
|
494
|
+
$[11] = t7;
|
|
495
|
+
} else t7 = $[11];
|
|
496
|
+
const attachmentClients = useClientLookup(t7);
|
|
497
|
+
let t8;
|
|
498
|
+
if ($[15] !== attachmentAdapter) {
|
|
499
|
+
t8 = async (removed) => {
|
|
457
500
|
if (!attachmentAdapter) return;
|
|
458
501
|
await Promise.all(removed.filter(_temp6).map((a_1) => attachmentAdapter.remove(a_1)));
|
|
459
502
|
};
|
|
460
|
-
$[
|
|
461
|
-
$[
|
|
462
|
-
} else
|
|
463
|
-
const removePendingAttachments =
|
|
464
|
-
let
|
|
465
|
-
if ($[
|
|
466
|
-
|
|
503
|
+
$[15] = attachmentAdapter;
|
|
504
|
+
$[16] = t8;
|
|
505
|
+
} else t8 = $[16];
|
|
506
|
+
const removePendingAttachments = t8;
|
|
507
|
+
let t9;
|
|
508
|
+
if ($[17] !== setAttachments) {
|
|
509
|
+
t9 = (attachment_0) => {
|
|
467
510
|
setAttachments((prev_0) => {
|
|
468
511
|
const idx = prev_0.findIndex((a_2) => a_2.id === attachment_0.id);
|
|
469
512
|
if (idx === -1) return [...prev_0, attachment_0];
|
|
@@ -472,41 +515,41 @@ const useComposerClientResource = (t0) => {
|
|
|
472
515
|
return next;
|
|
473
516
|
});
|
|
474
517
|
};
|
|
475
|
-
$[
|
|
476
|
-
$[
|
|
477
|
-
} else
|
|
478
|
-
const upsertAttachment =
|
|
518
|
+
$[17] = setAttachments;
|
|
519
|
+
$[18] = t9;
|
|
520
|
+
} else t9 = $[18];
|
|
521
|
+
const upsertAttachment = t9;
|
|
479
522
|
const steerItems = queue?.steerItems ?? EMPTY_QUEUE_ITEMS;
|
|
480
523
|
const laneItems = queue?.items ?? EMPTY_QUEUE_ITEMS;
|
|
481
|
-
let
|
|
482
|
-
if ($[
|
|
483
|
-
|
|
484
|
-
$[
|
|
485
|
-
$[
|
|
486
|
-
$[
|
|
487
|
-
} else
|
|
488
|
-
const queueItems =
|
|
489
|
-
let
|
|
490
|
-
if ($[
|
|
491
|
-
let
|
|
492
|
-
if ($[
|
|
493
|
-
|
|
524
|
+
let t10;
|
|
525
|
+
if ($[19] !== laneItems || $[20] !== steerItems) {
|
|
526
|
+
t10 = steerItems.length === 0 ? laneItems : laneItems.length === 0 ? steerItems : [...steerItems, ...laneItems];
|
|
527
|
+
$[19] = laneItems;
|
|
528
|
+
$[20] = steerItems;
|
|
529
|
+
$[21] = t10;
|
|
530
|
+
} else t10 = $[21];
|
|
531
|
+
const queueItems = t10;
|
|
532
|
+
let t11;
|
|
533
|
+
if ($[22] !== queue || $[23] !== queueItems) {
|
|
534
|
+
let t12;
|
|
535
|
+
if ($[25] !== queue) {
|
|
536
|
+
t12 = (item) => withKey(item.id, QueueItemClient({
|
|
494
537
|
item,
|
|
495
538
|
onMove: (placement) => queue?.move(item.id, placement),
|
|
496
539
|
onRemove: () => queue?.remove(item.id)
|
|
497
540
|
}));
|
|
498
|
-
$[
|
|
499
|
-
$[
|
|
500
|
-
} else
|
|
501
|
-
|
|
502
|
-
$[
|
|
503
|
-
$[
|
|
504
|
-
$[
|
|
505
|
-
} else
|
|
506
|
-
const queueItemClients = useClientLookup(
|
|
507
|
-
let
|
|
508
|
-
if ($[
|
|
509
|
-
|
|
541
|
+
$[25] = queue;
|
|
542
|
+
$[26] = t12;
|
|
543
|
+
} else t12 = $[26];
|
|
544
|
+
t11 = queueItems.map(t12);
|
|
545
|
+
$[22] = queue;
|
|
546
|
+
$[23] = queueItems;
|
|
547
|
+
$[24] = t11;
|
|
548
|
+
} else t11 = $[24];
|
|
549
|
+
const queueItemClients = useClientLookup(t11);
|
|
550
|
+
let t12;
|
|
551
|
+
if ($[27] !== attachmentAdapter?.accept || $[28] !== attachmentClients.state || $[29] !== attachments.length || $[30] !== canCancel || $[31] !== isEditing || $[32] !== isSendDisabled || $[33] !== queueItems || $[34] !== quote || $[35] !== role || $[36] !== runConfig || $[37] !== text || $[38] !== type) {
|
|
552
|
+
t12 = () => {
|
|
510
553
|
const isEmpty = !text.trim() && !attachments.length;
|
|
511
554
|
return {
|
|
512
555
|
text,
|
|
@@ -524,37 +567,37 @@ const useComposerClientResource = (t0) => {
|
|
|
524
567
|
queue: queueItems
|
|
525
568
|
};
|
|
526
569
|
};
|
|
527
|
-
$[
|
|
528
|
-
$[
|
|
529
|
-
$[
|
|
530
|
-
$[
|
|
531
|
-
$[
|
|
532
|
-
$[
|
|
533
|
-
$[
|
|
534
|
-
$[
|
|
535
|
-
$[
|
|
536
|
-
$[
|
|
537
|
-
$[
|
|
538
|
-
$[
|
|
539
|
-
$[
|
|
540
|
-
} else
|
|
570
|
+
$[27] = attachmentAdapter?.accept;
|
|
571
|
+
$[28] = attachmentClients.state;
|
|
572
|
+
$[29] = attachments.length;
|
|
573
|
+
$[30] = canCancel;
|
|
574
|
+
$[31] = isEditing;
|
|
575
|
+
$[32] = isSendDisabled;
|
|
576
|
+
$[33] = queueItems;
|
|
577
|
+
$[34] = quote;
|
|
578
|
+
$[35] = role;
|
|
579
|
+
$[36] = runConfig;
|
|
580
|
+
$[37] = text;
|
|
581
|
+
$[38] = type;
|
|
582
|
+
$[39] = t12;
|
|
583
|
+
} else t12 = $[39];
|
|
541
584
|
attachmentAdapter?.accept;
|
|
542
|
-
let t11;
|
|
543
|
-
if ($[39] !== t10) {
|
|
544
|
-
t11 = t10();
|
|
545
|
-
$[39] = t10;
|
|
546
|
-
$[40] = t11;
|
|
547
|
-
} else t11 = $[40];
|
|
548
|
-
const state = t11;
|
|
549
|
-
let t12;
|
|
550
|
-
if ($[41] !== state) {
|
|
551
|
-
t12 = () => state;
|
|
552
|
-
$[41] = state;
|
|
553
|
-
$[42] = t12;
|
|
554
|
-
} else t12 = $[42];
|
|
555
585
|
let t13;
|
|
556
|
-
if ($[
|
|
557
|
-
t13 =
|
|
586
|
+
if ($[40] !== t12) {
|
|
587
|
+
t13 = t12();
|
|
588
|
+
$[40] = t12;
|
|
589
|
+
$[41] = t13;
|
|
590
|
+
} else t13 = $[41];
|
|
591
|
+
const state = t13;
|
|
592
|
+
let t14;
|
|
593
|
+
if ($[42] !== state) {
|
|
594
|
+
t14 = () => state;
|
|
595
|
+
$[42] = state;
|
|
596
|
+
$[43] = t14;
|
|
597
|
+
} else t14 = $[43];
|
|
598
|
+
let t15;
|
|
599
|
+
if ($[44] !== attachmentAdapter || $[45] !== setAttachments || $[46] !== upsertAttachment) {
|
|
600
|
+
t15 = async (fileOrAttachment) => {
|
|
558
601
|
if (attachmentAdapter) {
|
|
559
602
|
const file = isCreateAttachment(fileOrAttachment) ? {
|
|
560
603
|
name: fileOrAttachment.name,
|
|
@@ -565,8 +608,21 @@ const useComposerClientResource = (t0) => {
|
|
|
565
608
|
};
|
|
566
609
|
if (!fileMatchesAccept(file, attachmentAdapter.accept)) throw new Error(`File type ${file.type || "unknown"} is not accepted. Accepted types: ${attachmentAdapter.accept}`);
|
|
567
610
|
}
|
|
568
|
-
if (!isCreateAttachment(fileOrAttachment) && attachmentAdapter)
|
|
569
|
-
|
|
611
|
+
if (!isCreateAttachment(fileOrAttachment) && attachmentAdapter) {
|
|
612
|
+
const operation = attachmentAddOperations.start();
|
|
613
|
+
try {
|
|
614
|
+
await drainAdapterAdd(attachmentAdapter.add({ file: fileOrAttachment }), (attachment_1) => {
|
|
615
|
+
if (!attachmentAddOperations.accept(operation, attachment_1.id)) return false;
|
|
616
|
+
upsertAttachment(attachment_1);
|
|
617
|
+
return true;
|
|
618
|
+
});
|
|
619
|
+
attachmentAddOperations.finish(operation);
|
|
620
|
+
} catch (t16) {
|
|
621
|
+
const error = t16;
|
|
622
|
+
attachmentAddOperations.finish(operation);
|
|
623
|
+
if (!attachmentAddOperations.isCancelled(operation)) throw error;
|
|
624
|
+
}
|
|
625
|
+
} else if (!isCreateAttachment(fileOrAttachment)) {
|
|
570
626
|
const newAttachment = {
|
|
571
627
|
id: Math.random().toString(36).substring(7),
|
|
572
628
|
type: "file",
|
|
@@ -589,35 +645,37 @@ const useComposerClientResource = (t0) => {
|
|
|
589
645
|
setAttachments((prev_2) => [...prev_2, newAttachment_0]);
|
|
590
646
|
}
|
|
591
647
|
};
|
|
592
|
-
$[
|
|
593
|
-
$[
|
|
594
|
-
$[
|
|
595
|
-
$[
|
|
596
|
-
} else
|
|
597
|
-
let
|
|
598
|
-
if ($[
|
|
599
|
-
|
|
648
|
+
$[44] = attachmentAdapter;
|
|
649
|
+
$[45] = setAttachments;
|
|
650
|
+
$[46] = upsertAttachment;
|
|
651
|
+
$[47] = t15;
|
|
652
|
+
} else t15 = $[47];
|
|
653
|
+
let t16;
|
|
654
|
+
if ($[48] !== attachmentsRef || $[49] !== removePendingAttachments || $[50] !== setAttachments) {
|
|
655
|
+
t16 = async () => {
|
|
656
|
+
attachmentAddOperations.cancelAll();
|
|
600
657
|
const removed_0 = attachmentsRef.current;
|
|
601
658
|
setAttachments([]);
|
|
602
659
|
await removePendingAttachments(removed_0);
|
|
603
660
|
};
|
|
604
|
-
$[
|
|
605
|
-
$[
|
|
606
|
-
$[
|
|
607
|
-
$[
|
|
608
|
-
} else
|
|
609
|
-
let
|
|
610
|
-
if ($[
|
|
611
|
-
|
|
661
|
+
$[48] = attachmentsRef;
|
|
662
|
+
$[49] = removePendingAttachments;
|
|
663
|
+
$[50] = setAttachments;
|
|
664
|
+
$[51] = t16;
|
|
665
|
+
} else t16 = $[51];
|
|
666
|
+
let t17;
|
|
667
|
+
if ($[52] !== attachmentClients) {
|
|
668
|
+
t17 = (selector) => {
|
|
612
669
|
if ("id" in selector) return attachmentClients.get({ key: selector.id });
|
|
613
670
|
return attachmentClients.get(selector);
|
|
614
671
|
};
|
|
615
|
-
$[
|
|
616
|
-
$[
|
|
617
|
-
} else
|
|
618
|
-
let
|
|
619
|
-
if ($[
|
|
620
|
-
|
|
672
|
+
$[52] = attachmentClients;
|
|
673
|
+
$[53] = t17;
|
|
674
|
+
} else t17 = $[53];
|
|
675
|
+
let t18;
|
|
676
|
+
if ($[54] !== attachmentsRef || $[55] !== removePendingAttachments || $[56] !== setAttachments || $[57] !== setQuote || $[58] !== setRole || $[59] !== setRunConfig || $[60] !== setText) {
|
|
677
|
+
t18 = async () => {
|
|
678
|
+
attachmentAddOperations.cancelAll();
|
|
621
679
|
const removed_1 = attachmentsRef.current;
|
|
622
680
|
setText("");
|
|
623
681
|
setRole("user");
|
|
@@ -626,30 +684,33 @@ const useComposerClientResource = (t0) => {
|
|
|
626
684
|
setQuote(void 0);
|
|
627
685
|
await removePendingAttachments(removed_1);
|
|
628
686
|
};
|
|
629
|
-
$[
|
|
630
|
-
$[
|
|
631
|
-
$[
|
|
632
|
-
$[
|
|
633
|
-
$[
|
|
634
|
-
$[
|
|
635
|
-
$[
|
|
636
|
-
$[
|
|
637
|
-
} else
|
|
638
|
-
let
|
|
639
|
-
if ($[
|
|
640
|
-
|
|
687
|
+
$[54] = attachmentsRef;
|
|
688
|
+
$[55] = removePendingAttachments;
|
|
689
|
+
$[56] = setAttachments;
|
|
690
|
+
$[57] = setQuote;
|
|
691
|
+
$[58] = setRole;
|
|
692
|
+
$[59] = setRunConfig;
|
|
693
|
+
$[60] = setText;
|
|
694
|
+
$[61] = t18;
|
|
695
|
+
} else t18 = $[61];
|
|
696
|
+
let t19;
|
|
697
|
+
if ($[62] !== attachmentAdapter || $[63] !== attachmentsRef || $[64] !== isEditingRef || $[65] !== isRunning || $[66] !== isSendDisabled || $[67] !== onSend || $[68] !== queue || $[69] !== quoteRef || $[70] !== roleRef || $[71] !== runConfigRef || $[72] !== setAttachments || $[73] !== setIsEditing || $[74] !== setQuote || $[75] !== setText || $[76] !== textRef || $[77] !== type) {
|
|
698
|
+
t19 = (opts) => {
|
|
641
699
|
const currentQuote = quoteRef.current;
|
|
642
700
|
const currentText = textRef.current;
|
|
701
|
+
const currentRole = roleRef.current;
|
|
702
|
+
const currentRunConfig = runConfigRef.current;
|
|
643
703
|
const currentAttachments = attachmentsRef.current;
|
|
644
704
|
const isEmpty_0 = !currentText.trim() && !currentAttachments.length;
|
|
645
705
|
if (!isEditingRef.current) throw new Error("Composer is not available");
|
|
646
706
|
if (isEmpty_0 || isSendDisabled) return;
|
|
707
|
+
attachmentAddOperations.cancelAll();
|
|
647
708
|
setText("");
|
|
648
709
|
setAttachments([]);
|
|
649
710
|
setQuote(void 0);
|
|
650
711
|
const dispatch = (sendAttachments) => {
|
|
651
712
|
const composedMessage = {
|
|
652
|
-
role:
|
|
713
|
+
role: currentRole,
|
|
653
714
|
content: currentText ? [{
|
|
654
715
|
type: "text",
|
|
655
716
|
text: currentText
|
|
@@ -658,113 +719,113 @@ const useComposerClientResource = (t0) => {
|
|
|
658
719
|
createdAt: /* @__PURE__ */ new Date(),
|
|
659
720
|
parentId: null,
|
|
660
721
|
sourceId: null,
|
|
661
|
-
runConfig:
|
|
722
|
+
runConfig: currentRunConfig,
|
|
662
723
|
startRun: opts?.startRun,
|
|
663
724
|
metadata: { custom: { ...currentQuote ? { quote: currentQuote } : {} } }
|
|
664
725
|
};
|
|
665
726
|
if (queue && type === "thread") {
|
|
666
|
-
if (opts?.steer ??
|
|
727
|
+
if (opts?.steer ?? isRunning) queue.steer(composedMessage);
|
|
667
728
|
else queue.enqueue(composedMessage);
|
|
668
729
|
} else onSend?.(composedMessage);
|
|
669
730
|
if (type === "edit") setIsEditing(false);
|
|
670
731
|
};
|
|
671
|
-
if (attachmentAdapter && currentAttachments.length > 0) Promise.all(currentAttachments.map((
|
|
732
|
+
if (attachmentAdapter && currentAttachments.length > 0) Promise.all(currentAttachments.map((attachment_2) => attachment_2.status.type === "complete" ? attachment_2 : attachmentAdapter.send(attachment_2))).then(dispatch, (error_0) => {
|
|
672
733
|
setText((prev_3) => currentText && prev_3 ? currentText + "\n" + prev_3 : currentText || prev_3);
|
|
673
734
|
setQuote((prev_4) => prev_4 ?? currentQuote);
|
|
674
735
|
setAttachments((prev_5) => [...currentAttachments, ...prev_5]);
|
|
675
|
-
console.error("Failed to send attachments",
|
|
736
|
+
console.error("Failed to send attachments", error_0);
|
|
676
737
|
});
|
|
677
738
|
else dispatch(currentAttachments);
|
|
678
739
|
};
|
|
679
|
-
$[
|
|
680
|
-
$[
|
|
681
|
-
$[63] = canCancel;
|
|
740
|
+
$[62] = attachmentAdapter;
|
|
741
|
+
$[63] = attachmentsRef;
|
|
682
742
|
$[64] = isEditingRef;
|
|
683
|
-
$[65] =
|
|
684
|
-
$[66] =
|
|
685
|
-
$[67] =
|
|
686
|
-
$[68] =
|
|
687
|
-
$[69] =
|
|
688
|
-
$[70] =
|
|
689
|
-
$[71] =
|
|
690
|
-
$[72] =
|
|
691
|
-
$[73] =
|
|
692
|
-
$[74] =
|
|
693
|
-
$[75] =
|
|
694
|
-
$[76] =
|
|
695
|
-
$[77] =
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
743
|
+
$[65] = isRunning;
|
|
744
|
+
$[66] = isSendDisabled;
|
|
745
|
+
$[67] = onSend;
|
|
746
|
+
$[68] = queue;
|
|
747
|
+
$[69] = quoteRef;
|
|
748
|
+
$[70] = roleRef;
|
|
749
|
+
$[71] = runConfigRef;
|
|
750
|
+
$[72] = setAttachments;
|
|
751
|
+
$[73] = setIsEditing;
|
|
752
|
+
$[74] = setQuote;
|
|
753
|
+
$[75] = setText;
|
|
754
|
+
$[76] = textRef;
|
|
755
|
+
$[77] = type;
|
|
756
|
+
$[78] = t19;
|
|
757
|
+
} else t19 = $[78];
|
|
758
|
+
let t20;
|
|
759
|
+
if ($[79] !== onCancel || $[80] !== setIsEditing || $[81] !== type) {
|
|
760
|
+
t20 = () => {
|
|
700
761
|
onCancel?.();
|
|
701
762
|
if (type === "edit") setIsEditing(false);
|
|
702
763
|
};
|
|
703
|
-
$[
|
|
704
|
-
$[
|
|
705
|
-
$[
|
|
706
|
-
$[
|
|
707
|
-
} else
|
|
708
|
-
let
|
|
709
|
-
if ($[
|
|
710
|
-
|
|
764
|
+
$[79] = onCancel;
|
|
765
|
+
$[80] = setIsEditing;
|
|
766
|
+
$[81] = type;
|
|
767
|
+
$[82] = t20;
|
|
768
|
+
} else t20 = $[82];
|
|
769
|
+
let t21;
|
|
770
|
+
if ($[83] !== isEditingRef || $[84] !== onBeginEdit || $[85] !== setIsEditing || $[86] !== type || $[87] !== updateFromMessage) {
|
|
771
|
+
t21 = () => {
|
|
711
772
|
onBeginEdit?.();
|
|
712
773
|
if (type === "thread") return;
|
|
713
774
|
if (isEditingRef.current) throw new Error("Edit already in progress");
|
|
714
775
|
setIsEditing(true);
|
|
715
776
|
updateFromMessage();
|
|
716
777
|
};
|
|
717
|
-
$[
|
|
718
|
-
$[
|
|
719
|
-
$[
|
|
720
|
-
$[
|
|
721
|
-
$[
|
|
722
|
-
$[
|
|
723
|
-
} else
|
|
724
|
-
let
|
|
725
|
-
if ($[
|
|
726
|
-
|
|
778
|
+
$[83] = isEditingRef;
|
|
779
|
+
$[84] = onBeginEdit;
|
|
780
|
+
$[85] = setIsEditing;
|
|
781
|
+
$[86] = type;
|
|
782
|
+
$[87] = updateFromMessage;
|
|
783
|
+
$[88] = t21;
|
|
784
|
+
} else t21 = $[88];
|
|
785
|
+
let t22;
|
|
786
|
+
if ($[89] !== queueItemClients) {
|
|
787
|
+
t22 = (selector_0) => {
|
|
727
788
|
if ("id" in selector_0) return queueItemClients.get({ key: selector_0.id });
|
|
728
789
|
return queueItemClients.get(selector_0);
|
|
729
790
|
};
|
|
730
|
-
$[
|
|
731
|
-
$[
|
|
732
|
-
} else
|
|
733
|
-
let
|
|
734
|
-
if ($[
|
|
735
|
-
|
|
736
|
-
getState:
|
|
791
|
+
$[89] = queueItemClients;
|
|
792
|
+
$[90] = t22;
|
|
793
|
+
} else t22 = $[90];
|
|
794
|
+
let t23;
|
|
795
|
+
if ($[91] !== setQuote || $[92] !== setRole || $[93] !== setRunConfig || $[94] !== setText || $[95] !== t14 || $[96] !== t15 || $[97] !== t16 || $[98] !== t17 || $[99] !== t18 || $[100] !== t19 || $[101] !== t20 || $[102] !== t21 || $[103] !== t22) {
|
|
796
|
+
t23 = {
|
|
797
|
+
getState: t14,
|
|
737
798
|
setText,
|
|
738
799
|
setRole,
|
|
739
800
|
setRunConfig,
|
|
740
|
-
addAttachment:
|
|
741
|
-
clearAttachments:
|
|
742
|
-
attachment:
|
|
743
|
-
reset:
|
|
744
|
-
send:
|
|
745
|
-
cancel:
|
|
746
|
-
beginEdit:
|
|
801
|
+
addAttachment: t15,
|
|
802
|
+
clearAttachments: t16,
|
|
803
|
+
attachment: t17,
|
|
804
|
+
reset: t18,
|
|
805
|
+
send: t19,
|
|
806
|
+
cancel: t20,
|
|
807
|
+
beginEdit: t21,
|
|
747
808
|
startDictation: _temp7,
|
|
748
809
|
stopDictation: _temp8,
|
|
749
810
|
setQuote,
|
|
750
|
-
queueItem:
|
|
811
|
+
queueItem: t22
|
|
751
812
|
};
|
|
752
|
-
$[
|
|
753
|
-
$[
|
|
754
|
-
$[
|
|
755
|
-
$[
|
|
756
|
-
$[
|
|
757
|
-
$[
|
|
758
|
-
$[
|
|
759
|
-
$[
|
|
760
|
-
$[
|
|
761
|
-
$[
|
|
762
|
-
$[
|
|
763
|
-
$[
|
|
764
|
-
$[
|
|
765
|
-
$[
|
|
766
|
-
} else
|
|
767
|
-
return
|
|
813
|
+
$[91] = setQuote;
|
|
814
|
+
$[92] = setRole;
|
|
815
|
+
$[93] = setRunConfig;
|
|
816
|
+
$[94] = setText;
|
|
817
|
+
$[95] = t14;
|
|
818
|
+
$[96] = t15;
|
|
819
|
+
$[97] = t16;
|
|
820
|
+
$[98] = t17;
|
|
821
|
+
$[99] = t18;
|
|
822
|
+
$[100] = t19;
|
|
823
|
+
$[101] = t20;
|
|
824
|
+
$[102] = t21;
|
|
825
|
+
$[103] = t22;
|
|
826
|
+
$[104] = t23;
|
|
827
|
+
} else t23 = $[104];
|
|
828
|
+
return t23;
|
|
768
829
|
};
|
|
769
830
|
const ComposerClientResource = resource(useComposerClientResource);
|
|
770
831
|
const createSpeechController = (notify) => {
|
|
@@ -833,8 +894,8 @@ const dedupeMessagesById = (messages) => {
|
|
|
833
894
|
return deduped.length === messages.length ? messages : deduped.reverse();
|
|
834
895
|
};
|
|
835
896
|
const useExternalThread = (t0) => {
|
|
836
|
-
const $ = c(
|
|
837
|
-
const { messages: messagesProp, isRunning: t1, isLoading: t2, state: threadState, extras, isSendDisabled: t3, onNew, onEdit, onReload, onStartRun, onCancel, onResume, onAddToolResult, onResumeToolCall, onLoadExternalState, attachmentAdapter, feedbackAdapter, speechAdapter, queue, branches, onRespondToToolApproval } = t0;
|
|
897
|
+
const $ = c(115);
|
|
898
|
+
const { messages: messagesProp, isRunning: t1, isLoading: t2, state: threadState, extras, isSendDisabled: t3, onNew, onEdit, onReload, onStartRun, onCancel, onResume, onRefetchThread, onAddToolResult, onResumeToolCall, onLoadExternalState, attachmentAdapter, feedbackAdapter, speechAdapter, queue, branches, onRespondToToolApproval } = t0;
|
|
838
899
|
const isRunning = t1 === void 0 ? false : t1;
|
|
839
900
|
const isLoading = t2 === void 0 ? false : t2;
|
|
840
901
|
const isSendDisabled = t3 === void 0 ? false : t3;
|
|
@@ -1007,36 +1068,41 @@ const useExternalThread = (t0) => {
|
|
|
1007
1068
|
} else t17 = $[38];
|
|
1008
1069
|
const messageClients = useClientLookup(t17);
|
|
1009
1070
|
let t18;
|
|
1010
|
-
if ($[39] !== onCancel) {
|
|
1071
|
+
if ($[39] !== onCancel || $[40] !== queue) {
|
|
1011
1072
|
t18 = () => {
|
|
1012
|
-
onCancel
|
|
1073
|
+
if (!onCancel) return;
|
|
1074
|
+
queue?.__internal_notifyCancelled?.();
|
|
1075
|
+
onCancel();
|
|
1013
1076
|
};
|
|
1014
1077
|
$[39] = onCancel;
|
|
1015
|
-
$[40] =
|
|
1016
|
-
|
|
1078
|
+
$[40] = queue;
|
|
1079
|
+
$[41] = t18;
|
|
1080
|
+
} else t18 = $[41];
|
|
1017
1081
|
const handleCancelRun = t18;
|
|
1018
1082
|
let t19;
|
|
1019
|
-
if ($[
|
|
1083
|
+
if ($[42] !== messages || $[43] !== onNew) {
|
|
1020
1084
|
t19 = (message_1) => {
|
|
1021
1085
|
onNew?.({
|
|
1022
1086
|
...message_1,
|
|
1023
1087
|
parentId: messages.at(-1)?.id ?? null
|
|
1024
1088
|
});
|
|
1025
1089
|
};
|
|
1026
|
-
$[
|
|
1027
|
-
$[
|
|
1028
|
-
$[
|
|
1029
|
-
} else t19 = $[
|
|
1090
|
+
$[42] = messages;
|
|
1091
|
+
$[43] = onNew;
|
|
1092
|
+
$[44] = t19;
|
|
1093
|
+
} else t19 = $[44];
|
|
1030
1094
|
const handleSendNew = t19;
|
|
1031
1095
|
let t20;
|
|
1032
|
-
if ($[
|
|
1096
|
+
if ($[45] !== messages) {
|
|
1033
1097
|
t20 = messages.at(-1)?.id ?? null;
|
|
1034
|
-
$[
|
|
1035
|
-
$[
|
|
1036
|
-
} else t20 = $[
|
|
1098
|
+
$[45] = messages;
|
|
1099
|
+
$[46] = t20;
|
|
1100
|
+
} else t20 = $[46];
|
|
1037
1101
|
const headId = t20;
|
|
1102
|
+
const hasCancel = !!onCancel;
|
|
1103
|
+
const hasRefetchThread = !!onRefetchThread;
|
|
1038
1104
|
let t21;
|
|
1039
|
-
if ($[
|
|
1105
|
+
if ($[47] !== headId || $[48] !== queue) {
|
|
1040
1106
|
t21 = queue && {
|
|
1041
1107
|
...queue,
|
|
1042
1108
|
enqueue: (message_2) => queue.enqueue({
|
|
@@ -1048,31 +1114,40 @@ const useExternalThread = (t0) => {
|
|
|
1048
1114
|
parentId: message_3.parentId ?? headId
|
|
1049
1115
|
})
|
|
1050
1116
|
};
|
|
1051
|
-
$[
|
|
1052
|
-
$[
|
|
1053
|
-
$[
|
|
1054
|
-
} else t21 = $[
|
|
1117
|
+
$[47] = headId;
|
|
1118
|
+
$[48] = queue;
|
|
1119
|
+
$[49] = t21;
|
|
1120
|
+
} else t21 = $[49];
|
|
1055
1121
|
const composerQueue = t21;
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1122
|
+
const t22 = isRunning && hasCancel;
|
|
1123
|
+
let t23;
|
|
1124
|
+
if ($[50] !== attachmentAdapter || $[51] !== composerQueue || $[52] !== handleCancelRun || $[53] !== handleSendNew || $[54] !== isRunning || $[55] !== isSendDisabled || $[56] !== t22) {
|
|
1125
|
+
t23 = ComposerClientResource({
|
|
1059
1126
|
type: "thread",
|
|
1060
|
-
canCancel:
|
|
1127
|
+
canCancel: t22,
|
|
1128
|
+
isRunning,
|
|
1061
1129
|
isSendDisabled,
|
|
1062
1130
|
onCancel: handleCancelRun,
|
|
1063
1131
|
onSend: handleSendNew,
|
|
1064
1132
|
queue: composerQueue,
|
|
1065
1133
|
attachmentAdapter
|
|
1066
1134
|
});
|
|
1067
|
-
$[
|
|
1068
|
-
$[
|
|
1069
|
-
$[
|
|
1070
|
-
$[
|
|
1071
|
-
$[
|
|
1072
|
-
$[
|
|
1073
|
-
$[
|
|
1074
|
-
|
|
1075
|
-
|
|
1135
|
+
$[50] = attachmentAdapter;
|
|
1136
|
+
$[51] = composerQueue;
|
|
1137
|
+
$[52] = handleCancelRun;
|
|
1138
|
+
$[53] = handleSendNew;
|
|
1139
|
+
$[54] = isRunning;
|
|
1140
|
+
$[55] = isSendDisabled;
|
|
1141
|
+
$[56] = t22;
|
|
1142
|
+
$[57] = t23;
|
|
1143
|
+
} else t23 = $[57];
|
|
1144
|
+
const composerClient = useClientResource(t23);
|
|
1145
|
+
let t24;
|
|
1146
|
+
if ($[58] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1147
|
+
t24 = ThreadSuggestions(EMPTY_SUGGESTIONS);
|
|
1148
|
+
$[58] = t24;
|
|
1149
|
+
} else t24 = $[58];
|
|
1150
|
+
const suggestionsClient = useClientResource(t24);
|
|
1076
1151
|
const hasQueue = !!queue;
|
|
1077
1152
|
const hasBranches = !!branches;
|
|
1078
1153
|
const hasEdit = !!onEdit;
|
|
@@ -1080,22 +1155,22 @@ const useExternalThread = (t0) => {
|
|
|
1080
1155
|
const hasAttachments = !!attachmentAdapter;
|
|
1081
1156
|
const hasFeedback = !!feedbackAdapter;
|
|
1082
1157
|
const hasSpeech = !!speechAdapter;
|
|
1083
|
-
let t23;
|
|
1084
|
-
if ($[56] !== messageClients.state) {
|
|
1085
|
-
t23 = messageClients.state.map(_temp9);
|
|
1086
|
-
$[56] = messageClients.state;
|
|
1087
|
-
$[57] = t23;
|
|
1088
|
-
} else t23 = $[57];
|
|
1089
|
-
const messageStates = t23;
|
|
1090
|
-
const t24 = messages.length === 0;
|
|
1091
1158
|
let t25;
|
|
1092
|
-
if ($[
|
|
1093
|
-
t25 =
|
|
1159
|
+
if ($[59] !== messageClients.state) {
|
|
1160
|
+
t25 = messageClients.state.map(_temp9);
|
|
1161
|
+
$[59] = messageClients.state;
|
|
1162
|
+
$[60] = t25;
|
|
1163
|
+
} else t25 = $[60];
|
|
1164
|
+
const messageStates = t25;
|
|
1165
|
+
const t26 = messages.length === 0;
|
|
1166
|
+
let t27;
|
|
1167
|
+
if ($[61] !== hasAttachments || $[62] !== hasBranches || $[63] !== hasCancel || $[64] !== hasEdit || $[65] !== hasFeedback || $[66] !== hasQueue || $[67] !== hasRefetchThread || $[68] !== hasReload || $[69] !== hasSpeech) {
|
|
1168
|
+
t27 = {
|
|
1094
1169
|
edit: hasEdit,
|
|
1095
1170
|
delete: false,
|
|
1096
1171
|
reload: hasReload,
|
|
1097
|
-
refetchThread:
|
|
1098
|
-
cancel:
|
|
1172
|
+
refetchThread: hasRefetchThread,
|
|
1173
|
+
cancel: hasCancel,
|
|
1099
1174
|
speech: hasSpeech,
|
|
1100
1175
|
attachments: hasAttachments,
|
|
1101
1176
|
feedback: hasFeedback,
|
|
@@ -1106,70 +1181,72 @@ const useExternalThread = (t0) => {
|
|
|
1106
1181
|
dictation: false,
|
|
1107
1182
|
queue: hasQueue
|
|
1108
1183
|
};
|
|
1109
|
-
$[
|
|
1110
|
-
$[
|
|
1111
|
-
$[
|
|
1112
|
-
$[
|
|
1113
|
-
$[
|
|
1114
|
-
$[
|
|
1115
|
-
$[
|
|
1116
|
-
$[
|
|
1117
|
-
$[
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
if ($[67] !== threadState) {
|
|
1121
|
-
t26 = threadState ?? {};
|
|
1122
|
-
$[67] = threadState;
|
|
1123
|
-
$[68] = t26;
|
|
1124
|
-
} else t26 = $[68];
|
|
1125
|
-
let t27;
|
|
1126
|
-
if ($[69] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1127
|
-
t27 = [];
|
|
1128
|
-
$[69] = t27;
|
|
1129
|
-
} else t27 = $[69];
|
|
1184
|
+
$[61] = hasAttachments;
|
|
1185
|
+
$[62] = hasBranches;
|
|
1186
|
+
$[63] = hasCancel;
|
|
1187
|
+
$[64] = hasEdit;
|
|
1188
|
+
$[65] = hasFeedback;
|
|
1189
|
+
$[66] = hasQueue;
|
|
1190
|
+
$[67] = hasRefetchThread;
|
|
1191
|
+
$[68] = hasReload;
|
|
1192
|
+
$[69] = hasSpeech;
|
|
1193
|
+
$[70] = t27;
|
|
1194
|
+
} else t27 = $[70];
|
|
1130
1195
|
let t28;
|
|
1131
|
-
if ($[
|
|
1132
|
-
t28 = {
|
|
1133
|
-
|
|
1196
|
+
if ($[71] !== threadState) {
|
|
1197
|
+
t28 = threadState ?? {};
|
|
1198
|
+
$[71] = threadState;
|
|
1199
|
+
$[72] = t28;
|
|
1200
|
+
} else t28 = $[72];
|
|
1201
|
+
let t29;
|
|
1202
|
+
if ($[73] !== composerClient.state || $[74] !== extras || $[75] !== isLoading || $[76] !== isRunning || $[77] !== messageStates || $[78] !== speech || $[79] !== t26 || $[80] !== t27 || $[81] !== t28) {
|
|
1203
|
+
t29 = {
|
|
1204
|
+
isEmpty: t26,
|
|
1134
1205
|
isDisabled: false,
|
|
1135
1206
|
isLoading,
|
|
1136
1207
|
isRunning,
|
|
1137
|
-
capabilities:
|
|
1208
|
+
capabilities: t27,
|
|
1138
1209
|
messages: messageStates,
|
|
1139
|
-
state:
|
|
1140
|
-
suggestions:
|
|
1210
|
+
state: t28,
|
|
1211
|
+
suggestions: EMPTY_SUGGESTIONS,
|
|
1141
1212
|
extras,
|
|
1142
1213
|
speech,
|
|
1143
1214
|
voice: void 0,
|
|
1144
1215
|
composer: composerClient.state
|
|
1145
1216
|
};
|
|
1146
|
-
$[
|
|
1147
|
-
$[
|
|
1148
|
-
$[
|
|
1149
|
-
$[
|
|
1150
|
-
$[
|
|
1151
|
-
$[
|
|
1152
|
-
$[
|
|
1153
|
-
$[
|
|
1154
|
-
$[
|
|
1155
|
-
$[
|
|
1156
|
-
} else
|
|
1157
|
-
const state =
|
|
1158
|
-
let t29;
|
|
1159
|
-
if ($[80] !== state) {
|
|
1160
|
-
t29 = () => state;
|
|
1161
|
-
$[80] = state;
|
|
1162
|
-
$[81] = t29;
|
|
1163
|
-
} else t29 = $[81];
|
|
1217
|
+
$[73] = composerClient.state;
|
|
1218
|
+
$[74] = extras;
|
|
1219
|
+
$[75] = isLoading;
|
|
1220
|
+
$[76] = isRunning;
|
|
1221
|
+
$[77] = messageStates;
|
|
1222
|
+
$[78] = speech;
|
|
1223
|
+
$[79] = t26;
|
|
1224
|
+
$[80] = t27;
|
|
1225
|
+
$[81] = t28;
|
|
1226
|
+
$[82] = t29;
|
|
1227
|
+
} else t29 = $[82];
|
|
1228
|
+
const state = t29;
|
|
1164
1229
|
let t30;
|
|
1165
|
-
if ($[
|
|
1166
|
-
t30 = () =>
|
|
1167
|
-
$[
|
|
1168
|
-
$[
|
|
1169
|
-
} else t30 = $[
|
|
1230
|
+
if ($[83] !== state) {
|
|
1231
|
+
t30 = () => state;
|
|
1232
|
+
$[83] = state;
|
|
1233
|
+
$[84] = t30;
|
|
1234
|
+
} else t30 = $[84];
|
|
1170
1235
|
let t31;
|
|
1171
|
-
if ($[
|
|
1172
|
-
t31 = (
|
|
1236
|
+
if ($[85] !== composerClient.methods) {
|
|
1237
|
+
t31 = () => composerClient.methods;
|
|
1238
|
+
$[85] = composerClient.methods;
|
|
1239
|
+
$[86] = t31;
|
|
1240
|
+
} else t31 = $[86];
|
|
1241
|
+
let t32;
|
|
1242
|
+
if ($[87] !== suggestionsClient) {
|
|
1243
|
+
t32 = () => suggestionsClient.methods;
|
|
1244
|
+
$[87] = suggestionsClient;
|
|
1245
|
+
$[88] = t32;
|
|
1246
|
+
} else t32 = $[88];
|
|
1247
|
+
let t33;
|
|
1248
|
+
if ($[89] !== messages || $[90] !== onNew || $[91] !== queue) {
|
|
1249
|
+
t33 = (message_4) => {
|
|
1173
1250
|
const appendMessage = typeof message_4 === "string" ? {
|
|
1174
1251
|
createdAt: /* @__PURE__ */ new Date(),
|
|
1175
1252
|
parentId: messages.at(-1)?.id ?? null,
|
|
@@ -1196,62 +1273,70 @@ const useExternalThread = (t0) => {
|
|
|
1196
1273
|
if (queue) queue.enqueue(appendMessage);
|
|
1197
1274
|
else onNew?.(appendMessage);
|
|
1198
1275
|
};
|
|
1199
|
-
$[
|
|
1200
|
-
$[
|
|
1201
|
-
$[
|
|
1202
|
-
$[
|
|
1203
|
-
} else
|
|
1204
|
-
let
|
|
1205
|
-
if ($[
|
|
1206
|
-
|
|
1276
|
+
$[89] = messages;
|
|
1277
|
+
$[90] = onNew;
|
|
1278
|
+
$[91] = queue;
|
|
1279
|
+
$[92] = t33;
|
|
1280
|
+
} else t33 = $[92];
|
|
1281
|
+
let t34;
|
|
1282
|
+
if ($[93] !== onStartRun) {
|
|
1283
|
+
t34 = () => {
|
|
1207
1284
|
onStartRun?.();
|
|
1208
1285
|
};
|
|
1209
|
-
$[
|
|
1210
|
-
$[
|
|
1211
|
-
} else
|
|
1212
|
-
let
|
|
1213
|
-
if ($[
|
|
1214
|
-
|
|
1286
|
+
$[93] = onStartRun;
|
|
1287
|
+
$[94] = t34;
|
|
1288
|
+
} else t34 = $[94];
|
|
1289
|
+
let t35;
|
|
1290
|
+
if ($[95] !== onResume) {
|
|
1291
|
+
t35 = () => {
|
|
1215
1292
|
if (!onResume) throw new Error("Runtime does not support resuming runs (onResume is not set).");
|
|
1216
1293
|
onResume();
|
|
1217
1294
|
};
|
|
1218
|
-
$[
|
|
1219
|
-
$[
|
|
1220
|
-
} else
|
|
1221
|
-
let
|
|
1222
|
-
if ($[
|
|
1223
|
-
|
|
1295
|
+
$[95] = onResume;
|
|
1296
|
+
$[96] = t35;
|
|
1297
|
+
} else t35 = $[96];
|
|
1298
|
+
let t36;
|
|
1299
|
+
if ($[97] !== onRefetchThread) {
|
|
1300
|
+
t36 = onRefetchThread && { unstable_refetchThread: onRefetchThread };
|
|
1301
|
+
$[97] = onRefetchThread;
|
|
1302
|
+
$[98] = t36;
|
|
1303
|
+
} else t36 = $[98];
|
|
1304
|
+
let t37;
|
|
1305
|
+
if ($[99] !== onLoadExternalState) {
|
|
1306
|
+
t37 = (state_0) => {
|
|
1224
1307
|
if (!onLoadExternalState) throw new Error("Runtime does not support importing external states (onLoadExternalState is not set).");
|
|
1225
1308
|
onLoadExternalState(state_0);
|
|
1226
1309
|
};
|
|
1227
|
-
$[
|
|
1228
|
-
$[
|
|
1229
|
-
} else
|
|
1230
|
-
let
|
|
1231
|
-
if ($[
|
|
1232
|
-
|
|
1310
|
+
$[99] = onLoadExternalState;
|
|
1311
|
+
$[100] = t37;
|
|
1312
|
+
} else t37 = $[100];
|
|
1313
|
+
let t38;
|
|
1314
|
+
if ($[101] !== messageClients) {
|
|
1315
|
+
t38 = (selector) => {
|
|
1233
1316
|
if ("id" in selector) return messageClients.get({ key: selector.id });
|
|
1234
1317
|
return messageClients.get(selector);
|
|
1235
1318
|
};
|
|
1236
|
-
$[
|
|
1237
|
-
$[
|
|
1238
|
-
} else
|
|
1239
|
-
let
|
|
1240
|
-
if ($[
|
|
1241
|
-
|
|
1242
|
-
getState:
|
|
1243
|
-
composer:
|
|
1244
|
-
|
|
1319
|
+
$[101] = messageClients;
|
|
1320
|
+
$[102] = t38;
|
|
1321
|
+
} else t38 = $[102];
|
|
1322
|
+
let t39;
|
|
1323
|
+
if ($[103] !== handleCancelRun || $[104] !== speechController.stop || $[105] !== t30 || $[106] !== t31 || $[107] !== t32 || $[108] !== t33 || $[109] !== t34 || $[110] !== t35 || $[111] !== t36 || $[112] !== t37 || $[113] !== t38) {
|
|
1324
|
+
t39 = {
|
|
1325
|
+
getState: t30,
|
|
1326
|
+
composer: t31,
|
|
1327
|
+
suggestions: t32,
|
|
1328
|
+
append: t33,
|
|
1245
1329
|
deleteMessage: _temp0,
|
|
1246
|
-
startRun:
|
|
1247
|
-
resumeRun:
|
|
1330
|
+
startRun: t34,
|
|
1331
|
+
resumeRun: t35,
|
|
1248
1332
|
cancelRun: handleCancelRun,
|
|
1249
|
-
|
|
1333
|
+
...t36,
|
|
1334
|
+
importExternalState: t37,
|
|
1250
1335
|
getModelContext: _temp1,
|
|
1251
1336
|
export: _temp10,
|
|
1252
1337
|
import: _temp11,
|
|
1253
1338
|
reset: _temp12,
|
|
1254
|
-
message:
|
|
1339
|
+
message: t38,
|
|
1255
1340
|
stopSpeaking: speechController.stop,
|
|
1256
1341
|
connectVoice: _temp13,
|
|
1257
1342
|
disconnectVoice: _temp14,
|
|
@@ -1260,18 +1345,20 @@ const useExternalThread = (t0) => {
|
|
|
1260
1345
|
muteVoice: _temp18,
|
|
1261
1346
|
unmuteVoice: _temp19
|
|
1262
1347
|
};
|
|
1263
|
-
$[
|
|
1264
|
-
$[
|
|
1265
|
-
$[
|
|
1266
|
-
$[
|
|
1267
|
-
$[
|
|
1268
|
-
$[
|
|
1269
|
-
$[
|
|
1270
|
-
$[
|
|
1271
|
-
$[
|
|
1272
|
-
$[
|
|
1273
|
-
|
|
1274
|
-
|
|
1348
|
+
$[103] = handleCancelRun;
|
|
1349
|
+
$[104] = speechController.stop;
|
|
1350
|
+
$[105] = t30;
|
|
1351
|
+
$[106] = t31;
|
|
1352
|
+
$[107] = t32;
|
|
1353
|
+
$[108] = t33;
|
|
1354
|
+
$[109] = t34;
|
|
1355
|
+
$[110] = t35;
|
|
1356
|
+
$[111] = t36;
|
|
1357
|
+
$[112] = t37;
|
|
1358
|
+
$[113] = t38;
|
|
1359
|
+
$[114] = t39;
|
|
1360
|
+
} else t39 = $[114];
|
|
1361
|
+
return t39;
|
|
1275
1362
|
};
|
|
1276
1363
|
const ExternalThread = resource(useExternalThread);
|
|
1277
1364
|
attachTransformScopes(useExternalThread, (scopes, parent) => {
|
|
@@ -1298,7 +1385,11 @@ attachTransformScopes(useExternalThread, (scopes, parent) => {
|
|
|
1298
1385
|
if (!scopes.modelContext && parent.modelContext.source === null) scopes.modelContext = ModelContext();
|
|
1299
1386
|
if (!scopes.tools && parent.tools.source === null) scopes.tools = Tools({});
|
|
1300
1387
|
if (!scopes.dataRenderers && parent.dataRenderers.source === null) scopes.dataRenderers = DataRenderers();
|
|
1301
|
-
if (!scopes.suggestions && parent.suggestions.source === null) scopes.suggestions =
|
|
1388
|
+
if (!scopes.suggestions && parent.suggestions.source === null) scopes.suggestions = Derived({
|
|
1389
|
+
source: "thread",
|
|
1390
|
+
query: {},
|
|
1391
|
+
get: (aui) => aui.thread.suggestions()
|
|
1392
|
+
});
|
|
1302
1393
|
});
|
|
1303
1394
|
function _temp() {}
|
|
1304
1395
|
function _temp2(attachment) {
|