fix(windows): add windowless agent-libw for scheduled sync
agent-lib.exe is a console program, so Windows opens a terminal window on every scheduled run. Ship agent-libw.exe, the same program built with -H=windowsgui, in the Windows zip for use in the task action. Start the PowerShell toast without a window, since agent-libw has no console to inherit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5e7d693699
commit
e41ffa6a14
5 files changed
+32
-1
No files matched your search
@@ -6,6 +6,7 @@
|
||||
# Go build artifacts
|
||||
agent-lib
|
||||
agent-lib.exe
|
||||
agent-libw.exe
|
||||
dist/
|
||||
*.test
|
||||
*.out
|
||||
|
||||
@@ -40,6 +40,18 @@ builds:
|
||||
ldflags:
|
||||
- -s -w -X github.com/m3tam3re/agent-lib/internal/version.Version={{.Version}}
|
||||
binary: agent-lib
|
||||
# GUI-Subsystem-Variante fuer die Aufgabenplanung: oeffnet kein
|
||||
# Konsolenfenster, dafuer auch keine Ausgabe auf stdout/stderr.
|
||||
- id: agent-libw
|
||||
env:
|
||||
- CGO_ENABLED=0
|
||||
goos:
|
||||
- windows
|
||||
goarch:
|
||||
- amd64
|
||||
ldflags:
|
||||
- -s -w -H=windowsgui -X github.com/m3tam3re/agent-lib/internal/version.Version={{.Version}}
|
||||
binary: agent-libw
|
||||
|
||||
checksum:
|
||||
name_template: "checksums.txt"
|
||||
@@ -53,6 +65,8 @@ archives:
|
||||
# Explizit stabil, damit Fleet-Download-URLs vorhersehbar bleiben:
|
||||
# .../releases/download/<tag>/agent-lib_<os>_<arch>.<ext>
|
||||
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
|
||||
# Das Windows-Zip enthaelt zusaetzlich agent-libw.exe.
|
||||
allow_different_binary_count: true
|
||||
|
||||
changelog:
|
||||
sort: asc
|
||||
|
||||
@@ -300,6 +300,7 @@ flag that drives the non-zero exit code — suitable for headless drift checks.
|
||||
| `status` exits 1 | Local modifications block repository updates (or occupy names the repo needs). See `status` output for the item list. |
|
||||
| Sync fails with clone/fetch error | Work repository unreachable, or token expired. Previous local state remains intact; fix config/network and re-run. |
|
||||
| No toast on Windows | Toasts need an interactive user session — the scheduled task must run as the logged-in user, not SYSTEM. |
|
||||
| Terminal window flashes on scheduled sync (Windows) | The task runs the console program `agent-lib.exe`. Point it at `agent-libw.exe sync` from the same zip: same commands, no window, no output. |
|
||||
|
||||
## Development
|
||||
|
||||
|
||||
+10
-1
@@ -27,7 +27,8 @@ the external areas).
|
||||
|
||||
- Source of truth: GitHub releases of `m3tam3re/agent-lib`.
|
||||
- Artifacts: `agent-lib_{windows_amd64,linux_amd64,linux_arm64,darwin_amd64,darwin_arm64}`
|
||||
plus `checksums.txt` (tar.gz archives; windows is a zip).
|
||||
plus `checksums.txt` (tar.gz archives; windows is a zip containing
|
||||
`agent-lib.exe` and the windowless `agent-libw.exe`).
|
||||
- Fleet pins an exact release tag (installer-pin pattern already used for
|
||||
other tools). **No self-update exists in the binary** — binary updates are
|
||||
exclusively fleet rollouts. Content updates are pulled by the binary itself.
|
||||
@@ -68,6 +69,12 @@ Local state (manifest, cached bare repo, sync log) lives per-user:
|
||||
against the user's profile.
|
||||
2. Windows toast notifications require an interactive user session. A task
|
||||
running as SYSTEM produces no visible toasts.
|
||||
- On Windows, the task action must run `agent-libw.exe sync`, not
|
||||
`agent-lib.exe sync`. `agent-lib.exe` is a console program, so Windows opens
|
||||
a terminal window for it on every run. `agent-libw.exe` is the same program
|
||||
without a console. It prints nothing, so check the task's last run result
|
||||
(`0` = success, `1` = failed), and run `agent-lib.exe sync` by hand to see
|
||||
the error.
|
||||
- Suggested cadence: every 1–4 hours plus/except at logon. Sync is idempotent
|
||||
and cheap when unchanged.
|
||||
- Optional companion: a drift check running `agent-lib status --json`
|
||||
@@ -132,6 +139,8 @@ Local state (manifest, cached bare repo, sync log) lives per-user:
|
||||
admins; token present.
|
||||
- [ ] Scheduled task runs as the logged-in user; toast appears when a
|
||||
modified item is skipped (manual visual check on a Windows client).
|
||||
- [ ] Windows task action uses `agent-libw.exe`; no terminal window appears
|
||||
when the task runs.
|
||||
- [ ] `agent-lib status` exits 0 on a clean machine, non-zero after editing a
|
||||
deployed file (self-test).
|
||||
- [ ] Drift monitoring consumes `status --json` → `problematic_drift`.
|
||||
@@ -6,8 +6,12 @@ import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// createNoWindow is the Win32 CREATE_NO_WINDOW process creation flag.
|
||||
const createNoWindow = 0x08000000
|
||||
|
||||
// PowerShellToast raises a Windows toast notification by invoking
|
||||
// PowerShell with an AppId-tagged script — the same mechanism go-toast
|
||||
// uses, without the dependency.
|
||||
@@ -36,6 +40,8 @@ func (p PowerShellToast) Send(title, body string) error {
|
||||
}
|
||||
script := fmt.Sprintf(toastScript, escape(appID), escape(title), escape(body))
|
||||
cmd := exec.Command("powershell", "-NoProfile", "-NonInteractive", "-Command", script)
|
||||
// agent-libw has no console to inherit, so PowerShell would open its own.
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true, CreationFlags: createNoWindow}
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
return fmt.Errorf("toast failed: %v: %s", err, strings.TrimSpace(string(out)))
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user