alineo-cli 0.4.0 → 0.4.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/README.md CHANGED
@@ -174,7 +174,7 @@ port = 8080
174
174
 
175
175
  [runtime]
176
176
  type = "docker"
177
- execd_image = "opensandbox/execd:v1.0.22"
177
+ execd_image = "opensandbox/execd:release-1.1.1"
178
178
 
179
179
  [docker]
180
180
  network_mode = "bridge"
@@ -1,4 +1,4 @@
1
- import { n as getSessions, t as formatAge } from "./sessions-data-CceSi5Jz.mjs";
1
+ import { n as getSessions, t as formatAge } from "./sessions-data-5DoRAJiJ.mjs";
2
2
  //#region src/commands/agents.ts
3
3
  async function agents(opts = {}) {
4
4
  const { tracked, untracked } = await getSessions();
package/dist/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env bun
2
2
  import { installLoggerFromEnv } from "@alineo-labs/logger";
3
+ import { errorCodeOf } from "@alineo-labs/errors";
3
4
  import { dirname, join, resolve } from "node:path";
4
5
  import { join as join$1 } from "path";
5
6
  import { homedir } from "os";
@@ -54,7 +55,7 @@ const commands = [
54
55
  usage: "alineo list",
55
56
  summary: "List saved agent specs"
56
57
  }],
57
- run: async (argv) => (await import("./list-D0m4Llsl.mjs")).listCommand.run(argv)
58
+ run: async (argv) => (await import("./list-3JgvP7S3.mjs")).listCommand.run(argv)
58
59
  },
59
60
  {
60
61
  name: "remove",
@@ -93,7 +94,7 @@ const commands = [
93
94
  usage: "alineo spawn <parent> <child-spec>",
94
95
  summary: "Spawn a child from a running session's own live sandbox"
95
96
  }],
96
- run: async (argv) => (await import("./spawn-_Q1KNp_T.mjs")).spawnCommand.run(argv)
97
+ run: async (argv) => (await import("./spawn-I360DtxA.mjs")).spawnCommand.run(argv)
97
98
  },
98
99
  {
99
100
  name: "steer",
@@ -102,7 +103,7 @@ const commands = [
102
103
  usage: "alineo steer <sandbox-id> <message>",
103
104
  summary: "Redirect a running session — lands at its next turn boundary, not instantly"
104
105
  }],
105
- run: async (argv) => (await import("./steer-NAX3xw09.mjs")).steerCommand.run(argv)
106
+ run: async (argv) => (await import("./steer-DfVxy4oz.mjs")).steerCommand.run(argv)
106
107
  },
107
108
  {
108
109
  name: "agents",
@@ -111,7 +112,7 @@ const commands = [
111
112
  usage: "alineo agents [--json]",
112
113
  summary: "List running agent sessions"
113
114
  }],
114
- run: async (argv) => (await import("./agents-CC5ZirAu.mjs")).agentsCommand.run(argv)
115
+ run: async (argv) => (await import("./agents-D01yG4rU.mjs")).agentsCommand.run(argv)
115
116
  },
116
117
  {
117
118
  name: "stop",
@@ -120,7 +121,7 @@ const commands = [
120
121
  usage: "alineo stop <sandbox-id>",
121
122
  summary: "Stop a sandbox"
122
123
  }],
123
- run: async (argv) => (await import("./stop-CvyZQHIf.mjs")).stopCommand.run(argv)
124
+ run: async (argv) => (await import("./stop-D139QjDq.mjs")).stopCommand.run(argv)
124
125
  },
125
126
  {
126
127
  name: "logs",
@@ -129,7 +130,7 @@ const commands = [
129
130
  usage: "alineo logs <name> [--json]",
130
131
  summary: "Print ledger events for a session"
131
132
  }],
132
- run: async (argv) => (await import("./logs-CaLt2Ya0.mjs")).logsCommand.run(argv)
133
+ run: async (argv) => (await import("./logs-1y_vBes2.mjs")).logsCommand.run(argv)
133
134
  },
134
135
  {
135
136
  name: "telemetry",
@@ -152,7 +153,20 @@ const commands = [
152
153
  }
153
154
  ];
154
155
  //#endregion
