@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.
Files changed (53) hide show
  1. package/dist/App.vue.d.ts +4 -1
  2. package/dist/App.vue.d.ts.map +1 -1
  3. package/dist/App.vue.js +13 -11
  4. package/dist/api.d.ts +3 -1
  5. package/dist/api.d.ts.map +1 -1
  6. package/dist/api.js +54 -53
  7. package/dist/client-tools/execute-request.d.ts +1 -0
  8. package/dist/client-tools/execute-request.d.ts.map +1 -1
  9. package/dist/client-tools/execute-request.js +33 -27
  10. package/dist/components/FreeMessagesInfoSection.vue.d.ts.map +1 -1
  11. package/dist/components/FreeMessagesInfoSection.vue.js +1 -1
  12. package/dist/components/FreeMessagesInfoSection.vue2.js +27 -25
  13. package/dist/components/PaymentSection.vue.d.ts.map +1 -1
  14. package/dist/components/PaymentSection.vue.js +1 -1
  15. package/dist/components/PaymentSection.vue2.js +16 -20
  16. package/dist/components/ServerSelector.vue.d.ts.map +1 -1
  17. package/dist/components/ServerSelector.vue.js +27 -21
  18. package/dist/components/UploadSection.vue.js +2 -2
  19. package/dist/components/UploadSection.vue2.js +13 -13
  20. package/dist/consts/urls.d.ts +8 -0
  21. package/dist/consts/urls.d.ts.map +1 -0
  22. package/dist/consts/urls.js +10 -0
  23. package/dist/helpers.d.ts +4 -10
  24. package/dist/helpers.d.ts.map +1 -1
  25. package/dist/helpers.js +34 -45
  26. package/dist/hooks/use-agent-key-documents.js +6 -6
  27. package/dist/hooks/use-chat-approvals.d.ts.map +1 -1
  28. package/dist/hooks/use-chat-approvals.js +7 -6
  29. package/dist/hooks/use-signup-link.d.ts +12 -0
  30. package/dist/hooks/use-signup-link.d.ts.map +1 -0
  31. package/dist/hooks/use-signup-link.js +12 -0
  32. package/dist/hooks/use-upload-tmp-document.d.ts +3 -0
  33. package/dist/hooks/use-upload-tmp-document.d.ts.map +1 -1
  34. package/dist/hooks/use-upload-tmp-document.js +31 -28
  35. package/dist/package.json +1 -1
  36. package/dist/state/state.d.ts +5 -2
  37. package/dist/state/state.d.ts.map +1 -1
  38. package/dist/state/state.js +140 -131
  39. package/dist/style.css +1 -1
  40. package/dist/views/Chat/Messages/AskForAuthentication.vue.js +1 -1
  41. package/dist/views/Chat/Messages/AskForAuthentication.vue2.js +12 -12
  42. package/dist/views/PromptForm.vue.d.ts.map +1 -1
  43. package/dist/views/PromptForm.vue.js +2 -2
  44. package/dist/views/PromptForm.vue2.js +132 -122
  45. package/dist/views/Settings/DocSettings.vue.js +1 -1
  46. package/dist/views/Settings/DocSettings.vue2.js +10 -10
  47. package/dist/views/Settings/Settings.vue.d.ts.map +1 -1
  48. package/dist/views/Settings/Settings.vue.js +2 -2
  49. package/dist/views/Settings/Settings.vue2.js +53 -43
  50. package/dist/views/Start.vue.d.ts.map +1 -1
  51. package/dist/views/Start.vue.js +1 -1
  52. package/dist/views/Start.vue2.js +28 -27
  53. package/package.json +7 -7
