@ai-sdk/harness-acp 1.0.0 → 1.0.1
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 +11 -0
- package/README.md +5 -6
- package/dist/bridge/host-tool-mcp.mjs +1 -1
- package/dist/bridge/index.mjs +71 -32
- package/dist/bridge/index.mjs.map +1 -1
- package/dist/index.d.ts +25 -19
- package/dist/index.js +98 -103
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/acp-harness.ts +7 -60
- package/src/index.ts +3 -3
- package/src/v1/acp-v1-harness.ts +32 -18
- package/src/v1/acp-v1-settings.ts +19 -20
- package/src/v1/bridge/acp-diagnostics.ts +27 -1
- package/src/v1/bridge/agent-stderr-monitor.ts +52 -0
- package/src/v1/bridge/index.ts +19 -34
- package/src/v1/implementation.ts +73 -47
- package/src/v1/index.ts +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @ai-sdk/harness-acp
|
|
2
2
|
|
|
3
|
+
## 1.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6f54e1d: feat(harness-acp): further simplify public `createACP()` API
|
|
8
|
+
- 15d0475: fix(harness-acp): defer auth resolution until session start to correctly recognize available credentials
|
|
9
|
+
- faaabb0: fix(harness-acp): improve bridge error handling to prevent infinite hang on certain errors
|
|
10
|
+
- Updated dependencies [81cd026]
|
|
11
|
+
- @ai-sdk/provider-utils@5.0.25
|
|
12
|
+
- @ai-sdk/harness@1.0.64
|
|
13
|
+
|
|
3
14
|
## 1.0.0
|
|
4
15
|
|
|
5
16
|
### Major Changes
|
package/README.md
CHANGED
|
@@ -27,14 +27,13 @@ import { createVercelSandbox } from '@ai-sdk/sandbox-vercel';
|
|
|
27
27
|
|
|
28
28
|
const codexACP = createACP({
|
|
29
29
|
harnessId: 'acp-codex',
|
|
30
|
-
|
|
31
|
-
type: 'npm',
|
|
32
|
-
mode: 'simple',
|
|
30
|
+
source: {
|
|
31
|
+
type: 'npm-simple',
|
|
33
32
|
packageName: '@agentclientprotocol/codex-acp',
|
|
34
|
-
|
|
35
|
-
executable: 'codex-acp',
|
|
36
|
-
forwardEnv: ['CODEX_API_KEY', 'OPENAI_API_KEY'],
|
|
33
|
+
packageVersion: '1.1.4',
|
|
37
34
|
},
|
|
35
|
+
executable: 'codex-acp',
|
|
36
|
+
forwardEnv: ['CODEX_API_KEY', 'OPENAI_API_KEY'],
|
|
38
37
|
permissionModeMapping: {
|
|
39
38
|
'allow-reads': null,
|
|
40
39
|
'allow-edits': null,
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
ListToolsRequestSchema,
|
|
13
13
|
McpError
|
|
14
14
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
15
|
-
var VERSION = true ? "1.0.
|
|
15
|
+
var VERSION = true ? "1.0.1" : "0.0.0-test";
|
|
16
16
|
function createHostToolMCPServer({
|
|
17
17
|
tools: tools2,
|
|
18
18
|
revision = 1,
|
package/dist/bridge/index.mjs
CHANGED
|
@@ -820,10 +820,25 @@ function createACPBridgeError({
|
|
|
820
820
|
stage,
|
|
821
821
|
cause
|
|
822
822
|
}) {
|
|
823
|
-
const
|
|
823
|
+
const causeMessage = getErrorMessage({ error: cause });
|
|
824
|
+
const error = new Error(
|
|
825
|
+
causeMessage == null ? `ACP ${stage} failed.` : `ACP ${stage} failed: ${causeMessage}`
|
|
826
|
+
);
|
|
824
827
|
error.cause = cause;
|
|
825
828
|
return error;
|
|
826
829
|
}
|
|
830
|
+
function getErrorMessage({ error }) {
|
|
831
|
+
if (error instanceof Error) {
|
|
832
|
+
return error.message;
|
|
833
|
+
}
|
|
834
|
+
if (error != null && typeof error === "object" && "message" in error && typeof error.message === "string") {
|
|
835
|
+
return error.message;
|
|
836
|
+
}
|
|
837
|
+
if (typeof error === "string") {
|
|
838
|
+
return error;
|
|
839
|
+
}
|
|
840
|
+
return void 0;
|
|
841
|
+
}
|
|
827
842
|
function stripMetadata({ value }) {
|
|
828
843
|
if (Array.isArray(value)) {
|
|
829
844
|
return value.map((item) => stripMetadata({ value: item }));
|
|
@@ -836,6 +851,42 @@ function stripMetadata({ value }) {
|
|
|
836
851
|
return result;
|
|
837
852
|
}
|
|
838
853
|
|
|
854
|
+
// src/v1/bridge/agent-stderr-monitor.ts
|
|
855
|
+
import { stripVTControlCharacters } from "util";
|
|
856
|
+
function monitorACPAgentStderr({
|
|
857
|
+
stderr,
|
|
858
|
+
onStderrLine
|
|
859
|
+
}) {
|
|
860
|
+
let rejectFailure;
|
|
861
|
+
const failure = new Promise((_, reject) => {
|
|
862
|
+
rejectFailure = reject;
|
|
863
|
+
});
|
|
864
|
+
void failure.catch(() => {
|
|
865
|
+
});
|
|
866
|
+
void (async () => {
|
|
867
|
+
stderr.setEncoding("utf8");
|
|
868
|
+
let pending = "";
|
|
869
|
+
for await (const chunk of stderr) {
|
|
870
|
+
pending += chunk;
|
|
871
|
+
const lines = pending.split("\n");
|
|
872
|
+
pending = lines.pop() ?? "";
|
|
873
|
+
for (const line of lines) handleStderrLine({ line });
|
|
874
|
+
}
|
|
875
|
+
if (pending.length > 0) handleStderrLine({ line: pending });
|
|
876
|
+
})().catch((error) => rejectFailure(error));
|
|
877
|
+
return failure;
|
|
878
|
+
function handleStderrLine({ line }) {
|
|
879
|
+
if (line.length === 0) return;
|
|
880
|
+
onStderrLine(line);
|
|
881
|
+
const normalizedLine = stripVTControlCharacters(line);
|
|
882
|
+
if (normalizedLine.toLowerCase().includes("failed to deserialize responsestreamevent from stream")) {
|
|
883
|
+
rejectFailure(
|
|
884
|
+
new Error("ACP agent failed to deserialize a streamed response.")
|
|
885
|
+
);
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
|
|
839
890
|
// src/v1/bridge/stream-translator.ts
|
|
840
891
|
function createACPStreamTranslator({
|
|
841
892
|
emit,
|
|
@@ -2713,6 +2764,7 @@ var implementation = await readImplementationDescriptor({
|
|
|
2713
2764
|
});
|
|
2714
2765
|
var bridgeConfiguration = await readACPBridgeEnvironment({ env: processEnv });
|
|
2715
2766
|
var child;
|
|
2767
|
+
var agentResponseStreamFailure;
|
|
2716
2768
|
var connection;
|
|
2717
2769
|
var session;
|
|
2718
2770
|
var recoveredSessionUpdates;
|
|
@@ -2767,6 +2819,12 @@ async function runTurn(start, turn) {
|
|
|
2767
2819
|
if (activeSession == null) {
|
|
2768
2820
|
throw new Error("ACP session initialization did not produce a session.");
|
|
2769
2821
|
}
|
|
2822
|
+
const activeAgentResponseStreamFailure = agentResponseStreamFailure;
|
|
2823
|
+
if (activeAgentResponseStreamFailure == null) {
|
|
2824
|
+
throw new Error(
|
|
2825
|
+
"ACP session initialization did not start stderr monitoring."
|
|
2826
|
+
);
|
|
2827
|
+
}
|
|
2770
2828
|
if (start.recoveryMode?.type === "lossy-rerun") {
|
|
2771
2829
|
const marker = {
|
|
2772
2830
|
type: "acp-recovery",
|
|
@@ -2883,7 +2941,8 @@ async function runTurn(start, turn) {
|
|
|
2883
2941
|
try {
|
|
2884
2942
|
message = await Promise.race([
|
|
2885
2943
|
activeSession.nextUpdate(),
|
|
2886
|
-
cancellationFailure
|
|
2944
|
+
cancellationFailure,
|
|
2945
|
+
activeAgentResponseStreamFailure
|
|
2887
2946
|
]);
|
|
2888
2947
|
} catch (error) {
|
|
2889
2948
|
for (const rawValue of streamCapture?.drainRawValues() ?? []) {
|
|
@@ -2977,7 +3036,16 @@ async function ensureSession({
|
|
|
2977
3036
|
stdio: ["pipe", "pipe", "pipe"]
|
|
2978
3037
|
}
|
|
2979
3038
|
);
|
|
2980
|
-
|
|
3039
|
+
agentResponseStreamFailure = monitorACPAgentStderr({
|
|
3040
|
+
stderr: child.stderr,
|
|
3041
|
+
onStderrLine: (line) => {
|
|
3042
|
+
turn.bridgeLog({
|
|
3043
|
+
level: "warn",
|
|
3044
|
+
subsystem: "acp.agent.stderr",
|
|
3045
|
+
message: line
|
|
3046
|
+
});
|
|
3047
|
+
}
|
|
3048
|
+
});
|
|
2981
3049
|
const input = Writable.toWeb(child.stdin);
|
|
2982
3050
|
const output = Readable.toWeb(child.stdout);
|
|
2983
3051
|
const capturedStream = captureACPStream({
|
|
@@ -3207,35 +3275,6 @@ function createChildEnvironment({
|
|
|
3207
3275
|
function isRecord6(value) {
|
|
3208
3276
|
return value != null && typeof value === "object" && !Array.isArray(value);
|
|
3209
3277
|
}
|
|
3210
|
-
function forwardAgentStderr({
|
|
3211
|
-
child: child2,
|
|
3212
|
-
turn
|
|
3213
|
-
}) {
|
|
3214
|
-
void (async () => {
|
|
3215
|
-
child2.stderr.setEncoding("utf8");
|
|
3216
|
-
let pending = "";
|
|
3217
|
-
for await (const chunk of child2.stderr) {
|
|
3218
|
-
pending += chunk;
|
|
3219
|
-
const lines = pending.split("\n");
|
|
3220
|
-
pending = lines.pop() ?? "";
|
|
3221
|
-
for (const line of lines) {
|
|
3222
|
-
if (line.length === 0) continue;
|
|
3223
|
-
turn.bridgeLog({
|
|
3224
|
-
level: "warn",
|
|
3225
|
-
subsystem: "acp.agent.stderr",
|
|
3226
|
-
message: line
|
|
3227
|
-
});
|
|
3228
|
-
}
|
|
3229
|
-
}
|
|
3230
|
-
if (pending.length > 0) {
|
|
3231
|
-
turn.bridgeLog({
|
|
3232
|
-
level: "warn",
|
|
3233
|
-
subsystem: "acp.agent.stderr",
|
|
3234
|
-
message: pending
|
|
3235
|
-
});
|
|
3236
|
-
}
|
|
3237
|
-
})();
|
|
3238
|
-
}
|
|
3239
3278
|
async function readImplementationDescriptor({
|
|
3240
3279
|
path
|
|
3241
3280
|
}) {
|