zelari-code 2.9.0 → 2.9.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.
@@ -40619,6 +40619,7 @@ function frozenProfile(input) {
40619
40619
  Object.freeze(input.promptCache);
40620
40620
  Object.freeze(input.toolCalling);
40621
40621
  Object.freeze(input.buildRecovery);
40622
+ Object.freeze(input.wire);
40622
40623
  Object.freeze(input.sampling);
40623
40624
  Object.freeze(input.compaction);
40624
40625
  return Object.freeze(input);
@@ -40660,6 +40661,13 @@ var init_capabilities = __esm({
40660
40661
  promptCache: { supported: true, pricedCacheRead: false },
40661
40662
  toolCalling: { parallel: true },
40662
40663
  buildRecovery: { forceToolChoice: false, maxForcedTurns: 0 },
40664
+ wire: {
40665
+ grokRequestHeaders: false,
40666
+ omitAutoToolChoice: false,
40667
+ toolCallDeltasResetIdle: false,
40668
+ retriesBeforeOutput: 0,
40669
+ strictSseJson: false
40670
+ },
40663
40671
  sampling: { temperature: 0.7 },
40664
40672
  compaction: { ...SHARED_COMPACTION },
40665
40673
  profile: "default"
@@ -40670,6 +40678,13 @@ var init_capabilities = __esm({
40670
40678
  promptCache: { supported: true, pricedCacheRead: true },
40671
40679
  toolCalling: { parallel: true },
40672
40680
  buildRecovery: { forceToolChoice: false, maxForcedTurns: 0 },
40681
+ wire: {
40682
+ grokRequestHeaders: false,
40683
+ omitAutoToolChoice: false,
40684
+ toolCallDeltasResetIdle: false,
40685
+ retriesBeforeOutput: 0,
40686
+ strictSseJson: false
40687
+ },
40673
40688
  sampling: { temperature: 0.7 },
40674
40689
  compaction: { ...SHARED_COMPACTION },
40675
40690
  profile: "deepseek-v4"
@@ -40688,6 +40703,13 @@ var init_capabilities = __esm({
40688
40703
  },
40689
40704
  toolCalling: { parallel: true },
40690
40705
  buildRecovery: { forceToolChoice: true, maxForcedTurns: 1 },
40706
+ wire: {
40707
+ grokRequestHeaders: true,
40708
+ omitAutoToolChoice: true,
40709
+ toolCallDeltasResetIdle: true,
40710
+ retriesBeforeOutput: 1,
40711
+ strictSseJson: true
40712
+ },
40691
40713
  sampling: { temperature: 0.7 },
40692
40714
  compaction: { ...SHARED_COMPACTION },
40693
40715
  profile: "grok"
@@ -40698,6 +40720,13 @@ var init_capabilities = __esm({
40698
40720
  promptCache: { supported: false, pricedCacheRead: false },
40699
40721
  toolCalling: { parallel: true },
40700
40722
  buildRecovery: { forceToolChoice: false, maxForcedTurns: 0 },
40723
+ wire: {
40724
+ grokRequestHeaders: false,
40725
+ omitAutoToolChoice: false,
40726
+ toolCallDeltasResetIdle: false,
40727
+ retriesBeforeOutput: 0,
40728
+ strictSseJson: false
40729
+ },
40701
40730
  sampling: { temperature: 0.7 },
40702
40731
  compaction: { ...SHARED_COMPACTION },
40703
40732
  profile: "minimax"
@@ -40708,6 +40737,13 @@ var init_capabilities = __esm({
40708
40737
  promptCache: { supported: false, pricedCacheRead: false },
40709
40738
  toolCalling: { parallel: true },
40710
40739
  buildRecovery: { forceToolChoice: false, maxForcedTurns: 0 },
40740
+ wire: {
40741
+ grokRequestHeaders: false,
40742
+ omitAutoToolChoice: false,
40743
+ toolCallDeltasResetIdle: false,
40744
+ retriesBeforeOutput: 0,
40745
+ strictSseJson: false
40746
+ },
40711
40747
  sampling: { temperature: 0.7 },
40712
40748
  compaction: { ...SHARED_COMPACTION },
40713
40749
  profile: "minimax"
@@ -40718,6 +40754,13 @@ var init_capabilities = __esm({
40718
40754
  promptCache: { supported: true, pricedCacheRead: false },
40719
40755
  toolCalling: { parallel: true },
40720
40756
  buildRecovery: { forceToolChoice: false, maxForcedTurns: 0 },
40757
+ wire: {
40758
+ grokRequestHeaders: false,
40759
+ omitAutoToolChoice: false,
40760
+ toolCallDeltasResetIdle: false,
40761
+ retriesBeforeOutput: 0,
40762
+ strictSseJson: false
40763
+ },
40721
40764
  sampling: { temperature: 0.7 },
40722
40765
  compaction: { ...SHARED_COMPACTION },
40723
40766
  profile: "glm"
@@ -40730,6 +40773,61 @@ var init_capabilities = __esm({
40730
40773
  }
40731
40774
  });
40732
40775
 
40776
+ // src/cli/provider/sse.ts
40777
+ var SseDataDecoder;
40778
+ var init_sse = __esm({
40779
+ "src/cli/provider/sse.ts"() {
40780
+ "use strict";
40781
+ SseDataDecoder = class {
40782
+ lineBuffer = "";
40783
+ dataLines = [];
40784
+ firstText = true;
40785
+ push(text, final = false) {
40786
+ if (this.firstText) {
40787
+ this.firstText = false;
40788
+ if (text.charCodeAt(0) === 65279) text = text.slice(1);
40789
+ }
40790
+ this.lineBuffer += text;
40791
+ const lines = this.lineBuffer.split("\n");
40792
+ this.lineBuffer = final ? "" : lines.pop() ?? "";
40793
+ const events = [];
40794
+ for (const rawLine of lines) {
40795
+ this.acceptLine(rawLine.endsWith("\r") ? rawLine.slice(0, -1) : rawLine, events);
40796
+ }
40797
+ if (final) {
40798
+ if (this.lineBuffer.length > 0) {
40799
+ this.acceptLine(
40800
+ this.lineBuffer.endsWith("\r") ? this.lineBuffer.slice(0, -1) : this.lineBuffer,
40801
+ events
40802
+ );
40803
+ this.lineBuffer = "";
40804
+ }
40805
+ this.dispatch(events);
40806
+ }
40807
+ return events;
40808
+ }
40809
+ acceptLine(line, events) {
40810
+ if (line.length === 0) {
40811
+ this.dispatch(events);
40812
+ return;
40813
+ }
40814
+ if (line.startsWith(":")) return;
40815
+ const colon = line.indexOf(":");
40816
+ const field = colon < 0 ? line : line.slice(0, colon);
40817
+ if (field !== "data") return;
40818
+ let value = colon < 0 ? "" : line.slice(colon + 1);
40819
+ if (value.startsWith(" ")) value = value.slice(1);
40820
+ this.dataLines.push(value);
40821
+ }
40822
+ dispatch(events) {
40823
+ if (this.dataLines.length === 0) return;
40824
+ events.push(this.dataLines.join("\n"));
40825
+ this.dataLines = [];
40826
+ }
40827
+ };
40828
+ }
40829
+ });
40830
+
40733
40831
  // src/cli/provider/openai-compatible.ts
40734
40832
  var openai_compatible_exports = {};
40735
40833
  __export(openai_compatible_exports, {
@@ -40738,12 +40836,14 @@ __export(openai_compatible_exports, {
40738
40836
  modelSupportsVision: () => modelSupportsVision,
40739
40837
  openaiCompatibleProvider: () => openaiCompatibleProvider,
40740
40838
  parseCachedPromptTokens: () => parseCachedPromptTokens,
40839
+ parseOpenAiStreamError: () => parseOpenAiStreamError,
40741
40840
  providerConfigFor: () => providerConfigFor,
40742
40841
  providerFromEnv: () => providerFromEnv,
40743
40842
  readChunkWithTimeout: () => readChunkWithTimeout,
40744
40843
  resolveActiveProvider: () => resolveActiveProvider,
40745
40844
  resolveBaseUrl: () => resolveBaseUrl
40746
40845
  });
40846
+ import { randomUUID as randomUUID2 } from "node:crypto";
40747
40847
  function abortableSleep(ms, signal) {
40748
40848
  return new Promise((resolve7) => {
40749
40849
  if (signal?.aborted) return resolve7();
@@ -40787,9 +40887,10 @@ async function readChunkWithTimeout(reader, opts) {
40787
40887
  reader.read(),
40788
40888
  new Promise((_, reject) => {
40789
40889
  idleTimer = setTimeout(() => {
40890
+ const totalIdleMs = Math.max(opts.idleMs, Date.now() - opts.lastUsefulAt());
40790
40891
  reject(
40791
40892
  new Error(
40792
- `Provider stream idle for ${Math.round(waitMs / 1e3)}s (no tokens). The model/gateway stalled \u2014 try again or switch model. Override with ZELARI_PROVIDER_STREAM_IDLE_MS.`
40893
+ `Provider stream idle for ${Math.round(totalIdleMs / 1e3)}s (no useful deltas). The model/gateway stalled \u2014 try again or switch model. Override with ZELARI_PROVIDER_STREAM_IDLE_MS.`
40793
40894
  )
40794
40895
  );
40795
40896
  }, waitMs);
@@ -40837,6 +40938,22 @@ function parseCachedPromptTokens(usage) {
40837
40938
  }
40838
40939
  return 0;
40839
40940
  }
40941
+ function parseOpenAiStreamError(value) {
40942
+ if (!value || typeof value !== "object" || Array.isArray(value)) return null;
40943
+ const root = value;
40944
+ const nested = root.error;
40945
+ if (nested && typeof nested === "object" && !Array.isArray(nested)) {
40946
+ const error51 = nested;
40947
+ const message = typeof error51.message === "string" && error51.message.trim() ? error51.message.trim() : "unknown error";
40948
+ const type = typeof error51.type === "string" && error51.type.trim() ? error51.type.trim() : "server_error";
40949
+ return `Provider stream error (${type}): ${message}`;
40950
+ }
40951
+ if (typeof nested === "string" && nested.trim()) {
40952
+ const type = typeof root.code === "string" && root.code.trim() ? root.code.trim() : "server_error";
40953
+ return `Provider stream error (${type}): ${nested.trim()}`;
40954
+ }
40955
+ return null;
40956
+ }
40840
40957
  function resolveBaseUrl(providerId) {
40841
40958
  const custom2 = getCustomEndpoint(providerId);
40842
40959
  if (custom2) return custom2;
@@ -40914,7 +41031,7 @@ ${notes}
40914
41031
  return { role: m.role, content: m.content };
40915
41032
  }
40916
41033
  function openaiCompatibleProvider(config2) {
40917
- return async function* (params) {
41034
+ const run = async function* (params, streamRetryAttempt = 0) {
40918
41035
  const capabilities = capabilitiesFor(params.model, config2.providerId);
40919
41036
  const vision = modelSupportsVision(params.model);
40920
41037
  const messages = params.messages.map((m) => {
@@ -40973,7 +41090,11 @@ function openaiCompatibleProvider(config2) {
40973
41090
  }));
40974
41091
  const recoveryAttempt = generation?.recoveryAttempt ?? 1;
40975
41092
  const forceRecoveryTool = generation?.toolChoice === "required" && capabilities.buildRecovery.forceToolChoice && recoveryAttempt <= capabilities.buildRecovery.maxForcedTurns;
40976
- body.tool_choice = forceRecoveryTool ? "required" : "auto";
41093
+ if (forceRecoveryTool) {
41094
+ body.tool_choice = "required";
41095
+ } else if (!capabilities.wire.omitAutoToolChoice) {
41096
+ body.tool_choice = "auto";
41097
+ }
40977
41098
  }
40978
41099
  const headers2 = {
40979
41100
  "Content-Type": "application/json",
@@ -40982,8 +41103,16 @@ function openaiCompatibleProvider(config2) {
40982
41103
  };
40983
41104
  const affinityHeader = capabilities.promptCache.conversationAffinityHeader;
40984
41105
  const conversationId = params.conversationId?.trim();
40985
- if (affinityHeader && conversationId && conversationId.length <= 256 && !/[\u0000-\u001f\u007f]/.test(conversationId)) {
40986
- headers2[affinityHeader] = conversationId;
41106
+ const safeConversationId = conversationId && conversationId.length <= 256 && !/[\u0000-\u001f\u007f]/.test(conversationId) ? conversationId : void 0;
41107
+ if (affinityHeader && safeConversationId) {
41108
+ headers2[affinityHeader] = safeConversationId;
41109
+ }
41110
+ if (capabilities.wire.grokRequestHeaders) {
41111
+ headers2.Accept = "text/event-stream";
41112
+ headers2["x-grok-client-identifier"] = "zelari-code";
41113
+ headers2["x-grok-req-id"] = `zelari-${randomUUID2()}`;
41114
+ headers2["x-grok-model-override"] = params.model;
41115
+ if (safeConversationId) headers2["x-grok-session-id"] = safeConversationId;
40987
41116
  }
40988
41117
  let response;
40989
41118
  let lastErrText = "";
@@ -41051,9 +41180,10 @@ function openaiCompatibleProvider(config2) {
41051
41180
  }
41052
41181
  const reader = response.body.getReader();
41053
41182
  const decoder = new TextDecoder();
41054
- let buffer = "";
41183
+ const sseDecoder = new SseDataDecoder();
41055
41184
  const toolCallAccumulator = /* @__PURE__ */ new Map();
41056
41185
  let emittedToolCall = false;
41186
+ let emittedProviderDelta = false;
41057
41187
  let reasoningDetailsBuf = "";
41058
41188
  const tryParseArgs = (raw) => {
41059
41189
  const t = raw.trim();
@@ -41076,6 +41206,7 @@ function openaiCompatibleProvider(config2) {
41076
41206
  if (args === null) continue;
41077
41207
  toolCallAccumulator.delete(idx);
41078
41208
  emittedToolCall = true;
41209
+ emittedProviderDelta = true;
41079
41210
  markUseful();
41080
41211
  yield {
41081
41212
  kind: "tool_call",
@@ -41111,18 +41242,19 @@ function openaiCompatibleProvider(config2) {
41111
41242
  await reader.cancel(msg);
41112
41243
  } catch {
41113
41244
  }
41245
+ if (!emittedProviderDelta && streamRetryAttempt < capabilities.wire.retriesBeforeOutput) {
41246
+ await abortableSleep(backoffDelay(streamRetryAttempt, null), params.signal);
41247
+ yield* run(params, streamRetryAttempt + 1);
41248
+ return;
41249
+ }
41114
41250
  yield { kind: "error", message: msg };
41115
41251
  return;
41116
41252
  }
41117
41253
  const { value, done } = chunk;
41118
- if (done) break;
41119
- buffer += decoder.decode(value, { stream: true });
41120
- const lines = buffer.split("\n");
41121
- buffer = lines.pop() ?? "";
41122
- for (const line of lines) {
41123
- const trimmed = line.trim();
41124
- if (!trimmed.startsWith("data:")) continue;
41125
- const data = trimmed.slice(5).trim();
41254
+ const decoded = done ? decoder.decode() : decoder.decode(value, { stream: true });
41255
+ const events = sseDecoder.push(decoded, done);
41256
+ for (const data of events) {
41257
+ if (data.length === 0) continue;
41126
41258
  if (data === "[DONE]") {
41127
41259
  yield* flushToolAccumulator();
41128
41260
  yield {
@@ -41132,7 +41264,22 @@ function openaiCompatibleProvider(config2) {
41132
41264
  return;
41133
41265
  }
41134
41266
  try {
41135
- const parsed = JSON.parse(data);
41267
+ const rawParsed = JSON.parse(data);
41268
+ const streamError = parseOpenAiStreamError(rawParsed);
41269
+ if (streamError) {
41270
+ try {
41271
+ await reader.cancel(streamError);
41272
+ } catch {
41273
+ }
41274
+ if (!emittedProviderDelta && streamRetryAttempt < capabilities.wire.retriesBeforeOutput) {
41275
+ await abortableSleep(backoffDelay(streamRetryAttempt, null), params.signal);
41276
+ yield* run(params, streamRetryAttempt + 1);
41277
+ return;
41278
+ }
41279
+ yield { kind: "error", message: streamError };
41280
+ return;
41281
+ }
41282
+ const parsed = rawParsed;
41136
41283
  const choice = parsed.choices?.[0];
41137
41284
  const delta = choice?.delta;
41138
41285
  if (parsed.usage && typeof parsed.usage === "object") {
@@ -41141,6 +41288,7 @@ function openaiCompatibleProvider(config2) {
41141
41288
  const totalTokens = typeof parsed.usage.total_tokens === "number" ? parsed.usage.total_tokens : promptTokens + completionTokens;
41142
41289
  const cachedPromptTokens = parseCachedPromptTokens(parsed.usage);
41143
41290
  markUseful();
41291
+ emittedProviderDelta = true;
41144
41292
  yield {
41145
41293
  kind: "usage",
41146
41294
  usage: {
@@ -41153,11 +41301,13 @@ function openaiCompatibleProvider(config2) {
41153
41301
  }
41154
41302
  if (typeof delta?.content === "string" && delta.content.length > 0) {
41155
41303
  markUseful();
41304
+ emittedProviderDelta = true;
41156
41305
  yield { kind: "text", delta: delta.content };
41157
41306
  }
41158
41307
  const reasoning = delta?.reasoning_content ?? delta?.reasoning;
41159
41308
  if (typeof reasoning === "string" && reasoning.length > 0) {
41160
41309
  markUseful();
41310
+ emittedProviderDelta = true;
41161
41311
  yield { kind: "thinking", delta: reasoning };
41162
41312
  }
41163
41313
  const details = delta?.reasoning_details;
@@ -41171,16 +41321,21 @@ function openaiCompatibleProvider(config2) {
41171
41321
  reasoningDetailsBuf = t;
41172
41322
  if (piece.length > 0) {
41173
41323
  markUseful();
41324
+ emittedProviderDelta = true;
41174
41325
  yield { kind: "thinking", delta: piece };
41175
41326
  }
41176
41327
  } else {
41177
41328
  reasoningDetailsBuf += t;
41178
41329
  markUseful();
41330
+ emittedProviderDelta = true;
41179
41331
  yield { kind: "thinking", delta: t };
41180
41332
  }
41181
41333
  }
41182
41334
  }
41183
41335
  if (Array.isArray(delta?.tool_calls)) {
41336
+ if (capabilities.wire.toolCallDeltasResetIdle && delta.tool_calls.length > 0) {
41337
+ markUseful();
41338
+ }
41184
41339
  for (const tc of delta.tool_calls) {
41185
41340
  const idx = tc.index ?? 0;
41186
41341
  const existing = toolCallAccumulator.get(idx) ?? {
@@ -41197,12 +41352,21 @@ function openaiCompatibleProvider(config2) {
41197
41352
  if (choice?.finish_reason) {
41198
41353
  yield* flushToolAccumulator();
41199
41354
  markUseful();
41355
+ emittedProviderDelta = true;
41200
41356
  const reason = choice.finish_reason === "stop" && emittedToolCall ? "tool_calls" : choice.finish_reason;
41201
41357
  yield { kind: "finish", reason };
41202
41358
  }
41203
41359
  } catch {
41360
+ if (capabilities.wire.strictSseJson) {
41361
+ yield {
41362
+ kind: "error",
41363
+ message: "Malformed Grok SSE data event (expected Chat Completions JSON)."
41364
+ };
41365
+ return;
41366
+ }
41204
41367
  }
41205
41368
  }
41369
+ if (done) break;
41206
41370
  }
41207
41371
  yield* flushToolAccumulator();
41208
41372
  yield {
@@ -41213,6 +41377,7 @@ function openaiCompatibleProvider(config2) {
41213
41377
  reader.releaseLock();
41214
41378
  }
41215
41379
  };
41380
+ return (params) => run(params);
41216
41381
  }
41217
41382
  function extraFromStored(providerId) {
41218
41383
  const stored = getOAuthToken(providerId);
@@ -41255,6 +41420,7 @@ var init_openai_compatible = __esm({
41255
41420
  init_providerConfig();
41256
41421
  init_thinking();
41257
41422
  init_capabilities();
41423
+ init_sse();
41258
41424
  RETRYABLE_STATUSES = /* @__PURE__ */ new Set([429, 500, 502, 503, 504]);
41259
41425
  MAX_RETRIES = (() => {
41260
41426
  const raw = process.env.ZELARI_PROVIDER_MAX_RETRIES;
@@ -44233,11 +44399,11 @@ var init_metrics3 = __esm({
44233
44399
  });
44234
44400
 
44235
44401
  // src/cli/state/fileStateStore.ts
44236
- import { createHash as createHash13, randomUUID as randomUUID2 } from "node:crypto";
44402
+ import { createHash as createHash13, randomUUID as randomUUID3 } from "node:crypto";
44237
44403
  import { promises as fs21 } from "node:fs";
44238
44404
  import * as path43 from "node:path";
44239
44405
  function shortId() {
44240
- return randomUUID2().replace(/-/g, "").slice(0, 12);
44406
+ return randomUUID3().replace(/-/g, "").slice(0, 12);
44241
44407
  }
44242
44408
  async function writeJsonAtomic(filePath, data) {
44243
44409
  await fs21.mkdir(path43.dirname(filePath), { recursive: true });
@@ -46604,7 +46770,7 @@ WHERE NOT EXISTS (SELECT 1 FROM memory_fts f WHERE f.node_id = n.id);
46604
46770
  });
46605
46771
 
46606
46772
  // src/cli/memory/sqliteBackend.ts
46607
- import { createHash as createHash15, randomUUID as randomUUID3 } from "node:crypto";
46773
+ import { createHash as createHash15, randomUUID as randomUUID4 } from "node:crypto";
46608
46774
  import { promises as fs23 } from "node:fs";
46609
46775
  import * as path46 from "node:path";
46610
46776
  function boundedLimit(value, fallback = 50) {
@@ -46727,7 +46893,7 @@ VALUES (${Array.from({ length: 19 }, () => "?").join(",")})`;
46727
46893
  const createdAt = input.createdAt ?? now;
46728
46894
  const recordedAt = input.recordedAt ?? createdAt;
46729
46895
  const node = MemoryNodeSchema.parse({
46730
- id: input.id ?? `mem_${randomUUID3()}`,
46896
+ id: input.id ?? `mem_${randomUUID4()}`,
46731
46897
  schemaVersion: 1,
46732
46898
  projectId: input.projectId,
46733
46899
  kind: input.kind,
@@ -46753,7 +46919,7 @@ VALUES (${Array.from({ length: 19 }, () => "?").join(",")})`;
46753
46919
  (version_id, memory_id, revision, snapshot_json, recorded_at, actor, reason)
46754
46920
  VALUES (?, ?, 1, ?, ?, ?, ?)`,
46755
46921
  params: [
46756
- `ver_${randomUUID3()}`,
46922
+ `ver_${randomUUID4()}`,
46757
46923
  node.id,
46758
46924
  JSON.stringify(node),
46759
46925
  recordedAt,
@@ -46814,7 +46980,7 @@ VALUES (${Array.from({ length: 19 }, () => "?").join(",")})`;
46814
46980
  (version_id, memory_id, revision, snapshot_json, recorded_at, actor, reason)
46815
46981
  VALUES (?, ?, (SELECT COALESCE(MAX(revision), 0) + 1 FROM memory_versions WHERE memory_id=?), ?, ?, ?, ?)`,
46816
46982
  params: [
46817
- `ver_${randomUUID3()}`,
46983
+ `ver_${randomUUID4()}`,
46818
46984
  updated.id,
46819
46985
  updated.id,
46820
46986
  JSON.stringify(updated),
@@ -47048,7 +47214,7 @@ VALUES (${Array.from({ length: 19 }, () => "?").join(",")})`;
47048
47214
  if (decoded) return decoded;
47049
47215
  const edge = MemoryEdgeSchema.parse({
47050
47216
  ...input,
47051
- id: input.id ?? `edge_${randomUUID3()}`,
47217
+ id: input.id ?? `edge_${randomUUID4()}`,
47052
47218
  strength: input.strength ?? 1,
47053
47219
  confidence: input.confidence ?? 0.8,
47054
47220
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -50431,7 +50597,7 @@ import { promisify as promisify2 } from "node:util";
50431
50597
  import { mkdtempSync, rmSync as rmSync2 } from "node:fs";
50432
50598
  import { tmpdir as tmpdir2 } from "node:os";
50433
50599
  import path49 from "node:path";
50434
- import { randomUUID as randomUUID4 } from "node:crypto";
50600
+ import { randomUUID as randomUUID5 } from "node:crypto";
50435
50601
  async function git3(cwd, args, env) {
50436
50602
  const { stdout } = await execFileAsync2("git", ["-C", cwd, ...args], {
50437
50603
  maxBuffer: 64 * 1024 * 1024,
@@ -50474,7 +50640,7 @@ async function createCheckpoint(cwd, label = "checkpoint") {
50474
50640
  }
50475
50641
  try {
50476
50642
  const { tree, head } = await snapshotTree(cwd);
50477
- const id3 = randomUUID4().slice(0, 8);
50643
+ const id3 = randomUUID5().slice(0, 8);
50478
50644
  const createdAt = Date.now();
50479
50645
  const message = `zelari-checkpoint ${id3}: ${label}`;
50480
50646
  const commitArgs = ["commit-tree", tree, "-m", message];
@@ -50641,7 +50807,7 @@ __export(fileBackend_exports, {
50641
50807
  getMemoryBackend: () => getMemoryBackend,
50642
50808
  isMemoryEnabled: () => isMemoryEnabled
50643
50809
  });
50644
- import { randomUUID as randomUUID5 } from "node:crypto";
50810
+ import { randomUUID as randomUUID6 } from "node:crypto";
50645
50811
  import { promises as fs26 } from "node:fs";
50646
50812
  import * as path50 from "node:path";
50647
50813
  function tokenize(text) {
@@ -50700,7 +50866,7 @@ var init_fileBackend = __esm({
50700
50866
  }
50701
50867
  async add(content, metadata2 = {}, graph) {
50702
50868
  const fact = {
50703
- id: randomUUID5(),
50869
+ id: randomUUID6(),
50704
50870
  content,
50705
50871
  metadata: metadata2,
50706
50872
  ...graph ? { graph } : {},
@@ -50808,7 +50974,7 @@ __export(zelariMission_exports, {
50808
50974
  resolveMaxTokens: () => resolveMaxTokens,
50809
50975
  runZelariMission: () => runZelariMission
50810
50976
  });
50811
- import { randomUUID as randomUUID6 } from "node:crypto";
50977
+ import { randomUUID as randomUUID7 } from "node:crypto";
50812
50978
  import { promises as fs28 } from "node:fs";
50813
50979
  import * as path52 from "node:path";
50814
50980
  function resolveMaxIterations(env = process.env) {
@@ -50905,7 +51071,7 @@ async function runZelariMission(userMessage, brief, deps) {
50905
51071
  const maxStall = resolveMaxStall(deps.env);
50906
51072
  const maxCost = resolveMaxCost(deps.env);
50907
51073
  const maxTokens = resolveMaxTokens(deps.env);
50908
- const missionId = deps.missionId ?? `m_${randomUUID6().slice(0, 8)}`;
51074
+ const missionId = deps.missionId ?? `m_${randomUUID7().slice(0, 8)}`;
50909
51075
  const startedAt = now().toISOString();
50910
51076
  const state3 = {
50911
51077
  missionId,
@@ -57437,7 +57603,7 @@ var init_mcpCli = __esm({
57437
57603
 
57438
57604
  // src/cli/mcp/mcpPermissionServer.ts
57439
57605
  import { createInterface as createInterface2 } from "node:readline";
57440
- import { randomUUID as randomUUID8 } from "node:crypto";
57606
+ import { randomUUID as randomUUID9 } from "node:crypto";
57441
57607
  function startPermissionMcpServer(opts) {
57442
57608
  const socketPath = opts.socketPath.trim();
57443
57609
  const requestTimeoutMs = opts.requestTimeoutMs ?? PERMISSION_BROKER_DEFAULT_TIMEOUT_MS;
@@ -57533,7 +57699,7 @@ function startPermissionMcpServer(opts) {
57533
57699
  socketPath,
57534
57700
  {
57535
57701
  t: "ask",
57536
- id: randomUUID8(),
57702
+ id: randomUUID9(),
57537
57703
  kind: "permission",
57538
57704
  tool: toolName,
57539
57705
  input: input2,
@@ -57572,7 +57738,7 @@ function startPermissionMcpServer(opts) {
57572
57738
  socketPath,
57573
57739
  {
57574
57740
  t: "ask",
57575
- id: randomUUID8(),
57741
+ id: randomUUID9(),
57576
57742
  kind: "question",
57577
57743
  question,
57578
57744
  choices,
@@ -57864,7 +58030,7 @@ var init_config = __esm({
57864
58030
  // src/cli/companion/runManager.ts
57865
58031
  import { spawn as spawn17 } from "node:child_process";
57866
58032
  import { createInterface as createInterface3 } from "node:readline";
57867
- import { randomUUID as randomUUID9 } from "node:crypto";
58033
+ import { randomUUID as randomUUID10 } from "node:crypto";
57868
58034
  import { writeFileSync as writeFileSync26, unlinkSync as unlinkSync3 } from "node:fs";
57869
58035
  import { join as join44 } from "node:path";
57870
58036
  import { tmpdir as tmpdir3 } from "node:os";
@@ -57933,7 +58099,7 @@ var init_runManager = __esm({
57933
58099
  }
57934
58100
  const prompt = args.prompt?.trim();
57935
58101
  if (!prompt) return { ok: false, error: "prompt is required" };
57936
- const id3 = randomUUID9();
58102
+ const id3 = randomUUID10();
57937
58103
  const mode = (args.mode || "kraken").toLowerCase();
57938
58104
  const phase2 = (args.phase || "build").toLowerCase();
57939
58105
  const run = {
@@ -69525,7 +69691,7 @@ init_taskTool();
69525
69691
  init_sessionTodos();
69526
69692
  import { promises as fs41 } from "node:fs";
69527
69693
  import path68 from "node:path";
69528
- import { randomUUID as randomUUID7 } from "node:crypto";
69694
+ import { randomUUID as randomUUID8 } from "node:crypto";
69529
69695
 
69530
69696
  // src/cli/kraken/verifierLifecycle.ts
69531
69697
  init_verification2();
@@ -69822,7 +69988,7 @@ async function runHeadlessKrakenGraph(opts, provider, model) {
69822
69988
  });
69823
69989
  log(formatKrakenGraphAscii2(graph));
69824
69990
  if (opts.planOnly) {
69825
- const planId = randomUUID7();
69991
+ const planId = randomUUID8();
69826
69992
  const planDir = path68.join(cwd, ".zelari", "radio");
69827
69993
  const planPath = path68.join(planDir, `plan-${planId}.json`);
69828
69994
  await fs41.mkdir(planDir, { recursive: true });