Where everything lives and runs

Your machine, one Node.js process, a private data folder, a model in the cloud, and the places an agent is allowed to touch.

beginner13 min read

You ask Developer to fix a file and start the app. Then you close the tab. Later, you can open the chat again in your browser because Pipal kept it on the computer running the server. To find the edit or check whether the app is still up, you need to know where Developer did the work.

In this chapter

  • Locate the browser, the server, the model, and the files each uses.
  • Follow a project edit to the machine and process that perform it.
  • Tell what survives a closed tab, a stopped server, or a new chat.

One process on the host

The places Pipal uses
  • A Pipal installation

    The browser can run on the host or on another device. The development machine can be a Linux virtual machine on the same physical computer as Pipal.

    • Pipal host

      This is the Mac or Linux computer that runs the server and holds its private data. If you use a browser on this computer, the tab still runs separately from Node.js.

      • Node.js

        One long-lived process serves the client and runs the conversation. Hono serves the tab at 127.0.0.1:8080 by default. ChatGPT sign-in uses a separate loopback callback on port 1455.

        • Hono

          Serves the web files and handles requests from the browser. It hands chat messages to Pipal core in the same process.

        • Pipal core

          Accepts messages, sets deadlines and checks which tools a chat may use. Host tool handlers live in this process too.

        • Pi Durable + Pi AI

          Pi Durable schedules the work and saves its progress. Pi AI handles the model request, including Local echo in this process.

      • Checkout

        In a checkout at ~/projects/pipal, look for config.toml if you made one, profiles in agents/, and the client build in packages/web/build.

      • Private data

        storage.data_dir defaults to ./data beside the config file. The conversation store, uploaded originals and workspace-settings.json go here.

        • Local projects data/projects/

          Each named local project has a folder under projects/ in the data directory. Another chat can open the same folder.

      • Host helpers

        The host starts a child process to prepare each PDF. Host project search starts ripgrep, and some diagnostics launch fixed executables.

      • Local runner

        For a local project tool call, the host starts a Node.js runner here. The runner starts Bash or a file helper in the selected project.

    • Browser tab

      Runs the Svelte client. The tab sends requests and watches the selected conversation. Closing it leaves accepted work on the host.

    • OpenAI or DeepSeek

      The selected remote provider receives the context for each model request. The provider sends back text or requests for tools.

    • Exa · Public web search

      Receives the query from the host when Developer calls search_public_web. The tool returns titles, URLs and excerpts.

    • Jina Reader · Public page reader

      Receives a public HTTPS URL from the host when Developer calls read_url. The tool returns the extracted page content.

    • Docker engine · Optional Docker project

      The engine that the host’s Docker command connects to can be local or on a separate machine. It runs the containers and holds the volume.

      • Tool container

        A fresh container without network access does one Bash command or ordinary file operation. The next operation gets a fresh container with the same project volume.

      • Project volume

        Bash and ordinary file calls mount the whole volume at /workspace. The opt-in networked Git fetch mounts only its staging directory. Docker keeps the volume between calls and chats.

    • Linux development machine · Optional SSH destination

      The host starts an SSH client. A short-lived Node.js runner on Linux starts Bash or a file helper in the selected project. The Linux account can also run apps under its own Docker engine or service manager.

      • Project folder

        This ordinary Linux folder holds the files the tools edit. A second chat that selects the same project uses those same files.

      • Docker on Linux

        Runs apps you start on this machine, such as the Discourse example below. Docker can mount a project folder so the app sees your edits.

  • Browser tab → Hono · HTTP requests and live updates
  • Node.js → Checkout · Configuration, profiles and client files
  • Pi Durable + Pi AI → Private data · Conversation reads and writes
  • Pi Durable + Pi AI → OpenAI or DeepSeek · Model requests and replies
  • Node.js → Exa · Search queries
  • Node.js → Jina Reader · Page URLs to read
  • Node.js → Host helpers · Local processing and commands
  • Node.js → Local runner · Starts a local tool call
  • Local runner → Local projects · Works in the selected folder
  • Node.js → Docker engine · Docker commands for a tool call
  • Tool container → Project volume · Whole volume mounted at /workspace
  • Node.js → Linux development machine · SSH for a tool call
  • Docker on Linux → Project folder · Apps can mount project files

