@steerable/agent-shell 0.6.15

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 (204) hide show
  1. package/LICENSE +91 -0
  2. package/contracts/tool-contract.json +326 -0
  3. package/dist/attachments.d.ts +41 -0
  4. package/dist/attachments.js +147 -0
  5. package/dist/brand.d.ts +24 -0
  6. package/dist/brand.js +92 -0
  7. package/dist/host/http-routes.d.ts +21 -0
  8. package/dist/host/http-routes.js +55 -0
  9. package/dist/host/ipc.d.ts +11 -0
  10. package/dist/host/ipc.js +20 -0
  11. package/dist/host/pack-assembly.d.ts +86 -0
  12. package/dist/host/pack-assembly.js +32 -0
  13. package/dist/host/runtime.d.ts +69 -0
  14. package/dist/host/runtime.js +207 -0
  15. package/dist/host/visible-terminal-exec.d.ts +21 -0
  16. package/dist/host/visible-terminal-exec.js +151 -0
  17. package/dist/hosted-web-search.d.ts +13 -0
  18. package/dist/hosted-web-search.js +82 -0
  19. package/dist/image-attachment.d.ts +39 -0
  20. package/dist/image-attachment.js +133 -0
  21. package/dist/insights/flush.d.ts +10 -0
  22. package/dist/insights/flush.js +139 -0
  23. package/dist/insights/record.d.ts +17 -0
  24. package/dist/insights/record.js +44 -0
  25. package/dist/json-store.d.ts +9 -0
  26. package/dist/json-store.js +22 -0
  27. package/dist/llm/index.d.ts +23 -0
  28. package/dist/llm/index.js +105 -0
  29. package/dist/llm/ollama.d.ts +23 -0
  30. package/dist/llm/ollama.js +242 -0
  31. package/dist/llm/openai-compat.d.ts +20 -0
  32. package/dist/llm/openai-compat.js +199 -0
  33. package/dist/llm/sidecar-provider.d.ts +37 -0
  34. package/dist/llm/sidecar-provider.js +163 -0
  35. package/dist/llm/tool-choice.d.ts +35 -0
  36. package/dist/llm/tool-choice.js +85 -0
  37. package/dist/llm/types.d.ts +122 -0
  38. package/dist/llm/types.js +1 -0
  39. package/dist/local-backend/agent-capability.d.ts +101 -0
  40. package/dist/local-backend/agent-capability.js +174 -0
  41. package/dist/local-backend/ai-title.d.ts +43 -0
  42. package/dist/local-backend/ai-title.js +173 -0
  43. package/dist/local-backend/auto-continue-helper.d.ts +80 -0
  44. package/dist/local-backend/auto-continue-helper.js +83 -0
  45. package/dist/local-backend/branch-helper.d.ts +24 -0
  46. package/dist/local-backend/branch-helper.js +27 -0
  47. package/dist/local-backend/context-compactor.d.ts +81 -0
  48. package/dist/local-backend/context-compactor.js +213 -0
  49. package/dist/local-backend/coreloop-stream.d.ts +245 -0
  50. package/dist/local-backend/coreloop-stream.js +277 -0
  51. package/dist/local-backend/deferred-detector.d.ts +15 -0
  52. package/dist/local-backend/deferred-detector.js +124 -0
  53. package/dist/local-backend/history-helper.d.ts +30 -0
  54. package/dist/local-backend/history-helper.js +34 -0
  55. package/dist/local-backend/interrupted-helper.d.ts +29 -0
  56. package/dist/local-backend/interrupted-helper.js +25 -0
  57. package/dist/local-backend/live-stream.d.ts +36 -0
  58. package/dist/local-backend/live-stream.js +23 -0
  59. package/dist/local-backend/llm-diagnose.d.ts +37 -0
  60. package/dist/local-backend/llm-diagnose.js +284 -0
  61. package/dist/local-backend/message-triggers.d.ts +27 -0
  62. package/dist/local-backend/message-triggers.js +67 -0
  63. package/dist/local-backend/pack-backend-routes.d.ts +31 -0
  64. package/dist/local-backend/pack-backend-routes.js +62 -0
  65. package/dist/local-backend/pack-turn-hooks.d.ts +37 -0
  66. package/dist/local-backend/pack-turn-hooks.js +67 -0
  67. package/dist/local-backend/prompt-builder.d.ts +101 -0
  68. package/dist/local-backend/prompt-builder.js +246 -0
  69. package/dist/local-backend/regenerate-helper.d.ts +62 -0
  70. package/dist/local-backend/regenerate-helper.js +75 -0
  71. package/dist/local-backend/router.d.ts +175 -0
  72. package/dist/local-backend/router.js +3139 -0
  73. package/dist/local-backend/skill-install.d.ts +19 -0
  74. package/dist/local-backend/skill-install.js +71 -0
  75. package/dist/local-backend/skill-loader.d.ts +92 -0
  76. package/dist/local-backend/skill-loader.js +146 -0
  77. package/dist/local-backend/skills/00-identity/SKILL.md +32 -0
  78. package/dist/local-backend/skills/10-goal/SKILL.md +59 -0
  79. package/dist/local-backend/skills/11-loop/SKILL.md +71 -0
  80. package/dist/local-backend/skills/12-create-skill/SKILL.md +88 -0
  81. package/dist/local-backend/skills/70-plan-mode/SKILL.md +58 -0
  82. package/dist/local-backend/skills/80-tool-usage/SKILL.md +70 -0
  83. package/dist/local-backend/skills/81-anti-deferred/SKILL.md +53 -0
  84. package/dist/local-backend/skills/82-data-grounding/SKILL.md +56 -0
  85. package/dist/local-backend/skills/85-local-exec/SKILL.md +86 -0
  86. package/dist/local-backend/skills/86-proactive-coding/SKILL.md +51 -0
  87. package/dist/local-backend/subagent-profiles.d.ts +30 -0
  88. package/dist/local-backend/subagent-profiles.js +74 -0
  89. package/dist/local-backend/task-process.d.ts +12 -0
  90. package/dist/local-backend/task-process.js +176 -0
  91. package/dist/local-backend/task-service.d.ts +135 -0
  92. package/dist/local-backend/task-service.js +565 -0
  93. package/dist/local-backend/turn-duration.d.ts +2 -0
  94. package/dist/local-backend/turn-duration.js +9 -0
  95. package/dist/local-backend/turn-timeline.d.ts +16 -0
  96. package/dist/local-backend/turn-timeline.js +42 -0
  97. package/dist/local-backend/worktree-service.d.ts +84 -0
  98. package/dist/local-backend/worktree-service.js +243 -0
  99. package/dist/local-edit.d.ts +48 -0
  100. package/dist/local-edit.js +44 -0
  101. package/dist/local-executor.d.ts +255 -0
  102. package/dist/local-executor.js +881 -0
  103. package/dist/local-script-registry.d.ts +28 -0
  104. package/dist/local-script-registry.js +63 -0
  105. package/dist/log.d.ts +13 -0
  106. package/dist/log.js +12 -0
  107. package/dist/main.d.ts +1 -0
  108. package/dist/main.js +855 -0
  109. package/dist/mcp-executor.d.ts +45 -0
  110. package/dist/mcp-executor.js +241 -0
  111. package/dist/mcp-server-registry.d.ts +104 -0
  112. package/dist/mcp-server-registry.js +234 -0
  113. package/dist/preload-default.d.ts +1 -0
  114. package/dist/preload-default.js +9 -0
  115. package/dist/preload.cjs +395 -0
  116. package/dist/preload.d.ts +20 -0
  117. package/dist/preload.js +411 -0
  118. package/dist/product-config.d.ts +43 -0
  119. package/dist/product-config.js +26 -0
  120. package/dist/project-registry.d.ts +55 -0
  121. package/dist/project-registry.js +106 -0
  122. package/dist/project-rules.d.ts +15 -0
  123. package/dist/project-rules.js +102 -0
  124. package/dist/runtime.d.ts +62 -0
  125. package/dist/runtime.js +217 -0
  126. package/dist/scenario/pack.d.ts +8 -0
  127. package/dist/scenario/pack.js +1 -0
  128. package/dist/scenario/registry.d.ts +24 -0
  129. package/dist/scenario/registry.js +31 -0
  130. package/dist/server/http-server.d.ts +39 -0
  131. package/dist/server/http-server.js +361 -0
  132. package/dist/server/index.d.ts +1 -0
  133. package/dist/server/index.js +107 -0
  134. package/dist/server/sse-bus.d.ts +14 -0
  135. package/dist/server/sse-bus.js +31 -0
  136. package/dist/shell-adapt.d.ts +21 -0
  137. package/dist/shell-adapt.js +104 -0
  138. package/dist/sidecar/boot.d.ts +36 -0
  139. package/dist/sidecar/boot.js +343 -0
  140. package/dist/sidecar/egress-hint.d.ts +15 -0
  141. package/dist/sidecar/egress-hint.js +46 -0
  142. package/dist/sidecar/egress-proxy.d.ts +183 -0
  143. package/dist/sidecar/egress-proxy.js +419 -0
  144. package/dist/sidecar/errors.d.ts +22 -0
  145. package/dist/sidecar/errors.js +38 -0
  146. package/dist/sidecar/exec-sandbox.d.ts +48 -0
  147. package/dist/sidecar/exec-sandbox.js +94 -0
  148. package/dist/sidecar/handle.d.ts +32 -0
  149. package/dist/sidecar/handle.js +53 -0
  150. package/dist/sidecar/index.d.ts +14 -0
  151. package/dist/sidecar/index.js +13 -0
  152. package/dist/sidecar/proxy-detect.d.ts +50 -0
  153. package/dist/sidecar/proxy-detect.js +182 -0
  154. package/dist/sidecar/reverse-approval.d.ts +55 -0
  155. package/dist/sidecar/reverse-approval.js +86 -0
  156. package/dist/sidecar/reverse-ask-user.d.ts +34 -0
  157. package/dist/sidecar/reverse-ask-user.js +59 -0
  158. package/dist/sidecar/reverse-spawn.d.ts +19 -0
  159. package/dist/sidecar/reverse-spawn.js +161 -0
  160. package/dist/sidecar/reverse-tools.d.ts +29 -0
  161. package/dist/sidecar/reverse-tools.js +106 -0
  162. package/dist/sidecar/safety-patterns.d.ts +41 -0
  163. package/dist/sidecar/safety-patterns.js +157 -0
  164. package/dist/sidecar/storage-path.d.ts +14 -0
  165. package/dist/sidecar/storage-path.js +35 -0
  166. package/dist/sidecar/supervisor.d.ts +218 -0
  167. package/dist/sidecar/supervisor.js +932 -0
  168. package/dist/sidecar/types.d.ts +601 -0
  169. package/dist/sidecar/types.js +1 -0
  170. package/dist/single-instance.d.ts +11 -0
  171. package/dist/single-instance.js +21 -0
  172. package/dist/storage/empty-chats.d.ts +9 -0
  173. package/dist/storage/empty-chats.js +16 -0
  174. package/dist/storage/index.d.ts +373 -0
  175. package/dist/storage/index.js +1158 -0
  176. package/dist/storage/insights-redact.d.ts +2 -0
  177. package/dist/storage/insights-redact.js +30 -0
  178. package/dist/storage/insights-settings.d.ts +53 -0
  179. package/dist/storage/insights-settings.js +92 -0
  180. package/dist/storage/llm-settings.d.ts +120 -0
  181. package/dist/storage/llm-settings.js +233 -0
  182. package/dist/storage/local-store-singleton.d.ts +28 -0
  183. package/dist/storage/local-store-singleton.js +38 -0
  184. package/dist/storage/message-order.d.ts +25 -0
  185. package/dist/storage/message-order.js +27 -0
  186. package/dist/storage/pack-migrations.d.ts +22 -0
  187. package/dist/storage/pack-migrations.js +24 -0
  188. package/dist/storage/pack-seeds.d.ts +36 -0
  189. package/dist/storage/pack-seeds.js +42 -0
  190. package/dist/storage/telemetry-settings.d.ts +38 -0
  191. package/dist/storage/telemetry-settings.js +59 -0
  192. package/dist/storage/usage-summary.d.ts +55 -0
  193. package/dist/storage/usage-summary.js +38 -0
  194. package/dist/storage/web-search-settings.d.ts +38 -0
  195. package/dist/storage/web-search-settings.js +74 -0
  196. package/dist/storage/write-lease.d.ts +26 -0
  197. package/dist/storage/write-lease.js +74 -0
  198. package/dist/terminal-manager.d.ts +83 -0
  199. package/dist/terminal-manager.js +506 -0
  200. package/dist/tool-router.d.ts +228 -0
  201. package/dist/tool-router.js +930 -0
  202. package/dist/tool-search-rank.d.ts +42 -0
  203. package/dist/tool-search-rank.js +96 -0
  204. package/package.json +67 -0
