@scalar/agent-chat 0.4.8 → 0.5.2

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 (77) hide show
  1. package/dist/App.vue.d.ts +56 -1
  2. package/dist/App.vue.d.ts.map +1 -1
  3. package/dist/App.vue.js +25 -20
  4. package/dist/Chat.vue.d.ts +5 -1
  5. package/dist/Chat.vue.d.ts.map +1 -1
  6. package/dist/Chat.vue.js +26 -22
  7. package/dist/client-tools/execute-request.d.ts +72 -0
  8. package/dist/client-tools/execute-request.d.ts.map +1 -0
  9. package/dist/client-tools/execute-request.js +92 -0
  10. package/dist/components/ActionsDropdown.vue.d.ts +17 -0
  11. package/dist/components/ActionsDropdown.vue.d.ts.map +1 -0
  12. package/dist/components/ActionsDropdown.vue.js +7 -0
  13. package/dist/components/ActionsDropdown.vue2.js +50 -0
  14. package/dist/components/RequestPreview.vue.d.ts +3 -3
  15. package/dist/components/RequestPreview.vue.d.ts.map +1 -1
  16. package/dist/components/RequestPreview.vue.js +2 -2
  17. package/dist/components/RequestPreview.vue2.js +31 -31
  18. package/dist/entities/index.d.ts +1 -1
  19. package/dist/entities/index.d.ts.map +1 -1
  20. package/dist/entities/index.js +16 -16
  21. package/dist/entities/registry/document.d.ts +1 -0
  22. package/dist/entities/registry/document.d.ts.map +1 -1
  23. package/dist/entities/tools/execute-request.d.ts +27 -34
  24. package/dist/entities/tools/execute-request.d.ts.map +1 -1
  25. package/dist/entities/tools/execute-request.js +5 -4
  26. package/dist/helpers.d.ts +36 -275
  27. package/dist/helpers.d.ts.map +1 -1
  28. package/dist/helpers.js +44 -86
  29. package/dist/hooks/use-chat-approvals.d.ts +17 -10
  30. package/dist/hooks/use-chat-approvals.d.ts.map +1 -1
  31. package/dist/hooks/use-chat-approvals.js +28 -15
  32. package/dist/hooks/use-search.d.ts +2 -0
  33. package/dist/hooks/use-search.d.ts.map +1 -1
  34. package/dist/index.d.ts +1 -0
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/package.json +2 -1
  37. package/dist/plugins/persistance.d.ts +16 -0
  38. package/dist/plugins/persistance.d.ts.map +1 -0
  39. package/dist/plugins/persistance.js +23 -0
  40. package/dist/state/state.d.ts +16 -5
  41. package/dist/state/state.d.ts.map +1 -1
  42. package/dist/state/state.js +148 -101
  43. package/dist/style.css +1 -1
  44. package/dist/views/Catalog/Catalog.vue.d.ts +7 -0
  45. package/dist/views/Catalog/Catalog.vue.d.ts.map +1 -0
  46. package/dist/views/Catalog/Catalog.vue.js +8 -0
  47. package/dist/views/Catalog/Catalog.vue2.js +70 -0
  48. package/dist/views/Chat/Chat.vue.d.ts +2 -0
  49. package/dist/views/Chat/Chat.vue.d.ts.map +1 -1
  50. package/dist/views/Chat/Chat.vue.js +1 -1
  51. package/dist/views/Chat/Chat.vue2.js +36 -35
  52. package/dist/views/Chat/Messages/AskForAuthentication.vue.d.ts.map +1 -1
  53. package/dist/views/Chat/Messages/AskForAuthentication.vue.js +2 -2
  54. package/dist/views/Chat/Messages/AskForAuthentication.vue2.js +50 -52
  55. package/dist/views/Chat/Messages/ExecuteRequestTool.vue.d.ts +2 -2
  56. package/dist/views/Chat/Messages/ExecuteRequestTool.vue.d.ts.map +1 -1
  57. package/dist/views/Chat/Messages/ExecuteRequestTool.vue.js +2 -2
  58. package/dist/views/Chat/Messages/ExecuteRequestTool.vue2.js +8 -7
  59. package/dist/views/Layout.vue.d.ts +2 -0
  60. package/dist/views/Layout.vue.d.ts.map +1 -1
  61. package/dist/views/Layout.vue.js +2 -2
  62. package/dist/views/Layout.vue2.js +16 -14
  63. package/dist/views/PromptForm.vue.d.ts +2 -0
  64. package/dist/views/PromptForm.vue.d.ts.map +1 -1
  65. package/dist/views/PromptForm.vue.js +1 -1
  66. package/dist/views/PromptForm.vue2.js +112 -99
  67. package/dist/views/Settings/Auth.vue.d.ts +2 -2
  68. package/dist/views/Settings/Auth.vue.d.ts.map +1 -1
  69. package/dist/views/Settings/Auth.vue.js +32 -32
  70. package/dist/views/Settings/DocSettings.vue.d.ts.map +1 -1
  71. package/dist/views/Settings/DocSettings.vue.js +1 -1
  72. package/dist/views/Settings/DocSettings.vue2.js +22 -21
  73. package/dist/views/Start.vue.d.ts +2 -0
  74. package/dist/views/Start.vue.d.ts.map +1 -1
  75. package/dist/views/Start.vue.js +2 -2
  76. package/dist/views/Start.vue2.js +22 -21
  77. package/package.json +8 -7
