@scalar/agent-chat 0.5.18 → 0.7.1

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