@noldova/terminal 0.0.14 → 0.0.15
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/module.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "terminal",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"displayName": "Terminal",
|
|
5
5
|
"description": "Runs shells in terminal panes, and lets AI agents run commands in them through permission requests.",
|
|
6
6
|
"parts": ["runtime", "window"],
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
],
|
|
23
23
|
"commands": ["terminal.new", "terminal.newWithShell", "terminal.toggle", "terminal.restartShell"],
|
|
24
24
|
"menus": ["terminal.tabRow", "terminal.shellMenu"],
|
|
25
|
-
"settings": ["terminal.defaultShell", "terminal.outputLimit", "terminal.fontSize", "terminal.suggestions", "terminal.commandColors", "terminal.completionList", "terminal.linkClick", "terminal.restoreTerminals"],
|
|
25
|
+
"settings": ["terminal.defaultShell", "terminal.outputLimit", "terminal.fontSize", "terminal.suggestions", "terminal.commandColors", "terminal.completionList", "terminal.linkClick", "terminal.restoreTerminals", "terminal.windowCommands"],
|
|
26
26
|
"views": ["terminal.panel", "terminal.session"],
|
|
27
27
|
"tools": ["terminal_list", "terminal_read", "terminal_open", "terminal_run", "terminal_write", "terminal_interrupt", "terminal_close"]
|
|
28
28
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noldova/terminal",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"description": "The terminal module for apps on Noldova Desktop: terminal panes over real shells, and agent tools that run commands through permission requests.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"registry": "https://registry.npmjs.org/"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@noldova/terminal.protocol": "0.0.
|
|
41
|
-
"@noldova/terminal.window": "0.0.
|
|
40
|
+
"@noldova/terminal.protocol": "0.0.15",
|
|
41
|
+
"@noldova/terminal.window": "0.0.15",
|
|
42
42
|
"@xterm/addon-serialize": "0.14.0",
|
|
43
43
|
"@xterm/headless": "6.0.0",
|
|
44
44
|
"node-pty": "1.2.0-beta.15"
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"@noldova/context.exceptions": ">=0.0.18 <0.1.0",
|
|
51
51
|
"@noldova/context.json": ">=0.0.18 <0.1.0"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "11f0eee5496c1362a594d15a9108ef75aa43e0ea"
|
|
54
54
|
}
|
package/settings.json
CHANGED
|
@@ -106,6 +106,17 @@
|
|
|
106
106
|
"scopes": [],
|
|
107
107
|
"page": "Terminal",
|
|
108
108
|
"group": "Terminal"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"name": "terminal.windowCommands",
|
|
112
|
+
"title": "Window commands",
|
|
113
|
+
"description": "Commands, by name, whose keys go to the window rather than the shell while a terminal has the focus, such as an app's command that maximizes its dock. None by default.",
|
|
114
|
+
"type": { "kind": "List", "maxLength": 200 },
|
|
115
|
+
"default": [],
|
|
116
|
+
"locality": "Shared",
|
|
117
|
+
"scopes": [],
|
|
118
|
+
"page": "Terminal",
|
|
119
|
+
"group": "Terminal"
|
|
109
120
|
}
|
|
110
121
|
]
|
|
111
122
|
}
|
package/src/resources.js
CHANGED
|
@@ -737,6 +737,7 @@ exit 0
|
|
|
737
737
|
static regOverwriteArgument = "/y";
|
|
738
738
|
static regQueryArgument = "query";
|
|
739
739
|
static environmentExportRetryMilliseconds = 250;
|
|
740
|
+
static environmentKeptMilliseconds = 2_000;
|
|
740
741
|
static machineEnvironmentKey = "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment";
|
|
741
742
|
static userEnvironmentKey = "HKCU\\Environment";
|
|
742
743
|
static environmentFolderPrefix = "noldova-terminal-environment-";
|
package/src/runtime-part.js
CHANGED
|
@@ -53,9 +53,11 @@ export class RuntimePart {
|
|
|
53
53
|
const signaller = new ProcessSignaller();
|
|
54
54
|
const environment = ShellEnvironment.create(process.platform, process.env, new EnvironmentTools(new LineProcessStarter(context), runner, reader, writer, access, tmpdir(), signaller, process.pid), context.log, Intl.DateTimeFormat().resolvedOptions().locale, MacEnvironment.hasSystemLocaleAsync);
|
|
55
55
|
environment.start();
|
|
56
|
+
const historyFolder = new TerminalHistoryFolder(writer, reader, signaller, tmpdir(), process.pid, context.log, access);
|
|
57
|
+
historyFolder.start();
|
|
56
58
|
try {
|
|
57
59
|
const events = new TerminalEvents(context.declareEvent(TerminalNames.outputEvent), context.declareEvent(TerminalNames.exitedEvent), context.declareEvent(TerminalNames.restartedEvent), context.declareEvent(TerminalNames.titleChangedEvent), context.declareEvent(TerminalNames.cwdChangedEvent), context.declareEvent(TerminalNames.detachedEvent), context.declareEvent(TerminalNames.closedEvent), context.declareEvent(TerminalNames.openedEvent), context.declareEvent(TerminalNames.launchCommandEndedEvent), context.declareEvent(TerminalNames.runOpenedEvent), context.declareEvent(TerminalNames.runEndedEvent), context.declareEvent(TerminalNames.renamedEvent), context.declareEvent(TerminalNames.commandAddedEvent), context.declareEvent(TerminalNames.commandStartedEvent), context.declareEvent(TerminalNames.outputStartedEvent), context.declareEvent(TerminalNames.outputPrintedEvent), context.declareEvent(TerminalNames.commandEndedEvent), context.declareEvent(TerminalNames.promptStartedEvent), context.declareEvent(TerminalNames.screenChangedEvent));
|
|
58
|
-
const host = new TerminalHost(new ContextPtySpawner(context), reader, new ShellIntegration(writer, tmpdir(), context.log, access, context.settings, process.platform),
|
|
60
|
+
const host = new TerminalHost(new ContextPtySpawner(context), reader, new ShellIntegration(writer, tmpdir(), context.log, access, context.settings, process.platform), historyFolder, new ShellLocator(process.platform, process.arch, process.env, ShellLocator.readUserShell(), reader, runner, context.log), process.platform, release(), new LatestEnvironment(environment, process.env), homedir(), context.log, events, new SavedTerminals(context.database, context.log), new CompletionSource(reader, runner, process.platform, homedir(), context.log), new CommandDescriber(runner, context.log));
|
|
59
61
|
for (const name of TerminalNames.methods)
|
|
60
62
|
context.registerMethod(name, { handleAsync: t => host.handleAsync(name, t.payload, RequestClient.fromContext(t)) });
|
|
61
63
|
context.onClientClosed(t => host.closeConnectionAsync(t.connection, t.window));
|
|
@@ -68,6 +70,7 @@ export class RuntimePart {
|
|
|
68
70
|
}
|
|
69
71
|
catch (error) {
|
|
70
72
|
environment.end();
|
|
73
|
+
await historyFolder.removeAsync();
|
|
71
74
|
throw error;
|
|
72
75
|
}
|
|
73
76
|
}
|
|
@@ -27,6 +27,10 @@ export class TerminalHistoryFolder {
|
|
|
27
27
|
this.log = log;
|
|
28
28
|
this.access = access;
|
|
29
29
|
}
|
|
30
|
+
start() {
|
|
31
|
+
this.folder = this.createAsync();
|
|
32
|
+
void this.folder.catch(() => undefined);
|
|
33
|
+
}
|
|
30
34
|
async pathsAsync(sessionId) {
|
|
31
35
|
this.folder ??= this.createAsync();
|
|
32
36
|
let folder;
|
|
@@ -24,6 +24,9 @@ export class WindowsEnvironment {
|
|
|
24
24
|
ending = Promise.withResolvers();
|
|
25
25
|
reading = null;
|
|
26
26
|
folder = null;
|
|
27
|
+
kept = null;
|
|
28
|
+
keptAt = 0;
|
|
29
|
+
isStartShared = false;
|
|
27
30
|
readCount = 0;
|
|
28
31
|
ended = false;
|
|
29
32
|
constructor(environment, tools, log) {
|
|
@@ -34,19 +37,30 @@ export class WindowsEnvironment {
|
|
|
34
37
|
this.reg = Object.isUndefined(systemRoot) || systemRoot.length === 0 ? null : path.win32.join(systemRoot, ...Resources.regPath);
|
|
35
38
|
}
|
|
36
39
|
start() {
|
|
37
|
-
void this.readAsync()
|
|
40
|
+
void this.readAsync().then(environment => {
|
|
41
|
+
if (Object.isNull(environment) || this.isStartShared)
|
|
42
|
+
return;
|
|
43
|
+
this.kept = environment;
|
|
44
|
+
this.keptAt = Date.now();
|
|
45
|
+
});
|
|
38
46
|
}
|
|
39
47
|
readAsync() {
|
|
40
48
|
if (this.ended)
|
|
41
49
|
return Promise.resolve(this.environment);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
const kept = this.kept;
|
|
51
|
+
this.kept = null;
|
|
52
|
+
if (!Object.isNull(kept) && Date.now() - this.keptAt < Resources.environmentKeptMilliseconds)
|
|
53
|
+
return Promise.resolve(kept);
|
|
54
|
+
if (!Object.isNull(this.reading)) {
|
|
55
|
+
this.isStartShared = true;
|
|
56
|
+
return this.reading;
|
|
48
57
|
}
|
|
49
|
-
|
|
58
|
+
const reading = Promise.race([this.readNowAsync(), this.ending.promise.then(() => this.environment)]);
|
|
59
|
+
this.reading = reading;
|
|
60
|
+
void reading.then(() => {
|
|
61
|
+
this.reading = null;
|
|
62
|
+
});
|
|
63
|
+
return reading;
|
|
50
64
|
}
|
|
51
65
|
end() {
|
|
52
66
|
this.ended = true;
|
|
@@ -205,7 +219,7 @@ export class WindowsEnvironment {
|
|
|
205
219
|
return scopePath;
|
|
206
220
|
}
|
|
207
221
|
static expand(value, variables) {
|
|
208
|
-
let text =
|
|
222
|
+
let text = String.empty;
|
|
209
223
|
let index = 0;
|
|
210
224
|
for (;;) {
|
|
211
225
|
const start = value.indexOf(Resources.windowsEnvironmentVariableDelimiter, index);
|