Skip to content

Commit cd31d34

Browse files
authored
chore: replace scout.streamStepResponse with buildStreamTextParams (#86)
1 parent d18cf85 commit cd31d34

File tree

4 files changed

+24
-19
lines changed

4 files changed

+24
-19
lines changed

packages/scout-agent/agent.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { tool } from "ai";
1+
import { streamText, tool } from "ai";
22
import * as blink from "blink";
33
import { z } from "zod";
44
import { type Message, Scout } from "./lib";
@@ -36,9 +36,9 @@ agent.on("request", async (request) => {
3636
});
3737

3838
agent.on("chat", async ({ id, messages }) => {
39-
return scout.streamStepResponse({
40-
chatID: id,
39+
const params = scout.buildStreamTextParams({
4140
messages,
41+
chatID: id,
4242
model: "anthropic/claude-sonnet-4.5",
4343
providerOptions: { anthropic: { cacheControl: { type: "ephemeral" } } },
4444
tools: {
@@ -51,6 +51,7 @@ agent.on("chat", async ({ id, messages }) => {
5151
}),
5252
},
5353
});
54+
return streamText(params);
5455
});
5556

5657
agent.serve();

packages/scout-agent/lib/core.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { createServerAdapter } from "@whatwg-node/server";
55
import {
66
readUIMessageStream,
77
simulateReadableStream,
8+
streamText,
89
type UIMessage,
910
} from "ai";
1011
import { MockLanguageModelV2 } from "ai/test";
@@ -64,11 +65,12 @@ const newAgent = (options: {
6465
return new Response("Hello, world!", { status: 200 });
6566
});
6667
agent.on("chat", async ({ messages }) => {
67-
return core.streamStepResponse({
68+
const params = core.buildStreamTextParams({
6869
model: options.model,
6970
messages,
7071
chatID: "b485db32-3d53-45fb-b980-6f4672fc66a6",
7172
});
73+
return streamText(params);
7274
});
7375
return agent;
7476
};
@@ -611,11 +613,12 @@ describe("daytona integration", () => {
611613
},
612614
});
613615

614-
const result = scout.streamStepResponse({
616+
const params = scout.buildStreamTextParams({
615617
chatID: "test-chat-id" as blink.ID,
616618
messages: [],
617619
model: newMockModel({ textResponse: "test" }),
618620
});
621+
const result = streamText(params);
619622

620623
// Access the tools from the result and call initialize_workspace directly
621624
// biome-ignore lint/suspicious/noExplicitAny: accessing internal tools for testing
@@ -677,11 +680,12 @@ describe("daytona integration", () => {
677680
},
678681
});
679682

680-
const result = scout.streamStepResponse({
683+
const params = scout.buildStreamTextParams({
681684
chatID: "test-chat-id" as blink.ID,
682685
messages: [],
683686
model: newMockModel({ textResponse: "test" }),
684687
});
688+
const result = streamText(params);
685689

686690
// biome-ignore lint/suspicious/noExplicitAny: accessing internal tools for testing
687691
const tools = (result as any).tools as Record<

packages/scout-agent/lib/core.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
import util from "node:util";
2-
import type { ProviderOptions } from "@ai-sdk/provider-utils";
2+
import type { ModelMessage, ProviderOptions } from "@ai-sdk/provider-utils";
33
import withModelIntent from "@blink-sdk/model-intent";
44
import * as slack from "@blink-sdk/slack";
55
import type { App } from "@slack/bolt";
6-
import {
7-
convertToModelMessages,
8-
type LanguageModel,
9-
type StreamTextResult,
10-
streamText,
11-
type Tool,
12-
} from "ai";
6+
import { convertToModelMessages, type LanguageModel, type Tool } from "ai";
137
import type * as blink from "blink";
148
import {
159
type DaytonaClient,
@@ -260,14 +254,20 @@ export class Scout {
260254
}
261255
}
262256

263-
streamStepResponse({
257+
buildStreamTextParams({
264258
messages,
265259
chatID,
266260
model,
267261
providerOptions,
268262
tools: providedTools,
269263
systemPrompt = defaultSystemPrompt,
270-
}: StreamStepResponseOptions): StreamTextResult<Tools, never> {
264+
}: StreamStepResponseOptions): {
265+
model: LanguageModel;
266+
messages: ModelMessage[];
267+
maxOutputTokens: number;
268+
providerOptions?: ProviderOptions;
269+
tools: Tools;
270+
} {
271271
if (!this.suppressConfigWarnings) {
272272
this.printConfigWarnings();
273273
}
@@ -376,12 +376,12 @@ ${slack.formattingRules}
376376
}
377377
lastMessage.providerOptions = providerOptions;
378378

379-
return streamText({
379+
return {
380380
model,
381381
messages: converted,
382382
maxOutputTokens: 64_000,
383383
providerOptions,
384384
tools: withModelIntent(tools),
385-
});
385+
};
386386
}
387387
}

packages/scout-agent/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@blink-sdk/scout-agent",
33
"description": "A general-purpose AI agent with GitHub, Slack, web search, and compute capabilities built on Blink SDK.",
4-
"version": "0.0.2",
4+
"version": "0.0.3",
55
"type": "module",
66
"keywords": [
77
"blink",

0 commit comments

Comments
 (0)