Skip to content

refactor(inference): migrate Bedrock runtime adapter launcher to .mts - #6938

Merged
cv merged 10 commits into
mainfrom
chore/6925-bedrock-adapter-mts
Jul 15, 2026
Merged

refactor(inference): migrate Bedrock runtime adapter launcher to .mts#6938
cv merged 10 commits into
mainfrom
chore/6925-bedrock-adapter-mts

Conversation

@laitingsheng

@laitingsheng laitingsheng commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Migrates the Bedrock runtime adapter launcher scripts/bedrock-runtime-adapter.js from a thin CommonJS shim to a typed explicit-ESM .mts entrypoint, without adding a root "type": "module" declaration. The adapter implementation stays in src/lib/inference/bedrock-runtime-adapter.ts; the launcher keeps loading the compiled module and starting the adapter from the environment. Start, ownership detection, recovery, stop, state, PID, token, and log behaviour are unchanged.

Related Issue

Resolves #6925

Changes

  • scripts/bedrock-runtime-adapter.js is renamed to scripts/bedrock-runtime-adapter.mts and its require is replaced with a static ESM import of the compiled adapter, named explicitly as ../dist/lib/inference/bedrock-runtime-adapter.js. This mirrors the existing openrouter-runtime-adapter-entry.ts launcher shape.
  • The launcher runs on the minimum supported Node version (>=22.19.0) without tsx or installed development dependencies: the adapter is spawned as node <launcher> and Node strips the .mts types natively.
  • The process ownership needle drops its file extension (bedrock-runtime-adapter), matching the openrouter-runtime-adapter convention. A single needle now recognises both the old .js and the new .mts launcher, so a pre-upgrade adapter process is detected and stopped during cleanup rather than silently orphaned. The packaged launcher path resolved by the lifecycle now names the .mts file.
  • The live E2E adapter-ownership check matches the extensionless launcher name, so it keeps recognising the running adapter across the rename.
  • package.json needs no change: files already ships the whole scripts/ directory, and tsconfig.cli.json already includes scripts/**/*.mts.

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with doc updates
  • Doc only (prose changes, no code sample modifications)
  • Doc only (includes code sample changes)

Quality Gates

  • Tests added or updated for changed behavior
  • Existing tests cover changed behavior — justification:
  • Tests not applicable — justification:
  • Docs updated for user-facing behavior changes
  • Docs not applicable — justification: internal scripts/ launcher file-extension migration with unchanged runtime behaviour; no contributor-facing command example or doc page references this launcher path.
  • Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging)
  • Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification:
  • Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue:

Verification

  • PR description includes a Signed-off-by: line and every commit appears as Verified in GitHub
  • Normal pre-commit, commit-msg, and pre-push hooks passed, or npm run check:diff passed when hooks were skipped or unavailable
  • Targeted behavior tests pass for the current change set, or tests are marked not applicable above — command/result or justification:
  • Applicable broad gate passed — npm test for broad runtime/test-harness changes; npm run check for repo-wide validation/coverage changes — command/result:
  • Quality Gates section completed with required justifications or waivers
  • No secrets, API keys, or credentials committed
  • npm run docs builds without warnings (doc changes only)
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Signed-off-by: Tinson Lai tinsonl@nvidia.com

Summary by CodeRabbit

  • Bug Fixes
    • Improved local Bedrock adapter detection across environments.
    • Added compatibility for both .js and .mts adapter launchers.
    • Improved cleanup of stale adapter processes.
    • Updated end-to-end validation for configured test sharding.

Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The Bedrock runtime adapter launcher now uses a typed .mts entrypoint. Process detection and cleanup accept both .mts and legacy .js launchers, with focused tests and live E2E shard validation updated accordingly.

Changes

Bedrock launcher migration

