@scalar/agent-chat 0.3.1 → 0.3.3

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.
Files changed (65) hide show
  1. package/dist/App.vue.d.ts +4 -5
  2. package/dist/App.vue.d.ts.map +1 -1
  3. package/dist/App.vue.js +16 -14
  4. package/dist/Chat.vue.d.ts.map +1 -1
  5. package/dist/Chat.vue.js +43 -16
  6. package/dist/api.d.ts +53 -2
  7. package/dist/api.d.ts.map +1 -1
  8. package/dist/api.js +67 -37
  9. package/dist/components/ApprovalSection.vue.d.ts.map +1 -1
  10. package/dist/components/ApprovalSection.vue.js +1 -1
  11. package/dist/components/ApprovalSection.vue2.js +19 -28
  12. package/dist/components/AuthenticationProvided.vue.js +8 -8
  13. package/dist/components/PaymentSection.vue.d.ts +1 -7
  14. package/dist/components/PaymentSection.vue.d.ts.map +1 -1
  15. package/dist/components/PaymentSection.vue.js +2 -2
  16. package/dist/components/PaymentSection.vue2.js +21 -21
  17. package/dist/components/ResponseBody/helpers/media-types.d.ts +0 -4
  18. package/dist/components/ResponseBody/helpers/media-types.d.ts.map +1 -1
  19. package/dist/components/ResponseBody/helpers/media-types.js +0 -1
  20. package/dist/entities/index.d.ts +1 -0
  21. package/dist/entities/index.d.ts.map +1 -1
  22. package/dist/entities/index.js +17 -15
  23. package/dist/entities/registry/document.d.ts +3 -1
  24. package/dist/entities/registry/document.d.ts.map +1 -1
  25. package/dist/helpers.d.ts +8 -67
  26. package/dist/helpers.d.ts.map +1 -1
  27. package/dist/helpers.js +67 -57
  28. package/dist/hooks/use-agent-key-documents.d.ts +2 -0
  29. package/dist/hooks/use-agent-key-documents.d.ts.map +1 -0
  30. package/dist/hooks/use-agent-key-documents.js +16 -0
  31. package/dist/hooks/use-curated-documents.d.ts +2 -0
  32. package/dist/hooks/use-curated-documents.d.ts.map +1 -0
  33. package/dist/hooks/use-curated-documents.js +12 -0
  34. package/dist/hooks/use-search.d.ts +4 -8
  35. package/dist/hooks/use-search.d.ts.map +1 -1
  36. package/dist/hooks/use-search.js +14 -18
  37. package/dist/hooks/use-term-and-conditions.d.ts +0 -1
  38. package/dist/hooks/use-term-and-conditions.d.ts.map +1 -1
  39. package/dist/hooks/use-term-and-conditions.js +0 -1
  40. package/dist/hooks/use-upload-tmp-document.d.ts +6 -2
  41. package/dist/hooks/use-upload-tmp-document.d.ts.map +1 -1
  42. package/dist/hooks/use-upload-tmp-document.js +45 -23
  43. package/dist/package.json +1 -1
  44. package/dist/registry/add-documents-to-store.d.ts +6 -5
  45. package/dist/registry/add-documents-to-store.d.ts.map +1 -1
  46. package/dist/registry/add-documents-to-store.js +16 -20
  47. package/dist/state/state.d.ts +16 -7
  48. package/dist/state/state.d.ts.map +1 -1
  49. package/dist/state/state.js +92 -78
  50. package/dist/style.css +1 -1
  51. package/dist/views/Chat/Chat.vue.js +2 -2
  52. package/dist/views/Chat/Messages/AskForAuthentication.vue.js +1 -1
  53. package/dist/views/PromptForm.vue.d.ts.map +1 -1
  54. package/dist/views/PromptForm.vue.js +2 -2
  55. package/dist/views/PromptForm.vue2.js +118 -104
  56. package/dist/views/Settings/DocSettings.vue.d.ts.map +1 -1
  57. package/dist/views/Settings/DocSettings.vue.js +2 -2
  58. package/dist/views/Settings/Settings.vue.d.ts.map +1 -1
  59. package/dist/views/Settings/Settings.vue.js +2 -2
  60. package/dist/views/Settings/Settings.vue2.js +33 -31
  61. package/package.json +8 -8
  62. package/dist/components/Suggestion.vue.d.ts +0 -10
  63. package/dist/components/Suggestion.vue.d.ts.map +0 -1
  64. package/dist/components/TestRequestButton.vue.d.ts +0 -8
  65. package/dist/components/TestRequestButton.vue.d.ts.map +0 -1
