@orbit-build/cli 0.7.6 → 0.8.0

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.
Files changed (3) hide show
  1. package/README.md +6 -1
  2. package/dist/index.js +400 -232
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -116,7 +116,12 @@ expose 1,000,000-token context, 384,000-token maximum output, and native
116
116
  low/high/max reasoning. One DeepSeek profile supports Chat Completions,
117
117
  Responses, and Anthropic transports; automatic mode keeps Chat as the default
118
118
  and selects Responses for schema-constrained output. Compatible gateways retain
119
- their explicitly configured transport and per-model discovered context limits.
119
+ their explicitly configured transport, exact model ID, and per-model discovered
120
+ context limits. Model-family behavior is independent from that transport: any
121
+ recognized DeepSeek V4 model on TokenDance, an OpenAI-compatible endpoint, or
122
+ an Anthropic-compatible endpoint automatically receives DeepSeek reasoning,
123
+ tool replay, canonical schema, cache, and context policy. Unknown models remain
124
+ on the conservative generic-compatible path.
120
125
 
121
126
  Credentials use native OS protection when available and are redacted from
122
127
  configuration, diagnostics, events, sessions, and exported traces.
package/dist/index.js CHANGED
@@ -238894,6 +238894,52 @@ async function readResponseJsonWithinLimit(response, maxBytes, label = "HTTP JSO
238894
238894
  await readResponseTextWithinLimit(response, maxBytes, label)
238895
238895
  );
238896
238896
  }
238897
+ function canonicalizeJson(value, ancestors = /* @__PURE__ */ new Set()) {
238898
+ if (value === null || typeof value === "string" || typeof value === "boolean") {
238899
+ return value;
238900
+ }
238901
+ if (typeof value === "number") {
238902
+ if (!Number.isFinite(value)) {
238903
+ throw new TypeError(
238904
+ "Canonical JSON does not support non-finite numbers."
238905
+ );
238906
+ }
238907
+ return value;
238908
+ }
238909
+ if (typeof value !== "object") {
238910
+ throw new TypeError(
238911
+ `Canonical JSON does not support ${typeof value} values.`
238912
+ );
238913
+ }
238914
+ if (ancestors.has(value)) {
238915
+ throw new TypeError("Canonical JSON does not support cyclic values.");
238916
+ }
238917
+ const nextAncestors = new Set(ancestors);
238918
+ nextAncestors.add(value);
238919
+ if (Array.isArray(value)) {
238920
+ return value.map(
238921
+ (item) => canonicalizeArrayValueWithAncestors(item, nextAncestors)
238922
+ );
238923
+ }
238924
+ const result = {};
238925
+ for (const key of Object.keys(value).sort()) {
238926
+ const item = value[key];
238927
+ if (item === void 0 || typeof item === "function" || typeof item === "symbol") {
238928
+ continue;
238929
+ }
238930
+ result[key] = canonicalizeJson(item, nextAncestors);
238931
+ }
238932
+ return result;
238933
+ }
238934
+ function canonicalizeArrayValueWithAncestors(value, ancestors) {
238935
+ if (value === void 0 || typeof value === "function" || typeof value === "symbol") {
238936
+ return null;
238937
+ }
238938
+ return canonicalizeJson(value, ancestors);
238939
+ }
238940
+ function canonicalJsonStringify(value) {
238941
+ return JSON.stringify(canonicalizeJson(value));
238942
+ }
238897
238943
 
238898
238944
  // src/commands/init.ts
238899
238945
  import picocolors from "picocolors";
@@ -242645,6 +242691,7 @@ var zodToJsonSchema = (schema, options) => {
242645
242691
  };
242646
242692
 
242647
242693
  // ../model-providers/dist/index.js
242694
+ import { createHash as createHash2 } from "crypto";
242648
242695
  import { z as z9 } from "zod";
242649
242696
  import { z as z23 } from "zod";
242650
242697
  import { z as z33 } from "zod";
@@ -242750,6 +242797,10 @@ function resolveModelAdaptation(model) {
242750
242797
  const deepSeekV4 = getDeepSeekV4ModelProfile(model);
242751
242798
  return deepSeekV4 ? { family: "deepseek-v4", requestedModel: model, deepSeekV4 } : { family: "generic", requestedModel: model };
242752
242799
  }
