lightman-agent 1.0.14 → 1.0.16

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/agent.config.json CHANGED
@@ -5,6 +5,7 @@
5
5
  "logLevel": "debug",
6
6
  "logFile": "agent.log",
7
7
  "identityFile": ".lightman-identity.json",
8
+ "pairingTimeoutSeconds": 900,
8
9
  "kiosk": {
9
10
  "browserPath": "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe",
10
11
  "defaultUrl": "http://localhost:3403/display/a-av03",
@@ -19,4 +20,4 @@
19
20
  "timezone": "Asia/Kolkata",
20
21
  "shutdownWarningSeconds": 60
21
22
  }
22
- }
23
+ }
@@ -5,6 +5,7 @@
5
5
  "logLevel": "info",
6
6
  "logFile": "agent.log",
7
7
  "identityFile": ".lightman-identity.json",
8
+ "pairingTimeoutSeconds": __PAIRING_TIMEOUT_SECONDS__,
8
9
  "localServices": false,
9
10
  "kiosk": {
10
11
  "browserPath": "__BROWSER_PATH__",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lightman-agent",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "description": "LIGHTMAN Agent - System-level daemon for museum display machines",
5
5
  "private": false,
6
6
  "type": "module",
@@ -9,13 +9,14 @@
9
9
  # powershell -ExecutionPolicy Bypass -File install-windows.ps1 -Slug "F-AV01" -Server "http://..." -ShellReplace
10
10
  #Requires -RunAsAdministrator
11
11
 
12
- param(
13
- [Parameter(Mandatory=$true)] [string]$Slug,
14
- [Parameter(Mandatory=$true)] [string]$Server,
15
- [string]$Timezone = "Asia/Kolkata",
16
- [string]$Username = "",
17
- [switch]$ShellReplace = $false
18
- )
12
+ param(
13
+ [Parameter(Mandatory=$true)] [string]$Slug,
14
+ [Parameter(Mandatory=$true)] [string]$Server,
15
+ [string]$Timezone = "Asia/Kolkata",
16
+ [int]$PairingTimeoutSeconds = 900,
17
+ [string]$Username = "",
18
+ [switch]$ShellReplace = $false
19
+ )
19
20
 
20
21
  $ErrorActionPreference = "Stop"
21
22
 
@@ -37,11 +38,12 @@ Write-Host ""
37
38
  Write-Host "=============================================" -ForegroundColor Cyan
38
39
  Write-Host " LIGHTMAN Agent - Complete Windows Installer" -ForegroundColor Cyan
39
40
  Write-Host "=============================================" -ForegroundColor Cyan
40
- Write-Host " Device slug : $Slug"
41
- Write-Host " Server URL : $Server"
42
- Write-Host " Username : $Username"
43
- Write-Host " Mode : $(if ($ShellReplace) { 'Shell Replacement' } else { 'Standard' })"
44
- Write-Host ""
41
+ Write-Host " Device slug : $Slug"
42
+ Write-Host " Server URL : $Server"
43
+ Write-Host " Username : $Username"
44
+ Write-Host " Mode : $(if ($ShellReplace) { 'Shell Replacement' } else { 'Standard' })"
45
+ Write-Host " Pair timeout: $(if ($PairingTimeoutSeconds -eq 0) { 'Disabled' } else { "$PairingTimeoutSeconds s" })"
46
+ Write-Host ""
45
47
 
46
48
  # ============================================================
47
49
  # PHASE 0: NUKE EVERYTHING FROM PREVIOUS INSTALLS
@@ -142,11 +144,11 @@ Pop-Location
142
144
 
143
145
  # --- 6. Generate config ---
144
146
  Write-Host "[6/19] Generating config..." -ForegroundColor Yellow
145
- if ($ShellReplace) {
146
- & "$ScriptDir\setup.ps1" -Slug $Slug -Server $Server -Timezone $Timezone -InstallDir $InstallDir -ShellMode
147
- } else {
148
- & "$ScriptDir\setup.ps1" -Slug $Slug -Server $Server -Timezone $Timezone -InstallDir $InstallDir
149
- }
147
+ if ($ShellReplace) {
148
+ & "$ScriptDir\setup.ps1" -Slug $Slug -Server $Server -Timezone $Timezone -PairingTimeoutSeconds $PairingTimeoutSeconds -InstallDir $InstallDir -ShellMode
149
+ } else {
150
+ & "$ScriptDir\setup.ps1" -Slug $Slug -Server $Server -Timezone $Timezone -PairingTimeoutSeconds $PairingTimeoutSeconds -InstallDir $InstallDir
151
+ }
150
152
 
151
153
  # --- 7. Fix BOM ---
152
154
  Write-Host "[7/19] Fixing config encoding..." -ForegroundColor Yellow
package/scripts/setup.ps1 CHANGED
@@ -15,11 +15,14 @@ param(
15
15
  [Parameter(Mandatory=$true)]
16
16
  [string]$Server,
17
17
 
18
- [Parameter(Mandatory=$false)]
19
- [string]$Timezone = "Asia/Kolkata",
20
-
21
- [Parameter(Mandatory=$false)]
22
- [string]$InstallDir = $null,
18
+ [Parameter(Mandatory=$false)]
19
+ [string]$Timezone = "Asia/Kolkata",
20
+
21
+ [Parameter(Mandatory=$false)]
22
+ [int]$PairingTimeoutSeconds = 900,
23
+
24
+ [Parameter(Mandatory=$false)]
25
+ [string]$InstallDir = $null,
23
26
 
24
27
  [Parameter(Mandatory=$false)]
25
28
  [switch]$ShellMode = $false
@@ -36,11 +39,12 @@ if (-not $InstallDir) {
36
39
 
37
40
  Write-Host ""
38
41
  Write-Host "=== LIGHTMAN Agent - Device Setup ===" -ForegroundColor Cyan
39
- Write-Host " Slug: $Slug"
40
- Write-Host " Server: $Server"
41
- Write-Host " Install dir: $InstallDir"
42
- Write-Host " Timezone: $Timezone"
43
- Write-Host ""
42
+ Write-Host " Slug: $Slug"
43
+ Write-Host " Server: $Server"
44
+ Write-Host " Install dir: $InstallDir"
45
+ Write-Host " Timezone: $Timezone"
46
+ Write-Host " Pair timeout: $(if ($PairingTimeoutSeconds -eq 0) { 'Disabled' } else { "$PairingTimeoutSeconds s" })"
47
+ Write-Host ""
44
48
 
45
49
  # 1. Clear cached identity (CRITICAL - prevents old device credentials leaking)
46
50
  $IdentityFile = Join-Path $InstallDir ".lightman-identity.json"
@@ -83,13 +87,14 @@ $Template = Get-Content $TemplatePath -Raw
83
87
  $BrowserEscaped = $BrowserPath -replace '\\', '\\'
84
88
  $ChromeDirEscaped = $ChromeDataDir -replace '\\', '\\'
85
89
 
86
- $Config = $Template `
87
- -replace '__SERVER_URL__', $Server `
88
- -replace '__DEVICE_SLUG__', $Slug `
89
- -replace '__KIOSK_URL__', $KioskUrl `
90
- -replace '__BROWSER_PATH__', $BrowserEscaped `
91
- -replace '__CHROME_DATA_DIR__', $ChromeDirEscaped `
92
- -replace 'Asia/Kolkata', $Timezone
90
+ $Config = $Template `
91
+ -replace '__SERVER_URL__', $Server `
92
+ -replace '__DEVICE_SLUG__', $Slug `
93
+ -replace '__KIOSK_URL__', $KioskUrl `
94
+ -replace '__BROWSER_PATH__', $BrowserEscaped `
95
+ -replace '__CHROME_DATA_DIR__', $ChromeDirEscaped `
96
+ -replace '__PAIRING_TIMEOUT_SECONDS__', $PairingTimeoutSeconds `
97
+ -replace 'Asia/Kolkata', $Timezone
93
98
 
94
99
  # 6. Inject shellMode into kiosk config if requested
95
100
  if ($ShellMode) {
package/src/lib/config.ts CHANGED
@@ -32,8 +32,9 @@ const configSchema = z.object({
32
32
  healthIntervalMs: z.number().int().min(5000).default(60000),
33
33
  logLevel: z.enum(['debug', 'info', 'warn', 'error']).default('info'),
34
34
  logFile: z.string().default('agent.log'),
35
- identityFile: z.string().default('.lightman-identity.json'),
36
- localServices: z.boolean().default(true),
35
+ identityFile: z.string().default('.lightman-identity.json'),
36
+ pairingTimeoutSeconds: z.number().int().min(0).default(900),
37
+ localServices: z.boolean().default(true),
37
38
  kiosk: kioskSchema.optional(),
38
39
  screenshot: screenshotSchema.optional(),
39
40
  powerSchedule: powerScheduleSchema.optional(),
package/src/lib/types.ts CHANGED
@@ -6,6 +6,7 @@ export interface AgentConfig {
6
6
  logLevel: 'debug' | 'info' | 'warn' | 'error';
7
7
  logFile: string;
8
8
  identityFile: string;
9
+ pairingTimeoutSeconds?: number;
9
10
  /** When false, agent runs in kiosk-only mode — no local server/display processes. Default: true */
10
11
  localServices: boolean;
11
12
  kiosk?: KioskConfig;
@@ -61,10 +61,12 @@ export async function provision(
61
61
  const code = data.code as string;
62
62
  logger.warn(`Pairing required. Enter code in admin UI: ${code}`);
63
63
  logger.info('Waiting for admin to approve pairing...');
64
+ const pairingTimeoutMs = Math.max(0, config.pairingTimeoutSeconds ?? 900) * 1000;
64
65
 
65
66
  const identity = await pollForPairing(
66
67
  `${baseUrl}/status?code=${encodeURIComponent(code)}`,
67
- logger
68
+ logger,
69
+ pairingTimeoutMs
68
70
  );
69
71
 
70
72
  writeIdentity(config.identityFile, identity);
@@ -81,7 +83,7 @@ async function pollForPairing(
81
83
  timeoutMs = 600_000,
82
84
  intervalMs = 5_000
83
85
  ): Promise<Identity> {
84
- const deadline = Date.now() + timeoutMs;
86
+ const deadline = timeoutMs <= 0 ? Number.POSITIVE_INFINITY : Date.now() + timeoutMs;
85
87
 
86
88
  while (Date.now() < deadline) {
87
89
  await sleep(intervalMs);