alineo-cli 0.1.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 +195 -0
- package/dist/add-Dv8ui6gU.mjs +47 -0
- package/dist/agent-prompt-DeTX84DU.mjs +17 -0
- package/dist/agents-uXEMlj41.mjs +46 -0
- package/dist/args-BBPtXttx.mjs +8 -0
- package/dist/fork-BSbb54Ba.mjs +89 -0
- package/dist/index.mjs +492 -0
- package/dist/init-BI4f18xk.mjs +162 -0
- package/dist/kill-CTAbMh-H.mjs +35 -0
- package/dist/list-DKxmgyNL.mjs +53 -0
- package/dist/logs-BkVSXK9O.mjs +44 -0
- package/dist/package-DKqFeJxs.mjs +4 -0
- package/dist/prompt-DN_v5l5u.mjs +64 -0
- package/dist/remove-Dsp071zF.mjs +26 -0
- package/dist/sessions-data-BYaLq9wh.mjs +54 -0
- package/dist/spawn-CBsNRaLz.mjs +70 -0
- package/dist/telemetry-D5PF-o_p.mjs +52 -0
- package/dist/tui-mkWqwNZl.mjs +429 -0
- package/package.json +51 -0
- package/pi-extension/alineo.ts +179 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { a as readConfig } from "./index.mjs";
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
import { existsSync, readdirSync } from "fs";
|
|
4
|
+
//#region src/commands/list.ts
|
|
5
|
+
async function list() {
|
|
6
|
+
const dir = (await readConfig()).agentsDir;
|
|
7
|
+
if (!existsSync(dir)) {
|
|
8
|
+
console.log(`No agents dir found at '${dir}'. Run 'alineo add <url>' to add an agent spec.`);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const files = readdirSync(dir).filter((f) => f.endsWith(".json"));
|
|
12
|
+
if (files.length === 0) {
|
|
13
|
+
console.log("No agent specs found. Run 'alineo add <url>' to add one.");
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const cols = [
|
|
17
|
+
20,
|
|
18
|
+
8,
|
|
19
|
+
0
|
|
20
|
+
];
|
|
21
|
+
console.log([
|
|
22
|
+
"NAME",
|
|
23
|
+
"CLI",
|
|
24
|
+
"DESCRIPTION"
|
|
25
|
+
].map((h, i) => cols[i] ? h.padEnd(cols[i]) : h).join(" "));
|
|
26
|
+
console.log("-".repeat(60));
|
|
27
|
+
for (const file of files) try {
|
|
28
|
+
const spec = await Bun.file(join(dir, file)).json();
|
|
29
|
+
const name = (spec.name ?? file.replace(/\.json$/, "")).slice(0, 19);
|
|
30
|
+
const cli = (spec.cli ?? "?").slice(0, 7);
|
|
31
|
+
const desc = spec.description ?? spec.title ?? "";
|
|
32
|
+
console.log([
|
|
33
|
+
name.padEnd(cols[0]),
|
|
34
|
+
cli.padEnd(cols[1]),
|
|
35
|
+
desc
|
|
36
|
+
].join(" "));
|
|
37
|
+
} catch {
|
|
38
|
+
console.log(`${file.replace(/\.json$/, "").padEnd(cols[0])} (unreadable)`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const listCommand = {
|
|
42
|
+
name: "list",
|
|
43
|
+
group: "sdk",
|
|
44
|
+
variants: [{
|
|
45
|
+
usage: "alineo list",
|
|
46
|
+
summary: "List saved agent specs"
|
|
47
|
+
}],
|
|
48
|
+
run: async () => {
|
|
49
|
+
await list();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
//#endregion
|
|
53
|
+
export { listCommand };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { a as readConfig } from "./index.mjs";
|
|
2
|
+
import { Alineo } from "alineo";
|
|
3
|
+
import { SQLiteAdapter } from "@alineo-labs/sqlite";
|
|
4
|
+
//#region src/commands/logs.ts
|
|
5
|
+
async function logs(name, opts = {}) {
|
|
6
|
+
if (!name) throw new Error("Usage: alineo logs <name> [--json]");
|
|
7
|
+
const config = await readConfig();
|
|
8
|
+
const adapter = new SQLiteAdapter(config.adapterPath);
|
|
9
|
+
const session = (await new Alineo({
|
|
10
|
+
baseUrl: config.serverUrl,
|
|
11
|
+
apiKey: config.apiKey,
|
|
12
|
+
adapter,
|
|
13
|
+
useServerProxy: config.useServerProxy
|
|
14
|
+
}).sandboxes.listByName(name))[0];
|
|
15
|
+
if (!session) throw new Error(`No session named '${name}' found in the ledger.`);
|
|
16
|
+
const entries = await adapter.readAll(name, session.sandboxId);
|
|
17
|
+
if (opts.json) {
|
|
18
|
+
console.log(JSON.stringify(entries, null, 2));
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
console.log(`${entries.length} events for '${name}' (${session.sandboxId}):\n`);
|
|
22
|
+
for (const entry of entries) {
|
|
23
|
+
const ts = new Date(entry.ts).toISOString();
|
|
24
|
+
const suffix = entry.error ? ` error=${entry.error}` : "";
|
|
25
|
+
console.log(`${ts} ${entry.event}${suffix}`);
|
|
26
|
+
if (entry.payload !== void 0) {
|
|
27
|
+
const payload = JSON.stringify(entry.payload);
|
|
28
|
+
console.log(` ${payload.length > 200 ? payload.slice(0, 200) + "..." : payload}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const logsCommand = {
|
|
33
|
+
name: "logs",
|
|
34
|
+
group: "agent",
|
|
35
|
+
variants: [{
|
|
36
|
+
usage: "alineo logs <name> [--json]",
|
|
37
|
+
summary: "Print ledger events for a session"
|
|
38
|
+
}],
|
|
39
|
+
run: async (argv) => {
|
|
40
|
+
await logs(argv[0] ?? "", { json: argv.includes("--json") });
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
//#endregion
|
|
44
|
+
export { logsCommand };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { a as readConfig } from "./index.mjs";
|
|
2
|
+
import { t as flag } from "./args-BBPtXttx.mjs";
|
|
3
|
+
import { t as collectReply } from "./agent-prompt-DeTX84DU.mjs";
|
|
4
|
+
import { Agent } from "@alineo-labs/agent";
|
|
5
|
+
import { SQLiteAdapter } from "@alineo-labs/sqlite";
|
|
6
|
+
//#region src/commands/prompt.ts
|
|
7
|
+
/**
|
|
8
|
+
* Addressed by sandbox ID, not session name — names aren't unique (re-running
|
|
9
|
+
* `alineo spawn` on the same spec produces two sandboxes with the same name)
|
|
10
|
+
* and a name-based ledger lookup can hand back a sandbox that died ungracefully
|
|
11
|
+
* (crashed before its `close()` ran, expired via OpenSandbox's own TTL) since
|
|
12
|
+
* nothing ever told the ledger it stopped. `Agent.resume()`'s own `connect()`
|
|
13
|
+
* call is the actual authoritative liveness check — addressing by ID means
|
|
14
|
+
* that's the ONLY check, not a second opinion after an already-stale one.
|
|
15
|
+
*
|
|
16
|
+
* `opts.specPath` lets a caller skip `Agent.resume()`'s own ledger lookup for
|
|
17
|
+
* the spec file entirely — necessary when prompting a sandbox whose
|
|
18
|
+
* `sandbox_created` event lives in a different ledger than this CLI
|
|
19
|
+
* invocation's own (e.g. a child spawned via `alineo fork` from inside
|
|
20
|
+
* another sandbox).
|
|
21
|
+
*/
|
|
22
|
+
async function prompt(sandboxId, message, opts = {}) {
|
|
23
|
+
if (!sandboxId || !message) throw new Error("Usage: alineo prompt <sandbox-id> <message> [--spec <path>] [--timeout SECONDS] [--json]");
|
|
24
|
+
const adapter = new SQLiteAdapter((await readConfig()).adapterPath);
|
|
25
|
+
const agent = await Agent.resume(sandboxId, {
|
|
26
|
+
adapter,
|
|
27
|
+
specPath: opts.specPath
|
|
28
|
+
});
|
|
29
|
+
const collected = await collectReply(agent, message, { inactivityTimeoutMs: opts.timeoutSeconds !== void 0 ? opts.timeoutSeconds * 1e3 : void 0 });
|
|
30
|
+
if (opts.json) {
|
|
31
|
+
console.log(JSON.stringify({
|
|
32
|
+
name: agent.name,
|
|
33
|
+
sandboxId: agent.sandboxId,
|
|
34
|
+
reply: collected.text,
|
|
35
|
+
toolCalls: collected.toolCalls
|
|
36
|
+
}, null, 2));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (collected.text) console.log(collected.text);
|
|
40
|
+
else if (collected.toolCalls.length > 0) {
|
|
41
|
+
const names = collected.toolCalls.map((t) => t.name).join(", ");
|
|
42
|
+
console.log(`[alineo] (no final text — ${collected.toolCalls.length} tool call(s): ${names})`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const promptCommand = {
|
|
46
|
+
name: "prompt",
|
|
47
|
+
group: "agent",
|
|
48
|
+
variants: [{
|
|
49
|
+
usage: "alineo prompt <sandbox-id> <msg>",
|
|
50
|
+
summary: "Send one prompt to a running sandbox, print the reply"
|
|
51
|
+
}],
|
|
52
|
+
run: async (argv) => {
|
|
53
|
+
const sandboxId = argv[0] ?? "";
|
|
54
|
+
const message = argv.slice(1).find((a) => !a.startsWith("--")) ?? "";
|
|
55
|
+
const timeoutFlag = flag(argv, "--timeout");
|
|
56
|
+
await prompt(sandboxId, message, {
|
|
57
|
+
json: argv.includes("--json"),
|
|
58
|
+
specPath: flag(argv, "--spec"),
|
|
59
|
+
timeoutSeconds: timeoutFlag !== void 0 ? Number(timeoutFlag) : void 0
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
//#endregion
|
|
64
|
+
export { promptCommand };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { a as readConfig } from "./index.mjs";
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
import { existsSync } from "fs";
|
|
4
|
+
import { unlink } from "fs/promises";
|
|
5
|
+
//#region src/commands/remove.ts
|
|
6
|
+
async function remove(name) {
|
|
7
|
+
if (!name) throw new Error("Usage: alineo remove <name>");
|
|
8
|
+
const config = await readConfig();
|
|
9
|
+
const dest = join(config.agentsDir, `${name}.json`);
|
|
10
|
+
if (!existsSync(dest)) throw new Error(`No agent spec named '${name}' in '${config.agentsDir}'. Run 'alineo list' to see available specs.`);
|
|
11
|
+
await unlink(dest);
|
|
12
|
+
console.log(`Removed agent spec '${name}'`);
|
|
13
|
+
}
|
|
14
|
+
const removeCommand = {
|
|
15
|
+
name: "remove",
|
|
16
|
+
group: "sdk",
|
|
17
|
+
variants: [{
|
|
18
|
+
usage: "alineo remove <name>",
|
|
19
|
+
summary: "Remove a saved agent spec"
|
|
20
|
+
}],
|
|
21
|
+
run: async (argv) => {
|
|
22
|
+
await remove(argv[0] ?? "");
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { removeCommand };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { a as readConfig } from "./index.mjs";
|
|
2
|
+
import { Alineo, SandboxStatus } from "alineo";
|
|
3
|
+
import { SQLiteAdapter } from "@alineo-labs/sqlite";
|
|
4
|
+
import { ControlClient, SandboxState } from "@alineo-labs/opensandbox";
|
|
5
|
+
//#region src/sessions-data.ts
|
|
6
|
+
/**
|
|
7
|
+
* Data layer shared by `alineo ps` and the TUI dashboard: alineo-tracked running
|
|
8
|
+
* sessions from the ledger, merged with raw OpenSandbox sandboxes the ledger
|
|
9
|
+
* never recorded.
|
|
10
|
+
*
|
|
11
|
+
* The ledger only learns a sandbox stopped when its own `close()` call runs
|
|
12
|
+
* and emits `sandbox_closed` — an ungraceful death (a crash, OpenSandbox's
|
|
13
|
+
* own TTL expiring the container, someone deleting it outside alineo entirely)
|
|
14
|
+
* leaves a "Running" ledger row forever, since nothing ever told it
|
|
15
|
+
* otherwise. Every ledger-"Running" entry is cross-checked here against the
|
|
16
|
+
* live OpenSandbox control plane — the actual source of truth — and dropped
|
|
17
|
+
* if the control plane no longer has it Running.
|
|
18
|
+
*/
|
|
19
|
+
async function getSessions(config) {
|
|
20
|
+
const cfg = config ?? await readConfig();
|
|
21
|
+
const adapter = new SQLiteAdapter(cfg.adapterPath);
|
|
22
|
+
const ledgerRunning = await new Alineo({
|
|
23
|
+
baseUrl: cfg.serverUrl,
|
|
24
|
+
apiKey: cfg.apiKey,
|
|
25
|
+
adapter,
|
|
26
|
+
useServerProxy: cfg.useServerProxy
|
|
27
|
+
}).sandboxes.list({ status: SandboxStatus.Running });
|
|
28
|
+
const control = new ControlClient({
|
|
29
|
+
baseUrl: cfg.serverUrl,
|
|
30
|
+
apiKey: cfg.apiKey
|
|
31
|
+
});
|
|
32
|
+
let liveIds = null;
|
|
33
|
+
try {
|
|
34
|
+
const raw = await control.listSandboxes({ state: SandboxState.Running });
|
|
35
|
+
liveIds = new Set(raw.map((s) => s.id));
|
|
36
|
+
} catch {}
|
|
37
|
+
const tracked = liveIds ? ledgerRunning.filter((s) => liveIds.has(s.sandboxId)) : ledgerRunning;
|
|
38
|
+
const trackedIds = new Set(tracked.map((s) => s.sandboxId));
|
|
39
|
+
return {
|
|
40
|
+
tracked,
|
|
41
|
+
untracked: liveIds ? [...liveIds].filter((id) => !trackedIds.has(id)) : []
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function formatAge(startedAt) {
|
|
45
|
+
const ms = Date.now() - startedAt;
|
|
46
|
+
const mins = Math.floor(ms / 6e4);
|
|
47
|
+
if (mins < 1) return "just now";
|
|
48
|
+
if (mins < 60) return `${mins}m ago`;
|
|
49
|
+
const hours = Math.floor(mins / 60);
|
|
50
|
+
if (hours < 24) return `${hours}h ago`;
|
|
51
|
+
return `${Math.floor(hours / 24)}d ago`;
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { getSessions as n, formatAge as t };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { a as readConfig } from "./index.mjs";
|
|
2
|
+
import { t as flag } from "./args-BBPtXttx.mjs";
|
|
3
|
+
import { t as collectReply } from "./agent-prompt-DeTX84DU.mjs";
|
|
4
|
+
import { Agent } from "@alineo-labs/agent";
|
|
5
|
+
import { SQLiteAdapter } from "@alineo-labs/sqlite";
|
|
6
|
+
//#region src/commands/spawn.ts
|
|
7
|
+
/**
|
|
8
|
+
* Start a brand-new, independent agent sandbox from a spec's own snapshot —
|
|
9
|
+
* unlike `alineo fork`, which forks a running session's *live* sandbox state
|
|
10
|
+
* instead. This is the entry point for a fresh session (e.g. a host-level Pi
|
|
11
|
+
* session starting the master of an RLM run); `fork` is what a running
|
|
12
|
+
* session uses to fan out its own live state into children.
|
|
13
|
+
*/
|
|
14
|
+
async function spawn(specPath, opts = {}) {
|
|
15
|
+
if (!specPath) throw new Error("Usage: alineo spawn <spec> [--prompt <msg>] [--rebuild] [--depth N] [--max N] [--timeout SECONDS] [--run-id ID] [--json]");
|
|
16
|
+
const adapter = new SQLiteAdapter((await readConfig()).adapterPath);
|
|
17
|
+
const agent = await Agent.load(specPath, {
|
|
18
|
+
adapter,
|
|
19
|
+
rebuild: opts.rebuild,
|
|
20
|
+
spawnDepth: opts.depth,
|
|
21
|
+
maxAgents: opts.max,
|
|
22
|
+
runId: opts.runId
|
|
23
|
+
});
|
|
24
|
+
const collected = opts.prompt ? await collectReply(agent, opts.prompt, { inactivityTimeoutMs: opts.timeoutSeconds !== void 0 ? opts.timeoutSeconds * 1e3 : void 0 }) : void 0;
|
|
25
|
+
if (opts.json) {
|
|
26
|
+
console.log(JSON.stringify({
|
|
27
|
+
name: agent.name,
|
|
28
|
+
sandboxId: agent.sandboxId,
|
|
29
|
+
reply: collected?.text,
|
|
30
|
+
toolCalls: collected?.toolCalls
|
|
31
|
+
}, null, 2));
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
console.log(`\n[alineo] session: ${agent.name} sandbox: ${agent.sandboxId}`);
|
|
35
|
+
if (collected) {
|
|
36
|
+
if (collected.text) console.log(`\n${collected.text}`);
|
|
37
|
+
else if (collected.toolCalls.length > 0) {
|
|
38
|
+
const names = collected.toolCalls.map((t) => t.name).join(", ");
|
|
39
|
+
console.log(`\n[alineo] (no final text — ${collected.toolCalls.length} tool call(s): ${names})`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const spawnCommand = {
|
|
44
|
+
name: "spawn",
|
|
45
|
+
group: "agent",
|
|
46
|
+
variants: [{
|
|
47
|
+
usage: "alineo spawn <spec>",
|
|
48
|
+
summary: "Start a fresh agent sandbox, print its name, exit"
|
|
49
|
+
}, {
|
|
50
|
+
usage: "alineo spawn <spec> --prompt <msg>",
|
|
51
|
+
summary: "Start it, send one prompt, print the reply, exit"
|
|
52
|
+
}],
|
|
53
|
+
run: async (argv) => {
|
|
54
|
+
const specPath = argv.find((a) => !a.startsWith("--")) ?? "";
|
|
55
|
+
const depthFlag = flag(argv, "--depth");
|
|
56
|
+
const maxFlag = flag(argv, "--max");
|
|
57
|
+
const timeoutFlag = flag(argv, "--timeout");
|
|
58
|
+
await spawn(specPath, {
|
|
59
|
+
prompt: flag(argv, "--prompt"),
|
|
60
|
+
rebuild: argv.includes("--rebuild"),
|
|
61
|
+
json: argv.includes("--json"),
|
|
62
|
+
depth: depthFlag !== void 0 ? Number(depthFlag) : void 0,
|
|
63
|
+
max: maxFlag !== void 0 ? Number(maxFlag) : void 0,
|
|
64
|
+
timeoutSeconds: timeoutFlag !== void 0 ? Number(timeoutFlag) : void 0,
|
|
65
|
+
runId: flag(argv, "--run-id")
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
//#endregion
|
|
70
|
+
export { spawnCommand };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { n as readTelemetryConfig, r as writeTelemetryConfig, t as envDisabled } from "./index.mjs";
|
|
2
|
+
//#region src/commands/telemetry.ts
|
|
3
|
+
async function telemetry(argv) {
|
|
4
|
+
const sub = argv[0];
|
|
5
|
+
const config = await readTelemetryConfig();
|
|
6
|
+
if (sub === "enable") {
|
|
7
|
+
await writeTelemetryConfig({
|
|
8
|
+
...config,
|
|
9
|
+
enabled: true
|
|
10
|
+
});
|
|
11
|
+
console.log("[alineo] telemetry enabled");
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (sub === "disable") {
|
|
15
|
+
await writeTelemetryConfig({
|
|
16
|
+
...config,
|
|
17
|
+
enabled: false
|
|
18
|
+
});
|
|
19
|
+
console.log("[alineo] telemetry disabled");
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (sub === "status" || !sub) {
|
|
23
|
+
if (envDisabled()) console.log("[alineo] telemetry: disabled (ALINEO_TELEMETRY_DISABLED or DO_NOT_TRACK is set)");
|
|
24
|
+
else console.log(`[alineo] telemetry: ${config.enabled ? "enabled" : "disabled"}`);
|
|
25
|
+
console.log(` anonymous id: ${config.anonymousId}`);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
throw new Error("Usage: alineo telemetry status|enable|disable");
|
|
29
|
+
}
|
|
30
|
+
const telemetryCommand = {
|
|
31
|
+
name: "telemetry",
|
|
32
|
+
group: "sdk",
|
|
33
|
+
variants: [
|
|
34
|
+
{
|
|
35
|
+
usage: "alineo telemetry status",
|
|
36
|
+
summary: "Show whether telemetry is enabled"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
usage: "alineo telemetry enable",
|
|
40
|
+
summary: "Enable anonymous usage telemetry"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
usage: "alineo telemetry disable",
|
|
44
|
+
summary: "Disable anonymous usage telemetry"
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
run: async (argv) => {
|
|
48
|
+
await telemetry(argv);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
//#endregion
|
|
52
|
+
export { telemetryCommand };
|