Skip to content

Commit 4b6417c

Browse files
committed
wip
1 parent c732405 commit 4b6417c

File tree

4 files changed

+46
-5
lines changed

4 files changed

+46
-5
lines changed

.env.example

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ MCP_SERVER_URL=https://mcp.svelte.dev/mcp
2121
# MCP_SERVER_URL=
2222

2323
# To disable the test component tool, uncomment the line below
24-
#DISABLE_TESTCOMPONENT_TOOL=1
24+
#DISABLE_TESTCOMPONENT_TOOL=1
25+
26+
VERBOSE_LOGGING=true

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,13 @@ MCP_SERVER_URL=https://mcp.svelte.dev/mcp
4444
### Supported Providers
4545

4646
**Cloud Providers:**
47+
4748
- `anthropic/*` - Direct Anthropic API (requires `ANTHROPIC_API_KEY`)
4849
- `openai/*` - Direct OpenAI API (requires `OPENAI_API_KEY`)
4950
- `openrouter/*` - OpenRouter unified API (requires `OPENROUTER_API_KEY`)
5051

5152
**Local Providers:**
53+
5254
- `lmstudio/*` - LM Studio local server (requires LM Studio running on `http://localhost:1234`)
5355

5456
Example configurations:

index.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,44 @@ async function runSingleTest(
109109
};
110110

111111
// Create agent for this test
112+
let stepCounter = 0;
112113
const agent = new Agent({
113114
model,
114115
stopWhen: [hasToolCall("ResultWrite"), stepCountIs(10)],
115116
tools,
117+
onStepFinish: (step) => {
118+
if (process.env.VERBOSE_LOGGING !== "true") {
119+
return;
120+
}
121+
stepCounter++;
122+
console.log(` Step ${stepCounter}:`);
123+
if (step.text) {
124+
const preview =
125+
step.text.length > 100
126+
? step.text.slice(0, 100) + "..."
127+
: step.text;
128+
console.log(`💬 Text: ${preview}`);
129+
}
130+
if (step.toolCalls && step.toolCalls.length > 0) {
131+
for (const call of step.toolCalls) {
132+
if (call) {
133+
console.log(`🔧 Tool call: ${call.toolName}`);
134+
}
135+
}
136+
}
137+
if (step.toolResults && step.toolResults.length > 0) {
138+
for (const result of step.toolResults) {
139+
if (result && "output" in result) {
140+
const resultStr = JSON.stringify(result.output);
141+
const preview =
142+
resultStr.length > 80
143+
? resultStr.slice(0, 80) + "..."
144+
: resultStr;
145+
console.log(`📤 Tool result: ${preview}`);
146+
}
147+
}
148+
}
149+
},
116150
});
117151

118152
// Run the agent

lib/report-template.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ function renderContentBlock(block: ContentBlock): string {
9797
</details>`;
9898
} else if (block.type === "tool-result") {
9999
const outputText = JSON.stringify(block.output, null, 2);
100-
const isError = block.output && typeof block.output === "object" && "error" in block.output;
100+
const isError =
101+
block.output &&
102+
typeof block.output === "object" &&
103+
"error" in block.output;
101104
const statusIcon = isError ? "✗" : "✓";
102105
return `<details class="result ${isError ? "error" : ""}">
103106
<summary><span class="status ${isError ? "error" : "success"}">${statusIcon}</span> Output</summary>
@@ -180,8 +183,8 @@ function renderSteps(steps: Step[]): string {
180183
<summary class="step-header">
181184
<span class="step-num">Step ${index + 1}</span>
182185
<span class="line"></span>
183-
<span class="tokens" title="Total tokens: ${step.usage.totalTokens.toLocaleString()}&#10;Input: ${inputTokens.toLocaleString()} (${uncachedInputTokens.toLocaleString()} new + ${cachedTokens.toLocaleString()} cached)&#10;Output: ${step.usage.outputTokens.toLocaleString()}">${step.usage.totalTokens.toLocaleString()} tok</span>
184-
<span class="output" title="Output tokens generated: ${step.usage.outputTokens.toLocaleString()}&#10;${cachedTokens > 0 ? `Cached input tokens (⚡): ${cachedTokens.toLocaleString()} (not billed)` : "No cached tokens"}">(${step.usage.outputTokens.toLocaleString()}${cachedInfo})</span>
186+
<span class="tokens" title="Total tokens: ${step.usage.totalTokens.toLocaleString()}&#10;Input: ${inputTokens.toLocaleString()} (${uncachedInputTokens.toLocaleString()} new + ${cachedTokens?.toLocaleString()} cached)&#10;Output: ${step.usage.outputTokens.toLocaleString()}">${step.usage.totalTokens.toLocaleString()} tok</span>
187+
<span class="output" title="Output tokens generated: ${step.usage.outputTokens.toLocaleString()}&#10;${cachedTokens > 0 ? `Cached input tokens (⚡): ${cachedTokens?.toLocaleString()} (not billed)` : "No cached tokens"}">(${step.usage.outputTokens.toLocaleString()}${cachedInfo})</span>
185188
<span class="reason">${step.finishReason}</span>
186189
</summary>
187190
<div class="step-content">
@@ -217,7 +220,7 @@ function renderTestSection(test: SingleTestResult, index: number): string {
217220

218221
// Generate unique ID for this test's component code
219222
const componentId = `component-${test.testName.replace(/[^a-zA-Z0-9]/g, "-")}`;
220-
223+
221224
const resultWriteHtml = test.resultWriteContent
222225
? `<div class="output-section">
223226
<div class="token-summary">

0 commit comments

Comments
 (0)