@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.
- package/dist/App.vue.d.ts +56 -1
- package/dist/App.vue.d.ts.map +1 -1
- package/dist/App.vue.js +25 -20
- package/dist/Chat.vue.d.ts +5 -1
- package/dist/Chat.vue.d.ts.map +1 -1
- package/dist/Chat.vue.js +26 -22
- package/dist/client-tools/execute-request.d.ts +72 -0
- package/dist/client-tools/execute-request.d.ts.map +1 -0
- package/dist/client-tools/execute-request.js +92 -0
- package/dist/components/ActionsDropdown.vue.d.ts +17 -0
- package/dist/components/ActionsDropdown.vue.d.ts.map +1 -0
- package/dist/components/ActionsDropdown.vue.js +7 -0
- package/dist/components/ActionsDropdown.vue2.js +50 -0
- package/dist/components/RequestPreview.vue.d.ts +3 -3
- package/dist/components/RequestPreview.vue.d.ts.map +1 -1
- package/dist/components/RequestPreview.vue.js +2 -2
- package/dist/components/RequestPreview.vue2.js +31 -31
- package/dist/entities/index.d.ts +1 -1
- package/dist/entities/index.d.ts.map +1 -1
- package/dist/entities/index.js +16 -16
- package/dist/entities/registry/document.d.ts +1 -0
- package/dist/entities/registry/document.d.ts.map +1 -1
- package/dist/entities/tools/execute-request.d.ts +27 -34
- package/dist/entities/tools/execute-request.d.ts.map +1 -1
- package/dist/entities/tools/execute-request.js +5 -4
- package/dist/helpers.d.ts +36 -275
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +44 -86
- package/dist/hooks/use-chat-approvals.d.ts +17 -10
- package/dist/hooks/use-chat-approvals.d.ts.map +1 -1
- package/dist/hooks/use-chat-approvals.js +28 -15
- package/dist/hooks/use-search.d.ts +2 -0
- package/dist/hooks/use-search.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/package.json +2 -1
- package/dist/plugins/persistance.d.ts +16 -0
- package/dist/plugins/persistance.d.ts.map +1 -0
- package/dist/plugins/persistance.js +23 -0
- package/dist/state/state.d.ts +16 -5
- package/dist/state/state.d.ts.map +1 -1
- package/dist/state/state.js +148 -101
- package/dist/style.css +1 -1
- package/dist/views/Catalog/Catalog.vue.d.ts +7 -0
- package/dist/views/Catalog/Catalog.vue.d.ts.map +1 -0
- package/dist/views/Catalog/Catalog.vue.js +8 -0
- package/dist/views/Catalog/Catalog.vue2.js +70 -0
- package/dist/views/Chat/Chat.vue.d.ts +2 -0
- package/dist/views/Chat/Chat.vue.d.ts.map +1 -1
- package/dist/views/Chat/Chat.vue.js +1 -1
- package/dist/views/Chat/Chat.vue2.js +36 -35
- package/dist/views/Chat/Messages/AskForAuthentication.vue.d.ts.map +1 -1
- package/dist/views/Chat/Messages/AskForAuthentication.vue.js +2 -2
- package/dist/views/Chat/Messages/AskForAuthentication.vue2.js +50 -52
- package/dist/views/Chat/Messages/ExecuteRequestTool.vue.d.ts +2 -2
- package/dist/views/Chat/Messages/ExecuteRequestTool.vue.d.ts.map +1 -1
- package/dist/views/Chat/Messages/ExecuteRequestTool.vue.js +2 -2
- package/dist/views/Chat/Messages/ExecuteRequestTool.vue2.js +8 -7
- package/dist/views/Layout.vue.d.ts +2 -0
- package/dist/views/Layout.vue.d.ts.map +1 -1
- package/dist/views/Layout.vue.js +2 -2
- package/dist/views/Layout.vue2.js +16 -14
- package/dist/views/PromptForm.vue.d.ts +2 -0
- package/dist/views/PromptForm.vue.d.ts.map +1 -1
- package/dist/views/PromptForm.vue.js +1 -1
- package/dist/views/PromptForm.vue2.js +112 -99
- package/dist/views/Settings/Auth.vue.d.ts +2 -2
- package/dist/views/Settings/Auth.vue.d.ts.map +1 -1
- package/dist/views/Settings/Auth.vue.js +32 -32
- package/dist/views/Settings/DocSettings.vue.d.ts.map +1 -1
- package/dist/views/Settings/DocSettings.vue.js +1 -1
- package/dist/views/Settings/DocSettings.vue2.js +22 -21
- package/dist/views/Start.vue.d.ts +2 -0
- package/dist/views/Start.vue.d.ts.map +1 -1
- package/dist/views/Start.vue.js +2 -2
- package/dist/views/Start.vue2.js +22 -21
- package/package.json +8 -7
package/dist/helpers.js
CHANGED
|
@@ -1,120 +1,78 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { coerceValue as
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return Object.values(e.paths ?? {}).flatMap((c) => Object.values(c ?? {}));
|
|
1
|
+
import { mergeSecurity as a } from "@scalar/api-client/v2/blocks/scalar-auth-selector-block";
|
|
2
|
+
import { getSelectedServer as c } from "@scalar/api-client/v2/features/operation";
|
|
3
|
+
import { getServers as n } from "@scalar/api-client/v2/helpers";
|
|
4
|
+
import { safeLocalStorage as u, REFERENCE_LS_KEYS as i } from "@scalar/helpers/object/local-storage";
|
|
5
|
+
import { AuthSchema as m } from "@scalar/workspace-store/entities/auth";
|
|
6
|
+
import { coerceValue as h } from "@scalar/workspace-store/schemas/typebox-coerce";
|
|
7
|
+
function U(t) {
|
|
8
|
+
return Object.values(t.paths ?? {}).flatMap((r) => Object.values(r ?? {}));
|
|
10
9
|
}
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
return t ? s.reduce((r, n) => {
|
|
14
|
-
const o = t[n];
|
|
15
|
-
return o && r.push(h(o)), r;
|
|
16
|
-
}, []) : [];
|
|
10
|
+
function p(t, r, e) {
|
|
11
|
+
return Object.values(a(r?.components?.securitySchemes, {}, e, t));
|
|
17
12
|
}
|
|
18
|
-
function
|
|
13
|
+
function x(t) {
|
|
19
14
|
return Object.fromEntries(
|
|
20
|
-
Object.entries(
|
|
21
|
-
const
|
|
22
|
-
documentUrl:
|
|
15
|
+
Object.entries(t.workspace.documents).map(([r, e]) => {
|
|
16
|
+
const s = n(e.servers, {
|
|
17
|
+
documentUrl: e?.["x-scalar-original-source-url"]
|
|
23
18
|
});
|
|
24
19
|
return [
|
|
25
|
-
|
|
20
|
+
r,
|
|
26
21
|
{
|
|
27
|
-
activeServer:
|
|
28
|
-
securitySchemes:
|
|
22
|
+
activeServer: c(e, s),
|
|
23
|
+
securitySchemes: p(r, e, t.auth)
|
|
29
24
|
}
|
|
30
25
|
];
|
|
31
26
|
})
|
|
32
27
|
);
|
|
33
28
|
}
|
|
34
|
-
const
|
|
35
|
-
const
|
|
29
|
+
const o = u(), S = () => {
|
|
30
|
+
const t = (r) => `${i.AUTH}-${r}`;
|
|
36
31
|
return {
|
|
37
32
|
/**
|
|
38
33
|
* Retrieves and coerces the authentication schemes stored in local storage.
|
|
39
34
|
*/
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
return
|
|
35
|
+
getAuth: (r) => {
|
|
36
|
+
const e = JSON.parse(o.getItem(t(r)) ?? "{}");
|
|
37
|
+
return h(m, e);
|
|
43
38
|
},
|
|
44
39
|
/**
|
|
45
40
|
* Stores the authentication schemes in local storage.
|
|
46
|
-
* @param value The
|
|
41
|
+
* @param value The Auth object to stringify and store.
|
|
47
42
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
},
|
|
51
|
-
/**
|
|
52
|
-
* Retrieves and coerces the selected authentication schemes stored in local storage.
|
|
53
|
-
*/
|
|
54
|
-
getSelectedSchemes: (t) => {
|
|
55
|
-
const r = JSON.parse(m.getItem(s("selectedSchemes", t)) ?? "{}");
|
|
56
|
-
return y(E, r);
|
|
57
|
-
},
|
|
58
|
-
/**
|
|
59
|
-
* Stores the user's selected authentication schemes in local storage.
|
|
60
|
-
* @param value The XScalarSelectedSecurity object to stringify and store.
|
|
61
|
-
*/
|
|
62
|
-
setSelectedSchemes: (t, r) => {
|
|
63
|
-
m.setItem(s("selectedSchemes", t), JSON.stringify(r));
|
|
43
|
+
setAuth: (r, e) => {
|
|
44
|
+
o.setItem(t(r), JSON.stringify(e));
|
|
64
45
|
}
|
|
65
46
|
};
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (typeof t != "object") {
|
|
70
|
-
e[s] = t;
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
p(h(e[s]), t);
|
|
74
|
-
}
|
|
75
|
-
}, I = (e, c) => Object.keys(e).every((s) => c.has(s)), U = (e, c) => e >= c ? c - 1 : e, H = ({
|
|
76
|
-
documentName: e,
|
|
77
|
-
workspaceStore: c
|
|
47
|
+
}, A = ({
|
|
48
|
+
documentName: t,
|
|
49
|
+
workspaceStore: r
|
|
78
50
|
}) => {
|
|
79
|
-
const s =
|
|
80
|
-
|
|
81
|
-
return;
|
|
82
|
-
const n = f().getSelectedSchemes(e), o = new Set(Object.keys(t.components?.securitySchemes ?? {})), S = n["x-scalar-selected-security"]?.selectedSchemes?.filter((a) => I(a, o));
|
|
83
|
-
if (!t["x-scalar-selected-security"] && S && S.length > 0) {
|
|
84
|
-
const a = n["x-scalar-selected-security"]?.selectedIndex, i = U(a ?? 0, S.length);
|
|
85
|
-
t["x-scalar-selected-security"] = {
|
|
86
|
-
selectedIndex: i,
|
|
87
|
-
selectedSchemes: S
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
const g = t.components?.securitySchemes ?? {};
|
|
91
|
-
for (const [a, i] of Object.entries(s)) {
|
|
92
|
-
const u = h(g[a]);
|
|
93
|
-
l(u) && p(u, i);
|
|
94
|
-
}
|
|
51
|
+
const s = S().getAuth(t);
|
|
52
|
+
r.auth.load({ [t]: s });
|
|
95
53
|
};
|
|
96
|
-
function
|
|
54
|
+
function E(t) {
|
|
97
55
|
try {
|
|
98
|
-
return JSON.parse(
|
|
56
|
+
return JSON.parse(t);
|
|
99
57
|
} catch {
|
|
100
58
|
return;
|
|
101
59
|
}
|
|
102
60
|
}
|
|
103
|
-
function
|
|
61
|
+
function b(t) {
|
|
104
62
|
try {
|
|
105
|
-
if (
|
|
106
|
-
return
|
|
107
|
-
const
|
|
108
|
-
return new URL(`https://proxy.scalar.com/?${
|
|
63
|
+
if (t.startsWith("/") || t.startsWith("http://localhost"))
|
|
64
|
+
return t;
|
|
65
|
+
const r = new URLSearchParams({ scalar_url: t });
|
|
66
|
+
return new URL(`https://proxy.scalar.com/?${r}`).toString();
|
|
109
67
|
} catch {
|
|
110
|
-
return console.error(`Invalid URL provided: ${
|
|
68
|
+
return console.error(`Invalid URL provided: ${t}`), t;
|
|
111
69
|
}
|
|
112
70
|
}
|
|
113
71
|
export {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
72
|
+
S as authStorage,
|
|
73
|
+
x as createDocumentSettings,
|
|
74
|
+
U as getOperations,
|
|
75
|
+
b as makeScalarProxyUrl,
|
|
76
|
+
A as restoreAuthSecretsFromStorage,
|
|
77
|
+
E as safeParseJson
|
|
120
78
|
};
|
|
@@ -1,24 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { ToolUIPart, UIMessagePart } from 'ai';
|
|
2
|
+
import { type Tools } from '../state/state.js';
|
|
3
|
+
type RequestToolPart = ToolUIPart & {
|
|
4
|
+
type: 'tool-execute-request';
|
|
5
|
+
state: 'input-available';
|
|
6
|
+
input: Tools['execute-request']['input'];
|
|
7
|
+
};
|
|
8
|
+
export declare function requestPartRequiresApproval(part: UIMessagePart<any, Tools>): part is RequestToolPart;
|
|
9
|
+
export declare function useRequestApprovals(): {
|
|
10
|
+
approvalRequiredParts: import("vue").ComputedRef<({
|
|
3
11
|
type: `tool-${string}`;
|
|
4
12
|
} & {
|
|
5
13
|
toolCallId: string;
|
|
6
14
|
title?: string;
|
|
7
15
|
providerExecuted?: boolean;
|
|
8
16
|
} & {
|
|
9
|
-
state: "
|
|
17
|
+
state: "input-available";
|
|
10
18
|
input: unknown;
|
|
11
19
|
output?: never;
|
|
12
20
|
errorText?: never;
|
|
13
21
|
callProviderMetadata?: import("ai").ProviderMetadata;
|
|
14
|
-
approval
|
|
15
|
-
id: string;
|
|
16
|
-
approved?: never;
|
|
17
|
-
reason?: never;
|
|
18
|
-
};
|
|
22
|
+
approval?: never;
|
|
19
23
|
} & {
|
|
20
|
-
|
|
24
|
+
type: "tool-execute-request";
|
|
25
|
+
state: "input-available";
|
|
26
|
+
input: Tools["execute-request"]["input"];
|
|
21
27
|
})[]>;
|
|
22
|
-
|
|
28
|
+
respondToRequestApprovals: (approved: boolean) => Promise<void>;
|
|
23
29
|
};
|
|
30
|
+
export {};
|
|
24
31
|
//# sourceMappingURL=use-chat-approvals.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-chat-approvals.d.ts","sourceRoot":"","sources":["../../src/hooks/use-chat-approvals.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-chat-approvals.d.ts","sourceRoot":"","sources":["../../src/hooks/use-chat-approvals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,IAAI,CAAA;AAMnD,OAAO,EAAE,KAAK,KAAK,EAAY,MAAM,eAAe,CAAA;AAEpD,KAAK,eAAe,GAAG,UAAU,GAAG;IAClC,IAAI,EAAE,sBAAsB,CAAA;IAC5B,KAAK,EAAE,iBAAiB,CAAA;IACxB,KAAK,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,CAAA;CACzC,CAAA;AAED,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,aAAa,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,IAAI,IAAI,eAAe,CAMpG;AAED,wBAAgB,mBAAmB;;;;;;;;;;;;;;;cAb3B,sBAAsB;eACrB,iBAAiB;eACjB,KAAK,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC;;0CAqBW,OAAO;EAuB3D"}
|
|
@@ -1,21 +1,34 @@
|
|
|
1
1
|
import { computed as l } from "vue";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { executeRequestTool as i } from "../client-tools/execute-request.js";
|
|
3
|
+
import { createDocumentSettings as n } from "../helpers.js";
|
|
4
|
+
import { useState as m } from "../state/state.js";
|
|
5
|
+
import { EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME as s } from "../entities/tools/execute-request.js";
|
|
6
|
+
function a(t) {
|
|
7
|
+
return t.type === `tool-${s}` && t.state === "input-available" && t.input?.method?.toLowerCase() !== "get";
|
|
5
8
|
}
|
|
6
|
-
function
|
|
7
|
-
const t =
|
|
8
|
-
async function
|
|
9
|
-
const
|
|
10
|
-
(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
function h() {
|
|
10
|
+
const t = m(), r = l(() => t.chat.messages.filter((e) => e.parts.some(a)).flatMap((e) => e.parts).filter(a));
|
|
11
|
+
async function u(e) {
|
|
12
|
+
const p = r.value.map(async (o) => {
|
|
13
|
+
if (!e)
|
|
14
|
+
return await t.chat.addToolOutput({
|
|
15
|
+
tool: s,
|
|
16
|
+
toolCallId: o.toolCallId,
|
|
17
|
+
state: "output-error",
|
|
18
|
+
errorText: "The user denied the request."
|
|
19
|
+
});
|
|
20
|
+
await i({
|
|
21
|
+
documentSettings: n(t.workspaceStore),
|
|
22
|
+
input: o.input,
|
|
23
|
+
toolCallId: o.toolCallId,
|
|
24
|
+
chat: t.chat
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
await Promise.all(p);
|
|
16
28
|
}
|
|
17
|
-
return {
|
|
29
|
+
return { approvalRequiredParts: r, respondToRequestApprovals: u };
|
|
18
30
|
}
|
|
19
31
|
export {
|
|
20
|
-
|
|
32
|
+
a as requestPartRequiresApproval,
|
|
33
|
+
h as useRequestApprovals
|
|
21
34
|
};
|
|
@@ -9,6 +9,7 @@ export declare function useSearch(): {
|
|
|
9
9
|
logoUrl: string | null;
|
|
10
10
|
slug: string;
|
|
11
11
|
removable?: boolean | undefined;
|
|
12
|
+
searchEnabled?: boolean | undefined;
|
|
12
13
|
}[], ApiMetadata[] | {
|
|
13
14
|
id: string;
|
|
14
15
|
title: string;
|
|
@@ -17,6 +18,7 @@ export declare function useSearch(): {
|
|
|
17
18
|
logoUrl: string | null;
|
|
18
19
|
slug: string;
|
|
19
20
|
removable?: boolean | undefined;
|
|
21
|
+
searchEnabled?: boolean | undefined;
|
|
20
22
|
}[]>;
|
|
21
23
|
};
|
|
22
24
|
//# sourceMappingURL=use-search.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-search.d.ts","sourceRoot":"","sources":["../../src/hooks/use-search.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAG/D,wBAAgB,SAAS
|
|
1
|
+
{"version":3,"file":"use-search.d.ts","sourceRoot":"","sources":["../../src/hooks/use-search.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAG/D,wBAAgB,SAAS;;;;;;;;;;;;;;;;;;;;;EAiCxB"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAA"}
|
package/dist/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.
|
|
13
|
+
"version": "0.5.2",
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=20"
|
|
16
16
|
},
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"@vueuse/core": "catalog:*",
|
|
63
63
|
"ai": "catalog:*",
|
|
64
64
|
"neverpanic": "catalog:*",
|
|
65
|
+
"truncate-json": "catalog:*",
|
|
65
66
|
"vue": "catalog:*",
|
|
66
67
|
"whatwg-mimetype": "catalog:*",
|
|
67
68
|
"zod": "catalog:*"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { WorkspacePlugin } from '@scalar/workspace-store/workspace-plugin';
|
|
2
|
+
/**
|
|
3
|
+
* Plugin to persist workspace state changes with debounced writes.
|
|
4
|
+
*/
|
|
5
|
+
export declare const persistencePlugin: ({ debounceDelay, maxWait, persistAuth, }: {
|
|
6
|
+
debounceDelay?: number;
|
|
7
|
+
/** Maximum time in milliseconds to wait before forcing execution, even with continuous calls. */
|
|
8
|
+
maxWait?: number;
|
|
9
|
+
/**
|
|
10
|
+
* Determines whether authentication details should be persisted.
|
|
11
|
+
* Accepts a boolean or a function that returns a boolean.
|
|
12
|
+
* Allows for conditional persistence logic, e.g., based on environment or user settings.
|
|
13
|
+
*/
|
|
14
|
+
persistAuth?: boolean | (() => boolean);
|
|
15
|
+
}) => WorkspacePlugin;
|
|
16
|
+
//# sourceMappingURL=persistance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persistance.d.ts","sourceRoot":"","sources":["../../src/plugins/persistance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAA;AAI/E;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,0CAI/B;IACD,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,iGAAiG;IACjG,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,CAAA;CACxC,KAAG,eA8BH,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { debounce as c } from "@scalar/helpers/general/debounce";
|
|
2
|
+
import { authStorage as s } from "../helpers.js";
|
|
3
|
+
const h = ({
|
|
4
|
+
debounceDelay: o = 500,
|
|
5
|
+
maxWait: r = 1e4,
|
|
6
|
+
persistAuth: e = !1
|
|
7
|
+
}) => {
|
|
8
|
+
const { execute: n } = c({ delay: o, maxWait: r }), u = s(), a = () => typeof e == "function" ? e() : e;
|
|
9
|
+
return {
|
|
10
|
+
hooks: {
|
|
11
|
+
/**
|
|
12
|
+
* Handles all workspace state change events.
|
|
13
|
+
* Each write is debounced by a key to prevent frequent writes for the same entity.
|
|
14
|
+
*/
|
|
15
|
+
onWorkspaceStateChanges(t) {
|
|
16
|
+
a() && t.type === "auth" && n("auth", () => u.setAuth(t.documentName, t.value));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
h as persistencePlugin
|
|
23
|
+
};
|
package/dist/state/state.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { type ComputedRef, type InjectionKey, type Ref } from 'vue';
|
|
|
8
8
|
import { type Api } from '../api.js';
|
|
9
9
|
import type { ApiMetadata } from '../entities/registry/document.js';
|
|
10
10
|
import type { ASK_FOR_AUTHENTICATION_TOOL_NAME, AskForAuthenticationInput } from '../entities/tools/ask-for-authentication.js';
|
|
11
|
-
import
|
|
11
|
+
import { EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME, type ExecuteClientSideRequestToolInput, type ExecuteClientSideRequestToolOutput } from '../entities/tools/execute-request.js';
|
|
12
12
|
import type { GET_MINI_OPENAPI_SPEC_TOOL_NAME, GetMiniOpenAPIDocToolInput, GetMiniOpenAPIDocToolOutput } from '../entities/tools/get-mini-openapi-spec.js';
|
|
13
13
|
import type { GET_OPENAPI_SPECS_SUMMARY_TOOL_NAME, GetOpenAPISpecsSummaryToolOutput } from '../entities/tools/get-openapi-spec-summary.js';
|
|
14
14
|
import type { ChatMode } from '../types';
|
|
@@ -21,9 +21,9 @@ export type Tools = {
|
|
|
21
21
|
input: GetMiniOpenAPIDocToolInput;
|
|
22
22
|
output: GetMiniOpenAPIDocToolOutput;
|
|
23
23
|
};
|
|
24
|
-
[
|
|
25
|
-
input:
|
|
26
|
-
output:
|
|
24
|
+
[EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME]: {
|
|
25
|
+
input: ExecuteClientSideRequestToolInput;
|
|
26
|
+
output: ExecuteClientSideRequestToolOutput;
|
|
27
27
|
};
|
|
28
28
|
[GET_OPENAPI_SPECS_SUMMARY_TOOL_NAME]: {
|
|
29
29
|
input: object;
|
|
@@ -47,7 +47,12 @@ type State = {
|
|
|
47
47
|
registryUrl: string;
|
|
48
48
|
dashboardUrl: string;
|
|
49
49
|
baseUrl: string;
|
|
50
|
+
isLoggedIn?: Ref<boolean>;
|
|
50
51
|
registryDocuments: Ref<ApiMetadata[]>;
|
|
52
|
+
pendingDocuments: Ref<{
|
|
53
|
+
namespace: string;
|
|
54
|
+
slug: string;
|
|
55
|
+
}[]>;
|
|
51
56
|
mode: ChatMode;
|
|
52
57
|
terms: {
|
|
53
58
|
accepted: Ref<boolean>;
|
|
@@ -58,6 +63,11 @@ type State = {
|
|
|
58
63
|
slug: string;
|
|
59
64
|
removable?: boolean;
|
|
60
65
|
}) => Promise<void>;
|
|
66
|
+
addDocumentAsync: (document: {
|
|
67
|
+
namespace: string;
|
|
68
|
+
slug: string;
|
|
69
|
+
removable?: boolean;
|
|
70
|
+
}) => Promise<void>;
|
|
61
71
|
removeDocument: (document: {
|
|
62
72
|
namespace: string;
|
|
63
73
|
slug: string;
|
|
@@ -69,7 +79,7 @@ type State = {
|
|
|
69
79
|
curatedDocuments: Ref<ApiMetadata[]>;
|
|
70
80
|
getActiveDocumentJson?: () => string;
|
|
71
81
|
};
|
|
72
|
-
export declare function createState({ initialRegistryDocuments, registryUrl, dashboardUrl, baseUrl, mode, getAccessToken, getAgentKey, getActiveDocumentJson, prefilledMessageRef, }: {
|
|
82
|
+
export declare function createState({ initialRegistryDocuments, registryUrl, dashboardUrl, baseUrl, mode, isLoggedIn, getAccessToken, getAgentKey, getActiveDocumentJson, prefilledMessageRef, }: {
|
|
73
83
|
initialRegistryDocuments: {
|
|
74
84
|
namespace: string;
|
|
75
85
|
slug: string;
|
|
@@ -78,6 +88,7 @@ export declare function createState({ initialRegistryDocuments, registryUrl, das
|
|
|
78
88
|
dashboardUrl: string;
|
|
79
89
|
baseUrl: string;
|
|
80
90
|
mode: ChatMode;
|
|
91
|
+
isLoggedIn?: Ref<boolean>;
|
|
81
92
|
getAccessToken?: () => string;
|
|
82
93
|
getAgentKey?: () => string;
|
|
83
94
|
getActiveDocumentJson?: () => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/state/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,KAAK,UAAU,EAAY,MAAM,oBAAoB,CAAA;AAC9D,OAAO,EAAE,KAAK,4BAA4B,EAAmC,MAAM,6BAA6B,CAAA;AAChH,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,gCAAgC,CAAA;AAC1F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAEvE,OAAO,
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/state/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,KAAK,UAAU,EAAY,MAAM,oBAAoB,CAAA;AAC9D,OAAO,EAAE,KAAK,4BAA4B,EAAmC,MAAM,6BAA6B,CAAA;AAChH,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,gCAAgC,CAAA;AAC1F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAEvE,OAA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