@uru-intelligence/cli 0.5.2 → 0.5.3

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
@@ -8,6 +8,8 @@
8
8
 
9
9
  - gem.validate and gem.build return a hosted job id immediately. Pass --wait to poll gem.build_job until the compile settles. — surfaces: cli, docs; reference: skills/uru-gems/SKILL.md
10
10
  - Action: Update agents and scripts that expected a compiler result from uru gems validate or uru gems build. Print or store hosted_job_id, then poll gem.build_job, or pass --wait.
11
+ - Registry-family commands (uru home, sharing, web, files, workspace, business-sql, datasets, distribution, library source) send --params-json fields exactly as the tool's input schema spells them. The camelCase-to-snake_case rewrite and its error are gone. — surfaces: cli, docs; reference: apps/cli/src/local-commands.ts
12
+ - Action: Send the field names uru <family> <operation> --get-schema or uru operations inspect <id> prints, for example target_id and idempotency_key, not targetId and idempotencyKey.
11
13
  - uru logs --follow now streams live lines over the server-sent stream only. The one-second poll fallback and the --poll-interval-ms flag on logs are gone. — surfaces: cli; reference: docs/research/gem-debugging-2026-09.md
12
14
  - Action: Drop --poll-interval-ms from uru logs and uru gems logs; the flag is rejected. --follow reads the recent page once, then follows the same stream the web Activity tab uses. When a Gem has no runtime log stream, the command now says so instead of polling.
13
15
 
@@ -88,6 +90,8 @@
88
90
  - Action: Prefer published CLI >= 0.4.15. Use uru sharing labels_list / label_create (or operations sharing.labels_list / sharing.label_create). library_fs read ops should point callers at library_query instead of an opaque safety refusal.
89
91
  - uru operations inspect <id> and uru <family> <verb> --get-schema print the operation's real input schema, narrowed to its op, with the op's examples, instead of Input schema: {}. — surfaces: cli; reference: URU-1425
90
92
  - Action: Nothing to change. A not-logged-in inspect prints a pointer to uru login and exits 0; operations ls stays local and schema-free.
93
+ - uru operations run and inspect accept the tool name that uru operations ls prints beside each operation id, invalid_tool_arguments names the failing fields of the operation that ran, and a retryable failure says it is temporary and how to retry a write safely. — surfaces: cli; reference: apps/cli/src/tool-failure-guidance.ts
94
+ - Action: Nothing to change. uru operations run home_pins_query --params-json '{"op":"pins_list"}' now runs home.pins_list; a tool name without a known op lists its operation ids. --json errors now carry retryable and the server details.
91
95
  - Use the shared SemVer contract when deciding whether to show a CLI update notice. — surfaces: cli, release; reference: docs/plans/cli-sdk-native-release-modernization/PLAN.md
92
96
  - Action: No action is required; prerelease and malformed registry versions now follow the same validation and ordering rules as release publication.
93
97
 
package/README.md CHANGED
@@ -73,12 +73,12 @@ bun src/index.ts library rm 'library/Notes/Old.md'
73
73
  bun src/index.ts library restore 'library/Notes/Old.md'
74
74
  bun src/index.ts datasets ls --limit 50 --json
75
75
  bun src/index.ts datasets query revenue_rows --limit 50 --response-format concise --json
76
- # Registry-family commands accept canonical camelCase fields and adapt them at
77
- # the tool-protocol boundary.
76
+ # Registry-family commands send --params-json fields exactly as the tool's input
77
+ # schema spells them. Read that schema with --get-schema or `uru operations inspect <id>`.
78
78
  bun src/index.ts datasets get revenue-rows
79
79
  bun src/index.ts datasets history revenue-rows --limit 20
80
80
  bun src/index.ts datasets jobs revenue-rows --limit 20
81
- bun src/index.ts datasets rows --params-json '{"op":"upsert","datasetId":"revenue-rows","rows":[{"name":"Acme"}]}'
81
+ bun src/index.ts datasets rows --params-json '{"op":"upsert","dataset_id":"revenue-rows","rows":[{"name":"Acme"}]}'
82
82
  bun src/index.ts datasets create --params-json '{"title":"Revenue Rows","properties":[{"clientKey":"name","name":"Name","type":"title","required":true,"nullable":false,"position":0,"config":{}}]}'
83
83
  bun src/index.ts datasets sql --params-json '{"sql":"SELECT 1"}'
84
84
  bun src/index.ts distribution list --limit 20
