@smithers-orchestrator/pi-plugin 0.16.9

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/src/index.d.ts ADDED
@@ -0,0 +1,443 @@
1
+ import { SmithersAgentContract } from '@smithers-orchestrator/agents/agent-contract';
2
+ import { ExtensionAPI as ExtensionAPI$1 } from '@mariozechner/pi-coding-agent';
3
+ import { DevToolsSnapshot, DevToolsDelta, DevToolsNode } from '@smithers-orchestrator/protocol';
4
+
5
+ type ApproveArgs = {
6
+ runId: string;
7
+ nodeId: string;
8
+ iteration?: number;
9
+ note?: string;
10
+ baseUrl?: string;
11
+ apiKey?: string;
12
+ };
13
+ declare function approve(args: ApproveArgs): Promise<any>;
14
+
15
+ type CancelArgs = {
16
+ runId: string;
17
+ baseUrl?: string;
18
+ apiKey?: string;
19
+ };
20
+ declare function cancel(args: CancelArgs): Promise<any>;
21
+
22
+ type DenyArgs = {
23
+ runId: string;
24
+ nodeId: string;
25
+ iteration?: number;
26
+ note?: string;
27
+ baseUrl?: string;
28
+ apiKey?: string;
29
+ };
30
+ declare function deny(args: DenyArgs): Promise<any>;
31
+
32
+ type GetFramesArgs = {
33
+ runId: string;
34
+ tail?: number;
35
+ baseUrl?: string;
36
+ apiKey?: string;
37
+ };
38
+ declare function getFrames(args: GetFramesArgs): Promise<any>;
39
+
40
+ type GetStatusArgs = {
41
+ runId: string;
42
+ baseUrl?: string;
43
+ apiKey?: string;
44
+ };
45
+ declare function getStatus(args: GetStatusArgs): Promise<any>;
46
+
47
+ type ListRunsArgs = {
48
+ limit?: number;
49
+ status?: string;
50
+ baseUrl?: string;
51
+ apiKey?: string;
52
+ };
53
+ declare function listRuns(args?: ListRunsArgs): Promise<any>;
54
+
55
+ type ResumeArgs = {
56
+ workflowPath: string;
57
+ runId: string;
58
+ baseUrl?: string;
59
+ apiKey?: string;
60
+ };
61
+ declare function resume(args: ResumeArgs): Promise<any>;
62
+
63
+ type RunWorkflowArgs = {
64
+ workflowPath: string;
65
+ input: unknown;
66
+ runId?: string;
67
+ baseUrl?: string;
68
+ apiKey?: string;
69
+ };
70
+ declare function runWorkflow(args: RunWorkflowArgs): Promise<any>;
71
+
72
+ type StreamEventsArgs = {
73
+ runId: string;
74
+ baseUrl?: string;
75
+ apiKey?: string;
76
+ };
77
+ declare function streamEvents(args: StreamEventsArgs): AsyncGenerator<any, void, unknown>;
78
+
79
+ type SmithersPiRunContext = {
80
+ runId: string;
81
+ workflowName: string;
82
+ status: string;
83
+ nodeStates: Array<{
84
+ nodeId: string;
85
+ state: string;
86
+ }>;
87
+ errors: string[];
88
+ };
89
+
90
+ declare function buildSmithersPiSystemPrompt(baseSystemPrompt: string, docs: string, contract: SmithersAgentContract, activeRun?: SmithersPiRunContext): string;
91
+
92
+ type ExtensionAPI = ExtensionAPI$1 & {
93
+ registerFlag: (name: string, config: Record<string, unknown>) => void;
94
+ getFlag: (name: string) => string | undefined;
95
+ on: (event: string, handler: (...args: any[]) => unknown) => void;
96
+ registerTool: (tool: Record<string, unknown>) => void;
97
+ registerCommand: (name: string, command: Record<string, unknown>) => void;
98
+ registerMessageRenderer: (name: string, renderer: (...args: any[]) => unknown) => void;
99
+ };
100
+ declare function extension(pi: ExtensionAPI): void;
101
+
102
+ type RequestOptions = {
103
+ baseUrl?: string;
104
+ apiKey?: string;
105
+ clientId?: string;
106
+ clientVersion?: string;
107
+ };
108
+ type DevToolsGapResync$1 = {
109
+ fromSeq: number;
110
+ toSeq: number;
111
+ };
112
+ type DevToolsRuntimeEvent$1 = {
113
+ version: 1;
114
+ kind: "snapshot";
115
+ snapshot: DevToolsSnapshot & {
116
+ runState?: RunStateView$1;
117
+ };
118
+ } | {
119
+ version: 1;
120
+ kind: "delta";
121
+ delta: DevToolsDelta;
122
+ } | {
123
+ version: 1;
124
+ kind: "gapResync";
125
+ gapResync: DevToolsGapResync$1;
126
+ };
127
+ type RunStateView$1 = {
128
+ runId?: string;
129
+ run_id?: string;
130
+ state?: string;
131
+ computedAt?: string;
132
+ computed_at?: string;
133
+ engineHeartbeatAtMs?: number;
134
+ engine_heartbeat_at_ms?: number;
135
+ engineHeartbeatMs?: number;
136
+ engine_heartbeat_ms?: number;
137
+ viewersHeartbeatAtMs?: number;
138
+ viewers_heartbeat_at_ms?: number;
139
+ uiHeartbeatAtMs?: number;
140
+ ui_heartbeat_at_ms?: number;
141
+ viewersHeartbeatMs?: number;
142
+ viewers_heartbeat_ms?: number;
143
+ uiHeartbeatMs?: number;
144
+ ui_heartbeat_ms?: number;
145
+ engineHeartbeatAt?: string;
146
+ engine_heartbeat_at?: string;
147
+ viewersHeartbeatAt?: string;
148
+ viewers_heartbeat_at?: string;
149
+ uiHeartbeatAt?: string;
150
+ ui_heartbeat_at?: string;
151
+ blocked?: unknown;
152
+ unhealthy?: unknown;
153
+ };
154
+ declare class DevToolsClient {
155
+ readonly baseUrl: string;
156
+ readonly apiKey: string | undefined;
157
+ private readonly clientId;
158
+ private readonly clientVersion;
159
+ private readonly lastSeqSeenByRunId;
160
+ constructor(opts?: RequestOptions);
161
+ lastSeqSeen(runId: string): number | undefined;
162
+ streamDevTools(runId: string, afterSeq?: number, signal?: AbortSignal): AsyncGenerator<DevToolsRuntimeEvent$1>;
163
+ getDevToolsSnapshot(runId: string, frameNo?: number): Promise<DevToolsSnapshot & {
164
+ runState?: RunStateView$1;
165
+ }>;
166
+ getNodeOutput(runId: string, nodeId: string, iteration?: number): Promise<unknown>;
167
+ getNodeDiff(runId: string, nodeId: string, iteration?: number): Promise<unknown>;
168
+ approve(runId: string, nodeId: string, iteration?: number, note?: string): Promise<{
169
+ auditRowId: string | undefined;
170
+ }>;
171
+ deny(runId: string, nodeId: string, iteration?: number, note?: string): Promise<{
172
+ auditRowId: string | undefined;
173
+ }>;
174
+ signal(runId: string, signal: string, payload?: unknown, correlationId?: string): Promise<{
175
+ auditRowId: string | undefined;
176
+ }>;
177
+ cancel(runId: string): Promise<{
178
+ auditRowId: string | undefined;
179
+ }>;
180
+ resume(runId: string): Promise<{
181
+ auditRowId: string | undefined;
182
+ }>;
183
+ rewind(runId: string, frameNo: number, confirm?: boolean): Promise<{
184
+ auditRowId: string | undefined;
185
+ }>;
186
+ private performMutation;
187
+ private rpc;
188
+ private assertOk;
189
+ }
190
+
191
+ type DevToolsGapResync = {
192
+ fromSeq: number;
193
+ toSeq: number;
194
+ };
195
+ type RunStateView = Record<string, unknown>;
196
+ type SnapshotWithRunState = DevToolsSnapshot & {
197
+ runState?: RunStateView;
198
+ };
199
+ type DevToolsRuntimeEvent = {
200
+ version: 1;
201
+ kind: "snapshot";
202
+ snapshot: SnapshotWithRunState;
203
+ } | {
204
+ version: 1;
205
+ kind: "delta";
206
+ delta: DevToolsDelta;
207
+ } | {
208
+ version: 1;
209
+ kind: "gapResync";
210
+ gapResync: DevToolsGapResync;
211
+ };
212
+ type ConnectionState = {
213
+ kind: "disconnected";
214
+ } | {
215
+ kind: "connecting";
216
+ } | {
217
+ kind: "streaming";
218
+ } | {
219
+ kind: "error";
220
+ error: Error;
221
+ };
222
+ type GhostNodeRecord = {
223
+ key: string;
224
+ node: DevToolsNode;
225
+ mountedFrameNo: number;
226
+ unmountedFrameNo: number;
227
+ unmountedSeq: number;
228
+ capturedAtMs: number;
229
+ };
230
+ type StoreOptions = {
231
+ client?: DevToolsClient;
232
+ ghostNodeCap?: number;
233
+ staleBannerDelayMs?: number;
234
+ toastSink?: (message: string) => void;
235
+ };
236
+ type LiveRunDevToolsMode = {
237
+ kind: "live";
238
+ } | {
239
+ kind: "historical";
240
+ frameNo: number;
241
+ };
242
+ type StoreListener = (store: DevToolsStore) => void;
243
+ declare class DevToolsStore {
244
+ readonly client: DevToolsClient;
245
+ readonly ghostNodeCap: number;
246
+ readonly staleBannerDelayMs: number;
247
+ tree: DevToolsNode | undefined;
248
+ seq: number;
249
+ lastEventAt: Date | undefined;
250
+ selectedNodeId: number | undefined;
251
+ isGhost: boolean;
252
+ connectionState: ConnectionState;
253
+ staleSince: Date | undefined;
254
+ isStaleBannerVisible: boolean;
255
+ ghostNodes: Map<string, GhostNodeRecord>;
256
+ mode: LiveRunDevToolsMode;
257
+ latestFrameNo: number;
258
+ scrubError: Error | undefined;
259
+ rewindError: Error | undefined;
260
+ rewindInFlight: boolean;
261
+ runningNodeCount: number;
262
+ runningNodeIds: Set<string>;
263
+ eventsApplied: number;
264
+ reconnectCount: number;
265
+ decodeErrorCount: number;
266
+ runSupportsRetry: boolean;
267
+ runStatus: string;
268
+ runStateView: RunStateView | undefined;
269
+ lastToastMessage: string | undefined;
270
+ lastAuditRowId: string | undefined;
271
+ runId: string | undefined;
272
+ bufferedLiveEvents: number;
273
+ private readonly listeners;
274
+ private readonly toastSink;
275
+ private readonly backoff;
276
+ private streamAbort;
277
+ private staleBannerTimer;
278
+ private shouldReconnect;
279
+ private stateRunId;
280
+ private selectedNodeGhostKey;
281
+ private readonly lastSeqSeenByRunId;
282
+ private readonly mountedFrameByGhostKey;
283
+ private readonly ghostEvictionOrder;
284
+ private liveSnapshot;
285
+ private liveLatestFrameNo;
286
+ private awaitingSnapshotAfterGapResync;
287
+ constructor(options?: StoreOptions);
288
+ get heartbeatAgeMs(): number;
289
+ get selectedNode(): DevToolsNode | undefined;
290
+ get selectedGhostRecord(): GhostNodeRecord | undefined;
291
+ get displayedFrameNo(): number;
292
+ get isRunFinished(): boolean;
293
+ get isRewindEligible(): boolean;
294
+ subscribe(listener: StoreListener): () => boolean;
295
+ connect(runId: string): void;
296
+ disconnect(): void;
297
+ applyEvent(event: DevToolsRuntimeEvent): void;
298
+ applyGapResync(gapResync: DevToolsGapResync): void;
299
+ applySnapshot(snapshot: SnapshotWithRunState): void;
300
+ applyDeltaEvent(delta: DevToolsDelta): void;
301
+ scrubTo(frameNo: number): Promise<void>;
302
+ returnToLive(): void;
303
+ rewind(frameNo: number, confirm?: boolean): Promise<void>;
304
+ clearHistoricalError(): void;
305
+ clearRewindError(): void;
306
+ selectNode(nodeId: number | undefined): void;
307
+ clearSelection(): void;
308
+ clearHistory(): void;
309
+ isGhostNode(node: DevToolsNode): boolean;
310
+ ghostRecord(node: DevToolsNode): GhostNodeRecord | undefined;
311
+ retryNode(_nodeId: string): void;
312
+ private startStream;
313
+ private consumeStream;
314
+ private requestResync;
315
+ private applySnapshotToLiveState;
316
+ private applyDeltaToLiveState;
317
+ private syncDisplayedTreeWithLive;
318
+ private refreshRunningState;
319
+ private resetForNewRun;
320
+ private lastSeenSeq;
321
+ private markConnectionInterrupted;
322
+ private markStreamHealthy;
323
+ private scheduleStaleBannerReveal;
324
+ private clearStaleBannerTimer;
325
+ private updateGhostState;
326
+ private recordMountedFrames;
327
+ private recordMountedFramesFromDelta;
328
+ private captureGhostNodesRemovedBySnapshot;
329
+ private registerRemovedGhostNodes;
330
+ private captureGhostNodesFromDelta;
331
+ private registerGhostSubtree;
332
+ private registerGhostNode;
333
+ private enforceGhostBudget;
334
+ private pruneGhostNodesNowActive;
335
+ private pruneGhostNodesForRewind;
336
+ private removeGhostRecords;
337
+ private resolvedGhostNodeCap;
338
+ private emit;
339
+ }
340
+
341
+ type Theme$4 = {
342
+ fg?: (color: string, value: string) => string;
343
+ bold?: (value: string) => string;
344
+ };
345
+ declare class FrameScrubber {
346
+ private readonly store;
347
+ constructor(store: DevToolsStore);
348
+ handleInput(data: string): boolean;
349
+ render(width: number, theme: Theme$4): string[];
350
+ }
351
+
352
+ type Theme$3 = {
353
+ fg?: (color: string, value: string) => string;
354
+ bold?: (value: string) => string;
355
+ };
356
+ declare class Header {
357
+ private readonly store;
358
+ private readonly workflowName;
359
+ constructor(store: DevToolsStore, workflowName?: string);
360
+ render(width: number, theme: Theme$3): string[];
361
+ }
362
+
363
+ type Theme$2 = {
364
+ fg?: (color: string, value: string) => string;
365
+ bold?: (value: string) => string;
366
+ };
367
+ declare class NodeInspector {
368
+ private readonly store;
369
+ private tab;
370
+ private scrollOffset;
371
+ constructor(store: DevToolsStore);
372
+ handleInput(data: string): "handled" | "unhandled";
373
+ render(width: number, height: number, theme: Theme$2): string[];
374
+ private bodyLines;
375
+ private nextTab;
376
+ private pad;
377
+ }
378
+
379
+ type Theme$1 = {
380
+ fg?: (color: string, value: string) => string;
381
+ bold?: (value: string) => string;
382
+ };
383
+ type RunInspectorOptions = {
384
+ workflowName?: string;
385
+ onClose?: () => void;
386
+ onNotify?: (message: string, level?: "info" | "warning" | "error") => void;
387
+ };
388
+ declare class RunInspector {
389
+ private readonly store;
390
+ private readonly client;
391
+ private readonly header;
392
+ private readonly scrubber;
393
+ private readonly tree;
394
+ private readonly inspector;
395
+ private readonly onClose;
396
+ private readonly onNotify;
397
+ private focus;
398
+ private cachedLines;
399
+ private cachedWidth;
400
+ constructor(store: DevToolsStore, client: DevToolsClient, options?: RunInspectorOptions);
401
+ handleInput(data: string): void;
402
+ render(width: number, height: number | undefined, theme: Theme$1): string[];
403
+ invalidate(): void;
404
+ dispose(): void;
405
+ private cycleFocus;
406
+ private selectedTask;
407
+ private approveSelected;
408
+ private denySelected;
409
+ private cancelRun;
410
+ private rewindDisplayedFrame;
411
+ }
412
+
413
+ type Theme = {
414
+ fg?: (color: string, value: string) => string;
415
+ bold?: (value: string) => string;
416
+ };
417
+ type TreeRow = {
418
+ node: DevToolsNode;
419
+ depth: number;
420
+ };
421
+ declare class RunTree {
422
+ private readonly store;
423
+ private readonly expandedIds;
424
+ private readonly userCollapsedIds;
425
+ private scrollOffset;
426
+ private searchQuery;
427
+ private searchMode;
428
+ private lastAutoSeq;
429
+ constructor(store: DevToolsStore);
430
+ handleInput(data: string): "handled" | "unhandled" | "focusInspector";
431
+ render(width: number, height: number, theme: Theme): string[];
432
+ visibleRows(): TreeRow[];
433
+ private renderRow;
434
+ private rebuildAutoExpansion;
435
+ private ensureSelection;
436
+ private ensureScroll;
437
+ private moveSelection;
438
+ private collapseSelected;
439
+ private expandSelected;
440
+ private selectRow;
441
+ }
442
+
443
+ export { DevToolsClient, DevToolsStore, FrameScrubber, Header, NodeInspector, RunInspector, RunTree, approve, buildSmithersPiSystemPrompt, cancel, deny, extension, getFrames, getStatus, listRuns, resume, runWorkflow, streamEvents };
package/src/index.ts ADDED
@@ -0,0 +1,18 @@
1
+ export { approve } from "./api/approve.js";
2
+ export { cancel } from "./api/cancel.js";
3
+ export { deny } from "./api/deny.js";
4
+ export { getFrames } from "./api/getFrames.js";
5
+ export { getStatus } from "./api/getStatus.js";
6
+ export { listRuns } from "./api/listRuns.js";
7
+ export { resume } from "./api/resume.js";
8
+ export { runWorkflow } from "./api/runWorkflow.js";
9
+ export { streamEvents } from "./api/streamEvents.js";
10
+ export { buildSmithersPiSystemPrompt } from "./buildSmithersPiSystemPrompt.js";
11
+ export { extension } from "./extension.js";
12
+ export { DevToolsClient } from "./runtime/DevToolsClient.js";
13
+ export { DevToolsStore } from "./runtime/DevToolsStore.js";
14
+ export { FrameScrubber } from "./views/FrameScrubber.js";
15
+ export { Header } from "./views/Header.js";
16
+ export { NodeInspector } from "./views/NodeInspector.js";
17
+ export { RunInspector } from "./views/RunInspector.js";
18
+ export { RunTree } from "./views/RunTree.js";