@openagentpack/cli 0.3.0-beta-fb9e73b-20260721 → 0.3.0-beta-316bfba-20260722

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-JNVZKNUE.js";
6
+ } from "../chunk-JJZ3YA2Y.js";
7
7
 
8
8
  // bin/agents.ts
9
9
  import { UserError } from "@openagentpack/sdk";
@@ -360,6 +360,8 @@ import {
360
360
  getDeploymentDetailsForContext,
361
361
  getDeploymentRuntimeProviderForContext,
362
362
  listDeploymentsForContext,
363
+ listRemoteDeploymentsForContext,
364
+ pauseDeploymentForContext,
363
365
  runDeploymentForContext,
364
366
  UserError as UserError3
365
367
  } from "@openagentpack/sdk";
@@ -388,9 +390,56 @@ function printTableFooter() {
388
390
  console.log();
389
391
  }
390
392
 
393
+ // src/utils/pagination.ts
394
+ async function fetchAllPages(fetchPage, all) {
395
+ const first = await fetchPage();
396
+ const items = [...first.items];
397
+ let hasMore = first.hasMore;
398
+ let nextPage = first.nextPage;
399
+ while (all && nextPage) {
400
+ const next = await fetchPage(nextPage);
401
+ items.push(...next.items);
402
+ hasMore = next.hasMore;
403
+ nextPage = next.nextPage;
404
+ }
405
+ return { items, hasMore, nextPage };
406
+ }
407
+
391
408
  // src/commands/deployment.ts
