@lunora/vue 1.0.0-alpha.38 → 1.0.0-alpha.39
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.mjs
CHANGED
|
@@ -2,7 +2,7 @@ export { AuthLoading, Authenticated, Unauthenticated } from './packem_shared/Aut
|
|
|
2
2
|
export { hydratePreloaded } from './packem_shared/hydratePreloaded-Cnd2GmG1.mjs';
|
|
3
3
|
export { LUNORA_INJECTION_KEY, createLunora, provideLunora, useLunora } from './packem_shared/LUNORA_INJECTION_KEY-DQM5MgsC.mjs';
|
|
4
4
|
export { useAgent } from './packem_shared/useAgent-TEp9OWs3.mjs';
|
|
5
|
-
export { useAgentChat } from './packem_shared/useAgentChat-
|
|
5
|
+
export { useAgentChat } from './packem_shared/useAgentChat-DQmekE-E.mjs';
|
|
6
6
|
export { useAgentState } from './packem_shared/useAgentState-CeDpLTib.mjs';
|
|
7
7
|
export { useAgentToolEvents } from './packem_shared/useAgentToolEvents-DfCy9INR.mjs';
|
|
8
8
|
export { useAuth } from './packem_shared/useAuth-yXaaF-ro.mjs';
|
|
@@ -6,12 +6,15 @@ import { useSubscription } from './useSubscription-B2s-lc5e.mjs';
|
|
|
6
6
|
|
|
7
7
|
const NO_STREAM_REF = { __lunoraRef: "" };
|
|
8
8
|
const reconcileOptimistic = (optimistic, durable) => {
|
|
9
|
-
const
|
|
9
|
+
const durableUserRows = durable.filter((message) => message.role === "user");
|
|
10
|
+
const consumed = /* @__PURE__ */ new Set();
|
|
10
11
|
return optimistic.filter((pending) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
for (let index = pending.durableUserCountAtSend; index < durableUserRows.length; index += 1) {
|
|
13
|
+
const row = durableUserRows[index];
|
|
14
|
+
if (row !== void 0 && !consumed.has(index) && row.content === pending.content) {
|
|
15
|
+
consumed.add(index);
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
15
18
|
}
|
|
16
19
|
return true;
|
|
17
20
|
});
|
|
@@ -43,6 +46,12 @@ const useAgentChat = (options) => {
|
|
|
43
46
|
if (visible.length === 0) {
|
|
44
47
|
return rows;
|
|
45
48
|
}
|
|
49
|
+
let maxDurableSeq = -1;
|
|
50
|
+
for (const message of rows) {
|
|
51
|
+
if (message.seq > maxDurableSeq) {
|
|
52
|
+
maxDurableSeq = message.seq;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
46
55
|
return [
|
|
47
56
|
...rows,
|
|
48
57
|
...visible.map((pending, index) => {
|
|
@@ -50,7 +59,7 @@ const useAgentChat = (options) => {
|
|
|
50
59
|
content: pending.content,
|
|
51
60
|
optimistic: true,
|
|
52
61
|
role: "user",
|
|
53
|
-
seq:
|
|
62
|
+
seq: maxDurableSeq + 1 + index
|
|
54
63
|
};
|
|
55
64
|
})
|
|
56
65
|
];
|
|
@@ -63,8 +72,14 @@ const useAgentChat = (options) => {
|
|
|
63
72
|
const send = async (input, arguments_) => {
|
|
64
73
|
const id = nextId;
|
|
65
74
|
nextId += 1;
|
|
66
|
-
|
|
67
|
-
|
|
75
|
+
const durableUserCountAtSend = durable.value.filter((message) => message.role === "user").length;
|
|
76
|
+
optimistic.value = [...reconcileOptimistic(optimistic.value, durable.value), { content: input, durableUserCountAtSend, id }];
|
|
77
|
+
try {
|
|
78
|
+
await sendMutation.mutate({ input, threadKey: toValue(threadKey), ...sendArgs, ...arguments_ });
|
|
79
|
+
} catch (error) {
|
|
80
|
+
optimistic.value = optimistic.value.filter((pending) => pending.id !== id);
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
68
83
|
};
|
|
69
84
|
const approve = async (toolCallId, note) => {
|
|
70
85
|
const instanceId = thread.value?.instanceId;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/vue",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.39",
|
|
4
4
|
"description": "Vue adapter for Lunora — live composables, optimistic mutations, and reactive loaders",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@lunora/client": "1.0.0-alpha.
|
|
57
|
+
"@lunora/client": "1.0.0-alpha.24",
|
|
58
58
|
"@lunora/errors": "1.0.0-alpha.5",
|
|
59
59
|
"@lunora/ratelimit": "1.0.0-alpha.8",
|
|
60
60
|
"@lunora/runtime": "1.0.0-alpha.28"
|