@prismshadow/penguin-server 0.2.17 → 0.2.18

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.
Files changed (90) hide show
  1. package/dist/api/types.d.ts +181 -17
  2. package/dist/api/types.js +9 -1
  3. package/dist/auth-token.js +1 -1
  4. package/dist/{chunk-HPOHMZCH.js → chunk-5YLLSHY3.js} +61 -2
  5. package/dist/chunk-5YLLSHY3.js.map +1 -0
  6. package/dist/{chunk-D3JNA6ZI.js → chunk-B3PSKR3D.js} +2 -2
  7. package/dist/chunk-B3PSKR3D.js.map +1 -0
  8. package/dist/{chunk-HDBZRVA5.js → chunk-BRMNPLU6.js} +9 -1
  9. package/dist/chunk-BRMNPLU6.js.map +1 -0
  10. package/dist/index.js +8331 -6769
  11. package/dist/index.js.map +1 -1
  12. package/dist/machine-status.js +1 -1
  13. package/dist/plugin/index.d.ts +57 -16
  14. package/dist/reset-admin-password.js +2 -2
  15. package/package.json +4 -4
  16. package/web-dist/assets/{abnfDiagram-VCTEODGH-DMzkb4l4.js → abnfDiagram-VCTEODGH-C_Ej4MyZ.js} +1 -1
  17. package/web-dist/assets/{addon-clipboard-BtD2BVSi.js → addon-clipboard-eONBCa8x.js} +1 -1
  18. package/web-dist/assets/{addon-fit-Dr6HWsi_.js → addon-fit-Dk6bkT8u.js} +1 -1
  19. package/web-dist/assets/{addon-web-links-VEE3YLzQ.js → addon-web-links-e0JpGvGv.js} +1 -1
  20. package/web-dist/assets/{arc-CvMPOU_B.js → arc-ytwqobEL.js} +1 -1
  21. package/web-dist/assets/{architectureDiagram-5GKGNRK7-Bk65mIBz.js → architectureDiagram-5GKGNRK7-oxT9SNOE.js} +1 -1
  22. package/web-dist/assets/{blockDiagram-I7D4REHJ-D54-XSNs.js → blockDiagram-I7D4REHJ-D8OXfpb9.js} +1 -1
  23. package/web-dist/assets/{c4Diagram-7LVT6UL2-Dm954LSt.js → c4Diagram-7LVT6UL2-BNYNzSWK.js} +1 -1
  24. package/web-dist/assets/channel-7Be_pU-b.js +1 -0
  25. package/web-dist/assets/{chunk-2Q5K7J3B-D_LJ_7Cn.js → chunk-2Q5K7J3B-C2yNhFmh.js} +1 -1
  26. package/web-dist/assets/{chunk-5VM5RSS4-B8RI4tl3.js → chunk-5VM5RSS4-CAeuhwbB.js} +1 -1
  27. package/web-dist/assets/{chunk-F27PBJKO-aVSYH9JV.js → chunk-F27PBJKO-DSuRiLxP.js} +1 -1
  28. package/web-dist/assets/{chunk-IMKFNOWR-DnkdWeq2.js → chunk-IMKFNOWR-MStar4cf.js} +1 -1
  29. package/web-dist/assets/{chunk-JWPE2WC7-C2pJzKuW.js → chunk-JWPE2WC7-CIgQwRv4.js} +1 -1
  30. package/web-dist/assets/{chunk-POPQ4Y6H-Bx7Iikzx.js → chunk-POPQ4Y6H-CA8evx9g.js} +1 -1
  31. package/web-dist/assets/{chunk-SVP7TREG-qJC2SMqr.js → chunk-SVP7TREG-bR7-FT1W.js} +1 -1
  32. package/web-dist/assets/{chunk-TICWLB2K-Crl_BgKI.js → chunk-TICWLB2K-C0ZdCnvI.js} +1 -1
  33. package/web-dist/assets/{chunk-XXDRQBXY-BFFemuGm.js → chunk-XXDRQBXY-CzozFLFI.js} +1 -1
  34. package/web-dist/assets/classDiagram-ZZMXUADV-BjVhvDIH.js +1 -0
  35. package/web-dist/assets/classDiagram-v2-VYDZK3BY-BjVhvDIH.js +1 -0
  36. package/web-dist/assets/{cose-bilkent-JH36ORCC-Bmh2Kx7h.js → cose-bilkent-JH36ORCC-nkjrY6eI.js} +1 -1
  37. package/web-dist/assets/{cynefin-OW5HDTMX-BveNWnUV.js → cynefin-OW5HDTMX-D2A0h062.js} +1 -1
  38. package/web-dist/assets/{cynefinDiagram-5FMLGOSQ-85itazbJ.js → cynefinDiagram-5FMLGOSQ-DFZQ7d_T.js} +1 -1
  39. package/web-dist/assets/{dagre-GXQ25YYZ-DIZT-KY_.js → dagre-GXQ25YYZ-DPYLLARd.js} +1 -1
  40. package/web-dist/assets/{diagram-S7CK7UJ4-Dum-g63f.js → diagram-S7CK7UJ4-B204Nrur.js} +1 -1
  41. package/web-dist/assets/{diagram-UQ7AKVKN-DallMKJl.js → diagram-UQ7AKVKN-DWORCZlS.js} +1 -1
  42. package/web-dist/assets/{diagram-VSXAHHWV-DWELqxfN.js → diagram-VSXAHHWV-Su6Bzm4Z.js} +1 -1
  43. package/web-dist/assets/{diagram-VX7I27RA-BNs0gB9E.js → diagram-VX7I27RA-B4p8ssYj.js} +1 -1
  44. package/web-dist/assets/{diagram-Z3DM3KII-C9mF9xAd.js → diagram-Z3DM3KII-BgMz7jjW.js} +1 -1
  45. package/web-dist/assets/{ebnfDiagram-PWID7BFC-D_Diy9HH.js → ebnfDiagram-PWID7BFC-DBCS3Cwc.js} +1 -1
  46. package/web-dist/assets/{erDiagram-RLTQ6QDP-4QTS5VIh.js → erDiagram-RLTQ6QDP-DEm39S5C.js} +1 -1
  47. package/web-dist/assets/{flowDiagram-HODETNUW-CliTRrtV.js → flowDiagram-HODETNUW-CEUQGUza.js} +1 -1
  48. package/web-dist/assets/{ganttDiagram-EL5Y4UJY-DCRd-Ss4.js → ganttDiagram-EL5Y4UJY-myYTgwFp.js} +1 -1
  49. package/web-dist/assets/{gitGraphDiagram-WWUBYQGX-CTz13GjS.js → gitGraphDiagram-WWUBYQGX-BAQ0Kl1C.js} +1 -1
  50. package/web-dist/assets/{highlighter-BScH1Ud3.js → highlighter-DRTMVWxI.js} +2 -2
  51. package/web-dist/assets/{highlighter-core-DKz8Z6-I.js → highlighter-core-DgISzHrX.js} +1 -1
  52. package/web-dist/assets/index-PA-IFoA6.js +1300 -0
  53. package/web-dist/assets/index-oCEyg9BT.css +1 -0
  54. package/web-dist/assets/{infoDiagram-27XIBGKW-DNfTEPAV.js → infoDiagram-27XIBGKW-B2WDMvX9.js} +1 -1
  55. package/web-dist/assets/{ishikawaDiagram-5VMMS53U-B7aCjjG1.js → ishikawaDiagram-5VMMS53U-8qHTttjq.js} +1 -1
  56. package/web-dist/assets/{journeyDiagram-3NMN7TZE-COmDALVr.js → journeyDiagram-3NMN7TZE-DKE_xRCO.js} +1 -1
  57. package/web-dist/assets/{kanban-definition-UXKFOSKX-BzUfPINh.js → kanban-definition-UXKFOSKX-EnJbHEmV.js} +1 -1
  58. package/web-dist/assets/{layout-BwzuPU4M.js → layout-BlhCFmEZ.js} +1 -1
  59. package/web-dist/assets/{linear-WPZTYjz3.js → linear-Dw2VzU-D.js} +1 -1
  60. package/web-dist/assets/{mermaid.core-zKzlwpkw.js → mermaid.core-CaXNMz57.js} +6 -6
  61. package/web-dist/assets/{mindmap-definition-YA3MSWOX-DCRg7eAx.js → mindmap-definition-YA3MSWOX-DnTTfqbu.js} +1 -1
  62. package/web-dist/assets/{pegDiagram-XKGWAZYB-DyphzDLU.js → pegDiagram-XKGWAZYB-C3SArVd6.js} +1 -1
  63. package/web-dist/assets/{pieDiagram-E7YTZNPT-BI5DueGA.js → pieDiagram-E7YTZNPT-CTOmO6ke.js} +1 -1
  64. package/web-dist/assets/{quadrantDiagram-AXDQQJYC-GZxSMY2Z.js → quadrantDiagram-AXDQQJYC-CbUsMwzO.js} +1 -1
  65. package/web-dist/assets/{railroadDiagram-O6MQD6OU-DEFCigBf.js → railroadDiagram-O6MQD6OU-Co2hsvaZ.js} +1 -1
  66. package/web-dist/assets/{requirementDiagram-BXWQKSXE-Br0thc4j.js → requirementDiagram-BXWQKSXE-BqFG0eYQ.js} +1 -1
  67. package/web-dist/assets/{sankeyDiagram-P5KCCOFB-DYf0pY67.js → sankeyDiagram-P5KCCOFB-YgQHJlB7.js} +1 -1
  68. package/web-dist/assets/{sequenceDiagram-WJ2MYXX4-1EFMboX4.js → sequenceDiagram-WJ2MYXX4-CdDrP6O2.js} +1 -1
  69. package/web-dist/assets/{sizeCapture-INFHLROL-BuOFv-5q.js → sizeCapture-INFHLROL-CKwbEVhU.js} +1 -1
  70. package/web-dist/assets/{stateDiagram-D77RDMKH-Bg3H1tjX.js → stateDiagram-D77RDMKH-kTJR3t2p.js} +1 -1
  71. package/web-dist/assets/stateDiagram-v2-MP3YSRHH-DzaSnZwj.js +1 -0
  72. package/web-dist/assets/{swimlanes-42K2YHIH-BuOa6Osb.js → swimlanes-42K2YHIH-DCAO3rCQ.js} +1 -1
  73. package/web-dist/assets/swimlanesDiagram-VR7AAH4N-DNfCLejq.js +8 -0
  74. package/web-dist/assets/{timeline-definition-24CTP7MA-BDekfdDT.js → timeline-definition-24CTP7MA-DEjnyzKw.js} +1 -1
  75. package/web-dist/assets/{vennDiagram-4TSXK5OY-DnC09UI4.js → vennDiagram-4TSXK5OY-DSihUvCq.js} +1 -1
  76. package/web-dist/assets/{wardleyDiagram-VM6X3IG4-BXKvxuZQ.js → wardleyDiagram-VM6X3IG4-CnAoMeCH.js} +1 -1
  77. package/web-dist/assets/{xterm-oY4DYg5s.js → xterm-3JwPT74G.js} +1 -1
  78. package/web-dist/assets/{xychartDiagram-S5SC5T6Z-DdDC1VLb.js → xychartDiagram-S5SC5T6Z-43dHqZTr.js} +1 -1
  79. package/web-dist/index.html +2 -2
  80. package/web-dist/workbench-ui.css +164 -34
  81. package/dist/chunk-D3JNA6ZI.js.map +0 -1
  82. package/dist/chunk-HDBZRVA5.js.map +0 -1
  83. package/dist/chunk-HPOHMZCH.js.map +0 -1
  84. package/web-dist/assets/channel-CVHI75kz.js +0 -1
  85. package/web-dist/assets/classDiagram-ZZMXUADV-CBdzAPFu.js +0 -1
  86. package/web-dist/assets/classDiagram-v2-VYDZK3BY-CBdzAPFu.js +0 -1
  87. package/web-dist/assets/index-BUvJ5Ctt.js +0 -1299
  88. package/web-dist/assets/index-DRj7nvPY.css +0 -1
  89. package/web-dist/assets/stateDiagram-v2-MP3YSRHH-DfaDaPAd.js +0 -1
  90. package/web-dist/assets/swimlanesDiagram-VR7AAH4N-BopAC7b8.js +0 -8
