|
| 1 | +# Scaffolded Provider Modes Implementation Plan |
| 2 | + |
| 3 | +> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. |
| 4 | +
|
| 5 | +**Goal:** Implement the 6 scaffolded provider modes in `workflow-plugin-agent/provider`, replacing the `"not yet implemented"` stubs with working code. |
| 6 | + |
| 7 | +**Architecture:** Each scaffolded provider already has its config struct, AuthModeInfo, and interface stubs. Implementation adds HTTP request construction, authentication, and response parsing specific to each cloud platform's API. |
| 8 | + |
| 9 | +**Tech Stack:** Go 1.26, AWS SDK v2 (Bedrock), Google Cloud Auth (Vertex), Azure REST API (Foundry/Azure OpenAI), GitHub REST API (Models) |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +## Research Prerequisites |
| 14 | + |
| 15 | +Before implementing each provider, read the relevant API documentation: |
| 16 | + |
| 17 | +| Provider | API Reference | Auth Mechanism | |
| 18 | +|---|---|---| |
| 19 | +| GitHub Models | https://docs.github.com/en/rest/models/inference | PAT with `models:read` scope, `Authorization: Bearer <token>` | |
| 20 | +| Anthropic Bedrock | https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_Converse.html | AWS SigV4 via `aws-sdk-go-v2` | |
| 21 | +| Anthropic Vertex | https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/use-claude | GCP ADC → OAuth2 bearer token | |
| 22 | +| Anthropic Foundry | https://learn.microsoft.com/en-us/azure/ai-services/model-catalog/how-to/deploy-models-serverless | Azure API key or Entra ID token | |
| 23 | +| OpenAI Azure | https://learn.microsoft.com/en-us/azure/ai-services/openai/reference | `api-key` header or Entra ID bearer | |
| 24 | +| OpenRouter | https://openrouter.ai/docs/api/reference/authentication | `Authorization: Bearer <key>` (OpenAI-compatible) | |
| 25 | + |
| 26 | +--- |
| 27 | + |
| 28 | +## Task 1: GitHub Models Provider (`copilot_models.go`) |
| 29 | + |
| 30 | +**Files:** |
| 31 | +- Modify: `workflow-plugin-agent/provider/copilot_models.go` |
| 32 | +- Create: `workflow-plugin-agent/provider/copilot_models_test.go` |
| 33 | + |
| 34 | +**Implementation Notes:** |
| 35 | +- Endpoint: `POST https://models.github.ai/inference/chat/completions` |
| 36 | +- Auth: `Authorization: Bearer <PAT>` (fine-grained PAT with `models:read`) |
| 37 | +- Request/response format: OpenAI-compatible chat completions |
| 38 | +- Model IDs include vendor prefix: `openai/gpt-4o`, `anthropic/claude-sonnet-4` |
| 39 | +- Can likely reuse OpenAI provider's request/response parsing with different base URL and auth header |
| 40 | +- Streaming: SSE format identical to OpenAI |
| 41 | + |
| 42 | +**Test Strategy:** |
| 43 | +- Mock HTTP server returning OpenAI-compatible responses |
| 44 | +- Test PAT auth header is set correctly |
| 45 | +- Test model ID passthrough (vendor-prefixed) |
| 46 | + |
| 47 | +--- |
| 48 | + |
| 49 | +## Task 2: OpenRouter Dedicated Type (`openrouter.go`) |
| 50 | + |
| 51 | +**Files:** |
| 52 | +- Modify: `workflow-plugin-agent/provider/openrouter.go` |
| 53 | +- Create: `workflow-plugin-agent/provider/openrouter_test.go` |
| 54 | + |
| 55 | +**Implementation Notes:** |
| 56 | +- Currently `NewOpenRouterProvider` returns `*OpenAIProvider` — create a wrapper type `OpenRouterProvider` that embeds `*OpenAIProvider` and overrides `Name()` and `AuthModeInfo()` |
| 57 | +- Adds proper `X-Title` and `HTTP-Referer` headers (OpenRouter-specific) |
| 58 | +- Everything else delegates to OpenAI provider |
| 59 | + |
| 60 | +**Test Strategy:** |
| 61 | +- Verify Name() returns "openrouter" |
| 62 | +- Verify AuthModeInfo() returns openrouter-specific info |
| 63 | +- Verify OpenRouter-specific headers are set |
| 64 | + |
| 65 | +--- |
| 66 | + |
| 67 | +## Task 3: Anthropic Bedrock Provider (`anthropic_bedrock.go`) |
| 68 | + |
| 69 | +**Files:** |
| 70 | +- Modify: `workflow-plugin-agent/provider/anthropic_bedrock.go` |
| 71 | +- Create: `workflow-plugin-agent/provider/anthropic_bedrock_test.go` |
| 72 | +- Modify: `workflow-plugin-agent/go.mod` (add `aws-sdk-go-v2` dependencies) |
| 73 | + |
| 74 | +**Implementation Notes:** |
| 75 | +- Endpoint: `POST https://bedrock-runtime.{region}.amazonaws.com/model/{model}/converse` |
| 76 | +- Auth: AWS SigV4 via `aws-sdk-go-v2/config` credential chain |
| 77 | +- Request format: Bedrock Converse API (different from Anthropic Messages API) |
| 78 | + - Messages use `role`/`content` but content is structured blocks |
| 79 | + - Tools use Bedrock's tool schema format |
| 80 | +- Response format: Bedrock Converse response (map to provider.Response) |
| 81 | +- Streaming: Bedrock uses event stream encoding, not SSE |
| 82 | + |
| 83 | +**Dependencies:** |
| 84 | +``` |
| 85 | +github.com/aws/aws-sdk-go-v2 |
| 86 | +github.com/aws/aws-sdk-go-v2/config |
| 87 | +github.com/aws/aws-sdk-go-v2/credentials |
| 88 | +github.com/aws/aws-sdk-go-v2/service/bedrockruntime |
| 89 | +``` |
| 90 | + |
| 91 | +**Test Strategy:** |
| 92 | +- Mock Bedrock Converse API endpoint |
| 93 | +- Test credential chain configuration |
| 94 | +- Test request/response format conversion |
| 95 | +- Test region in URL construction |
| 96 | + |
| 97 | +--- |
| 98 | + |
| 99 | +## Task 4: Anthropic Vertex AI Provider (`anthropic_vertex.go`) |
| 100 | + |
| 101 | +**Files:** |
| 102 | +- Modify: `workflow-plugin-agent/provider/anthropic_vertex.go` |
| 103 | +- Create: `workflow-plugin-agent/provider/anthropic_vertex_test.go` |
| 104 | + |
| 105 | +**Implementation Notes:** |
| 106 | +- Endpoint: `POST https://{region}-aiplatform.googleapis.com/v1/projects/{project}/locations/{region}/publishers/anthropic/models/{model}:streamRawPredict` |
| 107 | +- Auth: GCP Application Default Credentials → OAuth2 bearer token |
| 108 | +- Request format: Anthropic Messages API (same as direct, wrapped in Vertex envelope) |
| 109 | +- Response format: Anthropic Messages response |
| 110 | +- Key difference: URL structure and auth mechanism; message format is identical to direct Anthropic |
| 111 | + |
| 112 | +**Dependencies:** |
| 113 | +``` |
| 114 | +golang.org/x/oauth2/google (for ADC) |
| 115 | +``` |
| 116 | + |
| 117 | +**Test Strategy:** |
| 118 | +- Mock Vertex AI endpoint |
| 119 | +- Test URL construction with project/region |
| 120 | +- Test ADC credential resolution |
| 121 | +- Test that request body matches Anthropic Messages format |
| 122 | + |
| 123 | +--- |
| 124 | + |
| 125 | +## Task 5: Anthropic Azure Foundry Provider (`anthropic_foundry.go`) |
| 126 | + |
| 127 | +**Files:** |
| 128 | +- Modify: `workflow-plugin-agent/provider/anthropic_foundry.go` |
| 129 | +- Create: `workflow-plugin-agent/provider/anthropic_foundry_test.go` |
| 130 | + |
| 131 | +**Implementation Notes:** |
| 132 | +- Endpoint: `POST https://{resource}.services.ai.azure.com/anthropic/v1/messages` |
| 133 | +- Auth: `api-key` header (Azure API key) OR `Authorization: Bearer <token>` (Entra ID) |
| 134 | +- Request format: Anthropic Messages API |
| 135 | +- Response format: Anthropic Messages response |
| 136 | +- Very similar to direct Anthropic — mainly URL and auth differ |
| 137 | + |
| 138 | +**Test Strategy:** |
| 139 | +- Mock Azure AI Foundry endpoint |
| 140 | +- Test both API key and Entra ID auth paths |
| 141 | +- Test URL construction with resource name |
| 142 | + |
| 143 | +--- |
| 144 | + |
| 145 | +## Task 6: Azure OpenAI Provider (`openai_azure.go`) |
| 146 | + |
| 147 | +**Files:** |
| 148 | +- Modify: `workflow-plugin-agent/provider/openai_azure.go` |
| 149 | +- Create: `workflow-plugin-agent/provider/openai_azure_test.go` |
| 150 | + |
| 151 | +**Implementation Notes:** |
| 152 | +- Endpoint: `POST https://{resource}.openai.azure.com/openai/deployments/{deployment}/chat/completions?api-version={version}` |
| 153 | +- Auth: `api-key` header (Azure key) OR `Authorization: Bearer <token>` (Entra ID) |
| 154 | +- Request format: OpenAI Chat Completions (identical) |
| 155 | +- Response format: OpenAI Chat Completions (identical) |
| 156 | +- Key differences: URL structure (deployment-based), API version query param, auth header name |
| 157 | + |
| 158 | +**Test Strategy:** |
| 159 | +- Mock Azure OpenAI endpoint |
| 160 | +- Test URL construction with resource/deployment/api-version |
| 161 | +- Test both API key and Entra ID auth |
| 162 | +- Test that request/response format matches OpenAI |
| 163 | + |
| 164 | +--- |
| 165 | + |
| 166 | +## Task 7: Integration into provider_registry.go |
| 167 | + |
| 168 | +**Files:** |
| 169 | +- Modify: `ratchet/ratchetplugin/provider_registry.go` |
| 170 | + |
| 171 | +**Implementation Notes:** |
| 172 | +- Add factory functions for each new provider type |
| 173 | +- Register in `NewProviderRegistry()`: |
| 174 | + - `"copilot_models"` → `copilotModelsProviderFactory` |
| 175 | + - `"anthropic_bedrock"` → `anthropicBedrockProviderFactory` |
| 176 | + - `"anthropic_vertex"` → `anthropicVertexProviderFactory` |
| 177 | + - `"anthropic_foundry"` → `anthropicFoundryProviderFactory` |
| 178 | + - `"openai_azure"` → `openaiAzureProviderFactory` |
| 179 | +- Update `LLMProviderConfig` if new fields needed (region, project_id, resource, deployment) |
| 180 | + |
| 181 | +--- |
| 182 | + |
| 183 | +## Task 8: Update ListModels() for new providers |
| 184 | + |
| 185 | +**Files:** |
| 186 | +- Modify: `workflow-plugin-agent/provider/models.go` |
| 187 | + |
| 188 | +**Implementation Notes:** |
| 189 | +- Add cases for each new provider type in `ListModels()` switch |
| 190 | +- Implement model listing for providers that support it: |
| 191 | + - GitHub Models: `GET https://models.github.ai/inference/models` |
| 192 | + - Azure OpenAI: `GET https://{resource}.openai.azure.com/openai/models?api-version={version}` |
| 193 | + - Bedrock: Use `ListFoundationModels` API |
| 194 | + - Others: fallback model lists |
| 195 | + |
| 196 | +--- |
| 197 | + |
| 198 | +## Task 9: Tag and release |
| 199 | + |
| 200 | +Tag `workflow-plugin-agent` v0.3.0, update ratchet and ratchet-cli dependencies, tag both. |
| 201 | + |
| 202 | +--- |
| 203 | + |
| 204 | +## Priority Order |
| 205 | + |
| 206 | +Recommended implementation order (easiest → hardest): |
| 207 | +1. **OpenRouter** (Task 2) — wrapper type only, minutes of work |
| 208 | +2. **GitHub Models** (Task 1) — OpenAI-compatible, just different URL + auth |
| 209 | +3. **Azure OpenAI** (Task 6) — OpenAI-compatible, URL/auth differences |
| 210 | +4. **Anthropic Foundry** (Task 5) — Anthropic Messages format, different URL/auth |
| 211 | +5. **Anthropic Vertex** (Task 4) — Anthropic Messages + GCP ADC |
| 212 | +6. **Anthropic Bedrock** (Task 3) — Different API format (Converse), AWS SDK dependency |
0 commit comments