Commit Graph

179 Commits

Author SHA1 Message Date
Nikhil Sonti
385cf03227 chore: bump server version 2026-03-10 18:19:21 -07:00
Nikhil
a824078f6d fix: compaction config for small context windows (≤32K) (#466)
* fix: compaction config for small context windows (≤32K)

Raise COMPACTION_SMALL_CONTEXT_WINDOW from 16K to 32K so models like
Haiku 4.5 (30K context) use proportional 50% reserve instead of the
fixed 20K reserve. Also scale fixedOverhead for small contexts (capped
at 40% of context window) to prevent the doom loop where overhead alone
triggers compaction on every step.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* docs: add compaction tuning guidance to limits constants

Explain the relationship between SMALL_CONTEXT_WINDOW and
FIXED_OVERHEAD so devs know the 24K minimum constraint when
tweaking these values.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 18:12:20 -07:00
Nikhil Sonti
bcd91a8e03 chore: Merge branch 'main' 2026-03-10 17:23:27 -07:00
Nikhil
2d6d08c9fe fix: move tool-result media normalization into agent (#460)
* fix: sanitize media during compaction

* fix: normalize content outputs in compaction helpers

* fix: move tool-result media normalization into agent

* chore: rename compaction orchestrator file
2026-03-10 17:21:09 -07:00
Nikhil Sonti
2477063673 chore: bump server version 2026-03-10 15:08:17 -07:00
Nikhil
f81e73f6a4 fix: avoid crashing on controller startup failure (#458)
* fix: avoid crashing on controller startup failure

* fix: address PR review comments for remove_controller_startup_crash
2026-03-10 11:53:11 -07:00
Nikhil
4fc68b5264 feat: use execution dir for tool temp output (#456)
* feat: use execution dir for tool temp output

* fix: harden execution dir temp staging

* refactor: use temp files for transient tool output
2026-03-10 10:57:00 -07:00
Nikhil
5b27933c63 feat: add 2-stage pruning to compaction pipeline (#455)
* feat: add 2-stage pruning to compaction pipeline before LLM summarization

Add two new lightweight stages to the compaction prepareStep pipeline that
recover context tokens cheaply before falling back to expensive LLM
summarization:

- Stage 2: Use AI SDK's pruneMessages to remove old tool call/result
  pairs beyond the last 6 messages entirely
- Stage 3: Replace remaining tool output values with short placeholders
  ("[Cleared — N chars]") while preserving tool call structure and IDs

Both stages re-estimate tokens from message content (not stale step
usage) after modifying messages. The existing LLM summarization and
sliding window fallback remain as Stage 4.

Also adds estimateTokensForThreshold() helper, clearToolOutputs()
function, and COMPACTION_PRUNE_KEEP_RECENT_MESSAGES /
COMPACTION_CLEAR_OUTPUT_MIN_CHARS constants.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: reorder compaction pipeline — truncate before clear, protect recent tools

- Stage 0: Check threshold, return untouched when under (no data loss)
- Stage 1: Prune old tool call/result pairs beyond last 6 messages
- Stage 2: Truncate large tool outputs to 15K chars (keeps partial content)
- Stage 3: Clear old tool outputs with placeholders, protect last 2
- Stage 4: LLM-based compaction with sliding window fallback

clearToolOutputs now accepts keepRecentCount parameter (default 2) to
skip the N most recent tool messages from clearing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: limits fixes

* fix: address review — preserve toKeep context, derive test values from constants

- When Stage 3 (clearToolOutputs) doesn't resolve overflow, pass
  truncated (not cleared) messages to Stage 4 so toKeep retains
  meaningful tool outputs for the agent's immediate context
- Add comment explaining intentional conservatism in post-prune
  token estimation (step usage is stale, must re-estimate safely)
- Refactor computeConfig tests to derive expected values from
  AGENT_LIMITS constants instead of hardcoding magic numbers

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 10:41:34 -07:00
shivammittal274
d1937b3280 fix: replace stale browser_open_tab tool name with new_page in prompt (#454)
The system prompt referenced `browser_open_tab` which was renamed to
`new_page`. This caused models to infer a `browser_*` naming convention
and call non-existent tools like `browser_navigate`, resulting in
MCP error -32602.

Fixes TKT-540
2026-03-10 22:21:21 +05:30
Nikhil
15755a84d9 feat: use execution dir in browser tool context (#453) 2026-03-10 09:38:36 -07:00
Nikhil
7d20768d8e feat: persist large tool outputs to disk (#452)
* feat: persist large tool outputs to disk

* fix: address PR review comments for tool output limits

* chore: raise filesystem read line limit to 500
2026-03-10 09:25:19 -07:00
Nikhil Sonti
a2eb965759 chore: Merge branch 'main' of https://github.com/browseros-ai/BrowserOS-agent 2026-03-10 07:50:11 -07:00
Dani Akash
f35ac0ddd3 feat: new onboarding tools (#385)
* feat: new tools for breadcrumbs

* feat: setup scheduled task card

* feat: added dismiss cooldown

* chore: update prompt

* fix: support api key tool

* fix: prompt text to limit nudges

* fix: scheduled tasks card

* fix: update nudges prompt

* feat: skip nudges when user dismisses nudge

* fix: ensure nudges only show if they are not dismissed

* Revert "fix: ensure nudges only show if they are not dismissed"

This reverts commit d825254698829b8e9941aae7873bd440027d0c74.

* Revert "feat: skip nudges when user dismisses nudge"

This reverts commit 12b552b454d10ec4209b88668fc48681423ff6fc.

* Revert "fix: update nudges prompt"

This reverts commit 80b7520b953b4d3cbed2ed477b9e508e39938dca.

* feat: update agent with mcp when new mcp connection is added

* feat: created connect apps option as a blocking card system

* feat: schedule tasks passive without dismiss

* fix: nudges and prompt texts

* fix: biome lint errors

* fix: review comments

* fix: resolve comments

* fix: review comments

* fix: review comments

* fix: auto resolve state

* fix: eliminate the race where the async delete could resolve after the
new session

* feat: track ignored apps list

* fix: empty response text object on message reply

* feat: sync previously connected mcps

* feat: sync integrations with klavis

* feat: account for unauthenticated connections

* fix: analytics events

* fix: typescript issues

* fix: klavis client issue

* fix: invalid mcps causing entire responses from failing

* fix: prompt with card for integrations when the integration fails

* fix: prompt structure to support declined apps

* fix: refresh session on mcp changes
2026-03-10 17:44:10 +05:30
shivammittal274
b6b45404ee feat: add agent skills system with catalog, loader, and UI (#450)
* feat: add agent skills system with catalog, loader, and UI

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: return 500 for server errors in PUT/DELETE skill routes

Previously both handlers returned 404 for all errors, masking filesystem
failures (disk full, permission denied) as "not found". Now only
"not found" errors return 404; everything else returns 500.

* fix: align SKILL.md format with agentskills.io spec

- Move `enabled` and `version` into `metadata` field (spec only allows
  name, description, license, compatibility, metadata, allowed-tools)
- Frontmatter `name` now matches directory name (lowercase kebab-case)
- Human-readable name stored in `metadata.display-name`
- Add index signature to SkillMetadata for arbitrary string keys
- Validate frontmatter with type guard in getSkill (remove unsafe cast)
- updateSkill now preserves existing frontmatter fields (license, etc.)
- Tighten buildSkillMd param from Record<string, unknown> to SkillFrontmatter

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 17:24:05 +05:30
Nikhil Sonti
ca777dd2fd chore: bump server version 2026-03-09 16:25:43 -07:00
shivammittal274
44071cb0f4 fix: fix compaction tool output truncation and token estimation (#448)
- truncateToolOutputs: handle all output.type variants (text, json,
  content) by checking output.value directly instead of branching on
  type. The old code missed type 'content' (array of content parts),
  causing 1M+ char tool results to pass through untouched.

- estimateTokens: change chars/4 to chars/3 — HTML/Markdown content
  tokenizes at ~3.14 chars/token empirically, not 4.

- COMPACTION_FIXED_OVERHEAD: 5K → 12K to account for system prompt
  (~2.5K tokens) + tool definitions as JSON Schema (~8-9K tokens).

- Apply truncateToolOutputs in prepareStep (Stage 0) before token
  estimation, not just during summarization.
2026-03-10 02:39:54 +05:30
Nikhil Sonti
09bd10cb56 chore: bump server version 2026-03-09 12:04:20 -07:00
shivammittal274
3808faf94d fix: robust compaction with Pi-style token counting + overflow middle… (#444)
* fix: robust compaction with Pi-style token counting + overflow middleware

Root cause: getCurrentTokenCount() returned stale inputTokens from the
previous step, ignoring new tool results added to messages since that
step. A large tool output (DOM snapshot, page content) caused a token
jump that bypassed the compaction threshold check, leading to
context_length_exceeded errors (322K tokens sent, model max 262K).

Layer 1 — Accurate token counting (proactive):
- Adopt Pi coding agent's additive approach: base(inputTokens) +
  outputTokens + estimate(trailing tool results)
- Trailing tool results are estimated by walking backwards from end of
  messages array until a non-tool message is found
- Falls back to full estimation with safety multiplier when no real
  usage data is available (first step of a turn)

Layer 2 — Context overflow middleware (reactive):
- LanguageModelV3Middleware that wraps doGenerate/doStream
- Catches context_length_exceeded errors at the model call level
- Truncates prompt (keeps system messages + most recent non-system
  messages targeting 60% of context window)
- Retries the model call once

Verified end-to-end with real model (Gemini Flash Lite via OpenRouter)
on 16K context window: 4 compactions triggered correctly across 8
steps, no context_length_exceeded errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: adopt Pi-style overflow detection patterns + fix truncation edge case

- Replace 6 generic substring matches with 17 provider-specific regex
  patterns from Pi coding agent (Anthropic, OpenAI, Google, xAI, Groq,
  OpenRouter, Bedrock, Copilot, llama.cpp, LM Studio, MiniMax, Kimi,
  Mistral, z.ai)
- Fix truncatePrompt edge case: when the last message alone exceeds the
  target, keepFrom was never updated → empty non-system messages. Now
  always keeps at least the most recent non-system message.
- Add runtime guard for LanguageModelV3 cast in ai-sdk-agent.ts
- Add tests for false-positive rejection and truncation edge case

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 14:22:35 +05:30
shivammittal274
c8a674fe93 feat: return element coordinates in tool responses and DPR in screens… (#437)
* feat: return element coordinates in tool responses and DPR in screenshots

- click, hover, fill, drag now return resolved coordinates in response text
- take_screenshot returns devicePixelRatio for mapping coordinates to pixels
- Coordinates are in CSS pixels; multiply by DPR to get screenshot pixels

* fix: use Promise.allSettled in screenshot to prevent DPR eval from aborting capture

Runtime.evaluate for devicePixelRatio can fail on PDF pages or
chrome-extension pages. Using Promise.allSettled ensures the screenshot
still succeeds, falling back to DPR=1.
2026-03-07 16:29:13 +05:30
Nikhil
2e79933cae refactor: flatten server agent directory (#435) 2026-03-06 16:07:14 -08:00
Nikhil Sonti
7dbf645457 chore: bump server version 2026-03-06 11:37:00 -08:00
Nikhil
bc53ff52e5 feat: remove legacy /chat endpoint (#428)
* feat: remove legacy chat endpoint alias

* refactor: rename chat-v2 to chat
2026-03-06 09:29:42 -08:00
shivammittal274
d778cd6ba9 fix: anchor agent to active tab page ID from browser context (#426)
* fix: anchor agent to active tab page ID from browser context

Generalize the scheduled-task page anchoring instruction to all tasks.
The agent now always uses the page ID from Browser Context instead of
calling get_active_page or list_pages, preventing it from operating
on the wrong tab.

* fix: add chatMode guard and scope windowLine to scheduled tasks

- Skip page-context section in chat mode where list_pages is allowed
- Only show windowId instruction for scheduled tasks (hidden window)
2026-03-06 17:11:22 +05:30
Nikhil Sonti
3477772e4e chore: bump server version 2026-03-05 19:52:45 -08:00
Felarof
696d520199 Revert "feat: integrate models.dev registry for model defaults (#425)"
This reverts commit ddc376a026.
2026-03-05 17:48:12 -08:00
Felarof
ddc376a026 feat: integrate models.dev registry for model defaults (#425)
* feat: integrate models.dev registry for auto-populated model defaults

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: fall back to upstream provider for model registry lookup

When the browseros meta-provider is used, the registry lookup now
also tries the upstream provider (e.g., openrouter, anthropic) so
that BrowserOS-hosted models get correct context window and image
support defaults.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: add Object.hasOwn guards to prevent prototype chain lookup

Addresses Greptile review: bracket notation on the registry object
could return prototype-chain properties for keys like __proto__ or
constructor, bypassing the 404 guard in the route handler.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 16:27:14 -08:00
Nikhil
9fdb361d67 feat: build prod server resource artifact pipeline (#417)
* feat: build prod server resource artifacts with cloudflare r2

* fix: address PR review comments for prod_server_resources_cloudflare

* feat: fix prod server build setup and CLI ergonomics

* fix: prevent build env secret inlining and template fallback

* fix: read from fileenv

* feat: add ripgrep

* feat: upload prod artifacts to latest and version prefixes
2026-03-05 14:26:46 -08:00
Nikhil
e37d19da51 feat: add structured MCP tool outputs and schemas (#420)
* feat: add structured MCP outputs for browser tools

* fix: address PR review comments for mcp_structured_content
2026-03-05 13:19:01 -08:00
shivammittal274
88cb227444 feat: add MCP server instructions for external AI clients (#419)
Add server-level instructions that get injected into the LLM system
prompt when external MCP clients (Claude Desktop, Cursor, Gemini CLI)
connect. Covers browser automation workflow, Klavis integration
discovery, and auth flow guidance.
2026-03-06 02:28:09 +05:30
Nikhil
ec725b3781 fix: restrict browser tools in chat mode for AI SDK agent (#414)
The AI SDK agent (v2) was allowing all 54 browser tools in chat mode,
while the Gemini agent correctly restricted to 6 read-only tools.
Extract CHAT_MODE_ALLOWED_TOOLS to a shared constant and filter
browser tools in AiSdkAgent.create() when chatMode is true.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 11:59:00 -08:00
Nikhil
52570bd6aa feat: make server tests use dynamic browser runtime allocation (#416)
* feat: use dynamic runtime allocation for server test browser startup

* fix: address PR review comments for sdk_test_dev_runner_migration
2026-03-05 11:19:31 -08:00
shivammittal274
fb58a6ee1c feat: expose Klavis MCP tools to external MCP clients (#411)
* feat: expose Klavis MCP tools to external MCP clients

Connect to Klavis Strata at server startup and register discovered tools
on each per-request McpServer instance. This lets external MCP clients
(Claude Code, Gemini CLI) access Klavis-proxied integrations (Gmail,
Slack, GitHub, etc.) alongside browser tools.

- Add register-klavis-mcp.ts with connectKlavisProxy() and registerKlavisTools()
- Wire KlavisProxyHandle through server.ts -> mcp routes -> mcp-server
- Use structured logging and proper type imports

* fix: forward Klavis tool schemas and add shutdown cleanup

- Use zod-from-json-schema to convert Strata's JSON Schema to Zod,
  so MCP clients see proper parameter names, types, and required fields
- Close Klavis proxy transport on server shutdown
- Move per-request Klavis tool registration logging to debug level
- Use proper type imports instead of inline import() types
- Fix connectKlavisProxy return type (never returns null)

* fix: add timeout to Klavis MCP connect/listTools and log shutdown errors

* fix: clear timeout timer and pre-compute Klavis tool schemas at startup

* fix: use client.close() instead of transport.close() for proper cleanup
2026-03-06 00:04:57 +05:30
Nikhil
a91bef1cd1 feat: remove legacy gemini agent and provider adapter (#415)
* feat: remove legacy gemini agent and provider adapter

* fix: remove redundant run graph schema refine
2026-03-05 10:34:43 -08:00
Felarof
609341a445 feat: add Kimi/Moonshot partnership branding with feature flag
## Summary
- Add `VITE_PUBLIC_KIMI_LAUNCH` feature flag controlling Kimi partnership branding
- BrowserOS provider card shows "Powered by Kimi K2.5 from Moonshot AI" badge and "Extended usage limits for the next 2 weeks!" when flag is on
- Moonshot/Kimi highlighted as "Recommended" in provider templates
- LLM Hub defaults to Kimi, ChatGPT, Claude, Gemini (with legacy defaults migration)
- Kimi hub row shows "Powered by Moonshot AI" flare
- Model selector locked to kimi-k2.5
- "How to get a Kimi API key" link in provider dialog
- Moonshot provider fully integrated across frontend and backend
2026-03-04 17:55:40 -08:00
Nikhil
3969660906 fix: refactor SDK BrowserService to use Browser class directly (#406)
* fix: refactor SDK BrowserService to use Browser class directly

The tools system was completely rewritten with new tool names and response
formats. BrowserService was calling non-existent MCP tools (browser_get_active_tab,
browser_navigate, etc.) that returned structuredContent which no longer exists.

Replaced MCP HTTP client calls with direct Browser class method calls:
- getActiveTab → browser.getActivePage() / browser.listPages()
- getPageContent → browser.contentAsMarkdown()
- getScreenshot → browser.screenshot()
- navigate → browser.goto() with tabId/windowId resolution
- getPageLoadStatus → browser.listPages() with isLoading check
- getInteractiveElements → browser.snapshot() / browser.enhancedSnapshot()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: address PR review — consistent tabId guard and remove dead PageContent type

- Change `if (tabId)` to `if (tabId !== undefined)` in navigate() to match
  the guard style used for windowId and elsewhere in the file
- Remove orphaned PageContent interface no longer imported after refactor

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 14:08:18 -08:00
Dani Akash
52f9dfb2e4 feat: soul and memory (#401)
* feat: install fuse.js

* feat: implement soul and basic memory system

* fix: memory recall

* fix: memory search pattern

* feat: create soul.md file progressively

* fix: soul vs core memory

* fix: provide a soul read tool

* feat: display soul on settings page

* feat: refresh soul document

* fix: chat mode avoids memory and soul tools

* fix: date construction on memory cleanup

* fix: atomicity of write operation

* chore: upgrade biome
2026-03-04 19:12:47 +05:30
Nikhil Sonti
d4447adf65 chore: bump server version 2026-03-03 12:01:14 -08:00
Nikhil
ae2c216321 feat: add get_dom and search_dom tools (#398)
* feat: add get_dom and search_dom tools for HTML DOM inspection

Add two new observation tools:
- get_dom: Returns raw HTML of a page or scoped element via CSS selector
- search_dom: Fuzzy searches DOM elements by text, attributes, IDs, and
  class names using Fuse.js with extended search syntax support

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* refactor: use CDP DOM protocol instead of injected scripts for DOM tools

Replace Runtime.evaluate-based approach with native CDP DOM methods:
- get_dom uses DOM.getDocument + DOM.querySelector + DOM.getOuterHTML
- search_dom uses DOM.performSearch + DOM.getSearchResults + DOM.describeNode
- Remove fuse.js dependency (CDP performSearch handles text/CSS/XPath natively)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test: add comprehensive tests for get_dom and search_dom tools

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: resolve text nodes to parent elements in searchDom

CDP performSearch returns text nodes (nodeType 3) for plain text queries.
describeNode does not populate parentId, so use resolveNode + callFunctionOn
to get parentElement, then requestNode to obtain the parent's nodeId.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: add limit bounds validation and searchId leak prevention

- Add .int().min(1).max(200) to search_dom limit parameter
- Wrap searchDom result processing in try/finally to ensure
  discardSearchResults is always called

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 11:35:09 -08:00
Nikhil
20bb4cb21e fix: use pageIds instead of tabIds in tab group tests (#397)
Tests were passing raw Chrome tabIds to group_tabs and ungroup_tabs tools,
but the Zod schemas expect pageIds (MCP-layer page IDs). The tabIds field
was silently stripped during validation, causing both tests to fail.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 10:54:49 -08:00
Nikhil
14ab8fe97e feat: add new CDP tools and improve tool ergonomics (#396)
* feat: add new CDP tools for links, hidden pages/windows, show/move

- get_page_links: extract deduplicated links from a page via evaluate
- new_hidden_page: open a hidden tab for background automation
- create_hidden_window: create a hidden window for background automation
- show_page: restore a hidden page back into a visible window
- move_page: move a tab to a different window or position
- Default includeLinks to false in get_page_content

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: use AX tree for get_page_links, add tests, fix test scripts

- Refactor get_page_links to use accessibility tree instead of raw JS
  evaluate — more reliable for role="link" elements and shadow DOM
- Add extractLinkNodes() to snapshot.ts and getPageLinks() to browser.ts
- Add tests for get_page_links (constructed HTML with dedup/filtering),
  new_hidden_page, show_page, move_page, create_hidden_window
- Fix root package.json test scripts to match server's actual scripts
- Update CLAUDE.md test docs to reflect current structure

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 10:38:23 -08:00
Nikhil
36b9a78d56 fix: move ChatV2Service to API services layer and add resolvePageIds (#394)
* feat: move ChatV2Service to api/services layer and add resolvePageIds

Move ChatV2Service from agent/tool-loop/ to api/services/ where it
belongs as a service-layer concern. Add resolvePageIds() to convert
Chrome tab IDs to internal page IDs before they reach the agent,
fixing undefined pageId issues in browser automation tools.

Clean up server.ts by removing the USE_TOOL_AGENT flag, SessionManager,
and old chat route import — both /chat and /chat-v2 now directly use
createChatV2Routes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: address review comments for chat-v2-service

- Fix TOCTOU race: derive isNewSession inside the creation block
  instead of separate has()/get() calls
- Log warning when resolvePageIds can't map a tab ID
- Deduplicate tab IDs with Set before resolving
- Remove redundant null check on session in onFinish
- Add license header

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: update bun.lock

* fix: skip resolvePageIds for scheduled tasks to prevent pageId corruption

Scheduled tasks build browserContext with internal page IDs from
browser.newPage(), not Chrome tab IDs. The unconditional second
resolvePageIds() call was passing these internal IDs to resolveTabIds()
which expects Chrome tab IDs, causing the lookup to fail and overwrite
correct pageIds with undefined.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 10:18:44 -08:00
Nikhil
f449162699 fix: suppress biome lint warnings with biome-ignore directives (#395)
Add biome-ignore comments for noExcessiveCognitiveComplexity on compaction.ts
and grep.ts, and noExplicitAny on filesystem test helpers.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 10:12:07 -08:00
shivammittal274
de52afbc55 feat: generalized compaction prompts with split turn handling (#391)
* feat: generalized compaction prompts with split turn handling

Replace browser-specific XML prompts with domain-agnostic markdown format.
Add split turn detection and parallel summarization for large single-turn
conversations. Switch compaction from generateText to streamText for
Fireworks API compatibility. Add comprehensive unit and E2E tests (84 total).

* fix: address code review issues for compaction (PR #391)

Enforce COMPACTION_MAX_SUMMARIZATION_INPUT cap, extract shared
callSummarizer helper, add runtime type guard for experimental_context,
move magic constants to AGENT_LIMITS, and remove dead constants.

* fix: cap truncatedTurnPrefix input to maxSummarizationInput

Apply the same sliding window cap to turn prefix messages that was
already applied to toSummarize, preventing unbounded LLM input for
long single-turn conversations with many tool calls.

* fix: reduce browseros-auto default context window to 200K

The 400K setting caused compaction to trigger at ~383K, but the actual
model limit is 262K. Conversations hit the hard limit before compaction
could kick in.
2026-03-03 17:20:18 +05:30
Nikhil
d84feb105c feat: add different signal for sigterm and sigint (#390) 2026-03-02 18:23:22 -08:00
Nikhil Sonti
053480d753 feat: add shutdown reason 2026-03-02 18:17:16 -08:00
Nikhil
f74c353698 feat: remove tab-grouping instructions from agent prompt (#388)
* feat: remove tab grouping from agent prompt

* fix: address PR review comments for remove_tab_grouping
2026-03-02 17:53:15 -08:00
Nikhil Sonti
54f7e90a61 chore: bump server version 2026-03-02 15:23:08 -08:00
shivammittal274
c5afcea1fb fix: per-request MCP server+transport for SDK 1.26.0 security fix (#386)
* fix: use fresh browser context for selected tabs on each message

Previously, session.browserContext (set on the first message) always
took precedence via the nullish coalescing operator. On subsequent
messages with different tab selections, the new selectedTabs from the
request were silently ignored.

Now normal messages always use request.browserContext so freshly
selected tabs are included. Scheduled tasks still use the stored
session context to preserve the hidden window's pageId/windowId.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: use singleton transport for MCP route

MCP SDK 1.26.0 added a strict guard in Protocol.connect() that throws
"Already connected to a transport" if called when already connected.
The previous code created a new transport per request and called
connect() each time, causing every request after the first to fail
with -32603 Internal server error.

Move transport creation outside the request handler and add
isConnected() check per @hono/mcp docs pattern.

* fix: per-request MCP server+transport for SDK 1.26.0 compat

MCP SDK 1.26.0 patched a security vulnerability (GHSA-345p-7cg4-v4c7)
where sharing a singleton McpServer across requests could leak
cross-client response data via message ID collisions.

Create fresh McpServer + StreamableHTTPTransport per request:
no shared state, no race conditions, no ID collisions.

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 15:03:14 -08:00
shivammittal274
2988bf3640 feat: add workspace directory awareness to agent system prompt (#383)
The agent had no knowledge of its working directory, so it couldn't
reference created files by absolute path or help users locate them.

Pass sessionExecutionDir into buildSystemPrompt for both AiSdkAgent
and GeminiAgent so the prompt includes a <workspace> section with
the resolved directory path.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 16:12:18 +05:30
shivammittal274
3aca3a6f5c fix: use fresh browser context for selected tabs on each message (#384)
Previously, session.browserContext (set on the first message) always
took precedence via the nullish coalescing operator. On subsequent
messages with different tab selections, the new selectedTabs from the
request were silently ignored.

Now normal messages always use request.browserContext so freshly
selected tabs are included. Scheduled tasks still use the stored
session context to preserve the hidden window's pageId/windowId.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 16:12:04 +05:30