@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.
Files changed (56) hide show
  1. package/dist/App.vue.d.ts.map +1 -1
  2. package/dist/api.js +13 -13
  3. package/dist/api.js.map +1 -1
  4. package/dist/entities/registry/document.d.ts +10 -10
  5. package/dist/entities/registry/document.d.ts.map +1 -1
  6. package/dist/entities/registry/document.js +8 -8
  7. package/dist/entities/registry/document.js.map +1 -1
  8. package/dist/entities/tools/ask-for-authentication.d.ts +6 -6
  9. package/dist/entities/tools/ask-for-authentication.d.ts.map +1 -1
  10. package/dist/entities/tools/ask-for-authentication.js +4 -4
  11. package/dist/entities/tools/ask-for-authentication.js.map +1 -1
  12. package/dist/entities/tools/execute-request.d.ts +10 -10
  13. package/dist/entities/tools/execute-request.d.ts.map +1 -1
  14. package/dist/entities/tools/execute-request.js +8 -8
  15. package/dist/entities/tools/execute-request.js.map +1 -1
  16. package/dist/entities/tools/search-openapi-operations.d.ts +5 -5
  17. package/dist/entities/tools/search-openapi-operations.d.ts.map +1 -1
  18. package/dist/entities/tools/search-openapi-operations.js +2 -2
  19. package/dist/entities/tools/search-openapi-operations.js.map +1 -1
  20. package/dist/helpers.d.ts +1 -1
  21. package/dist/helpers.d.ts.map +1 -1
  22. package/dist/helpers.js +6 -3
  23. package/dist/helpers.js.map +1 -1
  24. package/dist/hooks/use-chat-error.d.ts +10 -9
  25. package/dist/hooks/use-chat-error.d.ts.map +1 -1
  26. package/dist/hooks/use-chat-error.js +7 -8
  27. package/dist/hooks/use-chat-error.js.map +1 -1
  28. package/dist/hooks/use-upload-tmp-document.d.ts.map +1 -1
  29. package/dist/hooks/use-upload-tmp-document.js +20 -18
  30. package/dist/hooks/use-upload-tmp-document.js.map +1 -1
  31. package/dist/package.json +4 -3
  32. package/dist/state/state.d.ts.map +1 -1
  33. package/dist/state/state.js +3 -2
  34. package/dist/state/state.js.map +1 -1
  35. package/dist/style.css +180 -1087
  36. package/dist/views/Chat/Messages/AskForAuthentication.vue.d.ts.map +1 -1
  37. package/dist/views/Chat/Messages/AskForAuthentication.vue.js +1 -1
  38. package/dist/views/Chat/Messages/AskForAuthentication.vue.js.map +1 -1
  39. package/dist/views/Chat/Messages/AskForAuthentication.vue.script.js +3 -1
  40. package/dist/views/Chat/Messages/AskForAuthentication.vue.script.js.map +1 -1
  41. package/dist/views/Settings/Auth.vue.d.ts +2 -3
  42. package/dist/views/Settings/Auth.vue.d.ts.map +1 -1
  43. package/dist/views/Settings/Auth.vue.js.map +1 -1
  44. package/dist/views/Settings/Auth.vue.script.js.map +1 -1
  45. package/dist/views/Settings/DocSettings.vue.d.ts +2 -2
  46. package/dist/views/Settings/DocSettings.vue.d.ts.map +1 -1
  47. package/dist/views/Settings/DocSettings.vue.js +1 -1
  48. package/dist/views/Settings/DocSettings.vue.js.map +1 -1
  49. package/dist/views/Settings/DocSettings.vue.script.js.map +1 -1
  50. package/dist/views/Settings/Settings.vue.d.ts.map +1 -1
  51. package/dist/views/Settings/Settings.vue.js +1 -1
  52. package/dist/views/Settings/Settings.vue.js.map +1 -1
  53. package/dist/views/Settings/Settings.vue.script.js +2 -1
  54. package/dist/views/Settings/Settings.vue.script.js.map +1 -1
  55. package/dist/vue-styles.css +20 -20
  56. package/package.json +12 -11
