@tonbo/cli 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/tonbo.js +174 -36
- package/package.json +7 -7
package/dist/bin/tonbo.js
CHANGED
|
@@ -143,12 +143,12 @@ var TonboApi = class {
|
|
|
143
143
|
});
|
|
144
144
|
if (prepared.status === "upload") {
|
|
145
145
|
if (!prepared.upload_url) throw new Error("Tonbo did not return a source upload URL.");
|
|
146
|
+
if (!prepared.upload_headers || prepared.upload_headers["if-none-match"] !== "*")
|
|
147
|
+
throw new Error("Missing immutable source upload headers.");
|
|
146
148
|
const uploaded = await this.fetcher(prepared.upload_url, {
|
|
149
|
+
redirect: "error",
|
|
147
150
|
method: "PUT",
|
|
148
|
-
headers:
|
|
149
|
-
"content-type": prepared.content_type ?? "application/vnd.tonbo.source+tar",
|
|
150
|
-
"x-upsert": "false"
|
|
151
|
-
},
|
|
151
|
+
headers: prepared.upload_headers,
|
|
152
152
|
body: new Blob([new Uint8Array(bundle.bytes)])
|
|
153
153
|
});
|
|
154
154
|
let uploadError = null;
|
|
@@ -773,6 +773,40 @@ async function openBrowser(url) {
|
|
|
773
773
|
return void await exec("xdg-open", [url]);
|
|
774
774
|
}
|
|
775
775
|
|
|
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
|
|
780
|
+
var sourceBundleContract = { "version": 1, "format": "tar-v1", "key_prefix": "agent-source-bundles", "content_type": "application/vnd.tonbo.source+tar", "max_bytes": 67108864 };
|
|
781
|
+
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
|
+
|
|
783
|
+
// ../../packages/agent-source-bundler/src/deployment-origin.ts
|
|
784
|
+
function deploymentOriginLabel(actor) {
|
|
785
|
+
return actor === "onboarding" ? "Setup guide" : "tonbo deploy";
|
|
786
|
+
}
|
|
787
|
+
function githubRepositoryUrl(remote) {
|
|
788
|
+
if (typeof remote !== "string" || !remote || /\s/.test(remote) || [...remote].some((character) => character.charCodeAt(0) < 32))
|
|
789
|
+
return null;
|
|
790
|
+
let path6;
|
|
791
|
+
const ssh = /^git@github\.com:([^?#]+)$/.exec(remote);
|
|
792
|
+
if (ssh) path6 = ssh[1];
|
|
793
|
+
else {
|
|
794
|
+
try {
|
|
795
|
+
const url = new URL(remote);
|
|
796
|
+
if (url.hostname !== "github.com" || url.port || !["https:", "ssh:"].includes(url.protocol))
|
|
797
|
+
return null;
|
|
798
|
+
path6 = url.pathname.slice(1);
|
|
799
|
+
} catch {
|
|
800
|
+
return null;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
path6 = path6.replace(/\/$/, "").replace(/\.git$/, "");
|
|
804
|
+
const parts = path6.split("/");
|
|
805
|
+
if (parts.length !== 2 || !/^[a-z\d](?:[a-z\d-]{0,38})$/i.test(parts[0]) || !/^[a-z\d._-]{1,100}$/i.test(parts[1]) || [".", ".."].includes(parts[1]))
|
|
806
|
+
return null;
|
|
807
|
+
return `https://github.com/${parts[0]}/${parts[1]}`;
|
|
808
|
+
}
|
|
809
|
+
|
|
776
810
|
// src/commands.ts
|
|
777
811
|
import path4 from "node:path";
|
|
778
812
|
|
|
@@ -1047,32 +1081,12 @@ var deploymentSchema = {
|
|
|
1047
1081
|
}
|
|
1048
1082
|
}
|
|
1049
1083
|
};
|
|
1050
|
-
var sourceBundleContract = {
|
|
1051
|
-
"version": 1,
|
|
1052
|
-
"format": "tar-v1",
|
|
1053
|
-
"bucket": "agent-source-bundles",
|
|
1054
|
-
"content_type": "application/vnd.tonbo.source+tar",
|
|
1055
|
-
"max_bytes": 67108864
|
|
1056
|
-
};
|
|
1057
|
-
var piSessionContract = {
|
|
1058
|
-
"version": 1,
|
|
1059
|
-
"adapter": "pi-jsonl-v3",
|
|
1060
|
-
"format_version": 3,
|
|
1061
|
-
"durable_completion_timeout_seconds": 30,
|
|
1062
|
-
"session_directory": "/sessions",
|
|
1063
|
-
"path_template": "/sessions/{session_id}.jsonl",
|
|
1064
|
-
"preflight_command": [
|
|
1065
|
-
"/usr/local/bin/artifacts",
|
|
1066
|
-
"runtime",
|
|
1067
|
-
"session-preflight"
|
|
1068
|
-
]
|
|
1069
|
-
};
|
|
1070
1084
|
var agentNameContract = {
|
|
1071
1085
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
1072
1086
|
"$id": "https://contracts.tonbo.dev/agents/agent-name-v1.json",
|
|
1073
1087
|
"x-tonbo-version": 1,
|
|
1074
1088
|
"x-tonbo-public-hostname-apex": "tonbo.sh",
|
|
1075
|
-
"x-tonbo-public-hostname-template": "<agent>-<organization>.tonbo.sh",
|
|
1089
|
+
"x-tonbo-public-hostname-template": "<agent>-<organization>-<word>-<word>.tonbo.sh",
|
|
1076
1090
|
"$defs": {
|
|
1077
1091
|
"name": {
|
|
1078
1092
|
"type": "string",
|
|
@@ -1111,6 +1125,116 @@ var agentNameContract = {
|
|
|
1111
1125
|
"www.tonbo.sh"
|
|
1112
1126
|
]
|
|
1113
1127
|
}
|
|
1128
|
+
},
|
|
1129
|
+
"hostnameWord": {
|
|
1130
|
+
"type": "string",
|
|
1131
|
+
"enum": [
|
|
1132
|
+
"arch",
|
|
1133
|
+
"bark",
|
|
1134
|
+
"beam",
|
|
1135
|
+
"bell",
|
|
1136
|
+
"bird",
|
|
1137
|
+
"blue",
|
|
1138
|
+
"boat",
|
|
1139
|
+
"bold",
|
|
1140
|
+
"book",
|
|
1141
|
+
"calm",
|
|
1142
|
+
"cave",
|
|
1143
|
+
"clay",
|
|
1144
|
+
"coal",
|
|
1145
|
+
"cool",
|
|
1146
|
+
"cove",
|
|
1147
|
+
"dawn",
|
|
1148
|
+
"deer",
|
|
1149
|
+
"dove",
|
|
1150
|
+
"dune",
|
|
1151
|
+
"dusk",
|
|
1152
|
+
"echo",
|
|
1153
|
+
"fern",
|
|
1154
|
+
"fire",
|
|
1155
|
+
"flax",
|
|
1156
|
+
"flow",
|
|
1157
|
+
"foam",
|
|
1158
|
+
"fawn",
|
|
1159
|
+
"frog",
|
|
1160
|
+
"gate",
|
|
1161
|
+
"glow",
|
|
1162
|
+
"gold",
|
|
1163
|
+
"gray",
|
|
1164
|
+
"gulf",
|
|
1165
|
+
"hail",
|
|
1166
|
+
"halo",
|
|
1167
|
+
"hare",
|
|
1168
|
+
"hawk",
|
|
1169
|
+
"hill",
|
|
1170
|
+
"iris",
|
|
1171
|
+
"jade",
|
|
1172
|
+
"kite",
|
|
1173
|
+
"lake",
|
|
1174
|
+
"lamb",
|
|
1175
|
+
"leaf",
|
|
1176
|
+
"lime",
|
|
1177
|
+
"lion",
|
|
1178
|
+
"lobe",
|
|
1179
|
+
"loft",
|
|
1180
|
+
"loom",
|
|
1181
|
+
"luma",
|
|
1182
|
+
"lynx",
|
|
1183
|
+
"mint",
|
|
1184
|
+
"mist",
|
|
1185
|
+
"moon",
|
|
1186
|
+
"moss",
|
|
1187
|
+
"navy",
|
|
1188
|
+
"nest",
|
|
1189
|
+
"nova",
|
|
1190
|
+
"oak",
|
|
1191
|
+
"ocean",
|
|
1192
|
+
"onyx",
|
|
1193
|
+
"opal",
|
|
1194
|
+
"otter",
|
|
1195
|
+
"palm",
|
|
1196
|
+
"peak",
|
|
1197
|
+
"pine",
|
|
1198
|
+
"pond",
|
|
1199
|
+
"pool",
|
|
1200
|
+
"rain",
|
|
1201
|
+
"reed",
|
|
1202
|
+
"reef",
|
|
1203
|
+
"rice",
|
|
1204
|
+
"ring",
|
|
1205
|
+
"rise",
|
|
1206
|
+
"road",
|
|
1207
|
+
"rock",
|
|
1208
|
+
"rose",
|
|
1209
|
+
"ruby",
|
|
1210
|
+
"sage",
|
|
1211
|
+
"sand",
|
|
1212
|
+
"seal",
|
|
1213
|
+
"seed",
|
|
1214
|
+
"silk",
|
|
1215
|
+
"sky",
|
|
1216
|
+
"snow",
|
|
1217
|
+
"soft",
|
|
1218
|
+
"star",
|
|
1219
|
+
"stem",
|
|
1220
|
+
"stone",
|
|
1221
|
+
"surf",
|
|
1222
|
+
"swan",
|
|
1223
|
+
"teal",
|
|
1224
|
+
"tide",
|
|
1225
|
+
"tree",
|
|
1226
|
+
"vale",
|
|
1227
|
+
"vine",
|
|
1228
|
+
"wave",
|
|
1229
|
+
"west",
|
|
1230
|
+
"wind",
|
|
1231
|
+
"wing",
|
|
1232
|
+
"wolf",
|
|
1233
|
+
"wood",
|
|
1234
|
+
"wren",
|
|
1235
|
+
"yarn",
|
|
1236
|
+
"zest"
|
|
1237
|
+
]
|
|
1114
1238
|
}
|
|
1115
1239
|
}
|
|
1116
1240
|
};
|
|
@@ -1144,26 +1268,38 @@ function assertManagedDeploymentSpec(value) {
|
|
|
1144
1268
|
}
|
|
1145
1269
|
}
|
|
1146
1270
|
|
|
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
|
|
1275
|
+
import { stringify } from "smol-toml";
|
|
1276
|
+
function nativePiDeclaration(model) {
|
|
1277
|
+
return {
|
|
1278
|
+
version: 2,
|
|
1279
|
+
harness: { runtime: "pi", driver: { kind: "native" } },
|
|
1280
|
+
inference: { model }
|
|
1281
|
+
};
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1147
1284
|
// src/declaration.ts
|
|
1148
1285
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
1149
1286
|
import { lstat as lstat2, open, readFile as readFile2, rename, rm } from "node:fs/promises";
|
|
1150
1287
|
import path2 from "node:path";
|
|
1151
|
-
import { parse, stringify } from "smol-toml";
|
|
1288
|
+
import { parse, stringify as stringify2 } from "smol-toml";
|
|
1152
1289
|
var DECLARATION_FILENAME = ".tonbo";
|
|
1153
|
-
var DEFAULT_INFERENCE_MODEL = "claude-sonnet-4-5";
|
|
1154
1290
|
function createDeclaration(model = DEFAULT_INFERENCE_MODEL, driver = { kind: "native" }, buildCommand, agentHostname) {
|
|
1291
|
+
const base = nativePiDeclaration(model.trim());
|
|
1155
1292
|
return parseDeclaration({
|
|
1156
|
-
|
|
1293
|
+
...base,
|
|
1157
1294
|
...agentHostname ? { agent: agentHostname } : {},
|
|
1158
|
-
harness: {
|
|
1159
|
-
inference: { model: model.trim() },
|
|
1295
|
+
harness: { ...base.harness, driver },
|
|
1160
1296
|
...buildCommand ? { build: { command: buildCommand } } : {}
|
|
1161
1297
|
});
|
|
1162
1298
|
}
|
|
1163
1299
|
function renderDeclaration(declaration) {
|
|
1164
1300
|
return `# Tonbo Agent configuration.
|
|
1165
1301
|
# Edit this file directly or run \`tonbo init\` to reconfigure.
|
|
1166
|
-
${
|
|
1302
|
+
${stringify2(declaration)}`;
|
|
1167
1303
|
}
|
|
1168
1304
|
async function bindDeclarationAgent(root, agentHostname) {
|
|
1169
1305
|
const declaration = await loadDeclaration(root);
|
|
@@ -1246,7 +1382,7 @@ function buildDeploymentSpec(declaration, source) {
|
|
|
1246
1382
|
return spec;
|
|
1247
1383
|
}
|
|
1248
1384
|
|
|
1249
|
-
// src/
|
|
1385
|
+
// ../../packages/agent-source-bundler/src/index.ts
|
|
1250
1386
|
import { createHash as createHash2 } from "node:crypto";
|
|
1251
1387
|
import { lstat as lstat3, readFile as readFile3, readdir } from "node:fs/promises";
|
|
1252
1388
|
import path3 from "node:path";
|
|
@@ -1591,7 +1727,7 @@ async function initCommand(deps, options) {
|
|
|
1591
1727
|
entry = (await deps.prompt("PI SDK entry file [dist/agent.mjs]: ")).trim();
|
|
1592
1728
|
}
|
|
1593
1729
|
entry ||= "dist/agent.mjs";
|
|
1594
|
-
let model = options.model?.trim() || existingDeclaration?.inference.model ||
|
|
1730
|
+
let model = options.model?.trim() || existingDeclaration?.inference.model || DEFAULT_INFERENCE_MODEL2;
|
|
1595
1731
|
let buildCommand = driver === "command" ? options.buildCommand ?? existingDeclaration?.build?.command ?? ["npm", "run", "build"] : void 0;
|
|
1596
1732
|
let agentPlan = existingDeclaration?.agent ? {
|
|
1597
1733
|
kind: "existing",
|
|
@@ -2066,7 +2202,7 @@ function deploymentName(deployment) {
|
|
|
2066
2202
|
}
|
|
2067
2203
|
function deploymentSourceLabel(deployment) {
|
|
2068
2204
|
const git = deployment.origin.git;
|
|
2069
|
-
if (!git) return
|
|
2205
|
+
if (!git) return deploymentOriginLabel(deployment.origin.actor);
|
|
2070
2206
|
const sha = git.commit_sha.slice(0, 7);
|
|
2071
2207
|
return git.ref ? `${sha} \xB7 ${git.ref}` : sha;
|
|
2072
2208
|
}
|
|
@@ -2369,15 +2505,17 @@ var AUTHOR_MAX_LENGTH = 255;
|
|
|
2369
2505
|
async function collectGitProvenance(root, run = defaultGitRunner) {
|
|
2370
2506
|
const commitSha = await read(run, ["rev-parse", "HEAD"], root);
|
|
2371
2507
|
if (!commitSha || !COMMIT_SHA.test(commitSha)) return null;
|
|
2372
|
-
const [ref, subject, author, status] = await Promise.all([
|
|
2508
|
+
const [ref, subject, author, status, remote] = await Promise.all([
|
|
2373
2509
|
read(run, ["rev-parse", "--abbrev-ref", "HEAD"], root),
|
|
2374
2510
|
read(run, ["log", "-1", "--format=%s"], root),
|
|
2375
2511
|
read(run, ["log", "-1", "--format=%an"], root),
|
|
2376
2512
|
// Only the deployed tree matters: changes elsewhere in the repository do
|
|
2377
2513
|
// not alter the uploaded bundle.
|
|
2378
|
-
read(run, ["status", "--porcelain", "--", "."], root)
|
|
2514
|
+
read(run, ["status", "--porcelain", "--", "."], root),
|
|
2515
|
+
read(run, ["remote", "get-url", "origin"], root)
|
|
2379
2516
|
]);
|
|
2380
2517
|
return {
|
|
2518
|
+
...githubRepositoryUrl(remote) ? { repository_url: githubRepositoryUrl(remote) } : {},
|
|
2381
2519
|
commit_sha: commitSha,
|
|
2382
2520
|
ref: ref === "HEAD" ? null : clamp(ref, REF_MAX_LENGTH),
|
|
2383
2521
|
subject: clamp(subject, SUBJECT_MAX_LENGTH),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tonbo/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Deploy persistent Agents and manage their Machines from the command line.",
|
|
5
5
|
"homepage": "https://tonbo.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
|
-
"build": "pnpm run build:source-
|
|
26
|
-
"build:source-
|
|
25
|
+
"build": "pnpm run build:source-tools && node scripts/generate-contracts.mjs --check && tsc -p tsconfig.json && node scripts/bundle.mjs",
|
|
26
|
+
"build:source-tools": "pnpm --filter @tonbo/agent-source-inspector --filter @tonbo/agent-source-bundler build",
|
|
27
27
|
"generate:contracts": "node scripts/generate-contracts.mjs",
|
|
28
|
-
"lint": "pnpm run build:source-
|
|
28
|
+
"lint": "pnpm run build:source-tools && eslint . --max-warnings=0",
|
|
29
29
|
"test": "pnpm build && node --test dist/test/*.test.js",
|
|
30
|
-
"typecheck": "pnpm run build:source-
|
|
30
|
+
"typecheck": "pnpm run build:source-tools && node scripts/generate-contracts.mjs --check && tsc -p tsconfig.json --noEmit"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@inquirer/select": "4.4.2",
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@tonbo/agent-source-inspector": "workspace:*",
|
|
42
42
|
"@types/node": "^20.19.37",
|
|
43
|
-
"@types/tar-stream": "^3.1.4",
|
|
44
43
|
"esbuild": "0.25.4",
|
|
45
|
-
"typescript": "catalog:"
|
|
44
|
+
"typescript": "catalog:",
|
|
45
|
+
"@tonbo/agent-source-bundler": "workspace:*"
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|
|
48
48
|
"node": ">=22"
|