Node.js

One long-lived process serves the client and runs the conversation. Hono serves the tab at 127.0.0.1:8080 by default. ChatGPT sign-in uses a separate loopback callback on port 1455.

Talks to

Select a box to see what runs there and what it connects to. On a phone, the details sit below the map.

On your Mac or Linux server, start in ~/projects/pipal. That computer is the hostThe computer running the Pipal server process.. The checkout has the source, the profiles in agents/, and your config.toml if you made one. Run pnpm build to create the browser files in packages/web/build. Then pnpm start starts a Node.js process that serves those files. main.ts package.json

Open http://127.0.0.1:8080 on the host and Hono serves the page. When you send a message, Hono hands it to Pipal core, which checks whether the conversation can accept the message and calls Pi Durable to keep track of the work and save its progress. All of that happens inside the same Node.js process. If your browser is on another device, an HTTPS proxy on the host can pass requests to Pipal. Set server.origin to the public HTTPS origin. Deploying Pipal shows that setup. main.ts config.ts

Choose an OpenAI or DeepSeek model and the server sends a request outside your machine. Pi AI sends the model contextThe instructions, messages, and tool information assembled for a model request., including instructions and the messages and tool results in scope. Pipal checks requested host tools against the chat’s grants. README.md index.ts

You can connect OpenAI with ChatGPT sign-in or an API key. Choose Local echo (faux/faux-1) to try a chat on the host alone. It replies inside Node.js with Local echo: followed by the text of your latest user message. Profiles and models covers those choices. models.ts

Deep diveHow the host starts and where it sends work

The package script starts packages/server/src/start.mjs, which imports main.ts in the same process. The config loader resolves the default profile and data paths from the config file’s directory. It defaults the listener to 127.0.0.1:8080. package.json start.mjs config.ts

Hono serves the static build and calls core to submit messages. The browser sends a new chat to the creation route before it submits a message. Core opens Pi Durable with the model registry and checks each tool call against the chat’s profile. The faux provider runs the echo function in the host. app.ts App.svelte index.ts models.ts

For each PDF it prepares, the host forks a new Node.js process running pdf-worker.ts. Parsing can block while it works, so the separate process keeps the server responsive and lets the parent kill a worker that exceeds its deadline. Inside that child process, a separate thread checks how much memory the process is using while the parser works. pdf.ts pdf-worker.ts

For images, Pi Durable uses a Photon worker thread inside the host process. Pipal lets that worker go after 5 seconds idle. Optional Code Mode also runs scripts in a worker thread. uploads.ts README.md main.ts README.md

The host project reader starts rg (ripgrep) for find and grep. Diagnostics launch fixed executables such as /bin/ps and /usr/bin/systemctl. During ChatGPT sign-in, Pi AI owns the loopback callback at 127.0.0.1:1455 in the host process. Pipal can also pass the callback URL to Pi AI when you sign in from a browser on another device. project-search.ts system-diagnostics.ts chatgpt-callback.ts models.ts provider-login.ts

Conversations live in the private data directory

What goes on the host’s disk
  • data/
    Default private directory
    • durable.sqlite
      Conversations and work in progress
      Pi Durable keeps the messages, agent settings, queued work, checkpoints and usage here. SQLite also keeps journal and coordination files beside the database while it is in use.
    • owner.sqlite
      One runtime per directory
      A separate SQLite connection holds an exclusive transaction here. The lock goes away when the owning connection or process ends. The file can stay.
    • access-token
      Workspace sign-in in token mode
      The server creates the token once and reads it on later starts in token mode.
    • passkeys/
      Workspace sign-in in passkey mode
      • auth.sqlite
        Public keys, counters and hostname
      • setup-code
        Issued for first enrollment
      • recovery-code
        Issued on a recovery start
    • chatgpt-auth.json
      Model account sign-in
      When Pi AI asks for a device ID, Pipal saves one if needed. A successful sign-in adds the credential and model list. API-key mode reads its key from the host environment.
    • workspace-settings.json
      Enabled locations and new-chat defaults
      The server saves the workspace settings by renaming a temporary file created with mode 0600.
    • projects/
      Folders for local projects
      • <project>/
        One folder per named project
        Pipal creates the projects root when it probes the local runner. The root and new project folders are created with mode 0700.
    • uploads/
      One folder per upload
      • <uuid>/
        • original
          Original image or PDF bytes
        • metadata.json
          ID, name, type and size
    • extensions/
      State owned by host modules
      • <name>/
        Directory supplied to a module factory
  • Default private directory
    • Conversations and work in progress
    • One runtime per directory
    • Workspace sign-in in token mode
    • Workspace sign-in in passkey mode
    • Model account sign-in
    • Enabled locations and new-chat defaults
    • Folders for local projects
    • One folder per upload
    • State owned by host modules
