# mariagorskikh/open-instinct architecture

> Architecture diagram of the GitHub repository mariagorskikh/open-instinct, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mariagorskikh/open-instinct
- Repository: https://github.com/mariagorskikh/open-instinct

## Overview

Open Instinct is a personal agent reached by messaging, hosted either locally or in a per-person Maritime microVM. The main workflow is a user message arriving through Inkbox or WhatsApp, reaching the server and agent runtime, then being handled under trust and policy controls before tools act; the response returns through a messaging channel. Other documented branches include agent-to-agent coordination, scheduled tasks, desktop work, app integrations, payments, calls, PDFs, and multi-user signup. Some links use README-level evidence because implementation excerpts are partial or absent.

Main entry points: [`packages/core/src/runtime.ts`](https://github.com/mariagorskikh/open-instinct/blob/main/packages/core/src/runtime.ts) (Pi agent loop), [`packages/server/src/boot.ts`](https://github.com/mariagorskikh/open-instinct/blob/main/packages/server/src/boot.ts) (Agent server), [`packages/gateway/src/server.ts`](https://github.com/mariagorskikh/open-instinct/blob/main/packages/gateway/src/server.ts) (Multi-user gateway), [`packages/inkbox/src/channel.ts`](https://github.com/mariagorskikh/open-instinct/blob/main/packages/inkbox/src/channel.ts) (Inkbox identity)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingress["Messaging and hosting"]
  node_inkbox["Inkbox identity<br/>[channel.ts]"]
  node_whatsapp["WhatsApp channel<br/>[channel.ts]"]
  node_gateway["Multi-user gateway<br/>[server.ts]"]
  node_maritime["Maritime microVM<br/>[maritime.ts]"]
  node_server["Agent server<br/>[boot.ts]"]
end

subgraph group_agent["Agent runtime"]
  node_runtime["Pi agent loop<br/>[runtime.ts]"]
  node_prompt["Persona and prompt<br/>[prompt.ts]"]
  node_state[("Agent state<br/>[state.ts]")]
  node_scheduler["Scheduled tasks<br/>[scheduler.ts]"]
  node_memory[("Memory<br/>[memory.ts]")]
end

subgraph group_trust["Trust and coordination"]
  node_policy["Policy engine<br/>[policy.ts]"]
  node_approvals["Owner approvals<br/>[approvals.ts]"]
  node_audit[("Audit log<br/>[audit.ts]")]
  node_network["Contacts and A2A<br/>[tools.ts]"]
end

subgraph group_capabilities["Agent capabilities"]
  node_computer["Linux desktop<br/>[desktopd.ts]"]
  node_apps["Composio apps<br/>[composio.ts]"]
  node_payments["Stripe Link wallet<br/>[tools.ts]"]
  node_ample["Ample tools<br/>[tools.ts]"]
  node_pdf["PDF creation<br/>[pdf.ts]"]
  node_callhandling["Voice call outcomes<br/>[events.ts]"]
end

subgraph group_operations["Setup and provisioning"]
  node_gatewaystore[("Gateway user store<br/>[store.ts]")]
  node_cli["Instinct CLI<br/>[dev.ts]"]
  node_inkboxprovision["Identity provisioning<br/>[provisioner.ts]"]
end

node_user(("Owner or contact"))

node_user -->|"texts"| node_inkbox
node_inkbox -->|"wakes and relays"| node_gateway
node_gateway -->|"forwards messages"| node_server
node_user -->|"messages"| node_whatsapp
node_whatsapp -.->|"delivers events"| node_server
node_maritime -->|"hosts agent"| node_server
node_server -->|"boots"| node_runtime
node_runtime -->|"builds context"| node_prompt
node_runtime -->|"checks tool access"| node_policy
node_runtime -->|"requests approval"| node_approvals
node_runtime -->|"records actions"| node_audit
node_runtime -->|"reads and writes"| node_state
node_runtime -->|"uses memory"| node_memory
node_runtime -->|"uses schedules"| node_scheduler
node_runtime -->|"operates desktop"| node_computer
node_runtime -->|"uses connected apps"| node_apps
node_runtime -->|"requests payments"| node_payments
node_runtime -.->|"uses tools"| node_ample
node_runtime -->|"creates PDFs"| node_pdf
node_runtime -->|"coordinates agents"| node_network
node_network -->|"sends agent messages"| node_inkbox
node_runtime -->|"handles call outcomes"| node_callhandling
node_cli -->|"starts local agent"| node_server
node_gateway -->|"loads users"| node_gatewaystore
node_gateway -->|"provisions identities"| node_inkboxprovision
node_cli -->|"provisions identity"| node_inkboxprovision

click node_inkbox "https://github.com/mariagorskikh/open-instinct/blob/main/packages/inkbox/src/channel.ts"
click node_whatsapp "https://github.com/mariagorskikh/open-instinct/blob/main/packages/whatsapp/src/channel.ts"
click node_gateway "https://github.com/mariagorskikh/open-instinct/blob/main/packages/gateway/src/server.ts"
click node_maritime "https://github.com/mariagorskikh/open-instinct/blob/main/packages/computer/src/maritime.ts"
click node_server "https://github.com/mariagorskikh/open-instinct/blob/main/packages/server/src/boot.ts"
click node_runtime "https://github.com/mariagorskikh/open-instinct/blob/main/packages/core/src/runtime.ts"
click node_prompt "https://github.com/mariagorskikh/open-instinct/blob/main/packages/core/src/prompt.ts"
click node_state "https://github.com/mariagorskikh/open-instinct/blob/main/packages/core/src/state.ts"
click node_policy "https://github.com/mariagorskikh/open-instinct/blob/main/packages/core/src/policy.ts"
click node_approvals "https://github.com/mariagorskikh/open-instinct/blob/main/packages/core/src/approvals.ts"
click node_audit "https://github.com/mariagorskikh/open-instinct/blob/main/packages/core/src/audit.ts"
click node_network "https://github.com/mariagorskikh/open-instinct/blob/main/packages/network/src/tools.ts"
click node_scheduler "https://github.com/mariagorskikh/open-instinct/blob/main/packages/core/src/scheduler.ts"
click node_memory "https://github.com/mariagorskikh/open-instinct/blob/main/packages/core/src/memory.ts"
click node_computer "https://github.com/mariagorskikh/open-instinct/blob/main/packages/computer/src/desktopd.ts"
click node_apps "https://github.com/mariagorskikh/open-instinct/blob/main/packages/apps/src/composio.ts"
click node_payments "https://github.com/mariagorskikh/open-instinct/blob/main/packages/payments/src/tools.ts"
click node_ample "https://github.com/mariagorskikh/open-instinct/blob/main/packages/ample/src/tools.ts"
click node_pdf "https://github.com/mariagorskikh/open-instinct/blob/main/packages/core/src/pdf.ts"
click node_gatewaystore "https://github.com/mariagorskikh/open-instinct/blob/main/packages/gateway/src/store.ts"
click node_cli "https://github.com/mariagorskikh/open-instinct/blob/main/packages/cli/src/commands/dev.ts"
click node_inkboxprovision "https://github.com/mariagorskikh/open-instinct/blob/main/packages/inkbox/src/provisioner.ts"
click node_callhandling "https://github.com/mariagorskikh/open-instinct/blob/main/packages/inkbox/src/events.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_inkbox,node_whatsapp,node_gateway,node_maritime,node_server toneBlue
class node_runtime,node_prompt,node_state,node_scheduler,node_memory toneAmber
class node_policy,node_approvals,node_audit,node_network toneMint
class node_computer,node_apps,node_payments,node_ample,node_pdf,node_callhandling toneRose
class node_gatewaystore,node_cli,node_inkboxprovision,node_user toneIndigo
```

## Components

### Messaging and hosting

- [Inkbox identity](https://github.com/mariagorskikh/open-instinct/blob/main/packages/inkbox/src/channel.ts): `packages/inkbox/src/channel.ts`
- [WhatsApp channel](https://github.com/mariagorskikh/open-instinct/blob/main/packages/whatsapp/src/channel.ts): `packages/whatsapp/src/channel.ts`
- [Multi-user gateway](https://github.com/mariagorskikh/open-instinct/blob/main/packages/gateway/src/server.ts): `packages/gateway/src/server.ts`
- [Maritime microVM](https://github.com/mariagorskikh/open-instinct/blob/main/packages/computer/src/maritime.ts): `packages/computer/src/maritime.ts`
- [Agent server](https://github.com/mariagorskikh/open-instinct/blob/main/packages/server/src/boot.ts): `packages/server/src/boot.ts`

### Agent runtime

- [Pi agent loop](https://github.com/mariagorskikh/open-instinct/blob/main/packages/core/src/runtime.ts): `packages/core/src/runtime.ts`
- [Persona and prompt](https://github.com/mariagorskikh/open-instinct/blob/main/packages/core/src/prompt.ts): `packages/core/src/prompt.ts`
- [Agent state](https://github.com/mariagorskikh/open-instinct/blob/main/packages/core/src/state.ts): `packages/core/src/state.ts`
- [Scheduled tasks](https://github.com/mariagorskikh/open-instinct/blob/main/packages/core/src/scheduler.ts): `packages/core/src/scheduler.ts`
- [Memory](https://github.com/mariagorskikh/open-instinct/blob/main/packages/core/src/memory.ts): `packages/core/src/memory.ts`

### Trust and coordination

- [Policy engine](https://github.com/mariagorskikh/open-instinct/blob/main/packages/core/src/policy.ts): `packages/core/src/policy.ts`
- [Owner approvals](https://github.com/mariagorskikh/open-instinct/blob/main/packages/core/src/approvals.ts): `packages/core/src/approvals.ts`
- [Audit log](https://github.com/mariagorskikh/open-instinct/blob/main/packages/core/src/audit.ts): `packages/core/src/audit.ts`
- [Contacts and A2A](https://github.com/mariagorskikh/open-instinct/blob/main/packages/network/src/tools.ts): `packages/network/src/tools.ts`

### Agent capabilities

- [Linux desktop](https://github.com/mariagorskikh/open-instinct/blob/main/packages/computer/src/desktopd.ts): `packages/computer/src/desktopd.ts`
- [Composio apps](https://github.com/mariagorskikh/open-instinct/blob/main/packages/apps/src/composio.ts): `packages/apps/src/composio.ts`
- [Stripe Link wallet](https://github.com/mariagorskikh/open-instinct/blob/main/packages/payments/src/tools.ts): `packages/payments/src/tools.ts`
- [Ample tools](https://github.com/mariagorskikh/open-instinct/blob/main/packages/ample/src/tools.ts): `packages/ample/src/tools.ts`
- [PDF creation](https://github.com/mariagorskikh/open-instinct/blob/main/packages/core/src/pdf.ts): `packages/core/src/pdf.ts`
- [Voice call outcomes](https://github.com/mariagorskikh/open-instinct/blob/main/packages/inkbox/src/events.ts): `packages/inkbox/src/events.ts`

### Setup and provisioning

- [Gateway user store](https://github.com/mariagorskikh/open-instinct/blob/main/packages/gateway/src/store.ts): `packages/gateway/src/store.ts`
- [Instinct CLI](https://github.com/mariagorskikh/open-instinct/blob/main/packages/cli/src/commands/dev.ts): `packages/cli/src/commands/dev.ts`
- [Identity provisioning](https://github.com/mariagorskikh/open-instinct/blob/main/packages/inkbox/src/provisioner.ts): `packages/inkbox/src/provisioner.ts`

### Other components

- **Owner or contact**

## Connections

- Owner or contact → Inkbox identity: texts
- Inkbox identity → Multi-user gateway: wakes and relays
- Multi-user gateway → Agent server: forwards messages
- Owner or contact → WhatsApp channel: messages
- WhatsApp channel → Agent server: delivers events
- Maritime microVM → Agent server: hosts agent
- Agent server → Pi agent loop: boots (evidence: `packages/server/src/boot.ts`)
- Pi agent loop → Persona and prompt: builds context (evidence: `packages/core/src/runtime.ts`)
- Pi agent loop → Policy engine: checks tool access (evidence: `packages/core/src/runtime.ts`)
- Pi agent loop → Owner approvals: requests approval (evidence: `packages/core/src/runtime.ts`)
- Pi agent loop → Audit log: records actions (evidence: `packages/core/src/runtime.ts`)
- Pi agent loop → Agent state: reads and writes (evidence: `packages/core/src/runtime.ts`)
- Pi agent loop → Memory: uses memory (evidence: `packages/core/src/runtime.ts`)
- Pi agent loop → Scheduled tasks: uses schedules (evidence: `packages/core/src/runtime.ts`)
- Pi agent loop → Linux desktop: operates desktop
- Pi agent loop → Composio apps: uses connected apps
- Pi agent loop → Stripe Link wallet: requests payments
- Pi agent loop → Ample tools: uses tools
- Pi agent loop → PDF creation: creates PDFs
- Pi agent loop → Contacts and A2A: coordinates agents
- Contacts and A2A → Inkbox identity: sends agent messages (evidence: `packages/network/src/tools.ts`)
- Pi agent loop → Voice call outcomes: handles call outcomes
- Instinct CLI → Agent server: starts local agent (evidence: `packages/cli/src/commands/dev.ts`)
- Multi-user gateway → Gateway user store: loads users (evidence: `packages/gateway/src/main.ts`)
- Multi-user gateway → Identity provisioning: provisions identities
- Instinct CLI → Identity provisioning: provisions identity
