@noldova/terminal 0.0.7 → 0.0.9

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 (80) hide show
  1. package/README.md +1 -1
  2. package/module.json +2 -2
  3. package/package.json +10 -8
  4. package/src/exceptions/stored-lines-damaged.exception.js +2 -1
  5. package/src/models/hosted-terminal.js +4 -3
  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 +4 -3
  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-tracker.js +5 -4
  27. package/src/services/completion-source.js +27 -23
  28. package/src/services/context-pty-process.js +3 -2
  29. package/src/services/context-pty-spawner.js +2 -1
  30. package/src/services/deferred-pty-process.js +7 -8
  31. package/src/services/escape-sequence-tracker.js +2 -1
  32. package/src/services/failure-text.js +2 -1
  33. package/src/services/flow-controller.js +5 -4
  34. package/src/services/latest-environment.js +2 -1
  35. package/src/services/mac-environment.js +3 -2
  36. package/src/services/mark-scanner.js +22 -14
  37. package/src/services/one-shot-command.js +3 -2
  38. package/src/services/output-batcher.js +2 -1
  39. package/src/services/output-log.js +4 -1
  40. package/src/services/powershell-binding.js +7 -6
  41. package/src/services/pseudo-terminal.js +2 -1
  42. package/src/services/registry-export.js +3 -2
  43. package/src/services/resize-wakeup.js +2 -1
  44. package/src/services/saved-terminals.js +2 -1
  45. package/src/services/shared-reads.js +3 -2
  46. package/src/services/shell-command.js +14 -15
  47. package/src/services/shell-integration.js +24 -22
  48. package/src/services/shell-locator.js +25 -22
  49. package/src/services/shell-words.js +3 -2
  50. package/src/services/system-requirements.js +9 -9
  51. package/src/services/terminal-audience.js +10 -9
  52. package/src/services/terminal-history-folder.js +5 -4
  53. package/src/services/terminal-history-segment.js +2 -1
  54. package/src/services/terminal-history.js +14 -12
  55. package/src/services/terminal-host.js +106 -103
  56. package/src/services/terminal-line-reader.js +3 -2
  57. package/src/services/terminal-mirror.js +13 -12
  58. package/src/services/terminal-session.js +21 -21
  59. package/src/services/visual-studio.reader.js +3 -2
  60. package/src/services/windows-environment.js +12 -11
  61. package/src/services/windows-folder-access.js +2 -1
  62. package/src/services/wsl-distribution.reader.js +2 -1
  63. package/src/tools/models/agent-terminal-opening.js +2 -1
  64. package/src/tools/models/output-chunk.js +4 -1
  65. package/src/tools/models/output-excerpt.js +12 -6
  66. package/src/tools/models/terminal-open-input.js +3 -2
  67. package/src/tools/models/terminal-output-report.js +5 -4
  68. package/src/tools/models/terminal-run-input.js +2 -1
  69. package/src/tools/models/terminal-target-input.js +2 -1
  70. package/src/tools/models/terminal-write-input.js +2 -1
  71. package/src/tools/models/tool-call-context.js +4 -3
  72. package/src/tools/services/permission-details.js +3 -2
  73. package/src/tools/services/permission-gate.js +2 -1
  74. package/src/tools/services/terminal-access-policy.js +8 -7
  75. package/src/tools/services/terminal-interrupt-tool.js +2 -1
  76. package/src/tools/services/terminal-read-tool.js +3 -2
  77. package/src/tools/services/terminal-run-tool.js +6 -5
  78. package/src/tools/services/terminal-text-escaper.js +2 -1
  79. package/src/tools/services/terminal-tool.js +2 -1
  80. package/src/tools/services/terminal-write-tool.js +2 -1
@@ -5,6 +5,7 @@
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 { randomUUID } from "node:crypto";
9
10
  import { ArgumentException } from "@noldova/context.exceptions";
10
11
  import { EndedBy, Resources as ProtocolResources, TerminalAckParams, TerminalCommandAdded, TerminalCommandEnded, TerminalCompleteParams, TerminalCompletion, TerminalExit, TerminalExited, TerminalFindCommandsParams, TerminalInputParams, TerminalLaunched, TerminalLaunchParams, TerminalLinesParams, TerminalName, TerminalNames, TerminalOpenParams, TerminalOwnerReference, TerminalPaneReference, TerminalReference, TerminalResizeParams, TerminalRestartParams, TerminalRestoreParams, TerminalRunBusy, TerminalRunEnded, TerminalRunEndedBy, TerminalRunOutcome, TerminalRunOutputParams, TerminalRunParams, TerminalRunResult, TerminalSessions, TerminalShellKind, TerminalShells, TerminalShowOwnerParams, TerminalSize, TerminalVisibilityParams, WindowsPty } from "@noldova/terminal.protocol";
@@ -23,6 +24,7 @@ import { HostedTerminal } from "../models/hosted-terminal.js";
23
24
  import { SavedTerminal } from "../models/saved-terminal.js";
24
25
  import { ShellOptionsReply } from "../models/shell-options-reply.js";
25
26
  import { StartedShell } from "../models/started-shell.js";
27
+ import { TerminalFolderKey } from "../models/terminal-folder-key.js";
26
28
  import { TerminalOpening } from "../models/terminal-opening.js";
27
29
  import { WaitingRun } from "../models/waiting-run.js";
28
30
  import { Resources } from "../resources.js";
@@ -95,7 +97,7 @@ export class TerminalHost {
95
97
  return null;
96
98
  case TerminalNames.sessionsMethod:
97
99
  return new TerminalSessions(this.terminals.filter(t => t.isReachedBy(client.connection, client.isApp))
98
- .map(t => t.session.toSummary(t.folder, t.ownerSessionId !== null, t.isPanelTerminal, t.owner, t.opensTab, t.name, t.shell.name))).toJson();
100
+ .map(t => t.session.toSummary(t.folder, !Object.isNull(t.ownerSessionId), t.isPanelTerminal, t.owner, t.opensTab, t.name, t.shell.name))).toJson();
99
101
  case TerminalNames.attachMethod:
100
102
  return (await this.attachAsync(TerminalPaneReference.fromJson(payload), client)).toJson();
101
103
  case TerminalNames.inputMethod:
