mirror of
https://github.com/stablyai/orca.git
synced 2026-11-02 01:57:57 +00:00
* [comment audit] Shorten daemon, hook, and emulator comments [skip ci] * [comment audit] Shorten VM, conversation, SQLite, and theme-import comments [skip ci] * [comment audit] Tighten Git execution and source-control comment contracts [skip ci] * [comment audit] Clarify repository probes and maintenance comments [skip ci] * [comment audit] Shorten status, diff-cache, and checkout comments [skip ci] * [comment audit] Clarify worktree lifecycle and WSL routing comments [skip ci] * [comment audit] Shorten forge identity and review-refresh comments [skip ci] * [comment audit] Tighten hosted-review client comment contracts [skip ci] * [comment audit] Clarify GitLab compatibility and review comments [skip ci] * [comment audit] Tighten hook ownership and watchdog rationale [skip ci] * [comment audit] Condense host and integration compatibility comments [skip ci] * [comment audit] Clarify IPC authority and remote-routing rationale [skip ci] * [comment audit] Finalize file-import and containment comment cleanup * [comment audit] Fix stale Jira type imports blocking full CI --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
49 lines
1.6 KiB
TypeScript
49 lines
1.6 KiB
TypeScript
import { parentPort } from 'node:worker_threads'
|
|
import { handleOpenCodeSqliteRequest } from '../ai-vault/session-scanner-opencode-sqlite-dispatch'
|
|
import type { OpenCodeSqliteWorkerRequest } from '../ai-vault/session-scanner-opencode-sqlite-worker-protocol'
|
|
import { handleForeignSqliteReaderRequest } from './foreign-sqlite-reader-dispatch'
|
|
import type {
|
|
ForeignSqliteReaderRequest,
|
|
ForeignSqliteReaderResponse
|
|
} from './foreign-sqlite-reader-protocol'
|
|
|
|
// Keep OpenCode dispatch separate because SSH/WSL relays bundle it without the other readers.
|
|
|
|
if (!parentPort) {
|
|
throw new Error('Foreign SQLite reader worker must run with a parent port.')
|
|
}
|
|
const port = parentPort
|
|
|
|
type ReaderRequest = OpenCodeSqliteWorkerRequest | ForeignSqliteReaderRequest
|
|
|
|
function isOpenCodeRequest(request: ReaderRequest): request is OpenCodeSqliteWorkerRequest {
|
|
return (
|
|
request.kind === 'list' ||
|
|
request.kind === 'parse' ||
|
|
request.kind === 'capture' ||
|
|
request.kind === 'native-page' ||
|
|
request.kind === 'native-signal'
|
|
)
|
|
}
|
|
|
|
function handle(request: ReaderRequest): Promise<ForeignSqliteReaderResponse> {
|
|
return isOpenCodeRequest(request)
|
|
? handleOpenCodeSqliteRequest(request)
|
|
: Promise.resolve(handleForeignSqliteReaderRequest(request))
|
|
}
|
|
|
|
port.on('message', (request: ReaderRequest) => {
|
|
void handle(request).then((response) => {
|
|
try {
|
|
port.postMessage(response)
|
|
} catch {
|
|
// Reply with a serialization failure instead of leaving the client waiting for its timeout.
|
|
port.postMessage({
|
|
id: request.id,
|
|
ok: false,
|
|
error: 'Foreign SQLite reader result could not be serialized.'
|
|
})
|
|
}
|
|
})
|
|
})
|