@scalar/agent-chat 0.5.17 → 0.5.18
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 -0
- package/dist/App.vue.d.ts.map +1 -1
- package/dist/App.vue.js +13 -11
- package/dist/package.json +1 -1
- package/dist/state/state.d.ts +3 -1
- package/dist/state/state.d.ts.map +1 -1
- package/dist/state/state.js +52 -50
- package/dist/style.css +1 -1
- package/dist/views/PromptForm.vue.d.ts.map +1 -1
- package/dist/views/PromptForm.vue.js +1 -1
- package/dist/views/PromptForm.vue2.js +129 -126
- package/package.json +7 -7
|
@@ -1,44 +1,47 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { ScalarIconButton as
|
|
3
|
-
import { ScalarIconPlus as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import { AgentErrorCodes as
|
|
12
|
-
import { MAX_PROMPT_SIZE as
|
|
13
|
-
import { useRequestApprovals as
|
|
14
|
-
import { useChatError as
|
|
15
|
-
import { useChatPendingClientToolParts as
|
|
1
|
+
import { defineComponent as q, useTemplateRef as K, computed as d, watch as w, createElementBlock as r, openBlock as o, createBlock as u, createCommentVNode as a, createElementVNode as l, unref as e, withModifiers as j, withDirectives as J, vModelText as O, Fragment as f, withCtx as S, createVNode as g, renderList as C, createTextVNode as P, toDisplayString as X } from "vue";
|
|
2
|
+
import { ScalarIconButton as T, ScalarLoading as Z } from "@scalar/components";
|
|
3
|
+
import { ScalarIconPlus as I, ScalarIconX as G, ScalarIconLockSimple as Q, ScalarIconCheck as W, ScalarIconArrowUp as Y } from "@scalar/icons";
|
|
4
|
+
import ee from "../components/ActionsDropdown.vue.js";
|
|
5
|
+
import te from "../components/ApprovalSection.vue.js";
|
|
6
|
+
import oe from "../components/ErrorMessage.vue.js";
|
|
7
|
+
import se from "../components/FreeMessagesInfoSection.vue.js";
|
|
8
|
+
import ne from "../components/PaymentSection.vue.js";
|
|
9
|
+
import le from "../components/SearchPopover.vue.js";
|
|
10
|
+
import ae from "../components/UploadSection.vue.js";
|
|
11
|
+
import { AgentErrorCodes as x } from "../entities/error/constants.js";
|
|
12
|
+
import { MAX_PROMPT_SIZE as re } from "../entities/prompt/constants.js";
|
|
13
|
+
import { useRequestApprovals as ie } from "../hooks/use-chat-approvals.js";
|
|
14
|
+
import { useChatError as ue } from "../hooks/use-chat-error.js";
|
|
15
|
+
import { useChatPendingClientToolParts as ce } from "../hooks/use-chat-pending-client-tool-parts.js";
|
|
16
16
|
import { useUploadTmpDocument as de } from "../hooks/use-upload-tmp-document.js";
|
|
17
|
-
import { useState as
|
|
18
|
-
const
|
|
17
|
+
import { useState as pe } from "../state/state.js";
|
|
18
|
+
const me = { class: "actionContainer" }, ge = ["disabled"], ve = { class: "inputActionsContainer" }, fe = { class: "inputActionsLeft" }, he = {
|
|
19
19
|
class: "addAPIButton",
|
|
20
20
|
type: "button"
|
|
21
|
-
},
|
|
21
|
+
}, ye = {
|
|
22
22
|
class: "addAPIButton",
|
|
23
23
|
type: "button"
|
|
24
|
-
}, Ae = ["src"],
|
|
24
|
+
}, Ae = ["src"], be = ["onClick"], ke = { class: "inputActionsRight" }, _e = { class: "sendCheckboxContinue" }, we = {
|
|
25
25
|
key: 0,
|
|
26
26
|
class: "relative flex items-center gap-1.5"
|
|
27
|
-
},
|
|
27
|
+
}, Se = {
|
|
28
28
|
class: "termsAgree",
|
|
29
29
|
for: "agentTermsAgree"
|
|
30
|
-
},
|
|
30
|
+
}, Ce = {
|
|
31
|
+
key: 5,
|
|
32
|
+
class: "addMoreContext"
|
|
33
|
+
}, Pe = { class: "ml-auto flex items-center gap-1" }, Te = ["onClick"], Ie = ["alt", "src"], Oe = /* @__PURE__ */ q({
|
|
31
34
|
__name: "PromptForm",
|
|
32
35
|
emits: ["submit", "uploadApi"],
|
|
33
|
-
setup(
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
const c =
|
|
37
|
-
() => t.prompt.value.trim().length >
|
|
38
|
-
),
|
|
39
|
-
() => t.chat.messages.length > 1 && !t.getAgentKey?.() && m?.value?.code !==
|
|
36
|
+
setup(xe, { expose: D, emit: L }) {
|
|
37
|
+
const E = L;
|
|
38
|
+
D({ focusPrompt: z });
|
|
39
|
+
const c = K("agentPrompt"), t = pe(), M = d(() => t.prompt.value.trim().length > 0), R = d(
|
|
40
|
+
() => t.prompt.value.trim().length > re
|
|
41
|
+
), B = d(
|
|
42
|
+
() => t.chat.messages.length > 1 && !t.getAgentKey?.() && m?.value?.code !== x.LIMIT_REACHED
|
|
40
43
|
);
|
|
41
|
-
|
|
44
|
+
w(t.prompt, () => {
|
|
42
45
|
if (c?.value) {
|
|
43
46
|
if (!t.prompt.value.length) {
|
|
44
47
|
c.value.style.height = "0px";
|
|
@@ -47,144 +50,146 @@ const ge = { class: "actionContainer" }, ve = ["disabled"], fe = { class: "input
|
|
|
47
50
|
c.value.style.height = "auto", c.value.style.height = c.value.scrollHeight + "px";
|
|
48
51
|
}
|
|
49
52
|
});
|
|
50
|
-
function
|
|
51
|
-
t.loading.value ||
|
|
53
|
+
function U(i) {
|
|
54
|
+
t.loading.value || i.key === "Enter" && !i.shiftKey && (i.preventDefault(), k(), window.scrollTo(0, document.body.scrollHeight));
|
|
52
55
|
}
|
|
53
|
-
function
|
|
56
|
+
function z() {
|
|
54
57
|
c.value?.focus();
|
|
55
58
|
}
|
|
56
|
-
|
|
59
|
+
w(
|
|
57
60
|
() => t.chat.status,
|
|
58
|
-
(
|
|
59
|
-
(
|
|
61
|
+
(i) => {
|
|
62
|
+
(i === "ready" || i === "error") && c.value?.focus();
|
|
60
63
|
}
|
|
61
64
|
);
|
|
62
|
-
const { approvalRequiredParts:
|
|
63
|
-
function
|
|
64
|
-
t.terms.accept(), t.mode === "preview" && t.getActiveDocumentJson &&
|
|
65
|
+
const { approvalRequiredParts: h, respondToRequestApprovals: y } = ie(), { pendingClientToolParts: $ } = ce(), p = de();
|
|
66
|
+
function V() {
|
|
67
|
+
t.terms.accept(), t.mode === "preview" && t.getActiveDocumentJson && p.uploadTempDocument(t.getActiveDocumentJson(), !0);
|
|
65
68
|
}
|
|
66
|
-
const
|
|
69
|
+
const A = d(
|
|
67
70
|
() => Object.values(t.pendingDocuments).some(Boolean)
|
|
68
|
-
), b =
|
|
69
|
-
const
|
|
70
|
-
return
|
|
71
|
+
), b = d(() => {
|
|
72
|
+
const i = R.value, n = !M.value, s = h.value.length > 0, v = $.value.length > 0, _ = t.mode === "preview", F = _ && !t.terms.accepted.value, H = _ && !!p.uploadState.value, N = A.value;
|
|
73
|
+
return i || n || s || v || F || H || N;
|
|
71
74
|
});
|
|
72
|
-
function
|
|
73
|
-
b.value ||
|
|
75
|
+
function k() {
|
|
76
|
+
b.value || E("submit");
|
|
74
77
|
}
|
|
75
|
-
const m =
|
|
76
|
-
return (
|
|
77
|
-
e(
|
|
78
|
+
const m = ue();
|
|
79
|
+
return (i, n) => (o(), r("div", me, [
|
|
80
|
+
e(p).uploadState.value || A.value ? (o(), u(ae, {
|
|
78
81
|
key: 0,
|
|
79
|
-
uploadState: e(
|
|
80
|
-
}, null, 8, ["uploadState"])) :
|
|
81
|
-
e(m) ? (
|
|
82
|
+
uploadState: e(p).uploadState.value ?? { type: "loading" }
|
|
83
|
+
}, null, 8, ["uploadState"])) : a("", !0),
|
|
84
|
+
e(m) ? (o(), u(oe, {
|
|
82
85
|
key: 1,
|
|
83
86
|
error: e(m)
|
|
84
|
-
}, null, 8, ["error"])) :
|
|
85
|
-
e(
|
|
87
|
+
}, null, 8, ["error"])) : a("", !0),
|
|
88
|
+
e(h).length ? (o(), u(te, {
|
|
86
89
|
key: 2,
|
|
87
|
-
onApprove: n[0] || (n[0] = (
|
|
88
|
-
onReject: n[1] || (n[1] = (
|
|
89
|
-
})) :
|
|
90
|
-
e(m)?.code === e(
|
|
91
|
-
|
|
90
|
+
onApprove: n[0] || (n[0] = (s) => e(y)(!0)),
|
|
91
|
+
onReject: n[1] || (n[1] = (s) => e(y)(!1))
|
|
92
|
+
})) : a("", !0),
|
|
93
|
+
e(m)?.code === e(x).LIMIT_REACHED ? (o(), u(ne, { key: 3 })) : a("", !0),
|
|
94
|
+
B.value ? (o(), u(se, { key: 4 })) : a("", !0),
|
|
92
95
|
l("form", {
|
|
93
96
|
class: "promptForm",
|
|
94
|
-
onSubmit:
|
|
97
|
+
onSubmit: j(k, ["prevent"])
|
|
95
98
|
}, [
|
|
96
99
|
n[6] || (n[6] = l("label", {
|
|
97
100
|
class: "agentLabel",
|
|
98
101
|
for: "agentTextarea"
|
|
99
102
|
}, " Type a Request To get Started ", -1)),
|
|
100
|
-
|
|
103
|
+
J(l("textarea", {
|
|
101
104
|
id: "agentTextarea",
|
|
102
105
|
ref: "agentPrompt",
|
|
103
|
-
"onUpdate:modelValue": n[2] || (n[2] = (
|
|
106
|
+
"onUpdate:modelValue": n[2] || (n[2] = (s) => e(t).prompt.value = s),
|
|
104
107
|
class: "prompt custom-scroll",
|
|
105
108
|
disabled: e(t).loading.value,
|
|
106
109
|
name: "prompt",
|
|
107
110
|
placeholder: "Ask me anything...",
|
|
108
|
-
onKeydown:
|
|
109
|
-
}, null, 40,
|
|
111
|
+
onKeydown: U
|
|
112
|
+
}, null, 40, ge), [
|
|
110
113
|
[O, e(t).prompt.value]
|
|
111
114
|
]),
|
|
112
|
-
l("div",
|
|
113
|
-
l("div",
|
|
114
|
-
e(t).
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
115
|
+
l("div", ve, [
|
|
116
|
+
l("div", fe, [
|
|
117
|
+
e(t).hideAddApi ? a("", !0) : (o(), r(f, { key: 0 }, [
|
|
118
|
+
e(t).isLoggedIn?.value ? (o(), u(ee, {
|
|
119
|
+
key: 1,
|
|
120
|
+
onUploadApi: n[3] || (n[3] = (s) => i.$emit("uploadApi"))
|
|
121
|
+
}, {
|
|
122
|
+
default: S(() => [
|
|
123
|
+
l("button", ye, [
|
|
124
|
+
g(e(I), {
|
|
125
|
+
class: "size-4",
|
|
126
|
+
weight: "bold"
|
|
127
|
+
})
|
|
128
|
+
])
|
|
129
|
+
]),
|
|
130
|
+
_: 1
|
|
131
|
+
})) : (o(), u(le, { key: 0 }, {
|
|
132
|
+
default: S(() => [
|
|
133
|
+
l("button", he, [
|
|
134
|
+
g(e(I), {
|
|
135
|
+
class: "size-4",
|
|
136
|
+
weight: "bold"
|
|
137
|
+
})
|
|
138
|
+
])
|
|
139
|
+
]),
|
|
140
|
+
_: 1
|
|
141
|
+
}))
|
|
142
|
+
], 64)),
|
|
143
|
+
(o(!0), r(f, null, C(e(t).registryDocuments.value, (s) => (o(), r("div", {
|
|
144
|
+
key: s.id,
|
|
140
145
|
class: "apiPill"
|
|
141
146
|
}, [
|
|
142
|
-
|
|
147
|
+
s.logoUrl ? (o(), r("img", {
|
|
143
148
|
key: 0,
|
|
144
149
|
class: "apiPillLogo",
|
|
145
|
-
src:
|
|
146
|
-
}, null, 8, Ae)) :
|
|
147
|
-
|
|
148
|
-
|
|
150
|
+
src: s.logoUrl
|
|
151
|
+
}, null, 8, Ae)) : a("", !0),
|
|
152
|
+
P(" " + X(s.title) + " ", 1),
|
|
153
|
+
s.removable ? (o(), r("button", {
|
|
149
154
|
key: 1,
|
|
150
155
|
class: "apiPillRemove",
|
|
151
156
|
type: "button",
|
|
152
|
-
onClick: (v) => e(t).removeDocument(
|
|
157
|
+
onClick: (v) => e(t).removeDocument(s)
|
|
153
158
|
}, [
|
|
154
|
-
g(e(
|
|
159
|
+
g(e(G), {
|
|
155
160
|
class: "size-4",
|
|
156
161
|
weight: "bold"
|
|
157
162
|
})
|
|
158
|
-
], 8,
|
|
163
|
+
], 8, be)) : a("", !0)
|
|
159
164
|
]))), 128))
|
|
160
165
|
]),
|
|
161
|
-
l("div",
|
|
162
|
-
e(t).loading.value ?
|
|
166
|
+
l("div", ke, [
|
|
167
|
+
e(t).loading.value ? a("", !0) : (o(), u(e(T), {
|
|
163
168
|
key: 0,
|
|
164
169
|
class: "settingsButton h-7 w-7 p-1.5",
|
|
165
|
-
icon: e(
|
|
170
|
+
icon: e(Q),
|
|
166
171
|
label: "Scalar",
|
|
167
172
|
size: "md",
|
|
168
173
|
weight: "bold",
|
|
169
|
-
onClick: n[4] || (n[4] = (
|
|
174
|
+
onClick: n[4] || (n[4] = (s) => e(t).settingsModal.show())
|
|
170
175
|
}, null, 8, ["icon"])),
|
|
171
|
-
l("div",
|
|
172
|
-
!e(t).terms.accepted.value && e(t).mode === "preview" ? (
|
|
176
|
+
l("div", _e, [
|
|
177
|
+
!e(t).terms.accepted.value && e(t).mode === "preview" ? (o(), r("div", we, [
|
|
173
178
|
l("input", {
|
|
174
179
|
id: "agentTermsAgree",
|
|
175
180
|
class: "sr-only",
|
|
176
181
|
type: "checkbox",
|
|
177
|
-
onChange:
|
|
182
|
+
onChange: V
|
|
178
183
|
}, null, 32),
|
|
179
|
-
l("label",
|
|
180
|
-
g(e(
|
|
184
|
+
l("label", Se, [
|
|
185
|
+
g(e(W), {
|
|
181
186
|
class: "termsAgreeIcon",
|
|
182
187
|
weight: "bold"
|
|
183
188
|
}),
|
|
184
|
-
n[5] || (n[5] =
|
|
189
|
+
n[5] || (n[5] = P(" Agree to Terms & Conditions ", -1))
|
|
185
190
|
])
|
|
186
|
-
])) :
|
|
187
|
-
e(t).loading.value ? (
|
|
191
|
+
])) : a("", !0),
|
|
192
|
+
e(t).loading.value ? (o(), u(e(Z), {
|
|
188
193
|
key: 2,
|
|
189
194
|
class: "loader h-7 w-7",
|
|
190
195
|
loader: {
|
|
@@ -202,11 +207,11 @@ const ge = { class: "actionContainer" }, ve = ["disabled"], fe = { class: "input
|
|
|
202
207
|
}
|
|
203
208
|
},
|
|
204
209
|
size: "2xl"
|
|
205
|
-
}, null, 8, ["loader"])) : (
|
|
210
|
+
}, null, 8, ["loader"])) : (o(), u(e(T), {
|
|
206
211
|
key: 1,
|
|
207
212
|
class: "sendButton h-7 w-7 p-1.5",
|
|
208
213
|
disabled: b.value,
|
|
209
|
-
icon: e(
|
|
214
|
+
icon: e(Y),
|
|
210
215
|
label: "Scalar",
|
|
211
216
|
size: "md",
|
|
212
217
|
type: "submit",
|
|
@@ -216,29 +221,27 @@ const ge = { class: "actionContainer" }, ve = ["disabled"], fe = { class: "input
|
|
|
216
221
|
])
|
|
217
222
|
])
|
|
218
223
|
], 32),
|
|
219
|
-
|
|
224
|
+
e(t).chat.messages.length <= 1 && !e(t).hideAddApi ? (o(), r("div", Ce, [
|
|
220
225
|
n[7] || (n[7] = l("span", null, "Add context from dozens of API's", -1)),
|
|
221
|
-
l("div",
|
|
222
|
-
(
|
|
223
|
-
key:
|
|
226
|
+
l("div", Pe, [
|
|
227
|
+
(o(!0), r(f, null, C(e(t).curatedDocuments.value, (s) => (o(), r("button", {
|
|
228
|
+
key: s.id,
|
|
224
229
|
class: "addAPIContext",
|
|
225
230
|
type: "button",
|
|
226
|
-
onClick: (v) => e(t).addDocument(
|
|
231
|
+
onClick: (v) => e(t).addDocument(s)
|
|
227
232
|
}, [
|
|
228
|
-
|
|
233
|
+
s.logoUrl ? (o(), r("img", {
|
|
229
234
|
key: 0,
|
|
230
|
-
alt:
|
|
235
|
+
alt: s.title,
|
|
231
236
|
class: "size-4",
|
|
232
|
-
src:
|
|
233
|
-
}, null, 8,
|
|
234
|
-
], 8,
|
|
237
|
+
src: s.logoUrl
|
|
238
|
+
}, null, 8, Ie)) : a("", !0)
|
|
239
|
+
], 8, Te))), 128))
|
|
235
240
|
])
|
|
236
|
-
],
|
|
237
|
-
[Z, e(t).chat.messages.length <= 1]
|
|
238
|
-
])
|
|
241
|
+
])) : a("", !0)
|
|
239
242
|
]));
|
|
240
243
|
}
|
|
241
244
|
});
|
|
242
245
|
export {
|
|
243
|
-
|
|
246
|
+
Oe as default
|
|
244
247
|
};
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"url": "git+https://github.com/scalar/scalar.git",
|
|
11
11
|
"directory": "packages/agent-chat"
|
|
12
12
|
},
|
|
13
|
-
"version": "0.5.
|
|
13
|
+
"version": "0.5.18",
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=20"
|
|
16
16
|
},
|
|
@@ -50,16 +50,16 @@
|
|
|
50
50
|
"vue": "^3.5.26",
|
|
51
51
|
"whatwg-mimetype": "4.0.0",
|
|
52
52
|
"zod": "^4.3.5",
|
|
53
|
-
"@scalar/api-client": "2.29.
|
|
54
|
-
"@scalar/
|
|
55
|
-
"@scalar/components": "0.19.9",
|
|
53
|
+
"@scalar/api-client": "2.29.4",
|
|
54
|
+
"@scalar/components": "0.19.10",
|
|
56
55
|
"@scalar/icons": "0.5.3",
|
|
56
|
+
"@scalar/helpers": "0.2.16",
|
|
57
57
|
"@scalar/openapi-types": "0.5.3",
|
|
58
58
|
"@scalar/themes": "0.14.0",
|
|
59
|
-
"@scalar/
|
|
60
|
-
"@scalar/types": "0.6.7",
|
|
59
|
+
"@scalar/types": "0.6.8",
|
|
61
60
|
"@scalar/use-toasts": "0.9.1",
|
|
62
|
-
"@scalar/
|
|
61
|
+
"@scalar/json-magic": "0.11.5",
|
|
62
|
+
"@scalar/workspace-store": "0.34.4"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@modelcontextprotocol/sdk": "1.26.0",
|