@smooai/smooth-operator-core 0.10.0 → 0.10.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/dist/agent.d.ts +276 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +450 -0
- package/dist/agent.js.map +1 -0
- package/dist/cast.d.ts +81 -0
- package/dist/cast.d.ts.map +1 -0
- package/dist/cast.js +103 -0
- package/dist/cast.js.map +1 -0
- package/dist/checkpoint.d.ts +25 -0
- package/dist/checkpoint.d.ts.map +1 -0
- package/dist/checkpoint.js +23 -0
- package/dist/checkpoint.js.map +1 -0
- package/dist/compaction.d.ts +21 -0
- package/dist/compaction.d.ts.map +1 -0
- package/dist/compaction.js +50 -0
- package/dist/compaction.js.map +1 -0
- package/dist/cost.d.ts +34 -0
- package/dist/cost.d.ts.map +1 -0
- package/dist/cost.js +42 -0
- package/dist/cost.js.map +1 -0
- package/dist/extension/host.d.ts +199 -0
- package/dist/extension/host.d.ts.map +1 -0
- package/dist/extension/host.js +502 -0
- package/dist/extension/host.js.map +1 -0
- package/dist/extension/index.d.ts +36 -0
- package/dist/extension/index.d.ts.map +1 -0
- package/dist/extension/index.js +37 -0
- package/dist/extension/index.js.map +1 -0
- package/dist/extension/manifest.d.ts +111 -0
- package/dist/extension/manifest.d.ts.map +1 -0
- package/dist/extension/manifest.js +190 -0
- package/dist/extension/manifest.js.map +1 -0
- package/dist/extension/process.d.ts +118 -0
- package/dist/extension/process.d.ts.map +1 -0
- package/dist/extension/process.js +352 -0
- package/dist/extension/process.js.map +1 -0
- package/dist/extension/protocol.d.ts +254 -0
- package/dist/extension/protocol.d.ts.map +1 -0
- package/dist/extension/protocol.js +127 -0
- package/dist/extension/protocol.js.map +1 -0
- package/dist/extension/tool_proxy.d.ts +34 -0
- package/dist/extension/tool_proxy.d.ts.map +1 -0
- package/dist/extension/tool_proxy.js +48 -0
- package/dist/extension/tool_proxy.js.map +1 -0
- package/dist/humanGate.d.ts +44 -0
- package/dist/humanGate.d.ts.map +1 -0
- package/dist/humanGate.js +30 -0
- package/dist/humanGate.js.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/knowledge.d.ts +30 -0
- package/dist/knowledge.d.ts.map +1 -0
- package/dist/knowledge.js +43 -0
- package/dist/knowledge.js.map +1 -0
- package/dist/llmProvider.d.ts +106 -0
- package/dist/llmProvider.d.ts.map +1 -0
- package/dist/llmProvider.js +160 -0
- package/dist/llmProvider.js.map +1 -0
- package/dist/memory.d.ts +23 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +40 -0
- package/dist/memory.js.map +1 -0
- package/dist/rerank.d.ts +27 -0
- package/dist/rerank.d.ts.map +1 -0
- package/dist/rerank.js +45 -0
- package/dist/rerank.js.map +1 -0
- package/dist/thread.d.ts +43 -0
- package/dist/thread.d.ts.map +1 -0
- package/dist/thread.js +60 -0
- package/dist/thread.js.map +1 -0
- package/dist/toolSearch.d.ts +55 -0
- package/dist/toolSearch.d.ts.map +1 -0
- package/dist/toolSearch.js +110 -0
- package/dist/toolSearch.js.map +1 -0
- package/dist/vector.d.ts +36 -0
- package/dist/vector.d.ts.map +1 -0
- package/dist/vector.js +75 -0
- package/dist/vector.js.map +1 -0
- package/dist/workflow.d.ts +62 -0
- package/dist/workflow.d.ts.map +1 -0
- package/dist/workflow.js +109 -0
- package/dist/workflow.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ExtensionProcess` — one extension subprocess, its ndjson codec, and its
|
|
3
|
+
* request/response plumbing. The TS sibling of the Rust host's
|
|
4
|
+
* `extension/process.rs`.
|
|
5
|
+
*
|
|
6
|
+
* Framing is identical to MCP stdio: one JSON-RPC message per line on the child's
|
|
7
|
+
* stdin/stdout, stderr drained to host logging. Inbound responses route to their
|
|
8
|
+
* pending caller; inbound requests go to an {@link InboundHandler}.
|
|
9
|
+
*
|
|
10
|
+
* Restart is in-place ({@link ExtensionProcess.respawn}): a generation counter is
|
|
11
|
+
* bumped so a stale reader from the dead child can't resolve a request registered
|
|
12
|
+
* against the new child, and every in-flight request fails fast.
|
|
13
|
+
*/
|
|
14
|
+
import { spawn } from 'node:child_process';
|
|
15
|
+
import { createInterface } from 'node:readline';
|
|
16
|
+
import { codes, isNotification, isRequest, isResponse, notification, request, RpcError, success, errorResponse } from './protocol.js';
|
|
17
|
+
/**
|
|
18
|
+
* Backoff schedule (ms) for restart attempts. After the third failed attempt the
|
|
19
|
+
* host marks the extension failed and stops trying.
|
|
20
|
+
*/
|
|
21
|
+
export const RESTART_BACKOFFS_MS = [1000, 5000, 25000];
|
|
22
|
+
/** Idle interval (ms) after which the host should health-probe with `ping`. */
|
|
23
|
+
export const PING_IDLE_MS = 60_000;
|
|
24
|
+
/**
|
|
25
|
+
* Bounded depth of the per-connection observe (`event`) lane. When a slow or
|
|
26
|
+
* stalled extension lets events pile past this, the OLDEST are shed and an
|
|
27
|
+
* `events_lost` marker is delivered on recovery — observe events are lossy by
|
|
28
|
+
* contract. Requests (hook/tool/ping/shutdown) are NEVER shed; they ride the
|
|
29
|
+
* reliable control lane (a direct stdin write).
|
|
30
|
+
*/
|
|
31
|
+
export const OBSERVE_QUEUE_CAP = 1024;
|
|
32
|
+
/**
|
|
33
|
+
* Backoff (ms) for restart `attempt` (0-indexed). `undefined` once attempts are
|
|
34
|
+
* exhausted — the caller transitions the extension to failed.
|
|
35
|
+
*/
|
|
36
|
+
export function backoffFor(attempt) {
|
|
37
|
+
return RESTART_BACKOFFS_MS[attempt];
|
|
38
|
+
}
|
|
39
|
+
/** The trivial handler: ping only. Used when the host wires nothing richer. */
|
|
40
|
+
export class DefaultInboundHandler {
|
|
41
|
+
async handleRequest(method, _params) {
|
|
42
|
+
if (method === 'ping')
|
|
43
|
+
return {};
|
|
44
|
+
throw new RpcError(codes.MethodNotFound, `method not found: ${method}`);
|
|
45
|
+
}
|
|
46
|
+
handleNotification(_method, _params) { }
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The per-connection observe lane: a bounded, oldest-shedding queue of `event`
|
|
50
|
+
* frames plus a monotonic sequence and a shed counter. Fire-and-forget events go
|
|
51
|
+
* here so a stuck child stdin can't grow host memory without bound.
|
|
52
|
+
*/
|
|
53
|
+
class ObserveLane {
|
|
54
|
+
queue = [];
|
|
55
|
+
seq = 0;
|
|
56
|
+
lost = 0;
|
|
57
|
+
lastContext = null;
|
|
58
|
+
/** Enqueue an `event` frame, shedding the oldest if at capacity. */
|
|
59
|
+
push(event, context, payload) {
|
|
60
|
+
const seq = this.seq++;
|
|
61
|
+
const frame = notification('event', { event, seq, context, payload });
|
|
62
|
+
if (this.queue.length >= OBSERVE_QUEUE_CAP) {
|
|
63
|
+
this.queue.shift();
|
|
64
|
+
this.lost++;
|
|
65
|
+
}
|
|
66
|
+
this.queue.push(frame);
|
|
67
|
+
this.lastContext = context;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Next frame for the writer to flush, or `undefined` when drained. Emits an
|
|
71
|
+
* `events_lost` marker (no `seq`) before the surviving events whenever
|
|
72
|
+
* shedding happened since the last drain — a gap in the seq run signals the
|
|
73
|
+
* loss; the marker carries the exact count.
|
|
74
|
+
*/
|
|
75
|
+
popForWrite() {
|
|
76
|
+
if (this.lost > 0) {
|
|
77
|
+
const lost = this.lost;
|
|
78
|
+
this.lost = 0;
|
|
79
|
+
return notification('event', { event: 'events_lost', context: this.lastContext, payload: { lost } });
|
|
80
|
+
}
|
|
81
|
+
return this.queue.shift();
|
|
82
|
+
}
|
|
83
|
+
get length() {
|
|
84
|
+
return this.queue.length;
|
|
85
|
+
}
|
|
86
|
+
get lostCount() {
|
|
87
|
+
return this.lost;
|
|
88
|
+
}
|
|
89
|
+
get seqValue() {
|
|
90
|
+
return this.seq;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/** One extension subprocess. */
|
|
94
|
+
export class ExtensionProcess {
|
|
95
|
+
spec;
|
|
96
|
+
handler;
|
|
97
|
+
pending = new Map();
|
|
98
|
+
generation = 0;
|
|
99
|
+
nextId = 1;
|
|
100
|
+
alive = true;
|
|
101
|
+
conn;
|
|
102
|
+
constructor(spec, handler) {
|
|
103
|
+
this.spec = spec;
|
|
104
|
+
this.handler = handler;
|
|
105
|
+
this.conn = this.startConnection(0);
|
|
106
|
+
}
|
|
107
|
+
/** Spawn the subprocess and start its reader. Throws if it can't be spawned. */
|
|
108
|
+
static spawn(spec, handler) {
|
|
109
|
+
return new ExtensionProcess(spec, handler);
|
|
110
|
+
}
|
|
111
|
+
startConnection(myGeneration) {
|
|
112
|
+
const child = spawn(this.spec.command, this.spec.args, {
|
|
113
|
+
cwd: this.spec.cwd,
|
|
114
|
+
env: { ...process.env, ...this.spec.env },
|
|
115
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
116
|
+
});
|
|
117
|
+
child.on('error', (err) => {
|
|
118
|
+
if (this.generation === myGeneration) {
|
|
119
|
+
this.alive = false;
|
|
120
|
+
this.failAllPending(`extension spawn error: ${err.message}`);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
const rl = createInterface({ input: child.stdout, terminal: false });
|
|
124
|
+
rl.on('line', (line) => {
|
|
125
|
+
if (!line.trim())
|
|
126
|
+
return;
|
|
127
|
+
this.dispatchLine(line, myGeneration);
|
|
128
|
+
});
|
|
129
|
+
const errRl = createInterface({ input: child.stderr, terminal: false });
|
|
130
|
+
errRl.on('line', (line) => {
|
|
131
|
+
console.error(`[ext ${this.spec.command}] ${line}`);
|
|
132
|
+
});
|
|
133
|
+
const onClose = () => {
|
|
134
|
+
// Only the current generation's reader may declare death and fail
|
|
135
|
+
// pending — a stale reader must not disturb a fresh child.
|
|
136
|
+
if (this.generation === myGeneration) {
|
|
137
|
+
this.alive = false;
|
|
138
|
+
this.failAllPending('extension connection closed');
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
child.stdout.on('close', onClose);
|
|
142
|
+
child.on('exit', onClose);
|
|
143
|
+
return { child, rl, observe: new ObserveLane(), pumping: false };
|
|
144
|
+
}
|
|
145
|
+
/** Parse and route one inbound line. */
|
|
146
|
+
dispatchLine(line, myGeneration) {
|
|
147
|
+
let msg;
|
|
148
|
+
try {
|
|
149
|
+
msg = JSON.parse(line);
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
console.error(`[ext ${this.spec.command}] unparseable frame: ${line}`);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (isResponse(msg)) {
|
|
156
|
+
// Generation guard: drop responses that belong to a prior child.
|
|
157
|
+
if (this.generation !== myGeneration)
|
|
158
|
+
return;
|
|
159
|
+
const id = typeof msg.id === 'number' ? msg.id : undefined;
|
|
160
|
+
if (id === undefined)
|
|
161
|
+
return;
|
|
162
|
+
const pending = this.pending.get(id);
|
|
163
|
+
if (!pending)
|
|
164
|
+
return;
|
|
165
|
+
this.pending.delete(id);
|
|
166
|
+
clearTimeout(pending.timer);
|
|
167
|
+
if (msg.error)
|
|
168
|
+
pending.reject(new RpcError(msg.error.code, msg.error.message, msg.error.data));
|
|
169
|
+
else
|
|
170
|
+
pending.resolve(msg.result ?? null);
|
|
171
|
+
}
|
|
172
|
+
else if (isRequest(msg)) {
|
|
173
|
+
void this.handleInboundRequest(msg.id ?? null, msg.method ?? '', msg.params);
|
|
174
|
+
}
|
|
175
|
+
else if (isNotification(msg)) {
|
|
176
|
+
this.handler.handleNotification(msg.method ?? '', msg.params);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
async handleInboundRequest(id, method, params) {
|
|
180
|
+
let reply;
|
|
181
|
+
try {
|
|
182
|
+
reply = success(id, (await this.handler.handleRequest(method, params)) ?? {});
|
|
183
|
+
}
|
|
184
|
+
catch (err) {
|
|
185
|
+
const obj = err instanceof RpcError ? err.toObject() : { code: codes.InternalError, message: err instanceof Error ? err.message : String(err) };
|
|
186
|
+
reply = errorResponse(id, obj);
|
|
187
|
+
}
|
|
188
|
+
this.writeFrame(reply);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Send a request and await its response, bounded by `timeoutMs`. Rejects if
|
|
192
|
+
* the connection is dead, the request times out (it also sends `$/cancel`), or
|
|
193
|
+
* the extension replies with a JSON-RPC error.
|
|
194
|
+
*/
|
|
195
|
+
request(method, params, timeoutMs) {
|
|
196
|
+
if (!this.alive)
|
|
197
|
+
return Promise.reject(new Error('extension is not alive'));
|
|
198
|
+
const id = this.nextId++;
|
|
199
|
+
return new Promise((resolve, reject) => {
|
|
200
|
+
const timer = setTimeout(() => {
|
|
201
|
+
// Timed out: clear the slot, tell the peer to stop (best-effort
|
|
202
|
+
// `$/cancel`), and fail the caller — mirrors the Rust CancelGuard.
|
|
203
|
+
if (this.pending.delete(id)) {
|
|
204
|
+
this.cancel(id);
|
|
205
|
+
reject(new Error(`extension request \`${method}\` timed out after ${timeoutMs}ms`));
|
|
206
|
+
}
|
|
207
|
+
}, timeoutMs);
|
|
208
|
+
this.pending.set(id, { resolve, reject, timer });
|
|
209
|
+
if (!this.writeFrame(request(id, method, params))) {
|
|
210
|
+
if (this.pending.delete(id)) {
|
|
211
|
+
clearTimeout(timer);
|
|
212
|
+
reject(new Error('extension writer is gone'));
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Best-effort `$/cancel` for an in-flight request `id`. The peer SHOULD stop
|
|
219
|
+
* work; a cancel for an already-answered id is a harmless no-op.
|
|
220
|
+
*/
|
|
221
|
+
cancel(id) {
|
|
222
|
+
this.notify('$/cancel', { id });
|
|
223
|
+
}
|
|
224
|
+
/** Send a fire-and-forget notification on the reliable control lane. */
|
|
225
|
+
notify(method, params) {
|
|
226
|
+
this.writeFrame(notification(method, params));
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Enqueue an observe `event` on the bounded, lossy lane. Assigns the frame a
|
|
230
|
+
* per-connection sequence; sheds the oldest queued event (tracked for the next
|
|
231
|
+
* `events_lost` marker) rather than block or grow unbounded when the extension
|
|
232
|
+
* is not draining its stdin. Never throws — a shed event is the contract.
|
|
233
|
+
*/
|
|
234
|
+
sendEvent(event, context, payload) {
|
|
235
|
+
this.conn.observe.push(event, context, payload);
|
|
236
|
+
this.pumpObserve();
|
|
237
|
+
}
|
|
238
|
+
/** Whether the connection is currently believed alive. */
|
|
239
|
+
isAlive() {
|
|
240
|
+
return this.alive;
|
|
241
|
+
}
|
|
242
|
+
/** Current generation (increments on every successful respawn). */
|
|
243
|
+
getGeneration() {
|
|
244
|
+
return this.generation;
|
|
245
|
+
}
|
|
246
|
+
/** Health-probe with `ping`; resolves `true` if answered within `timeoutMs`. */
|
|
247
|
+
async pingHealth(timeoutMs) {
|
|
248
|
+
try {
|
|
249
|
+
await this.request('ping', {}, timeoutMs);
|
|
250
|
+
return true;
|
|
251
|
+
}
|
|
252
|
+
catch {
|
|
253
|
+
return false;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Kill and re-spawn the child in place. Bumps the generation (invalidating any
|
|
258
|
+
* stale reader and failing every in-flight request), then starts a fresh
|
|
259
|
+
* connection. `nextId` is NOT reset, so ids never collide across generations.
|
|
260
|
+
*/
|
|
261
|
+
respawn() {
|
|
262
|
+
this.generation++;
|
|
263
|
+
const myGeneration = this.generation;
|
|
264
|
+
this.failAllPending('extension restarting');
|
|
265
|
+
this.abortConnection();
|
|
266
|
+
this.conn = this.startConnection(myGeneration);
|
|
267
|
+
this.alive = true;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Graceful shutdown: send `shutdown`, wait up to `graceMs` for the reply, then
|
|
271
|
+
* force-kill. Always leaves the process dead.
|
|
272
|
+
*/
|
|
273
|
+
async shutdown(graceMs) {
|
|
274
|
+
try {
|
|
275
|
+
await this.request('shutdown', {}, graceMs);
|
|
276
|
+
}
|
|
277
|
+
catch {
|
|
278
|
+
// Ignore — we kill regardless below.
|
|
279
|
+
}
|
|
280
|
+
this.alive = false;
|
|
281
|
+
this.abortConnection();
|
|
282
|
+
}
|
|
283
|
+
/** Serialize a frame as ndjson to the child stdin. Returns false on any error. */
|
|
284
|
+
writeFrame(msg) {
|
|
285
|
+
let line;
|
|
286
|
+
try {
|
|
287
|
+
line = `${JSON.stringify(msg)}\n`;
|
|
288
|
+
}
|
|
289
|
+
catch (e) {
|
|
290
|
+
console.error(`[ext ${this.spec.command}] failed to serialize frame: ${String(e)}`);
|
|
291
|
+
return true; // a bad frame is not a broken pipe — keep the connection.
|
|
292
|
+
}
|
|
293
|
+
const stdin = this.conn.child.stdin;
|
|
294
|
+
if (!stdin.writable)
|
|
295
|
+
return false;
|
|
296
|
+
stdin.write(line);
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
299
|
+
/** Drain the observe lane to stdin, honoring backpressure via `drain`. */
|
|
300
|
+
pumpObserve() {
|
|
301
|
+
const conn = this.conn;
|
|
302
|
+
if (conn.pumping)
|
|
303
|
+
return;
|
|
304
|
+
conn.pumping = true;
|
|
305
|
+
const stdin = conn.child.stdin;
|
|
306
|
+
const drain = () => {
|
|
307
|
+
for (;;) {
|
|
308
|
+
const frame = conn.observe.popForWrite();
|
|
309
|
+
if (!frame) {
|
|
310
|
+
conn.pumping = false;
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
if (!stdin.writable) {
|
|
314
|
+
conn.pumping = false;
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
const ok = stdin.write(`${JSON.stringify(frame)}\n`);
|
|
318
|
+
if (!ok) {
|
|
319
|
+
// Backpressure: wait for the child to drain, then continue. The
|
|
320
|
+
// observe queue keeps shedding oldest meanwhile (bounded memory).
|
|
321
|
+
stdin.once('drain', drain);
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
drain();
|
|
327
|
+
}
|
|
328
|
+
/** Fail every pending request with the same error message. */
|
|
329
|
+
failAllPending(reason) {
|
|
330
|
+
const drained = [...this.pending.values()];
|
|
331
|
+
this.pending.clear();
|
|
332
|
+
for (const p of drained) {
|
|
333
|
+
clearTimeout(p.timer);
|
|
334
|
+
p.reject(new RpcError(codes.InternalError, reason));
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
/** Tear down the current connection's child + readers. */
|
|
338
|
+
abortConnection() {
|
|
339
|
+
const { child, rl } = this.conn;
|
|
340
|
+
rl.close();
|
|
341
|
+
child.stdout.removeAllListeners();
|
|
342
|
+
child.stderr.removeAllListeners();
|
|
343
|
+
child.removeAllListeners('exit');
|
|
344
|
+
try {
|
|
345
|
+
child.kill('SIGKILL');
|
|
346
|
+
}
|
|
347
|
+
catch {
|
|
348
|
+
// already gone
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
//# sourceMappingURL=process.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process.js","sourceRoot":"","sources":["../../src/extension/process.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAuC,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,eAAe,EAAuC,MAAM,eAAe,CAAC;AACrF,OAAO,EAAE,KAAK,EAAW,cAAc,EAAE,SAAS,EAAE,UAAU,EAAgB,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAuB,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAElL;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAsB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AAE1E,+EAA+E;AAC/E,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC;AAEnC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAEtC;;;GAGG;AACH,MAA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Smooth Extension Protocol) is JSON-RPC 2.0 over ndjson on an extension
|
|
5
|
+
* subprocess's stdio. The canonical schemas live in the `smooth-operator` repo at
|
|
6
|
+
* `spec/extension/`; the types here are the TS engine host's view of that wire —
|
|
7
|
+
* the sibling of the Rust host's `extension/protocol.rs`. Field names are
|
|
8
|
+
* `snake_case` because they ARE the wire.
|
|
9
|
+
*
|
|
10
|
+
* The author-side `@smooai/smooth-extension-sdk` ships its own copy of these
|
|
11
|
+
* shapes; the host keeps them local rather than importing the SDK, which would
|
|
12
|
+
* invert the dependency (the engine is the lower layer the SDK's host consumers
|
|
13
|
+
* build on).
|
|
14
|
+
*/
|
|
15
|
+
/** The SEP protocol version this host implements. Effective = min(host, ext). */
|
|
16
|
+
export declare const PROTOCOL_VERSION = 1;
|
|
17
|
+
/** SEP method names, centralized so the host and tests never spell one wrong. */
|
|
18
|
+
export declare const method: {
|
|
19
|
+
readonly INITIALIZE: "initialize";
|
|
20
|
+
readonly SHUTDOWN: "shutdown";
|
|
21
|
+
readonly PING: "ping";
|
|
22
|
+
readonly EVENT: "event";
|
|
23
|
+
readonly HOOK: "hook";
|
|
24
|
+
readonly TOOL_EXECUTE: "tool/execute";
|
|
25
|
+
readonly TOOL_UPDATE: "tool/update";
|
|
26
|
+
readonly COMMAND_EXECUTE: "command/execute";
|
|
27
|
+
readonly COMMAND_COMPLETE: "command/complete";
|
|
28
|
+
readonly CANCEL: "$/cancel";
|
|
29
|
+
readonly REGISTRY_UPDATE: "registry/update";
|
|
30
|
+
readonly TOOLS_SET_ACTIVE: "tools/set_active";
|
|
31
|
+
readonly EXEC_RUN: "exec/run";
|
|
32
|
+
readonly UI_REQUEST: "ui/request";
|
|
33
|
+
readonly LOG: "log";
|
|
34
|
+
readonly BUS_PUBLISH: "bus/publish";
|
|
35
|
+
readonly SESSION_SEND_MESSAGE: "session/send_message";
|
|
36
|
+
readonly SESSION_SEND_USER_MESSAGE: "session/send_user_message";
|
|
37
|
+
readonly SESSION_APPEND_ENTRY: "session/append_entry";
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* JSON-RPC + SEP error codes (see `spec/extension/envelope.md`). Standard range
|
|
41
|
+
* plus the SEP extensions.
|
|
42
|
+
*/
|
|
43
|
+
export declare const codes: {
|
|
44
|
+
readonly ParseError: -32700;
|
|
45
|
+
readonly InvalidRequest: -32600;
|
|
46
|
+
readonly MethodNotFound: -32601;
|
|
47
|
+
readonly InvalidParams: -32602;
|
|
48
|
+
readonly InternalError: -32603;
|
|
49
|
+
/** A hook or policy vetoed the operation. */
|
|
50
|
+
readonly Blocked: -32000;
|
|
51
|
+
/** `ui/request` in a headless/uncapable frontend. */
|
|
52
|
+
readonly NoUI: -32001;
|
|
53
|
+
/** Extension acted beyond its granted trust. */
|
|
54
|
+
readonly NotTrusted: -32002;
|
|
55
|
+
/** Command-tier action attempted from an event-tier context. */
|
|
56
|
+
readonly ContextViolation: -32003;
|
|
57
|
+
/** Method requires a capability the handshake did not enable. */
|
|
58
|
+
readonly CapabilityDisabled: -32004;
|
|
59
|
+
/** Request cancelled via `$/cancel`. */
|
|
60
|
+
readonly Cancelled: -32800;
|
|
61
|
+
};
|
|
62
|
+
/** A JSON-RPC error object. */
|
|
63
|
+
export interface RpcErrorObject {
|
|
64
|
+
code: number;
|
|
65
|
+
message: string;
|
|
66
|
+
data?: unknown;
|
|
67
|
+
}
|
|
68
|
+
/** An error carrying a JSON-RPC error code, thrown/returned for a remote error. */
|
|
69
|
+
export declare class RpcError extends Error {
|
|
70
|
+
readonly code: number;
|
|
71
|
+
readonly data?: unknown | undefined;
|
|
72
|
+
constructor(code: number, message: string, data?: unknown | undefined);
|
|
73
|
+
toObject(): RpcErrorObject;
|
|
74
|
+
}
|
|
75
|
+
/** A JSON-RPC id: an integer or a string (null only on a parse-error response). */
|
|
76
|
+
export type Id = number | string | null;
|
|
77
|
+
/**
|
|
78
|
+
* The JSON-RPC 2.0 envelope. All four frame shapes share this type; which fields
|
|
79
|
+
* are present determines the shape:
|
|
80
|
+
* - request: `id` + `method` (+ optional `params`)
|
|
81
|
+
* - notification: `method`, no `id`
|
|
82
|
+
* - success response: `id` + `result`
|
|
83
|
+
* - error response: `id` + `error`
|
|
84
|
+
*/
|
|
85
|
+
export interface Message {
|
|
86
|
+
jsonrpc: '2.0';
|
|
87
|
+
id?: Id;
|
|
88
|
+
method?: string;
|
|
89
|
+
params?: unknown;
|
|
90
|
+
result?: unknown;
|
|
91
|
+
error?: RpcErrorObject;
|
|
92
|
+
}
|
|
93
|
+
/** Build a request frame. */
|
|
94
|
+
export declare function request(id: Exclude<Id, null>, methodName: string, params: unknown): Message;
|
|
95
|
+
/** Build a notification frame (no id, no reply expected). */
|
|
96
|
+
export declare function notification(methodName: string, params: unknown): Message;
|
|
97
|
+
/** Build a success response frame echoing `id`. */
|
|
98
|
+
export declare function success(id: Id, result: unknown): Message;
|
|
99
|
+
/** Build an error response frame echoing `id`. */
|
|
100
|
+
export declare function errorResponse(id: Id, error: RpcErrorObject): Message;
|
|
101
|
+
/** True when this frame is a request (has both `id` and `method`). */
|
|
102
|
+
export declare function isRequest(m: Message): boolean;
|
|
103
|
+
/** True when this frame is a notification (has `method`, no `id`). */
|
|
104
|
+
export declare function isNotification(m: Message): boolean;
|
|
105
|
+
/** True when this frame is a response (has `id`, no `method`). */
|
|
106
|
+
export declare function isResponse(m: Message): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Whether a dispatch may only observe (`event`) or may mutate the session
|
|
109
|
+
* (`command`). Session-mutating ext→host actions require `command`.
|
|
110
|
+
*/
|
|
111
|
+
export type Tier = 'event' | 'command';
|
|
112
|
+
/** The dispatch context carried by every host→ext event/hook/tool/command. */
|
|
113
|
+
export interface Context {
|
|
114
|
+
token: string;
|
|
115
|
+
tier: Tier;
|
|
116
|
+
}
|
|
117
|
+
export interface HostInfo {
|
|
118
|
+
name: string;
|
|
119
|
+
version: string;
|
|
120
|
+
}
|
|
121
|
+
export interface WorkspaceInfo {
|
|
122
|
+
root: string;
|
|
123
|
+
trusted: boolean;
|
|
124
|
+
}
|
|
125
|
+
export interface InitializeParams {
|
|
126
|
+
protocol_version: number;
|
|
127
|
+
host: HostInfo;
|
|
128
|
+
workspace: WorkspaceInfo;
|
|
129
|
+
session?: {
|
|
130
|
+
id?: string;
|
|
131
|
+
};
|
|
132
|
+
mode: string;
|
|
133
|
+
ui_capabilities?: string[];
|
|
134
|
+
/** Parsed values for the flags the extension declares (name → value). */
|
|
135
|
+
flags?: Record<string, unknown>;
|
|
136
|
+
capabilities_enabled?: Record<string, unknown>;
|
|
137
|
+
}
|
|
138
|
+
export interface ToolRegistration {
|
|
139
|
+
name: string;
|
|
140
|
+
description: string;
|
|
141
|
+
/** JSON Schema for the tool's arguments. */
|
|
142
|
+
parameters: Record<string, unknown>;
|
|
143
|
+
deferred?: boolean;
|
|
144
|
+
}
|
|
145
|
+
export interface CommandRegistration {
|
|
146
|
+
name: string;
|
|
147
|
+
description: string;
|
|
148
|
+
}
|
|
149
|
+
/** A keyboard shortcut an extension binds to one of its commands. */
|
|
150
|
+
export interface ShortcutRegistration {
|
|
151
|
+
/** A human-typed chord, e.g. `ctrl+p`; the frontend parses it. */
|
|
152
|
+
key: string;
|
|
153
|
+
/** The registered command this chord invokes (no leading `/`). */
|
|
154
|
+
command: string;
|
|
155
|
+
description?: string;
|
|
156
|
+
}
|
|
157
|
+
export interface Registrations {
|
|
158
|
+
tools?: ToolRegistration[];
|
|
159
|
+
commands?: CommandRegistration[];
|
|
160
|
+
flags?: string[];
|
|
161
|
+
shortcuts?: ShortcutRegistration[];
|
|
162
|
+
subscriptions?: string[];
|
|
163
|
+
}
|
|
164
|
+
export interface InitializeResult {
|
|
165
|
+
protocol_version: number;
|
|
166
|
+
extension: {
|
|
167
|
+
name: string;
|
|
168
|
+
version: string;
|
|
169
|
+
};
|
|
170
|
+
registrations?: Registrations;
|
|
171
|
+
}
|
|
172
|
+
export interface HookParams {
|
|
173
|
+
hook: string;
|
|
174
|
+
context: Context;
|
|
175
|
+
input: unknown;
|
|
176
|
+
}
|
|
177
|
+
/** The extension's reply to a `hook`, tagged by `action`. */
|
|
178
|
+
export type HookOutcome = {
|
|
179
|
+
action: 'continue';
|
|
180
|
+
} | {
|
|
181
|
+
action: 'block';
|
|
182
|
+
reason?: string;
|
|
183
|
+
} | {
|
|
184
|
+
action: 'modify';
|
|
185
|
+
patch: unknown;
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Parse an untyped `hook` reply into a {@link HookOutcome}, or throw when it is
|
|
189
|
+
* malformed. Mirrors the Rust host's serde-tagged decode: a `modify` without a
|
|
190
|
+
* `patch`, or an unknown `action`, is rejected (the host then treats it as a
|
|
191
|
+
* failed hook step).
|
|
192
|
+
*/
|
|
193
|
+
export declare function parseHookOutcome(value: unknown): HookOutcome;
|
|
194
|
+
export interface ToolExecuteParams {
|
|
195
|
+
call_id: string;
|
|
196
|
+
tool: string;
|
|
197
|
+
arguments: unknown;
|
|
198
|
+
context: Context;
|
|
199
|
+
}
|
|
200
|
+
export interface ToolExecuteResult {
|
|
201
|
+
content: string;
|
|
202
|
+
is_error?: boolean;
|
|
203
|
+
details?: unknown;
|
|
204
|
+
}
|
|
205
|
+
export interface ToolUpdateParams {
|
|
206
|
+
call_id: string;
|
|
207
|
+
message?: string;
|
|
208
|
+
progress?: number;
|
|
209
|
+
details?: unknown;
|
|
210
|
+
}
|
|
211
|
+
export interface EventParams {
|
|
212
|
+
event: string;
|
|
213
|
+
/** Per-connection monotonic sequence; absent on the `events_lost` marker. */
|
|
214
|
+
seq?: number;
|
|
215
|
+
context: Context;
|
|
216
|
+
payload?: unknown;
|
|
217
|
+
}
|
|
218
|
+
export interface CommandExecuteParams {
|
|
219
|
+
command: string;
|
|
220
|
+
context: Context;
|
|
221
|
+
arguments?: unknown;
|
|
222
|
+
}
|
|
223
|
+
export interface CommandExecuteResult {
|
|
224
|
+
content?: string;
|
|
225
|
+
}
|
|
226
|
+
export interface CommandCompleteParams {
|
|
227
|
+
command: string;
|
|
228
|
+
context: Context;
|
|
229
|
+
partial?: string;
|
|
230
|
+
}
|
|
231
|
+
export interface Completion {
|
|
232
|
+
value: string;
|
|
233
|
+
description?: string;
|
|
234
|
+
}
|
|
235
|
+
export interface CommandCompleteResult {
|
|
236
|
+
completions: Completion[];
|
|
237
|
+
}
|
|
238
|
+
/** How a `session/send_user_message` is delivered relative to the current turn. */
|
|
239
|
+
export type DeliverAs = 'steer' | 'follow_up' | 'next_turn';
|
|
240
|
+
export interface SessionSendMessageParams {
|
|
241
|
+
context: Context;
|
|
242
|
+
text: string;
|
|
243
|
+
role?: 'user' | 'assistant';
|
|
244
|
+
}
|
|
245
|
+
export interface SessionSendUserMessageParams {
|
|
246
|
+
context: Context;
|
|
247
|
+
text: string;
|
|
248
|
+
deliver_as?: DeliverAs;
|
|
249
|
+
}
|
|
250
|
+
export interface SessionAppendEntryParams {
|
|
251
|
+
context: Context;
|
|
252
|
+
entry: unknown;
|
|
253
|
+
}
|
|
254
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/extension/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,iFAAiF;AACjF,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC,iFAAiF;AACjF,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;CAoBT,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,KAAK;;;;;;IAMd,6CAA6C;;IAE7C,qDAAqD;;IAErD,gDAAgD;;IAEhD,gEAAgE;;IAEhE,iEAAiE;;IAEjE,wCAAwC;;CAElC,CAAC;AAEX,+BAA+B;AAC/B,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,mFAAmF;AACnF,qBAAa,Q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