@@ -1,21 +1,23 @@
1
1
  import { AgentErrorCodes as e } from "./error/constants.js";
2
2
  import { createError as E } from "./error/helpers.js";
3
- import { registryApiMetadata as A } from "./registry/document.js";
4
- import { ASK_FOR_AUTHENTICATION_TOOL_NAME as T, askForAuthenticationInputSchema as p } from "./tools/ask-for-authentication.js";
5
- import { TOOL_NAMESPACE_SLUG_DELIMITER as m } from "./tools/constants.js";
6
- import { EXECUTE_REQUEST_TOOL_NAME as S, executeRequestToolInputSchema as N } from "./tools/execute-request.js";
7
- import { GET_MINI_OPENAPI_SPEC_TOOL_NAME as x, getMiniOpenAPIDocToolInputSchema as f } from "./tools/get-mini-openapi-spec.js";
8
- import { GET_OPENAPI_SPECS_SUMMARY_TOOL_NAME as P } from "./tools/get-openapi-spec-summary.js";
3
+ import { MAX_PROMPT_SIZE as A } from "./prompt/constants.js";
4
+ import { registryApiMetadata as T } from "./registry/document.js";
5
+ import { ASK_FOR_AUTHENTICATION_TOOL_NAME as I, askForAuthenticationInputSchema as M } from "./tools/ask-for-authentication.js";
6
+ import { TOOL_NAMESPACE_SLUG_DELIMITER as S } from "./tools/constants.js";
7
+ import { EXECUTE_REQUEST_TOOL_NAME as N, executeRequestToolInputSchema as P } from "./tools/execute-request.js";
8
+ import { GET_MINI_OPENAPI_SPEC_TOOL_NAME as f, getMiniOpenAPIDocToolInputSchema as n } from "./tools/get-mini-openapi-spec.js";
9
+ import { GET_OPENAPI_SPECS_SUMMARY_TOOL_NAME as L } from "./tools/get-openapi-spec-summary.js";
9
10
  export {
10
- T as ASK_FOR_AUTHENTICATION_TOOL_NAME,
11
+ I as ASK_FOR_AUTHENTICATION_TOOL_NAME,
11
12
  e as AgentErrorCodes,
12
- S as EXECUTE_REQUEST_TOOL_NAME,
13
- x as GET_MINI_OPENAPI_SPEC_TOOL_NAME,
14
- P as GET_OPENAPI_SPECS_SUMMARY_TOOL_NAME,
15
- m as TOOL_NAMESPACE_SLUG_DELIMITER,
16
- p as askForAuthenticationInputSchema,
13
+ N as EXECUTE_REQUEST_TOOL_NAME,
14
+ f as GET_MINI_OPENAPI_SPEC_TOOL_NAME,
15
+ L as GET_OPENAPI_SPECS_SUMMARY_TOOL_NAME,
16
+ A as MAX_PROMPT_SIZE,
17
+ S as TOOL_NAMESPACE_SLUG_DELIMITER,
18
+ M as askForAuthenticationInputSchema,
17
19
  E as createError,
18
- N as executeRequestToolInputSchema,
19
- f as getMiniOpenAPIDocToolInputSchema,
20
- A as registryApiMetadata
20
+ P as executeRequestToolInputSchema,
21
+ n as getMiniOpenAPIDocToolInputSchema,
22
+ T as registryApiMetadata
21
23
  };
@@ -9,7 +9,9 @@ export declare const registryApiMetadata: z.ZodObject<{
9
9
  logoUrl: z.ZodNullable<z.ZodURL>;
10
10
  slug: z.ZodString;
11
11
  }, z.core.$strip>;
