@agent-commons/cli 0.0.0-staging-20260823002256 → 0.0.0-staging-20260826201443

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.
Files changed (2) hide show
  1. package/dist/bin.js +223 -36
  2. package/package.json +2 -2
package/dist/bin.js CHANGED
@@ -24,7 +24,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
24
  ));
25
25
 
26
26
  // src/bin.ts
27
- var import_commander22 = require("commander");
27
+ var import_commander23 = require("commander");
28
28
  var import_child_process3 = require("child_process");
29
29
 
30
30
  // src/commands/login.ts
@@ -2536,15 +2536,50 @@ async function runLocalTool(call, cfg) {
2536
2536
 
2537
2537
  // src/commands/run.ts
2538
2538
  function runCommand() {
2539
- return new import_commander8.Command("run").description("Send a single prompt to an agent and stream the response").argument("<prompt>", "Prompt text to send").option("--agent <agentId>", "Agent ID").option("--session <sessionId>", "Resume an existing session by ID").option("--new-session", "Create a new session and print its ID for future use").option("--computer", "Give the agent access to its persistent cloud computer").option("--local", "Enable local file system access (with permission prompts)").option("-y, --yes", "Enable local file system access and auto-approve all operations").option("--no-stream", "Disable streaming (wait for full response)").option("--json", "Output raw event stream as JSON lines").action(async (prompt, opts) => {
2539
+ return new import_commander8.Command("run").description("Send a single prompt to an agent and stream the response").argument("<prompt>", "Prompt text to send").option("--agent <agentId>", "Agent ID").option("--session <sessionId>", "Resume an existing session by ID").option(
2540
+ "--new-session",
2541
+ "Create a new session and print its ID for future use"
2542
+ ).option(
2543
+ "--computer",
2544
+ "Give the agent access to its persistent cloud computer"
2545
+ ).option(
2546
+ "--local",
2547
+ "Enable local file system access (with permission prompts)"
2548
+ ).option(
2549
+ "-y, --yes",
2550
+ "Enable local file system access and auto-approve all operations"
2551
+ ).option("--no-stream", "Disable streaming (wait for full response)").option("--json", "Output raw event stream as JSON lines").option(
2552
+ "--provenance <mode>",
2553
+ "Provenance capture: off, metadata, or full",
2554
+ "metadata"
2555
+ ).option(
2556
+ "--onchain-provenance",
2557
+ "Request an optional on-chain anchor for this run"
2558
+ ).action(async (prompt, opts) => {
2540
2559
  const cfg = loadConfig();
2541
2560
  const agentId2 = opts.agent ?? cfg.defaultAgentId;
2542
2561
  if (!agentId2) {
2543
- console.error(c.error("Specify --agent <agentId> or set defaultAgentId with `agc config set defaultAgentId <id>`"));
2562
+ console.error(
2563
+ c.error(
2564
+ "Specify --agent <agentId> or set defaultAgentId with `agc config set defaultAgentId <id>`"
2565
+ )
2566
+ );
2544
2567
  process.exit(1);
2545
2568
  }
2546
2569
  if (opts.session && opts.newSession) {
2547
- console.error(c.error("Cannot use --session and --new-session together."));
2570
+ console.error(
2571
+ c.error("Cannot use --session and --new-session together.")
2572
+ );
2573
+ process.exit(1);
2574
+ }
2575
+ if (!["off", "metadata", "full"].includes(opts.provenance)) {
2576
+ console.error(c.error("--provenance must be off, metadata, or full."));
2577
+ process.exit(1);
2578
+ }
2579
+ if (opts.onchainProvenance && opts.provenance === "off") {
2580
+ console.error(
2581
+ c.error("--onchain-provenance requires metadata or full capture.")
2582
+ );
2548
2583
  process.exit(1);
2549
2584
  }
2550
2585
  const client = makeClient();
@@ -2594,7 +2629,12 @@ function runCommand() {
2594
2629
  autoApprove
2595
2630
  };
2596
2631
  const snapshot = buildDirSnapshot(rootDir, 2);
2597
- cliContext = buildLocalToolsManifest(rootDir, snapshot, [], autoApprove);
2632
+ cliContext = buildLocalToolsManifest(
2633
+ rootDir,
2634
+ snapshot,
2635
+ [],
2636
+ autoApprove
2637
+ );
2598
2638
  }
2599
2639
  if (!opts.json) {
2600
2640
  const rows = [];
@@ -2603,10 +2643,16 @@ function runCommand() {
2603
2643
  rows.push(["Session", label]);
2604
2644
  }
2605
2645
  if (localEnabled) {
2606
- rows.push(["Local tools", autoApprove ? c.warn("enabled (auto-approve on)") : c.success("enabled")]);
2646
+ rows.push([
2647
+ "Local tools",
2648
+ autoApprove ? c.warn("enabled (auto-approve on)") : c.success("enabled")
2649
+ ]);
2607
2650
  }
2608
2651
  if (opts.computer) {
2609
- rows.push(["Cloud computer", c.success("enabled") + c.dim(" (persistent, remote)")]);
2652
+ rows.push([
2653
+ "Cloud computer",
2654
+ c.success("enabled") + c.dim(" (persistent, remote)")
2655
+ ]);
2610
2656
  }
2611
2657
  if (rows.length) {
2612
2658
  detail(rows);
@@ -2619,7 +2665,11 @@ function runCommand() {
2619
2665
  messages: [{ role: "user", content: prompt }],
2620
2666
  ...cfg.initiator && { initiatorId: cfg.initiator },
2621
2667
  ...opts.computer && { computerRequest: { enabled: true } },
2622
- ...cliContext && { cliContext }
2668
+ ...cliContext && { cliContext },
2669
+ provenance: {
2670
+ mode: opts.provenance,
2671
+ onchain: Boolean(opts.onchainProvenance)
2672
+ }
2623
2673
  };
2624
2674
  if (opts.noStream && !localEnabled) {
2625
2675
  const spinner = spin("Running\u2026");
@@ -2629,8 +2679,13 @@ function runCommand() {
2629
2679
  if (opts.json) return jsonOut(result);
2630
2680
  const text = result?.content ?? result?.text ?? result?.message ?? JSON.stringify(result);
2631
2681
  console.log(text);
2632
- if (sessionId) console.log(c.dim(`
2633
- Session: ${sessionId} (resume with: agc run --session ${sessionId} "<prompt>")`));
2682
+ if (sessionId)
2683
+ console.log(
2684
+ c.dim(
2685
+ `
2686
+ Session: ${sessionId} (resume with: agc run --session ${sessionId} "<prompt>")`
2687
+ )
2688
+ );
2634
2689
  } catch (err) {
2635
2690
  spinner.stop();
2636
2691
  printError(err);
@@ -2662,7 +2717,10 @@ Session: ${sessionId} (resume with: agc run --session ${sessionId} "<prompt>")`
2662
2717
  let result;
2663
2718
  let toolOk = true;
2664
2719
  try {
2665
- result = await runLocalTool({ tool: displayName, args: args ?? {} }, localToolsCfg);
2720
+ result = await runLocalTool(
2721
+ { tool: displayName, args: args ?? {} },
2722
+ localToolsCfg
2723
+ );
2666
2724
  } catch (err) {
2667
2725
  result = `Error: ${err?.message ?? String(err)}`;
2668
2726
  toolOk = false;
@@ -2670,8 +2728,10 @@ Session: ${sessionId} (resume with: agc run --session ${sessionId} "<prompt>")`
2670
2728
  const elapsed = ((Date.now() - startMs) / 1e3).toFixed(1);
2671
2729
  readline2.cursorTo(process.stdout, 0);
2672
2730
  readline2.clearLine(process.stdout, 0);
2673
- process.stdout.write(` ${c.dim("\u2500")} ${c.bold(displayName)} ${toolOk ? sym.ok : sym.fail} ${c.dim("(" + elapsed + "s)")}
2674
- `);
2731
+ process.stdout.write(
2732
+ ` ${c.dim("\u2500")} ${c.bold(displayName)} ${toolOk ? sym.ok : sym.fail} ${c.dim("(" + elapsed + "s)")}
2733
+ `
2734
+ );
2675
2735
  try {
2676
2736
  await client.agents.submitCliToolResult(requestId, result);
2677
2737
  } catch {
@@ -2688,20 +2748,29 @@ Session: ${sessionId} (resume with: agc run --session ${sessionId} "<prompt>")`
2688
2748
  const elapsed = ((Date.now() - toolStartMs) / 1e3).toFixed(1);
2689
2749
  readline2.cursorTo(process.stdout, 0);
2690
2750
  readline2.clearLine(process.stdout, 0);
2691
- process.stdout.write(` ${c.dim("\u2500")} ${c.bold(lastToolName)} ${sym.ok} ${c.dim("(" + elapsed + "s)")}
2692
- `);
2751
+ process.stdout.write(
2752
+ ` ${c.dim("\u2500")} ${c.bold(lastToolName)} ${sym.ok} ${c.dim("(" + elapsed + "s)")}
2753
+ `
2754
+ );
2693
2755
  } else if (event.type === "final") {
2694
2756
  if (hasOutput) process.stdout.write("\n");
2695
2757
  const e = event;
2696
2758
  const finalText = e.content ?? e.payload?.content ?? e.payload?.text ?? e.payload?.message;
2697
2759
  if (finalText && !hasOutput) console.log(finalText);
2698
- if (sessionId) console.log(c.dim(`
2699
- Session: ${sessionId} (resume with: agc run --session ${sessionId} "<prompt>")`));
2760
+ if (sessionId)
2761
+ console.log(
2762
+ c.dim(
2763
+ `
2764
+ Session: ${sessionId} (resume with: agc run --session ${sessionId} "<prompt>")`
2765
+ )
2766
+ );
2700
2767
  break;
2701
2768
  } else if (event.type === "error") {
2702
2769
  if (hasOutput) process.stdout.write("\n");
2703
- console.error(`
2704
- ${sym.fail} ${c.error(event.message ?? "Error")}`);
2770
+ console.error(
2771
+ `
2772
+ ${sym.fail} ${c.error(event.message ?? "Error")}`
2773
+ );
2705
2774
  process.exit(1);
2706
2775
  }
2707
2776
  }
@@ -5333,6 +5402,96 @@ ${sym.ok} Developer project created.`);
5333
5402
  return command;
5334
5403
  }
5335
5404
 
5405
+ // src/commands/provenance.ts
5406
+ var import_commander22 = require("commander");
5407
+ function printTrajectory(trajectory) {
5408
+ const sources = trajectory.events.flatMap(
5409
+ (event) => event.metadata?.lineage?.sources ?? []
5410
+ );
5411
+ const delegates = trajectory.events.flatMap(
5412
+ (event) => event.metadata?.lineage?.delegation ? [event.metadata.lineage.delegation] : []
5413
+ );
5414
+ const matches = trajectory.events.flatMap(
5415
+ (event) => event.metadata?.lineage?.library?.results ?? []
5416
+ );
5417
+ section("Provenance report");
5418
+ detail([
5419
+ ["Runs", String(trajectory.summary?.runs ?? trajectory.runs?.length ?? 0)],
5420
+ [
5421
+ "Events",
5422
+ String(trajectory.summary?.events ?? trajectory.events?.length ?? 0)
5423
+ ],
5424
+ [
5425
+ "Model / tool calls",
5426
+ `${trajectory.summary?.modelCalls ?? 0} / ${trajectory.summary?.toolCalls ?? 0}`
5427
+ ],
5428
+ ["Sources", String(sources.length)],
5429
+ ["Agent delegations", String(delegates.length)],
5430
+ ["Library matches", String(matches.length)],
5431
+ ["Dropped events", String(trajectory.summary?.droppedEvents ?? 0)]
5432
+ ]);
5433
+ if (sources.length) {
5434
+ section("Web sources");
5435
+ for (const source of sources)
5436
+ console.log(
5437
+ ` ${c.primary(source.domain)} ${source.title ?? ""}
5438
+ ${c.dim(source.url)}`
5439
+ );
5440
+ }
5441
+ if (delegates.length) {
5442
+ section("Agent contributions");
5443
+ for (const item of delegates)
5444
+ console.log(
5445
+ ` ${item.fromAgentId ?? "workflow"} \u2192 ${c.primary(item.toAgentId)} ${c.dim(item.role ?? "")}`
5446
+ );
5447
+ }
5448
+ if (matches.length) {
5449
+ section("Library matches");
5450
+ for (const item of matches)
5451
+ console.log(
5452
+ ` ${c.primary(`${item.percentageMatch}%`)} ${item.name ?? item.itemId} ${c.dim(`#${item.rank}`)}`
5453
+ );
5454
+ }
5455
+ }
5456
+ function provenanceCommand() {
5457
+ const cmd = new import_commander22.Command("provenance").description(
5458
+ "Inspect and export provenance and attribution trails"
5459
+ );
5460
+ cmd.command("session <sessionId>").description("Show a plain-language sources and contributors report").option("--json", "Output the complete machine-readable trajectory").action(async (sessionId, opts) => {
5461
+ const spinner = spin("Building provenance report\u2026");
5462
+ try {
5463
+ const { data } = await makeClient().provenance.session(sessionId);
5464
+ spinner.stop();
5465
+ if (opts.json) return jsonOut(data);
5466
+ printTrajectory(data);
5467
+ } catch (error) {
5468
+ spinner.stop();
5469
+ printError(error);
5470
+ process.exitCode = 1;
5471
+ }
5472
+ });
5473
+ cmd.command("workflow <executionId>").description("Show provenance for a workflow execution").option("--json", "Output the complete machine-readable trajectory").action(async (executionId, opts) => {
5474
+ const spinner = spin("Building workflow provenance report\u2026");
5475
+ try {
5476
+ const { data } = await makeClient().provenance.scope(
5477
+ "workflow",
5478
+ executionId
5479
+ );
5480
+ spinner.stop();
5481
+ if (opts.json) return jsonOut(data);
5482
+ printTrajectory(data);
5483
+ } catch (error) {
5484
+ spinner.stop();
5485
+ printError(error);
5486
+ process.exitCode = 1;
5487
+ }
5488
+ });
5489
+ cmd.command("bundle <traceId>").description("Export the standards-based EAA provenance bundle as JSON").action(
5490
+ async (traceId) => jsonOut((await makeClient().provenance.bundle(traceId)).data)
5491
+ );
5492
+ return cmd;
5493
+ }
5494
+
5336
5495
  // src/bin.ts
5337
5496
  async function interactiveMenu() {
5338
5497
  banner();
@@ -5340,9 +5499,15 @@ async function interactiveMenu() {
5340
5499
  const isSetup = !!((cfg.accessToken || cfg.apiKey || cfg.sessionToken) && (cfg.userId || cfg.initiator));
5341
5500
  if (!isSetup) {
5342
5501
  console.log(c.bold(" Welcome to Agent Commons CLI!"));
5343
- console.log(c.dim(" Looks like this is your first time here \u2014 let's get you set up.\n"));
5344
- console.log(` ${sym.arrow} Running ${c.bold("agc login")} to configure your credentials\u2026
5345
- `);
5502
+ console.log(
5503
+ c.dim(
5504
+ " Looks like this is your first time here \u2014 let's get you set up.\n"
5505
+ )
5506
+ );
5507
+ console.log(
5508
+ ` ${sym.arrow} Running ${c.bold("agc login")} to configure your credentials\u2026
5509
+ `
5510
+ );
5346
5511
  runSubcommand(["login"]);
5347
5512
  return;
5348
5513
  }
@@ -5353,7 +5518,11 @@ async function interactiveMenu() {
5353
5518
  const action = await select("What would you like to do?", [
5354
5519
  { label: "Chat with an agent", value: "chat", hint: "agc chat" },
5355
5520
  { label: "Run an agent (one-shot)", value: "run", hint: "agc run" },
5356
- { label: "Manage an agent cloud computer", value: "computer", hint: "agc computer status" },
5521
+ {
5522
+ label: "Manage an agent cloud computer",
5523
+ value: "computer",
5524
+ hint: "agc computer status"
5525
+ },
5357
5526
  { label: "View sessions", value: "sessions", hint: "agc sessions list" },
5358
5527
  { label: "Manage agents", value: "agents", hint: "agc agents list" },
5359
5528
  { label: "Tasks", value: "tasks", hint: "agc task list" },
@@ -5406,7 +5575,10 @@ async function interactiveMenu() {
5406
5575
  async function askPrompt(question) {
5407
5576
  const { createInterface: createInterface3 } = await import("readline");
5408
5577
  return new Promise((resolve2) => {
5409
- const rl = createInterface3({ input: process.stdin, output: process.stdout });
5578
+ const rl = createInterface3({
5579
+ input: process.stdin,
5580
+ output: process.stdout
5581
+ });
5410
5582
  process.stdout.write(`
5411
5583
  ${c.bold(question)}
5412
5584
  ${c.primary("\u203A")} `);
@@ -5434,19 +5606,28 @@ async function pickAgentInteractively(action) {
5434
5606
  spinner.stop();
5435
5607
  } catch {
5436
5608
  spinner.stop();
5437
- console.log(`
5609
+ console.log(
5610
+ `
5438
5611
  ${c.warn("\u26A0")} Could not fetch agents. Check your sign-in and connection.
5439
- `);
5612
+ `
5613
+ );
5440
5614
  return null;
5441
5615
  }
5442
5616
  if (agents.length === 0) {
5443
5617
  console.log(`
5444
5618
  ${c.warn("\u26A0")} You don't have any agents yet.
5445
5619
  `);
5446
- const choice = await select("What would you like to do?", [
5447
- { label: "Create a new agent now", value: "create", hint: "agc agents create" },
5448
- { label: "Go back", value: "cancel" }
5449
- ]);
5620
+ const choice = await select(
5621
+ "What would you like to do?",
5622
+ [
5623
+ {
5624
+ label: "Create a new agent now",
5625
+ value: "create",
5626
+ hint: "agc agents create"
5627
+ },
5628
+ { label: "Go back", value: "cancel" }
5629
+ ]
5630
+ );
5450
5631
  if (choice === "create") {
5451
5632
  runSubcommand(["agents", "create"]);
5452
5633
  }
@@ -5468,12 +5649,14 @@ async function pickAgentInteractively(action) {
5468
5649
  if (saveDefault) {
5469
5650
  saveConfig({ defaultAgentId: agentId2 });
5470
5651
  const chosen = agents.find((a) => a.agentId === agentId2);
5471
- console.log(` ${sym.ok} ${c.dim("Default agent set to")} ${c.bold(chosen?.name ?? agentId2)}
5472
- `);
5652
+ console.log(
5653
+ ` ${sym.ok} ${c.dim("Default agent set to")} ${c.bold(chosen?.name ?? agentId2)}
5654
+ `
5655
+ );
5473
5656
  }
5474
5657
  return agentId2;
5475
5658
  }
5476
- var program = new import_commander22.Command();
5659
+ var program = new import_commander23.Command();
5477
5660
  program.name("agc").description("Agent Commons CLI \u2014 interact with the Agent Commons platform").version("0.4.0", "-v, --version").showHelpAfterError("(run `agc --help` for usage)").configureHelp({
5478
5661
  sortOptions: true,
5479
5662
  sortSubcommands: true
@@ -5492,7 +5675,8 @@ Docs: https://docs.agentcommons.io/docs/cli
5492
5675
  await interactiveMenu();
5493
5676
  });
5494
5677
  program.hook("preAction", async (_thisCommand, actionCommand) => {
5495
- if (actionCommand.name() === "login" || actionCommand.name() === "logout") return;
5678
+ if (actionCommand.name() === "login" || actionCommand.name() === "logout")
5679
+ return;
5496
5680
  await ensureAccessToken();
5497
5681
  });
5498
5682
  program.addCommand(loginCommand());
@@ -5506,6 +5690,7 @@ program.addCommand(connectionsCommand());
5506
5690
  program.addCommand(libraryCommand());
5507
5691
  program.addCommand(projectsCommand());
5508
5692
  program.addCommand(apiKeysCommand());
5693
+ program.addCommand(provenanceCommand());
5509
5694
  program.addCommand(workflowCommand());
5510
5695
  program.addCommand(taskCommand());
5511
5696
  program.addCommand(runCommand());
@@ -5530,8 +5715,10 @@ program.on("command:*", () => {
5530
5715
  process.exit(1);
5531
5716
  });
5532
5717
  program.parseAsync(process.argv).catch((error) => {
5533
- console.error(`
5718
+ console.error(
5719
+ `
5534
5720
  ${sym.fail} ${c.error(error instanceof Error ? error.message : String(error))}
5535
- `);
5721
+ `
5722
+ );
5536
5723
  process.exitCode = 1;
5537
5724
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-commons/cli",
3
- "version": "0.0.0-staging-20260823002256",
3
+ "version": "0.0.0-staging-20260826201443",
4
4
  "description": "Official Agent Commons CLI for building, running, and managing AI agents from the terminal",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -37,7 +37,7 @@
37
37
  "commander": "^12.1.0",
38
38
  "ora": "^8.1.1",
39
39
  "pdf-parse": "^1.1.1",
40
- "@agent-commons/sdk": "0.0.0-staging-20260823002256"
40
+ "@agent-commons/sdk": "0.0.0-staging-20260826201443"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/node": "^22.10.2",