@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.
Files changed (81) hide show
  1. package/README.md +1 -1
  2. package/module.json +2 -2
  3. package/package.json +8 -6
  4. package/src/exceptions/stored-lines-damaged.exception.js +2 -1
  5. package/src/models/hosted-terminal.js +14 -7
  6. package/src/models/integration-script.js +15 -0
  7. package/src/models/mark-introducer.js +15 -0
  8. package/src/models/mark-terminator.js +15 -0
  9. package/src/models/mirror-line.js +2 -1
  10. package/src/models/one-shot-launch.js +2 -1
  11. package/src/models/output-span.js +15 -0
  12. package/src/models/shell-candidate.js +21 -0
  13. package/src/models/shell-mark.js +2 -1
  14. package/src/models/taken-segment.js +15 -0
  15. package/src/models/terminal-folder-key.js +15 -0
  16. package/src/models/terminal-opening.js +2 -1
  17. package/src/models/tracked-command.js +2 -1
  18. package/src/models/typed-line.js +2 -1
  19. package/src/models/wsl-launcher.js +15 -0
  20. package/src/resources.js +7 -3
  21. package/src/runtime-part.js +2 -1
  22. package/src/services/agent-terminal.js +8 -5
  23. package/src/services/agent-terminals.js +3 -2
  24. package/src/services/bounded-reads.js +7 -5
  25. package/src/services/change-signal.js +5 -4
  26. package/src/services/command-runner.js +10 -4
  27. package/src/services/command-tracker.js +5 -4
  28. package/src/services/completion-source.js +27 -23
  29. package/src/services/context-pty-process.js +3 -2
  30. package/src/services/context-pty-spawner.js +2 -1
  31. package/src/services/deferred-pty-process.js +7 -5
  32. package/src/services/escape-sequence-tracker.js +2 -1
  33. package/src/services/failure-text.js +2 -1
  34. package/src/services/flow-controller.js +5 -4
  35. package/src/services/latest-environment.js +2 -1
  36. package/src/services/mac-environment.js +3 -2
  37. package/src/services/mark-scanner.js +22 -14
  38. package/src/services/one-shot-command.js +3 -2
  39. package/src/services/output-batcher.js +2 -1
  40. package/src/services/output-log.js +4 -1
  41. package/src/services/powershell-binding.js +7 -6
  42. package/src/services/pseudo-terminal.js +7 -1
  43. package/src/services/registry-export.js +3 -2
  44. package/src/services/resize-wakeup.js +2 -1
  45. package/src/services/saved-terminals.js +2 -1
  46. package/src/services/shared-reads.js +3 -2
  47. package/src/services/shell-command.js +14 -15
  48. package/src/services/shell-integration.js +24 -22
  49. package/src/services/shell-locator.js +25 -22
  50. package/src/services/shell-words.js +3 -2
  51. package/src/services/system-requirements.js +9 -9
  52. package/src/services/terminal-audience.js +10 -9
  53. package/src/services/terminal-history-folder.js +5 -4
  54. package/src/services/terminal-history-segment.js +2 -1
  55. package/src/services/terminal-history.js +14 -12
  56. package/src/services/terminal-host.js +104 -101
  57. package/src/services/terminal-line-reader.js +3 -2
  58. package/src/services/terminal-mirror.js +13 -12
  59. package/src/services/terminal-session.js +37 -26
  60. package/src/services/visual-studio.reader.js +3 -2
  61. package/src/services/windows-environment.js +12 -11
  62. package/src/services/windows-folder-access.js +2 -1
  63. package/src/services/wsl-distribution.reader.js +2 -1
  64. package/src/tools/models/agent-terminal-opening.js +2 -1
  65. package/src/tools/models/output-chunk.js +4 -1
  66. package/src/tools/models/output-excerpt.js +12 -6
  67. package/src/tools/models/terminal-open-input.js +3 -2
  68. package/src/tools/models/terminal-output-report.js +5 -4
  69. package/src/tools/models/terminal-run-input.js +2 -1
  70. package/src/tools/models/terminal-target-input.js +2 -1
  71. package/src/tools/models/terminal-write-input.js +2 -1
  72. package/src/tools/models/tool-call-context.js +4 -3
  73. package/src/tools/services/permission-details.js +3 -2
  74. package/src/tools/services/permission-gate.js +2 -1
  75. package/src/tools/services/terminal-access-policy.js +8 -7
  76. package/src/tools/services/terminal-interrupt-tool.js +2 -1
  77. package/src/tools/services/terminal-read-tool.js +3 -2
  78. package/src/tools/services/terminal-run-tool.js +6 -5
  79. package/src/tools/services/terminal-text-escaper.js +2 -1
  80. package/src/tools/services/terminal-tool.js +2 -1
  81. 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 === null ? null : new TerminalHistorySegment(paths.first, 0);
28
- if (paths === null)
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 === null)
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 === null || this.newer === null || this.failure !== null || this.isClosed)
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 === null || this.newer === null)
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 !== null);
76
+ return [this.older, this.newer].filter(t => !Object.isNull(t));
75
77
  }
76
78
  rotate(paths, newer) {
77
- const path = this.older === null ? paths.second : this.older.path;
78
- if (this.older !== null) {
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 => [t, t.take()]);
117
- for (const [segment, buffer] of pending)
118
- await this.storeAsync(segment, buffer);
119
- if (this.failure !== null)
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);