pi-gpt
Native Pi extension: drive your ChatGPT/Codex account (chat, deep research, account, models) as Pi tools, scoped to the current project.
Package details
Install pi-gpt from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-gpt- Package
pi-gpt- Version
0.3.2- Published
- Jul 21, 2026
- Downloads
- 267/mo · 43/wk
- Author
- davidroman
- License
- MIT
- Types
- extension, skill
- Size
- 155.8 KB
- Dependencies
- 0 dependencies · 2 peers
Pi manifest JSON
{
"extensions": [
"extensions/chatgpt.ts",
"extensions/observer.ts"
],
"skills": [
"skills/chatgpt"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-gpt
A native Pi extension that drives a ChatGPT / Codex account as Pi tools.
Inspect the account, list models, start or continue chats (normal, agent, deep
research, deep-research heavy), pick an intelligence level, and read back
conversation history — all scoped to the current project. No API key needed: it
reuses codex login (~/.codex/auth.json).
Native Pi package — no separate process, no MCP stdio. Loaded directly into Pi as a TypeScript extension. Talk to chatgpt.com with plain
fetch(no TLS impersonation, no native deps).
Install
pi install /path/to/pi-gpt # local
# or, once published:
pi install npm:pi-gpt
Then in Pi, the tools gpt_account_status, gpt_list_models, gpt_chat,
gpt_list_chats, gpt_get_conversation, gpt_get_message are available, plus
the /skill:chatgpt skill.
Requires a ChatGPT login:
codex login # writes ~/.codex/auth.json, shared with pi-gpt
Tools
| Tool | Purpose |
|---|---|
gpt_account_status |
Plan, email, expiry, features of the connected account. |
gpt_list_models |
Available models with slug + thinking-effort options. |
gpt_chat |
Start/continue a chat: normal | agent | deep_research | deep_research_heavy. Accepts prompt_file and attach for file inputs. |
gpt_list_chats |
Chats started from the current project path. |
gpt_get_conversation |
Message history of a conversation. |
gpt_get_message |
A single message by id. |
Intelligence levels (gpt_chat)
instant → medium → high → extra_high → pro. Each maps to a model and a
thinking effort; pro uses gpt-5-5-pro. For normal chats, pass an explicit
model slug plus thinking_effort (min | standard | extended | max)
to pin both values; use an effort listed by gpt_list_models for that model.
Deep-research chat types use their own models and ignore these settings.
high/extra_high (extended/max thinking)
are returned asynchronously — the tool auto-polls the conversation so you
still get the answer.
File inputs (gpt_chat)
prompt_file— path to a text file whose contents are appended to the prompt (long prompts, code pastes). Eitherpromptorprompt_filerequired.attach— array of local file paths (images, PDFs, docs, code, data) to upload and attach. Images go asmultimodal_text; other files as document attachments. Works for normal/agent chats.
Upload is a 3-step Azure-blob flow (POST /files → PUT blob → confirm), with
no native deps.
Long-running research
deep_research_heavy can run 30–60+ min. Set max_wait_minutes (default 90) —
it won't blindly kill active research: a heartbeat keeps the run visibly alive,
Esc aborts, and on timeout it returns the partial result plus the
conversation_id so you can retrieve the completed report later via
gpt_get_conversation.
Project-scoped chats
Every chat gpt_chat creates is indexed by the working directory it ran in.
gpt_list_chats returns only the chats for the current project, so you can keep
per-repo threads separate. The index lives at ~/.pi-gpt/registry.json.
Observer — struggle detection (experimental, off by default)
A silent supervisor that reads the agent's visible messages with a model,
detects sustained struggle, and nudges it to ask for help — ask you, consult
gpt_chat, or run Deep Research. Think of it as pushing an introvert model to
socialize. It is not a keyword matcher: a model judges each turn, and
healthy exploration / confident bug diagnoses never count as struggle
(validated: 0 false positives on real session messages).
- Off by default. Enable with
/gpt-observer. A status-bar line shows👁 observer: off/on · <mode> · <model>(set on session start, refreshed from the menu). - Passive first: the default delivery mode is
notify(surfaces to you); flip tosteerto push the agent, ornextTurnto queue a nudge. - The detector picks who to ask (user /
gpt_chat/ Deep Research) from the kind of struggle; the delivery mode picks how. - Smart, not a counter: acts only on sustained struggle (
minStreak, default- with a cooldown (default 6 turns), skips turns where the agent already sought help, and never crashes the agent (fail-silent).
- State/config at
~/.pi-gpt/observer/(config.json,state.json,log.jsonl).
/gpt-observer # interactive menu: enable, delivery mode, detector
# model, sensitivity, streak, window, cooldown, status
How it works
- Auth: reads the access token from
~/.codex/auth.json(honorsCODEX_HOMEfor multi-account) and re-reads it on mtime change so codex's background refresh can't 401 mid-request. - Sentinel gate: solves the chatgpt.com proof-of-work (SHA3-512) and
turnstile challenge, ported to
node:crypto. - Streaming: SSE parsed over
fetchweb streams for chat, agent, and both deep-research paths (including the delta-patchv1encoding and widget-state report recovery for heavy DR). - File upload: 3-step Azure-blob upload with a no-dep image-dimension reader (PNG/JPEG/GIF/BMP/WebP) for image attachments.
- Redaction: tool output masks emails, phone numbers, and secrets (JWT, bearer tokens, API keys, GitHub tokens).
Status & limits
Native port of the conversation engine, proven live: account, models, normal /
thinking chat (incl. extended & max), multi-turn + cross-type continuation
(including normal follow-ups and sequential Heavy Research turns in one thread),
light & heavy deep research (heavy completed in ~11 min end-to-end), file inputs, and
the project-scoped registry. Deep-research heavy consumes the account's monthly
DR quota — check it at chatgpt.com → Settings → Connectors. Tool output is
PII-redacted.
License
MIT.