@songsid/agend 2.3.5-alpha.13 → 2.3.5-alpha.14
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/agent-export.d.ts +74 -0
- package/dist/agent-export.js +362 -0
- package/dist/agent-export.js.map +1 -0
- package/dist/build-provenance.json +1 -1
- package/dist/cli.js +27 -12
- package/dist/cli.js.map +1 -1
- package/dist/fleet-manager.d.ts +7 -0
- package/dist/fleet-manager.js +20 -1
- package/dist/fleet-manager.js.map +1 -1
- package/dist/hub/join/local.d.ts +1 -0
- package/dist/hub/join/local.js +8 -3
- package/dist/hub/join/local.js.map +1 -1
- package/dist/install-user-systemd.d.ts +20 -0
- package/dist/install-user-systemd.js +55 -0
- package/dist/install-user-systemd.js.map +1 -0
- package/dist/linux-launchers.d.ts +88 -0
- package/dist/linux-launchers.js +296 -0
- package/dist/linux-launchers.js.map +1 -0
- package/dist/locale.js +85 -2
- package/dist/locale.js.map +1 -1
- package/dist/service-installer.js +11 -2
- package/dist/service-installer.js.map +1 -1
- package/dist/ui/agent-export-dialog.js +169 -0
- package/dist/ui/agent-export-strings.js +81 -0
- package/dist/ui/settings-dialogs.js +3 -1
- package/dist/update-dispatch.d.ts +12 -0
- package/dist/update-dispatch.js +11 -0
- package/dist/update-dispatch.js.map +1 -1
- package/dist/web-api.d.ts +2 -0
- package/dist/web-api.js +49 -0
- package/dist/web-api.js.map +1 -1
- package/dist/windows-shortcuts.d.ts +29 -5
- package/dist/windows-shortcuts.js +52 -9
- package/dist/windows-shortcuts.js.map +1 -1
- package/launcher/agend-install.cjs +7 -1
- package/package.json +1 -1
- package/templates/icons/agend-restart.ico +0 -0
- package/templates/icons/agend.ico +0 -0
- package/templates/windows-shortcuts.ps1 +45 -12
|
@@ -26,6 +26,13 @@ export declare function interopState(host: ShortcutsHost): "on" | "off" | "unkno
|
|
|
26
26
|
export declare function findPowershell(host: ShortcutsHost): string | null;
|
|
27
27
|
/** The installer's shortcut code: the template below its header (which ends at the first blank line). */
|
|
28
28
|
export declare function sharedShortcutsPs(templateText?: string): string;
|
|
29
|
+
/** M-2885: the shortcut icons this package ships (templates/icons, built by scripts/build-shortcut-icons.py). */
|
|
30
|
+
export declare const SHORTCUT_ICON_NAMES: readonly ["agend.ico", "agend-restart.ico"];
|
|
31
|
+
export type ShortcutIcons = Partial<Record<(typeof SHORTCUT_ICON_NAMES)[number], Buffer>>;
|
|
32
|
+
/** The icons as the package has them; one that can't be read is left out (that shortcut keeps whatever icon it has). */
|
|
33
|
+
export declare function packageShortcutIcons(dir?: string): ShortcutIcons;
|
|
34
|
+
/** `$icons` for Install-AgendShortcuts: base64 literals only (no quoting needed), or `$null` when there are none. */
|
|
35
|
+
export declare function iconsLiteral(icons?: ShortcutIcons): string;
|
|
29
36
|
/** The target install.json named when the person was asked (and said yes to replacing). */
|
|
30
37
|
export interface ShortcutsTarget {
|
|
31
38
|
distro: string;
|
|
@@ -37,10 +44,21 @@ export interface ShortcutsTarget {
|
|
|
37
44
|
* without asking, the leader 2026-10-20) — unless it is exactly the one the person was shown and said yes to
|
|
38
45
|
* (`confirmedOver`), read again right before writing: changed while they answered, it stops again (#2279 review).
|
|
39
46
|
*/
|
|
40
|
-
export declare function buildShortcutsScript(shared: string, distro: string, user: string, confirmedOver?: ShortcutsTarget): string;
|
|
47
|
+
export declare function buildShortcutsScript(shared: string, distro: string, user: string, confirmedOver?: ShortcutsTarget, icons?: ShortcutIcons): string;
|
|
41
48
|
/** -EncodedCommand takes UTF-16LE in base64: no quoting, and the Chinese names arrive intact. */
|
|
42
49
|
export declare function encodePowershell(script: string): string;
|
|
43
|
-
|
|
50
|
+
/**
|
|
51
|
+
* M-2885: what -EncodedCommand carries — only this loader. The script itself (the shared code, then the icons) arrives on
|
|
52
|
+
* standard input, read WHOLE and run at the top level as ONE script block (never line by line). Windows' command line
|
|
53
|
+
* holds 32,767 characters; the script with its icons is far longer.
|
|
54
|
+
* Standard input carries base64 of the script's UTF-8 bytes — ASCII only, which no console code page can alter, whatever
|
|
55
|
+
* Windows PowerShell 5.1 does with redirected input. (The "AgEnD ???" first seen on a real Windows was not this: it was
|
|
56
|
+
* WScript.Shell saving through the ANSI code page — see New-AgendShortcut.)
|
|
57
|
+
*/
|
|
58
|
+
export declare const STDIN_LOADER = "$ErrorActionPreference = 'Stop'; $r = New-Object IO.StreamReader([Console]::OpenStandardInput(), [Text.Encoding]::ASCII); $b = $r.ReadToEnd(); $r.Dispose(); $s = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($b.Trim())); . ([ScriptBlock]::Create($s))";
|
|
59
|
+
/** What goes on the loader's standard input: the script, as base64 of its UTF-8 bytes (see STDIN_LOADER). */
|
|
60
|
+
export declare function stdinPayload(script: string): string;
|
|
61
|
+
export declare function powershellArgs(): string[];
|
|
44
62
|
export interface RunResult {
|
|
45
63
|
status: number | null;
|
|
46
64
|
stdout: string;
|
|
@@ -52,7 +70,10 @@ export interface ShortcutsDeps {
|
|
|
52
70
|
user: string;
|
|
53
71
|
dataDir: string;
|
|
54
72
|
shared: () => string;
|
|
55
|
-
|
|
73
|
+
/** `input`: written to the program's standard input (the script as stdinPayload gives it, M-2885). */
|
|
74
|
+
run: (command: string, args: string[], input: string) => RunResult;
|
|
75
|
+
/** The icons to put on the shortcuts (M-2885). */
|
|
76
|
+
icons?: () => ShortcutIcons;
|
|
56
77
|
writeMarker: (path: string, content: string) => void;
|
|
57
78
|
log: (line: string) => void;
|
|
58
79
|
now: () => Date;
|
|
@@ -74,5 +95,8 @@ export declare function shortcutsHintOnce(o: {
|
|
|
74
95
|
tty: boolean;
|
|
75
96
|
write: (path: string, content: string) => void;
|
|
76
97
|
}): string | null;
|
|
77
|
-
/**
|
|
78
|
-
|
|
98
|
+
/**
|
|
99
|
+
* After an install or `agend update`: print the one-time line, if it is due — the Windows shortcuts in WSL (#1853), the
|
|
100
|
+
* launchers on a Linux desktop (M-2885).
|
|
101
|
+
*/
|
|
102
|
+
export declare function printUpdateShortcutsHint(dataDir: string): Promise<void>;
|
|
@@ -69,13 +69,31 @@ export function sharedShortcutsPs(templateText) {
|
|
|
69
69
|
return text.slice(text.indexOf("\n\n") + 2);
|
|
70
70
|
}
|
|
71
71
|
const psQuote = (value) => `'${value.replace(/'/g, "''")}'`;
|
|
72
|
+
/** M-2885: the shortcut icons this package ships (templates/icons, built by scripts/build-shortcut-icons.py). */
|
|
73
|
+
export const SHORTCUT_ICON_NAMES = ["agend.ico", "agend-restart.ico"];
|
|
74
|
+
/** The icons as the package has them; one that can't be read is left out (that shortcut keeps whatever icon it has). */
|
|
75
|
+
export function packageShortcutIcons(dir = join(dirname(fileURLToPath(import.meta.url)), "..", "templates", "icons")) {
|
|
76
|
+
const icons = {};
|
|
77
|
+
for (const name of SHORTCUT_ICON_NAMES) {
|
|
78
|
+
try {
|
|
79
|
+
icons[name] = readFileSync(join(dir, name));
|
|
80
|
+
}
|
|
81
|
+
catch { /* left out */ }
|
|
82
|
+
}
|
|
83
|
+
return icons;
|
|
84
|
+
}
|
|
85
|
+
/** `$icons` for Install-AgendShortcuts: base64 literals only (no quoting needed), or `$null` when there are none. */
|
|
86
|
+
export function iconsLiteral(icons = {}) {
|
|
87
|
+
const entries = SHORTCUT_ICON_NAMES.filter(name => icons[name]?.length).map(name => `'${name}' = [Convert]::FromBase64String('${icons[name].toString("base64")}')`);
|
|
88
|
+
return entries.length ? `@{ ${entries.join("; ")} }` : "$null";
|
|
89
|
+
}
|
|
72
90
|
/**
|
|
73
91
|
* The whole script Windows PowerShell runs: the shared code, then both shortcuts for this Linux and user. An
|
|
74
92
|
* install.json that names another Linux or user stops it first, changing nothing (the shortcuts are never repointed
|
|
75
93
|
* without asking, the leader 2026-10-20) — unless it is exactly the one the person was shown and said yes to
|
|
76
94
|
* (`confirmedOver`), read again right before writing: changed while they answered, it stops again (#2279 review).
|
|
77
95
|
*/
|
|
78
|
-
export function buildShortcutsScript(shared, distro, user, confirmedOver) {
|
|
96
|
+
export function buildShortcutsScript(shared, distro, user, confirmedOver, icons = {}) {
|
|
79
97
|
const seen = confirmedOver ? `@{ Distro = ${psQuote(confirmedOver.distro)}; User = ${psQuote(confirmedOver.user)} }` : "$null";
|
|
80
98
|
return [
|
|
81
99
|
"$ErrorActionPreference = 'Stop'",
|
|
@@ -86,7 +104,7 @@ export function buildShortcutsScript(shared, distro, user, confirmedOver) {
|
|
|
86
104
|
` $other = Get-InstallRecordConflict ${psQuote(distro)} ${psQuote(user)}`,
|
|
87
105
|
" Write-Output ('AGEND_RECORD_OTHER=' + $other.Distro + '|' + $other.User); exit 0",
|
|
88
106
|
"}",
|
|
89
|
-
`$made = @(Install-AgendShortcuts ${psQuote(distro)} ${psQuote(user)})`,
|
|
107
|
+
`$made = @(Install-AgendShortcuts ${psQuote(distro)} ${psQuote(user)} ${iconsLiteral(icons)})`,
|
|
90
108
|
"Write-Output ('AGEND_SHORTCUTS_MADE=' + $made.Count)",
|
|
91
109
|
"",
|
|
92
110
|
].join("\n");
|
|
@@ -95,8 +113,21 @@ export function buildShortcutsScript(shared, distro, user, confirmedOver) {
|
|
|
95
113
|
export function encodePowershell(script) {
|
|
96
114
|
return Buffer.from(script, "utf16le").toString("base64");
|
|
97
115
|
}
|
|
98
|
-
|
|
99
|
-
|
|
116
|
+
/**
|
|
117
|
+
* M-2885: what -EncodedCommand carries — only this loader. The script itself (the shared code, then the icons) arrives on
|
|
118
|
+
* standard input, read WHOLE and run at the top level as ONE script block (never line by line). Windows' command line
|
|
119
|
+
* holds 32,767 characters; the script with its icons is far longer.
|
|
120
|
+
* Standard input carries base64 of the script's UTF-8 bytes — ASCII only, which no console code page can alter, whatever
|
|
121
|
+
* Windows PowerShell 5.1 does with redirected input. (The "AgEnD ???" first seen on a real Windows was not this: it was
|
|
122
|
+
* WScript.Shell saving through the ANSI code page — see New-AgendShortcut.)
|
|
123
|
+
*/
|
|
124
|
+
export const STDIN_LOADER = "$ErrorActionPreference = 'Stop'; $r = New-Object IO.StreamReader([Console]::OpenStandardInput(), [Text.Encoding]::ASCII); $b = $r.ReadToEnd(); $r.Dispose(); $s = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($b.Trim())); . ([ScriptBlock]::Create($s))";
|
|
125
|
+
/** What goes on the loader's standard input: the script, as base64 of its UTF-8 bytes (see STDIN_LOADER). */
|
|
126
|
+
export function stdinPayload(script) {
|
|
127
|
+
return Buffer.from(script, "utf8").toString("base64");
|
|
128
|
+
}
|
|
129
|
+
export function powershellArgs() {
|
|
130
|
+
return ["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-EncodedCommand", encodePowershell(STDIN_LOADER)];
|
|
100
131
|
}
|
|
101
132
|
/** `agend shortcuts`. Resolves to the exit code. */
|
|
102
133
|
export async function runShortcuts(deps) {
|
|
@@ -115,7 +146,8 @@ export async function runShortcuts(deps) {
|
|
|
115
146
|
return 1;
|
|
116
147
|
}
|
|
117
148
|
deps.log(t("shortcuts.making", distro, deps.user));
|
|
118
|
-
|
|
149
|
+
const icons = deps.icons?.() ?? {};
|
|
150
|
+
let result = deps.run(powershell, powershellArgs(), stdinPayload(buildShortcutsScript(deps.shared(), distro, deps.user, undefined, icons)));
|
|
119
151
|
const other = OTHER_LINE.exec(result.stdout ?? "");
|
|
120
152
|
if (other) {
|
|
121
153
|
// The shortcuts (and install.json) point at another Linux or user: say so, and switch only on an explicit y.
|
|
@@ -125,7 +157,7 @@ export async function runShortcuts(deps) {
|
|
|
125
157
|
deps.log(t(yes === null ? "shortcuts.kept_no_tty" : "shortcuts.kept", otherDistro, otherUser));
|
|
126
158
|
return 1;
|
|
127
159
|
}
|
|
128
|
-
result = deps.run(powershell, powershellArgs(buildShortcutsScript(deps.shared(), distro, deps.user, { distro: otherDistro, user: otherUser })));
|
|
160
|
+
result = deps.run(powershell, powershellArgs(), stdinPayload(buildShortcutsScript(deps.shared(), distro, deps.user, { distro: otherDistro, user: otherUser }, icons)));
|
|
129
161
|
// Changed while the person answered: what they agreed to replace is no longer there — nothing is written.
|
|
130
162
|
const again = OTHER_LINE.exec(result.stdout ?? "");
|
|
131
163
|
if (again) {
|
|
@@ -157,6 +189,7 @@ export function realShortcutsDeps(dataDir, user, run) {
|
|
|
157
189
|
return {
|
|
158
190
|
host: realHost(), user, dataDir, run,
|
|
159
191
|
shared: () => sharedShortcutsPs(),
|
|
192
|
+
icons: () => packageShortcutIcons(),
|
|
160
193
|
writeMarker: (path, content) => { mkdirSync(dirname(path), { recursive: true, mode: 0o700 }); writeFileSync(path, content); },
|
|
161
194
|
log: line => console.log(line),
|
|
162
195
|
now: () => new Date(),
|
|
@@ -194,9 +227,19 @@ export function shortcutsHintOnce(o) {
|
|
|
194
227
|
}
|
|
195
228
|
return t("shortcuts.hint");
|
|
196
229
|
}
|
|
197
|
-
/**
|
|
198
|
-
|
|
199
|
-
|
|
230
|
+
/**
|
|
231
|
+
* After an install or `agend update`: print the one-time line, if it is due — the Windows shortcuts in WSL (#1853), the
|
|
232
|
+
* launchers on a Linux desktop (M-2885).
|
|
233
|
+
*/
|
|
234
|
+
export async function printUpdateShortcutsHint(dataDir) {
|
|
235
|
+
const host = realHost();
|
|
236
|
+
const write = (path, content) => writeFileSync(path, content, { flag: "wx" });
|
|
237
|
+
const tty = !!process.stdout.isTTY;
|
|
238
|
+
let line = shortcutsHintOnce({ host, dataDir, tty, write });
|
|
239
|
+
if (!line) {
|
|
240
|
+
const { launchersHintOnce } = await import("./linux-launchers.js");
|
|
241
|
+
line = launchersHintOnce({ env: host.env, platform: process.platform, wsl: detectWsl(host).wsl, dataDir, tty, exists: host.exists, write });
|
|
242
|
+
}
|
|
200
243
|
if (line)
|
|
201
244
|
console.log(` ${line}\n`);
|
|
202
245
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"windows-shortcuts.js","sourceRoot":"","sources":["../src/windows-shortcuts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,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5D,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,EAAE,iBAAiB,EAAE,GAAG,MAAM,MAAM,CAAC,sBAAsB,CAAC,CAAC;QACnE,IAAI,GAAG,iBAAiB,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,GAAG,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;IAC9I,CAAC;IACD,IAAI,IAAI;QAAE,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -733,6 +733,11 @@ function main(argv, injected) {
|
|
|
733
733
|
pruneStale(prefix, deps).forEach(function (n) { log(" ↺ " + n); });
|
|
734
734
|
var previous = isAgendPackage(path.join(root, "@songsid", "agend"));
|
|
735
735
|
var bin = path.join(prefix, "bin", "agend");
|
|
736
|
+
// M-2885: the one-time line about desktop shortcuts (WSL) or launchers (a Linux desktop), said by the agend just
|
|
737
|
+
// installed and only in a terminal — on every successful end. Its outcome never changes this install's.
|
|
738
|
+
var sayShortcutsHint = function () {
|
|
739
|
+
try { deps.run(bin, ["shortcuts", "--hint"], { inherit: true, env: withoutUpdateNpmBounds(deps.env) }); } catch (e) { /* a hint never fails an install */ }
|
|
740
|
+
};
|
|
736
741
|
// #2420: on a host with a service, what an update whose new service does not come up goes back to.
|
|
737
742
|
var svc = serviceOf(serviceKind(deps), deps);
|
|
738
743
|
if (svc && previous) {
|
|
@@ -779,7 +784,7 @@ function main(argv, injected) {
|
|
|
779
784
|
// A fresh install (no fleet set up, not an upgrade): the next step is the setup wizard.
|
|
780
785
|
var kind = serviceKind(deps);
|
|
781
786
|
var configured = fs.existsSync(path.join(home, "fleet.yaml")) || fs.existsSync(path.join(home, "fleet.pid"));
|
|
782
|
-
if (!configured && !upgrade && !kind) { log(" Next: run `agend quickstart` to set up AgEnD."); return 0; }
|
|
787
|
+
if (!configured && !upgrade && !kind) { log(" Next: run `agend quickstart` to set up AgEnD."); sayShortcutsHint(); return 0; }
|
|
783
788
|
// The service stays under the manager it has (`agend restart` picks the same one: system unit, else user unit or
|
|
784
789
|
// launchd job): the new release's `agend install --no-activate` refreshes that definition without starting anything
|
|
785
790
|
// (a legacy system unit is refreshed in place — never a second, user unit), then the fleet moves onto the new release:
|
|
@@ -852,6 +857,7 @@ function main(argv, injected) {
|
|
|
852
857
|
var notUp = launchdReady(svc, home, deps);
|
|
853
858
|
if (notUp) return rollBack(restarted ? "stopping" : "starting", "the launchd job did not come up on v" + version + ": " + notUp, "run `agend restart`");
|
|
854
859
|
}
|
|
860
|
+
sayShortcutsHint();
|
|
855
861
|
return 0;
|
|
856
862
|
} finally {
|
|
857
863
|
// Spent (put back), or not needed: only a rollback that could not finish keeps its copy, says where, and marks it
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
@@ -104,7 +104,7 @@ function Invoke-AgendInWsl([string]$distro, [string]$user, [string]$command) {
|
|
|
104
104
|
}
|
|
105
105
|
function Invoke-RestartAgend([string]$distro, [string]$user, [switch]$Wait, [int]$SettleSeconds = 3) {
|
|
106
106
|
Write-Host ""
|
|
107
|
-
$answer = Read-Host " 確定要重啟 AgEnD 嗎?所有
|
|
107
|
+
$answer = Read-Host " 確定要重啟 AgEnD 嗎?所有 Agent 會重新啟動,正在進行的工作會中斷。(y/N)"
|
|
108
108
|
if (([string]$answer) -notmatch '^\s*[yY]\s*$') {
|
|
109
109
|
Write-Host " 沒有重啟。"
|
|
110
110
|
if ($Wait) { $null = Read-Host "按 Enter 關閉" }
|
|
@@ -167,26 +167,59 @@ function Get-ShortcutCommand([string]$file) {
|
|
|
167
167
|
if ($wt) { return @{ Target = $wt.Source; Arguments = '-w new "{0}" {1}' -f $ps, ($a -replace ';', '\;') } }
|
|
168
168
|
return @{ Target = $ps; Arguments = $a }
|
|
169
169
|
}
|
|
170
|
-
function
|
|
170
|
+
function Save-AgendIcon([string]$name, $bytes) {
|
|
171
|
+
if (-not $bytes) { return $null }
|
|
172
|
+
try {
|
|
173
|
+
New-Item -ItemType Directory -Path (Get-AgendShortcutDir) -Force | Out-Null
|
|
174
|
+
$path = Join-Path (Get-AgendShortcutDir) $name
|
|
175
|
+
[IO.File]::WriteAllBytes($path, [byte[]]$bytes)
|
|
176
|
+
return $path
|
|
177
|
+
} catch { return $null }
|
|
178
|
+
}
|
|
179
|
+
function New-AgendShortcut([string]$name, [string]$scriptName, [string]$scriptText, [string]$description, [string]$icon = '') {
|
|
171
180
|
$dir = Get-AgendShortcutDir
|
|
172
181
|
New-Item -ItemType Directory -Path $dir -Force | Out-Null
|
|
173
182
|
$file = Join-Path $dir $scriptName
|
|
174
183
|
[IO.File]::WriteAllText($file, $scriptText, (New-Object System.Text.UTF8Encoding $true))
|
|
175
184
|
$lnk = Join-Path ([Environment]::GetFolderPath('Desktop')) ($name + '.lnk')
|
|
176
|
-
$
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
$
|
|
181
|
-
$
|
|
182
|
-
$
|
|
185
|
+
$staged = $lnk + '.agend-new'
|
|
186
|
+
# WScript.Shell saves a shortcut through the system ANSI code page: on a Windows whose system language has no 儀表板
|
|
187
|
+
# (English, Japanese...) Save() on the Chinese name fails. So it is saved under an ASCII name here, then put in place
|
|
188
|
+
# by .NET (Unicode). Leftovers of a run that died midway are ours by name, and only those are removed.
|
|
189
|
+
Get-ChildItem -LiteralPath $dir -Filter 'shortcut-*.tmp.lnk' -ErrorAction SilentlyContinue | Remove-Item -Force -ErrorAction SilentlyContinue
|
|
190
|
+
if ([IO.File]::Exists($staged)) { [IO.File]::Delete($staged) }
|
|
191
|
+
$tmp = Join-Path $dir ('shortcut-' + [guid]::NewGuid().ToString('N') + '.tmp.lnk')
|
|
192
|
+
try {
|
|
193
|
+
$shell = New-Object -ComObject WScript.Shell
|
|
194
|
+
$sc = $shell.CreateShortcut($tmp)
|
|
195
|
+
$cmd = Get-ShortcutCommand $file
|
|
196
|
+
$sc.TargetPath = $cmd.Target
|
|
197
|
+
$sc.Arguments = $cmd.Arguments
|
|
198
|
+
$sc.Description = $description
|
|
199
|
+
if ($icon) { $sc.IconLocation = $icon + ',0' }
|
|
200
|
+
$sc.Save()
|
|
201
|
+
# Beside the old one first (same folder, same volume), then swapped in: if that fails, the old shortcut stays.
|
|
202
|
+
[IO.File]::Copy($tmp, $staged, $true)
|
|
203
|
+
if (-not [IO.File]::Exists($lnk)) { [IO.File]::Move($staged, $lnk) }
|
|
204
|
+
else {
|
|
205
|
+
try { [IO.File]::Replace($staged, $lnk, [NullString]::Value) }
|
|
206
|
+
catch {
|
|
207
|
+
# ReplaceFile can fail after the old one is gone (ERROR_UNABLE_TO_MOVE_REPLACEMENT): then the new one goes in.
|
|
208
|
+
if ((-not [IO.File]::Exists($lnk)) -and [IO.File]::Exists($staged)) { [IO.File]::Move($staged, $lnk) } else { throw }
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
} finally {
|
|
212
|
+
foreach ($left in @($tmp, $staged)) { try { if ([IO.File]::Exists($left)) { [IO.File]::Delete($left) } } catch { } }
|
|
213
|
+
}
|
|
183
214
|
return $lnk
|
|
184
215
|
}
|
|
185
|
-
function Install-AgendShortcuts([string]$distro, [string]$user) {
|
|
216
|
+
function Install-AgendShortcuts([string]$distro, [string]$user, $icons = $null) {
|
|
186
217
|
if (-not $script:OnWindows) { return @() }
|
|
187
218
|
$made = @()
|
|
188
|
-
|
|
189
|
-
|
|
219
|
+
$dashIcon = ''; $restartIcon = ''
|
|
220
|
+
if ($icons) { $dashIcon = [string](Save-AgendIcon 'agend.ico' $icons['agend.ico']); $restartIcon = [string](Save-AgendIcon 'agend-restart.ico' $icons['agend-restart.ico']) }
|
|
221
|
+
try { $made += New-AgendShortcut 'AgEnD 儀表板' 'open-dashboard.ps1' (Get-DashboardOpenerScript $distro $user) 'AgEnD 網頁儀表板(自動帶入登入碼)' $dashIcon } catch { }
|
|
222
|
+
try { $made += New-AgendShortcut 'AgEnD 重新啟動' 'restart-agend.ps1' (Get-RestartScript $distro $user) '重新啟動 AgEnD(會先詢問)' $restartIcon } catch { }
|
|
190
223
|
try {
|
|
191
224
|
New-Item -ItemType Directory -Path (Get-AgendShortcutDir) -Force | Out-Null
|
|
192
225
|
$record = @{ distro = $distro; user = $user } | ConvertTo-Json -Compress
|