@@ -1 +1 @@
1
- {"version":3,"file":"use-upload-tmp-document.js","names":[],"sources":["../../src/hooks/use-upload-tmp-document.ts"],"sourcesContent":["import { redirectToProxy } from '@scalar/helpers/url/redirect-to-proxy'\nimport { ref } from 'vue'\nimport { z } from 'zod/mini'\n\nimport { useState } from '@/state/state'\n\nconst SHOW_UPLOAD_SUCCESS_DELAY = 5_000 // 5 seconds\n\nexport type UploadTmpDocumentState =\n | { type: 'error'; error: unknown }\n | { type: 'uploading' }\n | { type: 'processing' }\n | { type: 'loading' }\n | { type: 'done' }\n\nconst TMP_DOC_LS_KEY = 'scalar-tmp-doc'\n\nfunction saveTmpDocumentInLocalStorage({ namespace, slug }: { namespace: string; slug: string }) {\n localStorage.setItem(TMP_DOC_LS_KEY, JSON.stringify({ namespace, slug }))\n}\n\nexport function getTmpDocFromLocalStorage() {\n const tmpDoc = localStorage.getItem(TMP_DOC_LS_KEY)\n if (!tmpDoc) {\n return\n }\n\n return z\n .object({\n namespace: z.string(),\n slug: z.string(),\n })\n .parse(JSON.parse(tmpDoc))\n}\n\nexport function removeTmpDocFromLocalStorage() {\n const tmpDoc = localStorage.getItem(TMP_DOC_LS_KEY)\n if (!tmpDoc) {\n return\n }\n\n localStorage.removeItem(TMP_DOC_LS_KEY)\n}\n\n/**\n * Handle uploading a temporary OpenAPI document.\n */\nexport function useUploadTmpDocument() {\n const state = useState()\n const uploadState = ref<UploadTmpDocumentState>()\n\n function createUrl(path: string) {\n const fullUrl = `${state.baseUrl}${path}`\n return redirectToProxy(state.platformProxyUrl, fullUrl)\n }\n\n async function uploadTempDocument(document: string, isAgent = false) {\n try {\n uploadState.value = {\n type: 'uploading',\n }\n\n const response = await fetch(createUrl(`/core/share/upload/apis${isAgent ? '?source=agent' : ''}`), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ document }),\n })\n\n if (!response.ok) {\n uploadState.value = {\n type: 'error',\n error: 'Failed to upload your OpenAPI document.',\n }\n\n return\n }\n\n const json = await response.json()\n\n const { success, data } = z.object({ url: z.string(), namespace: z.string(), slug: z.string() }).safeParse(json)\n\n if (!success) {\n uploadState.value = {\n type: 'error',\n error: 'Failed to process document.',\n }\n return\n }\n\n uploadState.value = {\n type: 'processing',\n }\n const embeddingStatusResponse = await fetch(\n createUrl(`/vector/registry/embeddings/${data.namespace}/${data.slug}`),\n {\n method: 'GET',\n },\n )\n\n saveTmpDocumentInLocalStorage({\n namespace: data.namespace,\n slug: data.slug,\n })\n\n await state.addDocument({\n namespace: data.namespace,\n slug: data.slug,\n removable: false,\n tmp: true,\n })\n\n if (!embeddingStatusResponse.ok) {\n uploadState.value = {\n type: 'error',\n error: 'Failed to embed document.',\n }\n return\n }\n\n uploadState.value = { type: 'done' }\n state.uploadedTmpDocumentUrl.value = data.url\n\n setTimeout(() => {\n uploadState.value = undefined\n }, SHOW_UPLOAD_SUCCESS_DELAY)\n\n return data\n } catch {\n uploadState.value = { type: 'error', error: 'Failed to upload your OpenAPI document.' }\n return\n }\n }\n\n return {\n uploadTempDocument,\n uploadState,\n }\n}\n"],"mappings":";;;;;AAMA,IAAM,4BAA4B;AASlC,IAAM,iBAAiB;AAEvB,SAAS,8BAA8B,EAAE,WAAW,QAA6C;AAC/F,cAAa,QAAQ,gBAAgB,KAAK,UAAU;EAAE;EAAW;EAAM,CAAC,CAAC;;AAG3E,SAAgB,4BAA4B;CAC1C,MAAM,SAAS,aAAa,QAAQ,eAAe;AACnD,KAAI,CAAC,OACH;AAGF,QAAO,EACJ,OAAO;EACN,WAAW,EAAE,QAAQ;EACrB,MAAM,EAAE,QAAQ;EACjB,CAAC,CACD,MAAM,KAAK,MAAM,OAAO,CAAC;;AAG9B,SAAgB,+BAA+B;AAE7C,KAAI,CADW,aAAa,QAAQ,eAAe,CAEjD;AAGF,cAAa,WAAW,eAAe;;;;;AAMzC,SAAgB,uBAAuB;CACrC,MAAM,QAAQ,UAAU;CACxB,MAAM,cAAc,KAA6B;CAEjD,SAAS,UAAU,MAAc;EAC/B,MAAM,UAAU,GAAG,MAAM,UAAU;AACnC,SAAO,gBAAgB,MAAM,kBAAkB,QAAQ;;CAGzD,eAAe,mBAAmB,UAAkB,UAAU,OAAO;AACnE,MAAI;AACF,eAAY,QAAQ,EAClB,MAAM,aACP;GAED,MAAM,WAAW,MAAM,MAAM,UAAU,0BAA0B,UAAU,kBAAkB,KAAK,EAAE;IAClG,QAAQ;IACR,SAAS,EACP,gBAAgB,oBACjB;IACD,MAAM,KAAK,UAAU,EAAE,UAAU,CAAC;IACnC,CAAC;AAEF,OAAI,CAAC,SAAS,IAAI;AAChB,gBAAY,QAAQ;KAClB,MAAM;KACN,OAAO;KACR;AAED;;GAGF,MAAM,OAAO,MAAM,SAAS,MAAM;GAElC,MAAM,EAAE,SAAS,SAAS,EAAE,OAAO;IAAE,KAAK,EAAE,QAAQ;IAAE,WAAW,EAAE,QAAQ;IAAE,MAAM,EAAE,QAAQ;IAAE,CAAC,CAAC,UAAU,KAAK;AAEhH,OAAI,CAAC,SAAS;AACZ,gBAAY,QAAQ;KAClB,MAAM;KACN,OAAO;KACR;AACD;;AAGF,eAAY,QAAQ,EAClB,MAAM,cACP;GACD,MAAM,0BAA0B,MAAM,MACpC,UAAU,+BAA+B,KAAK,UAAU,GAAG,KAAK,OAAO,EACvE,EACE,QAAQ,OACT,CACF;AAED,iCAA8B;IAC5B,WAAW,KAAK;IAChB,MAAM,KAAK;IACZ,CAAC;AAEF,SAAM,MAAM,YAAY;IACtB,WAAW,KAAK;IAChB,MAAM,KAAK;IACX,WAAW;IACX,KAAK;IACN,CAAC;AAEF,OAAI,CAAC,wBAAwB,IAAI;AAC/B,gBAAY,QAAQ;KAClB,MAAM;KACN,OAAO;KACR;AACD;;AAGF,eAAY,QAAQ,EAAE,MAAM,QAAQ;AACpC,SAAM,uBAAuB,QAAQ,KAAK;AAE1C,oBAAiB;AACf,gBAAY,QAAQ,KAAA;MACnB,0BAA0B;AAE7B,UAAO;UACD;AACN,eAAY,QAAQ;IAAE,MAAM;IAAS,OAAO;IAA2C;AACvF;;;AAIJ,QAAO;EACL;EACA;EACD"}
1
+ {"version":3,"file":"use-upload-tmp-document.js","names":[],"sources":["../../src/hooks/use-upload-tmp-document.ts"],"sourcesContent":["import { redirectToProxy } from '@scalar/helpers/url/redirect-to-proxy'\nimport { coerce, object, string, validate } from '@scalar/validation'\nimport { ref } from 'vue'\n\nimport { useState } from '@/state/state'\n\nconst SHOW_UPLOAD_SUCCESS_DELAY = 5_000 // 5 seconds\n\nexport type UploadTmpDocumentState =\n | { type: 'error'; error: unknown }\n | { type: 'uploading' }\n | { type: 'processing' }\n | { type: 'loading' }\n | { type: 'done' }\n\nconst TMP_DOC_LS_KEY = 'scalar-tmp-doc'\n\nfunction saveTmpDocumentInLocalStorage({ namespace, slug }: { namespace: string; slug: string }) {\n localStorage.setItem(TMP_DOC_LS_KEY, JSON.stringify({ namespace, slug }))\n}\n\nconst tmpDocSchema = object({\n namespace: string(),\n slug: string(),\n})\n\nexport function getTmpDocFromLocalStorage() {\n const tmpDoc = localStorage.getItem(TMP_DOC_LS_KEY)\n if (!tmpDoc) {\n return\n }\n\n return coerce(tmpDocSchema, JSON.parse(tmpDoc))\n}\n\nexport function removeTmpDocFromLocalStorage() {\n const tmpDoc = localStorage.getItem(TMP_DOC_LS_KEY)\n if (!tmpDoc) {\n return\n }\n\n localStorage.removeItem(TMP_DOC_LS_KEY)\n}\n\n/**\n * Handle uploading a temporary OpenAPI document.\n */\nexport function useUploadTmpDocument() {\n const state = useState()\n const uploadState = ref<UploadTmpDocumentState>()\n\n function createUrl(path: string) {\n const fullUrl = `${state.baseUrl}${path}`\n return redirectToProxy(state.platformProxyUrl, fullUrl)\n }\n\n async function uploadTempDocument(document: string, isAgent = false) {\n try {\n uploadState.value = {\n type: 'uploading',\n }\n\n const response = await fetch(createUrl(`/core/share/upload/apis${isAgent ? '?source=agent' : ''}`), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ document }),\n })\n\n if (!response.ok) {\n uploadState.value = {\n type: 'error',\n error: 'Failed to upload your OpenAPI document.',\n }\n\n return\n }\n\n const json = await response.json()\n\n const uploadResponseSchema = object({ url: string(), namespace: string(), slug: string() })\n\n if (!validate(uploadResponseSchema, json)) {\n uploadState.value = {\n type: 'error',\n error: 'Failed to process document.',\n }\n return\n }\n\n const uploadData = coerce(uploadResponseSchema, json)\n\n uploadState.value = {\n type: 'processing',\n }\n const embeddingStatusResponse = await fetch(\n createUrl(`/vector/registry/embeddings/${uploadData.namespace}/${uploadData.slug}`),\n {\n method: 'GET',\n },\n )\n\n saveTmpDocumentInLocalStorage({\n namespace: uploadData.namespace,\n slug: uploadData.slug,\n })\n\n await state.addDocument({\n namespace: uploadData.namespace,\n slug: uploadData.slug,\n removable: false,\n tmp: true,\n })\n\n if (!embeddingStatusResponse.ok) {\n uploadState.value = {\n type: 'error',\n error: 'Failed to embed document.',\n }\n return\n }\n\n uploadState.value = { type: 'done' }\n state.uploadedTmpDocumentUrl.value = uploadData.url\n\n setTimeout(() => {\n uploadState.value = undefined\n }, SHOW_UPLOAD_SUCCESS_DELAY)\n\n return uploadData\n } catch {\n uploadState.value = { type: 'error', error: 'Failed to upload your OpenAPI document.' }\n return\n }\n }\n\n return {\n uploadTempDocument,\n uploadState,\n }\n}\n"],"mappings":";;;;;AAMA,IAAM,4BAA4B;AASlC,IAAM,iBAAiB;AAEvB,SAAS,8BAA8B,EAAE,WAAW,QAA6C;AAC/F,cAAa,QAAQ,gBAAgB,KAAK,UAAU;EAAE;EAAW;EAAM,CAAC,CAAC;;AAG3E,IAAM,eAAe,OAAO;CAC1B,WAAW,QAAQ;CACnB,MAAM,QAAQ;CACf,CAAC;AAEF,SAAgB,4BAA4B;CAC1C,MAAM,SAAS,aAAa,QAAQ,eAAe;AACnD,KAAI,CAAC,OACH;AAGF,QAAO,OAAO,cAAc,KAAK,MAAM,OAAO,CAAC;;AAGjD,SAAgB,+BAA+B;AAE7C,KAAI,CADW,aAAa,QAAQ,eAAe,CAEjD;AAGF,cAAa,WAAW,eAAe;;;;;AAMzC,SAAgB,uBAAuB;CACrC,MAAM,QAAQ,UAAU;CACxB,MAAM,cAAc,KAA6B;CAEjD,SAAS,UAAU,MAAc;EAC/B,MAAM,UAAU,GAAG,MAAM,UAAU;AACnC,SAAO,gBAAgB,MAAM,kBAAkB,QAAQ;;CAGzD,eAAe,mBAAmB,UAAkB,UAAU,OAAO;AACnE,MAAI;AACF,eAAY,QAAQ,EAClB,MAAM,aACP;GAED,MAAM,WAAW,MAAM,MAAM,UAAU,0BAA0B,UAAU,kBAAkB,KAAK,EAAE;IAClG,QAAQ;IACR,SAAS,EACP,gBAAgB,oBACjB;IACD,MAAM,KAAK,UAAU,EAAE,UAAU,CAAC;IACnC,CAAC;AAEF,OAAI,CAAC,SAAS,IAAI;AAChB,gBAAY,QAAQ;KAClB,MAAM;KACN,OAAO;KACR;AAED;;GAGF,MAAM,OAAO,MAAM,SAAS,MAAM;GAElC,MAAM,uBAAuB,OAAO;IAAE,KAAK,QAAQ;IAAE,WAAW,QAAQ;IAAE,MAAM,QAAQ;IAAE,CAAC;AAE3F,OAAI,CAAC,SAAS,sBAAsB,KAAK,EAAE;AACzC,gBAAY,QAAQ;KAClB,MAAM;KACN,OAAO;KACR;AACD;;GAGF,MAAM,aAAa,OAAO,sBAAsB,KAAK;AAErD,eAAY,QAAQ,EAClB,MAAM,cACP;GACD,MAAM,0BAA0B,MAAM,MACpC,UAAU,+BAA+B,WAAW,UAAU,GAAG,WAAW,OAAO,EACnF,EACE,QAAQ,OACT,CACF;AAED,iCAA8B;IAC5B,WAAW,WAAW;IACtB,MAAM,WAAW;IAClB,CAAC;AAEF,SAAM,MAAM,YAAY;IACtB,WAAW,WAAW;IACtB,MAAM,WAAW;IACjB,WAAW;IACX,KAAK;IACN,CAAC;AAEF,OAAI,CAAC,wBAAwB,IAAI;AAC/B,gBAAY,QAAQ;KAClB,MAAM;KACN,OAAO;KACR;AACD;;AAGF,eAAY,QAAQ,EAAE,MAAM,QAAQ;AACpC,SAAM,uBAAuB,QAAQ,WAAW;AAEhD,oBAAiB;AACf,gBAAY,QAAQ,KAAA;MACnB,0BAA0B;AAE7B,UAAO;UACD;AACN,eAAY,QAAQ;IAAE,MAAM;IAAS,OAAO;IAA2C;AACvF;;;AAIJ,QAAO;EACL;EACA;EACD"}
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.10.14",
13
+ "version": "0.12.0",
14
14
  "engines": {
15
15
  "node": ">=22"
16
16
  },
