@noldova/terminal 0.0.6 → 0.0.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 +1 -1
- package/module.json +2 -2
- package/package.json +8 -6
- package/src/exceptions/stored-lines-damaged.exception.js +2 -1
- package/src/models/hosted-terminal.js +14 -7
- package/src/models/integration-script.js +15 -0
- package/src/models/mark-introducer.js +15 -0
- package/src/models/mark-terminator.js +15 -0
- package/src/models/mirror-line.js +2 -1
- package/src/models/one-shot-launch.js +2 -1
- package/src/models/output-span.js +15 -0
- package/src/models/shell-candidate.js +21 -0
- package/src/models/shell-mark.js +2 -1
- package/src/models/taken-segment.js +15 -0
- package/src/models/terminal-folder-key.js +15 -0
- package/src/models/terminal-opening.js +2 -1
- package/src/models/tracked-command.js +2 -1
- package/src/models/typed-line.js +2 -1
- package/src/models/wsl-launcher.js +15 -0
- package/src/resources.js +7 -3
- package/src/runtime-part.js +2 -1
- package/src/services/agent-terminal.js +8 -5
- package/src/services/agent-terminals.js +3 -2
- package/src/services/bounded-reads.js +7 -5
- package/src/services/change-signal.js +5 -4
- package/src/services/command-runner.js +10 -4
- package/src/services/command-tracker.js +5 -4
- package/src/services/completion-source.js +27 -23
- package/src/services/context-pty-process.js +3 -2
- package/src/services/context-pty-spawner.js +2 -1
- package/src/services/deferred-pty-process.js +7 -5
- package/src/services/escape-sequence-tracker.js +2 -1
- package/src/services/failure-text.js +2 -1
- package/src/services/flow-controller.js +5 -4
- package/src/services/latest-environment.js +2 -1
- package/src/services/mac-environment.js +3 -2
- package/src/services/mark-scanner.js +22 -14
- package/src/services/one-shot-command.js +3 -2
- package/src/services/output-batcher.js +2 -1
- package/src/services/output-log.js +4 -1
- package/src/services/powershell-binding.js +7 -6
- package/src/services/pseudo-terminal.js +7 -1
- package/src/services/registry-export.js +3 -2
- package/src/services/resize-wakeup.js +2 -1
- package/src/services/saved-terminals.js +2 -1
- package/src/services/shared-reads.js +3 -2
- package/src/services/shell-command.js +14 -15
- package/src/services/shell-integration.js +24 -22
- package/src/services/shell-locator.js +25 -22
- package/src/services/shell-words.js +3 -2
- package/src/services/system-requirements.js +9 -9
- package/src/services/terminal-audience.js +10 -9
- package/src/services/terminal-history-folder.js +5 -4
- package/src/services/terminal-history-segment.js +2 -1
- package/src/services/terminal-history.js +14 -12
- package/src/services/terminal-host.js +104 -101
- package/src/services/terminal-line-reader.js +3 -2
- package/src/services/terminal-mirror.js +13 -12
- package/src/services/terminal-session.js +37 -26
- package/src/services/visual-studio.reader.js +3 -2
- package/src/services/windows-environment.js +12 -11
- package/src/services/windows-folder-access.js +2 -1
- package/src/services/wsl-distribution.reader.js +2 -1
- package/src/tools/models/agent-terminal-opening.js +2 -1
- package/src/tools/models/output-chunk.js +4 -1
- package/src/tools/models/output-excerpt.js +12 -6
- package/src/tools/models/terminal-open-input.js +3 -2
- package/src/tools/models/terminal-output-report.js +5 -4
- package/src/tools/models/terminal-run-input.js +2 -1
- package/src/tools/models/terminal-target-input.js +2 -1
- package/src/tools/models/terminal-write-input.js +2 -1
- package/src/tools/models/tool-call-context.js +4 -3
- package/src/tools/services/permission-details.js +3 -2
- package/src/tools/services/permission-gate.js +2 -1
- package/src/tools/services/terminal-access-policy.js +8 -7
- package/src/tools/services/terminal-interrupt-tool.js +2 -1
- package/src/tools/services/terminal-read-tool.js +3 -2
- package/src/tools/services/terminal-run-tool.js +6 -5
- package/src/tools/services/terminal-text-escaper.js +2 -1
- package/src/tools/services/terminal-tool.js +2 -1
- package/src/tools/services/terminal-write-tool.js +2 -1
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
* This source code is licensed under the license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
|
+
import "@noldova/context.core";
|
|
8
9
|
import { TerminalLinePage, TerminalLineRange } from "@noldova/terminal.protocol";
|
|
9
10
|
import { StoredLinesUnwritableException } from "../exceptions/stored-lines-unwritable.exception.js";
|
|
11
|
+
import { TakenSegment } from "../models/taken-segment.js";
|
|
10
12
|
import { Resources } from "../resources.js";
|
|
11
13
|
import { TerminalHistorySegment } from "./terminal-history-segment.js";
|
|
12
14
|
export class TerminalHistory {
|
|
@@ -24,12 +26,12 @@ export class TerminalHistory {
|
|
|
24
26
|
this.paths = paths;
|
|
25
27
|
this.segmentLimit = Math.floor(limit / 2);
|
|
26
28
|
this.onWritten = onWritten;
|
|
27
|
-
this.newer = paths
|
|
28
|
-
if (paths
|
|
29
|
+
this.newer = Object.isNull(paths) ? null : new TerminalHistorySegment(paths.first, 0);
|
|
30
|
+
if (Object.isNull(paths))
|
|
29
31
|
this.fail(null);
|
|
30
32
|
}
|
|
31
33
|
get stored() {
|
|
32
|
-
if (this.newer
|
|
34
|
+
if (Object.isNull(this.newer))
|
|
33
35
|
return new TerminalLineRange(0, 0, 0);
|
|
34
36
|
return new TerminalLineRange(this.older?.first ?? this.newer.first, this.newer.end, this.dropped);
|
|
35
37
|
}
|
|
@@ -37,7 +39,7 @@ export class TerminalHistory {
|
|
|
37
39
|
return this.unwritten;
|
|
38
40
|
}
|
|
39
41
|
append(line) {
|
|
40
|
-
if (this.paths
|
|
42
|
+
if (Object.isNull(this.paths) || Object.isNull(this.newer) || !Object.isNull(this.failure) || this.isClosed)
|
|
41
43
|
return;
|
|
42
44
|
const text = `${JSON.stringify(line.toJson())}${Resources.lineFeed}`;
|
|
43
45
|
const bytes = Buffer.byteLength(text, Resources.utf8Encoding);
|
|
@@ -50,7 +52,7 @@ export class TerminalHistory {
|
|
|
50
52
|
this.unwritten += bytes;
|
|
51
53
|
}
|
|
52
54
|
clear() {
|
|
53
|
-
if (this.isClosed || this.paths
|
|
55
|
+
if (this.isClosed || Object.isNull(this.paths) || Object.isNull(this.newer))
|
|
54
56
|
return;
|
|
55
57
|
const end = this.newer.end;
|
|
56
58
|
for (const segment of this.segments)
|
|
@@ -71,11 +73,11 @@ export class TerminalHistory {
|
|
|
71
73
|
return (await Promise.allSettled(removals)).filter(t => t.status === "rejected").map(t => t.reason);
|
|
72
74
|
}
|
|
73
75
|
get segments() {
|
|
74
|
-
return [this.older, this.newer].filter(t => t
|
|
76
|
+
return [this.older, this.newer].filter(t => !Object.isNull(t));
|
|
75
77
|
}
|
|
76
78
|
rotate(paths, newer) {
|
|
77
|
-
const path = this.older
|
|
78
|
-
if (this.older
|
|
79
|
+
const path = Object.isNull(this.older) ? paths.second : this.older.path;
|
|
80
|
+
if (!Object.isNull(this.older)) {
|
|
79
81
|
this.dropped += this.older.end - this.older.first;
|
|
80
82
|
this.discard(this.older, false);
|
|
81
83
|
}
|
|
@@ -113,10 +115,10 @@ export class TerminalHistory {
|
|
|
113
115
|
async readPageAsync(start, limit) {
|
|
114
116
|
const stored = this.stored;
|
|
115
117
|
const segments = this.segments;
|
|
116
|
-
const pending = segments.map(t =>
|
|
117
|
-
for (const
|
|
118
|
-
await this.storeAsync(segment, buffer);
|
|
119
|
-
if (this.failure
|
|
118
|
+
const pending = segments.map(t => new TakenSegment(t, t.take()));
|
|
119
|
+
for (const taken of pending)
|
|
120
|
+
await this.storeAsync(taken.segment, taken.buffer);
|
|
121
|
+
if (!Object.isNull(this.failure))
|
|
120
122
|
throw this.failure;
|
|
121
123
|
const first = Math.min(Math.max(start, stored.start), stored.end);
|
|
122
124
|
const last = Math.min(first + limit, stored.end);
|