@marifold/core 0.69.0 → 0.70.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/agent/AgentRunner.d.ts +7 -1
- package/dist/agent/AgentRunner.d.ts.map +1 -1
- package/dist/agent/AgentRunner.js +50 -16
- package/dist/agent/AgentRunner.js.map +1 -1
- package/dist/agent/RunArtifacts.d.ts +6 -1
- package/dist/agent/RunArtifacts.d.ts.map +1 -1
- package/dist/agent/RunArtifacts.js +16 -3
- package/dist/agent/RunArtifacts.js.map +1 -1
- package/dist/agent/RunWorkspace.d.ts +3 -0
- package/dist/agent/RunWorkspace.d.ts.map +1 -1
- package/dist/agent/RunWorkspace.js +5 -0
- package/dist/agent/RunWorkspace.js.map +1 -1
- package/dist/agent/ScopedProcess.d.ts.map +1 -1
- package/dist/agent/ScopedProcess.js +1 -0
- package/dist/agent/ScopedProcess.js.map +1 -1
- package/dist/agent/ToolRegistry.d.ts +6 -1
- package/dist/agent/ToolRegistry.d.ts.map +1 -1
- package/dist/agent/ToolRegistry.js +4 -1
- package/dist/agent/ToolRegistry.js.map +1 -1
- package/dist/agent/tools/ReadFileTool.d.ts.map +1 -1
- package/dist/agent/tools/ReadFileTool.js +4 -0
- package/dist/agent/tools/ReadFileTool.js.map +1 -1
- package/dist/agent/tools/WriteFileTool.d.ts.map +1 -1
- package/dist/agent/tools/WriteFileTool.js +4 -0
- package/dist/agent/tools/WriteFileTool.js.map +1 -1
- package/dist/app/SkillAppInstanceRegistry.d.ts.map +1 -1
- package/dist/app/SkillAppInstanceRegistry.js +5 -0
- package/dist/app/SkillAppInstanceRegistry.js.map +1 -1
- package/dist/config/ChatGptCatalogVersion.d.ts +3 -0
- package/dist/config/ChatGptCatalogVersion.d.ts.map +1 -0
- package/dist/config/ChatGptCatalogVersion.js +55 -0
- package/dist/config/ChatGptCatalogVersion.js.map +1 -0
- package/dist/config/ProviderInspector.d.ts.map +1 -1
- package/dist/config/ProviderInspector.js +2 -5
- package/dist/config/ProviderInspector.js.map +1 -1
- package/dist/errors/MarifoldError.d.ts +1 -1
- package/dist/errors/MarifoldError.d.ts.map +1 -1
- package/dist/errors/MarifoldError.js.map +1 -1
- package/dist/images/AvatarThumbnail.d.ts +3 -0
- package/dist/images/AvatarThumbnail.d.ts.map +1 -0
- package/dist/images/AvatarThumbnail.js +16 -0
- package/dist/images/AvatarThumbnail.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -4
- package/dist/index.js.map +1 -1
- package/dist/profiles/ProfileManager.d.ts.map +1 -1
- package/dist/profiles/ProfileManager.js +2 -3
- package/dist/profiles/ProfileManager.js.map +1 -1
- package/dist/runs/RunRegistry.d.ts +27 -1
- package/dist/runs/RunRegistry.d.ts.map +1 -1
- package/dist/runs/RunRegistry.js +75 -16
- package/dist/runs/RunRegistry.js.map +1 -1
- package/dist/runtime/MarifoldRuntime.d.ts +9 -2
- package/dist/runtime/MarifoldRuntime.d.ts.map +1 -1
- package/dist/runtime/MarifoldRuntime.js +26 -5
- package/dist/runtime/MarifoldRuntime.js.map +1 -1
- package/dist/workspace/DeviceDelegateTool.d.ts +40 -0
- package/dist/workspace/DeviceDelegateTool.d.ts.map +1 -0
- package/dist/workspace/DeviceDelegateTool.js +79 -0
- package/dist/workspace/DeviceDelegateTool.js.map +1 -0
- package/dist/workspace/WorkspaceArtifactTransfer.d.ts +8 -0
- package/dist/workspace/WorkspaceArtifactTransfer.d.ts.map +1 -0
- package/dist/workspace/WorkspaceArtifactTransfer.js +45 -0
- package/dist/workspace/WorkspaceArtifactTransfer.js.map +1 -0
- package/dist/workspace/WorkspaceExecutor.d.ts +19 -0
- package/dist/workspace/WorkspaceExecutor.d.ts.map +1 -0
- package/dist/workspace/WorkspaceExecutor.js +212 -0
- package/dist/workspace/WorkspaceExecutor.js.map +1 -0
- package/dist/workspace/WorkspaceManager.d.ts +43 -0
- package/dist/workspace/WorkspaceManager.d.ts.map +1 -0
- package/dist/workspace/WorkspaceManager.js +378 -0
- package/dist/workspace/WorkspaceManager.js.map +1 -0
- package/dist/workspace/WorkspaceRuns.d.ts +18 -0
- package/dist/workspace/WorkspaceRuns.d.ts.map +1 -0
- package/dist/workspace/WorkspaceRuns.js +152 -0
- package/dist/workspace/WorkspaceRuns.js.map +1 -0
- package/dist/workspace/WorkspaceStore.d.ts +49 -0
- package/dist/workspace/WorkspaceStore.d.ts.map +1 -0
- package/dist/workspace/WorkspaceStore.js +419 -0
- package/dist/workspace/WorkspaceStore.js.map +1 -0
- package/dist/workspace/WorkspaceTerminal.d.ts +4 -0
- package/dist/workspace/WorkspaceTerminal.d.ts.map +1 -0
- package/dist/workspace/WorkspaceTerminal.js +80 -0
- package/dist/workspace/WorkspaceTerminal.js.map +1 -0
- package/dist/workspace/bridge/BridgePeer.d.ts +48 -0
- package/dist/workspace/bridge/BridgePeer.d.ts.map +1 -0
- package/dist/workspace/bridge/BridgePeer.js +307 -0
- package/dist/workspace/bridge/BridgePeer.js.map +1 -0
- package/dist/workspace/bridge/ChunkTransfers.d.ts +19 -0
- package/dist/workspace/bridge/ChunkTransfers.d.ts.map +1 -0
- package/dist/workspace/bridge/ChunkTransfers.js +125 -0
- package/dist/workspace/bridge/ChunkTransfers.js.map +1 -0
- package/package.json +6 -3
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.WorkspaceManager = void 0;
|
|
37
|
+
const MarifoldError_1 = require("../errors/MarifoldError");
|
|
38
|
+
const os = __importStar(require("node:os"));
|
|
39
|
+
const workspace_protocol_1 = require("@marifold/workspace-protocol");
|
|
40
|
+
const WorkspaceStore_1 = require("./WorkspaceStore");
|
|
41
|
+
const BridgePeer_1 = require("./bridge/BridgePeer");
|
|
42
|
+
class WorkspaceManager {
|
|
43
|
+
store;
|
|
44
|
+
peers = new Map();
|
|
45
|
+
hostStatus = new Map();
|
|
46
|
+
presence = new Map();
|
|
47
|
+
onMembershipRemoved;
|
|
48
|
+
heartbeat;
|
|
49
|
+
remoteHandler;
|
|
50
|
+
executorHandler;
|
|
51
|
+
constructor(configPath) {
|
|
52
|
+
this.store = new WorkspaceStore_1.WorkspaceStore(configPath);
|
|
53
|
+
}
|
|
54
|
+
start(handler, executor) {
|
|
55
|
+
this.remoteHandler = handler;
|
|
56
|
+
this.executorHandler = executor;
|
|
57
|
+
this.store.interruptRequests();
|
|
58
|
+
for (const c of this.store.list())
|
|
59
|
+
this.connect(c);
|
|
60
|
+
this.heartbeat = setInterval(() => {
|
|
61
|
+
for (const c of this.store.list())
|
|
62
|
+
if (c.role === 'guest')
|
|
63
|
+
void this.checkHost(c);
|
|
64
|
+
}, 15000);
|
|
65
|
+
}
|
|
66
|
+
close() {
|
|
67
|
+
clearInterval(this.heartbeat);
|
|
68
|
+
for (const peer of this.peers.values())
|
|
69
|
+
peer.close();
|
|
70
|
+
this.store.close();
|
|
71
|
+
}
|
|
72
|
+
list() {
|
|
73
|
+
return this.store
|
|
74
|
+
.list()
|
|
75
|
+
.map(({ id, name, role, bridgeUrl, deviceId, hostDeviceId, executor }) => ({
|
|
76
|
+
id,
|
|
77
|
+
name,
|
|
78
|
+
role,
|
|
79
|
+
bridgeUrl,
|
|
80
|
+
deviceId,
|
|
81
|
+
hostDeviceId,
|
|
82
|
+
executor,
|
|
83
|
+
online: role === 'host' ? Boolean(this.peers.get(id)?.online) : this.hostStatus.get(id) === true,
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
async create(name, url, registrationToken) {
|
|
87
|
+
const c = await this.store.create(name, url, os.hostname());
|
|
88
|
+
try {
|
|
89
|
+
const response = await fetch(`${c.bridgeUrl}/v1/hosts`, {
|
|
90
|
+
method: 'POST',
|
|
91
|
+
headers: { authorization: `Bearer ${registrationToken}`, 'content-type': 'application/json' },
|
|
92
|
+
body: JSON.stringify({ workspaceId: c.id, hostDeviceId: c.hostDeviceId, host: c.host }),
|
|
93
|
+
signal: AbortSignal.timeout(10000),
|
|
94
|
+
redirect: 'error',
|
|
95
|
+
});
|
|
96
|
+
if (!response.ok)
|
|
97
|
+
throw new Error(`Bridge registration failed (HTTP ${response.status}).`);
|
|
98
|
+
const peer = this.connect(c);
|
|
99
|
+
await peer.ready();
|
|
100
|
+
return { workspace: this.list().find((w) => w.id === c.id), invitation: this.store.invite(c.id) };
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
this.peers.get(c.id)?.close();
|
|
104
|
+
this.peers.delete(c.id);
|
|
105
|
+
this.store.remove(c.id);
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async add(url, token, executor = false) {
|
|
110
|
+
if (token.length > 16384)
|
|
111
|
+
throw new Error('Invalid invitation.');
|
|
112
|
+
const invitation = (0, workspace_protocol_1.record)(JSON.parse(Buffer.from(token, 'base64url').toString('utf8')));
|
|
113
|
+
if (invitation.version !== 1 ||
|
|
114
|
+
invitation.expiresAt < Date.now() ||
|
|
115
|
+
(0, workspace_protocol_1.bridgeOrigin)(url) !== invitation.bridgeUrl ||
|
|
116
|
+
typeof invitation.secret !== 'string')
|
|
117
|
+
throw new Error('Invitation expired or belongs to a different bridge.');
|
|
118
|
+
const workspaceId = (0, workspace_protocol_1.identifier)(invitation.workspaceId);
|
|
119
|
+
if (this.store.list().some((c) => c.id === workspaceId))
|
|
120
|
+
throw new Error('Workspace already connected.');
|
|
121
|
+
const identity = await (0, workspace_protocol_1.createIdentity)();
|
|
122
|
+
const pendingId = `pending_${(0, workspace_protocol_1.randomId)()}`;
|
|
123
|
+
const temporary = new BridgePeer_1.BridgePeer({
|
|
124
|
+
bridgeUrl: invitation.bridgeUrl,
|
|
125
|
+
workspaceId,
|
|
126
|
+
deviceId: pendingId,
|
|
127
|
+
identity,
|
|
128
|
+
host: invitation.host,
|
|
129
|
+
onRequest: async () => {
|
|
130
|
+
throw new Error('Pairing is not an execution connection.');
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
temporary.start();
|
|
134
|
+
try {
|
|
135
|
+
await temporary.ready();
|
|
136
|
+
const reply = (0, workspace_protocol_1.record)(await temporary.request('join', { secret: invitation.secret, name: os.hostname() }));
|
|
137
|
+
const certificate = reply.certificate;
|
|
138
|
+
if (!(0, workspace_protocol_1.validMembership)(certificate, invitation.host) ||
|
|
139
|
+
certificate.membership.workspaceId !== workspaceId ||
|
|
140
|
+
JSON.stringify(certificate.membership.identity) !== JSON.stringify((0, workspace_protocol_1.publicIdentity)(identity)))
|
|
141
|
+
throw new Error('Host returned invalid membership.');
|
|
142
|
+
const c = {
|
|
143
|
+
id: workspaceId,
|
|
144
|
+
name: String(reply.name),
|
|
145
|
+
role: 'guest',
|
|
146
|
+
bridgeUrl: invitation.bridgeUrl,
|
|
147
|
+
hostDeviceId: temporary.hostId,
|
|
148
|
+
deviceId: certificate.membership.deviceId,
|
|
149
|
+
identity,
|
|
150
|
+
host: invitation.host,
|
|
151
|
+
certificate,
|
|
152
|
+
executor,
|
|
153
|
+
};
|
|
154
|
+
this.store.save(c);
|
|
155
|
+
const peer = this.connect(c);
|
|
156
|
+
await peer.ready();
|
|
157
|
+
await this.checkHost(c);
|
|
158
|
+
return this.list().find((w) => w.id === c.id);
|
|
159
|
+
}
|
|
160
|
+
finally {
|
|
161
|
+
temporary.close();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
devices(id) {
|
|
165
|
+
const c = this.store.get(id);
|
|
166
|
+
return this.store
|
|
167
|
+
.devices(c.id)
|
|
168
|
+
.filter((d) => !d.revoked)
|
|
169
|
+
.map((d) => {
|
|
170
|
+
const m = d.certificate.membership;
|
|
171
|
+
const host = m.deviceId === c.hostDeviceId;
|
|
172
|
+
const p = this.presence.get(`${c.id}:${m.deviceId}`);
|
|
173
|
+
return {
|
|
174
|
+
id: m.deviceId,
|
|
175
|
+
name: m.name,
|
|
176
|
+
host,
|
|
177
|
+
platform: host ? os.platform() : (p?.platform ?? ''),
|
|
178
|
+
architecture: host ? os.arch() : (p?.architecture ?? ''),
|
|
179
|
+
executor: host || p?.executor === true,
|
|
180
|
+
online: host || Boolean(p && Date.now() - p.seen < 35000),
|
|
181
|
+
};
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
async request(id, operation, input, requestId = (0, workspace_protocol_1.randomId)()) {
|
|
185
|
+
const c = this.store.get(id);
|
|
186
|
+
if (c.role === 'host')
|
|
187
|
+
return this.dispatch(c, { type: 'request', operation, input, id: requestId }, { id: c.deviceId, identity: c.host, certificate: c.certificate });
|
|
188
|
+
const peer = this.peers.get(c.id);
|
|
189
|
+
if (!peer?.online || this.hostStatus.get(c.id) !== true)
|
|
190
|
+
throw new MarifoldError_1.MarifoldError('WORKSPACE_OFFLINE', 'Workspace host is offline.');
|
|
191
|
+
const read = ['devices', 'run.events', 'artifact.read'].includes(operation) ||
|
|
192
|
+
(operation === 'api' && (0, workspace_protocol_1.record)(input).method === 'GET');
|
|
193
|
+
let result;
|
|
194
|
+
try {
|
|
195
|
+
result = await peer.request(operation, input, c.hostDeviceId, c.host, requestId, read ? 60000 : 120000);
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
if (!peer.online ||
|
|
199
|
+
this.hostStatus.get(c.id) !== true)
|
|
200
|
+
throw new MarifoldError_1.MarifoldError('WORKSPACE_OFFLINE', 'Workspace host is unavailable.');
|
|
201
|
+
if (read && error instanceof Error && error.message.includes('timed out'))
|
|
202
|
+
throw new MarifoldError_1.MarifoldError('WORKSPACE_TIMEOUT', 'Workspace request timed out while the bridge remained connected.');
|
|
203
|
+
throw error;
|
|
204
|
+
}
|
|
205
|
+
if (operation === 'rename' && typeof (0, workspace_protocol_1.record)(result).name === 'string')
|
|
206
|
+
this.store.rename(c.id, String((0, workspace_protocol_1.record)(result).name));
|
|
207
|
+
return result;
|
|
208
|
+
}
|
|
209
|
+
async execute(id, device, operation, input, requestId = (0, workspace_protocol_1.randomId)()) {
|
|
210
|
+
const c = this.store.get(id);
|
|
211
|
+
if (c.role !== 'host')
|
|
212
|
+
throw new Error('Only the workspace host coordinates execution.');
|
|
213
|
+
const member = this.store.devices(c.id).find((d) => d.certificate.membership.deviceId === device && !d.revoked);
|
|
214
|
+
if (!member)
|
|
215
|
+
throw new Error('Execution device is not a workspace member.');
|
|
216
|
+
const peer = this.peers.get(c.id);
|
|
217
|
+
if (!peer?.online)
|
|
218
|
+
throw new MarifoldError_1.MarifoldError('WORKSPACE_OFFLINE', 'Execution device is unavailable.');
|
|
219
|
+
return peer.request(operation, input, device, member.certificate.membership.identity, requestId, operation === 'executor.execute' ? 120000 : 10000);
|
|
220
|
+
}
|
|
221
|
+
async remove(id) {
|
|
222
|
+
const c = this.store.get(id);
|
|
223
|
+
this.onMembershipRemoved?.(c.id);
|
|
224
|
+
if (c.role === 'host') {
|
|
225
|
+
const peer = this.peers.get(c.id);
|
|
226
|
+
if (peer?.online) {
|
|
227
|
+
for (const d of this.store.devices(c.id))
|
|
228
|
+
if (d.certificate.membership.deviceId !== c.deviceId)
|
|
229
|
+
await peer.revoke(d.certificate.membership.deviceId);
|
|
230
|
+
await peer.revoke(c.deviceId);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
else if (this.peers.get(c.id)?.online) {
|
|
234
|
+
// Leaving locally must remain available even when the host disappears.
|
|
235
|
+
try {
|
|
236
|
+
await this.peers.get(c.id).request('leave', {}, c.hostDeviceId, c.host, (0, workspace_protocol_1.randomId)(), 3000);
|
|
237
|
+
}
|
|
238
|
+
catch {
|
|
239
|
+
/* Host can revoke an offline former device separately. */
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
this.peers.get(c.id)?.close();
|
|
243
|
+
this.peers.delete(c.id);
|
|
244
|
+
this.hostStatus.delete(c.id);
|
|
245
|
+
this.store.remove(c.id);
|
|
246
|
+
}
|
|
247
|
+
async setExecutor(id, enabled) {
|
|
248
|
+
const connection = this.store.get(id);
|
|
249
|
+
if (connection.role !== 'guest')
|
|
250
|
+
throw new Error('The workspace host always executes its local tools.');
|
|
251
|
+
this.store.save({ ...connection, executor: enabled });
|
|
252
|
+
await this.checkHost(this.store.get(connection.id));
|
|
253
|
+
}
|
|
254
|
+
connect(c) {
|
|
255
|
+
this.peers.get(c.id)?.close();
|
|
256
|
+
const peer = new BridgePeer_1.BridgePeer({
|
|
257
|
+
bridgeUrl: c.bridgeUrl,
|
|
258
|
+
workspaceId: c.id,
|
|
259
|
+
deviceId: c.deviceId,
|
|
260
|
+
hostDeviceId: c.hostDeviceId,
|
|
261
|
+
identity: c.identity,
|
|
262
|
+
host: c.host,
|
|
263
|
+
certificate: c.certificate,
|
|
264
|
+
accept: (certificate) => c.role !== 'host' ||
|
|
265
|
+
this.store.devices(c.id).some((d) => !d.revoked && d.certificate.signature === certificate.signature),
|
|
266
|
+
onRequest: (request, sender) => this.dispatch(c, request, sender),
|
|
267
|
+
onStatus: (online) => {
|
|
268
|
+
if (!online)
|
|
269
|
+
this.hostStatus.set(c.id, false);
|
|
270
|
+
else if (c.role === 'host') {
|
|
271
|
+
for (const d of this.store.devices(c.id))
|
|
272
|
+
if (d.revoked)
|
|
273
|
+
void this.peers
|
|
274
|
+
.get(c.id)
|
|
275
|
+
?.revoke(d.certificate.membership.deviceId)
|
|
276
|
+
.catch(() => undefined);
|
|
277
|
+
}
|
|
278
|
+
else if (c.role === 'guest')
|
|
279
|
+
queueMicrotask(() => {
|
|
280
|
+
void this.checkHost(c);
|
|
281
|
+
});
|
|
282
|
+
},
|
|
283
|
+
});
|
|
284
|
+
this.peers.set(c.id, peer);
|
|
285
|
+
peer.start();
|
|
286
|
+
return peer;
|
|
287
|
+
}
|
|
288
|
+
async checkHost(c) {
|
|
289
|
+
try {
|
|
290
|
+
const peer = this.peers.get(c.id);
|
|
291
|
+
if (!peer?.online)
|
|
292
|
+
throw new Error('offline');
|
|
293
|
+
const status = (0, workspace_protocol_1.record)(await peer.request('status', { platform: os.platform(), architecture: os.arch(), executor: this.store.get(c.id).executor }, c.hostDeviceId, c.host, (0, workspace_protocol_1.randomId)(), 10000));
|
|
294
|
+
if (typeof status.name === 'string' && status.name !== c.name)
|
|
295
|
+
this.store.rename(c.id, status.name);
|
|
296
|
+
this.hostStatus.set(c.id, true);
|
|
297
|
+
}
|
|
298
|
+
catch {
|
|
299
|
+
this.hostStatus.set(c.id, false);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
async dispatch(c, request, sender) {
|
|
303
|
+
const context = { workspaceId: c.id, senderDeviceId: sender.id, hostDeviceId: c.hostDeviceId };
|
|
304
|
+
if (c.role === 'guest') {
|
|
305
|
+
if (sender.id !== c.hostDeviceId || !this.store.get(c.id).executor || !request.operation.startsWith('executor.'))
|
|
306
|
+
throw new Error('This device has not enabled this execution capability.');
|
|
307
|
+
if (!this.executorHandler)
|
|
308
|
+
throw new Error('Executor unavailable.');
|
|
309
|
+
if (['executor.lease', 'executor.assess', 'executor.artifact', 'executor.artifacts', 'executor.cancel'].includes(request.operation))
|
|
310
|
+
return this.executorHandler(request.operation, request.input, context);
|
|
311
|
+
return this.store.once(c.id, sender.id, request.id, request, () => this.executorHandler(request.operation, request.input, context));
|
|
312
|
+
}
|
|
313
|
+
if (request.operation === 'status') {
|
|
314
|
+
const info = (0, workspace_protocol_1.record)(request.input);
|
|
315
|
+
this.presence.set(`${c.id}:${sender.id}`, {
|
|
316
|
+
seen: Date.now(),
|
|
317
|
+
platform: String(info.platform ?? ''),
|
|
318
|
+
architecture: String(info.architecture ?? ''),
|
|
319
|
+
executor: info.executor === true,
|
|
320
|
+
});
|
|
321
|
+
return { name: this.store.get(c.id).name, hostDeviceId: c.hostDeviceId };
|
|
322
|
+
}
|
|
323
|
+
if (sender.certificate && ['run.events', 'artifact.read'].includes(request.operation))
|
|
324
|
+
return this.remoteHandler(request.operation, request.input, context);
|
|
325
|
+
if (sender.certificate &&
|
|
326
|
+
request.operation === 'api' &&
|
|
327
|
+
((0, workspace_protocol_1.record)(request.input).method === 'GET' || (0, workspace_protocol_1.record)(request.input).path === '/v1/terminal/snapshot'))
|
|
328
|
+
return this.remoteHandler(request.operation, request.input, context);
|
|
329
|
+
if (sender.certificate && request.operation === 'devices')
|
|
330
|
+
return { devices: this.devices(c.id) };
|
|
331
|
+
return this.store.once(c.id, sender.id, request.id, request, async () => {
|
|
332
|
+
const input = (0, workspace_protocol_1.record)(request.input);
|
|
333
|
+
if (request.operation === 'join') {
|
|
334
|
+
if (sender.certificate || typeof input.secret !== 'string')
|
|
335
|
+
throw new Error('Invalid pairing request.');
|
|
336
|
+
return {
|
|
337
|
+
name: this.store.get(c.id).name,
|
|
338
|
+
certificate: this.store.enroll(c.id, input.secret, (0, workspace_protocol_1.randomId)(), String(input.name), sender.identity),
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
if (!sender.certificate)
|
|
342
|
+
throw new Error('Workspace membership required.');
|
|
343
|
+
if (request.operation === 'invite')
|
|
344
|
+
return { invitation: this.store.invite(c.id) };
|
|
345
|
+
if (request.operation === 'rename') {
|
|
346
|
+
this.store.rename(c.id, String(input.name));
|
|
347
|
+
return { name: this.store.get(c.id).name };
|
|
348
|
+
}
|
|
349
|
+
if (request.operation === 'devices')
|
|
350
|
+
return { devices: this.devices(c.id) };
|
|
351
|
+
if (request.operation === 'revoke' || request.operation === 'leave') {
|
|
352
|
+
const deviceId = request.operation === 'leave' ? sender.id : (0, workspace_protocol_1.identifier)(input.deviceId);
|
|
353
|
+
this.store.revoke(c.id, deviceId);
|
|
354
|
+
this.onMembershipRemoved?.(c.id, deviceId);
|
|
355
|
+
// The host's authoritative membership check takes effect immediately.
|
|
356
|
+
// Allow the departing device's final response to enter the relay first.
|
|
357
|
+
if (deviceId === sender.id)
|
|
358
|
+
setTimeout(() => {
|
|
359
|
+
void this.peers
|
|
360
|
+
.get(c.id)
|
|
361
|
+
?.revoke(deviceId)
|
|
362
|
+
.catch(() => undefined);
|
|
363
|
+
}, 1000).unref();
|
|
364
|
+
else
|
|
365
|
+
await this.peers.get(c.id)?.revoke(deviceId);
|
|
366
|
+
return { revoked: true };
|
|
367
|
+
}
|
|
368
|
+
if (!this.remoteHandler)
|
|
369
|
+
throw new Error('Workspace operation unavailable.');
|
|
370
|
+
return this.remoteHandler(request.operation, request.input, context);
|
|
371
|
+
}, () => {
|
|
372
|
+
if (request.operation === 'join')
|
|
373
|
+
this.store.validateInvitation(c.id, (0, workspace_protocol_1.record)(request.input).secret);
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
exports.WorkspaceManager = WorkspaceManager;
|
|
378
|
+
//# sourceMappingURL=WorkspaceManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WorkspaceManager.js","sourceRoot":"","sources":["../../src/workspace/WorkspaceManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAAwD;AACxD,MAAY,EAAE,oCAAgB;AAC9B,qEAQsC;AAQtC,qDAAuE;AACvE,oDAAiD;AAOjD;IACW,KAAK,CAAiB;IACvB,KAAK,GAAG,IAAI,GAAG,EAAsB,CAAC;IACtC,UAAU,GAAG,IAAI,GAAG,EAAmB,CAAC;IACxC,QAAQ,GAAG,IAAI,GAAG,EAAuF,CAAC;IAClH,mBAAmB,CAAoD;IAC/D,SAAS,CAAkC;IAC3C,aAAa,CAA+F;IAC5G,eAAe,CAA+F;IACtH,YAAY,UAAkB;QAC5B,IAAI,CAAC,KAAK,GAAG,IAAI,+BAAc,CAAC,UAAU,CAAC,CAAC;IAC9C,CAAC;IACD,KAAK,CAAC,OAAuD,EAAE,QAA8C;QAC3G,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC;QAC7B,IAAI,CAAC,eAAe,GAAG,QAAQ,CAAC;QAChC,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC/B,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;YAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACnD,IAAI,CAAC,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE;YAChC,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;gB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aAAa;gBAAE,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;YAC7E,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACvE,CAAC,EACD,GAAG,EAAE;YACH,IAAI,OAAO,CAAC,SAAS,KAAK,MAAM;gBAAE,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,EAAE,IAAA,2BAAM,EAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC;QACtG,CAAC,CACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type DeviceChildRun } from './DeviceDelegateTool';
|
|
2
|
+
import type { AgentRunner } from '../agent/AgentRunner';
|
|
3
|
+
import type { MarifoldRuntime } from '../runtime/MarifoldRuntime';
|
|
4
|
+
import type { RunStartInput } from '../runs/RunRegistry';
|
|
5
|
+
import type { WorkspaceManager, WorkspaceOperationContext } from './WorkspaceManager';
|
|
6
|
+
export declare class WorkspaceRuns {
|
|
7
|
+
private readonly runtime;
|
|
8
|
+
private readonly manager;
|
|
9
|
+
private delegate?;
|
|
10
|
+
setDelegate(start: (parentRunId: string, input: RunStartInput) => DeviceChildRun): void;
|
|
11
|
+
constructor(runtime: MarifoldRuntime, manager: WorkspaceManager);
|
|
12
|
+
resolve(input: RunStartInput, selection: {
|
|
13
|
+
workspaceId?: string;
|
|
14
|
+
executionDeviceId?: string;
|
|
15
|
+
}, origin?: WorkspaceOperationContext): Promise<RunStartInput>;
|
|
16
|
+
createRunner(input: RunStartInput): AgentRunner;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=WorkspaceRuns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WorkspaceRuns.d.ts","sourceRoot":"","sources":["../../src/workspace/WorkspaceRuns.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG/E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AASxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAEtF,qBAAa,aAAa;IAMtB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAN1B,OAAO,CAAC,QAAQ,CAAC,CAAgE;IACjF,WAAW,CAAC,KAAK,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,KAAK,cAAc,GAAG,IAAI,CAEtF;IACD,YACmB,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,gBAAgB,EACxC;IACE,OAAO,CACX,KAAK,EAAE,aAAa,EACpB,SAAS,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;KAAE,EAC/D,MAAM,CAAC,EAAE,yBAAyB,GACjC,OAAO,CAAC,aAAa,CAAC,CAyBxB;IACD,YAAY,CAAC,KAAK,EAAE,aAAa,GAAG,WAAW,CAiH9C;CACF"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkspaceRuns = void 0;
|
|
4
|
+
const DeviceDelegateTool_1 = require("./DeviceDelegateTool");
|
|
5
|
+
const workspace_protocol_1 = require("@marifold/workspace-protocol");
|
|
6
|
+
const ToolRegistry_1 = require("../agent/ToolRegistry");
|
|
7
|
+
const WorkspaceExecutor_1 = require("./WorkspaceExecutor");
|
|
8
|
+
class WorkspaceRuns {
|
|
9
|
+
runtime;
|
|
10
|
+
manager;
|
|
11
|
+
delegate;
|
|
12
|
+
setDelegate(start) {
|
|
13
|
+
this.delegate = start;
|
|
14
|
+
}
|
|
15
|
+
constructor(runtime, manager) {
|
|
16
|
+
this.runtime = runtime;
|
|
17
|
+
this.manager = manager;
|
|
18
|
+
}
|
|
19
|
+
async resolve(input, selection, origin) {
|
|
20
|
+
const workspaceId = origin?.workspaceId ?? selection.workspaceId;
|
|
21
|
+
if (!workspaceId) {
|
|
22
|
+
if (selection.executionDeviceId)
|
|
23
|
+
throw new Error('Select a workspace before an execution device.');
|
|
24
|
+
return input;
|
|
25
|
+
}
|
|
26
|
+
const connection = this.manager.store.get(workspaceId);
|
|
27
|
+
if (connection.role !== 'host')
|
|
28
|
+
throw new Error('Run must be submitted to the workspace host.');
|
|
29
|
+
const originId = origin?.senderDeviceId ?? connection.deviceId;
|
|
30
|
+
const devices = this.manager.devices(connection.id);
|
|
31
|
+
const skill = input.lean || /^\s*\$[\w-]+/.test(input.userTurn ?? input.objective);
|
|
32
|
+
const explicit = selection.executionDeviceId;
|
|
33
|
+
const executionDeviceId = explicit === 'host'
|
|
34
|
+
? connection.hostDeviceId
|
|
35
|
+
: (explicit ??
|
|
36
|
+
(skill
|
|
37
|
+
? connection.hostDeviceId
|
|
38
|
+
: (devices.find((d) => d.id === originId && d.executor)?.id ?? connection.hostDeviceId)));
|
|
39
|
+
if (skill && executionDeviceId !== connection.hostDeviceId)
|
|
40
|
+
throw new Error('Skills execute on the workspace host in this version.');
|
|
41
|
+
const device = devices.find((d) => d.id === executionDeviceId);
|
|
42
|
+
if (!device || !device.online || !device.executor)
|
|
43
|
+
throw new Error('The selected execution device is unavailable or has disabled execution.');
|
|
44
|
+
return { ...input, execution: { workspaceId: connection.id, originDeviceId: originId, executionDeviceId } };
|
|
45
|
+
}
|
|
46
|
+
createRunner(input) {
|
|
47
|
+
const execution = input.execution;
|
|
48
|
+
if (!execution)
|
|
49
|
+
return this.runtime.createAgentRunner(input.profile);
|
|
50
|
+
const { workspaceId, executionDeviceId } = execution;
|
|
51
|
+
const host = this.manager.store.get(workspaceId);
|
|
52
|
+
const devices = this.manager.devices(workspaceId);
|
|
53
|
+
const contextInstructions = [
|
|
54
|
+
`Device context (metadata): ${JSON.stringify({ workspaceId, originDeviceId: execution.originDeviceId, executionDeviceId, devices })}. All file paths and tools belong to the execution device. Skills and Apps run on the host. Device delegation is limited to this workspace.`,
|
|
55
|
+
];
|
|
56
|
+
const registry = executionDeviceId === host.hostDeviceId
|
|
57
|
+
? this.runtime.createDefaultToolRegistry(input.profile)
|
|
58
|
+
: this.runtime.createHostContextTools(input.profile);
|
|
59
|
+
if (!input.parentRunId && !input.lean && input.registryRunId && this.delegate) {
|
|
60
|
+
registry.register(new DeviceDelegateTool_1.DeviceDelegateTool(async (selected, objective) => {
|
|
61
|
+
const matches = this.manager
|
|
62
|
+
.devices(workspaceId)
|
|
63
|
+
.filter((d) => d.id === selected || d.name === selected || (selected === 'host' && d.host));
|
|
64
|
+
if (matches.length !== 1)
|
|
65
|
+
throw new Error('Device name is ambiguous or unknown; use its ID.');
|
|
66
|
+
const child = await this.resolve({
|
|
67
|
+
objective,
|
|
68
|
+
profile: input.profile,
|
|
69
|
+
provider: input.provider,
|
|
70
|
+
model: input.model,
|
|
71
|
+
think: input.think,
|
|
72
|
+
files: input.files,
|
|
73
|
+
images: input.images,
|
|
74
|
+
}, { executionDeviceId: matches[0].id }, { workspaceId, senderDeviceId: execution.originDeviceId, hostDeviceId: host.hostDeviceId });
|
|
75
|
+
return this.delegate(input.registryRunId, child);
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
if (executionDeviceId === host.hostDeviceId)
|
|
79
|
+
return this.runtime.createAgentRunner(input.profile, registry, undefined, { contextInstructions });
|
|
80
|
+
let runId;
|
|
81
|
+
let lease;
|
|
82
|
+
let signal;
|
|
83
|
+
const request = (operation, body, id) => this.manager.execute(workspaceId, executionDeviceId, operation, body, id);
|
|
84
|
+
const stop = () => {
|
|
85
|
+
clearInterval(lease);
|
|
86
|
+
signal?.removeEventListener('abort', cancel);
|
|
87
|
+
};
|
|
88
|
+
const cancel = () => {
|
|
89
|
+
stop();
|
|
90
|
+
void request('executor.cancel', { runId }).catch(() => undefined);
|
|
91
|
+
};
|
|
92
|
+
for (const tool of (0, WorkspaceExecutor_1.executionTools)()) {
|
|
93
|
+
let grant;
|
|
94
|
+
registry.register({
|
|
95
|
+
definition: tool.definition,
|
|
96
|
+
kind: tool.kind,
|
|
97
|
+
summarizeCall: (value) => `[${devices.find((device) => device.id === executionDeviceId)?.name ?? executionDeviceId}] ${tool.summarizeCall(value)}`,
|
|
98
|
+
assessRisk: async (value, context) => {
|
|
99
|
+
signal = context.signal;
|
|
100
|
+
if (signal?.aborted)
|
|
101
|
+
throw new Error('Run cancelled.');
|
|
102
|
+
signal?.removeEventListener('abort', cancel);
|
|
103
|
+
signal?.addEventListener('abort', cancel, { once: true });
|
|
104
|
+
const assessment = (await request('executor.assess', {
|
|
105
|
+
runId,
|
|
106
|
+
tool: tool.definition.name,
|
|
107
|
+
input: value,
|
|
108
|
+
}));
|
|
109
|
+
grant = assessment.grant;
|
|
110
|
+
return assessment;
|
|
111
|
+
},
|
|
112
|
+
execute: async (value, context) => {
|
|
113
|
+
if (context.signal?.aborted)
|
|
114
|
+
throw new Error('Run cancelled.');
|
|
115
|
+
const permission = grant;
|
|
116
|
+
grant = undefined;
|
|
117
|
+
try {
|
|
118
|
+
return (await request('executor.execute', { runId, tool: tool.definition.name, input: value, grant: permission }, (0, workspace_protocol_1.randomId)()));
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
cancel();
|
|
122
|
+
throw new ToolRegistry_1.UncertainToolOutcomeError(`Execution stopped. The remote call may have completed; inspect the target device before retrying. ${error instanceof Error ? error.message : ''}`);
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
return this.runtime.createAgentRunner(input.profile, registry, undefined, {
|
|
128
|
+
contextInstructions,
|
|
129
|
+
deviceInstructions: `This run uses a model on the workspace host and tools on execution device ${executionDeviceId}. The requesting device is ${execution.originDeviceId}. All tool paths, home directory, and operating system belong to the execution device. Do not substitute host paths. Skills and Apps must be run on the host in a separate run.`,
|
|
130
|
+
createWorkspace: async (options) => {
|
|
131
|
+
runId = options.id;
|
|
132
|
+
const workspace = (await request('executor.prepare', {
|
|
133
|
+
runId,
|
|
134
|
+
cwd: input.cwd,
|
|
135
|
+
files: options.files,
|
|
136
|
+
images: options.images,
|
|
137
|
+
}));
|
|
138
|
+
lease = setInterval(() => {
|
|
139
|
+
void request('executor.lease', { runId }).catch(() => undefined);
|
|
140
|
+
}, 10000);
|
|
141
|
+
lease.unref();
|
|
142
|
+
return workspace;
|
|
143
|
+
},
|
|
144
|
+
listArtifacts: async () => {
|
|
145
|
+
stop();
|
|
146
|
+
return (await request('executor.artifacts', { runId }));
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
exports.WorkspaceRuns = WorkspaceRuns;
|
|
152
|
+
//# sourceMappingURL=WorkspaceRuns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WorkspaceRuns.js","sourceRoot":"","sources":["../../src/workspace/WorkspaceRuns.ts"],"names":[],"mappings":";;;AAAA,6DAA+E;AAE/E,qEAAgE;AAIhE,wDAK+B;AAG/B,2DAAqD;AAGrD;IAMqB,OAAO;IACP,OAAO;IANlB,QAAQ,CAAiE;IACjF,WAAW,CAAC,KAAoE;QAC9E,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;IACxB,CAAC;IACD,YACmB,OAAwB,EACxB,OAAyB;uBADzB,OAAO;uBACP,OAAO;IACvB,CAAC;IACJ,KAAK,CAAC,OAAO,CACX,KAAoB,EACpB,SAA+D,EAC/D,MAAkC;QAElC,MAAM,WAAW,GAAG,MAAM,EAAE,WAAW,IAAI,SAAS,CAAC,WAAW,CAAC;QACjE,IAAI,CA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AAQ,EAAE,SAAS,EAAE;YACxE,mBAAmB;YACnB,kBAAkB,EAAE,6EAA6E,iBAAiB,8BAA8B,SAAS,CAAC,cAAc,iLAAiL;YACzV,eAAe,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;gBACjC,KAAK,GAAG,OAAO,CAAC,EAAE,CAAC;gBACnB,MAAM,SAAS,GAAG,CAAC,MAAM,OAAO,CAAC,kBAAkB,EAAE;oBACnD,KAAK;oBACL,GAAG,EAAE,KAAK,CAAC,GAAG;oBACd,KAAK,EAAE,OAAO,CAAC,KAAK;oBACpB,MAAM,EAAE,OAAO,CAAC,MAAM;iBACvB,CAAC,CAAiB,CAAC;gBACpB,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;oBACvB,KAAK,OAAO,CAAC,gBAAgB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;gBACnE,CAAC,EAAE,KAAK,CAAC,CAAC;gBACV,KAAK,CAAC,KAAK,EAAE,CAAC;gBACd,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,aAAa,EAAE,KAAK,IAAI,EAAE;gBACxB,IAAI,EAAE,CAAC;gBACP,OAAO,CAAC,MAAM,OAAO,CAAC,oBAAoB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAkB,CAAC;YAC3E,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { PrivateIdentity, PublicIdentity, SignedMembership, WorkspaceSummary } from '@marifold/workspace-protocol';
|
|
2
|
+
export interface WorkspaceConnection extends Omit<WorkspaceSummary, 'online'> {
|
|
3
|
+
identity: PrivateIdentity;
|
|
4
|
+
certificate: SignedMembership;
|
|
5
|
+
host: PublicIdentity;
|
|
6
|
+
executor: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare class WorkspaceStore {
|
|
9
|
+
readonly directory: string;
|
|
10
|
+
private readonly db;
|
|
11
|
+
private closed;
|
|
12
|
+
private readonly lockPath;
|
|
13
|
+
private readonly lockValue;
|
|
14
|
+
private lastPruned;
|
|
15
|
+
constructor(configPath: string);
|
|
16
|
+
private acquireLock;
|
|
17
|
+
private releaseLock;
|
|
18
|
+
close(): void;
|
|
19
|
+
private prune;
|
|
20
|
+
readonly runJournal: {
|
|
21
|
+
load: () => Array<{
|
|
22
|
+
record: import('../runs/RunRegistry').RunRecord;
|
|
23
|
+
events: import('../runs/RunRegistry').SequencedEvent[];
|
|
24
|
+
}>;
|
|
25
|
+
save: (record: import('../runs/RunRegistry').RunRecord, event?: import('../runs/RunRegistry').SequencedEvent) => void;
|
|
26
|
+
};
|
|
27
|
+
list(): WorkspaceConnection[];
|
|
28
|
+
get(idOrName: string): WorkspaceConnection;
|
|
29
|
+
save(connection: WorkspaceConnection): void;
|
|
30
|
+
create(name: string, bridgeUrl: string, deviceName: string): Promise<WorkspaceConnection>;
|
|
31
|
+
invite(id: string): string;
|
|
32
|
+
validateInvitation(workspace: string, secret: unknown): void;
|
|
33
|
+
enroll(id: string, secret: string, deviceId: string, name: string, identity: PublicIdentity): SignedMembership;
|
|
34
|
+
addDevice(certificate: SignedMembership): void;
|
|
35
|
+
devices(workspace: string): Array<{
|
|
36
|
+
certificate: SignedMembership;
|
|
37
|
+
revoked: boolean;
|
|
38
|
+
}>;
|
|
39
|
+
revoke(workspace: string, deviceId: string): void;
|
|
40
|
+
rename(id: string, name: string): void;
|
|
41
|
+
remove(id: string): void;
|
|
42
|
+
defaultId(): string;
|
|
43
|
+
setDefault(id: string): void;
|
|
44
|
+
interruptRequests(): void;
|
|
45
|
+
once<T>(workspace: string, sender: string, id: string, input: unknown, operation: () => Promise<T>, validate?: () => void): Promise<T>;
|
|
46
|
+
private readIdentity;
|
|
47
|
+
private writeIdentity;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=WorkspaceStore.d.ts.map
|