gitlab-ai-provider 5.3.3 → 6.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 +31 -0
- package/dist/gitlab-ai-provider-6.1.0.tgz +0 -0
- package/dist/index.d.mts +92 -48
- package/dist/index.d.ts +92 -48
- package/dist/index.js +319 -117
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +319 -117
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/dist/gitlab-ai-provider-5.3.3.tgz +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,37 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## 6.1.0 (2026-03-29)
|
|
6
|
+
|
|
7
|
+
- fix(approval): defer stream close while approval is pending and send rejection to DWS ([9344828](https://gitlab.com/vglafirov/gitlab-ai-provider/commit/9344828))
|
|
8
|
+
- feat(client): emit approval-required event for TOOL_CALL_APPROVAL_REQUIRED checkpoints ([500eff1](https://gitlab.com/vglafirov/gitlab-ai-provider/commit/500eff1))
|
|
9
|
+
- feat(model): add approveAndResume, sessionPreapprovedTools, processedRequestIDs dedup ([f543831](https://gitlab.com/vglafirov/gitlab-ai-provider/commit/f543831))
|
|
10
|
+
- feat(model): add public approvalHandler getter/setter for external wiring ([ee075b9](https://gitlab.com/vglafirov/gitlab-ai-provider/commit/ee075b9))
|
|
11
|
+
- feat(options): add agentPrivileges to GitLabWorkflowOptions for testing approval flow ([475f2c7](https://gitlab.com/vglafirov/gitlab-ai-provider/commit/475f2c7))
|
|
12
|
+
- feat(types): add ApprovalDecision, approval on StartRequest, approval-required event ([9a4ccf4](https://gitlab.com/vglafirov/gitlab-ai-provider/commit/9a4ccf4))
|
|
13
|
+
- chore: rebuild dist with approval integration changes ([d66deb9](https://gitlab.com/vglafirov/gitlab-ai-provider/commit/d66deb9))
|
|
14
|
+
- chore: rebuild dist with approval integration changes ([daacc33](https://gitlab.com/vglafirov/gitlab-ai-provider/commit/daacc33))
|
|
15
|
+
|
|
16
|
+
## 6.0.0 (2026-03-26)
|
|
17
|
+
|
|
18
|
+
- feat!: migrate to AI SDK v6 (LanguageModelV3) ([21c1165](https://gitlab.com/vglafirov/gitlab-ai-provider/commit/21c1165))
|
|
19
|
+
- Merge branch 'ai-sdk-v6' into 'main' ([a527717](https://gitlab.com/vglafirov/gitlab-ai-provider/commit/a527717)), closes [#3](https://gitlab.com/vglafirov/gitlab-ai-provider/issues/3)
|
|
20
|
+
- chore: add .worktrees to .gitignore ([a7df2fb](https://gitlab.com/vglafirov/gitlab-ai-provider/commit/a7df2fb))
|
|
21
|
+
|
|
22
|
+
### BREAKING CHANGE
|
|
23
|
+
|
|
24
|
+
- This release migrates the provider to AI SDK v6 which
|
|
25
|
+
requires @ai-sdk/provider-utils v4+ and uses the LanguageModelV3 interface.
|
|
26
|
+
Consumers must upgrade to AI SDK v6 compatible tooling.
|
|
27
|
+
|
|
28
|
+
* Migrate models and provider to LanguageModelV3 for AI SDK v6
|
|
29
|
+
* Add AI SDK v6 support with updated streaming and tool-call handling
|
|
30
|
+
* Fix streaming tool-call handling and normalize v3 tool-result output
|
|
31
|
+
* Fix per-tool strict mode in OpenAI responses
|
|
32
|
+
* Fix unknown finish reason mapping for v6 compatibility
|
|
33
|
+
* Fix cache and add v3 contract tests
|
|
34
|
+
* Rebuild dist
|
|
35
|
+
|
|
5
36
|
## <small>5.3.3 (2026-03-25)</small>
|
|
6
37
|
|
|
7
38
|
- Merge branch 'vg/tools-fix' into 'main' ([d33e8c0](https://gitlab.com/vglafirov/gitlab-ai-provider/commit/d33e8c0))
|
|
Binary file
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateResult, LanguageModelV3StreamResult, LanguageModelV3Content, LanguageModelV3FinishReason, LanguageModelV3Usage, LanguageModelV3StreamPart } from '@ai-sdk/provider';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
interface GitLabAnthropicConfig {
|
|
@@ -47,8 +47,8 @@ interface GitLabAnthropicConfig {
|
|
|
47
47
|
* for the duo-chat model. It connects to Claude through GitLab's cloud proxy
|
|
48
48
|
* at https://cloud.gitlab.com/ai/v1/proxy/anthropic/
|
|
49
49
|
*/
|
|
50
|
-
declare class GitLabAnthropicLanguageModel implements
|
|
51
|
-
readonly specificationVersion: "
|
|
50
|
+
declare class GitLabAnthropicLanguageModel implements LanguageModelV3 {
|
|
51
|
+
readonly specificationVersion: "v3";
|
|
52
52
|
readonly modelId: string;
|
|
53
53
|
readonly supportedUrls: Record<string, RegExp[]>;
|
|
54
54
|
private readonly config;
|
|
@@ -86,22 +86,10 @@ declare class GitLabAnthropicLanguageModel implements LanguageModelV2 {
|
|
|
86
86
|
* Convert Anthropic finish reason to AI SDK format
|
|
87
87
|
*/
|
|
88
88
|
private convertFinishReason;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
finishReason: LanguageModelV2FinishReason;
|
|
92
|
-
usage: LanguageModelV2Usage;
|
|
93
|
-
warnings: LanguageModelV2CallWarning[];
|
|
94
|
-
}>;
|
|
89
|
+
private createUsage;
|
|
90
|
+
doGenerate(options: LanguageModelV3CallOptions): Promise<LanguageModelV3GenerateResult>;
|
|
95
91
|
private doGenerateWithRetry;
|
|
96
|
-
doStream(options:
|
|
97
|
-
stream: ReadableStream<LanguageModelV2StreamPart>;
|
|
98
|
-
request?: {
|
|
99
|
-
body?: unknown;
|
|
100
|
-
};
|
|
101
|
-
response?: {
|
|
102
|
-
headers?: Record<string, string>;
|
|
103
|
-
};
|
|
104
|
-
}>;
|
|
92
|
+
doStream(options: LanguageModelV3CallOptions): Promise<LanguageModelV3StreamResult>;
|
|
105
93
|
private doStreamWithRetry;
|
|
106
94
|
}
|
|
107
95
|
|
|
@@ -358,6 +346,17 @@ interface StartRequest {
|
|
|
358
346
|
preapproved_tools?: string[];
|
|
359
347
|
flowConfig?: unknown;
|
|
360
348
|
flowConfigSchemaVersion?: string;
|
|
349
|
+
approval?: ApprovalDecision;
|
|
350
|
+
}
|
|
351
|
+
interface ApprovalDecision {
|
|
352
|
+
approval?: {
|
|
353
|
+
remember_approval?: boolean;
|
|
354
|
+
tool_name?: string;
|
|
355
|
+
tool_args_json?: string;
|
|
356
|
+
};
|
|
357
|
+
rejection?: {
|
|
358
|
+
message?: string;
|
|
359
|
+
};
|
|
361
360
|
}
|
|
362
361
|
interface ActionResponsePayload {
|
|
363
362
|
requestID: string;
|
|
@@ -563,6 +562,25 @@ interface GitLabWorkflowOptions {
|
|
|
563
562
|
* @returns The selected model ref, or null/undefined for default
|
|
564
563
|
*/
|
|
565
564
|
onSelectModel?: (models: AiModel[]) => Promise<string | null | undefined>;
|
|
565
|
+
/**
|
|
566
|
+
* Agent privileges to request when creating the workflow.
|
|
567
|
+
* Defaults to DEFAULT_AGENT_PRIVILEGES (all privileges).
|
|
568
|
+
* Pass a subset to restrict which tools DWS pre-approves server-side,
|
|
569
|
+
* causing TOOL_CALL_APPROVAL_REQUIRED for excluded privileges.
|
|
570
|
+
*/
|
|
571
|
+
agentPrivileges?: number[];
|
|
572
|
+
/**
|
|
573
|
+
* Called when DWS requires approval for a tool call.
|
|
574
|
+
* Return `{ approved: true }` to proceed or `{ approved: false, message? }` to reject.
|
|
575
|
+
* If not set, the stream ends silently when approval is required (backward compat).
|
|
576
|
+
*/
|
|
577
|
+
approvalHandler?: (tools: Array<{
|
|
578
|
+
name: string;
|
|
579
|
+
args: string;
|
|
580
|
+
}>) => Promise<{
|
|
581
|
+
approved: boolean;
|
|
582
|
+
message?: string;
|
|
583
|
+
}>;
|
|
566
584
|
}
|
|
567
585
|
interface GitLabWorkflowClientConfig {
|
|
568
586
|
/** GitLab instance URL (e.g., 'https://gitlab.com') */
|
|
@@ -596,6 +614,12 @@ type WorkflowClientEvent = {
|
|
|
596
614
|
requestID: string;
|
|
597
615
|
toolName: string;
|
|
598
616
|
data: Record<string, unknown>;
|
|
617
|
+
} | {
|
|
618
|
+
type: 'approval-required';
|
|
619
|
+
tools: Array<{
|
|
620
|
+
name: string;
|
|
621
|
+
args: string;
|
|
622
|
+
}>;
|
|
599
623
|
} | {
|
|
600
624
|
type: 'completed';
|
|
601
625
|
} | {
|
|
@@ -665,11 +689,11 @@ type WorkflowToolExecutor = (toolName: string, args: string, requestID: string)
|
|
|
665
689
|
/**
|
|
666
690
|
* GitLab Duo Agent Platform Language Model.
|
|
667
691
|
*
|
|
668
|
-
* Implements
|
|
692
|
+
* Implements LanguageModelV3 by bridging the DWS WebSocket protocol
|
|
669
693
|
* to the Vercel AI SDK stream part format.
|
|
670
694
|
*/
|
|
671
|
-
declare class GitLabWorkflowLanguageModel implements
|
|
672
|
-
readonly specificationVersion: "
|
|
695
|
+
declare class GitLabWorkflowLanguageModel implements LanguageModelV3 {
|
|
696
|
+
readonly specificationVersion: "v3";
|
|
673
697
|
readonly modelId: string;
|
|
674
698
|
readonly supportedUrls: Record<string, RegExp[]>;
|
|
675
699
|
private readonly config;
|
|
@@ -725,6 +749,31 @@ declare class GitLabWorkflowLanguageModel implements LanguageModelV2 {
|
|
|
725
749
|
inputTokens: number;
|
|
726
750
|
outputTokens: number;
|
|
727
751
|
}) => void) | null;
|
|
752
|
+
/**
|
|
753
|
+
* Tool names pre-approved for the current session.
|
|
754
|
+
* Set by the host (e.g., opencode) and merged into preapproved_tools on each StartRequest.
|
|
755
|
+
* Updated when the user chooses "always" in the approval prompt.
|
|
756
|
+
*/
|
|
757
|
+
sessionPreapprovedTools: string[];
|
|
758
|
+
/**
|
|
759
|
+
* Set the approval handler callback.
|
|
760
|
+
* Called when DWS requires tool call approval. Host (e.g., opencode) wires this
|
|
761
|
+
* to its permission system each stream call, similar to toolExecutor.
|
|
762
|
+
*/
|
|
763
|
+
set approvalHandler(handler: ((tools: Array<{
|
|
764
|
+
name: string;
|
|
765
|
+
args: string;
|
|
766
|
+
}>) => Promise<{
|
|
767
|
+
approved: boolean;
|
|
768
|
+
message?: string;
|
|
769
|
+
}>) | null);
|
|
770
|
+
get approvalHandler(): ((tools: Array<{
|
|
771
|
+
name: string;
|
|
772
|
+
args: string;
|
|
773
|
+
}>) => Promise<{
|
|
774
|
+
approved: boolean;
|
|
775
|
+
message?: string;
|
|
776
|
+
}>) | null;
|
|
728
777
|
/**
|
|
729
778
|
* Optional callback invoked when multiple workflow models are available
|
|
730
779
|
* and the user should pick one. Set per-stream by the host (e.g., OpenCode)
|
|
@@ -799,22 +848,15 @@ declare class GitLabWorkflowLanguageModel implements LanguageModelV2 {
|
|
|
799
848
|
* Useful for consumers that need to track workflow state.
|
|
800
849
|
*/
|
|
801
850
|
get workflowId(): string | null;
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
warnings: LanguageModelV2CallWarning[];
|
|
807
|
-
}>;
|
|
808
|
-
doStream(options: LanguageModelV2CallOptions): Promise<{
|
|
809
|
-
stream: ReadableStream<LanguageModelV2StreamPart>;
|
|
810
|
-
request?: {
|
|
811
|
-
body?: unknown;
|
|
812
|
-
};
|
|
813
|
-
}>;
|
|
851
|
+
private createUsage;
|
|
852
|
+
private createFinishReason;
|
|
853
|
+
doGenerate(options: LanguageModelV3CallOptions): Promise<LanguageModelV3GenerateResult>;
|
|
854
|
+
doStream(options: LanguageModelV3CallOptions): Promise<LanguageModelV3StreamResult>;
|
|
814
855
|
private handleWorkflowEvent;
|
|
815
856
|
private processCheckpoint;
|
|
816
857
|
private executeToolAndRespond;
|
|
817
858
|
private cleanupClient;
|
|
859
|
+
private approveAndResume;
|
|
818
860
|
private buildWorkflowMetadata;
|
|
819
861
|
private getGitInfo;
|
|
820
862
|
/**
|
|
@@ -845,10 +887,10 @@ declare class GitLabWorkflowLanguageModel implements LanguageModelV2 {
|
|
|
845
887
|
}
|
|
846
888
|
|
|
847
889
|
interface GitLabProvider {
|
|
848
|
-
(modelId: string):
|
|
849
|
-
readonly specificationVersion: '
|
|
850
|
-
languageModel(modelId: string):
|
|
851
|
-
chat(modelId: string):
|
|
890
|
+
(modelId: string): LanguageModelV3;
|
|
891
|
+
readonly specificationVersion: 'v3';
|
|
892
|
+
languageModel(modelId: string): LanguageModelV3;
|
|
893
|
+
chat(modelId: string): LanguageModelV3;
|
|
852
894
|
/**
|
|
853
895
|
* Create an agentic chat model with tool calling support
|
|
854
896
|
*
|
|
@@ -888,7 +930,7 @@ interface GitLabProvider {
|
|
|
888
930
|
* });
|
|
889
931
|
*/
|
|
890
932
|
workflowChat(modelId: string, options?: GitLabWorkflowOptions): GitLabWorkflowLanguageModel;
|
|
891
|
-
|
|
933
|
+
embeddingModel(modelId: string): never;
|
|
892
934
|
imageModel(modelId: string): never;
|
|
893
935
|
}
|
|
894
936
|
interface GitLabAgenticOptions {
|
|
@@ -1020,8 +1062,8 @@ interface GitLabOpenAIConfig {
|
|
|
1020
1062
|
*/
|
|
1021
1063
|
aiGatewayHeaders?: Record<string, string>;
|
|
1022
1064
|
}
|
|
1023
|
-
declare class GitLabOpenAILanguageModel implements
|
|
1024
|
-
readonly specificationVersion: "
|
|
1065
|
+
declare class GitLabOpenAILanguageModel implements LanguageModelV3 {
|
|
1066
|
+
readonly specificationVersion: "v3";
|
|
1025
1067
|
readonly modelId: string;
|
|
1026
1068
|
readonly supportedUrls: Record<string, RegExp[]>;
|
|
1027
1069
|
private readonly config;
|
|
@@ -1041,6 +1083,7 @@ declare class GitLabOpenAILanguageModel implements LanguageModelV2 {
|
|
|
1041
1083
|
private convertToolChoice;
|
|
1042
1084
|
private convertPrompt;
|
|
1043
1085
|
private convertFinishReason;
|
|
1086
|
+
private createUsage;
|
|
1044
1087
|
/**
|
|
1045
1088
|
* Convert tools to Responses API format
|
|
1046
1089
|
*/
|
|
@@ -1059,16 +1102,16 @@ declare class GitLabOpenAILanguageModel implements LanguageModelV2 {
|
|
|
1059
1102
|
* so we need to check the content for tool calls separately.
|
|
1060
1103
|
*/
|
|
1061
1104
|
private convertResponsesStatus;
|
|
1062
|
-
doGenerate(options:
|
|
1063
|
-
content:
|
|
1064
|
-
finishReason:
|
|
1065
|
-
usage:
|
|
1066
|
-
warnings:
|
|
1105
|
+
doGenerate(options: LanguageModelV3CallOptions): Promise<{
|
|
1106
|
+
content: LanguageModelV3Content[];
|
|
1107
|
+
finishReason: LanguageModelV3FinishReason;
|
|
1108
|
+
usage: LanguageModelV3Usage;
|
|
1109
|
+
warnings: [];
|
|
1067
1110
|
}>;
|
|
1068
1111
|
private doGenerateWithChatApi;
|
|
1069
1112
|
private doGenerateWithResponsesApi;
|
|
1070
|
-
doStream(options:
|
|
1071
|
-
stream: ReadableStream<
|
|
1113
|
+
doStream(options: LanguageModelV3CallOptions): Promise<{
|
|
1114
|
+
stream: ReadableStream<LanguageModelV3StreamPart>;
|
|
1072
1115
|
request?: {
|
|
1073
1116
|
body?: unknown;
|
|
1074
1117
|
};
|
|
@@ -1463,6 +1506,7 @@ declare class GitLabWorkflowClient {
|
|
|
1463
1506
|
private buildWebSocketUrl;
|
|
1464
1507
|
private buildWebSocketHeaders;
|
|
1465
1508
|
private handleAction;
|
|
1509
|
+
private extractApprovalTools;
|
|
1466
1510
|
private send;
|
|
1467
1511
|
private sendHeartbeatIfNeeded;
|
|
1468
1512
|
private emit;
|
|
@@ -1639,4 +1683,4 @@ interface WorkflowDiscoveryResult {
|
|
|
1639
1683
|
}
|
|
1640
1684
|
declare function discoverWorkflowModels(config: WorkflowDiscoveryConfig, options: WorkflowDiscoveryOptions): Promise<WorkflowDiscoveryResult>;
|
|
1641
1685
|
|
|
1642
|
-
export { AGENT_PRIVILEGES, type ActionResponsePayload, type AdditionalContext, type AiChatAvailableModels, type AiModel, BUNDLED_CLIENT_ID, CLIENT_VERSION, type ClientEvent, DEFAULT_AGENT_PRIVILEGES, DEFAULT_AI_GATEWAY_URL, DEFAULT_CLIENT_CAPABILITIES, DEFAULT_WORKFLOW_DEFINITION, type DirectAccessToken, type DiscoveredModels, type DiscoveredWorkflowModel, GITLAB_COM_URL, type GenerateTokenResponse, type GitLabAgenticOptions, type GitLabAnthropicConfig, GitLabAnthropicLanguageModel, GitLabDirectAccessClient, type GitLabDirectAccessConfig, GitLabError, type GitLabErrorOptions, GitLabModelCache, GitLabModelConfigRegistry, GitLabModelDiscovery, GitLabOAuthManager, type GitLabOAuthTokenResponse, type GitLabOAuthTokens, type GitLabOpenAIConfig, GitLabOpenAILanguageModel, type GitLabProject, GitLabProjectCache, GitLabProjectDetector, type GitLabProjectDetectorConfig, type GitLabProvider, type GitLabProviderSettings, GitLabWorkflowClient, type GitLabWorkflowClientConfig, GitLabWorkflowLanguageModel, type GitLabWorkflowLanguageModelConfig, type GitLabWorkflowOptions, GitLabWorkflowTokenClient, MODEL_ID_TO_ANTHROPIC_MODEL, MODEL_MAPPINGS, type McpToolDefinition, type ModelCacheEntry, type ModelConfig, type ModelConfigRegistryOptions, type ModelDiscoveryConfig, type ModelMapping, type ModelProvider, type NewCheckpoint, OAUTH_SCOPES, OPENCODE_GITLAB_AUTH_CLIENT_ID, type OpenAIApiType, type OpenCodeAuth, type OpenCodeAuthApi, type OpenCodeAuthOAuth, type RunMcpTool, type StartRequest, TOKEN_EXPIRY_SKEW_MS, VERSION, WORKFLOW_ENVIRONMENT, WS_HEARTBEAT_INTERVAL_MS, WS_KEEPALIVE_PING_INTERVAL_MS, type WorkflowAction, type WorkflowClientEvent, type WorkflowDiscoveryConfig, type WorkflowDiscoveryOptions, type WorkflowDiscoveryResult, type WorkflowStatus, type WorkflowToolExecutor, WorkflowType, type WorkflowWebSocketOptions, createGitLab, discoverWorkflowModels, getAnthropicModelForModelId, getModelMapping, getOpenAIApiType, getOpenAIModelForModelId, getProviderForModelId, getValidModelsForProvider, getWorkflowModelRef, gitlab, isResponsesApiModel, isWorkflowModel, parseModelsYml };
|
|
1686
|
+
export { AGENT_PRIVILEGES, type ActionResponsePayload, type AdditionalContext, type AiChatAvailableModels, type AiModel, type ApprovalDecision, BUNDLED_CLIENT_ID, CLIENT_VERSION, type ClientEvent, DEFAULT_AGENT_PRIVILEGES, DEFAULT_AI_GATEWAY_URL, DEFAULT_CLIENT_CAPABILITIES, DEFAULT_WORKFLOW_DEFINITION, type DirectAccessToken, type DiscoveredModels, type DiscoveredWorkflowModel, GITLAB_COM_URL, type GenerateTokenResponse, type GitLabAgenticOptions, type GitLabAnthropicConfig, GitLabAnthropicLanguageModel, GitLabDirectAccessClient, type GitLabDirectAccessConfig, GitLabError, type GitLabErrorOptions, GitLabModelCache, GitLabModelConfigRegistry, GitLabModelDiscovery, GitLabOAuthManager, type GitLabOAuthTokenResponse, type GitLabOAuthTokens, type GitLabOpenAIConfig, GitLabOpenAILanguageModel, type GitLabProject, GitLabProjectCache, GitLabProjectDetector, type GitLabProjectDetectorConfig, type GitLabProvider, type GitLabProviderSettings, GitLabWorkflowClient, type GitLabWorkflowClientConfig, GitLabWorkflowLanguageModel, type GitLabWorkflowLanguageModelConfig, type GitLabWorkflowOptions, GitLabWorkflowTokenClient, MODEL_ID_TO_ANTHROPIC_MODEL, MODEL_MAPPINGS, type McpToolDefinition, type ModelCacheEntry, type ModelConfig, type ModelConfigRegistryOptions, type ModelDiscoveryConfig, type ModelMapping, type ModelProvider, type NewCheckpoint, OAUTH_SCOPES, OPENCODE_GITLAB_AUTH_CLIENT_ID, type OpenAIApiType, type OpenCodeAuth, type OpenCodeAuthApi, type OpenCodeAuthOAuth, type RunMcpTool, type StartRequest, TOKEN_EXPIRY_SKEW_MS, VERSION, WORKFLOW_ENVIRONMENT, WS_HEARTBEAT_INTERVAL_MS, WS_KEEPALIVE_PING_INTERVAL_MS, type WorkflowAction, type WorkflowClientEvent, type WorkflowDiscoveryConfig, type WorkflowDiscoveryOptions, type WorkflowDiscoveryResult, type WorkflowStatus, type WorkflowToolExecutor, WorkflowType, type WorkflowWebSocketOptions, createGitLab, discoverWorkflowModels, getAnthropicModelForModelId, getModelMapping, getOpenAIApiType, getOpenAIModelForModelId, getProviderForModelId, getValidModelsForProvider, getWorkflowModelRef, gitlab, isResponsesApiModel, isWorkflowModel, parseModelsYml };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateResult, LanguageModelV3StreamResult, LanguageModelV3Content, LanguageModelV3FinishReason, LanguageModelV3Usage, LanguageModelV3StreamPart } from '@ai-sdk/provider';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
interface GitLabAnthropicConfig {
|
|
@@ -47,8 +47,8 @@ interface GitLabAnthropicConfig {
|
|
|
47
47
|
* for the duo-chat model. It connects to Claude through GitLab's cloud proxy
|
|
48
48
|
* at https://cloud.gitlab.com/ai/v1/proxy/anthropic/
|
|
49
49
|
*/
|
|
50
|
-
declare class GitLabAnthropicLanguageModel implements
|
|
51
|
-
readonly specificationVersion: "
|
|
50
|
+
declare class GitLabAnthropicLanguageModel implements LanguageModelV3 {
|
|
51
|
+
readonly specificationVersion: "v3";
|
|
52
52
|
readonly modelId: string;
|
|
53
53
|
readonly supportedUrls: Record<string, RegExp[]>;
|
|
54
54
|
private readonly config;
|
|
@@ -86,22 +86,10 @@ declare class GitLabAnthropicLanguageModel implements LanguageModelV2 {
|
|
|
86
86
|
* Convert Anthropic finish reason to AI SDK format
|
|
87
87
|
*/
|
|
88
88
|
private convertFinishReason;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
finishReason: LanguageModelV2FinishReason;
|
|
92
|
-
usage: LanguageModelV2Usage;
|
|
93
|
-
warnings: LanguageModelV2CallWarning[];
|
|
94
|
-
}>;
|
|
89
|
+
private createUsage;
|
|
90
|
+
doGenerate(options: LanguageModelV3CallOptions): Promise<LanguageModelV3GenerateResult>;
|
|
95
91
|
private doGenerateWithRetry;
|
|
96
|
-
doStream(options:
|
|
97
|
-
stream: ReadableStream<LanguageModelV2StreamPart>;
|
|
98
|
-
request?: {
|
|
99
|
-
body?: unknown;
|
|
100
|
-
};
|
|
101
|
-
response?: {
|
|
102
|
-
headers?: Record<string, string>;
|
|
103
|
-
};
|
|
104
|
-
}>;
|
|
92
|
+
doStream(options: LanguageModelV3CallOptions): Promise<LanguageModelV3StreamResult>;
|
|
105
93
|
private doStreamWithRetry;
|
|
106
94
|
}
|
|
107
95
|
|
|
@@ -358,6 +346,17 @@ interface StartRequest {
|
|
|
358
346
|
preapproved_tools?: string[];
|
|
359
347
|
flowConfig?: unknown;
|
|
360
348
|
flowConfigSchemaVersion?: string;
|
|
349
|
+
approval?: ApprovalDecision;
|
|
350
|
+
}
|
|
351
|
+
interface ApprovalDecision {
|
|
352
|
+
approval?: {
|
|
353
|
+
remember_approval?: boolean;
|
|
354
|
+
tool_name?: string;
|
|
355
|
+
tool_args_json?: string;
|
|
356
|
+
};
|
|
357
|
+
rejection?: {
|
|
358
|
+
message?: string;
|
|
359
|
+
};
|
|
361
360
|
}
|
|
362
361
|
interface ActionResponsePayload {
|
|
363
362
|
requestID: string;
|
|
@@ -563,6 +562,25 @@ interface GitLabWorkflowOptions {
|
|
|
563
562
|
* @returns The selected model ref, or null/undefined for default
|
|
564
563
|
*/
|
|
565
564
|
onSelectModel?: (models: AiModel[]) => Promise<string | null | undefined>;
|
|
565
|
+
/**
|
|
566
|
+
* Agent privileges to request when creating the workflow.
|
|
567
|
+
* Defaults to DEFAULT_AGENT_PRIVILEGES (all privileges).
|
|
568
|
+
* Pass a subset to restrict which tools DWS pre-approves server-side,
|
|
569
|
+
* causing TOOL_CALL_APPROVAL_REQUIRED for excluded privileges.
|
|
570
|
+
*/
|
|
571
|
+
agentPrivileges?: number[];
|
|
572
|
+
/**
|
|
573
|
+
* Called when DWS requires approval for a tool call.
|
|
574
|
+
* Return `{ approved: true }` to proceed or `{ approved: false, message? }` to reject.
|
|
575
|
+
* If not set, the stream ends silently when approval is required (backward compat).
|
|
576
|
+
*/
|
|
577
|
+
approvalHandler?: (tools: Array<{
|
|
578
|
+
name: string;
|
|
579
|
+
args: string;
|
|
580
|
+
}>) => Promise<{
|
|
581
|
+
approved: boolean;
|
|
582
|
+
message?: string;
|
|
583
|
+
}>;
|
|
566
584
|
}
|
|
567
585
|
interface GitLabWorkflowClientConfig {
|
|
568
586
|
/** GitLab instance URL (e.g., 'https://gitlab.com') */
|
|
@@ -596,6 +614,12 @@ type WorkflowClientEvent = {
|
|
|
596
614
|
requestID: string;
|
|
597
615
|
toolName: string;
|
|
598
616
|
data: Record<string, unknown>;
|
|
617
|
+
} | {
|
|
618
|
+
type: 'approval-required';
|
|
619
|
+
tools: Array<{
|
|
620
|
+
name: string;
|
|
621
|
+
args: string;
|
|
622
|
+
}>;
|
|
599
623
|
} | {
|
|
600
624
|
type: 'completed';
|
|
601
625
|
} | {
|
|
@@ -665,11 +689,11 @@ type WorkflowToolExecutor = (toolName: string, args: string, requestID: string)
|
|
|
665
689
|
/**
|
|
666
690
|
* GitLab Duo Agent Platform Language Model.
|
|
667
691
|
*
|
|
668
|
-
* Implements
|
|
692
|
+
* Implements LanguageModelV3 by bridging the DWS WebSocket protocol
|
|
669
693
|
* to the Vercel AI SDK stream part format.
|
|
670
694
|
*/
|
|
671
|
-
declare class GitLabWorkflowLanguageModel implements
|
|
672
|
-
readonly specificationVersion: "
|
|
695
|
+
declare class GitLabWorkflowLanguageModel implements LanguageModelV3 {
|
|
696
|
+
readonly specificationVersion: "v3";
|
|
673
697
|
readonly modelId: string;
|
|
674
698
|
readonly supportedUrls: Record<string, RegExp[]>;
|
|
675
699
|
private readonly config;
|
|
@@ -725,6 +749,31 @@ declare class GitLabWorkflowLanguageModel implements LanguageModelV2 {
|
|
|
725
749
|
inputTokens: number;
|
|
726
750
|
outputTokens: number;
|
|
727
751
|
}) => void) | null;
|
|
752
|
+
/**
|
|
753
|
+
* Tool names pre-approved for the current session.
|
|
754
|
+
* Set by the host (e.g., opencode) and merged into preapproved_tools on each StartRequest.
|
|
755
|
+
* Updated when the user chooses "always" in the approval prompt.
|
|
756
|
+
*/
|
|
757
|
+
sessionPreapprovedTools: string[];
|
|
758
|
+
/**
|
|
759
|
+
* Set the approval handler callback.
|
|
760
|
+
* Called when DWS requires tool call approval. Host (e.g., opencode) wires this
|
|
761
|
+
* to its permission system each stream call, similar to toolExecutor.
|
|
762
|
+
*/
|
|
763
|
+
set approvalHandler(handler: ((tools: Array<{
|
|
764
|
+
name: string;
|
|
765
|
+
args: string;
|
|
766
|
+
}>) => Promise<{
|
|
767
|
+
approved: boolean;
|
|
768
|
+
message?: string;
|
|
769
|
+
}>) | null);
|
|
770
|
+
get approvalHandler(): ((tools: Array<{
|
|
771
|
+
name: string;
|
|
772
|
+
args: string;
|
|
773
|
+
}>) => Promise<{
|
|
774
|
+
approved: boolean;
|
|
775
|
+
message?: string;
|
|
776
|
+
}>) | null;
|
|
728
777
|
/**
|
|
729
778
|
* Optional callback invoked when multiple workflow models are available
|
|
730
779
|
* and the user should pick one. Set per-stream by the host (e.g., OpenCode)
|
|
@@ -799,22 +848,15 @@ declare class GitLabWorkflowLanguageModel implements LanguageModelV2 {
|
|
|
799
848
|
* Useful for consumers that need to track workflow state.
|
|
800
849
|
*/
|
|
801
850
|
get workflowId(): string | null;
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
warnings: LanguageModelV2CallWarning[];
|
|
807
|
-
}>;
|
|
808
|
-
doStream(options: LanguageModelV2CallOptions): Promise<{
|
|
809
|
-
stream: ReadableStream<LanguageModelV2StreamPart>;
|
|
810
|
-
request?: {
|
|
811
|
-
body?: unknown;
|
|
812
|
-
};
|
|
813
|
-
}>;
|
|
851
|
+
private createUsage;
|
|
852
|
+
private createFinishReason;
|
|
853
|
+
doGenerate(options: LanguageModelV3CallOptions): Promise<LanguageModelV3GenerateResult>;
|
|
854
|
+
doStream(options: LanguageModelV3CallOptions): Promise<LanguageModelV3StreamResult>;
|
|
814
855
|
private handleWorkflowEvent;
|
|
815
856
|
private processCheckpoint;
|
|
816
857
|
private executeToolAndRespond;
|
|
817
858
|
private cleanupClient;
|
|
859
|
+
private approveAndResume;
|
|
818
860
|
private buildWorkflowMetadata;
|
|
819
861
|
private getGitInfo;
|
|
820
862
|
/**
|
|
@@ -845,10 +887,10 @@ declare class GitLabWorkflowLanguageModel implements LanguageModelV2 {
|
|
|
845
887
|
}
|
|
846
888
|
|
|
847
889
|
interface GitLabProvider {
|
|
848
|
-
(modelId: string):
|
|
849
|
-
readonly specificationVersion: '
|
|
850
|
-
languageModel(modelId: string):
|
|
851
|
-
chat(modelId: string):
|
|
890
|
+
(modelId: string): LanguageModelV3;
|
|
891
|
+
readonly specificationVersion: 'v3';
|
|
892
|
+
languageModel(modelId: string): LanguageModelV3;
|
|
893
|
+
chat(modelId: string): LanguageModelV3;
|
|
852
894
|
/**
|
|
853
895
|
* Create an agentic chat model with tool calling support
|
|
854
896
|
*
|
|
@@ -888,7 +930,7 @@ interface GitLabProvider {
|
|
|
888
930
|
* });
|
|
889
931
|
*/
|
|
890
932
|
workflowChat(modelId: string, options?: GitLabWorkflowOptions): GitLabWorkflowLanguageModel;
|
|
891
|
-
|
|
933
|
+
embeddingModel(modelId: string): never;
|
|
892
934
|
imageModel(modelId: string): never;
|
|
893
935
|
}
|
|
894
936
|
interface GitLabAgenticOptions {
|
|
@@ -1020,8 +1062,8 @@ interface GitLabOpenAIConfig {
|
|
|
1020
1062
|
*/
|
|
1021
1063
|
aiGatewayHeaders?: Record<string, string>;
|
|
1022
1064
|
}
|
|
1023
|
-
declare class GitLabOpenAILanguageModel implements
|
|
1024
|
-
readonly specificationVersion: "
|
|
1065
|
+
declare class GitLabOpenAILanguageModel implements LanguageModelV3 {
|
|
1066
|
+
readonly specificationVersion: "v3";
|
|
1025
1067
|
readonly modelId: string;
|
|
1026
1068
|
readonly supportedUrls: Record<string, RegExp[]>;
|
|
1027
1069
|
private readonly config;
|
|
@@ -1041,6 +1083,7 @@ declare class GitLabOpenAILanguageModel implements LanguageModelV2 {
|
|
|
1041
1083
|
private convertToolChoice;
|
|
1042
1084
|
private convertPrompt;
|
|
1043
1085
|
private convertFinishReason;
|
|
1086
|
+
private createUsage;
|
|
1044
1087
|
/**
|
|
1045
1088
|
* Convert tools to Responses API format
|
|
1046
1089
|
*/
|
|
@@ -1059,16 +1102,16 @@ declare class GitLabOpenAILanguageModel implements LanguageModelV2 {
|
|
|
1059
1102
|
* so we need to check the content for tool calls separately.
|
|
1060
1103
|
*/
|
|
1061
1104
|
private convertResponsesStatus;
|
|
1062
|
-
doGenerate(options:
|
|
1063
|
-
content:
|
|
1064
|
-
finishReason:
|
|
1065
|
-
usage:
|
|
1066
|
-
warnings:
|
|
1105
|
+
doGenerate(options: LanguageModelV3CallOptions): Promise<{
|
|
1106
|
+
content: LanguageModelV3Content[];
|
|
1107
|
+
finishReason: LanguageModelV3FinishReason;
|
|
1108
|
+
usage: LanguageModelV3Usage;
|
|
1109
|
+
warnings: [];
|
|
1067
1110
|
}>;
|
|
1068
1111
|
private doGenerateWithChatApi;
|
|
1069
1112
|
private doGenerateWithResponsesApi;
|
|
1070
|
-
doStream(options:
|
|
1071
|
-
stream: ReadableStream<
|
|
1113
|
+
doStream(options: LanguageModelV3CallOptions): Promise<{
|
|
1114
|
+
stream: ReadableStream<LanguageModelV3StreamPart>;
|
|
1072
1115
|
request?: {
|
|
1073
1116
|
body?: unknown;
|
|
1074
1117
|
};
|
|
@@ -1463,6 +1506,7 @@ declare class GitLabWorkflowClient {
|
|
|
1463
1506
|
private buildWebSocketUrl;
|
|
1464
1507
|
private buildWebSocketHeaders;
|
|
1465
1508
|
private handleAction;
|
|
1509
|
+
private extractApprovalTools;
|
|
1466
1510
|
private send;
|
|
1467
1511
|
private sendHeartbeatIfNeeded;
|
|
1468
1512
|
private emit;
|
|
@@ -1639,4 +1683,4 @@ interface WorkflowDiscoveryResult {
|
|
|
1639
1683
|
}
|
|
1640
1684
|
declare function discoverWorkflowModels(config: WorkflowDiscoveryConfig, options: WorkflowDiscoveryOptions): Promise<WorkflowDiscoveryResult>;
|
|
1641
1685
|
|
|
1642
|
-
export { AGENT_PRIVILEGES, type ActionResponsePayload, type AdditionalContext, type AiChatAvailableModels, type AiModel, BUNDLED_CLIENT_ID, CLIENT_VERSION, type ClientEvent, DEFAULT_AGENT_PRIVILEGES, DEFAULT_AI_GATEWAY_URL, DEFAULT_CLIENT_CAPABILITIES, DEFAULT_WORKFLOW_DEFINITION, type DirectAccessToken, type DiscoveredModels, type DiscoveredWorkflowModel, GITLAB_COM_URL, type GenerateTokenResponse, type GitLabAgenticOptions, type GitLabAnthropicConfig, GitLabAnthropicLanguageModel, GitLabDirectAccessClient, type GitLabDirectAccessConfig, GitLabError, type GitLabErrorOptions, GitLabModelCache, GitLabModelConfigRegistry, GitLabModelDiscovery, GitLabOAuthManager, type GitLabOAuthTokenResponse, type GitLabOAuthTokens, type GitLabOpenAIConfig, GitLabOpenAILanguageModel, type GitLabProject, GitLabProjectCache, GitLabProjectDetector, type GitLabProjectDetectorConfig, type GitLabProvider, type GitLabProviderSettings, GitLabWorkflowClient, type GitLabWorkflowClientConfig, GitLabWorkflowLanguageModel, type GitLabWorkflowLanguageModelConfig, type GitLabWorkflowOptions, GitLabWorkflowTokenClient, MODEL_ID_TO_ANTHROPIC_MODEL, MODEL_MAPPINGS, type McpToolDefinition, type ModelCacheEntry, type ModelConfig, type ModelConfigRegistryOptions, type ModelDiscoveryConfig, type ModelMapping, type ModelProvider, type NewCheckpoint, OAUTH_SCOPES, OPENCODE_GITLAB_AUTH_CLIENT_ID, type OpenAIApiType, type OpenCodeAuth, type OpenCodeAuthApi, type OpenCodeAuthOAuth, type RunMcpTool, type StartRequest, TOKEN_EXPIRY_SKEW_MS, VERSION, WORKFLOW_ENVIRONMENT, WS_HEARTBEAT_INTERVAL_MS, WS_KEEPALIVE_PING_INTERVAL_MS, type WorkflowAction, type WorkflowClientEvent, type WorkflowDiscoveryConfig, type WorkflowDiscoveryOptions, type WorkflowDiscoveryResult, type WorkflowStatus, type WorkflowToolExecutor, WorkflowType, type WorkflowWebSocketOptions, createGitLab, discoverWorkflowModels, getAnthropicModelForModelId, getModelMapping, getOpenAIApiType, getOpenAIModelForModelId, getProviderForModelId, getValidModelsForProvider, getWorkflowModelRef, gitlab, isResponsesApiModel, isWorkflowModel, parseModelsYml };
|
|
1686
|
+
export { AGENT_PRIVILEGES, type ActionResponsePayload, type AdditionalContext, type AiChatAvailableModels, type AiModel, type ApprovalDecision, BUNDLED_CLIENT_ID, CLIENT_VERSION, type ClientEvent, DEFAULT_AGENT_PRIVILEGES, DEFAULT_AI_GATEWAY_URL, DEFAULT_CLIENT_CAPABILITIES, DEFAULT_WORKFLOW_DEFINITION, type DirectAccessToken, type DiscoveredModels, type DiscoveredWorkflowModel, GITLAB_COM_URL, type GenerateTokenResponse, type GitLabAgenticOptions, type GitLabAnthropicConfig, GitLabAnthropicLanguageModel, GitLabDirectAccessClient, type GitLabDirectAccessConfig, GitLabError, type GitLabErrorOptions, GitLabModelCache, GitLabModelConfigRegistry, GitLabModelDiscovery, GitLabOAuthManager, type GitLabOAuthTokenResponse, type GitLabOAuthTokens, type GitLabOpenAIConfig, GitLabOpenAILanguageModel, type GitLabProject, GitLabProjectCache, GitLabProjectDetector, type GitLabProjectDetectorConfig, type GitLabProvider, type GitLabProviderSettings, GitLabWorkflowClient, type GitLabWorkflowClientConfig, GitLabWorkflowLanguageModel, type GitLabWorkflowLanguageModelConfig, type GitLabWorkflowOptions, GitLabWorkflowTokenClient, MODEL_ID_TO_ANTHROPIC_MODEL, MODEL_MAPPINGS, type McpToolDefinition, type ModelCacheEntry, type ModelConfig, type ModelConfigRegistryOptions, type ModelDiscoveryConfig, type ModelMapping, type ModelProvider, type NewCheckpoint, OAUTH_SCOPES, OPENCODE_GITLAB_AUTH_CLIENT_ID, type OpenAIApiType, type OpenCodeAuth, type OpenCodeAuthApi, type OpenCodeAuthOAuth, type RunMcpTool, type StartRequest, TOKEN_EXPIRY_SKEW_MS, VERSION, WORKFLOW_ENVIRONMENT, WS_HEARTBEAT_INTERVAL_MS, WS_KEEPALIVE_PING_INTERVAL_MS, type WorkflowAction, type WorkflowClientEvent, type WorkflowDiscoveryConfig, type WorkflowDiscoveryOptions, type WorkflowDiscoveryResult, type WorkflowStatus, type WorkflowToolExecutor, WorkflowType, type WorkflowWebSocketOptions, createGitLab, discoverWorkflowModels, getAnthropicModelForModelId, getModelMapping, getOpenAIApiType, getOpenAIModelForModelId, getProviderForModelId, getValidModelsForProvider, getWorkflowModelRef, gitlab, isResponsesApiModel, isWorkflowModel, parseModelsYml };
|