@songsid/agend 2.2.0-beta.1 → 2.2.0-beta.11
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/README.md +1 -1
- package/README.zh-TW.md +1 -1
- package/dist/agent-cli-instructions.md +16 -9
- package/dist/agent-cli.js +15 -7
- package/dist/agent-cli.js.map +1 -1
- package/dist/agent-endpoint.js +24 -9
- package/dist/agent-endpoint.js.map +1 -1
- package/dist/agent-whats-new.d.ts +47 -0
- package/dist/agent-whats-new.js +147 -0
- package/dist/agent-whats-new.js.map +1 -0
- package/dist/auth-api.d.ts +5 -3
- package/dist/auth-api.js +19 -3
- package/dist/auth-api.js.map +1 -1
- package/dist/backend/antigravity.d.ts +8 -0
- package/dist/backend/antigravity.js +32 -9
- package/dist/backend/antigravity.js.map +1 -1
- package/dist/backend/claude-carry.d.ts +22 -0
- package/dist/backend/claude-carry.js +170 -0
- package/dist/backend/claude-carry.js.map +1 -0
- package/dist/backend/claude-code.d.ts +65 -2
- package/dist/backend/claude-code.js +226 -33
- package/dist/backend/claude-code.js.map +1 -1
- package/dist/backend/codex-metadata.d.ts +33 -0
- package/dist/backend/codex-metadata.js +122 -18
- package/dist/backend/codex-metadata.js.map +1 -1
- package/dist/backend/codex.d.ts +3 -0
- package/dist/backend/codex.js +17 -1
- package/dist/backend/codex.js.map +1 -1
- package/dist/backend/credential-profile.d.ts +40 -3
- package/dist/backend/credential-profile.js +113 -5
- package/dist/backend/credential-profile.js.map +1 -1
- package/dist/backend/effort-metadata.d.ts +37 -1
- package/dist/backend/effort-metadata.js +86 -15
- package/dist/backend/effort-metadata.js.map +1 -1
- package/dist/backend/grok.d.ts +4 -0
- package/dist/backend/grok.js +14 -0
- package/dist/backend/grok.js.map +1 -1
- package/dist/backend/kiro-engine-ledger.d.ts +5 -0
- package/dist/backend/kiro-engine-ledger.js +20 -0
- package/dist/backend/kiro-engine-ledger.js.map +1 -1
- package/dist/backend/kiro-identity.d.ts +6 -0
- package/dist/backend/kiro-identity.js +19 -5
- package/dist/backend/kiro-identity.js.map +1 -1
- package/dist/backend/kiro.d.ts +39 -3
- package/dist/backend/kiro.js +143 -19
- package/dist/backend/kiro.js.map +1 -1
- package/dist/backend/launch-effort.d.ts +61 -0
- package/dist/backend/launch-effort.js +170 -0
- package/dist/backend/launch-effort.js.map +1 -0
- package/dist/backend/muse.d.ts +84 -0
- package/dist/backend/muse.js +449 -53
- package/dist/backend/muse.js.map +1 -1
- package/dist/backend/types.d.ts +47 -4
- package/dist/backend/types.js +12 -1
- package/dist/backend/types.js.map +1 -1
- package/dist/backend-command.d.ts +91 -0
- package/dist/backend-command.js +122 -0
- package/dist/backend-command.js.map +1 -0
- package/dist/background-work-ended.d.ts +18 -0
- package/dist/background-work-ended.js +30 -0
- package/dist/background-work-ended.js.map +1 -0
- package/dist/cache-service.d.ts +2 -0
- package/dist/cache-service.js +2 -1
- package/dist/cache-service.js.map +1 -1
- package/dist/channel/adapters/discord.d.ts +36 -1
- package/dist/channel/adapters/discord.js +126 -4
- package/dist/channel/adapters/discord.js.map +1 -1
- package/dist/channel/adapters/telegram.d.ts +42 -2
- package/dist/channel/adapters/telegram.js +142 -23
- package/dist/channel/adapters/telegram.js.map +1 -1
- package/dist/channel/mcp-server.js +9 -1
- package/dist/channel/mcp-server.js.map +1 -1
- package/dist/channel/mcp-tools.d.ts +11 -0
- package/dist/channel/mcp-tools.js +26 -13
- package/dist/channel/mcp-tools.js.map +1 -1
- package/dist/channel/message-edit-errors.d.ts +5 -0
- package/dist/channel/message-edit-errors.js +24 -0
- package/dist/channel/message-edit-errors.js.map +1 -0
- package/dist/channel/telegram-markdown.d.ts +6 -0
- package/dist/channel/telegram-markdown.js +104 -0
- package/dist/channel/telegram-markdown.js.map +1 -0
- package/dist/channel/tool-router.d.ts +2 -0
- package/dist/channel/tool-router.js +10 -4
- package/dist/channel/tool-router.js.map +1 -1
- package/dist/channel/types.d.ts +55 -3
- package/dist/cli.js +167 -39
- package/dist/cli.js.map +1 -1
- package/dist/command-table.d.ts +2 -2
- package/dist/command-table.js +6 -3
- package/dist/command-table.js.map +1 -1
- package/dist/config-validator.js +59 -0
- package/dist/config-validator.js.map +1 -1
- package/dist/cross-instance-envelope.d.ts +15 -2
- package/dist/cross-instance-envelope.js +29 -5
- package/dist/cross-instance-envelope.js.map +1 -1
- package/dist/daemon.d.ts +156 -1
- package/dist/daemon.js +773 -89
- package/dist/daemon.js.map +1 -1
- package/dist/delivery-outbox.d.ts +70 -8
- package/dist/delivery-outbox.js +315 -24
- package/dist/delivery-outbox.js.map +1 -1
- package/dist/delivery-reconciliation.d.ts +18 -1
- package/dist/delivery-reconciliation.js +67 -2
- package/dist/delivery-reconciliation.js.map +1 -1
- package/dist/fleet-context.d.ts +10 -1
- package/dist/fleet-manager.d.ts +404 -13
- package/dist/fleet-manager.js +2039 -210
- package/dist/fleet-manager.js.map +1 -1
- package/dist/general-knowledge/skills/backend-providers/SKILL.md +1 -1
- package/dist/general-knowledge/skills/credential-profiles/SKILL.md +92 -21
- package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +27 -3
- package/dist/general-knowledge/skills/delegation-playbook/SKILL.md +8 -8
- package/dist/general-knowledge/skills/fleet-config/SKILL.md +5 -5
- package/dist/general-knowledge/skills/fleet-health/SKILL.md +4 -4
- package/dist/general-knowledge/skills/fleet-restart/SKILL.md +13 -13
- package/dist/general-knowledge/skills/instance-lifecycle/SKILL.md +3 -2
- package/dist/general-knowledge/skills/kiro-engine-migration/SKILL.md +6 -0
- package/dist/general-knowledge/skills/model-discovery/SKILL.md +12 -9
- package/dist/general-knowledge/skills/multi-channel/SKILL.md +8 -2
- package/dist/general-knowledge/skills/scheduling/SKILL.md +5 -3
- package/dist/general-knowledge/skills/session-management/SKILL.md +6 -5
- package/dist/general-knowledge/skills/tui-effort/SKILL.md +2 -2
- package/dist/general-knowledge/skills/worker-collaboration/SKILL.md +8 -3
- package/dist/general-knowledge/steering/core-rules.md +8 -7
- package/dist/host-memory.d.ts +10 -0
- package/dist/host-memory.js +33 -1
- package/dist/host-memory.js.map +1 -1
- package/dist/human-delivery-receipts.d.ts +83 -0
- package/dist/human-delivery-receipts.js +194 -0
- package/dist/human-delivery-receipts.js.map +1 -0
- package/dist/instance-avatar.d.ts +36 -0
- package/dist/instance-avatar.js +57 -0
- package/dist/instance-avatar.js.map +1 -0
- package/dist/instance-config-impact.js +6 -0
- package/dist/instance-config-impact.js.map +1 -1
- package/dist/instance-lifecycle.d.ts +29 -6
- package/dist/instance-lifecycle.js +79 -28
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/instructions.d.ts +3 -1
- package/dist/instructions.js +11 -8
- package/dist/instructions.js.map +1 -1
- package/dist/kiro-log-gate.d.ts +42 -0
- package/dist/kiro-log-gate.js +39 -0
- package/dist/kiro-log-gate.js.map +1 -0
- package/dist/locale.js +226 -44
- package/dist/locale.js.map +1 -1
- package/dist/log-service.d.ts +99 -0
- package/dist/log-service.js +243 -0
- package/dist/log-service.js.map +1 -0
- package/dist/log-steps.d.ts +169 -0
- package/dist/log-steps.js +858 -0
- package/dist/log-steps.js.map +1 -0
- package/dist/login-controller.d.ts +20 -3
- package/dist/login-controller.js +71 -19
- package/dist/login-controller.js.map +1 -1
- package/dist/login-flows.d.ts +5 -2
- package/dist/login-flows.js +5 -4
- package/dist/login-flows.js.map +1 -1
- package/dist/memory-pressure.d.ts +13 -1
- package/dist/memory-pressure.js +50 -10
- package/dist/memory-pressure.js.map +1 -1
- package/dist/needs-you-hub.js +2 -0
- package/dist/needs-you-hub.js.map +1 -1
- package/dist/needs-you-live.d.ts +6 -0
- package/dist/needs-you-live.js +23 -3
- package/dist/needs-you-live.js.map +1 -1
- package/dist/next-steps.js +1 -1
- package/dist/next-steps.js.map +1 -1
- package/dist/outbound-handlers.d.ts +100 -0
- package/dist/outbound-handlers.js +284 -97
- package/dist/outbound-handlers.js.map +1 -1
- package/dist/outbound-schemas.d.ts +38 -15
- package/dist/outbound-schemas.js +36 -8
- package/dist/outbound-schemas.js.map +1 -1
- package/dist/public-link-progress.d.ts +1 -1
- package/dist/public-link-progress.js +8 -2
- package/dist/public-link-progress.js.map +1 -1
- package/dist/public-preview.d.ts +101 -0
- package/dist/public-preview.js +236 -0
- package/dist/public-preview.js.map +1 -0
- package/dist/public-web-gateway.js +14 -4
- package/dist/public-web-gateway.js.map +1 -1
- package/dist/public-web-link.d.ts +24 -1
- package/dist/public-web-link.js +63 -9
- package/dist/public-web-link.js.map +1 -1
- package/dist/reply-buttons-controller.d.ts +89 -5
- package/dist/reply-buttons-controller.js +273 -8
- package/dist/reply-buttons-controller.js.map +1 -1
- package/dist/reply-buttons.d.ts +48 -3
- package/dist/reply-buttons.js +105 -10
- package/dist/reply-buttons.js.map +1 -1
- package/dist/reply-polls.d.ts +85 -0
- package/dist/reply-polls.js +154 -0
- package/dist/reply-polls.js.map +1 -0
- package/dist/restart-guard.d.ts +6 -3
- package/dist/restart-guard.js +6 -3
- package/dist/restart-guard.js.map +1 -1
- package/dist/restart-progress.d.ts +33 -0
- package/dist/restart-progress.js +30 -0
- package/dist/restart-progress.js.map +1 -1
- package/dist/service-activation.d.ts +15 -7
- package/dist/service-activation.js +46 -29
- package/dist/service-activation.js.map +1 -1
- package/dist/service-installer.d.ts +31 -0
- package/dist/service-installer.js +41 -2
- package/dist/service-installer.js.map +1 -1
- package/dist/settings-api.js +85 -25
- package/dist/settings-api.js.map +1 -1
- package/dist/settings-change.js +72 -1
- package/dist/settings-change.js.map +1 -1
- package/dist/settings-effect.js +28 -4
- package/dist/settings-effect.js.map +1 -1
- package/dist/settings-http-confirmation.js +7 -0
- package/dist/settings-http-confirmation.js.map +1 -1
- package/dist/setup-form.d.ts +1 -1
- package/dist/setup-form.js +1 -1
- package/dist/spawn-gate.js +5 -1
- package/dist/spawn-gate.js.map +1 -1
- package/dist/spawn-hold-reply.d.ts +12 -0
- package/dist/spawn-hold-reply.js +39 -0
- package/dist/spawn-hold-reply.js.map +1 -0
- package/dist/status-emojis.d.ts +10 -3
- package/dist/status-emojis.js +11 -2
- package/dist/status-emojis.js.map +1 -1
- package/dist/systemd-peer-bus.d.ts +95 -0
- package/dist/systemd-peer-bus.js +430 -0
- package/dist/systemd-peer-bus.js.map +1 -0
- package/dist/systemd-runtime.d.ts +27 -1
- package/dist/systemd-runtime.js +69 -7
- package/dist/systemd-runtime.js.map +1 -1
- package/dist/tips.js +4 -4
- package/dist/tips.js.map +1 -1
- package/dist/tool-permissions.js +3 -3
- package/dist/tool-permissions.js.map +1 -1
- package/dist/tool-progress.js +3 -2
- package/dist/tool-progress.js.map +1 -1
- package/dist/topic-commands.d.ts +42 -2
- package/dist/topic-commands.js +101 -11
- package/dist/topic-commands.js.map +1 -1
- package/dist/transcript-delta-reader.d.ts +3 -3
- package/dist/transcript-delta-reader.js +8 -8
- package/dist/transcript-delta-reader.js.map +1 -1
- package/dist/transcript-jsonl.d.ts +80 -3
- package/dist/transcript-jsonl.js +147 -10
- package/dist/transcript-jsonl.js.map +1 -1
- package/dist/transcript-monitor.d.ts +19 -0
- package/dist/transcript-monitor.js +87 -15
- package/dist/transcript-monitor.js.map +1 -1
- package/dist/transcript-sources.d.ts +78 -0
- package/dist/transcript-sources.js +375 -64
- package/dist/transcript-sources.js.map +1 -1
- package/dist/transcript-turns.d.ts +15 -2
- package/dist/transcript-turns.js +15 -2
- package/dist/transcript-turns.js.map +1 -1
- package/dist/tunnel/cloudflared.d.ts +7 -15
- package/dist/tunnel/cloudflared.js +36 -1
- package/dist/tunnel/cloudflared.js.map +1 -1
- package/dist/tunnel/purpose-lane.d.ts +5 -1
- package/dist/tunnel/purpose-lane.js +14 -7
- package/dist/tunnel/purpose-lane.js.map +1 -1
- package/dist/tunnel/types.d.ts +5 -1
- package/dist/tunnel/types.js.map +1 -1
- package/dist/turn-resume.d.ts +2 -0
- package/dist/turn-resume.js +1 -1
- package/dist/turn-resume.js.map +1 -1
- package/dist/types.d.ts +25 -0
- package/dist/ui/chat-commands.js +1 -0
- package/dist/ui/chat-emojis.js +33 -0
- package/dist/ui/chat-mentions.js +63 -0
- package/dist/ui/chat-render.js +61 -4
- package/dist/ui/chat-store.js +37 -3
- package/dist/ui/chat-strings.js +40 -20
- package/dist/ui/chat-thread.js +111 -12
- package/dist/ui/chat-time.js +80 -0
- package/dist/ui/panel-chat.js +41 -10
- package/dist/ui/panel-details.js +2 -0
- package/dist/ui/panel-fleet.js +199 -57
- package/dist/ui/panel-log.js +428 -0
- package/dist/ui/panel-needs.js +6 -2
- package/dist/ui/panel-settings.js +184 -32
- package/dist/ui/preview-panel.js +55 -15
- package/dist/ui/preview-status.js +28 -0
- package/dist/ui/preview.js +44 -3
- package/dist/ui/settings-dialogs.js +7 -2
- package/dist/ui/settings-model.js +2 -1
- package/dist/ui/settings-strings.js +56 -4
- package/dist/ui/settings-token.js +1 -1
- package/dist/ui/shared/app-i18n.js +43 -17
- package/dist/ui/shared/app-prefs.js +250 -0
- package/dist/ui/shared/app-route.js +7 -2
- package/dist/ui/shared/app-shell.js +165 -8
- package/dist/ui/shared/app-store.js +5 -1
- package/dist/ui/shared/app-stream.js +26 -5
- package/dist/ui/shared/app.css +163 -22
- package/dist/ui/shared/app.js +11 -1
- package/dist/ui/shared/fonts/README.md +1 -1
- package/dist/ui/shared/header-tools.js +55 -5
- package/dist/ui/shared/instance-nav.js +241 -45
- package/dist/ui/shared/instance-switch.js +4 -4
- package/dist/ui/shared/panel-view.js +6 -0
- package/dist/ui/shared/signin.js +7 -7
- package/dist/ui/shared/theme.js +39 -7
- package/dist/ui/shared/tokens.css +1 -1
- package/dist/ui/shared/ui-icons.js +1 -0
- package/dist/ui/shared/usage-dialog.js +23 -5
- package/dist/ui/shared/view-strings.js +32 -4
- package/dist/ui/signin.html +1 -1
- package/dist/unrecognised-prompt.d.ts +23 -0
- package/dist/unrecognised-prompt.js +74 -0
- package/dist/unrecognised-prompt.js.map +1 -0
- package/dist/update-check.d.ts +31 -0
- package/dist/update-check.js +47 -0
- package/dist/update-check.js.map +1 -1
- package/dist/update-install.d.ts +28 -2
- package/dist/update-install.js +22 -4
- package/dist/update-install.js.map +1 -1
- package/dist/update-launch.d.ts +46 -1
- package/dist/update-launch.js +146 -3
- package/dist/update-launch.js.map +1 -1
- package/dist/update-marker.d.ts +51 -0
- package/dist/update-marker.js +61 -0
- package/dist/update-marker.js.map +1 -1
- package/dist/update-preflight.d.ts +100 -0
- package/dist/update-preflight.js +264 -0
- package/dist/update-preflight.js.map +1 -0
- package/dist/updater-caller.d.ts +31 -0
- package/dist/updater-caller.js +109 -0
- package/dist/updater-caller.js.map +1 -0
- package/dist/usage/i18n-keys.d.ts +1 -1
- package/dist/usage/i18n-keys.js +1 -1
- package/dist/usage/i18n-keys.js.map +1 -1
- package/dist/usage/providers.d.ts +34 -5
- package/dist/usage/providers.js +160 -27
- package/dist/usage/providers.js.map +1 -1
- package/dist/usage/statusline-usage.d.ts +6 -2
- package/dist/usage/statusline-usage.js +10 -4
- package/dist/usage/statusline-usage.js.map +1 -1
- package/dist/view-api.d.ts +1 -1
- package/dist/view-api.js +38 -8
- package/dist/view-api.js.map +1 -1
- package/dist/wake-coordinator.d.ts +11 -0
- package/dist/wake-coordinator.js +38 -4
- package/dist/wake-coordinator.js.map +1 -1
- package/dist/web-api.d.ts +89 -4
- package/dist/web-api.js +551 -45
- package/dist/web-api.js.map +1 -1
- package/dist/web-auth.d.ts +2 -2
- package/dist/web-auth.js +9 -4
- package/dist/web-auth.js.map +1 -1
- package/dist/web-chat-history.d.ts +12 -1
- package/dist/web-chat-history.js +29 -7
- package/dist/web-chat-history.js.map +1 -1
- package/dist/web-commands.d.ts +27 -4
- package/dist/web-commands.js +19 -4
- package/dist/web-commands.js.map +1 -1
- package/dist/web-host-guard.d.ts +3 -11
- package/dist/web-host-guard.js +3 -12
- package/dist/web-host-guard.js.map +1 -1
- package/dist/web-images.d.ts +47 -0
- package/dist/web-images.js +169 -0
- package/dist/web-images.js.map +1 -0
- package/dist/web-login.d.ts +14 -0
- package/dist/web-login.js +4 -2
- package/dist/web-login.js.map +1 -1
- package/dist/web-mentions.d.ts +44 -0
- package/dist/web-mentions.js +75 -0
- package/dist/web-mentions.js.map +1 -0
- package/dist/web-prefs.d.ts +81 -0
- package/dist/web-prefs.js +297 -0
- package/dist/web-prefs.js.map +1 -0
- package/dist/web-preview.d.ts +14 -1
- package/dist/web-preview.js +35 -13
- package/dist/web-preview.js.map +1 -1
- package/dist/web-profile.d.ts +32 -0
- package/dist/web-profile.js +132 -0
- package/dist/web-profile.js.map +1 -0
- package/dist/web-reply-files.d.ts +45 -0
- package/dist/web-reply-files.js +223 -0
- package/dist/web-reply-files.js.map +1 -0
- package/dist/web-schedules.d.ts +12 -0
- package/dist/web-schedules.js +34 -0
- package/dist/web-schedules.js.map +1 -0
- package/dist/web-server-drain.d.ts +10 -0
- package/dist/web-server-drain.js +50 -0
- package/dist/web-server-drain.js.map +1 -0
- package/dist/web-session.d.ts +50 -1
- package/dist/web-session.js +63 -6
- package/dist/web-session.js.map +1 -1
- package/dist/web-settings-patch.d.ts +23 -0
- package/dist/web-settings-patch.js +77 -0
- package/dist/web-settings-patch.js.map +1 -0
- package/dist/web-shell-routes.d.ts +5 -1
- package/dist/web-shell-routes.js +10 -1
- package/dist/web-shell-routes.js.map +1 -1
- package/dist/web-upload.d.ts +17 -4
- package/dist/web-upload.js +64 -13
- package/dist/web-upload.js.map +1 -1
- package/dist/workflow-templates/default.md +1 -1
- package/package.json +1 -1
- package/templates/launchd.plist.ejs +3 -1
- package/templates/systemd.service.ejs +2 -1
package/dist/update-launch.js
CHANGED
|
@@ -1,9 +1,141 @@
|
|
|
1
1
|
/** Chat updates must survive the fleet's service cgroup being stopped (#1490 row 37). */
|
|
2
2
|
import { execFile } from "node:child_process";
|
|
3
3
|
import { randomBytes } from "node:crypto";
|
|
4
|
+
import { appendFileSync, existsSync, fchmodSync, openSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
4
5
|
import { readFile } from "node:fs/promises";
|
|
6
|
+
import { basename, dirname, isAbsolute, join } from "node:path";
|
|
5
7
|
import { promisify } from "node:util";
|
|
6
8
|
import { updateCommand } from "./update-dispatch.js";
|
|
9
|
+
import { maskSecrets } from "./log-steps.js";
|
|
10
|
+
/** How many bytes to read from the tail of the log when extracting a cause after the updater exits. */
|
|
11
|
+
const CAUSE_TAIL_BYTES = 8 * 1024;
|
|
12
|
+
/** How many bytes to cap the update.log file at (across all runs). */
|
|
13
|
+
export const UPDATE_LOG_FILE_CAP = 400 * 1024;
|
|
14
|
+
/**
|
|
15
|
+
* Path of the update log file (mode 0600; raw updater output is written directly — secrets are
|
|
16
|
+
* masked only when extracting the short cause shown in chat; the file itself is owner-readable only).
|
|
17
|
+
*/
|
|
18
|
+
export function updateLogPath(dataDir) {
|
|
19
|
+
return join(dataDir, "update.log");
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Extract a short human-readable cause from raw updater output.
|
|
23
|
+
* Prefers the last `npm ERR!`/`npm error` summary line or the last `✗` line.
|
|
24
|
+
* Falls back to the last non-blank line. Masks secrets and caps at ~300 chars.
|
|
25
|
+
*/
|
|
26
|
+
export function extractUpdateCause(output) {
|
|
27
|
+
// Lines starting with --- are log headers, not updater output.
|
|
28
|
+
const lines = output.split("\n").map(l => l.trimEnd()).filter(l => Boolean(l) && !l.startsWith("---"));
|
|
29
|
+
if (!lines.length)
|
|
30
|
+
return null;
|
|
31
|
+
// npm ERR! ends with !, a non-word char: \b does not anchor here. Use (?:\s|$) instead.
|
|
32
|
+
const npmErrRe = /^npm (ERR!|error)(?:\s|$)/i;
|
|
33
|
+
const npmLines = lines.filter(l => npmErrRe.test(l));
|
|
34
|
+
if (npmLines.length) {
|
|
35
|
+
// npm 10 always ends with "A complete log of this run can be found in: …". Skip that footer.
|
|
36
|
+
// Prefer the first `npm error code` line plus the next for context.
|
|
37
|
+
const codeIdx = npmLines.findIndex(l => /^npm (ERR!|error) code\s/i.test(l));
|
|
38
|
+
if (codeIdx >= 0) {
|
|
39
|
+
const summary = [npmLines[codeIdx], npmLines[codeIdx + 1]].filter(Boolean).join(" — ");
|
|
40
|
+
return maskSecrets(summary).slice(0, 300);
|
|
41
|
+
}
|
|
42
|
+
const meaningful = npmLines.filter(l => !/A complete log of this run can be found in/i.test(l));
|
|
43
|
+
const pick = meaningful.length ? meaningful[meaningful.length - 1] : npmLines[npmLines.length - 1];
|
|
44
|
+
return maskSecrets(pick).slice(0, 300);
|
|
45
|
+
}
|
|
46
|
+
const cross = lines.filter(l => /^\s*[✗✕×✘]/.test(l));
|
|
47
|
+
if (cross.length)
|
|
48
|
+
return maskSecrets(cross[cross.length - 1]).slice(0, 300);
|
|
49
|
+
return maskSecrets(lines[lines.length - 1]).slice(0, 300);
|
|
50
|
+
}
|
|
51
|
+
/** A version or dist-tag as the updater printed it, safe to put in a suggested command; else a placeholder. */
|
|
52
|
+
function updateTarget(output) {
|
|
53
|
+
const to = /Updating AgEnD v\S+ → v(\S+?)\.\.\./.exec(output)?.[1] ?? /Updating AgEnD to (\S+?)\.\.\./.exec(output)?.[1];
|
|
54
|
+
return to && /^[0-9A-Za-z][0-9A-Za-z.+-]*$/.test(to) ? to : "<version>";
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* #1829: the one-line fix for a failure AgEnD knows, from this run's output (a small lookup; anything else: null).
|
|
58
|
+
* - `agendGone`: the launched `agend` is no longer there (an install that removed it and did not put it back).
|
|
59
|
+
* - npm `ENOTEMPTY` on its rename: a staging directory left by an interrupted install. npm names the same one on every
|
|
60
|
+
* retry, so the retry fails the same way until it is removed — only that exact directory, and only when it is one of
|
|
61
|
+
* AgEnD's own (`@songsid/.agend…`), never a pattern.
|
|
62
|
+
* - "systemd does not know …": the activation proof could not read the user manager (#1804): the one-time manual hop.
|
|
63
|
+
*/
|
|
64
|
+
export function updateFixHint(output, opts = {}) {
|
|
65
|
+
const target = updateTarget(output);
|
|
66
|
+
if (opts.agendGone)
|
|
67
|
+
return `\`npm install -g @songsid/agend@${target}\``;
|
|
68
|
+
if (/^npm (?:ERR!|error) code ENOTEMPTY\b/im.test(output)) {
|
|
69
|
+
const named = /^npm (?:ERR!|error) dest (.+)$/im.exec(output)?.[1] ?? /ENOTEMPTY[^\n]*rename '[^'\n]+' -> '([^'\n]+)'/.exec(output)?.[1];
|
|
70
|
+
const ours = named && isAbsolute(named) && !/['"\s\\`$]/.test(named)
|
|
71
|
+
&& basename(dirname(named)) === "@songsid" && /^\.agend[A-Za-z0-9._-]*$/.test(basename(named));
|
|
72
|
+
if (ours)
|
|
73
|
+
return `remove the directory an interrupted install left, then update again: \`rm -rf '${named}' && agend update\``;
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
if (/systemd does not know /.test(output))
|
|
77
|
+
return `\`npm i -g @songsid/agend@${target} && agend restart\``;
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Rotate the log file if needed, write a run header, and return an open file descriptor
|
|
82
|
+
* for the child process to write to directly — not a pipe.
|
|
83
|
+
*
|
|
84
|
+
* Using an fd instead of a pipe means the updater can keep writing after the fleet process
|
|
85
|
+
* that spawned it has been stopped: there is no read end to close, so no EPIPE.
|
|
86
|
+
* The caller must closeSync(fd) after spawn so the parent's copy of the fd is released.
|
|
87
|
+
*
|
|
88
|
+
* Returns `null` when the log file cannot be opened (dataDir unwritable, disk full, etc.).
|
|
89
|
+
* In that case the caller should fall back to `stdio: "ignore"` and omit the log note.
|
|
90
|
+
*/
|
|
91
|
+
export function openUpdateLog(logPath, header) {
|
|
92
|
+
// Rotate BEFORE opening the fd the child will use (never write to the same inode concurrently).
|
|
93
|
+
try {
|
|
94
|
+
if (existsSync(logPath) && statSync(logPath).size > UPDATE_LOG_FILE_CAP / 2) {
|
|
95
|
+
const old = readFileSync(logPath);
|
|
96
|
+
writeFileSync(logPath, old.subarray(Math.max(0, old.length - UPDATE_LOG_FILE_CAP / 2)));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
catch { /* best-effort */ }
|
|
100
|
+
try {
|
|
101
|
+
appendFileSync(logPath, `${header}\n`, { mode: 0o600 });
|
|
102
|
+
}
|
|
103
|
+
catch { /* best-effort */ }
|
|
104
|
+
let fd;
|
|
105
|
+
try {
|
|
106
|
+
fd = openSync(logPath, "a", 0o600);
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return null; // caller falls back to stdio: "ignore" and no log note
|
|
110
|
+
}
|
|
111
|
+
// fchmod: mode param of openSync only applies to new files; existing files keep their mode.
|
|
112
|
+
try {
|
|
113
|
+
fchmodSync(fd, 0o600);
|
|
114
|
+
}
|
|
115
|
+
catch { /* best-effort */ }
|
|
116
|
+
// Record the offset so readRunCause only reads this run's output, not previous runs.
|
|
117
|
+
const offset = (() => { try {
|
|
118
|
+
return statSync(logPath).size;
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
return 0;
|
|
122
|
+
} })();
|
|
123
|
+
return { fd, offset };
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Read only this run's output from the log (from `offset`): its tail, for the cause and the fix.
|
|
127
|
+
* Prevents a run with no output from picking up the previous run's error as the cause.
|
|
128
|
+
*/
|
|
129
|
+
function readRunTail(logPath, offset) {
|
|
130
|
+
try {
|
|
131
|
+
const buf = readFileSync(logPath);
|
|
132
|
+
const runBytes = buf.subarray(offset);
|
|
133
|
+
return runBytes.subarray(Math.max(0, runBytes.length - CAUSE_TAIL_BYTES)).toString("utf8");
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
7
139
|
export const defaultUpdateLaunchDeps = {
|
|
8
140
|
platform: process.platform,
|
|
9
141
|
cgroup: async () => {
|
|
@@ -89,18 +221,29 @@ export async function resolveUpdateLaunch(agend, deps = defaultUpdateLaunchDeps)
|
|
|
89
221
|
] };
|
|
90
222
|
}
|
|
91
223
|
/** Spawn/manager refusal and nonzero updater exit are visible; exit 75 is the existing pending hand-off. */
|
|
92
|
-
export function watchUpdateLaunch(child, fail
|
|
224
|
+
export function watchUpdateLaunch(child, fail, logPath,
|
|
225
|
+
/** Byte offset into the log file at which this run's output begins. */
|
|
226
|
+
logOffset,
|
|
227
|
+
/** The `agend` the updater runs: there at launch and gone after a failure → reinstalling is the fix (#1829). */
|
|
228
|
+
agendPath) {
|
|
93
229
|
let reported = false;
|
|
230
|
+
const agendAtLaunch = agendPath !== undefined && existsSync(agendPath);
|
|
94
231
|
const report = (reason) => {
|
|
95
232
|
if (reported)
|
|
96
233
|
return;
|
|
97
234
|
reported = true;
|
|
98
|
-
|
|
235
|
+
const tail = logPath != null && logOffset != null ? readRunTail(logPath, logOffset) : null;
|
|
236
|
+
const cause = tail === null ? null : extractUpdateCause(tail);
|
|
237
|
+
const logNote = logPath ? ` Full log: ${logPath}.` : "";
|
|
238
|
+
const detail = cause ? ` Cause: ${cause}.${logNote}` : logNote;
|
|
239
|
+
const fix = updateFixHint(tail ?? "", { agendGone: agendAtLaunch && !existsSync(agendPath) });
|
|
240
|
+
fail(`/update could not complete (${reason}).${detail} ${fix ? `Fix: ${fix}` : "Run `agend update` from a host shell."}`);
|
|
99
241
|
};
|
|
100
242
|
child.once("error", () => report("updater launch failed"));
|
|
101
243
|
child.once("exit", (code, signal) => {
|
|
102
|
-
if (signal || (code !== 0 && code !== 75))
|
|
244
|
+
if (signal || (code !== 0 && code !== 75)) {
|
|
103
245
|
report(signal ? "updater was interrupted" : `updater exited ${code ?? "without a status"}`);
|
|
246
|
+
}
|
|
104
247
|
});
|
|
105
248
|
}
|
|
106
249
|
//# sourceMappingURL=update-launch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-launch.js","sourceRoot":"","sources":["../src/update-launch.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"update-launch.js","sourceRoot":"","sources":["../src/update-launch.ts"],"names":[],"mappings":"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AK,EAAE,CAAC,EAAE,CAAC;YAC1C,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,kBAAkB,IAAI,IAAI,kBAAkB,EAAE,CAAC,CAAC;QAC9F,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/update-marker.d.ts
CHANGED
|
@@ -20,7 +20,55 @@ export interface UpdateProgressState {
|
|
|
20
20
|
version?: string;
|
|
21
21
|
error?: string;
|
|
22
22
|
failedStage?: UpdateProgressStage;
|
|
23
|
+
/** Non-fatal cleanup note (e.g. old system copy left behind, #1660). */
|
|
24
|
+
warning?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Verbatim copy-paste cleanup command. Unlike prose it is never whitespace-
|
|
27
|
+
* normalized or sliced: a path with double spaces or a long absolute npm
|
|
28
|
+
* path must survive byte-exact (#1660 review). Bounded by the platform
|
|
29
|
+
* (it names one absolute path), not by a prose length cap.
|
|
30
|
+
*/
|
|
31
|
+
cleanupCommand?: string;
|
|
32
|
+
/** #1660: the retire outcome is still owed (set before restart) or recorded. */
|
|
33
|
+
cleanup?: "pending" | "done";
|
|
23
34
|
}
|
|
35
|
+
/** Which update receipt a cleanup outcome belongs to (owner fence, #1660). */
|
|
36
|
+
export interface UpdateReceipt {
|
|
37
|
+
startedAt: number;
|
|
38
|
+
messageId: string;
|
|
39
|
+
operation: UpdateProgressOperation;
|
|
40
|
+
}
|
|
41
|
+
export declare function updateReceiptOf(marker: (UpdateMarker & {
|
|
42
|
+
progress: UpdateProgressState;
|
|
43
|
+
}) | null): UpdateReceipt | null;
|
|
44
|
+
/**
|
|
45
|
+
* #1737 review: a marker's identity — when it was started and, for a chat-tracked one, its receipt — so a reader can
|
|
46
|
+
* tell "still the marker I adopted" from a newer one written since (a `/restart full`, a new `/update`).
|
|
47
|
+
*/
|
|
48
|
+
export interface UpdateMarkerIdentity {
|
|
49
|
+
startedAt: number;
|
|
50
|
+
receipt: UpdateReceipt | null;
|
|
51
|
+
}
|
|
52
|
+
export declare function updateMarkerIdentity(dataDir: string): UpdateMarkerIdentity | null;
|
|
53
|
+
/** The same marker: started at the same time, with the same receipt (or none on both). */
|
|
54
|
+
export declare function sameUpdateMarker(a: UpdateMarkerIdentity | null, b: UpdateMarkerIdentity | null): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Mark the current update as owing its retire outcome, before the restart
|
|
57
|
+
* that may let a new fleet consume this receipt. Returns the receipt the
|
|
58
|
+
* later write must still match.
|
|
59
|
+
*/
|
|
60
|
+
export declare function markCleanupPending(dataDir: string): UpdateReceipt | null;
|
|
61
|
+
/**
|
|
62
|
+
* Record a retire outcome against the receipt captured before the restart.
|
|
63
|
+
* Refuses when the marker is gone (the new fleet already consumed it) or
|
|
64
|
+
* belongs to another operation (e.g. a later full-restart adopted it) — the
|
|
65
|
+
* warning was already printed to the updater's own output, so refusing here
|
|
66
|
+
* loses nothing the operator saw.
|
|
67
|
+
*/
|
|
68
|
+
export declare function writeCleanupOutcome(dataDir: string, receipt: UpdateReceipt | null, outcome: {
|
|
69
|
+
warning?: string;
|
|
70
|
+
cleanupCommand?: string;
|
|
71
|
+
} | null): boolean;
|
|
24
72
|
export interface UpdateMarker {
|
|
25
73
|
startedAt: number;
|
|
26
74
|
pid: number;
|
|
@@ -43,6 +91,9 @@ export declare function readUpdateProgress(dataDir: string): (UpdateMarker & {
|
|
|
43
91
|
export declare function setUpdateProgressStage(dataDir: string, stage: UpdateProgressStage, details?: {
|
|
44
92
|
version?: string;
|
|
45
93
|
error?: string;
|
|
94
|
+
warning?: string;
|
|
95
|
+
cleanupCommand?: string;
|
|
96
|
+
cleanup?: "pending" | "done";
|
|
46
97
|
}): boolean;
|
|
47
98
|
/** Called by `agend update` before it touches anything. */
|
|
48
99
|
export declare function markUpdateInProgress(dataDir: string, now?: number, pid?: number): void;
|
package/dist/update-marker.js
CHANGED
|
@@ -23,6 +23,64 @@ import { atomicWriteFileSync } from "./atomic-write.js";
|
|
|
23
23
|
*/
|
|
24
24
|
export const UPDATE_MARKER_MAX_AGE_MS = 15 * 60_000;
|
|
25
25
|
const FILE = "update-in-progress.json";
|
|
26
|
+
export function updateReceiptOf(marker) {
|
|
27
|
+
if (!marker?.progress?.target?.messageId)
|
|
28
|
+
return null;
|
|
29
|
+
return { startedAt: marker.startedAt, messageId: marker.progress.target.messageId, operation: updateProgressOperation(marker.progress) };
|
|
30
|
+
}
|
|
31
|
+
function sameReceipt(a, b) {
|
|
32
|
+
return !!a && !!b && a.startedAt === b.startedAt && a.messageId === b.messageId && a.operation === b.operation;
|
|
33
|
+
}
|
|
34
|
+
export function updateMarkerIdentity(dataDir) {
|
|
35
|
+
const marker = readMarker(dataDir);
|
|
36
|
+
if (!marker)
|
|
37
|
+
return null;
|
|
38
|
+
return { startedAt: marker.startedAt, receipt: marker.progress ? updateReceiptOf(marker) : null };
|
|
39
|
+
}
|
|
40
|
+
/** The same marker: started at the same time, with the same receipt (or none on both). */
|
|
41
|
+
export function sameUpdateMarker(a, b) {
|
|
42
|
+
if (!a || !b || a.startedAt !== b.startedAt)
|
|
43
|
+
return false;
|
|
44
|
+
return a.receipt === null ? b.receipt === null : sameReceipt(a.receipt, b.receipt);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Mark the current update as owing its retire outcome, before the restart
|
|
48
|
+
* that may let a new fleet consume this receipt. Returns the receipt the
|
|
49
|
+
* later write must still match.
|
|
50
|
+
*/
|
|
51
|
+
export function markCleanupPending(dataDir) {
|
|
52
|
+
const marker = readUpdateProgress(dataDir);
|
|
53
|
+
const receipt = updateReceiptOf(marker);
|
|
54
|
+
if (!receipt || !marker)
|
|
55
|
+
return null;
|
|
56
|
+
marker.pid = process.pid;
|
|
57
|
+
marker.progress = { ...marker.progress, cleanup: "pending" };
|
|
58
|
+
return writeMarker(dataDir, marker) ? receipt : null;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Record a retire outcome against the receipt captured before the restart.
|
|
62
|
+
* Refuses when the marker is gone (the new fleet already consumed it) or
|
|
63
|
+
* belongs to another operation (e.g. a later full-restart adopted it) — the
|
|
64
|
+
* warning was already printed to the updater's own output, so refusing here
|
|
65
|
+
* loses nothing the operator saw.
|
|
66
|
+
*/
|
|
67
|
+
export function writeCleanupOutcome(dataDir, receipt, outcome) {
|
|
68
|
+
if (!receipt)
|
|
69
|
+
return false;
|
|
70
|
+
const marker = readUpdateProgress(dataDir);
|
|
71
|
+
if (!marker || !sameReceipt(updateReceiptOf(marker), receipt))
|
|
72
|
+
return false;
|
|
73
|
+
marker.pid = process.pid;
|
|
74
|
+
marker.progress = {
|
|
75
|
+
...marker.progress,
|
|
76
|
+
// Prose follows the same rule as setUpdateProgressStage; the command is
|
|
77
|
+
// verbatim so quoted paths survive byte-exact.
|
|
78
|
+
...(outcome?.warning !== undefined ? { warning: outcome.warning.replace(/\s+/g, " ").trim().slice(0, 300) } : {}),
|
|
79
|
+
...(outcome?.cleanupCommand !== undefined ? { cleanupCommand: outcome.cleanupCommand } : {}),
|
|
80
|
+
cleanup: "done",
|
|
81
|
+
};
|
|
82
|
+
return writeMarker(dataDir, marker);
|
|
83
|
+
}
|
|
26
84
|
function markerPath(dataDir) {
|
|
27
85
|
return join(dataDir, FILE);
|
|
28
86
|
}
|
|
@@ -91,6 +149,9 @@ export function setUpdateProgressStage(dataDir, stage, details = {}) {
|
|
|
91
149
|
stage,
|
|
92
150
|
...(details.version !== undefined ? { version: details.version } : {}),
|
|
93
151
|
...(details.error !== undefined ? { error: details.error.replace(/\s+/g, " ").trim().slice(0, 300) } : {}),
|
|
152
|
+
...(details.warning !== undefined ? { warning: details.warning.replace(/\s+/g, " ").trim().slice(0, 300) } : {}),
|
|
153
|
+
...(details.cleanupCommand !== undefined ? { cleanupCommand: details.cleanupCommand } : {}),
|
|
154
|
+
...(details.cleanup !== undefined ? { cleanup: details.cleanup } : {}),
|
|
94
155
|
...(stage === "failed" ? { failedStage: previousStage } : {}),
|
|
95
156
|
};
|
|
96
157
|
return writeMarker(dataDir, marker);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-marker.js","sourceRoot":"","sources":["../src/update-marker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAc,UAAU,EAAiB,MAAM,SAAS,CAAC;AAC1F,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,GAAG,MAAM,CAAC;AAEpD,MAAM,IAAI,GAAG,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"update-marker.js","sourceRoot":"","sources":["../src/update-marker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAc,UAAU,EAAiB,MAAM,SAAS,CAAC;AAC1F,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,GAAG,MAAM,CAAC;AAEpD,MAAM,IAAI,GAAG,yBAAyB,CAAC;AAgDvC,MAAM,UAAU,eAAe,CAAC,MAAiE;IAC/F,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS;QAAE,OAAO,IAAI,CAAC;IACtD,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,uBAAuB,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;AAC3I,CAAC;AAED,SAAS,WAAW,CAAC,CAAuB,EAAE,CAAuB;IACnE,OAAO,CAAC,CAAC,CAAC,I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,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC/D,CAAC,CAAC;AACL,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,iBAAiB,CAAC,OAAe;IAC/C,IAAI,CAAC;QAAC,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;IAAC,CAAC;IAAC,MAAM,CAAC,CAAC,wBAAwB,CAAC,CAAC;AAC7E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAe,EAAE,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE;IAClE,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IACnD,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACnC,IAAI,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAC1B,IAAI,MAAM,CAAC,QAAQ,EAAE,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,EAAE,KAAK,KAAK,UAAU;QAAE,OAAO,KAAK,CAAC;IAC/F,8EAA8E;IAC9E,MAAM,GAAG,GAAG,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC;IACnC,OAAO,GAAG,IAAI,CAAC,IAAI,GAAG,GAAG,wBAAwB,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export interface RuntimeHost {
|
|
2
|
+
platform: string;
|
|
3
|
+
arch: string;
|
|
4
|
+
id: string;
|
|
5
|
+
glibc: string | null;
|
|
6
|
+
darwinRelease: string | null;
|
|
7
|
+
}
|
|
8
|
+
export interface RuntimePlatform {
|
|
9
|
+
hostPlatform(probe?: Partial<RuntimeHost>): RuntimeHost;
|
|
10
|
+
runtimeSupport(host: RuntimeHost): {
|
|
11
|
+
supported: boolean;
|
|
12
|
+
reason: string | null;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/** The one answer to "can this host run AgEnD's bundled Node?", shared with preinstall, postinstall and the launcher. */
|
|
16
|
+
export declare const runtimePlatform: RuntimePlatform;
|
|
17
|
+
/** What the release about to be installed asks for: its Node range, and the runtime it pins per host id. */
|
|
18
|
+
export interface TargetManifest {
|
|
19
|
+
version: string;
|
|
20
|
+
engines: string | null;
|
|
21
|
+
runtimePins: Record<string, string>;
|
|
22
|
+
}
|
|
23
|
+
/** The npm arguments that read a release's requirements; the caller runs them with the npm that installs it. */
|
|
24
|
+
export declare function manifestQuery(spec: string): string[];
|
|
25
|
+
/**
|
|
26
|
+
* The target's own requirements, read by `read` — which runs `npm <manifestQuery(spec)>` with the npm, environment and
|
|
27
|
+
* registry the install uses and returns its stdout, or null when it fails. The spec must be the one npm installs, and
|
|
28
|
+
* it must name the exact version (`@songsid/agend@<version>`); the answer must be that version. Otherwise: null.
|
|
29
|
+
*/
|
|
30
|
+
export declare function lookupTargetManifest(spec: string, version: string, read: (args: string[]) => string | null): TargetManifest | null;
|
|
31
|
+
/** The Node the release would run on when its bundled runtime does not apply. */
|
|
32
|
+
export type SystemNode = {
|
|
33
|
+
kind: "version";
|
|
34
|
+
version: string;
|
|
35
|
+
path?: string | null;
|
|
36
|
+
label: string;
|
|
37
|
+
} | {
|
|
38
|
+
kind: "none";
|
|
39
|
+
} | {
|
|
40
|
+
kind: "unknown";
|
|
41
|
+
note: string;
|
|
42
|
+
};
|
|
43
|
+
export type UpdateTargetVerdict = {
|
|
44
|
+
kind: "runtime";
|
|
45
|
+
host: string;
|
|
46
|
+
pin: string;
|
|
47
|
+
} | {
|
|
48
|
+
kind: "system";
|
|
49
|
+
node: string;
|
|
50
|
+
label: string;
|
|
51
|
+
} | {
|
|
52
|
+
kind: "refuse";
|
|
53
|
+
message: string;
|
|
54
|
+
summary: string;
|
|
55
|
+
} | {
|
|
56
|
+
kind: "unknown";
|
|
57
|
+
note: string;
|
|
58
|
+
};
|
|
59
|
+
/** Which Node the target will run on here, and whether that Node satisfies the target's engines. */
|
|
60
|
+
export declare function evaluateUpdateTarget(input: {
|
|
61
|
+
manifest: TargetManifest | null;
|
|
62
|
+
host: RuntimeHost;
|
|
63
|
+
platform?: RuntimePlatform;
|
|
64
|
+
system: SystemNode;
|
|
65
|
+
}): UpdateTargetVerdict;
|
|
66
|
+
/** Where the update runs its commands: the install environment (`run`) and the npm binary the install invokes. */
|
|
67
|
+
export interface PreflightEnv {
|
|
68
|
+
run(argv: string[], timeoutMs: number): {
|
|
69
|
+
status: number | null;
|
|
70
|
+
stdout: string;
|
|
71
|
+
};
|
|
72
|
+
npm: string;
|
|
73
|
+
}
|
|
74
|
+
/** The version and path of the `node` the environment resolves; exit 127 when there is none. */
|
|
75
|
+
export declare const NODE_PROBE_SCRIPT = "command -v node >/dev/null 2>&1 || exit 127; exec node -p \"process.versions.node + ' ' + process.execPath\"";
|
|
76
|
+
/** The Node the release's `#!/usr/bin/env node` resolves to in `env` (`label` names it in messages). */
|
|
77
|
+
export declare function probeSystemNode(env: PreflightEnv, label: string): SystemNode;
|
|
78
|
+
/**
|
|
79
|
+
* The whole check, run where the install runs: the requirements of `spec` (which must be `@songsid/agend@<version>`)
|
|
80
|
+
* from `env.npm`, and the Node `env` resolves — both read the way the install that follows reads them.
|
|
81
|
+
*/
|
|
82
|
+
export declare function preflightUpdate(env: PreflightEnv, spec: string, version: string, label: string, host?: RuntimeHost): UpdateTargetVerdict;
|
|
83
|
+
/**
|
|
84
|
+
* The check an nvm install runs once nvm has selected its Node 22 (UpdateInstallPlan.preflight): on that Node, with that
|
|
85
|
+
* Node's npm. A refusal is printed in full and returned as the update's outcome; unknown is a note and the install goes on.
|
|
86
|
+
*/
|
|
87
|
+
export declare function installPreflight(spec: string, version: string, label: string, out: {
|
|
88
|
+
log(message: string): void;
|
|
89
|
+
error(message: string): void;
|
|
90
|
+
}, host?: RuntimeHost): (env: PreflightEnv) => {
|
|
91
|
+
ok: true;
|
|
92
|
+
} | {
|
|
93
|
+
ok: false;
|
|
94
|
+
message: string;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Does Node `version` (stable x.y.z) satisfy npm range `range`? true/false as semver would answer, or null when the
|
|
98
|
+
* version or the range is outside what this parser reads exactly.
|
|
99
|
+
*/
|
|
100
|
+
export declare function satisfiesNodeRange(version: string, range: string): boolean | null;
|