@scalar/agent-chat 0.12.55 → 0.12.56
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 +3 -4
- package/dist/App.vue.d.ts.map +1 -1
- package/dist/App.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/App.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/Chat.vue.d.ts.map +1 -1
- package/dist/Chat.vue_vue_type_script_setup_true_lang.js +2 -3
- package/dist/Chat.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/client-tools/execute-request.d.ts.map +1 -1
- package/dist/client-tools/execute-request.js +2 -1
- package/dist/client-tools/execute-request.js.map +1 -1
- package/dist/client-tools/redact-secrets.d.ts.map +1 -1
- package/dist/client-tools/redact-secrets.js +5 -3
- package/dist/client-tools/redact-secrets.js.map +1 -1
- package/dist/components/RequestPreview.vue.d.ts.map +1 -1
- package/dist/components/RequestPreview.vue.js +1 -1
- package/dist/components/RequestPreview.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/RequestPreview.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/helpers.d.ts +2 -1
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +4 -4
- package/dist/helpers.js.map +1 -1
- package/dist/hooks/use-chat-approvals.js +1 -1
- package/dist/hooks/use-chat-approvals.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/package.json +1 -1
- package/dist/state/state.d.ts +3 -4
- package/dist/state/state.d.ts.map +1 -1
- package/dist/state/state.js +8 -5
- package/dist/state/state.js.map +1 -1
- package/dist/style.css +47 -18
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/vue-styles.css +16 -16
- package/package.json +9 -9
package/dist/App.vue.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Ref } from 'vue';
|
|
2
2
|
import { type RegistryDocument } from './state/state.js';
|
|
3
|
-
import { type ChatMode } from './types.js';
|
|
3
|
+
import { type ChatMode, type SelectedDocument } from './types.js';
|
|
4
4
|
type __VLS_Props = {
|
|
5
5
|
registryDocuments: RegistryDocument[];
|
|
6
6
|
registryUrl: string;
|
|
@@ -11,8 +11,8 @@ type __VLS_Props = {
|
|
|
11
11
|
getAccessToken?: () => string;
|
|
12
12
|
getAgentKey?: () => string;
|
|
13
13
|
getActiveDocumentJson?: () => string;
|
|
14
|
-
/**
|
|
15
|
-
|
|
14
|
+
/** Scopes outgoing requests without adding context to conversation messages. */
|
|
15
|
+
getActiveDocumentSelection?: () => SelectedDocument | undefined;
|
|
16
16
|
isLoggedIn?: Ref<boolean>;
|
|
17
17
|
prefilledMessage?: Ref<string>;
|
|
18
18
|
hideAddApi?: boolean;
|
|
@@ -62,7 +62,6 @@ declare const state: {
|
|
|
62
62
|
uploadedTmpDocumentUrl: Ref<string | undefined>;
|
|
63
63
|
curatedDocuments: Ref<import("./entities/index.js").ApiMetadata[]>;
|
|
64
64
|
getActiveDocumentJson?: () => string;
|
|
65
|
-
getActiveDocumentContext?: () => string | undefined;
|
|
66
65
|
hideAddApi?: boolean;
|
|
67
66
|
};
|
|
68
67
|
export type ChatExposed = {
|
package/dist/App.vue.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.vue.d.ts","sourceRoot":"","sources":["../src/App.vue"],"names":[],"mappings":"AA6EA,OAAO,EAAW,KAAK,GAAG,EAAE,MAAM,KAAK,CAAA;AAGvC,OAAO,EAA6B,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAChF,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"App.vue.d.ts","sourceRoot":"","sources":["../src/App.vue"],"names":[],"mappings":"AA6EA,OAAO,EAAW,KAAK,GAAG,EAAE,MAAM,KAAK,CAAA;AAGvC,OAAO,EAA6B,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAChF,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE9D,KAAK,WAAW,GAAG;IACjB,iBAAiB,EAAE,gBAAgB,EAAE,CAAA;IACrC,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,gBAAgB,EAAE,MAAM,CAAA;IACxB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,QAAQ,CAAA;IACf,cAAc,CAAC,EAAE,MAAM,MAAM,CAAA;IAC7B,WAAW,CAAC,EAAE,MAAM,MAAM,CAAA;IAC1B,qBAAqB,CAAC,EAAE,MAAM,MAAM,CAAA;IACpC,gFAAgF;IAChF,0BAA0B,CAAC,EAAE,MAAM,gBAAgB,GAAG,SAAS,CAAA;IAC/D,UAAU,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IACzB,gBAAgB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC9B,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,CAAC;AAuBF,QAAA,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;iBA2BmC,CAAC;WAAc,CAAC;;;;;iBAC/B,CAAC;;;;;;;;;;;;;;CAd9B,CAAA;AAIF,MAAM,MAAM,WAAW,GAAG;IACxB,gBAAgB,EAAE,OAAO,KAAK,CAAC,gBAAgB,CAAA;CAChD,CAAA;AA+CD,QAAA,MAAM,YAAY;;;;kFAIhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -14,7 +14,7 @@ var App_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCompon
|
|
|
14
14
|
getAccessToken: { type: Function },
|
|
15
15
|
getAgentKey: { type: Function },
|
|
16
16
|
getActiveDocumentJson: { type: Function },
|
|
17
|
-
|
|
17
|
+
getActiveDocumentSelection: { type: Function },
|
|
18
18
|
isLoggedIn: {},
|
|
19
19
|
prefilledMessage: {},
|
|
20
20
|
hideAddApi: { type: Boolean }
|
|
@@ -23,7 +23,7 @@ var App_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCompon
|
|
|
23
23
|
setup(__props, { expose: __expose }) {
|
|
24
24
|
const state = createState({
|
|
25
25
|
getActiveDocumentJson: __props.getActiveDocumentJson,
|
|
26
|
-
|
|
26
|
+
getActiveDocumentSelection: __props.getActiveDocumentSelection,
|
|
27
27
|
initialRegistryDocuments: __props.registryDocuments,
|
|
28
28
|
prefilledMessageRef: __props.prefilledMessage,
|
|
29
29
|
platformProxyUrl: __props.platformProxyUrl,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.vue_vue_type_script_setup_true_lang.js","names":["$emit","_openBlock","_createBlock","Chat"],"sources":["../src/App.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { provide, type Ref } from 'vue'\n\nimport Chat from '@/Chat.vue'\nimport { createState, STATE_SYMBOL, type RegistryDocument } from '@/state/state'\nimport { type ChatMode } from '@/types'\n\nconst {\n dashboardUrl,\n platformProxyUrl,\n registryDocuments,\n registryUrl,\n baseUrl,\n mode = 'full',\n getAccessToken,\n getAgentKey,\n getActiveDocumentJson,\n
|
|
1
|
+
{"version":3,"file":"App.vue_vue_type_script_setup_true_lang.js","names":["$emit","_openBlock","_createBlock","Chat"],"sources":["../src/App.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { provide, type Ref } from 'vue'\n\nimport Chat from '@/Chat.vue'\nimport { createState, STATE_SYMBOL, type RegistryDocument } from '@/state/state'\nimport { type ChatMode, type SelectedDocument } from '@/types'\n\nconst {\n dashboardUrl,\n platformProxyUrl,\n registryDocuments,\n registryUrl,\n baseUrl,\n mode = 'full',\n getAccessToken,\n getAgentKey,\n getActiveDocumentJson,\n getActiveDocumentSelection,\n isLoggedIn,\n prefilledMessage,\n hideAddApi,\n} = defineProps<{\n registryDocuments: RegistryDocument[]\n registryUrl: string\n dashboardUrl: string\n platformProxyUrl: string\n baseUrl: string\n mode?: ChatMode\n getAccessToken?: () => string\n getAgentKey?: () => string\n getActiveDocumentJson?: () => string\n /** Scopes outgoing requests without adding context to conversation messages. */\n getActiveDocumentSelection?: () => SelectedDocument | undefined\n isLoggedIn?: Ref<boolean>\n prefilledMessage?: Ref<string>\n hideAddApi?: boolean\n}>()\n\ndefineEmits<{\n (e: 'uploadApi'): void\n}>()\n\nconst state = createState({\n getActiveDocumentJson,\n getActiveDocumentSelection,\n initialRegistryDocuments: registryDocuments,\n prefilledMessageRef: prefilledMessage,\n platformProxyUrl,\n registryUrl,\n baseUrl,\n mode,\n getAccessToken,\n getAgentKey,\n isLoggedIn,\n dashboardUrl,\n hideAddApi,\n})\n\nprovide(STATE_SYMBOL, state)\n\nexport type ChatExposed = {\n addDocumentAsync: typeof state.addDocumentAsync\n}\n\ndefineExpose<ChatExposed>({\n addDocumentAsync: state.addDocumentAsync,\n})\n</script>\n\n<template>\n <Chat @uploadApi=\"$emit('uploadApi')\" />\n</template>\n\n<style scoped></style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;EA0CA,MAAM,QAAQ,YAAY;GACxB,uBAAoB,QAAA;GACpB,4BAAyB,QAAA;GACzB,0BAA0B,QAAA;GAC1B,qBAAqB,QAAA;GACrB,kBAAe,QAAA;GACf,aAAU,QAAA;GACV,SAAM,QAAA;GACN,MAAG,QAAA;GACH,gBAAa,QAAA;GACb,aAAU,QAAA;GACV,YAAS,QAAA;GACT,cAAW,QAAA;GACX,YAAS,QAAA;EACX,CAAC;EAED,QAAQ,cAAc,KAAK;EAM3B,SAA0B,EACxB,kBAAkB,MAAM,iBAC1B,CAAC;;GAIC,OAAAC,UAAA,GAAAC,YAAwCC,cAAA,EAAjC,aAAS,OAAA,OAAA,OAAA,MAAA,WAAEH,KAAAA,MAAK,WAAA,G"}
|
package/dist/Chat.vue.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chat.vue.d.ts","sourceRoot":"","sources":["../src/Chat.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Chat.vue.d.ts","sourceRoot":"","sources":["../src/Chat.vue"],"names":[],"mappings":"AA0SA,QAAA,MAAM,YAAY;;;;iFAEhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -15,7 +15,7 @@ var Chat_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCompo
|
|
|
15
15
|
__name: "Chat",
|
|
16
16
|
emits: ["uploadApi"],
|
|
17
17
|
setup(__props) {
|
|
18
|
-
const { chat, prompt, settingsModal, eventBus, workspaceStore, config, mode, addDocument, getActiveDocumentJson,
|
|
18
|
+
const { chat, prompt, settingsModal, eventBus, workspaceStore, config, mode, addDocument, getActiveDocumentJson, terms } = useState();
|
|
19
19
|
const clientModalRef = useTemplateRef("clientModal");
|
|
20
20
|
const stopClientEvents = initializeWorkspaceEventHandlers({
|
|
21
21
|
eventBus,
|
|
@@ -61,8 +61,7 @@ var Chat_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCompo
|
|
|
61
61
|
useAgentKeyDocuments();
|
|
62
62
|
useCuratedDocuments();
|
|
63
63
|
async function handleSubmit() {
|
|
64
|
-
|
|
65
|
-
await chat.sendMessage({ text: context ? `${prompt.value}\n\nSelected API description: ${context}` : prompt.value });
|
|
64
|
+
await chat.sendMessage({ text: prompt.value });
|
|
66
65
|
}
|
|
67
66
|
return (_ctx, _cache) => {
|
|
68
67
|
return openBlock(), createElementBlock(Fragment, null, [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chat.vue_vue_type_script_setup_true_lang.js","names":["$emit","_openBlock","_createElementBlock","_createElementVNode","_toDisplayString","_createVNode","Layout","Settings","_unref"],"sources":["../src/Chat.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { useLazyApiClient } from '@scalar/api-client/modal/use-lazy-api-client'\nimport { initializeWorkspaceEventHandlers } from '@scalar/api-client/v2/workspace-events'\nimport { onBeforeUnmount, onMounted, ref, useTemplateRef, watch } from 'vue'\n\nimport { useAgentKeyDocuments } from '@/hooks/use-agent-key-documents'\nimport { useChatScroll } from '@/hooks/use-chat-scroll'\nimport { useCuratedDocuments } from '@/hooks/use-curated-documents'\nimport {\n getTmpDocFromLocalStorage,\n useUploadTmpDocument,\n} from '@/hooks/use-upload-tmp-document'\nimport { useState } from '@/state/state'\nimport Layout from '@/views/Layout.vue'\nimport Settings from '@/views/Settings/Settings.vue'\n\ndefineEmits<{\n (e: 'uploadApi'): void\n}>()\n\nconst {\n chat,\n prompt,\n settingsModal,\n eventBus,\n workspaceStore,\n config,\n mode,\n addDocument,\n getActiveDocumentJson,\n
|
|
1
|
+
{"version":3,"file":"Chat.vue_vue_type_script_setup_true_lang.js","names":["$emit","_openBlock","_createElementBlock","_createElementVNode","_toDisplayString","_createVNode","Layout","Settings","_unref"],"sources":["../src/Chat.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { useLazyApiClient } from '@scalar/api-client/modal/use-lazy-api-client'\nimport { initializeWorkspaceEventHandlers } from '@scalar/api-client/v2/workspace-events'\nimport { onBeforeUnmount, onMounted, ref, useTemplateRef, watch } from 'vue'\n\nimport { useAgentKeyDocuments } from '@/hooks/use-agent-key-documents'\nimport { useChatScroll } from '@/hooks/use-chat-scroll'\nimport { useCuratedDocuments } from '@/hooks/use-curated-documents'\nimport {\n getTmpDocFromLocalStorage,\n useUploadTmpDocument,\n} from '@/hooks/use-upload-tmp-document'\nimport { useState } from '@/state/state'\nimport Layout from '@/views/Layout.vue'\nimport Settings from '@/views/Settings/Settings.vue'\n\ndefineEmits<{\n (e: 'uploadApi'): void\n}>()\n\nconst {\n chat,\n prompt,\n settingsModal,\n eventBus,\n workspaceStore,\n config,\n mode,\n addDocument,\n getActiveDocumentJson,\n terms,\n} = useState()\n\nconst clientModalRef = useTemplateRef<HTMLElement>('clientModal')\n// Authentication and server controls also work before the request editor opens.\nconst stopClientEvents = initializeWorkspaceEventHandlers({\n eventBus,\n store: ref(workspaceStore),\n hooks: {},\n})\nconst clientLoadingStatus = ref<'idle' | 'loading' | 'error'>('idle')\nuseLazyApiClient({\n eventBus,\n status: clientLoadingStatus,\n load: async () => {\n const { createApiClientModal } = await import('@scalar/api-client/modal')\n return () => {\n if (!clientModalRef.value) {\n return null\n }\n stopClientEvents()\n return createApiClientModal({\n el: clientModalRef.value,\n options: config,\n eventBus,\n workspaceStore,\n })\n }\n },\n})\nonBeforeUnmount(stopClientEvents)\n\nonMounted(async () => {\n const tmpDoc = getTmpDocFromLocalStorage()\n\n if (mode === 'preview' && tmpDoc && !getActiveDocumentJson) {\n await addDocument({\n namespace: tmpDoc.namespace,\n slug: tmpDoc.slug,\n removable: false,\n tmp: true,\n })\n }\n})\n\nconst { uploadTempDocument } = useUploadTmpDocument()\nwatch(\n terms.accepted,\n (accepted) => {\n if (accepted && mode === 'preview' && getActiveDocumentJson) {\n void uploadTempDocument(getActiveDocumentJson(), true)\n }\n },\n { immediate: true },\n)\nonBeforeUnmount(() => {\n void chat.stop()\n})\n\nuseChatScroll()\nuseAgentKeyDocuments()\nuseCuratedDocuments()\n\nasync function handleSubmit() {\n await chat.sendMessage({ text: prompt.value })\n}\n</script>\n\n<template>\n <div ref=\"clientModal\" />\n <div\n v-if=\"clientLoadingStatus !== 'idle'\"\n class=\"bg-b-1 text-c-1 fixed right-4 bottom-4 z-[10001] rounded-lg border px-4 py-3 text-sm shadow-lg\"\n :role=\"clientLoadingStatus === 'error' ? 'alert' : 'status'\">\n {{\n clientLoadingStatus === 'loading'\n ? 'Loading request editor…'\n : 'Could not load the request editor. Refresh the page and try again.'\n }}\n </div>\n <Layout\n @submit=\"handleSubmit\"\n @uploadApi=\"$emit('uploadApi')\" />\n <Settings :modalState=\"settingsModal\" />\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;EAoBA,MAAM,EACJ,MACA,QACA,eACA,UACA,gBACA,QACA,M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K,WAAA;;IACnBK,YAAwCE,kBAAA,EAA7B,YAAYC,MAAA,aAAA,EAAa,GAAA,MAAA,GAAA,CAAA,YAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute-request.d.ts","sourceRoot":"","sources":["../../src/client-tools/execute-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"execute-request.d.ts","sourceRoot":"","sources":["../../src/client-tools/execute-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAIvC,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAA;AAEzF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAChG,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,IAAI,CAAA;AAOhD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AA8F1C;;GAEG;AACH,eAAO,MAAM,kBAAkB;sBAQT,MAAM,CACtB,MAAM,EACN;QAAE,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;QAAC,eAAe,EAAE,0BAA0B,EAAE,CAAA;KAAE,CACrF;gBACW,MAAM;UACZ,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;cACxC,MAAM;WACT;QACL,MAAM,EAAE,MAAM,CAAA;QACd,IAAI,EAAE,MAAM,CAAA;QACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QAChC,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,YAAY,EAAE,MAAM,CAAA;KACrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kHA2GJ,CAAA"}
|
|
@@ -4,6 +4,7 @@ import { createSecretRedactor } from "./redact-secrets.js";
|
|
|
4
4
|
import { n } from "neverpanic";
|
|
5
5
|
import { redirectToProxy } from "@scalar/helpers/url/redirect-to-proxy";
|
|
6
6
|
import { buildRequestSecurity, getResolvedUrl } from "@scalar/workspace-store/request-example";
|
|
7
|
+
import { formatTokenPrefix } from "@scalar/helpers/http/format-token-prefix";
|
|
7
8
|
import { restoreOriginalHeaders } from "@scalar/helpers/http/restore-original-headers";
|
|
8
9
|
import { encode } from "js-base64";
|
|
9
10
|
import truncateJson from "truncate-json";
|
|
@@ -85,7 +86,7 @@ var executeRequestTool = n.safeFn(async ({ documentSettings, toolCallId, chat, p
|
|
|
85
86
|
const securityValue = (() => {
|
|
86
87
|
if (securityOption.format === "basic") return `Basic ${encode(securityOption.value)}`;
|
|
87
88
|
if (securityOption.format === "bearer") return `Bearer ${securityOption.value}`;
|
|
88
|
-
return securityOption.value;
|
|
89
|
+
return formatTokenPrefix(securityOption.value, securityOption.tokenPrefix);
|
|
89
90
|
})();
|
|
90
91
|
if (securityOption.in === "header") acc.headers[securityOption.name] = securityValue;
|
|
91
92
|
else if (securityOption.in === "query") acc.queryParams.set(securityOption.name, securityValue);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute-request.js","names":["encodeBase64"],"sources":["../../src/client-tools/execute-request.ts"],"sourcesContent":["import type { Chat } from '@ai-sdk/vue'\nimport { restoreOriginalHeaders } from '@scalar/helpers/http/restore-original-headers'\nimport { redirectToProxy } from '@scalar/helpers/url/redirect-to-proxy'\nimport type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport { buildRequestSecurity, getResolvedUrl } from '@scalar/workspace-store/request-example'\nimport type { ServerObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport type { UIDataTypes, UIMessage } from 'ai'\nimport { encode as encodeBase64 } from 'js-base64'\nimport { n } from 'neverpanic'\nimport truncateJson from 'truncate-json'\n\nimport { EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME } from '@/entities'\nimport { createError } from '@/entities/error/helpers'\nimport type { Tools } from '@/state/state'\n\nimport { createSecretRedactor } from './redact-secrets'\n\n// The maximum number of bytes the requests response can be.\nconst MAX_RESPONSE_SIZE = 50_000\n\nconst getBody = n.safeFn(\n async (response: Response) => {\n const contentType = response.headers.get('content-type')\n\n if (contentType === 'application/json') {\n return { success: true, data: await response.json() }\n }\n\n return { success: true, data: await response.text() }\n },\n (originalError) => createError('FAILED_TO_PARSE_RESPONSE_BODY', { originalError }),\n)\n\nconst truncateResponse = (response: unknown) =>\n JSON.parse(truncateJson(JSON.stringify(response), MAX_RESPONSE_SIZE).jsonString)\n\n/* Result type wrapper for fetch */\nconst safeFetch = n.safeFn(\n async (url: string, init: RequestInit) => {\n const response = await fetch(url, init)\n\n const responseBodyResult = await getBody(response)\n\n if (!response.ok) {\n // Response URLs can contain credentials, so keep them out of model-visible tool output.\n return {\n success: false,\n error: createError('REQUEST_NOT_OK', {\n status: response.status,\n responseBody: responseBodyResult.success ? responseBodyResult.data : undefined,\n headers: Object.fromEntries(restoreOriginalHeaders(response.headers).entries()),\n }),\n }\n }\n\n if (!responseBodyResult.success) {\n return responseBodyResult\n }\n\n return {\n success: true,\n data: {\n status: response.status,\n responseBody: responseBodyResult.data,\n headers: Object.fromEntries(restoreOriginalHeaders(response.headers).entries()),\n },\n }\n },\n (originalError) => createError('FAILED_TO_FETCH', { originalError }),\n)\n\n/** Validate the exact destination that will receive credentials before applying the proxy. */\nconst createDestination = (\n path: string,\n activeServer: ServerObject | null,\n queryParams: URLSearchParams,\n): { url: string; error?: never } | { url?: never; error: string } => {\n if (!activeServer?.url?.trim()) {\n return { error: 'Add a server to the API description before sending an API request.' }\n }\n\n const pathname = path.split('?')[0] ?? ''\n if (\n !pathname.startsWith('/') ||\n pathname.startsWith('//') ||\n pathname.includes('\\\\') ||\n // biome-ignore lint/suspicious/noControlCharactersInRegex: Reject characters that URL parsers silently normalize.\n /[\\u0000-\\u001f\\u007f]/.test(pathname)\n ) {\n return { error: 'Request paths must be relative endpoints beginning with a single forward slash.' }\n }\n\n try {\n const serverUrl = new URL(getResolvedUrl({ server: activeServer, path: '' }))\n const requestUrl = new URL(getResolvedUrl({ server: activeServer, path, urlParams: queryParams }))\n if (\n (requestUrl.protocol !== 'http:' && requestUrl.protocol !== 'https:') ||\n requestUrl.origin !== serverUrl.origin\n ) {\n return { error: 'Request destinations must use the selected HTTP or HTTPS server.' }\n }\n return { url: requestUrl.href }\n } catch {\n return { error: 'Select a valid HTTP or HTTPS server before sending an API request.' }\n }\n}\n\n/**\n * Executes an HTTP request with the specified options, including method, path, headers, and security schemes, and returns the processed response.\n */\nexport const executeRequestTool = n.safeFn(\n async ({\n documentSettings,\n toolCallId,\n chat,\n proxyUrl,\n input: { method, path, body, headers, documentName },\n }: {\n documentSettings: Record<\n string,\n { activeServer: ServerObject | null; securitySchemes: SecuritySchemeObjectSecret[] }\n >\n toolCallId: string\n chat: Chat<UIMessage<unknown, UIDataTypes, Tools>>\n proxyUrl: string\n input: {\n method: string\n path: string\n headers?: Record<string, string>\n body?: string\n documentName: string\n }\n }) => {\n const settings = documentSettings[documentName]\n\n if (!settings) {\n void chat.addToolOutput({\n tool: EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME,\n toolCallId,\n state: 'output-error',\n errorText: 'The selected API could not be found. Select an available API before sending a request.',\n })\n return {\n success: false,\n error: createError('DOCUMENT_SETTINGS_COULD_NOT_BE_DETERMINED', {\n documentName,\n }),\n }\n }\n\n const requestSecurityOptions = buildRequestSecurity(settings.securitySchemes)\n\n const requestSecurity = requestSecurityOptions.reduce<{\n headers: Record<string, string>\n queryParams: URLSearchParams\n cookies: Record<string, string>\n }>(\n (acc, securityOption) => {\n /** Format the security value based on its authentication scheme. */\n const securityValue = (() => {\n if (securityOption.format === 'basic') {\n return `Basic ${encodeBase64(securityOption.value)}`\n }\n if (securityOption.format === 'bearer') {\n return `Bearer ${securityOption.value}`\n }\n return securityOption.value\n })()\n\n if (securityOption.in === 'header') {\n acc.headers[securityOption.name] = securityValue\n } else if (securityOption.in === 'query') {\n acc.queryParams.set(securityOption.name, securityValue)\n } else if (securityOption.in === 'cookie') {\n acc.cookies[securityOption.name] = securityValue\n }\n\n return acc\n },\n {\n headers: {},\n queryParams: new URLSearchParams(),\n cookies: {},\n },\n )\n\n const destination = createDestination(path, settings.activeServer, requestSecurity.queryParams)\n if (destination.error) {\n // Tool callbacks run inside the stream queue, so do not await a write to that same queue.\n void chat.addToolOutput({\n tool: EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME,\n toolCallId,\n state: 'output-error',\n errorText: destination.error,\n })\n return { success: false, error: createError('FAILED_TO_EXECUTE_REQUEST', destination.error) }\n }\n\n const cookieHeader = Object.entries(requestSecurity.cookies)\n .map(([name, value]) => `${name}=${value}`)\n .join('; ')\n\n const fetchOptions: RequestInit = {\n redirect: 'error',\n method,\n body,\n headers: {\n ...headers,\n ...requestSecurity.headers,\n Cookie: cookieHeader,\n },\n }\n\n const url = redirectToProxy(proxyUrl, destination.url)\n\n const redact = createSecretRedactor(requestSecurityOptions)\n const result = await safeFetch(url, fetchOptions)\n // Redact complete values before truncation can split a credential at the size limit.\n if (result.success) {\n result.data.responseBody = truncateResponse(redact(result.data.responseBody))\n result.data.headers = redact(result.data.headers)\n } else if (result.error.code === 'REQUEST_NOT_OK') {\n if (result.error.detail.responseBody !== undefined) {\n result.error.detail.responseBody = truncateResponse(redact(result.error.detail.responseBody))\n }\n result.error.detail.headers = redact(result.error.detail.headers)\n }\n\n void chat.addToolOutput({\n tool: EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME,\n toolCallId,\n output: result,\n state: 'output-available',\n })\n\n return result\n },\n (originalError) => createError('FAILED_TO_EXECUTE_REQUEST', originalError),\n)\n"],"mappings":";;;;;;;;;;AAkBA,IAAM,oBAAoB;AAE1B,IAAM,UAAU,EAAE,OAChB,OAAO,aAAuB;CAG5B,IAFoB,SAAS,QAAQ,IAAI,cAErC,MAAgB,oBAClB,OAAO;EA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AI,YAAY,OAAO;EAErB,KAAU,cAAc;GACtB,MAAM;GACN;GACA,OAAO;GACP,WAAW,YAAY;EACzB,CAAC;EACD,OAAO;GAAE,SAAS;GAAO,OAAO,YAAY,6BAA6B,YAAY,KAAK;EAAE;CAC9F;CAEA,MAAM,eAAe,OAAO,QAAQ,gBAAgB,OAAO,CAAC,CACzD,KAAK,CAAC,MAAM,WAAW,GAAG,KAAK,GAAG,OAAO,CAAC,CAC1C,KAAK,IAAI;CAEZ,MAAM,eAA4B;EAChC,UAAU;EACV;EACA;EACA,SAAS;GACP,GAAG;GACH,GAAG,gBAAgB;GACnB,QAAQ;EACV;CACF;CAEA,MAAM,MAAM,gBAAgB,UAAU,YAAY,GAAG;CAErD,MAAM,SAAS,qBAAqB,sBAAsB;CAC1D,MAAM,SAAS,MAAM,UAAU,KAAK,YAAY;CAEhD,IAAI,OAAO,SAAS;EAClB,OAAO,KAAK,eAAe,iBAAiB,OAAO,OAAO,KAAK,YAAY,CAAC;EAC5E,OAAO,KAAK,UAAU,OAAO,OAAO,KAAK,OAAO;CAClD,OAAO,IAAI,OAAO,MAAM,SAAS,kBAAkB;EACjD,IAAI,OAAO,MAAM,OAAO,iBAAiB,KAAA,GACvC,OAAO,MAAM,OAAO,eAAe,iBAAiB,OAAO,OAAO,MAAM,OAAO,YAAY,CAAC;EAE9F,OAAO,MAAM,OAAO,UAAU,OAAO,OAAO,MAAM,OAAO,OAAO;CAClE;CAEA,KAAU,cAAc;EACtB,MAAM;EACN;EACA,QAAQ;EACR,OAAO;CACT,CAAC;CAED,OAAO;AACT,IACC,kBAAkB,YAAY,6BAA6B,aAAa,CAC3E"}
|
|
1
|
+
{"version":3,"file":"execute-request.js","names":["encodeBase64"],"sources":["../../src/client-tools/execute-request.ts"],"sourcesContent":["import type { Chat } from '@ai-sdk/vue'\nimport { formatTokenPrefix } from '@scalar/helpers/http/format-token-prefix'\nimport { restoreOriginalHeaders } from '@scalar/helpers/http/restore-original-headers'\nimport { redirectToProxy } from '@scalar/helpers/url/redirect-to-proxy'\nimport type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport { buildRequestSecurity, getResolvedUrl } from '@scalar/workspace-store/request-example'\nimport type { ServerObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport type { UIDataTypes, UIMessage } from 'ai'\nimport { encode as encodeBase64 } from 'js-base64'\nimport { n } from 'neverpanic'\nimport truncateJson from 'truncate-json'\n\nimport { EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME } from '@/entities'\nimport { createError } from '@/entities/error/helpers'\nimport type { Tools } from '@/state/state'\n\nimport { createSecretRedactor } from './redact-secrets'\n\n// The maximum number of bytes the requests response can be.\nconst MAX_RESPONSE_SIZE = 50_000\n\nconst getBody = n.safeFn(\n async (response: Response) => {\n const contentType = response.headers.get('content-type')\n\n if (contentType === 'application/json') {\n return { success: true, data: await response.json() }\n }\n\n return { success: true, data: await response.text() }\n },\n (originalError) => createError('FAILED_TO_PARSE_RESPONSE_BODY', { originalError }),\n)\n\nconst truncateResponse = (response: unknown) =>\n JSON.parse(truncateJson(JSON.stringify(response), MAX_RESPONSE_SIZE).jsonString)\n\n/* Result type wrapper for fetch */\nconst safeFetch = n.safeFn(\n async (url: string, init: RequestInit) => {\n const response = await fetch(url, init)\n\n const responseBodyResult = await getBody(response)\n\n if (!response.ok) {\n // Response URLs can contain credentials, so keep them out of model-visible tool output.\n return {\n success: false,\n error: createError('REQUEST_NOT_OK', {\n status: response.status,\n responseBody: responseBodyResult.success ? responseBodyResult.data : undefined,\n headers: Object.fromEntries(restoreOriginalHeaders(response.headers).entries()),\n }),\n }\n }\n\n if (!responseBodyResult.success) {\n return responseBodyResult\n }\n\n return {\n success: true,\n data: {\n status: response.status,\n responseBody: responseBodyResult.data,\n headers: Object.fromEntries(restoreOriginalHeaders(response.headers).entries()),\n },\n }\n },\n (originalError) => createError('FAILED_TO_FETCH', { originalError }),\n)\n\n/** Validate the exact destination that will receive credentials before applying the proxy. */\nconst createDestination = (\n path: string,\n activeServer: ServerObject | null,\n queryParams: URLSearchParams,\n): { url: string; error?: never } | { url?: never; error: string } => {\n if (!activeServer?.url?.trim()) {\n return { error: 'Add a server to the API description before sending an API request.' }\n }\n\n const pathname = path.split('?')[0] ?? ''\n if (\n !pathname.startsWith('/') ||\n pathname.startsWith('//') ||\n pathname.includes('\\\\') ||\n // biome-ignore lint/suspicious/noControlCharactersInRegex: Reject characters that URL parsers silently normalize.\n /[\\u0000-\\u001f\\u007f]/.test(pathname)\n ) {\n return { error: 'Request paths must be relative endpoints beginning with a single forward slash.' }\n }\n\n try {\n const serverUrl = new URL(getResolvedUrl({ server: activeServer, path: '' }))\n const requestUrl = new URL(getResolvedUrl({ server: activeServer, path, urlParams: queryParams }))\n if (\n (requestUrl.protocol !== 'http:' && requestUrl.protocol !== 'https:') ||\n requestUrl.origin !== serverUrl.origin\n ) {\n return { error: 'Request destinations must use the selected HTTP or HTTPS server.' }\n }\n return { url: requestUrl.href }\n } catch {\n return { error: 'Select a valid HTTP or HTTPS server before sending an API request.' }\n }\n}\n\n/**\n * Executes an HTTP request with the specified options, including method, path, headers, and security schemes, and returns the processed response.\n */\nexport const executeRequestTool = n.safeFn(\n async ({\n documentSettings,\n toolCallId,\n chat,\n proxyUrl,\n input: { method, path, body, headers, documentName },\n }: {\n documentSettings: Record<\n string,\n { activeServer: ServerObject | null; securitySchemes: SecuritySchemeObjectSecret[] }\n >\n toolCallId: string\n chat: Chat<UIMessage<unknown, UIDataTypes, Tools>>\n proxyUrl: string\n input: {\n method: string\n path: string\n headers?: Record<string, string>\n body?: string\n documentName: string\n }\n }) => {\n const settings = documentSettings[documentName]\n\n if (!settings) {\n void chat.addToolOutput({\n tool: EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME,\n toolCallId,\n state: 'output-error',\n errorText: 'The selected API could not be found. Select an available API before sending a request.',\n })\n return {\n success: false,\n error: createError('DOCUMENT_SETTINGS_COULD_NOT_BE_DETERMINED', {\n documentName,\n }),\n }\n }\n\n const requestSecurityOptions = buildRequestSecurity(settings.securitySchemes)\n\n const requestSecurity = requestSecurityOptions.reduce<{\n headers: Record<string, string>\n queryParams: URLSearchParams\n cookies: Record<string, string>\n }>(\n (acc, securityOption) => {\n /** Format the security value based on its authentication scheme. */\n const securityValue = (() => {\n if (securityOption.format === 'basic') {\n return `Basic ${encodeBase64(securityOption.value)}`\n }\n if (securityOption.format === 'bearer') {\n return `Bearer ${securityOption.value}`\n }\n return formatTokenPrefix(securityOption.value, securityOption.tokenPrefix)\n })()\n\n if (securityOption.in === 'header') {\n acc.headers[securityOption.name] = securityValue\n } else if (securityOption.in === 'query') {\n acc.queryParams.set(securityOption.name, securityValue)\n } else if (securityOption.in === 'cookie') {\n acc.cookies[securityOption.name] = securityValue\n }\n\n return acc\n },\n {\n headers: {},\n queryParams: new URLSearchParams(),\n cookies: {},\n },\n )\n\n const destination = createDestination(path, settings.activeServer, requestSecurity.queryParams)\n if (destination.error) {\n // Tool callbacks run inside the stream queue, so do not await a write to that same queue.\n void chat.addToolOutput({\n tool: EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME,\n toolCallId,\n state: 'output-error',\n errorText: destination.error,\n })\n return { success: false, error: createError('FAILED_TO_EXECUTE_REQUEST', destination.error) }\n }\n\n const cookieHeader = Object.entries(requestSecurity.cookies)\n .map(([name, value]) => `${name}=${value}`)\n .join('; ')\n\n const fetchOptions: RequestInit = {\n redirect: 'error',\n method,\n body,\n headers: {\n ...headers,\n ...requestSecurity.headers,\n Cookie: cookieHeader,\n },\n }\n\n const url = redirectToProxy(proxyUrl, destination.url)\n\n const redact = createSecretRedactor(requestSecurityOptions)\n const result = await safeFetch(url, fetchOptions)\n // Redact complete values before truncation can split a credential at the size limit.\n if (result.success) {\n result.data.responseBody = truncateResponse(redact(result.data.responseBody))\n result.data.headers = redact(result.data.headers)\n } else if (result.error.code === 'REQUEST_NOT_OK') {\n if (result.error.detail.responseBody !== undefined) {\n result.error.detail.responseBody = truncateResponse(redact(result.error.detail.responseBody))\n }\n result.error.detail.headers = redact(result.error.detail.headers)\n }\n\n void chat.addToolOutput({\n tool: EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME,\n toolCallId,\n output: result,\n state: 'output-available',\n })\n\n return result\n },\n (originalError) => createError('FAILED_TO_EXECUTE_REQUEST', originalError),\n)\n"],"mappings":";;;;;;;;;;;AAmBA,IAAM,oBAAoB;AAE1B,IAAM,UAAU,EAAE,OAChB,OAAO,aAAuB;CAG5B,IAFoB,SAAS,QAAQ,IAAI,cAErC,MAAgB,oBAClB,OAAO;EAAE,SAAS;EAAM,MAAM,MAAM,SAAS,KAAK;CAAE;CAGtD,OAAO;EAAE,SAAS;EAAM,MAAM,MAAM,SAAS,KAAK;CAAE;AACtD,IACC,kBAAkB,YAAY,iCAAiC,EAAE,cAAc,CAAC,CACnF;AAEA,IAAM,oBAAoB,aACxB,KAAK,MAAM,aAAa,KAAK,UAAU,QAAQ,GAAG,iBAAiB,CAAC,CAAC,UAAU;AAGjF,IAAM,YAAY,EAAE,OAClB,OAAO,KAAa,SAAsB;CACxC,MAAM,WAAW,MAAM,MAAM,KAAK,IAAI;CAEtC,MAAM,qBAAqB,MAAM,QAAQ,QAAQ;CAEjD,IAAI,CAAC,SAAS,IAEZ,OAAO;EACL,SAAS;EACT,OAAO,YAAY,kBAAkB;GACnC,QAAQ,SAAS;GACjB,cAAc,mBAAmB,UAAU,mBAAmB,OAAO,KAAA;GACrE,SAAS,OAAO,YAAY,uBAAuB,SAAS,OAAO,CAAC,CAAC,QAAQ,CAAC;EAChF,CAAC;CACH;CAGF,IAAI,CAAC,mBAAmB,SACtB,OAAO;CAGT,OAAO;EACL,SAAS;EACT,MAAM;GACJ,QAAQ,SAAS;GACjB,cAAc,mBAAmB;GACjC,SAAS,OAAO,YAAY,uBAAuB,SAAS,OAAO,CAAC,CAAC,QAAQ,CAAC;EAChF;CACF;AACF,IACC,kBAAkB,YAAY,mBAAmB,EAAE,cAA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F,OAAO,MAAM,OAAO,UAAU,OAAO,OAAO,MAAM,OAAO,OAAO;CAClE;CAEA,KAAU,cAAc;EACtB,MAAM;EACN;EACA,QAAQ;EACR,OAAO;CACT,CAAC;CAED,OAAO;AACT,IACC,kBAAkB,YAAY,6BAA6B,aAAa,CAC3E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redact-secrets.d.ts","sourceRoot":"","sources":["../../src/client-tools/redact-secrets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAA;AAGnF,wGAAwG;AACxG,eAAO,MAAM,oBAAoB,GAAI,UAAU,UAAU,CAAC,OAAO,oBAAoB,CAAC,KAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"redact-secrets.d.ts","sourceRoot":"","sources":["../../src/client-tools/redact-secrets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAA;AAGnF,wGAAwG;AACxG,eAAO,MAAM,oBAAoB,GAAI,UAAU,UAAU,CAAC,OAAO,oBAAoB,CAAC,KAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,CAsC3G,CAAA"}
|
|
@@ -2,12 +2,14 @@ import { encode } from "js-base64";
|
|
|
2
2
|
// src/client-tools/redact-secrets.ts
|
|
3
3
|
/** Remove saved credentials from JSON-visible response fields before truncation or model submission. */
|
|
4
4
|
var createSecretRedactor = (security) => {
|
|
5
|
-
const secrets = [...new Set(security.flatMap(({ value, format }) => {
|
|
6
|
-
|
|
5
|
+
const secrets = [...new Set(security.flatMap(({ value, format, tokenPrefix }) => {
|
|
6
|
+
const values = format === "basic" ? [
|
|
7
7
|
value,
|
|
8
8
|
value.slice(value.indexOf(":") + 1),
|
|
9
9
|
encode(value)
|
|
10
|
-
] : [value]
|
|
10
|
+
] : [value];
|
|
11
|
+
if (tokenPrefix?.trim()) values.push(value.trim());
|
|
12
|
+
return values.filter(Boolean).flatMap((secret) => [
|
|
11
13
|
secret,
|
|
12
14
|
encodeURIComponent(secret),
|
|
13
15
|
new URLSearchParams({ value: secret }).toString().slice(6)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redact-secrets.js","names":["encodeBase64"],"sources":["../../src/client-tools/redact-secrets.ts"],"sourcesContent":["import type { buildRequestSecurity } from '@scalar/workspace-store/request-example'\nimport { encode as encodeBase64 } from 'js-base64'\n\n/** Remove saved credentials from JSON-visible response fields before truncation or model submission. */\nexport const createSecretRedactor = (security: ReturnType<typeof buildRequestSecurity>): (<T>(value: T) => T) => {\n const secrets = [\n ...new Set(\n security.flatMap(({ value, format }) => {\n // Basic usernames are identifiers and can appear in unrelated response text.\n const values = format === 'basic' ? [value, value.slice(value.indexOf(':') + 1), encodeBase64(value)] : [value]\n return values\n .filter(Boolean)\n .flatMap((secret) => [\n secret,\n encodeURIComponent(secret),\n new URLSearchParams({ value: secret }).toString().slice('value='.length),\n ])\n }),\n ),\n ].sort((a, b) => b.length - a.length)\n\n // Match all secrets in one pass so overlapping values do not partially redact each other.\n const pattern = secrets.length\n ? new RegExp(secrets.map((secret) => secret.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')).join('|'), 'g')\n : undefined\n\n return <T>(value: T): T => {\n if (!pattern || value === undefined) {\n return value\n }\n // Work on decoded JSON string tokens, including object keys, without changing JSON syntax or scalar types.\n return JSON.parse(\n JSON.stringify(value).replace(/\"(?:\\\\.|[^\"\\\\])*\"/g, (token) => {\n const text: string = JSON.parse(token)\n return JSON.stringify(text.replace(pattern, '[REDACTED]'))\n }),\n )\n }\n}\n"],"mappings":";;;AAIA,IAAa,wBAAwB,aAA4E;CAC/G,MAAM,UAAU,CACd,GAAG,IAAI,IACL,SAAS,SAAS,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"redact-secrets.js","names":["encodeBase64"],"sources":["../../src/client-tools/redact-secrets.ts"],"sourcesContent":["import type { buildRequestSecurity } from '@scalar/workspace-store/request-example'\nimport { encode as encodeBase64 } from 'js-base64'\n\n/** Remove saved credentials from JSON-visible response fields before truncation or model submission. */\nexport const createSecretRedactor = (security: ReturnType<typeof buildRequestSecurity>): (<T>(value: T) => T) => {\n const secrets = [\n ...new Set(\n security.flatMap(({ value, format, tokenPrefix }) => {\n // Basic usernames are identifiers and can appear in unrelated response text.\n const values = format === 'basic' ? [value, value.slice(value.indexOf(':') + 1), encodeBase64(value)] : [value]\n // Prefixed API keys are trimmed for transmission; redact both stored and transmitted forms.\n if (tokenPrefix?.trim()) {\n values.push(value.trim())\n }\n return values\n .filter(Boolean)\n .flatMap((secret) => [\n secret,\n encodeURIComponent(secret),\n new URLSearchParams({ value: secret }).toString().slice('value='.length),\n ])\n }),\n ),\n ].sort((a, b) => b.length - a.length)\n\n // Match all secrets in one pass so overlapping values do not partially redact each other.\n const pattern = secrets.length\n ? new RegExp(secrets.map((secret) => secret.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')).join('|'), 'g')\n : undefined\n\n return <T>(value: T): T => {\n if (!pattern || value === undefined) {\n return value\n }\n // Work on decoded JSON string tokens, including object keys, without changing JSON syntax or scalar types.\n return JSON.parse(\n JSON.stringify(value).replace(/\"(?:\\\\.|[^\"\\\\])*\"/g, (token) => {\n const text: string = JSON.parse(token)\n return JSON.stringify(text.replace(pattern, '[REDACTED]'))\n }),\n )\n }\n}\n"],"mappings":";;;AAIA,IAAa,wBAAwB,aAA4E;CAC/G,MAAM,UAAU,CACd,GAAG,IAAI,IACL,SAAS,SAAS,EAAE,OAAO,QAAQ,kBAAkB;EAEnD,MAAM,SAAS,WAAW,UAAU;GAAC;GAAO,MAAM,MAAM,MAAM,QAAQ,GAAG,IAAI,CAAC;GAAGA,OAAa,KAAK;EAAC,IAAI,CAAC,KAAK;EAE9G,IAAI,aAAa,KAAK,GACpB,OAAO,KAAK,MAAM,KAAK,CAAC;EAE1B,OAAO,OACJ,OAAO,OAAO,CAAC,CACf,SAAS,WAAW;GACnB;GACA,mBAAmB,MAAM;GACzB,IAAI,gBAAgB,EAAE,OAAO,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,CAAe;EACzE,CAAC;CACL,CAAC,CACH,CACF,CAAC,CAAC,MAAM,GAAG,MAAM,EAAE,SAAS,EAAE,MAAM;CAGpC,MAAM,UAAU,QAAQ,SACpB,IAAI,OAAO,QAAQ,KAAK,WAAW,OAAO,QAAQ,uBAAuB,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,GAAG,GAAG,IAChG,KAAA;CAEJ,QAAW,UAAgB;EACzB,IAAI,CAAC,WAAW,UAAU,KAAA,GACxB,OAAO;EAGT,OAAO,KAAK,MACV,KAAK,UAAU,KAAK,CAAC,CAAC,QAAQ,uBAAuB,UAAU;GAC7D,MAAM,OAAe,KAAK,MAAM,KAAK;GACrC,OAAO,KAAK,UAAU,KAAK,QAAQ,SAAS,YAAY,CAAC;EAC3D,CAAC,CACH;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestPreview.vue.d.ts","sourceRoot":"","sources":["../../src/components/RequestPreview.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RequestPreview.vue.d.ts","sourceRoot":"","sources":["../../src/components/RequestPreview.vue"],"names":[],"mappings":"AAgTA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,IAAI,CAAA;AAcrC,OAAO,KAAK,EACV,iCAAiC,EACjC,kCAAkC,EACnC,MAAM,kCAAkC,CAAA;AAKzC,KAAK,WAAW,GAAG;IACjB,OAAO,CAAC,EACJ,iCAAiC,GACjC,WAAW,CAAC,iCAAiC,CAAC,CAAA;IAClD,QAAQ,CAAC,EAAE,kCAAkC,CAAA;IAC7C,KAAK,EACD,kBAAkB,GAClB,gBAAgB,GAChB,kBAAkB,GAClB,eAAe,GACf,UAAU,GACV,UAAU,GACV,iBAAiB,CAAA;CACtB,CAAC;AAkZF,QAAA,MAAM,YAAY,kSAEhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -2,7 +2,7 @@ import RequestPreview_vue_vue_type_script_setup_true_lang_default from "./Reques
|
|
|
2
2
|
/* empty css */
|
|
3
3
|
import _plugin_vue_export_helper_default from "../_virtual/_plugin-vue_export-helper.js";
|
|
4
4
|
// src/components/RequestPreview.vue
|
|
5
|
-
var RequestPreview_default = /*#__PURE__*/ _plugin_vue_export_helper_default(RequestPreview_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-
|
|
5
|
+
var RequestPreview_default = /*#__PURE__*/ _plugin_vue_export_helper_default(RequestPreview_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-92d74c5a"]]);
|
|
6
6
|
export { RequestPreview_default as default };
|
|
7
7
|
|
|
8
8
|
//# sourceMappingURL=RequestPreview.vue.js.map
|
|
@@ -50,7 +50,7 @@ var RequestPreview_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ d
|
|
|
50
50
|
const chatState = useState();
|
|
51
51
|
const requestDestination = computed(() => {
|
|
52
52
|
if (!__props.request?.documentName || !__props.request.path || !__props.request.method) return;
|
|
53
|
-
const settings = createDocumentSettings(chatState.workspaceStore)[__props.request.documentName];
|
|
53
|
+
const settings = createDocumentSettings(chatState.workspaceStore, chatState.config.value.authentication)[__props.request.documentName];
|
|
54
54
|
if (!settings?.activeServer?.url) return `${__props.request.method.toUpperCase()} ${__props.request.path} (no server selected)`;
|
|
55
55
|
return `${__props.request.method.toUpperCase()} ${getResolvedUrl({
|
|
56
56
|
server: settings.activeServer,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestPreview.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_normalizeClass","_toDisplayString","_createBlock","RequestApproved","_createVNode","BuildingRequest","AutosendPaused","SendingRequest","_unref","RequestSuccess","RequestRejected","RequestFailed","_createElementVNode","ResponseBodyToggle","ResponseBody"],"sources":["../../src/components/RequestPreview.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarCodeBlock } from '@scalar/components/code-block'\nimport { ScalarIconCaretDown, ScalarIconCaretRight } from '@scalar/icons'\nimport { getResolvedUrl } from '@scalar/workspace-store/request-example'\nimport { type DeepPartial } from 'ai'\nimport { computed, ref } from 'vue'\n\nimport AutosendPaused from '@/components/AutosendPaused.vue'\nimport BuildingRequest from '@/components/BuildingRequest.vue'\nimport RequestApproved from '@/components/RequestApproved.vue'\nimport RequestFailed from '@/components/RequestFailed.vue'\nimport RequestRejected from '@/components/RequestRejected.vue'\nimport RequestSuccess from '@/components/RequestSuccess.vue'\nimport { getMediaTypeConfig } from '@/components/ResponseBody/helpers/media-types'\nimport { processResponseBody } from '@/components/ResponseBody/helpers/process-response-body'\nimport ResponseBody from '@/components/ResponseBody/ResponseBody.vue'\nimport ResponseBodyToggle from '@/components/ResponseBody/ResponseBodyToggle.vue'\nimport SendingRequest from '@/components/SendingRequest.vue'\nimport type {\n ExecuteClientSideRequestToolInput,\n ExecuteClientSideRequestToolOutput,\n} from '@/entities/tools/execute-request'\n\nimport { createDocumentSettings } from '@/helpers'\nimport { useState } from '@/state/state'\n\nconst { request, response, state } = defineProps<{\n request?:\n | ExecuteClientSideRequestToolInput\n | DeepPartial<ExecuteClientSideRequestToolInput>\n response?: ExecuteClientSideRequestToolOutput\n state:\n | 'requiresApproval'\n | 'sendingRequest'\n | 'requestSucceeded'\n | 'requestFailed'\n | 'approved'\n | 'rejected'\n | 'buildingRequest'\n}>()\n\nconst chatState = useState()\nconst requestDestination = computed(() => {\n if (!request?.documentName || !request.path || !request.method) {\n return undefined\n }\n const settings = createDocumentSettings(chatState.workspaceStore)[\n request.documentName\n ]\n if (!settings?.activeServer?.url) {\n return `${request.method.toUpperCase()} ${request.path} (no server selected)`\n }\n return `${request.method.toUpperCase()} ${getResolvedUrl({ server: settings.activeServer, path: request.path })}`\n})\n\nconst responseData = computed(() => {\n if (response?.success) {\n return {\n data: response.data.responseBody,\n headers: response.data.headers,\n }\n }\n\n if (response?.error?.code === 'REQUEST_NOT_OK') {\n return {\n data: response.error.detail.responseBody,\n headers: response.error.detail.headers,\n }\n }\n\n return undefined\n})\n\nconst showRequestToggle = ref(false)\n\n/** Show request preview automatically for failed requests or when approval is required. */\nconst shouldShowRequest = computed(() => {\n if (state === 'requestFailed' || state === 'requiresApproval') {\n return true\n }\n return showRequestToggle.value\n})\n\nconst responseBody = computed(() =>\n processResponseBody({\n data: responseData.value?.data,\n headers: responseData.value?.headers,\n }),\n)\n\nconst mediaConfig = computed(() =>\n getMediaTypeConfig(responseBody.value.mimeType?.essence ?? ''),\n)\n\nconst displayToggle = ref<'preview' | 'raw'>()\nfunction toggleDisplay(mode: 'preview' | 'raw') {\n displayToggle.value = mode\n}\n\nconst displayMode = computed(() => {\n if (displayToggle.value) {\n return displayToggle.value\n }\n\n if (mediaConfig.value?.raw && !mediaConfig.value.preview) {\n return 'raw'\n }\n if (mediaConfig.value?.preview) {\n return 'preview'\n }\n\n return 'raw'\n})\n</script>\n\n<template>\n <div\n class=\"requestPreview\"\n :class=\"{\n open: shouldShowRequest,\n succeeded: state === 'requestSucceeded',\n }\">\n <p\n v-if=\"requestDestination\"\n class=\"text-c-2 py-2 font-mono text-sm break-all\">\n {{ request?.documentName }} · {{ requestDestination }}\n </p>\n <RequestApproved v-if=\"state === 'approved'\" />\n <div\n v-else-if=\"state === 'buildingRequest'\"\n class=\"autosendContainer\">\n <BuildingRequest />\n </div>\n <div\n v-else-if=\"state === 'requiresApproval'\"\n class=\"autosendContainer\">\n <AutosendPaused />\n </div>\n <button\n v-else-if=\"state === 'sendingRequest'\"\n class=\"toggleButton\"\n type=\"button\"\n @click=\"showRequestToggle = !showRequestToggle\">\n <SendingRequest />\n\n <ScalarIconCaretDown v-if=\"shouldShowRequest\" />\n <ScalarIconCaretRight v-else />\n </button>\n <button\n v-else-if=\"state === 'requestSucceeded'\"\n class=\"toggleButton\"\n type=\"button\"\n @click=\"showRequestToggle = !showRequestToggle\">\n <RequestSuccess />\n\n <ScalarIconCaretDown v-if=\"shouldShowRequest\" />\n <ScalarIconCaretRight v-else />\n </button>\n <button\n v-else-if=\"state === 'rejected'\"\n class=\"toggleButton\"\n type=\"button\"\n @click=\"showRequestToggle = !showRequestToggle\">\n <RequestRejected />\n\n <ScalarIconCaretDown v-if=\"shouldShowRequest\" />\n <ScalarIconCaretRight v-else />\n </button>\n <RequestFailed v-else-if=\"state === 'requestFailed'\" />\n <div class=\"requestContent\">\n <div class=\"requestContentInner\">\n <div\n v-if=\"request\"\n class=\"code\">\n <div class=\"requestHeaderContainer\">\n <h1>Request</h1>\n </div>\n <ScalarCodeBlock\n class=\"codeBlock\"\n :content=\"JSON.stringify(request, null, 2)\"\n lang=\"json\" />\n </div>\n <div\n v-if=\"responseData\"\n class=\"code\">\n <div class=\"requestHeaderContainer\">\n <h1>Response</h1>\n <ResponseBodyToggle\n v-if=\"mediaConfig?.raw && mediaConfig.preview\"\n v-model=\"displayMode\"\n @toggle=\"toggleDisplay\" />\n </div>\n <ResponseBody\n :data=\"responseData.data\"\n :display=\"displayMode\"\n :mediaConfig=\"mediaConfig\"\n :responseBody=\"responseBody\" />\n </div>\n </div>\n </div>\n </div>\n</template>\n\n<style scoped>\n.requestHeaderContainer {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 0 5px;\n}\n\n.requestPreview {\n border-radius: var(--scalar-radius-2xl);\n display: flex;\n flex-direction: column;\n width: 100%;\n position: relative;\n}\n\n.requestContent {\n display: grid;\n grid-template-rows: 0fr;\n min-height: 0;\n overflow: hidden;\n transition: grid-template-rows 0.2s ease-out;\n}\n\n.requestPreview.open .requestContent {\n grid-template-rows: 1fr;\n}\n.requestPreview.succeeded {\n padding: 0;\n}\n\n.requestContentInner {\n min-height: 0;\n overflow: hidden;\n}\n.code {\n display: flex;\n flex-direction: column;\n font-size: var(--scalar-font-size-4);\n border-radius: var(--scalar-radius-2xl);\n background: color-mix(\n in srgb,\n var(--scalar-background-2),\n var(--scalar-background-1)\n );\n overflow: hidden;\n margin-bottom: 12px;\n}\n.dark-mode .code {\n background: var(--scalar-background-2);\n}\n.code h1 {\n font-size: var(--scalar-font-size-3);\n color: var(--scalar-color-3);\n padding: 8px;\n}\n.code :deep(.codeBlock) {\n max-height: calc(50vh - 100px);\n padding-top: 0;\n}\n.autosendContainer {\n display: flex;\n justify-content: space-between;\n}\n\n.sendButton {\n background: var(--scalar-color-blue);\n color: white;\n font-weight: var(--scalar-semibold);\n padding: 5px 10px;\n}\n.sendButton:hover,\n.sendButton:active {\n background: color-mix(in srgb, var(--scalar-color-blue), black 10%);\n color: white !important;\n}\n\n.toggleButton {\n background: none;\n border: none;\n cursor: pointer;\n text-align: left;\n position: relative;\n display: flex;\n align-items: center;\n color: var(--scalar-color-3);\n justify-content: space-between;\n border-radius: var(--scalar-radius-lg);\n}\n\n.toggleButton:hover {\n text-decoration: underline;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyCA,MAAM,YAAY,SAAS;EAC3B,MAAM,qBAAqB,eAAe;GACxC,IAAI,CAAC,QAAA,SAAS,gBAAgB,CAAC,QAAA,QAAQ,QAAQ,CAAC,QAAA,QAAQ,QACtD;GAEF,MAAM,WAAW,uBAAuB,UAAU,cAAc,CAAC,CAC/D,QAAA,QAAQ;GAEV,IAAI,CAAC,UAAU,cAAc,KAC3B,OAAO,GAAG,QAAA,QAAQ,OAAO,YAAY,EAAE,GAAG,QAAA,QAAQ,KAAK;GAEzD,OAAO,GAAG,QAAA,QAAQ,OAAO,YAAY,EAAE,GAAG,eAAe;IAAE,QAAQ,SAAS;IAAc,MAAM,QAAA,QAAQ;GAAK,CAAC;EAChH,CAAC;EAED,MAAM,eAAe,eAAe;GAClC,IAAI,QAAA,UAAU,SACZ,OAAO;IACL,MAAM,QAAA,SAAS,KA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AAA,OAAA,OAAA,KAAAa,mBAEM,OAAA,EAFD,OAAM,yBAAwB,GAAA,CACjCA,mBAAgB,MAAA,MAAZ,SAAO,C,SAEbR,YAGgBI,MAAA,eAAA,GAAA;KAFd,OAAM;KACL,SAAS,KAAK,UAAU,QAAA,SAAO,MAAA,CAAA;KAChC,MAAK;I,4DAGD,aAAA,SADRV,UAAA,GAAAC,mBAeM,OAfN,YAeM,CAZJa,mBAMM,OANN,YAMM,CALJ,OAAA,OAAA,OAAA,KAAAA,mBAAiB,MAAA,MAAb,YAAQ,EAAA,IAEJ,YAAA,OAAa,OAAO,YAAA,MAAY,WADxCd,UAAA,GAAAI,YAG4BW,4BAAA;;KADjB,YAAA,YAAA;KAAA,uBAAA,OAAA,OAAA,OAAA,MAAA,WAAA,YAAW,QAAA;KACnB,UAAQ;I,+DAEbT,YAIiCU,sBAAA;KAH9B,MAAM,aAAA,MAAa;KACnB,SAAS,YAAA;KACT,aAAa,YAAA;KACb,cAAc,aAAA"}
|
|
1
|
+
{"version":3,"file":"RequestPreview.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_normalizeClass","_toDisplayString","_createBlock","RequestApproved","_createVNode","BuildingRequest","AutosendPaused","SendingRequest","_unref","RequestSuccess","RequestRejected","RequestFailed","_createElementVNode","ResponseBodyToggle","ResponseBody"],"sources":["../../src/components/RequestPreview.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarCodeBlock } from '@scalar/components/code-block'\nimport { ScalarIconCaretDown, ScalarIconCaretRight } from '@scalar/icons'\nimport { getResolvedUrl } from '@scalar/workspace-store/request-example'\nimport { type DeepPartial } from 'ai'\nimport { computed, ref } from 'vue'\n\nimport AutosendPaused from '@/components/AutosendPaused.vue'\nimport BuildingRequest from '@/components/BuildingRequest.vue'\nimport RequestApproved from '@/components/RequestApproved.vue'\nimport RequestFailed from '@/components/RequestFailed.vue'\nimport RequestRejected from '@/components/RequestRejected.vue'\nimport RequestSuccess from '@/components/RequestSuccess.vue'\nimport { getMediaTypeConfig } from '@/components/ResponseBody/helpers/media-types'\nimport { processResponseBody } from '@/components/ResponseBody/helpers/process-response-body'\nimport ResponseBody from '@/components/ResponseBody/ResponseBody.vue'\nimport ResponseBodyToggle from '@/components/ResponseBody/ResponseBodyToggle.vue'\nimport SendingRequest from '@/components/SendingRequest.vue'\nimport type {\n ExecuteClientSideRequestToolInput,\n ExecuteClientSideRequestToolOutput,\n} from '@/entities/tools/execute-request'\n\nimport { createDocumentSettings } from '@/helpers'\nimport { useState } from '@/state/state'\n\nconst { request, response, state } = defineProps<{\n request?:\n | ExecuteClientSideRequestToolInput\n | DeepPartial<ExecuteClientSideRequestToolInput>\n response?: ExecuteClientSideRequestToolOutput\n state:\n | 'requiresApproval'\n | 'sendingRequest'\n | 'requestSucceeded'\n | 'requestFailed'\n | 'approved'\n | 'rejected'\n | 'buildingRequest'\n}>()\n\nconst chatState = useState()\nconst requestDestination = computed(() => {\n if (!request?.documentName || !request.path || !request.method) {\n return undefined\n }\n const settings = createDocumentSettings(\n chatState.workspaceStore,\n chatState.config.value.authentication,\n )[request.documentName]\n if (!settings?.activeServer?.url) {\n return `${request.method.toUpperCase()} ${request.path} (no server selected)`\n }\n return `${request.method.toUpperCase()} ${getResolvedUrl({ server: settings.activeServer, path: request.path })}`\n})\n\nconst responseData = computed(() => {\n if (response?.success) {\n return {\n data: response.data.responseBody,\n headers: response.data.headers,\n }\n }\n\n if (response?.error?.code === 'REQUEST_NOT_OK') {\n return {\n data: response.error.detail.responseBody,\n headers: response.error.detail.headers,\n }\n }\n\n return undefined\n})\n\nconst showRequestToggle = ref(false)\n\n/** Show request preview automatically for failed requests or when approval is required. */\nconst shouldShowRequest = computed(() => {\n if (state === 'requestFailed' || state === 'requiresApproval') {\n return true\n }\n return showRequestToggle.value\n})\n\nconst responseBody = computed(() =>\n processResponseBody({\n data: responseData.value?.data,\n headers: responseData.value?.headers,\n }),\n)\n\nconst mediaConfig = computed(() =>\n getMediaTypeConfig(responseBody.value.mimeType?.essence ?? ''),\n)\n\nconst displayToggle = ref<'preview' | 'raw'>()\nfunction toggleDisplay(mode: 'preview' | 'raw') {\n displayToggle.value = mode\n}\n\nconst displayMode = computed(() => {\n if (displayToggle.value) {\n return displayToggle.value\n }\n\n if (mediaConfig.value?.raw && !mediaConfig.value.preview) {\n return 'raw'\n }\n if (mediaConfig.value?.preview) {\n return 'preview'\n }\n\n return 'raw'\n})\n</script>\n\n<template>\n <div\n class=\"requestPreview\"\n :class=\"{\n open: shouldShowRequest,\n succeeded: state === 'requestSucceeded',\n }\">\n <p\n v-if=\"requestDestination\"\n class=\"text-c-2 py-2 font-mono text-sm break-all\">\n {{ request?.documentName }} · {{ requestDestination }}\n </p>\n <RequestApproved v-if=\"state === 'approved'\" />\n <div\n v-else-if=\"state === 'buildingRequest'\"\n class=\"autosendContainer\">\n <BuildingRequest />\n </div>\n <div\n v-else-if=\"state === 'requiresApproval'\"\n class=\"autosendContainer\">\n <AutosendPaused />\n </div>\n <button\n v-else-if=\"state === 'sendingRequest'\"\n class=\"toggleButton\"\n type=\"button\"\n @click=\"showRequestToggle = !showRequestToggle\">\n <SendingRequest />\n\n <ScalarIconCaretDown v-if=\"shouldShowRequest\" />\n <ScalarIconCaretRight v-else />\n </button>\n <button\n v-else-if=\"state === 'requestSucceeded'\"\n class=\"toggleButton\"\n type=\"button\"\n @click=\"showRequestToggle = !showRequestToggle\">\n <RequestSuccess />\n\n <ScalarIconCaretDown v-if=\"shouldShowRequest\" />\n <ScalarIconCaretRight v-else />\n </button>\n <button\n v-else-if=\"state === 'rejected'\"\n class=\"toggleButton\"\n type=\"button\"\n @click=\"showRequestToggle = !showRequestToggle\">\n <RequestRejected />\n\n <ScalarIconCaretDown v-if=\"shouldShowRequest\" />\n <ScalarIconCaretRight v-else />\n </button>\n <RequestFailed v-else-if=\"state === 'requestFailed'\" />\n <div class=\"requestContent\">\n <div class=\"requestContentInner\">\n <div\n v-if=\"request\"\n class=\"code\">\n <div class=\"requestHeaderContainer\">\n <h1>Request</h1>\n </div>\n <ScalarCodeBlock\n class=\"codeBlock\"\n :content=\"JSON.stringify(request, null, 2)\"\n lang=\"json\" />\n </div>\n <div\n v-if=\"responseData\"\n class=\"code\">\n <div class=\"requestHeaderContainer\">\n <h1>Response</h1>\n <ResponseBodyToggle\n v-if=\"mediaConfig?.raw && mediaConfig.preview\"\n v-model=\"displayMode\"\n @toggle=\"toggleDisplay\" />\n </div>\n <ResponseBody\n :data=\"responseData.data\"\n :display=\"displayMode\"\n :mediaConfig=\"mediaConfig\"\n :responseBody=\"responseBody\" />\n </div>\n </div>\n </div>\n </div>\n</template>\n\n<style scoped>\n.requestHeaderContainer {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 0 5px;\n}\n\n.requestPreview {\n border-radius: var(--scalar-radius-2xl);\n display: flex;\n flex-direction: column;\n width: 100%;\n position: relative;\n}\n\n.requestContent {\n display: grid;\n grid-template-rows: 0fr;\n min-height: 0;\n overflow: hidden;\n transition: grid-template-rows 0.2s ease-out;\n}\n\n.requestPreview.open .requestContent {\n grid-template-rows: 1fr;\n}\n.requestPreview.succeeded {\n padding: 0;\n}\n\n.requestContentInner {\n min-height: 0;\n overflow: hidden;\n}\n.code {\n display: flex;\n flex-direction: column;\n font-size: var(--scalar-font-size-4);\n border-radius: var(--scalar-radius-2xl);\n background: color-mix(\n in srgb,\n var(--scalar-background-2),\n var(--scalar-background-1)\n );\n overflow: hidden;\n margin-bottom: 12px;\n}\n.dark-mode .code {\n background: var(--scalar-background-2);\n}\n.code h1 {\n font-size: var(--scalar-font-size-3);\n color: var(--scalar-color-3);\n padding: 8px;\n}\n.code :deep(.codeBlock) {\n max-height: calc(50vh - 100px);\n padding-top: 0;\n}\n.autosendContainer {\n display: flex;\n justify-content: space-between;\n}\n\n.sendButton {\n background: var(--scalar-color-blue);\n color: white;\n font-weight: var(--scalar-semibold);\n padding: 5px 10px;\n}\n.sendButton:hover,\n.sendButton:active {\n background: color-mix(in srgb, var(--scalar-color-blue), black 10%);\n color: white !important;\n}\n\n.toggleButton {\n background: none;\n border: none;\n cursor: pointer;\n text-align: left;\n position: relative;\n display: flex;\n align-items: center;\n color: var(--scalar-color-3);\n justify-content: space-between;\n border-radius: var(--scalar-radius-lg);\n}\n\n.toggleButton:hover {\n text-decoration: underline;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyCA,MAAM,YAAY,SAAS;EAC3B,MAAM,qBAAqB,eAAe;GACxC,IAAI,CAAC,QAAA,SAAS,gBAAgB,CAAC,QAAA,QAAQ,QAAQ,CAAC,QAAA,QAAQ,QACtD;GAEF,MAAM,WAAW,uBACf,UAAU,gBACV,UAAU,OAAO,MAAM,cACzB,CAAC,CAAC,QAAA,QAAQ;GACV,IAAI,CAAC,UAAU,cAAc,KAC3B,OAAO,GAAG,QAAA,QAAQ,OAAO,YAAY,EAAE,GAAG,QAAA,QAAQ,KAAK;GAEzD,OAAO,GAAG,QAAA,QAAQ,OAAO,YAAY,EAAE,GAAG,eAAe;IAAE,QAAQ,SAAS;IAAc,MAAM,QAAA,QAAQ;GAAK,CAAC;EAChH,CAAC;EAED,MAAM,eAAe,eAAe;GAClC,IAAI,QAAA,UAAU,SACZ,OAAO;IACL,MAAM,QAAA,SAAS,KAAK;IACpB,SAAS,QAAA,SAAS,KAAK;GACzB;GAGF,IAAI,QAAA,UAAU,OAAO,SAAS,kBAC5B,OAAO;IACL,MAAM,QAAA,SAAS,MAAM,OAAO;IAC5B,SAAS,QAAA,SAAS,MAAM,OAAO;GACjC;EAIJ,CAAC;EAED,MAAM,oBAAoB,IAAI,KAAK;;EAGnC,MAAM,oBAAoB,eAAe;GACvC,IAAI,QAAA,UAAU,mBAAmB,QAAA,UAAU,oBACzC,OAAO;GAET,OAAO,kBAAkB;EAC3B,CAAC;EAED,MAAM,eAAe,eACnB,oBAAoB;GAClB,MAAM,aAAa,OAAO;GAC1B,SAAS,aAA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AI,YAG4BW,4BAAA;;KADjB,YAAA,YAAA;KAAA,uBAAA,OAAA,OAAA,OAAA,MAAA,WAAA,YAAW,QAAA;KACnB,UAAQ;I,+DAEbT,YAIiCU,sBAAA;KAH9B,MAAM,aAAA,MAAa;KACnB,SAAS,YAAA;KACT,aAAa,YAAA;KACb,cAAc,aAAA"}
|
package/dist/helpers.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { AuthenticationConfiguration } from '@scalar/types/api-reference';
|
|
1
2
|
import type { WorkspaceStore } from '@scalar/workspace-store/client';
|
|
2
3
|
import { type Auth } from '@scalar/workspace-store/entities/auth';
|
|
3
4
|
import type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example';
|
|
4
5
|
/** Generate document settings from workspace store. AsyncAPI docs are skipped — this feature is OpenAPI-native. */
|
|
5
|
-
export declare function createDocumentSettings(workspaceStore: WorkspaceStore): {
|
|
6
|
+
export declare function createDocumentSettings(workspaceStore: WorkspaceStore, authentication?: AuthenticationConfiguration): {
|
|
6
7
|
[k: string]: {
|
|
7
8
|
activeServer: import("@scalar/workspace-store/schemas/v3.2/strict/server").ServerObject | null;
|
|
8
9
|
securitySchemes: SecuritySchemeObjectSecret[];
|
package/dist/helpers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAEpE,OAAO,EAAE,KAAK,IAAI,EAAc,MAAM,uCAAuC,CAAA;AAC7E,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAA;
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAA;AAC9E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAEpE,OAAO,EAAE,KAAK,IAAI,EAAc,MAAM,uCAAuC,CAAA;AAC7E,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAA;AAyCzF,mHAAmH;AACnH,wBAAgB,sBAAsB,CAAC,cAAc,EAAE,cAAc,EAAE,cAAc,CAAC,EAAE,2BAA2B;;;;;EAuBlH;AAKD;;;;GAIG;AACH,eAAO,MAAM,WAAW;IAMpB;;OAEG;oBACa,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAItB;;;OAGG;oBACa,MAAM,SAAS,IAAI;CAItC,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,6BAA6B,GAAI,mCAG3C;IACD,YAAY,EAAE,MAAM,CAAA;IACpB,cAAc,EAAE,cAAc,CAAA;CAC/B,KAAG,IAIH,CAAA;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,OAM1C"}
|
package/dist/helpers.js
CHANGED
|
@@ -5,8 +5,8 @@ import { getSecurityRequirements, getSecuritySchemes, getSelectedSecurity, getSe
|
|
|
5
5
|
import { coerceValue } from "@scalar/workspace-store/schemas/typebox-coerce";
|
|
6
6
|
// src/helpers.ts
|
|
7
7
|
/** Flattens all security requirements from a document */
|
|
8
|
-
function getSecurityFromDocument(documentName, document, authStore) {
|
|
9
|
-
const mergedSecurity = mergeSecurity(document?.components?.securitySchemes,
|
|
8
|
+
function getSecurityFromDocument(documentName, document, authStore, authentication) {
|
|
9
|
+
const mergedSecurity = mergeSecurity(document?.components?.securitySchemes, authentication?.securitySchemes, authStore, documentName);
|
|
10
10
|
const securityRequirements = getSecurityRequirements(document.security);
|
|
11
11
|
const selectedSecurity = getSelectedSecurity(authStore.getAuthSelectedSchemas({
|
|
12
12
|
type: "document",
|
|
@@ -15,14 +15,14 @@ function getSecurityFromDocument(documentName, document, authStore) {
|
|
|
15
15
|
return getSecuritySchemes(mergedSecurity, selectedSecurity.selectedSchemes[selectedSecurity.selectedIndex] ?? {});
|
|
16
16
|
}
|
|
17
17
|
/** Generate document settings from workspace store. AsyncAPI docs are skipped — this feature is OpenAPI-native. */
|
|
18
|
-
function createDocumentSettings(workspaceStore) {
|
|
18
|
+
function createDocumentSettings(workspaceStore, authentication) {
|
|
19
19
|
const openApiEntries = [];
|
|
20
20
|
for (const [key, document] of Object.entries(workspaceStore.workspace.documents)) if (isOpenApiDocument(document)) openApiEntries.push([key, document]);
|
|
21
21
|
return Object.fromEntries(openApiEntries.map(([key, document]) => {
|
|
22
22
|
const servers = getServers(document.servers, { documentUrl: document["x-scalar-original-source-url"] });
|
|
23
23
|
return [key, {
|
|
24
24
|
activeServer: getSelectedServer(document, null, null, servers),
|
|
25
|
-
securitySchemes: getSecurityFromDocument(key, document, workspaceStore.auth)
|
|
25
|
+
securitySchemes: getSecurityFromDocument(key, document, workspaceStore.auth, authentication)
|
|
26
26
|
}];
|
|
27
27
|
}));
|
|
28
28
|
}
|
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 { 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 { isOpenApiDocument } from '@scalar/workspace-store/schemas/type-guards'\nimport { coerceValue } from '@scalar/workspace-store/schemas/typebox-coerce'\nimport type { OpenApiDocument } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\n\n/** Flattens all security requirements from a document */\nfunction getSecurityFromDocument(\n documentName: string,\n document: OpenApiDocument,\n authStore: AuthStore,\n): SecuritySchemeObjectSecret[] {\n const mergedSecurity = mergeSecurity(document?.components?.securitySchemes
|
|
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 { AuthenticationConfiguration } from '@scalar/types/api-reference'\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 { isOpenApiDocument } from '@scalar/workspace-store/schemas/type-guards'\nimport { coerceValue } from '@scalar/workspace-store/schemas/typebox-coerce'\nimport type { OpenApiDocument } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\n\n/** Flattens all security requirements from a document */\nfunction getSecurityFromDocument(\n documentName: string,\n document: OpenApiDocument,\n authStore: AuthStore,\n authentication?: AuthenticationConfiguration,\n): SecuritySchemeObjectSecret[] {\n const mergedSecurity = mergeSecurity(\n document?.components?.securitySchemes,\n authentication?.securitySchemes,\n authStore,\n documentName,\n )\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. AsyncAPI docs are skipped — this feature is OpenAPI-native. */\nexport function createDocumentSettings(workspaceStore: WorkspaceStore, authentication?: AuthenticationConfiguration) {\n const openApiEntries: [string, OpenApiDocument][] = []\n for (const [key, document] of Object.entries(workspaceStore.workspace.documents)) {\n if (isOpenApiDocument(document)) {\n openApiEntries.push([key, document])\n }\n }\n\n return Object.fromEntries(\n openApiEntries.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, authentication),\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":";;;;;;;AAmBA,SAAS,wBACP,cACA,UACA,WACA,gBAC8B;CAC9B,MAAM,iBAAiB,cACrB,UAAU,YAAY,iBACtB,gBAAgB,iBAChB,WACA,YACF;CAEA,MAAM,uBAAuB,wBAAwB,SAAS,QAAQ;CAEtE,MAAM,mBAAmB,oBACvB,UAAU,uBAAuB;EAC/B,MAAM;EACN;CACF,CAAC,GACD,KAAA,GACA,oBACF;CAEA,OAAO,mBAAmB,gBAAgB,iBAAiB,gBAAgB,iBAAiB,kBAAkB,CAAC,CAAC;AAClH;;AAGA,SAAgB,uBAAuB,gBAAgC,gBAA8C;CACnH,MAAM,iBAA8C,CAAC;CACrD,KAAK,MAAM,CAAC,KAAK,aAAa,OAAO,QAAQ,eAAe,UAAU,SAAS,GAC7E,IAAI,kBAAkB,QAAQ,GAC5B,eAAe,KAAK,CAAC,KAAK,QAAQ,CAAC;CAIvC,OAAO,OAAO,YACZ,eAAe,KAAK,CAAC,KAAK,cAAc;EACtC,MAAM,UAAU,WAAW,SAAS,SAAS,EAC3C,aAAa,SAAS,gCACxB,CAAC;EAED,OAAO,CACL,KACA;GACE,cAAc,kBAAkB,UAAU,MAAM,MAAM,OAAO;GAC7D,iBAAiB,wBAAwB,KAAK,UAAU,eAAe,MAAM,cAAc;EAC7F,CACF;CACF,CAAC,CACH;AACF;AAGA,IAAM,UAAU,iBAAiB;;;;;;AAOjC,IAAa,oBAAoB;CAC/B,MAAM,UAAU,SAAiB;EAC/B,OAAO,GAAG,kBAAkB,KAAK,GAAG;CACtC;CAEA,OAAO;;;;EAIL,UAAU,SAAiB;GACzB,MAAM,SAAS,KAAK,MAAM,QAAQ,QAAQ,OAAO,IAAI,CAAC,KAAK,IAAI;GAC/D,OAAO,YAAY,YAAY,MAAM;EACvC;;;;;EAKA,UAAU,MAAc,UAAgB;GACtC,QAAQ,QAAQ,OAAO,IAAI,GAAG,KAAK,UAAU,KAAK,CAAC;EACrD;CACF;AACF;;;;;;;;;;AAWA,IAAa,iCAAiC,EAC5C,cACA,qBAIU;CAEV,MAAM,OADkB,YACX,CAAA,CAAgB,QAAQ,YAAY;CACjD,eAAe,KAAK,KAAK,GAAG,eAAe,KAAK,CAAC;AACnD;AAEA,SAAgB,cAAc,OAAe;CAC3C,IAAI;EACF,OAAO,KAAK,MAAM,KAAK;CACzB,QAAQ;EACN;CACF;AACF"}
|
|
@@ -26,7 +26,7 @@ function useRequestApprovals() {
|
|
|
26
26
|
errorText: "The user denied the request."
|
|
27
27
|
});
|
|
28
28
|
await executeRequestTool({
|
|
29
|
-
documentSettings: createDocumentSettings(state.workspaceStore),
|
|
29
|
+
documentSettings: createDocumentSettings(state.workspaceStore, state.config.value.authentication),
|
|
30
30
|
proxyUrl: state.proxyUrl.value,
|
|
31
31
|
input: toolPart.input,
|
|
32
32
|
toolCallId: toolPart.toolCallId,
|
|
@@ -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 { type ComputedRef, 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\n/** Every outbound request needs consent, including GET requests that can carry credentials or data. */\nexport function requestPartRequiresApproval(part: UIMessagePart<any, Tools>): part is RequestToolPart {\n return part.type === (`tool-${EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME}` as const) && part.state === 'input-available'\n}\n\n/** Exposes pending request approvals without leaking SDK implementation types. */\nexport function useRequestApprovals(): {\n approvalRequiredParts: ComputedRef<RequestToolPart[]>\n respondToRequestApprovals: (approved: boolean) => Promise<void>\n} {\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)\n .filter((part) => !state.pendingRequestIds.value.has(part.toolCallId)) as RequestToolPart[]\n })\n\n async function respondToRequestApprovals(approved: boolean) {\n const parts = approvalRequiredParts.value\n // Claim every part synchronously before any asynchronous execution can yield.\n parts.forEach((part) => state.pendingRequestIds.value.add(part.toolCallId))\n const approvalPromises = parts.map(async (toolPart) => {\n try {\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 } finally {\n state.pendingRequestIds.value.delete(toolPart.toolCallId)\n }\n })\n\n await Promise.all(approvalPromises)\n }\n\n return { approvalRequiredParts, respondToRequestApprovals }\n}\n"],"mappings":";;;;;;;AAeA,SAAgB,4BAA4B,MAA0D;CACpG,OAAO,KAAK,SAAU,0BAA6D,KAAK,UAAU;AACpG;;AAGA,SAAgB,sBAGd;CACA,MAAM,QAAQ,SAAS;CAEvB,MAAM,wBAAwB,eAAe;EAC3C,OAAO,MAAM,KAAK,SACf,QAAQ,YAAY,QAAQ,MAAM,KAAK,2BAA2B,CAAC,CAAC,CACpE,SAAS,YAAY,QAAQ,KAAK,CAAC,CACnC,OAAO,2BAA2B,CAAC,CACnC,QAAQ,SAAS,CAAC,MAAM,kBAAkB,MAAM,IAAI,KAAK,UAAU,CAAC;CACzE,CAAC;CAED,eAAe,0BAA0B,UAAmB;EAC1D,MAAM,QAAQ,sBAAsB;EAEpC,MAAM,SAAS,SAAS,MAAM,kBAAkB,MAAM,IAAI,KAAK,UAAU,CAAC;EAC1E,MAAM,mBAAmB,MAAM,IAAI,OAAO,aAAa;GACrD,IAAI;IACF,IAAI,CAAC,UACH,OAAO,MAAM,MAAM,KAAK,cAAc;KACpC,MAAM;KACN,YAAY,SAAS;KACrB,OAAO;KACP,WAAW;IACb,CAAC;IAGH,MAAM,mBAAmB;KACvB,kBAAkB,uBAAuB,MAAM,cAAc;
|
|
1
|
+
{"version":3,"file":"use-chat-approvals.js","names":[],"sources":["../../src/hooks/use-chat-approvals.ts"],"sourcesContent":["import type { ToolUIPart, UIMessagePart } from 'ai'\nimport { type ComputedRef, 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\n/** Every outbound request needs consent, including GET requests that can carry credentials or data. */\nexport function requestPartRequiresApproval(part: UIMessagePart<any, Tools>): part is RequestToolPart {\n return part.type === (`tool-${EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME}` as const) && part.state === 'input-available'\n}\n\n/** Exposes pending request approvals without leaking SDK implementation types. */\nexport function useRequestApprovals(): {\n approvalRequiredParts: ComputedRef<RequestToolPart[]>\n respondToRequestApprovals: (approved: boolean) => Promise<void>\n} {\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)\n .filter((part) => !state.pendingRequestIds.value.has(part.toolCallId)) as RequestToolPart[]\n })\n\n async function respondToRequestApprovals(approved: boolean) {\n const parts = approvalRequiredParts.value\n // Claim every part synchronously before any asynchronous execution can yield.\n parts.forEach((part) => state.pendingRequestIds.value.add(part.toolCallId))\n const approvalPromises = parts.map(async (toolPart) => {\n try {\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, state.config.value.authentication),\n proxyUrl: state.proxyUrl.value,\n input: toolPart.input,\n toolCallId: toolPart.toolCallId,\n chat: state.chat,\n })\n } finally {\n state.pendingRequestIds.value.delete(toolPart.toolCallId)\n }\n })\n\n await Promise.all(approvalPromises)\n }\n\n return { approvalRequiredParts, respondToRequestApprovals }\n}\n"],"mappings":";;;;;;;AAeA,SAAgB,4BAA4B,MAA0D;CACpG,OAAO,KAAK,SAAU,0BAA6D,KAAK,UAAU;AACpG;;AAGA,SAAgB,sBAGd;CACA,MAAM,QAAQ,SAAS;CAEvB,MAAM,wBAAwB,eAAe;EAC3C,OAAO,MAAM,KAAK,SACf,QAAQ,YAAY,QAAQ,MAAM,KAAK,2BAA2B,CAAC,CAAC,CACpE,SAAS,YAAY,QAAQ,KAAK,CAAC,CACnC,OAAO,2BAA2B,CAAC,CACnC,QAAQ,SAAS,CAAC,MAAM,kBAAkB,MAAM,IAAI,KAAK,UAAU,CAAC;CACzE,CAAC;CAED,eAAe,0BAA0B,UAAmB;EAC1D,MAAM,QAAQ,sBAAsB;EAEpC,MAAM,SAAS,SAAS,MAAM,kBAAkB,MAAM,IAAI,KAAK,UAAU,CAAC;EAC1E,MAAM,mBAAmB,MAAM,IAAI,OAAO,aAAa;GACrD,IAAI;IACF,IAAI,CAAC,UACH,OAAO,MAAM,MAAM,KAAK,cAAc;KACpC,MAAM;KACN,YAAY,SAAS;KACrB,OAAO;KACP,WAAW;IACb,CAAC;IAGH,MAAM,mBAAmB;KACvB,kBAAkB,uBAAuB,MAAM,gBAAgB,MAAM,OAAO,MAAM,cAAc;KAChG,UAAU,MAAM,SAAS;KACzB,OAAO,SAAS;KAChB,YAAY,SAAS;KACrB,MAAM,MAAM;IACd,CAAC;GACH,UAAU;IACR,MAAM,kBAAkB,MAAM,OAAO,SAAS,UAAU;GAC1D;EACF,CAAC;EAED,MAAM,QAAQ,IAAI,gBAAgB;CACpC;CAEA,OAAO;EAAE;EAAuB;CAA0B;AAC5D"}
|
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,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAA;AAC3C,YAAY,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA"}
|
package/dist/package.json
CHANGED
package/dist/state/state.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME, type ExecuteClientSideRequestToo
|
|
|
12
12
|
import type { GetOpenAPISpecsSummaryToolOutput, SUMMARIZE_OPENAPI_SPECS_TOOL_NAME } from '../entities/tools/get-openapi-specs-summary.js';
|
|
13
13
|
import type { SEARCH_OPENAPI_OPERATIONS_TOOL_NAME, SearchOpenAPIOperationsToolInput, SearchOpenAPIOperationsToolOutput } from '../entities/tools/search-openapi-operations.js';
|
|
14
14
|
import { type UploadTmpDocumentState } from '../hooks/use-upload-tmp-document.js';
|
|
15
|
-
import type { ChatMode } from '../types.js';
|
|
15
|
+
import type { ChatMode, SelectedDocument } from '../types.js';
|
|
16
16
|
export type RegistryDocument = {
|
|
17
17
|
namespace: string;
|
|
18
18
|
slug: string;
|
|
@@ -81,10 +81,9 @@ type State = {
|
|
|
81
81
|
uploadedTmpDocumentUrl: Ref<string | undefined>;
|
|
82
82
|
curatedDocuments: Ref<ApiMetadata[]>;
|
|
83
83
|
getActiveDocumentJson?: () => string;
|
|
84
|
-
getActiveDocumentContext?: () => string | undefined;
|
|
85
84
|
hideAddApi?: boolean;
|
|
86
85
|
};
|
|
87
|
-
export declare function createState({ initialRegistryDocuments, registryUrl, dashboardUrl, platformProxyUrl, baseUrl, mode, isLoggedIn, getAccessToken, getAgentKey, getActiveDocumentJson,
|
|
86
|
+
export declare function createState({ initialRegistryDocuments, registryUrl, dashboardUrl, platformProxyUrl, baseUrl, mode, isLoggedIn, getAccessToken, getAgentKey, getActiveDocumentJson, getActiveDocumentSelection, prefilledMessageRef, hideAddApi, }: {
|
|
88
87
|
initialRegistryDocuments: {
|
|
89
88
|
namespace: string;
|
|
90
89
|
slug: string;
|
|
@@ -98,7 +97,7 @@ export declare function createState({ initialRegistryDocuments, registryUrl, das
|
|
|
98
97
|
getAccessToken?: () => string;
|
|
99
98
|
getAgentKey?: () => string;
|
|
100
99
|
getActiveDocumentJson?: () => string;
|
|
101
|
-
|
|
100
|
+
getActiveDocumentSelection?: () => SelectedDocument | undefined;
|
|
102
101
|
prefilledMessageRef?: Ref<string>;
|
|
103
102
|
hideAddApi?: boolean;
|
|
104
103
|
}): State;
|
|
@@ -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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B,gBAAgB,EAAE,MAAM,CAAA;IACxB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,QAAQ,CAAA;IACd,UAAU,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IACzB,cAAc,CAAC,EAAE,MAAM,MAAM,CAAA;IAC7B,WAAW,CAAC,EAAE,MAAM,MAAM,CAAA;IAC1B,qBAAqB,CAAC,EAAE,MAAM,MAAM,CAAA;IACpC,0BAA0B,CAAC,EAAE,MAAM,gBAAgB,GAAG,SAAS,CAAA;IAC/D,mBAAmB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACjC,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,GAAG,KAAK,CAuNR;AAED,wBAAgB,QAAQ,UAQvB"}
|
package/dist/state/state.js
CHANGED
|
@@ -21,7 +21,7 @@ import { n } from "neverpanic";
|
|
|
21
21
|
// src/state/state.ts
|
|
22
22
|
var STATE_SYMBOL = Symbol("STATE_SYMBOL");
|
|
23
23
|
var { toast } = useToasts();
|
|
24
|
-
function createChat({ registryDocuments, workspaceStore, baseUrl, getAccessToken, getAgentKey }) {
|
|
24
|
+
function createChat({ registryDocuments, workspaceStore, baseUrl, getAccessToken, getAgentKey, getActiveDocumentSelection }) {
|
|
25
25
|
const chat = new Chat({
|
|
26
26
|
sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithToolCalls,
|
|
27
27
|
transport: new DefaultChatTransport({
|
|
@@ -30,7 +30,10 @@ function createChat({ registryDocuments, workspaceStore, baseUrl, getAccessToken
|
|
|
30
30
|
getAccessToken,
|
|
31
31
|
getAgentKey
|
|
32
32
|
}),
|
|
33
|
-
body: () => ({
|
|
33
|
+
body: () => ({
|
|
34
|
+
registryDocuments: registryDocuments.value,
|
|
35
|
+
selectedDocument: getActiveDocumentSelection?.()
|
|
36
|
+
})
|
|
34
37
|
}),
|
|
35
38
|
onToolCall({ toolCall }) {
|
|
36
39
|
if (toolCall.dynamic) return;
|
|
@@ -47,7 +50,7 @@ function createChat({ registryDocuments, workspaceStore, baseUrl, getAccessToken
|
|
|
47
50
|
});
|
|
48
51
|
return chat;
|
|
49
52
|
}
|
|
50
|
-
function createState({ initialRegistryDocuments, registryUrl, dashboardUrl, platformProxyUrl, baseUrl, mode, isLoggedIn, getAccessToken, getAgentKey, getActiveDocumentJson,
|
|
53
|
+
function createState({ initialRegistryDocuments, registryUrl, dashboardUrl, platformProxyUrl, baseUrl, mode, isLoggedIn, getAccessToken, getAgentKey, getActiveDocumentJson, getActiveDocumentSelection, prefilledMessageRef, hideAddApi }) {
|
|
51
54
|
const prompt = ref(prefilledMessageRef?.value ?? "");
|
|
52
55
|
const registryDocuments = ref([]);
|
|
53
56
|
const pendingDocuments = reactive({});
|
|
@@ -67,7 +70,8 @@ function createState({ initialRegistryDocuments, registryUrl, dashboardUrl, plat
|
|
|
67
70
|
workspaceStore,
|
|
68
71
|
baseUrl,
|
|
69
72
|
getAccessToken,
|
|
70
|
-
getAgentKey
|
|
73
|
+
getAgentKey,
|
|
74
|
+
getActiveDocumentSelection
|
|
71
75
|
});
|
|
72
76
|
const api = createApi({
|
|
73
77
|
baseUrl,
|
|
@@ -182,7 +186,6 @@ function createState({ initialRegistryDocuments, registryUrl, dashboardUrl, plat
|
|
|
182
186
|
uploadedTmpDocumentUrl,
|
|
183
187
|
curatedDocuments,
|
|
184
188
|
getActiveDocumentJson,
|
|
185
|
-
getActiveDocumentContext,
|
|
186
189
|
hideAddApi
|
|
187
190
|
};
|
|
188
191
|
}
|
package/dist/state/state.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","names":[],"sources":["../../src/state/state.ts"],"sourcesContent":["import { Chat } from '@ai-sdk/vue'\nimport { type ModalState, useModal } from '@scalar/components/modal'\nimport { apiReferenceConfigurationSchema } from '@scalar/schemas/api-reference'\nimport type { ApiReferenceConfigurationRaw } from '@scalar/types/api-reference'\nimport { useToasts } from '@scalar/use-toasts'\nimport { coerce } from '@scalar/validation'\nimport { type WorkspaceStore, createWorkspaceStore } from '@scalar/workspace-store/client'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { createWorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { isAsyncApiDocument, isOpenApiDocument } from '@scalar/workspace-store/schemas/type-guards'\nimport { DefaultChatTransport, type UIDataTypes, type UIMessage, lastAssistantMessageIsCompleteWithToolCalls } from 'ai'\nimport { n } from 'neverpanic'\nimport { type ComputedRef, type InjectionKey, type Ref, computed, inject, reactive, ref, watch } from 'vue'\n\nimport { type Api, createApi, createAuthorizationHeaders } from '@/api'\nimport { URLS } from '@/consts/urls'\nimport { createError } from '@/entities'\nimport type { ApiMetadata } from '@/entities/registry/document'\nimport type {\n ASK_FOR_AUTHENTICATION_TOOL_NAME,\n AskForAuthenticationInput,\n} from '@/entities/tools/ask-for-authentication'\nimport {\n EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME,\n type ExecuteClientSideRequestToolInput,\n type ExecuteClientSideRequestToolOutput,\n} from '@/entities/tools/execute-request'\nimport type {\n GetOpenAPISpecsSummaryToolOutput,\n SUMMARIZE_OPENAPI_SPECS_TOOL_NAME,\n} from '@/entities/tools/get-openapi-specs-summary'\nimport type {\n SEARCH_OPENAPI_OPERATIONS_TOOL_NAME,\n SearchOpenAPIOperationsToolInput,\n SearchOpenAPIOperationsToolOutput,\n} from '@/entities/tools/search-openapi-operations'\nimport { useTermsAndConditions } from '@/hooks/use-term-and-conditions'\nimport { type UploadTmpDocumentState, removeTmpDocFromLocalStorage } from '@/hooks/use-upload-tmp-document'\nimport { persistencePlugin } from '@/plugins/persistance'\nimport { loadDocument } from '@/registry/add-documents-to-store'\nimport { createDocumentName } from '@/registry/create-document-name'\nimport type { ChatMode } from '@/types'\n\nexport type RegistryDocument = {\n namespace: string\n slug: string\n}\n\nexport type Tools = {\n [SEARCH_OPENAPI_OPERATIONS_TOOL_NAME]: {\n input: SearchOpenAPIOperationsToolInput\n output: SearchOpenAPIOperationsToolOutput\n }\n [EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME]: {\n input: ExecuteClientSideRequestToolInput\n output: ExecuteClientSideRequestToolOutput\n }\n [SUMMARIZE_OPENAPI_SPECS_TOOL_NAME]: {\n input: object\n output: GetOpenAPISpecsSummaryToolOutput\n }\n [ASK_FOR_AUTHENTICATION_TOOL_NAME]: {\n input: AskForAuthenticationInput\n output: unknown\n }\n}\n\nexport const STATE_SYMBOL: InjectionKey<State> = Symbol('STATE_SYMBOL')\n\nconst { toast } = useToasts()\n\ntype State = {\n pendingRequestIds: Ref<Set<string>>\n prompt: Ref<string>\n chat: Chat<UIMessage<unknown, UIDataTypes, Tools>>\n workspaceStore: WorkspaceStore\n loading: ComputedRef<boolean>\n settingsModal: ModalState\n eventBus: WorkspaceEventBus\n proxyUrl: ComputedRef<string>\n proxyUrlRaw: Ref<string | undefined>\n config: ComputedRef<ApiReferenceConfigurationRaw>\n registryUrl: string\n dashboardUrl: string\n baseUrl: string\n platformProxyUrl: string\n isLoggedIn?: Ref<boolean>\n registryDocuments: Ref<ApiMetadata[]>\n pendingDocuments: Record<string, boolean>\n mode: ChatMode\n terms: { accepted: Ref<boolean>; accept: () => void }\n addDocument: (document: { namespace: string; slug: string; removable?: boolean; tmp?: boolean }) => Promise<void>\n addDocumentAsync: (document: { namespace: string; slug: string; removable?: boolean }) => Promise<void>\n removeDocument: (document: { namespace: string; slug: string }) => void\n getAccessToken?: () => string\n getAgentKey?: () => string\n api: Api\n uploadState: Ref<UploadTmpDocumentState | undefined>\n uploadedTmpDocumentUrl: Ref<string | undefined>\n curatedDocuments: Ref<ApiMetadata[]>\n getActiveDocumentJson?: () => string\n getActiveDocumentContext?: () => string | undefined\n hideAddApi?: boolean\n}\n\nfunction createChat({\n registryDocuments,\n workspaceStore,\n baseUrl,\n getAccessToken,\n getAgentKey,\n}: {\n registryDocuments: Ref<ApiMetadata[]>\n workspaceStore: WorkspaceStore\n baseUrl: string\n getAccessToken?: () => string\n getAgentKey?: () => string\n}) {\n const chat = new Chat<UIMessage<unknown, UIDataTypes, Tools>>({\n sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithToolCalls,\n transport: new DefaultChatTransport({\n api: `${baseUrl}/vector/openapi/chat`,\n headers: () => createAuthorizationHeaders({ getAccessToken, getAgentKey }),\n body: () => ({\n registryDocuments: registryDocuments.value,\n }),\n }),\n onToolCall({ toolCall }): void {\n if (toolCall.dynamic) {\n return\n }\n\n if (\n (toolCall.toolName === EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME ||\n toolCall.toolName === 'ask-for-authentication') &&\n !isOpenApiDocument(workspaceStore.workspace.documents[toolCall.input.documentName])\n ) {\n // Tool callbacks run inside the stream queue; enqueue the result without waiting on that queue.\n void chat.addToolOutput({\n tool: toolCall.toolName,\n toolCallId: toolCall.toolCallId,\n state: 'output-error',\n errorText: isAsyncApiDocument(workspaceStore.workspace.documents[toolCall.input.documentName])\n ? 'Live AsyncAPI messaging and authentication are not supported in Ask AI. Ask for an explanation or code example instead.'\n : 'Requests and authentication require an OpenAPI document. This document format is not supported in Ask AI.',\n })\n return\n }\n },\n })\n\n return chat\n}\n\nexport function createState({\n initialRegistryDocuments,\n registryUrl,\n dashboardUrl,\n platformProxyUrl,\n baseUrl,\n mode,\n isLoggedIn,\n getAccessToken,\n getAgentKey,\n getActiveDocumentJson,\n getActiveDocumentContext,\n prefilledMessageRef,\n hideAddApi,\n}: {\n initialRegistryDocuments: { namespace: string; slug: string }[]\n registryUrl: string\n dashboardUrl: string\n platformProxyUrl: string\n baseUrl: string\n mode: ChatMode\n isLoggedIn?: Ref<boolean>\n getAccessToken?: () => string\n getAgentKey?: () => string\n getActiveDocumentJson?: () => string\n getActiveDocumentContext?: () => string | undefined\n prefilledMessageRef?: Ref<string>\n hideAddApi?: boolean\n}): State {\n const prompt = ref<State['prompt']['value']>(prefilledMessageRef?.value ?? '')\n const registryDocuments = ref<ApiMetadata[]>([])\n const pendingDocuments = reactive<Record<string, boolean>>({})\n const curatedDocuments = ref<ApiMetadata[]>([])\n const proxyUrlRaw = ref<State['proxyUrlRaw']['value']>(URLS.DEFAULT_PROXY_URL)\n const proxyUrl = computed(() => proxyUrlRaw.value?.trim() || URLS.DEFAULT_PROXY_URL)\n const uploadedTmpDocumentUrl = ref<string>()\n const terms = useTermsAndConditions()\n\n const eventBus = createWorkspaceEventBus()\n const workspaceStore = createWorkspaceStore({\n plugins: [\n persistencePlugin({\n persistAuth: true,\n }),\n ],\n })\n\n const config = computed(() =>\n coerce(apiReferenceConfigurationSchema, {\n proxyUrl: proxyUrl.value,\n persistAuth: true,\n }),\n )\n\n const chat = createChat({\n registryDocuments,\n workspaceStore,\n baseUrl,\n getAccessToken,\n getAgentKey,\n })\n\n const api = createApi({\n baseUrl,\n getAccessToken,\n getAgentKey,\n })\n\n const loading = computed(\n () =>\n chat.status === 'submitted' ||\n (chat.status === 'streaming' && !chat.lastMessage?.parts.some((part) => part.type === 'text')),\n )\n\n watch(\n () => chat.status,\n () => {\n if (chat.status === 'streaming') {\n prompt.value = ''\n }\n },\n )\n\n if (prefilledMessageRef) {\n watch(prefilledMessageRef, (val) => {\n if (val) {\n prompt.value = val\n }\n })\n }\n\n const settingsModal = useModal()\n\n async function addDocument({\n namespace,\n slug,\n removable = true,\n tmp = false,\n }: {\n namespace: string\n slug: string\n removable?: boolean\n tmp?: boolean\n }) {\n const matchingDoc = registryDocuments.value.find((doc) => doc.namespace === namespace && doc.slug === slug)\n\n if (matchingDoc) {\n return\n }\n\n const identifier = `@${namespace}/${slug}`\n\n pendingDocuments[identifier] = true\n\n const loadDocumentResult = await loadDocument({\n namespace,\n slug,\n workspaceStore,\n registryUrl,\n registryDocuments,\n config: config.value,\n getAccessToken,\n api,\n removable,\n })\n\n pendingDocuments[identifier] = false\n\n if (!loadDocumentResult.success) {\n /**\n * If we are unable to load a document, we just remove it\n * from tmp local storage, do not warn the user.\n */\n if (tmp) {\n removeTmpDocFromLocalStorage()\n throw loadDocumentResult.error\n }\n\n console.warn('[AGENT]: Unable to load document', loadDocumentResult.error)\n toast(`Unable to load the document @${namespace}/${slug}`, 'warn')\n throw loadDocumentResult.error\n }\n }\n\n /**\n * Waits for document to be available in embeddings\n * and adds to the list\n */\n async function addDocumentAsync({\n namespace,\n slug,\n removable = true,\n }: {\n namespace: string\n slug: string\n removable?: boolean\n }) {\n const matchingDoc = registryDocuments.value.find((doc) => doc.namespace === namespace && doc.slug === slug)\n\n if (matchingDoc) {\n return\n }\n\n const identifier = `@${namespace}/${slug}`\n\n pendingDocuments[identifier] = true\n\n const embeddingStatusResponse = await n.fromUnsafe(\n () =>\n fetch(`${baseUrl}/vector/registry/embeddings/${namespace}/${slug}`, {\n method: 'GET',\n }),\n (originalError) => createError('FAILED_TO_GET_EMBEDDING_STATUS', originalError),\n )\n\n if (embeddingStatusResponse.success && embeddingStatusResponse.data.ok) {\n const loadDocumentResult = await loadDocument({\n namespace,\n slug,\n workspaceStore,\n registryUrl,\n registryDocuments,\n config: config.value,\n getAccessToken,\n api,\n removable,\n })\n\n if (!loadDocumentResult.success) {\n console.warn('[AGENT]: Unable to load document', loadDocumentResult.error)\n toast(`Unable to load the document @${namespace}/${slug}`, 'warn')\n }\n } else {\n console.warn('[AGENT]: Document could not be embedded')\n toast(`Unable to embed the document @${namespace}/${slug}`, 'warn')\n }\n\n pendingDocuments[identifier] = false\n }\n\n function removeDocument({ namespace, slug }: { namespace: string; slug: string }) {\n registryDocuments.value = registryDocuments.value.filter(\n (doc) => !(doc.namespace === namespace && doc.slug === slug),\n )\n\n workspaceStore.deleteDocument(createDocumentName(namespace, slug))\n }\n\n initialRegistryDocuments.forEach(({ namespace, slug }) => addDocument({ namespace, slug, removable: false }))\n\n return {\n pendingRequestIds: ref(new Set<string>()),\n prompt,\n chat,\n workspaceStore,\n eventBus,\n loading,\n settingsModal,\n config,\n registryUrl,\n dashboardUrl,\n platformProxyUrl,\n baseUrl,\n registryDocuments,\n pendingDocuments,\n proxyUrl,\n proxyUrlRaw,\n mode,\n terms,\n isLoggedIn,\n addDocument,\n addDocumentAsync,\n removeDocument,\n getAccessToken,\n getAgentKey,\n api,\n uploadState: ref<UploadTmpDocumentState>(),\n uploadedTmpDocumentUrl,\n curatedDocuments,\n getActiveDocumentJson,\n getActiveDocumentContext,\n hideAddApi,\n }\n}\n\nexport function useState() {\n const state = inject(STATE_SYMBOL)\n\n if (!state) {\n throw new Error('No state provided.')\n }\n\n return state\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAmEA,IAAa,eAAoC,OAAO,cAAc;AAEtE,IAAM,EAAE,UAAU,UAAU;AAoC5B,SAAS,WAAW,EAClB,mBACA,gBACA,SACA,gBACA,eAOC;CACD,MAAM,OAAO,IAAI,KAA6C;EAC5D,uBAAuB;EACvB,WAAW,IAAI,qBAAqB;GAClC,KAAK,GAAG,QAAQ;GAChB,eAAe,2BAA2B;IAAE;IAAgB;GAAY,CAAC;GACzE,aAAa,EACX,mBAAmB,kBAAkB,MACvC;EACF,CAAC;EACD,WAAW,EAAE,YAAkB;GAC7B,IAAI,SAAS,SACX;GAGF,KACG,SAAS,aAAA,qBACR,SAAS,aAAa,6BACxB,CAAC,kBAAkB,eAAe,UAAU,UAAU,SAAS,MAAM,aAAa,GAClF;IAEA,KAAU,cAAc;KACtB,MAAM,SAAS;KACf,YAAY,SAAS;KACrB,OAAO;KACP,WAAW,mBAAmB,eAAe,UAAU,UAAU,SAAS,MAAM,aAAa,IACzF,4HACA;IACN,CAAC;IACD;GACF;EACF;CACF,CAAC;CAED,OAAO;AACT;AAEA,SAAgB,YAAY,EAC1B,0BACA,aACA,cACA,kBACA,SACA,MACA,YACA,gBACA,aACA,uBACA,0BACA,qBACA,cAeQ;CACR,MAAM,SAAS,IAA8B,qBAAqB,SAAS,EAAE;CAC7E,MAAM,oBAAoB,IAAmB,CAAC,CAAC;CAC/C,MAAM,mBAAmB,SAAkC,CAAC,CAAC;CAC7D,MAAM,mBAAmB,IAAmB,CAAC,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;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,aAAa,IAA4B;EACzC;EACA;EACA;EACA;EACA;CACF;AACF;AAEA,SAAgB,WAAW;CACzB,MAAM,QAAQ,OAAO,YAAY;CAEjC,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,oBAAoB;CAGtC,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"state.js","names":[],"sources":["../../src/state/state.ts"],"sourcesContent":["import { Chat } from '@ai-sdk/vue'\nimport { type ModalState, useModal } from '@scalar/components/modal'\nimport { apiReferenceConfigurationSchema } from '@scalar/schemas/api-reference'\nimport type { ApiReferenceConfigurationRaw } from '@scalar/types/api-reference'\nimport { useToasts } from '@scalar/use-toasts'\nimport { coerce } from '@scalar/validation'\nimport { type WorkspaceStore, createWorkspaceStore } from '@scalar/workspace-store/client'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { createWorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { isAsyncApiDocument, isOpenApiDocument } from '@scalar/workspace-store/schemas/type-guards'\nimport { DefaultChatTransport, type UIDataTypes, type UIMessage, lastAssistantMessageIsCompleteWithToolCalls } from 'ai'\nimport { n } from 'neverpanic'\nimport { type ComputedRef, type InjectionKey, type Ref, computed, inject, reactive, ref, watch } from 'vue'\n\nimport { type Api, createApi, createAuthorizationHeaders } from '@/api'\nimport { URLS } from '@/consts/urls'\nimport { createError } from '@/entities'\nimport type { ApiMetadata } from '@/entities/registry/document'\nimport type {\n ASK_FOR_AUTHENTICATION_TOOL_NAME,\n AskForAuthenticationInput,\n} from '@/entities/tools/ask-for-authentication'\nimport {\n EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME,\n type ExecuteClientSideRequestToolInput,\n type ExecuteClientSideRequestToolOutput,\n} from '@/entities/tools/execute-request'\nimport type {\n GetOpenAPISpecsSummaryToolOutput,\n SUMMARIZE_OPENAPI_SPECS_TOOL_NAME,\n} from '@/entities/tools/get-openapi-specs-summary'\nimport type {\n SEARCH_OPENAPI_OPERATIONS_TOOL_NAME,\n SearchOpenAPIOperationsToolInput,\n SearchOpenAPIOperationsToolOutput,\n} from '@/entities/tools/search-openapi-operations'\nimport { useTermsAndConditions } from '@/hooks/use-term-and-conditions'\nimport { type UploadTmpDocumentState, removeTmpDocFromLocalStorage } from '@/hooks/use-upload-tmp-document'\nimport { persistencePlugin } from '@/plugins/persistance'\nimport { loadDocument } from '@/registry/add-documents-to-store'\nimport { createDocumentName } from '@/registry/create-document-name'\nimport type { ChatMode, SelectedDocument } from '@/types'\n\nexport type RegistryDocument = {\n namespace: string\n slug: string\n}\n\nexport type Tools = {\n [SEARCH_OPENAPI_OPERATIONS_TOOL_NAME]: {\n input: SearchOpenAPIOperationsToolInput\n output: SearchOpenAPIOperationsToolOutput\n }\n [EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME]: {\n input: ExecuteClientSideRequestToolInput\n output: ExecuteClientSideRequestToolOutput\n }\n [SUMMARIZE_OPENAPI_SPECS_TOOL_NAME]: {\n input: object\n output: GetOpenAPISpecsSummaryToolOutput\n }\n [ASK_FOR_AUTHENTICATION_TOOL_NAME]: {\n input: AskForAuthenticationInput\n output: unknown\n }\n}\n\nexport const STATE_SYMBOL: InjectionKey<State> = Symbol('STATE_SYMBOL')\n\nconst { toast } = useToasts()\n\ntype State = {\n pendingRequestIds: Ref<Set<string>>\n prompt: Ref<string>\n chat: Chat<UIMessage<unknown, UIDataTypes, Tools>>\n workspaceStore: WorkspaceStore\n loading: ComputedRef<boolean>\n settingsModal: ModalState\n eventBus: WorkspaceEventBus\n proxyUrl: ComputedRef<string>\n proxyUrlRaw: Ref<string | undefined>\n config: ComputedRef<ApiReferenceConfigurationRaw>\n registryUrl: string\n dashboardUrl: string\n baseUrl: string\n platformProxyUrl: string\n isLoggedIn?: Ref<boolean>\n registryDocuments: Ref<ApiMetadata[]>\n pendingDocuments: Record<string, boolean>\n mode: ChatMode\n terms: { accepted: Ref<boolean>; accept: () => void }\n addDocument: (document: { namespace: string; slug: string; removable?: boolean; tmp?: boolean }) => Promise<void>\n addDocumentAsync: (document: { namespace: string; slug: string; removable?: boolean }) => Promise<void>\n removeDocument: (document: { namespace: string; slug: string }) => void\n getAccessToken?: () => string\n getAgentKey?: () => string\n api: Api\n uploadState: Ref<UploadTmpDocumentState | undefined>\n uploadedTmpDocumentUrl: Ref<string | undefined>\n curatedDocuments: Ref<ApiMetadata[]>\n getActiveDocumentJson?: () => string\n hideAddApi?: boolean\n}\n\nfunction createChat({\n registryDocuments,\n workspaceStore,\n baseUrl,\n getAccessToken,\n getAgentKey,\n getActiveDocumentSelection,\n}: {\n registryDocuments: Ref<ApiMetadata[]>\n workspaceStore: WorkspaceStore\n baseUrl: string\n getAccessToken?: () => string\n getAgentKey?: () => string\n getActiveDocumentSelection?: () => SelectedDocument | undefined\n}) {\n const chat = new Chat<UIMessage<unknown, UIDataTypes, Tools>>({\n sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithToolCalls,\n transport: new DefaultChatTransport({\n api: `${baseUrl}/vector/openapi/chat`,\n headers: () => createAuthorizationHeaders({ getAccessToken, getAgentKey }),\n body: () => ({\n registryDocuments: registryDocuments.value,\n selectedDocument: getActiveDocumentSelection?.(),\n }),\n }),\n onToolCall({ toolCall }): void {\n if (toolCall.dynamic) {\n return\n }\n\n if (\n (toolCall.toolName === EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME ||\n toolCall.toolName === 'ask-for-authentication') &&\n !isOpenApiDocument(workspaceStore.workspace.documents[toolCall.input.documentName])\n ) {\n // Tool callbacks run inside the stream queue; enqueue the result without waiting on that queue.\n void chat.addToolOutput({\n tool: toolCall.toolName,\n toolCallId: toolCall.toolCallId,\n state: 'output-error',\n errorText: isAsyncApiDocument(workspaceStore.workspace.documents[toolCall.input.documentName])\n ? 'Live AsyncAPI messaging and authentication are not supported in Ask AI. Ask for an explanation or code example instead.'\n : 'Requests and authentication require an OpenAPI document. This document format is not supported in Ask AI.',\n })\n return\n }\n },\n })\n\n return chat\n}\n\nexport function createState({\n initialRegistryDocuments,\n registryUrl,\n dashboardUrl,\n platformProxyUrl,\n baseUrl,\n mode,\n isLoggedIn,\n getAccessToken,\n getAgentKey,\n getActiveDocumentJson,\n getActiveDocumentSelection,\n prefilledMessageRef,\n hideAddApi,\n}: {\n initialRegistryDocuments: { namespace: string; slug: string }[]\n registryUrl: string\n dashboardUrl: string\n platformProxyUrl: string\n baseUrl: string\n mode: ChatMode\n isLoggedIn?: Ref<boolean>\n getAccessToken?: () => string\n getAgentKey?: () => string\n getActiveDocumentJson?: () => string\n getActiveDocumentSelection?: () => SelectedDocument | undefined\n prefilledMessageRef?: Ref<string>\n hideAddApi?: boolean\n}): State {\n const prompt = ref<State['prompt']['value']>(prefilledMessageRef?.value ?? '')\n const registryDocuments = ref<ApiMetadata[]>([])\n const pendingDocuments = reactive<Record<string, boolean>>({})\n const curatedDocuments = ref<ApiMetadata[]>([])\n const proxyUrlRaw = ref<State['proxyUrlRaw']['value']>(URLS.DEFAULT_PROXY_URL)\n const proxyUrl = computed(() => proxyUrlRaw.value?.trim() || URLS.DEFAULT_PROXY_URL)\n const uploadedTmpDocumentUrl = ref<string>()\n const terms = useTermsAndConditions()\n\n const eventBus = createWorkspaceEventBus()\n const workspaceStore = createWorkspaceStore({\n plugins: [\n persistencePlugin({\n persistAuth: true,\n }),\n ],\n })\n\n const config = computed(() =>\n coerce(apiReferenceConfigurationSchema, {\n proxyUrl: proxyUrl.value,\n persistAuth: true,\n }),\n )\n\n const chat = createChat({\n registryDocuments,\n workspaceStore,\n baseUrl,\n getAccessToken,\n getAgentKey,\n getActiveDocumentSelection,\n })\n\n const api = createApi({\n baseUrl,\n getAccessToken,\n getAgentKey,\n })\n\n const loading = computed(\n () =>\n chat.status === 'submitted' ||\n (chat.status === 'streaming' && !chat.lastMessage?.parts.some((part) => part.type === 'text')),\n )\n\n watch(\n () => chat.status,\n () => {\n if (chat.status === 'streaming') {\n prompt.value = ''\n }\n },\n )\n\n if (prefilledMessageRef) {\n watch(prefilledMessageRef, (val) => {\n if (val) {\n prompt.value = val\n }\n })\n }\n\n const settingsModal = useModal()\n\n async function addDocument({\n namespace,\n slug,\n removable = true,\n tmp = false,\n }: {\n namespace: string\n slug: string\n removable?: boolean\n tmp?: boolean\n }) {\n const matchingDoc = registryDocuments.value.find((doc) => doc.namespace === namespace && doc.slug === slug)\n\n if (matchingDoc) {\n return\n }\n\n const identifier = `@${namespace}/${slug}`\n\n pendingDocuments[identifier] = true\n\n const loadDocumentResult = await loadDocument({\n namespace,\n slug,\n workspaceStore,\n registryUrl,\n registryDocuments,\n config: config.value,\n getAccessToken,\n api,\n removable,\n })\n\n pendingDocuments[identifier] = false\n\n if (!loadDocumentResult.success) {\n /**\n * If we are unable to load a document, we just remove it\n * from tmp local storage, do not warn the user.\n */\n if (tmp) {\n removeTmpDocFromLocalStorage()\n throw loadDocumentResult.error\n }\n\n console.warn('[AGENT]: Unable to load document', loadDocumentResult.error)\n toast(`Unable to load the document @${namespace}/${slug}`, 'warn')\n throw loadDocumentResult.error\n }\n }\n\n /**\n * Waits for document to be available in embeddings\n * and adds to the list\n */\n async function addDocumentAsync({\n namespace,\n slug,\n removable = true,\n }: {\n namespace: string\n slug: string\n removable?: boolean\n }) {\n const matchingDoc = registryDocuments.value.find((doc) => doc.namespace === namespace && doc.slug === slug)\n\n if (matchingDoc) {\n return\n }\n\n const identifier = `@${namespace}/${slug}`\n\n pendingDocuments[identifier] = true\n\n const embeddingStatusResponse = await n.fromUnsafe(\n () =>\n fetch(`${baseUrl}/vector/registry/embeddings/${namespace}/${slug}`, {\n method: 'GET',\n }),\n (originalError) => createError('FAILED_TO_GET_EMBEDDING_STATUS', originalError),\n )\n\n if (embeddingStatusResponse.success && embeddingStatusResponse.data.ok) {\n const loadDocumentResult = await loadDocument({\n namespace,\n slug,\n workspaceStore,\n registryUrl,\n registryDocuments,\n config: config.value,\n getAccessToken,\n api,\n removable,\n })\n\n if (!loadDocumentResult.success) {\n console.warn('[AGENT]: Unable to load document', loadDocumentResult.error)\n toast(`Unable to load the document @${namespace}/${slug}`, 'warn')\n }\n } else {\n console.warn('[AGENT]: Document could not be embedded')\n toast(`Unable to embed the document @${namespace}/${slug}`, 'warn')\n }\n\n pendingDocuments[identifier] = false\n }\n\n function removeDocument({ namespace, slug }: { namespace: string; slug: string }) {\n registryDocuments.value = registryDocuments.value.filter(\n (doc) => !(doc.namespace === namespace && doc.slug === slug),\n )\n\n workspaceStore.deleteDocument(createDocumentName(namespace, slug))\n }\n\n initialRegistryDocuments.forEach(({ namespace, slug }) => addDocument({ namespace, slug, removable: false }))\n\n return {\n pendingRequestIds: ref(new Set<string>()),\n prompt,\n chat,\n workspaceStore,\n eventBus,\n loading,\n settingsModal,\n config,\n registryUrl,\n dashboardUrl,\n platformProxyUrl,\n baseUrl,\n registryDocuments,\n pendingDocuments,\n proxyUrl,\n proxyUrlRaw,\n mode,\n terms,\n isLoggedIn,\n addDocument,\n addDocumentAsync,\n removeDocument,\n getAccessToken,\n getAgentKey,\n api,\n uploadState: ref<UploadTmpDocumentState>(),\n uploadedTmpDocumentUrl,\n curatedDocuments,\n getActiveDocumentJson,\n hideAddApi,\n }\n}\n\nexport function useState() {\n const state = inject(STATE_SYMBOL)\n\n if (!state) {\n throw new Error('No state provided.')\n }\n\n return state\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAmEA,IAAa,eAAoC,OAAO,cAAc;AAEtE,IAAM,EAAE,UAAU,UAAU;AAmC5B,SAAS,WAAW,EAClB,mBACA,gBACA,SACA,gBACA,aACA,8BAQC;CACD,MAAM,OAAO,IAAI,KAA6C;EAC5D,uBAAuB;EACvB,WAAW,IAAI,qBAAqB;GAClC,KAAK,GAAG,QAAQ;GAChB,eAAe,2BAA2B;IAAE;IAAgB;GAAY,CAAC;GACzE,aAAa;IACX,mBAAmB,kBAAkB;IACrC,kBAAkB,6BAA6B;GACjD;EACF,CAAC;EACD,WAAW,EAAE,YAAkB;GAC7B,IAAI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zE,MAAM,gCAAgC,UAAU,GAAG,QAAQ,MAAM;GACnE;EACF,OAAO;GACL,QAAQ,KAAK,yCAAyC;GACtD,MAAM,iCAAiC,UAAU,GAAG,QAAQ,MAAM;EACpE;EAEA,iBAAiB,cAAc;CACjC;CAEA,SAAS,eAAe,EAAE,WAAW,QAA6C;EAChF,kBAAkB,QAAQ,kBAAkB,MAAM,QAC/C,QAAQ,EAAE,IAAI,cAAc,aAAa,IAAI,SAAS,KACzD;EAEA,eAAe,eAAe,mBAAmB,WAAW,IAAI,CAAC;CACnE;CAEA,yBAAyB,SAAS,EAAE,WAAW,WAAW,YAAY;EAAE;EAAW;EAAM,WAAW;CAAM,CAAC,CAAC;CAE5G,OAAO;EACL,mBAAmB,oBAAI,IAAI,IAAY,CAAC;EACxC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,aAAa,IAA4B;EACzC;EACA;EACA;EACA;CACF;AACF;AAEA,SAAgB,WAAW;CACzB,MAAM,QAAQ,OAAO,YAAY;CAEjC,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,oBAAoB;CAGtC,OAAO;AACT"}
|
package/dist/style.css
CHANGED
|
@@ -314,8 +314,8 @@
|
|
|
314
314
|
filter: brightness(1.1);
|
|
315
315
|
}
|
|
316
316
|
|
|
317
|
-
.scalar-icon[data-v-
|
|
318
|
-
stroke-width: var(--
|
|
317
|
+
.scalar-icon[data-v-6150d8b1], .scalar-icon[data-v-6150d8b1] * {
|
|
318
|
+
stroke-width: var(--scalar-icon-stroke-width);
|
|
319
319
|
}
|
|
320
320
|
|
|
321
321
|
:where(pre:has( > code.hljs)) {
|
|
@@ -2670,6 +2670,10 @@ input[data-v-029a43f5]::placeholder {
|
|
|
2670
2670
|
margin-inline: -1px;
|
|
2671
2671
|
}
|
|
2672
2672
|
|
|
2673
|
+
.scalar-app .mx-auto {
|
|
2674
|
+
margin-inline: auto;
|
|
2675
|
+
}
|
|
2676
|
+
|
|
2673
2677
|
.scalar-app .mx-px {
|
|
2674
2678
|
margin-inline: 1px;
|
|
2675
2679
|
}
|
|
@@ -3079,6 +3083,10 @@ input[data-v-029a43f5]::placeholder {
|
|
|
3079
3083
|
flex-grow: 3;
|
|
3080
3084
|
}
|
|
3081
3085
|
|
|
3086
|
+
.scalar-app .border-collapse {
|
|
3087
|
+
border-collapse: collapse;
|
|
3088
|
+
}
|
|
3089
|
+
|
|
3082
3090
|
.scalar-app .-translate-x-1\/2 {
|
|
3083
3091
|
--tw-translate-x: calc(calc(1 / 2 * 100%) * -1);
|
|
3084
3092
|
translate: var(--tw-translate-x) var(--tw-translate-y);
|
|
@@ -3187,6 +3195,10 @@ input[data-v-029a43f5]::placeholder {
|
|
|
3187
3195
|
grid-auto-rows: auto;
|
|
3188
3196
|
}
|
|
3189
3197
|
|
|
3198
|
+
.scalar-app .grid-cols-7 {
|
|
3199
|
+
grid-template-columns: repeat(7, minmax(0, 1fr));
|
|
3200
|
+
}
|
|
3201
|
+
|
|
3190
3202
|
.scalar-app .grid-cols-\[44px_1fr_repeat\(3\,auto\)\] {
|
|
3191
3203
|
grid-template-columns: 44px 1fr repeat(3, auto);
|
|
3192
3204
|
}
|
|
@@ -3581,6 +3593,10 @@ input[data-v-029a43f5]::placeholder {
|
|
|
3581
3593
|
padding-inline: var(--scalar-sidebar-padding);
|
|
3582
3594
|
}
|
|
3583
3595
|
|
|
3596
|
+
.scalar-app .px-\[5px\] {
|
|
3597
|
+
padding-inline: 5px;
|
|
3598
|
+
}
|
|
3599
|
+
|
|
3584
3600
|
.scalar-app .py-\[6\.75px\] {
|
|
3585
3601
|
padding-block: 6.75px;
|
|
3586
3602
|
}
|
|
@@ -3637,6 +3653,10 @@ input[data-v-029a43f5]::placeholder {
|
|
|
3637
3653
|
text-align: start;
|
|
3638
3654
|
}
|
|
3639
3655
|
|
|
3656
|
+
.scalar-app .align-\[1px\] {
|
|
3657
|
+
vertical-align: 1px;
|
|
3658
|
+
}
|
|
3659
|
+
|
|
3640
3660
|
.scalar-app .text-\(length\:--scalar-mini\) {
|
|
3641
3661
|
font-size: var(--scalar-mini);
|
|
3642
3662
|
}
|
|
@@ -3671,6 +3691,11 @@ input[data-v-029a43f5]::placeholder {
|
|
|
3671
3691
|
line-height: 7px;
|
|
3672
3692
|
}
|
|
3673
3693
|
|
|
3694
|
+
.scalar-app .leading-\[14px\] {
|
|
3695
|
+
--tw-leading: 14px;
|
|
3696
|
+
line-height: 14px;
|
|
3697
|
+
}
|
|
3698
|
+
|
|
3674
3699
|
.scalar-app .leading-\[20px\] {
|
|
3675
3700
|
--tw-leading: 20px;
|
|
3676
3701
|
line-height: 20px;
|
|
@@ -4388,6 +4413,10 @@ input[data-v-029a43f5]::placeholder {
|
|
|
4388
4413
|
opacity: 1;
|
|
4389
4414
|
}
|
|
4390
4415
|
|
|
4416
|
+
.scalar-app .rtl\:rotate-180:where(:dir(rtl), [dir="rtl"], [dir="rtl"] *) {
|
|
4417
|
+
rotate: 180deg;
|
|
4418
|
+
}
|
|
4419
|
+
|
|
4391
4420
|
@media (prefers-color-scheme: dark) {
|
|
4392
4421
|
.scalar-app .dark\:bg-\(--bg-dark\) {
|
|
4393
4422
|
background-color: var(--bg-dark);
|
|
@@ -5051,37 +5080,37 @@ input[data-v-029a43f5]::placeholder {
|
|
|
5051
5080
|
}
|
|
5052
5081
|
}
|
|
5053
5082
|
|
|
5054
|
-
.requestHeaderContainer[data-v-
|
|
5083
|
+
.requestHeaderContainer[data-v-92d74c5a] {
|
|
5055
5084
|
display: flex;
|
|
5056
5085
|
align-items: center;
|
|
5057
5086
|
justify-content: space-between;
|
|
5058
5087
|
padding: 0 5px;
|
|
5059
5088
|
}
|
|
5060
|
-
.requestPreview[data-v-
|
|
5089
|
+
.requestPreview[data-v-92d74c5a] {
|
|
5061
5090
|
border-radius: var(--scalar-radius-2xl);
|
|
5062
5091
|
display: flex;
|
|
5063
5092
|
flex-direction: column;
|
|
5064
5093
|
width: 100%;
|
|
5065
5094
|
position: relative;
|
|
5066
5095
|
}
|
|
5067
|
-
.requestContent[data-v-
|
|
5096
|
+
.requestContent[data-v-92d74c5a] {
|
|
5068
5097
|
display: grid;
|
|
5069
5098
|
grid-template-rows: 0fr;
|
|
5070
5099
|
min-height: 0;
|
|
5071
5100
|
overflow: hidden;
|
|
5072
5101
|
transition: grid-template-rows 0.2s ease-out;
|
|
5073
5102
|
}
|
|
5074
|
-
.requestPreview.open .requestContent[data-v-
|
|
5103
|
+
.requestPreview.open .requestContent[data-v-92d74c5a] {
|
|
5075
5104
|
grid-template-rows: 1fr;
|
|
5076
5105
|
}
|
|
5077
|
-
.requestPreview.succeeded[data-v-
|
|
5106
|
+
.requestPreview.succeeded[data-v-92d74c5a] {
|
|
5078
5107
|
padding: 0;
|
|
5079
5108
|
}
|
|
5080
|
-
.requestContentInner[data-v-
|
|
5109
|
+
.requestContentInner[data-v-92d74c5a] {
|
|
5081
5110
|
min-height: 0;
|
|
5082
5111
|
overflow: hidden;
|
|
5083
5112
|
}
|
|
5084
|
-
.code[data-v-
|
|
5113
|
+
.code[data-v-92d74c5a] {
|
|
5085
5114
|
display: flex;
|
|
5086
5115
|
flex-direction: column;
|
|
5087
5116
|
font-size: var(--scalar-font-size-4);
|
|
@@ -5094,34 +5123,34 @@ input[data-v-029a43f5]::placeholder {
|
|
|
5094
5123
|
overflow: hidden;
|
|
5095
5124
|
margin-bottom: 12px;
|
|
5096
5125
|
}
|
|
5097
|
-
.dark-mode .code[data-v-
|
|
5126
|
+
.dark-mode .code[data-v-92d74c5a] {
|
|
5098
5127
|
background: var(--scalar-background-2);
|
|
5099
5128
|
}
|
|
5100
|
-
.code h1[data-v-
|
|
5129
|
+
.code h1[data-v-92d74c5a] {
|
|
5101
5130
|
font-size: var(--scalar-font-size-3);
|
|
5102
5131
|
color: var(--scalar-color-3);
|
|
5103
5132
|
padding: 8px;
|
|
5104
5133
|
}
|
|
5105
|
-
.code[data-v-
|
|
5134
|
+
.code[data-v-92d74c5a] .codeBlock {
|
|
5106
5135
|
max-height: calc(50vh - 100px);
|
|
5107
5136
|
padding-top: 0;
|
|
5108
5137
|
}
|
|
5109
|
-
.autosendContainer[data-v-
|
|
5138
|
+
.autosendContainer[data-v-92d74c5a] {
|
|
5110
5139
|
display: flex;
|
|
5111
5140
|
justify-content: space-between;
|
|
5112
5141
|
}
|
|
5113
|
-
.sendButton[data-v-
|
|
5142
|
+
.sendButton[data-v-92d74c5a] {
|
|
5114
5143
|
background: var(--scalar-color-blue);
|
|
5115
5144
|
color: white;
|
|
5116
5145
|
font-weight: var(--scalar-semibold);
|
|
5117
5146
|
padding: 5px 10px;
|
|
5118
5147
|
}
|
|
5119
|
-
.sendButton[data-v-
|
|
5120
|
-
.sendButton[data-v-
|
|
5148
|
+
.sendButton[data-v-92d74c5a]:hover,
|
|
5149
|
+
.sendButton[data-v-92d74c5a]:active {
|
|
5121
5150
|
background: color-mix(in srgb, var(--scalar-color-blue), black 10%);
|
|
5122
5151
|
color: white !important;
|
|
5123
5152
|
}
|
|
5124
|
-
.toggleButton[data-v-
|
|
5153
|
+
.toggleButton[data-v-92d74c5a] {
|
|
5125
5154
|
background: none;
|
|
5126
5155
|
border: none;
|
|
5127
5156
|
cursor: pointer;
|
|
@@ -5133,7 +5162,7 @@ input[data-v-029a43f5]::placeholder {
|
|
|
5133
5162
|
justify-content: space-between;
|
|
5134
5163
|
border-radius: var(--scalar-radius-lg);
|
|
5135
5164
|
}
|
|
5136
|
-
.toggleButton[data-v-
|
|
5165
|
+
.toggleButton[data-v-92d74c5a]:hover {
|
|
5137
5166
|
text-decoration: underline;
|
|
5138
5167
|
}
|
|
5139
5168
|
|
package/dist/types.d.ts
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
export type ChatMode = 'preview' | 'full';
|
|
2
|
+
/** Identifies the selected API description within the documents authorized for a chat. */
|
|
3
|
+
export type SelectedDocument = {
|
|
4
|
+
source: string;
|
|
5
|
+
title: string;
|
|
6
|
+
format: 'OpenAPI' | 'AsyncAPI';
|
|
7
|
+
/** The API's info.version, rather than the OpenAPI or AsyncAPI specification version. */
|
|
8
|
+
version: string;
|
|
9
|
+
};
|
|
2
10
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAA"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAA;AAEzC,0FAA0F;AAC1F,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,SAAS,GAAG,UAAU,CAAA;IAC9B,yFAAyF;IACzF,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA"}
|
package/dist/vue-styles.css
CHANGED
|
@@ -255,37 +255,37 @@
|
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
-
.requestHeaderContainer[data-v-
|
|
258
|
+
.requestHeaderContainer[data-v-92d74c5a] {
|
|
259
259
|
display: flex;
|
|
260
260
|
align-items: center;
|
|
261
261
|
justify-content: space-between;
|
|
262
262
|
padding: 0 5px;
|
|
263
263
|
}
|
|
264
|
-
.requestPreview[data-v-
|
|
264
|
+
.requestPreview[data-v-92d74c5a] {
|
|
265
265
|
border-radius: var(--scalar-radius-2xl);
|
|
266
266
|
display: flex;
|
|
267
267
|
flex-direction: column;
|
|
268
268
|
width: 100%;
|
|
269
269
|
position: relative;
|
|
270
270
|
}
|
|
271
|
-
.requestContent[data-v-
|
|
271
|
+
.requestContent[data-v-92d74c5a] {
|
|
272
272
|
display: grid;
|
|
273
273
|
grid-template-rows: 0fr;
|
|
274
274
|
min-height: 0;
|
|
275
275
|
overflow: hidden;
|
|
276
276
|
transition: grid-template-rows 0.2s ease-out;
|
|
277
277
|
}
|
|
278
|
-
.requestPreview.open .requestContent[data-v-
|
|
278
|
+
.requestPreview.open .requestContent[data-v-92d74c5a] {
|
|
279
279
|
grid-template-rows: 1fr;
|
|
280
280
|
}
|
|
281
|
-
.requestPreview.succeeded[data-v-
|
|
281
|
+
.requestPreview.succeeded[data-v-92d74c5a] {
|
|
282
282
|
padding: 0;
|
|
283
283
|
}
|
|
284
|
-
.requestContentInner[data-v-
|
|
284
|
+
.requestContentInner[data-v-92d74c5a] {
|
|
285
285
|
min-height: 0;
|
|
286
286
|
overflow: hidden;
|
|
287
287
|
}
|
|
288
|
-
.code[data-v-
|
|
288
|
+
.code[data-v-92d74c5a] {
|
|
289
289
|
display: flex;
|
|
290
290
|
flex-direction: column;
|
|
291
291
|
font-size: var(--scalar-font-size-4);
|
|
@@ -298,34 +298,34 @@
|
|
|
298
298
|
overflow: hidden;
|
|
299
299
|
margin-bottom: 12px;
|
|
300
300
|
}
|
|
301
|
-
.dark-mode .code[data-v-
|
|
301
|
+
.dark-mode .code[data-v-92d74c5a] {
|
|
302
302
|
background: var(--scalar-background-2);
|
|
303
303
|
}
|
|
304
|
-
.code h1[data-v-
|
|
304
|
+
.code h1[data-v-92d74c5a] {
|
|
305
305
|
font-size: var(--scalar-font-size-3);
|
|
306
306
|
color: var(--scalar-color-3);
|
|
307
307
|
padding: 8px;
|
|
308
308
|
}
|
|
309
|
-
.code[data-v-
|
|
309
|
+
.code[data-v-92d74c5a] .codeBlock {
|
|
310
310
|
max-height: calc(50vh - 100px);
|
|
311
311
|
padding-top: 0;
|
|
312
312
|
}
|
|
313
|
-
.autosendContainer[data-v-
|
|
313
|
+
.autosendContainer[data-v-92d74c5a] {
|
|
314
314
|
display: flex;
|
|
315
315
|
justify-content: space-between;
|
|
316
316
|
}
|
|
317
|
-
.sendButton[data-v-
|
|
317
|
+
.sendButton[data-v-92d74c5a] {
|
|
318
318
|
background: var(--scalar-color-blue);
|
|
319
319
|
color: white;
|
|
320
320
|
font-weight: var(--scalar-semibold);
|
|
321
321
|
padding: 5px 10px;
|
|
322
322
|
}
|
|
323
|
-
.sendButton[data-v-
|
|
324
|
-
.sendButton[data-v-
|
|
323
|
+
.sendButton[data-v-92d74c5a]:hover,
|
|
324
|
+
.sendButton[data-v-92d74c5a]:active {
|
|
325
325
|
background: color-mix(in srgb, var(--scalar-color-blue), black 10%);
|
|
326
326
|
color: white !important;
|
|
327
327
|
}
|
|
328
|
-
.toggleButton[data-v-
|
|
328
|
+
.toggleButton[data-v-92d74c5a] {
|
|
329
329
|
background: none;
|
|
330
330
|
border: none;
|
|
331
331
|
cursor: pointer;
|
|
@@ -337,7 +337,7 @@
|
|
|
337
337
|
justify-content: space-between;
|
|
338
338
|
border-radius: var(--scalar-radius-lg);
|
|
339
339
|
}
|
|
340
|
-
.toggleButton[data-v-
|
|
340
|
+
.toggleButton[data-v-92d74c5a]:hover {
|
|
341
341
|
text-decoration: underline;
|
|
342
342
|
}
|
|
343
343
|
|
package/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.12.
|
|
13
|
+
"version": "0.12.56",
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=22"
|
|
16
16
|
},
|
|
@@ -46,18 +46,18 @@
|
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@ai-sdk/vue": "4.0.173",
|
|
49
|
-
"@scalar/api-client": "3.
|
|
50
|
-
"@scalar/components": "0.35.
|
|
51
|
-
"@scalar/helpers": "0.
|
|
49
|
+
"@scalar/api-client": "3.28.0",
|
|
50
|
+
"@scalar/components": "0.35.3",
|
|
51
|
+
"@scalar/helpers": "0.19.0",
|
|
52
52
|
"@scalar/icons": "0.7.11",
|
|
53
|
-
"@scalar/json-magic": "0.21.
|
|
53
|
+
"@scalar/json-magic": "0.21.1",
|
|
54
54
|
"@scalar/openapi-types": "0.9.10",
|
|
55
|
-
"@scalar/schemas": "0.
|
|
55
|
+
"@scalar/schemas": "0.19.0",
|
|
56
56
|
"@scalar/themes": "0.20.3",
|
|
57
|
-
"@scalar/types": "0.
|
|
57
|
+
"@scalar/types": "0.31.0",
|
|
58
58
|
"@scalar/use-toasts": "0.10.9",
|
|
59
59
|
"@scalar/validation": "0.6.9",
|
|
60
|
-
"@scalar/workspace-store": "0.
|
|
60
|
+
"@scalar/workspace-store": "0.75.0",
|
|
61
61
|
"@vueuse/core": "15.0.0",
|
|
62
62
|
"ai": "7.0.173",
|
|
63
63
|
"js-base64": "^3.9.6",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"vue": "^3.5.45"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@scalar/sidebar": "0.
|
|
69
|
+
"@scalar/sidebar": "0.13.0",
|
|
70
70
|
"@tailwindcss/cli": "^4.3.5",
|
|
71
71
|
"@tailwindcss/vite": "^4.3.5",
|
|
72
72
|
"@types/jsdom": "30.0.0",
|