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
7 changes: 4 additions & 3 deletions packages/scout-agent/agent.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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: {
Expand All @@ -51,6 +51,7 @@ agent.on("chat", async ({ id, messages }) => {
}),
},
});
return streamText(params);
});

agent.serve();
10 changes: 7 additions & 3 deletions packages/scout-agent/lib/core.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { createServerAdapter } from "@whatwg-node/server";
import {
readUIMessageStream,
simulateReadableStream,
streamText,
type UIMessage,
} from "ai";
import { MockLanguageModelV2 } from "ai/test";
Expand Down Expand Up @@ -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;
};
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<
Expand Down
24 changes: 12 additions & 12 deletions packages/scout-agent/lib/core.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -260,14 +254,20 @@ export class Scout {
}
}

streamStepResponse({
buildStreamTextParams({
messages,
chatID,
model,
providerOptions,
tools: providedTools,
systemPrompt = defaultSystemPrompt,
}: StreamStepResponseOptions): StreamTextResult<Tools, never> {
}: StreamStepResponseOptions): {
model: LanguageModel;
messages: ModelMessage[];
maxOutputTokens: number;
providerOptions?: ProviderOptions;
tools: Tools;
} {
if (!this.suppressConfigWarnings) {
this.printConfigWarnings();
}
Expand Down Expand Up @@ -376,12 +376,12 @@ ${slack.formattingRules}
}
lastMessage.providerOptions = providerOptions;

return streamText({
return {
model,
messages: converted,
maxOutputTokens: 64_000,
providerOptions,
tools: withModelIntent(tools),
});
};
}
}
2 changes: 1 addition & 1 deletion packages/scout-agent/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down