@swmansion/argent 0.32.1-next.10 → 0.32.1-next.12

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/client.d.ts CHANGED
@@ -12,6 +12,11 @@ export interface ArgentToolResult<T = unknown> {
12
12
  data: T;
13
13
  /** Optional advisory note the tool attached to the result. */
14
14
  note?: string;
15
+ /**
16
+ * Why the call did not do its job though it returned, such as an e2e test
17
+ * that does not pass. See the tool-server API reference for the list.
18
+ */
19
+ failure?: string;
15
20
  }
16
21
  /**
17
22
  * A node of the `ui-tree` result. A flag is set only when true; a field named in
package/dist/client.js CHANGED
@@ -9025,6 +9025,8 @@ var FAILURE_CODES = {
9025
9025
  CLI_RUN_ARGS_JSON_INVALID: "CLI_RUN_ARGS_JSON_INVALID",
9026
9026
  CLI_RUN_INPUT_VALIDATION_FAILED: "CLI_RUN_INPUT_VALIDATION_FAILED",
9027
9027
  CLI_RUN_TOOL_CALL_FAILED: "CLI_RUN_TOOL_CALL_FAILED",
9028
+ // The result carried the tool-server's `failure` field.
9029
+ CLI_RUN_TOOL_RESULT_FAILED: "CLI_RUN_TOOL_RESULT_FAILED",
9028
9030
  CLI_RUN_SAVE_IMAGE_FAILED: "CLI_RUN_SAVE_IMAGE_FAILED",
9029
9031
  TOOL_CAPABILITY_UNSUPPORTED_OPERATION: "TOOL_CAPABILITY_UNSUPPORTED_OPERATION",
9030
9032
  TOOL_PLATFORM_NOT_IMPLEMENTED: "TOOL_PLATFORM_NOT_IMPLEMENTED",
@@ -9040,6 +9042,7 @@ var FAILURE_CODES = {
9040
9042
  INSTALL_MODE_FLAG_CONFLICT: "INSTALL_MODE_FLAG_CONFLICT",
9041
9043
  INSTALL_FROM_TAR_PACKAGE_FAILED: "INSTALL_FROM_TAR_PACKAGE_FAILED",
9042
9044
  INSTALL_INIT_TRIGGERED_UPDATE_FAILED: "INSTALL_INIT_TRIGGERED_UPDATE_FAILED",
9045
+ INSTALL_SKILLS_FAILED: "INSTALL_SKILLS_FAILED",
9043
9046
  INSTALL_SKILLS_REFRESH_FAILED: "INSTALL_SKILLS_REFRESH_FAILED",
9044
9047
  INSTALL_UNCLASSIFIED_FAILED: "INSTALL_UNCLASSIFIED_FAILED",
9045
9048
  UPDATE_INSTALLED_VERSION_DETECT_FAILED: "UPDATE_INSTALLED_VERSION_DETECT_FAILED",
@@ -10397,7 +10400,8 @@ async function consumeToolStream(name, body, onProgress, signal) {
10397
10400
  final = {
10398
10401
  data: msg.data,
10399
10402
  note: msg.note,
10400
- ...msg.profiling === true ? { profiling: true } : {}
10403
+ ...msg.profiling === true ? { profiling: true } : {},
10404
+ ...typeof msg.failure === "string" ? { failure: msg.failure } : {}
10401
10405
  };
10402
10406
  } else if (msg.event === "error") {
10403
10407
  throw new ToolInvocationError(msg.error ?? "tool invocation failed", {
@@ -10449,7 +10453,8 @@ async function consumeToolStream(name, body, onProgress, signal) {
10449
10453
  return {
10450
10454
  data: final.data,
10451
10455
  note: final.note,
10452
- ...final.profiling ? { profiling: true } : {}
10456
+ ...final.profiling ? { profiling: true } : {},
10457
+ ...final.failure !== void 0 ? { failure: final.failure } : {}
10453
10458
  };
10454
10459
  }
10455
10460
  function errorBodyMessage(body) {
@@ -10614,6 +10619,7 @@ function createToolsClient(options = {}) {
10614
10619
  }
10615
10620
  const shadowWarning = await e2eShadowWarningFor(name, args);
10616
10621
  const baselineDirs = [];
10622
+ let unwrittenBaselines = [];
10617
10623
  if (meta?.fileInputs?.length) {
10618
10624
  if (remote) assertRequiredPresent(meta, finalArgs);
10619
10625
  finalArgs = await prepareFileInputs(meta.fileInputs, finalArgs ?? {}, {
@@ -10627,8 +10633,9 @@ function createToolsClient(options = {}) {
10627
10633
  signal: opts?.signal
10628
10634
  });
10629
10635
  }
10630
- const settle = async (data) => {
10631
- const applied = await applyClientFileDirectives(data, { allowedDirs: baselineDirs });
10636
+ const settle = async (data2) => {
10637
+ const applied = await applyClientFileDirectives(data2, { allowedDirs: baselineDirs });
10638
+ unwrittenBaselines = applied.failed.map((f) => f.path);
10632
10639
  for (const { path: file, error } of applied.failed) {
10633
10640
  diagnose(`The baseline ${file} was not written on this client: ${error}`);
10634
10641
  }
@@ -10645,6 +10652,7 @@ function createToolsClient(options = {}) {
10645
10652
  }
10646
10653
  return { ...result, warning: shadowWarning };
10647
10654
  };
10655
+ const unwrittenFailure = () => unwrittenBaselines.length > 0 ? `Baselines not written on this client: ${unwrittenBaselines.join(", ")}` : void 0;
10648
10656
  const stream = opts?.onProgress !== void 0 || carriesMembers(finalArgs);
10649
10657
  const sentOnce = carriesUpload(finalArgs);
10650
10658
  const forwarded = remote ? await forwardedSecrets(finalArgs) : void 0;
@@ -10708,11 +10716,14 @@ function createToolsClient(options = {}) {
10708
10716
  }),
10709
10717
  opts?.signal
10710
10718
  );
10719
+ const data2 = await settle(streamed.data);
10720
+ const failure2 = streamed.failure ?? unwrittenFailure();
10711
10721
  return {
10712
- data: await settle(streamed.data),
10722
+ data: data2,
10713
10723
  note: streamed.note,
10714
10724
  outputHint: meta?.outputHint,
10715
- ...streamed.profiling ? { profiling: true } : {}
10725
+ ...streamed.profiling ? { profiling: true } : {},
10726
+ ...failure2 !== void 0 ? { failure: failure2 } : {}
10716
10727
  };
10717
10728
  }
10718
10729
  let json;
@@ -10748,11 +10759,14 @@ function createToolsClient(options = {}) {
10748
10759
  });
10749
10760
  }
10750
10761
  opts?.signal?.throwIfAborted();
10762
+ const data = await settle(json.data);
10763
+ const failure = (typeof json.failure === "string" ? json.failure : void 0) ?? unwrittenFailure();
10751
10764
  return {
10752
- data: await settle(json.data),
10765
+ data,
10753
10766
  note: json.note,
10754
10767
  outputHint: meta?.outputHint,
10755
- ...json.profiling === true ? { profiling: true } : {}
10768
+ ...json.profiling === true ? { profiling: true } : {},
10769
+ ...failure !== void 0 ? { failure } : {}
10756
10770
  };
10757
10771
  }
10758
10772
  return { fetchTools, fetchTool, callTool, baseUrl };
@@ -11162,7 +11176,11 @@ function createArgentClient() {
11162
11176
  signal: options?.signal
11163
11177
  });
11164
11178
  options?.signal?.throwIfAborted();
11165
- return { data: result, note: response.note };
11179
+ return {
11180
+ data: result,
11181
+ note: response.note,
11182
+ ...response.failure !== void 0 ? { failure: response.failure } : {}
11183
+ };
11166
11184
  } catch (err) {
11167
11185
  if (err instanceof ToolInvocationError) {
11168
11186
  throw new ArgentToolError(err.message, {