@peers-app/peers-sdk 0.14.0 → 0.15.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 (210) hide show
  1. package/dist/context/data-context.d.ts +4 -4
  2. package/dist/context/data-context.js +1 -1
  3. package/dist/context/index.d.ts +3 -3
  4. package/dist/context/index.js +4 -0
  5. package/dist/context/user-context-singleton.js +13 -14
  6. package/dist/context/user-context.d.ts +4 -4
  7. package/dist/context/user-context.js +48 -31
  8. package/dist/data/assistants.d.ts +1 -1
  9. package/dist/data/assistants.js +35 -24
  10. package/dist/data/change-tracking.d.ts +8 -8
  11. package/dist/data/change-tracking.js +45 -39
  12. package/dist/data/channels.js +5 -5
  13. package/dist/data/data-locks.d.ts +2 -2
  14. package/dist/data/data-locks.js +21 -23
  15. package/dist/data/data-locks.test.js +73 -75
  16. package/dist/data/device-sync-info.d.ts +1 -1
  17. package/dist/data/device-sync-info.js +4 -4
  18. package/dist/data/devices.d.ts +1 -1
  19. package/dist/data/devices.js +9 -12
  20. package/dist/data/embeddings.js +14 -11
  21. package/dist/data/files/file-read-stream.d.ts +2 -2
  22. package/dist/data/files/file-read-stream.js +23 -14
  23. package/dist/data/files/file-write-stream.d.ts +2 -2
  24. package/dist/data/files/file-write-stream.js +8 -8
  25. package/dist/data/files/file.types.d.ts +2 -2
  26. package/dist/data/files/file.types.js +17 -11
  27. package/dist/data/files/files.d.ts +6 -6
  28. package/dist/data/files/files.js +17 -19
  29. package/dist/data/files/files.test.js +213 -214
  30. package/dist/data/files/index.d.ts +4 -4
  31. package/dist/data/files/index.js +4 -4
  32. package/dist/data/group-member-roles.js +2 -2
  33. package/dist/data/group-members.d.ts +5 -5
  34. package/dist/data/group-members.js +27 -18
  35. package/dist/data/group-members.test.js +73 -73
  36. package/dist/data/group-permissions.d.ts +3 -3
  37. package/dist/data/group-permissions.js +13 -11
  38. package/dist/data/group-share.d.ts +2 -2
  39. package/dist/data/group-share.js +29 -24
  40. package/dist/data/groups.d.ts +4 -4
  41. package/dist/data/groups.js +27 -19
  42. package/dist/data/groups.test.js +44 -44
  43. package/dist/data/index.d.ts +6 -6
  44. package/dist/data/index.js +6 -6
  45. package/dist/data/knowledge/peer-types.js +9 -9
  46. package/dist/data/messages.d.ts +5 -5
  47. package/dist/data/messages.js +43 -30
  48. package/dist/data/orm/client-proxy.data-source.d.ts +4 -4
  49. package/dist/data/orm/client-proxy.data-source.js +10 -12
  50. package/dist/data/orm/cursor.d.ts +1 -1
  51. package/dist/data/orm/cursor.js +2 -2
  52. package/dist/data/orm/cursor.test.js +92 -93
  53. package/dist/data/orm/data-query.d.ts +3 -3
  54. package/dist/data/orm/data-query.js +24 -18
  55. package/dist/data/orm/data-query.mongo.d.ts +1 -1
  56. package/dist/data/orm/data-query.mongo.js +49 -51
  57. package/dist/data/orm/data-query.mongo.test.js +173 -204
  58. package/dist/data/orm/data-query.sqlite.d.ts +1 -1
  59. package/dist/data/orm/data-query.sqlite.js +84 -73
  60. package/dist/data/orm/data-query.sqlite.test.js +164 -176
  61. package/dist/data/orm/data-query.test.js +216 -224
  62. package/dist/data/orm/decorators.js +3 -3
  63. package/dist/data/orm/dependency-injection.test.js +53 -56
  64. package/dist/data/orm/doc.d.ts +4 -4
  65. package/dist/data/orm/doc.js +17 -21
  66. package/dist/data/orm/event-registry.d.ts +1 -1
  67. package/dist/data/orm/event-registry.test.js +16 -16
  68. package/dist/data/orm/factory.d.ts +2 -2
  69. package/dist/data/orm/factory.js +33 -33
  70. package/dist/data/orm/index.d.ts +10 -10
  71. package/dist/data/orm/index.js +10 -10
  72. package/dist/data/orm/multi-cursors.d.ts +1 -1
  73. package/dist/data/orm/multi-cursors.js +6 -6
  74. package/dist/data/orm/multi-cursors.test.js +152 -144
  75. package/dist/data/orm/sql.data-source.d.ts +7 -7
  76. package/dist/data/orm/sql.data-source.js +88 -93
  77. package/dist/data/orm/sql.data-source.test.js +109 -101
  78. package/dist/data/orm/subscribable.data-source.d.ts +4 -4
  79. package/dist/data/orm/subscribable.data-source.js +5 -5
  80. package/dist/data/orm/table-container-events.test.js +34 -26
  81. package/dist/data/orm/table-container.d.ts +6 -6
  82. package/dist/data/orm/table-container.js +33 -21
  83. package/dist/data/orm/table-container.test.js +64 -53
  84. package/dist/data/orm/table-definitions.system.d.ts +3 -3
  85. package/dist/data/orm/table-definitions.system.js +3 -3
  86. package/dist/data/orm/table-definitions.type.d.ts +5 -5
  87. package/dist/data/orm/table-dependencies.d.ts +2 -2
  88. package/dist/data/orm/table.d.ts +5 -5
  89. package/dist/data/orm/table.event-source.test.js +105 -115
  90. package/dist/data/orm/table.js +35 -34
  91. package/dist/data/orm/types.d.ts +3 -3
  92. package/dist/data/orm/types.js +26 -25
  93. package/dist/data/orm/types.test.js +166 -92
  94. package/dist/data/package-permissions.d.ts +1 -1
  95. package/dist/data/package-permissions.js +2 -2
  96. package/dist/data/package-version-permissions.d.ts +1 -1
  97. package/dist/data/package-version-permissions.js +2 -2
  98. package/dist/data/package-versions.d.ts +9 -9
  99. package/dist/data/package-versions.js +47 -33
  100. package/dist/data/packages.d.ts +2 -2
  101. package/dist/data/packages.js +36 -18
  102. package/dist/data/packages.utils.d.ts +2 -2
  103. package/dist/data/packages.utils.js +4 -4
  104. package/dist/data/persistent-vars.d.ts +15 -15
  105. package/dist/data/persistent-vars.js +165 -154
  106. package/dist/data/table-definitions-table.d.ts +5 -5
  107. package/dist/data/table-definitions-table.js +13 -12
  108. package/dist/data/tool-tests.js +6 -6
  109. package/dist/data/tools.js +29 -19
  110. package/dist/data/user-permissions.d.ts +1 -1
  111. package/dist/data/user-permissions.js +5 -5
  112. package/dist/data/user-permissions.test.js +90 -88
  113. package/dist/data/user-trust-levels.js +10 -10
  114. package/dist/data/users.d.ts +4 -4
  115. package/dist/data/users.js +16 -15
  116. package/dist/data/voice-messages.d.ts +2 -2
  117. package/dist/data/voice-messages.js +13 -13
  118. package/dist/data/welcome-modal.pvar.js +3 -1
  119. package/dist/data/workflow-logs.js +26 -18
  120. package/dist/data/workflow-runs.d.ts +6 -6
  121. package/dist/data/workflow-runs.js +70 -44
  122. package/dist/data/workflows.d.ts +2 -2
  123. package/dist/data/workflows.js +7 -9
  124. package/dist/device/binary-peer-connection-v2.d.ts +7 -7
  125. package/dist/device/binary-peer-connection-v2.js +32 -28
  126. package/dist/device/binary-peer-connection-v2.test.js +80 -67
  127. package/dist/device/binary-peer-connection.d.ts +7 -7
  128. package/dist/device/binary-peer-connection.js +29 -28
  129. package/dist/device/binary-peer-connection.test.js +35 -31
  130. package/dist/device/connection.d.ts +5 -5
  131. package/dist/device/connection.js +59 -48
  132. package/dist/device/connection.test.js +74 -68
  133. package/dist/device/device-election.d.ts +2 -2
  134. package/dist/device/device-election.js +25 -20
  135. package/dist/device/device-election.test.js +35 -36
  136. package/dist/device/device.d.ts +2 -2
  137. package/dist/device/device.js +10 -4
  138. package/dist/device/device.test.js +16 -17
  139. package/dist/device/get-trust-level-fn.d.ts +2 -2
  140. package/dist/device/get-trust-level-fn.js +22 -11
  141. package/dist/device/get-trust-level-fn.test.js +58 -58
  142. package/dist/device/socket-io-binary-peer.d.ts +1 -1
  143. package/dist/device/socket-io-binary-peer.js +16 -13
  144. package/dist/device/socket.type.d.ts +2 -2
  145. package/dist/device/streamed-socket.d.ts +2 -2
  146. package/dist/device/streamed-socket.js +8 -8
  147. package/dist/device/streamed-socket.test.js +40 -40
  148. package/dist/device/tx-encoding.test.js +77 -77
  149. package/dist/events.d.ts +1 -1
  150. package/dist/events.js +5 -2
  151. package/dist/group-invite/group-invite.js +110 -19
  152. package/dist/group-invite/group-invite.pvars.d.ts +2 -2
  153. package/dist/group-invite/group-invite.pvars.js +21 -13
  154. package/dist/group-invite/group-invite.types.d.ts +1 -1
  155. package/dist/group-invite/index.d.ts +3 -3
  156. package/dist/group-invite/index.js +1 -1
  157. package/dist/index.d.ts +25 -24
  158. package/dist/index.js +30 -25
  159. package/dist/keys.d.ts +3 -3
  160. package/dist/keys.js +31 -30
  161. package/dist/keys.test.js +69 -61
  162. package/dist/logging/console-logger.d.ts +1 -1
  163. package/dist/logging/console-logger.js +35 -40
  164. package/dist/logging/console-logger.test.js +115 -115
  165. package/dist/logging/console-logs.table.d.ts +3 -3
  166. package/dist/logging/console-logs.table.js +28 -23
  167. package/dist/mentions.js +16 -12
  168. package/dist/observable.d.ts +2 -2
  169. package/dist/observable.js +15 -9
  170. package/dist/observable.test.js +47 -47
  171. package/dist/package-loader/get-require.js +3 -4
  172. package/dist/package-loader/package-loader.d.ts +2 -2
  173. package/dist/package-loader/package-loader.js +52 -34
  174. package/dist/peers-ui/peers-ui.d.ts +2 -2
  175. package/dist/peers-ui/peers-ui.js +2 -4
  176. package/dist/peers-ui/peers-ui.types.d.ts +3 -3
  177. package/dist/peers-ui/peers-ui.types.js +0 -1
  178. package/dist/rpc-types.d.ts +61 -59
  179. package/dist/rpc-types.js +61 -55
  180. package/dist/serial-json.d.ts +1 -1
  181. package/dist/serial-json.js +50 -43
  182. package/dist/serial-json.test.js +22 -22
  183. package/dist/system-ids.js +8 -8
  184. package/dist/tools/index.d.ts +1 -1
  185. package/dist/tools/tools-factory.d.ts +1 -1
  186. package/dist/tools/tools-factory.js +2 -2
  187. package/dist/types/assistant-runner-args.d.ts +3 -3
  188. package/dist/types/peer-device.d.ts +1 -1
  189. package/dist/types/peers-package.d.ts +3 -3
  190. package/dist/types/workflow-logger.d.ts +1 -1
  191. package/dist/types/workflow-run-context.d.ts +4 -4
  192. package/dist/types/workflow.d.ts +4 -4
  193. package/dist/types/workflow.js +27 -14
  194. package/dist/types/zod-types.d.ts +2 -1
  195. package/dist/types/zod-types.js +9 -3
  196. package/dist/user-connect/connection-code.d.ts +1 -1
  197. package/dist/user-connect/connection-code.js +7 -7
  198. package/dist/user-connect/connection-code.test.js +106 -106
  199. package/dist/user-connect/index.d.ts +3 -3
  200. package/dist/user-connect/index.js +1 -1
  201. package/dist/user-connect/user-connect.pvars.js +13 -11
  202. package/dist/user-connect/user-connect.types.d.ts +3 -3
  203. package/dist/users.query.d.ts +2 -2
  204. package/dist/users.query.js +40 -30
  205. package/dist/utils.d.ts +2 -2
  206. package/dist/utils.js +34 -32
  207. package/dist/utils.test.js +12 -8
  208. package/dist/workflow-log-formatter.d.ts +1 -1
  209. package/dist/workflow-log-formatter.js +17 -18
  210. package/package.json +14 -8
