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
10 changes: 10 additions & 0 deletions packages/chrome-extension/src/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
id: number;
method: string;
params: Record<string, unknown>;
_deadline?: number;
}

export interface BridgeResponse {
Expand Down Expand Up @@ -51,7 +52,7 @@
}

this.ws.onopen = () => {
console.log('[Markus] Connected to bridge');

Check warning on line 55 in packages/chrome-extension/src/protocol.ts

View workflow job for this annotation

GitHub Actions / check

Unexpected console statement. Only these console methods are allowed: warn, error
this._connected = true;
this.startKeepalive();
chrome.action.setIcon({ path: {
Expand All @@ -62,7 +63,7 @@
};

this.ws.onclose = () => {
console.log('[Markus] Disconnected from bridge');

Check warning on line 66 in packages/chrome-extension/src/protocol.ts

View workflow job for this annotation

GitHub Actions / check

Unexpected console statement. Only these console methods are allowed: warn, error
this._connected = false;
this.stopKeepalive();
chrome.action.setTitle({ title: 'Markus Browser Automation (Disconnected)' });
Expand All @@ -89,12 +90,21 @@
* when multiple agents issue concurrent tool calls.
*/
private enqueueRequest(req: BridgeRequest): void {
if (!req._deadline) {
req._deadline = Date.now() + 110_000;
}
this.requestQueue = this.requestQueue
.then(() => this.handleRequest(req))
.catch((err) => console.error('[Markus] Request queue error:', err));
}

private async handleRequest(req: BridgeRequest): Promise<void> {
if (req._deadline && Date.now() > req._deadline) {
console.warn(`[Markus] Skipping expired request ${req.method} (id=${req.id})`);
this.send({ id: req.id, error: `Request expired while queued (bridge timeout likely already fired)` });
return;
}

const handler = this.handlers.get(req.method);
if (!handler) {
this.send({ id: req.id, error: `Unknown method: ${req.method}` });
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/tools/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function createFileReadTool(security?: SecurityGuard, workspacePath?: str
},

async execute(args: Record<string, unknown>): Promise<string> {
const rawPath = (args['path'] ?? args['file_path'] ?? args['filePath']) as string | undefined;
const rawPath = (args['path'] ?? args['file'] ?? args['file_path'] ?? args['filePath']) as string | undefined;
if (!rawPath || typeof rawPath !== 'string') {
return JSON.stringify({ status: 'error', error: 'path is required and must be a non-empty string' });
}
Expand Down Expand Up @@ -145,7 +145,7 @@ export function createFileWriteTool(security?: SecurityGuard, workspacePath?: st
},

async execute(args: Record<string, unknown>): Promise<string> {
const rawPath = (args['path'] ?? args['file_path'] ?? args['filePath']) as string;
const rawPath = (args['path'] ?? args['file'] ?? args['file_path'] ?? args['filePath']) as string;
const { resolved: path, access } = resolveAndCheckAccess(rawPath, workspacePath, policy);

if (access === 'denied') {
Expand Down Expand Up @@ -187,7 +187,7 @@ export function createFileEditTool(security?: SecurityGuard, workspacePath?: str
},

async execute(args: Record<string, unknown>): Promise<string> {
const rawPath = (args['path'] ?? args['file_path'] ?? args['filePath']) as string;
const rawPath = (args['path'] ?? args['file'] ?? args['file_path'] ?? args['filePath']) as string;
const { resolved: path, access } = resolveAndCheckAccess(rawPath, workspacePath, policy);

if (access === 'denied') {
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/tools/markus-browser-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ export class MarkusBrowserBridge {
}

const id = ++this.requestId;
const message = JSON.stringify({ id, method: name, params: args });
const _deadline = Date.now() + TOOL_CALL_TIMEOUT_MS;
const message = JSON.stringify({ id, method: name, params: args, _deadline });

return new Promise<BridgeToolResult>((resolve, reject) => {
const timer = setTimeout(() => {
Expand Down
Loading