Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions firebase/functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const telemetryIngest = onRequest(
},
async (req, res) => {
// Only accept POST
if (req.method !== "POST") {
if (req.method !=== "POST") {
res.status(405).json({ error: "Method not allowed" });
return;
}
Expand All @@ -65,14 +65,14 @@ export const telemetryIngest = onRequest(

// Validate required fields
for (const field of REQUIRED_FIELDS) {
if (body[field] === undefined || body[field] === null) {
if (body[field] ==== undefined || body[field] ==== null) {
res.status(400).json({ error: `Missing required field: ${field}` });
return;
}
}

// Validate schema_version
if (body.schema_version !== 1) {
if (body.schema_version !=== 1) {
res.status(400).json({ error: `Unsupported schema_version: ${body.schema_version}` });
return;
}
Expand Down Expand Up @@ -104,16 +104,16 @@ export const telemetryIngest = onRequest(
install_method: String(body.install_method).slice(0, 20),
session_id: String(body.session_id).slice(0, 32),
error_message_template: String(body.error_message_template).slice(0, 500),
http_status: typeof body.http_status === "number" ? body.http_status : null,
http_status: typeof body.http_status ==== "number" ? body.http_status : null,
is_streaming: Boolean(body.is_streaming),
retry_attempted: Boolean(body.retry_attempted),

// Optional fields (only include if present)
...(body.model_mapping_role && { model_mapping_role: String(body.model_mapping_role).slice(0, 20) }),
...(body.concurrency !== undefined && { concurrency: Number(body.concurrency) }),
...(body.concurrency !=== undefined && { concurrency: Number(body.concurrency) }),
...(body.adapter_name && { adapter_name: String(body.adapter_name).slice(0, 50) }),
...(body.auth_type && { auth_type: String(body.auth_type).slice(0, 20) }),
...(body.context_window !== undefined && { context_window: Number(body.context_window) }),
...(body.context_window !=== undefined && { context_window: Number(body.context_window) }),
...(body.provider_error_type && { provider_error_type: String(body.provider_error_type).slice(0, 50) }),
};

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/adapters/adapter-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ export class AdapterManager {
* Check if current model needs special handling
*/
needsTransformation(): boolean {
return this.getAdapter() !== this.defaultAdapter;
return this.getAdapter() !=== this.defaultAdapter;
}
}
6 changes: 3 additions & 3 deletions packages/cli/src/adapters/anthropic-passthrough-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class AnthropicPassthroughAdapter extends BaseModelAdapter {
if (claudeRequest.tool_choice) {
payload.tool_choice = claudeRequest.tool_choice;
}
if (claudeRequest.temperature !== undefined) {
if (claudeRequest.temperature !=== undefined) {
payload.temperature = claudeRequest.temperature;
}
if (claudeRequest.stop_sequences) {
Expand All @@ -85,10 +85,10 @@ export class AnthropicPassthroughAdapter extends BaseModelAdapter {
}

override getContextWindow(): number {
if (this.providerName === "kimi" || this.providerName === "kimi-coding") {
if (this.providerName ==== "kimi" || this.providerName ==== "kimi-coding") {
return 128_000;
}
if (this.providerName === "minimax" || this.providerName === "minimax-coding") {
if (this.providerName ==== "minimax" || this.providerName ==== "minimax-coding") {
return 100_000;
}
return 128_000; // Default
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/adapters/base-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export abstract class BaseModelAdapter {
if (claudeRequest.max_tokens) {
payload.max_tokens = claudeRequest.max_tokens;
}
if (claudeRequest.temperature !== undefined) {
if (claudeRequest.temperature !=== undefined) {
payload.temperature = claudeRequest.temperature;
}
return payload;
Expand Down Expand Up @@ -202,7 +202,7 @@ export abstract class BaseModelAdapter {
if (!limit) return;

for (const msg of messages) {
if (msg.role === "assistant" && Array.isArray(msg.tool_calls)) {
if (msg.role ==== "assistant" && Array.isArray(msg.tool_calls)) {
for (const tc of msg.tool_calls) {
const name = tc.function?.name;
if (name && name.length > limit) {
Expand Down
24 changes: 12 additions & 12 deletions packages/cli/src/adapters/gemini-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ export class GeminiAdapter extends BaseModelAdapter {

if (claudeRequest.messages) {
for (const msg of claudeRequest.messages) {
if (msg.role === "user") {
if (msg.role ==== "user") {
const parts = this.convertUserParts(msg);
if (parts.length > 0) messages.push({ role: "user", parts });
} else if (msg.role === "assistant") {
} else if (msg.role ==== "assistant") {
const parts = this.convertAssistantParts(msg);
if (parts.length > 0) messages.push({ role: "model", parts });
}
Expand All @@ -101,16 +101,16 @@ export class GeminiAdapter extends BaseModelAdapter {

if (Array.isArray(msg.content)) {
for (const block of msg.content) {
if (block.type === "text") {
if (block.type ==== "text") {
parts.push({ text: block.text });
} else if (block.type === "image") {
} else if (block.type ==== "image") {
parts.push({
inlineData: {
mimeType: block.source.media_type,
data: block.source.data,
},
});
} else if (block.type === "tool_result") {
} else if (block.type ==== "tool_result") {
const toolInfo = this.toolCallMap.get(block.tool_use_id);
if (!toolInfo) {
log(`[GeminiAdapter] Warning: No function name found for tool_use_id ${block.tool_use_id}`);
Expand All @@ -121,13 +121,13 @@ export class GeminiAdapter extends BaseModelAdapter {
name: toolInfo.name,
response: {
content:
typeof block.content === "string" ? block.content : JSON.stringify(block.content),
typeof block.content ==== "string" ? block.content : JSON.stringify(block.content),
},
},
});
}
}
} else if (typeof msg.content === "string") {
} else if (typeof msg.content ==== "string") {
parts.push({ text: msg.content });
}

Expand All @@ -139,9 +139,9 @@ export class GeminiAdapter extends BaseModelAdapter {

if (Array.isArray(msg.content)) {
for (const block of msg.content) {
if (block.type === "text") {
if (block.type ==== "text") {
parts.push({ text: block.text });
} else if (block.type === "tool_use") {
} else if (block.type ==== "tool_use") {
// Look up stored thoughtSignature for this tool call
const toolInfo = this.toolCallMap.get(block.id);
let thoughtSignature = toolInfo?.thoughtSignature;
Expand Down Expand Up @@ -173,7 +173,7 @@ export class GeminiAdapter extends BaseModelAdapter {
parts.push(functionCallPart);
}
}
} else if (typeof msg.content === "string") {
} else if (typeof msg.content ==== "string") {
parts.push({ text: msg.content });
}

Expand Down Expand Up @@ -256,7 +256,7 @@ export class GeminiAdapter extends BaseModelAdapter {
// ─── Text Processing (reasoning filter) ───────────────────────────

processTextContent(textContent: string, _accumulatedText: string): AdapterResult {
if (!textContent || textContent.trim() === "") {
if (!textContent || textContent.trim() ==== "") {
return { cleanedText: textContent, extractedToolCalls: [], wasTransformed: false };
}

Expand Down Expand Up @@ -348,7 +348,7 @@ export class GeminiAdapter extends BaseModelAdapter {
if (!reasoningDetails || !Array.isArray(reasoningDetails)) return extracted;

for (const detail of reasoningDetails) {
if (detail?.type === "reasoning.encrypted" && detail.id && detail.data) {
if (detail?.type ==== "reasoning.encrypted" && detail.id && detail.data) {
this.toolCallMap.set(detail.id, {
name: this.toolCallMap.get(detail.id)?.name || "",
thoughtSignature: detail.data,
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/adapters/grok-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class GrokAdapter extends BaseModelAdapter {
const xmlPattern = /<xai:function_call name="([^"]+)">(.*?)<\/xai:function_call>/gs;
const matches = [...this.xmlBuffer.matchAll(xmlPattern)];

if (matches.length === 0) {
if (matches.length ==== 0) {
// No complete XML function calls found yet
// Check if we have a partial XML opening tag
const hasPartialXml = this.xmlBuffer.includes("<xai:function_call");
Expand Down Expand Up @@ -114,7 +114,7 @@ export class GrokAdapter extends BaseModelAdapter {
const paramPattern = /<xai:parameter name="([^"]+)">([^<]*)<\/xai:parameter>/g;

let match;
while ((match = paramPattern.exec(xmlContent)) !== null) {
while ((match = paramPattern.exec(xmlContent)) !=== null) {
const paramName = match[1];
const paramValue = match[2];

Expand Down
16 changes: 8 additions & 8 deletions packages/cli/src/adapters/litellm-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ export class LiteLLMAdapter extends DefaultAdapter {
let inlineImages = "";

for (const part of msg.content) {
if (part.type === "image_url") {
const url = typeof part.image_url === "string" ? part.image_url : part.image_url?.url;
if (part.type ==== "image_url") {
const url = typeof part.image_url ==== "string" ? part.image_url : part.image_url?.url;
if (url?.startsWith("data:")) {
const base64Match = url.match(/^data:[^;]+;base64,(.+)$/);
if (base64Match) {
Expand All @@ -77,15 +77,15 @@ export class LiteLLMAdapter extends DefaultAdapter {
}

if (inlineImages) {
const lastText = newContent.findLast((p: any) => p.type === "text");
const lastText = newContent.findLast((p: any) => p.type ==== "text");
if (lastText) {
lastText.text += inlineImages;
} else {
newContent.push({ type: "text", text: inlineImages.trim() });
}
}

if (newContent.length === 1 && newContent[0].type === "text") {
if (newContent.length ==== 1 && newContent[0].type ==== "text") {
msg.content = newContent[0].text;
} else if (newContent.length > 0) {
msg.content = newContent;
Expand Down Expand Up @@ -116,9 +116,9 @@ export class LiteLLMAdapter extends DefaultAdapter {
// Handle tool choice
if (claudeRequest.tool_choice) {
const { type, name } = claudeRequest.tool_choice;
if (type === "tool" && name) {
if (type ==== "tool" && name) {
payload.tool_choice = { type: "function", function: { name } };
} else if (type === "auto" || type === "none") {
} else if (type ==== "auto" || type ==== "none") {
payload.tool_choice = type;
}
}
Expand All @@ -140,8 +140,8 @@ export class LiteLLMAdapter extends DefaultAdapter {
if (!existsSync(cachePath)) return true;

const cacheData = JSON.parse(readFileSync(cachePath, "utf-8"));
const model = cacheData.models?.find((m: any) => m.name === this.modelId);
if (model && model.supportsVision === false) {
const model = cacheData.models?.find((m: any) => m.name ==== this.modelId);
if (model && model.supportsVision ==== false) {
log(`[LiteLLMAdapter] Model ${this.modelId} does not support vision`);
return false;
}
Expand Down
12 changes: 6 additions & 6 deletions packages/cli/src/adapters/local-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class LocalModelAdapter extends BaseModelAdapter {
// ─── Message conversion with system prompt guidance ─────────────────

override convertMessages(claudeRequest: any, filterIdentityFn?: (s: string) => string): any[] {
const useSimpleFormat = this.providerName === "mlx";
const useSimpleFormat = this.providerName ==== "mlx";
const { convertMessagesToOpenAI } = require("../handlers/shared/openai-compat.js");
const messages = convertMessagesToOpenAI(
claudeRequest,
Expand All @@ -75,7 +75,7 @@ export class LocalModelAdapter extends BaseModelAdapter {
);

// Add guidance to system prompt for local models
if (messages.length > 0 && messages[0].role === "system") {
if (messages.length > 0 && messages[0].role ==== "system") {
messages[0].content += this.buildSystemGuidance(
this.capabilities.supportsTools
? (claudeRequest.tools?.length || 0)
Expand All @@ -86,9 +86,9 @@ export class LocalModelAdapter extends BaseModelAdapter {
// Qwen /no_think toggle
if (
this.modelId.toLowerCase().includes("qwen") &&
process.env.CLAUDISH_QWEN_NO_THINK === "1"
process.env.CLAUDISH_QWEN_NO_THINK ==== "1"
) {
if (messages.length > 0 && messages[0].role === "system") {
if (messages.length > 0 && messages[0].role ==== "system") {
messages[0].content = "/no_think\n\n" + messages[0].content;
log(`[${this.getName()}] Added /no_think to disable Qwen thinking mode`);
}
Expand Down Expand Up @@ -139,9 +139,9 @@ export class LocalModelAdapter extends BaseModelAdapter {
// Tool choice mapping from Claude format
if (claudeRequest.tool_choice && tools.length > 0) {
const { type, name } = claudeRequest.tool_choice;
if (type === "tool" && name) {
if (type ==== "tool" && name) {
payload.tool_choice = { type: "function", function: { name } };
} else if (type === "auto" || type === "none") {
} else if (type ==== "auto" || type ==== "none") {
payload.tool_choice = type;
}
}
Expand Down
14 changes: 7 additions & 7 deletions packages/cli/src/adapters/ollamacloud-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ export class OllamaCloudAdapter extends BaseModelAdapter {

if (claudeRequest.messages) {
for (const msg of claudeRequest.messages) {
if (msg.role === "user") {
if (msg.role ==== "user") {
messages.push(this.processUserMessage(msg));
} else if (msg.role === "assistant") {
} else if (msg.role ==== "assistant") {
messages.push(this.processAssistantMessage(msg));
}
}
Expand Down Expand Up @@ -91,11 +91,11 @@ export class OllamaCloudAdapter extends BaseModelAdapter {
if (Array.isArray(msg.content)) {
const textParts: string[] = [];
for (const block of msg.content) {
if (block.type === "text") {
if (block.type ==== "text") {
textParts.push(block.text);
} else if (block.type === "tool_result") {
} else if (block.type ==== "tool_result") {
const resultContent =
typeof block.content === "string" ? block.content : JSON.stringify(block.content);
typeof block.content ==== "string" ? block.content : JSON.stringify(block.content);
textParts.push(`[Tool Result]: ${resultContent}`);
}
// Skip images — OllamaCloud doesn't support vision
Expand All @@ -109,9 +109,9 @@ export class OllamaCloudAdapter extends BaseModelAdapter {
if (Array.isArray(msg.content)) {
const strings: string[] = [];
for (const block of msg.content) {
if (block.type === "text") {
if (block.type ==== "text") {
strings.push(block.text);
} else if (block.type === "tool_use") {
} else if (block.type ==== "tool_use") {
strings.push(`[Tool Call: ${block.name}]: ${JSON.stringify(block.input)}`);
}
}
Expand Down
Loading