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
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { describe, expect, it } from "vitest";
import {
COMPUTER_USE_ONBOARDING_PREFIX,
SCREEN_CAPTURE_PREFIX,
isComputerUseOnboardingRequest,
isComputerUsePermissions,
isComputerUseProbeTarget,
isScreenCaptureMessage,
isScreenCaptureRequest,
isScreenCaptureResult,
} from "./index.js";

describe("computer-use local API exports", () => {
it("exports and validates the permission onboarding messages", () => {
expect(COMPUTER_USE_ONBOARDING_PREFIX).toBe("memmy:computer-use-onboarding:");
expect(isComputerUseOnboardingRequest({
type: `${COMPUTER_USE_ONBOARDING_PREFIX}prepare`,
requestId: "prepare-1",
})).toBe(true);
expect(isComputerUseOnboardingRequest({
type: `${COMPUTER_USE_ONBOARDING_PREFIX}guide`,
requestId: "guide-1",
reason: "accessibility",
helperApp: "/Applications/Open Computer Use.app",
canContinue: false,
})).toBe(true);
expect(isComputerUseOnboardingRequest({
type: `${COMPUTER_USE_ONBOARDING_PREFIX}guide`,
requestId: "guide-1",
reason: "accessibility",
helperApp: "/tmp/helper.app",
})).toBe(false);
expect(isComputerUseOnboardingRequest({
type: `${COMPUTER_USE_ONBOARDING_PREFIX}prepare`,
requestId: "prepare-1",
extra: true,
})).toBe(false);
});

it("bounds permission probe payloads and states", () => {
expect(isComputerUsePermissions({
accessibility: "granted",
screenRecording: "required",
failure: "helperPauseFailed",
})).toBe(true);
expect(isComputerUsePermissions({
accessibility: "granted",
screenRecording: "required",
unexpected: true,
})).toBe(false);
expect(isComputerUseProbeTarget({ app: "com.example.Helper", pid: 42 })).toBe(true);
expect(isComputerUseProbeTarget({ app: "/Applications/Helper.app", pid: 42 })).toBe(false);
expect(isComputerUseProbeTarget({ app: "com.example.Helper", pid: 0 })).toBe(false);
});

it("exports and validates screen capture requests and results", () => {
expect(SCREEN_CAPTURE_PREFIX).toBe("memmy:screen-capture:");
const request = {
type: `${SCREEN_CAPTURE_PREFIX}request`,
requestId: "capture-1",
displayId: "7",
};
expect(isScreenCaptureMessage(request)).toBe(true);
expect(isScreenCaptureRequest(request)).toBe(true);
expect(isScreenCaptureRequest({ ...request, displayId: "../../secret" })).toBe(false);
expect(isScreenCaptureRequest({ ...request, command: "open" })).toBe(false);

expect(isScreenCaptureResult({
ok: true,
pngBase64: "png",
displayId: "7",
bounds: { x: 0, y: 0, width: 1920, height: 1080 },
width: 1280,
height: 720,
})).toBe(true);
expect(isScreenCaptureResult({
ok: false,
code: "permission_required",
message: "Screen recording permission is required",
})).toBe(true);
expect(isScreenCaptureResult({
ok: false,
code: "permission_required",
message: "x".repeat(2001),
})).toBe(false);
});
});
2 changes: 2 additions & 0 deletions App/memmy-agent/src/core/agent-runtime/tools/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,12 @@ export abstract class Tool {
}

static enabled(ctx: any): boolean {
void ctx;
return true;
}

static create(ctx?: any): Tool {
void ctx;
return new (this as any)() as Tool;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class DesktopOnboardingClient {
};
const cancel = () => {
finish();
if (this.ipc.connected) { try { this.ipc.send!({ type: `${PREFIX}cancel`, requestId }, () => undefined); } catch {} }
if (this.ipc.connected) { try { this.ipc.send!({ type: `${PREFIX}cancel`, requestId }, () => undefined); } catch { /* Ignore cleanup send failures. */ } }
};
const receive = (reply: any) => {
if (reply?.type === `${PREFIX}guide:result` && reply.requestId === requestId) finish(reply.approved === true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ describe("AgentRunner tool execution", () => {
}

async execute(_params: Record<string, any> = {}, context?: ToolExecutionContext): Promise<string> {
void _params;
if (context) receivedContexts.push(context);
entered();
return await new Promise((resolve, reject) => {
Expand Down
6 changes: 5 additions & 1 deletion App/shell/desktop/tests/renderer-context-menu.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ describe("desktop renderer context menu", () => {
it("wires the native renderer context menu into both desktop windows", () => {
const source = readFileSync(mainSourcePath, "utf8");

expect(source).toContain("clipboard, dialog, ipcMain, Menu");
const electronImport = source.match(/import \{[^}]+\} from "electron";/su)?.[0] ?? "";
expect(electronImport).toContain("clipboard");
expect(electronImport).toContain("dialog");
expect(electronImport).toContain("ipcMain");
expect(electronImport).toContain("Menu");
expect(source).toContain('import { resolveRendererContextMenuCommands, resolveRendererContextMenuMaxLabelWidth, type RendererContextMenuCommand } from "./renderer-context-menu.js";');
expect(source).toContain("attachRendererContextMenu(targetMainWindow);");
expect(source).toContain("attachRendererContextMenu(petWindow);");
Expand Down
1 change: 1 addition & 0 deletions App/shell/desktop/tests/startup-lifecycle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ function setup(options: { delay?: number; error?: Error; apiError?: Error; clean
resolveCurrentDesktopEdition: () => "cn", initLogger: noop, forceLightWindowChrome: noop,
installPreparedRequiredUpdateBeforeBoot: async () => false,
registerIpcHandlers: noop, installBundledCliIfNeeded: async () => {}, startPackagedRendererServerIfNeeded: async () => {},
createDesktopScreenCapture: noop, createComputerUseOnboarding: noop,
windowsDataLayout: null,
startManagedRuntimeServices: async () => {
if (options.delay) await new Promise(resolve => setTimeout(resolve, options.delay));
Expand Down
Loading