@silo-code/sdk 0.43.0 → 0.45.0
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/ActivityGlyph.d.ts +15 -2
- package/dist/ActivityGlyph.d.ts.map +1 -1
- package/dist/ActivityGlyph.js +11 -4
- package/dist/ActivityGlyph.js.map +1 -1
- package/dist/activity.d.ts +25 -2
- package/dist/activity.d.ts.map +1 -1
- package/dist/activity.js +29 -0
- package/dist/activity.js.map +1 -1
- package/dist/agents-service.d.ts +183 -0
- package/dist/agents-service.d.ts.map +1 -1
- package/dist/extension-storage.d.ts +56 -8
- package/dist/extension-storage.d.ts.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/process-service.d.ts +12 -2
- package/dist/process-service.d.ts.map +1 -1
- package/dist/terminal-service.d.ts +78 -2
- package/dist/terminal-service.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ActivityGlyph.tsx +23 -2
- package/src/activity.test.ts +34 -1
- package/src/activity.ts +37 -2
- package/src/agents-service.ts +190 -0
- package/src/extension-storage.ts +58 -8
- package/src/index.ts +8 -0
- package/src/process-service.ts +15 -2
- package/src/terminal-service.ts +82 -2
package/src/terminal-service.ts
CHANGED
|
@@ -26,6 +26,53 @@ export interface OscEvent {
|
|
|
26
26
|
payload: string;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Where a chunk of terminal output came from in time.
|
|
31
|
+
*
|
|
32
|
+
* A terminal session outlives the app, so re-attaching to one replays the
|
|
33
|
+
* session host's recent scrollback — bytes that are byte-for-byte identical to
|
|
34
|
+
* live output but describe things that already happened, sometimes long ago.
|
|
35
|
+
* Treating them as live is what makes a reattached agent terminal announce a
|
|
36
|
+
* turn that finished before the app started.
|
|
37
|
+
*
|
|
38
|
+
* @category Consumer Services
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
export interface OutputOrigin {
|
|
42
|
+
/**
|
|
43
|
+
* `true` when the chunk is scrollback the session host is replaying on
|
|
44
|
+
* attach, `false` when the session produced it just now.
|
|
45
|
+
*
|
|
46
|
+
* Only ever `true` for a subscription that opted in with
|
|
47
|
+
* {@link SubscribeOutputOptions.includeReplay}.
|
|
48
|
+
*/
|
|
49
|
+
replay: boolean;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Options for {@link TerminalService.subscribeOutput} and
|
|
54
|
+
* {@link TerminalService.subscribeOsc}.
|
|
55
|
+
*
|
|
56
|
+
* @category Consumer Services
|
|
57
|
+
* @public
|
|
58
|
+
*/
|
|
59
|
+
export interface SubscribeOutputOptions {
|
|
60
|
+
/**
|
|
61
|
+
* Deliver the scrollback the session host replays when re-attaching to a
|
|
62
|
+
* terminal, in addition to live output. Defaults to `false`.
|
|
63
|
+
*
|
|
64
|
+
* Leave it off for anything that reads output as *activity* — "the agent is
|
|
65
|
+
* working", "something just happened", a notification — because replayed
|
|
66
|
+
* bytes would fire all of it for events that are already over.
|
|
67
|
+
*
|
|
68
|
+
* Turn it on for anything that needs the terminal's *history*: rendering the
|
|
69
|
+
* scrollback, or identifying which program is running in a terminal you have
|
|
70
|
+
* only just attached to. Each chunk then arrives with an
|
|
71
|
+
* {@link OutputOrigin} saying which kind it is.
|
|
72
|
+
*/
|
|
73
|
+
includeReplay?: boolean;
|
|
74
|
+
}
|
|
75
|
+
|
|
29
76
|
// Re-export the terminal domain types so consumers can name them from the SDK.
|
|
30
77
|
export type { TerminalKind, TerminalRecord } from "./domain-types";
|
|
31
78
|
|
|
@@ -234,10 +281,19 @@ export interface TerminalService extends TabAdornmentMethods {
|
|
|
234
281
|
* });
|
|
235
282
|
* ctx.subscriptions.push(sub);
|
|
236
283
|
* ```
|
|
284
|
+
*
|
|
285
|
+
* @remarks
|
|
286
|
+
* OSC sequences ride the raw output stream, so the same replay rule applies
|
|
287
|
+
* as for {@link TerminalService.subscribeOutput}: by default only sequences
|
|
288
|
+
* from **live** output are delivered, and `{ includeReplay: true }` adds
|
|
289
|
+
* those found in the scrollback replayed on attach. Status titles are the
|
|
290
|
+
* usual reason to leave it off — a replayed "busy" title describes a turn
|
|
291
|
+
* that is already over.
|
|
237
292
|
*/
|
|
238
293
|
subscribeOsc(
|
|
239
294
|
terminalId: string,
|
|
240
|
-
handler: (event: OscEvent) => void,
|
|
295
|
+
handler: (event: OscEvent, origin: OutputOrigin) => void,
|
|
296
|
+
options?: SubscribeOutputOptions,
|
|
241
297
|
): Disposable;
|
|
242
298
|
|
|
243
299
|
/**
|
|
@@ -256,21 +312,45 @@ export interface TerminalService extends TabAdornmentMethods {
|
|
|
256
312
|
* not the underlying PTY session id, so it survives terminal recreation within
|
|
257
313
|
* the same record.
|
|
258
314
|
*
|
|
315
|
+
* By default only **live** output is delivered. A terminal session outlives
|
|
316
|
+
* the app, so attaching to one replays its recent scrollback; without this
|
|
317
|
+
* default every reattach would look like a burst of activity happening right
|
|
318
|
+
* now. Pass `{ includeReplay: true }` to receive that history too — each
|
|
319
|
+
* chunk then arrives with an {@link OutputOrigin} saying which kind it is.
|
|
320
|
+
*
|
|
259
321
|
* Returns a {@link Disposable} that cancels the subscription.
|
|
260
322
|
*
|
|
261
323
|
* @example
|
|
262
324
|
* ```ts
|
|
263
325
|
* // Track the last time any output arrived to confirm agent activity.
|
|
326
|
+
* // Replayed scrollback is excluded by default, so re-attaching to a
|
|
327
|
+
* // long-idle terminal doesn't read as fresh activity.
|
|
264
328
|
* let lastOutputAt = 0;
|
|
265
329
|
* const sub = ctx.terminals.subscribeOutput(terminalId, () => {
|
|
266
330
|
* lastOutputAt = Date.now();
|
|
267
331
|
* });
|
|
268
332
|
* ctx.subscriptions.push(sub);
|
|
269
333
|
* ```
|
|
334
|
+
*
|
|
335
|
+
* @example
|
|
336
|
+
* ```ts
|
|
337
|
+
* // Opt in to the replayed scrollback — needed to work out what is running
|
|
338
|
+
* // in a terminal you just attached to — and keep the two apart.
|
|
339
|
+
* const sub = ctx.terminals.subscribeOutput(
|
|
340
|
+
* terminalId,
|
|
341
|
+
* (chunk, { replay }) => {
|
|
342
|
+
* identifyProgram(chunk); // history is evidence
|
|
343
|
+
* if (!replay) noteActivity(); // …but only live output is activity
|
|
344
|
+
* },
|
|
345
|
+
* { includeReplay: true },
|
|
346
|
+
* );
|
|
347
|
+
* ctx.subscriptions.push(sub);
|
|
348
|
+
* ```
|
|
270
349
|
*/
|
|
271
350
|
subscribeOutput(
|
|
272
351
|
terminalId: string,
|
|
273
|
-
handler: (data: string) => void,
|
|
352
|
+
handler: (data: string, origin: OutputOrigin) => void,
|
|
353
|
+
options?: SubscribeOutputOptions,
|
|
274
354
|
): Disposable;
|
|
275
355
|
|
|
276
356
|
/**
|