@aion0/forge 0.6.1 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/.forge/mcp.json +8 -0
  2. package/.forge/worktrees/pipeline-0a33c50d/lib/help-docs/01-settings.md +5 -5
  3. package/.forge/worktrees/pipeline-0a33c50d/lib/help-docs/07-projects.md +1 -1
  4. package/.forge/worktrees/pipeline-2ba01c10/lib/help-docs/01-settings.md +5 -5
  5. package/.forge/worktrees/pipeline-2ba01c10/lib/help-docs/07-projects.md +1 -1
  6. package/.forge/worktrees/pipeline-3156a8b3/lib/help-docs/01-settings.md +5 -5
  7. package/.forge/worktrees/pipeline-3156a8b3/lib/help-docs/07-projects.md +1 -1
  8. package/.forge/worktrees/pipeline-316c6574/lib/help-docs/01-settings.md +5 -5
  9. package/.forge/worktrees/pipeline-316c6574/lib/help-docs/07-projects.md +1 -1
  10. package/.forge/worktrees/pipeline-44a94121/lib/help-docs/01-settings.md +5 -5
  11. package/.forge/worktrees/pipeline-44a94121/lib/help-docs/07-projects.md +1 -1
  12. package/.forge/worktrees/pipeline-4dd8dc2d/lib/help-docs/01-settings.md +5 -5
  13. package/.forge/worktrees/pipeline-4dd8dc2d/lib/help-docs/07-projects.md +1 -1
  14. package/.forge/worktrees/pipeline-d1757a50/lib/help-docs/01-settings.md +5 -5
  15. package/.forge/worktrees/pipeline-d1757a50/lib/help-docs/07-projects.md +1 -1
  16. package/.forge/worktrees/pipeline-d59c2fe2/lib/help-docs/01-settings.md +5 -5
  17. package/.forge/worktrees/pipeline-d59c2fe2/lib/help-docs/07-projects.md +1 -1
  18. package/.forge/worktrees/pipeline-d6a6ef23/lib/help-docs/01-settings.md +5 -5
  19. package/.forge/worktrees/pipeline-d6a6ef23/lib/help-docs/07-projects.md +1 -1
  20. package/.forge/worktrees/pipeline-e7f78b7a/lib/help-docs/01-settings.md +5 -5
  21. package/.forge/worktrees/pipeline-e7f78b7a/lib/help-docs/07-projects.md +1 -1
  22. package/.forge/worktrees/pipeline-e97c13c7/lib/help-docs/01-settings.md +5 -5
  23. package/.forge/worktrees/pipeline-e97c13c7/lib/help-docs/07-projects.md +1 -1
  24. package/.forge/worktrees/pipeline-ecd7cb0f/lib/help-docs/01-settings.md +5 -5
  25. package/.forge/worktrees/pipeline-ecd7cb0f/lib/help-docs/07-projects.md +1 -1
  26. package/CLAUDE.md +2 -2
  27. package/RELEASE_NOTES.md +101 -5
  28. package/app/api/auth/check/route.ts +18 -0
  29. package/app/api/browser-bridge/route.ts +70 -0
  30. package/app/api/chat/sessions/[id]/events/route.ts +17 -0
  31. package/app/api/chat/sessions/[id]/fork/route.ts +15 -0
  32. package/app/api/chat/sessions/[id]/messages/route.ts +21 -0
  33. package/app/api/chat/sessions/[id]/route.ts +23 -0
  34. package/app/api/chat/sessions/route.ts +12 -0
  35. package/app/api/chat/temper-ping/route.ts +18 -0
  36. package/app/api/chat-proxy/[...path]/route.ts +83 -0
  37. package/app/api/connector-tool/route.ts +38 -0
  38. package/app/api/connectors/[id]/settings/route.ts +112 -0
  39. package/app/api/connectors/route.ts +108 -0
  40. package/app/api/health/tools/route.ts +14 -0
  41. package/app/api/issue-scanner-gitlab/route.ts +95 -0
  42. package/app/api/jobs/[id]/reset_dedup/route.ts +15 -0
  43. package/app/api/jobs/[id]/route.ts +31 -0
  44. package/app/api/jobs/[id]/run/route.ts +44 -0
  45. package/app/api/jobs/[id]/runs/[runId]/route.ts +15 -0
  46. package/app/api/jobs/[id]/runs/route.ts +15 -0
  47. package/app/api/jobs/preview/route.ts +193 -0
  48. package/app/api/jobs/route.ts +36 -0
  49. package/app/api/notify/test/route.ts +39 -7
  50. package/app/api/pipelines/[id]/route.ts +10 -1
  51. package/app/api/pipelines/route.ts +16 -2
  52. package/app/api/plugins/route.ts +40 -8
  53. package/app/api/project-sessions/route.ts +50 -10
  54. package/app/api/settings/route.ts +13 -0
  55. package/app/chat/page.tsx +531 -0
  56. package/bin/forge-server.mjs +3 -1
  57. package/cli/chat.ts +283 -0
  58. package/cli/jobs.ts +176 -0
  59. package/cli/mw.ts +28 -1
  60. package/cli/worktree.ts +245 -0
  61. package/components/ConnectorsPanel.tsx +275 -0
  62. package/components/Dashboard.tsx +90 -37
  63. package/components/JobsView.tsx +361 -0
  64. package/components/LogViewer.tsx +12 -2
  65. package/components/PipelineView.tsx +275 -56
  66. package/components/PluginsPanel.tsx +3 -1
  67. package/components/SettingsModal.tsx +229 -40
  68. package/components/SkillsPanel.tsx +12 -4
  69. package/components/TerminalLauncher.tsx +3 -1
  70. package/components/WebTerminal.tsx +32 -9
  71. package/components/WorkspaceView.tsx +18 -10
  72. package/docs/Connector-DeclarativeExtract-Handoff.md +471 -0
  73. package/docs/Connector-DeclarativeExtract-Spec.md +364 -0
  74. package/docs/Implementation-Plan-Browser-Agent.md +487 -0
  75. package/docs/Jobs-Design.md +240 -0
  76. package/docs/LOCAL-DEPLOY.md +3 -3
  77. package/docs/RFC-Browser-Connectors.md +509 -0
  78. package/lib/agents/index.ts +44 -6
  79. package/lib/agents/types.ts +1 -1
  80. package/lib/browser-bridge-standalone.ts +317 -0
  81. package/lib/builtin-plugins/github-api.yaml +93 -0
  82. package/lib/builtin-plugins/gitlab.yaml +860 -0
  83. package/lib/builtin-plugins/mantis.probe.js +176 -0
  84. package/lib/builtin-plugins/mantis.yaml +964 -0
  85. package/lib/builtin-plugins/pmdb.yaml +178 -0
  86. package/lib/builtin-plugins/teams.yaml +913 -0
  87. package/lib/chat/__test__/smoke.ts +30 -0
  88. package/lib/chat/agent-loop.ts +523 -0
  89. package/lib/chat/bridge-client.ts +59 -0
  90. package/lib/chat/llm/anthropic.ts +99 -0
  91. package/lib/chat/llm/index.ts +20 -0
  92. package/lib/chat/llm/openai.ts +215 -0
  93. package/lib/chat/llm/types.ts +42 -0
  94. package/lib/chat/local-memory.ts +300 -0
  95. package/lib/chat/memory-store.ts +87 -0
  96. package/lib/chat/memory-tools.ts +157 -0
  97. package/lib/chat/protocols/http.ts +118 -0
  98. package/lib/chat/protocols/shell.ts +101 -0
  99. package/lib/chat/proxy.ts +51 -0
  100. package/lib/chat/session-store.ts +272 -0
  101. package/lib/chat/telegram-bridge.ts +276 -0
  102. package/lib/chat/temper.ts +281 -0
  103. package/lib/chat/tool-dispatcher.ts +190 -0
  104. package/lib/chat/types.ts +50 -0
  105. package/lib/chat-standalone.ts +286 -0
  106. package/lib/crypto.ts +1 -1
  107. package/lib/health.ts +131 -0
  108. package/lib/help-docs/00-overview.md +2 -1
  109. package/lib/help-docs/01-settings.md +46 -25
  110. package/lib/help-docs/07-projects.md +1 -1
  111. package/lib/help-docs/10-troubleshooting.md +10 -2
  112. package/lib/help-docs/16-gitlab-autofix.md +114 -0
  113. package/lib/help-docs/17-connectors.md +322 -0
  114. package/lib/help-docs/18-chrome-mcp.md +134 -0
  115. package/lib/help-docs/19-jobs.md +140 -0
  116. package/lib/help-docs/20-mantis-bug-fix.md +115 -0
  117. package/lib/help-docs/CLAUDE.md +10 -0
  118. package/lib/init.ts +137 -50
  119. package/lib/iso-time.ts +30 -0
  120. package/lib/issue-scanner-gitlab.ts +281 -0
  121. package/lib/jobs/dispatcher.ts +217 -0
  122. package/lib/jobs/scheduler.ts +334 -0
  123. package/lib/jobs/store.ts +319 -0
  124. package/lib/jobs/types.ts +117 -0
  125. package/lib/pipeline-scheduler.ts +1 -6
  126. package/lib/pipeline.ts +790 -10
  127. package/lib/plugins/registry.ts +133 -8
  128. package/lib/plugins/templates.ts +83 -0
  129. package/lib/plugins/types.ts +140 -1
  130. package/lib/session-watcher.ts +36 -10
  131. package/lib/settings.ts +65 -33
  132. package/lib/skills.ts +3 -1
  133. package/lib/task-manager.ts +50 -22
  134. package/lib/telegram-bot.ts +71 -0
  135. package/lib/terminal-standalone.ts +58 -36
  136. package/lib/workspace/orchestrator.ts +1 -0
  137. package/middleware.ts +10 -0
  138. package/package.json +3 -2
  139. package/scripts/bench/README.md +1 -1
  140. package/scripts/bench/tasks/01-text-utils/validator.sh +1 -1
  141. package/scripts/bench/tasks/02-pagination/setup.sh +1 -1
  142. package/scripts/bench/tasks/02-pagination/validator.sh +1 -1
  143. package/scripts/bench/tasks/03-bug-fix/setup.sh +1 -1
  144. package/scripts/bench/tasks/03-bug-fix/validator.sh +1 -1
  145. package/src/core/db/database.ts +21 -12