392
409
  async function deploymentListCommand(options) {
393
410
  const ctx = await buildCliRuntime(options.file);
411
+ if (options.remote) {
412
+ if (!options.provider) throw new UserError3("Remote deployment listing requires --provider.");
413
+ if (options.provider === "claude" && options.status && options.includeArchived) {
414
+ throw new UserError3("Claude remote deployment listing cannot combine --status with --include-archived.");
415
+ }
416
+ const { items, hasMore } = await fetchAllPages(async (page) => {
417
+ const result = await listRemoteDeploymentsForContext(ctx, options.provider, {
418
+ status: options.status,
419
+ include_archived: options.includeArchived,
420
+ agent_id: options.agentId,
421
+ limit: options.limit,
422
+ page
423
+ });
424
+ return { items: result.deployments, hasMore: result.has_more, nextPage: result.next_page };
425
+ }, options.all);
426
+ if (items.length === 0) {
427
+ log.info("No remote deployments found.");
428
+ return;
429
+ }
430
+ printTableTitle("Remote Deployments", items.length);
431
+ printTableHeader(["Name".padEnd(24), "ID".padEnd(28), "Status".padEnd(10), "Schedule"], 82);
432
+ for (const item of items) {
433
+ const raw = item.attributes ?? {};
434
+ const name = String(raw.name ?? "").slice(0, 22).padEnd(24);
435
+ const id = String(item.id ?? "").slice(0, 26).padEnd(28);
436
+ const schedule = item.schedule?.expression ?? "manual";
437
+ printTableRow([chalk5.bold(name), id, item.status.padEnd(10), schedule]);
438
+ }
439
+ printTableFooter();
440
+ if (hasMore) log.info("More deployments available. Use --all to fetch all.");
441
+ return;
442
+ }
394
443
  const rows = listDeploymentsForContext(ctx, options.provider);
395
444
  if (rows.length === 0) {
396
445
  log.info("No deployments in state. Run `agents apply` first.");
@@ -411,6 +460,12 @@ async function deploymentListCommand(options) {
411
460
  }
412
461
  printTableFooter();
413
462
  }
463
+ async function deploymentPauseCommand(name, options, paused = true) {
464
+ const ctx = await buildCliRuntime(options.file);
465
+ const info = await pauseDeploymentForContext(ctx, name, paused, options.provider);
466
+ log.success(`Deployment '${name}' ${paused ? "paused" : "unpaused"}.`);
467
+ console.log(` Status: ${info.status}`);
468
+ }
414
469
  async function deploymentGetCommand(name, options) {
415
470
  const ctx = await buildCliRuntime(options.file);
416
471
  const { bindings, provider, info } = await getDeploymentDetailsForContext(ctx, name, void 0, options.provider);
@@ -1211,6 +1266,35 @@ function openBrowser(url) {
1211
1266
  log.warn(`Could not open a browser automatically \u2014 visit ${url}`);
1212
1267
  }
1213
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
+ }
1214
1298
  async function playgroundCommand(options) {
1215
1299
  const port = options.port ? Number(options.port) : DEFAULT_PORT;
1216
1300
  if (!Number.isInteger(port) || port <= 0) {
@@ -1220,12 +1304,29 @@ async function playgroundCommand(options) {
1220
1304
  const supported = [...SUPPORTED_PLAYGROUND_PROVIDERS].join(", ");
1221
1305
  throw new Error(`Playground supports providers: ${supported}; received '${options.provider}'.`);
1222
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
+ }
1223
1324
  const env = { ...process.env, PORT: String(port) };
1224
1325
  if (options.provider) {
1225
1326
  env.AGENTS_PROVIDER = options.provider;
1226
1327
  env.AGENTS_CLI_PROVIDER = options.provider;
1227
1328
  }
1228
- const { cmd, args } = resolveLauncher(cliVersion());
1329
+ const { cmd, args } = resolveLauncher(version);
1229
1330
  if (cmd === "npx") log.info(`Fetching ${PLAYGROUND_PKG} (first run may take a moment)...`);
1230
1331
  const child = spawn(cmd, args, { env, stdio: ["inherit", "pipe", "inherit"] });
1231
1332
  const forward = (signal) => child.kill(signal);
@@ -1262,23 +1363,6 @@ import {
1262
1363
  } from "@openagentpack/sdk";
1263
1364
  import { sanitizeSessionEvent, sanitizeSessionEvents } from "@openagentpack/sdk/session-events";
1264
1365
  import chalk9 from "chalk";
1265
-
1266
- // src/utils/pagination.ts
1267
- async function fetchAllPages(fetchPage, all) {
1268
- const first = await fetchPage();
1269
- const items = [...first.items];
1270
- let hasMore = first.hasMore;
1271
- let nextPage = first.nextPage;
1272
- while (all && nextPage) {
1273
- const next = await fetchPage(nextPage);
1274
- items.push(...next.items);
1275
- hasMore = next.hasMore;
1276
- nextPage = next.nextPage;
1277
- }
1278
- return { items, hasMore, nextPage };
1279
- }
1280
-
1281
- // src/commands/session.ts
1282
1366
  function formatTimestamp(iso) {
1283
1367
  const d = new Date(iso);
1284
1368
  if (Number.isNaN(d.getTime())) return iso;
@@ -1976,9 +2060,11 @@ sessionCmd.command("run <prompt-or-agent> [prompt]").description("Create a sessi
1976
2060
  sessionCmd.command("send <session-id> <message>").description("Send a message to an existing session and wait for the response").addOption(configFileOption()).addOption(providerOption("Target provider")).option("--json", "Output events as JSONL").addOption(new Option2("--stream", "Stream events over SSE instead of polling").conflicts("noStream")).addOption(new Option2("--no-stream", "Use polling (deprecated; polling is now the default)").hideHelp()).action(withResolvedConfigFile(sessionSendCommand));
1977
2061
  sessionCmd.command("events <session-id>").description("List event history for a session").addOption(configFileOption()).addOption(providerOption("Target provider")).addOption(new Option2("--limit <count>", "Maximum number of events to fetch").argParser(parsePositiveInteger)).option("--all", "Fetch all pages by following the cursor").option("--json", "Output as JSON").action(withResolvedConfigFile(sessionEventsCommand));
1978
2062
  var deploymentCmd = program.command("deployment").description("Manage agent deployments (scheduled / triggered runs)");
1979
- deploymentCmd.command("list").description("List deployments tracked in state").addOption(configFileOption()).addOption(providerOption("Filter by provider")).action(withResolvedConfigFile(deploymentListCommand));
2063
+ deploymentCmd.command("list").description("List deployments tracked in state").addOption(configFileOption()).addOption(providerOption("Filter by provider")).option("--remote", "List deployments from the provider API").addOption(new Option2("--status <status>", "Filter remote deployments by status").choices(["active", "paused"])).option("--include-archived", "Include archived remote deployments").option("--agent-id <id>", "Filter remote deployments by agent ID").option("--limit <count>", "Maximum remote deployments per page", parsePositiveInteger).option("--all", "Fetch all remote pages").action(withResolvedConfigFile(deploymentListCommand));
1980
2064
  deploymentCmd.command("get <name>").description("Show a deployment's status and resolved bindings").addOption(configFileOption()).addOption(providerOption("Target provider")).action(withResolvedConfigFile(deploymentGetCommand));
1981
- deploymentCmd.command("run <name>").description("Trigger a deployment run (native on Claude, emulated as a session on Qoder)").addOption(configFileOption()).addOption(providerOption("Target provider")).action(withResolvedConfigFile(deploymentRunCommand));
2065
+ deploymentCmd.command("pause <name>").description("Pause a native deployment's scheduled runs").addOption(configFileOption()).addOption(providerOption("Target provider")).action(withResolvedConfigFile((name, options) => deploymentPauseCommand(name, options, true)));
2066
+ deploymentCmd.command("unpause <name>").description("Resume a paused native deployment").addOption(configFileOption()).addOption(providerOption("Target provider")).action(withResolvedConfigFile((name, options) => deploymentPauseCommand(name, options, false)));
2067
+ deploymentCmd.command("run <name>").description("Trigger a deployment run (native on Qoder/Claude, emulated on Bailian/Ark)").addOption(configFileOption()).addOption(providerOption("Target provider")).action(withResolvedConfigFile(deploymentRunCommand));
1982
2068
  var memoryStoreCmd = program.command("memory-store").description("Manage persistent memory stores");
1983
2069
  memoryStoreCmd.command("create <name>").addOption(configFileOption()).addOption(providerOption("Target provider")).option("--description <description>").action(withResolvedConfigFile(memoryStoreCreateCommand));
1984
2070
  memoryStoreCmd.command("list").addOption(configFileOption()).addOption(providerOption("Target provider")).option("--limit <n>", "Page size", parsePositiveInteger).option("--cursor <cursor>").option("--include-archived").action(withResolvedConfigFile(memoryStoreListCommand));
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  program
3
- } from "../chunk-JNVZKNUE.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-beta-fb9e73b-20260721",
3
+ "version": "0.3.0-beta-316bfba-20260722",
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-beta-fb9e73b-20260721",
52
+ "@openagentpack/playground": "0.3.0-beta-316bfba-20260722",
53
53
  "@types/bun": "^1.3.14",
54
54
  "typescript": "^6.0.3"
55
55
  },
56
56
  "dependencies": {
57
- "@openagentpack/sdk": "0.3.0-beta-fb9e73b-20260721",
57
+ "@openagentpack/sdk": "0.3.0-beta-316bfba-20260722",
58
58
  "@clack/prompts": "^1.5.1",
59
59
  "chalk": "^5.6.2",
60
60
  "commander": "^14.0.3",