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