gsd-pi 2.53.0 → 2.54.0-dev.16631ca

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 (200) hide show
  1. package/dist/cli.js +19 -19
  2. package/dist/headless-ui.d.ts +29 -3
  3. package/dist/headless-ui.js +221 -28
  4. package/dist/headless.d.ts +11 -0
  5. package/dist/headless.js +238 -41
  6. package/dist/resources/extensions/bg-shell/bg-shell-lifecycle.js +2 -2
  7. package/dist/resources/extensions/bg-shell/utilities.js +34 -5
  8. package/dist/resources/extensions/gsd/auto/phases.js +10 -1
  9. package/dist/resources/extensions/gsd/auto-dispatch.js +1 -1
  10. package/dist/resources/extensions/gsd/auto-model-selection.js +17 -1
  11. package/dist/resources/extensions/gsd/auto-prompts.js +9 -0
  12. package/dist/resources/extensions/gsd/bootstrap/register-extension.js +18 -5
  13. package/dist/web/standalone/.next/BUILD_ID +1 -1
  14. package/dist/web/standalone/.next/app-path-routes-manifest.json +19 -19
  15. package/dist/web/standalone/.next/build-manifest.json +4 -4
  16. package/dist/web/standalone/.next/prerender-manifest.json +3 -3
  17. package/dist/web/standalone/.next/react-loadable-manifest.json +1 -1
  18. package/dist/web/standalone/.next/required-server-files.json +4 -4
  19. package/dist/web/standalone/.next/server/app/_global-error/page.js +3 -3
  20. package/dist/web/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  21. package/dist/web/standalone/.next/server/app/_global-error.html +2 -2
  22. package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
  23. package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  24. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  25. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  26. package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  27. package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  28. package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  29. package/dist/web/standalone/.next/server/app/_not-found/page.js +2 -2
  30. package/dist/web/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  31. package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
  32. package/dist/web/standalone/.next/server/app/_not-found.rsc +3 -3
  33. package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
  34. package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  35. package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +3 -3
  36. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  37. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  38. package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  39. package/dist/web/standalone/.next/server/app/api/boot/route.js +1 -1
  40. package/dist/web/standalone/.next/server/app/api/boot/route_client-reference-manifest.js +1 -1
  41. package/dist/web/standalone/.next/server/app/api/bridge-terminal/input/route.js +1 -1
  42. package/dist/web/standalone/.next/server/app/api/bridge-terminal/input/route_client-reference-manifest.js +1 -1
  43. package/dist/web/standalone/.next/server/app/api/bridge-terminal/resize/route.js +1 -1
  44. package/dist/web/standalone/.next/server/app/api/bridge-terminal/resize/route_client-reference-manifest.js +1 -1
  45. package/dist/web/standalone/.next/server/app/api/bridge-terminal/stream/route.js +2 -2
  46. package/dist/web/standalone/.next/server/app/api/bridge-terminal/stream/route_client-reference-manifest.js +1 -1
  47. package/dist/web/standalone/.next/server/app/api/browse-directories/route.js +1 -1
  48. package/dist/web/standalone/.next/server/app/api/browse-directories/route_client-reference-manifest.js +1 -1
  49. package/dist/web/standalone/.next/server/app/api/captures/route.js +1 -1
  50. package/dist/web/standalone/.next/server/app/api/captures/route_client-reference-manifest.js +1 -1
  51. package/dist/web/standalone/.next/server/app/api/cleanup/route.js +1 -1
  52. package/dist/web/standalone/.next/server/app/api/cleanup/route_client-reference-manifest.js +1 -1
  53. package/dist/web/standalone/.next/server/app/api/dev-mode/route.js +1 -1
  54. package/dist/web/standalone/.next/server/app/api/dev-mode/route_client-reference-manifest.js +1 -1
  55. package/dist/web/standalone/.next/server/app/api/doctor/route.js +1 -1
  56. package/dist/web/standalone/.next/server/app/api/doctor/route_client-reference-manifest.js +1 -1
  57. package/dist/web/standalone/.next/server/app/api/experimental/route.js +2 -2
  58. package/dist/web/standalone/.next/server/app/api/experimental/route_client-reference-manifest.js +1 -1
  59. package/dist/web/standalone/.next/server/app/api/export-data/route.js +1 -1
  60. package/dist/web/standalone/.next/server/app/api/export-data/route_client-reference-manifest.js +1 -1
  61. package/dist/web/standalone/.next/server/app/api/files/route.js +1 -1
  62. package/dist/web/standalone/.next/server/app/api/files/route_client-reference-manifest.js +1 -1
  63. package/dist/web/standalone/.next/server/app/api/forensics/route.js +1 -1
  64. package/dist/web/standalone/.next/server/app/api/forensics/route_client-reference-manifest.js +1 -1
  65. package/dist/web/standalone/.next/server/app/api/git/route.js +1 -1
  66. package/dist/web/standalone/.next/server/app/api/git/route_client-reference-manifest.js +1 -1
  67. package/dist/web/standalone/.next/server/app/api/history/route.js +1 -1
  68. package/dist/web/standalone/.next/server/app/api/history/route_client-reference-manifest.js +1 -1
  69. package/dist/web/standalone/.next/server/app/api/hooks/route.js +1 -1
  70. package/dist/web/standalone/.next/server/app/api/hooks/route_client-reference-manifest.js +1 -1
  71. package/dist/web/standalone/.next/server/app/api/inspect/route.js +1 -1
  72. package/dist/web/standalone/.next/server/app/api/inspect/route_client-reference-manifest.js +1 -1
  73. package/dist/web/standalone/.next/server/app/api/knowledge/route.js +1 -1
  74. package/dist/web/standalone/.next/server/app/api/knowledge/route_client-reference-manifest.js +1 -1
  75. package/dist/web/standalone/.next/server/app/api/live-state/route.js +1 -1
  76. package/dist/web/standalone/.next/server/app/api/live-state/route_client-reference-manifest.js +1 -1
  77. package/dist/web/standalone/.next/server/app/api/onboarding/route.js +1 -1
  78. package/dist/web/standalone/.next/server/app/api/onboarding/route_client-reference-manifest.js +1 -1
  79. package/dist/web/standalone/.next/server/app/api/preferences/route.js +1 -1
  80. package/dist/web/standalone/.next/server/app/api/preferences/route_client-reference-manifest.js +1 -1
  81. package/dist/web/standalone/.next/server/app/api/projects/route.js +1 -1
  82. package/dist/web/standalone/.next/server/app/api/projects/route_client-reference-manifest.js +1 -1
  83. package/dist/web/standalone/.next/server/app/api/recovery/route.js +1 -1
  84. package/dist/web/standalone/.next/server/app/api/recovery/route_client-reference-manifest.js +1 -1
  85. package/dist/web/standalone/.next/server/app/api/remote-questions/route.js +2 -2
  86. package/dist/web/standalone/.next/server/app/api/remote-questions/route_client-reference-manifest.js +1 -1
  87. package/dist/web/standalone/.next/server/app/api/session/browser/route.js +1 -1
  88. package/dist/web/standalone/.next/server/app/api/session/browser/route_client-reference-manifest.js +1 -1
  89. package/dist/web/standalone/.next/server/app/api/session/command/route.js +1 -1
  90. package/dist/web/standalone/.next/server/app/api/session/command/route_client-reference-manifest.js +1 -1
  91. package/dist/web/standalone/.next/server/app/api/session/events/route.js +2 -2
  92. package/dist/web/standalone/.next/server/app/api/session/events/route_client-reference-manifest.js +1 -1
  93. package/dist/web/standalone/.next/server/app/api/session/manage/route.js +1 -1
  94. package/dist/web/standalone/.next/server/app/api/session/manage/route_client-reference-manifest.js +1 -1
  95. package/dist/web/standalone/.next/server/app/api/settings-data/route.js +1 -1
  96. package/dist/web/standalone/.next/server/app/api/settings-data/route_client-reference-manifest.js +1 -1
  97. package/dist/web/standalone/.next/server/app/api/shutdown/route.js +1 -1
  98. package/dist/web/standalone/.next/server/app/api/shutdown/route_client-reference-manifest.js +1 -1
  99. package/dist/web/standalone/.next/server/app/api/skill-health/route.js +1 -1
  100. package/dist/web/standalone/.next/server/app/api/skill-health/route_client-reference-manifest.js +1 -1
  101. package/dist/web/standalone/.next/server/app/api/steer/route.js +1 -1
  102. package/dist/web/standalone/.next/server/app/api/steer/route_client-reference-manifest.js +1 -1
  103. package/dist/web/standalone/.next/server/app/api/switch-root/route.js +1 -1
  104. package/dist/web/standalone/.next/server/app/api/switch-root/route_client-reference-manifest.js +1 -1
  105. package/dist/web/standalone/.next/server/app/api/terminal/input/route.js +2 -2
  106. package/dist/web/standalone/.next/server/app/api/terminal/input/route_client-reference-manifest.js +1 -1
  107. package/dist/web/standalone/.next/server/app/api/terminal/resize/route.js +2 -2
  108. package/dist/web/standalone/.next/server/app/api/terminal/resize/route_client-reference-manifest.js +1 -1
  109. package/dist/web/standalone/.next/server/app/api/terminal/sessions/route.js +2 -2
  110. package/dist/web/standalone/.next/server/app/api/terminal/sessions/route_client-reference-manifest.js +1 -1
  111. package/dist/web/standalone/.next/server/app/api/terminal/stream/route.js +4 -4
  112. package/dist/web/standalone/.next/server/app/api/terminal/stream/route_client-reference-manifest.js +1 -1
  113. package/dist/web/standalone/.next/server/app/api/terminal/upload/route.js +1 -1
  114. package/dist/web/standalone/.next/server/app/api/terminal/upload/route_client-reference-manifest.js +1 -1
  115. package/dist/web/standalone/.next/server/app/api/undo/route.js +1 -1
  116. package/dist/web/standalone/.next/server/app/api/undo/route_client-reference-manifest.js +1 -1
  117. package/dist/web/standalone/.next/server/app/api/update/route.js +1 -1
  118. package/dist/web/standalone/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
  119. package/dist/web/standalone/.next/server/app/api/visualizer/route.js +1 -1
  120. package/dist/web/standalone/.next/server/app/api/visualizer/route_client-reference-manifest.js +1 -1
  121. package/dist/web/standalone/.next/server/app/index.html +1 -1
  122. package/dist/web/standalone/.next/server/app/index.rsc +4 -4
  123. package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  124. package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +4 -4
  125. package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  126. package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +3 -3
  127. package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  128. package/dist/web/standalone/.next/server/app/page.js +2 -2
  129. package/dist/web/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  130. package/dist/web/standalone/.next/server/app-paths-manifest.json +19 -19
  131. package/dist/web/standalone/.next/server/chunks/2229.js +2 -2
  132. package/dist/web/standalone/.next/server/chunks/7471.js +3 -3
  133. package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
  134. package/dist/web/standalone/.next/server/middleware-react-loadable-manifest.js +1 -1
  135. package/dist/web/standalone/.next/server/middleware.js +2 -2
  136. package/dist/web/standalone/.next/server/next-font-manifest.js +1 -1
  137. package/dist/web/standalone/.next/server/next-font-manifest.json +1 -1
  138. package/dist/web/standalone/.next/server/pages/404.html +1 -1
  139. package/dist/web/standalone/.next/server/pages/500.html +2 -2
  140. package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
  141. package/dist/web/standalone/.next/static/chunks/4024.82f2e2a838908338.js +9 -0
  142. package/dist/web/standalone/.next/static/chunks/app/_not-found/{page-2f24283c162b6ab3.js → page-f2a7482d42a5614b.js} +1 -1
  143. package/dist/web/standalone/.next/static/chunks/app/{layout-9ecfd95f343793f0.js → layout-a16c7a7ecdf0c2cf.js} +1 -1
  144. package/dist/web/standalone/.next/static/chunks/app/page-b950e4e384cc62b3.js +1 -0
  145. package/dist/web/standalone/.next/static/chunks/main-app-fdab67f7802d7832.js +1 -0
  146. package/dist/web/standalone/.next/static/chunks/next/dist/client/components/builtin/global-error-459824ffb8c323dd.js +1 -0
  147. package/dist/web/standalone/.next/static/chunks/{webpack-bca0e732db0dcec3.js → webpack-70adf6e3be5479ce.js} +1 -1
  148. package/dist/web/standalone/node_modules/node-pty/build/Makefile +2 -2
  149. package/dist/web/standalone/node_modules/node-pty/build/Release/pty.node +0 -0
  150. package/dist/web/standalone/node_modules/node-pty/build/pty.target.mk +14 -14
  151. package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api.target.mk +14 -14
  152. package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api_except.target.mk +14 -14
  153. package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api_maybe.target.mk +14 -14
  154. package/dist/web/standalone/server.js +1 -1
  155. package/package.json +1 -1
  156. package/packages/mcp-server/README.md +6 -6
  157. package/packages/mcp-server/package.json +14 -4
  158. package/packages/mcp-server/src/cli.ts +1 -1
  159. package/packages/mcp-server/src/index.ts +1 -1
  160. package/packages/mcp-server/src/mcp-server.test.ts +2 -2
  161. package/packages/mcp-server/src/session-manager.ts +2 -2
  162. package/packages/mcp-server/src/types.ts +1 -1
  163. package/packages/pi-coding-agent/dist/core/model-registry.d.ts +1 -1
  164. package/packages/pi-coding-agent/dist/core/model-registry.d.ts.map +1 -1
  165. package/packages/pi-coding-agent/dist/core/model-registry.js.map +1 -1
  166. package/packages/pi-coding-agent/dist/modes/interactive/components/provider-manager.d.ts +2 -0
  167. package/packages/pi-coding-agent/dist/modes/interactive/components/provider-manager.d.ts.map +1 -1
  168. package/packages/pi-coding-agent/dist/modes/interactive/components/provider-manager.js +14 -2
  169. package/packages/pi-coding-agent/dist/modes/interactive/components/provider-manager.js.map +1 -1
  170. package/packages/pi-coding-agent/package.json +1 -1
  171. package/packages/pi-coding-agent/src/core/model-registry.ts +1 -1
  172. package/packages/pi-coding-agent/src/modes/interactive/components/provider-manager.ts +16 -2
  173. package/packages/rpc-client/README.md +125 -0
  174. package/packages/rpc-client/examples/basic-usage.ts +13 -0
  175. package/packages/rpc-client/package.json +17 -3
  176. package/packages/rpc-client/src/index.ts +10 -0
  177. package/packages/rpc-client/src/jsonl.ts +64 -0
  178. package/packages/rpc-client/src/rpc-client.test.ts +568 -0
  179. package/packages/rpc-client/src/rpc-client.ts +666 -0
  180. package/packages/rpc-client/src/rpc-types.ts +399 -0
  181. package/packages/rpc-client/tsconfig.examples.json +17 -0
  182. package/packages/rpc-client/tsconfig.json +24 -0
  183. package/pkg/package.json +1 -1
  184. package/src/resources/extensions/bg-shell/bg-shell-lifecycle.ts +2 -2
  185. package/src/resources/extensions/bg-shell/utilities.ts +39 -4
  186. package/src/resources/extensions/gsd/auto/phases.ts +14 -2
  187. package/src/resources/extensions/gsd/auto-dispatch.ts +1 -1
  188. package/src/resources/extensions/gsd/auto-model-selection.ts +21 -1
  189. package/src/resources/extensions/gsd/auto-prompts.ts +15 -0
  190. package/src/resources/extensions/gsd/bootstrap/register-extension.ts +19 -6
  191. package/src/resources/extensions/gsd/tests/auto-model-selection.test.ts +139 -0
  192. package/src/resources/extensions/gsd/tests/journal-integration.test.ts +55 -0
  193. package/src/resources/extensions/gsd/tests/plan-milestone-queue-context.test.ts +48 -0
  194. package/src/resources/extensions/gsd/tests/register-extension-guard.test.ts +59 -0
  195. package/dist/web/standalone/.next/static/chunks/4024.87fd909ae0110f50.js +0 -9
  196. package/dist/web/standalone/.next/static/chunks/app/page-fbecd1237e2d6d1f.js +0 -1
  197. package/dist/web/standalone/.next/static/chunks/main-app-d3d4c336195465f9.js +0 -1
  198. package/dist/web/standalone/.next/static/chunks/next/dist/client/components/builtin/global-error-ab5a8926e07ec673.js +0 -1
  199. /package/dist/web/standalone/.next/static/{mWBOLPnUoeaTGiD-vhu5O → 8yiPxQ52ue_s6qdrrAxsH}/_buildManifest.js +0 -0
  200. /package/dist/web/standalone/.next/static/{mWBOLPnUoeaTGiD-vhu5O → 8yiPxQ52ue_s6qdrrAxsH}/_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
