mirror of
https://github.com/browseros-ai/BrowserOS.git
synced 2026-05-17 02:25:57 +00:00
refactor: flatten server agent directory (#435)
This commit is contained in:
@@ -22,8 +22,8 @@
|
||||
"import": "./src/rpc.ts"
|
||||
},
|
||||
"./agent": {
|
||||
"types": "./src/agent/tool-loop/ai-sdk-agent.ts",
|
||||
"default": "./src/agent/tool-loop/ai-sdk-agent.ts"
|
||||
"types": "./src/agent/ai-sdk-agent.ts",
|
||||
"default": "./src/agent/ai-sdk-agent.ts"
|
||||
},
|
||||
"./agent/types": {
|
||||
"types": "./src/agent/types.ts",
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
import { AGENT_LIMITS } from '@browseros/shared/constants/limits'
|
||||
import type { BrowserContext } from '@browseros/shared/schemas/browser-context'
|
||||
import { stepCountIs, ToolLoopAgent, type UIMessage } from 'ai'
|
||||
import type { Browser } from '../../browser/browser'
|
||||
import type { KlavisClient } from '../../lib/clients/klavis/klavis-client'
|
||||
import { logger } from '../../lib/logger'
|
||||
import { isSoulBootstrap, readSoul } from '../../lib/soul'
|
||||
import { buildFilesystemToolSet } from '../../tools/filesystem/build-toolset'
|
||||
import { buildMemoryToolSet } from '../../tools/memory/build-toolset'
|
||||
import type { ToolRegistry } from '../../tools/tool-registry'
|
||||
import { CHAT_MODE_ALLOWED_TOOLS } from '../chat-mode'
|
||||
import { buildSystemPrompt } from '../prompt'
|
||||
import type { ResolvedAgentConfig } from '../types'
|
||||
import type { Browser } from '../browser/browser'
|
||||
import type { KlavisClient } from '../lib/clients/klavis/klavis-client'
|
||||
import { logger } from '../lib/logger'
|
||||
import { isSoulBootstrap, readSoul } from '../lib/soul'
|
||||
import { buildFilesystemToolSet } from '../tools/filesystem/build-toolset'
|
||||
import { buildMemoryToolSet } from '../tools/memory/build-toolset'
|
||||
import type { ToolRegistry } from '../tools/tool-registry'
|
||||
import { CHAT_MODE_ALLOWED_TOOLS } from './chat-mode'
|
||||
import { createCompactionPrepareStep } from './compaction'
|
||||
import { buildMcpServerSpecs, createMcpClients } from './mcp-builder'
|
||||
import { buildSystemPrompt } from './prompt'
|
||||
import { createLanguageModel } from './provider-factory'
|
||||
import { buildBrowserToolSet } from './tool-adapter'
|
||||
import type { ResolvedAgentConfig } from './types'
|
||||
|
||||
export interface AiSdkAgentConfig {
|
||||
resolvedConfig: ResolvedAgentConfig
|
||||
@@ -1,6 +1,6 @@
|
||||
import { AGENT_LIMITS } from '@browseros/shared/constants/limits'
|
||||
import { type LanguageModel, type ModelMessage, streamText } from 'ai'
|
||||
import { logger } from '../../lib/logger'
|
||||
import { logger } from '../lib/logger'
|
||||
import {
|
||||
buildSummarizationPrompt,
|
||||
buildSummarizationSystemPrompt,
|
||||
@@ -1,12 +1,12 @@
|
||||
import { createMCPClient } from '@ai-sdk/mcp'
|
||||
import type { BrowserContext } from '@browseros/shared/schemas/browser-context'
|
||||
import type { ToolSet } from 'ai'
|
||||
import type { KlavisClient } from '../../lib/clients/klavis/klavis-client'
|
||||
import { logger } from '../../lib/logger'
|
||||
import type { KlavisClient } from '../lib/clients/klavis/klavis-client'
|
||||
import { logger } from '../lib/logger'
|
||||
import {
|
||||
detectMcpTransport,
|
||||
type McpTransportType,
|
||||
} from '../../lib/mcp-transport-detect'
|
||||
} from '../lib/mcp-transport-detect'
|
||||
|
||||
export interface McpServerSpec {
|
||||
name: string
|
||||
@@ -7,9 +7,9 @@ import { createOpenAICompatible } from '@ai-sdk/openai-compatible'
|
||||
import { LLM_PROVIDERS } from '@browseros/shared/schemas/llm'
|
||||
import { createOpenRouter } from '@openrouter/ai-sdk-provider'
|
||||
import type { LanguageModel } from 'ai'
|
||||
import { logger } from '../../lib/logger'
|
||||
import { createOpenRouterCompatibleFetch } from '../../lib/openrouter-fetch'
|
||||
import type { ResolvedAgentConfig } from '../types'
|
||||
import { logger } from '../lib/logger'
|
||||
import { createOpenRouterCompatibleFetch } from '../lib/openrouter-fetch'
|
||||
import type { ResolvedAgentConfig } from './types'
|
||||
|
||||
type ProviderFactory = (
|
||||
config: ResolvedAgentConfig,
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { BrowserContext } from '@browseros/shared/schemas/browser-context'
|
||||
import { logger } from '../../lib/logger'
|
||||
import { logger } from '../lib/logger'
|
||||
import type { AiSdkAgent } from './ai-sdk-agent'
|
||||
|
||||
export interface AgentSession {
|
||||
@@ -1,11 +1,11 @@
|
||||
import type { LanguageModelV2ToolResultOutput } from '@ai-sdk/provider'
|
||||
import { type ToolSet, tool } from 'ai'
|
||||
import type { Browser } from '../../browser/browser'
|
||||
import { logger } from '../../lib/logger'
|
||||
import { metrics } from '../../lib/metrics'
|
||||
import { executeTool } from '../../tools/framework'
|
||||
import type { ContentItem } from '../../tools/response'
|
||||
import type { ToolRegistry } from '../../tools/tool-registry'
|
||||
import type { Browser } from '../browser/browser'
|
||||
import { logger } from '../lib/logger'
|
||||
import { metrics } from '../lib/metrics'
|
||||
import { executeTool } from '../tools/framework'
|
||||
import type { ContentItem } from '../tools/response'
|
||||
import type { ToolRegistry } from '../tools/tool-registry'
|
||||
|
||||
function contentToModelOutput(
|
||||
content: ContentItem[],
|
||||
@@ -1,7 +1,7 @@
|
||||
import { PATHS } from '@browseros/shared/constants/paths'
|
||||
import { zValidator } from '@hono/zod-validator'
|
||||
import { Hono } from 'hono'
|
||||
import { SessionStore } from '../../agent/tool-loop/session-store'
|
||||
import { SessionStore } from '../../agent/session-store'
|
||||
import type { Browser } from '../../browser/browser'
|
||||
import { KlavisClient } from '../../lib/clients/klavis/klavis-client'
|
||||
import { logger } from '../../lib/logger'
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
import { mkdir } from 'node:fs/promises'
|
||||
import path from 'node:path'
|
||||
import { createAgentUIStreamResponse, type UIMessage } from 'ai'
|
||||
import { AiSdkAgent } from '../../agent/tool-loop/ai-sdk-agent'
|
||||
import { formatUserMessage } from '../../agent/tool-loop/format-message'
|
||||
import type { SessionStore } from '../../agent/tool-loop/session-store'
|
||||
import { AiSdkAgent } from '../../agent/ai-sdk-agent'
|
||||
import { formatUserMessage } from '../../agent/format-message'
|
||||
import type { SessionStore } from '../../agent/session-store'
|
||||
import type { ResolvedAgentConfig } from '../../agent/types'
|
||||
import type { Browser } from '../../browser/browser'
|
||||
import type { KlavisClient } from '../../lib/clients/klavis/klavis-client'
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
type CompactionState,
|
||||
computeConfig,
|
||||
createCompactionPrepareStep,
|
||||
} from '../../src/agent/tool-loop/compaction'
|
||||
} from '../../src/agent/compaction'
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Test infrastructure
|
||||
|
||||
@@ -6,12 +6,12 @@ import {
|
||||
findSafeSplitPoint,
|
||||
slidingWindow,
|
||||
truncateToolOutputs,
|
||||
} from '../../src/agent/tool-loop/compaction'
|
||||
} from '../../src/agent/compaction'
|
||||
import {
|
||||
buildSummarizationPrompt,
|
||||
buildTurnPrefixPrompt,
|
||||
messagesToTranscript,
|
||||
} from '../../src/agent/tool-loop/compaction-prompt'
|
||||
} from '../../src/agent/compaction-prompt'
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Helpers
|
||||
|
||||
Reference in New Issue
Block a user