@@ -2,31 +2,44 @@
2
2
  * Base stylesheet for a workbench's own page (features/workbenches/workbench-tabs.tsx injects it
3
3
  * into the frame, and a page may link it itself for standalone viewing).
4
4
  *
5
- * A workbench page is a separate document: Tailwind never sees it, and the app's `html.dark`
6
- * class and accent variables stop at the frame boundary. So the app copies its RESOLVED
7
- * tokens — the gray scale, the accent pair, the font stack, the root font size — onto this
8
- * document's root (lib/workbench-theme.ts), and everything here is expressed in those
9
- * variables. The literal fallbacks are only for a page opened outside the app; the palette
10
- * has exactly one source of truth, styles.css.
5
+ * A workbench page is a separate document: Tailwind never sees it, and the app's theme stops at
6
+ * the frame boundary. So the app copies what it has RESOLVED onto this document's root
7
+ * (lib/workbench-theme.ts): the `light` / `dark` class, `data-theme`, `data-accent`,
8
+ * `data-font-latin` / `data-font-cjk`, the root font size, every `--ui-*` token of the shared UI
9
+ * package's contract (packages/ui/src/tokens.ts), and the bundled fonts' `@font-face` rules.
11
10
  *
12
- * This is a floor, not a framework: it styles the plain HTML an agent writes (headings,
13
- * lists, forms, tables, code) and gets out of the way. It is injected FIRST in the head, so
14
- * a page's own rules always win.
11
+ * Two vocabularies follow from that:
12
+ * - `--wb-*` and the `wb-*` classes are the workbench's own, stable names. Each `--wb-*` is mapped
13
+ * below onto a `--ui-*` token, so it follows the app's theme, mode, accent and font pairing; a
14
+ * page restyles one by redeclaring it on `:root`. Names are only ever added here, never renamed
15
+ * or removed: published workbenches read them.
16
+ * - `--ui-*` is the token contract itself, what the app's own components read. A page may read it
17
+ * for anything `--wb-*` does not name, and then follows the contract as it changes. It sits on
18
+ * the root's inline style, so a page reads it but does not redeclare it.
19
+ *
20
+ * The literal fallbacks are only for a page opened outside the app, where no token is stamped:
21
+ * they are Primer's values, `light-dark()` picking the one for the mode the root's class (or, with
22
+ * no class, the viewer's system preference) sets.
23
+ *
24
+ * This is a floor, not a framework: it styles the plain HTML an agent writes (headings, lists,
25
+ * forms, tables, code) and gets out of the way. It is injected FIRST in the head, so a page's own
26
+ * rules always win.
15
27
  */
16
28
 
17
29
  :root {
18
30
  color-scheme: light;
19
- --wb-bg: #ffffff;
20
- --wb-surface: var(--color-gray-50, #f9fafb);
21
- --wb-fg: var(--color-gray-900, #111827);
22
- --wb-muted: var(--color-gray-500, #6b7280);
23
- --wb-border: var(--color-gray-200, #e5e7eb);
24
- --wb-hover: var(--color-gray-100, #f3f4f6);
25
- --wb-accent: var(--ui-accent, #111827);
26
- --wb-accent-fg: var(--ui-accent-fg, #ffffff);
27
- --wb-radius: 6px;
31
+
32
+ --wb-bg: var(--ui-canvas, light-dark(#ffffff, #121212));
33
+ --wb-surface: var(--ui-surface-muted, light-dark(#f9fafb, #1a1a1a));
34
+ --wb-fg: var(--ui-fg, light-dark(#111827, #f5f5f5));
35
+ --wb-muted: var(--ui-fg-muted, light-dark(#6b7280, #a1a1a1));
36
+ --wb-border: var(--ui-line, light-dark(#e5e7eb, #333333));
37
+ --wb-hover: var(--ui-fill-neutral, light-dark(#f3f4f6, #262626));
38
+ --wb-accent: var(--ui-accent, light-dark(#111827, #f3f4f6));
39
+ --wb-accent-fg: var(--ui-accent-fg, light-dark(#ffffff, #111827));
40
+ --wb-radius: var(--ui-radius-md, 6px);
28
41
  --wb-font: var(
29
- --font-app-sans,
42
+ --ui-font-ui,
30
43
  ui-sans-serif,
31
44
  system-ui,
32
45
  -apple-system,
@@ -36,7 +49,84 @@
36
49
  "Microsoft YaHei",
37
50
  sans-serif
38
51
  );
39
- --wb-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
52
+ --wb-mono: var(
53
+ --ui-font-mono,
54
+ ui-monospace,
55
+ SFMono-Regular,
56
+ "SF Mono",
57
+ Menlo,
58
+ Consolas,
59
+ monospace
60
+ );
61
+
62
+ /* The semantic tones, picked by meaning: `success` finished well or healthy (a run in progress
63
+ takes it too, its word telling the two apart), `attention` unfinished, waiting on time, a
64
+ queue or the user, `danger` failed or destructive, `done` closed for good, `info` a fact worth
65
+ a colour, `neutral` a kind, or a state that should recede. `fg` is the ink, `bg` the tint a
66
+ badge sits on, `line` its rule. */
67
+ --wb-tone-success-fg: var(
68
+ --ui-tone-success-fg,
69
+ light-dark(oklch(50.8% 0.118 165.612), oklch(76.5% 0.177 163.223))
70
+ );
71
+ --wb-tone-success-bg: var(
72
+ --ui-tone-success-bg,
73
+ light-dark(oklch(97.9% 0.021 166.113), oklch(26.2% 0.051 172.552 / 0.4))
74
+ );
75
+ --wb-tone-success-line: var(
76
+ --ui-tone-success-line,
77
+ light-dark(oklch(84.5% 0.143 164.978), oklch(50.8% 0.118 165.612))
78
+ );
79
+ --wb-tone-attention-fg: var(
80
+ --ui-tone-attention-fg,
81
+ light-dark(oklch(55.5% 0.163 48.998), oklch(82.8% 0.189 84.429))
82
+ );
83
+ --wb-tone-attention-bg: var(
84
+ --ui-tone-attention-bg,
85
+ light-dark(oklch(98.7% 0.022 95.277), oklch(27.9% 0.077 45.635 / 0.4))
86
+ );
87
+ --wb-tone-attention-line: var(
88
+ --ui-tone-attention-line,
89
+ light-dark(oklch(87.9% 0.169 91.605), oklch(55.5% 0.163 48.998))
90
+ );
91
+ --wb-tone-danger-fg: var(
92
+ --ui-tone-danger-fg,
93
+ light-dark(oklch(50.5% 0.213 27.518), oklch(70.4% 0.191 22.216))
94
+ );
95
+ --wb-tone-danger-bg: var(
96
+ --ui-tone-danger-bg,
97
+ light-dark(oklch(97.1% 0.013 17.38), oklch(25.8% 0.092 26.042 / 0.4))
98
+ );
99
+ --wb-tone-danger-line: var(
100
+ --ui-tone-danger-line,
101
+ light-dark(oklch(80.8% 0.114 19.571), oklch(50.5% 0.213 27.518))
102
+ );
103
+ --wb-tone-done-fg: var(
104
+ --ui-tone-done-fg,
105
+ light-dark(oklch(49.6% 0.265 301.924), oklch(71.4% 0.203 305.504))
106
+ );
107
+ --wb-tone-done-bg: var(
108
+ --ui-tone-done-bg,
109
+ light-dark(oklch(97.7% 0.014 308.299), oklch(29.1% 0.149 302.717 / 0.4))
110
+ );
111
+ --wb-tone-done-line: var(
112
+ --ui-tone-done-line,
113
+ light-dark(oklch(82.7% 0.119 306.383), oklch(49.6% 0.265 301.924))
114
+ );
115
+ --wb-tone-neutral-fg: var(--ui-tone-neutral-fg, light-dark(#4b5563, #b0b0b0));
116
+ --wb-tone-neutral-bg: var(--ui-tone-neutral-bg, light-dark(#f3f4f6, #262626));
117
+ --wb-tone-neutral-line: var(--ui-tone-neutral-line, light-dark(#e5e7eb, #262626));
118
+ --wb-tone-info-fg: var(
119
+ --ui-tone-info-fg,
120
+ light-dark(oklch(50% 0.134 242.749), oklch(74.6% 0.16 232.661))
121
+ );
122
+ --wb-tone-info-bg: var(
123
+ --ui-tone-info-bg,
124
+ light-dark(oklch(97.7% 0.013 236.62), oklch(29.3% 0.066 243.157 / 0.4))
125
+ );
126
+ --wb-tone-info-line: var(
127
+ --ui-tone-info-line,
128
+ light-dark(oklch(82.8% 0.111 230.318), oklch(50% 0.134 242.749))
129
+ );
40
130
  }
41
131
 
42
132
  /* The app stamps `dark` or `light` on the root; `prefers-color-scheme` only decides for a
@@ -44,23 +134,11 @@
44
134
  @media (prefers-color-scheme: dark) {
45
135
  :root:not(.light) {
46
136
  color-scheme: dark;
47
- --wb-bg: var(--color-gray-950, #121212);
48
- --wb-surface: var(--color-gray-900, #1a1a1a);
49
- --wb-fg: var(--color-gray-100, #f5f5f5);
50
- --wb-muted: var(--color-gray-400, #a1a1a1);
51
- --wb-border: var(--color-gray-700, #333333);
52
- --wb-hover: var(--color-gray-800, #262626);
53
137
  }
54
138
  }
55
139
 
56
140
  :root.dark {
57
141
  color-scheme: dark;
58
- --wb-bg: var(--color-gray-950, #121212);
59
- --wb-surface: var(--color-gray-900, #1a1a1a);
60
- --wb-fg: var(--color-gray-100, #f5f5f5);
61
- --wb-muted: var(--color-gray-400, #a1a1a1);
62
- --wb-border: var(--color-gray-700, #333333);
63
- --wb-hover: var(--color-gray-800, #262626);
64
142
  }
65
143
 
66
144
  body {
@@ -69,7 +147,7 @@ body {
69
147
  background: var(--wb-bg);
70
148
  color: var(--wb-fg);
71
149
  font-family: var(--wb-font);
72
- font-size: 0.875rem;
150
+ font-size: var(--ui-text-body-size, 0.875rem);
73
151
  line-height: 1.6;
74
152
  }
75
153
 
@@ -150,7 +228,7 @@ code,
150
228
  kbd,
151
229
  samp {
152
230
  font-family: var(--wb-mono);
153
- font-size: 0.8125rem;
231
+ font-size: var(--ui-text-code-size, 0.8125rem);
154
232
  }
155
233
  code {
156
234
  background: var(--wb-surface);
@@ -253,6 +331,58 @@ button.wb-primary:hover:not(:disabled) {
253
331
  flex-wrap: wrap;
254
332
  }
255
333
 
334
+ /* A short label beside a name — a state, a kind, a fact — drawn the way the app draws its label
335
+ pills: the tone's tint under its ink, the theme's pill radius, tag type and (where the theme
336
+ draws one) an inset rule in the tone's line. `data-tone` picks the tone; none is `neutral`.
337
+ Colour never carries the state alone: the word on the badge does. */
338
+ .wb-badge {
339
+ --_wb-badge-fg: var(--wb-tone-neutral-fg);
340
+ --_wb-badge-bg: var(--wb-tone-neutral-bg);
341
+ --_wb-badge-line: var(--wb-tone-neutral-line);
342
+ display: inline-flex;
343
+ flex-shrink: 0;
344
+ align-items: center;
345
+ white-space: nowrap;
346
+ padding: 1px calc(var(--ui-space-unit, 0.25rem) * 1.5);
347
+ border-radius: var(--ui-radius-pill, 9999px);
348
+ color: var(--_wb-badge-fg);
349
+ background: var(--_wb-badge-bg);
350
+ box-shadow: inset 0 0 0 var(--ui-badge-soft-ring, 0px) var(--_wb-badge-line);
351
+ font-size: var(--ui-badge-size, 0.6875rem);
352
+ line-height: var(--ui-badge-lh, 1rem);
353
+ font-weight: var(--ui-badge-weight, 600);
354
+ }
355
+ .wb-badge[data-tone="success"] {
356
+ --_wb-badge-fg: var(--wb-tone-success-fg);
357
+ --_wb-badge-bg: var(--wb-tone-success-bg);
358
+ --_wb-badge-line: var(--wb-tone-success-line);
359
+ }
360
+ .wb-badge[data-tone="attention"] {
361
+ --_wb-badge-fg: var(--wb-tone-attention-fg);
362
+ --_wb-badge-bg: var(--wb-tone-attention-bg);
363
+ --_wb-badge-line: var(--wb-tone-attention-line);
364
+ }
365
+ .wb-badge[data-tone="danger"] {
366
+ --_wb-badge-fg: var(--wb-tone-danger-fg);
367
+ --_wb-badge-bg: var(--wb-tone-danger-bg);
368
+ --_wb-badge-line: var(--wb-tone-danger-line);
369
+ }
370
+ .wb-badge[data-tone="done"] {
371
+ --_wb-badge-fg: var(--wb-tone-done-fg);
372
+ --_wb-badge-bg: var(--wb-tone-done-bg);
373
+ --_wb-badge-line: var(--wb-tone-done-line);
374
+ }
375
+ .wb-badge[data-tone="neutral"] {
376
+ --_wb-badge-fg: var(--wb-tone-neutral-fg);
377
+ --_wb-badge-bg: var(--wb-tone-neutral-bg);
378
+ --_wb-badge-line: var(--wb-tone-neutral-line);
379
+ }
380
+ .wb-badge[data-tone="info"] {
381
+ --_wb-badge-fg: var(--wb-tone-info-fg);
382
+ --_wb-badge-bg: var(--wb-tone-info-bg);
383
+ --_wb-badge-line: var(--wb-tone-info-line);
384
+ }
385
+
256
386
  @media (prefers-reduced-motion: reduce) {
257
387
  * {
258
388
  transition: none !important;
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/auth/password.ts","../src/auth/service.ts","../src/auth/api-token.ts","../src/http/errors.ts"],"sourcesContent":["import { Component, Interface } from \"@prismshadow/penguin-core/kernel\";\n/**\n * Password hashing (slow-hash storage).\n *\n * Uses node:crypto's scrypt (built-in, no extra dependency, meets the same\n * slow-hash requirement as bcrypt/argon2). Storage format:\n * `scrypt$N$r$p$<salt b64>$<hash b64>` — parameters are stored alongside the hash,\n * so old hashes remain verifiable after future parameter tuning; comparison uses\n * timingSafeEqual to guard against timing side-channels, and a sign-in for an account\n * that does not exist costs the same derivation as a wrong password\n * (verifyAccountPassword).\n */\nimport { randomBytes, scrypt, timingSafeEqual } from \"node:crypto\";\n\n/**\n * Work factor for new hashes. `hashPassword` takes it as a defaulted argument so the server's\n * own test suite can hash at a token cost: almost every case there seeds an admin, provisions\n * users and logs them in, and one derivation at this strength costs on the order of 100ms.\n * Nothing on the production path passes the argument, and no configuration reaches it —\n * `buildAppDeps`, which carries the test override, is not part of this package's exports.\n */\nexport const SCRYPT_COST = 16384;\nconst SCRYPT_R = 8;\nconst SCRYPT_P = 1;\nconst SALT_BYTES = 16;\nconst KEY_BYTES = 64;\n\nfunction scryptAsync(\n password: string,\n salt: Buffer,\n keyLen: number,\n n: number,\n r: number,\n p: number,\n): Promise<Buffer> {\n return new Promise((resolve, reject) => {\n scrypt(password, salt, keyLen, { N: n, r, p, maxmem: 128 * 1024 * 1024 }, (err, key) => {\n if (err) reject(err);\n else resolve(key);\n });\n });\n}\n\n/**\n * Generates a password hash in `scrypt$N$r$p$salt$hash` format. `cost` is scrypt's N and\n * is recorded in the hash, so `verifyPassword` re-derives at whatever cost produced the\n * stored string.\n */\nexport async function hashPassword(password: string, cost: number = SCRYPT_COST): Promise<string> {\n const salt = randomBytes(SALT_BYTES);\n const key = await scryptAsync(password, salt, KEY_BYTES, cost, SCRYPT_R, SCRYPT_P);\n return [\n \"scrypt\",\n String(cost),\n String(SCRYPT_R),\n String(SCRYPT_P),\n salt.toString(\"base64\"),\n key.toString(\"base64\"),\n ].join(\"$\");\n}\n\n/**\n * What checking a password against a stored string found. `match` and `mismatch` each cost one\n * scrypt derivation; `unverifiable` — not the `scrypt$N$r$p$salt$hash` format, or parameters\n * scrypt refuses — cost none.\n */\nexport type PasswordCheck = \"match\" | \"mismatch\" | \"unverifiable\";\n\n/** Checks a password against a stored hash. Never throws. */\nexport async function checkPassword(password: string, stored: string): Promise<PasswordCheck> {\n const parts = stored.split(\"$\");\n if (parts.length !== 6 || parts[0] !== \"scrypt\") return \"unverifiable\";\n const n = Number(parts[1]);\n const r = Number(parts[2]);\n const p = Number(parts[3]);\n if (!Number.isInteger(n) || !Number.isInteger(r) || !Number.isInteger(p)) return \"unverifiable\";\n const salt = Buffer.from(parts[4]!, \"base64\");\n const expected = Buffer.from(parts[5]!, \"base64\");\n if (salt.length === 0 || expected.length === 0) return \"unverifiable\";\n let actual: Buffer;\n try {\n actual = await scryptAsync(password, salt, expected.length, n, r, p);\n } catch {\n return \"unverifiable\";\n }\n return timingSafeEqual(actual, expected) ? \"match\" : \"mismatch\";\n}\n\n/** Verifies a password; returns false if the stored string has an invalid format (never throws, so the login path can uniformly treat it as a credential error). */\nexport async function verifyPassword(password: string, stored: string): Promise<boolean> {\n return (await checkPassword(password, stored)) === \"match\";\n}\n\n/**\n * Verifies a sign-in password for an account that may not exist, at the cost a real account's\n * check has. `stored` is the account's hash, or null when there is no such account. When there is\n * nothing to derive against — no account, an empty hash, or one `checkPassword` finds\n * unverifiable — the password is checked against `dummyHash` instead and the result is false, so\n * every call runs exactly one scrypt derivation and how long a failure takes does not tell a\n * missing username from a wrong password. `check` is a parameter so a test can count the\n * derivations.\n */\nexport async function verifyAccountPassword(\n password: string,\n stored: string | null,\n dummyHash: () => Promise<string>,\n check: (password: string, stored: string) => Promise<PasswordCheck> = checkPassword,\n): Promise<boolean> {\n const outcome = stored === null ? \"unverifiable\" : await check(password, stored);\n if (outcome !== \"unverifiable\") return outcome === \"match\";\n await check(password, await dummyHash());\n return false;\n}\n\n/** Hashes the passwords this server writes; a test stands in a cheap one. */\n@Interface()\nexport abstract class PasswordHasher {\n abstract hash(password: string): Promise<string>;\n}\n\n/** scrypt at full strength. */\n@Component()\nexport class ScryptHasher implements PasswordHasher {\n hash(password: string): Promise<string> {\n return hashPassword(password, SCRYPT_COST);\n }\n}\n","/**\n * Auth service: admin seeding / login / logout / password change / session validation.\n *\n * No open registration: an empty users table seeds `admin` with a random password hashed and\n * discarded unseen, claimed through the first-login link; every other user is created by an\n * admin. Sessions are rows in auth_sessions (cookie holds the token, the row its sha256), so\n * they outlive a restart and renew in place.\n */\nimport { randomBytes } from \"node:crypto\";\nimport { tokensEqual } from \"./api-token.js\";\nimport type { UserInfo } from \"../api/types.js\";\nimport { HttpError } from \"../http/errors.js\";\nimport type { UserRow } from \"../db/repos/users.js\";\nimport { sessionTokenHash } from \"../db/repos/auth-sessions.js\";\nimport type { SessionViaValue, AuthSessionsRepo } from \"../db/repos/auth-sessions.js\";\nimport type { AuthRuntimeState } from \"./runtime-state.js\";\nimport { verifyAccountPassword, verifyPassword } from \"./password.js\";\nimport type { PasswordHasher } from \"./password.js\";\nimport { Component, Use, Interface } from \"@prismshadow/penguin-core/kernel\";\nimport type { AuthState, Clock, Config } from \"../hmr/capabilities.js\";\nimport type { Auth, AuthSessions, Users } from \"../mechanisms/identity.js\";\n\nexport const MIN_PASSWORD_LENGTH = 8;\nexport const REMOTE_SESSION_TTL_MS = 60 * 60_000;\n\n/** Built-in admin user_id. */\nexport const ADMIN_USER_ID = \"admin\";\n\n/**\n * Login throttling, per userId. After LOGIN_FREE_ATTEMPTS failures each attempt waits an\n * exponentially growing delay (1s doubling to a 60s cap), settling at a guess per minute.\n * Kept for nonexistent userIds too, so it is not an account-existence oracle — and neither is\n * the time a failure takes: a nonexistent userId is checked against a dummy hash (loginDummyHash).\n * Deliberately NOT covered: a concurrent burst before the first failure lands, and guesses\n * spread across many accounts.\n */\nconst LOGIN_FREE_ATTEMPTS = 5;\nconst LOGIN_BACKOFF_START_MS = 1000;\nconst LOGIN_BACKOFF_CAP_MS = 60_000;\n/** Failure entries idle longer than this are swept (bounds the map; far above the cap). */\nconst LOGIN_FAILURE_IDLE_MS = 15 * 60_000;\n\n/** Characters of base64url in a seeded password — 18 random bytes, 144 bits. */\nconst SEED_PASSWORD_CHARS = 24;\n\n/**\n * Never read or typed — hashed at once and discarded — which is what lets it be long enough\n * that the login endpoint, reachable the moment the account exists, has no search space.\n */\nexport function generateInitialAdminPassword(): string {\n return randomBytes(SEED_PASSWORD_CHARS).toString(\"base64url\").slice(0, SEED_PASSWORD_CHARS);\n}\n\n/**\n * \"desktop\" and \"setup\" may set a password without the old one (theirs is random and was never\n * shown); desktop-only routes open to \"desktop\" alone. \"token\" is the local API token's\n * authority, whether presented as a Bearer header or exchanged for a Remote cookie.\n * Exchanging the credential must not grant the person's privileges. Anything else reads as\n * \"password\".\n */\nexport type SessionVia = \"password\" | \"desktop\" | \"setup\" | \"token\";\n\n/** Row -> DTO. The two profile columns are omitted rather than sent as null when unset. */\nexport function toUserInfo(row: UserRow): UserInfo {\n return {\n userId: row.userId,\n isAdmin: row.isAdmin,\n passwordIsInitial: row.passwordIsInitial,\n ...(row.displayName !== null ? { displayName: row.displayName } : {}),\n ...(row.avatar !== null ? { avatar: row.avatar } : {}),\n createdAt: row.createdAt,\n };\n}\n\n@Component()\nexport class AuthService implements Auth {\n @Use() private readonly users!: Users;\n @Use() private readonly authSessions!: AuthSessions;\n /**\n * Process-scoped auth values (runtime-state.ts). Held by the RUNTIME so the link a boot\n * printed survives a platform push; everything else about auth is rebuilt with the App.\n */\n @Use() private readonly state!: AuthState;\n /** Provisions the initial Project at signup — declared at the consumer, below. */\n @Use() private readonly provisioner!: InitialProjectProvisioner;\n @Use() private readonly config!: Config;\n @Use() private readonly clock!: Clock;\n @Use() private readonly hasher!: PasswordHasher;\n /** Session lifetime, for the cookie that must expire WITH the session, not before it. */\n get sessionTtlMs(): number {\n return this.config.authSessionTtlMs;\n }\n private get sessionRenewMs(): number {\n return this.config.authSessionRenewMs;\n }\n /** Fixed initial password for the seeded admin; null generates a random one at seed time. */\n private get seedAdminPassword(): string | null {\n return this.config.seedAdminPassword;\n }\n\n setup(): void {\n this.authSessions.deleteExpired(this.clock.now().toISOString());\n }\n\n /**\n * Null once the server is claimed, so the only setup session that exists is a printed one.\n * On demand rather than in the constructor: seedAdmin() runs after it, so \"claimed?\" has no\n * answer there. A cached link whose row is gone is re-minted, not handed out dead.\n */\n mintFirstLogin(): string | null {\n if (!this.adminPasswordIsInitial()) return null;\n if (\n this.state.firstLoginToken !== null &&\n this.authenticateWithMeta(this.state.firstLoginToken) === null\n ) {\n this.state.firstLoginToken = null;\n }\n this.state.firstLoginToken ??= this.issueSession(ADMIN_USER_ID, \"setup\");\n return this.state.firstLoginToken;\n }\n\n /**\n * For the startup notice's pinned-seed gate (index.ts): a pin usually means the operator\n * knows the password, but an offline reset makes it stale, and the gate must see through\n * that or the rescue link stays suppressed.\n */\n async adminPasswordIs(password: string): Promise<boolean> {\n const row = this.users.findById(ADMIN_USER_ID);\n return row !== null && (await verifyPassword(password, row.passwordHash));\n }\n\n /**\n * Startup seeding (idempotent): creates the built-in admin and adopts default_project when\n * the users table is empty; if the initial Project fails, the user row is rolled back and\n * the server retries on next startup.\n */\n async seedAdmin(): Promise<void> {\n if (this.users.count() > 0) return;\n const password = this.seedAdminPassword ?? generateInitialAdminPassword();\n // A pinned override must meet the same policy as every other password — rejected before\n // any insert, so a configuration typo cannot create a trivially weak privileged account.\n if (password.length < MIN_PASSWORD_LENGTH) {\n throw new Error(\n `PENGUIN_SEED_ADMIN_PASSWORD must be at least ${MIN_PASSWORD_LENGTH} characters.`,\n );\n }\n const user: UserRow = {\n userId: ADMIN_USER_ID,\n passwordHash: await this.hasher.hash(password),\n isAdmin: true,\n passwordIsInitial: true,\n displayName: null,\n avatar: null,\n createdAt: this.clock.now().toISOString(),\n };\n this.users.insert(user);\n try {\n await this.provisioner.provisionInitialProject(user, true);\n } catch (err) {\n this.users.delete(user.userId);\n throw err;\n }\n }\n\n /**\n * Compared against the printed value, not merely verified: a cookie made out of ANY valid\n * token would let one person hand another a link into the sender's account. Not single-use,\n * because a prefetching browser would burn it before its reader clicked.\n */\n redeemFirstLogin(given: string): string | null {\n const expected = this.state.firstLoginToken;\n if (expected === null || given === \"\" || !tokensEqual(given, expected)) return null;\n return this.authenticateWithMeta(expected) === null ? null : expected;\n }\n\n /** Whether the built-in admin still runs on its initial password (gates the first-login link). */\n adminPasswordIsInitial(): boolean {\n return this.users.findById(ADMIN_USER_ID)?.passwordIsInitial === true;\n }\n\n /** Consecutive login failures per userId (see the throttling comment on the constants). */\n private readonly loginFailures = new Map<string, { failures: number; lastFailureAt: number }>();\n\n /** Cache for loginDummyHash. */\n private dummyHash: string | null = null;\n\n /**\n * The hash a sign-in with no account to check is verified against (verifyAccountPassword), so\n * it costs what a wrong password costs. Made by this server's own hasher, hence at the cost its\n * real hashes carry, from a random password nobody holds; computed on the first such sign-in\n * and kept.\n */\n private async loginDummyHash(): Promise<string> {\n this.dummyHash ??= await this.hasher.hash(randomBytes(18).toString(\"base64url\"));\n return this.dummyHash;\n }\n\n /** The wait imposed after `failures` consecutive failures (0 while within the free attempts). */\n private loginDelayMs(failures: number): number {\n const excess = failures - LOGIN_FREE_ATTEMPTS;\n if (excess <= 0) return 0;\n return Math.min(LOGIN_BACKOFF_START_MS * 2 ** (excess - 1), LOGIN_BACKOFF_CAP_MS);\n }\n\n async login(userId: string, password: string): Promise<{ user: UserInfo; token: string }> {\n const nowMs = this.clock.now().getTime();\n for (const [key, entry] of this.loginFailures) {\n if (nowMs - entry.lastFailureAt > LOGIN_FAILURE_IDLE_MS) this.loginFailures.delete(key);\n }\n const failed = this.loginFailures.get(userId);\n if (failed) {\n const readyAt = failed.lastFailureAt + this.loginDelayMs(failed.failures);\n if (nowMs < readyAt) {\n throw new HttpError(\n 429,\n \"too_many_attempts\",\n `Too many failed sign-in attempts. Try again in ${Math.ceil((readyAt - nowMs) / 1000)}s.`,\n );\n }\n }\n const row = this.users.findById(userId);\n // A missing account, or one whose hash cannot be checked, still costs one scrypt\n // derivation, and fails with the same 401 as a wrong password.\n const ok = await verifyAccountPassword(password, row?.passwordHash ?? null, () =>\n this.loginDummyHash(),\n );\n if (!row || !ok) {\n this.loginFailures.set(userId, {\n failures: (failed?.failures ?? 0) + 1,\n lastFailureAt: this.clock.now().getTime(),\n });\n throw new HttpError(401, \"invalid_credentials\", \"Incorrect username or password.\");\n }\n this.loginFailures.delete(userId);\n this.authSessions.deleteExpired(this.clock.now().toISOString());\n return { user: toUserInfo(row), token: this.issueSession(row.userId, \"password\") };\n }\n\n /**\n * Whether a user is an admin, by id — for a caller that has a user's NAME rather than an\n * authenticated request: the terminal relay reads the owner out of a pty reference the\n * runtime has already matched against the signed-in user (machines/terminal-relay.ts), and\n * what is left to decide is whether that user may reach machines at all. Unknown users are\n * not admins.\n */\n isAdmin(userId: string): boolean {\n return this.users.findById(userId)?.isAdmin === true;\n }\n\n /**\n * Desktop-mode sign-in: an admin session with no password check — the claim route already\n * redeemed the shell's one-shot token, which is the credential here. Throws only on a\n * broken deployment (seeding runs before the route exists).\n */\n loginDesktop(): { user: UserInfo; token: string } {\n const row = this.users.findById(ADMIN_USER_ID);\n if (!row) {\n throw new HttpError(500, \"internal\", \"Built-in admin has not been seeded.\");\n }\n return { user: toUserInfo(row), token: this.issueSession(row.userId, \"desktop\") };\n }\n\n issueRemoteSession(): { token: string; expiresAt: string; maxAgeSeconds: number } {\n const row = this.users.findById(ADMIN_USER_ID);\n if (!row) {\n throw new HttpError(500, \"internal\", \"Built-in admin has not been seeded.\");\n }\n const maxAgeSeconds = Math.floor(REMOTE_SESSION_TTL_MS / 1000);\n return {\n ...this.authSessions.issue({\n userId: row.userId,\n via: \"remote\",\n now: this.clock.now(),\n ttlMs: REMOTE_SESSION_TTL_MS,\n }),\n maxAgeSeconds,\n };\n }\n\n /** Self password change (user settings): validates the old password first; the current session stays valid. */\n async changePassword(userId: string, oldPassword: string, newPassword: string): Promise<void> {\n const row = this.users.findById(userId);\n if (!row || !(await verifyPassword(oldPassword, row.passwordHash))) {\n throw new HttpError(400, \"password_mismatch\", \"Current password is incorrect.\");\n }\n await this.setPassword(userId, newPassword);\n }\n\n /** No old-password check; the me route gates which sessions may call this. */\n async setInitialPassword(userId: string, newPassword: string): Promise<void> {\n await this.setPassword(userId, newPassword);\n }\n\n /**\n * Validation comes FIRST, so a rejected password leaves the first-login link alive: burning\n * it on a typo would strand the claimer until a restart.\n */\n private async setPassword(userId: string, newPassword: string): Promise<void> {\n if (newPassword.length < MIN_PASSWORD_LENGTH) {\n throw new HttpError(400, \"invalid_password\", \"Password must be at least 8 characters.\");\n }\n this.users.updatePassword(userId, await this.hasher.hash(newPassword), false);\n // A successful set proves at least what the successful login that resets the counter\n // proves (the old password, or a desktop/setup session), so it resets it too. Without\n // this, anyone spamming the login endpoint holds the backoff window open, and the sign-in\n // that follows a first-login claim (routes/me.ts) would 429 AFTER the password committed —\n // reporting failure for a change that took, with the claimer's setup session already gone.\n this.loginFailures.delete(userId);\n // EVERY first-login session for this account, not just the link this process printed: an\n // earlier boot's link can still be live in a terminal scrollback, and a `setup` session is\n // allowed to change the password without knowing the old one — so one left behind is an\n // account takeover waiting to happen.\n if (userId === ADMIN_USER_ID) {\n this.authSessions.deleteByUserAndVia(userId, \"setup\");\n this.state.firstLoginToken = null;\n }\n }\n\n /** Ends a session: the row is the session, so logout deletes it. Unknown token is a no-op. */\n logout(token: string): void {\n this.authSessions.delete(sessionTokenHash(token));\n }\n\n /**\n * The current boot's local API token (what control-env injection hands to tool\n * subprocesses); null when none was minted. It lives on the runtime state, not on this\n * service: the token was written to `<root>/api-token` by the process, so it must\n * outlive the App a push replaces (auth/runtime-state.ts).\n */\n localApiToken(): string | null {\n return this.state.apiToken;\n }\n\n /**\n * Validates a Bearer token against the boot's local API token (constant-time compare):\n * a match authenticates as the built-in admin — holding the token proves filesystem\n * access to the data root, which is admin authority (see auth/api-token.ts). Returns\n * null on mismatch, when no token was minted, or when the admin row is missing.\n */\n authenticateApiToken(token: string): { user: UserRow; via: SessionVia } | null {\n const apiToken = this.state.apiToken;\n if (apiToken === null || token.length === 0) return null;\n if (!tokensEqual(token, apiToken)) return null;\n const user = this.users.findById(ADMIN_USER_ID);\n return user === null ? null : { user, via: \"token\" };\n }\n\n /**\n * Validates the cookie token. Sliding renewal tops the expiry up IN PLACE, so the cookie\n * value never changes and there is no second identity to revoke. Only a session whose own\n * span reaches the renewal window slides — a one-hour minted token must expire at its hour,\n * not stretch by being used.\n */\n authenticateWithMeta(token: string): { user: UserRow; via: SessionVia; renewed: boolean } | null {\n const tokenHash = sessionTokenHash(token);\n const session = this.authSessions.findByTokenHash(tokenHash);\n if (!session) return null;\n const now = this.clock.now();\n const expiresAt = Date.parse(session.expiresAt);\n if (expiresAt <= now.getTime()) {\n this.authSessions.delete(tokenHash);\n return null;\n }\n const user = this.users.findById(session.userId);\n if (!user) return null;\n const renewable = expiresAt - Date.parse(session.createdAt) >= this.sessionRenewMs;\n let renewed = false;\n if (renewable && expiresAt - now.getTime() < this.sessionRenewMs) {\n this.authSessions.touch(tokenHash, new Date(now.getTime() + this.sessionTtlMs).toISOString());\n renewed = true;\n }\n const via: SessionVia =\n session.via === \"remote\"\n ? \"token\"\n : session.via === \"desktop\"\n ? \"desktop\"\n : session.via === \"setup\"\n ? \"setup\"\n : \"password\";\n return { user, via, renewed };\n }\n\n /**\n * Whether the session behind a cookie token still exists and has not expired — the same\n * two facts {@link authenticateWithMeta} establishes, without its sliding renewal or its\n * user lookup. A connection that outlives the request that opened it has to re-ask\n * periodically (the SSE heartbeat does, once per beat), and asking through the renewing\n * path would top the expiry up every time: a window nobody has touched since last week\n * would stay signed in purely because it is still connected.\n */\n sessionIsLive(token: string): boolean {\n const session = this.authSessions.findByTokenHash(sessionTokenHash(token));\n if (!session) return false;\n return Date.parse(session.expiresAt) > this.clock.now().getTime();\n }\n\n private issueSession(userId: string, via: SessionViaValue): string {\n return this.authSessions.issue({\n userId,\n via,\n now: this.clock.now(),\n ttlMs: this.sessionTtlMs,\n }).token;\n }\n}\n\n/** What signing a new user in needs of project administration — declared at the consumer. */\n@Interface()\nexport abstract class InitialProjectProvisioner {\n abstract provisionInitialProject(user: UserRow, isAdmin: boolean): Promise<void>;\n}\n","/**\n * Local API token (`<root>/api-token`): the machine-local credential behind\n * `Authorization: Bearer`.\n *\n * Minted fresh at every server boot (same recipe as auth-session tokens) and written to\n * the data root with owner-only permissions, so anything that can read the file can call\n * the API as the admin. That equivalence is the authorization model, not an accident:\n * local filesystem access to the data root already IS admin authority — the same rule\n * `penguin server reset-admin-password` stands on (whoever can run it owns web.db\n * anyway) — and agents driving their own harness through the CLI is the product feature\n * this token exists for (server-driven Sessions hand it to tool subprocesses as\n * PENGUIN_API_TOKEN). Rotation per boot bounds the life of any leaked copy to the\n * process that minted it.\n */\nimport { createHash, randomBytes, timingSafeEqual } from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nexport function apiTokenPath(root: string): string {\n return path.join(root, \"api-token\");\n}\n\n/** Mints a boot-scoped local API token (the auth-session token recipe). */\nexport function mintApiToken(): string {\n return randomBytes(32).toString(\"base64url\");\n}\n\n/**\n * Persists the boot token (owner-only file, tmp + rename so a concurrent reader never\n * sees a partial write). Best-effort like the initial-password file: an exotic read-only\n * root must not stop the server — local CLI callers then fall back to\n * PENGUIN_API_TOKEN.\n */\nexport function storeApiToken(root: string, token: string): void {\n try {\n fs.mkdirSync(root, { recursive: true });\n const target = apiTokenPath(root);\n const tmp = `${target}.${process.pid}.tmp`;\n fs.writeFileSync(tmp, `${token}\\n`, { mode: 0o600 });\n fs.renameSync(tmp, target);\n } catch {\n // Best-effort: Bearer auth still works for callers holding the token some other way.\n }\n}\n\n/** The stored token, or null when absent/unreadable/empty (shared with the CLI's file fallback). */\nexport function readApiToken(root: string): string | null {\n try {\n const value = fs.readFileSync(apiTokenPath(root), \"utf8\").trim();\n return value === \"\" ? null : value;\n } catch {\n return null;\n }\n}\n\n/**\n * Constant-time equality for token checks: both sides are reduced to fixed-size sha256\n * digests first, so the comparison's timing depends on neither the content nor the\n * length of an attacker-supplied value.\n */\nexport function tokensEqual(a: string, b: string): boolean {\n const digest = (v: string): Buffer => createHash(\"sha256\").update(v).digest();\n return timingSafeEqual(digest(a), digest(b));\n}\n","/**\n * Unified HTTP error: `{error: {code, message, details?}}` response body,\n * with message in English.\n *\n * Routes and services express business errors via throw HttpError; app-level onError\n * uniformly converges these into a JSON response, with unknown errors converged to 500\n * (never leaking internal details to the client).\n *\n * `details` carries the facts a client acts on beside the code — the id a 409 is about, say — so\n * that no client has to parse them out of the message, which is prose and may change.\n */\nimport type { Context } from \"hono\";\nimport type { ErrorBody, ErrorDetails } from \"../api/types.js\";\n\nexport class HttpError extends Error {\n constructor(\n readonly status: number,\n readonly code: string,\n message: string,\n readonly retryAfterSeconds?: number,\n readonly details?: ErrorDetails,\n ) {\n super(message);\n this.name = \"HttpError\";\n }\n}\n\n/** A 400 for a request the route cannot take as it is; validate.ts re-exports it beside its checks. */\nexport function badRequest(message: string): HttpError {\n return new HttpError(400, \"bad_request\", message);\n}\n\nexport function errorBody(code: string, message: string, details?: ErrorDetails): ErrorBody {\n return { error: { code, message, ...(details !== undefined ? { details } : {}) } };\n}\n\n/**\n * Model missing a credential: the provider SDK throws this at **client-construction\n * time** (hit by both creating a Session and resuming a Session); the original message\n * is full of environment variable names, meaningless to a user — uniformly replaced\n * with a single actionable sentence. The frontend produces localized text by code\n * (message is only a fallback); see web's lib/api-error.ts.\n */\nexport function isMissingCredential(err: unknown): boolean {\n const message = err instanceof Error ? err.message : String(err);\n return /missing credentials|api[_ ]?key/i.test(message);\n}\n\nexport function modelCredentialMissing(modelId: string): HttpError {\n return new HttpError(\n 400,\n \"model_credential_missing\",\n `Model ${modelId} has no API key yet. Configure it on the Models page first.`,\n );\n}\n\n/** app.onError handler: maps HttpError through as-is; everything else is logged and converged to 500. */\nexport function handleError(err: Error, c: Context): Response {\n if (err instanceof HttpError) {\n if (err.retryAfterSeconds !== undefined) {\n c.header(\"Retry-After\", String(err.retryAfterSeconds));\n }\n return c.json(errorBody(err.code, err.message, err.details), err.status as 400);\n }\n // Unknown error: print the stack for diagnosis, but never expose details externally.\n console.error(`[server] Unhandled exception: ${err.stack ?? err.message}`);\n return c.json(errorBody(\"internal\", \"Internal server error.\"), 500);\n}\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,WAAW,iBAAiB;AAYrC,SAAS,aAAa,QAAQ,uBAAuB;AAS9C,IAAM,cAAc;AAC3B,IAAM,WAAW;AACjB,IAAM,WAAW;AACjB,IAAM,aAAa;AACnB,IAAM,YAAY;AAElB,SAAS,YACP,UACA,MACA,QACA,GACA,GACA,GACiB;AACjB,SAAO,IAAI,QAAQ,CAAC,SAAS,W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