The cast

Pi, Hono, Svelte, SQLite and Docker. Who does which job, and why each one is here.

beginner7 min read

Press Send and watch the answer arrive. The page shows the words as the server sends them. The server saves the work, so another process can pick it up after a restart. Give each piece one job and the whole exchange gets easier to follow.

In this chapter

  • Name the piece that does each job on a send
  • Find the technology behind a feature you use
  • Read the three kinds of dependency entries in the server manifest

Follow the work, one job at a time

Who does what
FeatureOn a send Where to look
SvelteShows the chat.App.svelte
HonoCarries requests and updates.app.ts routes
Pipal coreDecides whether to accept the message.Core’s index.ts
Pi DurableRecords and runs the work.Core’s Harness.open()
SQLiteStores the conversation and its work on disk.durable.sqlite
Pi AICalls the selected model.models.ts

Choose up to two columns

FeatureOn a send Where to look
SvelteShows the chat.App.svelte
HonoCarries requests and updates.app.ts routes
Pipal coreDecides whether to accept the message.Core’s index.ts
Pi DurableRecords and runs the work.Core’s Harness.open()
SQLiteStores the conversation and its work on disk.durable.sqlite
Pi AICalls the selected model.models.ts
Each row gives one piece a job. Use the file names to trace a send in the source.

Start with the page. Svelte 5 builds the interface you see. Vite turns the client into browser-ready files, and Hono serves them. When the page loads, packages/web/src/main.ts mounts App.svelte. That’s the file to start with if you want to see how the composer, sidebar, and chat fit together. The Svelte workspace follows the browser side. main.ts

Follow the request. Hono matches the request to a route, a handler for an address and method. @hono/node-server connects that handler to Node’s HTTP server. When the browser wants to follow the chat, Hono keeps an event streamAn open HTTP response that carries updates from the server to the browser. open so the answer can arrive as it grows. The Hono server follows these requests. app.ts main.ts

If you come back halfway through a reply, the stream can show you what the conversation looks like now. Pipal starts the connection with a snapshot of the recent transcript and the live state. After that, the browser’s stream gets changes to that snapshot. If the chat has older entries, choose Load earlier messages to fetch them through a separate request for history. app.ts App.svelte

Look behind the route. Pipal core decides whether it can take your message. Pi Durable, the agent harnessThe software that keeps track of a conversation and runs the model and tools that answer it., keeps track of the work to answer it, including model requests and tool calls. Pi AI handles the calls to the selected model. Keeping the work in the harness lets the browser come and go while the host carries on. What Pi gives you goes into the handoff. index.ts

Keep the chat on disk. SQLite keeps Pipal’s records in database files. At startup, Pipal opens durable.sqlite with Pi Durable’s Node SQLite adapter. Core puts the input, the task that answers it, and the deadline in one commit. index.ts

Give Developer a place to work. A locationThe place a chat uses for project tools, either the Pipal host, an account reached over SSH, or a Docker project. is where Developer’s project tools run. The signed-in owner chooses which locations to enable in Settings → Workspace. This machine runs tools as the Pipal service user, whose files include the chat database and any saved model login. SSH machine uses OpenSSH to reach the development account. In either development workspace, Docker can run apps if the account has access to it. DeveloperWorkspace.svelte development-workspace.ts

The Docker location runs shell commands and ordinary file operations in containers without network access. Settings and the Runtime panel show the shell’s network restriction. Where everything lives and runs puts the locations on the map. project-shell.ts workspace-choice.ts

Developer can still look up public documentation in a Docker chat when web access is configured. A compatible model provider can handle search. Pipal’s host can also ask Exa for search results or Jina Reader for the contents of a page. These calls run outside the project containers. hosted-search.ts public-web.ts

On a fresh install, every location starts off. On upgrade, Pipal can import a configured SSH or Docker grant if a chat database exists and workspace settings have yet to be saved. The host probes enabled locations at startup. A location that fails to connect stays enabled and appears as unavailable. The owner can choose Retry connection in Settings when a connection error is shown. workspace-locations.ts DeveloperWorkspace.svelte

Deep diveHow the host assembles the runtime

main.ts opens the runtime and gives it to createApp(). Node’s createServer() receives the request listener from Hono’s Node adapter. The app serves the Vite output as files, and its conversation events route writes updates using streamSSE(). The runtime opens Pi Durable with the registry of tools and the providers built in models.ts. main.ts app.ts index.ts

SQLite has other jobs besides the transcript. store-lock.ts holds a connection to owner.sqlite for exclusive ownership. passkey-store.ts opens passkeys/auth.sqlite in passkey mode for registered credentials. Search opens an SQLite database in memory, so an index need not be carried forward when Pipal restarts. store-lock.ts passkey-store.ts transcript-search.ts

For the two persistent workspace locations, persistentTools() runs the same Node helper. It starts it directly on the host for This machine and invokes it through ssh for SSH machine. development-workspace.ts

The other Pi packages show up at narrower boundaries. The app uses Pi Schema to define shapes for incoming requests, and the optional Code Mode extension is loaded from Pi Codemode and Pi Durable when enabled. Core uses Chord’s context helpers to carry information such as the workspace location and selected project scope into a tool call. These imports give you concrete places to look before opening the package documentation. app.ts main.ts index.ts

