@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
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs"
|
|
2
|
+
|
|
3
|
+
import type { ActiveAppProvider, ActiveAppSnapshot } from "../active-app"
|
|
4
|
+
|
|
5
|
+
const sameSnapshot = (
|
|
6
|
+
left: ActiveAppSnapshot | null,
|
|
7
|
+
right: ActiveAppSnapshot | null,
|
|
8
|
+
): boolean =>
|
|
9
|
+
left?.name === right?.name &&
|
|
10
|
+
left?.windowTitle === right?.windowTitle &&
|
|
11
|
+
left?.processId === right?.processId
|
|
12
|
+
|
|
13
|
+
const readSnapshot = (path: string): ActiveAppSnapshot | null => {
|
|
14
|
+
try {
|
|
15
|
+
const value: unknown = JSON.parse(readFileSync(path, "utf8"))
|
|
16
|
+
if (value === null) return null
|
|
17
|
+
if (typeof value !== "object" || Array.isArray(value)) return null
|
|
18
|
+
const snapshot = value as Record<string, unknown>
|
|
19
|
+
if (typeof snapshot["name"] !== "string") return null
|
|
20
|
+
const windowTitle = snapshot["windowTitle"]
|
|
21
|
+
const processId = snapshot["processId"]
|
|
22
|
+
return {
|
|
23
|
+
name: snapshot["name"],
|
|
24
|
+
windowTitle: typeof windowTitle === "string" ? windowTitle : null,
|
|
25
|
+
processId:
|
|
26
|
+
typeof processId === "number" && Number.isFinite(processId)
|
|
27
|
+
? processId
|
|
28
|
+
: null,
|
|
29
|
+
}
|
|
30
|
+
} catch {
|
|
31
|
+
return null
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const createCaptureFileActiveAppProvider = (
|
|
36
|
+
path: string,
|
|
37
|
+
): ActiveAppProvider => {
|
|
38
|
+
const subscribers = new Set<(snapshot: ActiveAppSnapshot | null) => void>()
|
|
39
|
+
let last = readSnapshot(path)
|
|
40
|
+
const interval = setInterval(() => {
|
|
41
|
+
const next = readSnapshot(path)
|
|
42
|
+
if (sameSnapshot(last, next)) return
|
|
43
|
+
last = next
|
|
44
|
+
for (const subscriber of subscribers) subscriber(next)
|
|
45
|
+
}, 100)
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
async getActive() {
|
|
49
|
+
last = readSnapshot(path)
|
|
50
|
+
return last
|
|
51
|
+
},
|
|
52
|
+
subscribe(handler) {
|
|
53
|
+
subscribers.add(handler)
|
|
54
|
+
return () => subscribers.delete(handler)
|
|
55
|
+
},
|
|
56
|
+
async stop() {
|
|
57
|
+
clearInterval(interval)
|
|
58
|
+
subscribers.clear()
|
|
59
|
+
},
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -47,6 +47,12 @@ export interface CreateActiveAppProviderOptions {
|
|
|
47
47
|
export const createActiveAppProvider = async (
|
|
48
48
|
options: CreateActiveAppProviderOptions,
|
|
49
49
|
): Promise<ActiveAppProvider> => {
|
|
50
|
+
const captureFile = process.env["SIRENO_CAPTURE_ACTIVE_APP_FILE"]
|
|
51
|
+
if (captureFile !== undefined) {
|
|
52
|
+
const { createCaptureFileActiveAppProvider } =
|
|
53
|
+
await import("./active-app/capture-file")
|
|
54
|
+
return createCaptureFileActiveAppProvider(captureFile)
|
|
55
|
+
}
|
|
50
56
|
const platform = options.platform ?? process.platform
|
|
51
57
|
if (platform === "linux") {
|
|
52
58
|
if (options.executor === undefined) {
|
package/src/util/logger.ts
CHANGED
|
@@ -90,6 +90,7 @@ const CONTEXT_FIELDS = [
|
|
|
90
90
|
"addonConfigEntries",
|
|
91
91
|
"icon",
|
|
92
92
|
"fullPath",
|
|
93
|
+
"reason",
|
|
93
94
|
] as const
|
|
94
95
|
|
|
95
96
|
const FORWARDED_CONTEXT_FIELDS = [
|
|
@@ -128,6 +129,22 @@ const formatLogTime = (value: unknown): string | null => {
|
|
|
128
129
|
return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}.${pad(d.getMilliseconds(), 3)}`
|
|
129
130
|
}
|
|
130
131
|
|
|
132
|
+
const formatContextValue = (key: string, value: unknown): string => {
|
|
133
|
+
if (key === "reason" && typeof value === "object" && value !== null) {
|
|
134
|
+
const reason = value as {
|
|
135
|
+
type?: unknown
|
|
136
|
+
message?: unknown
|
|
137
|
+
value?: unknown
|
|
138
|
+
}
|
|
139
|
+
if (typeof reason.message === "string" && reason.message.length > 0) {
|
|
140
|
+
const type = typeof reason.type === "string" ? reason.type : "Error"
|
|
141
|
+
return `${type}: ${reason.message}`
|
|
142
|
+
}
|
|
143
|
+
if (typeof reason.value === "string") return reason.value
|
|
144
|
+
}
|
|
145
|
+
return typeof value === "string" ? value : JSON.stringify(value)
|
|
146
|
+
}
|
|
147
|
+
|
|
131
148
|
export const formatHuman = (
|
|
132
149
|
jsonLine: string,
|
|
133
150
|
options: FormatHumanOptions = {},
|
|
@@ -161,7 +178,7 @@ export const formatHuman = (
|
|
|
161
178
|
for (const key of CONTEXT_FIELDS) {
|
|
162
179
|
const value = entry[key]
|
|
163
180
|
if (value === undefined || value === null) continue
|
|
164
|
-
const display =
|
|
181
|
+
const display = formatContextValue(key, value)
|
|
165
182
|
if (display.length === 0) continue
|
|
166
183
|
ctxParts.push(`${colorize(DIM, `${key}:`)} ${display}`)
|
|
167
184
|
}
|
|
@@ -223,8 +240,7 @@ class HumanWritable extends Writable {
|
|
|
223
240
|
for (const key of CONTEXT_FIELDS) {
|
|
224
241
|
const value = entry[key]
|
|
225
242
|
if (value === undefined || value === null) continue
|
|
226
|
-
const display =
|
|
227
|
-
typeof value === "string" ? value : JSON.stringify(value)
|
|
243
|
+
const display = formatContextValue(key, value)
|
|
228
244
|
if (display.length === 0) continue
|
|
229
245
|
ctxParts.push(`${key}: ${display}`)
|
|
230
246
|
}
|
package/src/version.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import packageJson from "../package.json" with { type: "json" }
|
|
2
|
+
|
|
1
3
|
export const PACKAGE_NAME = "@sirenodeck/sirenodeck"
|
|
2
4
|
/**
|
|
3
5
|
* The name users actually type. `PACKAGE_NAME` is the npm package, which is
|
|
@@ -5,6 +7,6 @@ export const PACKAGE_NAME = "@sirenodeck/sirenodeck"
|
|
|
5
7
|
* a string that is not a runnable command. Keep the two separate.
|
|
6
8
|
*/
|
|
7
9
|
export const BIN_NAME = "sirenodeck"
|
|
8
|
-
export const VERSION =
|
|
10
|
+
export const VERSION: string = packageJson.version
|
|
9
11
|
export const SIRENO_ADDON_API_VERSION = 3
|
|
10
12
|
export const PROTOCOL_VERSION = 3
|