@zetaloop/chappie 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -7
- package/docs/tools.md +55 -68
- package/package.json +3 -1
- package/src/broker.ts +240 -50
- package/src/config.ts +21 -0
- package/src/delivery.ts +27 -56
- package/src/index.ts +15 -10
- package/src/instructions.md +8 -4
- package/src/ipc.ts +144 -41
- package/src/provider.ts +3 -5
- package/src/question.html +384 -0
- package/src/questions.ts +95 -0
- package/src/server.ts +250 -69
- package/src/session.ts +131 -67
- package/src/state.ts +104 -9
- package/src/stdio.ts +11 -2
- package/src/tools.ts +6 -23
- package/src/transfer.ts +3 -3
package/README.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
# Chappie
|
|
2
2
|
|
|
3
|
-
Use ChatGPT to
|
|
3
|
+
Use ChatGPT to work through [Pi](https://github.com/earendil-works/pi): edit local files, run commands, call Pi extensions, exchange files and images, and move between sessions on one or more devices.
|
|
4
4
|
|
|
5
5
|
## Setup
|
|
6
6
|
|
|
7
|
-
Install
|
|
7
|
+
Install the Pi package:
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
10
|
pi install npm:@zetaloop/chappie
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Run Chappie as the MCP server managed by [otunnel](https://github.com/zetaloop/otunnel):
|
|
14
14
|
|
|
15
15
|
```yaml
|
|
16
16
|
mcp:
|
|
@@ -19,16 +19,36 @@ mcp:
|
|
|
19
19
|
command: pi --chappie
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
Add the tunnel as a developer-mode app in ChatGPT, then start Pi in a project:
|
|
23
23
|
|
|
24
24
|
```sh
|
|
25
25
|
pi --provider chappie --model chatgpt
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
Call `init` from ChatGPT to connect the conversation to Pi. A conversation can resume an existing task with its Pi session ID, while `sessions` can find connected sessions by device, directory, or name.
|
|
29
29
|
|
|
30
30
|
## Usage
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
Chappie exposes common coding tools directly and every active Pi tool through `tools` and `call`. `chat` sends an assistant message to Pi, Pi input accompanies later tool results, and `transfer` moves files in either direction. `ask` can present a persistent question in ChatGPT when webpage questions are enabled.
|
|
33
33
|
|
|
34
|
-
See the [tool guide](docs/tools.md) for session selection,
|
|
34
|
+
See the [tool guide](docs/tools.md) for session selection, Pi tools, webpage questions, and file transfer.
|
|
35
|
+
|
|
36
|
+
## Configuration
|
|
37
|
+
|
|
38
|
+
`chappie.json` in Pi's agent directory configures Chappie.
|
|
39
|
+
|
|
40
|
+
A broker can accept Pi sessions from other devices on the local network:
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
{ "listen": true }
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Remote Pi sessions connect through the broker device's mDNS name:
|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
{ "connect": "<broker>.local" }
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The default port is `24274`. Set `listen` to a port number or append `:port` to `connect` to use another one. Only the broker device runs otunnel; local and remote sessions appear in the same session list.
|
|
53
|
+
|
|
54
|
+
Set `ask` to `false` to disable webpage questions. Set `latestWorkflow` to `true` to let a newer otunnel workflow supersede older requests from the same ChatGPT conversation.
|
package/docs/tools.md
CHANGED
|
@@ -2,58 +2,40 @@
|
|
|
2
2
|
|
|
3
3
|
| Tool | Purpose |
|
|
4
4
|
|---|---|
|
|
5
|
-
| `init` |
|
|
6
|
-
| `sessions` | List connected Pi sessions and the
|
|
7
|
-
| `tools` | Read
|
|
5
|
+
| `init` | Select this ChatGPT conversation's default Pi session and read its environment. |
|
|
6
|
+
| `sessions` | List connected Pi sessions and the current default. |
|
|
7
|
+
| `tools` | Read full definitions of active Pi tools for `call`. |
|
|
8
8
|
| `chat` | Send an assistant message to Pi. |
|
|
9
|
-
| `
|
|
9
|
+
| `ask` | Create a persistent question in ChatGPT. |
|
|
10
|
+
| `ask_assert` | Confirm that an `ask` widget loaded. |
|
|
11
|
+
| `call` | Run one or more Pi tools as one native batch. |
|
|
10
12
|
| `read` | Read local text or images. |
|
|
11
|
-
| `bash` |
|
|
13
|
+
| `bash` | Run a shell command. |
|
|
12
14
|
| `edit` | Apply text replacements. |
|
|
13
15
|
| `write` | Write text to a file. |
|
|
14
|
-
| `transfer` |
|
|
15
|
-
|
|
16
|
-
## Model environment
|
|
17
|
-
|
|
18
|
-
The active model is the current ChatGPT conversation. A Pi tool that starts another `chappie/chatgpt` agent cannot create a new browser conversation, so that child waits without a model response. Subagents configured with another provider use that provider normally.
|
|
19
|
-
|
|
20
|
-
Use ChatGPT's web search, connectors, and cloud tools for remote research and cloud-side work. Chappie tools operate on local files, processes, Pi extensions, and Pi user interfaces. Pi project-memory tools access their local stores; Pi context-reduction tools do not alter the current ChatGPT conversation.
|
|
21
|
-
|
|
22
|
-
Use `chat` for progress or results that should appear in Pi. When a Pi user decision is needed, load the installed interactive tool definition with `tools` and invoke it through `call`.
|
|
16
|
+
| `transfer` | Move files between ChatGPT and Pi or export a Pi image. |
|
|
23
17
|
|
|
24
18
|
## Sessions
|
|
25
19
|
|
|
26
|
-
Call `init`
|
|
27
|
-
|
|
28
|
-
`sessions` lists session IDs, working directories, names, and status. `ready` means the provider is accepting output, `executing` means Pi is handling an operation, and `idle` means the next operation will start a turn.
|
|
29
|
-
|
|
30
|
-
Use an ID from that list to select a default with `init`:
|
|
31
|
-
|
|
32
|
-
```json
|
|
33
|
-
{ "sessionId": "<session-id>" }
|
|
34
|
-
```
|
|
20
|
+
Call `init` at the start of local work. Without `sessionId`, it reuses the conversation's saved default or selects an online Pi session with no saved ChatGPT binding. Pass a Pi session ID to resume a specific task, including from another ChatGPT conversation or branch.
|
|
35
21
|
|
|
36
|
-
|
|
22
|
+
`sessions` lists connected sessions with their ID, device, working directory, name, execution status, and binding count. A conversation can address another session for one operation by supplying that tool's optional `sessionId`; only `init({ sessionId })` changes the saved default.
|
|
37
23
|
|
|
38
|
-
|
|
39
|
-
{ "path": "package.json", "sessionId": "<session-id>" }
|
|
40
|
-
```
|
|
24
|
+
Several ChatGPT conversations can use the same Pi session. One conversation can also operate on several Pi sessions explicitly. Requests already assigned to a session continue there even if the conversation later changes its default.
|
|
41
25
|
|
|
42
|
-
|
|
26
|
+
Remote Pi sessions appear in the same list when they connect to a broker exposed through `listen` and `connect`. Their tools, global `AGENTS.md`, files, images, and Pi interfaces come from the remote device.
|
|
43
27
|
|
|
44
|
-
|
|
28
|
+
## Pi tools
|
|
45
29
|
|
|
46
|
-
|
|
30
|
+
`read`, `bash`, `edit`, `write`, and `transfer` are available directly. `init` includes a short catalog of the active Pi tools; use `tools` for their complete definitions and `call` to invoke extension tools.
|
|
47
31
|
|
|
48
|
-
|
|
32
|
+
For example:
|
|
49
33
|
|
|
50
34
|
```json
|
|
51
35
|
{ "names": ["ask_user", "ctx_search"] }
|
|
52
36
|
```
|
|
53
37
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
A single extension tool uses a one-item `calls` array. To request a batch:
|
|
38
|
+
A `call` array is one Pi tool batch:
|
|
57
39
|
|
|
58
40
|
```json
|
|
59
41
|
{
|
|
@@ -64,46 +46,53 @@ A single extension tool uses a one-item `calls` array. To request a batch:
|
|
|
64
46
|
}
|
|
65
47
|
```
|
|
66
48
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
Extension tools execute through Pi, including their interactive prompts. Results include each tool's name, call ID, error status, and original text or image content.
|
|
70
|
-
|
|
71
|
-
ChatGPT file inputs use the direct `transfer` tool. Its top-level `files` parameter lets the host prepare the files before sending them to Pi.
|
|
49
|
+
Pi controls execution inside that batch. Separate requests run in order within one Pi session, while different Pi sessions can work independently. Extension tools retain their native Pi behavior, including interactive interfaces.
|
|
72
50
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
Call `chat` to display a reply in Pi:
|
|
51
|
+
`chat` creates a normal assistant message in Pi:
|
|
76
52
|
|
|
77
53
|
```json
|
|
78
54
|
{ "text": "Updated the parser and its callers." }
|
|
79
55
|
```
|
|
80
56
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
User messages consumed by Pi accompany later Chappie replies, including images. Steering is delivered when Pi consumes it; follow-up uses Pi's normal follow-up timing.
|
|
57
|
+
Pi user input consumed during the work accompanies later Chappie results, including images. Steering and follow-up follow Pi's own delivery timing.
|
|
84
58
|
|
|
85
|
-
|
|
59
|
+
If a request is explicitly cancelled after local work has produced results, those results can accompany a later response to the originating ChatGPT conversation. Long-running local work is better run through the environment's persistent process facilities instead of occupying one tool request.
|
|
86
60
|
|
|
87
|
-
|
|
61
|
+
The active model remains the current ChatGPT conversation. Starting another `chappie/chatgpt` agent inside Pi does not create another browser conversation; tools that need another model should use a separately configured provider.
|
|
88
62
|
|
|
89
|
-
##
|
|
63
|
+
## Webpage questions
|
|
90
64
|
|
|
91
|
-
`
|
|
92
|
-
|
|
93
|
-
### ChatGPT to Pi
|
|
94
|
-
|
|
95
|
-
Supply matching `paths` and `files` arrays:
|
|
65
|
+
When enabled, `ask` creates a question in ChatGPT and returns its ID immediately:
|
|
96
66
|
|
|
97
67
|
```json
|
|
98
68
|
{
|
|
99
|
-
"
|
|
100
|
-
"
|
|
69
|
+
"header": "Export format",
|
|
70
|
+
"question": "Which export format should the command use?",
|
|
71
|
+
"context": "Both preserve the required data.",
|
|
72
|
+
"options": [
|
|
73
|
+
{ "title": "JSON", "description": "Convenient for programs.", "recommended": true },
|
|
74
|
+
{ "title": "CSV", "description": "Convenient for spreadsheets." }
|
|
75
|
+
]
|
|
101
76
|
}
|
|
102
77
|
```
|
|
103
78
|
|
|
104
|
-
`
|
|
79
|
+
Call `ask_assert` with the returned ID to confirm that the widget loaded:
|
|
105
80
|
|
|
106
|
-
|
|
81
|
+
```json
|
|
82
|
+
{ "questionId": "<question-id>" }
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Answers, revisions, and skips arrive later as `webAnswer` in normal Chappie results. `options` can be omitted for a text answer, and `allowMultiple: true` allows several choices. `sessionId` associates the question with a Pi session without changing the conversation's default.
|
|
86
|
+
|
|
87
|
+
Questions remain available after the assistant response and across broker restarts. Pi's own interactive tools remain ordinary Pi tools and can be invoked through `call`.
|
|
88
|
+
|
|
89
|
+
## Files
|
|
90
|
+
|
|
91
|
+
`transfer.paths` always names paths or image references on the Pi side. Relative paths resolve from the selected Pi session's working directory; absolute paths and `~/` are accepted.
|
|
92
|
+
|
|
93
|
+
### ChatGPT to Pi
|
|
94
|
+
|
|
95
|
+
Pair Pi destinations with ChatGPT files:
|
|
107
96
|
|
|
108
97
|
```json
|
|
109
98
|
{
|
|
@@ -112,7 +101,9 @@ Multiple files are matched by array position:
|
|
|
112
101
|
}
|
|
113
102
|
```
|
|
114
103
|
|
|
115
|
-
|
|
104
|
+
The ChatGPT host turns the cloud paths or attachment references into downloadable file objects before the call reaches Chappie. Chappie creates parent directories and writes each file directly to its destination.
|
|
105
|
+
|
|
106
|
+
Existing targets produce an error by default. Use `overwrite: true` when replacement is intended:
|
|
116
107
|
|
|
117
108
|
```json
|
|
118
109
|
{
|
|
@@ -122,26 +113,22 @@ Chappie creates parent directories and streams each file into its destination. E
|
|
|
122
113
|
}
|
|
123
114
|
```
|
|
124
115
|
|
|
125
|
-
|
|
116
|
+
A failed or cancelled transfer removes the incomplete destination opened by that operation. Successful members of a multi-file transfer remain in place.
|
|
126
117
|
|
|
127
118
|
### Pi to ChatGPT
|
|
128
119
|
|
|
129
|
-
Omit `files` to export existing files:
|
|
120
|
+
Omit `files` to export existing Pi files:
|
|
130
121
|
|
|
131
122
|
```json
|
|
132
123
|
{ "paths": ["build/output.zip", "renders/preview.png"] }
|
|
133
124
|
```
|
|
134
125
|
|
|
135
|
-
|
|
126
|
+
Chappie returns MCP resource links. ChatGPT retrieves the bytes when it materializes those resources, which can require user confirmation. A resource remains associated with the Pi session that exported it, so that Pi process and source file need to remain available until the bytes are read.
|
|
136
127
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
For a directory, create an archive using a Pi tool and export that file.
|
|
128
|
+
For a directory, create an archive with a Pi tool and export the resulting file.
|
|
140
129
|
|
|
141
130
|
### Images
|
|
142
131
|
|
|
143
|
-
`read`
|
|
144
|
-
|
|
145
|
-
To analyze one in ChatGPT's cloud container, pass the returned reference in `transfer.paths`. This exports the image bytes held by Pi as a file. Include the image's owning `sessionId` when another session is selected.
|
|
132
|
+
`read` and Pi tool results send images directly to ChatGPT for visual inspection. Chappie also returns a `chappie://` image reference with Pi images. Pass that reference to `transfer.paths` when the same bytes are needed as a file in ChatGPT's cloud environment.
|
|
146
133
|
|
|
147
|
-
|
|
134
|
+
Use the original local path with `transfer` when the original image file is required; Pi can resize or convert images used only for display.
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zetaloop/chappie",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Connect ChatGPT to Pi",
|
|
5
5
|
"devDependencies": {
|
|
6
6
|
"@earendil-works/pi-ai": "^0.85.1",
|
|
7
7
|
"@earendil-works/pi-coding-agent": "^0.85.1",
|
|
8
|
+
"@earendil-works/pi-tui": "^0.85.1",
|
|
8
9
|
"@types/node": "^26.5.1",
|
|
9
10
|
"typebox": "^1.3.30",
|
|
10
11
|
"typescript": "^7.0.2"
|
|
@@ -34,6 +35,7 @@
|
|
|
34
35
|
"peerDependencies": {
|
|
35
36
|
"@earendil-works/pi-ai": "*",
|
|
36
37
|
"@earendil-works/pi-coding-agent": "*",
|
|
38
|
+
"@earendil-works/pi-tui": "*",
|
|
37
39
|
"typebox": "*"
|
|
38
40
|
},
|
|
39
41
|
"dependencies": {
|