@scalar/agent-chat 0.12.57 → 0.12.58
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/package.json +1 -1
- package/dist/state/ai-sdk/index.d.ts +4 -0
- package/dist/state/ai-sdk/index.d.ts.map +1 -0
- package/dist/state/ai-sdk/index.js +4 -0
- package/dist/state/state.d.ts +2 -2
- package/dist/state/state.d.ts.map +1 -1
- package/dist/state/state.js +1 -2
- package/dist/state/state.js.map +1 -1
- package/dist/style.css +10 -10
- package/package.json +14 -14
- package/dist/App.test.d.ts +0 -2
- package/dist/App.test.d.ts.map +0 -1
- package/dist/client-tools/execute-request.redaction.test.d.ts +0 -2
- package/dist/client-tools/execute-request.redaction.test.d.ts.map +0 -1
- package/dist/client-tools/execute-request.test.d.ts +0 -2
- package/dist/client-tools/execute-request.test.d.ts.map +0 -1
- package/dist/client-tools/redact-secrets.test.d.ts +0 -2
- package/dist/client-tools/redact-secrets.test.d.ts.map +0 -1
- package/dist/helpers/get-search-result-labels.test.d.ts +0 -2
- package/dist/helpers/get-search-result-labels.test.d.ts.map +0 -1
- package/dist/hooks/use-chat-approvals.test.d.ts +0 -2
- package/dist/hooks/use-chat-approvals.test.d.ts.map +0 -1
- package/dist/registry/add-documents-to-store.test.d.ts +0 -2
- package/dist/registry/add-documents-to-store.test.d.ts.map +0 -1
- package/dist/state/state.test.d.ts +0 -2
- package/dist/state/state.test.d.ts.map +0 -1
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,KAAK,gBAAgB,EAA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AM,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;;;;;;;;;;;;;;;;;;;;;;;;;;iBA2B4B,CAAC;WAAe,CAAA;;;;;iBAC9B,CAAA;;;;;;;;;;;;;;CAdvB,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"}
|
package/dist/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/state/ai-sdk/index.ts"],"names":[],"mappings":"AACA,OAAO,mBAAmB,CAAA;AAE1B,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,oBAAoB,EAAE,2CAA2C,EAAE,MAAM,IAAI,CAAA"}
|
package/dist/state/state.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { Chat } from '@ai-sdk/vue';
|
|
2
1
|
import { type ModalState } from '@scalar/components/modal';
|
|
3
2
|
import type { ApiReferenceConfigurationRaw } from '@scalar/types/api-reference';
|
|
4
3
|
import { type WorkspaceStore } from '@scalar/workspace-store/client';
|
|
5
4
|
import type { WorkspaceEventBus } from '@scalar/workspace-store/events';
|
|
6
|
-
import {
|
|
5
|
+
import type { UIDataTypes, UIMessage } from 'ai';
|
|
7
6
|
import { type ComputedRef, type InjectionKey, type Ref } from 'vue';
|
|
8
7
|
import { type Api } from '../api.js';
|
|
9
8
|
import type { ApiMetadata } from '../entities/registry/document.js';
|
|
@@ -13,6 +12,7 @@ import type { GetOpenAPISpecsSummaryToolOutput, SUMMARIZE_OPENAPI_SPECS_TOOL_NAM
|
|
|
13
12
|
import type { SEARCH_OPENAPI_OPERATIONS_TOOL_NAME, SearchOpenAPIOperationsToolInput, SearchOpenAPIOperationsToolOutput } from '../entities/tools/search-openapi-operations.js';
|
|
14
13
|
import { type UploadTmpDocumentState } from '../hooks/use-upload-tmp-document.js';
|
|
15
14
|
import type { ChatMode, SelectedDocument } from '../types.js';
|
|
15
|
+
import { Chat } from './ai-sdk/index.js';
|
|
16
16
|
export type RegistryDocument = {
|
|
17
17
|
namespace: string;
|
|
18
18
|
slug: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/state/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/state/state.ts"],"names":[],"mappings":"AAAA,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,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,IAAI,CAAA;AAEhD,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,EACh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AAmB,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
|
@@ -7,16 +7,15 @@ import { removeTmpDocFromLocalStorage } from "../hooks/use-upload-tmp-document.j
|
|
|
7
7
|
import { persistencePlugin } from "../plugins/persistance.js";
|
|
8
8
|
import { loadDocument } from "../registry/add-documents-to-store.js";
|
|
9
9
|
import { createDocumentName } from "../registry/create-document-name.js";
|
|
10
|
+
import { Chat, DefaultChatTransport, lastAssistantMessageIsCompleteWithToolCalls } from "./ai-sdk/index.js";
|
|
10
11
|
import { computed, inject, reactive, ref, watch } from "vue";
|
|
11
12
|
import { useToasts } from "@scalar/use-toasts";
|
|
12
|
-
import { Chat } from "@ai-sdk/vue";
|
|
13
13
|
import { useModal } from "@scalar/components/modal";
|
|
14
14
|
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
18
|
import { isAsyncApiDocument, isOpenApiDocument } from "@scalar/workspace-store/schemas/type-guards";
|
|
19
|
-
import { DefaultChatTransport, lastAssistantMessageIsCompleteWithToolCalls } from "ai";
|
|
20
19
|
import { n } from "neverpanic";
|
|
21
20
|
// src/state/state.ts
|
|
22
21
|
var STATE_SYMBOL = Symbol("STATE_SYMBOL");
|
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, 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,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,4BACA,qBACA,cAeQ;CACR,MA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,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"}
|
|
1
|
+
{"version":3,"file":"state.js","names":[],"sources":["../../src/state/state.ts"],"sourcesContent":["import { 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 type { UIDataTypes, UIMessage } 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\nimport { Chat, DefaultChatTransport, lastAssistantMessageIsCompleteWithToolCalls } from './ai-sdk'\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":";;;;;;;;;;;;;;;;;;;;AAoEA,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,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a;IAC5C;IACA;IACA;IACA;IACA;IACA,QAAQ,OAAO;IACf;IACA;IACA;GACF,CAAC;GAED,IAAI,CAAC,mBAAmB,SAAS;IAC/B,QAAQ,KAAK,oCAAoC,mBAAmB,KAAK;IACzE,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
|
@@ -441,7 +441,7 @@
|
|
|
441
441
|
color: var(--scalar-code-string, var(--scalar-color-blue));
|
|
442
442
|
}
|
|
443
443
|
|
|
444
|
-
.hljs.language-
|
|
444
|
+
.hljs.language-php .hljs-variable, .hljs.language-objectivec .hljs-meta {
|
|
445
445
|
color: var(--scalar-color-1);
|
|
446
446
|
}
|
|
447
447
|
|
|
@@ -1927,7 +1927,7 @@
|
|
|
1927
1927
|
color: var(--scalar-color-1);
|
|
1928
1928
|
}
|
|
1929
1929
|
|
|
1930
|
-
[data-v-
|
|
1930
|
+
[data-v-efbe965b] .cm-content {
|
|
1931
1931
|
font-size: var(--scalar-small);
|
|
1932
1932
|
}
|
|
1933
1933
|
|
|
@@ -1987,38 +1987,38 @@ input[data-v-029a43f5]::placeholder {
|
|
|
1987
1987
|
-moz-text-security: disc;
|
|
1988
1988
|
}
|
|
1989
1989
|
|
|
1990
|
-
.request-section-content[data-v-
|
|
1990
|
+
.request-section-content[data-v-2e177312] {
|
|
1991
1991
|
--scalar-border-width: .5px;
|
|
1992
1992
|
}
|
|
1993
1993
|
|
|
1994
|
-
.request-section-content-filter[data-v-
|
|
1994
|
+
.request-section-content-filter[data-v-2e177312] {
|
|
1995
1995
|
box-shadow: 0 -10px 0 10px var(--scalar-background-1);
|
|
1996
1996
|
}
|
|
1997
1997
|
|
|
1998
|
-
.request-item:focus-within .request-meta-buttons[data-v-
|
|
1998
|
+
.request-item:focus-within .request-meta-buttons[data-v-2e177312] {
|
|
1999
1999
|
opacity: 1;
|
|
2000
2000
|
}
|
|
2001
2001
|
|
|
2002
|
-
.group-hover-input[data-v-
|
|
2002
|
+
.group-hover-input[data-v-2e177312] {
|
|
2003
2003
|
border-width: var(--scalar-border-width);
|
|
2004
2004
|
border-color: #0000;
|
|
2005
2005
|
}
|
|
2006
2006
|
|
|
2007
|
-
.group:hover .group-hover-input[data-v-
|
|
2007
|
+
.group:hover .group-hover-input[data-v-2e177312] {
|
|
2008
2008
|
background: var(--scalar-background-1);
|
|
2009
2009
|
}
|
|
2010
2010
|
|
|
2011
2011
|
@supports (color: color-mix(in lab, red, red)) {
|
|
2012
|
-
.group:hover .group-hover-input[data-v-
|
|
2012
|
+
.group:hover .group-hover-input[data-v-2e177312] {
|
|
2013
2013
|
background: color-mix(in srgb, var(--scalar-background-1), var(--scalar-background-2));
|
|
2014
2014
|
}
|
|
2015
2015
|
}
|
|
2016
2016
|
|
|
2017
|
-
.group:hover .group-hover-input[data-v-
|
|
2017
|
+
.group:hover .group-hover-input[data-v-2e177312] {
|
|
2018
2018
|
border-color: var(--scalar-border-color);
|
|
2019
2019
|
}
|
|
2020
2020
|
|
|
2021
|
-
.group-hover-input[data-v-
|
|
2021
|
+
.group-hover-input[data-v-2e177312]:focus {
|
|
2022
2022
|
border-color: var(--scalar-border-color) !important;
|
|
2023
2023
|
background: none !important;
|
|
2024
2024
|
}
|
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.58",
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=22"
|
|
16
16
|
},
|
|
@@ -45,38 +45,38 @@
|
|
|
45
45
|
"dist"
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@ai-sdk/vue": "4.0.
|
|
49
|
-
"@scalar/api-client": "3.
|
|
50
|
-
"@scalar/components": "0.35.
|
|
48
|
+
"@ai-sdk/vue": "4.0.177",
|
|
49
|
+
"@scalar/api-client": "3.29.0",
|
|
50
|
+
"@scalar/components": "0.35.5",
|
|
51
51
|
"@scalar/helpers": "0.19.0",
|
|
52
52
|
"@scalar/icons": "0.7.11",
|
|
53
|
-
"@scalar/json-magic": "0.
|
|
53
|
+
"@scalar/json-magic": "0.22.0",
|
|
54
54
|
"@scalar/openapi-types": "0.9.10",
|
|
55
|
-
"@scalar/schemas": "0.
|
|
56
|
-
"@scalar/themes": "0.21.
|
|
57
|
-
"@scalar/types": "0.
|
|
55
|
+
"@scalar/schemas": "0.20.0",
|
|
56
|
+
"@scalar/themes": "0.21.1",
|
|
57
|
+
"@scalar/types": "0.32.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.76.0",
|
|
61
61
|
"@vueuse/core": "15.0.0",
|
|
62
|
-
"ai": "7.0.
|
|
63
|
-
"js-base64": "^3.9.
|
|
62
|
+
"ai": "7.0.177",
|
|
63
|
+
"js-base64": "^3.9.7",
|
|
64
64
|
"neverpanic": "0.0.8",
|
|
65
65
|
"truncate-json": "3.0.1",
|
|
66
66
|
"vue": "^3.5.45"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@scalar/sidebar": "0.13.
|
|
69
|
+
"@scalar/sidebar": "0.13.2",
|
|
70
70
|
"@tailwindcss/cli": "^4.3.5",
|
|
71
71
|
"@tailwindcss/vite": "^4.3.5",
|
|
72
72
|
"@types/jsdom": "30.0.0",
|
|
73
73
|
"@vitejs/plugin-vue": "^6.0.11",
|
|
74
74
|
"@vue/test-utils": "2.6.0",
|
|
75
75
|
"hono": "^4.13.18",
|
|
76
|
-
"jsdom": "
|
|
76
|
+
"jsdom": "31.0.1",
|
|
77
77
|
"tailwindcss": "^4.3.5",
|
|
78
78
|
"vite": "8.3.8",
|
|
79
|
-
"vitest": "5.1.
|
|
79
|
+
"vitest": "5.1.1"
|
|
80
80
|
},
|
|
81
81
|
"scripts": {
|
|
82
82
|
"build": "vite build && pnpm build:styles && vue-tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && shx cp package.json dist",
|
package/dist/App.test.d.ts
DELETED
package/dist/App.test.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"App.test.d.ts","sourceRoot":"","sources":["../src/App.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"execute-request.redaction.test.d.ts","sourceRoot":"","sources":["../../src/client-tools/execute-request.redaction.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"execute-request.test.d.ts","sourceRoot":"","sources":["../../src/client-tools/execute-request.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"redact-secrets.test.d.ts","sourceRoot":"","sources":["../../src/client-tools/redact-secrets.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-search-result-labels.test.d.ts","sourceRoot":"","sources":["../../src/helpers/get-search-result-labels.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-chat-approvals.test.d.ts","sourceRoot":"","sources":["../../src/hooks/use-chat-approvals.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"add-documents-to-store.test.d.ts","sourceRoot":"","sources":["../../src/registry/add-documents-to-store.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"state.test.d.ts","sourceRoot":"","sources":["../../src/state/state.test.ts"],"names":[],"mappings":""}
|