@keystrokehq/cli 0.1.95 → 0.1.96

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/index.mjs CHANGED
@@ -5397,6 +5397,80 @@ function registerAgentPromptCommand(agent) {
5397
5397
  }));
5398
5398
  }
5399
5399
  //#endregion
5400
+ //#region src/commands/inspect-detail.ts
5401
+ const WORKFLOW_RUN_FIELDS = [
5402
+ "id",
5403
+ "status",
5404
+ "input",
5405
+ "output",
5406
+ "error"
5407
+ ];
5408
+ const AGENT_SESSION_FIELDS = [
5409
+ "id",
5410
+ "status",
5411
+ "title",
5412
+ "error",
5413
+ "activeRunId",
5414
+ "messageCount"
5415
+ ];
5416
+ function parseInspectDetailOptions(options) {
5417
+ const summary = Boolean(options.summary);
5418
+ const field = options.field?.trim() || void 0;
5419
+ const include = options.include;
5420
+ if (summary && field) throw new Error("Use --summary or --field, not both");
5421
+ if ((summary || field) && include !== void 0) throw new Error("Do not combine --include with --summary or --field");
5422
+ if (summary) return { kind: "summary" };
5423
+ if (field) return {
5424
+ kind: "field",
5425
+ field
5426
+ };
5427
+ return {
5428
+ kind: "raw",
5429
+ include
5430
+ };
5431
+ }
5432
+ function includeForInspectMode(mode) {
5433
+ if (mode.kind === "raw") return mode.include;
5434
+ return "none";
5435
+ }
5436
+ function writeInspectJson(value) {
5437
+ process.stdout.write(`${JSON.stringify(value, null, 2)}\n`);
5438
+ }
5439
+ function projectWorkflowRunSummary(detail) {
5440
+ return {
5441
+ id: detail.run.id,
5442
+ status: detail.run.status,
5443
+ input: detail.run.input,
5444
+ output: detail.run.output,
5445
+ error: detail.run.error
5446
+ };
5447
+ }
5448
+ function projectWorkflowRunField(detail, field) {
5449
+ if (!isWorkflowRunField(field)) throw new Error(`Unknown --field ${field}. Allowed: ${WORKFLOW_RUN_FIELDS.join(", ")}`);
5450
+ return detail.run[field];
5451
+ }
5452
+ function projectAgentSessionSummary(detail) {
5453
+ return {
5454
+ id: detail.session.id,
5455
+ status: detail.session.status,
5456
+ title: detail.session.title,
5457
+ error: detail.session.error,
5458
+ activeRunId: detail.activeRunId,
5459
+ messageCount: detail.session.messageCount
5460
+ };
5461
+ }
5462
+ function projectAgentSessionField(detail, field) {
5463
+ if (!isAgentSessionField(field)) throw new Error(`Unknown --field ${field}. Allowed: ${AGENT_SESSION_FIELDS.join(", ")}`);
5464
+ if (field === "activeRunId") return detail.activeRunId;
5465
+ return detail.session[field];
5466
+ }
5467
+ function isWorkflowRunField(field) {
5468
+ return WORKFLOW_RUN_FIELDS.includes(field);
5469
+ }
5470
+ function isAgentSessionField(field) {
5471
+ return AGENT_SESSION_FIELDS.includes(field);
5472
+ }
5473
+ //#endregion
5400
5474
  //#region src/commands/projects/run-project.ts
5401
5475
  async function withActivePlatformClient(config, fn, fromDir = process.cwd()) {
5402
5476
  await resolveActiveOrganization(config, fromDir);
@@ -5483,9 +5557,18 @@ function registerAgentSessionsCommand(agent) {
5483
5557
  });
5484
5558
  process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
5485
5559
  }));
