agentleFS
nullpointexception-inullpointexception-i/agent-sphere/agent-sphere-copilot-widget/AGENTS.md

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.

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
  1. Very specific:

    Every widget request sends X-Client-Surface: widget.

    line 42
  2. Distinctive:

    Do not inline status strings or timing numbers in components/stream code.

    line 49
  3. Very specific:

    Never copy node_modules or package-lock.json across machines/OSes: rollup platform optional dependencies cause Cannot find module …

    line 53
  4. Distinctive:

    No third-party site brand/domain in code, comments, tests, or UI copy.

    line 58
  5. Very specific:

    Keep /api and /stream proxy behavior aligned with the admin UI.

    line 59

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

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.ts

Build outputs:

  • dist/agent-sphere-widget.js
  • dist/agent-sphere-auth.js (built with emptyOutDir: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 ?inline import.
  • OIDC: ?otc= → POST /auth/sso/exchange → token stored at sessionStorage['agent-sphere-widget:agent-user'].
  • autoLogin performs a one-shot prompt=none silent probe.

Timeline and streaming

  • Timeline: GET /instance/sessions/{sid}/timeline with beforeSeq / afterSeq, limit 5–50.
  • Stream: SSE /runtime/{sid}/stream.
  • run_*, tool_call_*, clarification_* events trigger an afterSeq refresh for authoritative merging.
  • mergeTimeline deduplicates by seq; sub-agent placeholder rows use seq < 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_session defaults to false; allow_console_session defaults to true.
  • Every widget request sends X-Client-Surface: widget.
  • Frontend src/instance.ts#allowsWidgetSession accepts only strict true.
  • Server SessionSurfacePolicy is 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_modules or package-lock.json across machines/OSes: rollup platform optional dependencies cause Cannot 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 /api and /stream proxy behavior aligned with the admin UI; do not remove SSE headers.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.