Orkas is an open-source (MIT), local-first AI team for your desktop: a Commander turns your goal into to-dos and coordinates 16 built-in specialist agents plus Claude Code, Codex, OpenCode, OpenClaw and Hermes, with projects, scheduled automations and connectors. Free app for macOS & Windows; built-in models or your own keys.
JavaScript agent-collaborationagent-harnessagent-orchestrationagent-teamagent-workflowai-assistantai-automationai-employeeai-productivityai-teamai-workflowautonomous-agentsclaude-code-guiclaude-coworkdesktop-agentlocal-firstmulti-agentmulti-agent-systemself-evolving-agentstask-automation
Allow marketplace agent memory edits
wytf6975b81a26a
diff --git a/src/main/features/agents.ts b/src/main/features/agents.tsindex 02243a08..f7d1a150 100644--- a/src/main/features/agents.ts+++ b/src/main/features/agents.ts@@ -1324,6 +1324,27 @@ function _agentMemoryNotSupportedForExternalResult() {return _agentMemoryUnsupportedResult('agent memory is not supported for external CLI agents');}+async function _resolveAgentMemoryTarget(agentId: string): Promise<{+ source: AgentSource;+ file: string;+ data: AgentRaw;+} | null> {+ for (const source of ['marketplace', 'custom'] as AgentSource[]) {+ const file = isMarketplaceSource(source)+ ? _platformAgentSpecFile(agentId)+ : customAgentFile(agentId);+ if (!fs.existsSync(file)) continue;+ try {+ const data = await readJson<AgentRaw>(file);+ const norm = normalizeAgent(data, source);+ if (norm?.agent_id === agentId) return { source, file, data };+ } catch {+ /* try the next source */+ }+ }+ return null;+}+function _readAgentRuntimeStats(userId: string, agentId: string): AgentRuntimeStats | undefined {if (!safeId(agentId)) return undefined;try {@@ -1864,10 +1885,9 @@ export async function appendAgentSkill(agentId: string, skillId: string): Promisexport async function addCustomAgentMemory(agentId: string, content: string) {if (!agentId || !safeId(agentId)) return { ok: false, error: 'invalid agent_id', entries: [], usage: { current: 0, limit: 0 } };- const f = customAgentFile(agentId);- if (!fs.existsSync(f)) return { ok: false, error: 'agent not found or read-only', entries: [], usage: { current: 0, limit: 0 } };- const data = await readJson<AgentRaw>(f);- if (_normalizeRuntime(data.runtime)?.kind === 'cli') return _agentMemoryNotSupportedForExternalResult();+ const target = await _resolveAgentMemoryTarget(agentId);+ if (!target) return { ok: false, error: 'agent not found or read-only', entries: [], usage: { current: 0, limit: 0 } };+ if (_normalizeRuntime(target.data.runtime)?.kind === 'cli') return _agentMemoryNotSupportedForExternalResult();const res = addAgentEntry(getActiveUserId(), agentId, content);if (res.ok) _invalidateAgentListCache();return res;@@ -1875,17 +1895,18 @@ export async function addCustomAgentMemory(agentId: string, content: string) {export async function removeCustomAgentMemory(agentId: string, oldText: string) {if (!agentId || !safeId(agentId)) return { ok: false, error: 'invalid agent_id', entries: [], usage: { current: 0, limit: 0 } };- const f = customAgentFile(agentId);- if (!fs.existsSync(f)) return { ok: false, error: 'agent not found or read-only', entries: [], usage: { current: 0, limit: 0 } };- const data = await readJson<AgentRaw>(f);- if (_normalizeRuntime(data.runtime)?.kind === 'cli') return _agentMemoryNotSupportedForExternalResult();+ const target = await _resolveAgentMemoryTarget(agentId);+ if (!target) return { ok: false, error: 'agent not found or read-only', entries: [], usage: { current: 0, limit: 0 } };+ if (_normalizeRuntime(target.data.runtime)?.kind === 'cli') return _agentMemoryNotSupportedForExternalResult();const fileRes = removeAgentEntry(getActiveUserId(), agentId, oldText);if (fileRes.ok) {_invalidateAgentListCache();return fileRes;}+ if (target.source !== 'custom') return fileRes;+ const data = target.data;const profile = normalizeAgentProfile(data);const memory = profile?.memory || [];const needle = String(oldText || '').trim();@@ -1905,17 +1926,16 @@ export async function removeCustomAgentMemory(agentId: string, oldText: string)}bumpAgentSpecRevision(data);data.updated_at = nowIso();- await writeJson(f, data);+ await writeJson(target.file, data);_invalidateAgentListCache();return listAgentEntries(getActiveUserId(), agentId);}export async function updateCustomAgentMemory(agentId: string, oldText: string, content: string) {if (!agentId || !safeId(agentId)) return { ok: false, error: 'invalid agent_id', entries: [], usage: { current: 0, limit: 0 } };- const f = customAgentFile(agentId);- if (!fs.existsSync(f)) return { ok: false, error: 'agent not found or read-only', entries: [], usage: { current: 0, limit: 0 } };- const data = await readJson<AgentRaw>(f);- if (_normalizeRuntime(data.runtime)?.kind === 'cli') return _agentMemoryNotSupportedForExternalResult();+ const target = await _resolveAgentMemoryTarget(agentId);+ if (!target) return { ok: false, error: 'agent not found or read-only', entries: [], usage: { current: 0, limit: 0 } };+ if (_normalizeRuntime(target.data.runtime)?.kind === 'cli') return _agentMemoryNotSupportedForExternalResult();const res = replaceAgentEntry(getActiveUserId(), agentId, oldText, content);if (res.ok) _invalidateAgentListCache();return res;diff --git a/src/renderer/modules/agents.js b/src/renderer/modules/agents.jsindex dd7d411f..9691b3fc 100644--- a/src/renderer/modules/agents.js+++ b/src/renderer/modules/agents.js@@ -961,15 +961,12 @@ function _renderAgentRowMenuItems(menu, agentId, source = '') {const enabled = a ? a.enabled !== false : true;const isMock = _isAgentProfileMock(a || agentId);const isCustom = a?.source === 'custom' && !isMock;- // Dev mode lifts the source guard for marketplace edit / delete.- const canEdit = !isMock && (isCustom || (_isAgentPlatformSource(a?.source) && false));- // Dev-only entry on builtin: tag the label so the user knows this isn't a- // normal user capability (mirrors marketplace.upload's "(dev)" treatment).- const editLabelSuffix = (_isAgentPlatformSource(a?.source) && false) ? t('common.dev_suffix') : '';+ const canEditDefinition = !isMock && isCustom;+ const canEdit = canEditDefinition || _canEditAgentMemory(a);const toggleLabel = enabled ? t('component.disable') : t('component.enable');const items = [];if (canEdit) {- items.push(`<div class="agent-row-menu-item" data-action="edit">${escapeHtml(t('agents.edit') + editLabelSuffix)}</div>`);+ items.push(`<div class="agent-row-menu-item" data-action="edit">${escapeHtml(t('agents.edit'))}</div>`);}// Upload-to-marketplace is owned by marketplace_dev.js (renderer-side dev module). the open-source build// doesn't ship that file, so `typeof openMarketplaceUpload === 'function'` is false there@@ -979,7 +976,7 @@ function _renderAgentRowMenuItems(menu, agentId, source = '') {items.push(`<div class="agent-row-menu-item" data-action="upload-marketplace">${escapeHtml(t('marketplace.upload'))}</div>`);}if (!isMock) items.push(`<div class="agent-row-menu-item" data-action="toggle-enabled">${escapeHtml(toggleLabel)}</div>`);- if (canEdit) {+ if (canEditDefinition) {items.push(`<div class="agent-row-menu-item is-danger" data-action="delete">${escapeHtml(t('agents.delete'))}</div>`);}menu.innerHTML = items.join('');@@ -1251,7 +1248,19 @@ function _agentTextList(agent, key) {function _canEditAgentDefinition(agent) {const source = _agentSource(agent && agent.source);return !!agent && !_isAgentProfileMock(agent)- && (source === 'custom' || (_isAgentPlatformSource(source) && typeof isDevMode === 'function' && false));+ && source === 'custom';+}++function _canEditAgentMemory(agent) {+ const source = _agentSource(agent && agent.source);+ return !!agent+ && !_isAgentProfileMock(agent)+ && !_isExternalCliAgent(agent)+ && (_isCommanderAgent(agent) || source === 'custom' || _isAgentPlatformSource(source));+}++function _canEnterAgentEditMode(agent) {+ return _isCommanderAgent(agent) || _canEditAgentDefinition(agent) || _canEditAgentMemory(agent);}async function _saveAgentTextList(agent, key, values) {@@ -1432,8 +1441,7 @@ function _renderAgentDetailMemory(agent, editing = false) {.map((entry) => entry.title || entry.description).filter(Boolean).slice(0, 20);- const canEditMemory = !!editing && !_isAgentProfileMock(agent)- && (agent.source === 'custom' || _isCommanderAgent(agent));+ const canEditMemory = !!editing && _canEditAgentMemory(agent);section.style.display = (memoryTags.length || canEditMemory) ? '' : 'none';section.querySelector('[data-agent-memory-add]')?.remove();const title = section.querySelector('.agents-detail-label');@@ -1630,7 +1638,8 @@ function _renderAgentDetail(agent, editing) {const delBtn = document.getElementById('agent-delete-btn');const isMock = _isAgentProfileMock(agent);const isCustom = agent.source === 'custom' && !isMock;- const canEdit = isCommander || (!isMock && (isCustom || (_isAgentPlatformSource(agent.source) && false)));+ const canEditDefinition = !isMock && isCustom;+ const canEdit = isCommander || canEditDefinition || _canEditAgentMemory(agent);if (useBtn) {useBtn.style.display = editing ? 'none' : '';useBtn.disabled = isMock || agent.enabled === false;@@ -1655,17 +1664,13 @@ function _renderAgentDetail(agent, editing) {uploadBtn.disabled = isCommander || isMock;}if (delBtn) {- delBtn.style.display = (!isCommander && (canEdit || isMock) && !editing) ? '' : 'none';+ delBtn.style.display = (!isCommander && (canEditDefinition || isMock) && !editing) ? '' : 'none';delBtn.disabled = isCommander || isMock;}if (editBtn) {editBtn.style.display = (canEdit || isMock) ? '' : 'none';editBtn.disabled = isMock && !isCommander;- // Tag the "Edit" label on marketplace agents (dev-only entry); "Done" stays- // bare because the user is already in edit mode and the marker would be- // redundant noise.- const editSuffix = (!editing && _isAgentPlatformSource(agent.source) && false) ? t('common.dev_suffix') : '';- editBtn.textContent = editing ? t('agents.edit_btn_done') : (t('agents.edit_btn_edit') + editSuffix);+ editBtn.textContent = editing ? t('agents.edit_btn_done') : t('agents.edit_btn_edit');}if (!isMock && !isCommander) _renderAgentEnabledButton({ id: agent.agent_id, enabled: agent.enabled !== false });@@ -1721,8 +1726,7 @@ function _renderAgentOutputFormatSection(agent, editing = false) {return;}- const canEdit = !isMock && agent.source === 'custom'- || (_isAgentPlatformSource(agent.source) && typeof isDevMode === 'function' && false);+ const canEdit = !isMock && agent.source === 'custom';slot.innerHTML = '';const mount = document.createElement('div');@@ -1915,8 +1919,7 @@ async function _renderAgentDetailProjectDir(agent) {section.style.display = '';slot.dataset.agentId = agent.agent_id;- const canEdit = agent.source === 'custom'- || (_isAgentPlatformSource(agent.source) && typeof isDevMode === 'function' && false);+ const canEdit = agent.source === 'custom';const renderInfo = (info) => {if (_selectedAgent?.id !== agent.agent_id || slot.dataset.agentId !== agent.agent_id) return;@@ -2113,8 +2116,6 @@ function _toggleAgentFieldEditable(on) {async function toggleAgentEditMode() {if (!_selectedAgent) return;if (_isAgentProfileMock(_selectedAgent.id)) return;- // Marketplace editing is dev-only; lift the source guard accordingly.- if (!_isCommanderAgent(_selectedAgent.id) && _isAgentPlatformSource(_selectedAgent.source) && !false) return;if (_agentEditing) {await _exitAgentEditMode();} else {@@ -2133,18 +2134,26 @@ async function _enterAgentEditMode() {// Re-fetch to show raw workflow (not rendered markdown) for editing.const res = await apiFetch(`/api/agents/${encodeURIComponent(_selectedAgent.id)}`);const data = await res.json();- if (data.ok && data.agent) _renderAgentDetail(data.agent, true);- // External (cli-runtime) agents have no LLM-driven authoring — the- // CLI brings its own behaviour, and the edit chat would just sit- // empty. Hide the chat column so the user only sees the manual- // name + description editors. In-process agents keep the chat.- const isExternal = !!(data.ok && data.agent && data.agent.runtime?.kind === 'cli');+ const agent = data.ok && data.agent ? { ...data.agent, source: _agentSource(data.agent.source) } : null;+ if (!agent) {+ _agentEditing = false;+ return;+ }+ if (!_canEnterAgentEditMode(agent)) {+ _agentEditing = false;+ return;+ }+ _renderAgentDetail(agent, true);+ // External agents have no LLM-driven authoring. Marketplace installs in+ // the open-source build are memory-only edits. Both hide the edit chat.+ const isExternal = !!(agent.runtime?.kind === 'cli');+ const isMemoryOnly = !_canEditAgentDefinition(agent) && _canEditAgentMemory(agent);const chatCol = document.getElementById('agents-chat-col');- if (chatCol) chatCol.style.display = isExternal ? 'none' : '';- if (!isExternal) {+ if (chatCol) chatCol.style.display = (isExternal || isMemoryOnly) ? 'none' : '';+ if (!isExternal && !isMemoryOnly) {await _loadAgentChatHistory(_selectedAgent.id);setTimeout(() => document.getElementById('agents-chat-input')?.focus(), 50);- } else {+ } else if (isExternal) {setTimeout(() => document.getElementById('agents-detail-name-input')?.focus(), 50);}// Wire field blur-save (one-time attach)@@ -2207,7 +2216,7 @@ function _restoreAgentNameField() {function _scheduleAgentFieldSave(field, value) {if (!_selectedAgent) return;- if (_isAgentPlatformSource(_selectedAgent.source) && !false) return;+ if (_isAgentPlatformSource(_selectedAgent.source)) return;_pendingAgentField = { field, value };clearTimeout(_agentFieldSaveTimer);_agentFieldSaveTimer = setTimeout(_flushAgentFieldSave, 800);diff --git a/test/main/features/agents.test.ts b/test/main/features/agents.test.tsindex dd758a6a..6f779ace 100644--- a/test/main/features/agents.test.ts+++ b/test/main/features/agents.test.ts@@ -70,6 +70,22 @@ function writeCustomAgent(agentId: string, fields: Partial<Record<string, any>>fs.writeFileSync(path.join(dir, 'agent.json'), JSON.stringify(data));}+function writePlatformAgent(agentId: string, fields: Partial<Record<string, any>> = {}): void {+ const dir = path.join(builtinAgentsDir(), agentId);+ fs.mkdirSync(dir, { recursive: true });+ const data: Record<string, any> = {+ agent_id: agentId,+ name: fields.name ?? agentId,+ description: fields.description ?? 'Platform agent',+ category: fields.category ?? 'general',+ workflow: fields.workflow ?? '',+ created_at: '2026-04-18T10:00:00',+ updated_at: '2026-04-18T10:00:00',+ };+ if ('runtime' in fields) data.runtime = fields.runtime;+ fs.writeFileSync(path.join(dir, 'agent.json'), JSON.stringify(data));+}+function customSkillsDir(): string {return path.join(tmpDir, TEST_UID, 'cloud', 'skills');}@@ -1423,6 +1439,32 @@ describe('agents › custom agent memory', () => {expect(fs.readFileSync(canonicalMemoryFile, 'utf8')).toContain('new delivery preference');});+ it('lets platform-installed agents edit user memory without mutating the installed spec', async () => {+ writePlatformAgent('platform-agent', { name: 'PlatformAgent' });+ const specFile = path.join(builtinAgentsDir(), 'platform-agent', 'agent.json');+ const beforeSpec = fs.readFileSync(specFile, 'utf8');+ const a = await loadAgents();++ const added = await a.addCustomAgentMemory('platform-agent', 'old platform preference');+ expect(added.ok).toBe(true);+ const canonicalMemoryFile = path.join(tmpDir, TEST_UID, 'cloud', 'memory', 'agents', 'platform-agent', 'MEMORY.md');+ expect(fs.readFileSync(canonicalMemoryFile, 'utf8')).toContain('old platform preference');+ expect(fs.readFileSync(specFile, 'utf8')).toBe(beforeSpec);++ const updated = await a.updateCustomAgentMemory('platform-agent', 'old platform preference', 'new platform preference');+ expect(updated.ok).toBe(true);+ expect(updated.entries).toEqual(['new platform preference']);++ const reread = await a.getAgent('platform-agent');+ expect(reread?.source).toBe('marketplace');+ expect(reread?.profile?.memory?.map((entry) => entry.title)).toEqual(['new platform preference']);++ const removed = await a.removeCustomAgentMemory('platform-agent', 'new platform preference');+ expect(removed.ok).toBe(true);+ expect(removed.entries).toEqual([]);+ expect(fs.readFileSync(specFile, 'utf8')).toBe(beforeSpec);+ });+it('does not expose or mutate detail memory for external CLI agents', async () => {writeCustomAgent('cli-agent', {name: 'CliAgent',@@ -1441,6 +1483,20 @@ describe('agents › custom agent memory', () => {expect(added.error).toContain('external CLI');expect(fs.readFileSync(memoryFile, 'utf8')).toBe('existing external memory');});++ it('does not add memory for platform-installed external CLI agents', async () => {+ writePlatformAgent('platform-cli', {+ name: 'PlatformCli',+ runtime: { kind: 'cli', cli: 'codex' },+ });+ const a = await loadAgents();++ const added = await a.addCustomAgentMemory('platform-cli', 'new external memory');+ expect(added.ok).toBe(false);+ expect(added.error).toContain('external CLI');+ const canonicalMemoryFile = path.join(tmpDir, TEST_UID, 'cloud', 'memory', 'agents', 'platform-cli', 'MEMORY.md');+ expect(fs.existsSync(canonicalMemoryFile)).toBe(false);+ });});describe('agents › streamSendToAgentEditChat synthesized progress', () => {diff --git a/test/renderer/category-tabs.test.ts b/test/renderer/category-tabs.test.tsindex 3d72226e..da3b031d 100644--- a/test/renderer/category-tabs.test.ts+++ b/test/renderer/category-tabs.test.ts@@ -17,12 +17,18 @@ class FakeClassList {class FakeElement {innerHTML = '';+ id = '';+ className = '';+ dataset: Record<string, string> = {};style: Record<string, string> = {};classList = new FakeClassList();focused = false;querySelectorAll() { return []; }+ querySelector() { return null; }addEventListener() {}+ appendChild() {}focus() { this.focused = true; }+ getBoundingClientRect() { return { left: 0, right: 120, top: 0, bottom: 32, width: 120, height: 32 }; }}function loadCategoryRenderers() {@@ -35,8 +41,17 @@ function loadCategoryRenderers() {console,setTimeout,createLogger: () => ({ warn: () => {}, error: () => {}, info: () => {} }),- document: { getElementById: (id: string) => el(id), querySelectorAll: () => [] },- window: { addEventListener: () => {}, orkas: { invoke: async () => ({ list: [] }) } },+ document: {+ getElementById: (id: string) => el(id),+ createElement: (tag: string) => {+ const node = new FakeElement();+ node.dataset.tag = tag;+ return node;+ },+ body: { appendChild: () => {} },+ querySelectorAll: () => [],+ },+ window: { addEventListener: () => {}, innerWidth: 1024, innerHeight: 768, orkas: { invoke: async () => ({ list: [] }) } },escapeHtml: (s: unknown) => String(s ?? '').replace(/[&<>"']/g, (ch) => ({'&': '&', '<': '<', '>': '>', '"': '"', "'": ''',} as Record<string, string>)[ch]),@@ -249,6 +264,92 @@ describe('agent and skill category tabs', () => {expect(el('skills-grid').innerHTML).not.toContain('reviewing');});+ it('shows memory-only edit for marketplace agents outside dev mode', () => {+ const { context } = loadCategoryRenderers();+ context.isDevMode = () => false;+ vm.runInContext(`+ _agentsCache = [{+ agent_id: 'platform-agent',+ name: 'Platform Agent',+ source: 'marketplace',+ category: 'general',+ enabled: true+ }];+ `, context);++ const menu: any = {+ innerHTML: '',+ dataset: {},+ querySelectorAll: () => [],+ };+ context._renderAgentRowMenuItems(menu, 'platform-agent', 'marketplace');++ expect(context._canEditAgentDefinition({ source: 'marketplace' })).toBe(false);+ expect(context._canEditAgentMemory({ source: 'marketplace' })).toBe(true);+ expect(context._canEditAgentMemory({ source: 'marketplace', runtime: { kind: 'cli', cli: 'codex' } })).toBe(false);+ expect(menu.innerHTML).toContain('data-action="edit"');+ expect(menu.innerHTML).not.toContain('data-action="delete"');+ });++ it('keeps marketplace agents memory-editable but definition-locked in dev mode', () => {+ const { context } = loadCategoryRenderers();+ context.isDevMode = () => true;+ vm.runInContext(`+ _agentsCache = [{+ agent_id: 'platform-agent',+ name: 'Platform Agent',+ source: 'marketplace',+ category: 'general',+ enabled: true+ }];+ `, context);++ const menu: any = {+ innerHTML: '',+ dataset: {},+ querySelectorAll: () => [],+ };+ context._renderAgentRowMenuItems(menu, 'platform-agent', 'marketplace');++ expect(context._canEditAgentDefinition({ source: 'marketplace' })).toBe(false);+ expect(context._canEditAgentMemory({ source: 'marketplace' })).toBe(true);+ expect(menu.innerHTML).toContain('data-action="edit"');+ expect(menu.innerHTML).not.toContain('data-action="delete"');+ });++ it('keeps marketplace skills definition-locked even in dev mode', () => {+ const { context, el } = loadCategoryRenderers();+ const anchor = {+ getBoundingClientRect: () => ({ left: 0, right: 120, top: 0, bottom: 32, width: 120, height: 32 }),+ closest: () => ({ classList: new FakeClassList() }),+ };+ vm.runInContext(`+ _skillsCache = [{+ id: 'platform-skill-dev',+ name: 'Platform Skill Dev',+ source: 'marketplace',+ category: 'general',+ enabled: true+ }, {+ id: 'platform-skill-prod',+ name: 'Platform Skill Prod',+ source: 'marketplace',+ category: 'general',+ enabled: true+ }];+ `, context);++ context.isDevMode = () => true;+ context._openSkillRowMenu(anchor, 'platform-skill-dev', 'marketplace');+ expect(el('skill-row-menu').innerHTML).not.toContain('data-action="edit"');+ expect(el('skill-row-menu').innerHTML).not.toContain('data-action="delete"');++ context.isDevMode = () => false;+ context._openSkillRowMenu(anchor, 'platform-skill-prod', 'marketplace');+ expect(el('skill-row-menu').innerHTML).not.toContain('data-action="edit"');+ expect(el('skill-row-menu').innerHTML).not.toContain('data-action="delete"');+ });+it('uses friendly external package display names while keeping the package key internal', () => {const { context, el } = loadCategoryRenderers();vm.runInContext(`