@@ -1,189 +1,198 @@
1
- import { Chat as P } from "@ai-sdk/vue";
2
- import { useModal as Y } from "@scalar/components";
3
- import { apiReferenceConfigurationSchema as j } from "@scalar/types/api-reference";
4
- import { useToasts as q } from "@scalar/use-toasts";
5
- import { createWorkspaceStore as z } from "@scalar/workspace-store/client";
6
- import { createWorkspaceEventBus as F } from "@scalar/workspace-store/events";
7
- import { DefaultChatTransport as H, lastAssistantMessageIsCompleteWithToolCalls as Q } from "ai";
8
- import { n as X } from "neverpanic";
9
- import { ref as l, reactive as J, computed as _, watch as C, inject as V } from "vue";
10
- import { createApi as Z, createAuthorizationHeaders as K } from "../api.js";
11
- import { executeRequestTool as tt } from "../client-tools/execute-request.js";
12
- import { EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME as ot } from "../entities/tools/execute-request.js";
13
- import { createDocumentSettings as N, makeScalarProxyUrl as U } from "../helpers.js";
14
- import { useTermsAndConditions as et } from "../hooks/use-term-and-conditions.js";
15
- import { persistencePlugin as nt } from "../plugins/persistance.js";
16
- import { loadDocument as x } from "../registry/add-documents-to-store.js";
17
- import { createDocumentName as rt } from "../registry/create-document-name.js";
18
- import { createError as at } from "../entities/error/helpers.js";
19
- const ct = /* @__PURE__ */ Symbol("STATE_SYMBOL"), { toast: y } = q();
20
- function st({
21
- registryDocuments: c,
22
- workspaceStore: s,
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
- getAccessToken: i,
25
- getAgentKey: T
26
+ proxyUrl: a,
27
+ getAccessToken: T,
28
+ getAgentKey: w
26
29
  }) {
27
- const h = new P({
28
- sendAutomaticallyWhen: Q,
29
- transport: new H({
30
- api: U(`${E}/vector/openapi/chat`),
31
- headers: () => K({ getAccessToken: i, getAgentKey: T }),
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: c.value,
34
- documentSettings: N(s)
36
+ registryDocuments: s.value,
37
+ documentSettings: C(i)
35
38
  })
36
39
  }),
37
- async onToolCall({ toolCall: n }) {
38
- n.dynamic || n.toolName === ot && n.input.method.toLowerCase() === "get" && await tt({
39
- documentSettings: N(s),
40
- input: n.input,
41
- toolCallId: n.toolCallId,
42
- chat: h
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 h;
50
+ return m;
47
51
  }
48
- function gt({
49
- initialRegistryDocuments: c,
50
- registryUrl: s,
52
+ function Ct({
53
+ initialRegistryDocuments: s,
54
+ registryUrl: i,
51
55
  dashboardUrl: E,
52
- baseUrl: i,
56
+ baseUrl: a,
53
57
  mode: T,
54
- isLoggedIn: h,
55
- getAccessToken: n,
56
- getAgentKey: v,
58
+ isLoggedIn: w,
59
+ getAccessToken: m,
60
+ getAgentKey: r,
57
61
  getActiveDocumentJson: I,
58
- prefilledMessageRef: w
62
+ prefilledMessageRef: S,
63
+ hideAddApi: M
59
64
  }) {
60
- const D = l(w?.value ?? ""), r = l([]), d = J({}), M = l([]), A = l("https://proxy.scalar.com"), G = l(), b = et(), L = F(), f = z({
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
- nt({
67
+ ct({
63
68
  persistAuth: !0
64
69
  })
65
70
  ]
66
- }), S = _(
67
- () => j.parse({
68
- proxyUrl: A.value,
71
+ }), _ = $(
72
+ () => q.parse({
73
+ proxyUrl: p.value,
69
74
  persistAuth: !0
70
75
  })
71
- ), a = st({
72
- registryDocuments: r,
73
- workspaceStore: f,
74
- baseUrl: i,
75
- getAccessToken: n,
76
- getAgentKey: v
77
- }), $ = Z({
78
- baseUrl: i,
79
- getAccessToken: n,
80
- getAgentKey: v
81
- }), B = _(
82
- () => a.status === "submitted" || a.status === "streaming" && !a.lastMessage?.parts.some((t) => t.type === "text")
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
- C(
85
- () => a.status,
91
+ L(
92
+ () => c.status,
86
93
  () => {
87
- a.status === "streaming" && (D.value = "");
94
+ c.status === "streaming" && (v.value = "");
88
95
  }
89
- ), w && C(w, async (t) => {
90
- t && (D.value = t, b.accepted.value && await a.sendMessage({ text: D.value }));
96
+ ), S && L(S, async (t) => {
97
+ t && (v.value = t, b.accepted.value && await c.sendMessage({ text: v.value }));
91
98
  });
92
- const O = Y();
99
+ const W = k();
93
100
  async function g({
94
101
  namespace: t,
95
102
  slug: o,
96
- removable: m = !0
103
+ removable: u = !0
97
104
  }) {
98
- if (r.value.find((e) => e.namespace === t && e.slug === o))
105
+ if (n.value.find((e) => e.namespace === t && e.slug === o))
99
106
  return;
100
- const p = `@${t}/${o}`;
101
- d[p] = !0;
102
- const u = await x({
107
+ const h = `@${t}/${o}`;
108
+ f[h] = !0;
109
+ const d = await N({
103
110
  namespace: t,
104
111
  slug: o,
105
- workspaceStore: f,
106
- registryUrl: s,
107
- registryDocuments: r,
108
- config: S.value,
109
- api: $,
110
- removable: m
112
+ workspaceStore: l,
113
+ registryUrl: i,
114
+ registryDocuments: n,
115
+ config: _.value,
116
+ api: A,
117
+ removable: u
111
118
  });
112
- if (d[p] = !1, !u.success)
113
- throw console.warn("[AGENT]: Unable to load document", u.error), y(`Unable to load the document @${t}/${o}`, "warn"), u.error;
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 R({
122
+ async function Y({
116
123
  namespace: t,
117
124
  slug: o,
118
- removable: m = !0
125
+ removable: u = !0
119
126
  }) {
120
- if (r.value.find((e) => e.namespace === t && e.slug === o))
127
+ if (n.value.find((e) => e.namespace === t && e.slug === o))
121
128
  return;
122
- const p = `@${t}/${o}`;
123
- d[p] = !0;
124
- const u = await X.fromUnsafe(
125
- () => fetch(U(`${i}/vector/registry/embeddings/${t}/${o}`), {
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) => at("FAILED_TO_GET_EMBEDDING_STATUS", e)
135
+ (e) => it("FAILED_TO_GET_EMBEDDING_STATUS", e)
129
136
  );
130
- if (u.success && u.data.ok) {
131
- const e = await x({
137
+ if (d.success && d.data.ok) {
138
+ const e = await N({
132
139
  namespace: t,
133
140
  slug: o,
134
- workspaceStore: f,
135
- registryUrl: s,
136
- registryDocuments: r,
137
- config: S.value,
138
- api: $,
139
- removable: m
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
- d[p] = !1;
151
+ f[h] = !1;
145
152
  }
146
- function W({ namespace: t, slug: o }) {
147
- r.value = r.value.filter(
148
- (m) => !(m.namespace === t && m.slug === o)
149
- ), f.deleteDocument(rt(t, o));
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 c.forEach(({ namespace: t, slug: o }) => g({ namespace: t, slug: o, removable: !1 })), {
152
- prompt: D,
153
- chat: a,
154
- workspaceStore: f,
155
- eventBus: L,
156
- loading: B,
157
- settingsModal: O,
158
- config: S,
159
- registryUrl: s,
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: i,
162
- registryDocuments: r,
163
- pendingDocuments: d,
164
- proxyUrl: A,
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: h,
175
+ isLoggedIn: w,
168
176
  addDocument: g,
169
- addDocumentAsync: R,
170
- removeDocument: W,
171
- getAccessToken: n,
172
- getAgentKey: v,
173
- api: $,
177
+ addDocumentAsync: Y,
178
+ removeDocument: F,
179
+ getAccessToken: m,
180
+ getAgentKey: r,
181
+ api: A,
174
182
  uploadedTmpDocumentUrl: G,
175
- curatedDocuments: M,
176
- getActiveDocumentJson: I
183
+ curatedDocuments: O,
184
+ getActiveDocumentJson: I,
185
+ hideAddApi: M
177
186
  };
178
187
  }
179
- function _t() {
180
- const c = V(ct);
181
- if (!c)
188
+ function Nt() {
189
+ const s = tt(mt);
190
+ if (!s)
182
191
  throw new Error("No state provided.");
183
- return c;
192
+ return s;
184
193
  }
185
194
  export {
186
- ct as STATE_SYMBOL,
187
- gt as createState,
188
- _t as useState
195
+ mt as STATE_SYMBOL,
196
+ Ct as createState,
197
+ Nt as useState
189
198
  };