@prismshadow/penguin-server 0.2.6 → 0.2.8
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/README.md +4 -4
- package/dist/api/types.d.ts +393 -21
- package/dist/auth-token.d.ts +29 -0
- package/dist/auth-token.js +51 -0
- package/dist/auth-token.js.map +1 -0
- package/dist/{chunk-WKJ3ANJP.js → chunk-622KL7BQ.js} +92 -381
- package/dist/chunk-622KL7BQ.js.map +1 -0
- package/dist/chunk-K4ZSUT72.js +34 -0
- package/dist/chunk-K4ZSUT72.js.map +1 -0
- package/dist/chunk-UGAFPYVX.js +374 -0
- package/dist/chunk-UGAFPYVX.js.map +1 -0
- package/dist/extension/index.d.ts +212 -0
- package/dist/extension/index.js +1 -0
- package/dist/extension/index.js.map +1 -0
- package/dist/index.js +5758 -1310
- package/dist/index.js.map +1 -1
- package/dist/initial-password.d.ts +9 -12
- package/dist/initial-password.js +3 -7
- package/dist/install.ps1 +729 -0
- package/dist/install.sh +785 -0
- package/dist/reset-admin-password.d.ts +4 -7
- package/dist/reset-admin-password.js +11 -9
- package/dist/reset-admin-password.js.map +1 -1
- package/dist/secret-file.d.ts +3 -0
- package/dist/secret-file.js +17 -0
- package/dist/secret-file.js.map +1 -0
- package/package.json +19 -3
- package/web-dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/web-dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/web-dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/web-dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/web-dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/web-dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/web-dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/web-dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/web-dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/web-dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/web-dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/web-dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/web-dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/web-dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/web-dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/web-dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/web-dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/web-dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/web-dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/web-dist/assets/{addon-fit-CE-3eCvv.js → addon-fit-DHOzI3Ur.js} +1 -1
- package/web-dist/assets/{addon-web-links-DeODgawX.js → addon-web-links-DC7759H1.js} +1 -1
- package/web-dist/assets/{highlighter-DpnM5FfD.js → highlighter-CGPO6Q4b.js} +1 -1
- package/web-dist/assets/index-CaFDHl-w.js +451 -0
- package/web-dist/assets/index-D8Bk9LtJ.css +1 -0
- package/web-dist/assets/{xterm-BjU-ZsL5.js → xterm-DY5ko-BU.js} +1 -1
- package/web-dist/index.html +2 -2
- package/dist/chunk-UUJCF46V.js +0 -50
- package/dist/chunk-UUJCF46V.js.map +0 -1
- package/dist/chunk-WKJ3ANJP.js.map +0 -1
- package/web-dist/assets/index-aRsvImZt.css +0 -1
- package/web-dist/assets/index-gNzir_kH.js +0 -189
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { Resources } from '@prismshadow/penguin-core/kernel';
|
|
2
|
+
export { Disposable, Extension, ExtensionContext, ExtensionEvents, PenguinContext, PenguinInterface, ToolFactory, WorkflowFactory, WorkflowInstance, WorkflowInstances } from '@prismshadow/penguin-core/extension';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Screen snapshot -> ANSI restore stream, plus plain-text capture.
|
|
6
|
+
*
|
|
7
|
+
* This is what makes a browser refresh (or a reconnect from a second device) show the
|
|
8
|
+
* terminal exactly as it was: the daemon keeps an authoritative headless xterm per pty, and
|
|
9
|
+
* on attach it *re-renders* that grid as an escape-sequence stream the client's real xterm
|
|
10
|
+
* replays into an identical screen. That beats the two obvious alternatives:
|
|
11
|
+
*
|
|
12
|
+
* - Replaying the raw pty byte log: unbounded, and full-screen programs (vim, top) replay
|
|
13
|
+
* as a flicker of stale frames.
|
|
14
|
+
* - Sending a JSON cell grid: a 200k-object payload per attach, parsed on the UI thread.
|
|
15
|
+
*
|
|
16
|
+
* Cursor alignment is the subtle part. The restore writes `scrollback + rows` lines, so the
|
|
17
|
+
* client's viewport ends up holding exactly the server's viewport, and only then is the
|
|
18
|
+
* cursor placed with a viewport-relative CUP. Trailing blank rows are therefore written on
|
|
19
|
+
* purpose — dropping them would shift every subsequent row and land the cursor in the wrong
|
|
20
|
+
* place.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
interface CaptureLinesOptions {
|
|
24
|
+
/** Line index into scrollback+viewport; negative counts from the end (-1 = last line). */
|
|
25
|
+
start?: number;
|
|
26
|
+
end?: number;
|
|
27
|
+
}
|
|
28
|
+
interface CaptureLinesResult {
|
|
29
|
+
lines: string[];
|
|
30
|
+
totalLines: number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface TerminalExitInfo {
|
|
34
|
+
exitCode: number;
|
|
35
|
+
signal: number | null;
|
|
36
|
+
lastOutputLines: string[];
|
|
37
|
+
}
|
|
38
|
+
interface CreateTerminalSessionOptions {
|
|
39
|
+
id?: string;
|
|
40
|
+
/** Absolute working directory (already resolved and validated by the manager). */
|
|
41
|
+
cwd: string;
|
|
42
|
+
/** Owning user id — a shell is the most privileged thing this server hands out. */
|
|
43
|
+
ownerUserId: string;
|
|
44
|
+
/**
|
|
45
|
+
* Stable per-user display number (tmux-style), assigned by the manager at creation. It
|
|
46
|
+
* travels with the terminal for its whole life — UI numbering must never depend on list
|
|
47
|
+
* position, which changes under user-reordered tabs.
|
|
48
|
+
*/
|
|
49
|
+
seq?: number;
|
|
50
|
+
name?: string;
|
|
51
|
+
shell?: string;
|
|
52
|
+
cols?: number;
|
|
53
|
+
rows?: number;
|
|
54
|
+
env?: Record<string, string>;
|
|
55
|
+
/**
|
|
56
|
+
* Where a pushed bundle's node-pty assets live (the hmr capability's assetsDir);
|
|
57
|
+
* absent falls back to the packaged require (see pty-module.ts).
|
|
58
|
+
*/
|
|
59
|
+
assets?: () => string | null;
|
|
60
|
+
}
|
|
61
|
+
interface TerminalSessionInfo {
|
|
62
|
+
id: string;
|
|
63
|
+
seq: number;
|
|
64
|
+
name: string;
|
|
65
|
+
cwd: string;
|
|
66
|
+
ownerUserId: string;
|
|
67
|
+
title: string | null;
|
|
68
|
+
cols: number;
|
|
69
|
+
rows: number;
|
|
70
|
+
pid: number;
|
|
71
|
+
createdAt: string;
|
|
72
|
+
alive: boolean;
|
|
73
|
+
exit: TerminalExitInfo | null;
|
|
74
|
+
}
|
|
75
|
+
type TerminalOutputListener = (data: string) => void;
|
|
76
|
+
type TerminalExitListener = (info: TerminalExitInfo) => void;
|
|
77
|
+
type TerminalTitleListener = (title: string | null) => void;
|
|
78
|
+
declare class TerminalSession {
|
|
79
|
+
readonly id: string;
|
|
80
|
+
readonly seq: number;
|
|
81
|
+
readonly cwd: string;
|
|
82
|
+
readonly ownerUserId: string;
|
|
83
|
+
readonly createdAt: Date;
|
|
84
|
+
private name;
|
|
85
|
+
private readonly terminal;
|
|
86
|
+
private readonly ptyProcess;
|
|
87
|
+
private readonly inputMode;
|
|
88
|
+
private readonly outputListeners;
|
|
89
|
+
private readonly exitListeners;
|
|
90
|
+
private readonly titleListeners;
|
|
91
|
+
private title;
|
|
92
|
+
private pendingTitle;
|
|
93
|
+
private titleTimer;
|
|
94
|
+
private sizeState;
|
|
95
|
+
private exitInfo;
|
|
96
|
+
private disposed;
|
|
97
|
+
constructor(options: CreateTerminalSessionOptions);
|
|
98
|
+
/** DA1 / DSR / OSC colour queries — see OSC_COLOR_QUERY_RESPONSES. */
|
|
99
|
+
private registerCapabilityResponders;
|
|
100
|
+
get alive(): boolean;
|
|
101
|
+
get exit(): TerminalExitInfo | null;
|
|
102
|
+
info(): TerminalSessionInfo;
|
|
103
|
+
rename(name: string): void;
|
|
104
|
+
write(data: string): void;
|
|
105
|
+
/**
|
|
106
|
+
* Applies a size request under the claim/update ownership rule, resizing both the pty and
|
|
107
|
+
* the daemon's emulator so snapshots keep matching what the shell laid out.
|
|
108
|
+
*/
|
|
109
|
+
resize(request: {
|
|
110
|
+
connectionId: string;
|
|
111
|
+
cols: number;
|
|
112
|
+
rows: number;
|
|
113
|
+
intent: "claim" | "update";
|
|
114
|
+
}): boolean;
|
|
115
|
+
releaseSize(connectionId: string): void;
|
|
116
|
+
get size(): {
|
|
117
|
+
cols: number;
|
|
118
|
+
rows: number;
|
|
119
|
+
};
|
|
120
|
+
/** The attach payload: the whole screen as an ANSI stream (see snapshot.ts). */
|
|
121
|
+
restoreStream(options?: {
|
|
122
|
+
scrollbackLines?: number;
|
|
123
|
+
}): string;
|
|
124
|
+
capture(options?: CaptureLinesOptions): CaptureLinesResult;
|
|
125
|
+
onOutput(listener: TerminalOutputListener): () => void;
|
|
126
|
+
onExit(listener: TerminalExitListener): () => void;
|
|
127
|
+
onTitleChange(listener: TerminalTitleListener): () => void;
|
|
128
|
+
kill(signal?: string): void;
|
|
129
|
+
dispose(): void;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
interface CreateTerminalRequest {
|
|
133
|
+
cwd: string;
|
|
134
|
+
ownerUserId: string;
|
|
135
|
+
name?: string;
|
|
136
|
+
cols?: number;
|
|
137
|
+
rows?: number;
|
|
138
|
+
shell?: string;
|
|
139
|
+
}
|
|
140
|
+
declare class TerminalManager {
|
|
141
|
+
private readonly resources;
|
|
142
|
+
private readonly opts;
|
|
143
|
+
/**
|
|
144
|
+
* The kernel's resource registry, threaded to every session it creates: a native module
|
|
145
|
+
* reaches the platform through it (pty-module.ts), and live ptys are registered in it so
|
|
146
|
+
* a hot swap hands them to the next platform instead of killing them.
|
|
147
|
+
*/
|
|
148
|
+
constructor(resources: Resources, opts?: {
|
|
149
|
+
graceMs?: number;
|
|
150
|
+
/** Where a pushed bundle's node-pty assets live (hmr.assetsDir); absent falls back to the packaged require. */
|
|
151
|
+
assets?: () => string | null;
|
|
152
|
+
});
|
|
153
|
+
private get graceMs();
|
|
154
|
+
private readonly sessions;
|
|
155
|
+
private readonly reapTimers;
|
|
156
|
+
/** Exit-listener unsubscribers, so quiesce() can detach this manager from delivered ptys. */
|
|
157
|
+
private readonly exitUnsubs;
|
|
158
|
+
/** Paired unregister per pty (register's return): the only way an entry leaves the registry. */
|
|
159
|
+
private readonly unregisters;
|
|
160
|
+
create(request: CreateTerminalRequest): Promise<TerminalSession>;
|
|
161
|
+
/**
|
|
162
|
+
* Takes a session into this manager AND into the runtime's resource registry. The
|
|
163
|
+
* registry is what makes a pty outlive a platform swap: it sits outside the reloadable
|
|
164
|
+
* tree, so the shell keeps running and the next instance claims it back (see
|
|
165
|
+
* hmr/resources.ts). The parked context carries only these ids.
|
|
166
|
+
*/
|
|
167
|
+
private track;
|
|
168
|
+
/**
|
|
169
|
+
* Reclaims the sessions a previous instance parked. An id the registry no longer knows
|
|
170
|
+
* is simply dropped: its shell died with the process that owned it, and a manager
|
|
171
|
+
* holding a handle to nothing would only fail later, further from the cause.
|
|
172
|
+
*/
|
|
173
|
+
adopt(ids: readonly string[]): void;
|
|
174
|
+
/**
|
|
175
|
+
* Park-side detach (hot swap only — never process exit): the ptys are DELIVERED to the
|
|
176
|
+
* next App through the registry, so this manager must stop acting on them. Exit
|
|
177
|
+
* listeners are unsubscribed (the successor adopts and re-listens), and every pending
|
|
178
|
+
* reap — each targeting an already-dead session that was therefore NOT parked for
|
|
179
|
+
* adoption — runs immediately instead of firing later from a dead generation, where it
|
|
180
|
+
* would release a registry id out from under whoever owns it next.
|
|
181
|
+
*/
|
|
182
|
+
quiesce(): void;
|
|
183
|
+
/** Handle ids for the parked context document — live sessions only. */
|
|
184
|
+
handleIds(): string[];
|
|
185
|
+
/** Looks up a session, enforcing ownership. Unknown and not-yours are both 404 — no probing. */
|
|
186
|
+
require(id: string, userId: string): TerminalSession;
|
|
187
|
+
get(id: string): TerminalSession | undefined;
|
|
188
|
+
list(userId: string): TerminalSession[];
|
|
189
|
+
listInfo(userId: string): TerminalSessionInfo[];
|
|
190
|
+
kill(id: string, userId: string): void;
|
|
191
|
+
/** Drops the session once nothing can usefully be read from it any more. */
|
|
192
|
+
private scheduleReap;
|
|
193
|
+
/** Server shutdown: every pty is a child process and must not outlive us. */
|
|
194
|
+
disposeAll(): void;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* The harness's extension surface — the `@prismshadow/penguin-server/extension` subpath.
|
|
199
|
+
*
|
|
200
|
+
* The contract itself lives in `@prismshadow/penguin-core/extension`; what this module adds
|
|
201
|
+
* is the harness's own members, contributed by AUGMENTING that contract rather than by
|
|
202
|
+
* redeclaring it. Core names nothing it cannot reach, this layer names what it owns, and
|
|
203
|
+
* an extension sees one `PenguinContext` either way.
|
|
204
|
+
*
|
|
205
|
+
* Re-exported here so an extension package has one import site for both halves.
|
|
206
|
+
*/
|
|
207
|
+
|
|
208
|
+
declare module "@prismshadow/penguin-core/extension" {
|
|
209
|
+
interface PenguinContext {
|
|
210
|
+
terminals: TerminalManager;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|