@peers-app/peers-sdk 0.14.1 → 0.15.1
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.
- package/dist/context/data-context.d.ts +4 -4
- package/dist/context/data-context.js +1 -1
- package/dist/context/index.d.ts +3 -3
- package/dist/context/index.js +4 -0
- package/dist/context/user-context-singleton.js +13 -14
- package/dist/context/user-context.d.ts +4 -4
- package/dist/context/user-context.js +48 -31
- package/dist/data/assistants.d.ts +1 -1
- package/dist/data/assistants.js +35 -24
- package/dist/data/change-tracking.d.ts +8 -8
- package/dist/data/change-tracking.js +45 -39
- package/dist/data/channels.js +5 -5
- package/dist/data/data-locks.d.ts +2 -2
- package/dist/data/data-locks.js +21 -23
- package/dist/data/data-locks.test.js +73 -75
- package/dist/data/device-sync-info.d.ts +1 -1
- package/dist/data/device-sync-info.js +4 -4
- package/dist/data/devices.d.ts +1 -1
- package/dist/data/devices.js +9 -12
- package/dist/data/embeddings.js +14 -11
- package/dist/data/files/file-read-stream.d.ts +2 -2
- package/dist/data/files/file-read-stream.js +23 -14
- package/dist/data/files/file-write-stream.d.ts +2 -2
- package/dist/data/files/file-write-stream.js +8 -8
- package/dist/data/files/file.types.d.ts +2 -2
- package/dist/data/files/file.types.js +17 -11
- package/dist/data/files/files.d.ts +6 -6
- package/dist/data/files/files.js +17 -19
- package/dist/data/files/files.test.js +213 -214
- package/dist/data/files/index.d.ts +4 -4
- package/dist/data/files/index.js +4 -4
- package/dist/data/group-member-roles.js +2 -2
- package/dist/data/group-members.d.ts +5 -5
- package/dist/data/group-members.js +27 -18
- package/dist/data/group-members.test.js +73 -73
- package/dist/data/group-permissions.d.ts +3 -3
- package/dist/data/group-permissions.js +13 -11
- package/dist/data/group-share.d.ts +2 -2
- package/dist/data/group-share.js +29 -24
- package/dist/data/groups.d.ts +4 -4
- package/dist/data/groups.js +27 -19
- package/dist/data/groups.test.js +44 -44
- package/dist/data/index.d.ts +6 -6
- package/dist/data/index.js +6 -6
- package/dist/data/knowledge/peer-types.js +9 -9
- package/dist/data/messages.d.ts +5 -5
- package/dist/data/messages.js +43 -30
- package/dist/data/orm/client-proxy.data-source.d.ts +4 -4
- package/dist/data/orm/client-proxy.data-source.js +10 -12
- package/dist/data/orm/cursor.d.ts +1 -1
- package/dist/data/orm/cursor.js +2 -2
- package/dist/data/orm/cursor.test.js +92 -93
- package/dist/data/orm/data-query.d.ts +3 -3
- package/dist/data/orm/data-query.js +24 -18
- package/dist/data/orm/data-query.mongo.d.ts +1 -1
- package/dist/data/orm/data-query.mongo.js +49 -51
- package/dist/data/orm/data-query.mongo.test.js +173 -204
- package/dist/data/orm/data-query.sqlite.d.ts +1 -1
- package/dist/data/orm/data-query.sqlite.js +84 -73
- package/dist/data/orm/data-query.sqlite.test.js +164 -176
- package/dist/data/orm/data-query.test.js +216 -224
- package/dist/data/orm/decorators.js +3 -3
- package/dist/data/orm/dependency-injection.test.js +53 -56
- package/dist/data/orm/doc.d.ts +4 -4
- package/dist/data/orm/doc.js +17 -21
- package/dist/data/orm/event-registry.d.ts +1 -1
- package/dist/data/orm/event-registry.test.js +16 -16
- package/dist/data/orm/factory.d.ts +2 -2
- package/dist/data/orm/factory.js +33 -33
- package/dist/data/orm/index.d.ts +10 -10
- package/dist/data/orm/index.js +10 -10
- package/dist/data/orm/multi-cursors.d.ts +1 -1
- package/dist/data/orm/multi-cursors.js +6 -6
- package/dist/data/orm/multi-cursors.test.js +152 -144
- package/dist/data/orm/sql.data-source.d.ts +7 -7
- package/dist/data/orm/sql.data-source.js +88 -93
- package/dist/data/orm/sql.data-source.test.js +109 -101
- package/dist/data/orm/subscribable.data-source.d.ts +4 -4
- package/dist/data/orm/subscribable.data-source.js +5 -5
- package/dist/data/orm/table-container-events.test.js +34 -26
- package/dist/data/orm/table-container.d.ts +6 -6
- package/dist/data/orm/table-container.js +33 -21
- package/dist/data/orm/table-container.test.js +64 -53
- package/dist/data/orm/table-definitions.system.d.ts +3 -3
- package/dist/data/orm/table-definitions.system.js +3 -3
- package/dist/data/orm/table-definitions.type.d.ts +5 -5
- package/dist/data/orm/table-dependencies.d.ts +2 -2
- package/dist/data/orm/table.d.ts +5 -5
- package/dist/data/orm/table.event-source.test.js +105 -115
- package/dist/data/orm/table.js +35 -34
- package/dist/data/orm/types.d.ts +3 -3
- package/dist/data/orm/types.js +26 -25
- package/dist/data/orm/types.test.js +166 -92
- package/dist/data/package-permissions.d.ts +1 -1
- package/dist/data/package-permissions.js +2 -2
- package/dist/data/package-version-permissions.d.ts +1 -1
- package/dist/data/package-version-permissions.js +2 -2
- package/dist/data/package-versions.d.ts +9 -9
- package/dist/data/package-versions.js +47 -33
- package/dist/data/packages.d.ts +2 -2
- package/dist/data/packages.js +36 -18
- package/dist/data/packages.utils.d.ts +2 -2
- package/dist/data/packages.utils.js +4 -4
- package/dist/data/persistent-vars.d.ts +15 -15
- package/dist/data/persistent-vars.js +165 -154
- package/dist/data/table-definitions-table.d.ts +5 -5
- package/dist/data/table-definitions-table.js +13 -12
- package/dist/data/tool-tests.js +6 -6
- package/dist/data/tools.js +29 -19
- package/dist/data/user-permissions.d.ts +1 -1
- package/dist/data/user-permissions.js +5 -5
- package/dist/data/user-permissions.test.js +90 -88
- package/dist/data/user-trust-levels.js +10 -10
- package/dist/data/users.d.ts +4 -4
- package/dist/data/users.js +16 -15
- package/dist/data/voice-messages.d.ts +2 -2
- package/dist/data/voice-messages.js +13 -13
- package/dist/data/welcome-modal.pvar.js +3 -1
- package/dist/data/workflow-logs.js +26 -18
- package/dist/data/workflow-runs.d.ts +6 -6
- package/dist/data/workflow-runs.js +70 -44
- package/dist/data/workflows.d.ts +2 -2
- package/dist/data/workflows.js +7 -9
- package/dist/device/binary-peer-connection-v2.d.ts +7 -7
- package/dist/device/binary-peer-connection-v2.js +32 -28
- package/dist/device/binary-peer-connection-v2.test.js +80 -67
- package/dist/device/binary-peer-connection.d.ts +7 -7
- package/dist/device/binary-peer-connection.js +29 -28
- package/dist/device/binary-peer-connection.test.js +35 -31
- package/dist/device/connection.d.ts +5 -5
- package/dist/device/connection.js +59 -48
- package/dist/device/connection.test.js +74 -68
- package/dist/device/device-election.d.ts +2 -2
- package/dist/device/device-election.js +25 -20
- package/dist/device/device-election.test.js +35 -36
- package/dist/device/device.d.ts +2 -2
- package/dist/device/device.js +10 -4
- package/dist/device/device.test.js +16 -17
- package/dist/device/get-trust-level-fn.d.ts +2 -2
- package/dist/device/get-trust-level-fn.js +22 -11
- package/dist/device/get-trust-level-fn.test.js +58 -58
- package/dist/device/socket-io-binary-peer.d.ts +1 -1
- package/dist/device/socket-io-binary-peer.js +16 -13
- package/dist/device/socket.type.d.ts +2 -2
- package/dist/device/streamed-socket.d.ts +2 -2
- package/dist/device/streamed-socket.js +8 -8
- package/dist/device/streamed-socket.test.js +40 -40
- package/dist/device/tx-encoding.test.js +77 -77
- package/dist/events.d.ts +1 -1
- package/dist/events.js +5 -2
- package/dist/group-invite/group-invite.js +110 -19
- package/dist/group-invite/group-invite.pvars.d.ts +2 -2
- package/dist/group-invite/group-invite.pvars.js +21 -13
- package/dist/group-invite/group-invite.types.d.ts +1 -1
- package/dist/group-invite/index.d.ts +3 -3
- package/dist/group-invite/index.js +1 -1
- package/dist/index.d.ts +25 -24
- package/dist/index.js +30 -25
- package/dist/keys.d.ts +3 -3
- package/dist/keys.js +31 -30
- package/dist/keys.test.js +69 -61
- package/dist/logging/console-logger.d.ts +1 -1
- package/dist/logging/console-logger.js +35 -40
- package/dist/logging/console-logger.test.js +115 -115
- package/dist/logging/console-logs.table.d.ts +3 -3
- package/dist/logging/console-logs.table.js +28 -23
- package/dist/mentions.js +16 -12
- package/dist/observable.d.ts +2 -2
- package/dist/observable.js +15 -9
- package/dist/observable.test.js +47 -47
- package/dist/package-loader/get-require.js +3 -4
- package/dist/package-loader/package-loader.d.ts +2 -2
- package/dist/package-loader/package-loader.js +52 -34
- package/dist/peers-ui/peers-ui.d.ts +2 -2
- package/dist/peers-ui/peers-ui.js +2 -4
- package/dist/peers-ui/peers-ui.types.d.ts +3 -3
- package/dist/peers-ui/peers-ui.types.js +0 -1
- package/dist/rpc-types.d.ts +60 -60
- package/dist/rpc-types.js +60 -56
- package/dist/serial-json.d.ts +1 -1
- package/dist/serial-json.js +50 -43
- package/dist/serial-json.test.js +22 -22
- package/dist/system-ids.js +8 -8
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/tools-factory.d.ts +1 -1
- package/dist/tools/tools-factory.js +2 -2
- package/dist/types/assistant-runner-args.d.ts +3 -3
- package/dist/types/peer-device.d.ts +1 -1
- package/dist/types/peers-package.d.ts +3 -3
- package/dist/types/workflow-logger.d.ts +1 -1
- package/dist/types/workflow-run-context.d.ts +4 -4
- package/dist/types/workflow.d.ts +4 -4
- package/dist/types/workflow.js +27 -14
- package/dist/types/zod-types.d.ts +2 -1
- package/dist/types/zod-types.js +9 -3
- package/dist/user-connect/connection-code.d.ts +1 -1
- package/dist/user-connect/connection-code.js +7 -7
- package/dist/user-connect/connection-code.test.js +106 -106
- package/dist/user-connect/index.d.ts +3 -3
- package/dist/user-connect/index.js +1 -1
- package/dist/user-connect/user-connect.pvars.js +13 -11
- package/dist/user-connect/user-connect.types.d.ts +3 -3
- package/dist/users.query.d.ts +2 -2
- package/dist/users.query.js +40 -30
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +34 -32
- package/dist/utils.test.js +12 -8
- package/dist/workflow-log-formatter.d.ts +1 -1
- package/dist/workflow-log-formatter.js +17 -18
- 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
|
|
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 {
|
|
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(
|
|
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 ===
|
|
83
|
+
const _require = this.require ?? defaultRequire ?? (typeof require === "function" ? require : null);
|
|
87
84
|
if (!_require || !localPath)
|
|
88
85
|
return;
|
|
89
|
-
const fs = _require(
|
|
90
|
-
const path = _require(
|
|
91
|
-
return fs.readFileSync(path.join(localPath,
|
|
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 !==
|
|
102
|
+
const isNodeEnvironment = typeof process !== "undefined" && !!process.versions?.node;
|
|
106
103
|
const NODE_ONLY_MODULES = new Set([
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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 ===
|
|
131
|
+
const _require = (this.require ?? defaultRequire ?? typeof require === "function") ? require : undefined;
|
|
116
132
|
if (!_require) {
|
|
117
|
-
throw new Error(
|
|
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
|
|
121
|
-
case
|
|
122
|
-
return PackageLoader.PeersSDK || _require(
|
|
123
|
-
case
|
|
124
|
-
return PackageLoader.Zod || _require(
|
|
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(
|
|
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 ===
|
|
161
|
+
if (packageInstance && typeof packageInstance === "object") {
|
|
146
162
|
packageInstance.toolInstances?.forEach((toolInstance) => {
|
|
147
|
-
(0,
|
|
148
|
-
(0,
|
|
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, {
|
|
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
|
|
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
|
-
}) =>
|
|
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
|
-
|
|
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 {
|
|
2
|
-
export type UICategory =
|
|
3
|
-
export type UIEditMode =
|
|
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 */
|
package/dist/rpc-types.d.ts
CHANGED
|
@@ -27,23 +27,23 @@ export interface UIState {
|
|
|
27
27
|
}
|
|
28
28
|
export declare const rpcServerCalls: {
|
|
29
29
|
ping: (msg: string) => Promise<string>;
|
|
30
|
-
openLinkInBrowser: (
|
|
31
|
-
openPath: (
|
|
32
|
-
openPackage: (
|
|
33
|
-
addOrUpdatePackage: (
|
|
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: (
|
|
38
|
+
}) => Promise<string>;
|
|
39
|
+
setUserIdAndSecretKey: (userId: string, secretKey: string) => Promise<void>;
|
|
40
40
|
getUserId: () => Promise<string | undefined>;
|
|
41
|
-
encryptData: (
|
|
42
|
-
logout: (
|
|
43
|
-
tableMethodCall: (
|
|
44
|
-
getFileContents: (
|
|
45
|
-
getFileContentsBase64: (
|
|
46
|
-
saveFile: (
|
|
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,39 +55,39 @@ export declare const rpcServerCalls: {
|
|
|
55
55
|
fileSize: number;
|
|
56
56
|
fileHash: string;
|
|
57
57
|
mimeType?: string;
|
|
58
|
-
}
|
|
59
|
-
injectUIBundle: (
|
|
60
|
-
resetAllDeviceSyncInfo: (
|
|
58
|
+
}>;
|
|
59
|
+
injectUIBundle: (uiBundleFileId: string) => Promise<void>;
|
|
60
|
+
resetAllDeviceSyncInfo: () => Promise<void>;
|
|
61
61
|
/** Clear change tracking and rebuild from current rows for the default data context (same as Data Explorer). */
|
|
62
|
-
resetChangeTracking: (
|
|
63
|
-
deleteLocalDatabase: (
|
|
64
|
-
importGroupShare: (
|
|
65
|
-
appQuit: (
|
|
66
|
-
appRestart: (
|
|
67
|
-
dbQuery: (
|
|
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<{
|
|
68
68
|
columns: string[];
|
|
69
69
|
rows: any[][];
|
|
70
70
|
rowCount: number;
|
|
71
|
-
}
|
|
72
|
-
runTool: (
|
|
73
|
-
uiReload: (
|
|
71
|
+
}>;
|
|
72
|
+
runTool: (toolId: string, args: Record<string, any>, dataContextId?: string, assistantId?: string) => Promise<any>;
|
|
73
|
+
uiReload: (options?: {
|
|
74
74
|
ignoreCache?: boolean;
|
|
75
|
-
}) => Promise<void
|
|
76
|
-
uiInspect: (
|
|
75
|
+
}) => Promise<void>;
|
|
76
|
+
uiInspect: (options?: {
|
|
77
77
|
includeRects?: boolean;
|
|
78
|
-
}) => Promise<UIState
|
|
79
|
-
uiClick: (
|
|
78
|
+
}) => Promise<UIState>;
|
|
79
|
+
uiClick: (selector: string) => Promise<{
|
|
80
80
|
success: boolean;
|
|
81
81
|
error?: string;
|
|
82
|
-
}
|
|
83
|
-
uiSet: (
|
|
82
|
+
}>;
|
|
83
|
+
uiSet: (selector: string, text: string, options?: {
|
|
84
84
|
clear?: boolean;
|
|
85
85
|
pressEnter?: boolean;
|
|
86
86
|
}) => Promise<{
|
|
87
87
|
success: boolean;
|
|
88
88
|
error?: string;
|
|
89
|
-
}
|
|
90
|
-
uiScroll: (
|
|
89
|
+
}>;
|
|
90
|
+
uiScroll: (options: {
|
|
91
91
|
selector?: string;
|
|
92
92
|
x?: number;
|
|
93
93
|
y?: number;
|
|
@@ -96,46 +96,46 @@ export declare const rpcServerCalls: {
|
|
|
96
96
|
}) => Promise<{
|
|
97
97
|
success: boolean;
|
|
98
98
|
error?: string;
|
|
99
|
-
}
|
|
100
|
-
voiceGetState: (
|
|
99
|
+
}>;
|
|
100
|
+
voiceGetState: () => Promise<{
|
|
101
101
|
state: "disabled" | "idle" | "listening" | "recording" | "processing" | "speaking";
|
|
102
102
|
keyError?: "refused" | "invalid" | "limit" | "throttled";
|
|
103
|
-
}
|
|
104
|
-
voiceStartRecording: (
|
|
105
|
-
voiceStopRecording: (
|
|
106
|
-
voiceCancelRecording: (
|
|
107
|
-
voiceSetTargetChannel: (
|
|
108
|
-
voiceGetAudioDevices: (
|
|
109
|
-
voiceTestTTS: (
|
|
110
|
-
voiceNotifyPlaybackComplete: (
|
|
111
|
-
voiceStopPlayback: (
|
|
112
|
-
voiceGetThreadId: (
|
|
113
|
-
voiceSetThreadId: (
|
|
114
|
-
voiceNotifyTextActivity: (
|
|
115
|
-
voiceDisable: (
|
|
116
|
-
voiceEnable: (
|
|
117
|
-
flushDatabases: (
|
|
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>;
|
|
118
118
|
};
|
|
119
119
|
export declare const rpcClientCalls: {
|
|
120
120
|
ping: (msg: string) => Promise<string>;
|
|
121
|
-
emitEvent: (
|
|
122
|
-
setClientPath: (
|
|
123
|
-
openThread: (
|
|
124
|
-
uiGetState: (
|
|
121
|
+
emitEvent: (event: IEventData) => Promise<boolean>;
|
|
122
|
+
setClientPath: (url: string) => Promise<void>;
|
|
123
|
+
openThread: (threadId: string) => Promise<void>;
|
|
124
|
+
uiGetState: (options?: {
|
|
125
125
|
includeRects?: boolean;
|
|
126
|
-
}) => Promise<UIState
|
|
127
|
-
uiDoClick: (
|
|
126
|
+
}) => Promise<UIState>;
|
|
127
|
+
uiDoClick: (selector: string) => Promise<{
|
|
128
128
|
success: boolean;
|
|
129
129
|
error?: string;
|
|
130
|
-
}
|
|
131
|
-
uiDoSet: (
|
|
130
|
+
}>;
|
|
131
|
+
uiDoSet: (selector: string, text: string, options?: {
|
|
132
132
|
clear?: boolean;
|
|
133
133
|
pressEnter?: boolean;
|
|
134
134
|
}) => Promise<{
|
|
135
135
|
success: boolean;
|
|
136
136
|
error?: string;
|
|
137
|
-
}
|
|
138
|
-
uiDoScroll: (
|
|
137
|
+
}>;
|
|
138
|
+
uiDoScroll: (options: {
|
|
139
139
|
selector?: string;
|
|
140
140
|
x?: number;
|
|
141
141
|
y?: number;
|
|
@@ -144,7 +144,7 @@ export declare const rpcClientCalls: {
|
|
|
144
144
|
}) => Promise<{
|
|
145
145
|
success: boolean;
|
|
146
146
|
error?: string;
|
|
147
|
-
}
|
|
147
|
+
}>;
|
|
148
148
|
};
|
|
149
149
|
export type RpcServerNames = keyof typeof rpcServerCalls;
|
|
150
150
|
export type RpcClientNames = keyof typeof rpcClientCalls;
|
package/dist/rpc-types.js
CHANGED
|
@@ -5,62 +5,64 @@ exports.setSingleProcessClient = setSingleProcessClient;
|
|
|
5
5
|
exports.isSingleProcessClient = isSingleProcessClient;
|
|
6
6
|
function rpcStub(rpcName) {
|
|
7
7
|
return async (...args) => {
|
|
8
|
-
console.warn(rpcName +
|
|
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(
|
|
15
|
-
openPath: rpcStub(
|
|
16
|
-
openPackage: rpcStub(
|
|
17
|
-
addOrUpdatePackage: rpcStub(
|
|
18
|
-
setUserIdAndSecretKey: rpcStub(
|
|
19
|
-
getUserId: rpcStub(
|
|
20
|
-
encryptData: rpcStub(
|
|
21
|
-
logout: rpcStub(
|
|
22
|
-
tableMethodCall: rpcStub(
|
|
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(
|
|
26
|
+
getFileContents: rpcStub("getFileContents"),
|
|
25
27
|
// Get file contents as base64 - useful for binary data like images
|
|
26
|
-
getFileContentsBase64: rpcStub(
|
|
28
|
+
getFileContentsBase64: rpcStub("getFileContentsBase64"),
|
|
27
29
|
// Save a file from the UI - data should be base64 encoded for binary files
|
|
28
|
-
saveFile: rpcStub(
|
|
30
|
+
saveFile: rpcStub("saveFile"),
|
|
29
31
|
// Inject UI bundle directly into WebView (bypasses slow postMessage for large strings)
|
|
30
|
-
injectUIBundle: rpcStub(
|
|
31
|
-
resetAllDeviceSyncInfo: rpcStub(
|
|
32
|
+
injectUIBundle: rpcStub("injectUIBundle"),
|
|
33
|
+
resetAllDeviceSyncInfo: rpcStub("resetAllDeviceSyncInfo"),
|
|
32
34
|
/** Clear change tracking and rebuild from current rows for the default data context (same as Data Explorer). */
|
|
33
|
-
resetChangeTracking: rpcStub(
|
|
34
|
-
deleteLocalDatabase: rpcStub(
|
|
35
|
-
importGroupShare: rpcStub(
|
|
35
|
+
resetChangeTracking: rpcStub("resetChangeTracking"),
|
|
36
|
+
deleteLocalDatabase: rpcStub("deleteLocalDatabase"),
|
|
37
|
+
importGroupShare: rpcStub("importGroupShare"),
|
|
36
38
|
// App lifecycle commands (for CLI control)
|
|
37
|
-
appQuit: rpcStub(
|
|
38
|
-
appRestart: rpcStub(
|
|
39
|
+
appQuit: rpcStub("appQuit"),
|
|
40
|
+
appRestart: rpcStub("appRestart"),
|
|
39
41
|
// Database exploration (for CLI)
|
|
40
|
-
dbQuery: rpcStub(
|
|
42
|
+
dbQuery: rpcStub("dbQuery"),
|
|
41
43
|
// Direct tool execution (for CLI)
|
|
42
|
-
runTool: rpcStub(
|
|
44
|
+
runTool: rpcStub("runTool"),
|
|
43
45
|
// UI control (for CLI)
|
|
44
|
-
uiReload: rpcStub(
|
|
45
|
-
uiInspect: rpcStub(
|
|
46
|
-
uiClick: rpcStub(
|
|
47
|
-
uiSet: rpcStub(
|
|
48
|
-
uiScroll: rpcStub(
|
|
46
|
+
uiReload: rpcStub("uiReload"),
|
|
47
|
+
uiInspect: rpcStub("uiInspect"),
|
|
48
|
+
uiClick: rpcStub("uiClick"),
|
|
49
|
+
uiSet: rpcStub("uiSet"),
|
|
50
|
+
uiScroll: rpcStub("uiScroll"),
|
|
49
51
|
// Voice control (settings managed via voiceSettings pvar, keys via secret pvars)
|
|
50
|
-
voiceGetState: rpcStub(
|
|
51
|
-
voiceStartRecording: rpcStub(
|
|
52
|
-
voiceStopRecording: rpcStub(
|
|
53
|
-
voiceCancelRecording: rpcStub(
|
|
54
|
-
voiceSetTargetChannel: rpcStub(
|
|
55
|
-
voiceGetAudioDevices: rpcStub(
|
|
56
|
-
voiceTestTTS: rpcStub(
|
|
57
|
-
voiceNotifyPlaybackComplete: rpcStub(
|
|
58
|
-
voiceStopPlayback: rpcStub(
|
|
59
|
-
voiceGetThreadId: rpcStub(
|
|
60
|
-
voiceSetThreadId: rpcStub(
|
|
61
|
-
voiceNotifyTextActivity: rpcStub(
|
|
62
|
-
voiceDisable: rpcStub(
|
|
63
|
-
voiceEnable: rpcStub(
|
|
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"),
|
|
64
66
|
// Flush all in-memory database snapshots to durable storage (IndexedDB in PWA).
|
|
65
67
|
// No-op on Electron where better-sqlite3 writes are synchronous to disk.
|
|
66
68
|
flushDatabases: (async () => { }),
|
|
@@ -72,30 +74,32 @@ exports.rpcServerCalls = {
|
|
|
72
74
|
exports.rpcClientCalls = {
|
|
73
75
|
ping: async (msg) => `pong: ${msg}`,
|
|
74
76
|
// emitEvent: rpcStub('emitEvent') as ((event: IEventData) => Promise<boolean>),
|
|
75
|
-
emitEvent: ((...
|
|
76
|
-
setClientPath: rpcStub(
|
|
77
|
-
openThread: rpcStub(
|
|
77
|
+
emitEvent: ((..._args) => Promise.resolve(false)),
|
|
78
|
+
setClientPath: rpcStub("setClientPath"),
|
|
79
|
+
openThread: rpcStub("openThread"),
|
|
78
80
|
// UI inspection (for CLI)
|
|
79
|
-
uiGetState: rpcStub(
|
|
81
|
+
uiGetState: rpcStub("uiGetState"),
|
|
80
82
|
// UI actions (for CLI)
|
|
81
|
-
uiDoClick: rpcStub(
|
|
82
|
-
uiDoSet: rpcStub(
|
|
83
|
-
uiDoScroll: rpcStub(
|
|
83
|
+
uiDoClick: rpcStub("uiDoClick"),
|
|
84
|
+
uiDoSet: rpcStub("uiDoSet"),
|
|
85
|
+
uiDoScroll: rpcStub("uiDoScroll"),
|
|
84
86
|
};
|
|
85
87
|
// Check if we're in a client context (browser, webview, or CLI connected to server)
|
|
86
88
|
// - Browser: window + document exist
|
|
87
89
|
// - CLI: process.env.PEERS_IS_CLIENT === 'true'
|
|
88
|
-
exports.isClient = (typeof window !==
|
|
89
|
-
|
|
90
|
+
exports.isClient = (typeof window !== "undefined" && typeof document !== "undefined") ||
|
|
91
|
+
(typeof process !== "undefined" && process.env?.PEERS_IS_CLIENT === "true");
|
|
90
92
|
// Single-process mode (PWA): client and server live in the same process,
|
|
91
93
|
// so Table events must NOT be suppressed on the client side.
|
|
92
94
|
let _singleProcessClient = false;
|
|
93
|
-
function setSingleProcessClient(value) {
|
|
94
|
-
|
|
95
|
+
function setSingleProcessClient(value) {
|
|
96
|
+
_singleProcessClient = value;
|
|
97
|
+
}
|
|
98
|
+
function isSingleProcessClient() {
|
|
99
|
+
return _singleProcessClient;
|
|
100
|
+
}
|
|
95
101
|
if (exports.isClient) {
|
|
96
|
-
if (typeof window !==
|
|
97
|
-
|
|
98
|
-
const _window = window;
|
|
99
|
-
_window['rpc'] = exports.rpcServerCalls;
|
|
102
|
+
if (typeof window !== "undefined") {
|
|
103
|
+
window.rpc = exports.rpcServerCalls;
|
|
100
104
|
}
|
|
101
105
|
}
|
package/dist/serial-json.d.ts
CHANGED
|
@@ -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,
|
|
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;
|