@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/bin.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  exitCodeFor,
4
4
  runCli
5
- } from "./chunk-S3OYXHDG.js";
5
+ } from "./chunk-PQX6SKYJ.js";
6
6
 
7
7
  // src/bin.ts
8
8
  runCli().catch((err) => {
@@ -1800,10 +1800,10 @@ import { existsSync as existsSync4 } from "fs";
1800
1800
  import { cpus, hostname, totalmem } from "os";
1801
1801
  import { resolve as resolve5 } from "path";
1802
1802
 
1803
- // ../harness/dist/chunk-UG5XHNFB.js
1803
+ // ../harness/dist/chunk-7SN5SG4N.js
1804
1804
  var HARNESS_PROTOCOL_VERSION = 1;
1805
1805
 
1806
- // ../harness/dist/chunk-QALIIZRJ.js
1806
+ // ../harness/dist/chunk-HX4QYGWE.js
1807
1807
  var CONTROL = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/;
1808
1808
  var HarnessProtocolError = class extends Error {
1809
1809
  name = "HarnessProtocolError";
@@ -1881,7 +1881,7 @@ function encodeAgentInput(message2) {
1881
1881
  `;
1882
1882
  }
1883
1883
 
1884
- // ../harness/dist/chunk-TA2FKK27.js
1884
+ // ../harness/dist/chunk-QWWRL7M4.js
1885
1885
  import { execFile as execFile2, spawn as spawn2 } from "child_process";
1886
1886
  import { constants } from "fs";
1887
1887
  import { access } from "fs/promises";
@@ -2398,7 +2398,7 @@ async function stageWorkspacePair(baselineSource, workspaceSource, options = {})
2398
2398
  }
2399
2399
  }
2400
2400
 
2401
- // ../harness/dist/chunk-4EM6NMET.js
2401
+ // ../harness/dist/chunk-T2RD6ZAW.js
2402
2402
  import { createHash } from "crypto";
2403
2403
  import { readFile, readdir as readdir2 } from "fs/promises";
2404
2404
  import { relative as relative3, resolve as resolve4 } from "path";
@@ -2735,7 +2735,7 @@ function validateSnapshot(snapshot, limits) {
2735
2735
  }
2736
2736
  }
2737
2737
 
2738
- // ../harness/dist/chunk-4EM6NMET.js
2738
+ // ../harness/dist/chunk-T2RD6ZAW.js
2739
2739
  import { spawn as spawn4 } from "child_process";
2740
2740
  import { lstat as lstat2 } from "fs/promises";
2741
2741
  import { resolve as resolve23, sep as sep3 } from "path";
@@ -3028,7 +3028,7 @@ function looksLikeDestination(value) {
3028
3028
  return /^(?:[a-z][a-z0-9+.-]*:\/\/|\/|\\\\)/i.test(text) || /^[\w.-]+\.[a-z]{2,}(?:[/:]|$)/i.test(text);
3029
3029
  }
3030
3030
 
3031
- // ../harness/dist/chunk-4EM6NMET.js
3031
+ // ../harness/dist/chunk-T2RD6ZAW.js
3032
3032
  import { createHash as createHash3 } from "crypto";
3033
3033
  async function digestStagedWorkspace(root, limits) {
3034
3034
  const files = [];
@@ -3143,9 +3143,13 @@ function createCodeRuntimeControlClient(options) {
3143
3143
  if (!Number.isSafeInteger(requestTimeoutMs) || requestTimeoutMs < 1e3 || requestTimeoutMs > 12e4) {
3144
3144
  throw new TypeError("requestTimeoutMs must be an integer from 1000 to 120000");
3145
3145
  }
3146
+ const modelRequestTimeoutMs = options.modelRequestTimeoutMs ?? 15 * 6e4;
3147
+ if (!Number.isSafeInteger(modelRequestTimeoutMs) || modelRequestTimeoutMs < 3e4 || modelRequestTimeoutMs > 30 * 6e4) {
3148
+ throw new TypeError("modelRequestTimeoutMs must be an integer from 30000 to 1800000");
3149
+ }
3146
3150
  const request = options.fetch ?? fetch;
3147
- const call = async (path, body) => {
3148
- const timeout = AbortSignal.timeout(requestTimeoutMs);
3151
+ const call = async (path, body, timeoutMs = requestTimeoutMs) => {
3152
+ const timeout = AbortSignal.timeout(timeoutMs);
3149
3153
  const signal = options.signal ? AbortSignal.any([options.signal, timeout]) : timeout;
3150
3154
  let response2;
3151
3155
  try {
@@ -3184,14 +3188,18 @@ function createCodeRuntimeControlClient(options) {
3184
3188
  await call(`/registry/code/runtime/sessions/${validSessionId(sessionId)}/source`, {})
3185
3189
  ),
3186
3190
  infer: async (sessionId, inference) => {
3187
- const value = record3(await call(`/registry/code/runtime/sessions/${validSessionId(sessionId)}/inference`, inference));
3191
+ const value = record3(await call(
3192
+ `/registry/code/runtime/sessions/${validSessionId(sessionId)}/inference`,
3193
+ inference,
3194
+ modelRequestTimeoutMs
3195
+ ));
3188
3196
  if (!value || value.requestId !== inference.requestId || !record3(value.response) || !record3(value.receipt)) {
3189
3197
  throw new CodeRuntimeControlError("invalid Code inference response", 502, "invalid_response");
3190
3198
  }
3191
3199
  return value;
3192
3200
  },
3193
3201
  review: async (sessionId, review) => parseReview(
3194
- await call(`/registry/code/runtime/sessions/${validSessionId(sessionId)}/review`, review)
3202
+ await call(`/registry/code/runtime/sessions/${validSessionId(sessionId)}/review`, review, modelRequestTimeoutMs)
3195
3203
  ),
3196
3204
  submitCandidate: async (sessionId, checkpointId, verification) => {
3197
3205
  if (!/^cpoint_[0-9a-f]{32}$/.test(checkpointId)) throw new TypeError("invalid Code checkpoint id");
@@ -4319,7 +4327,13 @@ var safeRuntimeJson = (value) => {
4319
4327
  };
4320
4328
  function runtimeResultText(value) {
4321
4329
  const record32 = runtimeRecord(value);
4322
- return record32 && typeof record32.text === "string" ? record32.text.slice(0, 2e4) : null;
4330
+ if (record32 && typeof record32.text === "string") return record32.text.slice(0, 2e4);
4331
+ if (record32 && typeof record32.error === "string") return `Pi failed: ${record32.error.slice(0, 19989)}`;
4332
+ return null;
4333
+ }
4334
+ function runtimeResultError(value) {
4335
+ const record32 = runtimeRecord(value);
4336
+ return record32 && typeof record32.error === "string" && record32.error.trim() ? record32.error.trim().slice(0, 2e3) : null;
4323
4337
  }
4324
4338
  var CodePiRuntimeEngine = class {
4325
4339
  constructor(options) {
@@ -4427,9 +4441,11 @@ var CodePiRuntimeEngine = class {
4427
4441
  }, conversationRefs);
4428
4442
  }
4429
4443
  active.done = this.#runAttempt(command, metadata2, active).catch(async (cause) => {
4430
- await this.#event(command, { type: "message", actor: "system", body: `Pi failed: ${runtimeErrorMessage(cause)}` }, conversationRefs).catch(() => void 0);
4444
+ const detail = runtimeErrorMessage(cause);
4445
+ await this.#event(command, { type: "message", actor: "system", body: `Pi failed: ${detail}` }, conversationRefs).catch(() => void 0);
4446
+ await this.#diagnostic(command, active, detail);
4431
4447
  await this.#event(command, { type: "status", status: "failed" }, conversationRefs).catch(() => void 0);
4432
- await this.#failure(command, active, runtimeErrorMessage(cause));
4448
+ await this.#failure(command, active, detail);
4433
4449
  return null;
4434
4450
  });
4435
4451
  return { status: "running", message: resume ? "Pi resumed from a portable checkpoint" : "Pi started" };
@@ -4454,13 +4470,15 @@ var CodePiRuntimeEngine = class {
4454
4470
  baseCommitSha: active.baseCommitSha,
4455
4471
  sourceTreeDigest: active.sourceTreeDigest
4456
4472
  }, active).catch(async (cause) => {
4473
+ const detail = runtimeErrorMessage(cause);
4457
4474
  await this.#event(
4458
4475
  command,
4459
- { type: "message", actor: "system", body: `Pi failed: ${runtimeErrorMessage(cause)}` },
4476
+ { type: "message", actor: "system", body: `Pi failed: ${detail}` },
4460
4477
  active.conversationRefs
4461
4478
  ).catch(() => void 0);
4479
+ await this.#diagnostic(command, active, detail);
4462
4480
  await this.#event(command, { type: "status", status: "failed" }, active.conversationRefs).catch(() => void 0);
4463
- await this.#failure(command, active, runtimeErrorMessage(cause));
4481
+ await this.#failure(command, active, detail);
4464
4482
  return null;
4465
4483
  });
4466
4484
  return { status: "running", message: "Pi accepted the owner prompt" };
@@ -4572,7 +4590,9 @@ var CodePiRuntimeEngine = class {
4572
4590
  durationMs: Date.now() - startedAt
4573
4591
  }, active.conversationRefs).catch(() => void 0);
4574
4592
  if (result.status === "failed") {
4575
- await this.#failure(command, active, result.stderr || "Pi container failed");
4593
+ const detail = (runtimeResultError(result.result) ?? result.stderr.trim()) || "Pi container failed";
4594
+ await this.#diagnostic(command, active, detail);
4595
+ await this.#failure(command, active, detail);
4576
4596
  }
4577
4597
  return result;
4578
4598
  }
@@ -4589,6 +4609,15 @@ var CodePiRuntimeEngine = class {
4589
4609
  await this.options.control.reportSessionFailure(command.sessionId, active.failure).catch(() => void 0);
4590
4610
  }
4591
4611
  }
4612
+ async #diagnostic(command, active, value) {
4613
+ const detail = value.trim().slice(0, 2e3) || "Pi runtime failed";
4614
+ this.options.onDiagnostic?.(detail);
4615
+ await this.#event(
4616
+ command,
4617
+ { type: "diagnostic", level: "error", message: detail },
4618
+ active.conversationRefs
4619
+ ).catch(() => void 0);
4620
+ }
4592
4621
  async #event(command, event, refs) {
4593
4622
  await appendCodeRuntimeEvent(this.options.control, command, event, refs);
4594
4623
  }
@@ -4906,7 +4935,8 @@ async function runCodeRuntime(input) {
4906
4935
  image: CODE_PI_IMAGE,
4907
4936
  recipes: CODE_BUILD_RECIPES,
4908
4937
  recipeAuthorization: "registered_recipe",
4909
- localSource: input.localSource
4938
+ localSource: input.localSource,
4939
+ onDiagnostic: (message2) => input.stdout.error(`Pi runtime failed \xB7 ${message2}`)
4910
4940
  });
4911
4941
  const reconciler = new CodeRuntimeReconciler(control, commandEngine);
4912
4942
  try {
@@ -7746,4 +7776,4 @@ export {
7746
7776
  exitCodeFor,
7747
7777
  runCli
7748
7778
  };
7749
- //# sourceMappingURL=chunk-S3OYXHDG.js.map
7779
+ //# sourceMappingURL=chunk-PQX6SKYJ.js.map