+ }
package/pkg/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glittercowboy/gsd",
3
- "version": "2.53.0",
3
+ "version": "2.54.0",
4
4
  "piConfig": {
5
5
  "name": "gsd",
6
6
  "configDir": ".gsd"
@@ -22,7 +22,7 @@ import {
22
22
  loadManifest,
23
23
  pruneDeadProcesses,
24
24
  } from "./process-manager.js";
25
- import { formatUptime, resolveBgShellPersistenceCwd } from "./utilities.js";
25
+ import { formatUptime, getBgShellLiveCwd, resolveBgShellPersistenceCwd } from "./utilities.js";
26
26
  import { formatTokenCount } from "../shared/format-utils.js";
27
27
 
28
28
  import type { BgShellSharedState } from "./index.js";
@@ -213,7 +213,7 @@ export function registerBgShellLifecycle(pi: ExtensionAPI, state: BgShellSharedS
213
213
  return {
214
214
  render(width: number): string[] {
215
215
  // ── Line 1: pwd (branch) [session] ... bg status ──
216
- let pwd = process.cwd();
216
+ let pwd = getBgShellLiveCwd(state.latestCtx?.cwd);
217
217
  const home = process.env.HOME || process.env.USERPROFILE;
218
218
  if (home && pwd.startsWith(home)) {
219
219
  pwd = `~${pwd.slice(home.length)}`;
@@ -42,16 +42,51 @@ export function formatTimeAgo(timestamp: number): string {
42
42
  return formatDuration(Date.now() - timestamp) + " ago";
43
43
  }
44
44
 
45
+ function deriveProjectRootFromAutoWorktree(cachedCwd?: string): string | undefined {
46
+ if (!cachedCwd) return undefined;
47
+ const match = cachedCwd.match(/^(.*?)[\\/]\.gsd[\\/]worktrees[\\/][^\\/]+(?:[\\/].*)?$/);
48
+ return match?.[1];
49
+ }
50
+
51
+ export function getBgShellLiveCwd(
52
+ cachedCwd?: string,
53
+ pathExists: (path: string) => boolean = existsSync,
54
+ getCwd: () => string = () => process.cwd(),
55
+ chdir: (path: string) => void = (path) => process.chdir(path),
56
+ ): string {
57
+ try {
58
+ return getCwd();
59
+ } catch {
60
+ const projectRoot = deriveProjectRootFromAutoWorktree(cachedCwd);
61
+ const home = process.env.HOME || process.env.USERPROFILE;
62
+ const fallbacks = [projectRoot, cachedCwd, home, "/"].filter(
63
+ (candidate): candidate is string => Boolean(candidate),
64
+ );
65
+
66
+ for (const candidate of fallbacks) {
67
+ if (candidate !== "/" && !pathExists(candidate)) continue;
68
+ try {
69
+ chdir(candidate);
70
+ } catch {
71
+ // Best-effort only. Returning a known-good fallback is enough to avoid crashes.
72
+ }
73
+ return candidate;
74
+ }
75
+
76
+ return "/";
77
+ }
78
+ }
45
79
 
46
80
  export function resolveBgShellPersistenceCwd(
47
81
  cachedCwd: string,
48
- liveCwd = process.cwd(),
82
+ liveCwd: string | undefined = undefined,
49
83
  pathExists: (path: string) => boolean = existsSync,
50
84
  ): string {
85
+ const resolvedLiveCwd = liveCwd ?? getBgShellLiveCwd(cachedCwd, pathExists);
51
86
  const cachedIsAutoWorktree = /(?:^|[\\/])\.gsd[\\/]worktrees[\\/]/.test(cachedCwd);
52
87
  if (!cachedIsAutoWorktree) return cachedCwd;
53
- if (cachedCwd === liveCwd && pathExists(cachedCwd)) return cachedCwd;
54
- if (!pathExists(cachedCwd)) return liveCwd;
55
- if (liveCwd !== cachedCwd) return liveCwd;
88
+ if (cachedCwd === resolvedLiveCwd && pathExists(cachedCwd)) return cachedCwd;
89
+ if (!pathExists(cachedCwd)) return resolvedLiveCwd;
90
+ if (resolvedLiveCwd !== cachedCwd) return resolvedLiveCwd;
56
91
  return cachedCwd;
57
92
  }
@@ -45,6 +45,17 @@ export function _resolveReportBasePath(s: Pick<AutoSession, "originalBasePath" |
45
45
  return s.originalBasePath || s.basePath;
46
46
  }
47
47
 
48
+ /**
49
+ * Resolve the authoritative project base for dispatch guards.
50
+ * Prior-milestone completion lives at the project root, even when the active
51
+ * unit is running inside an auto worktree.
52
+ */
53
+ export function _resolveDispatchGuardBasePath(
54
+ s: Pick<AutoSession, "originalBasePath" | "basePath">,
55
+ ): string {
56
+ return s.originalBasePath || s.basePath;
57
+ }
58
+
48
59
  /**
49
60
  * Generate and write an HTML milestone report snapshot.
50
61
  * Extracted from the milestone-transition block in autoLoop.
@@ -667,9 +678,10 @@ export async function runDispatch(
667
678
  prompt = preDispatchResult.prompt;
668
679
  }
669
680
 
681
+ const guardBasePath = _resolveDispatchGuardBasePath(s);
670
682
  const priorSliceBlocker = deps.getPriorSliceCompletionBlocker(
671
- s.basePath,
672
- deps.getMainBranch(s.basePath),
683
+ guardBasePath,
684
+ deps.getMainBranch(guardBasePath),
673
685
  unitType,
674
686
  unitId,
675
687
  );
@@ -200,7 +200,7 @@ export const DISPATCH_RULES: DispatchRule[] = [
200
200
  uatContent ?? "",
201
201
  basePath,
202
202
  ),
203
- pauseAfterDispatch: uatType !== "artifact-driven" && uatType !== "browser-executable" && uatType !== "runtime-executable",
203
+ pauseAfterDispatch: !process.env.GSD_HEADLESS && uatType !== "artifact-driven" && uatType !== "browser-executable" && uatType !== "runtime-executable",
204
204
  };
205
205
  },
206
206
  },
@@ -18,6 +18,26 @@ export interface ModelSelectionResult {
18
18
  routing: { tier: string; modelDowngraded: boolean } | null;
19
19
  }
20
20
 
21
+ export function resolvePreferredModelConfig(
22
+ unitType: string,
23
+ autoModeStartModel: { provider: string; id: string } | null,
24
+ ) {
25
+ const explicitConfig = resolveModelWithFallbacksForUnit(unitType);
26
+ if (explicitConfig) return explicitConfig;
27
+
28
+ const routingConfig = resolveDynamicRoutingConfig();
29
+ if (!routingConfig.enabled || !routingConfig.tier_models) return undefined;
30
+
31
+ const ceilingModel = routingConfig.tier_models.heavy
32
+ ?? (autoModeStartModel ? `${autoModeStartModel.provider}/${autoModeStartModel.id}` : undefined);
33
+ if (!ceilingModel) return undefined;
34
+
35
+ return {
36
+ primary: ceilingModel,
37
+ fallbacks: [],
38
+ };
39
+ }
40
+
21
41
  /**
22
42
  * Select and apply the appropriate model for a unit dispatch.
23
43
  * Handles: per-unit-type model preferences, dynamic complexity routing,
@@ -36,7 +56,7 @@ export async function selectAndApplyModel(
36
56
  autoModeStartModel: { provider: string; id: string } | null,
37
57
  retryContext?: { isRetry: boolean; previousTier?: string },
38
58
  ): Promise<ModelSelectionResult> {
39
- const modelConfig = resolveModelWithFallbacksForUnit(unitType);
59
+ const modelConfig = resolvePreferredModelConfig(unitType, autoModeStartModel);
40
60
  let routing: { tier: string; modelDowngraded: boolean } | null = null;
41
61
 
42
62
  if (modelConfig) {
@@ -87,6 +87,11 @@ function buildSourceFilePaths(
87
87
  paths.push(`- **Decisions**: \`${relGsdRootFile("DECISIONS")}\``);
88
88
  }
89
89
 
90
+ const queuePath = resolveGsdRootFile(base, "QUEUE");
91
+ if (existsSync(queuePath)) {
92
+ paths.push(`- **Queue**: \`${relGsdRootFile("QUEUE")}\``);
93
+ }
94
+
90
95
  const contextPath = resolveMilestoneFile(base, mid, "CONTEXT");
91
96
  if (contextPath) {
92
97
  paths.push(`- **Milestone Context**: \`${relMilestoneFile(base, mid, "CONTEXT")}\``);
@@ -915,6 +920,16 @@ export async function buildPlanMilestonePrompt(mid: string, midTitle: string, ba
915
920
  const decisionsInline = await inlineDecisionsFromDb(base, mid, undefined, inlineLevel);
916
921
  if (decisionsInline) inlined.push(decisionsInline);
917
922
  }
923
+ const queuePath = resolveGsdRootFile(base, "QUEUE");
924
+ if (existsSync(queuePath)) {
925
+ const queueInline = await inlineFileSmart(
926
+ queuePath,
927
+ relGsdRootFile("QUEUE"),
928
+ "Project Queue",
929
+ `${mid} ${midTitle}`,
930
+ );
931
+ inlined.push(queueInline);
932
+ }
918
933
  const knowledgeInlinePM = await inlineGsdRootFile(base, "knowledge.md", "Project Knowledge");
919
934
  if (knowledgeInlinePM) inlined.push(knowledgeInlinePM);
920
935
  inlined.push(inlineTemplate("roadmap", "Roadmap"));
@@ -9,14 +9,28 @@ import { registerJournalTools } from "./journal-tools.js";
9
9
  import { registerHooks } from "./register-hooks.js";
10
10
  import { registerShortcuts } from "./register-shortcuts.js";
11
11
 
12
+ export function handleRecoverableExtensionProcessError(err: Error): boolean {
13
+ if ((err as NodeJS.ErrnoException).code === "EPIPE") {
14
+ process.exit(0);
15
+ }
16
+ if ((err as NodeJS.ErrnoException).code === "ENOENT") {
17
+ const syscall = (err as NodeJS.ErrnoException).syscall;
18
+ if (syscall?.startsWith("spawn")) {
19
+ process.stderr.write(`[gsd] spawn ENOENT: ${(err as any).path ?? "unknown"} — command not found\n`);
20
+ return true;
21
+ }
22
+ if (syscall === "uv_cwd") {
23
+ process.stderr.write(`[gsd] ENOENT (${syscall}): ${err.message}\n`);
24
+ return true;
25
+ }
26
+ }
27
+ return false;
28
+ }
29
+
12
30
  function installEpipeGuard(): void {
13
31
  if (!process.listeners("uncaughtException").some((listener) => listener.name === "_gsdEpipeGuard")) {
14
32
  const _gsdEpipeGuard = (err: Error): void => {
15
- if ((err as NodeJS.ErrnoException).code === "EPIPE") {
16
- process.exit(0);
17
- }
18
- if ((err as NodeJS.ErrnoException).code === "ENOENT" && (err as any).syscall?.startsWith("spawn")) {
19
- process.stderr.write(`[gsd] spawn ENOENT: ${(err as any).path ?? "unknown"} — command not found\n`);
33
+ if (handleRecoverableExtensionProcessError(err)) {
20
34
  return;
21
35
  }
22
36
  throw err;
@@ -45,4 +59,3 @@ export function registerGsdExtension(pi: ExtensionAPI): void {
45
59
  registerShortcuts(pi);
46
60
  registerHooks(pi);
47
61
  }
48
-