@scalar/agent-chat 0.5.18 → 0.7.1
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/App.vue.d.ts +2 -1
- package/dist/App.vue.d.ts.map +1 -1
- package/dist/api.d.ts +3 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +54 -53
- package/dist/client-tools/execute-request.d.ts +1 -0
- package/dist/client-tools/execute-request.d.ts.map +1 -1
- package/dist/client-tools/execute-request.js +33 -27
- package/dist/components/FreeMessagesInfoSection.vue.d.ts.map +1 -1
- package/dist/components/FreeMessagesInfoSection.vue.js +1 -1
- package/dist/components/FreeMessagesInfoSection.vue2.js +27 -25
- package/dist/components/PaymentSection.vue.d.ts.map +1 -1
- package/dist/components/PaymentSection.vue.js +1 -1
- package/dist/components/PaymentSection.vue2.js +16 -20
- package/dist/components/ServerSelector.vue.d.ts.map +1 -1
- package/dist/components/ServerSelector.vue.js +27 -21
- package/dist/components/UploadSection.vue.js +2 -2
- package/dist/components/UploadSection.vue2.js +13 -13
- package/dist/consts/urls.d.ts +8 -0
- package/dist/consts/urls.d.ts.map +1 -0
- package/dist/consts/urls.js +10 -0
- package/dist/helpers.d.ts +4 -10
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +34 -45
- package/dist/hooks/use-agent-key-documents.js +6 -6
- package/dist/hooks/use-chat-approvals.d.ts.map +1 -1
- package/dist/hooks/use-chat-approvals.js +7 -6
- package/dist/hooks/use-signup-link.d.ts +12 -0
- package/dist/hooks/use-signup-link.d.ts.map +1 -0
- package/dist/hooks/use-signup-link.js +12 -0
- package/dist/hooks/use-upload-tmp-document.d.ts +3 -0
- package/dist/hooks/use-upload-tmp-document.d.ts.map +1 -1
- package/dist/hooks/use-upload-tmp-document.js +31 -28
- package/dist/package.json +1 -1
- package/dist/state/state.d.ts +2 -1
- package/dist/state/state.d.ts.map +1 -1
- package/dist/state/state.js +134 -127
- package/dist/style.css +1 -1
- package/dist/views/Chat/Messages/AskForAuthentication.vue.js +1 -1
- package/dist/views/Chat/Messages/AskForAuthentication.vue2.js +12 -12
- package/dist/views/PromptForm.vue.d.ts.map +1 -1
- package/dist/views/PromptForm.vue.js +2 -2
- package/dist/views/PromptForm.vue2.js +100 -93
- package/dist/views/Settings/DocSettings.vue.js +1 -1
- package/dist/views/Settings/DocSettings.vue2.js +10 -10
- package/dist/views/Settings/Settings.vue.d.ts.map +1 -1
- package/dist/views/Settings/Settings.vue.js +2 -2
- package/dist/views/Settings/Settings.vue2.js +53 -43
- package/dist/views/Start.vue.d.ts.map +1 -1
- package/dist/views/Start.vue.js +1 -1
- package/dist/views/Start.vue2.js +28 -27
- package/package.json +8 -8
package/dist/state/state.js
CHANGED
|
@@ -1,191 +1,198 @@
|
|
|
1
|
-
import { Chat as
|
|
2
|
-
import { useModal as
|
|
1
|
+
import { Chat as j } from "@ai-sdk/vue";
|
|
2
|
+
import { useModal as k } from "@scalar/components";
|
|
3
|
+
import { redirectToProxy as x } from "@scalar/helpers/url/redirect-to-proxy";
|
|
3
4
|
import { apiReferenceConfigurationSchema as q } from "@scalar/types/api-reference";
|
|
4
5
|
import { useToasts as z } from "@scalar/use-toasts";
|
|
5
|
-
import { createWorkspaceStore as
|
|
6
|
-
import { createWorkspaceEventBus as
|
|
7
|
-
import { DefaultChatTransport as
|
|
8
|
-
import { n as
|
|
9
|
-
import { ref as
|
|
10
|
-
import { createApi as
|
|
11
|
-
import { executeRequestTool as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
6
|
+
import { createWorkspaceStore as H } from "@scalar/workspace-store/client";
|
|
7
|
+
import { createWorkspaceEventBus as Q } from "@scalar/workspace-store/events";
|
|
8
|
+
import { DefaultChatTransport as J, lastAssistantMessageIsCompleteWithToolCalls as V } from "ai";
|
|
9
|
+
import { n as Z } from "neverpanic";
|
|
10
|
+
import { ref as D, reactive as K, computed as $, watch as L, inject as tt } from "vue";
|
|
11
|
+
import { createApi as ot, createAuthorizationHeaders as et } from "../api.js";
|
|
12
|
+
import { executeRequestTool as rt } from "../client-tools/execute-request.js";
|
|
13
|
+
import { URLS as R } from "../consts/urls.js";
|
|
14
|
+
import { EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME as nt } from "../entities/tools/execute-request.js";
|
|
15
|
+
import { createDocumentSettings as C } from "../helpers.js";
|
|
16
|
+
import { useTermsAndConditions as at } from "../hooks/use-term-and-conditions.js";
|
|
17
|
+
import { persistencePlugin as ct } from "../plugins/persistance.js";
|
|
18
|
+
import { loadDocument as N } from "../registry/add-documents-to-store.js";
|
|
19
|
+
import { createDocumentName as st } from "../registry/create-document-name.js";
|
|
20
|
+
import { createError as it } from "../entities/error/helpers.js";
|
|
21
|
+
const mt = /* @__PURE__ */ Symbol("STATE_SYMBOL"), { toast: y } = z();
|
|
22
|
+
function ut({
|
|
23
|
+
registryDocuments: s,
|
|
24
|
+
workspaceStore: i,
|
|
23
25
|
baseUrl: E,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
proxyUrl: a,
|
|
27
|
+
getAccessToken: T,
|
|
28
|
+
getAgentKey: w
|
|
26
29
|
}) {
|
|
27
|
-
const
|
|
28
|
-
sendAutomaticallyWhen:
|
|
29
|
-
transport: new
|
|
30
|
-
api:
|
|
31
|
-
headers: () =>
|
|
30
|
+
const m = new j({
|
|
31
|
+
sendAutomaticallyWhen: V,
|
|
32
|
+
transport: new J({
|
|
33
|
+
api: x(a.value, `${E}/vector/openapi/chat`),
|
|
34
|
+
headers: () => et({ getAccessToken: T, getAgentKey: w }),
|
|
32
35
|
body: () => ({
|
|
33
|
-
registryDocuments:
|
|
34
|
-
documentSettings:
|
|
36
|
+
registryDocuments: s.value,
|
|
37
|
+
documentSettings: C(i)
|
|
35
38
|
})
|
|
36
39
|
}),
|
|
37
|
-
async onToolCall({ toolCall:
|
|
38
|
-
|
|
39
|
-
documentSettings:
|
|
40
|
-
input:
|
|
41
|
-
toolCallId:
|
|
42
|
-
chat:
|
|
40
|
+
async onToolCall({ toolCall: r }) {
|
|
41
|
+
r.dynamic || r.toolName === nt && r.input.method.toLowerCase() === "get" && await rt({
|
|
42
|
+
documentSettings: C(i),
|
|
43
|
+
input: r.input,
|
|
44
|
+
toolCallId: r.toolCallId,
|
|
45
|
+
chat: m,
|
|
46
|
+
proxyUrl: a.value
|
|
43
47
|
});
|
|
44
48
|
}
|
|
45
49
|
});
|
|
46
|
-
return
|
|
50
|
+
return m;
|
|
47
51
|
}
|
|
48
|
-
function
|
|
49
|
-
initialRegistryDocuments:
|
|
50
|
-
registryUrl:
|
|
52
|
+
function Ct({
|
|
53
|
+
initialRegistryDocuments: s,
|
|
54
|
+
registryUrl: i,
|
|
51
55
|
dashboardUrl: E,
|
|
52
|
-
baseUrl:
|
|
56
|
+
baseUrl: a,
|
|
53
57
|
mode: T,
|
|
54
|
-
isLoggedIn:
|
|
55
|
-
getAccessToken:
|
|
56
|
-
getAgentKey:
|
|
58
|
+
isLoggedIn: w,
|
|
59
|
+
getAccessToken: m,
|
|
60
|
+
getAgentKey: r,
|
|
57
61
|
getActiveDocumentJson: I,
|
|
58
|
-
prefilledMessageRef:
|
|
62
|
+
prefilledMessageRef: S,
|
|
59
63
|
hideAddApi: M
|
|
60
64
|
}) {
|
|
61
|
-
const
|
|
65
|
+
const v = D(S?.value ?? ""), n = D([]), f = K({}), O = D([]), U = D(R.DEFAULT_PROXY_URL), p = $(() => U.value?.trim() || R.DEFAULT_PROXY_URL), G = D(), b = at(), B = Q(), l = H({
|
|
62
66
|
plugins: [
|
|
63
|
-
|
|
67
|
+
ct({
|
|
64
68
|
persistAuth: !0
|
|
65
69
|
})
|
|
66
70
|
]
|
|
67
|
-
}),
|
|
71
|
+
}), _ = $(
|
|
68
72
|
() => q.parse({
|
|
69
|
-
proxyUrl:
|
|
73
|
+
proxyUrl: p.value,
|
|
70
74
|
persistAuth: !0
|
|
71
75
|
})
|
|
72
|
-
),
|
|
73
|
-
registryDocuments:
|
|
74
|
-
workspaceStore:
|
|
75
|
-
baseUrl:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
76
|
+
), c = ut({
|
|
77
|
+
registryDocuments: n,
|
|
78
|
+
workspaceStore: l,
|
|
79
|
+
baseUrl: a,
|
|
80
|
+
proxyUrl: p,
|
|
81
|
+
getAccessToken: m,
|
|
82
|
+
getAgentKey: r
|
|
83
|
+
}), A = ot({
|
|
84
|
+
baseUrl: a,
|
|
85
|
+
proxyUrl: p,
|
|
86
|
+
getAccessToken: m,
|
|
87
|
+
getAgentKey: r
|
|
88
|
+
}), P = $(
|
|
89
|
+
() => c.status === "submitted" || c.status === "streaming" && !c.lastMessage?.parts.some((t) => t.type === "text")
|
|
84
90
|
);
|
|
85
|
-
|
|
86
|
-
() =>
|
|
91
|
+
L(
|
|
92
|
+
() => c.status,
|
|
87
93
|
() => {
|
|
88
|
-
|
|
94
|
+
c.status === "streaming" && (v.value = "");
|
|
89
95
|
}
|
|
90
|
-
),
|
|
91
|
-
t && (
|
|
96
|
+
), S && L(S, async (t) => {
|
|
97
|
+
t && (v.value = t, b.accepted.value && await c.sendMessage({ text: v.value }));
|
|
92
98
|
});
|
|
93
|
-
const
|
|
99
|
+
const W = k();
|
|
94
100
|
async function g({
|
|
95
101
|
namespace: t,
|
|
96
102
|
slug: o,
|
|
97
|
-
removable:
|
|
103
|
+
removable: u = !0
|
|
98
104
|
}) {
|
|
99
|
-
if (
|
|
105
|
+
if (n.value.find((e) => e.namespace === t && e.slug === o))
|
|
100
106
|
return;
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
const
|
|
107
|
+
const h = `@${t}/${o}`;
|
|
108
|
+
f[h] = !0;
|
|
109
|
+
const d = await N({
|
|
104
110
|
namespace: t,
|
|
105
111
|
slug: o,
|
|
106
|
-
workspaceStore:
|
|
107
|
-
registryUrl:
|
|
108
|
-
registryDocuments:
|
|
109
|
-
config:
|
|
110
|
-
api:
|
|
111
|
-
removable:
|
|
112
|
+
workspaceStore: l,
|
|
113
|
+
registryUrl: i,
|
|
114
|
+
registryDocuments: n,
|
|
115
|
+
config: _.value,
|
|
116
|
+
api: A,
|
|
117
|
+
removable: u
|
|
112
118
|
});
|
|
113
|
-
if (
|
|
114
|
-
throw console.warn("[AGENT]: Unable to load document",
|
|
119
|
+
if (f[h] = !1, !d.success)
|
|
120
|
+
throw console.warn("[AGENT]: Unable to load document", d.error), y(`Unable to load the document @${t}/${o}`, "warn"), d.error;
|
|
115
121
|
}
|
|
116
|
-
async function
|
|
122
|
+
async function Y({
|
|
117
123
|
namespace: t,
|
|
118
124
|
slug: o,
|
|
119
|
-
removable:
|
|
125
|
+
removable: u = !0
|
|
120
126
|
}) {
|
|
121
|
-
if (
|
|
127
|
+
if (n.value.find((e) => e.namespace === t && e.slug === o))
|
|
122
128
|
return;
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
() => fetch(
|
|
129
|
+
const h = `@${t}/${o}`;
|
|
130
|
+
f[h] = !0;
|
|
131
|
+
const d = await Z.fromUnsafe(
|
|
132
|
+
() => fetch(x(p.value, `${a}/vector/registry/embeddings/${t}/${o}`), {
|
|
127
133
|
method: "GET"
|
|
128
134
|
}),
|
|
129
|
-
(e) =>
|
|
135
|
+
(e) => it("FAILED_TO_GET_EMBEDDING_STATUS", e)
|
|
130
136
|
);
|
|
131
|
-
if (
|
|
132
|
-
const e = await
|
|
137
|
+
if (d.success && d.data.ok) {
|
|
138
|
+
const e = await N({
|
|
133
139
|
namespace: t,
|
|
134
140
|
slug: o,
|
|
135
|
-
workspaceStore:
|
|
136
|
-
registryUrl:
|
|
137
|
-
registryDocuments:
|
|
138
|
-
config:
|
|
139
|
-
api:
|
|
140
|
-
removable:
|
|
141
|
+
workspaceStore: l,
|
|
142
|
+
registryUrl: i,
|
|
143
|
+
registryDocuments: n,
|
|
144
|
+
config: _.value,
|
|
145
|
+
api: A,
|
|
146
|
+
removable: u
|
|
141
147
|
});
|
|
142
148
|
e.success || (console.warn("[AGENT]: Unable to load document", e.error), y(`Unable to load the document @${t}/${o}`, "warn"));
|
|
143
149
|
} else
|
|
144
150
|
console.warn("[AGENT]: Document could not be embedded"), y(`Unable to embed the document @${t}/${o}`, "warn");
|
|
145
|
-
|
|
151
|
+
f[h] = !1;
|
|
146
152
|
}
|
|
147
|
-
function
|
|
148
|
-
|
|
149
|
-
(
|
|
150
|
-
),
|
|
153
|
+
function F({ namespace: t, slug: o }) {
|
|
154
|
+
n.value = n.value.filter(
|
|
155
|
+
(u) => !(u.namespace === t && u.slug === o)
|
|
156
|
+
), l.deleteDocument(st(t, o));
|
|
151
157
|
}
|
|
152
|
-
return
|
|
153
|
-
prompt:
|
|
154
|
-
chat:
|
|
155
|
-
workspaceStore:
|
|
158
|
+
return s.forEach(({ namespace: t, slug: o }) => g({ namespace: t, slug: o, removable: !1 })), {
|
|
159
|
+
prompt: v,
|
|
160
|
+
chat: c,
|
|
161
|
+
workspaceStore: l,
|
|
156
162
|
eventBus: B,
|
|
157
|
-
loading:
|
|
158
|
-
settingsModal:
|
|
159
|
-
config:
|
|
160
|
-
registryUrl:
|
|
163
|
+
loading: P,
|
|
164
|
+
settingsModal: W,
|
|
165
|
+
config: _,
|
|
166
|
+
registryUrl: i,
|
|
161
167
|
dashboardUrl: E,
|
|
162
|
-
baseUrl:
|
|
163
|
-
registryDocuments:
|
|
164
|
-
pendingDocuments:
|
|
165
|
-
proxyUrl:
|
|
168
|
+
baseUrl: a,
|
|
169
|
+
registryDocuments: n,
|
|
170
|
+
pendingDocuments: f,
|
|
171
|
+
proxyUrl: p,
|
|
172
|
+
proxyUrlRaw: U,
|
|
166
173
|
mode: T,
|
|
167
174
|
terms: b,
|
|
168
|
-
isLoggedIn:
|
|
175
|
+
isLoggedIn: w,
|
|
169
176
|
addDocument: g,
|
|
170
|
-
addDocumentAsync:
|
|
171
|
-
removeDocument:
|
|
172
|
-
getAccessToken:
|
|
173
|
-
getAgentKey:
|
|
174
|
-
api:
|
|
175
|
-
uploadedTmpDocumentUrl:
|
|
176
|
-
curatedDocuments:
|
|
177
|
+
addDocumentAsync: Y,
|
|
178
|
+
removeDocument: F,
|
|
179
|
+
getAccessToken: m,
|
|
180
|
+
getAgentKey: r,
|
|
181
|
+
api: A,
|
|
182
|
+
uploadedTmpDocumentUrl: G,
|
|
183
|
+
curatedDocuments: O,
|
|
177
184
|
getActiveDocumentJson: I,
|
|
178
185
|
hideAddApi: M
|
|
179
186
|
};
|
|
180
187
|
}
|
|
181
|
-
function
|
|
182
|
-
const
|
|
183
|
-
if (!
|
|
188
|
+
function Nt() {
|
|
189
|
+
const s = tt(mt);
|
|
190
|
+
if (!s)
|
|
184
191
|
throw new Error("No state provided.");
|
|
185
|
-
return
|
|
192
|
+
return s;
|
|
186
193
|
}
|
|
187
194
|
export {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
195
|
+
mt as STATE_SYMBOL,
|
|
196
|
+
Ct as createState,
|
|
197
|
+
Nt as useState
|
|
191
198
|
};
|