@@ -2,11 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PackageLoader = void 0;
4
4
  exports.setDefaultRequire = setDefaultRequire;
5
- const tools_1 = require("../tools");
6
5
  const files_1 = require("../data/files");
7
6
  const package_versions_1 = require("../data/package-versions");
8
7
  const packages_1 = require("../data/packages");
9
- const tools_2 = require("../data/tools");
8
+ const tools_1 = require("../data/tools");
9
+ const tools_2 = require("../tools");
10
10
  class PackageLoader {
11
11
  dataContext;
12
12
  static PeersSDK;
@@ -18,12 +18,7 @@ class PackageLoader {
18
18
  }
19
19
  async loadAllPackages(opts) {
20
20
  const packages = await (0, packages_1.Packages)(this.dataContext).list();
21
- await Promise.all(packages.map(pkg => {
22
- if (pkg.disabled) {
23
- return;
24
- }
25
- return this.loadPackage(pkg, opts);
26
- }));
21
+ await Promise.all(packages.filter((pkg) => !pkg.disabled).map((pkg) => this.loadPackage(pkg, opts)));
27
22
  }
28
23
  async loadPackage(pkg, opts) {
29
24
  if (this.packageInstances[pkg.packageId] && !opts?.force) {
@@ -31,7 +26,7 @@ class PackageLoader {
31
26
  }
32
27
  const localPath = opts?.localPath;
33
28
  try {
34
- let bundleCode = '';
29
+ let bundleCode = "";
35
30
  let bundleFileId;
36
31
  if (pkg.activePackageVersionId) {
37
32
  try {
@@ -40,13 +35,15 @@ class PackageLoader {
40
35
  bundleFileId = pv.packageBundleFileId;
41
36
  }
42
37
  }
43
- catch { /* no version record */ }
38
+ catch {
39
+ /* no version record */
40
+ }
44
41
  }
45
42
  if (bundleFileId) {
46
43
  const filesTable = (0, files_1.Files)(this.dataContext);
47
44
  const bundleBuffer = await filesTable.getFileContents(bundleFileId);
48
45
  if (bundleBuffer) {
49
- bundleCode = Buffer.from(bundleBuffer).toString('utf8');
46
+ bundleCode = Buffer.from(bundleBuffer).toString("utf8");
50
47
  }
51
48
  else {
52
49
  console.warn(`Package bundle file not found for ${pkg.name} (fileId: ${bundleFileId})`);
@@ -57,7 +54,7 @@ class PackageLoader {
57
54
  }
58
55
  // Fallback: try loading from local path if stored bundle is not available
59
56
  if (!bundleCode && localPath) {
60
- bundleCode = this._readLocalBundle(localPath) ?? '';
57
+ bundleCode = this._readLocalBundle(localPath) ?? "";
61
58
  }
62
59
  if (!bundleCode)
63
60
  return;
@@ -83,12 +80,12 @@ class PackageLoader {
83
80
  }
84
81
  _readLocalBundle(localPath) {
85
82
  try {
86
- const _require = this.require ?? defaultRequire ?? (typeof require === 'function' ? require : null);
83
+ const _require = this.require ?? defaultRequire ?? (typeof require === "function" ? require : null);
87
84
  if (!_require || !localPath)
88
85
  return;
89
- const fs = _require('fs');
90
- const path = _require('path');
91
- return fs.readFileSync(path.join(localPath, 'dist', 'package.bundle.js'), 'utf8');
86
+ const fs = _require("fs");
87
+ const path = _require("path");
88
+ return fs.readFileSync(path.join(localPath, "dist", "package.bundle.js"), "utf8");
92
89
  }
93
90
  catch {
94
91
  return;
@@ -102,26 +99,45 @@ class PackageLoader {
102
99
  //
103
100
  // In Node.js / Electron environments these modules ARE available, so we skip
104
101
  // the guard and let require pass through normally.
105
- const isNodeEnvironment = typeof process !== 'undefined' && !!process.versions?.node;
102
+ const isNodeEnvironment = typeof process !== "undefined" && !!process.versions?.node;
106
103
  const NODE_ONLY_MODULES = new Set([
107
- 'child_process', 'fs', 'path', 'os', 'crypto', 'http', 'https',
108
- 'net', 'tls', 'stream', 'buffer', 'util', 'events', 'assert',
109
- 'dns', 'url', 'querystring', 'readline', 'repl', 'vm',
110
- 'worker_threads', 'cluster', 'perf_hooks',
104
+ "child_process",
105
+ "fs",
106
+ "path",
107
+ "os",
108
+ "crypto",
109
+ "http",
110
+ "https",
111
+ "net",
112
+ "tls",
113
+ "stream",
114
+ "buffer",
115
+ "util",
116
+ "events",
117
+ "assert",
118
+ "dns",
119
+ "url",
120
+ "querystring",
121
+ "readline",
122
+ "repl",
123
+ "vm",
124
+ "worker_threads",
125
+ "cluster",
126
+ "perf_hooks",
111
127
  ]);
112
128
  const moduleExports = {};
113
129
  const module = { exports: moduleExports };
114
130
  const customRequire = (moduleId) => {
115
- const _require = this.require ?? defaultRequire ?? typeof require === 'function' ? require : undefined;
131
+ const _require = (this.require ?? defaultRequire ?? typeof require === "function") ? require : undefined;
116
132
  if (!_require) {
117
- throw new Error('You must set the `require` function in package loader before loading a package');
133
+ throw new Error("You must set the `require` function in package loader before loading a package");
118
134
  }
119
135
  switch (moduleId) {
120
- case 'peers-sdk':
121
- case 'PeersSDK':
122
- return PackageLoader.PeersSDK || _require('../index');
123
- case 'zod':
124
- return PackageLoader.Zod || _require('zod');
136
+ case "peers-sdk":
137
+ case "PeersSDK":
138
+ return PackageLoader.PeersSDK || _require("../index");
139
+ case "zod":
140
+ return PackageLoader.Zod || _require("zod");
125
141
  default:
126
142
  // TODO: Add a permissions system for packages — packages should declare which
127
143
  // external Node modules they need (e.g. child_process, os, path), and the loader
@@ -137,18 +153,20 @@ class PackageLoader {
137
153
  }
138
154
  };
139
155
  try {
140
- const bundleFunction = new Function('module', 'exports', 'require', bundleCode);
156
+ const bundleFunction = new Function("module", "exports", "require", bundleCode);
141
157
  bundleFunction(module, moduleExports, customRequire);
142
158
  const bundleExports = module.exports;
143
159
  const packageInstance = bundleExports?.exports || bundleExports?.package || bundleExports?.default || bundleExports;
144
160
  this.packageInstances[pkg.packageId] = packageInstance;
145
- if (packageInstance && typeof packageInstance === 'object') {
161
+ if (packageInstance && typeof packageInstance === "object") {
146
162
  packageInstance.toolInstances?.forEach((toolInstance) => {
147
- (0, tools_1.registerTool)(toolInstance);
148
- (0, tools_2.Tools)(this.dataContext).save(toolInstance.tool);
163
+ (0, tools_2.registerTool)(toolInstance);
164
+ (0, tools_1.Tools)(this.dataContext).save(toolInstance.tool);
149
165
  });
150
166
  packageInstance.tableDefinitions?.forEach((tableDefinition) => {
151
- this.dataContext.tableContainer.registerTableDefinition(tableDefinition, { overwrite: true });
167
+ this.dataContext.tableContainer.registerTableDefinition(tableDefinition, {
168
+ overwrite: true,
169
+ });
152
170
  });
153
171
  return packageInstance;
154
172
  }
@@ -161,7 +179,7 @@ class PackageLoader {
161
179
  }
162
180
  }
163
181
  exports.PackageLoader = PackageLoader;
164
- let defaultRequire = undefined;
182
+ let defaultRequire;
165
183
  function setDefaultRequire(require) {
166
184
  defaultRequire = require;
167
185
  }
@@ -1,5 +1,5 @@
1
+ import type { ZodAny, ZodArray, ZodObject, ZodTypeAny } from "zod";
1
2
  import type { IPeersUIRoute } from "./peers-ui.types";
2
- import type { ZodObject, ZodArray, ZodAny, ZodTypeAny } from "zod";
3
3
  export interface IPeersUI {
4
4
  peersUIId: string;
5
5
  propsSchema: ZodObject<any> | ZodArray<any> | ZodAny | ZodTypeAny;
@@ -12,4 +12,4 @@ export declare const PeersUI: (props: {
12
12
  uiSubcategory?: IPeersUIRoute["uiSubcategory"];
13
13
  children?: React.ReactNode;
14
14
  props?: Record<string, any>;
15
- }) => (React.ReactNode | undefined);
15
+ }) => React.ReactNode | undefined;
@@ -1,10 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PeersUI = void 0;
4
- const PeersUI = (props
5
- // @ts-ignore
6
- ) => {
7
- if (typeof window === 'undefined') {
4
+ const PeersUI = (props) => {
5
+ if (typeof window === "undefined") {
8
6
  throw new Error("PeersUI can only be used in the browser");
9
7
  }
10
8
  const _window = window;
@@ -1,6 +1,6 @@
1
- import type { ZodObject, ZodAny, ZodArray, ZodTypeAny } from "zod";
2
- export type UICategory = 'field' | 'list' | 'details' | 'screen' | 'list-item' | 'other' | '*';
3
- export type UIEditMode = 'view' | 'edit' | 'create' | '*';
1
+ import type { ZodAny, ZodArray, ZodObject, ZodTypeAny } from "zod";
2
+ export type UICategory = "field" | "list" | "details" | "screen" | "list-item" | "other" | "*";
3
+ export type UIEditMode = "view" | "edit" | "create" | "*";
4
4
  export type UIContextPropsSchema = ZodObject<any> | ZodAny | ZodArray<any> | ZodTypeAny;
5
5
  export interface UIContext {
6
6
  /** The current screen path */
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- ;
@@ -27,23 +27,23 @@ export interface UIState {
27
27
  }
28
28
  export declare const rpcServerCalls: {
29
29
  ping: (msg: string) => Promise<string>;
30
- openLinkInBrowser: ((url: string) => Promise<void>);
31
- openPath: ((path: string) => Promise<void>);
32
- openPackage: ((path: string) => Promise<void>);
33
- addOrUpdatePackage: ((input: string, options?: {
30
+ openLinkInBrowser: (url: string) => Promise<void>;
31
+ openPath: (path: string) => Promise<void>;
32
+ openPackage: (path: string) => Promise<void>;
33
+ addOrUpdatePackage: (input: string, options?: {
34
34
  dataContextId?: string;
35
35
  packageLocation?: string;
36
36
  update?: boolean;
37
37
  linkRemote?: boolean;
38
- }) => Promise<string>);
39
- setUserIdAndSecretKey: ((userId: string, secretKey: string) => Promise<void>);
38
+ }) => Promise<string>;
39
+ setUserIdAndSecretKey: (userId: string, secretKey: string) => Promise<void>;
40
40
  getUserId: () => Promise<string | undefined>;
41
- encryptData: ((value: string, groupId?: string) => Promise<string>);
42
- logout: (() => Promise<void>);
43
- tableMethodCall: ((dataContextId: string, tableName: string, methodName: string, ...args: any[]) => Promise<any>);
44
- getFileContents: ((fileId: string, encoding?: BufferEncoding) => Promise<string>);
45
- getFileContentsBase64: ((fileId: string) => Promise<string>);
46
- saveFile: ((input: {
41
+ encryptData: (value: string, groupId?: string) => Promise<string>;
42
+ logout: () => Promise<void>;
43
+ tableMethodCall: (dataContextId: string, tableName: string, methodName: string, ...args: any[]) => Promise<any>;
44
+ getFileContents: (fileId: string, encoding?: BufferEncoding) => Promise<string>;
45
+ getFileContentsBase64: (fileId: string) => Promise<string>;
46
+ saveFile: (input: {
47
47
  name: string;
48
48
  mimeType?: string;
49
49
  data: string;
@@ -55,37 +55,39 @@ export declare const rpcServerCalls: {
55
55
  fileSize: number;
56
56
  fileHash: string;
57
57
  mimeType?: string;
58
- }>);
59
- injectUIBundle: ((uiBundleFileId: string) => Promise<void>);
60
- resetAllDeviceSyncInfo: (() => Promise<void>);
61
- deleteLocalDatabase: (() => Promise<void>);
62
- importGroupShare: ((groupShareJson: string) => Promise<string>);
63
- appQuit: (() => Promise<void>);
64
- appRestart: (() => Promise<void>);
65
- dbQuery: ((query: string, dataContextId?: string) => Promise<{
58
+ }>;
59
+ injectUIBundle: (uiBundleFileId: string) => Promise<void>;
60
+ resetAllDeviceSyncInfo: () => Promise<void>;
61
+ /** Clear change tracking and rebuild from current rows for the default data context (same as Data Explorer). */
62
+ resetChangeTracking: () => Promise<void>;
63
+ deleteLocalDatabase: () => Promise<void>;
64
+ importGroupShare: (groupShareJson: string) => Promise<string>;
65
+ appQuit: () => Promise<void>;
66
+ appRestart: () => Promise<void>;
67
+ dbQuery: (query: string, dataContextId?: string) => Promise<{
66
68
  columns: string[];
67
69
  rows: any[][];
68
70
  rowCount: number;
69
- }>);
70
- runTool: ((toolId: string, args: Record<string, any>, dataContextId?: string, assistantId?: string) => Promise<any>);
71
- uiReload: ((options?: {
71
+ }>;
72
+ runTool: (toolId: string, args: Record<string, any>, dataContextId?: string, assistantId?: string) => Promise<any>;
73
+ uiReload: (options?: {
72
74
  ignoreCache?: boolean;
73
- }) => Promise<void>);
74
- uiInspect: ((options?: {
75
+ }) => Promise<void>;
76
+ uiInspect: (options?: {
75
77
  includeRects?: boolean;
76
- }) => Promise<UIState>);
77
- uiClick: ((selector: string) => Promise<{
78
+ }) => Promise<UIState>;
79
+ uiClick: (selector: string) => Promise<{
78
80
  success: boolean;
79
81
  error?: string;
80
- }>);
81
- uiSet: ((selector: string, text: string, options?: {
82
+ }>;
83
+ uiSet: (selector: string, text: string, options?: {
82
84
  clear?: boolean;
83
85
  pressEnter?: boolean;
84
86
  }) => Promise<{
85
87
  success: boolean;
86
88
  error?: string;
87
- }>);
88
- uiScroll: ((options: {
89
+ }>;
90
+ uiScroll: (options: {
89
91
  selector?: string;
90
92
  x?: number;
91
93
  y?: number;
@@ -94,46 +96,46 @@ export declare const rpcServerCalls: {
94
96
  }) => Promise<{
95
97
  success: boolean;
96
98
  error?: string;
97
- }>);
98
- voiceGetState: (() => Promise<{
99
+ }>;
100
+ voiceGetState: () => Promise<{
99
101
  state: "disabled" | "idle" | "listening" | "recording" | "processing" | "speaking";
100
102
  keyError?: "refused" | "invalid" | "limit" | "throttled";
101
- }>);
102
- voiceStartRecording: (() => Promise<void>);
103
- voiceStopRecording: (() => Promise<void>);
104
- voiceCancelRecording: (() => Promise<void>);
105
- voiceSetTargetChannel: ((channelId: string) => Promise<void>);
106
- voiceGetAudioDevices: (() => Promise<string[]>);
107
- voiceTestTTS: ((text: string) => Promise<void>);
108
- voiceNotifyPlaybackComplete: (() => Promise<void>);
109
- voiceStopPlayback: (() => Promise<void>);
110
- voiceGetThreadId: (() => Promise<string | null>);
111
- voiceSetThreadId: ((threadId: string | null) => Promise<void>);
112
- voiceNotifyTextActivity: (() => Promise<void>);
113
- voiceDisable: (() => Promise<void>);
114
- voiceEnable: (() => Promise<void>);
115
- flushDatabases: (() => Promise<void>);
103
+ }>;
104
+ voiceStartRecording: () => Promise<void>;
105
+ voiceStopRecording: () => Promise<void>;
106
+ voiceCancelRecording: () => Promise<void>;
107
+ voiceSetTargetChannel: (channelId: string) => Promise<void>;
108
+ voiceGetAudioDevices: () => Promise<string[]>;
109
+ voiceTestTTS: (text: string) => Promise<void>;
110
+ voiceNotifyPlaybackComplete: () => Promise<void>;
111
+ voiceStopPlayback: () => Promise<void>;
112
+ voiceGetThreadId: () => Promise<string | null>;
113
+ voiceSetThreadId: (threadId: string | null) => Promise<void>;
114
+ voiceNotifyTextActivity: () => Promise<void>;
115
+ voiceDisable: () => Promise<void>;
116
+ voiceEnable: () => Promise<void>;
117
+ flushDatabases: () => Promise<void>;
116
118
  };
117
119
  export declare const rpcClientCalls: {
118
120
  ping: (msg: string) => Promise<string>;
119
- emitEvent: ((event: IEventData) => Promise<boolean>);
120
- setClientPath: ((url: string) => Promise<void>);
121
- openThread: ((threadId: string) => Promise<void>);
122
- uiGetState: ((options?: {
121
+ emitEvent: (event: IEventData) => Promise<boolean>;
122
+ setClientPath: (url: string) => Promise<void>;
123
+ openThread: (threadId: string) => Promise<void>;
124
+ uiGetState: (options?: {
123
125
  includeRects?: boolean;
124
- }) => Promise<UIState>);
125
- uiDoClick: ((selector: string) => Promise<{
126
+ }) => Promise<UIState>;
127
+ uiDoClick: (selector: string) => Promise<{
126
128
  success: boolean;
127
129
  error?: string;
128
- }>);
129
- uiDoSet: ((selector: string, text: string, options?: {
130
+ }>;
131
+ uiDoSet: (selector: string, text: string, options?: {
130
132
  clear?: boolean;
131
133
  pressEnter?: boolean;
132
134
  }) => Promise<{
133
135
  success: boolean;
134
136
  error?: string;
135
- }>);
136
- uiDoScroll: ((options: {
137
+ }>;
138
+ uiDoScroll: (options: {
137
139
  selector?: string;
138
140
  x?: number;
139
141
  y?: number;
@@ -142,7 +144,7 @@ export declare const rpcClientCalls: {
142
144
  }) => Promise<{
143
145
  success: boolean;
144
146
  error?: string;
145
- }>);
147
+ }>;
146
148
  };
147
149
  export type RpcServerNames = keyof typeof rpcServerCalls;
148
150
  export type RpcClientNames = keyof typeof rpcClientCalls;
package/dist/rpc-types.js CHANGED
@@ -5,60 +5,64 @@ exports.setSingleProcessClient = setSingleProcessClient;
5
5
  exports.isSingleProcessClient = isSingleProcessClient;
6
6
  function rpcStub(rpcName) {
7
7
  return async (...args) => {
8
- console.warn(rpcName + ': rpc fn not set. This means that an RPC call is happening before the RPC function has been set. This is either a race condition or the RPC handler was never set.' + JSON.stringify({ rpcName, args }, null, 2));
8
+ console.warn(rpcName +
9
+ ": rpc fn not set. This means that an RPC call is happening before the RPC function has been set. This is either a race condition or the RPC handler was never set." +
10
+ JSON.stringify({ rpcName, args }, null, 2));
9
11
  };
10
12
  }
11
13
  exports.rpcServerCalls = {
12
14
  ping: async (msg) => `pong: ${msg}`,
13
15
  // TODO collapse these two down to just openPath
14
- openLinkInBrowser: rpcStub('openLinkInBrowser'),
15
- openPath: rpcStub('openPath'),
16
- openPackage: rpcStub('OpenPackage'),
17
- addOrUpdatePackage: rpcStub('addOrUpdatePackage'),
18
- setUserIdAndSecretKey: rpcStub('setUserIdAndSecretKey'),
19
- getUserId: rpcStub('getUserId'),
20
- encryptData: rpcStub('encryptData'),
21
- logout: rpcStub('logout'),
22
- tableMethodCall: rpcStub('tableMethodCall'),
16
+ openLinkInBrowser: rpcStub("openLinkInBrowser"),
17
+ openPath: rpcStub("openPath"),
18
+ openPackage: rpcStub("OpenPackage"),
19
+ addOrUpdatePackage: rpcStub("addOrUpdatePackage"),
20
+ setUserIdAndSecretKey: rpcStub("setUserIdAndSecretKey"),
21
+ getUserId: rpcStub("getUserId"),
22
+ encryptData: rpcStub("encryptData"),
23
+ logout: rpcStub("logout"),
24
+ tableMethodCall: rpcStub("tableMethodCall"),
23
25
  // TODO lock this down so not all code can get any file contents
24
- getFileContents: rpcStub('getFileContents'),
26
+ getFileContents: rpcStub("getFileContents"),
25
27
  // Get file contents as base64 - useful for binary data like images
26
- getFileContentsBase64: rpcStub('getFileContentsBase64'),
28
+ getFileContentsBase64: rpcStub("getFileContentsBase64"),
27
29
  // Save a file from the UI - data should be base64 encoded for binary files
28
- saveFile: rpcStub('saveFile'),
30
+ saveFile: rpcStub("saveFile"),
29
31
  // Inject UI bundle directly into WebView (bypasses slow postMessage for large strings)
30
- injectUIBundle: rpcStub('injectUIBundle'),
31
- resetAllDeviceSyncInfo: rpcStub('resetAllDeviceSyncInfo'),
32
- deleteLocalDatabase: rpcStub('deleteLocalDatabase'),
33
- importGroupShare: rpcStub('importGroupShare'),
32
+ injectUIBundle: rpcStub("injectUIBundle"),
33
+ resetAllDeviceSyncInfo: rpcStub("resetAllDeviceSyncInfo"),
34
+ /** Clear change tracking and rebuild from current rows for the default data context (same as Data Explorer). */
35
+ resetChangeTracking: rpcStub("resetChangeTracking"),
36
+ deleteLocalDatabase: rpcStub("deleteLocalDatabase"),
37
+ importGroupShare: rpcStub("importGroupShare"),
34
38
  // App lifecycle commands (for CLI control)
35
- appQuit: rpcStub('appQuit'),
36
- appRestart: rpcStub('appRestart'),
39
+ appQuit: rpcStub("appQuit"),
40
+ appRestart: rpcStub("appRestart"),
37
41
  // Database exploration (for CLI)
38
- dbQuery: rpcStub('dbQuery'),
42
+ dbQuery: rpcStub("dbQuery"),
39
43
  // Direct tool execution (for CLI)
40
- runTool: rpcStub('runTool'),
44
+ runTool: rpcStub("runTool"),
41
45
  // UI control (for CLI)
42
- uiReload: rpcStub('uiReload'),
43
- uiInspect: rpcStub('uiInspect'),
44
- uiClick: rpcStub('uiClick'),
45
- uiSet: rpcStub('uiSet'),
46
- uiScroll: rpcStub('uiScroll'),
46
+ uiReload: rpcStub("uiReload"),
47
+ uiInspect: rpcStub("uiInspect"),
48
+ uiClick: rpcStub("uiClick"),
49
+ uiSet: rpcStub("uiSet"),
50
+ uiScroll: rpcStub("uiScroll"),
47
51
  // Voice control (settings managed via voiceSettings pvar, keys via secret pvars)
48
- voiceGetState: rpcStub('voiceGetState'),
49
- voiceStartRecording: rpcStub('voiceStartRecording'),
50
- voiceStopRecording: rpcStub('voiceStopRecording'),
51
- voiceCancelRecording: rpcStub('voiceCancelRecording'),
52
- voiceSetTargetChannel: rpcStub('voiceSetTargetChannel'),
53
- voiceGetAudioDevices: rpcStub('voiceGetAudioDevices'),
54
- voiceTestTTS: rpcStub('voiceTestTTS'),
55
- voiceNotifyPlaybackComplete: rpcStub('voiceNotifyPlaybackComplete'),
56
- voiceStopPlayback: rpcStub('voiceStopPlayback'),
57
- voiceGetThreadId: rpcStub('voiceGetThreadId'),
58
- voiceSetThreadId: rpcStub('voiceSetThreadId'),
59
- voiceNotifyTextActivity: rpcStub('voiceNotifyTextActivity'),
60
- voiceDisable: rpcStub('voiceDisable'),
61
- voiceEnable: rpcStub('voiceEnable'),
52
+ voiceGetState: rpcStub("voiceGetState"),
53
+ voiceStartRecording: rpcStub("voiceStartRecording"),
54
+ voiceStopRecording: rpcStub("voiceStopRecording"),
55
+ voiceCancelRecording: rpcStub("voiceCancelRecording"),
56
+ voiceSetTargetChannel: rpcStub("voiceSetTargetChannel"),
57
+ voiceGetAudioDevices: rpcStub("voiceGetAudioDevices"),
58
+ voiceTestTTS: rpcStub("voiceTestTTS"),
59
+ voiceNotifyPlaybackComplete: rpcStub("voiceNotifyPlaybackComplete"),
60
+ voiceStopPlayback: rpcStub("voiceStopPlayback"),
61
+ voiceGetThreadId: rpcStub("voiceGetThreadId"),
62
+ voiceSetThreadId: rpcStub("voiceSetThreadId"),
63
+ voiceNotifyTextActivity: rpcStub("voiceNotifyTextActivity"),
64
+ voiceDisable: rpcStub("voiceDisable"),
65
+ voiceEnable: rpcStub("voiceEnable"),
62
66
  // Flush all in-memory database snapshots to durable storage (IndexedDB in PWA).
63
67
  // No-op on Electron where better-sqlite3 writes are synchronous to disk.
64
68
  flushDatabases: (async () => { }),
@@ -70,30 +74,32 @@ exports.rpcServerCalls = {
70
74
  exports.rpcClientCalls = {
71
75
  ping: async (msg) => `pong: ${msg}`,
72
76
  // emitEvent: rpcStub('emitEvent') as ((event: IEventData) => Promise<boolean>),
73
- emitEvent: ((...args) => Promise.resolve(false)),
74
- setClientPath: rpcStub('setClientPath'),
75
- openThread: rpcStub('openThread'),
77
+ emitEvent: ((..._args) => Promise.resolve(false)),
78
+ setClientPath: rpcStub("setClientPath"),
79
+ openThread: rpcStub("openThread"),
76
80
  // UI inspection (for CLI)
77
- uiGetState: rpcStub('uiGetState'),
81
+ uiGetState: rpcStub("uiGetState"),
78
82
  // UI actions (for CLI)
79
- uiDoClick: rpcStub('uiDoClick'),
80
- uiDoSet: rpcStub('uiDoSet'),
81
- uiDoScroll: rpcStub('uiDoScroll'),
83
+ uiDoClick: rpcStub("uiDoClick"),
84
+ uiDoSet: rpcStub("uiDoSet"),
85
+ uiDoScroll: rpcStub("uiDoScroll"),
82
86
  };
83
87
  // Check if we're in a client context (browser, webview, or CLI connected to server)
84
88
  // - Browser: window + document exist
85
89
  // - CLI: process.env.PEERS_IS_CLIENT === 'true'
86
- exports.isClient = (typeof window !== 'undefined' && typeof document !== 'undefined')
87
- || (typeof process !== 'undefined' && process.env?.PEERS_IS_CLIENT === 'true');
90
+ exports.isClient = (typeof window !== "undefined" && typeof document !== "undefined") ||
91
+ (typeof process !== "undefined" && process.env?.PEERS_IS_CLIENT === "true");
88
92
  // Single-process mode (PWA): client and server live in the same process,
89
93
  // so Table events must NOT be suppressed on the client side.
90
94
  let _singleProcessClient = false;
91
- function setSingleProcessClient(value) { _singleProcessClient = value; }
92
- function isSingleProcessClient() { return _singleProcessClient; }
95
+ function setSingleProcessClient(value) {
96
+ _singleProcessClient = value;
97
+ }
98
+ function isSingleProcessClient() {
99
+ return _singleProcessClient;
100
+ }
93
101
  if (exports.isClient) {
94
- if (typeof window !== 'undefined') {
95
- // @ts-ignore
96
- const _window = window;
97
- _window['rpc'] = exports.rpcServerCalls;
102
+ if (typeof window !== "undefined") {
103
+ window.rpc = exports.rpcServerCalls;
98
104
  }
99
105
  }
@@ -1,5 +1,5 @@
1
1
  export declare function isObject(x: any): x is Record<string, any>;
2
2
  export declare function toJSON(obj: any): any;
3
- export declare function fromJSON(obj: any, externalReferences?: any): any;
3
+ export declare function fromJSON(obj: any, _externalReferences?: any): any;
4
4
  export declare function toJSONString(obj: any): string;
5
5
  export declare function fromJSONString(str: string): any;