@sirenodeck/sirenodeck 0.1.1-alpha.0 → 0.2.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.
Files changed (84) hide show
  1. package/LICENSE +674 -21
  2. package/bin/dev.js +12 -2
  3. package/dist/main.mjs +3655 -1657
  4. package/package.json +18 -16
  5. package/src/api/protocol-internal.ts +16 -1
  6. package/src/assets/logo.png +0 -0
  7. package/src/assets/logo72x72.png +0 -0
  8. package/src/builtin-addons/brightness/buttons/brightness/config.ts +12 -2
  9. package/src/builtin-addons/coding-agents/buttons/agent/config.ts +5 -1
  10. package/src/builtin-addons/coding-agents/buttons/summary/config.ts +15 -3
  11. package/src/builtin-addons/coding-agents/buttons/summary/frontend.tsx +3 -3
  12. package/src/builtin-addons/coding-agents/global/backend.ts +56 -34
  13. package/src/builtin-addons/coding-agents/providers/opencode.ts +4 -5
  14. package/src/builtin-addons/core/buttons/action/config.ts +5 -2
  15. package/src/builtin-addons/core/buttons/change-deck/config.ts +6 -3
  16. package/src/builtin-addons/core/buttons/media-sample/config.ts +2 -2
  17. package/src/builtin-addons/core/buttons/toggle/config.ts +26 -9
  18. package/src/builtin-addons/date-time/buttons/custom/config.ts +5 -1
  19. package/src/builtin-addons/date-time/buttons/date/config.ts +2 -2
  20. package/src/builtin-addons/date-time/buttons/time/config.ts +5 -1
  21. package/src/builtin-addons/emoji-selector/buttons/category/config.ts +3 -3
  22. package/src/builtin-addons/emoji-selector/buttons/emoji/config.ts +5 -2
  23. package/src/builtin-addons/emoji-selector/support.ts +5 -2
  24. package/src/builtin-addons/global-services.ts +23 -0
  25. package/src/builtin-addons/internal-settings/buttons/app-info/config.ts +2 -1
  26. package/src/builtin-addons/internal-settings/buttons/brightness-down/config.ts +6 -1
  27. package/src/builtin-addons/internal-settings/buttons/brightness-up/config.ts +6 -1
  28. package/src/builtin-addons/media/backend.ts +54 -0
  29. package/src/builtin-addons/media/buttons/volume/volume-down/config.ts +1 -1
  30. package/src/builtin-addons/media/buttons/volume/volume-up/config.ts +1 -1
  31. package/src/builtin-addons/session/buttons/time/config.ts +1 -1
  32. package/src/builtin-addons/system-status/buttons/system-status/schemas.ts +32 -6
  33. package/src/builtin-addons/system-status/manifest.ts +49 -0
  34. package/src/builtin-addons/value-display/buttons/value-display/config.ts +23 -9
  35. package/src/builtin-addons/weather/buttons/weather/config.ts +11 -6
  36. package/src/cli/coding-agents-onboarding.ts +181 -34
  37. package/src/cli/commands/command-executor.ts +61 -0
  38. package/src/cli/commands/emulator-mode.ts +17 -2
  39. package/src/cli/commands/network-bind.ts +13 -9
  40. package/src/cli/commands/restart.ts +15 -5
  41. package/src/cli/commands/run.ts +174 -317
  42. package/src/cli/commands/service/render-template.ts +10 -0
  43. package/src/cli/commands/skills.ts +106 -0
  44. package/src/cli/commands/start.ts +39 -9
  45. package/src/cli/commands/stop.ts +3 -2
  46. package/src/cli/commands/system-requirements.ts +1 -0
  47. package/src/cli/index.ts +16 -3
  48. package/src/cli/main.ts +15 -2
  49. package/src/cli/package-manager.ts +6 -0
  50. package/src/cli/skills-first-run.ts +46 -0
  51. package/src/cli/startup-display.ts +35 -17
  52. package/src/config/mutation.ts +13 -1
  53. package/src/config/schemas.ts +3 -3
  54. package/src/config/validation.ts +7 -1
  55. package/src/core/icon-asset-registry.ts +11 -6
  56. package/src/deck/addon-handler-bridge.ts +246 -176
  57. package/src/deck/deck-config.ts +11 -2
  58. package/src/deck/deck-presentation-publisher.ts +116 -0
  59. package/src/deck/index.ts +13 -0
  60. package/src/deck/inject-config-ui-button.ts +23 -0
  61. package/src/deck/methods.ts +23 -0
  62. package/src/deck/position-settings-version-button.ts +20 -0
  63. package/src/deck/runtime/host-policy-coordinator.ts +186 -0
  64. package/src/deck/runtime/runtime.ts +123 -250
  65. package/src/deck/system-back-injection.ts +2 -1
  66. package/src/device/reconnecting.ts +8 -1
  67. package/src/index.ts +1 -2
  68. package/src/outputClient/emulator.ts +13 -0
  69. package/src/outputClient/index.ts +8 -0
  70. package/src/outputClient/real.ts +40 -45
  71. package/src/outputClient/remote-mirror.ts +77 -0
  72. package/src/outputClient/types.ts +2 -0
  73. package/src/render/editor-handler.ts +12 -1
  74. package/src/render/frontend-bridge-url.ts +10 -0
  75. package/src/render/push-startup-screen.ts +76 -0
  76. package/src/render/ws-bridge.ts +2 -0
  77. package/src/system/providers/active-app/capture-file.ts +61 -0
  78. package/src/system/providers/active-app/wayland-gnome.ts +26 -10
  79. package/src/system/providers/active-app.ts +6 -0
  80. package/src/system/providers/clipboard/darwin.ts +28 -4
  81. package/src/system/providers/url.ts +57 -0
  82. package/src/util/logger.ts +19 -3
  83. package/src/version.ts +3 -1
  84. package/src/vite/virtual-modules.ts +12 -6
