Where agent teams gather. Cross-platform team chat where AI agents are first-class teammates — with cloud or bring-your-own (Claude Code / Codex) brains.
TypeScript
feat(byoa): add Maka ACP persistent-session engine adapter (#338)
El Zhang60fb5b3e489c
diff --git a/scripts/guard-big-brain.mjs b/scripts/guard-big-brain.mjsindex 8a3bbb5..607100b 100644--- a/scripts/guard-big-brain.mjs+++ b/scripts/guard-big-brain.mjs@@ -80,7 +80,7 @@ export function lineViolations(rel, raw) {out.push('big-brain engine spawn (adapter.run) outside the gated daemon path')}// R4 — a supported engine binary spawned directly, outside the adapter.- if (/(?:spawn|execFile\w*|exec)\s*\(\s*['"`](claude|codex|grok|cursor-agent|opencode|pi|gemini|qwen|agy|zcode)['"`]/.test(code) && !ALLOW.engineSpawn.includes(rel)) {+ if (/(?:spawn|execFile\w*|exec)\s*\(\s*['"`](claude|codex|grok|cursor-agent|opencode|pi|gemini|qwen|agy|zcode|maka)['"`]/.test(code) && !ALLOW.engineSpawn.includes(rel)) {out.push('engine binary spawned outside the engine adapter (bypasses the classify=small / run=big split)')}return outdiff --git a/server/src/__tests__/agents-computer-daemon-auth-hint.test.ts b/server/src/__tests__/agents-computer-daemon-auth-hint.test.tsindex d46ecb8..0c05cad 100644--- a/server/src/__tests__/agents-computer-daemon-auth-hint.test.ts+++ b/server/src/__tests__/agents-computer-daemon-auth-hint.test.ts@@ -24,6 +24,8 @@ test('authFailureHint correctly mentions the relevant CLI/tool for each engine',assert.match(authFailureHint('gemini', 'quota exceeded'), /gemini/)assert.match(authFailureHint('qwen', 'quota exceeded'), /qwen/)assert.match(authFailureHint('antigravity', 'quota exceeded'), /agy/)+ assert.match(authFailureHint('zcode', 'quota exceeded'), /zcode/)+ assert.match(authFailureHint('maka', 'quota exceeded'), /maka/)})test('Codex authentication guidance signs in to the isolated runtime', () => {diff --git a/server/src/__tests__/agents-computer-engine-maka.test.ts b/server/src/__tests__/agents-computer-engine-maka.test.tsnew file mode 100644index 0000000..3a9c618--- /dev/null+++ b/server/src/__tests__/agents-computer-engine-maka.test.ts@@ -0,0 +1,592 @@+/** Contract tests for the BYOA Maka (`maka --acp`) ACP adapter. */+import assert from 'node:assert/strict'+import { chmod, mkdir, mkdtemp, readFile, rm, stat, writeFile } from 'node:fs/promises'+import { tmpdir } from 'node:os'+import { join } from 'node:path'+import { afterEach, test } from 'node:test'+import { getAdapter, resolveMakaBin, type EngineHopReport } from '../agents/computer/engine.js'++const tempDirs: string[] = []+const liveSessions: Array<{ stop(): void | Promise<void> }> = []++const FAKE_MAKA_ACP_SOURCE = String.raw`+import { appendFileSync } from 'node:fs'+import { createInterface } from 'node:readline'++const logFile = process.env.FAKE_MAKA_LOG+const mode = process.env.FAKE_MAKA_MODE || 'ok'+const argv = process.argv.slice(2)+if (argv.length !== 1 || argv[0] !== '--acp') {+ process.stderr.write('maka --acp does not accept extra arguments\n')+ process.exit(2)+}++let prompts = 0+let permissionReply = null+let pendingPrompt = null+const send = (obj) => process.stdout.write(JSON.stringify(obj) + '\n')+const record = (entry) => {+ if (logFile) appendFileSync(logFile, JSON.stringify(entry) + '\n')+}+const finishPrompt = (id, sid) => {+ send({+ jsonrpc: '2.0',+ method: 'session/update',+ params: { sessionId: sid, update: { sessionUpdate: 'tool_call', toolCallId: 'tc-1', title: 'Read README.md' } },+ })+ send({+ jsonrpc: '2.0',+ method: 'session/update',+ params: {+ sessionId: sid,+ update: { sessionUpdate: 'agent_message_chunk', content: { type: 'text', text: 'pong #' + prompts } },+ },+ })+ send({+ jsonrpc: '2.0',+ id,+ result: mode === 'with-usage'+ ? {+ stopReason: 'end_turn',+ usage: { inputTokens: 110, cachedReadTokens: 30, cachedWriteTokens: 10, outputTokens: 15 },+ }+ : {+ stopReason: 'end_turn',+ },+ })+}++const rl = createInterface({ input: process.stdin })+rl.on('line', (line) => {+ const msg = JSON.parse(line)+ record(msg)+ if (msg.id !== undefined && !msg.method) {+ permissionReply = msg.result+ if (pendingPrompt) {+ const { id, sid } = pendingPrompt+ pendingPrompt = null+ finishPrompt(id, sid)+ }+ return+ }+ if (msg.method === 'initialize') {+ send({ jsonrpc: '2.0', id: msg.id, result: { protocolVersion: 1, agentCapabilities: { loadSession: true } } })+ } else if (msg.method === 'session/new') {+ send({ jsonrpc: '2.0', id: msg.id, result: { sessionId: 'maka-sess-fresh', configOptions: [] } })+ } else if (msg.method === 'session/resume' || msg.method === 'session/load') {+ if (mode === 'fail-load') {+ send({ jsonrpc: '2.0', id: msg.id, error: { code: -32603, message: 'Runtime Host Session was not found.' } })+ } else {+ if (mode === 'replay-on-load') {+ send({+ jsonrpc: '2.0',+ method: 'session/update',+ params: {+ sessionId: msg.params.sessionId,+ update: { sessionUpdate: 'agent_message_chunk', content: { type: 'text', text: 'STALE_REPLAY_TEXT ' } },+ },+ })+ }+ send({ jsonrpc: '2.0', id: msg.id, result: { sessionId: msg.params.sessionId, configOptions: [] } })+ }+ } else if (msg.method === 'session/set_config_option') {+ if (msg.params?.configId !== 'permission_mode' || !['ask', 'bypass'].includes(msg.params?.value)) {+ send({ jsonrpc: '2.0', id: msg.id, error: { code: -32602, message: 'Invalid params: Invalid Session configuration option' } })+ } else {+ send({ jsonrpc: '2.0', id: msg.id, result: { configOptions: [] } })+ }+ } else if (msg.method === 'session/prompt') {+ prompts += 1+ if (mode === 'session-gone-after-first' && prompts >= 2) {+ // The turn began without a resume, so the resumed flag is already false.+ send({ jsonrpc: '2.0', id: msg.id, error: { code: -32603, message: 'Session is not owned by this ACP connection' } })+ return+ }+ if (mode === 'die-mid-turn') {+ process.exit(17)+ }+ if (mode === 'session-gone') {+ send({ jsonrpc: '2.0', id: msg.id, error: { code: -32603, message: 'Session is not owned by this ACP connection' } })+ return+ }+ if (mode === 'cwd-mismatch') {+ send({ jsonrpc: '2.0', id: msg.id, error: { code: -32602, message: 'cwd does not match the existing session workspace' } })+ return+ }+ if (mode === 'cancelled') {+ send({+ jsonrpc: '2.0',+ id: msg.id,+ result: { stopReason: 'cancelled' },+ })+ return+ }+ if (mode === 'ask-permission') {+ pendingPrompt = { id: msg.id, sid: msg.params.sessionId }+ // Deliberately reuse the pending prompt's own id: a server->client request+ // must be routed by method, never by id, or it would be delivered as the+ // prompt's response.+ send({+ jsonrpc: '2.0',+ id: msg.id,+ method: 'session/request_permission',+ params: {+ sessionId: msg.params.sessionId,+ toolCall: { toolCallId: 'tc-perm', title: 'Write file' },+ options: [+ { optionId: '550e8400-e29b-41d4-a716-446655440001', name: 'Allow once', kind: 'allow_once' },+ { optionId: '550e8400-e29b-41d4-a716-446655440002', name: 'Always allow', kind: 'allow_always' },+ { optionId: '550e8400-e29b-41d4-a716-446655440003', name: 'Reject', kind: 'reject_once' },+ ],+ },+ })+ return+ }+ if (mode === 'ask-permission-reject-only') {+ pendingPrompt = { id: msg.id, sid: msg.params.sessionId }+ send({+ jsonrpc: '2.0',+ id: msg.id,+ method: 'session/request_permission',+ params: {+ sessionId: msg.params.sessionId,+ toolCall: { toolCallId: 'tc-perm', title: 'Write file' },+ options: [+ { optionId: '550e8400-e29b-41d4-a716-446655440003', name: 'Reject', kind: 'reject_once' },+ ],+ },+ })+ return+ }+ const sid = msg.params.sessionId+ if (mode === 'split-utf8') {+ const updateFrame = Buffer.from(+ JSON.stringify({+ jsonrpc: '2.0',+ method: 'session/update',+ params: {+ sessionId: sid,+ update: { sessionUpdate: 'agent_message_chunk', content: { type: 'text', text: '你好世界' } },+ },+ }) + '\n',+ 'utf8',+ )+ // '你' in UTF-8 is 0xe4 0xbd 0xa0 — split right after the first byte (0xe4)+ const splitIndex = updateFrame.indexOf(0xe4) + 1+ process.stdout.write(updateFrame.subarray(0, splitIndex))+ setTimeout(() => {+ process.stdout.write(updateFrame.subarray(splitIndex))+ send({+ jsonrpc: '2.0',+ id: msg.id,+ result: { stopReason: 'end_turn' },+ })+ }, 15)+ return+ }+ finishPrompt(msg.id, sid)+ }+})+`++async function makeFixture(mode = 'ok'): Promise<{+ home: string+ env: NodeJS.ProcessEnv+ readCalls: () => Promise<Array<{ id?: number; method?: string; params?: Record<string, unknown>; result?: Record<string, unknown> }>>+}> {+ const root = await mkdtemp(join(tmpdir(), 'cumora-maka-'))+ tempDirs.push(root)+ const home = join(root, 'home')+ await mkdir(home, { recursive: true })+ const bridge = join(root, 'fake-maka.mjs')+ const logFile = join(root, 'calls.jsonl')+ await writeFile(bridge, FAKE_MAKA_ACP_SOURCE, 'utf8')+ return {+ home,+ env: {+ ...process.env,+ CUMORA_MAKA_BIN: bridge,+ FAKE_MAKA_LOG: logFile,+ FAKE_MAKA_MODE: mode,+ },+ readCalls: async () => {+ const raw = await readFile(logFile, 'utf8').catch(() => '')+ return raw.trim().split('\n').filter(Boolean).map((l) => JSON.parse(l))+ },+ }+}++afterEach(async () => {+ for (const s of liveSessions.splice(0)) {+ try { await s.stop() } catch { /* already gone */ }+ }+ await Promise.all(tempDirs.splice(0).map((d) => rm(d, { recursive: true, force: true })))+})++test('maka persistent session pins permission_mode=bypass once across wakes and ignores model pin', async () => {+ const f = await makeFixture()+ const logs: string[] = []+ const hops: EngineHopReport[] = []+ const session = getAdapter('maka').startSession?.({+ home: f.home,+ env: f.env,+ model: 'claude-sonnet-4-6',+ standingPrompt: null,+ resumeSessionId: null,+ onLog: (l) => logs.push(l),+ onHopUsage: (h) => hops.push(h),+ })+ assert.ok(session)+ liveSessions.push(session)++ const r1 = await session.send('first wake')+ const r2 = await session.send('second wake')++ assert.equal(r1.exitCode, 0)+ assert.equal(r2.exitCode, 0)+ assert.equal(r1.sessionId, 'maka-sess-fresh')+ assert.equal(r2.sessionId, 'maka-sess-fresh')+ assert.equal(r1.model, '<maka-default>')+ assert.equal(r1.usage, undefined)+ assert.equal(hops.length, 2)+ assert.equal(hops[0]?.model, '<maka-default>')+ assert.equal(hops[0]?.usage, undefined)+ assert.equal(+ logs.filter((l) => l.includes('[maka] model pin (claude-sonnet-4-6) is ignored')).length,+ 1,+ )+ assert.ok(logs.some((l) => l.includes('[maka] tool Read README.md')))+ assert.ok(logs.some((l) => l.includes('pong #1')))+ assert.ok(logs.some((l) => l.includes('pong #2')))++ const calls = await f.readCalls()+ assert.deepEqual(+ calls.map((c) => c.method),+ [+ 'initialize',+ 'session/new',+ 'session/set_config_option',+ 'session/prompt',+ 'session/prompt',+ ],+ )+ assert.deepEqual(calls[2]?.params, {+ sessionId: 'maka-sess-fresh',+ configId: 'permission_mode',+ value: 'bypass',+ })+ assert.equal(+ calls.some((c) => c.method === 'session/set_config_option' && c.params?.configId === 'model'),+ false,+ )+})++test('maka uses session/resume when resumeSessionId is supplied and ignores non-turn session/update notifications', async () => {+ const f = await makeFixture('replay-on-load')+ const logs: string[] = []+ const session = getAdapter('maka').startSession?.({+ home: f.home,+ env: f.env,+ standingPrompt: null,+ resumeSessionId: 'maka-sess-existing',+ onLog: (l) => logs.push(l),+ })+ assert.ok(session)+ liveSessions.push(session)++ const r = await session.send('wake after resume')+ assert.equal(r.exitCode, 0)+ assert.equal(r.sessionId, 'maka-sess-existing')+ assert.ok(!logs.some((l) => l.includes('STALE_REPLAY_TEXT')), 'non-turn chunks must not leak into new turn logs')+ assert.ok(logs.some((l) => l.includes('pong #1')))++ const calls = await f.readCalls()+ assert.deepEqual(calls.slice(0, 2).map((c) => c.method), ['initialize', 'session/resume'])+})++test('maka still recovers when the session disappears after a successful turn', async () => {+ const f = await makeFixture('session-gone-after-first')+ const session = getAdapter('maka').startSession?.({+ home: f.home,+ env: f.env,+ standingPrompt: null,+ resumeSessionId: 'maka-sess-existing',+ onLog: () => {},+ })+ assert.ok(session)+ liveSessions.push(session)++ // The first turn succeeds, which clears `resumed` on the connection.+ const first = await session.send('first turn')+ assert.equal(first.exitCode, 0)++ // The backend loses the session afterwards. Without classifying Maka's own+ // wording independently of `resumed`, this reads as an unknown error and+ // recovery never happens.+ const second = await session.send('second turn')+ assert.equal(second.failure?.kind, 'resume-not-found')+})++test('maka auto-answers server-initiated session/request_permission requests and cancels when no allow option exists', async () => {+ const f = await makeFixture('ask-permission')+ const session = getAdapter('maka').startSession?.({+ home: f.home,+ env: f.env,+ standingPrompt: null,+ resumeSessionId: null,+ onLog: () => {},+ })+ assert.ok(session)+ liveSessions.push(session)++ const r = await session.send('do something requiring permission')+ assert.equal(r.exitCode, 0)++ const calls = await f.readCalls()+ const promptCall = calls.find((c) => c.method === 'session/prompt')+ const reply = calls.find((c) => c.id === promptCall?.id && !c.method)+ // Same id as the outstanding prompt: routing by id would have been wrong.+ assert.equal(reply?.id, promptCall?.id)+ assert.deepEqual(reply?.result, {+ outcome: { outcome: 'selected', optionId: '550e8400-e29b-41d4-a716-446655440002' },+ })++ const fRejectOnly = await makeFixture('ask-permission-reject-only')+ const sessionRejectOnly = getAdapter('maka').startSession?.({+ home: fRejectOnly.home,+ env: fRejectOnly.env,+ standingPrompt: null,+ resumeSessionId: null,+ onLog: () => {},+ })+ assert.ok(sessionRejectOnly)+ liveSessions.push(sessionRejectOnly)++ const r2 = await sessionRejectOnly.send('permission options lack allow')+ assert.equal(r2.exitCode, 0)++ const callsRejectOnly = await fRejectOnly.readCalls()+ const promptCallRejectOnly = callsRejectOnly.find((c) => c.method === 'session/prompt')+ const replyRejectOnly = callsRejectOnly.find((c) => c.id === promptCallRejectOnly?.id && !c.method)+ assert.equal(replyRejectOnly?.id, promptCallRejectOnly?.id)+ assert.deepEqual(replyRejectOnly?.result, {+ outcome: { outcome: 'cancelled' },+ })+})++test('maka treats stopReason=cancelled as a failed turn instead of success', async () => {+ const f = await makeFixture('cancelled')+ const hops: EngineHopReport[] = []+ const session = getAdapter('maka').startSession?.({+ home: f.home,+ env: f.env,+ standingPrompt: null,+ resumeSessionId: null,+ onLog: () => {},+ onHopUsage: (h) => hops.push(h),+ })+ assert.ok(session)+ liveSessions.push(session)++ const r = await session.send('fail with cancelled stopReason')+ assert.equal(r.exitCode, 1)+ assert.match(r.error ?? '', /cancelled/i)+ assert.equal(hops.length, 0)+})++test('maka self-heals a stale resume at handshake time via session/resume -> session/new and reports a fresh session', async () => {+ const f = await makeFixture('fail-load')+ const logs: string[] = []+ const session = getAdapter('maka').startSession?.({+ home: f.home,+ env: f.env,+ standingPrompt: null,+ resumeSessionId: 'maka-sess-stale',+ onLog: (l) => logs.push(l),+ })+ assert.ok(session)+ liveSessions.push(session)++ const r = await session.send('after stale resume')+ assert.equal(r.exitCode, 0)+ assert.equal(r.sessionId, 'maka-sess-fresh')+ assert.ok(logs.some((l) => l.includes('session/resume failed') && l.includes('fresh session')))++ const calls = await f.readCalls()+ assert.deepEqual(calls.slice(0, 3).map((c) => c.method), ['initialize', 'session/resume', 'session/new'])+})++test('maka maps mid-life missing or cwd-mismatched Runtime Host sessions to resume-not-found', async () => {+ const f = await makeFixture('session-gone')+ const session = getAdapter('maka').startSession?.({+ home: f.home,+ env: f.env,+ standingPrompt: null,+ resumeSessionId: 'maka-sess-stale',+ onLog: () => {},+ })+ assert.ok(session)+ liveSessions.push(session)++ const r = await session.send('turn on dead backend session')+ assert.equal(r.exitCode, 1)+ assert.equal(r.failure?.kind, 'resume-not-found')++ const fCwd = await makeFixture('cwd-mismatch')+ const sessionCwd = getAdapter('maka').startSession?.({+ home: fCwd.home,+ env: fCwd.env,+ standingPrompt: null,+ resumeSessionId: 'maka-sess-cwd',+ onLog: () => {},+ })+ assert.ok(sessionCwd)+ liveSessions.push(sessionCwd)++ const rCwd = await sessionCwd.send('turn on mismatched workspace')+ assert.equal(rCwd.exitCode, 1)+ assert.equal(rCwd.failure?.kind, 'resume-not-found')+})++test('maka process dying MID-TURN resolves the turn as a failure, never rejects', async () => {+ const f = await makeFixture('die-mid-turn')+ const session = getAdapter('maka').startSession?.({+ home: f.home,+ env: f.env,+ standingPrompt: null,+ resumeSessionId: null,+ onLog: () => {},+ })+ assert.ok(session)+ liveSessions.push(session)++ const r = await session.send('crash now')+ assert.equal(r.exitCode, 17)+ assert.match(r.error ?? '', /exited with code 17/)+ assert.equal(session.alive, false)+})++test('maka seedHome writes AGENTS.md and .agents/skills, and classify/probe use bypass mode', async () => {+ const f = await makeFixture()+ const adapter = getAdapter('maka')+ await adapter.seedHome(f.home, {+ id: 'agent-maka',+ name: 'Maka Engineer',+ role: 'engineer',+ systemPrompt: 'Follow first principles.',+ })+ const agentsMd = await readFile(join(f.home, 'AGENTS.md'), 'utf8')+ assert.match(agentsMd, /Maka Engineer/)+ assert.match(agentsMd, /\.agents\/skills\//)+ assert.equal((await stat(join(f.home, '.agents', 'skills'))).isDirectory(), true)++ const controller = new AbortController()+ const classified = await adapter.classify({+ cwd: f.home,+ env: f.env,+ prompt: 'Actionable?',+ signal: controller.signal,+ })+ assert.equal(classified.error, undefined)+ assert.equal(classified.text, 'pong #1')++ const calls = await f.readCalls()+ const permCfg = calls.find((c) => c.method === 'session/set_config_option' && c.params?.configId === 'permission_mode')+ assert.equal(permCfg?.params?.value, 'bypass')+})++test('maka probeWake exercises the acp handshake and one-shot run forwards resumeSessionId', async () => {+ const f = await makeFixture()+ const adapter = getAdapter('maka')+ const controller = new AbortController()++ const wake = await adapter.probeWake({ cwd: f.home, env: f.env, signal: controller.signal })+ assert.equal(wake.ok, true)++ const oneShot = await adapter.run({+ home: f.home,+ env: f.env,+ prompt: 'say pong',+ resumeSessionId: 'maka-sess-resumed-run',+ signal: controller.signal,+ onLog: () => {},+ })+ assert.equal(oneShot.exitCode, 0)+ assert.equal(oneShot.sessionId, 'maka-sess-resumed-run')++ const calls = await f.readCalls()+ assert.ok(+ calls.some((c) => c.method === 'session/resume' && c.params?.sessionId === 'maka-sess-resumed-run'),+ 'MakaAdapter.run must forward resumeSessionId to session/resume',+ )++ const probed = await adapter.probe({ cwd: f.home, env: f.env, tier: 'big', signal: controller.signal })+ assert.equal(probed.text, 'pong #1')+})++test('maka does not fall back to dsh when only dsh is on PATH', async () => {+ const root = await mkdtemp(join(tmpdir(), 'cumora-maka-dsh-only-'))+ tempDirs.push(root)+ const binDir = join(root, 'bin')+ await mkdir(binDir, { recursive: true })+ const dshBin = join(binDir, process.platform === 'win32' ? 'dsh.cmd' : 'dsh')+ await writeFile(dshBin, '#!/bin/sh\nexit 0\n', 'utf8')+ await chmod(dshBin, 0o755)++ const envWithOnlyDsh: NodeJS.ProcessEnv = { PATH: binDir }+ assert.equal(resolveMakaBin(envWithOnlyDsh), null)++ const controller = new AbortController()+ const wake = await getAdapter('maka').probeWake({+ cwd: root,+ env: envWithOnlyDsh,+ signal: controller.signal,+ })+ assert.equal(wake.ok, false)+})++test('maka extracts ACP standard cachedReadTokens and cachedWriteTokens when usage is present', async () => {+ const f = await makeFixture('with-usage')+ const hops: EngineHopReport[] = []+ const session = getAdapter('maka').startSession?.({+ home: f.home,+ env: f.env,+ standingPrompt: null,+ resumeSessionId: null,+ onLog: () => {},+ onHopUsage: (h) => hops.push(h),+ })+ assert.ok(session)+ liveSessions.push(session)++ const r = await session.send('turn with usage')+ assert.equal(r.exitCode, 0)+ assert.deepEqual(r.usage, {+ input_tokens: 110,+ output_tokens: 15,+ cache_read_input_tokens: 30,+ cache_creation_input_tokens: 10,+ })+ assert.equal(hops.length, 1)+ assert.deepEqual(hops[0]?.usage, {+ input_tokens: 110,+ output_tokens: 15,+ cache_read_input_tokens: 30,+ cache_creation_input_tokens: 10,+ })+})++test('acp connection decodes multi-byte UTF-8 characters split across stdout chunks without replacement characters', async () => {+ const f = await makeFixture('split-utf8')+ const controller = new AbortController()+ const classified = await getAdapter('maka').classify({+ cwd: f.home,+ env: f.env,+ prompt: 'say hello in Chinese',+ signal: controller.signal,+ })+ assert.equal(classified.error, undefined)+ assert.equal(classified.text, '你好世界')+ assert.ok(!classified.text.includes('\uFFFD'))+})+diff --git a/server/src/__tests__/agents-computer-engine.test.ts b/server/src/__tests__/agents-computer-engine.test.tsindex de26c8f..f89fb53 100644--- a/server/src/__tests__/agents-computer-engine.test.ts+++ b/server/src/__tests__/agents-computer-engine.test.ts@@ -1250,7 +1250,7 @@ test('a Grok ACP turn reports the model the engine announced', { skip: IS_WIN },assert.equal(result.model, 'grok-4.6', 'the turn must be priced on the real model, not left null')assert.equal(hops.length, 1)assert.equal(hops[0].model, 'grok-4.6', 'the ledger hop must name a real model, not the engine id')- assert.equal(hops[0].usage.output_tokens, 4)+ assert.equal(hops[0].usage?.output_tokens, 4)})test('a Grok ACP turn still settles when no model is announced', { skip: IS_WIN }, async () => {diff --git a/server/src/agents/computer/cli-version.ts b/server/src/agents/computer/cli-version.tsindex 5bd511e..1fec615 100644--- a/server/src/agents/computer/cli-version.ts+++ b/server/src/agents/computer/cli-version.ts@@ -130,6 +130,10 @@ export const ENGINE_VERSION_SPECS: Record<string, EngineVersionSpec> = {zcode: {versionArgs: ['--version'],},+ maka: {+ versionArgs: ['--version'],+ selfUpdate: 'maka update --target latest',+ },hermes: {versionArgs: ['version'],selfUpdate: 'hermes update',diff --git a/server/src/agents/computer/daemon.ts b/server/src/agents/computer/daemon.tsindex f38c0dc..8b3ceec 100644--- a/server/src/agents/computer/daemon.ts+++ b/server/src/agents/computer/daemon.ts@@ -856,6 +856,9 @@ export function authFailureHint(engine: EngineId, detail: string): string {if (engine === 'zcode') {return 'Open ZCode on that computer and run `zcode` to refresh its login, model access, or quota, then wake the agent again.'}+ if (engine === 'maka') {+ return 'Open Maka on that computer and run `maka` to refresh its login, model access, or quota, then wake the agent again.'+ }return 'Check the daemon terminal for details, then wake the agent again.'}@@ -878,6 +881,7 @@ function missingEngineMessage(): string {' - ZCode: install the `zcode` CLI, then run `zcode` once to sign in',' (the daemon drives it through the npm-published `zcode-acp-server` bridge via npx;',' CUMORA_ZCODE_ACP_BIN pins a specific bridge copy when needed)',+ ' - Maka: install the `maka` CLI, then run `maka` once to sign in','','After that, rerun:',' npx cumora@latest agent computer --pair <code>',@@ -1647,7 +1651,7 @@ interface PendingHop {runId: string | nullconversationId: string | nullmodel: string- usage: TokenUsage | null+ usage?: TokenUsage | nulllatencyMs: numberstatus: 'ok' | 'rate_limited' | 'timeout' | 'failed'error?: string | null@@ -1921,7 +1925,7 @@ export class AgentRunner {runId: this.currentRunId,conversationId: this.lastWakeConvo,model: report.model,- usage: this.hopUsageOf(report.usage),+ usage: report.usage ? this.hopUsageOf(report.usage) : undefined,latencyMs: report.latencyMs ?? 0,status: 'ok',extras: Object.keys(extras).length ? extras : undefined,@@ -2519,6 +2523,7 @@ export class AgentRunner {if (this.adapter.id === 'pi') return this.agent.model ?? '<pi-default>'if (this.adapter.id === 'antigravity') return this.agent.model ?? 'gemini-3.8-flash-high'if (this.adapter.id === 'zcode') return this.agent.model ?? '<zcode-default>'+ if (this.adapter.id === 'maka') return '<maka-default>'if (this.adapter.id === 'cursor') return this.agent.model ?? '<cursor-default>'return this.agent.model ?? '<cursor-default>'}diff --git a/server/src/agents/computer/engine.ts b/server/src/agents/computer/engine.tsindex 48f22c0..8ea3060 100644--- a/server/src/agents/computer/engine.ts+++ b/server/src/agents/computer/engine.ts@@ -401,10 +401,10 @@ export async function loginCodexRuntime(): Promise<void> {})}-export type EngineId = 'claude' | 'codex' | 'grok' | 'cursor' | 'opencode' | 'pi' | 'gemini' | 'qwen' | 'antigravity' | 'zcode'+export type EngineId = 'claude' | 'codex' | 'grok' | 'cursor' | 'opencode' | 'pi' | 'gemini' | 'qwen' | 'antigravity' | 'zcode' | 'maka'/** The pairable engine ids, in the daemon's default detection order. */-export const ENGINE_IDS: EngineId[] = ['claude', 'codex', 'grok', 'cursor', 'opencode', 'pi', 'gemini', 'qwen', 'antigravity', 'zcode']+export const ENGINE_IDS: EngineId[] = ['claude', 'codex', 'grok', 'cursor', 'opencode', 'pi', 'gemini', 'qwen', 'antigravity', 'zcode', 'maka']/** Engines for which Cumora can impose a fail-closed filesystem + tool-network* boundary non-interactively. The remaining adapters still work for operators@@ -763,7 +763,7 @@ export interface EngineHopReport {* gpt-5.5). The model on this hop's own message — NOT the session default,* since native auto-compaction etc. can switch models mid-turn. */model: string- usage: EngineUsage+ usage?: EngineUsage/** Wall-clock ms since the engine emitted this hop's first event to the* emission of its terminating event (so cache warming etc. are visible). */latencyMs?: number@@ -2767,8 +2767,8 @@ function extractAcpUsage(result: unknown): EngineUsage | undefined {const usage: EngineUsage = {input_tokens: num(raw.input_tokens) ?? num(raw.inputTokens),output_tokens: num(raw.output_tokens) ?? num(raw.outputTokens),- cache_read_input_tokens: num(raw.cache_read_input_tokens) ?? num(raw.cacheReadInputTokens),- cache_creation_input_tokens: num(raw.cache_creation_input_tokens) ?? num(raw.cacheCreationInputTokens),+ cache_read_input_tokens: num(raw.cache_read_input_tokens) ?? num(raw.cachedReadTokens) ?? num(raw.cacheReadInputTokens),+ cache_creation_input_tokens: num(raw.cache_creation_input_tokens) ?? num(raw.cachedWriteTokens) ?? num(raw.cacheCreationInputTokens),}if (usage.input_tokens == null && usage.output_tokens == null) return undefinedreturn usage@@ -3035,6 +3035,8 @@ class AcpRpcConnection {private reqId = 0/** In-flight requests awaiting their JSON-RPC response. */private readonly waiters = new Map<number, (msg: AcpMsg) => void>()+ private readonly stdoutDecoder = new StringDecoder('utf8')+ private readonly stderrDecoder = new StringDecoder('utf8')private outBuf = ''/** Settles when the handshake completes; rejects when the handshake or the* process itself failed. send() awaits it, and so does probeWake(). */@@ -3048,6 +3050,7 @@ class AcpRpcConnection {sessionParams: () => Record<string, unknown>,hooks: AcpRpcConnectionHooks,signal?: AbortSignal,+ private readonly attachMethod: 'session/load' | 'session/resume' = 'session/load',) {this.child = spawnEngineChild(spawnSpec.command, spawnSpec.args, {cwd: home, env, stdio: ['pipe', 'pipe', 'pipe'], shell: spawnSpec.shell,@@ -3058,7 +3061,7 @@ class AcpRpcConnection {this.signal = signalthis.child.stdout?.on('data', (b: Buffer) => this.onStdout(b))this.child.stderr?.on('data', (b: Buffer) => {- for (const raw of b.toString('utf8').split('\n')) {+ for (const raw of this.stderrDecoder.write(b).split('\n')) {const l = cleanLine(raw)if (l) this.hooks.onLog(l)}@@ -3094,13 +3097,19 @@ class AcpRpcConnection {})}+ /** Reply to a server→client JSON-RPC request (e.g. session/request_permission). */+ reply(id: number | string, result: unknown): void {+ if (this.dead || this.stopRequested) return+ writeStdin(this.child, JSON.stringify({ jsonrpc: '2.0', id, result }) + '\n')+ }+stop(options: { force?: boolean } = {}): Promise<void> {this.stopRequested = truetry { this.child.stdin?.end() } catch { /* ignore */ }return terminateEngineTree(this.child, options.force)}- /** initialize → session/load|new. A stale resume falls back to a fresh+ /** initialize → session/load|resume|new. A stale resume falls back to a fresh* session; anything else rejects `ready` and fails the pending turn. */private async handshake(): Promise<void> {await this.rpc('initialize', {@@ -3110,7 +3119,7 @@ class AcpRpcConnection {})if (this.sid) {try {- this.absorbSessionId(await this.rpc('session/load', { sessionId: this.sid, ...this.sessionParams() }))+ this.absorbSessionId(await this.rpc(this.attachMethod, { sessionId: this.sid, ...this.sessionParams() }))this.resumed = truereturn} catch (err) {@@ -3124,7 +3133,7 @@ class AcpRpcConnection {}private onStdout(buf: Buffer): void {- this.outBuf += buf.toString('utf8')+ this.outBuf += this.stdoutDecoder.write(buf)let nl: numberwhile ((nl = this.outBuf.indexOf('\n')) >= 0) {const line = this.outBuf.slice(0, nl)@@ -3134,7 +3143,7 @@ class AcpRpcConnection {let msg: AcpMsg | null = nulltry { msg = JSON.parse(t) as AcpMsg } catch { msg = null }if (!msg) { const c = cleanLine(line); if (c) this.hooks.onLog(c); continue }- if (msg.id !== undefined) {+ if (msg.id !== undefined && !msg.method) {const waiter = this.waiters.get(msg.id)if (waiter) { this.waiters.delete(msg.id); waiter(msg); continue }}@@ -3231,7 +3240,7 @@ class ZcodeSession implements EngineSession {try {this.onHopUsage({model: this.model ?? 'zcode',- usage: usage ?? {},+ usage,latencyMs: Date.now() - startedAt,hopIndex: 1,})@@ -3423,6 +3432,328 @@ class ZcodeAdapter implements EngineAdapter {}}+// ─── maka ─────────────────────────────────────────────────────────────────+// Apache Maka (`maka --acp`) ACP v1 persistent session: initialize →+// session/resume (fallback session/new) → permission_mode=bypass → session/prompt.++/** Resolve `CUMORA_MAKA_BIN` or `maka` on `env.PATH`. */+export function resolveMakaBin(env: NodeJS.ProcessEnv = process.env): string | null {+ const explicit = env.CUMORA_MAKA_BIN?.trim()+ if (explicit) return explicit+ for (const dir of (env.PATH ?? '').split(PATH_DELIMITER)) {+ if (!dir) continue+ const candidate = join(dir, IS_WIN ? 'maka.cmd' : 'maka')+ if (existsSync(candidate)) return candidate+ if (IS_WIN && existsSync(join(dir, 'maka.exe'))) return join(dir, 'maka.exe')+ if (IS_WIN && existsSync(join(dir, 'maka'))) return join(dir, 'maka')+ }+ return null+}++/** Locate the `maka --acp` spawn command on this machine. */+function resolveMakaAcpSpawn(env: NodeJS.ProcessEnv): { command: string; args: string[]; shell: boolean } {+ const explicit = env.CUMORA_MAKA_BIN?.trim()+ if (explicit) {+ if (/\.[cm]?js$/i.test(explicit)) return { command: process.execPath, args: [explicit, '--acp'], shell: false }+ const sp = resolveSpawn(explicit)+ return { command: sp.command, args: ['--acp'], shell: sp.shell }+ }+ const sp = resolveSpawn(resolveMakaBin(env) ?? 'maka')+ return { command: sp.command, args: ['--acp'], shell: sp.shell }+}++interface MakaTurnOptions {+ cwd: string+ env: NodeJS.ProcessEnv+ prompt: string+ model?: string | null+ resumeSessionId?: string | null+ signal: AbortSignal+ onLog?: (line: string) => void+ onHopUsage?: (r: EngineHopReport) => void+}++interface MakaSessionOptions extends EngineSessionArgs {+ onAgentText?: (text: string) => void+ signal?: AbortSignal+}++const MAKA_MISSING_SESSION_RE =+ /runtime host session was not found|archived runtime host sessions cannot be loaded|session is not owned by this acp connection|cwd does not match the existing session workspace/i++class MakaSession implements EngineSession {+ readonly carriesStandingPrompt = false++ private readonly conn: AcpRpcConnection+ private readonly onLog: (line: string) => void+ private readonly onHopUsage?: (r: EngineHopReport) => void+ private readonly onAgentText?: (text: string) => void+ private readonly model: string | null+ private permissionModeUnapplied = true+ private modelWarned = false+ private turn: { resolve: (r: EngineRunResult) => void } | null = null+ private promptInFlight = false+ private steerWarned = false+ private stopped = false++ constructor(home: string, env: NodeJS.ProcessEnv, opts: MakaSessionOptions) {+ this.onLog = opts.onLog+ this.onHopUsage = opts.onHopUsage+ this.onAgentText = opts.onAgentText+ this.model = opts.model ?? null+ this.conn = new AcpRpcConnection(+ resolveMakaAcpSpawn(env),+ home,+ env,+ opts.resumeSessionId ?? null,+ () => ({ cwd: home, mcpServers: [] }),+ {+ onLog: (line) => this.onLog(line),+ onNotification: (msg) => this.onUpdate(msg),+ onDeath: (code, why) => this.onDeath(code, why),+ onLoadFallback: (why) => {+ this.onLog(`[maka] session/resume failed (${why}) — starting a fresh session`)+ },+ },+ opts.signal,+ 'session/resume',+ )+ }++ get alive(): boolean { return this.conn.alive }+ get sessionId(): string | null { return this.conn.sid }+ whenReady(): Promise<void> { return this.conn.ready }++ async send(prompt: string): Promise<EngineRunResult> {+ if (this.turn) return classifyEngineResult({ exitCode: 1, error: 'engine session busy — a turn is already in flight', sessionId: this.conn.sid }, this.conn.resumed)+ if (!this.alive) return classifyEngineResult({ exitCode: this.conn.exitStatusCode || 1, error: 'engine session is not alive (process gone)', sessionId: this.conn.sid }, this.conn.resumed)+ let resolveTurn!: (r: EngineRunResult) => void+ const done = new Promise<EngineRunResult>((resolve) => { resolveTurn = resolve })+ let settled = false+ const settle = (r: EngineRunResult) => { if (!settled) { settled = true; this.turn = null; resolveTurn(r) } }+ this.turn = { resolve: settle }+ try {+ await this.conn.ready+ await this.applySessionConfig()+ if (!this.alive) throw new Error('engine session is not alive (process gone)')+ const wasResume = this.conn.resumed+ const startedAt = Date.now()+ this.promptInFlight = true+ const resp = await this.conn.rpc('session/prompt', {+ sessionId: this.conn.sid,+ prompt: [{ type: 'text', text: stripLoneSurrogates(prompt) }],+ })+ this.conn.resumed = false+ const stopReason = (resp.result as { stopReason?: unknown } | undefined)?.stopReason+ if (stopReason === 'cancelled') {+ settle(this.failureResult('maka turn was cancelled', wasResume, 1))+ return done+ }+ const usage = extractAcpUsage(resp.result) ?? undefined+ if (this.onHopUsage) {+ try {+ this.onHopUsage({+ model: '<maka-default>',+ usage,+ latencyMs: Date.now() - startedAt,+ hopIndex: 1,+ })+ } catch { /* never break the stream */ }+ }+ settle(classifyEngineResult({ exitCode: 0, sessionId: this.conn.sid, usage, model: '<maka-default>' }, wasResume))+ } catch (err) {+ const message = err instanceof Error ? err.message : String(err)+ const wasResume = this.conn.resumed+ this.conn.resumed = false+ settle(this.failureResult(message, wasResume, this.conn.exitStatusCode || 1))+ } finally {+ this.promptInFlight = false+ }+ return done+ }++ steer(_text: string): void {+ if (!this.steerWarned) {+ this.steerWarned = true+ this.log('[maka] same-turn steer is not supported on ACP stdio — the ping rides the next wake')+ }+ }++ async stop(options: { force?: boolean } = {}): Promise<void> {+ this.stopped = true+ await this.conn.stop(options)+ }++ private async applySessionConfig(): Promise<void> {+ if (!this.conn.sid) return+ if (!this.modelWarned && this.model) {+ this.modelWarned = true+ this.log(`[maka] model pin (${this.model}) is ignored — Maka selects its model in its own settings; ACP does not expose model selection`)+ }+ if (this.permissionModeUnapplied) {+ try {+ await this.conn.rpc('session/set_config_option', {+ sessionId: this.conn.sid,+ configId: 'permission_mode',+ value: 'bypass',+ })+ this.permissionModeUnapplied = false+ } catch (err) {+ const why = err instanceof Error ? err.message : String(err)+ this.log(`[maka] permission_mode pin rejected (${why}) — continuing`)+ }+ }+ }++ private failureResult(message: string, wasResume: boolean, exitCode = 1): EngineRunResult {+ // The wording is Maka's own and unambiguous, so it classifies whether or not+ // this turn began as a resume. Gating it on `resumed` let a session that+ // disappeared AFTER a successful turn fall through as an unknown error,+ // skipping recovery and leaving the connection on a stale session id.+ const missingSession = MAKA_MISSING_SESSION_RE.test(message)+ return classifyEngineResult({+ exitCode,+ error: message,+ failure: missingSession+ ? { kind: 'resume-not-found', message, diagnostic: message }+ : undefined,+ sessionId: this.conn.sid,+ }, wasResume)+ }++ private onDeath(code: number, why: string): void {+ if (!this.stopped) {+ this.log(`[session] engine process died ${this.turn ? 'MID-TURN' : 'while idle'}: ${why} (exit ${code})`)+ }+ const wasResume = this.conn.resumed+ this.conn.resumed = false+ this.turn?.resolve(this.failureResult(why, wasResume, code))+ }++ private onUpdate(msg: AcpMsg): void {+ if (msg.method === 'session/request_permission' && msg.id !== undefined) {+ const options = Array.isArray(msg.params?.options)+ ? msg.params.options as Array<{ optionId?: unknown; kind?: unknown }>+ : []+ const preferred = options.find((o) => o?.kind === 'allow_always')+ ?? options.find((o) => o?.kind === 'allow_once')+ if (typeof preferred?.optionId === 'string' && preferred.optionId) {+ this.conn.reply(msg.id, { outcome: { outcome: 'selected', optionId: preferred.optionId } })+ } else {+ this.conn.reply(msg.id, { outcome: { outcome: 'cancelled' } })+ }+ return+ }+ if (msg.method !== 'session/update' || !this.promptInFlight) return+ const u = (msg.params?.update ?? msg.params) as Record<string, unknown> | undefined+ const kind = typeof u?.sessionUpdate === 'string' ? u.sessionUpdate : null+ if (kind === 'tool_call' && typeof u?.title === 'string') {+ this.log(`[maka] tool ${u.title}`)+ } else if (kind === 'agent_message_chunk') {+ const content = u?.content as { text?: unknown } | undefined+ if (typeof content?.text === 'string' && content.text) {+ this.onAgentText?.(content.text)+ if (content.text.trim()) this.log(`[maka] » ${content.text.replace(/\s+/g, ' ').slice(0, 200)}`)+ }+ }+ }++ private log(line: string): void { this.onLog(line) }+}++async function runMakaAcpTurn(opts: MakaTurnOptions): Promise<EngineRunResult & { text: string }> {+ const chunks: string[] = []+ const session = new MakaSession(opts.cwd, opts.env, {+ home: opts.cwd,+ env: opts.env,+ model: opts.model,+ standingPrompt: null,+ resumeSessionId: opts.resumeSessionId ?? null,+ onLog: opts.onLog ?? (() => {}),+ onHopUsage: opts.onHopUsage,+ onAgentText: (text) => chunks.push(text),+ signal: opts.signal,+ })+ try {+ return { ...await session.send(opts.prompt), text: chunks.join('') }+ } finally {+ await session.stop({ force: true })+ }+}++class MakaAdapter implements EngineAdapter {+ readonly id = 'maka' as const+ readonly bin = 'maka'++ async seedHome(home: string, persona: EnginePersona): Promise<void> {+ await ensureCommonHome(home)+ await mkdir(join(home, '.agents', 'skills'), { recursive: true })+ await atomicAgentWrite(+ join(home, 'AGENTS.md'),+ PERSONA_HEADER(persona, { personaFile: 'AGENTS.md', skillsDir: '.agents/skills/' }),+ )+ }++ run(args: EngineRunArgs): Promise<EngineRunResult> {+ return runMakaAcpTurn({+ cwd: args.home,+ env: args.env,+ prompt: args.prompt,+ model: args.model,+ resumeSessionId: args.resumeSessionId,+ signal: args.signal,+ onLog: args.onLog,+ onHopUsage: args.onHopUsage,+ })+ }++ startSession(args: EngineSessionArgs): EngineSession | null {+ return new MakaSession(args.home, args.env, args)+ }++ classify(args: EngineClassifyArgs): Promise<EngineClassifyResult> {+ return runMakaAcpTurn({+ cwd: args.cwd,+ env: args.env,+ prompt: args.prompt,+ model: args.model,+ signal: args.signal,+ onLog: args.onLog,+ })+ }++ probe(args: EngineProbeArgs): Promise<EngineClassifyResult> {+ return runMakaAcpTurn({+ cwd: args.cwd,+ env: args.env,+ prompt: DOCTOR_PROMPT,+ signal: args.signal,+ })+ }++ async probeWake(args: EngineWakeProbeArgs): Promise<EngineWakeProbeResult> {+ const session = new MakaSession(args.cwd, args.env, {+ home: args.cwd,+ env: args.env,+ standingPrompt: null,+ resumeSessionId: null,+ onLog: () => {},+ signal: args.signal,+ })+ try {+ await session.whenReady()+ return { ok: true, detail: '' }+ } catch (err) {+ const why = args.signal.aborted+ ? 'aborted (timeout)'+ : err instanceof Error ? err.message : String(err)+ return { ok: false, detail: `maka acp handshake failed: ${why}`.slice(0, 240) }+ } finally {+ await session.stop({ force: true })+ }+ }+}+// ─── cursor ───────────────────────────────────────────────────────────────//// Cursor Agent (the `cursor-agent` CLI bundled with Cursor, 2026.08.11-e8db854)@@ -5925,6 +6256,7 @@ const ADAPTERS: Record<EngineId, EngineAdapter> = {qwen: new QwenAdapter(),antigravity: new AntigravityAdapter(),zcode: new ZcodeAdapter(),+ maka: new MakaAdapter(),}export function getAdapter(id: EngineId): EngineAdapter {@@ -5944,7 +6276,9 @@ export async function detectEnginesWithStatus(): Promise<EngineDetection> {const ids = Object.keys(ADAPTERS) as EngineId[]const probes = await Promise.all(ids.map(async (id) => {const status = await probeBinOnPath(ADAPTERS[id].bin)- const installed = status === 'present' || (id === 'grok' && resolveGrokBin() != null)+ const installed = status === 'present'+ || (id === 'grok' && resolveGrokBin() != null)+ || (id === 'maka' && resolveMakaBin() != null)return { id, installed, status }}))return {@@ -5987,7 +6321,9 @@ export async function snapshotDetectedEngines(ids?: readonly EngineId[]): Promisconst bin = ADAPTERS[id].binconst path = id === 'grok'? (resolveGrokBin() ?? await resolveBinPath(bin))- : await resolveBinPath(bin)+ : id === 'maka'+ ? (resolveMakaBin() ?? await resolveBinPath(bin))+ : await resolveBinPath(bin)return { id, bin, path }}))}@@ -6115,7 +6451,8 @@ export async function runEngineDoctor(opts?: {const ids = opts?.engines ?? Object.keys(ADAPTERS) as EngineId[]return Promise.all(ids.map(async (id): Promise<EngineHealth> => {const adapter = ADAPTERS[id]- const path = (await resolveBinPath(adapter.bin)) ?? (id === 'grok' ? resolveGrokBin(env) : null)+ const path = (await resolveBinPath(adapter.bin))+ ?? (id === 'grok' ? resolveGrokBin(env) : id === 'maka' ? resolveMakaBin(env) : null)if (!path) return { id, installed: false, path: null, big: null, small: null, wake: null }const probeTier = async (tier: 'big' | 'small'): Promise<BrainHealth> => {const controller = new AbortController()diff --git a/server/src/agents/computer/model-catalog.ts b/server/src/agents/computer/model-catalog.tsindex 0d8d52d..f57704a 100644--- a/server/src/agents/computer/model-catalog.ts+++ b/server/src/agents/computer/model-catalog.ts@@ -136,6 +136,15 @@ const PRESETS: Record<EngineId, EngineModelCatalog> = {fastModelScope: 'agent',source: 'presets',},+ maka: {+ // Maka selects models in its own settings; ACP does not expose model selection.+ models: [],+ defaultModel: null,+ defaultFastModel: null,+ supportsCustom: false,+ fastModelScope: 'agent',+ source: 'presets',+ },}const MODEL_PROBE_TIMEOUT_MS = 10_000diff --git a/server/src/agents/computer/registry.ts b/server/src/agents/computer/registry.tsindex 745ae60..f05fa84 100644--- a/server/src/agents/computer/registry.ts+++ b/server/src/agents/computer/registry.ts@@ -26,7 +26,7 @@ import { signAgentToken } from '../runtime/jwt.js'import type { EngineModelCatalog, EngineModelOption, FastModelScope, ModelCatalogSource } from './model-catalog.js'export type ComputerKind = 'cloud' | 'local' | 'vps'-export type EngineId = 'managed' | 'claude' | 'codex' | 'grok' | 'cursor' | 'opencode' | 'pi' | 'gemini' | 'qwen' | 'antigravity' | 'zcode'+export type EngineId = 'managed' | 'claude' | 'codex' | 'grok' | 'cursor' | 'opencode' | 'pi' | 'gemini' | 'qwen' | 'antigravity' | 'zcode' | 'maka'export type ComputerStatus = 'online' | 'offline' | 'busy'/** How long a paired computer can go without a heartbeat before the sweep@@ -70,6 +70,7 @@ const PAIRABLE: Record<Exclude<EngineId, 'managed'>, true> = {qwen: true,antigravity: true,zcode: true,+ maka: true,}export const PAIRABLE_ENGINES: ReadonlySet<string> = new Set<string>(Object.keys(PAIRABLE))@@ -122,6 +123,7 @@ const ENGINE_BINS: Record<Exclude<EngineId, 'managed'>, string> = {qwen: 'qwen',antigravity: 'agy',zcode: 'zcode',+ maka: 'maka',}/** Cached PATH snapshot from the daemon. The app reads this; it never probes. */@@ -836,7 +838,9 @@ export async function listAgentsForComputer(computerId: string, supportsProvider? antigravityDefault: r.engine === 'zcode'? zcodeDefault- : null+ : r.engine === 'maka'+ ? null+ : nullreturn dflt ? { ...agent, model: dflt, fastModel: fastModelWithEngineDefault } : { ...agent, fastModel: fastModelWithEngineDefault }})}diff --git a/server/src/agents/llm-ledger.ts b/server/src/agents/llm-ledger.tsindex 3cc4e1c..fbf24dc 100644--- a/server/src/agents/llm-ledger.ts+++ b/server/src/agents/llm-ledger.ts@@ -75,7 +75,7 @@ export type LlmCallPurpose =| 'agent-image'export type LlmCallStatus = 'ok' | 'rate_limited' | 'timeout' | 'failed'-export type LlmCallSource = 'cloud' | 'byoa-claude' | 'byoa-codex' | 'byoa-grok' | 'byoa-cursor' | 'byoa-opencode' | 'byoa-pi' | 'byoa-gemini' | 'byoa-qwen' | 'byoa-antigravity' | 'byoa-zcode'+export type LlmCallSource = 'cloud' | 'byoa-claude' | 'byoa-codex' | 'byoa-grok' | 'byoa-cursor' | 'byoa-opencode' | 'byoa-pi' | 'byoa-gemini' | 'byoa-qwen' | 'byoa-antigravity' | 'byoa-zcode' | 'byoa-maka'/** Context bound to a tracked client. Every LLM call it makes carries this* shape into the ledger. `purpose` is mandatory; everything else scopes thediff --git a/server/src/agents/observability.ts b/server/src/agents/observability.tsindex c706158..5ceb3f3 100644--- a/server/src/agents/observability.ts+++ b/server/src/agents/observability.ts@@ -4,7 +4,7 @@ import { pool } from '../db/pool.js'import { EMPTY_USAGE, effectiveCostUsd, modelPriceTable, priceFor, type TokenUsage } from './cost.js'export type AgentRunStatus = 'running' | 'completed' | 'failed' | 'skipped'-export type TriageSource = 'cloud' | 'byoa-claude' | 'byoa-codex' | 'byoa-grok' | 'byoa-cursor' | 'byoa-opencode' | 'byoa-pi' | 'byoa-gemini' | 'byoa-qwen' | 'byoa-antigravity' | 'byoa-zcode'+export type TriageSource = 'cloud' | 'byoa-claude' | 'byoa-codex' | 'byoa-grok' | 'byoa-cursor' | 'byoa-opencode' | 'byoa-pi' | 'byoa-gemini' | 'byoa-qwen' | 'byoa-antigravity' | 'byoa-zcode' | 'byoa-maka'export type AgentEventLevel = 'debug' | 'info' | 'warn' | 'error'type Queryable = Pick<PoolClient, 'query'>diff --git a/server/src/agents/runtime/byoa-source.ts b/server/src/agents/runtime/byoa-source.tsindex 09ab7d7..823d235 100644--- a/server/src/agents/runtime/byoa-source.ts+++ b/server/src/agents/runtime/byoa-source.ts@@ -11,6 +11,7 @@ export const BYOA_SOURCES = ['byoa-qwen','byoa-antigravity','byoa-zcode',+ 'byoa-maka',] as constexport type ByoaSource = typeof BYOA_SOURCES[number]diff --git a/src/admin/api.ts b/src/admin/api.tsindex 9c2335c..5375034 100644--- a/src/admin/api.ts+++ b/src/admin/api.ts@@ -120,7 +120,7 @@ export type LlmCallPurpose =| 'palette' | 'gender' | 'avatar-image' | 'agent-image'export type LlmCallStatus = 'ok' | 'rate_limited' | 'timeout' | 'failed'-export type LlmCallSource = 'cloud' | 'byoa-claude' | 'byoa-codex' | 'byoa-grok' | 'byoa-cursor' | 'byoa-opencode' | 'byoa-pi' | 'byoa-gemini' | 'byoa-qwen' | 'byoa-antigravity' | 'byoa-zcode'+export type LlmCallSource = 'cloud' | 'byoa-claude' | 'byoa-codex' | 'byoa-grok' | 'byoa-cursor' | 'byoa-opencode' | 'byoa-pi' | 'byoa-gemini' | 'byoa-qwen' | 'byoa-antigravity' | 'byoa-zcode' | 'byoa-maka'export interface LlmSummary {sinceDays: numberdiff --git a/src/api/client.ts b/src/api/client.tsindex c45418b..729518d 100644--- a/src/api/client.ts+++ b/src/api/client.ts@@ -420,7 +420,7 @@ export interface ApiAgentRun {}// ── Triage cost-effectiveness ledger ──-export type ApiTriageSource = 'cloud' | 'byoa-claude' | 'byoa-codex' | 'byoa-grok' | 'byoa-cursor' | 'byoa-opencode' | 'byoa-pi' | 'byoa-gemini' | 'byoa-qwen' | 'byoa-antigravity' | 'byoa-zcode'+export type ApiTriageSource = 'cloud' | 'byoa-claude' | 'byoa-codex' | 'byoa-grok' | 'byoa-cursor' | 'byoa-opencode' | 'byoa-pi' | 'byoa-gemini' | 'byoa-qwen' | 'byoa-antigravity' | 'byoa-zcode' | 'byoa-maka'export interface ApiTriageAgentRow {agentId: stringdiff --git a/src/desktop/MeView.tsx b/src/desktop/MeView.tsxindex aa3c059..c3ca423 100644--- a/src/desktop/MeView.tsx+++ b/src/desktop/MeView.tsx@@ -791,7 +791,7 @@ type AgentRow = {const CLI_ORDER = ['claude', 'cursor', 'codex', 'grok', 'opencode',- 'pi', 'gemini', 'qwen', 'zcode', 'hermes',+ 'pi', 'gemini', 'qwen', 'zcode', 'maka', 'hermes',]const COMPUTER_STATUS_KEY: Record<string, MessageKey> = {diff --git a/src/lib/engines.ts b/src/lib/engines.tsindex bf9ae2d..0038af0 100644--- a/src/lib/engines.ts+++ b/src/lib/engines.ts@@ -11,6 +11,7 @@ export const ENGINE_LABEL: Record<string, string> = {qwen: 'Qwen Code',antigravity: 'Antigravity',zcode: 'ZCode',+ maka: 'Maka',hermes: 'Hermes',}@@ -26,6 +27,7 @@ export const ENGINE_BIN: Record<string, string> = {qwen: 'qwen',antigravity: 'agy',zcode: 'zcode',+ maka: 'maka',hermes: 'hermes',}@@ -37,7 +39,7 @@ export const ENGINE_BIN: Record<string, string> = {* state that holds a choice, and the set for membership tests. Engine pickers* used to inline their own copy of this list *and* their own copy of the* labels, which is how adding an engine could leave it unselectable. */-export const RUNNABLE_ENGINES = ['claude', 'codex', 'grok', 'cursor', 'opencode', 'pi', 'gemini', 'qwen', 'antigravity', 'zcode'] as const+export const RUNNABLE_ENGINES = ['claude', 'codex', 'grok', 'cursor', 'opencode', 'pi', 'gemini', 'qwen', 'antigravity', 'zcode', 'maka'] as constexport type RunnableEngineId = typeof RUNNABLE_ENGINES[number]diff --git a/src/locales/en.ts b/src/locales/en.tsindex 88df358..2dfe3dd 100644--- a/src/locales/en.ts+++ b/src/locales/en.ts@@ -489,6 +489,7 @@ export const en = {'agent.modelHintByoaQwen': 'A Qwen Code model id or configured provider model; blank = Qwen default.','agent.modelHintByoaAntigravity': 'An exact Antigravity model name shown by `agy models` (e.g. Gemini 3.5 Flash (High)).','agent.modelHintByoaZcode': 'A model id your zcode install accepts (GLM plan model or a configured provider model); blank = ZCode default.',+ 'agent.modelHintByoaMaka': 'Models are selected in Maka\'s own settings; Cumora cannot pin a model over ACP.','agent.modelHintByoaClaude': "A Claude alias or full name (e.g. opus, sonnet, claude-sonnet-4-6).",'agent.modelHintByoaSuffix': 'Blank = engine default.','agent.modelHintCloud': 'Optional — leave blank to use the system default. Any OpenAI model name works (e.g. gpt-5.5, gpt-5.5-pro, gpt-5.5-mini). Prefix with novita/ to run this agent on Novita instead (e.g. novita/deepseek/deepseek-v3.2).',@@ -507,6 +508,7 @@ export const en = {'agent.fastHintByoaQwen': 'Not used by Qwen; triage follows CUMORA_TRIAGE_MODEL on the computer. Blank = Qwen default.','agent.fastHintByoaAntigravity': 'Not used by Antigravity; triage follows CUMORA_TRIAGE_MODEL on the computer. Blank = Antigravity default.','agent.fastHintByoaZcode': 'Not used by ZCode; triage follows CUMORA_TRIAGE_MODEL on the computer. Blank = ZCode default.',+ 'agent.fastHintByoaMaka': 'Not used by Maka; triage follows CUMORA_TRIAGE_MODEL on the computer. Blank = Maka default.','agent.fastHintByoaClaude': "Cheaper/faster model for light auxiliary tasks — maps to Claude's ANTHROPIC_SMALL_FAST_MODEL. Blank = engine default.",'agent.defaultPh': '(default)','agent.runsOnLabel': 'Runs on',diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.tsindex be13a38..386d438 100644--- a/src/locales/zh-CN.ts+++ b/src/locales/zh-CN.ts@@ -491,6 +491,7 @@ export const zhCN: Partial<Record<keyof typeof en, string>> = {'agent.modelHintByoaQwen': 'Qwen Code 的模型 id 或已配置的 provider 模型;留空 = Qwen 默认。','agent.modelHintByoaAntigravity': 'Antigravity `agy models` 显示的完整模型名(例如 Gemini 3.5 Flash (High))。','agent.modelHintByoaZcode': '你的 zcode 所接受的模型 id(GLM 套餐模型或已配置的 provider 模型);留空 = ZCode 默认。',+ 'agent.modelHintByoaMaka': '模型在 Maka 自己的设置里选择;Cumora 无法通过 ACP 指定。','agent.modelHintByoaClaude': 'Claude 别名或全名(例如 opus、sonnet、claude-sonnet-4-6)。','agent.modelHintByoaSuffix': '留空 = 使用引擎默认。','agent.modelHintCloud': '可选 — 留空使用系统默认。任意 OpenAI 模型名都可以(例如 gpt-5.5、gpt-5.5-pro、gpt-5.5-mini)。加 novita/ 前缀可改走 Novita(例如 novita/deepseek/deepseek-v3.2)。',@@ -509,6 +510,7 @@ export const zhCN: Partial<Record<keyof typeof en, string>> = {'agent.fastHintByoaQwen': 'Qwen 用不到这一项;分流跟随该计算机上的 CUMORA_TRIAGE_MODEL。留空 = Qwen 默认。','agent.fastHintByoaAntigravity': 'Antigravity 用不到这一项;分流跟随该计算机上的 CUMORA_TRIAGE_MODEL。留空 = Antigravity 默认。','agent.fastHintByoaZcode': 'ZCode 用不到这一项;分流跟随该计算机上的 CUMORA_TRIAGE_MODEL。留空 = ZCode 默认。',+ 'agent.fastHintByoaMaka': 'Maka 用不到这一项;分流跟随该计算机上的 CUMORA_TRIAGE_MODEL。留空 = Maka 默认。','agent.fastHintByoaClaude': "更便宜、更快的轻量任务模型 —— 对应 Claude 的 ANTHROPIC_SMALL_FAST_MODEL。留空 = 引擎默认。",'agent.defaultPh': '(默认)','agent.runsOnLabel': '运行于',diff --git a/src/types.ts b/src/types.tsindex ffe8d82..f5e3808 100644--- a/src/types.ts+++ b/src/types.ts@@ -7,7 +7,7 @@ export type Status = 'avail' | 'working' | 'thinking' | 'waiting' | 'resting'export type ComputerKind = 'cloud' | 'local' | 'vps'export type ComputerStatus = 'online' | 'offline' | 'busy'/** Engine an agent's host runs it on. 'managed' = Cumora's server-side loop. */-export type EngineId = 'managed' | 'claude' | 'codex' | 'grok' | 'cursor' | 'opencode' | 'pi' | 'gemini' | 'qwen' | 'antigravity' | 'zcode'+export type EngineId = 'managed' | 'claude' | 'codex' | 'grok' | 'cursor' | 'opencode' | 'pi' | 'gemini' | 'qwen' | 'antigravity' | 'zcode' | 'maka'export interface EngineModelOption {id: string