@ai-sdk/harness-codex 1.0.40 → 1.0.42
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 +16 -0
- package/dist/bridge/index.mjs +10 -42
- package/dist/bridge/index.mjs.map +1 -1
- package/dist/bridge/package.json +1 -3
- package/dist/bridge/pnpm-lock.yaml +0 -769
- package/dist/index.js +5 -10
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
- package/src/bridge/index.ts +16 -70
- package/src/bridge/package.json +1 -3
- package/src/bridge/pnpm-lock.yaml +0 -769
- package/src/codex-harness.ts +2 -7
- package/dist/bridge/host-tool-mcp.mjs +0 -103
- package/dist/bridge/host-tool-mcp.mjs.map +0 -1
- package/src/bridge/host-tool-mcp.ts +0 -160
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @ai-sdk/harness-codex
|
|
2
2
|
|
|
3
|
+
## 1.0.42
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [59a2306]
|
|
8
|
+
- Updated dependencies [5f65e61]
|
|
9
|
+
- @ai-sdk/harness@1.0.40
|
|
10
|
+
|
|
11
|
+
## 1.0.41
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- b2f553b: fix(harness-codex): route Codex host tools through the CLI relay only instead of registering them as MCP tools
|
|
16
|
+
- Updated dependencies [86a84c9]
|
|
17
|
+
- @ai-sdk/harness@1.0.39
|
|
18
|
+
|
|
3
19
|
## 1.0.40
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/bridge/index.mjs
CHANGED
|
@@ -53,6 +53,7 @@ async function runBridge(options) {
|
|
|
53
53
|
let currentBoundPort = 0;
|
|
54
54
|
let currentTurnState = "init";
|
|
55
55
|
let activeSocket;
|
|
56
|
+
let activeSocketReadyForLiveEvents = false;
|
|
56
57
|
let isFirstTurn = true;
|
|
57
58
|
let turnAbort;
|
|
58
59
|
let currentUserMessages;
|
|
@@ -152,7 +153,7 @@ async function runBridge(options) {
|
|
|
152
153
|
diskBuffer += `${line}
|
|
153
154
|
`;
|
|
154
155
|
scheduleEventFlush();
|
|
155
|
-
if (activeSocket?.readyState === WS_OPEN) {
|
|
156
|
+
if (activeSocketReadyForLiveEvents && activeSocket?.readyState === WS_OPEN) {
|
|
156
157
|
try {
|
|
157
158
|
activeSocket.send(line);
|
|
158
159
|
} catch {
|
|
@@ -255,6 +256,8 @@ async function runBridge(options) {
|
|
|
255
256
|
const handleInbound = async (msg, ws) => {
|
|
256
257
|
switch (msg.type) {
|
|
257
258
|
case "start": {
|
|
259
|
+
if (activeSocket !== ws) return;
|
|
260
|
+
activeSocketReadyForLiveEvents = true;
|
|
258
261
|
const firstTurn = isFirstTurn;
|
|
259
262
|
isFirstTurn = false;
|
|
260
263
|
eventLog = [];
|
|
@@ -357,7 +360,9 @@ async function runBridge(options) {
|
|
|
357
360
|
}
|
|
358
361
|
return;
|
|
359
362
|
case "resume":
|
|
363
|
+
if (activeSocket !== ws) return;
|
|
360
364
|
replay(ws, msg.lastSeenEventId);
|
|
365
|
+
activeSocketReadyForLiveEvents = true;
|
|
361
366
|
return;
|
|
362
367
|
case "shutdown":
|
|
363
368
|
currentTurnState = "done";
|
|
@@ -422,6 +427,7 @@ async function runBridge(options) {
|
|
|
422
427
|
return;
|
|
423
428
|
}
|
|
424
429
|
activeSocket = ws;
|
|
430
|
+
activeSocketReadyForLiveEvents = false;
|
|
425
431
|
sendControl({
|
|
426
432
|
type: "bridge-hello",
|
|
427
433
|
state: currentTurnState,
|
|
@@ -444,6 +450,7 @@ async function runBridge(options) {
|
|
|
444
450
|
ws.on("close", () => {
|
|
445
451
|
if (activeSocket === ws) {
|
|
446
452
|
activeSocket = void 0;
|
|
453
|
+
activeSocketReadyForLiveEvents = false;
|
|
447
454
|
}
|
|
448
455
|
});
|
|
449
456
|
ws.on("error", () => {
|
|
@@ -958,7 +965,6 @@ var cliShimDir = requireArg({
|
|
|
958
965
|
value: args.cliShimDir,
|
|
959
966
|
name: "--cli-shim-dir"
|
|
960
967
|
});
|
|
961
|
-
var bootstrapDir = args.bootstrapDir ?? workdir;
|
|
962
968
|
var HARNESS_CLIENT_APP = procEnv2.AI_SDK_HARNESS_CLIENT_APP;
|
|
963
969
|
var codexSdk = codexSdkModule;
|
|
964
970
|
var threadState = { id: void 0 };
|
|
@@ -973,7 +979,6 @@ async function runTurn(start, turn) {
|
|
|
973
979
|
if (typeof start.resumeThreadId === "string" && start.resumeThreadId.length > 0) {
|
|
974
980
|
threadState.id = start.resumeThreadId;
|
|
975
981
|
}
|
|
976
|
-
const mcpServers = {};
|
|
977
982
|
let relay;
|
|
978
983
|
let cliShimPath;
|
|
979
984
|
if (start.tools && start.tools.length > 0) {
|
|
@@ -983,21 +988,6 @@ async function runTurn(start, turn) {
|
|
|
983
988
|
emit,
|
|
984
989
|
requestToolResult: turn.requestToolResult
|
|
985
990
|
});
|
|
986
|
-
mcpServers["harness-tools"] = {
|
|
987
|
-
enabled: true,
|
|
988
|
-
command: "node",
|
|
989
|
-
args: [`${bootstrapDir}/host-tool-mcp.mjs`],
|
|
990
|
-
env: {
|
|
991
|
-
TOOL_SCHEMAS: JSON.stringify(
|
|
992
|
-
start.tools.map((t) => ({
|
|
993
|
-
name: t.name,
|
|
994
|
-
description: t.description,
|
|
995
|
-
inputSchema: t.inputSchema
|
|
996
|
-
}))
|
|
997
|
-
),
|
|
998
|
-
TOOL_RELAY_URL: `http://127.0.0.1:${relay.port}`
|
|
999
|
-
}
|
|
1000
|
-
};
|
|
1001
991
|
await mkdir2(cliShimDir, { recursive: true });
|
|
1002
992
|
await writeFile2(
|
|
1003
993
|
cliShimPath,
|
|
@@ -1006,7 +996,6 @@ async function runTurn(start, turn) {
|
|
|
1006
996
|
);
|
|
1007
997
|
}
|
|
1008
998
|
const codexConfig = {};
|
|
1009
|
-
if (Object.keys(mcpServers).length > 0) codexConfig.mcp_servers = mcpServers;
|
|
1010
999
|
const gatewayBaseUrl = procEnv2.AI_GATEWAY_BASE_URL;
|
|
1011
1000
|
const hasGatewayAuth = Boolean(procEnv2.AI_GATEWAY_API_KEY || gatewayBaseUrl);
|
|
1012
1001
|
if (hasGatewayAuth && !gatewayBaseUrl) {
|
|
@@ -1086,12 +1075,6 @@ async function runTurn(start, turn) {
|
|
|
1086
1075
|
continue;
|
|
1087
1076
|
}
|
|
1088
1077
|
}
|
|
1089
|
-
if (relay && isHostMcpToolEvent(event)) {
|
|
1090
|
-
stepTracker.observeEvent({ event, itemId: event.item?.id });
|
|
1091
|
-
const relayCall = relayCallFromCodexMcpEvent(event);
|
|
1092
|
-
if (relayCall) relay.authorizeToolCall(relayCall);
|
|
1093
|
-
continue;
|
|
1094
|
-
}
|
|
1095
1078
|
translateAndEmit(event, {
|
|
1096
1079
|
send: emit,
|
|
1097
1080
|
textByItem,
|
|
@@ -1125,18 +1108,6 @@ function extractMcpToolCallResult(item) {
|
|
|
1125
1108
|
}
|
|
1126
1109
|
return result.content ?? null;
|
|
1127
1110
|
}
|
|
1128
|
-
function isHostMcpToolEvent(event) {
|
|
1129
|
-
return event.item?.type === "mcp_tool_call" && event.item.server === "harness-tools";
|
|
1130
|
-
}
|
|
1131
|
-
function relayCallFromCodexMcpEvent(event) {
|
|
1132
|
-
if (event.type !== "item.started") return void 0;
|
|
1133
|
-
const toolName = event.item?.tool;
|
|
1134
|
-
if (!toolName) return void 0;
|
|
1135
|
-
return {
|
|
1136
|
-
toolName,
|
|
1137
|
-
input: event.item?.arguments ?? {}
|
|
1138
|
-
};
|
|
1139
|
-
}
|
|
1140
1111
|
function translateAndEmit(event, ctx) {
|
|
1141
1112
|
if (event.type === "turn.completed") {
|
|
1142
1113
|
if (event.usage) ctx.setTurnUsage(mapUsage(event.usage));
|
|
@@ -1221,15 +1192,14 @@ function translateAndEmit(event, ctx) {
|
|
|
1221
1192
|
return;
|
|
1222
1193
|
}
|
|
1223
1194
|
if (item.type === "mcp_tool_call") {
|
|
1224
|
-
const isHostTool = item.server === "harness-tools";
|
|
1225
1195
|
if (event.type === "item.started") {
|
|
1226
1196
|
ctx.send({
|
|
1227
1197
|
type: "tool-call",
|
|
1228
1198
|
toolCallId: id,
|
|
1229
1199
|
toolName: item.tool ?? "unknown",
|
|
1230
|
-
|
|
1200
|
+
nativeName: item.tool ?? "unknown",
|
|
1231
1201
|
input: JSON.stringify(item.arguments ?? {}),
|
|
1232
|
-
providerExecuted:
|
|
1202
|
+
providerExecuted: true
|
|
1233
1203
|
});
|
|
1234
1204
|
} else if (event.type === "item.completed") {
|
|
1235
1205
|
ctx.send({
|
|
@@ -1311,8 +1281,6 @@ function parseArgs(args2) {
|
|
|
1311
1281
|
out.workdir = args2[++i];
|
|
1312
1282
|
} else if (args2[i] === "--bridge-state-dir" && i + 1 < args2.length) {
|
|
1313
1283
|
out.bridgeStateDir = args2[++i];
|
|
1314
|
-
} else if (args2[i] === "--bootstrap-dir" && i + 1 < args2.length) {
|
|
1315
|
-
out.bootstrapDir = args2[++i];
|
|
1316
1284
|
} else if (args2[i] === "--cli-shim-dir" && i + 1 < args2.length) {
|
|
1317
1285
|
out.cliShimDir = args2[++i];
|
|
1318
1286
|
}
|