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