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