@powerhousedao/reactor-browser 6.2.3-dev.7 → 6.2.3-dev.70

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 (94) hide show
  1. package/dist/{attachment-service-D3EhiAJ7.d.ts → attachment-service-CAf9N-15.d.ts} +365 -66
  2. package/dist/attachment-service-CAf9N-15.d.ts.map +1 -0
  3. package/dist/{client-DjK30EQ-.js → client-BFnMV-EO.js} +39 -22
  4. package/dist/client-BFnMV-EO.js.map +1 -0
  5. package/dist/{client-BIHN_UyR.d.ts → client-BnGewICj.d.ts} +3 -3
  6. package/dist/client-BnGewICj.d.ts.map +1 -0
  7. package/dist/{client-D66jVnot.js → client-CXDpILj6.js} +232 -32
  8. package/dist/client-CXDpILj6.js.map +1 -0
  9. package/dist/dispatch-Dd_WEz35.js +870 -0
  10. package/dist/dispatch-Dd_WEz35.js.map +1 -0
  11. package/dist/document-by-id-DqAyjr9P.js +16 -0
  12. package/dist/document-by-id-DqAyjr9P.js.map +1 -0
  13. package/dist/document-model-modules-DROQT_yu.js +431 -0
  14. package/dist/document-model-modules-DROQT_yu.js.map +1 -0
  15. package/dist/{document-operations-WeE6wIDt.js → document-operations-C6khz2If.js} +958 -204
  16. package/dist/document-operations-C6khz2If.js.map +1 -0
  17. package/dist/{global-OuINvEGT.d.ts → global-D-VZTZRz.d.ts} +113 -20
  18. package/dist/global-D-VZTZRz.d.ts.map +1 -0
  19. package/dist/{index-B33TKEqp.d.ts → index-XfcUiODQ.d.ts} +19 -98
  20. package/dist/index-XfcUiODQ.d.ts.map +1 -0
  21. package/dist/{index-BIVDXw3K.d.ts → index-rtDmzViP.d.ts} +3 -3
  22. package/dist/index-rtDmzViP.d.ts.map +1 -0
  23. package/dist/index.d.ts +693 -391
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +469 -72
  26. package/dist/index.js.map +1 -1
  27. package/dist/inspector-proxy-DODqs15F.d.ts +25 -0
  28. package/dist/inspector-proxy-DODqs15F.d.ts.map +1 -0
  29. package/dist/make-ph-event-functions-B5GU5xcR.js +180 -0
  30. package/dist/make-ph-event-functions-B5GU5xcR.js.map +1 -0
  31. package/dist/navigation-BqphkrOB.js +302 -0
  32. package/dist/navigation-BqphkrOB.js.map +1 -0
  33. package/dist/{pglite-CntadC_p-9NDG14dS.d.ts → pglite-CntadC_p-DTkdF8sr.d.ts} +11 -33
  34. package/dist/pglite-CntadC_p-DTkdF8sr.d.ts.map +1 -0
  35. package/dist/{relational-D1RB45sA.js → relational-DZuyKp2y.js} +66 -5
  36. package/dist/relational-DZuyKp2y.js.map +1 -0
  37. package/dist/{renown-rqK8sokh.js → renown-BtjgHBjH.js} +33 -28
  38. package/dist/{renown-rqK8sokh.js.map → renown-BtjgHBjH.js.map} +1 -1
  39. package/dist/{renown-BHxwP7xU.js → renown-BxkZYzbQ.js} +2 -2
  40. package/dist/{renown-BHxwP7xU.js.map → renown-BxkZYzbQ.js.map} +1 -1
  41. package/dist/src/ai/index.d.ts +51 -62
  42. package/dist/src/ai/index.d.ts.map +1 -1
  43. package/dist/src/ai/index.js +6 -9
  44. package/dist/src/ai/index.js.map +1 -1
  45. package/dist/src/analytics/index.d.ts +36 -44
  46. package/dist/src/analytics/index.d.ts.map +1 -1
  47. package/dist/src/analytics/index.js +4 -4
  48. package/dist/src/analytics/index.js.map +1 -1
  49. package/dist/src/document-model.d.ts +3 -4
  50. package/dist/src/document-model.d.ts.map +1 -1
  51. package/dist/src/document-model.js.map +1 -1
  52. package/dist/src/graphql/client.d.ts +4 -3
  53. package/dist/src/graphql/client.js +1 -1
  54. package/dist/src/graphql-client/entry.d.ts +5 -4
  55. package/dist/src/graphql-client/entry.js +4 -4
  56. package/dist/src/relational/index.d.ts +15 -9
  57. package/dist/src/relational/index.d.ts.map +1 -1
  58. package/dist/src/relational/index.js +1 -1
  59. package/dist/src/renown/index.d.ts +3 -2
  60. package/dist/src/renown/index.js +2 -2
  61. package/dist/src/rpc/index.d.ts +178 -138
  62. package/dist/src/rpc/index.d.ts.map +1 -1
  63. package/dist/src/rpc/index.js +420 -619
  64. package/dist/src/rpc/index.js.map +1 -1
  65. package/dist/{store-BJYcr_FL.js → store-DInXcjal.js} +1 -1
  66. package/dist/{store-BJYcr_FL.js.map → store-DInXcjal.js.map} +1 -1
  67. package/dist/{switchboard-CaXQ4-5Q.js → switchboard-cwUp3FxP.js} +98 -11
  68. package/dist/switchboard-cwUp3FxP.js.map +1 -0
  69. package/dist/{types-Dcv1ZLoW.d.ts → types-0Fh1tNjy.d.ts} +242 -17
  70. package/dist/types-0Fh1tNjy.d.ts.map +1 -0
  71. package/dist/{types-6vDzbRRS.d.ts → types-520nWrB3.d.ts} +2 -2
  72. package/dist/types-520nWrB3.d.ts.map +1 -0
  73. package/package.json +20 -21
  74. package/dist/attachment-service-D3EhiAJ7.d.ts.map +0 -1
  75. package/dist/client-BIHN_UyR.d.ts.map +0 -1
  76. package/dist/client-D66jVnot.js.map +0 -1
  77. package/dist/client-DjK30EQ-.js.map +0 -1
  78. package/dist/document-by-id-B4FIzG1w.js +0 -519
  79. package/dist/document-by-id-B4FIzG1w.js.map +0 -1
  80. package/dist/document-model-modules-bTP87nyr.js +0 -419
  81. package/dist/document-model-modules-bTP87nyr.js.map +0 -1
  82. package/dist/document-operations-WeE6wIDt.js.map +0 -1
  83. package/dist/global-OuINvEGT.d.ts.map +0 -1
  84. package/dist/index-B33TKEqp.d.ts.map +0 -1
  85. package/dist/index-BIVDXw3K.d.ts.map +0 -1
  86. package/dist/inspector-proxy-6h5VKAwt.d.ts +0 -257
  87. package/dist/inspector-proxy-6h5VKAwt.d.ts.map +0 -1
  88. package/dist/make-ph-event-functions-DBq3iWYn.js +0 -53
  89. package/dist/make-ph-event-functions-DBq3iWYn.js.map +0 -1
  90. package/dist/pglite-CntadC_p-9NDG14dS.d.ts.map +0 -1
  91. package/dist/relational-D1RB45sA.js.map +0 -1
  92. package/dist/switchboard-CaXQ4-5Q.js.map +0 -1
  93. package/dist/types-6vDzbRRS.d.ts.map +0 -1
  94. package/dist/types-Dcv1ZLoW.d.ts.map +0 -1
