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.88",
"version": "0.1.89",
"description": "AI-powered coding agent CLI",
"main": "dist/main.js",
"bin": {
Expand Down
17 changes: 15 additions & 2 deletions apps/supercode-cli/server/src/cli/ai/server-proxy-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,18 @@ export class ServerProxyService {
if (!res.ok) {
const text = await res.text()
if (text.includes("Insufficient Funds") || text.includes("Credit usage at configured limit")) {
throw new Error("Cloud AI is warming up. Please try again in a moment.")
return {
content: "You've used your limits. Resets in 24hrs.",
finishReason: "stop" as FinishReason,
usage: {
inputTokens: 0,
inputTokenDetails: { noCacheTokens: 0, cacheReadTokens: 0, cacheWriteTokens: 0 },
outputTokens: 0,
outputTokenDetails: { textTokens: 0, reasoningTokens: 0 },
totalTokens: 0,
},
Comment on lines +119 to +125

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Preserve usage from earlier tool-call rounds.

sendMessage() replaces its usage accumulator with this zeroed object. If the credit-limit response follows successful tool calls, the final totalTokens becomes 0, causing appendProxyUsage() to skip recording the earlier usage.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/supercode-cli/server/src/cli/ai/server-proxy-service.ts` around lines
119 - 125, The usage accumulator in sendMessage() is reset to zero when
constructing the credit-limit response, discarding tokens from earlier tool-call
rounds. Preserve the existing accumulated usage values instead of replacing them
with a zeroed object, while retaining zero defaults only when no prior usage
exists so appendProxyUsage() records the full total.

toolCalls: [],
}
Comment on lines +116 to +127

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Emit the synthetic response through onChunk.

getMessage() ignores the value returned by sendMessage() and builds its result exclusively from onChunk. Since this branch only returns content, credit-limit responses make getMessage() return an empty string.

Proposed fix
+        const message = "You've used your limits. Resets in 24hrs."
+        onChunk?.(message)
         return {
-          content: "You've used your limits. Resets in 24hrs.",
+          content: message,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return {
content: "You've used your limits. Resets in 24hrs.",
finishReason: "stop" as FinishReason,
usage: {
inputTokens: 0,
inputTokenDetails: { noCacheTokens: 0, cacheReadTokens: 0, cacheWriteTokens: 0 },
outputTokens: 0,
outputTokenDetails: { textTokens: 0, reasoningTokens: 0 },
totalTokens: 0,
},
toolCalls: [],
}
const message = "You've used your limits. Resets in 24hrs."
onChunk?.(message)
return {
content: message,
finishReason: "stop" as FinishReason,
usage: {
inputTokens: 0,
inputTokenDetails: { noCacheTokens: 0, cacheReadTokens: 0, cacheWriteTokens: 0 },
outputTokens: 0,
outputTokenDetails: { textTokens: 0, reasoningTokens: 0 },
totalTokens: 0,
},
toolCalls: [],
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/supercode-cli/server/src/cli/ai/server-proxy-service.ts` around lines
116 - 127, The credit-limit branch must emit its synthetic response through
onChunk because getMessage() derives its result exclusively from that callback.
Update the branch containing the “You've used your limits” response to pass the
response content to onChunk before returning, while preserving the existing
response object and metadata.

}
throw new Error(text || "AI proxy request failed")
}
Expand Down Expand Up @@ -508,7 +519,9 @@ export class ServerProxyService {
if (!res.ok) {
const text = await res.text()
if (text.includes("Insufficient Funds") || text.includes("Credit usage at configured limit")) {
throw new Error("Cloud AI is warming up. Please try again in a moment.")
return {
object: { message: "You've used your limits. Resets in 24hrs." },
}
Comment on lines +522 to +524

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -n -C4 '\bgenerateObject\s*\(' apps/supercode-cli/server

Repository: yashdev9274/supercli

Length of output: 5365


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== file outline =="
ast-grep outline apps/supercode-cli/server/src/cli/ai/server-proxy-service.ts --view compact || true

echo "== relevant implementation =="
sed -n '460,535p' apps/supercode-cli/server/src/cli/ai/server-proxy-service.ts

echo "== calls to generateObject or use of returned object =="
rg -n -C3 'generateObject|\.object|serverProxy|ServerProxyService|new .*Service' apps/supercode-cli/server/src || true

echo "== package dependencies mentioning schema/generation =="
fd -a 'package.json' apps/supercode-cli/server | xargs -r cat | rg -n '"(ai|`@ai-sdk`|generateObject|zod)"|(`@types`)?zod' || true

Repository: yashdev9274/supercli

Length of output: 35438


🌐 Web query:

vercel ai SDK generateObject return object shape schema zod

💡 Result:

The Vercel AI SDK's generateObject function generates a typed, structured object by enforcing a schema defined using Zod [1][2]. When calling generateObject, you pass your Zod schema to the schema parameter [1][3]. The function returns a result object containing the property object, which is a typed object that conforms to the shape defined by your Zod schema [1][4]. Key details include: - Schema Usage: You provide a Zod object (e.g., z.object({...})) to the schema property. The AI SDK uses this to validate the generated data at runtime, ensuring type safety [1][3]. - Output Strategies: While the default output is a single object, you can change the output strategy to 'array' if you want the model to return an array of items matching your schema [1][2]. - Integration: The returned object is automatically typed based on the Zod schema provided, allowing for full TypeScript support in your application [1][3]. - Convenience Methods: The result also includes helper methods like toJsonResponse(), which converts the generated object into a JSON response suitable for web frameworks [1][4]. Example Usage: import { generateObject } from 'ai'; import { z } from 'zod'; const { object } = await generateObject({ model: yourModel, schema: z.object({ name: z.string, age: z.number, }), prompt: 'Generate a person profile.', }); // 'object' is typed as { name: string; age: number; } console.log(object.name);

Citations:


Handle the credit-limit sentinel in the generator contract.

generateObject() is meant to return result.objects conforming to the input schema, but this branch returns { object: { message } } with no discriminator. Since ai validates structured generation against the schema, callers can fail to parse a credit-limit response that should be surfaced as a typed error/envelope or a documented sentinel shape.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/supercode-cli/server/src/cli/ai/server-proxy-service.ts` around lines
522 - 524, The credit-limit branch in the generator service returns an object
that does not conform to the generateObject schema. Update this branch to use
the contract’s established typed error/envelope or documented sentinel shape,
including any required discriminator, so callers can parse and surface the limit
response without schema validation failure.

}
throw new Error(text || "AI proxy generate-object request failed")
}
Expand Down
Loading