@tianshu-ai/local-bridge 0.9.1 → 0.9.2
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/dist/settings-window.js +51 -21
- package/dist/settings-window.js.map +1 -1
- package/package.json +1 -1
package/dist/settings-window.js
CHANGED
|
@@ -34,7 +34,10 @@ export function openSettingsWindow(configPath, current) {
|
|
|
34
34
|
// ─── Windows: PowerShell + WinForms ─────────────────────────────────
|
|
35
35
|
function openWindowsForm(configPath, cur) {
|
|
36
36
|
const scriptPath = path.join(os.tmpdir(), `tsbridge-settings-${process.pid}.ps1`);
|
|
37
|
-
|
|
37
|
+
// Diagnostics: the PS script logs here (and we redirect its stdio too),
|
|
38
|
+
// so "clicked Settings, nothing happened" always leaves a trace.
|
|
39
|
+
const settingsLog = path.join(path.dirname(configPath), "settings.log");
|
|
40
|
+
const ps = renderWindowsPs1(configPath, cur, settingsLog);
|
|
38
41
|
try {
|
|
39
42
|
fs.writeFileSync(scriptPath, ps, "utf8");
|
|
40
43
|
}
|
|
@@ -42,18 +45,25 @@ function openWindowsForm(configPath, cur) {
|
|
|
42
45
|
return false;
|
|
43
46
|
}
|
|
44
47
|
try {
|
|
45
|
-
// -STA is required for WinForms
|
|
46
|
-
//
|
|
48
|
+
// -STA is required for WinForms. We do NOT pass -WindowStyle Hidden:
|
|
49
|
+
// it can suppress the form itself, and windowsHide:true on the spawn
|
|
50
|
+
// already keeps the PS console from flashing. The form is shown
|
|
51
|
+
// TopMost + Activated (see the script) so it comes to the front.
|
|
52
|
+
let out = "ignore";
|
|
53
|
+
try {
|
|
54
|
+
out = fs.openSync(settingsLog, "a");
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
out = "ignore";
|
|
58
|
+
}
|
|
47
59
|
const child = spawn("powershell.exe", [
|
|
48
60
|
"-NoProfile",
|
|
49
61
|
"-ExecutionPolicy",
|
|
50
62
|
"Bypass",
|
|
51
63
|
"-STA",
|
|
52
|
-
"-WindowStyle",
|
|
53
|
-
"Hidden",
|
|
54
64
|
"-File",
|
|
55
65
|
scriptPath,
|
|
56
|
-
], { stdio: "ignore", detached: true, windowsHide: true });
|
|
66
|
+
], { stdio: ["ignore", out, out], detached: true, windowsHide: true });
|
|
57
67
|
// Swallow spawn errors (e.g. powershell missing) so they don't crash
|
|
58
68
|
// the tray process; the caller falls back to opening the raw file.
|
|
59
69
|
child.on("error", () => { });
|
|
@@ -68,12 +78,19 @@ function openWindowsForm(configPath, cur) {
|
|
|
68
78
|
function psq(s) {
|
|
69
79
|
return `'${String(s).replace(/'/g, "''")}'`;
|
|
70
80
|
}
|
|
71
|
-
function renderWindowsPs1(configPath, cur) {
|
|
81
|
+
function renderWindowsPs1(configPath, cur, logPathArg) {
|
|
72
82
|
// The script builds a WinForms dialog, prefilled with current values,
|
|
73
|
-
// and on OK writes
|
|
74
|
-
// so we don't clobber unknown keys).
|
|
83
|
+
// and on OK writes the known fields to config.json.
|
|
75
84
|
const cfgPathLit = psq(configPath);
|
|
85
|
+
const logLit = psq(logPathArg);
|
|
86
|
+
// Whole body wrapped in try/catch → any WinForms/assembly error is
|
|
87
|
+
// written to settings.log instead of vanishing silently.
|
|
76
88
|
return `
|
|
89
|
+
$ErrorActionPreference = 'Stop'
|
|
90
|
+
$logPath = ${logLit}
|
|
91
|
+
function Log($m) { try { Add-Content -Path $logPath -Value ("[{0}] {1}" -f (Get-Date -Format o), $m) } catch {} }
|
|
92
|
+
Log 'settings window: starting'
|
|
93
|
+
try {
|
|
77
94
|
Add-Type -AssemblyName System.Windows.Forms
|
|
78
95
|
Add-Type -AssemblyName System.Drawing
|
|
79
96
|
|
|
@@ -86,6 +103,12 @@ $form.StartPosition = 'CenterScreen'
|
|
|
86
103
|
$form.FormBorderStyle = 'FixedDialog'
|
|
87
104
|
$form.MaximizeBox = $false
|
|
88
105
|
$form.MinimizeBox = $false
|
|
106
|
+
# Force the window to the front — a detached PowerShell child doesn't own
|
|
107
|
+
# the foreground, so without this the form can open behind other windows
|
|
108
|
+
# and look like "nothing happened".
|
|
109
|
+
$form.TopMost = $true
|
|
110
|
+
$form.ShowInTaskbar = $true
|
|
111
|
+
$form.Add_Shown({ $form.Activate(); $form.BringToFront() })
|
|
89
112
|
|
|
90
113
|
function New-Label($text, $y) {
|
|
91
114
|
$l = New-Object System.Windows.Forms.Label
|
|
@@ -172,24 +195,31 @@ $cancel.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
|
|
|
172
195
|
$form.Controls.Add($cancel)
|
|
173
196
|
$form.CancelButton = $cancel
|
|
174
197
|
|
|
198
|
+
Log 'settings window: showing dialog'
|
|
175
199
|
$result = $form.ShowDialog()
|
|
176
200
|
if ($result -eq [System.Windows.Forms.DialogResult]::OK) {
|
|
177
|
-
#
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
201
|
+
# Build the config as an ordered dictionary. We deliberately do NOT use
|
|
202
|
+
# ConvertFrom-Json -AsHashtable (that switch is PowerShell 6+; Windows
|
|
203
|
+
# ships 5.1). We just write the known fields — the tray only reads
|
|
204
|
+
# these, so a full round-trip merge isn't needed.
|
|
205
|
+
$cfg = [ordered]@{
|
|
206
|
+
server = $server.Text
|
|
207
|
+
token = $token.Text
|
|
208
|
+
device = $device.Text
|
|
209
|
+
browser = [bool]$browser.Checked
|
|
210
|
+
engine = [string]$engine.SelectedItem
|
|
211
|
+
headless = [bool]$headless.Checked
|
|
212
|
+
shell = [bool]$shell.Checked
|
|
181
213
|
}
|
|
182
|
-
if ($null -eq $cfg) { $cfg = @{} }
|
|
183
|
-
$cfg['server'] = $server.Text
|
|
184
|
-
$cfg['token'] = $token.Text
|
|
185
|
-
$cfg['device'] = $device.Text
|
|
186
|
-
$cfg['browser'] = [bool]$browser.Checked
|
|
187
|
-
$cfg['engine'] = [string]$engine.SelectedItem
|
|
188
|
-
$cfg['headless'] = [bool]$headless.Checked
|
|
189
|
-
$cfg['shell'] = [bool]$shell.Checked
|
|
190
214
|
$dir = Split-Path -Parent $configPath
|
|
191
215
|
if (-not (Test-Path $dir)) { New-Item -ItemType Directory -Path $dir -Force | Out-Null }
|
|
192
216
|
($cfg | ConvertTo-Json -Depth 10) | Set-Content -Path $configPath -Encoding UTF8
|
|
217
|
+
Log 'settings window: saved config'
|
|
218
|
+
} else {
|
|
219
|
+
Log 'settings window: cancelled'
|
|
220
|
+
}
|
|
221
|
+
} catch {
|
|
222
|
+
Log ("settings window ERROR: " + $_.Exception.Message)
|
|
193
223
|
}
|
|
194
224
|
`;
|
|
195
225
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings-window.js","sourceRoot":"","sources":["../src/settings-window.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,qEAAqE;AACrE,gEAAgE;AAChE,kEAAkE;AAClE,EAAE;AACF,wEAAwE;AACxE,yEAAyE;AACzE,uEAAuE;AACvE,oDAAoD;AAEpD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAY7B;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAChC,UAAkB,EAClB,OAAuB;IAEvB,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QACjC,OAAO,eAAe,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IACD,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAClC,OAAO,cAAc,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,KAAK,CAAC,CAAC,uCAAuC;AACvD,CAAC;AAED,uEAAuE;AAEvE,SAAS,eAAe,CAAC,UAAkB,EAAE,GAAmB;IAC9D,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAA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N;QACvN,oGAAoG;QACpG,uFAAuF;KACxF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tianshu-ai/local-bridge",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "Local bridge for tianshu — dial into a tianshu server over WebSocket and expose your machine's tools (browser, files, shell) to the agent via reverse-MCP.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|