@dudko.dev/agent-web-react 0.0.42 → 0.0.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/styles.css CHANGED
@@ -18,6 +18,8 @@
18
18
  --awr-accent-fg: #ffffff;
19
19
  --awr-assistant-bg: #f3f4f6;
20
20
  --awr-danger: #dc2626;
21
+ /* Text and icons on a solid --awr-danger (the listening mic). */
22
+ --awr-danger-fg: #ffffff;
21
23
  --awr-warn: #b45309;
22
24
  --awr-ok: #16a34a;
23
25
  --awr-radius: 12px;
@@ -40,6 +42,7 @@
40
42
  --awr-accent: #6366f1;
41
43
  --awr-assistant-bg: #1a1e27;
42
44
  --awr-danger: #f87171;
45
+ --awr-danger-fg: #1c0606;
43
46
  --awr-warn: #fbbf24;
44
47
  --awr-ok: #4ade80;
45
48
  --awr-scrim: rgb(0 0 0 / 0.5);
@@ -54,6 +57,7 @@
54
57
  --awr-accent: #6366f1;
55
58
  --awr-assistant-bg: #1a1e27;
56
59
  --awr-danger: #f87171;
60
+ --awr-danger-fg: #1c0606;
57
61
  --awr-warn: #fbbf24;
58
62
  --awr-ok: #4ade80;
59
63
  --awr-scrim: rgb(0 0 0 / 0.5);
@@ -99,21 +103,34 @@
99
103
  }
100
104
  .awr-chat__closeside {
101
105
  display: none;
102
- position: absolute;
103
- top: 6px;
104
- right: 6px;
105
106
  font-size: 18px;
106
107
  line-height: 1;
107
108
  }
108
- /* Narrow panels: the side panels overlay the chat instead of squeezing it. */
109
+ /* A side panel's × belongs to the narrow layout only (`.awr-iconbtn`, later in this sheet, would
110
+ show it on a wide chat too). */
111
+ .awr-chat:not(.awr-chat--narrow) .awr-chat__closeside {
112
+ display: none;
113
+ }
114
+ /* What `slots.sidebar` holds lays out as if it had no wrapper; the narrow panel's rules below
115
+ leave it alone. */
116
+ .awr-chat__slot {
117
+ display: contents;
118
+ }
119
+ /* Narrow panels (a phone): the side panels overlay the chat instead of squeezing it, with a
120
+ strip of the shaded chat left beside them (a tap on it closes the panel). The panel scrolls
121
+ by itself - never the page behind it - and its header row stays on top while it does. */
109
122
  .awr-chat--narrow > .awr-chat__sidebar,
110
123
  .awr-chat--narrow > .awr-chat__files {
111
124
  position: absolute;
112
125
  top: 0;
113
126
  bottom: 0;
114
127
  z-index: 5;
115
- width: min(85%, 320px);
128
+ width: min(88%, 360px);
116
129
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
130
+ overscroll-behavior: contain;
131
+ /* A row the focus moves to is scrolled clear of the sticky header bar (56 px and its line). */
132
+ scroll-padding-top: 64px;
133
+ outline: none;
117
134
  }
118
135
  /* Beside an open side panel: the chat under a shade, and a tap on it closes the panel. */
