@opengeni/runtime 4.6.1 → 4.6.2-canary.39854174564001
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/assets/codemode-client.json +1 -1
- package/dist/{chunk-L6CVIN52.js → chunk-LOWZTPW3.js} +452 -117
- package/dist/chunk-LOWZTPW3.js.map +1 -0
- package/dist/{chunk-YXNCKAJS.js → chunk-TVZD7HHB.js} +9 -4
- package/dist/{chunk-YXNCKAJS.js.map → chunk-TVZD7HHB.js.map} +1 -1
- package/dist/drive-mcp.d.ts +110 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +6 -2
- package/dist/model-call.js +1 -1
- package/dist/workspace-tool-gateway.js +2 -2
- package/package.json +15 -15
- package/src/codex-tool-search.ts +16 -3
- package/src/computer-model-text.ts +6 -2
- package/src/drive-mcp.ts +408 -0
- package/src/index.ts +34 -24
- package/src/interaction-tools.ts +2 -2
- package/src/model-context-inspector.ts +29 -26
- package/dist/chunk-L6CVIN52.js.map +0 -1
|
@@ -105,7 +105,7 @@ import {
|
|
|
105
105
|
withModelRequestCapture,
|
|
106
106
|
withModelTransportStartedObserver,
|
|
107
107
|
withPreparedCompactionRequest
|
|
108
|
-
} from "./chunk-
|
|
108
|
+
} from "./chunk-TVZD7HHB.js";
|
|
109
109
|
import {
|
|
110
110
|
GMAIL_REST_MCP_BRIDGE_ADAPTER,
|
|
111
111
|
gmailRestResultOutcome,
|
|
@@ -190,6 +190,332 @@ import {
|
|
|
190
190
|
undiciFetch
|
|
191
191
|
} from "./chunk-LJNCGUMB.js";
|
|
192
192
|
|
|
193
|
+
// src/drive-mcp.ts
|
|
194
|
+
import { Buffer as Buffer2 } from "buffer";
|
|
195
|
+
import {
|
|
196
|
+
defineLocalMcpBridgeDescriptor
|
|
197
|
+
} from "@opengeni/capabilities";
|
|
198
|
+
import { readResponseJsonBounded } from "@opengeni/network";
|
|
199
|
+
var OFFICIAL_DRIVE_MCP_URL = "https://drivemcp.googleapis.com/mcp/v1";
|
|
200
|
+
var api = "https://www.googleapis.com/drive/v3/";
|
|
201
|
+
var id = external_exports.string().min(1).max(256).regex(/^[a-zA-Z0-9_-]+$/u);
|
|
202
|
+
var file2 = { fileId: id };
|
|
203
|
+
var role = external_exports.enum(["reader", "commenter", "writer", "fileOrganizer", "organizer"]);
|
|
204
|
+
var definitions = {
|
|
205
|
+
update_file: {
|
|
206
|
+
description: "Rename a file or update its description. Requires the app's existing drive.file access to this file.",
|
|
207
|
+
schema: external_exports.object({
|
|
208
|
+
...file2,
|
|
209
|
+
name: external_exports.string().min(1).max(1024).optional(),
|
|
210
|
+
description: external_exports.string().max(16e3).optional()
|
|
211
|
+
}).strict()
|
|
212
|
+
},
|
|
213
|
+
overwrite_file_content: {
|
|
214
|
+
description: "Overwrite the bytes of an existing binary file, preserving its ID. Requires drive.file access. Does not edit native Google Docs/Sheets contents.",
|
|
215
|
+
schema: external_exports.object({
|
|
216
|
+
...file2,
|
|
217
|
+
base64Content: external_exports.string().max(34952536),
|
|
218
|
+
contentMimeType: external_exports.string().min(1).max(255).regex(/^[\w.+-]+\/[\w.+-]+$/u)
|
|
219
|
+
}).strict()
|
|
220
|
+
},
|
|
221
|
+
move_file: {
|
|
222
|
+
description: "Move an existing file between folders. Specify the current parent and destination. Requires drive.file access.",
|
|
223
|
+
schema: external_exports.object({ ...file2, fromParentId: id, toParentId: id }).strict()
|
|
224
|
+
},
|
|
225
|
+
trash_file: {
|
|
226
|
+
description: "Move a file to Trash. Requires drive.file access.",
|
|
227
|
+
schema: external_exports.object(file2).strict()
|
|
228
|
+
},
|
|
229
|
+
restore_file: {
|
|
230
|
+
description: "Restore a file from Trash. Requires drive.file access.",
|
|
231
|
+
schema: external_exports.object(file2).strict()
|
|
232
|
+
},
|
|
233
|
+
delete_file: {
|
|
234
|
+
description: "Permanently delete a file. This cannot be undone. Requires drive.file access.",
|
|
235
|
+
schema: external_exports.object(file2).strict()
|
|
236
|
+
},
|
|
237
|
+
create_permission: {
|
|
238
|
+
description: "Share a file with a user, group, domain, or anyone. Requires drive.file access and sharing permission. Never transfers ownership.",
|
|
239
|
+
schema: external_exports.object({
|
|
240
|
+
...file2,
|
|
241
|
+
type: external_exports.enum(["user", "group", "domain", "anyone"]),
|
|
242
|
+
role,
|
|
243
|
+
emailAddress: external_exports.string().email().optional(),
|
|
244
|
+
domain: external_exports.string().min(1).max(253).optional(),
|
|
245
|
+
allowFileDiscovery: external_exports.boolean().optional()
|
|
246
|
+
}).strict()
|
|
247
|
+
},
|
|
248
|
+
update_permission: {
|
|
249
|
+
description: "Change an existing sharing permission's role. Never transfers ownership. Requires drive.file access.",
|
|
250
|
+
schema: external_exports.object({ ...file2, permissionId: id, role }).strict()
|
|
251
|
+
},
|
|
252
|
+
delete_permission: {
|
|
253
|
+
description: "Remove a file's sharing permission. Requires drive.file access.",
|
|
254
|
+
schema: external_exports.object({ ...file2, permissionId: id }).strict()
|
|
255
|
+
},
|
|
256
|
+
get_changes_start_token: {
|
|
257
|
+
description: "Get a Drive change-feed checkpoint for an ordinary scheduled agent. Save the returned token for list_changes.",
|
|
258
|
+
schema: external_exports.object({ driveId: id.optional() }).strict()
|
|
259
|
+
},
|
|
260
|
+
list_changes: {
|
|
261
|
+
description: "Read a page of changes since a saved pageToken. Follow nextPageToken; save newStartPageToken only after processing every page. Removed items do not grant access to their old contents.",
|
|
262
|
+
schema: external_exports.object({
|
|
263
|
+
pageToken: external_exports.string().min(1).max(2048),
|
|
264
|
+
driveId: id.optional(),
|
|
265
|
+
pageSize: external_exports.number().int().min(1).max(1e3).default(100)
|
|
266
|
+
}).strict()
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
var readNames = /* @__PURE__ */ new Set(["get_changes_start_token", "list_changes"]);
|
|
270
|
+
var DRIVE_EXTRA_TOOLS = Object.entries(definitions).map(([name, definition]) => ({
|
|
271
|
+
name,
|
|
272
|
+
description: definition.description,
|
|
273
|
+
inputSchema: external_exports.toJSONSchema(definition.schema),
|
|
274
|
+
annotations: {
|
|
275
|
+
readOnlyHint: readNames.has(name),
|
|
276
|
+
destructiveHint: !readNames.has(name),
|
|
277
|
+
idempotentHint: readNames.has(name),
|
|
278
|
+
openWorldHint: true
|
|
279
|
+
}
|
|
280
|
+
}));
|
|
281
|
+
var DRIVE_MCP_BRIDGE_DESCRIPTOR = defineLocalMcpBridgeDescriptor({
|
|
282
|
+
adapterId: "drive-mcp-extensions",
|
|
283
|
+
providerId: "google-drive",
|
|
284
|
+
catalogIdentity: `mcp:${OFFICIAL_DRIVE_MCP_URL}`,
|
|
285
|
+
authority: "connection",
|
|
286
|
+
toolSurface: "remote_with_reviewed_extensions",
|
|
287
|
+
mutationReplay: "safe_reads_only",
|
|
288
|
+
destinations: [
|
|
289
|
+
{ origin: "https://drivemcp.googleapis.com", pathPrefix: "/mcp/v1" },
|
|
290
|
+
{ origin: "https://www.googleapis.com", pathPrefix: "/drive/v3/" },
|
|
291
|
+
{ origin: "https://www.googleapis.com", pathPrefix: "/upload/drive/v3/files/" }
|
|
292
|
+
]
|
|
293
|
+
});
|
|
294
|
+
function inputError(text) {
|
|
295
|
+
return { isError: true, content: [{ type: "text", text }] };
|
|
296
|
+
}
|
|
297
|
+
var DriveMcpServer = class {
|
|
298
|
+
constructor(config, context) {
|
|
299
|
+
this.config = config;
|
|
300
|
+
this.context = context;
|
|
301
|
+
this.remote = context.createRemoteServer();
|
|
302
|
+
this.name = this.remote.name;
|
|
303
|
+
}
|
|
304
|
+
bridge = DRIVE_MCP_BRIDGE_DESCRIPTOR;
|
|
305
|
+
cacheToolsList = false;
|
|
306
|
+
name;
|
|
307
|
+
remote;
|
|
308
|
+
connect() {
|
|
309
|
+
return this.remote.connect();
|
|
310
|
+
}
|
|
311
|
+
close() {
|
|
312
|
+
return this.remote.close();
|
|
313
|
+
}
|
|
314
|
+
async invalidateToolsCache() {
|
|
315
|
+
await this.remote.invalidateToolsCache();
|
|
316
|
+
}
|
|
317
|
+
async listTools() {
|
|
318
|
+
return mergeDriveMcpTools(await this.remote.listTools());
|
|
319
|
+
}
|
|
320
|
+
async callTool(name, args, meta, options) {
|
|
321
|
+
return (await this.callToolResult(name, args, meta, options)).content;
|
|
322
|
+
}
|
|
323
|
+
async callToolResult(name, args, meta, options) {
|
|
324
|
+
options?.signal?.throwIfAborted();
|
|
325
|
+
if (!Object.hasOwn(definitions, name)) {
|
|
326
|
+
const remote = this.remote;
|
|
327
|
+
if (remote.callToolResult) return remote.callToolResult(name, args, meta, options);
|
|
328
|
+
return { content: await remote.callTool(name, args, meta, options) };
|
|
329
|
+
}
|
|
330
|
+
const tool2 = name;
|
|
331
|
+
const parsed = definitions[tool2].schema.safeParse(args ?? {});
|
|
332
|
+
if (!parsed.success)
|
|
333
|
+
return { isError: true, content: [{ type: "text", text: parsed.error.message }] };
|
|
334
|
+
const call = { name: tool2, input: parsed.data };
|
|
335
|
+
const fileId = "fileId" in call.input ? call.input.fileId : void 0;
|
|
336
|
+
const url = new URL(api + (fileId ? `files/${fileId}` : "changes"));
|
|
337
|
+
const request = { method: "GET" };
|
|
338
|
+
let body;
|
|
339
|
+
if (fileId) url.searchParams.set("supportsAllDrives", "true");
|
|
340
|
+
switch (call.name) {
|
|
341
|
+
case "update_file": {
|
|
342
|
+
const { input } = call;
|
|
343
|
+
if (input.name === void 0 && input.description === void 0)
|
|
344
|
+
return inputError("Supply name or description.");
|
|
345
|
+
request.method = "PATCH";
|
|
346
|
+
body = {
|
|
347
|
+
...input.name !== void 0 ? { name: input.name } : {},
|
|
348
|
+
...input.description !== void 0 ? { description: input.description } : {}
|
|
349
|
+
};
|
|
350
|
+
break;
|
|
351
|
+
}
|
|
352
|
+
case "overwrite_file_content": {
|
|
353
|
+
const { input } = call;
|
|
354
|
+
if (!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u.test(
|
|
355
|
+
input.base64Content
|
|
356
|
+
))
|
|
357
|
+
return inputError("base64Content must be canonical base64.");
|
|
358
|
+
const bytes = Buffer2.from(input.base64Content, "base64");
|
|
359
|
+
if (bytes.toString("base64") !== input.base64Content)
|
|
360
|
+
return inputError("base64Content must be canonical base64.");
|
|
361
|
+
if (bytes.length > 25 * 1024 * 1024) return inputError("Content exceeds 25 MiB.");
|
|
362
|
+
url.pathname = `/upload/drive/v3/files/${input.fileId}`;
|
|
363
|
+
url.searchParams.set("uploadType", "media");
|
|
364
|
+
request.method = "PATCH";
|
|
365
|
+
request.body = bytes;
|
|
366
|
+
request.headers = { "content-type": input.contentMimeType };
|
|
367
|
+
break;
|
|
368
|
+
}
|
|
369
|
+
case "move_file": {
|
|
370
|
+
const { input } = call;
|
|
371
|
+
if (input.fromParentId === input.toParentId)
|
|
372
|
+
return inputError("The current and destination folders must differ.");
|
|
373
|
+
request.method = "PATCH";
|
|
374
|
+
body = {};
|
|
375
|
+
url.searchParams.set("addParents", input.toParentId);
|
|
376
|
+
url.searchParams.set("removeParents", input.fromParentId);
|
|
377
|
+
break;
|
|
378
|
+
}
|
|
379
|
+
case "trash_file":
|
|
380
|
+
case "restore_file":
|
|
381
|
+
request.method = "PATCH";
|
|
382
|
+
body = { trashed: call.name === "trash_file" };
|
|
383
|
+
break;
|
|
384
|
+
case "delete_file":
|
|
385
|
+
request.method = "DELETE";
|
|
386
|
+
break;
|
|
387
|
+
case "create_permission": {
|
|
388
|
+
const { input } = call;
|
|
389
|
+
const person = input.type === "user" || input.type === "group";
|
|
390
|
+
if (person ? !input.emailAddress || input.domain !== void 0 || input.allowFileDiscovery !== void 0 : input.emailAddress !== void 0 || (input.type === "domain" ? !input.domain : input.domain !== void 0))
|
|
391
|
+
return inputError(
|
|
392
|
+
"User/group sharing requires only emailAddress; domain sharing requires only domain; anyone sharing accepts neither. allowFileDiscovery applies only to domain/anyone."
|
|
393
|
+
);
|
|
394
|
+
request.method = "POST";
|
|
395
|
+
url.pathname += "/permissions";
|
|
396
|
+
body = Object.fromEntries(Object.entries(input).filter(([key]) => key !== "fileId"));
|
|
397
|
+
break;
|
|
398
|
+
}
|
|
399
|
+
case "update_permission":
|
|
400
|
+
request.method = "PATCH";
|
|
401
|
+
url.pathname += `/permissions/${call.input.permissionId}`;
|
|
402
|
+
body = { role: call.input.role };
|
|
403
|
+
break;
|
|
404
|
+
case "delete_permission":
|
|
405
|
+
request.method = "DELETE";
|
|
406
|
+
url.pathname += `/permissions/${call.input.permissionId}`;
|
|
407
|
+
break;
|
|
408
|
+
case "get_changes_start_token":
|
|
409
|
+
url.pathname += "/startPageToken";
|
|
410
|
+
if (call.input.driveId) url.searchParams.set("driveId", call.input.driveId);
|
|
411
|
+
url.searchParams.set("supportsAllDrives", "true");
|
|
412
|
+
break;
|
|
413
|
+
case "list_changes": {
|
|
414
|
+
const { input } = call;
|
|
415
|
+
for (const key of ["pageToken", "pageSize", "driveId"])
|
|
416
|
+
if (input[key] !== void 0) url.searchParams.set(key, String(input[key]));
|
|
417
|
+
url.searchParams.set("supportsAllDrives", "true");
|
|
418
|
+
url.searchParams.set("includeItemsFromAllDrives", "true");
|
|
419
|
+
url.searchParams.set(
|
|
420
|
+
"fields",
|
|
421
|
+
"nextPageToken,newStartPageToken,changes(fileId,removed,time,driveId,file(id,name,mimeType,modifiedTime,parents,trashed))"
|
|
422
|
+
);
|
|
423
|
+
break;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
if (body) {
|
|
427
|
+
request.body = JSON.stringify(body);
|
|
428
|
+
request.headers = { "content-type": "application/json" };
|
|
429
|
+
}
|
|
430
|
+
const read = readNames.has(tool2);
|
|
431
|
+
const credential = await this.context.resolveCredential({
|
|
432
|
+
workspaceId: this.context.workspaceId,
|
|
433
|
+
serverId: this.context.serverId,
|
|
434
|
+
connectionRef: this.config.connectionRef,
|
|
435
|
+
destinationUrl: url.toString(),
|
|
436
|
+
toolName: name,
|
|
437
|
+
forceRefresh: false,
|
|
438
|
+
...this.context.subjectId ? { subjectId: this.context.subjectId } : {}
|
|
439
|
+
});
|
|
440
|
+
if (credential.status === "auth_needed") {
|
|
441
|
+
await this.context.onAuthNeeded?.({
|
|
442
|
+
...credential,
|
|
443
|
+
serverId: this.context.serverId,
|
|
444
|
+
toolName: name
|
|
445
|
+
});
|
|
446
|
+
return {
|
|
447
|
+
isError: true,
|
|
448
|
+
content: [{ type: "text", text: "Reconnect Google Drive to authorize this operation." }]
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
this.context.onResolvedConnectionId?.(credential.connectionId);
|
|
452
|
+
if (credential.authorizeProviderRequest && !await credential.authorizeProviderRequest())
|
|
453
|
+
throw new Error("Google Drive authority is no longer valid");
|
|
454
|
+
options?.signal?.throwIfAborted();
|
|
455
|
+
let response;
|
|
456
|
+
try {
|
|
457
|
+
response = await (this.context.fetchImpl ?? fetch)(url, {
|
|
458
|
+
...request,
|
|
459
|
+
headers: { ...credential.headers, ...request.headers },
|
|
460
|
+
redirect: "error",
|
|
461
|
+
signal: AbortSignal.any([
|
|
462
|
+
AbortSignal.timeout(3e4),
|
|
463
|
+
...options?.signal ? [options.signal] : []
|
|
464
|
+
])
|
|
465
|
+
});
|
|
466
|
+
if (!read && response.status >= 500) {
|
|
467
|
+
await response.body?.cancel().catch(() => void 0);
|
|
468
|
+
throw new DriveMutationOutcomeUnknown();
|
|
469
|
+
}
|
|
470
|
+
} catch (error) {
|
|
471
|
+
if (!read) throw new DriveMutationOutcomeUnknown();
|
|
472
|
+
throw new Error("Google Drive request failed", { cause: error });
|
|
473
|
+
}
|
|
474
|
+
if (response.status === 204) {
|
|
475
|
+
await response.body?.cancel().catch(() => void 0);
|
|
476
|
+
return { content: [{ type: "text", text: "{}" }], structuredContent: {} };
|
|
477
|
+
}
|
|
478
|
+
let payload;
|
|
479
|
+
try {
|
|
480
|
+
payload = await readResponseJsonBounded(response, 8 * 1024 * 1024, "Google Drive response");
|
|
481
|
+
} catch (error) {
|
|
482
|
+
if (!read && response.ok) throw new DriveMutationOutcomeUnknown();
|
|
483
|
+
throw error;
|
|
484
|
+
}
|
|
485
|
+
return {
|
|
486
|
+
...response.ok ? {} : { isError: true },
|
|
487
|
+
content: [{ type: "text", text: JSON.stringify(payload) }],
|
|
488
|
+
structuredContent: payload
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
var DriveMutationOutcomeUnknown = class extends Error {
|
|
493
|
+
code = 40102;
|
|
494
|
+
connectorActionOutcome = "uncertain";
|
|
495
|
+
retryable = false;
|
|
496
|
+
constructor() {
|
|
497
|
+
super(
|
|
498
|
+
"Google Drive mutation was submitted but its outcome is uncertain. Inspect the file before trying again."
|
|
499
|
+
);
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
function isOfficialDriveMcpConfig(config) {
|
|
503
|
+
return config.url === OFFICIAL_DRIVE_MCP_URL && config.connectionRef?.providerDomain === "drivemcp.googleapis.com" && config.connectionRef.kind === "oauth2" && config.connectionRef.subjectScope === "subject";
|
|
504
|
+
}
|
|
505
|
+
function mergeDriveMcpTools(remote) {
|
|
506
|
+
const collisions = remote.filter((tool2) => Object.hasOwn(definitions, tool2.name));
|
|
507
|
+
if (collisions.length)
|
|
508
|
+
throw new Error(
|
|
509
|
+
`Drive tool extension collision: ${collisions.map((tool2) => tool2.name).join(", ")}`
|
|
510
|
+
);
|
|
511
|
+
return [...remote, ...structuredClone(DRIVE_EXTRA_TOOLS)];
|
|
512
|
+
}
|
|
513
|
+
var DRIVE_MCP_BRIDGE_ADAPTER = {
|
|
514
|
+
adapterId: DRIVE_MCP_BRIDGE_DESCRIPTOR.adapterId,
|
|
515
|
+
matches: isOfficialDriveMcpConfig,
|
|
516
|
+
create: (config, context) => new DriveMcpServer(config, context)
|
|
517
|
+
};
|
|
518
|
+
|
|
193
519
|
// src/agent-instructions/types.ts
|
|
194
520
|
function toolAvailable(context, name) {
|
|
195
521
|
return !context.toolAvailability?.unavailable.includes(name);
|
|
@@ -859,11 +1185,11 @@ var REFLESS_ROLES = /* @__PURE__ */ new Set([
|
|
|
859
1185
|
"text",
|
|
860
1186
|
"time"
|
|
861
1187
|
]);
|
|
862
|
-
function shownState(
|
|
1188
|
+
function shownState(role2, state) {
|
|
863
1189
|
if (state === "focusable" || state === "settable" || state === "editable") return false;
|
|
864
1190
|
if (state.startsWith("editable=") || state.startsWith("url=")) return false;
|
|
865
1191
|
if (state.endsWith("=")) return false;
|
|
866
|
-
if (
|
|
1192
|
+
if (role2 === "document" && state === "focused") return false;
|
|
867
1193
|
return true;
|
|
868
1194
|
}
|
|
869
1195
|
function quoted(value) {
|
|
@@ -1300,11 +1626,13 @@ function computerObservationText(observation) {
|
|
|
1300
1626
|
roots.length === 0 && semantic.removedRefs.length === 0 ? `No element changed since ${semantic.baseObservationId}; its refs are still valid.` : `Changed elements since ${semantic.baseObservationId}; elements not listed are unchanged and keep their refs:`
|
|
1301
1627
|
);
|
|
1302
1628
|
} else if (rendered.listed === 0) {
|
|
1303
|
-
lines.push(
|
|
1629
|
+
lines.push(
|
|
1630
|
+
rendered.omitted ? `No element is listed: the accessibility tree's ${plural2(rendered.omitted, "element")} are all hidden, unlabeled or repeated; use the screenshot.` : "The accessibility tree has no readable elements; use the screenshot."
|
|
1631
|
+
);
|
|
1304
1632
|
}
|
|
1305
1633
|
lines.push(...rendered.lines);
|
|
1306
1634
|
const notes = [
|
|
1307
|
-
rendered.omitted ? `${plural2(rendered.omitted, "hidden, unlabeled or repeated element")} not shown` : null,
|
|
1635
|
+
rendered.omitted && rendered.listed > 0 ? `${plural2(rendered.omitted, "hidden, unlabeled or repeated element")} not shown` : null,
|
|
1308
1636
|
semantic.kind === "diff" && semantic.removedRefs.length > 0 ? `${plural2(semantic.removedRefs.length, "earlier element")} removed` : null,
|
|
1309
1637
|
rendered.clipped ? `${plural2(rendered.clipped, "long field")} clipped` : null
|
|
1310
1638
|
].filter((entry) => entry !== null);
|
|
@@ -2079,7 +2407,7 @@ function createInteractionAttemptToolDefinitions(input) {
|
|
|
2079
2407
|
name: "Opengeni Browser",
|
|
2080
2408
|
installUrl: OPENGENI_BROWSER_EXTENSION_URL
|
|
2081
2409
|
};
|
|
2082
|
-
const
|
|
2410
|
+
const definitions2 = [];
|
|
2083
2411
|
const publishedUploads = /* @__PURE__ */ new Map();
|
|
2084
2412
|
const computerSeen = /* @__PURE__ */ new Map();
|
|
2085
2413
|
const seenComputerKey = (observation) => `${observation.computerSessionId}\0${observation.target.id}`;
|
|
@@ -2322,7 +2650,7 @@ function createInteractionAttemptToolDefinitions(input) {
|
|
|
2322
2650
|
if (!selected.has(options.name) || !hasToolPermission(permissions, TOOL_PERMISSION[options.name])) {
|
|
2323
2651
|
return;
|
|
2324
2652
|
}
|
|
2325
|
-
|
|
2653
|
+
definitions2.push({
|
|
2326
2654
|
identity: { serverId: "interaction", toolName: options.name },
|
|
2327
2655
|
modelName: `interaction__${options.name}`,
|
|
2328
2656
|
codemodePath: options.codemodePath,
|
|
@@ -3287,12 +3615,12 @@ No screenshot of an app target; observe one of its windows or the screen for pix
|
|
|
3287
3615
|
})
|
|
3288
3616
|
);
|
|
3289
3617
|
const outputSchema = variants.every((variant) => variant.outputSchema) ? nativeCuaSchema(variants.map((variant) => variant.outputSchema)) : void 0;
|
|
3290
|
-
|
|
3618
|
+
definitions2.push({
|
|
3291
3619
|
identity: { serverId: "interaction", toolName: "cua_" + tool2.name },
|
|
3292
3620
|
modelName: "interaction__cua_" + tool2.name,
|
|
3293
|
-
codemodePath: ["
|
|
3621
|
+
codemodePath: ["interaction", "cua", tool2.name],
|
|
3294
3622
|
title: tool2.name,
|
|
3295
|
-
description: "Native CUA computer tool; requires a CUA-backed computer_open session. " + tool2.description,
|
|
3623
|
+
description: "Native CUA computer tool; requires a CUA-backed computer_open session. Other CUA tools it names are interaction__cua_<name> (in Code Mode interaction.cua.<name>); steps inside run_steps keep the plain name. " + tool2.description,
|
|
3296
3624
|
inputSchema,
|
|
3297
3625
|
...outputSchema ? { outputSchema } : {},
|
|
3298
3626
|
// Read-like tools can write screenshots to files; all native calls use
|
|
@@ -3302,10 +3630,10 @@ No screenshot of an app target; observe one of its windows or the screen for pix
|
|
|
3302
3630
|
approval: "none",
|
|
3303
3631
|
execute: async (raw, context) => {
|
|
3304
3632
|
const { computerSessionId, ...args } = raw;
|
|
3305
|
-
const
|
|
3633
|
+
const id2 = external_exports.string().uuid().parse(computerSessionId);
|
|
3306
3634
|
let response;
|
|
3307
3635
|
try {
|
|
3308
|
-
response = await input.transport.callNativeComputerTool(input.workspaceId,
|
|
3636
|
+
response = await input.transport.callNativeComputerTool(input.workspaceId, id2, {
|
|
3309
3637
|
operationId: context.operationId,
|
|
3310
3638
|
tool: tool2.name,
|
|
3311
3639
|
arguments: args
|
|
@@ -3344,7 +3672,7 @@ No screenshot of an app target; observe one of its windows or the screen for pix
|
|
|
3344
3672
|
});
|
|
3345
3673
|
}
|
|
3346
3674
|
}
|
|
3347
|
-
return
|
|
3675
|
+
return definitions2;
|
|
3348
3676
|
}
|
|
3349
3677
|
function nativeCuaSchema(variants) {
|
|
3350
3678
|
const unique = [...new Map(variants.map((schema) => [JSON.stringify(schema), schema])).values()];
|
|
@@ -4614,12 +4942,12 @@ function compactionPrefixCuts(items) {
|
|
|
4614
4942
|
const phase = realInput || resultTypes.has(type) ? "user" : "assistant";
|
|
4615
4943
|
if (index > 0 && calls.size === 0 && !unidentifiedCall && phase !== previousPhase)
|
|
4616
4944
|
cuts.push(index);
|
|
4617
|
-
const
|
|
4945
|
+
const id2 = toolCallIdFromSdkItem(item);
|
|
4618
4946
|
if (Object.hasOwn(TOOL_CALL_RESULT_TYPE_BY_CALL_TYPE, type)) {
|
|
4619
|
-
if (
|
|
4947
|
+
if (id2) calls.add(id2);
|
|
4620
4948
|
else unidentifiedCall = true;
|
|
4621
4949
|
}
|
|
4622
|
-
if (resultTypes.has(type) && typeof
|
|
4950
|
+
if (resultTypes.has(type) && typeof id2 === "string") calls.delete(id2);
|
|
4623
4951
|
previousPhase = phase;
|
|
4624
4952
|
}
|
|
4625
4953
|
return cuts;
|
|
@@ -4669,7 +4997,7 @@ var RunMcpCredentials = class {
|
|
|
4669
4997
|
#closed = false;
|
|
4670
4998
|
#onAbort = () => this.close();
|
|
4671
4999
|
constructor(targets, options = {}) {
|
|
4672
|
-
this.#targets = targets.filter((target) => !target.connectionRef).map(({ id, url }) => ({ id, url }));
|
|
5000
|
+
this.#targets = targets.filter((target) => !target.connectionRef).map(({ id: id2, url }) => ({ id: id2, url }));
|
|
4673
5001
|
this.#signal = options.signal;
|
|
4674
5002
|
this.#now = options.now ?? Date.now;
|
|
4675
5003
|
this.#signal?.addEventListener("abort", this.#onAbort, { once: true });
|
|
@@ -4705,39 +5033,39 @@ var RunMcpCredentials = class {
|
|
|
4705
5033
|
skipped += 1;
|
|
4706
5034
|
continue;
|
|
4707
5035
|
}
|
|
4708
|
-
const
|
|
4709
|
-
managed.add(
|
|
4710
|
-
if (next.has(
|
|
5036
|
+
const id2 = matches[0].id;
|
|
5037
|
+
managed.add(id2);
|
|
5038
|
+
if (next.has(id2)) {
|
|
4711
5039
|
skipped += 1;
|
|
4712
|
-
next.delete(
|
|
5040
|
+
next.delete(id2);
|
|
4713
5041
|
continue;
|
|
4714
5042
|
}
|
|
4715
5043
|
const expiry = entry.expiresAt ? Date.parse(entry.expiresAt) : null;
|
|
4716
5044
|
const expiresAt = expiry === null ? material?.expiresAt?.getTime() ?? null : Math.min(expiry, material?.expiresAt?.getTime() ?? Infinity);
|
|
4717
5045
|
if (expiresAt !== null && (!Number.isFinite(expiresAt) || expiresAt <= this.#now())) {
|
|
4718
5046
|
skipped += 1;
|
|
4719
|
-
retained.add(
|
|
5047
|
+
retained.add(id2);
|
|
4720
5048
|
continue;
|
|
4721
5049
|
}
|
|
4722
|
-
next.set(
|
|
5050
|
+
next.set(id2, { headers: { ...entry.headers }, expiresAt });
|
|
4723
5051
|
}
|
|
4724
5052
|
return () => {
|
|
4725
5053
|
this.#assertOpen();
|
|
4726
|
-
for (const
|
|
4727
|
-
if (this.#remoteTargets && !this.#remoteTargets.some((target) => target.id ===
|
|
4728
|
-
next.delete(
|
|
5054
|
+
for (const id2 of next.keys()) {
|
|
5055
|
+
if (this.#remoteTargets && !this.#remoteTargets.some((target) => target.id === id2)) {
|
|
5056
|
+
next.delete(id2);
|
|
4729
5057
|
skipped += 1;
|
|
4730
5058
|
}
|
|
4731
5059
|
}
|
|
4732
5060
|
if (skipped) {
|
|
4733
|
-
for (const [
|
|
4734
|
-
if (!next.has(
|
|
5061
|
+
for (const [id2, entry] of this.#entries) {
|
|
5062
|
+
if (!next.has(id2) && (retained.has(id2) || !managed.has(id2))) next.set(id2, entry);
|
|
4735
5063
|
}
|
|
4736
5064
|
}
|
|
4737
5065
|
this.#entries = next;
|
|
4738
|
-
for (const
|
|
4739
|
-
if (!this.#remoteTargets || this.#remoteTargets.some((target) => target.id ===
|
|
4740
|
-
this.#managed.add(
|
|
5066
|
+
for (const id2 of managed) {
|
|
5067
|
+
if (!this.#remoteTargets || this.#remoteTargets.some((target) => target.id === id2)) {
|
|
5068
|
+
this.#managed.add(id2);
|
|
4741
5069
|
}
|
|
4742
5070
|
}
|
|
4743
5071
|
this.#warnSkipped(skipped);
|
|
@@ -4755,18 +5083,18 @@ var RunMcpCredentials = class {
|
|
|
4755
5083
|
);
|
|
4756
5084
|
this.#dropExcluded();
|
|
4757
5085
|
}
|
|
4758
|
-
excludeLocalTarget(
|
|
5086
|
+
excludeLocalTarget(id2) {
|
|
4759
5087
|
this.#remoteTargets = (this.#remoteTargets ?? this.#targets).filter(
|
|
4760
|
-
(target) => target.id !==
|
|
5088
|
+
(target) => target.id !== id2
|
|
4761
5089
|
);
|
|
4762
5090
|
this.#dropExcluded();
|
|
4763
5091
|
}
|
|
4764
5092
|
#dropExcluded() {
|
|
4765
5093
|
let skipped = 0;
|
|
4766
|
-
for (const
|
|
4767
|
-
if (!this.#remoteTargets?.some((target) => target.id ===
|
|
4768
|
-
this.#entries.delete(
|
|
4769
|
-
this.#managed.delete(
|
|
5094
|
+
for (const id2 of this.#managed) {
|
|
5095
|
+
if (!this.#remoteTargets?.some((target) => target.id === id2)) {
|
|
5096
|
+
this.#entries.delete(id2);
|
|
5097
|
+
this.#managed.delete(id2);
|
|
4770
5098
|
skipped += 1;
|
|
4771
5099
|
}
|
|
4772
5100
|
}
|
|
@@ -4779,13 +5107,13 @@ var RunMcpCredentials = class {
|
|
|
4779
5107
|
count
|
|
4780
5108
|
});
|
|
4781
5109
|
}
|
|
4782
|
-
has(
|
|
4783
|
-
return this.#managed.has(
|
|
5110
|
+
has(id2) {
|
|
5111
|
+
return this.#managed.has(id2);
|
|
4784
5112
|
}
|
|
4785
|
-
assertAvailable(
|
|
5113
|
+
assertAvailable(id2) {
|
|
4786
5114
|
this.#assertOpen();
|
|
4787
|
-
if (!this.#managed.has(
|
|
4788
|
-
const entry = this.#entries.get(
|
|
5115
|
+
if (!this.#managed.has(id2)) return;
|
|
5116
|
+
const entry = this.#entries.get(id2);
|
|
4789
5117
|
if (!entry || entry.expiresAt !== null && entry.expiresAt <= this.#now()) {
|
|
4790
5118
|
throw new RunMcpCredentialError("MCP authentication unavailable: provider renewal required");
|
|
4791
5119
|
}
|
|
@@ -5148,8 +5476,8 @@ function skillCatalogEntryIds(catalog) {
|
|
|
5148
5476
|
} catch {
|
|
5149
5477
|
continue;
|
|
5150
5478
|
}
|
|
5151
|
-
const
|
|
5152
|
-
if (typeof
|
|
5479
|
+
const id2 = entry?.id;
|
|
5480
|
+
if (typeof id2 === "string" && id2) ids.add(id2);
|
|
5153
5481
|
}
|
|
5154
5482
|
return ids;
|
|
5155
5483
|
}
|
|
@@ -5525,8 +5853,8 @@ async function projectAttemptToolResultForCaller(result, context, spill, identit
|
|
|
5525
5853
|
function wrapAttemptToolExecute(execute, spill, identity2) {
|
|
5526
5854
|
return async (args, context) => await projectAttemptToolResultForCaller(await execute(args, context), context, spill, identity2);
|
|
5527
5855
|
}
|
|
5528
|
-
function wrapAttemptToolDefinitions(
|
|
5529
|
-
return
|
|
5856
|
+
function wrapAttemptToolDefinitions(definitions2, spill) {
|
|
5857
|
+
return definitions2.map((definition) => ({
|
|
5530
5858
|
...definition,
|
|
5531
5859
|
execute: wrapAttemptToolExecute(definition.execute, spill, definition.identity)
|
|
5532
5860
|
}));
|
|
@@ -6343,10 +6671,10 @@ function composeModularAgentInstructions(input) {
|
|
|
6343
6671
|
joinBefore: MODULAR_LAYER_SEPARATOR
|
|
6344
6672
|
}
|
|
6345
6673
|
];
|
|
6346
|
-
const push = (
|
|
6674
|
+
const push = (id2, title, content) => {
|
|
6347
6675
|
const trimmed = content?.trim();
|
|
6348
6676
|
if (!trimmed) return;
|
|
6349
|
-
layers.push({ id, title, content: trimmed, joinBefore: MODULAR_LAYER_SEPARATOR });
|
|
6677
|
+
layers.push({ id: id2, title, content: trimmed, joinBefore: MODULAR_LAYER_SEPARATOR });
|
|
6350
6678
|
};
|
|
6351
6679
|
push("codemode", "Codemode", input.codemode);
|
|
6352
6680
|
push("code_search", "Code search", input.codeSearch);
|
|
@@ -7325,7 +7653,7 @@ async function repositorySkillFiles(session, root, paths, runAs) {
|
|
|
7325
7653
|
});
|
|
7326
7654
|
readSkillFiles(
|
|
7327
7655
|
files,
|
|
7328
|
-
files.map((
|
|
7656
|
+
files.map((file3) => file3.path)
|
|
7329
7657
|
);
|
|
7330
7658
|
}
|
|
7331
7659
|
return files;
|
|
@@ -7368,7 +7696,7 @@ import { existsSync, readdirSync } from "fs";
|
|
|
7368
7696
|
// ../sdk/package.json
|
|
7369
7697
|
var package_default = {
|
|
7370
7698
|
name: "@opengeni/sdk",
|
|
7371
|
-
version: "4.6.
|
|
7699
|
+
version: "4.6.2-canary.39854174564001",
|
|
7372
7700
|
description: "Framework-agnostic TypeScript SDK for the Opengeni API: typed client, session lifecycle, SSE event streaming with reconnect + replay-by-sequence, and proxy re-streaming helpers.",
|
|
7373
7701
|
license: "Apache-2.0",
|
|
7374
7702
|
repository: {
|
|
@@ -7610,7 +7938,7 @@ var package_default = {
|
|
|
7610
7938
|
// ../react/package.json
|
|
7611
7939
|
var package_default2 = {
|
|
7612
7940
|
name: "@opengeni/react",
|
|
7613
|
-
version: "4.6.
|
|
7941
|
+
version: "4.6.2-canary.39854174564001",
|
|
7614
7942
|
description: "React hooks and styled components for Opengeni: live session streaming, chat composer, message timeline, session status, and fleet views \u2014 token-themed (CSS variables), dark-first, built on Tailwind v4 + Radix + Motion.",
|
|
7615
7943
|
license: "Apache-2.0",
|
|
7616
7944
|
repository: {
|
|
@@ -7984,7 +8312,7 @@ var package_default2 = {
|
|
|
7984
8312
|
// ../codemode/package.json
|
|
7985
8313
|
var package_default3 = {
|
|
7986
8314
|
name: "@opengeni/codemode",
|
|
7987
|
-
version: "4.6.
|
|
8315
|
+
version: "4.6.2-canary.39854174564001",
|
|
7988
8316
|
description: "Attempt-frozen programmatic tool catalog and execution authority for Opengeni.",
|
|
7989
8317
|
license: "Apache-2.0",
|
|
7990
8318
|
repository: {
|
|
@@ -8034,7 +8362,7 @@ var package_default3 = {
|
|
|
8034
8362
|
// ../ogtool/package.json
|
|
8035
8363
|
var package_default4 = {
|
|
8036
8364
|
name: "@opengeni/ogtool",
|
|
8037
|
-
version: "4.6.
|
|
8365
|
+
version: "4.6.2-canary.39854174564001",
|
|
8038
8366
|
description: "Codemode CLI and typed client entrypoint for an Opengeni execution attempt.",
|
|
8039
8367
|
license: "Apache-2.0",
|
|
8040
8368
|
repository: {
|
|
@@ -8429,7 +8757,7 @@ function runtimeSkillDescription(skill) {
|
|
|
8429
8757
|
|
|
8430
8758
|
// src/model-context-inspector.ts
|
|
8431
8759
|
import { MODEL_CONTEXT_SNAPSHOT_VERSION } from "@opengeni/contracts";
|
|
8432
|
-
function contextTextEstimate(value) {
|
|
8760
|
+
function contextTextEstimate(value, serialized) {
|
|
8433
8761
|
const containsNonText = (part) => {
|
|
8434
8762
|
if (Array.isArray(part)) return part.some(containsNonText);
|
|
8435
8763
|
if (!part || typeof part !== "object") return false;
|
|
@@ -8441,7 +8769,10 @@ function contextTextEstimate(value) {
|
|
|
8441
8769
|
return true;
|
|
8442
8770
|
return Object.values(record).some(containsNonText);
|
|
8443
8771
|
};
|
|
8444
|
-
|
|
8772
|
+
if (containsNonText(value)) return null;
|
|
8773
|
+
return estimateTextTokens(
|
|
8774
|
+
typeof value === "string" ? value : serialized ?? JSON.stringify(value)
|
|
8775
|
+
);
|
|
8445
8776
|
}
|
|
8446
8777
|
function buildProviderRequestSnapshot(input) {
|
|
8447
8778
|
let body = input.body;
|
|
@@ -8457,12 +8788,15 @@ function buildProviderRequestSnapshot(input) {
|
|
|
8457
8788
|
body = null;
|
|
8458
8789
|
unavailableReason = "The provider body is not a JSON object.";
|
|
8459
8790
|
}
|
|
8460
|
-
const parts = Object.entries(payload).map(([key, value]) =>
|
|
8461
|
-
|
|
8462
|
-
|
|
8463
|
-
|
|
8464
|
-
|
|
8465
|
-
|
|
8791
|
+
const parts = Object.entries(payload).map(([key, value]) => {
|
|
8792
|
+
const serialized = JSON.stringify(value);
|
|
8793
|
+
return {
|
|
8794
|
+
key,
|
|
8795
|
+
estimatedTokens: contextTextEstimate(value, serialized),
|
|
8796
|
+
utf8Bytes: Buffer.byteLength(serialized, "utf8"),
|
|
8797
|
+
...Array.isArray(value) ? { itemEstimatedTokens: value.map((item) => contextTextEstimate(item)) } : {}
|
|
8798
|
+
};
|
|
8799
|
+
});
|
|
8466
8800
|
const instructionsTokens = parts.find((part) => part.key === "instructions")?.estimatedTokens ?? 0;
|
|
8467
8801
|
const wireInstructions = typeof payload.instructions === "string" ? payload.instructions : null;
|
|
8468
8802
|
const sectionLayers = wireInstructions && input.persistentLayers?.length ? splitCapturedInstructions({
|
|
@@ -8699,16 +9033,14 @@ function splitRawSystemInstructions(captured, persistent, composed, genesisTitle
|
|
|
8699
9033
|
}
|
|
8700
9034
|
function countedTool(input) {
|
|
8701
9035
|
const schema = input.schema;
|
|
8702
|
-
const
|
|
8703
|
-
|
|
8704
|
-
|
|
8705
|
-
|
|
8706
|
-
|
|
8707
|
-
|
|
8708
|
-
|
|
8709
|
-
|
|
8710
|
-
"utf8"
|
|
8711
|
-
);
|
|
9036
|
+
const serialized = JSON.stringify({
|
|
9037
|
+
name: input.name,
|
|
9038
|
+
type: input.type,
|
|
9039
|
+
description: input.description,
|
|
9040
|
+
namespace: input.namespace,
|
|
9041
|
+
schema
|
|
9042
|
+
});
|
|
9043
|
+
const utf8Bytes = Buffer.byteLength(serialized, "utf8");
|
|
8712
9044
|
return {
|
|
8713
9045
|
name: input.name,
|
|
8714
9046
|
type: input.type,
|
|
@@ -8717,13 +9049,7 @@ function countedTool(input) {
|
|
|
8717
9049
|
...input.namespace ? { namespace: input.namespace } : {},
|
|
8718
9050
|
...schema !== void 0 ? { schema } : {},
|
|
8719
9051
|
utf8Bytes,
|
|
8720
|
-
estimatedTokens:
|
|
8721
|
-
name: input.name,
|
|
8722
|
-
type: input.type,
|
|
8723
|
-
description: input.description,
|
|
8724
|
-
namespace: input.namespace,
|
|
8725
|
-
schema
|
|
8726
|
-
})
|
|
9052
|
+
estimatedTokens: estimateTextTokens(serialized)
|
|
8727
9053
|
};
|
|
8728
9054
|
}
|
|
8729
9055
|
function serializedToolToModelContextTool(tool2, visibility) {
|
|
@@ -10062,7 +10388,11 @@ setOpenSandboxApplyDiff(
|
|
|
10062
10388
|
applyDiff
|
|
10063
10389
|
);
|
|
10064
10390
|
ensureReadableStreamFrom();
|
|
10065
|
-
var BUILT_IN_MCP_BRIDGE_ADAPTERS = Object.freeze([
|
|
10391
|
+
var BUILT_IN_MCP_BRIDGE_ADAPTERS = Object.freeze([
|
|
10392
|
+
GMAIL_REST_MCP_BRIDGE_ADAPTER,
|
|
10393
|
+
SLACK_REST_MCP_BRIDGE_ADAPTER,
|
|
10394
|
+
DRIVE_MCP_BRIDGE_ADAPTER
|
|
10395
|
+
]);
|
|
10066
10396
|
var SANDBOX_LIFECYCLE_COMMAND_TIMEOUT_MS = 12e4;
|
|
10067
10397
|
function ensureReadableStreamFrom() {
|
|
10068
10398
|
const ctor = globalThis.ReadableStream;
|
|
@@ -10164,13 +10494,13 @@ function normalizeGeneratedSessionTitle(text, stoppedAtOutputLimit) {
|
|
|
10164
10494
|
}
|
|
10165
10495
|
async function summarizeForCompaction(settings, input, options = {}) {
|
|
10166
10496
|
const client = options.client ?? buildOpenAIClientFromSettings(settings);
|
|
10167
|
-
const
|
|
10497
|
+
const api2 = options.api ?? "responses";
|
|
10168
10498
|
const model = options.model ?? settings.openaiModel;
|
|
10169
10499
|
const provider = options.provider ?? configuredProviders(settings)[0];
|
|
10170
10500
|
if (!provider) throw new Error("Built-in model provider is unavailable");
|
|
10171
10501
|
const azureResponses = provider.wireProfile === "azure-openai";
|
|
10172
10502
|
const maxTokens = options.maxOutputTokens ?? compactionSummaryOutputTokens(settings.contextWindowTokens);
|
|
10173
|
-
if (
|
|
10503
|
+
if (api2 === "chat") {
|
|
10174
10504
|
const transcript = renderCompactionPromptInputForChat(input);
|
|
10175
10505
|
let completion;
|
|
10176
10506
|
try {
|
|
@@ -10854,10 +11184,10 @@ ${personaAndCore}` : OPENGENI_OPERATIONAL_INSTRUCTIONS
|
|
|
10854
11184
|
},
|
|
10855
11185
|
{ id: "persona_and_core", title: "Persona and CORE", content: personaAndCore }
|
|
10856
11186
|
];
|
|
10857
|
-
const push = (
|
|
11187
|
+
const push = (id2, title, content) => {
|
|
10858
11188
|
const trimmed = content?.trim();
|
|
10859
11189
|
if (!trimmed) return;
|
|
10860
|
-
layers.push({ id, title, content: trimmed });
|
|
11190
|
+
layers.push({ id: id2, title, content: trimmed });
|
|
10861
11191
|
};
|
|
10862
11192
|
if (!options.workspaceGovernance?.trim()) {
|
|
10863
11193
|
if (codemodeIsAvailable(options)) {
|
|
@@ -12531,6 +12861,27 @@ async function prepareAgentTools(settings, tools, options = {}) {
|
|
|
12531
12861
|
optional
|
|
12532
12862
|
) : firstParty ? firstPartyAuthFetch(guardedFetch, settings, options) : guardedFetch;
|
|
12533
12863
|
const bestEffort = isCodexAppsMcpServer(config) || optional || !!config.connectionRef;
|
|
12864
|
+
const remoteRequestInit = await mcpServerRequestInit(settings, config);
|
|
12865
|
+
const createRemoteServer = () => new MCPServerStreamableHttp({
|
|
12866
|
+
url,
|
|
12867
|
+
name: config.name ?? config.id,
|
|
12868
|
+
cacheToolsList: config.cacheToolsList,
|
|
12869
|
+
// The upstream transport logger receives raw thrown errors, whose
|
|
12870
|
+
// messages may contain response bodies, URLs, headers, or echoed
|
|
12871
|
+
// credentials. Keep its diagnostic surface structural only.
|
|
12872
|
+
// This logger spans tool invocation as well as setup. Only the
|
|
12873
|
+
// connect/list lifecycle wrappers may add setup-safe recovery facts.
|
|
12874
|
+
logger: mcpTransportLogger(config.id),
|
|
12875
|
+
// codex_apps returns connector tools with empty `outputSchema: {}` that the
|
|
12876
|
+
// MCP SDK's strict Tool schema rejects (fails the turn during tools/list);
|
|
12877
|
+
// sanitize the response on the wire before validation. The namespace Set
|
|
12878
|
+
// also captures each tool's original connector namespace (P4 Part B.1).
|
|
12879
|
+
fetch: fetchImpl,
|
|
12880
|
+
...mcpStreamableHttpClientOptions({ firstParty }),
|
|
12881
|
+
...remoteRequestInit,
|
|
12882
|
+
...config.timeoutMs ? { timeout: config.timeoutMs } : {},
|
|
12883
|
+
...mcpSessionTimeoutOptions(config)
|
|
12884
|
+
});
|
|
12534
12885
|
const bridge = createLocalMcpBridgeFromAdapters(
|
|
12535
12886
|
BUILT_IN_MCP_BRIDGE_ADAPTERS,
|
|
12536
12887
|
{
|
|
@@ -12538,6 +12889,7 @@ async function prepareAgentTools(settings, tools, options = {}) {
|
|
|
12538
12889
|
...config.connectionRef ? { connectionRef: config.connectionRef } : {}
|
|
12539
12890
|
},
|
|
12540
12891
|
{
|
|
12892
|
+
createRemoteServer,
|
|
12541
12893
|
workspaceId: options.workspaceId ?? "",
|
|
12542
12894
|
...options.credentialSubjectId ? { subjectId: options.credentialSubjectId } : {},
|
|
12543
12895
|
serverId: config.id,
|
|
@@ -12561,26 +12913,7 @@ async function prepareAgentTools(settings, tools, options = {}) {
|
|
|
12561
12913
|
...settings.gmailWatchTopicName ? { watchTopicName: settings.gmailWatchTopicName } : {}
|
|
12562
12914
|
}
|
|
12563
12915
|
);
|
|
12564
|
-
const innerServer = bridge ??
|
|
12565
|
-
url,
|
|
12566
|
-
name: config.name ?? config.id,
|
|
12567
|
-
cacheToolsList: config.cacheToolsList,
|
|
12568
|
-
// The upstream transport logger receives raw thrown errors, whose
|
|
12569
|
-
// messages may contain response bodies, URLs, headers, or echoed
|
|
12570
|
-
// credentials. Keep its diagnostic surface structural only.
|
|
12571
|
-
// This logger spans tool invocation as well as setup. Only the
|
|
12572
|
-
// connect/list lifecycle wrappers may add setup-safe recovery facts.
|
|
12573
|
-
logger: mcpTransportLogger(config.id),
|
|
12574
|
-
// codex_apps returns connector tools with empty `outputSchema: {}` that the
|
|
12575
|
-
// MCP SDK's strict Tool schema rejects (fails the turn during tools/list);
|
|
12576
|
-
// sanitize the response on the wire before validation. The namespace Set
|
|
12577
|
-
// also captures each tool's original connector namespace (P4 Part B.1).
|
|
12578
|
-
fetch: fetchImpl,
|
|
12579
|
-
...mcpStreamableHttpClientOptions({ firstParty }),
|
|
12580
|
-
...await mcpServerRequestInit(settings, config),
|
|
12581
|
-
...config.timeoutMs ? { timeout: config.timeoutMs } : {},
|
|
12582
|
-
...mcpSessionTimeoutOptions(config)
|
|
12583
|
-
});
|
|
12916
|
+
const innerServer = bridge ?? createRemoteServer();
|
|
12584
12917
|
if (bridge) options.runMcpCredentials?.excludeLocalTarget(config.id);
|
|
12585
12918
|
const server = configureMcpOperationRecovery(
|
|
12586
12919
|
new PrefixedMcpServer(
|
|
@@ -12988,7 +13321,7 @@ async function prepareAttemptToolEnvironment(servers, registry, resolvedMcpConne
|
|
|
12988
13321
|
options.sessionAttachedRemoteMcpTargets,
|
|
12989
13322
|
options.runMcpCredentials
|
|
12990
13323
|
);
|
|
12991
|
-
const
|
|
13324
|
+
const definitions2 = installAttemptConnectorActionGatewayLifecycle(
|
|
12992
13325
|
[
|
|
12993
13326
|
...prepared.definitions.map((definition) => ({
|
|
12994
13327
|
...definition,
|
|
@@ -13017,7 +13350,7 @@ async function prepareAttemptToolEnvironment(servers, registry, resolvedMcpConne
|
|
|
13017
13350
|
);
|
|
13018
13351
|
const subjectId = options.subjectId ?? "worker:mcp-model";
|
|
13019
13352
|
const secretArguments = createSecretArgumentResolver({ resolver: options.secretResolver });
|
|
13020
|
-
const guardedDefinitions = options.authorizeAttemptExecution ?
|
|
13353
|
+
const guardedDefinitions = options.authorizeAttemptExecution ? definitions2.map((definition) => ({
|
|
13021
13354
|
...definition,
|
|
13022
13355
|
lifecycle: {
|
|
13023
13356
|
prepare: async (input) => {
|
|
@@ -13032,7 +13365,7 @@ async function prepareAttemptToolEnvironment(servers, registry, resolvedMcpConne
|
|
|
13032
13365
|
};
|
|
13033
13366
|
}
|
|
13034
13367
|
}
|
|
13035
|
-
})) :
|
|
13368
|
+
})) : definitions2;
|
|
13036
13369
|
const environment = createAttemptToolEnvironment({
|
|
13037
13370
|
scope,
|
|
13038
13371
|
firstPartyMcpPermissions: options.firstPartyPermissions ?? [
|
|
@@ -13049,7 +13382,7 @@ async function prepareAttemptToolEnvironment(servers, registry, resolvedMcpConne
|
|
|
13049
13382
|
}
|
|
13050
13383
|
return environment;
|
|
13051
13384
|
}
|
|
13052
|
-
function installAttemptConnectorActionGatewayLifecycle(
|
|
13385
|
+
function installAttemptConnectorActionGatewayLifecycle(definitions2, registry, resolvedMcpConnectionIds, bindings, connectorActionPolicy, accountLabels, reviewReaders) {
|
|
13053
13386
|
const byModelName = /* @__PURE__ */ new Map();
|
|
13054
13387
|
for (const binding of bindings) {
|
|
13055
13388
|
if (byModelName.has(binding.modelName)) {
|
|
@@ -13057,7 +13390,7 @@ function installAttemptConnectorActionGatewayLifecycle(definitions, registry, re
|
|
|
13057
13390
|
}
|
|
13058
13391
|
byModelName.set(binding.modelName, binding);
|
|
13059
13392
|
}
|
|
13060
|
-
return
|
|
13393
|
+
return definitions2.map((definition) => {
|
|
13061
13394
|
const binding = byModelName.get(definition.modelName);
|
|
13062
13395
|
const config = registry.get(definition.identity.serverId);
|
|
13063
13396
|
const legacyMcpApproval = Boolean(config) && !config.connectionRef && definition.approval === "human";
|
|
@@ -13222,12 +13555,12 @@ async function prepareWorkspaceToolGatewayEnvironment(servers, registry, options
|
|
|
13222
13555
|
}
|
|
13223
13556
|
const prepared = await prepareToolGatewayDefinitionsFromServers(servers, registry);
|
|
13224
13557
|
const admittedDefinitions = options.workspaceToolGateway.filterDefinition ? prepared.definitions.filter(options.workspaceToolGateway.filterDefinition) : prepared.definitions;
|
|
13225
|
-
const
|
|
13558
|
+
const definitions2 = options.workspaceToolGateway.mapDefinition ? admittedDefinitions.map(options.workspaceToolGateway.mapDefinition) : admittedDefinitions;
|
|
13226
13559
|
return createWorkspaceToolGateway({
|
|
13227
13560
|
accountId: options.accountId,
|
|
13228
13561
|
workspaceId: options.workspaceId,
|
|
13229
13562
|
generation: options.workspaceToolGateway.generation ?? 1,
|
|
13230
|
-
definitions,
|
|
13563
|
+
definitions: definitions2,
|
|
13231
13564
|
...options.workspaceToolGateway.createdAt ? { createdAt: options.workspaceToolGateway.createdAt } : {},
|
|
13232
13565
|
...options.workspaceToolGateway.authorize ? { authorize: options.workspaceToolGateway.authorize } : {},
|
|
13233
13566
|
...options.workspaceToolGateway.resolveApproval ? { resolveApproval: options.workspaceToolGateway.resolveApproval } : {},
|
|
@@ -14546,16 +14879,16 @@ function logPublicMcpLifecycleFailure(error) {
|
|
|
14546
14879
|
});
|
|
14547
14880
|
}
|
|
14548
14881
|
var AttemptDefinitionMcpServer = class {
|
|
14549
|
-
constructor(
|
|
14882
|
+
constructor(definitions2, aggregateToolBudget, subjectId) {
|
|
14550
14883
|
this.aggregateToolBudget = aggregateToolBudget;
|
|
14551
14884
|
this.subjectId = subjectId;
|
|
14552
|
-
for (const definition of
|
|
14885
|
+
for (const definition of definitions2) {
|
|
14553
14886
|
this.catalogIdentities.set(definition.modelName, {
|
|
14554
14887
|
identity: definition.identity,
|
|
14555
14888
|
source: definition.source
|
|
14556
14889
|
});
|
|
14557
14890
|
}
|
|
14558
|
-
const descriptors =
|
|
14891
|
+
const descriptors = definitions2.map(
|
|
14559
14892
|
(definition) => ({
|
|
14560
14893
|
name: definition.modelName,
|
|
14561
14894
|
...definition.title ? { title: definition.title } : {},
|
|
@@ -16583,10 +16916,10 @@ var builtInSandboxLifecycleHooks = {
|
|
|
16583
16916
|
}
|
|
16584
16917
|
};
|
|
16585
16918
|
function sandboxLifecycleHooksForIds(ids) {
|
|
16586
|
-
const resolved = ids.map((
|
|
16587
|
-
const hook = builtInSandboxLifecycleHooks[
|
|
16919
|
+
const resolved = ids.map((id2) => {
|
|
16920
|
+
const hook = builtInSandboxLifecycleHooks[id2];
|
|
16588
16921
|
if (!hook) {
|
|
16589
|
-
throw new Error(`Unknown sandbox lifecycle hook ${
|
|
16922
|
+
throw new Error(`Unknown sandbox lifecycle hook ${id2}`);
|
|
16590
16923
|
}
|
|
16591
16924
|
return hook;
|
|
16592
16925
|
});
|
|
@@ -18592,6 +18925,8 @@ function sortJson(value) {
|
|
|
18592
18925
|
}
|
|
18593
18926
|
|
|
18594
18927
|
export {
|
|
18928
|
+
isOfficialDriveMcpConfig,
|
|
18929
|
+
mergeDriveMcpTools,
|
|
18595
18930
|
INTERACTION_ATTEMPT_TOOL_NAMES,
|
|
18596
18931
|
createInteractionAttemptToolDefinitions,
|
|
18597
18932
|
nativeCuaSchema,
|
|
@@ -18787,4 +19122,4 @@ export {
|
|
|
18787
19122
|
runAzureCliLoginHook,
|
|
18788
19123
|
renderSessionGoalContext2 as renderSessionGoalContext
|
|
18789
19124
|
};
|
|
18790
|
-
//# sourceMappingURL=chunk-
|
|
19125
|
+
//# sourceMappingURL=chunk-LOWZTPW3.js.map
|