gsd-pi 2.53.0-dev.07ffe51 → 2.53.0-dev.a67436f

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.
Files changed (57) hide show
  1. package/dist/headless-ui.d.ts +2 -2
  2. package/dist/headless-ui.js +18 -15
  3. package/dist/headless.d.ts +11 -0
  4. package/dist/headless.js +178 -38
  5. package/dist/web/standalone/.next/BUILD_ID +1 -1
  6. package/dist/web/standalone/.next/app-path-routes-manifest.json +18 -18
  7. package/dist/web/standalone/.next/build-manifest.json +2 -2
  8. package/dist/web/standalone/.next/prerender-manifest.json +3 -3
  9. package/dist/web/standalone/.next/required-server-files.json +1 -1
  10. package/dist/web/standalone/.next/server/app/_global-error.html +2 -2
  11. package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
  12. package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  13. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  14. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  15. package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  16. package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  17. package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  18. package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
  19. package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
  20. package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  21. package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  22. package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  23. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  24. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  25. package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  26. package/dist/web/standalone/.next/server/app/index.html +1 -1
  27. package/dist/web/standalone/.next/server/app/index.rsc +1 -1
  28. package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  29. package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
  30. package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  31. package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
  32. package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  33. package/dist/web/standalone/.next/server/app-paths-manifest.json +18 -18
  34. package/dist/web/standalone/.next/server/pages/404.html +1 -1
  35. package/dist/web/standalone/.next/server/pages/500.html +2 -2
  36. package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
  37. package/dist/web/standalone/server.js +1 -1
  38. package/package.json +1 -1
  39. package/packages/mcp-server/README.md +6 -6
  40. package/packages/mcp-server/package.json +14 -4
  41. package/packages/mcp-server/src/cli.ts +1 -1
  42. package/packages/mcp-server/src/index.ts +1 -1
  43. package/packages/mcp-server/src/mcp-server.test.ts +2 -2
  44. package/packages/mcp-server/src/session-manager.ts +2 -2
  45. package/packages/mcp-server/src/types.ts +1 -1
  46. package/packages/rpc-client/README.md +125 -0
  47. package/packages/rpc-client/examples/basic-usage.ts +13 -0
  48. package/packages/rpc-client/package.json +17 -3
  49. package/packages/rpc-client/src/index.ts +10 -0
  50. package/packages/rpc-client/src/jsonl.ts +64 -0
  51. package/packages/rpc-client/src/rpc-client.test.ts +568 -0
  52. package/packages/rpc-client/src/rpc-client.ts +666 -0
  53. package/packages/rpc-client/src/rpc-types.ts +399 -0
  54. package/packages/rpc-client/tsconfig.examples.json +17 -0
  55. package/packages/rpc-client/tsconfig.json +24 -0
  56. /package/dist/web/standalone/.next/static/{Q5pfrfJIvgUKR3LJLVB0T → YO-PWFRitlHM-L-dotlmm}/_buildManifest.js +0 -0
  57. /package/dist/web/standalone/.next/static/{Q5pfrfJIvgUKR3LJLVB0T → YO-PWFRitlHM-L-dotlmm}/_ssgManifest.js +0 -0
