playcanvas-agent-bridge-cli 0.4.2 → 0.5.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/cli.js CHANGED
@@ -1418,11 +1418,39 @@ async function handleWorkspace(args) {
1418
1418
  }
1419
1419
  return fail("UNKNOWN_COMMAND", `Unknown workspace command: ${subcommand}`);
1420
1420
  }
1421
+ async function handleBuilder(args) {
1422
+ const subcommand = args._[1] || "status";
1423
+ if (subcommand === "start" || subcommand === "build") {
1424
+ const templateAssetId = flagString(args, "asset") ||
1425
+ flagString(args, "asset-id") ||
1426
+ flagString(args, "id");
1427
+ if (!templateAssetId) {
1428
+ return fail("INVALID_REQUEST", "builder start requires --asset <templateAssetId>.");
1429
+ }
1430
+ return fetchDaemon("/builder/jobs", {
1431
+ method: "POST",
1432
+ body: JSON.stringify({
1433
+ target: flagString(args, "target", "current") || "current",
1434
+ templateAssetId,
1435
+ suffix: flagString(args, "suffix") || "",
1436
+ prefix: flagString(args, "prefix") || "",
1437
+ }),
1438
+ });
1439
+ }
1440
+ if (subcommand === "status") {
1441
+ const jobId = flagString(args, "job") || flagString(args, "id");
1442
+ if (!jobId)
1443
+ return fail("INVALID_REQUEST", "builder status requires --job <jobId>.");
1444
+ return fetchDaemon(`/builder/jobs/${encodeURIComponent(jobId)}`);
1445
+ }
1446
+ return fail("UNKNOWN_COMMAND", `Unknown builder command: ${subcommand}`);
1447
+ }
1421
1448
  function help(group = "overview") {
1422
1449
  const groups = {
1423
1450
  overview: [
1424
1451
  "pcbridge help core",
1425
1452
  "pcbridge help workspace",
1453
+ "pcbridge help builder",
1426
1454
  "pcbridge help frontend",
1427
1455
  "pcbridge help target",
1428
1456
  "pcbridge help entity",
@@ -1459,6 +1487,12 @@ function help(group = "overview") {
1459
1487
  "pcbridge workspace pull --target editor:<sceneId> --asset <assetId>",
1460
1488
  "The directory where `pcbridge daemon start` runs is the workspace root.",
1461
1489
  ],
1490
+ builder: [
1491
+ "pcbridge builder start --target editor:<sceneId> --asset <template_asset_id> [--suffix '-${time}'] [--prefix assets]",
1492
+ "pcbridge builder status --job <build_job_id>",
1493
+ "Template assets also show a pcbridge Tiny Builder panel in the PlayCanvas Editor.",
1494
+ "S3 settings come from the project .env, then the workspace-root .env; files upload directly without a ZIP.",
1495
+ ],
1462
1496
  frontend: [
1463
1497
  "pcbridge frontend install [latest|playcanvas-editor-v<version>-r<revision>] [--no-activate]",
1464
1498
  "pcbridge frontend update",
@@ -1615,6 +1649,9 @@ async function main() {
1615
1649
  else if (command === "workspace") {
1616
1650
  print(await handleWorkspace(args));
1617
1651
  }
1652
+ else if (command === "builder" || command === "build") {
1653
+ print(await handleBuilder(args));
1654
+ }
1618
1655
  else if (command === "eval") {
1619
1656
  const commandArgs = await readJsonFlag(args, "args-json");
1620
1657
  print(await rpcEval(args, await readCode(args), objectJson(commandArgs, "eval args")));
package/dist/config.js CHANGED
@@ -4,7 +4,7 @@ import { existsSync } from "node:fs";
4
4
  import { homedir } from "node:os";
5
5
  import { dirname, join, resolve } from "node:path";
6
6
  import { fileURLToPath } from "node:url";
7
- export const VERSION = "0.4.2";
7
+ export const VERSION = "0.5.1";
8
8
  export const DEFAULT_HOST = "127.0.0.1";
9
9
  export const DEFAULT_PORT = 17329;
10
10
  export const DEFAULT_FRONTEND_PORT = 3487;
@@ -5,6 +5,7 @@ import { CONFIG_DIR, DEFAULT_FRONTEND_PORT, DEFAULT_HOST, DEFAULT_PORT, VERSION,
5
5
  import { createFrontendServer, } from "../frontend/server.js";
6
6
  import { TargetRegistry } from "./target-registry.js";
7
7
  import { WorkspaceManager } from "../workspace/manager.js";
8
+ import { BuilderManager } from "../builder/manager.js";
8
9
  import { fail, normalizeError, ok, } from "../shared/protocol.js";
9
10
  function readBody(req) {
10
11
  return new Promise((resolve, reject) => {
@@ -103,6 +104,16 @@ export function createDaemonServer(options) {
103
104
  timeoutMs,
104
105
  }),
105
106
  });
107
+ const builder = new BuilderManager({
108
+ rootDir: workspace.rootDir,
109
+ requestTarget: (target, method, params = {}, timeoutMs = 15000) => sendToTarget({
110
+ target,
111
+ method,
112
+ params,
113
+ timeoutMs,
114
+ }),
115
+ workspace,
116
+ });
106
117
  const server = http.createServer(async (req, res) => {
107
118
  try {
108
119
  const url = new URL(req.url || "/", `http://${req.headers.host || `${host}:${port}`}`);
@@ -217,6 +228,41 @@ export function createDaemonServer(options) {
217
228
  }
218
229
  return;
219
230
  }
231
+ if (url.pathname === "/builder/jobs" && req.method === "POST") {
232
+ if (!requireToken(req)) {
233
+ writeJson(res, 403, fail("BAD_TOKEN", "Invalid pcbridge token."));
234
+ return;
235
+ }
236
+ const body = await readBody(req);
237
+ if (!isJsonObject(body) || typeof body.templateAssetId !== "string") {
238
+ writeJson(res, 400, fail("INVALID_REQUEST", "Template build requires templateAssetId."));
239
+ return;
240
+ }
241
+ const selector = typeof body.target === "string" ? body.target : "current";
242
+ const resolved = registry.resolve(selector);
243
+ if (!resolved.ok) {
244
+ writeJson(res, 400, fail(resolved.code, resolved.message));
245
+ return;
246
+ }
247
+ const suffix = typeof body.suffix === "string" ? body.suffix : undefined;
248
+ const prefix = typeof body.prefix === "string" ? body.prefix : undefined;
249
+ writeJson(res, 202, ok(builder.start(resolved.target.info, body.templateAssetId, { suffix, prefix })));
250
+ return;
251
+ }
252
+ const builderJobMatch = url.pathname.match(/^\/builder\/jobs\/([^/]+)$/);
253
+ if (builderJobMatch && req.method === "GET") {
254
+ if (!requireToken(req)) {
255
+ writeJson(res, 403, fail("BAD_TOKEN", "Invalid pcbridge token."));
256
+ return;
257
+ }
258
+ const job = builder.get(decodeURIComponent(builderJobMatch[1]));
259
+ if (!job) {
260
+ writeJson(res, 404, fail("BUILD_NOT_FOUND", "Template build job was not found."));
261
+ return;
262
+ }
263
+ writeJson(res, 200, ok(job));
264
+ return;
265
+ }
220
266
  if (url.pathname === "/rpc" && req.method === "POST") {
221
267
  if (!requireToken(req)) {
222
268
  writeJson(res, 403, fail("BAD_TOKEN", "Invalid pcbridge token."));
@@ -335,6 +381,7 @@ export function createDaemonServer(options) {
335
381
  registry,
336
382
  frontend,
337
383
  workspace,
384
+ builder,
338
385
  listen: async () => {
339
386
  await new Promise((resolveListen, reject) => {
340
387
  server.once("error", reject);