@@ -1,8 +1,61 @@
1
- import { t as useDocumentById } from "./document-by-id-B4FIzG1w.js";
2
- import { K as ambientRenownTokenProvider, U as DocumentTypeMismatchError, W as NoSelectedDocumentError, s as useSelectedNode, t as useDocumentModelModuleById } from "./document-model-modules-bTP87nyr.js";
1
+ import { c as getPHStore } from "./make-ph-event-functions-B5GU5xcR.js";
2
+ import { O as useSelectedNodeId, P as useDriveContext, R as DocumentTypeMismatchError, V as ambientRenownTokenProvider, g as useSelectedDriveSafe, t as useDocumentModelModuleById, z as NoSelectedDocumentError } from "./document-model-modules-DROQT_yu.js";
3
+ import { n as useDocumentsByIds, t as useDocumentById } from "./document-by-id-DqAyjr9P.js";
4
+ import { createContext, useContext, useMemo } from "react";
5
+ import { jsx } from "react/jsx-runtime";
3
6
  import { DriveCollectionId, ModuleNotFoundError } from "@powerhousedao/reactor";
4
7
  import { isFileNode } from "@powerhousedao/shared/document-drive";
5
8
  import { z } from "zod";
9
+ //#region src/utils/nodes.ts
10
+ /** Sorts nodes by name. */
11
+ function sortNodesByName(nodes) {
12
+ return nodes.toSorted((a, b) => a.name.localeCompare(b.name));
13
+ }
14
+ /** Returns whether a node is a file. */
15
+ function isFileNodeKind(node) {
16
+ if (!node) return false;
17
+ return node.kind.toUpperCase() === "FILE";
18
+ }
19
+ /** Returns whether a node is a folder. */
20
+ function isFolderNodeKind(node) {
21
+ if (!node) return false;
22
+ return node.kind.toUpperCase() === "FOLDER";
23
+ }
24
+ //#endregion
25
+ //#region src/hooks/items-in-selected-drive.ts
26
+ /** Returns the nodes in the selected drive. */
27
+ function useNodesInSelectedDrive() {
28
+ const [selectedDrive] = useSelectedDriveSafe();
29
+ return selectedDrive?.state.global.nodes;
30
+ }
31
+ /** Returns the file nodes in the selected drive. */
32
+ function useFileNodesInSelectedDrive() {
33
+ return useNodesInSelectedDrive()?.filter((n) => isFileNodeKind(n));
34
+ }
35
+ /** Returns the folder nodes in the selected drive. */
36
+ function useFolderNodesInSelectedDrive() {
37
+ return useNodesInSelectedDrive()?.filter((n) => isFolderNodeKind(n));
38
+ }
39
+ /** Returns the documents in the selected drive. */
40
+ function useDocumentsInSelectedDrive() {
41
+ const fileNodeIds = useFileNodesInSelectedDrive()?.map((node) => node.id);
42
+ return useDocumentsByIds(fileNodeIds);
43
+ }
44
+ /** Returns the document types supported by the selected drive, as defined by the document model documents present in the drive */
45
+ function useDocumentTypesInSelectedDrive() {
46
+ return (useDocumentsInSelectedDrive()?.filter(isDocumentModelDocument))?.map((doc) => doc.state.global.id);
47
+ }
48
+ function isDocumentModelDocument(document) {
49
+ return document.header.documentType === "powerhouse/document-model";
50
+ }
51
+ //#endregion
52
+ //#region src/hooks/selected-node.ts
53
+ /** Returns the selected node. */
54
+ function useSelectedNode() {
55
+ const selectedNodeId = useSelectedNodeId();
56
+ return useNodesInSelectedDrive()?.find((n) => n.id === selectedNodeId);
57
+ }
58
+ //#endregion
6
59
  //#region src/hooks/document-of-type.ts
