@scalar/agent-chat 0.10.13 → 0.10.14
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.js +3 -3
- package/dist/App.vue.script.js +24 -20
- package/dist/App.vue.script.js.map +1 -1
- package/dist/Chat.vue.js +3 -3
- package/dist/Chat.vue.script.js +50 -39
- package/dist/Chat.vue.script.js.map +1 -1
- package/dist/_virtual/_plugin-vue_export-helper.js +5 -5
- package/dist/api.js +66 -57
- package/dist/api.js.map +1 -1
- package/dist/client-tools/execute-request.js +84 -60
- package/dist/client-tools/execute-request.js.map +1 -1
- package/dist/components/ActionsDropdown.vue.js +4 -4
- package/dist/components/ActionsDropdown.vue.script.js +29 -25
- package/dist/components/ActionsDropdown.vue.script.js.map +1 -1
- package/dist/components/ApprovalSection.vue.js +4 -4
- package/dist/components/ApprovalSection.vue.script.js +23 -18
- package/dist/components/ApprovalSection.vue.script.js.map +1 -1
- package/dist/components/AuthenticationProvided.vue.js +8 -7
- package/dist/components/AuthenticationProvided.vue.js.map +1 -1
- package/dist/components/AuthenticationRequired.vue.js +8 -7
- package/dist/components/AuthenticationRequired.vue.js.map +1 -1
- package/dist/components/AutosendPaused.vue.js +8 -7
- package/dist/components/AutosendPaused.vue.js.map +1 -1
- package/dist/components/BuildingRequest.vue.js +9 -8
- package/dist/components/BuildingRequest.vue.js.map +1 -1
- package/dist/components/ContextItem.vue.js +4 -4
- package/dist/components/ContextItem.vue.script.js +8 -5
- package/dist/components/ContextItem.vue.script.js.map +1 -1
- package/dist/components/ErrorMessage.vue.js +4 -4
- package/dist/components/ErrorMessage.vue.script.js +15 -12
- package/dist/components/ErrorMessage.vue.script.js.map +1 -1
- package/dist/components/FreeMessagesInfoSection.vue.js +4 -4
- package/dist/components/FreeMessagesInfoSection.vue.script.js +45 -34
- package/dist/components/FreeMessagesInfoSection.vue.script.js.map +1 -1
- package/dist/components/LoadingOpenAPISpecsSummary.vue.js +8 -7
- package/dist/components/LoadingOpenAPISpecsSummary.vue.js.map +1 -1
- package/dist/components/LoadingSearchOpenAPIOperations.vue.js +8 -7
- package/dist/components/LoadingSearchOpenAPIOperations.vue.js.map +1 -1
- package/dist/components/Logo.vue.js +9 -8
- package/dist/components/Logo.vue.js.map +1 -1
- package/dist/components/PaymentSection.vue.js +4 -4
- package/dist/components/PaymentSection.vue.script.js +20 -15
- package/dist/components/PaymentSection.vue.script.js.map +1 -1
- package/dist/components/RequestApproved.vue.js +8 -7
- package/dist/components/RequestApproved.vue.js.map +1 -1
- package/dist/components/RequestFailed.vue.js +9 -8
- package/dist/components/RequestFailed.vue.js.map +1 -1
- package/dist/components/RequestPreview.vue.js +4 -4
- package/dist/components/RequestPreview.vue.script.js +96 -73
- package/dist/components/RequestPreview.vue.script.js.map +1 -1
- package/dist/components/RequestRejected.vue.js +9 -8
- package/dist/components/RequestRejected.vue.js.map +1 -1
- package/dist/components/RequestSuccess.vue.js +8 -7
- package/dist/components/RequestSuccess.vue.js.map +1 -1
- package/dist/components/ResponseBody/ResponseBody.vue.js +3 -3
- package/dist/components/ResponseBody/ResponseBody.vue.script.js +33 -30
- package/dist/components/ResponseBody/ResponseBody.vue.script.js.map +1 -1
- package/dist/components/ResponseBody/ResponseBodyInfo.vue.js +9 -7
- package/dist/components/ResponseBody/ResponseBodyInfo.vue.js.map +1 -1
- package/dist/components/ResponseBody/ResponseBodyPreview.vue.js +4 -4
- package/dist/components/ResponseBody/ResponseBodyPreview.vue.script.js +51 -44
- package/dist/components/ResponseBody/ResponseBodyPreview.vue.script.js.map +1 -1
- package/dist/components/ResponseBody/ResponseBodyRaw.vue.js +3 -3
- package/dist/components/ResponseBody/ResponseBodyRaw.vue.script.js +13 -11
- package/dist/components/ResponseBody/ResponseBodyRaw.vue.script.js.map +1 -1
- package/dist/components/ResponseBody/ResponseBodyToggle.vue.js +3 -3
- package/dist/components/ResponseBody/ResponseBodyToggle.vue.script.js +17 -14
- package/dist/components/ResponseBody/ResponseBodyToggle.vue.script.js.map +1 -1
- package/dist/components/ResponseBody/helpers/media-types.js +37 -35
- package/dist/components/ResponseBody/helpers/media-types.js.map +1 -1
- package/dist/components/ResponseBody/helpers/process-response-body.js +30 -20
- package/dist/components/ResponseBody/helpers/process-response-body.js.map +1 -1
- package/dist/components/SearchPopover.vue.js +4 -4
- package/dist/components/SearchPopover.vue.script.js +52 -42
- package/dist/components/SearchPopover.vue.script.js.map +1 -1
- package/dist/components/Selector.vue.js +3 -3
- package/dist/components/Selector.vue.script.js +54 -45
- package/dist/components/Selector.vue.script.js.map +1 -1
- package/dist/components/SendingRequest.vue.js +9 -8
- package/dist/components/SendingRequest.vue.js.map +1 -1
- package/dist/components/ServerSelector.vue.js +3 -3
- package/dist/components/ServerSelector.vue.script.js +52 -43
- package/dist/components/ServerSelector.vue.script.js.map +1 -1
- package/dist/components/UploadSection.vue.js +4 -4
- package/dist/components/UploadSection.vue.script.js +38 -29
- package/dist/components/UploadSection.vue.script.js.map +1 -1
- package/dist/consts/urls.js +2 -2
- package/dist/consts/urls.js.map +1 -1
- package/dist/entities/error/constants.js +2 -2
- package/dist/entities/error/constants.js.map +1 -1
- package/dist/entities/error/helpers.js +4 -4
- package/dist/entities/error/helpers.js.map +1 -1
- package/dist/entities/index.js +10 -10
- package/dist/entities/prompt/constants.js +2 -2
- package/dist/entities/prompt/constants.js.map +1 -1
- package/dist/entities/registry/document.js +9 -9
- package/dist/entities/registry/document.js.map +1 -1
- package/dist/entities/tools/ask-for-authentication.js +6 -5
- package/dist/entities/tools/ask-for-authentication.js.map +1 -1
- package/dist/entities/tools/execute-request.js +10 -9
- package/dist/entities/tools/execute-request.js.map +1 -1
- package/dist/entities/tools/get-openapi-specs-summary.js +2 -2
- package/dist/entities/tools/get-openapi-specs-summary.js.map +1 -1
- package/dist/entities/tools/search-openapi-operations.js +4 -3
- package/dist/entities/tools/search-openapi-operations.js.map +1 -1
- package/dist/helpers.js +53 -27
- package/dist/helpers.js.map +1 -1
- package/dist/hooks/use-agent-key-documents.js +16 -15
- package/dist/hooks/use-agent-key-documents.js.map +1 -1
- package/dist/hooks/use-chat-approvals.js +27 -24
- package/dist/hooks/use-chat-approvals.js.map +1 -1
- package/dist/hooks/use-chat-error.js +19 -17
- package/dist/hooks/use-chat-error.js.map +1 -1
- package/dist/hooks/use-chat-pending-client-tool-parts.js +10 -8
- package/dist/hooks/use-chat-pending-client-tool-parts.js.map +1 -1
- package/dist/hooks/use-chat-scroll.js +13 -10
- package/dist/hooks/use-chat-scroll.js.map +1 -1
- package/dist/hooks/use-curated-documents.js +9 -8
- package/dist/hooks/use-curated-documents.js.map +1 -1
- package/dist/hooks/use-search.js +25 -16
- package/dist/hooks/use-search.js.map +1 -1
- package/dist/hooks/use-signup-link.js +19 -9
- package/dist/hooks/use-signup-link.js.map +1 -1
- package/dist/hooks/use-term-and-conditions.js +12 -11
- package/dist/hooks/use-term-and-conditions.js.map +1 -1
- package/dist/hooks/use-upload-tmp-document.js +67 -54
- package/dist/hooks/use-upload-tmp-document.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/package.json +9 -2
- package/dist/plugins/persistance.js +18 -10
- package/dist/plugins/persistance.js.map +1 -1
- package/dist/registry/add-documents-to-store.js +39 -33
- package/dist/registry/add-documents-to-store.js.map +1 -1
- package/dist/registry/create-document-name.js +3 -3
- package/dist/registry/create-document-name.js.map +1 -1
- package/dist/state/state.js +176 -132
- package/dist/state/state.js.map +1 -1
- package/dist/style.css +6596 -1
- package/dist/styles/tailwind.config.css +12 -0
- package/dist/views/Catalog/Catalog.vue.js +4 -4
- package/dist/views/Catalog/Catalog.vue.script.js +56 -39
- package/dist/views/Catalog/Catalog.vue.script.js.map +1 -1
- package/dist/views/Chat/Chat.vue.js +4 -4
- package/dist/views/Chat/Chat.vue.script.js +55 -43
- package/dist/views/Chat/Chat.vue.script.js.map +1 -1
- package/dist/views/Chat/Messages/AskForAuthentication.vue.js +4 -4
- package/dist/views/Chat/Messages/AskForAuthentication.vue.script.js +67 -55
- package/dist/views/Chat/Messages/AskForAuthentication.vue.script.js.map +1 -1
- package/dist/views/Chat/Messages/ExecuteRequestTool.vue.js +4 -4
- package/dist/views/Chat/Messages/ExecuteRequestTool.vue.script.js +29 -18
- package/dist/views/Chat/Messages/ExecuteRequestTool.vue.script.js.map +1 -1
- package/dist/views/Chat/Messages/GetOpenAPISpecsSummary.vue.js +3 -3
- package/dist/views/Chat/Messages/GetOpenAPISpecsSummary.vue.script.js +15 -10
- package/dist/views/Chat/Messages/GetOpenAPISpecsSummary.vue.script.js.map +1 -1
- package/dist/views/Chat/Messages/SearchOpenAPIOperationsTool.vue.js +4 -4
- package/dist/views/Chat/Messages/SearchOpenAPIOperationsTool.vue.script.js +55 -40
- package/dist/views/Chat/Messages/SearchOpenAPIOperationsTool.vue.script.js.map +1 -1
- package/dist/views/Chat/Messages/Text.vue.js +3 -3
- package/dist/views/Chat/Messages/Text.vue.script.js +8 -6
- package/dist/views/Chat/Messages/Text.vue.script.js.map +1 -1
- package/dist/views/Layout.vue.js +4 -4
- package/dist/views/Layout.vue.script.js +21 -17
- package/dist/views/Layout.vue.script.js.map +1 -1
- package/dist/views/PromptForm.vue.js +4 -4
- package/dist/views/PromptForm.vue.script.js +214 -170
- package/dist/views/PromptForm.vue.script.js.map +1 -1
- package/dist/views/Settings/Auth.vue.js +3 -3
- package/dist/views/Settings/Auth.vue.script.js +58 -46
- package/dist/views/Settings/Auth.vue.script.js.map +1 -1
- package/dist/views/Settings/DocSettings.vue.js +4 -4
- package/dist/views/Settings/DocSettings.vue.script.js +45 -39
- package/dist/views/Settings/DocSettings.vue.script.js.map +1 -1
- package/dist/views/Settings/Settings.vue.js +4 -4
- package/dist/views/Settings/Settings.vue.script.js +59 -48
- package/dist/views/Settings/Settings.vue.script.js.map +1 -1
- package/dist/views/Start.vue.js +4 -4
- package/dist/views/Start.vue.script.js +40 -33
- package/dist/views/Start.vue.script.js.map +1 -1
- package/dist/vue-styles.css +1341 -0
- package/package.json +17 -10
package/dist/helpers.js
CHANGED
|
@@ -1,44 +1,70 @@
|
|
|
1
|
-
import { getSecurityRequirements
|
|
2
|
-
import { REFERENCE_LS_KEYS
|
|
3
|
-
import { AuthSchema
|
|
4
|
-
import { coerceValue
|
|
1
|
+
import { getSecurityRequirements, getSecuritySchemes, getSelectedSecurity, getSelectedServer, getServers, mergeSecurity } from "@scalar/workspace-store/request-example";
|
|
2
|
+
import { REFERENCE_LS_KEYS, safeLocalStorage } from "@scalar/helpers/object/local-storage";
|
|
3
|
+
import { AuthSchema } from "@scalar/workspace-store/entities/auth";
|
|
4
|
+
import { coerceValue } from "@scalar/workspace-store/schemas/typebox-coerce";
|
|
5
5
|
//#region src/helpers.ts
|
|
6
|
-
function
|
|
7
|
-
return Object.values(
|
|
6
|
+
function getOperations(doc) {
|
|
7
|
+
return Object.values(doc.paths ?? {}).flatMap((path) => Object.values(path ?? {}));
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
/** Flattens all security requirements from a document */
|
|
10
|
+
function getSecurityFromDocument(documentName, document, authStore) {
|
|
11
|
+
const mergedSecurity = mergeSecurity(document?.components?.securitySchemes, {}, authStore, documentName);
|
|
12
|
+
const securityRequirements = getSecurityRequirements(document.security);
|
|
13
|
+
const selectedSecurity = getSelectedSecurity(authStore.getAuthSelectedSchemas({
|
|
11
14
|
type: "document",
|
|
12
|
-
documentName
|
|
13
|
-
}), void 0,
|
|
14
|
-
return
|
|
15
|
+
documentName
|
|
16
|
+
}), void 0, securityRequirements);
|
|
17
|
+
return getSecuritySchemes(mergedSecurity, selectedSecurity.selectedSchemes[selectedSecurity.selectedIndex] ?? {});
|
|
15
18
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
/** Generate document settings from workspace store */
|
|
20
|
+
function createDocumentSettings(workspaceStore) {
|
|
21
|
+
return Object.fromEntries(Object.entries(workspaceStore.workspace.documents).map(([key, document]) => {
|
|
22
|
+
return [key, {
|
|
23
|
+
activeServer: getSelectedServer(document, null, null, getServers(document.servers, { documentUrl: document?.["x-scalar-original-source-url"] })),
|
|
24
|
+
securitySchemes: getSecurityFromDocument(key, document, workspaceStore.auth)
|
|
25
|
+
}];
|
|
26
|
+
}));
|
|
21
27
|
}
|
|
22
|
-
var
|
|
23
|
-
|
|
28
|
+
var storage = safeLocalStorage();
|
|
29
|
+
/**
|
|
30
|
+
* Provides an interface to store and retrieve authentication scheme
|
|
31
|
+
* information in local storage, including both the available schemes and
|
|
32
|
+
* the user's selected schemes.
|
|
33
|
+
*/
|
|
34
|
+
var authStorage = () => {
|
|
35
|
+
const getKey = (slug) => {
|
|
36
|
+
return `${REFERENCE_LS_KEYS.AUTH}-${slug}`;
|
|
37
|
+
};
|
|
24
38
|
return {
|
|
25
|
-
getAuth: (
|
|
26
|
-
|
|
27
|
-
|
|
39
|
+
getAuth: (slug) => {
|
|
40
|
+
return coerceValue(AuthSchema, JSON.parse(storage.getItem(getKey(slug)) ?? "{}"));
|
|
41
|
+
},
|
|
42
|
+
setAuth: (slug, value) => {
|
|
43
|
+
storage.setItem(getKey(slug), JSON.stringify(value));
|
|
28
44
|
}
|
|
29
45
|
};
|
|
30
|
-
}, h = ({ documentName: e, workspaceStore: t }) => {
|
|
31
|
-
let n = m().getAuth(e);
|
|
32
|
-
t.auth.load({ [e]: n });
|
|
33
46
|
};
|
|
34
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Restores authentication secrets from local storage to the workspace store.
|
|
49
|
+
*
|
|
50
|
+
* This function iterates through stored authentication schemes and restores
|
|
51
|
+
* any secret values (keys starting with x-scalar-secret-) to the active
|
|
52
|
+
* document's security schemes. It uses the current security schemes as the
|
|
53
|
+
* source of truth, only restoring secrets for structures that exist in the
|
|
54
|
+
* current document.
|
|
55
|
+
*/
|
|
56
|
+
var restoreAuthSecretsFromStorage = ({ documentName, workspaceStore }) => {
|
|
57
|
+
const auth = authStorage().getAuth(documentName);
|
|
58
|
+
workspaceStore.auth.load({ [documentName]: auth });
|
|
59
|
+
};
|
|
60
|
+
function safeParseJson(value) {
|
|
35
61
|
try {
|
|
36
|
-
return JSON.parse(
|
|
62
|
+
return JSON.parse(value);
|
|
37
63
|
} catch {
|
|
38
64
|
return;
|
|
39
65
|
}
|
|
40
66
|
}
|
|
41
67
|
//#endregion
|
|
42
|
-
export {
|
|
68
|
+
export { authStorage, createDocumentSettings, getOperations, restoreAuthSecretsFromStorage, safeParseJson };
|
|
43
69
|
|
|
44
70
|
//# sourceMappingURL=helpers.js.map
|
package/dist/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","names":[],"sources":["../src/helpers.ts"],"sourcesContent":["import { REFERENCE_LS_KEYS, safeLocalStorage } from '@scalar/helpers/object/local-storage'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport type { AuthStore } from '@scalar/workspace-store/entities/auth'\nimport { type Auth, AuthSchema } from '@scalar/workspace-store/entities/auth'\nimport type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport {\n getSecurityRequirements,\n getSecuritySchemes,\n getSelectedSecurity,\n getSelectedServer,\n getServers,\n mergeSecurity,\n} from '@scalar/workspace-store/request-example'\nimport type { WorkspaceDocument } from '@scalar/workspace-store/schemas'\nimport { coerceValue } from '@scalar/workspace-store/schemas/typebox-coerce'\nimport type { OperationObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\nexport function getOperations(doc: Partial<OpenAPIV3_1.Document>) {\n return Object.values(doc.paths ?? {}).flatMap((path) => Object.values(path ?? {})) as OperationObject[]\n}\n\n/** Flattens all security requirements from a document */\nfunction getSecurityFromDocument(\n documentName: string,\n document: WorkspaceDocument,\n authStore: AuthStore,\n): SecuritySchemeObjectSecret[] {\n const mergedSecurity = mergeSecurity(document?.components?.securitySchemes, {}, authStore, documentName)\n\n const securityRequirements = getSecurityRequirements(document.security)\n\n const selectedSecurity = getSelectedSecurity(\n authStore.getAuthSelectedSchemas({\n type: 'document',\n documentName,\n }),\n undefined,\n securityRequirements,\n )\n\n return getSecuritySchemes(mergedSecurity, selectedSecurity.selectedSchemes[selectedSecurity.selectedIndex] ?? {})\n}\n\n/** Generate document settings from workspace store */\nexport function createDocumentSettings(workspaceStore: WorkspaceStore) {\n return Object.fromEntries(\n Object.entries(workspaceStore.workspace.documents).map(([key, document]) => {\n const servers = getServers(document.servers, {\n documentUrl: document?.['x-scalar-original-source-url'],\n })\n\n return [\n key,\n {\n activeServer: getSelectedServer(document, null, null, servers),\n securitySchemes: getSecurityFromDocument(key, document, workspaceStore.auth),\n },\n ]\n }),\n )\n}\n\n// Local storage helper instance, safely wrapped.\nconst storage = safeLocalStorage()\n\n/**\n * Provides an interface to store and retrieve authentication scheme\n * information in local storage, including both the available schemes and\n * the user's selected schemes.\n */\nexport const authStorage = () => {\n const getKey = (slug: string) => {\n return `${REFERENCE_LS_KEYS.AUTH}-${slug}`\n }\n\n return {\n /**\n * Retrieves and coerces the authentication schemes stored in local storage.\n */\n getAuth: (slug: string) => {\n const parsed = JSON.parse(storage.getItem(getKey(slug)) ?? '{}')\n return coerceValue(AuthSchema, parsed)\n },\n /**\n * Stores the authentication schemes in local storage.\n * @param value The Auth object to stringify and store.\n */\n setAuth: (slug: string, value: Auth) => {\n storage.setItem(getKey(slug), JSON.stringify(value))\n },\n }\n}\n\n/**\n * Restores authentication secrets from local storage to the workspace store.\n *\n * This function iterates through stored authentication schemes and restores\n * any secret values (keys starting with x-scalar-secret-) to the active\n * document's security schemes. It uses the current security schemes as the\n * source of truth, only restoring secrets for structures that exist in the\n * current document.\n */\nexport const restoreAuthSecretsFromStorage = ({\n documentName,\n workspaceStore,\n}: {\n documentName: string\n workspaceStore: WorkspaceStore\n}): void => {\n const authPersistence = authStorage()\n const auth = authPersistence.getAuth(documentName)\n workspaceStore.auth.load({ [documentName]: auth })\n}\n\nexport function safeParseJson(value: string) {\n try {\n return JSON.parse(value)\n } catch {\n return\n }\n}\n"],"mappings":";;;;;AAkBA,SAAgB,
|
|
1
|
+
{"version":3,"file":"helpers.js","names":[],"sources":["../src/helpers.ts"],"sourcesContent":["import { REFERENCE_LS_KEYS, safeLocalStorage } from '@scalar/helpers/object/local-storage'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport type { AuthStore } from '@scalar/workspace-store/entities/auth'\nimport { type Auth, AuthSchema } from '@scalar/workspace-store/entities/auth'\nimport type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport {\n getSecurityRequirements,\n getSecuritySchemes,\n getSelectedSecurity,\n getSelectedServer,\n getServers,\n mergeSecurity,\n} from '@scalar/workspace-store/request-example'\nimport type { WorkspaceDocument } from '@scalar/workspace-store/schemas'\nimport { coerceValue } from '@scalar/workspace-store/schemas/typebox-coerce'\nimport type { OperationObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\nexport function getOperations(doc: Partial<OpenAPIV3_1.Document>) {\n return Object.values(doc.paths ?? {}).flatMap((path) => Object.values(path ?? {})) as OperationObject[]\n}\n\n/** Flattens all security requirements from a document */\nfunction getSecurityFromDocument(\n documentName: string,\n document: WorkspaceDocument,\n authStore: AuthStore,\n): SecuritySchemeObjectSecret[] {\n const mergedSecurity = mergeSecurity(document?.components?.securitySchemes, {}, authStore, documentName)\n\n const securityRequirements = getSecurityRequirements(document.security)\n\n const selectedSecurity = getSelectedSecurity(\n authStore.getAuthSelectedSchemas({\n type: 'document',\n documentName,\n }),\n undefined,\n securityRequirements,\n )\n\n return getSecuritySchemes(mergedSecurity, selectedSecurity.selectedSchemes[selectedSecurity.selectedIndex] ?? {})\n}\n\n/** Generate document settings from workspace store */\nexport function createDocumentSettings(workspaceStore: WorkspaceStore) {\n return Object.fromEntries(\n Object.entries(workspaceStore.workspace.documents).map(([key, document]) => {\n const servers = getServers(document.servers, {\n documentUrl: document?.['x-scalar-original-source-url'],\n })\n\n return [\n key,\n {\n activeServer: getSelectedServer(document, null, null, servers),\n securitySchemes: getSecurityFromDocument(key, document, workspaceStore.auth),\n },\n ]\n }),\n )\n}\n\n// Local storage helper instance, safely wrapped.\nconst storage = safeLocalStorage()\n\n/**\n * Provides an interface to store and retrieve authentication scheme\n * information in local storage, including both the available schemes and\n * the user's selected schemes.\n */\nexport const authStorage = () => {\n const getKey = (slug: string) => {\n return `${REFERENCE_LS_KEYS.AUTH}-${slug}`\n }\n\n return {\n /**\n * Retrieves and coerces the authentication schemes stored in local storage.\n */\n getAuth: (slug: string) => {\n const parsed = JSON.parse(storage.getItem(getKey(slug)) ?? '{}')\n return coerceValue(AuthSchema, parsed)\n },\n /**\n * Stores the authentication schemes in local storage.\n * @param value The Auth object to stringify and store.\n */\n setAuth: (slug: string, value: Auth) => {\n storage.setItem(getKey(slug), JSON.stringify(value))\n },\n }\n}\n\n/**\n * Restores authentication secrets from local storage to the workspace store.\n *\n * This function iterates through stored authentication schemes and restores\n * any secret values (keys starting with x-scalar-secret-) to the active\n * document's security schemes. It uses the current security schemes as the\n * source of truth, only restoring secrets for structures that exist in the\n * current document.\n */\nexport const restoreAuthSecretsFromStorage = ({\n documentName,\n workspaceStore,\n}: {\n documentName: string\n workspaceStore: WorkspaceStore\n}): void => {\n const authPersistence = authStorage()\n const auth = authPersistence.getAuth(documentName)\n workspaceStore.auth.load({ [documentName]: auth })\n}\n\nexport function safeParseJson(value: string) {\n try {\n return JSON.parse(value)\n } catch {\n return\n }\n}\n"],"mappings":";;;;;AAkBA,SAAgB,cAAc,KAAoC;AAChE,QAAO,OAAO,OAAO,IAAI,SAAS,EAAE,CAAC,CAAC,SAAS,SAAS,OAAO,OAAO,QAAQ,EAAE,CAAC,CAAC;;;AAIpF,SAAS,wBACP,cACA,UACA,WAC8B;CAC9B,MAAM,iBAAiB,cAAc,UAAU,YAAY,iBAAiB,EAAE,EAAE,WAAW,aAAa;CAExG,MAAM,uBAAuB,wBAAwB,SAAS,SAAS;CAEvE,MAAM,mBAAmB,oBACvB,UAAU,uBAAuB;EAC/B,MAAM;EACN;EACD,CAAC,EACF,KAAA,GACA,qBACD;AAED,QAAO,mBAAmB,gBAAgB,iBAAiB,gBAAgB,iBAAiB,kBAAkB,EAAE,CAAC;;;AAInH,SAAgB,uBAAuB,gBAAgC;AACrE,QAAO,OAAO,YACZ,OAAO,QAAQ,eAAe,UAAU,UAAU,CAAC,KAAK,CAAC,KAAK,cAAc;AAK1E,SAAO,CACL,KACA;GACE,cAAc,kBAAkB,UAAU,MAAM,MAPpC,WAAW,SAAS,SAAS,EAC3C,aAAa,WAAW,iCACzB,CAAC,CAKgE;GAC9D,iBAAiB,wBAAwB,KAAK,UAAU,eAAe,KAAK;GAC7E,CACF;GACD,CACH;;AAIH,IAAM,UAAU,kBAAkB;;;;;;AAOlC,IAAa,oBAAoB;CAC/B,MAAM,UAAU,SAAiB;AAC/B,SAAO,GAAG,kBAAkB,KAAK,GAAG;;AAGtC,QAAO;EAIL,UAAU,SAAiB;AAEzB,UAAO,YAAY,YADJ,KAAK,MAAM,QAAQ,QAAQ,OAAO,KAAK,CAAC,IAAI,KAAK,CAC1B;;EAMxC,UAAU,MAAc,UAAgB;AACtC,WAAQ,QAAQ,OAAO,KAAK,EAAE,KAAK,UAAU,MAAM,CAAC;;EAEvD;;;;;;;;;;;AAYH,IAAa,iCAAiC,EAC5C,cACA,qBAIU;CAEV,MAAM,OADkB,aAAa,CACR,QAAQ,aAAa;AAClD,gBAAe,KAAK,KAAK,GAAG,eAAe,MAAM,CAAC;;AAGpD,SAAgB,cAAc,OAAe;AAC3C,KAAI;AACF,SAAO,KAAK,MAAM,MAAM;SAClB;AACN"}
|
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import { useState
|
|
2
|
-
import { onMounted
|
|
3
|
-
import { useToasts
|
|
1
|
+
import { useState } from "../state/state.js";
|
|
2
|
+
import { onMounted } from "vue";
|
|
3
|
+
import { useToasts } from "@scalar/use-toasts";
|
|
4
4
|
//#region src/hooks/use-agent-key-documents.ts
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
function useAgentKeyDocuments() {
|
|
6
|
+
const { api, addDocument, mode, getAgentKey } = useState();
|
|
7
|
+
const { toast } = useToasts();
|
|
8
|
+
onMounted(async () => {
|
|
9
|
+
if (mode !== "full" || !getAgentKey) return;
|
|
10
|
+
const keyDocumentsResult = await api.getKeyDocuments();
|
|
11
|
+
if (!keyDocumentsResult.success) {
|
|
12
|
+
toast("Failed to fetch your OpenAPI document. The Agent key may be invalid.", "error");
|
|
12
13
|
return;
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
-
namespace
|
|
16
|
-
slug
|
|
17
|
-
removable:
|
|
15
|
+
keyDocumentsResult.data.documents.forEach(({ namespace, slug }) => addDocument({
|
|
16
|
+
namespace,
|
|
17
|
+
slug,
|
|
18
|
+
removable: false
|
|
18
19
|
}));
|
|
19
20
|
});
|
|
20
21
|
}
|
|
21
22
|
//#endregion
|
|
22
|
-
export {
|
|
23
|
+
export { useAgentKeyDocuments };
|
|
23
24
|
|
|
24
25
|
//# sourceMappingURL=use-agent-key-documents.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-agent-key-documents.js","names":[],"sources":["../../src/hooks/use-agent-key-documents.ts"],"sourcesContent":["import { useToasts } from '@scalar/use-toasts'\nimport { onMounted } from 'vue'\n\nimport { useState } from '@/state/state'\n\nexport function useAgentKeyDocuments() {\n const { api, addDocument, mode, getAgentKey } = useState()\n const { toast } = useToasts()\n\n onMounted(async () => {\n if (mode !== 'full' || !getAgentKey) {\n return\n }\n\n const keyDocumentsResult = await api.getKeyDocuments()\n\n if (!keyDocumentsResult.success) {\n toast('Failed to fetch your OpenAPI document. The Agent key may be invalid.', 'error')\n return\n }\n\n keyDocumentsResult.data.documents.forEach(({ namespace, slug }) =>\n addDocument({ namespace, slug, removable: false }),\n )\n })\n}\n"],"mappings":";;;;AAKA,SAAgB,
|
|
1
|
+
{"version":3,"file":"use-agent-key-documents.js","names":[],"sources":["../../src/hooks/use-agent-key-documents.ts"],"sourcesContent":["import { useToasts } from '@scalar/use-toasts'\nimport { onMounted } from 'vue'\n\nimport { useState } from '@/state/state'\n\nexport function useAgentKeyDocuments() {\n const { api, addDocument, mode, getAgentKey } = useState()\n const { toast } = useToasts()\n\n onMounted(async () => {\n if (mode !== 'full' || !getAgentKey) {\n return\n }\n\n const keyDocumentsResult = await api.getKeyDocuments()\n\n if (!keyDocumentsResult.success) {\n toast('Failed to fetch your OpenAPI document. The Agent key may be invalid.', 'error')\n return\n }\n\n keyDocumentsResult.data.documents.forEach(({ namespace, slug }) =>\n addDocument({ namespace, slug, removable: false }),\n )\n })\n}\n"],"mappings":";;;;AAKA,SAAgB,uBAAuB;CACrC,MAAM,EAAE,KAAK,aAAa,MAAM,gBAAgB,UAAU;CAC1D,MAAM,EAAE,UAAU,WAAW;AAE7B,WAAU,YAAY;AACpB,MAAI,SAAS,UAAU,CAAC,YACtB;EAGF,MAAM,qBAAqB,MAAM,IAAI,iBAAiB;AAEtD,MAAI,CAAC,mBAAmB,SAAS;AAC/B,SAAM,wEAAwE,QAAQ;AACtF;;AAGF,qBAAmB,KAAK,UAAU,SAAS,EAAE,WAAW,WACtD,YAAY;GAAE;GAAW;GAAM,WAAW;GAAO,CAAC,CACnD;GACD"}
|
|
@@ -1,38 +1,41 @@
|
|
|
1
|
-
import { EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME
|
|
2
|
-
import { executeRequestTool
|
|
3
|
-
import { createDocumentSettings
|
|
4
|
-
import { useState
|
|
5
|
-
import { computed
|
|
1
|
+
import { EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME } from "../entities/tools/execute-request.js";
|
|
2
|
+
import { executeRequestTool } from "../client-tools/execute-request.js";
|
|
3
|
+
import { createDocumentSettings } from "../helpers.js";
|
|
4
|
+
import { useState } from "../state/state.js";
|
|
5
|
+
import { computed } from "vue";
|
|
6
6
|
//#region src/hooks/use-chat-approvals.ts
|
|
7
|
-
function
|
|
8
|
-
return
|
|
7
|
+
function requestPartRequiresApproval(part) {
|
|
8
|
+
return part.type === `tool-execute-request` && part.state === "input-available" && part.input?.method?.toLowerCase() !== "get";
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
function useRequestApprovals() {
|
|
11
|
+
const state = useState();
|
|
12
|
+
const approvalRequiredParts = computed(() => {
|
|
13
|
+
return state.chat.messages.filter((message) => message.parts.some(requestPartRequiresApproval)).flatMap((message) => message.parts).filter(requestPartRequiresApproval);
|
|
14
|
+
});
|
|
15
|
+
async function respondToRequestApprovals(approved) {
|
|
16
|
+
const approvalPromises = approvalRequiredParts.value.map(async (toolPart) => {
|
|
17
|
+
if (!approved) return await state.chat.addToolOutput({
|
|
18
|
+
tool: EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME,
|
|
19
|
+
toolCallId: toolPart.toolCallId,
|
|
17
20
|
state: "output-error",
|
|
18
21
|
errorText: "The user denied the request."
|
|
19
22
|
});
|
|
20
|
-
await
|
|
21
|
-
documentSettings:
|
|
22
|
-
proxyUrl:
|
|
23
|
-
input:
|
|
24
|
-
toolCallId:
|
|
25
|
-
chat:
|
|
23
|
+
await executeRequestTool({
|
|
24
|
+
documentSettings: createDocumentSettings(state.workspaceStore),
|
|
25
|
+
proxyUrl: state.proxyUrl.value,
|
|
26
|
+
input: toolPart.input,
|
|
27
|
+
toolCallId: toolPart.toolCallId,
|
|
28
|
+
chat: state.chat
|
|
26
29
|
});
|
|
27
30
|
});
|
|
28
|
-
await Promise.all(
|
|
31
|
+
await Promise.all(approvalPromises);
|
|
29
32
|
}
|
|
30
33
|
return {
|
|
31
|
-
approvalRequiredParts
|
|
32
|
-
respondToRequestApprovals
|
|
34
|
+
approvalRequiredParts,
|
|
35
|
+
respondToRequestApprovals
|
|
33
36
|
};
|
|
34
37
|
}
|
|
35
38
|
//#endregion
|
|
36
|
-
export {
|
|
39
|
+
export { requestPartRequiresApproval, useRequestApprovals };
|
|
37
40
|
|
|
38
41
|
//# sourceMappingURL=use-chat-approvals.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-chat-approvals.js","names":[],"sources":["../../src/hooks/use-chat-approvals.ts"],"sourcesContent":["import type { ToolUIPart, UIMessagePart } from 'ai'\nimport { computed } from 'vue'\n\nimport { executeRequestTool } from '@/client-tools/execute-request'\nimport { EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME } from '@/entities'\nimport { createDocumentSettings } from '@/helpers'\nimport { type Tools, useState } from '@/state/state'\n\ntype RequestToolPart = ToolUIPart & {\n type: 'tool-execute-request'\n state: 'input-available'\n input: Tools['execute-request']['input']\n}\n\nexport function requestPartRequiresApproval(part: UIMessagePart<any, Tools>): part is RequestToolPart {\n return (\n part.type === (`tool-${EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME}` as const) &&\n part.state === 'input-available' &&\n part.input?.method?.toLowerCase() !== 'get'\n )\n}\n\nexport function useRequestApprovals() {\n const state = useState()\n\n const approvalRequiredParts = computed(() => {\n return state.chat.messages\n .filter((message) => message.parts.some(requestPartRequiresApproval))\n .flatMap((message) => message.parts)\n .filter(requestPartRequiresApproval) as RequestToolPart[]\n })\n\n async function respondToRequestApprovals(approved: boolean) {\n const approvalPromises = approvalRequiredParts.value.map(async (toolPart) => {\n if (!approved) {\n return await state.chat.addToolOutput({\n tool: EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME,\n toolCallId: toolPart.toolCallId,\n state: 'output-error',\n errorText: 'The user denied the request.',\n })\n }\n\n await executeRequestTool({\n documentSettings: createDocumentSettings(state.workspaceStore),\n proxyUrl: state.proxyUrl.value,\n input: toolPart.input,\n toolCallId: toolPart.toolCallId,\n chat: state.chat,\n })\n })\n\n await Promise.all(approvalPromises)\n }\n\n return { approvalRequiredParts, respondToRequestApprovals }\n}\n"],"mappings":";;;;;;AAcA,SAAgB,
|
|
1
|
+
{"version":3,"file":"use-chat-approvals.js","names":[],"sources":["../../src/hooks/use-chat-approvals.ts"],"sourcesContent":["import type { ToolUIPart, UIMessagePart } from 'ai'\nimport { computed } from 'vue'\n\nimport { executeRequestTool } from '@/client-tools/execute-request'\nimport { EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME } from '@/entities'\nimport { createDocumentSettings } from '@/helpers'\nimport { type Tools, useState } from '@/state/state'\n\ntype RequestToolPart = ToolUIPart & {\n type: 'tool-execute-request'\n state: 'input-available'\n input: Tools['execute-request']['input']\n}\n\nexport function requestPartRequiresApproval(part: UIMessagePart<any, Tools>): part is RequestToolPart {\n return (\n part.type === (`tool-${EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME}` as const) &&\n part.state === 'input-available' &&\n part.input?.method?.toLowerCase() !== 'get'\n )\n}\n\nexport function useRequestApprovals() {\n const state = useState()\n\n const approvalRequiredParts = computed(() => {\n return state.chat.messages\n .filter((message) => message.parts.some(requestPartRequiresApproval))\n .flatMap((message) => message.parts)\n .filter(requestPartRequiresApproval) as RequestToolPart[]\n })\n\n async function respondToRequestApprovals(approved: boolean) {\n const approvalPromises = approvalRequiredParts.value.map(async (toolPart) => {\n if (!approved) {\n return await state.chat.addToolOutput({\n tool: EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME,\n toolCallId: toolPart.toolCallId,\n state: 'output-error',\n errorText: 'The user denied the request.',\n })\n }\n\n await executeRequestTool({\n documentSettings: createDocumentSettings(state.workspaceStore),\n proxyUrl: state.proxyUrl.value,\n input: toolPart.input,\n toolCallId: toolPart.toolCallId,\n chat: state.chat,\n })\n })\n\n await Promise.all(approvalPromises)\n }\n\n return { approvalRequiredParts, respondToRequestApprovals }\n}\n"],"mappings":";;;;;;AAcA,SAAgB,4BAA4B,MAA0D;AACpG,QACE,KAAK,SAAU,0BACf,KAAK,UAAU,qBACf,KAAK,OAAO,QAAQ,aAAa,KAAK;;AAI1C,SAAgB,sBAAsB;CACpC,MAAM,QAAQ,UAAU;CAExB,MAAM,wBAAwB,eAAe;AAC3C,SAAO,MAAM,KAAK,SACf,QAAQ,YAAY,QAAQ,MAAM,KAAK,4BAA4B,CAAC,CACpE,SAAS,YAAY,QAAQ,MAAM,CACnC,OAAO,4BAA4B;GACtC;CAEF,eAAe,0BAA0B,UAAmB;EAC1D,MAAM,mBAAmB,sBAAsB,MAAM,IAAI,OAAO,aAAa;AAC3E,OAAI,CAAC,SACH,QAAO,MAAM,MAAM,KAAK,cAAc;IACpC,MAAM;IACN,YAAY,SAAS;IACrB,OAAO;IACP,WAAW;IACZ,CAAC;AAGJ,SAAM,mBAAmB;IACvB,kBAAkB,uBAAuB,MAAM,eAAe;IAC9D,UAAU,MAAM,SAAS;IACzB,OAAO,SAAS;IAChB,YAAY,SAAS;IACrB,MAAM,MAAM;IACb,CAAC;IACF;AAEF,QAAM,QAAQ,IAAI,iBAAiB;;AAGrC,QAAO;EAAE;EAAuB;EAA2B"}
|
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
import { safeParseJson
|
|
2
|
-
import { useState
|
|
3
|
-
import { computed
|
|
4
|
-
import { z
|
|
1
|
+
import { safeParseJson } from "../helpers.js";
|
|
2
|
+
import { useState } from "../state/state.js";
|
|
3
|
+
import { computed } from "vue";
|
|
4
|
+
import { z } from "zod/mini";
|
|
5
5
|
//#region src/hooks/use-chat-error.ts
|
|
6
|
-
var
|
|
7
|
-
message:
|
|
8
|
-
code:
|
|
9
|
-
status:
|
|
6
|
+
var chatErrorSchema = z.object({
|
|
7
|
+
message: z.string(),
|
|
8
|
+
code: z.string(),
|
|
9
|
+
status: z.optional(z.number())
|
|
10
10
|
});
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
return
|
|
14
|
-
if (!
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
function useChatError() {
|
|
12
|
+
const { chat } = useState();
|
|
13
|
+
return computed(() => {
|
|
14
|
+
if (!chat.error) return;
|
|
15
|
+
const errorJson = safeParseJson(chat.error.message);
|
|
16
|
+
const parsedError = chatErrorSchema.safeParse(errorJson);
|
|
17
|
+
if (!errorJson || !parsedError.success) return {
|
|
18
|
+
message: chat.error.message,
|
|
18
19
|
code: "UNKNOWN_ERROR"
|
|
19
|
-
}
|
|
20
|
+
};
|
|
21
|
+
return parsedError.data;
|
|
20
22
|
});
|
|
21
23
|
}
|
|
22
24
|
//#endregion
|
|
23
|
-
export {
|
|
25
|
+
export { useChatError };
|
|
24
26
|
|
|
25
27
|
//# sourceMappingURL=use-chat-error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-chat-error.js","names":[],"sources":["../../src/hooks/use-chat-error.ts"],"sourcesContent":["import { computed } from 'vue'\nimport { z } from 'zod/mini'\n\nimport { safeParseJson } from '@/helpers'\nimport { useState } from '@/state/state'\n\nconst chatErrorSchema = z.object({\n message: z.string(),\n code: z.string(),\n status: z.optional(z.number()),\n})\nexport type ChatError = z.infer<typeof chatErrorSchema>\n\nexport function useChatError() {\n const { chat } = useState()\n\n return computed(() => {\n if (!chat.error) return\n\n const errorJson = safeParseJson(chat.error.message)\n const parsedError = chatErrorSchema.safeParse(errorJson)\n\n if (!errorJson || !parsedError.success)\n return {\n message: chat.error.message,\n code: 'UNKNOWN_ERROR',\n }\n\n return parsedError.data\n })\n}\n"],"mappings":";;;;;AAMA,IAAM,
|
|
1
|
+
{"version":3,"file":"use-chat-error.js","names":[],"sources":["../../src/hooks/use-chat-error.ts"],"sourcesContent":["import { computed } from 'vue'\nimport { z } from 'zod/mini'\n\nimport { safeParseJson } from '@/helpers'\nimport { useState } from '@/state/state'\n\nconst chatErrorSchema = z.object({\n message: z.string(),\n code: z.string(),\n status: z.optional(z.number()),\n})\nexport type ChatError = z.infer<typeof chatErrorSchema>\n\nexport function useChatError() {\n const { chat } = useState()\n\n return computed(() => {\n if (!chat.error) return\n\n const errorJson = safeParseJson(chat.error.message)\n const parsedError = chatErrorSchema.safeParse(errorJson)\n\n if (!errorJson || !parsedError.success)\n return {\n message: chat.error.message,\n code: 'UNKNOWN_ERROR',\n }\n\n return parsedError.data\n })\n}\n"],"mappings":";;;;;AAMA,IAAM,kBAAkB,EAAE,OAAO;CAC/B,SAAS,EAAE,QAAQ;CACnB,MAAM,EAAE,QAAQ;CAChB,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC;CAC/B,CAAC;AAGF,SAAgB,eAAe;CAC7B,MAAM,EAAE,SAAS,UAAU;AAE3B,QAAO,eAAe;AACpB,MAAI,CAAC,KAAK,MAAO;EAEjB,MAAM,YAAY,cAAc,KAAK,MAAM,QAAQ;EACnD,MAAM,cAAc,gBAAgB,UAAU,UAAU;AAExD,MAAI,CAAC,aAAa,CAAC,YAAY,QAC7B,QAAO;GACL,SAAS,KAAK,MAAM;GACpB,MAAM;GACP;AAEH,SAAO,YAAY;GACnB"}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { useState
|
|
2
|
-
import { computed
|
|
1
|
+
import { useState } from "../state/state.js";
|
|
2
|
+
import { computed } from "vue";
|
|
3
3
|
//#region src/hooks/use-chat-pending-client-tool-parts.ts
|
|
4
|
-
function
|
|
5
|
-
return
|
|
4
|
+
function isPendingClientToolPart(part) {
|
|
5
|
+
return part.type.startsWith("tool") && part.state === "input-available";
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
return { pendingClientToolParts:
|
|
7
|
+
function useChatPendingClientToolParts() {
|
|
8
|
+
const state = useState();
|
|
9
|
+
return { pendingClientToolParts: computed(() => {
|
|
10
|
+
return state.chat.messages.filter((message) => message.parts.some(isPendingClientToolPart)).flatMap((message) => message.parts).filter(isPendingClientToolPart);
|
|
11
|
+
}) };
|
|
10
12
|
}
|
|
11
13
|
//#endregion
|
|
12
|
-
export {
|
|
14
|
+
export { useChatPendingClientToolParts };
|
|
13
15
|
|
|
14
16
|
//# sourceMappingURL=use-chat-pending-client-tool-parts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-chat-pending-client-tool-parts.js","names":[],"sources":["../../src/hooks/use-chat-pending-client-tool-parts.ts"],"sourcesContent":["import type { ToolUIPart, UIMessagePart, UITools } from 'ai'\nimport { computed } from 'vue'\n\nimport { useState } from '@/state/state'\n\ntype PendingClientToolPart = ToolUIPart & { state: 'input-available' }\n\nfunction isPendingClientToolPart(part: UIMessagePart<any, UITools>): part is PendingClientToolPart {\n return part.type.startsWith('tool') && (part as ToolUIPart).state === 'input-available'\n}\n\nexport function useChatPendingClientToolParts() {\n const state = useState()\n\n const pendingClientToolParts = computed(() => {\n return state.chat.messages\n .filter((message) => message.parts.some(isPendingClientToolPart))\n .flatMap((message) => message.parts)\n .filter(isPendingClientToolPart) as PendingClientToolPart[]\n })\n\n return { pendingClientToolParts }\n}\n"],"mappings":";;;AAOA,SAAS,
|
|
1
|
+
{"version":3,"file":"use-chat-pending-client-tool-parts.js","names":[],"sources":["../../src/hooks/use-chat-pending-client-tool-parts.ts"],"sourcesContent":["import type { ToolUIPart, UIMessagePart, UITools } from 'ai'\nimport { computed } from 'vue'\n\nimport { useState } from '@/state/state'\n\ntype PendingClientToolPart = ToolUIPart & { state: 'input-available' }\n\nfunction isPendingClientToolPart(part: UIMessagePart<any, UITools>): part is PendingClientToolPart {\n return part.type.startsWith('tool') && (part as ToolUIPart).state === 'input-available'\n}\n\nexport function useChatPendingClientToolParts() {\n const state = useState()\n\n const pendingClientToolParts = computed(() => {\n return state.chat.messages\n .filter((message) => message.parts.some(isPendingClientToolPart))\n .flatMap((message) => message.parts)\n .filter(isPendingClientToolPart) as PendingClientToolPart[]\n })\n\n return { pendingClientToolParts }\n}\n"],"mappings":";;;AAOA,SAAS,wBAAwB,MAAkE;AACjG,QAAO,KAAK,KAAK,WAAW,OAAO,IAAK,KAAoB,UAAU;;AAGxE,SAAgB,gCAAgC;CAC9C,MAAM,QAAQ,UAAU;AASxB,QAAO,EAAE,wBAPsB,eAAe;AAC5C,SAAO,MAAM,KAAK,SACf,QAAQ,YAAY,QAAQ,MAAM,KAAK,wBAAwB,CAAC,CAChE,SAAS,YAAY,QAAQ,MAAM,CACnC,OAAO,wBAAwB;GAClC,EAE+B"}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import { useState
|
|
2
|
-
import { nextTick
|
|
1
|
+
import { useState } from "../state/state.js";
|
|
2
|
+
import { nextTick, watch } from "vue";
|
|
3
3
|
//#region src/hooks/use-chat-scroll.ts
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
-
if (
|
|
4
|
+
function useChatScroll() {
|
|
5
|
+
const state = useState();
|
|
6
|
+
function getMsgContent(msg) {
|
|
7
|
+
const lastPart = msg?.parts.at(-1);
|
|
8
|
+
if (!lastPart) return;
|
|
9
|
+
if (lastPart.type !== "text") return;
|
|
10
|
+
return lastPart.text;
|
|
9
11
|
}
|
|
10
|
-
|
|
11
|
-
await
|
|
12
|
+
watch([() => state.chat.status, () => getMsgContent(state.chat.lastMessage)], async () => {
|
|
13
|
+
await nextTick();
|
|
14
|
+
window.scrollTo(0, document.body.scrollHeight);
|
|
12
15
|
});
|
|
13
16
|
}
|
|
14
17
|
//#endregion
|
|
15
|
-
export {
|
|
18
|
+
export { useChatScroll };
|
|
16
19
|
|
|
17
20
|
//# sourceMappingURL=use-chat-scroll.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-chat-scroll.js","names":[],"sources":["../../src/hooks/use-chat-scroll.ts"],"sourcesContent":["import type { UIMessage } from 'ai'\nimport { nextTick, watch } from 'vue'\n\nimport { useState } from '@/state/state'\n\nexport function useChatScroll() {\n const state = useState()\n\n function getMsgContent(msg?: UIMessage) {\n const lastPart = msg?.parts.at(-1)\n if (!lastPart) return\n\n if (lastPart.type !== 'text') return\n\n return lastPart.text\n }\n\n watch([() => state.chat.status, () => getMsgContent(state.chat.lastMessage)], async () => {\n await nextTick()\n window.scrollTo(0, document.body.scrollHeight)\n })\n}\n"],"mappings":";;;AAKA,SAAgB,
|
|
1
|
+
{"version":3,"file":"use-chat-scroll.js","names":[],"sources":["../../src/hooks/use-chat-scroll.ts"],"sourcesContent":["import type { UIMessage } from 'ai'\nimport { nextTick, watch } from 'vue'\n\nimport { useState } from '@/state/state'\n\nexport function useChatScroll() {\n const state = useState()\n\n function getMsgContent(msg?: UIMessage) {\n const lastPart = msg?.parts.at(-1)\n if (!lastPart) return\n\n if (lastPart.type !== 'text') return\n\n return lastPart.text\n }\n\n watch([() => state.chat.status, () => getMsgContent(state.chat.lastMessage)], async () => {\n await nextTick()\n window.scrollTo(0, document.body.scrollHeight)\n })\n}\n"],"mappings":";;;AAKA,SAAgB,gBAAgB;CAC9B,MAAM,QAAQ,UAAU;CAExB,SAAS,cAAc,KAAiB;EACtC,MAAM,WAAW,KAAK,MAAM,GAAG,GAAG;AAClC,MAAI,CAAC,SAAU;AAEf,MAAI,SAAS,SAAS,OAAQ;AAE9B,SAAO,SAAS;;AAGlB,OAAM,OAAO,MAAM,KAAK,cAAc,cAAc,MAAM,KAAK,YAAY,CAAC,EAAE,YAAY;AACxF,QAAM,UAAU;AAChB,SAAO,SAAS,GAAG,SAAS,KAAK,aAAa;GAC9C"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { useState
|
|
2
|
-
import { onMounted
|
|
1
|
+
import { useState } from "../state/state.js";
|
|
2
|
+
import { onMounted } from "vue";
|
|
3
3
|
//#region src/hooks/use-curated-documents.ts
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
function useCuratedDocuments() {
|
|
5
|
+
const { api, curatedDocuments } = useState();
|
|
6
|
+
onMounted(async () => {
|
|
7
|
+
const getCuratedDocumentsResult = await api.getCuratedDocuments();
|
|
8
|
+
if (!getCuratedDocumentsResult.success) return;
|
|
9
|
+
curatedDocuments.value = getCuratedDocumentsResult.data.results;
|
|
9
10
|
});
|
|
10
11
|
}
|
|
11
12
|
//#endregion
|
|
12
|
-
export {
|
|
13
|
+
export { useCuratedDocuments };
|
|
13
14
|
|
|
14
15
|
//# sourceMappingURL=use-curated-documents.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-curated-documents.js","names":[],"sources":["../../src/hooks/use-curated-documents.ts"],"sourcesContent":["import { onMounted } from 'vue'\n\nimport { useState } from '@/state/state'\n\nexport function useCuratedDocuments() {\n const { api, curatedDocuments } = useState()\n\n onMounted(async () => {\n const getCuratedDocumentsResult = await api.getCuratedDocuments()\n\n if (!getCuratedDocumentsResult.success) {\n return\n }\n\n curatedDocuments.value = getCuratedDocumentsResult.data.results\n })\n}\n"],"mappings":";;;AAIA,SAAgB,
|
|
1
|
+
{"version":3,"file":"use-curated-documents.js","names":[],"sources":["../../src/hooks/use-curated-documents.ts"],"sourcesContent":["import { onMounted } from 'vue'\n\nimport { useState } from '@/state/state'\n\nexport function useCuratedDocuments() {\n const { api, curatedDocuments } = useState()\n\n onMounted(async () => {\n const getCuratedDocumentsResult = await api.getCuratedDocuments()\n\n if (!getCuratedDocumentsResult.success) {\n return\n }\n\n curatedDocuments.value = getCuratedDocumentsResult.data.results\n })\n}\n"],"mappings":";;;AAIA,SAAgB,sBAAsB;CACpC,MAAM,EAAE,KAAK,qBAAqB,UAAU;AAE5C,WAAU,YAAY;EACpB,MAAM,4BAA4B,MAAM,IAAI,qBAAqB;AAEjE,MAAI,CAAC,0BAA0B,QAC7B;AAGF,mBAAiB,QAAQ,0BAA0B,KAAK;GACxD"}
|
package/dist/hooks/use-search.js
CHANGED
|
@@ -1,23 +1,32 @@
|
|
|
1
|
-
import { useState
|
|
2
|
-
import { computed
|
|
3
|
-
import { useDebounceFn
|
|
1
|
+
import { useState } from "../state/state.js";
|
|
2
|
+
import { computed, ref } from "vue";
|
|
3
|
+
import { useDebounceFn } from "@vueuse/core";
|
|
4
4
|
//#region src/hooks/use-search.ts
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
function useSearch() {
|
|
6
|
+
const { api } = useState();
|
|
7
|
+
const queryRef = ref("");
|
|
8
|
+
const search = useDebounceFn(async (q) => {
|
|
9
|
+
const searchResponse = await api.search(q);
|
|
10
|
+
if (!searchResponse.success) return;
|
|
11
|
+
results.value = searchResponse.data.results;
|
|
12
|
+
}, 200);
|
|
13
|
+
const query = computed({
|
|
14
|
+
get: () => {
|
|
15
|
+
return queryRef.value;
|
|
16
|
+
},
|
|
17
|
+
set: (v) => {
|
|
18
|
+
search(v);
|
|
19
|
+
queryRef.value = v;
|
|
13
20
|
}
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
});
|
|
22
|
+
const results = ref([]);
|
|
23
|
+
search("");
|
|
24
|
+
return {
|
|
25
|
+
query,
|
|
26
|
+
results
|
|
18
27
|
};
|
|
19
28
|
}
|
|
20
29
|
//#endregion
|
|
21
|
-
export {
|
|
30
|
+
export { useSearch };
|
|
22
31
|
|
|
23
32
|
//# sourceMappingURL=use-search.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-search.js","names":[],"sources":["../../src/hooks/use-search.ts"],"sourcesContent":["import { useDebounceFn } from '@vueuse/core'\nimport { computed, ref } from 'vue'\n\nimport type { ApiMetadata } from '@/entities/registry/document'\nimport { useState } from '@/state/state'\n\nexport function useSearch() {\n const { api } = useState()\n\n const queryRef = ref('')\n\n const search = useDebounceFn(async (q) => {\n const searchResponse = await api.search(q)\n\n if (!searchResponse.success) {\n return\n }\n\n results.value = searchResponse.data.results\n }, 200)\n\n const query = computed({\n get: () => {\n return queryRef.value\n },\n set: (v) => {\n search(v)\n queryRef.value = v\n },\n })\n\n const results = ref<ApiMetadata[]>([])\n\n search('')\n\n return {\n query,\n results,\n }\n}\n"],"mappings":";;;;AAMA,SAAgB,
|
|
1
|
+
{"version":3,"file":"use-search.js","names":[],"sources":["../../src/hooks/use-search.ts"],"sourcesContent":["import { useDebounceFn } from '@vueuse/core'\nimport { computed, ref } from 'vue'\n\nimport type { ApiMetadata } from '@/entities/registry/document'\nimport { useState } from '@/state/state'\n\nexport function useSearch() {\n const { api } = useState()\n\n const queryRef = ref('')\n\n const search = useDebounceFn(async (q) => {\n const searchResponse = await api.search(q)\n\n if (!searchResponse.success) {\n return\n }\n\n results.value = searchResponse.data.results\n }, 200)\n\n const query = computed({\n get: () => {\n return queryRef.value\n },\n set: (v) => {\n search(v)\n queryRef.value = v\n },\n })\n\n const results = ref<ApiMetadata[]>([])\n\n search('')\n\n return {\n query,\n results,\n }\n}\n"],"mappings":";;;;AAMA,SAAgB,YAAY;CAC1B,MAAM,EAAE,QAAQ,UAAU;CAE1B,MAAM,WAAW,IAAI,GAAG;CAExB,MAAM,SAAS,cAAc,OAAO,MAAM;EACxC,MAAM,iBAAiB,MAAM,IAAI,OAAO,EAAE;AAE1C,MAAI,CAAC,eAAe,QAClB;AAGF,UAAQ,QAAQ,eAAe,KAAK;IACnC,IAAI;CAEP,MAAM,QAAQ,SAAS;EACrB,WAAW;AACT,UAAO,SAAS;;EAElB,MAAM,MAAM;AACV,UAAO,EAAE;AACT,YAAS,QAAQ;;EAEpB,CAAC;CAEF,MAAM,UAAU,IAAmB,EAAE,CAAC;AAEtC,QAAO,GAAG;AAEV,QAAO;EACL;EACA;EACD"}
|
|
@@ -1,17 +1,27 @@
|
|
|
1
|
-
import { useState
|
|
2
|
-
import { computed
|
|
1
|
+
import { useState } from "../state/state.js";
|
|
2
|
+
import { computed } from "vue";
|
|
3
3
|
//#region src/hooks/use-signup-link.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Agent Scalar signup/upgrade URL for both full (agent.scalar.com) and embedded
|
|
6
|
+
* (@scalar/api-reference) modes.
|
|
7
|
+
*
|
|
8
|
+
* In embedded mode, includes register flow and optional docUrl when a temporary document was uploaded.
|
|
9
|
+
*/
|
|
10
|
+
function useSignupLink() {
|
|
11
|
+
const { dashboardUrl, mode, uploadedTmpDocumentUrl } = useState();
|
|
12
|
+
const signupLink = computed(() => {
|
|
13
|
+
if (mode === "full") return dashboardUrl;
|
|
14
|
+
return uploadedTmpDocumentUrl.value ? `${dashboardUrl}/register?flow=oss-agent&docUrl=${uploadedTmpDocumentUrl.value}` : dashboardUrl;
|
|
15
|
+
});
|
|
16
|
+
function navigateToSignup() {
|
|
17
|
+
window.location.assign(signupLink.value);
|
|
8
18
|
}
|
|
9
19
|
return {
|
|
10
|
-
signupLink
|
|
11
|
-
navigateToSignup
|
|
20
|
+
signupLink,
|
|
21
|
+
navigateToSignup
|
|
12
22
|
};
|
|
13
23
|
}
|
|
14
24
|
//#endregion
|
|
15
|
-
export {
|
|
25
|
+
export { useSignupLink };
|
|
16
26
|
|
|
17
27
|
//# sourceMappingURL=use-signup-link.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-signup-link.js","names":[],"sources":["../../src/hooks/use-signup-link.ts"],"sourcesContent":["import type { ComputedRef } from 'vue'\nimport { computed } from 'vue'\n\nimport { useState } from '@/state/state'\n\n/**\n * Agent Scalar signup/upgrade URL for both full (agent.scalar.com) and embedded\n * (@scalar/api-reference) modes.\n *\n * In embedded mode, includes register flow and optional docUrl when a temporary document was uploaded.\n */\nexport function useSignupLink(): {\n signupLink: ComputedRef<string>\n navigateToSignup: () => void\n} {\n const { dashboardUrl, mode, uploadedTmpDocumentUrl } = useState()\n\n const signupLink = computed(() => {\n // we use mode 'full' on agent.scalar.com\n if (mode === 'full') {\n return dashboardUrl\n }\n\n // we use mode 'preview' in @scalar/api-reference\n return uploadedTmpDocumentUrl.value\n ? `${dashboardUrl}/register?flow=oss-agent&docUrl=${uploadedTmpDocumentUrl.value}`\n : dashboardUrl\n })\n\n function navigateToSignup() {\n window.location.assign(signupLink.value)\n }\n\n return { signupLink, navigateToSignup }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-signup-link.js","names":[],"sources":["../../src/hooks/use-signup-link.ts"],"sourcesContent":["import type { ComputedRef } from 'vue'\nimport { computed } from 'vue'\n\nimport { useState } from '@/state/state'\n\n/**\n * Agent Scalar signup/upgrade URL for both full (agent.scalar.com) and embedded\n * (@scalar/api-reference) modes.\n *\n * In embedded mode, includes register flow and optional docUrl when a temporary document was uploaded.\n */\nexport function useSignupLink(): {\n signupLink: ComputedRef<string>\n navigateToSignup: () => void\n} {\n const { dashboardUrl, mode, uploadedTmpDocumentUrl } = useState()\n\n const signupLink = computed(() => {\n // we use mode 'full' on agent.scalar.com\n if (mode === 'full') {\n return dashboardUrl\n }\n\n // we use mode 'preview' in @scalar/api-reference\n return uploadedTmpDocumentUrl.value\n ? `${dashboardUrl}/register?flow=oss-agent&docUrl=${uploadedTmpDocumentUrl.value}`\n : dashboardUrl\n })\n\n function navigateToSignup() {\n window.location.assign(signupLink.value)\n }\n\n return { signupLink, navigateToSignup }\n}\n"],"mappings":";;;;;;;;;AAWA,SAAgB,gBAGd;CACA,MAAM,EAAE,cAAc,MAAM,2BAA2B,UAAU;CAEjE,MAAM,aAAa,eAAe;AAEhC,MAAI,SAAS,OACX,QAAO;AAIT,SAAO,uBAAuB,QAC1B,GAAG,aAAa,kCAAkC,uBAAuB,UACzE;GACJ;CAEF,SAAS,mBAAmB;AAC1B,SAAO,SAAS,OAAO,WAAW,MAAM;;AAG1C,QAAO;EAAE;EAAY;EAAkB"}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import { onMounted
|
|
1
|
+
import { onMounted, ref } from "vue";
|
|
2
2
|
//#region src/hooks/use-term-and-conditions.ts
|
|
3
|
-
var
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
var TERMS_AND_CONDITIONS_LS_KEY = "scalar/agent-terms-accepted";
|
|
4
|
+
function useTermsAndConditions() {
|
|
5
|
+
const accepted = ref(false);
|
|
6
|
+
onMounted(() => {
|
|
7
|
+
accepted.value = localStorage.getItem(TERMS_AND_CONDITIONS_LS_KEY) === "true";
|
|
8
8
|
});
|
|
9
|
-
function
|
|
10
|
-
|
|
9
|
+
function accept() {
|
|
10
|
+
accepted.value = true;
|
|
11
|
+
localStorage.setItem(TERMS_AND_CONDITIONS_LS_KEY, "true");
|
|
11
12
|
}
|
|
12
13
|
return {
|
|
13
|
-
accepted
|
|
14
|
-
accept
|
|
14
|
+
accepted,
|
|
15
|
+
accept
|
|
15
16
|
};
|
|
16
17
|
}
|
|
17
18
|
//#endregion
|
|
18
|
-
export {
|
|
19
|
+
export { useTermsAndConditions };
|
|
19
20
|
|
|
20
21
|
//# sourceMappingURL=use-term-and-conditions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-term-and-conditions.js","names":[],"sources":["../../src/hooks/use-term-and-conditions.ts"],"sourcesContent":["import { onMounted, ref } from 'vue'\n\nconst TERMS_AND_CONDITIONS_LS_KEY = 'scalar/agent-terms-accepted'\n\nexport function useTermsAndConditions() {\n const accepted = ref(false)\n\n onMounted(() => {\n accepted.value = localStorage.getItem(TERMS_AND_CONDITIONS_LS_KEY) === 'true'\n })\n\n function accept() {\n accepted.value = true\n localStorage.setItem(TERMS_AND_CONDITIONS_LS_KEY, 'true')\n }\n\n return { accepted, accept }\n}\n"],"mappings":";;AAEA,IAAM,
|
|
1
|
+
{"version":3,"file":"use-term-and-conditions.js","names":[],"sources":["../../src/hooks/use-term-and-conditions.ts"],"sourcesContent":["import { onMounted, ref } from 'vue'\n\nconst TERMS_AND_CONDITIONS_LS_KEY = 'scalar/agent-terms-accepted'\n\nexport function useTermsAndConditions() {\n const accepted = ref(false)\n\n onMounted(() => {\n accepted.value = localStorage.getItem(TERMS_AND_CONDITIONS_LS_KEY) === 'true'\n })\n\n function accept() {\n accepted.value = true\n localStorage.setItem(TERMS_AND_CONDITIONS_LS_KEY, 'true')\n }\n\n return { accepted, accept }\n}\n"],"mappings":";;AAEA,IAAM,8BAA8B;AAEpC,SAAgB,wBAAwB;CACtC,MAAM,WAAW,IAAI,MAAM;AAE3B,iBAAgB;AACd,WAAS,QAAQ,aAAa,QAAQ,4BAA4B,KAAK;GACvE;CAEF,SAAS,SAAS;AAChB,WAAS,QAAQ;AACjB,eAAa,QAAQ,6BAA6B,OAAO;;AAG3D,QAAO;EAAE;EAAU;EAAQ"}
|