@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/README.md CHANGED
@@ -29,8 +29,8 @@ For a project you keep working in, install it as a dev dependency so the
29
29
  shorter `npx odla-ai` form works and the version is pinned by your lockfile:
30
30
 
31
31
  ```bash
32
- npm view @odla-ai/cli@0.16.0 version
33
- npm i -D --save-exact @odla-ai/cli@0.16.0
32
+ npm view @odla-ai/cli@0.16.2 version
33
+ npm i -D --save-exact @odla-ai/cli@0.16.2
34
34
  ```
35
35
 
36
36
  ## Prerequisites
package/dist/bin.cjs CHANGED
@@ -1942,10 +1942,10 @@ var import_node_fs7 = require("fs");
1942
1942
  var import_node_os = require("os");
1943
1943
  var import_node_path4 = require("path");
1944
1944
 
1945
- // ../harness/dist/chunk-UG5XHNFB.js
1945
+ // ../harness/dist/chunk-7SN5SG4N.js
1946
1946
  var HARNESS_PROTOCOL_VERSION = 1;
1947
1947
 
1948
- // ../harness/dist/chunk-QALIIZRJ.js
1948
+ // ../harness/dist/chunk-HX4QYGWE.js
1949
1949
  var CONTROL = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/;
1950
1950
  var HarnessProtocolError = class extends Error {
1951
1951
  name = "HarnessProtocolError";
@@ -2023,7 +2023,7 @@ function encodeAgentInput(message2) {
2023
2023
  `;
2024
2024
  }
2025
2025
 
2026
- // ../harness/dist/chunk-TA2FKK27.js
2026
+ // ../harness/dist/chunk-QWWRL7M4.js
2027
2027
  var import_child_process = require("child_process");
2028
2028
  var import_fs = require("fs");
2029
2029
  var import_promises2 = require("fs/promises");
@@ -2540,7 +2540,7 @@ async function stageWorkspacePair(baselineSource, workspaceSource, options = {})
2540
2540
  }
2541
2541
  }
2542
2542
 
2543
- // ../harness/dist/chunk-4EM6NMET.js
2543
+ // ../harness/dist/chunk-T2RD6ZAW.js
2544
2544
  var import_crypto = require("crypto");
2545
2545
  var import_promises5 = require("fs/promises");
2546
2546
  var import_path5 = require("path");
@@ -2877,7 +2877,7 @@ function validateSnapshot(snapshot, limits) {
2877
2877
  }
2878
2878
  }
2879
2879
 
2880
- // ../harness/dist/chunk-4EM6NMET.js
2880
+ // ../harness/dist/chunk-T2RD6ZAW.js
2881
2881
  var import_child_process4 = require("child_process");
2882
2882
  var import_promises6 = require("fs/promises");
2883
2883
  var import_path6 = require("path");
@@ -3170,7 +3170,7 @@ function looksLikeDestination(value) {
3170
3170
  return /^(?:[a-z][a-z0-9+.-]*:\/\/|\/|\\\\)/i.test(text) || /^[\w.-]+\.[a-z]{2,}(?:[/:]|$)/i.test(text);
3171
3171
  }
3172
3172
 
3173
- // ../harness/dist/chunk-4EM6NMET.js
3173
+ // ../harness/dist/chunk-T2RD6ZAW.js
3174
3174
  var import_crypto4 = require("crypto");
3175
3175
  async function digestStagedWorkspace(root, limits) {
3176
3176
  const files = [];
@@ -3285,9 +3285,13 @@ function createCodeRuntimeControlClient(options) {
3285
3285
  if (!Number.isSafeInteger(requestTimeoutMs) || requestTimeoutMs < 1e3 || requestTimeoutMs > 12e4) {
3286
3286
  throw new TypeError("requestTimeoutMs must be an integer from 1000 to 120000");
3287
3287
  }
3288
+ const modelRequestTimeoutMs = options.modelRequestTimeoutMs ?? 15 * 6e4;
3289
+ if (!Number.isSafeInteger(modelRequestTimeoutMs) || modelRequestTimeoutMs < 3e4 || modelRequestTimeoutMs > 30 * 6e4) {
3290
+ throw new TypeError("modelRequestTimeoutMs must be an integer from 30000 to 1800000");
3291
+ }
3288
3292
  const request = options.fetch ?? fetch;
3289
- const call = async (path, body) => {
3290
- const timeout = AbortSignal.timeout(requestTimeoutMs);
3293
+ const call = async (path, body, timeoutMs = requestTimeoutMs) => {
3294
+ const timeout = AbortSignal.timeout(timeoutMs);
3291
3295
  const signal = options.signal ? AbortSignal.any([options.signal, timeout]) : timeout;
3292
3296
  let response2;
3293
3297
  try {
@@ -3326,14 +3330,18 @@ function createCodeRuntimeControlClient(options) {
3326
3330
  await call(`/registry/code/runtime/sessions/${validSessionId(sessionId)}/source`, {})
3327
3331
  ),
3328
3332
  infer: async (sessionId, inference) => {
3329
- const value = record3(await call(`/registry/code/runtime/sessions/${validSessionId(sessionId)}/inference`, inference));
3333
+ const value = record3(await call(
3334
+ `/registry/code/runtime/sessions/${validSessionId(sessionId)}/inference`,
3335
+ inference,
3336
+ modelRequestTimeoutMs
3337
+ ));
3330
3338
  if (!value || value.requestId !== inference.requestId || !record3(value.response) || !record3(value.receipt)) {
3331
3339
  throw new CodeRuntimeControlError("invalid Code inference response", 502, "invalid_response");
3332
3340
  }
3333
3341
  return value;
3334
3342
  },
3335
3343
  review: async (sessionId, review) => parseReview(
3336
- await call(`/registry/code/runtime/sessions/${validSessionId(sessionId)}/review`, review)
3344
+ await call(`/registry/code/runtime/sessions/${validSessionId(sessionId)}/review`, review, modelRequestTimeoutMs)
3337
3345
  ),
3338
3346
  submitCandidate: async (sessionId, checkpointId, verification) => {
3339
3347
  if (!/^cpoint_[0-9a-f]{32}$/.test(checkpointId)) throw new TypeError("invalid Code checkpoint id");
@@ -4461,7 +4469,13 @@ var safeRuntimeJson = (value) => {
4461
4469
  };
4462
4470
  function runtimeResultText(value) {
4463
4471
  const record32 = runtimeRecord(value);
4464
- return record32 && typeof record32.text === "string" ? record32.text.slice(0, 2e4) : null;
4472
+ if (record32 && typeof record32.text === "string") return record32.text.slice(0, 2e4);
4473
+ if (record32 && typeof record32.error === "string") return `Pi failed: ${record32.error.slice(0, 19989)}`;
4474
+ return null;
4475
+ }
4476
+ function runtimeResultError(value) {
4477
+ const record32 = runtimeRecord(value);
4478
+ return record32 && typeof record32.error === "string" && record32.error.trim() ? record32.error.trim().slice(0, 2e3) : null;
4465
4479
  }
4466
4480
  var CodePiRuntimeEngine = class {
4467
4481
  constructor(options) {
@@ -4569,9 +4583,11 @@ var CodePiRuntimeEngine = class {
4569
4583
  }, conversationRefs);
4570
4584
  }
4571
4585
  active.done = this.#runAttempt(command, metadata2, active).catch(async (cause) => {
4572
- await this.#event(command, { type: "message", actor: "system", body: `Pi failed: ${runtimeErrorMessage(cause)}` }, conversationRefs).catch(() => void 0);
4586
+ const detail = runtimeErrorMessage(cause);
4587
+ await this.#event(command, { type: "message", actor: "system", body: `Pi failed: ${detail}` }, conversationRefs).catch(() => void 0);
4588
+ await this.#diagnostic(command, active, detail);
4573
4589
  await this.#event(command, { type: "status", status: "failed" }, conversationRefs).catch(() => void 0);
4574
- await this.#failure(command, active, runtimeErrorMessage(cause));
4590
+ await this.#failure(command, active, detail);
4575
4591
  return null;
4576
4592
  });
4577
4593
  return { status: "running", message: resume ? "Pi resumed from a portable checkpoint" : "Pi started" };
@@ -4596,13 +4612,15 @@ var CodePiRuntimeEngine = class {
4596
4612
  baseCommitSha: active.baseCommitSha,
4597
4613
  sourceTreeDigest: active.sourceTreeDigest
4598
4614
  }, active).catch(async (cause) => {
4615
+ const detail = runtimeErrorMessage(cause);
4599
4616
  await this.#event(
4600
4617
  command,
4601
- { type: "message", actor: "system", body: `Pi failed: ${runtimeErrorMessage(cause)}` },
4618
+ { type: "message", actor: "system", body: `Pi failed: ${detail}` },
4602
4619
  active.conversationRefs
4603
4620
  ).catch(() => void 0);
4621
+ await this.#diagnostic(command, active, detail);
4604
4622
  await this.#event(command, { type: "status", status: "failed" }, active.conversationRefs).catch(() => void 0);
4605
- await this.#failure(command, active, runtimeErrorMessage(cause));
4623
+ await this.#failure(command, active, detail);
4606
4624
  return null;
4607
4625
  });
4608
4626
  return { status: "running", message: "Pi accepted the owner prompt" };
@@ -4714,7 +4732,9 @@ var CodePiRuntimeEngine = class {
4714
4732
  durationMs: Date.now() - startedAt
4715
4733
  }, active.conversationRefs).catch(() => void 0);
4716
4734
  if (result.status === "failed") {
4717
- await this.#failure(command, active, result.stderr || "Pi container failed");
4735
+ const detail = (runtimeResultError(result.result) ?? result.stderr.trim()) || "Pi container failed";
4736
+ await this.#diagnostic(command, active, detail);
4737
+ await this.#failure(command, active, detail);
4718
4738
  }
4719
4739
  return result;
4720
4740
  }
@@ -4731,6 +4751,15 @@ var CodePiRuntimeEngine = class {
4731
4751
  await this.options.control.reportSessionFailure(command.sessionId, active.failure).catch(() => void 0);
4732
4752
  }
4733
4753
  }
4754
+ async #diagnostic(command, active, value) {
4755
+ const detail = value.trim().slice(0, 2e3) || "Pi runtime failed";
4756
+ this.options.onDiagnostic?.(detail);
4757
+ await this.#event(
4758
+ command,
4759
+ { type: "diagnostic", level: "error", message: detail },
4760
+ active.conversationRefs
4761
+ ).catch(() => void 0);
4762
+ }
4734
4763
  async #event(command, event, refs) {
4735
4764
  await appendCodeRuntimeEvent(this.options.control, command, event, refs);
4736
4765
  }
@@ -5283,7 +5312,8 @@ async function runCodeRuntime(input) {
5283
5312
  image: CODE_PI_IMAGE,
5284
5313
  recipes: CODE_BUILD_RECIPES,
5285
5314
  recipeAuthorization: "registered_recipe",
5286
- localSource: input.localSource
5315
+ localSource: input.localSource,
5316
+ onDiagnostic: (message2) => input.stdout.error(`Pi runtime failed \xB7 ${message2}`)
5287
5317
  });
5288
5318
  const reconciler = new CodeRuntimeReconciler(control, commandEngine);
5289
5319
  try {