Support Claude on Vertex AI (vendor + register vertex-anthropic provider) — B1 #169

Merged
david merged 3 commits from issue-27/vertex-anthropic-provider into main 2026-08-10 01:32:45 +00:00
Owner

Summary

Adds an opt-in Claude-on-Vertex provider (Option B / Approach B1 from the LLM-provider
investigation). With PILOOP_VERTEX_ANTHROPIC=1 and PILOOP_MODEL="vertex-anthropic/claude-opus-4-8",
pi-loop stage sessions run against Claude models served via Google Cloud Vertex AI using
existing GCP/ADC credentials. Default OFF = zero behavioural change for all existing providers.

Changes

  • Vendored pi-provider-vertex-anthropic@0.1.3 (MIT) into src/model/vertexAnthropic/
    (config, auth, shell, models, messages, vertex-api) with per-file provenance headers.
  • Added exact dep @earendil-works/pi-ai@0.81.1 (matches the bundled SDK); re-pointed the
    vendored @mariozechner/pi-ai imports to it.
  • registerVertexAnthropic() calls ModelRuntime.registerProvider(...); env-gated
    maybeRegisterVertexAnthropic() wired into createPiStageSession.ts.
  • resolveRegion() also honours GOOGLE_CLOUD_LOCATION (consistency with builtin google-vertex).
  • Docs: README "Claude on Vertex (optional)", AGENTS.md config note, scope doc marked
    B1 implemented, NOTICE for MIT attribution.

Testing

  • 51 new unit tests (config precedence/URLs, auth strategy selection + no token logged,
    message/tool conversion, SSE parse + request body, registration gate).
  • Full suite green: 917 passed.
  • npm run lint (0 errors/0 warnings) and npm run build pass.
  • Gated live smoke (PILOOP_E2E=1 + PILOOP_VERTEX_ANTHROPIC=1) — added but not run
    here (needs live GCP creds); skips cleanly by default.

Checklist

  • Self-reviewed the diff
  • Code follows project conventions (deterministic seams unit-tested; LLM stream as black box)
  • Descriptive naming
  • Documentation + MIT attribution updated

Closes #27

## Summary Adds an **opt-in** Claude-on-Vertex provider (Option B / Approach B1 from the LLM-provider investigation). With `PILOOP_VERTEX_ANTHROPIC=1` and `PILOOP_MODEL="vertex-anthropic/claude-opus-4-8"`, pi-loop stage sessions run against Claude models served via Google Cloud Vertex AI using existing GCP/ADC credentials. Default OFF = zero behavioural change for all existing providers. ## Changes - Vendored `pi-provider-vertex-anthropic@0.1.3` (MIT) into `src/model/vertexAnthropic/` (config, auth, shell, models, messages, vertex-api) with per-file provenance headers. - Added exact dep `@earendil-works/pi-ai@0.81.1` (matches the bundled SDK); re-pointed the vendored `@mariozechner/pi-ai` imports to it. - `registerVertexAnthropic()` calls `ModelRuntime.registerProvider(...)`; env-gated `maybeRegisterVertexAnthropic()` wired into `createPiStageSession.ts`. - `resolveRegion()` also honours `GOOGLE_CLOUD_LOCATION` (consistency with builtin google-vertex). - Docs: README "Claude on Vertex (optional)", AGENTS.md config note, scope doc marked B1 implemented, `NOTICE` for MIT attribution. ## Testing - [x] 51 new unit tests (config precedence/URLs, auth strategy selection + **no token logged**, message/tool conversion, SSE parse + request body, registration gate). - [x] Full suite green: **917 passed**. - [x] `npm run lint` (0 errors/0 warnings) and `npm run build` pass. - [ ] Gated live smoke (`PILOOP_E2E=1` + `PILOOP_VERTEX_ANTHROPIC=1`) — added but not run here (needs live GCP creds); skips cleanly by default. ## Checklist - [x] Self-reviewed the diff - [x] Code follows project conventions (deterministic seams unit-tested; LLM stream as black box) - [x] Descriptive naming - [x] Documentation + MIT attribution updated Closes #27
Vendor pi-provider-vertex-anthropic@0.1.3 (MIT) into src/model/vertexAnthropic/
and register it on the SDK ModelRuntime, gated by PILOOP_VERTEX_ANTHROPIC=1.
Default OFF leaves all existing providers unchanged.

- Add exact dep @earendil-works/pi-ai@0.81.1 (matches bundled SDK).
- Vendor config/auth/shell/models (pure) + messages/vertex-api (imports
  re-pointed to @earendil-works/pi-ai; .js extensions; strict-null guards).
- registerVertexAnthropic + env-gated maybeRegisterVertexAnthropic wired into
  createPiStageSession.
- Unit tests for config, auth (no token logged), messages, SSE/request body,
  and the registration gate; gated e2e smoke (PILOOP_E2E=1 + flag).
- Docs: README 'Claude on Vertex (optional)', AGENTS.md, scope doc marked
  B1 implemented; NOTICE for MIT attribution.

Closes #27
- Add src/model and src/model/vertexAnthropic barrels; import the provider
  registration seam via the module barrel instead of a deep import (High).
- Narrow parseSSE to a local VertexSSEEvent type instead of any (Medium).
- Log message-only diagnostics on each auth strategy's failure path so the
  SA -> ADC -> gcloud fall-through is observable; add tests (Low).
- Document the console.error diagnostics deviation and retained-but-unused
  spawn helper; clarify the enableThinkingBudget model gate (Low/Medium).
- Update NOTICE + per-file provenance headers to match the actual deltas.
- Add model barrel test.
david changed title from WIP: Support Claude on Vertex AI (vendor + register vertex-anthropic provider) — B1 to Support Claude on Vertex AI (vendor + register vertex-anthropic provider) — B1 2026-08-10 01:32:38 +00:00
david merged commit d0f99f5c30 into main 2026-08-10 01:32:45 +00:00
david deleted branch issue-27/vertex-anthropic-provider 2026-08-10 01:32:45 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
david/pi-loop!169
No description provided.