155
- //#region ../schema/dist/agent-spec-iZ9p1pjI.mjs
156
+ //#region src/format-error.ts
157
+ /**
158
+ * The text the CLI prints for a failure.
159
+ *
160
+ * An alineo error can carry a `hint`: the one sentence that says what to do next. The message
161
+ * says what went wrong, so it is printed first and the hint on its own line after it.
162
+ */
163
+ function formatError(err) {
164
+ const message = err instanceof Error ? err.message : String(err);
165
+ const hint = err?.hint;
166
+ return typeof hint === "string" && hint.length > 0 ? `Error: ${message}\nHint: ${hint}` : `Error: ${message}`;
167
+ }
168
+ //#endregion
169
+ //#region ../schema/dist/agent-spec-BiNRKcYr.mjs
156
170
  /**
157
171
  * The two lists every alineo surface derives its names from.
158
172
  *
@@ -176,6 +190,10 @@ const commands = [
176
190
  * (`GET /agents/:id/transcript`, `GET /runs/:id/events`): they were vocabulary in use, just not
177
191
  * written down.
178
192
  *
193
+ * `provider` joined with the `SandboxProvider` interface: the thing a sandbox runs on and is
194
+ * owned by (`sandbox.created` records which one). No event or route is named after it yet; it
195
+ * is registered so the first one is not a surprise.
196
+ *
179
197
  * `memory` and `fact` joined with alineod's memory routes (`GET /agents/:id/memory`,
180
198
  * `POST /agents/:id/facts`): `memory` is an agent's durable working memory, `fact` one item of
181
199
  * its semantic memory.
@@ -184,6 +202,7 @@ const SUBJECTS = [
184
202
  "run",
185
203
  "agent",
186
204
  "sandbox",
205
+ "provider",
187
206
  "session",
188
207
  "turn",
189
208
  "message",
@@ -276,7 +295,13 @@ defineEvent({
276
295
  resourceId: z.string().optional(),
277
296
  teamId: z.string().optional(),
278
297
  /** Set when this session came from `sb.fork()`; absent for a top-level `client.sandbox()`. */
279
- parentSandboxId: z.string().optional()
298
+ parentSandboxId: z.string().optional(),
299
+ /**
300
+ * The sandbox provider that owns `sandboxId`. Absent on rows written before this field
301
+ * existed, and an absent value means `"opensandbox"` (the only provider there was). Readers
302
+ * apply that default; there is no migration.
303
+ */
304
+ provider: z.string().optional()
280
305
  })
281
306
  });
