@zetaloop/chappie 0.4.0 → 0.5.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 +3 -9
- package/docs/tools.md +36 -36
- package/package.json +1 -1
- package/src/broker.ts +106 -328
- package/src/config.ts +0 -1
- package/src/history.ts +15 -2
- package/src/index.ts +4 -1
- package/src/instructions.md +5 -5
- package/src/ipc.ts +19 -4
- package/src/questions.ts +6 -14
- package/src/resources.ts +26 -6
- package/src/server.ts +40 -89
- package/src/session.ts +272 -27
- package/src/state.ts +1 -17
- package/src/transfer.ts +200 -49
package/README.md
CHANGED
|
@@ -29,9 +29,9 @@ Call `init` from ChatGPT to connect the conversation to Pi. A conversation can r
|
|
|
29
29
|
|
|
30
30
|
## Usage
|
|
31
31
|
|
|
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
|
|
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 between ChatGPT and Pi or between connected devices. `history` reads recent Pi messages and activity with timestamps. `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, history,
|
|
34
|
+
See the [tool guide](docs/tools.md) for session selection, history, Pi tools, webpage questions, and file transfer.
|
|
35
35
|
|
|
36
36
|
## Configuration
|
|
37
37
|
|
|
@@ -53,10 +53,4 @@ The default port is `24274`. Set `listen` to a port number or append `:port` to
|
|
|
53
53
|
|
|
54
54
|
Set `ask` to `false` to disable webpage questions.
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
```json
|
|
59
|
-
{ "sync": true }
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
With synchronization enabled, initialization returns a fresh code. `sync` locks a Pi session and its bound conversations while executions verify their codes. Rejected executions announce their exit and end their responses; the verified execution confirms those exits through `chat` and `history`, then releases the lock. Codes persist in broker state; locks last for the broker process. See [synchronization](docs/tools.md#synchronization) for the tool sequence.
|
|
56
|
+
Closely spaced initializations from the same ChatGPT conversation receive guidance to observe the ongoing work through `history` and explain its results. See [participation](docs/tools.md#participation).
|
package/docs/tools.md
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
|---|---|
|
|
5
5
|
| `init` | Select this ChatGPT conversation's default Pi session and read its environment. |
|
|
6
6
|
| `history` | Read the current Pi branch with timestamps and entry IDs. |
|
|
7
|
-
| `sync` | End duplicate executions so one execution continues. |
|
|
8
7
|
| `sessions` | List connected Pi sessions and the current default. |
|
|
9
8
|
| `tools` | Read full definitions of active Pi tools for `call`. |
|
|
10
9
|
| `chat` | Send an assistant message to Pi. |
|
|
@@ -15,15 +14,17 @@
|
|
|
15
14
|
| `bash` | Run a shell command. |
|
|
16
15
|
| `edit` | Apply text replacements. |
|
|
17
16
|
| `write` | Write text to a file. |
|
|
18
|
-
| `transfer` | Move files between ChatGPT and Pi or export a Pi image. |
|
|
17
|
+
| `transfer` | Move files between ChatGPT and Pi, copy between Pi sessions, or export a Pi image. |
|
|
19
18
|
|
|
20
19
|
## Sessions
|
|
21
20
|
|
|
22
21
|
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. Read recent `history` to recover progress before continuing the current task.
|
|
23
22
|
|
|
24
|
-
`
|
|
23
|
+
When `globalAgents` is present, read and follow the instructions at `globalAgents.path` on the selected Pi session. Follow the participation guidance in `initialization.instructions`.
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
`sessions` lists connected sessions with their ID, device, working directory, name, execution status, and binding count. The first execution tool call establishes the default using its `sessionId` or an online session with no saved bindings. Once a default exists, another tool's `sessionId` selects only that operation's target; `init({ sessionId })` changes the default.
|
|
26
|
+
|
|
27
|
+
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.
|
|
27
28
|
|
|
28
29
|
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.
|
|
29
30
|
|
|
@@ -37,42 +38,20 @@ Remote Pi sessions appear in the same list when they connect to a broker exposed
|
|
|
37
38
|
|
|
38
39
|
Omit `before` for the latest entries. Use `after` to read forward from an entry. Both fields can delimit a range, with the named entries outside the returned range. The default limit is 20 readable entries. Results follow branch order and contain each entry's original ID and timestamp. `hasMore` indicates additional entries in the requested direction.
|
|
39
40
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
Pi user input, webpage answers, connection status, and deferred delivery target sessions or conversations. A deferred result's `requestId` identifies the original operation; the result can reach another execution in that conversation.
|
|
43
|
-
|
|
44
|
-
## Synchronization
|
|
45
|
-
|
|
46
|
-
Set `sync` to `true` in the broker's `chappie.json` to enable the `sync` tool. Each explicit initialization and first execution that establishes a default returns `initialization.code`. Retain the code in the ChatGPT context alongside its Pi session ID. Ordinary calls use the existing binding; a saved binding without a code receives one on its next execution.
|
|
47
|
-
|
|
48
|
-
When activity conflicts, start synchronization for the session:
|
|
49
|
-
|
|
50
|
-
```json
|
|
51
|
-
{ "action": "start", "sessionId": "<session-id>" }
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
This locks ordinary tools and initialization for that Pi session and every conversation currently bound to it. Existing ordinary requests in that scope are cancelled through Pi's cancellation path. Bound conversations also pause their operations on other sessions. Other conversations continue using unrelated sessions. Automatic session selection considers unlocked sessions.
|
|
41
|
+
To follow progress, pass `after` with `wait: true`. Available entries return immediately; at the end of the branch, the request waits up to 30 seconds for new readable entries. A timeout returns an empty page. Reads with `before` return immediately. Cancellation, disconnection, or an invalidated branch cursor ends the request. Waiting for history leaves the session available for other requests.
|
|
55
42
|
|
|
56
|
-
|
|
43
|
+
Set `observer: true` to read as an observer. New messages and work activity wake waiting readers; idle status alone does not indicate task completion.
|
|
57
44
|
|
|
58
|
-
|
|
45
|
+
History includes saved messages, tool calls and results, summaries, images, file links, and work activity. Truncation notices and full-output paths are included so complete output can be read when needed. Reading history leaves new input and pending results available for normal delivery.
|
|
59
46
|
|
|
60
|
-
|
|
61
|
-
{ "action": "verify", "code": "<initialization-code>" }
|
|
62
|
-
```
|
|
47
|
+
## Participation
|
|
63
48
|
|
|
64
|
-
The
|
|
65
|
-
|
|
66
|
-
The holder of the verified code uses `chat` and `history` to identify every observed conflicting execution, require an explicit final exit message, and confirm it has ended its response. A promise to pause ordinary tools, idle Pi status, or a quiet history page alone is insufficient. After those final exits and resolution of conflicting activity, the surviving execution explicitly releases the session:
|
|
67
|
-
|
|
68
|
-
```json
|
|
69
|
-
{ "action": "release", "code": "<verified-code>" }
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
Current codes are saved per Pi session in `chappie.state.json`. Activity records contain coordination details; codes stay in initialization and synchronization exchanges. Lock and verification state live in the broker process, so restarting the broker restores ordinary operation. Pi-client and tunnel reconnections retain the running broker's locks. `sessions` and `history` report the current synchronization state.
|
|
49
|
+
The executing assistant uses `chat` to share progress and completion in Pi. When initialization directs an assistant to observe, it follows that work through `history` with `observer: true` and `wait: true`, thinks independently, and explains the recorded results in ChatGPT when the task is complete.
|
|
73
50
|
|
|
74
51
|
## Pi tools
|
|
75
52
|
|
|
53
|
+
ChatGPT truncates tool responses exceeding 10,000 tokens.
|
|
54
|
+
|
|
76
55
|
`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.
|
|
77
56
|
|
|
78
57
|
For example:
|
|
@@ -100,7 +79,7 @@ Pi controls execution inside that batch. Separate requests run in order within o
|
|
|
100
79
|
{ "text": "Updated the parser and its callers." }
|
|
101
80
|
```
|
|
102
81
|
|
|
103
|
-
Pi user input consumed during the work accompanies later Chappie results, including images.
|
|
82
|
+
Pi user input consumed during the work accompanies later Chappie results, including images.
|
|
104
83
|
|
|
105
84
|
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.
|
|
106
85
|
|
|
@@ -108,7 +87,7 @@ The active model remains the current ChatGPT conversation. Starting another `cha
|
|
|
108
87
|
|
|
109
88
|
## Webpage questions
|
|
110
89
|
|
|
111
|
-
When enabled, `ask`
|
|
90
|
+
When enabled, `ask` saves a question and requests a widget in ChatGPT, returning its ID immediately. Display depends on the host:
|
|
112
91
|
|
|
113
92
|
```json
|
|
114
93
|
{
|
|
@@ -128,6 +107,8 @@ Call `ask_assert` with the returned ID to confirm that the widget loaded:
|
|
|
128
107
|
{ "questionId": "<question-id>" }
|
|
129
108
|
```
|
|
130
109
|
|
|
110
|
+
If the widget has not loaded within 10 seconds, `ask_assert` fails and saves the unanswered question as skipped. Use a Pi interactive tool when an answer is needed. The user can still answer or edit the saved question when its widget is available.
|
|
111
|
+
|
|
131
112
|
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 using the session selection rules above.
|
|
132
113
|
|
|
133
114
|
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`.
|
|
@@ -147,7 +128,7 @@ Pair Pi destinations with ChatGPT files:
|
|
|
147
128
|
}
|
|
148
129
|
```
|
|
149
130
|
|
|
150
|
-
The ChatGPT host turns the cloud paths or attachment references into downloadable file objects before the call reaches Chappie.
|
|
131
|
+
The ChatGPT host turns the cloud paths or attachment references into downloadable file objects before the call reaches Chappie. Parent directories are created as needed.
|
|
151
132
|
|
|
152
133
|
Existing targets produce an error by default. Use `overwrite: true` when replacement is intended:
|
|
153
134
|
|
|
@@ -173,6 +154,25 @@ Chappie returns MCP resource links. ChatGPT retrieves the bytes when it material
|
|
|
173
154
|
|
|
174
155
|
For a directory, create an archive with a Pi tool and export the resulting file.
|
|
175
156
|
|
|
157
|
+
### Pi to Pi
|
|
158
|
+
|
|
159
|
+
Supply `to` to copy files to another connected Pi session:
|
|
160
|
+
|
|
161
|
+
```json
|
|
162
|
+
{
|
|
163
|
+
"sessionId": "<source-session>",
|
|
164
|
+
"paths": ["build/output.zip"],
|
|
165
|
+
"to": {
|
|
166
|
+
"sessionId": "<destination-session>",
|
|
167
|
+
"paths": ["downloads/output.zip"]
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Source and destination paths correspond by position. Each session resolves its own relative paths, absolute paths, and `~/`. Image references can also be copied. `files` and `to` select different sources and are mutually exclusive.
|
|
173
|
+
|
|
174
|
+
Both Pi sessions need to stay connected during the transfer. `overwrite: true` replaces an existing destination. Cancellation or failure discards the incomplete file; successfully copied files remain available.
|
|
175
|
+
|
|
176
176
|
### Images
|
|
177
177
|
|
|
178
178
|
`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.
|