alineo-cli 0.1.5 → 0.2.1

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.mjs CHANGED
@@ -28,7 +28,7 @@ const commands = [
28
28
  usage: "alineo init",
29
29
  summary: "Start OpenSandbox locally via Docker"
30
30
  }],
31
- run: async (argv) => (await import("./init-BRkdxhkW.mjs")).initCommand.run(argv)
31
+ run: async (argv) => (await import("./init-D6RgxqQQ.mjs")).initCommand.run(argv)
32
32
  },
33
33
  {
34
34
  name: "add",
@@ -67,7 +67,7 @@ const commands = [
67
67
  usage: "alineo spawn <spec> --prompt <msg>",
68
68
  summary: "Start it, send one prompt, print the reply, exit"
69
69
  }],
70
- run: async (argv) => (await import("./spawn-C0URxOO5.mjs")).spawnCommand.run(argv)
70
+ run: async (argv) => (await import("./spawn-Dd8Y0OXB.mjs")).spawnCommand.run(argv)
71
71
  },
72
72
  {
73
73
  name: "prompt",
@@ -76,7 +76,7 @@ const commands = [
76
76
  usage: "alineo prompt <sandbox-id> <msg>",
77
77
  summary: "Send one prompt to a running sandbox, print the reply"
78
78
  }],
79
- run: async (argv) => (await import("./prompt-CK2gcAJs.mjs")).promptCommand.run(argv)
79
+ run: async (argv) => (await import("./prompt-CSu1QDCA.mjs")).promptCommand.run(argv)
80
80
  },
81
81
  {
82
82
  name: "fork",
@@ -87,6 +87,15 @@ const commands = [
87
87
  }],
88
88
  run: async (argv) => (await import("./fork-CAtxcuwS.mjs")).forkCommand.run(argv)
89
89
  },
