@slock-ai/computer 0.0.34 → 0.0.36
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 +590 -1690
- package/dist/lib/index.d.ts +25 -1
- package/dist/lib/index.js +73 -13
- package/package.json +6 -2
package/dist/lib/index.d.ts
CHANGED
|
@@ -48,6 +48,30 @@ type LegacyMachineRosterResult = {
|
|
|
48
48
|
status: "error";
|
|
49
49
|
code: string;
|
|
50
50
|
};
|
|
51
|
+
/** A server the user belongs to. `role` mirrors the server-side
|
|
52
|
+
* `server_members.role` enum (`owner | admin | member`). */
|
|
53
|
+
interface UserServerEntry {
|
|
54
|
+
id: string;
|
|
55
|
+
name: string;
|
|
56
|
+
slug: string;
|
|
57
|
+
role: "owner" | "admin" | "member";
|
|
58
|
+
}
|
|
59
|
+
type UserServersResult = {
|
|
60
|
+
status: "success";
|
|
61
|
+
servers: UserServerEntry[];
|
|
62
|
+
} | {
|
|
63
|
+
status: "auth_required";
|
|
64
|
+
} | {
|
|
65
|
+
status: "error";
|
|
66
|
+
code: string;
|
|
67
|
+
};
|
|
68
|
+
declare class ServersClient {
|
|
69
|
+
private readonly baseUrl;
|
|
70
|
+
private readonly accessToken;
|
|
71
|
+
constructor(baseUrl: string, accessToken: string);
|
|
72
|
+
private url;
|
|
73
|
+
list(): Promise<UserServersResult>;
|
|
74
|
+
}
|
|
51
75
|
declare class LegacyMachinesClient {
|
|
52
76
|
private readonly baseUrl;
|
|
53
77
|
private readonly accessToken;
|
|
@@ -652,4 +676,4 @@ interface UpgradeLogEntryErr {
|
|
|
652
676
|
*/
|
|
653
677
|
declare function assertUpgradeLogEntry(entry: UpgradeLogEntry): void;
|
|
654
678
|
|
|
655
|
-
export { type ComputerStatusReport, type ConnectService, type ConnectServiceOptions, type DaemonState, IPC_ERROR_CODES, type IpcErrorCode, type LegacyMachineCandidate, type LegacyMachineRosterClient, type LegacyMachineRosterEntry, type LegacyMachineRosterResult, LegacyMachinesClient, type ListRunnersResult, MIGRATION_DETECTION_KINDS, MIGRATION_FRESH_TRIGGERS, type ManualPathValidation, type MigrationDetection, type MigrationDetectionKind, type MigrationFreshTrigger, type PickerSelection, RUNNER_STATE_VALUES, type RequestMethodMap, type RequestOptions, type ResetRunnerResult, type ResetServiceResult, type RunnerListItem as RunnerInfo, type RunnerListPerServer, type RunnerState, type RunnerStatusResult, SERVICE_STATE_VALUES, STATE_READER_ERROR_CODES, type ServerHealth, type ServerStatusRow, type ServiceClient, ServiceClientError, type ServiceEvent, type ServiceState, type ServiceStatusResult, StateReaderError, type StateReaderErrorCode, UPGRADE_ERROR_CODES, type UpgradeBundle, type UpgradeErrorCode, type UpgradeLogEntry, type UpgradeLogEntryErr, type UpgradeLogEntryOk, type UpgradeStartResult, type UpgradeTrigger, assertUpgradeLogEntry, detectLegacyMigration, isIpcErrorCode, isMigrationDetectionKind, isRunnerState, isServiceState, listRunners, pickMigrationCandidateFromInput, readRunnerStatus, readServiceStatus, validateManualMigratePath };
|
|
679
|
+
export { type ComputerStatusReport, type ConnectService, type ConnectServiceOptions, type DaemonState, IPC_ERROR_CODES, type IpcErrorCode, type LegacyMachineCandidate, type LegacyMachineRosterClient, type LegacyMachineRosterEntry, type LegacyMachineRosterResult, LegacyMachinesClient, type ListRunnersResult, MIGRATION_DETECTION_KINDS, MIGRATION_FRESH_TRIGGERS, type ManualPathValidation, type MigrationDetection, type MigrationDetectionKind, type MigrationFreshTrigger, type PickerSelection, RUNNER_STATE_VALUES, type RequestMethodMap, type RequestOptions, type ResetRunnerResult, type ResetServiceResult, type RunnerListItem as RunnerInfo, type RunnerListPerServer, type RunnerState, type RunnerStatusResult, SERVICE_STATE_VALUES, STATE_READER_ERROR_CODES, type ServerHealth, type ServerStatusRow, ServersClient, type ServiceClient, ServiceClientError, type ServiceEvent, type ServiceState, type ServiceStatusResult, StateReaderError, type StateReaderErrorCode, UPGRADE_ERROR_CODES, type UpgradeBundle, type UpgradeErrorCode, type UpgradeLogEntry, type UpgradeLogEntryErr, type UpgradeLogEntryOk, type UpgradeStartResult, type UpgradeTrigger, type UserServerEntry, type UserServersResult, assertUpgradeLogEntry, detectLegacyMigration, isIpcErrorCode, isMigrationDetectionKind, isRunnerState, isServiceState, listRunners, pickMigrationCandidateFromInput, readRunnerStatus, readServiceStatus, validateManualMigratePath };
|
package/dist/lib/index.js
CHANGED
|
@@ -188,7 +188,51 @@ async function firstReadableOwner(paths) {
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
// src/apiClient.ts
|
|
191
|
-
import { fetch } from "undici";
|
|
191
|
+
import { fetch as fetch2 } from "undici";
|
|
192
|
+
var ServersClient = class {
|
|
193
|
+
constructor(baseUrl, accessToken) {
|
|
194
|
+
this.baseUrl = baseUrl;
|
|
195
|
+
this.accessToken = accessToken;
|
|
196
|
+
}
|
|
197
|
+
url(p) {
|
|
198
|
+
return new URL(p, this.baseUrl).toString();
|
|
199
|
+
}
|
|
200
|
+
async list() {
|
|
201
|
+
let res;
|
|
202
|
+
try {
|
|
203
|
+
res = await fetch2(this.url("/api/servers/"), {
|
|
204
|
+
method: "GET",
|
|
205
|
+
headers: { Authorization: `Bearer ${this.accessToken}` }
|
|
206
|
+
});
|
|
207
|
+
} catch {
|
|
208
|
+
return { status: "error", code: "request_failed" };
|
|
209
|
+
}
|
|
210
|
+
if (res.status === 401) return { status: "auth_required" };
|
|
211
|
+
const body = await res.json().catch(() => null);
|
|
212
|
+
if (res.status === 200 && Array.isArray(body)) {
|
|
213
|
+
const servers = body.map((raw) => {
|
|
214
|
+
if (!raw || typeof raw !== "object") return null;
|
|
215
|
+
const e = raw;
|
|
216
|
+
if (typeof e.id !== "string" || typeof e.slug !== "string" || typeof e.role !== "string") {
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
if (e.role !== "owner" && e.role !== "admin" && e.role !== "member") {
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
return {
|
|
223
|
+
id: e.id,
|
|
224
|
+
name: typeof e.name === "string" ? e.name : e.slug,
|
|
225
|
+
slug: e.slug,
|
|
226
|
+
role: e.role
|
|
227
|
+
};
|
|
228
|
+
}).filter((entry) => entry !== null);
|
|
229
|
+
return { status: "success", servers };
|
|
230
|
+
}
|
|
231
|
+
const errBody = body;
|
|
232
|
+
const code = errBody && typeof errBody.code === "string" ? errBody.code : `http_${res.status}`;
|
|
233
|
+
return { status: "error", code };
|
|
234
|
+
}
|
|
235
|
+
};
|
|
192
236
|
var LegacyMachinesClient = class {
|
|
193
237
|
constructor(baseUrl, accessToken) {
|
|
194
238
|
this.baseUrl = baseUrl;
|
|
@@ -200,7 +244,7 @@ var LegacyMachinesClient = class {
|
|
|
200
244
|
async list(serverSlug) {
|
|
201
245
|
let res;
|
|
202
246
|
try {
|
|
203
|
-
res = await
|
|
247
|
+
res = await fetch2(
|
|
204
248
|
this.url(`/api/computer/legacy-machines?serverSlug=${encodeURIComponent(serverSlug)}`),
|
|
205
249
|
{
|
|
206
250
|
method: "GET",
|
|
@@ -244,7 +288,7 @@ var RunnersClient = class {
|
|
|
244
288
|
return new URL(p, this.baseUrl).toString();
|
|
245
289
|
}
|
|
246
290
|
async list() {
|
|
247
|
-
const res = await
|
|
291
|
+
const res = await fetch2(this.url("/internal/computer/runners"), {
|
|
248
292
|
method: "GET",
|
|
249
293
|
headers: { Authorization: `Bearer ${this.computerApiKey}` }
|
|
250
294
|
});
|
|
@@ -261,7 +305,7 @@ var RunnersClient = class {
|
|
|
261
305
|
return { status: "error", code };
|
|
262
306
|
}
|
|
263
307
|
async stop(agentId) {
|
|
264
|
-
const res = await
|
|
308
|
+
const res = await fetch2(this.url(`/internal/computer/runners/${encodeURIComponent(agentId)}/stop`), {
|
|
265
309
|
method: "POST",
|
|
266
310
|
headers: { Authorization: `Bearer ${this.computerApiKey}`, "Content-Type": "application/json" },
|
|
267
311
|
body: "{}"
|
|
@@ -276,9 +320,9 @@ var RunnersClient = class {
|
|
|
276
320
|
};
|
|
277
321
|
|
|
278
322
|
// src/setup.ts
|
|
279
|
-
import { chmod as
|
|
280
|
-
import { dirname as
|
|
281
|
-
import { fetch as
|
|
323
|
+
import { chmod as chmod5, mkdir as mkdir11, readFile as readFile10, rename as rename4, rm as rm3, writeFile as writeFile10 } from "fs/promises";
|
|
324
|
+
import { dirname as dirname9 } from "path";
|
|
325
|
+
import { fetch as fetch4 } from "undici";
|
|
282
326
|
|
|
283
327
|
// src/serverState.ts
|
|
284
328
|
import { readFile as readFile2, readdir as readdir2, writeFile, mkdir, unlink, access, chmod } from "fs/promises";
|
|
@@ -428,10 +472,13 @@ import { setTimeout as delay } from "timers/promises";
|
|
|
428
472
|
|
|
429
473
|
// src/service.ts
|
|
430
474
|
import { spawn as spawn2 } from "child_process";
|
|
475
|
+
import { createRequire as createRequire2 } from "module";
|
|
431
476
|
|
|
432
477
|
// src/version.ts
|
|
433
478
|
import { createRequire } from "module";
|
|
434
479
|
function readComputerVersion(moduleUrl = import.meta.url) {
|
|
480
|
+
const baked = process.env.SLOCK_COMPUTER_VERSION;
|
|
481
|
+
if (typeof baked === "string" && baked.length > 0) return baked;
|
|
435
482
|
try {
|
|
436
483
|
const require2 = createRequire(moduleUrl);
|
|
437
484
|
const pkg = require2("../package.json");
|
|
@@ -443,8 +490,8 @@ function readComputerVersion(moduleUrl = import.meta.url) {
|
|
|
443
490
|
var COMPUTER_VERSION = readComputerVersion();
|
|
444
491
|
|
|
445
492
|
// src/service.ts
|
|
446
|
-
import { mkdir as
|
|
447
|
-
import { dirname as
|
|
493
|
+
import { mkdir as mkdir10, readFile as readFile9, writeFile as writeFile9, open, rename as rename3 } from "fs/promises";
|
|
494
|
+
import { dirname as dirname8, join as joinPath } from "path";
|
|
448
495
|
import { fileURLToPath } from "url";
|
|
449
496
|
|
|
450
497
|
// src/cleanup.ts
|
|
@@ -541,7 +588,19 @@ async function walkFallback(slockHome, readPidfile, isAlive, clearStale) {
|
|
|
541
588
|
}
|
|
542
589
|
|
|
543
590
|
// src/services/detach.ts
|
|
544
|
-
import { fetch as
|
|
591
|
+
import { fetch as fetch3 } from "undici";
|
|
592
|
+
|
|
593
|
+
// src/upgradeSea.ts
|
|
594
|
+
import { createHash as createHash3 } from "crypto";
|
|
595
|
+
import { chmod as chmod4, mkdir as mkdir9, readFile as readFile8, rename as rename2, rm as rm2, writeFile as writeFile8 } from "fs/promises";
|
|
596
|
+
import { join as join4 } from "path";
|
|
597
|
+
|
|
598
|
+
// src/channel.ts
|
|
599
|
+
import { readFile as readFile7, writeFile as writeFile7, mkdir as mkdir8 } from "fs/promises";
|
|
600
|
+
import { dirname as dirname7 } from "path";
|
|
601
|
+
|
|
602
|
+
// src/service.ts
|
|
603
|
+
var seaRequire = createRequire2(import.meta.url);
|
|
545
604
|
|
|
546
605
|
// src/setup.ts
|
|
547
606
|
var MIGRATION_FRESH_TRIGGERS = [
|
|
@@ -590,10 +649,10 @@ async function pickMigrationCandidateFromInput(candidates, read, write) {
|
|
|
590
649
|
}
|
|
591
650
|
|
|
592
651
|
// src/status.ts
|
|
593
|
-
import { readFile as
|
|
652
|
+
import { readFile as readFile11 } from "fs/promises";
|
|
594
653
|
async function readUserSession(path2) {
|
|
595
654
|
try {
|
|
596
|
-
const parsed = JSON.parse(await
|
|
655
|
+
const parsed = JSON.parse(await readFile11(path2, "utf8"));
|
|
597
656
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
598
657
|
return { state: "present", session: parsed, error: null };
|
|
599
658
|
}
|
|
@@ -746,7 +805,7 @@ function isServiceState(value) {
|
|
|
746
805
|
}
|
|
747
806
|
|
|
748
807
|
// src/upgradeLog.ts
|
|
749
|
-
import { chmod as
|
|
808
|
+
import { chmod as chmod6, mkdir as mkdir12, open as open2 } from "fs/promises";
|
|
750
809
|
var UPGRADE_ERROR_CODES = [
|
|
751
810
|
"UPGRADE_DEPS_CHANGED",
|
|
752
811
|
"UPGRADE_NETWORK_FAILED",
|
|
@@ -796,6 +855,7 @@ export {
|
|
|
796
855
|
RUNNER_STATE_VALUES,
|
|
797
856
|
SERVICE_STATE_VALUES,
|
|
798
857
|
STATE_READER_ERROR_CODES,
|
|
858
|
+
ServersClient,
|
|
799
859
|
ServiceClientError,
|
|
800
860
|
StateReaderError,
|
|
801
861
|
UPGRADE_ERROR_CODES,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slock-ai/computer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.36",
|
|
4
4
|
"description": "Slock Computer — standalone human/local-machine control-plane CLI (login + attach). Distinct from the agent-facing @slock-ai/cli.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -28,11 +28,13 @@
|
|
|
28
28
|
"commander": "^12.1.0",
|
|
29
29
|
"proper-lockfile": "^4.1.2",
|
|
30
30
|
"undici": "^7.24.7",
|
|
31
|
-
"@slock-ai/daemon": "0.57.
|
|
31
|
+
"@slock-ai/daemon": "0.57.6"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/node": "^25.5.0",
|
|
35
35
|
"@types/proper-lockfile": "^4.1.4",
|
|
36
|
+
"esbuild": "^0.25.0",
|
|
37
|
+
"postject": "^1.0.0-alpha.6",
|
|
36
38
|
"tsup": "^8.5.1",
|
|
37
39
|
"tsx": "^4.21.0",
|
|
38
40
|
"typescript": "^5.9.3"
|
|
@@ -42,6 +44,8 @@
|
|
|
42
44
|
"start": "tsx src/index.ts",
|
|
43
45
|
"build:deps": "pnpm --filter @slock-ai/daemon build",
|
|
44
46
|
"build": "pnpm run build:deps && tsup",
|
|
47
|
+
"build:native": "pnpm run build:deps && node scripts/native/build.mjs",
|
|
48
|
+
"manifest:native": "node scripts/native/produce-manifest.mjs",
|
|
45
49
|
"test": "node --import tsx --test --test-force-exit 'src/**/*.test.ts'",
|
|
46
50
|
"typecheck": "tsc --noEmit",
|
|
47
51
|
"lint:boundaries": "node scripts/check-boundaries.mjs",
|