@slock-ai/computer 0.0.17 → 0.0.18
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/index.js +19 -4
- package/dist/lib/index.js +19 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -29925,6 +29925,9 @@ function serverDir(slockHome, serverId) {
|
|
|
29925
29925
|
function serverAttachmentPath(slockHome, serverId) {
|
|
29926
29926
|
return path2.join(serverDir(slockHome, serverId), "runner.state.json");
|
|
29927
29927
|
}
|
|
29928
|
+
function legacyServerAttachmentPath(slockHome, serverId) {
|
|
29929
|
+
return path2.join(serverDir(slockHome, serverId), "attachment.json");
|
|
29930
|
+
}
|
|
29928
29931
|
function serverRunnerPidPath(slockHome, serverId) {
|
|
29929
29932
|
return path2.join(serverDir(slockHome, serverId), "server-runner.pid");
|
|
29930
29933
|
}
|
|
@@ -30176,21 +30179,33 @@ function parseAttachment(raw) {
|
|
|
30176
30179
|
serverMachineId: a.serverMachineId,
|
|
30177
30180
|
apiKey: a.apiKey,
|
|
30178
30181
|
serverUrl: a.serverUrl,
|
|
30179
|
-
attachedAt: typeof a.attachedAt === "string" ? a.attachedAt : void 0
|
|
30182
|
+
attachedAt: typeof a.attachedAt === "string" ? a.attachedAt : void 0,
|
|
30183
|
+
adoptedFromLegacy: a.adoptedFromLegacy === true ? true : void 0,
|
|
30184
|
+
legacyMachineId: typeof a.legacyMachineId === "string" ? a.legacyMachineId : void 0
|
|
30180
30185
|
};
|
|
30181
30186
|
}
|
|
30182
30187
|
} catch {
|
|
30183
30188
|
}
|
|
30184
30189
|
return null;
|
|
30185
30190
|
}
|
|
30186
|
-
async function
|
|
30187
|
-
if (!isValidServerId(serverId)) return null;
|
|
30191
|
+
async function readAttachmentAt(path3) {
|
|
30188
30192
|
try {
|
|
30189
|
-
return parseAttachment(await readFile(
|
|
30193
|
+
return parseAttachment(await readFile(path3, "utf8"));
|
|
30190
30194
|
} catch {
|
|
30191
30195
|
return null;
|
|
30192
30196
|
}
|
|
30193
30197
|
}
|
|
30198
|
+
async function readServerAttachment(slockHome, serverId) {
|
|
30199
|
+
if (!isValidServerId(serverId)) return null;
|
|
30200
|
+
const current = await readAttachmentAt(serverAttachmentPath(slockHome, serverId));
|
|
30201
|
+
const legacy = await readAttachmentAt(legacyServerAttachmentPath(slockHome, serverId));
|
|
30202
|
+
if (!current) return legacy;
|
|
30203
|
+
if (!legacy) return current;
|
|
30204
|
+
if (legacy.adoptedFromLegacy === true && current.adoptedFromLegacy !== true && legacy.serverMachineId !== current.serverMachineId) {
|
|
30205
|
+
return legacy;
|
|
30206
|
+
}
|
|
30207
|
+
return current;
|
|
30208
|
+
}
|
|
30194
30209
|
async function writeServerAttachment(slockHome, attachment) {
|
|
30195
30210
|
if (!isValidServerId(attachment.serverId)) return;
|
|
30196
30211
|
const path3 = serverAttachmentPath(slockHome, attachment.serverId);
|
package/dist/lib/index.js
CHANGED
|
@@ -308,6 +308,9 @@ function serverDir(slockHome, serverId) {
|
|
|
308
308
|
function serverAttachmentPath(slockHome, serverId) {
|
|
309
309
|
return path.join(serverDir(slockHome, serverId), "runner.state.json");
|
|
310
310
|
}
|
|
311
|
+
function legacyServerAttachmentPath(slockHome, serverId) {
|
|
312
|
+
return path.join(serverDir(slockHome, serverId), "attachment.json");
|
|
313
|
+
}
|
|
311
314
|
function serverRunnerPidPath(slockHome, serverId) {
|
|
312
315
|
return path.join(serverDir(slockHome, serverId), "server-runner.pid");
|
|
313
316
|
}
|
|
@@ -352,21 +355,33 @@ function parseAttachment(raw) {
|
|
|
352
355
|
serverMachineId: a.serverMachineId,
|
|
353
356
|
apiKey: a.apiKey,
|
|
354
357
|
serverUrl: a.serverUrl,
|
|
355
|
-
attachedAt: typeof a.attachedAt === "string" ? a.attachedAt : void 0
|
|
358
|
+
attachedAt: typeof a.attachedAt === "string" ? a.attachedAt : void 0,
|
|
359
|
+
adoptedFromLegacy: a.adoptedFromLegacy === true ? true : void 0,
|
|
360
|
+
legacyMachineId: typeof a.legacyMachineId === "string" ? a.legacyMachineId : void 0
|
|
356
361
|
};
|
|
357
362
|
}
|
|
358
363
|
} catch {
|
|
359
364
|
}
|
|
360
365
|
return null;
|
|
361
366
|
}
|
|
362
|
-
async function
|
|
363
|
-
if (!isValidServerId(serverId)) return null;
|
|
367
|
+
async function readAttachmentAt(path2) {
|
|
364
368
|
try {
|
|
365
|
-
return parseAttachment(await readFile2(
|
|
369
|
+
return parseAttachment(await readFile2(path2, "utf8"));
|
|
366
370
|
} catch {
|
|
367
371
|
return null;
|
|
368
372
|
}
|
|
369
373
|
}
|
|
374
|
+
async function readServerAttachment(slockHome, serverId) {
|
|
375
|
+
if (!isValidServerId(serverId)) return null;
|
|
376
|
+
const current = await readAttachmentAt(serverAttachmentPath(slockHome, serverId));
|
|
377
|
+
const legacy = await readAttachmentAt(legacyServerAttachmentPath(slockHome, serverId));
|
|
378
|
+
if (!current) return legacy;
|
|
379
|
+
if (!legacy) return current;
|
|
380
|
+
if (legacy.adoptedFromLegacy === true && current.adoptedFromLegacy !== true && legacy.serverMachineId !== current.serverMachineId) {
|
|
381
|
+
return legacy;
|
|
382
|
+
}
|
|
383
|
+
return current;
|
|
384
|
+
}
|
|
370
385
|
async function listAttachedServerIds(slockHome) {
|
|
371
386
|
let entries;
|
|
372
387
|
try {
|
package/package.json
CHANGED