@evandu/super-pi 0.1.223 → 0.1.225
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/client/.super-pi-client-sources.json +12 -8
- package/dist/client/assets/{CodeMirrorEditor-Due3YL4A.js → CodeMirrorEditor-OLbwCzUh.js} +2 -2
- package/dist/client/assets/{dist-B3qtMidG.js → dist-BQImRXFO.js} +1 -1
- package/dist/client/assets/{dist-BJ5mZEGq.js → dist-BUOU8RAm.js} +1 -1
- package/dist/client/assets/{dist-BZGq856v.js → dist-BdrKprbZ.js} +1 -1
- package/dist/client/assets/{dist-DCVXoyno.js → dist-BffuhHE1.js} +1 -1
- package/dist/client/assets/{dist-B2XX-bBx.js → dist-C8-e07vM.js} +1 -1
- package/dist/client/assets/{dist-2kMlRtqo.js → dist-C8naDDXu.js} +1 -1
- package/dist/client/assets/{dist-JSFnHR0P.js → dist-C9f0Riun.js} +1 -1
- package/dist/client/assets/{dist-1hXEE44f.js → dist-CB9Qr9C6.js} +1 -1
- package/dist/client/assets/{dist-DSCSHwdP.js → dist-CIEDxNn7.js} +1 -1
- package/dist/client/assets/{dist-CRrYz-2t.js → dist-CIsUvpC9.js} +1 -1
- package/dist/client/assets/{dist-BHlGN5Cp.js → dist-CKA2u-s7.js} +1 -1
- package/dist/client/assets/{dist-D2n9-vIx.js → dist-COIAnYiN.js} +1 -1
- package/dist/client/assets/{dist-BvUexO6W.js → dist-CXpar2cD.js} +1 -1
- package/dist/client/assets/{dist-CMws1R9h.js → dist-CZu3CzDX.js} +1 -1
- package/dist/client/assets/{dist-BJ_pU8qp.js → dist-CaePDjkH.js} +1 -1
- package/dist/client/assets/{dist-CA52X7jm.js → dist-Cro2exEx.js} +1 -1
- package/dist/client/assets/{dist-BXTbngmK.js → dist-CxJkT0iM.js} +1 -1
- package/dist/client/assets/{dist-BaUqm3zx.js → dist-D53uN01l.js} +1 -1
- package/dist/client/assets/{dist-DOJKt6Px.js → dist-D9kySnbi.js} +1 -1
- package/dist/client/assets/{dist-Cw21UX77.js → dist-MARoODS1.js} +1 -1
- package/dist/client/assets/{dist-Po3GdueN.js → dist-ot9lBE7N.js} +1 -1
- package/dist/client/assets/{dist-CQIMZ_7M.js → dist-sv2AtsDR.js} +1 -1
- package/dist/client/assets/index-B0m5CXCB.js +105 -0
- package/dist/client/assets/index-DK_mME9e.css +1 -0
- package/dist/client/index.html +2 -2
- package/dist/server/application/extension-ui-service.d.ts +6 -1
- package/dist/server/application/extension-ui-service.js +31 -2
- package/dist/server/application/run-service.d.ts +4 -1
- package/dist/server/application/run-service.js +102 -35
- package/dist/server/command-handler.js +11 -2
- package/dist/server/exec-service.d.ts +5 -2
- package/dist/server/exec-service.js +12 -2
- package/dist/server/file-index.d.ts +13 -1
- package/dist/server/file-index.js +108 -12
- package/dist/server/file-name-index.d.ts +8 -0
- package/dist/server/file-name-index.js +58 -11
- package/dist/server/files.js +4 -0
- package/dist/server/http-server.js +182 -25
- package/dist/server/index.js +14 -9
- package/dist/server/persistence/app-state-repository.d.ts +3 -1
- package/dist/server/persistence/sqlite-state-repository.js +14 -1
- package/dist/server/session-cwd.d.ts +2 -0
- package/dist/server/session-cwd.js +16 -1
- package/dist/server/store.d.ts +1 -0
- package/dist/server/store.js +49 -12
- package/dist/server/terminal.d.ts +26 -76
- package/dist/server/terminal.js +239 -172
- package/dist/server/tool-llm.d.ts +7 -0
- package/dist/server/tool-llm.js +8 -1
- package/dist/server/tool-runner.d.ts +7 -0
- package/dist/server/tool-runner.js +8 -1
- package/dist/server/types.d.ts +27 -75
- package/dist/server/workspace-file-indexes.d.ts +2 -0
- package/dist/server/workspace-file-indexes.js +61 -0
- package/dist/server/workspace-file-operations.d.ts +36 -0
- package/dist/server/workspace-file-operations.js +281 -0
- package/dist/server/workspace-file-response.d.ts +3 -0
- package/dist/server/workspace-file-response.js +79 -0
- package/dist/server/ws-server.d.ts +7 -12
- package/dist/server/ws-server.js +23 -18
- package/dist/shared/terminal-protocol.d.ts +71 -0
- package/dist/shared/terminal-protocol.js +1 -0
- package/dist/shared/workspace-file-preview.d.ts +4 -0
- package/dist/shared/workspace-file-preview.js +28 -0
- package/package.json +2 -1
- package/dist/client/assets/index-DHdzZ1mf.js +0 -103
- package/dist/client/assets/index-OmaD3l6r.css +0 -1
|
@@ -2,7 +2,7 @@ import type { Server as NodeHttpServer } from "node:http";
|
|
|
2
2
|
import { WebSocket } from "ws";
|
|
3
3
|
import type { AppState, ServerEvent } from "./types.js";
|
|
4
4
|
import type { EventBroadcaster } from "./server-context.js";
|
|
5
|
-
import type { CommandHandler } from "./command-handler.js";
|
|
5
|
+
import type { CommandHandler, SocketSender } from "./command-handler.js";
|
|
6
6
|
import type { CatalogService } from "./application/catalog-service.js";
|
|
7
7
|
/**
|
|
8
8
|
* A WebSocket is a live transport, not an unbounded queue. `ws.send()` only
|
|
@@ -44,6 +44,7 @@ export declare function safeSend(socket: WebSocket, payload: string): boolean;
|
|
|
44
44
|
*/
|
|
45
45
|
export declare class WsBroadcaster implements EventBroadcaster {
|
|
46
46
|
private readonly getState;
|
|
47
|
+
private readonly replay?;
|
|
47
48
|
private readonly sockets;
|
|
48
49
|
private readonly scopes;
|
|
49
50
|
private readonly fileIndexScopes;
|
|
@@ -64,7 +65,9 @@ export declare class WsBroadcaster implements EventBroadcaster {
|
|
|
64
65
|
private readonly sendStateImmediately;
|
|
65
66
|
constructor(getState: (scope?: {
|
|
66
67
|
conversationId?: string;
|
|
67
|
-
}) => AppState
|
|
68
|
+
}) => AppState, replay?: ((state: AppState, scope?: {
|
|
69
|
+
conversationId?: string;
|
|
70
|
+
}) => ServerEvent[]) | undefined);
|
|
68
71
|
register(socket: WebSocket, scope?: {
|
|
69
72
|
conversationId?: string;
|
|
70
73
|
}): void;
|
|
@@ -114,16 +117,8 @@ export interface WsServerOptions {
|
|
|
114
117
|
catalogService: CatalogService;
|
|
115
118
|
accessToken?: string;
|
|
116
119
|
rootDir?: string;
|
|
117
|
-
/**
|
|
118
|
-
|
|
119
|
-
*
|
|
120
|
-
* An ORPHANED SHELL IS THE FAILURE MODE THIS EXISTS TO PREVENT. A terminal outlives its tab by
|
|
121
|
-
* default: close the browser tab, or lose the Wi-Fi, or hit refresh mid-build, and the PTY keeps
|
|
122
|
-
* running with nobody reading its output. On a laptop that is a battery drain; on a machine running
|
|
123
|
-
* a long `npm install` it is a process nobody can interrupt from the UI any more. Tracking the ids
|
|
124
|
-
* per connection makes "the socket closed" and "the shells it started are gone" the same event.
|
|
125
|
-
*/
|
|
126
|
-
onSocketClose?: (terminalSessionIds: readonly string[]) => void;
|
|
120
|
+
/** Release subscriptions owned by this connection. */
|
|
121
|
+
onSocketClose?: (sender: SocketSender) => void;
|
|
127
122
|
}
|
|
128
123
|
/**
|
|
129
124
|
* WebSocket transport manager handling upgrade, connection lifecycles, and command dispatch.
|
package/dist/server/ws-server.js
CHANGED
|
@@ -66,6 +66,7 @@ export function safeSend(socket, payload) {
|
|
|
66
66
|
*/
|
|
67
67
|
export class WsBroadcaster {
|
|
68
68
|
getState;
|
|
69
|
+
replay;
|
|
69
70
|
sockets = new Set();
|
|
70
71
|
// Undefined preserves the original full-state protocol. An object, including {}, opts into
|
|
71
72
|
// conversation-focused snapshots from the very first frame of the connection.
|
|
@@ -86,8 +87,9 @@ export class WsBroadcaster {
|
|
|
86
87
|
* Never set outside a probe or a regression test that is asserting the old behaviour.
|
|
87
88
|
*/
|
|
88
89
|
sendStateImmediately = process.env.SUPER_PI_LEGACY_SUBAGENT_FLOOD === "1";
|
|
89
|
-
constructor(getState) {
|
|
90
|
+
constructor(getState, replay) {
|
|
90
91
|
this.getState = getState;
|
|
92
|
+
this.replay = replay;
|
|
91
93
|
}
|
|
92
94
|
register(socket, scope) {
|
|
93
95
|
this.sockets.add(socket);
|
|
@@ -114,7 +116,12 @@ export class WsBroadcaster {
|
|
|
114
116
|
if (socket.readyState !== WebSocket.OPEN)
|
|
115
117
|
return;
|
|
116
118
|
this.flushStreaming(socket);
|
|
117
|
-
|
|
119
|
+
const scope = this.scopes.get(socket);
|
|
120
|
+
const state = this.getState(scope);
|
|
121
|
+
if (!safeSend(socket, JSON.stringify({ type: "state", state })))
|
|
122
|
+
return;
|
|
123
|
+
for (const event of this.replay?.(state, scope) ?? [])
|
|
124
|
+
safeSend(socket, JSON.stringify(event));
|
|
118
125
|
}
|
|
119
126
|
subscribeFileIndex(socket, workspaceId, cwd = "") {
|
|
120
127
|
if (workspaceId)
|
|
@@ -135,6 +142,8 @@ export class WsBroadcaster {
|
|
|
135
142
|
case "message.thinking":
|
|
136
143
|
case "message.tools":
|
|
137
144
|
return event.conversationId === scope.conversationId;
|
|
145
|
+
case "exec.output":
|
|
146
|
+
return !event.conversationId || event.conversationId === scope.conversationId;
|
|
138
147
|
case "subagent.event":
|
|
139
148
|
return event.run.conversationId === scope.conversationId;
|
|
140
149
|
case "workflow.event":
|
|
@@ -404,12 +413,14 @@ export class WsServer {
|
|
|
404
413
|
* a missing address must fail CLOSED rather than fall back to "allowed".
|
|
405
414
|
*/
|
|
406
415
|
const remoteAddress = request.socket.remoteAddress;
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
416
|
+
const send = event => {
|
|
417
|
+
if (safeSend(socket, JSON.stringify(event)))
|
|
418
|
+
return;
|
|
419
|
+
// Dropping a terminal frame would corrupt the stream or leave its replay unfinished.
|
|
420
|
+
// Reconnecting restores the baseline without stopping the PTY.
|
|
421
|
+
if (event.type.startsWith("terminal.") && socket.readyState === WebSocket.OPEN)
|
|
422
|
+
socket.close(1013, "Terminal reconnect required");
|
|
423
|
+
};
|
|
413
424
|
this.broadcaster.sendState(socket);
|
|
414
425
|
if (this.rootDir) {
|
|
415
426
|
safeSend(socket, JSON.stringify({ type: "server.version", version: checkDiskVersion(this.rootDir) }));
|
|
@@ -452,11 +463,7 @@ export class WsServer {
|
|
|
452
463
|
socket.on("close", () => {
|
|
453
464
|
clearInterval(heartbeat);
|
|
454
465
|
this.broadcaster.unregister(socket);
|
|
455
|
-
|
|
456
|
-
// `terminal.open` cannot leak one. The set is per-connection, so another tab's terminal survives.
|
|
457
|
-
if (terminalSessionIds.size)
|
|
458
|
-
this.onSocketClose?.([...terminalSessionIds]);
|
|
459
|
-
terminalSessionIds.clear();
|
|
466
|
+
this.onSocketClose?.(send);
|
|
460
467
|
});
|
|
461
468
|
/**
|
|
462
469
|
* Commands from ONE socket are SERIALIZED through a promise chain. `handleCommand` is async, so
|
|
@@ -514,11 +521,9 @@ export class WsServer {
|
|
|
514
521
|
let command;
|
|
515
522
|
try {
|
|
516
523
|
command = parsed;
|
|
517
|
-
if (command.type
|
|
518
|
-
|
|
519
|
-
const entityId = await this.commandHandler.handleCommand(command,
|
|
520
|
-
safeSend(socket, JSON.stringify(event));
|
|
521
|
-
}, remoteAddress);
|
|
524
|
+
if (command.type.startsWith("terminal.") && socket.readyState !== WebSocket.OPEN)
|
|
525
|
+
return;
|
|
526
|
+
const entityId = await this.commandHandler.handleCommand(command, send, remoteAddress);
|
|
522
527
|
// Void-returning configuration commands also need an ack to release optimistic UI state.
|
|
523
528
|
if (command.operationRequestId)
|
|
524
529
|
safeSend(socket, JSON.stringify({ type: "operation.result", requestId: command.operationRequestId, ok: true, entityId }));
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export declare const MAX_TERMINAL_SLOTS = 5;
|
|
2
|
+
export interface TerminalScope {
|
|
3
|
+
workspaceId: string;
|
|
4
|
+
conversationId?: string;
|
|
5
|
+
}
|
|
6
|
+
interface TerminalSize {
|
|
7
|
+
cols?: number;
|
|
8
|
+
rows?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface TerminalSlot extends Required<TerminalSize> {
|
|
11
|
+
id: string;
|
|
12
|
+
title: string;
|
|
13
|
+
exitCode?: number;
|
|
14
|
+
reason?: string;
|
|
15
|
+
}
|
|
16
|
+
export type TerminalCommand = ({
|
|
17
|
+
type: "terminal.sync";
|
|
18
|
+
ownerId: string;
|
|
19
|
+
cwd?: string;
|
|
20
|
+
initialize?: boolean;
|
|
21
|
+
} & TerminalScope & TerminalSize) | {
|
|
22
|
+
type: "terminal.detach";
|
|
23
|
+
} | ({
|
|
24
|
+
type: "terminal.open";
|
|
25
|
+
sessionId?: string;
|
|
26
|
+
} & TerminalSize) | {
|
|
27
|
+
type: "terminal.input";
|
|
28
|
+
sessionId: string;
|
|
29
|
+
data: string;
|
|
30
|
+
} | {
|
|
31
|
+
type: "terminal.resize";
|
|
32
|
+
sessionId: string;
|
|
33
|
+
cols: number;
|
|
34
|
+
rows: number;
|
|
35
|
+
} | {
|
|
36
|
+
type: "terminal.close";
|
|
37
|
+
sessionId: string;
|
|
38
|
+
};
|
|
39
|
+
export type TerminalEvent = ({
|
|
40
|
+
type: "terminal.sessions";
|
|
41
|
+
sessions: TerminalSlot[];
|
|
42
|
+
replay: boolean;
|
|
43
|
+
activate?: string;
|
|
44
|
+
} & TerminalScope) | {
|
|
45
|
+
type: "terminal.replay";
|
|
46
|
+
sessionId: string;
|
|
47
|
+
data: string;
|
|
48
|
+
} | {
|
|
49
|
+
type: "terminal.size";
|
|
50
|
+
sessionId: string;
|
|
51
|
+
cols: number;
|
|
52
|
+
rows: number;
|
|
53
|
+
} | {
|
|
54
|
+
type: "terminal.output";
|
|
55
|
+
sessionId: string;
|
|
56
|
+
data: string;
|
|
57
|
+
} | {
|
|
58
|
+
type: "terminal.exit";
|
|
59
|
+
sessionId: string;
|
|
60
|
+
exitCode: number;
|
|
61
|
+
reason?: string;
|
|
62
|
+
} | {
|
|
63
|
+
type: "terminal.error";
|
|
64
|
+
sessionId?: string;
|
|
65
|
+
message: string;
|
|
66
|
+
} | {
|
|
67
|
+
type: "terminal.status";
|
|
68
|
+
enabled: boolean;
|
|
69
|
+
reason?: string;
|
|
70
|
+
};
|
|
71
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const MAX_TERMINAL_SLOTS = 5;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type WorkspacePreviewKind = "image" | "pdf" | "audio" | "video" | "table" | "document" | "download";
|
|
2
|
+
export declare function workspaceFileExtension(path: string): string;
|
|
3
|
+
export declare function workspaceFileMime(path: string): string | undefined;
|
|
4
|
+
export declare function workspacePreviewKind(path: string): WorkspacePreviewKind | undefined;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const types = {
|
|
2
|
+
png: "image/png", jpg: "image/jpeg", jpeg: "image/jpeg", gif: "image/gif", webp: "image/webp", avif: "image/avif",
|
|
3
|
+
pdf: "application/pdf", mp3: "audio/mpeg", wav: "audio/wav", ogg: "audio/ogg", m4a: "audio/mp4",
|
|
4
|
+
mp4: "video/mp4", webm: "video/webm", ogv: "video/ogg",
|
|
5
|
+
};
|
|
6
|
+
export function workspaceFileExtension(path) {
|
|
7
|
+
return /\.([^./]+)$/.exec(path)?.[1].toLowerCase() ?? "";
|
|
8
|
+
}
|
|
9
|
+
export function workspaceFileMime(path) {
|
|
10
|
+
const extension = workspaceFileExtension(path);
|
|
11
|
+
return Object.hasOwn(types, extension) ? types[extension] : undefined;
|
|
12
|
+
}
|
|
13
|
+
export function workspacePreviewKind(path) {
|
|
14
|
+
const mime = workspaceFileMime(path);
|
|
15
|
+
if (mime === "application/pdf")
|
|
16
|
+
return "pdf";
|
|
17
|
+
if (mime?.startsWith("image/"))
|
|
18
|
+
return "image";
|
|
19
|
+
if (mime?.startsWith("audio/"))
|
|
20
|
+
return "audio";
|
|
21
|
+
if (mime?.startsWith("video/"))
|
|
22
|
+
return "video";
|
|
23
|
+
if (/\.(csv|tsv)$/i.test(path))
|
|
24
|
+
return "table";
|
|
25
|
+
if (/\.docx$/i.test(path))
|
|
26
|
+
return "document";
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evandu/super-pi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.225",
|
|
4
4
|
"description": "Web control plane and companion for Pi",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -292,6 +292,7 @@
|
|
|
292
292
|
"check:browser": [
|
|
293
293
|
"scripts/markdown-syntax-browser.test.mjs",
|
|
294
294
|
"scripts/file-mentions-browser.test.mjs",
|
|
295
|
+
"scripts/workspace-explorer-browser.test.mjs",
|
|
295
296
|
"scripts/message-actions-browser.test.mjs",
|
|
296
297
|
"scripts/sidebar-refresh-browser.test.mjs",
|
|
297
298
|
"scripts/provider-network-browser.test.mjs",
|