@peers-app/peers-sdk 0.26.3 → 0.26.5
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/contracts/__tests__/contract-resolvers.test.js +24 -0
- package/dist/contracts/__tests__/legacy-removal.test.js +38 -0
- package/dist/contracts/__tests__/remote-contract-transport.test.js +23 -32
- package/dist/contracts/__tests__/system-contracts.test.js +80 -0
- package/dist/contracts/contract-resolvers.d.ts +1 -1
- package/dist/contracts/contract-resolvers.js +3 -2
- package/dist/contracts/create-local-consumer.d.ts +2 -1
- package/dist/contracts/create-local-consumer.js +1 -1
- package/dist/contracts/index.d.ts +2 -0
- package/dist/contracts/index.js +2 -0
- package/dist/contracts/remote-contract-transport.d.ts +3 -3
- package/dist/contracts/remote-contract-transport.js +19 -17
- package/dist/contracts/system/host-shell-contract.d.ts +191 -0
- package/dist/contracts/system/host-shell-contract.js +190 -0
- package/dist/contracts/system/index.d.ts +4 -0
- package/dist/contracts/system/index.js +4 -0
- package/dist/contracts/system/packages-contract.d.ts +257 -0
- package/dist/contracts/system/packages-contract.js +213 -0
- package/dist/data/create-group.d.ts +1 -1
- package/dist/data/create-group.js +1 -1
- package/dist/data/package-version-resolver.d.ts +8 -2
- package/dist/data/package-version-resolver.js +28 -2
- package/dist/data/package-version-resolver.test.js +42 -0
- package/dist/package-installer/package-author-signer.d.ts +19 -0
- package/dist/package-installer/package-author-signer.js +24 -0
- package/dist/package-installer/package-creator.d.ts +1 -7
- package/dist/package-installer/package-creator.js +0 -12
- package/dist/package-installer/package-creator.test.js +0 -16
- package/dist/package-installer/package-installer.d.ts +5 -0
- package/dist/package-installer/package-installer.js +60 -37
- package/dist/package-installer/package-installer.test.js +129 -0
- package/dist/package-installer/types.d.ts +5 -11
- package/dist/package-loader/index.d.ts +1 -0
- package/dist/package-loader/index.js +1 -0
- package/dist/package-loader/isolated-runtime.d.ts +18 -0
- package/dist/package-loader/package-loader.d.ts +67 -4
- package/dist/package-loader/package-loader.js +300 -52
- package/dist/package-loader/package-loader.test.js +413 -1
- package/dist/package-loader/package-runtime-state.d.ts +112 -0
- package/dist/package-loader/package-runtime-state.js +18 -0
- package/dist/package-loader/resolve-consumed-contracts.js +5 -4
- package/dist/package-loader/resolve-consumed-contracts.test.js +1 -1
- package/dist/rpc-types.d.ts +0 -121
- package/dist/rpc-types.js +0 -39
- package/dist/system-ids.d.ts +13 -0
- package/dist/system-ids.js +14 -1
- package/package.json +1 -1
package/dist/rpc-types.d.ts
CHANGED
|
@@ -1,38 +1,11 @@
|
|
|
1
1
|
import type { IDeviceDatabaseQueryResult, IDeviceOperationStatus, IDeviceToolRunInput } from "./contracts/system/device-operations-contract";
|
|
2
2
|
import type { ITool } from "./data/tools";
|
|
3
3
|
import type { IConsoleLog } from "./logging/console-logs.table";
|
|
4
|
-
import type { IAddOrUpdatePackageResult } from "./package-installer/types";
|
|
5
|
-
import type { IAppNav } from "./types/app-nav";
|
|
6
4
|
/** Named event payload sent across the frontend RPC bridge. */
|
|
7
5
|
export interface IEventData<T = any> {
|
|
8
6
|
name: string;
|
|
9
7
|
data: T;
|
|
10
8
|
}
|
|
11
|
-
/** Serializable description of one interactive UI element. */
|
|
12
|
-
export interface UIElement {
|
|
13
|
-
tag: string;
|
|
14
|
-
text?: string;
|
|
15
|
-
selector: string;
|
|
16
|
-
type?: string;
|
|
17
|
-
value?: string;
|
|
18
|
-
placeholder?: string;
|
|
19
|
-
href?: string;
|
|
20
|
-
disabled?: boolean;
|
|
21
|
-
rect?: {
|
|
22
|
-
x: number;
|
|
23
|
-
y: number;
|
|
24
|
-
width: number;
|
|
25
|
-
height: number;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
/** Serializable renderer state returned to CLI UI-inspection commands. */
|
|
29
|
-
export interface UIState {
|
|
30
|
-
url: string;
|
|
31
|
-
title: string;
|
|
32
|
-
route?: string;
|
|
33
|
-
text: string;
|
|
34
|
-
elements: UIElement[];
|
|
35
|
-
}
|
|
36
9
|
/** One verified direct device connection exposed by the local Electron bridge. */
|
|
37
10
|
export interface IConnectedDeviceSummary {
|
|
38
11
|
deviceId: string;
|
|
@@ -55,27 +28,7 @@ export interface IRemoteLogsQueryInput {
|
|
|
55
28
|
/** RPC methods implemented by the trusted local server/main process. */
|
|
56
29
|
export declare const rpcServerCalls: {
|
|
57
30
|
ping: (msg: string) => Promise<string>;
|
|
58
|
-
openLinkInBrowser: (url: string) => Promise<void>;
|
|
59
|
-
openPath: (path: string) => Promise<void>;
|
|
60
|
-
openPackage: (path: string) => Promise<void>;
|
|
61
|
-
addOrUpdatePackage: (input: string, options?: {
|
|
62
|
-
dataContextId?: string;
|
|
63
|
-
packageLocation?: string;
|
|
64
|
-
update?: boolean;
|
|
65
|
-
linkRemote?: boolean;
|
|
66
|
-
}) => Promise<string | IAddOrUpdatePackageResult>;
|
|
67
|
-
seedBundledPeersCore: (dataContextId?: string) => Promise<boolean>;
|
|
68
31
|
encryptData: (value: string, groupId?: string) => Promise<string>;
|
|
69
|
-
/**
|
|
70
|
-
* Decrypt (if secret) and copy a persistent variable's value to the system clipboard
|
|
71
|
-
* entirely on the server/main process. The plaintext is never returned to the caller,
|
|
72
|
-
* so secret values are never exposed to the UI. On desktop, secret values are
|
|
73
|
-
* automatically cleared from the clipboard after a short delay.
|
|
74
|
-
*/
|
|
75
|
-
copyPvarValueToClipboard: (persistentVarId: string, groupId?: string) => Promise<{
|
|
76
|
-
success: boolean;
|
|
77
|
-
error?: string;
|
|
78
|
-
}>;
|
|
79
32
|
tableMethodCall: (dataContextId: string, tableName: string, methodName: string, ...args: any[]) => Promise<any>;
|
|
80
33
|
getFileContents: (fileId: string, encoding?: BufferEncoding) => Promise<string>;
|
|
81
34
|
getFileContentsBase64: (fileId: string) => Promise<string>;
|
|
@@ -92,7 +45,6 @@ export declare const rpcServerCalls: {
|
|
|
92
45
|
fileHash: string;
|
|
93
46
|
mimeType?: string;
|
|
94
47
|
}>;
|
|
95
|
-
injectUIBundle: (uiBundleFileId: string) => Promise<void>;
|
|
96
48
|
deleteLocalDatabase: () => Promise<void>;
|
|
97
49
|
/** Returns info about the pre-migration data directory, or `null` if already cleaned up. */
|
|
98
50
|
getOldDataDirInfo: () => Promise<{
|
|
@@ -101,26 +53,6 @@ export declare const rpcServerCalls: {
|
|
|
101
53
|
} | null>;
|
|
102
54
|
/** Deletes the pre-migration data directory after the user confirms. */
|
|
103
55
|
cleanupOldDataDir: () => Promise<void>;
|
|
104
|
-
/**
|
|
105
|
-
* Sign a package version with the package author's key (server-side only — key never leaves the server).
|
|
106
|
-
* Returns the base64url detached signature, or undefined if the signing key isn't available.
|
|
107
|
-
* Optional fields (appNavs, createdBy, createdAt) must match the PV record when present so
|
|
108
|
-
* propagation verification of the full record succeeds.
|
|
109
|
-
*/
|
|
110
|
-
signPackageAuthorVersion: (pvFields: {
|
|
111
|
-
packageId: string;
|
|
112
|
-
packageVersionId: string;
|
|
113
|
-
version: string;
|
|
114
|
-
versionTag?: string;
|
|
115
|
-
packageBundleFileHash: string;
|
|
116
|
-
routesBundleFileHash?: string;
|
|
117
|
-
uiBundleFileHash?: string;
|
|
118
|
-
appNavs?: IAppNav[];
|
|
119
|
-
createdBy?: string;
|
|
120
|
-
createdAt?: string;
|
|
121
|
-
}) => Promise<string | undefined>;
|
|
122
|
-
appQuit: () => Promise<void>;
|
|
123
|
-
appRestart: () => Promise<void>;
|
|
124
56
|
dbQuery: (query: string, dataContextId?: string) => Promise<{
|
|
125
57
|
columns: string[];
|
|
126
58
|
rows: any[][];
|
|
@@ -134,33 +66,6 @@ export declare const rpcServerCalls: {
|
|
|
134
66
|
remoteGetTool: (deviceId: string, toolIdOrName: string, dataContextId?: string) => Promise<ITool | null>;
|
|
135
67
|
remoteRunTool: (deviceId: string, input: IDeviceToolRunInput, dataContextId?: string) => Promise<unknown>;
|
|
136
68
|
remoteQueryLogs: (deviceId: string, input?: IRemoteLogsQueryInput) => Promise<IConsoleLog[]>;
|
|
137
|
-
uiReload: (options?: {
|
|
138
|
-
ignoreCache?: boolean;
|
|
139
|
-
}) => Promise<void>;
|
|
140
|
-
uiInspect: (options?: {
|
|
141
|
-
includeRects?: boolean;
|
|
142
|
-
}) => Promise<UIState>;
|
|
143
|
-
uiClick: (selector: string) => Promise<{
|
|
144
|
-
success: boolean;
|
|
145
|
-
error?: string;
|
|
146
|
-
}>;
|
|
147
|
-
uiSet: (selector: string, text: string, options?: {
|
|
148
|
-
clear?: boolean;
|
|
149
|
-
pressEnter?: boolean;
|
|
150
|
-
}) => Promise<{
|
|
151
|
-
success: boolean;
|
|
152
|
-
error?: string;
|
|
153
|
-
}>;
|
|
154
|
-
uiScroll: (options: {
|
|
155
|
-
selector?: string;
|
|
156
|
-
x?: number;
|
|
157
|
-
y?: number;
|
|
158
|
-
direction?: "up" | "down" | "left" | "right";
|
|
159
|
-
amount?: number;
|
|
160
|
-
}) => Promise<{
|
|
161
|
-
success: boolean;
|
|
162
|
-
error?: string;
|
|
163
|
-
}>;
|
|
164
69
|
flushDatabases: () => Promise<void>;
|
|
165
70
|
subscribeEvents: (names: string[]) => Promise<void>;
|
|
166
71
|
unsubscribeEvents: (names: string[]) => Promise<void>;
|
|
@@ -171,32 +76,6 @@ export declare const rpcServerCalls: {
|
|
|
171
76
|
export declare const rpcClientCalls: {
|
|
172
77
|
ping: (msg: string) => Promise<string>;
|
|
173
78
|
emitEvent: (event: IEventData) => Promise<boolean>;
|
|
174
|
-
setClientPath: (url: string) => Promise<void>;
|
|
175
|
-
openThread: (threadId: string) => Promise<void>;
|
|
176
|
-
uiGetState: (options?: {
|
|
177
|
-
includeRects?: boolean;
|
|
178
|
-
}) => Promise<UIState>;
|
|
179
|
-
uiDoClick: (selector: string) => Promise<{
|
|
180
|
-
success: boolean;
|
|
181
|
-
error?: string;
|
|
182
|
-
}>;
|
|
183
|
-
uiDoSet: (selector: string, text: string, options?: {
|
|
184
|
-
clear?: boolean;
|
|
185
|
-
pressEnter?: boolean;
|
|
186
|
-
}) => Promise<{
|
|
187
|
-
success: boolean;
|
|
188
|
-
error?: string;
|
|
189
|
-
}>;
|
|
190
|
-
uiDoScroll: (options: {
|
|
191
|
-
selector?: string;
|
|
192
|
-
x?: number;
|
|
193
|
-
y?: number;
|
|
194
|
-
direction?: "up" | "down" | "left" | "right";
|
|
195
|
-
amount?: number;
|
|
196
|
-
}) => Promise<{
|
|
197
|
-
success: boolean;
|
|
198
|
-
error?: string;
|
|
199
|
-
}>;
|
|
200
79
|
};
|
|
201
80
|
/** Name of a server/main-process RPC method. */
|
|
202
81
|
export type RpcServerNames = keyof typeof rpcServerCalls;
|
package/dist/rpc-types.js
CHANGED
|
@@ -13,20 +13,7 @@ function rpcStub(rpcName) {
|
|
|
13
13
|
/** RPC methods implemented by the trusted local server/main process. */
|
|
14
14
|
exports.rpcServerCalls = {
|
|
15
15
|
ping: async (msg) => `pong: ${msg}`,
|
|
16
|
-
// TODO collapse these two down to just openPath
|
|
17
|
-
openLinkInBrowser: rpcStub("openLinkInBrowser"),
|
|
18
|
-
openPath: rpcStub("openPath"),
|
|
19
|
-
openPackage: rpcStub("OpenPackage"),
|
|
20
|
-
addOrUpdatePackage: rpcStub("addOrUpdatePackage"),
|
|
21
|
-
seedBundledPeersCore: rpcStub("seedBundledPeersCore"),
|
|
22
16
|
encryptData: rpcStub("encryptData"),
|
|
23
|
-
/**
|
|
24
|
-
* Decrypt (if secret) and copy a persistent variable's value to the system clipboard
|
|
25
|
-
* entirely on the server/main process. The plaintext is never returned to the caller,
|
|
26
|
-
* so secret values are never exposed to the UI. On desktop, secret values are
|
|
27
|
-
* automatically cleared from the clipboard after a short delay.
|
|
28
|
-
*/
|
|
29
|
-
copyPvarValueToClipboard: rpcStub("copyPvarValueToClipboard"),
|
|
30
17
|
tableMethodCall: rpcStub("tableMethodCall"),
|
|
31
18
|
// TODO lock this down so not all code can get any file contents
|
|
32
19
|
getFileContents: rpcStub("getFileContents"),
|
|
@@ -34,23 +21,11 @@ exports.rpcServerCalls = {
|
|
|
34
21
|
getFileContentsBase64: rpcStub("getFileContentsBase64"),
|
|
35
22
|
// Save a file from the UI - data should be base64 encoded for binary files
|
|
36
23
|
saveFile: rpcStub("saveFile"),
|
|
37
|
-
// Inject UI bundle directly into WebView (bypasses slow postMessage for large strings)
|
|
38
|
-
injectUIBundle: rpcStub("injectUIBundle"),
|
|
39
24
|
deleteLocalDatabase: rpcStub("deleteLocalDatabase"),
|
|
40
25
|
/** Returns info about the pre-migration data directory, or `null` if already cleaned up. */
|
|
41
26
|
getOldDataDirInfo: rpcStub("getOldDataDirInfo"),
|
|
42
27
|
/** Deletes the pre-migration data directory after the user confirms. */
|
|
43
28
|
cleanupOldDataDir: rpcStub("cleanupOldDataDir"),
|
|
44
|
-
/**
|
|
45
|
-
* Sign a package version with the package author's key (server-side only — key never leaves the server).
|
|
46
|
-
* Returns the base64url detached signature, or undefined if the signing key isn't available.
|
|
47
|
-
* Optional fields (appNavs, createdBy, createdAt) must match the PV record when present so
|
|
48
|
-
* propagation verification of the full record succeeds.
|
|
49
|
-
*/
|
|
50
|
-
signPackageAuthorVersion: rpcStub("signPackageAuthorVersion"),
|
|
51
|
-
// App lifecycle commands (for CLI control)
|
|
52
|
-
appQuit: rpcStub("appQuit"),
|
|
53
|
-
appRestart: rpcStub("appRestart"),
|
|
54
29
|
// Database exploration (for CLI)
|
|
55
30
|
dbQuery: rpcStub("dbQuery"),
|
|
56
31
|
// Direct tool execution (for CLI)
|
|
@@ -63,12 +38,6 @@ exports.rpcServerCalls = {
|
|
|
63
38
|
remoteGetTool: rpcStub("remoteGetTool"),
|
|
64
39
|
remoteRunTool: rpcStub("remoteRunTool"),
|
|
65
40
|
remoteQueryLogs: rpcStub("remoteQueryLogs"),
|
|
66
|
-
// UI control (for CLI)
|
|
67
|
-
uiReload: rpcStub("uiReload"),
|
|
68
|
-
uiInspect: rpcStub("uiInspect"),
|
|
69
|
-
uiClick: rpcStub("uiClick"),
|
|
70
|
-
uiSet: rpcStub("uiSet"),
|
|
71
|
-
uiScroll: rpcStub("uiScroll"),
|
|
72
41
|
// Flush all in-memory database snapshots to durable storage (IndexedDB in PWA).
|
|
73
42
|
// No-op on Electron where better-sqlite3 writes are synchronous to disk.
|
|
74
43
|
flushDatabases: (async () => { }),
|
|
@@ -83,14 +52,6 @@ exports.rpcClientCalls = {
|
|
|
83
52
|
ping: async (msg) => `pong: ${msg}`,
|
|
84
53
|
// emitEvent: rpcStub('emitEvent') as ((event: IEventData) => Promise<boolean>),
|
|
85
54
|
emitEvent: ((..._args) => Promise.resolve(false)),
|
|
86
|
-
setClientPath: rpcStub("setClientPath"),
|
|
87
|
-
openThread: rpcStub("openThread"),
|
|
88
|
-
// UI inspection (for CLI)
|
|
89
|
-
uiGetState: rpcStub("uiGetState"),
|
|
90
|
-
// UI actions (for CLI)
|
|
91
|
-
uiDoClick: rpcStub("uiDoClick"),
|
|
92
|
-
uiDoSet: rpcStub("uiDoSet"),
|
|
93
|
-
uiDoScroll: rpcStub("uiDoScroll"),
|
|
94
55
|
};
|
|
95
56
|
// Check if we're in a client context (browser, webview, or CLI connected to server)
|
|
96
57
|
// - Browser: window + document exist
|
package/dist/system-ids.d.ts
CHANGED
|
@@ -195,3 +195,16 @@ export declare const toolCatalogContractId = "00mvbpdnm2au2rzmdelorjwah";
|
|
|
195
195
|
export declare const hostToolsContractId = "00mvbrni9wjucq4q1jbfe9ep3";
|
|
196
196
|
/** Desktop-only utilities; allocated once with newid() for System Desktop Tools v1. */
|
|
197
197
|
export declare const desktopToolsContractId = "00mvbrni9w4z58hwoxfe406ru";
|
|
198
|
+
/**
|
|
199
|
+
* Contract id for **System Packages**: list, inspect, import, reload, activate, and uninstall
|
|
200
|
+
* packages, with each device's observed runtime state. Reachable over the UI and CLI host
|
|
201
|
+
* transport and, remotely, by devices this one trusts as Self; allocated once with newid() for
|
|
202
|
+
* System Packages v1.
|
|
203
|
+
*/
|
|
204
|
+
export declare const packagesContractId = "00mvdhk66tdqrj3hy0bacmj32";
|
|
205
|
+
/**
|
|
206
|
+
* Contract id for **System Host Shell**: the app's window and shell (inspect, drive, and
|
|
207
|
+
* screenshot the UI; quit and restart; open links, folders, and the editor; the clipboard).
|
|
208
|
+
* Allocated once with newid() for System Host Shell v1.
|
|
209
|
+
*/
|
|
210
|
+
export declare const hostShellContractId = "00mveexhw7ezjfghxomlo011g";
|
package/dist/system-ids.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.desktopToolsContractId = exports.hostToolsContractId = exports.toolCatalogContractId = exports.schedulerToolIds = exports.schedulerContractId = exports.contractCatalogToolIds = exports.contractCatalogContractId = exports.httpToolIds = exports.httpContractId = exports.localFoldersToolIds = exports.localFoldersContractId = exports.identityToolIds = exports.identityContractId = exports.invitesToolIds = exports.invitesContractId = exports.toolAccessControlToolIds = exports.toolAccessControlContractId = exports.appUpdatesContractId = exports.networkControlContractId = exports.networkDiagnosticsContractId = exports.deviceOperationsContractId = exports.logsContractId = exports.peersSystemPackageId = exports.peersCoreRevokedPublishPublicKeys = exports.peersCorePublishPublicKey = exports.peersCorePackageRepoUrl = exports.peersCorePackageId = exports.createGroupToolId = exports.queryDatabaseToolId = exports.runWorkflowToolId = exports.defaultSendMessageToolId = exports.defaultAssistantRunnerToolId = exports.adminAssistantId = exports.openCodeAssistantId = exports.defaultAssistantId = exports.peersRootUserId = void 0;
|
|
3
|
+
exports.hostShellContractId = exports.packagesContractId = exports.desktopToolsContractId = exports.hostToolsContractId = exports.toolCatalogContractId = exports.schedulerToolIds = exports.schedulerContractId = exports.contractCatalogToolIds = exports.contractCatalogContractId = exports.httpToolIds = exports.httpContractId = exports.localFoldersToolIds = exports.localFoldersContractId = exports.identityToolIds = exports.identityContractId = exports.invitesToolIds = exports.invitesContractId = exports.toolAccessControlToolIds = exports.toolAccessControlContractId = exports.appUpdatesContractId = exports.networkControlContractId = exports.networkDiagnosticsContractId = exports.deviceOperationsContractId = exports.logsContractId = exports.peersSystemPackageId = exports.peersCoreRevokedPublishPublicKeys = exports.peersCorePublishPublicKey = exports.peersCorePackageRepoUrl = exports.peersCorePackageId = exports.createGroupToolId = exports.queryDatabaseToolId = exports.runWorkflowToolId = exports.defaultSendMessageToolId = exports.defaultAssistantRunnerToolId = exports.adminAssistantId = exports.openCodeAssistantId = exports.defaultAssistantId = exports.peersRootUserId = void 0;
|
|
4
4
|
/** Stable user ID that owns built-in Peers system records. */
|
|
5
5
|
exports.peersRootUserId = "000peers0user000000000001";
|
|
6
6
|
/** Default assistant used when no user-selected assistant is available. */
|
|
@@ -202,3 +202,16 @@ exports.toolCatalogContractId = "00mvbpdnm2au2rzmdelorjwah";
|
|
|
202
202
|
exports.hostToolsContractId = "00mvbrni9wjucq4q1jbfe9ep3";
|
|
203
203
|
/** Desktop-only utilities; allocated once with newid() for System Desktop Tools v1. */
|
|
204
204
|
exports.desktopToolsContractId = "00mvbrni9w4z58hwoxfe406ru";
|
|
205
|
+
/**
|
|
206
|
+
* Contract id for **System Packages**: list, inspect, import, reload, activate, and uninstall
|
|
207
|
+
* packages, with each device's observed runtime state. Reachable over the UI and CLI host
|
|
208
|
+
* transport and, remotely, by devices this one trusts as Self; allocated once with newid() for
|
|
209
|
+
* System Packages v1.
|
|
210
|
+
*/
|
|
211
|
+
exports.packagesContractId = "00mvdhk66tdqrj3hy0bacmj32";
|
|
212
|
+
/**
|
|
213
|
+
* Contract id for **System Host Shell**: the app's window and shell (inspect, drive, and
|
|
214
|
+
* screenshot the UI; quit and restart; open links, folders, and the editor; the clipboard).
|
|
215
|
+
* Allocated once with newid() for System Host Shell v1.
|
|
216
|
+
*/
|
|
217
|
+
exports.hostShellContractId = "00mveexhw7ezjfghxomlo011g";
|