@@ -61,17 +61,18 @@
61
61
  "@scalar/icons": "workspace:*",
62
62
  "@scalar/json-magic": "workspace:*",
63
63
  "@scalar/openapi-types": "workspace:*",
64
+ "@scalar/schemas": "workspace:*",
64
65
  "@scalar/themes": "workspace:*",
65
66
  "@scalar/types": "workspace:*",
66
67
  "@scalar/use-toasts": "workspace:*",
68
+ "@scalar/validation": "workspace:*",
67
69
  "@scalar/workspace-store": "workspace:*",
68
70
  "@vueuse/core": "catalog:*",
69
71
  "ai": "catalog:*",
70
72
  "js-base64": "catalog:*",
71
73
  "neverpanic": "catalog:*",
72
74
  "truncate-json": "catalog:*",
73
- "vue": "catalog:*",
74
- "zod": "catalog:*"
75
+ "vue": "catalog:*"
75
76
  },
76
77
  "devDependencies": {
77
78
  "@scalar/sidebar": "workspace:*",
@@ -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;AAEhH,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,gCAAgC,CAAA;AAC1F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAEvE,OAAO,EAAwB,KAAK,WAAW,EAAE,KAAK,SAAS,EAA+C,MAAM,IAAI,CAAA;AAExH,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,KAAK,GAAG,EAA0C,MAAM,KAAK,CAAA;AAE3G,OAAO,EAAE,KAAK,GAAG,EAAyC,MAAM,OAAO,CAAA;AAIvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC/D,OAAO,KAAK,EACV,gCAAgC,EAChC,yBAAyB,EAC1B,MAAM,yCAAyC,CAAA;AACh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CAAA;IAC7B,WAAW,CAAC,EAAE,MAAM,MAAM,CAAA;IAC1B,qBAAqB,CAAC,EAAE,MAAM,MAAM,CAAA;IACpC,mBAAmB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACjC,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,GAAG,KAAK,CAwNR;AAED,wBAAgB,QAAQ,UAQvB"}
@@ -13,11 +13,12 @@ import { computed, inject, reactive, ref, watch } from "vue";
13
13
  import { useToasts } from "@scalar/use-toasts";
14
14
  import { Chat } from "@ai-sdk/vue";
15
15
  import { useModal } from "@scalar/components";
16
- import { apiReferenceConfigurationSchema } from "@scalar/types/api-reference";
16
+ import { apiReferenceConfigurationSchema } from "@scalar/schemas/api-reference";
17
17
  import { createWorkspaceStore } from "@scalar/workspace-store/client";
18
18
  import { createWorkspaceEventBus } from "@scalar/workspace-store/events";
19
19
  import { DefaultChatTransport, lastAssistantMessageIsCompleteWithToolCalls } from "ai";
20
20
  import { n } from "neverpanic";
21
+ import { coerce } from "@scalar/validation";
21
22
  //#region src/state/state.ts
22
23
  var STATE_SYMBOL = Symbol("STATE_SYMBOL");
23
24
  var { toast } = useToasts();
@@ -56,7 +57,7 @@ function createState({ initialRegistryDocuments, registryUrl, dashboardUrl, plat
56
57
  const terms = useTermsAndConditions();
57
58
  const eventBus = createWorkspaceEventBus();
58
59
  const workspaceStore = createWorkspaceStore({ plugins: [persistencePlugin({ persistAuth: true })] });
59
- const config = computed(() => apiReferenceConfigurationSchema.parse({
60
+ const config = computed(() => coerce(apiReferenceConfigurationSchema, {
60
61
  proxyUrl: proxyUrl.value,
61
62
  persistAuth: true
62
63
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"state.js","names":[],"sources":["../../src/state/state.ts"],"sourcesContent":["import { Chat } from '@ai-sdk/vue'\nimport { type ModalState, useModal } from '@scalar/components'\nimport { type ApiReferenceConfigurationRaw, apiReferenceConfigurationSchema } from '@scalar/types/api-reference'\nimport { useToasts } from '@scalar/use-toasts'\nimport { type WorkspaceStore, createWorkspaceStore } from '@scalar/workspace-store/client'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { createWorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { DefaultChatTransport, type UIDataTypes, type UIMessage, lastAssistantMessageIsCompleteWithToolCalls } from 'ai'\nimport { n } from 'neverpanic'\nimport { type ComputedRef, type InjectionKey, type Ref, computed, inject, reactive, ref, watch } from 'vue'\n\nimport { type Api, createApi, createAuthorizationHeaders } from '@/api'\nimport { executeRequestTool } from '@/client-tools/execute-request'\nimport { URLS } from '@/consts/urls'\nimport { createError } from '@/entities'\nimport type { ApiMetadata } from '@/entities/registry/document'\nimport type {\n ASK_FOR_AUTHENTICATION_TOOL_NAME,\n AskForAuthenticationInput,\n} from '@/entities/tools/ask-for-authentication'\nimport {\n EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME,\n type ExecuteClientSideRequestToolInput,\n type ExecuteClientSideRequestToolOutput,\n} from '@/entities/tools/execute-request'\nimport type {\n GetOpenAPISpecsSummaryToolOutput,\n SUMMARIZE_OPENAPI_SPECS_TOOL_NAME,\n} from '@/entities/tools/get-openapi-specs-summary'\nimport type {\n SEARCH_OPENAPI_OPERATIONS_TOOL_NAME,\n SearchOpenAPIOperationsToolInput,\n SearchOpenAPIOperationsToolOutput,\n} from '@/entities/tools/search-openapi-operations'\nimport { createDocumentSettings } from '@/helpers'\nimport { useTermsAndConditions } from '@/hooks/use-term-and-conditions'\nimport { removeTmpDocFromLocalStorage } from '@/hooks/use-upload-tmp-document'\nimport { persistencePlugin } from '@/plugins/persistance'\nimport { loadDocument } from '@/registry/add-documents-to-store'\nimport { createDocumentName } from '@/registry/create-document-name'\nimport type { ChatMode } from '@/types'\n\nexport type RegistryDocument = {\n namespace: string\n slug: string\n}\n\nexport type Tools = {\n [SEARCH_OPENAPI_OPERATIONS_TOOL_NAME]: {\n input: SearchOpenAPIOperationsToolInput\n output: SearchOpenAPIOperationsToolOutput\n }\n [EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME]: {\n input: ExecuteClientSideRequestToolInput\n output: ExecuteClientSideRequestToolOutput\n }\n [SUMMARIZE_OPENAPI_SPECS_TOOL_NAME]: {\n input: object\n output: GetOpenAPISpecsSummaryToolOutput\n }\n [ASK_FOR_AUTHENTICATION_TOOL_NAME]: {\n input: AskForAuthenticationInput\n output: unknown\n }\n}\n\nexport const STATE_SYMBOL: InjectionKey<State> = Symbol('STATE_SYMBOL')\n\nconst { toast } = useToasts()\n\ntype State = {\n prompt: Ref<string>\n chat: Chat<UIMessage<unknown, UIDataTypes, Tools>>\n workspaceStore: WorkspaceStore\n loading: ComputedRef<boolean>\n settingsModal: ModalState\n eventBus: WorkspaceEventBus\n proxyUrl: ComputedRef<string>\n proxyUrlRaw: Ref<string | undefined>\n config: ComputedRef<ApiReferenceConfigurationRaw>\n registryUrl: string\n dashboardUrl: string\n baseUrl: string\n platformProxyUrl: string\n isLoggedIn?: Ref<boolean>\n registryDocuments: Ref<ApiMetadata[]>\n pendingDocuments: Record<string, boolean>\n mode: ChatMode\n terms: { accepted: Ref<boolean>; accept: () => void }\n addDocument: (document: { namespace: string; slug: string; removable?: boolean; tmp?: boolean }) => Promise<void>\n addDocumentAsync: (document: { namespace: string; slug: string; removable?: boolean }) => Promise<void>\n removeDocument: (document: { namespace: string; slug: string }) => void\n getAccessToken?: () => string\n getAgentKey?: () => string\n api: Api\n uploadedTmpDocumentUrl: Ref<string | undefined>\n curatedDocuments: Ref<ApiMetadata[]>\n getActiveDocumentJson?: () => string\n hideAddApi?: boolean\n}\n\nfunction createChat({\n registryDocuments,\n workspaceStore,\n baseUrl,\n proxyUrl,\n getAccessToken,\n getAgentKey,\n}: {\n registryDocuments: Ref<ApiMetadata[]>\n workspaceStore: WorkspaceStore\n baseUrl: string\n proxyUrl: ComputedRef<string>\n getAccessToken?: () => string\n getAgentKey?: () => string\n}) {\n const chat = new Chat<UIMessage<unknown, UIDataTypes, Tools>>({\n sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithToolCalls,\n transport: new DefaultChatTransport({\n api: `${baseUrl}/vector/openapi/chat`,\n headers: () => createAuthorizationHeaders({ getAccessToken, getAgentKey }),\n body: () => ({\n registryDocuments: registryDocuments.value,\n }),\n }),\n async onToolCall({ toolCall }): Promise<any> {\n if (toolCall.dynamic) {\n return\n }\n\n if (\n toolCall.toolName === EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME &&\n toolCall.input.method.toLowerCase() === 'get'\n ) {\n await executeRequestTool({\n documentSettings: createDocumentSettings(workspaceStore),\n input: toolCall.input,\n toolCallId: toolCall.toolCallId,\n chat,\n proxyUrl: proxyUrl.value,\n })\n }\n },\n })\n\n return chat\n}\n\nexport function createState({\n initialRegistryDocuments,\n registryUrl,\n dashboardUrl,\n platformProxyUrl,\n baseUrl,\n mode,\n isLoggedIn,\n getAccessToken,\n getAgentKey,\n getActiveDocumentJson,\n prefilledMessageRef,\n hideAddApi,\n}: {\n initialRegistryDocuments: { namespace: string; slug: string }[]\n registryUrl: string\n dashboardUrl: string\n platformProxyUrl: string\n baseUrl: string\n mode: ChatMode\n isLoggedIn?: Ref<boolean>\n getAccessToken?: () => string\n getAgentKey?: () => string\n getActiveDocumentJson?: () => string\n prefilledMessageRef?: Ref<string>\n hideAddApi?: boolean\n}): State {\n const prompt = ref<State['prompt']['value']>(prefilledMessageRef?.value ?? '')\n const registryDocuments = ref<ApiMetadata[]>([])\n const pendingDocuments = reactive<Record<string, boolean>>({})\n const curatedDocuments = ref<ApiMetadata[]>([])\n const proxyUrlRaw = ref<State['proxyUrlRaw']['value']>(URLS.DEFAULT_PROXY_URL)\n const proxyUrl = computed(() => proxyUrlRaw.value?.trim() || URLS.DEFAULT_PROXY_URL)\n const uploadedTmpDocumentUrl = ref<string>()\n const terms = useTermsAndConditions()\n\n const eventBus = createWorkspaceEventBus()\n const workspaceStore = createWorkspaceStore({\n plugins: [\n persistencePlugin({\n persistAuth: true,\n }),\n ],\n })\n\n const config = computed(() =>\n apiReferenceConfigurationSchema.parse({\n proxyUrl: proxyUrl.value,\n persistAuth: true,\n }),\n )\n\n const chat = createChat({\n registryDocuments,\n workspaceStore,\n baseUrl,\n proxyUrl,\n getAccessToken,\n getAgentKey,\n })\n\n const api = createApi({\n baseUrl,\n getAccessToken,\n getAgentKey,\n })\n\n const loading = computed(\n () =>\n chat.status === 'submitted' ||\n (chat.status === 'streaming' && !chat.lastMessage?.parts.some((part) => part.type === 'text')),\n )\n\n watch(\n () => chat.status,\n () => {\n if (chat.status === 'streaming') {\n prompt.value = ''\n }\n },\n )\n\n if (prefilledMessageRef) {\n watch(prefilledMessageRef, async (val) => {\n if (val) {\n prompt.value = val\n if (terms.accepted.value) {\n await chat.sendMessage({ text: prompt.value })\n }\n }\n })\n }\n\n const settingsModal = useModal()\n\n async function addDocument({\n namespace,\n slug,\n removable = true,\n tmp = false,\n }: {\n namespace: string\n slug: string\n removable?: boolean\n tmp?: boolean\n }) {\n const matchingDoc = registryDocuments.value.find((doc) => doc.namespace === namespace && doc.slug === slug)\n\n if (matchingDoc) {\n return\n }\n\n const identifier = `@${namespace}/${slug}`\n\n pendingDocuments[identifier] = true\n\n const loadDocumentResult = await loadDocument({\n namespace,\n slug,\n workspaceStore,\n registryUrl,\n registryDocuments,\n config: config.value,\n getAccessToken,\n api,\n removable,\n })\n\n pendingDocuments[identifier] = false\n\n if (!loadDocumentResult.success) {\n /**\n * If we are unable to load a document, we just remove it\n * from tmp local storage, do not warn the user.\n */\n if (tmp) {\n removeTmpDocFromLocalStorage()\n throw loadDocumentResult.error\n }\n\n console.warn('[AGENT]: Unable to load document', loadDocumentResult.error)\n toast(`Unable to load the document @${namespace}/${slug}`, 'warn')\n throw loadDocumentResult.error\n }\n }\n\n /**\n * Waits for document to be available in embeddings\n * and adds to the list\n */\n async function addDocumentAsync({\n namespace,\n slug,\n removable = true,\n }: {\n namespace: string\n slug: string\n removable?: boolean\n }) {\n const matchingDoc = registryDocuments.value.find((doc) => doc.namespace === namespace && doc.slug === slug)\n\n if (matchingDoc) {\n return\n }\n\n const identifier = `@${namespace}/${slug}`\n\n pendingDocuments[identifier] = true\n\n const embeddingStatusResponse = await n.fromUnsafe(\n () =>\n fetch(`${baseUrl}/vector/registry/embeddings/${namespace}/${slug}`, {\n method: 'GET',\n }),\n (originalError) => createError('FAILED_TO_GET_EMBEDDING_STATUS', originalError),\n )\n\n if (embeddingStatusResponse.success && embeddingStatusResponse.data.ok) {\n const loadDocumentResult = await loadDocument({\n namespace,\n slug,\n workspaceStore,\n registryUrl,\n registryDocuments,\n config: config.value,\n getAccessToken,\n api,\n removable,\n })\n\n if (!loadDocumentResult.success) {\n console.warn('[AGENT]: Unable to load document', loadDocumentResult.error)\n toast(`Unable to load the document @${namespace}/${slug}`, 'warn')\n }\n } else {\n console.warn('[AGENT]: Document could not be embedded')\n toast(`Unable to embed the document @${namespace}/${slug}`, 'warn')\n }\n\n pendingDocuments[identifier] = false\n }\n\n function removeDocument({ namespace, slug }: { namespace: string; slug: string }) {\n registryDocuments.value = registryDocuments.value.filter(\n (doc) => !(doc.namespace === namespace && doc.slug === slug),\n )\n\n workspaceStore.deleteDocument(createDocumentName(namespace, slug))\n }\n\n initialRegistryDocuments.forEach(({ namespace, slug }) => addDocument({ namespace, slug, removable: false }))\n\n return {\n prompt,\n chat,\n workspaceStore,\n eventBus,\n loading,\n settingsModal,\n config,\n registryUrl,\n dashboardUrl,\n platformProxyUrl,\n baseUrl,\n registryDocuments,\n pendingDocuments,\n proxyUrl,\n proxyUrlRaw,\n mode,\n terms,\n isLoggedIn,\n addDocument,\n addDocumentAsync,\n removeDocument,\n getAccessToken,\n getAgentKey,\n api,\n uploadedTmpDocumentUrl,\n curatedDocuments,\n getActiveDocumentJson,\n hideAddApi,\n }\n}\n\nexport function useState() {\n const state = inject(STATE_SYMBOL)\n\n if (!state) {\n throw new Error('No state provided.')\n }\n\n return state\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;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E,iBAEpC,MAAM,GAAG,QAAQ,8BAA8B,UAAU,GAAG,QAAQ,EAClE,QAAQ,OACT,CAAC,GACH,kBAAkB,YAAY,kCAAkC,cAAc,CAChF;AAED,MAAI,wBAAwB,WAAW,wBAAwB,KAAK,IAAI;GACtE,MAAM,qBAAqB,MAAM,aAAa;IAC5C;IACA;IACA;IACA;IACA;IACA,QAAQ,OAAO;IACf;IACA;IACA;IACD,CAAC;AAEF,OAAI,CAAC,mBAAmB,SAAS;AAC/B,YAAQ,KAAK,oCAAoC,mBAAmB,MAAM;AAC1E,UAAM,gCAAgC,UAAU,GAAG,QAAQ,OAAO;;SAE/D;AACL,WAAQ,KAAK,0CAA0C;AACvD,SAAM,iCAAiC,UAAU,GAAG,QAAQ,OAAO;;AAGrE,mBAAiB,cAAc;;CAGjC,SAAS,eAAe,EAAE,WAAW,QAA6C;AAChF,oBAAkB,QAAQ,kBAAkB,MAAM,QAC/C,QAAQ,EAAE,IAAI,cAAc,aAAa,IAAI,SAAS,MACxD;AAED,iBAAe,eAAe,mBAAmB,WAAW,KAAK,CAAC;;AAGpE,0BAAyB,SAAS,EAAE,WAAW,WAAW,YAAY;EAAE;EAAW;EAAM,WAAW;EAAO,CAAC,CAAC;AAE7G,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD;;AAGH,SAAgB,WAAW;CACzB,MAAM,QAAQ,OAAO,aAAa;AAElC,KAAI,CAAC,MACH,OAAM,IAAI,MAAM,qBAAqB;AAGvC,QAAO"}
1
+ {"version":3,"file":"state.js","names":[],"sources":["../../src/state/state.ts"],"sourcesContent":["import { Chat } from '@ai-sdk/vue'\nimport { type ModalState, useModal } from '@scalar/components'\nimport { type ApiReferenceConfigurationRaw } from '@scalar/types/api-reference'\nimport { apiReferenceConfigurationSchema } from '@scalar/schemas/api-reference'\nimport { useToasts } from '@scalar/use-toasts'\nimport { type WorkspaceStore, createWorkspaceStore } from '@scalar/workspace-store/client'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { createWorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { DefaultChatTransport, type UIDataTypes, type UIMessage, lastAssistantMessageIsCompleteWithToolCalls } from 'ai'\nimport { n } from 'neverpanic'\nimport { type ComputedRef, type InjectionKey, type Ref, computed, inject, reactive, ref, watch } from 'vue'\n\nimport { type Api, createApi, createAuthorizationHeaders } from '@/api'\nimport { executeRequestTool } from '@/client-tools/execute-request'\nimport { URLS } from '@/consts/urls'\nimport { createError } from '@/entities'\nimport type { ApiMetadata } from '@/entities/registry/document'\nimport type {\n ASK_FOR_AUTHENTICATION_TOOL_NAME,\n AskForAuthenticationInput,\n} from '@/entities/tools/ask-for-authentication'\nimport {\n EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME,\n type ExecuteClientSideRequestToolInput,\n type ExecuteClientSideRequestToolOutput,\n} from '@/entities/tools/execute-request'\nimport type {\n GetOpenAPISpecsSummaryToolOutput,\n SUMMARIZE_OPENAPI_SPECS_TOOL_NAME,\n} from '@/entities/tools/get-openapi-specs-summary'\nimport type {\n SEARCH_OPENAPI_OPERATIONS_TOOL_NAME,\n SearchOpenAPIOperationsToolInput,\n SearchOpenAPIOperationsToolOutput,\n} from '@/entities/tools/search-openapi-operations'\nimport { createDocumentSettings } from '@/helpers'\nimport { useTermsAndConditions } from '@/hooks/use-term-and-conditions'\nimport { removeTmpDocFromLocalStorage } from '@/hooks/use-upload-tmp-document'\nimport { persistencePlugin } from '@/plugins/persistance'\nimport { loadDocument } from '@/registry/add-documents-to-store'\nimport { createDocumentName } from '@/registry/create-document-name'\nimport type { ChatMode } from '@/types'\nimport { coerce } from '@scalar/validation'\n\nexport type RegistryDocument = {\n namespace: string\n slug: string\n}\n\nexport type Tools = {\n [SEARCH_OPENAPI_OPERATIONS_TOOL_NAME]: {\n input: SearchOpenAPIOperationsToolInput\n output: SearchOpenAPIOperationsToolOutput\n }\n [EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME]: {\n input: ExecuteClientSideRequestToolInput\n output: ExecuteClientSideRequestToolOutput\n }\n [SUMMARIZE_OPENAPI_SPECS_TOOL_NAME]: {\n input: object\n output: GetOpenAPISpecsSummaryToolOutput\n }\n [ASK_FOR_AUTHENTICATION_TOOL_NAME]: {\n input: AskForAuthenticationInput\n output: unknown\n }\n}\n\nexport const STATE_SYMBOL: InjectionKey<State> = Symbol('STATE_SYMBOL')\n\nconst { toast } = useToasts()\n\ntype State = {\n prompt: Ref<string>\n chat: Chat<UIMessage<unknown, UIDataTypes, Tools>>\n workspaceStore: WorkspaceStore\n loading: ComputedRef<boolean>\n settingsModal: ModalState\n eventBus: WorkspaceEventBus\n proxyUrl: ComputedRef<string>\n proxyUrlRaw: Ref<string | undefined>\n config: ComputedRef<ApiReferenceConfigurationRaw>\n registryUrl: string\n dashboardUrl: string\n baseUrl: string\n platformProxyUrl: string\n isLoggedIn?: Ref<boolean>\n registryDocuments: Ref<ApiMetadata[]>\n pendingDocuments: Record<string, boolean>\n mode: ChatMode\n terms: { accepted: Ref<boolean>; accept: () => void }\n addDocument: (document: { namespace: string; slug: string; removable?: boolean; tmp?: boolean }) => Promise<void>\n addDocumentAsync: (document: { namespace: string; slug: string; removable?: boolean }) => Promise<void>\n removeDocument: (document: { namespace: string; slug: string }) => void\n getAccessToken?: () => string\n getAgentKey?: () => string\n api: Api\n uploadedTmpDocumentUrl: Ref<string | undefined>\n curatedDocuments: Ref<ApiMetadata[]>\n getActiveDocumentJson?: () => string\n hideAddApi?: boolean\n}\n\nfunction createChat({\n registryDocuments,\n workspaceStore,\n baseUrl,\n proxyUrl,\n getAccessToken,\n getAgentKey,\n}: {\n registryDocuments: Ref<ApiMetadata[]>\n workspaceStore: WorkspaceStore\n baseUrl: string\n proxyUrl: ComputedRef<string>\n getAccessToken?: () => string\n getAgentKey?: () => string\n}) {\n const chat = new Chat<UIMessage<unknown, UIDataTypes, Tools>>({\n sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithToolCalls,\n transport: new DefaultChatTransport({\n api: `${baseUrl}/vector/openapi/chat`,\n headers: () => createAuthorizationHeaders({ getAccessToken, getAgentKey }),\n body: () => ({\n registryDocuments: registryDocuments.value,\n }),\n }),\n async onToolCall({ toolCall }): Promise<any> {\n if (toolCall.dynamic) {\n return\n }\n\n if (\n toolCall.toolName === EXECUTE_CLIENT_SIDE_REQUEST_TOOL_NAME &&\n toolCall.input.method.toLowerCase() === 'get'\n ) {\n await executeRequestTool({\n documentSettings: createDocumentSettings(workspaceStore),\n input: toolCall.input,\n toolCallId: toolCall.toolCallId,\n chat,\n proxyUrl: proxyUrl.value,\n })\n }\n },\n })\n\n return chat\n}\n\nexport function createState({\n initialRegistryDocuments,\n registryUrl,\n dashboardUrl,\n platformProxyUrl,\n baseUrl,\n mode,\n isLoggedIn,\n getAccessToken,\n getAgentKey,\n getActiveDocumentJson,\n prefilledMessageRef,\n hideAddApi,\n}: {\n initialRegistryDocuments: { namespace: string; slug: string }[]\n registryUrl: string\n dashboardUrl: string\n platformProxyUrl: string\n baseUrl: string\n mode: ChatMode\n isLoggedIn?: Ref<boolean>\n getAccessToken?: () => string\n getAgentKey?: () => string\n getActiveDocumentJson?: () => string\n prefilledMessageRef?: Ref<string>\n hideAddApi?: boolean\n}): State {\n const prompt = ref<State['prompt']['value']>(prefilledMessageRef?.value ?? '')\n const registryDocuments = ref<ApiMetadata[]>([])\n const pendingDocuments = reactive<Record<string, boolean>>({})\n const curatedDocuments = ref<ApiMetadata[]>([])\n const proxyUrlRaw = ref<State['proxyUrlRaw']['value']>(URLS.DEFAULT_PROXY_URL)\n const proxyUrl = computed(() => proxyUrlRaw.value?.trim() || URLS.DEFAULT_PROXY_URL)\n const uploadedTmpDocumentUrl = ref<string>()\n const terms = useTermsAndConditions()\n\n const eventBus = createWorkspaceEventBus()\n const workspaceStore = createWorkspaceStore({\n plugins: [\n persistencePlugin({\n persistAuth: true,\n }),\n ],\n })\n\n const config = computed(() =>\n coerce(apiReferenceConfigurationSchema, {\n proxyUrl: proxyUrl.value,\n persistAuth: true,\n }),\n )\n\n const chat = createChat({\n registryDocuments,\n workspaceStore,\n baseUrl,\n proxyUrl,\n getAccessToken,\n getAgentKey,\n })\n\n const api = createApi({\n baseUrl,\n getAccessToken,\n getAgentKey,\n })\n\n const loading = computed(\n () =>\n chat.status === 'submitted' ||\n (chat.status === 'streaming' && !chat.lastMessage?.parts.some((part) => part.type === 'text')),\n )\n\n watch(\n () => chat.status,\n () => {\n if (chat.status === 'streaming') {\n prompt.value = ''\n }\n },\n )\n\n if (prefilledMessageRef) {\n watch(prefilledMessageRef, async (val) => {\n if (val) {\n prompt.value = val\n if (terms.accepted.value) {\n await chat.sendMessage({ text: prompt.value })\n }\n }\n })\n }\n\n const settingsModal = useModal()\n\n async function addDocument({\n namespace,\n slug,\n removable = true,\n tmp = false,\n }: {\n namespace: string\n slug: string\n removable?: boolean\n tmp?: boolean\n }) {\n const matchingDoc = registryDocuments.value.find((doc) => doc.namespace === namespace && doc.slug === slug)\n\n if (matchingDoc) {\n return\n }\n\n const identifier = `@${namespace}/${slug}`\n\n pendingDocuments[identifier] = true\n\n const loadDocumentResult = await loadDocument({\n namespace,\n slug,\n workspaceStore,\n registryUrl,\n registryDocuments,\n config: config.value,\n getAccessToken,\n api,\n removable,\n })\n\n pendingDocuments[identifier] = false\n\n if (!loadDocumentResult.success) {\n /**\n * If we are unable to load a document, we just remove it\n * from tmp local storage, do not warn the user.\n */\n if (tmp) {\n removeTmpDocFromLocalStorage()\n throw loadDocumentResult.error\n }\n\n console.warn('[AGENT]: Unable to load document', loadDocumentResult.error)\n toast(`Unable to load the document @${namespace}/${slug}`, 'warn')\n throw loadDocumentResult.error\n }\n }\n\n /**\n * Waits for document to be available in embeddings\n * and adds to the list\n */\n async function addDocumentAsync({\n namespace,\n slug,\n removable = true,\n }: {\n namespace: string\n slug: string\n removable?: boolean\n }) {\n const matchingDoc = registryDocuments.value.find((doc) => doc.namespace === namespace && doc.slug === slug)\n\n if (matchingDoc) {\n return\n }\n\n const identifier = `@${namespace}/${slug}`\n\n pendingDocuments[identifier] = true\n\n const embeddingStatusResponse = await n.fromUnsafe(\n () =>\n fetch(`${baseUrl}/vector/registry/embeddings/${namespace}/${slug}`, {\n method: 'GET',\n }),\n (originalError) => createError('FAILED_TO_GET_EMBEDDING_STATUS', originalError),\n )\n\n if (embeddingStatusResponse.success && embeddingStatusResponse.data.ok) {\n const loadDocumentResult = await loadDocument({\n namespace,\n slug,\n workspaceStore,\n registryUrl,\n registryDocuments,\n config: config.value,\n getAccessToken,\n api,\n removable,\n })\n\n if (!loadDocumentResult.success) {\n console.warn('[AGENT]: Unable to load document', loadDocumentResult.error)\n toast(`Unable to load the document @${namespace}/${slug}`, 'warn')\n }\n } else {\n console.warn('[AGENT]: Document could not be embedded')\n toast(`Unable to embed the document @${namespace}/${slug}`, 'warn')\n }\n\n pendingDocuments[identifier] = false\n }\n\n function removeDocument({ namespace, slug }: { namespace: string; slug: string }) {\n registryDocuments.value = registryDocuments.value.filter(\n (doc) => !(doc.namespace === namespace && doc.slug === slug),\n )\n\n workspaceStore.deleteDocument(createDocumentName(namespace, slug))\n }\n\n initialRegistryDocuments.forEach(({ namespace, slug }) => addDocument({ namespace, slug, removable: false }))\n\n return {\n prompt,\n chat,\n workspaceStore,\n eventBus,\n loading,\n settingsModal,\n config,\n registryUrl,\n dashboardUrl,\n platformProxyUrl,\n baseUrl,\n registryDocuments,\n pendingDocuments,\n proxyUrl,\n proxyUrlRaw,\n mode,\n terms,\n isLoggedIn,\n addDocument,\n addDocumentAsync,\n removeDocument,\n getAccessToken,\n getAgentKey,\n api,\n uploadedTmpDocumentUrl,\n curatedDocuments,\n getActiveDocumentJson,\n hideAddApi,\n }\n}\n\nexport function useState() {\n const state = inject(STATE_SYMBOL)\n\n if (!state) {\n throw new Error('No state provided.')\n }\n\n return state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