ERPBridge SDK โ Agent Guide
This page mirrors the AGENTS.md from the ERPBridge SDK repository. It is the operating manual for AI agents making changes to the SDK. It is kept in sync with the repository and updated on every SDK release.
Project overviewโ
TypeScript client library for the ERPBridge server family: @erpbridge/sdk. Wraps @modelcontextprotocol/client (v2) plus typed REST wrappers (logs, metrics, health, cache, tool registry, invoke). Consumed by application and AI-agent developers embedding ERPBridge in their own products.
Development rulesโ
Rules for agents making changes to the SDK repository.
Plan firstโ
- Read the active plan before coding:
.agents/plans/Plan.md. Implement tasks in order and tick each checkbox as it completes. - Each plan task carries a
Verify:command โ the task is done only when that command is green. .agents/plans/Plan-auth.mdis historical; SDK auth work follows the active compatibility section in.agents/plans/Plan.md.- Open a plan (or extend it) for any work the plan doesn't cover.
Small commitsโ
- One plan task = one commit. Keep commits small and single-purpose; separate unrelated changes into their own commits.
- Use Conventional Commits (
feat:,fix:,docs:,chore:,build:,refactor:,test:) โ the git-commiter skill handles message generation and staging. - Never commit generated artifacts (
dist/,node_modules/,*.tgz).
TDDโ
- Follow the tdd skill workflow: write the failing test first (red), watch it fail, implement the minimum (green), then refactor.
- Tests live beside the code they cover (
src/*.test.ts) withvitest. Use thenode:httpfixture servers (underfixtures/) for hermetic HTTP/MCP tests โ do not mockfetchor the MCP SDK. - Add a test for every behavior change; a change without a test is not complete.
- Live integration tests go under
tests/integration/, gated behind theERPBridge_TEST_SERVERenv var (skipped when unset).
Quality gatesโ
- Run
npm testandnpm run buildbefore finishing any task; runnpm run lint:publish(publint + attw --pack on the tarball) for anything that ships in the package. - Behavior changes update README.md and CHANGELOG.md (Unreleased) in the same commit.
- Product-facing documentation lives in this site (erpbridge-docs) under
docs/sdk/(single source of truth) โ update it in the same commit as the behavior, and runnpm run buildhere to verify links.
Release pipelineโ
- Versions and changelogs come from release-please (Conventional Commits drive bumps:
fix:โ patch,feat:โ minor,BREAKING CHANGE:footer โ major). Never hand-editCHANGELOG.mdversion entries or bump the version field yourself โ the release PR does it. Write Unreleased entries only. - Publishing uses npm Trusted Publishing (OIDC) from CI โ no
NODE_AUTH_TOKEN, provenance is automatic.package.jsonrepository.urlmust exactly match the GitHub repo or provenance fails. - Every release ships with a documentation update: SDK user-facing changes are documented on this site (erpbridge-docs) in the same release cycle, and this page is kept in sync with the SDK repository.
- CI and release workflows are part of the contract:
.github/workflows/{ci,release}.ymlmust stay green; SHA-pin any new third-party action and keeppermissionsleast-privilege. API reference docs live on this site (docs/sdk/api-reference.mdx), not in a Pages workflow.
Secretsโ
- Resolve credentials from configuration or environment only โ explicit
token, configuredtokenEnv, or the defaultERPBRIDGE_TOKENenv var.ERPBridge_TOKENremains a legacy fallback when the canonical variable is absent. Keep token values out of code, logs, tests, and commits. - When debugging or writing tests, assert header injection but never log the token value itself.
- Auth is consume-only: the SDK sends
Authorization: Bearer; it never creates, lists, reveals, revokes, refreshes, or stores tokens (that is server-admin work via bridgectl).
Conventionsโ
- Tool names on the wire are bare (
list_employees), noterp.-prefixed โ the proxy keys on exact registered names. Do not add prefix normalization without extending the plan. - Public API ships dual ESM + CJS built with tsdown (
format: ['esm','cjs'],fixedExtensionโ.mjs/.cjs+.d.mts/.d.cts). Keep theexportsmap inpackage.jsonin sync withsrc/index.ts; subpaths./client,./rest,./typesmirror their source files. Named exports only โ noexport default. @modelcontextprotocol/*stays an external runtime dependency (never bundled intodist/).- Errors are typed: always throw/forward the class hierarchy from
src/types.ts(ErpbridgeErrorโAuthenticationError/AuthorizationError/NotFoundError/RateLimitError/ClientError(4xx) /ServerError(5xx) /ProtocolError), never rawErrorwith string-matching. - SSE parsing lives in one module and stays dependency-free; the server format is
data: <json>\n\n. - Node >= 20 โ use built-in
fetch,AbortSignal, andAsyncIterablerather than adding runtime dependencies.