package/dist/helpers.js CHANGED
@@ -1,120 +1,78 @@
1
- import { getSelectedServer as O } from "@scalar/api-client/v2/features/operation";
2
- import { getServers as x } from "@scalar/api-client/v2/helpers";
3
- import { isObject as l } from "@scalar/helpers/object/is-object";
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 E, SecuritySchemesSchema as b } 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 ?? {}));
1
+ import { mergeSecurity as a } from "@scalar/api-client/v2/blocks/scalar-auth-selector-block";
2
+ import { getSelectedServer as c } from "@scalar/api-client/v2/features/operation";
3
+ import { getServers as n } from "@scalar/api-client/v2/helpers";
4
+ import { safeLocalStorage as u, REFERENCE_LS_KEYS as i } from "@scalar/helpers/object/local-storage";
5
+ import { AuthSchema as m } from "@scalar/workspace-store/entities/auth";
6
+ import { coerceValue as h } from "@scalar/workspace-store/schemas/typebox-coerce";
7
+ function U(t) {
8
+ return Object.values(t.paths ?? {}).flatMap((r) => Object.values(r ?? {}));
10
9
  }
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
- }, []) : [];
10
+ function p(t, r, e) {
11
+ return Object.values(a(r?.components?.securitySchemes, {}, e, t));
17
12
  }
