Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
Node Services Conventions
Boundary
- This app is one deployable Node process that hosts roles. The roles are
memory,llm-wiki,agent(the Agent Service),document, andvoice. agent,memory, andllm-wikishare one HTTP listener (src/http-host.ts,NODE_SERVICES_HTTP_ADDRESSashost:port, default127.0.0.1:4319;DOCUMENT_RUNTIME_HTTP_ADDRESS, default127.0.0.1:4321, for the Document Runtime). Each role mounts its own path prefixes: Agent/v1/(plus the/v1/runner-gatewayWebSocket upgrade), Memory/internal/v1/, LLM Wiki/v0/document-normalizationsand/internal/v1/wiki-refreshes/; the longest prefix wins. Prefixes must not collide. The host alone answers/healthz(process alive),/startupz(every selected role started), and/readyz(started and every mounted role's readiness ok); roles must not register their own probes. When a role closes, it calls the unmount function returned bymount(); it never closes a shared listener. Only the host owns that listener's lifecycle, so other roles remain available and replacements can mount.- The
documentrole keeps its own port (4321 by default) on its own worker thread (src/document/main.ts) because it installs jsdom globals and replaces the globalRequest/Response. Thevoicerole supervises separate ASR, recorder and Live child processes, each on a health port the system offers when it starts (VOICE_WORKER_PORT); it does not run audio jobs on the main thread. Voice workers follow TeamHub's effective provider keys (GET /internal/v1/voice/provider-keyswith thevoice-runtimecredential): a Soniox key runs ASR and recorder, an xAI key runs Live. The role reconciles at startup, on TeamHub'sPOST /v1/voice/workers:reconcile(node-services-internalbearer), and every 60 seconds, so workers start, drain, or restart with a new key without restarting node-services. The reconcile route answers{ready}only after every wanted worker's health port reports it registered with LiveKit, or after 20 seconds, so TeamHub answers a key save once a voice session can be dispatched. Keys reach a worker only through its environment; a failed key fetch leaves the running workers unchanged. Other roles run on the main thread and must not install process globals. NODE_SERVICES_ROLESselects roles as a comma-separated list. An unset or empty value starts every role; an unknown role fails startup. Selected roles always start in the ordermemory,llm-wiki,agent,voice,document. Shutdown starts media draining immediately while other roles stop in reverse. Background work that uses a later role's seam starts from the role'sstarted(), which the host calls once every selected role has started, and stops fromstopping(), called before the first role stops: Memory's scheduler runs only while the agent role's model call can be there. The shared listener starts only when an HTTP role is selected.src/main.tsis the only process entrypoint. It owns SIGINT/SIGTERM throughsrc/process-lifecycle.ts: the first signal aborts startup or starts ordered shutdown under the fixed 95-secondSHUTDOWN_TIMEOUT_MS, later signals are ignored, and it is the only caller ofprocess.exit.- A role exports a
start*Servicefunction that receives the host's seams and returnsPromise<{ stop(): Promise<void> }>. Roles must not register signal handlers, callprocess.exit, read.envfiles, or depend onprocess.cwd(). - Role code stays under
src/<role>/. Do not import another role's runtime modules; host-level code shared by roles stays flat undersrc/. - Roles exchange in-process data only through host-owned seams passed to their
start functions. The memory role returns its flashback (
src/flashback.ts), and the host passes it to the agent role only when both run in the same process; the Agent calls it directly, not over HTTP.
Text document conversion
Imported code, JSON, XML and YAML remain literal code-block content in the normalized Markdown. Embedded backtick runs must not close the surrounding fence, and filename-derived language metadata must not introduce backticks or line breaks into its opening line.
Configuration and Paths
- Roles read only the process environment. Package scripts load the root
.envthroughscripts/with-local-env.mjs; images set environment variables. - Resolve relative configured paths with
resolveConfiguredPathfromsrc/paths.ts, which uses the repository root. The Agent and Memory roles both take the Context Host root fromcontextHostRootthere. Locate packaged assets frompackageRoot:prompts/memoryandprompts/llm-wikithroughpromptsRoot. Start workers fromserviceModule, and guard CLI entrypoints withisMainModule, never withimport.meta.urldirectly: the desktop's offline runtime bundles each entry into one file (apps/desktop/scripts/bundle-node-services.mjs), where every module shares the entry's URL and relative paths resolve against the directory it runs in. - Packages that hold model data (the Voice VAD binding)
resolve through
src/model-packages.ts: from node_modules in development and images, downloaded on first use where the offline runtime lists them inmodels.json. Thevoicerole starts its download when the role starts, before any provider key exists, so the first worker start does not wait for it. At process start, downloaded packagesmodels.jsonno longer lists are deleted, so a retired feature's model data leaves the machine. - Roles log through the
JsonLoggerthe host passes tostart*Service(createJsonLoggerfrom@linger/service-kit/node); thedocumentrole creates its own inside its worker thread, and theagentrole keeps its own file-backed Agent log (src/agent/observability/), which the host drains on exit. Log events are<area>.<what>with snake_case fields; CLIs keep plain text. Shared guards and hashing (isRecord,isNodeError,sleep,sha256Hex) come from@linger/service-kit; do not redefine them.
Document normalization
MIME document normalization prefers extractable HTML, then the recorded plain-text alternative when HTML has no extractable body. Headers alone do not make an empty message indexable.
Structure
tests/<role>/mirrorssrc/<role>/; host-level tests such astests/main.test.tsandtests/http-host.test.tsstay flat undertests/.- Role-specific rules live in
src/agent/AGENTS.md,src/llm-wiki/AGENTS.md, andsrc/document/AGENTS.md. Memory's human-facing behavior and commands live insrc/memory/README.md. - Vitest projects:
rolesandagentrun in parallel,documentruns one file at a time after them, andagent-process(tests/agent/executor/agent-manager-process.test.ts, the real process) runs alone last. scripts/generate-feature-catalog.tsgeneratessrc/agent/agent-features/catalog.generated.ts;typecheckverifies it.
JSON document conversion
JSON imports validate and pretty-print the source while retaining each numeric
literal. The converter uses Node's source-aware JSON reviver and raw JSON values
so large identifiers, precise decimals and extreme exponents are not rounded or
replaced with null. JSON conversion uses the normalizer's queued worker so
per-value revival does not block the shared Node Services event loop, and it
obeys the worker's cancellation, memory and timeout limits. UTF-8 validation
is unchanged. Invalid JSON remains DOCUMENT_SOURCE_INVALID.
Commands
pnpm --filter @linger/node-services check: typecheck and lint concurrently, then test.make check-node-servicesruns the same gate.pnpm --filter @linger/node-services exec vitest run <test-file>: run one test.pnpm dev:node-services(root): start every role throughscripts/dev-supervisor.ts, which waits for TeamHub, regenerates the Agent feature catalog, and restarts the process after a crash. It does not watch files, so a source change never restarts a running Wiki generation.pnpm --filter @linger/node-services dev: watch every role during focused work;NODE_SERVICES_ROLES=agent(or another role) narrows it.- Memory CLIs:
pnpm --filter @linger/node-services memory:<command>.
Large text documents
CSV and TSV normalization accepts large row counts within the existing source
and Markdown byte limits. An output that exceeds its configured byte budget
fails with DOCUMENT_MARKDOWN_TOO_LARGE, independently of the number of rows.
Imported table cells
CSV, TSV and XLSX values are table data. Both table converters use the shared cell escaping function so backslashes and inline Markdown delimiters remain visible text after document materialization. CR, LF and CRLF inside a cell become spaces instead of introducing new Markdown rows.
Image
- The
Dockerfilebuilds one image that runs every role: port 4319 for the shared listener and 4321 for the Document Runtime. Its health check uses both ports'/healthz.