Open a folder to see what it holds. The sign-in files and tool state depend on which features you enable.

Look beside config.toml for ./data. That’s the default data directoryThe private folder on the host where Pipal keeps conversations, uploads, sign-in records, and other state., and you can move it with storage.data_dir. Pipal creates it for the account that runs the server and refuses to start if the directory is inside the web build. main.ts config.ts

Send a message and Pi Durable writes it to durable.sqlite along with the work needed to answer it. That’s where Pipal can pick things up after a restart. The neighboring owner.sqlite lets one Pipal process use the directory at a time. When that process exits, its lock goes away and the file stays. index.ts store-lock.ts

Attach a PDF and you’ll find a second kind of file in data/. The browser shows uploads/<uuid>/original. Its name, type, size, and ID are in metadata.json. Pi Durable saves the prepared parts with your message so it can include them on later calls. Files in, artifacts out shows how Pipal prepares those parts. uploads.ts index.ts

Deep diveWhat the lock protects and what the host re-creates

Startup sets umask 077, creates the data directory with mode 0700 if it is missing, and rejects a location inside the web build. It leaves existing permissions as they are. On Mac and Linux, startup fails if the group or other users have access. Core opens durable.sqlite through Pi Durable’s SQLite storage adapter. For a message with uploads, the admission commit writes the prepared parts into the model message and saves each upload’s identifying information alongside it. main.ts store-lock.ts index.ts

createRuntime() takes the lock before it loads profiles and extensions and calls loadWorkspaceLocations() to probe enabled locations. The lock is a separate SQLite transaction held until the runtime closes, including while the credential and conversation stores are open. index.ts main.ts

