fix(moss-md-indexer): upload through @moss-js/moss instead of the legacy REST SDK
Pull Request Checklist
- I have read the CONTRIBUTING guide.
- I have updated the documentation (if applicable). CHANGELOG entry added; the README has no SDK-specific instructions to change.
- My code follows the style guidelines of this project.
- I have performed a self-review of my own code.
- I have added tests that prove my fix is effective or that my feature works. The package has no test runner; see "How I tested" below.
- New and existing unit tests pass locally with my changes.
Description
@moss-tools/md-indexer uploads through @inferedge-rest/moss, a pre-1.0 SDK that calls moss-control's legacy /manage deleteIndex + createIndex. That blocks the moss-control release:
- usemoss/infra-moss-tf#317 (MOS-654) retires the
/managewrite actions (they answer 410). Its precondition is no write traffic left on/manage. - In the last 90 days the only steady
/managewrite caller is themoss_vitepressVercel project (rootpackages/vitepress-plugin-moss/demo-site). On every push tomainits build runsvitepress-plugin-moss→ md-indexer 1.0.0-beta.3 →deleteIndexthencreateIndexon indexfilter, twice per build. Once #317 ships, the delete would still succeed and the create would fail, leaving the docs site with no search index. - Indexes built that way also carry no model artifact identity, so current SDKs refuse text queries on them.
This PR swaps the client for MossClient from @moss-js/moss (1.21.0, the current JS SDK; @moss-dev/moss is the older name, still at 1.7.1). It builds indexes in moss-index-manager (service.usemoss.dev/index) and never calls moss-control.
Behaviour is otherwise unchanged: delete the index if present, then create it with the configured model (modelId). The public API (uploadDocuments, createIndex, sync, buildJsonDocs, types) is the same. The client is now closed after use.
This covers the same SDK migration as #528, kept to the minimum needed to unblock the moss-control release. #528 also switches to a non-destructive upsert. That's worth doing as a follow-up, but as written it would throw on the live filter index (it was built by the old SDK, so it has no model version) instead of rebuilding it. Thanks to @PredictiveManish for flagging the legacy dependency.
Type of Change
- Bug fix (non-breaking change which fixes an issue)
How I tested
pnpm build(tsc) passes;dist/has no reference to@inferedge-rest/moss.- Ran the built uploader with
@moss-js/mossmocked (Node 24,node:test):- It calls delete → create, with
{ modelId }, then closes the client. - A missing index isn't an error.
- Other delete errors only warn.
- A create failure is wrapped as
Moss Upload Failed: …and the client is still closed. - An empty document list makes no calls.
- It calls delete → create, with
- Loaded the real
@moss-js/mossnative module under Node 24.22.1 and opened and closed a client. - Not run against a live project. The first real run will be the
moss_vitepressbuild after step 3 below.
Rollout (needed for the docs site to pick this up)
- Merge, then run Publish moss-md-indexer (workflow_dispatch) to publish
1.0.0-beta.4. Its last two runs in April failed. The logs have expired, but they most likely tried to republish1.0.0-beta.3, and the version bump avoids that. - Follow-up PR: update
packages/vitepress-plugin-moss/pnpm-lock.yamlto md-indexer1.0.0-beta.4. The demo site installs the plugin's dependencies from that lockfile, so^1.0.0-beta.3alone keeps resolvingbeta.3. - Check the next
moss_vitepressbuild log, and confirm moss-control's CloudWatch shows no/managewrites from that project.
package-lock.json in this package was already stale. Regenerating it churns about 1,900 lines, so I left it alone; publishing uses pnpm-lock.yaml.
🤖 Generated with Claude Code
Summary by CodeRabbit
- Compatibility
- Updated Markdown index uploads to use the current Moss SDK.
- Index creation now passes the selected model to the indexing service, supporting text queries with current SDKs.
- Legacy SDK
/managewrite actions are being retired; use current SDKs to manage indexes.
- Bug Fixes
- Improved handling of missing-index errors and client cleanup during index operations.