@elpapi42/pi-fleet-cli 0.2.0 → 0.3.0
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/README.md +7 -1
- package/dist/main.js +72 -50
- package/dist/main.js.map +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -10,6 +10,12 @@ npm install --global @elpapi42/pi-fleet-cli
|
|
|
10
10
|
pif create researcher --cwd "$PWD"
|
|
11
11
|
pif list
|
|
12
12
|
pif status researcher
|
|
13
|
+
|
|
14
|
+
# Pass a session selector directly to Pi
|
|
15
|
+
pif create existing --cwd "$PWD" -- --session /path/to/session.jsonl
|
|
16
|
+
pif create named --cwd "$PWD" -- --session-id my-session
|
|
13
17
|
```
|
|
14
18
|
|
|
15
|
-
|
|
19
|
+
Arguments after `--` pass through to Pi. Pi-fleet adds `--mode rpc` and rejects `--mode` and `--no-session`. Pi owns session lookup, working-directory selection, prompts, and failures.
|
|
20
|
+
|
|
21
|
+
Commands print human-readable output. Use `pif --help` or `pif COMMAND --help` for generated usage. This CLI requires Node.js 22.12 or later. Slice 1 supports Unix-like hosts with ZeroMQ `ipc://` support. It provides `create`, `list`, and `status`. Sending work, event streaming, recovery, retirement, compact, and destroy come in later slices.
|
package/dist/main.js
CHANGED
|
@@ -1,63 +1,85 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { connectPiFleet } from "@elpapi42/pi-fleet-sdk";
|
|
4
|
+
const version = "0.3.0";
|
|
5
|
+
function splitPiArgs(args) {
|
|
6
|
+
const separator = args.indexOf("--");
|
|
7
|
+
if (separator < 0)
|
|
8
|
+
return { pifArgs: args, piArgs: [] };
|
|
9
|
+
return {
|
|
10
|
+
pifArgs: args.slice(0, separator),
|
|
11
|
+
piArgs: args.slice(separator + 1),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function printAgent(id, name, state) {
|
|
15
|
+
console.log(`ID: ${id}`);
|
|
16
|
+
console.log(`Name: ${name}`);
|
|
17
|
+
console.log(`State: ${state}`);
|
|
18
|
+
}
|
|
19
|
+
async function withClient(action) {
|
|
15
20
|
const client = await connectPiFleet();
|
|
16
21
|
try {
|
|
17
|
-
|
|
18
|
-
case "create": {
|
|
19
|
-
const [name, ...remaining] = args.slice(1);
|
|
20
|
-
if (!name)
|
|
21
|
-
throw new Error("Usage: pif create NAME [INSTRUCTIONS] [--cwd PATH] [-- PI_ARGS...]");
|
|
22
|
-
const instructions = remaining[0] && !remaining[0].startsWith("--") ? remaining.shift() : undefined;
|
|
23
|
-
const separator = remaining.indexOf("--");
|
|
24
|
-
const options = separator < 0 ? remaining : remaining.slice(0, separator);
|
|
25
|
-
const piArgs = separator < 0 ? [] : remaining.slice(separator + 1);
|
|
26
|
-
const cwdIndex = options.indexOf("--cwd");
|
|
27
|
-
if (cwdIndex >= 0 && (cwdIndex + 1 >= options.length || options.length !== 2)) {
|
|
28
|
-
throw new Error("Usage: pif create NAME [INSTRUCTIONS] [--cwd PATH] [-- PI_ARGS...]");
|
|
29
|
-
}
|
|
30
|
-
if (cwdIndex < 0 && options.length !== 0)
|
|
31
|
-
throw new Error("Usage: pif create NAME [INSTRUCTIONS] [--cwd PATH] [-- PI_ARGS...]");
|
|
32
|
-
const cwd = cwdIndex < 0 ? process.cwd() : options[cwdIndex + 1];
|
|
33
|
-
const agent = await client.create({ name, instructions, cwd, piArgs });
|
|
34
|
-
console.log(JSON.stringify({ id: agent.id, name: agent.name }));
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
case "status": {
|
|
38
|
-
const name = args[1];
|
|
39
|
-
if (!name || args.length !== 2)
|
|
40
|
-
throw new Error("Usage: pif status NAME");
|
|
41
|
-
console.log(JSON.stringify(await (await client.get(name)).status()));
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
case "list":
|
|
45
|
-
if (args.length !== 1)
|
|
46
|
-
throw new Error("Usage: pif list");
|
|
47
|
-
for (const agent of await client.list())
|
|
48
|
-
console.log(JSON.stringify(agent));
|
|
49
|
-
return;
|
|
50
|
-
default:
|
|
51
|
-
throw new Error(`Unknown command: ${args[0]}`);
|
|
52
|
-
}
|
|
22
|
+
return await action(client);
|
|
53
23
|
}
|
|
54
24
|
finally {
|
|
55
25
|
await client.close();
|
|
56
26
|
}
|
|
57
27
|
}
|
|
28
|
+
function createProgram(piArgs) {
|
|
29
|
+
const program = new Command();
|
|
30
|
+
program
|
|
31
|
+
.name("pif")
|
|
32
|
+
.description("Manage durable, host-local Pi agents")
|
|
33
|
+
.version(version)
|
|
34
|
+
.showSuggestionAfterError()
|
|
35
|
+
.showHelpAfterError();
|
|
36
|
+
program
|
|
37
|
+
.command("create <name> [instructions]")
|
|
38
|
+
.description("Create a durable Pi agent")
|
|
39
|
+
.option("--cwd <path>", "working directory", process.cwd())
|
|
40
|
+
.addHelpText("after", "\nArguments after -- pass through to Pi.")
|
|
41
|
+
.action(async (name, instructions, options) => {
|
|
42
|
+
const agent = await withClient((client) => client.create({ name, instructions, cwd: options.cwd, piArgs }));
|
|
43
|
+
console.log(`Created agent ${agent.name}`);
|
|
44
|
+
printAgent(agent.id, agent.name, "idle");
|
|
45
|
+
});
|
|
46
|
+
program
|
|
47
|
+
.command("status <name>")
|
|
48
|
+
.description("Show an agent's current state")
|
|
49
|
+
.action(async (name) => {
|
|
50
|
+
const status = await withClient(async (client) => (await client.get(name)).status());
|
|
51
|
+
printAgent(status.id, status.name, status.state);
|
|
52
|
+
});
|
|
53
|
+
program
|
|
54
|
+
.command("list")
|
|
55
|
+
.description("List durable Pi agents")
|
|
56
|
+
.action(async () => {
|
|
57
|
+
const agents = await withClient((client) => client.list());
|
|
58
|
+
if (agents.length === 0) {
|
|
59
|
+
console.log("No agents.");
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
console.log("NAME\tID\tSTATE");
|
|
63
|
+
for (const agent of agents)
|
|
64
|
+
console.log(`${agent.name}\t${agent.id}\t${agent.state}`);
|
|
65
|
+
});
|
|
66
|
+
return program;
|
|
67
|
+
}
|
|
68
|
+
async function main(args) {
|
|
69
|
+
const { pifArgs, piArgs } = splitPiArgs(args);
|
|
70
|
+
const program = createProgram(piArgs);
|
|
71
|
+
if (piArgs.length > 0 && pifArgs[0] !== "create") {
|
|
72
|
+
program.error("Arguments after -- are supported only by pif create");
|
|
73
|
+
}
|
|
74
|
+
if (pifArgs.length === 0) {
|
|
75
|
+
program.help();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
await program.parseAsync(["node", "pif", ...pifArgs]);
|
|
79
|
+
}
|
|
58
80
|
void main(process.argv.slice(2)).catch((error) => {
|
|
59
81
|
const message = error instanceof Error ? error.message : String(error);
|
|
60
|
-
|
|
82
|
+
console.error(message);
|
|
61
83
|
process.exitCode = 1;
|
|
62
84
|
});
|
|
63
85
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAEvD,MAAM,OAAO,GAAG,OAAO,CAAA;AAEvB,SAAS,WAAW,CAAC,IAAc;IACjC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACpC,IAAI,SAAS,GAAG,CAAC;QAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,E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EAAE,KAAK,KAAK,CAAC,KAAK,EAAE,CAAC,CAAA;IACvF,CAAC,CAAC,CAAA;IAEJ,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,KAAK,UAAU,IAAI,CAAC,IAAc;IAChC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,WAAW,CAAC,IAAI,CAAC,CAAA;IAC7C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,CAAA;IACrC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE,CAAC;QACjD,OAAO,CAAC,KAAK,CAAC,qDAAqD,CAAC,CAAA;IACtE,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,CAAC,IAAI,EAAE,CAAA;QACd,OAAM;IACR,CAAC;IACD,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,CAAC,CAAA;AACvD,CAAC;AAED,KAAK,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IAC/C,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACtE,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACtB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;AACtB,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elpapi42/pi-fleet-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "CLI for durable, host-local Pi agents",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
|
12
12
|
"engines": {
|
|
13
|
-
"node": ">=22"
|
|
13
|
+
"node": ">=22.12.0"
|
|
14
14
|
},
|
|
15
15
|
"bin": {
|
|
16
16
|
"pif": "./dist/main.js"
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"test": "node --test test/*.test.mjs"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@elpapi42/pi-fleet-sdk": "0.2.
|
|
27
|
+
"@elpapi42/pi-fleet-sdk": "0.2.1",
|
|
28
|
+
"commander": "15.0.0"
|
|
28
29
|
}
|
|
29
30
|
}
|