12
- export type ApiMetadata = z.infer<typeof registryApiMetadata>;
12
+ export type ApiMetadata = z.infer<typeof registryApiMetadata> & {
13
+ removable?: boolean;
14
+ };
13
15
  export type RegistryDocument = {
14
16
  namespace: string;
15
17
  slug: string;
@@ -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,CAAC,MAAM,KAAK,CAAA;AAEnB,eAAO,MAAM,mBAAmB;;;;;;;iBAO9B,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAE7D,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
+ {"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,CAAC,MAAM,KAAK,CAAA;AAEnB,eAAO,MAAM,mBAAmB;;;;;;;iBAO9B,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,GAAG;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,CAAA;AAEvF,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"}
package/dist/helpers.d.ts CHANGED
@@ -1,69 +1,16 @@
1
- import type { MergedSecuritySchemes } from '@scalar/api-client/v2/blocks/scalar-auth-selector-block';
2
1
  import type { OpenAPIV3_1 } from '@scalar/openapi-types';
3
- import type { AuthenticationConfiguration } from '@scalar/types/api-reference';
4
2
  import type { WorkspaceStore } from '@scalar/workspace-store/client';
5
- import type { WorkspaceDocument } from '@scalar/workspace-store/schemas';
6
3
  import type { XScalarSelectedSecurity } from '@scalar/workspace-store/schemas/extensions/security/x-scalar-selected-security';
7
- import type { OpenApiDocument, OperationObject, ParameterObject, PathItemObject, SecurityRequirementObject, SecuritySchemeObject, ServerObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
4
+ import type { OperationObject, SecuritySchemeObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
8
5
  import { type SecuritySchemes } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
9
- import type { ToolUIPart, UIDataTypes, UIMessagePart } from 'ai';
10
- import type { Tools } from './state/state.js';
11
- /** Combine pathItem and operation parameters into a single, dereferenced parameter array */
12
- export declare const combineParams: (pathParams?: PathItemObject["parameters"], operationParams?: OperationObject["parameters"]) => ParameterObject[];
13
- /**
14
- * Iterate through all available servers and pick the first one
15
- *
16
- * @example
17
- * getFirstServer([operation.servers, pathItem.servers, server])
18
- */
19
- export declare function getFirstServer(...availableServers: (ServerObject[] | ServerObject | undefined | null)[]): ServerObject | undefined;
20
- /** Determine if a message part is a tool */
21
- export declare function isToolPart(part: UIMessagePart<UIDataTypes, Tools>): part is ToolUIPart<Tools>;
22
- /**
23
- * Extracts the default scopes for a security scheme.
24
- * Only OAuth2 schemes can have default scopes via the x-default-scopes extension.
25
- */
26
- export declare const getDefaultScopes: (scheme: SecuritySchemeObject | undefined) => string[];
27
- /**
28
- * Determines the default security scheme to use for an operation.
29
- *
30
- * Priority order:
31
- * 1. User-configured preferred security scheme (if provided)
32
- * 2. First security requirement from the OpenAPI spec
33
- * 3. null (no security required)
34
- */
35
- export declare const getDefaultSecurity: (securityRequirements: SecurityRequirementObject[], preferredSecurityScheme: AuthenticationConfiguration["preferredSecurityScheme"], securitySchemes: MergedSecuritySchemes) => SecurityRequirementObject | null;
36
- /**
37
- * Find the intersection between which security is selected on the document and what this operation requires
38
- *
39
- * If there is no overlap, we return the first requirement
40
- */
41
- export declare const filterSelectedSecurity: (document: OpenApiDocument, operation: OperationObject | null, securitySchemes?: MergedSecuritySchemes) => SecuritySchemeObject[];
42
6
  export declare function getOperations(doc: Partial<OpenAPIV3_1.Document>): OperationObject[];
43
- /** Flattens all security requirements from a document */
44
- export declare function getSecurityFromDocument(document: WorkspaceDocument): SecuritySchemeObject[];
45
7
  /** Generate document settings from workspace store */
46
8
  export declare function createDocumentSettings(workspaceStore: WorkspaceStore): {
47
9
  [k: string]: {
48
- activeServer: ServerObject | null;
10
+ activeServer: import("@scalar/workspace-store/schemas/v3.1/strict/server").ServerObject | null;
49
11
  securitySchemes: SecuritySchemeObject[];
50
12
  };
51
13
  };
52
- /**
53
- * Provides an interface to store and retrieve the selected client value
54
- * in local storage.
55
- */
56
- export declare const clientStorage: () => {
57
- /**
58
- * Gets the stored selected client from local storage.
59
- */
60
- get: () => string | null;
61
- /**
62
- * Stores the selected client value in local storage.
63
- * @param value The value to store
64
- */
65
- set: (value: string) => void;
66
- };
67
14
  /**
68
15
  * Provides an interface to store and retrieve authentication scheme
69
16
  * information in local storage, including both the available schemes and
@@ -389,18 +336,6 @@ export declare const authStorage: () => {
389
336
  */
390
337
  setSelectedSchemes: (slug: string, value: XScalarSelectedSecurity) => void;
391
338
  };
392
- /**
393
- * Recursively merges secret values from stored data into the current schema.
394
- * Only merges secrets if the corresponding structure exists in the current schema.
395
- *
396
- * This function walks through both objects in parallel, copying any keys that
397
- * start with 'x-scalar-secret-' from the stored object to the current object,
398
- * but only if the path exists in the current schema.
399
- *
400
- * @param current - The current schema object (source of truth for structure)
401
- * @param stored - The stored object containing secret values to restore
402
- */
403
- export declare const mergeSecrets: (current: unknown, stored: unknown) => void;
404
339
  /**
405
340
  * Restores authentication secrets from local storage to the workspace store.
406
341
  *
@@ -415,4 +350,10 @@ export declare const restoreAuthSecretsFromStorage: ({ documentName, workspaceSt
415
350
  workspaceStore: WorkspaceStore;
416
351
  }) => void;
417
352
  export declare function safeParseJson(value: string): any;
353
+ /**
354
+ * Wrap url with Scalar Proxy
355
+ *
356
+ * Skips wrapping if the url is localhost
357
+ */
358
+ export declare function makeScalarProxyUrl(url: string): string;
418
359
  //# sourceMappingURL=helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yDAAyD,CAAA;AAMpG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAA;AAC9E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAGpE,OAAO,KAAK,EAAE,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H,CAAA;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,OAM1C;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,UAqB7C"}
package/dist/helpers.js CHANGED
@@ -1,111 +1,121 @@
1
1
  import { getSelectedServer as O } from "@scalar/api-client/v2/features/operation";
2
- import { getServers as E } from "@scalar/api-client/v2/helpers";
2
+ import { getServers as x } from "@scalar/api-client/v2/helpers";
3
3
  import { isObject as l } from "@scalar/helpers/object/is-object";
4
- import { REFERENCE_LS_KEYS as d, safeLocalStorage as b } from "@scalar/helpers/object/local-storage";
5
- import { getResolvedRef as u } from "@scalar/workspace-store/helpers/get-resolved-ref";
6
- import { coerceValue as f } from "@scalar/workspace-store/schemas/typebox-coerce";
7
- import { XScalarSelectedSecuritySchema as v, SecuritySchemesSchema as j } from "@scalar/workspace-store/schemas/v3.1/strict/openapi-document";
8
- function R(t) {
9
- return Object.values(t.paths ?? {}).flatMap((c) => Object.values(c ?? {}));
4
+ import { REFERENCE_LS_KEYS as d, safeLocalStorage as v } from "@scalar/helpers/object/local-storage";
5
+ import { getResolvedRef as h } from "@scalar/workspace-store/helpers/get-resolved-ref";
6
+ import { coerceValue as y } from "@scalar/workspace-store/schemas/typebox-coerce";
7
+ import { XScalarSelectedSecuritySchema as b, SecuritySchemesSchema as E } from "@scalar/workspace-store/schemas/v3.1/strict/openapi-document";
8
+ function P(e) {
9
+ return Object.values(e.paths ?? {}).flatMap((c) => Object.values(c ?? {}));
10
10
  }
11
- function x(t) {
12
- const s = (t["x-scalar-selected-security"]?.selectedSchemes ?? []).flatMap((r) => Object.keys(r)), e = t.components?.securitySchemes;
13
- return e ? s.reduce((r, n) => {
14
- const o = e[n];
15
- return o && r.push(u(o)), r;
11
+ function j(e) {
12
+ const s = (e["x-scalar-selected-security"]?.selectedSchemes ?? []).flatMap((r) => Object.keys(r)), t = e.components?.securitySchemes;
13
+ return t ? s.reduce((r, n) => {
14
+ const o = t[n];
15
+ return o && r.push(h(o)), r;
16
16
  }, []) : [];
17
17
  }
18
- function w(t) {
18
+ function C(e) {
19
19
  return Object.fromEntries(
20
- Object.entries(t.workspace.documents).map(([c, s]) => {
21
- const e = E(s.servers, {
20
+ Object.entries(e.workspace.documents).map(([c, s]) => {
21
+ const t = x(s.servers, {
22
22
  documentUrl: s?.["x-scalar-original-source-url"]
23
23
  });
24
24
  return [
25
25
  c,
26
26
  {
27
- activeServer: O(s, e),
28
- securitySchemes: x(s)
27
+ activeServer: O(s, t),
28
+ securitySchemes: j(s)
29
29
  }
30
30
  ];
31
31
  })
32
32
  );
33
33
  }
34
- const a = b(), y = () => {
35
- const t = d.AUTH_SCHEMES, c = d.SELECTED_AUTH_SCHEMES, s = (e, r) => `${r}-${((o) => o === "schemas" ? t : c)(e)}`;
34
+ const m = v(), f = () => {
35
+ const e = d.AUTH_SCHEMES, c = d.SELECTED_AUTH_SCHEMES, s = (t, r) => `${r}-${((o) => o === "schemas" ? e : c)(t)}`;
36
36
  return {
37
37
  /**
38
38
  * Retrieves and coerces the authentication schemes stored in local storage.
39
39
  */
40
- getSchemas: (e) => {
41
- const r = JSON.parse(a.getItem(s("schemas", e)) ?? "{}");
42
- return f(j, r);
40
+ getSchemas: (t) => {
41
+ const r = JSON.parse(m.getItem(s("schemas", t)) ?? "{}");
42
+ return y(E, r);
43
43
  },
44
44
  /**
45
45
  * Stores the authentication schemes in local storage.
46
46
  * @param value The SecuritySchemes object to stringify and store.
47
47
  */
48
- setSchemas: (e, r) => {
49
- a.setItem(s("schemas", e), JSON.stringify(r));
48
+ setSchemas: (t, r) => {
49
+ m.setItem(s("schemas", t), JSON.stringify(r));
50
50
  },
51
51
  /**
52
52
  * Retrieves and coerces the selected authentication schemes stored in local storage.
53
53
  */
54
- getSelectedSchemes: (e) => {
55
- const r = JSON.parse(a.getItem(s("selectedSchemes", e)) ?? "{}");
56
- return f(v, r);
54
+ getSelectedSchemes: (t) => {
55
+ const r = JSON.parse(m.getItem(s("selectedSchemes", t)) ?? "{}");
56
+ return y(b, r);
57
57
  },
58
58
  /**
59
59
  * Stores the user's selected authentication schemes in local storage.
60
60
  * @param value The XScalarSelectedSecurity object to stringify and store.
61
61
  */
62
- setSelectedSchemes: (e, r) => {
63
- a.setItem(s("selectedSchemes", e), JSON.stringify(r));
62
+ setSelectedSchemes: (t, r) => {
63
+ m.setItem(s("selectedSchemes", t), JSON.stringify(r));
64
64
  }
65
65
  };
66
- }, p = (t, c) => {
67
- if (!(!l(t) || !l(c)))
68
- for (const [s, e] of Object.entries(c)) {
69
- if (typeof e != "object") {
70
- t[s] = e;
66
+ }, p = (e, c) => {
67
+ if (!(!l(e) || !l(c)))
68
+ for (const [s, t] of Object.entries(c)) {
69
+ if (typeof t != "object") {
70
+ e[s] = t;
71
71
  continue;
72
72
  }
73
- p(u(t[s]), e);
73
+ p(h(e[s]), t);
74
74
  }
75
- }, I = (t, c) => Object.keys(t).every((s) => c.has(s)), k = (t, c) => t >= c ? c - 1 : t, D = ({
76
- documentName: t,
75
+ }, U = (e, c) => Object.keys(e).every((s) => c.has(s)), I = (e, c) => e >= c ? c - 1 : e, H = ({
76
+ documentName: e,
77
77
  workspaceStore: c
78
78
  }) => {
79
- const s = y().getSchemas(t), e = c.workspace.documents[t];
80
- if (!e)
79
+ const s = f().getSchemas(e), t = c.workspace.documents[e];
80
+ if (!t)
81
81
  return;
82
- const n = y().getSelectedSchemes(t), o = new Set(Object.keys(e.components?.securitySchemes ?? {})), m = n["x-scalar-selected-security"]?.selectedSchemes?.filter((S) => I(S, o));
83
- if (!e["x-scalar-selected-security"] && m && m.length > 0) {
84
- const S = n["x-scalar-selected-security"]?.selectedIndex, i = k(S ?? 0, m.length);
85
- e["x-scalar-selected-security"] = {
82
+ const n = f().getSelectedSchemes(e), o = new Set(Object.keys(t.components?.securitySchemes ?? {})), S = n["x-scalar-selected-security"]?.selectedSchemes?.filter((a) => U(a, o));
83
+ if (!t["x-scalar-selected-security"] && S && S.length > 0) {
84
+ const a = n["x-scalar-selected-security"]?.selectedIndex, i = I(a ?? 0, S.length);
85
+ t["x-scalar-selected-security"] = {
86
86
  selectedIndex: i,
87
- selectedSchemes: m
87
+ selectedSchemes: S
88
88
  };
89
89
  }
90
- const g = e.components?.securitySchemes ?? {};
91
- for (const [S, i] of Object.entries(s)) {
92
- const h = u(g[S]);
93
- l(h) && p(h, i);
90
+ const g = t.components?.securitySchemes ?? {};
91
+ for (const [a, i] of Object.entries(s)) {
92
+ const u = h(g[a]);
93
+ l(u) && p(u, i);
94
94
  }
95
95
  };
96
- function F(t) {
96
+ function M(e) {
97
97
  try {
98
- return JSON.parse(t);
98
+ return JSON.parse(e);
99
99
  } catch {
100
100
  return;
101
101
  }
102
102
  }
103
+ function N(e) {
104
+ try {
105
+ const c = new URL(e);
106
+ if (c.host === "localhost")
107
+ return e;
108
+ const s = new URLSearchParams({ scalar_url: c.toString() });
109
+ return new URL(`https://proxy.scalar.com/?${s}`).toString();
110
+ } catch {
111
+ return console.error(`Invalid URL provided: ${e}`), e;
112
+ }
113
+ }
103
114
  export {
104
- y as authStorage,
105
- w as createDocumentSettings,
106
- R as getOperations,
107
- x as getSecurityFromDocument,
108
- p as mergeSecrets,
109
- D as restoreAuthSecretsFromStorage,
110
- F as safeParseJson
115
+ f as authStorage,
116
+ C as createDocumentSettings,
117
+ P as getOperations,
118
+ N as makeScalarProxyUrl,
119
+ H as restoreAuthSecretsFromStorage,
120
+ M as safeParseJson
111
121
  };
@@ -0,0 +1,2 @@
1
+ export declare function useAgentKeyDocuments(): void;
2
+ //# sourceMappingURL=use-agent-key-documents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-agent-key-documents.d.ts","sourceRoot":"","sources":["../../src/hooks/use-agent-key-documents.ts"],"names":[],"mappings":"AAIA,wBAAgB,oBAAoB,SAkBnC"}
@@ -0,0 +1,16 @@
1
+ import { onMounted as a } from "vue";
2
+ import { useState as m } from "../state/state.js";
3
+ function i() {
4
+ const { api: t, addDocument: o, mode: n, getAgentKey: s } = m();
5
+ a(async () => {
6
+ if (n !== "full" || !s)
7
+ return;
8
+ const e = await t.getKeyDocuments();
9
+ e.success && e.data.documents.forEach(
10
+ ({ namespace: u, slug: c }) => o({ namespace: u, slug: c, removable: !1 })
11
+ );
12
+ });
13
+ }
14
+ export {
15
+ i as useAgentKeyDocuments
16
+ };
@@ -0,0 +1,2 @@
1
+ export declare function useCuratedDocuments(): void;
2
+ //# sourceMappingURL=use-curated-documents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-curated-documents.d.ts","sourceRoot":"","sources":["../../src/hooks/use-curated-documents.ts"],"names":[],"mappings":"AAIA,wBAAgB,mBAAmB,SAYlC"}
@@ -0,0 +1,12 @@
1
+ import { onMounted as s } from "vue";
2
+ import { useState as o } from "../state/state.js";
3
+ function r() {
4
+ const { api: e, curatedDocuments: u } = o();
5
+ s(async () => {
6
+ const t = await e.getCuratedDocuments();
7
+ t.success && (u.value = t.data.results);
8
+ });
9
+ }
10
+ export {
11
+ r as useCuratedDocuments
12
+ };
@@ -1,3 +1,4 @@
1
+ import type { ApiMetadata } from '../entities/registry/document.js';
1
2
  export declare function useSearch(): {
2
3
  query: import("vue").WritableComputedRef<string, string>;
3
4
  results: import("vue").Ref<{
@@ -7,20 +8,15 @@ export declare function useSearch(): {
7
8
  currentVersion: string;
8
9
  logoUrl: string | null;
9
10
  slug: string;
10
- }[], {
11
- id: string;
12
- title: string;
13
- namespace: string;
14
- currentVersion: string;
15
- logoUrl: string | null;
16
- slug: string;
17
- }[] | {
11
+ removable?: boolean | undefined;
12
+ }[], ApiMetadata[] | {
18
13
  id: string;
19
14
  title: string;
20
15
  namespace: string;
21
16
  currentVersion: string;
22
17
  logoUrl: string | null;
23
18
  slug: string;
19
+ removable?: boolean | undefined;
24
20
  }[]>;
25
21
  };
26
22
  //# sourceMappingURL=use-search.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-search.d.ts","sourceRoot":"","sources":["../../src/hooks/use-search.ts"],"names":[],"mappings":"AAOA,wBAAgB,SAAS;;;;;;;;;;;;;;;;;;;;;;;;EAoCxB"}
1
+ {"version":3,"file":"use-search.d.ts","sourceRoot":"","sources":["../../src/hooks/use-search.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAG/D,wBAAgB,SAAS;;;;;;;;;;;;;;;;;;;EAiCxB"}
@@ -1,25 +1,21 @@
1
- import { useDebounceFn as m } from "@vueuse/core";
2
- import { ref as c, computed as f } from "vue";
3
- import { api as i } from "../api.js";
4
- import { useState as p } from "../state/state.js";
5
- function d() {
6
- const { baseUrl: u, getAccessToken: n } = p(), s = c(""), r = m(async (e) => {
7
- const o = await i({
8
- baseUrl: u,
9
- getAccessToken: n
10
- }).search(e);
11
- o.success && (t.value = o.data.results);
12
- }, 200), a = f({
1
+ import { useDebounceFn as a } from "@vueuse/core";
2
+ import { ref as u, computed as f } from "vue";
3
+ import { useState as i } from "../state/state.js";
4
+ function h() {
5
+ const { api: c } = i(), s = u(""), t = a(async (e) => {
6
+ const o = await c.search(e);
7
+ o.success && (r.value = o.data.results);
8
+ }, 200), n = f({
13
9
  get: () => s.value,
14
10
  set: (e) => {
15
- r(e), s.value = e;
11
+ t(e), s.value = e;
16
12
  }
17
- }), t = c([]);
18
- return r(""), {
19
- query: a,
20
- results: t
13
+ }), r = u([]);
14
+ return t(""), {
15
+ query: n,
16
+ results: r
21
17
  };
22
18
  }
23
19
  export {
24
- d as useSearch
20
+ h as useSearch
25
21
  };
@@ -1,4 +1,3 @@
1
- export declare const TERMS_AND_CONDITIONS_LS_KEY = "scalar/agent-terms-accepted";
2
1
  export declare function useTermsAndConditions(): {
3
2
  accepted: import("vue").Ref<boolean, boolean>;
4
3
  accept: () => void;
@@ -1 +1 @@
1
- {"version":3,"file":"use-term-and-conditions.d.ts","sourceRoot":"","sources":["../../src/hooks/use-term-and-conditions.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,2BAA2B,gCAAgC,CAAA;AAExE,wBAAgB,qBAAqB;;;EAapC"}
1
+ {"version":3,"file":"use-term-and-conditions.d.ts","sourceRoot":"","sources":["../../src/hooks/use-term-and-conditions.ts"],"names":[],"mappings":"AAIA,wBAAgB,qBAAqB;;;EAapC"}
@@ -11,6 +11,5 @@ function n() {
11
11
  return { accepted: e, accept: o };
12
12
  }
13
13
  export {
14
- t as TERMS_AND_CONDITIONS_LS_KEY,
15
14
  n as useTermsAndConditions
16
15
  };
@@ -1,4 +1,3 @@
1
- import type { WorkspaceDocument } from '@scalar/workspace-store/schemas';
2
1
  export type UploadTmpDocumentState = {
3
2
  type: 'error';
4
3
  error: unknown;
@@ -9,8 +8,13 @@ export type UploadTmpDocumentState = {
9
8
  } | {
10
9
  type: 'done';
11
10
  };
11
+ export declare function getTmpDocFromLocalStorage(): {
12
+ namespace: string;
13
+ slug: string;
14
+ } | undefined;
12
15
  export declare function useUploadTmpDocument(): {
13
- uploadTempDocument: (document: WorkspaceDocument) => Promise<{
16
+ uploadTempDocument: (document: string) => Promise<{
17
+ url: string;
14
18
  namespace: string;
15
19
  slug: string;
16
20
  } | undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"use-upload-tmp-document.d.ts","sourceRoot":"","sources":["../../src/hooks/use-upload-tmp-document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AAMxE,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,MAAM,CAAA;CAAE,CAAA;AAEpB,wBAAgB,oBAAoB;mCAeU,iBAAiB;;;;;EAgE9D"}
1
+ {"version":3,"file":"use-upload-tmp-document.d.ts","sourceRoot":"","sources":["../../src/hooks/use-upload-tmp-document.ts"],"names":[],"mappings":"AAKA,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,MAAM,CAAA;CAAE,CAAA;AAQpB,wBAAgB,yBAAyB;;;cAYxC;AAED,wBAAgB,oBAAoB;mCAeU,MAAM;;;;;;EA4EnD"}
@@ -1,64 +1,86 @@
1
- import { ref as p } from "vue";
2
- import { z as n } from "zod/mini";
1
+ import { ref as m } from "vue";
2
+ import { z as o } from "zod/mini";
3
3
  import { useState as d } from "../state/state.js";
4
- function g() {
5
- const u = d(), e = p();
6
- function s(r) {
7
- const t = `${u.baseUrl}${r}`;
8
- if (t.startsWith("/")) return t;
9
- const o = new URLSearchParams({ scalar_url: t.toString() });
10
- return new URL(`https://proxy.scalar.com/?${o}`);
4
+ const u = "scalar-tmp-doc";
5
+ function g({ namespace: t, slug: e }) {
6
+ localStorage.setItem(u, JSON.stringify({ namespace: t, slug: e }));
7
+ }
8
+ function v() {
9
+ const t = localStorage.getItem(u);
10
+ if (t)
11
+ return o.object({
12
+ namespace: o.string(),
13
+ slug: o.string()
14
+ }).parse(JSON.parse(t));
15
+ }
16
+ function h() {
17
+ const t = d(), e = m();
18
+ function c(s) {
19
+ const a = `${t.baseUrl}${s}`;
20
+ if (a.startsWith("/")) return a;
21
+ const n = new URLSearchParams({ scalar_url: a.toString() });
22
+ return new URL(`https://proxy.scalar.com/?${n}`);
11
23
  }
12
- async function c(r) {
24
+ async function l(s) {
13
25
  try {
14
26
  e.value = { type: "uploading" };
15
- const t = await fetch(s("/core/share/upload/apis"), {
27
+ const a = await fetch(c("/core/share/upload/apis"), {
16
28
  method: "POST",
17
29
  headers: { "Content-Type": "application/json" },
18
- body: JSON.stringify({ document: JSON.stringify(r) })
30
+ body: JSON.stringify({ document: s })
19
31
  });
20
- if (!t.ok) {
32
+ if (!a.ok) {
21
33
  e.value = {
22
34
  type: "error",
23
35
  error: "Failed to upload document."
24
36
  };
25
37
  return;
26
38
  }
27
- const o = await t.json(), { success: i, data: a } = n.object({ namespace: n.string(), slug: n.string() }).safeParse(o);
28
- if (!i) {
39
+ const n = await a.json(), { success: p, data: r } = o.object({ url: o.string(), namespace: o.string(), slug: o.string() }).safeParse(n);
40
+ if (!p) {
29
41
  e.value = {
30
42
  type: "error",
31
43
  error: "Failed to process document."
32
44
  };
33
45
  return;
34
46
  }
35
- if (e.value = {
47
+ e.value = {
36
48
  type: "processing"
37
- }, !(await fetch(
38
- s(`/vector/registry/embeddings/${a.namespace}/${a.slug}`),
49
+ };
50
+ const i = await fetch(
51
+ c(`/vector/registry/embeddings/${r.namespace}/${r.slug}`),
39
52
  {
40
53
  method: "GET"
41
54
  }
42
- )).ok) {
55
+ );
56
+ if (g({
57
+ namespace: r.namespace,
58
+ slug: r.slug
59
+ }), await t.addDocument({
60
+ namespace: r.namespace,
61
+ slug: r.slug,
62
+ removable: !1
63
+ }), !i.ok) {
43
64
  e.value = {
44
65
  type: "error",
45
66
  error: "Failed to embed document."
46
67
  };
47
68
  return;
48
69
  }
49
- return e.value = { type: "done" }, setTimeout(() => {
70
+ return e.value = { type: "done" }, t.uploadedTmpDocumentUrl.value = r.url, setTimeout(() => {
50
71
  e.value = void 0;
51
- }, 2e3), a;
72
+ }, 2e3), r;
52
73
  } catch {
53
74
  e.value = { type: "error", error: "Failed to upload document." };
54
75
  return;
55
76
  }
56
77
  }
57
78
  return {
58
- uploadTempDocument: c,
79
+ uploadTempDocument: l,
59
80
  uploadState: e
60
81
  };
61
82
  }
62
83
  export {
63
- g as useUploadTmpDocument
84
+ v as getTmpDocFromLocalStorage,
85
+ h as useUploadTmpDocument
64
86
  };
package/dist/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "url": "git+https://github.com/scalar/scalar.git",
11
11
  "directory": "packages/agent-chat"
12
12
  },
13
- "version": "0.3.0",
13
+ "version": "0.3.3",
14
14
  "engines": {
15
15
  "node": ">=20"
16
16
  },