@kingingwang/pi-darwin-arm64 0.87.0 → 0.99.1
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/bin/CHANGELOG.md +121 -0
- package/bin/README.md +25 -711
- package/bin/docs/cli-integration.md +106 -0
- package/bin/docs/cli.md +329 -0
- package/bin/docs/compaction.md +22 -22
- package/bin/docs/configuration.md +47 -0
- package/bin/docs/containerization.md +109 -82
- package/bin/docs/custom-provider.md +109 -722
- package/bin/docs/docs.json +147 -99
- package/bin/docs/environment-variables.md +3 -5
- package/bin/docs/extensions.md +165 -2996
- package/bin/docs/how-pi-works.md +49 -0
- package/bin/docs/images/interactive-mode.png +0 -0
- package/bin/docs/index.md +24 -69
- package/bin/docs/json.md +193 -65
- package/bin/docs/keybindings.md +58 -103
- package/bin/docs/llama-cpp.md +16 -3
- package/bin/docs/mcp.md +188 -0
- package/bin/docs/message-types.md +261 -0
- package/bin/docs/models.md +81 -556
- package/bin/docs/packages.md +67 -166
- package/bin/docs/prompt-templates.md +31 -68
- package/bin/docs/providers.md +103 -240
- package/bin/docs/quickstart.md +61 -106
- package/bin/docs/rpc-commands.md +860 -0
- package/bin/docs/rpc-extension-ui.md +200 -0
- package/bin/docs/rpc.md +130 -1555
- package/bin/docs/sdk.md +79 -1169
- package/bin/docs/security.md +72 -32
- package/bin/docs/session-format.md +15 -215
- package/bin/docs/sessions.md +35 -141
- package/bin/docs/settings.md +117 -377
- package/bin/docs/shell-aliases.md +85 -5
- package/bin/docs/skills.md +51 -190
- package/bin/docs/slash-commands.md +60 -0
- package/bin/docs/terminal-setup.md +105 -78
- package/bin/docs/termux.md +74 -83
- package/bin/docs/themes.md +88 -274
- package/bin/docs/tmux.md +31 -39
- package/bin/docs/tui.md +74 -910
- package/bin/docs/usage.md +54 -272
- package/bin/docs/virtual-models.md +114 -0
- package/bin/docs/windows.md +45 -17
- package/bin/examples/README.md +13 -2
- package/bin/examples/extensions/README.md +2 -0
- package/bin/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/bin/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/bin/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/bin/examples/extensions/custom-provider-gitlab-duo/test.ts +5 -5
- package/bin/examples/extensions/debug-provider.ts +90 -0
- package/bin/examples/extensions/gondolin/package-lock.json +2 -2
- package/bin/examples/extensions/gondolin/package.json +1 -1
- package/bin/examples/extensions/jev-router.ts +113 -0
- package/bin/examples/extensions/sandbox/package-lock.json +2 -2
- package/bin/examples/extensions/sandbox/package.json +1 -1
- package/bin/examples/extensions/with-deps/package-lock.json +2 -2
- package/bin/examples/extensions/with-deps/package.json +1 -1
- package/bin/examples/rpc-client.ts +35 -0
- package/bin/examples/rpc-extension-ui.ts +26 -6
- package/bin/examples/sdk/14-codemode-mcp.ts +61 -0
- package/bin/examples/sdk/README.md +3 -2
- package/bin/export-html/ansi-to-html.d.ts.map +1 -1
- package/bin/export-html/ansi-to-html.js.map +1 -1
- package/bin/export-html/index.d.ts.map +1 -1
- package/bin/export-html/index.js.map +1 -1
- package/bin/export-html/template.css +10 -0
- package/bin/export-html/template.js +66 -17
- package/bin/export-html/tool-renderer.d.ts.map +1 -1
- package/bin/export-html/tool-renderer.js.map +1 -1
- package/bin/native/darwin/prebuilds/darwin-arm64/darwin-platform.node +0 -0
- package/bin/package.json +14 -12
- package/bin/pi +2 -2
- package/bin/theme/dark.json +59 -72
- package/bin/theme/light.json +57 -69
- package/bin/theme/theme-schema.json +7 -2
- package/package.json +1 -1
- package/bin/docs/development.md +0 -90
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
# Message Types
|
|
2
|
+
|
|
3
|
+
Pi uses `AgentMessage` values in SDK state, lifecycle events, RPC responses, and persisted session message entries. This page defines those shared messages and their content blocks.
|
|
4
|
+
|
|
5
|
+
Message timestamps are Unix timestamps in milliseconds. They are different from the ISO 8601 timestamps on [session entries](session-format.md#entry-base).
|
|
6
|
+
|
|
7
|
+
Source definitions:
|
|
8
|
+
|
|
9
|
+
- [`packages/ai/src/types.ts`](https://github.com/earendil-works/pi/blob/main/packages/ai/src/types.ts) defines provider-facing messages and content blocks.
|
|
10
|
+
- [`packages/agent/src/types.ts`](https://github.com/earendil-works/pi/blob/main/packages/agent/src/types.ts) defines the extensible `AgentMessage` union.
|
|
11
|
+
- [`packages/coding-agent/src/core/messages.ts`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/messages.ts) adds coding-agent message roles.
|
|
12
|
+
|
|
13
|
+
## Content blocks
|
|
14
|
+
|
|
15
|
+
### TextContent
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
interface TextContent {
|
|
19
|
+
type: "text";
|
|
20
|
+
text: string;
|
|
21
|
+
textSignature?: string;
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`textSignature` contains provider-specific message metadata. Treat it as opaque.
|
|
26
|
+
|
|
27
|
+
### ImageContent
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
interface ImageContent {
|
|
31
|
+
type: "image";
|
|
32
|
+
data: string;
|
|
33
|
+
mimeType: string;
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`data` is base64-encoded image data. `mimeType` identifies its media type, such as `image/png` or `image/jpeg`.
|
|
38
|
+
|
|
39
|
+
### ThinkingContent
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
interface ThinkingContent {
|
|
43
|
+
type: "thinking";
|
|
44
|
+
thinking: string;
|
|
45
|
+
thinkingSignature?: string;
|
|
46
|
+
redacted?: boolean;
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Thinking signatures contain provider-specific replay data. Treat them as opaque. A redacted block can have no visible thinking text while retaining an encrypted payload in `thinkingSignature`.
|
|
51
|
+
|
|
52
|
+
### ToolCall
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
interface ToolCall {
|
|
56
|
+
type: "toolCall";
|
|
57
|
+
id: string;
|
|
58
|
+
name: string;
|
|
59
|
+
arguments: Record<string, any>;
|
|
60
|
+
thoughtSignature?: string;
|
|
61
|
+
namespace?: string;
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
`thoughtSignature` is provider-specific. `namespace` identifies an OpenAI Responses namespace for dynamically loaded or namespaced tools.
|
|
66
|
+
|
|
67
|
+
## Usage
|
|
68
|
+
|
|
69
|
+
Assistant messages always contain usage. Tool results can contain usage when the tool performed nested model work.
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
interface Usage {
|
|
73
|
+
input: number;
|
|
74
|
+
output: number;
|
|
75
|
+
cacheRead: number;
|
|
76
|
+
cacheWrite: number;
|
|
77
|
+
cacheWrite1h?: number;
|
|
78
|
+
reasoning?: number;
|
|
79
|
+
totalTokens: number;
|
|
80
|
+
cost: {
|
|
81
|
+
input: number;
|
|
82
|
+
output: number;
|
|
83
|
+
cacheRead: number;
|
|
84
|
+
cacheWrite: number;
|
|
85
|
+
total: number;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
When present, `reasoning` is already included in `output`; do not add it again. `cacheWrite1h` is the subset of `cacheWrite` written with one-hour retention.
|
|
91
|
+
|
|
92
|
+
## Base messages
|
|
93
|
+
|
|
94
|
+
### SystemMessage
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
interface SystemMessage {
|
|
98
|
+
role: "system";
|
|
99
|
+
content: string | TextContent[];
|
|
100
|
+
sections?: Record<string, string | null>;
|
|
101
|
+
toolsAdded?: Tool[];
|
|
102
|
+
toolsRemoved?: ToolReference[];
|
|
103
|
+
replace?: boolean;
|
|
104
|
+
timestamp: number;
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
The leading system message declares the initial prompt and tools. Later system messages can append instructions, replace or remove named prompt sections, and add or remove tools. Replaying them in order yields the current state. A message with `replace: true` discards the earlier state and establishes a complete new baseline.
|
|
109
|
+
|
|
110
|
+
### UserMessage
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
interface UserMessage {
|
|
114
|
+
role: "user";
|
|
115
|
+
content: string | (TextContent | ImageContent)[];
|
|
116
|
+
timestamp: number;
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### AssistantMessage
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
interface AssistantMessage {
|
|
124
|
+
role: "assistant";
|
|
125
|
+
content: (TextContent | ThinkingContent | ToolCall)[];
|
|
126
|
+
api: string;
|
|
127
|
+
provider: string;
|
|
128
|
+
model: string;
|
|
129
|
+
responseModel?: string;
|
|
130
|
+
responseId?: string;
|
|
131
|
+
providerThinkingLevel?: string;
|
|
132
|
+
diagnostics?: AssistantMessageDiagnostic[];
|
|
133
|
+
usage: Usage;
|
|
134
|
+
stopReason: "pending" | "stop" | "length" | "toolUse" | "error" | "aborted" | "deferred";
|
|
135
|
+
deferred?: DeferredHandle;
|
|
136
|
+
errorMessage?: string;
|
|
137
|
+
rawStopReason?: string;
|
|
138
|
+
endTurn?: boolean;
|
|
139
|
+
timestamp: number;
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
`responseModel` records a concrete provider response model when it differs from the requested model. `responseId`, `providerThinkingLevel`, `diagnostics`, and `rawStopReason` preserve provider or runtime details.
|
|
144
|
+
|
|
145
|
+
`"pending"` is used for a partial assistant message while it streams. The completed message in `message_end` has a terminal stop reason, and Pi does not persist `"pending"` assistant messages in session JSONL.
|
|
146
|
+
|
|
147
|
+
A `"deferred"` response has a `DeferredHandle` with the provider data needed to retrieve it:
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
interface DeferredHandle {
|
|
151
|
+
provider: string;
|
|
152
|
+
modelId: string;
|
|
153
|
+
api: string;
|
|
154
|
+
id: string;
|
|
155
|
+
expiresAt?: number;
|
|
156
|
+
pollAfterMs?: number;
|
|
157
|
+
data?: JsonValue;
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### ToolResultMessage
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
interface ToolResultMessage<TDetails = any> {
|
|
165
|
+
role: "toolResult";
|
|
166
|
+
toolCallId: string;
|
|
167
|
+
toolName: string;
|
|
168
|
+
content: (TextContent | ImageContent)[];
|
|
169
|
+
details?: TDetails;
|
|
170
|
+
usage?: Usage;
|
|
171
|
+
isError: boolean;
|
|
172
|
+
timestamp: number;
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
`details` is tool-specific. Optional `usage` reports nested model work performed by the tool and contributes to full-session statistics, but it is not part of the main model-call usage.
|
|
177
|
+
|
|
178
|
+
## Coding-agent messages
|
|
179
|
+
|
|
180
|
+
The coding-agent package extends `AgentMessage` with four roles.
|
|
181
|
+
|
|
182
|
+
### BashExecutionMessage
|
|
183
|
+
|
|
184
|
+
Created by direct shell commands, including the RPC [`bash`](rpc-commands.md#bash) command. It is not an LLM tool result.
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
interface BashExecutionMessage {
|
|
188
|
+
role: "bashExecution";
|
|
189
|
+
command: string;
|
|
190
|
+
output: string;
|
|
191
|
+
exitCode: number | undefined;
|
|
192
|
+
cancelled: boolean;
|
|
193
|
+
truncated: boolean;
|
|
194
|
+
fullOutputPath?: string;
|
|
195
|
+
excludeFromContext?: boolean;
|
|
196
|
+
timestamp: number;
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Unless `excludeFromContext` is true, Pi converts this message to user-role text before the next model request.
|
|
201
|
+
|
|
202
|
+
### CustomMessage
|
|
203
|
+
|
|
204
|
+
Created when an extension sends a context message.
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
interface CustomMessage<T = unknown> {
|
|
208
|
+
role: "custom";
|
|
209
|
+
customType: string;
|
|
210
|
+
content: string | (TextContent | ImageContent)[];
|
|
211
|
+
display: boolean;
|
|
212
|
+
details?: T;
|
|
213
|
+
timestamp: number;
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Pi converts its content to a user message for model requests. `display` controls terminal rendering; `details` is not sent to the model.
|
|
218
|
+
|
|
219
|
+
### BranchSummaryMessage
|
|
220
|
+
|
|
221
|
+
```typescript
|
|
222
|
+
interface BranchSummaryMessage {
|
|
223
|
+
role: "branchSummary";
|
|
224
|
+
summary: string;
|
|
225
|
+
fromId: string | null;
|
|
226
|
+
timestamp: number;
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Pi creates this context message from a persisted `branch_summary` entry.
|
|
231
|
+
|
|
232
|
+
### CompactionSummaryMessage
|
|
233
|
+
|
|
234
|
+
```typescript
|
|
235
|
+
interface CompactionSummaryMessage {
|
|
236
|
+
role: "compactionSummary";
|
|
237
|
+
summary: string;
|
|
238
|
+
tokensBefore: number;
|
|
239
|
+
timestamp: number;
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
Pi creates this context message from a persisted `compaction` entry.
|
|
244
|
+
|
|
245
|
+
## AgentMessage union
|
|
246
|
+
|
|
247
|
+
In the coding agent, the union is equivalent to:
|
|
248
|
+
|
|
249
|
+
```typescript
|
|
250
|
+
type AgentMessage =
|
|
251
|
+
| SystemMessage
|
|
252
|
+
| UserMessage
|
|
253
|
+
| AssistantMessage
|
|
254
|
+
| ToolResultMessage
|
|
255
|
+
| BashExecutionMessage
|
|
256
|
+
| CustomMessage
|
|
257
|
+
| BranchSummaryMessage
|
|
258
|
+
| CompactionSummaryMessage;
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
At the lower-level agent package, `AgentMessage` is `Message | CustomAgentMessages[keyof CustomAgentMessages]`. Applications can add roles through TypeScript declaration merging, so consumers should tolerate unknown custom roles when they accept messages from an augmented host.
|