diff --git a/packages/scout-agent/agent.ts b/packages/scout-agent/agent.ts index 9f36828..dcf2ae3 100644 --- a/packages/scout-agent/agent.ts +++ b/packages/scout-agent/agent.ts @@ -1,4 +1,4 @@ -import { tool } from "ai"; +import { streamText, tool } from "ai"; import * as blink from "blink"; import { z } from "zod"; import { type Message, Scout } from "./lib"; @@ -36,9 +36,9 @@ agent.on("request", async (request) => { }); agent.on("chat", async ({ id, messages }) => { - return scout.streamStepResponse({ - chatID: id, + const params = scout.buildStreamTextParams({ messages, + chatID: id, model: "anthropic/claude-sonnet-4.5", providerOptions: { anthropic: { cacheControl: { type: "ephemeral" } } }, tools: { @@ -51,6 +51,7 @@ agent.on("chat", async ({ id, messages }) => { }), }, }); + return streamText(params); }); agent.serve(); diff --git a/packages/scout-agent/lib/core.test.ts b/packages/scout-agent/lib/core.test.ts index 49e783d..658d6cd 100644 --- a/packages/scout-agent/lib/core.test.ts +++ b/packages/scout-agent/lib/core.test.ts @@ -5,6 +5,7 @@ import { createServerAdapter } from "@whatwg-node/server"; import { readUIMessageStream, simulateReadableStream, + streamText, type UIMessage, } from "ai"; import { MockLanguageModelV2 } from "ai/test"; @@ -64,11 +65,12 @@ const newAgent = (options: { return new Response("Hello, world!", { status: 200 }); }); agent.on("chat", async ({ messages }) => { - return core.streamStepResponse({ + const params = core.buildStreamTextParams({ model: options.model, messages, chatID: "b485db32-3d53-45fb-b980-6f4672fc66a6", }); + return streamText(params); }); return agent; }; @@ -611,11 +613,12 @@ describe("daytona integration", () => { }, }); - const result = scout.streamStepResponse({ + const params = scout.buildStreamTextParams({ chatID: "test-chat-id" as blink.ID, messages: [], model: newMockModel({ textResponse: "test" }), }); + const result = streamText(params); // Access the tools from the result and call initialize_workspace directly // biome-ignore lint/suspicious/noExplicitAny: accessing internal tools for testing @@ -677,11 +680,12 @@ describe("daytona integration", () => { }, }); - const result = scout.streamStepResponse({ + const params = scout.buildStreamTextParams({ chatID: "test-chat-id" as blink.ID, messages: [], model: newMockModel({ textResponse: "test" }), }); + const result = streamText(params); // biome-ignore lint/suspicious/noExplicitAny: accessing internal tools for testing const tools = (result as any).tools as Record< diff --git a/packages/scout-agent/lib/core.ts b/packages/scout-agent/lib/core.ts index f328872..9712514 100644 --- a/packages/scout-agent/lib/core.ts +++ b/packages/scout-agent/lib/core.ts @@ -1,15 +1,9 @@ import util from "node:util"; -import type { ProviderOptions } from "@ai-sdk/provider-utils"; +import type { ModelMessage, ProviderOptions } from "@ai-sdk/provider-utils"; import withModelIntent from "@blink-sdk/model-intent"; import * as slack from "@blink-sdk/slack"; import type { App } from "@slack/bolt"; -import { - convertToModelMessages, - type LanguageModel, - type StreamTextResult, - streamText, - type Tool, -} from "ai"; +import { convertToModelMessages, type LanguageModel, type Tool } from "ai"; import type * as blink from "blink"; import { type DaytonaClient, @@ -260,14 +254,20 @@ export class Scout { } } - streamStepResponse({ + buildStreamTextParams({ messages, chatID, model, providerOptions, tools: providedTools, systemPrompt = defaultSystemPrompt, - }: StreamStepResponseOptions): StreamTextResult { + }: StreamStepResponseOptions): { + model: LanguageModel; + messages: ModelMessage[]; + maxOutputTokens: number; + providerOptions?: ProviderOptions; + tools: Tools; + } { if (!this.suppressConfigWarnings) { this.printConfigWarnings(); } @@ -376,12 +376,12 @@ ${slack.formattingRules} } lastMessage.providerOptions = providerOptions; - return streamText({ + return { model, messages: converted, maxOutputTokens: 64_000, providerOptions, tools: withModelIntent(tools), - }); + }; } } diff --git a/packages/scout-agent/package.json b/packages/scout-agent/package.json index d92beb0..3d3b251 100644 --- a/packages/scout-agent/package.json +++ b/packages/scout-agent/package.json @@ -1,7 +1,7 @@ { "name": "@blink-sdk/scout-agent", "description": "A general-purpose AI agent with GitHub, Slack, web search, and compute capabilities built on Blink SDK.", - "version": "0.0.2", + "version": "0.0.3", "type": "module", "keywords": [ "blink",