Skip to content
Merged
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
2 changes: 1 addition & 1 deletion apps/supercode-cli/server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "supercode-cli",
"version": "0.1.48",
"version": "0.1.49",
"description": "AI-powered coding agent CLI",
"main": "dist/main.js",
"bin": {
Expand Down
2 changes: 2 additions & 0 deletions apps/supercode-cli/server/src/cli/ai/concentrate-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export class ConcentrateService {
model: this.model,
messages: nonSystemMessages,
system,
maxOutputTokens: 8192,
abortSignal: streamAbortController.signal,
})

Expand Down Expand Up @@ -208,6 +209,7 @@ export class ConcentrateService {
messages: nonSystemMessages,
system,
tools,
maxOutputTokens: 8192,
stopWhen: stepCountIs(8),
abortSignal: streamAbortController.signal,
prepareStep: async ({ messages }) => {
Expand Down
26 changes: 12 additions & 14 deletions apps/supercode-cli/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ import { join } from "path"
import { writeFileSync, unlinkSync } from "fs"
import { randomUUID } from "crypto"

function toolParams(fn: any): object {
const raw = fn.inputSchema ?? fn.parameters ?? {}
return raw && typeof raw === "object" && "_def" in raw ? {} : raw
}

loadEnvOnce()

const port = process.env.PORT || 10000
Expand All @@ -33,7 +38,7 @@ const MODEL_MAX_TOKENS: Record<string, number> = {
"glm-5.2": 4096,
"glm-5.1": 4096,
"minimax-m3": 8192,
"anthropic/claude-opus-4-8": 128000,
"anthropic/claude-opus-4-8": 8192,
}
function getModelMaxTokens(model: string): number {
const exact = MODEL_MAX_TOKENS[model]
Expand Down Expand Up @@ -278,17 +283,10 @@ app.post("/api/ai/chat", async (req, res) => {
bodyObj.messages = [{ role: "system", content: system }, ...bodyObj.messages]
}
if (tools) {
bodyObj.tools = Object.entries(tools).map(([name, fn]: [string, any]) => {
// AI SDK 6 tools expose their schema as `inputSchema`; fall back
// to the legacy `parameters` key for tools that haven't been
// wrapped yet. The schema object is already a JSON-Schema-shaped
// value (or a Zod schema) — OpenRouter accepts the JSON Schema.
const schema = fn.inputSchema ?? fn.parameters ?? {}
return {
type: "function",
function: { name, description: fn.description || "", parameters: schema },
}
})
bodyObj.tools = Object.entries(tools).map(([name, fn]: [string, any]) => ({
type: "function",
function: { name, description: fn.description || "", parameters: toolParams(fn) },
}))
}
const response = await fetch("https://openrouter.ai/api/v1/chat/completions", {
method: "POST",
Expand Down Expand Up @@ -430,7 +428,7 @@ app.post("/api/ai/chat", async (req, res) => {
if (tools) {
bodyObj.tools = Object.entries(tools).map(([name, fn]: [string, any]) => ({
type: "function",
function: { name, description: fn.description || "", parameters: fn.inputSchema ?? fn.parameters ?? {} },
function: { name, description: fn.description || "", parameters: toolParams(fn) },
}))
}
const response = await fetch(`${baseUrl}/chat/completions`, {
Expand Down Expand Up @@ -538,7 +536,7 @@ app.post("/api/ai/chat", async (req, res) => {
if (tools) {
bodyObj.tools = Object.entries(tools).map(([name, fn]: [string, any]) => ({
type: "function",
function: { name, description: fn.description || "", parameters: fn.inputSchema ?? fn.parameters ?? {} },
function: { name, description: fn.description || "", parameters: toolParams(fn) },
}))
}
const response = await fetch("https://api.concentrate.ai/v1/chat/completions", {
Expand Down
Loading