Layer / File(s) Summary
Launcher path and process lifecycle
scripts/bedrock-runtime-adapter.mts, src/lib/inference/bedrock-runtime-adapter.ts, src/lib/inference/local-adapter-lifecycle.ts
The launcher uses ESM imports, resolves the .mts script path, and supports string or regular-expression process needles for detection and cleanup.
Process recognition validation
src/lib/inference/bedrock-runtime-adapter.test.ts
Tests verify the .mts path, recognition of .mts and legacy .js Bedrock launchers, and rejection of unrelated launchers.
Live E2E validation
test/e2e/live/bedrock-runtime-compatible-anthropic.test.ts
Live process checks accept both launcher filenames, and the test validates the resolved E2E shard.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

  • Issue 6918 — Covers the broader Bedrock runtime adapter launcher migration to .mts.
  • Issue 6926 — Addresses related migration of host-side launcher scripts from .js to .mts and legacy filename handling.

Possibly related PRs

  • NVIDIA/NemoClaw#6969 — Updates CI/workflow handling for the NEMOCLAW_E2E_SHARD value validated by this E2E test.

Suggested labels: refactor

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Linked Issues check ❓ Inconclusive The launcher migration and process-matching updates align with the issue, but the summary doesn't show package-content or detached-spawn-arg changes or validation results. Confirm the packaging and spawn-argument updates landed, and provide evidence that focused Bedrock tests, live E2E, and typecheck:cli pass.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: migrating the Bedrock runtime adapter launcher to .mts.
Out of Scope Changes check ✅ Passed All listed changes are directly related to the Bedrock launcher migration and its tests; no unrelated edits are evident.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/6925-bedrock-adapter-mts

Comment @coderabbitai help to get the list of available commands.

@laitingsheng laitingsheng added the chore Build, CI, dependency, or tooling maintenance label Jul 15, 2026
@github-code-quality

github-code-quality Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage remains at 96%, unchanged from the main branch.

TypeScript / code-coverage/cli

The overall coverage in the chore/6925-bedrock-a... branch remains at 80%, unchanged from the main branch.

Show a code coverage summary of the most impacted files.
File main 819e6ff chore/6925-bedrock-a... 2222c3e +/-
src/lib/inferen...er-lifecycle.ts 70% 69% -1%
src/lib/securit...ntial-filter.ts 98% 99% +1%
src/lib/inferen...time-adapter.ts 54% 57% +3%

Updated July 15, 2026 21:25 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/lib/inference/bedrock-runtime-adapter.test.ts (2)

390-401: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Add a near-match rejection case.

The test does not reject bedrock-runtime-adapter-backup.js or a command argument containing the needle, so it would pass while false-positive process detection remains possible. Add a negative case for a similarly named launcher.

