@assistant-ui/core 0.1.7 → 0.1.9
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/adapters/attachment.d.ts +4 -0
- package/dist/adapters/attachment.d.ts.map +1 -1
- package/dist/adapters/attachment.js +1 -1
- package/dist/adapters/attachment.js.map +1 -1
- package/dist/adapters/index.d.ts +10 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +4 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/mention.d.ts +24 -0
- package/dist/adapters/mention.d.ts.map +1 -0
- package/dist/adapters/mention.js +42 -0
- package/dist/adapters/mention.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/react/RuntimeAdapter.js +5 -6
- package/dist/react/RuntimeAdapter.js.map +1 -1
- package/dist/react/client/Interactables.d.ts +3 -0
- package/dist/react/client/Interactables.d.ts.map +1 -0
- package/dist/react/client/Interactables.js +173 -0
- package/dist/react/client/Interactables.js.map +1 -0
- package/dist/react/client/Tools.js +5 -6
- package/dist/react/client/Tools.js.map +1 -1
- package/dist/react/index.d.ts +6 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +5 -0
- package/dist/react/index.js.map +1 -1
- package/dist/react/model-context/makeInteractable.d.ts +10 -0
- package/dist/react/model-context/makeInteractable.d.ts.map +1 -0
- package/dist/react/model-context/makeInteractable.js +10 -0
- package/dist/react/model-context/makeInteractable.js.map +1 -0
- package/dist/react/model-context/useInteractable.d.ts +16 -0
- package/dist/react/model-context/useInteractable.d.ts.map +1 -0
- package/dist/react/model-context/useInteractable.js +36 -0
- package/dist/react/model-context/useInteractable.js.map +1 -0
- package/dist/react/primitive-hooks/useComposerSend.d.ts +2 -1
- package/dist/react/primitive-hooks/useComposerSend.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useComposerSend.js +5 -3
- package/dist/react/primitive-hooks/useComposerSend.js.map +1 -1
- package/dist/react/primitives/composer/ComposerQueue.d.ts +31 -0
- package/dist/react/primitives/composer/ComposerQueue.d.ts.map +1 -0
- package/dist/react/primitives/composer/ComposerQueue.js +30 -0
- package/dist/react/primitives/composer/ComposerQueue.js.map +1 -0
- package/dist/react/primitives/message/MessageParts.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageParts.js +2 -0
- package/dist/react/primitives/message/MessageParts.js.map +1 -1
- package/dist/react/providers/QueueItemByIndexProvider.d.ts +6 -0
- package/dist/react/providers/QueueItemByIndexProvider.d.ts.map +1 -0
- package/dist/react/providers/QueueItemByIndexProvider.js +13 -0
- package/dist/react/providers/QueueItemByIndexProvider.js.map +1 -0
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +1 -0
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
- package/dist/react/types/scopes/interactables.d.ts +39 -0
- package/dist/react/types/scopes/interactables.d.ts.map +1 -0
- package/dist/react/types/scopes/interactables.js +2 -0
- package/dist/react/types/scopes/interactables.js.map +1 -0
- package/dist/react/types/store-augmentation.d.ts +2 -0
- package/dist/react/types/store-augmentation.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.d.ts +1 -1
- package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.js +33 -8
- package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
- package/dist/runtime/interfaces/composer-runtime-core.d.ts +1 -1
- package/dist/runtime/interfaces/composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/interfaces/thread-runtime-core.d.ts +1 -0
- package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -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 +2 -0
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.d.ts +1 -0
- package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.js +1 -0
- package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts +1 -0
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js +1 -0
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/empty-thread-core.js +1 -0
- package/dist/runtimes/remote-thread-list/empty-thread-core.js.map +1 -1
- package/dist/runtimes/remote-thread-list/optimistic-state.d.ts +9 -0
- package/dist/runtimes/remote-thread-list/optimistic-state.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/optimistic-state.js +20 -0
- package/dist/runtimes/remote-thread-list/optimistic-state.js.map +1 -1
- package/dist/store/clients/no-op-composer-client.d.ts.map +1 -1
- package/dist/store/clients/no-op-composer-client.js +4 -0
- package/dist/store/clients/no-op-composer-client.js.map +1 -1
- package/dist/store/clients/runtime-adapter.d.ts +1 -1
- package/dist/store/clients/runtime-adapter.d.ts.map +1 -1
- package/dist/store/clients/runtime-adapter.js +19 -26
- package/dist/store/clients/runtime-adapter.js.map +1 -1
- package/dist/store/index.d.ts +2 -1
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/index.js.map +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.js +16 -5
- package/dist/store/runtime-clients/composer-runtime-client.js.map +1 -1
- package/dist/store/scope-registration.d.ts +2 -0
- package/dist/store/scope-registration.d.ts.map +1 -1
- package/dist/store/scopes/composer.d.ts +25 -1
- package/dist/store/scopes/composer.d.ts.map +1 -1
- package/dist/store/scopes/queue-item.d.ts +20 -0
- package/dist/store/scopes/queue-item.d.ts.map +1 -0
- package/dist/store/scopes/queue-item.js +2 -0
- package/dist/store/scopes/queue-item.js.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/mention.d.ts +32 -0
- package/dist/types/mention.d.ts.map +1 -0
- package/dist/types/mention.js +2 -0
- package/dist/types/mention.js.map +1 -0
- package/package.json +11 -11
- package/src/adapters/attachment.ts +1 -1
- package/src/adapters/index.ts +34 -0
- package/src/adapters/mention.ts +77 -0
- package/src/index.ts +11 -0
- package/src/react/RuntimeAdapter.ts +5 -7
- package/src/react/client/Interactables.ts +233 -0
- package/src/react/client/Tools.ts +5 -6
- package/src/react/index.ts +24 -0
- package/src/react/model-context/makeInteractable.ts +21 -0
- package/src/react/model-context/useInteractable.ts +73 -0
- package/src/react/primitive-hooks/useComposerSend.ts +11 -4
- package/src/react/primitives/composer/ComposerQueue.tsx +58 -0
- package/src/react/primitives/message/MessageParts.tsx +2 -0
- package/src/react/providers/QueueItemByIndexProvider.tsx +21 -0
- package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +1 -0
- package/src/react/types/scopes/interactables.ts +44 -0
- package/src/react/types/store-augmentation.ts +2 -0
- package/src/runtime/base/base-composer-runtime-core.ts +45 -9
- package/src/runtime/interfaces/composer-runtime-core.ts +4 -1
- package/src/runtime/interfaces/thread-runtime-core.ts +1 -0
- package/src/runtimes/external-store/external-store-thread-runtime-core.ts +2 -0
- package/src/runtimes/local/local-thread-runtime-core.ts +1 -0
- package/src/runtimes/readonly/ReadonlyThreadRuntimeCore.ts +1 -0
- package/src/runtimes/remote-thread-list/empty-thread-core.ts +1 -0
- package/src/runtimes/remote-thread-list/optimistic-state.ts +27 -0
- package/src/store/clients/no-op-composer-client.ts +4 -0
- package/src/store/clients/runtime-adapter.ts +20 -31
- package/src/store/index.ts +7 -0
- package/src/store/runtime-clients/composer-runtime-client.ts +22 -7
- package/src/store/scope-registration.ts +2 -0
- package/src/store/scopes/composer.ts +26 -1
- package/src/store/scopes/queue-item.ts +20 -0
- package/src/tests/OptimisticState-list-race.test.ts +256 -0
- package/src/tests/mention-formatter.test.ts +112 -0
- package/src/types/index.ts +47 -0
- package/src/types/mention.ts +50 -0
|
@@ -15,11 +15,7 @@ export const ComposerClient = resource(({ threadIdRef, messageIdRef, runtime, })
|
|
|
15
15
|
tapEffect(() => {
|
|
16
16
|
const unsubscribers = [];
|
|
17
17
|
// Subscribe to composer events
|
|
18
|
-
const
|
|
19
|
-
"send",
|
|
20
|
-
"attachmentAdd",
|
|
21
|
-
];
|
|
22
|
-
for (const event of composerEvents) {
|
|
18
|
+
for (const event of ["send", "attachmentAdd"]) {
|
|
23
19
|
const unsubscribe = runtime.unstable_on(event, () => {
|
|
24
20
|
emit(`composer.${event}`, {
|
|
25
21
|
threadId: threadIdRef.current,
|
|
@@ -28,6 +24,17 @@ export const ComposerClient = resource(({ threadIdRef, messageIdRef, runtime, })
|
|
|
28
24
|
});
|
|
29
25
|
unsubscribers.push(unsubscribe);
|
|
30
26
|
}
|
|
27
|
+
// attachmentAddError carries the failed attachment ID
|
|
28
|
+
unsubscribers.push(runtime.unstable_on("attachmentAddError", () => {
|
|
29
|
+
const errorAttachment = runtime
|
|
30
|
+
.getState()
|
|
31
|
+
.attachments.findLast((a) => a.status.type === "incomplete" && a.status.reason === "error");
|
|
32
|
+
emit("composer.attachmentAddError", {
|
|
33
|
+
threadId: threadIdRef.current,
|
|
34
|
+
...(messageIdRef && { messageId: messageIdRef.current }),
|
|
35
|
+
...(errorAttachment && { attachmentId: errorAttachment.id }),
|
|
36
|
+
});
|
|
37
|
+
}));
|
|
31
38
|
return () => {
|
|
32
39
|
for (const unsub of unsubscribers)
|
|
33
40
|
unsub();
|
|
@@ -50,6 +57,7 @@ export const ComposerClient = resource(({ threadIdRef, messageIdRef, runtime, })
|
|
|
50
57
|
type: runtimeState.type ?? "thread",
|
|
51
58
|
dictation: runtimeState.dictation,
|
|
52
59
|
quote: runtimeState.quote,
|
|
60
|
+
queue: [],
|
|
53
61
|
};
|
|
54
62
|
}, [runtimeState, attachments.state]);
|
|
55
63
|
return {
|
|
@@ -77,6 +85,9 @@ export const ComposerClient = resource(({ threadIdRef, messageIdRef, runtime, })
|
|
|
77
85
|
return attachments.get(selector);
|
|
78
86
|
}
|
|
79
87
|
},
|
|
88
|
+
queueItem: () => {
|
|
89
|
+
throw new Error("Queue is not supported in this runtime");
|
|
90
|
+
},
|
|
80
91
|
__internal_getRuntime: () => runtime,
|
|
81
92
|
};
|
|
82
93
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composer-runtime-client.js","sourceRoot":"","sources":["../../../src/store/runtime-clients/composer-runtime-client.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EACR,OAAO,EACP,SAAS,EACT,WAAW,EAEX,OAAO,GACR,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,gBAAgB,EAChB,eAAe,GAChB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"composer-runtime-client.js","sourceRoot":"","sources":["../../../src/store/runtime-clients/composer-runtime-client.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EACR,OAAO,EACP,SAAS,EACT,WAAW,EAEX,OAAO,GACR,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,gBAAgB,EAChB,eAAe,GAChB,MAAM,qBAAqB,CAAC;AAM7B,OAAO,EAAE,uBAAuB,EAAE,uCAAoC;AACtE,OAAO,EAAE,eAAe,EAAE,8BAA2B;AAErD,MAAM,+BAA+B,GAAG,QAAQ,CAC9C,CAAC,EAAE,OAAO,EAAE,KAAK,EAA+C,EAAE,EAAE;IAClE,MAAM,iBAAiB,GAAG,OAAO,CAC/B,GAAG,EAAE,CAAC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type { SuggestionsClientSchema } from "./scopes/suggestions.js";
|
|
10
10
|
import type { SuggestionClientSchema } from "./scopes/suggestion.js";
|
|
11
11
|
import type { ChainOfThoughtClientSchema } from "./scopes/chain-of-thought.js";
|
|
12
|
+
import type { QueueItemClientSchema } from "./scopes/queue-item.js";
|
|
12
13
|
declare module "@assistant-ui/store" {
|
|
13
14
|
interface ScopeRegistry {
|
|
14
15
|
threads: ThreadsClientSchema;
|
|
@@ -22,6 +23,7 @@ declare module "@assistant-ui/store" {
|
|
|
22
23
|
suggestions: SuggestionsClientSchema;
|
|
23
24
|
suggestion: SuggestionClientSchema;
|
|
24
25
|
chainOfThought: ChainOfThoughtClientSchema;
|
|
26
|
+
queueItem: QueueItemClientSchema;
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
//# sourceMappingURL=scope-registration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope-registration.d.ts","sourceRoot":"","sources":["../../src/store/scope-registration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,4BAAyB;AAC5D,OAAO,KAAK,EAAE,0BAA0B,EAAE,qCAAkC;AAC5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,2BAAwB;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,4BAAyB;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,yBAAsB;AACtD,OAAO,KAAK,EAAE,oBAAoB,EAAE,6BAA0B;AAC9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,+BAA4B;AAClE,OAAO,KAAK,EAAE,wBAAwB,EAAE,kCAA+B;AACvE,OAAO,KAAK,EAAE,uBAAuB,EAAE,gCAA6B;AACpE,OAAO,KAAK,EAAE,sBAAsB,EAAE,+BAA4B;AAClE,OAAO,KAAK,EAAE,0BAA0B,EAAE,qCAAkC;
|
|
1
|
+
{"version":3,"file":"scope-registration.d.ts","sourceRoot":"","sources":["../../src/store/scope-registration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,4BAAyB;AAC5D,OAAO,KAAK,EAAE,0BAA0B,EAAE,qCAAkC;AAC5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,2BAAwB;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,4BAAyB;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,yBAAsB;AACtD,OAAO,KAAK,EAAE,oBAAoB,EAAE,6BAA0B;AAC9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,+BAA4B;AAClE,OAAO,KAAK,EAAE,wBAAwB,EAAE,kCAA+B;AACvE,OAAO,KAAK,EAAE,uBAAuB,EAAE,gCAA6B;AACpE,OAAO,KAAK,EAAE,sBAAsB,EAAE,+BAA4B;AAClE,OAAO,KAAK,EAAE,0BAA0B,EAAE,qCAAkC;AAC5E,OAAO,KAAK,EAAE,qBAAqB,EAAE,+BAA4B;AAEjE,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,aAAa;QACrB,OAAO,EAAE,mBAAmB,CAAC;QAC7B,cAAc,EAAE,0BAA0B,CAAC;QAC3C,MAAM,EAAE,kBAAkB,CAAC;QAC3B,OAAO,EAAE,mBAAmB,CAAC;QAC7B,IAAI,EAAE,gBAAgB,CAAC;QACvB,QAAQ,EAAE,oBAAoB,CAAC;QAC/B,UAAU,EAAE,sBAAsB,CAAC;QACnC,YAAY,EAAE,wBAAwB,CAAC;QACvC,WAAW,EAAE,uBAAuB,CAAC;QACrC,UAAU,EAAE,sBAAsB,CAAC;QACnC,cAAc,EAAE,0BAA0B,CAAC;QAC3C,SAAS,EAAE,qBAAqB,CAAC;KAClC;CACF"}
|
|
@@ -5,6 +5,14 @@ import type { RunConfig } from "../../types/message.js";
|
|
|
5
5
|
import type { ComposerRuntime } from "../../runtime/api/composer-runtime.js";
|
|
6
6
|
import type { DictationState } from "../../runtime/interfaces/composer-runtime-core.js";
|
|
7
7
|
import type { AttachmentMethods } from "./attachment.js";
|
|
8
|
+
import type { QueueItemState, QueueItemMethods } from "./queue-item.js";
|
|
9
|
+
export type ComposerSendOptions = {
|
|
10
|
+
/**
|
|
11
|
+
* Whether to steer (interrupt the current run and process this message immediately).
|
|
12
|
+
* When false (default), the message is queued and processed in order.
|
|
13
|
+
*/
|
|
14
|
+
steer?: boolean;
|
|
15
|
+
};
|
|
8
16
|
export type ComposerState = {
|
|
9
17
|
readonly text: string;
|
|
10
18
|
readonly role: MessageRole;
|
|
@@ -25,6 +33,11 @@ export type ComposerState = {
|
|
|
25
33
|
* Undefined when no quote is set.
|
|
26
34
|
*/
|
|
27
35
|
readonly quote: QuoteInfo | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* The queue of messages waiting to be processed.
|
|
38
|
+
* Empty when no messages are queued.
|
|
39
|
+
*/
|
|
40
|
+
readonly queue: readonly QueueItemState[];
|
|
28
41
|
};
|
|
29
42
|
export type ComposerMethods = {
|
|
30
43
|
getState(): ComposerState;
|
|
@@ -39,7 +52,7 @@ export type ComposerMethods = {
|
|
|
39
52
|
id: string;
|
|
40
53
|
}): AttachmentMethods;
|
|
41
54
|
reset(): Promise<void>;
|
|
42
|
-
send(): void;
|
|
55
|
+
send(opts?: ComposerSendOptions): void;
|
|
43
56
|
cancel(): void;
|
|
44
57
|
beginEdit(): void;
|
|
45
58
|
/**
|
|
@@ -55,6 +68,12 @@ export type ComposerMethods = {
|
|
|
55
68
|
* Set a quote for the next message. Pass undefined to clear.
|
|
56
69
|
*/
|
|
57
70
|
setQuote(quote: QuoteInfo | undefined): void;
|
|
71
|
+
/**
|
|
72
|
+
* Access a queue item by index.
|
|
73
|
+
*/
|
|
74
|
+
queueItem(selector: {
|
|
75
|
+
index: number;
|
|
76
|
+
}): QueueItemMethods;
|
|
58
77
|
__internal_getRuntime?(): ComposerRuntime;
|
|
59
78
|
};
|
|
60
79
|
export type ComposerMeta = {
|
|
@@ -70,6 +89,11 @@ export type ComposerEvents = {
|
|
|
70
89
|
threadId: string;
|
|
71
90
|
messageId?: string;
|
|
72
91
|
};
|
|
92
|
+
"composer.attachmentAddError": {
|
|
93
|
+
threadId: string;
|
|
94
|
+
messageId?: string;
|
|
95
|
+
attachmentId?: string;
|
|
96
|
+
};
|
|
73
97
|
};
|
|
74
98
|
export type ComposerClientSchema = {
|
|
75
99
|
methods: ComposerMethods;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composer.d.ts","sourceRoot":"","sources":["../../../src/store/scopes/composer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,kCAA+B;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,+BAA4B;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,6BAA0B;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,+BAA4B;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,8CAA2C;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAE,0DAAuD;AACrF,OAAO,KAAK,EAAE,iBAAiB,EAAE,wBAAqB;
|
|
1
|
+
{"version":3,"file":"composer.d.ts","sourceRoot":"","sources":["../../../src/store/scopes/composer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,kCAA+B;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,+BAA4B;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,6BAA0B;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,+BAA4B;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,8CAA2C;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAE,0DAAuD;AACrF,OAAO,KAAK,EAAE,iBAAiB,EAAE,wBAAqB;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,wBAAqB;AAErE,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,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
|
+
getState(): QueueItemState;
|
|
7
|
+
steer(): void;
|
|
8
|
+
remove(): void;
|
|
9
|
+
};
|
|
10
|
+
export type QueueItemMeta = {
|
|
11
|
+
source: "composer";
|
|
12
|
+
query: {
|
|
13
|
+
index: number;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export type QueueItemClientSchema = {
|
|
17
|
+
methods: QueueItemMethods;
|
|
18
|
+
meta: QueueItemMeta;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=queue-item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue-item.d.ts","sourceRoot":"","sources":["../../../src/store/scopes/queue-item.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,IAAI,cAAc,CAAC;IAC3B,KAAK,IAAI,IAAI,CAAC;IACd,MAAM,IAAI,IAAI,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,gBAAgB,CAAC;IAC1B,IAAI,EAAE,aAAa,CAAC;CACrB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue-item.js","sourceRoot":"","sources":["../../../src/store/scopes/queue-item.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { TextMessagePart, ReasoningMessagePart, SourceMessagePart, ImageMessagePart, FileMessagePart, DataMessagePart, Unstable_AudioMessagePart, ToolCallMessagePart, ThreadUserMessagePart, ThreadAssistantMessagePart, MessagePartStatus, ToolCallMessagePartStatus, MessageStatus, MessageTiming, ThreadStep, ThreadSystemMessage, ThreadUserMessage, ThreadAssistantMessage, ThreadMessage, MessageRole, RunConfig, AppendMessage, } from "./message.js";
|
|
2
|
+
export type { Attachment, PendingAttachment, CompleteAttachment, AttachmentStatus, CreateAttachment, } from "./attachment.js";
|
|
3
|
+
export type { Unsubscribe } from "./unsubscribe.js";
|
|
4
|
+
export type { QuoteInfo } from "./quote.js";
|
|
5
|
+
export type { Unstable_MentionItem, Unstable_MentionCategory, Unstable_DirectiveSegment, Unstable_DirectiveFormatter, } from "./mention.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAEV,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,yBAAyB,EACzB,mBAAmB,EACnB,qBAAqB,EACrB,0BAA0B,EAE1B,iBAAiB,EACjB,yBAAyB,EACzB,aAAa,EAEb,aAAa,EACb,UAAU,EACV,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,EACtB,aAAa,EACb,WAAW,EAEX,SAAS,EACT,aAAa,GACd,qBAAkB;AAEnB,YAAY,EACV,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,GACjB,wBAAqB;AAEtB,YAAY,EAAE,WAAW,EAAE,yBAAsB;AAEjD,YAAY,EAAE,SAAS,EAAE,mBAAgB;AAEzC,YAAY,EACV,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,EACzB,2BAA2B,GAC5B,qBAAkB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ReadonlyJSONObject } from "assistant-stream/utils";
|
|
2
|
+
export type Unstable_MentionItem = {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly type: string;
|
|
5
|
+
readonly label: string;
|
|
6
|
+
readonly icon?: string | undefined;
|
|
7
|
+
readonly description?: string | undefined;
|
|
8
|
+
readonly metadata?: ReadonlyJSONObject | undefined;
|
|
9
|
+
};
|
|
10
|
+
export type Unstable_MentionCategory = {
|
|
11
|
+
readonly id: string;
|
|
12
|
+
readonly label: string;
|
|
13
|
+
readonly icon?: string | undefined;
|
|
14
|
+
};
|
|
15
|
+
/** Parsed segment from directive text */
|
|
16
|
+
export type Unstable_DirectiveSegment = {
|
|
17
|
+
readonly kind: "text";
|
|
18
|
+
readonly text: string;
|
|
19
|
+
} | {
|
|
20
|
+
readonly kind: "mention";
|
|
21
|
+
readonly type: string;
|
|
22
|
+
readonly label: string;
|
|
23
|
+
readonly id: string;
|
|
24
|
+
};
|
|
25
|
+
/** Configurable formatter for mention directive serialization/parsing */
|
|
26
|
+
export type Unstable_DirectiveFormatter = {
|
|
27
|
+
/** Serialize a mention item to directive text */
|
|
28
|
+
serialize(item: Unstable_MentionItem): string;
|
|
29
|
+
/** Parse text into alternating text and mention segments */
|
|
30
|
+
parse(text: string): readonly Unstable_DirectiveSegment[];
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=mention.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mention.d.ts","sourceRoot":"","sources":["../../src/types/mention.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAMjE,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,QAAQ,CAAC,QAAQ,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAC;CACpD,CAAC;AAMF,MAAM,MAAM,wBAAwB,GAAG;IACrC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC,CAAC;AAMF,yCAAyC;AACzC,MAAM,MAAM,yBAAyB,GACjC;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAChD;IACE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB,CAAC;AAMN,yEAAyE;AACzE,MAAM,MAAM,2BAA2B,GAAG;IACxC,iDAAiD;IACjD,SAAS,CAAC,IAAI,EAAE,oBAAoB,GAAG,MAAM,CAAC;IAC9C,4DAA4D;IAC5D,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,yBAAyB,EAAE,CAAC;CAC3D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mention.js","sourceRoot":"","sources":["../../src/types/mention.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@assistant-ui/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "Framework-agnostic core runtime for assistant-ui",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"assistant",
|
|
@@ -53,15 +53,15 @@
|
|
|
53
53
|
],
|
|
54
54
|
"sideEffects": false,
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"assistant-stream": "^0.3.
|
|
57
|
-
"nanoid": "^5.1.
|
|
56
|
+
"assistant-stream": "^0.3.8",
|
|
57
|
+
"nanoid": "^5.1.7"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"@assistant-ui/store": "^0.2.
|
|
61
|
-
"@assistant-ui/tap": "^0.5.
|
|
60
|
+
"@assistant-ui/store": "^0.2.5",
|
|
61
|
+
"@assistant-ui/tap": "^0.5.5",
|
|
62
62
|
"@types/react": "*",
|
|
63
63
|
"react": "^18 || ^19",
|
|
64
|
-
"assistant-cloud": "^0.1.
|
|
64
|
+
"assistant-cloud": "^0.1.23",
|
|
65
65
|
"zustand": "^5.0.11"
|
|
66
66
|
},
|
|
67
67
|
"peerDependenciesMeta": {
|
|
@@ -81,12 +81,12 @@
|
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@types/react": "^19.2.14",
|
|
83
83
|
"react": "^19.2.4",
|
|
84
|
-
"vitest": "^4.1.
|
|
85
|
-
"zustand": "^5.0.
|
|
86
|
-
"@assistant-ui/store": "0.2.
|
|
87
|
-
"@assistant-ui/tap": "0.5.
|
|
84
|
+
"vitest": "^4.1.1",
|
|
85
|
+
"zustand": "^5.0.12",
|
|
86
|
+
"@assistant-ui/store": "0.2.5",
|
|
87
|
+
"@assistant-ui/tap": "0.5.5",
|
|
88
88
|
"@assistant-ui/x-buildutils": "0.0.3",
|
|
89
|
-
"assistant-cloud": "0.1.
|
|
89
|
+
"assistant-cloud": "0.1.23"
|
|
90
90
|
},
|
|
91
91
|
"publishConfig": {
|
|
92
92
|
"access": "public",
|
|
@@ -114,7 +114,7 @@ const getFileText = (file: File) =>
|
|
|
114
114
|
// Composite Attachment Adapter
|
|
115
115
|
// =============================================================================
|
|
116
116
|
|
|
117
|
-
function fileMatchesAccept(
|
|
117
|
+
export function fileMatchesAccept(
|
|
118
118
|
file: { name: string; type: string },
|
|
119
119
|
acceptString: string,
|
|
120
120
|
) {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Attachment adapters
|
|
2
|
+
export type { AttachmentAdapter } from "./attachment";
|
|
3
|
+
export {
|
|
4
|
+
SimpleImageAttachmentAdapter,
|
|
5
|
+
SimpleTextAttachmentAdapter,
|
|
6
|
+
CompositeAttachmentAdapter,
|
|
7
|
+
} from "./attachment";
|
|
8
|
+
|
|
9
|
+
// Speech adapters
|
|
10
|
+
export type { SpeechSynthesisAdapter, DictationAdapter } from "./speech";
|
|
11
|
+
export {
|
|
12
|
+
WebSpeechSynthesisAdapter,
|
|
13
|
+
WebSpeechDictationAdapter,
|
|
14
|
+
} from "./speech";
|
|
15
|
+
|
|
16
|
+
// Feedback adapter
|
|
17
|
+
export type { FeedbackAdapter } from "./feedback";
|
|
18
|
+
|
|
19
|
+
// Suggestion adapter
|
|
20
|
+
export type { SuggestionAdapter } from "./suggestion";
|
|
21
|
+
|
|
22
|
+
// Mention adapter
|
|
23
|
+
export type { Unstable_MentionAdapter } from "./mention";
|
|
24
|
+
export { unstable_defaultDirectiveFormatter } from "./mention";
|
|
25
|
+
|
|
26
|
+
// Thread history adapters
|
|
27
|
+
export type {
|
|
28
|
+
ThreadHistoryAdapter,
|
|
29
|
+
GenericThreadHistoryAdapter,
|
|
30
|
+
MessageFormatAdapter,
|
|
31
|
+
MessageFormatItem,
|
|
32
|
+
MessageFormatRepository,
|
|
33
|
+
MessageStorageEntry,
|
|
34
|
+
} from "./thread-history";
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Unstable_MentionCategory,
|
|
3
|
+
Unstable_MentionItem,
|
|
4
|
+
Unstable_DirectiveSegment,
|
|
5
|
+
Unstable_DirectiveFormatter,
|
|
6
|
+
} from "../types/mention";
|
|
7
|
+
|
|
8
|
+
// =============================================================================
|
|
9
|
+
// Mention Adapter
|
|
10
|
+
// =============================================================================
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Adapter for providing mention categories and items to the mention picker.
|
|
14
|
+
*
|
|
15
|
+
* All methods are synchronous by design — the adapter drives UI display and
|
|
16
|
+
* must return data immediately. Use external state management (e.g. React
|
|
17
|
+
* Query, SWR, or local state) to handle async data fetching, then expose
|
|
18
|
+
* the loaded results synchronously through this adapter.
|
|
19
|
+
*/
|
|
20
|
+
export type Unstable_MentionAdapter = {
|
|
21
|
+
/** Return the top-level categories for the mention picker. */
|
|
22
|
+
categories(): readonly Unstable_MentionCategory[];
|
|
23
|
+
|
|
24
|
+
/** Return items within a category. */
|
|
25
|
+
categoryItems(categoryId: string): readonly Unstable_MentionItem[];
|
|
26
|
+
|
|
27
|
+
/** Global search across all categories (optional). */
|
|
28
|
+
search?(query: string): readonly Unstable_MentionItem[];
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// =============================================================================
|
|
32
|
+
// Default Directive Formatter
|
|
33
|
+
// =============================================================================
|
|
34
|
+
|
|
35
|
+
const DIRECTIVE_RE = /:([\w-]+)\[([^\]]+)\](?:\{name=([^}]+)\})?/g;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Default directive formatter using the `:type[label]{name=id}` syntax.
|
|
39
|
+
*
|
|
40
|
+
* When `id` equals `label`, the `{name=…}` attribute is omitted for brevity.
|
|
41
|
+
*/
|
|
42
|
+
export const unstable_defaultDirectiveFormatter: Unstable_DirectiveFormatter = {
|
|
43
|
+
serialize(item: Unstable_MentionItem): string {
|
|
44
|
+
const attrs = item.id !== item.label ? `{name=${item.id}}` : "";
|
|
45
|
+
return `:${item.type}[${item.label}]${attrs}`;
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
parse(text: string): Unstable_DirectiveSegment[] {
|
|
49
|
+
const segments: Unstable_DirectiveSegment[] = [];
|
|
50
|
+
let lastIndex = 0;
|
|
51
|
+
|
|
52
|
+
DIRECTIVE_RE.lastIndex = 0;
|
|
53
|
+
let match: RegExpExecArray | null;
|
|
54
|
+
while ((match = DIRECTIVE_RE.exec(text)) !== null) {
|
|
55
|
+
if (match.index > lastIndex) {
|
|
56
|
+
segments.push({
|
|
57
|
+
kind: "text",
|
|
58
|
+
text: text.slice(lastIndex, match.index),
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
const label = match[2]!;
|
|
62
|
+
segments.push({
|
|
63
|
+
kind: "mention",
|
|
64
|
+
type: match[1]!,
|
|
65
|
+
label,
|
|
66
|
+
id: match[3] ?? label,
|
|
67
|
+
});
|
|
68
|
+
lastIndex = DIRECTIVE_RE.lastIndex;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (lastIndex < text.length) {
|
|
72
|
+
segments.push({ kind: "text", text: text.slice(lastIndex) });
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return segments;
|
|
76
|
+
},
|
|
77
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -43,6 +43,13 @@ export type { Unsubscribe } from "./types/unsubscribe";
|
|
|
43
43
|
|
|
44
44
|
export type { QuoteInfo } from "./types/quote";
|
|
45
45
|
|
|
46
|
+
export type {
|
|
47
|
+
Unstable_MentionItem,
|
|
48
|
+
Unstable_MentionCategory,
|
|
49
|
+
Unstable_DirectiveSegment,
|
|
50
|
+
Unstable_DirectiveFormatter,
|
|
51
|
+
} from "./types/mention";
|
|
52
|
+
|
|
46
53
|
// === model-context ===
|
|
47
54
|
|
|
48
55
|
export type {
|
|
@@ -103,6 +110,10 @@ export type { FeedbackAdapter } from "./adapters/feedback";
|
|
|
103
110
|
// Suggestion adapter
|
|
104
111
|
export type { SuggestionAdapter } from "./adapters/suggestion";
|
|
105
112
|
|
|
113
|
+
// Mention adapter
|
|
114
|
+
export type { Unstable_MentionAdapter } from "./adapters/mention";
|
|
115
|
+
export { unstable_defaultDirectiveFormatter } from "./adapters/mention";
|
|
116
|
+
|
|
106
117
|
// Thread history adapters
|
|
107
118
|
export type {
|
|
108
119
|
ThreadHistoryAdapter,
|
|
@@ -13,15 +13,13 @@ export const RuntimeAdapter = resource((runtime: AssistantRuntime) =>
|
|
|
13
13
|
);
|
|
14
14
|
|
|
15
15
|
attachTransformScopes(RuntimeAdapter, (scopes, parent) => {
|
|
16
|
-
|
|
16
|
+
baseRuntimeAdapterTransformScopes(scopes, parent);
|
|
17
17
|
|
|
18
|
-
if (!
|
|
19
|
-
|
|
18
|
+
if (!scopes.tools && parent.tools.source === null) {
|
|
19
|
+
scopes.tools = Tools({});
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
if (!
|
|
23
|
-
|
|
22
|
+
if (!scopes.dataRenderers && parent.dataRenderers.source === null) {
|
|
23
|
+
scopes.dataRenderers = DataRenderers();
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
return result;
|
|
27
25
|
});
|