@eigenpal/cli 0.23.2 → 0.23.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @eigenpal/cli
2
2
 
3
+ ## 0.23.4
4
+
5
+ ### Patch Changes
6
+
7
+ - a679fff: The CLI now retries rate-limited requests a few times, waiting as long as the server asks, and reports a request that is still rate limited as a rate limit with how long to wait, instead of as a validation failure.
8
+ - a679fff: `eigenpal workflow step-type get <type>` now accepts `--json`, like the other commands. Its output was already JSON.
9
+ - a679fff: `eigenpal workflow push --json` now prints the same shape on create and update, `{ id, name, version, versionId, created }`, so `jq -r .id` always gives the workflow id. `eigenpal workflow list` shows each workflow's name and version again, and its `--json` rows include `name`, `description` and `version`. New `eigenpal workflow get <id-or-slug>` shows one workflow's name, version, folder and your access, with `--json` for the full record. `workflow push --bump` now reads the current version correctly.
10
+ - 9cdd671: `eigenpal workflow experiment run --wait` now returns only after every run has finished and been graded, so its pass rate matches `workflow experiment results`. Previously it could return while the last runs were still being scored and report a pass rate that was too low.
11
+ - 8456358: The bundled step reference in `eigenpal docs` now covers OCR word confidence in extraction grounding and the `lineageFrom` option on human review.
12
+
13
+ ## 0.23.3
14
+
15
+ ### Patch Changes
16
+
17
+ - b92b4e8: The bundled self-hosting docs in `eigenpal docs` now describe the install preflight check and how to run it on its own.
18
+
3
19
  ## 0.22.6
4
20
 
5
21
  ### Patch Changes
package/dist/cli.js CHANGED
@@ -7093,7 +7093,8 @@ var init_parser = __esm(() => {
7093
7093
  filename: string2(),
7094
7094
  mimeType: string2(),
7095
7095
  size: number2().describe("File size in bytes"),
7096
- storageRef: string2().optional().describe("Storage reference for the original file")
7096
+ storageRef: string2().optional().describe("Storage reference for the original file"),
7097
+ renderedPdfRef: string2().optional().describe("Storage key of the PDF an office input was rendered to. Page word boxes are measured on this PDF.")
7097
7098
  });
