@scalar/agent-chat 0.5.17 → 0.7.0
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 +4 -1
- package/dist/App.vue.d.ts.map +1 -1
- package/dist/App.vue.js +13 -11
- 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 +5 -2
- package/dist/state/state.d.ts.map +1 -1
- package/dist/state/state.js +140 -131
- 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 +132 -122
- 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 +7 -7
package/dist/state/state.js
CHANGED
|
@@ -1,189 +1,198 @@
|
|
|
1
|
-
import { Chat as
|
|
2
|
-
import { useModal as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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";
|
|
4
|
+
import { apiReferenceConfigurationSchema as q } from "@scalar/types/api-reference";
|
|
5
|
+
import { useToasts as z } from "@scalar/use-toasts";
|
|
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,
|
|
63
|
+
hideAddApi: M
|
|
59
64
|
}) {
|
|
60
|
-
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({
|
|
61
66
|
plugins: [
|
|
62
|
-
|
|
67
|
+
ct({
|
|
63
68
|
persistAuth: !0
|
|
64
69
|
})
|
|
65
70
|
]
|
|
66
|
-
}),
|
|
67
|
-
() =>
|
|
68
|
-
proxyUrl:
|
|
71
|
+
}), _ = $(
|
|
72
|
+
() => q.parse({
|
|
73
|
+
proxyUrl: p.value,
|
|
69
74
|
persistAuth: !0
|
|
70
75
|
})
|
|
71
|
-
),
|
|
72
|
-
registryDocuments:
|
|
73
|
-
workspaceStore:
|
|
74
|
-
baseUrl:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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")
|
|
83
90
|
);
|
|
84
|
-
|
|
85
|
-
() =>
|
|
91
|
+
L(
|
|
92
|
+
() => c.status,
|
|
86
93
|
() => {
|
|
87
|
-
|
|
94
|
+
c.status === "streaming" && (v.value = "");
|
|
88
95
|
}
|
|
89
|
-
),
|
|
90
|
-
t && (
|
|
96
|
+
), S && L(S, async (t) => {
|
|
97
|
+
t && (v.value = t, b.accepted.value && await c.sendMessage({ text: v.value }));
|
|
91
98
|
});
|
|
92
|
-
const
|
|
99
|
+
const W = k();
|
|
93
100
|
async function g({
|
|
94
101
|
namespace: t,
|
|
95
102
|
slug: o,
|
|
96
|
-
removable:
|
|
103
|
+
removable: u = !0
|
|
97
104
|
}) {
|
|
98
|
-
if (
|
|
105
|
+
if (n.value.find((e) => e.namespace === t && e.slug === o))
|
|
99
106
|
return;
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
const
|
|
107
|
+
const h = `@${t}/${o}`;
|
|
108
|
+
f[h] = !0;
|
|
109
|
+
const d = await N({
|
|
103
110
|
namespace: t,
|
|
104
111
|
slug: o,
|
|
105
|
-
workspaceStore:
|
|
106
|
-
registryUrl:
|
|
107
|
-
registryDocuments:
|
|
108
|
-
config:
|
|
109
|
-
api:
|
|
110
|
-
removable:
|
|
112
|
+
workspaceStore: l,
|
|
113
|
+
registryUrl: i,
|
|
114
|
+
registryDocuments: n,
|
|
115
|
+
config: _.value,
|
|
116
|
+
api: A,
|
|
117
|
+
removable: u
|
|
111
118
|
});
|
|
112
|
-
if (
|
|
113
|
-
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;
|
|
114
121
|
}
|
|
115
|
-
async function
|
|
122
|
+
async function Y({
|
|
116
123
|
namespace: t,
|
|
117
124
|
slug: o,
|
|
118
|
-
removable:
|
|
125
|
+
removable: u = !0
|
|
119
126
|
}) {
|
|
120
|
-
if (
|
|
127
|
+
if (n.value.find((e) => e.namespace === t && e.slug === o))
|
|
121
128
|
return;
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
const
|
|
125
|
-
() => 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}`), {
|
|
126
133
|
method: "GET"
|
|
127
134
|
}),
|
|
128
|
-
(e) =>
|
|
135
|
+
(e) => it("FAILED_TO_GET_EMBEDDING_STATUS", e)
|
|
129
136
|
);
|
|
130
|
-
if (
|
|
131
|
-
const e = await
|
|
137
|
+
if (d.success && d.data.ok) {
|
|
138
|
+
const e = await N({
|
|
132
139
|
namespace: t,
|
|
133
140
|
slug: o,
|
|
134
|
-
workspaceStore:
|
|
135
|
-
registryUrl:
|
|
136
|
-
registryDocuments:
|
|
137
|
-
config:
|
|
138
|
-
api:
|
|
139
|
-
removable:
|
|
141
|
+
workspaceStore: l,
|
|
142
|
+
registryUrl: i,
|
|
143
|
+
registryDocuments: n,
|
|
144
|
+
config: _.value,
|
|
145
|
+
api: A,
|
|
146
|
+
removable: u
|
|
140
147
|
});
|
|
141
148
|
e.success || (console.warn("[AGENT]: Unable to load document", e.error), y(`Unable to load the document @${t}/${o}`, "warn"));
|
|
142
149
|
} else
|
|
143
150
|
console.warn("[AGENT]: Document could not be embedded"), y(`Unable to embed the document @${t}/${o}`, "warn");
|
|
144
|
-
|
|
151
|
+
f[h] = !1;
|
|
145
152
|
}
|
|
146
|
-
function
|
|
147
|
-
|
|
148
|
-
(
|
|
149
|
-
),
|
|
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));
|
|
150
157
|
}
|
|
151
|
-
return
|
|
152
|
-
prompt:
|
|
153
|
-
chat:
|
|
154
|
-
workspaceStore:
|
|
155
|
-
eventBus:
|
|
156
|
-
loading:
|
|
157
|
-
settingsModal:
|
|
158
|
-
config:
|
|
159
|
-
registryUrl:
|
|
158
|
+
return s.forEach(({ namespace: t, slug: o }) => g({ namespace: t, slug: o, removable: !1 })), {
|
|
159
|
+
prompt: v,
|
|
160
|
+
chat: c,
|
|
161
|
+
workspaceStore: l,
|
|
162
|
+
eventBus: B,
|
|
163
|
+
loading: P,
|
|
164
|
+
settingsModal: W,
|
|
165
|
+
config: _,
|
|
166
|
+
registryUrl: i,
|
|
160
167
|
dashboardUrl: E,
|
|
161
|
-
baseUrl:
|
|
162
|
-
registryDocuments:
|
|
163
|
-
pendingDocuments:
|
|
164
|
-
proxyUrl:
|
|
168
|
+
baseUrl: a,
|
|
169
|
+
registryDocuments: n,
|
|
170
|
+
pendingDocuments: f,
|
|
171
|
+
proxyUrl: p,
|
|
172
|
+
proxyUrlRaw: U,
|
|
165
173
|
mode: T,
|
|
166
174
|
terms: b,
|
|
167
|
-
isLoggedIn:
|
|
175
|
+
isLoggedIn: w,
|
|
168
176
|
addDocument: g,
|
|
169
|
-
addDocumentAsync:
|
|
170
|
-
removeDocument:
|
|
171
|
-
getAccessToken:
|
|
172
|
-
getAgentKey:
|
|
173
|
-
api:
|
|
177
|
+
addDocumentAsync: Y,
|
|
178
|
+
removeDocument: F,
|
|
179
|
+
getAccessToken: m,
|
|
180
|
+
getAgentKey: r,
|
|
181
|
+
api: A,
|
|
174
182
|
uploadedTmpDocumentUrl: G,
|
|
175
|
-
curatedDocuments:
|
|
176
|
-
getActiveDocumentJson: I
|
|
183
|
+
curatedDocuments: O,
|
|
184
|
+
getActiveDocumentJson: I,
|
|
185
|
+
hideAddApi: M
|
|
177
186
|
};
|
|
178
187
|
}
|
|
179
|
-
function
|
|
180
|
-
const
|
|
181
|
-
if (!
|
|
188
|
+
function Nt() {
|
|
189
|
+
const s = tt(mt);
|
|
190
|
+
if (!s)
|
|
182
191
|
throw new Error("No state provided.");
|
|
183
|
-
return
|
|
192
|
+
return s;
|
|
184
193
|
}
|
|
185
194
|
export {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
195
|
+
mt as STATE_SYMBOL,
|
|
196
|
+
Ct as createState,
|
|
197
|
+
Nt as useState
|
|
189
198
|
};
|