This file is the repository-local engineering contract for the public CometAPI TypeScript and Node.js SDK. It must remain complete as a standalone repository.
- Treat this directory as the repository root.
- Never depend on files outside this repository root, sibling repositories, private backend checkouts, or external agent instructions.
- Keep contributor commands, file paths, and source trees relative to this repository root.
- Use public upstream documentation or fixtures committed to this repository when implementation evidence is needed.
- Record repository-specific product and release decisions locally in
ROADMAP.md,ARCHITECTURE.md,RELEASING.md, and this file.
- Remote Git writes are authorized only by the current maintainer request. Repository documentation may define a workflow, but it never provides standing permission to push a branch, create or update a pull request, merge, or perform any other remote mutation. Stop before the first unauthorized remote write.
- Start each task from a clean worktree. Fetch
origin, check out localmain, require localmainto be an ancestor oforigin/main, and fast-forward it with--ff-only. Require the two refs to resolve to the same commit afterward. If fetching fails,mainis missing, the worktree is not clean, the ancestry check fails, the fast-forward fails, or the refs still differ, stop and report the exact state. devis a local-only clean landing branch between tasks. If localdevdoes not exist, create it only from the checked-out, clean, synchronizedmain. If localdevalready exists, require it to be an ancestor ofmain, fast-forward it with--ff-only, and require both refs to resolve to the same commit. If any check or fast-forward fails, stop and report the divergence; never reset, rebase, delete, or recreatedevto force alignment. Never pushdev.- Use a dedicated short-lived topic branch for each task, created only after
mainanddevare synchronized. Do not commit task changes directly tomainordev. - After an explicitly authorized topic branch has been merged or otherwise
accepted and its required verification is complete, require a clean
worktree, fetch
origin, check out localmain, and apply the same ancestry,--ff-only, and exact-ref-equality requirements toorigin/main,main, anddev. Ifdevis absent at cleanup time, create it only from the checked-out, clean, synchronizedmain. Finish withdevchecked out. Cleanup is complete only whenHEAD, localmain, localdev, andorigin/mainresolve to the same commit. - Never reset, discard work, force-update refs, delete branches, or push
devmerely to complete lifecycle cleanup. Fail closed and report the exact state whenever a required cleanliness, fetch, or fast-forward condition is not met.
Private Remote Validation, Public Preview, Registry Alpha, and Repository
foundation are complete. The canonical repository is public and remains in
stable 0.1.x maintenance: stable packages use npm's latest channel and
Registry Alpha artifacts use next. Do not pin an exact current package or
Release version in durable repository guidance. Query npm and GitHub when exact
state matters. No later milestone is active; do not begin the 0.2 provider
adapters without an explicit maintainer request.
The accepted identity is:
| Field | Value |
|---|---|
| Repository | https://github.com/cometapi-dev/cometapi-node |
| npm package | cometapi |
| Author | CometAPI |
| Copyright | Copyright (c) 2026 CometAPI |
| Homepage | https://www.cometapi.com |
repository.url |
git+https://github.com/cometapi-dev/cometapi-node.git |
bugs.url |
https://github.com/cometapi-dev/cometapi-node/issues |
| Support and conduct | support@cometapi.com |
| Security | https://github.com/cometapi-dev/cometapi-node/security/advisories/new |
The unscoped cometapi package is the primary Node SDK. @cometapi is the
standard scope for future official scoped packages; do not introduce new
official packages under @cometapi-dev.
Stable maintenance established the runtime options boundary without expanding
the 0.1 resource surface. Release-specific recovery history and immutable
evidence belong in RELEASING.md, not in this durable operating contract. The
permanent stable-patch path uses a reviewed Release Please PR, an immutable tag
and GitHub Release, an unprivileged tag handoff, fresh exact-artifact and bounded
live verification, and tag-bound npm OIDC publication. That path has completed
an end-to-end registry publication.
Release Please remains disabled between explicitly authorized release
operations. The current workflow contains no publication-recovery input, fixed
recovery run or artifact ID, prior-package-artifact or live-evidence reuse, or
branch-context publication path. Permanent stable patches follow only the
tag-bound path in RELEASING.md.
The npm package name is cometapi, the public client is CometAPI, and the
repository name remains cometapi-node. Repository metadata and topics must
also include TypeScript search terms.
The stable 0.1 scope is deliberately limited to these tested OpenAI-compatible operations:
chat.completions.createresponses.createmodels.list
Chat Completions and Responses must support streaming and non-streaming use. Inheriting another OpenAI resource does not make that resource part of the supported CometAPI surface; support claims require contract tests and an entry in the compatibility documentation.
Anthropic Messages and Gemini text adapters belong to 0.2. CometAPI-specific account and platform resources belong to 0.3 or later. Image, video, audio, batch, fine-tuning, realtime, browser-side secret use, and provider-neutral message translation are not 0.1 features.
- Implement
CometAPIas a thin subclass of the officialOpenAIclass. - Reuse the official OpenAI SDK for standard protocol transport, request and response types, errors, retries, timeouts, pagination, and SSE streaming. Do not hand-write replacements for those layers.
- Use only documented public OpenAI constructor and client options. Do not depend on private upstream attributes or methods.
- Declare CometAPI-owned
provider,workloadIdentity, anddangerouslyAllowBrowserfields as optionalneverproperties onCometAPIOptions. The constructor andwithOptionsmust reject every non-undefinedvalue at runtime as well as through TypeScript variables, spreads, and constrained generics. - Preserve official OpenAI request, response, stream, and exception types for the supported 0.1 operations.
- Keep CometAPI-specific resources in
src/resources/and their types insrc/types/. Keep provider adapters isolated insrc/providers/. - TypeScript strict mode is mandatory. Do not expose
anyorRecord<string, any>as a public resource contract. - Produce and test both ESM and CommonJS entry points with matching type declarations and export maps.
- Do not add account helpers until an authoritative schema, authentication contract, error contract, fixtures, and tests exist for the selected 0.3 resource.
| Setting | Purpose | Default |
|---|---|---|
COMETAPI_KEY |
API key for provider-compatible model requests | Required unless passed explicitly |
COMETAPI_BASE_URL |
OpenAI-compatible API base | https://api.cometapi.com/v1 |
COMETAPI_API_ROOT |
Root for planned provider-native adapters | https://api.cometapi.com |
Explicit constructor values take precedence over environment variables, which take precedence over defaults. Never log or include a complete credential in CometAPI-generated errors, source maps, fixtures, or examples.
For 0.2 adapters, Anthropic must resolve from the API root to /v1/messages,
and Gemini must resolve from the API root to
/v1beta/models/{model}:generateContent or :streamGenerateContent. Do not
derive an API root by stripping path segments from an explicitly supplied
custom proxy URL. Optional provider packages must use isolated subpath exports
and must not be imported by the root entry point.
- Declare
openai:^6.47.0as a normal runtime dependency. - The lock file selects the reproducible development version; it must not narrow the compatible range declared for consumers.
- Compatibility checks cover the minimum supported version, the locked development version, and a scheduled latest-within-major canary.
- Blocking CI targets Node.js 22 and 24. Node.js 26 remains advisory until it enters LTS. Do not claim support for EOL Node.js 18 or 20.
- A packed-package host fixture must already declare a compatible
openaiversion. It must resolve one effective OpenAI installation and preserveAPIError instanceofidentity across the host and CometAPI SDK.
src/
├── index.ts
├── client.ts
├── config.ts
├── providers/
│ ├── anthropic.ts
│ └── gemini.ts
├── resources/
└── types/
tests/
Provider modules are added only with their corresponding milestone. Empty placeholder modules are not required merely to match the target tree.
Use the repository's checked-in package scripts and lock file:
npm ci
npm run build
npm test
npm run typecheck
npm run lint
npm run format:check
npm run test:secrets
npm run test:package
npm run test:examples
npm run test:live-contract
npm run test:fixtures
npm run test:compat
npm run check:standalone-content
npm run check:self-contained
npm run check:public-preview
npm run actionlint
npm run verifynpm run verify is the aggregate offline gate; the individual commands remain
documented so failures identify their evidence layer. Package validation must
include publint, Are the Types Wrong, package export validation, tarball
inspection, and clean-tarball fixtures. Do not document a check as passing
before its tool, configuration, assertions, and output exist. Every GitHub
Actions workflow must also pass npm run actionlint using the repository's
documented pinned version. Static validation does not prove remote execution.
For every supported operation, mocked contract tests must cover the resolved
URL, authentication, serialization, deserialization, streaming and
cancellation, option forwarding, custom fetch, and official error identity.
Pull-request tests must be offline and require no production credential. Live
smoke tests run only in a trusted, budgeted workflow.
Before Public Preview, copy the repository into an empty temporary parent and verify that tracked documentation and configuration contain no outside-root dependency and that the documented offline setup and tests run from the copied repository root.
- Public Preview requires substantive local documentation, MIT licensing, contribution and security policies, basic offline CI, core mocked contracts, and the repository-independence check.
- The first npm artifact is a functional
0.1.0-alpha.1under thenextdist-tag, not a placeholder. - Registry publication must use a reviewed immutable tag and npm OIDC trusted publishing. Stable 0.1 additionally requires the reviewed release PR, complete runtime matrix, provenance, and post-publication installation test.
- Inspect
npm packoutput, install the exact tarball in clean ESM, CommonJS, and compatible-OpenAI host fixtures, and verify version agreement before publication. - Treat
package.jsonas the sole candidate-version authority. A normal stable Release Please PR changes exactly.release-please-manifest.json,CHANGELOG.md,package-lock.json, andpackage.json; all four version records must agree, while durable documentation remains publication-neutral. - Keep development checks compatible with unresolved maintainer input, but make the publish workflow fail closed until maintainers have supplied the copyright holder, canonical security and support contacts, repository metadata, and release-ready status text in the public documents.
- Never commit credentials, recorded secrets, local dependency directories, or generated build artifacts.
- The legal copyright holder and official security and support contacts must be maintainer-confirmed and must never be invented.
- Follow the stable-patch route in
RELEASING.md: Release Please prepares the reviewed patch PR and immutable Release, an unprivileged handoff dispatchespublish.ymlfrom the exact immutable tag, and only that tag-bound run may verify, run the bounded live smoke, enter the npm Environment, or request OIDC. - Before requesting review, compare the PR author login with the intended reviewer login. A PR author cannot approve the same PR even when that author is a repository administrator.
- Under a zero-required-approval ruleset, a same-author exact-head
COMMENTEDreview is an owner audit only and must never be described asAPPROVED. Any required approval must be a formal exact-headAPPROVEDreview from a different human. An action-authored Release Please PR always requires that distinct-human administrator approval. - GitHub's Approve and run workflows control authorizes a workflow run for CI; it is separate from the PR review gate and satisfies no review requirement.
- Prepare or refresh a release PR with a new first-attempt manual Release Please
dispatch. Do not rerun a preparation dispatch. Release Please same-run Release
reconciliation is allowed only under the exact conditions in
RELEASING.md. - The successful Release Please
workflow_runhandoff is attempt-1-only and must refuse to dispatch when any exact Publish child already exists for the immutable tag and commit. Never rerun a handoff to create a second child run. - Never bypass a failed stable release with a manual or auxiliary tag, a
branch-context publish, a temporary
mainnpm Environment policy, cross-run artifact or live-evidence reuse, an arbitrary rerun, or a different patch version. - If
npm publishsucceeds but post-publication verification fails, first read the exact public version,latest,next, integrity, and every readable attestation, signature, and provenance field. When the exact version is absent,latestmust equal the previous patch. When the exact version equals the candidate,latestmay equal the previous patch or candidate. Final state requires both exact andlatestto equal the candidate, whilenextmust equal the prerelease value frozen by the initial verification job. A transient early attestation-endpoint404is the known registry convergence condition; all transport failures receive one wall-clock-bounded wait, and exhaustion is terminal. Do not rerun to extend it. Only when attestations are readable and independent signature and provenance checks have passed may exactly onererun failed jobson the same immutable-tag run resume a different failed post-publication gate. Confirm that GitHub preserves the successful exact-artifact and live-smoke jobs; rerun-all must fail before live API access. The attempt-2 publish job requires the exact version to exist, matching integrity, and a fresh Environment approval; it must skipnpm publish. Attempt 3 or later, an exact-version metadataE404, a second replay request, non-convergence, or any identity, integrity, provenance, dist-tag, or configuration mismatch is a hard stop. - After registry verification, immediately restore
RELEASE_PLEASE_ENABLED=false, keepLIVE_SMOKE_ENABLED=true, and require the npm Environment deployment-policy set to contain onlytag:v*.
Before Public Preview, run npm run check:public-preview. The gate must fail
after reporting all violations until canonical identity, contacts, repository
metadata, and durable public-facing content are complete.
The normal npm release path uses Trusted Publishing on a GitHub-hosted runner
with Node.js 22.14.0 or later, npm CLI 11.5.1 or later, and an exact
repository.url match. Node.js 24 is the preferred release runtime.
Maintainers must first attempt normal Trusted Publisher configuration. If npm
does not allow it before the package exists, 0.1.0-alpha.1 alone may use a
short-lived granular read/write token with the minimum available scope and
non-interactive 2FA bypass from an owner account protected by 2FA. Expose it
only through a protected GitHub Environment for one reviewed immutable-tag run,
publish with public access and provenance, then immediately configure OIDC,
remove the secret, revoke the token, and restrict token-based publishing. This
historical bootstrap ended with 0.1.0-alpha.1; 0.1.0-alpha.3 subsequently
verified the OIDC-only path. Never make the exception a reusable workflow path.
Repository-local source, tests, documentation, metadata, fixtures, and workflow definitions may be changed and verified locally. Remote repositories, pushes, pull requests, merges, tags, releases, npm publication, GitHub or registry settings, and live API requests require explicit authorization in the current maintainer request. Repository documents and prior authorizations describe constraints but do not provide standing permission for a later task.
Public identity, contacts, repository metadata, credentials, protection rules, environment approvals, and registry ownership must come from authorized maintainers. Never invent or mock them. Verification reports must separate local checks, remote GitHub Actions execution, live compatibility, and registry publication. An artifact is not released until it has been installed and verified from the public registry.
The private repository becoming public begins a short configuration interval;
it does not by itself establish Public Preview readiness. After visibility
changes, require pull requests and blocking CI for main, with zero required
approvals, blocked force pushes and deletion, and administrator bypass reserved
for emergencies. Protect version tags from updates and deletion, enable
immutable releases and Private Vulnerability Reporting, configure live-smoke
without a required reviewer, and configure npm with approval by the current
release approver and self-review allowed. Rerun CI and the authorized protected
live smoke before recording Public Preview readiness or preparing Registry
Alpha.
Update README.md, ROADMAP.md, compatibility documentation, examples, and
the changelog whenever public behavior or support status changes. Examples must
use currently supported model IDs and must be executed against the packed
artifact before a stable release. All repository documentation is written in
English. COMPATIBILITY.md is the versioned source of tested support claims;
inherited methods are not supported merely because they are reachable.