claude-code-session-manager 0.107.0 → 0.109.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/assets/AgentLibrary-Br4Ispr4.js +2 -0
- package/dist/assets/{Button-CRLhoI2K.js → Button-C8Mc6MEP.js} +1 -1
- package/dist/assets/DataModel-Bz0MypYO.js +1 -0
- package/dist/assets/History-DT26Iy38.js +2 -0
- package/dist/assets/Hooks-e4xUGEf-.js +3 -0
- package/dist/assets/{Library-rqaJJJ1b.js → Library-B3rzEhvN.js} +24 -24
- package/dist/assets/{ListDetail-qI27OYfy.js → ListDetail-BAvci_aP.js} +1 -1
- package/dist/assets/{MarkdownEditor-BEFuHVNz.js → MarkdownEditor-DBWTGgRz.js} +1 -1
- package/dist/assets/{McpServers-Bz9O79rz.js → McpServers-C-grBN21.js} +2 -2
- package/dist/assets/{Memory-DobxIoZ-.js → Memory-BmM0Fz-C.js} +5 -5
- package/dist/assets/{Panel-Cyt1wpUf.js → Panel-Dc6F8wb4.js} +1 -1
- package/dist/assets/Permissions-m_NnldFh.js +3 -0
- package/dist/assets/Plugins-BB0TLUC9.js +2 -0
- package/dist/assets/ProvenanceBadge-k9PH0S2n.js +1 -0
- package/dist/assets/{SaveBar-BuYrg5E9.js → SaveBar-DSMnbUVI.js} +1 -1
- package/dist/assets/Scheduler-CbIcJEfM.js +16 -0
- package/dist/assets/{ScopeSwitcher-BM0gLPhd.js → ScopeSwitcher-tHtloWbN.js} +1 -1
- package/dist/assets/Settings-CW3w7knp.js +6 -0
- package/dist/assets/{SkillReferenceGraph-D0Hgdfxq.js → SkillReferenceGraph-Dndl1tzr.js} +14 -14
- package/dist/assets/Skills-CGnxroik.js +2 -0
- package/dist/assets/SystemPrompt-B3A3rHNp.js +1 -0
- package/dist/assets/TagLibrary-k4CTiAYo.js +1 -0
- package/dist/assets/{TiptapBody-CP_F_mwb.js → TiptapBody-C2LfNQXw.js} +1 -1
- package/dist/assets/{Toggle-haRPHS5N.js → Toggle-CTXTU1q5.js} +1 -1
- package/dist/assets/{ViewTabs-BHV3MA5u.js → ViewTabs-CfEfOSE1.js} +1 -1
- package/dist/assets/historyTotals-Db0xy2Fg.js +1 -0
- package/dist/assets/{index-tr1w3hHB.css → index-C8Smiz7z.css} +1 -1
- package/dist/assets/{index-v_3LvhMx.js → index-fJxuoRvi.js} +697 -697
- package/dist/assets/listSkills-C1aWKf0T.js +1 -0
- package/dist/assets/{settingsSchema-CE46TA3V.js → settingsSchema-xxO9p4yF.js} +1 -1
- package/dist/assets/useAgentsDirWatch-DLS1_moj.js +1 -0
- package/dist/index.html +2 -2
- package/package.json +5 -2
- package/plugins/session-manager-dev/skills/develop/standards.md +5 -0
- package/scripts/README.md +7 -0
- package/scripts/scheduler-mcp-server.cjs +38 -5
- package/src/main/agentLibrary.cjs +20 -9
- package/src/main/build-info.json +4 -4
- package/src/main/config.cjs +20 -10
- package/src/main/historyAggregator.cjs +46 -3
- package/src/main/index.cjs +2 -0
- package/src/main/ipcSchemas.cjs +2 -0
- package/src/main/lib/builtinMacros.cjs +2 -2
- package/src/main/lib/mcpToolCatalog.cjs +3 -1
- package/src/main/lib/remoteE2eCrypto.cjs +109 -0
- package/src/main/lib/shippedPersonaSeeds.cjs +11 -0
- package/src/main/pty.cjs +53 -0
- package/src/main/remoteClient.cjs +305 -0
- package/src/main/remoteClientIpc.cjs +101 -0
- package/src/main/webRemote.cjs +90 -108
- package/src/preload/api.d.ts +42 -5
- package/src/preload/index.cjs +27 -2
- package/src/seed/agents/demo-video-builder.md +69 -48
- package/dist/assets/AgentLibrary-Bjeq2-kp.js +0 -2
- package/dist/assets/DataModel-iPJw5jcG.js +0 -1
- package/dist/assets/History-DfPR3_6N.js +0 -2
- package/dist/assets/Hooks-Bw7H_DmC.js +0 -3
- package/dist/assets/Permissions-ChSNRUJJ.js +0 -3
- package/dist/assets/Plugins-CII221R2.js +0 -2
- package/dist/assets/ProvenanceBadge-C_sk5-v3.js +0 -1
- package/dist/assets/Scheduler-eixbMGEk.js +0 -16
- package/dist/assets/Settings-qD-0W-Ut.js +0 -4
- package/dist/assets/Skills-C3T_2_2o.js +0 -3
- package/dist/assets/SystemPrompt-B-xTy9Qn.js +0 -1
- package/dist/assets/TagLibrary-BH67tR5z.js +0 -1
- package/dist/assets/listSkills-QORduPIk.js +0 -1
- package/dist/assets/useAgentsDirWatch-BZTi2K2e.js +0 -1
- package/dist/assets/useConfigDirWatch-CjcswsWR.js +0 -1
package/src/main/webRemote.cjs
CHANGED
|
@@ -68,107 +68,8 @@ const MSG_MAX_BYTES = 256 * 1024;
|
|
|
68
68
|
const { ALLOWED_COMMANDS, MUTATE_COMMANDS, SAS_GATED_READS } = require('./ipcSchemas.cjs');
|
|
69
69
|
|
|
70
70
|
// ─── E2E encryption helpers (P-256 ECDH + AES-256-GCM, ADR §5.2) ────────────
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
* Generate a P-256 ECDH keypair. Public key is SPKI DER base64url; private key
|
|
74
|
-
* is PKCS8 DER base64url. Both are stored in web-remote.json at 0600.
|
|
75
|
-
*/
|
|
76
|
-
function generateE2EKeyPair() {
|
|
77
|
-
const { privateKey, publicKey } = crypto.generateKeyPairSync('ec', {
|
|
78
|
-
namedCurve: 'P-256',
|
|
79
|
-
publicKeyEncoding: { type: 'spki', format: 'der' },
|
|
80
|
-
privateKeyEncoding: { type: 'pkcs8', format: 'der' },
|
|
81
|
-
});
|
|
82
|
-
return {
|
|
83
|
-
e2ePrivateKey: privateKey.toString('base64url'),
|
|
84
|
-
e2ePublicKey: publicKey.toString('base64url'),
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Derive an AES-256-GCM session key from two P-256 public keys via ECDH + HKDF.
|
|
90
|
-
* @param myPrivateKeyB64 Agent's PKCS8 private key, base64url DER
|
|
91
|
-
* @param peerPublicKeyB64 Browser's SPKI public key, base64url DER
|
|
92
|
-
* @param deviceId Used as HKDF salt for domain separation
|
|
93
|
-
* @returns 32-byte Buffer (AES-256-GCM key)
|
|
94
|
-
*/
|
|
95
|
-
function deriveSessionKey(myPrivateKeyB64, peerPublicKeyB64, deviceId) {
|
|
96
|
-
const myPrivKey = crypto.createPrivateKey({
|
|
97
|
-
key: Buffer.from(myPrivateKeyB64, 'base64url'),
|
|
98
|
-
format: 'der',
|
|
99
|
-
type: 'pkcs8',
|
|
100
|
-
});
|
|
101
|
-
const peerPubKey = crypto.createPublicKey({
|
|
102
|
-
key: Buffer.from(peerPublicKeyB64, 'base64url'),
|
|
103
|
-
format: 'der',
|
|
104
|
-
type: 'spki',
|
|
105
|
-
});
|
|
106
|
-
const sharedSecret = crypto.diffieHellman({ privateKey: myPrivKey, publicKey: peerPubKey });
|
|
107
|
-
// HKDF: salt = deviceId bytes for domain separation, info = fixed protocol label.
|
|
108
|
-
const salt = Buffer.from(deviceId, 'utf8');
|
|
109
|
-
const info = Buffer.from('sm-e2e-v1', 'utf8');
|
|
110
|
-
return Buffer.from(crypto.hkdfSync('sha256', sharedSecret, salt, info, 32));
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Derive a 6-digit Short Authentication String from the ECDH shared secret.
|
|
115
|
-
* Uses a separate HKDF info label ('sm-sas-v1') so the SAS is independent of
|
|
116
|
-
* the session key. Both sides compute the same value; user confirms they match.
|
|
117
|
-
*/
|
|
118
|
-
function deriveSas(myPrivateKeyB64, peerPublicKeyB64, deviceId) {
|
|
119
|
-
const myPrivKey = crypto.createPrivateKey({
|
|
120
|
-
key: Buffer.from(myPrivateKeyB64, 'base64url'),
|
|
121
|
-
format: 'der',
|
|
122
|
-
type: 'pkcs8',
|
|
123
|
-
});
|
|
124
|
-
const peerPubKey = crypto.createPublicKey({
|
|
125
|
-
key: Buffer.from(peerPublicKeyB64, 'base64url'),
|
|
126
|
-
format: 'der',
|
|
127
|
-
type: 'spki',
|
|
128
|
-
});
|
|
129
|
-
const sharedSecret = crypto.diffieHellman({ privateKey: myPrivKey, publicKey: peerPubKey });
|
|
130
|
-
const salt = Buffer.from(deviceId, 'utf8');
|
|
131
|
-
const info = Buffer.from('sm-sas-v1', 'utf8');
|
|
132
|
-
const sasBytes = Buffer.from(crypto.hkdfSync('sha256', sharedSecret, salt, info, 3));
|
|
133
|
-
const sasNum = ((sasBytes[0] << 16) | (sasBytes[1] << 8) | sasBytes[2]) % 1_000_000;
|
|
134
|
-
return sasNum.toString().padStart(6, '0');
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Encrypt a plaintext JSON string into an AES-256-GCM box.
|
|
139
|
-
* @returns { nonce: base64url, ciphertext: base64url } — the nonce is 12 random bytes
|
|
140
|
-
*/
|
|
141
|
-
function encryptBox(plaintext, sessionKey) {
|
|
142
|
-
const nonce = crypto.randomBytes(12);
|
|
143
|
-
const cipher = crypto.createCipheriv('aes-256-gcm', sessionKey, nonce);
|
|
144
|
-
const encrypted = Buffer.concat([cipher.update(plaintext, 'utf8'), cipher.final()]);
|
|
145
|
-
const tag = cipher.getAuthTag(); // 16-byte GCM authentication tag
|
|
146
|
-
return {
|
|
147
|
-
nonce: nonce.toString('base64url'),
|
|
148
|
-
// Append the GCM tag to the ciphertext so decryptBox can locate it.
|
|
149
|
-
ciphertext: Buffer.concat([encrypted, tag]).toString('base64url'),
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Decrypt an AES-256-GCM box produced by encryptBox (or the browser's equivalent).
|
|
155
|
-
* @returns Decrypted UTF-8 string, or null if authentication fails.
|
|
156
|
-
*/
|
|
157
|
-
function decryptBox(nonceB64, ciphertextB64, sessionKey) {
|
|
158
|
-
try {
|
|
159
|
-
const nonce = Buffer.from(nonceB64, 'base64url');
|
|
160
|
-
const data = Buffer.from(ciphertextB64, 'base64url');
|
|
161
|
-
if (data.length < 16) return null; // too short to contain tag
|
|
162
|
-
const tag = data.subarray(data.length - 16);
|
|
163
|
-
const ciphertext = data.subarray(0, data.length - 16);
|
|
164
|
-
const decipher = crypto.createDecipheriv('aes-256-gcm', sessionKey, nonce);
|
|
165
|
-
decipher.setAuthTag(tag);
|
|
166
|
-
const plain = Buffer.concat([decipher.update(ciphertext), decipher.final()]).toString('utf8');
|
|
167
|
-
return plain;
|
|
168
|
-
} catch {
|
|
169
|
-
return null; // authentication failed — drop the message
|
|
170
|
-
}
|
|
171
|
-
}
|
|
71
|
+
// Implemented in ./lib/remoteE2eCrypto.cjs (shared with the desktop client role).
|
|
72
|
+
const { generateE2EKeyPair, deriveSessionKey, deriveSas, encryptBox, decryptBox } = require('./lib/remoteE2eCrypto.cjs');
|
|
172
73
|
|
|
173
74
|
// ─── Module state ────────────────────────────────────────────────────────────
|
|
174
75
|
|
|
@@ -317,7 +218,23 @@ async function getDeviceTicket(deviceToken) {
|
|
|
317
218
|
|
|
318
219
|
// ─── E2E state helpers ────────────────────────────────────────────────────────
|
|
319
220
|
|
|
221
|
+
// tabId → unsubscribe fn for the PtyManager output listener streaming to the peer.
|
|
222
|
+
const _remotePtyStreams = new Map();
|
|
223
|
+
|
|
224
|
+
function stopRemotePtyStream(tabId) {
|
|
225
|
+
const unsub = _remotePtyStreams.get(tabId);
|
|
226
|
+
_remotePtyStreams.delete(tabId);
|
|
227
|
+
if (unsub) {
|
|
228
|
+
try { unsub(); } catch { /* listener already gone */ }
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function stopAllRemotePtyStreams() {
|
|
233
|
+
for (const tabId of [..._remotePtyStreams.keys()]) stopRemotePtyStream(tabId);
|
|
234
|
+
}
|
|
235
|
+
|
|
320
236
|
function resetE2e(state = 'idle') {
|
|
237
|
+
stopAllRemotePtyStreams();
|
|
321
238
|
_e2e = makeState(state);
|
|
322
239
|
_e2ePeerPubKey = null;
|
|
323
240
|
_e2eDeviceId = null;
|
|
@@ -407,6 +324,7 @@ function scheduleReconnect() {
|
|
|
407
324
|
async function disconnect() {
|
|
408
325
|
cancelReconnect();
|
|
409
326
|
stopHeartbeat();
|
|
327
|
+
stopAllRemotePtyStreams();
|
|
410
328
|
resetE2e();
|
|
411
329
|
if (_ws) {
|
|
412
330
|
const ws = _ws;
|
|
@@ -526,6 +444,7 @@ async function connect() {
|
|
|
526
444
|
}
|
|
527
445
|
|
|
528
446
|
async function handleTokenRevoked(deviceId) {
|
|
447
|
+
stopAllRemotePtyStreams();
|
|
529
448
|
logs.writeLine({ scope: 'webRemote', level: 'warn', message: 'token revoked', meta: { deviceId } });
|
|
530
449
|
const cfg = await loadConfig();
|
|
531
450
|
const devices = (cfg.devices || []).filter((d) => d.deviceId !== deviceId);
|
|
@@ -712,6 +631,41 @@ function stopAllSessionWatches() {
|
|
|
712
631
|
if (_sessionListTimer) { clearInterval(_sessionListTimer); _sessionListTimer = null; }
|
|
713
632
|
}
|
|
714
633
|
|
|
634
|
+
/**
|
|
635
|
+
* Pure builder for the phone's session list: one project entry per tab, then
|
|
636
|
+
* each tab's ACTIVE Epics (from active-index.json via readIndex). Never throws.
|
|
637
|
+
*/
|
|
638
|
+
function buildRemoteSessionList(tabs, readIndex) {
|
|
639
|
+
const out = [];
|
|
640
|
+
const seenEpics = new Set();
|
|
641
|
+
for (const tab of Array.isArray(tabs) ? tabs : []) {
|
|
642
|
+
if (!tab) continue;
|
|
643
|
+
const project = tab.label || path.basename(tab.cwd || '');
|
|
644
|
+
out.push({ kind: 'project', tabId: tab.sessionId, cwd: tab.cwd, title: tab.label || tab.cwd, project });
|
|
645
|
+
let sessions = null;
|
|
646
|
+
try { sessions = readIndex(tab.cwd)?.sessions; } catch { sessions = null; }
|
|
647
|
+
if (!sessions || typeof sessions !== 'object') continue;
|
|
648
|
+
for (const epic of Object.values(sessions)) {
|
|
649
|
+
if (!epic || epic.status !== 'active') continue;
|
|
650
|
+
if (typeof epic.claudeSessionId !== 'string' || !epic.claudeSessionId) continue;
|
|
651
|
+
if (seenEpics.has(epic.id)) continue;
|
|
652
|
+
seenEpics.add(epic.id);
|
|
653
|
+
const firstLine = typeof epic.goalText === 'string' ? epic.goalText.split('\n')[0].trim().slice(0, 80).trim() : '';
|
|
654
|
+
out.push({
|
|
655
|
+
kind: 'epic',
|
|
656
|
+
tabId: epic.claudeSessionId,
|
|
657
|
+
epicId: epic.id,
|
|
658
|
+
cwd: epic.worktree?.dir || epic.cwd,
|
|
659
|
+
title: firstLine || epic.id,
|
|
660
|
+
project,
|
|
661
|
+
tag: epic.tag,
|
|
662
|
+
agentType: epic.agentType,
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
return out;
|
|
667
|
+
}
|
|
668
|
+
|
|
715
669
|
/** Push the current session list (reuses sessionsStore — the canonical source). */
|
|
716
670
|
async function pushSessionList() {
|
|
717
671
|
try {
|
|
@@ -727,13 +681,12 @@ async function pushSessionList() {
|
|
|
727
681
|
if (_e2e.state !== 'authenticated') return;
|
|
728
682
|
const sessionsStore = require('./sessionsStore.cjs');
|
|
729
683
|
const data = await sessionsStore.load();
|
|
730
|
-
//
|
|
684
|
+
// Tabs + their ACTIVE Epics → SessionMeta. tabId === claude sessionId so it
|
|
731
685
|
// matches the transcript JSONL name used by cmd:session:subscribe.
|
|
732
|
-
const
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
state: _sessionWatchers.get(t.sessionId)?.state ?? null,
|
|
686
|
+
const { readActiveIndex } = require('./lib/epicMint.cjs');
|
|
687
|
+
const sessions = buildRemoteSessionList(data?.tabs ?? [], readActiveIndex).map((s) => ({
|
|
688
|
+
...s,
|
|
689
|
+
state: _sessionWatchers.get(s.tabId)?.state ?? null,
|
|
737
690
|
}));
|
|
738
691
|
const payload = { sessions, activeTabId: data?.activeTabId ?? null };
|
|
739
692
|
const json = JSON.stringify(payload);
|
|
@@ -1072,7 +1025,25 @@ function getDispatchMap() {
|
|
|
1072
1025
|
// remotely-controlled 8 KiB string to spawn is a landmine if pty.cjs
|
|
1073
1026
|
// ever uses it. Remote callers have no legitimate need for it.
|
|
1074
1027
|
const { startupCommand: _ignored, ...safePayload } = parsed;
|
|
1075
|
-
|
|
1028
|
+
const result = await ptyManager.spawn(safePayload);
|
|
1029
|
+
// Stream output to the peer — replaces any prior subscription for this tab.
|
|
1030
|
+
// Chunk contents are sensitive: never logged.
|
|
1031
|
+
const tabId = safePayload.tabId;
|
|
1032
|
+
stopRemotePtyStream(tabId);
|
|
1033
|
+
const unsub = ptyManager.addOutputListener(
|
|
1034
|
+
tabId,
|
|
1035
|
+
(_id, data) => {
|
|
1036
|
+
if (_e2e.state !== 'authenticated' || !loadConfigSync().remoteEnabled) return;
|
|
1037
|
+
pushEvent('event:pty:data', { tabId, data });
|
|
1038
|
+
},
|
|
1039
|
+
(_id, info) => {
|
|
1040
|
+
if (_remotePtyStreams.get(tabId) === unsub) _remotePtyStreams.delete(tabId);
|
|
1041
|
+
if (_e2e.state !== 'authenticated' || !loadConfigSync().remoteEnabled) return;
|
|
1042
|
+
pushEvent('event:pty:exit', { tabId, exitCode: info?.exitCode, signal: info?.signal });
|
|
1043
|
+
},
|
|
1044
|
+
);
|
|
1045
|
+
_remotePtyStreams.set(tabId, unsub);
|
|
1046
|
+
return result;
|
|
1076
1047
|
},
|
|
1077
1048
|
|
|
1078
1049
|
'cmd:pty:write': async (payload) => {
|
|
@@ -1088,6 +1059,7 @@ function getDispatchMap() {
|
|
|
1088
1059
|
|
|
1089
1060
|
'cmd:pty:kill': async (payload) => {
|
|
1090
1061
|
const parsed = schemas.ptyTabId.parse(payload);
|
|
1062
|
+
stopRemotePtyStream(parsed.tabId);
|
|
1091
1063
|
ptyManager.kill(parsed.tabId);
|
|
1092
1064
|
return { ok: true };
|
|
1093
1065
|
},
|
|
@@ -1190,6 +1162,7 @@ async function pair(otp) {
|
|
|
1190
1162
|
}
|
|
1191
1163
|
|
|
1192
1164
|
async function revokeDevice(deviceId) {
|
|
1165
|
+
stopAllRemotePtyStreams();
|
|
1193
1166
|
invalidateConfigCache();
|
|
1194
1167
|
const cfg = await loadConfig();
|
|
1195
1168
|
const devices = (cfg.devices || []).filter((d) => d.deviceId !== deviceId);
|
|
@@ -1214,6 +1187,7 @@ async function revokeDevice(deviceId) {
|
|
|
1214
1187
|
* This is the local-side "kill everything" action (ADR §4.1).
|
|
1215
1188
|
*/
|
|
1216
1189
|
async function revokeAllDevices() {
|
|
1190
|
+
stopAllRemotePtyStreams();
|
|
1217
1191
|
const cfg = await loadConfig();
|
|
1218
1192
|
const revokedCount = (cfg.devices || []).length;
|
|
1219
1193
|
await saveConfig({ ...cfg, remoteEnabled: false, devices: [] });
|
|
@@ -1361,4 +1335,12 @@ module.exports = {
|
|
|
1361
1335
|
resetE2e,
|
|
1362
1336
|
getE2eState: () => _e2e,
|
|
1363
1337
|
},
|
|
1338
|
+
__test: {
|
|
1339
|
+
getDispatchMap,
|
|
1340
|
+
buildRemoteSessionList,
|
|
1341
|
+
setWs: (ws) => { _ws = ws; },
|
|
1342
|
+
setE2eAuthenticated: (key) => { _e2e = makeState('authenticated', key, null); },
|
|
1343
|
+
revokeAllDevices,
|
|
1344
|
+
streamCount: () => _remotePtyStreams.size,
|
|
1345
|
+
},
|
|
1364
1346
|
};
|
package/src/preload/api.d.ts
CHANGED
|
@@ -317,12 +317,13 @@ export interface AgentPersonaSaveInput {
|
|
|
317
317
|
effort?: string;
|
|
318
318
|
color: string;
|
|
319
319
|
tags: AgentPersonaTag[];
|
|
320
|
-
/** Project cwds (or the `'*'` sentinel) this persona's Action button appears in. */
|
|
320
|
+
/** Project cwds (or the `'*'` sentinel) this persona's Action button appears in. Omit to keep the existing file's value; `[]` clears it. */
|
|
321
321
|
projects?: string[];
|
|
322
|
-
/** Opening instruction sent by this persona's Action button. */
|
|
322
|
+
/** Opening instruction sent by this persona's Action button. Omit to keep the existing file's value. */
|
|
323
323
|
action?: string;
|
|
324
|
-
/** Caption override for this persona's Action button. */
|
|
324
|
+
/** Caption override for this persona's Action button. Omit to keep the existing file's value. */
|
|
325
325
|
actionLabel?: string;
|
|
326
|
+
/** Omit to keep the existing file's value. */
|
|
326
327
|
title?: string;
|
|
327
328
|
/** Open project name: write that project's frontmatter-only override (only `model`/`effort` are used) instead of the global file. */
|
|
328
329
|
projectName?: string;
|
|
@@ -1593,6 +1594,31 @@ export interface WebRemoteDevice {
|
|
|
1593
1594
|
lastConnectedAt: string | null;
|
|
1594
1595
|
}
|
|
1595
1596
|
|
|
1597
|
+
export interface RemoteMachinePeer {
|
|
1598
|
+
peerId: string;
|
|
1599
|
+
deviceId: string;
|
|
1600
|
+
machineName: string;
|
|
1601
|
+
pairedAt: string;
|
|
1602
|
+
clientPublicKey: string;
|
|
1603
|
+
verifiedDevicePubKey: string | null;
|
|
1604
|
+
status: string;
|
|
1605
|
+
reason: string | null;
|
|
1606
|
+
sas: string | null;
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
export interface RemoteClientStatus {
|
|
1610
|
+
peerId: string;
|
|
1611
|
+
status: string;
|
|
1612
|
+
reason: string | null;
|
|
1613
|
+
sas: string | null;
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1616
|
+
export interface RemoteClientEvent {
|
|
1617
|
+
peerId: string;
|
|
1618
|
+
type: string;
|
|
1619
|
+
payload: unknown;
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1596
1622
|
export interface WebRemoteStatus {
|
|
1597
1623
|
enabled: boolean;
|
|
1598
1624
|
remoteControlEnabled: boolean;
|
|
@@ -1814,8 +1840,8 @@ export interface SessionManagerAPI {
|
|
|
1814
1840
|
writeText: (path: string, text: string, writer?: OpsWriter) => Promise<WriteResult>;
|
|
1815
1841
|
listDir: (path: string, opts?: { filesOnly?: boolean; dirsOnly?: boolean; includeHidden?: boolean }) => Promise<ListDirResult>;
|
|
1816
1842
|
exists: (path: string) => Promise<boolean>;
|
|
1817
|
-
watch: (paths: string[]) => void;
|
|
1818
|
-
unwatch: (paths: string[]) => void;
|
|
1843
|
+
watch: (paths: string[], opts?: { depth?: 0 | 1 | 2 }) => void;
|
|
1844
|
+
unwatch: (paths: string[], opts?: { depth?: 0 | 1 | 2 }) => void;
|
|
1819
1845
|
onChanged: (handler: (info: ConfigChangedEvent) => void) => () => void;
|
|
1820
1846
|
parseImports: (path: string) => Promise<{ ok: true; imports: ImportRef[] } | { ok: false; error: string }>;
|
|
1821
1847
|
};
|
|
@@ -1930,6 +1956,8 @@ export interface SessionManagerAPI {
|
|
|
1930
1956
|
aggregate: (req?: HistoryAggregateRequest) => Promise<HistoryAggregateResult>;
|
|
1931
1957
|
scanProjects: () => Promise<SessionScanResult>;
|
|
1932
1958
|
dashboard: (req: HistoryDashboardRequest) => Promise<HistoryDashboardResult>;
|
|
1959
|
+
/** Fires (throttled to 1/5 s) when main appends days to the rollup. Returns unsubscribe. */
|
|
1960
|
+
onUpdated: (handler: () => void) => () => void;
|
|
1933
1961
|
};
|
|
1934
1962
|
schedule: {
|
|
1935
1963
|
state: () => Promise<ScheduleStateSnapshot>;
|
|
@@ -2111,6 +2139,15 @@ export interface SessionManagerAPI {
|
|
|
2111
2139
|
* renderer needs per-row badges without a separate git call per file. */
|
|
2112
2140
|
fileStatus: (cwd: string) => Promise<GitFileStatusMap>;
|
|
2113
2141
|
};
|
|
2142
|
+
remoteClient: {
|
|
2143
|
+
list: () => Promise<RemoteMachinePeer[]>;
|
|
2144
|
+
connect: (peerId: string) => Promise<{ status: string; reason: string | null; sas: string | null }>;
|
|
2145
|
+
confirmSas: (peerId: string) => Promise<{ ok: boolean; reason?: string }>;
|
|
2146
|
+
remove: (peerId: string) => Promise<{ ok: boolean }>;
|
|
2147
|
+
send: (peerId: string, type: string, payload?: unknown) => Promise<unknown>;
|
|
2148
|
+
onStatus: (handler: (status: RemoteClientStatus) => void) => () => void;
|
|
2149
|
+
onEvent: (handler: (ev: RemoteClientEvent) => void) => () => void;
|
|
2150
|
+
};
|
|
2114
2151
|
webRemote: {
|
|
2115
2152
|
getStatus: () => Promise<WebRemoteStatus>;
|
|
2116
2153
|
enable: () => Promise<WebRemoteMutationResult>;
|
package/src/preload/index.cjs
CHANGED
|
@@ -150,8 +150,8 @@ contextBridge.exposeInMainWorld('api', {
|
|
|
150
150
|
writeText: (path, text, writer) => ipcRenderer.invoke('config:write-text', { path, text, writer }),
|
|
151
151
|
listDir: (path, opts) => ipcRenderer.invoke('config:list-dir', { path, opts }),
|
|
152
152
|
exists: (path) => ipcRenderer.invoke('config:exists', { path }),
|
|
153
|
-
watch: (paths) => ipcRenderer.send('config:watch', { paths }),
|
|
154
|
-
unwatch: (paths) => ipcRenderer.send('config:unwatch', { paths }),
|
|
153
|
+
watch: (paths, opts) => ipcRenderer.send('config:watch', { paths, opts }),
|
|
154
|
+
unwatch: (paths, opts) => ipcRenderer.send('config:unwatch', { paths, opts }),
|
|
155
155
|
parseImports: (path) => ipcRenderer.invoke('config:parse-imports', { path }),
|
|
156
156
|
onChanged: (handler) => {
|
|
157
157
|
const listener = (_e, info) => handler(info);
|
|
@@ -234,6 +234,12 @@ contextBridge.exposeInMainWorld('api', {
|
|
|
234
234
|
aggregate: (req) => ipcRenderer.invoke('history:aggregate', req),
|
|
235
235
|
scanProjects: () => ipcRenderer.invoke('history:scan-projects'),
|
|
236
236
|
dashboard: (req) => ipcRenderer.invoke('history:dashboard', req),
|
|
237
|
+
// Fired (throttled) after main appends new days to the rollup.
|
|
238
|
+
onUpdated: (handler) => {
|
|
239
|
+
const listener = () => handler();
|
|
240
|
+
ipcRenderer.on('history:updated', listener);
|
|
241
|
+
return () => ipcRenderer.removeListener('history:updated', listener);
|
|
242
|
+
},
|
|
237
243
|
},
|
|
238
244
|
files: {
|
|
239
245
|
list: (path, showHidden) => ipcRenderer.invoke('files:list', { path, showHidden }),
|
|
@@ -392,6 +398,25 @@ contextBridge.exposeInMainWorld('api', {
|
|
|
392
398
|
status: (cwd) => ipcRenderer.invoke('git:status', { cwd }),
|
|
393
399
|
fileStatus: (cwd) => ipcRenderer.invoke('git:file-status', { cwd }),
|
|
394
400
|
},
|
|
401
|
+
remoteClient: {
|
|
402
|
+
/** Paired remote machines merged with live connection status. */
|
|
403
|
+
list: () => ipcRenderer.invoke('remoteClient:list'),
|
|
404
|
+
connect: (peerId) => ipcRenderer.invoke('remoteClient:connect', { peerId }),
|
|
405
|
+
/** Confirm the short authentication string matches the remote machine. */
|
|
406
|
+
confirmSas: (peerId) => ipcRenderer.invoke('remoteClient:confirm-sas', { peerId }),
|
|
407
|
+
remove: (peerId) => ipcRenderer.invoke('remoteClient:remove', { peerId }),
|
|
408
|
+
send: (peerId, type, payload) => ipcRenderer.invoke('remoteClient:send', { peerId, type, payload }),
|
|
409
|
+
onStatus: (handler) => {
|
|
410
|
+
const listener = (_e, payload) => handler(payload);
|
|
411
|
+
ipcRenderer.on('remoteClient:status', listener);
|
|
412
|
+
return () => ipcRenderer.removeListener('remoteClient:status', listener);
|
|
413
|
+
},
|
|
414
|
+
onEvent: (handler) => {
|
|
415
|
+
const listener = (_e, payload) => handler(payload);
|
|
416
|
+
ipcRenderer.on('remoteClient:event', listener);
|
|
417
|
+
return () => ipcRenderer.removeListener('remoteClient:event', listener);
|
|
418
|
+
},
|
|
419
|
+
},
|
|
395
420
|
webRemote: {
|
|
396
421
|
/** Current connection state (no token values). */
|
|
397
422
|
getStatus: () => ipcRenderer.invoke('webRemote:get-status'),
|
|
@@ -5,7 +5,7 @@ tools: Read, Grep, Glob, Bash, Write, Edit
|
|
|
5
5
|
title: 'Project Home — Demo Video'
|
|
6
6
|
model: sonnet
|
|
7
7
|
effort: medium
|
|
8
|
-
seedVersion:
|
|
8
|
+
seedVersion: 3
|
|
9
9
|
---
|
|
10
10
|
|
|
11
11
|
You are the demo-video-builder. You make a 30-second animated demo that shows someone what this
|
|
@@ -52,54 +52,73 @@ Produce exactly one complete HTML document:
|
|
|
52
52
|
- Expose `window.smDemo = { duration: 30, seek(t), play(), pause() }`, where `seek(t)` renders
|
|
53
53
|
the exact frame for time `t` in seconds, independent of whatever played before it.
|
|
54
54
|
- Autoplays once on load; shows play/pause, restart, and a progress bar.
|
|
55
|
-
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
- A light/dark neutral palette with sufficient contrast in both.
|
|
62
|
-
</output_contract>
|
|
55
|
+
- Narration audio built per `<audio_policy>
|
|
56
|
+
Narration is the default deliverable: every video ships with a natural-sounding on-device voice
|
|
57
|
+
track reading the storyboard captions. Generate it at build time, never at playback time; the
|
|
58
|
+
shipped document never calls out to a network TTS service. A silent video is allowed ONLY when
|
|
59
|
+
the install or model download below genuinely fails — then your final report must state the exact
|
|
60
|
+
failing command and its error. Generating a track and then saving the HTML without it is a failed run.
|
|
63
61
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
- **TTS: Kokoro-82M via `kokoro-onnx`** (Apache-2.0, ONNX runtime, no PyTorch). Install with
|
|
63
|
+
`python3 -m pip install --user --break-system-packages kokoro-onnx soundfile`. If
|
|
64
|
+
`python3 -m pip` is missing, bootstrap it first:
|
|
65
|
+
`curl -sS https://bootstrap.pypa.io/get-pip.py | python3 - --user --break-system-packages`.
|
|
66
|
+
`ffmpeg` must be on PATH.
|
|
67
|
+
- **Shared model cache:** `MODEL_DIR=~/.cache/kokoro-onnx`, reused across projects. Only if
|
|
68
|
+
`kokoro-v1.0.onnx` (~325 MB) or `voices-v1.0.bin` (~28 MB) is missing there, download it with
|
|
69
|
+
`curl -L --max-time 600 -o "$MODEL_DIR/<file>" https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files-v1.0/<file>`.
|
|
70
|
+
Never download into /tmp or the project tree.
|
|
71
|
+
- **Voices** (all `lang='en-us'`, speed 1.0; raise speed only to fit a line into its scene, max 1.15):
|
|
72
|
+
female narrator `af_heart` (Kokoro's top-graded voice; alt `af_bella`) is the default; male
|
|
73
|
+
narrator `am_michael` (alt `am_fenrir`) when the human asks for it or the project's audience or
|
|
74
|
+
brand suggests it. A two-voice video may alternate `af_heart` / `am_michael` per scene. Never use
|
|
75
|
+
Piper `-medium` or espeak (robotic). Piper `en_US-lessac-high` is the fallback only when Kokoro
|
|
76
|
+
cannot be installed.
|
|
77
|
+
- **Build recipe.** Work in a fresh `mktemp -d` directory outside the project. Save this as
|
|
78
|
+
`build.py` there, fill in `SCENES` and `TEMPLATE`, and run it:
|
|
68
79
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
80
|
+
```python
|
|
81
|
+
import base64, os, subprocess
|
|
82
|
+
import numpy as np, soundfile
|
|
83
|
+
from kokoro_onnx import Kokoro
|
|
84
|
+
|
|
85
|
+
MODEL_DIR = os.path.expanduser('~/.cache/kokoro-onnx')
|
|
86
|
+
SCENES = [ # (start_s, end_s, line, voice) — one per scene, from the storyboard captions
|
|
87
|
+
(0.0, 4.0, 'Project name. One-line purpose.', 'af_heart'),
|
|
88
|
+
]
|
|
89
|
+
k = Kokoro(f'{MODEL_DIR}/kokoro-v1.0.onnx', f'{MODEL_DIR}/voices-v1.0.bin')
|
|
90
|
+
buf, sr = None, None
|
|
91
|
+
for start, end, line, voice in SCENES:
|
|
92
|
+
samples, sr = k.create(line, voice=voice, speed=1.0, lang='en-us')
|
|
93
|
+
room = end - start - 0.3
|
|
94
|
+
if len(samples) / sr > room: # overruns its scene: speed up, never past 1.15
|
|
95
|
+
speed = min(1.15, len(samples) / sr / room)
|
|
96
|
+
samples, sr = k.create(line, voice=voice, speed=speed, lang='en-us')
|
|
97
|
+
if buf is None:
|
|
98
|
+
buf = np.zeros(30 * sr, dtype=np.float32)
|
|
99
|
+
at = int((start + 0.15) * sr)
|
|
100
|
+
clip = samples[: len(buf) - at]
|
|
101
|
+
buf[at : at + len(clip)] += clip
|
|
102
|
+
soundfile.write('narration.wav', buf, sr)
|
|
103
|
+
subprocess.run(['ffmpeg', '-y', '-i', 'narration.wav', '-ac', '1', '-ar', '24000',
|
|
104
|
+
'-c:a', 'libmp3lame', '-b:a', '64k', 'narration.mp3'], check=True)
|
|
105
|
+
b64 = base64.b64encode(open('narration.mp3', 'rb').read()).decode()
|
|
106
|
+
html = open('template.html').read() # your finished HTML with the placeholder below
|
|
107
|
+
html = html.replace('AUDIO_B64_PLACEHOLDER', b64) # <audio src="data:audio/mpeg;base64,AUDIO_B64_PLACEHOLDER">
|
|
108
|
+
open('demo.html', 'w').write(html)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Keep the mono track at the model's native 24000 Hz and ~64 kbps — downsampling or dropping below
|
|
112
|
+
~48 kbps makes speech sound crushed (a 30 s track is only ~235 KB). Keep the whole document
|
|
113
|
+
under the 2 MB cap.
|
|
93
114
|
- Wire `play()`/`pause()`/`seek(t)` to the `<audio>` element too (`audio.currentTime = t` on
|
|
94
|
-
seek) so
|
|
95
|
-
|
|
96
|
-
button instead of failing silently forever.
|
|
115
|
+
seek) so narration never drifts from the visual clock; call `.play()` on load and, on rejection
|
|
116
|
+
(autoplay-blocked), show a small "tap for sound" button instead of failing silently.
|
|
97
117
|
- Never write the literal pattern `function (` or `function(` in the inline `<script>` —
|
|
98
|
-
`project_demo_video_write`'s safety scanner blocks anything matching `/\bFunction\s*\(/i
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
silent video rather than failing the whole run — audio is a nice-to-have, never a blocker.
|
|
118
|
+
`project_demo_video_write`'s safety scanner blocks anything matching `/\bFunction\s*\(/i`.
|
|
119
|
+
Use arrow functions (`() => { ... }`) throughout.
|
|
120
|
+
- Save the built file by path (see `<process>` step 6). Never retype the base64 audio into a tool
|
|
121
|
+
argument — a ~300 KB payload retyped by the model is exactly how a run once shipped silent.
|
|
103
122
|
</audio_policy>
|
|
104
123
|
|
|
105
124
|
<process>
|
|
@@ -109,11 +128,13 @@ never calls out to a network TTS service.
|
|
|
109
128
|
2. Write the claims list: for every goal or feature you plan to show, note the source you read
|
|
110
129
|
it from. Drop anything without a source.
|
|
111
130
|
3. Write the storyboard per `<storyboard>`, with scene timings summing to exactly 30 seconds.
|
|
112
|
-
4. Build the HTML per `<output_contract
|
|
131
|
+
4. Build the HTML per `<output_contract>` and the narration track per `<audio_policy>`, ending
|
|
132
|
+
with the final document written to a file (`demo.html`) that contains the `<audio>` tag.
|
|
113
133
|
5. Self-check before saving: scene durations sum to 30, every caption traces to a claim in your
|
|
114
134
|
list, and the document contains none of the forbidden network APIs.
|
|
115
|
-
6. Call `project_demo_video_write` exactly once with `{
|
|
116
|
-
|
|
135
|
+
6. Call `project_demo_video_write` exactly once with `{ htmlPath }` — the absolute path of the
|
|
136
|
+
built file. Never pass the document in `html` (retyping base64 is how narration got lost). It
|
|
137
|
+
validates the document and writes it as the project's Demo Video.
|
|
117
138
|
7. Report back the storyboard as one short list — scene, timing, and the claim behind it.
|
|
118
139
|
</process>
|
|
119
140
|
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{ak as A,aw as y,b0 as de,ah as e,m as U,a as M,aL as k,aI as ce,U as Q,aK as fe,aV as X,M as me,c as G,E as xe}from"./index-v_3LvhMx.js";import{P as he}from"./Panel-Cyt1wpUf.js";import{L as pe}from"./ListDetail-qI27OYfy.js";import{B as R}from"./Button-CRLhoI2K.js";import{u as ue}from"./useAgentsDirWatch-BZTi2K2e.js";import{r as ge}from"./claude-settings-schema-COigsajx.js";import"./monaco-editor-BsIlgG7c.js";import"./useConfigDirWatch-CjcswsWR.js";const ve=n=>{const[s,r]=n.split(".");return Number(s)+(r?Number(r)/100:0)};function be(n){const s=/Effort is supported on ([^.]*?)(?:, with|\.|$)/.exec(n);if(!s)return[];const r=[];for(const d of s[1].split(/,\s*|\s+and\s+/)){const o=/^(\w+)\s+(\d+(?:\.\d+)?)$/.exec(d.trim());o&&r.push({family:o[1].toLowerCase(),version:ve(o[2])})}return r}var J,Y;const je=be(String(((Y=(J=ge.properties)==null?void 0:J.effortLevel)==null?void 0:Y.description)??""));function we(n,s){const r=new RegExp(`${s}-(\\d+)(?:-(\\d{1,2})(?!\\d))?`,"i").exec(n);if(r)return Number(r[1])+(r[2]?Number(r[2])/100:0);const d=new RegExp(`claude-(\\d+)(?:-(\\d{1,2}))?-${s}`,"i").exec(n);return d?Number(d[1])+(d[2]?Number(d[2])/100:0):null}function ye(n,s=je){if(!n||n==="inherit"||s.length===0)return null;const r=A(n);if(!r)return null;const d=s.filter(l=>l.family===r);if(d.length===0)return!1;const o=we(n,r);return o===null?null:o>=Math.min(...d.map(l=>l.version))}const z=["Read","Grep","Glob","Bash","Write","Edit","WebFetch","WebSearch","Task"],Ne=["","red","orange","yellow","green","cyan","blue","purple","pink"],Z={red:"#c0392b",orange:"#b85c34",yellow:"#c9a227",green:"#6f7d52",cyan:"#3f8f8a",blue:"#4a6fa5",purple:"#7a6a8a",pink:"#b45a80"};function W(n){return{name:n.name,description:n.description??"",tools:n.tools,model:n.model??"inherit",effort:n.effort??"inherit",color:n.color??"",tags:n.tags,body:n.body}}const q={name:"new-agent",description:"",tools:["Read","Grep"],model:"inherit",effort:"inherit",color:"",tags:[],body:""},Ce=new Set(Q.map(n=>n.tag));function ke(n){return n.filter(s=>Ce.has(s))}function $e(n){return n.overridingProjects.map(s=>{var o;const r=(o=n.overrideDetails)==null?void 0:o.find(l=>l.project===s);if(!r)return s;const d=[...r.fields.filter(l=>l!=="name"),...r.bodyOverridden?["full body"]:[]];return`${s}: ${d.join(", ")||"overlay"}`}).join(`
|
|
2
|
-
`)}function Se(){const[n,s]=y.useState(null),[r,d]=y.useState(null),[o,l]=y.useState(""),[i,m]=y.useState(null),[S,h]=y.useState(!1),[w,v]=y.useState(!1),[N,u]=y.useState(null),[b,j]=y.useState(!1),L=y.useRef(!0);y.useEffect(()=>()=>{L.current=!1},[]);const a=de(t=>{var x;return((x=t.tabs.find(E=>E.id===t.activeTabId))==null?void 0:x.cwd)??null}),g=a?a.replace(/\/+$/,"").split("/").pop()||a:null,C=y.useRef(0),$=async t=>{const x=++C.current;try{const E=await window.api.agents.listPersonas();if(!L.current||C.current!==x)return;s(E),d(V=>{var P;return t??V??((P=E[0])==null?void 0:P.name)??null})}catch(E){if(!L.current||C.current!==x)return;s([]),k.error(E.message||"failed to load agent personas")}};if(y.useEffect(()=>{$()},[]),y.useEffect(()=>window.api.agents.onChanged(()=>$()),[]),ue(a,()=>$()),y.useEffect(()=>{const t=ce();t&&d(t);const x=E=>d(E.detail);return window.addEventListener("sm:select-persona",x),()=>window.removeEventListener("sm:select-persona",x)},[]),n===null)return e.jsx(U,{title:"loading…"});const T=o.toLowerCase(),F=n.filter(t=>!T||t.name.toLowerCase().includes(T)||(t.description??"").toLowerCase().includes(T)),c=n.find(t=>t.name===r)??n[0]??null,f=i??(c?W(c):null),B=!!i&&!!c&&JSON.stringify(i)!==JSON.stringify(W(c)),O=S,I=t=>{m(null),h(!1),v(!1),u(null),d(t)},p=t=>m(x=>({...x??(c?W(c):q),...t})),K=()=>{m({...q}),h(!0),v(!1)},ne=()=>{f&&(m({...f,name:f.name+"-copy"}),h(!0))},se=()=>{m(null),h(!1)},ae=async()=>{if(f){if(!/^[a-z][a-z0-9-]*$/.test(f.name)){k.error('agent name must be lowercase, hyphenated (e.g. "my-agent")');return}j(!0);try{const t=O?null:c,x={name:f.name,originalName:O||c==null?void 0:c.name,description:f.description,tools:f.tools,model:f.model,effort:f.effort,color:f.color,tags:ke(f.tags),projects:(t==null?void 0:t.projects)??void 0,action:(t==null?void 0:t.action)??void 0,actionLabel:(t==null?void 0:t.actionLabel)??void 0,body:f.body};await window.api.agents.savePersona(x),k.info(O?`created ${f.name}`:`saved ${f.name}`),m(null),h(!1),await $(f.name)}catch(t){k.error(t.message||"failed to save agent persona")}finally{j(!1)}}},oe=async()=>{if(c){j(!0);try{await window.api.agents.deletePersona({name:c.name}),k.info(`deleted ${c.name}`),v(!1),m(null),h(!1),await $()}catch(t){k.error(t.message||"failed to delete agent persona")}finally{j(!1)}}},re=async t=>{j(!0);try{await window.api.agents.deletePersona({name:t}),k.info(`deleted ${t}`),u(null),r===t&&(m(null),h(!1)),await $()}catch(x){k.error(x.message||"failed to delete agent persona")}finally{j(!1)}},ie=async t=>{if(c)try{await window.api.agents.removeOverride({name:c.name,projectName:t}),k.info(`removed ${t}'s override of ${c.name}`),await $(c.name)}catch(x){k.error(x.message||"failed to remove override")}},le=async t=>{if(!(!c||!g)){j(!0);try{t.model==="inherit"&&t.effort==="inherit"?(await window.api.agents.removeOverride({name:c.name,projectName:g}),k.info(`cleared ${g}'s override of ${c.name}`)):(await window.api.agents.savePersona({name:c.name,projectName:g,description:"",tools:[],color:"",tags:[],body:"",model:t.model,effort:t.effort}),k.info(`saved ${g}'s override of ${c.name}`)),await $(c.name)}catch(x){k.error(x.message||"failed to save project override")}finally{j(!1)}}};return e.jsx(he,{toolbar:e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-fg-faint",children:[n.length," persona",n.length===1?"":"s"]}),e.jsx("input",{value:o,onChange:t=>l(t.target.value),placeholder:"filter…",className:"bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg w-40"}),e.jsx("div",{className:"flex-1"}),e.jsx(R,{variant:"primary",onClick:K,children:"+ New agent"})]}),children:e.jsx(pe,{sidebar:e.jsxs("div",{className:"py-1",children:[O&&e.jsx("div",{className:"w-full text-left px-3 py-1 text-xs flex flex-col gap-0.5 bg-bg-hi text-fg border-l-2 border-accent",children:e.jsxs("span",{className:"flex items-center gap-2 justify-between w-full",children:[e.jsx("span",{className:"truncate font-mono",children:f==null?void 0:f.name}),e.jsx("span",{className:"shrink-0 text-[10px] font-semibold text-accent",children:"new"})]})}),F.length===0&&!O?e.jsx("div",{className:"px-3 py-1 text-xs text-fg-faint italic",children:"no agent personas found"}):F.map(t=>{const x=!O&&t.name===r,E=x&&B,V=N===t.name;return e.jsxs("div",{"data-agent-row":t.name,className:`group w-full text-left px-3 py-1 text-xs flex flex-col gap-0.5 border-l-2 cursor-pointer ${x?"bg-bg-hi text-fg border-accent":"text-fg-dim hover:text-fg hover:bg-bg-hi border-transparent"}`,onClick:()=>I(t.name),children:[e.jsxs("span",{className:"flex items-center gap-2 justify-between w-full",children:[e.jsxs("span",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"w-2 h-2 rounded-sm shrink-0",style:{background:t.color?Z[t.color]??t.color:"var(--fg-faint, #999)",opacity:t.color?1:.35}}),e.jsx("span",{className:"truncate font-mono",children:t.name})]}),e.jsxs("span",{className:"shrink-0 flex items-center gap-1.5",children:[E&&e.jsx("span",{className:"text-[10px] font-semibold text-accent",children:"unsaved"}),!E&&t.overridingProjects.length>0&&e.jsx("span",{title:$e(t),children:e.jsxs(M,{tone:"dim",children:[t.overridingProjects.length," override",t.overridingProjects.length>1?"s":""]})}),V?e.jsxs("span",{className:"flex items-center gap-1",onClick:P=>P.stopPropagation(),children:[e.jsx("button",{onClick:()=>re(t.name),disabled:b,title:`Delete ${t.name}`,className:"text-[10px] font-semibold text-red-400 hover:text-red-300",children:"confirm"}),e.jsx("button",{onClick:()=>u(null),title:"Cancel",className:"text-[10px] text-fg-faint hover:text-fg",children:"cancel"})]}):e.jsx("button",{onClick:P=>{P.stopPropagation(),u(t.name)},title:`Delete ${t.name}`,className:"opacity-0 group-hover:opacity-100 text-fg-faint hover:text-red-400 transition-opacity",children:"×"})]})]}),t.description&&e.jsx("span",{className:"truncate text-fg-faint",children:t.description})]},t.name)})]}),detail:f?e.jsx(Le,{obj:f,set:p,saved:c,dirty:B,isNew:O,busy:b,confirmDelete:w,setConfirmDelete:v,onDuplicate:ne,onRevert:se,onSave:ae,onDelete:oe,onDropOverride:ie,activeProject:g,onSaveOverride:le}):e.jsx(U,{title:"select an agent"})})})}const Me=y.memo(Se);function Le({obj:n,set:s,saved:r,dirty:d,isNew:o,busy:l,confirmDelete:i,setConfirmDelete:m,onDuplicate:S,onRevert:h,onSave:w,onDelete:v,onDropOverride:N,activeProject:u,onSaveOverride:b}){const j=`~/.claude/agents/${n.name}.md`,L=d||o;return e.jsxs("div",{className:"max-w-3xl",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-line flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-semibold text-fg font-mono",children:n.name}),o?e.jsx(M,{tone:"accent",children:"unsaved draft"}):d?e.jsx(M,{tone:"warn",children:"edited"}):e.jsx(M,{tone:"good",children:"saved"}),e.jsx("span",{className:"ml-auto text-[11px] text-fg-faint font-mono",children:j})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsx(D,{label:"name",hint:"Filename on disk — lowercase, hyphenated.",children:e.jsx("input",{value:n.name,onChange:a=>s({name:a.target.value.toLowerCase()}),className:"w-full bg-bg border border-line rounded px-2 py-1 text-xs text-fg font-mono"})}),e.jsx(D,{label:"description",hint:"Shown in the list and in agent pickers.",children:e.jsx("input",{value:n.description,onChange:a=>s({description:a.target.value}),className:"w-full bg-bg border border-line rounded px-2 py-1 text-xs text-fg"})}),e.jsx(ee,{value:n.model,onChange:a=>s({model:a})}),e.jsx(te,{value:n.effort,model:n.model,onChange:a=>s({effort:a})}),!o&&r&&e.jsx(Ee,{saved:r,activeProject:u,busy:l,onSave:b}),e.jsx(D,{label:"tools",hint:`${n.tools.length} of ${z.length} granted. Anything not ticked is refused at call time.`,children:e.jsx("div",{className:"flex flex-wrap gap-1.5",children:z.map(a=>{const g=n.tools.includes(a);return e.jsx("button",{onClick:()=>s({tools:g?n.tools.filter(C=>C!==a):[...n.tools,a]}),className:`px-2 py-0.5 rounded-full text-[11px] font-mono border ${g?"bg-sage/15 text-sage-dark border-sage/30":"bg-bg-hi text-fg-faint border-line"}`,children:a},a)})})}),e.jsx(D,{label:"color",children:e.jsx("div",{className:"flex gap-1.5",children:Ne.map(a=>e.jsx("button",{title:a||"none",onClick:()=>s({color:a}),className:"w-5 h-5 rounded",style:{background:a?Z[a]:"transparent",border:n.color===a?"2px solid var(--accent, #b85c34)":"1px solid var(--line, #555)"}},a||"none"))})}),e.jsx(D,{label:"tags",hint:"Session mission tags this persona is associated with — shown as the default agent on that tag's own page. The first one (in Tag Library order) is the MISSION an Action button's session opens with.",children:e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Q.map(a=>{const g=n.tags.includes(a.tag),C=fe(a.tag);return e.jsxs("button",{onClick:()=>s({tags:g?n.tags.filter($=>$!==a.tag):[...n.tags,a.tag]}),className:`px-2 py-0.5 rounded-full text-[11px] font-mono border ${g?`${C.bg} ${C.text} ${C.border?"border-current/30":"border-transparent"}`:"bg-bg-hi text-fg-faint border-line"}`,children:["#",a.tag]},a.tag)})})}),e.jsx(D,{label:"definition",hint:"The system prompt this persona runs under.",children:e.jsx("textarea",{rows:9,value:n.body,onChange:a=>s({body:a.target.value}),className:"w-full bg-bg border border-line rounded px-2 py-1.5 text-xs text-fg font-mono leading-relaxed resize-y"})}),e.jsx(D,{label:"project overrides",hint:"Open projects that shadow this definition with a local copy.",children:r&&r.overridingProjects.length>0?e.jsx("div",{className:"flex flex-wrap gap-1.5",children:r.overridingProjects.map(a=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 bg-bg-elev border border-line rounded px-2 py-0.5 text-[11px] font-mono text-fg-dim",children:[a,e.jsx("button",{onClick:()=>N(a),title:"Drop the local copy",className:"text-fg-faint hover:text-fg",children:"×"})]},a))}):e.jsx("div",{className:"text-xs text-fg-faint italic",children:o?"save first to see project overrides.":"no open project overlays this agent — the global definition applies everywhere."})})]}),e.jsx("div",{className:"px-4 py-2.5 border-t border-line flex items-center gap-2 flex-wrap",children:i?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-xs text-fg-dim",children:["Delete ",e.jsx("strong",{className:"font-mono",children:n.name})," and its file?"]}),e.jsx(R,{variant:"danger",onClick:v,disabled:l,children:"Delete"}),e.jsx(R,{onClick:()=>m(!1),children:"Keep"})]}):e.jsxs(e.Fragment,{children:[e.jsx(R,{onClick:S,disabled:l,children:"Duplicate"}),!o&&e.jsx(R,{variant:"danger",onClick:()=>m(!0),disabled:l,children:"Delete"}),e.jsx("div",{className:"flex-1"}),L&&e.jsx("span",{className:"text-[11px] text-fg-faint",children:"unsaved changes"}),e.jsx(R,{onClick:h,disabled:!L||l,children:"Revert"}),e.jsx(R,{variant:"primary",onClick:w,disabled:!L||l,children:l?"Saving…":o?"Create":"Save"})]})})]})}function D({label:n,hint:s,children:r}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] font-semibold uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:n}),r,s&&e.jsx("div",{className:"text-[11px] text-fg-faint mt-1 leading-snug",children:s})]})}const _="latest",H="Blocked by the availableModels allowlist in your Claude settings";function ee({value:n,onChange:s,label:r="default model",hint:d,testIdPrefix:o="",inheritLabel:l}){var O,I;const{catalog:i,loading:m,degraded:S,refresh:h}=X(null),w=i?["inherit",...i.aliases]:[...me],v=(i==null?void 0:i.availableModels)??null,N=p=>!!v&&p!=="inherit"&&!v.includes(p),u=(p,K)=>!!v&&!v.includes(p)&&!(K&&v.includes(K)),b=n||"inherit",j=((O=/\[[^\]]*\]$/.exec(b))==null?void 0:O[0])??"",L=w.includes(b),a=!L&&i&&A(b)&&w.includes(A(b)+j)?A(b)+j:null,g=L?b:a??b,C=A(g),$=((I=/\[[^\]]*\]$/.exec(g))==null?void 0:I[0])??"",T=!!i&&b!=="inherit"&&!!C&&w.includes(g),F=T?i.models.filter(p=>A(p)===C).map(p=>p+$):[],c=L?_:b,f={};if(i)for(const p of w)N(p)&&(f[p]=H);const B={};for(const p of F)u(p,C)&&(B[p]=H);return e.jsxs(D,{label:r,hint:d??"This persona's default model for its Epics — sets the --model an Epic launches with (Terminal + Chat both honor it). 'inherit' falls back to each view's own default, not this Settings page. Cheap models for read-only personas; opus for judgement calls.",children:[e.jsx("div",{"data-testid":`${o}model-row`,children:e.jsx(G,{options:w,value:g,onChange:s,mono:!0,blocked:f,labels:l?{inherit:l}:void 0})}),T&&e.jsxs("div",{className:"mt-2","data-testid":`${o}model-version-row`,children:[e.jsx("div",{className:"text-[10.5px] text-fg-faint mb-1 font-mono",children:"version"}),e.jsx(G,{options:[_,...F],value:c,onChange:p=>s(p===_?g:p),mono:!0,blocked:B})]}),e.jsxs("div",{className:"text-[11px] text-fg-faint mt-1 leading-snug flex items-center gap-2",children:[e.jsx("span",{children:i?`Models are live-read from the installed claude CLI${S?" (cached — CLI probe unavailable)":""}. "latest" keeps the floating alias.`:m?"Loading model catalog…":"catalog unavailable — showing the standard list."}),e.jsx("button",{"data-testid":`${o}model-catalog-refresh`,onClick:()=>{h()},disabled:m,className:"underline text-fg-dim disabled:opacity-40",children:"refresh"})]})]})}function te({value:n,model:s,onChange:r,label:d="effort",testIdPrefix:o="",inheritLabel:l}){const{catalog:i}=X(null),m=i&&i.effortLevels.length?["inherit",...i.effortLevels]:[...xe],S=(i==null?void 0:i.settingsEffortLevels)??[],h=i?m.filter(N=>N!=="inherit"&&!S.includes(N)):[],w=n||"inherit",v=w!=="inherit"&&ye(s)===!1;return e.jsxs(D,{label:d,hint:i?`Effort levels are live-read from the installed claude CLI (what /effort accepts). ${h.length?`${h.join(", ")} ${h.length>1?"are":"is"} session-only — settings.json accepts ${S.join(", ")}. `:""}'inherit' writes no effort: line.`:"catalog unavailable — showing the standard list. 'inherit' writes no effort: line.",children:[e.jsx("div",{"data-testid":`${o}effort-row`,children:e.jsx(G,{options:m,value:w,onChange:r,mono:!0,labels:l?{inherit:l}:void 0})}),h.length>0&&e.jsx("div",{className:"text-[11px] text-fg-faint mt-1 font-mono","data-testid":`${o}effort-session-only`,children:h.map(N=>`${N} (session-only)`).join(" · ")}),v&&e.jsx("div",{className:"text-[11px] text-amber-400 mt-1 leading-snug","data-testid":`${o}effort-unsupported-note`,children:"The selected model does not support effort — the CLI will ignore this setting."})]})}function Ee({saved:n,activeProject:s,busy:r,onSave:d}){var w,v,N;if(!s)return e.jsxs("div",{"data-testid":"project-override-none",className:"border border-dashed border-line rounded p-3 text-[11px] text-fg-faint",children:[e.jsx("div",{className:"text-[10.5px] font-semibold uppercase tracking-wide mb-1 font-mono",children:"project override"}),"No active project — open a project tab to override this persona's model or effort for that project only."]});const o=(w=n.overrideDetails)==null?void 0:w.find(u=>u.project===s),l=!!(o!=null&&o.bodyOverridden),i=((v=o==null?void 0:o.values)==null?void 0:v.model)??"inherit",m=((N=o==null?void 0:o.values)==null?void 0:N.effort)??"inherit",S=n.model??"inherit",h=n.effort??"inherit";return e.jsxs("div",{"data-testid":"project-override",className:"border border-accent/40 rounded p-3 space-y-3 bg-accent/5",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-[10.5px] font-semibold uppercase tracking-wide text-accent font-mono",children:"project override"}),e.jsxs(M,{tone:"accent",children:[s," only"]}),e.jsx("span",{className:"ml-auto text-[11px] text-fg-faint font-mono",children:`<project>/.claude/agents/${n.name}.md`})]}),e.jsxs("div",{className:"text-[11px] text-fg-faint leading-snug",children:["Changes what the SCHEDULER (and new Epics) spawn for ",e.jsx("strong",{children:s})," only — a frontmatter-only overlay with just the keys you set; the persona's body stays the global one. The global model/effort rows edit the machine-wide persona and are never touched here."]}),l&&e.jsxs("div",{"data-testid":"project-override-fullbody",className:"text-[11px] text-amber-400 leading-snug",children:[s,' already has a FULL-BODY override of this persona (its own definition text). It is shown as-is and not converted to a frontmatter-only overlay — edit that file directly, or drop it with × under "project overrides" below.']}),e.jsxs("fieldset",{disabled:r||l,className:"space-y-3 border-0 p-0 m-0 min-w-0",children:[e.jsx(ee,{value:i,onChange:u=>{l||d({model:u,effort:m})},label:"project model",hint:"'use global' writes no model: line in the overlay.",testIdPrefix:"override-",inheritLabel:"use global"}),e.jsx(te,{value:m,model:i!=="inherit"?i:S,onChange:u=>{l||d({model:i,effort:u})},label:"project effort",testIdPrefix:"override-",inheritLabel:"use global"})]}),e.jsx("div",{"data-testid":"override-provenance",className:"text-[11px] font-mono text-fg-dim space-y-0.5",children:[["model",S,i],["effort",h,m]].map(([u,b,j])=>e.jsxs("div",{"data-testid":`override-provenance-${u}`,children:[u,": ",j!=="inherit"?e.jsxs(e.Fragment,{children:[b," ",e.jsx("span",{className:"text-fg-faint",children:"(global)"})," → ",e.jsx("span",{className:"text-accent",children:j})," ",e.jsx("span",{className:"text-fg-faint",children:"(this project)"})]}):e.jsxs(e.Fragment,{children:[b," ",e.jsx("span",{className:"text-fg-faint",children:"(global — not overridden)"})]})]},u))})]})}export{Me as AgentLibrary};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{aw as d,i as j,ai as $,a1 as g,ah as e,m as N,al as E,a2 as b,aA as S,a as p,Y as T,j as v,h as D}from"./index-v_3LvhMx.js";import{P as R}from"./Panel-Cyt1wpUf.js";import{V}from"./ViewTabs-BHV3MA5u.js";import"./monaco-editor-BsIlgG7c.js";const C=[{key:"diagram",label:"Diagram"},{key:"tables",label:"Tables"}];function G(){const[s,t]=d.useState("diagram"),[a,i]=d.useState(null),[l,n]=d.useState(()=>new Set),c=d.useMemo(()=>j.filter(r=>!l.has(r.group)),[l]),m=d.useMemo(()=>$(c),[c]),o=r=>{n(x=>{const h=new Set(x);return h.has(r)?h.delete(r):h.add(r),h}),i(null)},u=a?g(a):null,y=r=>c.some(x=>x.id===r);return e.jsx(R,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(V,{options:C,active:s,onChange:t}),e.jsx(M,{hiddenGroups:l,onToggle:o}),e.jsxs("span",{className:"ml-auto text-fg-faint",children:[j.length," entities"]})]}),children:s==="diagram"?e.jsxs("div",{className:"h-full flex",children:[e.jsx("div",{className:"flex-1 min-w-0 overflow-auto",children:e.jsx(O,{layout:m,selectedId:a,onSelect:r=>i(x=>x===r?null:r)})}),e.jsx("div",{className:"w-96 shrink-0 border-l border-line overflow-y-auto",children:u?e.jsx(F,{entity:u,onSelectRelated:r=>y(r)?i(r):void 0}):e.jsx(N,{title:"select an entity",hint:"click a box in the diagram to see its storage, fields, and relations"})})]}):e.jsx(P,{})})}const X=d.memo(G);function M({hiddenGroups:s,onToggle:t}){return e.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:v.map(a=>{const i=s.has(a.id);return e.jsxs("button",{onClick:()=>t(a.id),title:`${a.blurb} (${a.realm})`,className:`flex items-center gap-1 px-1.5 py-0.5 rounded border text-[10.5px] ${i?"border-line text-fg-faint opacity-50":"border-line text-fg-dim hover:text-fg"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${a.tone.dot}`}),a.label,e.jsx("span",{className:"text-fg-faint",children:a.realm})]},a.id)})})}function O({layout:s,selectedId:t,onSelect:a}){const i=d.useMemo(()=>t?new Set(E(t)):null,[t]),l=n=>!!t&&(n.relation.from===t||n.relation.to===t);return s.boxes.length===0?e.jsx(N,{title:"no entities in view",hint:"toggle a group in the legend to show its entities"}):e.jsxs("div",{className:"relative p-4",style:{width:s.width+32,height:s.height+32},children:[e.jsxs("svg",{width:s.width,height:s.height,className:"absolute left-4 top-4 overflow-visible",children:[s.edges.map(n=>{const c=l(n);return e.jsx("path",{"data-testid":`erd-edge-${n.relation.from}-${n.relation.to}`,d:n.d,fill:"none",className:c?"stroke-accent":"stroke-line",strokeWidth:c?2:1,opacity:t&&!c?.25:1},`${n.relation.from}-${n.relation.to}-${n.relation.label}`)}),s.edges.map(n=>l(n)?e.jsx("text",{x:n.mx,y:n.my,textAnchor:"middle",className:"fill-fg-dim text-[10px]",children:n.relation.label},`label-${n.relation.from}-${n.relation.to}-${n.relation.label}`):null)]}),s.boxes.map(n=>e.jsx(_,{box:n,selected:n.id===t,dimmed:!!t&&n.id!==t&&!(i!=null&&i.has(n.id)),onClick:()=>a(n.id)},n.id))]})}function _({box:s,selected:t,dimmed:a,onClick:i}){const l=g(s.id),n=b(s.group),c=l.fields.slice(0,D),m=l.fields.length-c.length;return e.jsxs("button",{type:"button","data-testid":`erd-box-${s.id}`,onClick:i,className:`absolute text-left rounded border overflow-hidden bg-bg-hi ${t?"border-accent ring-1 ring-accent":"border-line"} ${a?"opacity-30":""}`,style:{left:s.x,top:s.y,width:s.w,height:s.h},children:[e.jsxs("div",{className:"px-2 py-1 border-b border-line flex items-center gap-1.5",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${n.tone.dot}`}),e.jsx("span",{className:"text-[11px] font-semibold text-fg truncate",children:l.name})]}),l.aka&&e.jsx("div",{className:"px-2 pt-0.5 text-[9.5px] text-fg-faint truncate",children:l.aka}),e.jsxs("div",{className:"px-2 py-0.5",children:[c.map(o=>e.jsxs("div",{className:"text-[9.5px] font-mono text-fg-dim truncate flex items-center gap-1",children:[o.key&&e.jsx("span",{className:"text-fg-faint",children:o.key}),e.jsx("span",{className:"truncate",children:o.name})]},o.name)),m>0&&e.jsxs("div",{className:"text-[9.5px] text-fg-faint italic",children:["+",m," more"]})]})]})}function w({fields:s}){return e.jsxs("table",{className:"w-full text-[11px] font-mono",children:[e.jsx("thead",{className:"text-fg-faint uppercase tracking-wide text-[9.5px]",children:e.jsxs("tr",{className:"border-b border-line",children:[e.jsx("th",{className:"text-left font-normal px-2 py-1",children:"name"}),e.jsx("th",{className:"text-left font-normal px-2 py-1",children:"type"}),e.jsx("th",{className:"text-left font-normal px-2 py-1",children:"key"}),e.jsx("th",{className:"text-left font-normal px-2 py-1",children:"note"})]})}),e.jsx("tbody",{children:s.map(t=>e.jsxs("tr",{className:"border-b border-line/50",children:[e.jsxs("td",{className:"px-2 py-1 text-fg",children:[t.name,t.optional&&e.jsx("span",{className:"text-fg-faint",children:"?"})]}),e.jsx("td",{className:"px-2 py-1 text-fg-dim",children:t.type}),e.jsx("td",{className:"px-2 py-1",children:t.key&&e.jsxs(p,{tone:t.key==="pk"?"accent":"dim",children:[t.key,t.ref?` → ${t.ref}`:""]})}),e.jsx("td",{className:"px-2 py-1 text-fg-faint",children:t.note})]},t.name))})]})}function k({entity:s}){return e.jsxs("div",{className:"space-y-1 text-[11px]",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-fg-faint w-20 shrink-0",children:"path"}),e.jsx("span",{className:"font-mono text-fg-dim break-all",children:s.store.path})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-fg-faint w-20 shrink-0",children:"format"}),e.jsx("span",{className:"font-mono text-fg-dim",children:s.store.format})]}),s.store.writer&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-fg-faint w-20 shrink-0",children:"writer"}),e.jsxs(p,{tone:"accent",children:["single-writer: ",s.store.writer]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-fg-faint w-20 shrink-0",children:"definedIn"}),e.jsx("span",{className:"font-mono text-fg-dim break-all",children:s.store.definedIn})]})]})}function F({entity:s,onSelectRelated:t}){const a=b(s.group),i=S(s.id);return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${a.tone.dot}`}),e.jsx("span",{className:"text-sm font-semibold text-fg",children:s.name})]}),s.aka&&e.jsx("div",{className:"text-[10.5px] text-fg-faint",children:s.aka}),e.jsx(p,{tone:"dim",className:"mt-1",children:a.label})]}),e.jsx("div",{className:"text-xs text-fg-dim leading-relaxed",children:s.summary}),e.jsxs("div",{children:[e.jsx(f,{children:"storage"}),e.jsx(k,{entity:s})]}),e.jsxs("div",{children:[e.jsx(f,{children:"fields"}),e.jsx(w,{fields:s.fields})]}),s.notes&&s.notes.length>0&&e.jsxs("div",{children:[e.jsx(f,{children:"notes"}),e.jsx("ul",{className:"list-disc pl-4 space-y-0.5 text-xs text-fg-dim",children:s.notes.map(l=>e.jsx("li",{children:l},l))})]}),e.jsxs("div",{children:[e.jsx(f,{children:"relations"}),i.length===0?e.jsx("div",{className:"text-xs text-fg-faint italic",children:"no relations"}):e.jsx("ul",{className:"space-y-1",children:i.map(l=>{const n=l.from===s.id?l.to:l.from,c=g(n);return e.jsxs("li",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx("span",{className:"font-mono text-fg-faint w-10 shrink-0",children:T(l.cardinality)}),e.jsx("span",{className:"text-fg-dim",children:l.label}),l.via&&e.jsxs("span",{className:"font-mono text-[10px] text-fg-faint",children:["via ",l.via]}),e.jsx("button",{type:"button",onClick:()=>t(n),className:"ml-auto text-accent hover:underline font-mono",children:c.name})]},`${l.from}-${l.to}-${l.label}`)})})]})]})}function f({children:s}){return e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1 font-mono",children:s})}function P(){return e.jsx("div",{className:"p-4 space-y-6",children:v.map(s=>{const t=j.filter(a=>a.group===s.id);return t.length===0?null:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${s.tone.dot}`}),e.jsx("span",{className:"text-xs font-semibold text-fg",children:s.label}),e.jsx("span",{className:"text-[10.5px] text-fg-faint",children:s.realm})]}),e.jsx("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-3",children:t.map(a=>e.jsxs("div",{className:"border border-line rounded bg-bg-hi p-3 space-y-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-fg",children:a.name}),a.aka&&e.jsx("span",{className:"text-[10.5px] text-fg-faint",children:a.aka})]}),e.jsx(p,{tone:"dim",className:"mt-1",children:s.label})]}),e.jsx("div",{className:"text-xs text-fg-dim leading-relaxed",children:a.summary}),e.jsx(k,{entity:a}),e.jsx(w,{fields:a.fields}),a.notes&&a.notes.length>0&&e.jsx("ul",{className:"list-disc pl-4 space-y-0.5 text-xs text-fg-dim",children:a.notes.map(i=>e.jsx("li",{children:i},i))})]},a.id))})]},s.id)})})}export{X as DataModel};
|