@openagentpack/cli 0.1.0 → 0.2.0-beta-ddef91c-20260720

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-XRJ6J5YM.js";
6
+ } from "../chunk-RABNXQ33.js";
7
7
 
8
8
  // bin/agents.ts
9
9
  import { UserError } from "@openagentpack/sdk";
@@ -519,7 +519,9 @@ function stopResourceSpinner(spinner4, result) {
519
519
  return;
520
520
  }
521
521
  if (result.status === "success") {
522
- if (result.reason === "already_gone") {
522
+ if (result.reason === "reference_removed") {
523
+ spinner4.stop(chalk6.green(`\u2713 ${label} \u2014 local reference removed (remote left intact)`));
524
+ } else if (result.reason === "already_gone") {
523
525
  spinner4.stop(chalk6.yellow(`\u2298 ${label} \u2014 already deleted remotely, cleaned up state`));
524
526
  } else if (result.cascaded) {
525
527
  spinner4.stop(chalk6.green(`\u2713 ${label} \u2014 destroyed (cascaded)`));
@@ -724,7 +726,12 @@ async function modelsListCommand(options) {
724
726
  for (const listing of listings) {
725
727
  const name = listing.provider;
726
728
  if (!listing.supportsDynamicListing) {
727
- if (!options.json) {
729
+ if (options.json) {
730
+ process.stdout.write(
731
+ `${JSON.stringify({ provider: name, supportsDynamicListing: false, models: [] }, null, 2)}
732
+ `
733
+ );
734
+ } else {
728
735
  console.log(chalk7.yellow(`
729
736
  Provider '${name}' does not support dynamic model listing.`));
730
737
  if (name === "claude") {
@@ -1177,8 +1184,12 @@ async function sessionCreateCommand(agentNameOrOptions, maybeOptions) {
1177
1184
  const ctx = await buildCliRuntime(options.file);
1178
1185
  const run = await createSessionForAgent(ctx, {
1179
1186
  agent: positionalAgent ?? options.agent,
1187
+ identityId: options.identityId,
1180
1188
  provider: options.provider,
1181
1189
  environment: options.environment,
1190
+ environmentId: options.environmentId,
1191
+ tunnel: options.tunnel,
1192
+ tunnelId: options.tunnelId,
1182
1193
  vault: options.vault,
1183
1194
  memoryStores: parseMemoryStores(options.memoryStores),
1184
1195
  title: options.title
@@ -1187,6 +1198,7 @@ async function sessionCreateCommand(agentNameOrOptions, maybeOptions) {
1187
1198
  log.success(`Session created: ${chalk9.bold(session.id)}`);
1188
1199
  console.log(` Agent: ${agentName}`);
1189
1200
  console.log(` Environment: ${session.environment_id}`);
1201
+ if (session.tunnel_id) console.log(` Tunnel: ${session.tunnel_id}`);
1190
1202
  console.log(` Status: ${session.status}`);
1191
1203
  if (session.vault_ids.length) console.log(` Vaults: ${session.vault_ids.join(", ")}`);
1192
1204
  if (session.memory_store_ids.length) console.log(` Memory: ${session.memory_store_ids.join(", ")}`);
@@ -1246,6 +1258,7 @@ async function sessionGetCommand(sessionId, options) {
1246
1258
  console.log(` ID: ${chalk9.bold(session.id)}`);
1247
1259
  console.log(` Agent: ${session.agent_id}`);
1248
1260
  console.log(` Environment: ${session.environment_id}`);
1261
+ if (session.tunnel_id) console.log(` Tunnel: ${session.tunnel_id}`);
1249
1262
  console.log(` Status: ${session.status}`);
1250
1263
  if (session.title) console.log(` Title: ${session.title}`);
1251
1264
  if (session.vault_ids.length) console.log(` Vaults: ${session.vault_ids.join(", ")}`);
@@ -1314,6 +1327,9 @@ function renderCollectedEvents(result, json) {
1314
1327
  renderTerminalStatus(result.terminalStatus, json);
1315
1328
  }
1316
1329
  }
1330
+ function shouldStreamSession(options) {
1331
+ return options.stream === true && options.noStream !== true;
1332
+ }
1317
1333
  async function sessionRunCommand(promptOrAgent, promptOrOptions, maybeOptions) {
1318
1334
  const hasPositionalAgent = typeof promptOrOptions === "string";
1319
1335
  const positionalAgent = hasPositionalAgent ? promptOrAgent : void 0;
@@ -1324,32 +1340,37 @@ async function sessionRunCommand(promptOrAgent, promptOrOptions, maybeOptions) {
1324
1340
  }
1325
1341
  const runOptions = {
1326
1342
  agent: positionalAgent ?? options.agent,
1343
+ identityId: options.identityId,
1327
1344
  provider: options.provider,
1328
1345
  environment: options.environment,
1346
+ environmentId: options.environmentId,
1347
+ tunnel: options.tunnel,
1348
+ tunnelId: options.tunnelId,
1329
1349
  vault: options.vault,
1330
1350
  memoryStores: parseMemoryStores(options.memoryStores),
1331
1351
  title: options.title
1332
1352
  };
1333
1353
  const ctx = await buildCliRuntime(options.file);
1334
- const run = options.noStream ? await startSessionRunPolling(ctx, prompt, runOptions) : await startSessionRun(ctx, prompt, runOptions);
1354
+ const stream = shouldStreamSession(options);
1355
+ const run = stream ? await startSessionRun(ctx, prompt, runOptions) : await startSessionRunPolling(ctx, prompt, runOptions);
1335
1356
  const session = run.session;
1336
1357
  if (!options.json) {
1337
1358
  log.success(`Session created: ${chalk9.bold(session.id)}`);
1338
1359
  }
1339
- if (options.noStream) {
1340
- renderCollectedEvents(run, !!options.json);
1341
- } else {
1360
+ if (stream) {
1342
1361
  await streamAndRender(run.events, !!options.json);
1362
+ } else {
1363
+ renderCollectedEvents(run, !!options.json);
1343
1364
  }
1344
1365
  }
1345
1366
  async function sessionSendCommand(sessionId, message, options) {
1346
1367
  const ctx = await buildCliRuntime(options.file);
1347
- if (options.noStream) {
1348
- const result = await sendSessionMessagePolling(ctx, sessionId, message, { provider: options.provider });
1349
- renderCollectedEvents(result, !!options.json);
1350
- } else {
1368
+ if (shouldStreamSession(options)) {
1351
1369
  const events = await sendSessionMessageStreaming(ctx, sessionId, message, { provider: options.provider });
1352
1370
  await streamAndRender(events, !!options.json);
1371
+ } else {
1372
+ const result = await sendSessionMessagePolling(ctx, sessionId, message, { provider: options.provider });
1373
+ renderCollectedEvents(result, !!options.json);
1353
1374
  }
1354
1375
  }
1355
1376
  async function sessionEventsCommand(sessionId, options) {
@@ -1471,7 +1492,7 @@ async function syncCommand(options) {
1471
1492
  const configPath = resolve3(options.file);
1472
1493
  const { provider, result } = fileExistsSync(configPath) ? await syncFromConfig(configPath, options.provider) : await syncFromEnv(options.provider);
1473
1494
  const baseDir = dirname3(outPath);
1474
- const removedFiles = await promptFileAssociation(result.config, baseDir);
1495
+ const removedFiles = options.skipMissingFiles ? removeMissingFileAssociations(result.config, baseDir) : await promptFileAssociation(result.config, baseDir);
1475
1496
  if (removedFiles.length > 0) {
1476
1497
  const files = result.config.files ?? {};
1477
1498
  for (const key of removedFiles) {
@@ -1506,6 +1527,14 @@ async function syncCommand(options) {
1506
1527
  await promptSecretValues(result.secretPlaceholders);
1507
1528
  }
1508
1529
  }
1530
+ function removeMissingFileAssociations(config, baseDir) {
1531
+ const files = config.files ?? {};
1532
+ const removed = Object.entries(files).filter(([, decl]) => !fileExistsSync(join(baseDir, decl.source))).map(([key]) => key);
1533
+ if (removed.length > 0) {
1534
+ log.info(`${removed.length} file(s) removed (skipped).`);
1535
+ }
1536
+ return removed;
1537
+ }
1509
1538
  async function syncFromConfig(configPath, explicitProvider) {
1510
1539
  const ctx = await buildCliRuntime(configPath);
1511
1540
  const provider = resolveSyncProvider(ctx.config, explicitProvider);
@@ -1728,6 +1757,7 @@ async function serializeConfig(config) {
1728
1757
  import { resolve as resolve4 } from "path";
1729
1758
  import { resolveProjectConfig as resolveProjectConfig2, UserError as UserError10, validateProjectConfig } from "@openagentpack/sdk";
1730
1759
  async function validateCommand(options) {
1760
+ ensureCredentials();
1731
1761
  const configPath = resolve4(options.file);
1732
1762
  log.info(`Validating ${configPath}...`);
1733
1763
  const { config } = await resolveProjectConfig2(options.file);
@@ -1805,7 +1835,7 @@ program.command("apply").description("Apply the planned changes to create/update
1805
1835
  parsePositiveInteger
1806
1836
  ).addOption(providerOption("Target provider", { allowAll: true, defaultValue: "all" })).action(withResolvedConfigFile(applyCommand));
1807
1837
  program.command("destroy").description("Destroy all managed resources").addOption(configFileOption()).option("-y, --yes", "Skip confirmation prompt").option("--cascade", "Auto-delete dependent resources (e.g., sessions referencing an environment)").action(withResolvedConfigFile(destroyCommand));
1808
- program.command("sync").description("Export a provider's remote configuration into a local agents.yaml").addOption(configFileOption()).addOption(providerOption("Source provider to sync from (defaults from config when -f is set)")).option("-o, --out <path>", "Output file path", "agents.synced.yaml").option("--force", "Overwrite the output file if it already exists").action(withResolvedConfigFile(syncCommand));
1838
+ program.command("sync").description("Export a provider's remote configuration into a local agents.yaml").addOption(configFileOption()).addOption(providerOption("Source provider to sync from (defaults from config when -f is set)")).option("-o, --out <path>", "Output file path", "agents.synced.yaml").option("--force", "Overwrite the output file if it already exists").option("--skip-missing-files", "Do not prompt for remote files that cannot be downloaded; omit them from output").action(withResolvedConfigFile(syncCommand));
1809
1839
  program.command("migrate").description("Merge synced resources into the project agents.yaml (incremental, skip existing)").option("--from <path>", "Source synced file", "agents.synced.yaml").option("--to <path>", "Target agents.yaml file", "agents.yaml").action(migrateCommand);
1810
1840
  var stateCmd = program.command("state").description("Manage state file");
1811
1841
  stateCmd.command("list").description("List all resources in state").addOption(configFileOption()).action(withResolvedConfigFile(stateListCommand));
@@ -1817,12 +1847,12 @@ stateCmd.command("import <address> <remote-id>").description("Import an existing
1817
1847
  )
1818
1848
  ).action(withResolvedConfigFile(stateImportCommand));
1819
1849
  var sessionCmd = program.command("session").description("Manage agent sessions (runtime)");
1820
- sessionCmd.command("create [agent-name]").description("Create a new session for an agent").addOption(configFileOption()).option("--agent <name>", "Agent name (auto-detected when only one agent is configured)").option("--environment <name>", "Override agent's declared environment").option("--vault <name>", "Override agent's declared vault").option("--memory-stores <names>", "Override agent's declared memory stores (comma-separated)").option("--title <title>", "Session title").addOption(providerOption("Target provider (required for multi-provider agents)")).action(withResolvedConfigFile(sessionCreateCommand));
1850
+ sessionCmd.command("create [agent-name]").description("Create a new session for an agent").addOption(configFileOption()).option("--agent <name>", "Agent name (auto-detected when only one agent is configured)").option("--identity-id <id>", "Override the configured Qoder Forward Identity").option("--environment <name>", "Override agent's declared environment").option("--environment-id <id>", "Use an explicit remote environment id instead of the configured one").option("--tunnel <name>", "Override agent's declared tunnel").option("--tunnel-id <id>", "Use an explicit remote tunnel id instead of the configured one").option("--vault <name>", "Override agent's declared vault").option("--memory-stores <names>", "Override agent's declared memory stores (comma-separated)").option("--title <title>", "Session title").addOption(providerOption("Target provider (required for multi-provider agents)")).action(withResolvedConfigFile(sessionCreateCommand));
1821
1851
  sessionCmd.command("list").description("List sessions from the provider").addOption(configFileOption()).option("--agent <name>", "Filter by agent name").option("--all", "Fetch all pages by following the cursor").addOption(providerOption("Target provider")).action(withResolvedConfigFile(sessionListCommand));
1822
1852
  sessionCmd.command("get <session-id>").description("Get details of a session").addOption(configFileOption()).addOption(providerOption("Target provider")).action(withResolvedConfigFile(sessionGetCommand));
1823
1853
  sessionCmd.command("delete <session-id>").description("Delete a session").addOption(configFileOption()).addOption(providerOption("Target provider")).action(withResolvedConfigFile(sessionDeleteCommand));
1824
- sessionCmd.command("run <prompt-or-agent> [prompt]").description("Create a session, send a message, and stream the response").addOption(configFileOption()).option("--agent <name>", "Agent name (auto-detected when only one agent is configured)").option("--environment <name>", "Override agent's declared environment").option("--vault <name>", "Override agent's declared vault").option("--memory-stores <names>", "Override agent's declared memory stores (comma-separated)").option("--title <title>", "Session title").addOption(providerOption("Target provider")).option("--json", "Output events as JSONL").option("--no-stream", "Use polling instead of SSE streaming").action(withResolvedConfigFile(sessionRunCommand));
1825
- sessionCmd.command("send <session-id> <message>").description("Send a message to an existing session and stream the response").addOption(configFileOption()).addOption(providerOption("Target provider")).option("--json", "Output events as JSONL").option("--no-stream", "Use polling instead of SSE streaming").action(withResolvedConfigFile(sessionSendCommand));
1854
+ sessionCmd.command("run <prompt-or-agent> [prompt]").description("Create a session, send a message, and wait for the response").addOption(configFileOption()).option("--agent <name>", "Agent name (auto-detected when only one agent is configured)").option("--identity-id <id>", "Override the configured Qoder Forward Identity").option("--environment <name>", "Override agent's declared environment").option("--environment-id <id>", "Use an explicit remote environment id instead of the configured one").option("--tunnel <name>", "Override agent's declared tunnel").option("--tunnel-id <id>", "Use an explicit remote tunnel id instead of the configured one").option("--vault <name>", "Override agent's declared vault").option("--memory-stores <names>", "Override agent's declared memory stores (comma-separated)").option("--title <title>", "Session title").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(sessionRunCommand));
1855
+ 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));
1826
1856
  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));
1827
1857
  var deploymentCmd = program.command("deployment").description("Manage agent deployments (scheduled / triggered runs)");
1828
1858
  deploymentCmd.command("list").description("List deployments tracked in state").addOption(configFileOption()).addOption(providerOption("Filter by provider")).action(withResolvedConfigFile(deploymentListCommand));
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  program
3
- } from "../chunk-XRJ6J5YM.js";
3
+ } from "../chunk-RABNXQ33.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.1.0",
3
+ "version": "0.2.0-beta-ddef91c-20260720",
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.1.0",
52
+ "@openagentpack/playground": "0.2.0-beta-ddef91c-20260720",
53
53
  "@types/bun": "^1.3.14",
54
54
  "typescript": "^6.0.3"
55
55
  },
56
56
  "dependencies": {
57
- "@openagentpack/sdk": "0.1.0",
57
+ "@openagentpack/sdk": "0.2.0-beta-ddef91c-20260720",
58
58
  "@clack/prompts": "^1.5.1",
59
59
  "chalk": "^5.6.2",
60
60
  "commander": "^14.0.3",