@ai-sdk/harness-acp 1.0.31 → 1.0.33
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 +20 -0
- package/README.md +10 -9
- package/dist/bridge/host-tool-mcp.mjs +1 -1
- package/dist/bridge/index.mjs +59 -24
- package/dist/bridge/index.mjs.map +1 -1
- package/dist/index.d.ts +13 -17
- package/dist/index.js +86 -75
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/acp-harness.ts +8 -3
- package/src/index.ts +1 -2
- package/src/v1/{acp-bootstrap.ts → acp-v1-bootstrap.ts} +12 -20
- package/src/v1/acp-v1-bridge-protocol.ts +27 -6
- package/src/v1/acp-v1-harness.ts +41 -49
- package/src/v1/acp-v1-settings.ts +12 -16
- package/src/v1/acp-v1-turn-start-config.ts +7 -3
- package/src/v1/bridge/acp-v1-bridge-environment.ts +4 -8
- package/src/v1/bridge/index.ts +10 -2
- package/src/v1/bridge/model-mapping.ts +35 -0
- package/src/v1/bridge/protocol-configuration.ts +6 -2
- package/src/v1/implementation.ts +8 -0
- package/src/v1/index.ts +1 -2
- package/src/acp-bridge-protocol.ts +0 -13
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as acp from '@agentclientprotocol/sdk';
|
|
2
|
+
import type { ACPModelMapping } from '../acp-v1-settings';
|
|
3
|
+
|
|
4
|
+
export async function configureACPModel({
|
|
5
|
+
agent,
|
|
6
|
+
sessionId,
|
|
7
|
+
model,
|
|
8
|
+
mapping,
|
|
9
|
+
}: {
|
|
10
|
+
agent: acp.ClientContext;
|
|
11
|
+
sessionId: string;
|
|
12
|
+
model: string | undefined;
|
|
13
|
+
mapping: ACPModelMapping | undefined;
|
|
14
|
+
}): Promise<void> {
|
|
15
|
+
if (model == null) return;
|
|
16
|
+
if (mapping == null) {
|
|
17
|
+
throw new Error('ACP model mapping is required when a model is set.');
|
|
18
|
+
}
|
|
19
|
+
/*
|
|
20
|
+
* Some ACP harnesses, including Grok Build, use the non-standard
|
|
21
|
+
* `session/set_model` convention.
|
|
22
|
+
*/
|
|
23
|
+
if (mapping.type === 'session-model') {
|
|
24
|
+
await agent.request('session/set_model', {
|
|
25
|
+
sessionId,
|
|
26
|
+
[mapping.path]: model,
|
|
27
|
+
});
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
await agent.request(acp.methods.agent.session.setConfigOption, {
|
|
31
|
+
sessionId,
|
|
32
|
+
configId: mapping.path,
|
|
33
|
+
value: model,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
@@ -16,11 +16,13 @@ export function createACPInitializeRequest({
|
|
|
16
16
|
protocolVersion,
|
|
17
17
|
clientApp,
|
|
18
18
|
authentication,
|
|
19
|
+
clientCapabilities: configuredClientCapabilities,
|
|
19
20
|
supportsBooleanSessionConfigOptions = false,
|
|
20
21
|
}: {
|
|
21
22
|
protocolVersion: number;
|
|
22
23
|
clientApp: ACPClientApp;
|
|
23
24
|
authentication: ACPAuthentication | undefined;
|
|
25
|
+
clientCapabilities?: Readonly<Record<string, unknown>>;
|
|
24
26
|
supportsBooleanSessionConfigOptions?: boolean;
|
|
25
27
|
}): {
|
|
26
28
|
readonly protocolVersion: number;
|
|
@@ -30,8 +32,10 @@ export function createACPInitializeRequest({
|
|
|
30
32
|
};
|
|
31
33
|
readonly clientCapabilities: Readonly<Record<string, unknown>>;
|
|
32
34
|
} {
|
|
33
|
-
let clientCapabilities
|
|
34
|
-
authentication?.clientCapabilities ?? {}
|
|
35
|
+
let clientCapabilities = mergeRecords({
|
|
36
|
+
left: authentication?.clientCapabilities ?? {},
|
|
37
|
+
right: configuredClientCapabilities ?? {},
|
|
38
|
+
});
|
|
35
39
|
if (supportsBooleanSessionConfigOptions) {
|
|
36
40
|
clientCapabilities = mergeRecords({
|
|
37
41
|
left: clientCapabilities,
|
package/src/v1/implementation.ts
CHANGED
|
@@ -4,8 +4,10 @@ import type {
|
|
|
4
4
|
ACPProviderAuthenticationCompatibility,
|
|
5
5
|
} from '../acp-auth';
|
|
6
6
|
import type {
|
|
7
|
+
ACPModelMapping,
|
|
7
8
|
ACPNpmSimpleSource,
|
|
8
9
|
ACPPermissionModeMapping,
|
|
10
|
+
ACPSerializableValue,
|
|
9
11
|
ACPSource,
|
|
10
12
|
ACPV1Settings,
|
|
11
13
|
} from './acp-v1-settings';
|
|
@@ -172,6 +174,8 @@ export function createImplementationIdentity({
|
|
|
172
174
|
acpVersion,
|
|
173
175
|
implementation,
|
|
174
176
|
clientApp,
|
|
177
|
+
clientCapabilities,
|
|
178
|
+
modelMapping,
|
|
175
179
|
providerAuthentication,
|
|
176
180
|
permissionModeMapping,
|
|
177
181
|
}: {
|
|
@@ -179,6 +183,8 @@ export function createImplementationIdentity({
|
|
|
179
183
|
acpVersion: 'v1';
|
|
180
184
|
implementation: ACPImplementation;
|
|
181
185
|
clientApp: ACPClientApp;
|
|
186
|
+
clientCapabilities?: Readonly<Record<string, ACPSerializableValue>>;
|
|
187
|
+
modelMapping: ACPModelMapping;
|
|
182
188
|
providerAuthentication: ACPProviderAuthenticationCompatibility | undefined;
|
|
183
189
|
permissionModeMapping?: ACPPermissionModeMapping;
|
|
184
190
|
}): string {
|
|
@@ -221,6 +227,8 @@ export function createImplementationIdentity({
|
|
|
221
227
|
executable: implementation.executable,
|
|
222
228
|
args: implementation.args ?? [],
|
|
223
229
|
clientApp,
|
|
230
|
+
clientCapabilities: clientCapabilities ?? null,
|
|
231
|
+
modelMapping,
|
|
224
232
|
environment: {
|
|
225
233
|
forwarded: forwardedEnvironment,
|
|
226
234
|
credential: credentialEnvironment,
|
package/src/v1/index.ts
CHANGED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import * as acpV1BridgeProtocol from './v1/acp-v1-bridge-protocol';
|
|
2
|
-
|
|
3
|
-
export const outboundMessageSchema = acpV1BridgeProtocol.outboundMessageSchema;
|
|
4
|
-
export type OutboundMessage = acpV1BridgeProtocol.OutboundMessage;
|
|
5
|
-
|
|
6
|
-
export const startMessageSchema = acpV1BridgeProtocol.startMessageSchema;
|
|
7
|
-
export type StartMessage = acpV1BridgeProtocol.StartMessage;
|
|
8
|
-
|
|
9
|
-
export const inboundMessageSchema = acpV1BridgeProtocol.inboundMessageSchema;
|
|
10
|
-
export type InboundMessage = acpV1BridgeProtocol.InboundMessage;
|
|
11
|
-
|
|
12
|
-
export const bridgeReadySchema = acpV1BridgeProtocol.bridgeReadySchema;
|
|
13
|
-
export type BridgeReady = acpV1BridgeProtocol.BridgeReady;
|