@@ -0,0 +1,218 @@
1
+ /**
2
+ * Supervises the steerable-sidecar Python subprocess.
3
+ *
4
+ * Responsibilities:
5
+ * - locate the bundled portable Python runtime (or accept an override),
6
+ * - spawn the sidecar with stdin/stdout/stderr pipes,
7
+ * - wait for the `__SIDECAR_READY__` marker on stderr before resolving start(),
8
+ * - parse JSON-RPC frames and dispatch them to pending requests / handlers,
9
+ * - run a periodic `system.ping` health-check and auto-restart on failure,
10
+ * - kill the process when the Electron app quits.
11
+ */
12
+ import { EventEmitter } from 'node:events';
13
+ import type { SidecarApplyEditsResult, SidecarChatStreamHandlers, SidecarChatStreamRequest, SidecarHealthSnapshot, SidecarMethodOptions, SidecarModelCatalog, SidecarReverseHandler, SidecarSandboxPosture, SidecarSessionBranches, SidecarSessionForkOutcome, SidecarSessionMessages, SidecarSessionTree, SidecarSkillModule, SidecarStartOptions, SidecarToolResult } from './types.js';
14
+ /**
15
+ * Tool names carried by a `tool.list` reply.
16
+ *
17
+ * The sidecar answers with OpenAI function-call descriptors —
18
+ * `{ type: 'function', function: { name, description, parameters } }` — so the
19
+ * name sits one level in. Reading a top-level `name` yields undefined for every
20
+ * entry, which reads as "the sidecar registered nothing" rather than as a
21
+ * decoding error.
22
+ */
23
+ export declare function toolNamesFromDescriptors(listed: unknown): string[];
24
+ /**
25
+ * `SidecarSupervisor.start()` 的 boot 失败错误上携带的实例:后台 restart
26
+ * 循环仍在重试,宿主可监听其 'ready' 事件处理迟到就绪。
27
+ */
28
+ export interface SidecarBootFailure {
29
+ supervisor?: SidecarSupervisor;
30
+ }
31
+ export declare class SidecarSupervisor extends EventEmitter {
32
+ private readonly options;
33
+ /** Last layer-1 refuse when start() threw (settings page still needs a posture). */
34
+ static lastSpawnRefusal: SidecarSandboxPosture | null;
35
+ private child;
36
+ private readyHealth;
37
+ private sandboxPosture;
38
+ private nextRequestId;
39
+ private pending;
40
+ private stdoutBuffer;
41
+ private stderrBuffer;
42
+ private healthTimer;
43
+ private failedPings;
44
+ private shuttingDown;
45
+ private quitListener;
46
+ private reverseHandlers;
47
+ private constructor();
48
+ /** Spawn the sidecar and wait for the ready marker. */
49
+ static start(options?: SidecarStartOptions): Promise<SidecarSupervisor>;
50
+ /** Round-trip a JSON-RPC method call. */
51
+ call<T = unknown>(method: string, params?: unknown, options?: SidecarMethodOptions): Promise<T>;
52
+ /** Convenience: list tools registered on the sidecar. */
53
+ listTools(): Promise<unknown[]>;
54
+ /**
55
+ * The gateway's live model catalog (`models.list`): ids the configured
56
+ * gateway actually accepts, joined with models.dev capabilities. The
57
+ * host passes the user's configured baseUrl/apiKey explicitly — the
58
+ * sidecar process env does not carry the app's settings. Fetch failures
59
+ * come back as `catalogStatus: 'offline'`/`'stale'` in the payload, not
60
+ * as RPC errors, so the picker can badge instead of breaking.
61
+ */
62
+ listModels(params?: {
63
+ baseUrl?: string;
64
+ apiKey?: string;
65
+ refresh?: boolean;
66
+ provider?: string;
67
+ }): Promise<SidecarModelCatalog>;
68
+ /** Names advertised by the sidecar's registry, decoded from `tool.list`. */
69
+ listToolNames(): Promise<string[]>;
70
+ /** Convenience: invoke a tool by name. */
71
+ invokeTool(name: string, args?: Record<string, unknown>, extra?: {
72
+ consentGranted?: boolean;
73
+ context?: Record<string, unknown>;
74
+ timeoutMs?: number;
75
+ }): Promise<SidecarToolResult>;
76
+ /** Convenience: ping for a health snapshot. */
77
+ ping(): Promise<SidecarHealthSnapshot>;
78
+ /**
79
+ * W6-1 single source of truth: run the structured-edit algorithm in the
80
+ * sidecar (Python `file_edit.apply_edits`) on caller-supplied content. The
81
+ * host keeps all file I/O (read / version check / atomic write); only the
82
+ * locate-and-replace surgery crosses the wire so the desktop and the
83
+ * headless / ACP workspace tools share one implementation.
84
+ */
85
+ applyEdits(params: {
86
+ content: string;
87
+ edits: Array<{
88
+ oldText: string;
89
+ newText: string;
90
+ }>;
91
+ filePath?: string;
92
+ }): Promise<SidecarApplyEditsResult>;
93
+ /**
94
+ * Skills single source of truth: parse + select SKILL.md modules in the
95
+ * sidecar (Python `skills.py`) from host-supplied roots. Returns both layers
96
+ * with bodies; the host applies its own layer filter / budget / name lookup.
97
+ */
98
+ listSkills(params: {
99
+ roots: string[];
100
+ conditions?: string[];
101
+ exclude?: string[];
102
+ ignoreConditions?: boolean;
103
+ }): Promise<SidecarSkillModule[]>;
104
+ /**
105
+ * Run a streaming chat completion through the sidecar's `agent.chat.stream`
106
+ * method. Subscribes to `stream.chunk` / `stream.done` / `stream.error`
107
+ * notifications, demuxes them by `streamId`, and surfaces them through the
108
+ * supplied callbacks.
109
+ *
110
+ * Returns the `streamId` so callers can correlate cancel requests.
111
+ */
112
+ streamChat(request: SidecarChatStreamRequest, handlers: SidecarChatStreamHandlers): Promise<string>;
113
+ /** Best-effort cancel a sidecar stream by id. */
114
+ cancelChat(streamId: string): Promise<void>;
115
+ /**
116
+ * W5-2: fork a durable record without running a turn — the non-destructive
117
+ * regenerate primitive.
118
+ *
119
+ * Reports why a fork did not happen instead of collapsing every cause to a
120
+ * single falsy value. The caller's fallback destroys the reply's UI row and
121
+ * lets the next turn append into the same record, so a declined address and a
122
+ * failed request are not interchangeable — see {@link SidecarSessionForkOutcome}.
123
+ */
124
+ forkSession(params: {
125
+ recordId: string;
126
+ beforeLastUser?: boolean;
127
+ beforeUserIndex?: number;
128
+ newRecordId?: string;
129
+ label?: string;
130
+ }): Promise<SidecarSessionForkOutcome>;
131
+ /**
132
+ * W1.2.1: branch-family view of a record (lineage + direct children).
133
+ * Soft-fail null when the sidecar has no such record — the caller renders
134
+ * "no branches" rather than an error.
135
+ */
136
+ sessionBranches(recordId: string): Promise<SidecarSessionBranches | null>;
137
+ /**
138
+ * Session tree: full branch family containing a record, expanded from
139
+ * the family root (`agent.session.tree`). Unlike {@link sessionBranches}
140
+ * (lineage + direct children only), this sees cousins and deeper
141
+ * descendants — the activation guard and the tree modal both need it.
142
+ * Soft-fail null when the sidecar has no such record — the caller
143
+ * renders "no branches" rather than an error.
144
+ */
145
+ sessionTree(recordId: string): Promise<SidecarSessionTree | null>;
146
+ /**
147
+ * W1.2.1: projected transcript of a record (post-boundary visible span) —
148
+ * the read path for rendering a branch after a switch. Soft-fail null.
149
+ */
150
+ sessionMessages(recordId: string): Promise<SidecarSessionMessages | null>;
151
+ /**
152
+ * Inject a user message into a running CoreLoop turn (mid-turn steering).
153
+ * Soft-fails (`{ ok: false }`) when the turn already ended — the caller
154
+ * should then send the message as a normal new turn instead.
155
+ */
156
+ steerChat(streamId: string, content: string): Promise<boolean>;
157
+ /**
158
+ * Register a host-side handler for a reverse (sidecar -> host) request.
159
+ *
160
+ * When the sidecar hosts the agent loop but a tool must execute in the
161
+ * Electron process (shell, filesystem, MCP), the sidecar sends a reverse
162
+ * `tool.invoke` request; the handler registered for that method runs the
163
+ * real tool and its return value is sent back as the JSON-RPC result.
164
+ */
165
+ onReverseRequest(method: string, handler: SidecarReverseHandler): void;
166
+ /** Returns the most recent ready snapshot collected at boot. */
167
+ getBootSnapshot(): SidecarHealthSnapshot | null;
168
+ /**
169
+ * W4-3: the layer-1 (sidecar process sandbox) posture recorded at
170
+ * spawn-plan time. This is the value the renderer reads (via
171
+ * `GET /api/v2/sidecar/sandbox-posture`) to disclose confined / opt-out
172
+ * / refused-start. A refused start also lands on `lastSpawnRefusal`.
173
+ */
174
+ getSandboxPosture(): SidecarSandboxPosture | null;
175
+ /** Graceful shutdown. */
176
+ shutdown(): Promise<void>;
177
+ private boot;
178
+ /**
179
+ * Wrap the sidecar spawn in the platform's process sandbox.
180
+ *
181
+ * macOS Seatbelt, Linux bwrap/Landlock, Windows restricted-token
182
+ * passthrough. Any failure refuses start — confinement requested means
183
+ * the process does not run unsandboxed. Explicit opt-out
184
+ * (`sandbox: false` / `STEERABLE_SIDECAR_SANDBOX=0`) is the only
185
+ * unconfined path. Every exit records `sandboxPosture`.
186
+ */
187
+ private resolveSandboxedSpawn;
188
+ private refuse;
189
+ private wrapSeatbelt;
190
+ private wrapLinux;
191
+ private wrapWindows;
192
+ private attachListeners;
193
+ private installAppQuitHook;
194
+ private waitForReady;
195
+ private handleStdoutChunk;
196
+ private handleStderrChunk;
197
+ private handleStderrLine;
198
+ private handleStdoutLine;
199
+ private handleReverseRequest;
200
+ private writeFrame;
201
+ private dispatchResponse;
202
+ private dispatchNotification;
203
+ private startHealthTimer;
204
+ private stopHealthTimer;
205
+ private runHealthCheck;
206
+ private scheduleRestart;
207
+ private restart;
208
+ private requireChild;
209
+ private failPending;
210
+ private resolvePythonBinary;
211
+ }
212
+ /**
213
+ * Resolve the sidecar's Python interpreter: explicit option →
214
+ * STEERABLE_SIDECAR_PYTHON → bundled python-runtime → sibling framework
215
+ * venv (dev layout) → system python. Module-level so the egress-proxy
216
+ * launcher (W1.3.3) spawns the same interpreter the sidecar uses.
217
+ */
218
+ export declare function resolveSidecarPython(pythonExecutable?: string): string;