@scalar/agent-chat 0.12.43 → 0.12.45
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.test.d.ts +2 -0
- package/dist/App.test.d.ts.map +1 -0
- package/dist/App.vue.d.ts +4 -0
- package/dist/App.vue.d.ts.map +1 -1
- package/dist/App.vue.js.map +1 -1
- package/dist/App.vue.script.js +2 -0
- package/dist/App.vue.script.js.map +1 -1
- package/dist/Chat.vue.d.ts.map +1 -1
- package/dist/Chat.vue.js.map +1 -1
- package/dist/Chat.vue.script.js +13 -5
- package/dist/Chat.vue.script.js.map +1 -1
- package/dist/components/ApprovalSection.vue.js +1 -1
- package/dist/components/ApprovalSection.vue.js.map +1 -1
- package/dist/components/ApprovalSection.vue.script.js +2 -2
- package/dist/components/ApprovalSection.vue.script.js.map +1 -1
- package/dist/components/UploadSection.vue.js +1 -1
- package/dist/components/UploadSection.vue.js.map +1 -1
- package/dist/components/UploadSection.vue.script.js +2 -2
- package/dist/components/UploadSection.vue.script.js.map +1 -1
- package/dist/entities/tools/get-openapi-specs-summary.d.ts +3 -2
- package/dist/entities/tools/get-openapi-specs-summary.d.ts.map +1 -1
- package/dist/entities/tools/get-openapi-specs-summary.js.map +1 -1
- package/dist/entities/tools/search-openapi-operations.d.ts +2 -1
- package/dist/entities/tools/search-openapi-operations.d.ts.map +1 -1
- package/dist/entities/tools/search-openapi-operations.js.map +1 -1
- package/dist/helpers/get-search-result-labels.d.ts +3 -0
- package/dist/helpers/get-search-result-labels.d.ts.map +1 -0
- package/dist/helpers/get-search-result-labels.js +38 -0
- package/dist/helpers/get-search-result-labels.js.map +1 -0
- package/dist/helpers/get-search-result-labels.test.d.ts +2 -0
- package/dist/helpers/get-search-result-labels.test.d.ts.map +1 -0
- package/dist/helpers.d.ts +1 -3
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +2 -5
- package/dist/helpers.js.map +1 -1
- package/dist/hooks/use-agent-key-documents.js +1 -1
- package/dist/hooks/use-agent-key-documents.js.map +1 -1
- package/dist/hooks/use-chat-approvals.d.ts +3 -18
- package/dist/hooks/use-chat-approvals.d.ts.map +1 -1
- package/dist/hooks/use-chat-approvals.js +1 -0
- package/dist/hooks/use-chat-approvals.js.map +1 -1
- package/dist/hooks/use-chat-pending-client-tool-parts.d.ts +8 -16
- package/dist/hooks/use-chat-pending-client-tool-parts.d.ts.map +1 -1
- package/dist/hooks/use-chat-pending-client-tool-parts.js +1 -0
- package/dist/hooks/use-chat-pending-client-tool-parts.js.map +1 -1
- package/dist/hooks/use-upload-tmp-document.d.ts +1 -1
- package/dist/hooks/use-upload-tmp-document.d.ts.map +1 -1
- package/dist/hooks/use-upload-tmp-document.js +24 -17
- package/dist/hooks/use-upload-tmp-document.js.map +1 -1
- package/dist/package.json +2 -1
- package/dist/registry/add-documents-to-store.d.ts.map +1 -1
- package/dist/registry/add-documents-to-store.js.map +1 -1
- package/dist/state/state.d.ts +5 -1
- package/dist/state/state.d.ts.map +1 -1
- package/dist/state/state.js +15 -6
- package/dist/state/state.js.map +1 -1
- package/dist/state/state.test.d.ts +2 -0
- package/dist/state/state.test.d.ts.map +1 -0
- package/dist/style.css +153 -129
- package/dist/views/Chat/Messages/AskForAuthentication.vue.d.ts.map +1 -1
- package/dist/views/Chat/Messages/AskForAuthentication.vue.js +1 -1
- package/dist/views/Chat/Messages/AskForAuthentication.vue.js.map +1 -1
- package/dist/views/Chat/Messages/AskForAuthentication.vue.script.js +44 -35
- package/dist/views/Chat/Messages/AskForAuthentication.vue.script.js.map +1 -1
- package/dist/views/Chat/Messages/ExecuteRequestTool.vue.d.ts.map +1 -1
- package/dist/views/Chat/Messages/ExecuteRequestTool.vue.js +1 -1
- package/dist/views/Chat/Messages/ExecuteRequestTool.vue.js.map +1 -1
- package/dist/views/Chat/Messages/ExecuteRequestTool.vue.script.js +8 -3
- package/dist/views/Chat/Messages/ExecuteRequestTool.vue.script.js.map +1 -1
- package/dist/views/Chat/Messages/SearchOpenAPIOperationsTool.vue.d.ts.map +1 -1
- package/dist/views/Chat/Messages/SearchOpenAPIOperationsTool.vue.js +1 -1
- package/dist/views/Chat/Messages/SearchOpenAPIOperationsTool.vue.js.map +1 -1
- package/dist/views/Chat/Messages/SearchOpenAPIOperationsTool.vue.script.js +6 -9
- package/dist/views/Chat/Messages/SearchOpenAPIOperationsTool.vue.script.js.map +1 -1
- package/dist/views/PromptForm.vue.d.ts.map +1 -1
- package/dist/views/PromptForm.vue.js +1 -1
- package/dist/views/PromptForm.vue.js.map +1 -1
- package/dist/views/PromptForm.vue.script.js +0 -1
- package/dist/views/PromptForm.vue.script.js.map +1 -1
- package/dist/views/Settings/Settings.vue.d.ts.map +1 -1
- package/dist/views/Settings/Settings.vue.js +1 -1
- package/dist/views/Settings/Settings.vue.js.map +1 -1
- package/dist/views/Settings/Settings.vue.script.js +10 -6
- package/dist/views/Settings/Settings.vue.script.js.map +1 -1
- package/dist/views/Start.vue.js +1 -1
- package/dist/views/Start.vue.js.map +1 -1
- package/dist/views/Start.vue.script.js +1 -1
- package/dist/views/Start.vue.script.js.map +1 -1
- package/dist/vue-styles.css +81 -81
- package/package.json +14 -13
|
@@ -7,6 +7,7 @@ import { computed } from "vue";
|
|
|
7
7
|
function requestPartRequiresApproval(part) {
|
|
8
8
|
return part.type === `tool-execute-request` && part.state === "input-available" && part.input?.method?.toLowerCase() !== "get";
|
|
9
9
|
}
|
|
10
|
+
/** Exposes pending request approvals without leaking SDK implementation types. */
|
|
10
11
|
function useRequestApprovals() {
|
|
11
12
|
const state = useState();
|
|
12
13
|
const approvalRequiredParts = computed(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-chat-approvals.js","names":[],"sources":["../../src/hooks/use-chat-approvals.ts"],"sourcesContent":["import type { ToolUIPart, UIMessagePart } from 'ai'\nimport { computed } from 'vue'\n\nimport { executeRequestTool } from '@/client-tools/execute-request'\nimport { EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME } from '@/entities'\nimport { createDocumentSettings } from '@/helpers'\nimport { type Tools, useState } from '@/state/state'\n\ntype RequestToolPart = ToolUIPart & {\n type: 'tool-execute-request'\n state: 'input-available'\n input: Tools['execute-request']['input']\n}\n\nexport function requestPartRequiresApproval(part: UIMessagePart<any, Tools>): part is RequestToolPart {\n return (\n part.type === (`tool-${EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME}` as const) &&\n part.state === 'input-available' &&\n part.input?.method?.toLowerCase() !== 'get'\n )\n}\n\nexport function useRequestApprovals() {\n const state = useState()\n\n const approvalRequiredParts = computed(() => {\n return state.chat.messages\n .filter((message) => message.parts.some(requestPartRequiresApproval))\n .flatMap((message) => message.parts)\n .filter(requestPartRequiresApproval) as RequestToolPart[]\n })\n\n async function respondToRequestApprovals(approved: boolean) {\n const approvalPromises = approvalRequiredParts.value.map(async (toolPart) => {\n if (!approved) {\n return await state.chat.addToolOutput({\n tool: EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME,\n toolCallId: toolPart.toolCallId,\n state: 'output-error',\n errorText: 'The user denied the request.',\n })\n }\n\n await executeRequestTool({\n documentSettings: createDocumentSettings(state.workspaceStore),\n proxyUrl: state.proxyUrl.value,\n input: toolPart.input,\n toolCallId: toolPart.toolCallId,\n chat: state.chat,\n })\n })\n\n await Promise.all(approvalPromises)\n }\n\n return { approvalRequiredParts, respondToRequestApprovals }\n}\n"],"mappings":";;;;;;AAcA,SAAgB,4BAA4B,MAA0D;CACpG,OACE,KAAK,SAAU,0BACf,KAAK,UAAU,qBACf,KAAK,OAAO,QAAQ,YAAY,MAAM;AAE1C
|
|
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\nexport function requestPartRequiresApproval(part: UIMessagePart<any, Tools>): part is RequestToolPart {\n return (\n part.type === (`tool-${EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME}` as const) &&\n part.state === 'input-available' &&\n part.input?.method?.toLowerCase() !== 'get'\n )\n}\n\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) as RequestToolPart[]\n })\n\n async function respondToRequestApprovals(approved: boolean) {\n const approvalPromises = approvalRequiredParts.value.map(async (toolPart) => {\n if (!approved) {\n return await state.chat.addToolOutput({\n tool: EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME,\n toolCallId: toolPart.toolCallId,\n state: 'output-error',\n errorText: 'The user denied the request.',\n })\n }\n\n await executeRequestTool({\n documentSettings: createDocumentSettings(state.workspaceStore),\n proxyUrl: state.proxyUrl.value,\n input: toolPart.input,\n toolCallId: toolPart.toolCallId,\n chat: state.chat,\n })\n })\n\n await Promise.all(approvalPromises)\n }\n\n return { approvalRequiredParts, respondToRequestApprovals }\n}\n"],"mappings":";;;;;;AAcA,SAAgB,4BAA4B,MAA0D;CACpG,OACE,KAAK,SAAU,0BACf,KAAK,UAAU,qBACf,KAAK,OAAO,QAAQ,YAAY,MAAM;AAE1C;;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;CACvC,CAAC;CAED,eAAe,0BAA0B,UAAmB;EAC1D,MAAM,mBAAmB,sBAAsB,MAAM,IAAI,OAAO,aAAa;GAC3E,IAAI,CAAC,UACH,OAAO,MAAM,MAAM,KAAK,cAAc;IACpC,MAAM;IACN,YAAY,SAAS;IACrB,OAAO;IACP,WAAW;GACb,CAAC;GAGH,MAAM,mBAAmB;IACvB,kBAAkB,uBAAuB,MAAM,cAAc;IAC7D,UAAU,MAAM,SAAS;IACzB,OAAO,SAAS;IAChB,YAAY,SAAS;IACrB,MAAM,MAAM;GACd,CAAC;EACH,CAAC;EAED,MAAM,QAAQ,IAAI,gBAAgB;CACpC;CAEA,OAAO;EAAE;EAAuB;CAA0B;AAC5D"}
|
|
@@ -1,19 +1,11 @@
|
|
|
1
|
+
import type { ToolUIPart } from 'ai';
|
|
2
|
+
import { type ComputedRef } from 'vue';
|
|
3
|
+
type PendingClientToolPart = ToolUIPart & {
|
|
4
|
+
state: 'input-available';
|
|
5
|
+
};
|
|
6
|
+
/** Exposes pending client tools without leaking SDK implementation types. */
|
|
1
7
|
export declare function useChatPendingClientToolParts(): {
|
|
2
|
-
pendingClientToolParts:
|
|
3
|
-
type: `tool-${string}`;
|
|
4
|
-
} & {
|
|
5
|
-
toolCallId: string;
|
|
6
|
-
title?: string;
|
|
7
|
-
providerExecuted?: boolean;
|
|
8
|
-
} & {
|
|
9
|
-
state: "input-available";
|
|
10
|
-
input: unknown;
|
|
11
|
-
output?: never;
|
|
12
|
-
errorText?: never;
|
|
13
|
-
callProviderMetadata?: import("ai").ProviderMetadata;
|
|
14
|
-
approval?: never;
|
|
15
|
-
} & {
|
|
16
|
-
state: "input-available";
|
|
17
|
-
})[]>;
|
|
8
|
+
pendingClientToolParts: ComputedRef<PendingClientToolPart[]>;
|
|
18
9
|
};
|
|
10
|
+
export {};
|
|
19
11
|
//# sourceMappingURL=use-chat-pending-client-tool-parts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-chat-pending-client-tool-parts.d.ts","sourceRoot":"","sources":["../../src/hooks/use-chat-pending-client-tool-parts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-chat-pending-client-tool-parts.d.ts","sourceRoot":"","sources":["../../src/hooks/use-chat-pending-client-tool-parts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAA0B,MAAM,IAAI,CAAA;AAC5D,OAAO,EAAE,KAAK,WAAW,EAAY,MAAM,KAAK,CAAA;AAIhD,KAAK,qBAAqB,GAAG,UAAU,GAAG;IAAE,KAAK,EAAE,iBAAiB,CAAA;CAAE,CAAA;AAMtE,6EAA6E;AAC7E,wBAAgB,6BAA6B,IAAI;IAC/C,sBAAsB,EAAE,WAAW,CAAC,qBAAqB,EAAE,CAAC,CAAA;CAC7D,CAWA"}
|
|
@@ -4,6 +4,7 @@ import { computed } from "vue";
|
|
|
4
4
|
function isPendingClientToolPart(part) {
|
|
5
5
|
return part.type.startsWith("tool") && part.state === "input-available";
|
|
6
6
|
}
|
|
7
|
+
/** Exposes pending client tools without leaking SDK implementation types. */
|
|
7
8
|
function useChatPendingClientToolParts() {
|
|
8
9
|
const state = useState();
|
|
9
10
|
return { pendingClientToolParts: computed(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-chat-pending-client-tool-parts.js","names":[],"sources":["../../src/hooks/use-chat-pending-client-tool-parts.ts"],"sourcesContent":["import type { ToolUIPart, UIMessagePart, UITools } from 'ai'\nimport { computed } from 'vue'\n\nimport { useState } from '@/state/state'\n\ntype PendingClientToolPart = ToolUIPart & { state: 'input-available' }\n\nfunction isPendingClientToolPart(part: UIMessagePart<any, UITools>): part is PendingClientToolPart {\n return part.type.startsWith('tool') && (part as ToolUIPart).state === 'input-available'\n}\n\nexport function useChatPendingClientToolParts() {\n const state = useState()\n\n const pendingClientToolParts = computed(() => {\n return state.chat.messages\n .filter((message) => message.parts.some(isPendingClientToolPart))\n .flatMap((message) => message.parts)\n .filter(isPendingClientToolPart) as PendingClientToolPart[]\n })\n\n return { pendingClientToolParts }\n}\n"],"mappings":";;;AAOA,SAAS,wBAAwB,MAAkE;CACjG,OAAO,KAAK,KAAK,WAAW,MAAM,KAAM,KAAoB,UAAU;AACxE
|
|
1
|
+
{"version":3,"file":"use-chat-pending-client-tool-parts.js","names":[],"sources":["../../src/hooks/use-chat-pending-client-tool-parts.ts"],"sourcesContent":["import type { ToolUIPart, UIMessagePart, UITools } from 'ai'\nimport { type ComputedRef, computed } from 'vue'\n\nimport { useState } from '@/state/state'\n\ntype PendingClientToolPart = ToolUIPart & { state: 'input-available' }\n\nfunction isPendingClientToolPart(part: UIMessagePart<any, UITools>): part is PendingClientToolPart {\n return part.type.startsWith('tool') && (part as ToolUIPart).state === 'input-available'\n}\n\n/** Exposes pending client tools without leaking SDK implementation types. */\nexport function useChatPendingClientToolParts(): {\n pendingClientToolParts: ComputedRef<PendingClientToolPart[]>\n} {\n const state = useState()\n\n const pendingClientToolParts = computed(() => {\n return state.chat.messages\n .filter((message) => message.parts.some(isPendingClientToolPart))\n .flatMap((message) => message.parts)\n .filter(isPendingClientToolPart) as PendingClientToolPart[]\n })\n\n return { pendingClientToolParts }\n}\n"],"mappings":";;;AAOA,SAAS,wBAAwB,MAAkE;CACjG,OAAO,KAAK,KAAK,WAAW,MAAM,KAAM,KAAoB,UAAU;AACxE;;AAGA,SAAgB,gCAEd;CACA,MAAM,QAAQ,SAAS;CASvB,OAAO,EAAE,wBAPsB,eAAe;EAC5C,OAAO,MAAM,KAAK,SACf,QAAQ,YAAY,QAAQ,MAAM,KAAK,uBAAuB,CAAC,CAAC,CAChE,SAAS,YAAY,QAAQ,KAAK,CAAC,CACnC,OAAO,uBAAuB;CACnC,CAES,EAAuB;AAClC"}
|
|
@@ -16,7 +16,7 @@ export declare function getTmpDocFromLocalStorage(): {
|
|
|
16
16
|
} | undefined;
|
|
17
17
|
export declare function removeTmpDocFromLocalStorage(): void;
|
|
18
18
|
/**
|
|
19
|
-
* Handle uploading a temporary
|
|
19
|
+
* Handle uploading a temporary API description.
|
|
20
20
|
*/
|
|
21
21
|
export declare function useUploadTmpDocument(): {
|
|
22
22
|
uploadTempDocument: (document: string, isAgent?: boolean) => Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-upload-tmp-document.d.ts","sourceRoot":"","sources":["../../src/hooks/use-upload-tmp-document.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,sBAAsB,GAC9B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,GACtB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAapB,wBAAgB,yBAAyB;;;cAOxC;AAED,wBAAgB,4BAA4B,SAO3C;AAED;;GAEG;AACH,wBAAgB,oBAAoB;
|
|
1
|
+
{"version":3,"file":"use-upload-tmp-document.d.ts","sourceRoot":"","sources":["../../src/hooks/use-upload-tmp-document.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,sBAAsB,GAC9B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,GACtB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAapB,wBAAgB,yBAAyB;;;cAOxC;AAED,wBAAgB,4BAA4B,SAO3C;AAED;;GAEG;AACH,wBAAgB,oBAAoB;mCAWU,MAAM;;;;;;EAyFnD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState } from "../state/state.js";
|
|
2
|
-
import {
|
|
2
|
+
import { onScopeDispose } from "vue";
|
|
3
3
|
import { coerce, object, string, validate } from "@scalar/validation";
|
|
4
4
|
import { redirectToProxy } from "@scalar/helpers/url/redirect-to-proxy";
|
|
5
5
|
//#region src/hooks/use-upload-tmp-document.ts
|
|
@@ -25,11 +25,13 @@ function removeTmpDocFromLocalStorage() {
|
|
|
25
25
|
localStorage.removeItem(TMP_DOC_LS_KEY);
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
* Handle uploading a temporary
|
|
28
|
+
* Handle uploading a temporary API description.
|
|
29
29
|
*/
|
|
30
30
|
function useUploadTmpDocument() {
|
|
31
31
|
const state = useState();
|
|
32
|
-
const uploadState =
|
|
32
|
+
const { uploadState } = state;
|
|
33
|
+
const controller = new AbortController();
|
|
34
|
+
onScopeDispose(() => controller.abort());
|
|
33
35
|
function createUrl(path) {
|
|
34
36
|
const fullUrl = `${state.baseUrl}${path}`;
|
|
35
37
|
return redirectToProxy(state.platformProxyUrl, fullUrl);
|
|
@@ -39,13 +41,14 @@ function useUploadTmpDocument() {
|
|
|
39
41
|
uploadState.value = { type: "uploading" };
|
|
40
42
|
const response = await fetch(createUrl(`/core/share/upload/apis${isAgent ? "?source=agent" : ""}`), {
|
|
41
43
|
method: "POST",
|
|
44
|
+
signal: controller.signal,
|
|
42
45
|
headers: { "Content-Type": "application/json" },
|
|
43
46
|
body: JSON.stringify({ document })
|
|
44
47
|
});
|
|
45
48
|
if (!response.ok) {
|
|
46
49
|
uploadState.value = {
|
|
47
50
|
type: "error",
|
|
48
|
-
error: "Failed to upload your
|
|
51
|
+
error: "Failed to upload your API description."
|
|
49
52
|
};
|
|
50
53
|
return;
|
|
51
54
|
}
|
|
@@ -64,24 +67,27 @@ function useUploadTmpDocument() {
|
|
|
64
67
|
}
|
|
65
68
|
const uploadData = coerce(uploadResponseSchema, json);
|
|
66
69
|
uploadState.value = { type: "processing" };
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
});
|
|
72
|
-
await state.addDocument({
|
|
73
|
-
namespace: uploadData.namespace,
|
|
74
|
-
slug: uploadData.slug,
|
|
75
|
-
removable: false,
|
|
76
|
-
tmp: true
|
|
77
|
-
});
|
|
78
|
-
if (!embeddingStatusResponse.ok) {
|
|
70
|
+
if (!(await fetch(createUrl(`/vector/registry/embeddings/${uploadData.namespace}/${uploadData.slug}`), {
|
|
71
|
+
method: "GET",
|
|
72
|
+
signal: controller.signal
|
|
73
|
+
})).ok) {
|
|
79
74
|
uploadState.value = {
|
|
80
75
|
type: "error",
|
|
81
76
|
error: "Failed to embed document."
|
|
82
77
|
};
|
|
83
78
|
return;
|
|
84
79
|
}
|
|
80
|
+
await state.addDocument({
|
|
81
|
+
namespace: uploadData.namespace,
|
|
82
|
+
slug: uploadData.slug,
|
|
83
|
+
removable: false,
|
|
84
|
+
tmp: true
|
|
85
|
+
});
|
|
86
|
+
if (controller.signal.aborted) return;
|
|
87
|
+
saveTmpDocumentInLocalStorage({
|
|
88
|
+
namespace: uploadData.namespace,
|
|
89
|
+
slug: uploadData.slug
|
|
90
|
+
});
|
|
85
91
|
uploadState.value = { type: "done" };
|
|
86
92
|
state.uploadedTmpDocumentUrl.value = uploadData.url;
|
|
87
93
|
setTimeout(() => {
|
|
@@ -89,9 +95,10 @@ function useUploadTmpDocument() {
|
|
|
89
95
|
}, SHOW_UPLOAD_SUCCESS_DELAY);
|
|
90
96
|
return uploadData;
|
|
91
97
|
} catch {
|
|
98
|
+
if (controller.signal.aborted) return;
|
|
92
99
|
uploadState.value = {
|
|
93
100
|
type: "error",
|
|
94
|
-
error: "Failed to upload your
|
|
101
|
+
error: "Failed to upload your API description."
|
|
95
102
|
};
|
|
96
103
|
return;
|
|
97
104
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-upload-tmp-document.js","names":[],"sources":["../../src/hooks/use-upload-tmp-document.ts"],"sourcesContent":["import { redirectToProxy } from '@scalar/helpers/url/redirect-to-proxy'\nimport { coerce, object, string, validate } from '@scalar/validation'\nimport {
|
|
1
|
+
{"version":3,"file":"use-upload-tmp-document.js","names":[],"sources":["../../src/hooks/use-upload-tmp-document.ts"],"sourcesContent":["import { redirectToProxy } from '@scalar/helpers/url/redirect-to-proxy'\nimport { coerce, object, string, validate } from '@scalar/validation'\nimport { onScopeDispose } from 'vue'\n\nimport { useState } from '@/state/state'\n\nconst SHOW_UPLOAD_SUCCESS_DELAY = 5_000 // 5 seconds\n\nexport type UploadTmpDocumentState =\n | { type: 'error'; error: unknown }\n | { type: 'uploading' }\n | { type: 'processing' }\n | { type: 'loading' }\n | { type: 'done' }\n\nconst TMP_DOC_LS_KEY = 'scalar-tmp-doc'\n\nfunction saveTmpDocumentInLocalStorage({ namespace, slug }: { namespace: string; slug: string }) {\n localStorage.setItem(TMP_DOC_LS_KEY, JSON.stringify({ namespace, slug }))\n}\n\nconst tmpDocSchema = object({\n namespace: string(),\n slug: string(),\n})\n\nexport function getTmpDocFromLocalStorage() {\n const tmpDoc = localStorage.getItem(TMP_DOC_LS_KEY)\n if (!tmpDoc) {\n return\n }\n\n return coerce(tmpDocSchema, JSON.parse(tmpDoc))\n}\n\nexport function removeTmpDocFromLocalStorage() {\n const tmpDoc = localStorage.getItem(TMP_DOC_LS_KEY)\n if (!tmpDoc) {\n return\n }\n\n localStorage.removeItem(TMP_DOC_LS_KEY)\n}\n\n/**\n * Handle uploading a temporary API description.\n */\nexport function useUploadTmpDocument() {\n const state = useState()\n const { uploadState } = state\n const controller = new AbortController()\n onScopeDispose(() => controller.abort())\n\n function createUrl(path: string) {\n const fullUrl = `${state.baseUrl}${path}`\n return redirectToProxy(state.platformProxyUrl, fullUrl)\n }\n\n async function uploadTempDocument(document: string, isAgent = false) {\n try {\n uploadState.value = {\n type: 'uploading',\n }\n\n const response = await fetch(createUrl(`/core/share/upload/apis${isAgent ? '?source=agent' : ''}`), {\n method: 'POST',\n signal: controller.signal,\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ document }),\n })\n\n if (!response.ok) {\n uploadState.value = {\n type: 'error',\n error: 'Failed to upload your API description.',\n }\n\n return\n }\n\n const json = await response.json()\n\n const uploadResponseSchema = object({ url: string(), namespace: string(), slug: string() })\n\n if (!validate(uploadResponseSchema, json)) {\n uploadState.value = {\n type: 'error',\n error: 'Failed to process document.',\n }\n return\n }\n\n const uploadData = coerce(uploadResponseSchema, json)\n\n uploadState.value = {\n type: 'processing',\n }\n const embeddingStatusResponse = await fetch(\n createUrl(`/vector/registry/embeddings/${uploadData.namespace}/${uploadData.slug}`),\n {\n method: 'GET',\n signal: controller.signal,\n },\n )\n\n if (!embeddingStatusResponse.ok) {\n uploadState.value = {\n type: 'error',\n error: 'Failed to embed document.',\n }\n return\n }\n\n await state.addDocument({\n namespace: uploadData.namespace,\n slug: uploadData.slug,\n removable: false,\n tmp: true,\n })\n\n if (controller.signal.aborted) {\n return\n }\n saveTmpDocumentInLocalStorage({ namespace: uploadData.namespace, slug: uploadData.slug })\n uploadState.value = { type: 'done' }\n state.uploadedTmpDocumentUrl.value = uploadData.url\n\n setTimeout(() => {\n uploadState.value = undefined\n }, SHOW_UPLOAD_SUCCESS_DELAY)\n\n return uploadData\n } catch {\n if (controller.signal.aborted) {\n return\n }\n uploadState.value = { type: 'error', error: 'Failed to upload your API description.' }\n return\n }\n }\n\n return {\n uploadTempDocument,\n uploadState,\n }\n}\n"],"mappings":";;;;;AAMA,IAAM,4BAA4B;AASlC,IAAM,iBAAiB;AAEvB,SAAS,8BAA8B,EAAE,WAAW,QAA6C;CAC/F,aAAa,QAAQ,gBAAgB,KAAK,UAAU;EAAE;EAAW;CAAK,CAAC,CAAC;AAC1E;AAEA,IAAM,eAAe,OAAO;CAC1B,WAAW,OAAO;CAClB,MAAM,OAAO;AACf,CAAC;AAED,SAAgB,4BAA4B;CAC1C,MAAM,SAAS,aAA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A,CAE6B,IAAI;IAC/B,YAAY,QAAQ;KAClB,MAAM;KACN,OAAO;IACT;IACA;GACF;GAEA,MAAM,MAAM,YAAY;IACtB,WAAW,WAAW;IACtB,MAAM,WAAW;IACjB,WAAW;IACX,KAAK;GACP,CAAC;GAED,IAAI,WAAW,OAAO,SACpB;GAEF,8BAA8B;IAAE,WAAW,WAAW;IAAW,MAAM,WAAW;GAAK,CAAC;GACxF,YAAY,QAAQ,EAAE,MAAM,OAAO;GACnC,MAAM,uBAAuB,QAAQ,WAAW;GAEhD,iBAAiB;IACf,YAAY,QAAQ,KAAA;GACtB,GAAG,yBAAyB;GAE5B,OAAO;EACT,QAAQ;GACN,IAAI,WAAW,OAAO,SACpB;GAEF,YAAY,QAAQ;IAAE,MAAM;IAAS,OAAO;GAAyC;GACrF;EACF;CACF;CAEA,OAAO;EACL;EACA;CACF;AACF"}
|
package/dist/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"url": "git+https://github.com/scalar/scalar.git",
|
|
11
11
|
"directory": "packages/agent-chat"
|
|
12
12
|
},
|
|
13
|
-
"version": "0.12.
|
|
13
|
+
"version": "0.12.45",
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=22"
|
|
16
16
|
},
|
|
@@ -80,6 +80,7 @@
|
|
|
80
80
|
"@tailwindcss/vite": "catalog:*",
|
|
81
81
|
"@types/jsdom": "catalog:*",
|
|
82
82
|
"@vitejs/plugin-vue": "catalog:*",
|
|
83
|
+
"@vue/test-utils": "catalog:*",
|
|
83
84
|
"hono": "catalog:*",
|
|
84
85
|
"jsdom": "catalog:*",
|
|
85
86
|
"tailwindcss": "catalog:*",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-documents-to-store.d.ts","sourceRoot":"","sources":["../../src/registry/add-documents-to-store.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"add-documents-to-store.d.ts","sourceRoot":"","sources":["../../src/registry/add-documents-to-store.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAA;AAE5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAGpE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAE9B,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAI/D,eAAO,MAAM,YAAY;eAYV,MAAM;UACX,MAAM;oBACI,cAAc;qBACb,MAAM,MAAM;uBACV,GAAG,CAAC,WAAW,EAAE,CAAC;iBACxB,MAAM;YACX,OAAO,CAAC,yBAAyB,CAAC;SACrC,GAAG;gBACI,OAAO;;;;;;;;;;;;;;;;;;;;;gHA6DtB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-documents-to-store.js","names":[],"sources":["../../src/registry/add-documents-to-store.ts"],"sourcesContent":["import { bundle } from '@scalar/json-magic/bundle'\nimport { fetchUrls } from '@scalar/json-magic/bundle/plugins/browser'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport type { ApiReferenceConfiguration } from '@scalar/types/api-reference'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport { openApiDocument } from '@scalar/workspace-store/plugins/bundler'\nimport { n } from 'neverpanic'\nimport type { Ref } from 'vue'\n\nimport type { Api } from '@/api'\nimport { createError } from '@/entities'\nimport type { ApiMetadata } from '@/entities/registry/document'\nimport { restoreAuthSecretsFromStorage } from '@/helpers'\nimport { createDocumentName } from '@/registry/create-document-name'\n\nexport const loadDocument = n.safeFn(\n async ({\n namespace,\n slug,\n workspaceStore,\n registryDocuments,\n getAccessToken,\n registryUrl,\n config,\n api,\n removable,\n }: {\n namespace: string\n slug: string\n workspaceStore: WorkspaceStore\n getAccessToken?: () => string\n registryDocuments: Ref<ApiMetadata[]>\n registryUrl: string\n config: Partial<ApiReferenceConfiguration>\n api: Api\n removable?: boolean\n }) => {\n const getDocumentResult = await api.getDocument({\n namespace,\n slug,\n })\n\n if (!getDocumentResult.success) {\n return getDocumentResult\n }\n\n registryDocuments.value.push({ ...getDocumentResult.data, removable })\n\n const url = new URL(`/@${namespace}/apis/${slug}/latest`, registryUrl)\n\n const headers: {\n headers: HeadersInit\n domains: string[]\n }[] = []\n\n const token = getAccessToken?.()\n\n if (token) {\n headers.push({\n domains: [new URL(registryUrl).host],\n headers: {\n 'x-scalar-auth': token,\n },\n })\n }\n\n const document: OpenAPIV3_1.Document = await bundle(url.toString(), {\n plugins: [\n openApiDocument(),\n fetchUrls({\n headers,\n }),\n ],\n treeShake: false,\n })\n\n const documentName = createDocumentName(namespace, slug)\n\n await workspaceStore.addDocument(\n {\n name: documentName,\n document,\n },\n config,\n )\n\n workspaceStore.update('x-scalar-active-document', documentName)\n\n restoreAuthSecretsFromStorage({ documentName, workspaceStore })\n\n return {\n success: true,\n data: getDocumentResult.data,\n }\n },\n (originalError) => createError('UNABLE_TO_LOAD_DOCUMENT', originalError),\n)\n"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"add-documents-to-store.js","names":[],"sources":["../../src/registry/add-documents-to-store.ts"],"sourcesContent":["import { bundle } from '@scalar/json-magic/bundle'\nimport { fetchUrls } from '@scalar/json-magic/bundle/plugins/browser'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport type { ApiReferenceConfiguration } from '@scalar/types/api-reference'\nimport type { AsyncApiDocument } from '@scalar/types/asyncapi/3.1'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport { openApiDocument } from '@scalar/workspace-store/plugins/bundler'\nimport { n } from 'neverpanic'\nimport type { Ref } from 'vue'\n\nimport type { Api } from '@/api'\nimport { createError } from '@/entities'\nimport type { ApiMetadata } from '@/entities/registry/document'\nimport { restoreAuthSecretsFromStorage } from '@/helpers'\nimport { createDocumentName } from '@/registry/create-document-name'\n\nexport const loadDocument = n.safeFn(\n async ({\n namespace,\n slug,\n workspaceStore,\n registryDocuments,\n getAccessToken,\n registryUrl,\n config,\n api,\n removable,\n }: {\n namespace: string\n slug: string\n workspaceStore: WorkspaceStore\n getAccessToken?: () => string\n registryDocuments: Ref<ApiMetadata[]>\n registryUrl: string\n config: Partial<ApiReferenceConfiguration>\n api: Api\n removable?: boolean\n }) => {\n const getDocumentResult = await api.getDocument({\n namespace,\n slug,\n })\n\n if (!getDocumentResult.success) {\n return getDocumentResult\n }\n\n registryDocuments.value.push({ ...getDocumentResult.data, removable })\n\n const url = new URL(`/@${namespace}/apis/${slug}/latest`, registryUrl)\n\n const headers: {\n headers: HeadersInit\n domains: string[]\n }[] = []\n\n const token = getAccessToken?.()\n\n if (token) {\n headers.push({\n domains: [new URL(registryUrl).host],\n headers: {\n 'x-scalar-auth': token,\n },\n })\n }\n\n const document: OpenAPIV3_1.Document | AsyncApiDocument = await bundle(url.toString(), {\n plugins: [\n openApiDocument(),\n fetchUrls({\n headers,\n }),\n ],\n treeShake: false,\n })\n\n const documentName = createDocumentName(namespace, slug)\n\n await workspaceStore.addDocument(\n {\n name: documentName,\n document,\n },\n config,\n )\n\n workspaceStore.update('x-scalar-active-document', documentName)\n\n restoreAuthSecretsFromStorage({ documentName, workspaceStore })\n\n return {\n success: true,\n data: getDocumentResult.data,\n }\n },\n (originalError) => createError('UNABLE_TO_LOAD_DOCUMENT', originalError),\n)\n"],"mappings":";;;;;;;;AAgBA,IAAa,eAAe,EAAE,OAC5B,OAAO,EACL,WACA,MACA,gBACA,mBACA,gBACA,aACA,QACA,KACA,gBAWI;CACJ,MAAM,oBAAoB,MAAM,IAAI,YAAY;EAC9C;EACA;CACF,CAAC;CAED,IAAI,CAAC,kBAAkB,SACrB,OAAO;CAGT,kBAAkB,MAAM,KAAK;EAAE,GAAG,kBAAkB;EAAM;CAAU,CAAC;CAErE,MAAM,MAAM,IAAI,IAAI,KAAK,UAAU,QAAQ,KAAK,UAAU,WAAW;CAErE,MAAM,UAGA,CAAC;CAEP,MAAM,QAAQ,iBAAiB;CAE/B,IAAI,OACF,QAAQ,KAAK;EACX,SAAS,CAAC,IAAI,IAAI,WAAW,CAAC,CAAC,IAAI;EACnC,SAAS,EACP,iBAAiB,MACnB;CACF,CAAC;CAGH,MAAM,WAAoD,MAAM,OAAO,IAAI,SAAS,GAAG;EACrF,SAAS,CACP,gBAAgB,GAChB,UAAU,EACR,QACF,CAAC,CACH;EACA,WAAW;CACb,CAAC;CAED,MAAM,eAAe,mBAAmB,WAAW,IAAI;CAEvD,MAAM,eAAe,YACnB;EACE,MAAM;EACN;CACF,GACA,MACF;CAEA,eAAe,OAAO,4BAA4B,YAAY;CAE9D,8BAA8B;EAAE;EAAc;CAAe,CAAC;CAE9D,OAAO;EACL,SAAS;EACT,MAAM,kBAAkB;CAC1B;AACF,IACC,kBAAkB,YAAY,2BAA2B,aAAa,CACzE"}
|
package/dist/state/state.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type { ASK_FOR_AUTHENTICATION_TOOL_NAME, AskForAuthenticationInput } from
|
|
|
11
11
|
import { EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME, type ExecuteClientSideRequestToolInput, type ExecuteClientSideRequestToolOutput } from '../entities/tools/execute-request.js';
|
|
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
|
+
import { type UploadTmpDocumentState } from '../hooks/use-upload-tmp-document.js';
|
|
14
15
|
import type { ChatMode } from '../types';
|
|
15
16
|
export type RegistryDocument = {
|
|
16
17
|
namespace: string;
|
|
@@ -75,12 +76,14 @@ type State = {
|
|
|
75
76
|
getAccessToken?: () => string;
|
|
76
77
|
getAgentKey?: () => string;
|
|
77
78
|
api: Api;
|
|
79
|
+
uploadState: Ref<UploadTmpDocumentState | undefined>;
|
|
78
80
|
uploadedTmpDocumentUrl: Ref<string | undefined>;
|
|
79
81
|
curatedDocuments: Ref<ApiMetadata[]>;
|
|
80
82
|
getActiveDocumentJson?: () => string;
|
|
83
|
+
getActiveDocumentContext?: () => string | undefined;
|
|
81
84
|
hideAddApi?: boolean;
|
|
82
85
|
};
|
|
83
|
-
export declare function createState({ initialRegistryDocuments, registryUrl, dashboardUrl, platformProxyUrl, baseUrl, mode, isLoggedIn, getAccessToken, getAgentKey, getActiveDocumentJson, prefilledMessageRef, hideAddApi, }: {
|
|
86
|
+
export declare function createState({ initialRegistryDocuments, registryUrl, dashboardUrl, platformProxyUrl, baseUrl, mode, isLoggedIn, getAccessToken, getAgentKey, getActiveDocumentJson, getActiveDocumentContext, prefilledMessageRef, hideAddApi, }: {
|
|
84
87
|
initialRegistryDocuments: {
|
|
85
88
|
namespace: string;
|
|
86
89
|
slug: string;
|
|
@@ -94,6 +97,7 @@ export declare function createState({ initialRegistryDocuments, registryUrl, das
|
|
|
94
97
|
getAccessToken?: () => string;
|
|
95
98
|
getAgentKey?: () => string;
|
|
96
99
|
getActiveDocumentJson?: () => string;
|
|
100
|
+
getActiveDocumentContext?: () => string | undefined;
|
|
97
101
|
prefilledMessageRef?: Ref<string>;
|
|
98
102
|
hideAddApi?: boolean;
|
|
99
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,KAAK,UAAU,EAAY,MAAM,0BAA0B,CAAA;AAEpE,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAA;AAG/E,OAAO,EAAE,KAAK,cAAc,EA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,CAAC,EAC1B,wBAAwB,EACxB,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,OAAO,EACP,IAAI,EACJ,UAAU,EACV,cAAc,EACd,WAAW,EACX,qBAAqB,EACrB,wBAAwB,EACxB,mBAAmB,EACnB,UAAU,GACX,EAAE;IACD,wBAAwB,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IAC/D,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,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,wBAAwB,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAA;IACnD,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
|
@@ -17,6 +17,7 @@ import { apiReferenceConfigurationSchema } from "@scalar/schemas/api-reference";
|
|
|
17
17
|
import { coerce } from "@scalar/validation";
|
|
18
18
|
import { createWorkspaceStore } from "@scalar/workspace-store/client";
|
|
19
19
|
import { createWorkspaceEventBus } from "@scalar/workspace-store/events";
|
|
20
|
+
import { isAsyncApiDocument } from "@scalar/workspace-store/schemas/type-guards";
|
|
20
21
|
import { DefaultChatTransport, lastAssistantMessageIsCompleteWithToolCalls } from "ai";
|
|
21
22
|
import { n } from "neverpanic";
|
|
22
23
|
//#region src/state/state.ts
|
|
@@ -35,6 +36,15 @@ function createChat({ registryDocuments, workspaceStore, baseUrl, proxyUrl, getA
|
|
|
35
36
|
}),
|
|
36
37
|
async onToolCall({ toolCall }) {
|
|
37
38
|
if (toolCall.dynamic) return;
|
|
39
|
+
if ((toolCall.toolName === "execute-request" || toolCall.toolName === "ask-for-authentication") && isAsyncApiDocument(workspaceStore.workspace.documents[toolCall.input.documentName])) {
|
|
40
|
+
chat.addToolOutput({
|
|
41
|
+
tool: toolCall.toolName,
|
|
42
|
+
toolCallId: toolCall.toolCallId,
|
|
43
|
+
state: "output-error",
|
|
44
|
+
errorText: "Live AsyncAPI messaging and authentication are not supported in Ask AI. Ask for an explanation or code example instead."
|
|
45
|
+
});
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
38
48
|
if (toolCall.toolName === "execute-request" && toolCall.input.method.toLowerCase() === "get") await executeRequestTool({
|
|
39
49
|
documentSettings: createDocumentSettings(workspaceStore),
|
|
40
50
|
input: toolCall.input,
|
|
@@ -46,7 +56,7 @@ function createChat({ registryDocuments, workspaceStore, baseUrl, proxyUrl, getA
|
|
|
46
56
|
});
|
|
47
57
|
return chat;
|
|
48
58
|
}
|
|
49
|
-
function createState({ initialRegistryDocuments, registryUrl, dashboardUrl, platformProxyUrl, baseUrl, mode, isLoggedIn, getAccessToken, getAgentKey, getActiveDocumentJson, prefilledMessageRef, hideAddApi }) {
|
|
59
|
+
function createState({ initialRegistryDocuments, registryUrl, dashboardUrl, platformProxyUrl, baseUrl, mode, isLoggedIn, getAccessToken, getAgentKey, getActiveDocumentJson, getActiveDocumentContext, prefilledMessageRef, hideAddApi }) {
|
|
50
60
|
const prompt = ref(prefilledMessageRef?.value ?? "");
|
|
51
61
|
const registryDocuments = ref([]);
|
|
52
62
|
const pendingDocuments = reactive({});
|
|
@@ -78,11 +88,8 @@ function createState({ initialRegistryDocuments, registryUrl, dashboardUrl, plat
|
|
|
78
88
|
watch(() => chat.status, () => {
|
|
79
89
|
if (chat.status === "streaming") prompt.value = "";
|
|
80
90
|
});
|
|
81
|
-
if (prefilledMessageRef) watch(prefilledMessageRef,
|
|
82
|
-
if (val)
|
|
83
|
-
prompt.value = val;
|
|
84
|
-
if (terms.accepted.value) await chat.sendMessage({ text: prompt.value });
|
|
85
|
-
}
|
|
91
|
+
if (prefilledMessageRef) watch(prefilledMessageRef, (val) => {
|
|
92
|
+
if (val) prompt.value = val;
|
|
86
93
|
});
|
|
87
94
|
const settingsModal = useModal();
|
|
88
95
|
async function addDocument({ namespace, slug, removable = true, tmp = false }) {
|
|
@@ -180,9 +187,11 @@ function createState({ initialRegistryDocuments, registryUrl, dashboardUrl, plat
|
|
|
180
187
|
getAccessToken,
|
|
181
188
|
getAgentKey,
|
|
182
189
|
api,
|
|
190
|
+
uploadState: ref(),
|
|
183
191
|
uploadedTmpDocumentUrl,
|
|
184
192
|
curatedDocuments,
|
|
185
193
|
getActiveDocumentJson,
|
|
194
|
+
getActiveDocumentContext,
|
|
186
195
|
hideAddApi
|
|
187
196
|
};
|
|
188
197
|
}
|
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 { 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 { executeRequestTool } from '@/client-tools/execute-request'\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 { createDocumentSettings } from '@/helpers'\nimport { useTermsAndConditions } from '@/hooks/use-term-and-conditions'\nimport { 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 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 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 proxyUrl,\n getAccessToken,\n getAgentKey,\n}: {\n registryDocuments: Ref<ApiMetadata[]>\n workspaceStore: WorkspaceStore\n baseUrl: string\n proxyUrl: ComputedRef<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 async onToolCall({ toolCall }): Promise<any> {\n if (toolCall.dynamic) {\n return\n }\n\n if (\n toolCall.toolName === EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME &&\n toolCall.input.method.toLowerCase() === 'get'\n ) {\n await executeRequestTool({\n documentSettings: createDocumentSettings(workspaceStore),\n input: toolCall.input,\n toolCallId: toolCall.toolCallId,\n chat,\n proxyUrl: proxyUrl.value,\n })\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 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 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 proxyUrl,\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, async (val) => {\n if (val) {\n prompt.value = val\n if (terms.accepted.value) {\n await chat.sendMessage({ text: prompt.value })\n }\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 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 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;AAiC5B,SAAS,WAAW,EAClB,mBACA,gBACA,SACA,UACA,gBACA,eAQC;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;EAC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AAS;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;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;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 } 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 { executeRequestTool } from '@/client-tools/execute-request'\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 { createDocumentSettings } from '@/helpers'\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 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 proxyUrl,\n getAccessToken,\n getAgentKey,\n}: {\n registryDocuments: Ref<ApiMetadata[]>\n workspaceStore: WorkspaceStore\n baseUrl: string\n proxyUrl: ComputedRef<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 async onToolCall({ toolCall }): Promise<any> {\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 if (\n toolCall.toolName === EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME &&\n toolCall.input.method.toLowerCase() === 'get'\n ) {\n await executeRequestTool({\n documentSettings: createDocumentSettings(workspaceStore),\n input: toolCall.input,\n toolCallId: toolCall.toolCallId,\n chat,\n proxyUrl: proxyUrl.value,\n })\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 proxyUrl,\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 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":";;;;;;;;;;;;;;;;;;;;;;;AAqEA,IAAa,eAAoC,OAAO,cAAc;AAEtE,IAAM,EAAE,UAAU,UAAU;AAmC5B,SAAS,WAAW,EAClB,mBACA,gBACA,SACA,UACA,gBACA,eAQC;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,MAAM,WAAW,EAAE,YAA0B;GAC3C,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;GAEA,IACE,SAAS,aAAA,qBACT,SAAS,MAAM,OAAO,YAAY,MAAM,OAExC,MAAM,mBAAmB;IACvB,kBAAkB,uBAAuB,cAAc;IACvD,OAAO,SAAS;IAChB,YAAY,SAAS;IACrB;IACA,UAAU,SAAS;GACrB,CAAC;EAEL;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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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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.test.d.ts","sourceRoot":"","sources":["../../src/state/state.test.ts"],"names":[],"mappings":""}
|