@@ -0,0 +1,399 @@
1
+ /**
2
+ * RPC protocol types for headless operation.
3
+ *
4
+ * Commands are sent as JSON lines on stdin.
5
+ * Responses and events are emitted as JSON lines on stdout.
6
+ *
7
+ * This file is self-contained — all types that were previously imported from
8
+ * internal packages are inlined so that this package has zero internal
9
+ * dependencies.
10
+ */
11
+
12
+ // ============================================================================
13
+ // Inlined types (originally from internal packages)
14
+ // ============================================================================
15
+
16
+ /** Thinking budget level (inlined from agent-core) */
17
+ export type ThinkingLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh";
18
+
19
+ /** Image attachment (inlined from pi-ai) */
20
+ export interface ImageContent {
21
+ type: "image";
22
+ data: string; // base64 encoded image data
23
+ mimeType: string; // e.g., "image/jpeg", "image/png"
24
+ }
25
+
26
+ /** Model descriptor — opaque for SDK consumers */
27
+ export interface ModelInfo {
28
+ provider: string;
29
+ id: string;
30
+ contextWindow?: number;
31
+ reasoning?: boolean;
32
+ [key: string]: unknown;
33
+ }
34
+
35
+ /** Session statistics (from agent-session.ts) */
36
+ export interface SessionStats {
37
+ sessionFile: string | undefined;
38
+ sessionId: string;
39
+ userMessages: number;
40
+ assistantMessages: number;
41
+ toolCalls: number;
42
+ toolResults: number;
43
+ totalMessages: number;
44
+ tokens: {
45
+ input: number;
46
+ output: number;
47
+ cacheRead: number;
48
+ cacheWrite: number;
49
+ total: number;
50
+ };
51
+ cost: number;
52
+ }
53
+
54
+ /** Bash command result (from bash-executor.ts) */
55
+ export interface BashResult {
56
+ /** Combined stdout + stderr output (sanitized, possibly truncated) */
57
+ output: string;
58
+ /** Process exit code (undefined if killed/cancelled) */
59
+ exitCode: number | undefined;
60
+ /** Whether the command was cancelled via signal */
61
+ cancelled: boolean;
62
+ /** Whether the output was truncated */
63
+ truncated: boolean;
64
+ /** Path to temp file containing full output (if output exceeded truncation threshold) */
65
+ fullOutputPath?: string;
66
+ }
67
+
68
+ /** Compaction result (from compaction.ts) */
69
+ export interface CompactionResult<T = unknown> {
70
+ summary: string;
71
+ firstKeptEntryId: string;
72
+ tokensBefore: number;
73
+ /** Extension-specific data (e.g., ArtifactIndex, version markers for structured compaction) */
74
+ details?: T;
75
+ }
76
+
77
+ // ============================================================================
78
+ // RPC Protocol Versioning
79
+ // ============================================================================
80
+
81
+ /** Supported protocol versions. v1 is the implicit default; v2 requires an init handshake. */
82
+ export type RpcProtocolVersion = 1 | 2;
83
+
84
+ // ============================================================================
85
+ // RPC Commands (stdin)
86
+ // ============================================================================
87
+
88
+ export type RpcCommand =
89
+ // Prompting
90
+ | { id?: string; type: "prompt"; message: string; images?: ImageContent[]; streamingBehavior?: "steer" | "followUp" }
91
+ | { id?: string; type: "steer"; message: string; images?: ImageContent[] }
92
+ | { id?: string; type: "follow_up"; message: string; images?: ImageContent[] }
93
+ | { id?: string; type: "abort" }
94
+ | { id?: string; type: "new_session"; parentSession?: string }
95
+
96
+ // State
97
+ | { id?: string; type: "get_state" }
98
+
99
+ // Model
100
+ | { id?: string; type: "set_model"; provider: string; modelId: string }
101
+ | { id?: string; type: "cycle_model" }
102
+ | { id?: string; type: "get_available_models" }
103
+
104
+ // Thinking
105
+ | { id?: string; type: "set_thinking_level"; level: ThinkingLevel }
106
+ | { id?: string; type: "cycle_thinking_level" }
107
+
108
+ // Queue modes
109
+ | { id?: string; type: "set_steering_mode"; mode: "all" | "one-at-a-time" }
110
+ | { id?: string; type: "set_follow_up_mode"; mode: "all" | "one-at-a-time" }
111
+
112
+ // Compaction
113
+ | { id?: string; type: "compact"; customInstructions?: string }
114
+ | { id?: string; type: "set_auto_compaction"; enabled: boolean }
115
+
116
+ // Retry
117
+ | { id?: string; type: "set_auto_retry"; enabled: boolean }
118
+ | { id?: string; type: "abort_retry" }
119
+
120
+ // Bash
121
+ | { id?: string; type: "bash"; command: string }
122
+ | { id?: string; type: "abort_bash" }
123
+
124
+ // Session
125
+ | { id?: string; type: "get_session_stats" }
126
+ | { id?: string; type: "export_html"; outputPath?: string }
127
+ | { id?: string; type: "switch_session"; sessionPath: string }
128
+ | { id?: string; type: "fork"; entryId: string }
129
+ | { id?: string; type: "get_fork_messages" }
130
+ | { id?: string; type: "get_last_assistant_text" }
131
+ | { id?: string; type: "set_session_name"; name: string }
132
+
133
+ // Messages
134
+ | { id?: string; type: "get_messages" }
135
+
136
+ // Commands (available for invocation via prompt)
137
+ | { id?: string; type: "get_commands" }
138
+
139
+ // Bridge-hosted native terminal
140
+ | { id?: string; type: "terminal_input"; data: string }
141
+ | { id?: string; type: "terminal_resize"; cols: number; rows: number }
142
+ | { id?: string; type: "terminal_redraw" }
143
+
144
+ // v2 Protocol
145
+ | { id?: string; type: "init"; protocolVersion: 2; clientId?: string }
146
+ | { id?: string; type: "shutdown"; graceful?: boolean }
147
+ | { id?: string; type: "subscribe"; events: string[] };
148
+
149
+ // ============================================================================
150
+ // RPC Slash Command (for get_commands response)
151
+ // ============================================================================
152
+
153
+ /** A command available for invocation via prompt */
154
+ export interface RpcSlashCommand {
155
+ /** Command name (without leading slash) */
156
+ name: string;
157
+ /** Human-readable description */
158
+ description?: string;
159
+ /** What kind of command this is */
160
+ source: "extension" | "prompt" | "skill";
161
+ /** Where the command was loaded from (undefined for extensions) */
162
+ location?: "user" | "project" | "path";
163
+ /** File path to the command source */
164
+ path?: string;
165
+ }
166
+
167
+ // ============================================================================
168
+ // RPC State
169
+ // ============================================================================
170
+
171
+ export interface RpcSessionState {
172
+ model?: ModelInfo;
173
+ thinkingLevel: ThinkingLevel;
174
+ isStreaming: boolean;
175
+ isCompacting: boolean;
176
+ steeringMode: "all" | "one-at-a-time";
177
+ followUpMode: "all" | "one-at-a-time";
178
+ sessionFile?: string;
179
+ sessionId: string;
180
+ sessionName?: string;
181
+ autoCompactionEnabled: boolean;
182
+ autoRetryEnabled: boolean;
183
+ retryInProgress: boolean;
184
+ retryAttempt: number;
185
+ messageCount: number;
186
+ pendingMessageCount: number;
187
+ /** Whether extension loading has completed. Commands from `get_commands` may be incomplete until true. */
188
+ extensionsReady: boolean;
189
+ }
190
+
191
+ // ============================================================================
192
+ // RPC Responses (stdout)
193
+ // ============================================================================
194
+
195
+ // Success responses with data
196
+ export type RpcResponse =
197
+ // Prompting (async - events follow)
198
+ | { id?: string; type: "response"; command: "prompt"; success: true; runId?: string }
199
+ | { id?: string; type: "response"; command: "steer"; success: true; runId?: string }
200
+ | { id?: string; type: "response"; command: "follow_up"; success: true; runId?: string }
201
+ | { id?: string; type: "response"; command: "abort"; success: true }
202
+ | { id?: string; type: "response"; command: "new_session"; success: true; data: { cancelled: boolean } }
203
+
204
+ // State
205
+ | { id?: string; type: "response"; command: "get_state"; success: true; data: RpcSessionState }
206
+
207
+ // Model
208
+ | {
209
+ id?: string;
210
+ type: "response";
211
+ command: "set_model";
212
+ success: true;
213
+ data: ModelInfo;
214
+ }
215
+ | {
216
+ id?: string;
217
+ type: "response";
218
+ command: "cycle_model";
219
+ success: true;
220
+ data: { model: ModelInfo; thinkingLevel: ThinkingLevel; isScoped: boolean } | null;
221
+ }
222
+ | {
223
+ id?: string;
224
+ type: "response";
225
+ command: "get_available_models";
226
+ success: true;
227
+ data: { models: ModelInfo[] };
228
+ }
229
+
230
+ // Thinking
231
+ | { id?: string; type: "response"; command: "set_thinking_level"; success: true }
232
+ | {
233
+ id?: string;
234
+ type: "response";
235
+ command: "cycle_thinking_level";
236
+ success: true;
237
+ data: { level: ThinkingLevel } | null;
238
+ }
239
+
240
+ // Queue modes
241
+ | { id?: string; type: "response"; command: "set_steering_mode"; success: true }
242
+ | { id?: string; type: "response"; command: "set_follow_up_mode"; success: true }
243
+
244
+ // Compaction
245
+ | { id?: string; type: "response"; command: "compact"; success: true; data: CompactionResult }
246
+ | { id?: string; type: "response"; command: "set_auto_compaction"; success: true }
247
+
248
+ // Retry
249
+ | { id?: string; type: "response"; command: "set_auto_retry"; success: true }
250
+ | { id?: string; type: "response"; command: "abort_retry"; success: true }
251
+
252
+ // Bash
253
+ | { id?: string; type: "response"; command: "bash"; success: true; data: BashResult }
254
+ | { id?: string; type: "response"; command: "abort_bash"; success: true }
255
+
256
+ // Session
257
+ | { id?: string; type: "response"; command: "get_session_stats"; success: true; data: SessionStats }
258
+ | { id?: string; type: "response"; command: "export_html"; success: true; data: { path: string } }
259
+ | { id?: string; type: "response"; command: "switch_session"; success: true; data: { cancelled: boolean } }
260
+ | { id?: string; type: "response"; command: "fork"; success: true; data: { text: string; cancelled: boolean } }
261
+ | {
262
+ id?: string;
263
+ type: "response";
264
+ command: "get_fork_messages";
265
+ success: true;
266
+ data: { messages: Array<{ entryId: string; text: string }> };
267
+ }
268
+ | {
269
+ id?: string;
270
+ type: "response";
271
+ command: "get_last_assistant_text";
272
+ success: true;
273
+ data: { text: string | null };
274
+ }
275
+ | { id?: string; type: "response"; command: "set_session_name"; success: true }
276
+
277
+ // Messages — AgentMessage is opaque for SDK consumers
278
+ | { id?: string; type: "response"; command: "get_messages"; success: true; data: { messages: unknown[] } }
279
+
280
+ // Commands
281
+ | {
282
+ id?: string;
283
+ type: "response";
284
+ command: "get_commands";
285
+ success: true;
286
+ data: { commands: RpcSlashCommand[] };
287
+ }
288
+
289
+ // Bridge-hosted native terminal
290
+ | { id?: string; type: "response"; command: "terminal_input"; success: true }
291
+ | { id?: string; type: "response"; command: "terminal_resize"; success: true }
292
+ | { id?: string; type: "response"; command: "terminal_redraw"; success: true }
293
+
294
+ // v2 Protocol
295
+ | { id?: string; type: "response"; command: "init"; success: true; data: RpcInitResult }
296
+ | { id?: string; type: "response"; command: "shutdown"; success: true }
297
+ | { id?: string; type: "response"; command: "subscribe"; success: true }
298
+
299
+ // Error response (any command can fail)
300
+ | { id?: string; type: "response"; command: string; success: false; error: string };
301
+
302
+ // ============================================================================
303
+ // v2 Protocol Types
304
+ // ============================================================================
305
+
306
+ /** Result of the init handshake (v2 only) */
307
+ export interface RpcInitResult {
308
+ protocolVersion: 2;
309
+ sessionId: string;
310
+ capabilities: {
311
+ events: string[];
312
+ commands: string[];
313
+ };
314
+ }
315
+
316
+ /** v2 execution_complete event — emitted when a prompt/steer/follow_up finishes */
317
+ export interface RpcExecutionCompleteEvent {
318
+ type: "execution_complete";
319
+ runId: string;
320
+ status: "completed" | "error" | "cancelled";
321
+ reason?: string;
322
+ stats: SessionStats;
323
+ }
324
+
325
+ /** v2 cost_update event — emitted per-turn with running cost data */
326
+ export interface RpcCostUpdateEvent {
327
+ type: "cost_update";
328
+ runId: string;
329
+ turnCost: number;
330
+ cumulativeCost: number;
331
+ tokens: {
332
+ input: number;
333
+ output: number;
334
+ cacheRead: number;
335
+ cacheWrite: number;
336
+ };
337
+ }
338
+
339
+ /** Discriminated union of all v2-only event types */
340
+ export type RpcV2Event = RpcExecutionCompleteEvent | RpcCostUpdateEvent;
341
+
342
+ // ============================================================================
343
+ // Extension UI Events (stdout)
344
+ // ============================================================================
345
+
346
+ /** Emitted when an extension needs user input */
347
+ export type RpcExtensionUIRequest =
348
+ | { type: "extension_ui_request"; id: string; method: "select"; title: string; options: string[]; timeout?: number; allowMultiple?: boolean }
349
+ | { type: "extension_ui_request"; id: string; method: "confirm"; title: string; message: string; timeout?: number }
350
+ | {
351
+ type: "extension_ui_request";
352
+ id: string;
353
+ method: "input";
354
+ title: string;
355
+ placeholder?: string;
356
+ timeout?: number;
357
+ }
358
+ | { type: "extension_ui_request"; id: string; method: "editor"; title: string; prefill?: string }
359
+ | {
360
+ type: "extension_ui_request";
361
+ id: string;
362
+ method: "notify";
363
+ message: string;
364
+ notifyType?: "info" | "warning" | "error";
365
+ }
366
+ | {
367
+ type: "extension_ui_request";
368
+ id: string;
369
+ method: "setStatus";
370
+ statusKey: string;
371
+ statusText: string | undefined;
372
+ }
373
+ | {
374
+ type: "extension_ui_request";
375
+ id: string;
376
+ method: "setWidget";
377
+ widgetKey: string;
378
+ widgetLines: string[] | undefined;
379
+ widgetPlacement?: "aboveEditor" | "belowEditor";
380
+ }
381
+ | { type: "extension_ui_request"; id: string; method: "setTitle"; title: string }
382
+ | { type: "extension_ui_request"; id: string; method: "set_editor_text"; text: string };
383
+
384
+ // ============================================================================
385
+ // Extension UI Commands (stdin)
386
+ // ============================================================================
387
+
388
+ /** Response to an extension UI request */
389
+ export type RpcExtensionUIResponse =
390
+ | { type: "extension_ui_response"; id: string; value: string }
391
+ | { type: "extension_ui_response"; id: string; values: string[] }
392
+ | { type: "extension_ui_response"; id: string; confirmed: boolean }
393
+ | { type: "extension_ui_response"; id: string; cancelled: true };
394
+
395
+ // ============================================================================
396
+ // Helper type for extracting command types
397
+ // ============================================================================
398
+
399
+ export type RpcCommandType = RpcCommand["type"];
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2024",
4
+ "module": "Node16",
5
+ "lib": ["ES2024"],
6
+ "strict": true,
7
+ "esModuleInterop": true,
8
+ "skipLibCheck": true,
9
+ "moduleResolution": "Node16",
10
+ "noEmit": true,
11
+ "types": ["node"],
12
+ "paths": {
13
+ "@gsd-build/rpc-client": ["./src/index.ts"]
14
+ }
15
+ },
16
+ "include": ["examples/**/*.ts"]
17
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2024",
4
+ "module": "Node16",
5
+ "lib": ["ES2024"],
6
+ "strict": true,
7
+ "esModuleInterop": true,
8
+ "skipLibCheck": true,
9
+ "forceConsistentCasingInFileNames": true,
10
+ "declaration": true,
11
+ "declarationMap": true,
12
+ "sourceMap": true,
13
+ "inlineSources": true,
14
+ "inlineSourceMap": false,
15
+ "moduleResolution": "Node16",
16
+ "resolveJsonModule": true,
17
+ "allowImportingTsExtensions": false,
18
+ "types": ["node"],
19
+ "outDir": "./dist",
20
+ "rootDir": "./src"
21
+ },
22
+ "include": ["src/**/*.ts"],
23
+ "exclude": ["node_modules", "dist", "**/*.d.ts", "src/**/*.d.ts"]
24
+ }