Skip to content

Commit 4815d53

Browse files
committed
Persistent background session with multi-image support
1 parent cd0cac3 commit 4815d53

2 files changed

Lines changed: 305 additions & 183 deletions

File tree

pi/README.md

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44

55
## What it does
66

7-
Registers a `glance` **tool** and a `/glance` **command**:
7+
Maintains a **persistent background session** on glance.sh. Paste an image anytime — the agent receives it instantly.
88

9-
- **Tool** — the LLM calls it when it needs to see something visual (your screen, a UI, an error dialog). The agent creates a session, you paste a screenshot in your browser, the agent receives the image URL.
10-
- **Command** — you type `/glance` in the pi prompt to proactively share a screenshot with the agent.
9+
- **Background listener** — starts when pi launches, reconnects automatically, refreshes sessions before they expire.
10+
- **`glance` tool** — the LLM calls it when it needs to see something visual. Surfaces the session URL and waits for the next paste.
11+
- **`/glance` command** — type it to see the current session URL.
12+
- **Multiple images** — paste as many images as you want. Each one is injected into the conversation as `Screenshot: <url>`.
1113

1214
## Install
1315

@@ -21,24 +23,32 @@ ln -s "$(pwd)/glance.ts" ~/.pi/extensions/glance.ts
2123
cp glance.ts ~/.pi/extensions/glance.ts
2224
```
2325

24-
Restart pi. The `glance` tool and `/glance` command are now available.
26+
Restart pi. The background session starts automatically.
2527

2628
## How it works
2729

2830
```
29-
agent ──POST /api/session──▶ { id, url }
30-
agent ──GET /api/session/<id>/events──▶ SSE (waiting…)
31-
user ──opens /s/<id>, pastes image──▶ agent receives URL
32-
```
31+
pi starts
32+
└─▶ create session on glance.sh
33+
└─▶ connect SSE (background, auto-reconnect)
3334
34-
1. Creates a live session on glance.sh.
35-
2. Shows you the session URL (status bar + notification).
36-
3. Connects via SSE and waits up to ~5 minutes.
37-
4. When you paste an image, the URL is returned to the LLM.
35+
user pastes image at /s/<id>
36+
└─▶ SSE emits "image" event
37+
└─▶ extension injects "Screenshot: <url>" into conversation
3838
39-
No API keys required — sessions are anonymous and ephemeral (10-minute TTL).
39+
session expires (~10 min)
40+
└─▶ extension creates new session, reconnects
41+
```
42+
43+
The `glance` tool reuses the existing background session — it just surfaces the URL and waits for the next image rather than creating a new session each time.
4044

4145
## Requirements
4246

4347
- [pi](https://github.com/mariozechner/pi) coding agent
4448
- Node.js with global `fetch` (Node 18+)
49+
50+
## Configuration
51+
52+
No API keys required — sessions are anonymous and ephemeral (10-minute TTL).
53+
54+
The extension connects to `https://glance.sh` by default. The SSE connection is held for ~5 minutes per cycle, with automatic reconnection.

0 commit comments

Comments
 (0)