119
136
  .awr-chat__scrim {
@@ -135,10 +152,142 @@
135
152
  .awr-chat--narrow .awr-status__text {
136
153
  display: none;
137
154
  }
138
- /* The close button sits in the panel's header row on a narrow panel. */
139
- .awr-chat--narrow .awr-chat__sidebar .awr-panel__head,
140
- .awr-chat--narrow .awr-chat__files .awr-panel__head {
141
- padding-right: 40px;
155
+ /* A host's own panel that draws no `headerEnd`: its × in the corner. */
156
+ .awr-chat--narrow > .awr-chat__sidebar > .awr-chat__closeside--corner,
157
+ .awr-chat--narrow > .awr-chat__files > .awr-chat__closeside--corner {
158
+ position: absolute;
159
+ top: 6px;
160
+ right: 6px;
161
+ width: 44px;
162
+ height: 44px;
163
+ z-index: 2;
164
+ }
165
+ /* The panel itself (the chats list, the files panel - also inside a host's own component; never
166
+ what `slots.sidebar` holds) on a narrow chat. Its wrapper steps aside (`display: contents`:
167
+ a box style given to it with `className` does not show here) so the header row sticks to the
168
+ top of the WHOLE panel - list, preview and whatever is under them scroll beneath it - and
169
+ what it holds keeps its height (a flex item that scrolls by itself, the file preview, would
170
+ be squeezed). */
171
+ .awr-chat--narrow
172
+ > :is(.awr-chat__sidebar, .awr-chat__files)
173
+ :where(:is(.awr-history, .awr-filespanel):not(.awr-chat__slot *)) {
174
+ display: contents;
175
+ }
176
+ .awr-chat--narrow
177
+ > :is(.awr-chat__sidebar, .awr-chat__files)
178
+ :where(:is(.awr-history, .awr-filespanel):not(.awr-chat__slot *))
179
+ > * {
180
+ flex-shrink: 0;
181
+ }
182
+ /* Its header: a header bar - as tall as the chat's, on its own background with a line under it,
183
+ the title at the chat title's size, every control a 44 px target, the × in the row. */
184
+ .awr-chat--narrow
185
+ > :is(.awr-chat__sidebar, .awr-chat__files)
186
+ :where(:is(.awr-history, .awr-filespanel):not(.awr-chat__slot *))
187
+ > .awr-panel__head {
188
+ position: sticky;
189
+ top: 0;
190
+ z-index: 1;
191
+ flex: none;
192
+ box-sizing: border-box;
193
+ min-height: 56px;
194
+ margin: 0 0 6px;
195
+ padding: 6px 4px 6px 16px;
196
+ gap: 4px;
197
+ background: var(--awr-bg);
198
+ border-bottom: 1px solid var(--awr-border);
199
+ }
200
+ .awr-chat--narrow
201
+ > :is(.awr-chat__sidebar, .awr-chat__files)
202
+ :where(:is(.awr-history, .awr-filespanel):not(.awr-chat__slot *))
203
+ > .awr-panel__head
204
+ .awr-panel__title {
205
+ min-width: 0;
206
+ overflow: hidden;
207
+ text-overflow: ellipsis;
208
+ white-space: nowrap;
209
+ font-size: inherit;
210
+ color: var(--awr-fg);
211
+ }
212
+ .awr-chat--narrow
213
+ > :is(.awr-chat__sidebar, .awr-chat__files)
214
+ :where(:is(.awr-history, .awr-filespanel):not(.awr-chat__slot *))
215
+ > .awr-panel__head
216
+ .awr-iconbtn {
217
+ width: 44px;
218
+ height: 44px;
219
+ }
220
+ .awr-chat--narrow .awr-panel__head .awr-chat__closeside {
221
+ font-size: 26px;
222
+ font-weight: 300;
223
+ color: var(--awr-fg);
224
+ }
225
+ .awr-chat--narrow
226
+ > :is(.awr-chat__sidebar, .awr-chat__files)
227
+ :where(:is(.awr-history, .awr-filespanel):not(.awr-chat__slot *))
228
+ .awr-history__new {
229
+ flex: none;
230
+ min-height: 44px;
231
+ padding: 0 12px;
232
+ font-size: 14px;
233
+ white-space: nowrap;
234
+ }
235
+ .awr-chat--narrow
236
+ > :is(.awr-chat__sidebar, .awr-chat__files)
237
+ :where(:is(.awr-history, .awr-filespanel):not(.awr-chat__slot *))
238
+ > .awr-panel__empty {
239
+ padding: 8px 16px;
240
+ font-size: 13px;
241
+ }
242
+ /* The rows: the whole row opens the chat (at least 44 px tall, the title at the body's size, the
243
+ time and count under it); its × is a 44 px target of its own, a gap away from it. */
244
+ .awr-chat--narrow
245
+ > :is(.awr-chat__sidebar, .awr-chat__files)
246
+ :where(:is(.awr-history, .awr-filespanel):not(.awr-chat__slot *))
247
+ > :is(.awr-history__list, .awr-filelist) {
248
+ flex: none;
249
+ padding: 0 6px 12px;
250
+ }
251
+ .awr-chat--narrow
252
+ > :is(.awr-chat__sidebar, .awr-chat__files)
253
+ :where(:is(.awr-history, .awr-filespanel):not(.awr-chat__slot *))
254
+ :is(.awr-history__item, .awr-filelist__item) {
255
+ gap: 8px;
256
+ }
257
+ .awr-chat--narrow
258
+ > :is(.awr-chat__sidebar, .awr-chat__files)
259
+ :where(:is(.awr-history, .awr-filespanel):not(.awr-chat__slot *))
260
+ .awr-history__open {
261
+ min-height: 52px;
262
+ justify-content: center;
263
+ gap: 2px;
264
+ padding: 8px 10px;
265
+ }
266
+ .awr-chat--narrow
267
+ > :is(.awr-chat__sidebar, .awr-chat__files)
268
+ :where(:is(.awr-history, .awr-filespanel):not(.awr-chat__slot *))
269
+ .awr-history__title {
270
+ font-size: inherit;
271
+ }
272
+ .awr-chat--narrow
273
+ > :is(.awr-chat__sidebar, .awr-chat__files)
274
+ :where(:is(.awr-history, .awr-filespanel):not(.awr-chat__slot *))
275
+ .awr-history__meta {
276
+ font-size: 12px;
277
+ }
278
+ .awr-chat--narrow
279
+ > :is(.awr-chat__sidebar, .awr-chat__files)
280
+ :where(:is(.awr-history, .awr-filespanel):not(.awr-chat__slot *))
281
+ .awr-filelist__open {
282
+ min-height: 44px;
283
+ }
284
+ .awr-chat--narrow
285
+ > :is(.awr-chat__sidebar, .awr-chat__files)
286
+ :where(:is(.awr-history, .awr-filespanel):not(.awr-chat__slot *))
287
+ :is(.awr-history__item, .awr-filelist__item)
288
+ .awr-iconbtn {
289
+ width: 44px;
290
+ height: 44px;
142
291
  }
143
292
  /* The header and the footer keep their height: only the transcript between them gives way.
144
293
  (As flex items they would shrink a little with every line the transcript grows - the header
@@ -182,7 +331,9 @@
182
331
  /* A fling that reaches the end of the transcript stops there: it is not handed on to the
183
332
  page, which on a phone would scroll or bounce the whole window. */
184
333
  overscroll-behavior: contain;
185
- padding: 16px;
334
+ /* Its top padding, as a property: a tall app's sticky head sits flush with the top (below). */
335
+ --awr-chat-pad-top: 16px;
336
+ padding: var(--awr-chat-pad-top) 16px 16px;
186
337
  display: flex;
187
338
  flex-direction: column;
188
339
  gap: 12px;
@@ -1073,16 +1224,112 @@
1073
1224
  field-sizing: content;
1074
1225
  min-height: 2.6em;
1075
1226
  }
1227
+ /* The box's counter near its limit (`longText`): quiet, under the end of the input. */
1228
+ .awr-composer2__count {
1229
+ align-self: flex-end;
1230
+ margin-top: -4px;
1231
+ padding: 0 6px;
1232
+ font-size: 11px;
1233
+ line-height: 14px;
1234
+ color: var(--awr-muted);
1235
+ font-variant-numeric: tabular-nums;
1236
+ white-space: nowrap;
1237
+ }
1238
+ .awr-composer2__count.is-full {
1239
+ color: var(--awr-warn);
1240
+ }
1241
+ .awr-composer2__sr {
1242
+ position: absolute;
1243
+ width: 1px;
1244
+ height: 1px;
1245
+ overflow: hidden;
1246
+ clip-path: inset(50%);
1247
+ white-space: nowrap;
1248
+ }
1076
1249
  .awr-composer2__interim {
1077
1250
  font-size: 12px;
1078
1251
  color: var(--awr-muted);
1079
1252
  font-style: italic;
1080
1253
  padding: 0 6px;
1081
1254
  }
1082
- .awr-mic.is-on {
1255
+ /* The dictation mic. Idle: an icon button like the others. Listening: unmistakable - a solid
1256
+ danger disc with the stop square (what a tap does now), a ring that pulses out of it
1257
+ (transform / opacity only; a still ring with reduced motion) and the elapsed time beside it.
1258
+ Finishing (the transcript on its way): calm - a quiet disc, a spinner, nothing moving but it.
1259
+ The selectors carry `:hover`: on a touch screen the tapped button keeps `:hover`, and the
1260
+ shared `.awr-iconbtn:hover:not(:disabled)` (more specific than `.awr-mic.is-on`) used to paint
1261
+ the listening state back to a plain grey button - all that was left was a blink.
1262
+ The time is OUT of the layout: over the input's end, left of the button, on the composer's
1263
+ own colour - in the flow it took ~40 px from the input the moment dictation started (its text
1264
+ re-wrapped under the person's eyes, on a 320 px phone a line more). */
1265
+ .awr-micbox {
1266
+ position: relative;
1267
+ display: inline-flex;
1268
+ align-items: center;
1269
+ flex: none;
1270
+ }
1271
+ .awr-mic__time {
1272
+ position: absolute;
1273
+ top: 50%;
1274
+ right: calc(100% + 4px);
1275
+ transform: translateY(-50%);
1276
+ padding: 1px 5px;
1277
+ border-radius: 999px;
1278
+ background: var(--awr-bg);
1279
+ font-size: 13px;
1280
+ font-weight: 600;
1281
+ line-height: 1.4;
1282
+ font-variant-numeric: tabular-nums;
1083
1283
  color: var(--awr-danger);
1084
- background: color-mix(in srgb, var(--awr-danger) 12%, transparent);
1085
- animation: awr-pulse 1.4s ease-in-out infinite;
1284
+ white-space: nowrap;
1285
+ pointer-events: none;
1286
+ }
1287
+ .awr-iconbtn.awr-mic {
1288
+ position: relative;
1289
+ }
1290
+ .awr-iconbtn.awr-mic.is-on,
1291
+ .awr-iconbtn.awr-mic.is-on:hover:not(:disabled) {
1292
+ border-radius: 50%;
1293
+ background: var(--awr-danger);
1294
+ color: var(--awr-danger-fg);
1295
+ }
1296
+ .awr-iconbtn.awr-mic.is-on svg {
1297
+ fill: currentColor;
1298
+ }
1299
+ .awr-iconbtn.awr-mic.is-on::after {
1300
+ content: '';
1301
+ position: absolute;
1302
+ inset: -4px;
1303
+ border: 2px solid var(--awr-danger);
1304
+ border-radius: 50%;
1305
+ pointer-events: none;
1306
+ animation: awr-mic-ring 1.6s ease-out infinite;
1307
+ }
1308
+ @keyframes awr-mic-ring {
1309
+ from {
1310
+ transform: scale(0.85);
1311
+ opacity: 0.9;
1312
+ }
1313
+ to {
1314
+ transform: scale(1.3);
1315
+ opacity: 0;
1316
+ }
1317
+ }
1318
+ .awr-iconbtn.awr-mic.is-busy,
1319
+ .awr-iconbtn.awr-mic.is-busy:disabled {
1320
+ border-radius: 50%;
1321
+ background: var(--awr-subtle);
1322
+ color: var(--awr-fg);
1323
+ box-shadow: inset 0 0 0 2px var(--awr-border);
1324
+ opacity: 1;
1325
+ cursor: progress;
1326
+ }
1327
+ @media (prefers-reduced-motion: reduce) {
1328
+ .awr-iconbtn.awr-mic.is-on::after {
1329
+ animation: none;
1330
+ transform: none;
1331
+ opacity: 1;
1332
+ }
1086
1333
  }
1087
1334
  @keyframes awr-pulse {
1088
1335
  50% {
@@ -1095,9 +1342,6 @@
1095
1342
  gap: 6px;
1096
1343
  padding: 0 4px;
1097
1344
  }
1098
- .awr-mic.is-busy {
1099
- color: var(--awr-muted);
1100
- }
1101
1345
  /* A voice message being recorded: a strip above the input, the dot, the time, Cancel / Attach. */
1102
1346
  .awr-voicebtn.is-on {
1103
1347
  color: var(--awr-danger);
@@ -1652,7 +1896,8 @@
1652
1896
  max-width: 100%;
1653
1897
  }
1654
1898
  .awr-chat__body {
1655
- padding: 12px 10px;
1899
+ --awr-chat-pad-top: 12px;
1900
+ padding: var(--awr-chat-pad-top) 10px 12px;
1656
1901
  }
1657
1902
  .awr-chat__footer {
1658
1903
  padding: 6px 8px 8px;
@@ -2664,6 +2909,17 @@
2664
2909
  object-fit: cover;
2665
2910
  display: block;
2666
2911
  }
2912
+ /* A named picture's thumbnail is the viewer's button (`NamedFileChips`): it fills the square. */
2913
+ .awr-filechip__thumb .awr-filechip__imgbtn {
2914
+ width: 100%;
2915
+ height: 100%;
2916
+ padding: 0;
2917
+ border: 0;
2918
+ border-radius: 0;
2919
+ }
2920
+ .awr-filechip__thumb .awr-filechip__imgbtn:focus-visible {
2921
+ outline-offset: -2px;
2922
+ }
2667
2923
  .awr-filechip__text {
2668
2924
  flex: 1 1 auto;
2669
2925
  min-width: 0;
@@ -2921,6 +3177,13 @@
2921
3177
  background: #fff;
2922
3178
  color-scheme: light;
2923
3179
  }
3180
+ /* A frame whose app is told `dark`: the dark scheme on the element (the documents inside declare
3181
+ the same) and the host's own surface behind it, so an app with a transparent body sits on the
3182
+ chat's colour. An app that declares no scheme still gets the browser's light canvas. */
3183
+ .awr-frame__iframe[data-color-scheme='dark'] {
3184
+ background: var(--awr-bg);
3185
+ color-scheme: dark;
3186
+ }
2924
3187
  .awr-frame__foot {
2925
3188
  display: flex;
2926
3189
  align-items: center;
@@ -3600,3 +3863,145 @@
3600
3863
  .awr-viewer__nav--next {
3601
3864
  right: max(8px, env(safe-area-inset-right, 0px));
3602
3865
  }
3866
+ /* An app's prompts where the app is (panel, sheet, full screen): host-drawn chrome ABOVE the
3867
+ frame - a flex item of its own, so the frame's box never meets it, never under the app and never
3868
+ scrolled away with the app's content. It scrolls itself when it is tall; the app keeps the rest. */
3869
+ .awr-frame__prompts {
3870
+ position: relative;
3871
+ z-index: 1;
3872
+ flex: 0 1 auto;
3873
+ max-height: 60%;
3874
+ min-height: 0;
3875
+ overflow: auto;
3876
+ overscroll-behavior: contain;
3877
+ padding: 8px 10px;
3878
+ border-top: 1px solid color-mix(in srgb, var(--awr-warn) 45%, var(--awr-border));
3879
+ background: var(--awr-bg);
3880
+ }
3881
+ .awr-frame__prompts:focus {
3882
+ outline: none;
3883
+ }
3884
+ .awr-frame__prompts .awr-approvals {
3885
+ margin: 0;
3886
+ }
3887
+ .awr-frame--app.has-prompts .awr-frame__iframe {
3888
+ min-height: 120px;
3889
+ }
3890
+ button.awr-frame__state {
3891
+ cursor: pointer;
3892
+ background: transparent;
3893
+ font: inherit;
3894
+ font-size: 11px;
3895
+ }
3896
+ button.awr-frame__state:hover,
3897
+ button.awr-frame__state:focus-visible {
3898
+ background: color-mix(in srgb, var(--awr-warn) 14%, transparent);
3899
+ }
3900
+ .awr-frame__tall {
3901
+ display: flex;
3902
+ flex-wrap: wrap;
3903
+ align-items: center;
3904
+ gap: 4px 6px;
3905
+ padding: 5px 10px;
3906
+ border-top: 1px solid color-mix(in srgb, var(--awr-fg) 14%, var(--awr-border));
3907
+ font-size: 11.5px;
3908
+ color: var(--awr-muted);
3909
+ min-width: 0;
3910
+ overflow-wrap: anywhere;
3911
+ }
3912
+ .awr-frame__tall .awr-frame__show {
3913
+ margin-left: auto;
3914
+ }
3915
+ /* A "yes" to an MCP App before it takes a press (`ArmedButton`): shown, not yet armed. */
3916
+ .awr-btn.is-arming {
3917
+ opacity: 0.55;
3918
+ cursor: default;
3919
+ }
3920
+ /* An inline app taller than the view keeps the host's label in sight while it scrolls by: the
3921
+ head sticks to the top of the transcript (`overflow: clip` - not `hidden` - lets it), so a
3922
+ tall app cannot pass for the chat over several screens. A sticky box stops at the scroller's
3923
+ padding: `top` takes the transcript's top padding back (`--awr-chat-pad-top`, set where that
3924
+ padding is), so the head is flush with the visible top and no strip of the app shows above
3925
+ it. A host that changes the transcript's top padding sets the property with it. */
3926
+ .awr-frame--app:not(.awr-frame--panel):not(.awr-frame--fullscreen) {
3927
+ overflow: clip;
3928
+ }
3929
+ .awr-frame--app:not(.awr-frame--panel):not(.awr-frame--fullscreen) > .awr-frame__head {
3930
+ position: sticky;
3931
+ top: calc(-1 * var(--awr-chat-pad-top, 0px));
3932
+ z-index: 2;
3933
+ background: var(--awr-bg);
3934
+ border-radius: 10px 10px 0 0;
3935
+ }
3936
+
3937
+ /* ── A link in an answer to a workspace file: inline text that reads as a link ───
3938
+ A span (role="button"), never a <button>: a button is one box, and its words could not
3939
+ break across lines with the text around them. */
3940
+ .awr-filelink {
3941
+ color: var(--awr-accent);
3942
+ text-decoration: underline;
3943
+ text-underline-offset: 2px;
3944
+ cursor: pointer;
3945
+ border-radius: 2px;
3946
+ -webkit-tap-highlight-color: transparent;
3947
+ }
3948
+ .awr-filelink:hover {
3949
+ text-decoration-thickness: 2px;
3950
+ }
3951
+ .awr-filelink:focus-visible {
3952
+ outline: 2px solid var(--awr-accent);
3953
+ outline-offset: 2px;
3954
+ }
3955
+ .awr-filelink code {
3956
+ color: inherit;
3957
+ }
3958
+ /* Its file's preview, over the chat. */
3959
+ .awr-filedialog {
3960
+ position: fixed;
3961
+ inset: 0;
3962
+ z-index: 60;
3963
+ display: flex;
3964
+ align-items: center;
3965
+ justify-content: center;
3966
+ padding: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px))
3967
+ max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
3968
+ background: color-mix(in srgb, var(--awr-bg) 80%, transparent);
3969
+ color: var(--awr-fg);
3970
+ font-family: var(--awr-font);
3971
+ font-size: 14px;
3972
+ }
3973
+ .awr-filedialog__panel {
3974
+ display: flex;
3975
+ flex-direction: column;
3976
+ gap: 8px;
3977
+ width: min(760px, 100%);
3978
+ max-height: 100%;
3979
+ min-width: 0;
3980
+ overflow: auto;
3981
+ overscroll-behavior: contain;
3982
+ padding: 8px 12px 12px;
3983
+ border: 1px solid var(--awr-border);
3984
+ border-radius: 12px;
3985
+ background: var(--awr-bg);
3986
+ box-shadow: 0 12px 40px rgb(0 0 0 / 0.35);
3987
+ }
3988
+ .awr-filedialog__bar {
3989
+ display: flex;
3990
+ align-items: center;
3991
+ gap: 8px;
3992
+ }
3993
+ .awr-filedialog__name {
3994
+ flex: 1 1 auto;
3995
+ min-width: 0;
3996
+ overflow: hidden;
3997
+ text-overflow: ellipsis;
3998
+ white-space: nowrap;
3999
+ font-weight: 600;
4000
+ }
4001
+ .awr-filedialog .awr-iconbtn {
4002
+ width: 36px;
4003
+ height: 36px;
4004
+ }
4005
+ .awr-filedialog .awr-fileview {
4006
+ margin: 0;
4007
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dudko.dev/agent-web-react",
3
- "version": "0.0.42",
3
+ "version": "0.0.44",
4
4
  "description": "React bindings for @dudko.dev/agent-web: a headless useAgent hook, an AgentProvider context, and optional pre-styled components (chat panel, plan/step view, BYOK key form, WebLLM load bar) that connect the in-browser LLM agent to any React site. UI you can drop in — or a headless reducer you can build your own around.",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -145,8 +145,8 @@
145
145
  "tsup": "^9.0.0",
146
146
  "typescript": "^6.0.3",
147
147
  "zod": "^4.6.7",
148
- "@dudko.dev/agent-web": "0.0.52",
149
- "@dudko.dev/test-servers": "0.0.0"
148
+ "@dudko.dev/test-servers": "0.0.0",
149
+ "@dudko.dev/agent-web": "0.0.53"
150
150
  },
151
151
  "scripts": {
152
152
  "build": "tsup",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/mcp-app-policy.ts"],"sourcesContent":["/**\n * MCP Apps: what the host (the page, `mcp-app.ts`) and the sandbox proxy (a page on ANOTHER\n * origin, `mcp-app-sandbox.ts`) must agree on - the app's Content-Security-Policy, the policy as a\n * path segment of the proxy's URL, and the names of the sandbox messages. Pure code with NO\n * imports at all: the proxy's server bundles it without React or the core (a Worker), so the\n * origin rule below is a copy of the core's `mcpAppOrigin`, and `tests/apps-sandbox.test.ts`\n * holds the two to the same answers.\n */\n\n/** The proxy tells the host it can take the app (Sandbox → Host; content-free). */\nexport const MCP_APP_SANDBOX_PROXY_READY = 'ui/notifications/sandbox-proxy-ready'\n/** The host hands the proxy the app's HTML (Host → Sandbox), once. */\nexport const MCP_APP_SANDBOX_RESOURCE_READY = 'ui/notifications/sandbox-resource-ready'\n\n/** The specification reserves these between a host and its proxy: never relayed to or from an app. */\nexport const isMcpAppSandboxMessage = (data: unknown): boolean =>\n typeof data === 'object' &&\n data !== null &&\n typeof (data as { method?: unknown }).method === 'string' &&\n (data as { method: string }).method.startsWith('ui/notifications/sandbox-')\n\n/** The origins an app's policy grants, each already an origin (`mcpAppPolicyOrigin`). */\nexport interface McpAppPolicyOrigins {\n /** `fetch` / XHR / WebSocket (`connect-src`). */\n connect: string[]\n /** Scripts, styles, images, fonts, media. */\n resources: string[]\n}\n\n/**\n * The policy of an app's document: scripts and styles inline, `data:` / `blob:` media, and the\n * network ONLY where the resource declared it. Nested frames, workers, plugins, forms and `<base>`\n * are refused whatever was declared (a frame the app may embed would also be a place it may\n * navigate itself to). The lists must already be checked origins: nothing here re-checks them.\n */\nexport const mcpAppPolicy = ({ connect, resources }: McpAppPolicyOrigins): string => {\n const from = resources.length > 0 ? ` ${resources.join(' ')}` : ''\n return [\n \"default-src 'none'\",\n `script-src 'unsafe-inline'${from}`,\n `style-src 'unsafe-inline'${from}`,\n `img-src data: blob:${from}`,\n `font-src data:${from}`,\n `media-src data: blob:${from}`,\n connect.length > 0 ? `connect-src ${connect.join(' ')}` : \"connect-src 'none'\",\n \"frame-src 'none'\",\n \"child-src 'none'\",\n \"worker-src 'none'\",\n \"object-src 'none'\",\n \"form-action 'none'\",\n \"base-uri 'none'\",\n \"webrtc 'block'\",\n ].join('; ')\n}\n\n// ── The origin rule: a COPY of the core's `mcpAppOrigin` (src/mcp/apps.ts) ──────────────────\n\nconst LABEL = '[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?'\nconst HOST = `(?:\\\\*\\\\.)?${LABEL}(?:\\\\.${LABEL})*`\nconst PORT = '(?::\\\\d{1,5})?'\nconst SECURE_ORIGIN = new RegExp(`^(?:https|wss)://${HOST}${PORT}$`)\nconst LOOPBACK_ORIGIN = new RegExp(`^(?:http|ws)://(?:localhost|127\\\\.0\\\\.0\\\\.1|\\\\[::1\\\\])${PORT}$`)\n\n/**\n * One declared CSP entry as a source expression a policy may carry, or `undefined`: only an\n * origin (`https://` / `wss://`, a `*.` wildcard over at least two labels, or `http://` /\n * `ws://` on loopback). The same answers as the core's `mcpAppOrigin`, for the proxy's server.\n */\nexport const mcpAppPolicyOrigin = (entry: unknown): string | undefined => {\n if (typeof entry !== 'string' || entry.length > 300) return undefined\n const value = entry.trim().toLowerCase().replace(/\\/$/, '')\n if (SECURE_ORIGIN.test(value)) {\n const host = value.replace(/^[a-z]+:\\/\\//, '').replace(/:\\d+$/, '')\n if (host.startsWith('*.') && !host.slice(2).includes('.')) return undefined\n return value\n }\n return LOOPBACK_ORIGIN.test(value) ? value : undefined\n}\n\n// ── The policy in the proxy's URL ────────────────────────────────────────────────────────────\n\n/** At most this many origins per list (the core's `MCP_APP_MAX_DOMAINS`). */\nexport const MCP_APP_POLICY_MAX_ORIGINS = 32\n/** A policy token longer than this is not put in a URL: the app runs without its own origin. */\nexport const MCP_APP_POLICY_TOKEN_MAX_CHARS = 4096\n\nconst B64URL = /^[A-Za-z0-9_-]+$/\n\n/**\n * The policy as one path segment (base64url of `{\"c\":[…],\"r\":[…]}`), or `undefined` when it does\n * not fit. It is in the PATH, not the query, because a `frame-src` source expression matches a\n * path exactly and ignores the query: the host pins the proxy's frame to this one URL, so nothing\n * inside the frame can load the proxy page with a policy of its choosing.\n */\nexport const mcpAppPolicyToken = ({\n connect,\n resources,\n}: McpAppPolicyOrigins): string | undefined => {\n const json = JSON.stringify({ c: connect, r: resources })\n // Origins are ASCII; anything else is not a list of checked origins.\n if (/[^\\x20-\\x7e]/.test(json)) return undefined\n const token = btoa(json).replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/, '')\n return token.length <= MCP_APP_POLICY_TOKEN_MAX_CHARS ? token : undefined\n}\n\nconst isObject = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value)\n\nconst originList = (value: unknown): string[] | undefined => {\n if (!Array.isArray(value) || value.length > MCP_APP_POLICY_MAX_ORIGINS) return undefined\n const out: string[] = []\n for (const entry of value) {\n // Exactly an origin as the host writes it: checked, canonical, once.\n if (typeof entry !== 'string' || mcpAppPolicyOrigin(entry) !== entry || out.includes(entry)) {\n return undefined\n }\n out.push(entry)\n }\n return out\n}\n\n/**\n * The policy a token stands for, or `undefined` for anything that is not exactly what\n * `mcpAppPolicyToken` writes: base64url of an object with the two lists and nothing else, every\n * entry an origin by the rule above, no more than `MCP_APP_POLICY_MAX_ORIGINS` each, the\n * canonical encoding (one URL per policy).\n */\nexport const mcpAppPolicyOfToken = (token: unknown): McpAppPolicyOrigins | undefined => {\n if (\n typeof token !== 'string' ||\n token.length === 0 ||\n token.length > MCP_APP_POLICY_TOKEN_MAX_CHARS ||\n !B64URL.test(token)\n ) {\n return undefined\n }\n let parsed: unknown\n try {\n parsed = JSON.parse(atob(token.replace(/-/g, '+').replace(/_/g, '/')))\n } catch {\n return undefined\n }\n if (!isObject(parsed)) return undefined\n const keys = Object.keys(parsed)\n if (keys.length !== 2 || !keys.includes('c') || !keys.includes('r')) return undefined\n const connect = originList(parsed.c)\n const resources = originList(parsed.r)\n if (!connect || !resources) return undefined\n const policy = { connect, resources }\n return mcpAppPolicyToken(policy) === token ? policy : undefined\n}\n"],"mappings":";AAUO,IAAM,8BAA8B;AAEpC,IAAM,iCAAiC;AAGvC,IAAM,yBAAyB,CAAC,SACrC,OAAO,SAAS,YAChB,SAAS,QACT,OAAQ,KAA8B,WAAW,YAChD,KAA4B,OAAO,WAAW,2BAA2B;AAgBrE,IAAM,eAAe,CAAC,EAAE,SAAS,UAAU,MAAmC;AACnF,QAAM,OAAO,UAAU,SAAS,IAAI,IAAI,UAAU,KAAK,GAAG,CAAC,KAAK;AAChE,SAAO;AAAA,IACL;AAAA,IACA,6BAA6B,IAAI;AAAA,IACjC,4BAA4B,IAAI;AAAA,IAChC,sBAAsB,IAAI;AAAA,IAC1B,iBAAiB,IAAI;AAAA,IACrB,wBAAwB,IAAI;AAAA,IAC5B,QAAQ,SAAS,IAAI,eAAe,QAAQ,KAAK,GAAG,CAAC,KAAK;AAAA,IAC1D;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,EAAE,KAAK,IAAI;AACb;AAIA,IAAM,QAAQ;AACd,IAAM,OAAO,cAAc,KAAK,SAAS,KAAK;AAC9C,IAAM,OAAO;AACb,IAAM,gBAAgB,IAAI,OAAO,oBAAoB,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