As per path instructions, behavioral tests should protect the process-recognition contract, including rejection of near matches.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/inference/bedrock-runtime-adapter.test.ts` around lines 390 - 401,
Extend the test case around isLocalAdapterProcess to add negative assertions for
the similarly named bedrock-runtime-adapter-backup.js launcher and for a command
argument that merely contains adapterProcessNeedle. Preserve the existing
positive checks for the old and new launcher filenames and the unrelated
OpenRouter rejection.

Source: Path instructions


386-388: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Exercise the launch boundary, not only the private path helper.

This test says “spawns” but only checks __test.getAdapterScriptPath(). A regression in ensureBedrockRuntimeAdapter or spawnDetachedNodeAdapter could still pass. Assert the actual detached-spawn argument, or rename the test if helper-only coverage is intentional.

As per path instructions, tests should verify observable behavior through the public boundary rather than private-shape assertions.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/inference/bedrock-runtime-adapter.test.ts` around lines 386 - 388,
Update the test around ensureBedrockRuntimeAdapter and spawnDetachedNodeAdapter
to exercise the public launch flow and assert the actual detached-spawn argument
ends with bedrock-runtime-adapter.mts. If this test remains limited to
__test.getAdapterScriptPath(), rename it to describe helper-path coverage rather
than claiming that it spawns the launcher.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lib/inference/bedrock-runtime-adapter.ts`:
- Around line 319-336: Replace the bare ADAPTER_PROCESS_NEEDLE matching used by
isAdapterProcess and killStaleAdapter with one shared exact launcher-filename
matcher that accepts only bedrock-runtime-adapter.mts or legacy .js basenames
with proper boundaries. Update
src/lib/inference/bedrock-runtime-adapter.test.ts:390-401 to include a similarly
named launcher or argument and assert it is rejected; update
test/e2e/live/bedrock-runtime-compatible-anthropic.test.ts:585-585 to apply the
same matcher to both procfs and ps command paths.

---

Nitpick comments:
In `@src/lib/inference/bedrock-runtime-adapter.test.ts`:
- Around line 390-401: Extend the test case around isLocalAdapterProcess to add
negative assertions for the similarly named bedrock-runtime-adapter-backup.js
launcher and for a command argument that merely contains adapterProcessNeedle.
Preserve the existing positive checks for the old and new launcher filenames and
the unrelated OpenRouter rejection.
- Around line 386-388: Update the test around ensureBedrockRuntimeAdapter and
spawnDetachedNodeAdapter to exercise the public launch flow and assert the
actual detached-spawn argument ends with bedrock-runtime-adapter.mts. If this
test remains limited to __test.getAdapterScriptPath(), rename it to describe
helper-path coverage rather than claiming that it spawns the launcher.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: b2043080-d4c5-4f8e-8ced-af0facdd8cde

📥 Commits

Reviewing files that changed from the base of the PR and between 55fdc3f and 6d9fdd1.

📒 Files selected for processing (4)
  • scripts/bedrock-runtime-adapter.mts
  • src/lib/inference/bedrock-runtime-adapter.test.ts
  • src/lib/inference/bedrock-runtime-adapter.ts
  • test/e2e/live/bedrock-runtime-compatible-anthropic.test.ts

Comment thread src/lib/inference/bedrock-runtime-adapter.ts Outdated
@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor — Informational

Advisor assessment: Informational / high confidence
Next action: No advisor follow-up needed.
Findings: 0 blockers · 0 warnings · 0 suggestions
Status: No actionable findings remain in the canonical review ledger.

Model lanes

  • GPT-5.6 Terra (primary): Completed · high confidence · 0 blockers · 0 warnings · 0 suggestions
  • Nemotron 3 Ultra (second opinion): Completed · high confidence · 1 blocker · 3 warnings · 0 suggestions
  • Model comparison: normalized findings differ; normalized E2E selections differ; Nemotron reported 1 more blocker, 3 more warnings, the same number of suggestions.

Nemotron output stays in workflow artifacts and does not change the assessment above.

Since last review: 0 prior items resolved · 0 still apply · 0 new items found

E2E guidance

Advisory only. E2E / PR Gate selects and runs jobs independently.

Recommended E2E: cloud-onboard, credential-sanitization, security-posture, bedrock-runtime-compatible-anthropic, inference-routing, network-policy

Workflow run details

This automated review informs maintainers. Warnings and suggestions do not require a response. A maintainer decides whether to merge.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
test/e2e/live/bedrock-runtime-compatible-anthropic.test.ts (1)

584-590: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Avoid copying the production launcher matcher into the E2E helper.

This regex duplicates src/lib/inference/bedrock-runtime-adapter.ts’s production matcher, so a defect in the matching rule can be reproduced by both code paths and still pass E2E validation. Assert the observed command line against the expected current and legacy launcher basenames, leaving matcher edge cases to focused unit tests.

As per path instructions, E2E tests should prioritize behavioral confidence and flag copied production algorithms.

Also applies to: 595-599

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/e2e/live/bedrock-runtime-compatible-anthropic.test.ts` around lines 584
- 590, Remove the duplicated BEDROCK_ADAPTER_LAUNCHER_PATTERN from
isBedrockAdapterProcess and stop copying the production matcher logic. Instead,
assert the observed command line against the expected current and legacy
launcher basenames directly, preserving detection for both launchers while
leaving matcher edge cases to focused unit tests.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@test/e2e/live/bedrock-runtime-compatible-anthropic.test.ts`:
- Around line 584-590: Remove the duplicated BEDROCK_ADAPTER_LAUNCHER_PATTERN
from isBedrockAdapterProcess and stop copying the production matcher logic.
Instead, assert the observed command line against the expected current and
legacy launcher basenames directly, preserving detection for both launchers
while leaving matcher edge cases to focused unit tests.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 4ff2ece8-1b23-47f7-a78d-1de2dc267d88

📥 Commits

Reviewing files that changed from the base of the PR and between 29c7858 and cf26387.

📒 Files selected for processing (4)
  • src/lib/inference/bedrock-runtime-adapter.test.ts
  • src/lib/inference/bedrock-runtime-adapter.ts
  • src/lib/inference/local-adapter-lifecycle.ts
  • test/e2e/live/bedrock-runtime-compatible-anthropic.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/lib/inference/bedrock-runtime-adapter.test.ts

cv
cv previously requested changes Jul 15, 2026

@cv cv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is blocked by the current Bedrock E2E workflow contract. The job does not set to the matrix agent, so the controller authorizes / shards while the child reports ; the evidence run fails before it can validate the migration. Land a small mainline workflow prerequisite that sets the shard from and adds workflow-boundary/controller regression coverage, then rebase and rerun this PR. The existing runtime jobs passed, but the required controller/evidence contract is not satisfied.

cv
cv previously requested changes Jul 15, 2026

@cv cv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correction with the affected contract: the Bedrock job does not set NEMOCLAW_E2E_SHARD to the matrix agent, so the controller authorizes openclaw and hermes shards while the child reports default. Land a small mainline workflow prerequisite that sets the shard from matrix.agent and adds workflow-boundary and controller regression coverage, then rebase and rerun this PR. The existing runtime jobs passed, but the required controller and evidence contract is not satisfied.

@cv
cv dismissed their stale review July 15, 2026 17:18

Superseded by the immediately following corrected review with complete path and contract names.

@cv

cv commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Post-prerequisite reconciliation plan: after #6969 merges, merge current main manually. A blind merge is text-clean but would leave two NEMOCLAW_E2E_SHARD keys in the Bedrock job and duplicate validator blocks. Keep one mapping after NEMOCLAW_AGENT, keep the main validator with the must-pass-matrix.agent diagnostic, and preserve both the launcher process matcher and the live shard assertion. Then run the focused adapter/lifecycle, E2E-workflow, risk-plan, typecheck, and package-contract checks before fresh protected E2E.

cv added a commit that referenced this pull request Jul 15, 2026
<!-- markdownlint-disable MD041 -->
## Summary

Unblocks the v0.0.84 TypeScript migration PRs whose required evidence
depends on trusted workflow code from `main`. Coverage actions now
select the available TypeScript entrypoint, and the Bedrock matrix
reports the agent-specific shard expected by the E2E controller.

## Changes

- Make the base-trusted CLI and plugin coverage actions prefer the
migrated `.mts` entrypoints and fall back to `.ts` for older branches.
This compatibility window is required because #6935 deletes the old
entrypoints in the PR checkout while the action implementation still
comes from `main`; the action-contract test executes `.mts`-only,
`.ts`-only, and missing-entrypoint fixtures across all four consumers.
Remove the `.ts` fallback after #6935 lands and no open migration branch
depends on the old entrypoints.
- Set `NEMOCLAW_E2E_SHARD` from the Bedrock job's `matrix.agent` so
#6938 produces distinct OpenClaw and Hermes evidence. Workflow-boundary
and controller tests protect the mapping and reject drift.

## Type of Change

- [x] Code change (feature, bug fix, or refactor)
- [ ] Code change with doc updates
- [ ] Doc only (prose changes, no code sample modifications)
- [ ] Doc only (includes code sample changes)

## Quality Gates

- [x] Tests added or updated for changed behavior
- [ ] Existing tests cover changed behavior — justification:
- [ ] Tests not applicable — justification:
- [ ] Docs updated for user-facing behavior changes
- [x] Docs not applicable — justification: internal CI compatibility and
evidence routing only; the documentation-writer review found no
user-facing command, default, configuration, API, policy, or supported
workflow change.
- [x] Sensitive paths changed (security, policy, credentials, preflight,
onboarding, inference, runner, sandbox, or messaging)
- [x] Sensitive-path review completed or maintainer-approved waiver
recorded — reviewer/approval link/justification: maintainer and
independent review found no secret, permission, dependency, or
untrusted-input expansion; fixed paths are quoted and missing
entrypoints fail closed.
- [ ] Non-success, skipped, or missing CI check accepted by maintainer —
check name, approval link, and follow-up issue:

## Verification

- [x] PR description includes a `Signed-off-by:` line and every commit
appears as `Verified` in GitHub
- [x] Normal `pre-commit`, `commit-msg`, and `pre-push` hooks passed, or
`npm run check:diff` passed when hooks were skipped or unavailable
- [x] Targeted behavior tests pass for the current change set, or tests
are marked not applicable above — `npx vitest run
test/pr-workflow-contract.test.ts test/pr-e2e-gate-shards.test.ts
--project integration` (22 passed); `npx vitest run
test/e2e/support/e2e-workflow.test.ts --project e2e-support` (36
passed); workflow validator, `npm run source-shape:check`, and `npm run
checks` passed.
- [ ] Applicable broad gate passed — `npm test` for broad
runtime/test-harness changes; `npm run check` for repo-wide
validation/coverage changes — command/result:
- [x] Quality Gates section completed with required justifications or
waivers
- [x] No secrets, API keys, or credentials committed
- [ ] `npm run docs` builds without warnings (doc changes only)
- [ ] Doc pages follow the [style
guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md)
(doc changes only)
- [ ] New doc pages include SPDX header and frontmatter (new pages only)

---
Signed-off-by: Carlos Villela <cvillela@nvidia.com>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **CI & Build Improvements**
- Updated CLI coverage and sourcemap verification to automatically run
the correct `.mts` vs `.ts` script variant when present.

- **Bug Fixes**
- Fixed Bedrock-compatible Anthropic E2E shard propagation by requiring
the runtime shard to match the matrix agent and failing fast on
drift/mismatch.

- **Tests**
- Added/expanded E2E and PR workflow contract tests for shard
expectations and boundary validation.
- Enhanced workflow step execution coverage with optional
working-directory support and `.ts`/`.mts` entrypoint compatibility
checks.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
@cv
cv dismissed their stale review July 15, 2026 20:37

Prerequisite #6969 is merged, this branch is reconciled, and the final diff preserves one agent-shard mapping plus a live assertion that the CI shard matches the matrix agent. Focused workflow, gate, adapter, package, type, and full coverage checks pass; re-review is clean.

@cv cv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed after #6969 and reconciliation. The launcher migration, bounded legacy/new process recognition, single shard mapping, CI shard assertion, and regression coverage are correct. Focused suites, package contracts, type-check, full coverage, commit hooks, and pre-push all pass.

@cv

cv commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Advisor follow-up: I reproduced the launcher directly on the repository minimum runtime with npx --yes node@22.19.0 scripts/bedrock-runtime-adapter.mts, without a TypeScript loader or tsx. It parsed the .mts entrypoint, resolved the compiled ESM import, and reached the expected NEMOCLAW_BEDROCK_RUNTIME_ADAPTER_TOKEN is required validation rather than an extension or module-resolution error. Package contracts are also green, and the selected protected Bedrock live job will exercise the installed launcher path end to end. The secondary duplication suggestion concerns pre-existing E2E cleanup logic and does not require a release-blocking refactor.

@cv
cv merged commit 4a2354f into main Jul 15, 2026
53 checks passed
@cv
cv deleted the chore/6925-bedrock-adapter-mts branch July 15, 2026 21:38
cv added a commit that referenced this pull request Jul 15, 2026
## Summary

Migrate the host-side Ollama authentication proxy from CommonJS
`scripts/ollama-auth-proxy.js` to the typed ESM
`scripts/ollama-auth-proxy.mts` entrypoint while preserving the existing
request-handling and lifecycle contract. This maintainer salvage
preserves the verified commits from #6949 and reconciles its process
matcher with the Bedrock adapter migration merged in #6938.

## Related Issue

Resolves #6926
Part of #6918
Supersedes #6949

## Changes

- Rename the Ollama authentication proxy entrypoint to `.mts` and retain
its fail-closed Bearer-token check, byte-length gate before
`timingSafeEqual`, sensitive-header stripping, loopback backend, public
listener, and nonzero `EADDRINUSE` behavior.
- Match only filename-bounded legacy `.js` and current `.mts` proxy
processes during lifecycle cleanup and uninstall, with positive coverage
for both names and negative coverage for helper and suffix near matches.
- Reconcile the shared local-adapter matcher after #6938: strings use
substring matching, regular expressions retain Bedrock's bounded
launcher matching, and callbacks support Ollama's ownership predicate.
All call sites use the existing `processMatcher` name.
- Repoint unit, recovery, uninstall, and live E2E fixtures to the `.mts`
entrypoint.

## Type of Change

- [x] Code change (feature, bug fix, or refactor)
- [ ] Code change with doc updates
- [ ] Doc only (prose changes, no code sample modifications)
- [ ] Doc only (includes code sample changes)

## Quality Gates

- [x] Tests added or updated for changed behavior
- [ ] Existing tests cover changed behavior — justification:
- [ ] Tests not applicable — justification:
- [ ] Docs updated for user-facing behavior changes
- [x] Docs not applicable — justification: the filenames and shared
matcher are internal; existing setup, lifecycle, uninstall, and
port-conflict documentation remains accurate. A documentation-writer
review found no page or standalone changelog change necessary.
- [x] Sensitive paths changed (security, policy, credentials, preflight,
onboarding, inference, runner, sandbox, or messaging)
- [x] Sensitive-path review completed or maintainer-approved waiver
recorded — reviewer/approval link/justification: the focused security
re-review on #6949 passed after the bounded matcher and negative tests
were added; the conflict resolution preserves #6938's bounded Bedrock
matcher and was independently revalidated.
- [ ] Non-success, skipped, or missing CI check accepted by maintainer —
check name, approval link, and follow-up issue:

## Verification

- [x] PR description includes a `Signed-off-by:` line and every commit
appears as `Verified` in GitHub
- [x] Normal `pre-commit`, `commit-msg`, and `pre-push` hooks passed, or
`npm run check:diff` passed when hooks were skipped or unavailable
- [x] Targeted behavior tests pass for the current change set, or tests
are marked not applicable above — 85 focused lifecycle, Bedrock,
uninstall, handler, and recovery tests passed after generating ignored
build artifacts.
- [ ] Applicable broad gate passed — `npm test` for broad
runtime/test-harness changes; `npm run check` for repo-wide
validation/coverage changes — command/result:
- [x] Quality Gates section completed with required justifications or
waivers
- [x] No secrets, API keys, or credentials committed
- [ ] `npm run docs` builds without warnings (doc changes only)
- [ ] Doc pages follow the [style
guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md)
(doc changes only)
- [ ] New doc pages include SPDX header and frontmatter (new pages only)

Additional validation: `npm run build:cli` and `npm run typecheck:cli`
passed. All original #6949 commits remain in the branch unchanged, and
the signed merge commit records the mechanical two-file resolution
against current `main`.

---
Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Updated the authenticated Ollama proxy launcher to the TypeScript
module entrypoint with configurable ports.
* **Bug Fixes**
* Improved proxy and local-adapter process detection so cleanup targets
only the intended auth-proxy variants.
* Enhanced handling of proxy startup when the configured port is already
in use, and better behavior during backend disconnects.
* **Tests**
* Expanded coverage for proxy ownership, restart/recovery flows,
near-name process matching, and error cases (including port conflicts
and backend disconnect scenarios).
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
Signed-off-by: Prekshi Vyas <prekshiv@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Co-authored-by: Tinson Lai <tinsonl@nvidia.com>
Co-authored-by: Prekshi Vyas <prekshiv@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Build, CI, dependency, or tooling maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate the Bedrock runtime adapter launcher to .mts

2 participants