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

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);
@@ -1079,10 +1083,84 @@
1079
1083
  font-style: italic;
1080
1084
  padding: 0 6px;
1081
1085
  }
1082
- .awr-mic.is-on {
1086
+ /* The dictation mic. Idle: an icon button like the others. Listening: unmistakable - a solid
1087
+ danger disc with the stop square (what a tap does now), a ring that pulses out of it
1088
+ (transform / opacity only; a still ring with reduced motion) and the elapsed time beside it.
1089
+ Finishing (the transcript on its way): calm - a quiet disc, a spinner, nothing moving but it.
1090
+ The selectors carry `:hover`: on a touch screen the tapped button keeps `:hover`, and the
1091
+ shared `.awr-iconbtn:hover:not(:disabled)` (more specific than `.awr-mic.is-on`) used to paint
1092
+ the listening state back to a plain grey button - all that was left was a blink.
1093
+ The time is OUT of the layout: over the input's end, left of the button, on the composer's
1094
+ own colour - in the flow it took ~40 px from the input the moment dictation started (its text
1095
+ re-wrapped under the person's eyes, on a 320 px phone a line more). */
1096
+ .awr-micbox {
1097
+ position: relative;
1098
+ display: inline-flex;
1099
+ align-items: center;
1100
+ flex: none;
1101
+ }
1102
+ .awr-mic__time {
1103
+ position: absolute;
1104
+ top: 50%;
1105
+ right: calc(100% + 4px);
1106
+ transform: translateY(-50%);
1107
+ padding: 1px 5px;
1108
+ border-radius: 999px;
1109
+ background: var(--awr-bg);
1110
+ font-size: 13px;
1111
+ font-weight: 600;
1112
+ line-height: 1.4;
1113
+ font-variant-numeric: tabular-nums;
1083
1114
  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;
1115
+ white-space: nowrap;
1116
+ pointer-events: none;
1117
+ }
1118
+ .awr-iconbtn.awr-mic {
1119
+ position: relative;
1120
+ }
1121
+ .awr-iconbtn.awr-mic.is-on,
1122
+ .awr-iconbtn.awr-mic.is-on:hover:not(:disabled) {
1123
+ border-radius: 50%;
1124
+ background: var(--awr-danger);
1125
+ color: var(--awr-danger-fg);
1126
+ }
1127
+ .awr-iconbtn.awr-mic.is-on svg {
1128
+ fill: currentColor;
1129
+ }
1130
+ .awr-iconbtn.awr-mic.is-on::after {
1131
+ content: '';
1132
+ position: absolute;
1133
+ inset: -4px;
1134
+ border: 2px solid var(--awr-danger);
1135
+ border-radius: 50%;
1136
+ pointer-events: none;
1137
+ animation: awr-mic-ring 1.6s ease-out infinite;
1138
+ }
1139
+ @keyframes awr-mic-ring {
1140
+ from {
1141
+ transform: scale(0.85);
1142
+ opacity: 0.9;
1143
+ }
1144
+ to {
1145
+ transform: scale(1.3);
1146
+ opacity: 0;
1147
+ }
1148
+ }
1149
+ .awr-iconbtn.awr-mic.is-busy,
1150
+ .awr-iconbtn.awr-mic.is-busy:disabled {
1151
+ border-radius: 50%;
1152
+ background: var(--awr-subtle);
1153
+ color: var(--awr-fg);
1154
+ box-shadow: inset 0 0 0 2px var(--awr-border);
1155
+ opacity: 1;
1156
+ cursor: progress;
1157
+ }
1158
+ @media (prefers-reduced-motion: reduce) {
1159
+ .awr-iconbtn.awr-mic.is-on::after {
1160
+ animation: none;
1161
+ transform: none;
1162
+ opacity: 1;
1163
+ }
1086
1164
  }
1087
1165
  @keyframes awr-pulse {
1088
1166
  50% {
@@ -1095,9 +1173,6 @@
1095
1173
  gap: 6px;
1096
1174
  padding: 0 4px;
1097
1175
  }
1098
- .awr-mic.is-busy {
1099
- color: var(--awr-muted);
1100
- }
1101
1176
  /* A voice message being recorded: a strip above the input, the dot, the time, Cancel / Attach. */
1102
1177
  .awr-voicebtn.is-on {
1103
1178
  color: var(--awr-danger);
@@ -2664,6 +2739,17 @@
2664
2739
  object-fit: cover;
2665
2740
  display: block;
2666
2741
  }
2742
+ /* A named picture's thumbnail is the viewer's button (`NamedFileChips`): it fills the square. */
2743
+ .awr-filechip__thumb .awr-filechip__imgbtn {
2744
+ width: 100%;
2745
+ height: 100%;
2746
+ padding: 0;
2747
+ border: 0;
2748
+ border-radius: 0;
2749
+ }
2750
+ .awr-filechip__thumb .awr-filechip__imgbtn:focus-visible {
2751
+ outline-offset: -2px;
2752
+ }
2667
2753
  .awr-filechip__text {
2668
2754
  flex: 1 1 auto;
2669
2755
  min-width: 0;
@@ -2921,6 +3007,13 @@
2921
3007
  background: #fff;
2922
3008
  color-scheme: light;
2923
3009
  }
3010
+ /* A frame whose app is told `dark`: the dark scheme on the element (the documents inside declare
3011
+ the same) and the host's own surface behind it, so an app with a transparent body sits on the
3012
+ chat's colour. An app that declares no scheme still gets the browser's light canvas. */
3013
+ .awr-frame__iframe[data-color-scheme='dark'] {
3014
+ background: var(--awr-bg);
3015
+ color-scheme: dark;
3016
+ }
2924
3017
  .awr-frame__foot {
2925
3018
  display: flex;
2926
3019
  align-items: center;
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.43",
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.52"
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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