@scp-dev/cli 0.0.0-stage → 0.1.2

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.
@@ -0,0 +1,72 @@
1
+ import {
2
+ spawnDetached
3
+ } from "./chunk-V5I7KEU7.js";
4
+ import "./chunk-KN7WEIE4.js";
5
+ import "./chunk-N3ZROLFA.js";
6
+ import {
7
+ mcpInstall
8
+ } from "./chunk-4DNQFATX.js";
9
+ import {
10
+ RelayUsage,
11
+ startDaemon
12
+ } from "./chunk-7KP6TAJW.js";
13
+ import "./chunk-XWLF7ON2.js";
14
+ import "./chunk-YYSLYVNZ.js";
15
+ import {
16
+ harnessPid,
17
+ relayIdentity
18
+ } from "./chunk-DA3EB2YF.js";
19
+
20
+ // src/mcp.ts
21
+ import { CLI_NAME, validHandle } from "@scp-dev/core";
22
+ import { connectBroker, relayDir } from "@scp-dev/broker";
23
+ import { runRelayMcp } from "@scp-dev/mcp";
24
+ async function relayMcpCommand(values, positionals) {
25
+ if (positionals[0] === "install") {
26
+ if (positionals.length > 1 || values.human || values.channels) throw new RelayUsage(`${CLI_NAME} mcp install takes --harness H and optionally --as NAME`);
27
+ return mcpInstall(values.harness, values.as, (line) => process.stdout.write(`${line}
28
+ `));
29
+ }
30
+ if (positionals.length) throw new RelayUsage(`${CLI_NAME} mcp takes no arguments (did you mean ${CLI_NAME} mcp install?)`);
31
+ if (values.human) throw new RelayUsage("the relay MCP shim is always an agent: --human is not available to it");
32
+ const claim = relayIdentity({
33
+ ...values.as !== void 0 ? { as: values.as } : {},
34
+ ...values.harness !== void 0 ? { harness: values.harness } : {},
35
+ fallbackHarness: "mcp",
36
+ cwd: process.cwd(),
37
+ env: process.env,
38
+ harnessPid: () => harnessPid()
39
+ });
40
+ if (!validHandle(claim.handle)) throw new RelayUsage(`${JSON.stringify(claim.handle)} is not a valid agent handle (me, user and relay are reserved)`);
41
+ const dir = relayDir();
42
+ await runRelayMcp({
43
+ connect: () => connectBroker(dir, () => startDaemon(dir)),
44
+ claim,
45
+ input: process.stdin,
46
+ output: (line) => void process.stdout.write(line),
47
+ env: process.env,
48
+ channels: values.channels === true,
49
+ spawn: (request) => spawnDetached(spawnWords(request), request.cwd ?? claim.cwd),
50
+ log: (line) => void process.stderr.write(`${line}
51
+ `)
52
+ });
53
+ return 0;
54
+ }
55
+ function spawnWords(request) {
56
+ return [
57
+ "--bg",
58
+ "--as",
59
+ request.as,
60
+ ...request.harness !== void 0 ? ["--harness", request.harness] : [],
61
+ ...request.name !== void 0 ? ["--name", request.name] : [],
62
+ ...request.title !== void 0 ? ["--title", request.title] : [],
63
+ ...request.no_push ? ["--no-push"] : [],
64
+ ...request.handback_bytes !== void 0 ? ["--handback-bytes", String(request.handback_bytes)] : [],
65
+ "--",
66
+ ...request.command
67
+ ];
68
+ }
69
+ export {
70
+ relayMcpCommand,
71
+ spawnWords
72
+ };
@@ -0,0 +1,60 @@
1
+ import {
2
+ RelayUsage,
3
+ peekGrant,
4
+ stamp
5
+ } from "./chunk-7KP6TAJW.js";
6
+ import {
7
+ note
8
+ } from "./chunk-DA3EB2YF.js";
9
+
10
+ // src/peek.ts
11
+ import { PREAMBLE, wrapPeek, CLI_NAME } from "@scp-dev/core";
12
+ var TURNS_MAX = 10;
13
+ var LEVELS = /* @__PURE__ */ new Set(["on", "local", "off"]);
14
+ var out = (line = "") => process.stdout.write(`${line}
15
+ `);
16
+ var json = (value) => out(JSON.stringify(value, null, 2));
17
+ function turnsArg(value) {
18
+ if (value === void 0) return void 0;
19
+ const turns = typeof value === "string" && /^\d+$/.test(value) ? Number(value) : Number.NaN;
20
+ if (!(turns >= 1 && turns <= TURNS_MAX)) throw new RelayUsage(`--turns takes a whole number from 1 to ${TURNS_MAX}, not ${JSON.stringify(value)}`);
21
+ return turns;
22
+ }
23
+ async function peekCommand(client, values, positionals) {
24
+ const asJson = values.json === true;
25
+ const [endpoint, extra] = positionals;
26
+ if (extra !== void 0) throw new RelayUsage(`${CLI_NAME} peek takes one address`);
27
+ if (values.who === true) {
28
+ if (values.turns !== void 0 || values.full !== void 0) throw new RelayUsage(`${CLI_NAME} peek --who takes no --turns or --full`);
29
+ const { peeked_by } = await client.request("peek_who", endpoint ? { endpoint } : {});
30
+ if (asJson) json({ peeked_by });
31
+ else if (!peeked_by.length) note(`nobody peeked at ${endpoint ?? "you"}`);
32
+ else for (const seen of peeked_by) out(`${stamp(seen.at)} ${seen.by} (${seen.auth}) ${seen.turns} turn${seen.turns === 1 ? "" : "s"}`);
33
+ return 0;
34
+ }
35
+ if (!endpoint) throw new RelayUsage(`${CLI_NAME} peek takes an address, or --who`);
36
+ const turns = turnsArg(values.turns);
37
+ const result = await client.request("peek", {
38
+ endpoint,
39
+ ...turns !== void 0 ? { turns } : {},
40
+ ...values.full === true ? { full: true } : {}
41
+ });
42
+ if (asJson) json({ preamble: PREAMBLE, ...result });
43
+ else out(`${PREAMBLE}
44
+
45
+ ${wrapPeek(result)}`);
46
+ return 0;
47
+ }
48
+ async function setPeekCommand(client, values, positionals) {
49
+ const [level, endpoint, extra] = positionals;
50
+ if (!level || !LEVELS.has(level) || extra !== void 0) throw new RelayUsage(`${CLI_NAME} set-peek takes on|off [endpoint]`);
51
+ const result = await client.request("peek_set", { level, ...endpoint ? { endpoint } : {} });
52
+ if (values.json === true) json(result);
53
+ else out(`${result.endpoint}: peek ${result.peek ?? "off"}`);
54
+ return 0;
55
+ }
56
+ export {
57
+ peekCommand,
58
+ peekGrant,
59
+ setPeekCommand
60
+ };
@@ -0,0 +1,30 @@
1
+ import {
2
+ DEFAULT_RELAY,
3
+ activeRelay,
4
+ checkRelayUrl,
5
+ configDir,
6
+ loginMain,
7
+ logoutMain,
8
+ readCredentials,
9
+ relayCredential,
10
+ relayVerb,
11
+ removeCredential,
12
+ saveCredential,
13
+ writePrivateJson
14
+ } from "./chunk-4QYUPPGV.js";
15
+ import "./chunk-7KP6TAJW.js";
16
+ import "./chunk-DA3EB2YF.js";
17
+ export {
18
+ DEFAULT_RELAY,
19
+ activeRelay,
20
+ checkRelayUrl,
21
+ configDir,
22
+ loginMain,
23
+ logoutMain,
24
+ readCredentials,
25
+ relayCredential,
26
+ relayVerb,
27
+ removeCredential,
28
+ saveCredential,
29
+ writePrivateJson
30
+ };
@@ -0,0 +1,27 @@
1
+ import {
2
+ CloudRelayClient,
3
+ CloudUsage,
4
+ cloudFilePath,
5
+ cloudMain,
6
+ daemonBridge,
7
+ hostMachine,
8
+ machineName,
9
+ machinesVerb,
10
+ openCloud,
11
+ readCloudFile
12
+ } from "./chunk-6UFMKYPH.js";
13
+ import "./chunk-4QYUPPGV.js";
14
+ import "./chunk-7KP6TAJW.js";
15
+ import "./chunk-DA3EB2YF.js";
16
+ export {
17
+ CloudRelayClient,
18
+ CloudUsage,
19
+ cloudFilePath,
20
+ cloudMain,
21
+ daemonBridge,
22
+ hostMachine,
23
+ machineName,
24
+ machinesVerb,
25
+ openCloud,
26
+ readCloudFile
27
+ };
@@ -0,0 +1,39 @@
1
+ import {
2
+ SETUP_HARNESSES,
3
+ SETUP_HELP,
4
+ agyRules,
5
+ agySettingsFile,
6
+ detectHarnesses,
7
+ manifestFile,
8
+ mcpFile,
9
+ mountArgv,
10
+ mountedEntry,
11
+ parseSetupArgs,
12
+ relaySetup,
13
+ relaySetupCommand,
14
+ verifyMount,
15
+ verifyMusePlugin,
16
+ whichOnPath
17
+ } from "./chunk-N3ZROLFA.js";
18
+ import "./chunk-4DNQFATX.js";
19
+ import "./chunk-7KP6TAJW.js";
20
+ import "./chunk-XWLF7ON2.js";
21
+ import "./chunk-YYSLYVNZ.js";
22
+ import "./chunk-DA3EB2YF.js";
23
+ export {
24
+ SETUP_HARNESSES,
25
+ SETUP_HELP,
26
+ agyRules,
27
+ agySettingsFile,
28
+ detectHarnesses,
29
+ manifestFile,
30
+ mcpFile,
31
+ mountArgv,
32
+ mountedEntry,
33
+ parseSetupArgs,
34
+ relaySetup,
35
+ relaySetupCommand,
36
+ verifyMount,
37
+ verifyMusePlugin,
38
+ whichOnPath
39
+ };
@@ -0,0 +1,74 @@
1
+ import {
2
+ MESSAGING,
3
+ SPAWN_RUNNER,
4
+ STDIN_WAIT_MS,
5
+ agentShell,
6
+ agyNote,
7
+ claudeTranscripts,
8
+ closedStdin,
9
+ codexMount,
10
+ codexOverrideAt,
11
+ codexOverrides,
12
+ codexSkipsGitCheck,
13
+ contributorRefusal,
14
+ harnessArgv,
15
+ harnessOutput,
16
+ harnessStdin,
17
+ programAt,
18
+ repliesOutput,
19
+ resumeArgv,
20
+ runHarness,
21
+ spawnCommand,
22
+ spawnDefaults,
23
+ spawnDetached,
24
+ spawnEnvironment,
25
+ spawnPrompt,
26
+ spawnTitle,
27
+ splitSpawn,
28
+ stderrOutput,
29
+ steerArgv,
30
+ transcriptReplies,
31
+ workerName
32
+ } from "./chunk-V5I7KEU7.js";
33
+ import {
34
+ SPAWN_HELP
35
+ } from "./chunk-KN7WEIE4.js";
36
+ import "./chunk-N3ZROLFA.js";
37
+ import "./chunk-4DNQFATX.js";
38
+ import "./chunk-7KP6TAJW.js";
39
+ import "./chunk-XWLF7ON2.js";
40
+ import "./chunk-YYSLYVNZ.js";
41
+ import "./chunk-DA3EB2YF.js";
42
+ export {
43
+ MESSAGING,
44
+ SPAWN_HELP,
45
+ SPAWN_RUNNER,
46
+ STDIN_WAIT_MS,
47
+ agentShell,
48
+ agyNote,
49
+ claudeTranscripts,
50
+ closedStdin,
51
+ codexMount,
52
+ codexOverrideAt,
53
+ codexOverrides,
54
+ codexSkipsGitCheck,
55
+ contributorRefusal,
56
+ harnessArgv,
57
+ harnessOutput,
58
+ harnessStdin,
59
+ programAt,
60
+ repliesOutput,
61
+ resumeArgv,
62
+ runHarness,
63
+ spawnCommand,
64
+ spawnDefaults,
65
+ spawnDetached,
66
+ spawnEnvironment,
67
+ spawnPrompt,
68
+ spawnTitle,
69
+ splitSpawn,
70
+ stderrOutput,
71
+ steerArgv,
72
+ transcriptReplies,
73
+ workerName
74
+ };
@@ -0,0 +1,37 @@
1
+ import {
2
+ activeRelay,
3
+ relayCredential
4
+ } from "./chunk-4QYUPPGV.js";
5
+ import {
6
+ RelayUsage
7
+ } from "./chunk-7KP6TAJW.js";
8
+ import "./chunk-DA3EB2YF.js";
9
+
10
+ // src/up.ts
11
+ import { CLI_NAME } from "@scp-dev/core";
12
+ async function up(positionals, values, cwd, brokerStatus) {
13
+ if (positionals.length) throw new RelayUsage(`${CLI_NAME} up takes only flags`);
14
+ const out = (line) => process.stdout.write(`${line}
15
+ `);
16
+ const { url } = activeRelay(process.env);
17
+ const headless = values.token !== void 0 || Boolean(process.env.SCP_TOKEN?.trim());
18
+ if (headless || !relayCredential(process.env, url).token) {
19
+ const code = await (await import("./login-JTRUWG6Q.js")).login({
20
+ ...values.token !== void 0 ? { token: values.token } : {},
21
+ ...values.label !== void 0 ? { label: values.label } : {},
22
+ ...values["no-browser"] ? { "no-browser": true } : {}
23
+ });
24
+ if (code !== 0) return code;
25
+ } else out(`already logged in to ${url}`);
26
+ const enabled = await (await import("./remote-3BWFISXJ.js")).cloudMain(["enable"], values.machine !== void 0 ? { machine: values.machine } : {}, brokerStatus);
27
+ if (enabled !== 0) return enabled;
28
+ const setup = (await import("./setup-RDPVGE4H.js")).relaySetupCommand(["--write"], cwd, out);
29
+ if (setup !== 0) return setup;
30
+ const broker = await brokerStatus();
31
+ if (!broker.enabled) out(`the broker that was already running stays local-only until it exits (it stops when idle); the next one links to ${url}`);
32
+ else out(`broker linked to ${broker.url ?? url}${broker.connected ? "" : " (connecting)"}`);
33
+ return 0;
34
+ }
35
+ export {
36
+ up
37
+ };
package/package.json CHANGED
@@ -1,6 +1,40 @@
1
1
  {
2
2
  "name": "@scp-dev/cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.2",
4
+ "description": "The swarm command line tool.",
5
+ "license": "Apache-2.0",
6
+ "homepage": "https://scp.dev",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/scphq/scp.git",
10
+ "directory": "packages/cli"
11
+ },
12
+ "type": "module",
13
+ "bin": {
14
+ "swarm": "./dist/cli.js"
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "engines": {
20
+ "node": ">=22.13"
21
+ },
22
+ "scripts": {
23
+ "build": "tsup",
24
+ "typecheck": "tsc -p ."
25
+ },
26
+ "dependencies": {
27
+ "@scp-dev/core": "0.1.1",
28
+ "@scp-dev/broker": "0.1.1",
29
+ "@scp-dev/hub": "0.1.1",
30
+ "@scp-dev/mcp": "0.1.1",
31
+ "smol-toml": "^1.9.1"
32
+ },
33
+ "devDependencies": {
34
+ "tsup": "^8.5.1"
35
+ },
36
+ "publishConfig": {
37
+ "access": "public",
38
+ "provenance": true
39
+ }
40
+ }