Read the ingredients in the manifests

Three ways to name a dependency
"@earendil-works/chord": "catalog:",
"@earendil-works/pi-codemode": "catalog:",
"@earendil-works/pi-durable":
  "catalog:",
"@earendil-works/pi-schema":
  "catalog:",
"@hono/node-server": "2.1.11",
"@napi-rs/canvas": "1.2.1",
"@pipal/core": "workspace:*",
packages/server/package.json
  1. Look up a version

    pnpm-workspace.yaml gives this package its exact version, 1.7.0.

  2. Pin it here

    The server manifest gives the Node adapter an exact version.

  3. Use the local package

    pnpm links to the core package in this checkout.

"@earendil-works/chord": "catalog:",
"@earendil-works/pi-codemode": "catalog:",
"@earendil-works/pi-durable":
  ,
"@earendil-works/pi-schema":
  "catalog:",
"@hono/node-server": ,
"@napi-rs/canvas": "1.2.1",
"@pipal/core": ,
packages/server/package.json

1 Look up a version

pnpm-workspace.yaml gives this package its exact version, 1.7.0.

Select a dependency to see where pnpm gets it. This excerpt is from the server’s package.json.

Open the root package.json and you’ll see that pnpm build builds the web client. pnpm start expects that build to be present and tells you to build it if it is missing. Node.js 26 runs the server’s TypeScript and the local core package it imports. The browser loads the client files Vite built. package.json main.ts

The three packages belong to one pnpm workspace. In pnpm-workspace.yaml, the catalog gives Pi Durable, Pi AI, Pi Codemode, Pi Schema, and Chord the same exact version, 1.7.0. When a manifest says catalog:, look there for the number. An entry such as "hono": "4.13.23" gives the exact version in the manifest itself. pnpm-workspace.yaml package.json

The pins let you match what you’re reading to what Pipal imports. When you open an example from Pi, use the version pinned here. A newer example can describe a different interface. The catalog tells you the requested version and pnpm-lock.yaml records the resolved dependencies. The recovery tests use the installed harness through the same runtime that the app uses. pnpm-lock.yaml recovery-worker.ts

Small libraries do specific jobs

When a feature catches your eye, start with the file that handles it and look at its imports. For a formatted reply, Marked interprets Markdown and DOMPurify sanitizes the resulting HTML before the browser displays it. You can see both stages in the same Svelte component. Markdown.svelte

When you… The library and where it works
Sign in with a passkey SimpleWebAuthn helps the browser ask for a passkey in Access.svelte and the server verify the response in passkeys.ts.
Read a formatted answer Marked turns Markdown into HTML and DOMPurify cleans it in Markdown.svelte.
Send a PDF PDF.js reads pages and @napi-rs/canvas supplies the canvas for rendering in pdf-worker.ts.
Upload an image image-size checks the image dimensions in uploads.ts.
Start with a config file smol-toml parses it in config.ts.
Schedule a repeating prompt cron-parser interprets the schedule in routine-schedule.ts.
Load a profile yaml reads the settings at the top of its Markdown file in profiles.ts.
Deep diveWhere the smaller dependencies enter the code

The passkey server asks SimpleWebAuthn to verify the browser’s assertion, including user verification. The browser imports its companion package in the sign-in screen. In a reply, Markdown.svelte creates the parser and sanitizes the resulting HTML before displaying it. passkeys.ts Access.svelte Markdown.svelte

The PDF worker opens the document and creates a canvas sized for the page. Upload checks use image-size on image bytes before saving. Config parsing, profile parsing, and schedule parsing take place in three different files. Each library sees the format it is meant to read. pdf-worker.ts uploads.ts config.ts profiles.ts routine-schedule.ts

The manifests tell you which side uses each library. Both the browser and server list SimpleWebAuthn, under distinct package names, because they have different jobs in a sign-in. PDF parsing and rendering belong to the server package. Looking at the imports beside the dependency lists tells you which part of the feature to read first. package.json package.json

You know the jobs now. Where should you open the checkout if you want to see the handoff between them? A tour of the repository starts at the top of the tree.

Recap

  • Svelte draws the chat, Hono handles requests, and core applies the rules.
  • Pi Durable runs the conversation, Pi AI calls the model, and SQLite keeps the records.
  • The manifests tell you which code comes from the checkout and which version of a library Pipal uses.
Check yourself
  1. An answer appears a little at a time. What carries those updates into the browser?
    • Hono’s event stream
    • The Node compile cache
    • The pnpm catalog
    Answer and explanation

    Hono’s event stream

    Hono holds open a response and writes updates as the conversation changes.

  2. You see catalog: beside Pi Durable. Where do you find its version?
    • agents/
    • pnpm-workspace.yaml
    • The conversation store
    Answer and explanation

    pnpm-workspace.yaml

    The workspace catalog supplies the pinned version shared across the package manifests.

  3. Which piece talks to the selected model?
    • Vite
    • SQLite
    • Pi AI
    Answer and explanation

    Pi AI

    Pi AI handles model calls. Pi Durable keeps track of the work in the conversation.

  1. An answer appears a little at a time. What carries those updates into the browser?

  2. You see catalog: beside Pi Durable. Where do you find its version?

  3. Which piece talks to the selected model?

In the source

Book contents

Search the book