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