@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,23 @@
1
+ import type { RuntimeDeck } from "./runtime"
2
+
3
+ export const injectConfigUiButton = (
4
+ decks: ReadonlyArray<RuntimeDeck>,
5
+ configUiUrl: string,
6
+ ): RuntimeDeck[] =>
7
+ decks.map((deck) =>
8
+ deck.id !== "internal-settings:settings"
9
+ ? deck
10
+ : {
11
+ ...deck,
12
+ buttons: [
13
+ ...deck.buttons,
14
+ {
15
+ id: "config-ui",
16
+ type: "core:action",
17
+ position: 3,
18
+ config: { label: "Config UI", icon: "icon://settings" },
19
+ actions: { tap: `url://${configUiUrl}` },
20
+ },
21
+ ],
22
+ },
23
+ )
@@ -7,6 +7,7 @@ import type {
7
7
  NotificationArgs,
8
8
  NotificationProvider,
9
9
  } from "@/system/providers/notification"
10
+ import type { UrlProvider } from "@/system/providers/url"
10
11
  import {
11
12
  type RequirementsCheckResult,
12
13
  type SystemCapability,
@@ -39,6 +40,7 @@ export interface MethodsContext {
39
40
  logger: pino.Logger
40
41
  keyMacroProvider?: KeyMacroProvider
41
42
  notificationProvider?: NotificationProvider
43
+ urlProvider?: UrlProvider
42
44
  }
43
45
 
44
46
  export interface Methods {
@@ -80,6 +82,7 @@ export interface Methods {
80
82
  */
81
83
  notify(args: NotificationArgs): Promise<void>
82
84
  setNotificationProvider(provider: NotificationProvider): void
85
+ setUrlProvider(provider: UrlProvider): void
83
86
  setRequirements(requirements: RequirementsCheckResult): void
84
87
  checkRequirement(capability: SystemCapability): boolean
85
88
  showTemporaryError(
@@ -104,6 +107,7 @@ export const createMethods = (ctx: MethodsContext): Methods => {
104
107
  let keyMacroProvider: KeyMacroProvider | undefined = ctx.keyMacroProvider
105
108
  let notificationProvider: NotificationProvider | undefined =
106
109
  ctx.notificationProvider
110
+ let urlProvider: UrlProvider | undefined = ctx.urlProvider
107
111
  const logger = ctx.logger.child({ component: "methods" })
108
112
  const setKeyMacroProvider: Methods["setKeyMacroProvider"] = (provider) => {
109
113
  keyMacroProvider = provider
@@ -113,6 +117,9 @@ export const createMethods = (ctx: MethodsContext): Methods => {
113
117
  ) => {
114
118
  notificationProvider = provider
115
119
  }
120
+ const setUrlProvider: Methods["setUrlProvider"] = (provider) => {
121
+ urlProvider = provider
122
+ }
116
123
  const notify: Methods["notify"] = async (args) => {
117
124
  if (notificationProvider === undefined) {
118
125
  logger.warn(
@@ -254,6 +261,21 @@ export const createMethods = (ctx: MethodsContext): Methods => {
254
261
  await keyMacro({ kind: "text", value: text })
255
262
  return
256
263
  }
264
+ if (value.startsWith("url://")) {
265
+ const url = value.slice("url://".length)
266
+ if (url.length === 0) {
267
+ throw new NotImplementedError(
268
+ "dispatch: url:// requires a URL, e.g. url://https://example.com",
269
+ )
270
+ }
271
+ if (urlProvider === undefined) {
272
+ throw new NotImplementedError(
273
+ "dispatch: url:// requires a URL provider configured for this platform",
274
+ )
275
+ }
276
+ await urlProvider.open(url)
277
+ return
278
+ }
257
279
  if (value.startsWith("macro://")) {
258
280
  const inner = value.slice("macro://".length)
259
281
  if (inner.length === 0) {
@@ -335,6 +357,7 @@ export const createMethods = (ctx: MethodsContext): Methods => {
335
357
  subscribe,
336
358
  setKeyMacroProvider,
337
359
  setNotificationProvider,
360
+ setUrlProvider,
338
361
  notify,
339
362
  setRequirements,
340
363
  checkRequirement,
@@ -0,0 +1,20 @@
1
+ import type { RuntimeDeck } from "./system-back-injection"
2
+
3
+ export const positionSettingsVersionButton = (
4
+ decks: ReadonlyArray<RuntimeDeck>,
5
+ keyCount: number,
6
+ ): RuntimeDeck[] => {
7
+ const versionPosition = keyCount - 2
8
+ return decks.map((deck) =>
9
+ deck.id !== "internal-settings:settings"
10
+ ? deck
11
+ : {
12
+ ...deck,
13
+ buttons: deck.buttons.map((button) =>
14
+ button.type === "internal-settings:app-info"
15
+ ? { ...button, position: versionPosition }
16
+ : button,
17
+ ),
18
+ },
19
+ )
20
+ }
@@ -0,0 +1,186 @@
1
+ import type pino from "pino"
2
+
3
+ import { compileDeckMatcher } from "@/system/glob-match"
4
+ import type { ActiveAppProvider } from "@/system/providers/active-app"
5
+ import type { SessionProvider } from "@/system/providers/session"
6
+
7
+ import type { Runtime, RuntimeDeck } from "./runtime"
8
+
9
+ const DEFAULT_POLL_MS = 1000
10
+ const DEFAULT_DEBOUNCE_MS = 200
11
+
12
+ type ActiveAppProviderLike = Pick<ActiveAppProvider, "getActive" | "stop">
13
+
14
+ export interface HostPolicyCoordinator {
15
+ start(): void
16
+ updateDecks(decks: ReadonlyArray<RuntimeDeck>): void
17
+ dispose(): Promise<void>
18
+ }
19
+
20
+ export interface CreateHostPolicyCoordinatorOptions {
21
+ readonly runtime: Pick<
22
+ Runtime,
23
+ | "enterLock"
24
+ | "getOverlay"
25
+ | "restoreFromLock"
26
+ | "setAvailableOverlayDeck"
27
+ | "setOverlay"
28
+ >
29
+ readonly activeApp: ActiveAppProviderLike
30
+ readonly session: SessionProvider
31
+ readonly decks: ReadonlyArray<RuntimeDeck>
32
+ readonly logger: pino.Logger
33
+ readonly pollIntervalMs?: number
34
+ readonly debounceMs?: number
35
+ }
36
+
37
+ export const createHostPolicyCoordinator = (
38
+ options: CreateHostPolicyCoordinatorOptions,
39
+ ): HostPolicyCoordinator => {
40
+ const logger = options.logger.child({ component: "host-policy" })
41
+ let decks = options.decks
42
+ let poll: ReturnType<typeof setInterval> | null = null
43
+ let debounce: ReturnType<typeof setTimeout> | null = null
44
+ let pendingDeckId: string | null = null
45
+ let latestSnapshot: Awaited<ReturnType<ActiveAppProviderLike["getActive"]>> =
46
+ null
47
+ let hasObservedActiveApp = false
48
+ let lastMatchedDeckId: string | null = null
49
+ let lastLoggedActiveAppKey: string | null = null
50
+ let lockSnapshot: ReturnType<Runtime["enterLock"]> | null = null
51
+ let unsubscribeSession: (() => void) | null = null
52
+
53
+ const match = (
54
+ snapshot: NonNullable<typeof latestSnapshot>,
55
+ ): RuntimeDeck | null => {
56
+ let result: RuntimeDeck | null = null
57
+ let specificity = -1
58
+ for (const deck of decks) {
59
+ const hasProcess = (deck.processNames?.length ?? 0) > 0
60
+ const hasWindow = (deck.windowNames?.length ?? 0) > 0
61
+ if (!hasProcess && !hasWindow) continue
62
+ const matcher = compileDeckMatcher({
63
+ processNames: deck.processNames,
64
+ windowNames: deck.windowNames,
65
+ })
66
+ const nextSpecificity = Number(hasProcess) + Number(hasWindow)
67
+ if (matcher(snapshot) && nextSpecificity > specificity) {
68
+ result = deck
69
+ specificity = nextSpecificity
70
+ }
71
+ }
72
+ return result
73
+ }
74
+
75
+ const apply = (deckId: string | null): void => {
76
+ const deck =
77
+ deckId === null ? null : decks.find((item) => item.id === deckId)
78
+ const currentOverlayId = options.runtime.getOverlay()?.id ?? null
79
+ if (deck === null) {
80
+ options.runtime.setAvailableOverlayDeck(null)
81
+ if (currentOverlayId !== null)
82
+ options.runtime.setOverlay(null, { source: "autoShow" })
83
+ lastMatchedDeckId = null
84
+ return
85
+ }
86
+ if (deck === undefined) return
87
+ options.runtime.setAvailableOverlayDeck(deck.id)
88
+ if (currentOverlayId !== null && currentOverlayId !== deck.id) {
89
+ options.runtime.setOverlay(deck.autoShow === true ? deck.id : null, {
90
+ source: "autoShow",
91
+ })
92
+ lastMatchedDeckId = deck.id
93
+ return
94
+ }
95
+ if (deck.id !== lastMatchedDeckId && deck.autoShow === true) {
96
+ options.runtime.setOverlay(deck.id, { source: "autoShow" })
97
+ }
98
+ lastMatchedDeckId = deck.id
99
+ }
100
+
101
+ const schedule = (deckId: string | null): void => {
102
+ pendingDeckId = deckId
103
+ if (debounce !== null) clearTimeout(debounce)
104
+ debounce = setTimeout(() => {
105
+ debounce = null
106
+ apply(pendingDeckId)
107
+ pendingDeckId = null
108
+ }, options.debounceMs ?? DEFAULT_DEBOUNCE_MS)
109
+ }
110
+
111
+ const pollActiveApp = (): void => {
112
+ void options.activeApp.getActive().then((snapshot) => {
113
+ latestSnapshot = snapshot
114
+ hasObservedActiveApp = true
115
+ const matchedDeck = snapshot === null ? null : match(snapshot)
116
+ const snapshotKey =
117
+ snapshot === null
118
+ ? "<none>"
119
+ : JSON.stringify([snapshot.name, snapshot.windowTitle])
120
+ if (snapshotKey !== lastLoggedActiveAppKey) {
121
+ lastLoggedActiveAppKey = snapshotKey
122
+ logger.info(
123
+ {
124
+ snapshot:
125
+ snapshot === null
126
+ ? null
127
+ : { name: snapshot.name, windowTitle: snapshot.windowTitle },
128
+ matchedDeckId: matchedDeck?.id ?? null,
129
+ },
130
+ "active-app: focus snapshot changed",
131
+ )
132
+ }
133
+ logger.debug(
134
+ { snapshot, matchedDeckId: matchedDeck?.id ?? null },
135
+ "active-app: focus snapshot",
136
+ )
137
+ schedule(matchedDeck?.id ?? null)
138
+ })
139
+ }
140
+
141
+ const handleSession = (
142
+ state: ReturnType<SessionProvider["getState"]>,
143
+ ): void => {
144
+ if (state === "locked") {
145
+ lockSnapshot = options.runtime.enterLock()
146
+ return
147
+ }
148
+ if (state !== "unlocked" || lockSnapshot === null) return
149
+ const matchingId =
150
+ latestSnapshot === null ? null : (match(latestSnapshot)?.id ?? null)
151
+ options.runtime.restoreFromLock({
152
+ activeDeckId: lockSnapshot.activeDeckId,
153
+ overlayDeckId:
154
+ !hasObservedActiveApp || lockSnapshot.overlayDeckId === matchingId
155
+ ? lockSnapshot.overlayDeckId
156
+ : null,
157
+ })
158
+ lockSnapshot = null
159
+ }
160
+
161
+ return {
162
+ start(): void {
163
+ if (poll !== null) return
164
+ unsubscribeSession = options.session.subscribe(handleSession)
165
+ if (options.session.getState() === "locked") handleSession("locked")
166
+ poll = setInterval(
167
+ pollActiveApp,
168
+ options.pollIntervalMs ?? DEFAULT_POLL_MS,
169
+ )
170
+ pollActiveApp()
171
+ },
172
+ updateDecks(nextDecks): void {
173
+ decks = nextDecks
174
+ if (latestSnapshot !== null) schedule(match(latestSnapshot)?.id ?? null)
175
+ },
176
+ async dispose(): Promise<void> {
177
+ if (poll !== null) clearInterval(poll)
178
+ poll = null
179
+ if (debounce !== null) clearTimeout(debounce)
180
+ debounce = null
181
+ unsubscribeSession?.()
182
+ unsubscribeSession = null
183
+ await options.activeApp.stop()
184
+ },
185
+ }
186
+ }