pulse-for-claude-code 0.1.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/LICENSE +21 -0
- package/README.md +292 -0
- package/bin/cli.js +169 -0
- package/bin/export.js +64 -0
- package/hooks/notify-hook.js +109 -0
- package/hooks/permission-hook.js +177 -0
- package/hooks/stop-hook.js +83 -0
- package/package.json +36 -0
- package/public/app.js +1024 -0
- package/public/assets/ClaudeCourchevel.png +0 -0
- package/public/assets/ClaudeCourchevelWork.png +0 -0
- package/public/assets/ClaudeGarage.png +0 -0
- package/public/assets/ClaudeGarageWork.png +0 -0
- package/public/assets/ClaudeOffice.png +0 -0
- package/public/assets/ClaudeOfficeWork.png +0 -0
- package/public/assets/ClaudeParis.png +0 -0
- package/public/assets/ClaudeParisWork.png +0 -0
- package/public/favicon.svg +5 -0
- package/public/index.html +216 -0
- package/public/manifest.webmanifest +11 -0
- package/public/style.css +577 -0
- package/src/approvals.js +77 -0
- package/src/config.js +83 -0
- package/src/daemon.js +148 -0
- package/src/engine.js +573 -0
- package/src/hooksetup.js +60 -0
- package/src/notify.js +56 -0
- package/src/ntfy.js +82 -0
- package/src/phonepage.js +81 -0
- package/src/search.js +45 -0
- package/src/server.js +322 -0
- package/src/snapshots.js +33 -0
- package/src/transcript.js +206 -0
package/public/style.css
ADDED
|
@@ -0,0 +1,577 @@
|
|
|
1
|
+
/* ===== Pulse for Claude Code ===== */
|
|
2
|
+
|
|
3
|
+
:root {
|
|
4
|
+
--accent: #d97757;
|
|
5
|
+
--accent-soft: rgba(217, 119, 87, 0.14);
|
|
6
|
+
--accent-line: rgba(217, 119, 87, 0.4);
|
|
7
|
+
--ok: #6a9a78;
|
|
8
|
+
--warn: #d9a157;
|
|
9
|
+
--danger: #cc6b5a;
|
|
10
|
+
--radius: 14px;
|
|
11
|
+
--maxw: 1120px;
|
|
12
|
+
--ease: cubic-bezier(0.22, 0.61, 0.36, 1);
|
|
13
|
+
--sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
|
14
|
+
--serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
html[data-theme="dark"] {
|
|
18
|
+
--bg: #1f1e1b;
|
|
19
|
+
--surface: #292824;
|
|
20
|
+
--surface-2: #322f2a;
|
|
21
|
+
--text: #eceae1;
|
|
22
|
+
--muted: #9a988e;
|
|
23
|
+
--faint: #6f6d64;
|
|
24
|
+
--hairline: rgba(255, 255, 255, 0.10);
|
|
25
|
+
--track: rgba(255, 255, 255, 0.08);
|
|
26
|
+
}
|
|
27
|
+
html[data-theme="light"] {
|
|
28
|
+
--bg: #faf9f5;
|
|
29
|
+
--surface: #ffffff;
|
|
30
|
+
--surface-2: #f4f2ec;
|
|
31
|
+
--text: #20201c;
|
|
32
|
+
--muted: #73726b;
|
|
33
|
+
--faint: #a3a199;
|
|
34
|
+
--hairline: rgba(20, 20, 15, 0.10);
|
|
35
|
+
--track: rgba(20, 20, 15, 0.07);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
* { box-sizing: border-box; }
|
|
39
|
+
/* the hidden attribute must always win, even over display:grid/flex below */
|
|
40
|
+
[hidden] { display: none !important; }
|
|
41
|
+
html, body { margin: 0; }
|
|
42
|
+
body {
|
|
43
|
+
font-family: var(--sans);
|
|
44
|
+
background: var(--bg);
|
|
45
|
+
color: var(--text);
|
|
46
|
+
line-height: 1.5;
|
|
47
|
+
-webkit-font-smoothing: antialiased;
|
|
48
|
+
font-size: 15px;
|
|
49
|
+
}
|
|
50
|
+
button { font-family: inherit; cursor: pointer; }
|
|
51
|
+
canvas { display: block; width: 100%; }
|
|
52
|
+
|
|
53
|
+
/* ===== Topbar ===== */
|
|
54
|
+
.topbar {
|
|
55
|
+
position: sticky;
|
|
56
|
+
top: 0;
|
|
57
|
+
z-index: 20;
|
|
58
|
+
display: flex;
|
|
59
|
+
align-items: center;
|
|
60
|
+
gap: 24px;
|
|
61
|
+
padding: 14px 24px;
|
|
62
|
+
background: color-mix(in srgb, var(--bg) 82%, transparent);
|
|
63
|
+
backdrop-filter: saturate(160%) blur(12px);
|
|
64
|
+
border-bottom: 1px solid var(--hairline);
|
|
65
|
+
}
|
|
66
|
+
.brand { display: flex; align-items: center; gap: 8px; }
|
|
67
|
+
.brand__mark { border-radius: 6px; }
|
|
68
|
+
.brand__name { font-weight: 600; letter-spacing: -0.01em; }
|
|
69
|
+
.brand__sub { color: var(--muted); font-size: 13px; }
|
|
70
|
+
|
|
71
|
+
.tabs { display: flex; gap: 2px; margin: 0 auto 0 12px; }
|
|
72
|
+
.tab {
|
|
73
|
+
border: 0;
|
|
74
|
+
background: transparent;
|
|
75
|
+
color: var(--muted);
|
|
76
|
+
font-size: 14px;
|
|
77
|
+
padding: 7px 13px;
|
|
78
|
+
border-radius: 9px;
|
|
79
|
+
transition: color .15s, background .15s;
|
|
80
|
+
}
|
|
81
|
+
.tab:hover { color: var(--text); }
|
|
82
|
+
.tab.is-active { color: var(--text); background: var(--surface-2); }
|
|
83
|
+
|
|
84
|
+
.topbar__right { display: flex; align-items: center; gap: 12px; }
|
|
85
|
+
.plan {
|
|
86
|
+
font-size: 12px;
|
|
87
|
+
color: var(--accent);
|
|
88
|
+
background: var(--accent-soft);
|
|
89
|
+
padding: 4px 9px;
|
|
90
|
+
border-radius: 7px;
|
|
91
|
+
text-transform: lowercase;
|
|
92
|
+
}
|
|
93
|
+
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
|
|
94
|
+
.live__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 var(--ok); animation: ping 2.4s ease-out infinite; }
|
|
95
|
+
.live.is-stale .live__dot { background: var(--faint); animation: none; }
|
|
96
|
+
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(106,154,120,.5);} 70%,100% { box-shadow: 0 0 0 6px rgba(106,154,120,0);} }
|
|
97
|
+
.icon-btn {
|
|
98
|
+
border: 1px solid var(--hairline);
|
|
99
|
+
background: var(--surface);
|
|
100
|
+
color: var(--text);
|
|
101
|
+
width: 32px; height: 32px;
|
|
102
|
+
border-radius: 9px;
|
|
103
|
+
font-size: 15px;
|
|
104
|
+
}
|
|
105
|
+
.ready { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
|
|
106
|
+
.ready__ring { transform: rotate(-90deg); }
|
|
107
|
+
.ready__bg { fill: none; stroke: var(--track); stroke-width: 3; }
|
|
108
|
+
.ready__fg {
|
|
109
|
+
fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round;
|
|
110
|
+
stroke-dasharray: 94.25; stroke-dashoffset: 94.25;
|
|
111
|
+
transition: stroke-dashoffset .6s var(--ease), stroke .3s var(--ease);
|
|
112
|
+
}
|
|
113
|
+
.ready__pct { font-variant-numeric: tabular-nums; min-width: 30px; }
|
|
114
|
+
.ready.is-done .ready__fg { stroke: var(--ok); }
|
|
115
|
+
.ready.is-done .ready__pct { color: var(--ok); }
|
|
116
|
+
body.office-mode .ready { color: #cfcdc3; }
|
|
117
|
+
|
|
118
|
+
.rank {
|
|
119
|
+
font-size: 12px;
|
|
120
|
+
font-weight: 500;
|
|
121
|
+
color: var(--accent);
|
|
122
|
+
background: var(--accent-soft);
|
|
123
|
+
padding: 5px 10px;
|
|
124
|
+
border-radius: 7px;
|
|
125
|
+
white-space: nowrap;
|
|
126
|
+
}
|
|
127
|
+
.plan-select {
|
|
128
|
+
appearance: none;
|
|
129
|
+
border: 1px solid var(--hairline);
|
|
130
|
+
background: var(--surface);
|
|
131
|
+
color: var(--text);
|
|
132
|
+
font: inherit;
|
|
133
|
+
font-size: 13px;
|
|
134
|
+
padding: 6px 10px;
|
|
135
|
+
border-radius: 8px;
|
|
136
|
+
cursor: pointer;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/* ===== Waiting banner ===== */
|
|
140
|
+
.waiting {
|
|
141
|
+
display: flex; align-items: center; gap: 12px;
|
|
142
|
+
max-width: var(--maxw); margin: 16px auto 0; padding: 14px 18px;
|
|
143
|
+
background: var(--accent-soft);
|
|
144
|
+
border: 1px solid var(--accent-line);
|
|
145
|
+
border-radius: var(--radius);
|
|
146
|
+
}
|
|
147
|
+
.waiting__pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: ping2 1.3s ease-out infinite; flex: none; }
|
|
148
|
+
@keyframes ping2 { 0% { box-shadow: 0 0 0 0 rgba(217,119,87,.6);} 70%,100% { box-shadow: 0 0 0 8px rgba(217,119,87,0);} }
|
|
149
|
+
.waiting__text { font-weight: 500; }
|
|
150
|
+
.waiting__meta { color: var(--muted); font-size: 13px; margin-left: auto; }
|
|
151
|
+
|
|
152
|
+
/* ===== Approvals (Allow / Allow all / Deny) ===== */
|
|
153
|
+
.approvals { max-width: var(--maxw); margin: 16px auto 0; padding: 0 24px; display: flex; flex-direction: column; gap: 10px; }
|
|
154
|
+
.appr {
|
|
155
|
+
display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
|
|
156
|
+
background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: 14px; padding: 14px 18px;
|
|
157
|
+
}
|
|
158
|
+
.appr__info { font-size: 14px; min-width: 0; }
|
|
159
|
+
.appr__tool { font-weight: 600; color: var(--accent); }
|
|
160
|
+
.appr__proj { color: var(--faint); font-size: 12px; }
|
|
161
|
+
.appr__sum { margin-top: 5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--muted); word-break: break-word; }
|
|
162
|
+
.appr__btns { display: flex; gap: 8px; flex: none; }
|
|
163
|
+
.abtn { border: 1px solid var(--hairline); background: var(--surface); color: var(--text); font: inherit; font-size: 13px; font-weight: 500; padding: 8px 14px; border-radius: 9px; cursor: pointer; transition: transform .15s var(--ease); }
|
|
164
|
+
.abtn:hover { transform: translateY(-1px); }
|
|
165
|
+
.abtn--allow { background: var(--accent); color: #fff; border-color: var(--accent); }
|
|
166
|
+
.abtn--all { color: var(--accent); border-color: var(--accent-line); }
|
|
167
|
+
.abtn--deny:hover { border-color: var(--danger); color: var(--danger); }
|
|
168
|
+
.office__now { color: var(--accent); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
|
|
169
|
+
|
|
170
|
+
/* the approval card pulses to catch your eye */
|
|
171
|
+
.appr { animation: apprpulse 1.7s ease-in-out infinite; }
|
|
172
|
+
@keyframes apprpulse {
|
|
173
|
+
0%, 100% { box-shadow: 0 0 0 0 rgba(217, 119, 87, 0); }
|
|
174
|
+
50% { box-shadow: 0 0 0 5px rgba(217, 119, 87, 0.18); }
|
|
175
|
+
}
|
|
176
|
+
body.office-mode .appr { padding: 18px 22px; font-size: 15px; }
|
|
177
|
+
body.office-mode .abtn { padding: 12px 20px; font-size: 15px; }
|
|
178
|
+
|
|
179
|
+
/* ===== Layout ===== */
|
|
180
|
+
.main { max-width: var(--maxw); margin: 0 auto; padding: 22px 24px 40px; }
|
|
181
|
+
.panel { display: none; }
|
|
182
|
+
.panel.is-active { display: block; animation: fade .25s ease; }
|
|
183
|
+
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none; } }
|
|
184
|
+
|
|
185
|
+
.card {
|
|
186
|
+
background: var(--surface);
|
|
187
|
+
border: 1px solid var(--hairline);
|
|
188
|
+
border-radius: var(--radius);
|
|
189
|
+
padding: 18px 20px;
|
|
190
|
+
margin-bottom: 16px;
|
|
191
|
+
}
|
|
192
|
+
.card__head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
|
|
193
|
+
.card__title { font-weight: 500; }
|
|
194
|
+
.card__hint { color: var(--muted); font-size: 13px; }
|
|
195
|
+
.card--active { min-height: 150px; }
|
|
196
|
+
.chart { cursor: crosshair; }
|
|
197
|
+
|
|
198
|
+
/* segmented period control */
|
|
199
|
+
.seg { display: inline-flex; gap: 2px; background: var(--surface-2); padding: 2px; border-radius: 8px; }
|
|
200
|
+
.seg button { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 12px; padding: 4px 10px; border-radius: 6px; cursor: pointer; }
|
|
201
|
+
.seg button:hover { color: var(--text); }
|
|
202
|
+
.seg button.is-on { background: var(--surface); color: var(--text); }
|
|
203
|
+
|
|
204
|
+
/* hover tooltip for charts */
|
|
205
|
+
.tip {
|
|
206
|
+
position: fixed; z-index: 200; pointer-events: none;
|
|
207
|
+
background: var(--surface); border: 1px solid var(--hairline);
|
|
208
|
+
border-radius: 8px; padding: 7px 10px; font-size: 12px;
|
|
209
|
+
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
|
|
210
|
+
}
|
|
211
|
+
.tip__label { color: var(--muted); }
|
|
212
|
+
.tip__val { color: var(--text); font-variant-numeric: tabular-nums; margin-top: 2px; }
|
|
213
|
+
|
|
214
|
+
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
|
|
215
|
+
.ov-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
|
|
216
|
+
|
|
217
|
+
/* ===== Stat cards ===== */
|
|
218
|
+
.stat {
|
|
219
|
+
background: var(--surface);
|
|
220
|
+
border: 1px solid var(--hairline);
|
|
221
|
+
border-radius: var(--radius);
|
|
222
|
+
padding: 16px 18px;
|
|
223
|
+
}
|
|
224
|
+
.stat__label { color: var(--muted); font-size: 13px; }
|
|
225
|
+
.stat__value { font-family: var(--serif); font-size: 34px; line-height: 1.1; margin-top: 8px; letter-spacing: -0.01em; }
|
|
226
|
+
.stat__value small { font-size: 17px; color: var(--muted); font-family: var(--sans); }
|
|
227
|
+
.stat__sub { color: var(--muted); font-size: 13px; margin-top: 6px; }
|
|
228
|
+
.stat__bar { margin-top: 12px; }
|
|
229
|
+
|
|
230
|
+
/* ===== Bars ===== */
|
|
231
|
+
.bar { height: 8px; background: var(--track); border-radius: 6px; overflow: hidden; }
|
|
232
|
+
.bar__fill { height: 100%; background: var(--accent); border-radius: 6px; transition: width .4s ease; }
|
|
233
|
+
.bar__fill.is-ok { background: var(--ok); }
|
|
234
|
+
.bar__fill.is-warn { background: var(--warn); }
|
|
235
|
+
.bar__fill.is-danger { background: var(--danger); }
|
|
236
|
+
|
|
237
|
+
/* per-session context rows */
|
|
238
|
+
.ctxrow { margin: 15px 0; }
|
|
239
|
+
.ctxrow__top { display: flex; justify-content: space-between; gap: 14px; align-items: center; font-size: 14px; margin-bottom: 7px; }
|
|
240
|
+
.ctxrow__name { display: flex; align-items: center; gap: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
241
|
+
.ctxrow__name small { color: var(--muted); }
|
|
242
|
+
.ctxrow__val { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|
243
|
+
|
|
244
|
+
.num { cursor: pointer; border-bottom: 1px dotted var(--faint); }
|
|
245
|
+
.num:hover { color: var(--accent); border-bottom-color: var(--accent-line); }
|
|
246
|
+
|
|
247
|
+
.limitrow { margin: 16px 0; }
|
|
248
|
+
.limitrow__top { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 7px; }
|
|
249
|
+
.limitrow__name { color: var(--text); }
|
|
250
|
+
.limitrow__reset { margin-top: 6px; font-size: 12px; color: var(--faint); }
|
|
251
|
+
.limitrow__val { color: var(--muted); }
|
|
252
|
+
.limitrow__val b { color: var(--text); font-weight: 500; }
|
|
253
|
+
|
|
254
|
+
/* ===== Active session ===== */
|
|
255
|
+
.act__title { font-weight: 500; font-size: 16px; margin-bottom: 4px; }
|
|
256
|
+
.act__row { display: flex; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin-top: 8px; }
|
|
257
|
+
.chip { background: var(--surface-2); padding: 3px 9px; border-radius: 7px; font-size: 12px; color: var(--muted); }
|
|
258
|
+
.chip--accent { background: var(--accent-soft); color: var(--accent); }
|
|
259
|
+
.act__prompt { margin-top: 12px; color: var(--muted); font-size: 13px; border-left: 2px solid var(--hairline); padding-left: 12px; }
|
|
260
|
+
|
|
261
|
+
/* ===== Tables / lists ===== */
|
|
262
|
+
.table { width: 100%; }
|
|
263
|
+
.trow {
|
|
264
|
+
display: grid;
|
|
265
|
+
grid-template-columns: 16px 1fr 110px 90px 90px 90px;
|
|
266
|
+
gap: 12px;
|
|
267
|
+
align-items: center;
|
|
268
|
+
padding: 11px 4px;
|
|
269
|
+
border-top: 1px solid var(--hairline);
|
|
270
|
+
font-size: 14px;
|
|
271
|
+
}
|
|
272
|
+
.trow:first-child { border-top: 0; }
|
|
273
|
+
.trow__title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
274
|
+
.trow__title small { color: var(--muted); }
|
|
275
|
+
.trow__num { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
|
|
276
|
+
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
|
|
277
|
+
.dot.is-on { background: var(--ok); }
|
|
278
|
+
|
|
279
|
+
/* breakdown list */
|
|
280
|
+
.brk { margin: 10px 0; }
|
|
281
|
+
.brk__top { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
|
|
282
|
+
.brk__name { text-transform: capitalize; }
|
|
283
|
+
.brk__val { color: var(--muted); font-variant-numeric: tabular-nums; }
|
|
284
|
+
|
|
285
|
+
/* composition */
|
|
286
|
+
.comp { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
|
|
287
|
+
.comp__item { text-align: left; }
|
|
288
|
+
.comp__k { color: var(--muted); font-size: 13px; }
|
|
289
|
+
.comp__v { font-family: var(--serif); font-size: 22px; margin-top: 4px; }
|
|
290
|
+
|
|
291
|
+
/* ===== Activity feed ===== */
|
|
292
|
+
.feed { display: flex; flex-direction: column; }
|
|
293
|
+
.fitem { display: grid; grid-template-columns: 70px 88px 1fr 110px; gap: 12px; align-items: center; padding: 9px 2px; border-top: 1px solid var(--hairline); font-size: 13px; }
|
|
294
|
+
.fitem:first-child { border-top: 0; }
|
|
295
|
+
.fitem__time { color: var(--faint); font-variant-numeric: tabular-nums; }
|
|
296
|
+
.ftag { font-size: 12px; color: var(--accent); background: var(--accent-soft); padding: 2px 8px; border-radius: 6px; text-align: center; }
|
|
297
|
+
.fitem__hint { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
|
|
298
|
+
.fitem__proj { color: var(--faint); text-align: right; }
|
|
299
|
+
|
|
300
|
+
/* ===== focusable metrics + focus overlay ===== */
|
|
301
|
+
[data-focus] { cursor: zoom-in; }
|
|
302
|
+
.focus {
|
|
303
|
+
position: fixed; inset: 0; z-index: 100;
|
|
304
|
+
display: grid; place-items: center;
|
|
305
|
+
background: color-mix(in srgb, var(--bg) 55%, transparent);
|
|
306
|
+
backdrop-filter: blur(14px) saturate(120%);
|
|
307
|
+
-webkit-backdrop-filter: blur(14px) saturate(120%);
|
|
308
|
+
animation: fade .2s ease;
|
|
309
|
+
}
|
|
310
|
+
.focus__card { text-align: center; padding: 40px; }
|
|
311
|
+
.focus__label { color: var(--muted); font-size: 16px; letter-spacing: .02em; }
|
|
312
|
+
.focus__value {
|
|
313
|
+
font-family: var(--serif);
|
|
314
|
+
font-size: clamp(48px, 11vw, 132px);
|
|
315
|
+
line-height: 1.02; letter-spacing: -0.02em;
|
|
316
|
+
margin: 12px 0 6px; font-variant-numeric: tabular-nums;
|
|
317
|
+
}
|
|
318
|
+
.focus__sub { color: var(--muted); font-size: 16px; }
|
|
319
|
+
.focus__hint { color: var(--faint); font-size: 12px; margin-top: 28px; }
|
|
320
|
+
|
|
321
|
+
/* ===== clickable rows ===== */
|
|
322
|
+
.trow--link, .ctxrow--link { cursor: pointer; border-radius: 8px; }
|
|
323
|
+
.trow--link:hover { background: var(--surface-2); }
|
|
324
|
+
.ctxrow--link:hover .ctxrow__name { color: var(--accent); }
|
|
325
|
+
|
|
326
|
+
/* ===== session detail ===== */
|
|
327
|
+
.back {
|
|
328
|
+
border: 1px solid var(--hairline);
|
|
329
|
+
background: var(--surface);
|
|
330
|
+
color: var(--muted);
|
|
331
|
+
font: inherit; font-size: 13px;
|
|
332
|
+
padding: 7px 13px; border-radius: 9px; margin-bottom: 16px;
|
|
333
|
+
}
|
|
334
|
+
.back:hover { color: var(--text); }
|
|
335
|
+
.sdetail__title { font-family: var(--serif); font-size: 26px; letter-spacing: -0.01em; line-height: 1.15; }
|
|
336
|
+
|
|
337
|
+
.turns { display: flex; flex-direction: column; gap: 12px; }
|
|
338
|
+
.turn {
|
|
339
|
+
background: var(--surface);
|
|
340
|
+
border: 1px solid var(--hairline);
|
|
341
|
+
border-radius: var(--radius);
|
|
342
|
+
padding: 16px 18px;
|
|
343
|
+
}
|
|
344
|
+
.turn__head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
|
|
345
|
+
.turn__idx { font-weight: 500; color: var(--accent); font-variant-numeric: tabular-nums; }
|
|
346
|
+
.turn__meta { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
|
|
347
|
+
.turn__prompt {
|
|
348
|
+
font-size: 15px;
|
|
349
|
+
border-left: 2px solid var(--accent-line);
|
|
350
|
+
padding-left: 12px;
|
|
351
|
+
margin-bottom: 12px;
|
|
352
|
+
white-space: pre-wrap;
|
|
353
|
+
word-break: break-word;
|
|
354
|
+
}
|
|
355
|
+
.turn__actions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
|
|
356
|
+
.saction { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; }
|
|
357
|
+
.saction__hint {
|
|
358
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
359
|
+
font-size: 11px; color: var(--muted);
|
|
360
|
+
overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 340px;
|
|
361
|
+
}
|
|
362
|
+
.turn__text { color: var(--muted); font-size: 14px; white-space: pre-wrap; word-break: break-word; }
|
|
363
|
+
|
|
364
|
+
.note { color: var(--faint); font-size: 12px; margin: 14px 0 0; }
|
|
365
|
+
.empty { color: var(--muted); font-size: 14px; padding: 20px 0; text-align: center; }
|
|
366
|
+
|
|
367
|
+
/* search across sessions */
|
|
368
|
+
.search {
|
|
369
|
+
width: 100%; margin: 4px 0 12px; padding: 10px 12px;
|
|
370
|
+
background: var(--surface-2); border: 1px solid var(--accent-line);
|
|
371
|
+
border-radius: 9px; color: var(--text); font-size: 14px; outline: none;
|
|
372
|
+
}
|
|
373
|
+
.search::placeholder { color: var(--muted); }
|
|
374
|
+
.search:focus { border-color: var(--accent); }
|
|
375
|
+
.sr { padding: 11px 10px; border-top: 1px solid var(--surface-2); cursor: pointer; border-radius: 8px; }
|
|
376
|
+
.sr:hover { background: var(--surface-2); }
|
|
377
|
+
.sr__top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
|
|
378
|
+
.sr__title { color: var(--text); font-size: 14px; }
|
|
379
|
+
.sr__title small { color: var(--muted); }
|
|
380
|
+
.sr__count { color: var(--accent); font-size: 12px; white-space: nowrap; }
|
|
381
|
+
.sr__snip { color: var(--muted); font-size: 13px; margin-top: 4px; line-height: 1.45; }
|
|
382
|
+
.sr__who { color: var(--accent); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
|
|
383
|
+
.sr mark, .sr__snip mark { background: var(--accent-soft); color: var(--accent); border-radius: 3px; padding: 0 2px; }
|
|
384
|
+
.search-row { display: flex; gap: 8px; align-items: center; }
|
|
385
|
+
.search-row .search { flex: 1; }
|
|
386
|
+
.search-project {
|
|
387
|
+
padding: 9px 10px; background: var(--surface-2); border: 1px solid var(--accent-line);
|
|
388
|
+
border-radius: 9px; color: var(--text); font-size: 13px; margin: 4px 0 12px;
|
|
389
|
+
}
|
|
390
|
+
.card__action { margin-left: auto; color: var(--accent); text-decoration: none; font-size: 12px; }
|
|
391
|
+
.card__action:hover { text-decoration: underline; }
|
|
392
|
+
|
|
393
|
+
.foot a { color: var(--accent); text-decoration: none; }
|
|
394
|
+
|
|
395
|
+
/* ===== Footer ===== */
|
|
396
|
+
.foot { max-width: var(--maxw); margin: 0 auto; padding: 18px 24px 30px; color: var(--faint); font-size: 12px; display: flex; gap: 10px; }
|
|
397
|
+
.foot__sep { opacity: .5; }
|
|
398
|
+
|
|
399
|
+
/* ===== Office / crab scene ===== */
|
|
400
|
+
.office { display: flex; flex-direction: column; align-items: center; padding: 16px 0 40px; }
|
|
401
|
+
.office__scene { width: 100%; max-width: 560px; }
|
|
402
|
+
.scene-svg { width: 100%; height: auto; display: block; }
|
|
403
|
+
|
|
404
|
+
.room-window { fill: var(--accent-soft); stroke: var(--hairline); stroke-width: 2; }
|
|
405
|
+
.room-line { stroke: var(--hairline); stroke-width: 2; }
|
|
406
|
+
.desk { fill: var(--surface-2); }
|
|
407
|
+
.body { fill: var(--accent); }
|
|
408
|
+
.leg, .arm { fill: none; stroke: var(--accent); stroke-width: 7; stroke-linecap: round; }
|
|
409
|
+
.claw-shape { fill: var(--accent); }
|
|
410
|
+
.stalk { stroke: var(--accent); stroke-width: 5; stroke-linecap: round; }
|
|
411
|
+
.eye-white { fill: #fff; stroke: rgba(0, 0, 0, 0.08); stroke-width: 1; }
|
|
412
|
+
.pupil { fill: #1a1a17; transition: transform .5s var(--ease); }
|
|
413
|
+
.mouth { fill: none; stroke: rgba(0, 0, 0, 0.32); stroke-width: 3; stroke-linecap: round; }
|
|
414
|
+
.laptop-base { fill: var(--surface-2); stroke: var(--hairline); stroke-width: 1; }
|
|
415
|
+
.screen { fill: #201f1b; }
|
|
416
|
+
.code-line { stroke: var(--accent); stroke-width: 4; stroke-linecap: round; opacity: .5; }
|
|
417
|
+
|
|
418
|
+
#crab, .claw-l, .claw-r { transform-box: fill-box; transform-origin: center; }
|
|
419
|
+
#crab { transition: transform .5s var(--ease); }
|
|
420
|
+
|
|
421
|
+
.bubble { opacity: 0; transition: opacity .4s var(--ease); }
|
|
422
|
+
.bubble-bg { fill: var(--surface); stroke: var(--accent-line); stroke-width: 2; }
|
|
423
|
+
.bubble-mark { fill: var(--accent); font-size: 26px; font-weight: 600; font-family: var(--sans); }
|
|
424
|
+
.check { fill: none; stroke: var(--ok); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
|
|
425
|
+
.dot { fill: var(--accent); }
|
|
426
|
+
|
|
427
|
+
#crab-scene.is-thinking #crab, #crab-scene.is-working #crab, #crab-scene.is-idle #crab { animation: bob 3.6s ease-in-out infinite; }
|
|
428
|
+
#crab-scene.is-working .pupil, #crab-scene.is-thinking .pupil { transform: translateY(5px); }
|
|
429
|
+
#crab-scene.is-waiting .pupil, #crab-scene.is-idle .pupil { transform: translateY(0); }
|
|
430
|
+
#crab-scene.is-waiting #crab { animation: lookbob 1.1s ease-in-out infinite; }
|
|
431
|
+
#crab-scene.is-done #crab { animation: happy 1.7s ease-in-out infinite; }
|
|
432
|
+
|
|
433
|
+
#crab-scene.is-thinking .bubble-think, #crab-scene.is-working .bubble-think { opacity: 1; }
|
|
434
|
+
#crab-scene.is-waiting .bubble-wait { opacity: 1; }
|
|
435
|
+
#crab-scene.is-done .bubble-done { opacity: 1; }
|
|
436
|
+
|
|
437
|
+
#crab-scene.is-working .claw-l { animation: tap .5s ease-in-out infinite; }
|
|
438
|
+
#crab-scene.is-working .claw-r { animation: tap .5s ease-in-out infinite .25s; }
|
|
439
|
+
#crab-scene.is-working .code-line { animation: codeblink 1.4s steps(1, end) infinite; }
|
|
440
|
+
#crab-scene.is-working .c2 { animation-delay: .35s; }
|
|
441
|
+
#crab-scene.is-working .c3 { animation-delay: .7s; }
|
|
442
|
+
.bubble-think .d1 { animation: dotp 1.2s ease-in-out infinite; }
|
|
443
|
+
.bubble-think .d2 { animation: dotp 1.2s ease-in-out infinite .2s; }
|
|
444
|
+
.bubble-think .d3 { animation: dotp 1.2s ease-in-out infinite .4s; }
|
|
445
|
+
|
|
446
|
+
@keyframes bob { 0%,100% { transform: translateY(0);} 50% { transform: translateY(-6px);} }
|
|
447
|
+
@keyframes lookbob { 0%,100% { transform: translateY(0) scale(1.03);} 50% { transform: translateY(-4px) scale(1.03);} }
|
|
448
|
+
@keyframes happy { 0%,100% { transform: rotate(-2.5deg);} 50% { transform: rotate(2.5deg);} }
|
|
449
|
+
@keyframes tap { 0%,100% { transform: rotate(0);} 50% { transform: rotate(-13deg);} }
|
|
450
|
+
@keyframes codeblink { 0%,45% { opacity:.45;} 50%,100% { opacity:.9;} }
|
|
451
|
+
@keyframes dotp { 0%,100% { opacity:.3;} 50% { opacity:1;} }
|
|
452
|
+
|
|
453
|
+
.office__status { text-align: center; margin-top: 4px; }
|
|
454
|
+
.office__state { font-family: var(--serif); font-size: 30px; letter-spacing: -0.01em; }
|
|
455
|
+
.appr-toggle { border: 1px solid var(--hairline); background: var(--surface); color: var(--muted); font: inherit; font-size: 12px; padding: 6px 10px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
|
|
456
|
+
.appr-toggle.is-on { color: #fff; background: var(--accent); border-color: var(--accent); }
|
|
457
|
+
.appr-toggle.is-allowall { color: #1c1b19; background: #d9a154; border-color: #d9a154; }
|
|
458
|
+
.office__eta { font-size: 16px; color: var(--accent); margin-top: 8px; min-height: 20px; }
|
|
459
|
+
.office__sub { font-size: 13px; color: var(--muted); margin-top: 6px; }
|
|
460
|
+
|
|
461
|
+
/* ===== Office scene (image-based, with ambient life) ===== */
|
|
462
|
+
.office__bar { margin-bottom: 14px; }
|
|
463
|
+
.scene {
|
|
464
|
+
position: relative;
|
|
465
|
+
width: 100%;
|
|
466
|
+
max-width: 980px;
|
|
467
|
+
border-radius: var(--radius);
|
|
468
|
+
overflow: hidden;
|
|
469
|
+
border: 1px solid var(--hairline);
|
|
470
|
+
background: #0d0d0c;
|
|
471
|
+
line-height: 0;
|
|
472
|
+
}
|
|
473
|
+
.scene__img { width: 100%; display: block; }
|
|
474
|
+
|
|
475
|
+
/* twinkling city / window lights */
|
|
476
|
+
.scene__lights { position: absolute; inset: 0; pointer-events: none; }
|
|
477
|
+
.scene__lights i {
|
|
478
|
+
position: absolute; width: 3px; height: 3px; border-radius: 1px;
|
|
479
|
+
opacity: 0; animation: twinkle 3.4s ease-in-out infinite;
|
|
480
|
+
}
|
|
481
|
+
@keyframes twinkle { 0%, 100% { opacity: 0; } 50% { opacity: 0.85; } }
|
|
482
|
+
|
|
483
|
+
/* coffee steam (only while working) */
|
|
484
|
+
.scene__steam { position: absolute; width: 0; height: 0; pointer-events: none; opacity: 0; transition: opacity .5s var(--ease); }
|
|
485
|
+
.scene.is-working .scene__steam { opacity: 1; }
|
|
486
|
+
.scene__steam i {
|
|
487
|
+
position: absolute; bottom: 0; left: 0; width: 5px; height: 5px; border-radius: 50%;
|
|
488
|
+
background: rgba(255, 255, 255, 0.55); animation: steam 3.2s ease-in infinite;
|
|
489
|
+
}
|
|
490
|
+
.scene__steam i:nth-child(2) { left: 9px; animation-delay: 1.1s; }
|
|
491
|
+
.scene__steam i:nth-child(3) { left: -7px; animation-delay: 2.1s; }
|
|
492
|
+
@keyframes steam {
|
|
493
|
+
0% { transform: translateY(0) scale(.7); opacity: 0; }
|
|
494
|
+
25% { opacity: .55; }
|
|
495
|
+
100% { transform: translateY(-38px) scale(1.5); opacity: 0; }
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/* status bubble over the maskot */
|
|
499
|
+
.scene__bubble {
|
|
500
|
+
position: absolute; left: 52%; top: 34%; transform: translate(-50%, -50%);
|
|
501
|
+
min-width: 46px; height: 46px; padding: 0 8px; border-radius: 24px;
|
|
502
|
+
display: grid; place-items: center;
|
|
503
|
+
background: var(--surface); border: 2px solid var(--accent-line);
|
|
504
|
+
font-size: 24px; font-weight: 600; color: var(--accent);
|
|
505
|
+
animation: pop .3s var(--ease);
|
|
506
|
+
}
|
|
507
|
+
.scene__bubble.is-done { color: var(--ok); border-color: var(--ok); }
|
|
508
|
+
.scene__bubble.is-error { color: var(--danger); border-color: var(--danger); }
|
|
509
|
+
@keyframes pop { from { transform: translate(-50%, -50%) scale(.5); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }
|
|
510
|
+
|
|
511
|
+
/* done overlay: blur everything, say what got done */
|
|
512
|
+
.done-ov {
|
|
513
|
+
position: fixed; inset: 0; z-index: 120;
|
|
514
|
+
display: grid; place-items: center;
|
|
515
|
+
background: color-mix(in srgb, #000 55%, transparent);
|
|
516
|
+
backdrop-filter: blur(16px) saturate(120%);
|
|
517
|
+
-webkit-backdrop-filter: blur(16px) saturate(120%);
|
|
518
|
+
animation: fade .25s var(--ease);
|
|
519
|
+
cursor: pointer;
|
|
520
|
+
}
|
|
521
|
+
.done-ov__card { text-align: center; max-width: 620px; padding: 40px; }
|
|
522
|
+
.done-ov__phrase { font-family: var(--serif); font-size: clamp(40px, 8vw, 84px); color: var(--ok); letter-spacing: -0.02em; }
|
|
523
|
+
.done-ov__did { margin-top: 20px; color: #e9e7dd; }
|
|
524
|
+
.done__acts { font-size: 14px; color: var(--accent); font-variant-numeric: tabular-nums; }
|
|
525
|
+
.done__text { margin-top: 12px; font-size: 15px; color: #c4c2b8; line-height: 1.5; }
|
|
526
|
+
.done-ov__hint { margin-top: 28px; font-size: 12px; color: #7f7d74; }
|
|
527
|
+
|
|
528
|
+
/* ===== immersive office: the whole app goes black, scene fills the screen ===== */
|
|
529
|
+
.vibe-seg { display: none; }
|
|
530
|
+
.office__info { display: none; }
|
|
531
|
+
body.office-mode { background: #000; overflow: hidden; }
|
|
532
|
+
body.office-mode .tabs { display: none; }
|
|
533
|
+
body.office-mode .vibe-seg { display: inline-flex; }
|
|
534
|
+
body.office-mode .office__info {
|
|
535
|
+
display: block; position: absolute; top: 16px; left: 22px; z-index: 5;
|
|
536
|
+
font-size: 13px; color: #b7b5ab; font-variant-numeric: tabular-nums;
|
|
537
|
+
}
|
|
538
|
+
body.office-mode .topbar {
|
|
539
|
+
background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none;
|
|
540
|
+
border-bottom-color: transparent;
|
|
541
|
+
}
|
|
542
|
+
body.office-mode .brand__name, body.office-mode .brand__sub, body.office-mode .tab { color: #e9e7dd; }
|
|
543
|
+
body.office-mode .tab:hover { color: #fff; }
|
|
544
|
+
body.office-mode .tab.is-active { background: rgba(255, 255, 255, 0.12); color: #fff; }
|
|
545
|
+
body.office-mode .foot { display: none; }
|
|
546
|
+
body.office-mode .main { max-width: none; padding: 0; }
|
|
547
|
+
body.office-mode .office {
|
|
548
|
+
position: relative;
|
|
549
|
+
padding: 0;
|
|
550
|
+
min-height: calc(100vh - 64px);
|
|
551
|
+
justify-content: center;
|
|
552
|
+
}
|
|
553
|
+
body.office-mode .scene { width: auto; max-width: 100%; margin: 0 auto; border: 0; border-radius: 0; background: #000; }
|
|
554
|
+
body.office-mode .scene__img { width: auto; max-width: 100%; max-height: calc(100vh - 172px); }
|
|
555
|
+
body.office-mode .office__status { position: fixed; bottom: 22px; left: 0; right: 0; z-index: 6; }
|
|
556
|
+
body.office-mode .approvals { position: fixed; left: 50%; transform: translateX(-50%); bottom: 92px; z-index: 8; width: min(680px, 92vw); margin: 0; padding: 0; }
|
|
557
|
+
body.office-mode .office__state { color: #f2efe6; }
|
|
558
|
+
body.office-mode .office__sub { color: #b7b5ab; }
|
|
559
|
+
|
|
560
|
+
/* ===== smoothness pass: ease colour, border and lift changes everywhere ===== */
|
|
561
|
+
.card, .stat, .turn, .trow--link, .tab, .icon-btn, .plan-select, .seg button {
|
|
562
|
+
transition: background-color .25s var(--ease), border-color .25s var(--ease), color .2s var(--ease), transform .2s var(--ease);
|
|
563
|
+
}
|
|
564
|
+
.stat[data-focus]:hover, .limitrow[data-focus]:hover { transform: translateY(-2px); }
|
|
565
|
+
|
|
566
|
+
/* ===== Responsive ===== */
|
|
567
|
+
@media (max-width: 900px) {
|
|
568
|
+
.cards { grid-template-columns: repeat(2, 1fr); }
|
|
569
|
+
.ov-grid { grid-template-columns: 1fr; }
|
|
570
|
+
.tabs { order: 3; width: 100%; margin: 8px 0 0; overflow-x: auto; }
|
|
571
|
+
.topbar { flex-wrap: wrap; }
|
|
572
|
+
.trow { grid-template-columns: 14px 1fr 70px 70px; }
|
|
573
|
+
.trow__model, .trow__cost { display: none; }
|
|
574
|
+
.comp { grid-template-columns: repeat(2, 1fr); }
|
|
575
|
+
.fitem { grid-template-columns: 56px 80px 1fr; }
|
|
576
|
+
.fitem__proj { display: none; }
|
|
577
|
+
}
|
package/src/approvals.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Shared state between the PreToolUse hook and the dashboard, all on local disk.
|
|
4
|
+
// alive - server heartbeat; the hook refuses to block if it is stale
|
|
5
|
+
// pending/<id> - a tool waiting for your decision
|
|
6
|
+
// decisions/<id> - your answer, written by the dashboard
|
|
7
|
+
// rules.json - standing auto allow rules (allow all / per tool)
|
|
8
|
+
// token - shared secret for approving from another device on the LAN
|
|
9
|
+
|
|
10
|
+
const fs = require('fs');
|
|
11
|
+
const path = require('path');
|
|
12
|
+
const os = require('os');
|
|
13
|
+
|
|
14
|
+
const DIR = path.join(os.homedir(), '.claude-pulse');
|
|
15
|
+
const PENDING = path.join(DIR, 'pending');
|
|
16
|
+
const DECISIONS = path.join(DIR, 'decisions');
|
|
17
|
+
const RULES = path.join(DIR, 'rules.json');
|
|
18
|
+
const ALIVE = path.join(DIR, 'alive');
|
|
19
|
+
const TOKEN = path.join(DIR, 'token');
|
|
20
|
+
|
|
21
|
+
function ensure() {
|
|
22
|
+
for (const d of [DIR, PENDING, DECISIONS]) { try { fs.mkdirSync(d, { recursive: true }); } catch (e) {} }
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function heartbeat() { ensure(); try { fs.writeFileSync(ALIVE, String(Date.now())); } catch (e) {} }
|
|
26
|
+
function isAlive(maxAgeMs) {
|
|
27
|
+
try { return Date.now() - (parseInt(fs.readFileSync(ALIVE, 'utf8'), 10) || 0) < (maxAgeMs || 10000); }
|
|
28
|
+
catch (e) { return false; }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function readPending() {
|
|
32
|
+
ensure();
|
|
33
|
+
let files = [];
|
|
34
|
+
try { files = fs.readdirSync(PENDING); } catch (e) {}
|
|
35
|
+
const out = [];
|
|
36
|
+
for (const f of files) {
|
|
37
|
+
if (!f.endsWith('.json')) continue;
|
|
38
|
+
try { out.push(JSON.parse(fs.readFileSync(path.join(PENDING, f), 'utf8'))); } catch (e) {}
|
|
39
|
+
}
|
|
40
|
+
// drop stale requests (hook gone) older than 5 min
|
|
41
|
+
const now = Date.now();
|
|
42
|
+
const fresh = out.filter(r => r.time && now - r.time < 5 * 60 * 1000);
|
|
43
|
+
out.sort((a, b) => (a.time || 0) - (b.time || 0));
|
|
44
|
+
return fresh.sort((a, b) => (a.time || 0) - (b.time || 0));
|
|
45
|
+
}
|
|
46
|
+
function writePending(req) { ensure(); try { fs.writeFileSync(path.join(PENDING, req.id + '.json'), JSON.stringify(req)); } catch (e) {} }
|
|
47
|
+
function removePending(id) { try { fs.unlinkSync(path.join(PENDING, id + '.json')); } catch (e) {} }
|
|
48
|
+
|
|
49
|
+
function writeDecision(id, decision) { ensure(); try { fs.writeFileSync(path.join(DECISIONS, id + '.json'), JSON.stringify(decision)); } catch (e) {} }
|
|
50
|
+
function readDecision(id) { try { return JSON.parse(fs.readFileSync(path.join(DECISIONS, id + '.json'), 'utf8')); } catch (e) { return null; } }
|
|
51
|
+
function removeDecision(id) { try { fs.unlinkSync(path.join(DECISIONS, id + '.json')); } catch (e) {} }
|
|
52
|
+
|
|
53
|
+
function readRules() {
|
|
54
|
+
try {
|
|
55
|
+
const r = JSON.parse(fs.readFileSync(RULES, 'utf8'));
|
|
56
|
+
if (typeof r.enabled !== 'boolean') r.enabled = false; // remote approvals are opt-in
|
|
57
|
+
if (typeof r.paused !== 'boolean') r.paused = false; // pause is independent of approvals
|
|
58
|
+
return r;
|
|
59
|
+
} catch (e) { return { enabled: false, allowAll: false, allowTools: [], denyTools: [], paused: false }; }
|
|
60
|
+
}
|
|
61
|
+
function writeRules(r) { ensure(); try { fs.writeFileSync(RULES, JSON.stringify(r, null, 2)); } catch (e) {} }
|
|
62
|
+
|
|
63
|
+
function token() {
|
|
64
|
+
ensure();
|
|
65
|
+
try { const t = fs.readFileSync(TOKEN, 'utf8').trim(); if (t) return t; } catch (e) {}
|
|
66
|
+
const t = (Date.now().toString(36) + Math.random().toString(36).slice(2) + Math.random().toString(36).slice(2));
|
|
67
|
+
try { fs.writeFileSync(TOKEN, t); } catch (e) {}
|
|
68
|
+
return t;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
module.exports = {
|
|
72
|
+
DIR, PENDING, DECISIONS,
|
|
73
|
+
ensure, heartbeat, isAlive,
|
|
74
|
+
readPending, writePending, removePending,
|
|
75
|
+
writeDecision, readDecision, removeDecision,
|
|
76
|
+
readRules, writeRules, token,
|
|
77
|
+
};
|