Skip to content

Add browser-compatible agent loop packages#31

Merged
nick-pape merged 5 commits into
mainfrom
codex/browser-agent-loop
Jun 9, 2026
Merged

Add browser-compatible agent loop packages#31
nick-pape merged 5 commits into
mainfrom
codex/browser-agent-loop

Conversation

@nick-pape

Copy link
Copy Markdown
Owner

Summary

  • Extract the ACP agent loop into @fledgling/agent-core with injected session, tool, model, and logger interfaces.
  • Add Node/browser session implementations and rewire @fledgling/acp-agent as a Node assembly package.
  • Add a browser web-agent package plus a WebContainer-compatible MCP workspace sidecar over MCP in-memory transport.
  • Add a webpack bundle proof that fails on Node builtin imports from the browser entrypoint.

Verification

  • rush test --to @fledgling/acp-agent
  • rush build --to @fledgling/web-agent
  • rushx bundle from packages/web-agent (passes with webpack size warnings for the 374 KiB bundle)

Closes #30.

Comment thread packages/agent-core/src/agent.ts Fixed
Comment thread packages/session-file-system/src/index.ts Fixed
Comment thread packages/session-local-storage/src/index.ts Fixed
@nick-pape nick-pape force-pushed the codex/browser-agent-loop branch from 95360b1 to 2608506 Compare June 3, 2026 07:05
@nick-pape nick-pape marked this pull request as ready for review June 6, 2026 03:18
Copilot AI review requested due to automatic review settings June 6, 2026 03:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the ACP agent loop into a new runtime-neutral core package and introduces separate Node and browser “assembly” packages so browser builds can avoid leaking Node-only dependencies.

Changes:

  • Extracted the agent loop + core interfaces into @fledgling/agent-core, and rewired @fledgling/acp-agent to inject Node implementations.
  • Added session manager implementations for memory, localStorage, and filesystem, plus a Node MCP tool provider package.
  • Added a browser @fledgling/web-agent package with a webpack “fail on Node builtins” proof and a WebContainer-backed MCP workspace sidecar.

Reviewed changes

