Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.
Merge pull request #299 from nosliwhtes/feat/isolated-browser-workflows
Salman Qureshi3da9380a31d0
diff --cc src/capabilities/permission-context.tsindex 0d38a814,930d1053..ae685d93--- a/src/capabilities/permission-context.ts+++ b/src/capabilities/permission-context.ts@@@ -27,8 -27,8 +27,10 @@@ export interface ContextScopeexport interface PermissionContext {readonly channelType: string;readonly channelId: string;+ /** External event turns neither consume nor create remembered conversation approvals. */+ readonly rememberApprovals: boolean;+ /** Canonical repository session, supplied by the agent, never tool arguments. */+ readonly sessionId?: string;readonly senderRole: 'admin' | 'member' | undefined;/** Allow-all: approved-scope actions and non-blocked commands run without prompts. */readonly autoApprove: boolean;@@@ -54,8 -54,8 +56,9 @@@ export function makeContext(fields: Parreturn Object.freeze({channelType: fields.channelType ?? 'cli',channelId: fields.channelId ?? 'cli',+ ...(fields.sessionId ? { sessionId: fields.sessionId } : {}),senderRole: fields.senderRole,+ rememberApprovals: fields.rememberApprovals ?? true,autoApprove: fields.autoApprove ?? false,autoApproveOrigin: fields.autoApprove ? (fields.autoApproveOrigin ?? 'session') : null,allowedTools: fields.allowedTools ? Object.freeze([...fields.allowedTools]) : undefined,diff --cc src/capabilities/registry.tsindex c17fd97d,73ced266..155b07c1--- a/src/capabilities/registry.ts+++ b/src/capabilities/registry.ts@@@ -264,19 -222,23 +267,23 @@@ export class CapabilityRegistryregisterAll(): void {const manifest = this.permissions.getManifest();+ if (manifest.capabilities.browser?.enabled && !this.permissions.isFailClosed()) {+ this.browser ??= new IsolatedBrowserReader({ executable: manifest.capabilities.browser.executable });+ }+if (manifest.capabilities.filesystem.enabled) {- this.tools.read_file = createReadFileTool(this.permissions, () => this.getCwd());- this.tools.write_file = createWriteFileTool(this.permissions, () => this.getCwd());- this.tools.create_file = createCreateFileTool(this.permissions, () => this.getCwd());- this.tools.list_dir = createListDirTool(this.permissions, () => this.getCwd());- this.tools.delete_file = createDeleteFileTool(this.permissions, () => this.getCwd());- this.tools.edit_file = createEditFileTool(this.permissions, () => this.getCwd());+ this.tools.read_file = createReadFileTool(this.permissions, this.cwdSource);+ this.tools.write_file = createWriteFileTool(this.permissions, this.cwdSource);+ this.tools.create_file = createCreateFileTool(this.permissions, this.cwdSource);+ this.tools.list_dir = createListDirTool(this.permissions, this.cwdSource);+ this.tools.delete_file = createDeleteFileTool(this.permissions, this.cwdSource);+ this.tools.edit_file = createEditFileTool(this.permissions, this.cwdSource);if (this.sendFileHandler) {- this.tools.send_file = createSendFileTool(this.permissions, () => this.getCwd(), this.sendFileHandler);+ this.tools.send_file = createSendFileTool(this.permissions, this.cwdSource, this.sendFileHandler);}- this.tools.approve_scope = createApproveScopeTool(this.permissions, () => this.getCwd());+ this.tools.approve_scope = createApproveScopeTool(this.permissions, this.cwdSource);logger.info('Filesystem tools registered');}diff --cc src/core/agent.tsindex 17e24cd8,8a471378..0a283292--- a/src/core/agent.ts+++ b/src/core/agent.ts@@@ -3121,11 -3111,6 +3121,11 @@@ export class Agent}}+ // Set this turn's caller before exposing tools or routing a skill. A+ // previous local/owner turn must not determine remote recall access.- this.capabilities.setChannelContext(msg.channelId, msg.channelType);++ this.capabilities.setChannelContext(msg.channelId, msg.channelType, canonicalSession.id);+ this.capabilities.permissions.setCurrentSenderRole(msg.senderRole);+let systemPrompt = this.buildSystemPrompt();if (chatFolder) systemPrompt += `\n- Files you make go in the working directory (this chat's folder in the owner's Mercury artifacts folder), unless the owner names another place. Use relative paths or that folder; never write loose files into the home folder.`;if (msg.metadata?.workContinuation === true) {