@mrrlin-dev/mcp 0.4.107 → 0.4.108
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/dist/bin.cjs +298 -218
- package/package.json +1 -1
package/dist/bin.cjs
CHANGED
|
@@ -41024,8 +41024,8 @@ function createMrrlinClient(config2) {
|
|
|
41024
41024
|
throw error51;
|
|
41025
41025
|
}
|
|
41026
41026
|
},
|
|
41027
|
-
async getActiveAsyncJob(projectSlug,
|
|
41028
|
-
const url2 = appendQuery(`${projectPath(projectSlug)}/async-jobs/active`, { toolName, dedupKey });
|
|
41027
|
+
async getActiveAsyncJob(projectSlug, toolName2, dedupKey) {
|
|
41028
|
+
const url2 = appendQuery(`${projectPath(projectSlug)}/async-jobs/active`, { toolName: toolName2, dedupKey });
|
|
41029
41029
|
const body = await request(url2);
|
|
41030
41030
|
return asyncJobMaybeResponseSchema.parse(body).data;
|
|
41031
41031
|
},
|
|
@@ -44198,7 +44198,11 @@ var ClaudeProcess = class {
|
|
|
44198
44198
|
if (options.brokerSocket != null) {
|
|
44199
44199
|
stdio[3] = options.brokerSocket;
|
|
44200
44200
|
}
|
|
44201
|
-
|
|
44201
|
+
const [spawnExecutable, ...spawnArgs] = spawnCmd;
|
|
44202
|
+
if (spawnExecutable === void 0) {
|
|
44203
|
+
throw new Error("Claude command wrapper returned no executable");
|
|
44204
|
+
}
|
|
44205
|
+
this.child = (0, import_node_child_process3.spawn)(spawnExecutable, spawnArgs, {
|
|
44202
44206
|
cwd: options.cwd?.trim() || void 0,
|
|
44203
44207
|
// Inherit the operator's env so the CLI picks up their own ~/.claude.json tool registry —
|
|
44204
44208
|
// unless an explicit mcpConfig was provided in options.
|
|
@@ -44740,7 +44744,11 @@ var AgyProcess = class _AgyProcess {
|
|
|
44740
44744
|
if (options.brokerSocket != null) {
|
|
44741
44745
|
stdio[3] = options.brokerSocket;
|
|
44742
44746
|
}
|
|
44743
|
-
|
|
44747
|
+
const [spawnExecutable, ...spawnArgs] = spawnCmd;
|
|
44748
|
+
if (spawnExecutable === void 0) {
|
|
44749
|
+
throw new Error("Agy command wrapper returned no executable");
|
|
44750
|
+
}
|
|
44751
|
+
this.child = (0, import_node_child_process4.spawn)(spawnExecutable, spawnArgs, {
|
|
44744
44752
|
cwd,
|
|
44745
44753
|
env: options.env ?? process.env,
|
|
44746
44754
|
stdio
|
|
@@ -45854,7 +45862,7 @@ async function resolvePinnedProviderIps(hosts, options) {
|
|
|
45854
45862
|
result[normalized] = records;
|
|
45855
45863
|
continue;
|
|
45856
45864
|
}
|
|
45857
|
-
} catch (
|
|
45865
|
+
} catch (_err) {
|
|
45858
45866
|
if (options?.failClosedOnDnsError) {
|
|
45859
45867
|
if ((process.env.NODE_ENV === "test" || !process.env.NODE_ENV || process.env.MRRLIN_TEST === "1") && DEFAULT_PINNED_PROVIDER_IPS[normalized]) {
|
|
45860
45868
|
result[normalized] = DEFAULT_PINNED_PROVIDER_IPS[normalized];
|
|
@@ -45917,6 +45925,8 @@ function parseIpv4Bytes(ip) {
|
|
|
45917
45925
|
const out = new Uint8Array(4);
|
|
45918
45926
|
for (let i = 0; i < 4; i++) {
|
|
45919
45927
|
const p = parts[i];
|
|
45928
|
+
if (p === void 0)
|
|
45929
|
+
return null;
|
|
45920
45930
|
if (!/^\d+$/.test(p))
|
|
45921
45931
|
return null;
|
|
45922
45932
|
if (p.length > 1 && p.startsWith("0"))
|
|
@@ -45950,10 +45960,13 @@ function parseIpv6Bytes(ip) {
|
|
|
45950
45960
|
}
|
|
45951
45961
|
const out = new Uint8Array(16);
|
|
45952
45962
|
if (v4Bytes) {
|
|
45953
|
-
|
|
45954
|
-
|
|
45955
|
-
|
|
45956
|
-
out[
|
|
45963
|
+
const [first, second, third, fourth] = v4Bytes;
|
|
45964
|
+
if (first === void 0 || second === void 0 || third === void 0 || fourth === void 0)
|
|
45965
|
+
return null;
|
|
45966
|
+
out[12] = first;
|
|
45967
|
+
out[13] = second;
|
|
45968
|
+
out[14] = third;
|
|
45969
|
+
out[15] = fourth;
|
|
45957
45970
|
}
|
|
45958
45971
|
const targetGroupCount = v4Bytes ? 6 : 8;
|
|
45959
45972
|
if (doubleColonIdx === -1) {
|
|
@@ -45962,6 +45975,8 @@ function parseIpv6Bytes(ip) {
|
|
|
45962
45975
|
return null;
|
|
45963
45976
|
for (let i = 0; i < targetGroupCount; i++) {
|
|
45964
45977
|
const g = groups[i];
|
|
45978
|
+
if (g === void 0)
|
|
45979
|
+
return null;
|
|
45965
45980
|
if (!/^[0-9a-f]{1,4}$/.test(g))
|
|
45966
45981
|
return null;
|
|
45967
45982
|
const val = parseInt(g, 16);
|
|
@@ -45977,6 +45992,8 @@ function parseIpv6Bytes(ip) {
|
|
|
45977
45992
|
return null;
|
|
45978
45993
|
for (let i = 0; i < leftGroups.length; i++) {
|
|
45979
45994
|
const g = leftGroups[i];
|
|
45995
|
+
if (g === void 0)
|
|
45996
|
+
return null;
|
|
45980
45997
|
if (!/^[0-9a-f]{1,4}$/.test(g))
|
|
45981
45998
|
return null;
|
|
45982
45999
|
const val = parseInt(g, 16);
|
|
@@ -45986,6 +46003,8 @@ function parseIpv6Bytes(ip) {
|
|
|
45986
46003
|
const omitted = targetGroupCount - leftGroups.length - rightGroups.length;
|
|
45987
46004
|
for (let i = 0; i < rightGroups.length; i++) {
|
|
45988
46005
|
const g = rightGroups[i];
|
|
46006
|
+
if (g === void 0)
|
|
46007
|
+
return null;
|
|
45989
46008
|
if (!/^[0-9a-f]{1,4}$/.test(g))
|
|
45990
46009
|
return null;
|
|
45991
46010
|
const val = parseInt(g, 16);
|
|
@@ -45997,9 +46016,9 @@ function parseIpv6Bytes(ip) {
|
|
|
45997
46016
|
return out;
|
|
45998
46017
|
}
|
|
45999
46018
|
function isRestrictedIpv4Bytes(b) {
|
|
46000
|
-
const b0 = b
|
|
46001
|
-
|
|
46002
|
-
|
|
46019
|
+
const [b0, b1, b2] = b;
|
|
46020
|
+
if (b0 === void 0 || b1 === void 0 || b2 === void 0)
|
|
46021
|
+
return true;
|
|
46003
46022
|
if (b0 === 0)
|
|
46004
46023
|
return true;
|
|
46005
46024
|
if (b0 === 10)
|
|
@@ -46067,9 +46086,13 @@ function isRestrictedIp(ip) {
|
|
|
46067
46086
|
}
|
|
46068
46087
|
if (isLoopback)
|
|
46069
46088
|
return true;
|
|
46070
|
-
|
|
46089
|
+
const firstByte = v6[0];
|
|
46090
|
+
const secondByte = v6[1];
|
|
46091
|
+
if (firstByte === void 0 || secondByte === void 0)
|
|
46071
46092
|
return true;
|
|
46072
|
-
if ((
|
|
46093
|
+
if (firstByte === 254 && (secondByte & 192) === 128)
|
|
46094
|
+
return true;
|
|
46095
|
+
if ((firstByte & 254) === 252)
|
|
46073
46096
|
return true;
|
|
46074
46097
|
if (v6[0] === 255)
|
|
46075
46098
|
return true;
|
|
@@ -46098,6 +46121,8 @@ function extractTlsSni(buf) {
|
|
|
46098
46121
|
if (offset >= buf.length)
|
|
46099
46122
|
return null;
|
|
46100
46123
|
const sidLen = buf[offset];
|
|
46124
|
+
if (sidLen === void 0)
|
|
46125
|
+
return null;
|
|
46101
46126
|
offset += 1 + sidLen;
|
|
46102
46127
|
if (offset + 2 > buf.length)
|
|
46103
46128
|
return null;
|
|
@@ -46106,6 +46131,8 @@ function extractTlsSni(buf) {
|
|
|
46106
46131
|
if (offset + 1 > buf.length)
|
|
46107
46132
|
return null;
|
|
46108
46133
|
const cmLen = buf[offset];
|
|
46134
|
+
if (cmLen === void 0)
|
|
46135
|
+
return null;
|
|
46109
46136
|
offset += 1 + cmLen;
|
|
46110
46137
|
if (offset + 2 > buf.length)
|
|
46111
46138
|
return null;
|
|
@@ -46124,6 +46151,8 @@ function extractTlsSni(buf) {
|
|
|
46124
46151
|
const sniEnd = Math.min(extensionsEnd, sniOffset + sniListLen);
|
|
46125
46152
|
while (sniOffset + 3 <= sniEnd) {
|
|
46126
46153
|
const nameType = buf[sniOffset];
|
|
46154
|
+
if (nameType === void 0)
|
|
46155
|
+
return null;
|
|
46127
46156
|
const nameLen = buf.readUInt16BE(sniOffset + 1);
|
|
46128
46157
|
sniOffset += 3;
|
|
46129
46158
|
if (nameType === 0) {
|
|
@@ -46225,7 +46254,13 @@ async function startProviderProxy(allowedHosts, options) {
|
|
|
46225
46254
|
return;
|
|
46226
46255
|
}
|
|
46227
46256
|
}
|
|
46228
|
-
const
|
|
46257
|
+
const firstAddress = addresses[0];
|
|
46258
|
+
if (!firstAddress) {
|
|
46259
|
+
res.writeHead(502, { "content-type": "text/plain" });
|
|
46260
|
+
res.end(`BAD_GATEWAY: DNS lookup failed for provider host "${effectiveHost}"`);
|
|
46261
|
+
return;
|
|
46262
|
+
}
|
|
46263
|
+
const validatedIp = options?.allowPrivateUpstream ? "127.0.0.1" : firstAddress.address;
|
|
46229
46264
|
const requestFn = isHttps ? import_node_https.default.request : import_node_http.default.request;
|
|
46230
46265
|
const transportOpts = {
|
|
46231
46266
|
host: validatedIp,
|
|
@@ -46304,7 +46339,12 @@ async function startProviderProxy(allowedHosts, options) {
|
|
|
46304
46339
|
return;
|
|
46305
46340
|
}
|
|
46306
46341
|
}
|
|
46307
|
-
const
|
|
46342
|
+
const firstAddress = addresses[0];
|
|
46343
|
+
if (!firstAddress) {
|
|
46344
|
+
clientSocket.end("HTTP/1.1 502 Bad Gateway\\r\\n\\r\\n");
|
|
46345
|
+
return;
|
|
46346
|
+
}
|
|
46347
|
+
const validatedIp = options?.allowPrivateUpstream ? "127.0.0.1" : firstAddress.address;
|
|
46308
46348
|
const serverSocket = import_node_net.default.connect({ host: validatedIp, port: targetPort }, () => {
|
|
46309
46349
|
clientSocket.write("HTTP/1.1 200 Connection Established\r\n\r\n");
|
|
46310
46350
|
let validatedAuthority = false;
|
|
@@ -46383,19 +46423,20 @@ async function startProviderProxy(allowedHosts, options) {
|
|
|
46383
46423
|
await new Promise((resolve2, reject) => {
|
|
46384
46424
|
server.on("error", reject);
|
|
46385
46425
|
if (options?.socketPath) {
|
|
46426
|
+
const socketPath = options.socketPath;
|
|
46386
46427
|
try {
|
|
46387
|
-
if (import_node_fs2.default.existsSync(
|
|
46388
|
-
import_node_fs2.default.unlinkSync(
|
|
46428
|
+
if (import_node_fs2.default.existsSync(socketPath)) {
|
|
46429
|
+
import_node_fs2.default.unlinkSync(socketPath);
|
|
46389
46430
|
}
|
|
46390
46431
|
} catch {
|
|
46391
46432
|
}
|
|
46392
|
-
server.listen(
|
|
46433
|
+
server.listen(socketPath, () => {
|
|
46393
46434
|
try {
|
|
46394
|
-
import_node_fs2.default.chmodSync(
|
|
46435
|
+
import_node_fs2.default.chmodSync(socketPath, 384);
|
|
46395
46436
|
} catch {
|
|
46396
46437
|
}
|
|
46397
46438
|
server.unref();
|
|
46398
|
-
assignedSocketPath =
|
|
46439
|
+
assignedSocketPath = socketPath;
|
|
46399
46440
|
resolve2();
|
|
46400
46441
|
});
|
|
46401
46442
|
} else {
|
|
@@ -46597,7 +46638,6 @@ async function createVerificationNetworkSandbox(config2) {
|
|
|
46597
46638
|
}
|
|
46598
46639
|
};
|
|
46599
46640
|
}
|
|
46600
|
-
const allPinnedIps = Array.from(new Set(Object.values(resolvedIpsMap).flat()));
|
|
46601
46641
|
const hostsLines = [
|
|
46602
46642
|
"127.0.0.1 localhost",
|
|
46603
46643
|
"::1 localhost",
|
|
@@ -47137,8 +47177,7 @@ exit $EXIT_CODE`,
|
|
|
47137
47177
|
dispose: () => {
|
|
47138
47178
|
try {
|
|
47139
47179
|
if (providerProxy) {
|
|
47140
|
-
providerProxy.close().catch(() =>
|
|
47141
|
-
});
|
|
47180
|
+
providerProxy.close().catch(() => void 0);
|
|
47142
47181
|
}
|
|
47143
47182
|
} catch {
|
|
47144
47183
|
}
|
|
@@ -50451,8 +50490,8 @@ var Protocol = class {
|
|
|
50451
50490
|
if (queuedMessage.type === "response") {
|
|
50452
50491
|
resolver(message);
|
|
50453
50492
|
} else {
|
|
50454
|
-
const
|
|
50455
|
-
const error51 = new McpError(
|
|
50493
|
+
const errorMessage2 = message;
|
|
50494
|
+
const error51 = new McpError(errorMessage2.error.code, errorMessage2.error.message, errorMessage2.error.data);
|
|
50456
50495
|
resolver(error51);
|
|
50457
50496
|
}
|
|
50458
50497
|
} else {
|
|
@@ -51758,8 +51797,8 @@ var Client = class extends Protocol {
|
|
|
51758
51797
|
const wrappedHandler = async (request, extra) => {
|
|
51759
51798
|
const validatedRequest = safeParse3(ElicitRequestSchema, request);
|
|
51760
51799
|
if (!validatedRequest.success) {
|
|
51761
|
-
const
|
|
51762
|
-
throw new McpError(ErrorCode.InvalidParams, `Invalid elicitation request: ${
|
|
51800
|
+
const errorMessage2 = validatedRequest.error instanceof Error ? validatedRequest.error.message : String(validatedRequest.error);
|
|
51801
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid elicitation request: ${errorMessage2}`);
|
|
51763
51802
|
}
|
|
51764
51803
|
const { params } = validatedRequest.data;
|
|
51765
51804
|
params.mode = params.mode ?? "form";
|
|
@@ -51774,15 +51813,15 @@ var Client = class extends Protocol {
|
|
|
51774
51813
|
if (params.task) {
|
|
51775
51814
|
const taskValidationResult = safeParse3(CreateTaskResultSchema, result);
|
|
51776
51815
|
if (!taskValidationResult.success) {
|
|
51777
|
-
const
|
|
51778
|
-
throw new McpError(ErrorCode.InvalidParams, `Invalid task creation result: ${
|
|
51816
|
+
const errorMessage2 = taskValidationResult.error instanceof Error ? taskValidationResult.error.message : String(taskValidationResult.error);
|
|
51817
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid task creation result: ${errorMessage2}`);
|
|
51779
51818
|
}
|
|
51780
51819
|
return taskValidationResult.data;
|
|
51781
51820
|
}
|
|
51782
51821
|
const validationResult = safeParse3(ElicitResultSchema, result);
|
|
51783
51822
|
if (!validationResult.success) {
|
|
51784
|
-
const
|
|
51785
|
-
throw new McpError(ErrorCode.InvalidParams, `Invalid elicitation result: ${
|
|
51823
|
+
const errorMessage2 = validationResult.error instanceof Error ? validationResult.error.message : String(validationResult.error);
|
|
51824
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid elicitation result: ${errorMessage2}`);
|
|
51786
51825
|
}
|
|
51787
51826
|
const validatedResult = validationResult.data;
|
|
51788
51827
|
const requestedSchema = params.mode === "form" ? params.requestedSchema : void 0;
|
|
@@ -51802,16 +51841,16 @@ var Client = class extends Protocol {
|
|
|
51802
51841
|
const wrappedHandler = async (request, extra) => {
|
|
51803
51842
|
const validatedRequest = safeParse3(CreateMessageRequestSchema, request);
|
|
51804
51843
|
if (!validatedRequest.success) {
|
|
51805
|
-
const
|
|
51806
|
-
throw new McpError(ErrorCode.InvalidParams, `Invalid sampling request: ${
|
|
51844
|
+
const errorMessage2 = validatedRequest.error instanceof Error ? validatedRequest.error.message : String(validatedRequest.error);
|
|
51845
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid sampling request: ${errorMessage2}`);
|
|
51807
51846
|
}
|
|
51808
51847
|
const { params } = validatedRequest.data;
|
|
51809
51848
|
const result = await Promise.resolve(handler(request, extra));
|
|
51810
51849
|
if (params.task) {
|
|
51811
51850
|
const taskValidationResult = safeParse3(CreateTaskResultSchema, result);
|
|
51812
51851
|
if (!taskValidationResult.success) {
|
|
51813
|
-
const
|
|
51814
|
-
throw new McpError(ErrorCode.InvalidParams, `Invalid task creation result: ${
|
|
51852
|
+
const errorMessage2 = taskValidationResult.error instanceof Error ? taskValidationResult.error.message : String(taskValidationResult.error);
|
|
51853
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid task creation result: ${errorMessage2}`);
|
|
51815
51854
|
}
|
|
51816
51855
|
return taskValidationResult.data;
|
|
51817
51856
|
}
|
|
@@ -51819,8 +51858,8 @@ var Client = class extends Protocol {
|
|
|
51819
51858
|
const resultSchema = hasTools ? CreateMessageResultWithToolsSchema : CreateMessageResultSchema;
|
|
51820
51859
|
const validationResult = safeParse3(resultSchema, result);
|
|
51821
51860
|
if (!validationResult.success) {
|
|
51822
|
-
const
|
|
51823
|
-
throw new McpError(ErrorCode.InvalidParams, `Invalid sampling result: ${
|
|
51861
|
+
const errorMessage2 = validationResult.error instanceof Error ? validationResult.error.message : String(validationResult.error);
|
|
51862
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid sampling result: ${errorMessage2}`);
|
|
51824
51863
|
}
|
|
51825
51864
|
return validationResult.data;
|
|
51826
51865
|
};
|
|
@@ -52048,18 +52087,18 @@ var Client = class extends Protocol {
|
|
|
52048
52087
|
}
|
|
52049
52088
|
return result;
|
|
52050
52089
|
}
|
|
52051
|
-
isToolTask(
|
|
52090
|
+
isToolTask(toolName2) {
|
|
52052
52091
|
if (!this._serverCapabilities?.tasks?.requests?.tools?.call) {
|
|
52053
52092
|
return false;
|
|
52054
52093
|
}
|
|
52055
|
-
return this._cachedKnownTaskTools.has(
|
|
52094
|
+
return this._cachedKnownTaskTools.has(toolName2);
|
|
52056
52095
|
}
|
|
52057
52096
|
/**
|
|
52058
52097
|
* Check if a tool requires task-based execution.
|
|
52059
52098
|
* Unlike isToolTask which includes 'optional' tools, this only checks for 'required'.
|
|
52060
52099
|
*/
|
|
52061
|
-
isToolTaskRequired(
|
|
52062
|
-
return this._cachedRequiredTaskTools.has(
|
|
52100
|
+
isToolTaskRequired(toolName2) {
|
|
52101
|
+
return this._cachedRequiredTaskTools.has(toolName2);
|
|
52063
52102
|
}
|
|
52064
52103
|
/**
|
|
52065
52104
|
* Cache validators for tool output schemas.
|
|
@@ -52086,8 +52125,8 @@ var Client = class extends Protocol {
|
|
|
52086
52125
|
/**
|
|
52087
52126
|
* Get cached validator for a tool
|
|
52088
52127
|
*/
|
|
52089
|
-
getToolOutputValidator(
|
|
52090
|
-
return this._cachedToolOutputValidators.get(
|
|
52128
|
+
getToolOutputValidator(toolName2) {
|
|
52129
|
+
return this._cachedToolOutputValidators.get(toolName2);
|
|
52091
52130
|
}
|
|
52092
52131
|
async listTools(params, options) {
|
|
52093
52132
|
const result = await this.request({ method: "tools/list", params }, ListToolsResultSchema, options);
|
|
@@ -52630,8 +52669,8 @@ async function parseErrorResponse(input) {
|
|
|
52630
52669
|
return new errorClass(error_description || "", error_uri);
|
|
52631
52670
|
} catch (error51) {
|
|
52632
52671
|
const redirect = input instanceof Response ? unfollowedRedirect(input, input.url) : void 0;
|
|
52633
|
-
const
|
|
52634
|
-
return new ServerError(
|
|
52672
|
+
const errorMessage2 = `${statusCode ? `HTTP ${statusCode}: ` : ""}${redirect ?? `Invalid OAuth error response: ${error51}. Raw body: ${body}`}`;
|
|
52673
|
+
return new ServerError(errorMessage2);
|
|
52635
52674
|
}
|
|
52636
52675
|
}
|
|
52637
52676
|
function issuersMatch(a, b) {
|
|
@@ -53974,7 +54013,7 @@ var StdioClientTransport = class {
|
|
|
53974
54013
|
};
|
|
53975
54014
|
|
|
53976
54015
|
// src/delivery/invoke.ts
|
|
53977
|
-
async function invokeCapability(server,
|
|
54016
|
+
async function invokeCapability(server, toolName2, payload) {
|
|
53978
54017
|
const client = new Client({ name: "mrrlin-delivery-invoker", version: "1.0.0" });
|
|
53979
54018
|
try {
|
|
53980
54019
|
let result;
|
|
@@ -54020,14 +54059,14 @@ async function invokeCapability(server, toolName, payload) {
|
|
|
54020
54059
|
await client.connect(transport);
|
|
54021
54060
|
}
|
|
54022
54061
|
result = await client.callTool({
|
|
54023
|
-
name:
|
|
54062
|
+
name: toolName2,
|
|
54024
54063
|
arguments: isRecord(payload) ? payload : void 0
|
|
54025
54064
|
});
|
|
54026
54065
|
} catch (error51) {
|
|
54027
|
-
throw classifyInvokeError(error51, target,
|
|
54066
|
+
throw classifyInvokeError(error51, target, toolName2);
|
|
54028
54067
|
}
|
|
54029
54068
|
if (result.isError) {
|
|
54030
|
-
throw new InvokeToolExecutionError(
|
|
54069
|
+
throw new InvokeToolExecutionError(toolName2, extractFirstText(result.content));
|
|
54031
54070
|
}
|
|
54032
54071
|
return { content: result.content, url: extractFirstUrl(result.content) };
|
|
54033
54072
|
} finally {
|
|
@@ -54036,14 +54075,14 @@ async function invokeCapability(server, toolName, payload) {
|
|
|
54036
54075
|
}
|
|
54037
54076
|
}
|
|
54038
54077
|
var InvokeToolNotFoundError = class extends Error {
|
|
54039
|
-
constructor(
|
|
54040
|
-
super(`invokeCapability: tool "${
|
|
54078
|
+
constructor(toolName2, cause) {
|
|
54079
|
+
super(`invokeCapability: tool "${toolName2}" not found on the granted server`, { cause });
|
|
54041
54080
|
this.name = "InvokeToolNotFoundError";
|
|
54042
54081
|
}
|
|
54043
54082
|
};
|
|
54044
54083
|
var InvokeToolExecutionError = class extends Error {
|
|
54045
|
-
constructor(
|
|
54046
|
-
super(`invokeCapability: tool "${
|
|
54084
|
+
constructor(toolName2, detail, cause) {
|
|
54085
|
+
super(`invokeCapability: tool "${toolName2}" reported isError -- ${detail}`, { cause });
|
|
54047
54086
|
this.name = "InvokeToolExecutionError";
|
|
54048
54087
|
}
|
|
54049
54088
|
};
|
|
@@ -54071,7 +54110,7 @@ var InvokeUnexpandedHeaderError = class extends Error {
|
|
|
54071
54110
|
this.name = "InvokeUnexpandedHeaderError";
|
|
54072
54111
|
}
|
|
54073
54112
|
};
|
|
54074
|
-
function classifyInvokeError(error51, url2,
|
|
54113
|
+
function classifyInvokeError(error51, url2, toolName2) {
|
|
54075
54114
|
if (error51 instanceof InvokeUnexpandedHeaderError) {
|
|
54076
54115
|
return error51;
|
|
54077
54116
|
}
|
|
@@ -54081,10 +54120,10 @@ function classifyInvokeError(error51, url2, toolName) {
|
|
|
54081
54120
|
}
|
|
54082
54121
|
if (error51 instanceof McpError) {
|
|
54083
54122
|
if (error51.code === ErrorCode.MethodNotFound) {
|
|
54084
|
-
return new InvokeToolNotFoundError(
|
|
54123
|
+
return new InvokeToolNotFoundError(toolName2, error51);
|
|
54085
54124
|
}
|
|
54086
54125
|
if (error51.code === ErrorCode.InvalidParams) {
|
|
54087
|
-
return new InvokeMalformedResultError(`invalid parameters for tool "${
|
|
54126
|
+
return new InvokeMalformedResultError(`invalid parameters for tool "${toolName2}": ${error51.message}`, error51);
|
|
54088
54127
|
}
|
|
54089
54128
|
return new InvokeMalformedResultError(error51.message, error51);
|
|
54090
54129
|
}
|
|
@@ -54160,12 +54199,12 @@ function parsePullRequestUrl(url2) {
|
|
|
54160
54199
|
}
|
|
54161
54200
|
return {};
|
|
54162
54201
|
}
|
|
54163
|
-
async function deliverToGit(server,
|
|
54202
|
+
async function deliverToGit(server, toolName2, payload) {
|
|
54164
54203
|
const defaultRoute = server.id ? getDefaultCapabilityRouteForServer(server.id) : null;
|
|
54165
54204
|
const isDefaultGitHubRoute = defaultRoute?.capability === "repo_host";
|
|
54166
54205
|
if (payload.operation === "pull_request") {
|
|
54167
54206
|
const { operation: _operation, ...args } = payload;
|
|
54168
|
-
if (isDefaultGitHubRoute &&
|
|
54207
|
+
if (isDefaultGitHubRoute && toolName2 === defaultRoute.operations.pull_request) {
|
|
54169
54208
|
let owner = args.owner;
|
|
54170
54209
|
let repo = args.repo;
|
|
54171
54210
|
const repository = args.repository;
|
|
@@ -54189,11 +54228,11 @@ async function deliverToGit(server, toolName, payload) {
|
|
|
54189
54228
|
if (typeof payload.draft === "boolean") {
|
|
54190
54229
|
adaptedArgs.draft = payload.draft;
|
|
54191
54230
|
}
|
|
54192
|
-
return invokeCapability(server,
|
|
54231
|
+
return invokeCapability(server, toolName2, adaptedArgs);
|
|
54193
54232
|
}
|
|
54194
|
-
return invokeCapability(server,
|
|
54233
|
+
return invokeCapability(server, toolName2, args);
|
|
54195
54234
|
}
|
|
54196
|
-
if (isDefaultGitHubRoute && (
|
|
54235
|
+
if (isDefaultGitHubRoute && (toolName2 === defaultRoute.operations.pull_request_state || toolName2 === "pull_request_read")) {
|
|
54197
54236
|
const { operation: _operation, ...args } = payload;
|
|
54198
54237
|
const urlParts = parsePullRequestUrl(payload.pullRequestUrl);
|
|
54199
54238
|
let owner = args.owner ?? urlParts.owner;
|
|
@@ -54209,16 +54248,16 @@ async function deliverToGit(server, toolName, payload) {
|
|
|
54209
54248
|
if (owner) adaptedArgs.owner = owner;
|
|
54210
54249
|
if (repo) adaptedArgs.repo = repo;
|
|
54211
54250
|
if (pullNumber !== void 0) {
|
|
54212
|
-
if (
|
|
54251
|
+
if (toolName2 === "pull_request_read") {
|
|
54213
54252
|
adaptedArgs.method = "get";
|
|
54214
54253
|
adaptedArgs.pullNumber = pullNumber;
|
|
54215
54254
|
} else {
|
|
54216
54255
|
adaptedArgs.pull_number = pullNumber;
|
|
54217
54256
|
}
|
|
54218
54257
|
}
|
|
54219
|
-
return invokeCapability(server,
|
|
54258
|
+
return invokeCapability(server, toolName2, adaptedArgs);
|
|
54220
54259
|
}
|
|
54221
|
-
return invokeCapability(server,
|
|
54260
|
+
return invokeCapability(server, toolName2, { pullRequestUrl: payload.pullRequestUrl });
|
|
54222
54261
|
}
|
|
54223
54262
|
|
|
54224
54263
|
// src/mcp-tool-error.ts
|
|
@@ -54297,11 +54336,11 @@ async function deliverToArtifacts(client, projectSlug, payload, bareFetch) {
|
|
|
54297
54336
|
}
|
|
54298
54337
|
|
|
54299
54338
|
// src/delivery/send.ts
|
|
54300
|
-
async function deliverToSend(server,
|
|
54339
|
+
async function deliverToSend(server, toolName2, payload) {
|
|
54301
54340
|
const { operation: _operation, ...args } = payload;
|
|
54302
54341
|
const defaultRoute = server.id ? getDefaultCapabilityRouteForServer(server.id) : null;
|
|
54303
54342
|
const isDefaultSlackRoute = defaultRoute?.capability === "send";
|
|
54304
|
-
if (payload.operation === "dispatch" && isDefaultSlackRoute &&
|
|
54343
|
+
if (payload.operation === "dispatch" && isDefaultSlackRoute && toolName2 === defaultRoute.operations.dispatch) {
|
|
54305
54344
|
const rawChannel = args.channel_id ?? args.destination ?? args.channel ?? args.to;
|
|
54306
54345
|
const channelId = typeof rawChannel === "string" ? rawChannel.trim() : rawChannel !== void 0 ? String(rawChannel) : void 0;
|
|
54307
54346
|
const rawText = args.text ?? args.body ?? args.message ?? args.content;
|
|
@@ -54309,15 +54348,15 @@ async function deliverToSend(server, toolName, payload) {
|
|
|
54309
54348
|
const adaptedArgs = {};
|
|
54310
54349
|
if (channelId !== void 0) adaptedArgs.channel_id = channelId;
|
|
54311
54350
|
if (text !== void 0) adaptedArgs.text = text;
|
|
54312
|
-
return invokeCapability(server,
|
|
54351
|
+
return invokeCapability(server, toolName2, adaptedArgs);
|
|
54313
54352
|
}
|
|
54314
|
-
return invokeCapability(server,
|
|
54353
|
+
return invokeCapability(server, toolName2, args);
|
|
54315
54354
|
}
|
|
54316
54355
|
|
|
54317
54356
|
// src/delivery/publish.ts
|
|
54318
|
-
async function deliverToPublish(server,
|
|
54357
|
+
async function deliverToPublish(server, toolName2, payload) {
|
|
54319
54358
|
const { operation: _operation, ...args } = payload;
|
|
54320
|
-
return invokeCapability(server,
|
|
54359
|
+
return invokeCapability(server, toolName2, args);
|
|
54321
54360
|
}
|
|
54322
54361
|
function parsePublishObserveResult(content) {
|
|
54323
54362
|
const raw = parseStructuredContent(content);
|
|
@@ -54472,7 +54511,7 @@ async function proceedToDestination(client, route, resolvedToolName, input) {
|
|
|
54472
54511
|
serverId: route.serverId,
|
|
54473
54512
|
capability: route.capability,
|
|
54474
54513
|
toolName: resolvedToolName,
|
|
54475
|
-
operationClass: route
|
|
54514
|
+
operationClass: resolveOperationClass(route, "reversible"),
|
|
54476
54515
|
payloadDigest
|
|
54477
54516
|
});
|
|
54478
54517
|
const idempotencyKey = `deliver:${input.taskProjectSlug}:${permit.id}`;
|
|
@@ -54492,7 +54531,7 @@ async function proceedToDestination(client, route, resolvedToolName, input) {
|
|
|
54492
54531
|
return {
|
|
54493
54532
|
ok: false,
|
|
54494
54533
|
reason: "invocation_failed",
|
|
54495
|
-
message:
|
|
54534
|
+
message: errorMessage(redemption.error) ?? "Capability invocation previously failed"
|
|
54496
54535
|
};
|
|
54497
54536
|
}
|
|
54498
54537
|
await recordUse(client, route, resolvedToolName, input, "refused");
|
|
@@ -54504,7 +54543,7 @@ async function proceedToDestination(client, route, resolvedToolName, input) {
|
|
|
54504
54543
|
}
|
|
54505
54544
|
} catch (permitError) {
|
|
54506
54545
|
await recordUse(client, route, resolvedToolName, input, "refused");
|
|
54507
|
-
const msg = permitError
|
|
54546
|
+
const msg = errorMessage(permitError) ?? String(permitError);
|
|
54508
54547
|
const isNoGrant = msg.includes("GRANT_REQUIRED") || msg.includes("no active grant");
|
|
54509
54548
|
return {
|
|
54510
54549
|
ok: false,
|
|
@@ -54799,7 +54838,7 @@ async function readPublishState(client, projectSlug, taskProjectSlug, payload, m
|
|
|
54799
54838
|
return redemption.result;
|
|
54800
54839
|
}
|
|
54801
54840
|
if (redemption.status === "failed") {
|
|
54802
|
-
const errMsg =
|
|
54841
|
+
const errMsg = errorMessage(redemption.error) ?? "Capability invocation previously failed";
|
|
54803
54842
|
throw new Error(`CAPABILITY_REPLAY_FAILED: ${errMsg}`);
|
|
54804
54843
|
}
|
|
54805
54844
|
throw new Error(`OPERATIONAL_INCIDENT: capability invocation ${redemption.id} is in status "${redemption.status}" and cannot be replayed as success`);
|
|
@@ -54866,7 +54905,7 @@ async function dispatchPublishOperation(client, projectSlug, taskProjectSlug, ta
|
|
|
54866
54905
|
serverId: route.serverId,
|
|
54867
54906
|
capability: route.capability,
|
|
54868
54907
|
toolName: resolvedToolName,
|
|
54869
|
-
operationClass: route
|
|
54908
|
+
operationClass: resolveOperationClass(route, payload.operation === "preview" ? "reversible" : "irreversible"),
|
|
54870
54909
|
payloadDigest
|
|
54871
54910
|
});
|
|
54872
54911
|
const idempotencyKey = `publish:${taskProjectSlug}:${permit.id}`;
|
|
@@ -54879,11 +54918,14 @@ async function dispatchPublishOperation(client, projectSlug, taskProjectSlug, ta
|
|
|
54879
54918
|
if (redemption.replayed) {
|
|
54880
54919
|
if (redemption.status === "completed") {
|
|
54881
54920
|
const use2 = await recordUse(client, route, resolvedToolName, input, "ok");
|
|
54882
|
-
|
|
54921
|
+
if (!isRecord3(redemption.result) || !("content" in redemption.result) || !("url" in redemption.result)) {
|
|
54922
|
+
throw new Error("CAPABILITY_REPLAY_INVALID_RESULT: completed publish invocation has no object result");
|
|
54923
|
+
}
|
|
54924
|
+
return { content: redemption.result.content, url: typeof redemption.result.url === "string" ? redemption.result.url : null, use: use2 };
|
|
54883
54925
|
}
|
|
54884
54926
|
if (redemption.status === "failed") {
|
|
54885
54927
|
const use2 = await recordUse(client, route, resolvedToolName, input, "error");
|
|
54886
|
-
const errMsg =
|
|
54928
|
+
const errMsg = errorMessage(redemption.error) ?? "Capability invocation previously failed";
|
|
54887
54929
|
throw Object.assign(new Error(`CAPABILITY_REPLAY_FAILED: ${errMsg}`), { use: use2 });
|
|
54888
54930
|
}
|
|
54889
54931
|
const use = await recordUse(client, route, resolvedToolName, input, "refused");
|
|
@@ -54928,8 +54970,8 @@ async function readPullRequestState(client, projectSlug, taskProjectSlug, pullRe
|
|
|
54928
54970
|
throw new RepoHostRouteUnavailableError(`repo_host capability route unavailable: ${resolution.reason}`);
|
|
54929
54971
|
}
|
|
54930
54972
|
const { route } = resolution;
|
|
54931
|
-
const
|
|
54932
|
-
if (typeof
|
|
54973
|
+
const toolName2 = route.operations.pull_request_state;
|
|
54974
|
+
if (typeof toolName2 !== "string") {
|
|
54933
54975
|
throw new RepoHostRouteUnavailableError('operation "pull_request_state" is not configured for repo_host capability');
|
|
54934
54976
|
}
|
|
54935
54977
|
const server = readMcpServerById(mcpConfigPath ?? defaultMcpConfigPath(), route.serverId);
|
|
@@ -54950,7 +54992,7 @@ async function readPullRequestState(client, projectSlug, taskProjectSlug, pullRe
|
|
|
54950
54992
|
taskId,
|
|
54951
54993
|
serverId: route.serverId,
|
|
54952
54994
|
capability: route.capability,
|
|
54953
|
-
toolName,
|
|
54995
|
+
toolName: toolName2,
|
|
54954
54996
|
operationClass: "read",
|
|
54955
54997
|
payloadDigest
|
|
54956
54998
|
});
|
|
@@ -54961,18 +55003,18 @@ async function readPullRequestState(client, projectSlug, taskProjectSlug, pullRe
|
|
|
54961
55003
|
payloadDigest
|
|
54962
55004
|
});
|
|
54963
55005
|
if (redemption.replayed) {
|
|
54964
|
-
if (redemption.status === "completed" && redemption.result && typeof redemption.result.merged === "boolean") {
|
|
55006
|
+
if (redemption.status === "completed" && isRecord3(redemption.result) && typeof redemption.result.merged === "boolean") {
|
|
54965
55007
|
return { merged: redemption.result.merged };
|
|
54966
55008
|
}
|
|
54967
55009
|
if (redemption.status === "failed") {
|
|
54968
|
-
const errMsg =
|
|
55010
|
+
const errMsg = errorMessage(redemption.error) ?? "Capability invocation previously failed";
|
|
54969
55011
|
throw new Error(`CAPABILITY_REPLAY_FAILED: ${errMsg}`);
|
|
54970
55012
|
}
|
|
54971
55013
|
throw new Error(`OPERATIONAL_INCIDENT: capability invocation ${redemption.id} is in status "${redemption.status}" and cannot be replayed as success`);
|
|
54972
55014
|
}
|
|
54973
55015
|
const invocationId = redemption.id;
|
|
54974
55016
|
try {
|
|
54975
|
-
const result = await deliverToGit(server,
|
|
55017
|
+
const result = await deliverToGit(server, toolName2, payload);
|
|
54976
55018
|
const raw = parseStructuredContent(result.content);
|
|
54977
55019
|
const parsed = gitPullRequestStateResponseSchema.safeParse(raw);
|
|
54978
55020
|
if (!parsed.success) {
|
|
@@ -55003,6 +55045,17 @@ async function readPullRequestState(client, projectSlug, taskProjectSlug, pullRe
|
|
|
55003
55045
|
function isRecord3(value) {
|
|
55004
55046
|
return typeof value === "object" && value !== null;
|
|
55005
55047
|
}
|
|
55048
|
+
function errorMessage(value) {
|
|
55049
|
+
if (typeof value === "string") return value;
|
|
55050
|
+
if (value instanceof Error) return value.message;
|
|
55051
|
+
if (isRecord3(value) && typeof value.message === "string") return value.message;
|
|
55052
|
+
return void 0;
|
|
55053
|
+
}
|
|
55054
|
+
function resolveOperationClass(route, fallback) {
|
|
55055
|
+
if (!isRecord3(route)) return fallback;
|
|
55056
|
+
const operationClass = route.operationClass;
|
|
55057
|
+
return operationClass === "read" || operationClass === "reversible" || operationClass === "irreversible" ? operationClass : fallback;
|
|
55058
|
+
}
|
|
55006
55059
|
|
|
55007
55060
|
// src/decision-consensus.ts
|
|
55008
55061
|
var ANCHOR_TIMEOUT_MS = Number(process.env["MRRLIN_DECISION_TIMEOUT_MS"] ?? 9e4);
|
|
@@ -55149,8 +55202,8 @@ var registry2 = /* @__PURE__ */ new Map();
|
|
|
55149
55202
|
function registerAsyncTool(descriptor2) {
|
|
55150
55203
|
registry2.set(descriptor2.toolName, descriptor2);
|
|
55151
55204
|
}
|
|
55152
|
-
function getAsyncToolDescriptor(
|
|
55153
|
-
return registry2.get(
|
|
55205
|
+
function getAsyncToolDescriptor(toolName2) {
|
|
55206
|
+
return registry2.get(toolName2);
|
|
55154
55207
|
}
|
|
55155
55208
|
|
|
55156
55209
|
// src/async-tools/consensus.ts
|
|
@@ -56793,12 +56846,12 @@ function buildProjection(payload, type, ms, telemetry) {
|
|
|
56793
56846
|
const tool = rawEvent.tool;
|
|
56794
56847
|
if (!isRecord4(tool)) return null;
|
|
56795
56848
|
const toolId = tool.id;
|
|
56796
|
-
const
|
|
56797
|
-
if (typeof toolId !== "string" || typeof
|
|
56849
|
+
const toolName2 = tool.name;
|
|
56850
|
+
if (typeof toolId !== "string" || typeof toolName2 !== "string") return null;
|
|
56798
56851
|
const input = tool.input;
|
|
56799
56852
|
const argKeys = isRecord4(input) ? Object.keys(input) : [];
|
|
56800
56853
|
const projectSlug = isRecord4(input) && typeof input.projectSlug === "string" ? input.projectSlug : void 0;
|
|
56801
|
-
const proj = { kind: "tool_use", toolId, toolName, argKeys, seq: maybeSeq ?? 0 };
|
|
56854
|
+
const proj = { kind: "tool_use", toolId, toolName: toolName2, argKeys, seq: maybeSeq ?? 0 };
|
|
56802
56855
|
if (maybeTurnId !== void 0) proj.turnId = maybeTurnId;
|
|
56803
56856
|
if (ms !== void 0) proj.ms = ms;
|
|
56804
56857
|
if (projectSlug !== void 0) proj.projectSlug = projectSlug;
|
|
@@ -56974,14 +57027,14 @@ var READ_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
|
56974
57027
|
// call), making every turn that stops a run permanently, unfixably "unresolved".
|
|
56975
57028
|
"stop_execution_run"
|
|
56976
57029
|
]);
|
|
56977
|
-
function normalizeToolName(
|
|
56978
|
-
return
|
|
57030
|
+
function normalizeToolName(toolName2) {
|
|
57031
|
+
return toolName2.replace(/^mcp__.+?__/, "");
|
|
56979
57032
|
}
|
|
56980
57033
|
var MRRLIN_MCP_NAMESPACE_PREFIXES = ["mcp__mrrlin__", "mcp__mrrlin-browser__"];
|
|
56981
57034
|
function classifyToolEffect(rawToolName) {
|
|
56982
|
-
const
|
|
56983
|
-
if (READ_TOOL_NAMES.has(
|
|
56984
|
-
if (OUTWARD_TOOL_NAMES.has(
|
|
57035
|
+
const toolName2 = normalizeToolName(rawToolName);
|
|
57036
|
+
if (READ_TOOL_NAMES.has(toolName2)) return "read";
|
|
57037
|
+
if (OUTWARD_TOOL_NAMES.has(toolName2)) return "outward";
|
|
56985
57038
|
if (MRRLIN_MCP_NAMESPACE_PREFIXES.some((prefix) => rawToolName.startsWith(prefix))) return "outward";
|
|
56986
57039
|
return "read";
|
|
56987
57040
|
}
|
|
@@ -56994,10 +57047,10 @@ var BROWSER_OUTWARD_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
|
56994
57047
|
"browser_select_option"
|
|
56995
57048
|
]);
|
|
56996
57049
|
var IN_PRODUCT_WRITE_TOOL_NAMES = /* @__PURE__ */ new Set(["create_task", "update_task", "create_wiki_page", "update_wiki_page", "create_inbox_item"]);
|
|
56997
|
-
function buildBrowserAttemptReceipt(
|
|
57050
|
+
function buildBrowserAttemptReceipt(toolName2) {
|
|
56998
57051
|
return {
|
|
56999
57052
|
kind: "attempt",
|
|
57000
|
-
evidence: { type: "human_tap", value:
|
|
57053
|
+
evidence: { type: "human_tap", value: toolName2 },
|
|
57001
57054
|
observedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
57002
57055
|
requiresCovered: []
|
|
57003
57056
|
};
|
|
@@ -57127,20 +57180,20 @@ function createBridgeLogger(stateDir, env = process.env) {
|
|
|
57127
57180
|
if (isNewTurn) state.pending = [];
|
|
57128
57181
|
}
|
|
57129
57182
|
if (projection?.kind === "tool_use" && typeof projection.toolName === "string" && typeof projection.toolId === "string") {
|
|
57130
|
-
const
|
|
57183
|
+
const toolName2 = normalizeToolName(projection.toolName);
|
|
57131
57184
|
if (classifyToolEffect(projection.toolName) === "outward") {
|
|
57132
|
-
if (BROWSER_OUTWARD_TOOL_NAMES.has(
|
|
57133
|
-
syntheticReceipt = buildBrowserAttemptReceipt(
|
|
57185
|
+
if (BROWSER_OUTWARD_TOOL_NAMES.has(toolName2)) {
|
|
57186
|
+
syntheticReceipt = buildBrowserAttemptReceipt(toolName2);
|
|
57134
57187
|
} else {
|
|
57135
57188
|
state.pending.push({
|
|
57136
57189
|
turnSpanId: projection.turnId,
|
|
57137
|
-
toolName,
|
|
57190
|
+
toolName: toolName2,
|
|
57138
57191
|
toolId: projection.toolId,
|
|
57139
57192
|
seq: projection.seq,
|
|
57140
57193
|
armedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
57141
57194
|
});
|
|
57142
57195
|
}
|
|
57143
|
-
} else if (IN_PRODUCT_WRITE_TOOL_NAMES.has(
|
|
57196
|
+
} else if (IN_PRODUCT_WRITE_TOOL_NAMES.has(toolName2) && state.pending.length > 0) {
|
|
57144
57197
|
if (state.pending.length > 1) {
|
|
57145
57198
|
recordingObligationMultiResolve = {
|
|
57146
57199
|
resolvedCount: state.pending.length,
|
|
@@ -57348,10 +57401,10 @@ async function assembleEvidence(stateDir, sessionId, reportId, gateCtx) {
|
|
|
57348
57401
|
if (line.projection?.kind !== "tool_use") continue;
|
|
57349
57402
|
const rawToolId = line.payload?.event?.tool?.id;
|
|
57350
57403
|
const paired = typeof rawToolId === "string" ? resultByToolId.get(rawToolId) : void 0;
|
|
57351
|
-
const
|
|
57404
|
+
const toolName2 = line.projection.toolName ?? line.payload?.event?.tool?.name ?? "";
|
|
57352
57405
|
const ms = line.projection.ms ?? 0;
|
|
57353
57406
|
const outcome = paired?.projection?.kind === "tool_result" ? paired.projection.outcome ?? "unknown" : "unknown";
|
|
57354
|
-
const step = { toolName, ms, outcome };
|
|
57407
|
+
const step = { toolName: toolName2, ms, outcome };
|
|
57355
57408
|
if (paired?.projection?.kind === "tool_result" && paired.projection.exitCode !== void 0) {
|
|
57356
57409
|
step.exitCode = paired.projection.exitCode;
|
|
57357
57410
|
}
|
|
@@ -61611,7 +61664,7 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
|
|
|
61611
61664
|
}
|
|
61612
61665
|
|
|
61613
61666
|
// src/_generated/version.ts
|
|
61614
|
-
var PKG_VERSION = "0.4.
|
|
61667
|
+
var PKG_VERSION = "0.4.108";
|
|
61615
61668
|
|
|
61616
61669
|
// src/receipt-signing.ts
|
|
61617
61670
|
var import_node_crypto13 = __toESM(require("node:crypto"), 1);
|
|
@@ -61838,26 +61891,26 @@ function turnReferences(events) {
|
|
|
61838
61891
|
if (event.type === "tool_use") {
|
|
61839
61892
|
hasToolEvents = true;
|
|
61840
61893
|
const rawName = event.tool?.name ?? event.name ?? "";
|
|
61841
|
-
const
|
|
61842
|
-
const isMutation = MUTATION_TOOLS.has(
|
|
61894
|
+
const toolName2 = rawName.replace(/^.*__/, "");
|
|
61895
|
+
const isMutation = MUTATION_TOOLS.has(toolName2);
|
|
61843
61896
|
const inputObj = event.tool?.input && typeof event.tool.input === "object" ? event.tool.input : event.input && typeof event.input === "object" ? event.input : {};
|
|
61844
61897
|
const rawTargetId = typeof inputObj.taskId === "string" ? inputObj.taskId : typeof inputObj.pageId === "string" ? inputObj.pageId : typeof inputObj.id === "string" ? inputObj.id : null;
|
|
61845
61898
|
let targetId = null;
|
|
61846
61899
|
if (rawTargetId) {
|
|
61847
|
-
if ((
|
|
61900
|
+
if ((toolName2 === "create_task" || toolName2 === "update_task") && /^GT-\d+$/.test(rawTargetId)) {
|
|
61848
61901
|
targetId = rawTargetId;
|
|
61849
|
-
} else if ((
|
|
61902
|
+
} else if ((toolName2 === "create_wiki_page" || toolName2 === "update_wiki_page") && /^WK-\d+$/.test(rawTargetId)) {
|
|
61850
61903
|
targetId = rawTargetId;
|
|
61851
61904
|
}
|
|
61852
61905
|
}
|
|
61853
61906
|
const callId = event.tool?.id ?? event.tool_use_id ?? event.id;
|
|
61854
61907
|
if (callId && typeof callId === "string") {
|
|
61855
61908
|
if (isMutation) {
|
|
61856
|
-
keyedPending.set(callId, { toolName, targetId });
|
|
61909
|
+
keyedPending.set(callId, { toolName: toolName2, targetId });
|
|
61857
61910
|
}
|
|
61858
61911
|
} else {
|
|
61859
61912
|
if (isMutation) {
|
|
61860
|
-
unkeyedCalls.push({ isMutation: true, toolName, targetId });
|
|
61913
|
+
unkeyedCalls.push({ isMutation: true, toolName: toolName2, targetId });
|
|
61861
61914
|
} else {
|
|
61862
61915
|
unkeyedCalls.push({ isMutation: false });
|
|
61863
61916
|
}
|
|
@@ -67818,13 +67871,13 @@ async function driveAsyncJob(deps, projectSlug, jobId) {
|
|
|
67818
67871
|
}
|
|
67819
67872
|
if (descriptor2.wakeDirector) deps.wake(projectSlug, claimed.directorSessionId, delivery.body, delivery.kind);
|
|
67820
67873
|
}
|
|
67821
|
-
async function deriveRequestedHash(client,
|
|
67874
|
+
async function deriveRequestedHash(client, toolName2, input) {
|
|
67822
67875
|
if (input.requestedHash) return input.requestedHash;
|
|
67823
|
-
if (
|
|
67876
|
+
if (toolName2 === "run_spec_consensus" && input.pageId) {
|
|
67824
67877
|
const page = await client.getWikiPage(input.projectSlug, input.pageId);
|
|
67825
67878
|
return page.contentHash ?? import_node_crypto18.default.createHash("sha256").update(page.markdownBody).digest("hex");
|
|
67826
67879
|
}
|
|
67827
|
-
if (
|
|
67880
|
+
if (toolName2 === "draft_task_spec" && input.taskId) {
|
|
67828
67881
|
const task = await client.getTask(input.projectSlug, input.taskId);
|
|
67829
67882
|
return task.updatedAt ?? import_node_crypto18.default.createHash("sha256").update(JSON.stringify(task)).digest("hex");
|
|
67830
67883
|
}
|
|
@@ -72168,18 +72221,19 @@ async function startExecutorServer(opts) {
|
|
|
72168
72221
|
const childEnv = withDisabledGitHooksEnv(baseEnv, opts.disabledGitHooksDir);
|
|
72169
72222
|
const baseSpawn = opts.spawn ?? import_node_child_process22.spawn;
|
|
72170
72223
|
const hasExtraFd = opts.brokerSocket != null || opts.brokerSocketFd != null;
|
|
72171
|
-
const spawnFn = (cmd, args, spawnOpts) => {
|
|
72172
|
-
const argList =
|
|
72173
|
-
const optsObj = args && !Array.isArray(args) ? args : spawnOpts ?? {};
|
|
72224
|
+
const spawnFn = (cmd, args = [], spawnOpts = {}) => {
|
|
72225
|
+
const argList = [...args];
|
|
72174
72226
|
const fullCmd = [cmd, ...argList];
|
|
72175
72227
|
const wrapped = opts.wrapCommand ? opts.wrapCommand(fullCmd) : fullCmd;
|
|
72176
|
-
const finalSpawnOpts = { ...
|
|
72228
|
+
const finalSpawnOpts = { ...spawnOpts };
|
|
72177
72229
|
if (hasExtraFd) {
|
|
72178
|
-
const stdio = Array.isArray(finalSpawnOpts
|
|
72230
|
+
const stdio = Array.isArray(finalSpawnOpts.stdio) ? [...finalSpawnOpts.stdio] : ["pipe", "pipe", "pipe"];
|
|
72179
72231
|
stdio[3] = opts.brokerSocket ?? opts.brokerSocketFd;
|
|
72180
72232
|
finalSpawnOpts.stdio = stdio;
|
|
72181
72233
|
}
|
|
72182
|
-
|
|
72234
|
+
const executable = wrapped[0];
|
|
72235
|
+
if (!executable) throw new Error("command wrapper returned an empty command");
|
|
72236
|
+
return baseSpawn(executable, wrapped.slice(1), finalSpawnOpts);
|
|
72183
72237
|
};
|
|
72184
72238
|
if (opts.provider === "codex") {
|
|
72185
72239
|
const manager = new CodexServerManager();
|
|
@@ -72429,19 +72483,21 @@ function parseIpv4Numeric(ipStr) {
|
|
|
72429
72483
|
parsedParts.push(n);
|
|
72430
72484
|
}
|
|
72431
72485
|
if (parsedParts.length === 4) {
|
|
72432
|
-
for (const
|
|
72433
|
-
if (
|
|
72486
|
+
for (const b2 of parsedParts) {
|
|
72487
|
+
if (b2 > 255) return null;
|
|
72434
72488
|
}
|
|
72435
|
-
|
|
72489
|
+
const [a, b, c, d] = parsedParts;
|
|
72490
|
+
if (a === void 0 || b === void 0 || c === void 0 || d === void 0) return null;
|
|
72491
|
+
return [a, b, c, d];
|
|
72436
72492
|
}
|
|
72437
72493
|
if (parsedParts.length === 3) {
|
|
72438
72494
|
const [a, b, c] = parsedParts;
|
|
72439
|
-
if (a > 255 || b > 255 || c > 65535) return null;
|
|
72495
|
+
if (a === void 0 || b === void 0 || c === void 0 || a > 255 || b > 255 || c > 65535) return null;
|
|
72440
72496
|
return [a, b, c >>> 8 & 255, c & 255];
|
|
72441
72497
|
}
|
|
72442
72498
|
if (parsedParts.length === 2) {
|
|
72443
72499
|
const [a, b] = parsedParts;
|
|
72444
|
-
if (a > 255 || b > 16777215) return null;
|
|
72500
|
+
if (a === void 0 || b === void 0 || a > 255 || b > 16777215) return null;
|
|
72445
72501
|
return [a, b >>> 16 & 255, b >>> 8 & 255, b & 255];
|
|
72446
72502
|
}
|
|
72447
72503
|
return null;
|
|
@@ -72475,14 +72531,14 @@ function isGlobalIpv6(ipStr) {
|
|
|
72475
72531
|
}
|
|
72476
72532
|
const mappedMatch = /^::ffff:(?:0:)?(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/i.exec(clean);
|
|
72477
72533
|
if (mappedMatch) {
|
|
72478
|
-
const ipv43 = parseIpv4Numeric(mappedMatch[1]);
|
|
72534
|
+
const ipv43 = parseIpv4Numeric(mappedMatch[1] ?? "");
|
|
72479
72535
|
if (!ipv43) return false;
|
|
72480
72536
|
return isGlobalIpv4(ipv43);
|
|
72481
72537
|
}
|
|
72482
72538
|
const hexMappedMatch = /^::ffff:(?:0:)?([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i.exec(clean);
|
|
72483
72539
|
if (hexMappedMatch) {
|
|
72484
|
-
const high = Number.parseInt(hexMappedMatch[1], 16);
|
|
72485
|
-
const low = Number.parseInt(hexMappedMatch[2], 16);
|
|
72540
|
+
const high = Number.parseInt(hexMappedMatch[1] ?? "", 16);
|
|
72541
|
+
const low = Number.parseInt(hexMappedMatch[2] ?? "", 16);
|
|
72486
72542
|
const b0 = high >>> 8 & 255;
|
|
72487
72543
|
const b1 = high & 255;
|
|
72488
72544
|
const b2 = low >>> 8 & 255;
|
|
@@ -72492,13 +72548,13 @@ function isGlobalIpv6(ipStr) {
|
|
|
72492
72548
|
if (clean.startsWith("::ffff:")) return false;
|
|
72493
72549
|
const compatMatch = /^::(?:0:)?(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/i.exec(clean);
|
|
72494
72550
|
if (compatMatch) {
|
|
72495
|
-
const ipv43 = parseIpv4Numeric(compatMatch[1]);
|
|
72551
|
+
const ipv43 = parseIpv4Numeric(compatMatch[1] ?? "");
|
|
72496
72552
|
if (!ipv43) return false;
|
|
72497
72553
|
return isGlobalIpv4(ipv43);
|
|
72498
72554
|
}
|
|
72499
72555
|
const nat64Match = /^64:ff9b::(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/i.exec(clean);
|
|
72500
72556
|
if (nat64Match) {
|
|
72501
|
-
const ipv43 = parseIpv4Numeric(nat64Match[1]);
|
|
72557
|
+
const ipv43 = parseIpv4Numeric(nat64Match[1] ?? "");
|
|
72502
72558
|
if (!ipv43) return false;
|
|
72503
72559
|
return isGlobalIpv4(ipv43);
|
|
72504
72560
|
}
|
|
@@ -72618,7 +72674,9 @@ async function resolveAndPinAddress(hostname3, customResolver) {
|
|
|
72618
72674
|
}
|
|
72619
72675
|
return {
|
|
72620
72676
|
hostname: cleanHost,
|
|
72621
|
-
pinnedIp: allIps[0]
|
|
72677
|
+
pinnedIp: allIps[0] ?? (() => {
|
|
72678
|
+
throw new Error("DNS_RESOLUTION_FAILED: empty address set");
|
|
72679
|
+
})(),
|
|
72622
72680
|
allIps
|
|
72623
72681
|
};
|
|
72624
72682
|
}
|
|
@@ -72748,11 +72806,11 @@ async function createVerificationBrokerSession(options) {
|
|
|
72748
72806
|
clearTimeout(timer);
|
|
72749
72807
|
try {
|
|
72750
72808
|
res.destroy();
|
|
72751
|
-
} catch {
|
|
72809
|
+
} catch (error51) {
|
|
72752
72810
|
}
|
|
72753
72811
|
try {
|
|
72754
72812
|
req.destroy();
|
|
72755
|
-
} catch {
|
|
72813
|
+
} catch (error51) {
|
|
72756
72814
|
}
|
|
72757
72815
|
reject(err);
|
|
72758
72816
|
};
|
|
@@ -72783,7 +72841,7 @@ async function createVerificationBrokerSession(options) {
|
|
|
72783
72841
|
if (decompressedBytes > maxDecompBytes) {
|
|
72784
72842
|
try {
|
|
72785
72843
|
decompressor.destroy();
|
|
72786
|
-
} catch {
|
|
72844
|
+
} catch (error51) {
|
|
72787
72845
|
}
|
|
72788
72846
|
fail(new Error(`DECOMPRESSION_LIMIT_EXCEEDED: decompressed body exceeded ${maxDecompBytes} bytes`));
|
|
72789
72847
|
}
|
|
@@ -72948,12 +73006,12 @@ async function createVerificationBrokerSession(options) {
|
|
|
72948
73006
|
server.close();
|
|
72949
73007
|
try {
|
|
72950
73008
|
if (import_node_fs22.default.existsSync(socketPath)) import_node_fs22.default.unlinkSync(socketPath);
|
|
72951
|
-
} catch {
|
|
73009
|
+
} catch (error51) {
|
|
72952
73010
|
}
|
|
72953
73011
|
if (createdDir) {
|
|
72954
73012
|
try {
|
|
72955
73013
|
import_node_fs22.default.rmSync(createdDir, { recursive: true, force: true });
|
|
72956
|
-
} catch {
|
|
73014
|
+
} catch (error51) {
|
|
72957
73015
|
}
|
|
72958
73016
|
}
|
|
72959
73017
|
throw new Error(`BROKER_SOCKET_ERROR: failed to establish inherited client socket connection: ${String(err)}`);
|
|
@@ -72973,7 +73031,7 @@ async function createVerificationBrokerSession(options) {
|
|
|
72973
73031
|
if (clientSocket) {
|
|
72974
73032
|
try {
|
|
72975
73033
|
clientSocket.destroy();
|
|
72976
|
-
} catch {
|
|
73034
|
+
} catch (error51) {
|
|
72977
73035
|
}
|
|
72978
73036
|
}
|
|
72979
73037
|
await new Promise((resolve2) => {
|
|
@@ -72997,6 +73055,31 @@ async function createVerificationBrokerSession(options) {
|
|
|
72997
73055
|
}
|
|
72998
73056
|
|
|
72999
73057
|
// src/verification-turn.ts
|
|
73058
|
+
function runtimeHandle(handle) {
|
|
73059
|
+
return handle;
|
|
73060
|
+
}
|
|
73061
|
+
function toolName(tool) {
|
|
73062
|
+
if (typeof tool === "string") return tool;
|
|
73063
|
+
if (tool !== null && typeof tool === "object") {
|
|
73064
|
+
const descriptor2 = tool;
|
|
73065
|
+
if (typeof descriptor2.name === "string") return descriptor2.name;
|
|
73066
|
+
if (typeof descriptor2.function?.name === "string") return descriptor2.function.name;
|
|
73067
|
+
}
|
|
73068
|
+
return "";
|
|
73069
|
+
}
|
|
73070
|
+
function disabledToolFromEvent(event, disabledTools) {
|
|
73071
|
+
if (event === null || typeof event !== "object") return null;
|
|
73072
|
+
const record2 = event;
|
|
73073
|
+
if (record2.type !== "tool_use") return null;
|
|
73074
|
+
const name = typeof record2.tool?.name === "string" ? record2.tool.name : null;
|
|
73075
|
+
if (name === null) return null;
|
|
73076
|
+
return disabledTools.some((tool) => tool.toLowerCase() === name.toLowerCase()) ? name : null;
|
|
73077
|
+
}
|
|
73078
|
+
function isDnsNoData(error51) {
|
|
73079
|
+
if (error51 === null || typeof error51 !== "object") return false;
|
|
73080
|
+
const code = error51.code;
|
|
73081
|
+
return code === "ENODATA" || code === "ENOTFOUND";
|
|
73082
|
+
}
|
|
73000
73083
|
var DISABLED_NATIVE_VERIFICATION_TOOLS = [
|
|
73001
73084
|
"WebFetch",
|
|
73002
73085
|
"WebSearch",
|
|
@@ -73007,42 +73090,40 @@ var DISABLED_NATIVE_VERIFICATION_TOOLS = [
|
|
|
73007
73090
|
"curl"
|
|
73008
73091
|
];
|
|
73009
73092
|
var DisabledToolInvocationError = class extends Error {
|
|
73010
|
-
constructor(
|
|
73011
|
-
super(`TOOL_INVOCATION_FORBIDDEN: native network tool "${
|
|
73093
|
+
constructor(toolName2) {
|
|
73094
|
+
super(`TOOL_INVOCATION_FORBIDDEN: native network tool "${toolName2}" is disabled in verification isolation mode`);
|
|
73012
73095
|
this.name = "DisabledToolInvocationError";
|
|
73013
73096
|
}
|
|
73014
73097
|
};
|
|
73015
|
-
function assertNativeToolsDisabled(
|
|
73098
|
+
function assertNativeToolsDisabled(toolName2, disabledTools = DISABLED_NATIVE_VERIFICATION_TOOLS) {
|
|
73016
73099
|
const disabledSet = new Set(disabledTools.map((t) => t.toLowerCase()));
|
|
73017
|
-
if (disabledSet.has(
|
|
73018
|
-
throw new DisabledToolInvocationError(
|
|
73100
|
+
if (disabledSet.has(toolName2.toLowerCase())) {
|
|
73101
|
+
throw new DisabledToolInvocationError(toolName2);
|
|
73019
73102
|
}
|
|
73020
73103
|
}
|
|
73021
73104
|
function enforceNativeToolsDisabled(handle, disabledTools = DISABLED_NATIVE_VERIFICATION_TOOLS) {
|
|
73022
73105
|
const disabledSet = new Set(disabledTools.map((t) => t.toLowerCase()));
|
|
73106
|
+
const extendedHandle = runtimeHandle(handle);
|
|
73023
73107
|
for (const prop of ["tools", "availableTools", "registeredTools"]) {
|
|
73024
|
-
const val =
|
|
73108
|
+
const val = extendedHandle[prop];
|
|
73025
73109
|
if (Array.isArray(val)) {
|
|
73026
|
-
|
|
73027
|
-
const name = typeof t === "string" ? t : t?.name ?? t?.function?.name ?? "";
|
|
73028
|
-
return !disabledSet.has(String(name).toLowerCase());
|
|
73029
|
-
});
|
|
73110
|
+
extendedHandle[prop] = val.filter((tool) => !disabledSet.has(toolName(tool).toLowerCase()));
|
|
73030
73111
|
}
|
|
73031
73112
|
}
|
|
73032
|
-
const toolsConfig =
|
|
73113
|
+
const toolsConfig = extendedHandle.toolsConfig;
|
|
73033
73114
|
if (toolsConfig && typeof toolsConfig === "object") {
|
|
73034
73115
|
for (const tool of disabledTools) {
|
|
73035
73116
|
toolsConfig[tool] = false;
|
|
73036
73117
|
toolsConfig[tool.toLowerCase()] = false;
|
|
73037
73118
|
}
|
|
73038
73119
|
}
|
|
73039
|
-
if (typeof
|
|
73120
|
+
if (typeof extendedHandle.disableNativeTools === "function") {
|
|
73040
73121
|
try {
|
|
73041
|
-
|
|
73042
|
-
} catch {
|
|
73122
|
+
extendedHandle.disableNativeTools(disabledTools);
|
|
73123
|
+
} catch (error51) {
|
|
73043
73124
|
}
|
|
73044
73125
|
}
|
|
73045
|
-
|
|
73126
|
+
extendedHandle.disabledTools = disabledTools;
|
|
73046
73127
|
return handle;
|
|
73047
73128
|
}
|
|
73048
73129
|
function createVerificationTurnRunner(baseRunTurn, disabledTools = DISABLED_NATIVE_VERIFICATION_TOOLS) {
|
|
@@ -73051,11 +73132,12 @@ function createVerificationTurnRunner(baseRunTurn, disabledTools = DISABLED_NATI
|
|
|
73051
73132
|
throw new Error("INVALID_AGENT_HANDLE: handle is required for verification turn runner");
|
|
73052
73133
|
}
|
|
73053
73134
|
enforceNativeToolsDisabled(handle, disabledTools);
|
|
73054
|
-
|
|
73135
|
+
const extendedHandle = runtimeHandle(handle);
|
|
73136
|
+
let origExecute;
|
|
73055
73137
|
let didPatchExecute = false;
|
|
73056
|
-
let origStartThread
|
|
73057
|
-
let origResumeThread
|
|
73058
|
-
let origStartTurn
|
|
73138
|
+
let origStartThread;
|
|
73139
|
+
let origResumeThread;
|
|
73140
|
+
let origStartTurn;
|
|
73059
73141
|
const unsubscribes = [];
|
|
73060
73142
|
const subscribedThreads = /* @__PURE__ */ new Set();
|
|
73061
73143
|
let toolViolationError = null;
|
|
@@ -73065,32 +73147,26 @@ function createVerificationTurnRunner(baseRunTurn, disabledTools = DISABLED_NATI
|
|
|
73065
73147
|
if (typeof handle.onEvent === "function") {
|
|
73066
73148
|
try {
|
|
73067
73149
|
const unsub = handle.onEvent(threadId, (event) => {
|
|
73068
|
-
|
|
73069
|
-
|
|
73070
|
-
|
|
73071
|
-
|
|
73072
|
-
|
|
73073
|
-
|
|
73074
|
-
|
|
73075
|
-
handle.interruptTurn(threadId).catch(() => {
|
|
73076
|
-
});
|
|
73077
|
-
} catch {
|
|
73078
|
-
}
|
|
73079
|
-
}
|
|
73080
|
-
break;
|
|
73081
|
-
}
|
|
73150
|
+
const disabledTool = disabledToolFromEvent(event, disabledTools);
|
|
73151
|
+
if (disabledTool !== null) {
|
|
73152
|
+
toolViolationError = new DisabledToolInvocationError(disabledTool);
|
|
73153
|
+
try {
|
|
73154
|
+
void handle.interruptTurn(threadId).catch((error51) => {
|
|
73155
|
+
});
|
|
73156
|
+
} catch (error51) {
|
|
73082
73157
|
}
|
|
73083
73158
|
}
|
|
73084
73159
|
});
|
|
73085
73160
|
unsubscribes.push(unsub);
|
|
73086
|
-
} catch {
|
|
73161
|
+
} catch (error51) {
|
|
73087
73162
|
}
|
|
73088
73163
|
}
|
|
73089
73164
|
};
|
|
73090
73165
|
if (typeof handle.startThread === "function") {
|
|
73091
|
-
|
|
73166
|
+
const startThread = handle.startThread;
|
|
73167
|
+
origStartThread = startThread;
|
|
73092
73168
|
handle.startThread = async (params) => {
|
|
73093
|
-
const res = await
|
|
73169
|
+
const res = await startThread.call(handle, params);
|
|
73094
73170
|
if (res?.threadId) {
|
|
73095
73171
|
subscribeThread(res.threadId);
|
|
73096
73172
|
}
|
|
@@ -73098,9 +73174,10 @@ function createVerificationTurnRunner(baseRunTurn, disabledTools = DISABLED_NATI
|
|
|
73098
73174
|
};
|
|
73099
73175
|
}
|
|
73100
73176
|
if (typeof handle.resumeThread === "function") {
|
|
73101
|
-
|
|
73177
|
+
const resumeThread = handle.resumeThread;
|
|
73178
|
+
origResumeThread = resumeThread;
|
|
73102
73179
|
handle.resumeThread = async (threadId, params) => {
|
|
73103
|
-
const res = await
|
|
73180
|
+
const res = await resumeThread.call(handle, threadId, params);
|
|
73104
73181
|
if (res?.threadId) {
|
|
73105
73182
|
subscribeThread(res.threadId);
|
|
73106
73183
|
}
|
|
@@ -73108,44 +73185,39 @@ function createVerificationTurnRunner(baseRunTurn, disabledTools = DISABLED_NATI
|
|
|
73108
73185
|
};
|
|
73109
73186
|
}
|
|
73110
73187
|
if (typeof handle.startTurn === "function") {
|
|
73111
|
-
|
|
73188
|
+
const startTurn = handle.startTurn;
|
|
73189
|
+
origStartTurn = startTurn;
|
|
73112
73190
|
handle.startTurn = async (threadId, input, effort) => {
|
|
73113
73191
|
if (threadId) {
|
|
73114
73192
|
subscribeThread(threadId);
|
|
73115
73193
|
}
|
|
73116
|
-
return
|
|
73194
|
+
return startTurn.call(handle, threadId, input, effort);
|
|
73117
73195
|
};
|
|
73118
73196
|
}
|
|
73119
73197
|
if (typeof handle.onEvent === "function" && typeof handle.startThread !== "function") {
|
|
73120
73198
|
try {
|
|
73121
73199
|
const unsub = handle.onEvent("*", (event) => {
|
|
73122
|
-
|
|
73123
|
-
|
|
73124
|
-
|
|
73125
|
-
|
|
73126
|
-
|
|
73127
|
-
|
|
73128
|
-
|
|
73129
|
-
handle.interruptTurn("*").catch(() => {
|
|
73130
|
-
});
|
|
73131
|
-
} catch {
|
|
73132
|
-
}
|
|
73133
|
-
}
|
|
73134
|
-
break;
|
|
73135
|
-
}
|
|
73200
|
+
const disabledTool = disabledToolFromEvent(event, disabledTools);
|
|
73201
|
+
if (disabledTool !== null) {
|
|
73202
|
+
toolViolationError = new DisabledToolInvocationError(disabledTool);
|
|
73203
|
+
try {
|
|
73204
|
+
void handle.interruptTurn("*").catch((error51) => {
|
|
73205
|
+
});
|
|
73206
|
+
} catch (error51) {
|
|
73136
73207
|
}
|
|
73137
73208
|
}
|
|
73138
73209
|
});
|
|
73139
73210
|
unsubscribes.push(unsub);
|
|
73140
|
-
} catch {
|
|
73211
|
+
} catch (error51) {
|
|
73141
73212
|
}
|
|
73142
73213
|
}
|
|
73143
|
-
if (typeof
|
|
73144
|
-
|
|
73214
|
+
if (typeof extendedHandle.executeTool === "function") {
|
|
73215
|
+
const executeTool = extendedHandle.executeTool;
|
|
73216
|
+
origExecute = executeTool;
|
|
73145
73217
|
didPatchExecute = true;
|
|
73146
|
-
|
|
73218
|
+
extendedHandle.executeTool = async (name, args) => {
|
|
73147
73219
|
assertNativeToolsDisabled(name, disabledTools);
|
|
73148
|
-
return
|
|
73220
|
+
return executeTool.call(handle, name, args);
|
|
73149
73221
|
};
|
|
73150
73222
|
}
|
|
73151
73223
|
try {
|
|
@@ -73158,14 +73230,14 @@ function createVerificationTurnRunner(baseRunTurn, disabledTools = DISABLED_NATI
|
|
|
73158
73230
|
for (const unsub of unsubscribes) {
|
|
73159
73231
|
try {
|
|
73160
73232
|
unsub();
|
|
73161
|
-
} catch {
|
|
73233
|
+
} catch (error51) {
|
|
73162
73234
|
}
|
|
73163
73235
|
}
|
|
73164
73236
|
if (origStartThread) handle.startThread = origStartThread;
|
|
73165
73237
|
if (origResumeThread) handle.resumeThread = origResumeThread;
|
|
73166
73238
|
if (origStartTurn) handle.startTurn = origStartTurn;
|
|
73167
73239
|
if (didPatchExecute && origExecute) {
|
|
73168
|
-
|
|
73240
|
+
extendedHandle.executeTool = origExecute;
|
|
73169
73241
|
}
|
|
73170
73242
|
}
|
|
73171
73243
|
};
|
|
@@ -73245,7 +73317,7 @@ function createRunVerificationTurn(deps) {
|
|
|
73245
73317
|
let v6 = [];
|
|
73246
73318
|
try {
|
|
73247
73319
|
v4 = await import_node_dns2.default.promises.resolve4(normalizedUrl.hostname).catch((err) => {
|
|
73248
|
-
if (err
|
|
73320
|
+
if (isDnsNoData(err)) return [];
|
|
73249
73321
|
throw err;
|
|
73250
73322
|
});
|
|
73251
73323
|
} catch (err) {
|
|
@@ -73257,7 +73329,7 @@ function createRunVerificationTurn(deps) {
|
|
|
73257
73329
|
}
|
|
73258
73330
|
try {
|
|
73259
73331
|
v6 = await import_node_dns2.default.promises.resolve6(normalizedUrl.hostname).catch((err) => {
|
|
73260
|
-
if (err
|
|
73332
|
+
if (isDnsNoData(err)) return [];
|
|
73261
73333
|
throw err;
|
|
73262
73334
|
});
|
|
73263
73335
|
} catch (err) {
|
|
@@ -73302,7 +73374,7 @@ function createRunVerificationTurn(deps) {
|
|
|
73302
73374
|
if (!brokerSession.clientSocket) {
|
|
73303
73375
|
try {
|
|
73304
73376
|
await brokerSession.close();
|
|
73305
|
-
} catch {
|
|
73377
|
+
} catch (error51) {
|
|
73306
73378
|
}
|
|
73307
73379
|
return {
|
|
73308
73380
|
verdict: "fail",
|
|
@@ -73323,7 +73395,7 @@ function createRunVerificationTurn(deps) {
|
|
|
73323
73395
|
if (brokerSession) {
|
|
73324
73396
|
try {
|
|
73325
73397
|
await brokerSession.close();
|
|
73326
|
-
} catch {
|
|
73398
|
+
} catch (error51) {
|
|
73327
73399
|
}
|
|
73328
73400
|
}
|
|
73329
73401
|
return { verdict: "fail", summary: `network sandbox initialization failed: ${String(err)}`, turnRef: null };
|
|
@@ -73338,13 +73410,13 @@ function createRunVerificationTurn(deps) {
|
|
|
73338
73410
|
if (sandboxHandle) {
|
|
73339
73411
|
try {
|
|
73340
73412
|
sandboxHandle.dispose();
|
|
73341
|
-
} catch {
|
|
73413
|
+
} catch (error51) {
|
|
73342
73414
|
}
|
|
73343
73415
|
}
|
|
73344
73416
|
if (brokerSession) {
|
|
73345
73417
|
try {
|
|
73346
73418
|
await brokerSession.close();
|
|
73347
|
-
} catch {
|
|
73419
|
+
} catch (error51) {
|
|
73348
73420
|
}
|
|
73349
73421
|
}
|
|
73350
73422
|
return {
|
|
@@ -73370,13 +73442,13 @@ function createRunVerificationTurn(deps) {
|
|
|
73370
73442
|
if (sandboxHandle) {
|
|
73371
73443
|
try {
|
|
73372
73444
|
sandboxHandle.dispose();
|
|
73373
|
-
} catch {
|
|
73445
|
+
} catch (error51) {
|
|
73374
73446
|
}
|
|
73375
73447
|
}
|
|
73376
73448
|
if (brokerSession) {
|
|
73377
73449
|
try {
|
|
73378
73450
|
await brokerSession.close();
|
|
73379
|
-
} catch {
|
|
73451
|
+
} catch (error51) {
|
|
73380
73452
|
}
|
|
73381
73453
|
}
|
|
73382
73454
|
return { verdict: "fail", summary: `agent sandbox startup failed: ${String(err)}`, turnRef: null };
|
|
@@ -73385,19 +73457,19 @@ function createRunVerificationTurn(deps) {
|
|
|
73385
73457
|
if (agentSandbox) {
|
|
73386
73458
|
try {
|
|
73387
73459
|
agentSandbox.dispose();
|
|
73388
|
-
} catch {
|
|
73460
|
+
} catch (error51) {
|
|
73389
73461
|
}
|
|
73390
73462
|
}
|
|
73391
73463
|
if (sandboxHandle) {
|
|
73392
73464
|
try {
|
|
73393
73465
|
sandboxHandle.dispose();
|
|
73394
|
-
} catch {
|
|
73466
|
+
} catch (error51) {
|
|
73395
73467
|
}
|
|
73396
73468
|
}
|
|
73397
73469
|
if (brokerSession) {
|
|
73398
73470
|
try {
|
|
73399
73471
|
await brokerSession.close();
|
|
73400
|
-
} catch {
|
|
73472
|
+
} catch (error51) {
|
|
73401
73473
|
}
|
|
73402
73474
|
}
|
|
73403
73475
|
return {
|
|
@@ -73422,19 +73494,19 @@ function createRunVerificationTurn(deps) {
|
|
|
73422
73494
|
if (agentSandbox) {
|
|
73423
73495
|
try {
|
|
73424
73496
|
agentSandbox.dispose();
|
|
73425
|
-
} catch {
|
|
73497
|
+
} catch (error51) {
|
|
73426
73498
|
}
|
|
73427
73499
|
}
|
|
73428
73500
|
if (sandboxHandle) {
|
|
73429
73501
|
try {
|
|
73430
73502
|
sandboxHandle.dispose();
|
|
73431
|
-
} catch {
|
|
73503
|
+
} catch (error51) {
|
|
73432
73504
|
}
|
|
73433
73505
|
}
|
|
73434
73506
|
if (brokerSession) {
|
|
73435
73507
|
try {
|
|
73436
73508
|
await brokerSession.close();
|
|
73437
|
-
} catch {
|
|
73509
|
+
} catch (error51) {
|
|
73438
73510
|
}
|
|
73439
73511
|
}
|
|
73440
73512
|
}
|
|
@@ -75990,7 +76062,15 @@ function createBridgeMessageHandler(deps) {
|
|
|
75990
76062
|
project: projectContext,
|
|
75991
76063
|
answeredQuestions,
|
|
75992
76064
|
openQuestions: presentedLedger.shown.length ? presentedLedger.shown : void 0,
|
|
75993
|
-
clarifications: msg.context?.clarifications ?? (presentedLedger.shown.some((i) => i.id) ? presentedLedger.shown
|
|
76065
|
+
clarifications: msg.context?.clarifications ?? (presentedLedger.shown.some((i) => i.id) ? presentedLedger.shown.map(({ id, round, ordinal, question, status, answer, actor }) => ({
|
|
76066
|
+
id,
|
|
76067
|
+
round,
|
|
76068
|
+
ordinal,
|
|
76069
|
+
question,
|
|
76070
|
+
status,
|
|
76071
|
+
answer,
|
|
76072
|
+
actor
|
|
76073
|
+
})) : void 0),
|
|
75994
76074
|
directorSessionId
|
|
75995
76075
|
});
|
|
75996
76076
|
const sendInTurn = (msg2) => {
|
|
@@ -77935,23 +78015,23 @@ var Server = class extends Protocol {
|
|
|
77935
78015
|
const wrappedHandler = async (request, extra) => {
|
|
77936
78016
|
const validatedRequest = safeParse3(CallToolRequestSchema, request);
|
|
77937
78017
|
if (!validatedRequest.success) {
|
|
77938
|
-
const
|
|
77939
|
-
throw new McpError(ErrorCode.InvalidParams, `Invalid tools/call request: ${
|
|
78018
|
+
const errorMessage2 = validatedRequest.error instanceof Error ? validatedRequest.error.message : String(validatedRequest.error);
|
|
78019
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid tools/call request: ${errorMessage2}`);
|
|
77940
78020
|
}
|
|
77941
78021
|
const { params } = validatedRequest.data;
|
|
77942
78022
|
const result = await Promise.resolve(handler(request, extra));
|
|
77943
78023
|
if (params.task) {
|
|
77944
78024
|
const taskValidationResult = safeParse3(CreateTaskResultSchema, result);
|
|
77945
78025
|
if (!taskValidationResult.success) {
|
|
77946
|
-
const
|
|
77947
|
-
throw new McpError(ErrorCode.InvalidParams, `Invalid task creation result: ${
|
|
78026
|
+
const errorMessage2 = taskValidationResult.error instanceof Error ? taskValidationResult.error.message : String(taskValidationResult.error);
|
|
78027
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid task creation result: ${errorMessage2}`);
|
|
77948
78028
|
}
|
|
77949
78029
|
return taskValidationResult.data;
|
|
77950
78030
|
}
|
|
77951
78031
|
const validationResult = safeParse3(CallToolResultSchema, result);
|
|
77952
78032
|
if (!validationResult.success) {
|
|
77953
|
-
const
|
|
77954
|
-
throw new McpError(ErrorCode.InvalidParams, `Invalid tools/call result: ${
|
|
78033
|
+
const errorMessage2 = validationResult.error instanceof Error ? validationResult.error.message : String(validationResult.error);
|
|
78034
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid tools/call result: ${errorMessage2}`);
|
|
77955
78035
|
}
|
|
77956
78036
|
return validationResult.data;
|
|
77957
78037
|
};
|