@@ -0,0 +1,61 @@
1
+ import { spawn as nodeSpawn } from "node:child_process"
2
+
3
+ import type { CommandExecutor } from "@/system/providers/shared"
4
+
5
+ type SpawnedProcess = ReturnType<typeof nodeSpawn>
6
+ type SpawnCommand = (
7
+ command: string,
8
+ args: string[],
9
+ options: { stdio: ["pipe", "pipe", "pipe"] },
10
+ ) => SpawnedProcess
11
+
12
+ export const createCommandExecutor = (
13
+ spawnCommand: SpawnCommand = nodeSpawn,
14
+ ): CommandExecutor => ({
15
+ async run(command, args, execOptions) {
16
+ const timeoutMs = execOptions?.timeoutMs
17
+ return await new Promise((resolve) => {
18
+ const proc = spawnCommand(command, [...args], {
19
+ stdio: ["pipe", "pipe", "pipe"],
20
+ })
21
+ let stdout = ""
22
+ let stderr = ""
23
+ let timedOut = false
24
+ let killTimer: ReturnType<typeof setTimeout> | undefined
25
+ proc.stdout?.on("data", (chunk: Buffer) => {
26
+ stdout += chunk.toString()
27
+ })
28
+ proc.stderr?.on("data", (chunk: Buffer) => {
29
+ stderr += chunk.toString()
30
+ })
31
+ const onExit = (code: number | null): void => {
32
+ if (timeoutMs !== undefined) return
33
+ finish(code)
34
+ }
35
+ const finish = (code: number | null): void => {
36
+ if (killTimer !== undefined) clearTimeout(killTimer)
37
+ resolve({
38
+ exitCode: timedOut ? -1 : (code ?? -1),
39
+ stdout,
40
+ stderr,
41
+ })
42
+ }
43
+ proc.on("exit", onExit)
44
+ if (timeoutMs !== undefined) proc.on("close", finish)
45
+ proc.on("error", (err) => {
46
+ if (killTimer !== undefined) clearTimeout(killTimer)
47
+ resolve({
48
+ exitCode: -1,
49
+ stdout,
50
+ stderr: stderr ? `${stderr}\n${err.message}` : err.message,
51
+ })
52
+ })
53
+ if (timeoutMs !== undefined && timeoutMs > 0) {
54
+ killTimer = setTimeout(() => {
55
+ timedOut = true
56
+ proc.kill("SIGKILL")
57
+ }, timeoutMs)
58
+ }
59
+ })
60
+ },
61
+ })
@@ -12,8 +12,23 @@ import {
12
12
  readAndValidateManifest,
13
13
  } from "@/themes/loader"