@@ -137,7 +139,7 @@ export class TerminalHost {
137
139
  case TerminalNames.findCommandsMethod:
138
140
  return (await this.findCommandsAsync(TerminalFindCommandsParams.fromJson(payload), client)).toJson();
139
141
  case TerminalNames.windowStartedMethod:
140
- if (client.window !== null) {
142
+ if (!Object.isNull(client.window)) {
141
143
  this.detachLeftPanes(t => t.connection === client.connection && t.window === client.window && t.page !== client.page);
142
144
  await this.endLaunchesWithoutTabAsync(client.connection, client.window, client.page);
143
145
  }
@@ -192,13 +194,13 @@ export class TerminalHost {
192
194
  return this.spawnFromAsync(await this.readEnvironmentAsync(), file, args, folder, size, environment, false);
193
195
  }
194
196
  async closeOwnerAsync(owner, client) {
195
- const isApp = client === null || client.isApp;
197
+ const isApp = Object.isNull(client) || client.isApp;
196
198
  if (isApp)
197
199
  for (const [agentSessionId, bound] of this.agentSessionOwners)
198
200
  if (bound === owner)
199
201
  this.agentSessionOwners.delete(agentSessionId);
200
202
  const isOwned = (terminal) => terminal.owner === owner
201
- && (client === null || terminal.isReachedBy(client.connection, client.isApp));
203
+ && (Object.isNull(client) || terminal.isReachedBy(client.connection, client.isApp));
202
204
  const closed = Promise.withResolvers();
203
205
  this.closings.set(isOwned, closed);
204
206
  try {
@@ -225,9 +227,9 @@ export class TerminalHost {
225
227
  }
226
228
  async closeConnectionAsync(connection, window) {
227
229
  const wasApp = this.audience.forget(connection, window);
228
- this.detachLeftPanes(t => t.connection === connection && (window === null || t.window === window));
230
+ this.detachLeftPanes(t => t.connection === connection && (Object.isNull(window) || t.window === window));
229
231
  this.startUnshownShells();
230
- if (window !== null) {
232
+ if (!Object.isNull(window)) {
231
233
  await this.endLaunchesWithoutTabAsync(connection, window, null);
232
234
  return;
233
235
  }
@@ -243,15 +245,15 @@ export class TerminalHost {
243
245
  }
244
246
  async closeTerminalAsync(sessionId) {
245
247
  const terminal = this.sessions.get(sessionId);
246
- if (terminal === undefined)
248
+ if (Object.isUndefined(terminal))
247
249
  return;
248
250
  this.sessions.delete(sessionId);
249
251
  terminal.cancelCommand();
250
252
  this.endRun(terminal, TerminalRunEndedBy.TerminalEnded, null);
251
253
  this.saved.forget(sessionId);
252
- if (terminal.owner !== null)
254
+ if (!Object.isNull(terminal.owner))
253
255
  this.audience.publish(this.events.closed, terminal, new TerminalReference(sessionId).toJson());
254
- if ((!await this.stopAsync(terminal.session) || terminal.heldExit !== null) && terminal.environment !== null) {
256
+ if ((!await this.stopAsync(terminal.session) || !Object.isNull(terminal.heldExit)) && !Object.isNull(terminal.environment)) {
255
257
  terminal.isEndSent = true;
256
258
  this.audience.publish(this.events.exited, terminal, new TerminalExited(sessionId, new TerminalExit(null, EndedBy.Close)).toJson());
257
259
  }
@@ -260,8 +262,8 @@ export class TerminalHost {
260
262
  async startTerminalAsync(shellId, folder, size, ownerSessionId, storedLimit, note, isPanelTerminal, owner, client, sessionId, environment, startsAtFit, opensTab, kept) {
261
263
  const shell = await this.locator.findAsync(shellId);
262
264
  this.ensureRunning();
263
- if (shell === undefined)
264
- throw shellId === null ? new DefaultShellNotFoundException() : new ShellNotFoundException(shellId);
265
+ if (Object.isUndefined(shell))
266
+ throw Object.isNull(shellId) ? new DefaultShellNotFoundException() : new ShellNotFoundException(shellId);
265
267
  const isFolder = await this.fileSystem.isFolderAsync(folder);
266
268
  this.ensureRunning();
267
269
  if (!isFolder)
@@ -269,7 +271,7 @@ export class TerminalHost {
269
271
  const historyPaths = await this.historyFolder.pathsAsync(sessionId);
270
272
  this.ensureRunning();
271
273
  const started = await this.startShellAsync(shell, folder, size, note, environment ?? {}, startsAtFit ? sessionId : null);
272
- const isKept = ownerSessionId === null && client?.isApp === true && environment === null;
274
+ const isKept = Object.isNull(ownerSessionId) && client?.isApp === true && Object.isNull(environment);
273
275
  const publish = (channel, payload) => this.audience.publish(channel, terminal, payload);
274
276
  const terminal = new HostedTerminal(new TerminalSession(sessionId, shell.id, size, started.process, started.nonce, this.windowsPty, historyPaths, storedLimit, {
275
277
  onOutput: t => publish(this.events.output, t.toJson()),
@@ -296,7 +298,7 @@ export class TerminalHost {
296
298
  },
297
299
  onPromptStarted: () => {
298
300
  const offset = terminal.launchCommandOffset;
299
- if (offset !== null && terminal.session.text.readRange(offset, terminal.session.text.endOffset).includes(Resources.lineFeed))
301
+ if (!Object.isNull(offset) && terminal.session.text.readRange(offset, terminal.session.text.endOffset).includes(Resources.lineFeed))
300
302
  this.endLaunchCommand(terminal, null);
301
303
  this.countRunEnd(terminal, null, false);
302
304
  },
@@ -304,8 +306,8 @@ export class TerminalHost {
304
306
  onDetached: t => publish(this.events.detached, t.toJson()),
305
307
  onFailed: (id, message) => this.log.write(Resources.formatStartedCommandUnread(id, message)),
306
308
  onResizeUnasked: t => this.log.write(Resources.formatResizeUnasked(t))
307
- }, Resources.maximumAgentTextLength, shell.kind, ownerSessionId === null), shell, folder, ownerSessionId, isPanelTerminal, owner, client?.connection ?? null, environment);
308
- if (kept !== null)
309
+ }, Resources.maximumAgentTextLength, shell.kind, Object.isNull(ownerSessionId)), shell, folder, ownerSessionId, isPanelTerminal, owner, client?.connection ?? null, environment);
310
+ if (!Object.isNull(kept))
309
311
  terminal.keepFolderReports(kept.shellId === shell.id, kept.folder === folder);
310
312
  terminal.deferredShell = started.deferred;
311
313
  terminal.startTemporaryFolder = started.temporaryFolder;
@@ -315,14 +317,14 @@ export class TerminalHost {
315
317
  this.sessions.set(sessionId, terminal);
316
318
  if (isKept)
317
319
  this.saved.save(kept ?? new SavedTerminal(sessionId, shell.id, folder, isPanelTerminal, owner, opensTab));
318
- else if (ownerSessionId !== null && owner !== null)
320
+ else if (!Object.isNull(ownerSessionId) && !Object.isNull(owner))
319
321
  this.audience.publish(this.events.opened, terminal, terminal.session.toSummary(folder, true, isPanelTerminal, owner, true, null, shell.name).toJson());
320
322
  return terminal;
321
323
  }
322
324
  async endLaunchesWithoutTabAsync(connection, window, page) {
323
325
  await Promise.allSettled([...this.launches].filter(([, t]) => t.connection === connection && t.window === window).map(([t]) => t));
324
326
  await Promise.all(this.terminals
325
- .filter(t => t.connection === connection && t.launcher?.window === window && (page === null || t.launcher.page !== page))
327
+ .filter(t => t.connection === connection && t.launcher?.window === window && (Object.isNull(page) || t.launcher.page !== page))
326
328
  .map(t => this.closeTerminalAsync(t.session.sessionId)));
327
329
  }
328
330
  trackLaunchAsync(launching, client) {
@@ -332,7 +334,7 @@ export class TerminalHost {
332
334
  return launching;
333
335
  }
334
336
  async endConnectionAsync(connection, wasApp) {
335
- const isEnding = (terminal) => terminal.connection === null ? wasApp && terminal.owner !== null
337
+ const isEnding = (terminal) => Object.isNull(terminal.connection) ? wasApp && !Object.isNull(terminal.owner)
336
338
  : terminal.connection === connection;
337
339
  const closed = Promise.withResolvers();
338
340
  this.closings.set(isEnding, closed);
@@ -364,7 +366,7 @@ export class TerminalHost {
364
366
  }
365
367
  endForClose(params, client) {
366
368
  const closing = this.findClosing(params, client);
367
- return closing === undefined ? null : new TerminalRunResult(closing.session.sessionId, TerminalRunOutcome.Ended);
369
+ return Object.isUndefined(closing) ? null : new TerminalRunResult(closing.session.sessionId, TerminalRunOutcome.Ended);
368
370
  }
369
371
  findClosing(params, client) {
370
372
  return this.terminals.findLast(t => t.owner === params.owner && t.isReachedBy(client.connection, client.isApp) && this.isClosing(t));
@@ -379,7 +381,7 @@ export class TerminalHost {
379
381
  await Promise.allSettled([...this.opens].filter(([, t]) => isTheirs(t)).map(([t]) => t));
380
382
  }
381
383
  async launchAsync(params, client) {
382
- if (params.folder !== null && !this.isAbsolute(params.folder))
384
+ if (!Object.isNull(params.folder) && !this.isAbsolute(params.folder))
383
385
  throw new ArgumentException(ProtocolResources.formatNotAbsolutePath(ProtocolResources.valueSubject), Resources.folderParameter);
384
386
  const folder = params.folder ?? this.homeFolder;
385
387
  const isFolder = await this.fileSystem.isFolderAsync(folder);
@@ -390,17 +392,17 @@ export class TerminalHost {
390
392
  if (params.shellKinds.length > 0) {
391
393
  const shell = await this.findShellOfKindsAsync(params.shellKinds, params.shellId);
392
394
  this.ensureRunning();
393
- if (shell === undefined)
395
+ if (Object.isUndefined(shell))
394
396
  throw new ShellKindNotFoundException(params.shellKinds);
395
397
  shellId = shell.id;
396
398
  }
397
399
  const terminal = await this.startTerminalAsync(shellId, folder, params.size, null, params.storedLimit, params.notice, false, null, client, randomUUID(), params.environment, false, params.opensTab, null);
398
400
  if (!params.opensTab)
399
401
  terminal.launcher = client;
400
- if (params.command !== null)
402
+ if (!Object.isNull(params.command))
401
403
  void this.typeCommandAsync(terminal, params.command).then(t => {
402
404
  terminal.launchCommandOffset = terminal.session.text.endOffset;
403
- if (t !== TerminalRunOutcome.Typed || !terminal.session.commands.hasMarks || terminal.session.commands.promptEndOffset === null || terminal.keyCount !== 0)
405
+ if (t !== TerminalRunOutcome.Typed || !terminal.session.commands.hasMarks || Object.isNull(terminal.session.commands.promptEndOffset) || terminal.keyCount !== 0)
404
406
  this.endLaunchCommand(terminal, null);
405
407
  }).catch((error) => this.log.write(Resources.formatLaunchCommandFailed(terminal.session.sessionId, FailureText.read(error))));
406
408
  return new TerminalLaunched(terminal.session.sessionId, null);
@@ -419,7 +421,7 @@ export class TerminalHost {
419
421
  this.startShell(terminal);
420
422
  }
421
423
  const startedAt = Date.now();
422
- const isReady = () => session.hasIntegration ? session.commands.promptEndOffset !== null : session.receivedLength > 0;
424
+ const isReady = () => session.hasIntegration ? !Object.isNull(session.commands.promptEndOffset) : session.receivedLength > 0;
423
425
  const isStarted = () => session.hasExited || isReady() || session.commands.isLoaded;
424
426
  if (await session.waitForStartAsync(isStarted, signal) && session.text.endOffset > 0)
425
427
  await session.changes.waitUntilAsync(isStarted, Resources.integrationWaitMilliseconds, signal);
@@ -435,7 +437,7 @@ export class TerminalHost {
435
437
  const isEnded = () => signal.aborted || session.hasExited || this.sessions.get(session.sessionId) !== terminal || this.isClosing(terminal);
436
438
  const isBracketed = isPaste && !isEnded() && await session.isBracketedPasteAsync();
437
439
  const outcome = isEnded() ? TerminalRunOutcome.Ended
438
- : isPaste && ((waitsForFit ? terminal.keyCount !== keyCount : terminal.inputCount !== inputCount) || session.commands.promptEndOffset !== null && session.readPromptLine() !== "") ? TerminalRunOutcome.Input
440
+ : isPaste && ((waitsForFit ? terminal.keyCount !== keyCount : terminal.inputCount !== inputCount) || !Object.isNull(session.commands.promptEndOffset) && session.readPromptLine() !== "") ? TerminalRunOutcome.Input
439
441
  : isPaste && !isBracketed && typed.includes(Resources.tabKey) ? TerminalRunOutcome.Tab
440
442
  : TerminalRunOutcome.Typed;
441
443
  if (outcome === TerminalRunOutcome.Typed) {
@@ -451,7 +453,7 @@ export class TerminalHost {
451
453
  return outcome;
452
454
  }
453
455
  endLaunchCommand(terminal, exitCode) {
454
- if (terminal.launchCommandOffset === null)
456
+ if (Object.isNull(terminal.launchCommandOffset))
455
457
  return;
456
458
  terminal.launchCommandOffset = null;
457
459
  this.audience.publish(this.events.launchCommandEnded, terminal, new TerminalCommandEnded(terminal.session.sessionId, exitCode).toJson());
@@ -473,25 +475,25 @@ export class TerminalHost {
473
475
  async runAfterClosesAsync(params, client) {
474
476
  const place = new TerminalOpening(params.owner, client.connection);
475
477
  for (;;) {
476
- if (params.sessionId === null && this.isClosing(place)) {
478
+ if (Object.isNull(params.sessionId) && this.isClosing(place)) {
477
479
  const closing = this.findClosing(params, client);
478
- if (closing !== undefined)
480
+ if (!Object.isUndefined(closing))
479
481
  return new TerminalRunResult(closing.session.sessionId, TerminalRunOutcome.Ended);
480
482
  if (this.closingConnections.has(client.connection))
481
483
  throw new ConnectionClosingException();
482
484
  await Promise.allSettled([...this.closings].filter(([isTheirs]) => isTheirs(place)).map(([, closed]) => closed.promise));
483
485
  }
484
486
  const result = await this.trackAsync(this.runAsync(params, client), place);
485
- if (result !== null)
487
+ if (!Object.isNull(result))
486
488
  return result;
487
489
  }
488
490
  }
489
491
  async runAsync(params, client) {
490
492
  await Promise.allSettled([this.restoring]);
491
493
  this.ensureRunning();
492
- if (params.sessionId !== null) {
494
+ if (!Object.isNull(params.sessionId)) {
493
495
  const target = this.findRunTarget(params.sessionId, params, client);
494
- return target === null || this.isClosing(target) ? new TerminalRunResult(params.sessionId, TerminalRunOutcome.Ended)
496
+ return Object.isNull(target) || this.isClosing(target) ? new TerminalRunResult(params.sessionId, TerminalRunOutcome.Ended)
495
497
  : this.runIntoAsync(params, target, client);
496
498
  }
497
499
  const place = new TerminalOpening(params.owner, client.connection);
@@ -499,19 +501,19 @@ export class TerminalHost {
499
501
  return this.endForClose(params, client);
500
502
  const isOwned = (t) => t.owner === params.owner && t.isReachedBy(client.connection, client.isApp)
501
503
  && (params.shellKinds.length === 0 || params.shellKinds.includes(t.shell.kind)) && !t.isRunStarting;
502
- const wanted = params.folder === null ? null : await this.toRunFolderKeyAsync(params.folder);
504
+ const wanted = Object.isNull(params.folder) ? null : await this.toRunFolderKeyAsync(params.folder);
503
505
  let inFolder = await this.findInFolderAsync(wanted, isOwned);
504
506
  const newest = this.terminals.findLast(t => isOwned(t) && inFolder?.has(t) !== false && (t.isFree || t.isDrawingPrompt));
505
- if (newest !== undefined && !newest.isFree) {
507
+ if (!Object.isUndefined(newest) && !newest.isFree) {
506
508
  await this.waitForPromptAsync(newest);
507
509
  inFolder = await this.findInFolderAsync(wanted, isOwned);
508
510
  }
509
511
  let terminal = this.terminals.findLast(t => isOwned(t) && inFolder?.has(t) !== false && t.isFree);
510
- const isNew = terminal === undefined;
511
- if (terminal === undefined) {
512
+ const isNew = Object.isUndefined(terminal);
513
+ if (Object.isUndefined(terminal)) {
512
514
  const shell = params.shellKinds.length === 0 ? await this.findFallbackShellAsync(params.shellId)
513
515
  : await this.findShellOfKindsAsync(params.shellKinds, params.shellId);
514
- if (shell === undefined && params.shellKinds.length > 0)
516
+ if (Object.isUndefined(shell) && params.shellKinds.length > 0)
515
517
  return new TerminalRunResult(null, TerminalRunOutcome.NoShell);
516
518
  if (this.isClosing(place))
517
519
  return this.endForClose(params, client);
@@ -540,7 +542,7 @@ export class TerminalHost {
540
542
  }
541
543
  findRunTarget(sessionId, params, client) {
542
544
  const terminal = this.sessions.get(sessionId);
543
- return terminal === undefined || !terminal.isReachedBy(client.connection, client.isApp) || terminal.ownerSessionId !== null
545
+ return Object.isUndefined(terminal) || !terminal.isReachedBy(client.connection, client.isApp) || !Object.isNull(terminal.ownerSessionId)
544
546
  || terminal.owner !== params.owner || params.shellKinds.length > 0 && !params.shellKinds.includes(terminal.shell.kind) ? null : terminal;
545
547
  }
546
548
  async runIntoAsync(params, terminal, client) {
@@ -556,8 +558,8 @@ export class TerminalHost {
556
558
  if (this.sessions.get(session.sessionId) !== terminal)
557
559
  return new TerminalRunResult(session.sessionId, TerminalRunOutcome.Ended);
558
560
  }
559
- if (isBusy() && params.whenBusy === TerminalRunBusy.Interrupt && terminal.pendingCommand === null) {
560
- const isStarted = () => isBusy() && session.commands.runningCommand !== null;
561
+ if (isBusy() && params.whenBusy === TerminalRunBusy.Interrupt && Object.isNull(terminal.pendingCommand)) {
562
+ const isStarted = () => isBusy() && !Object.isNull(session.commands.runningCommand);
561
563
  const signal = terminal.beginInterrupt();
562
564
  const deadline = Date.now() + Resources.runInterruptWaitMilliseconds;
563
565
  await session.changes.waitUntilAsync(() => !isBusy() || isStarted(), Resources.runInterruptWaitMilliseconds, signal);
@@ -577,7 +579,7 @@ export class TerminalHost {
577
579
  }
578
580
  static readWindowsBuild(osRelease) {
579
581
  const build = SystemRequirements.readWindowsBuild(osRelease);
580
- if (build === null)
582
+ if (Object.isNull(build))
581
583
  throw new UnsupportedSystemException(SystemRequirement.WindowsBuild, osRelease);
582
584
  return build;
583
585
  }
@@ -586,8 +588,8 @@ export class TerminalHost {
586
588
  const foreground = await session.readForegroundProcessAsync();
587
589
  if (!isStarted() || signal.aborted)
588
590
  return false;
589
- const isCommand = foreground === null || foreground.group !== session.pid;
590
- if (isCommand && (foreground === null || !foreground.isTerminalProgram))
591
+ const isCommand = Object.isNull(foreground) || foreground.group !== session.pid;
592
+ if (isCommand && (Object.isNull(foreground) || !foreground.isTerminalProgram))
591
593
  return true;
592
594
  if (Date.now() >= deadline)
593
595
  return isCommand;
@@ -603,9 +605,9 @@ export class TerminalHost {
603
605
  terminal.addRun(runId, session.anchorRunAsync());
604
606
  const ended = [];
605
607
  const previous = this.endRun(terminal, TerminalRunEndedBy.Command, terminal.waitingRun?.exitCode ?? null, client);
606
- if (previous !== null)
608
+ if (!Object.isNull(previous))
607
609
  ended.push(previous);
608
- if (session.commands.hasMarks && session.commands.promptEndOffset !== null)
610
+ if (session.commands.hasMarks && !Object.isNull(session.commands.promptEndOffset))
609
611
  terminal.waitingRun = new WaitingRun(runId, client.connection, client.window, terminal.typedEnds, session.text.endOffset, terminal.paste);
610
612
  else
611
613
  ended.push(new TerminalRunEnded(session.sessionId, runId, TerminalRunEndedBy.NoIntegration, null));
@@ -613,12 +615,12 @@ export class TerminalHost {
613
615
  }
614
616
  countRunEnd(terminal, exitCode, isEndMark) {
615
617
  const run = terminal.waitingRun;
616
- if (run === null)
618
+ if (Object.isNull(run))
617
619
  return;
618
620
  const text = terminal.session.text;
619
621
  const output = text.readRange(run.offset, text.endOffset);
620
622
  const echoEnd = run.paste.length === 0 ? 0 : TerminalHost.findEchoEnd(output, run.paste);
621
- if (!isEndMark && (run.isAfterEndMark || echoEnd === null || !output.slice(echoEnd).includes(Resources.lineFeed))) {
623
+ if (!isEndMark && (run.isAfterEndMark || Object.isNull(echoEnd) || !output.slice(echoEnd).includes(Resources.lineFeed))) {
622
624
  run.isAfterEndMark = false;
623
625
  return;
624
626
  }
@@ -632,32 +634,33 @@ export class TerminalHost {
632
634
  }
633
635
  endRun(terminal, endedBy, exitCode, answered = null) {
634
636
  const run = terminal.waitingRun;
635
- if (run === null)
637
+ if (Object.isNull(run))
636
638
  return null;
637
639
  terminal.waitingRun = null;
638
640
  const ended = new TerminalRunEnded(terminal.session.sessionId, run.runId, endedBy, endedBy === TerminalRunEndedBy.Command ? exitCode : null);
639
- if (answered !== null && answered.connection === run.connection && answered.window === run.window)
641
+ if (!Object.isNull(answered) && answered.connection === run.connection && answered.window === run.window)
640
642
  return ended;
641
643
  this.events.runEnded.publishTo(run.connection, run.window, ended.toJson());
642
644
  return null;
643
645
  }
644
646
  async readRunOutputAsync(params, client) {
645
647
  const terminal = this.sessions.get(params.sessionId);
646
- const runs = terminal === undefined ? [] : [...terminal.runs];
647
- const index = runs.findIndex(([runId]) => runId === params.runId);
648
- const run = runs[index];
649
- if (terminal === undefined || run === undefined || !client.isApp || !terminal.isReachedBy(client.connection, true) || terminal.ownerSessionId !== null
648
+ const runIds = Object.isUndefined(terminal) ? [] : [...terminal.runs.keys()];
649
+ const index = runIds.indexOf(params.runId);
650
+ const run = terminal?.runs.get(params.runId);
651
+ if (Object.isUndefined(terminal) || Object.isUndefined(run) || !client.isApp || !terminal.isReachedBy(client.connection, true) || !Object.isNull(terminal.ownerSessionId)
650
652
  || terminal.session.hasExited || terminal.isRestarting)
651
653
  return null;
652
- const next = runs[index + 1];
653
- return terminal.session.readRunLinesAsync(await run[1], next === undefined ? null : await next[1], params.maximumLines);
654
+ const nextId = runIds[index + 1];
655
+ const next = Object.isUndefined(nextId) ? undefined : terminal.runs.get(nextId);
656
+ return terminal.session.readRunLinesAsync(await run, Object.isUndefined(next) ? null : await next, params.maximumLines);
654
657
  }
655
658
  async findFallbackShellAsync(shellId) {
656
- return (shellId === null ? undefined : await this.locator.findAsync(shellId)) ?? await this.locator.findAsync(null);
659
+ return (Object.isNull(shellId) ? undefined : await this.locator.findAsync(shellId)) ?? await this.locator.findAsync(null);
657
660
  }
658
661
  async findShellOfKindsAsync(kinds, shellId) {
659
662
  const fallback = await this.findFallbackShellAsync(shellId);
660
- return fallback !== undefined && kinds.includes(fallback.kind) ? fallback : await this.locator.findKindAsync(kinds);
663
+ return !Object.isUndefined(fallback) && kinds.includes(fallback.kind) ? fallback : await this.locator.findKindAsync(kinds);
661
664
  }
662
665
  openAsync(params, client) {
663
666
  return this.trackAsync(this.openRequestedAsync(params, client), new TerminalOpening(params.owner, client.connection));
@@ -667,10 +670,10 @@ export class TerminalHost {
667
670
  return this.openForPersonAsync(params, client);
668
671
  await Promise.allSettled([this.restoring]);
669
672
  const panel = this.terminals.findLast(t => t.isPanelTerminal && t.isReachedBy(client.connection, client.isApp));
670
- if (panel !== undefined)
673
+ if (!Object.isUndefined(panel))
671
674
  return new TerminalReference(panel.session.sessionId);
672
675
  let opening = this.panelOpenings.get(client.connection);
673
- if (opening === undefined) {
676
+ if (Object.isUndefined(opening)) {
674
677
  opening = this.openForPersonAsync(params, client).finally(() => {
675
678
  this.panelOpenings.delete(client.connection);
676
679
  });
@@ -682,13 +685,13 @@ export class TerminalHost {
682
685
  return new TerminalReference((await this.startForPersonAsync(params, client)).session.sessionId);
683
686
  }
684
687
  async startForPersonAsync(params, client, startsAtFit = false, opensTab = true) {
685
- if (params.folder !== null && !this.isAbsolute(params.folder))
688
+ if (!Object.isNull(params.folder) && !this.isAbsolute(params.folder))
686
689
  throw new ArgumentException(ProtocolResources.formatNotAbsolutePath(ProtocolResources.valueSubject), Resources.folderParameter);
687
- const missing = params.folder !== null && !(await this.fileSystem.isFolderAsync(params.folder)) ? params.folder : null;
690
+ const missing = !Object.isNull(params.folder) && !(await this.fileSystem.isFolderAsync(params.folder)) ? params.folder : null;
688
691
  this.ensureRunning();
689
- const folder = params.folder === null || missing !== null ? this.homeFolder : params.folder;
690
- const terminal = await this.openTerminalAsync(params.shellId, folder, params.size, null, params.storedLimit, missing === null ? null : Resources.formatStartFolderNote(missing), params.isPanelTerminal, params.owner, client, randomUUID(), null, startsAtFit, opensTab);
691
- if (missing !== null)
692
+ const folder = Object.isNull(params.folder) || !Object.isNull(missing) ? this.homeFolder : params.folder;
693
+ const terminal = await this.openTerminalAsync(params.shellId, folder, params.size, null, params.storedLimit, Object.isNull(missing) ? null : Resources.formatStartFolderNote(missing), params.isPanelTerminal, params.owner, client, randomUUID(), null, startsAtFit, opensTab);
694
+ if (!Object.isNull(missing))
692
695
  this.log.write(Resources.formatStartFolderMissing(terminal.session.sessionId, missing, this.homeFolder));
693
696
  return terminal;
694
697
  }
@@ -726,7 +729,7 @@ export class TerminalHost {
726
729
  await Promise.all(restoring.map(t => this.restoreOrForgetAsync(t, params, client)));
727
730
  for (const terminal of restoring) {
728
731
  const hosted = this.sessions.get(terminal.sessionId);
729
- if (hosted !== undefined) {
732
+ if (!Object.isUndefined(hosted)) {
730
733
  this.sessions.delete(terminal.sessionId);
731
734
  this.sessions.set(terminal.sessionId, hosted);
732
735
  }
@@ -743,8 +746,8 @@ export class TerminalHost {
743
746
  }
744
747
  }
745
748
  async restoreTerminalAsync(saved, params, client) {
746
- const hasShell = await this.locator.findAsync(saved.shellId) !== undefined;
747
- const fallback = params.shellId !== null && await this.locator.findAsync(params.shellId) !== undefined ? params.shellId : null;
749
+ const hasShell = !Object.isUndefined(await this.locator.findAsync(saved.shellId));
750
+ const fallback = !Object.isNull(params.shellId) && !Object.isUndefined(await this.locator.findAsync(params.shellId)) ? params.shellId : null;
748
751
  const hasFolder = this.isAbsolute(saved.folder) && await this.fileSystem.isFolderAsync(saved.folder);
749
752
  this.ensureRunning();
750
753
  const note = hasShell
@@ -752,56 +755,56 @@ export class TerminalHost {
752
755
  : hasFolder ? Resources.formatRestoredShellNote(saved.shellId) : Resources.formatRestoredShellAndFolderNote(saved.shellId, saved.folder);
753
756
  const terminal = await this.openTerminalAsync(hasShell ? saved.shellId : fallback, hasFolder ? saved.folder : this.homeFolder, params.size, null, params.storedLimit, note, saved.isPanelTerminal, saved.owner, client, saved.sessionId, null, false, saved.opensTab, saved);
754
757
  const name = saved.name;
755
- terminal.name = name !== null && name.trim() !== "" && name.length <= ProtocolResources.maximumTitleLength ? name : null;
758
+ terminal.name = !Object.isNull(name) && name.trim() !== "" && name.length <= ProtocolResources.maximumTitleLength ? name : null;
756
759
  if (!hasShell)
757
760
  this.log.write(Resources.formatRestoredShellMissing(saved.sessionId, saved.shellId));
758
761
  if (!hasFolder)
759
762
  this.log.write(Resources.formatStartFolderMissing(saved.sessionId, saved.folder, this.homeFolder));
760
763
  }
761
764
  toVariableKey(name) {
762
- return this.windowsPty === null ? name : name.toUpperCase();
765
+ return Object.isNull(this.windowsPty) ? name : name.toUpperCase();
763
766
  }
764
767
  isAbsolute(folder) {
765
- return this.windowsPty === null ? folder.startsWith(Resources.posixRoot) : Resources.windowsAbsolutePath.test(folder);
768
+ return Object.isNull(this.windowsPty) ? folder.startsWith(Resources.posixRoot) : Resources.windowsAbsolutePath.test(folder);
766
769
  }
767
770
  async findInFolderAsync(wanted, isOwned) {
768
- if (wanted === null)
771
+ if (Object.isNull(wanted))
769
772
  return null;
770
- const matched = [];
773
+ const matched = new Map();
771
774
  await Promise.all(this.terminals.filter(isOwned).map(async (t) => {
772
775
  const known = await this.toTerminalFolderKeyAsync(t);
773
- if (known !== null && known[1] === wanted)
774
- matched.push([t, known[0]]);
776
+ if (!Object.isNull(known) && known.key === wanted)
777
+ matched.set(t, known.folder);
775
778
  }));
776
- return new Set(matched.filter(([t, folder]) => folder === this.currentFolderOf(t)).map(([t]) => t));
779
+ return new Set([...matched.keys()].filter(t => matched.get(t) === this.currentFolderOf(t)));
777
780
  }
778
781
  async toRunFolderKeyAsync(folder) {
779
782
  const real = await this.readRealFolderAsync(folder);
780
- if (real !== null || await this.readBoundedAsync(() => this.fileSystem.isFolderAsync(folder)) !== false)
783
+ if (!Object.isNull(real) || await this.readBoundedAsync(() => this.fileSystem.isFolderAsync(folder)) !== false)
781
784
  return this.toFolderKey(real ?? folder);
782
785
  return this.toFolderKey(await this.readRealFolderAsync(this.homeFolder) ?? this.homeFolder);
783
786
  }
784
787
  async toTerminalFolderKeyAsync(terminal) {
785
788
  const folder = this.currentFolderOf(terminal);
786
- if (folder === null)
789
+ if (Object.isNull(folder))
787
790
  return null;
788
791
  const known = this.folderKeys.get(terminal);
789
- if (known !== undefined && known[0] === folder)
792
+ if (!Object.isUndefined(known) && known.folder === folder)
790
793
  return known;
791
794
  const reading = this.joinRealFolderRead(folder);
792
795
  void reading.then(real => {
793
796
  if (this.currentFolderOf(terminal) === folder)
794
- this.folderKeys.set(terminal, [folder, this.toFolderKey(real ?? folder)]);
797
+ this.folderKeys.set(terminal, new TerminalFolderKey(folder, this.toFolderKey(real ?? folder)));
795
798
  }, () => undefined);
796
799
  const real = await this.readBoundedAsync(() => reading);
797
- return [folder, this.toFolderKey(real ?? folder)];
800
+ return new TerminalFolderKey(folder, this.toFolderKey(real ?? folder));
798
801
  }
799
802
  currentFolderOf(terminal) {
800
803
  const cwd = terminal.session.cwd;
801
- if (cwd === null)
804
+ if (Object.isNull(cwd))
802
805
  return terminal.folder;
803
806
  const local = this.completions.toLocalFolder(cwd, terminal.shell.kind, this.readCompletionEnvironment(terminal));
804
- if (local === null)
807
+ if (Object.isNull(local))
805
808
  return null;
806
809
  return this.isAbsolute(local) ? local : terminal.folder;
807
810
  }
@@ -810,7 +813,7 @@ export class TerminalHost {
810
813
  }
811
814
  joinRealFolderRead(folder) {
812
815
  const running = this.realFolderReads.get(folder);
813
- if (running !== undefined)
816
+ if (!Object.isUndefined(running))
814
817
  return running;
815
818
  const reading = this.fileSystem.readRealPathOrNullAsync(folder).finally(() => this.realFolderReads.delete(folder));
816
819
  this.realFolderReads.set(folder, reading);
@@ -828,7 +831,7 @@ export class TerminalHost {
828
831
  }
829
832
  toFolderKey(folder) {
830
833
  const trimmed = folder.replace(Resources.trailingFolderSeparators, "");
831
- return this.windowsPty === null ? trimmed : trimmed.replaceAll(Resources.posixRoot, Resources.windowsSeparator).toLowerCase();
834
+ return Object.isNull(this.windowsPty) ? trimmed : trimmed.replaceAll(Resources.posixRoot, Resources.windowsSeparator).toLowerCase();
832
835
  }
833
836
  async closeAsync(sessionId, client) {
834
837
  this.find(sessionId, client);
@@ -846,11 +849,11 @@ export class TerminalHost {
846
849
  ? Resources.optionsKeys.get(terminal.shell.kind) : undefined;
847
850
  const [completion, reply] = await Promise.all([
848
851
  this.completions.completeAsync(params.sessionId, terminal.shell.kind, params.line, params.cursor, terminal.session.cwd ?? terminal.folder, this.readCompletionEnvironment(terminal), terminal.session.shellNames, terminal.session.shellBuiltins),
849
- keys === undefined ? Promise.resolve(ShellOptionsReply.none) : terminal.session.askOptionsAsync(keys)
852
+ Object.isUndefined(keys) ? Promise.resolve(ShellOptionsReply.none) : terminal.session.askOptionsAsync(keys)
850
853
  ]);
851
854
  if (reply.isTimedOut)
852
855
  return new TerminalCompletion(params.cursor, [], true);
853
- return reply.options === null ? completion
856
+ return Object.isNull(reply.options) ? completion
854
857
  : this.completions.addOptions(completion, terminal.shell.kind, params.line, params.cursor, reply.options);
855
858
  }
856
859
  async findCommandsAsync(params, client) {
@@ -864,12 +867,12 @@ export class TerminalHost {
864
867
  }
865
868
  readCompletionEnvironment(terminal) {
866
869
  const replaced = {};
867
- if (terminal.session.shellPath !== null)
870
+ if (!Object.isNull(terminal.session.shellPath))
868
871
  replaced[Resources.pathVariable] = terminal.session.shellPath;
869
- if (terminal.session.shellModulePath !== null)
872
+ if (!Object.isNull(terminal.session.shellModulePath))
870
873
  replaced[Resources.modulePathVariable] = terminal.session.shellModulePath;
871
874
  const temporaryFolder = terminal.session.shellTemporaryFolder ?? terminal.startTemporaryFolder;
872
- if (temporaryFolder !== null)
875
+ if (!Object.isNull(temporaryFolder))
873
876
  replaced[Resources.temporaryFolderVariable] = temporaryFolder;
874
877
  const keys = new Set(Object.keys(replaced).map(t => this.toVariableKey(t)));
875
878
  return this.withVariables(TerminalHost.toTerminalEnvironment(this.environment.read()), {
@@ -880,7 +883,7 @@ export class TerminalHost {
880
883
  async restartAsync(params, client) {
881
884
  const sessionId = params.sessionId;
882
885
  const terminal = this.findHosted(sessionId, client);
883
- if (terminal.ownerSessionId !== null)
886
+ if (!Object.isNull(terminal.ownerSessionId))
884
887
  throw new AgentTerminalRestartException(sessionId);
885
888
  const restart = terminal.restarts.then(() => this.restartNowAsync(sessionId, terminal, params.size));
886
889
  terminal.restarts = restart.then(() => undefined, () => undefined);
@@ -917,7 +920,7 @@ export class TerminalHost {
917
920
  sendHeldExit(sessionId, terminal) {
918
921
  const exited = terminal.heldExit;
919
922
  terminal.heldExit = null;
920
- if (exited === null || this.sessions.get(sessionId) !== terminal)
923
+ if (Object.isNull(exited) || this.sessions.get(sessionId) !== terminal)
921
924
  return;
922
925
  this.audience.publish(this.events.exited, terminal, exited.toJson());
923
926
  this.forgetOldestExited();
@@ -943,13 +946,13 @@ export class TerminalHost {
943
946
  return;
944
947
  this.commandHistory.add(shellId, command);
945
948
  for (const terminal of this.sessions.values())
946
- if (terminal.shell.id === shellId && terminal.ownerSessionId === null)
949
+ if (terminal.shell.id === shellId && Object.isNull(terminal.ownerSessionId))
947
950
  this.audience.publish(this.events.commandAdded, terminal, new TerminalCommandAdded(terminal.session.sessionId, command).toJson());
948
951
  }
949
952
  async attachAsync(reference, client) {
950
953
  const terminal = this.findHosted(reference.sessionId, client);
951
954
  terminal.paneClients.set(reference.paneId, client);
952
- const attachment = await terminal.session.attachAsync(reference.paneId, terminal.ownerSessionId === null && this.isSuggesting()
955
+ const attachment = await terminal.session.attachAsync(reference.paneId, Object.isNull(terminal.ownerSessionId) && this.isSuggesting()
953
956
  ? this.commandHistory.list(terminal.shell.id) : []);
954
957
  if (!terminal.paneClients.has(reference.paneId))
955
958
  terminal.session.detach(reference.paneId);
@@ -968,8 +971,8 @@ export class TerminalHost {
968
971
  }
969
972
  resize(params, client) {
970
973
  const terminal = this.findHosted(params.sessionId, client);
971
- if (!terminal.session.resize(params.size))
972
- terminal.deferredShell?.start();
974
+ terminal.session.resize(params.size);
975
+ terminal.deferredShell?.start();
973
976
  terminal.isSized = true;
974
977
  terminal.session.changes.notify();
975
978
  }
@@ -983,7 +986,7 @@ export class TerminalHost {
983
986
  const terminal = this.reachable(reference.sessionId, client);
984
987
  terminal?.paneClients.delete(reference.paneId);
985
988
  terminal?.session.detach(reference.paneId);
986
- if (terminal !== null && !terminal.isSized)
989
+ if (!Object.isNull(terminal) && !terminal.isSized)
987
990
  this.startShell(terminal);
988
991
  }
989
992
  detachLeftPanes(isLeft) {
@@ -1005,11 +1008,11 @@ export class TerminalHost {
1005
1008
  if (terminal.isSized)
1006
1009
  return;
1007
1010
  const fitWindow = terminal.fitWindow;
1008
- if (fitWindow === null ? !terminal.opensTab || !this.audience.shows(terminal) : !this.audience.isOpen(fitWindow) || this.audience.isHidden(fitWindow))
1011
+ if (Object.isNull(fitWindow) ? !terminal.opensTab || !this.audience.shows(terminal) : !this.audience.isOpen(fitWindow) || this.audience.isHidden(fitWindow))
1009
1012
  this.startShell(terminal);
1010
1013
  }
1011
1014
  startShell(terminal) {
1012
- if (terminal.deferredShell === null || terminal.deferredShell.hasStarted)
1015
+ if (Object.isNull(terminal.deferredShell) || terminal.deferredShell.hasStarted)
1013
1016
  return;
1014
1017
  terminal.deferredShell.start();
1015
1018
  terminal.session.changes.notify();
@@ -1019,13 +1022,13 @@ export class TerminalHost {
1019
1022
  }
1020
1023
  findHosted(sessionId, client) {
1021
1024
  const terminal = this.reachable(sessionId, client);
1022
- if (terminal === null)
1025
+ if (Object.isNull(terminal))
1023
1026
  throw new SessionNotFoundException(sessionId);
1024
1027
  return terminal;
1025
1028
  }
1026
1029
  reachable(sessionId, client) {
1027
1030
  const terminal = this.sessions.get(sessionId);
1028
- return terminal === undefined || !terminal.isReachedBy(client.connection, client.isApp) ? null : terminal;
1031
+ return Object.isUndefined(terminal) || !terminal.isReachedBy(client.connection, client.isApp) ? null : terminal;
1029
1032
  }
1030
1033
  async endAsync(session) {
1031
1034
  await this.stopAsync(session);
@@ -1056,15 +1059,15 @@ export class TerminalHost {
1056
1059
  }
1057
1060
  async startShellAsync(shell, folder, size, note, variables, deferredSessionId = null) {
1058
1061
  const environment = this.withVariables(await this.readEnvironmentAsync(), variables);
1059
- const printedNote = note === null || this.windowsPty === null ? null
1062
+ const printedNote = Object.isNull(note) || Object.isNull(this.windowsPty) ? null
1060
1063
  : note.split(Resources.lineBreaks).map(t => TerminalSession.toNote(t)).join("");
1061
1064
  const launch = await this.integration.prepareAsync(shell, randomUUID().replaceAll(Resources.terminalHostUuidSeparator, ""), environment, printedNote);
1062
- const inheritsCursor = note !== null && !launch.printsNote;
1065
+ const inheritsCursor = !Object.isNull(note) && !launch.printsNote;
1063
1066
  let process;
1064
1067
  let deferred = null;
1065
1068
  try {
1066
1069
  this.ensureRunning();
1067
- if (deferredSessionId === null)
1070
+ if (Object.isNull(deferredSessionId))
1068
1071
  process = await this.spawnFromAsync(environment, launch.file, launch.args, folder, size, launch.environment, inheritsCursor);
1069
1072
  else {
1070
1073
  deferred = new DeferredPtyProcess(async (columns, rows) => {
@@ -1102,7 +1105,7 @@ export class TerminalHost {
1102
1105
  static toTerminalEnvironment(environment) {
1103
1106
  const terminalEnvironment = {};
1104
1107
  for (const [name, value] of Object.entries(environment)) {
1105
- if (value !== undefined && !Resources.hostVariables.includes(name.toUpperCase()))
1108
+ if (!Object.isUndefined(value) && !Resources.hostVariables.includes(name.toUpperCase()))
1106
1109
  terminalEnvironment[name] = value;
1107
1110
  }
1108
1111
  terminalEnvironment[Resources.termVariable] = Resources.terminalName;