@saltpub/agent-autoloop 0.0.0-stage → 0.1.3
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/CHANGELOG.md +27 -0
- package/INSTALL.md +120 -0
- package/LICENSE +21 -0
- package/README.en.md +268 -0
- package/README.md +264 -2
- package/SECURITY.md +49 -0
- package/dist/bin/agent-autoloop.js +2 -0
- package/dist/cli/agents.js +14 -0
- package/dist/cli/backup.js +144 -0
- package/dist/cli/dashboard/app.js +424 -0
- package/dist/cli/dashboard/index.html +15 -0
- package/dist/cli/dashboard/style.css +629 -0
- package/dist/cli/dashboard.js +94 -0
- package/dist/cli/explain.js +84 -0
- package/dist/cli/main.js +1142 -0
- package/dist/cli/mcp.js +151 -0
- package/dist/cli/runs.js +40 -0
- package/dist/cli/spend.js +21 -0
- package/dist/cli/status.js +272 -0
- package/dist/cli/try.js +6 -0
- package/dist/cli/ui.js +75 -0
- package/dist/cli/uninstall.js +86 -0
- package/dist/cli/update.js +65 -0
- package/dist/cli/why.js +115 -0
- package/dist/host/background-launcher.js +12 -0
- package/dist/host/background.js +24 -0
- package/dist/host/channels.js +4 -0
- package/dist/host/command.js +98 -0
- package/dist/host/config.js +37 -0
- package/dist/host/files.js +22 -0
- package/dist/host/home.js +5 -0
- package/dist/host/http.js +45 -0
- package/dist/host/launcher.js +188 -0
- package/dist/host/lines.js +15 -0
- package/dist/host/node-path.js +33 -0
- package/dist/host/npm.js +28 -0
- package/dist/host/plugins.js +26 -0
- package/dist/host/program.js +14 -0
- package/dist/host/runtime.js +179 -0
- package/dist/host/server.js +159 -0
- package/dist/host/service.js +325 -0
- package/dist/host/state.js +203 -0
- package/dist/host/up.js +162 -0
- package/dist/host/update.js +286 -0
- package/dist/host/version.js +81 -0
- package/dist/kernel/card-page.js +54 -0
- package/dist/kernel/credentials.js +16 -0
- package/dist/kernel/cron.js +135 -0
- package/dist/kernel/decide.js +826 -0
- package/dist/kernel/due.js +73 -0
- package/dist/kernel/errors.js +9 -0
- package/dist/kernel/evolve.js +264 -0
- package/dist/kernel/http.js +357 -0
- package/dist/kernel/query.js +202 -0
- package/dist/kernel/rules.js +20 -0
- package/dist/kernel/store.js +52 -0
- package/dist/plugins/acp/agent.js +32 -0
- package/dist/plugins/acp/bridge.js +204 -0
- package/dist/plugins/claude/agent.js +113 -0
- package/dist/plugins/codex/agent.js +105 -0
- package/dist/plugins/command/agent.js +25 -0
- package/dist/plugins/delivery/action.js +25 -0
- package/dist/plugins/delivery/agent.js +13 -0
- package/dist/plugins/delivery/delivery.js +388 -0
- package/dist/plugins/delivery/github.js +201 -0
- package/dist/plugins/delivery/handoff.js +50 -0
- package/dist/plugins/delivery/input.js +47 -0
- package/dist/plugins/delivery/poll.js +72 -0
- package/dist/plugins/delivery/project.js +144 -0
- package/dist/plugins/delivery/review-ledger.js +82 -0
- package/dist/plugins/delivery/review-policy.js +99 -0
- package/dist/plugins/delivery/review.js +280 -0
- package/dist/plugins/delivery/run.js +204 -0
- package/dist/plugins/desktop/channel.js +94 -0
- package/dist/plugins/dsh/agent.js +116 -0
- package/dist/plugins/feishu/channel.js +245 -0
- package/dist/plugins/github/source.js +30 -0
- package/dist/plugins/gitlab/source.js +30 -0
- package/dist/plugins/omp/agent.js +3 -0
- package/dist/plugins/opencode/agent.js +88 -0
- package/dist/plugins/pi/agent.js +92 -0
- package/dist/plugins/webhook/channel.js +70 -0
- package/dist/plugins/webhook/templates.js +34 -0
- package/dist/plugins/xiaojiu/channel.js +410 -0
- package/dist/plugins/zcode/agent.js +102 -0
- package/dist/protocol/client.js +56 -0
- package/dist/protocol/conformance.js +184 -0
- package/dist/protocol/job.js +1 -0
- package/dist/protocol/rules.js +230 -0
- package/dist/protocol/schema.js +70 -0
- package/dist/protocol/schema.json +985 -0
- package/dist/protocol/validate.js +150 -0
- package/dist/worker/agents.js +47 -0
- package/dist/worker/contract.js +178 -0
- package/dist/worker/run.js +52 -0
- package/dist/worker/usage.js +45 -0
- package/dist/worker/windows.ps1 +48 -0
- package/dist/worker/worker.js +595 -0
- package/docs/architecture.en.svg +178 -0
- package/docs/architecture.svg +178 -0
- package/docs/auto-update.md +53 -0
- package/docs/plugins.md +139 -0
- package/docs/protocol.md +582 -0
- package/docs/state-machines.md +77 -0
- package/examples/channel.sh +15 -0
- package/examples/plugins/hello-agent/agent.ts +40 -0
- package/examples/plugins/hello-channel/channel.ts +54 -0
- package/examples/plugins/hello-source/source.ts +19 -0
- package/examples/recipes/browser-handoff/README.md +44 -0
- package/examples/recipes/browser-handoff/SKILL.md +22 -0
- package/examples/recipes/browser-handoff/browser.json +10 -0
- package/examples/recipes/browser-handoff/handoff.ts +44 -0
- package/examples/recipes/browser-handoff/rules.json +19 -0
- package/examples/recipes/feedback/README.md +34 -0
- package/examples/recipes/feedback/SKILL.md +22 -0
- package/examples/recipes/feedback/event.json +8 -0
- package/examples/recipes/feedback/rules.json +37 -0
- package/examples/recipes/feishu-brief/README.md +28 -0
- package/examples/recipes/feishu-brief/SKILL.md +16 -0
- package/examples/recipes/feishu-brief/collect.ts +164 -0
- package/examples/recipes/feishu-brief/rules.json +57 -0
- package/examples/recipes/feishu-brief/sources.json +13 -0
- package/examples/recipes/github-issues/README.md +17 -0
- package/examples/recipes/github-issues/SKILL.md +18 -0
- package/examples/recipes/github-issues/rules.json +30 -0
- package/examples/recipes/inbox-triage/README.md +36 -0
- package/examples/recipes/inbox-triage/SKILL.md +19 -0
- package/examples/recipes/inbox-triage/collect.ts +191 -0
- package/examples/recipes/inbox-triage/rules.json +57 -0
- package/examples/recipes/inbox-triage/sources.json +8 -0
- package/examples/recipes/morning-brief/README.md +17 -0
- package/examples/recipes/morning-brief/SKILL.md +17 -0
- package/examples/recipes/morning-brief/rules.json +16 -0
- package/examples/recipes/ops-alerts/README.md +18 -0
- package/examples/recipes/ops-alerts/SKILL.md +34 -0
- package/examples/recipes/ops-alerts/restart.sh +5 -0
- package/examples/recipes/ops-alerts/rules.json +29 -0
- package/examples/recipes/website-watch/README.md +26 -0
- package/examples/recipes/website-watch/SKILL.md +19 -0
- package/examples/recipes/website-watch/check.ts +86 -0
- package/examples/recipes/website-watch/rules.json +56 -0
- package/examples/recipes/website-watch/site.json +6 -0
- package/examples/skills/weekly-sweep/SKILL.md +17 -0
- package/examples/watch-github-issues.sh +23 -0
- package/examples/worker.sh +18 -0
- package/package.json +57 -4
- package/plugins/acp/agent.ts +31 -0
- package/plugins/acp/bridge.ts +190 -0
- package/plugins/claude/agent.ts +121 -0
- package/plugins/codex/agent.ts +103 -0
- package/plugins/command/agent.ts +25 -0
- package/plugins/delivery/action.ts +29 -0
- package/plugins/delivery/action.yml +28 -0
- package/plugins/delivery/agent.ts +15 -0
- package/plugins/delivery/delivery.ts +408 -0
- package/plugins/delivery/github.ts +207 -0
- package/plugins/delivery/handoff.ts +72 -0
- package/plugins/delivery/input.ts +55 -0
- package/plugins/delivery/poll.ts +65 -0
- package/plugins/delivery/project.ts +161 -0
- package/plugins/delivery/review-ledger.ts +90 -0
- package/plugins/delivery/review-policy.ts +126 -0
- package/plugins/delivery/review.ts +324 -0
- package/plugins/delivery/run.ts +219 -0
- package/plugins/desktop/channel.ts +100 -0
- package/plugins/dsh/agent.ts +100 -0
- package/plugins/feishu/channel.ts +243 -0
- package/plugins/github/source.ts +33 -0
- package/plugins/gitlab/source.ts +32 -0
- package/plugins/omp/agent.ts +4 -0
- package/plugins/opencode/agent.ts +78 -0
- package/plugins/pi/agent.ts +80 -0
- package/plugins/webhook/channel.ts +74 -0
- package/plugins/webhook/templates.ts +32 -0
- package/plugins/xiaojiu/channel.ts +426 -0
- package/plugins/zcode/agent.ts +96 -0
- package/skills/agent-autoloop/SKILL.md +260 -0
|
@@ -0,0 +1,629 @@
|
|
|
1
|
+
/* The owner page: 时刻表, a 24-hour rail with each run where it started. */
|
|
2
|
+
/* PROTOTYPE — throwaway. Three identities on purpose: A 时刻表 (cool paper, hairline rails), B 交换机 (dark console,
|
|
3
|
+
mono), C 简报 (serif, measured column). */
|
|
4
|
+
|
|
5
|
+
* {
|
|
6
|
+
box-sizing: border-box;
|
|
7
|
+
}
|
|
8
|
+
html,
|
|
9
|
+
body {
|
|
10
|
+
margin: 0;
|
|
11
|
+
}
|
|
12
|
+
button {
|
|
13
|
+
font: inherit;
|
|
14
|
+
color: inherit;
|
|
15
|
+
background: none;
|
|
16
|
+
border: 0;
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
}
|
|
19
|
+
:focus-visible {
|
|
20
|
+
outline: 2px solid currentColor;
|
|
21
|
+
outline-offset: 2px;
|
|
22
|
+
}
|
|
23
|
+
.boot {
|
|
24
|
+
font: 14px/1.6 ui-sans-serif, "PingFang SC", "Microsoft YaHei", sans-serif;
|
|
25
|
+
color: #6a737b;
|
|
26
|
+
padding: 64px 28px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
:root {
|
|
30
|
+
--bg: #edeff1;
|
|
31
|
+
--ink: #171b1f;
|
|
32
|
+
--mute: #616b74;
|
|
33
|
+
--hair: #c7cdd3;
|
|
34
|
+
--blue: #1d4e89;
|
|
35
|
+
--live: #a86c15;
|
|
36
|
+
--bad: #9c3a2f;
|
|
37
|
+
--sheet-bg: #ffffff;
|
|
38
|
+
--sheet-ink: #171b1f;
|
|
39
|
+
--sheet-text: #2b3238;
|
|
40
|
+
--sheet-mute: #616b74;
|
|
41
|
+
--sheet-hair: #dce1e5;
|
|
42
|
+
--sheet-hover: #eef1f3;
|
|
43
|
+
--sheet-accent: #1d4e89;
|
|
44
|
+
--sheet-bad: #9c3a2f;
|
|
45
|
+
--sheet-warm: #a86c15;
|
|
46
|
+
}
|
|
47
|
+
body {
|
|
48
|
+
background: var(--bg);
|
|
49
|
+
color: var(--ink);
|
|
50
|
+
font-family: ui-sans-serif, "PingFang SC", "Microsoft YaHei", sans-serif;
|
|
51
|
+
font-size: 14px;
|
|
52
|
+
}
|
|
53
|
+
.boot {
|
|
54
|
+
color: var(--mute);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.a-top {
|
|
58
|
+
display: flex;
|
|
59
|
+
align-items: flex-end;
|
|
60
|
+
justify-content: space-between;
|
|
61
|
+
gap: 32px;
|
|
62
|
+
padding: 26px 28px 14px;
|
|
63
|
+
border-bottom: 2px solid var(--ink);
|
|
64
|
+
flex-wrap: wrap;
|
|
65
|
+
}
|
|
66
|
+
.a-title h1 {
|
|
67
|
+
margin: 0;
|
|
68
|
+
font-size: 25px;
|
|
69
|
+
font-weight: 600;
|
|
70
|
+
letter-spacing: 0.02em;
|
|
71
|
+
}
|
|
72
|
+
.a-title p {
|
|
73
|
+
margin: 6px 0 0;
|
|
74
|
+
color: var(--mute);
|
|
75
|
+
font-size: 12.5px;
|
|
76
|
+
font-variant-numeric: tabular-nums;
|
|
77
|
+
}
|
|
78
|
+
.a-counts {
|
|
79
|
+
display: flex;
|
|
80
|
+
margin: 0;
|
|
81
|
+
gap: 0;
|
|
82
|
+
}
|
|
83
|
+
.a-count {
|
|
84
|
+
padding: 0 16px;
|
|
85
|
+
border-left: 1px solid var(--hair);
|
|
86
|
+
min-width: 74px;
|
|
87
|
+
text-align: left;
|
|
88
|
+
display: block;
|
|
89
|
+
}
|
|
90
|
+
.a-count:first-child {
|
|
91
|
+
border-left: 0;
|
|
92
|
+
}
|
|
93
|
+
.a-count span {
|
|
94
|
+
display: block;
|
|
95
|
+
font-size: 11.5px;
|
|
96
|
+
color: var(--mute);
|
|
97
|
+
}
|
|
98
|
+
.a-count b {
|
|
99
|
+
display: block;
|
|
100
|
+
margin-top: 2px;
|
|
101
|
+
font: 21px/1.2 ui-monospace, "Cascadia Mono", Consolas, monospace;
|
|
102
|
+
font-weight: 400;
|
|
103
|
+
font-variant-numeric: tabular-nums;
|
|
104
|
+
}
|
|
105
|
+
.a-count:hover span {
|
|
106
|
+
color: var(--ink);
|
|
107
|
+
text-decoration: underline;
|
|
108
|
+
}
|
|
109
|
+
.a-count.hot b {
|
|
110
|
+
color: var(--bad);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.a-alert {
|
|
114
|
+
display: flex;
|
|
115
|
+
gap: 10px;
|
|
116
|
+
align-items: baseline;
|
|
117
|
+
padding: 9px 28px;
|
|
118
|
+
border-bottom: 1px solid var(--hair);
|
|
119
|
+
font-size: 12.5px;
|
|
120
|
+
color: var(--mute);
|
|
121
|
+
background: #e6e9eb;
|
|
122
|
+
}
|
|
123
|
+
.a-alert b {
|
|
124
|
+
color: var(--ink);
|
|
125
|
+
font-weight: 600;
|
|
126
|
+
}
|
|
127
|
+
.a-alert em {
|
|
128
|
+
margin-left: auto;
|
|
129
|
+
font-style: normal;
|
|
130
|
+
color: var(--bad);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.a-grid {
|
|
134
|
+
display: grid;
|
|
135
|
+
grid-template-columns: 244px minmax(0, 1fr) 252px;
|
|
136
|
+
align-items: start;
|
|
137
|
+
}
|
|
138
|
+
.a-grid h2 {
|
|
139
|
+
margin: 0 0 10px;
|
|
140
|
+
font-size: 11.5px;
|
|
141
|
+
font-weight: 600;
|
|
142
|
+
color: var(--mute);
|
|
143
|
+
letter-spacing: 0.06em;
|
|
144
|
+
}
|
|
145
|
+
.a-rules,
|
|
146
|
+
.a-side {
|
|
147
|
+
padding: 18px 20px 60px;
|
|
148
|
+
}
|
|
149
|
+
.a-rules {
|
|
150
|
+
border-right: 1px solid var(--hair);
|
|
151
|
+
}
|
|
152
|
+
.a-side {
|
|
153
|
+
border-left: 1px solid var(--hair);
|
|
154
|
+
}
|
|
155
|
+
.a-rules ul,
|
|
156
|
+
.a-side ul {
|
|
157
|
+
list-style: none;
|
|
158
|
+
margin: 0;
|
|
159
|
+
padding: 0;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.a-rule {
|
|
163
|
+
display: grid;
|
|
164
|
+
grid-template-columns: 8px minmax(0, 1fr) auto;
|
|
165
|
+
gap: 9px;
|
|
166
|
+
align-items: start;
|
|
167
|
+
padding: 8px 0;
|
|
168
|
+
border-bottom: 1px solid var(--hair);
|
|
169
|
+
}
|
|
170
|
+
.a-lamp {
|
|
171
|
+
width: 7px;
|
|
172
|
+
height: 7px;
|
|
173
|
+
margin-top: 5px;
|
|
174
|
+
background: #b9c0c6;
|
|
175
|
+
border-radius: 50%;
|
|
176
|
+
}
|
|
177
|
+
.a-rule.live .a-lamp {
|
|
178
|
+
background: var(--live);
|
|
179
|
+
box-shadow: 0 0 0 3px rgba(168, 108, 21, 0.18);
|
|
180
|
+
}
|
|
181
|
+
.a-rule.queued .a-lamp {
|
|
182
|
+
background: var(--blue);
|
|
183
|
+
}
|
|
184
|
+
.a-rule.paused {
|
|
185
|
+
opacity: 0.55;
|
|
186
|
+
}
|
|
187
|
+
.a-rule.paused .a-lamp {
|
|
188
|
+
background: var(--bad);
|
|
189
|
+
}
|
|
190
|
+
.a-rule b {
|
|
191
|
+
display: block;
|
|
192
|
+
font-size: 13px;
|
|
193
|
+
font-weight: 600;
|
|
194
|
+
line-height: 1.35;
|
|
195
|
+
}
|
|
196
|
+
.a-rule div > span {
|
|
197
|
+
display: block;
|
|
198
|
+
margin-top: 2px;
|
|
199
|
+
font-size: 11.5px;
|
|
200
|
+
color: var(--mute);
|
|
201
|
+
overflow: hidden;
|
|
202
|
+
text-overflow: ellipsis;
|
|
203
|
+
white-space: nowrap;
|
|
204
|
+
}
|
|
205
|
+
.a-next-at {
|
|
206
|
+
font: 11.5px ui-monospace, "Cascadia Mono", Consolas, monospace;
|
|
207
|
+
color: var(--mute);
|
|
208
|
+
padding-top: 2px;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.a-rail {
|
|
212
|
+
padding: 18px 24px 60px;
|
|
213
|
+
min-width: 0;
|
|
214
|
+
}
|
|
215
|
+
.a-track {
|
|
216
|
+
position: relative;
|
|
217
|
+
border-left: 1px solid var(--hair);
|
|
218
|
+
margin-left: 76px;
|
|
219
|
+
min-height: 300px;
|
|
220
|
+
}
|
|
221
|
+
.a-tick {
|
|
222
|
+
position: absolute;
|
|
223
|
+
left: 0;
|
|
224
|
+
right: 0;
|
|
225
|
+
border-top: 1px solid var(--hair);
|
|
226
|
+
height: 0;
|
|
227
|
+
}
|
|
228
|
+
.a-tick span {
|
|
229
|
+
position: absolute;
|
|
230
|
+
right: 100%;
|
|
231
|
+
margin-right: 12px;
|
|
232
|
+
top: -8px;
|
|
233
|
+
width: 44px;
|
|
234
|
+
text-align: right;
|
|
235
|
+
font: 11px ui-monospace, "Cascadia Mono", Consolas, monospace;
|
|
236
|
+
color: var(--mute);
|
|
237
|
+
}
|
|
238
|
+
.a-mark {
|
|
239
|
+
position: absolute;
|
|
240
|
+
left: 0;
|
|
241
|
+
right: 0;
|
|
242
|
+
padding-left: 12px;
|
|
243
|
+
z-index: 1;
|
|
244
|
+
}
|
|
245
|
+
.a-time {
|
|
246
|
+
position: absolute;
|
|
247
|
+
right: 100%;
|
|
248
|
+
margin-right: 12px;
|
|
249
|
+
top: 0;
|
|
250
|
+
width: 44px;
|
|
251
|
+
text-align: right;
|
|
252
|
+
font: 12px ui-monospace, "Cascadia Mono", Consolas, monospace;
|
|
253
|
+
color: var(--mute);
|
|
254
|
+
padding-top: 1px;
|
|
255
|
+
}
|
|
256
|
+
.a-dot {
|
|
257
|
+
position: absolute;
|
|
258
|
+
left: -5px;
|
|
259
|
+
top: 4px;
|
|
260
|
+
width: 9px;
|
|
261
|
+
height: 9px;
|
|
262
|
+
border-radius: 50%;
|
|
263
|
+
background: var(--bg);
|
|
264
|
+
border: 2px solid var(--blue);
|
|
265
|
+
box-sizing: border-box;
|
|
266
|
+
}
|
|
267
|
+
.a-mark.claimed .a-dot {
|
|
268
|
+
border-color: var(--live);
|
|
269
|
+
background: var(--live);
|
|
270
|
+
}
|
|
271
|
+
.a-mark.unknown .a-dot,
|
|
272
|
+
.a-mark.queued .a-dot {
|
|
273
|
+
border-color: var(--bad);
|
|
274
|
+
}
|
|
275
|
+
.a-label {
|
|
276
|
+
min-width: 0;
|
|
277
|
+
padding: 0 0 4px 0;
|
|
278
|
+
background: var(--bg);
|
|
279
|
+
}
|
|
280
|
+
.a-label b {
|
|
281
|
+
font-size: 13.5px;
|
|
282
|
+
font-weight: 600;
|
|
283
|
+
}
|
|
284
|
+
.a-label em {
|
|
285
|
+
font-style: normal;
|
|
286
|
+
margin-left: 8px;
|
|
287
|
+
font-size: 11.5px;
|
|
288
|
+
color: var(--mute);
|
|
289
|
+
font-variant-numeric: tabular-nums;
|
|
290
|
+
}
|
|
291
|
+
.a-label p {
|
|
292
|
+
margin: 2px 0 0;
|
|
293
|
+
font-size: 12px;
|
|
294
|
+
line-height: 1.5;
|
|
295
|
+
color: #3d474f;
|
|
296
|
+
max-width: 62ch;
|
|
297
|
+
overflow: hidden;
|
|
298
|
+
display: -webkit-box;
|
|
299
|
+
-webkit-line-clamp: 2;
|
|
300
|
+
-webkit-box-orient: vertical;
|
|
301
|
+
}
|
|
302
|
+
.a-now {
|
|
303
|
+
position: absolute;
|
|
304
|
+
left: -4px;
|
|
305
|
+
right: 0;
|
|
306
|
+
border-top: 1px dashed var(--blue);
|
|
307
|
+
height: 0;
|
|
308
|
+
}
|
|
309
|
+
.a-now span {
|
|
310
|
+
position: absolute;
|
|
311
|
+
right: 0;
|
|
312
|
+
top: -9px;
|
|
313
|
+
font: 10.5px ui-monospace, "Cascadia Mono", Consolas, monospace;
|
|
314
|
+
color: var(--blue);
|
|
315
|
+
background: var(--bg);
|
|
316
|
+
padding-left: 6px;
|
|
317
|
+
}
|
|
318
|
+
.a-empty {
|
|
319
|
+
color: var(--mute);
|
|
320
|
+
font-size: 12.5px;
|
|
321
|
+
padding: 8px 0 8px 6px;
|
|
322
|
+
}
|
|
323
|
+
.a-edge {
|
|
324
|
+
position: absolute;
|
|
325
|
+
right: 100%;
|
|
326
|
+
margin-right: 12px;
|
|
327
|
+
top: -6px;
|
|
328
|
+
width: 64px;
|
|
329
|
+
text-align: right;
|
|
330
|
+
font: 10.5px ui-monospace, "Cascadia Mono", Consolas, monospace;
|
|
331
|
+
color: #8d959c;
|
|
332
|
+
line-height: 1.3;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
.a-upcoming li,
|
|
336
|
+
.a-recent li {
|
|
337
|
+
padding: 8px 0;
|
|
338
|
+
border-bottom: 1px solid var(--hair);
|
|
339
|
+
font-size: 12.5px;
|
|
340
|
+
line-height: 1.45;
|
|
341
|
+
}
|
|
342
|
+
.a-upcoming span {
|
|
343
|
+
display: block;
|
|
344
|
+
font: 11.5px ui-monospace, "Cascadia Mono", Consolas, monospace;
|
|
345
|
+
color: var(--mute);
|
|
346
|
+
}
|
|
347
|
+
.a-upcoming b {
|
|
348
|
+
font-weight: 600;
|
|
349
|
+
}
|
|
350
|
+
.a-upcoming em {
|
|
351
|
+
font-style: normal;
|
|
352
|
+
color: var(--mute);
|
|
353
|
+
font-size: 11.5px;
|
|
354
|
+
margin-left: 6px;
|
|
355
|
+
}
|
|
356
|
+
.a-recent b {
|
|
357
|
+
font: 11.5px ui-monospace, "Cascadia Mono", Consolas, monospace;
|
|
358
|
+
font-weight: 400;
|
|
359
|
+
color: var(--mute);
|
|
360
|
+
margin-right: 6px;
|
|
361
|
+
}
|
|
362
|
+
.a-recent li span {
|
|
363
|
+
display: block;
|
|
364
|
+
color: var(--mute);
|
|
365
|
+
font-size: 11.5px;
|
|
366
|
+
}
|
|
367
|
+
.a-side h2 + ul {
|
|
368
|
+
margin-bottom: 24px;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/* ---------------- 明细(点计数打开) ---------------- */
|
|
372
|
+
|
|
373
|
+
.sheet-backdrop {
|
|
374
|
+
position: fixed;
|
|
375
|
+
inset: 0;
|
|
376
|
+
background: rgba(10, 12, 14, 0.34);
|
|
377
|
+
z-index: 55;
|
|
378
|
+
}
|
|
379
|
+
.sheet {
|
|
380
|
+
position: fixed;
|
|
381
|
+
top: 0;
|
|
382
|
+
right: 0;
|
|
383
|
+
bottom: 0;
|
|
384
|
+
width: min(470px, 94vw);
|
|
385
|
+
display: flex;
|
|
386
|
+
flex-direction: column;
|
|
387
|
+
background: var(--sheet-bg);
|
|
388
|
+
color: var(--sheet-ink);
|
|
389
|
+
border-left: 1px solid var(--sheet-hair);
|
|
390
|
+
box-shadow: -20px 0 44px rgba(0, 0, 0, 0.18);
|
|
391
|
+
z-index: 56;
|
|
392
|
+
font-family: ui-sans-serif, "PingFang SC", "Microsoft YaHei", sans-serif;
|
|
393
|
+
font-size: 13px;
|
|
394
|
+
line-height: 1.6;
|
|
395
|
+
}
|
|
396
|
+
.sheet header {
|
|
397
|
+
display: flex;
|
|
398
|
+
align-items: baseline;
|
|
399
|
+
gap: 10px;
|
|
400
|
+
padding: 13px 18px 4px;
|
|
401
|
+
}
|
|
402
|
+
.sheet h2 {
|
|
403
|
+
margin: 0;
|
|
404
|
+
font-size: 14px;
|
|
405
|
+
font-weight: 600;
|
|
406
|
+
}
|
|
407
|
+
.sheet header b {
|
|
408
|
+
font: 13px ui-monospace, "Cascadia Mono", Consolas, monospace;
|
|
409
|
+
font-weight: 400;
|
|
410
|
+
color: var(--sheet-mute);
|
|
411
|
+
font-variant-numeric: tabular-nums;
|
|
412
|
+
}
|
|
413
|
+
.sheet-close {
|
|
414
|
+
margin-left: auto;
|
|
415
|
+
width: 26px;
|
|
416
|
+
height: 26px;
|
|
417
|
+
border-radius: 50%;
|
|
418
|
+
color: var(--sheet-mute);
|
|
419
|
+
font-size: 17px;
|
|
420
|
+
line-height: 1;
|
|
421
|
+
}
|
|
422
|
+
.sheet-close:hover {
|
|
423
|
+
background: var(--sheet-hover);
|
|
424
|
+
color: var(--sheet-ink);
|
|
425
|
+
}
|
|
426
|
+
.sheet-body {
|
|
427
|
+
flex: 1;
|
|
428
|
+
overflow-y: auto;
|
|
429
|
+
padding: 2px 18px 20px;
|
|
430
|
+
}
|
|
431
|
+
.sheet-tabs {
|
|
432
|
+
display: flex;
|
|
433
|
+
gap: 2px;
|
|
434
|
+
padding: 8px 14px 0;
|
|
435
|
+
border-bottom: 1px solid var(--sheet-hair);
|
|
436
|
+
overflow-x: auto;
|
|
437
|
+
}
|
|
438
|
+
.sheet-tabs button {
|
|
439
|
+
padding: 5px 9px 6px;
|
|
440
|
+
border-bottom: 2px solid transparent;
|
|
441
|
+
color: var(--sheet-mute);
|
|
442
|
+
font-size: 11.5px;
|
|
443
|
+
white-space: nowrap;
|
|
444
|
+
}
|
|
445
|
+
.sheet-tabs button b {
|
|
446
|
+
margin-left: 5px;
|
|
447
|
+
font: 11px ui-monospace, "Cascadia Mono", Consolas, monospace;
|
|
448
|
+
font-weight: 400;
|
|
449
|
+
color: var(--sheet-mute);
|
|
450
|
+
font-variant-numeric: tabular-nums;
|
|
451
|
+
}
|
|
452
|
+
.sheet-tabs button:hover {
|
|
453
|
+
color: var(--sheet-ink);
|
|
454
|
+
}
|
|
455
|
+
.sheet-tabs button.on {
|
|
456
|
+
color: var(--sheet-ink);
|
|
457
|
+
border-bottom-color: var(--sheet-accent);
|
|
458
|
+
}
|
|
459
|
+
.sheet-tabs button.on b {
|
|
460
|
+
color: var(--sheet-accent);
|
|
461
|
+
}
|
|
462
|
+
.sheet-item {
|
|
463
|
+
padding: 12px 0 14px;
|
|
464
|
+
border-bottom: 1px solid var(--sheet-hair);
|
|
465
|
+
}
|
|
466
|
+
.sheet-item:last-child {
|
|
467
|
+
border-bottom: 0;
|
|
468
|
+
}
|
|
469
|
+
.si-head {
|
|
470
|
+
display: flex;
|
|
471
|
+
align-items: baseline;
|
|
472
|
+
gap: 8px;
|
|
473
|
+
margin: 0;
|
|
474
|
+
}
|
|
475
|
+
.si-head b {
|
|
476
|
+
font-size: 13.5px;
|
|
477
|
+
font-weight: 600;
|
|
478
|
+
}
|
|
479
|
+
.si-head em {
|
|
480
|
+
margin-left: auto;
|
|
481
|
+
font-style: normal;
|
|
482
|
+
font: 11px ui-monospace, "Cascadia Mono", Consolas, monospace;
|
|
483
|
+
color: var(--sheet-mute);
|
|
484
|
+
}
|
|
485
|
+
.si-kind {
|
|
486
|
+
white-space: nowrap;
|
|
487
|
+
font-size: 10.5px;
|
|
488
|
+
padding: 0 5px;
|
|
489
|
+
border: 1px solid var(--sheet-hair);
|
|
490
|
+
color: var(--sheet-mute);
|
|
491
|
+
}
|
|
492
|
+
.si-kind.ask,
|
|
493
|
+
.si-kind.bad {
|
|
494
|
+
color: var(--sheet-bad);
|
|
495
|
+
border-color: currentColor;
|
|
496
|
+
}
|
|
497
|
+
.si-kind.claimed,
|
|
498
|
+
.si-kind.warn {
|
|
499
|
+
color: var(--sheet-warm);
|
|
500
|
+
border-color: currentColor;
|
|
501
|
+
}
|
|
502
|
+
.si-text {
|
|
503
|
+
margin: 6px 0 0;
|
|
504
|
+
font-size: 12.5px;
|
|
505
|
+
line-height: 1.65;
|
|
506
|
+
color: var(--sheet-text);
|
|
507
|
+
white-space: pre-wrap;
|
|
508
|
+
}
|
|
509
|
+
.si-meta {
|
|
510
|
+
margin: 8px 0 0;
|
|
511
|
+
font-size: 11px;
|
|
512
|
+
color: var(--sheet-mute);
|
|
513
|
+
}
|
|
514
|
+
.si-grid {
|
|
515
|
+
display: grid;
|
|
516
|
+
grid-template-columns: 52px minmax(0, 1fr);
|
|
517
|
+
gap: 2px 10px;
|
|
518
|
+
margin: 8px 0 0;
|
|
519
|
+
font-size: 11.5px;
|
|
520
|
+
}
|
|
521
|
+
.si-grid dt {
|
|
522
|
+
color: var(--sheet-mute);
|
|
523
|
+
}
|
|
524
|
+
.si-grid dd {
|
|
525
|
+
margin: 0;
|
|
526
|
+
color: var(--sheet-text);
|
|
527
|
+
}
|
|
528
|
+
.si-grid dd.mono {
|
|
529
|
+
font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
|
|
530
|
+
font-size: 10.5px;
|
|
531
|
+
word-break: break-all;
|
|
532
|
+
}
|
|
533
|
+
.si-grid dd.bad {
|
|
534
|
+
color: var(--sheet-bad);
|
|
535
|
+
}
|
|
536
|
+
.si-options {
|
|
537
|
+
margin: 8px 0 0;
|
|
538
|
+
padding: 0;
|
|
539
|
+
list-style: none;
|
|
540
|
+
counter-reset: opt;
|
|
541
|
+
}
|
|
542
|
+
.si-options li {
|
|
543
|
+
counter-increment: opt;
|
|
544
|
+
position: relative;
|
|
545
|
+
padding: 3px 0 3px 24px;
|
|
546
|
+
font-size: 12px;
|
|
547
|
+
color: var(--sheet-mute);
|
|
548
|
+
}
|
|
549
|
+
.si-options li::before {
|
|
550
|
+
content: counter(opt);
|
|
551
|
+
position: absolute;
|
|
552
|
+
left: 0;
|
|
553
|
+
top: 4px;
|
|
554
|
+
font: 11px ui-monospace, "Cascadia Mono", Consolas, monospace;
|
|
555
|
+
}
|
|
556
|
+
.si-options li.rec {
|
|
557
|
+
color: var(--sheet-ink);
|
|
558
|
+
}
|
|
559
|
+
.si-options li.rec::after {
|
|
560
|
+
content: "推荐";
|
|
561
|
+
margin-left: 8px;
|
|
562
|
+
font-size: 10.5px;
|
|
563
|
+
color: var(--sheet-accent);
|
|
564
|
+
border: 1px solid var(--sheet-accent);
|
|
565
|
+
padding: 0 4px;
|
|
566
|
+
}
|
|
567
|
+
.si-events {
|
|
568
|
+
display: flex;
|
|
569
|
+
flex-wrap: wrap;
|
|
570
|
+
gap: 6px;
|
|
571
|
+
margin: 10px 0 0;
|
|
572
|
+
padding: 0;
|
|
573
|
+
list-style: none;
|
|
574
|
+
}
|
|
575
|
+
.si-events li {
|
|
576
|
+
font-size: 10.5px;
|
|
577
|
+
color: var(--sheet-mute);
|
|
578
|
+
border: 1px solid var(--sheet-hair);
|
|
579
|
+
padding: 0 5px;
|
|
580
|
+
}
|
|
581
|
+
.sheet-empty {
|
|
582
|
+
margin: 22px 0;
|
|
583
|
+
color: var(--sheet-mute);
|
|
584
|
+
font-size: 12.5px;
|
|
585
|
+
}
|
|
586
|
+
.sheet footer {
|
|
587
|
+
padding: 10px 18px 14px;
|
|
588
|
+
border-top: 1px solid var(--sheet-hair);
|
|
589
|
+
font-size: 11px;
|
|
590
|
+
line-height: 1.55;
|
|
591
|
+
color: var(--sheet-mute);
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
@media (max-width: 900px) {
|
|
595
|
+
.a-grid {
|
|
596
|
+
grid-template-columns: 1fr;
|
|
597
|
+
}
|
|
598
|
+
.a-rules,
|
|
599
|
+
.a-side {
|
|
600
|
+
border: 0;
|
|
601
|
+
border-bottom: 1px solid var(--hair);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
@media (prefers-reduced-motion: reduce) {
|
|
605
|
+
* {
|
|
606
|
+
transition: none !important;
|
|
607
|
+
animation: none !important;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
.si-why-line {
|
|
611
|
+
margin: 10px 0 0;
|
|
612
|
+
}
|
|
613
|
+
.si-why {
|
|
614
|
+
font-size: 11.5px;
|
|
615
|
+
color: var(--sheet-accent);
|
|
616
|
+
border-bottom: 1px solid currentColor;
|
|
617
|
+
padding: 0 0 1px;
|
|
618
|
+
}
|
|
619
|
+
.si-why-text {
|
|
620
|
+
margin: 10px 0 0;
|
|
621
|
+
padding: 10px 12px;
|
|
622
|
+
background: #f6f8f9;
|
|
623
|
+
border-left: 2px solid var(--sheet-hair);
|
|
624
|
+
font: 11.5px/1.75 ui-monospace, "SF Mono", Consolas, monospace;
|
|
625
|
+
color: var(--sheet-text);
|
|
626
|
+
white-space: pre-wrap;
|
|
627
|
+
max-height: 340px;
|
|
628
|
+
overflow: auto;
|
|
629
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// The owner's page, served from this machine: a read-only client of the hub. It adds the owner's key to what it forwards,
|
|
2
|
+
// so the page never holds the key, and refuses a Host that isn't this machine's — a site can point its own name at
|
|
3
|
+
// 127.0.0.1, and what the owner sees is everything the hub knows.
|
|
4
|
+
import { readFileSync } from "node:fs";
|
|
5
|
+
import { createServer } from "node:http";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { Readable } from "node:stream";
|
|
8
|
+
import { formatWhy } from "./why.js";
|
|
9
|
+
const PAGES = [
|
|
10
|
+
["/", "index.html", "text/html; charset=utf-8"],
|
|
11
|
+
["/app.js", "app.js", "text/javascript; charset=utf-8"],
|
|
12
|
+
["/style.css", "style.css", "text/css; charset=utf-8"],
|
|
13
|
+
];
|
|
14
|
+
/** Starts the page on this machine, pointed at one hub with one owner's key. Port 0 lets the system pick one. */
|
|
15
|
+
export async function startDashboard({ url, key, port, folder = path.join(import.meta.dirname, "dashboard"), }) {
|
|
16
|
+
const hub = url.replace(/\/+$/, "");
|
|
17
|
+
const pages = new Map(PAGES.map(([route, file, type]) => [route, { body: readFileSync(path.join(folder, file)), type }]));
|
|
18
|
+
const owner = { authorization: `Bearer ${key}` };
|
|
19
|
+
let allowed = new Set();
|
|
20
|
+
async function forward(answer, address) {
|
|
21
|
+
const upstream = await fetch(address, { headers: owner });
|
|
22
|
+
if (!upstream.ok)
|
|
23
|
+
return send(answer, upstream.status, await refused(upstream));
|
|
24
|
+
send(answer, 200, await upstream.json());
|
|
25
|
+
}
|
|
26
|
+
/** Facts go out as they're logged: holding them until the hub closes would freeze the board mid-run. */
|
|
27
|
+
async function stream(request, answer, address) {
|
|
28
|
+
const stop = new AbortController();
|
|
29
|
+
answer.on("close", () => stop.abort());
|
|
30
|
+
const last = request.headers["last-event-id"];
|
|
31
|
+
const upstream = await fetch(address, {
|
|
32
|
+
headers: { ...owner, ...(last ? { "last-event-id": String(last) } : {}) },
|
|
33
|
+
signal: stop.signal,
|
|
34
|
+
});
|
|
35
|
+
if (!upstream.ok || !upstream.body)
|
|
36
|
+
return send(answer, upstream.status, await refused(upstream));
|
|
37
|
+
answer.writeHead(200, {
|
|
38
|
+
"content-type": upstream.headers.get("content-type") ?? "text/event-stream",
|
|
39
|
+
"cache-control": "no-store",
|
|
40
|
+
"x-accel-buffering": "no",
|
|
41
|
+
});
|
|
42
|
+
// Node holds the head until the first chunk; the hub can be quiet for a minute and the page waits on those heads to call itself live.
|
|
43
|
+
answer.flushHeaders();
|
|
44
|
+
Readable.fromWeb(upstream.body)
|
|
45
|
+
// The page closing its tab aborts the upstream read; that is the end of one stream, not of the board.
|
|
46
|
+
.on("error", () => answer.destroy())
|
|
47
|
+
.pipe(answer);
|
|
48
|
+
}
|
|
49
|
+
async function serve(request, answer) {
|
|
50
|
+
if (!allowed.has(request.headers.host ?? ""))
|
|
51
|
+
return send(answer, 403, { error: "这个地址不是本机的看板" });
|
|
52
|
+
if (request.method !== "GET" && request.method !== "HEAD")
|
|
53
|
+
return send(answer, 405, { error: "看板只读" });
|
|
54
|
+
const here = new URL(request.url ?? "/", "http://127.0.0.1");
|
|
55
|
+
const page = pages.get(here.pathname);
|
|
56
|
+
if (page) {
|
|
57
|
+
answer.writeHead(200, { "content-type": page.type, "cache-control": "no-store" });
|
|
58
|
+
return answer.end(request.method === "HEAD" ? undefined : page.body);
|
|
59
|
+
}
|
|
60
|
+
if (here.pathname === "/api/state")
|
|
61
|
+
return forward(answer, `${hub}/v1/state${here.search}`);
|
|
62
|
+
if (here.pathname === "/api/stream")
|
|
63
|
+
return stream(request, answer, `${hub}/v1/stream${here.search}`);
|
|
64
|
+
const why = /^\/api\/why\/(\d+)$/.exec(here.pathname);
|
|
65
|
+
if (why) {
|
|
66
|
+
const facts = await fetch(`${hub}/v1/runs/${why[1]}/why`, { headers: owner });
|
|
67
|
+
if (!facts.ok)
|
|
68
|
+
return send(answer, facts.status, await refused(facts));
|
|
69
|
+
return send(answer, 200, { text: formatWhy(Number(why[1]), (await facts.json())) });
|
|
70
|
+
}
|
|
71
|
+
return send(answer, 404, { error: "看板没有这个地址" });
|
|
72
|
+
}
|
|
73
|
+
const server = createServer((request, answer) => {
|
|
74
|
+
serve(request, answer).catch((error) => send(answer, 502, { error: error.message }));
|
|
75
|
+
});
|
|
76
|
+
const listening = Promise.withResolvers();
|
|
77
|
+
server.once("error", listening.reject);
|
|
78
|
+
server.listen(port, "127.0.0.1", () => {
|
|
79
|
+
const bound = server.address().port;
|
|
80
|
+
allowed = new Set([`127.0.0.1:${bound}`, `localhost:${bound}`]);
|
|
81
|
+
listening.resolve({ url: `http://127.0.0.1:${bound}/`, close: () => server.close() });
|
|
82
|
+
});
|
|
83
|
+
return listening.promise;
|
|
84
|
+
}
|
|
85
|
+
function send(answer, status, body) {
|
|
86
|
+
if (answer.headersSent)
|
|
87
|
+
return answer.end();
|
|
88
|
+
answer.writeHead(status, { "content-type": "application/json; charset=utf-8", "cache-control": "no-store" });
|
|
89
|
+
answer.end(JSON.stringify(body));
|
|
90
|
+
}
|
|
91
|
+
/** The hub's own words when it refuses, so a wrong key reads as «没有这个密钥» rather than an empty board. */
|
|
92
|
+
async function refused(response) {
|
|
93
|
+
return response.json().catch(() => ({ error: `中台回了 ${response.status}` }));
|
|
94
|
+
}
|