14
14
 
15
- export const DEFAULT_FRONTEND_PORT = 5180
16
- export const DEFAULT_CONFIG_UI_PORT = 52938
15
+ const configuredPort = (name: string, fallback: number): number => {
16
+ const port = Number.parseInt(process.env[name] ?? "", 10)
17
+ return Number.isInteger(port) && port > 0 && port <= 65535 ? port : fallback
18
+ }
19
+
20
+ export const DEFAULT_FRONTEND_PORT = configuredPort(
21
+ "SIRENODECK_FRONTEND_PORT",
22
+ 5180,
23
+ )
24
+ export const DEFAULT_CONFIG_UI_PORT = configuredPort(
25
+ "SIRENODECK_CONFIG_UI_PORT",
26
+ 52938,
27
+ )
28
+ export const DEFAULT_BRIDGE_PORT = configuredPort(
29
+ "SIRENODECK_BRIDGE_PORT",
30
+ 52937,
31
+ )
17
32
  const DEFAULT_TIMEOUT_MS = 30_000
18
33
  // eslint-disable-next-line no-control-regex
19
34
  const ANSI_REGEX = /\u001b\[[0-9;]*m/g
@@ -16,10 +16,11 @@ export interface SelectLanAddressesOptions {
16
16
  readonly networkInterfaces?: typeof networkInterfaces
17
17
  }
18
18
 
19
- export const TUNNEL_INTERFACE_PATTERN = /^(utun|tun|tap|vpn|tailscale|wg)/i
20
19
  export const PHYSICAL_ETHERNET_PATTERN = /^en/i
21
20
  export const PHYSICAL_LINUX_ETHERNET_PATTERN = /^eth/i
22
21
  export const NON_TUNNEL_WIRELESS_PATTERN = /^wlan/i
22
+ export const VIRTUAL_INTERFACE_PATTERN =
23
+ /^(?:docker\d*|br-|bridge\d*|veth|virbr|vmnet|vboxnet|tailscale|utun|tun\d*|tap\d*|wg\d*|zt\w*|cni\d*|flannel|podman|lxcbr|vEthernet|loopback|awdl\d*|llw\d*|anpi\d*|gif\d*|stf\d*)/i
23
24
 
24
25
  const LAN_INTERFACE_PRIORITY: ReadonlyArray<{
25
26
  readonly pattern: RegExp
@@ -27,8 +28,10 @@ const LAN_INTERFACE_PRIORITY: ReadonlyArray<{
27
28
  }> = [
28
29
  { pattern: PHYSICAL_ETHERNET_PATTERN, score: 0 },
29
30
  { pattern: PHYSICAL_LINUX_ETHERNET_PATTERN, score: 0 },
31
+ { pattern: /^wlp/i, score: 1 },
30
32
  { pattern: NON_TUNNEL_WIRELESS_PATTERN, score: 1 },
31
- { pattern: TUNNEL_INTERFACE_PATTERN, score: 3 },
33
+ { pattern: /^wi[- ]?fi$/i, score: 1 },
34
+ { pattern: /^ethernet/i, score: 0 },
32
35
  ]
33
36
 
34
37
  const computePriority = (interfaceName: string): number => {
@@ -55,18 +58,19 @@ export const selectLanAddresses = (
55
58
 
56
59
  const candidates: LanAddress[] = []
57
60
  for (const interfaceName of Object.keys(interfaces)) {
61
+ if (VIRTUAL_INTERFACE_PATTERN.test(interfaceName)) continue
58
62
  const list = interfaces[interfaceName]
59
63
  if (list === undefined) continue
60
- const first = list[0]
61
- if (first === undefined) continue
62
- if (!isValidIPv4LanAddress(first)) continue
63
- candidates.push({ address: first.address, interfaceName })
64
+ const address = list.find(isValidIPv4LanAddress)
65
+ if (address === undefined) continue
66
+ candidates.push({ address: address.address, interfaceName })
64
67
  }
65
68
 
66
- return candidates.sort(
69
+ const selected = candidates.sort(
67
70
  (a, b) =>
68
71
  computePriority(a.interfaceName) - computePriority(b.interfaceName),
69
- )
72
+ )[0]
73
+ return selected === undefined ? [] : [selected]
70
74
  }
71
75
 
72
76
  export interface PrintConfigUiBannerOptions {
@@ -95,7 +99,7 @@ export async function printConfigUiBanner(
95
99
  }
96
100
 
97
101
  output("\n Config UI (LAN):\n")
98
- for (const entry of lanAddresses) {
102
+ for (const entry of lanAddresses.slice(0, 1)) {
99
103
  const url = configUiUrlFn(entry.address)
100
104
  if (qrGenerate !== undefined) {
101
105
  output("\n")
@@ -69,7 +69,17 @@ export const restart = async (options: RestartOptions): Promise<void> => {
69
69
  const snapshot = snapshotDaemonLog()
70
70
  const logPath = logPathFor()
71
71
  await stop({ logger })
72
- await start(startOptions)
72
+ const launchResult = await start(startOptions)
73
+ if (launchResult !== "started") {
74
+ if (launchResult === "blocked") {
75
+ const message =
76
+ "Restart stopped before the daemon was launched. Resolve the requirement warning above, then retry."
77
+ logger.warn(message)
78
+ process.exitCode = 1
79
+ printRestartFailed(message)
80
+ }
81
+ return
82
+ }
73
83
  const outcome: StartOutcome = await waitForFullStart({
74
84
  port: startOptions.port ?? 52937,
75
85
  tcpTimeoutMs: 30_000,
@@ -82,8 +92,8 @@ export const restart = async (options: RestartOptions): Promise<void> => {
82
92
  printRestartComplete()
83
93
  } else {
84
94
  const message = outcome.tcpReady
85
- ? "daemon: TCP bound but runtime state did not appear in 5s"
86
- : "daemon: port 52937 did not accept connections in 30s"
95
+ ? "The daemon accepted connections but did not finish startup. Check `sirenodeck logs` for the cause."
96
+ : `SirenoDeck did not reopen its WebSocket on 127.0.0.1:${startOptions.port ?? 52937} within 30 seconds. Check \`sirenodeck logs\`; if another app owns the port, stop it or choose another with \`--port <port>\`.`
87
97
  logger.warn(message)
88
98
  process.exitCode = 1
89
99
  printRestartFailed(message)
@@ -126,8 +136,8 @@ export const restart = async (options: RestartOptions): Promise<void> => {
126
136
  printRestartComplete()
127
137
  } else {
128
138
  const message = outcome.tcpReady
129
- ? "daemon: TCP bound but runtime state did not appear in 5s"
130
- : "daemon: port 52937 did not accept connections in 30s"
139
+ ? "The daemon accepted connections but did not finish startup. Check `sirenodeck logs` for the cause."
140
+ : `SirenoDeck did not reopen its WebSocket on 127.0.0.1:${port} within 30 seconds. Check \`sirenodeck logs\`; if another app owns the port, stop it or choose another with \`--port <port>\`.`
131
141
  logger.warn(message)
132
142
  process.exitCode = 1
133
143
  printRestartFailed(message)