packages/core/src/store-lock.ts
const db = new DatabaseSync(join(dataDir, 'owner.sqlite'));
try {
db.exec('BEGIN EXCLUSIVE');
// …

The lock also covers workspace sign-in records. In token mode, the server loads or creates access-token. In passkey mode, passkeys/auth.sqlite holds the public credential records and the hostname they belong to. Passkey-mode startup removes old one-time code files and writes a new one when setup or recovery calls for it. The separate chatgpt-auth.json holds the device ID and, once connected, the model account credential and discovered models. Module factories receive their own extensions/<name>/ directory. main.ts auth.ts passkey-store.ts credentials.ts extensions.ts

The queue that orders message acceptance and the timers that enforce deadlines live in memory. So do browser sessions, a pending ChatGPT sign-in, and records of passkey enrollments in progress. Passkey flows also use a temporary HttpOnly cookie, pipal_passkey. At start, core reads saved deadlines and arms timers for pending work. The chat search index is another SQLite database, opened as :memory:. Core builds it from saved chat entries as you search, so it needs no file of its own. auth.ts provider-login.ts passkeys.ts index.ts transcript-search.ts

A Node.js compile cache can also exist outside the data directory, under ~/.cache/pipal-node on Linux when the startup checks allow it. That holds compiled code, while durable.sqlite holds your chats. start.mjs

The server marks the session cookie HttpOnly. The browser can send it on requests, and page scripts cannot read it. The browser keeps the selected conversation in session storage. The appearance settings use local storage and can stay when the tab closes. app.ts App.svelte appearance-init.js

The browser keeps the view and the draft

Type a few words without sending them. The Svelte client keeps that draft in session storage, the browser’s storage for this tab. When storage is available, the draft survives a reload in the same tab. Files already uploaded can be restored by ID. Local files that have yet to be uploaded need to be attached again. Your display preferences go in local storage, so they can follow you across tabs and visits. drafts.ts appearance-init.js

After sign-in, the browser holds a pipal_session cookie and the host keeps the matching browser sessionA sign-in record in server memory that the browser refers to with a cookie. in memory. After a restart, sign in again to fetch saved chats. The Svelte workspace follows what the browser loads. auth.ts

Project files live where the tools run

In Settings → Workspace, the signed-in owner enables a locationThe place a chat uses for project tools, either the Pipal host, an account reached over SSH, or a Docker project. for Developer’s project tools. A fresh installation starts with all locations off. The server saves the choices in workspace-settings.json. An upgrade can import a previously configured SSH or Docker grant. DeveloperWorkspace.svelte workspace-locations.ts

On the first Send, creating the chat pins its location and project before the browser submits the message. To switch either, start a new chat. Edits and commands still wait for approval unless you’ve enabled automatic approval for that chat and project. Three ways to touch a project shows what you can enable. App.svelte index.ts

Read on the host. Enable pipal.project-read on the host and grant it to a profile such as Code reviewer. It reads under extensions.coding_root. With a host and profile grant, pipal.workspace reads, lists, and searches text files under extensions.workspace_root. coding.ts workspace.ts

Work in Docker. Bash and ordinary file operations each get a fresh container with the whole volume at /workspace. Both run offline. Settings and Runtime say “Shell commands run without network access.” The Docker project follows a call from startup to cleanup. workspace-choice.ts project-shell.ts

Developer can still look up public documentation in a Docker chat. A compatible model provider can handle search during a reply. With the public-web tools enabled, the Pipal host can send a query to Exa or a page URL to Jina Reader. hosted-search.ts public-web.ts

Work in a development workspace. With This machine, Developer uses a folder under the data directory’s projects/. Commands run as the Pipal service user and can read that account’s files, including durable.sqlite and the saved model login. With SSH machine, tools run in your selected Linux folder as the configured account. Dependencies installed on disk can still be there for the next call in either location. The development workspace follows both paths. development-workspace.ts DeveloperWorkspace.svelte

Deep diveWhat the project tools can do and where they run

loadConfig() accepts one SSH or Docker destination. Docker needs an explicit extensions.enabled grant for pipal.bash or pipal.coding. Either can coexist with This machine. loadWorkspaceLocations() routes one set of tools to the pinned location. If a location’s startup probe fails, it stays enabled and Settings offers Retry connection. config.ts workspace-locations.ts DeveloperWorkspace.svelte

Core checks the profile and binding. read can proceed without approval. edit, write, bash, publish_file, and optional git_clone need approval or a matching automatic grant. publish_file reads from the selected project and stores a copy in the conversation. Approvals and YOLO follows the gate. index.ts project-coding.ts web-artifacts.ts

For each development operation, persistentTools() starts the same Node.js runner directly on the host or through an SSH client. The runner starts Bash or the file helper. Pipal leaves the app’s lifecycle to the programs on that machine. development-workspace.ts development-runner.mjs

Pi’s edit tool can read in one container and write in a second. The host wraps the whole tool in one turn of the project queue, then each file operation invokes project-files.mjs in a fresh container. The worker stages a write next to its destination and renames it into place. That rename is on the project filesystem, outside the transaction that saves the tool result in the conversation. project-coding.ts project-shell.ts project-files.mjs

An abrupt crash can leave a labeled container behind. After restart, Pipal tries to remove any leftovers before creating a new container. If removal fails and containers remain, the new call fails. A failed cleanup after a tool call also triggers a sweep on the next operation. Pipal starts Bash and ordinary file operations with --network=none. The optional git_clone tool uses a networked fetch container with only a staging subdirectory mounted, then publishes the checkout to the volume through an offline operation. project-shell.ts

Both web extensions require an explicit host grant. Developer’s instructions favor hosted search and suggest search_public_web as a fallback. Enabling pipal.public-web also gives Developer read_url for a specific public HTTPS page. The host tools need no API key. Keeping private material out of the query or URL is an instruction to Developer. developer.md public-web.ts

One Mac, one Linux machine, one running Discourse

Inside pipal-dev-check
  • /home/pipal-build/source/
    The project called “source” in the picker
    • discourse/
      Discourse source code
      In this setup, the Docker container discourse_dev sees this same folder at /src. An edit to the Linux folder changes the file the container sees.
    • discourse-dev/
      Scripts for starting and stopping Discourse
    • .pipal-projects/
      Projects you name from chat
      • Project naming demo/
        Already exists
      • pipal-scratch/
        Created if missing on first Send
        Typing a new project name selects a destination. The server opens or creates the folder when the first Send creates the chat.
  • The project called “source” in the picker
    • Discourse source code
    • discourse-dev/
      Scripts for starting and stopping Discourse
    • Projects you name from chat
      • Project naming demo/
        Already exists
      • Created if missing on first Send
The maintainer’s preview setup. All of these paths are on the Linux machine. The Discourse container sees the source at /src.

Where the files live. This is one real setup for SSH machine, as Pipal’s maintainer describes it. Pipal itself runs on the Mac from ~/projects/pipal. OrbStack also runs a small Linux computer on that same Mac, called pipal-dev-check. The config names /home/pipal-build/source source. Pick source in a Developer chat and Pipal connects to that Linux computer and runs commands in that folder. With source first in the list and no projects_root, the first Send for a new project name creates a folder under .pipal-projects/. development-workspace.ts

Where Docker fits. A Pipal project here is an ordinary folder. Docker comes in when you want to run an app. For Discourse, Docker runs a container called discourse_dev. Inside that container, /src points to the same discourse/ folder shown above, so an edit changes the file the app sees. The database has its own Docker-managed storage. That’s why you can close a chat, open another one on the same project, and find both your edits and the running app.

Deep diveWhy this setup puts new projects under .pipal-projects

On the first Send, the browser asks the server to create the chat. Core opens the selected project over SSH before saving the chat and before the browser posts the message. A failed open prevents that chat from being created. The opt-in development workspace test reopens Pipal, reads a file written from an earlier chat, and reaches the service still running on Linux. App.svelte index.ts development-workspace.test.ts

projects maps known names to Linux directories. If there is no projects_root, Pipal takes the first configured project as the base and puts projects named from chat under its .pipal-projects directory. With projects_root set, new project folders go directly under that directory. The runner on Linux creates the folder or reuses an existing directory with that name. A file or symbolic link already using the name blocks creation. development-workspace.ts development-runner.mjs

packages/server/src/development-workspace.ts
const directory = config.projects_root ?? bindings[0]?.directory;
if (!directory) throw new Error('Configure a directory for development projects.');
const nested = !config.projects_root;
const parent = nested ? posix.join(directory, '.pipal-projects') : directory;

Core saves the chat’s location, project name, and scope. The scope ties that name to the SSH destination, account, and remote directory’s identity. The runner checks the identity again before executing a command, so replacing a directory at the same path can invalidate the old binding. Bash runs with the development account’s permissions. The checked working directory gives the command a place to start, and the account determines what else it can reach. index.ts development-workspace.ts development-runner.mjs

When the foreground command ends or the SSH input closes, the runner kills its process group. A detached service started under Docker or a user service manager has an owner of its own. development-runner.mjs

Closing the tab leaves the work on the host

What survives what
FeatureClose tab Stop Pipal Pipal crashes Reboot host Open new chat
Reply in progressKeeps running on the host.Stops. May resume on restart.Stops. May retry on restart.Stops. May resume when Pipal starts again.Keeps running in the old chat.
Saved chatStays on disk.Stays on disk.Committed history stays.Committed history stays on a clean reboot.Old history stays in the old chat.
Browser sessionValid while the cookie and session last.Sign in again.Sign in again.Sign in again.Same sign-in.
Saved project editsStay in the folder or volume. Local projects live in data/projects/ by default.Stay in the project.Completed writes stay.Stay after a clean reboot.Same files if it uses the same location and project.
Docker tool processEnds with the tool command.Pipal attempts to remove the container.May last until timeout or cleanup.Ends if its machine reboots.Ends with the tool command.
Detached Linux serviceKeeps running.Keeps running.Keeps running.Keeps running if its machine stays up.Same app if the service stays up.

Choose up to two columns

Choose up to two columns

FeatureClose tab Stop Pipal Pipal crashes Reboot host Open new chat
Reply in progressKeeps running on the host.Stops. May resume on restart.Stops. May retry on restart.Stops. May resume when Pipal starts again.Keeps running in the old chat.
Saved chatStays on disk.Stays on disk.Committed history stays.Committed history stays on a clean reboot.Old history stays in the old chat.
Browser sessionValid while the cookie and session last.Sign in again.Sign in again.Sign in again.Same sign-in.
Saved project editsStay in the folder or volume. Local projects live in data/projects/ by default.Stay in the project.Completed writes stay.Stay after a clean reboot.Same files if it uses the same location and project.
Docker tool processEnds with the tool command.Pipal attempts to remove the container.May last until timeout or cleanup.Ends if its machine reboots.Ends with the tool command.
Detached Linux serviceKeeps running.Keeps running.Keeps running.Keeps running if its machine stays up.Same app if the service stays up.
The host and the project have separate lifetimes. Assumes Pipal accepted the message and the disks are intact.

Close the tab halfway through an answer and Pipal can finish without you. The tab was watching the work of answering your message, called a run. If you want to stop that work, use the chat’s Stop button. Ctrl+C in the server’s terminal starts shutdown. App.svelte main.ts

Start Pipal again and it can pick up saved work. The host checks the saved deadline, and a reply interrupted mid-stream may need a fresh model request. An interrupted edit can leave a write on disk without a tool result in the chat. index.ts recovery.test.ts

Reboot the Mac in the maintainer’s setup and Discourse stops along with its Linux machine. Whether it starts up again depends on how the service was set up. Files stay on disk through a clean reboot. Sudden power loss can cost you a recent SQLite commit. README.md

If you lose the host’s disk, you need a copy of the private data directory to restore the chats. That copy can include local projects under projects/. Back up SSH project folders and Docker project volumes from the machines that hold them. When things go wrong covers what to recover. backup.md

Deep diveA saved run and a saved file recover separately

A stream disconnect ends the watch. A chat Stop aborts the run, and Ctrl+C starts host shutdown. On startup, the deadline check can abort pending work that has expired, while a parked approval can keep waiting. app.ts index.ts main.ts

Pi Durable can lose visible text that has yet to reach disk. On recovery it can try a model request again, but an interrupted tool that writes external state can leave its effects behind without replaying the call. The recovery tests exercise both cases with a process kill. A project service has a separate owner on the development machine and can outlive the SSH command that started it. README.md recovery.test.ts development-runner.mjs

When Pipal starts again, how does it decide whether to retry the model, leave an approval waiting, or report an interrupted tool? Durable by default follows the records that make that decision possible.

Recap

  • The host’s Node.js process runs the conversation. A remote model receives the context for each call.
  • Chats live in durable.sqlite. Browser drafts, sessions, and project files each have their own home.
  • The Docker project keeps files in a volume. A development workspace keeps files in an ordinary folder on the host or the SSH machine.
Check yourself
  1. You close the tab while Pipal is answering an accepted message. Where can you find the answer later?
    • The original tab’s session storage
    • The saved chat on the host
    • The project folder on disk
    Answer and explanation

    The saved chat on the host

    The tab watches work owned by the host. When the run finishes, Pi Durable saves the answer with the conversation.

  2. A Bash call saves a dependency under /workspace in the Docker project. What will the next Bash call see?
    • The same running container
    • A fresh, empty volume
    • New container, same files
    Answer and explanation

    New container, same files

    Each Bash call starts a fresh container. Docker mounts the same volume at /workspace, so files saved there are available to the next call.

  3. In the maintainer’s example, you restart Pipal and open a new chat on source over SSH while Discourse stays up. Which piece still owns the running Discourse app?
    • Docker on the Linux machine
    • The new Pipal process
    • The old chat in durable.sqlite
    Answer and explanation

    Docker on the Linux machine

    The Linux machine and its Docker engine stayed up. The new chat selects the same project folder while Docker continues running the app.

  1. You close the tab while Pipal is answering an accepted message. Where can you find the answer later?

  2. A Bash call saves a dependency under /workspace in the Docker project. What will the next Bash call see?

  3. In the maintainer’s example, you restart Pipal and open a new chat on source over SSH while Discourse stays up. Which piece still owns the running Discourse app?

In the source

Book contents

Search the book