@tonbo/cli 0.3.0 → 0.3.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.
Files changed (2) hide show
  1. package/dist/bin/tonbo.js +50 -69
  2. package/package.json +1 -1
package/dist/bin/tonbo.js CHANGED
@@ -323,7 +323,7 @@ var TonboApi = class {
323
323
  import { lstat, readFile } from "node:fs/promises";
324
324
  import path from "node:path";
325
325
 
326
- // ../../packages/agent-source-inspector/src/index.ts
326
+ // ../../packages/agent-source-inspector/dist/src/index.js
327
327
  var AGENTS_INSTRUCTIONS_PATH = "AGENTS.md";
328
328
  var PI_SETTINGS_PATH = ".pi/settings.json";
329
329
  var MAX_HARNESS_CONFIG_BYTES = 256 * 1024;
@@ -339,6 +339,8 @@ var supportedExecutionTargets = [
339
339
  { driver: "command", harness: "pi" }
340
340
  ];
341
341
  var AgentSourceInspectionError = class extends Error {
342
+ code;
343
+ path;
342
344
  constructor(code, path6, message, options) {
343
345
  super(message, options);
344
346
  this.code = code;
@@ -351,28 +353,16 @@ function parsePiPackageCount(contents) {
351
353
  try {
352
354
  settings = JSON.parse(contents);
353
355
  } catch (error) {
354
- throw new AgentSourceInspectionError(
355
- "invalid_pi_settings",
356
- PI_SETTINGS_PATH,
357
- `${PI_SETTINGS_PATH} must contain valid JSON.`,
358
- { cause: error }
359
- );
356
+ throw new AgentSourceInspectionError("invalid_pi_settings", PI_SETTINGS_PATH, `${PI_SETTINGS_PATH} must contain valid JSON.`, { cause: error });
360
357
  }
361
358
  if (!settings || typeof settings !== "object" || Array.isArray(settings)) {
362
- throw new AgentSourceInspectionError(
363
- "invalid_pi_settings",
364
- PI_SETTINGS_PATH,
365
- `${PI_SETTINGS_PATH} must contain a JSON object.`
366
- );
359
+ throw new AgentSourceInspectionError("invalid_pi_settings", PI_SETTINGS_PATH, `${PI_SETTINGS_PATH} must contain a JSON object.`);
367
360
  }
368
- if (!("packages" in settings)) return 0;
361
+ if (!("packages" in settings))
362
+ return 0;
369
363
  const packages = settings.packages;
370
364
  if (!Array.isArray(packages)) {
371
- throw new AgentSourceInspectionError(
372
- "invalid_pi_settings",
373
- PI_SETTINGS_PATH,
374
- `${PI_SETTINGS_PATH} packages must be an array.`
375
- );
365
+ throw new AgentSourceInspectionError("invalid_pi_settings", PI_SETTINGS_PATH, `${PI_SETTINGS_PATH} packages must be an array.`);
376
366
  }
377
367
  return packages.length;
378
368
  }
@@ -773,14 +763,15 @@ async function openBrowser(url) {
773
763
  return void await exec("xdg-open", [url]);
774
764
  }
775
765
 
776
- // src/commands.ts
777
- import { DEFAULT_INFERENCE_MODEL as DEFAULT_INFERENCE_MODEL2 } from "@tonbo/agent-source-bundler/inference-default";
778
-
779
- // ../../packages/agent-source-bundler/src/generated/contracts.ts
766
+ // ../../packages/agent-source-bundler/dist/src/generated/contracts.js
767
+ var inferenceDefault = { "model": "claude-sonnet-5" };
780
768
  var sourceBundleContract = { "version": 1, "format": "tar-v1", "key_prefix": "agent-source-bundles", "content_type": "application/vnd.tonbo.source+tar", "max_bytes": 67108864 };
781
769
  var piSessionContract = { "version": 1, "adapter": "pi-jsonl-v3", "format_version": 3, "durable_completion_timeout_seconds": 30, "session_directory": "/sessions", "path_template": "/sessions/{session_id}.jsonl", "preflight_command": ["/usr/local/bin/artifacts", "runtime", "session-preflight"] };
782
770
 
783
- // ../../packages/agent-source-bundler/src/deployment-origin.ts
771
+ // ../../packages/agent-source-bundler/dist/src/inference-default.js
772
+ var DEFAULT_INFERENCE_MODEL = inferenceDefault.model;
773
+
774
+ // ../../packages/agent-source-bundler/dist/src/deployment-origin.js
784
775
  function deploymentOriginLabel(actor) {
785
776
  return actor === "onboarding" ? "Setup guide" : "tonbo deploy";
786
777
  }
@@ -789,7 +780,8 @@ function githubRepositoryUrl(remote) {
789
780
  return null;
790
781
  let path6;
791
782
  const ssh = /^git@github\.com:([^?#]+)$/.exec(remote);
792
- if (ssh) path6 = ssh[1];
783
+ if (ssh)
784
+ path6 = ssh[1];
793
785
  else {
794
786
  try {
795
787
  const url = new URL(remote);
@@ -1268,10 +1260,7 @@ function assertManagedDeploymentSpec(value) {
1268
1260
  }
1269
1261
  }
1270
1262
 
1271
- // src/declaration.ts
1272
- import { DEFAULT_INFERENCE_MODEL } from "@tonbo/agent-source-bundler/inference-default";
1273
-
1274
- // ../../packages/agent-source-bundler/src/native-pi.ts
1263
+ // ../../packages/agent-source-bundler/dist/src/native-pi.js
1275
1264
  import { stringify } from "smol-toml";
1276
1265
  function nativePiDeclaration(model) {
1277
1266
  return {
@@ -1382,7 +1371,7 @@ function buildDeploymentSpec(declaration, source) {
1382
1371
  return spec;
1383
1372
  }
1384
1373
 
1385
- // ../../packages/agent-source-bundler/src/index.ts
1374
+ // ../../packages/agent-source-bundler/dist/src/index.js
1386
1375
  import { createHash as createHash2 } from "node:crypto";
1387
1376
  import { lstat as lstat3, readFile as readFile3, readdir } from "node:fs/promises";
1388
1377
  import path3 from "node:path";
@@ -1405,7 +1394,8 @@ var DEFAULT_IGNORES = [
1405
1394
  var EXACT_NPM_VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
1406
1395
  var GIT_COMMIT = /^[0-9a-f]{40}$/i;
1407
1396
  function packageSource(value, index) {
1408
- if (typeof value === "string") return value;
1397
+ if (typeof value === "string")
1398
+ return value;
1409
1399
  if (value && typeof value === "object" && "source" in value && typeof value.source === "string")
1410
1400
  return value.source;
1411
1401
  throw new Error(`.pi/settings.json packages[${index}] must be a source string or object.`);
@@ -1415,9 +1405,7 @@ async function validatePackageSource(root, source) {
1415
1405
  const specifier = source.slice(4);
1416
1406
  const separator = specifier.lastIndexOf("@");
1417
1407
  if (separator <= 0 || !EXACT_NPM_VERSION.test(specifier.slice(separator + 1))) {
1418
- throw new Error(
1419
- `PI package ${source} must pin an exact npm version, for example npm:my-agent@1.2.3.`
1420
- );
1408
+ throw new Error(`PI package ${source} must pin an exact npm version, for example npm:my-agent@1.2.3.`);
1421
1409
  }
1422
1410
  return;
1423
1411
  }
@@ -1449,9 +1437,7 @@ async function validatePackageSource(root, source) {
1449
1437
  }
1450
1438
  return;
1451
1439
  }
1452
- throw new Error(
1453
- `PI package ${source} must use an exact npm version, a full Git commit, or a agent-local path.`
1454
- );
1440
+ throw new Error(`PI package ${source} must use an exact npm version, a full Git commit, or a agent-local path.`);
1455
1441
  }
1456
1442
  async function validatePiPackages(root) {
1457
1443
  const filename = path3.join(root, ".pi", "settings.json");
@@ -1459,23 +1445,26 @@ async function validatePiPackages(root) {
1459
1445
  try {
1460
1446
  settings = JSON.parse(await readFile3(filename, "utf8"));
1461
1447
  } catch (error) {
1462
- if (error.code === "ENOENT") return;
1448
+ if (error.code === "ENOENT")
1449
+ return;
1463
1450
  throw new Error(`Could not read ${filename} as JSON.`, { cause: error });
1464
1451
  }
1465
- if (!settings || typeof settings !== "object" || !("packages" in settings)) return;
1452
+ if (!settings || typeof settings !== "object" || !("packages" in settings))
1453
+ return;
1466
1454
  const packages = settings.packages;
1467
- if (!Array.isArray(packages)) throw new Error(`${filename} packages must be an array.`);
1468
- await Promise.all(
1469
- packages.map((value, index) => validatePackageSource(root, packageSource(value, index)))
1470
- );
1455
+ if (!Array.isArray(packages))
1456
+ throw new Error(`${filename} packages must be an array.`);
1457
+ await Promise.all(packages.map((value, index) => validatePackageSource(root, packageSource(value, index))));
1471
1458
  }
1472
1459
  async function findDeclarationRoot(start) {
1473
1460
  let candidate = path3.resolve(start);
1474
1461
  for (; ; ) {
1475
1462
  try {
1476
- if ((await lstat3(path3.join(candidate, ".tonbo"))).isFile()) return candidate;
1463
+ if ((await lstat3(path3.join(candidate, ".tonbo"))).isFile())
1464
+ return candidate;
1477
1465
  } catch (error) {
1478
- if (error.code !== "ENOENT") throw error;
1466
+ if (error.code !== "ENOENT")
1467
+ throw error;
1479
1468
  }
1480
1469
  const parent = path3.dirname(candidate);
1481
1470
  if (parent === candidate) {
@@ -1489,7 +1478,8 @@ async function sourceIgnore(root) {
1489
1478
  try {
1490
1479
  matcher.add(await readFile3(path3.join(root, ".tonboignore"), "utf8"));
1491
1480
  } catch (error) {
1492
- if (error.code !== "ENOENT") throw error;
1481
+ if (error.code !== "ENOENT")
1482
+ throw error;
1493
1483
  }
1494
1484
  return matcher;
1495
1485
  }
@@ -1502,11 +1492,10 @@ async function collectFiles(root) {
1502
1492
  for (const entry of entries) {
1503
1493
  const relative = relativeDirectory ? `${relativeDirectory}/${entry.name}` : entry.name;
1504
1494
  const ignored = matcher.ignores(relative + (entry.isDirectory() ? "/" : ""));
1505
- if (ignored) continue;
1495
+ if (ignored)
1496
+ continue;
1506
1497
  if (relative === SESSION_SOURCE_DIRECTORY || relative.startsWith(`${SESSION_SOURCE_DIRECTORY}/`)) {
1507
- throw new Error(
1508
- `Source path ${SESSION_SOURCE_DIRECTORY}/ is reserved for durable PI history. Rename it or exclude it with .tonboignore.`
1509
- );
1498
+ throw new Error(`Source path ${SESSION_SOURCE_DIRECTORY}/ is reserved for durable PI history. Rename it or exclude it with .tonboignore.`);
1510
1499
  }
1511
1500
  const absolute = path3.join(directory, entry.name);
1512
1501
  if (entry.isDirectory()) {
@@ -1515,9 +1504,7 @@ async function collectFiles(root) {
1515
1504
  }
1516
1505
  const metadata = await lstat3(absolute);
1517
1506
  if (!metadata.isFile()) {
1518
- throw new Error(
1519
- `Source path ${relative} is not a regular file. V1 does not follow symlinks or special files.`
1520
- );
1507
+ throw new Error(`Source path ${relative} is not a regular file. V1 does not follow symlinks or special files.`);
1521
1508
  }
1522
1509
  files.push({
1523
1510
  absolute,
@@ -1535,19 +1522,15 @@ async function collectFiles(root) {
1535
1522
  }
1536
1523
  function addEntry(pack, file, contents) {
1537
1524
  return new Promise((resolve, reject) => {
1538
- pack.entry(
1539
- {
1540
- gid: 0,
1541
- mode: file.mode,
1542
- mtime: /* @__PURE__ */ new Date(0),
1543
- name: file.relative,
1544
- size: contents.length,
1545
- type: "file",
1546
- uid: 0
1547
- },
1548
- contents,
1549
- (error) => error ? reject(error) : resolve()
1550
- );
1525
+ pack.entry({
1526
+ gid: 0,
1527
+ mode: file.mode,
1528
+ mtime: /* @__PURE__ */ new Date(0),
1529
+ name: file.relative,
1530
+ size: contents.length,
1531
+ type: "file",
1532
+ uid: 0
1533
+ }, contents, (error) => error ? reject(error) : resolve());
1551
1534
  });
1552
1535
  }
1553
1536
  async function buildSourceBundle(root) {
@@ -1564,9 +1547,7 @@ async function buildSourceBundle(root) {
1564
1547
  pack.on("data", (chunk) => {
1565
1548
  size += chunk.length;
1566
1549
  if (size > MAX_BUNDLE_BYTES) {
1567
- pack.destroy(
1568
- new Error(`Source bundle exceeds ${MAX_BUNDLE_BYTES} bytes after ignore rules.`)
1569
- );
1550
+ pack.destroy(new Error(`Source bundle exceeds ${MAX_BUNDLE_BYTES} bytes after ignore rules.`));
1570
1551
  return;
1571
1552
  }
1572
1553
  chunks.push(chunk);
@@ -1727,7 +1708,7 @@ async function initCommand(deps, options) {
1727
1708
  entry = (await deps.prompt("PI SDK entry file [dist/agent.mjs]: ")).trim();
1728
1709
  }
1729
1710
  entry ||= "dist/agent.mjs";
1730
- let model = options.model?.trim() || existingDeclaration?.inference.model || DEFAULT_INFERENCE_MODEL2;
1711
+ let model = options.model?.trim() || existingDeclaration?.inference.model || DEFAULT_INFERENCE_MODEL;
1731
1712
  let buildCommand = driver === "command" ? options.buildCommand ?? existingDeclaration?.build?.command ?? ["npm", "run", "build"] : void 0;
1732
1713
  let agentPlan = existingDeclaration?.agent ? {
1733
1714
  kind: "existing",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tonbo/cli",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Deploy persistent Agents and manage their Machines from the command line.",
5
5
  "homepage": "https://tonbo.dev",
6
6
  "bugs": {