@scalar/agent-chat 0.1.2 → 0.2.0
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 → App.vue.d.ts} +2 -2
- package/App.vue.d.ts.map +1 -0
- package/{dist/App.vue.js → App.vue.js} +9 -3
- package/App.vue.js.map +1 -0
- package/{dist/Chat.vue.js → Chat.vue.js} +3 -3
- package/Chat.vue.js.map +1 -0
- package/components/ApprovalSection.vue.d.ts +9 -0
- package/components/ApprovalSection.vue.d.ts.map +1 -0
- package/components/ApprovalSection.vue.js +8 -0
- package/components/ApprovalSection.vue.js.map +1 -0
- package/components/ApprovalSection.vue2.js +47 -0
- package/components/ApprovalSection.vue2.js.map +1 -0
- package/components/AutosendPaused.vue.d.ts +3 -0
- package/components/AutosendPaused.vue.d.ts.map +1 -0
- package/components/AutosendPaused.vue.js +15 -0
- package/components/AutosendPaused.vue.js.map +1 -0
- package/{dist/components → components}/ContextItem.vue.d.ts.map +1 -1
- package/{dist/components → components}/ContextItem.vue.js +1 -1
- package/{dist/components → components}/ContextItem.vue2.js +1 -1
- package/components/ContextItem.vue2.js.map +1 -0
- package/components/ErrorMessage.vue.d.ts +6 -0
- package/components/ErrorMessage.vue.d.ts.map +1 -0
- package/components/ErrorMessage.vue.js +8 -0
- package/components/ErrorMessage.vue.js.map +1 -0
- package/components/ErrorMessage.vue2.js +28 -0
- package/components/ErrorMessage.vue2.js.map +1 -0
- package/{dist/components → components}/LoadingMiniOpenAPIDoc.vue.d.ts.map +1 -1
- package/components/LoadingMiniOpenAPIDoc.vue.js +16 -0
- package/components/LoadingMiniOpenAPIDoc.vue.js.map +1 -0
- package/components/LoadingOpenAPISpecsSummary.vue.d.ts +3 -0
- package/components/LoadingOpenAPISpecsSummary.vue.d.ts.map +1 -0
- package/components/LoadingOpenAPISpecsSummary.vue.js +16 -0
- package/components/LoadingOpenAPISpecsSummary.vue.js.map +1 -0
- package/components/RequestApproved.vue.d.ts +3 -0
- package/components/RequestApproved.vue.d.ts.map +1 -0
- package/components/RequestApproved.vue.js +15 -0
- package/components/RequestApproved.vue.js.map +1 -0
- package/components/RequestFailed.vue.d.ts +3 -0
- package/components/RequestFailed.vue.d.ts.map +1 -0
- package/components/RequestFailed.vue.js +26 -0
- package/components/RequestFailed.vue.js.map +1 -0
- package/components/RequestPreview.vue.d.ts +10 -0
- package/components/RequestPreview.vue.d.ts.map +1 -0
- package/components/RequestPreview.vue.js +9 -0
- package/components/RequestPreview.vue.js.map +1 -0
- package/components/RequestPreview.vue2.js +150 -0
- package/components/RequestPreview.vue2.js.map +1 -0
- package/components/RequestRejected.vue.d.ts +3 -0
- package/components/RequestRejected.vue.d.ts.map +1 -0
- package/components/RequestRejected.vue.js +24 -0
- package/components/RequestRejected.vue.js.map +1 -0
- package/components/RequestSuccess.vue.d.ts +3 -0
- package/components/RequestSuccess.vue.d.ts.map +1 -0
- package/components/RequestSuccess.vue.js +15 -0
- package/components/RequestSuccess.vue.js.map +1 -0
- package/components/ResponseBody/ResponseBody.vue.d.ts +15 -0
- package/components/ResponseBody/ResponseBody.vue.d.ts.map +1 -0
- package/components/ResponseBody/ResponseBody.vue.js +45 -0
- package/components/ResponseBody/ResponseBody.vue.js.map +1 -0
- package/components/ResponseBody/ResponseBody.vue2.js +5 -0
- package/components/ResponseBody/ResponseBody.vue2.js.map +1 -0
- package/components/ResponseBody/ResponseBodyInfo.vue.d.ts +13 -0
- package/components/ResponseBody/ResponseBodyInfo.vue.d.ts.map +1 -0
- package/components/ResponseBody/ResponseBodyInfo.vue.js +17 -0
- package/components/ResponseBody/ResponseBodyInfo.vue.js.map +1 -0
- package/components/ResponseBody/ResponseBodyPreview.vue.d.ts +10 -0
- package/components/ResponseBody/ResponseBodyPreview.vue.d.ts.map +1 -0
- package/components/ResponseBody/ResponseBodyPreview.vue.js +8 -0
- package/components/ResponseBody/ResponseBodyPreview.vue.js.map +1 -0
- package/components/ResponseBody/ResponseBodyPreview.vue2.js +73 -0
- package/components/ResponseBody/ResponseBodyPreview.vue2.js.map +1 -0
- package/components/ResponseBody/ResponseBodyRaw.vue.d.ts +7 -0
- package/components/ResponseBody/ResponseBodyRaw.vue.d.ts.map +1 -0
- package/components/ResponseBody/ResponseBodyRaw.vue.js +23 -0
- package/components/ResponseBody/ResponseBodyRaw.vue.js.map +1 -0
- package/components/ResponseBody/ResponseBodyRaw.vue2.js +5 -0
- package/components/ResponseBody/ResponseBodyRaw.vue2.js.map +1 -0
- package/components/ResponseBody/ResponseBodyToggle.vue.d.ts +10 -0
- package/components/ResponseBody/ResponseBodyToggle.vue.d.ts.map +1 -0
- package/components/ResponseBody/ResponseBodyToggle.vue.js +30 -0
- package/components/ResponseBody/ResponseBodyToggle.vue.js.map +1 -0
- package/components/ResponseBody/ResponseBodyToggle.vue2.js +5 -0
- package/components/ResponseBody/ResponseBodyToggle.vue2.js.map +1 -0
- package/components/ResponseBody/helpers/media-types.d.ts +15 -0
- package/components/ResponseBody/helpers/media-types.d.ts.map +1 -0
- package/components/ResponseBody/helpers/media-types.js +134 -0
- package/components/ResponseBody/helpers/media-types.js.map +1 -0
- package/components/ResponseBody/helpers/process-response-body.d.ts +10 -0
- package/components/ResponseBody/helpers/process-response-body.d.ts.map +1 -0
- package/components/ResponseBody/helpers/process-response-body.js +63 -0
- package/components/ResponseBody/helpers/process-response-body.js.map +1 -0
- package/components/SearchPopover.vue.d.ts +13 -0
- package/components/SearchPopover.vue.d.ts.map +1 -0
- package/components/SearchPopover.vue.js +8 -0
- package/components/SearchPopover.vue.js.map +1 -0
- package/components/SearchPopover.vue2.js +78 -0
- package/components/SearchPopover.vue2.js.map +1 -0
- package/{dist/components → components}/SendingRequest.vue.d.ts.map +1 -1
- package/{dist/components → components}/SendingRequest.vue.js +1 -1
- package/{dist/components → components}/SendingRequest.vue.js.map +1 -1
- package/{dist/components → components}/Suggestion.vue.d.ts.map +1 -1
- package/{dist/components → components}/Suggestion.vue.js +1 -1
- package/{dist/components → components}/Suggestion.vue2.js +1 -1
- package/{dist/components → components}/Suggestion.vue2.js.map +1 -1
- package/{dist/components → components}/TestRequestButton.vue2.js +1 -1
- package/{dist/components → components}/TestRequestButton.vue2.js.map +1 -1
- package/helpers.d.ts +418 -0
- package/helpers.d.ts.map +1 -0
- package/helpers.js +201 -0
- package/helpers.js.map +1 -0
- package/hooks/useChatApprovals.d.ts +24 -0
- package/hooks/useChatApprovals.d.ts.map +1 -0
- package/hooks/useChatApprovals.js +25 -0
- package/hooks/useChatApprovals.js.map +1 -0
- package/{dist/hooks → hooks}/useChatOperationBlocks.js +1 -1
- package/hooks/useSearch.d.ts +26 -0
- package/hooks/useSearch.d.ts.map +1 -0
- package/hooks/useSearch.js +36 -0
- package/hooks/useSearch.js.map +1 -0
- package/package.json +3 -36
- package/registry/add-documents-to-store.d.ts +21 -0
- package/registry/add-documents-to-store.d.ts.map +1 -0
- package/registry/add-documents-to-store.js +42 -0
- package/registry/add-documents-to-store.js.map +1 -0
- package/{dist/state → state}/state.d.ts +29 -14
- package/state/state.d.ts.map +1 -0
- package/{dist/state → state}/state.js +45 -40
- package/state/state.js.map +1 -0
- package/{dist/style.css → style.css} +686 -234
- package/{dist/views → views}/Chat/Chat.vue.d.ts.map +1 -1
- package/{dist/views → views}/Chat/Chat.vue.js +1 -1
- package/{dist/views → views}/Chat/Chat.vue2.js +17 -5
- package/views/Chat/Chat.vue2.js.map +1 -0
- package/{dist/views → views}/Chat/Messages/ExecuteRequestTool.vue.d.ts.map +1 -1
- package/{dist/views → views}/Chat/Messages/ExecuteRequestTool.vue.js +1 -1
- package/views/Chat/Messages/ExecuteRequestTool.vue2.js +39 -0
- package/views/Chat/Messages/ExecuteRequestTool.vue2.js.map +1 -0
- package/{dist/views → views}/Chat/Messages/GetMiniOpenAPIDocTool.vue.d.ts.map +1 -1
- package/{dist/views → views}/Chat/Messages/GetMiniOpenAPIDocTool.vue.js +1 -1
- package/{dist/views → views}/Chat/Messages/GetMiniOpenAPIDocTool.vue2.js +2 -3
- package/views/Chat/Messages/GetMiniOpenAPIDocTool.vue2.js.map +1 -0
- package/views/Chat/Messages/GetOpenAPISpecsSummary.vue.d.ts +11 -0
- package/views/Chat/Messages/GetOpenAPISpecsSummary.vue.d.ts.map +1 -0
- package/views/Chat/Messages/GetOpenAPISpecsSummary.vue.js +32 -0
- package/views/Chat/Messages/GetOpenAPISpecsSummary.vue.js.map +1 -0
- package/views/Chat/Messages/GetOpenAPISpecsSummary.vue2.js +5 -0
- package/views/Chat/Messages/GetOpenAPISpecsSummary.vue2.js.map +1 -0
- package/{dist/views → views}/Chat/Messages/Text.vue.js +1 -1
- package/{dist/views → views}/Chat/Messages/Text.vue.js.map +1 -1
- package/views/Layout.vue.d.ts.map +1 -0
- package/{dist/views → views}/Layout.vue.js +1 -1
- package/{dist/views → views}/Layout.vue2.js +0 -4
- package/views/Layout.vue2.js.map +1 -0
- package/{dist/views → views}/PromptForm.vue.d.ts.map +1 -1
- package/{dist/views → views}/PromptForm.vue.js +1 -1
- package/views/PromptForm.vue2.js +182 -0
- package/views/PromptForm.vue2.js.map +1 -0
- package/{dist/views → views/Settings}/Auth.vue.d.ts +1 -0
- package/views/Settings/Auth.vue.d.ts.map +1 -0
- package/{dist/views → views/Settings}/Auth.vue.js +21 -26
- package/views/Settings/Auth.vue.js.map +1 -0
- package/views/Settings/DocSettings.vue.d.ts +8 -0
- package/views/Settings/DocSettings.vue.d.ts.map +1 -0
- package/views/Settings/DocSettings.vue.js +8 -0
- package/views/Settings/DocSettings.vue.js.map +1 -0
- package/views/Settings/DocSettings.vue2.js +50 -0
- package/views/Settings/DocSettings.vue2.js.map +1 -0
- package/views/Settings/Settings.vue.d.ts.map +1 -0
- package/{dist/views → views/Settings}/Settings.vue.js +2 -2
- package/views/Settings/Settings.vue2.js +78 -0
- package/views/Settings/Settings.vue2.js.map +1 -0
- package/views/Start.vue.d.ts.map +1 -0
- package/{dist/views → views}/Start.vue.js +1 -1
- package/{dist/views → views}/Start.vue2.js +0 -1
- package/views/Start.vue2.js.map +1 -0
- package/dist/App.vue.d.ts.map +0 -1
- package/dist/App.vue.js.map +0 -1
- package/dist/Chat.vue.js.map +0 -1
- package/dist/components/ContextItem.vue2.js.map +0 -1
- package/dist/components/LoadingMiniOpenAPIDoc.vue.js +0 -32
- package/dist/components/LoadingMiniOpenAPIDoc.vue.js.map +0 -1
- package/dist/helpers.d.ts +0 -39
- package/dist/helpers.d.ts.map +0 -1
- package/dist/helpers.js +0 -111
- package/dist/helpers.js.map +0 -1
- package/dist/hooks/useActiveServer.d.ts +0 -2
- package/dist/hooks/useActiveServer.d.ts.map +0 -1
- package/dist/hooks/useActiveServer.js +0 -20
- package/dist/hooks/useActiveServer.js.map +0 -1
- package/dist/hooks/useSecuritySchemes.d.ts +0 -2
- package/dist/hooks/useSecuritySchemes.d.ts.map +0 -1
- package/dist/hooks/useSecuritySchemes.js +0 -29
- package/dist/hooks/useSecuritySchemes.js.map +0 -1
- package/dist/node_modules/.pnpm/zod@4.1.11/node_modules/zod/v4/core/api.js +0 -11
- package/dist/node_modules/.pnpm/zod@4.1.11/node_modules/zod/v4/core/api.js.map +0 -1
- package/dist/node_modules/.pnpm/zod@4.1.11/node_modules/zod/v4/core/core.js +0 -58
- package/dist/node_modules/.pnpm/zod@4.1.11/node_modules/zod/v4/core/core.js.map +0 -1
- package/dist/node_modules/.pnpm/zod@4.1.11/node_modules/zod/v4/core/errors.js +0 -25
- package/dist/node_modules/.pnpm/zod@4.1.11/node_modules/zod/v4/core/errors.js.map +0 -1
- package/dist/node_modules/.pnpm/zod@4.1.11/node_modules/zod/v4/core/parse.js +0 -64
- package/dist/node_modules/.pnpm/zod@4.1.11/node_modules/zod/v4/core/parse.js.map +0 -1
- package/dist/node_modules/.pnpm/zod@4.1.11/node_modules/zod/v4/core/regexes.js +0 -8
- package/dist/node_modules/.pnpm/zod@4.1.11/node_modules/zod/v4/core/regexes.js.map +0 -1
- package/dist/node_modules/.pnpm/zod@4.1.11/node_modules/zod/v4/core/schemas.js +0 -181
- package/dist/node_modules/.pnpm/zod@4.1.11/node_modules/zod/v4/core/schemas.js.map +0 -1
- package/dist/node_modules/.pnpm/zod@4.1.11/node_modules/zod/v4/core/util.js +0 -61
- package/dist/node_modules/.pnpm/zod@4.1.11/node_modules/zod/v4/core/util.js.map +0 -1
- package/dist/node_modules/.pnpm/zod@4.1.11/node_modules/zod/v4/core/versions.js +0 -9
- package/dist/node_modules/.pnpm/zod@4.1.11/node_modules/zod/v4/core/versions.js.map +0 -1
- package/dist/node_modules/.pnpm/zod@4.1.11/node_modules/zod/v4/mini/schemas.js +0 -60
- package/dist/node_modules/.pnpm/zod@4.1.11/node_modules/zod/v4/mini/schemas.js.map +0 -1
- package/dist/package.json +0 -63
- package/dist/registry/get-document.d.ts +0 -4
- package/dist/registry/get-document.d.ts.map +0 -1
- package/dist/registry/get-document.js +0 -23
- package/dist/registry/get-document.js.map +0 -1
- package/dist/state/state.d.ts.map +0 -1
- package/dist/state/state.js.map +0 -1
- package/dist/views/Auth.vue.d.ts.map +0 -1
- package/dist/views/Auth.vue.js.map +0 -1
- package/dist/views/Chat/Chat.vue2.js.map +0 -1
- package/dist/views/Chat/Messages/ExecuteRequestTool.vue2.js +0 -62
- package/dist/views/Chat/Messages/ExecuteRequestTool.vue2.js.map +0 -1
- package/dist/views/Chat/Messages/GetMiniOpenAPIDocTool.vue2.js.map +0 -1
- package/dist/views/Layout.vue.d.ts.map +0 -1
- package/dist/views/Layout.vue2.js.map +0 -1
- package/dist/views/PromptForm.vue2.js +0 -125
- package/dist/views/PromptForm.vue2.js.map +0 -1
- package/dist/views/Settings.vue.d.ts.map +0 -1
- package/dist/views/Settings.vue2.js +0 -81
- package/dist/views/Settings.vue2.js.map +0 -1
- package/dist/views/Start.vue.d.ts.map +0 -1
- package/dist/views/Start.vue2.js.map +0 -1
- /package/{dist/App.vue2.js → App.vue2.js} +0 -0
- /package/{dist/App.vue2.js.map → App.vue2.js.map} +0 -0
- /package/{dist/Chat.vue.d.ts → Chat.vue.d.ts} +0 -0
- /package/{dist/Chat.vue.d.ts.map → Chat.vue.d.ts.map} +0 -0
- /package/{dist/Chat.vue2.js → Chat.vue2.js} +0 -0
- /package/{dist/Chat.vue2.js.map → Chat.vue2.js.map} +0 -0
- /package/{dist/_virtual → _virtual}/_plugin-vue_export-helper.js +0 -0
- /package/{dist/_virtual → _virtual}/_plugin-vue_export-helper.js.map +0 -0
- /package/{dist/components → components}/ContextItem.vue.d.ts +0 -0
- /package/{dist/components → components}/ContextItem.vue.js.map +0 -0
- /package/{dist/components → components}/Endpoint.vue.d.ts +0 -0
- /package/{dist/components → components}/Endpoint.vue.d.ts.map +0 -0
- /package/{dist/components → components}/Endpoint.vue.js +0 -0
- /package/{dist/components → components}/Endpoint.vue.js.map +0 -0
- /package/{dist/components → components}/Endpoint.vue2.js +0 -0
- /package/{dist/components → components}/Endpoint.vue2.js.map +0 -0
- /package/{dist/components → components}/LoadingMiniOpenAPIDoc.vue.d.ts +0 -0
- /package/{dist/components → components}/Logo.vue.d.ts +0 -0
- /package/{dist/components → components}/Logo.vue.d.ts.map +0 -0
- /package/{dist/components → components}/Logo.vue.js +0 -0
- /package/{dist/components → components}/Logo.vue.js.map +0 -0
- /package/{dist/components → components}/SendingRequest.vue.d.ts +0 -0
- /package/{dist/components → components}/Suggestion.vue.d.ts +0 -0
- /package/{dist/components → components}/Suggestion.vue.js.map +0 -0
- /package/{dist/components → components}/TestRequestButton.vue.d.ts +0 -0
- /package/{dist/components → components}/TestRequestButton.vue.d.ts.map +0 -0
- /package/{dist/components → components}/TestRequestButton.vue.js +0 -0
- /package/{dist/components → components}/TestRequestButton.vue.js.map +0 -0
- /package/{dist/hooks → hooks}/useChatOperationBlocks.d.ts +0 -0
- /package/{dist/hooks → hooks}/useChatOperationBlocks.d.ts.map +0 -0
- /package/{dist/hooks → hooks}/useChatOperationBlocks.js.map +0 -0
- /package/{dist/hooks → hooks}/useChatScroll.d.ts +0 -0
- /package/{dist/hooks → hooks}/useChatScroll.d.ts.map +0 -0
- /package/{dist/hooks → hooks}/useChatScroll.js +0 -0
- /package/{dist/hooks → hooks}/useChatScroll.js.map +0 -0
- /package/{dist/index.d.ts → index.d.ts} +0 -0
- /package/{dist/index.d.ts.map → index.d.ts.map} +0 -0
- /package/{dist/index.js → index.js} +0 -0
- /package/{dist/index.js.map → index.js.map} +0 -0
- /package/{dist/views → views}/Chat/Chat.vue.d.ts +0 -0
- /package/{dist/views → views}/Chat/Chat.vue.js.map +0 -0
- /package/{dist/views → views}/Chat/Messages/ExecuteRequestTool.vue.d.ts +0 -0
- /package/{dist/views → views}/Chat/Messages/ExecuteRequestTool.vue.js.map +0 -0
- /package/{dist/views → views}/Chat/Messages/GetMiniOpenAPIDocTool.vue.d.ts +0 -0
- /package/{dist/views → views}/Chat/Messages/GetMiniOpenAPIDocTool.vue.js.map +0 -0
- /package/{dist/views → views}/Chat/Messages/Text.vue.d.ts +0 -0
- /package/{dist/views → views}/Chat/Messages/Text.vue.d.ts.map +0 -0
- /package/{dist/views → views}/Chat/Messages/Text.vue2.js +0 -0
- /package/{dist/views → views}/Chat/Messages/Text.vue2.js.map +0 -0
- /package/{dist/views → views}/Layout.vue.d.ts +0 -0
- /package/{dist/views → views}/Layout.vue.js.map +0 -0
- /package/{dist/views → views}/PromptForm.vue.d.ts +0 -0
- /package/{dist/views → views}/PromptForm.vue.js.map +0 -0
- /package/{dist/views → views/Settings}/Auth.vue2.js +0 -0
- /package/{dist/views → views/Settings}/Auth.vue2.js.map +0 -0
- /package/{dist/views → views/Settings}/Settings.vue.d.ts +0 -0
- /package/{dist/views → views/Settings}/Settings.vue.js.map +0 -0
- /package/{dist/views → views}/Start.vue.d.ts +0 -0
- /package/{dist/views → views}/Start.vue.js.map +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare function useChatApprovals(): {
|
|
2
|
+
approvalRequestedParts: import("vue").ComputedRef<({
|
|
3
|
+
type: `tool-${string}`;
|
|
4
|
+
} & {
|
|
5
|
+
toolCallId: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
providerExecuted?: boolean;
|
|
8
|
+
} & {
|
|
9
|
+
state: "approval-requested";
|
|
10
|
+
input: unknown;
|
|
11
|
+
output?: never;
|
|
12
|
+
errorText?: never;
|
|
13
|
+
callProviderMetadata?: import("ai").ProviderMetadata;
|
|
14
|
+
approval: {
|
|
15
|
+
id: string;
|
|
16
|
+
approved?: never;
|
|
17
|
+
reason?: never;
|
|
18
|
+
};
|
|
19
|
+
} & {
|
|
20
|
+
state: "approval-requested";
|
|
21
|
+
})[]>;
|
|
22
|
+
respondToToolCalls: (approved: boolean) => Promise<void>;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=useChatApprovals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useChatApprovals.d.ts","sourceRoot":"","sources":["../../src/hooks/useChatApprovals.ts"],"names":[],"mappings":"AAgBA,wBAAgB,gBAAgB;;;;;;;;;;;;;;;oBAuB038C,CAAC;kBAAuB,CAAC;;;eAlC538C,oBAAoB;;mCAqB7B,OAAO;EAYpD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { computed } from "vue";
|
|
2
|
+
import { useState } from "../state/state.js";
|
|
3
|
+
function isRequestedToolPart(part) {
|
|
4
|
+
return part.type.startsWith("tool") && part.state === "approval-requested";
|
|
5
|
+
}
|
|
6
|
+
function useChatApprovals() {
|
|
7
|
+
const state = useState();
|
|
8
|
+
const approvalRequestedParts = computed(() => {
|
|
9
|
+
return state.chat.messages.filter((message) => message.parts.some(isRequestedToolPart)).flatMap((message) => message.parts).filter(isRequestedToolPart);
|
|
10
|
+
});
|
|
11
|
+
async function respondToToolCalls(approved) {
|
|
12
|
+
const approvalPromises = approvalRequestedParts.value.map(
|
|
13
|
+
(toolPart) => state.chat.addToolApprovalResponse({
|
|
14
|
+
id: toolPart.approval.id,
|
|
15
|
+
approved
|
|
16
|
+
})
|
|
17
|
+
);
|
|
18
|
+
await Promise.all(approvalPromises);
|
|
19
|
+
}
|
|
20
|
+
return { approvalRequestedParts, respondToToolCalls };
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
useChatApprovals
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=useChatApprovals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useChatApprovals.js","sources":["../../src/hooks/useChatApprovals.ts"],"sourcesContent":["import type { ToolUIPart, UIMessagePart, UITools } from 'ai'\nimport { computed } from 'vue'\n\nimport { useState } from '@/state/state'\n\ntype ApprovalRequestedToolPart = ToolUIPart & { state: 'approval-requested' }\n\nfunction isRequestedToolPart(\n part: UIMessagePart<any, UITools>,\n): part is ApprovalRequestedToolPart {\n return (\n part.type.startsWith('tool') &&\n (part as ToolUIPart).state === 'approval-requested'\n )\n}\n\nexport function useChatApprovals() {\n const state = useState()\n\n const approvalRequestedParts = computed(() => {\n return state.chat.messages\n .filter((message) => message.parts.some(isRequestedToolPart))\n .flatMap((message) => message.parts)\n .filter(isRequestedToolPart) as ApprovalRequestedToolPart[]\n })\n\n async function respondToToolCalls(approved: boolean) {\n const approvalPromises = approvalRequestedParts.value.map((toolPart) =>\n state.chat.addToolApprovalResponse({\n id: toolPart.approval.id,\n approved,\n }),\n )\n\n await Promise.all(approvalPromises)\n }\n\n return { approvalRequestedParts, respondToToolCalls }\n}\n"],"names":[],"mappings":";;AAOA,SAAS,oBACP,MACmC;AACnC,SACE,KAAK,KAAK,WAAW,MAAM,KAC1B,KAAoB,UAAU;AAEnC;AAEO,SAAS,mBAAmB;AACjC,QAAM,QAAQ,SAAA;AAEd,QAAM,yBAAyB,SAAS,MAAM;AAC5C,WAAO,MAAM,KAAK,SACf,OAAO,CAAC,YAAY,QAAQ,MAAM,KAAK,mBAAmB,CAAC,EAC3D,QAAQ,CAAC,YAAY,QAAQ,KAAK,EAClC,OAAO,mBAAmB;AAAA,EAC/B,CAAC;AAED,iBAAe,mBAAmB,UAAmB;AACnD,UAAM,mBAAmB,uBAAuB,MAAM;AAAA,MAAI,CAAC,aACzD,MAAM,KAAK,wBAAwB;AAAA,QACjC,IAAI,SAAS,SAAS;AAAA,QACtB;AAAA,MAAA,CACD;AAAA,IAAA;AAGH,UAAM,QAAQ,IAAI,gBAAgB;AAAA,EACpC;AAEA,SAAO,EAAE,wBAAwB,mBAAA;AACnC;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { watch, createApp } from "vue";
|
|
2
2
|
import Endpoint from "../components/Endpoint.vue.js";
|
|
3
3
|
import { useState } from "../state/state.js";
|
|
4
|
-
import { array, string } from "../node_modules/.pnpm/zod@4.
|
|
4
|
+
import { array, string } from "../node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/mini/schemas.js";
|
|
5
5
|
function useChatOperationBlocks(workspaceStore) {
|
|
6
6
|
const state = useState();
|
|
7
7
|
watch(
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare function useSearch(baseUrl: string): {
|
|
2
|
+
query: import("vue").WritableComputedRef<string, string>;
|
|
3
|
+
results: import("vue").Ref<{
|
|
4
|
+
namespace: string;
|
|
5
|
+
slug: string;
|
|
6
|
+
id: string;
|
|
7
|
+
title: string;
|
|
8
|
+
logoUrl: string | null;
|
|
9
|
+
currentVersion: string;
|
|
10
|
+
}[], {
|
|
11
|
+
namespace: string;
|
|
12
|
+
slug: string;
|
|
13
|
+
id: string;
|
|
14
|
+
title: string;
|
|
15
|
+
logoUrl: string | null;
|
|
16
|
+
currentVersion: string;
|
|
17
|
+
}[] | {
|
|
18
|
+
namespace: string;
|
|
19
|
+
slug: string;
|
|
20
|
+
id: string;
|
|
21
|
+
title: string;
|
|
22
|
+
logoUrl: string | null;
|
|
23
|
+
currentVersion: string;
|
|
24
|
+
}[]>;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=useSearch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSearch.d.ts","sourceRoot":"","sources":["../../src/hooks/useSearch.ts"],"names":[],"mappings":"AAOA,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;EAqCxC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useDebounceFn } from "@vueuse/core";
|
|
2
|
+
import { ref, computed } from "vue";
|
|
3
|
+
import { apiServiceFactory } from "@scalar-org/service-api";
|
|
4
|
+
function useSearch(baseUrl) {
|
|
5
|
+
const queryRef = ref("");
|
|
6
|
+
const api = apiServiceFactory(
|
|
7
|
+
baseUrl,
|
|
8
|
+
() => "no-token",
|
|
9
|
+
async () => {
|
|
10
|
+
}
|
|
11
|
+
);
|
|
12
|
+
const search = useDebounceFn(async (q) => {
|
|
13
|
+
const searchResponse = await api.agent.search(q);
|
|
14
|
+
if (searchResponse.error) return;
|
|
15
|
+
results.value = searchResponse.data.results;
|
|
16
|
+
}, 200);
|
|
17
|
+
const query = computed({
|
|
18
|
+
get: () => {
|
|
19
|
+
return queryRef.value;
|
|
20
|
+
},
|
|
21
|
+
set: (v) => {
|
|
22
|
+
search(v);
|
|
23
|
+
queryRef.value = v;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
const results = ref([]);
|
|
27
|
+
search("");
|
|
28
|
+
return {
|
|
29
|
+
query,
|
|
30
|
+
results
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
useSearch
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=useSearch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSearch.js","sources":["../../src/hooks/useSearch.ts"],"sourcesContent":["import { useDebounceFn } from '@vueuse/core'\nimport { computed, ref } from 'vue'\n\nimport { apiServiceFactory } from '@scalar-org/service-api'\n\nimport type { ApiMetadata } from '@/state/state'\n\nexport function useSearch(baseUrl: string) {\n const queryRef = ref('')\n\n const api = apiServiceFactory(\n baseUrl,\n () => 'no-token',\n async () => {\n // no-op\n },\n )\n\n const search = useDebounceFn(async (q) => {\n const searchResponse = await api.agent.search(q)\n\n if (searchResponse.error) return\n\n results.value = searchResponse.data.results\n }, 200)\n\n const query = computed({\n get: () => {\n return queryRef.value\n },\n set: (v) => {\n search(v)\n queryRef.value = v\n },\n })\n\n const results = ref<ApiMetadata[]>([])\n\n search('')\n\n return {\n query,\n results,\n }\n}\n"],"names":[],"mappings":";;;AAOO,SAAS,UAAU,SAAiB;AACzC,QAAM,WAAW,IAAI,EAAE;AAEvB,QAAM,MAAM;AAAA,IACV;AAAA,IACA,MAAM;AAAA,IACN,YAAY;AAAA,IAEZ;AAAA,EAAA;AAGF,QAAM,SAAS,cAAc,OAAO,MAAM;AACxC,UAAM,iBAAiB,MAAM,IAAI,MAAM,OAAO,CAAC;AAE/C,QAAI,eAAe,MAAO;AAE1B,YAAQ,QAAQ,eAAe,KAAK;AAAA,EACtC,GAAG,GAAG;AAEN,QAAM,QAAQ,SAAS;AAAA,IACrB,KAAK,MAAM;AACT,aAAO,SAAS;AAAA,IAClB;AAAA,IACA,KAAK,CAAC,MAAM;AACV,aAAO,CAAC;AACR,eAAS,QAAQ;AAAA,IACnB;AAAA,EAAA,CACD;AAED,QAAM,UAAU,IAAmB,EAAE;AAErC,SAAO,EAAE;AAET,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EAAA;AAEJ;"}
|
package/package.json
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scalar/agent-chat",
|
|
3
3
|
"description": "Agent chat components",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"author": "
|
|
6
|
-
"license": "
|
|
4
|
+
"version": "0.2.0",
|
|
5
|
+
"author": "Scalar (https://github.com/scalar)",
|
|
6
|
+
"license": "MIT",
|
|
7
7
|
"private": false,
|
|
8
8
|
"engines": {
|
|
9
9
|
"node": ">=24"
|
|
10
10
|
},
|
|
11
|
-
"files": [
|
|
12
|
-
"dist"
|
|
13
|
-
],
|
|
14
11
|
"type": "module",
|
|
15
12
|
"types": "./dist/index.d.ts",
|
|
16
13
|
"exports": {
|
|
@@ -29,35 +26,5 @@
|
|
|
29
26
|
"require": "./dist/css/*.css",
|
|
30
27
|
"default": "./dist/css/*.css"
|
|
31
28
|
}
|
|
32
|
-
},
|
|
33
|
-
"dependencies": {
|
|
34
|
-
"@ai-sdk/vue": "3.0.33",
|
|
35
|
-
"@scalar/api-client": "2.18.0",
|
|
36
|
-
"@scalar/api-reference": "1.43.4",
|
|
37
|
-
"@scalar/components": "0.16.19",
|
|
38
|
-
"@scalar/helpers": "0.2.7",
|
|
39
|
-
"@scalar/icons": "0.5.2",
|
|
40
|
-
"@scalar/json-magic": "0.9.0",
|
|
41
|
-
"@scalar/openapi-parser": "0.23.13",
|
|
42
|
-
"@scalar/openapi-types": "0.5.3",
|
|
43
|
-
"@scalar/types": "0.5.7",
|
|
44
|
-
"@scalar/workspace-store": "0.24.6",
|
|
45
|
-
"ai": "6.0.33",
|
|
46
|
-
"markstream-vue": "0.0.6-beta.0",
|
|
47
|
-
"vue": "3.5.21",
|
|
48
|
-
"@scalar-org/css": "0.0.0",
|
|
49
|
-
"@scalar-org/entities": "0.0.3"
|
|
50
|
-
},
|
|
51
|
-
"devDependencies": {
|
|
52
|
-
"@scalar/build-tooling": "0.4.1",
|
|
53
|
-
"@vitejs/plugin-vue": "6.0.1",
|
|
54
|
-
"vite": "7.1.12"
|
|
55
|
-
},
|
|
56
|
-
"scripts": {
|
|
57
|
-
"build": "scalar-build-vite && cp package.json dist",
|
|
58
|
-
"build:watch": "vite build --watch",
|
|
59
|
-
"playground": "cd playground && vite",
|
|
60
|
-
"types:build": "scalar-types-build-vue",
|
|
61
|
-
"types:check": "scalar-types-check-vue"
|
|
62
29
|
}
|
|
63
30
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Ref } from 'vue';
|
|
2
|
+
import type { ApiReferenceConfiguration } from '@scalar/types';
|
|
3
|
+
import type { WorkspaceStore } from '@scalar/workspace-store/client';
|
|
4
|
+
import type { ApiMetadata } from '../state/state.js';
|
|
5
|
+
export declare function loadDocument({ namespace, slug, workspaceStore, registryDocuments, registryUrl, baseUrl, config, }: {
|
|
6
|
+
namespace: string;
|
|
7
|
+
slug: string;
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
registryDocuments: Ref<ApiMetadata[]>;
|
|
10
|
+
workspaceStore: WorkspaceStore;
|
|
11
|
+
config: Partial<ApiReferenceConfiguration>;
|
|
12
|
+
registryUrl: string;
|
|
13
|
+
}): Promise<{
|
|
14
|
+
namespace: string;
|
|
15
|
+
slug: string;
|
|
16
|
+
id: string;
|
|
17
|
+
title: string;
|
|
18
|
+
logoUrl: string | null;
|
|
19
|
+
currentVersion: string;
|
|
20
|
+
} | undefined>;
|
|
21
|
+
//# sourceMappingURL=add-documents-to-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-documents-to-store.d.ts","sourceRoot":"","sources":["../../src/registry/add-documents-to-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAM9B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAA;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAIpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAEhD,wBAAsB,YAAY,CAAC,EACjC,SAAS,EACT,IAAI,EACJ,cAAc,EACd,iBAAiB,EACjB,WAAW,EACX,OAAO,EACP,MAAM,GACP,EAAE;IACD,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,iBAAiB,EAAE,GAAG,CAAC,WAAW,EAAE,CAAC,CAAA;IACrC,cAAc,EAAE,cAAc,CAAA;IAC9B,MAAM,EAAE,OAAO,CAAC,yBAAyB,CAAC,CAAA;IAC1C,WAAW,EAAE,MAAM,CAAA;CACpB;;;;;;;eAmCA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { mapConfiguration } from "@scalar/api-reference/helpers";
|
|
2
|
+
import { bundle } from "@scalar/json-magic/bundle";
|
|
3
|
+
import { fetchUrls } from "@scalar/json-magic/bundle/plugins/browser";
|
|
4
|
+
import { apiServiceFactory } from "@scalar-org/service-api";
|
|
5
|
+
import { restoreAuthSecretsFromStorage } from "../helpers.js";
|
|
6
|
+
async function loadDocument({
|
|
7
|
+
namespace,
|
|
8
|
+
slug,
|
|
9
|
+
workspaceStore,
|
|
10
|
+
registryDocuments,
|
|
11
|
+
registryUrl,
|
|
12
|
+
baseUrl,
|
|
13
|
+
config
|
|
14
|
+
}) {
|
|
15
|
+
const api = apiServiceFactory(
|
|
16
|
+
baseUrl,
|
|
17
|
+
() => "no-token",
|
|
18
|
+
async () => {
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
const getDocumentRes = await api.agent.getDocument({ namespace, slug });
|
|
22
|
+
if (getDocumentRes.error) return;
|
|
23
|
+
registryDocuments.value.push(getDocumentRes.data);
|
|
24
|
+
const url = new URL(`/@${namespace}/apis/${slug}/latest`, registryUrl);
|
|
25
|
+
const document = await bundle(url.toString(), {
|
|
26
|
+
plugins: [fetchUrls()],
|
|
27
|
+
treeShake: false
|
|
28
|
+
});
|
|
29
|
+
const documentName = `${namespace}/${slug}`;
|
|
30
|
+
await workspaceStore.addDocument({
|
|
31
|
+
name: documentName,
|
|
32
|
+
document,
|
|
33
|
+
config: mapConfiguration(config)
|
|
34
|
+
});
|
|
35
|
+
workspaceStore.update("x-scalar-active-document", documentName);
|
|
36
|
+
restoreAuthSecretsFromStorage({ documentName, workspaceStore });
|
|
37
|
+
return getDocumentRes.data;
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
loadDocument
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=add-documents-to-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-documents-to-store.js","sources":["../../src/registry/add-documents-to-store.ts"],"sourcesContent":["import type { Ref } from 'vue'\n\nimport { mapConfiguration } from '@scalar/api-reference/helpers'\nimport { 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'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport { apiServiceFactory } from '@scalar-org/service-api'\n\nimport { restoreAuthSecretsFromStorage } from '@/helpers'\nimport type { ApiMetadata } from '@/state/state'\n\nexport async function loadDocument({\n namespace,\n slug,\n workspaceStore,\n registryDocuments,\n registryUrl,\n baseUrl,\n config,\n}: {\n namespace: string\n slug: string\n baseUrl: string\n registryDocuments: Ref<ApiMetadata[]>\n workspaceStore: WorkspaceStore\n config: Partial<ApiReferenceConfiguration>\n registryUrl: string\n}) {\n const api = apiServiceFactory(\n baseUrl,\n () => 'no-token',\n async () => {\n // no-op\n },\n )\n\n const getDocumentRes = await api.agent.getDocument({ namespace, slug })\n\n if (getDocumentRes.error) return\n\n registryDocuments.value.push(getDocumentRes.data)\n\n const url = new URL(`/@${namespace}/apis/${slug}/latest`, registryUrl)\n\n const document: OpenAPIV3_1.Document = await bundle(url.toString(), {\n plugins: [fetchUrls()],\n treeShake: false,\n })\n\n const documentName = `${namespace}/${slug}`\n\n await workspaceStore.addDocument({\n name: documentName,\n document,\n config: mapConfiguration(config),\n })\n\n workspaceStore.update('x-scalar-active-document', documentName)\n\n restoreAuthSecretsFromStorage({ documentName, workspaceStore })\n\n return getDocumentRes.data\n}\n"],"names":[],"mappings":";;;;;AAaA,eAAsB,aAAa;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAQG;AACD,QAAM,MAAM;AAAA,IACV;AAAA,IACA,MAAM;AAAA,IACN,YAAY;AAAA,IAEZ;AAAA,EAAA;AAGF,QAAM,iBAAiB,MAAM,IAAI,MAAM,YAAY,EAAE,WAAW,MAAM;AAEtE,MAAI,eAAe,MAAO;AAE1B,oBAAkB,MAAM,KAAK,eAAe,IAAI;AAEhD,QAAM,MAAM,IAAI,IAAI,KAAK,SAAS,SAAS,IAAI,WAAW,WAAW;AAErE,QAAM,WAAiC,MAAM,OAAO,IAAI,YAAY;AAAA,IAClE,SAAS,CAAC,WAAW;AAAA,IACrB,WAAW;AAAA,EAAA,CACZ;AAED,QAAM,eAAe,GAAG,SAAS,IAAI,IAAI;AAEzC,QAAM,eAAe,YAAY;AAAA,IAC/B,MAAM;AAAA,IACN;AAAA,IACA,QAAQ,iBAAiB,MAAM;AAAA,EAAA,CAChC;AAED,iBAAe,OAAO,4BAA4B,YAAY;AAE9D,gCAA8B,EAAE,cAAc,gBAAgB;AAE9D,SAAO,eAAe;AACxB;"}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { Chat } from '@ai-sdk/vue';
|
|
2
2
|
import { type UIDataTypes, type UIMessage } from 'ai';
|
|
3
3
|
import { type ComputedRef, type InjectionKey, type Ref } from 'vue';
|
|
4
|
+
import type z from 'zod';
|
|
4
5
|
import { type ModalState } from '@scalar/components';
|
|
5
|
-
import type { OpenAPI } from '@scalar/openapi-types';
|
|
6
6
|
import { type ApiReferenceConfigurationRaw } from '@scalar/types';
|
|
7
7
|
import { type WorkspaceStore } from '@scalar/workspace-store/client';
|
|
8
8
|
import { type WorkspaceEventBus } from '@scalar/workspace-store/events';
|
|
9
|
-
import type {
|
|
10
|
-
import type
|
|
11
|
-
|
|
9
|
+
import type { agentRoutes } from '@scalar-org/entities/agent';
|
|
10
|
+
import { EXECUTE_REQUEST_TOOL_NAME, type ExecuteRequestToolInput, type ExecuteRequestToolOutput, GET_MINI_OPENAPI_SPEC_TOOL_NAME, GET_OPENAPI_SPECS_SUMMARY_TOOL_NAME, type GetMiniOpenAPIDocToolInput, type GetMiniOpenAPIDocToolOutput, type GetOpenAPISpecsSummaryToolOutput } from '@scalar-org/entities/agent/tools';
|
|
11
|
+
export type RegistryDocument = {
|
|
12
|
+
namespace: string;
|
|
13
|
+
slug: string;
|
|
14
|
+
};
|
|
12
15
|
export type Tools = {
|
|
13
16
|
[GET_MINI_OPENAPI_SPEC_TOOL_NAME]: {
|
|
14
17
|
input: GetMiniOpenAPIDocToolInput;
|
|
@@ -18,29 +21,41 @@ export type Tools = {
|
|
|
18
21
|
input: ExecuteRequestToolInput;
|
|
19
22
|
output: ExecuteRequestToolOutput;
|
|
20
23
|
};
|
|
24
|
+
[GET_OPENAPI_SPECS_SUMMARY_TOOL_NAME]: {
|
|
25
|
+
input: object;
|
|
26
|
+
output: GetOpenAPISpecsSummaryToolOutput;
|
|
27
|
+
};
|
|
21
28
|
};
|
|
29
|
+
export declare const STATE_SYMBOL: InjectionKey<State>;
|
|
30
|
+
export type ApiMetadata = z.output<typeof agentRoutes.registry.search.responseSchema>['results'][number];
|
|
22
31
|
type State = {
|
|
23
|
-
mode: Ref<'search' | 'agent'>;
|
|
24
32
|
prompt: Ref<string>;
|
|
25
33
|
chat: Chat<UIMessage<unknown, UIDataTypes, Tools>>;
|
|
26
34
|
workspaceStore: WorkspaceStore;
|
|
27
|
-
dereferencedDocument: Ref<OpenAPI.Document | null>;
|
|
28
35
|
loading: ComputedRef<boolean>;
|
|
29
36
|
settingsModal: ModalState;
|
|
30
|
-
securitySchemes: Ref<SecuritySchemeObject[]>;
|
|
31
|
-
activeServer: Ref<ServerObject | undefined>;
|
|
32
|
-
proxyUrl: Ref<string | undefined>;
|
|
33
37
|
eventBus: WorkspaceEventBus;
|
|
34
|
-
|
|
38
|
+
proxyUrl: Ref<string | undefined>;
|
|
39
|
+
config: ComputedRef<ApiReferenceConfigurationRaw>;
|
|
35
40
|
registryUrl: string;
|
|
36
41
|
baseUrl: string;
|
|
42
|
+
registryDocuments: Ref<ApiMetadata[]>;
|
|
43
|
+
addDocument: (document: {
|
|
44
|
+
namespace: string;
|
|
45
|
+
slug: string;
|
|
46
|
+
}) => void;
|
|
47
|
+
removeDocument: (document: {
|
|
48
|
+
namespace: string;
|
|
49
|
+
slug: string;
|
|
50
|
+
}) => void;
|
|
37
51
|
};
|
|
38
|
-
export declare
|
|
39
|
-
|
|
52
|
+
export declare function createState({ initialRegistryDocuments, registryUrl, baseUrl, }: {
|
|
53
|
+
initialRegistryDocuments: {
|
|
54
|
+
namespace: string;
|
|
55
|
+
slug: string;
|
|
56
|
+
}[];
|
|
40
57
|
registryUrl: string;
|
|
41
58
|
baseUrl: string;
|
|
42
|
-
namespace: string;
|
|
43
|
-
slug: string;
|
|
44
59
|
}): State;
|
|
45
60
|
export declare function useState(): State;
|
|
46
61
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/state/state.ts"],"names":[],"mappings":"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"}
|
|
@@ -5,15 +5,12 @@ import { useModal } from "@scalar/components";
|
|
|
5
5
|
import { apiReferenceConfigurationSchema } from "@scalar/types";
|
|
6
6
|
import { createWorkspaceStore } from "@scalar/workspace-store/client";
|
|
7
7
|
import { createWorkspaceEventBus } from "@scalar/workspace-store/events";
|
|
8
|
-
import {
|
|
8
|
+
import { createDocumentSettings } from "../helpers.js";
|
|
9
|
+
import { loadDocument } from "../registry/add-documents-to-store.js";
|
|
9
10
|
const STATE_SYMBOL = Symbol("STATE_SYMBOL");
|
|
10
11
|
function createChat({
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
activeServer,
|
|
14
|
-
namespace,
|
|
15
|
-
proxyUrl,
|
|
16
|
-
slug,
|
|
12
|
+
registryDocuments,
|
|
13
|
+
workspaceStore,
|
|
17
14
|
baseUrl
|
|
18
15
|
}) {
|
|
19
16
|
return new Chat({
|
|
@@ -21,31 +18,21 @@ function createChat({
|
|
|
21
18
|
transport: new DefaultChatTransport({
|
|
22
19
|
api: `${baseUrl}/vector/openapi/chat`,
|
|
23
20
|
body: () => ({
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
securitySchemes: securitySchemes.value,
|
|
27
|
-
activeServerUrl: activeServer.value?.url,
|
|
28
|
-
mode: mode.value,
|
|
29
|
-
...proxyUrl.value && {
|
|
30
|
-
proxyUrl: proxyUrl.value
|
|
31
|
-
}
|
|
21
|
+
registryDocuments: registryDocuments.value,
|
|
22
|
+
documentSettings: createDocumentSettings(workspaceStore)
|
|
32
23
|
})
|
|
33
24
|
})
|
|
34
25
|
});
|
|
35
26
|
}
|
|
36
27
|
function createState({
|
|
28
|
+
initialRegistryDocuments,
|
|
37
29
|
registryUrl,
|
|
38
|
-
baseUrl
|
|
39
|
-
namespace,
|
|
40
|
-
slug
|
|
30
|
+
baseUrl
|
|
41
31
|
}) {
|
|
42
|
-
const mode = ref("search");
|
|
43
32
|
const prompt = ref("");
|
|
44
|
-
const dereferencedDocument = ref(null);
|
|
45
|
-
const securitySchemes = ref([]);
|
|
46
|
-
const activeServer = ref();
|
|
47
|
-
const proxyUrl = ref("https://proxy.scalar.com");
|
|
48
33
|
const eventBus = createWorkspaceEventBus();
|
|
34
|
+
const registryDocuments = ref([]);
|
|
35
|
+
const proxyUrl = ref("https://proxy.scalar.com");
|
|
49
36
|
const config = computed(
|
|
50
37
|
() => apiReferenceConfigurationSchema.parse({
|
|
51
38
|
proxyUrl: proxyUrl.value,
|
|
@@ -54,19 +41,10 @@ function createState({
|
|
|
54
41
|
);
|
|
55
42
|
const workspaceStore = createWorkspaceStore();
|
|
56
43
|
const chat = createChat({
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
namespace,
|
|
60
|
-
slug,
|
|
61
|
-
activeServer,
|
|
62
|
-
proxyUrl,
|
|
44
|
+
registryDocuments,
|
|
45
|
+
workspaceStore,
|
|
63
46
|
baseUrl
|
|
64
47
|
});
|
|
65
|
-
getDocument(workspaceStore, namespace, slug, config.value, registryUrl).then(
|
|
66
|
-
(schema) => {
|
|
67
|
-
if (schema) dereferencedDocument.value = schema;
|
|
68
|
-
}
|
|
69
|
-
);
|
|
70
48
|
const loading = computed(
|
|
71
49
|
() => chat.status === "submitted" || chat.status === "streaming" && !chat.lastMessage?.parts.some((part) => part.type === "text")
|
|
72
50
|
);
|
|
@@ -77,21 +55,48 @@ function createState({
|
|
|
77
55
|
}
|
|
78
56
|
);
|
|
79
57
|
const settingsModal = useModal();
|
|
58
|
+
function addDocument({
|
|
59
|
+
namespace,
|
|
60
|
+
slug
|
|
61
|
+
}) {
|
|
62
|
+
const matchingDoc = registryDocuments.value.find(
|
|
63
|
+
(doc) => doc.namespace === namespace && doc.slug === slug
|
|
64
|
+
);
|
|
65
|
+
if (matchingDoc) return;
|
|
66
|
+
loadDocument({
|
|
67
|
+
namespace,
|
|
68
|
+
slug,
|
|
69
|
+
baseUrl,
|
|
70
|
+
workspaceStore,
|
|
71
|
+
registryUrl,
|
|
72
|
+
registryDocuments,
|
|
73
|
+
config: config.value
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function removeDocument({
|
|
77
|
+
namespace,
|
|
78
|
+
slug
|
|
79
|
+
}) {
|
|
80
|
+
registryDocuments.value = registryDocuments.value.filter(
|
|
81
|
+
(doc) => !(doc.namespace === namespace && doc.slug === slug)
|
|
82
|
+
);
|
|
83
|
+
workspaceStore.deleteDocument(`${namespace}/${slug}`);
|
|
84
|
+
}
|
|
85
|
+
initialRegistryDocuments.forEach(addDocument);
|
|
80
86
|
return {
|
|
81
|
-
mode,
|
|
82
87
|
prompt,
|
|
83
88
|
chat,
|
|
84
89
|
workspaceStore,
|
|
85
|
-
dereferencedDocument,
|
|
86
90
|
loading,
|
|
87
91
|
settingsModal,
|
|
88
|
-
securitySchemes,
|
|
89
|
-
activeServer,
|
|
90
|
-
proxyUrl,
|
|
91
92
|
eventBus,
|
|
92
93
|
config,
|
|
93
94
|
registryUrl,
|
|
94
|
-
baseUrl
|
|
95
|
+
baseUrl,
|
|
96
|
+
registryDocuments,
|
|
97
|
+
addDocument,
|
|
98
|
+
removeDocument,
|
|
99
|
+
proxyUrl
|
|
95
100
|
};
|
|
96
101
|
}
|
|
97
102
|
function useState() {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.js","sources":["../../src/state/state.ts"],"sourcesContent":["import { Chat } from '@ai-sdk/vue'\nimport {\n DefaultChatTransport,\n lastAssistantMessageIsCompleteWithApprovalResponses,\n type UIDataTypes,\n type UIMessage,\n} from 'ai'\nimport {\n type ComputedRef,\n computed,\n type InjectionKey,\n inject,\n type Ref,\n ref,\n watch,\n} from 'vue'\nimport type z from 'zod'\n\nimport { type ModalState, useModal } from '@scalar/components'\nimport {\n type ApiReferenceConfigurationRaw,\n apiReferenceConfigurationSchema,\n} from '@scalar/types'\nimport {\n createWorkspaceStore,\n type WorkspaceStore,\n} from '@scalar/workspace-store/client'\nimport {\n createWorkspaceEventBus,\n type WorkspaceEventBus,\n} from '@scalar/workspace-store/events'\nimport type { agentRoutes } from '@scalar-org/entities/agent'\nimport {\n EXECUTE_REQUEST_TOOL_NAME,\n type ExecuteRequestToolInput,\n type ExecuteRequestToolOutput,\n GET_MINI_OPENAPI_SPEC_TOOL_NAME,\n GET_OPENAPI_SPECS_SUMMARY_TOOL_NAME,\n type GetMiniOpenAPIDocToolInput,\n type GetMiniOpenAPIDocToolOutput,\n type GetOpenAPISpecsSummaryToolOutput,\n} from '@scalar-org/entities/agent/tools'\n\nimport { createDocumentSettings } from '@/helpers'\nimport { loadDocument } from '@/registry/add-documents-to-store'\n\nexport type RegistryDocument = {\n namespace: string\n slug: string\n}\n\nexport type Tools = {\n [GET_MINI_OPENAPI_SPEC_TOOL_NAME]: {\n input: GetMiniOpenAPIDocToolInput\n output: GetMiniOpenAPIDocToolOutput\n }\n [EXECUTE_REQUEST_TOOL_NAME]: {\n input: ExecuteRequestToolInput\n output: ExecuteRequestToolOutput\n }\n [GET_OPENAPI_SPECS_SUMMARY_TOOL_NAME]: {\n input: object\n output: GetOpenAPISpecsSummaryToolOutput\n }\n}\n\nexport const STATE_SYMBOL: InjectionKey<State> = Symbol('STATE_SYMBOL')\n\nexport type ApiMetadata = z.output<\n typeof agentRoutes.registry.search.responseSchema\n>['results'][number]\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: Ref<string | undefined>\n config: ComputedRef<ApiReferenceConfigurationRaw>\n registryUrl: string\n baseUrl: string\n registryDocuments: Ref<ApiMetadata[]>\n addDocument: (document: { namespace: string; slug: string }) => void\n removeDocument: (document: { namespace: string; slug: string }) => void\n}\n\nfunction createChat({\n registryDocuments,\n workspaceStore,\n baseUrl,\n}: {\n registryDocuments: Ref<ApiMetadata[]>\n workspaceStore: WorkspaceStore\n baseUrl: string\n}) {\n return new Chat<UIMessage<unknown, UIDataTypes, Tools>>({\n sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithApprovalResponses,\n transport: new DefaultChatTransport({\n api: `${baseUrl}/vector/openapi/chat`,\n body: () => ({\n registryDocuments: registryDocuments.value,\n documentSettings: createDocumentSettings(workspaceStore),\n }),\n }),\n })\n}\n\nexport function createState({\n initialRegistryDocuments,\n registryUrl,\n baseUrl,\n}: {\n initialRegistryDocuments: { namespace: string; slug: string }[]\n registryUrl: string\n baseUrl: string\n}): State {\n const prompt = ref<State['prompt']['value']>('')\n const eventBus = createWorkspaceEventBus()\n const registryDocuments = ref<ApiMetadata[]>([])\n const proxyUrl = ref<State['proxyUrl']['value']>('https://proxy.scalar.com')\n\n const config = computed(() =>\n apiReferenceConfigurationSchema.parse({\n proxyUrl: proxyUrl.value,\n persistAuth: true,\n }),\n )\n\n const workspaceStore = createWorkspaceStore()\n\n const chat = createChat({\n registryDocuments,\n workspaceStore,\n baseUrl,\n })\n\n const loading = computed(\n () =>\n chat.status === 'submitted' ||\n (chat.status === 'streaming' &&\n !chat.lastMessage?.parts.some((part) => part.type === 'text')),\n )\n\n watch(\n () => chat.status,\n () => {\n if (chat.status === 'streaming') prompt.value = ''\n },\n )\n\n const settingsModal = useModal()\n\n function addDocument({\n namespace,\n slug,\n }: {\n namespace: string\n slug: string\n }) {\n const matchingDoc = registryDocuments.value.find(\n (doc) => doc.namespace === namespace && doc.slug === slug,\n )\n\n if (matchingDoc) return\n\n loadDocument({\n namespace,\n slug,\n baseUrl,\n workspaceStore,\n registryUrl,\n registryDocuments,\n config: config.value,\n })\n }\n\n function removeDocument({\n namespace,\n slug,\n }: {\n namespace: string\n slug: string\n }) {\n registryDocuments.value = registryDocuments.value.filter(\n (doc) => !(doc.namespace === namespace && doc.slug === slug),\n )\n\n workspaceStore.deleteDocument(`${namespace}/${slug}`)\n }\n\n initialRegistryDocuments.forEach(addDocument)\n\n return {\n prompt,\n chat,\n workspaceStore,\n loading,\n settingsModal,\n eventBus,\n config,\n registryUrl,\n baseUrl,\n registryDocuments,\n addDocument,\n removeDocument,\n proxyUrl,\n }\n}\n\nexport function useState() {\n const state = inject(STATE_SYMBOL)\n if (!state) throw new Error('No state provided.')\n\n return state\n}\n"],"names":[],"mappings":";;;;;;;;;AAkEO,MAAM,eAAoC,OAAO,cAAc;AAsBtE,SAAS,WAAW;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AACF,GAIG;AACD,SAAO,IAAI,KAA6C;AAAA,IACtD,uBAAuB;AAAA,IACvB,WAAW,IAAI,qBAAqB;AAAA,MAClC,KAAK,GAAG,OAAO;AAAA,MACf,MAAM,OAAO;AAAA,QACX,mBAAmB,kBAAkB;AAAA,QACrC,kBAAkB,uBAAuB,cAAc;AAAA,MAAA;AAAA,IACzD,CACD;AAAA,EAAA,CACF;AACH;AAEO,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AACF,GAIU;AACR,QAAM,SAAS,IAA8B,EAAE;AAC/C,QAAM,WAAW,wBAAA;AACjB,QAAM,oBAAoB,IAAmB,EAAE;AAC/C,QAAM,WAAW,IAAgC,0BAA0B;AAE3E,QAAM,SAAS;AAAA,IAAS,MACtB,gCAAgC,MAAM;AAAA,MACpC,UAAU,SAAS;AAAA,MACnB,aAAa;AAAA,IAAA,CACd;AAAA,EAAA;AAGH,QAAM,iBAAiB,qBAAA;AAEvB,QAAM,OAAO,WAAW;AAAA,IACtB;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACD;AAED,QAAM,UAAU;AAAA,IACd,MACE,KAAK,WAAW,eACf,KAAK,WAAW,eACf,CAAC,KAAK,aAAa,MAAM,KAAK,CAAC,SAAS,KAAK,SAAS,MAAM;AAAA,EAAA;AAGlE;AAAA,IACE,MAAM,KAAK;AAAA,IACX,MAAM;AACJ,UAAI,KAAK,WAAW,YAAa,QAAO,QAAQ;AAAA,IAClD;AAAA,EAAA;AAGF,QAAM,gBAAgB,SAAA;AAEtB,WAAS,YAAY;AAAA,IACnB;AAAA,IACA;AAAA,EAAA,GAIC;AACD,UAAM,cAAc,kBAAkB,MAAM;AAAA,MAC1C,CAAC,QAAQ,IAAI,cAAc,aAAa,IAAI,SAAS;AAAA,IAAA;AAGvD,QAAI,YAAa;AAEjB,iBAAa;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,QAAQ,OAAO;AAAA,IAAA,CAChB;AAAA,EACH;AAEA,WAAS,eAAe;AAAA,IACtB;AAAA,IACA;AAAA,EAAA,GAIC;AACD,sBAAkB,QAAQ,kBAAkB,MAAM;AAAA,MAChD,CAAC,QAAQ,EAAE,IAAI,cAAc,aAAa,IAAI,SAAS;AAAA,IAAA;AAGzD,mBAAe,eAAe,GAAG,SAAS,IAAI,IAAI,EAAE;AAAA,EACtD;AAEA,2BAAyB,QAAQ,WAAW;AAE5C,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;AAEO,SAAS,WAAW;AACzB,QAAM,QAAQ,OAAO,YAAY;AACjC,MAAI,CAAC,MAAO,OAAM,IAAI,MAAM,oBAAoB;AAEhD,SAAO;AACT;"}
|