agent-sphere / agent-sphere-copilot-widget
AGENTS.md78 starsChanged 18 days agoMITView on GitHub
Embeddable chat widget: Vite library build (IIFE) + its own REST/SSE timeline. Independent npm project; run commands in this directory. Build outputs: Verification: npm run typecheck + npm test. Current baseline: about 53 tests.
- Deletes or force-pushes
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 33,398 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository4 other files it gives its agents.
- AGENTS.mdAGENTS.md
- agent-sphere/AGENTS.mdAGENTS.md
- agent-sphere-chrome-extension/AGENTS.mdAGENTS.md
- agent-sphere-ui/AGENTS.mdAGENTS.md
The file
We split this AGENTS.md into the rules it gives an agent
5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 42
Every widget request sends X-Client-Surface: widget.
- Distinctive: line 49
Do not inline status strings or timing numbers in components/stream code.
- Very specific: line 53
Never copy node_modules or package-lock.json across machines/OSes: rollup platform optional dependencies cause Cannot find module …
- Distinctive: line 58
No third-party site brand/domain in code, comments, tests, or UI copy.
- Very specific: line 59
Keep /api and /stream proxy behavior aligned with the admin UI.
≈ “Common” is an estimate: at least 1 in 5 of the 43,423 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AgentSphere Copilot Widget
Embeddable chat widget: Vite library build (IIFE) + its own REST/SSE timeline. Independent npm project; run commands in this directory.
Commands and artifacts
npm run dev # :5173, /api proxied
npm run typecheck # tsc --noEmit
npm test # vitest run
npm run build # tsc --noEmit && vite build && vite build --config vite.auth.config.tsBuild outputs:
dist/agent-sphere-widget.jsdist/agent-sphere-auth.js(built withemptyOutDir:false; do not remove that setting)
Verification: npm run typecheck + npm test. Current baseline: about 53 tests.
Runtime shape
AgentSphereWidget.init({apiBase, provider, autoLogin, title})mounts into a shadow DOM.- CSS is injected as a Vite
?inlineimport. - OIDC:
?otc=→POST /auth/sso/exchange→ token stored atsessionStorage['agent-sphere-widget:agent-user']. autoLoginperforms a one-shotprompt=nonesilent probe.
Timeline and streaming
- Timeline:
GET /instance/sessions/{sid}/timelinewithbeforeSeq/afterSeq, limit 5–50. - Stream: SSE
/runtime/{sid}/stream. run_*,tool_call_*,clarification_*events trigger anafterSeqrefresh for authoritative merging.mergeTimelinededuplicates byseq; sub-agent placeholder rows useseq < 0.- Send:
POST /runtime/{sid}/chat→{runId}. - Stop:
POST /runtime/{sid}/stop. - Clarify:
POST /runtime/{sid}/run/{runId}/clarify. useTimelineStream.connect(sessionId, token)replaces stream state; run it in an effect keyed by the selected session id.
Session switches
agent_instance.allow_widget_sessiondefaults to false;allow_console_sessiondefaults to true.- Every widget request sends
X-Client-Surface: widget. - Frontend
src/instance.ts#allowsWidgetSessionaccepts only stricttrue. - Server
SessionSurfacePolicyis the strong constraint; frontend checks are UX only.
Constants and magic values
- Shared values live in
src/constants.ts:TIMING,RUN_STATE,TOOL_STATE,TODO_STATUS. - Do not inline status strings or timing numbers in components/stream code; use the constants.
Environment pitfalls
- Never copy
node_modulesorpackage-lock.jsonacross machines/OSes: rollup platform optional dependencies causeCannot find module @rollup/rollup-*. - Local reinstall:
rm -rf node_modules package-lock.json && npm i.
Hard rules
- No third-party site brand/domain in code, comments, tests, or UI copy.
- Keep
/apiand/streamproxy behavior aligned with the admin UI; do not remove SSE headers.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

