beth-copilot 1.0.18 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -28
- package/README.md +87 -247
- package/bin/cli.js +158 -358
- package/dist/__tests__/smoke.test.d.ts +8 -0
- package/dist/__tests__/smoke.test.d.ts.map +1 -0
- package/dist/__tests__/smoke.test.js +49 -0
- package/dist/__tests__/smoke.test.js.map +1 -0
- package/dist/cli/commands/beads.e2e.test.d.ts +13 -0
- package/dist/cli/commands/beads.e2e.test.d.ts.map +1 -0
- package/dist/cli/commands/beads.e2e.test.js +526 -0
- package/dist/cli/commands/beads.e2e.test.js.map +1 -0
- package/dist/cli/commands/cli-edge-cases.e2e.test.d.ts +32 -0
- package/dist/cli/commands/cli-edge-cases.e2e.test.d.ts.map +1 -0
- package/dist/cli/commands/cli-edge-cases.e2e.test.js +162 -0
- package/dist/cli/commands/cli-edge-cases.e2e.test.js.map +1 -0
- package/dist/cli/commands/close.d.ts +89 -0
- package/dist/cli/commands/close.d.ts.map +1 -0
- package/dist/cli/commands/close.e2e.test.d.ts +27 -0
- package/dist/cli/commands/close.e2e.test.d.ts.map +1 -0
- package/dist/cli/commands/close.e2e.test.js +252 -0
- package/dist/cli/commands/close.e2e.test.js.map +1 -0
- package/dist/cli/commands/close.js +309 -0
- package/dist/cli/commands/close.js.map +1 -0
- package/dist/cli/commands/close.test.d.ts +15 -0
- package/dist/cli/commands/close.test.d.ts.map +1 -0
- package/dist/cli/commands/close.test.js +634 -0
- package/dist/cli/commands/close.test.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts +23 -0
- package/dist/cli/commands/doctor.d.ts.map +1 -1
- package/dist/cli/commands/doctor.js +93 -0
- package/dist/cli/commands/doctor.js.map +1 -1
- package/dist/cli/commands/doctor.test.js +209 -0
- package/dist/cli/commands/doctor.test.js.map +1 -1
- package/dist/cli/commands/framework-isolation.test.d.ts +30 -0
- package/dist/cli/commands/framework-isolation.test.d.ts.map +1 -0
- package/dist/cli/commands/framework-isolation.test.js +119 -0
- package/dist/cli/commands/framework-isolation.test.js.map +1 -0
- package/dist/cli/commands/help.e2e.test.js +4 -4
- package/dist/cli/commands/help.e2e.test.js.map +1 -1
- package/dist/cli/commands/init-logic.e2e.test.d.ts +37 -0
- package/dist/cli/commands/init-logic.e2e.test.d.ts.map +1 -0
- package/dist/cli/commands/init-logic.e2e.test.js +305 -0
- package/dist/cli/commands/init-logic.e2e.test.js.map +1 -0
- package/dist/cli/commands/land.d.ts +142 -0
- package/dist/cli/commands/land.d.ts.map +1 -0
- package/dist/cli/commands/land.js +647 -0
- package/dist/cli/commands/land.js.map +1 -0
- package/dist/cli/commands/land.test.d.ts +20 -0
- package/dist/cli/commands/land.test.d.ts.map +1 -0
- package/dist/cli/commands/land.test.js +622 -0
- package/dist/cli/commands/land.test.js.map +1 -0
- package/dist/cli/commands/mcp.e2e.test.js +22 -29
- package/dist/cli/commands/mcp.e2e.test.js.map +1 -1
- package/dist/cli/commands/pipeline.e2e.test.js +20 -20
- package/dist/cli/commands/pipeline.e2e.test.js.map +1 -1
- package/dist/cli/commands/pre-push-guard.d.ts +84 -0
- package/dist/cli/commands/pre-push-guard.d.ts.map +1 -0
- package/dist/cli/commands/pre-push-guard.e2e.test.d.ts +24 -0
- package/dist/cli/commands/pre-push-guard.e2e.test.d.ts.map +1 -0
- package/dist/cli/commands/pre-push-guard.e2e.test.js +171 -0
- package/dist/cli/commands/pre-push-guard.e2e.test.js.map +1 -0
- package/dist/cli/commands/pre-push-guard.js +257 -0
- package/dist/cli/commands/pre-push-guard.js.map +1 -0
- package/dist/cli/commands/pre-push-guard.test.d.ts +15 -0
- package/dist/cli/commands/pre-push-guard.test.d.ts.map +1 -0
- package/dist/cli/commands/pre-push-guard.test.js +397 -0
- package/dist/cli/commands/pre-push-guard.test.js.map +1 -0
- package/dist/cli/commands/quickstart-expanded.e2e.test.d.ts +23 -0
- package/dist/cli/commands/quickstart-expanded.e2e.test.d.ts.map +1 -0
- package/dist/cli/commands/quickstart-expanded.e2e.test.js +179 -0
- package/dist/cli/commands/quickstart-expanded.e2e.test.js.map +1 -0
- package/dist/cli/commands/quickstart.d.ts.map +1 -1
- package/dist/cli/commands/quickstart.js +7 -23
- package/dist/cli/commands/quickstart.js.map +1 -1
- package/dist/cli/commands/quickstart.test.js +40 -67
- package/dist/cli/commands/quickstart.test.js.map +1 -1
- package/dist/core/agents/suite.test.js +4 -2
- package/dist/core/agents/suite.test.js.map +1 -1
- package/dist/core/agents/tools.test.js +5 -1
- package/dist/core/agents/tools.test.js.map +1 -1
- package/dist/index.d.ts +3 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -10
- package/dist/index.js.map +1 -1
- package/package.json +15 -9
- package/sbom.json +2011 -819
- package/templates/.github/agents/beth.agent.md +220 -66
- package/templates/.github/agents/developer.agent.md +53 -90
- package/templates/.github/agents/product-manager.agent.md +15 -68
- package/templates/.github/agents/researcher.agent.md +20 -71
- package/templates/.github/agents/security-reviewer.agent.md +29 -81
- package/templates/.github/agents/tester.agent.md +40 -69
- package/templates/.github/agents/ux-designer.agent.md +20 -74
- package/templates/.github/copilot-instructions.md +217 -225
- package/templates/AGENTS.md +108 -20
- package/templates/mcp.json.example +0 -3
- package/dist/cli/commands/client-config.d.ts +0 -31
- package/dist/cli/commands/client-config.d.ts.map +0 -1
- package/dist/cli/commands/client-config.e2e.test.d.ts +0 -15
- package/dist/cli/commands/client-config.e2e.test.d.ts.map +0 -1
- package/dist/cli/commands/client-config.e2e.test.js +0 -556
- package/dist/cli/commands/client-config.e2e.test.js.map +0 -1
- package/dist/cli/commands/client-config.js +0 -73
- package/dist/cli/commands/client-config.js.map +0 -1
- package/dist/cli/commands/client-config.test.d.ts +0 -6
- package/dist/cli/commands/client-config.test.d.ts.map +0 -1
- package/dist/cli/commands/client-config.test.js +0 -133
- package/dist/cli/commands/client-config.test.js.map +0 -1
- package/dist/cli/commands/init-quickstart.e2e.test.d.ts +0 -11
- package/dist/cli/commands/init-quickstart.e2e.test.d.ts.map +0 -1
- package/dist/cli/commands/init-quickstart.e2e.test.js +0 -221
- package/dist/cli/commands/init-quickstart.e2e.test.js.map +0 -1
- package/dist/core/context.d.ts +0 -171
- package/dist/core/context.d.ts.map +0 -1
- package/dist/core/context.js +0 -353
- package/dist/core/context.js.map +0 -1
- package/dist/core/context.test.d.ts +0 -8
- package/dist/core/context.test.d.ts.map +0 -1
- package/dist/core/context.test.js +0 -253
- package/dist/core/context.test.js.map +0 -1
- package/dist/core/handoffs.d.ts +0 -151
- package/dist/core/handoffs.d.ts.map +0 -1
- package/dist/core/handoffs.js +0 -220
- package/dist/core/handoffs.js.map +0 -1
- package/dist/core/handoffs.test.d.ts +0 -8
- package/dist/core/handoffs.test.d.ts.map +0 -1
- package/dist/core/handoffs.test.js +0 -231
- package/dist/core/handoffs.test.js.map +0 -1
- package/dist/core/orchestrator.d.ts +0 -246
- package/dist/core/orchestrator.d.ts.map +0 -1
- package/dist/core/orchestrator.js +0 -514
- package/dist/core/orchestrator.js.map +0 -1
- package/dist/core/orchestrator.test.d.ts +0 -8
- package/dist/core/orchestrator.test.d.ts.map +0 -1
- package/dist/core/orchestrator.test.js +0 -517
- package/dist/core/orchestrator.test.js.map +0 -1
- package/dist/core/router.d.ts +0 -102
- package/dist/core/router.d.ts.map +0 -1
- package/dist/core/router.js +0 -178
- package/dist/core/router.js.map +0 -1
- package/dist/core/router.test.d.ts +0 -8
- package/dist/core/router.test.d.ts.map +0 -1
- package/dist/core/router.test.js +0 -215
- package/dist/core/router.test.js.map +0 -1
- package/dist/init.test.js +0 -288
- package/dist/providers/azure.d.ts +0 -147
- package/dist/providers/azure.d.ts.map +0 -1
- package/dist/providers/azure.js +0 -491
- package/dist/providers/azure.js.map +0 -1
- package/dist/providers/azure.test.d.ts +0 -11
- package/dist/providers/azure.test.d.ts.map +0 -1
- package/dist/providers/azure.test.js +0 -330
- package/dist/providers/azure.test.js.map +0 -1
- package/dist/providers/config.d.ts +0 -87
- package/dist/providers/config.d.ts.map +0 -1
- package/dist/providers/config.js +0 -193
- package/dist/providers/config.js.map +0 -1
- package/dist/providers/config.test.d.ts +0 -7
- package/dist/providers/config.test.d.ts.map +0 -1
- package/dist/providers/config.test.js +0 -370
- package/dist/providers/config.test.js.map +0 -1
- package/dist/providers/index.d.ts +0 -18
- package/dist/providers/index.d.ts.map +0 -1
- package/dist/providers/index.js +0 -14
- package/dist/providers/index.js.map +0 -1
- package/dist/providers/interface.d.ts +0 -191
- package/dist/providers/interface.d.ts.map +0 -1
- package/dist/providers/interface.js +0 -94
- package/dist/providers/interface.js.map +0 -1
- package/dist/providers/retry.d.ts +0 -128
- package/dist/providers/retry.d.ts.map +0 -1
- package/dist/providers/retry.js +0 -205
- package/dist/providers/retry.js.map +0 -1
- package/dist/providers/retry.test.d.ts +0 -7
- package/dist/providers/retry.test.d.ts.map +0 -1
- package/dist/providers/retry.test.js +0 -439
- package/dist/providers/retry.test.js.map +0 -1
- package/dist/providers/streaming.d.ts +0 -157
- package/dist/providers/streaming.d.ts.map +0 -1
- package/dist/providers/streaming.js +0 -233
- package/dist/providers/streaming.js.map +0 -1
- package/dist/providers/streaming.test.d.ts +0 -7
- package/dist/providers/streaming.test.d.ts.map +0 -1
- package/dist/providers/streaming.test.js +0 -372
- package/dist/providers/streaming.test.js.map +0 -1
- package/dist/providers/types.d.ts +0 -209
- package/dist/providers/types.d.ts.map +0 -1
- package/dist/providers/types.js +0 -53
- package/dist/providers/types.js.map +0 -1
- package/dist/providers/types.test.d.ts +0 -7
- package/dist/providers/types.test.d.ts.map +0 -1
- package/dist/providers/types.test.js +0 -141
- package/dist/providers/types.test.js.map +0 -1
- package/dist/tools/cli/beads.d.ts +0 -27
- package/dist/tools/cli/beads.d.ts.map +0 -1
- package/dist/tools/cli/beads.js +0 -172
- package/dist/tools/cli/beads.js.map +0 -1
- package/dist/tools/cli/beads.test.d.ts +0 -8
- package/dist/tools/cli/beads.test.d.ts.map +0 -1
- package/dist/tools/cli/beads.test.js +0 -264
- package/dist/tools/cli/beads.test.js.map +0 -1
- package/dist/tools/cli/editFile.d.ts +0 -17
- package/dist/tools/cli/editFile.d.ts.map +0 -1
- package/dist/tools/cli/editFile.js +0 -125
- package/dist/tools/cli/editFile.js.map +0 -1
- package/dist/tools/cli/editFile.test.d.ts +0 -8
- package/dist/tools/cli/editFile.test.d.ts.map +0 -1
- package/dist/tools/cli/editFile.test.js +0 -177
- package/dist/tools/cli/editFile.test.js.map +0 -1
- package/dist/tools/cli/readFile.d.ts +0 -25
- package/dist/tools/cli/readFile.d.ts.map +0 -1
- package/dist/tools/cli/readFile.js +0 -118
- package/dist/tools/cli/readFile.js.map +0 -1
- package/dist/tools/cli/readFile.test.d.ts +0 -8
- package/dist/tools/cli/readFile.test.d.ts.map +0 -1
- package/dist/tools/cli/readFile.test.js +0 -194
- package/dist/tools/cli/readFile.test.js.map +0 -1
- package/dist/tools/cli/search.d.ts +0 -16
- package/dist/tools/cli/search.d.ts.map +0 -1
- package/dist/tools/cli/search.js +0 -261
- package/dist/tools/cli/search.js.map +0 -1
- package/dist/tools/cli/search.test.d.ts +0 -8
- package/dist/tools/cli/search.test.d.ts.map +0 -1
- package/dist/tools/cli/search.test.js +0 -172
- package/dist/tools/cli/search.test.js.map +0 -1
- package/dist/tools/cli/subagent.d.ts +0 -43
- package/dist/tools/cli/subagent.d.ts.map +0 -1
- package/dist/tools/cli/subagent.js +0 -99
- package/dist/tools/cli/subagent.js.map +0 -1
- package/dist/tools/cli/subagent.test.d.ts +0 -8
- package/dist/tools/cli/subagent.test.d.ts.map +0 -1
- package/dist/tools/cli/subagent.test.js +0 -190
- package/dist/tools/cli/subagent.test.js.map +0 -1
- package/dist/tools/cli/terminal.d.ts +0 -19
- package/dist/tools/cli/terminal.d.ts.map +0 -1
- package/dist/tools/cli/terminal.js +0 -164
- package/dist/tools/cli/terminal.js.map +0 -1
- package/dist/tools/cli/terminal.test.d.ts +0 -8
- package/dist/tools/cli/terminal.test.d.ts.map +0 -1
- package/dist/tools/cli/terminal.test.js +0 -161
- package/dist/tools/cli/terminal.test.js.map +0 -1
- package/dist/tools/index.d.ts +0 -25
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/index.js +0 -41
- package/dist/tools/index.js.map +0 -1
- package/dist/tools/interface.d.ts +0 -64
- package/dist/tools/interface.d.ts.map +0 -1
- package/dist/tools/interface.js +0 -37
- package/dist/tools/interface.js.map +0 -1
- package/dist/tools/interface.test.d.ts +0 -7
- package/dist/tools/interface.test.d.ts.map +0 -1
- package/dist/tools/interface.test.js +0 -179
- package/dist/tools/interface.test.js.map +0 -1
- package/dist/tools/mcp/bridge.d.ts +0 -48
- package/dist/tools/mcp/bridge.d.ts.map +0 -1
- package/dist/tools/mcp/bridge.js +0 -128
- package/dist/tools/mcp/bridge.js.map +0 -1
- package/dist/tools/mcp/bridge.test.d.ts +0 -8
- package/dist/tools/mcp/bridge.test.d.ts.map +0 -1
- package/dist/tools/mcp/bridge.test.js +0 -300
- package/dist/tools/mcp/bridge.test.js.map +0 -1
- package/dist/tools/mcp/client.d.ts +0 -135
- package/dist/tools/mcp/client.d.ts.map +0 -1
- package/dist/tools/mcp/client.js +0 -263
- package/dist/tools/mcp/client.js.map +0 -1
- package/dist/tools/mcp/client.test.d.ts +0 -8
- package/dist/tools/mcp/client.test.d.ts.map +0 -1
- package/dist/tools/mcp/client.test.js +0 -390
- package/dist/tools/mcp/client.test.js.map +0 -1
- package/dist/tools/registry.d.ts +0 -82
- package/dist/tools/registry.d.ts.map +0 -1
- package/dist/tools/registry.js +0 -99
- package/dist/tools/registry.js.map +0 -1
- package/dist/tools/registry.test.d.ts +0 -7
- package/dist/tools/registry.test.d.ts.map +0 -1
- package/dist/tools/registry.test.js +0 -199
- package/dist/tools/registry.test.js.map +0 -1
- package/dist/tools/suite.test.d.ts +0 -11
- package/dist/tools/suite.test.d.ts.map +0 -1
- package/dist/tools/suite.test.js +0 -119
- package/dist/tools/suite.test.js.map +0 -1
- package/dist/tools/types.d.ts +0 -75
- package/dist/tools/types.d.ts.map +0 -1
- package/dist/tools/types.js +0 -30
- package/dist/tools/types.js.map +0 -1
- package/dist/tools/types.test.d.ts +0 -7
- package/dist/tools/types.test.d.ts.map +0 -1
- package/dist/tools/types.test.js +0 -178
- package/dist/tools/types.test.js.map +0 -1
- package/templates/.vscode/mcp.json +0 -20
- package/templates/CLAUDE.md +0 -129
package/dist/providers/azure.js
DELETED
|
@@ -1,491 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Azure OpenAI Provider
|
|
3
|
-
*
|
|
4
|
-
* LLM provider implementation for Azure OpenAI using the Responses API.
|
|
5
|
-
* Uses Entra ID authentication via TokenCredential.
|
|
6
|
-
*/
|
|
7
|
-
import { AzureOpenAI } from 'openai';
|
|
8
|
-
import { getBearerTokenProvider } from '@azure/identity';
|
|
9
|
-
import { LLMError } from './types.js';
|
|
10
|
-
import { LLMProviderBase } from './interface.js';
|
|
11
|
-
import { retry, isTransientError } from './retry.js';
|
|
12
|
-
// =============================================================================
|
|
13
|
-
// Constants
|
|
14
|
-
// =============================================================================
|
|
15
|
-
/** Azure Cognitive Services scope for token acquisition */
|
|
16
|
-
const AZURE_COGNITIVE_SERVICES_SCOPE = 'https://cognitiveservices.azure.com/.default';
|
|
17
|
-
/** Provider name identifier */
|
|
18
|
-
const PROVIDER_NAME = 'azure-openai';
|
|
19
|
-
// =============================================================================
|
|
20
|
-
// Azure OpenAI Provider
|
|
21
|
-
// =============================================================================
|
|
22
|
-
/**
|
|
23
|
-
* Azure OpenAI provider implementation.
|
|
24
|
-
*
|
|
25
|
-
* Uses the OpenAI SDK's AzureOpenAI client with Entra ID authentication.
|
|
26
|
-
* Supports both streaming and non-streaming chat completions with tool calling.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```typescript
|
|
30
|
-
* import { DefaultAzureCredential } from '@azure/identity';
|
|
31
|
-
*
|
|
32
|
-
* const provider = new AzureOpenAIProvider({
|
|
33
|
-
* provider: 'azure-openai',
|
|
34
|
-
* endpoint: 'https://my-resource.openai.azure.com',
|
|
35
|
-
* model: 'gpt-4',
|
|
36
|
-
* credential: new DefaultAzureCredential(),
|
|
37
|
-
* apiVersion: '2025-03-01-preview',
|
|
38
|
-
* });
|
|
39
|
-
*
|
|
40
|
-
* const response = await provider.chat([
|
|
41
|
-
* { role: 'user', content: 'Hello!' }
|
|
42
|
-
* ]);
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
|
-
export class AzureOpenAIProvider extends LLMProviderBase {
|
|
46
|
-
/** Azure OpenAI client instance */
|
|
47
|
-
client;
|
|
48
|
-
/**
|
|
49
|
-
* Create a new Azure OpenAI provider instance.
|
|
50
|
-
*
|
|
51
|
-
* @param config - Provider configuration with Entra ID credentials
|
|
52
|
-
*/
|
|
53
|
-
constructor(config) {
|
|
54
|
-
super(config);
|
|
55
|
-
// Create token provider from TokenCredential
|
|
56
|
-
const tokenProvider = getBearerTokenProvider(config.credential, AZURE_COGNITIVE_SERVICES_SCOPE);
|
|
57
|
-
// Initialize AzureOpenAI client with Entra ID auth
|
|
58
|
-
this.client = new AzureOpenAI({
|
|
59
|
-
endpoint: config.endpoint,
|
|
60
|
-
deployment: config.model,
|
|
61
|
-
apiVersion: config.apiVersion ?? '2025-03-01-preview',
|
|
62
|
-
azureADTokenProvider: tokenProvider,
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
// ===========================================================================
|
|
66
|
-
// Abstract Property Implementations
|
|
67
|
-
// ===========================================================================
|
|
68
|
-
/**
|
|
69
|
-
* Provider identifier.
|
|
70
|
-
*/
|
|
71
|
-
get name() {
|
|
72
|
-
return PROVIDER_NAME;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Check if the provider is properly configured.
|
|
76
|
-
*
|
|
77
|
-
* Validates that endpoint, model, and credential are present.
|
|
78
|
-
*/
|
|
79
|
-
get isConfigured() {
|
|
80
|
-
return Boolean(this.config.endpoint &&
|
|
81
|
-
this.config.model &&
|
|
82
|
-
this.config.credential);
|
|
83
|
-
}
|
|
84
|
-
// ===========================================================================
|
|
85
|
-
// Abstract Method Implementations
|
|
86
|
-
// ===========================================================================
|
|
87
|
-
/**
|
|
88
|
-
* Send a non-streaming chat completion request.
|
|
89
|
-
*
|
|
90
|
-
* @param messages - Conversation history
|
|
91
|
-
* @param options - Request options (tools, temperature, etc.)
|
|
92
|
-
* @returns Complete LLM response with message and usage stats
|
|
93
|
-
* @throws {LLMError} On API errors
|
|
94
|
-
*/
|
|
95
|
-
async chat(messages, options) {
|
|
96
|
-
return retry(async () => {
|
|
97
|
-
try {
|
|
98
|
-
const response = await this.client.chat.completions.create({
|
|
99
|
-
model: this.config.model,
|
|
100
|
-
messages: this.mapMessages(messages),
|
|
101
|
-
tools: options?.tools ? this.mapTools(options.tools) : undefined,
|
|
102
|
-
temperature: options?.temperature ?? this.config.temperature,
|
|
103
|
-
max_tokens: options?.maxTokens ?? this.config.maxTokens,
|
|
104
|
-
top_p: options?.topP ?? this.config.topP,
|
|
105
|
-
frequency_penalty: options?.frequencyPenalty ?? this.config.frequencyPenalty,
|
|
106
|
-
presence_penalty: options?.presencePenalty ?? this.config.presencePenalty,
|
|
107
|
-
stream: false,
|
|
108
|
-
}, {
|
|
109
|
-
signal: options?.signal,
|
|
110
|
-
});
|
|
111
|
-
return this.mapResponse(response);
|
|
112
|
-
}
|
|
113
|
-
catch (error) {
|
|
114
|
-
throw this.wrapError(error);
|
|
115
|
-
}
|
|
116
|
-
}, {
|
|
117
|
-
maxRetries: 3,
|
|
118
|
-
onRetry: (error, attempt, delay) => {
|
|
119
|
-
// Could add logging here if needed
|
|
120
|
-
void error;
|
|
121
|
-
void attempt;
|
|
122
|
-
void delay;
|
|
123
|
-
},
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Send a streaming chat completion request.
|
|
128
|
-
*
|
|
129
|
-
* @param messages - Conversation history
|
|
130
|
-
* @param options - Request options (tools, temperature, etc.)
|
|
131
|
-
* @yields ChatChunk objects with incremental content
|
|
132
|
-
* @throws {LLMError} On API errors
|
|
133
|
-
*/
|
|
134
|
-
async *chatStream(messages, options) {
|
|
135
|
-
let stream;
|
|
136
|
-
try {
|
|
137
|
-
stream = await this.client.chat.completions.create({
|
|
138
|
-
model: this.config.model,
|
|
139
|
-
messages: this.mapMessages(messages),
|
|
140
|
-
tools: options?.tools ? this.mapTools(options.tools) : undefined,
|
|
141
|
-
temperature: options?.temperature ?? this.config.temperature,
|
|
142
|
-
max_tokens: options?.maxTokens ?? this.config.maxTokens,
|
|
143
|
-
top_p: options?.topP ?? this.config.topP,
|
|
144
|
-
frequency_penalty: options?.frequencyPenalty ?? this.config.frequencyPenalty,
|
|
145
|
-
presence_penalty: options?.presencePenalty ?? this.config.presencePenalty,
|
|
146
|
-
stream: true,
|
|
147
|
-
}, {
|
|
148
|
-
signal: options?.signal,
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
catch (error) {
|
|
152
|
-
throw this.wrapError(error);
|
|
153
|
-
}
|
|
154
|
-
try {
|
|
155
|
-
for await (const chunk of stream) {
|
|
156
|
-
yield this.mapChunk(chunk);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
catch (error) {
|
|
160
|
-
// Handle errors during streaming
|
|
161
|
-
const wrappedError = this.wrapError(error);
|
|
162
|
-
// If it's a transient error, we could potentially retry,
|
|
163
|
-
// but for streaming we throw immediately
|
|
164
|
-
throw wrappedError;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Estimate token count for messages.
|
|
169
|
-
*
|
|
170
|
-
* Uses a rough estimation based on character count divided by 4.
|
|
171
|
-
* This is an approximation suitable for basic usage tracking and
|
|
172
|
-
* context window management.
|
|
173
|
-
*
|
|
174
|
-
* @param messages - Messages to count tokens for
|
|
175
|
-
* @returns Estimated token count
|
|
176
|
-
*/
|
|
177
|
-
async countTokens(messages) {
|
|
178
|
-
// Rough estimation: ~4 characters per token on average
|
|
179
|
-
// This is a common heuristic for English text with GPT models
|
|
180
|
-
let totalChars = 0;
|
|
181
|
-
for (const message of messages) {
|
|
182
|
-
// Count content
|
|
183
|
-
totalChars += message.content.length;
|
|
184
|
-
// Count role (approximate overhead)
|
|
185
|
-
totalChars += message.role.length + 4; // ~4 chars for formatting
|
|
186
|
-
// Count name if present
|
|
187
|
-
if (message.name) {
|
|
188
|
-
totalChars += message.name.length + 2;
|
|
189
|
-
}
|
|
190
|
-
// Count tool calls if present
|
|
191
|
-
if (message.tool_calls) {
|
|
192
|
-
for (const toolCall of message.tool_calls) {
|
|
193
|
-
totalChars += toolCall.function.name.length;
|
|
194
|
-
totalChars += toolCall.function.arguments.length;
|
|
195
|
-
totalChars += 20; // Overhead for structure
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
// Count tool_call_id if present
|
|
199
|
-
if (message.tool_call_id) {
|
|
200
|
-
totalChars += message.tool_call_id.length + 4;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
// Divide by 4 and round up for safety
|
|
204
|
-
return Math.ceil(totalChars / 4);
|
|
205
|
-
}
|
|
206
|
-
// ===========================================================================
|
|
207
|
-
// Message Mapping
|
|
208
|
-
// ===========================================================================
|
|
209
|
-
/**
|
|
210
|
-
* Map internal ChatMessage format to OpenAI API format.
|
|
211
|
-
*
|
|
212
|
-
* @param messages - Internal message format
|
|
213
|
-
* @returns OpenAI-compatible message array
|
|
214
|
-
*/
|
|
215
|
-
mapMessages(messages) {
|
|
216
|
-
return messages.map((msg) => {
|
|
217
|
-
switch (msg.role) {
|
|
218
|
-
case 'system':
|
|
219
|
-
return {
|
|
220
|
-
role: 'system',
|
|
221
|
-
content: msg.content,
|
|
222
|
-
};
|
|
223
|
-
case 'user':
|
|
224
|
-
return {
|
|
225
|
-
role: 'user',
|
|
226
|
-
content: msg.content,
|
|
227
|
-
name: msg.name,
|
|
228
|
-
};
|
|
229
|
-
case 'assistant':
|
|
230
|
-
return {
|
|
231
|
-
role: 'assistant',
|
|
232
|
-
content: msg.content,
|
|
233
|
-
tool_calls: msg.tool_calls?.map((tc) => ({
|
|
234
|
-
id: tc.id,
|
|
235
|
-
type: tc.type,
|
|
236
|
-
function: {
|
|
237
|
-
name: tc.function.name,
|
|
238
|
-
arguments: tc.function.arguments,
|
|
239
|
-
},
|
|
240
|
-
})),
|
|
241
|
-
};
|
|
242
|
-
case 'tool':
|
|
243
|
-
return {
|
|
244
|
-
role: 'tool',
|
|
245
|
-
content: msg.content,
|
|
246
|
-
tool_call_id: msg.tool_call_id ?? '',
|
|
247
|
-
};
|
|
248
|
-
default:
|
|
249
|
-
// TypeScript should catch this, but just in case
|
|
250
|
-
return {
|
|
251
|
-
role: 'user',
|
|
252
|
-
content: msg.content,
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* Map internal ToolDefinition format to OpenAI API format.
|
|
259
|
-
*
|
|
260
|
-
* @param tools - Internal tool definitions
|
|
261
|
-
* @returns OpenAI-compatible tool array
|
|
262
|
-
*/
|
|
263
|
-
mapTools(tools) {
|
|
264
|
-
return tools.map((tool) => ({
|
|
265
|
-
type: 'function',
|
|
266
|
-
function: {
|
|
267
|
-
name: tool.function.name,
|
|
268
|
-
description: tool.function.description,
|
|
269
|
-
parameters: tool.function.parameters,
|
|
270
|
-
},
|
|
271
|
-
}));
|
|
272
|
-
}
|
|
273
|
-
// ===========================================================================
|
|
274
|
-
// Response Mapping
|
|
275
|
-
// ===========================================================================
|
|
276
|
-
/**
|
|
277
|
-
* Map OpenAI API response to internal LLMResponse format.
|
|
278
|
-
*
|
|
279
|
-
* @param response - OpenAI API response
|
|
280
|
-
* @returns Internal response format
|
|
281
|
-
*/
|
|
282
|
-
mapResponse(response) {
|
|
283
|
-
return {
|
|
284
|
-
id: response.id,
|
|
285
|
-
choices: response.choices.map((choice) => ({
|
|
286
|
-
index: choice.index,
|
|
287
|
-
message: {
|
|
288
|
-
role: choice.message.role,
|
|
289
|
-
content: choice.message.content ?? '',
|
|
290
|
-
tool_calls: this.mapToolCalls(choice.message.tool_calls),
|
|
291
|
-
},
|
|
292
|
-
// finish_reason is required in LLMResponseChoice; default to 'stop' if not provided
|
|
293
|
-
finish_reason: this.mapFinishReason(choice.finish_reason) ?? 'stop',
|
|
294
|
-
})),
|
|
295
|
-
usage: {
|
|
296
|
-
prompt_tokens: response.usage?.prompt_tokens ?? 0,
|
|
297
|
-
completion_tokens: response.usage?.completion_tokens ?? 0,
|
|
298
|
-
total_tokens: response.usage?.total_tokens ?? 0,
|
|
299
|
-
},
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* Map tool calls from OpenAI format, filtering out non-function types.
|
|
304
|
-
*
|
|
305
|
-
* @param toolCalls - OpenAI tool calls array
|
|
306
|
-
* @returns Internal tool calls array or undefined
|
|
307
|
-
*/
|
|
308
|
-
mapToolCalls(toolCalls) {
|
|
309
|
-
if (!toolCalls) {
|
|
310
|
-
return undefined;
|
|
311
|
-
}
|
|
312
|
-
const functionCalls = toolCalls.filter((tc) => tc.type === 'function' && 'function' in tc);
|
|
313
|
-
if (functionCalls.length === 0) {
|
|
314
|
-
return undefined;
|
|
315
|
-
}
|
|
316
|
-
return functionCalls.map((tc) => ({
|
|
317
|
-
id: tc.id,
|
|
318
|
-
type: 'function',
|
|
319
|
-
function: {
|
|
320
|
-
name: tc.function.name,
|
|
321
|
-
arguments: tc.function.arguments,
|
|
322
|
-
},
|
|
323
|
-
}));
|
|
324
|
-
}
|
|
325
|
-
/**
|
|
326
|
-
* Map OpenAI streaming chunk to internal ChatChunk format.
|
|
327
|
-
*
|
|
328
|
-
* @param chunk - OpenAI streaming chunk
|
|
329
|
-
* @returns Internal chunk format
|
|
330
|
-
*/
|
|
331
|
-
mapChunk(chunk) {
|
|
332
|
-
const choice = chunk.choices[0];
|
|
333
|
-
if (!choice) {
|
|
334
|
-
// Empty chunk (can happen at start/end)
|
|
335
|
-
return {
|
|
336
|
-
id: chunk.id,
|
|
337
|
-
content: null,
|
|
338
|
-
finish_reason: null,
|
|
339
|
-
};
|
|
340
|
-
}
|
|
341
|
-
const delta = choice.delta;
|
|
342
|
-
// Map tool call deltas if present
|
|
343
|
-
let toolCallDeltas;
|
|
344
|
-
if (delta.tool_calls) {
|
|
345
|
-
toolCallDeltas = delta.tool_calls.map((tc) => ({
|
|
346
|
-
index: tc.index,
|
|
347
|
-
id: tc.id,
|
|
348
|
-
type: tc.type,
|
|
349
|
-
function: tc.function
|
|
350
|
-
? {
|
|
351
|
-
name: tc.function.name,
|
|
352
|
-
arguments: tc.function.arguments,
|
|
353
|
-
}
|
|
354
|
-
: undefined,
|
|
355
|
-
}));
|
|
356
|
-
}
|
|
357
|
-
return {
|
|
358
|
-
id: chunk.id,
|
|
359
|
-
content: delta.content ?? null,
|
|
360
|
-
role: delta.role,
|
|
361
|
-
finish_reason: this.mapFinishReason(choice.finish_reason),
|
|
362
|
-
tool_calls: toolCallDeltas,
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
/**
|
|
366
|
-
* Map OpenAI finish reason to internal FinishReason type.
|
|
367
|
-
*
|
|
368
|
-
* @param reason - OpenAI finish reason string
|
|
369
|
-
* @returns Internal finish reason or null
|
|
370
|
-
*/
|
|
371
|
-
mapFinishReason(reason) {
|
|
372
|
-
if (!reason) {
|
|
373
|
-
return null;
|
|
374
|
-
}
|
|
375
|
-
switch (reason) {
|
|
376
|
-
case 'stop':
|
|
377
|
-
return 'stop';
|
|
378
|
-
case 'tool_calls':
|
|
379
|
-
return 'tool_calls';
|
|
380
|
-
case 'length':
|
|
381
|
-
return 'length';
|
|
382
|
-
case 'content_filter':
|
|
383
|
-
return 'content_filter';
|
|
384
|
-
default:
|
|
385
|
-
// Unknown reason, treat as stop
|
|
386
|
-
return 'stop';
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
// ===========================================================================
|
|
390
|
-
// Error Handling
|
|
391
|
-
// ===========================================================================
|
|
392
|
-
/**
|
|
393
|
-
* Wrap an error from the OpenAI SDK into an LLMError.
|
|
394
|
-
*
|
|
395
|
-
* Maps HTTP status codes and error types to appropriate LLMErrorCode values.
|
|
396
|
-
*
|
|
397
|
-
* @param error - The original error
|
|
398
|
-
* @returns Wrapped LLMError
|
|
399
|
-
*/
|
|
400
|
-
wrapError(error) {
|
|
401
|
-
// If already an LLMError, return as-is
|
|
402
|
-
if (error instanceof LLMError) {
|
|
403
|
-
return error;
|
|
404
|
-
}
|
|
405
|
-
// Handle non-Error objects
|
|
406
|
-
if (!(error instanceof Error)) {
|
|
407
|
-
return new LLMError(String(error), 'SERVER_ERROR', PROVIDER_NAME, { retryable: false });
|
|
408
|
-
}
|
|
409
|
-
// Extract status code from OpenAI error structure
|
|
410
|
-
const statusCode = this.extractStatusCode(error);
|
|
411
|
-
const code = this.mapStatusToErrorCode(statusCode, error);
|
|
412
|
-
const retryable = isTransientError(error);
|
|
413
|
-
return new LLMError(error.message, code, PROVIDER_NAME, {
|
|
414
|
-
statusCode,
|
|
415
|
-
retryable,
|
|
416
|
-
cause: error,
|
|
417
|
-
});
|
|
418
|
-
}
|
|
419
|
-
/**
|
|
420
|
-
* Extract HTTP status code from various error types.
|
|
421
|
-
*
|
|
422
|
-
* @param error - Error object to inspect
|
|
423
|
-
* @returns HTTP status code or undefined
|
|
424
|
-
*/
|
|
425
|
-
extractStatusCode(error) {
|
|
426
|
-
// OpenAI SDK errors have a 'status' property
|
|
427
|
-
const errorWithStatus = error;
|
|
428
|
-
return (errorWithStatus.status ??
|
|
429
|
-
errorWithStatus.statusCode ??
|
|
430
|
-
errorWithStatus.response?.status);
|
|
431
|
-
}
|
|
432
|
-
/**
|
|
433
|
-
* Map HTTP status code to LLMErrorCode.
|
|
434
|
-
*
|
|
435
|
-
* @param statusCode - HTTP status code
|
|
436
|
-
* @param error - Original error for additional context
|
|
437
|
-
* @returns Appropriate LLMErrorCode
|
|
438
|
-
*/
|
|
439
|
-
mapStatusToErrorCode(statusCode, error) {
|
|
440
|
-
// Map by status code first
|
|
441
|
-
if (statusCode !== undefined) {
|
|
442
|
-
switch (statusCode) {
|
|
443
|
-
case 401:
|
|
444
|
-
case 403:
|
|
445
|
-
return 'AUTH_FAILED';
|
|
446
|
-
case 429:
|
|
447
|
-
return 'RATE_LIMITED';
|
|
448
|
-
case 408:
|
|
449
|
-
return 'TIMEOUT';
|
|
450
|
-
case 400:
|
|
451
|
-
case 422:
|
|
452
|
-
return 'INVALID_REQUEST';
|
|
453
|
-
case 500:
|
|
454
|
-
case 502:
|
|
455
|
-
case 503:
|
|
456
|
-
case 504:
|
|
457
|
-
return 'SERVER_ERROR';
|
|
458
|
-
default:
|
|
459
|
-
if (statusCode >= 400 && statusCode < 500) {
|
|
460
|
-
return 'INVALID_REQUEST';
|
|
461
|
-
}
|
|
462
|
-
if (statusCode >= 500) {
|
|
463
|
-
return 'SERVER_ERROR';
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
// Check for network errors by error code
|
|
468
|
-
const errorWithCode = error;
|
|
469
|
-
const networkErrorCodes = new Set([
|
|
470
|
-
'ECONNRESET',
|
|
471
|
-
'ETIMEDOUT',
|
|
472
|
-
'ECONNREFUSED',
|
|
473
|
-
'ENOTFOUND',
|
|
474
|
-
'ENETUNREACH',
|
|
475
|
-
'EHOSTUNREACH',
|
|
476
|
-
'EPIPE',
|
|
477
|
-
'EAI_AGAIN',
|
|
478
|
-
]);
|
|
479
|
-
if (errorWithCode.code && networkErrorCodes.has(errorWithCode.code)) {
|
|
480
|
-
return 'NETWORK_ERROR';
|
|
481
|
-
}
|
|
482
|
-
// Check error message for timeout indicators
|
|
483
|
-
if (error.message.toLowerCase().includes('timeout') ||
|
|
484
|
-
error.message.toLowerCase().includes('timed out')) {
|
|
485
|
-
return 'TIMEOUT';
|
|
486
|
-
}
|
|
487
|
-
// Default to server error for unknown cases
|
|
488
|
-
return 'SERVER_ERROR';
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
//# sourceMappingURL=azure.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"azure.js","sourceRoot":"","sources":["../../src/providers/azure.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAQrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAWzD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,eAAe,EAA2B,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAErD,gFAAgF;AAChF,YAAY;AACZ,gFAAgF;AAEhF,2DAA2D;AAC3D,MAAM,8BAA8B,GAClC,8CAA8C,CAAC;AAEjD,+BAA+B;AAC/B,MAAM,aAAa,GAAG,cAAc,CAAC;AAErC,gFAAgF;AAChF,wBAAwB;AACxB,gFAAgF;AAEhF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,OAAO,mBAAoB,SAAQ,eAAe;IACtD,mCAAmC;IAC3B,MAAM,CAAc;IAE5B;;;;OAIG;IACH,YAAY,MAAiB;QAC3B,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,6CAA6C;QAC7C,MAAM,aAAa,GAAG,sBAAsB,CAC1C,MAAM,CAAC,UAAU,EACjB,8BAA8B,CAC/B,CAAC;QAEF,mDAAmD;QACnD,IAAI,CAAC,MAAM,GAAG,IAAI,WAAW,CAAC;YAC5B,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,UAAU,EAAE,MAAM,CAAC,KAAK;YACxB,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,oBAAoB;YACrD,oBAAoB,EAAE,aAAa;SACpC,CAAC,CAAC;IACL,CAAC;IAED,8EAA8E;IAC9E,oCAAoC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C;gBACT,KAAK,GAAG,CAAC;gBACT,KAAK,GAAG,CAAC;gBACT,KAAK,GAAG;oBACN,OAAO,cAAc,CAAC;gBACxB;oBACE,IAAI,UAAU,IAAI,GAAG,IAAI,UAAU,GAAG,GAAG,EAAE,CAAC;wBAC1C,OAAO,iBAAiB,CAAC;oBAC3B,CAAC;oBACD,IAAI,UAAU,IAAI,GAAG,EAAE,CAAC;wBACtB,OAAO,cAAc,CAAC;oBACxB,CAAC;YACL,CAAC;QACH,CAAC;QAED,yCAAyC;QACzC,MAAM,aAAa,GAAG,KAAkC,CAAC;QACzD,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC;YAChC,YAAY;YACZ,WAAW;YACX,cAAc;YACd,WAAW;YACX,aAAa;YACb,cAAc;YACd,OAAO;YACP,WAAW;SACZ,CAAC,CAAC;QAEH,IAAI,aAAa,CAAC,IAAI,IAAI,iBAAiB,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;YACpE,OAAO,eAAe,CAAC;QACzB,CAAC;QAED,6CAA6C;QAC7C,IACE,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC;YAC/C,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,EACjD,CAAC;YACD,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,4CAA4C;QAC5C,OAAO,cAAc,CAAC;IACxB,CAAC;CACF"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Azure OpenAI Provider Tests
|
|
3
|
-
*
|
|
4
|
-
* Tests for AzureOpenAIProvider class.
|
|
5
|
-
* Due to ESM constraints with mocking, these tests focus on:
|
|
6
|
-
* - Properties and getters (name, isConfigured, model, getConfigSummary)
|
|
7
|
-
* - countTokens method (doesn't require API calls)
|
|
8
|
-
* - Error mapping behavior
|
|
9
|
-
*/
|
|
10
|
-
export {};
|
|
11
|
-
//# sourceMappingURL=azure.test.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"azure.test.d.ts","sourceRoot":"","sources":["../../src/providers/azure.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|