242800
+ function resolveDeepSeekModelProfile(model) {
242801
+ const adaptation = resolveModelAdaptation(model);
242802
+ return adaptation.family === "deepseek-v4" ? adaptation.deepSeekV4 : void 0;
242803
+ }
242753
242804
  function resolveModelThinkingPolicy(model, context) {
242754
242805
  const adaptation = resolveModelAdaptation(model);
242755
242806
  if (adaptation.family === "deepseek-v4") {
@@ -243039,6 +243090,113 @@ function parseRetryAfterMs(value) {
243039
243090
  }
243040
243091
  return void 0;
243041
243092
  }
243093
+ var MAX_PROVIDER_TOOLS = 128;
243094
+ var TOOL_NAME_PATTERN = /^[A-Za-z0-9_-]{1,64}$/;
243095
+ function normalizeJsonSchemaSets(value) {
243096
+ if (Array.isArray(value)) {
243097
+ return value.map((item) => normalizeJsonSchemaSets(item));
243098
+ }
243099
+ if (value === null || typeof value !== "object") return value;
243100
+ const result = {};
243101
+ for (const [key, item] of Object.entries(value)) {
243102
+ if (key === "required" && Array.isArray(item) && item.every((entry) => typeof entry === "string")) {
243103
+ result[key] = [...item].sort();
243104
+ } else {
243105
+ result[key] = normalizeJsonSchemaSets(item);
243106
+ }
243107
+ }
243108
+ return result;
243109
+ }
243110
+ function canonicalizeToolDefinitions(tools) {
243111
+ if (tools === void 0) return void 0;
243112
+ if (tools.length > MAX_PROVIDER_TOOLS) {
243113
+ throw new Error(
243114
+ `Provider requests support at most ${MAX_PROVIDER_TOOLS} tools.`
243115
+ );
243116
+ }
243117
+ const seen = /* @__PURE__ */ new Set();
243118
+ const canonical = tools.map((tool) => {
243119
+ if (!TOOL_NAME_PATTERN.test(tool.name)) {
243120
+ throw new Error(
243121
+ `Invalid provider tool name "${tool.name}". Use 1-64 letters, digits, underscores, or hyphens.`
243122
+ );
243123
+ }
243124
+ if (seen.has(tool.name)) {
243125
+ throw new Error(`Duplicate provider tool name "${tool.name}".`);
243126
+ }
243127
+ seen.add(tool.name);
243128
+ const schema = canonicalizeJson(
243129
+ normalizeJsonSchemaSets(
243130
+ tool.inputJsonSchema ?? zodToJsonSchema2(tool.inputSchema)
243131
+ )
243132
+ );
243133
+ if (Array.isArray(schema) || schema === null || typeof schema !== "object") {
243134
+ throw new Error(
243135
+ `Provider tool "${tool.name}" must use an object JSON Schema.`
243136
+ );
243137
+ }
243138
+ return {
243139
+ ...tool,
243140
+ inputJsonSchema: schema
243141
+ };
243142
+ });
243143
+ canonical.sort((left, right) => left.name.localeCompare(right.name, "en"));
243144
+ return canonical;
243145
+ }
243146
+ function toolDefinitionsFingerprint(tools) {
243147
+ const canonical = canonicalizeToolDefinitions(tools) ?? [];
243148
+ const wireCatalog = canonical.map((tool) => ({
243149
+ name: tool.name,
243150
+ description: tool.description,
243151
+ parameters: tool.inputJsonSchema
243152
+ }));
243153
+ return createHash2("sha256").update(canonicalJsonStringify(wireCatalog)).digest("hex");
243154
+ }
243155
+ function canonicalizeModelChatInput(input) {
243156
+ const tools = canonicalizeToolDefinitions(input.tools);
243157
+ return tools === void 0 ? input : { ...input, tools };
243158
+ }
243159
+ function validateDeepSeekUserId(userId) {
243160
+ if (userId === void 0) return;
243161
+ if (userId.length === 0 || userId.length > 512) {
243162
+ throw new Error(
243163
+ "DeepSeek user_id must contain between 1 and 512 characters."
243164
+ );
243165
+ }
243166
+ }
243167
+ var ProviderConnectionPreheater = class {
243168
+ constructor(endpoint, disabled = false, timeoutMs = 1e3) {
243169
+ this.endpoint = endpoint;
243170
+ this.disabled = disabled;
243171
+ this.timeoutMs = timeoutMs;
243172
+ }
243173
+ endpoint;
243174
+ disabled;
243175
+ timeoutMs;
243176
+ initialization;
243177
+ initialize() {
243178
+ if (this.disabled || !this.endpoint || typeof fetch !== "function") {
243179
+ return Promise.resolve();
243180
+ }
243181
+ this.initialization ??= this.preheat();
243182
+ return this.initialization;
243183
+ }
243184
+ async preheat() {
243185
+ const controller = new AbortController();
243186
+ const timeout = setTimeout(() => controller.abort(), this.timeoutMs);
243187
+ timeout.unref?.();
243188
+ try {
243189
+ const response = await fetch(this.endpoint, {
243190
+ method: "HEAD",
243191
+ signal: controller.signal
243192
+ });
243193
+ await response.body?.cancel().catch(() => void 0);
243194
+ } catch {
243195
+ } finally {
243196
+ clearTimeout(timeout);
243197
+ }
243198
+ }
243199
+ };
243042
243200
  var MAX_TOOL_ARGUMENT_CHARS = 4 * 1024 * 1024;
243043
243201
  function parseJsonObjectToolArguments(argumentsText, messages) {
243044
243202
  if (argumentsText.length > MAX_TOOL_ARGUMENT_CHARS) {
@@ -243185,6 +243343,10 @@ var AnthropicCompatibleProvider = class {
243185
243343
  this.apiKey = apiKey;
243186
243344
  this.baseUrl = baseUrl;
243187
243345
  this.options = options;
243346
+ this.connectionPreheater = new ProviderConnectionPreheater(
243347
+ baseUrl,
243348
+ options.disablePreheat
243349
+ );
243188
243350
  if (options.id) {
243189
243351
  this.id = options.id;
243190
243352
  }
@@ -243192,6 +243354,7 @@ var AnthropicCompatibleProvider = class {
243192
243354
  apiKey;
243193
243355
  baseUrl;
243194
243356
  options;
243357
+ connectionPreheater;
243195
243358
  id = "anthropic-compatible";
243196
243359
  type = "anthropic-compatible";
243197
243360
  capabilities = {
@@ -243202,28 +243365,14 @@ var AnthropicCompatibleProvider = class {
243202
243365
  vision: false,
243203
243366
  promptCaching: true
243204
243367
  };
243205
- isDeepSeekDialect() {
243368
+ isConfiguredDeepSeekDialect() {
243206
243369
  return this.options.anthropicDialect === "deepseek";
243207
243370
  }
243208
- async initialize() {
243209
- if (this.options.disablePreheat) return;
243210
- try {
243211
- if (this.baseUrl && typeof fetch === "function") {
243212
- const controller = new AbortController();
243213
- const timeout = setTimeout(() => controller.abort(), 1e3);
243214
- timeout.unref?.();
243215
- try {
243216
- const response = await fetch(this.baseUrl, {
243217
- method: "HEAD",
243218
- signal: controller.signal
243219
- });
243220
- await response.body?.cancel().catch(() => void 0);
243221
- } finally {
243222
- clearTimeout(timeout);
243223
- }
243224
- }
243225
- } catch {
243226
- }
243371
+ isOfficialDeepSeekEndpoint() {
243372
+ return this.isConfiguredDeepSeekDialect() && isOfficialDeepSeekApi(this.baseUrl);
243373
+ }
243374
+ initialize() {
243375
+ return this.connectionPreheater.initialize();
243227
243376
  }
243228
243377
  getDefaultApiKeyEnv() {
243229
243378
  if (this.options.apiKeyEnv) {
@@ -243284,9 +243433,9 @@ var AnthropicCompatibleProvider = class {
243284
243433
  return "low";
243285
243434
  }
243286
243435
  getModelCapabilities(model) {
243287
- if (this.isDeepSeekDialect()) {
243288
- const profile = getDeepSeekV4ModelProfile(model);
243289
- if (!profile || profile.legacyAlias || !profile.officialRequestModel) {
243436
+ const profile = resolveDeepSeekModelProfile(model);
243437
+ if (profile) {
243438
+ if (this.isOfficialDeepSeekEndpoint() && (profile.legacyAlias || !profile.officialRequestModel)) {
243290
243439
  return {
243291
243440
  streaming: true,
243292
243441
  toolCalls: false,
@@ -243332,6 +243481,12 @@ var AnthropicCompatibleProvider = class {
243332
243481
  };
243333
243482
  }
243334
243483
  async *chat(input) {
243484
+ try {
243485
+ input = canonicalizeModelChatInput(input);
243486
+ } catch (error) {
243487
+ yield { type: "error", error: toError(error) };
243488
+ return;
243489
+ }
243335
243490
  if (this.options.totalTimeoutMs) {
243336
243491
  const totalSignal = AbortSignal.timeout(this.options.totalTimeoutMs);
243337
243492
  input = {
@@ -243351,8 +243506,9 @@ var AnthropicCompatibleProvider = class {
243351
243506
  return;
243352
243507
  }
243353
243508
  const capabilities = this.getModelCapabilities(input.model);
243354
- const deepSeekProfile = this.isDeepSeekDialect() ? getDeepSeekV4ModelProfile(input.model) : void 0;
243355
- if (this.isDeepSeekDialect() && (!deepSeekProfile || deepSeekProfile.legacyAlias || !deepSeekProfile.officialRequestModel)) {
243509
+ const deepSeekProfile = resolveDeepSeekModelProfile(input.model);
243510
+ const deepSeekSemantics = deepSeekProfile !== void 0;
243511
+ if (this.isConfiguredDeepSeekDialect() && !deepSeekProfile || this.isOfficialDeepSeekEndpoint() && deepSeekProfile !== void 0 && (deepSeekProfile.legacyAlias || !deepSeekProfile.officialRequestModel)) {
243356
243512
  yield {
243357
243513
  type: "error",
243358
243514
  error: new Error(
@@ -243365,30 +243521,9 @@ var AnthropicCompatibleProvider = class {
243365
243521
  let tools;
243366
243522
  let maxTokens;
243367
243523
  try {
243368
- if (this.isDeepSeekDialect()) {
243369
- if (input.userId && !/^[A-Za-z0-9_-]{1,512}$/.test(input.userId)) {
243370
- throw new Error(
243371
- "DeepSeek userId must contain only letters, digits, underscores, or dashes and be at most 512 characters."
243372
- );
243373
- }
243374
- if ((input.tools?.length ?? 0) > 128) {
243375
- throw new Error("DeepSeek accepts at most 128 tools per request.");
243376
- }
243377
- const toolNames = /* @__PURE__ */ new Set();
243378
- for (const tool of input.tools ?? []) {
243379
- if (!/^[A-Za-z0-9_-]{1,64}$/.test(tool.name)) {
243380
- throw new Error(
243381
- "Invalid DeepSeek tool name. Use 1-64 letters, digits, underscores, or dashes."
243382
- );
243383
- }
243384
- if (toolNames.has(tool.name)) {
243385
- throw new Error(`DeepSeek tool name "${tool.name}" is duplicated.`);
243386
- }
243387
- toolNames.add(tool.name);
243388
- }
243389
- }
243524
+ if (deepSeekSemantics) validateDeepSeekUserId(input.userId);
243390
243525
  for (const message2 of input.messages) {
243391
- if (this.isDeepSeekDialect() && message2.content.some((block2) => block2.type === "image")) {
243526
+ if (deepSeekSemantics && message2.content.some((block2) => block2.type === "image")) {
243392
243527
  throw new Error(
243393
243528
  "The selected DeepSeek model does not accept image input. Switch to a vision-capable model or remove the attachment."
243394
243529
  );
@@ -243424,7 +243559,7 @@ var AnthropicCompatibleProvider = class {
243424
243559
  })) : void 0;
243425
243560
  maxTokens = Math.min(
243426
243561
  normalizeAnthropicMaxTokens(input.maxTokens, 16384),
243427
- this.isDeepSeekDialect() ? DEEPSEEK_V4_MAX_OUTPUT_TOKENS : Number.MAX_SAFE_INTEGER
243562
+ deepSeekSemantics ? DEEPSEEK_V4_MAX_OUTPUT_TOKENS : Number.MAX_SAFE_INTEGER
243428
243563
  );
243429
243564
  } catch (error) {
243430
243565
  yield { type: "error", error: toError(error) };
@@ -243473,7 +243608,7 @@ var AnthropicCompatibleProvider = class {
243473
243608
  }
243474
243609
  const body = {
243475
243610
  ...this.options.extraBody ?? {},
243476
- model: deepSeekProfile?.canonicalModel ?? input.model,
243611
+ model: this.isOfficialDeepSeekEndpoint() && deepSeekProfile ? deepSeekProfile.canonicalModel : input.model,
243477
243612
  messages: anthropicMessages,
243478
243613
  max_tokens: maxTokens,
243479
243614
  system: systemParam,
@@ -243562,12 +243697,15 @@ var AnthropicCompatibleProvider = class {
243562
243697
  this.getEndpointUrl("/v1/messages"),
243563
243698
  {
243564
243699
  method: "POST",
243565
- headers: this.buildJsonHeaders(key),
243700
+ headers: {
243701
+ ...this.buildJsonHeaders(key),
243702
+ Accept: body.stream ? "text/event-stream" : "application/json"
243703
+ },
243566
243704
  body: JSON.stringify(body),
243567
243705
  signal: chatSignal,
243568
243706
  timeout: this.options.requestTimeoutMs
243569
243707
  },
243570
- this.options.maxRetries ?? (this.isDeepSeekDialect() ? 0 : 2)
243708
+ this.options.maxRetries ?? (this.isOfficialDeepSeekEndpoint() ? 0 : 2)
243571
243709
  );
243572
243710
  } catch (error) {
243573
243711
  yield {
@@ -243581,7 +243719,7 @@ var AnthropicCompatibleProvider = class {
243581
243719
  yield {
243582
243720
  type: "error",
243583
243721
  error: providerHttpError(
243584
- this.isDeepSeekDialect() ? "DeepSeek Anthropic" : "Anthropic-compatible",
243722
+ deepSeekSemantics ? "DeepSeek Anthropic" : "Anthropic-compatible",
243585
243723
  response.status,
243586
243724
  errText,
243587
243725
  [key],
@@ -243620,7 +243758,7 @@ var AnthropicCompatibleProvider = class {
243620
243758
  input.thinking?.budgetTokens,
243621
243759
  input.thinking?.effort
243622
243760
  ),
243623
- endpointKind: "official"
243761
+ endpointKind: this.isOfficialDeepSeekEndpoint() ? "official" : "gateway"
243624
243762
  };
243625
243763
  }
243626
243764
  try {
@@ -243757,7 +243895,7 @@ var AnthropicCompatibleProvider = class {
243757
243895
  input.thinking?.budgetTokens,
243758
243896
  input.thinking?.effort
243759
243897
  ),
243760
- endpointKind: "official"
243898
+ endpointKind: this.isOfficialDeepSeekEndpoint() ? "official" : "gateway"
243761
243899
  };
243762
243900
  }
243763
243901
  if (parsed.message?.usage) {
@@ -244656,6 +244794,85 @@ async function* chatWithDeepSeekResponses(input, options) {
244656
244794
  input.abortSignal?.removeEventListener("abort", onAbort);
244657
244795
  }
244658
244796
  }
244797
+ function buildDeepSeekChatMessages(input, isDeepSeekV4) {
244798
+ const messages = [];
244799
+ for (const message2 of input.messages) {
244800
+ const text2 = message2.content.filter((block2) => block2.type === "text").map((block2) => block2.text).join("\n");
244801
+ const images = message2.content.filter((block2) => block2.type === "image");
244802
+ if (images.length > 0 && isDeepSeekV4) {
244803
+ throw new Error(
244804
+ "The selected DeepSeek model does not accept image input. Switch to a vision-capable model or remove the attachment."
244805
+ );
244806
+ }
244807
+ if (message2.role === "tool") {
244808
+ const results = message2.content.filter(
244809
+ (block2) => block2.type === "tool_result"
244810
+ );
244811
+ if (results.length === 0) {
244812
+ throw new Error(
244813
+ "A tool-role message must contain at least one tool result."
244814
+ );
244815
+ }
244816
+ for (const block2 of results) {
244817
+ messages.push({
244818
+ role: "tool",
244819
+ tool_call_id: block2.toolResult.toolCallId,
244820
+ content: block2.toolResult.content || "(no output)"
244821
+ });
244822
+ }
244823
+ continue;
244824
+ }
244825
+ const toolCalls = message2.content.filter((block2) => block2.type === "tool_call").map((block2) => {
244826
+ if (isDeepSeekV4) {
244827
+ validateJsonObjectToolArguments(block2.toolCall.arguments);
244828
+ }
244829
+ return {
244830
+ id: block2.toolCall.id,
244831
+ type: "function",
244832
+ function: {
244833
+ name: block2.toolCall.name,
244834
+ arguments: block2.toolCall.arguments
244835
+ }
244836
+ };
244837
+ });
244838
+ if (toolCalls.length > 0 && message2.role !== "assistant") {
244839
+ throw new Error("Tool-call content is only valid in assistant messages.");
244840
+ }
244841
+ if (message2.role === "assistant") {
244842
+ const reasoning = message2.content.filter((block2) => block2.type === "thinking").map((block2) => block2.text).join("\n");
244843
+ const content = isDeepSeekV4 ? text2 : reasoning ? `<think>
244844
+ ${reasoning}
244845
+ </think>
244846
+ ${text2}` : text2 || null;
244847
+ const assistant = {
244848
+ role: "assistant",
244849
+ content
244850
+ };
244851
+ if (toolCalls.length > 0) {
244852
+ assistant.tool_calls = toolCalls;
244853
+ if (isDeepSeekV4) assistant.reasoning_content = reasoning || "";
244854
+ }
244855
+ messages.push(assistant);
244856
+ continue;
244857
+ }
244858
+ if (message2.role === "user" && images.length > 0) {
244859
+ messages.push({
244860
+ role: "user",
244861
+ content: [
244862
+ ...text2 ? [{ type: "text", text: text2 }] : [],
244863
+ ...images.map((image) => ({
244864
+ type: "image_url",
244865
+ image_url: { url: `data:${image.mediaType};base64,${image.data}` }
244866
+ }))
244867
+ ]
244868
+ });
244869
+ } else {
244870
+ messages.push({ role: message2.role, content: text2 });
244871
+ }
244872
+ }
244873
+ if (input.system) messages.unshift({ role: "system", content: input.system });
244874
+ return messages;
244875
+ }
244659
244876
  var ProviderTokenCountSchema2 = z33.number().int().nonnegative().max(1e9);
244660
244877
  var ProviderCollectionIndexSchema2 = z33.number().int().nonnegative().max(1e6);
244661
244878
  var OpenAIUsageSchema = z33.object({
@@ -244734,8 +244951,6 @@ var OpenAICompletionResponseSchema = z33.object({
244734
244951
  }).passthrough()
244735
244952
  ).max(100)
244736
244953
  });
244737
- var OfficialDeepSeekUserIdSchema = z33.string().min(1).max(512).regex(/^[A-Za-z0-9_-]+$/);
244738
- var OfficialDeepSeekToolNameSchema = z33.string().min(1).max(64).regex(/^[A-Za-z0-9_-]+$/);
244739
244954
  var MAX_STREAM_FRAME_CHARS3 = 4 * 1024 * 1024;
244740
244955
  var MAX_STREAM_TOTAL_CHARS3 = 8 * 1024 * 1024;
244741
244956
  var MAX_STREAM_TOOL_CALLS3 = 1e3;
@@ -244763,29 +244978,6 @@ function validateDeepSeekV4Temperature(value) {
244763
244978
  return value;
244764
244979
  }
244765
244980
  function validateDeepSeekV4RequestInput(input) {
244766
- if (input.userId) {
244767
- const result = OfficialDeepSeekUserIdSchema.safeParse(input.userId);
244768
- if (!result.success) {
244769
- throw new Error(
244770
- "DeepSeek userId must contain only letters, digits, underscores, or dashes and be at most 512 characters."
244771
- );
244772
- }
244773
- }
244774
- if ((input.tools?.length ?? 0) > 128) {
244775
- throw new Error("DeepSeek accepts at most 128 tools per request.");
244776
- }
244777
- const toolNames = /* @__PURE__ */ new Set();
244778
- for (const tool of input.tools ?? []) {
244779
- if (!OfficialDeepSeekToolNameSchema.safeParse(tool.name).success) {
244780
- throw new Error(
244781
- "Invalid DeepSeek tool name. Use 1-64 letters, digits, underscores, or dashes."
244782
- );
244783
- }
244784
- if (toolNames.has(tool.name)) {
244785
- throw new Error(`DeepSeek tool name "${tool.name}" is duplicated.`);
244786
- }
244787
- toolNames.add(tool.name);
244788
- }
244789
244981
  if ((input.stopSequences?.length ?? 0) > 16) {
244790
244982
  throw new Error("DeepSeek accepts at most 16 stop sequences.");
244791
244983
  }
@@ -244797,91 +244989,6 @@ function validateDeepSeekV4RequestInput(input) {
244797
244989
  validateDeepSeekV4Temperature(input.temperature);
244798
244990
  }
244799
244991
  }
244800
- function buildOpenAIRequestMessages(input, isDeepSeekV4) {
244801
- const messages = [];
244802
- for (const message2 of input.messages) {
244803
- const text2 = message2.content.filter((block2) => block2.type === "text").map((block2) => block2.text).join("\n");
244804
- const images = message2.content.filter((block2) => block2.type === "image");
244805
- if (images.length > 0 && isDeepSeekV4) {
244806
- throw new Error(
244807
- "The selected DeepSeek model does not accept image input. Switch to a vision-capable model or remove the attachment."
244808
- );
244809
- }
244810
- if (message2.role === "tool") {
244811
- const toolResults = message2.content.filter(
244812
- (block2) => block2.type === "tool_result"
244813
- );
244814
- if (toolResults.length === 0) {
244815
- throw new Error(
244816
- "A tool-role message must contain at least one tool result."
244817
- );
244818
- }
244819
- for (const block2 of toolResults) {
244820
- messages.push({
244821
- role: "tool",
244822
- tool_call_id: block2.toolResult.toolCallId,
244823
- content: block2.toolResult.content || "(no output)"
244824
- });
244825
- }
244826
- continue;
244827
- }
244828
- const toolCalls = message2.content.filter((block2) => block2.type === "tool_call").map((block2) => {
244829
- if (isDeepSeekV4) {
244830
- validateJsonObjectToolArguments(block2.toolCall.arguments);
244831
- }
244832
- return {
244833
- id: block2.toolCall.id,
244834
- type: "function",
244835
- function: {
244836
- name: block2.toolCall.name,
244837
- arguments: block2.toolCall.arguments
244838
- }
244839
- };
244840
- });
244841
- if (toolCalls.length > 0 && message2.role !== "assistant") {
244842
- throw new Error("Tool-call content is only valid in assistant messages.");
244843
- }
244844
- if (message2.role === "assistant") {
244845
- const reasoningContent = message2.content.filter((block2) => block2.type === "thinking").map((block2) => block2.text).join("\n");
244846
- const content = reasoningContent && !isDeepSeekV4 ? `<think>
244847
- ${reasoningContent}
244848
- </think>
244849
- ${text2}` : text2 || (toolCalls.length > 0 && isDeepSeekV4 ? "" : null);
244850
- const assistantMessage = {
244851
- role: "assistant",
244852
- content
244853
- };
244854
- if (toolCalls.length > 0) {
244855
- assistantMessage.tool_calls = toolCalls;
244856
- if (isDeepSeekV4) {
244857
- assistantMessage.reasoning_content = reasoningContent || "";
244858
- }
244859
- }
244860
- messages.push(assistantMessage);
244861
- continue;
244862
- }
244863
- if (message2.role === "user" && images.length > 0) {
244864
- messages.push({
244865
- role: "user",
244866
- content: [
244867
- ...text2 ? [{ type: "text", text: text2 }] : [],
244868
- ...images.map((image) => ({
244869
- type: "image_url",
244870
- image_url: {
244871
- url: `data:${image.mediaType};base64,${image.data}`
244872
- }
244873
- }))
244874
- ]
244875
- });
244876
- } else {
244877
- messages.push({ role: message2.role, content: text2 });
244878
- }
244879
- }
244880
- if (input.system) {
244881
- messages.unshift({ role: "system", content: input.system });
244882
- }
244883
- return messages;
244884
- }
244885
244992
  var STREAMING_THINK_TAGS = [
244886
244993
  { open: "<think>", close: "</think>" },
244887
244994
  { open: "<thinking>", close: "</thinking>" },
@@ -244988,11 +245095,15 @@ var StreamingThinkParser = class {
244988
245095
  return events;
244989
245096
  }
244990
245097
  };
244991
- var DeepSeekOpenAIProvider = class _DeepSeekOpenAIProvider {
245098
+ var OpenAICompatibleProvider = class _OpenAICompatibleProvider {
244992
245099
  constructor(apiKey, baseUrl = "https://api.deepseek.com", options = {}) {
244993
245100
  this.apiKey = apiKey;
244994
245101
  this.baseUrl = baseUrl;
244995
245102
  this.options = options;
245103
+ this.connectionPreheater = new ProviderConnectionPreheater(
245104
+ baseUrl,
245105
+ options.disablePreheat
245106
+ );
244996
245107
  if (options.id) {
244997
245108
  this.id = options.id;
244998
245109
  }
@@ -245001,8 +245112,9 @@ var DeepSeekOpenAIProvider = class _DeepSeekOpenAIProvider {
245001
245112
  baseUrl;
245002
245113
  options;
245003
245114
  static RESPONSES_CIRCUIT_TTL_MS = 5 * 60 * 1e3;
245115
+ connectionPreheater;
245004
245116
  responsesEndpointCircuit;
245005
- id = "deepseek-openai";
245117
+ id = "openai-compatible";
245006
245118
  type = "openai-compatible";
245007
245119
  capabilities = {
245008
245120
  streaming: true,
@@ -245012,25 +245124,8 @@ var DeepSeekOpenAIProvider = class _DeepSeekOpenAIProvider {
245012
245124
  vision: false,
245013
245125
  promptCaching: true
245014
245126
  };
245015
- async initialize() {
245016
- if (this.options.disablePreheat) return;
245017
- try {
245018
- if (this.baseUrl && typeof fetch === "function") {
245019
- const controller = new AbortController();
245020
- const timeout = setTimeout(() => controller.abort(), 1e3);
245021
- timeout.unref?.();
245022
- try {
245023
- const response = await fetch(this.baseUrl, {
245024
- method: "HEAD",
245025
- signal: controller.signal
245026
- });
245027
- await response.body?.cancel().catch(() => void 0);
245028
- } finally {
245029
- clearTimeout(timeout);
245030
- }
245031
- }
245032
- } catch {
245033
- }
245127
+ initialize() {
245128
+ return this.connectionPreheater.initialize();
245034
245129
  }
245035
245130
  getEndpointUrl(path9) {
245036
245131
  const base = this.baseUrl.endsWith("/") ? this.baseUrl.slice(0, -1) : this.baseUrl;
@@ -245118,6 +245213,13 @@ var DeepSeekOpenAIProvider = class _DeepSeekOpenAIProvider {
245118
245213
  };
245119
245214
  }
245120
245215
  async *chat(input) {
245216
+ try {
245217
+ input = canonicalizeModelChatInput(input);
245218
+ validateDeepSeekUserId(input.userId);
245219
+ } catch (error) {
245220
+ yield { type: "error", error: toError(error) };
245221
+ return;
245222
+ }
245121
245223
  if (this.options.totalTimeoutMs) {
245122
245224
  const totalSignal = AbortSignal.timeout(this.options.totalTimeoutMs);
245123
245225
  input = {
@@ -245172,7 +245274,10 @@ var DeepSeekOpenAIProvider = class _DeepSeekOpenAIProvider {
245172
245274
  };
245173
245275
  yield* chatWithDeepSeekResponses(responsesInput, {
245174
245276
  endpoint: this.getEndpointUrl("/v1/responses"),
245175
- headers: this.buildJsonHeaders(key),
245277
+ headers: {
245278
+ ...this.buildJsonHeaders(key),
245279
+ Accept: "text/event-stream"
245280
+ },
245176
245281
  apiKey: key,
245177
245282
  runtime: this.options,
245178
245283
  profile: deepSeekV4Profile,
@@ -245192,14 +245297,14 @@ var DeepSeekOpenAIProvider = class _DeepSeekOpenAIProvider {
245192
245297
  responsesFallbackStatus = error.status;
245193
245298
  this.responsesEndpointCircuit = {
245194
245299
  status: error.status,
245195
- unavailableUntil: Date.now() + _DeepSeekOpenAIProvider.RESPONSES_CIRCUIT_TTL_MS
245300
+ unavailableUntil: Date.now() + _OpenAICompatibleProvider.RESPONSES_CIRCUIT_TTL_MS
245196
245301
  };
245197
245302
  }
245198
245303
  }
245199
245304
  let openaiMessages;
245200
245305
  let tools;
245201
245306
  try {
245202
- openaiMessages = buildOpenAIRequestMessages(input, isDeepSeekV4);
245307
+ openaiMessages = buildDeepSeekChatMessages(input, isDeepSeekV4);
245203
245308
  tools = input.tools?.map((tool) => ({
245204
245309
  type: "function",
245205
245310
  function: {
@@ -245339,7 +245444,10 @@ ${jsonInstruction}`;
245339
245444
  this.getEndpointUrl("/v1/chat/completions"),
245340
245445
  {
245341
245446
  method: "POST",
245342
- headers: this.buildJsonHeaders(key),
245447
+ headers: {
245448
+ ...this.buildJsonHeaders(key),
245449
+ Accept: body.stream ? "text/event-stream" : "application/json"
245450
+ },
245343
245451
  body: JSON.stringify(body),
245344
245452
  signal: chatSignal,
245345
245453
  timeout: this.options.requestTimeoutMs
@@ -245901,11 +246009,11 @@ var DeepSeekProvider = class {
245901
246009
  id: this.id,
245902
246010
  maxRetries: options.maxRetries ?? 0
245903
246011
  };
245904
- this.chatTransport = new DeepSeekOpenAIProvider(apiKey, baseUrl, {
246012
+ this.chatTransport = new OpenAICompatibleProvider(apiKey, baseUrl, {
245905
246013
  ...common,
245906
246014
  deepSeekApiFormat: "chat-completions"
245907
246015
  });
245908
- this.responsesTransport = new DeepSeekOpenAIProvider(apiKey, baseUrl, {
246016
+ this.responsesTransport = new OpenAICompatibleProvider(apiKey, baseUrl, {
245909
246017
  ...common,
245910
246018
  deepSeekApiFormat: "responses"
245911
246019
  });
@@ -245963,8 +246071,12 @@ var DeepSeekProvider = class {
245963
246071
  }
245964
246072
  chat(input) {
245965
246073
  const format = this.selectFormat(input);
245966
- if (format === "anthropic") return this.anthropicTransport.chat(input);
245967
- if (format === "responses") return this.responsesTransport.chat(input);
246074
+ if (format === "anthropic") {
246075
+ return this.anthropicTransport.chat(input);
246076
+ }
246077
+ if (format === "responses") {
246078
+ return this.responsesTransport.chat(input);
246079
+ }
245968
246080
  return this.chatTransport.chat(input);
245969
246081
  }
245970
246082
  embed(texts, options) {
@@ -245984,7 +246096,7 @@ var DeepSeekProvider = class {
245984
246096
  return baseUrl.endsWith("/anthropic") ? baseUrl : `${baseUrl.replace(/\/$/, "")}/anthropic`;
245985
246097
  }
245986
246098
  };
245987
- var OpenAIProvider = class extends DeepSeekOpenAIProvider {
246099
+ var OpenAIProvider = class extends OpenAICompatibleProvider {
245988
246100
  id = "openai";
245989
246101
  type = "openai";
245990
246102
  constructor(apiKey, baseUrl = "https://api.openai.com/v1", options = {}) {
@@ -246004,7 +246116,7 @@ var AnthropicProvider = class extends AnthropicCompatibleProvider {
246004
246116
  });
246005
246117
  }
246006
246118
  };
246007
- var OllamaProvider = class extends DeepSeekOpenAIProvider {
246119
+ var OllamaProvider = class extends OpenAICompatibleProvider {
246008
246120
  id = "ollama";
246009
246121
  type = "ollama";
246010
246122
  constructor(baseUrl = "http://localhost:11434", options = {}) {
@@ -246030,7 +246142,7 @@ import picocolors4 from "picocolors";
246030
246142
 
246031
246143
  // ../core/dist/index.js
246032
246144
  import { existsSync as existsSync11, readdirSync as readdirSync4 } from "fs";
246033
- import { createHash as createHash6 } from "crypto";
246145
+ import { createHash as createHash7 } from "crypto";
246034
246146
  import { join as join10 } from "path";
246035
246147
  import { z as z31 } from "zod";
246036
246148
  import { z as z211 } from "zod";
@@ -247648,7 +247760,7 @@ var $ = create$();
247648
247760
  import { z as z52 } from "zod";
247649
247761
  import { z as z62 } from "zod";
247650
247762
  import { z as z72 } from "zod";
247651
- import { createHash as createHash2 } from "crypto";
247763
+ import { createHash as createHash3 } from "crypto";
247652
247764
  import { z as z82 } from "zod";
247653
247765
  import { z as z92 } from "zod";
247654
247766
  import { z as z102 } from "zod";
@@ -248805,7 +248917,7 @@ var WriteFileTool = class {
248805
248917
  error: `Cannot verify expectedHash because the file does not exist: ${input.path}`
248806
248918
  };
248807
248919
  }
248808
- const currentHash = createHash2("sha256").update(current).digest("hex");
248920
+ const currentHash = createHash3("sha256").update(current).digest("hex");
248809
248921
  if (currentHash !== input.expectedHash.toLowerCase()) {
248810
248922
  return {
248811
248923
  ok: false,
@@ -251520,7 +251632,7 @@ import { basename, join as join7 } from "path";
251520
251632
  import { existsSync as existsSync43, writeFileSync as writeFileSync4, mkdirSync as mkdirSync3, renameSync as renameSync3, rmSync as rmSync2 } from "fs";
251521
251633
  import { promises as fsPromises3 } from "fs";
251522
251634
  import { join as join24, dirname as dirname32, isAbsolute as isAbsolute3, resolve as resolve32 } from "path";
251523
- import { createHash as createHash3, randomUUID as randomUUID32 } from "crypto";
251635
+ import { createHash as createHash4, randomUUID as randomUUID32 } from "crypto";
251524
251636
  import { execFile as execFile2 } from "child_process";
251525
251637
  import glob3 from "fast-glob";
251526
251638
  import { z as z43 } from "zod";
@@ -252939,7 +253051,7 @@ var EmbeddingCache = class {
252939
253051
  }
252940
253052
  }
252941
253053
  get(text2) {
252942
- const hash2 = createHash3("sha256").update(text2).digest("hex");
253054
+ const hash2 = createHash4("sha256").update(text2).digest("hex");
252943
253055
  const vector = this.cache[hash2];
252944
253056
  if (vector) {
252945
253057
  delete this.cache[hash2];
@@ -252951,7 +253063,7 @@ var EmbeddingCache = class {
252951
253063
  if (vector.length === 0 || vector.length > 32768 || vector.some((value) => !Number.isFinite(value))) {
252952
253064
  return;
252953
253065
  }
252954
- const hash2 = createHash3("sha256").update(text2).digest("hex");
253066
+ const hash2 = createHash4("sha256").update(text2).digest("hex");
252955
253067
  delete this.cache[hash2];
252956
253068
  this.cache[hash2] = vector;
252957
253069
  this.trim();
@@ -254735,7 +254847,7 @@ import { z as z64 } from "zod";
254735
254847
 
254736
254848
  // ../mcp/dist/index.js
254737
254849
  import { spawn as spawn2 } from "child_process";
254738
- import { createHash as createHash4 } from "crypto";
254850
+ import { createHash as createHash5 } from "crypto";
254739
254851
  var import_ajv = __toESM(require_ajv(), 1);
254740
254852
  import { z as z36 } from "zod";
254741
254853
  import { z as z27 } from "zod";
@@ -255763,7 +255875,7 @@ function createMcpToolName(serverName, originalToolName) {
255763
255875
  const rawName = `mcp__${serverName}__${originalToolName}`;
255764
255876
  if (/^[A-Za-z0-9_-]{1,64}$/.test(rawName)) return rawName;
255765
255877
  const normalized = rawName.replace(/[^A-Za-z0-9_-]+/g, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "");
255766
- const digest = createHash4("sha256").update(rawName).digest("hex").slice(0, 8);
255878
+ const digest = createHash5("sha256").update(rawName).digest("hex").slice(0, 8);
255767
255879
  const prefix = (normalized || "mcp_tool").slice(0, 55).replace(/_+$/g, "");
255768
255880
  return `${prefix}_${digest}`;
255769
255881
  }
@@ -257922,7 +258034,7 @@ function toErrorMessage2(error) {
257922
258034
 
257923
258035
  // ../session/dist/index.js
257924
258036
  import { z as z30 } from "zod";
257925
- import { createHash as createHash5, randomUUID as randomUUID6 } from "crypto";
258037
+ import { createHash as createHash6, randomUUID as randomUUID6 } from "crypto";
257926
258038
  import { dirname as dirname8, isAbsolute as isAbsolute4, join as join9, relative as relative5, resolve as resolve7, sep } from "path";
257927
258039
  import {
257928
258040
  closeSync as closeSync5,
@@ -258681,7 +258793,7 @@ var SessionStore = class {
258681
258793
  schemaVersion: 1,
258682
258794
  exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
258683
258795
  workspace: {
258684
- id: createHash5("sha256").update(this.cwd).digest("hex").slice(0, 16),
258796
+ id: createHash6("sha256").update(this.cwd).digest("hex").slice(0, 16),
258685
258797
  path: "<workspace>"
258686
258798
  },
258687
258799
  session: {
@@ -260271,8 +260383,11 @@ var PromptCacheTelemetrySampleSchema = z31.object({
260271
260383
  });
260272
260384
  var PromptCacheSlabMetadataSchema = z31.object({
260273
260385
  hash: z31.string().max(128).optional(),
260386
+ provider: z31.string().max(1024).optional(),
260274
260387
  model: z31.string().max(1024).optional(),
260275
260388
  tokenEstimate: z31.number().int().nonnegative().optional(),
260389
+ systemHash: z31.string().max(128).optional(),
260390
+ toolSchemaHash: z31.string().max(128).optional(),
260276
260391
  lastPrimedAt: z31.string().max(100).optional(),
260277
260392
  telemetry: z31.array(PromptCacheTelemetrySampleSchema).max(100).optional()
260278
260393
  }).passthrough();
@@ -260288,7 +260403,17 @@ function readPromptCacheSlabMetadata(path9) {
260288
260403
  var PromptCacheSlabBuilder = class {
260289
260404
  static build(input) {
260290
260405
  const stableText = this.buildStableText(input);
260291
- const hash2 = createHash6("sha256").update(stableText).digest("hex");
260406
+ const systemHash = createHash7("sha256").update(stableText).digest("hex");
260407
+ const toolSchemaHash = toolDefinitionsFingerprint(input.tools);
260408
+ const hash2 = createHash7("sha256").update(
260409
+ [
260410
+ "orbit-cache-prefix-v3",
260411
+ input.provider,
260412
+ input.model,
260413
+ systemHash,
260414
+ toolSchemaHash
260415
+ ].join("\n")
260416
+ ).digest("hex");
260292
260417
  const slabPath = join10(
260293
260418
  input.cwd,
260294
260419
  ".orbit",
@@ -260297,6 +260422,9 @@ var PromptCacheSlabBuilder = class {
260297
260422
  );
260298
260423
  return {
260299
260424
  hash: hash2,
260425
+ systemHash,
260426
+ toolSchemaHash,
260427
+ provider: input.provider,
260300
260428
  model: input.model,
260301
260429
  text: stableText,
260302
260430
  tokenEstimate: estimateTokenCount(stableText),
@@ -260344,7 +260472,7 @@ var PromptCacheSlabBuilder = class {
260344
260472
  const recent = samples.at(-1);
260345
260473
  const avgHit = samples.length > 0 ? samples.reduce((sum, item) => sum + item.hitRate, 0) / samples.length : void 0;
260346
260474
  lines.push(
260347
- `- slab ${String(slab.hash).slice(0, 8)} model=${slab.model || "unknown"} tokens=${slab.tokenEstimate || 0} observations=${samples.length}`
260475
+ `- slab ${String(slab.hash).slice(0, 8)} provider=${slab.provider || "legacy"} model=${slab.model || "unknown"} system=${String(slab.systemHash || "unknown").slice(0, 8)} tools=${String(slab.toolSchemaHash || "unknown").slice(0, 8)} tokens=${slab.tokenEstimate || 0} observations=${samples.length}`
260348
260476
  );
260349
260477
  if (recent) {
260350
260478
  lines.push(
@@ -260367,6 +260495,9 @@ var PromptCacheSlabBuilder = class {
260367
260495
  JSON.stringify(
260368
260496
  {
260369
260497
  hash: slab.hash,
260498
+ systemHash: slab.systemHash,
260499
+ toolSchemaHash: slab.toolSchemaHash,
260500
+ provider: slab.provider,
260370
260501
  model: slab.model,
260371
260502
  tokenEstimate: slab.tokenEstimate,
260372
260503
  telemetry: telemetry || existing?.telemetry || []
@@ -260383,7 +260514,10 @@ var PromptCacheSlabBuilder = class {
260383
260514
  const sortedLanguages = [...ctx.projectIndex.detectedLanguages].sort();
260384
260515
  const sortedFrameworks = [...ctx.projectIndex.frameworks].sort();
260385
260516
  const sortedEntrypoints = [...ctx.projectIndex.entrypoints].sort();
260386
- const skillsIndex = (ctx.skillsIndex || []).map((skill) => {
260517
+ const skillsIndex = (ctx.skillsIndex || []).slice().sort((left, right) => {
260518
+ const byName = left.name.localeCompare(right.name, "en");
260519
+ return byName !== 0 ? byName : left.path.localeCompare(right.path, "en");
260520
+ }).map((skill) => {
260387
260521
  const description = skill.description ? ` - ${skill.description.replace(/\s+/g, " ").trim()}` : "";
260388
260522
  return `- ${skill.name}${description}`;
260389
260523
  }).join("\n");
@@ -260402,7 +260536,7 @@ var PromptCacheSlabBuilder = class {
260402
260536
  ${skillsIndex}` : "",
260403
260537
  ctx.projectInstructions ? `
260404
260538
  ### Project Instructions
260405
- ${ctx.projectInstructions}` : ""
260539
+ ${ctx.projectInstructions.replace(/\r\n/g, "\n").replace(/\r/g, "\n")}` : ""
260406
260540
  ].filter(Boolean).join("\n");
260407
260541
  return [
260408
260542
  input.baseSystemPrompt.trimEnd(),
@@ -263709,9 +263843,11 @@ Note: To find where a symbol (class, function, etc.) is declared or referenced,
263709
263843
  const contextPack = this.cachedContextPack;
263710
263844
  const cacheSlab = PromptCacheSlabBuilder.build({
263711
263845
  cwd: this.cwd,
263846
+ provider: this.provider.id,
263712
263847
  model: activeModel2,
263713
263848
  baseSystemPrompt,
263714
263849
  toolsPrompt,
263850
+ tools: toolDefs,
263715
263851
  repoMapText,
263716
263852
  contextPack
263717
263853
  });
@@ -267811,7 +267947,7 @@ function getAutocompleteProvider(providerId, config) {
267811
267947
  if (providerId === "ollama") {
267812
267948
  return new OllamaProvider();
267813
267949
  }
267814
- return new DeepSeekOpenAIProvider(
267950
+ return new OpenAICompatibleProvider(
267815
267951
  process.env.DEEPSEEK_API_KEY || process.env.OPENAI_API_KEY || "no-key"
267816
267952
  );
267817
267953
  }
@@ -267839,7 +267975,7 @@ function getAutocompleteProvider(providerId, config) {
267839
267975
  case "openai-compatible":
267840
267976
  case "anthropic-compatible":
267841
267977
  default:
267842
- return new DeepSeekOpenAIProvider(apiKey, baseUrl, providerOptions);
267978
+ return new OpenAICompatibleProvider(apiKey, baseUrl, providerOptions);
267843
267979
  }
267844
267980
  }
267845
267981
  function safeDecodeURI(uri) {
@@ -268165,7 +268301,7 @@ function buildCacheDiagnostics(cwd) {
268165
268301
  }
268166
268302
 
268167
268303
  // src/runtime/ProviderBenchmarks.ts
268168
- import { createHash as createHash7 } from "crypto";
268304
+ import { createHash as createHash8 } from "crypto";
268169
268305
  import picocolors5 from "picocolors";
268170
268306
  import { z as z39 } from "zod";
268171
268307
  var MAX_PROVIDER_BENCHMARK_BYTES = 2 * 1024 * 1024;
@@ -268199,7 +268335,7 @@ function providerBenchmarkPath(cwd) {
268199
268335
  return resolveSafePath(cwd, ".orbit/provider-benchmarks.json");
268200
268336
  }
268201
268337
  function benchmarkPromptHash(prompt) {
268202
- return createHash7("sha256").update(prompt).digest("hex").slice(0, 16);
268338
+ return createHash8("sha256").update(prompt).digest("hex").slice(0, 16);
268203
268339
  }
268204
268340
  function readProviderBenchmarks(cwd) {
268205
268341
  try {
@@ -268679,7 +268815,7 @@ function createProviderFromConfig(config) {
268679
268815
  modelCapabilities: pConfig.modelCapabilities,
268680
268816
  apiKeyResolver: () => pConfig.apiKey
268681
268817
  };
268682
- if (pConfig.type === "deepseek") {
268818
+ if (pConfig.type === "deepseek" || pConfig.type === "openai-compatible" && isOfficialDeepSeekApi(pConfig.baseUrl)) {
268683
268819
  return new DeepSeekProvider(void 0, pConfig.baseUrl, providerOptions);
268684
268820
  }
268685
268821
  if (pConfig.type === "anthropic-compatible") {
@@ -268690,7 +268826,7 @@ function createProviderFromConfig(config) {
268690
268826
  );
268691
268827
  }
268692
268828
  if (pConfig.type === "openai-compatible") {
268693
- return new DeepSeekOpenAIProvider(
268829
+ return new OpenAICompatibleProvider(
268694
268830
  void 0,
268695
268831
  pConfig.baseUrl,
268696
268832
  providerOptions
@@ -268879,6 +269015,11 @@ function buildDoctorSnapshot(cwd, config = ConfigLoader.loadSync(cwd), options =
268879
269015
  const exec6 = options.exec || defaultExec;
268880
269016
  const defaultProvider = config.provider.default;
268881
269017
  const provider = config.providers[defaultProvider];
269018
+ let effectiveProviderType = provider?.type || null;
269019
+ try {
269020
+ effectiveProviderType = createProviderFromConfig(config).type;
269021
+ } catch {
269022
+ }
268882
269023
  const nodeMajor = Number(process.versions.node.split(".")[0]);
268883
269024
  const gitVersion = commandOutput(exec6, "git --version", cwd)?.replace(
268884
269025
  /^git version\s+/i,
@@ -268993,7 +269134,7 @@ function buildDoctorSnapshot(cwd, config = ConfigLoader.loadSync(cwd), options =
268993
269134
  },
268994
269135
  provider: {
268995
269136
  id: defaultProvider,
268996
- type: provider?.type || null,
269137
+ type: effectiveProviderType,
268997
269138
  baseUrl: sanitizeDiagnosticUrl(provider?.baseUrl),
268998
269139
  apiKeyLoaded: hasApiKey,
268999
269140
  apiKeySource: provider?.apiKeyEnv || "configured provider key",
@@ -269310,7 +269451,7 @@ async function runDoctor(cwd, options = {}) {
269310
269451
 
269311
269452
  // src/commands/bench.ts
269312
269453
  import picocolors7 from "picocolors";
269313
- import { createHash as createHash8, randomUUID as randomUUID8 } from "crypto";
269454
+ import { createHash as createHash9, randomUUID as randomUUID8 } from "crypto";
269314
269455
  import { resolve as resolve8 } from "path";
269315
269456
  import { z as z48 } from "zod";
269316
269457
  var BenchOptionsSchema = z48.object({
@@ -269332,7 +269473,7 @@ var BenchOptionsSchema = z48.object({
269332
269473
  function parseBenchOptions(value) {
269333
269474
  return BenchOptionsSchema.parse(value);
269334
269475
  }
269335
- async function runSingleBench(provider, model, prompt, maxTokens, thinkingMode, userId) {
269476
+ async function runSingleBench(provider, model, prompt, maxTokens, thinkingMode, userId, cacheContinuationRound = 0) {
269336
269477
  const startedAt = Date.now();
269337
269478
  let firstDeltaMs;
269338
269479
  let firstThinkingMs;
@@ -269348,14 +269489,7 @@ async function runSingleBench(provider, model, prompt, maxTokens, thinkingMode,
269348
269489
  try {
269349
269490
  const stream = provider.chat({
269350
269491
  model,
269351
- messages: [
269352
- {
269353
- id: `msg_bench_${Date.now()}`,
269354
- role: "user",
269355
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
269356
- content: [{ type: "text", text: prompt }]
269357
- }
269358
- ],
269492
+ messages: buildCacheProfileMessages(prompt, cacheContinuationRound),
269359
269493
  tools: [],
269360
269494
  stream: true,
269361
269495
  maxTokens,
@@ -269483,6 +269617,39 @@ ${Array.from({ length: 180 }, () => stablePrefix).join("\n")}
269483
269617
 
269484
269618
  ${workload}`;
269485
269619
  }
269620
+ function buildCacheProfileMessages(prompt, continuationRound = 0) {
269621
+ const createdAt = "2026-01-01T00:00:00.000Z";
269622
+ const messages = [
269623
+ {
269624
+ id: "cache-profile-user-0",
269625
+ role: "user",
269626
+ createdAt,
269627
+ content: [{ type: "text", text: prompt }]
269628
+ }
269629
+ ];
269630
+ if (continuationRound > 0) {
269631
+ messages.push(
269632
+ {
269633
+ id: "cache-profile-assistant-0",
269634
+ role: "assistant",
269635
+ createdAt,
269636
+ content: [{ type: "text", text: "ok" }]
269637
+ },
269638
+ {
269639
+ id: `cache-profile-user-${continuationRound}`,
269640
+ role: "user",
269641
+ createdAt,
269642
+ content: [
269643
+ {
269644
+ type: "text",
269645
+ text: `Cache continuation ${continuationRound}. Reply with exactly: ok`
269646
+ }
269647
+ ]
269648
+ }
269649
+ );
269650
+ }
269651
+ return messages;
269652
+ }
269486
269653
  function evaluateCacheProfile(results) {
269487
269654
  const successful = results.filter((item) => !item.error);
269488
269655
  const cold = successful[0];
@@ -269515,7 +269682,7 @@ function formatCacheProfileSummary(results) {
269515
269682
  warmAvgHit * 100
269516
269683
  )}% \xB7 speedup=${profile.speedup}`,
269517
269684
  `Prompt hash: ${cold.promptHash} \xB7 prompt chars=${cold.promptChars}`,
269518
- "Interpretation: the default profile uses a unique prefix per command and repeats it byte-for-byte within the run. Trust returned cacheReadTokens, since provider caching is best-effort."
269685
+ "Interpretation: the profile uses a unique prefix per command, then exercises append-only follow-up requests over the same persisted boundary. Trust returned cacheReadTokens, since provider caching is best-effort."
269519
269686
  ].join("\n");
269520
269687
  }
269521
269688
  function printBenchResult(result, index) {
@@ -269654,7 +269821,7 @@ async function runBench(cwd, options = {}) {
269654
269821
  const results = [];
269655
269822
  const cacheProfileGroups = /* @__PURE__ */ new Map();
269656
269823
  const workspaceIdentity = resolve8(cwd).replace(/\\/g, "/");
269657
- const userId = createHash8("sha256").update(
269824
+ const userId = createHash9("sha256").update(
269658
269825
  process.platform === "win32" ? workspaceIdentity.toLowerCase() : workspaceIdentity
269659
269826
  ).digest("hex");
269660
269827
  for (const model of models) {
@@ -269667,7 +269834,8 @@ async function runBench(cwd, options = {}) {
269667
269834
  prompt,
269668
269835
  maxTokens,
269669
269836
  thinkingMode,
269670
- userId
269837
+ userId,
269838
+ options.cacheProfile ? i2 : 0
269671
269839
  );
269672
269840
  recordProviderBenchmark(cwd, result);
269673
269841
  results.push(result);
@@ -299533,7 +299701,7 @@ import {
299533
299701
  rmSync as rmSync10,
299534
299702
  writeFileSync as writeFileSync10
299535
299703
  } from "fs";
299536
- import { createHash as createHash9, randomUUID as randomUUID16 } from "crypto";
299704
+ import { createHash as createHash10, randomUUID as randomUUID16 } from "crypto";
299537
299705
  import { dirname as dirname17, isAbsolute as isAbsolute8, join as join21, relative as relative10, resolve as resolve18, sep as sep2 } from "path";
299538
299706
  import { z as z77 } from "zod";
299539
299707
  var MAX_BACKUP_BYTES = 64 * 1024 * 1024;
@@ -299802,7 +299970,7 @@ function normalizeBundlePath(filePath) {
299802
299970
  return normalized;
299803
299971
  }
299804
299972
  function hash(content) {
299805
- return createHash9("sha256").update(content).digest("hex");
299973
+ return createHash10("sha256").update(content).digest("hex");
299806
299974
  }
299807
299975
  function formatBytes2(bytes) {
299808
299976
  return `${Math.round(bytes / (1024 * 1024))} MiB`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbit-build/cli",
3
- "version": "0.7.6",
3
+ "version": "0.8.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Local-first AI coding agent CLI, TUI, Web UI, diagnostics, and LSP runtime",
6
6
  "keywords": [