Copilot reviewed 65 out of 66 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
rush.json Registers new workspace packages (agent-core, session managers, MCP providers, web-agent, webcontainer sidecar).
packages/web-agent/webpack.config.cjs Webpack proof bundle targeting web with a plugin that throws on Node builtin imports.
packages/web-agent/tsconfig.json Browser TS config (DOM libs) emitting to lib/.
packages/web-agent/src/webpack-entry.ts Webpack entry that re-exports the public web-agent surface.
packages/web-agent/src/tool-provider.ts Browser MCP tool provider wiring via in-memory transport sidecar.
packages/web-agent/src/index.ts Web-agent public exports (core + sidecar + wiring helpers).
packages/web-agent/src/dependencies.ts Browser dependency assembly (localStorage session manager + sidecar tool provider + injected model runner).
packages/web-agent/package.json Web-agent package scripts + deps (including webpack bundle script).
packages/web-agent/eslint.config.cjs ESLint config via repo rig.
packages/web-agent/config/rig.json Heft rig configuration for web-agent.
packages/tools-mcp-node/vitest.config.ts Vitest config for tools-mcp-node.
packages/tools-mcp-node/tsconfig.json TS config for tools-mcp-node.
packages/tools-mcp-node/src/index.ts Node MCP tool provider implementation (stdio/http/sse + first-party workspace).
packages/tools-mcp-node/src/config.ts Filesystem-backed config loader for MCP server config.
packages/tools-mcp-node/src/config.test.ts Tests for MCP config loading.
packages/tools-mcp-node/package.json Package definition for Node MCP tool provider.
packages/tools-mcp-node/eslint.config.cjs ESLint config via repo rig.
packages/tools-mcp-node/config/rig.json Heft rig configuration for tools-mcp-node.
packages/session-memory/vitest.config.ts Vitest config for session-memory.
packages/session-memory/tsconfig.json TS config for session-memory.
packages/session-memory/src/session-memory.test.ts Tests for in-memory session event persistence.
packages/session-memory/src/index.ts In-memory ISessionManager implementation using Web Crypto IDs.
packages/session-memory/package.json Package definition for session-memory.
packages/session-memory/eslint.config.cjs ESLint config via repo rig.
packages/session-memory/config/rig.json Heft rig configuration for session-memory.
packages/session-local-storage/vitest.config.ts Vitest config for session-local-storage.
packages/session-local-storage/tsconfig.json Browser TS config (DOM libs) for local-storage session manager.
packages/session-local-storage/src/session-local-storage.test.ts Tests for localStorage session persistence and key prefix isolation.
packages/session-local-storage/src/index.ts localStorage-backed ISessionManager implementation.
packages/session-local-storage/package.json Package definition for session-local-storage.
packages/session-local-storage/eslint.config.cjs ESLint config via repo rig.
packages/session-local-storage/config/rig.json Heft rig configuration for session-local-storage.
packages/session-file-system/vitest.config.ts Vitest config for session-file-system.
packages/session-file-system/tsconfig.json TS config for session-file-system.
packages/session-file-system/src/session-file-system.test.ts Tests for filesystem JSONL session persistence.
packages/session-file-system/src/index.ts Filesystem JSONL ISessionManager implementation (Node).
packages/session-file-system/package.json Package definition for session-file-system.
packages/session-file-system/eslint.config.cjs ESLint config via repo rig.
packages/session-file-system/config/rig.json Heft rig configuration for session-file-system.
packages/mcp-workspace-webcontainer/vitest.config.ts Vitest config for webcontainer workspace sidecar package.
packages/mcp-workspace-webcontainer/tsconfig.json Browser TS config (DOM libs) for webcontainer sidecar package.
packages/mcp-workspace-webcontainer/src/sidecar.ts In-memory MCP server exposing workspace tools (read/write/list/search/run).
packages/mcp-workspace-webcontainer/src/runtime.ts WebContainer workspace runtime implementation used by sidecar tools.
packages/mcp-workspace-webcontainer/src/runtime.test.ts Tests for path normalization + search behavior in the runtime.
packages/mcp-workspace-webcontainer/src/index.ts Public exports for runtime + sidecar.
packages/mcp-workspace-webcontainer/package.json Package definition for webcontainer workspace sidecar.
packages/mcp-workspace-webcontainer/eslint.config.cjs ESLint config via repo rig.
packages/mcp-workspace-webcontainer/config/rig.json Heft rig configuration for webcontainer sidecar.
packages/agent-core/vitest.config.ts Vitest config for agent-core.
packages/agent-core/tsconfig.json TS config for agent-core.
packages/agent-core/src/session-cleanup.ts Browser-safe session cleanup utilities + client close helper.
packages/agent-core/src/prompt-errors.ts Prompt error normalization + sanitization/redaction utilities.
packages/agent-core/src/prompt-errors.test.ts Tests for error sanitization/redaction behavior.
packages/agent-core/src/prompt-content.ts Prompt/message/tool output flattening helpers + context-hint extraction.
packages/agent-core/src/interfaces.ts Core injected interfaces (ISessionManager, IToolProvider, IModelTurnRunner, logger types, etc.).
packages/agent-core/src/index.ts Barrel exports for agent-core.
packages/agent-core/src/agent.ts Extracted runtime-neutral ACP agent loop (FledglingAgent) using injected deps.
packages/agent-core/package.json Package definition for agent-core.
packages/agent-core/eslint.config.cjs ESLint config via repo rig.
packages/agent-core/config/rig.json Heft rig configuration for agent-core.
packages/acp-agent/src/index.ts Node entrypoint updated to construct FledglingAgent with default injected deps.
packages/acp-agent/src/agent.ts Node assembly updated to re-export core + provide Node default deps (FS sessions, Node MCP tools, OpenAI runner).
packages/acp-agent/src/agent-session-lifecycle.test.ts Tests updated for injected dependencies + filesystem session manager.
packages/acp-agent/src/agent-prompt-cancellation.test.ts Tests updated for injected dependencies + filesystem session manager.
packages/acp-agent/package.json Adds deps on new packages (agent-core/session-file-system/tools-mcp-node).
common/config/rush/pnpm-lock.yaml Lockfile updates reflecting added workspaces and dependencies.
Files not reviewed (1)
  • common/config/rush/pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/web-agent/src/tool-provider.ts Outdated
Comment thread packages/session-local-storage/src/index.ts
Comment thread packages/tools-mcp-node/src/index.ts
Comment thread packages/tools-mcp-node/src/index.ts
Comment thread packages/mcp-workspace-webcontainer/src/runtime.ts Outdated
Comment thread packages/acp-agent/package.json
Comment thread packages/web-agent/package.json

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 67 out of 68 changed files in this pull request and generated 5 comments.

Files not reviewed (1)
  • common/config/rush/pnpm-lock.yaml: Language not supported

Comment thread packages/web-agent/src/tool-provider.ts
Comment thread packages/tools-mcp-node/src/config.test.ts
Comment thread packages/mcp-workspace-webcontainer/src/runtime.ts
Comment thread packages/session-memory/src/index.ts
Comment thread packages/session-local-storage/src/index.ts
@nick-pape nick-pape merged commit f264e50 into main Jun 9, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extract browser-safe agent core and add web-agent webpack proof

3 participants