282
307
  defineEvent({
@@ -338,7 +363,15 @@ defineEvent({
338
363
  schema: z.object({
339
364
  exitCode: z.number().int().optional(),
340
365
  stdout: z.string().optional(),
341
- stderr: z.string().optional()
366
+ stderr: z.string().optional(),
367
+ /** How long the command ran, in milliseconds, as the client measured it. */
368
+ durationMs: z.number().int().optional(),
369
+ /** Present and true when a signal ended the command. */
370
+ killed: z.boolean().optional(),
371
+ /** The signal, as the server reported it. Set with `killed`. */
372
+ signal: z.string().optional(),
373
+ /** Present and true when the command was killed after running for `timeoutMs`. */
374
+ timedOut: z.boolean().optional()
342
375
  })
343
376
  });
344
377
  defineEvent({
@@ -399,10 +432,12 @@ defineEvent({
399
432
  type: "agent.checkpointed",
400
433
  durable: true,
401
434
  version: 1,
402
- description: "A turn-level checkpoint (workspace + session-file tarball) was captured and durably stored, after the tarball itself was confirmed written — a snapshot with no event pointing at it is unreachable garbage.",
435
+ description: "A turn-level checkpoint (workspace + session-file tarball) was captured and durably stored, after the tarball itself was confirmed written — a snapshot with no event pointing at it is unreachable garbage. `snapshotRef` is the file on the host. `remoteRef` is the same tarball in object storage and is absent when no store is configured or the upload failed (`uploadError` says why). A checkpoint without `remoteRef` does not survive the loss of the host's disk.",
403
436
  schema: z.object({
404
437
  turn: z.number(),
405
- snapshotRef: z.string()
438
+ snapshotRef: z.string(),
439
+ remoteRef: z.string().optional(),
440
+ uploadError: z.string().optional()
406
441
  })
407
442
  });
408
443
  defineEvent({
@@ -684,7 +719,23 @@ defineEvent({
684
719
  description: "The sandbox exists and the bridge is up — backfills what `agent.spawned` could not know yet.",
685
720
  schema: z.object({
686
721
  agentId: z.string().nullable(),
687
- sandboxId: z.string()
722
+ sandboxId: z.string(),
723
+ /**
724
+ * The sandbox provider that owns `sandboxId`. Absent on events written before this field
725
+ * existed, which all came from OpenSandbox.
726
+ */
727
+ provider: z.string().optional()
728
+ })
729
+ });
730
+ defineEvent({
731
+ type: "agent.restored",
732
+ durable: true,
733
+ version: 1,
734
+ description: "The agent's sandbox was gone, so a fresh one replaced it. `checkpointTurn` is the turn its workspace and session were restored from, or `null` when it had no checkpoint and came back blank. Follows `agent.provisioned`, which carries the new `sandboxId`.",
735
+ schema: z.object({
736
+ agentId: z.string().nullable(),
737
+ oldSandboxId: z.string(),
738
+ checkpointTurn: z.number().int().nullable()
688
739
  })
689
740
  });
690
741
  defineEvent({
@@ -733,7 +784,9 @@ defineEvent({
733
784
  agentId: z.string().nullable(),
734
785
  outcome: z.string(),
735
786
  endedAt: z.number(),
736
- error: z.string().optional()
787
+ error: z.string().optional(),
788
+ /** A stable `ErrorCode` for `error`, when one is known. See `@alineo-labs/errors`. */
789
+ errorCode: z.string().optional()
737
790
  })
738
791
  });
739
792
  defineEvent({
@@ -879,9 +932,27 @@ defineEvent({
879
932
  schema: z.object({
880
933
  agentId: z.string().nullable(),
881
934
  error: z.string(),
935
+ /** A stable `ErrorCode` for `error`, when one is known. See `@alineo-labs/errors`. */
936
+ errorCode: z.string().optional(),
882
937
  consecutiveFailures: z.number().int()
883
938
  })
884
939
  });
940
+ defineEvent({
941
+ type: "agent.turn_retried",
942
+ durable: true,
943
+ version: 1,
944
+ description: "A turn failed with a transient model-provider error (a 429 or a 5xx) and alineod is re-sending it after a backoff. This is not a supervision failure: it does not count toward the circuit breaker. After `maxAttempts` the failure is recorded as `agent.turn_failed`.",
945
+ schema: z.object({
946
+ agentId: z.string().nullable(),
947
+ error: z.string(),
948
+ errorCode: z.string(),
949
+ /** 1-based number of this retry. */
950
+ attempt: z.number().int(),
951
+ maxAttempts: z.number().int(),
952
+ /** The wait before the turn is re-sent, in milliseconds. */
953
+ delayMs: z.number().int()
954
+ })
955
+ });
885
956
  defineEvent({
886
957
  type: "agent.turn_interrupted",
887
958
  durable: true,
@@ -901,7 +972,9 @@ defineEvent({
901
972
  "retries-exhausted",
902
973
  "circuit-tripped"
903
974
  ]),
904
- error: z.string()
975
+ error: z.string(),
976
+ /** A stable `ErrorCode` for `error`, when one is known. See `@alineo-labs/errors`. */
977
+ errorCode: z.string().optional()
905
978
  })
906
979
  });
907
980
  /**
@@ -986,6 +1059,20 @@ const PermissionsSchema = z$1.union([z$1.enum([
986
1059
  "ask",
987
1060
  "readonly"
988
1061
  ]), PermissionPolicySchema]);
1062
+ /** The provider a non-Pi harness runs on. A spec that names another one is wrong. */
1063
+ const NATIVE_PROVIDER = {
1064
+ "claude-code": "anthropic",
1065
+ codex: "openai"
1066
+ };
1067
+ /** The harness id inside `{ id }`, so an error names `cursor` and not `{"id":"cursor"}`. */
1068
+ function harnessIdOf(input) {
1069
+ return typeof input === "object" && input !== null && "id" in input ? input.id : input;
1070
+ }
1071
+ const HarnessIdSchema = z$1.enum([
1072
+ "pi",
1073
+ "claude-code",
1074
+ "codex"
1075
+ ], { error: (issue) => issue.input === void 0 ? "Agent spec must have a 'harness' field. Supported values: pi, claude-code, codex" : `Unsupported harness: '${describeValue(harnessIdOf(issue.input))}'. Supported values: pi, claude-code, codex` });
989
1076
  const nonNegativeIntSpecField = (fieldName) => z$1.number({ error: `Agent spec '${fieldName}' must be a non-negative integer if set` }).int(`Agent spec '${fieldName}' must be a non-negative integer if set`).nonnegative(`Agent spec '${fieldName}' must be a non-negative integer if set`).optional();
990
1077
  z$1.object({
991
1078
  $schema: z$1.string().optional(),
@@ -994,10 +1081,16 @@ z$1.object({
994
1081
  description: z$1.string().optional(),
995
1082
  author: z$1.string().optional(),
996
1083
  categories: z$1.array(z$1.string()).optional(),
997
- harness: z$1.literal("pi", { error: (issue) => issue.input === void 0 ? "Agent spec must have a 'harness' field. Supported values: pi" : `Unsupported harness: '${describeValue(issue.input)}'. Supported values: pi` }),
1084
+ harness: z$1.union([HarnessIdSchema, z$1.object({
1085
+ id: HarnessIdSchema,
1086
+ version: z$1.string().optional()
1087
+ })], { error: (issue) => issue.input === void 0 ? "Agent spec must have a 'harness' field. Supported values: pi, claude-code, codex" : `Unsupported harness: '${describeValue(harnessIdOf(issue.input))}'. Supported values: pi, claude-code, codex` }),
998
1088
  harnessVersion: z$1.string().optional(),
999
1089
  provider: z$1.string().optional(),
1000
- model: z$1.string({ error: (issue) => issue.input === void 0 ? "Agent spec must have a 'model' string — name the model this agent runs on" : "Agent spec 'model' must be a string" }).min(1, "Agent spec must have a 'model' string — name the model this agent runs on"),
1090
+ model: z$1.union([z$1.string().min(1, "Agent spec must have a 'model' string — name the model this agent runs on"), z$1.object({
1091
+ provider: z$1.string().optional(),
1092
+ id: z$1.string().min(1, "Agent spec 'model.id' must name the model this agent runs on")
1093
+ })], { error: (issue) => issue.input === void 0 ? "Agent spec must have a 'model' string — name the model this agent runs on" : "Agent spec 'model' must be a string, or an object with an 'id'" }),
1001
1094
  packages: z$1.array(z$1.string()).optional(),
1002
1095
  env: z$1.record(z$1.string(), z$1.union([z$1.string(), CredentialEnvBindingSchema])).optional(),
1003
1096
  resources: z$1.object({
@@ -1021,7 +1114,28 @@ z$1.object({
1021
1114
  maxRetries: nonNegativeIntSpecField("maxRetries"),
1022
1115
  maxConsecutiveFailures: nonNegativeIntSpecField("maxConsecutiveFailures"),
1023
1116
  checkpoint: z$1.boolean().optional()
1024
- }).loose();
1117
+ }).loose().superRefine((spec, ctx) => {
1118
+ const harnessId = typeof spec.harness === "string" ? spec.harness : spec.harness.id;
1119
+ const nested = typeof spec.harness === "string" ? void 0 : spec.harness.version;
1120
+ if (nested !== void 0 && spec.harnessVersion !== void 0 && nested !== spec.harnessVersion) ctx.addIssue({
1121
+ code: "custom",
1122
+ path: ["harnessVersion"],
1123
+ message: `'harnessVersion' (${spec.harnessVersion}) conflicts with 'harness.version' (${nested}). Set only 'harness.version'.`
1124
+ });
1125
+ const modelProvider = typeof spec.model === "string" ? void 0 : spec.model.provider;
1126
+ if (modelProvider !== void 0 && spec.provider !== void 0 && modelProvider !== spec.provider) ctx.addIssue({
1127
+ code: "custom",
1128
+ path: ["provider"],
1129
+ message: `'provider' (${spec.provider}) conflicts with 'model.provider' (${modelProvider}). Set only 'model.provider'.`
1130
+ });
1131
+ const provider = modelProvider ?? spec.provider;
1132
+ const native = NATIVE_PROVIDER[harnessId];
1133
+ if (native !== void 0 && provider !== void 0 && provider !== native) ctx.addIssue({
1134
+ code: "custom",
1135
+ path: ["model", "provider"],
1136
+ message: `The ${harnessId} harness runs on ${native} models, but the provider is '${provider}'. Remove the provider, or use the pi harness.`
1137
+ });
1138
+ });
1025
1139
  //#endregion
1026
1140
  //#region ../schema/dist/index.mjs
1027
1141
  /**
@@ -1040,6 +1154,12 @@ z$1.object({
1040
1154
  * and use `defineEnv`/`loadConfig` directly.
1041
1155
  */
1042
1156
  const ProjectConfigObject = z.object({
1157
+ /**
1158
+ * Which sandbox provider to run on. Only `"opensandbox"` exists today, and it is what a file
1159
+ * without this key means, so every config written before the key existed keeps working.
1160
+ * `serverUrl`, `apiKey` and `useServerProxy` below are that provider's settings.
1161
+ */
1162
+ provider: z.string().min(1).default("opensandbox"),
1043
1163
  /**
1044
1164
  * 127.0.0.1, not "localhost" — some hosts resolve "localhost" to ::1 first, and OpenSandbox
1045
1165
  * typically only listens on IPv4.
@@ -1351,6 +1471,7 @@ function parseBoolean(raw, name) {
1351
1471
  */
1352
1472
  function projectConfigFromEnv(env) {
1353
1473
  const out = {};
1474
+ if (env.ALINEO_PROVIDER !== void 0) out.provider = env.ALINEO_PROVIDER;
1354
1475
  if (env.ALINEO_SERVER_URL !== void 0) out.serverUrl = env.ALINEO_SERVER_URL;
1355
1476
  if (env.ALINEO_API_KEY !== void 0) out.apiKey = env.ALINEO_API_KEY;
1356
1477
  if (env.ALINEO_USE_SERVER_PROXY !== void 0) out.useServerProxy = parseBoolean(env.ALINEO_USE_SERVER_PROXY, "ALINEO_USE_SERVER_PROXY");
@@ -1555,13 +1676,25 @@ function serverDataDir() {
1555
1676
  return join$1(serverConfigDir(), "opensandbox-data");
1556
1677
  }
1557
1678
  /**
1558
- * v1.0.19 (the previous pin) predates cached bwrap-archive support, so every sandbox logged
1559
- * "bwrap archive not cached for linux/amd64 -- isolation will be unavailable" and isolation
1560
- * sessions (and anything that depends on them, e.g. pause()/resume()) hung indefinitely
1561
- * instead of failing cleanly. OpenSandbox's own docs: >=v1.0.20 has base isolation-session
1562
- * support, >=v1.0.21 is recommended for full functionality -- the "v1.1.0+" the warning
1563
- * message itself suggests does not exist as a published tag. v1.0.22 is the latest.
1679
+ * The execd image the generated server config pins.
1680
+ *
1681
+ * `release-1.1.1`, not `v1.0.22`. Two reasons, both measured:
1682
+ *
1683
+ * - **Newlines.** `v1.0.22` emits one stdout event per line with the newline stripped, so
1684
+ * `ExecResult.stdout` of `echo one; echo two` was `"onetwo"`. From `release-1.1.1` the event
1685
+ * text keeps its newline (`"one\n"`), which is what `ExecHandle` assumes when it joins events.
1686
+ * `tests/contract` fails three exec cases on `v1.0.22` and passes all twenty on `release-1.1.1`.
1687
+ * - **Post-completion delay.** `/command` holds the stream open for 1.00 s after
1688
+ * `execution_complete` on `v1.0.22` and 0.20 s from 1.1.1 (opensandbox-group/OpenSandbox#1277).
1689
+ *
1690
+ * History: v1.0.19 predates cached bwrap-archive support, so every sandbox logged "bwrap archive
1691
+ * not cached for linux/amd64 -- isolation will be unavailable" and isolation sessions (and
1692
+ * anything that depends on them, e.g. pause()/resume()) hung instead of failing cleanly.
1693
+ *
1694
+ * Tags are `v1.0.x` up to v1.0.22 and `release-1.x.y` from 1.1.1. Re-run `tests/contract`
1695
+ * against a server on the new tag before changing this.
1564
1696
  */
1697
+ const EXECD_IMAGE = "opensandbox/execd:release-1.1.1";
1565
1698
  /**
1566
1699
  * Where the OpenSandbox server, running in its own container, reaches the ports it publishes on
1567
1700
  * the host (`[docker].host_ip`). Without it the server falls back to `127.0.0.1` — its own
@@ -1600,7 +1733,7 @@ eip = "${eip}"
1600
1733
 
1601
1734
  [runtime]
1602
1735
  type = "docker"
1603
- execd_image = "opensandbox/execd:v1.0.22"
1736
+ execd_image = "${EXECD_IMAGE}"
1604
1737
 
1605
1738
  [docker]
1606
1739
  network_mode = "bridge"
@@ -1909,6 +2042,7 @@ async function ensureServerDataDir() {
1909
2042
  async function ensureProjectConfig(log) {
1910
2043
  if (!existsSync(configPath())) {
1911
2044
  await writeConfig({
2045
+ provider: "opensandbox",
1912
2046
  serverUrl: SERVER_URL,
1913
2047
  useServerProxy: true,
1914
2048
  apiKey: "",
@@ -2038,23 +2172,36 @@ function extractAllowedFlags(commandName, argv) {
2038
2172
  for (const flagName of allowed) flags[flagName.replace(/^--/, "")] = argv.includes(flagName);
2039
2173
  return flags;
2040
2174
  }
2041
- /** `spawn`/`fork` take a spec file as their first non-flag argv token -- reads just its own
2042
- * `provider` field (a small, closed, non-identifying set like `"nvidia"`/`"google"`) to answer
2043
- * "which providers actually get used." Deliberately not `model` (closer to free text, not needed
2044
- * for that question) and nothing else from the spec. Never throws -- a missing/unreadable spec
2045
- * file must never surface through telemetry into the real command. */
2175
+ /** `start <spec>` and `spawn <parent> <child-spec>` take a spec file as a non-flag argv token --
2176
+ * reads just its own provider (a small, closed, non-identifying set like `"nvidia"`/`"google"`)
2177
+ * to answer "which providers actually get used." Deliberately not `model` itself (closer to free
2178
+ * text, not needed for that question) and nothing else from the spec. Never throws -- a
2179
+ * missing/unreadable spec file must never surface through telemetry into the real command.
2180
+ *
2181
+ * The token is found the way `start.ts` and `spawn.ts` find it: the first non-flag token for
2182
+ * `start`, the first one after the parent for `spawn`. This once keyed off the verbs from before
2183
+ * the rename (`spawn`/`fork`), so `start` sent no provider and `spawn` read the parent id as a
2184
+ * path. */
2046
2185
  async function extractSpecProvider(commandName, argv) {
2047
- if (commandName !== "spawn" && commandName !== "fork") return void 0;
2048
- const specPath = (commandName === "fork" ? argv.slice(1) : argv).find((a) => !a.startsWith("--"));
2186
+ const nonFlag = (a) => !a.startsWith("--");
2187
+ const specPath = commandName === "start" ? argv.find(nonFlag) : commandName === "spawn" ? argv.slice(1).find(nonFlag) : void 0;
2049
2188
  if (!specPath) return void 0;
2050
2189
  try {
2051
2190
  const spec = await Bun.file(specPath).json();
2052
- return typeof spec.provider === "string" ? spec.provider : void 0;
2191
+ const provider = (typeof spec.model === "object" && spec.model !== null ? spec.model.provider : void 0) ?? spec.provider;
2192
+ return typeof provider === "string" ? provider : void 0;
2053
2193
  } catch {
2054
2194
  return;
2055
2195
  }
2056
2196
  }
2197
+ /**
2198
+ * What the telemetry event calls a failure. The stable alineo code when the error carries one
2199
+ * (`EXEC_NOT_READY`), so failures group by cause and survive a class rename or minification.
2200
+ * Otherwise the class name, as before. Never a message: those can hold paths and ids.
2201
+ */
2057
2202
  function errorClassOf(err) {
2203
+ const code = errorCodeOf(err);
2204
+ if (code) return code;
2058
2205
  return err instanceof Error ? err.constructor.name : "UnknownError";
2059
2206
  }
2060
2207
  /**
@@ -2087,7 +2234,7 @@ async function withTelemetry(commandName, argv, run) {
2087
2234
  errorClass = errorClassOf(err);
2088
2235
  throw err;
2089
2236
  } finally {
2090
- const { version } = await import("./package-Bp80ZVLp.mjs");
2237
+ const { version } = await import("./package-D-x3nFQp.mjs");
2091
2238
  await sendTelemetryEvent({
2092
2239
  command: commandName,
2093
2240
  flags,
@@ -2112,7 +2259,7 @@ async function recordTuiLaunch() {
2112
2259
  const config = await readTelemetryConfig();
2113
2260
  if (!config.enabled) return;
2114
2261
  await maybePrintFirstRunNotice(config);
2115
- const { version } = await import("./package-Bp80ZVLp.mjs");
2262
+ const { version } = await import("./package-D-x3nFQp.mjs");
2116
2263
  await sendTelemetryEvent({
2117
2264
  command: "tui",
2118
2265
  flags: {},
@@ -2160,12 +2307,12 @@ function printHelp() {
2160
2307
  async function main() {
2161
2308
  if (!cmd && process.stdout.isTTY) {
2162
2309
  await recordTuiLaunch();
2163
- const { launchTui } = await import("./tui-sV-uyFWI.mjs");
2310
+ const { launchTui } = await import("./tui-LtXuxtba.mjs");
2164
2311
  await launchTui();
2165
2312
  return;
2166
2313
  }
2167
2314
  if (cmd === "--version" || cmd === "-v" || cmd === "version") {
2168
- const { version } = await import("./package-Bp80ZVLp.mjs");
2315
+ const { version } = await import("./package-D-x3nFQp.mjs");
2169
2316
  console.log(version);
2170
2317
  return;
2171
2318
  }
@@ -2179,7 +2326,7 @@ async function main() {
2179
2326
  if (cmd) process.exit(1);
2180
2327
  }
2181
2328
  main().catch((err) => {
2182
- console.error(`Error: ${err instanceof Error ? err.message : String(err)}`);
2329
+ console.error(formatError(err));
2183
2330
  process.exit(1);
2184
2331
  });
2185
2332
  //#endregion
@@ -27,7 +27,7 @@ async function list() {
27
27
  for (const file of files) try {
28
28
  const spec = await Bun.file(join(dir, file)).json();
29
29
  const name = (spec.name ?? file.replace(/\.json$/, "")).slice(0, 19);
30
- const harness = (spec.harness ?? "?").slice(0, 7);
30
+ const harness = ((typeof spec.harness === "object" ? spec.harness.id : spec.harness) ?? "?").slice(0, 7);
31
31
  const desc = spec.description ?? spec.title ?? "";
32
32
  console.log([
33
33
  name.padEnd(cols[0]),
@@ -1,17 +1,12 @@
1
1
  import { i as readConfig } from "./index.mjs";
2
- import { Sandbox } from "@alineo-labs/sandbox";
2
+ import { clientFromConfig } from "@alineo-labs/sandbox";
3
3
  import { SQLiteAdapter } from "@alineo-labs/sqlite";
4
4
  //#region src/commands/logs.ts
5
5
  async function logs(name, opts = {}) {
6
6
  if (!name) throw new Error("Usage: alineo logs <name> [--json]");
7
7
  const config = await readConfig();
8
8
  const adapter = new SQLiteAdapter(config.adapterPath);
9
- const session = (await new Sandbox({
10
- baseUrl: config.serverUrl,
11
- apiKey: config.apiKey,
12
- adapter,
13
- useServerProxy: config.useServerProxy
14
- }).sandboxes.listByName(name))[0];
9
+ const session = (await clientFromConfig(config, { adapter }).sandboxes.listByName(name))[0];
15
10
  if (!session) throw new Error(`No session named '${name}' found in the ledger.`);
16
11
  const entries = await adapter.readAll(name, session.sandboxId);
17
12
  if (opts.json) {
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.4.0";
2
+ var version = "0.4.1";
3
3
  //#endregion
4
4
  export { version };
@@ -1,7 +1,6 @@
1
1
  import { i as readConfig } from "./index.mjs";
2
- import { Sandbox, SandboxStatus } from "@alineo-labs/sandbox";
2
+ import { SandboxStatus, clientFromConfig } from "@alineo-labs/sandbox";
3
3
  import { SQLiteAdapter } from "@alineo-labs/sqlite";
4
- import { ControlClient, SandboxState } from "@alineo-labs/opensandbox";
5
4
  //#region src/sessions-data.ts
6
5
  /**
7
6
  * Data layer shared by `alineo agents` and the TUI dashboard: alineo-tracked running
@@ -19,19 +18,11 @@ import { ControlClient, SandboxState } from "@alineo-labs/opensandbox";
19
18
  async function getSessions(config) {
20
19
  const cfg = config ?? await readConfig();
21
20
  const adapter = new SQLiteAdapter(cfg.adapterPath);
22
- const ledgerRunning = await new Sandbox({
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
- });
21
+ const client = clientFromConfig(cfg, { adapter });
22
+ const ledgerRunning = await client.sandboxes.list({ status: SandboxStatus.Running });
32
23
  let liveIds = null;
33
24
  try {
34
- const raw = await control.listSandboxes({ state: SandboxState.Running });
25
+ const raw = await client.provider.listSandboxes({ state: "running" });
35
26
  liveIds = new Set(raw.map((s) => s.id));
36
27
  } catch {}
37
28
  let tracked = ledgerRunning;
@@ -2,7 +2,7 @@ import { i as readConfig } from "./index.mjs";
2
2
  import { t as flag } from "./args-BBPtXttx.mjs";
3
3
  import { t as collectReply } from "./agent-prompt-DeTX84DU.mjs";
4
4
  import { Alineo } from "alineo";
5
- import { Sandbox, SandboxStatus } from "@alineo-labs/sandbox";
5
+ import { SandboxStatus, clientFromConfig } from "@alineo-labs/sandbox";
6
6
  import { SQLiteAdapter } from "@alineo-labs/sqlite";
7
7
  //#region src/commands/spawn.ts
8
8
  /**
@@ -28,12 +28,7 @@ async function spawn(parent, childSpecPath, opts = {}) {
28
28
  const adapter = new SQLiteAdapter(config.adapterPath);
29
29
  let selfSandboxId = process.env.ALINEO_SANDBOX_ID;
30
30
  if (!selfSandboxId) {
31
- const session = (await new Sandbox({
32
- baseUrl: config.serverUrl,
33
- apiKey: config.apiKey,
34
- adapter,
35
- useServerProxy: config.useServerProxy
36
- }).sandboxes.list({ status: SandboxStatus.Running })).find((s) => s.name === parent);
31
+ const session = (await clientFromConfig(config, { adapter }).sandboxes.list({ status: SandboxStatus.Running })).find((s) => s.name === parent);
37
32
  if (!session) throw new Error(`No running session named '${parent}'. Run 'alineo agents' to see running sessions.`);
38
33
  selfSandboxId = session.sandboxId;
39
34
  }
@@ -1,7 +1,7 @@
1
1
  import { i as readConfig } from "./index.mjs";
2
2
  import { t as flag } from "./args-BBPtXttx.mjs";
3
3
  import { Alineo } from "alineo";
4
- import { Sandbox } from "@alineo-labs/sandbox";
4
+ import { clientFromConfig } from "@alineo-labs/sandbox";
5
5
  import { SQLiteAdapter } from "@alineo-labs/sqlite";
6
6
  //#region src/commands/steer.ts
7
7
  /**
@@ -34,12 +34,7 @@ async function steer(sandboxId, message, opts = {}) {
34
34
  if (!sandboxId || !message) throw new Error("Usage: alineo steer <sandbox-id> <message> [--spec <path>]");
35
35
  const config = await readConfig();
36
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;
37
+ const displayName = (await clientFromConfig(config, { adapter }).sandboxes.list()).find((s) => s.sandboxId === sandboxId)?.name ?? sandboxId;
43
38
  const agent = await Alineo.reattach(sandboxId, {
44
39
  adapter,
45
40
  ...opts.specPath ? { specPath: opts.specPath } : { spec: {
@@ -1,5 +1,5 @@
1
1
  import { i as readConfig } from "./index.mjs";
2
- import { Sandbox } from "@alineo-labs/sandbox";
2
+ import { clientFromConfig } from "@alineo-labs/sandbox";
3
3
  import { SQLiteAdapter } from "@alineo-labs/sqlite";
4
4
  //#region src/commands/stop.ts
5
5
  /**
@@ -12,12 +12,7 @@ async function stop(sandboxId) {
12
12
  if (!sandboxId) throw new Error("Usage: alineo stop <sandbox-id>");
13
13
  const config = await readConfig();
14
14
  const adapter = new SQLiteAdapter(config.adapterPath);
15
- await (await new Sandbox({
16
- baseUrl: config.serverUrl,
17
- apiKey: config.apiKey,
18
- adapter,
19
- useServerProxy: config.useServerProxy
20
- }).connect(sandboxId, sandboxId)).close();
15
+ await (await clientFromConfig(config, { adapter }).connect(sandboxId, sandboxId)).close();
21
16
  console.log(`Stopped sandbox ${sandboxId}`);
22
17
  }
23
18
  const stopCommand = {
@@ -1,9 +1,9 @@
1
1
  import { i as readConfig } from "./index.mjs";
2
- import { n as getSessions, t as formatAge } from "./sessions-data-CceSi5Jz.mjs";
2
+ import { n as getSessions, t as formatAge } from "./sessions-data-5DoRAJiJ.mjs";
3
3
  import { join } from "path";
4
4
  import { existsSync, readdirSync } from "fs";
5
5
  import { Alineo } from "alineo";
6
- import { Sandbox } from "@alineo-labs/sandbox";
6
+ import { clientFromConfig } from "@alineo-labs/sandbox";
7
7
  import { SQLiteAdapter } from "@alineo-labs/sqlite";
8
8
  import { BoxRenderable, InputRenderable, InputRenderableEvents, ScrollBoxRenderable, SelectRenderable, SelectRenderableEvents, TextRenderable, createCliRenderer } from "@opentui/core";
9
9
  //#region src/tui/dashboard.ts
@@ -53,12 +53,7 @@ function createDashboardView(renderer, onOpen, onQuit, onNew, onLogs) {
53
53
  status.content = `stopping ${session.name}...`;
54
54
  try {
55
55
  const config = await readConfig();
56
- await (await new Sandbox({
57
- baseUrl: config.serverUrl,
58
- apiKey: config.apiKey,
59
- adapter: new SQLiteAdapter(config.adapterPath),
60
- useServerProxy: config.useServerProxy
61
- }).connect(session.sandboxId, session.name)).close();
56
+ await (await clientFromConfig(config, { adapter: new SQLiteAdapter(config.adapterPath) }).connect(session.sandboxId, session.name)).close();
62
57
  await refresh();
63
58
  } catch (err) {
64
59
  status.content = `failed to stop '${session.name}': ${err instanceof Error ? err.message : String(err)}`;
@@ -333,12 +328,7 @@ function createLogsView(renderer, session, onBack) {
333
328
  async function load() {
334
329
  const config = await readConfig();
335
330
  const adapter = new SQLiteAdapter(config.adapterPath);
336
- await new Sandbox({
337
- baseUrl: config.serverUrl,
338
- apiKey: config.apiKey,
339
- adapter,
340
- useServerProxy: config.useServerProxy
341
- }).sandboxes.list();
331
+ await clientFromConfig(config, { adapter }).sandboxes.list();
342
332
  for (const child of scroll.getChildren()) scroll.remove(child);
343
333
  const entries = await adapter.readAll(session.name, session.sandboxId);
344
334
  if (entries.length === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alineo-cli",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -29,12 +29,12 @@
29
29
  "test": "bun test"
30
30
  },
31
31
  "dependencies": {
32
+ "@alineo-labs/errors": "0.1.0",
32
33
  "@alineo-labs/logger": "0.1.0",
33
- "@alineo-labs/opensandbox": "0.3.2",
34
- "@alineo-labs/sandbox": "0.5.0",
35
- "@alineo-labs/sqlite": "0.3.0",
36
- "@opentui/core": "^0.4.3",
37
- "alineo": "0.7.0",
34
+ "@alineo-labs/sandbox": "0.6.0",
35
+ "@alineo-labs/sqlite": "0.3.1",
36
+ "@opentui/core": "^0.5.11",
37
+ "alineo": "0.8.0",
38
38
  "zod": "^4.4.3"
39
39
  },
40
40
  "devDependencies": {