package/dist/library.mjs CHANGED
@@ -15899,6 +15899,7 @@ var zDatasetListRowsResponse = object({
15899
15899
  limit: int(),
15900
15900
  nextCursor: string2().nullish(),
15901
15901
  offset: int(),
15902
+ revision: string2().regex(/^(0|[1-9][0-9]{0,19})$/).optional(),
15902
15903
  rows: array(object({
15903
15904
  createdAt: string2().optional(),
15904
15905
  deleted: boolean2().optional(),
@@ -15923,6 +15924,7 @@ var zDatasetListRowsResponse = object({
15923
15924
  total: int().nullable()
15924
15925
  });
15925
15926
  var zDatasetUpsertRowsBody = object({
15927
+ expectedDatasetRevision: string2().regex(/^(0|[1-9][0-9]{0,19})$/).optional(),
15926
15928
  idempotencyKey: string2().min(1).max(128).optional(),
15927
15929
  rows: array(record(string2(), union([
15928
15930
  string2(),
@@ -15947,6 +15949,8 @@ var zDatasetUpsertRowsResponse = object({
15947
15949
  updatedIds: array(string2().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/))
15948
15950
  });
15949
15951
  var zDatasetDeleteRowsBody = object({
15952
+ expectedDatasetRevision: string2().regex(/^(0|[1-9][0-9]{0,19})$/).optional(),
15953
+ idempotencyKey: string2().min(1).max(128).optional(),
15950
15954
  rowIds: array(string2().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/)).max(1000).optional().default([])
15951
15955
  });
15952
15956
  var zDatasetDeleteRowsPath = object({
@@ -16024,6 +16028,8 @@ var zDatasetSubmitRowsMutationResponse = object({
16024
16028
  ])
16025
16029
  });
16026
16030
  var zDatasetRestoreRowsBody = object({
16031
+ expectedDatasetRevision: string2().regex(/^(0|[1-9][0-9]{0,19})$/).optional(),
16032
+ idempotencyKey: string2().min(1).max(128).optional(),
16027
16033
  rowIds: array(string2().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/)).max(1000).optional().default([])
16028
16034
  });
16029
16035
  var zDatasetRestoreRowsPath = object({
@@ -17561,7 +17567,7 @@ function pickString(record2, keys) {
17561
17567
  // package.json
17562
17568
  var package_default = {
17563
17569
  name: "@uru-intelligence/cli",
17564
- version: "0.5.2",
17570
+ version: "0.5.3",
17565
17571
  private: false,
17566
17572
  description: "Uru full-platform command line interface",
17567
17573
  repository: {
@@ -17641,6 +17647,9 @@ class CliError extends Error {
17641
17647
  suggestedCommand;
17642
17648
  errorId;
17643
17649
  httpStatus;
17650
+ retryable;
17651
+ tip;
17652
+ details;
17644
17653
  constructor(message, options = {}) {
17645
17654
  super(message, options.cause === undefined ? undefined : { cause: options.cause });
17646
17655
  this.name = "CliError";
@@ -17658,6 +17667,15 @@ class CliError extends Error {
17658
17667
  if (options.httpStatus !== undefined) {
17659
17668
  this.httpStatus = options.httpStatus;
17660
17669
  }
17670
+ if (options.retryable === true) {
17671
+ this.retryable = true;
17672
+ }
17673
+ if (options.tip !== undefined) {
17674
+ this.tip = options.tip;
17675
+ }
17676
+ if (options.details !== undefined) {
17677
+ this.details = options.details;
17678
+ }
17661
17679
  }
17662
17680
  }
17663
17681
  function defaultCliErrorCode(exitCode) {
@@ -17922,6 +17940,9 @@ function toolTransportError(body, requestBody) {
17922
17940
  const structured = {
17923
17941
  ...error2.errorCode === undefined ? {} : { errorCode: error2.errorCode },
17924
17942
  ...error2.errorId === undefined ? {} : { errorId: error2.errorId },
17943
+ ...error2.details === undefined ? {} : { details: error2.details },
17944
+ ...error2.tip === undefined ? {} : { tip: error2.tip },
17945
+ ...isTransientFailure(status, body) ? { retryable: true } : {},
17925
17946
  httpStatus: status
17926
17947
  };
17927
17948
  if (status === 409) {
@@ -18056,13 +18077,28 @@ function apiError(status, payload, requestBody) {
18056
18077
  "error_code"
18057
18078
  ]);
18058
18079
  const errorId = pickStringFromJsonValue(envelope, ["errorId", "error_id"]);
18080
+ const serverDetails = isRecord(envelope) ? envelope["details"] : undefined;
18081
+ const tip = serverTip(envelope);
18059
18082
  return new CliError(message, {
18083
+ ...tip === undefined ? {} : { tip: stripTerminalControl(redactValues(tip, redactions)) },
18060
18084
  code: status === 401 ? ExitCode.AuthRequired : ExitCode.Failure,
18061
18085
  errorCode: backendCode ?? (status === 401 ? "auth_required" : status === 403 ? "permission_denied" : "api_request_failed"),
18062
18086
  httpStatus: status,
18063
- ...errorId === undefined ? {} : { errorId }
18087
+ ...errorId === undefined ? {} : { errorId },
18088
+ ...isTransientFailure(status, payload) ? { retryable: true } : {},
18089
+ ...serverDetails !== undefined && isJsonObject(serverDetails) ? { details: serverDetails } : {}
18064
18090
  });
18065
18091
  }
18092
+ function isTransientFailure(status, payload) {
18093
+ if (status === 429 || status === 503) {
18094
+ return true;
18095
+ }
18096
+ if (!isRecord(payload)) {
18097
+ return false;
18098
+ }
18099
+ const nested = payload["error"];
18100
+ return payload["retryable"] === true || isRecord(nested) && nested["retryable"] === true;
18101
+ }
18066
18102
  function pickStringFromJsonValue(value, keys) {
18067
18103
  return isRecord(value) ? pickString(value, keys) : undefined;
18068
18104
  }
@@ -18100,16 +18136,23 @@ function errorDetails(payload) {
18100
18136
  if (code !== undefined) {
18101
18137
  details.push(`Code: ${code}`);
18102
18138
  }
18103
- const tip = pickString(payload, ["tip"]);
18104
- if (tip !== undefined) {
18105
- details.push(`Tip: ${tip}`);
18106
- }
18107
18139
  const nested = payload["details"];
18108
18140
  if (isJsonObject(nested)) {
18109
18141
  details.push(...errorDetails(nested));
18110
18142
  }
18111
18143
  return [...new Set(details)];
18112
18144
  }
18145
+ function serverTip(payload) {
18146
+ if (!isRecord(payload)) {
18147
+ return;
18148
+ }
18149
+ const tip = pickString(payload, ["tip"]);
18150
+ if (tip !== undefined) {
18151
+ return tip;
18152
+ }
18153
+ const nested = payload["details"];
18154
+ return isJsonObject(nested) ? serverTip(nested) : undefined;
18155
+ }
18113
18156
  function collectSensitiveValues(value) {
18114
18157
  if (value === undefined || value === null) {
18115
18158
  return [];
package/dist/uru.mjs CHANGED
@@ -3052,7 +3052,7 @@ function spec(id, summary, auth, workspace, safety, outputModes, cancellation =
3052
3052
  // package.json
3053
3053
  var package_default = {
3054
3054
  name: "@uru-intelligence/cli",
3055
- version: "0.5.2",
3055
+ version: "0.5.3",
3056
3056
  private: false,
3057
3057
  description: "Uru full-platform command line interface",
3058
3058
  repository: {
@@ -3132,6 +3132,9 @@ class CliError extends Error {
3132
3132
  suggestedCommand;
3133
3133
  errorId;
3134
3134
  httpStatus;
3135
+ retryable;
3136
+ tip;
3137
+ details;
3135
3138
  constructor(message, options = {}) {
3136
3139
  super(message, options.cause === undefined ? undefined : { cause: options.cause });
3137
3140
  this.name = "CliError";
@@ -3149,8 +3152,32 @@ class CliError extends Error {
3149
3152
  if (options.httpStatus !== undefined) {
3150
3153
  this.httpStatus = options.httpStatus;
3151
3154
  }
3155
+ if (options.retryable === true) {
3156
+ this.retryable = true;
3157
+ }
3158
+ if (options.tip !== undefined) {
3159
+ this.tip = options.tip;
3160
+ }
3161
+ if (options.details !== undefined) {
3162
+ this.details = options.details;
3163
+ }
3152
3164
  }
3153
3165
  }
3166
+ function refineCliError(error, refinement) {
3167
+ const tip = refinement.tip ?? error.tip;
3168
+ return new CliError(refinement.message ?? error.message, {
3169
+ code: error.exitCode,
3170
+ errorCode: error.errorCode,
3171
+ cause: error,
3172
+ ...error.errorId === undefined ? {} : { errorId: error.errorId },
3173
+ ...error.httpStatus === undefined ? {} : { httpStatus: error.httpStatus },
3174
+ ...error.confirmationRequired === true ? { confirmationRequired: true } : {},
3175
+ ...error.suggestedCommand === undefined ? {} : { suggestedCommand: error.suggestedCommand },
3176
+ ...error.retryable === true ? { retryable: true } : {},
3177
+ ...error.details === undefined ? {} : { details: error.details },
3178
+ ...tip === undefined ? {} : { tip }
3179
+ });
3180
+ }
3154
3181
  function defaultCliErrorCode(exitCode) {
3155
3182
  switch (exitCode) {
3156
3183
  case ExitCode.Cancelled:
@@ -19265,6 +19292,7 @@ var zDatasetListRowsResponse = object({
19265
19292
  limit: int(),
19266
19293
  nextCursor: string2().nullish(),
19267
19294
  offset: int(),
19295
+ revision: string2().regex(/^(0|[1-9][0-9]{0,19})$/).optional(),
19268
19296
  rows: array(object({
19269
19297
  createdAt: string2().optional(),
19270
19298
  deleted: boolean2().optional(),
@@ -19289,6 +19317,7 @@ var zDatasetListRowsResponse = object({
19289
19317
  total: int().nullable()
19290
19318
  });
19291
19319
  var zDatasetUpsertRowsBody = object({
19320
+ expectedDatasetRevision: string2().regex(/^(0|[1-9][0-9]{0,19})$/).optional(),
19292
19321
  idempotencyKey: string2().min(1).max(128).optional(),
19293
19322
  rows: array(record(string2(), union([
19294
19323
  string2(),
@@ -19313,6 +19342,8 @@ var zDatasetUpsertRowsResponse = object({
19313
19342
  updatedIds: array(string2().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/))
19314
19343
  });
19315
19344
  var zDatasetDeleteRowsBody = object({
19345
+ expectedDatasetRevision: string2().regex(/^(0|[1-9][0-9]{0,19})$/).optional(),
19346
+ idempotencyKey: string2().min(1).max(128).optional(),
19316
19347
  rowIds: array(string2().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/)).max(1000).optional().default([])
19317
19348
  });
19318
19349
  var zDatasetDeleteRowsPath = object({
@@ -19390,6 +19421,8 @@ var zDatasetSubmitRowsMutationResponse = object({
19390
19421
  ])
19391
19422
  });
19392
19423
  var zDatasetRestoreRowsBody = object({
19424
+ expectedDatasetRevision: string2().regex(/^(0|[1-9][0-9]{0,19})$/).optional(),
19425
+ idempotencyKey: string2().min(1).max(128).optional(),
19393
19426
  rowIds: array(string2().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/)).max(1000).optional().default([])
19394
19427
  });
19395
19428
  var zDatasetRestoreRowsPath = object({
@@ -21282,6 +21315,9 @@ function toolTransportError(body, requestBody) {
21282
21315
  const structured = {
21283
21316
  ...error2.errorCode === undefined ? {} : { errorCode: error2.errorCode },
21284
21317
  ...error2.errorId === undefined ? {} : { errorId: error2.errorId },
21318
+ ...error2.details === undefined ? {} : { details: error2.details },
21319
+ ...error2.tip === undefined ? {} : { tip: error2.tip },
21320
+ ...isTransientFailure(status, body) ? { retryable: true } : {},
21285
21321
  httpStatus: status
21286
21322
  };
21287
21323
  if (status === 409) {
@@ -21513,13 +21549,28 @@ function apiError(status, payload, requestBody) {
21513
21549
  "error_code"
21514
21550
  ]);
21515
21551
  const errorId = pickStringFromJsonValue(envelope, ["errorId", "error_id"]);
21552
+ const serverDetails = isRecord(envelope) ? envelope["details"] : undefined;
21553
+ const tip = serverTip(envelope);
21516
21554
  return new CliError(message, {
21555
+ ...tip === undefined ? {} : { tip: stripTerminalControl(redactValues(tip, redactions)) },
21517
21556
  code: status === 401 ? ExitCode.AuthRequired : ExitCode.Failure,
21518
21557
  errorCode: backendCode ?? (status === 401 ? "auth_required" : status === 403 ? "permission_denied" : "api_request_failed"),
21519
21558
  httpStatus: status,
21520
- ...errorId === undefined ? {} : { errorId }
21559
+ ...errorId === undefined ? {} : { errorId },
21560
+ ...isTransientFailure(status, payload) ? { retryable: true } : {},
21561
+ ...serverDetails !== undefined && isJsonObject(serverDetails) ? { details: serverDetails } : {}
21521
21562
  });
21522
21563
  }
21564
+ function isTransientFailure(status, payload) {
21565
+ if (status === 429 || status === 503) {
21566
+ return true;
21567
+ }
21568
+ if (!isRecord(payload)) {
21569
+ return false;
21570
+ }
21571
+ const nested = payload["error"];
21572
+ return payload["retryable"] === true || isRecord(nested) && nested["retryable"] === true;
21573
+ }
21523
21574
  function pickStringFromJsonValue(value, keys) {
21524
21575
  return isRecord(value) ? pickString(value, keys) : undefined;
21525
21576
  }
@@ -21557,16 +21608,23 @@ function errorDetails(payload) {
21557
21608
  if (code !== undefined) {
21558
21609
  details.push(`Code: ${code}`);
21559
21610
  }
21560
- const tip = pickString(payload, ["tip"]);
21561
- if (tip !== undefined) {
21562
- details.push(`Tip: ${tip}`);
21563
- }
21564
21611
  const nested = payload["details"];
21565
21612
  if (isJsonObject(nested)) {
21566
21613
  details.push(...errorDetails(nested));
21567
21614
  }
21568
21615
  return [...new Set(details)];
21569
21616
  }
21617
+ function serverTip(payload) {
21618
+ if (!isRecord(payload)) {
21619
+ return;
21620
+ }
21621
+ const tip = pickString(payload, ["tip"]);
21622
+ if (tip !== undefined) {
21623
+ return tip;
21624
+ }
21625
+ const nested = payload["details"];
21626
+ return isJsonObject(nested) ? serverTip(nested) : undefined;
21627
+ }
21570
21628
  function collectSensitiveValues(value) {
21571
21629
  if (value === undefined || value === null) {
21572
21630
  return [];
@@ -22443,6 +22501,7 @@ No generated CLI operations are registered for family ${family}.
22443
22501
  Generated ${family} operations:
22444
22502
  ${operations}
22445
22503
 
22504
+ Send the fields exactly as \`uru ${command} <operation> --get-schema\` prints them.
22446
22505
  Run \`uru operations run <operation-id> --params-json|--args-json '{...}'\` for the fully
22447
22506
  qualified operation form.
22448
22507
  `;
@@ -23642,6 +23701,103 @@ function nonEmptyString(value) {
23642
23701
 
23643
23702
  // src/cli-runtime.ts
23644
23703
  import { dirname } from "node:path";
23704
+
23705
+ // src/tool-failure-guidance.ts
23706
+ async function explainToolFailure(input) {
23707
+ const { error: error2, operation, params } = input;
23708
+ if (error2.errorCode === "invalid_tool_arguments") {
23709
+ const lines = invalidArgumentLines(operation, params, error2.details, await input.loadInputSchema());
23710
+ return refineCliError(error2, {
23711
+ ...lines.length === 0 ? {} : { message: `${error2.message} ${lines.join(" ")}` },
23712
+ tip: `Run \`uru operations inspect ${operation.id}\` to read this operation's exact input schema, then send its field names unchanged.`
23713
+ });
23714
+ }
23715
+ if (error2.retryable === true) {
23716
+ return error2.tip === undefined ? refineCliError(error2, { tip: retryTip(operation, params) }) : error2;
23717
+ }
23718
+ return error2;
23719
+ }
23720
+ function retryTip(operation, params) {
23721
+ if (operation.safety === "read") {
23722
+ return "This failure is temporary. This operation only reads, so it is safe to run the same command again. Wait a few seconds first.";
23723
+ }
23724
+ const key = params["idempotency_key"];
23725
+ if (typeof key === "string" && key !== "") {
23726
+ return `This failure is temporary. Run the same command again with the same idempotency_key (${JSON.stringify(key)}): the server uses the key to apply the change only once, so the retry cannot apply it twice.`;
23727
+ }
23728
+ return `This failure is temporary. The change may already have applied. This write carried no idempotency_key, so a retry could apply it twice. If \`uru operations inspect ${operation.id}\` lists idempotency_key, add one to --params-json and reuse it on every retry. If it does not, check the current state before you retry.`;
23729
+ }
23730
+ function invalidArgumentLines(operation, params, details, schema) {
23731
+ const fields = operationFields(schema);
23732
+ const lines = [];
23733
+ if (fields !== undefined) {
23734
+ const missing = fields.required.filter((name) => name !== "op" && !Object.hasOwn(params, name));
23735
+ const unknown2 = Object.keys(params).filter((name) => name !== "op" && !fields.properties.has(name));
23736
+ if (missing.length > 0) {
23737
+ lines.push(`Missing required fields: ${missing.join(", ")}.`);
23738
+ }
23739
+ if (unknown2.length > 0) {
23740
+ lines.push(`Fields not in this operation's input schema: ${unknown2.join(", ")}.`);
23741
+ }
23742
+ }
23743
+ const pathLine = mismatchPathLine(details, fields);
23744
+ if (pathLine !== undefined) {
23745
+ lines.push(pathLine);
23746
+ }
23747
+ return lines.length > 0 ? lines : serverReportLines(operation, details);
23748
+ }
23749
+ function operationFields(schema) {
23750
+ const properties = schema?.["properties"];
23751
+ if (schema === undefined || !isSchemaObject2(properties)) {
23752
+ return;
23753
+ }
23754
+ const required3 = schema["required"];
23755
+ return {
23756
+ properties: new Set(Object.keys(properties)),
23757
+ required: Array.isArray(required3) ? required3.filter((name) => typeof name === "string") : []
23758
+ };
23759
+ }
23760
+ function mismatchPathLine(details, fields) {
23761
+ const path = stringDetail(details, "first_mismatch_path");
23762
+ const keyword = stringDetail(details, "first_mismatch_keyword");
23763
+ if (path === undefined || path === "" || path === "/" || keyword === undefined) {
23764
+ return;
23765
+ }
23766
+ const topField = path.split("/")[1];
23767
+ if (fields !== undefined && (topField === undefined || !fields.properties.has(topField))) {
23768
+ return;
23769
+ }
23770
+ const property = stringDetail(details, "first_mismatch_property");
23771
+ return keyword === "required" && property !== undefined ? `Field ${path} is missing required field "${property}".` : `Field ${path} failed the schema rule "${keyword}".`;
23772
+ }
23773
+ function serverReportLines(operation, details) {
23774
+ const lines = [];
23775
+ const path = stringDetail(details, "first_mismatch_path");
23776
+ const property = stringDetail(details, "first_mismatch_property");
23777
+ if ((path === "/" || path === "") && stringDetail(details, "first_mismatch_keyword") === "required" && property !== undefined) {
23778
+ lines.push(`First failing field: ${property} (required).`);
23779
+ } else {
23780
+ const pathLine = mismatchPathLine(details, undefined);
23781
+ if (pathLine !== undefined) {
23782
+ lines.push(pathLine);
23783
+ }
23784
+ }
23785
+ const missing = details?.["missing_required"];
23786
+ const missingNames = Array.isArray(missing) ? missing.filter((name) => typeof name === "string") : [];
23787
+ if (missingNames.length > 0) {
23788
+ lines.push(operation.backendOp === undefined ? `Required fields the server found missing: ${missingNames.join(", ")}.` : `Required fields the server found missing, across every operation of ${operation.backendToolName}: ${missingNames.join(", ")}.`);
23789
+ }
23790
+ return lines;
23791
+ }
23792
+ function stringDetail(details, key) {
23793
+ const value = details?.[key];
23794
+ return typeof value === "string" ? value : undefined;
23795
+ }
23796
+ function isSchemaObject2(value) {
23797
+ return typeof value === "object" && value !== null && !Array.isArray(value);
23798
+ }
23799
+
23800
+ // src/cli-runtime.ts
23645
23801
  function cliStateHome(ctx) {
23646
23802
  return dirname(ctx.store.path);
23647
23803
  }
@@ -23673,6 +23829,38 @@ async function emitGemTool(ctx, operationId, params, options = {}) {
23673
23829
  return emitTool(ctx, operationId, params, options);
23674
23830
  }
23675
23831
  async function emitTool(ctx, operationId, params, options = {}) {
23832
+ try {
23833
+ return await emitToolOutput(ctx, operationId, params, options);
23834
+ } catch (error2) {
23835
+ throw await explainOperationFailure(ctx, operationId, params, error2);
23836
+ }
23837
+ }
23838
+ async function explainOperationFailure(ctx, operationId, params, error2) {
23839
+ const operation = getPlatformOperation(operationId);
23840
+ if (!(error2 instanceof CliError) || operation === undefined) {
23841
+ return error2;
23842
+ }
23843
+ return explainToolFailure({
23844
+ error: error2,
23845
+ operation,
23846
+ params,
23847
+ loadInputSchema: () => narrowedOperationInputSchema(ctx, operation)
23848
+ });
23849
+ }
23850
+ async function narrowedOperationInputSchema(ctx, operation) {
23851
+ if (getCliNativeOperationContract(operation.id) !== undefined) {
23852
+ return;
23853
+ }
23854
+ let rawSchema;
23855
+ try {
23856
+ rawSchema = await client(ctx).getToolSchema(operation.backendToolName);
23857
+ } catch {
23858
+ return;
23859
+ }
23860
+ const inputSchema = isJsonObject2(rawSchema) ? rawSchema["inputSchema"] : undefined;
23861
+ return isJsonObject2(inputSchema) ? narrowToolInputSchemaToOperation(inputSchema, operation.backendOp) : undefined;
23862
+ }
23863
+ async function emitToolOutput(ctx, operationId, params, options) {
23676
23864
  if (ctx.outputFormat === "stream-json" && options.streamStart !== undefined) {
23677
23865
  writeStreamJson(ctx.io, "started", options.streamStart);
23678
23866
  writeStreamJson(ctx.io, "phase", {
@@ -23954,11 +24142,15 @@ function assertToolResultSuccess(value) {
23954
24142
  ].filter((detail) => detail !== undefined);
23955
24143
  const tip = stringField2(value, ["tip"]);
23956
24144
  const errorId = stringField2(value, ["errorId", "error_id"]);
23957
- throw new CliError(`${message}${details.length === 0 ? "" : ` ${details.join(" ")}`}${tip === undefined ? "" : ` ${tip}`}`, {
24145
+ const serverDetails = value["details"] ?? value["errorDetails"];
24146
+ throw new CliError(`${message}${details.length === 0 ? "" : ` ${details.join(" ")}`}`, {
24147
+ ...tip === undefined ? {} : { tip },
23958
24148
  code: httpStatus === 409 ? ExitCode.Conflict : httpStatus === 401 || httpStatus === 403 ? ExitCode.AuthRequired : ExitCode.Failure,
23959
24149
  ...errorCode === undefined ? {} : { errorCode },
23960
24150
  ...errorId === undefined ? {} : { errorId },
23961
- ...httpStatus === undefined ? {} : { httpStatus }
24151
+ ...httpStatus === undefined ? {} : { httpStatus },
24152
+ ...isTransientFailure(httpStatus ?? 0, value) ? { retryable: true } : {},
24153
+ ...isJsonObject2(serverDetails) ? { details: serverDetails } : {}
23962
24154
  });
23963
24155
  }
23964
24156
  function isToolResultEnvelope(value) {
@@ -24656,19 +24848,18 @@ async function dispatchOperations(ctx, sub, args) {
24656
24848
  return;
24657
24849
  }
24658
24850
  if (sub === "inspect") {
24659
- const operationId = requireCommandValue(args[0], "Usage: uru operations inspect <operation-id>");
24660
- const operation = getPlatformOperation(operationId);
24661
- if (operation === undefined) {
24662
- throw new CliError(`Unknown operation: ${operationId}. Run \`uru operations ls\`.`);
24663
- }
24851
+ const reference = requireCommandValue(args[0], "Usage: uru operations inspect <operation-id>");
24852
+ const operation = resolveOperationReference(reference, "inspect", undefined);
24664
24853
  const { contract, text } = await operationContractForInspect(ctx, operation);
24665
24854
  emitValue(ctx, contract, text);
24666
24855
  return;
24667
24856
  }
24668
24857
  if (sub === "run") {
24858
+ const reference = requireCommandValue(args[0], "Usage: uru operations run <operation-id> --params-json '{...}'");
24859
+ const params = await paramsJson(args.slice(1), ["operations", "run"], paramsJsonOptions(ctx));
24860
+ const operation = resolveOperationReference(reference, "run", params);
24669
24861
  await withWorkspace(ctx);
24670
- const operationId = requireCommandValue(args[0], "Usage: uru operations run <operation-id> --params-json '{...}'");
24671
- await emitTool(ctx, operationId, await paramsJson(args.slice(1), ["operations", "run"], paramsJsonOptions(ctx)));
24862
+ await emitTool(ctx, operation.id, params);
24672
24863
  return;
24673
24864
  }
24674
24865
  throw new CliError("Usage: uru operations ls [--family <family>] | inspect <operation-id> | run <operation-id> --params-json {...}");
@@ -24685,43 +24876,31 @@ async function dispatchRegistryFamily(ctx, family, sub, args) {
24685
24876
  emitValue(ctx, contract, text);
24686
24877
  return;
24687
24878
  }
24688
- await emitTool(ctx, operation.id, adaptRegistryFamilyParams(await paramsJson(args, commandPath, paramsJsonOptions(ctx))));
24689
- }
24690
- function adaptRegistryFamilyParams(params) {
24691
- const adapted = {};
24692
- for (const [key, value] of Object.entries(params)) {
24693
- const protocolKey = canonicalCliFieldToToolProtocol(key);
24694
- if (Object.hasOwn(adapted, protocolKey)) {
24695
- throw new CliError(`--params-json contains ambiguous aliases for ${protocolKey}. Use canonical camelCase CLI fields only.`);
24696
- }
24697
- adapted[protocolKey] = value;
24698
- }
24699
- return adapted;
24700
- }
24701
- var REGISTRY_FAMILY_SNAKE_CASE_ALIASES = new Set([
24702
- "automation_id",
24703
- "dataset_ids",
24704
- "idempotency_key",
24705
- "item_id",
24706
- "label_id",
24707
- "label_value",
24708
- "max_results",
24709
- "source_id",
24710
- "connection_id",
24711
- "target_folder_id",
24712
- "drive_id",
24713
- "file_ids",
24714
- "folder_ids",
24715
- "sync_interval_minutes"
24716
- ]);
24717
- function canonicalCliFieldToToolProtocol(key) {
24718
- if (REGISTRY_FAMILY_SNAKE_CASE_ALIASES.has(key)) {
24719
- return key;
24879
+ await emitTool(ctx, operation.id, await paramsJson(args, commandPath, paramsJsonOptions(ctx)));
24880
+ }
24881
+ function resolveOperationReference(reference, verb, params) {
24882
+ const byId = getPlatformOperation(reference);
24883
+ if (byId !== undefined) {
24884
+ return byId;
24885
+ }
24886
+ const toolName = reference.trim().toLowerCase();
24887
+ const candidates = platformOperationsForSurface("cli").filter((operation) => operation.backendToolName.toLowerCase() === toolName);
24888
+ const [first] = candidates;
24889
+ if (first === undefined) {
24890
+ throw new CliError(`Unknown operation: ${reference}. Run \`uru operations ls\`.`);
24891
+ }
24892
+ const rawOp = params?.["op"];
24893
+ const op2 = typeof rawOp === "string" ? rawOp.trim().toLowerCase() : undefined;
24894
+ const [match, ...others] = candidates.filter((operation) => operation.backendOp === undefined ? op2 === undefined : operation.backendOp.toLowerCase() === op2);
24895
+ if (match !== undefined && others.length === 0) {
24896
+ return match;
24720
24897
  }
24721
- if (!/^[a-z][A-Za-z0-9]*$/u.test(key)) {
24722
- throw new CliError(`--params-json field ${JSON.stringify(key)} is not canonical camelCase. Registry-family commands accept canonical CLI fields and adapt them at the tool-protocol boundary.`);
24898
+ if (op2 === undefined && candidates.length === 1) {
24899
+ return first;
24723
24900
  }
24724
- return key.replace(/[A-Z]/g, (character) => `_${character.toLowerCase()}`);
24901
+ const listed = candidates.map((operation) => operation.backendOp === undefined ? operation.id : `${operation.id} (op=${operation.backendOp})`).join(", ");
24902
+ const next = verb === "run" ? `Pass one of those ops in --params-json, or use the operation id: \`uru operations run ${first.id} --params-json '{...}'\`.` : `Inspect one by its operation id: \`uru operations inspect ${first.id}\`.`;
24903
+ throw new CliError(`${reference} is a tool name, not an operation id${op2 === undefined ? "" : `, and op=${op2} is not one of its operations`}. Its operations: ${listed}. ${next}`);
24725
24904
  }
24726
24905
  async function dispatchLibrary(ctx, sub, args) {
24727
24906
  if (sub === "ls") {
@@ -24862,14 +25041,14 @@ async function dispatchLibrarySource(ctx, verb, args) {
24862
25041
  return;
24863
25042
  }
24864
25043
  if (normalizedVerb === "create") {
24865
- const params = adaptRegistryFamilyParams(await paramsJson(args, ["library", "source", "create"], paramsJsonOptions(ctx)));
25044
+ const params = await paramsJson(args, ["library", "source", "create"], paramsJsonOptions(ctx));
24866
25045
  await emitTool(ctx, "library.sources_create", params);
24867
25046
  return;
24868
25047
  }
24869
25048
  if (normalizedVerb === "edit") {
24870
25049
  const flags = parseLocalFlags(args, ["library", "source", "edit"]);
24871
25050
  const sourceId = requireCommandValue(flags.positionals[0], "Usage: uru library source edit <source-id> --params-json '{...}'");
24872
- const params = adaptRegistryFamilyParams(await paramsJson(args, ["library", "source", "edit"], paramsJsonOptions(ctx)));
25051
+ const params = await paramsJson(args, ["library", "source", "edit"], paramsJsonOptions(ctx));
24873
25052
  params["source_id"] = sourceId;
24874
25053
  await emitTool(ctx, "library.sources_edit", params);
24875
25054
  return;
@@ -24893,7 +25072,7 @@ async function dispatchLibrarySource(ctx, verb, args) {
24893
25072
  if (normalizedVerb === "reconnect") {
24894
25073
  const flags = parseLocalFlags(args, ["library", "source", "reconnect"]);
24895
25074
  const sourceId = requireCommandValue(flags.positionals[0], "Usage: uru library source reconnect <source-id> --params-json '{...}'");
24896
- const params = adaptRegistryFamilyParams(await paramsJson(args, ["library", "source", "reconnect"], paramsJsonOptions(ctx)));
25075
+ const params = await paramsJson(args, ["library", "source", "reconnect"], paramsJsonOptions(ctx));
24897
25076
  params["source_id"] = sourceId;
24898
25077
  await emitTool(ctx, "library.sources_reconnect", params);
24899
25078
  return;
@@ -25108,7 +25287,7 @@ async function dispatchDatasets(ctx, sub, args) {
25108
25287
  return;
25109
25288
  }
25110
25289
  if (sub === "create" || sub === "update" || sub === "rows" || sub === "restore" || sub === "sql" || sub === "sql-write") {
25111
- const params = adaptRegistryFamilyParams(await paramsJson(args, ["datasets", sub], paramsJsonOptions(ctx)));
25290
+ const params = await paramsJson(args, ["datasets", sub], paramsJsonOptions(ctx));
25112
25291
  let operationId;
25113
25292
  if (sub === "rows") {
25114
25293
  const rowOperation = params["op"];
@@ -25165,7 +25344,7 @@ async function dispatchDatasetCommand(ctx, sub, args) {
25165
25344
  if (sub === "query") {
25166
25345
  const explicitParams = flags.values["--params-json"];
25167
25346
  if (explicitParams !== undefined) {
25168
- const params2 = adaptRegistryFamilyParams(parseParamsJson(await readParamsJsonSource(explicitParams, paramsJsonOptions(ctx)), "--params-json"));
25347
+ const params2 = parseParamsJson(await readParamsJsonSource(explicitParams, paramsJsonOptions(ctx)), "--params-json");
25169
25348
  params2["dataset_id"] ??= datasetId;
25170
25349
  await emitTool(ctx, "dataset.query", params2);
25171
25350
  return;
@@ -25264,7 +25443,7 @@ async function dispatchDatasetSourceCommand(ctx, verb, args) {
25264
25443
  if (normalizedVerb === "put" || normalizedVerb === "test") {
25265
25444
  const flags = parseLocalFlags(args, ["datasets", "source", normalizedVerb]);
25266
25445
  const datasetId = requireCommandValue(flags.positionals[0], `Usage: uru datasets source ${normalizedVerb} <dataset-id> --params-json '{...}'`);
25267
- const params = adaptRegistryFamilyParams(await paramsJson(args, ["datasets", "source", normalizedVerb], paramsJsonOptions(ctx)));
25446
+ const params = await paramsJson(args, ["datasets", "source", normalizedVerb], paramsJsonOptions(ctx));
25268
25447
  params["dataset_id"] ??= datasetId;
25269
25448
  await emitTool(ctx, normalizedVerb === "put" ? "dataset.external_source_put" : "dataset.external_source_test", params);
25270
25449
  return;
@@ -25285,7 +25464,7 @@ async function dispatchDatasetSourceCommand(ctx, verb, args) {
25285
25464
  const flags = parseLocalFlags(args, ["datasets", "source", "sync"]);
25286
25465
  const datasetId = requireCommandValue(flags.positionals[0], "Usage: uru datasets source sync|run-now <dataset-id> [--params-json '{...}']");
25287
25466
  const explicitParams = flags.values["--params-json"];
25288
- const params = explicitParams === undefined ? {} : adaptRegistryFamilyParams(parseParamsJson(await readParamsJsonSource(explicitParams, paramsJsonOptions(ctx)), "--params-json"));
25467
+ const params = explicitParams === undefined ? {} : parseParamsJson(await readParamsJsonSource(explicitParams, paramsJsonOptions(ctx)), "--params-json");
25289
25468
  params["dataset_id"] = datasetId;
25290
25469
  params["idempotency_key"] ??= flags.values["--idempotency-key"] ?? randomUUID();
25291
25470
  if (params["expected_dataset_revision"] === undefined || params["expected_schema_revision"] === undefined) {
@@ -25804,7 +25983,7 @@ async function dispatchDistributionLinkCreate(ctx, args) {
25804
25983
  }
25805
25984
  function distributionParams(flags) {
25806
25985
  const raw = flags.values["--params-json"];
25807
- return raw === undefined ? {} : adaptRegistryFamilyParams(parseParamsJson(raw, "--params-json"));
25986
+ return raw === undefined ? {} : parseParamsJson(raw, "--params-json");
25808
25987
  }
25809
25988
 
25810
25989
  // src/mcp-commands.ts
@@ -31942,13 +32121,15 @@ function sourceSensitiveTip(errorCode, source) {
31942
32121
  return source === "explicit" ? "This token was supplied for this invocation, so `uru login` cannot replace it. The server refused the token itself: check that it is still valid and that it may act in the workspace this command targets." : "Run `uru login`, pass `--token`, or set `URU_TOKEN` before retrying.";
31943
32122
  }
31944
32123
  function cliErrorJson(error2, source = "stored") {
31945
- const tip = tipForErrorCode(error2.errorCode, source);
32124
+ const tip = tipForError(error2, source);
31946
32125
  return {
31947
32126
  error: error2.message,
31948
32127
  code: error2.errorCode,
31949
32128
  exitCode: error2.exitCode,
31950
32129
  ...error2.errorId === undefined ? {} : { errorId: error2.errorId },
31951
32130
  ...error2.httpStatus === undefined ? {} : { httpStatus: error2.httpStatus },
32131
+ ...error2.retryable === true ? { retryable: true } : {},
32132
+ ...error2.details === undefined ? {} : { details: error2.details },
31952
32133
  ...tip === undefined ? {} : { tip },
31953
32134
  docs: `${CLI_DOCS_URL}#${error2.errorCode}`,
31954
32135
  ...error2.confirmationRequired === true ? { confirmationRequired: true } : {},
@@ -31959,7 +32140,7 @@ function formatCliError(error2, source = "stored") {
31959
32140
  const lines = [
31960
32141
  `Error [${error2.errorCode}]: ${stripTerminalControl(error2.message)}`
31961
32142
  ];
31962
- const tip = tipForErrorCode(error2.errorCode, source);
32143
+ const tip = tipForError(error2, source);
31963
32144
  if (tip !== undefined) {
31964
32145
  lines.push(`Tip: ${tip}`);
31965
32146
  }
@@ -31968,8 +32149,9 @@ function formatCliError(error2, source = "stored") {
31968
32149
  `)}
31969
32150
  `;
31970
32151
  }
31971
- function tipForErrorCode(errorCode, source) {
31972
- return sourceSensitiveTip(errorCode, source) ?? ERROR_TIPS[errorCode];
32152
+ var RETRYABLE_TIP = "This failure is temporary. A read is safe to run again as it is. Retry a write only with the same idempotency_key, so the change cannot apply twice.";
32153
+ function tipForError(error2, source) {
32154
+ return sourceSensitiveTip(error2.errorCode, source) ?? error2.tip ?? (error2.retryable === true ? RETRYABLE_TIP : undefined) ?? ERROR_TIPS[error2.errorCode];
31973
32155
  }
31974
32156
 
31975
32157
  // src/terminal.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uru-intelligence/cli",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "private": false,
5
5
  "description": "Uru full-platform command line interface",
6
6
  "repository": {