@sirenodeck/sirenodeck 0.2.1 → 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.
- package/dist/main.mjs +218 -70
- package/package.json +1 -1
- package/src/builtin-addons/coding-agents/buttons/agent/config.ts +5 -1
- package/src/builtin-addons/coding-agents/buttons/summary/config.ts +15 -6
- package/src/builtin-addons/coding-agents/global/backend.ts +55 -35
- package/src/builtin-addons/media/backend.ts +54 -0
- package/src/builtin-addons/system-status/manifest.ts +49 -0
- package/src/cli/commands/restart.ts +15 -5
- package/src/cli/commands/run.ts +33 -11
- package/src/cli/commands/start.ts +10 -5
- package/src/cli/commands/system-requirements.ts +1 -0
- package/src/cli/index.ts +14 -3
- package/src/cli/main.ts +15 -2
- package/src/cli/startup-display.ts +32 -14
- package/src/config/validation.ts +7 -1
- package/src/index.ts +1 -2
- package/src/system/providers/active-app/capture-file.ts +61 -0
- package/src/system/providers/active-app.ts +6 -0
- package/src/util/logger.ts +19 -3
- package/src/version.ts +3 -1
|
@@ -256,14 +256,66 @@ const publishSnapshot = (): AgentsSnapshot => {
|
|
|
256
256
|
return payload
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
+
let captureFakeStage: string | null = null
|
|
260
|
+
|
|
261
|
+
const captureAgentsForStage = (stage: string): AgentsSnapshot => {
|
|
262
|
+
const statuses: Agent["status"][] =
|
|
263
|
+
stage === "updated"
|
|
264
|
+
? [
|
|
265
|
+
...Array.from({ length: 8 }, () => "running" as const),
|
|
266
|
+
"waiting_for_human",
|
|
267
|
+
"waiting_for_human",
|
|
268
|
+
"compacting",
|
|
269
|
+
]
|
|
270
|
+
: [
|
|
271
|
+
"idle",
|
|
272
|
+
...Array.from({ length: 10 }, () => "running" as const),
|
|
273
|
+
"waiting_for_human",
|
|
274
|
+
]
|
|
275
|
+
const now = Date.now()
|
|
276
|
+
const agents: Agent[] = statuses.map((status, index) => ({
|
|
277
|
+
sessionId: `sireno-capture-${stage}-${index + 1}`,
|
|
278
|
+
providerId: index % 2 === 0 ? "opencode" : "claude-code",
|
|
279
|
+
title: `Showcase task ${index + 1}`,
|
|
280
|
+
status,
|
|
281
|
+
directory: "/works/sireno-deck",
|
|
282
|
+
updatedAt: now - index * 1_000,
|
|
283
|
+
createdAt: now - (index + 1) * 60_000,
|
|
284
|
+
}))
|
|
285
|
+
return mergeSnapshot(EMPTY_SNAPSHOT, {
|
|
286
|
+
opencode: agents.filter((agent) => agent.providerId === "opencode"),
|
|
287
|
+
"claude-code": agents.filter((agent) => agent.providerId === "claude-code"),
|
|
288
|
+
})
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
const syncCaptureFakeAgents = (): void => {
|
|
292
|
+
const stagePath = process.env["SIRENO_CAPTURE_FAKE_AGENTS_FILE"]
|
|
293
|
+
let stage = "initial"
|
|
294
|
+
if (stagePath !== undefined) {
|
|
295
|
+
try {
|
|
296
|
+
const payload = JSON.parse(readFileSync(stagePath, "utf8")) as {
|
|
297
|
+
stage?: unknown
|
|
298
|
+
}
|
|
299
|
+
if (payload.stage === "updated") stage = "updated"
|
|
300
|
+
} catch {
|
|
301
|
+
// Keep the initial values until the capture timeline writes a stage.
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
if (stage === captureFakeStage) return
|
|
305
|
+
state.lastSnapshot = captureAgentsForStage(stage)
|
|
306
|
+
captureFakeStage = stage
|
|
307
|
+
}
|
|
308
|
+
|
|
259
309
|
const poller: AddonGlobalPoller = {
|
|
260
310
|
id: "agents",
|
|
261
311
|
channel: CHANNEL,
|
|
262
312
|
intervalMs: POLLER_INTERVAL_MS,
|
|
263
313
|
poll: async (ctx: AddonServiceContext) => {
|
|
264
314
|
state.context = ctx
|
|
265
|
-
if (process.env["SIRENO_CAPTURE_FAKE_AGENTS"] === "1")
|
|
315
|
+
if (process.env["SIRENO_CAPTURE_FAKE_AGENTS"] === "1") {
|
|
316
|
+
syncCaptureFakeAgents()
|
|
266
317
|
return publishSnapshot()
|
|
318
|
+
}
|
|
267
319
|
await setStateFromProviders()
|
|
268
320
|
fireNotices(state.lastSnapshot)
|
|
269
321
|
return publishSnapshot()
|
|
@@ -325,40 +377,7 @@ export const globalService: AddonGlobalService = {
|
|
|
325
377
|
// provider polling and injects a deterministic agent list so web captures
|
|
326
378
|
// show realistic "Agents" tiles without a live opencode / claude-code.
|
|
327
379
|
if (process.env["SIRENO_CAPTURE_FAKE_AGENTS"] === "1") {
|
|
328
|
-
|
|
329
|
-
const fake: Agent[] = [
|
|
330
|
-
{
|
|
331
|
-
sessionId: "sireno-capture-opencode-1",
|
|
332
|
-
providerId: "opencode" as ProviderId,
|
|
333
|
-
title: "Refactor capture pipeline",
|
|
334
|
-
status: "running" as const,
|
|
335
|
-
directory: "/works/sirenodeck",
|
|
336
|
-
updatedAt: now,
|
|
337
|
-
createdAt: now - 1000 * 60 * 12,
|
|
338
|
-
},
|
|
339
|
-
{
|
|
340
|
-
sessionId: "sireno-capture-opencode-2",
|
|
341
|
-
providerId: "opencode" as ProviderId,
|
|
342
|
-
title: "Fix flaky session tests",
|
|
343
|
-
status: "idle" as const,
|
|
344
|
-
directory: "/works/sirenodeck/packages/cli",
|
|
345
|
-
updatedAt: now - 1000 * 60 * 4,
|
|
346
|
-
createdAt: now - 1000 * 60 * 40,
|
|
347
|
-
},
|
|
348
|
-
{
|
|
349
|
-
sessionId: "sireno-capture-claude-1",
|
|
350
|
-
providerId: "claude-code" as ProviderId,
|
|
351
|
-
title: "Migrate themes",
|
|
352
|
-
status: "waiting_for_human" as const,
|
|
353
|
-
directory: "/works/sirenodeck/packages/web",
|
|
354
|
-
updatedAt: now - 1000 * 60 * 2,
|
|
355
|
-
createdAt: now - 1000 * 60 * 90,
|
|
356
|
-
},
|
|
357
|
-
]
|
|
358
|
-
state.lastSnapshot = mergeSnapshot(state.lastSnapshot, {
|
|
359
|
-
opencode: fake.filter((a) => a.providerId === "opencode"),
|
|
360
|
-
"claude-code": fake.filter((a) => a.providerId === "claude-code"),
|
|
361
|
-
})
|
|
380
|
+
syncCaptureFakeAgents()
|
|
362
381
|
publishSnapshot()
|
|
363
382
|
return
|
|
364
383
|
}
|
|
@@ -393,6 +412,7 @@ export const globalService: AddonGlobalService = {
|
|
|
393
412
|
}
|
|
394
413
|
state.providers.clear()
|
|
395
414
|
state.lastSnapshot = EMPTY_SNAPSHOT
|
|
415
|
+
captureFakeStage = null
|
|
396
416
|
state.lastSeenStatus.clear()
|
|
397
417
|
state.throttle.reset()
|
|
398
418
|
state.icons = {}
|
|
@@ -24,6 +24,21 @@ const FALLBACK_STATE: MediaPlayerState = {
|
|
|
24
24
|
|
|
25
25
|
let provider: MediaStatusProvider | null = null
|
|
26
26
|
let ctxRef: AddonServiceContext | null = null
|
|
27
|
+
let captureMediaState: MediaPlayerState | null = null
|
|
28
|
+
let captureStage = "playing"
|
|
29
|
+
|
|
30
|
+
const captureMode = (): boolean =>
|
|
31
|
+
process.env["SIRENO_CAPTURE_FAKE_MEDIA"] === "1"
|
|
32
|
+
|
|
33
|
+
const setCapturePlayback = (playing: boolean): void => {
|
|
34
|
+
captureStage = playing ? "playing" : "paused"
|
|
35
|
+
if (captureMediaState === null) return
|
|
36
|
+
captureMediaState = {
|
|
37
|
+
...captureMediaState,
|
|
38
|
+
status: playing ? "play" : "pause",
|
|
39
|
+
isPlaying: playing,
|
|
40
|
+
}
|
|
41
|
+
}
|
|
27
42
|
|
|
28
43
|
const mapStatus = (
|
|
29
44
|
playStatus: Awaited<
|
|
@@ -76,6 +91,21 @@ export const globalService: AddonGlobalService = {
|
|
|
76
91
|
channel: "media:state",
|
|
77
92
|
intervalMs: 1_000,
|
|
78
93
|
poll: async (_ctx: AddonServiceContext): Promise<MediaPlayerState> => {
|
|
94
|
+
if (captureMode() && captureMediaState !== null) {
|
|
95
|
+
const stagePath = process.env["SIRENO_CAPTURE_FAKE_MEDIA_FILE"]
|
|
96
|
+
if (stagePath !== undefined) {
|
|
97
|
+
try {
|
|
98
|
+
const stage = JSON.parse(
|
|
99
|
+
(await import("node:fs")).readFileSync(stagePath, "utf8"),
|
|
100
|
+
) as { stage?: unknown }
|
|
101
|
+
if (stage.stage === "paused" && captureStage !== "paused")
|
|
102
|
+
setCapturePlayback(false)
|
|
103
|
+
} catch {
|
|
104
|
+
// Keep the previous capture state while the stage file is being written.
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return { ...captureMediaState }
|
|
108
|
+
}
|
|
79
109
|
if (provider === null) return FALLBACK_STATE
|
|
80
110
|
try {
|
|
81
111
|
return buildState(await provider.getStatus())
|
|
@@ -88,12 +118,16 @@ export const globalService: AddonGlobalService = {
|
|
|
88
118
|
|
|
89
119
|
methods: {
|
|
90
120
|
play: wrap(async () => {
|
|
121
|
+
if (captureMode()) return setCapturePlayback(true)
|
|
91
122
|
await provider?.play()
|
|
92
123
|
}),
|
|
93
124
|
pause: wrap(async () => {
|
|
125
|
+
if (captureMode()) return setCapturePlayback(false)
|
|
94
126
|
await provider?.pause()
|
|
95
127
|
}),
|
|
96
128
|
toggle: wrap(async () => {
|
|
129
|
+
if (captureMode())
|
|
130
|
+
return setCapturePlayback(captureMediaState?.isPlaying !== true)
|
|
97
131
|
await provider?.toggle()
|
|
98
132
|
}),
|
|
99
133
|
next: wrap(async () => {
|
|
@@ -121,6 +155,25 @@ export const globalService: AddonGlobalService = {
|
|
|
121
155
|
|
|
122
156
|
onLoad: (ctx: AddonServiceContext) => {
|
|
123
157
|
ctxRef = ctx
|
|
158
|
+
if (captureMode()) {
|
|
159
|
+
captureMediaState = {
|
|
160
|
+
title: "Night Drive",
|
|
161
|
+
artist: "Sireno Studio",
|
|
162
|
+
source: "Demo session",
|
|
163
|
+
status: "play",
|
|
164
|
+
isPlaying: true,
|
|
165
|
+
volume: 68,
|
|
166
|
+
progress: 42,
|
|
167
|
+
currentTime: 84,
|
|
168
|
+
totalTime: 200,
|
|
169
|
+
muted: false,
|
|
170
|
+
}
|
|
171
|
+
captureStage = "playing"
|
|
172
|
+
provider = null
|
|
173
|
+
return
|
|
174
|
+
}
|
|
175
|
+
captureMediaState = null
|
|
176
|
+
captureStage = "playing"
|
|
124
177
|
provider = createMediaProvider(process.platform, {
|
|
125
178
|
async run(
|
|
126
179
|
command: string,
|
|
@@ -139,5 +192,6 @@ export const globalService: AddonGlobalService = {
|
|
|
139
192
|
onUnload: () => {
|
|
140
193
|
ctxRef = null
|
|
141
194
|
provider = null
|
|
195
|
+
captureMediaState = null
|
|
142
196
|
},
|
|
143
197
|
}
|
|
@@ -9,9 +9,56 @@ import {
|
|
|
9
9
|
import { CHART_HISTORY_CHANNEL } from "./domain"
|
|
10
10
|
import {
|
|
11
11
|
SYSTEM_METRIC_IDS,
|
|
12
|
+
METRICS_CATALOG,
|
|
12
13
|
type SystemMetricId,
|
|
14
|
+
type SystemMetricSnapshot,
|
|
13
15
|
} from "./shared/metrics-catalog"
|
|
14
16
|
|
|
17
|
+
const CAPTURE_METRIC_VALUES: Readonly<Record<SystemMetricId, number>> = {
|
|
18
|
+
battery: 86,
|
|
19
|
+
cpu: 42,
|
|
20
|
+
"cpu-boost": 1,
|
|
21
|
+
"cpu-voltages": 1_180,
|
|
22
|
+
disk: 54,
|
|
23
|
+
"disk-io": 1_240_000,
|
|
24
|
+
"fan-rpm": 1_260,
|
|
25
|
+
frequency: 3_400,
|
|
26
|
+
"gpu-temp": 58,
|
|
27
|
+
"gpu-usage": 27,
|
|
28
|
+
load: 1.4,
|
|
29
|
+
network: 64,
|
|
30
|
+
"network-read": 840_000,
|
|
31
|
+
"network-write": 126_000,
|
|
32
|
+
processes: 184,
|
|
33
|
+
ram: 68,
|
|
34
|
+
swap: 24,
|
|
35
|
+
temperature: 54,
|
|
36
|
+
uptime: 92_400,
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const captureMetric = (id: SystemMetricId): SystemMetricSnapshot => {
|
|
40
|
+
const definition = METRICS_CATALOG[id]
|
|
41
|
+
const value = CAPTURE_METRIC_VALUES[id]
|
|
42
|
+
const max = definition.maxValue
|
|
43
|
+
return {
|
|
44
|
+
id,
|
|
45
|
+
label: definition.defaultLabel,
|
|
46
|
+
available: true,
|
|
47
|
+
value,
|
|
48
|
+
...(definition.unit !== undefined ? { unit: definition.unit } : {}),
|
|
49
|
+
...(max !== undefined
|
|
50
|
+
? {
|
|
51
|
+
max,
|
|
52
|
+
percentage:
|
|
53
|
+
definition.formatter === "percent" ||
|
|
54
|
+
definition.formatter === "bool"
|
|
55
|
+
? value
|
|
56
|
+
: (value / max) * 100,
|
|
57
|
+
}
|
|
58
|
+
: {}),
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
15
62
|
// ponytail: pollers are server-only; lazy-import live-metrics so the manifest
|
|
16
63
|
// can be loaded by the frontend addon virtual module without dragging
|
|
17
64
|
// node:os / node:fs into the browser bundle.
|
|
@@ -25,6 +72,8 @@ function makePoller(metricId: SystemMetricId): AddonGlobalPoller {
|
|
|
25
72
|
// metric would race on one channel); not worth the refactor today.
|
|
26
73
|
intervalMs: POLL_INTERVAL_MS,
|
|
27
74
|
poll: async () => {
|
|
75
|
+
if (process.env["SIRENO_CAPTURE_FAKE_METRICS"] === "1")
|
|
76
|
+
return captureMetric(metricId)
|
|
28
77
|
const { probeMetric } = await import("./domain/live-metrics")
|
|
29
78
|
const result = await probeMetric(metricId)
|
|
30
79
|
if (result.value !== undefined && result.available) {
|
|
@@ -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
|
|
86
|
-
:
|
|
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
|
|
130
|
-
:
|
|
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)
|
package/src/cli/commands/run.ts
CHANGED
|
@@ -460,12 +460,22 @@ const loadExternalAddonsIntoRegistry = async (
|
|
|
460
460
|
}
|
|
461
461
|
for (const issue of result.issues) {
|
|
462
462
|
const payload = { source: issue.source, message: issue.message }
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
else
|
|
463
|
+
if (issue.level === "error") {
|
|
464
|
+
logger.warn(
|
|
465
|
+
payload,
|
|
466
|
+
`Configured addon '${issue.source}' was skipped; its buttons and decks are unavailable. ${issue.message} Fix the addon entry or remove it from addons[].`,
|
|
467
|
+
)
|
|
468
|
+
} else if (issue.level === "warning") {
|
|
469
|
+
logger.warn(
|
|
470
|
+
payload,
|
|
471
|
+
`addon load warning — ${issue.source}: ${issue.message}`,
|
|
472
|
+
)
|
|
473
|
+
} else {
|
|
474
|
+
logger.info(
|
|
475
|
+
payload,
|
|
476
|
+
`addon load info — ${issue.source}: ${issue.message}`,
|
|
477
|
+
)
|
|
478
|
+
}
|
|
469
479
|
}
|
|
470
480
|
for (const loaded of result.addons) {
|
|
471
481
|
try {
|
|
@@ -544,12 +554,14 @@ export const validateAndLoadConfig = async (
|
|
|
544
554
|
// Per-button config errors are non-fatal: each broken button is replaced
|
|
545
555
|
// with a `core:temporary-error` cell at its position and logged in full
|
|
546
556
|
// (the incorrect config + the schema issues) so the operator can see
|
|
547
|
-
// exactly what went wrong without restarting the daemon.
|
|
548
|
-
//
|
|
549
|
-
//
|
|
557
|
+
// exactly what went wrong without restarting the daemon. Unknown button
|
|
558
|
+
// types are also per-button failures: this lets the rest of the deck run
|
|
559
|
+
// when an optional addon is missing or a type has a typo.
|
|
550
560
|
const validation = validateFull(config, registry)
|
|
551
561
|
const structuralErrors = validation.issues.filter(
|
|
552
|
-
(i) =>
|
|
562
|
+
(i) =>
|
|
563
|
+
!i.path.includes(".config.") &&
|
|
564
|
+
!(i.reason === "unknown-type" && i.deckId !== undefined),
|
|
553
565
|
)
|
|
554
566
|
if (structuralErrors.some((i) => i.level === "error")) {
|
|
555
567
|
throw new Error(
|
|
@@ -1093,7 +1105,17 @@ const startSystemProviders = async (
|
|
|
1093
1105
|
executor,
|
|
1094
1106
|
logger,
|
|
1095
1107
|
}),
|
|
1096
|
-
|
|
1108
|
+
// ponytail: capture mode must not type emoji or Meet shortcuts into the
|
|
1109
|
+
// operator's active desktop while the emulator records their gestures.
|
|
1110
|
+
env["SIRENO_CAPTURE_DISABLE_KEYBOARD"] === "1"
|
|
1111
|
+
? Promise.resolve({ sendKey: async () => {}, stop: async () => {} })
|
|
1112
|
+
: createKeyMacroProvider({
|
|
1113
|
+
platform,
|
|
1114
|
+
executor,
|
|
1115
|
+
env,
|
|
1116
|
+
logger,
|
|
1117
|
+
extraFsProbe,
|
|
1118
|
+
}),
|
|
1097
1119
|
createNotificationProvider({
|
|
1098
1120
|
platform,
|
|
1099
1121
|
executor,
|
|
@@ -928,7 +928,9 @@ const runFirstRunCheckIfNeeded = async (
|
|
|
928
928
|
return true
|
|
929
929
|
}
|
|
930
930
|
|
|
931
|
-
|
|
931
|
+
export type StartLaunchResult = "started" | "blocked" | "cancelled"
|
|
932
|
+
|
|
933
|
+
const start = async (options: StartOptions): Promise<StartLaunchResult> => {
|
|
932
934
|
const { logger } = options
|
|
933
935
|
|
|
934
936
|
// ponytail: skip the first-run wizard in the daemon child. The forked
|
|
@@ -941,10 +943,12 @@ const start = async (options: StartOptions): Promise<void> => {
|
|
|
941
943
|
// the wizard before forking, so the child has no business re-running it.
|
|
942
944
|
if (isUnderServiceManager()) {
|
|
943
945
|
await runInProcess(options)
|
|
944
|
-
return
|
|
946
|
+
return "started"
|
|
945
947
|
}
|
|
946
948
|
|
|
947
|
-
if (!(await runFirstRunCheckIfNeeded(options, logger)))
|
|
949
|
+
if (!(await runFirstRunCheckIfNeeded(options, logger))) {
|
|
950
|
+
return process.exitCode === 1 ? "blocked" : "cancelled"
|
|
951
|
+
}
|
|
948
952
|
|
|
949
953
|
try {
|
|
950
954
|
await offerConfigSkillOnFirstRun()
|
|
@@ -967,7 +971,7 @@ const start = async (options: StartOptions): Promise<void> => {
|
|
|
967
971
|
const action = await promptConflict(existing)
|
|
968
972
|
if (action === "cancel") {
|
|
969
973
|
logger.info("start cancelled")
|
|
970
|
-
return
|
|
974
|
+
return "cancelled"
|
|
971
975
|
}
|
|
972
976
|
// ponytail: a supervised daemon cannot be restarted by killing it. launchd
|
|
973
977
|
// with KeepAlive brings it back in about two seconds — measured — and the
|
|
@@ -1003,7 +1007,7 @@ const start = async (options: StartOptions): Promise<void> => {
|
|
|
1003
1007
|
? "start: service manager restarted the daemon (pid not yet visible)"
|
|
1004
1008
|
: "start: daemon restarted by the service manager",
|
|
1005
1009
|
)
|
|
1006
|
-
return
|
|
1010
|
+
return "started"
|
|
1007
1011
|
}
|
|
1008
1012
|
if (existing !== null) await stopExisting(existing, logger)
|
|
1009
1013
|
else
|
|
@@ -1081,6 +1085,7 @@ const start = async (options: StartOptions): Promise<void> => {
|
|
|
1081
1085
|
} else {
|
|
1082
1086
|
await startProduction(options)
|
|
1083
1087
|
}
|
|
1088
|
+
return "started"
|
|
1084
1089
|
}
|
|
1085
1090
|
|
|
1086
1091
|
export default start
|
|
@@ -652,6 +652,7 @@ export const systemRequirementsCommand: CommandModule<
|
|
|
652
652
|
SystemRequirementsArgs
|
|
653
653
|
> = {
|
|
654
654
|
command: "system-requirements",
|
|
655
|
+
aliases: ["onboard"],
|
|
655
656
|
describe:
|
|
656
657
|
"Detect system capabilities (key macro, clipboard, notification, active-app) and optionally install missing pieces",
|
|
657
658
|
builder: (yargs) =>
|
package/src/cli/index.ts
CHANGED
|
@@ -175,7 +175,15 @@ const startCommand: CommandModule<object, StartArgs> = {
|
|
|
175
175
|
const logSnapshot = snapshotDaemonLog()
|
|
176
176
|
const logPath = join(resolveDaemonPaths().runtimeDir, "service.log")
|
|
177
177
|
const startRequestedAt = Date.now()
|
|
178
|
-
const
|
|
178
|
+
const launchResult = await start(options)
|
|
179
|
+
if (launchResult !== "started") {
|
|
180
|
+
if (launchResult === "blocked") {
|
|
181
|
+
const message =
|
|
182
|
+
"Startup stopped before the daemon was launched. Resolve the requirement warning above, then retry."
|
|
183
|
+
printStartupFailed(message)
|
|
184
|
+
}
|
|
185
|
+
return
|
|
186
|
+
}
|
|
179
187
|
const outcome: StartOutcome = await waitForFullStart({
|
|
180
188
|
port: options.port ?? 52937,
|
|
181
189
|
tcpTimeoutMs: 30_000,
|
|
@@ -213,13 +221,16 @@ const startCommand: CommandModule<object, StartArgs> = {
|
|
|
213
221
|
// ponytail: TCP never bound. Either the daemon crashed during
|
|
214
222
|
// boot, or port 52937 is held by an unrelated process. Either
|
|
215
223
|
// way, the start failed — the operator needs to know.
|
|
216
|
-
const
|
|
224
|
+
const port = options.port ?? 52937
|
|
225
|
+
const message =
|
|
226
|
+
`SirenoDeck did not open its WebSocket on 127.0.0.1:${port} within 30 seconds. ` +
|
|
227
|
+
"The daemon may have exited during startup. Check `sirenodeck logs` for the cause; " +
|
|
228
|
+
"if another app is using this port, stop it or retry with `--port <port>`."
|
|
217
229
|
logger.warn(message)
|
|
218
230
|
process.exitCode = 1
|
|
219
231
|
printStartupFailed(message)
|
|
220
232
|
return
|
|
221
233
|
}
|
|
222
|
-
await startPromise
|
|
223
234
|
} catch (err) {
|
|
224
235
|
printStartupFailed(err)
|
|
225
236
|
const e = err as { issues?: unknown; message?: unknown }
|
package/src/cli/main.ts
CHANGED
|
@@ -68,9 +68,10 @@ const installProcessGuards = (
|
|
|
68
68
|
logger: ReturnType<typeof createLogger>,
|
|
69
69
|
): void => {
|
|
70
70
|
process.on("uncaughtException", (err, origin) => {
|
|
71
|
+
const summary = `${err.name}: ${err.message}`
|
|
71
72
|
logger.fatal(
|
|
72
73
|
{ err, origin },
|
|
73
|
-
|
|
74
|
+
`Unexpected error: ${summary}. See the stack trace for where it occurred.`,
|
|
74
75
|
)
|
|
75
76
|
killChildrenAndExit(logger, 1)
|
|
76
77
|
})
|
|
@@ -89,12 +90,24 @@ const installProcessGuards = (
|
|
|
89
90
|
typeof (promise as unknown as { stack?: unknown }).stack === "string"
|
|
90
91
|
? (promise as unknown as { stack: string }).stack
|
|
91
92
|
: undefined
|
|
93
|
+
const summary =
|
|
94
|
+
reason instanceof Error
|
|
95
|
+
? `${reason.name}: ${reason.message}`
|
|
96
|
+
: typeof reason === "string"
|
|
97
|
+
? reason
|
|
98
|
+
: (() => {
|
|
99
|
+
try {
|
|
100
|
+
return JSON.stringify(reason) ?? String(reason)
|
|
101
|
+
} catch {
|
|
102
|
+
return String(reason)
|
|
103
|
+
}
|
|
104
|
+
})()
|
|
92
105
|
logger.fatal(
|
|
93
106
|
{
|
|
94
107
|
reason: reasonDump,
|
|
95
108
|
...(stackDump !== undefined ? { stack: stackDump } : {}),
|
|
96
109
|
},
|
|
97
|
-
|
|
110
|
+
`An asynchronous operation failed: ${summary}. See the stack trace for where it originated.`,
|
|
98
111
|
)
|
|
99
112
|
killChildrenAndExit(logger, 1)
|
|
100
113
|
})
|
|
@@ -15,6 +15,8 @@ import {
|
|
|
15
15
|
} from "@/system/setup-wizard"
|
|
16
16
|
|
|
17
17
|
import { cancel, intro, log, outro } from "@/cli/prompt"
|
|
18
|
+
import { color } from "@/system/setup-wizard/format"
|
|
19
|
+
import { VERSION } from "@/version"
|
|
18
20
|
|
|
19
21
|
import {
|
|
20
22
|
readDaemonEventsFromSnapshot,
|
|
@@ -174,20 +176,30 @@ const tryBind = (port: number): Promise<boolean> =>
|
|
|
174
176
|
}
|
|
175
177
|
})
|
|
176
178
|
|
|
177
|
-
interface FeatureItem {
|
|
179
|
+
export interface FeatureItem {
|
|
178
180
|
readonly name: string
|
|
179
181
|
readonly available: boolean
|
|
180
182
|
readonly reason?: string
|
|
181
183
|
}
|
|
182
184
|
|
|
183
|
-
const
|
|
184
|
-
items
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
185
|
+
export const formatFeaturesList = (
|
|
186
|
+
items: ReadonlyArray<FeatureItem>,
|
|
187
|
+
): string[] => [
|
|
188
|
+
"Features",
|
|
189
|
+
...items.map(
|
|
190
|
+
(it) =>
|
|
191
|
+
` ${it.name} ${it.available ? color.green("✓") : color.red("✗")}${!it.available && it.reason ? ` — ${it.reason}` : ""}`,
|
|
192
|
+
),
|
|
193
|
+
]
|
|
194
|
+
|
|
195
|
+
export const printFeaturesList = (
|
|
196
|
+
items: ReadonlyArray<FeatureItem>,
|
|
197
|
+
write: (text: string) => void = (text) => process.stdout.write(text),
|
|
198
|
+
): string[] => {
|
|
199
|
+
const lines = formatFeaturesList(items)
|
|
200
|
+
write(`${lines.slice(1).join("\n")}\n`)
|
|
201
|
+
return lines
|
|
202
|
+
}
|
|
191
203
|
|
|
192
204
|
const toFeatureItem = (
|
|
193
205
|
name: string,
|
|
@@ -213,7 +225,7 @@ const deviceLabel = (
|
|
|
213
225
|
}
|
|
214
226
|
|
|
215
227
|
export interface BannerResult {
|
|
216
|
-
readonly
|
|
228
|
+
readonly featuresLines: string[]
|
|
217
229
|
readonly deviceLabel: string
|
|
218
230
|
}
|
|
219
231
|
|
|
@@ -247,13 +259,19 @@ export const buildStartupBanner = async (
|
|
|
247
259
|
toFeatureItem("http", http),
|
|
248
260
|
]
|
|
249
261
|
|
|
250
|
-
const
|
|
262
|
+
const featuresLines = formatFeaturesList(items)
|
|
251
263
|
const label = deviceLabel(options.emulator, options.deviceModel, devices)
|
|
252
264
|
|
|
253
|
-
intro(
|
|
265
|
+
intro(`Starting SirenoDeck v${VERSION}`)
|
|
254
266
|
log.info(`Device: ${label}`)
|
|
255
|
-
log.info(
|
|
256
|
-
|
|
267
|
+
log.info("Features")
|
|
268
|
+
printFeaturesList(items)
|
|
269
|
+
if (items.some((item) => !item.available)) {
|
|
270
|
+
log.warn(
|
|
271
|
+
"Some features are unavailable. Run `sirenodeck onboard` to install missing dependencies.",
|
|
272
|
+
)
|
|
273
|
+
}
|
|
274
|
+
return { featuresLines, deviceLabel: label }
|
|
257
275
|
}
|
|
258
276
|
|
|
259
277
|
const toSystemCap = (
|
package/src/config/validation.ts
CHANGED
|
@@ -103,10 +103,16 @@ export const validateButton = (
|
|
|
103
103
|
const base = { deckId, position }
|
|
104
104
|
const issues: FullValidationIssue[] = []
|
|
105
105
|
if (!registry.hasButtonType(btn.type)) {
|
|
106
|
+
const addonName = btn.type.split(":", 1)[0]
|
|
107
|
+
const availableTypes = registry.getAddon(addonName ?? "")?.buttonTypes
|
|
108
|
+
const hint =
|
|
109
|
+
availableTypes !== undefined
|
|
110
|
+
? ` Available button types for '${addonName}': ${Object.keys(availableTypes).join(", ") || "none"}. Check the type spelling.`
|
|
111
|
+
: " Check the type spelling and confirm that its addon is installed and enabled."
|
|
106
112
|
issues.push({
|
|
107
113
|
level: "error",
|
|
108
114
|
path: `${path}.type`,
|
|
109
|
-
message: `Unknown button type: ${btn.type}`,
|
|
115
|
+
message: `Unknown button type: ${btn.type}.${hint}`,
|
|
110
116
|
reason: "unknown-type",
|
|
111
117
|
...base,
|
|
112
118
|
})
|
package/src/index.ts
CHANGED
|
@@ -17,6 +17,7 @@ export {
|
|
|
17
17
|
PACKAGE_NAME,
|
|
18
18
|
PROTOCOL_VERSION,
|
|
19
19
|
SIRENO_ADDON_API_VERSION,
|
|
20
|
+
VERSION as cliVersion,
|
|
20
21
|
} from "./version"
|
|
21
22
|
|
|
22
23
|
export {
|
|
@@ -70,5 +71,3 @@ export {
|
|
|
70
71
|
type TemporaryErrorSurfaceProps,
|
|
71
72
|
type ThemeUiPresentation,
|
|
72
73
|
} from "./ui"
|
|
73
|
-
|
|
74
|
-
export const cliVersion = "0.2.0"
|