@ai-sdk/harness-acp 1.0.29 → 1.0.30
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 +8 -0
- package/dist/bridge/host-tool-mcp.mjs +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +43 -16
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/acp-auth.ts +38 -13
- package/src/index.ts +1 -2
- package/src/v1/acp-v1-harness.ts +6 -0
- package/src/v1/acp-v1-settings.ts +3 -2
- package/src/v1/implementation.ts +9 -4
- package/src/v1/index.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/harness-acp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.30",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@ai-sdk/harness": "1.0.
|
|
29
|
+
"@ai-sdk/harness": "1.0.92",
|
|
30
30
|
"@ai-sdk/provider-utils": "5.0.32",
|
|
31
31
|
"ws": "^8.21.0"
|
|
32
32
|
},
|
package/src/acp-auth.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
getAiGatewayAuthFromEnv,
|
|
4
|
+
isHarnessAuthenticationEnvironment,
|
|
5
|
+
} from '@ai-sdk/harness/utils';
|
|
3
6
|
import type {
|
|
4
7
|
ACPAuthentication,
|
|
8
|
+
ACPAuthenticationMode as ACPV1AuthenticationMode,
|
|
5
9
|
ACPProviderAuthentication,
|
|
6
|
-
ACPProviderAuthenticationMode,
|
|
7
10
|
} from './v1';
|
|
8
11
|
import type { ACPResolvedProviderAuthentication } from './v1/bridge/acp-v1-bridge-environment';
|
|
9
12
|
|
|
10
13
|
const DEFAULT_AI_GATEWAY_BASE_URL = 'https://ai-gateway.vercel.sh';
|
|
11
14
|
|
|
12
|
-
export type
|
|
15
|
+
export type ACPAuthenticationMode = ACPV1AuthenticationMode;
|
|
13
16
|
|
|
14
17
|
export type ACPClientApp = {
|
|
15
18
|
readonly name: string;
|
|
@@ -17,7 +20,7 @@ export type ACPClientApp = {
|
|
|
17
20
|
};
|
|
18
21
|
|
|
19
22
|
type ACPAuthResolutionOptions = {
|
|
20
|
-
readonly mode?:
|
|
23
|
+
readonly mode?: ACPAuthenticationMode;
|
|
21
24
|
readonly providerAuthentication: ACPProviderAuthentication | undefined;
|
|
22
25
|
readonly clientApp: ACPClientApp;
|
|
23
26
|
};
|
|
@@ -102,6 +105,10 @@ export function resolveACPProviderAuthentication({
|
|
|
102
105
|
AI_SDK_ACP_CLIENT_APP_NAME: auth.clientApp.name,
|
|
103
106
|
AI_SDK_ACP_CLIENT_APP_VERSION: auth.clientApp.version,
|
|
104
107
|
};
|
|
108
|
+
const resolvedEnv = resolveACPAuthenticationEnvironment({
|
|
109
|
+
auth: auth.mode,
|
|
110
|
+
env,
|
|
111
|
+
});
|
|
105
112
|
const providerAuthentication = auth.providerAuthentication;
|
|
106
113
|
if (providerAuthentication == null) {
|
|
107
114
|
return { providerAuthentication: undefined, env: clientAppEnv };
|
|
@@ -114,7 +121,7 @@ export function resolveACPProviderAuthentication({
|
|
|
114
121
|
};
|
|
115
122
|
}
|
|
116
123
|
|
|
117
|
-
const mode = auth.mode
|
|
124
|
+
const mode = resolveACPProviderAuthenticationMode(auth.mode);
|
|
118
125
|
if (mode === 'direct') {
|
|
119
126
|
return {
|
|
120
127
|
providerAuthentication: { type: 'direct' },
|
|
@@ -126,12 +133,12 @@ export function resolveACPProviderAuthentication({
|
|
|
126
133
|
compatibility?.type === 'ai-gateway'
|
|
127
134
|
? {
|
|
128
135
|
apiKey: resolveGatewayCredential({
|
|
129
|
-
env,
|
|
136
|
+
env: resolvedEnv,
|
|
130
137
|
credentialSource: compatibility.credentialSource,
|
|
131
138
|
}),
|
|
132
139
|
baseUrl: compatibility.baseUrl,
|
|
133
140
|
}
|
|
134
|
-
: getAiGatewayAuthFromEnv({ env });
|
|
141
|
+
: getAiGatewayAuthFromEnv({ env: resolvedEnv });
|
|
135
142
|
const apiKey = gateway.apiKey;
|
|
136
143
|
if (compatibility == null && mode === 'auto' && apiKey == null) {
|
|
137
144
|
return {
|
|
@@ -166,20 +173,22 @@ export function resolveACPProviderAuthenticationCompatibility({
|
|
|
166
173
|
providerAuthentication,
|
|
167
174
|
env,
|
|
168
175
|
}: {
|
|
169
|
-
auth?:
|
|
176
|
+
auth?: ACPAuthenticationMode;
|
|
170
177
|
providerAuthentication: ACPProviderAuthentication | undefined;
|
|
171
178
|
env: Record<string, string | undefined>;
|
|
172
179
|
}): ACPProviderAuthenticationCompatibility | undefined {
|
|
180
|
+
const resolvedEnv = resolveACPAuthenticationEnvironment({
|
|
181
|
+
auth,
|
|
182
|
+
env,
|
|
183
|
+
});
|
|
173
184
|
if (providerAuthentication == null) return undefined;
|
|
174
185
|
|
|
175
|
-
const mode = auth;
|
|
186
|
+
const mode = resolveACPProviderAuthenticationMode(auth);
|
|
176
187
|
if (mode === 'direct') {
|
|
177
188
|
return { type: 'direct', mode };
|
|
178
189
|
}
|
|
179
190
|
|
|
180
|
-
const credentialSource = resolveGatewayCredentialSource({
|
|
181
|
-
env,
|
|
182
|
-
});
|
|
191
|
+
const credentialSource = resolveGatewayCredentialSource({ env: resolvedEnv });
|
|
183
192
|
if (mode === 'auto' && credentialSource == null) {
|
|
184
193
|
return { type: 'direct', mode };
|
|
185
194
|
}
|
|
@@ -189,10 +198,26 @@ export function resolveACPProviderAuthenticationCompatibility({
|
|
|
189
198
|
mode,
|
|
190
199
|
env: providerAuthentication.gateway.env,
|
|
191
200
|
credentialSource,
|
|
192
|
-
baseUrl:
|
|
201
|
+
baseUrl: resolvedEnv.AI_GATEWAY_BASE_URL ?? DEFAULT_AI_GATEWAY_BASE_URL,
|
|
193
202
|
};
|
|
194
203
|
}
|
|
195
204
|
|
|
205
|
+
function resolveACPProviderAuthenticationMode(
|
|
206
|
+
auth: ACPAuthenticationMode | undefined,
|
|
207
|
+
): Extract<ACPAuthenticationMode, string> {
|
|
208
|
+
return typeof auth === 'string' || auth == null ? (auth ?? 'auto') : 'auto';
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export function resolveACPAuthenticationEnvironment({
|
|
212
|
+
auth,
|
|
213
|
+
env,
|
|
214
|
+
}: {
|
|
215
|
+
auth: ACPAuthenticationMode | undefined;
|
|
216
|
+
env: Record<string, string | undefined>;
|
|
217
|
+
}): Record<string, string | undefined> {
|
|
218
|
+
return isHarnessAuthenticationEnvironment(auth) ? auth : env;
|
|
219
|
+
}
|
|
220
|
+
|
|
196
221
|
export function resolveACPEnv({
|
|
197
222
|
auth,
|
|
198
223
|
env,
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { createACP } from './acp-harness';
|
|
2
|
-
export type {
|
|
2
|
+
export type { ACPAuthenticationMode, ACPClientApp } from './acp-auth';
|
|
3
3
|
export type { ACPHarnessSettings } from './acp-harness';
|
|
4
4
|
export type {
|
|
5
5
|
ACPAnnotations,
|
|
@@ -31,7 +31,6 @@ export type {
|
|
|
31
31
|
ACPPermissionModeTarget,
|
|
32
32
|
ACPProfileValue,
|
|
33
33
|
ACPProviderAuthentication,
|
|
34
|
-
ACPProviderAuthenticationMode,
|
|
35
34
|
ACPSerializablePrimitive,
|
|
36
35
|
ACPSerializableValue,
|
|
37
36
|
ACPSource,
|
package/src/v1/acp-v1-harness.ts
CHANGED
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
import { WebSocket } from 'ws';
|
|
40
40
|
import {
|
|
41
41
|
createACPAuthenticationProfileIdentity,
|
|
42
|
+
resolveACPAuthenticationEnvironment,
|
|
42
43
|
resolveACPProviderAuthentication,
|
|
43
44
|
resolveACPProviderAuthenticationCompatibility,
|
|
44
45
|
type ACPAuthenticationProfileIdentity,
|
|
@@ -188,6 +189,10 @@ export function createACPV1<TBuiltinTools extends ToolSet = {}>({
|
|
|
188
189
|
}
|
|
189
190
|
const permissionMode = startOptions.permissionMode ?? 'allow-all';
|
|
190
191
|
const env = { ...process.env };
|
|
192
|
+
const authenticationEnvironment = resolveACPAuthenticationEnvironment({
|
|
193
|
+
auth: settings.auth,
|
|
194
|
+
env,
|
|
195
|
+
});
|
|
191
196
|
const providerAuthenticationCompatibility =
|
|
192
197
|
resolveACPProviderAuthenticationCompatibility({
|
|
193
198
|
auth: settings.auth,
|
|
@@ -259,6 +264,7 @@ export function createACPV1<TBuiltinTools extends ToolSet = {}>({
|
|
|
259
264
|
const implementationEnvironment = resolveImplementationEnvironment({
|
|
260
265
|
implementation,
|
|
261
266
|
env,
|
|
267
|
+
credentialEnv: authenticationEnvironment,
|
|
262
268
|
});
|
|
263
269
|
let sandboxImplementationEnvironment = implementationEnvironment;
|
|
264
270
|
let sandboxProviderAuthenticationEnvironment =
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
HarnessV1Authentication,
|
|
2
3
|
HarnessV1CredentialForwarding,
|
|
3
4
|
HarnessV1PermissionMode,
|
|
4
5
|
HarnessV1RequestTransformation,
|
|
@@ -66,7 +67,7 @@ export type ACPAuthentication = {
|
|
|
66
67
|
readonly clientCapabilities?: Readonly<Record<string, ACPSerializableValue>>;
|
|
67
68
|
};
|
|
68
69
|
|
|
69
|
-
export type
|
|
70
|
+
export type ACPAuthenticationMode = HarnessV1Authentication;
|
|
70
71
|
|
|
71
72
|
export type ACPProviderAuthentication = {
|
|
72
73
|
readonly gateway: {
|
|
@@ -123,7 +124,7 @@ export type ACPV1Settings = {
|
|
|
123
124
|
readonly harnessId: string;
|
|
124
125
|
readonly mcpServers?: Record<string, unknown>;
|
|
125
126
|
readonly isMcpToolCall?: (toolCall: ACPToolCall) => boolean;
|
|
126
|
-
readonly auth?:
|
|
127
|
+
readonly auth?: ACPAuthenticationMode;
|
|
127
128
|
readonly source: ACPSource;
|
|
128
129
|
readonly executable: string;
|
|
129
130
|
readonly args?: ReadonlyArray<string>;
|
package/src/v1/implementation.ts
CHANGED
|
@@ -277,20 +277,25 @@ ${implementation.source.command}
|
|
|
277
277
|
export function resolveImplementationEnvironment({
|
|
278
278
|
implementation,
|
|
279
279
|
env,
|
|
280
|
+
credentialEnv = env,
|
|
280
281
|
}: {
|
|
281
282
|
implementation: ACPImplementation;
|
|
282
283
|
env: Readonly<Record<string, string | undefined>>;
|
|
284
|
+
credentialEnv?: Readonly<Record<string, string | undefined>>;
|
|
283
285
|
}): Record<string, string> {
|
|
284
286
|
const forwardedEnvironment: Record<string, string> = {};
|
|
285
|
-
for (const name of [
|
|
286
|
-
...(implementation.forwardEnv ?? []),
|
|
287
|
-
...(implementation.credentialEnv ?? []),
|
|
288
|
-
]) {
|
|
287
|
+
for (const name of implementation.forwardEnv ?? []) {
|
|
289
288
|
const value = env[name];
|
|
290
289
|
if (value != null && value.length > 0) {
|
|
291
290
|
forwardedEnvironment[name] = value;
|
|
292
291
|
}
|
|
293
292
|
}
|
|
293
|
+
for (const name of implementation.credentialEnv ?? []) {
|
|
294
|
+
const value = credentialEnv[name];
|
|
295
|
+
if (value != null && value.length > 0) {
|
|
296
|
+
forwardedEnvironment[name] = value;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
294
299
|
return {
|
|
295
300
|
...forwardedEnvironment,
|
|
296
301
|
...implementation.env,
|
package/src/v1/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { createACPV1 } from './acp-v1-harness';
|
|
|
2
2
|
export type {
|
|
3
3
|
ACPCredentialBrokering,
|
|
4
4
|
ACPAuthentication,
|
|
5
|
+
ACPAuthenticationMode,
|
|
5
6
|
ACPInstallCommandSource,
|
|
6
7
|
ACPInstructionMapping,
|
|
7
8
|
ACPNpmLockedSource,
|
|
@@ -11,7 +12,6 @@ export type {
|
|
|
11
12
|
ACPPermissionModeTarget,
|
|
12
13
|
ACPProfileValue,
|
|
13
14
|
ACPProviderAuthentication,
|
|
14
|
-
ACPProviderAuthenticationMode,
|
|
15
15
|
ACPSerializablePrimitive,
|
|
16
16
|
ACPSerializableValue,
|
|
17
17
|
ACPSource,
|