@odla-ai/cli 0.37.0 → 0.37.1

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.cjs CHANGED
@@ -7647,7 +7647,7 @@ function createCodeRuntimeControlClient(options) {
7647
7647
  throw new TypeError("modelRequestTimeoutMs must be an integer from 30000 to 1800000");
7648
7648
  }
7649
7649
  const request3 = options.fetch ?? fetch;
7650
- const call2 = async (path, body, timeoutMs = requestTimeoutMs) => {
7650
+ const call3 = async (path, body, timeoutMs = requestTimeoutMs) => {
7651
7651
  const timeout = AbortSignal.timeout(timeoutMs);
7652
7652
  const signal = options.signal ? AbortSignal.any([options.signal, timeout]) : timeout;
7653
7653
  let response2;
@@ -7677,17 +7677,17 @@ function createCodeRuntimeControlClient(options) {
7677
7677
  return {
7678
7678
  heartbeat: async (version, capabilities) => {
7679
7679
  validateHeartbeat(version, capabilities);
7680
- return parseSnapshot(await call2("/registry/code/runtime/heartbeat", { runtimeVersion: version, capabilities }));
7680
+ return parseSnapshot(await call3("/registry/code/runtime/heartbeat", { runtimeVersion: version, capabilities }));
7681
7681
  },
7682
7682
  acknowledge: async (commandId, result) => {
7683
7683
  if (!/^ccmd_[0-9a-f]{32}$/.test(commandId)) throw new TypeError("invalid Code runtime command id");
7684
- await call2(`/registry/code/runtime/commands/${commandId}/ack`, result);
7684
+ await call3(`/registry/code/runtime/commands/${commandId}/ack`, result);
7685
7685
  },
7686
7686
  source: async (sessionId) => parseSource(
7687
- await call2(`/registry/code/runtime/sessions/${validSessionId(sessionId)}/source`, {})
7687
+ await call3(`/registry/code/runtime/sessions/${validSessionId(sessionId)}/source`, {})
7688
7688
  ),
7689
7689
  infer: async (sessionId, inference) => {
7690
- const value2 = record5(await call2(
7690
+ const value2 = record5(await call3(
7691
7691
  `/registry/code/runtime/sessions/${validSessionId(sessionId)}/inference`,
7692
7692
  inference,
7693
7693
  modelRequestTimeoutMs
@@ -7698,11 +7698,11 @@ function createCodeRuntimeControlClient(options) {
7698
7698
  return value2;
7699
7699
  },
7700
7700
  review: async (sessionId, review) => parseReview(
7701
- await call2(`/registry/code/runtime/sessions/${validSessionId(sessionId)}/review`, review, modelRequestTimeoutMs)
7701
+ await call3(`/registry/code/runtime/sessions/${validSessionId(sessionId)}/review`, review, modelRequestTimeoutMs)
7702
7702
  ),
7703
7703
  submitCandidate: async (sessionId, checkpointId, verification) => {
7704
7704
  if (!/^cpoint_[0-9a-f]{32}$/.test(checkpointId)) throw new TypeError("invalid Code checkpoint id");
7705
- return parseCandidate(await call2(
7705
+ return parseCandidate(await call3(
7706
7706
  `/registry/code/runtime/sessions/${validSessionId(sessionId)}/candidates`,
7707
7707
  { checkpointId, verification }
7708
7708
  ));
@@ -7712,21 +7712,21 @@ function createCodeRuntimeControlClient(options) {
7712
7712
  if (!/^[A-Za-z0-9._:-]{1,120}$/.test(eventId) || !event || typeof event !== "object" || new TextEncoder().encode(serialized).byteLength > 24e3) {
7713
7713
  throw new TypeError("invalid Code session event");
7714
7714
  }
7715
- await call2(`/registry/code/runtime/sessions/${validSessionId(sessionId)}/chat/events`, { eventId, event });
7715
+ await call3(`/registry/code/runtime/sessions/${validSessionId(sessionId)}/chat/events`, { eventId, event });
7716
7716
  },
7717
7717
  recallMemories: async (sessionId, subjects, limit) => {
7718
- const response2 = await call2(
7718
+ const response2 = await call3(
7719
7719
  `/registry/code/runtime/sessions/${validSessionId(sessionId)}/recall`,
7720
7720
  { subjects: [...subjects], limit }
7721
7721
  );
7722
7722
  return Array.isArray(response2.memories) ? response2.memories : [];
7723
7723
  },
7724
7724
  rememberMemory: async (sessionId, memory) => {
7725
- await call2(`/registry/code/runtime/sessions/${validSessionId(sessionId)}/remember`, memory);
7725
+ await call3(`/registry/code/runtime/sessions/${validSessionId(sessionId)}/remember`, memory);
7726
7726
  },
7727
7727
  reportSessionFailure: async (sessionId, message2) => {
7728
7728
  if (!message2.trim() || message2.length > 2e3) throw new TypeError("invalid Code session failure");
7729
- await call2(`/registry/code/runtime/sessions/${validSessionId(sessionId)}/failure`, { message: message2 });
7729
+ await call3(`/registry/code/runtime/sessions/${validSessionId(sessionId)}/failure`, { message: message2 });
7730
7730
  }
7731
7731
  };
7732
7732
  }
@@ -8512,7 +8512,7 @@ async function materializeCommandWorkspace(input) {
8512
8512
  }
8513
8513
  function codeSkill(opts) {
8514
8514
  let seq = 0;
8515
- const call2 = async (tool, input, signal) => {
8515
+ const call3 = async (tool, input, signal) => {
8516
8516
  const startedAt = Date.now();
8517
8517
  const response2 = await opts.broker.execute(
8518
8518
  { lease: opts.lease, workspaceDir: opts.workspaceDir, signal },
@@ -8534,7 +8534,7 @@ function codeSkill(opts) {
8534
8534
  },
8535
8535
  additionalProperties: false
8536
8536
  },
8537
- handler: (input, ctx) => call2("sandbox.read", input, ctx.signal)
8537
+ handler: (input, ctx) => call3("sandbox.read", input, ctx.signal)
8538
8538
  };
8539
8539
  const applyPatch = {
8540
8540
  name: "odla_apply_git_diff",
@@ -8545,7 +8545,7 @@ function codeSkill(opts) {
8545
8545
  properties: { patch: { type: "string", minLength: 1, maxLength: 262144 } },
8546
8546
  additionalProperties: false
8547
8547
  },
8548
- handler: (input, ctx) => call2("sandbox.apply_patch", input, ctx.signal)
8548
+ handler: (input, ctx) => call3("sandbox.apply_patch", input, ctx.signal)
8549
8549
  };
8550
8550
  const runRecipe = {
8551
8551
  name: "odla_run_recipe",
@@ -8556,7 +8556,7 @@ function codeSkill(opts) {
8556
8556
  properties: { recipeId: { type: "string", minLength: 1, maxLength: 120, pattern: "^[a-zA-Z0-9._:-]+$" } },
8557
8557
  additionalProperties: false
8558
8558
  },
8559
- handler: (input, ctx) => call2("sandbox.run_recipe", input, ctx.signal)
8559
+ handler: (input, ctx) => call3("sandbox.run_recipe", input, ctx.signal)
8560
8560
  };
8561
8561
  const listFiles2 = {
8562
8562
  name: "odla_list",
@@ -8569,7 +8569,7 @@ function codeSkill(opts) {
8569
8569
  },
8570
8570
  additionalProperties: false
8571
8571
  },
8572
- handler: (input, ctx) => call2("sandbox.list", input, ctx.signal)
8572
+ handler: (input, ctx) => call3("sandbox.list", input, ctx.signal)
8573
8573
  };
8574
8574
  const searchFiles = {
8575
8575
  name: "odla_search",
@@ -8585,7 +8585,7 @@ function codeSkill(opts) {
8585
8585
  },
8586
8586
  additionalProperties: false
8587
8587
  },
8588
- handler: (input, ctx) => call2("sandbox.search", input, ctx.signal)
8588
+ handler: (input, ctx) => call3("sandbox.search", input, ctx.signal)
8589
8589
  };
8590
8590
  const graphTool = (name, tool, description, required) => ({
8591
8591
  name,
@@ -8596,7 +8596,7 @@ function codeSkill(opts) {
8596
8596
  properties: { query: { type: "string", maxLength: 512 } },
8597
8597
  additionalProperties: false
8598
8598
  },
8599
- handler: (input, ctx) => call2(tool, input, ctx.signal)
8599
+ handler: (input, ctx) => call3(tool, input, ctx.signal)
8600
8600
  });
8601
8601
  const orientation = [
8602
8602
  graphTool(
@@ -8635,9 +8635,9 @@ async function runCodeAgent(options) {
8635
8635
  lease: options.lease,
8636
8636
  workspaceDir: options.workspaceDir,
8637
8637
  surface,
8638
- onToolCall: (call2) => {
8639
- toolCalls.push(call2);
8640
- options.onToolCall?.(call2);
8638
+ onToolCall: (call3) => {
8639
+ toolCalls.push(call3);
8640
+ options.onToolCall?.(call3);
8641
8641
  }
8642
8642
  });
8643
8643
  const compaction = options.compaction === void 0 ? (0, import_ai4.keepRecentExchanges)({ whenInputTokensExceed: 12e4, keep: 3 }) : options.compaction;
@@ -13866,9 +13866,15 @@ async function provisionEnvCredentials(opts) {
13866
13866
  if (o11yToken) {
13867
13867
  opts.stdout.log(`${opts.env}: reusing local o11y ingest token`);
13868
13868
  } else {
13869
- o11yToken = await issueO11yToken(opts);
13870
- credentials = save(opts, credentials, tenantId, { ...dbKey ? { dbKey } : {}, o11yToken });
13871
- opts.stdout.log(`${opts.env}: ${opts.rotateO11y ? "rotated" : "issued"} o11y ingest token`);
13869
+ o11yToken = await issueO11yToken(opts) ?? void 0;
13870
+ if (o11yToken) {
13871
+ credentials = save(opts, credentials, tenantId, { ...dbKey ? { dbKey } : {}, o11yToken });
13872
+ opts.stdout.log(`${opts.env}: ${opts.rotateO11y ? "rotated" : "issued"} o11y ingest token`);
13873
+ } else {
13874
+ opts.stdout.log(
13875
+ `${opts.env}: o11y token already exists and its shown-once value is not on this machine \u2014 leaving it alone (a co-owner provisioned this env). Nothing was rotated, and this env's running Worker keeps its token. To replace it deliberately \u2014 which invalidates the token on whatever is deployed \u2014 run "odla-ai provision --rotate-o11y-token --push-secrets".`
13876
+ );
13877
+ }
13872
13878
  }
13873
13879
  }
13874
13880
  return save(opts, credentials, tenantId, {
@@ -13922,11 +13928,7 @@ async function issueO11yToken(opts) {
13922
13928
  `${opts.cfg.platformUrl}/o11y/${encodeURIComponent(opts.cfg.app.id)}/token${suffix}?env=${encodeURIComponent(opts.env)}`,
13923
13929
  { method: "POST", headers: { authorization: `Bearer ${opts.developerToken}` } }
13924
13930
  );
13925
- if (res.status === 409 && !opts.rotateO11y) {
13926
- throw new Error(
13927
- `o11y token already exists for env "${opts.env}", but its shown-once value is not in the local credentials file; run "odla-ai provision --push-secrets" to install a separate runtime credential without rotating siblings`
13928
- );
13929
- }
13931
+ if (res.status === 409 && !opts.rotateO11y) return null;
13930
13932
  if (!res.ok) throw new Error(`o11y token ${opts.rotateO11y ? "rotation" : "issue"} (${opts.env}) failed: ${res.status} ${await safeText7(res)}`);
13931
13933
  const body = await res.json();
13932
13934
  if (!body.token) throw new Error(`o11y token ${opts.rotateO11y ? "rotation" : "issue"} (${opts.env}) returned no token`);
@@ -14898,12 +14900,7 @@ ${counts.created} created, ${counts.updated} updated, ${counts.unchanged} unchan
14898
14900
  );
14899
14901
  }
14900
14902
  async function upsert(ctx, r, visibility) {
14901
- const page2 = await call(
14902
- ctx,
14903
- "GET",
14904
- `/runbook?app=${encodeURIComponent(ctx.appId)}&slug=${encodeURIComponent(r.slug)}&limit=1`
14905
- );
14906
- const found = page2.records[0];
14903
+ const found = await bySlug(ctx, r.slug).catch(() => null);
14907
14904
  if (!found) {
14908
14905
  await call(ctx, "POST", "/runbook", {
14909
14906
  appId: ctx.appId,
@@ -15341,13 +15338,7 @@ async function runbookAsk(ctx, question, all) {
15341
15338
  ctx.out.log(JSDOC_POINTER);
15342
15339
  }
15343
15340
  async function runbookComment(ctx, slug, body) {
15344
- const page2 = await call(
15345
- ctx,
15346
- "GET",
15347
- `/runbook?app=${encodeURIComponent(ctx.appId)}&slug=${encodeURIComponent(slug)}&limit=1`
15348
- );
15349
- const found = page2.records[0];
15350
- if (!found) throw new Error(`no runbook "${slug}" in ${ctx.appId}`);
15341
+ const found = await bySlug(ctx, slug);
15351
15342
  await call(ctx, "POST", `/runbook/${encodeURIComponent(found.id)}/comments`, { body });
15352
15343
  ctx.out.log(`commented on ${slug} (v${found.version})`);
15353
15344
  }
@@ -15414,13 +15405,7 @@ var init_runbook_editor = __esm({
15414
15405
 
15415
15406
  // src/runbook-edit-flow.ts
15416
15407
  async function editRunbook(ctx, slug, deps = {}) {
15417
- const page2 = await call(
15418
- ctx,
15419
- "GET",
15420
- `/runbook?app=${encodeURIComponent(ctx.appId)}&slug=${encodeURIComponent(slug)}&limit=1`
15421
- );
15422
- const found = page2.records[0];
15423
- if (!found) throw new Error(`no runbook "${slug}" in ${ctx.appId}`);
15408
+ const found = await bySlug(ctx, slug);
15424
15409
  ctx.out.log(`opening ${slug} v${found.version} in your editor\u2026`);
15425
15410
  const body = await editText(found.body, slug, deps);
15426
15411
  return body === null ? null : { body, expectedVersion: found.version };