@@ -0,0 +1,487 @@
1
+ # Browser Agent — Implementation Plan
2
+
3
+ > **Status**: Ready to implement.
4
+ > **Date**: 2026-05-16
5
+ > **Owner**: aion0
6
+ > **Related**:
7
+ > - `docs/RFC-Browser-Connectors.md` — detailed connector design (this is the abridged action plan)
8
+ > - `../temper` — memory service (existing)
9
+ > - Forge main repo (this) — orchestration platform (existing)
10
+
11
+ ## TL;DR
12
+
13
+ Build a **Chrome extension** that does two things:
14
+
15
+ 1. **Chat UI** — daily-driver enterprise AI assistant with Temper-backed memory
16
+ 2. **Site connectors** — installable per-company adapters that re-use the user's browser sessions to read/write internal systems (Mantis, Teams, JIRA, internal CRM, …)
17
+
18
+ The extension is **independent of Forge** — composable, mutually enhancing. Forge stays as today (`localhost:8403` web UI) and is invoked when long tasks / code work are needed; the extension handles day-to-day chat + system queries.
19
+
20
+ ## Architecture (Final)
21
+
22
+ ```
23
+ ┌──────────────────────────────────┐
24
+ │ Browser (user's daily Chrome) │
25
+ │ ┌──────────────────────────────┐ │
26
+ │ │ Forge Browser Extension │ │
27
+ │ │ │ │
28
+ │ │ ┌────────────────────────┐ │ │
29
+ │ │ │ Chat side-panel UI │ │ │
30
+ │ │ │ (React) │ │ │
31
+ │ │ └────────────────────────┘ │ │
32
+ │ │ │ │
33
+ │ │ ┌────────────────────────┐ │ │
34
+ │ │ │ Agent loop │ │ │
35
+ │ │ │ (LLM + tool calling) │ │ │
36
+ │ │ └────────────────────────┘ │ │
37
+ │ │ │ │
38
+ │ │ ┌────────────────────────┐ │ │
39
+ │ │ │ Connector marketplace │ │ │
40
+ │ │ │ (install/uninstall) │ │ │
41
+ │ │ │ • Mantis │ │ │
42
+ │ │ │ • Teams │ │ │
43
+ │ │ │ • <yours> │ │ │
44
+ │ │ └────────────────────────┘ │ │
45
+ │ └─┬──────────┬─────────┬───────┘ │
46
+ └───┼──────────┼─────────┼─────────┘
47
+ │ │ │
48
+ HTTP REST │ │ HTTP │ HTTP (optional)
49
+ ▼ ▼ ▼
50
+ ┌─────────────┐ ┌──────┐ ┌──────────────┐
51
+ │ Temper │ │ LLM │ │ Forge │
52
+ │ (memory) │ │ API │ │ (when need │
53
+ │ existing │ │ │ │ pipelines/ │
54
+ │ │ │ │ │ long tasks) │
55
+ └─────────────┘ └──────┘ └──────────────┘
56
+ ```
57
+
58
+ **Three products with clear, asymmetric roles** (not three equal peers — each plays a distinct part):
59
+
60
+ | Product | Status | Role | Required when |
61
+ |---|---|---|---|
62
+ | **Browser Extension** | 🆕 to build | **Agent entry point** — main user-facing surface. Connector hub for company internal + external SaaS systems. | Always (the agent's "face") |
63
+ | **Forge** | ✅ existing | **Agent backend + dev platform** — pipelines, crafts, workspaces, code work, long-running tasks | When you need orchestration, code work, scheduled flows (not always for pure chat) |
64
+ | **Temper** | ✅ existing | **Agent memory** — supplements Forge's memory when agent chat is involved | Only when you have an agent that needs cross-session memory. Forge-only (no chat agent) usage doesn't need it. |
65
+
66
+ ### Reading the trinity
67
+
68
+ - **Extension** is the most user-visible. If a non-technical user only sees one thing, it's the extension.
69
+ - **Forge** sits behind the extension as the backend / dev platform. Power users open Forge UI directly when they need pipeline editing, multi-agent workspaces, or code work.
70
+ - **Temper** is purely a memory backplane. Optional. **Forge without an agent doesn't need Temper** — you can run pipelines / crafts / Forge UI fine without any memory service. Temper kicks in once a conversational agent (e.g. the extension's chat) needs to remember things across sessions.
71
+
72
+ ### Dependency direction
73
+
74
+ ```
75
+ Browser Extension ───depends on───▶ Forge (when long task)
76
+ ───depends on───▶ Temper (for memory)
77
+ ───depends on───▶ LLM API (always)
78
+
79
+ Forge ──optionally uses──▶ Temper (only when an agent runs)
80
+
81
+ Temper stands alone, dependent on nothing else
82
+ ```
83
+
84
+ **Nobody is a peer of "depends on me"** — Temper is the deepest, Forge is middle, Extension is the apex / user-facing layer.
85
+
86
+ ## Component Responsibilities
87
+
88
+ ### Browser Extension (new)
89
+
90
+ | Responsibility | How |
91
+ |---|---|
92
+ | Chat UI | React in side panel (`chrome.sidePanel`) |
93
+ | Agent loop | LLM tool-use loop (lightweight — direct API calls, no pi-coding-agent) |
94
+ | Memory | HTTP client → Temper REST API |
95
+ | Site access | Per-domain content scripts (connectors) + `fetch` with credentials |
96
+ | Connector management | Marketplace UI in extension popup (install/remove/update) |
97
+ | Forge bridge (optional) | `fetch('http://localhost:8403/api/…')` when user wants pipeline / craft / long task |
98
+
99
+ **Does NOT do:**
100
+ - Code editing / file ops (Forge job)
101
+ - tmux / terminal (Forge job)
102
+ - Long-running cron / scheduled tasks (Forge job)
103
+ - Cross-machine sync (Temper job)
104
+
105
+ ### Temper (existing, no changes needed)
106
+
107
+ - HTTP REST memory API
108
+ - KV memory blocks (preferences, profile, current state)
109
+ - Graph episodes (third-party facts, recall over time)
110
+ - Multi-tenant, multi-user
111
+
112
+ Extension is a Temper client; nothing new to build on Temper side for v1.
113
+
114
+ ### Forge (existing, minor additions later)
115
+
116
+ - Web UI for pipelines / crafts / workspace (as today)
117
+ - Backend services (terminal, workspace, telegram, MCP)
118
+ - Extension can call Forge's HTTP API when it needs heavy orchestration
119
+ - **No required changes for extension v1** — composable, the extension works without Forge
120
+
121
+ Later (post-v1):
122
+ - Forge "Browser Bridge" service for extension-to-Forge MCP bridging (per RFC)
123
+ - Forge UI showing connected extensions / paired devices
124
+
125
+ ## Connector Model
126
+
127
+ Connectors are **installable per-company**:
128
+ - Each company has their own internal systems
129
+ - A connector is a JS module: `id`, `matches: [urlPattern]`, `tools: {...}`, optional `healthCheck`
130
+ - Installable from a public registry (`forge-browser-connectors` GitHub repo, mirrors `forge-crafts`)
131
+ - Or sideload-able from a company's private registry (URL configurable in extension settings)
132
+
133
+ **v1 ships with empty marketplace.** Users add their own (or pick from public ones once registry exists).
134
+
135
+ ## Tech Stack
136
+
137
+ | Layer | Choice | Why |
138
+ |---|---|---|
139
+ | Extension manifest | MV3 | Chrome's mandatory modern format |
140
+ | Background | Service Worker | Required for MV3; OK because we don't need long-lived processes (the agent loop is request/response) |
141
+ | UI framework | React 18 + TypeScript + Vite | Match Forge stack; Vite for fast SPA build |
142
+ | State | Zustand (or jotai) | Lightweight; React Context for connector registry |
143
+ | LLM SDK | `@anthropic-ai/sdk` + optional OpenAI | User config; Anthropic primary |
144
+ | Memory client | Hand-rolled REST (or generated OpenAPI client) → Temper | Temper has stable API |
145
+ | Connector SDK | Local TS package | Defines `defineBrowserConnector({...})` |
146
+ | Bundler | Vite + `@crxjs/vite-plugin` | Standard MV3 toolchain |
147
+ | Package layout | Monorepo? Or single repo? | Decision: single repo `forge-browser-extension`, with `packages/sdk` workspace for the connector SDK to be published to npm |
148
+
149
+ ## Phase Plan (4 weeks → MVP)
150
+
151
+ ### Week 1: Skeleton
152
+
153
+ - New repo: `forge-browser-extension`
154
+ - MV3 manifest, side panel, background SW, content script
155
+ - Chat UI shell (input → static placeholder response)
156
+ - Settings page: Temper URL, LLM API key
157
+ - Build pipeline (Vite + crxjs) producing `dist/` loadable as unpacked extension
158
+ - **Deliverable**: extension loads in Chrome, side panel opens, you can type something + see your own message echoed back
159
+
160
+ ### Week 2: Agent + Memory
161
+
162
+ - Wire LLM API (Anthropic streaming)
163
+ - Implement minimal tool-use loop (5-10 hand-coded tools, no connectors yet)
164
+ - Temper memory:
165
+ - on session boot: load relevant memory blocks
166
+ - after every turn: extract & write back any "fact about user" → memory blocks
167
+ - episodes: write per-session to Temper graph
168
+ - **Deliverable**: chat with persistent memory; close Chrome, reopen, agent remembers what you told it last time
169
+
170
+ ### Week 3: Connector framework + first connector
171
+
172
+ - `@forge/browser-connector-sdk` (in `packages/sdk/`):
173
+ - `defineBrowserConnector({...})` factory
174
+ - `ctx.fetch / $ / $$ / waitFor / storage / log / AuthExpiredError`
175
+ - Connector loader in extension:
176
+ - Discover connectors in `chrome.storage` (installed list)
177
+ - On tab match, inject content script
178
+ - Register tools globally
179
+ - **Mantis connector** (first one, since you specifically mentioned it):
180
+ - Tier 1: `/api/rest/issues` with cookies
181
+ - Tier 2: scrape `view_all_bug_page.php`
182
+ - Tools: `mantis.list_my_bugs`, `mantis.view_bug`, `mantis.add_comment`
183
+ - **Deliverable**: extension chat can say "list my open Mantis bugs" → returns real data
184
+
185
+ ### Week 4: Marketplace + second connector
186
+
187
+ - Connector marketplace UI in extension popup
188
+ - `forge-browser-connectors` registry (GitHub repo, schema mirrors `forge-crafts`)
189
+ - Install / uninstall / update flows
190
+ - **Second connector** (pick one: Teams or your highest-value internal system)
191
+ - Connector health checks + auth-expired notification
192
+ - **Deliverable**: end-to-end real use; ready to use day-to-day on at least 2 systems
193
+
194
+ ### Beyond MVP
195
+
196
+ - Forge bridge (Phase 0-1 of RFC) — extension can call Forge MCP for heavy tasks
197
+ - More connectors
198
+ - Vision-tier fallback for awkward sites
199
+ - Possible: smith engine folded in as alternative agent loop
200
+
201
+ ## Code Locations
202
+
203
+ | Code | Repo | Path |
204
+ |---|---|---|
205
+ | Extension app | NEW `forge-browser-extension` | `src/` |
206
+ | Connector SDK | NEW `forge-browser-extension` | `packages/sdk/` |
207
+ | Connector registry index | NEW `forge-browser-connectors` (mirror `forge-crafts`) | `registry.json` + `<connector>/` |
208
+ | Forge integration (later) | Existing Forge repo | `lib/browser-bridge-standalone.ts` (Phase 0+ per RFC) |
209
+ | Temper changes | None | N/A (use existing API) |
210
+
211
+ ## Decisions Resolved
212
+
213
+ | Question | Resolution |
214
+ |---|---|
215
+ | Bundle backend into extension? | No — backend stays in Forge node process; extension is UI + connectors only |
216
+ | Run browser in Docker? | No — re-use user's session is the whole point |
217
+ | Connectors per-company or generic? | Per-company, installable via marketplace, with public + private registries |
218
+ | Forge required for extension to work? | No — composable. Extension works standalone for chat + connectors |
219
+ | Smith engine folded into extension? | Deferred — start with simpler hand-rolled agent loop, fold smith later if needed |
220
+ | MV3 service worker concerns? | Acceptable — chat is request/response, no long-lived state needed. Agent loop is per-message |
221
+ | Chat UI location | Side panel (Chrome 117+). Popup for marketplace + settings |
222
+
223
+ ## Open Questions
224
+
225
+ | Question | Need to answer by |
226
+ |---|---|
227
+ | Which LLM as default? Anthropic only, or also support OpenAI / local? | Week 1 (config) |
228
+ | Memory granularity: every turn → memory? Or only on important facts? | Week 2 |
229
+ | Connector code signing / supply-chain security | Week 3 (when registry goes public) |
230
+ | Public connector registry URL — host on github.com/aiwatching/forge-browser-connectors? | Week 3 |
231
+ | Auth expiry UX — toast? Inline chat message? Auto-resume? | Week 3 |
232
+ | Chrome Web Store publication strategy | Week 4 (or unsigned sideload for first internal users) |
233
+
234
+ ## Tomorrow's First Concrete Step
235
+
236
+ ```bash
237
+ mkdir -p ~/IdeaProjects/forge-browser-extension
238
+ cd ~/IdeaProjects/forge-browser-extension
239
+ git init
240
+ gh repo create aiwatching/forge-browser-extension --private --source . --remote origin
241
+
242
+ # Scaffold:
243
+ pnpm init
244
+ pnpm add -D vite @crxjs/vite-plugin @types/chrome typescript react @types/react @types/react-dom
245
+ pnpm add @anthropic-ai/sdk zustand
246
+
247
+ # Files to create on day 1:
248
+ # manifest.json (MV3)
249
+ # vite.config.ts (crxjs preset)
250
+ # src/background.ts (SW skeleton)
251
+ # src/sidepanel/index.html + sidepanel.tsx (chat UI shell)
252
+ # src/popup/index.html + popup.tsx (settings + marketplace placeholder)
253
+ # src/content/index.ts (per-tab content script bootstrap)
254
+ ```
255
+
256
+ Aim by end of day 1: load unpacked in Chrome, click extension icon → side panel opens with React app saying "Hello".
257
+
258
+ ## Success Criteria (4 weeks)
259
+
260
+ A user can:
261
+ 1. Install the extension once
262
+ 2. Configure Temper URL + LLM API key once
263
+ 3. Open the side panel from any tab
264
+ 4. Type: "list my open Mantis bugs"
265
+ 5. See real bug data from their Mantis without re-authenticating
266
+ 6. Continue: "summarise the top 3 by severity" — agent uses LLM
267
+ 7. Close Chrome, come back tomorrow — agent remembers user preferences
268
+ 8. Install a second connector from the marketplace with one click
269
+
270
+ If all 8 work end-to-end, MVP is done.
271
+
272
+ ## Out of Scope (defer)
273
+
274
+ - Mobile / Safari / Firefox
275
+ - Centralized headless browser farm
276
+ - Forge UI inside extension (Forge stays at `localhost:8403`)
277
+ - Connector code signing infrastructure
278
+ - Multi-user / SSO at extension level (Temper handles user separation)
279
+ - Computer Use vision-tier fallback
280
+ - Smith engine integration
281
+
282
+ ## ADR — 2026-05-16: Connectors are Forge plugins, not extension code
283
+
284
+ After initial RFC, decided to **move connector implementations out of the
285
+ extension and into Forge as plugins** (the existing `lib/builtin-plugins/*`
286
+ system: `docker`, `jenkins`, `slack`, `llm-vision`, …).
287
+
288
+ ### Why plugins not crafts
289
+ - Crafts are per-project + UI-heavy. Connectors are system-level, stateless,
290
+ pure capabilities.
291
+ - Plugins already have manifest/marketplace machinery in Forge.
292
+ - Plugins are already the "system capability" abstraction agents call.
293
+
294
+ ### Why not keep them in extension
295
+ - Extension stays thin (chat UI + memory client + thin RPC to Forge).
296
+ - Connector marketplace = Forge plugin marketplace (don't double-build).
297
+ - Adding a connector = adding a YAML to Forge. No JS compiled into extension.
298
+
299
+ ### Plugin execution modes (new addition to Forge plugin schema)
300
+ ```yaml
301
+ mode: server-side # default; Forge backend calls external API
302
+ mode: browser-side # Forge dispatches to extension which fetches via tab cookies
303
+ mode: hybrid # per-tool: some server, some browser
304
+ ```
305
+
306
+ ### Data flow (Mantis, browser-side mode)
307
+ ```
308
+ Extension chat → POST /api/plugins/mantis/invoke
309
+ ← Forge sees mode=browser-side → WS dispatch to extension
310
+ ← Extension runs content-script fetch in mantis tab w/ cookies
311
+ ← Mantis JSON → back up the chain → LLM → user
312
+ ```
313
+
314
+ ### Dependency revision
315
+ With this model, the extension's connector capabilities **require Forge**.
316
+ Pure-chat mode (no connectors) still works without Forge. The earlier
317
+ "all composable, all standalone" framing was too theoretical — for any
318
+ real enterprise use, the three-product stack is needed together.
319
+
320
+ ### Forge changes required (small but real)
321
+ 1. Plugin manifest accepts `mode: browser-side | server-side | hybrid`
322
+ 2. Plugin manifest accepts `category: connector | pipeline-node | mcp-server | tool | other` — marketplace + extension filter on this
323
+ 3. Plugin manifest accepts a `connectors: [...]` array (default 1:1 plugin↔connector; 1:N as escape hatch for same-vendor suites with shared auth — see RFC "Packaging in Forge")
324
+ 4. New plugin executor: when `mode=browser-side`, dispatch to extension via WS
325
+ 5. WebSocket back-channel: extension ↔ Forge persistent connection
326
+ 6. Extension capability registry: Forge tracks "which extension has which tabs matching which plugins"
327
+ 7. Plugin settings UI: show extension connectivity state + paired connectors
328
+
329
+ ### Defaults shipped with Forge
330
+ - `gmail` (server-side, OAuth) — built-in
331
+ - `teams` (browser-side, MSAL token extraction) — built-in
332
+ - `jira` (hybrid — cloud OAuth, self-hosted cookie) — built-in
333
+ - `github` (server-side, PAT) — built-in
334
+ - `gitlab` (server-side, PAT) — built-in
335
+ - User-installed: `mantis` and others from plugin marketplace
336
+
337
+ ### What this changes in the 4-week plan
338
+ - **Week 3 deliverable changes**: instead of "connector SDK + first connector in extension", it becomes "first browser-side plugin in Forge + extension dispatch mechanism".
339
+ - Extension code becomes thinner — no `defineBrowserConnector` SDK in extension itself; that lives as a Forge plugin author guide.
340
+ - `forge-browser-connectors` registry → **not needed**; reuse Forge plugin marketplace.
341
+
342
+ ## ADR — 2026-05-16: Data architecture (what goes into Temper)
343
+
344
+ Key rule: **opportunistic memory, not bulk mirroring.** Temper is the
345
+ agent's *memory*, not a data lake. Mantis / Teams / Gmail stay as the
346
+ sources of truth; we don't sync everything wholesale.
347
+
348
+ ### Data categories
349
+
350
+ | Category | Example | Storage | Why |
351
+ |---|---|---|---|
352
+ | Conversation | "user asked X, agent replied Y" | Temper **episodes** (graph) | Core memory asset |
353
+ | First-person facts | "user prefers concise answers", "user's team lead is Alice" | Temper **memory blocks** (KV) | Graphiti not great at these |
354
+ | Agent-processed content | bug #142 full text, meeting notes | Temper **wiki** (new) | RAG / long-form retrieval |
355
+ | Tool-call events | "called mantis.list_my_bugs, got 12 results" | Temper episode | Agent's own experience log |
356
+ | Transient search results | current Mantis result page, Teams query | Extension `chrome.storage` (TTL min) | Source is authoritative, refetch cheap |
357
+ | Files / code | git diff, file tree | NOT Temper — Forge workspace owns | Different concern |
358
+ | Credentials / cookies | tokens, passwords | NEVER STORED | Security red line |
359
+
360
+ ### Three-tier data flow
361
+
362
+ ```
363
+ Source system (Mantis / Teams / Gmail / GitHub) ← single source of truth
364
+ │ fetch on demand only
365
+
366
+ Extension chrome.storage / IndexedDB (TTL minutes) ← per-session cache
367
+ │ promote to persistent memory when:
368
+ │ - agent actually used the data (auto)
369
+ │ - user said "remember this" (explicit)
370
+ │ - agent flagged as significant (auto, heuristic)
371
+
372
+ Temper (cross-session, cross-device, cross-agent)
373
+ ├── episodes (graph) — chat + tool calls + agent events
374
+ ├── memory blocks (KV) — first-person facts
375
+ ├── wiki — agent-processed long-form content
376
+ └── postgres (Temper internal) — user/auth/meta
377
+ ```
378
+
379
+ ### Write strategy (Week 2 implementation)
380
+
381
+ Every chat turn end, async write a batch to Temper:
382
+
383
+ 1. **Episode for the conversation turn** — always (cheap, builds context)
384
+ 2. **Episode per tool call** — always (summary, no raw secrets)
385
+ 3. **Memory blocks** for first-person facts extracted by LLM from turn
386
+ 4. **Wiki entry** when:
387
+ - User says "记住 / remember this / save this"
388
+ - Agent processes a specific document/ticket end-to-end (auto)
389
+ - Agent generates a long-form artifact (status report, summary)
390
+
391
+ Sensitive fields (tokens, cookies, password-shaped strings) sanitized
392
+ before any Temper write.
393
+
394
+ ### Read strategy (every turn start)
395
+
396
+ 1. Episode semantic search by user message → top N (~10)
397
+ 2. Load all memory blocks for current user
398
+ 3. Wiki keyword/semantic search → top 3
399
+ 4. Build LLM system context from above
400
+
401
+ ### What to NEVER do
402
+
403
+ - ❌ Background cron mirroring Mantis / Teams full content into Temper
404
+ - ❌ Storing raw tool-call JSON unfiltered (noise + secrets risk)
405
+ - ❌ Using Temper as BI / aggregation store — it's per-user agent memory
406
+ - ❌ Storing files / code / large binaries — that's Forge workspace's job
407
+
408
+ ### Wiki's specific role (new Temper primitive)
409
+
410
+ Wiki sits between KV (short, structured) and episodes (medium, eventful):
411
+
412
+ | Primitive | Length | Update freq | Retrieval | Example |
413
+ |---|---|---|---|---|
414
+ | KV blocks | sentence | low | by key | "team lead = Alice" |
415
+ | Episodes | paragraph | every turn | semantic recall | "5/16 fetched bug #142, user satisfied" |
416
+ | **Wiki** | document | when meaningful | full-text + semantic | "bug #142 full content + agent's deep analysis" |
417
+
418
+ Use wiki for:
419
+ - Specific ticket content the agent worked on (cached with backlink to source)
420
+ - "Save this Confluence page" requests
421
+ - Agent-generated reports / status updates / decision records
422
+ - Team-level SOPs and shared docs
423
+
424
+ ### Integration timeline
425
+
426
+ | Week | What |
427
+ |---|---|
428
+ | Week 2 | Episodes (chat + tool calls) + KV blocks (extracted facts) write/read on every turn |
429
+ | Week 3 | Wiki writes when agent processes connector content end-to-end |
430
+ | Week 4+ | Smart promotion (episode → wiki by access frequency / agent tags) |
431
+ | Later | Forge pipelines also write episodes — chat and task share one memory plane |
432
+
433
+ ### One-line principle
434
+
435
+ **Not "everything the connectors fetch goes to Temper" but "everything
436
+ the agent actually experiences goes to Temper".** Fetching is data
437
+ movement (don't auto-store); experiencing is agent memory (auto-store).
438
+
439
+ ## ADR — 2026-05-16: DOM extraction is the default execution path
440
+
441
+ Surfaced after testing Mantis: REST API returned 403 because MantisBT's
442
+ `/api/rest/*` requires an `Authorization` token, not a cookie. Same
443
+ applies to GitLab `/api/v4/*`, JIRA Server REST, Teams Graph, etc.
444
+
445
+ **Decision**: connector tools run via **DOM extraction through the
446
+ extension's Chrome MCP capabilities**, not REST API calls.
447
+
448
+ ### Why
449
+
450
+ If we route through REST, every connector requires the user to mint and
451
+ manage a per-system API token. That's exactly the friction the browser
452
+ extension model exists to remove. The whole product story is "use the
453
+ browser session you already have, no setup". DOM-first preserves that.
454
+
455
+ ### Implementation rules
456
+
457
+ - Tool descriptions describe **observable behavior** ("list bugs assigned
458
+ to me"), never URL paths.
459
+ - Extension's connector runtime navigates tabs and parses HTML — does NOT
460
+ call `/api/rest/*` or `/api/v4/*`.
461
+ - `ctx.fetch` is reserved for same-origin XHR endpoints the rendered page
462
+ itself uses (cookie-authenticated). Not for documented REST APIs.
463
+ - Token-based fallback (`api_token` setting) is **opt-in per connector**,
464
+ only when DOM extraction is genuinely unworkable (canvas SPAs etc.).
465
+ Off by default.
466
+
467
+ ### Cost we accept
468
+
469
+ - Selector maintenance when sites redesign — pin stable attributes
470
+ (`data-testid`, role-based queries, schema.org microdata).
471
+ - Slower (200ms-2s vs 50-500ms for REST) — acceptable for interactive use.
472
+ - Some pages need scrolling / interactions before all data is in DOM —
473
+ connector handlers wait for selectors and trigger interactions as needed.
474
+
475
+ ### What this changes
476
+
477
+ - RFC's three-tier model rewritten: DOM is Tier 1, vision is Tier 2,
478
+ optional user-provided REST token is Tier 3 (escape hatch).
479
+ - Connector examples updated (no more "Tier 1 REST → Tier 2 DOM" — flipped).
480
+ - Mantis + GitLab manifests reflect this in their descriptions.
481
+
482
+ ## Changelog
483
+
484
+ - **2026-05-16**: Initial plan
485
+ - **2026-05-16 (later)**: ADR — connectors live in Forge as plugins, not in extension. Major simplification.
486
+ - **2026-05-16 (later 2)**: ADR — data architecture: opportunistic memory not bulk mirroring; wiki for long-form agent-processed content.
487
+ - **2026-05-16 (later 3)**: ADR — DOM extraction is the default execution path, not REST. Token-based fallback is opt-in per connector.