90
+ {
91
+ name: "steer",
92
+ group: "agent",
93
+ variants: [{
94
+ usage: "alineo steer <sandbox-id> <message>",
95
+ summary: "Redirect a running session — lands at its next turn boundary, not instantly"
96
+ }],
97
+ run: async (argv) => (await import("./steer-BdQ_-sf2.mjs")).steerCommand.run(argv)
98
+ },
90
99
  {
91
100
  name: "agents",
92
101
  group: "agent",
@@ -416,7 +425,7 @@ async function withTelemetry(commandName, argv, run) {
416
425
  errorClass = errorClassOf(err);
417
426
  throw err;
418
427
  } finally {
419
- const { version } = await import("./package-TLM-T8RC.mjs");
428
+ const { version } = await import("./package-OB-YNuQk.mjs");
420
429
  await sendTelemetryEvent({
421
430
  command: commandName,
422
431
  flags,
@@ -441,7 +450,7 @@ async function recordTuiLaunch() {
441
450
  const config = await readTelemetryConfig();
442
451
  if (!config.enabled) return;
443
452
  await maybePrintFirstRunNotice(config);
444
- const { version } = await import("./package-TLM-T8RC.mjs");
453
+ const { version } = await import("./package-OB-YNuQk.mjs");
445
454
  await sendTelemetryEvent({
446
455
  command: "tui",
447
456
  flags: {},
@@ -489,12 +498,12 @@ function printHelp() {
489
498
  async function main() {
490
499
  if (!cmd && process.stdout.isTTY) {
491
500
  await recordTuiLaunch();
492
- const { launchTui } = await import("./tui-BHpM7gtx.mjs");
501
+ const { launchTui } = await import("./tui-C7Vonahr.mjs");
493
502
  await launchTui();
494
503
  return;
495
504
  }
496
505
  if (cmd === "--version" || cmd === "-v" || cmd === "version") {
497
- const { version } = await import("./package-TLM-T8RC.mjs");
506
+ const { version } = await import("./package-OB-YNuQk.mjs");
498
507
  console.log(version);
499
508
  return;
500
509
  }
@@ -0,0 +1,265 @@
1
+ import { c as serverConfigPath, i as configPath, l as serverDataDir, o as serverConfigContent, s as serverConfigDir, u as writeConfig } from "./index.mjs";
2
+ import { existsSync } from "fs";
3
+ import { mkdir } from "fs/promises";
4
+ //#region src/docker.ts
5
+ async function spawn(cmd) {
6
+ let proc;
7
+ try {
8
+ proc = Bun.spawn(cmd, {
9
+ stdout: "pipe",
10
+ stderr: "pipe"
11
+ });
12
+ } catch {
13
+ throw new Error(`'${cmd[0]}' not found — is Docker installed?`);
14
+ }
15
+ const [stdout, stderr, exitCode] = await Promise.all([
16
+ new Response(proc.stdout).text(),
17
+ new Response(proc.stderr).text(),
18
+ proc.exited
19
+ ]);
20
+ return {
21
+ ok: exitCode === 0,
22
+ stdout,
23
+ stderr
24
+ };
25
+ }
26
+ async function checkDocker() {
27
+ const { ok, stderr } = await spawn(["docker", "info"]);
28
+ if (!ok) {
29
+ if (stderr.includes("Cannot connect") || stderr.includes("daemon") || stderr.includes("socket")) throw new Error("Docker daemon is not running. Start Docker and try again.");
30
+ throw new Error("Docker is not available. Install Docker and try again.");
31
+ }
32
+ }
33
+ async function getContainerState(name) {
34
+ const { ok, stdout } = await spawn([
35
+ "docker",
36
+ "inspect",
37
+ name,
38
+ "--format",
39
+ "{{.State.Status}}"
40
+ ]);
41
+ if (!ok) return "missing";
42
+ return stdout.trim() === "running" ? "running" : "stopped";
43
+ }
44
+ async function startContainer(name) {
45
+ const { ok, stderr } = await spawn([
46
+ "docker",
47
+ "start",
48
+ name
49
+ ]);
50
+ if (!ok) throw new Error(`Failed to start container '${name}': ${stderr.trim()}`);
51
+ }
52
+ async function runContainer(args, label = "container") {
53
+ const { ok, stderr } = await spawn([
54
+ "docker",
55
+ "run",
56
+ ...args
57
+ ]);
58
+ if (!ok) throw new Error(`Failed to start ${label}: ${stderr.trim()}`);
59
+ }
60
+ async function pullImage(image) {
61
+ const { ok, stderr } = await spawn([
62
+ "docker",
63
+ "pull",
64
+ image
65
+ ]);
66
+ if (!ok) throw new Error(`Failed to pull '${image}': ${stderr.trim()}`);
67
+ }
68
+ /** Default health predicate: OpenSandbox's `/health` returns `{ status: "healthy" }`. */
69
+ const isOpenSandboxHealthy = (body) => body?.status === "healthy";
70
+ async function pollHealth(url, timeoutMs = 6e4, isHealthy = isOpenSandboxHealthy) {
71
+ const deadline = Date.now() + timeoutMs;
72
+ while (Date.now() < deadline) {
73
+ try {
74
+ const res = await fetch(url);
75
+ if (res.ok && isHealthy(await res.json())) return;
76
+ } catch {}
77
+ await new Promise((r) => setTimeout(r, 1e3));
78
+ }
79
+ throw new Error(`${url} did not become healthy within ${timeoutMs / 1e3}s`);
80
+ }
81
+ //#endregion
82
+ //#region src/pi-model-keys.ts
83
+ /**
84
+ * Model API key env vars Pi's coding-agent runtime resolves providers from — mirrors the
85
+ * `envMap` in earendil-works/pi's `packages/ai/src/env-api-keys.ts` (plus Anthropic's three,
86
+ * handled separately there). An `AgentSpec`'s env map (`{ NVIDIA_API_KEY: "${NVIDIA_API_KEY}" }`,
87
+ * see `packages/agent/src/schema.ts`) is resolved from `process.env` inside whatever process
88
+ * calls `Alineo.load()`/`.spawn()` — for a swarm run through alineod, that's alineod's own
89
+ * container. `alineo init` forwards whichever of these are set in the operator's shell into
90
+ * that container so any Pi-supported model works, not just NVIDIA's free tier.
91
+ *
92
+ * Deliberately excludes ambient/file-based credential mechanisms (AWS IAM role chains,
93
+ * `AWS_PROFILE`, Google Application Default Credentials) — those need a mounted file or
94
+ * assumed-role wiring, not just a passed-through env var. Amazon Bedrock and Google Vertex
95
+ * are not yet supported by `init`'s auto-start for that reason.
96
+ *
97
+ * Keep in sync with pi's `env-api-keys.ts` `envMap` as it adds providers.
98
+ */
99
+ const PI_MODEL_API_KEY_ENV_VARS = [
100
+ "ANTHROPIC_API_KEY",
101
+ "ANTHROPIC_OAUTH_TOKEN",
102
+ "ANTHROPIC_AUTH_TOKEN",
103
+ "OPENAI_API_KEY",
104
+ "AZURE_OPENAI_API_KEY",
105
+ "GEMINI_API_KEY",
106
+ "NVIDIA_API_KEY",
107
+ "DEEPSEEK_API_KEY",
108
+ "MISTRAL_API_KEY",
109
+ "GROQ_API_KEY",
110
+ "CEREBRAS_API_KEY",
111
+ "XAI_API_KEY",
112
+ "OPENROUTER_API_KEY",
113
+ "AI_GATEWAY_API_KEY",
114
+ "CLOUDFLARE_API_KEY",
115
+ "CLOUDFLARE_ACCOUNT_ID",
116
+ "CLOUDFLARE_GATEWAY_ID",
117
+ "RADIUS_API_KEY",
118
+ "OPENCODE_API_KEY",
119
+ "QWEN_TOKEN_PLAN_API_KEY",
120
+ "QWEN_TOKEN_PLAN_CN_API_KEY",
121
+ "MOONSHOT_API_KEY",
122
+ "KIMI_API_KEY",
123
+ "ZAI_API_KEY",
124
+ "ZAI_CODING_CN_API_KEY",
125
+ "MINIMAX_API_KEY",
126
+ "MINIMAX_CN_API_KEY",
127
+ "XIAOMI_API_KEY",
128
+ "XIAOMI_TOKEN_PLAN_CN_API_KEY",
129
+ "XIAOMI_TOKEN_PLAN_AMS_API_KEY",
130
+ "XIAOMI_TOKEN_PLAN_SGP_API_KEY",
131
+ "ANT_LING_API_KEY",
132
+ "HF_TOKEN",
133
+ "FIREWORKS_API_KEY",
134
+ "TOGETHER_API_KEY",
135
+ "BASETEN_API_KEY",
136
+ "COPILOT_GITHUB_TOKEN"
137
+ ];
138
+ //#endregion
139
+ //#region src/commands/init.ts
140
+ const OPENSANDBOX_CONTAINER_NAME = "alineo-opensandbox";
141
+ const SERVER_URL = "http://127.0.0.1:8080";
142
+ const ALINEOD_CONTAINER_NAME = "alineo-alineod";
143
+ const ALINEOD_IMAGE = "ghcr.io/drejt/alineod:latest";
144
+ const ALINEOD_URL = "http://127.0.0.1:4600";
145
+ const isAlineodHealthy = (body) => body?.ok === true;
146
+ async function init() {
147
+ console.log("Checking Docker...");
148
+ await checkDocker();
149
+ const state = await getContainerState(OPENSANDBOX_CONTAINER_NAME);
150
+ if (state === "running") console.log(`OpenSandbox already running at ${SERVER_URL}`);
151
+ else if (state === "stopped") {
152
+ console.log("Restarting OpenSandbox container...");
153
+ await startContainer(OPENSANDBOX_CONTAINER_NAME);
154
+ console.log("Waiting for OpenSandbox to be ready...");
155
+ await pollHealth(`${SERVER_URL}/health`);
156
+ } else {
157
+ await ensureServerConfig();
158
+ await ensureServerDataDir();
159
+ console.log("Starting OpenSandbox in Docker...");
160
+ await runContainer([
161
+ "-d",
162
+ "--name",
163
+ OPENSANDBOX_CONTAINER_NAME,
164
+ "-p",
165
+ "8080:8080",
166
+ "-v",
167
+ "/var/run/docker.sock:/var/run/docker.sock",
168
+ "-v",
169
+ `${serverConfigPath()}:/etc/opensandbox/config.toml:ro`,
170
+ "-v",
171
+ `${serverDataDir()}:/data`,
172
+ "-e",
173
+ "SANDBOX_CONFIG_PATH=/etc/opensandbox/config.toml",
174
+ "-e",
175
+ "OPENSANDBOX_INSECURE_SERVER=YES",
176
+ "opensandbox/server:latest"
177
+ ], "OpenSandbox container");
178
+ console.log("Waiting for OpenSandbox to be ready...");
179
+ await pollHealth(`${SERVER_URL}/health`);
180
+ }
181
+ await ensureAlineod();
182
+ await ensureProjectConfig();
183
+ console.log(`OpenSandbox running at ${SERVER_URL}, alineod running at ${ALINEOD_URL} — ready.`);
184
+ }
185
+ async function ensureAlineod() {
186
+ const state = await getContainerState(ALINEOD_CONTAINER_NAME);
187
+ if (state === "running") {
188
+ console.log(`alineod already running at ${ALINEOD_URL}`);
189
+ return;
190
+ }
191
+ if (state === "stopped") {
192
+ console.log("Restarting alineod container...");
193
+ await startContainer(ALINEOD_CONTAINER_NAME);
194
+ } else {
195
+ console.log(`Pulling ${ALINEOD_IMAGE}...`);
196
+ await pullImage(ALINEOD_IMAGE);
197
+ console.log("Starting alineod in Docker...");
198
+ const foundModelKeys = PI_MODEL_API_KEY_ENV_VARS.filter((name) => process.env[name]);
199
+ const modelKeyArgs = foundModelKeys.flatMap((name) => ["-e", `${name}=${process.env[name]}`]);
200
+ if (foundModelKeys.length > 0) console.log(`Forwarding model key(s): ${foundModelKeys.join(", ")}`);
201
+ else console.log("No known model API key found in the environment — alineod will start, but agent specs referencing a provider key will fail until one is set (see any of the env vars in packages/cli/src/pi-model-keys.ts).");
202
+ await runContainer([
203
+ "-d",
204
+ "--name",
205
+ ALINEOD_CONTAINER_NAME,
206
+ "--network",
207
+ "host",
208
+ "-e",
209
+ `ALINEO_SERVER_URL=${SERVER_URL}`,
210
+ "-e",
211
+ "ALINEO_USE_SERVER_PROXY=true",
212
+ ...modelKeyArgs,
213
+ "-v",
214
+ "alineod-data:/data",
215
+ ALINEOD_IMAGE
216
+ ], "alineod container");
217
+ }
218
+ console.log("Waiting for alineod to be ready...");
219
+ await pollHealth(`${ALINEOD_URL}/health`, 6e4, isAlineodHealthy);
220
+ }
221
+ async function ensureServerConfig() {
222
+ const dir = serverConfigDir();
223
+ if (!existsSync(dir)) await mkdir(dir, { recursive: true });
224
+ const path = serverConfigPath();
225
+ if (!existsSync(path)) await Bun.write(path, serverConfigContent());
226
+ }
227
+ /**
228
+ * Host-side half of the `serverDataDir()` bind mount. `docker run -v` would auto-create
229
+ * a missing host path anyway, but doing it explicitly here matches `ensureServerConfig()`'s
230
+ * pattern and keeps directory creation in one place rather than relying on Docker's
231
+ * legacy-`-v`-specific behavior (unlike `--mount`, which requires the source to pre-exist).
232
+ */
233
+ async function ensureServerDataDir() {
234
+ const dir = serverDataDir();
235
+ if (!existsSync(dir)) await mkdir(dir, { recursive: true });
236
+ }
237
+ async function ensureProjectConfig() {
238
+ if (!existsSync(configPath())) {
239
+ await writeConfig({
240
+ serverUrl: SERVER_URL,
241
+ useServerProxy: true,
242
+ apiKey: "",
243
+ adapterPath: "./.alineo/ledger.db",
244
+ agentsDir: "./agents",
245
+ defaults: { resources: {
246
+ cpu: "1000m",
247
+ memory: "1Gi"
248
+ } }
249
+ });
250
+ console.log("Created alineo.config.json");
251
+ }
252
+ }
253
+ const initCommand = {
254
+ name: "init",
255
+ group: "sdk",
256
+ variants: [{
257
+ usage: "alineo init",
258
+ summary: "Start OpenSandbox and alineod locally via Docker"
259
+ }],
260
+ run: async () => {
261
+ await init();
262
+ }
263
+ };
264
+ //#endregion
265
+ export { initCommand };
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.1.5";
2
+ var version = "0.2.1";
3
3
  //#endregion
4
4
  export { version };
@@ -21,7 +21,8 @@ import { SQLiteAdapter } from "@alineo-labs/sqlite";
21
21
  */
22
22
  async function prompt(sandboxId, message, opts = {}) {
23
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);
24
+ const config = await readConfig();
25
+ const adapter = new SQLiteAdapter(config.adapterPath);
25
26
  const agent = await Alineo.resume(sandboxId, {
26
27
  adapter,
27
28
  specPath: opts.specPath
@@ -13,7 +13,8 @@ import { SQLiteAdapter } from "@alineo-labs/sqlite";
13
13
  */
14
14
  async function spawn(specPath, opts = {}) {
15
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);
16
+ const config = await readConfig();
17
+ const adapter = new SQLiteAdapter(config.adapterPath);
17
18
  const spec = await Bun.file(specPath).json();
18
19
  const agent = await Alineo.load(spec, {
19
20
  adapter,
@@ -0,0 +1,65 @@
1
+ import { a as readConfig } from "./index.mjs";
2
+ import { t as flag } from "./args-BBPtXttx.mjs";
3
+ import { Alineo } from "alineo";
4
+ import { Sandbox } from "@alineo-labs/sandbox";
5
+ import { SQLiteAdapter } from "@alineo-labs/sqlite";
6
+ //#region src/commands/steer.ts
7
+ /**
8
+ * Redirect a running session without restarting it — the agent-facing counterpart to
9
+ * alineod's `POST /agents/:id/steer` (research/swarm-control.md §8), for a session steering
10
+ * a sandbox it doesn't itself own the control plane for (a parent redirecting a child it
11
+ * forked, most commonly).
12
+ *
13
+ * Uses `Alineo.reattach()`, not `Alineo.resume()` — the whole point of steering a child is
14
+ * usually that it's mid-turn; `resume()` would kill its bridge and abort whatever it's doing,
15
+ * exactly what you're trying to avoid. `reattach()` rebinds to the bridge already running
16
+ * there with zero side effects, then a plain ack-only RPC call delivers the message.
17
+ *
18
+ * Addressed by sandbox ID only, same reasoning as `prompt.ts`: names aren't unique and a
19
+ * name-based lookup can hand back a session that died ungracefully. `alineo fork ... --json`
20
+ * already reports back the child's `sandboxId` — that's what a parent passes here.
21
+ *
22
+ * No spec is required — the sandbox's own ledger entry gives us its real name for a readable
23
+ * log line; a bare `{ name, cli: "pi" }` stub is otherwise enough for `reattach()` (env/budget
24
+ * resolution only matters for a fresh bridge start, which this never does). Pass `--spec
25
+ * <path>` only if the child's real spec happens to be on hand locally.
26
+ *
27
+ * Timing: `steer` is delivered after the target's CURRENT turn finishes its tool calls, but
28
+ * before its next LLM call — it does not interrupt a tool call already running (Pi's own RPC
29
+ * semantics, not alineo's). If you need to cut off a child immediately regardless of what
30
+ * it's doing, use `alineo kill <sandbox-id>` instead; steer is for redirecting cleanly, not
31
+ * stopping urgently.
32
+ */
33
+ async function steer(sandboxId, message, opts = {}) {
34
+ if (!sandboxId || !message) throw new Error("Usage: alineo steer <sandbox-id> <message> [--spec <path>]");
35
+ const config = await readConfig();
36
+ const adapter = new SQLiteAdapter(config.adapterPath);
37
+ const displayName = (await new Sandbox({
38
+ baseUrl: config.serverUrl,
39
+ apiKey: config.apiKey,
40
+ adapter,
41
+ useServerProxy: config.useServerProxy
42
+ }).sandboxes.list()).find((s) => s.sandboxId === sandboxId)?.name ?? sandboxId;
43
+ const agent = await Alineo.reattach(sandboxId, {
44
+ adapter,
45
+ ...opts.specPath ? { specPath: opts.specPath } : { spec: {
46
+ name: displayName,
47
+ cli: "pi"
48
+ } }
49
+ });
50
+ await agent.steer(message);
51
+ console.log(`[alineo] steered ${agent.name} (${agent.sandboxId})`);
52
+ }
53
+ const steerCommand = {
54
+ name: "steer",
55
+ group: "agent",
56
+ variants: [{
57
+ usage: "alineo steer <sandbox-id> <message>",
58
+ summary: "Redirect a running session — lands at its next turn boundary, not instantly"
59
+ }],
60
+ run: async (argv) => {
61
+ await steer(argv[0] ?? "", argv.slice(1).find((a) => !a.startsWith("--")) ?? "", { specPath: flag(argv, "--spec") });
62
+ }
63
+ };
64
+ //#endregion
65
+ export { steerCommand };
@@ -154,23 +154,7 @@ function createChatView(renderer, agent, onBack) {
154
154
  case "tool_end":
155
155
  appendLine(`[tool] ${ev.toolName} ${ev.isError ? "failed" : "done"}`);
156
156
  break;
157
- case "extension_error":
158
- appendLine(`[extension error] ${ev.extensionPath}: ${ev.error}`);
159
- break;
160
- case "agent_start":
161
- case "agent_end":
162
- case "tool_update":
163
- case "compaction_start":
164
- case "compaction_end":
165
- case "auto_retry_start":
166
- case "auto_retry_end":
167
- case "message_start":
168
- case "message_update":
169
- case "message_end":
170
- case "turn_start":
171
- case "turn_end":
172
- case "extension_ui":
173
- case "queue_update": break;
157
+ case "extension_error": appendLine(`[extension error] ${ev.extensionPath}: ${ev.error}`);
174
158
  }
175
159
  } catch (err) {
176
160
  appendLine(`[error] ${err instanceof Error ? err.message : String(err)}`);
@@ -294,7 +278,8 @@ function createNewSessionView(renderer, onLaunch, onCancel) {
294
278
  if (!specPath && entry.registryUrl) {
295
279
  const { add } = await import("./add-CmdLjuq_.mjs");
296
280
  await add(entry.registryUrl, { log: (msg) => status.content = msg });
297
- specPath = join((await readConfig()).agentsDir, `${entry.name}.json`);
281
+ const config = await readConfig();
282
+ specPath = join(config.agentsDir, `${entry.name}.json`);
298
283
  }
299
284
  if (!specPath) throw new Error("no spec path resolved");
300
285
  onLaunch(specPath);
@@ -425,10 +410,11 @@ async function launchTui() {
425
410
  const config = await readConfig();
426
411
  const adapter = new SQLiteAdapter(config.adapterPath);
427
412
  try {
428
- mount(createChatView(renderer, await Alineo.resume(session.sandboxId, {
413
+ const agent = await Alineo.resume(session.sandboxId, {
429
414
  adapter,
430
415
  specPath: `${config.agentsDir}/${session.name}.json`
431
- }), () => {
416
+ });
417
+ mount(createChatView(renderer, agent, () => {
432
418
  showDashboard();
433
419
  }));
434
420
  } catch (err) {
@@ -436,10 +422,12 @@ async function launchTui() {
436
422
  }
437
423
  }
438
424
  async function launchNewAgent(specPath) {
439
- const adapter = new SQLiteAdapter((await readConfig()).adapterPath);
425
+ const config = await readConfig();
426
+ const adapter = new SQLiteAdapter(config.adapterPath);
440
427
  try {
441
428
  const spec = await Bun.file(specPath).json();
442
- mount(createChatView(renderer, await Alineo.load(spec, { adapter }), () => {
429
+ const agent = await Alineo.load(spec, { adapter });
430
+ mount(createChatView(renderer, agent, () => {
443
431
  showDashboard();
444
432
  }));
445
433
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alineo-cli",
3
- "version": "0.1.5",
3
+ "version": "0.2.1",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -30,15 +30,15 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@alineo-labs/opensandbox": "0.3.0",
33
- "@alineo-labs/sandbox": "0.4.0",
34
- "@alineo-labs/sqlite": "0.2.1",
33
+ "@alineo-labs/sandbox": "0.4.2",
34
+ "@alineo-labs/sqlite": "0.2.2",
35
35
  "@opentui/core": "^0.4.3",
36
- "alineo": "0.4.0"
36
+ "alineo": "0.5.1"
37
37
  },
38
38
  "devDependencies": {
39
- "@earendil-works/pi-coding-agent": "^0.80.3",
40
- "bun-types": "1.3.14",
41
- "tsdown": "0.22.3",
39
+ "@earendil-works/pi-coding-agent": "^0.85.1",
40
+ "bun-types": "1.4.2",
41
+ "tsdown": "0.23.0",
42
42
  "typescript": "6.0.3"
43
43
  },
44
44
  "pi": {
@@ -85,7 +85,19 @@ nesting-depth or total-descendant budget if it has one.
85
85
  To start a completely independent agent instead (no shared state needed):
86
86
  \`alineo spawn <spec.json> --prompt "<msg>" --json\`. Other commands:
87
87
  \`alineo agents [--json]\` (list running sessions), \`alineo prompt <sandbox-id>
88
- <msg>\` (continue talking to one), \`alineo kill <sandbox-id>\` (stop one).
88
+ <msg>\` (continue talking to one), \`alineo steer <sandbox-id> <msg>\`
89
+ (redirect a child that's already working — see below), \`alineo kill
90
+ <sandbox-id>\` (stop one).
91
+
92
+ Steering a child: \`alineo steer\` delivers your message after the child's
93
+ CURRENT tool call finishes, right before its next decision — it does not
94
+ interrupt work already in progress, so nothing it's mid-way through gets
95
+ corrupted. Write the message for THAT child specifically (what its new
96
+ guidance means given what you asked it to do), not a copy of whatever
97
+ instruction you yourself received — it has its own narrower context, not
98
+ your full picture. If a child needs to stop immediately rather than finish
99
+ and then redirect, use \`alineo kill\` instead; steer is for adjusting
100
+ course, not for an urgent stop.
89
101
 
90
102
  Only reach for forking when a task genuinely splits into independent pieces
91
103
  of real size — for something you can finish yourself in a few tool calls,
@@ -101,19 +113,22 @@ their own sandboxes:
101
113
  alineo spawn <spec.json> --prompt "<msg>" --json
102
114
 
103
115
  Other commands: \`alineo agents [--json]\` (list running sessions), \`alineo
104
- prompt <sandbox-id> <msg>\` (continue talking to one), \`alineo kill
105
- <sandbox-id>\` (stop one). A spawned agent running inside its own sandbox may
106
- itself be able to fork further sub-agents from its own live state via
107
- \`alineo fork\` — that's its own decision to make, not yours to script for it.`;
116
+ prompt <sandbox-id> <msg>\` (continue talking to one), \`alineo steer
117
+ <sandbox-id> <msg>\` (redirect one that's already working — delivered after
118
+ its current tool call finishes, not an interrupt; use \`alineo kill\` instead
119
+ for an immediate stop), \`alineo kill <sandbox-id>\` (stop one). A spawned
120
+ agent running inside its own sandbox may itself be able to fork further
121
+ sub-agents from its own live state via \`alineo fork\` — that's its own
122
+ decision to make, not yours to script for it.`;
108
123
 
109
124
  const DEFAULT_RLM_MINDSET = `
110
125
 
111
126
  ## Your role: RLM orchestrator
112
127
 
113
- Think in terms of decompose, delegate, and collect. When a task is large
114
- enough to genuinely split into independent pieces, prefer forking dedicated
115
- sub-agents over doing everything yourself in one long session — each
116
- sub-agent should get a clear, bounded slice of the work and report back a
128
+ Think in terms of decompose, delegate, redirect, and collect. When a task is
129
+ large enough to genuinely split into independent pieces, prefer forking
130
+ dedicated sub-agents over doing everything yourself in one long session —
131
+ each sub-agent should get a clear, bounded slice of the work and report back a
117
132
  concise result, not its full transcript. Keep your own context focused on
118
133
  decomposition and integration, not on redoing what a child already did. For
119
134
  small or genuinely atomic tasks, just do the work yourself — decomposition
@@ -1,161 +0,0 @@
1
- import { c as serverConfigPath, i as configPath, l as serverDataDir, o as serverConfigContent, s as serverConfigDir, u as writeConfig } from "./index.mjs";
2
- import { existsSync } from "fs";
3
- import { mkdir } from "fs/promises";
4
- //#region src/docker.ts
5
- async function spawn(cmd) {
6
- let proc;
7
- try {
8
- proc = Bun.spawn(cmd, {
9
- stdout: "pipe",
10
- stderr: "pipe"
11
- });
12
- } catch {
13
- throw new Error(`'${cmd[0]}' not found — is Docker installed?`);
14
- }
15
- const [stdout, stderr, exitCode] = await Promise.all([
16
- new Response(proc.stdout).text(),
17
- new Response(proc.stderr).text(),
18
- proc.exited
19
- ]);
20
- return {
21
- ok: exitCode === 0,
22
- stdout,
23
- stderr
24
- };
25
- }
26
- async function checkDocker() {
27
- const { ok, stderr } = await spawn(["docker", "info"]);
28
- if (!ok) {
29
- if (stderr.includes("Cannot connect") || stderr.includes("daemon") || stderr.includes("socket")) throw new Error("Docker daemon is not running. Start Docker and try again.");
30
- throw new Error("Docker is not available. Install Docker and try again.");
31
- }
32
- }
33
- async function getContainerState(name) {
34
- const { ok, stdout } = await spawn([
35
- "docker",
36
- "inspect",
37
- name,
38
- "--format",
39
- "{{.State.Status}}"
40
- ]);
41
- if (!ok) return "missing";
42
- return stdout.trim() === "running" ? "running" : "stopped";
43
- }
44
- async function startContainer(name) {
45
- const { ok, stderr } = await spawn([
46
- "docker",
47
- "start",
48
- name
49
- ]);
50
- if (!ok) throw new Error(`Failed to start container '${name}': ${stderr.trim()}`);
51
- }
52
- async function runContainer(args) {
53
- const { ok, stderr } = await spawn([
54
- "docker",
55
- "run",
56
- ...args
57
- ]);
58
- if (!ok) throw new Error(`Failed to start OpenSandbox container: ${stderr.trim()}`);
59
- }
60
- async function pollHealth(url, timeoutMs = 6e4) {
61
- const deadline = Date.now() + timeoutMs;
62
- while (Date.now() < deadline) {
63
- try {
64
- const res = await fetch(url);
65
- if (res.ok) {
66
- if ((await res.json()).status === "healthy") return;
67
- }
68
- } catch {}
69
- await new Promise((r) => setTimeout(r, 1e3));
70
- }
71
- throw new Error(`OpenSandbox did not become healthy within ${timeoutMs / 1e3}s`);
72
- }
73
- //#endregion
74
- //#region src/commands/init.ts
75
- const CONTAINER_NAME = "alineo-opensandbox";
76
- const SERVER_URL = "http://127.0.0.1:8080";
77
- async function init() {
78
- console.log("Checking Docker...");
79
- await checkDocker();
80
- const state = await getContainerState(CONTAINER_NAME);
81
- if (state === "running") {
82
- console.log(`OpenSandbox already running at ${SERVER_URL}`);
83
- await ensureProjectConfig();
84
- return;
85
- }
86
- if (state === "stopped") {
87
- console.log("Restarting OpenSandbox container...");
88
- await startContainer(CONTAINER_NAME);
89
- } else {
90
- await ensureServerConfig();
91
- await ensureServerDataDir();
92
- console.log("Starting OpenSandbox in Docker...");
93
- await runContainer([
94
- "-d",
95
- "--name",
96
- CONTAINER_NAME,
97
- "-p",
98
- "8080:8080",
99
- "-v",
100
- "/var/run/docker.sock:/var/run/docker.sock",
101
- "-v",
102
- `${serverConfigPath()}:/etc/opensandbox/config.toml:ro`,
103
- "-v",
104
- `${serverDataDir()}:/data`,
105
- "-e",
106
- "SANDBOX_CONFIG_PATH=/etc/opensandbox/config.toml",
107
- "-e",
108
- "OPENSANDBOX_INSECURE_SERVER=YES",
109
- "opensandbox/server:latest"
110
- ]);
111
- }
112
- console.log("Waiting for OpenSandbox to be ready...");
113
- await pollHealth(`${SERVER_URL}/health`);
114
- await ensureProjectConfig();
115
- console.log(`OpenSandbox running at ${SERVER_URL} — ready.`);
116
- }
117
- async function ensureServerConfig() {
118
- const dir = serverConfigDir();
119
- if (!existsSync(dir)) await mkdir(dir, { recursive: true });
120
- const path = serverConfigPath();
121
- if (!existsSync(path)) await Bun.write(path, serverConfigContent());
122
- }
123
- /**
124
- * Host-side half of the `serverDataDir()` bind mount. `docker run -v` would auto-create
125
- * a missing host path anyway, but doing it explicitly here matches `ensureServerConfig()`'s
126
- * pattern and keeps directory creation in one place rather than relying on Docker's
127
- * legacy-`-v`-specific behavior (unlike `--mount`, which requires the source to pre-exist).
128
- */
129
- async function ensureServerDataDir() {
130
- const dir = serverDataDir();
131
- if (!existsSync(dir)) await mkdir(dir, { recursive: true });
132
- }
133
- async function ensureProjectConfig() {
134
- if (!existsSync(configPath())) {
135
- await writeConfig({
136
- serverUrl: SERVER_URL,
137
- useServerProxy: true,
138
- apiKey: "",
139
- adapterPath: "./.alineo/ledger.db",
140
- agentsDir: "./agents",
141
- defaults: { resources: {
142
- cpu: "1000m",
143
- memory: "1Gi"
144
- } }
145
- });
146
- console.log("Created alineo.config.json");
147
- }
148
- }
149
- const initCommand = {
150
- name: "init",
151
- group: "sdk",
152
- variants: [{
153
- usage: "alineo init",
154
- summary: "Start OpenSandbox locally via Docker"
155
- }],
156
- run: async () => {
157
- await init();
158
- }
159
- };
160
- //#endregion
161
- export { initCommand };