7
60
  /** Returns a document of a specific type, throws an error if the found document has a different type */
8
61
  function useDocumentOfType(documentId, documentType) {
@@ -15,27 +68,61 @@ function useDocumentOfType(documentId, documentType) {
15
68
  return [document, dispatch];
16
69
  }
17
70
  //#endregion
71
+ //#region src/hooks/editor-context.tsx
72
+ const EditorDocumentContext = createContext(void 0);
73
+ /** Hosts render an editor inside this, with the same `document` and `dispatch`
74
+ * as its props; `useSelected*Document` hooks below read them. */
75
+ function EditorDocumentProvider(props) {
76
+ const { document, dispatch } = props;
77
+ const value = useMemo(() => [document, dispatch], [document, dispatch]);
78
+ return /* @__PURE__ */ jsx(EditorDocumentContext.Provider, {
79
+ value,
80
+ children: props.children
81
+ });
82
+ }
83
+ /** The nearest editor's document and dispatch, or undefined outside one. */
84
+ function useEditorDocumentContext() {
85
+ return useContext(EditorDocumentContext);
86
+ }
87
+ //#endregion
18
88
  //#region src/hooks/selected-document.ts
19
- /** Returns the selected document id */
89
+ /** Returns the selected document id: the editor's document, else the drive
90
+ * app's open document, else the app's selection. */
20
91
  function useSelectedDocumentId() {
92
+ const editor = useEditorDocumentContext();
93
+ const drive = useDriveContext();
21
94
  const selectedNode = useSelectedNode();
95
+ if (editor) return editor[0].header.id;
96
+ if (drive?.nodeId && !drive.folder) return selectedNode && !isFileNode(selectedNode) ? void 0 : drive.nodeId;
22
97
  return selectedNode && isFileNode(selectedNode) ? selectedNode.id : void 0;
23
98
  }
24
99
  /** Returns the selected document. */
25
100
  function useSelectedDocument() {
26
- const [document, dispatch] = useDocumentById(useSelectedDocumentId());
101
+ const [document, dispatch] = useSelectedDocumentSafe();
27
102
  if (!document) throw new NoSelectedDocumentError();
28
103
  return [document, dispatch];
29
104
  }
30
- /** Returns the selected document. */
105
+ /** Returns the selected document: the editor's, else the app's selection. */
31
106
  function useSelectedDocumentSafe() {
32
- return useDocumentById(useSelectedDocumentId());
107
+ const editor = useEditorDocumentContext();
108
+ const selectedDocumentId = useSelectedDocumentId();
109
+ const selected = useDocumentById(editor ? null : selectedDocumentId);
110
+ return editor ?? selected;
33
111
  }
34
112
  function useSelectedDocumentOfType(documentType) {
113
+ const editor = useEditorDocumentContext();
35
114
  const documentId = useSelectedDocumentId();
115
+ const result = useDocumentOfType(documentType && !editor ? documentId : null, documentType);
116
+ const documentModelModule = useDocumentModelModuleById(documentType);
36
117
  if (!documentType) return [];
118
+ if (editor) {
119
+ const [document, dispatch] = editor;
120
+ if (!documentModelModule) throw new ModuleNotFoundError(documentType);
121
+ if (document.header.documentType !== documentType) throw new DocumentTypeMismatchError(document.header.id, documentType, document.header.documentType);
122
+ return [document, dispatch];
123
+ }
37
124
  if (!documentId) throw new NoSelectedDocumentError();
38
- return useDocumentOfType(documentId, documentType);
125
+ return result;
39
126
  }
40
127
  //#endregion
41
128
  //#region src/ai/switchboard.ts
@@ -46,7 +133,7 @@ function useSelectedDocumentOfType(documentType) {
46
133
  */
47
134
  function getBrowserSyncManager() {
48
135
  if (typeof window === "undefined") return;
49
- return window.ph?.reactorClientModule?.reactorModule?.syncModule?.syncManager;
136
+ return getPHStore()?.reactorClientModule?.reactorModule?.syncModule?.syncManager;
50
137
  }
51
138
  /** Suffix of the per-drive GraphQL channel endpoint the switchboard serves. */
52
139
  const GQL_CHANNEL_SUFFIX = "/graphql/r";
@@ -221,7 +308,7 @@ const SWITCHBOARD_SCHEMA_TOOL_NAME = "getSwitchboardSchema";
221
308
  */
222
309
  function createSwitchboardSchemaTool(deps) {
223
310
  const getSyncManager = deps?.getSyncManager ?? getBrowserSyncManager;
224
- const getSelectedDriveId = deps?.getSelectedDriveId ?? (() => typeof window === "undefined" ? void 0 : window.ph?.selectedDriveId);
311
+ const getSelectedDriveId = deps?.getSelectedDriveId ?? (() => typeof window === "undefined" ? void 0 : getPHStore()?.selectedDriveId);
225
312
  const tokenProvider = deps?.tokenProvider ?? ambientRenownTokenProvider;
226
313
  const fetchImpl = deps?.fetchImpl ?? fetch;
227
314
  const timeoutMs = deps?.timeoutMs ?? 1e4;
@@ -266,6 +353,6 @@ function createSwitchboardSchemaTool(deps) {
266
353
  };
267
354
  }
268
355
  //#endregion
269
- export { getBrowserSyncManager as a, useSelectedDocument as c, useSelectedDocumentSafe as d, useDocumentOfType as f, createSwitchboardSchemaTool as i, useSelectedDocumentId as l, SWITCHBOARD_INTROSPECTION_QUERY as n, resolveDriveSwitchboard as o, SWITCHBOARD_SCHEMA_TOOL_NAME as r, summarizeIntrospectionSchema as s, GQL_CHANNEL_SUFFIX as t, useSelectedDocumentOfType as u };
356
+ export { sortNodesByName as C, isFolderNodeKind as S, useDocumentsInSelectedDrive as _, getBrowserSyncManager as a, useNodesInSelectedDrive as b, useSelectedDocument as c, useSelectedDocumentSafe as d, EditorDocumentProvider as f, useDocumentTypesInSelectedDrive as g, useSelectedNode as h, createSwitchboardSchemaTool as i, useSelectedDocumentId as l, useDocumentOfType as m, SWITCHBOARD_INTROSPECTION_QUERY as n, resolveDriveSwitchboard as o, useEditorDocumentContext as p, SWITCHBOARD_SCHEMA_TOOL_NAME as r, summarizeIntrospectionSchema as s, GQL_CHANNEL_SUFFIX as t, useSelectedDocumentOfType as u, useFileNodesInSelectedDrive as v, isFileNodeKind as x, useFolderNodesInSelectedDrive as y };
270
357
 
271
- //# sourceMappingURL=switchboard-CaXQ4-5Q.js.map
358
+ //# sourceMappingURL=switchboard-cwUp3FxP.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switchboard-cwUp3FxP.js","names":[],"sources":["../src/utils/nodes.ts","../src/hooks/items-in-selected-drive.ts","../src/hooks/selected-node.ts","../src/hooks/document-of-type.ts","../src/hooks/editor-context.tsx","../src/hooks/selected-document.ts","../src/ai/switchboard.ts"],"sourcesContent":["import type {\n FileNode,\n FolderNode,\n Node,\n} from \"@powerhousedao/shared/document-drive\";\n\n/** Sorts nodes by name. */\nexport function sortNodesByName<T extends Node>(nodes: T[]) {\n return nodes.toSorted((a, b) => a.name.localeCompare(b.name));\n}\n\n/** Returns whether a node is a file. */\nexport function isFileNodeKind(\n node: Node | null | undefined,\n): node is FileNode {\n if (!node) return false;\n return node.kind.toUpperCase() === \"FILE\";\n}\n\n/** Returns whether a node is a folder. */\nexport function isFolderNodeKind(\n node: Node | null | undefined,\n): node is FolderNode {\n if (!node) return false;\n return node.kind.toUpperCase() === \"FOLDER\";\n}\n","import type {\n FileNode,\n FolderNode,\n} from \"@powerhousedao/shared/document-drive\";\nimport type {\n DocumentModelDocument,\n PHDocument,\n} from \"@powerhousedao/shared/document-model\";\nimport { isFileNodeKind, isFolderNodeKind } from \"../utils/nodes.js\";\nimport { useDocumentsByIds } from \"./document-by-id.js\";\nimport { useSelectedDriveSafe } from \"./selected-drive.js\";\n\n/** Returns the nodes in the selected drive. */\nexport function useNodesInSelectedDrive() {\n const [selectedDrive] = useSelectedDriveSafe();\n return selectedDrive?.state.global.nodes;\n}\n\n/** Returns the file nodes in the selected drive. */\nexport function useFileNodesInSelectedDrive(): FileNode[] | undefined {\n const nodes = useNodesInSelectedDrive();\n return nodes?.filter((n) => isFileNodeKind(n));\n}\n\n/** Returns the folder nodes in the selected drive. */\nexport function useFolderNodesInSelectedDrive(): FolderNode[] | undefined {\n const nodes = useNodesInSelectedDrive();\n return nodes?.filter((n) => isFolderNodeKind(n));\n}\n\n/** Returns the documents in the selected drive. */\nexport function useDocumentsInSelectedDrive(): PHDocument[] | undefined {\n const fileNodes = useFileNodesInSelectedDrive();\n const fileNodeIds = fileNodes?.map((node) => node.id);\n return useDocumentsByIds(fileNodeIds);\n}\n\n/** Returns the document types supported by the selected drive, as defined by the document model documents present in the drive */\nexport function useDocumentTypesInSelectedDrive() {\n const documentsInSelectedDrive = useDocumentsInSelectedDrive();\n const documentModelDocumentsInSelectedDrive =\n documentsInSelectedDrive?.filter(isDocumentModelDocument);\n const documentTypesFromDocumentModelDocuments =\n documentModelDocumentsInSelectedDrive?.map((doc) => doc.state.global.id);\n return documentTypesFromDocumentModelDocuments;\n}\n\nfunction isDocumentModelDocument(\n document: PHDocument,\n): document is DocumentModelDocument {\n return document.header.documentType === \"powerhouse/document-model\";\n}\n","import type { Node } from \"@powerhousedao/shared/document-drive\";\nimport { useNodesInSelectedDrive } from \"./items-in-selected-drive.js\";\nimport { useSelectedNodeId } from \"./set-selected-node.js\";\n\nexport {\n addResetSelectedNodeEventHandler,\n addSelectedNodeIdEventHandler,\n getNodeTarget,\n useNodeTarget,\n preloadNode,\n setSelectedNode,\n setSelectedNodeId,\n useOpenNode,\n usePreloadNode,\n useSetSelectedNode,\n} from \"./set-selected-node.js\";\nexport { addSetSelectedNodeOnPopStateEventHandler } from \"./sync-selection.js\";\n\n/** Returns the selected node. */\nexport function useSelectedNode(): Node | undefined {\n const selectedNodeId = useSelectedNodeId();\n const nodes = useNodesInSelectedDrive();\n return nodes?.find((n) => n.id === selectedNodeId);\n}\n","import { ModuleNotFoundError } from \"@powerhousedao/reactor\";\nimport type { DocumentDispatch } from \"@powerhousedao/reactor-browser\";\nimport type { Action, PHDocument } from \"@powerhousedao/shared/document-model\";\nimport { DocumentTypeMismatchError } from \"../errors.js\";\nimport { useDocumentById } from \"./document-by-id.js\";\nimport { useDocumentModelModuleById } from \"./document-model-modules.js\";\n\n/** Returns a document of a specific type, throws an error if the found document has a different type */\nexport function useDocumentOfType<\n TDocument extends PHDocument,\n TAction extends Action,\n>(\n documentId: string | null | undefined,\n documentType: string | null | undefined,\n) {\n const [document, dispatch] = useDocumentById(documentId);\n const documentModelModule = useDocumentModelModuleById(documentType);\n\n if (!documentId || !documentType) return [];\n\n if (!document) {\n throw new Error(`Document not found: ${documentId}`);\n }\n if (!documentModelModule) {\n throw new ModuleNotFoundError(documentType);\n }\n\n if (document.header.documentType !== documentType) {\n throw new DocumentTypeMismatchError(\n documentId,\n documentType,\n document.header.documentType,\n );\n }\n\n return [document, dispatch] as [TDocument, DocumentDispatch<TAction>];\n}\n","import type {\n DocumentDispatch,\n PHDocument,\n} from \"@powerhousedao/shared/document-model\";\nimport type { ReactNode } from \"react\";\nimport { createContext, useContext, useMemo } from \"react\";\n\n/** The document an editor is rendered with, and a dispatch bound to it. */\nexport type EditorDocumentContextValue = readonly [\n PHDocument,\n DocumentDispatch,\n];\n\nconst EditorDocumentContext = createContext<\n EditorDocumentContextValue | undefined\n>(undefined);\n\n/** Hosts render an editor inside this, with the same `document` and `dispatch`\n * as its props; `useSelected*Document` hooks below read them. */\nexport function EditorDocumentProvider(props: {\n document: PHDocument;\n dispatch: DocumentDispatch;\n children: ReactNode;\n}) {\n const { document, dispatch } = props;\n const value = useMemo(\n () => [document, dispatch] as const,\n [document, dispatch],\n );\n return (\n <EditorDocumentContext.Provider value={value}>\n {props.children}\n </EditorDocumentContext.Provider>\n );\n}\n\n/** The nearest editor's document and dispatch, or undefined outside one. */\nexport function useEditorDocumentContext() {\n return useContext(EditorDocumentContext);\n}\n","import { ModuleNotFoundError } from \"@powerhousedao/reactor\";\nimport type { DocumentDispatch } from \"@powerhousedao/reactor-browser\";\nimport { isFileNode } from \"@powerhousedao/shared/document-drive\";\nimport type { Action, PHDocument } from \"@powerhousedao/shared/document-model\";\nimport {\n DocumentTypeMismatchError,\n NoSelectedDocumentError,\n} from \"../errors.js\";\nimport type { DispatchFn, UseDispatchResult } from \"./dispatch.js\";\nimport { useDocumentById } from \"./document-by-id.js\";\nimport { useDocumentModelModuleById } from \"./document-model-modules.js\";\nimport { useDocumentOfType } from \"./document-of-type.js\";\nimport { useDriveContext } from \"./drive-context.js\";\nimport { useEditorDocumentContext } from \"./editor-context.js\";\nimport { useSelectedNode } from \"./selected-node.js\";\n\n/** Returns the selected document id: the editor's document, else the drive\n * app's open document, else the app's selection. */\nexport function useSelectedDocumentId(): string | undefined {\n const editor = useEditorDocumentContext();\n const drive = useDriveContext();\n const selectedNode = useSelectedNode();\n if (editor) return editor[0].header.id;\n // The drive may not list a document the route opened yet.\n if (drive?.nodeId && !drive.folder) {\n return selectedNode && !isFileNode(selectedNode) ? undefined : drive.nodeId;\n }\n return selectedNode && isFileNode(selectedNode) ? selectedNode.id : undefined;\n}\n\n/** Returns the selected document. */\nexport function useSelectedDocument(): readonly [\n PHDocument,\n DispatchFn<Action>,\n] {\n const [document, dispatch] = useSelectedDocumentSafe();\n if (!document) {\n throw new NoSelectedDocumentError();\n }\n return [document, dispatch] as const;\n}\n\n/** Returns the selected document: the editor's, else the app's selection. */\nexport function useSelectedDocumentSafe(): UseDispatchResult<\n PHDocument,\n Action\n> {\n const editor = useEditorDocumentContext();\n const selectedDocumentId = useSelectedDocumentId();\n const selected = useDocumentById(editor ? null : selectedDocumentId);\n return editor ?? selected;\n}\n\n/** Returns the selected document of a specific type, throws an error if the found document has a different type */\nexport function useSelectedDocumentOfType(\n documentType: null | undefined,\n): never[];\nexport function useSelectedDocumentOfType<\n TDocument extends PHDocument,\n TAction extends Action,\n>(documentType: string): [TDocument, DocumentDispatch<TAction>];\nexport function useSelectedDocumentOfType<\n TDocument extends PHDocument,\n TAction extends Action,\n>(\n documentType: string | null | undefined,\n): never[] | [TDocument, DocumentDispatch<TAction>] {\n const editor = useEditorDocumentContext();\n const documentId = useSelectedDocumentId();\n // Called on every render; without a type, or in an editor, it reads no document.\n const result = useDocumentOfType<TDocument, TAction>(\n documentType && !editor ? documentId : null,\n documentType,\n );\n const documentModelModule = useDocumentModelModuleById(documentType);\n\n if (!documentType) {\n return [];\n }\n if (editor) {\n const [document, dispatch] = editor;\n if (!documentModelModule) {\n throw new ModuleNotFoundError(documentType);\n }\n if (document.header.documentType !== documentType) {\n throw new DocumentTypeMismatchError(\n document.header.id,\n documentType,\n document.header.documentType,\n );\n }\n return [document as TDocument, dispatch];\n }\n if (!documentId) {\n throw new NoSelectedDocumentError();\n }\n return result;\n}\n","import { getPHStore } from \"../hooks/ph-store.js\";\nimport { DriveCollectionId, type ISyncManager } from \"@powerhousedao/reactor\";\nimport { z } from \"zod\";\nimport { ambientRenownTokenProvider } from \"../graphql-client/auth.js\";\nimport type { AiToolDescriptor } from \"./types.js\";\n\n/**\n * The switchboard serving a remote drive: the base URL the browser talks to\n * and its GraphQL supergraph endpoint.\n */\nexport interface DriveSwitchboard {\n /** Switchboard base URL (e.g. `http://localhost:4001`). */\n switchboardUrl: string;\n /** GraphQL supergraph endpoint (`<base>/graphql`). */\n graphqlUrl: string;\n}\n\n/**\n * Reads the tab-side sync manager from the browser global. Returns\n * `undefined` in non-browser environments or before the reactor client\n * module is initialized.\n */\nexport function getBrowserSyncManager(): ISyncManager | undefined {\n if (typeof window === \"undefined\") {\n return undefined;\n }\n return getPHStore()?.reactorClientModule?.reactorModule?.syncModule\n ?.syncManager;\n}\n\n/** Suffix of the per-drive GraphQL channel endpoint the switchboard serves. */\nexport const GQL_CHANNEL_SUFFIX = \"/graphql/r\";\n\n/**\n * Resolves the switchboard that serves a drive, if any.\n *\n * Every remote drive stores its switchboard's exact GraphQL channel\n * endpoint in its sync remote — `channelConfig = { type: \"gql\",\n * parameters: { url: \"<origin>/graphql/r\" } }` — and the switchboard base\n * is that URL minus the `/graphql/r` suffix. Deriving it per drive (rather\n * than from a global setting) is what keeps multi-switchboard deployments\n * correct. Drives that are not synced to a remote switchboard (local\n * drives, other channel types, unexpected shapes) return `undefined`.\n */\nexport function resolveDriveSwitchboard(\n driveId: string | undefined,\n syncManager?: ISyncManager,\n): DriveSwitchboard | undefined {\n const manager = syncManager ?? getBrowserSyncManager();\n if (!driveId || !manager) {\n return undefined;\n }\n const collectionId = DriveCollectionId.forDrive(driveId);\n const remote = manager\n .list()\n .find((r) => r.meta.collectionId.equals(collectionId));\n if (!remote) {\n return undefined;\n }\n const { channelConfig } = remote.meta;\n if (channelConfig.type !== \"gql\") {\n return undefined;\n }\n const url = channelConfig.parameters.url;\n if (typeof url !== \"string\" || !url.endsWith(GQL_CHANNEL_SUFFIX)) {\n return undefined;\n }\n const switchboardUrl = url.slice(0, -GQL_CHANNEL_SUFFIX.length);\n return { switchboardUrl, graphqlUrl: `${switchboardUrl}/graphql` };\n}\n\n/** A bounded introspected GraphQL type reference (see the query below). */\ntype IntrospectedTypeRef = {\n kind: string;\n name: string | null;\n ofType?: IntrospectedTypeRef | null;\n};\n\ntype IntrospectedField = {\n name: string;\n description: string | null;\n args: Array<{ name: string; type: IntrospectedTypeRef }>;\n type: IntrospectedTypeRef;\n};\n\ntype IntrospectedRootType = {\n fields: IntrospectedField[] | null;\n} | null;\n\ntype IntrospectedSchema = {\n queryType?: IntrospectedRootType;\n mutationType?: IntrospectedRootType;\n};\n\n/**\n * Introspection over the switchboard supergraph's root query and mutation\n * fields. Types are requested with three levels of `ofType` nesting so\n * that common shapes like `[X!]!` (LIST(NON_NULL(LIST(X)))) render fully.\n */\nexport const SWITCHBOARD_INTROSPECTION_QUERY: string = /* GraphQL */ `\n query SwitchboardIntrospection {\n __schema {\n queryType {\n fields {\n name\n description\n args {\n name\n type {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n }\n }\n }\n }\n }\n type {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n }\n }\n }\n }\n }\n }\n mutationType {\n fields {\n name\n description\n args {\n name\n type {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n }\n }\n }\n }\n }\n type {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n }\n }\n }\n }\n }\n }\n }\n }\n`;\n\n/**\n * Renders an introspected type reference as a GraphQL type string.\n * Recursion is bounded by the `ofType` nesting of the query, so it always\n * terminates.\n */\nfunction renderTypeRef(type: IntrospectedTypeRef | null | undefined): string {\n if (!type) {\n return \"Unknown\";\n }\n switch (type.kind) {\n case \"NON_NULL\":\n return `${renderTypeRef(type.ofType)}!`;\n case \"LIST\":\n return `[${renderTypeRef(type.ofType)}]`;\n default:\n return type.name ?? \"Unknown\";\n }\n}\n\n/** One root query or mutation field, reduced to a prompt-friendly line. */\nexport type SchemaFieldSummary = {\n name: string;\n description?: string;\n args: string;\n returns: string;\n};\n\n/** Cap on the number of fields reported per root type. */\nconst MAX_FIELDS_PER_ROOT = 200;\n\nfunction summarizeFields(fields: IntrospectedField[] | null | undefined): {\n fields: SchemaFieldSummary[];\n truncated: boolean;\n} {\n const list = fields ?? [];\n return {\n fields: list.slice(0, MAX_FIELDS_PER_ROOT).map((field) => ({\n name: field.name,\n ...(field.description ? { description: field.description } : {}),\n args: field.args\n .map((arg) => `${arg.name}: ${renderTypeRef(arg.type)}`)\n .join(\", \"),\n returns: renderTypeRef(field.type),\n })),\n truncated: list.length > MAX_FIELDS_PER_ROOT,\n };\n}\n\n/**\n * Reduces a GraphQL `__schema` introspection payload (the `data.__schema`\n * object) to a compact summary of its root query and mutation fields.\n * Accepts `unknown` because the payload arrives over the wire.\n */\nexport function summarizeIntrospectionSchema(schema: unknown): {\n queries: SchemaFieldSummary[];\n mutations: SchemaFieldSummary[];\n truncated: boolean;\n} {\n const introspection = (schema ?? {}) as IntrospectedSchema;\n const queries = summarizeFields(introspection.queryType?.fields);\n const mutations = summarizeFields(introspection.mutationType?.fields);\n return {\n queries: queries.fields,\n mutations: mutations.fields,\n truncated: queries.truncated || mutations.truncated,\n };\n}\n\nexport const SWITCHBOARD_SCHEMA_TOOL_NAME = \"getSwitchboardSchema\";\n\n/** Test seams for {@link createSwitchboardSchemaTool}. */\nexport interface SwitchboardToolDeps {\n getSyncManager?: () => ISyncManager | undefined;\n getSelectedDriveId?: () => string | undefined;\n tokenProvider?: () => Promise<string | undefined>;\n fetchImpl?: typeof fetch;\n timeoutMs?: number;\n}\n\n/**\n * Creates the read-only `getSwitchboardSchema` tool: it introspects the\n * GraphQL supergraph of the switchboard serving a drive and returns a\n * summary of its root queries and mutations. It reads the schema only and\n * never modifies data.\n */\nexport function createSwitchboardSchemaTool(\n deps?: SwitchboardToolDeps,\n): AiToolDescriptor {\n const getSyncManager = deps?.getSyncManager ?? getBrowserSyncManager;\n const getSelectedDriveId =\n deps?.getSelectedDriveId ??\n ((): string | undefined =>\n typeof window === \"undefined\"\n ? undefined\n : getPHStore()?.selectedDriveId);\n const tokenProvider = deps?.tokenProvider ?? ambientRenownTokenProvider;\n const fetchImpl = deps?.fetchImpl ?? fetch;\n const timeoutMs = deps?.timeoutMs ?? 10_000;\n\n return {\n name: SWITCHBOARD_SCHEMA_TOOL_NAME,\n description:\n \"Introspect the GraphQL endpoint of the switchboard serving a drive and list the queries and mutations it exposes (reactor operations, document-model read models, package subgraphs). Read-only: it reads the schema only and never modifies data. Omit driveId to introspect the currently selected drive.\",\n inputSchema: {\n driveId: z\n .string()\n .describe(\n \"Drive to introspect. Omit to use the currently selected drive.\",\n )\n .optional(),\n },\n annotations: { readOnlyHint: true },\n callback: async (input: { driveId?: string } | undefined) => {\n const driveId = input?.driveId ?? getSelectedDriveId();\n const sb = resolveDriveSwitchboard(driveId, getSyncManager());\n if (!sb) {\n throw new Error(\n driveId\n ? `Drive \"${driveId}\" has no switchboard: it is not synced to a remote switchboard.`\n : \"No drive is currently selected and no driveId was given.\",\n );\n }\n\n const token = await tokenProvider();\n let response: Response;\n try {\n response = await fetchImpl(sb.graphqlUrl, {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n ...(token ? { authorization: `Bearer ${token}` } : {}),\n },\n body: JSON.stringify({ query: SWITCHBOARD_INTROSPECTION_QUERY }),\n signal: AbortSignal.timeout(timeoutMs),\n });\n } catch (error) {\n throw new Error(\n `Switchboard at ${sb.graphqlUrl} is not reachable: ${\n error instanceof Error ? error.message : String(error)\n }`,\n { cause: error },\n );\n }\n\n if (response.status === 401 || response.status === 403) {\n throw new Error(\n `Switchboard at ${sb.graphqlUrl} refused the request (HTTP ${response.status}). Sign in to the switchboard (Renown) and try again.`,\n );\n }\n if (!response.ok) {\n throw new Error(\n `Switchboard introspection failed: HTTP ${response.status} ${response.statusText} from ${sb.graphqlUrl}`,\n );\n }\n\n const body = (await response.json()) as {\n errors?: Array<{ message?: string }>;\n data?: { __schema?: unknown } | null;\n } | null;\n const schemaErrors = body?.errors;\n if (schemaErrors && schemaErrors.length > 0) {\n throw new Error(\n schemaErrors.map((e) => e.message ?? \"unknown error\").join(\"; \"),\n );\n }\n const schema = body?.data?.__schema as\n | IntrospectedSchema\n | null\n | undefined;\n if (!schema?.queryType) {\n throw new Error(\n `Switchboard at ${sb.graphqlUrl} did not return a GraphQL schema.`,\n );\n }\n\n const summary = summarizeIntrospectionSchema(schema);\n return {\n switchboardUrl: sb.switchboardUrl,\n graphqlUrl: sb.graphqlUrl,\n ...summary,\n };\n },\n };\n}\n"],"mappings":";;;;;;;;;;AAOA,SAAgB,gBAAgC,OAAY;CAC1D,OAAO,MAAM,UAAU,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC;AAC9D;;AAGA,SAAgB,eACd,MACkB;CAClB,IAAI,CAAC,MAAM,OAAO;CAClB,OAAO,KAAK,KAAK,YAAY,MAAM;AACrC;;AAGA,SAAgB,iBACd,MACoB;CACpB,IAAI,CAAC,MAAM,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