18
- function C(e) {
13
+ function x(t) {
19
14
  return Object.fromEntries(
20
- Object.entries(e.workspace.documents).map(([c, s]) => {
21
- const t = x(s.servers, {
22
- documentUrl: s?.["x-scalar-original-source-url"]
15
+ Object.entries(t.workspace.documents).map(([r, e]) => {
16
+ const s = n(e.servers, {
17
+ documentUrl: e?.["x-scalar-original-source-url"]
23
18
  });
24
19
  return [
25
- c,
20
+ r,
26
21
  {
27
- activeServer: O(s, t),
28
- securitySchemes: j(s)
22
+ activeServer: c(e, s),
23
+ securitySchemes: p(r, e, t.auth)
29
24
  }
30
25
  ];
31
26
  })
32
27
  );
33
28
  }
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)}`;
29
+ const o = u(), S = () => {
30
+ const t = (r) => `${i.AUTH}-${r}`;
36
31
  return {
37
32
  /**
38
33
  * Retrieves and coerces the authentication schemes stored in local storage.
39
34
  */
40
- getSchemas: (t) => {
41
- const r = JSON.parse(m.getItem(s("schemas", t)) ?? "{}");
42
- return y(b, r);
35
+ getAuth: (r) => {
36
+ const e = JSON.parse(o.getItem(t(r)) ?? "{}");
37
+ return h(m, e);
43
38
  },
44
39
  /**
45
40
  * Stores the authentication schemes in local storage.
46
- * @param value The SecuritySchemes object to stringify and store.
41
+ * @param value The Auth object to stringify and store.
47
42
  */
48
- setSchemas: (t, r) => {
49
- m.setItem(s("schemas", t), JSON.stringify(r));
50
- },
51
- /**
52
- * Retrieves and coerces the selected authentication schemes stored in local storage.
53
- */
54
- getSelectedSchemes: (t) => {
55
- const r = JSON.parse(m.getItem(s("selectedSchemes", t)) ?? "{}");
56
- return y(E, r);
57
- },
58
- /**
59
- * Stores the user's selected authentication schemes in local storage.
60
- * @param value The XScalarSelectedSecurity object to stringify and store.
61
- */
62
- setSelectedSchemes: (t, r) => {
63
- m.setItem(s("selectedSchemes", t), JSON.stringify(r));
43
+ setAuth: (r, e) => {
44
+ o.setItem(t(r), JSON.stringify(e));
64
45
  }
65
46
  };
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
- continue;
72
- }
73
- p(h(e[s]), t);
74
- }
75
- }, I = (e, c) => Object.keys(e).every((s) => c.has(s)), U = (e, c) => e >= c ? c - 1 : e, H = ({
76
- documentName: e,
77
- workspaceStore: c
47
+ }, A = ({
48
+ documentName: t,
49
+ workspaceStore: r
78
50
  }) => {
79
- const s = f().getSchemas(e), t = c.workspace.documents[e];
80
- if (!t)
81
- return;
82
- const n = f().getSelectedSchemes(e), o = new Set(Object.keys(t.components?.securitySchemes ?? {})), S = n["x-scalar-selected-security"]?.selectedSchemes?.filter((a) => I(a, o));
83
- if (!t["x-scalar-selected-security"] && S && S.length > 0) {
84
- const a = n["x-scalar-selected-security"]?.selectedIndex, i = U(a ?? 0, S.length);
85
- t["x-scalar-selected-security"] = {
86
- selectedIndex: i,
87
- selectedSchemes: S
88
- };
89
- }
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
- }
51
+ const s = S().getAuth(t);
52
+ r.auth.load({ [t]: s });
95
53
  };
96
- function M(e) {
54
+ function E(t) {
97
55
  try {
98
- return JSON.parse(e);
56
+ return JSON.parse(t);
99
57
  } catch {
100
58
  return;
101
59
  }
102
60
  }
103
- function N(e) {
61
+ function b(t) {
104
62
  try {
105
- if (e.startsWith("/") || e.startsWith("http://localhost"))
106
- return e;
107
- const c = new URLSearchParams({ scalar_url: e });
108
- return new URL(`https://proxy.scalar.com/?${c}`).toString();
63
+ if (t.startsWith("/") || t.startsWith("http://localhost"))
64
+ return t;
65
+ const r = new URLSearchParams({ scalar_url: t });
66
+ return new URL(`https://proxy.scalar.com/?${r}`).toString();
109
67
  } catch {
110
- return console.error(`Invalid URL provided: ${e}`), e;
68
+ return console.error(`Invalid URL provided: ${t}`), t;
111
69
  }
112
70
  }
113
71
  export {
114
- f as authStorage,
115
- C as createDocumentSettings,
116
- P as getOperations,
117
- N as makeScalarProxyUrl,
118
- H as restoreAuthSecretsFromStorage,
119
- M as safeParseJson
72
+ S as authStorage,
73
+ x as createDocumentSettings,
74
+ U as getOperations,
75
+ b as makeScalarProxyUrl,
76
+ A as restoreAuthSecretsFromStorage,
77
+ E as safeParseJson
120
78
  };
@@ -1,24 +1,31 @@
1
- export declare function useChatApprovals(): {
2
- approvalRequestedParts: import("vue").ComputedRef<({
1
+ import type { ToolUIPart, UIMessagePart } from 'ai';
2
+ import { type Tools } from '../state/state.js';
3
+ type RequestToolPart = ToolUIPart & {
4
+ type: 'tool-execute-request';
5
+ state: 'input-available';
6
+ input: Tools['execute-request']['input'];
7
+ };
8
+ export declare function requestPartRequiresApproval(part: UIMessagePart<any, Tools>): part is RequestToolPart;
9
+ export declare function useRequestApprovals(): {
10
+ approvalRequiredParts: import("vue").ComputedRef<({
3
11
  type: `tool-${string}`;
4
12
  } & {
5
13
  toolCallId: string;
6
14
  title?: string;
7
15
  providerExecuted?: boolean;
8
16
  } & {
9
- state: "approval-requested";
17
+ state: "input-available";
10
18
  input: unknown;
11
19
  output?: never;
12
20
  errorText?: never;
13
21
  callProviderMetadata?: import("ai").ProviderMetadata;
14
- approval: {
15
- id: string;
16
- approved?: never;
17
- reason?: never;
18
- };
22
+ approval?: never;
19
23
  } & {
20
- state: "approval-requested";
24
+ type: "tool-execute-request";
25
+ state: "input-available";
26
+ input: Tools["execute-request"]["input"];
21
27
  })[]>;
22
- respondToToolCalls: (approved: boolean) => Promise<void>;
28
+ respondToRequestApprovals: (approved: boolean) => Promise<void>;
23
29
  };
30
+ export {};
24
31
  //# sourceMappingURL=use-chat-approvals.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-chat-approvals.d.ts","sourceRoot":"","sources":["../../src/hooks/use-chat-approvals.ts"],"names":[],"mappings":"AAWA,wBAAgB,gBAAgB;;;;;;;;;;;;;;;oBAuB648C,CAAC;kBAAuB,CAAC;;;eA7B/48C,oBAAoB;;mCAgB7B,OAAO;EAYpD"}
1
+ {"version":3,"file":"use-chat-approvals.d.ts","sourceRoot":"","sources":["../../src/hooks/use-chat-approvals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,IAAI,CAAA;AAMnD,OAAO,EAAE,KAAK,KAAK,EAAY,MAAM,eAAe,CAAA;AAEpD,KAAK,eAAe,GAAG,UAAU,GAAG;IAClC,IAAI,EAAE,sBAAsB,CAAA;IAC5B,KAAK,EAAE,iBAAiB,CAAA;IACxB,KAAK,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,CAAA;CACzC,CAAA;AAED,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,aAAa,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,IAAI,IAAI,eAAe,CAMpG;AAED,wBAAgB,mBAAmB;;;;;;;;;;;;;;;cAb3B,sBAAsB;eACrB,iBAAiB;eACjB,KAAK,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC;;0CAqBW,OAAO;EAuB3D"}
@@ -1,21 +1,34 @@
1
1
  import { computed as l } from "vue";
2
- import { useState as n } from "../state/state.js";
3
- function e(t) {
4
- return t.type.startsWith("tool") && t.state === "approval-requested";
2
+ import { executeRequestTool as i } from "../client-tools/execute-request.js";
3
+ import { createDocumentSettings as n } from "../helpers.js";
4
+ import { useState as m } from "../state/state.js";
5
+ import { EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME as s } from "../entities/tools/execute-request.js";
6
+ function a(t) {
7
+ return t.type === `tool-${s}` && t.state === "input-available" && t.input?.method?.toLowerCase() !== "get";
5
8
  }
6
- function c() {
7
- const t = n(), a = l(() => t.chat.messages.filter((o) => o.parts.some(e)).flatMap((o) => o.parts).filter(e));
8
- async function s(o) {
9
- const r = a.value.map(
10
- (p) => t.chat.addToolApprovalResponse({
11
- id: p.approval.id,
12
- approved: o
13
- })
14
- );
15
- await Promise.all(r);
9
+ function h() {
10
+ const t = m(), r = l(() => t.chat.messages.filter((e) => e.parts.some(a)).flatMap((e) => e.parts).filter(a));
11
+ async function u(e) {
12
+ const p = r.value.map(async (o) => {
13
+ if (!e)
14
+ return await t.chat.addToolOutput({
15
+ tool: s,
16
+ toolCallId: o.toolCallId,
17
+ state: "output-error",
18
+ errorText: "The user denied the request."
19
+ });
20
+ await i({
21
+ documentSettings: n(t.workspaceStore),
22
+ input: o.input,
23
+ toolCallId: o.toolCallId,
24
+ chat: t.chat
25
+ });
26
+ });
27
+ await Promise.all(p);
16
28
  }
17
- return { approvalRequestedParts: a, respondToToolCalls: s };
29
+ return { approvalRequiredParts: r, respondToRequestApprovals: u };
18
30
  }
19
31
  export {
20
- c as useChatApprovals
32
+ a as requestPartRequiresApproval,
33
+ h as useRequestApprovals
21
34
  };
@@ -9,6 +9,7 @@ export declare function useSearch(): {
9
9
  logoUrl: string | null;
10
10
  slug: string;
11
11
  removable?: boolean | undefined;
12
+ searchEnabled?: boolean | undefined;
12
13
  }[], ApiMetadata[] | {
13
14
  id: string;
14
15
  title: string;
@@ -17,6 +18,7 @@ export declare function useSearch(): {
17
18
  logoUrl: string | null;
18
19
  slug: string;
19
20
  removable?: boolean | undefined;
21
+ searchEnabled?: boolean | undefined;
20
22
  }[]>;
21
23
  };
22
24
  //# 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":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAG/D,wBAAgB,SAAS;;;;;;;;;;;;;;;;;;;EAiCxB"}
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"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  import './style.css';
2
+ export type { ChatExposed } from './App.vue.js';
2
3
  export { default as Chat } from './App.vue.js';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAA"}
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.4.8",
13
+ "version": "0.5.2",
14
14
  "engines": {
15
15
  "node": ">=20"
16
16
  },
@@ -62,6 +62,7 @@
62
62
  "@vueuse/core": "catalog:*",
63
63
  "ai": "catalog:*",
64
64
  "neverpanic": "catalog:*",
65
+ "truncate-json": "catalog:*",
65
66
  "vue": "catalog:*",
66
67
  "whatwg-mimetype": "catalog:*",
67
68
  "zod": "catalog:*"
@@ -0,0 +1,16 @@
1
+ import type { WorkspacePlugin } from '@scalar/workspace-store/workspace-plugin';
2
+ /**
3
+ * Plugin to persist workspace state changes with debounced writes.
4
+ */
5
+ export declare const persistencePlugin: ({ debounceDelay, maxWait, persistAuth, }: {
6
+ debounceDelay?: number;
7
+ /** Maximum time in milliseconds to wait before forcing execution, even with continuous calls. */
8
+ maxWait?: number;
9
+ /**
10
+ * Determines whether authentication details should be persisted.
11
+ * Accepts a boolean or a function that returns a boolean.
12
+ * Allows for conditional persistence logic, e.g., based on environment or user settings.
13
+ */
14
+ persistAuth?: boolean | (() => boolean);
15
+ }) => WorkspacePlugin;
16
+ //# sourceMappingURL=persistance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persistance.d.ts","sourceRoot":"","sources":["../../src/plugins/persistance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAA;AAI/E;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,0CAI/B;IACD,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,iGAAiG;IACjG,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,CAAA;CACxC,KAAG,eA8BH,CAAA"}
@@ -0,0 +1,23 @@
1
+ import { debounce as c } from "@scalar/helpers/general/debounce";
2
+ import { authStorage as s } from "../helpers.js";
3
+ const h = ({
4
+ debounceDelay: o = 500,
5
+ maxWait: r = 1e4,
6
+ persistAuth: e = !1
7
+ }) => {
8
+ const { execute: n } = c({ delay: o, maxWait: r }), u = s(), a = () => typeof e == "function" ? e() : e;
9
+ return {
10
+ hooks: {
11
+ /**
12
+ * Handles all workspace state change events.
13
+ * Each write is debounced by a key to prevent frequent writes for the same entity.
14
+ */
15
+ onWorkspaceStateChanges(t) {
16
+ a() && t.type === "auth" && n("auth", () => u.setAuth(t.documentName, t.value));
17
+ }
18
+ }
19
+ };
20
+ };
21
+ export {
22
+ h as persistencePlugin
23
+ };
@@ -8,7 +8,7 @@ import { type ComputedRef, type InjectionKey, type Ref } from 'vue';
8
8
  import { type Api } from '../api.js';
9
9
  import type { ApiMetadata } from '../entities/registry/document.js';
10
10
  import type { ASK_FOR_AUTHENTICATION_TOOL_NAME, AskForAuthenticationInput } from '../entities/tools/ask-for-authentication.js';
11
- import type { EXECUTE_REQUEST_TOOL_NAME, ExecuteRequestToolInput, ExecuteRequestToolOutput } from '../entities/tools/execute-request.js';
11
+ import { EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME, type ExecuteClientSideRequestToolInput, type ExecuteClientSideRequestToolOutput } from '../entities/tools/execute-request.js';
12
12
  import type { GET_MINI_OPENAPI_SPEC_TOOL_NAME, GetMiniOpenAPIDocToolInput, GetMiniOpenAPIDocToolOutput } from '../entities/tools/get-mini-openapi-spec.js';
13
13
  import type { GET_OPENAPI_SPECS_SUMMARY_TOOL_NAME, GetOpenAPISpecsSummaryToolOutput } from '../entities/tools/get-openapi-spec-summary.js';
14
14
  import type { ChatMode } from '../types';
@@ -21,9 +21,9 @@ export type Tools = {
21
21
  input: GetMiniOpenAPIDocToolInput;
22
22
  output: GetMiniOpenAPIDocToolOutput;
23
23
  };
24
- [EXECUTE_REQUEST_TOOL_NAME]: {
25
- input: ExecuteRequestToolInput;
26
- output: ExecuteRequestToolOutput;
24
+ [EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME]: {
25
+ input: ExecuteClientSideRequestToolInput;
26
+ output: ExecuteClientSideRequestToolOutput;
27
27
  };
28
28
  [GET_OPENAPI_SPECS_SUMMARY_TOOL_NAME]: {
29
29
  input: object;
@@ -47,7 +47,12 @@ type State = {
47
47
  registryUrl: string;
48
48
  dashboardUrl: string;
49
49
  baseUrl: string;
50
+ isLoggedIn?: Ref<boolean>;
50
51
  registryDocuments: Ref<ApiMetadata[]>;
52
+ pendingDocuments: Ref<{
53
+ namespace: string;
54
+ slug: string;
55
+ }[]>;
51
56
  mode: ChatMode;
52
57
  terms: {
53
58
  accepted: Ref<boolean>;
@@ -58,6 +63,11 @@ type State = {
58
63
  slug: string;
59
64
  removable?: boolean;
60
65
  }) => Promise<void>;
66
+ addDocumentAsync: (document: {
67
+ namespace: string;
68
+ slug: string;
69
+ removable?: boolean;
70
+ }) => Promise<void>;
61
71
  removeDocument: (document: {
62
72
  namespace: string;
63
73
  slug: string;
@@ -69,7 +79,7 @@ type State = {
69
79
  curatedDocuments: Ref<ApiMetadata[]>;
70
80
  getActiveDocumentJson?: () => string;
71
81
  };
72
- export declare function createState({ initialRegistryDocuments, registryUrl, dashboardUrl, baseUrl, mode, getAccessToken, getAgentKey, getActiveDocumentJson, prefilledMessageRef, }: {
82
+ export declare function createState({ initialRegistryDocuments, registryUrl, dashboardUrl, baseUrl, mode, isLoggedIn, getAccessToken, getAgentKey, getActiveDocumentJson, prefilledMessageRef, }: {
73
83
  initialRegistryDocuments: {
74
84
  namespace: string;
75
85
  slug: string;
@@ -78,6 +88,7 @@ export declare function createState({ initialRegistryDocuments, registryUrl, das
78
88
  dashboardUrl: string;
79
89
  baseUrl: string;
80
90
  mode: ChatMode;
91
+ isLoggedIn?: Ref<boolean>;
81
92
  getAccessToken?: () => string;
82
93
  getAgentKey?: () => string;
83
94
  getActiveDocumentJson?: () => string;
@@ -1 +1 @@
1
- {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/state/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,KAAK,UAAU,EAAY,MAAM,oBAAoB,CAAA;AAC9D,OAAO,EAAE,KAAK,4BAA4B,EAAmC,MAAM,6BAA6B,CAAA;AAChH,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,gCAAgC,CAAA;AAC1F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAEvE,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,SAAS,EAEf,MAAM,IAAI,CAAA;AACX,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,KAAK,GAAG,EAAgC,MAAM,KAAK,CAAA;AAEjG,OAAO,EAAE,KAAK,GAAG,EAAyC,MAAM,OAAO,CAAA;AACvE,OAAO,KAAK,EAAE,WAAW,EAA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