@openagentpack/cli 0.3.0 → 0.3.1-beta-85cd4b6-20260727

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.
@@ -3,7 +3,7 @@ import {
3
3
  configureLogger,
4
4
  log,
5
5
  program
6
- } from "../chunk-YXWT5OMX.js";
6
+ } from "../chunk-JJZ3YA2Y.js";
7
7
 
8
8
  // bin/agents.ts
9
9
  import { UserError } from "@openagentpack/sdk";
@@ -1266,6 +1266,35 @@ function openBrowser(url) {
1266
1266
  log.warn(`Could not open a browser automatically \u2014 visit ${url}`);
1267
1267
  }
1268
1268
  }
1269
+ async function probeExistingPlayground(port) {
1270
+ try {
1271
+ const controller = new AbortController();
1272
+ const timeout = setTimeout(() => controller.abort(), 2e3);
1273
+ const res = await fetch(`http://localhost:${port}/health`, { signal: controller.signal });
1274
+ clearTimeout(timeout);
1275
+ if (!res.ok) return null;
1276
+ const body = await res.json();
1277
+ if (body.playground?.pid) {
1278
+ return { version: body.playground.version ?? "unknown", pid: body.playground.pid };
1279
+ }
1280
+ } catch {
1281
+ }
1282
+ return null;
1283
+ }
1284
+ async function replaceExistingPlayground(existing, port) {
1285
+ log.info(`Replacing playground v${existing.version} (pid ${existing.pid}) on port ${port}...`);
1286
+ try {
1287
+ process.kill(existing.pid, "SIGTERM");
1288
+ } catch {
1289
+ return true;
1290
+ }
1291
+ for (let i = 0; i < 30; i++) {
1292
+ await new Promise((r) => setTimeout(r, 100));
1293
+ const still = await probeExistingPlayground(port);
1294
+ if (!still) return true;
1295
+ }
1296
+ return false;
1297
+ }
1269
1298
  async function playgroundCommand(options) {
1270
1299
  const port = options.port ? Number(options.port) : DEFAULT_PORT;
1271
1300
  if (!Number.isInteger(port) || port <= 0) {
@@ -1275,12 +1304,29 @@ async function playgroundCommand(options) {
1275
1304
  const supported = [...SUPPORTED_PLAYGROUND_PROVIDERS].join(", ");
1276
1305
  throw new Error(`Playground supports providers: ${supported}; received '${options.provider}'.`);
1277
1306
  }
1307
+ const version = cliVersion();
1308
+ const existing = await probeExistingPlayground(port);
1309
+ if (existing) {
1310
+ if (existing.version === version) {
1311
+ const url2 = `http://localhost:${port}`;
1312
+ log.success(`Playground v${version} already running at ${url2} (pid ${existing.pid})`);
1313
+ if (options.open !== false) openBrowser(url2);
1314
+ return;
1315
+ }
1316
+ const freed = await replaceExistingPlayground(existing, port);
1317
+ if (!freed) {
1318
+ log.warn(
1319
+ `Could not stop existing playground (pid ${existing.pid}) on port ${port}. Kill it manually and retry, or use --port to pick another port.`
1320
+ );
1321
+ return;
1322
+ }
1323
+ }
1278
1324
  const env = { ...process.env, PORT: String(port) };
1279
1325
  if (options.provider) {
1280
1326
  env.AGENTS_PROVIDER = options.provider;
1281
1327
  env.AGENTS_CLI_PROVIDER = options.provider;
1282
1328
  }
1283
- const { cmd, args } = resolveLauncher(cliVersion());
1329
+ const { cmd, args } = resolveLauncher(version);
1284
1330
  if (cmd === "npx") log.info(`Fetching ${PLAYGROUND_PKG} (first run may take a moment)...`);
1285
1331
  const child = spawn(cmd, args, { env, stdio: ["inherit", "pipe", "inherit"] });
1286
1332
  const forward = (signal) => child.kill(signal);
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  program
3
- } from "../chunk-YXWT5OMX.js";
3
+ } from "../chunk-JJZ3YA2Y.js";
4
4
  export {
5
5
  program
6
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openagentpack/cli",
3
- "version": "0.3.0",
3
+ "version": "0.3.1-beta-85cd4b6-20260727",
4
4
  "description": "Open Agent Pack — Declaratively manage AI agent infrastructure",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -49,12 +49,12 @@
49
49
  "typecheck": "tsc --noEmit"
50
50
  },
51
51
  "devDependencies": {
52
- "@openagentpack/playground": "0.3.0",
52
+ "@openagentpack/playground": "0.3.1-beta-85cd4b6-20260727",
53
53
  "@types/bun": "^1.3.14",
54
54
  "typescript": "^6.0.3"
55
55
  },
56
56
  "dependencies": {
57
- "@openagentpack/sdk": "0.3.0",
57
+ "@openagentpack/sdk": "0.3.1-beta-85cd4b6-20260727",
58
58
  "@clack/prompts": "^1.5.1",
59
59
  "chalk": "^5.6.2",
60
60
  "commander": "^14.0.3",