@sirenodeck/sirenodeck 0.2.9 → 0.4.0
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 +1118 -624
- package/dist/{windows-CRWdUgCn.mjs → windows-BCvfQ3PA.mjs} +4 -4
- package/frontend/src/App.tsx +3 -0
- package/frontend/src/components/Deck.tsx +13 -2
- package/package.json +10 -1
- package/src/addon/api.ts +24 -1
- package/src/addon/data-directory.ts +52 -0
- package/src/api/protocol-internal.ts +1 -0
- package/src/builtin-addons/coding-agents/global/backend.ts +15 -1
- package/src/builtin-addons/index.ts +0 -1
- package/src/builtin-addons/internal-settings/backend.ts +1 -1
- package/src/builtin-addons/internal-settings/buttons/brightness/common/frontend.tsx +14 -3
- package/src/builtin-addons/internal-settings/buttons/brightness-compact/frontend.tsx +6 -0
- package/src/builtin-addons/internal-settings/index.ts +15 -0
- package/src/builtin-addons/media/backend.ts +21 -0
- package/src/builtin-addons/register-builtins.ts +0 -3
- package/src/builtin-addons/system-status/README.md +1 -1
- package/src/builtin-addons/system-status/domain/display-metrics.ts +1 -1
- package/src/builtin-addons/system-status/manifest.ts +1 -1
- package/src/cli/commands/addon-decks.ts +1 -0
- package/src/cli/commands/addon-setup-config.ts +85 -0
- package/src/cli/commands/addon-setup.ts +134 -0
- package/src/cli/commands/emulator-mode.ts +2 -1
- package/src/cli/commands/run.ts +53 -11
- package/src/cli/commands/service-manager.ts +3 -5
- package/src/cli/commands/start.ts +14 -81
- package/src/cli/commands/stop.ts +4 -0
- package/src/cli/index.ts +2 -0
- package/src/config/environment.ts +44 -0
- package/src/config/loader.ts +17 -1
- package/src/config/schemas.ts +2 -1
- package/src/config/validation.ts +5 -1
- package/src/deck/addon-handler-bridge.ts +105 -6
- package/src/deck/addon-settings.ts +94 -0
- package/src/deck/deck-config.ts +1 -0
- package/src/deck/inject-config-ui-button.ts +25 -14
- package/src/deck/runtime/runtime.ts +175 -3
- package/src/deck/system-back-injection.ts +2 -0
- package/src/deck/system-buttons/registry.tsx +1 -0
- package/src/deck/system-buttons/types.ts +1 -0
- package/src/system/credentials/native.ts +74 -0
- package/src/system/credentials/store.ts +77 -0
- package/src/system/providers/notification/windows.ts +4 -4
- package/src/themes/default/sirenodeck.json +1 -0
- package/src/themes/light/sirenodeck.json +1 -0
- package/src/themes/manifest.ts +1 -0
- package/src/ui/primitives/Chip.tsx +1 -0
- package/src/ui/primitives/StatusIndicator.tsx +36 -0
- package/src/ui/primitives/index.ts +1 -0
- package/src/ui/surfaces/BinaryToggleSurface.tsx +52 -0
- package/src/ui/surfaces/LoadingSurface.tsx +34 -0
- package/src/ui/surfaces/index.ts +2 -0
- package/src/builtin-addons/brightness/README.md +0 -51
- package/src/builtin-addons/brightness/buttons/brightness/backend.ts +0 -13
- package/src/builtin-addons/brightness/buttons/brightness/config.ts +0 -20
- package/src/builtin-addons/brightness/buttons/brightness/frontend.tsx +0 -50
- package/src/builtin-addons/brightness/domain/macos.ts +0 -46
- package/src/builtin-addons/brightness/index.d.ts +0 -5
- package/src/builtin-addons/brightness/index.ts +0 -20
- package/src/builtin-addons/brightness/poller.ts +0 -27
- package/src/builtin-addons/brightness/sirenodeck.json +0 -6
- /package/src/builtin-addons/{brightness/providers → internal-settings/brightness-providers}/darwin.ts +0 -0
- /package/src/builtin-addons/{brightness/providers → internal-settings/brightness-providers}/index.ts +0 -0
- /package/src/builtin-addons/{brightness/providers → internal-settings/brightness-providers}/linux.ts +0 -0
- /package/src/builtin-addons/{brightness/providers → internal-settings/brightness-providers}/windows.ts +0 -0
package/dist/main.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import yargs from "yargs";
|
|
|
5
5
|
import { hideBin } from "yargs/helpers";
|
|
6
6
|
import { basename, dirname, extname, isAbsolute, join, normalize, resolve, sep } from "node:path";
|
|
7
7
|
import { Writable } from "node:stream";
|
|
8
|
-
import { cancel, confirm, intro, isCancel, log, log as log$1, note, outro, select, spinner } from "@clack/prompts";
|
|
8
|
+
import { cancel, confirm, confirm as confirm$1, intro, isCancel, isCancel as isCancel$1, log, log as log$1, multiselect, note, outro, password, select, spinner, text } from "@clack/prompts";
|
|
9
9
|
import pino from "pino";
|
|
10
10
|
import { chmodSync, closeSync, copyFileSync, cpSync, createWriteStream, existsSync, fchmodSync, fsyncSync, mkdirSync, mkdtempSync, openSync, readFileSync, readSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
|
|
11
11
|
import { createHash, randomBytes } from "node:crypto";
|
|
@@ -15,18 +15,18 @@ import { execFile, execFileSync, spawn } from "node:child_process";
|
|
|
15
15
|
import { z } from "zod";
|
|
16
16
|
import { connect, createServer } from "node:net";
|
|
17
17
|
import { createServer as createServer$1 } from "node:http";
|
|
18
|
-
import { open, readFile, readdir, stat, unlink } from "node:fs/promises";
|
|
18
|
+
import { chmod, lstat, mkdir, open, readFile, readdir, stat, unlink } from "node:fs/promises";
|
|
19
19
|
import { createContext, createElement, useCallback, useContext, useEffect, useRef, useState } from "react";
|
|
20
20
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
21
21
|
import * as lucideIcons from "lucide-react";
|
|
22
|
-
import { YAMLMap, YAMLParseError, YAMLSeq, parse, parseAllDocuments, parseDocument, stringify } from "yaml";
|
|
22
|
+
import { YAMLMap, YAMLParseError, YAMLSeq, isMap, isScalar, isSeq, parse, parseAllDocuments, parseDocument, stringify } from "yaml";
|
|
23
23
|
import { execa } from "execa";
|
|
24
24
|
import { sessionBus } from "dbus-next";
|
|
25
25
|
import chokidar from "chokidar";
|
|
26
26
|
import { WebSocketServer } from "ws";
|
|
27
27
|
import { getStreamDeckModelName, listStreamDecks, openStreamDeck } from "@elgato-stream-deck/node";
|
|
28
28
|
import sharp from "sharp";
|
|
29
|
-
import { promisify } from "node:util";
|
|
29
|
+
import { promisify, styleText } from "node:util";
|
|
30
30
|
import { applyEdits, modify, parse as parse$1 } from "jsonc-parser";
|
|
31
31
|
import qrcode from "qrcode";
|
|
32
32
|
//#region \0rolldown/runtime.js
|
|
@@ -308,7 +308,7 @@ const levelNameFromNumber = (level) => {
|
|
|
308
308
|
};
|
|
309
309
|
//#endregion
|
|
310
310
|
//#region package.json
|
|
311
|
-
var version$1 = "0.
|
|
311
|
+
var version$1 = "0.4.0";
|
|
312
312
|
//#endregion
|
|
313
313
|
//#region src/version.ts
|
|
314
314
|
const PACKAGE_NAME = "@sirenodeck/sirenodeck";
|
|
@@ -822,8 +822,6 @@ const refreshStaleUnit = (content, currentScript, nodePath, exists = existsSync)
|
|
|
822
822
|
const match = content.match(/^ExecStart="([^"]+)" "([^"]+\/dist\/main\.mjs)" start$/m);
|
|
823
823
|
const oldScript = match?.[2];
|
|
824
824
|
if (match === null || oldScript === void 0 || oldScript === currentScript || !exists(currentScript)) return content;
|
|
825
|
-
const brewUpgrade = oldScript.includes("/Cellar/sirenodeck/") && currentScript.includes("/Cellar/sirenodeck/");
|
|
826
|
-
if (exists(oldScript) && !brewUpgrade) return content;
|
|
827
825
|
return content.replace(match[0], `ExecStart="${nodePath}" "${currentScript}" start`);
|
|
828
826
|
};
|
|
829
827
|
const systemctl = (userLevel, args) => {
|
|
@@ -937,8 +935,9 @@ const invokeManager = async (options) => {
|
|
|
937
935
|
const plist = join(homedir(), "Library", "LaunchAgents", `${DAEMON_NAME}.plist`);
|
|
938
936
|
const uid = String(process.getuid?.() ?? 0);
|
|
939
937
|
if (action === "start") await bootstrapWithRetry(uid, plist, DAEMON_NAME);
|
|
940
|
-
else if (action === "stop")
|
|
941
|
-
|
|
938
|
+
else if (action === "stop") {
|
|
939
|
+
if (isJobLoaded(uid, DAEMON_NAME)) launchctl("bootout", [`gui/${uid}/${DAEMON_NAME}`]);
|
|
940
|
+
} else if (action === "restart") {
|
|
942
941
|
try {
|
|
943
942
|
launchctl("bootout", [`gui/${uid}/${DAEMON_NAME}`]);
|
|
944
943
|
} catch {}
|
|
@@ -1106,6 +1105,7 @@ const resolveConfigPath$1 = (options) => {
|
|
|
1106
1105
|
//#region src/themes/manifest.ts
|
|
1107
1106
|
const ThemeColorTokenSchema = z.object({
|
|
1108
1107
|
background: z.string().min(1),
|
|
1108
|
+
modalDeckBgr: z.string().min(1).optional(),
|
|
1109
1109
|
frame: z.string().min(1),
|
|
1110
1110
|
foreground: z.string().min(1),
|
|
1111
1111
|
"foreground-contrast": z.string().min(1),
|
|
@@ -1539,7 +1539,7 @@ const packageRoot = () => {
|
|
|
1539
1539
|
const resolveViteBin = () => {
|
|
1540
1540
|
let dir = packageRoot() ?? findWorkspaceRoot();
|
|
1541
1541
|
for (;;) {
|
|
1542
|
-
const bin = join(dir, "node_modules", "
|
|
1542
|
+
const bin = join(dir, "node_modules", "vite", "bin", "vite.js");
|
|
1543
1543
|
if (existsSync(bin)) return bin;
|
|
1544
1544
|
const parent = dirname(dir);
|
|
1545
1545
|
if (parent === dir) return bin;
|
|
@@ -3011,51 +3011,274 @@ var AddonRegistry = class {
|
|
|
3011
3011
|
//#region src/deck/system-buttons/types.ts
|
|
3012
3012
|
const SYSTEM_BUTTON_TYPES = [
|
|
3013
3013
|
"core:back",
|
|
3014
|
+
"core:modal-ok",
|
|
3014
3015
|
"core:settings-entry",
|
|
3015
3016
|
"core:overlay-toggle",
|
|
3016
3017
|
"core:temporary-error"
|
|
3017
3018
|
];
|
|
3018
3019
|
const isSystemButtonType = (value) => SYSTEM_BUTTON_TYPES.includes(value);
|
|
3019
3020
|
//#endregion
|
|
3020
|
-
//#region src/
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
];
|
|
3021
|
+
//#region src/deck/position-buttons.ts
|
|
3022
|
+
/**
|
|
3023
|
+
* Assigns a position to every button — no drops.
|
|
3024
|
+
*
|
|
3025
|
+
* - Buttons with a valid explicit `position` keep it (first-come wins
|
|
3026
|
+
* for duplicates).
|
|
3027
|
+
* - Duplicate positions and buttons without a position fall through to
|
|
3028
|
+
* a "gap" queue, filled sequentially starting at 0 in array order.
|
|
3029
|
+
* - Positions ≥ keyCount are preserved: the caller is responsible for
|
|
3030
|
+
* pagination (group by `floor(pos / (K-2))`). The deck-config and
|
|
3031
|
+
* addon-deck pipelines both go through `paginateDeck` for that.
|
|
3032
|
+
* - The internal contract: every emitted button has `position` set.
|
|
3033
|
+
*
|
|
3034
|
+
* ponytail: O(n²) scan is fine for deck sizes (<30).
|
|
3035
|
+
*/
|
|
3036
|
+
const positionButtons = (buttons, keyCount, logger) => {
|
|
3037
|
+
const occupied = /* @__PURE__ */ new Set();
|
|
3038
|
+
const result = [];
|
|
3039
|
+
const unfixed = [];
|
|
3040
|
+
for (const btn of buttons) {
|
|
3041
|
+
const pos = btn.position;
|
|
3042
|
+
if (pos === void 0 || !Number.isFinite(pos) || pos < 0) {
|
|
3043
|
+
unfixed.push(btn);
|
|
3044
|
+
continue;
|
|
3045
|
+
}
|
|
3046
|
+
if (occupied.has(pos)) {
|
|
3047
|
+
logger?.debug({
|
|
3048
|
+
position: pos,
|
|
3049
|
+
reason: "duplicate"
|
|
3050
|
+
}, "duplicate position, treating as unfixed");
|
|
3051
|
+
unfixed.push(btn);
|
|
3052
|
+
continue;
|
|
3053
|
+
}
|
|
3054
|
+
occupied.add(pos);
|
|
3055
|
+
result.push(btn);
|
|
3056
|
+
}
|
|
3057
|
+
let gap = 0;
|
|
3058
|
+
for (const btn of unfixed) {
|
|
3059
|
+
while (occupied.has(gap)) gap++;
|
|
3060
|
+
occupied.add(gap);
|
|
3061
|
+
result.push({
|
|
3062
|
+
...btn,
|
|
3063
|
+
position: gap
|
|
3064
|
+
});
|
|
3065
|
+
gap++;
|
|
3066
|
+
}
|
|
3067
|
+
return result;
|
|
3039
3068
|
};
|
|
3040
|
-
const formatCommand = (cmd) => cmd.map(escape).join(" ");
|
|
3041
3069
|
//#endregion
|
|
3042
|
-
//#region src/
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3070
|
+
//#region src/core/icon-source.ts
|
|
3071
|
+
const EMOJI_RE = /^(?:[\p{Extended_Pictographic}\p{Emoji_Component}]\uFE0F?(?:\u200D[\p{Extended_Pictographic}\p{Emoji_Component}]\uFE0F?)*|\p{Regional_Indicator}{2})$/u;
|
|
3072
|
+
const ICON_FALLBACK = "icon://alert-circle";
|
|
3073
|
+
const ABSOLUTE_PATH_RE = /^(?:\/|\\|[A-Za-z]:[\\/])/;
|
|
3074
|
+
/**
|
|
3075
|
+
* Validate that a runtime icon source is one of:
|
|
3076
|
+
* - `icon://<name>` — Lucide icon by name (resolved by the runtime
|
|
3077
|
+
* `resolveIconSource`)
|
|
3078
|
+
* - `asset://<id>` — pre-resolved asset id from the registry
|
|
3079
|
+
* - `addon://<a>/<p>` — asset inside an addon's frontendEntry dir
|
|
3080
|
+
* - `builtin://<p>` — asset inside the builtin addon's dir
|
|
3081
|
+
* - absolute path — asset resolved directly
|
|
3082
|
+
* - relative path — asset resolved against the config's baseDirs
|
|
3083
|
+
* (e.g. `./assets/chrome.svg`, `../shared/icon.svg`,
|
|
3084
|
+
* `~/Pictures/x.png`)
|
|
3085
|
+
* - a single emoji (Presentation, or base+VS16 like ✈️; also
|
|
3086
|
+
* regional-indicator pair flags like 🇪🇸, and ZWJ sequences
|
|
3087
|
+
* like 🏳️🌈 or 👨👩👧)
|
|
3088
|
+
*
|
|
3089
|
+
* Rejected: empty string, "%", "abc", multi-char (e.g. "abc🔥"),
|
|
3090
|
+
* inline URLs (data:, http://, https://, file://) — these must be
|
|
3091
|
+
* pre-resolved to asset:// before reaching the runtime.
|
|
3092
|
+
*
|
|
3093
|
+
* Anything rejected here triggers a runtime fallback (alert-circle
|
|
3094
|
+
* Lucide icon) AND, at config-load, a zod validation error.
|
|
3095
|
+
*/
|
|
3096
|
+
const isIconSource = (s) => {
|
|
3097
|
+
if (typeof s !== "string" || s.length === 0) return false;
|
|
3098
|
+
if (EMOJI_RE.test(s)) return true;
|
|
3099
|
+
if (s.startsWith("icon://") && s.length > 7) return true;
|
|
3100
|
+
if (s.startsWith("asset://") && s.length > 8) return true;
|
|
3101
|
+
if (s.startsWith("addon://")) {
|
|
3102
|
+
const rest = s.slice(8);
|
|
3103
|
+
const slash = rest.indexOf("/");
|
|
3104
|
+
if (slash > 0 && slash < rest.length - 1) return true;
|
|
3105
|
+
return false;
|
|
3056
3106
|
}
|
|
3107
|
+
if (s.startsWith("builtin://") && s.length > 10) return true;
|
|
3108
|
+
if (s.startsWith("data:") || s.startsWith("http://") || s.startsWith("https://") || s.startsWith("file://")) return false;
|
|
3109
|
+
if (ABSOLUTE_PATH_RE.test(s)) return true;
|
|
3110
|
+
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(s)) return false;
|
|
3111
|
+
if (s === "." || s === "~" || s.startsWith("./") || s.startsWith("../") || s.startsWith("~/") || s.startsWith("~\\") || /[\\/]/.test(s) || s.startsWith("/")) return true;
|
|
3112
|
+
return false;
|
|
3057
3113
|
};
|
|
3058
3114
|
//#endregion
|
|
3115
|
+
//#region src/config/schemas.ts
|
|
3116
|
+
const TriggerSchema = z.object({
|
|
3117
|
+
process_name: z.union([z.string(), z.array(z.string()).min(1)]).optional(),
|
|
3118
|
+
window_name: z.union([z.string(), z.array(z.string()).min(1)]).optional()
|
|
3119
|
+
}).strict().refine((t) => t.process_name !== void 0 || t.window_name !== void 0, { message: "trigger requires at least one of `process_name` or `window_name`" });
|
|
3120
|
+
const ButtonActionsSchema = z.object({
|
|
3121
|
+
tap: z.string().min(1).optional().meta({ title: "Tap action" }),
|
|
3122
|
+
dbltap: z.string().min(1).optional().meta({ title: "Double-tap action" }),
|
|
3123
|
+
hold: z.string().min(1).optional().meta({ title: "Hold action" })
|
|
3124
|
+
}).strict();
|
|
3125
|
+
/**
|
|
3126
|
+
* Runtime icon source. Accepted shapes:
|
|
3127
|
+
* - `icon://<name>` — Lucide icon by name (resolved at render time)
|
|
3128
|
+
* - `asset://<id>` — pre-resolved asset id from the registry
|
|
3129
|
+
* - a single emoji (Presentation or base+VS16 like ✈️)
|
|
3130
|
+
*
|
|
3131
|
+
* Anything else is rejected at config-load time so typos surface before
|
|
3132
|
+
* the daemon starts. The runtime also has a fallback path (alert-circle
|
|
3133
|
+
* Lucide icon) so an invalid source that's slipped through can't crash
|
|
3134
|
+
* the render tree.
|
|
3135
|
+
*/
|
|
3136
|
+
const IconSourceSchema = z.string().min(1).refine(isIconSource, { message: "icon must be icon://<name>, asset://<id>, or a single emoji (one Presentation character or one base+VS16 like ✈️)" });
|
|
3137
|
+
const ButtonConfigSchema = z.record(z.string(), z.unknown()).optional();
|
|
3138
|
+
/**
|
|
3139
|
+
* Closed core set of per-button hue names. Themes declare which of these
|
|
3140
|
+
* (or which additional names like riptide's `neon-pink`) they support
|
|
3141
|
+
* by adding entries to `variants.<name>` in their manifest. Themes are
|
|
3142
|
+
* authoritative — this list is a convention hint, not a constraint on
|
|
3143
|
+
* the theme. Names not declared in the active theme fall back to
|
|
3144
|
+
* "default" with a console.warn at render time (ButtonFrame).
|
|
3145
|
+
*/
|
|
3146
|
+
const ButtonColorSchema = z.enum([
|
|
3147
|
+
"blue",
|
|
3148
|
+
"green",
|
|
3149
|
+
"purple",
|
|
3150
|
+
"cyan",
|
|
3151
|
+
"magenta",
|
|
3152
|
+
"amber",
|
|
3153
|
+
"lime"
|
|
3154
|
+
]);
|
|
3155
|
+
const ButtonDefSchema = z.object({
|
|
3156
|
+
position: z.number().int().nonnegative().optional(),
|
|
3157
|
+
type: z.string().min(1),
|
|
3158
|
+
config: ButtonConfigSchema,
|
|
3159
|
+
accent: z.string().optional(),
|
|
3160
|
+
background: z.string().optional(),
|
|
3161
|
+
actions: ButtonActionsSchema.optional(),
|
|
3162
|
+
/**
|
|
3163
|
+
* Variant token name. Resolved by ButtonFrame against the active
|
|
3164
|
+
* theme's CSS vars at render time. Themes may declare extra
|
|
3165
|
+
* variants beyond the 5-required set; users pick from whatever the
|
|
3166
|
+
* active theme supports. Unknown names fall back to "default" with
|
|
3167
|
+
* a console.warn.
|
|
3168
|
+
*/
|
|
3169
|
+
variant: z.string().min(1).optional(),
|
|
3170
|
+
/**
|
|
3171
|
+
* Per-button hue customisation. Themes declare a `variants.<name>`
|
|
3172
|
+
* entry for each buttonColor they support. See ButtonColorSchema
|
|
3173
|
+
* for the closed core set; themes may add their own names
|
|
3174
|
+
* (e.g. riptide's `neon-pink`) and the runtime accepts them — but
|
|
3175
|
+
* this Zod schema restricts to the core set so typos fail-fast at
|
|
3176
|
+
* config load.
|
|
3177
|
+
*/
|
|
3178
|
+
buttonColor: ButtonColorSchema.optional(),
|
|
3179
|
+
label: z.string().optional(),
|
|
3180
|
+
icon: IconSourceSchema.optional(),
|
|
3181
|
+
iconUrl: z.string().min(1).optional(),
|
|
3182
|
+
size: z.string().optional(),
|
|
3183
|
+
textSize: z.string().optional(),
|
|
3184
|
+
borderRadius: z.string().optional(),
|
|
3185
|
+
addon: z.string().optional(),
|
|
3186
|
+
action: z.string().optional()
|
|
3187
|
+
}).strict();
|
|
3188
|
+
const ButtonEntrySchema = z.union([ButtonDefSchema, z.string()]);
|
|
3189
|
+
const DeckDefSchema = z.object({
|
|
3190
|
+
name: z.string().min(1).optional(),
|
|
3191
|
+
label: z.string().min(1).optional(),
|
|
3192
|
+
columns: z.number().int().positive().optional(),
|
|
3193
|
+
rows: z.number().int().positive().optional(),
|
|
3194
|
+
icon: IconSourceSchema.optional(),
|
|
3195
|
+
background: z.string().min(1).optional(),
|
|
3196
|
+
paginated: z.boolean().optional(),
|
|
3197
|
+
trigger: TriggerSchema.optional(),
|
|
3198
|
+
autoShow: z.boolean().optional(),
|
|
3199
|
+
buttons: z.array(ButtonEntrySchema)
|
|
3200
|
+
}).strict();
|
|
3201
|
+
const UserDeckCreateSchema = z.object({
|
|
3202
|
+
id: z.string().min(1),
|
|
3203
|
+
name: z.string().min(1).optional(),
|
|
3204
|
+
icon: IconSourceSchema.optional(),
|
|
3205
|
+
background: z.string().min(1).optional(),
|
|
3206
|
+
paginated: z.boolean().optional()
|
|
3207
|
+
}).strict();
|
|
3208
|
+
const UserDeckUpdateSchema = z.object({
|
|
3209
|
+
name: z.string().min(1).optional(),
|
|
3210
|
+
icon: IconSourceSchema.nullable().optional(),
|
|
3211
|
+
background: z.string().min(1).nullable().optional(),
|
|
3212
|
+
paginated: z.boolean().optional(),
|
|
3213
|
+
trigger: TriggerSchema.nullable().optional(),
|
|
3214
|
+
autoShow: z.boolean().optional()
|
|
3215
|
+
}).strict();
|
|
3216
|
+
/**
|
|
3217
|
+
* Phase 11: per-deck overrides for an addon-deck generated by `createDeck(s)`.
|
|
3218
|
+
* The deck id is the key in the parent record. Field-level overrides
|
|
3219
|
+
* (`autoShow`/`name`/`icon`/`trigger`) apply on top of the generated
|
|
3220
|
+
* deck; `config` is forwarded to `createDeck(s)({config})` as an
|
|
3221
|
+
* additive merge over the addon's default config.
|
|
3222
|
+
*/
|
|
3223
|
+
const AddonDeckOverrideSchema = z.object({
|
|
3224
|
+
autoShow: z.boolean().optional(),
|
|
3225
|
+
name: z.string().min(1).optional(),
|
|
3226
|
+
icon: IconSourceSchema.optional(),
|
|
3227
|
+
trigger: TriggerSchema.optional(),
|
|
3228
|
+
config: z.record(z.string(), z.unknown()).optional()
|
|
3229
|
+
}).strict();
|
|
3230
|
+
const AddonDeckDefaultsSchema = z.object({ autoShow: z.boolean().optional() }).strict();
|
|
3231
|
+
/**
|
|
3232
|
+
* Phase 11: addon-config block under `addons[i]`. Hosts three shape variants:
|
|
3233
|
+
* - `defaults:` addon-wide deck defaults (applied before per-deck overrides)
|
|
3234
|
+
* - `decks:` record keyed by addon deck id, with per-deck overrides
|
|
3235
|
+
* - `service:` addon-global backend settings (never merged into deck config)
|
|
3236
|
+
*/
|
|
3237
|
+
const AddonConfigSchema = z.object({
|
|
3238
|
+
defaults: AddonDeckDefaultsSchema.optional(),
|
|
3239
|
+
decks: z.record(z.string(), AddonDeckOverrideSchema).optional(),
|
|
3240
|
+
service: z.record(z.string(), z.unknown()).optional()
|
|
3241
|
+
}).strict();
|
|
3242
|
+
const AddonEntrySchema = z.union([z.string().min(1), z.object({
|
|
3243
|
+
src: z.string().min(1),
|
|
3244
|
+
enabled: z.boolean().optional(),
|
|
3245
|
+
global: z.boolean().optional(),
|
|
3246
|
+
config: AddonConfigSchema.optional()
|
|
3247
|
+
}).strict()]);
|
|
3248
|
+
const LoggingSchema = z.object({
|
|
3249
|
+
level: z.enum([
|
|
3250
|
+
"trace",
|
|
3251
|
+
"debug",
|
|
3252
|
+
"info",
|
|
3253
|
+
"warn",
|
|
3254
|
+
"error",
|
|
3255
|
+
"fatal",
|
|
3256
|
+
"silent"
|
|
3257
|
+
]).optional(),
|
|
3258
|
+
verbose: z.boolean().optional()
|
|
3259
|
+
}).strict().optional();
|
|
3260
|
+
const LockSchema = z.object({ buttons: z.array(ButtonDefSchema).optional() }).strict().optional();
|
|
3261
|
+
const ThemeEntrySchema = z.union([z.string().min(1), z.object({
|
|
3262
|
+
src: z.string().min(1),
|
|
3263
|
+
global: z.boolean().optional()
|
|
3264
|
+
}).strict()]);
|
|
3265
|
+
const RawConfigSchema = z.object({
|
|
3266
|
+
theme: ThemeEntrySchema.optional(),
|
|
3267
|
+
logging: LoggingSchema,
|
|
3268
|
+
decks: z.record(z.string(), DeckDefSchema),
|
|
3269
|
+
addons: z.array(AddonEntrySchema).optional(),
|
|
3270
|
+
lock: LockSchema
|
|
3271
|
+
}).strict();
|
|
3272
|
+
//#endregion
|
|
3273
|
+
//#region src/builtin-addons/core/buttons/action/backend.ts
|
|
3274
|
+
var backend_default$23 = { configSchema: z.object({
|
|
3275
|
+
icon: IconSourceSchema.optional().meta({
|
|
3276
|
+
title: "Icon",
|
|
3277
|
+
"x-control": "icon"
|
|
3278
|
+
}),
|
|
3279
|
+
label: z.string().optional().meta({ title: "Label" })
|
|
3280
|
+
}).refine((c) => Boolean(c.icon) || Boolean(c.label), { message: "core:action requires at least one of 'icon' or 'label'" }) };
|
|
3281
|
+
//#endregion
|
|
3059
3282
|
//#region src/ui/theme-presentation.tsx
|
|
3060
3283
|
const ThemeUiPresentationContext = createContext(void 0);
|
|
3061
3284
|
function useThemeUiPresentation() {
|
|
@@ -3601,56 +3824,12 @@ function chipBase(props) {
|
|
|
3601
3824
|
return /* @__PURE__ */ jsx(Text, {
|
|
3602
3825
|
className: cn(["inline-flex items-center justify-center rounded-full border px-2 py-0 font-aux uppercase tracking-wide font-bold", TONE_CLASS$1[tone]]),
|
|
3603
3826
|
size: props.size ?? "sm",
|
|
3827
|
+
tone,
|
|
3604
3828
|
"data-sireno-ui-chip": "true",
|
|
3605
3829
|
text: props.text
|
|
3606
3830
|
});
|
|
3607
3831
|
}
|
|
3608
3832
|
//#endregion
|
|
3609
|
-
//#region src/core/icon-source.ts
|
|
3610
|
-
const EMOJI_RE = /^(?:[\p{Extended_Pictographic}\p{Emoji_Component}]\uFE0F?(?:\u200D[\p{Extended_Pictographic}\p{Emoji_Component}]\uFE0F?)*|\p{Regional_Indicator}{2})$/u;
|
|
3611
|
-
const ICON_FALLBACK = "icon://alert-circle";
|
|
3612
|
-
const ABSOLUTE_PATH_RE = /^(?:\/|\\|[A-Za-z]:[\\/])/;
|
|
3613
|
-
/**
|
|
3614
|
-
* Validate that a runtime icon source is one of:
|
|
3615
|
-
* - `icon://<name>` — Lucide icon by name (resolved by the runtime
|
|
3616
|
-
* `resolveIconSource`)
|
|
3617
|
-
* - `asset://<id>` — pre-resolved asset id from the registry
|
|
3618
|
-
* - `addon://<a>/<p>` — asset inside an addon's frontendEntry dir
|
|
3619
|
-
* - `builtin://<p>` — asset inside the builtin addon's dir
|
|
3620
|
-
* - absolute path — asset resolved directly
|
|
3621
|
-
* - relative path — asset resolved against the config's baseDirs
|
|
3622
|
-
* (e.g. `./assets/chrome.svg`, `../shared/icon.svg`,
|
|
3623
|
-
* `~/Pictures/x.png`)
|
|
3624
|
-
* - a single emoji (Presentation, or base+VS16 like ✈️; also
|
|
3625
|
-
* regional-indicator pair flags like 🇪🇸, and ZWJ sequences
|
|
3626
|
-
* like 🏳️🌈 or 👨👩👧)
|
|
3627
|
-
*
|
|
3628
|
-
* Rejected: empty string, "%", "abc", multi-char (e.g. "abc🔥"),
|
|
3629
|
-
* inline URLs (data:, http://, https://, file://) — these must be
|
|
3630
|
-
* pre-resolved to asset:// before reaching the runtime.
|
|
3631
|
-
*
|
|
3632
|
-
* Anything rejected here triggers a runtime fallback (alert-circle
|
|
3633
|
-
* Lucide icon) AND, at config-load, a zod validation error.
|
|
3634
|
-
*/
|
|
3635
|
-
const isIconSource = (s) => {
|
|
3636
|
-
if (typeof s !== "string" || s.length === 0) return false;
|
|
3637
|
-
if (EMOJI_RE.test(s)) return true;
|
|
3638
|
-
if (s.startsWith("icon://") && s.length > 7) return true;
|
|
3639
|
-
if (s.startsWith("asset://") && s.length > 8) return true;
|
|
3640
|
-
if (s.startsWith("addon://")) {
|
|
3641
|
-
const rest = s.slice(8);
|
|
3642
|
-
const slash = rest.indexOf("/");
|
|
3643
|
-
if (slash > 0 && slash < rest.length - 1) return true;
|
|
3644
|
-
return false;
|
|
3645
|
-
}
|
|
3646
|
-
if (s.startsWith("builtin://") && s.length > 10) return true;
|
|
3647
|
-
if (s.startsWith("data:") || s.startsWith("http://") || s.startsWith("https://") || s.startsWith("file://")) return false;
|
|
3648
|
-
if (ABSOLUTE_PATH_RE.test(s)) return true;
|
|
3649
|
-
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(s)) return false;
|
|
3650
|
-
if (s === "." || s === "~" || s.startsWith("./") || s.startsWith("../") || s.startsWith("~/") || s.startsWith("~\\") || /[\\/]/.test(s) || s.startsWith("/")) return true;
|
|
3651
|
-
return false;
|
|
3652
|
-
};
|
|
3653
|
-
//#endregion
|
|
3654
3833
|
//#region src/ui/contexts/AssetCacheContext.tsx
|
|
3655
3834
|
const AssetCacheContext = createContext(/* @__PURE__ */ new Map());
|
|
3656
3835
|
const useAssetCache = () => {
|
|
@@ -4438,394 +4617,37 @@ function paginatedSurfaceBase({ pages, gesture, intervalMs, autoReturnMs, classN
|
|
|
4438
4617
|
useEffect(() => {
|
|
4439
4618
|
setCurrent((p) => p >= count ? 0 : p);
|
|
4440
4619
|
}, [count]);
|
|
4441
|
-
const page = allPages[current];
|
|
4442
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
4443
|
-
className: cn("relative flex h-full w-full flex-col", className),
|
|
4444
|
-
style,
|
|
4445
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
4446
|
-
className: "min-h-0 flex-1",
|
|
4447
|
-
children: page.render(page.config)
|
|
4448
|
-
}), count > 1 && /* @__PURE__ */ jsx("div", {
|
|
4449
|
-
className: "absolute bottom-[-4px] left-0 right-0 flex items-center justify-center gap-1",
|
|
4450
|
-
children: allPages.map((_, i) => /* @__PURE__ */ jsx("div", { className: cn("h-1 w-1 rounded-full", i === current ? DOT_ACTIVE : DOT_INACTIVE) }, i))
|
|
4451
|
-
})]
|
|
4452
|
-
});
|
|
4453
|
-
}
|
|
4454
|
-
//#endregion
|
|
4455
|
-
//#region src/ui/surfaces/paginated-schema.ts
|
|
4456
|
-
/**
|
|
4457
|
-
* Wraps a page schema to accept either a single page object or an array.
|
|
4458
|
-
* Normalizes to `{ pages: [...] }`.
|
|
4459
|
-
*
|
|
4460
|
-
* @example
|
|
4461
|
-
* const Config = pagesSchema(z.discriminatedUnion("type", [BarPage, ChartPage]))
|
|
4462
|
-
* // single: { type: "bars", metrics: ["cpu"] } → { pages: [{ type: "bars", metrics: [...] }] }
|
|
4463
|
-
* // array: [{ type: "bars", ... }, { type: "chart", ... }] → { pages: [...] }
|
|
4464
|
-
*/
|
|
4465
|
-
function pagesSchema(page) {
|
|
4466
|
-
return z.preprocess((input) => {
|
|
4467
|
-
if (Array.isArray(input)) return { pages: input };
|
|
4468
|
-
if (input && typeof input === "object" && !("pages" in input)) return { pages: [input] };
|
|
4469
|
-
return input;
|
|
4470
|
-
}, z.object({ pages: z.array(page).min(1).max(5) }).strict());
|
|
4471
|
-
}
|
|
4472
|
-
//#endregion
|
|
4473
|
-
//#region src/api/react/registry.ts
|
|
4474
|
-
var ChannelRegistry = class ChannelRegistry {
|
|
4475
|
-
static _instance = null;
|
|
4476
|
-
static _announceSubscribe = null;
|
|
4477
|
-
lastPayloads = /* @__PURE__ */ new Map();
|
|
4478
|
-
listeners = /* @__PURE__ */ new Map();
|
|
4479
|
-
listenerCounts = /* @__PURE__ */ new Map();
|
|
4480
|
-
pendingChannels = [];
|
|
4481
|
-
flushScheduled = false;
|
|
4482
|
-
static instance() {
|
|
4483
|
-
if (ChannelRegistry._instance === null) ChannelRegistry._instance = new ChannelRegistry();
|
|
4484
|
-
return ChannelRegistry._instance;
|
|
4485
|
-
}
|
|
4486
|
-
static resetForTests() {
|
|
4487
|
-
ChannelRegistry._instance = null;
|
|
4488
|
-
ChannelRegistry._announceSubscribe = null;
|
|
4489
|
-
}
|
|
4490
|
-
static setAnnounceSubscribe(cb) {
|
|
4491
|
-
ChannelRegistry._announceSubscribe = cb;
|
|
4492
|
-
}
|
|
4493
|
-
publish(channel, payload) {
|
|
4494
|
-
this.lastPayloads.set(channel, payload);
|
|
4495
|
-
const set = this.listeners.get(channel);
|
|
4496
|
-
if (set !== void 0) for (const l of set) l(payload);
|
|
4497
|
-
}
|
|
4498
|
-
subscribe(channel, cb) {
|
|
4499
|
-
let set = this.listeners.get(channel);
|
|
4500
|
-
if (set === void 0) {
|
|
4501
|
-
set = /* @__PURE__ */ new Set();
|
|
4502
|
-
this.listeners.set(channel, set);
|
|
4503
|
-
}
|
|
4504
|
-
const listener = cb;
|
|
4505
|
-
set.add(listener);
|
|
4506
|
-
const prevCount = this.listenerCounts.get(channel) ?? 0;
|
|
4507
|
-
this.listenerCounts.set(channel, prevCount + 1);
|
|
4508
|
-
if (prevCount === 0) {
|
|
4509
|
-
this.pendingChannels.push(channel);
|
|
4510
|
-
if (!this.flushScheduled) {
|
|
4511
|
-
this.flushScheduled = true;
|
|
4512
|
-
queueMicrotask(() => this.flushPendingSubscriptions());
|
|
4513
|
-
}
|
|
4514
|
-
}
|
|
4515
|
-
return () => {
|
|
4516
|
-
set?.delete(listener);
|
|
4517
|
-
const count = this.listenerCounts.get(channel) ?? 0;
|
|
4518
|
-
if (count <= 1) this.listenerCounts.delete(channel);
|
|
4519
|
-
else this.listenerCounts.set(channel, count - 1);
|
|
4520
|
-
};
|
|
4521
|
-
}
|
|
4522
|
-
flushPendingSubscriptions() {
|
|
4523
|
-
this.flushScheduled = false;
|
|
4524
|
-
if (this.pendingChannels.length === 0) return;
|
|
4525
|
-
const channels = [...new Set(this.pendingChannels)];
|
|
4526
|
-
this.pendingChannels = [];
|
|
4527
|
-
ChannelRegistry._announceSubscribe?.(channels);
|
|
4528
|
-
}
|
|
4529
|
-
last(channel) {
|
|
4530
|
-
return this.lastPayloads.get(channel);
|
|
4531
|
-
}
|
|
4532
|
-
clear() {
|
|
4533
|
-
this.lastPayloads.clear();
|
|
4534
|
-
this.listeners.clear();
|
|
4535
|
-
this.listenerCounts.clear();
|
|
4536
|
-
this.pendingChannels = [];
|
|
4537
|
-
this.flushScheduled = false;
|
|
4538
|
-
}
|
|
4539
|
-
};
|
|
4540
|
-
//#endregion
|
|
4541
|
-
//#region src/api/react/use-addon-channel.ts
|
|
4542
|
-
const useAddonChannel$2 = (channel) => {
|
|
4543
|
-
const [data, setData] = useState(() => ChannelRegistry.instance().last(channel));
|
|
4544
|
-
useEffect(() => {
|
|
4545
|
-
return ChannelRegistry.instance().subscribe(channel, (payload) => {
|
|
4546
|
-
setData(payload);
|
|
4547
|
-
});
|
|
4548
|
-
}, [channel]);
|
|
4549
|
-
return { data };
|
|
4550
|
-
};
|
|
4551
|
-
//#endregion
|
|
4552
|
-
//#region src/api/react/use-button-state.tsx
|
|
4553
|
-
const NullButton = () => null;
|
|
4554
|
-
//#endregion
|
|
4555
|
-
//#region src/builtin-addons/brightness/buttons/brightness/frontend.tsx
|
|
4556
|
-
const BrightnessButtonFrontend$1 = ({ config }) => {
|
|
4557
|
-
const { action } = config ?? {};
|
|
4558
|
-
const { data } = useAddonChannel$2("brightness:current");
|
|
4559
|
-
if (data === void 0) return /* @__PURE__ */ jsx(Text, {
|
|
4560
|
-
size: "xs",
|
|
4561
|
-
tone: "muted",
|
|
4562
|
-
typography: "mono",
|
|
4563
|
-
className: "flex h-full w-full items-center justify-center",
|
|
4564
|
-
text: "—"
|
|
4565
|
-
});
|
|
4566
|
-
const pct = Math.max(0, Math.min(100, data.value / (data.max || 100) * 100));
|
|
4567
|
-
return /* @__PURE__ */ jsxs("span", {
|
|
4568
|
-
className: "flex h-full w-full flex-col items-stretch justify-center gap-1 p-2",
|
|
4569
|
-
children: [
|
|
4570
|
-
/* @__PURE__ */ jsxs("span", {
|
|
4571
|
-
className: "flex items-baseline justify-between",
|
|
4572
|
-
children: [/* @__PURE__ */ jsx(Text, {
|
|
4573
|
-
size: "xs",
|
|
4574
|
-
tone: "muted",
|
|
4575
|
-
fit: "ellipsis",
|
|
4576
|
-
text: "Brightness"
|
|
4577
|
-
}), /* @__PURE__ */ jsx(Text, {
|
|
4578
|
-
size: "xs",
|
|
4579
|
-
tone: "fg",
|
|
4580
|
-
text: `${pct.toFixed(0)}%`
|
|
4581
|
-
})]
|
|
4582
|
-
}),
|
|
4583
|
-
/* @__PURE__ */ jsx("span", {
|
|
4584
|
-
className: "block h-1.5 w-full overflow-hidden rounded bg-bar",
|
|
4585
|
-
children: /* @__PURE__ */ jsx("span", {
|
|
4586
|
-
className: "block h-full bg-accent",
|
|
4587
|
-
style: { width: `${pct}%` }
|
|
4588
|
-
})
|
|
4589
|
-
}),
|
|
4590
|
-
/* @__PURE__ */ jsx(Text, {
|
|
4591
|
-
size: "xs",
|
|
4592
|
-
tone: "muted",
|
|
4593
|
-
className: "text-center",
|
|
4594
|
-
typography: "aux",
|
|
4595
|
-
text: `Tap: ${action ?? "up"}`
|
|
4596
|
-
})
|
|
4597
|
-
]
|
|
4598
|
-
});
|
|
4599
|
-
};
|
|
4600
|
-
//#endregion
|
|
4601
|
-
//#region src/builtin-addons/brightness/index.ts
|
|
4602
|
-
const manifest$9 = {
|
|
4603
|
-
apiVersion: 1,
|
|
4604
|
-
name: "brightness",
|
|
4605
|
-
buttonTypes: { "brightness:brightness": {
|
|
4606
|
-
frontend: BrightnessButtonFrontend$1,
|
|
4607
|
-
service: {
|
|
4608
|
-
...backend_default$24,
|
|
4609
|
-
gestureHandlers: ["tap"]
|
|
4610
|
-
}
|
|
4611
|
-
} },
|
|
4612
|
-
publishIntervalMs: 2e3
|
|
4613
|
-
};
|
|
4614
|
-
//#endregion
|
|
4615
|
-
//#region src/deck/position-buttons.ts
|
|
4616
|
-
/**
|
|
4617
|
-
* Assigns a position to every button — no drops.
|
|
4618
|
-
*
|
|
4619
|
-
* - Buttons with a valid explicit `position` keep it (first-come wins
|
|
4620
|
-
* for duplicates).
|
|
4621
|
-
* - Duplicate positions and buttons without a position fall through to
|
|
4622
|
-
* a "gap" queue, filled sequentially starting at 0 in array order.
|
|
4623
|
-
* - Positions ≥ keyCount are preserved: the caller is responsible for
|
|
4624
|
-
* pagination (group by `floor(pos / (K-2))`). The deck-config and
|
|
4625
|
-
* addon-deck pipelines both go through `paginateDeck` for that.
|
|
4626
|
-
* - The internal contract: every emitted button has `position` set.
|
|
4627
|
-
*
|
|
4628
|
-
* ponytail: O(n²) scan is fine for deck sizes (<30).
|
|
4629
|
-
*/
|
|
4630
|
-
const positionButtons = (buttons, keyCount, logger) => {
|
|
4631
|
-
const occupied = /* @__PURE__ */ new Set();
|
|
4632
|
-
const result = [];
|
|
4633
|
-
const unfixed = [];
|
|
4634
|
-
for (const btn of buttons) {
|
|
4635
|
-
const pos = btn.position;
|
|
4636
|
-
if (pos === void 0 || !Number.isFinite(pos) || pos < 0) {
|
|
4637
|
-
unfixed.push(btn);
|
|
4638
|
-
continue;
|
|
4639
|
-
}
|
|
4640
|
-
if (occupied.has(pos)) {
|
|
4641
|
-
logger?.debug({
|
|
4642
|
-
position: pos,
|
|
4643
|
-
reason: "duplicate"
|
|
4644
|
-
}, "duplicate position, treating as unfixed");
|
|
4645
|
-
unfixed.push(btn);
|
|
4646
|
-
continue;
|
|
4647
|
-
}
|
|
4648
|
-
occupied.add(pos);
|
|
4649
|
-
result.push(btn);
|
|
4650
|
-
}
|
|
4651
|
-
let gap = 0;
|
|
4652
|
-
for (const btn of unfixed) {
|
|
4653
|
-
while (occupied.has(gap)) gap++;
|
|
4654
|
-
occupied.add(gap);
|
|
4655
|
-
result.push({
|
|
4656
|
-
...btn,
|
|
4657
|
-
position: gap
|
|
4658
|
-
});
|
|
4659
|
-
gap++;
|
|
4660
|
-
}
|
|
4661
|
-
return result;
|
|
4662
|
-
};
|
|
4620
|
+
const page = allPages[current];
|
|
4621
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
4622
|
+
className: cn("relative flex h-full w-full flex-col", className),
|
|
4623
|
+
style,
|
|
4624
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
4625
|
+
className: "min-h-0 flex-1",
|
|
4626
|
+
children: page.render(page.config)
|
|
4627
|
+
}), count > 1 && /* @__PURE__ */ jsx("div", {
|
|
4628
|
+
className: "absolute bottom-[-4px] left-0 right-0 flex items-center justify-center gap-1",
|
|
4629
|
+
children: allPages.map((_, i) => /* @__PURE__ */ jsx("div", { className: cn("h-1 w-1 rounded-full", i === current ? DOT_ACTIVE : DOT_INACTIVE) }, i))
|
|
4630
|
+
})]
|
|
4631
|
+
});
|
|
4632
|
+
}
|
|
4663
4633
|
//#endregion
|
|
4664
|
-
//#region src/
|
|
4665
|
-
const TriggerSchema = z.object({
|
|
4666
|
-
process_name: z.union([z.string(), z.array(z.string()).min(1)]).optional(),
|
|
4667
|
-
window_name: z.union([z.string(), z.array(z.string()).min(1)]).optional()
|
|
4668
|
-
}).strict().refine((t) => t.process_name !== void 0 || t.window_name !== void 0, { message: "trigger requires at least one of `process_name` or `window_name`" });
|
|
4669
|
-
const ButtonActionsSchema = z.object({
|
|
4670
|
-
tap: z.string().min(1).optional().meta({ title: "Tap action" }),
|
|
4671
|
-
dbltap: z.string().min(1).optional().meta({ title: "Double-tap action" }),
|
|
4672
|
-
hold: z.string().min(1).optional().meta({ title: "Hold action" })
|
|
4673
|
-
}).strict();
|
|
4634
|
+
//#region src/ui/surfaces/paginated-schema.ts
|
|
4674
4635
|
/**
|
|
4675
|
-
*
|
|
4676
|
-
*
|
|
4677
|
-
* - `asset://<id>` — pre-resolved asset id from the registry
|
|
4678
|
-
* - a single emoji (Presentation or base+VS16 like ✈️)
|
|
4636
|
+
* Wraps a page schema to accept either a single page object or an array.
|
|
4637
|
+
* Normalizes to `{ pages: [...] }`.
|
|
4679
4638
|
*
|
|
4680
|
-
*
|
|
4681
|
-
*
|
|
4682
|
-
*
|
|
4683
|
-
*
|
|
4684
|
-
*/
|
|
4685
|
-
const IconSourceSchema = z.string().min(1).refine(isIconSource, { message: "icon must be icon://<name>, asset://<id>, or a single emoji (one Presentation character or one base+VS16 like ✈️)" });
|
|
4686
|
-
const ButtonConfigSchema = z.record(z.string(), z.unknown()).optional();
|
|
4687
|
-
/**
|
|
4688
|
-
* Closed core set of per-button hue names. Themes declare which of these
|
|
4689
|
-
* (or which additional names like riptide's `neon-pink`) they support
|
|
4690
|
-
* by adding entries to `variants.<name>` in their manifest. Themes are
|
|
4691
|
-
* authoritative — this list is a convention hint, not a constraint on
|
|
4692
|
-
* the theme. Names not declared in the active theme fall back to
|
|
4693
|
-
* "default" with a console.warn at render time (ButtonFrame).
|
|
4694
|
-
*/
|
|
4695
|
-
const ButtonColorSchema = z.enum([
|
|
4696
|
-
"blue",
|
|
4697
|
-
"green",
|
|
4698
|
-
"purple",
|
|
4699
|
-
"cyan",
|
|
4700
|
-
"magenta",
|
|
4701
|
-
"amber",
|
|
4702
|
-
"lime"
|
|
4703
|
-
]);
|
|
4704
|
-
const ButtonDefSchema = z.object({
|
|
4705
|
-
position: z.number().int().nonnegative().optional(),
|
|
4706
|
-
type: z.string().min(1),
|
|
4707
|
-
config: ButtonConfigSchema,
|
|
4708
|
-
accent: z.string().optional(),
|
|
4709
|
-
background: z.string().optional(),
|
|
4710
|
-
actions: ButtonActionsSchema.optional(),
|
|
4711
|
-
/**
|
|
4712
|
-
* Variant token name. Resolved by ButtonFrame against the active
|
|
4713
|
-
* theme's CSS vars at render time. Themes may declare extra
|
|
4714
|
-
* variants beyond the 5-required set; users pick from whatever the
|
|
4715
|
-
* active theme supports. Unknown names fall back to "default" with
|
|
4716
|
-
* a console.warn.
|
|
4717
|
-
*/
|
|
4718
|
-
variant: z.string().min(1).optional(),
|
|
4719
|
-
/**
|
|
4720
|
-
* Per-button hue customisation. Themes declare a `variants.<name>`
|
|
4721
|
-
* entry for each buttonColor they support. See ButtonColorSchema
|
|
4722
|
-
* for the closed core set; themes may add their own names
|
|
4723
|
-
* (e.g. riptide's `neon-pink`) and the runtime accepts them — but
|
|
4724
|
-
* this Zod schema restricts to the core set so typos fail-fast at
|
|
4725
|
-
* config load.
|
|
4726
|
-
*/
|
|
4727
|
-
buttonColor: ButtonColorSchema.optional(),
|
|
4728
|
-
label: z.string().optional(),
|
|
4729
|
-
icon: IconSourceSchema.optional(),
|
|
4730
|
-
iconUrl: z.string().min(1).optional(),
|
|
4731
|
-
size: z.string().optional(),
|
|
4732
|
-
textSize: z.string().optional(),
|
|
4733
|
-
borderRadius: z.string().optional(),
|
|
4734
|
-
addon: z.string().optional(),
|
|
4735
|
-
action: z.string().optional()
|
|
4736
|
-
}).strict();
|
|
4737
|
-
const ButtonEntrySchema = z.union([ButtonDefSchema, z.string()]);
|
|
4738
|
-
const DeckDefSchema = z.object({
|
|
4739
|
-
name: z.string().min(1).optional(),
|
|
4740
|
-
label: z.string().min(1).optional(),
|
|
4741
|
-
columns: z.number().int().positive().optional(),
|
|
4742
|
-
rows: z.number().int().positive().optional(),
|
|
4743
|
-
icon: IconSourceSchema.optional(),
|
|
4744
|
-
background: z.string().min(1).optional(),
|
|
4745
|
-
paginated: z.boolean().optional(),
|
|
4746
|
-
trigger: TriggerSchema.optional(),
|
|
4747
|
-
autoShow: z.boolean().optional(),
|
|
4748
|
-
buttons: z.array(ButtonEntrySchema)
|
|
4749
|
-
}).strict();
|
|
4750
|
-
const UserDeckCreateSchema = z.object({
|
|
4751
|
-
id: z.string().min(1),
|
|
4752
|
-
name: z.string().min(1).optional(),
|
|
4753
|
-
icon: IconSourceSchema.optional(),
|
|
4754
|
-
background: z.string().min(1).optional(),
|
|
4755
|
-
paginated: z.boolean().optional()
|
|
4756
|
-
}).strict();
|
|
4757
|
-
const UserDeckUpdateSchema = z.object({
|
|
4758
|
-
name: z.string().min(1).optional(),
|
|
4759
|
-
icon: IconSourceSchema.nullable().optional(),
|
|
4760
|
-
background: z.string().min(1).nullable().optional(),
|
|
4761
|
-
paginated: z.boolean().optional(),
|
|
4762
|
-
trigger: TriggerSchema.nullable().optional(),
|
|
4763
|
-
autoShow: z.boolean().optional()
|
|
4764
|
-
}).strict();
|
|
4765
|
-
/**
|
|
4766
|
-
* Phase 11: per-deck overrides for an addon-deck generated by `createDeck(s)`.
|
|
4767
|
-
* The deck id is the key in the parent record. Field-level overrides
|
|
4768
|
-
* (`autoShow`/`name`/`icon`/`trigger`) apply on top of the generated
|
|
4769
|
-
* deck; `config` is forwarded to `createDeck(s)({config})` as an
|
|
4770
|
-
* additive merge over the addon's default config.
|
|
4771
|
-
*/
|
|
4772
|
-
const AddonDeckOverrideSchema = z.object({
|
|
4773
|
-
autoShow: z.boolean().optional(),
|
|
4774
|
-
name: z.string().min(1).optional(),
|
|
4775
|
-
icon: IconSourceSchema.optional(),
|
|
4776
|
-
trigger: TriggerSchema.optional(),
|
|
4777
|
-
config: z.record(z.string(), z.unknown()).optional()
|
|
4778
|
-
}).strict();
|
|
4779
|
-
const AddonDeckDefaultsSchema = z.object({ autoShow: z.boolean().optional() }).strict();
|
|
4780
|
-
/**
|
|
4781
|
-
* Phase 11: addon-config block under `addons[i]`. Hosts three shape variants:
|
|
4782
|
-
* - `defaults:` addon-wide deck defaults (applied before per-deck overrides)
|
|
4783
|
-
* - `decks:` record keyed by addon deck id, with per-deck overrides
|
|
4784
|
-
* - addon-wide opaque config (anything else; merged into `createDeck(s)({config})`)
|
|
4639
|
+
* @example
|
|
4640
|
+
* const Config = pagesSchema(z.discriminatedUnion("type", [BarPage, ChartPage]))
|
|
4641
|
+
* // single: { type: "bars", metrics: ["cpu"] } → { pages: [{ type: "bars", metrics: [...] }] }
|
|
4642
|
+
* // array: [{ type: "bars", ... }, { type: "chart", ... }] → { pages: [...] }
|
|
4785
4643
|
*/
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
global: z.boolean().optional(),
|
|
4794
|
-
config: AddonConfigSchema.optional()
|
|
4795
|
-
}).strict()]);
|
|
4796
|
-
const LoggingSchema = z.object({
|
|
4797
|
-
level: z.enum([
|
|
4798
|
-
"trace",
|
|
4799
|
-
"debug",
|
|
4800
|
-
"info",
|
|
4801
|
-
"warn",
|
|
4802
|
-
"error",
|
|
4803
|
-
"fatal",
|
|
4804
|
-
"silent"
|
|
4805
|
-
]).optional(),
|
|
4806
|
-
verbose: z.boolean().optional()
|
|
4807
|
-
}).strict().optional();
|
|
4808
|
-
const LockSchema = z.object({ buttons: z.array(ButtonDefSchema).optional() }).strict().optional();
|
|
4809
|
-
const ThemeEntrySchema = z.union([z.string().min(1), z.object({
|
|
4810
|
-
src: z.string().min(1),
|
|
4811
|
-
global: z.boolean().optional()
|
|
4812
|
-
}).strict()]);
|
|
4813
|
-
const RawConfigSchema = z.object({
|
|
4814
|
-
theme: ThemeEntrySchema.optional(),
|
|
4815
|
-
logging: LoggingSchema,
|
|
4816
|
-
decks: z.record(z.string(), DeckDefSchema),
|
|
4817
|
-
addons: z.array(AddonEntrySchema).optional(),
|
|
4818
|
-
lock: LockSchema
|
|
4819
|
-
}).strict();
|
|
4820
|
-
//#endregion
|
|
4821
|
-
//#region src/builtin-addons/core/buttons/action/backend.ts
|
|
4822
|
-
var backend_default$23 = { configSchema: z.object({
|
|
4823
|
-
icon: IconSourceSchema.optional().meta({
|
|
4824
|
-
title: "Icon",
|
|
4825
|
-
"x-control": "icon"
|
|
4826
|
-
}),
|
|
4827
|
-
label: z.string().optional().meta({ title: "Label" })
|
|
4828
|
-
}).refine((c) => Boolean(c.icon) || Boolean(c.label), { message: "core:action requires at least one of 'icon' or 'label'" }) };
|
|
4644
|
+
function pagesSchema(page) {
|
|
4645
|
+
return z.preprocess((input) => {
|
|
4646
|
+
if (Array.isArray(input)) return { pages: input };
|
|
4647
|
+
if (input && typeof input === "object" && !("pages" in input)) return { pages: [input] };
|
|
4648
|
+
return input;
|
|
4649
|
+
}, z.object({ pages: z.array(page).min(1).max(5) }).strict());
|
|
4650
|
+
}
|
|
4829
4651
|
//#endregion
|
|
4830
4652
|
//#region src/builtin-addons/core/buttons/action/frontend.tsx
|
|
4831
4653
|
const CoreActionButtonFrontend = ({ config }) => {
|
|
@@ -4857,23 +4679,105 @@ var backend_default$22 = {
|
|
|
4857
4679
|
}
|
|
4858
4680
|
};
|
|
4859
4681
|
//#endregion
|
|
4860
|
-
//#region src/builtin-addons/core/buttons/change-deck/frontend.tsx
|
|
4861
|
-
const CoreChangeDeckButtonFrontend = ({ config }) => {
|
|
4862
|
-
const { icon, label } = config ?? {};
|
|
4863
|
-
return /* @__PURE__ */ jsx(IconLabelSurface, {
|
|
4864
|
-
...icon !== void 0 ? { source: icon } : {},
|
|
4865
|
-
label: label ?? ""
|
|
4866
|
-
});
|
|
4682
|
+
//#region src/builtin-addons/core/buttons/change-deck/frontend.tsx
|
|
4683
|
+
const CoreChangeDeckButtonFrontend = ({ config }) => {
|
|
4684
|
+
const { icon, label } = config ?? {};
|
|
4685
|
+
return /* @__PURE__ */ jsx(IconLabelSurface, {
|
|
4686
|
+
...icon !== void 0 ? { source: icon } : {},
|
|
4687
|
+
label: label ?? ""
|
|
4688
|
+
});
|
|
4689
|
+
};
|
|
4690
|
+
//#endregion
|
|
4691
|
+
//#region src/builtin-addons/core/buttons/media-sample/backend.ts
|
|
4692
|
+
var backend_default$21 = {
|
|
4693
|
+
configSchema: z.object({
|
|
4694
|
+
channel: z.string().min(1).meta({ title: "Data channel" }),
|
|
4695
|
+
fallback: z.unknown().optional().meta({ title: "Fallback value" })
|
|
4696
|
+
}),
|
|
4697
|
+
onTap: async () => {}
|
|
4698
|
+
};
|
|
4699
|
+
//#endregion
|
|
4700
|
+
//#region src/api/react/registry.ts
|
|
4701
|
+
var ChannelRegistry = class ChannelRegistry {
|
|
4702
|
+
static _instance = null;
|
|
4703
|
+
static _announceSubscribe = null;
|
|
4704
|
+
lastPayloads = /* @__PURE__ */ new Map();
|
|
4705
|
+
listeners = /* @__PURE__ */ new Map();
|
|
4706
|
+
listenerCounts = /* @__PURE__ */ new Map();
|
|
4707
|
+
pendingChannels = [];
|
|
4708
|
+
flushScheduled = false;
|
|
4709
|
+
static instance() {
|
|
4710
|
+
if (ChannelRegistry._instance === null) ChannelRegistry._instance = new ChannelRegistry();
|
|
4711
|
+
return ChannelRegistry._instance;
|
|
4712
|
+
}
|
|
4713
|
+
static resetForTests() {
|
|
4714
|
+
ChannelRegistry._instance = null;
|
|
4715
|
+
ChannelRegistry._announceSubscribe = null;
|
|
4716
|
+
}
|
|
4717
|
+
static setAnnounceSubscribe(cb) {
|
|
4718
|
+
ChannelRegistry._announceSubscribe = cb;
|
|
4719
|
+
}
|
|
4720
|
+
publish(channel, payload) {
|
|
4721
|
+
this.lastPayloads.set(channel, payload);
|
|
4722
|
+
const set = this.listeners.get(channel);
|
|
4723
|
+
if (set !== void 0) for (const l of set) l(payload);
|
|
4724
|
+
}
|
|
4725
|
+
subscribe(channel, cb) {
|
|
4726
|
+
let set = this.listeners.get(channel);
|
|
4727
|
+
if (set === void 0) {
|
|
4728
|
+
set = /* @__PURE__ */ new Set();
|
|
4729
|
+
this.listeners.set(channel, set);
|
|
4730
|
+
}
|
|
4731
|
+
const listener = cb;
|
|
4732
|
+
set.add(listener);
|
|
4733
|
+
const prevCount = this.listenerCounts.get(channel) ?? 0;
|
|
4734
|
+
this.listenerCounts.set(channel, prevCount + 1);
|
|
4735
|
+
if (prevCount === 0) {
|
|
4736
|
+
this.pendingChannels.push(channel);
|
|
4737
|
+
if (!this.flushScheduled) {
|
|
4738
|
+
this.flushScheduled = true;
|
|
4739
|
+
queueMicrotask(() => this.flushPendingSubscriptions());
|
|
4740
|
+
}
|
|
4741
|
+
}
|
|
4742
|
+
return () => {
|
|
4743
|
+
set?.delete(listener);
|
|
4744
|
+
const count = this.listenerCounts.get(channel) ?? 0;
|
|
4745
|
+
if (count <= 1) this.listenerCounts.delete(channel);
|
|
4746
|
+
else this.listenerCounts.set(channel, count - 1);
|
|
4747
|
+
};
|
|
4748
|
+
}
|
|
4749
|
+
flushPendingSubscriptions() {
|
|
4750
|
+
this.flushScheduled = false;
|
|
4751
|
+
if (this.pendingChannels.length === 0) return;
|
|
4752
|
+
const channels = [...new Set(this.pendingChannels)];
|
|
4753
|
+
this.pendingChannels = [];
|
|
4754
|
+
ChannelRegistry._announceSubscribe?.(channels);
|
|
4755
|
+
}
|
|
4756
|
+
last(channel) {
|
|
4757
|
+
return this.lastPayloads.get(channel);
|
|
4758
|
+
}
|
|
4759
|
+
clear() {
|
|
4760
|
+
this.lastPayloads.clear();
|
|
4761
|
+
this.listeners.clear();
|
|
4762
|
+
this.listenerCounts.clear();
|
|
4763
|
+
this.pendingChannels = [];
|
|
4764
|
+
this.flushScheduled = false;
|
|
4765
|
+
}
|
|
4766
|
+
};
|
|
4767
|
+
//#endregion
|
|
4768
|
+
//#region src/api/react/use-addon-channel.ts
|
|
4769
|
+
const useAddonChannel$2 = (channel) => {
|
|
4770
|
+
const [data, setData] = useState(() => ChannelRegistry.instance().last(channel));
|
|
4771
|
+
useEffect(() => {
|
|
4772
|
+
return ChannelRegistry.instance().subscribe(channel, (payload) => {
|
|
4773
|
+
setData(payload);
|
|
4774
|
+
});
|
|
4775
|
+
}, [channel]);
|
|
4776
|
+
return { data };
|
|
4867
4777
|
};
|
|
4868
4778
|
//#endregion
|
|
4869
|
-
//#region src/
|
|
4870
|
-
|
|
4871
|
-
configSchema: z.object({
|
|
4872
|
-
channel: z.string().min(1).meta({ title: "Data channel" }),
|
|
4873
|
-
fallback: z.unknown().optional().meta({ title: "Fallback value" })
|
|
4874
|
-
}),
|
|
4875
|
-
onTap: async () => {}
|
|
4876
|
-
};
|
|
4779
|
+
//#region src/api/react/use-button-state.tsx
|
|
4780
|
+
const NullButton = () => null;
|
|
4877
4781
|
//#endregion
|
|
4878
4782
|
//#region src/builtin-addons/core/buttons/media-sample/frontend.tsx
|
|
4879
4783
|
var frontend_default$1 = NullButton;
|
|
@@ -9828,7 +9732,7 @@ const BrightnessButtonFrontend = ({ variant, gesture }) => {
|
|
|
9828
9732
|
const [showProgress, setShowProgress] = useState(false);
|
|
9829
9733
|
const timerRef = useRef(null);
|
|
9830
9734
|
useEffect(() => {
|
|
9831
|
-
if (gesture?.gesture !== "tap" && gesture?.gesture !== "dbl-tap") return;
|
|
9735
|
+
if (gesture?.gesture !== "tap" && gesture?.gesture !== "dbl-tap" && gesture?.gesture !== "hold") return;
|
|
9832
9736
|
setShowProgress(true);
|
|
9833
9737
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
9834
9738
|
timerRef.current = setTimeout(() => setShowProgress(false), PROGRESS_VISIBLE_MS$1);
|
|
@@ -9838,7 +9742,7 @@ const BrightnessButtonFrontend = ({ variant, gesture }) => {
|
|
|
9838
9742
|
}, []);
|
|
9839
9743
|
return /* @__PURE__ */ jsx(IconLabelProgressSurface, {
|
|
9840
9744
|
source: `icon://${variant === "down" ? "sun-dim" : "sun"}`,
|
|
9841
|
-
label: variant === "down" ? "Darker" : "Lighter",
|
|
9745
|
+
label: variant === "compact" ? "Tap + / Hold −" : variant === "down" ? "Darker" : "Lighter",
|
|
9842
9746
|
progress,
|
|
9843
9747
|
visible: showProgress
|
|
9844
9748
|
});
|
|
@@ -9850,6 +9754,12 @@ const BrightnessDownButtonFrontend = ({ gesture }) => /* @__PURE__ */ jsx(Bright
|
|
|
9850
9754
|
gesture: gesture ?? null
|
|
9851
9755
|
});
|
|
9852
9756
|
//#endregion
|
|
9757
|
+
//#region src/builtin-addons/internal-settings/buttons/brightness-compact/frontend.tsx
|
|
9758
|
+
const CompactBrightnessFrontend = ({ gesture }) => /* @__PURE__ */ jsx(BrightnessButtonFrontend, {
|
|
9759
|
+
variant: "compact",
|
|
9760
|
+
gesture: gesture ?? null
|
|
9761
|
+
});
|
|
9762
|
+
//#endregion
|
|
9853
9763
|
//#region src/builtin-addons/internal-settings/buttons/brightness-up/backend.ts
|
|
9854
9764
|
var backend_default$9 = {
|
|
9855
9765
|
configSchema: z.object({ step: z.number().positive().max(100).default(5).meta({ title: "Brightness step" }) }),
|
|
@@ -9913,6 +9823,24 @@ const internalSettingsAddon = {
|
|
|
9913
9823
|
gestureHandlers: ["tap", "dbl-tap"]
|
|
9914
9824
|
}
|
|
9915
9825
|
},
|
|
9826
|
+
"internal-settings:compact-brightness": {
|
|
9827
|
+
frontend: CompactBrightnessFrontend,
|
|
9828
|
+
service: {
|
|
9829
|
+
...withInternal(backend_default$9),
|
|
9830
|
+
gestureHandlers: [
|
|
9831
|
+
"tap",
|
|
9832
|
+
"dbl-tap",
|
|
9833
|
+
"hold"
|
|
9834
|
+
],
|
|
9835
|
+
onHold: ({ coreMethods }) => {
|
|
9836
|
+
coreMethods.adjustBrightness({ direction: "down" });
|
|
9837
|
+
}
|
|
9838
|
+
}
|
|
9839
|
+
},
|
|
9840
|
+
"internal-settings:compact-app-info": {
|
|
9841
|
+
frontend: AppInfoButtonFrontend,
|
|
9842
|
+
service: { internal: true }
|
|
9843
|
+
},
|
|
9916
9844
|
"internal-settings:app-info": {
|
|
9917
9845
|
frontend: AppInfoButtonFrontend,
|
|
9918
9846
|
service: {
|
|
@@ -10422,8 +10350,23 @@ let provider = null;
|
|
|
10422
10350
|
let ctxRef$2 = null;
|
|
10423
10351
|
let captureMediaState = null;
|
|
10424
10352
|
let captureStage = "playing";
|
|
10353
|
+
let captureUpdatedAt = 0;
|
|
10425
10354
|
const captureMode = () => process.env["SIRENO_CAPTURE_FAKE_MEDIA"] === "1";
|
|
10355
|
+
const updateCaptureProgress = () => {
|
|
10356
|
+
if (captureMediaState === null) return;
|
|
10357
|
+
const now = Date.now();
|
|
10358
|
+
if (captureMediaState.isPlaying) {
|
|
10359
|
+
const currentTime = Math.min(captureMediaState.totalTime, captureMediaState.currentTime + (now - captureUpdatedAt) / 1e3);
|
|
10360
|
+
captureMediaState = {
|
|
10361
|
+
...captureMediaState,
|
|
10362
|
+
currentTime,
|
|
10363
|
+
progress: computeProgress(currentTime, captureMediaState.totalTime)
|
|
10364
|
+
};
|
|
10365
|
+
}
|
|
10366
|
+
captureUpdatedAt = now;
|
|
10367
|
+
};
|
|
10426
10368
|
const setCapturePlayback = (playing) => {
|
|
10369
|
+
updateCaptureProgress();
|
|
10427
10370
|
captureStage = playing ? "playing" : "paused";
|
|
10428
10371
|
if (captureMediaState === null) return;
|
|
10429
10372
|
captureMediaState = {
|
|
@@ -10465,6 +10408,7 @@ const globalService$3 = {
|
|
|
10465
10408
|
intervalMs: 1e3,
|
|
10466
10409
|
poll: async (_ctx) => {
|
|
10467
10410
|
if (captureMode() && captureMediaState !== null) {
|
|
10411
|
+
updateCaptureProgress();
|
|
10468
10412
|
const stagePath = process.env["SIRENO_CAPTURE_FAKE_MEDIA_FILE"];
|
|
10469
10413
|
if (stagePath !== void 0) try {
|
|
10470
10414
|
if (JSON.parse((await import("node:fs")).readFileSync(stagePath, "utf8")).stage === "paused" && captureStage !== "paused") setCapturePlayback(false);
|
|
@@ -10530,6 +10474,7 @@ const globalService$3 = {
|
|
|
10530
10474
|
muted: false
|
|
10531
10475
|
};
|
|
10532
10476
|
captureStage = "playing";
|
|
10477
|
+
captureUpdatedAt = Date.now();
|
|
10533
10478
|
provider = null;
|
|
10534
10479
|
return;
|
|
10535
10480
|
}
|
|
@@ -12185,7 +12130,7 @@ function formatValue(value, formatter) {
|
|
|
12185
12130
|
case "bytes": return formatBytes(value);
|
|
12186
12131
|
case "bool": return formatBool(value);
|
|
12187
12132
|
case "count": return { value: value.toFixed(0) };
|
|
12188
|
-
case "frequency-ghz": return { value: value.toFixed(
|
|
12133
|
+
case "frequency-ghz": return { value: value.toFixed(1) };
|
|
12189
12134
|
case "percent": return value < 10 ? {
|
|
12190
12135
|
value: value.toFixed(1),
|
|
12191
12136
|
unit: "%"
|
|
@@ -12472,7 +12417,7 @@ const CAPTURE_METRIC_VALUES = {
|
|
|
12472
12417
|
disk: 54,
|
|
12473
12418
|
"disk-io": 124e4,
|
|
12474
12419
|
"fan-rpm": 1260,
|
|
12475
|
-
frequency:
|
|
12420
|
+
frequency: 3.6,
|
|
12476
12421
|
"gpu-temp": 58,
|
|
12477
12422
|
"gpu-usage": 27,
|
|
12478
12423
|
load: 1.4,
|
|
@@ -13187,7 +13132,6 @@ const registerBuiltins = (registry) => {
|
|
|
13187
13132
|
registry.load(systemStatusAddon);
|
|
13188
13133
|
registry.load(manifest$1);
|
|
13189
13134
|
registry.load(manifest);
|
|
13190
|
-
registry.load(manifest$9);
|
|
13191
13135
|
registerCodingAgentsAddon(registry);
|
|
13192
13136
|
};
|
|
13193
13137
|
/**
|
|
@@ -13216,7 +13160,6 @@ const BUILTIN_MANIFESTS = /* @__PURE__ */ new Map([
|
|
|
13216
13160
|
["system-status", systemStatusAddon],
|
|
13217
13161
|
["value-display", manifest$1],
|
|
13218
13162
|
["weather", manifest],
|
|
13219
|
-
["brightness", manifest$9],
|
|
13220
13163
|
["coding-agents", manifest$3]
|
|
13221
13164
|
]);
|
|
13222
13165
|
[
|
|
@@ -13445,6 +13388,29 @@ const expandButtonReferences = (raw, configDir) => {
|
|
|
13445
13388
|
return raw;
|
|
13446
13389
|
};
|
|
13447
13390
|
//#endregion
|
|
13391
|
+
//#region src/config/environment.ts
|
|
13392
|
+
var MissingEnvironmentVariableError = class extends Error {
|
|
13393
|
+
variable;
|
|
13394
|
+
configPath;
|
|
13395
|
+
constructor(variable, configPath) {
|
|
13396
|
+
super(`Environment variable ${variable} is not set (at ${configPath || "<root>"})`);
|
|
13397
|
+
this.variable = variable;
|
|
13398
|
+
this.configPath = configPath;
|
|
13399
|
+
this.name = "MissingEnvironmentVariableError";
|
|
13400
|
+
}
|
|
13401
|
+
};
|
|
13402
|
+
/** Resolve placeholders in values, never mapping keys or YAML source text. */
|
|
13403
|
+
const resolveEnvironmentVariables = (value, env = process.env, path = "") => {
|
|
13404
|
+
if (typeof value === "string") return value.replace(/\$\{env:([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => {
|
|
13405
|
+
const resolved = Object.hasOwn(env, name) ? env[name] : void 0;
|
|
13406
|
+
if (resolved === void 0) throw new MissingEnvironmentVariableError(name, path);
|
|
13407
|
+
return resolved;
|
|
13408
|
+
});
|
|
13409
|
+
if (Array.isArray(value)) return value.map((item, index) => resolveEnvironmentVariables(item, env, `${path}[${index}]`));
|
|
13410
|
+
if (typeof value === "object" && value !== null) return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, resolveEnvironmentVariables(item, env, path ? `${path}.${key}` : key)]));
|
|
13411
|
+
return value;
|
|
13412
|
+
};
|
|
13413
|
+
//#endregion
|
|
13448
13414
|
//#region src/config/loader.ts
|
|
13449
13415
|
var ConfigLoadError = class extends Error {
|
|
13450
13416
|
issues;
|
|
@@ -13529,7 +13495,16 @@ const reportZodIssues = (issues) => issues.map((issue) => {
|
|
|
13529
13495
|
const loadConfig = ({ configPath }) => {
|
|
13530
13496
|
const configDir = dirname(configPath);
|
|
13531
13497
|
const raw = loadConfigFile(configPath);
|
|
13532
|
-
|
|
13498
|
+
let expanded;
|
|
13499
|
+
try {
|
|
13500
|
+
expanded = resolveEnvironmentVariables(expandButtonReferences(raw, configDir));
|
|
13501
|
+
} catch (err) {
|
|
13502
|
+
if (err instanceof MissingEnvironmentVariableError) throw new ConfigLoadError(err.message, [{
|
|
13503
|
+
message: err.message,
|
|
13504
|
+
path: err.configPath
|
|
13505
|
+
}]);
|
|
13506
|
+
throw err;
|
|
13507
|
+
}
|
|
13533
13508
|
const result = RawConfigSchema.safeParse(expanded);
|
|
13534
13509
|
if (!result.success) {
|
|
13535
13510
|
const issues = flattenZodIssues(result.error.issues);
|
|
@@ -13542,7 +13517,7 @@ const loadConfig = ({ configPath }) => {
|
|
|
13542
13517
|
};
|
|
13543
13518
|
//#endregion
|
|
13544
13519
|
//#region src/config/validation.ts
|
|
13545
|
-
const validateButton = (btn, registry, path, deckId, position) => {
|
|
13520
|
+
const validateButton = (btn, registry, path, deckId, position, allowInternal = false) => {
|
|
13546
13521
|
const base = {
|
|
13547
13522
|
deckId,
|
|
13548
13523
|
position
|
|
@@ -13565,7 +13540,7 @@ const validateButton = (btn, registry, path, deckId, position) => {
|
|
|
13565
13540
|
};
|
|
13566
13541
|
}
|
|
13567
13542
|
const def = registry.getButtonType(btn.type);
|
|
13568
|
-
if (isSystemButtonType(btn.type) || def.def.service.internal === true) {
|
|
13543
|
+
if (isSystemButtonType(btn.type) || !allowInternal && def.def.service.internal === true) {
|
|
13569
13544
|
issues.push({
|
|
13570
13545
|
level: "error",
|
|
13571
13546
|
path: `${path}.type`,
|
|
@@ -15229,6 +15204,7 @@ const paginate = (items, opts) => {
|
|
|
15229
15204
|
//#region src/deck/system-back-injection.ts
|
|
15230
15205
|
const computeSystemButtonForSlotN1 = (deck, state) => {
|
|
15231
15206
|
if (state.lockActive === true) return null;
|
|
15207
|
+
if (deck.isModal) return "core:modal-ok";
|
|
15232
15208
|
if (deck.isMain) return "core:settings-entry";
|
|
15233
15209
|
return "core:back";
|
|
15234
15210
|
};
|
|
@@ -15310,6 +15286,9 @@ const createRuntime = (options) => {
|
|
|
15310
15286
|
}
|
|
15311
15287
|
let brightness = 50;
|
|
15312
15288
|
let lockActive = false;
|
|
15289
|
+
const modals = [];
|
|
15290
|
+
let deferredOverlay = null;
|
|
15291
|
+
let interruption = null;
|
|
15313
15292
|
let legacyActiveApp = {
|
|
15314
15293
|
getActive: async () => null,
|
|
15315
15294
|
stop: async () => void 0
|
|
@@ -15320,6 +15299,17 @@ const createRuntime = (options) => {
|
|
|
15320
15299
|
const deckById = (id) => decks.find((d) => d.id === id);
|
|
15321
15300
|
const setDecks = (next) => {
|
|
15322
15301
|
decks = next;
|
|
15302
|
+
const activeModal = modals[0];
|
|
15303
|
+
for (let i = modals.length - 1; i >= 0; i--) if (deckById(modals[i].deckId) === void 0) modals.splice(i, 1);
|
|
15304
|
+
if (!lockActive && activeModal && modals[0] !== activeModal) {
|
|
15305
|
+
pubSub.publish("runtime:deck-inactive", { deckId: activeModal.deckId });
|
|
15306
|
+
pubSub.publish("runtime:activeDeck", { deckId: getActiveDeckId() });
|
|
15307
|
+
}
|
|
15308
|
+
if (interruption !== null && deckById(interruption.deckId) === void 0) {
|
|
15309
|
+
const previous = interruption.deckId;
|
|
15310
|
+
interruption = null;
|
|
15311
|
+
pubSub.publish("runtime:deck-inactive", { deckId: previous });
|
|
15312
|
+
}
|
|
15323
15313
|
buttonIndex.clear();
|
|
15324
15314
|
for (const deck of decks) {
|
|
15325
15315
|
if (!Array.isArray(deck.buttons)) continue;
|
|
@@ -15356,10 +15346,15 @@ const createRuntime = (options) => {
|
|
|
15356
15346
|
const id = getActiveDeckId();
|
|
15357
15347
|
const deck = deckById(id);
|
|
15358
15348
|
if (deck === void 0) throw new Error(`Active deck '${id}' not found`);
|
|
15359
|
-
return
|
|
15349
|
+
return !lockActive && modals[0]?.deckId === id ? {
|
|
15350
|
+
...deck,
|
|
15351
|
+
isModal: true
|
|
15352
|
+
} : deck;
|
|
15360
15353
|
};
|
|
15361
15354
|
const getActiveDeckId = () => {
|
|
15362
15355
|
if (lockActive) return "core:lock";
|
|
15356
|
+
if (modals[0]) return modals[0].deckId;
|
|
15357
|
+
if (interruption !== null) return interruption.deckId;
|
|
15363
15358
|
if (overlayDeckId !== null) {
|
|
15364
15359
|
if (transientDeckId !== null) return transientDeckId;
|
|
15365
15360
|
const stack = overlayNavStacks.get(overlayDeckId);
|
|
@@ -15369,6 +15364,51 @@ const createRuntime = (options) => {
|
|
|
15369
15364
|
return transientDeckId ?? navStack[navStack.length - 1] ?? mainDeck.id;
|
|
15370
15365
|
};
|
|
15371
15366
|
const snapshotRegularActiveDeckId = () => overlayPreviousActiveId ?? transientDeckId ?? navStack[navStack.length - 1] ?? mainDeck.id;
|
|
15367
|
+
const showModal = (id, options) => {
|
|
15368
|
+
if (!deckById(id)) return null;
|
|
15369
|
+
const previous = getActiveDeckId();
|
|
15370
|
+
const entry = {
|
|
15371
|
+
deckId: id,
|
|
15372
|
+
onOk: options?.onOk
|
|
15373
|
+
};
|
|
15374
|
+
modals.push(entry);
|
|
15375
|
+
if (!lockActive && modals[0] === entry) {
|
|
15376
|
+
pubSub.publish("runtime:deck-inactive", { deckId: previous });
|
|
15377
|
+
pubSub.publish("runtime:activeDeck", { deckId: id });
|
|
15378
|
+
}
|
|
15379
|
+
return () => {
|
|
15380
|
+
const index = modals.indexOf(entry);
|
|
15381
|
+
if (index < 0) return;
|
|
15382
|
+
const wasActive = index === 0 && !lockActive;
|
|
15383
|
+
modals.splice(index, 1);
|
|
15384
|
+
if (wasActive) {
|
|
15385
|
+
pubSub.publish("runtime:deck-inactive", { deckId: id });
|
|
15386
|
+
pubSub.publish("runtime:activeDeck", { deckId: getActiveDeckId() });
|
|
15387
|
+
if (modals.length === 0 && deferredOverlay) {
|
|
15388
|
+
const pending = deferredOverlay;
|
|
15389
|
+
deferredOverlay = null;
|
|
15390
|
+
setOverlay(pending.deckId, { source: pending.source });
|
|
15391
|
+
}
|
|
15392
|
+
}
|
|
15393
|
+
};
|
|
15394
|
+
};
|
|
15395
|
+
const interruptDeck = (id, options) => {
|
|
15396
|
+
if (lockActive || deckById(id) === void 0) return null;
|
|
15397
|
+
const previous = getActiveDeckId();
|
|
15398
|
+
const current = {
|
|
15399
|
+
deckId: id,
|
|
15400
|
+
onBack: options?.onBack
|
|
15401
|
+
};
|
|
15402
|
+
interruption = current;
|
|
15403
|
+
pubSub.publish("runtime:deck-inactive", { deckId: previous });
|
|
15404
|
+
pubSub.publish("runtime:activeDeck", { deckId: id });
|
|
15405
|
+
return () => {
|
|
15406
|
+
if (interruption !== current) return;
|
|
15407
|
+
interruption = null;
|
|
15408
|
+
pubSub.publish("runtime:deck-inactive", { deckId: id });
|
|
15409
|
+
pubSub.publish("runtime:activeDeck", { deckId: getActiveDeckId() });
|
|
15410
|
+
};
|
|
15411
|
+
};
|
|
15372
15412
|
const enterLock = () => {
|
|
15373
15413
|
const snapshot = {
|
|
15374
15414
|
activeDeckId: snapshotRegularActiveDeckId(),
|
|
@@ -15376,6 +15416,11 @@ const createRuntime = (options) => {
|
|
|
15376
15416
|
};
|
|
15377
15417
|
if (lockActive) return snapshot;
|
|
15378
15418
|
lockActive = true;
|
|
15419
|
+
if (interruption !== null) {
|
|
15420
|
+
const previous = interruption.deckId;
|
|
15421
|
+
interruption = null;
|
|
15422
|
+
pubSub.publish("runtime:deck-inactive", { deckId: previous });
|
|
15423
|
+
}
|
|
15379
15424
|
logger.info(snapshot, "runtime: lock active");
|
|
15380
15425
|
pubSub.publish("runtime:lock-mode", {
|
|
15381
15426
|
active: true,
|
|
@@ -15386,6 +15431,7 @@ const createRuntime = (options) => {
|
|
|
15386
15431
|
return snapshot;
|
|
15387
15432
|
};
|
|
15388
15433
|
const navigateToDeck = (id, navOptions) => {
|
|
15434
|
+
if (!lockActive && modals.length > 0) return;
|
|
15389
15435
|
if (id === getActiveDeckId()) return;
|
|
15390
15436
|
let resolvedId = id;
|
|
15391
15437
|
let target = deckById(id);
|
|
@@ -15400,6 +15446,15 @@ const createRuntime = (options) => {
|
|
|
15400
15446
|
logger.warn({ deckId: id }, "navigateToDeck: deck not found");
|
|
15401
15447
|
return;
|
|
15402
15448
|
}
|
|
15449
|
+
if (interruption !== null) {
|
|
15450
|
+
const previous = interruption.deckId;
|
|
15451
|
+
interruption = null;
|
|
15452
|
+
pubSub.publish("runtime:deck-inactive", { deckId: previous });
|
|
15453
|
+
if (getActiveDeckId() === resolvedId) {
|
|
15454
|
+
pubSub.publish("runtime:activeDeck", { deckId: resolvedId });
|
|
15455
|
+
return;
|
|
15456
|
+
}
|
|
15457
|
+
}
|
|
15403
15458
|
const previousActiveId = getActiveDeckId();
|
|
15404
15459
|
if (overlayDeckId !== null) {
|
|
15405
15460
|
if (overlayNavStacks.get(overlayDeckId) === void 0) overlayNavStacks.set(overlayDeckId, [overlayDeckId]);
|
|
@@ -15415,12 +15470,20 @@ const createRuntime = (options) => {
|
|
|
15415
15470
|
pubSub.publish("runtime:activeDeck", { deckId: resolvedId });
|
|
15416
15471
|
};
|
|
15417
15472
|
const goBack = () => {
|
|
15473
|
+
if (!lockActive && modals.length > 0) return;
|
|
15474
|
+
if (interruption !== null) {
|
|
15475
|
+
const previous = interruption.deckId;
|
|
15476
|
+
interruption = null;
|
|
15477
|
+
pubSub.publish("runtime:deck-inactive", { deckId: previous });
|
|
15478
|
+
pubSub.publish("runtime:activeDeck", { deckId: getActiveDeckId() });
|
|
15479
|
+
return;
|
|
15480
|
+
}
|
|
15418
15481
|
if (overlayDeckId !== null) {
|
|
15419
15482
|
const stack = overlayNavStacks.get(overlayDeckId);
|
|
15420
15483
|
if (stack !== void 0 && stack.length > 1) {
|
|
15421
|
-
stack.pop();
|
|
15484
|
+
const departed = stack.pop();
|
|
15422
15485
|
const prev = stack[stack.length - 1];
|
|
15423
|
-
pubSub.publish("runtime:deck-inactive", { deckId:
|
|
15486
|
+
pubSub.publish("runtime:deck-inactive", { deckId: departed });
|
|
15424
15487
|
pubSub.publish("runtime:activeDeck", { deckId: prev });
|
|
15425
15488
|
} else setOverlay(null);
|
|
15426
15489
|
return;
|
|
@@ -15452,10 +15515,23 @@ const createRuntime = (options) => {
|
|
|
15452
15515
|
pubSub.publish("runtime:activeDeck", { deckId: prev });
|
|
15453
15516
|
};
|
|
15454
15517
|
const setOverlay = (deckId, opts) => {
|
|
15518
|
+
if (!lockActive && modals.length > 0) {
|
|
15519
|
+
deferredOverlay = {
|
|
15520
|
+
deckId,
|
|
15521
|
+
...opts?.source ? { source: opts.source } : {}
|
|
15522
|
+
};
|
|
15523
|
+
return;
|
|
15524
|
+
}
|
|
15455
15525
|
if (deckId !== null && deckById(deckId) === void 0) {
|
|
15456
15526
|
logger.warn({ deckId }, "setOverlay: deck not found");
|
|
15457
15527
|
return;
|
|
15458
15528
|
}
|
|
15529
|
+
if (interruption !== null && deckId === overlayDeckId) return;
|
|
15530
|
+
if (interruption !== null && deckId !== overlayDeckId) {
|
|
15531
|
+
const previous = interruption.deckId;
|
|
15532
|
+
interruption = null;
|
|
15533
|
+
pubSub.publish("runtime:deck-inactive", { deckId: previous });
|
|
15534
|
+
}
|
|
15459
15535
|
if (deckId !== null && !overlayNavStacks.has(deckId)) overlayNavStacks.set(deckId, [deckId]);
|
|
15460
15536
|
const previousActiveId = getActiveDeckId();
|
|
15461
15537
|
const previousOverlayId = overlayDeckId;
|
|
@@ -15497,12 +15573,40 @@ const createRuntime = (options) => {
|
|
|
15497
15573
|
}, "mounted addon button");
|
|
15498
15574
|
};
|
|
15499
15575
|
const handleSystemButton = (type, gesture) => {
|
|
15576
|
+
if ((type === "core:back" || type === "core:modal-ok") && !lockActive && modals[0]) {
|
|
15577
|
+
if (gesture === "tap" || gesture === "hold") {
|
|
15578
|
+
const entry = modals.shift();
|
|
15579
|
+
pubSub.publish("runtime:deck-inactive", { deckId: entry.deckId });
|
|
15580
|
+
pubSub.publish("runtime:activeDeck", { deckId: getActiveDeckId() });
|
|
15581
|
+
if (modals.length === 0 && deferredOverlay) {
|
|
15582
|
+
const pending = deferredOverlay;
|
|
15583
|
+
deferredOverlay = null;
|
|
15584
|
+
setOverlay(pending.deckId, { source: pending.source });
|
|
15585
|
+
}
|
|
15586
|
+
if (entry.onOk) Promise.resolve().then(entry.onOk).catch((err) => logger.error({ err }, "modal OK action failed"));
|
|
15587
|
+
}
|
|
15588
|
+
return true;
|
|
15589
|
+
}
|
|
15500
15590
|
if (type === "core:back") {
|
|
15501
15591
|
if (gesture === "tap") {
|
|
15592
|
+
if (interruption?.onBack) {
|
|
15593
|
+
const current = interruption;
|
|
15594
|
+
if (current.backPending) return true;
|
|
15595
|
+
current.backPending = true;
|
|
15596
|
+
Promise.resolve().then(current.onBack).catch((err) => logger.error({ err }, "interruption back action failed")).finally(() => {
|
|
15597
|
+
current.backPending = false;
|
|
15598
|
+
});
|
|
15599
|
+
return true;
|
|
15600
|
+
}
|
|
15502
15601
|
goBack();
|
|
15503
15602
|
return true;
|
|
15504
15603
|
}
|
|
15505
15604
|
if (gesture === "hold") {
|
|
15605
|
+
if (interruption !== null) {
|
|
15606
|
+
const previous = interruption.deckId;
|
|
15607
|
+
interruption = null;
|
|
15608
|
+
pubSub.publish("runtime:deck-inactive", { deckId: previous });
|
|
15609
|
+
}
|
|
15506
15610
|
if (overlayDeckId !== null) setOverlay(null);
|
|
15507
15611
|
navStack.length = 0;
|
|
15508
15612
|
navStack.push(mainDeck.id);
|
|
@@ -15560,6 +15664,7 @@ const createRuntime = (options) => {
|
|
|
15560
15664
|
logger.warn({ buttonId }, "invokeAction: button not found");
|
|
15561
15665
|
return;
|
|
15562
15666
|
}
|
|
15667
|
+
if (!lockActive && modals[0] && found.deckId !== modals[0].deckId) return;
|
|
15563
15668
|
try {
|
|
15564
15669
|
if (handleSystemButton(found.button.type, gesture)) return;
|
|
15565
15670
|
if (lockActive && found.deckId === "core:lock") {
|
|
@@ -15683,6 +15788,7 @@ const createRuntime = (options) => {
|
|
|
15683
15788
|
logger.warn({ buttonId }, "dispatchGesture: button not found");
|
|
15684
15789
|
return;
|
|
15685
15790
|
}
|
|
15791
|
+
if (!lockActive && modals[0] && found.deckId !== modals[0].deckId) return;
|
|
15686
15792
|
gestureListener?.(found.button.id, {
|
|
15687
15793
|
gesture,
|
|
15688
15794
|
at: Date.now(),
|
|
@@ -15718,6 +15824,12 @@ const createRuntime = (options) => {
|
|
|
15718
15824
|
reason: "session-unlocked"
|
|
15719
15825
|
});
|
|
15720
15826
|
pubSub.publish("runtime:invalidate", void 0);
|
|
15827
|
+
if (modals[0]) pubSub.publish("runtime:activeDeck", { deckId: modals[0].deckId });
|
|
15828
|
+
else if (deferredOverlay) {
|
|
15829
|
+
const pending = deferredOverlay;
|
|
15830
|
+
deferredOverlay = null;
|
|
15831
|
+
setOverlay(pending.deckId, { source: pending.source });
|
|
15832
|
+
}
|
|
15721
15833
|
};
|
|
15722
15834
|
const startLegacyPolicy = () => {
|
|
15723
15835
|
legacyPolicy?.dispose();
|
|
@@ -15766,6 +15878,8 @@ const createRuntime = (options) => {
|
|
|
15766
15878
|
deckExists: (id) => deckById(id) !== void 0 || deckById(`${id}-p1`) !== void 0,
|
|
15767
15879
|
setDecks,
|
|
15768
15880
|
navigateToDeck,
|
|
15881
|
+
interruptDeck,
|
|
15882
|
+
showModal,
|
|
15769
15883
|
goBack,
|
|
15770
15884
|
setOverlay,
|
|
15771
15885
|
getOverlay,
|
|
@@ -15973,6 +16087,7 @@ const buildDeckConfigMessage = (deck, addonByType, resolverOptions = {}, navStat
|
|
|
15973
16087
|
surfaces: { [deck.id]: {
|
|
15974
16088
|
id: deck.id,
|
|
15975
16089
|
name: deck.name ?? deck.id,
|
|
16090
|
+
...deck.isModal === true ? { isModal: true } : {},
|
|
15976
16091
|
buttons: finalButtons,
|
|
15977
16092
|
...deck.buttonColor !== void 0 ? { buttonColor: deck.buttonColor } : {},
|
|
15978
16093
|
...deck.variant !== void 0 && deck.variant.length > 0 ? { variant: deck.variant } : {},
|
|
@@ -16144,7 +16259,13 @@ const paginateDeck = (opts) => {
|
|
|
16144
16259
|
};
|
|
16145
16260
|
//#endregion
|
|
16146
16261
|
//#region src/deck/inject-config-ui-button.ts
|
|
16147
|
-
const injectConfigUiButton = (decks, configUiUrl) => decks.map((deck) => deck.id !== "internal-settings:settings" ? deck : {
|
|
16262
|
+
const injectConfigUiButton = (decks, configUiUrl, keyCount = 15) => decks.map((deck) => deck.id !== "internal-settings:settings" && !deck.id.startsWith("internal-settings:settings-p") ? deck : keyCount === 6 ? {
|
|
16263
|
+
...deck,
|
|
16264
|
+
buttons: deck.buttons.map((button) => button.type === "internal-settings:compact-app-info" ? {
|
|
16265
|
+
...button,
|
|
16266
|
+
actions: { tap: `url://${configUiUrl}` }
|
|
16267
|
+
} : button)
|
|
16268
|
+
} : {
|
|
16148
16269
|
...deck,
|
|
16149
16270
|
buttons: [...deck.buttons, {
|
|
16150
16271
|
id: "config-ui",
|
|
@@ -16158,16 +16279,83 @@ const injectConfigUiButton = (decks, configUiUrl) => decks.map((deck) => deck.id
|
|
|
16158
16279
|
}]
|
|
16159
16280
|
});
|
|
16160
16281
|
//#endregion
|
|
16161
|
-
//#region src/deck/
|
|
16162
|
-
const
|
|
16163
|
-
|
|
16164
|
-
|
|
16165
|
-
|
|
16166
|
-
|
|
16167
|
-
|
|
16168
|
-
|
|
16169
|
-
|
|
16282
|
+
//#region src/deck/addon-settings.ts
|
|
16283
|
+
const settingsId = "internal-settings:settings";
|
|
16284
|
+
const buildAddonSettingsDecks = (decks, addons, keyCount) => {
|
|
16285
|
+
const base = decks.find((deck) => deck.id === settingsId);
|
|
16286
|
+
if (!base) return [...decks];
|
|
16287
|
+
const compact = keyCount === 6;
|
|
16288
|
+
const entries = addons.filter((addon) => addon.settings !== void 0);
|
|
16289
|
+
const start = compact ? 2 : 4;
|
|
16290
|
+
const available = keyCount - 1 - start;
|
|
16291
|
+
const paginated = entries.length > available;
|
|
16292
|
+
const pageSize = available - (paginated ? 1 : 0);
|
|
16293
|
+
if (pageSize < 1) return [...decks];
|
|
16294
|
+
const total = Math.max(1, Math.ceil(entries.length / pageSize));
|
|
16295
|
+
const pageId = (page) => page === 0 ? settingsId : `${settingsId}-p${page + 1}`;
|
|
16296
|
+
const pages = Array.from({ length: total }, (_, page) => {
|
|
16297
|
+
const buttons = compact ? [{
|
|
16298
|
+
id: "app-info",
|
|
16299
|
+
type: "internal-settings:compact-app-info",
|
|
16300
|
+
position: 0,
|
|
16301
|
+
config: { icon: "addon://internal-settings/logo72x72.png" }
|
|
16302
|
+
}, {
|
|
16303
|
+
id: "brightness",
|
|
16304
|
+
type: "internal-settings:compact-brightness",
|
|
16305
|
+
position: 1
|
|
16306
|
+
}] : [
|
|
16307
|
+
{
|
|
16308
|
+
id: "app-info",
|
|
16309
|
+
type: "internal-settings:app-info",
|
|
16310
|
+
position: 0,
|
|
16311
|
+
config: { icon: "addon://internal-settings/logo72x72.png" }
|
|
16312
|
+
},
|
|
16313
|
+
{
|
|
16314
|
+
id: "brightness-down",
|
|
16315
|
+
type: "internal-settings:brightness-down",
|
|
16316
|
+
position: 1
|
|
16317
|
+
},
|
|
16318
|
+
{
|
|
16319
|
+
id: "brightness-up",
|
|
16320
|
+
type: "internal-settings:brightness-up",
|
|
16321
|
+
position: 2
|
|
16322
|
+
}
|
|
16323
|
+
];
|
|
16324
|
+
for (const [index, addon] of entries.slice(page * pageSize, (page + 1) * pageSize).entries()) {
|
|
16325
|
+
const settings = addon.settings;
|
|
16326
|
+
buttons.push({
|
|
16327
|
+
id: `settings-${addon.name}`,
|
|
16328
|
+
type: "core:change-deck",
|
|
16329
|
+
position: start + index,
|
|
16330
|
+
config: {
|
|
16331
|
+
deck: settings.deck,
|
|
16332
|
+
label: settings.label,
|
|
16333
|
+
icon: settings.icon
|
|
16334
|
+
}
|
|
16335
|
+
});
|
|
16336
|
+
}
|
|
16337
|
+
if (paginated) buttons.push({
|
|
16338
|
+
id: "page-nav",
|
|
16339
|
+
type: "core:page-nav",
|
|
16340
|
+
position: keyCount - 2,
|
|
16341
|
+
config: {
|
|
16342
|
+
currentPage: page + 1,
|
|
16343
|
+
totalPages: total,
|
|
16344
|
+
prevDeckId: pageId(Math.max(0, page - 1)),
|
|
16345
|
+
nextDeckId: pageId(Math.min(total - 1, page + 1))
|
|
16346
|
+
}
|
|
16347
|
+
});
|
|
16348
|
+
return {
|
|
16349
|
+
...base,
|
|
16350
|
+
id: pageId(page),
|
|
16351
|
+
buttons,
|
|
16352
|
+
sourceDeckId: settingsId,
|
|
16353
|
+
projectionId: pageId(page),
|
|
16354
|
+
pageIndex: page,
|
|
16355
|
+
paginated
|
|
16356
|
+
};
|
|
16170
16357
|
});
|
|
16358
|
+
return decks.flatMap((deck) => deck.id === settingsId ? pages : [deck]);
|
|
16171
16359
|
};
|
|
16172
16360
|
//#endregion
|
|
16173
16361
|
//#region src/deck/runtime-subscriptions.ts
|
|
@@ -16302,7 +16490,7 @@ const createNotificationProvider = async (options) => {
|
|
|
16302
16490
|
});
|
|
16303
16491
|
}
|
|
16304
16492
|
if (platform === "win32") {
|
|
16305
|
-
const { createWindowsNotificationProvider } = await import("./windows-
|
|
16493
|
+
const { createWindowsNotificationProvider } = await import("./windows-BCvfQ3PA.mjs");
|
|
16306
16494
|
return createWindowsNotificationProvider({
|
|
16307
16495
|
executor: options.executor,
|
|
16308
16496
|
logger: options.logger,
|
|
@@ -17867,10 +18055,24 @@ const captureAgentsForStage = (stage) => {
|
|
|
17867
18055
|
"waiting_for_human"
|
|
17868
18056
|
];
|
|
17869
18057
|
const now = Date.now();
|
|
18058
|
+
const titles = [
|
|
18059
|
+
"Review authentication flow",
|
|
18060
|
+
"Fix dashboard loading state",
|
|
18061
|
+
"Write API integration tests",
|
|
18062
|
+
"Refactor configuration parser",
|
|
18063
|
+
"Investigate memory usage",
|
|
18064
|
+
"Update developer documentation",
|
|
18065
|
+
"Add keyboard shortcuts",
|
|
18066
|
+
"Improve deployment pipeline",
|
|
18067
|
+
"Review database migration",
|
|
18068
|
+
"Polish settings interface",
|
|
18069
|
+
"Summarize code changes",
|
|
18070
|
+
"Check release notes"
|
|
18071
|
+
];
|
|
17870
18072
|
const agents = statuses.map((status, index) => ({
|
|
17871
18073
|
sessionId: `sireno-capture-${stage}-${index + 1}`,
|
|
17872
18074
|
providerId: index % 2 === 0 ? "opencode" : "claude-code",
|
|
17873
|
-
title:
|
|
18075
|
+
title: titles[index],
|
|
17874
18076
|
status,
|
|
17875
18077
|
directory: "/works/sireno-deck",
|
|
17876
18078
|
updatedAt: now - index * 1e3,
|
|
@@ -18004,6 +18206,124 @@ const BUILTIN_GLOBAL_SERVICES = /* @__PURE__ */ new Map([["coding-agents", {
|
|
|
18004
18206
|
lastLiveCount = -1;
|
|
18005
18207
|
}
|
|
18006
18208
|
}]]);
|
|
18209
|
+
/** Error messages must not include credential values or native error details. */
|
|
18210
|
+
var CredentialStoreError = class extends Error {
|
|
18211
|
+
code;
|
|
18212
|
+
constructor(code) {
|
|
18213
|
+
super(`Credential store: ${code}`);
|
|
18214
|
+
this.code = code;
|
|
18215
|
+
this.name = "CredentialStoreError";
|
|
18216
|
+
}
|
|
18217
|
+
};
|
|
18218
|
+
const validateName = (name) => {
|
|
18219
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(name)) throw new CredentialStoreError("invalid-name");
|
|
18220
|
+
};
|
|
18221
|
+
/** Bind an addon identity so callers cannot choose another namespace. */
|
|
18222
|
+
const scopeCredentials = (backend, addon) => {
|
|
18223
|
+
return {
|
|
18224
|
+
availability: () => backend.availability(),
|
|
18225
|
+
get: async (name) => {
|
|
18226
|
+
validateName(name);
|
|
18227
|
+
return backend.get(addon, name);
|
|
18228
|
+
},
|
|
18229
|
+
set: async (name, value) => {
|
|
18230
|
+
validateName(name);
|
|
18231
|
+
if (Buffer.byteLength(value, "utf8") > 2560) throw new CredentialStoreError("too-large");
|
|
18232
|
+
await backend.set(addon, name, value);
|
|
18233
|
+
},
|
|
18234
|
+
delete: async (name) => {
|
|
18235
|
+
validateName(name);
|
|
18236
|
+
await backend.delete(addon, name);
|
|
18237
|
+
}
|
|
18238
|
+
};
|
|
18239
|
+
};
|
|
18240
|
+
//#endregion
|
|
18241
|
+
//#region src/system/credentials/native.ts
|
|
18242
|
+
const accountFor = (addon, name) => createHash("sha256").update(JSON.stringify([addon, name])).digest("hex");
|
|
18243
|
+
/** Entries contain no user-provided names in native-store metadata. */
|
|
18244
|
+
const createNativeCredentialBackend = (createEntry = async (account) => {
|
|
18245
|
+
const { AsyncEntry } = await import("@napi-rs/keyring");
|
|
18246
|
+
return new AsyncEntry("sirenodeck.credentials.v1", account, { linux: { store: "secret-service" } });
|
|
18247
|
+
}) => {
|
|
18248
|
+
const entry = async (addon, name) => {
|
|
18249
|
+
try {
|
|
18250
|
+
return await createEntry(accountFor(addon, name));
|
|
18251
|
+
} catch {
|
|
18252
|
+
throw new CredentialStoreError("unavailable");
|
|
18253
|
+
}
|
|
18254
|
+
};
|
|
18255
|
+
return {
|
|
18256
|
+
availability: async () => {
|
|
18257
|
+
try {
|
|
18258
|
+
await (await createEntry(accountFor("sirenodeck", "availability-probe"))).getSecret();
|
|
18259
|
+
return "available";
|
|
18260
|
+
} catch {
|
|
18261
|
+
return "unavailable";
|
|
18262
|
+
}
|
|
18263
|
+
},
|
|
18264
|
+
get: async (addon, name) => {
|
|
18265
|
+
const item = await entry(addon, name);
|
|
18266
|
+
try {
|
|
18267
|
+
const bytes = await item.getSecret();
|
|
18268
|
+
return bytes === null ? void 0 : new TextDecoder("utf-8", { fatal: true }).decode(Uint8Array.from(bytes));
|
|
18269
|
+
} catch {
|
|
18270
|
+
throw new CredentialStoreError("operation-failed");
|
|
18271
|
+
}
|
|
18272
|
+
},
|
|
18273
|
+
set: async (addon, name, value) => {
|
|
18274
|
+
const item = await entry(addon, name);
|
|
18275
|
+
try {
|
|
18276
|
+
await item.setSecret(new TextEncoder().encode(value));
|
|
18277
|
+
} catch {
|
|
18278
|
+
throw new CredentialStoreError("operation-failed");
|
|
18279
|
+
}
|
|
18280
|
+
},
|
|
18281
|
+
delete: async (addon, name) => {
|
|
18282
|
+
const item = await entry(addon, name);
|
|
18283
|
+
try {
|
|
18284
|
+
await item.deleteCredential();
|
|
18285
|
+
} catch {
|
|
18286
|
+
throw new CredentialStoreError("operation-failed");
|
|
18287
|
+
}
|
|
18288
|
+
}
|
|
18289
|
+
};
|
|
18290
|
+
};
|
|
18291
|
+
//#endregion
|
|
18292
|
+
//#region src/addon/data-directory.ts
|
|
18293
|
+
const addonDataRoot = () => {
|
|
18294
|
+
if (process.platform === "win32") {
|
|
18295
|
+
const local = process.env["LOCALAPPDATA"];
|
|
18296
|
+
if (!local || !isAbsolute(local)) throw new Error("LOCALAPPDATA is unavailable");
|
|
18297
|
+
return join(local, "sirenodeck");
|
|
18298
|
+
}
|
|
18299
|
+
if (process.platform === "darwin") return join(homedir(), "Library", "Application Support", "sirenodeck");
|
|
18300
|
+
const xdg = process.env["XDG_DATA_HOME"];
|
|
18301
|
+
return join(xdg && isAbsolute(xdg) ? xdg : join(homedir(), ".local", "share"), "sirenodeck");
|
|
18302
|
+
};
|
|
18303
|
+
const createAddonDataDirectory = (name, root) => {
|
|
18304
|
+
let result;
|
|
18305
|
+
return () => {
|
|
18306
|
+
result ??= (async () => {
|
|
18307
|
+
const base = root ?? addonDataRoot();
|
|
18308
|
+
if (!isAbsolute(base)) throw new Error("Addon data root must be absolute");
|
|
18309
|
+
const addons = join(base, "addons");
|
|
18310
|
+
const directory = join(addons, createHash("sha256").update(name).digest("hex"));
|
|
18311
|
+
await mkdir(base, {
|
|
18312
|
+
recursive: true,
|
|
18313
|
+
mode: 448
|
|
18314
|
+
});
|
|
18315
|
+
for (const path of [addons, directory]) {
|
|
18316
|
+
await mkdir(path, { mode: 448 }).catch((error) => {
|
|
18317
|
+
if (error.code !== "EEXIST") throw error;
|
|
18318
|
+
});
|
|
18319
|
+
if (!(await lstat(path)).isDirectory()) throw new Error(`Not a directory: ${path}`);
|
|
18320
|
+
if (process.platform !== "win32") await chmod(path, 448);
|
|
18321
|
+
}
|
|
18322
|
+
return directory;
|
|
18323
|
+
})();
|
|
18324
|
+
return result;
|
|
18325
|
+
};
|
|
18326
|
+
};
|
|
18007
18327
|
//#endregion
|
|
18008
18328
|
//#region src/deck/addon-handler-bridge.ts
|
|
18009
18329
|
const namespacedKey = (addonName, methodName) => `${addonName}:${methodName}`;
|
|
@@ -18040,7 +18360,7 @@ const staticGlobalServiceModule = (addonName) => {
|
|
|
18040
18360
|
return fromManifest.manifest?.globalService === void 0 ? null : fromManifest;
|
|
18041
18361
|
};
|
|
18042
18362
|
const bridgeAddonServices = async (params) => {
|
|
18043
|
-
const { runtime, decks, scanned, externalAddons, executor, pubSub, store, signal, statePublisher, bridge, methods, requestDeckRebuild } = params;
|
|
18363
|
+
const { runtime, decks, scanned, externalAddons, executor, pubSub, store, signal, statePublisher, bridge, methods, addonServiceConfigs, credentialBackend = createNativeCredentialBackend(), requestDeckRebuild } = params;
|
|
18044
18364
|
const logger = params.logger.child({ component: "addon-handler" });
|
|
18045
18365
|
const allAddons = [...scanned, ...externalAddons];
|
|
18046
18366
|
runtime.setGestureListener((buttonId, event) => {
|
|
@@ -18055,6 +18375,7 @@ const bridgeAddonServices = async (params) => {
|
|
|
18055
18375
|
const trackedCleanup = [];
|
|
18056
18376
|
const addonModules = /* @__PURE__ */ new Map();
|
|
18057
18377
|
const addonGlobalServices = /* @__PURE__ */ new Map();
|
|
18378
|
+
const addonDataDirectories = /* @__PURE__ */ new Map();
|
|
18058
18379
|
const addonMethods = /* @__PURE__ */ new Map();
|
|
18059
18380
|
for (const addon of allAddons) {
|
|
18060
18381
|
if (addon.globalServiceEntry === null) continue;
|
|
@@ -18079,10 +18400,46 @@ const bridgeAddonServices = async (params) => {
|
|
|
18079
18400
|
}
|
|
18080
18401
|
}
|
|
18081
18402
|
for (const [addonName, globalService] of addonGlobalServices) {
|
|
18403
|
+
const getDataDirectory = createAddonDataDirectory(addonName, params.addonDataRoot);
|
|
18404
|
+
addonDataDirectories.set(addonName, getDataDirectory);
|
|
18405
|
+
const interruptions = /* @__PURE__ */ new Set();
|
|
18406
|
+
abortController.signal.addEventListener("abort", () => {
|
|
18407
|
+
for (const release of interruptions) release();
|
|
18408
|
+
interruptions.clear();
|
|
18409
|
+
});
|
|
18082
18410
|
const primaryChannel = globalService.pollers?.[0]?.channel;
|
|
18083
18411
|
const pollersById = /* @__PURE__ */ new Map();
|
|
18084
18412
|
for (const poller of globalService.pollers ?? []) pollersById.set(poller.id, poller);
|
|
18085
18413
|
const ctx = {
|
|
18414
|
+
getDataDirectory,
|
|
18415
|
+
interruptDeck: (deckId, options) => {
|
|
18416
|
+
if (abortController.signal.aborted) return null;
|
|
18417
|
+
const release = runtime.interruptDeck(deckId, options);
|
|
18418
|
+
if (release === null) return null;
|
|
18419
|
+
const ownedRelease = () => {
|
|
18420
|
+
interruptions.delete(ownedRelease);
|
|
18421
|
+
release();
|
|
18422
|
+
};
|
|
18423
|
+
interruptions.add(ownedRelease);
|
|
18424
|
+
return ownedRelease;
|
|
18425
|
+
},
|
|
18426
|
+
showModal: (deckId, options) => {
|
|
18427
|
+
if (abortController.signal.aborted) return null;
|
|
18428
|
+
let ownedRelease;
|
|
18429
|
+
const release = runtime.showModal(deckId, { onOk: async () => {
|
|
18430
|
+
interruptions.delete(ownedRelease);
|
|
18431
|
+
if (abortController.signal.aborted) return;
|
|
18432
|
+
await options?.onOk?.();
|
|
18433
|
+
} });
|
|
18434
|
+
if (release === null) return null;
|
|
18435
|
+
ownedRelease = () => {
|
|
18436
|
+
interruptions.delete(ownedRelease);
|
|
18437
|
+
release();
|
|
18438
|
+
};
|
|
18439
|
+
interruptions.add(ownedRelease);
|
|
18440
|
+
return ownedRelease;
|
|
18441
|
+
},
|
|
18442
|
+
credentials: scopeCredentials(credentialBackend, addonName),
|
|
18086
18443
|
publish: (data) => {
|
|
18087
18444
|
if (primaryChannel !== void 0) {
|
|
18088
18445
|
bridge.broadcast({
|
|
@@ -18124,7 +18481,7 @@ const bridgeAddonServices = async (params) => {
|
|
|
18124
18481
|
bridge.registerCacheablePoller(poller.channel, () => poller.poll(ctx));
|
|
18125
18482
|
}
|
|
18126
18483
|
try {
|
|
18127
|
-
const result = globalService.onLoad?.(ctx);
|
|
18484
|
+
const result = globalService.onLoad?.(ctx, addonServiceConfigs?.get(addonName));
|
|
18128
18485
|
if (result instanceof Promise) result.catch((err) => {
|
|
18129
18486
|
logger.error({
|
|
18130
18487
|
addonName,
|
|
@@ -18221,19 +18578,39 @@ const bridgeAddonServices = async (params) => {
|
|
|
18221
18578
|
signal: abortController.signal,
|
|
18222
18579
|
store
|
|
18223
18580
|
};
|
|
18224
|
-
|
|
18581
|
+
let buttonAbort = new AbortController();
|
|
18225
18582
|
abortController.signal.addEventListener("abort", () => buttonAbort.abort());
|
|
18226
|
-
|
|
18583
|
+
let wrappedCtx = {
|
|
18227
18584
|
...buttonCtx,
|
|
18228
18585
|
signal: buttonAbort.signal
|
|
18229
18586
|
};
|
|
18230
|
-
const
|
|
18231
|
-
existing.push({
|
|
18587
|
+
const entry = {
|
|
18232
18588
|
handlerId,
|
|
18233
18589
|
buttonAbort,
|
|
18234
18590
|
buttonService,
|
|
18235
|
-
wrappedCtx
|
|
18236
|
-
|
|
18591
|
+
wrappedCtx,
|
|
18592
|
+
activate: () => {
|
|
18593
|
+
if (!buttonAbort.signal.aborted || abortController.signal.aborted) return;
|
|
18594
|
+
buttonAbort = new AbortController();
|
|
18595
|
+
wrappedCtx = {
|
|
18596
|
+
...buttonCtx,
|
|
18597
|
+
signal: buttonAbort.signal
|
|
18598
|
+
};
|
|
18599
|
+
entry.buttonAbort = buttonAbort;
|
|
18600
|
+
entry.wrappedCtx = wrappedCtx;
|
|
18601
|
+
try {
|
|
18602
|
+
buttonService.onMount?.(wrappedCtx);
|
|
18603
|
+
} catch (err) {
|
|
18604
|
+
logger.error({
|
|
18605
|
+
addonName,
|
|
18606
|
+
buttonType,
|
|
18607
|
+
err
|
|
18608
|
+
}, `addon onMount threw`);
|
|
18609
|
+
}
|
|
18610
|
+
}
|
|
18611
|
+
};
|
|
18612
|
+
const existing = deckButtonCleanup.get(deck.id) ?? [];
|
|
18613
|
+
existing.push(entry);
|
|
18237
18614
|
deckButtonCleanup.set(deck.id, existing);
|
|
18238
18615
|
try {
|
|
18239
18616
|
buttonService.onMount?.(wrappedCtx);
|
|
@@ -18330,6 +18707,7 @@ const bridgeAddonServices = async (params) => {
|
|
|
18330
18707
|
const tracked = deckButtonCleanup.get(deckId);
|
|
18331
18708
|
if (tracked === void 0) return;
|
|
18332
18709
|
for (const { buttonAbort, buttonService, wrappedCtx } of tracked) {
|
|
18710
|
+
if (buttonAbort.signal.aborted) continue;
|
|
18333
18711
|
try {
|
|
18334
18712
|
buttonService.onUnmount?.(wrappedCtx);
|
|
18335
18713
|
} catch (err) {
|
|
@@ -18342,16 +18720,22 @@ const bridgeAddonServices = async (params) => {
|
|
|
18342
18720
|
}
|
|
18343
18721
|
});
|
|
18344
18722
|
trackedCleanup.push(unsubscribeDeckInactive);
|
|
18723
|
+
trackedCleanup.push(pubSub.subscribe("runtime:activeDeck", (payload) => {
|
|
18724
|
+
if (typeof payload !== "object" || payload === null || !("deckId" in payload)) return;
|
|
18725
|
+
for (const entry of deckButtonCleanup.get(String(payload.deckId)) ?? []) entry.activate();
|
|
18726
|
+
}));
|
|
18345
18727
|
abortController.signal.addEventListener("abort", () => {
|
|
18346
18728
|
for (const [addonName, globalService] of addonGlobalServices) try {
|
|
18347
18729
|
const ctx = {
|
|
18730
|
+
getDataDirectory: addonDataDirectories.get(addonName),
|
|
18731
|
+
credentials: scopeCredentials(credentialBackend, addonName),
|
|
18348
18732
|
publish: () => {},
|
|
18349
18733
|
poll: async () => {},
|
|
18350
18734
|
signal: abortController.signal,
|
|
18351
18735
|
executor,
|
|
18352
18736
|
notify: methods.notify
|
|
18353
18737
|
};
|
|
18354
|
-
globalService.onUnload?.(ctx);
|
|
18738
|
+
globalService.onUnload?.(ctx, addonServiceConfigs?.get(addonName));
|
|
18355
18739
|
} catch (err) {
|
|
18356
18740
|
logger.error({
|
|
18357
18741
|
addonName,
|
|
@@ -18367,13 +18751,15 @@ const bridgeAddonServices = async (params) => {
|
|
|
18367
18751
|
unmountButtons();
|
|
18368
18752
|
for (const [addonName, globalService] of addonGlobalServices) try {
|
|
18369
18753
|
const ctx = {
|
|
18754
|
+
getDataDirectory: addonDataDirectories.get(addonName),
|
|
18755
|
+
credentials: scopeCredentials(credentialBackend, addonName),
|
|
18370
18756
|
publish: () => {},
|
|
18371
18757
|
poll: async () => {},
|
|
18372
18758
|
signal: abortController.signal,
|
|
18373
18759
|
executor,
|
|
18374
18760
|
notify: methods.notify
|
|
18375
18761
|
};
|
|
18376
|
-
globalService.onUnload?.(ctx);
|
|
18762
|
+
globalService.onUnload?.(ctx, addonServiceConfigs?.get(addonName));
|
|
18377
18763
|
} catch (err) {
|
|
18378
18764
|
logger.error({
|
|
18379
18765
|
addonName,
|
|
@@ -18534,6 +18920,7 @@ const deckConfigSurfaceSchema = z.object({
|
|
|
18534
18920
|
id: z.string(),
|
|
18535
18921
|
name: z.string(),
|
|
18536
18922
|
buttons: z.array(deckConfigSurfaceButtonSchema),
|
|
18923
|
+
isModal: z.boolean().optional(),
|
|
18537
18924
|
buttonColor: z.string().optional(),
|
|
18538
18925
|
variant: z.string().optional(),
|
|
18539
18926
|
buttonErrors: z.array(z.object({
|
|
@@ -21036,14 +21423,17 @@ const collectAddonDefaultButtonConfig = (registry, userDecks, logger) => {
|
|
|
21036
21423
|
for (const addon of registry.listAddons()) {
|
|
21037
21424
|
if (addon.defaultButton === void 0) continue;
|
|
21038
21425
|
let matchCount = 0;
|
|
21039
|
-
for (const deck of userDecks)
|
|
21040
|
-
if (
|
|
21041
|
-
|
|
21042
|
-
|
|
21043
|
-
|
|
21044
|
-
|
|
21045
|
-
|
|
21046
|
-
|
|
21426
|
+
for (const deck of userDecks) {
|
|
21427
|
+
if (deck.addonOwner !== void 0) continue;
|
|
21428
|
+
for (const btn of deck.buttons) if (btn.type === addon.defaultButton || btn.type === addon.name) {
|
|
21429
|
+
if (matchCount > 0) logger.warn({
|
|
21430
|
+
addon: addon.name,
|
|
21431
|
+
defaultButton: addon.defaultButton,
|
|
21432
|
+
deckId: deck.id
|
|
21433
|
+
}, "collectAddonDefaultButtonConfig: multiple launcher buttons found, using first");
|
|
21434
|
+
if (matchCount === 0) result.set(addon.name, btn.config ?? {});
|
|
21435
|
+
matchCount++;
|
|
21436
|
+
}
|
|
21047
21437
|
}
|
|
21048
21438
|
}
|
|
21049
21439
|
return result;
|
|
@@ -21228,7 +21618,7 @@ const collectActiveDeckAddonNames = (deck, addonByType) => {
|
|
|
21228
21618
|
return [...addonNames];
|
|
21229
21619
|
};
|
|
21230
21620
|
const setupAddonServices = (options) => {
|
|
21231
|
-
const { runtime, decks, pubSub, scanned, externalAddons, addonByType, executor, statePublisher, bridge, initialDeck, signal, store, methods, logger, requestDeckRebuild } = options;
|
|
21621
|
+
const { runtime, decks, pubSub, scanned, externalAddons, addonByType, executor, statePublisher, bridge, initialDeck, signal, store, methods, logger, requestDeckRebuild, addonServiceConfigs } = options;
|
|
21232
21622
|
const addonBridge = bridgeAddonServices({
|
|
21233
21623
|
runtime,
|
|
21234
21624
|
decks,
|
|
@@ -21242,6 +21632,7 @@ const setupAddonServices = (options) => {
|
|
|
21242
21632
|
bridge,
|
|
21243
21633
|
store,
|
|
21244
21634
|
methods,
|
|
21635
|
+
...addonServiceConfigs !== void 0 ? { addonServiceConfigs } : {},
|
|
21245
21636
|
...requestDeckRebuild !== void 0 ? { requestDeckRebuild } : {}
|
|
21246
21637
|
});
|
|
21247
21638
|
const unsubscribeDeck = pubSub.subscribe("runtime:activeDeck", (payload) => {
|
|
@@ -21324,7 +21715,7 @@ const loadExternalAddonsIntoRegistry = async (registry, config, configDir, homeD
|
|
|
21324
21715
|
if (missing.length > 0 && process.stdin.isTTY) {
|
|
21325
21716
|
for (const source of missing) {
|
|
21326
21717
|
const entry = entries.find((candidate) => (typeof candidate === "string" ? candidate : candidate.src) === source);
|
|
21327
|
-
if (await confirm({
|
|
21718
|
+
if (await confirm$1({
|
|
21328
21719
|
message: `Addon '${source}' is not installed. Install it now?`,
|
|
21329
21720
|
initialValue: true
|
|
21330
21721
|
})) await installPackage({
|
|
@@ -21408,7 +21799,7 @@ const validateAndLoadConfig = async (options) => {
|
|
|
21408
21799
|
} catch (error) {
|
|
21409
21800
|
const source = config.theme === void 0 ? null : typeof config.theme === "string" ? config.theme : config.theme.src;
|
|
21410
21801
|
if (source === null || !isNpmAddonSpec(source) || !process.stdin.isTTY) throw error;
|
|
21411
|
-
if (!await confirm({
|
|
21802
|
+
if (!await confirm$1({
|
|
21412
21803
|
message: `Theme '${source}' is not installed. Install it now?`,
|
|
21413
21804
|
initialValue: true
|
|
21414
21805
|
})) throw error;
|
|
@@ -21454,7 +21845,7 @@ const buildAddonConfigOverrides = (addonEntries, addonSpecToName, logger) => {
|
|
|
21454
21845
|
if (src === null) continue;
|
|
21455
21846
|
const cfg = typeof entry === "object" && entry !== null ? entry.config : void 0;
|
|
21456
21847
|
if (typeof cfg !== "object" || cfg === null) continue;
|
|
21457
|
-
const { decks: perDeckRaw, defaults, ...rest } = cfg;
|
|
21848
|
+
const { decks: perDeckRaw, defaults, service: _service, ...rest } = cfg;
|
|
21458
21849
|
const addonName = addonSpecToName.get(src);
|
|
21459
21850
|
if (addonName === void 0) {
|
|
21460
21851
|
logger.warn({ src }, "addon config override targets an addon that failed to load; ignoring");
|
|
@@ -21468,6 +21859,15 @@ const buildAddonConfigOverrides = (addonEntries, addonSpecToName, logger) => {
|
|
|
21468
21859
|
}
|
|
21469
21860
|
return overrides;
|
|
21470
21861
|
};
|
|
21862
|
+
const buildAddonServiceConfigs = (addonEntries, addonSpecToName) => {
|
|
21863
|
+
const configs = /* @__PURE__ */ new Map();
|
|
21864
|
+
for (const entry of addonEntries) {
|
|
21865
|
+
if (typeof entry === "string" || entry.enabled === false) continue;
|
|
21866
|
+
const name = addonSpecToName.get(entry.src);
|
|
21867
|
+
if (name !== void 0 && entry.config?.service !== void 0) configs.set(name, entry.config.service);
|
|
21868
|
+
}
|
|
21869
|
+
return configs;
|
|
21870
|
+
};
|
|
21471
21871
|
const buildRuntime = (options, loaded, keyCount, lockActive = false) => {
|
|
21472
21872
|
const { logger } = options;
|
|
21473
21873
|
const { config, registry, theme, themeDir } = loaded;
|
|
@@ -21556,14 +21956,14 @@ const buildRuntime = (options, loaded, keyCount, lockActive = false) => {
|
|
|
21556
21956
|
buttons: []
|
|
21557
21957
|
}];
|
|
21558
21958
|
const materializedDecks = materializeAddonDecks(registry, effectiveDecks, logger, keyCount, config.lock?.buttons, addonConfigOverrides);
|
|
21559
|
-
const sourceDecks =
|
|
21959
|
+
const sourceDecks = buildAddonSettingsDecks(materializedDecks, registry.listAddons(), keyCount);
|
|
21560
21960
|
const allDecsWithSystemButtons = injectSystemButtons(sourceDecks, keyCount, { lockActive });
|
|
21561
21961
|
const { decks: allDecks, errorsByDeck } = applyConfigErrorReplacements(allDecsWithSystemButtons, config, registry, logger);
|
|
21562
21962
|
const token = process.env["SIRENO_TOKEN"] ?? "";
|
|
21563
21963
|
const configUiUrl = new URL(options.configUiUrl ?? `http://127.0.0.1:${DEFAULT_CONFIG_UI_PORT}/`);
|
|
21564
21964
|
if (token.length > 0) configUiUrl.searchParams.set("token", token);
|
|
21565
21965
|
configUiUrl.hash = "/config";
|
|
21566
|
-
const runtimeDecks = injectConfigUiButton(allDecks, configUiUrl.toString());
|
|
21966
|
+
const runtimeDecks = injectConfigUiButton(allDecks, configUiUrl.toString(), keyCount);
|
|
21567
21967
|
const { runtime, methods, pubSub, store } = createDeckRuntime({
|
|
21568
21968
|
decks: runtimeDecks,
|
|
21569
21969
|
logger
|
|
@@ -21607,7 +22007,7 @@ const applyConfigErrorReplacements = (decks, config, registry, logger) => {
|
|
|
21607
22007
|
if (position === void 0) continue;
|
|
21608
22008
|
if (btn.type.startsWith("core:")) continue;
|
|
21609
22009
|
const path = `decks.${deck.id}.buttons[@position:${position}]`;
|
|
21610
|
-
const { issues, schemaIssues } = validateButton(btn, registry, path, deck.id, position);
|
|
22010
|
+
const { issues, schemaIssues } = validateButton(btn, registry, path, deck.id, position, deck.addonOwner !== void 0 && btn.type.startsWith(`${deck.addonOwner.addonName}:`));
|
|
21611
22011
|
if (issues.length === 0) continue;
|
|
21612
22012
|
const details = schemaIssues.map((i) => `${[...i.path].join(".") || "(root)"}: ${i.message}`).join("; ") || issues.map((i) => i.message).join("; ");
|
|
21613
22013
|
logger.warn({
|
|
@@ -21731,15 +22131,15 @@ const startSystemProviders = async (options, methods) => {
|
|
|
21731
22131
|
url
|
|
21732
22132
|
};
|
|
21733
22133
|
};
|
|
21734
|
-
const browserFrontendMain = (entry) => {
|
|
22134
|
+
const browserFrontendMain = (entry, dedicated = false) => {
|
|
21735
22135
|
const dir = dirname(entry);
|
|
21736
22136
|
const pkgRoot = basename(dir) === "dist" ? dirname(dir) : dir;
|
|
21737
|
-
const src = resolve(pkgRoot, "src", "index.ts");
|
|
22137
|
+
const src = resolve(pkgRoot, "src", dedicated ? "frontend-entry.ts" : "index.ts");
|
|
21738
22138
|
return existsSync(src) ? src : entry;
|
|
21739
22139
|
};
|
|
21740
22140
|
const addonSpecFromScanned = (s) => ({
|
|
21741
22141
|
name: s.name,
|
|
21742
|
-
frontend: s.browserEntry != null ? { main: browserFrontendMain(s.browserEntry) } : s.frontendEntry !== null ? { main: browserFrontendMain(s.frontendEntry) } : void 0,
|
|
22142
|
+
frontend: s.browserEntry != null ? { main: browserFrontendMain(s.browserEntry, s.browserEntry !== s.frontendEntry) } : s.frontendEntry !== null ? { main: browserFrontendMain(s.frontendEntry) } : void 0,
|
|
21743
22143
|
buttons: s.types.map((t) => ({ type: t })),
|
|
21744
22144
|
buttonTypes: Object.fromEntries(Object.entries(s.buttonTypes).map(([type, info]) => [type, info.exportName])),
|
|
21745
22145
|
defaultButton: s.defaultButton
|
|
@@ -21997,7 +22397,8 @@ const runPipeline = async (options) => {
|
|
|
21997
22397
|
});
|
|
21998
22398
|
const externalAddonDirs = buildExternalAddonDirs(loadedConfig.config.addons ?? [], loadedConfig.configPath, loadedConfig.addonEntryPaths);
|
|
21999
22399
|
let resolverOptions = buildResolverOptions(addonBundle.addonByType, [dirname(loadedConfig.configPath)], externalAddonDirs);
|
|
22000
|
-
|
|
22400
|
+
let currentLoadedConfig = loadedConfig;
|
|
22401
|
+
const reInjectedDecks = (isLocked) => buildRuntime(options, currentLoadedConfig, descriptor.keyCount, isLocked).decks;
|
|
22001
22402
|
if (providers.session.getState() === "locked") {
|
|
22002
22403
|
const reInjected = reInjectedDecks(true);
|
|
22003
22404
|
runtime.setDecks(reInjected);
|
|
@@ -22056,11 +22457,10 @@ const runPipeline = async (options) => {
|
|
|
22056
22457
|
presentation?.refresh({ force: true });
|
|
22057
22458
|
});
|
|
22058
22459
|
const serviceDecks = [...decks];
|
|
22059
|
-
let currentLoadedConfig = loadedConfig;
|
|
22060
22460
|
const nextMainDeckId = (config) => config.decks["main"] !== void 0 ? "main" : Object.keys(config.decks)[0] ?? "main";
|
|
22061
22461
|
const requestDeckRebuild = async () => {
|
|
22062
22462
|
if (runtime === null || descriptor === null || outputClient === null || bridge === null || addonBundle === null || loadedConfig === null || providers === null) return;
|
|
22063
|
-
const rebuilt = buildRuntime(options,
|
|
22463
|
+
const rebuilt = buildRuntime(options, currentLoadedConfig, descriptor.keyCount, providers.session.getState() === "locked").decks;
|
|
22064
22464
|
await addonServices?.reconcile(rebuilt);
|
|
22065
22465
|
decks = rebuilt;
|
|
22066
22466
|
serviceDecks.splice(0, serviceDecks.length, ...rebuilt);
|
|
@@ -22095,6 +22495,7 @@ const runPipeline = async (options) => {
|
|
|
22095
22495
|
keyCount: descriptor.keyCount,
|
|
22096
22496
|
resolverOptions,
|
|
22097
22497
|
requestDeckRebuild,
|
|
22498
|
+
addonServiceConfigs: buildAddonServiceConfigs(loadedConfig.config.addons ?? [], loadedConfig.addonSpecToName),
|
|
22098
22499
|
...mainDeck !== void 0 ? { initialDeck: mainDeck } : {},
|
|
22099
22500
|
signal: bridgeSignal.signal,
|
|
22100
22501
|
store,
|
|
@@ -23450,11 +23851,11 @@ const enableClaudeHooks = () => {
|
|
|
23450
23851
|
const onboardClaudeCode = async (options) => {
|
|
23451
23852
|
if (isClaudeHookInstalled() && isClaudeHookEnabled()) return false;
|
|
23452
23853
|
note("The coding-agents addon can show each Claude Code session and its live state.\n\nSireno Deck will add hooks to your Claude Code settings. They report only local session state (id, directory, status) to files owned by your user; no prompts or code are captured. Existing hooks are left untouched.", "Claude Code integration");
|
|
23453
|
-
const answer = options.yes === true ? true : await confirm({
|
|
23854
|
+
const answer = options.yes === true ? true : await confirm$1({
|
|
23454
23855
|
message: "Add the Claude Code session-state hooks now?",
|
|
23455
23856
|
initialValue: true
|
|
23456
23857
|
});
|
|
23457
|
-
if (isCancel(answer) || !answer) return false;
|
|
23858
|
+
if (isCancel$1(answer) || !answer) return false;
|
|
23458
23859
|
installClaudeHook();
|
|
23459
23860
|
if (!enableClaudeHooks()) {
|
|
23460
23861
|
note(`Could not update ${claudeSettingsPath()} because it is not valid JSON. Nothing was changed.`, "Claude Code integration");
|
|
@@ -23473,11 +23874,11 @@ const onboardCodingAgents = async (configPath, options = {}) => {
|
|
|
23473
23874
|
let changed = false;
|
|
23474
23875
|
if (!openCodeDone) {
|
|
23475
23876
|
note("The coding-agents addon can show each OpenCode terminal instance and its live state.\n\nSireno Deck will install a global OpenCode plugin. It reports only local process state to files owned by your user; no prompts or code are captured.", "OpenCode integration");
|
|
23476
|
-
const answer = options.yes === true ? true : await confirm({
|
|
23877
|
+
const answer = options.yes === true ? true : await confirm$1({
|
|
23477
23878
|
message: "Install the OpenCode instance-state plugin now?",
|
|
23478
23879
|
initialValue: true
|
|
23479
23880
|
});
|
|
23480
|
-
if (!isCancel(answer) && answer) {
|
|
23881
|
+
if (!isCancel$1(answer) && answer) {
|
|
23481
23882
|
if (openCodeMajorVersion === null) note("Could not detect a supported OpenCode version. Make sure `opencode --version` works, then run setup again. No plugin files were changed.", "OpenCode integration");
|
|
23482
23883
|
else {
|
|
23483
23884
|
const installedPath = installOpenCodePlugin(openCodeMajorVersion);
|
|
@@ -23602,11 +24003,11 @@ const reProbeCapability = async (step, deps) => {
|
|
|
23602
24003
|
const runDarwinAccessibilityStep = async (yesBatched) => {
|
|
23603
24004
|
if (await hasDarwinAccessibility(realExecutor)) return "installed";
|
|
23604
24005
|
if (!yesBatched) {
|
|
23605
|
-
const shouldOpen = await confirm({
|
|
24006
|
+
const shouldOpen = await confirm$1({
|
|
23606
24007
|
message: "Open System Settings at Privacy & Security → Accessibility?",
|
|
23607
24008
|
initialValue: true
|
|
23608
24009
|
});
|
|
23609
|
-
if (isCancel(shouldOpen) || !shouldOpen) return "manual";
|
|
24010
|
+
if (isCancel$1(shouldOpen) || !shouldOpen) return "manual";
|
|
23610
24011
|
}
|
|
23611
24012
|
if (!await openSettingsUrl(realExecutor, "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility")) {
|
|
23612
24013
|
log$1.warn("Could not open System Settings automatically.");
|
|
@@ -23614,11 +24015,11 @@ const runDarwinAccessibilityStep = async (yesBatched) => {
|
|
|
23614
24015
|
}
|
|
23615
24016
|
log$1.info(`Enable ${color.green(appNeedingAccessibility())} in the list that just opened.`);
|
|
23616
24017
|
if (yesBatched) return "manual";
|
|
23617
|
-
const granted = await confirm({
|
|
24018
|
+
const granted = await confirm$1({
|
|
23618
24019
|
message: "Granted? (re-checks the permission)",
|
|
23619
24020
|
initialValue: true
|
|
23620
24021
|
});
|
|
23621
|
-
if (isCancel(granted) || !granted) return "manual";
|
|
24022
|
+
if (isCancel$1(granted) || !granted) return "manual";
|
|
23622
24023
|
if (await hasDarwinAccessibility(realExecutor)) return "installed";
|
|
23623
24024
|
log$1.warn("Still not granted for this process — macOS applies the grant to the app that launched sirenodeck, so restart your terminal and re-run.");
|
|
23624
24025
|
return "manual";
|
|
@@ -23638,11 +24039,11 @@ const runInstallStep = async (step, yesBatched, logger, deps) => {
|
|
|
23638
24039
|
s.start(`Checking ${step.packages.join(", ")}`);
|
|
23639
24040
|
s.stop(`${step.packages.join(", ")} not found — install needed`);
|
|
23640
24041
|
if (!yesBatched) {
|
|
23641
|
-
const shouldRun = await confirm({
|
|
24042
|
+
const shouldRun = await confirm$1({
|
|
23642
24043
|
message: `Install ${step.title}?`,
|
|
23643
24044
|
initialValue: !step.sudo
|
|
23644
24045
|
});
|
|
23645
|
-
if (isCancel(shouldRun) || !shouldRun) return "skipped";
|
|
24046
|
+
if (isCancel$1(shouldRun) || !shouldRun) return "skipped";
|
|
23646
24047
|
}
|
|
23647
24048
|
let command;
|
|
23648
24049
|
let args;
|
|
@@ -23729,11 +24130,11 @@ const runInstallStep = async (step, yesBatched, logger, deps) => {
|
|
|
23729
24130
|
};
|
|
23730
24131
|
const runUdevStep = async (step, yesBatched, logger) => {
|
|
23731
24132
|
if (!yesBatched) {
|
|
23732
|
-
const shouldRun = await confirm({
|
|
24133
|
+
const shouldRun = await confirm$1({
|
|
23733
24134
|
message: `Install udev rules to ${process.platform === "linux" ? "/etc/udev/rules.d/70-sirenodeck.rules" : "system location"}?`,
|
|
23734
24135
|
initialValue: false
|
|
23735
24136
|
});
|
|
23736
|
-
if (isCancel(shouldRun) || !shouldRun) return "skipped";
|
|
24137
|
+
if (isCancel$1(shouldRun) || !shouldRun) return "skipped";
|
|
23737
24138
|
}
|
|
23738
24139
|
const nopasswd = await isSudoNopasswd();
|
|
23739
24140
|
let password = "";
|
|
@@ -23793,11 +24194,11 @@ const runConfigSeed = async (report, options, logger) => {
|
|
|
23793
24194
|
logger.warn({ path: report.config.path }, "config missing and non-interactive mode — skipping seed");
|
|
23794
24195
|
return false;
|
|
23795
24196
|
}
|
|
23796
|
-
const shouldSeed = await confirm({
|
|
24197
|
+
const shouldSeed = await confirm$1({
|
|
23797
24198
|
message: `Seed default config to ${report.config.path}?`,
|
|
23798
24199
|
initialValue: true
|
|
23799
24200
|
});
|
|
23800
|
-
if (isCancel(shouldSeed) || !shouldSeed) return false;
|
|
24201
|
+
if (isCancel$1(shouldSeed) || !shouldSeed) return false;
|
|
23801
24202
|
const s = spinner();
|
|
23802
24203
|
s.start(`Seeding ${report.config.path}`);
|
|
23803
24204
|
try {
|
|
@@ -24002,11 +24403,11 @@ const installConfigSkill = async (options = {}) => {
|
|
|
24002
24403
|
intro("sirenodeck skills");
|
|
24003
24404
|
note("Install the Sireno Deck config skill for your preferred coding agent. It helps your agent configure and update decks, buttons, and themes from your config.yml. The skill is installed globally from GitHub; it can read and edit your config only with your agent's normal file access.", "Configure decks with your agent");
|
|
24004
24405
|
if (!yes && options.confirmed !== true) {
|
|
24005
|
-
const answer = await confirm({
|
|
24406
|
+
const answer = await confirm$1({
|
|
24006
24407
|
message: "Install the Sireno Deck config skill globally?",
|
|
24007
24408
|
initialValue: false
|
|
24008
24409
|
});
|
|
24009
|
-
if (isCancel(answer) || !answer) {
|
|
24410
|
+
if (isCancel$1(answer) || !answer) {
|
|
24010
24411
|
log$1.info("Skill installation cancelled.");
|
|
24011
24412
|
return false;
|
|
24012
24413
|
}
|
|
@@ -24057,11 +24458,11 @@ const offerPath = () => join(process.env["XDG_CONFIG_HOME"] ?? join(homedir(), "
|
|
|
24057
24458
|
const offerConfigSkillOnFirstRun = async () => {
|
|
24058
24459
|
if (process.stdin.isTTY !== true || existsSync(offerPath())) return;
|
|
24059
24460
|
note("Your coding agent can help configure and update Sireno Deck decks, buttons, and themes. This optional skill is installed from GitHub.", "Sireno Deck agent skill");
|
|
24060
|
-
const answer = await confirm({
|
|
24461
|
+
const answer = await confirm$1({
|
|
24061
24462
|
message: "Install the Sireno Deck skill for your coding agent?",
|
|
24062
24463
|
initialValue: false
|
|
24063
24464
|
});
|
|
24064
|
-
if (isCancel(answer) || !answer) {
|
|
24465
|
+
if (isCancel$1(answer) || !answer) {
|
|
24065
24466
|
saveOfferChoice("declined");
|
|
24066
24467
|
return;
|
|
24067
24468
|
}
|
|
@@ -24343,24 +24744,6 @@ const killPortListeners = async (ports, logger) => {
|
|
|
24343
24744
|
}
|
|
24344
24745
|
await new Promise((r) => setTimeout(r, 500));
|
|
24345
24746
|
};
|
|
24346
|
-
const promptConflict = async (pid) => {
|
|
24347
|
-
const who = pid === null ? "" : ` with pid ${pid}`;
|
|
24348
|
-
if (!process.stdin.isTTY) throw new Error(`Daemon already running${who} (non-interactive: not stopping)`);
|
|
24349
|
-
const answer = await select({
|
|
24350
|
-
message: `Daemon already running${who}.`,
|
|
24351
|
-
options: [{
|
|
24352
|
-
value: "restart",
|
|
24353
|
-
label: "restart",
|
|
24354
|
-
hint: "Stop the existing daemon and start a new one"
|
|
24355
|
-
}, {
|
|
24356
|
-
value: "cancel",
|
|
24357
|
-
label: "cancel",
|
|
24358
|
-
hint: "Exit without changes"
|
|
24359
|
-
}]
|
|
24360
|
-
});
|
|
24361
|
-
if (isCancel(answer)) return "cancel";
|
|
24362
|
-
return answer;
|
|
24363
|
-
};
|
|
24364
24747
|
const stopExisting = async (pid, logger) => {
|
|
24365
24748
|
if (!isRunning(pid)) {
|
|
24366
24749
|
logger.warn({ pid }, "existing pid file is stale, removing");
|
|
@@ -24373,28 +24756,16 @@ const stopExisting = async (pid, logger) => {
|
|
|
24373
24756
|
removeStartLock();
|
|
24374
24757
|
return;
|
|
24375
24758
|
}
|
|
24759
|
+
if (!isOurDaemon(pid)) throw new Error(`Refusing to stop unverified daemon PID ${pid}`);
|
|
24376
24760
|
logger.info({ pid }, "stopping existing daemon");
|
|
24377
24761
|
try {
|
|
24378
24762
|
process.kill(pid, "SIGTERM");
|
|
24379
24763
|
} catch (err) {
|
|
24380
|
-
|
|
24381
|
-
err,
|
|
24382
|
-
pid
|
|
24383
|
-
}, "failed to send SIGTERM to existing daemon");
|
|
24764
|
+
throw new Error(`Failed to stop existing daemon ${pid}`, { cause: err });
|
|
24384
24765
|
}
|
|
24385
|
-
const deadline = Date.now() +
|
|
24766
|
+
const deadline = Date.now() + 2e4;
|
|
24386
24767
|
while (Date.now() < deadline && isRunning(pid)) await new Promise((r) => setTimeout(r, 100));
|
|
24387
|
-
if (isRunning(pid)) {
|
|
24388
|
-
logger.warn({ pid }, "existing daemon did not exit in 5s, sending SIGKILL");
|
|
24389
|
-
try {
|
|
24390
|
-
process.kill(pid, "SIGKILL");
|
|
24391
|
-
} catch (err) {
|
|
24392
|
-
logger.warn({
|
|
24393
|
-
err,
|
|
24394
|
-
pid
|
|
24395
|
-
}, "failed to send SIGKILL to existing daemon");
|
|
24396
|
-
}
|
|
24397
|
-
}
|
|
24768
|
+
if (isRunning(pid)) throw new Error(`Existing daemon ${pid} did not exit after SIGTERM`);
|
|
24398
24769
|
await terminateChildren({
|
|
24399
24770
|
logger,
|
|
24400
24771
|
timeoutMs: 2e3
|
|
@@ -24688,7 +25059,7 @@ const runFirstRunCheckIfNeeded = async (options, logger) => {
|
|
|
24688
25059
|
process.exitCode = 1;
|
|
24689
25060
|
return false;
|
|
24690
25061
|
}
|
|
24691
|
-
if (!await confirm({
|
|
25062
|
+
if (!await confirm$1({
|
|
24692
25063
|
message: "It looks like this is your first run (missing config or system capabilities). Run the setup wizard now?",
|
|
24693
25064
|
initialValue: true
|
|
24694
25065
|
})) {
|
|
@@ -24723,36 +25094,17 @@ const start = async (options) => {
|
|
|
24723
25094
|
logger.warn({ err: error }, "start: agent skill offer failed, continuing");
|
|
24724
25095
|
}
|
|
24725
25096
|
await onboardCodingAgents(resolveConfigPath(options).path);
|
|
25097
|
+
if (isUnitInstalled()) await invokeManager({
|
|
25098
|
+
action: "stop",
|
|
25099
|
+
logger
|
|
25100
|
+
});
|
|
24726
25101
|
const existing = readPid();
|
|
24727
|
-
|
|
24728
|
-
|
|
24729
|
-
|
|
24730
|
-
return "cancelled";
|
|
24731
|
-
}
|
|
24732
|
-
if (isUnitInstalled()) {
|
|
24733
|
-
const resolvedRestart = resolveConfigPath(options);
|
|
24734
|
-
writeConfigPath(resolvedRestart.path);
|
|
24735
|
-
writeFlags(buildRuntimeFlags(options));
|
|
24736
|
-
logger.info({ configPath: resolvedRestart.path }, "start: daemon is service-managed — restarting through the service manager");
|
|
24737
|
-
await invokeManager({
|
|
24738
|
-
action: "restart",
|
|
24739
|
-
logger
|
|
24740
|
-
});
|
|
24741
|
-
const deadline = Date.now() + 1e4;
|
|
24742
|
-
let restarted = null;
|
|
24743
|
-
while (Date.now() < deadline) {
|
|
24744
|
-
await new Promise((r) => setTimeout(r, 200));
|
|
24745
|
-
const pid = readPid();
|
|
24746
|
-
if (pid !== null && pid !== existing && isRunning(pid)) {
|
|
24747
|
-
restarted = pid;
|
|
24748
|
-
break;
|
|
24749
|
-
}
|
|
24750
|
-
}
|
|
24751
|
-
logger.info({ pid: restarted }, restarted === null ? "start: service manager restarted the daemon (pid not yet visible)" : "start: daemon restarted by the service manager");
|
|
24752
|
-
return "started";
|
|
24753
|
-
}
|
|
25102
|
+
const lockHeld = await isSocketLive(instanceLockPath(resolveDaemonPaths()));
|
|
25103
|
+
if (lockHeld || existing !== null && isRunning(existing)) {
|
|
25104
|
+
if (lockHeld && (existing === null || !isRunning(existing))) throw new Error("A daemon holds the instance lock but has no live PID; refusing to stop an unidentified process");
|
|
24754
25105
|
if (existing !== null) await stopExisting(existing, logger);
|
|
24755
|
-
else
|
|
25106
|
+
else throw new Error("A daemon holds the instance lock but has no PID; refusing to stop an unidentified process");
|
|
25107
|
+
if (await isSocketLive(instanceLockPath(resolveDaemonPaths()))) throw new Error("The previous daemon still holds the instance lock");
|
|
24756
25108
|
removePidFile();
|
|
24757
25109
|
removeDaemonControl(resolveDaemonPaths());
|
|
24758
25110
|
removeRuntimeStateFile();
|
|
@@ -25087,6 +25439,10 @@ const killGracefully = async (pid, logger, label) => {
|
|
|
25087
25439
|
}
|
|
25088
25440
|
};
|
|
25089
25441
|
const stop = async ({ logger }) => {
|
|
25442
|
+
if (isUnitInstalled()) await invokeManager({
|
|
25443
|
+
action: "stop",
|
|
25444
|
+
logger
|
|
25445
|
+
});
|
|
25090
25446
|
const pid = readPid();
|
|
25091
25447
|
if (pid === null) {
|
|
25092
25448
|
logger.info("stop: no running daemon found");
|
|
@@ -25273,6 +25629,143 @@ const openBrowser = (url, logger, noOpen = false) => {
|
|
|
25273
25629
|
});
|
|
25274
25630
|
};
|
|
25275
25631
|
//#endregion
|
|
25632
|
+
//#region src/cli/commands/addon-setup-config.ts
|
|
25633
|
+
const saveAddonProvider = async (path, addonName, provider) => {
|
|
25634
|
+
const mutation = createConfigMutationService({ configPath: path });
|
|
25635
|
+
const candidates = [];
|
|
25636
|
+
for (const source of mutation.sources()) {
|
|
25637
|
+
const doc = parseDocument(readFileSync(source, "utf8"));
|
|
25638
|
+
if (doc.errors.length) continue;
|
|
25639
|
+
const addons = doc.get("addons");
|
|
25640
|
+
if (!isSeq(addons)) continue;
|
|
25641
|
+
addons.items.forEach((item, index) => {
|
|
25642
|
+
const value = isMap(item) ? item.get("src") : isScalar(item) ? item.value : void 0;
|
|
25643
|
+
if (typeof value !== "string") return;
|
|
25644
|
+
const base = basename(value.replace(/\/$/, ""));
|
|
25645
|
+
let name = base === addonName || base === `addon-${addonName}`;
|
|
25646
|
+
const manifestPath = resolve(dirname(source), value, "sirenodeck.json");
|
|
25647
|
+
if (!name && existsSync(manifestPath)) try {
|
|
25648
|
+
name = JSON.parse(readFileSync(manifestPath, "utf8")).name === addonName;
|
|
25649
|
+
} catch {}
|
|
25650
|
+
if (name) candidates.push({
|
|
25651
|
+
path: source,
|
|
25652
|
+
index
|
|
25653
|
+
});
|
|
25654
|
+
});
|
|
25655
|
+
}
|
|
25656
|
+
if (candidates.length !== 1) throw new Error(`Expected one ${addonName} addon entry; found ${candidates.length}`);
|
|
25657
|
+
const target = candidates[0];
|
|
25658
|
+
const document = parseDocument(mutation.readSource(target.path), { keepSourceTokens: true });
|
|
25659
|
+
const addonPath = ["addons", target.index];
|
|
25660
|
+
const item = document.getIn(addonPath);
|
|
25661
|
+
if (!isMap(item)) {
|
|
25662
|
+
const src = typeof item === "string" ? item : isScalar(item) ? item.value : void 0;
|
|
25663
|
+
if (typeof src !== "string") throw new Error("Invalid addon entry");
|
|
25664
|
+
document.setIn(addonPath, document.createNode({ src }));
|
|
25665
|
+
}
|
|
25666
|
+
const providersPath = [
|
|
25667
|
+
...addonPath,
|
|
25668
|
+
"config",
|
|
25669
|
+
"service",
|
|
25670
|
+
"providers"
|
|
25671
|
+
];
|
|
25672
|
+
let providers = document.getIn(providersPath);
|
|
25673
|
+
if (providers === void 0) {
|
|
25674
|
+
document.setIn(providersPath, []);
|
|
25675
|
+
providers = document.getIn(providersPath);
|
|
25676
|
+
}
|
|
25677
|
+
if (!isSeq(providers)) throw new Error("Calendar providers must be a list");
|
|
25678
|
+
const matches = providers.items.filter((entry) => isMap(entry) && entry.get("id") === provider.id);
|
|
25679
|
+
if (matches.length > 1) throw new Error("Duplicate calendar account IDs in config");
|
|
25680
|
+
if (matches.length === 1) {
|
|
25681
|
+
const existing = matches[0];
|
|
25682
|
+
if (!isMap(existing) || existing.get("type") !== provider.type) throw new Error("Account ID is already used by another provider");
|
|
25683
|
+
for (const [key, value] of Object.entries(provider)) existing.set(key, value);
|
|
25684
|
+
} else providers.add(provider);
|
|
25685
|
+
await mutation.apply({
|
|
25686
|
+
kind: "edit-source",
|
|
25687
|
+
path: target.path,
|
|
25688
|
+
content: document.toString()
|
|
25689
|
+
});
|
|
25690
|
+
};
|
|
25691
|
+
//#endregion
|
|
25692
|
+
//#region src/cli/commands/addon-setup.ts
|
|
25693
|
+
const addonSetupCommand = {
|
|
25694
|
+
command: "addon-setup <module>",
|
|
25695
|
+
describe: "Run an installed addon's interactive setup module",
|
|
25696
|
+
builder: (yargs) => yargs.positional("module", {
|
|
25697
|
+
type: "string",
|
|
25698
|
+
demandOption: true,
|
|
25699
|
+
description: "Path to the addon's setup module"
|
|
25700
|
+
}),
|
|
25701
|
+
handler: async ({ module }) => {
|
|
25702
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) throw new Error("Addon setup requires an interactive terminal");
|
|
25703
|
+
const setup = await import(pathToFileURL(resolve(module)).href);
|
|
25704
|
+
if (!/^[a-z0-9][a-z0-9-]*$/.test(setup.addonName) || typeof setup.setupAddon !== "function") throw new Error("Invalid addon setup module");
|
|
25705
|
+
const logger = createLogger({});
|
|
25706
|
+
const pid = readPid();
|
|
25707
|
+
let configPath = pid !== null && isRunning(pid) ? readConfigPath() : null;
|
|
25708
|
+
await setup.setupAddon({
|
|
25709
|
+
credentials: scopeCredentials(createNativeCredentialBackend(), setup.addonName),
|
|
25710
|
+
openUrl: (url) => {
|
|
25711
|
+
console.log(`Open this URL if your browser does not start:\n${url}`);
|
|
25712
|
+
openBrowser(url, logger);
|
|
25713
|
+
},
|
|
25714
|
+
text: async (message, secret) => {
|
|
25715
|
+
const value = secret ? await password({ message }) : await text({ message });
|
|
25716
|
+
if (isCancel(value)) throw new Error("Addon setup cancelled");
|
|
25717
|
+
return value;
|
|
25718
|
+
},
|
|
25719
|
+
selectMany: async (message, options) => {
|
|
25720
|
+
const value = await multiselect({
|
|
25721
|
+
message,
|
|
25722
|
+
options: options.map(({ color, ...option }) => {
|
|
25723
|
+
const useColor = process.stdout.isTTY && process.env["NO_COLOR"] === void 0 && process.env["TERM"] !== "dumb";
|
|
25724
|
+
const hex = /^#[0-9a-f]{6}$/i.test(color ?? "") ? color.slice(1) : void 0;
|
|
25725
|
+
const rgb = hex === void 0 ? void 0 : [
|
|
25726
|
+
0,
|
|
25727
|
+
2,
|
|
25728
|
+
4
|
|
25729
|
+
].map((i) => parseInt(hex.slice(i, i + 2), 16));
|
|
25730
|
+
const marker = rgb && useColor ? `\x1b[38;2;${rgb.join(";")}m■\x1b[0m` : "■";
|
|
25731
|
+
return {
|
|
25732
|
+
...option,
|
|
25733
|
+
label: `${marker} ${useColor ? styleText("white", option.label) : option.label}`
|
|
25734
|
+
};
|
|
25735
|
+
}),
|
|
25736
|
+
required: true
|
|
25737
|
+
});
|
|
25738
|
+
if (isCancel(value)) throw new Error("Addon setup cancelled");
|
|
25739
|
+
return value;
|
|
25740
|
+
},
|
|
25741
|
+
confirm: async (message) => {
|
|
25742
|
+
const value = await confirm({
|
|
25743
|
+
message,
|
|
25744
|
+
initialValue: false
|
|
25745
|
+
});
|
|
25746
|
+
if (isCancel(value)) throw new Error("Addon setup cancelled");
|
|
25747
|
+
return value;
|
|
25748
|
+
},
|
|
25749
|
+
saveProvider: async (provider) => {
|
|
25750
|
+
if (!configPath) {
|
|
25751
|
+
const value = await text({ message: "Config file path (leave blank for manual instructions)" });
|
|
25752
|
+
if (isCancel(value)) throw new Error("Addon setup cancelled");
|
|
25753
|
+
if (!value.trim()) return null;
|
|
25754
|
+
configPath = resolveUserPath(value.trim());
|
|
25755
|
+
}
|
|
25756
|
+
try {
|
|
25757
|
+
await saveAddonProvider(configPath, setup.addonName, provider);
|
|
25758
|
+
return configPath;
|
|
25759
|
+
} catch (error) {
|
|
25760
|
+
console.error(`Could not update config: ${error instanceof Error ? error.message : String(error)}`);
|
|
25761
|
+
return null;
|
|
25762
|
+
}
|
|
25763
|
+
},
|
|
25764
|
+
print: (message) => console.log(message)
|
|
25765
|
+
});
|
|
25766
|
+
}
|
|
25767
|
+
};
|
|
25768
|
+
//#endregion
|
|
25276
25769
|
//#region src/cli/index.ts
|
|
25277
25770
|
const buildLogger = (argv) => {
|
|
25278
25771
|
const normalized = argv.logLevel === "none" ? "silent" : argv.logLevel;
|
|
@@ -25477,6 +25970,7 @@ const buildCli = async () => {
|
|
|
25477
25970
|
logsCommand,
|
|
25478
25971
|
systemRequirementsCommand,
|
|
25479
25972
|
installCommand,
|
|
25973
|
+
addonSetupCommand,
|
|
25480
25974
|
skillsCommand
|
|
25481
25975
|
],
|
|
25482
25976
|
packageName: PACKAGE_NAME,
|