@scalar/agent-chat 0.10.14 → 0.12.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.map +1 -1
- package/dist/api.js +13 -13
- package/dist/api.js.map +1 -1
- package/dist/entities/registry/document.d.ts +10 -10
- package/dist/entities/registry/document.d.ts.map +1 -1
- package/dist/entities/registry/document.js +8 -8
- package/dist/entities/registry/document.js.map +1 -1
- package/dist/entities/tools/ask-for-authentication.d.ts +6 -6
- package/dist/entities/tools/ask-for-authentication.d.ts.map +1 -1
- package/dist/entities/tools/ask-for-authentication.js +4 -4
- package/dist/entities/tools/ask-for-authentication.js.map +1 -1
- package/dist/entities/tools/execute-request.d.ts +10 -10
- package/dist/entities/tools/execute-request.d.ts.map +1 -1
- package/dist/entities/tools/execute-request.js +8 -8
- package/dist/entities/tools/execute-request.js.map +1 -1
- package/dist/entities/tools/search-openapi-operations.d.ts +5 -5
- package/dist/entities/tools/search-openapi-operations.d.ts.map +1 -1
- package/dist/entities/tools/search-openapi-operations.js +2 -2
- package/dist/entities/tools/search-openapi-operations.js.map +1 -1
- package/dist/helpers.d.ts +1 -1
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +6 -3
- package/dist/helpers.js.map +1 -1
- package/dist/hooks/use-chat-error.d.ts +10 -9
- package/dist/hooks/use-chat-error.d.ts.map +1 -1
- package/dist/hooks/use-chat-error.js +7 -8
- package/dist/hooks/use-chat-error.js.map +1 -1
- package/dist/hooks/use-upload-tmp-document.d.ts.map +1 -1
- package/dist/hooks/use-upload-tmp-document.js +20 -18
- package/dist/hooks/use-upload-tmp-document.js.map +1 -1
- package/dist/package.json +4 -3
- package/dist/state/state.d.ts.map +1 -1
- package/dist/state/state.js +3 -2
- package/dist/state/state.js.map +1 -1
- package/dist/style.css +180 -1087
- 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 +3 -1
- package/dist/views/Chat/Messages/AskForAuthentication.vue.script.js.map +1 -1
- package/dist/views/Settings/Auth.vue.d.ts +2 -3
- package/dist/views/Settings/Auth.vue.d.ts.map +1 -1
- package/dist/views/Settings/Auth.vue.js.map +1 -1
- package/dist/views/Settings/Auth.vue.script.js.map +1 -1
- package/dist/views/Settings/DocSettings.vue.d.ts +2 -2
- package/dist/views/Settings/DocSettings.vue.d.ts.map +1 -1
- package/dist/views/Settings/DocSettings.vue.js +1 -1
- package/dist/views/Settings/DocSettings.vue.js.map +1 -1
- package/dist/views/Settings/DocSettings.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 +2 -1
- package/dist/views/Settings/Settings.vue.script.js.map +1 -1
- package/dist/vue-styles.css +20 -20
- package/package.json +12 -11
package/dist/App.vue.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.vue.d.ts","sourceRoot":"","sources":["../src/App.vue"],"names":[],"mappings":"AAyEA,OAAO,EAAW,KAAK,GAAG,EAAE,MAAM,KAAK,CAAA;AAGvC,OAAO,EAA6B,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAChF,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEvC,KAAK,WAAW,GAAG;IACjB,iBAAiB,EAAE,gBAAgB,EAAE,CAAA;IACrC,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,gBAAgB,EAAE,MAAM,CAAA;IACxB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,QAAQ,CAAA;IACf,cAAc,CAAC,EAAE,MAAM,MAA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IACxB,gBAAgB,EAAE,OAAO,KAAK,CAAC,gBAAgB,CAAA;CAChD,CAAA;AA8CD,QAAA,MAAM,YAAY;;;;kFAIhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
package/dist/api.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createError } from "./entities/error/helpers.js";
|
|
2
2
|
import { registryApiMetadata } from "./entities/registry/document.js";
|
|
3
3
|
import { n } from "neverpanic";
|
|
4
|
-
import
|
|
4
|
+
import { array, coerce, object, string, validate } from "@scalar/validation";
|
|
5
5
|
//#region src/api.ts
|
|
6
6
|
function createAuthorizationHeaders({ getAccessToken, getAgentKey }) {
|
|
7
7
|
const token = getAccessToken?.();
|
|
@@ -13,6 +13,10 @@ function createAuthorizationHeaders({ getAccessToken, getAgentKey }) {
|
|
|
13
13
|
}
|
|
14
14
|
/** Minimal set of API requests needed for agent chat */
|
|
15
15
|
function createApi({ baseUrl, getAccessToken, getAgentKey }) {
|
|
16
|
+
const serviceErrorSchema = object({
|
|
17
|
+
message: string(),
|
|
18
|
+
code: string()
|
|
19
|
+
});
|
|
16
20
|
const request = n.safeFn(async ({ path, method = "get", query, body, responseSchema }) => {
|
|
17
21
|
const url = `${baseUrl}${path}${query ? `?${new URLSearchParams(query)}` : ""}`;
|
|
18
22
|
const fetchResult = await n.fromUnsafe(async () => fetch(url, {
|
|
@@ -30,33 +34,29 @@ function createApi({ baseUrl, getAccessToken, getAgentKey }) {
|
|
|
30
34
|
error: createError("UNKNOWN_ERROR", "Unknown error occurred. Please contact support.")
|
|
31
35
|
};
|
|
32
36
|
if (!fetchResult.data.ok) {
|
|
33
|
-
|
|
34
|
-
message: z$1.string(),
|
|
35
|
-
code: z$1.string()
|
|
36
|
-
}).safeParse(fetchDataResult.data);
|
|
37
|
-
if (!serviceError.success) return {
|
|
37
|
+
if (!validate(serviceErrorSchema, fetchDataResult.data)) return {
|
|
38
38
|
success: false,
|
|
39
39
|
error: createError("UNKNOWN_ERROR", "Unknown error occurred. Please contact support.")
|
|
40
40
|
};
|
|
41
|
+
const errorData = coerce(serviceErrorSchema, fetchDataResult.data);
|
|
41
42
|
return {
|
|
42
43
|
success: false,
|
|
43
|
-
error: createError(
|
|
44
|
+
error: createError(errorData.code, errorData.message)
|
|
44
45
|
};
|
|
45
46
|
}
|
|
46
|
-
|
|
47
|
-
if (!serviceData.success) return {
|
|
47
|
+
if (!validate(responseSchema, fetchDataResult.data)) return {
|
|
48
48
|
success: false,
|
|
49
49
|
error: createError("INVALID_RESPONSE", "Invalid response. Please contact support")
|
|
50
50
|
};
|
|
51
51
|
return {
|
|
52
52
|
success: true,
|
|
53
|
-
data:
|
|
53
|
+
data: coerce(responseSchema, fetchDataResult.data)
|
|
54
54
|
};
|
|
55
55
|
});
|
|
56
56
|
const search = async (query) => request({
|
|
57
57
|
path: "/vector/registry/search",
|
|
58
58
|
query: { query },
|
|
59
|
-
responseSchema:
|
|
59
|
+
responseSchema: object({ results: array(registryApiMetadata) })
|
|
60
60
|
});
|
|
61
61
|
const getDocument = async (params) => request({
|
|
62
62
|
path: `/vector/registry/document/${params.namespace}/${params.slug}`,
|
|
@@ -64,11 +64,11 @@ function createApi({ baseUrl, getAccessToken, getAgentKey }) {
|
|
|
64
64
|
});
|
|
65
65
|
const getKeyDocuments = async () => request({
|
|
66
66
|
path: "/vector/registry/documents",
|
|
67
|
-
responseSchema:
|
|
67
|
+
responseSchema: object({ documents: array(registryApiMetadata) })
|
|
68
68
|
});
|
|
69
69
|
const getCuratedDocuments = async () => request({
|
|
70
70
|
path: "/vector/registry/curated",
|
|
71
|
-
responseSchema:
|
|
71
|
+
responseSchema: object({ results: array(registryApiMetadata) })
|
|
72
72
|
});
|
|
73
73
|
return {
|
|
74
74
|
search,
|
package/dist/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","names":[],"sources":["../src/api.ts"],"sourcesContent":["import { n } from 'neverpanic'\nimport
|
|
1
|
+
{"version":3,"file":"api.js","names":[],"sources":["../src/api.ts"],"sourcesContent":["import { n } from 'neverpanic'\nimport { type Schema, type Static, array, coerce, object, string, validate } from '@scalar/validation'\n\nimport { createError } from '@/entities/error/helpers'\nimport { registryApiMetadata } from '@/entities/registry/document'\n\nexport function createAuthorizationHeaders({\n getAccessToken,\n getAgentKey,\n}: {\n getAccessToken?: () => string\n getAgentKey?: () => string\n}) {\n const token = getAccessToken?.()\n const agentKey = getAgentKey?.()\n\n return {\n ...(token && {\n Authorization: `Bearer ${token}`,\n }),\n ...(agentKey && {\n 'x-scalar-agent-key': agentKey,\n }),\n }\n}\n\n/** Minimal set of API requests needed for agent chat */\nexport function createApi({\n baseUrl,\n getAccessToken,\n getAgentKey,\n}: {\n baseUrl: string\n getAccessToken?: () => string\n getAgentKey?: () => string\n}) {\n const serviceErrorSchema = object({ message: string(), code: string() })\n\n const request = n.safeFn(\n async <T extends Schema>({\n path,\n method = 'get',\n query,\n body,\n responseSchema,\n }: {\n path: string\n method?: string\n query?: Record<string, string>\n body?: object\n responseSchema: T\n }) => {\n const url = `${baseUrl}${path}${query ? `?${new URLSearchParams(query)}` : ''}`\n\n const fetchResult = await n.fromUnsafe(\n async () =>\n fetch(url, {\n method,\n ...(body && { body: JSON.stringify(body) }),\n headers: {\n ...createAuthorizationHeaders({ getAccessToken, getAgentKey }),\n },\n }),\n (originalError) => createError('FAILED_TO_FETCH', originalError),\n )\n\n if (!fetchResult.success) {\n return fetchResult\n }\n\n const fetchDataResult = await n.fromUnsafe(\n async () => fetchResult.data.json(),\n (originalError) => createError('FAILED_TO_FETCH_DATA', originalError),\n )\n\n if (!fetchDataResult.success) {\n return {\n success: false,\n error: createError('UNKNOWN_ERROR', 'Unknown error occurred. Please contact support.'),\n }\n }\n\n if (!fetchResult.data.ok) {\n if (!validate(serviceErrorSchema, fetchDataResult.data)) {\n return {\n success: false,\n error: createError('UNKNOWN_ERROR', 'Unknown error occurred. Please contact support.'),\n }\n }\n\n const errorData = coerce(serviceErrorSchema, fetchDataResult.data)\n\n return {\n success: false,\n error: createError(errorData.code, errorData.message),\n }\n }\n\n if (!validate(responseSchema, fetchDataResult.data)) {\n return {\n success: false,\n error: createError('INVALID_RESPONSE', 'Invalid response. Please contact support'),\n }\n }\n\n return { success: true, data: coerce(responseSchema, fetchDataResult.data) as Static<T> }\n },\n )\n\n const search = async (query: string) =>\n request({\n path: '/vector/registry/search',\n query: { query },\n responseSchema: object({\n results: array(registryApiMetadata),\n }),\n })\n\n const getDocument = async (params: { namespace: string; slug: string }) =>\n request({\n path: `/vector/registry/document/${params.namespace}/${params.slug}`,\n responseSchema: registryApiMetadata,\n })\n\n const getKeyDocuments = async () =>\n request({\n path: '/vector/registry/documents',\n responseSchema: object({ documents: array(registryApiMetadata) }),\n })\n\n const getCuratedDocuments = async () =>\n request({\n path: '/vector/registry/curated',\n responseSchema: object({\n results: array(registryApiMetadata),\n }),\n })\n\n return {\n search,\n getDocument,\n getKeyDocuments,\n getCuratedDocuments,\n }\n}\n\nexport type Api = ReturnType<typeof createApi>\n"],"mappings":";;;;;AAMA,SAAgB,2BAA2B,EACzC,gBACA,eAIC;CACD,MAAM,QAAQ,kBAAkB;CAChC,MAAM,WAAW,eAAe;AAEhC,QAAO;EACL,GAAI,SAAS,EACX,eAAe,UAAU,SAC1B;EACD,GAAI,YAAY,EACd,sBAAsB,UACvB;EACF;;;AAIH,SAAgB,UAAU,EACxB,SACA,gBACA,eAKC;CACD,MAAM,qBAAqB,OAAO;EAAE,SAAS,QAAQ;EAAE,MAAM,QAAQ;EAAE,CAAC;CAExE,MAAM,UAAU,EAAE,OAChB,OAAyB,EACvB,MACA,SAAS,OACT,OACA,MACA,qBAOI;EACJ,MAAM,MAAM,GAAG,UAAU,OAAO,QAAQ,IAAI,IAAI,gBAAgB,MAAM,KAAK;EAE3E,MAAM,cAAc,MAAM,EAAE,WAC1B,YACE,MAAM,KAAK;GACT;GACA,GAAI,QAAQ,EAAE,MAAM,KAAK,UAAU,K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AO,EACrB,SAAS,MAAM,oBAAoB,EACpC,CAAC;EACH,CAAC;AAEJ,QAAO;EACL;EACA;EACA;EACA;EACD"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { OpenAPIV3_1 } from '@scalar/openapi-types';
|
|
2
2
|
import type { SecurityScheme } from '@scalar/types/entities';
|
|
3
|
-
import
|
|
4
|
-
export declare const registryApiMetadata:
|
|
5
|
-
id:
|
|
6
|
-
title:
|
|
7
|
-
namespace:
|
|
8
|
-
currentVersion:
|
|
9
|
-
logoUrl:
|
|
10
|
-
slug:
|
|
11
|
-
}
|
|
12
|
-
export type ApiMetadata =
|
|
3
|
+
import { type Static } from '@scalar/validation';
|
|
4
|
+
export declare const registryApiMetadata: import("@scalar/validation").ObjectSchema<{
|
|
5
|
+
id: import("@scalar/validation").StringSchema;
|
|
6
|
+
title: import("@scalar/validation").StringSchema;
|
|
7
|
+
namespace: import("@scalar/validation").StringSchema;
|
|
8
|
+
currentVersion: import("@scalar/validation").StringSchema;
|
|
9
|
+
logoUrl: import("@scalar/validation").UnionSchema<(import("@scalar/validation").StringSchema | import("@scalar/validation").NullableSchema)[]>;
|
|
10
|
+
slug: import("@scalar/validation").StringSchema;
|
|
11
|
+
}>;
|
|
12
|
+
export type ApiMetadata = Static<typeof registryApiMetadata> & {
|
|
13
13
|
removable?: boolean;
|
|
14
14
|
searchEnabled?: boolean;
|
|
15
15
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../../src/entities/registry/document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../../src/entities/registry/document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAAmC,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAEjF,eAAO,MAAM,mBAAmB;;;;;;;EAO9B,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,mBAAmB,CAAC,GAAG;IAAE,SAAS,CAAC,EAAE,OAAO,CAAC;IAAC,aAAa,CAAC,EAAE,OAAO,CAAA;CAAE,CAAA;AAE/G,MAAM,MAAM,gBAAgB,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAElE,MAAM,MAAM,gBAAgB,GAAG,MAAM,CACnC,MAAM,EACN;IACE,eAAe,EAAE,cAAc,EAAE,CAAA;IACjC,YAAY,EAAE,WAAW,CAAC,YAAY,GAAG,SAAS,CAAA;CACnD,CACF,CAAA"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { nullable, object, string, union } from "@scalar/validation";
|
|
2
2
|
//#region src/entities/registry/document.ts
|
|
3
|
-
var registryApiMetadata =
|
|
4
|
-
id:
|
|
5
|
-
title:
|
|
6
|
-
namespace:
|
|
7
|
-
currentVersion:
|
|
8
|
-
logoUrl:
|
|
9
|
-
slug:
|
|
3
|
+
var registryApiMetadata = object({
|
|
4
|
+
id: string(),
|
|
5
|
+
title: string(),
|
|
6
|
+
namespace: string(),
|
|
7
|
+
currentVersion: string(),
|
|
8
|
+
logoUrl: union([string(), nullable()]),
|
|
9
|
+
slug: string()
|
|
10
10
|
});
|
|
11
11
|
//#endregion
|
|
12
12
|
export { registryApiMetadata };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.js","names":[],"sources":["../../../src/entities/registry/document.ts"],"sourcesContent":["import type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport type { SecurityScheme } from '@scalar/types/entities'\nimport
|
|
1
|
+
{"version":3,"file":"document.js","names":[],"sources":["../../../src/entities/registry/document.ts"],"sourcesContent":["import type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport type { SecurityScheme } from '@scalar/types/entities'\nimport { nullable, object, string, union, type Static } from '@scalar/validation'\n\nexport const registryApiMetadata = object({\n id: string(),\n title: string(),\n namespace: string(),\n currentVersion: string(),\n logoUrl: union([string(), nullable()]),\n slug: string(),\n})\n\nexport type ApiMetadata = Static<typeof registryApiMetadata> & { removable?: boolean; searchEnabled?: boolean }\n\nexport type RegistryDocument = { namespace: string; slug: string }\n\nexport type DocumentSettings = Record<\n string,\n {\n securitySchemes: SecurityScheme[]\n activeServer: OpenAPIV3_1.ServerObject | undefined\n }\n>\n"],"mappings":";;AAIA,IAAa,sBAAsB,OAAO;CACxC,IAAI,QAAQ;CACZ,OAAO,QAAQ;CACf,WAAW,QAAQ;CACnB,gBAAgB,QAAQ;CACxB,SAAS,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;CACtC,MAAM,QAAQ;CACf,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type Static } from '@scalar/validation';
|
|
2
2
|
export declare const ASK_FOR_AUTHENTICATION_TOOL_NAME: "ask-for-authentication";
|
|
3
|
-
export declare const askForAuthenticationInputSchema:
|
|
4
|
-
documentName:
|
|
5
|
-
uniqueIdentifier:
|
|
6
|
-
}
|
|
7
|
-
export type AskForAuthenticationInput =
|
|
3
|
+
export declare const askForAuthenticationInputSchema: import("@scalar/validation").ObjectSchema<{
|
|
4
|
+
documentName: import("@scalar/validation").StringSchema;
|
|
5
|
+
uniqueIdentifier: import("@scalar/validation").StringSchema;
|
|
6
|
+
}>;
|
|
7
|
+
export type AskForAuthenticationInput = Static<typeof askForAuthenticationInputSchema>;
|
|
8
8
|
//# sourceMappingURL=ask-for-authentication.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ask-for-authentication.d.ts","sourceRoot":"","sources":["../../../src/entities/tools/ask-for-authentication.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ask-for-authentication.d.ts","sourceRoot":"","sources":["../../../src/entities/tools/ask-for-authentication.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAEhE,eAAO,MAAM,gCAAgC,EAAG,wBAAiC,CAAA;AAEjF,eAAO,MAAM,+BAA+B;;;EAG1C,CAAA;AAEF,MAAM,MAAM,yBAAyB,GAAG,MAAM,CAAC,OAAO,+BAA+B,CAAC,CAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { object, string } from "@scalar/validation";
|
|
2
2
|
//#region src/entities/tools/ask-for-authentication.ts
|
|
3
3
|
var ASK_FOR_AUTHENTICATION_TOOL_NAME = "ask-for-authentication";
|
|
4
|
-
var askForAuthenticationInputSchema =
|
|
5
|
-
documentName:
|
|
6
|
-
uniqueIdentifier:
|
|
4
|
+
var askForAuthenticationInputSchema = object({
|
|
5
|
+
documentName: string(),
|
|
6
|
+
uniqueIdentifier: string({ typeComment: "Needed for legacy support for old clients" })
|
|
7
7
|
});
|
|
8
8
|
//#endregion
|
|
9
9
|
export { ASK_FOR_AUTHENTICATION_TOOL_NAME, askForAuthenticationInputSchema };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ask-for-authentication.js","names":[],"sources":["../../../src/entities/tools/ask-for-authentication.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"ask-for-authentication.js","names":[],"sources":["../../../src/entities/tools/ask-for-authentication.ts"],"sourcesContent":["import { object, string, type Static } from '@scalar/validation'\n\nexport const ASK_FOR_AUTHENTICATION_TOOL_NAME = 'ask-for-authentication' as const\n\nexport const askForAuthenticationInputSchema = object({\n documentName: string(),\n uniqueIdentifier: string({ typeComment: 'Needed for legacy support for old clients' }),\n})\n\nexport type AskForAuthenticationInput = Static<typeof askForAuthenticationInputSchema>\n"],"mappings":";;AAEA,IAAa,mCAAmC;AAEhD,IAAa,kCAAkC,OAAO;CACpD,cAAc,QAAQ;CACtB,kBAAkB,OAAO,EAAE,aAAa,6CAA6C,CAAC;CACvF,CAAC"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import type { Result } from 'neverpanic';
|
|
2
|
-
import {
|
|
2
|
+
import { type Static } from '@scalar/validation';
|
|
3
3
|
import type { AgentChatError } from '../../entities/error/constants.js';
|
|
4
4
|
export declare const EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME: "execute-request";
|
|
5
|
-
export declare const executeClientSideRequestToolInputSchema:
|
|
6
|
-
method:
|
|
7
|
-
path:
|
|
8
|
-
headers:
|
|
9
|
-
body:
|
|
10
|
-
documentName:
|
|
11
|
-
documentIdentifier:
|
|
12
|
-
}
|
|
13
|
-
export type ExecuteClientSideRequestToolInput =
|
|
5
|
+
export declare const executeClientSideRequestToolInputSchema: import("@scalar/validation").ObjectSchema<{
|
|
6
|
+
method: import("@scalar/validation").StringSchema;
|
|
7
|
+
path: import("@scalar/validation").StringSchema;
|
|
8
|
+
headers: import("@scalar/validation").OptionalSchema<import("@scalar/validation").RecordSchema<import("@scalar/validation").StringSchema, import("@scalar/validation").StringSchema>>;
|
|
9
|
+
body: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
|
|
10
|
+
documentName: import("@scalar/validation").StringSchema;
|
|
11
|
+
documentIdentifier: import("@scalar/validation").StringSchema;
|
|
12
|
+
}>;
|
|
13
|
+
export type ExecuteClientSideRequestToolInput = Static<typeof executeClientSideRequestToolInputSchema>;
|
|
14
14
|
export type ExecuteClientSideRequestToolOutput = Result<{
|
|
15
15
|
status: number;
|
|
16
16
|
responseBody?: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute-request.d.ts","sourceRoot":"","sources":["../../../src/entities/tools/execute-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,
|
|
1
|
+
{"version":3,"file":"execute-request.d.ts","sourceRoot":"","sources":["../../../src/entities/tools/execute-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAoC,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAElF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAEhE,eAAO,MAAM,qCAAqC,EAAG,iBAA0B,CAAA;AAE/E,eAAO,MAAM,uCAAuC;;;;;;;EAOlD,CAAA;AAEF,MAAM,MAAM,iCAAiC,GAAG,MAAM,CAAC,OAAO,uCAAuC,CAAC,CAAA;AAEtG,MAAM,MAAM,kCAAkC,GAAG,MAAM,CACrD;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,EAAE,CAAA;CAAE,EACrD,cAAc,CACZ,+BAA+B,EAC/B;IACE,aAAa,EAAE,OAAO,CAAA;CACvB,CACF,GACD,cAAc,CACZ,gBAAgB,EAChB;IACE,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,MAAM,CAAA;IACX,YAAY,EAAE,OAAO,CAAA;IACrB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAChC,CACF,GACD,cAAc,CACZ,iBAAiB,EACjB;IACE,aAAa,EAAE,OAAO,CAAA;CACvB,CACF,GACD,cAAc,CACZ,2CAA2C,EAC3C;IACE,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;CACb,CACF,GACD,cAAc,CAAC,8BAA8B,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,kBAAkB,EAAE,MAAM,CAAA;CAAE,CAAC,GACjH,cAAc,CAAC,2BAA2B,EAAE,OAAO,CAAC,CACvD,CAAA"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { object, optional, record, string } from "@scalar/validation";
|
|
2
2
|
//#region src/entities/tools/execute-request.ts
|
|
3
3
|
var EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME = "execute-request";
|
|
4
|
-
var executeClientSideRequestToolInputSchema =
|
|
5
|
-
method:
|
|
6
|
-
path:
|
|
7
|
-
headers:
|
|
8
|
-
body:
|
|
9
|
-
documentName:
|
|
10
|
-
documentIdentifier:
|
|
4
|
+
var executeClientSideRequestToolInputSchema = object({
|
|
5
|
+
method: string(),
|
|
6
|
+
path: string(),
|
|
7
|
+
headers: optional(record(string(), string())),
|
|
8
|
+
body: optional(string()),
|
|
9
|
+
documentName: string(),
|
|
10
|
+
documentIdentifier: string({ typeComment: "Needed for legacy support for old clients" })
|
|
11
11
|
});
|
|
12
12
|
//#endregion
|
|
13
13
|
export { EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME, executeClientSideRequestToolInputSchema };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute-request.js","names":[],"sources":["../../../src/entities/tools/execute-request.ts"],"sourcesContent":["import type { Result } from 'neverpanic'\nimport {
|
|
1
|
+
{"version":3,"file":"execute-request.js","names":[],"sources":["../../../src/entities/tools/execute-request.ts"],"sourcesContent":["import type { Result } from 'neverpanic'\nimport { object, optional, record, string, type Static } from '@scalar/validation'\n\nimport type { AgentChatError } from '@/entities/error/constants'\n\nexport const EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME = 'execute-request' as const\n\nexport const executeClientSideRequestToolInputSchema = object({\n method: string(),\n path: string(),\n headers: optional(record(string(), string())),\n body: optional(string()),\n documentName: string(),\n documentIdentifier: string({ typeComment: 'Needed for legacy support for old clients' }),\n})\n\nexport type ExecuteClientSideRequestToolInput = Static<typeof executeClientSideRequestToolInputSchema>\n\nexport type ExecuteClientSideRequestToolOutput = Result<\n { status: number; responseBody?: unknown; headers: {} },\n | AgentChatError<\n 'FAILED_TO_PARSE_RESPONSE_BODY',\n {\n originalError: unknown\n }\n >\n | AgentChatError<\n 'REQUEST_NOT_OK',\n {\n status: number\n url: string\n responseBody: unknown\n headers: Record<string, string>\n }\n >\n | AgentChatError<\n 'FAILED_TO_FETCH',\n {\n originalError: unknown\n }\n >\n | AgentChatError<\n 'DOCUMENT_SETTINGS_COULD_NOT_BE_DETERMINED',\n {\n documentName: string\n namespace: string\n slug: string\n }\n >\n | AgentChatError<'FAILED_TO_DETERMINE_DOCUMENT', { namespace?: string; slug?: string; documentIdentifier: string }>\n | AgentChatError<'FAILED_TO_EXECUTE_REQUEST', unknown>\n>\n"],"mappings":";;AAKA,IAAa,wCAAwC;AAErD,IAAa,0CAA0C,OAAO;CAC5D,QAAQ,QAAQ;CAChB,MAAM,QAAQ;CACd,SAAS,SAAS,OAAO,QAAQ,EAAE,QAAQ,CAAC,CAAC;CAC7C,MAAM,SAAS,QAAQ,CAAC;CACxB,cAAc,QAAQ;CACtB,oBAAoB,OAAO,EAAE,aAAa,6CAA6C,CAAC;CACzF,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { OpenAPIV3_1 } from '@scalar/openapi-types';
|
|
2
|
-
import {
|
|
2
|
+
import { type Static } from '@scalar/validation';
|
|
3
3
|
export declare const SEARCH_OPENAPI_OPERATIONS_TOOL_NAME: "search-openapi-operations";
|
|
4
|
-
export declare const searchOpenAPIOperationsInputSchema:
|
|
5
|
-
question:
|
|
6
|
-
}
|
|
7
|
-
export type SearchOpenAPIOperationsToolInput =
|
|
4
|
+
export declare const searchOpenAPIOperationsInputSchema: import("@scalar/validation").ObjectSchema<{
|
|
5
|
+
question: import("@scalar/validation").StringSchema;
|
|
6
|
+
}>;
|
|
7
|
+
export type SearchOpenAPIOperationsToolInput = Static<typeof searchOpenAPIOperationsInputSchema>;
|
|
8
8
|
export type SearchOpenAPIOperationsToolOutput = Partial<OpenAPIV3_1.Document>[];
|
|
9
9
|
//# sourceMappingURL=search-openapi-operations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-openapi-operations.d.ts","sourceRoot":"","sources":["../../../src/entities/tools/search-openapi-operations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,
|
|
1
|
+
{"version":3,"file":"search-openapi-operations.d.ts","sourceRoot":"","sources":["../../../src/entities/tools/search-openapi-operations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAkB,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAEhE,eAAO,MAAM,mCAAmC,EAAG,2BAAoC,CAAA;AAEvF,eAAO,MAAM,kCAAkC;;EAE7C,CAAA;AAEF,MAAM,MAAM,gCAAgC,GAAG,MAAM,CAAC,OAAO,kCAAkC,CAAC,CAAA;AAEhG,MAAM,MAAM,iCAAiC,GAAG,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { object, string } from "@scalar/validation";
|
|
2
2
|
//#region src/entities/tools/search-openapi-operations.ts
|
|
3
3
|
var SEARCH_OPENAPI_OPERATIONS_TOOL_NAME = "search-openapi-operations";
|
|
4
|
-
var searchOpenAPIOperationsInputSchema =
|
|
4
|
+
var searchOpenAPIOperationsInputSchema = object({ question: string() });
|
|
5
5
|
//#endregion
|
|
6
6
|
export { SEARCH_OPENAPI_OPERATIONS_TOOL_NAME, searchOpenAPIOperationsInputSchema };
|
|
7
7
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-openapi-operations.js","names":[],"sources":["../../../src/entities/tools/search-openapi-operations.ts"],"sourcesContent":["import type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport {
|
|
1
|
+
{"version":3,"file":"search-openapi-operations.js","names":[],"sources":["../../../src/entities/tools/search-openapi-operations.ts"],"sourcesContent":["import type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { object, string, type Static } from '@scalar/validation'\n\nexport const SEARCH_OPENAPI_OPERATIONS_TOOL_NAME = 'search-openapi-operations' as const\n\nexport const searchOpenAPIOperationsInputSchema = object({\n question: string(),\n})\n\nexport type SearchOpenAPIOperationsToolInput = Static<typeof searchOpenAPIOperationsInputSchema>\n\nexport type SearchOpenAPIOperationsToolOutput = Partial<OpenAPIV3_1.Document>[]\n"],"mappings":";;AAGA,IAAa,sCAAsC;AAEnD,IAAa,qCAAqC,OAAO,EACvD,UAAU,QAAQ,EACnB,CAAC"}
|
package/dist/helpers.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { type Auth } from '@scalar/workspace-store/entities/auth';
|
|
|
4
4
|
import type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example';
|
|
5
5
|
import type { OperationObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
|
|
6
6
|
export declare function getOperations(doc: Partial<OpenAPIV3_1.Document>): OperationObject[];
|
|
7
|
-
/** Generate document settings from workspace store */
|
|
7
|
+
/** Generate document settings from workspace store. AsyncAPI docs are skipped — this feature is OpenAPI-native. */
|
|
8
8
|
export declare function createDocumentSettings(workspaceStore: WorkspaceStore): {
|
|
9
9
|
[k: string]: {
|
|
10
10
|
activeServer: import("@scalar/workspace-store/schemas/v3.1/strict/server").ServerObject | null;
|
package/dist/helpers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAE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,EAAE,MAAM,OAM1C"}
|
package/dist/helpers.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getSecurityRequirements, getSecuritySchemes, getSelectedSecurity, getSelectedServer, getServers, mergeSecurity } from "@scalar/workspace-store/request-example";
|
|
2
2
|
import { REFERENCE_LS_KEYS, safeLocalStorage } from "@scalar/helpers/object/local-storage";
|
|
3
3
|
import { AuthSchema } from "@scalar/workspace-store/entities/auth";
|
|
4
|
+
import { isOpenApiDocument } from "@scalar/workspace-store/schemas/type-guards";
|
|
4
5
|
import { coerceValue } from "@scalar/workspace-store/schemas/typebox-coerce";
|
|
5
6
|
//#region src/helpers.ts
|
|
6
7
|
function getOperations(doc) {
|
|
@@ -16,11 +17,13 @@ function getSecurityFromDocument(documentName, document, authStore) {
|
|
|
16
17
|
}), void 0, securityRequirements);
|
|
17
18
|
return getSecuritySchemes(mergedSecurity, selectedSecurity.selectedSchemes[selectedSecurity.selectedIndex] ?? {});
|
|
18
19
|
}
|
|
19
|
-
/** Generate document settings from workspace store */
|
|
20
|
+
/** Generate document settings from workspace store. AsyncAPI docs are skipped — this feature is OpenAPI-native. */
|
|
20
21
|
function createDocumentSettings(workspaceStore) {
|
|
21
|
-
|
|
22
|
+
const openApiEntries = [];
|
|
23
|
+
for (const [key, document] of Object.entries(workspaceStore.workspace.documents)) if (isOpenApiDocument(document)) openApiEntries.push([key, document]);
|
|
24
|
+
return Object.fromEntries(openApiEntries.map(([key, document]) => {
|
|
22
25
|
return [key, {
|
|
23
|
-
activeServer: getSelectedServer(document, null, null, getServers(document.servers, { documentUrl: document
|
|
26
|
+
activeServer: getSelectedServer(document, null, null, getServers(document.servers, { documentUrl: document["x-scalar-original-source-url"] })),
|
|
24
27
|
securitySchemes: getSecurityFromDocument(key, document, workspaceStore.auth)
|
|
25
28
|
}];
|
|
26
29
|
}));
|
package/dist/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","names":[],"sources":["../src/helpers.ts"],"sourcesContent":["import { REFERENCE_LS_KEYS, safeLocalStorage } from '@scalar/helpers/object/local-storage'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport type { AuthStore } from '@scalar/workspace-store/entities/auth'\nimport { type Auth, AuthSchema } from '@scalar/workspace-store/entities/auth'\nimport type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport {\n getSecurityRequirements,\n getSecuritySchemes,\n getSelectedSecurity,\n getSelectedServer,\n getServers,\n mergeSecurity,\n} from '@scalar/workspace-store/request-example'\nimport
|
|
1
|
+
{"version":3,"file":"helpers.js","names":[],"sources":["../src/helpers.ts"],"sourcesContent":["import { REFERENCE_LS_KEYS, safeLocalStorage } from '@scalar/helpers/object/local-storage'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport type { AuthStore } from '@scalar/workspace-store/entities/auth'\nimport { type Auth, AuthSchema } from '@scalar/workspace-store/entities/auth'\nimport type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport {\n getSecurityRequirements,\n getSecuritySchemes,\n getSelectedSecurity,\n getSelectedServer,\n getServers,\n mergeSecurity,\n} from '@scalar/workspace-store/request-example'\nimport { isOpenApiDocument } from '@scalar/workspace-store/schemas/type-guards'\nimport { coerceValue } from '@scalar/workspace-store/schemas/typebox-coerce'\nimport type { OpenApiDocument, OperationObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\nexport function getOperations(doc: Partial<OpenAPIV3_1.Document>) {\n return Object.values(doc.paths ?? {}).flatMap((path) => Object.values(path ?? {})) as OperationObject[]\n}\n\n/** Flattens all security requirements from a document */\nfunction getSecurityFromDocument(\n documentName: string,\n document: OpenApiDocument,\n authStore: AuthStore,\n): SecuritySchemeObjectSecret[] {\n const mergedSecurity = mergeSecurity(document?.components?.securitySchemes, {}, authStore, documentName)\n\n const securityRequirements = getSecurityRequirements(document.security)\n\n const selectedSecurity = getSelectedSecurity(\n authStore.getAuthSelectedSchemas({\n type: 'document',\n documentName,\n }),\n undefined,\n securityRequirements,\n )\n\n return getSecuritySchemes(mergedSecurity, selectedSecurity.selectedSchemes[selectedSecurity.selectedIndex] ?? {})\n}\n\n/** Generate document settings from workspace store. AsyncAPI docs are skipped — this feature is OpenAPI-native. */\nexport function createDocumentSettings(workspaceStore: WorkspaceStore) {\n const openApiEntries: [string, OpenApiDocument][] = []\n for (const [key, document] of Object.entries(workspaceStore.workspace.documents)) {\n if (isOpenApiDocument(document)) {\n openApiEntries.push([key, document])\n }\n }\n\n return Object.fromEntries(\n openApiEntries.map(([key, document]) => {\n const servers = getServers(document.servers, {\n documentUrl: document['x-scalar-original-source-url'],\n })\n\n return [\n key,\n {\n activeServer: getSelectedServer(document, null, null, servers),\n securitySchemes: getSecurityFromDocument(key, document, workspaceStore.auth),\n },\n ]\n }),\n )\n}\n\n// Local storage helper instance, safely wrapped.\nconst storage = safeLocalStorage()\n\n/**\n * Provides an interface to store and retrieve authentication scheme\n * information in local storage, including both the available schemes and\n * the user's selected schemes.\n */\nexport const authStorage = () => {\n const getKey = (slug: string) => {\n return `${REFERENCE_LS_KEYS.AUTH}-${slug}`\n }\n\n return {\n /**\n * Retrieves and coerces the authentication schemes stored in local storage.\n */\n getAuth: (slug: string) => {\n const parsed = JSON.parse(storage.getItem(getKey(slug)) ?? '{}')\n return coerceValue(AuthSchema, parsed)\n },\n /**\n * Stores the authentication schemes in local storage.\n * @param value The Auth object to stringify and store.\n */\n setAuth: (slug: string, value: Auth) => {\n storage.setItem(getKey(slug), JSON.stringify(value))\n },\n }\n}\n\n/**\n * Restores authentication secrets from local storage to the workspace store.\n *\n * This function iterates through stored authentication schemes and restores\n * any secret values (keys starting with x-scalar-secret-) to the active\n * document's security schemes. It uses the current security schemes as the\n * source of truth, only restoring secrets for structures that exist in the\n * current document.\n */\nexport const restoreAuthSecretsFromStorage = ({\n documentName,\n workspaceStore,\n}: {\n documentName: string\n workspaceStore: WorkspaceStore\n}): void => {\n const authPersistence = authStorage()\n const auth = authPersistence.getAuth(documentName)\n workspaceStore.auth.load({ [documentName]: auth })\n}\n\nexport function safeParseJson(value: string) {\n try {\n return JSON.parse(value)\n } catch {\n return\n }\n}\n"],"mappings":";;;;;;AAkBA,SAAgB,cAAc,KAAoC;AAChE,QAAO,OAAO,OAAO,IAAI,SAAS,EAAE,CAAC,CAAC,SAAS,SAAS,OAAO,OAAO,QAAQ,EAAE,CAAC,CAAC;;;AAIpF,SAAS,wBACP,cACA,UACA,WAC8B;CAC9B,MAAM,iBAAiB,cAAc,UAAU,YAAY,iBAAiB,EAAE,EAAE,WAAW,aAAa;CAExG,MAAM,uBAAuB,wBAAwB,SAAS,SAAS;CAEvE,MAAM,mBAAmB,oBACvB,UAAU,uBAAuB;EAC/B,MAAM;EACN;EACD,CAAC,EACF,KAAA,GACA,qBACD;AAED,QAAO,mBAAmB,gBAAgB,iBAAiB,gBAAgB,iBAAiB,kBAAkB,EAAE,CAAC;;;AAInH,SAAgB,uBAAuB,gBAAgC;CACrE,MAAM,iBAA8C,EAAE;AACtD,MAAK,MAAM,CAAC,KAAK,aAAa,OAAO,QAAQ,eAAe,UAAU,UAAU,CAC9E,KAAI,kBAAkB,SAAS,CAC7B,gBAAe,KAAK,CAAC,KAAK,SAAS,CAAC;AAIxC,QAAO,OAAO,YACZ,eAAe,KAAK,CAAC,KAAK,cAAc;AAKtC,SAAO,CACL,KACA;GACE,cAAc,kBAAkB,UAAU,MAAM,MAPpC,WAAW,SAAS,SAAS,EAC3C,aAAa,SAAS,iCACvB,CAAC,CAKgE;GAC9D,iBAAiB,wBAAwB,KAAK,UAAU,eAAe,KAAK;GAC7E,CACF;GACD,CACH;;AAIH,IAAM,UAAU,kBAAkB;;;;;;AAOlC,IAAa,oBAAoB;CAC/B,MAAM,UAAU,SAAiB;AAC/B,SAAO,GAAG,kBAAkB,KAAK,GAAG;;AAGtC,QAAO;EAIL,UAAU,SAAiB;AAEzB,UAAO,YAAY,YADJ,KAAK,MAAM,QAAQ,QAAQ,OAAO,KAAK,CAAC,IAAI,KAAK,CAC1B;;EAMxC,UAAU,MAAc,UAAgB;AACtC,WAAQ,QAAQ,OAAO,KAAK,EAAE,KAAK,UAAU,MAAM,CAAC;;EAEvD;;;;;;;;;;;AAYH,IAAa,iCAAiC,EAC5C,cACA,qBAIU;CAEV,MAAM,OADkB,aAAa,CACR,QAAQ,aAAa;AAClD,gBAAe,KAAK,KAAK,GAAG,eAAe,MAAM,CAAC;;AAGpD,SAAgB,cAAc,OAAe;AAC3C,KAAI;AACF,SAAO,KAAK,MAAM,MAAM;SAClB;AACN"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const chatErrorSchema:
|
|
3
|
-
message:
|
|
4
|
-
code:
|
|
5
|
-
status:
|
|
6
|
-
}
|
|
7
|
-
export type ChatError =
|
|
8
|
-
export declare function useChatError(): import("vue").ComputedRef<{
|
|
1
|
+
import { type Static } from '@scalar/validation';
|
|
2
|
+
declare const chatErrorSchema: import("@scalar/validation").ObjectSchema<{
|
|
3
|
+
message: import("@scalar/validation").StringSchema;
|
|
4
|
+
code: import("@scalar/validation").StringSchema;
|
|
5
|
+
status: import("@scalar/validation").OptionalSchema<import("@scalar/validation").NumberSchema>;
|
|
6
|
+
}>;
|
|
7
|
+
export type ChatError = Static<typeof chatErrorSchema>;
|
|
8
|
+
export declare function useChatError(): import("vue").ComputedRef<({
|
|
9
9
|
message: string;
|
|
10
10
|
code: string;
|
|
11
|
+
} & {
|
|
11
12
|
status?: number | undefined;
|
|
12
|
-
} | undefined>;
|
|
13
|
+
}) | undefined>;
|
|
13
14
|
export {};
|
|
14
15
|
//# sourceMappingURL=use-chat-error.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-chat-error.d.ts","sourceRoot":"","sources":["../../src/hooks/use-chat-error.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-chat-error.d.ts","sourceRoot":"","sources":["../../src/hooks/use-chat-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsD,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAMpG,QAAA,MAAM,eAAe;;;;EAInB,CAAA;AACF,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,eAAe,CAAC,CAAA;AAEtD,wBAAgB,YAAY;;;;;gBAgB3B"}
|
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
import { safeParseJson } from "../helpers.js";
|
|
2
2
|
import { useState } from "../state/state.js";
|
|
3
3
|
import { computed } from "vue";
|
|
4
|
-
import {
|
|
4
|
+
import { coerce, number, object, optional, string, validate } from "@scalar/validation";
|
|
5
5
|
//#region src/hooks/use-chat-error.ts
|
|
6
|
-
var chatErrorSchema =
|
|
7
|
-
message:
|
|
8
|
-
code:
|
|
9
|
-
status:
|
|
6
|
+
var chatErrorSchema = object({
|
|
7
|
+
message: string(),
|
|
8
|
+
code: string(),
|
|
9
|
+
status: optional(number())
|
|
10
10
|
});
|
|
11
11
|
function useChatError() {
|
|
12
12
|
const { chat } = useState();
|
|
13
13
|
return computed(() => {
|
|
14
14
|
if (!chat.error) return;
|
|
15
15
|
const errorJson = safeParseJson(chat.error.message);
|
|
16
|
-
|
|
17
|
-
if (!errorJson || !parsedError.success) return {
|
|
16
|
+
if (!errorJson || !validate(chatErrorSchema, errorJson)) return {
|
|
18
17
|
message: chat.error.message,
|
|
19
18
|
code: "UNKNOWN_ERROR"
|
|
20
19
|
};
|
|
21
|
-
return
|
|
20
|
+
return coerce(chatErrorSchema, errorJson);
|
|
22
21
|
});
|
|
23
22
|
}
|
|
24
23
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-chat-error.js","names":[],"sources":["../../src/hooks/use-chat-error.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"use-chat-error.js","names":[],"sources":["../../src/hooks/use-chat-error.ts"],"sourcesContent":["import { coerce, number, object, optional, string, validate, type Static } from '@scalar/validation'\nimport { computed } from 'vue'\n\nimport { safeParseJson } from '@/helpers'\nimport { useState } from '@/state/state'\n\nconst chatErrorSchema = object({\n message: string(),\n code: string(),\n status: optional(number()),\n})\nexport type ChatError = Static<typeof chatErrorSchema>\n\nexport function useChatError() {\n const { chat } = useState()\n\n return computed(() => {\n if (!chat.error) return\n\n const errorJson = safeParseJson(chat.error.message)\n\n if (!errorJson || !validate(chatErrorSchema, errorJson))\n return {\n message: chat.error.message,\n code: 'UNKNOWN_ERROR',\n }\n\n return coerce(chatErrorSchema, errorJson)\n })\n}\n"],"mappings":";;;;;AAMA,IAAM,kBAAkB,OAAO;CAC7B,SAAS,QAAQ;CACjB,MAAM,QAAQ;CACd,QAAQ,SAAS,QAAQ,CAAC;CAC3B,CAAC;AAGF,SAAgB,eAAe;CAC7B,MAAM,EAAE,SAAS,UAAU;AAE3B,QAAO,eAAe;AACpB,MAAI,CAAC,KAAK,MAAO;EAEjB,MAAM,YAAY,cAAc,KAAK,MAAM,QAAQ;AAEnD,MAAI,CAAC,aAAa,CAAC,SAAS,iBAAiB,UAAU,CACrD,QAAO;GACL,SAAS,KAAK,MAAM;GACpB,MAAM;GACP;AAEH,SAAO,OAAO,iBAAiB,UAAU;GACzC"}
|
|
@@ -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;
|
|
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;mCASU,MAAM;;;;;;EAqFnD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useState } from "../state/state.js";
|
|
2
2
|
import { ref } from "vue";
|
|
3
|
+
import { coerce, object, string, validate } from "@scalar/validation";
|
|
3
4
|
import { redirectToProxy } from "@scalar/helpers/url/redirect-to-proxy";
|
|
4
|
-
import { z } from "zod/mini";
|
|
5
5
|
//#region src/hooks/use-upload-tmp-document.ts
|
|
6
6
|
var SHOW_UPLOAD_SUCCESS_DELAY = 5e3;
|
|
7
7
|
var TMP_DOC_LS_KEY = "scalar-tmp-doc";
|
|
@@ -11,13 +11,14 @@ function saveTmpDocumentInLocalStorage({ namespace, slug }) {
|
|
|
11
11
|
slug
|
|
12
12
|
}));
|
|
13
13
|
}
|
|
14
|
+
var tmpDocSchema = object({
|
|
15
|
+
namespace: string(),
|
|
16
|
+
slug: string()
|
|
17
|
+
});
|
|
14
18
|
function getTmpDocFromLocalStorage() {
|
|
15
19
|
const tmpDoc = localStorage.getItem(TMP_DOC_LS_KEY);
|
|
16
20
|
if (!tmpDoc) return;
|
|
17
|
-
return
|
|
18
|
-
namespace: z.string(),
|
|
19
|
-
slug: z.string()
|
|
20
|
-
}).parse(JSON.parse(tmpDoc));
|
|
21
|
+
return coerce(tmpDocSchema, JSON.parse(tmpDoc));
|
|
21
22
|
}
|
|
22
23
|
function removeTmpDocFromLocalStorage() {
|
|
23
24
|
if (!localStorage.getItem(TMP_DOC_LS_KEY)) return;
|
|
@@ -49,27 +50,28 @@ function useUploadTmpDocument() {
|
|
|
49
50
|
return;
|
|
50
51
|
}
|
|
51
52
|
const json = await response.json();
|
|
52
|
-
const
|
|
53
|
-
url:
|
|
54
|
-
namespace:
|
|
55
|
-
slug:
|
|
56
|
-
})
|
|
57
|
-
if (!
|
|
53
|
+
const uploadResponseSchema = object({
|
|
54
|
+
url: string(),
|
|
55
|
+
namespace: string(),
|
|
56
|
+
slug: string()
|
|
57
|
+
});
|
|
58
|
+
if (!validate(uploadResponseSchema, json)) {
|
|
58
59
|
uploadState.value = {
|
|
59
60
|
type: "error",
|
|
60
61
|
error: "Failed to process document."
|
|
61
62
|
};
|
|
62
63
|
return;
|
|
63
64
|
}
|
|
65
|
+
const uploadData = coerce(uploadResponseSchema, json);
|
|
64
66
|
uploadState.value = { type: "processing" };
|
|
65
|
-
const embeddingStatusResponse = await fetch(createUrl(`/vector/registry/embeddings/${
|
|
67
|
+
const embeddingStatusResponse = await fetch(createUrl(`/vector/registry/embeddings/${uploadData.namespace}/${uploadData.slug}`), { method: "GET" });
|
|
66
68
|
saveTmpDocumentInLocalStorage({
|
|
67
|
-
namespace:
|
|
68
|
-
slug:
|
|
69
|
+
namespace: uploadData.namespace,
|
|
70
|
+
slug: uploadData.slug
|
|
69
71
|
});
|
|
70
72
|
await state.addDocument({
|
|
71
|
-
namespace:
|
|
72
|
-
slug:
|
|
73
|
+
namespace: uploadData.namespace,
|
|
74
|
+
slug: uploadData.slug,
|
|
73
75
|
removable: false,
|
|
74
76
|
tmp: true
|
|
75
77
|
});
|
|
@@ -81,11 +83,11 @@ function useUploadTmpDocument() {
|
|
|
81
83
|
return;
|
|
82
84
|
}
|
|
83
85
|
uploadState.value = { type: "done" };
|
|
84
|
-
state.uploadedTmpDocumentUrl.value =
|
|
86
|
+
state.uploadedTmpDocumentUrl.value = uploadData.url;
|
|
85
87
|
setTimeout(() => {
|
|
86
88
|
uploadState.value = void 0;
|
|
87
89
|
}, SHOW_UPLOAD_SUCCESS_DELAY);
|
|
88
|
-
return
|
|
90
|
+
return uploadData;
|
|
89
91
|
} catch {
|
|
90
92
|
uploadState.value = {
|
|
91
93
|
type: "error",
|