feat(ai): move API implementations to src/api with lazy wrappers (phase 2)
Stream implementations move from src/providers/ to src/api/, renamed by API id (anthropic.ts -> anthropic-messages.ts, google.ts -> google-generative-ai.ts, mistral.ts -> mistral-conversations.ts, amazon-bedrock.ts -> bedrock-converse-stream.ts). Every module now exports exactly stream/streamSimple; shared helpers move alongside. New ProviderStreams dispatch contract in types.ts, lazyApi() wrapper in api/lazy.ts, and one .lazy.ts wrapper per API. Bedrock's wrapper keeps the node-only variable-specifier import and setBedrockProviderModule() (now taking ProviderStreams). providers/register-builtins.ts deleted; interim until the compat entrypoint lands, builtin api-registry registration lives in stream.ts and lazy wrappers are exported from the root barrel. Old per-API lazy exports (streamAnthropic, ...) are gone; package.json subpaths retarget to dist/api/.
This commit is contained in:
@@ -153,7 +153,7 @@ async function refreshAnthropicToken(credentials: OAuthCredentials): Promise<OAu
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Streaming Implementation (simplified from packages/ai/src/providers/anthropic.ts)
|
||||
// Streaming Implementation (simplified from packages/ai/src/api/anthropic-messages.ts)
|
||||
// =============================================================================
|
||||
|
||||
// Claude Code tool names for OAuth stealth mode
|
||||
|
||||
@@ -12,14 +12,14 @@
|
||||
import {
|
||||
type Api,
|
||||
type AssistantMessageEventStream,
|
||||
anthropicMessagesApi,
|
||||
type Context,
|
||||
createAssistantMessageEventStream,
|
||||
type Model,
|
||||
type OAuthCredentials,
|
||||
type OAuthLoginCallbacks,
|
||||
openAIResponsesApi,
|
||||
type SimpleStreamOptions,
|
||||
streamSimpleAnthropic,
|
||||
streamSimpleOpenAIResponses,
|
||||
type ThinkingLevelMap,
|
||||
} from "@earendil-works/pi-ai";
|
||||
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
||||
@@ -325,7 +325,7 @@ export function streamGitLabDuo(
|
||||
|
||||
const innerStream =
|
||||
cfg.backend === "anthropic"
|
||||
? streamSimpleAnthropic(
|
||||
? anthropicMessagesApi().streamSimple(
|
||||
{
|
||||
...(modelWithBaseUrl as Model<"anthropic-messages">),
|
||||
compat: {
|
||||
@@ -336,7 +336,11 @@ export function streamGitLabDuo(
|
||||
context,
|
||||
streamOptions,
|
||||
)
|
||||
: streamSimpleOpenAIResponses(modelWithBaseUrl as Model<"openai-responses">, context, streamOptions);
|
||||
: openAIResponsesApi().streamSimple(
|
||||
modelWithBaseUrl as Model<"openai-responses">,
|
||||
context,
|
||||
streamOptions,
|
||||
);
|
||||
|
||||
for await (const event of innerStream) stream.push(event);
|
||||
stream.end();
|
||||
|
||||
Reference in New Issue
Block a user