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