@odla-ai/cli 0.16.1 → 0.16.2

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.cjs CHANGED
@@ -1995,10 +1995,10 @@ var import_node_fs7 = require("fs");
1995
1995
  var import_node_os = require("os");
1996
1996
  var import_node_path4 = require("path");
1997
1997
 
1998
- // ../harness/dist/chunk-UG5XHNFB.js
1998
+ // ../harness/dist/chunk-7SN5SG4N.js
1999
1999
  var HARNESS_PROTOCOL_VERSION = 1;
2000
2000
 
2001
- // ../harness/dist/chunk-QALIIZRJ.js
2001
+ // ../harness/dist/chunk-HX4QYGWE.js
2002
2002
  var CONTROL = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/;
2003
2003
  var HarnessProtocolError = class extends Error {
2004
2004
  name = "HarnessProtocolError";
@@ -2076,7 +2076,7 @@ function encodeAgentInput(message2) {
2076
2076
  `;
2077
2077
  }
2078
2078
 
2079
- // ../harness/dist/chunk-TA2FKK27.js
2079
+ // ../harness/dist/chunk-QWWRL7M4.js
2080
2080
  var import_child_process = require("child_process");
2081
2081
  var import_fs = require("fs");
2082
2082
  var import_promises2 = require("fs/promises");
@@ -2593,7 +2593,7 @@ async function stageWorkspacePair(baselineSource, workspaceSource, options = {})
2593
2593
  }
2594
2594
  }
2595
2595
 
2596
- // ../harness/dist/chunk-5E2R3LHE.js
2596
+ // ../harness/dist/chunk-T2RD6ZAW.js
2597
2597
  var import_crypto = require("crypto");
2598
2598
  var import_promises5 = require("fs/promises");
2599
2599
  var import_path5 = require("path");
@@ -2930,7 +2930,7 @@ function validateSnapshot(snapshot, limits) {
2930
2930
  }
2931
2931
  }
2932
2932
 
2933
- // ../harness/dist/chunk-5E2R3LHE.js
2933
+ // ../harness/dist/chunk-T2RD6ZAW.js
2934
2934
  var import_child_process4 = require("child_process");
2935
2935
  var import_promises6 = require("fs/promises");
2936
2936
  var import_path6 = require("path");
@@ -3223,7 +3223,7 @@ function looksLikeDestination(value) {
3223
3223
  return /^(?:[a-z][a-z0-9+.-]*:\/\/|\/|\\\\)/i.test(text) || /^[\w.-]+\.[a-z]{2,}(?:[/:]|$)/i.test(text);
3224
3224
  }
3225
3225
 
3226
- // ../harness/dist/chunk-5E2R3LHE.js
3226
+ // ../harness/dist/chunk-T2RD6ZAW.js
3227
3227
  var import_crypto4 = require("crypto");
3228
3228
  async function digestStagedWorkspace(root, limits) {
3229
3229
  const files = [];
@@ -4522,7 +4522,13 @@ var safeRuntimeJson = (value) => {
4522
4522
  };
4523
4523
  function runtimeResultText(value) {
4524
4524
  const record32 = runtimeRecord(value);
4525
- return record32 && typeof record32.text === "string" ? record32.text.slice(0, 2e4) : null;
4525
+ if (record32 && typeof record32.text === "string") return record32.text.slice(0, 2e4);
4526
+ if (record32 && typeof record32.error === "string") return `Pi failed: ${record32.error.slice(0, 19989)}`;
4527
+ return null;
4528
+ }
4529
+ function runtimeResultError(value) {
4530
+ const record32 = runtimeRecord(value);
4531
+ return record32 && typeof record32.error === "string" && record32.error.trim() ? record32.error.trim().slice(0, 2e3) : null;
4526
4532
  }
4527
4533
  var CodePiRuntimeEngine = class {
4528
4534
  constructor(options) {
@@ -4630,9 +4636,11 @@ var CodePiRuntimeEngine = class {
4630
4636
  }, conversationRefs);
4631
4637
  }
4632
4638
  active.done = this.#runAttempt(command, metadata2, active).catch(async (cause) => {
4633
- await this.#event(command, { type: "message", actor: "system", body: `Pi failed: ${runtimeErrorMessage(cause)}` }, conversationRefs).catch(() => void 0);
4639
+ const detail = runtimeErrorMessage(cause);
4640
+ await this.#event(command, { type: "message", actor: "system", body: `Pi failed: ${detail}` }, conversationRefs).catch(() => void 0);
4641
+ await this.#diagnostic(command, active, detail);
4634
4642
  await this.#event(command, { type: "status", status: "failed" }, conversationRefs).catch(() => void 0);
4635
- await this.#failure(command, active, runtimeErrorMessage(cause));
4643
+ await this.#failure(command, active, detail);
4636
4644
  return null;
4637
4645
  });
4638
4646
  return { status: "running", message: resume ? "Pi resumed from a portable checkpoint" : "Pi started" };
@@ -4657,13 +4665,15 @@ var CodePiRuntimeEngine = class {
4657
4665
  baseCommitSha: active.baseCommitSha,
4658
4666
  sourceTreeDigest: active.sourceTreeDigest
4659
4667
  }, active).catch(async (cause) => {
4668
+ const detail = runtimeErrorMessage(cause);
4660
4669
  await this.#event(
4661
4670
  command,
4662
- { type: "message", actor: "system", body: `Pi failed: ${runtimeErrorMessage(cause)}` },
4671
+ { type: "message", actor: "system", body: `Pi failed: ${detail}` },
4663
4672
  active.conversationRefs
4664
4673
  ).catch(() => void 0);
4674
+ await this.#diagnostic(command, active, detail);
4665
4675
  await this.#event(command, { type: "status", status: "failed" }, active.conversationRefs).catch(() => void 0);
4666
- await this.#failure(command, active, runtimeErrorMessage(cause));
4676
+ await this.#failure(command, active, detail);
4667
4677
  return null;
4668
4678
  });
4669
4679
  return { status: "running", message: "Pi accepted the owner prompt" };
@@ -4775,7 +4785,9 @@ var CodePiRuntimeEngine = class {
4775
4785
  durationMs: Date.now() - startedAt
4776
4786
  }, active.conversationRefs).catch(() => void 0);
4777
4787
  if (result.status === "failed") {
4778
- await this.#failure(command, active, result.stderr || "Pi container failed");
4788
+ const detail = (runtimeResultError(result.result) ?? result.stderr.trim()) || "Pi container failed";
4789
+ await this.#diagnostic(command, active, detail);
4790
+ await this.#failure(command, active, detail);
4779
4791
  }
4780
4792
  return result;
4781
4793
  }
@@ -4792,6 +4804,15 @@ var CodePiRuntimeEngine = class {
4792
4804
  await this.options.control.reportSessionFailure(command.sessionId, active.failure).catch(() => void 0);
4793
4805
  }
4794
4806
  }
4807
+ async #diagnostic(command, active, value) {
4808
+ const detail = value.trim().slice(0, 2e3) || "Pi runtime failed";
4809
+ this.options.onDiagnostic?.(detail);
4810
+ await this.#event(
4811
+ command,
4812
+ { type: "diagnostic", level: "error", message: detail },
4813
+ active.conversationRefs
4814
+ ).catch(() => void 0);
4815
+ }
4795
4816
  async #event(command, event, refs) {
4796
4817
  await appendCodeRuntimeEvent(this.options.control, command, event, refs);
4797
4818
  }
@@ -5344,7 +5365,8 @@ async function runCodeRuntime(input) {
5344
5365
  image: CODE_PI_IMAGE,
5345
5366
  recipes: CODE_BUILD_RECIPES,
5346
5367
  recipeAuthorization: "registered_recipe",
5347
- localSource: input.localSource
5368
+ localSource: input.localSource,
5369
+ onDiagnostic: (message2) => input.stdout.error(`Pi runtime failed \xB7 ${message2}`)
5348
5370
  });
5349
5371
  const reconciler = new CodeRuntimeReconciler(control, commandEngine);
5350
5372
  try {