@scalar/agent-chat 0.12.53 → 0.12.54
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.map +1 -1
- package/dist/components/ResponseBody/ResponseBodyToggle.vue.d.ts +2 -2
- package/dist/package.json +1 -1
- package/dist/state/state.d.ts.map +1 -1
- package/dist/state/state.js +3 -3
- package/dist/state/state.js.map +1 -1
- package/dist/style.css +32 -4
- package/package.json +14 -14
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;AAEvC,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,sEAAsE;IACtE,wBAAwB,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAA;IACnD,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;;;;;;;;;;;;;;;;;;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
|
};
|
|
4
4
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
5
|
-
toggle: (v: "
|
|
5
|
+
toggle: (v: "raw" | "preview") => any;
|
|
6
6
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
7
|
-
onToggle?: ((v: "
|
|
7
|
+
onToggle?: ((v: "raw" | "preview") => any) | undefined;
|
|
8
8
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
9
|
declare const _default: typeof __VLS_export;
|
|
10
10
|
export default _default;
|
package/dist/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/state/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,KAAK,UAAU,EAAY,MAAM,0BAA0B,CAAA;AAEpE,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAA;AAG/E,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,gCAAgC,CAAA;AAC1F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAGvE,OAAO,EAAwB,KAAK,WAAW,EAAE,KAAK,SAAS,EAA+C,MAAM,IAAI,CAAA;AAExH,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,KAAK,GAAG,EAA0C,MAAM,KAAK,CAAA;AAE3G,OAAO,EAAE,KAAK,GAAG,EAAyC,MAAM,OAAO,CAAA;AAGvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC/D,OAAO,KAAK,EACV,gCAAgC,EAChC,yBAAyB,EAC1B,MAAM,yCAAyC,CAAA;AAChD,OAAO,EACL,qCAAqC,EACrC,KAAK,iCAAiC,EACtC,KAAK,kC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/state/state.js
CHANGED
|
@@ -15,7 +15,7 @@ import { apiReferenceConfigurationSchema } from "@scalar/schemas/api-reference";
|
|
|
15
15
|
import { coerce } from "@scalar/validation";
|
|
16
16
|
import { createWorkspaceStore } from "@scalar/workspace-store/client";
|
|
17
17
|
import { createWorkspaceEventBus } from "@scalar/workspace-store/events";
|
|
18
|
-
import { isAsyncApiDocument } from "@scalar/workspace-store/schemas/type-guards";
|
|
18
|
+
import { isAsyncApiDocument, isOpenApiDocument } from "@scalar/workspace-store/schemas/type-guards";
|
|
19
19
|
import { DefaultChatTransport, lastAssistantMessageIsCompleteWithToolCalls } from "ai";
|
|
20
20
|
import { n } from "neverpanic";
|
|
21
21
|
//#region src/state/state.ts
|
|
@@ -34,12 +34,12 @@ function createChat({ registryDocuments, workspaceStore, baseUrl, getAccessToken
|
|
|
34
34
|
}),
|
|
35
35
|
onToolCall({ toolCall }) {
|
|
36
36
|
if (toolCall.dynamic) return;
|
|
37
|
-
if ((toolCall.toolName === "execute-request" || toolCall.toolName === "ask-for-authentication") &&
|
|
37
|
+
if ((toolCall.toolName === "execute-request" || toolCall.toolName === "ask-for-authentication") && !isOpenApiDocument(workspaceStore.workspace.documents[toolCall.input.documentName])) {
|
|
38
38
|
chat.addToolOutput({
|
|
39
39
|
tool: toolCall.toolName,
|
|
40
40
|
toolCallId: toolCall.toolCallId,
|
|
41
41
|
state: "output-error",
|
|
42
|
-
errorText: "Live AsyncAPI messaging and authentication are not supported in Ask AI. Ask for an explanation or code example instead."
|
|
42
|
+
errorText: isAsyncApiDocument(workspaceStore.workspace.documents[toolCall.input.documentName]) ? "Live AsyncAPI messaging and authentication are not supported in Ask AI. Ask for an explanation or code example instead." : "Requests and authentication require an OpenAPI document. This document format is not supported in Ask AI."
|
|
43
43
|
});
|
|
44
44
|
return;
|
|
45
45
|
}
|
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 } 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 isAsyncApiDocument(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:\n 'Live AsyncAPI messaging and authentication are not supported in Ask AI. Ask for an explanation or code example instead.',\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,mBAAmB,eAAe,UAAU,UAAU,SAAS,MAAM,aAAa,GAClF;IAEA,KAAU,cAAc;KACtB,MAAM,SAAS;KACf,YAAY,SAAS;KACrB,OAAO;KACP,WACE;IACJ,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,M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ACA;EACA;EACA;EACA;EACA;EACA;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 } 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,eA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AyC;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;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
|
@@ -211,6 +211,14 @@
|
|
|
211
211
|
border-radius: var(--scalar-radius-xl);
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
+
:where(.scalar-card.p-1 > .scalar-card-header:first-child:not(:last-child)) {
|
|
215
|
+
margin-block: -2px 2px;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
:where(.scalar-card.p-1 > .scalar-card-footer:last-child:not(:first-child)) {
|
|
219
|
+
margin-block: 2px -2px;
|
|
220
|
+
}
|
|
221
|
+
|
|
214
222
|
.scalar-app .hljs-regexp, .scalar-app .hljs-string, .scalar-app .hljs-built_in, .scalar-app .hljs-subst, .scalar-app .hljs-name, .scalar-app .hljs-doctag, .scalar-app .hljs-section, .scalar-app .hljs-title {
|
|
215
223
|
color: var(--scalar-color-blue);
|
|
216
224
|
}
|
|
@@ -1920,18 +1928,18 @@
|
|
|
1920
1928
|
}
|
|
1921
1929
|
}
|
|
1922
1930
|
|
|
1923
|
-
[data-v-
|
|
1931
|
+
[data-v-81035f01] .code-input-lite__editor {
|
|
1924
1932
|
font-family: var(--scalar-font);
|
|
1925
1933
|
font-size: var(--scalar-small);
|
|
1926
1934
|
background-color: #0000;
|
|
1927
1935
|
padding: 5px 8px;
|
|
1928
1936
|
}
|
|
1929
1937
|
|
|
1930
|
-
[data-v-
|
|
1938
|
+
[data-v-81035f01] .scalar-pill:not(:last-of-type) {
|
|
1931
1939
|
margin-right: .15em;
|
|
1932
1940
|
}
|
|
1933
1941
|
|
|
1934
|
-
[data-v-
|
|
1942
|
+
[data-v-81035f01] .scalar-pill:not(:first-of-type) {
|
|
1935
1943
|
margin-left: .5px;
|
|
1936
1944
|
}
|
|
1937
1945
|
|
|
@@ -2626,6 +2634,10 @@ input[data-v-029a43f5]::placeholder {
|
|
|
2626
2634
|
order: 9999;
|
|
2627
2635
|
}
|
|
2628
2636
|
|
|
2637
|
+
.scalar-app .col-span-2 {
|
|
2638
|
+
grid-column: span 2 / span 2;
|
|
2639
|
+
}
|
|
2640
|
+
|
|
2629
2641
|
.scalar-app .col-span-full {
|
|
2630
2642
|
grid-column: 1 / -1;
|
|
2631
2643
|
}
|
|
@@ -2907,6 +2919,10 @@ input[data-v-029a43f5]::placeholder {
|
|
|
2907
2919
|
max-height: fit-content;
|
|
2908
2920
|
}
|
|
2909
2921
|
|
|
2922
|
+
.scalar-app .max-h-none {
|
|
2923
|
+
max-height: none;
|
|
2924
|
+
}
|
|
2925
|
+
|
|
2910
2926
|
.scalar-app .max-h-radix-popper {
|
|
2911
2927
|
max-height: calc(var(--radix-popper-available-height) - 8px);
|
|
2912
2928
|
}
|
|
@@ -3155,6 +3171,10 @@ input[data-v-029a43f5]::placeholder {
|
|
|
3155
3171
|
resize: vertical;
|
|
3156
3172
|
}
|
|
3157
3173
|
|
|
3174
|
+
.scalar-app .list-none {
|
|
3175
|
+
list-style-type: none;
|
|
3176
|
+
}
|
|
3177
|
+
|
|
3158
3178
|
.scalar-app .appearance-none {
|
|
3159
3179
|
appearance: none;
|
|
3160
3180
|
}
|
|
@@ -3683,7 +3703,15 @@ input[data-v-029a43f5]::placeholder {
|
|
|
3683
3703
|
text-wrap: wrap;
|
|
3684
3704
|
}
|
|
3685
3705
|
|
|
3686
|
-
.scalar-app .break-words
|
|
3706
|
+
.scalar-app .break-words {
|
|
3707
|
+
overflow-wrap: break-word;
|
|
3708
|
+
}
|
|
3709
|
+
|
|
3710
|
+
.scalar-app .wrap-anywhere {
|
|
3711
|
+
overflow-wrap: anywhere;
|
|
3712
|
+
}
|
|
3713
|
+
|
|
3714
|
+
.scalar-app .wrap-break-word {
|
|
3687
3715
|
overflow-wrap: break-word;
|
|
3688
3716
|
}
|
|
3689
3717
|
|
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.54",
|
|
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.171",
|
|
49
|
-
"@scalar/api-client": "3.
|
|
50
|
-
"@scalar/components": "0.35.
|
|
51
|
-
"@scalar/helpers": "0.18.
|
|
52
|
-
"@scalar/icons": "0.7.
|
|
53
|
-
"@scalar/json-magic": "0.20.
|
|
54
|
-
"@scalar/openapi-types": "0.9.
|
|
55
|
-
"@scalar/schemas": "0.18.
|
|
56
|
-
"@scalar/themes": "0.20.
|
|
57
|
-
"@scalar/types": "0.
|
|
58
|
-
"@scalar/use-toasts": "0.10.
|
|
59
|
-
"@scalar/validation": "0.6.
|
|
60
|
-
"@scalar/workspace-store": "0.
|
|
49
|
+
"@scalar/api-client": "3.27.0",
|
|
50
|
+
"@scalar/components": "0.35.1",
|
|
51
|
+
"@scalar/helpers": "0.18.1",
|
|
52
|
+
"@scalar/icons": "0.7.10",
|
|
53
|
+
"@scalar/json-magic": "0.20.1",
|
|
54
|
+
"@scalar/openapi-types": "0.9.10",
|
|
55
|
+
"@scalar/schemas": "0.18.1",
|
|
56
|
+
"@scalar/themes": "0.20.2",
|
|
57
|
+
"@scalar/types": "0.30.0",
|
|
58
|
+
"@scalar/use-toasts": "0.10.8",
|
|
59
|
+
"@scalar/validation": "0.6.9",
|
|
60
|
+
"@scalar/workspace-store": "0.73.0",
|
|
61
61
|
"@vueuse/core": "15.0.0",
|
|
62
62
|
"ai": "7.0.171",
|
|
63
63
|
"js-base64": "^3.9.4",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"vue": "^3.5.44"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@scalar/sidebar": "0.12.
|
|
69
|
+
"@scalar/sidebar": "0.12.11",
|
|
70
70
|
"@tailwindcss/cli": "^4.3.3",
|
|
71
71
|
"@tailwindcss/vite": "^4.3.3",
|
|
72
72
|
"@types/jsdom": "30.0.0",
|