@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
|
@@ -42,6 +42,7 @@ export class SqliteStateRepository {
|
|
|
42
42
|
CREATE TABLE IF NOT EXISTS timestamps (conversation TEXT PRIMARY KEY, stamp TEXT NOT NULL);
|
|
43
43
|
CREATE TABLE IF NOT EXISTS collections (name TEXT PRIMARY KEY, json TEXT NOT NULL);
|
|
44
44
|
CREATE TABLE IF NOT EXISTS metadata (conversation TEXT PRIMARY KEY, json TEXT NOT NULL);
|
|
45
|
+
CREATE TABLE IF NOT EXISTS send_receipts (conversation TEXT NOT NULL, id TEXT NOT NULL, PRIMARY KEY(conversation,id));
|
|
45
46
|
CREATE TABLE IF NOT EXISTS runs (id TEXT PRIMARY KEY, json TEXT NOT NULL);`);
|
|
46
47
|
}
|
|
47
48
|
async load() {
|
|
@@ -56,6 +57,7 @@ export class SqliteStateRepository {
|
|
|
56
57
|
if (!Array.isArray(state.conversations))
|
|
57
58
|
state.conversations = [];
|
|
58
59
|
for (const conversation of state.conversations) {
|
|
60
|
+
const baseReceipts = conversation.acceptedSendIds ?? [];
|
|
59
61
|
const metadata = this.db.prepare("SELECT json FROM metadata WHERE conversation=?").get(conversation.id);
|
|
60
62
|
if (metadata) {
|
|
61
63
|
const messages = conversation.messages;
|
|
@@ -93,6 +95,10 @@ export class SqliteStateRepository {
|
|
|
93
95
|
const stamp = this.db.prepare("SELECT stamp FROM timestamps WHERE conversation=?").get(conversation.id);
|
|
94
96
|
if (stamp?.stamp)
|
|
95
97
|
conversation.updatedAt = String(stamp.stamp);
|
|
98
|
+
const receipts = this.db.prepare("SELECT id FROM send_receipts WHERE conversation=?").all(conversation.id);
|
|
99
|
+
if (baseReceipts.length || receipts.length) {
|
|
100
|
+
conversation.acceptedSendIds = [...new Set([...baseReceipts, ...(conversation.acceptedSendIds ?? []), ...receipts.map(item => String(item.id))])];
|
|
101
|
+
}
|
|
96
102
|
}
|
|
97
103
|
const runs = new Map(this.db.prepare("SELECT id,json FROM runs").all().map(r => [String(r.id), JSON.parse(String(r.json))]));
|
|
98
104
|
/**
|
|
@@ -122,7 +128,7 @@ export class SqliteStateRepository {
|
|
|
122
128
|
async save(state) {
|
|
123
129
|
this.atomic(() => {
|
|
124
130
|
this.db.prepare("INSERT INTO state VALUES(1,?) ON CONFLICT(id) DO UPDATE SET json=excluded.json").run(JSON.stringify(state));
|
|
125
|
-
this.db.exec("DELETE FROM messages; DELETE FROM message_order; DELETE FROM runs; DELETE FROM timestamps; DELETE FROM collections; DELETE FROM metadata;");
|
|
131
|
+
this.db.exec("DELETE FROM messages; DELETE FROM message_order; DELETE FROM runs; DELETE FROM timestamps; DELETE FROM collections; DELETE FROM metadata; DELETE FROM send_receipts;");
|
|
126
132
|
});
|
|
127
133
|
}
|
|
128
134
|
async commit(transaction) {
|
|
@@ -176,6 +182,13 @@ export class SqliteStateRepository {
|
|
|
176
182
|
// yet, the base array is authoritative - that is the `load` contract - so this falls back to
|
|
177
183
|
// the full write ONCE to materialise the order, and every later write is a diff.
|
|
178
184
|
const conversationId = transaction.conversationId;
|
|
185
|
+
if (transaction.acceptedSendId) {
|
|
186
|
+
this.db.prepare("INSERT OR IGNORE INTO send_receipts VALUES(?,?)").run(conversationId, transaction.acceptedSendId);
|
|
187
|
+
}
|
|
188
|
+
if (transaction.metadata) {
|
|
189
|
+
this.db.prepare("INSERT INTO metadata VALUES(?,?) ON CONFLICT(conversation) DO UPDATE SET json=excluded.json")
|
|
190
|
+
.run(conversationId, JSON.stringify(transaction.metadata));
|
|
191
|
+
}
|
|
179
192
|
const stored = new Map(this.db.prepare("SELECT id,json FROM messages WHERE conversation=?").all(conversationId)
|
|
180
193
|
.map((row) => [String(row.id), String(row.json)]));
|
|
181
194
|
const ordered = this.db.prepare("SELECT id,position FROM message_order WHERE conversation=? ORDER BY position").all(conversationId);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** Explicit file scopes must still name an existing directory. */
|
|
2
|
+
export declare function resolveFileCwd(workspaceRoot: string, cwd?: string | null): Promise<string>;
|
|
1
3
|
/**
|
|
2
4
|
* Resolves a conversation's optional relative cwd without ever letting it leave the workspace.
|
|
3
5
|
* An absent value preserves the workspace root; an invalid or escaping value is rejected back to
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import { relative, resolve, sep } from "node:path";
|
|
2
|
-
import {
|
|
2
|
+
import { stat } from "node:fs/promises";
|
|
3
|
+
import { FilesError, resolveInsideRoot } from "./files.js";
|
|
4
|
+
/** Explicit file scopes must still name an existing directory. */
|
|
5
|
+
export async function resolveFileCwd(workspaceRoot, cwd) {
|
|
6
|
+
const target = await resolveInsideRoot(workspaceRoot, cwd);
|
|
7
|
+
if (!cwd?.trim())
|
|
8
|
+
return target;
|
|
9
|
+
const info = await stat(target).catch((error) => {
|
|
10
|
+
if (error.code === "ENOENT" || error.code === "ENOTDIR")
|
|
11
|
+
throw new FilesError(404, "会话目录已不存在。", "cwd_missing");
|
|
12
|
+
throw error;
|
|
13
|
+
});
|
|
14
|
+
if (!info.isDirectory())
|
|
15
|
+
throw new FilesError(400, "会话路径必须是目录。", "cwd_not_directory");
|
|
16
|
+
return target;
|
|
17
|
+
}
|
|
3
18
|
/**
|
|
4
19
|
* Resolves a conversation's optional relative cwd without ever letting it leave the workspace.
|
|
5
20
|
* An absent value preserves the workspace root; an invalid or escaping value is rejected back to
|
package/dist/server/store.d.ts
CHANGED
|
@@ -198,6 +198,7 @@ export declare class Store {
|
|
|
198
198
|
* out, so nothing can mutate the store through it.
|
|
199
199
|
*/
|
|
200
200
|
hasMessage(conversationId: string, messageId: string): boolean;
|
|
201
|
+
hasAcceptedSend(conversationId: string, clientId: string): boolean;
|
|
201
202
|
/**
|
|
202
203
|
* One conversation and its workspace, as DETACHED copies, without cloning the whole state.
|
|
203
204
|
*
|
package/dist/server/store.js
CHANGED
|
@@ -1114,6 +1114,10 @@ export class Store {
|
|
|
1114
1114
|
hasMessage(conversationId, messageId) {
|
|
1115
1115
|
return Boolean(this.state.conversations.find((item) => item.id === conversationId)?.messages.some((message) => message.id === messageId));
|
|
1116
1116
|
}
|
|
1117
|
+
hasAcceptedSend(conversationId, clientId) {
|
|
1118
|
+
const conversation = this.state.conversations.find(item => item.id === conversationId);
|
|
1119
|
+
return Boolean(conversation?.acceptedSendIds?.includes(clientId) || conversation?.messages.some(message => message.id === clientId && message.role === "user"));
|
|
1120
|
+
}
|
|
1117
1121
|
/**
|
|
1118
1122
|
* One conversation and its workspace, as DETACHED copies, without cloning the whole state.
|
|
1119
1123
|
*
|
|
@@ -1267,7 +1271,8 @@ export class Store {
|
|
|
1267
1271
|
const { projects: _projects, ...publicState } = this.state;
|
|
1268
1272
|
const closed = new Set(this.state.workspaces.filter((item) => item.closedAt).map((item) => item.id));
|
|
1269
1273
|
const workspaces = this.state.workspaces.filter((item) => !closed.has(item.id));
|
|
1270
|
-
const visible = this.state.conversations.filter((item) => !closed.has(item.workspaceId) && !item.warmSession)
|
|
1274
|
+
const visible = this.state.conversations.filter((item) => !closed.has(item.workspaceId) && !item.warmSession)
|
|
1275
|
+
.map(({ acceptedSendIds: _accepted, ...conversation }) => conversation);
|
|
1271
1276
|
const warmSessions = workspaces.flatMap((workspace) => this.listWarmSessions(workspace.id));
|
|
1272
1277
|
const presets = warmSessions.length ? { warmSessions } : {};
|
|
1273
1278
|
const openEscalations = this.openEscalationAudiences();
|
|
@@ -1903,13 +1908,30 @@ export class Store {
|
|
|
1903
1908
|
conversation.messages.push(message);
|
|
1904
1909
|
// Persisted as a transcript change and nothing more: this is the honest record of "the user said this
|
|
1905
1910
|
// and nothing has picked it up yet", and a refresh has to show it in the same place it was sent from.
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1911
|
+
const acceptedSendId = options?.clientId === message.id ? message.id : undefined;
|
|
1912
|
+
const previousMetadata = !message.delivery && acceptedSendId
|
|
1913
|
+
? { title: conversation.title, updatedAt: conversation.updatedAt, status: conversation.status, error: conversation.error, warning: conversation.warning }
|
|
1914
|
+
: undefined;
|
|
1915
|
+
if (acceptedSendId)
|
|
1916
|
+
(conversation.acceptedSendIds ??= []).push(acceptedSendId);
|
|
1917
|
+
try {
|
|
1918
|
+
if (message.delivery)
|
|
1919
|
+
await this.persistMessages(conversation, acceptedSendId);
|
|
1920
|
+
else
|
|
1921
|
+
await this.persistIncomingTurn(conversation, message, acceptedSendId);
|
|
1922
|
+
}
|
|
1923
|
+
catch (error) {
|
|
1924
|
+
if (acceptedSendId) {
|
|
1925
|
+
conversation.messages = conversation.messages.filter(item => item !== message);
|
|
1926
|
+
conversation.acceptedSendIds = conversation.acceptedSendIds?.filter(id => id !== acceptedSendId);
|
|
1927
|
+
if (previousMetadata && conversation.updatedAt === message.createdAt && conversation.status === "waiting")
|
|
1928
|
+
Object.assign(conversation, previousMetadata);
|
|
1929
|
+
}
|
|
1930
|
+
throw error;
|
|
1931
|
+
}
|
|
1910
1932
|
return structuredClone(message);
|
|
1911
1933
|
}
|
|
1912
|
-
async persistIncomingTurn(conversation, message) {
|
|
1934
|
+
async persistIncomingTurn(conversation, message, acceptedSendId) {
|
|
1913
1935
|
const firstUser = conversation.messages.find((item) => item.role === "user");
|
|
1914
1936
|
const autoTitle = firstUser?.content.trim()
|
|
1915
1937
|
? firstUser.content.slice(0, 42)
|
|
@@ -1943,8 +1965,10 @@ export class Store {
|
|
|
1943
1965
|
// The conversation's metadata (status, title, updatedAt) and its messages are exactly what
|
|
1944
1966
|
// changed, and the repository has an incremental path for each. The base snapshot every other
|
|
1945
1967
|
// conversation lives in is untouched by this call, so rewriting it buys nothing.
|
|
1946
|
-
|
|
1947
|
-
await this.
|
|
1968
|
+
const { messages: _messages, acceptedSendIds: _receipts, ...metadata } = conversation;
|
|
1969
|
+
await this.persistMessages(conversation, acceptedSendId, acceptedSendId ? metadata : undefined);
|
|
1970
|
+
if (!acceptedSendId)
|
|
1971
|
+
await this.persistMetadata(conversation.id);
|
|
1948
1972
|
}
|
|
1949
1973
|
/**
|
|
1950
1974
|
* Takes the browser's id for its own optimistic message, when it is safe to.
|
|
@@ -2339,8 +2363,21 @@ export class Store {
|
|
|
2339
2363
|
if (patch.thinkingBlock !== undefined)
|
|
2340
2364
|
call.thinkingBlock = patch.thinkingBlock;
|
|
2341
2365
|
// The question rides on the call rather than beside it, so this is the only write it needs.
|
|
2342
|
-
if (patch.question !== undefined)
|
|
2366
|
+
if (patch.question !== undefined && (!call.question || call.question.status === "pending")) {
|
|
2367
|
+
const previous = call.question;
|
|
2343
2368
|
call.question = patch.question;
|
|
2369
|
+
if (patch.question.status !== "pending") {
|
|
2370
|
+
try {
|
|
2371
|
+
await this.persistToolCallMessage(conversationId, messageId);
|
|
2372
|
+
}
|
|
2373
|
+
catch (error) {
|
|
2374
|
+
if (call.question === patch.question)
|
|
2375
|
+
call.question = previous;
|
|
2376
|
+
throw error;
|
|
2377
|
+
}
|
|
2378
|
+
return structuredClone(calls);
|
|
2379
|
+
}
|
|
2380
|
+
}
|
|
2344
2381
|
conversation.updatedAt = now();
|
|
2345
2382
|
await this.persistToolCallMessage(conversationId, messageId);
|
|
2346
2383
|
return structuredClone(calls);
|
|
@@ -2561,8 +2598,8 @@ export class Store {
|
|
|
2561
2598
|
throw new Error(`等待中的消息不存在或已被处理:${messageId}`);
|
|
2562
2599
|
return { conversation, message };
|
|
2563
2600
|
}
|
|
2564
|
-
async persistMessages(conversation) {
|
|
2565
|
-
await this.persistTransaction({ kind: "conversation.messages", conversationId: conversation.id, messages: structuredClone(conversation.messages), updatedAt: conversation.updatedAt });
|
|
2601
|
+
async persistMessages(conversation, acceptedSendId, metadata) {
|
|
2602
|
+
await this.persistTransaction({ kind: "conversation.messages", conversationId: conversation.id, messages: structuredClone(conversation.messages), updatedAt: conversation.updatedAt, ...(acceptedSendId ? { acceptedSendId } : {}), ...(metadata ? { metadata: structuredClone(metadata) } : {}) });
|
|
2566
2603
|
}
|
|
2567
2604
|
/**
|
|
2568
2605
|
* Claims one waiting message for delivery to the live Pi process: `waiting` becomes `sending`, and the
|
|
@@ -3137,7 +3174,7 @@ export class Store {
|
|
|
3137
3174
|
await this.persistTransaction({ kind: "collections.replace", values: { [key]: structuredClone(value) } });
|
|
3138
3175
|
}
|
|
3139
3176
|
async persistMetadata(conversationId) {
|
|
3140
|
-
const { messages: _messages, ...metadata } = this.requireConversation(conversationId);
|
|
3177
|
+
const { messages: _messages, acceptedSendIds: _receipts, ...metadata } = this.requireConversation(conversationId);
|
|
3141
3178
|
await this.persistTransaction({ kind: "conversation.metadata", conversationId, metadata: structuredClone(metadata) });
|
|
3142
3179
|
}
|
|
3143
3180
|
async persist() { await this.repository.save(this.state); }
|
|
@@ -25,12 +25,10 @@
|
|
|
25
25
|
* 2. NETWORK SCOPE. Even enabled, a command is refused unless the WebSocket arrived from loopback or
|
|
26
26
|
* an RFC 1918 / link-local / ULA address (`isLocalOrPrivateAddress`, the same predicate the file
|
|
27
27
|
* endpoints use). A request that arrives from a routed or proxied address is refused by name.
|
|
28
|
-
* 3.
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* 4. BOUNDED SESSIONS. `MAX_SESSIONS` live shells, capped so a loop of reconnects cannot accumulate
|
|
33
|
-
* processes.
|
|
28
|
+
* 3. WORKSPACE SCOPE. The server resolves a workspace ID and validates the relative starting directory.
|
|
29
|
+
* 4. BOUNDED SESSIONS. Shells and retained output count toward fixed limits.
|
|
30
|
+
* 5. REATTACHMENT. Browser ownership scopes session discovery; only a subscribed socket may
|
|
31
|
+
* address a slot. Losing a subscription does not end the shell.
|
|
34
32
|
*
|
|
35
33
|
* What is NOT here is a per-command allowlist. A terminal that refuses `rm` or `curl` is not a terminal,
|
|
36
34
|
* and pretending otherwise would be worse than the honest version: with (1) and (2) the operator has
|
|
@@ -48,7 +46,8 @@
|
|
|
48
46
|
* `node-pty` allocates a real pseudo-terminal (ConPTY on Windows, `forkpty` elsewhere), which is the
|
|
49
47
|
* only way to get them. The cost is a native module, and it is paid only by operators who set
|
|
50
48
|
*/
|
|
51
|
-
import type {
|
|
49
|
+
import type { Workspace } from "./types.js";
|
|
50
|
+
import { type TerminalCommand, type TerminalEvent } from "../shared/terminal-protocol.js";
|
|
52
51
|
/**
|
|
53
52
|
* WHICH SHELL, and why it is not `COMSPEC`.
|
|
54
53
|
*
|
|
@@ -116,62 +115,15 @@ export declare function terminalShellCandidates(env?: NodeJS.ProcessEnv): {
|
|
|
116
115
|
* otherwise leave them behind.
|
|
117
116
|
*/
|
|
118
117
|
export declare const MAX_SESSIONS = 256;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
* than a second transport.
|
|
122
|
-
*
|
|
123
|
-
* Reusing the command channel is what makes this feature cheap to wire: the WebSocket already carries
|
|
124
|
-
* authentication, and `ws-server.ts` already answers exactly one socket. A parallel HTTP endpoint with
|
|
125
|
-
* server-sent events would have had to re-implement both, and the terminal's traffic is bidirectional -
|
|
126
|
-
* keystrokes have to flow back the same way output does.
|
|
127
|
-
*/
|
|
128
|
-
export type TerminalCommand = {
|
|
129
|
-
type: "terminal.open";
|
|
130
|
-
sessionId: string;
|
|
131
|
-
workspaceId: string;
|
|
132
|
-
cwd?: string;
|
|
133
|
-
cols?: number;
|
|
134
|
-
rows?: number;
|
|
135
|
-
} | {
|
|
136
|
-
type: "terminal.input";
|
|
137
|
-
sessionId: string;
|
|
138
|
-
data: string;
|
|
139
|
-
} | {
|
|
140
|
-
type: "terminal.resize";
|
|
141
|
-
sessionId: string;
|
|
142
|
-
cols: number;
|
|
143
|
-
rows: number;
|
|
144
|
-
} | {
|
|
145
|
-
type: "terminal.close";
|
|
146
|
-
sessionId: string;
|
|
147
|
-
};
|
|
148
|
-
export type TerminalEvent = {
|
|
149
|
-
type: "terminal.output";
|
|
150
|
-
sessionId: string;
|
|
151
|
-
data: string;
|
|
152
|
-
} | {
|
|
153
|
-
type: "terminal.exit";
|
|
154
|
-
sessionId: string;
|
|
155
|
-
exitCode: number;
|
|
156
|
-
} | {
|
|
157
|
-
type: "terminal.error";
|
|
158
|
-
sessionId: string;
|
|
159
|
-
message: string;
|
|
160
|
-
} | {
|
|
161
|
-
type: "terminal.status";
|
|
162
|
-
enabled: boolean;
|
|
163
|
-
reason?: string;
|
|
164
|
-
};
|
|
165
|
-
/**
|
|
166
|
-
* The terminal is built in; node-pty availability is checked when a session opens.
|
|
167
|
-
*/
|
|
118
|
+
type TerminalSender = (event: TerminalEvent) => void;
|
|
119
|
+
/** The terminal is built in. Native PTY availability is checked on use. */
|
|
168
120
|
export declare function isTerminalEnabled(env?: NodeJS.ProcessEnv): boolean;
|
|
169
|
-
/** The sentence a browser shows when the terminal is missing. Says WHICH of the three gates closed. */
|
|
170
121
|
export declare function terminalDisabledReason(_env?: NodeJS.ProcessEnv): string;
|
|
171
122
|
export declare class TerminalService {
|
|
172
|
-
private readonly
|
|
123
|
+
private readonly groups;
|
|
124
|
+
private readonly subscriptions;
|
|
125
|
+
private closing;
|
|
173
126
|
private readonly workspaceFor;
|
|
174
|
-
/** Whether a command from this peer is allowed to touch a shell at all. */
|
|
175
127
|
private readonly isTrustedPeer;
|
|
176
128
|
private readonly configuredShell;
|
|
177
129
|
private readonly saveConfiguredShell;
|
|
@@ -190,24 +142,22 @@ export declare class TerminalService {
|
|
|
190
142
|
});
|
|
191
143
|
readonly enabled: boolean;
|
|
192
144
|
setShell(command: string | null, remoteAddress: string | undefined): Promise<boolean>;
|
|
193
|
-
/**
|
|
194
|
-
* WHY THE PEER CHECK LIVES ON EVERY COMMAND AND NOT ONLY ON `open`.
|
|
195
|
-
*
|
|
196
|
-
* The obvious implementation authorises `terminal.open` and then trusts the session. That leaves a
|
|
197
|
-
* live shell reachable by a socket opened BEFORE the address changed - and, on this server, the
|
|
198
|
-
* browser is same-origin on whatever host it was opened from, so a user who tunnels in, opens a
|
|
199
|
-
* terminal, and then forwards their port to a colleague has silently widened the audience for every
|
|
200
|
-
* keystroke that follows.
|
|
201
|
-
*
|
|
202
|
-
* `isTrustedPeer` is re-evaluated per command. It is a pure function of the socket's remote address,
|
|
203
|
-
* so the cost is one predicate per keystroke and the guarantee is that no session outlives its
|
|
204
|
-
* socket's authorisation.
|
|
205
|
-
*/
|
|
206
145
|
private assertUsable;
|
|
207
|
-
handle(command: TerminalCommand, remoteAddress: string | undefined, send:
|
|
208
|
-
private
|
|
146
|
+
handle(command: TerminalCommand, remoteAddress: string | undefined, send: TerminalSender): Promise<void>;
|
|
147
|
+
private sync;
|
|
148
|
+
private open;
|
|
149
|
+
private spawn;
|
|
150
|
+
private slots;
|
|
151
|
+
private sendSessions;
|
|
152
|
+
private publish;
|
|
209
153
|
private flush;
|
|
210
|
-
private
|
|
211
|
-
|
|
154
|
+
private recordExit;
|
|
155
|
+
private stop;
|
|
156
|
+
private errorMessage;
|
|
157
|
+
/** Losing a reader never changes a shell or its output history. */
|
|
158
|
+
detach(send: TerminalSender): void;
|
|
159
|
+
private pruneEmptyGroup;
|
|
160
|
+
removeWorkspace(workspaceId: string): void;
|
|
212
161
|
closeAll(): void;
|
|
213
162
|
}
|
|
163
|
+
export {};
|