7098
7099
  ParseUsageSchema = object({
7099
7100
  pageCount: number2(),
@@ -15204,6 +15205,7 @@ var init_human_review = __esm(() => {
15204
15205
  data: union([string2().min(1), record(string2(), unknown()), array(unknown())]).describe("Structured data or a template expression resolving to an object or array"),
15205
15206
  schema: JsonSchemaSchema.optional().describe("Optional JSON Schema for validating edits and exposing downstream autocomplete. When omitted with metadataFrom: ai.extract and a direct whole-output data expression, the extract step schema is reused."),
15206
15207
  metadataFrom: HumanReviewMetadataFromSchema.optional(),
15208
+ lineageFrom: string2().regex(/^[A-Za-z0-9_-]+$/, "lineageFrom must be a step name").optional().describe("Name of the ai.extract step whose source lineage draws field boxes in the review. Needed only when data passes through a step that changes field paths. Without it, boxes come from the step in a direct `{{ steps.<name>.output }}` data reference, or, when that step is a transform.script, from the one whole step output it received whose field paths it kept."),
15207
15209
  fieldMetadata: record(HumanReviewJsonPointerSchema, HumanReviewFieldMetadataInputSchema).default({}).optional().describe("RFC 6901 pointer map of producer facts (labels, confidence, display). Selection policy belongs under selection.fields; fieldMetadata.review is a legacy alias."),
15208
15210
  selection: HumanReviewSelectionInputSchema,
15209
15211
  files: HumanReviewFilesSchema.default({ includeRunInputs: true, attachments: [] }).optional().describe("Run input files and optional current-run attachments for reviewers"),
@@ -15522,7 +15524,7 @@ var init_extract = __esm(() => {
15522
15524
  }).refine((data) => data.content || data.text || data.structured !== undefined, {
15523
15525
  message: "Either content, text, or structured must be provided"
15524
15526
  });
15525
- ExtractOutputSchema = record(string2(), unknown()).describe('Extracted structured data matching the provided schema. Unless grounding is disabled (grounded: false), the output also carries a reserved `_grounding` map keyed by dotted field path: `_grounding["line_items.0.amount"] = { confidence: high|medium|low, score?, needsReview, reason?, quote?, citations?, source_span }`, plus reserved `_degraded: true` / `_reason` markers when grounding could not run the shared algorithm or the Eigenpal text pass. Lineage is never included in this JSON.');
15527
+ ExtractOutputSchema = record(string2(), unknown()).describe('Extracted structured data matching the provided schema. Unless grounding is disabled (grounded: false), the output also carries a reserved `_grounding` map keyed by dotted field path: `_grounding["line_items.0.amount"] = { confidence: high|medium|low, score?, recognitionScore?, needsReview, reason?, quote?, citations?, source_span }`. When the parsed document carries per-word OCR confidence, `recognitionScore` is the recognition of the cited words and caps the field: `score` never exceeds it, below 0.8 the field is low, below 0.9 at most medium. The map also holds reserved `_degraded: true` / `_reason` markers when grounding could not run the shared algorithm or the Eigenpal text pass. Lineage is never included in this JSON.');
15526
15528
  ExtractConfigSchema = object({
15527
15529
  schema: record(string2(), unknown()).describe("JSON Schema defining the structure to extract. Fields not listed in `required` come back null when the document does not contain them; a missing required field fails the step."),
15528
15530
  prompt: string2().optional().describe("Custom prompt template for extraction"),
@@ -54298,7 +54300,7 @@ var init_step_configs = __esm(() => {
54298
54300
  })).optional().describe("Optional few-shot examples pinning grounding to verbatim source text per field."),
54299
54301
  reviewOn: _enum(["medium_or_low", "low_only"]).optional().describe("Which grounding confidences set needsReview on a field. Default: low_only (only fields whose value could not be located in the source). Use medium_or_low to also flag approximate and derived matches.")
54300
54302
  });
54301
- AiExtractOutputSchema = record(string2(), unknown()).describe('Extracted structured data matching the provided schema. Unless grounding is disabled (grounded: false), the output also carries a reserved `_grounding` map keyed by dotted field path: `_grounding["line_items.0.amount"] = { confidence: high|medium|low, score?, needsReview, reason?, quote?, citations?, source_span }`, plus reserved `_degraded: true` / `_reason` markers when grounding could not run the shared algorithm or the Eigenpal text pass. Lineage is never included in this JSON.');
54303
+ AiExtractOutputSchema = record(string2(), unknown()).describe('Extracted structured data matching the provided schema. Unless grounding is disabled (grounded: false), the output also carries a reserved `_grounding` map keyed by dotted field path: `_grounding["line_items.0.amount"] = { confidence: high|medium|low, score?, recognitionScore?, needsReview, reason?, quote?, citations?, source_span }`. When the parsed document carries per-word OCR confidence, `recognitionScore` is the recognition of the cited words and caps the field: `score` never exceeds it, below 0.8 the field is low, below 0.9 at most medium. The map also holds reserved `_degraded: true` / `_reason` markers when grounding could not run the shared algorithm or the Eigenpal text pass. Lineage is never included in this JSON.');
54302
54304
  VisionPageRangeSchema = tuple([number2().int().min(0), number2().int().min(0)]).describe("Inclusive 0-based [start, end] page range, matching ai.split page_range.");
54303
54305
  AiVisionConfigSchema = object({
54304
54306
  document: string2().describe("Template expression resolving to the input file (PDF, image, or Office document)."),
@@ -215662,7 +215664,7 @@ function toPutBody(body) {
215662
215664
  // package.json
215663
215665
  var package_default = {
215664
215666
  name: "@eigenpal/cli",
215665
- version: "0.23.2",
215667
+ version: "0.23.5",
215666
215668
  description: "Eigenpal CLI — author and run document workflows from your terminal. Agent-ready.",
215667
215669
  keywords: [
215668
215670
  "eigenpal",
@@ -215763,11 +215765,13 @@ function buildCliTelemetryHeaders() {
215763
215765
  class ApiError extends Error {
215764
215766
  status;
215765
215767
  body;
215766
- constructor(status, body) {
215768
+ retryAfterSeconds;
215769
+ constructor(status, body, retryAfterSeconds) {
215767
215770
  const msg = typeof body === "object" && body !== null && "error" in body ? body.error : `HTTP ${status}`;
215768
215771
  super(msg);
215769
215772
  this.status = status;
215770
215773
  this.body = body;
215774
+ this.retryAfterSeconds = retryAfterSeconds;
215771
215775
  this.name = "ApiError";
215772
215776
  }
215773
215777
  }
@@ -215786,15 +215790,50 @@ function assertNotHtml(res, resolvedUrl) {
215786
215790
  throw new HtmlResponseError(resolvedUrl);
215787
215791
  }
215788
215792
  }
215793
+ var DEFAULT_RATE_LIMIT_RETRY = {
215794
+ maxRetries: 3,
215795
+ baseDelayMs: 1000,
215796
+ maxDelayMs: 30000,
215797
+ sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms))
215798
+ };
215799
+ function parseRetryAfterSeconds(header, now = Date.now()) {
215800
+ if (!header)
215801
+ return;
215802
+ const trimmed = header.trim();
215803
+ if (/^\d+$/.test(trimmed))
215804
+ return Number(trimmed);
215805
+ const at = Date.parse(trimmed);
215806
+ if (Number.isNaN(at))
215807
+ return;
215808
+ return Math.max(0, Math.ceil((at - now) / 1000));
215809
+ }
215789
215810
 
215790
215811
  class ApiClient {
215791
215812
  baseUrl;
215792
215813
  apiKey;
215793
215814
  tenantId;
215794
- constructor(config) {
215815
+ retry;
215816
+ constructor(config, options = {}) {
215795
215817
  this.baseUrl = config.baseUrl;
215796
215818
  this.apiKey = config.apiKey;
215797
215819
  this.tenantId = config.tenantId;
215820
+ this.retry = { ...DEFAULT_RATE_LIMIT_RETRY, ...options.rateLimitRetry };
215821
+ }
215822
+ async send(url, init, replayable = true) {
215823
+ for (let attempt = 0;; attempt++) {
215824
+ const res = await fetch(url, init);
215825
+ if (res.status !== 429 || !replayable || attempt >= this.retry.maxRetries)
215826
+ return res;
215827
+ const retryAfter = parseRetryAfterSeconds(res.headers.get("retry-after"));
215828
+ const delayMs = retryAfter !== undefined ? retryAfter * 1000 : Math.min(this.retry.baseDelayMs * 2 ** attempt, this.retry.maxDelayMs);
215829
+ if (delayMs > this.retry.maxDelayMs)
215830
+ return res;
215831
+ await res.body?.cancel().catch(() => {
215832
+ return;
215833
+ });
215834
+ dim(`Rate limited by the server, retrying in ${Math.ceil(delayMs / 1000)}s (${attempt + 1} of ${this.retry.maxRetries})`);
215835
+ await this.retry.sleep(delayMs);
215836
+ }
215798
215837
  }
215799
215838
  buildUrl(path) {
215800
215839
  return resolveRequestUrl(this.baseUrl, path);
@@ -215820,7 +215859,7 @@ class ApiClient {
215820
215859
  } catch {
215821
215860
  body = `HTTP ${res.status}`;
215822
215861
  }
215823
- throw new ApiError(res.status, body);
215862
+ throw new ApiError(res.status, body, parseRetryAfterSeconds(res.headers.get("retry-after")));
215824
215863
  }
215825
215864
  if (contentType.includes("json")) {
215826
215865
  return res.json();
@@ -215834,12 +215873,12 @@ class ApiClient {
215834
215873
  if (qs)
215835
215874
  url += `?${qs}`;
215836
215875
  }
215837
- const res = await fetch(url, { headers: this.headers() });
215876
+ const res = await this.send(url, { headers: this.headers() });
215838
215877
  return this.handleResponse(res, url);
215839
215878
  }
215840
215879
  async post(path, body) {
215841
215880
  const url = this.buildUrl(path);
215842
- const res = await fetch(url, {
215881
+ const res = await this.send(url, {
215843
215882
  method: "POST",
215844
215883
  headers: this.headers({ "Content-Type": "application/json" }),
215845
215884
  body: body !== undefined ? JSON.stringify(body) : undefined
@@ -215848,7 +215887,7 @@ class ApiClient {
215848
215887
  }
215849
215888
  async put(path, body) {
215850
215889
  const url = this.buildUrl(path);
215851
- const res = await fetch(url, {
215890
+ const res = await this.send(url, {
215852
215891
  method: "PUT",
215853
215892
  headers: this.headers({ "Content-Type": "application/json" }),
215854
215893
  body: body !== undefined ? JSON.stringify(body) : undefined
@@ -215864,12 +215903,12 @@ class ApiClient {
215864
215903
  body,
215865
215904
  ...stream ? { duplex: "half" } : {}
215866
215905
  };
215867
- const res = await fetch(url, init);
215906
+ const res = await this.send(url, init, !stream);
215868
215907
  return this.handleResponse(res, url);
215869
215908
  }
215870
215909
  async patch(path, body) {
215871
215910
  const url = this.buildUrl(path);
215872
- const res = await fetch(url, {
215911
+ const res = await this.send(url, {
215873
215912
  method: "PATCH",
215874
215913
  headers: this.headers({ "Content-Type": "application/json" }),
215875
215914
  body: JSON.stringify(body)
@@ -215878,7 +215917,7 @@ class ApiClient {
215878
215917
  }
215879
215918
  async postFormData(path, formData) {
215880
215919
  const url = this.buildUrl(path);
215881
- const res = await fetch(url, {
215920
+ const res = await this.send(url, {
215882
215921
  method: "POST",
215883
215922
  headers: this.headers(),
215884
215923
  body: formData
@@ -215887,7 +215926,7 @@ class ApiClient {
215887
215926
  }
215888
215927
  async putFormData(path, formData) {
215889
215928
  const url = this.buildUrl(path);
215890
- const res = await fetch(url, {
215929
+ const res = await this.send(url, {
215891
215930
  method: "PUT",
215892
215931
  headers: this.headers(),
215893
215932
  body: formData
@@ -215896,7 +215935,7 @@ class ApiClient {
215896
215935
  }
215897
215936
  async patchFormData(path, formData) {
215898
215937
  const url = this.buildUrl(path);
215899
- const res = await fetch(url, {
215938
+ const res = await this.send(url, {
215900
215939
  method: "PATCH",
215901
215940
  headers: this.headers(),
215902
215941
  body: formData
@@ -215905,7 +215944,7 @@ class ApiClient {
215905
215944
  }
215906
215945
  async delete(path) {
215907
215946
  const url = this.buildUrl(path);
215908
- const res = await fetch(url, {
215947
+ const res = await this.send(url, {
215909
215948
  method: "DELETE",
215910
215949
  headers: this.headers()
215911
215950
  });
@@ -215913,18 +215952,18 @@ class ApiClient {
215913
215952
  }
215914
215953
  async getStream(path) {
215915
215954
  const url = this.buildUrl(path);
215916
- const res = await fetch(url, {
215955
+ const res = await this.send(url, {
215917
215956
  headers: this.headers()
215918
215957
  });
215919
215958
  assertNotHtml(res, url);
215920
215959
  if (!res.ok) {
215921
- throw new ApiError(res.status, `Failed to download: HTTP ${res.status}`);
215960
+ throw new ApiError(res.status, `Failed to download: HTTP ${res.status}`, parseRetryAfterSeconds(res.headers.get("retry-after")));
215922
215961
  }
215923
215962
  return res;
215924
215963
  }
215925
215964
  async postStream(path, body) {
215926
215965
  const url = this.buildUrl(path);
215927
- const res = await fetch(url, {
215966
+ const res = await this.send(url, {
215928
215967
  method: "POST",
215929
215968
  headers: this.headers({ "Content-Type": "application/json" }),
215930
215969
  body: body !== undefined ? JSON.stringify(body) : undefined
@@ -215934,7 +215973,7 @@ class ApiClient {
215934
215973
  }
215935
215974
  async postFormDataStream(path, formData) {
215936
215975
  const url = this.buildUrl(path);
215937
- const res = await fetch(url, {
215976
+ const res = await this.send(url, {
215938
215977
  method: "POST",
215939
215978
  headers: this.headers(),
215940
215979
  body: formData
@@ -215972,10 +216011,16 @@ function isConnectionFailure(err) {
215972
216011
  }
215973
216012
  return false;
215974
216013
  }
216014
+ function formatRateLimited(err) {
216015
+ const wait = err.retryAfterSeconds !== undefined ? `Wait ${err.retryAfterSeconds}s and try again.` : "Wait a moment and try again.";
216016
+ return `Rate limit exceeded (HTTP 429). ${wait}`;
216017
+ }
215975
216018
  function formatCliError(err, context) {
215976
216019
  if (err instanceof HtmlResponseError)
215977
216020
  return err.message;
215978
216021
  if (err instanceof ApiError) {
216022
+ if (err.status === 429)
216023
+ return formatRateLimited(err);
215979
216024
  if (err.status === 401) {
215980
216025
  return `${err.message}
215981
216026
  Run \`eigenpal auth login\` or set EIGENPAL_API_KEY.`;
@@ -215995,6 +216040,14 @@ function printApiError(err, context) {
215995
216040
  error2(err.message);
215996
216041
  return;
215997
216042
  }
216043
+ if (err instanceof ApiError && err.status === 429) {
216044
+ error2(formatRateLimited(err));
216045
+ const requestId = err.body?.requestId;
216046
+ if (requestId)
216047
+ process.stderr.write(`${ui.dim("request id:")} ${requestId}
216048
+ `);
216049
+ return;
216050
+ }
215998
216051
  if (err && typeof err === "object" && "body" in err) {
215999
216052
  const body = err.body;
216000
216053
  if (body?.issues && body.issues.length > 0) {
@@ -221490,6 +221543,34 @@ import { createHash as createHash4 } from "node:crypto";
221490
221543
  import { promises as fs16, readFileSync as readFileSync13 } from "node:fs";
221491
221544
  import path15 from "node:path";
221492
221545
 
221546
+ // src/lib/workflow-rows.ts
221547
+ function nonEmptyString(value) {
221548
+ return typeof value === "string" && value.length > 0 ? value : null;
221549
+ }
221550
+ function asRow(row) {
221551
+ return row && typeof row === "object" ? row : {};
221552
+ }
221553
+ function workflowRowName(row) {
221554
+ const r = asRow(row);
221555
+ return nonEmptyString(r.name) ?? nonEmptyString(r.currentVersion?.definition?.name);
221556
+ }
221557
+ function workflowRowDescription(row) {
221558
+ const r = asRow(row);
221559
+ return nonEmptyString(r.description) ?? nonEmptyString(r.currentVersion?.definition?.description);
221560
+ }
221561
+ function workflowRowVersion(row) {
221562
+ const r = asRow(row);
221563
+ return nonEmptyString(r.version) ?? nonEmptyString(r.currentVersion?.version) ?? nonEmptyString(r.workflowVersion);
221564
+ }
221565
+ function withWorkflowRowFields(row) {
221566
+ return {
221567
+ ...row,
221568
+ name: workflowRowName(row),
221569
+ description: workflowRowDescription(row),
221570
+ version: workflowRowVersion(row)
221571
+ };
221572
+ }
221573
+
221493
221574
  // src/lib/resolve-workflow.ts
221494
221575
  var WORKFLOW_ID_PREFIX = "wf_";
221495
221576
  function looksLikeWorkflowId(value) {
@@ -221528,7 +221609,7 @@ async function findSimilarSlug(client, slug) {
221528
221609
  search: slug,
221529
221610
  limit: "20"
221530
221611
  });
221531
- const candidates = (res.data ?? []).map((w) => w.name).filter((n) => typeof n === "string" && n.length > 0);
221612
+ const candidates = (res.data ?? []).map((w) => workflowRowName(w)).filter((n) => n !== null);
221532
221613
  let best = null;
221533
221614
  for (const candidate of candidates) {
221534
221615
  const distance = levenshtein(candidate, slug, 2);
@@ -256908,6 +256989,25 @@ function descriptionFor(tool) {
256908
256989
  function printJson6(value) {
256909
256990
  console.log(JSON.stringify(value, null, 2));
256910
256991
  }
256992
+ function renderWorkflowDetail(row) {
256993
+ const steps = row.currentVersion?.definition?.steps;
256994
+ const fields = [
256995
+ ["version", row.version ?? "-"],
256996
+ ["versionId", row.currentVersion?.id ?? "-"],
256997
+ ["description", row.description ?? "-"],
256998
+ ["folder", row.folderPath ?? "/"],
256999
+ ["steps", Array.isArray(steps) ? String(steps.length) : "-"],
257000
+ ["api", row.apiEnabled === undefined ? "-" : row.apiEnabled ? "enabled" : "disabled"],
257001
+ ["access", row.myAccess ?? "-"],
257002
+ ["updatedAt", formatTimestamp(row.updatedAt)],
257003
+ ["createdAt", formatTimestamp(row.createdAt)]
257004
+ ];
257005
+ const width = Math.max(...fields.map(([key]) => key.length));
257006
+ console.log(`${ui.bold(row.name ?? row.id)} ${ui.dim(`(${row.id})`)}`);
257007
+ for (const [key, value] of fields) {
257008
+ console.log(` ${ui.dim(key.padEnd(width))} ${value}`);
257009
+ }
257010
+ }
256911
257011
  function extractWorkflowVersion(yaml) {
256912
257012
  const match = yaml.match(/^version:\s*['"]?(\d+\.\d+\.\d+)['"]?\s*$/m);
256913
257013
  return match ? match[1] : null;
@@ -257016,13 +257116,36 @@ function registerWorkflowCoreCommands(parent) {
257016
257116
  if (opts.search)
257017
257117
  params.search = opts.search;
257018
257118
  const raw = await client.get("/api/workflows", params);
257019
- renderListResult(raw, [
257119
+ const listed = {
257120
+ ...raw,
257121
+ data: (raw?.data ?? []).map((row) => withWorkflowRowFields(row))
257122
+ };
257123
+ renderListResult(listed, [
257020
257124
  { key: "id", header: "id" },
257021
257125
  { key: "name", header: "name", format: (v) => typeof v === "string" ? v : "-" },
257022
257126
  { key: "version", header: "version", format: (v) => typeof v === "string" ? v : "-" },
257023
257127
  { key: "updatedAt", header: "updatedAt", format: formatTimestamp }
257024
257128
  ], { ...opts, entityLabel: "workflow" });
257025
257129
  }));
257130
+ const getCmd = parent.command("get <workflow-id>").description("Show one workflow: name, current version, folder and your access level.").addHelpText("after", `
257131
+ Examples:
257132
+ $ eigenpal workflow get wf_abc123
257133
+ $ eigenpal workflow get my-extraction --json | jq '{ id, name, version }'
257134
+
257135
+ \`--json\` prints the full server record with \`name\`, \`description\` and
257136
+ \`version\` lifted to the top level; the current YAML is under
257137
+ \`currentVersion.yamlContent\`. Use \`workflow pull\` to write the YAML to a
257138
+ file and \`workflow versions list\` for the version history.
257139
+ `);
257140
+ addJsonFlag(withBaseUrl(getCmd)).action(action(async (workflow, opts) => {
257141
+ const { client, workflowId } = await buildClientForWorkflow(workflow, opts);
257142
+ const row = withWorkflowRowFields(await client.get(`/api/workflows/${workflowId}`));
257143
+ if (opts.json) {
257144
+ printJson6(row);
257145
+ return;
257146
+ }
257147
+ renderWorkflowDetail(row);
257148
+ }));
257026
257149
  const pullCmd = parent.command("pull <workflow-id>").description(descriptionFor("workflow_get_definition")).option("--out <path>", "Write YAML to file instead of stdout");
257027
257150
  withBaseUrl(pullCmd).action(action(async (workflow, opts) => {
257028
257151
  const { client, workflowId } = await buildClientForWorkflow(workflow, opts);
@@ -257056,15 +257179,17 @@ Examples:
257056
257179
  $ eigenpal workflow push --file workflow.yaml --workflow-id wf_abc123
257057
257180
  $ eigenpal workflow push --file workflow.yaml --workflow-id wf_abc123 --bump patch
257058
257181
  $ eigenpal workflow push --file workflow.yaml --workflow-id wf_abc123 --set-version 2.0.0
257059
- $ eigenpal workflow push --file workflow.yaml --json | jq '.id'
257182
+ $ WF=$(eigenpal workflow push --file workflow.yaml --json | jq -r '.id')
257060
257183
 
257061
257184
  Update path requires the YAML to carry a top-level \`version: X.Y.Z\`, OR for
257062
257185
  \`--bump\` / \`--set-version\` to be passed (they splice the resolved semver
257063
257186
  into the YAML before sending so the file-on-disk doesn't have to be edited
257064
257187
  per push). Passing both an explicit \`version:\` in the YAML and
257065
257188
  \`--bump\` / \`--set-version\` on the command line is rejected.
257189
+ \`--json\` prints \`{ id, name, version, versionId, created }\` on both create
257190
+ and update, so \`jq -r .id\` is always the workflow id.
257066
257191
  Re-pushing byte-identical YAML for an existing version with \`--json\` is a
257067
- no-op reporting \`{ unchanged: true, workflowId, version }\` (exit 0);
257192
+ no-op reporting the same shape plus \`unchanged: true\` (exit 0);
257068
257193
  without \`--json\` — or with differing content — it stays a
257069
257194
  version-conflict error.
257070
257195
  \`--set-version\` is the long form because the global \`-v, --version\`
@@ -257133,8 +257258,7 @@ new uploads are deleted. The file on disk is not rewritten.
257133
257258
  if (opts.setVersion) {
257134
257259
  nextVersion = opts.setVersion;
257135
257260
  } else if (opts.bump) {
257136
- const wf = await client.get(`/api/workflows/${workflowId}`);
257137
- const current = wf?.version;
257261
+ const current = workflowRowVersion(await client.get(`/api/workflows/${workflowId}`));
257138
257262
  if (!current) {
257139
257263
  throw new Error(`Cannot --bump ${opts.bump} on ${workflowId}: server has no current version. Push an initial version (with \`--set-version 1.0.0\` or a YAML \`version:\` field) first.`);
257140
257264
  }
@@ -257178,11 +257302,18 @@ new uploads are deleted. The file on disk is not rewritten.
257178
257302
  version: nextVersion
257179
257303
  });
257180
257304
  await finalizeCreatedWorkspaceTemplates(client, created);
257305
+ const summary = workflowPushSummary({
257306
+ workflowId,
257307
+ created: false,
257308
+ version: result,
257309
+ localName: definition.name,
257310
+ fallbackVersion: nextVersion ?? null
257311
+ });
257181
257312
  if (opts.json) {
257182
- printJson6(withLocalTemplates(result, resolvedTemplates));
257313
+ printJson6(withPushExtras(summary, result.warnings, resolvedTemplates));
257183
257314
  return;
257184
257315
  }
257185
- success(`Pushed ${ui.bold(workflowId)} (v${result.version ?? nextVersion})`);
257316
+ success(`Pushed ${ui.bold(workflowId)} (v${summary.version ?? "?"})`);
257186
257317
  printSchemaQualityWarnings2(result.warnings);
257187
257318
  } else {
257188
257319
  const yamlToSend = opts.setVersion && !extractWorkflowVersion(yamlWithTemplates) ? spliceWorkflowVersion2(yamlWithTemplates, opts.setVersion) : yamlWithTemplates;
@@ -257192,13 +257323,18 @@ new uploads are deleted. The file on disk is not rewritten.
257192
257323
  ...createVersion ? { version: createVersion } : {}
257193
257324
  });
257194
257325
  await finalizeCreatedWorkspaceTemplates(client, created);
257326
+ const summary = workflowPushSummary({
257327
+ workflowId: result.workflow?.id ?? null,
257328
+ created: true,
257329
+ version: result.version,
257330
+ localName: definition.name,
257331
+ fallbackVersion: createVersion ?? null
257332
+ });
257195
257333
  if (opts.json) {
257196
- printJson6(withLocalTemplates(result, resolvedTemplates));
257334
+ printJson6(withPushExtras(summary, result.warnings, resolvedTemplates));
257197
257335
  return;
257198
257336
  }
257199
- const id = result.workflow?.id ?? result.id ?? "?";
257200
- const ver = result.version?.version ?? result.workflow?.currentVersion?.version ?? result.currentVersion?.version ?? "?";
257201
- success(`Created ${ui.bold(id)} (v${ver})`);
257337
+ success(`Created ${ui.bold(summary.id ?? "?")} (v${summary.version ?? "?"})`);
257202
257338
  printSchemaQualityWarnings2(result.warnings);
257203
257339
  }
257204
257340
  } catch (err) {
@@ -257261,6 +257397,23 @@ function withLocalTemplates(result, resolved) {
257261
257397
  return result;
257262
257398
  return { ...result, localTemplates: resolved };
257263
257399
  }
257400
+ function workflowPushSummary(args) {
257401
+ const serverName = args.version?.definition?.name;
257402
+ return {
257403
+ id: args.workflowId,
257404
+ name: typeof serverName === "string" && serverName ? serverName : args.localName ?? null,
257405
+ version: args.version?.version ?? args.fallbackVersion,
257406
+ versionId: args.version?.id ?? null,
257407
+ created: args.created
257408
+ };
257409
+ }
257410
+ function withPushExtras(summary, warnings, resolved) {
257411
+ return {
257412
+ ...summary,
257413
+ ...warnings && warnings.length > 0 ? { warnings } : {},
257414
+ ...resolved.length > 0 ? { localTemplates: resolved } : {}
257415
+ };
257416
+ }
257264
257417
  function parseWorkflowOrThrow(yamlText) {
257265
257418
  try {
257266
257419
  return parseWorkflow(yamlText);
@@ -257302,7 +257455,14 @@ async function preflightVersionConflict(client, workflowId, nextVersion, opts) {
257302
257455
  if (opts?.json && opts.yamlToSend !== undefined) {
257303
257456
  const current = await client.get(`/api/workflows/${workflowId}`);
257304
257457
  if (current?.currentVersion?.version === nextVersion && normalizeYamlForCompare(current.currentVersion.yamlContent) === normalizeYamlForCompare(opts.yamlToSend)) {
257305
- printJson6({ unchanged: true, workflowId, version: nextVersion });
257458
+ const summary = workflowPushSummary({
257459
+ workflowId,
257460
+ created: false,
257461
+ version: current.currentVersion,
257462
+ localName: workflowRowName(current),
257463
+ fallbackVersion: nextVersion
257464
+ });
257465
+ printJson6({ ...summary, unchanged: true, workflowId });
257306
257466
  return true;
257307
257467
  }
257308
257468
  }
@@ -258443,7 +258603,8 @@ function registerStepTypeCommands(parent) {
258443
258603
  { key: "name", header: "name" }
258444
258604
  ], { json: opts.json, entityLabel: "step type" });
258445
258605
  });
258446
- stepType.command("get <type>").description(descriptionFor("workflow_get_step_type")).option("--out <path>", "Write to file", undefined).action(async (type, opts) => {
258606
+ const getCmd = stepType.command("get <type>").description(descriptionFor("workflow_get_step_type")).option("--out <path>", "Write to file", undefined);
258607
+ addJsonFlag(getCmd).action(async (type, opts) => {
258447
258608
  await Promise.resolve().then(() => init_src());
258448
258609
  await Promise.resolve().then(() => init_zod());
258449
258610
  const def = getStepSchema(type);