Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@modelcontextprotocol/core": "2.0.0",
"@modelcontextprotocol/server": "2.0.0",
"@onkernel/managed-auth-react": "0.5.5",
"@onkernel/sdk": "0.126.0",
"@onkernel/sdk": "0.132.0",
"@posthog/mcp": "0.17.0",
"@types/jsonwebtoken": "^9.0.10",
"@types/redis": "^4.0.11",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/mcp/apps/managed-auth-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type SafeConnection = {
| null;
flow_type: "LOGIN" | "REAUTH" | null;
flow_expires_at: string | null;
region?: "us-east" | "eu-west" | "ap-southeast";
region?: "us-east" | "us-west" | "eu-west" | "ap-southeast";
error_code: string | null;
};

Expand Down
18 changes: 18 additions & 0 deletions src/lib/mcp/browser-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,21 @@ test("browser update config forwards a start URL", () => {
value: { start_url: "https://example.com/checkout" },
});
});

test("browser create config forwards multiple extensions and rejects aliases", () => {
const extensions = [{ id: "ext_1" }, { name: "second-extension" }];
expect(buildBrowserCreateConfig({ extensions })).toEqual({
ok: true,
value: { extensions },
});
expect(
buildBrowserCreateConfig({
extensions,
extension_name: "legacy-extension",
}),
).toEqual({
ok: false,
error:
"error: extensions cannot be combined with extension_id or extension_name.",
});
});
23 changes: 23 additions & 0 deletions src/lib/mcp/browser-config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { z } from "zod";
import type { KernelClient } from "@/lib/mcp/kernel-client";

type BrowserCreateParams = NonNullable<
Expand All @@ -17,7 +18,20 @@ export type BrowserProfileParams = {
save_profile_changes?: boolean;
};

export const browserExtensionSchema = z
.object({
id: z.string().min(1).optional(),
name: z.string().min(1).optional(),
})
.strict()
.refine((extension) => Boolean(extension.id) !== Boolean(extension.name), {
message: "each extension requires exactly one of id or name.",
});

export const browserExtensionsSchema = z.array(browserExtensionSchema);

export type BrowserExtensionParams = {
extensions?: z.infer<typeof browserExtensionsSchema>;
extension_id?: string;
extension_name?: string;
};
Expand Down Expand Up @@ -137,9 +151,18 @@ function buildBrowserProfile(
function buildBrowserExtensions(
params: BrowserExtensionParams,
): BrowserConfigResult<BrowserExtensionConfig | undefined> {
if (
params.extensions !== undefined &&
(params.extension_id || params.extension_name)
) {
return configError(
"extensions cannot be combined with extension_id or extension_name.",
);
}
if (params.extension_id && params.extension_name) {
return configError("cannot specify both extension_id and extension_name.");
}
if (params.extensions !== undefined) return configValue(params.extensions);
if (!params.extension_id && !params.extension_name)
return configValue(undefined);
return configValue([
Expand Down
1 change: 1 addition & 0 deletions src/lib/mcp/prompts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const API_FIELD_NAMES = new Set([
"manage_browsers:stealth",
"manage_browsers:captcha",
"manage_browser_pools:stealth",
"manage_browser_pools:captcha",
"manage_auth_connections:browser_stealth",
"manage_auth_connections:stealth",
"open_auth_login:stealth",
Expand Down
3 changes: 2 additions & 1 deletion src/lib/mcp/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ export const telemetryEventCategories = [
"page",
"interaction",
"control",
"platform",
"connection",
"system",
"screenshot",
"captcha",
"monitor",
] as const;

export const TELEMETRY_EVENT_CATALOG = `event categories: console (console output and uncaught exceptions), network (request/response metadata), page (navigation and lifecycle), interaction (clicks, keys, scrolls), control (agent-driven api calls), connection (cdp/live-view attach/detach), system (vm health), screenshot (periodic monitor screenshots), captcha (verification prompts a site displayed during the session), monitor (telemetry collector health; captured automatically with any cdp category). high-signal event types: console_error, network_loading_failed, network_response with non-2xx status, system_oom_kill, service_crashed, monitor_disconnected (telemetry gap — treat following events as incomplete).`;
export const TELEMETRY_EVENT_CATALOG = `event categories: console (console output and uncaught exceptions), network (request/response metadata), page (navigation and lifecycle), interaction (clicks, keys, scrolls), control (agent-driven api calls), platform (KERNEL platform lifecycle and service events), connection (cdp/live-view attach/detach), system (vm health), screenshot (periodic monitor screenshots), captcha (verification prompts a site displayed during the session), monitor (telemetry collector health; captured automatically with any cdp category). high-signal event types: console_error, network_loading_failed, network_response with non-2xx status, system_oom_kill, service_crashed, monitor_disconnected (telemetry gap — treat following events as incomplete).`;
Loading
Loading