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
6 changes: 6 additions & 0 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ import {
spawnOmp,
abortOmpSession,
} from './omp-cli.js';
import {
spawnOmo,
abortOmoSession,
} from './omo-cli.js';
import {
stripAnsiSequences,
normalizeDetectedUrl,
Expand Down Expand Up @@ -170,6 +174,7 @@ const wss = createWebSocketServer(server, {
opencode: spawnOpenCode,
gjc: spawnGjc,
omp: spawnOmp,
omo: spawnOmo,
},
abortFns: {
claude: abortClaudeSDKSession,
Expand All @@ -178,6 +183,7 @@ const wss = createWebSocketServer(server, {
opencode: abortOpenCodeSession,
gjc: abortGjcSession,
omp: abortOmpSession,
omo: abortOmoSession,
},
resolveToolApproval: resolveProviderToolApproval,
getPendingApprovalsForSession: getPendingProviderApprovalsForSession,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ const PROVIDER_CAPABILITIES: Record<LLMProvider, ProviderCapabilities> = {
provider: 'omo',
permissionModes: ['default'],
defaultPermissionMode: 'default',
// omo is wired for discovery and transcript reading only. There is no omo
// send runtime (no `server/omo-cli.ts`), so nothing forwards attachments or
// can cancel an in-flight run yet.
// Mirrors the Oh My Pi posture: buildPiCliArgs forwards image paths as
// @<path> and createPiCliRuntime terminates the tracked child with SIGTERM
// (`server/pi-cli.ts`), but this matrix still hides both UI controls.
supportsImages: false,
supportsAbort: false,
// omo's TUI renders "↑↓ navigate • enter select • esc close" and has no
Expand Down
100 changes: 100 additions & 0 deletions server/omo-cli.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import assert from 'node:assert/strict';
import test from 'node:test';

import { buildOmoArgs, normalizeOmoEvent } from './omo-cli.js';

test('buildOmoArgs preserves resume, model, thinking, images, and prompt as distinct argv', () => {
assert.deepEqual(
buildOmoArgs('Explain this image', {
sessionId: '019ff9fa-abab-78a3-83b0-67c261374f42',
model: 'anthropic/claude-opus-5',
effort: 'high',
images: [{ path: '/tmp/shot.png' }, { path: ' ' }, { path: 42 }],
}),
[
'--mode', 'json', '--print',
'--resume', '019ff9fa-abab-78a3-83b0-67c261374f42',
'--model', 'anthropic/claude-opus-5',
'--thinking', 'high',
'@/tmp/shot.png',
'Explain this image',
],
);
});

test('buildOmoArgs omits placeholder model and effort selections', () => {
assert.deepEqual(
buildOmoArgs('hi', { model: 'default', effort: 'default' }),
['--mode', 'json', '--print', 'hi'],
);
});

// Event shapes below are verbatim from `omo --mode json --print`.
test('normalizeOmoEvent captures the native session id and streams assistant text', () => {
assert.deepEqual(
normalizeOmoEvent(
{ type: 'session', version: 3, id: '019ff9fa-abab-78a3-83b0-67c261374f42', cwd: '/tmp' },
null,
).providerSessionId,
'019ff9fa-abab-78a3-83b0-67c261374f42',
);

const streamed = normalizeOmoEvent({
type: 'message_update',
assistantMessageEvent: { type: 'text_delta', contentIndex: 0, delta: 'ok' },
}, 'session-1');
assert.equal(streamed.messages.length, 1);
assert.equal(streamed.messages[0].kind, 'stream_delta');
assert.equal(streamed.messages[0].content, 'ok');
assert.equal(streamed.messages[0].provider, 'omo');
});

test('normalizeOmoEvent maps the native tool lifecycle to shared tool messages', () => {
const started = normalizeOmoEvent({
type: 'tool_execution_start',
toolCallId: 'toolu_01FqdHoP72XmbXtPo5yrEdkM',
toolName: 'read',
args: { path: '/tmp/omo-json-probe/sample.txt' },
}, 'session-1');
assert.equal(started.messages[0].kind, 'tool_use');
assert.equal(started.messages[0].toolName, 'read');
assert.equal(started.messages[0].toolId, 'toolu_01FqdHoP72XmbXtPo5yrEdkM');
assert.deepEqual(started.messages[0].toolInput, { path: '/tmp/omo-json-probe/sample.txt' });

const ended = normalizeOmoEvent({
type: 'tool_execution_end',
toolCallId: 'toolu_01FqdHoP72XmbXtPo5yrEdkM',
toolName: 'read',
result: { content: [{ type: 'text', text: 'probe file\n' }] },
isError: false,
}, 'session-1');
assert.equal(ended.messages[0].kind, 'tool_result');
assert.equal(ended.messages[0].toolId, 'toolu_01FqdHoP72XmbXtPo5yrEdkM');
assert.equal(ended.messages[0].content, 'probe file\n');
assert.equal(ended.messages[0].isError, false);
});

test('normalizeOmoEvent ignores the non-message envelopes the CLI also emits', () => {
for (const event of [
{ type: 'agent_start' },
{ type: 'turn_start' },
{ type: 'turn_end', message: { role: 'assistant', content: [] } },
{ type: 'agent_settled' },
{ type: 'entry_appended', entry: { type: 'custom', customType: 'omo-memory:accepted-turns' } },
{ type: 'tool_hook_status', hookName: 'PreToolUse', toolName: 'read' },
{ type: 'message_update', assistantMessageEvent: { type: 'text_start', contentIndex: 0 } },
]) {
assert.deepEqual(normalizeOmoEvent(event, 'session-1').messages, [], event.type);
}
});

test('normalizeOmoEvent surfaces errors with an omo-labelled fallback', () => {
assert.equal(
normalizeOmoEvent({ type: 'error', error: { message: 'boom' } }, 'session-1').messages[0].content,
'boom',
);
assert.equal(
normalizeOmoEvent({ type: 'error' }, 'session-1').messages[0].content,
'omo failed.',
);
});
40 changes: 40 additions & 0 deletions server/omo-cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import {
buildPiCliArgs,
createPiCliRuntime,
normalizePiCliEvent,
type PiCliDescriptor,
type PiCliRunOptions,
type PiCliWriter,
} from './pi-cli.js';
import type { NormalizedMessage } from './shared/types.js';

const OMO: PiCliDescriptor = {
provider: 'omo',
binary: 'omo',
label: 'omo',
};

const runtime = createPiCliRuntime(OMO);

export function buildOmoArgs(command: string, options: PiCliRunOptions): string[] {
return buildPiCliArgs(command, options);
}

export function normalizeOmoEvent(
eventValue: unknown,
sessionId: string | null,
): { providerSessionId?: string; messages: NormalizedMessage[] } {
return normalizePiCliEvent(eventValue, sessionId, OMO);
}

export function spawnOmo(
command: string,
options: PiCliRunOptions = {},
writer: PiCliWriter,
): Promise<void> {
return runtime.spawn(command, options, writer);
}

export function abortOmoSession(sessionId: string): boolean {
return runtime.abort(sessionId);
}
Loading