@odla-ai/cli 0.16.0 → 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-4EM6NMET.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-4EM6NMET.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-4EM6NMET.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 = [];
@@ -3338,9 +3338,13 @@ function createCodeRuntimeControlClient(options) {
3338
3338
  if (!Number.isSafeInteger(requestTimeoutMs) || requestTimeoutMs < 1e3 || requestTimeoutMs > 12e4) {
3339
3339
  throw new TypeError("requestTimeoutMs must be an integer from 1000 to 120000");
3340
3340
  }
3341
+ const modelRequestTimeoutMs = options.modelRequestTimeoutMs ?? 15 * 6e4;
3342
+ if (!Number.isSafeInteger(modelRequestTimeoutMs) || modelRequestTimeoutMs < 3e4 || modelRequestTimeoutMs > 30 * 6e4) {
3343
+ throw new TypeError("modelRequestTimeoutMs must be an integer from 30000 to 1800000");
3344
+ }
3341
3345
  const request = options.fetch ?? fetch;
3342
- const call = async (path, body) => {
3343
- const timeout = AbortSignal.timeout(requestTimeoutMs);
3346
+ const call = async (path, body, timeoutMs = requestTimeoutMs) => {
3347
+ const timeout = AbortSignal.timeout(timeoutMs);
3344
3348
  const signal = options.signal ? AbortSignal.any([options.signal, timeout]) : timeout;
3345
3349
  let response2;
3346
3350
  try {
@@ -3379,14 +3383,18 @@ function createCodeRuntimeControlClient(options) {
3379
3383
  await call(`/registry/code/runtime/sessions/${validSessionId(sessionId)}/source`, {})
3380
3384
  ),
3381
3385
  infer: async (sessionId, inference) => {
3382
- const value = record3(await call(`/registry/code/runtime/sessions/${validSessionId(sessionId)}/inference`, inference));
3386
+ const value = record3(await call(
3387
+ `/registry/code/runtime/sessions/${validSessionId(sessionId)}/inference`,
3388
+ inference,
3389
+ modelRequestTimeoutMs
3390
+ ));
3383
3391
  if (!value || value.requestId !== inference.requestId || !record3(value.response) || !record3(value.receipt)) {
3384
3392
  throw new CodeRuntimeControlError("invalid Code inference response", 502, "invalid_response");
3385
3393
  }
3386
3394
  return value;
3387
3395
  },
3388
3396
  review: async (sessionId, review) => parseReview(
3389
- await call(`/registry/code/runtime/sessions/${validSessionId(sessionId)}/review`, review)
3397
+ await call(`/registry/code/runtime/sessions/${validSessionId(sessionId)}/review`, review, modelRequestTimeoutMs)
3390
3398
  ),
3391
3399
  submitCandidate: async (sessionId, checkpointId, verification) => {
3392
3400
  if (!/^cpoint_[0-9a-f]{32}$/.test(checkpointId)) throw new TypeError("invalid Code checkpoint id");
@@ -4514,7 +4522,13 @@ var safeRuntimeJson = (value) => {
4514
4522
  };
4515
4523
  function runtimeResultText(value) {
4516
4524
  const record32 = runtimeRecord(value);
4517
- 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;
4518
4532
  }
4519
4533
  var CodePiRuntimeEngine = class {
4520
4534
  constructor(options) {
@@ -4622,9 +4636,11 @@ var CodePiRuntimeEngine = class {
4622
4636
  }, conversationRefs);
4623
4637
  }
4624
4638
  active.done = this.#runAttempt(command, metadata2, active).catch(async (cause) => {
4625
- 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);
4626
4642
  await this.#event(command, { type: "status", status: "failed" }, conversationRefs).catch(() => void 0);
4627
- await this.#failure(command, active, runtimeErrorMessage(cause));
4643
+ await this.#failure(command, active, detail);
4628
4644
  return null;
4629
4645
  });
4630
4646
  return { status: "running", message: resume ? "Pi resumed from a portable checkpoint" : "Pi started" };
@@ -4649,13 +4665,15 @@ var CodePiRuntimeEngine = class {
4649
4665
  baseCommitSha: active.baseCommitSha,
4650
4666
  sourceTreeDigest: active.sourceTreeDigest
4651
4667
  }, active).catch(async (cause) => {
4668
+ const detail = runtimeErrorMessage(cause);
4652
4669
  await this.#event(
4653
4670
  command,
4654
- { type: "message", actor: "system", body: `Pi failed: ${runtimeErrorMessage(cause)}` },
4671
+ { type: "message", actor: "system", body: `Pi failed: ${detail}` },
4655
4672
  active.conversationRefs
4656
4673
  ).catch(() => void 0);
4674
+ await this.#diagnostic(command, active, detail);
4657
4675
  await this.#event(command, { type: "status", status: "failed" }, active.conversationRefs).catch(() => void 0);
4658
- await this.#failure(command, active, runtimeErrorMessage(cause));
4676
+ await this.#failure(command, active, detail);
4659
4677
  return null;
4660
4678
  });
4661
4679
  return { status: "running", message: "Pi accepted the owner prompt" };
@@ -4767,7 +4785,9 @@ var CodePiRuntimeEngine = class {
4767
4785
  durationMs: Date.now() - startedAt
4768
4786
  }, active.conversationRefs).catch(() => void 0);
4769
4787
  if (result.status === "failed") {
4770
- 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);
4771
4791
  }
4772
4792
  return result;
4773
4793
  }
@@ -4784,6 +4804,15 @@ var CodePiRuntimeEngine = class {
4784
4804
  await this.options.control.reportSessionFailure(command.sessionId, active.failure).catch(() => void 0);
4785
4805
  }
4786
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
+ }
4787
4816
  async #event(command, event, refs) {
4788
4817
  await appendCodeRuntimeEvent(this.options.control, command, event, refs);
4789
4818
  }
@@ -5336,7 +5365,8 @@ async function runCodeRuntime(input) {
5336
5365
  image: CODE_PI_IMAGE,
5337
5366
  recipes: CODE_BUILD_RECIPES,
5338
5367
  recipeAuthorization: "registered_recipe",
5339
- localSource: input.localSource
5368
+ localSource: input.localSource,
5369
+ onDiagnostic: (message2) => input.stdout.error(`Pi runtime failed \xB7 ${message2}`)
5340
5370
  });
5341
5371
  const reconciler = new CodeRuntimeReconciler(control, commandEngine);
5342
5372
  try {