5486
- sessions.command("get").description("Get full details for an agent session").argument("<agentId>", "Agent key / route id").argument("<sessionId>", "Agent session id").option("--include <parts>", "Comma-separated: gateway, messages, events, trace").action((agentId, sessionId, options) => runProjectCliCommand("Get agent session failed", async ({ client }) => {
5487
- const result = await client.agents.getSession(agentId, sessionId, { include: options.include });
5488
- process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
5560
+ sessions.command("get").description("Get full details for an agent session").argument("<agentId>", "Agent key / route id").argument("<sessionId>", "Agent session id").option("--include <parts>", "Comma-separated: gateway, messages, events, trace, or none").option("--summary", "Print a concise JSON summary (status, title, error, activeRunId, messageCount)").option("--field <field>", "Print one field: id, status, title, error, activeRunId, messageCount").action((agentId, sessionId, options) => runProjectCliCommand("Get agent session failed", async ({ client }) => {
5561
+ const mode = parseInspectDetailOptions(options);
5562
+ const result = await client.agents.getSession(agentId, sessionId, { include: includeForInspectMode(mode) });
5563
+ if (mode.kind === "summary") {
5564
+ writeInspectJson(projectAgentSessionSummary(result));
5565
+ return;
5566
+ }
5567
+ if (mode.kind === "field") {
5568
+ writeInspectJson(projectAgentSessionField(result, mode.field));
5569
+ return;
5570
+ }
5571
+ writeInspectJson(result);
5489
5572
  }));
5490
5573
  sessions.command("cancel").description("Cancel a running agent session").argument("<agentId>", "Agent key / route id").argument("<sessionId>", "Agent session id").action(async (agentId, sessionId) => {
5491
5574
  const config = createCliConfig();
@@ -8692,7 +8775,7 @@ Examples:
8692
8775
  const input = parseJsonOption(options.input, "--input");
8693
8776
  const result = await client.workflows.run(workflowId, input);
8694
8777
  process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
8695
- if (isQueuedRunResponse(result)) process.stderr.write(`Run queued. Track progress:\n ${cliBinaryName()} workflows runs get ${workflowId} ${result.runId} --include steps,trace\n`);
8778
+ if (isQueuedRunResponse(result)) process.stderr.write(`Run queued. Track progress:\n ${cliBinaryName()} workflows runs get ${workflowId} ${result.runId} --summary\n`);
8696
8779
  }, { usage: {
8697
8780
  command: `${cliBinaryName()} workflows run ${workflowId}`,
8698
8781
  flag: "--input"
@@ -8719,9 +8802,18 @@ function registerWorkflowRunsCommand(workflow) {
8719
8802
  });
8720
8803
  process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
8721
8804
  }));
8722
- runs.command("get").description("Get full details for a workflow run").argument("<workflowId>", "Workflow key / route id").argument("<runId>", "Workflow run id").option("--include <parts>", "Comma-separated: trigger, steps, trace").action((workflowId, runId, options) => runProjectCliCommand("Get workflow run failed", async ({ client }) => {
8723
- const result = await client.workflows.getRun(workflowId, runId, { include: options.include });
8724
- process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
8805
+ runs.command("get").description("Get full details for a workflow run").argument("<workflowId>", "Workflow key / route id").argument("<runId>", "Workflow run id").option("--include <parts>", "Comma-separated: trigger, steps, trace, or none").option("--summary", "Print a concise JSON summary (status, input, output, error)").option("--field <field>", "Print one field: id, status, input, output, error").action((workflowId, runId, options) => runProjectCliCommand("Get workflow run failed", async ({ client }) => {
8806
+ const mode = parseInspectDetailOptions(options);
8807
+ const result = await client.workflows.getRun(workflowId, runId, { include: includeForInspectMode(mode) });
8808
+ if (mode.kind === "summary") {
8809
+ writeInspectJson(projectWorkflowRunSummary(result));
8810
+ return;
8811
+ }
8812
+ if (mode.kind === "field") {
8813
+ writeInspectJson(projectWorkflowRunField(result, mode.field));
8814
+ return;
8815
+ }
8816
+ writeInspectJson(result);
8725
8817
  }));
8726
8818
  runs.command("hooks").description("List hook tokens and resume URLs for a workflow run").argument("<workflowId>", "Workflow key / route id").argument("<runId>", "Workflow run id").action((workflowId, runId) => runProjectCliCommand("List workflow run hooks failed", async ({ client }) => {
8727
8819
  const result = await client.workflows.listHooks(workflowId, runId);