@cloudlet/toast 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +165 -0
- package/README.md +3 -0
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +19 -15
- package/dist/agent.js.map +1 -1
- package/dist/center-react.d.ts +286 -0
- package/dist/center-react.d.ts.map +1 -0
- package/dist/center-react.js +2 -0
- package/dist/center.d.ts +3 -0
- package/dist/center.d.ts.map +1 -0
- package/dist/center.js +1 -0
- package/dist/core/agent-port.d.ts +2 -0
- package/dist/core/agent-port.d.ts.map +1 -1
- package/dist/core/agent-port.js +3 -0
- package/dist/core/agent-port.js.map +1 -1
- package/dist/react/card.d.ts +4 -0
- package/dist/react/card.d.ts.map +1 -1
- package/dist/react/card.js +3 -8
- package/dist/react/card.js.map +1 -1
- package/dist/react/center-backdrop.d.ts +69 -0
- package/dist/react/center-backdrop.d.ts.map +1 -0
- package/dist/react/center-backdrop.js +81 -0
- package/dist/react/center-backdrop.js.map +1 -0
- package/dist/react/center-clear.d.ts +16 -0
- package/dist/react/center-clear.d.ts.map +1 -0
- package/dist/react/center-clear.js +24 -0
- package/dist/react/center-clear.js.map +1 -0
- package/dist/react/center-gestures.d.ts +47 -0
- package/dist/react/center-gestures.d.ts.map +1 -0
- package/dist/react/center-gestures.js +74 -0
- package/dist/react/center-gestures.js.map +1 -0
- package/dist/react/center-motion.d.ts +174 -0
- package/dist/react/center-motion.d.ts.map +1 -0
- package/dist/react/center-motion.js +344 -0
- package/dist/react/center-motion.js.map +1 -0
- package/dist/react/center.d.ts +15 -0
- package/dist/react/center.d.ts.map +1 -0
- package/dist/react/center.js +1287 -0
- package/dist/react/center.js.map +1 -0
- package/dist/react/focus.d.ts +7 -0
- package/dist/react/focus.d.ts.map +1 -0
- package/dist/react/focus.js +14 -0
- package/dist/react/focus.js.map +1 -0
- package/dist/react/gestures.d.ts +33 -2
- package/dist/react/gestures.d.ts.map +1 -1
- package/dist/react/gestures.js +181 -149
- package/dist/react/gestures.js.map +1 -1
- package/dist/react/host.d.ts.map +1 -1
- package/dist/react/host.js +287 -283
- package/dist/react/host.js.map +1 -1
- package/dist/react/motion.d.ts +18 -11
- package/dist/react/motion.d.ts.map +1 -1
- package/dist/react/motion.js +6 -3
- package/dist/react/motion.js.map +1 -1
- package/dist/react/reduced.d.ts +24 -0
- package/dist/react/reduced.d.ts.map +1 -0
- package/dist/react/reduced.js +35 -0
- package/dist/react/reduced.js.map +1 -0
- package/dist/react/zoom.d.ts +12 -0
- package/dist/react/zoom.d.ts.map +1 -0
- package/dist/react/zoom.js +21 -0
- package/dist/react/zoom.js.map +1 -0
- package/dist/react.d.ts +4 -0
- package/dist/react.d.ts.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +2 -1
- package/src/agent.ts +11 -6
- package/src/center-react.ts +300 -0
- package/src/center.ts +27 -0
- package/src/core/agent-port.ts +3 -0
- package/src/react/card.tsx +5 -6
- package/src/react/center-backdrop.tsx +151 -0
- package/src/react/center-clear.ts +56 -0
- package/src/react/center-gestures.ts +143 -0
- package/src/react/center-motion.ts +504 -0
- package/src/react/center.tsx +1557 -0
- package/src/react/focus.ts +18 -0
- package/src/react/gestures.ts +127 -37
- package/src/react/host.tsx +17 -5
- package/src/react/motion.ts +16 -9
- package/src/react/reduced.ts +52 -0
- package/src/react/zoom.ts +26 -0
- package/src/react.ts +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,170 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.5.0 — 2026-12-01
|
|
4
|
+
|
|
5
|
+
The notification center. A new subpath, `@cloudlet/toast/center`, shows your app's own
|
|
6
|
+
notifications in a panel at the edge of the page: newest first, gathered into groups that stack and
|
|
7
|
+
expand, with an unread state, actions and swipes. It takes an array from your app, wherever the
|
|
8
|
+
notifications come from (a REST API, a WebSocket, local state), and never changes it: dismissing,
|
|
9
|
+
clearing, actions and reading come back to you as callbacks, you update the array, and the panel
|
|
10
|
+
animates the difference. Connect it in three lines: `const center = useNotificationCenter()`, spread
|
|
11
|
+
`center.triggerProps` on your own button, and render
|
|
12
|
+
`<NotificationCenter center={center} notifications={items} onDismiss={…} />`. It is apart from the
|
|
13
|
+
Toaster: toasts never go into it, and the root entry does not load it. Documentation:
|
|
14
|
+
https://cloudlet.dev/docs/components/notification-center. In a shadcn/ui project the registry item
|
|
15
|
+
`notification-center` (`npx shadcn@latest add @cloudlet/notification-center`) adds the panel and a
|
|
16
|
+
bell button with a badge of the count you give it, on your theme's tokens. Swipes of the Toaster,
|
|
17
|
+
the Island and the center no longer fly away after a few pixels on a trackpad. This release also
|
|
18
|
+
carries the Island's fix for CSS `zoom` from 1.4.1, which was never published to npm: upgrading
|
|
19
|
+
from 1.4.0 needs nothing else.
|
|
20
|
+
|
|
21
|
+
### The center
|
|
22
|
+
|
|
23
|
+
- `NotificationCenter` takes `notifications`, an array of `NotificationItem`: `id` (stable and
|
|
24
|
+
unique: the panel follows a notification by it across arrays), `title`, `description`, `time` (a
|
|
25
|
+
`Date` or milliseconds since the epoch), `group`, `kind`, `read`, `icon`, `actions`
|
|
26
|
+
(`{ id, label }[]`) and `data` (the app's own, handed back untouched). The panel shows them newest
|
|
27
|
+
first by `time` (equal times keep the array's order); an item without a string `id`, or with the
|
|
28
|
+
`id` of an earlier one, is left out. `kind` `success`, `error`, `info`, `warning` or `loading`
|
|
29
|
+
draws the Toaster's status icon and tint and a hidden word for screen readers; any other string is
|
|
30
|
+
the app's own kind (`data-kind` on the card).
|
|
31
|
+
- The panel never changes the list. `onDismiss(id)` is asked by a card's clear button and by a
|
|
32
|
+
swipe, `onClear(ids)` by a group's two-step Clear (its ids, newest first) and by the header's
|
|
33
|
+
Clear all (every id), `onAction(id, actionId)` by an action button (the card stays unless the app
|
|
34
|
+
removes it), and `onRead(ids)` reports the unread notifications (`read: false`) the person has
|
|
35
|
+
seen: those listed when the panel opens and those that arrive while it is open on a visible page,
|
|
36
|
+
each id once per opening. With only `onClear`, a dismiss calls `onClear([id])`; with only
|
|
37
|
+
`onDismiss`, a clear calls it for each id; with neither, there are no clear buttons and no swipes.
|
|
38
|
+
- Each new array is laid out against the previous one: a notification that arrives while the panel
|
|
39
|
+
is open grows in at the top and is spoken in the panel's polite live region; one the app took out
|
|
40
|
+
leaves as an inert copy while the others move to their places. A card swiped away springs back
|
|
41
|
+
while the app decides and flies on with the swipe's speed when the app takes it out within 600 ms,
|
|
42
|
+
from wherever it has sprung back to; one the app takes out later (a server that confirms later)
|
|
43
|
+
leaves as any other, and one it keeps (it refused) stays.
|
|
44
|
+
- `renderNotification(item, parts)` draws a card's content from the default parts: `icon`, `title`
|
|
45
|
+
(the heading with `titleId`), `description`, `actions`, `time` (with the clear button in its
|
|
46
|
+
place), `content` (all of them as the default card lays them out), `dismiss()` and
|
|
47
|
+
`action(actionId)`. The panel keeps the card's frame, its motion and its swipe.
|
|
48
|
+
- An unread notification (`read: false`) has a dot and `data-read="false"`, and a hidden "Unread"
|
|
49
|
+
before its title. The bell's count is the app's own, from its `read` flags.
|
|
50
|
+
|
|
51
|
+
### The panel and your buttons
|
|
52
|
+
|
|
53
|
+
- `useNotificationCenter(options?)` gives `open`, `setOpen` and `triggerProps` for the app's own
|
|
54
|
+
button (`aria-expanded`, `aria-haspopup: 'dialog'`, `aria-controls` naming the panel while it is
|
|
55
|
+
open, a `ref` and a click that opens or closes the center). Uncontrolled with `defaultOpen`, or
|
|
56
|
+
controlled with `open` and `onOpenChange`, where the app may say no by keeping `open` (the next
|
|
57
|
+
Escape, press outside or click asks again); `setOpen` is the same function every render. Spread
|
|
58
|
+
`triggerProps` on as many buttons as you like: each opens and closes the center, and focus comes
|
|
59
|
+
back to the one that opened it. `NotificationCenter` takes the result as `center`; without it the
|
|
60
|
+
panel takes `open`, `defaultOpen` and `onOpenChange` itself.
|
|
61
|
+
- `<NotificationCenter />` is a non-modal dialog portalled into `document.body` on the Toaster's
|
|
62
|
+
layer, named by its visible heading "Notifications", with a round close button and a column of
|
|
63
|
+
cards at the right edge (`side="left"` for the left; physical, also in RTL), or "No
|
|
64
|
+
notifications". A card's time ("now", "2m", "1h", "3d", then a date) gives way to its clear button
|
|
65
|
+
on hover and while focus is in the card. Tab goes from the header's buttons to the cards from top
|
|
66
|
+
to bottom, with no stop on the list itself. The server and the first client render draw no panel,
|
|
67
|
+
even for an open center.
|
|
68
|
+
- Props: `center`, `open`, `defaultOpen`, `onOpenChange`, `notifications`, `onDismiss`, `onClear`,
|
|
69
|
+
`onAction`, `onRead`, `renderNotification`, `side`, `theme`, `dir`, `labels`, `classNames` by
|
|
70
|
+
part, `backdrop`, `motion`, `reducedMotion` and `nonce`. The labels are `title`, `close`, `clear`,
|
|
71
|
+
`empty`, `kind`, `unread`, `time` and those of groups below; the column is
|
|
72
|
+
`--cloudlet-center-width` wide (392px, never more than the viewport less 12px), and the panel's
|
|
73
|
+
root carries `.cloudlet-host`, so the Toaster's tokens and themes style it too.
|
|
74
|
+
- The panel closes the way a non-modal panel does: Escape while focus is in the panel, on one of the
|
|
75
|
+
center's buttons or on the page's body (no other Escape handler hears it; Escape in a field of the
|
|
76
|
+
page or during an IME composition is left alone), and a primary press anywhere outside the panel
|
|
77
|
+
and the center's buttons, which goes on to the page. Opening moves focus to the panel's heading;
|
|
78
|
+
closing from inside moves it to the button that opened the center, else to what had focus before,
|
|
79
|
+
else to the center's first button. A card that leaves while focus is in it hands focus to the card
|
|
80
|
+
that followed it, else to the heading.
|
|
81
|
+
- Motion. The drawer slides in from its edge and out on one critically damped spring of its
|
|
82
|
+
position, the cards trailing one another (12 % of the way each, up to the eighth), the header
|
|
83
|
+
appearing in the second half of the way; pressing the button again mid-way turns it from where it
|
|
84
|
+
is. A closing panel is inert and hidden from assistive technology at once. `motion` takes
|
|
85
|
+
`timeScale` and `overrides`, the Toaster's debugging channel; `reducedMotion` works as the
|
|
86
|
+
Toaster's (the system and `data-reduced-motion` on an ancestor still win), and under reduced motion
|
|
87
|
+
the column, the backdrop's layers and the cards fade for 80 ms instead of moving; `nonce` goes on
|
|
88
|
+
the panel's own `<style>`, whose CSSOM rules carry every frame (no style attribute).
|
|
89
|
+
- Swipes. Two fingers on a trackpad, or a finger, towards the drawer's edge drag the drawer (it
|
|
90
|
+
resists outwards past open); let go past the threshold, it asks the app to close the center and
|
|
91
|
+
keeps the swipe's speed. Away from the edge on a card, the card follows and fades; past the
|
|
92
|
+
threshold it asks the app to dismiss it. A sideways trackpad stream over the panel never reaches
|
|
93
|
+
the browser's back and forward swipe, while the page's own scrolling waits on no listener of the
|
|
94
|
+
panel; buttons start no swipe, sides count from the physical edge, and reduced motion turns the
|
|
95
|
+
swipes off while the buttons stay.
|
|
96
|
+
|
|
97
|
+
### Groups
|
|
98
|
+
|
|
99
|
+
- Notifications with the same nonempty `group` form a group, standing where its newest notification
|
|
100
|
+
stands. Two or more are a stack: the newest card in full, up to two edges of the cards under it,
|
|
101
|
+
and a button below, "Deploys · 2 more", that expands it, as a click on the stack does. Expanded,
|
|
102
|
+
the group shows all its cards under a row with its name and count and "Show less". The group is a
|
|
103
|
+
`role="group"` named "Deploys, 3 notifications"; its cards' titles are `h4`. Every group is
|
|
104
|
+
collapsed again when the center opens.
|
|
105
|
+
- A group and the whole list clear in two presses, as the Island's Clear all does: "Clear" in an
|
|
106
|
+
expanded group's heading row, a clear button in place of a collapsed stack's top card's time, and
|
|
107
|
+
"Clear all" in the header from two notifications. The first press arms the button ("Clear 3", in
|
|
108
|
+
the error tint, said by a polite status); the second within 3 seconds calls `onClear` with the
|
|
109
|
+
ids. A button disarms when its time runs out, when focus leaves it and when it leaves.
|
|
110
|
+
- The stacks move: expanding spreads the cards out of the stack on a spring that a click mid-way
|
|
111
|
+
turns, collapsing gathers them back, the heading row and the button under the stack swap with a
|
|
112
|
+
blur, and a notification arriving in a collapsed stack grows in on top.
|
|
113
|
+
- Labels `group`, `more`, `stack`, `showLess`, `clearGroup`, `clearGroupConfirm`, `clearStack`,
|
|
114
|
+
`clearAll` and `clearAllConfirm`; parts `group`, `group-header`, `group-title`, `show-less`,
|
|
115
|
+
`group-list`, `edge`, `more`, `clear-all`, `group-clear` and `stack-clear`; a motion constant
|
|
116
|
+
`stack` (`step` 10 px, `shrink` 0.06, `expand` and `collapse` the Island's shape springs, `reveal`
|
|
117
|
+
160 ms, `blur` 4 px, `cascade` 0).
|
|
118
|
+
|
|
119
|
+
### Backdrop
|
|
120
|
+
|
|
121
|
+
- `backdrop` is `blur` (the default), `tint` or `none`, live, said in the root's `data-backdrop`.
|
|
122
|
+
`blur` blurs the page under the column and a band past it progressively: four layers of
|
|
123
|
+
`backdrop-filter` under a tone, one in Safari and every browser on iOS and iPadOS, and the tone of
|
|
124
|
+
`tint` in a window narrower than 48rem and without `backdrop-filter`. `tint` is a tone of the
|
|
125
|
+
background, even under the column and fading out across the band; `none` draws nothing.
|
|
126
|
+
- The blur turns into the tone of `tint` under `prefers-reduced-transparency: reduce` and under
|
|
127
|
+
`data-reduced-transparency` on an ancestor of the panel. Tokens `--cloudlet-center-tint`,
|
|
128
|
+
`--cloudlet-center-backdrop-reach`, `--cloudlet-center-blur` and `--cloudlet-center-blur-tint`
|
|
129
|
+
set its look without JavaScript and keep the text on the backdrop at 4.5:1 over a busy page; in
|
|
130
|
+
forced colours a center with a backdrop gets a solid `Canvas` column. The backdrop fades with the
|
|
131
|
+
drawer, and `motion.overrides.backdrop` takes `layers` and `scrollTint` for the laboratory.
|
|
132
|
+
|
|
133
|
+
### API
|
|
134
|
+
|
|
135
|
+
- `@cloudlet/toast/center` exports `NotificationCenter` and `useNotificationCenter`, and the types
|
|
136
|
+
`NotificationItem`, `NotificationItemAction`, `NotificationParts`, `NotificationCenterProps`,
|
|
137
|
+
`NotificationCenterOpenOptions`, `NotificationCenterComponent`, `NotificationCenterLabels`,
|
|
138
|
+
`NotificationCenterPart`, `NotificationCenterMotion`, `NotificationCenterMotionConstants`,
|
|
139
|
+
`NotificationCenterMotionOverrides`, `NotificationCenterBackdropConstants`,
|
|
140
|
+
`NotificationCenterTriggerProps`, `UseNotificationCenter` and `UseNotificationCenterResult`. The
|
|
141
|
+
root entry and `@cloudlet/toast/agent` are unchanged.
|
|
142
|
+
|
|
143
|
+
### Fixes
|
|
144
|
+
|
|
145
|
+
- The Island fits its content under a CSS `zoom` on an ancestor, such as `html { zoom: 1.5 }`, a
|
|
146
|
+
`zoom` below 1 or two nested ones. The shell used to be measured in viewport pixels and drawn in
|
|
147
|
+
CSS pixels inside the same zoom, so it grew by the zoom (at 2.4 an open Island covered the page);
|
|
148
|
+
the room the host takes in the viewport had the same mistake. The heading's morph between the
|
|
149
|
+
pill and the Island now starts where the title was, and a swipe of the pill or the slides follows
|
|
150
|
+
the finger, with its thresholds scaled with the interface. Without a `zoom` nothing changes.
|
|
151
|
+
- Swipes no longer fly away after a few pixels on a trackpad. The release speed was the last step
|
|
152
|
+
of the event stream, so wheel events delivered in a burst gave huge speeds and a flick of 24 px
|
|
153
|
+
committed. Now the speed is measured over the last 100 ms of the swipe and capped at 3 px a
|
|
154
|
+
millisecond, and a swipe commits past 40 % of the swiped dimension or as a real flick: at least
|
|
155
|
+
60 px released at 0.6 px a millisecond or faster (a flick back still cancels, and a pause before
|
|
156
|
+
letting go is no flick). A finger that rests before it flicks is timed from when it moves, and
|
|
157
|
+
moves the browser delivers late in one event are timed by their own times. The content follows
|
|
158
|
+
the finger 1:1. This applies to the Toaster's pill,
|
|
159
|
+
the Island's slides and its collapse, and the notification center.
|
|
160
|
+
- A pending operation's cancel button always reads `labels.cancel`: it leaves once cancellation is
|
|
161
|
+
requested, so `labels.cancellationRequested` was never shown and is now documented as kept for
|
|
162
|
+
compatibility only.
|
|
163
|
+
- `toasterAgent`'s `subscribe`: every listener that throws reaches the controller's diagnostics as
|
|
164
|
+
its own `listener-error`, not only the first, and a second subscriber that subscribes while a
|
|
165
|
+
change is still being delivered no longer hears that change again (it gets an empty array, as
|
|
166
|
+
the first subscriber always did).
|
|
167
|
+
|
|
3
168
|
## 1.4.0 — 2026-11-29
|
|
4
169
|
|
|
5
170
|
The stable release of 1.4.0-rc.1, published to npm as `latest` (`npm install @cloudlet/toast`); the
|
package/README.md
CHANGED
|
@@ -70,6 +70,9 @@ Full documentation: **https://cloudlet.dev/docs/components/toaster**
|
|
|
70
70
|
- Guides: Notifications & time, Operations & cancellation, Forms, Positioning & offsets, Styling,
|
|
71
71
|
SSR & Next.js, Content Security Policy, Accessibility (including what is and is not tested).
|
|
72
72
|
- Reference: `createCloudlet`, the controller, Toaster props, labels & announcements, types.
|
|
73
|
+
- Notification center: `@cloudlet/toast/center` shows your app's own notifications (an array from
|
|
74
|
+
your server, a socket or local state) in a panel that your own button opens, in groups, at
|
|
75
|
+
**https://cloudlet.dev/docs/components/notification-center**.
|
|
73
76
|
- Agents: how an AI agent in your app reads and drives the Toaster, at
|
|
74
77
|
**https://cloudlet.dev/docs/agents**.
|
|
75
78
|
- The [changelog](CHANGELOG.md) lists every change, including migration from `1.0.0-rc.0`.
|
package/dist/agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAIpE,OAAO,KAAK,EAA6B,aAAa,EAAE,aAAa,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxI,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACrF,OAAO,KAAK,EAAE,oBAAoB,EAAwB,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAMxG;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EA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Xd"}
|
package/dist/agent.js
CHANGED
|
@@ -367,33 +367,37 @@ function b(r, f) {
|
|
|
367
367
|
name: b,
|
|
368
368
|
snapshot: F,
|
|
369
369
|
subscribe: (e) => {
|
|
370
|
-
let t
|
|
371
|
-
|
|
370
|
+
let t;
|
|
371
|
+
if (A.size) t = {
|
|
372
|
+
call: e,
|
|
373
|
+
from: C.read().controller.revision
|
|
372
374
|
};
|
|
373
|
-
|
|
375
|
+
else {
|
|
374
376
|
F();
|
|
375
|
-
let
|
|
377
|
+
let r = C.read(), i = r.controller;
|
|
376
378
|
D.clear();
|
|
377
|
-
for (let
|
|
378
|
-
let t =
|
|
379
|
-
D.set(
|
|
380
|
-
label:
|
|
381
|
-
action:
|
|
379
|
+
for (let e of i.notifications) {
|
|
380
|
+
let t = e.operation;
|
|
381
|
+
D.set(e.handle, {
|
|
382
|
+
label: e.content.title,
|
|
383
|
+
action: e.action.status,
|
|
382
384
|
operation: t ? {
|
|
383
385
|
token: t.token,
|
|
384
386
|
value: t.status === "pending" && t.cancelRequested ? "cancel-requested" : t.status
|
|
385
387
|
} : null,
|
|
386
|
-
authors:
|
|
388
|
+
authors: r.forms.get(e.handle)?.authors ?? h
|
|
387
389
|
});
|
|
388
390
|
}
|
|
389
|
-
O =
|
|
390
|
-
|
|
391
|
+
O = i.island.current ? E(i.island.current) : null, k = i.revision, t = {
|
|
392
|
+
call: e,
|
|
393
|
+
from: k
|
|
394
|
+
}, j = C.subscribe((e) => {
|
|
395
|
+
let t = W(e), r = e.controller.revision;
|
|
391
396
|
for (let e of [...A]) if (A.has(e)) try {
|
|
392
|
-
e(t);
|
|
397
|
+
e.call(r <= e.from ? n : t);
|
|
393
398
|
} catch (e) {
|
|
394
|
-
|
|
399
|
+
C.report(e);
|
|
395
400
|
}
|
|
396
|
-
if (n) throw n.error;
|
|
397
401
|
});
|
|
398
402
|
}
|
|
399
403
|
return A.add(t), () => {
|
package/dist/agent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","names":["freeze","EMPTY","quote","TOASTER_VERBS","NOTIFICATION_VERBS","VERBS","STRICTNESS","DONE","GONE","STALE","UNAVAILABLE","FORM_REJECTED","FORM_FAILED","texts","action","step","name","names","item","field","limit","label","messages","message","NO_AUTHORS","NOT_AVAILABLE","refuse","allowed","outcome","result","done","words","toasterAgent","options","port","createToasterPort","controller","refs","issued","refOf","ref","handle","known","islandRef","seeded","listeners","stop","source","entries","targets","snapshot","reading","state","byHandle","island","count","found","notifications","entry","notification","plan","current","mounted","holdsDraft","target","fillPlan","command","pressPlan","form","operation","value","candidate","permission","started","approved","signal","ended","describe","checked","check","verdict","run","context","subject","summon","collect","commit","live","changes","touched","push","reason","by","event","events","next","authors","previous","own","failure","each","error","errors","labels","sentence","description","content","progress","actionEntry","ready","may","shown","common"],"sources":["../src/agent.ts"],"sourcesContent":["import type { CloudletController } from './contracts/controller.js';\nimport type { ChangeSource } from './contracts/events.js';\nimport type { NotificationHandle } from './contracts/identity.js';\nimport type { FormErrors } from './contracts/internal.js';\nimport type { CommandAction, FormAction, FormFieldKind, FormInputMode, NotificationKind, Priority } from './contracts/notifications.js';\nimport type { CancellationSignal, OperationStatus } from './contracts/operations.js';\nimport type { NotificationLocation, NotificationSnapshot, PauseReason } from './contracts/snapshots.js';\nimport { createToasterPort, type FormReading, type PortCommit, type ToasterReading } from './core/agent-port.js';\n\n// The Toaster's side of the agent bridge. Its protocol types are declared here structurally:\n// this package never imports the bridge package, not even its types.\n\n/**\n * One record of an agent snapshot, as the bridge reads it.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type AgentEntryShape = {\n readonly ref: string;\n readonly component: string;\n readonly actions: readonly string[];\n readonly [key: string]: unknown;\n};\n\n/**\n * A cancellation signal as the bridge hands it out; an `AbortSignal` at runtime.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport interface AgentSignalShape {\n readonly aborted: boolean;\n readonly reason: unknown;\n readonly throwIfAborted: () => void;\n readonly addEventListener: (type: 'abort', listener: () => void, options?: { readonly once?: boolean }) => void;\n readonly removeEventListener: (type: 'abort', listener: () => void) => void;\n}\n\n/**\n * A value a step may return to the agent.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type AgentValueShape = string | number | boolean | null | readonly AgentValueShape[] | { readonly [key: string]: AgentValueShape };\n\n/**\n * What a step may do: on its own, with approval, or never.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type AgentPermissionShape = 'allow' | 'confirm' | 'deny';\n\n/**\n * A step as the bridge hands it to a component.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport interface AgentStepCallShape {\n readonly ref: string;\n readonly action: string;\n readonly args: readonly unknown[];\n}\n\n/**\n * How a person names what a step acts on, for the bridge's messages.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport interface AgentStepNamesShape {\n readonly target: string;\n readonly within?: string;\n}\n\n/**\n * A component's answer to the bridge's `check`.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type AgentStepCheckShape =\n | { readonly available: true; readonly permission: AgentPermissionShape; readonly names?: AgentStepNamesShape }\n | { readonly available: false; readonly message?: string };\n\n/**\n * What the bridge's `run` receives besides the step.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport interface AgentRunContextShape {\n readonly signal: AgentSignalShape;\n readonly approved: 'allow' | 'confirm';\n}\n\n/**\n * A component's answer to the bridge's `run`.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type AgentRunOutcomeShape =\n | { readonly status: 'done'; readonly result?: AgentValueShape; readonly gone?: boolean }\n | { readonly status: 'failed'; readonly message: string }\n | { readonly status: 'unavailable'; readonly message?: string }\n | { readonly status: 'stale' };\n\n/**\n * A component's answer to the bridge's `summon`.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type AgentSummonOutcomeShape = boolean | { readonly reached: boolean; readonly note: string };\n\n/**\n * One change a component reports to the bridge's subscribers: what changed on which record and who\n * changed it.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport interface AgentChangeShape {\n readonly ref: string;\n readonly component: string;\n readonly label?: string;\n readonly key: string;\n readonly value: AgentValueShape;\n readonly previous: AgentValueShape;\n readonly reason?: string;\n readonly source: 'user' | 'agent' | 'app' | 'system';\n}\n\n/**\n * What a component's verbs do, by kind of record: each verb with a line or two for an agent.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport interface AgentVerbsShape {\n readonly [component: string]: { readonly [verb: string]: string };\n}\n\n/**\n * What a component hands to the bridge's `connect`. `check` and `run` come together, `summon` is\n * optional, and a read-only component leaves all three out.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport interface AgentComponentShape<Entry extends AgentEntryShape = AgentEntryShape> {\n readonly protocol: 1;\n readonly name: string;\n snapshot(): readonly Entry[];\n subscribe(listener: (changes?: readonly AgentChangeShape[]) => void): () => void;\n readonly check?: (step: AgentStepCallShape) => AgentStepCheckShape;\n readonly run?: (step: AgentStepCallShape, context: AgentRunContextShape) => AgentRunOutcomeShape | PromiseLike<AgentRunOutcomeShape>;\n readonly summon?: (step: AgentStepCallShape) => AgentSummonOutcomeShape;\n readonly verbs?: AgentVerbsShape;\n}\n\n/**\n * The Toaster's own record: the Island, the count and the overflow.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type ToasterEntry = {\n readonly ref: string;\n readonly component: 'toaster';\n /** `open`, `close`, `clear`, `acknowledge`, by state. */\n readonly actions: readonly string[];\n readonly island: {\n readonly open: boolean;\n /** `ref` of the notification the open Island shows; null while closed. */\n readonly current: string | null;\n };\n readonly count: number;\n readonly overflow: { readonly count: number; readonly pending: boolean };\n /** A mounted `Toaster` renders this controller. */\n readonly mounted: boolean;\n};\n\n/**\n * A form field as a reader sees it. Its value, default and placeholder stay inside Cloudlet.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type FormFieldEntry = {\n readonly name: string;\n readonly label: string;\n readonly kind: FormFieldKind;\n readonly required: boolean;\n /** null when the field sets no limit. */\n readonly maxLength: number | null;\n /** null when the field sets no input mode. */\n readonly inputMode: FormInputMode | null;\n /** The field holds non-blank text. */\n readonly filled: boolean;\n /**\n * Who wrote the value last: `app` (the field's default), `user` (the person) or `agent`; null\n * while nobody has and there is no default. An agent can't `fill` a field the person wrote.\n */\n readonly filledBy: 'app' | 'user' | 'agent' | null;\n /**\n * Why the last submit stopped at this field, if it did: the built-in message for a required or\n * too long field, and a fixed phrase when the form's own `validate` did not accept it, because\n * that text may quote what the person typed.\n */\n readonly error: string | null;\n};\n\n/**\n * A notification's primary action.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type ActionEntry = {\n readonly kind: 'command' | 'link' | 'form';\n /** The label the application gave the action. */\n readonly label: string;\n readonly status: 'idle' | 'pending' | 'failed';\n /**\n * Why the last attempt failed; null unless `status` is `failed`. For a form it is always\n * `Action failed`: the app's own text may quote what the person typed.\n */\n readonly message: string | null;\n /**\n * What the app lets an agent do with a command or a form: `allow`, `confirm` (a person approves)\n * or `deny`. `confirm` when the app set nothing; absent for a link.\n */\n readonly agent?: 'allow' | 'confirm' | 'deny';\n /** Only for a link. */\n readonly href?: string;\n /** Only for a form. */\n readonly fields?: readonly FormFieldEntry[];\n /**\n * Set when the last submit stopped on the form as a whole; only for a form. A fixed phrase when\n * the form's own `validate` said so, for the same reason as a field's `error`.\n */\n readonly error?: string | null;\n};\n\n/**\n * A notification's operation, without its attempt token.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type OperationEntry = {\n readonly status: OperationStatus;\n readonly attempt: number;\n readonly canCancel: boolean;\n readonly canRetry: boolean;\n readonly cancelRequested: boolean;\n};\n\n/**\n * One notification, in presentation order.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type NotificationEntry = {\n readonly ref: string;\n readonly component: 'notification';\n /** `dismiss`, `show` (with a mounted `Toaster`), `press`, `fill`, `submit`, `cancel`, `retry`, by state. */\n readonly actions: readonly string[];\n /** The title. */\n readonly label: string;\n /** The description as text; for rich content, its announcement. */\n readonly text: string | null;\n readonly kind: NotificationKind;\n readonly priority: Priority;\n readonly occurrences: number;\n readonly location: NotificationLocation;\n readonly remainingMs: number | null;\n readonly pauseReasons: readonly PauseReason[];\n readonly progress: { readonly kind: 'indeterminate' | 'determinate'; readonly value: number | null; readonly label: string | null } | null;\n readonly draft: boolean;\n readonly operation: OperationEntry | null;\n readonly action: ActionEntry | null;\n};\n\n/** @experimental The protocol may change before the bridge reaches 1.0. */\nexport type ToasterAgentEntry = ToasterEntry | NotificationEntry;\n\n/**\n * What {@link toasterAgent} returns: pass it to the bridge's `connect`.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport interface ToasterAgent extends AgentComponentShape<ToasterAgentEntry> {\n /** The same frozen array until the controller changes; empty after `dispose`. */\n snapshot(): readonly ToasterAgentEntry[];\n /**\n * Calls `listener` after every change of the controller with what changed and who changed it.\n * On a notification's record: `present` (`true` when it appears, `false` when it closes, with\n * the close reason in `reason`), `content` (the app updated it; both values are null), `action`\n * (`idle`, `pending`, `failed`), `operation` (`pending`, `cancel-requested`, `fulfilled`,\n * `rejected`, `cancelled`) and `field:<name>` (who wrote the form field last: `app`, `user`,\n * `agent` or null; only when the author changes, and never the text). On the Toaster's record:\n * `island` (the `ref` of the notification it shows, or null) and `overflow` (the missed count\n * after it was acknowledged). `label` is the notification's title. The array is empty when the\n * snapshot changed with no author, such as a pause.\n */\n subscribe(listener: (changes?: readonly AgentChangeShape[]) => void): () => void;\n /** Whether a step is available now and the class it needs; no side effects. */\n readonly check: (step: AgentStepCallShape) => AgentStepCheckShape;\n /** Reads the controller again and runs the step, unless it changed since it was approved. */\n readonly run: (step: AgentStepCallShape, context: AgentRunContextShape) => AgentRunOutcomeShape | PromiseLike<AgentRunOutcomeShape>;\n /**\n * Opens the Island on the step's notification for a person, at once or once they stop using the\n * Toaster, without moving focus, and says which in `note`.\n */\n readonly summon: (step: AgentStepCallShape) => AgentSummonOutcomeShape;\n /** What each verb of the `toaster` and `notification` records does, for an agent. */\n readonly verbs: AgentVerbsShape;\n}\n\n/** @experimental The protocol may change before the bridge reaches 1.0. */\nexport interface ToasterAgentOptions {\n /** The component's name and the prefix of its refs; matches `[a-z][a-z0-9-]*`. Default `toaster`. */\n readonly name?: string;\n}\n\nconst freeze = Object.freeze;\nconst EMPTY: readonly never[] = freeze([]);\nconst quote = JSON.stringify;\nconst TOASTER_VERBS: ReadonlySet<string> = new Set(['open', 'close', 'clear', 'acknowledge']);\nconst NOTIFICATION_VERBS: ReadonlySet<string> = new Set(['dismiss', 'show', 'press', 'fill', 'submit', 'cancel', 'retry']);\n// For an agent that has never seen this code: arguments in order, what the step does, when it\n// needs a person. One entry for every verb a record can list.\nconst VERBS: AgentVerbsShape = freeze({\n toaster: freeze({\n open: 'No arguments. Opens the Island on the notification it shows first. Needs a mounted Toaster; refused while the person is using it.',\n close: 'No arguments. Closes the open Island; refused while it holds a form the person or an agent started filling.',\n clear: 'No arguments. Closes every notification at once.',\n acknowledge: 'No arguments. Marks the notifications that did not fit as seen: overflow.pending turns false.',\n }),\n notification: freeze({\n dismiss: 'No arguments. Closes this notification; its record leaves the snapshot.',\n show: 'No arguments. Opens the Island on this notification. Needs a mounted Toaster; refused while the person is using it.',\n press: 'No arguments. Runs the command action (action.kind \"command\") and waits for it: success closes the notification, result \"pending\" means it is still working. Under action.agent \"confirm\" it may need a person to approve. A link action has no verb: the bridge never opens it; its address is action.href.',\n fill: 'args [field name, text]: the field\\'s name from action.fields[].name, not its label, and a string. Writes the field as the agent; never over text the person typed.',\n submit: 'No arguments. Sends the form action (action.kind \"form\") and waits for it: success closes the notification, result \"pending\" means it is still working. Under action.agent \"confirm\" it may need a person to approve. A refusal names the fields that were not accepted.',\n cancel: 'No arguments. Asks the running operation to stop; result \"requested\".',\n retry: 'No arguments. Starts the failed operation again; result \"started\".',\n }),\n});\nconst STRICTNESS = { allow: 0, confirm: 1, deny: 2 } as const;\nconst DONE: AgentRunOutcomeShape = freeze({ status: 'done' });\nconst GONE: AgentRunOutcomeShape = freeze({ status: 'done', gone: true });\nconst STALE: AgentRunOutcomeShape = freeze({ status: 'stale' });\nconst UNAVAILABLE: AgentRunOutcomeShape = freeze({ status: 'unavailable' });\n\n// A form's `validate` and `errorMessage` see what the person typed and may quote it, so their\n// text stays with the person in the Island: an agent reads these instead.\nconst FORM_REJECTED = \"Not accepted by the form's own check\";\nconst FORM_FAILED = 'Action failed';\n\n// Refusals the adapter words itself; the bridge words the rest from the record's `actions`.\n// Labels and titles come from the app, so they are quoted.\nconst texts = {\n noScreen: (action: string) => `No Toaster is on screen: ${quote(action)} needs one.`,\n noArguments: (step: AgentStepCallShape) => `${quote(step.action)} on ${quote(step.ref)} takes no arguments.`,\n fillArguments: (step: AgentStepCallShape) => `${quote(step.action)} on ${quote(step.ref)} takes a field name and a value.`,\n noField: (step: AgentStepCallShape, name: string, names: readonly string[]) =>\n `No field ${quote(name)} on ${quote(step.ref)}. Fields: ${names.map((item) => quote(item)).join(', ')}.`,\n notText: (field: string) => `The value for ${quote(field)} must be a string.`,\n tooLong: (field: string, limit: number) => `${quote(field)} takes at most ${limit} characters.`,\n personTyped: (field: string) => `The person typed in ${quote(field)}. An agent can't overwrite it.`,\n notSent: (label: string, messages: string) => `${quote(label)} was not sent. ${messages}`,\n running: (label: string) => `${quote(label)} is already running.`,\n failed: (label: string, message: string) => `${quote(label)} failed: ${message}`,\n finished: 'This operation has already finished.',\n cancelRequested: 'Cancelling this operation was already requested.',\n notCancellable: \"This operation can't be cancelled.\",\n stillRunning: \"This operation is still running, so it can't be retried yet.\",\n notRetryable: \"This operation can't be retried.\",\n busy: 'The person is using the Island. Try again later.',\n islandOpen: 'The Island is open on it.',\n islandLater: 'The Island will open on it once they stop using it.',\n noToaster: 'No Toaster is on screen, so tell them what it does.',\n};\n\n/** A step as the adapter sees it right now: refused, or allowed under a class with a way to run it. */\ntype Plan =\n | { readonly available: false; readonly message?: string }\n | {\n readonly available: true;\n readonly permission: AgentPermissionShape;\n readonly names?: AgentStepNamesShape;\n /** The action object a press or a submit would run. */\n readonly subject?: object;\n readonly perform: (context: AgentRunContextShape) => AgentRunOutcomeShape | Promise<AgentRunOutcomeShape>;\n };\n\nconst NO_AUTHORS: FormReading['authors'] = new Map();\nconst NOT_AVAILABLE: Plan = freeze({ available: false });\nconst refuse = (message: string): Plan => freeze({ available: false, message });\nconst allowed = (perform: () => AgentRunOutcomeShape): Plan => freeze({ available: true, permission: 'allow', perform });\ntype PortResult = { readonly status: string; readonly reason?: string };\n/** A port refusal after the plan said yes: the state changed in between, so the step is unavailable. */\nconst outcome = (result: PortResult, done: AgentRunOutcomeShape, words: Readonly<Record<string, string>> = {}): AgentRunOutcomeShape => {\n if (result.status !== 'rejected') return done;\n const message = result.reason === undefined ? undefined : words[result.reason];\n return message === undefined ? UNAVAILABLE : freeze({ status: 'unavailable', message });\n};\n\n/**\n * Lets an agent read and drive a controller through the kit's agent bridge:\n * `agent.connect(toasterAgent(controller))`. It touches no DOM, starts no timers, never takes the\n * host from a `Toaster` and never moves focus. Form values never reach the snapshot.\n *\n * Steps: `open`, `close`, `clear` and `acknowledge` on the Toaster record; `show`, `dismiss`,\n * `press`, `fill`, `submit`, `cancel` and `retry` on a notification. `open` and `show` need a\n * mounted `Toaster`. `press` and `submit` follow the action's `agent` marker; every other step is\n * allowed unless the bridge's `allow` says no. `fill` (`args: [name, value]`) writes a form field\n * as the agent, never over what the person typed, and makes a draft as typing does; the snapshot\n * says who wrote each field (`filledBy`), never what. A press or submit that needs a person opens\n * the Island on its notification for them: at once, or after the attention delay once they stop\n * using the Toaster. While they use it (hover, focus, a gesture, a draft in the open Island, the\n * agent's own included), `open` and `show` are refused, and so is `close` over a draft.\n *\n * @throws TypeError for a controller that this copy of `@cloudlet/toast` did not create.\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport function toasterAgent<Slot, Signal extends CancellationSignal>(\n controller: Omit<CloudletController<Slot, Signal>, 'track'>,\n options?: ToasterAgentOptions,\n): ToasterAgent {\n const name = options?.name ?? 'toaster';\n const port = createToasterPort<Slot>(controller);\n // A number per handle, so a closed notification's ref is never handed to another one.\n const refs = new WeakMap<NotificationHandle, string>();\n let issued = 0;\n const refOf = (handle: NotificationHandle): string => {\n let ref = refs.get(handle);\n if (ref === undefined) refs.set(handle, ref = `${name}:${++issued}`);\n return ref;\n };\n // What the last change records said about each open notification, kept while someone listens.\n type Known = {\n label: string | undefined;\n action: 'idle' | 'pending' | 'failed';\n operation: { readonly token: string; value: string } | null;\n authors: FormReading['authors'];\n };\n const known = new Map<NotificationHandle, Known>();\n let islandRef: string | null = null;\n // The revision `known` was read at; a commit up to it is already in there.\n let seeded = 0;\n const listeners = new Set<(changes?: readonly AgentChangeShape[]) => void>();\n let stop: (() => void) | undefined;\n let source: ToasterReading<Slot> | undefined;\n let entries: readonly ToasterAgentEntry[] = EMPTY;\n // The notifications of the current snapshot by ref, for steps.\n let targets: ReadonlyMap<string, { readonly item: NotificationSnapshot<Slot>; readonly entry: NotificationEntry }> = new Map();\n\n const snapshot = (): readonly ToasterAgentEntry[] => {\n const reading = port.read();\n if (reading === source) return entries;\n source = reading;\n const state = reading.controller;\n if (state.disposed) { targets = new Map(); return entries = EMPTY; }\n const byHandle = new Map(state.notifications.map((item) => [item.handle, item] as const));\n const island = state.island;\n const count = state.stack.length;\n const found = new Map<string, { readonly item: NotificationSnapshot<Slot>; readonly entry: NotificationEntry }>();\n // Refs are issued in presentation order, so the top notification gets the lower number.\n const notifications = state.stack.map((handle) => {\n const item = byHandle.get(handle)!;\n const entry = notification(item, refOf(handle), island.open && island.current === handle, reading.mounted, reading.forms.get(handle));\n found.set(entry.ref, { item, entry });\n return entry;\n });\n targets = found;\n const toaster: ToasterEntry = freeze({\n ref: name, component: 'toaster' as const,\n actions: freeze([\n ...(!island.open && count > 0 && reading.mounted ? ['open'] : []),\n ...(island.open ? ['close'] : []),\n ...(count > 0 ? ['clear'] : []),\n ...(state.overflow.pending ? ['acknowledge'] : []),\n ]),\n island: freeze({ open: island.open, current: island.current ? refOf(island.current) : null }),\n count,\n overflow: freeze({ count: state.overflow.count, pending: state.overflow.pending }),\n mounted: reading.mounted,\n });\n return entries = freeze([toaster, ...notifications]);\n };\n\n /** Reads the step against the controller as it is now; `check` and `run` both start here. */\n const plan = (step: AgentStepCallShape): Plan => {\n const current = snapshot();\n const mounted = source?.mounted ?? false;\n const { action } = step;\n if (step.ref === name && current.length) {\n if (!TOASTER_VERBS.has(action)) return NOT_AVAILABLE;\n if (step.args.length) return refuse(texts.noArguments(step));\n if (action === 'open' && !mounted) return refuse(texts.noScreen(action));\n if (!current[0]!.actions.includes(action)) return NOT_AVAILABLE;\n // A busy person is not interrupted; only a draft stops `close`, which a person's Escape would collapse.\n if (action === 'open' && source!.busy) return refuse(texts.busy);\n if (action === 'close' && holdsDraft()) return refuse(texts.busy);\n switch (action) {\n case 'open': return allowed(() => outcome(port.open(), DONE, { 'no-host': texts.noScreen(action), busy: texts.busy }));\n case 'close': return allowed(() => outcome(port.close(), DONE, { busy: texts.busy }));\n case 'clear': return allowed(() => outcome(port.clear(), DONE));\n default: return allowed(() => outcome(port.acknowledge(), DONE));\n }\n }\n const target = targets.get(step.ref);\n if (!target || !NOTIFICATION_VERBS.has(action)) return NOT_AVAILABLE;\n const { item, entry } = target;\n if (action === 'fill') return fillPlan(step, item);\n if (step.args.length) return refuse(texts.noArguments(step));\n const { handle } = item;\n switch (action) {\n case 'show':\n if (!mounted) return refuse(texts.noScreen(action));\n break;\n case 'press': {\n const command = item.content.action;\n return command?.kind === 'command' ? pressPlan(item, command) : NOT_AVAILABLE;\n }\n case 'submit': {\n const form = item.content.action;\n return form?.kind === 'form' ? pressPlan(item, form) : NOT_AVAILABLE;\n }\n case 'cancel': {\n const operation = item.operation;\n if (!operation) return NOT_AVAILABLE;\n if (operation.status !== 'pending') return refuse(texts.finished);\n if (operation.cancelRequested) return refuse(texts.cancelRequested);\n if (!operation.canCancel) return refuse(texts.notCancellable);\n break;\n }\n case 'retry': {\n const operation = item.operation;\n if (!operation) return NOT_AVAILABLE;\n if (operation.status === 'pending') return refuse(texts.stillRunning);\n if (!operation.canRetry) return refuse(texts.notRetryable);\n break;\n }\n }\n if (!entry.actions.includes(action)) return NOT_AVAILABLE;\n if (action === 'show' && source!.busy) return refuse(texts.busy);\n switch (action) {\n case 'show': return allowed(() => outcome(port.show(handle), DONE, { 'no-host': texts.noScreen(action), busy: texts.busy }));\n case 'dismiss': return allowed(() => outcome(port.dismiss(handle), GONE));\n case 'cancel': return allowed(() => {\n const result = port.cancel(handle);\n return result.status === 'requested' ? freeze({ status: 'done', result: 'requested' })\n : outcome(result.status === 'unchanged' ? { status: 'rejected', reason: result.reason } : result, DONE, {\n settled: texts.finished, 'already-requested': texts.cancelRequested, 'not-cancellable': texts.notCancellable,\n });\n });\n default: return allowed(() => outcome(port.retry(handle), freeze({ status: 'done', result: 'started' }), {\n 'already-pending': texts.stillRunning, 'not-retryable': texts.notRetryable,\n }));\n }\n };\n\n /** The open Island shows a notification whose form holds a draft. */\n const holdsDraft = (): boolean => {\n const state = source!.controller;\n const current = state.island.current;\n return current !== null && state.notifications.some((item) => item.handle === current && item.draft);\n };\n\n // An agent's value goes in like a person's keystrokes, except over what the person typed. The\n // step's text names the field, never a value.\n const fillPlan = (step: AgentStepCallShape, item: NotificationSnapshot<Slot>): Plan => {\n const form = item.content.action;\n if (form?.kind !== 'form') return NOT_AVAILABLE;\n const [name, value] = step.args;\n if (step.args.length !== 2 || typeof name !== 'string') return refuse(texts.fillArguments(step));\n const field = form.fields.find((candidate) => candidate.name === name);\n if (!field) return refuse(texts.noField(step, name, form.fields.map((candidate) => candidate.name)));\n if (typeof value !== 'string') return refuse(texts.notText(field.label));\n const words = {\n 'already-pending': texts.running(form.label),\n 'too-long': texts.tooLong(field.label, field.maxLength ?? 0),\n 'person-typed': texts.personTyped(field.label),\n };\n if (item.action.status === 'pending') return refuse(words['already-pending']);\n if (field.maxLength !== undefined && value.length > field.maxLength) return refuse(words['too-long']);\n if (source!.forms.get(item.handle)?.authors.get(name) === 'user') return refuse(words['person-typed']);\n return allowed(() => outcome(port.fill(item.handle, name, value), DONE, words));\n };\n\n /** A command's press or a form's submit: both follow the action's marker and wait for its run. */\n const pressPlan = (item: NotificationSnapshot<Slot>, action: CommandAction | FormAction): Plan => {\n const { label } = action;\n const permission = action.agent ?? 'confirm';\n const names = freeze({ target: label, within: item.content.title });\n // A denied press never runs, so it is reported before its state.\n if (permission !== 'deny' && item.action.status === 'pending') return refuse(texts.running(label));\n return freeze({\n available: true, permission, names, subject: action,\n async perform({ signal, approved }: AgentRunContextShape): Promise<AgentRunOutcomeShape> {\n const started = port.press(item.handle, approved, signal);\n if (!(started instanceof Promise)) {\n return started.reason === 'stale' ? STALE : outcome(started, DONE, { 'already-pending': texts.running(label) });\n }\n const ended = await started;\n if (ended.status === 'done') return GONE;\n if (ended.status === 'replaced') return STALE;\n if (ended.status === 'failed') return freeze({ status: 'failed', message: texts.failed(label, action.kind === 'form' ? FORM_FAILED : ended.message) });\n if (ended.status === 'invalid') return freeze({ status: 'failed', message: texts.notSent(label, describe(action as FormAction, ended.errors)) });\n return freeze({ status: 'done', result: 'pending', ...(ended.gone ? { gone: true } : {}) });\n },\n });\n };\n\n // What a checked press or submit would have run, by step object: the bridge approves a step by\n // its ref and verb, so the action it named to the app or the person is held here until it runs.\n const checked = new WeakMap<AgentStepCallShape, object>();\n\n const check = (step: AgentStepCallShape): AgentStepCheckShape => {\n const verdict = plan(step);\n if (!verdict.available) return verdict;\n if (verdict.subject) checked.set(step, verdict.subject);\n return freeze({ available: true, permission: verdict.permission, ...(verdict.names ? { names: verdict.names } : {}) });\n };\n\n // The bridge approved the step under `approved`; the controller is read again before anything runs.\n const run = (step: AgentStepCallShape, context: AgentRunContextShape): AgentRunOutcomeShape | Promise<AgentRunOutcomeShape> => {\n const verdict = plan(step);\n if (!verdict.available) return verdict.message === undefined ? UNAVAILABLE : freeze({ status: 'unavailable', message: verdict.message });\n if (STRICTNESS[verdict.permission] > STRICTNESS[context.approved]) return STALE;\n // The app replaced the action while the step waited: the approval was for the other one.\n const subject = checked.get(step);\n if (subject !== undefined && subject !== verdict.subject) return STALE;\n return verdict.perform(context);\n };\n\n // A step only a person may take: the Island opens on its notification for them, through the\n // attention queue, so a person busy with the Toaster is not interrupted.\n const summon = (step: AgentStepCallShape): AgentSummonOutcomeShape => {\n snapshot();\n const target = targets.get(step.ref);\n if (!target) return false;\n const result = port.summon(target.item.handle);\n if (result.status === 'rejected') return result.reason === 'no-host' ? freeze({ reached: false, note: texts.noToaster }) : false;\n return freeze({ reached: true, note: result.status === 'waiting' ? texts.islandLater : texts.islandOpen });\n };\n\n /**\n * The records of one committed change: its events in order, then what only the state shows (an\n * action back to idle, a field's new author, the Island). A form's values are never read here.\n */\n const collect = (commit: PortCommit<Slot>): readonly AgentChangeShape[] => {\n // The commit's own state, not the latest: a listener before this one may have committed again.\n const state = commit.controller;\n // Subscribed while this commit was still queued: what it did was read then.\n if (state.revision <= seeded) return EMPTY;\n const { events } = commit;\n const live = new Map(state.notifications.map((item) => [item.handle, item] as const));\n for (const [handle, entry] of known) {\n const item = live.get(handle);\n if (item) entry.label = item.content.title;\n }\n const changes: AgentChangeShape[] = [];\n // Who changed a notification's content in this commit: the author of what follows from it.\n const touched = new Map<NotificationHandle, ChangeSource>();\n const push = (handle: NotificationHandle, key: string, value: AgentValueShape, previous: AgentValueShape, by: ChangeSource, reason?: string): void => {\n const label = known.get(handle)?.label;\n changes.push(freeze({\n ref: refOf(handle), component: 'notification', ...(label === undefined ? {} : { label }), key, value, previous,\n ...(reason === undefined ? {} : { reason }), source: by,\n }));\n };\n for (const event of events) {\n switch (event.type) {\n case 'admitted': {\n // The number is issued here, so a notification closed before anyone reads still has one.\n refOf(event.handle);\n known.set(event.handle, {\n label: live.get(event.handle)?.content.title, action: 'idle', operation: null,\n authors: commit.authors.get(event.handle) ?? NO_AUTHORS,\n });\n push(event.handle, 'present', true, false, event.source);\n break;\n }\n case 'closed':\n push(event.handle, 'present', false, true, event.source, event.reason);\n known.delete(event.handle);\n break;\n case 'updated':\n touched.set(event.handle, event.source);\n push(event.handle, 'content', null, null, event.source);\n break;\n case 'action-started':\n case 'action-failed': {\n const entry = known.get(event.handle);\n if (!entry) break;\n const next = event.type === 'action-started' ? 'pending' : 'failed';\n push(event.handle, 'action', next, entry.action, event.source);\n entry.action = next;\n break;\n }\n case 'operation-started': {\n const entry = event.handle && known.get(event.handle);\n if (!entry) break;\n touched.set(event.handle!, event.source);\n push(event.handle!, 'operation', 'pending', entry.operation?.value ?? null, event.source);\n entry.operation = { token: event.token, value: 'pending' };\n break;\n }\n case 'cancellation-requested':\n case 'operation-settled': {\n const entry = event.handle && known.get(event.handle);\n // An attempt that a newer one replaced no longer speaks for the notification.\n if (!entry || entry.operation?.token !== event.token) break;\n if (event.type === 'operation-settled') touched.set(event.handle!, event.source);\n const next = event.type === 'operation-settled' ? event.status : 'cancel-requested';\n push(event.handle!, 'operation', next, entry.operation.value, event.source);\n entry.operation.value = next;\n break;\n }\n case 'overflow-acknowledged':\n changes.push(freeze({ ref: name, component: 'toaster', key: 'overflow', value: 0, previous: event.count, source: event.source }));\n break;\n }\n }\n for (const [handle, entry] of known) {\n // A notification missing here closed in a later commit; its own records follow.\n const item = live.get(handle);\n if (!item) continue;\n const by = touched.get(handle);\n if (item.action.status === 'idle' && entry.action !== 'idle') {\n push(handle, 'action', 'idle', entry.action, by ?? 'system');\n entry.action = 'idle';\n }\n const authors = commit.authors.get(handle) ?? NO_AUTHORS;\n if (authors !== entry.authors) {\n // In the form's own order; a field of the form that was replaced comes after them.\n const action = item.content.action;\n const names = action?.kind === 'form' ? action.fields.map((field) => field.name) : [];\n for (const field of new Set([...names, ...entry.authors.keys(), ...authors.keys()])) {\n const next = authors.get(field) ?? null;\n const previous = entry.authors.get(field) ?? null;\n // A new author is the source; a field emptied with its form was replaced by the app.\n if (next !== previous) push(handle, `field:${field}`, next, previous, next ?? by ?? 'app');\n }\n entry.authors = authors;\n }\n }\n const current = state.island.current ? refOf(state.island.current) : null;\n if (current !== islandRef) {\n changes.push(freeze({\n ref: name, component: 'toaster', key: 'island', value: current, previous: islandRef,\n source: state.island.source ?? commit.closedBy ?? 'system',\n }));\n islandRef = current;\n }\n return freeze(changes);\n };\n\n const subscribe = (listener: (changes?: readonly AgentChangeShape[]) => void): (() => void) => {\n // The same function may subscribe twice; each subscription is removed on its own.\n const own = (changes?: readonly AgentChangeShape[]): void => { listener(changes); };\n if (!listeners.size) {\n // Refs of what is already there are issued as a snapshot does, top first.\n snapshot();\n const reading = port.read();\n const state = reading.controller;\n known.clear();\n for (const item of state.notifications) {\n const operation = item.operation;\n known.set(item.handle, {\n label: item.content.title, action: item.action.status,\n operation: operation ? { token: operation.token, value: operation.status === 'pending' && operation.cancelRequested ? 'cancel-requested' : operation.status } : null,\n authors: reading.forms.get(item.handle)?.authors ?? NO_AUTHORS,\n });\n }\n islandRef = state.island.current ? refOf(state.island.current) : null;\n seeded = state.revision;\n stop = port.subscribe((commit) => {\n const changes = collect(commit);\n // Every listener hears the change; the first error goes on to the controller's diagnostics.\n let failure: { readonly error: unknown } | undefined;\n for (const each of [...listeners]) {\n if (!listeners.has(each)) continue;\n try { each(changes); } catch (error) { failure ??= { error }; }\n }\n if (failure) throw failure.error;\n });\n }\n listeners.add(own);\n return () => {\n if (!listeners.delete(own) || listeners.size) return;\n stop?.();\n stop = undefined;\n known.clear();\n };\n };\n\n return freeze({ protocol: 1 as const, name, snapshot, subscribe, check, run, summon, verbs: VERBS });\n}\n\n/**\n * Why a form was not sent, by field label and never with a value: the built-in messages as the\n * person sees them, and for the app's own `validate` only which fields it did not accept.\n */\nfunction describe(form: FormAction, errors: FormErrors): string {\n if (errors.broken) return `${FORM_FAILED}.`;\n if (errors.authored) {\n // Own keys only, as below.\n const labels = form.fields.flatMap((field) => Object.hasOwn(errors.fields, field.name) ? [quote(field.label)] : []);\n return `The form's own check did not accept ${labels.length ? labels.join(', ') : 'it'}.`;\n }\n const sentence = (message: string) => /[.!?]$/.test(message.trim()) ? message.trim() : `${message.trim()}.`;\n return [\n // Own keys only: a field named `constructor` must not read `Object.prototype`.\n ...form.fields.flatMap((field) => Object.hasOwn(errors.fields, field.name) ? [`${quote(field.label)}: ${sentence(errors.fields[field.name]!)}`] : []),\n ...(errors.form ? [sentence(errors.form)] : []),\n ].join(' ');\n}\n\nfunction notification<Slot>(item: NotificationSnapshot<Slot>, ref: string, shown: boolean, mounted: boolean, form: FormReading | undefined): NotificationEntry {\n const { content } = item;\n const description = content.description;\n const progress = content.progress;\n const operation = item.operation;\n const action = actionEntry(item, form);\n // `deny` stops pressing and submitting only: a person can still submit what an agent filled.\n const ready = item.action.status !== 'pending';\n const may = ready && action?.agent !== 'deny';\n return freeze({\n ref, component: 'notification' as const,\n actions: freeze([\n 'dismiss',\n ...(!shown && mounted ? ['show'] : []),\n ...(action?.kind === 'command' && may ? ['press'] : []),\n ...(action?.kind === 'form' && ready ? ['fill'] : []),\n ...(action?.kind === 'form' && may ? ['submit'] : []),\n ...(operation?.canCancel ? ['cancel'] : []),\n ...(operation?.canRetry ? ['retry'] : []),\n ]),\n label: content.title,\n text: description ? description.kind === 'text' ? description.text : description.announcement : null,\n kind: item.kind,\n priority: item.priority,\n occurrences: item.occurrences,\n location: item.location,\n remainingMs: item.remainingMs,\n pauseReasons: freeze([...item.pauseReasons]),\n progress: progress ? freeze({\n kind: progress.kind,\n value: progress.kind === 'determinate' ? progress.value : null,\n label: progress.label ?? null,\n }) : null,\n draft: item.draft,\n operation: operation ? freeze({\n status: operation.status, attempt: operation.attempt, canCancel: operation.canCancel,\n canRetry: operation.canRetry, cancelRequested: operation.cancelRequested,\n }) : null,\n action,\n });\n}\n\nfunction actionEntry<Slot>(item: NotificationSnapshot<Slot>, form: FormReading | undefined): ActionEntry | null {\n const action = item.content.action;\n if (!action) return null;\n const state = item.action;\n const common = {\n kind: action.kind, label: action.label, status: state.status,\n message: state.status !== 'failed' ? null : action.kind === 'form' ? FORM_FAILED : state.message,\n };\n if (action.kind === 'link') return freeze({ ...common, href: action.href });\n if (action.kind === 'command') return freeze({ ...common, agent: action.agent ?? 'confirm' });\n const errors = form?.errors;\n return freeze({\n ...common,\n agent: action.agent ?? 'confirm',\n fields: freeze(action.fields.map((field) => freeze({\n name: field.name, label: field.label, kind: field.kind, required: field.required ?? false,\n maxLength: field.maxLength ?? null, inputMode: field.inputMode ?? null,\n filled: form?.filled.has(field.name) ?? false,\n filledBy: form?.authors.get(field.name) ?? null,\n // Own keys only: a field named `constructor` must not read `Object.prototype`.\n error: errors && Object.hasOwn(errors.fields, field.name) ? errors.authored ? FORM_REJECTED : errors.fields[field.name]! : null,\n }))),\n error: errors?.form ? errors.broken ? FORM_FAILED : errors.authored ? FORM_REJECTED : errors.form : null,\n });\n}\n"],"mappings":";;AA0TA,IAAMA,IAAS,OAAO,QAChBC,IAA0BD,EAAO,CAAC,CAAC,GACnCE,IAAQ,KAAK,WACbC,oBAAqC,IAAI,IAAI;CAAC;CAAQ;CAAS;CAAS;AAAa,CAAC,GACtFC,oBAA0C,IAAI,IAAI;CAAC;CAAW;CAAQ;CAAS;CAAQ;CAAU;CAAU;AAAO,CAAC,GAGnHC,IAAyBL,EAAO;CACpC,SAASA,EAAO;EACd,MAAM;EACN,OAAO;EACP,OAAO;EACP,aAAa;CACf,CAAC;CACD,cAAcA,EAAO;EACnB,SAAS;EACT,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACR,QAAQ;EACR,OAAO;CACT,CAAC;AACH,CAAC,GACKM,IAAa;CAAE,OAAO;CAAG,SAAS;CAAG,MAAM;AAAE,GAC7CC,IAA6BP,EAAO,EAAE,QAAQ,OAAO,CAAC,GACtDQ,IAA6BR,EAAO;CAAE,QAAQ;CAAQ,MAAM;AAAK,CAAC,GAClES,IAA8BT,EAAO,EAAE,QA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F,EAAO,WAAW3F,IAAgB2F,EAAO,OAAO;CACtG,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"agent.js","names":["freeze","EMPTY","quote","TOASTER_VERBS","NOTIFICATION_VERBS","VERBS","STRICTNESS","DONE","GONE","STALE","UNAVAILABLE","FORM_REJECTED","FORM_FAILED","texts","action","step","name","names","item","field","limit","label","messages","message","NO_AUTHORS","NOT_AVAILABLE","refuse","allowed","outcome","result","done","words","toasterAgent","options","port","createToasterPort","controller","refs","issued","refOf","ref","handle","known","islandRef","seeded","listeners","stop","source","entries","targets","snapshot","reading","state","byHandle","island","count","found","notifications","entry","notification","plan","current","mounted","holdsDraft","target","fillPlan","command","pressPlan","form","operation","value","candidate","permission","started","approved","signal","ended","describe","checked","check","verdict","run","context","subject","summon","collect","commit","live","changes","touched","push","reason","by","event","events","next","authors","previous","own","listener","revision","each","error","errors","labels","sentence","description","content","progress","actionEntry","ready","may","shown","common"],"sources":["../src/agent.ts"],"sourcesContent":["import type { CloudletController } from './contracts/controller.js';\nimport type { ChangeSource } from './contracts/events.js';\nimport type { NotificationHandle } from './contracts/identity.js';\nimport type { FormErrors } from './contracts/internal.js';\nimport type { CommandAction, FormAction, FormFieldKind, FormInputMode, NotificationKind, Priority } from './contracts/notifications.js';\nimport type { CancellationSignal, OperationStatus } from './contracts/operations.js';\nimport type { NotificationLocation, NotificationSnapshot, PauseReason } from './contracts/snapshots.js';\nimport { createToasterPort, type FormReading, type PortCommit, type ToasterReading } from './core/agent-port.js';\n\n// The Toaster's side of the agent bridge. Its protocol types are declared here structurally:\n// this package never imports the bridge package, not even its types.\n\n/**\n * One record of an agent snapshot, as the bridge reads it.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type AgentEntryShape = {\n readonly ref: string;\n readonly component: string;\n readonly actions: readonly string[];\n readonly [key: string]: unknown;\n};\n\n/**\n * A cancellation signal as the bridge hands it out; an `AbortSignal` at runtime.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport interface AgentSignalShape {\n readonly aborted: boolean;\n readonly reason: unknown;\n readonly throwIfAborted: () => void;\n readonly addEventListener: (type: 'abort', listener: () => void, options?: { readonly once?: boolean }) => void;\n readonly removeEventListener: (type: 'abort', listener: () => void) => void;\n}\n\n/**\n * A value a step may return to the agent.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type AgentValueShape = string | number | boolean | null | readonly AgentValueShape[] | { readonly [key: string]: AgentValueShape };\n\n/**\n * What a step may do: on its own, with approval, or never.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type AgentPermissionShape = 'allow' | 'confirm' | 'deny';\n\n/**\n * A step as the bridge hands it to a component.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport interface AgentStepCallShape {\n readonly ref: string;\n readonly action: string;\n readonly args: readonly unknown[];\n}\n\n/**\n * How a person names what a step acts on, for the bridge's messages.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport interface AgentStepNamesShape {\n readonly target: string;\n readonly within?: string;\n}\n\n/**\n * A component's answer to the bridge's `check`.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type AgentStepCheckShape =\n | { readonly available: true; readonly permission: AgentPermissionShape; readonly names?: AgentStepNamesShape }\n | { readonly available: false; readonly message?: string };\n\n/**\n * What the bridge's `run` receives besides the step.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport interface AgentRunContextShape {\n readonly signal: AgentSignalShape;\n readonly approved: 'allow' | 'confirm';\n}\n\n/**\n * A component's answer to the bridge's `run`.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type AgentRunOutcomeShape =\n | { readonly status: 'done'; readonly result?: AgentValueShape; readonly gone?: boolean }\n | { readonly status: 'failed'; readonly message: string }\n | { readonly status: 'unavailable'; readonly message?: string }\n | { readonly status: 'stale' };\n\n/**\n * A component's answer to the bridge's `summon`.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type AgentSummonOutcomeShape = boolean | { readonly reached: boolean; readonly note: string };\n\n/**\n * One change a component reports to the bridge's subscribers: what changed on which record and who\n * changed it.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport interface AgentChangeShape {\n readonly ref: string;\n readonly component: string;\n readonly label?: string;\n readonly key: string;\n readonly value: AgentValueShape;\n readonly previous: AgentValueShape;\n readonly reason?: string;\n readonly source: 'user' | 'agent' | 'app' | 'system';\n}\n\n/**\n * What a component's verbs do, by kind of record: each verb with a line or two for an agent.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport interface AgentVerbsShape {\n readonly [component: string]: { readonly [verb: string]: string };\n}\n\n/**\n * What a component hands to the bridge's `connect`. `check` and `run` come together, `summon` is\n * optional, and a read-only component leaves all three out.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport interface AgentComponentShape<Entry extends AgentEntryShape = AgentEntryShape> {\n readonly protocol: 1;\n readonly name: string;\n snapshot(): readonly Entry[];\n subscribe(listener: (changes?: readonly AgentChangeShape[]) => void): () => void;\n readonly check?: (step: AgentStepCallShape) => AgentStepCheckShape;\n readonly run?: (step: AgentStepCallShape, context: AgentRunContextShape) => AgentRunOutcomeShape | PromiseLike<AgentRunOutcomeShape>;\n readonly summon?: (step: AgentStepCallShape) => AgentSummonOutcomeShape;\n readonly verbs?: AgentVerbsShape;\n}\n\n/**\n * The Toaster's own record: the Island, the count and the overflow.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type ToasterEntry = {\n readonly ref: string;\n readonly component: 'toaster';\n /** `open`, `close`, `clear`, `acknowledge`, by state. */\n readonly actions: readonly string[];\n readonly island: {\n readonly open: boolean;\n /** `ref` of the notification the open Island shows; null while closed. */\n readonly current: string | null;\n };\n readonly count: number;\n readonly overflow: { readonly count: number; readonly pending: boolean };\n /** A mounted `Toaster` renders this controller. */\n readonly mounted: boolean;\n};\n\n/**\n * A form field as a reader sees it. Its value, default and placeholder stay inside Cloudlet.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type FormFieldEntry = {\n readonly name: string;\n readonly label: string;\n readonly kind: FormFieldKind;\n readonly required: boolean;\n /** null when the field sets no limit. */\n readonly maxLength: number | null;\n /** null when the field sets no input mode. */\n readonly inputMode: FormInputMode | null;\n /** The field holds non-blank text. */\n readonly filled: boolean;\n /**\n * Who wrote the value last: `app` (the field's default), `user` (the person) or `agent`; null\n * while nobody has and there is no default. An agent can't `fill` a field the person wrote.\n */\n readonly filledBy: 'app' | 'user' | 'agent' | null;\n /**\n * Why the last submit stopped at this field, if it did: the built-in message for a required or\n * too long field, and a fixed phrase when the form's own `validate` did not accept it, because\n * that text may quote what the person typed.\n */\n readonly error: string | null;\n};\n\n/**\n * A notification's primary action.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type ActionEntry = {\n readonly kind: 'command' | 'link' | 'form';\n /** The label the application gave the action. */\n readonly label: string;\n readonly status: 'idle' | 'pending' | 'failed';\n /**\n * Why the last attempt failed; null unless `status` is `failed`. For a form it is always\n * `Action failed`: the app's own text may quote what the person typed.\n */\n readonly message: string | null;\n /**\n * What the app lets an agent do with a command or a form: `allow`, `confirm` (a person approves)\n * or `deny`. `confirm` when the app set nothing; absent for a link.\n */\n readonly agent?: 'allow' | 'confirm' | 'deny';\n /** Only for a link. */\n readonly href?: string;\n /** Only for a form. */\n readonly fields?: readonly FormFieldEntry[];\n /**\n * Set when the last submit stopped on the form as a whole; only for a form. A fixed phrase when\n * the form's own `validate` said so, for the same reason as a field's `error`.\n */\n readonly error?: string | null;\n};\n\n/**\n * A notification's operation, without its attempt token.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type OperationEntry = {\n readonly status: OperationStatus;\n readonly attempt: number;\n readonly canCancel: boolean;\n readonly canRetry: boolean;\n readonly cancelRequested: boolean;\n};\n\n/**\n * One notification, in presentation order.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type NotificationEntry = {\n readonly ref: string;\n readonly component: 'notification';\n /** `dismiss`, `show` (with a mounted `Toaster`), `press`, `fill`, `submit`, `cancel`, `retry`, by state. */\n readonly actions: readonly string[];\n /** The title. */\n readonly label: string;\n /** The description as text; for rich content, its announcement. */\n readonly text: string | null;\n readonly kind: NotificationKind;\n readonly priority: Priority;\n readonly occurrences: number;\n readonly location: NotificationLocation;\n readonly remainingMs: number | null;\n readonly pauseReasons: readonly PauseReason[];\n readonly progress: { readonly kind: 'indeterminate' | 'determinate'; readonly value: number | null; readonly label: string | null } | null;\n readonly draft: boolean;\n readonly operation: OperationEntry | null;\n readonly action: ActionEntry | null;\n};\n\n/** @experimental The protocol may change before the bridge reaches 1.0. */\nexport type ToasterAgentEntry = ToasterEntry | NotificationEntry;\n\n/**\n * What {@link toasterAgent} returns: pass it to the bridge's `connect`.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport interface ToasterAgent extends AgentComponentShape<ToasterAgentEntry> {\n /** The same frozen array until the controller changes; empty after `dispose`. */\n snapshot(): readonly ToasterAgentEntry[];\n /**\n * Calls `listener` after every change of the controller with what changed and who changed it.\n * On a notification's record: `present` (`true` when it appears, `false` when it closes, with\n * the close reason in `reason`), `content` (the app updated it; both values are null), `action`\n * (`idle`, `pending`, `failed`), `operation` (`pending`, `cancel-requested`, `fulfilled`,\n * `rejected`, `cancelled`) and `field:<name>` (who wrote the form field last: `app`, `user`,\n * `agent` or null; only when the author changes, and never the text). On the Toaster's record:\n * `island` (the `ref` of the notification it shows, or null) and `overflow` (the missed count\n * after it was acknowledged). `label` is the notification's title. The array is empty when the\n * snapshot changed with no author, such as a pause.\n */\n subscribe(listener: (changes?: readonly AgentChangeShape[]) => void): () => void;\n /** Whether a step is available now and the class it needs; no side effects. */\n readonly check: (step: AgentStepCallShape) => AgentStepCheckShape;\n /** Reads the controller again and runs the step, unless it changed since it was approved. */\n readonly run: (step: AgentStepCallShape, context: AgentRunContextShape) => AgentRunOutcomeShape | PromiseLike<AgentRunOutcomeShape>;\n /**\n * Opens the Island on the step's notification for a person, at once or once they stop using the\n * Toaster, without moving focus, and says which in `note`.\n */\n readonly summon: (step: AgentStepCallShape) => AgentSummonOutcomeShape;\n /** What each verb of the `toaster` and `notification` records does, for an agent. */\n readonly verbs: AgentVerbsShape;\n}\n\n/** @experimental The protocol may change before the bridge reaches 1.0. */\nexport interface ToasterAgentOptions {\n /** The component's name and the prefix of its refs; matches `[a-z][a-z0-9-]*`. Default `toaster`. */\n readonly name?: string;\n}\n\nconst freeze = Object.freeze;\nconst EMPTY: readonly never[] = freeze([]);\nconst quote = JSON.stringify;\nconst TOASTER_VERBS: ReadonlySet<string> = new Set(['open', 'close', 'clear', 'acknowledge']);\nconst NOTIFICATION_VERBS: ReadonlySet<string> = new Set(['dismiss', 'show', 'press', 'fill', 'submit', 'cancel', 'retry']);\n// For an agent that has never seen this code: arguments in order, what the step does, when it\n// needs a person. One entry for every verb a record can list.\nconst VERBS: AgentVerbsShape = freeze({\n toaster: freeze({\n open: 'No arguments. Opens the Island on the notification it shows first. Needs a mounted Toaster; refused while the person is using it.',\n close: 'No arguments. Closes the open Island; refused while it holds a form the person or an agent started filling.',\n clear: 'No arguments. Closes every notification at once.',\n acknowledge: 'No arguments. Marks the notifications that did not fit as seen: overflow.pending turns false.',\n }),\n notification: freeze({\n dismiss: 'No arguments. Closes this notification; its record leaves the snapshot.',\n show: 'No arguments. Opens the Island on this notification. Needs a mounted Toaster; refused while the person is using it.',\n press: 'No arguments. Runs the command action (action.kind \"command\") and waits for it: success closes the notification, result \"pending\" means it is still working. Under action.agent \"confirm\" it may need a person to approve. A link action has no verb: the bridge never opens it; its address is action.href.',\n fill: 'args [field name, text]: the field\\'s name from action.fields[].name, not its label, and a string. Writes the field as the agent; never over text the person typed.',\n submit: 'No arguments. Sends the form action (action.kind \"form\") and waits for it: success closes the notification, result \"pending\" means it is still working. Under action.agent \"confirm\" it may need a person to approve. A refusal names the fields that were not accepted.',\n cancel: 'No arguments. Asks the running operation to stop; result \"requested\".',\n retry: 'No arguments. Starts the failed operation again; result \"started\".',\n }),\n});\nconst STRICTNESS = { allow: 0, confirm: 1, deny: 2 } as const;\nconst DONE: AgentRunOutcomeShape = freeze({ status: 'done' });\nconst GONE: AgentRunOutcomeShape = freeze({ status: 'done', gone: true });\nconst STALE: AgentRunOutcomeShape = freeze({ status: 'stale' });\nconst UNAVAILABLE: AgentRunOutcomeShape = freeze({ status: 'unavailable' });\n\n// A form's `validate` and `errorMessage` see what the person typed and may quote it, so their\n// text stays with the person in the Island: an agent reads these instead.\nconst FORM_REJECTED = \"Not accepted by the form's own check\";\nconst FORM_FAILED = 'Action failed';\n\n// Refusals the adapter words itself; the bridge words the rest from the record's `actions`.\n// Labels and titles come from the app, so they are quoted.\nconst texts = {\n noScreen: (action: string) => `No Toaster is on screen: ${quote(action)} needs one.`,\n noArguments: (step: AgentStepCallShape) => `${quote(step.action)} on ${quote(step.ref)} takes no arguments.`,\n fillArguments: (step: AgentStepCallShape) => `${quote(step.action)} on ${quote(step.ref)} takes a field name and a value.`,\n noField: (step: AgentStepCallShape, name: string, names: readonly string[]) =>\n `No field ${quote(name)} on ${quote(step.ref)}. Fields: ${names.map((item) => quote(item)).join(', ')}.`,\n notText: (field: string) => `The value for ${quote(field)} must be a string.`,\n tooLong: (field: string, limit: number) => `${quote(field)} takes at most ${limit} characters.`,\n personTyped: (field: string) => `The person typed in ${quote(field)}. An agent can't overwrite it.`,\n notSent: (label: string, messages: string) => `${quote(label)} was not sent. ${messages}`,\n running: (label: string) => `${quote(label)} is already running.`,\n failed: (label: string, message: string) => `${quote(label)} failed: ${message}`,\n finished: 'This operation has already finished.',\n cancelRequested: 'Cancelling this operation was already requested.',\n notCancellable: \"This operation can't be cancelled.\",\n stillRunning: \"This operation is still running, so it can't be retried yet.\",\n notRetryable: \"This operation can't be retried.\",\n busy: 'The person is using the Island. Try again later.',\n islandOpen: 'The Island is open on it.',\n islandLater: 'The Island will open on it once they stop using it.',\n noToaster: 'No Toaster is on screen, so tell them what it does.',\n};\n\n/** A step as the adapter sees it right now: refused, or allowed under a class with a way to run it. */\ntype Plan =\n | { readonly available: false; readonly message?: string }\n | {\n readonly available: true;\n readonly permission: AgentPermissionShape;\n readonly names?: AgentStepNamesShape;\n /** The action object a press or a submit would run. */\n readonly subject?: object;\n readonly perform: (context: AgentRunContextShape) => AgentRunOutcomeShape | Promise<AgentRunOutcomeShape>;\n };\n\nconst NO_AUTHORS: FormReading['authors'] = new Map();\nconst NOT_AVAILABLE: Plan = freeze({ available: false });\nconst refuse = (message: string): Plan => freeze({ available: false, message });\nconst allowed = (perform: () => AgentRunOutcomeShape): Plan => freeze({ available: true, permission: 'allow', perform });\ntype PortResult = { readonly status: string; readonly reason?: string };\n/** A port refusal after the plan said yes: the state changed in between, so the step is unavailable. */\nconst outcome = (result: PortResult, done: AgentRunOutcomeShape, words: Readonly<Record<string, string>> = {}): AgentRunOutcomeShape => {\n if (result.status !== 'rejected') return done;\n const message = result.reason === undefined ? undefined : words[result.reason];\n return message === undefined ? UNAVAILABLE : freeze({ status: 'unavailable', message });\n};\n\n/**\n * Lets an agent read and drive a controller through the kit's agent bridge:\n * `agent.connect(toasterAgent(controller))`. It touches no DOM, starts no timers, never takes the\n * host from a `Toaster` and never moves focus. Form values never reach the snapshot.\n *\n * Steps: `open`, `close`, `clear` and `acknowledge` on the Toaster record; `show`, `dismiss`,\n * `press`, `fill`, `submit`, `cancel` and `retry` on a notification. `open` and `show` need a\n * mounted `Toaster`. `press` and `submit` follow the action's `agent` marker; every other step is\n * allowed unless the bridge's `allow` says no. `fill` (`args: [name, value]`) writes a form field\n * as the agent, never over what the person typed, and makes a draft as typing does; the snapshot\n * says who wrote each field (`filledBy`), never what. A press or submit that needs a person opens\n * the Island on its notification for them: at once, or after the attention delay once they stop\n * using the Toaster. While they use it (hover, focus, a gesture, a draft in the open Island, the\n * agent's own included), `open` and `show` are refused, and so is `close` over a draft.\n *\n * @throws TypeError for a controller that this copy of `@cloudlet/toast` did not create.\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport function toasterAgent<Slot, Signal extends CancellationSignal>(\n controller: Omit<CloudletController<Slot, Signal>, 'track'>,\n options?: ToasterAgentOptions,\n): ToasterAgent {\n const name = options?.name ?? 'toaster';\n const port = createToasterPort<Slot>(controller);\n // A number per handle, so a closed notification's ref is never handed to another one.\n const refs = new WeakMap<NotificationHandle, string>();\n let issued = 0;\n const refOf = (handle: NotificationHandle): string => {\n let ref = refs.get(handle);\n if (ref === undefined) refs.set(handle, ref = `${name}:${++issued}`);\n return ref;\n };\n // What the last change records said about each open notification, kept while someone listens.\n type Known = {\n label: string | undefined;\n action: 'idle' | 'pending' | 'failed';\n operation: { readonly token: string; value: string } | null;\n authors: FormReading['authors'];\n };\n const known = new Map<NotificationHandle, Known>();\n let islandRef: string | null = null;\n // The revision `known` was read at; a commit up to it is already in there.\n let seeded = 0;\n // Each subscriber with the revision it read on subscribing: a commit up to it brings it nothing.\n type Listener = { readonly call: (changes?: readonly AgentChangeShape[]) => void; readonly from: number };\n const listeners = new Set<Listener>();\n let stop: (() => void) | undefined;\n let source: ToasterReading<Slot> | undefined;\n let entries: readonly ToasterAgentEntry[] = EMPTY;\n // The notifications of the current snapshot by ref, for steps.\n let targets: ReadonlyMap<string, { readonly item: NotificationSnapshot<Slot>; readonly entry: NotificationEntry }> = new Map();\n\n const snapshot = (): readonly ToasterAgentEntry[] => {\n const reading = port.read();\n if (reading === source) return entries;\n source = reading;\n const state = reading.controller;\n if (state.disposed) { targets = new Map(); return entries = EMPTY; }\n const byHandle = new Map(state.notifications.map((item) => [item.handle, item] as const));\n const island = state.island;\n const count = state.stack.length;\n const found = new Map<string, { readonly item: NotificationSnapshot<Slot>; readonly entry: NotificationEntry }>();\n // Refs are issued in presentation order, so the top notification gets the lower number.\n const notifications = state.stack.map((handle) => {\n const item = byHandle.get(handle)!;\n const entry = notification(item, refOf(handle), island.open && island.current === handle, reading.mounted, reading.forms.get(handle));\n found.set(entry.ref, { item, entry });\n return entry;\n });\n targets = found;\n const toaster: ToasterEntry = freeze({\n ref: name, component: 'toaster' as const,\n actions: freeze([\n ...(!island.open && count > 0 && reading.mounted ? ['open'] : []),\n ...(island.open ? ['close'] : []),\n ...(count > 0 ? ['clear'] : []),\n ...(state.overflow.pending ? ['acknowledge'] : []),\n ]),\n island: freeze({ open: island.open, current: island.current ? refOf(island.current) : null }),\n count,\n overflow: freeze({ count: state.overflow.count, pending: state.overflow.pending }),\n mounted: reading.mounted,\n });\n return entries = freeze([toaster, ...notifications]);\n };\n\n /** Reads the step against the controller as it is now; `check` and `run` both start here. */\n const plan = (step: AgentStepCallShape): Plan => {\n const current = snapshot();\n const mounted = source?.mounted ?? false;\n const { action } = step;\n if (step.ref === name && current.length) {\n if (!TOASTER_VERBS.has(action)) return NOT_AVAILABLE;\n if (step.args.length) return refuse(texts.noArguments(step));\n if (action === 'open' && !mounted) return refuse(texts.noScreen(action));\n if (!current[0]!.actions.includes(action)) return NOT_AVAILABLE;\n // A busy person is not interrupted; only a draft stops `close`, which a person's Escape would collapse.\n if (action === 'open' && source!.busy) return refuse(texts.busy);\n if (action === 'close' && holdsDraft()) return refuse(texts.busy);\n switch (action) {\n case 'open': return allowed(() => outcome(port.open(), DONE, { 'no-host': texts.noScreen(action), busy: texts.busy }));\n case 'close': return allowed(() => outcome(port.close(), DONE, { busy: texts.busy }));\n case 'clear': return allowed(() => outcome(port.clear(), DONE));\n default: return allowed(() => outcome(port.acknowledge(), DONE));\n }\n }\n const target = targets.get(step.ref);\n if (!target || !NOTIFICATION_VERBS.has(action)) return NOT_AVAILABLE;\n const { item, entry } = target;\n if (action === 'fill') return fillPlan(step, item);\n if (step.args.length) return refuse(texts.noArguments(step));\n const { handle } = item;\n switch (action) {\n case 'show':\n if (!mounted) return refuse(texts.noScreen(action));\n break;\n case 'press': {\n const command = item.content.action;\n return command?.kind === 'command' ? pressPlan(item, command) : NOT_AVAILABLE;\n }\n case 'submit': {\n const form = item.content.action;\n return form?.kind === 'form' ? pressPlan(item, form) : NOT_AVAILABLE;\n }\n case 'cancel': {\n const operation = item.operation;\n if (!operation) return NOT_AVAILABLE;\n if (operation.status !== 'pending') return refuse(texts.finished);\n if (operation.cancelRequested) return refuse(texts.cancelRequested);\n if (!operation.canCancel) return refuse(texts.notCancellable);\n break;\n }\n case 'retry': {\n const operation = item.operation;\n if (!operation) return NOT_AVAILABLE;\n if (operation.status === 'pending') return refuse(texts.stillRunning);\n if (!operation.canRetry) return refuse(texts.notRetryable);\n break;\n }\n }\n if (!entry.actions.includes(action)) return NOT_AVAILABLE;\n if (action === 'show' && source!.busy) return refuse(texts.busy);\n switch (action) {\n case 'show': return allowed(() => outcome(port.show(handle), DONE, { 'no-host': texts.noScreen(action), busy: texts.busy }));\n case 'dismiss': return allowed(() => outcome(port.dismiss(handle), GONE));\n case 'cancel': return allowed(() => {\n const result = port.cancel(handle);\n return result.status === 'requested' ? freeze({ status: 'done', result: 'requested' })\n : outcome(result.status === 'unchanged' ? { status: 'rejected', reason: result.reason } : result, DONE, {\n settled: texts.finished, 'already-requested': texts.cancelRequested, 'not-cancellable': texts.notCancellable,\n });\n });\n default: return allowed(() => outcome(port.retry(handle), freeze({ status: 'done', result: 'started' }), {\n 'already-pending': texts.stillRunning, 'not-retryable': texts.notRetryable,\n }));\n }\n };\n\n /** The open Island shows a notification whose form holds a draft. */\n const holdsDraft = (): boolean => {\n const state = source!.controller;\n const current = state.island.current;\n return current !== null && state.notifications.some((item) => item.handle === current && item.draft);\n };\n\n // An agent's value goes in like a person's keystrokes, except over what the person typed. The\n // step's text names the field, never a value.\n const fillPlan = (step: AgentStepCallShape, item: NotificationSnapshot<Slot>): Plan => {\n const form = item.content.action;\n if (form?.kind !== 'form') return NOT_AVAILABLE;\n const [name, value] = step.args;\n if (step.args.length !== 2 || typeof name !== 'string') return refuse(texts.fillArguments(step));\n const field = form.fields.find((candidate) => candidate.name === name);\n if (!field) return refuse(texts.noField(step, name, form.fields.map((candidate) => candidate.name)));\n if (typeof value !== 'string') return refuse(texts.notText(field.label));\n const words = {\n 'already-pending': texts.running(form.label),\n 'too-long': texts.tooLong(field.label, field.maxLength ?? 0),\n 'person-typed': texts.personTyped(field.label),\n };\n if (item.action.status === 'pending') return refuse(words['already-pending']);\n if (field.maxLength !== undefined && value.length > field.maxLength) return refuse(words['too-long']);\n if (source!.forms.get(item.handle)?.authors.get(name) === 'user') return refuse(words['person-typed']);\n return allowed(() => outcome(port.fill(item.handle, name, value), DONE, words));\n };\n\n /** A command's press or a form's submit: both follow the action's marker and wait for its run. */\n const pressPlan = (item: NotificationSnapshot<Slot>, action: CommandAction | FormAction): Plan => {\n const { label } = action;\n const permission = action.agent ?? 'confirm';\n const names = freeze({ target: label, within: item.content.title });\n // A denied press never runs, so it is reported before its state.\n if (permission !== 'deny' && item.action.status === 'pending') return refuse(texts.running(label));\n return freeze({\n available: true, permission, names, subject: action,\n async perform({ signal, approved }: AgentRunContextShape): Promise<AgentRunOutcomeShape> {\n const started = port.press(item.handle, approved, signal);\n if (!(started instanceof Promise)) {\n return started.reason === 'stale' ? STALE : outcome(started, DONE, { 'already-pending': texts.running(label) });\n }\n const ended = await started;\n if (ended.status === 'done') return GONE;\n if (ended.status === 'replaced') return STALE;\n if (ended.status === 'failed') return freeze({ status: 'failed', message: texts.failed(label, action.kind === 'form' ? FORM_FAILED : ended.message) });\n if (ended.status === 'invalid') return freeze({ status: 'failed', message: texts.notSent(label, describe(action as FormAction, ended.errors)) });\n return freeze({ status: 'done', result: 'pending', ...(ended.gone ? { gone: true } : {}) });\n },\n });\n };\n\n // What a checked press or submit would have run, by step object: the bridge approves a step by\n // its ref and verb, so the action it named to the app or the person is held here until it runs.\n const checked = new WeakMap<AgentStepCallShape, object>();\n\n const check = (step: AgentStepCallShape): AgentStepCheckShape => {\n const verdict = plan(step);\n if (!verdict.available) return verdict;\n if (verdict.subject) checked.set(step, verdict.subject);\n return freeze({ available: true, permission: verdict.permission, ...(verdict.names ? { names: verdict.names } : {}) });\n };\n\n // The bridge approved the step under `approved`; the controller is read again before anything runs.\n const run = (step: AgentStepCallShape, context: AgentRunContextShape): AgentRunOutcomeShape | Promise<AgentRunOutcomeShape> => {\n const verdict = plan(step);\n if (!verdict.available) return verdict.message === undefined ? UNAVAILABLE : freeze({ status: 'unavailable', message: verdict.message });\n if (STRICTNESS[verdict.permission] > STRICTNESS[context.approved]) return STALE;\n // The app replaced the action while the step waited: the approval was for the other one.\n const subject = checked.get(step);\n if (subject !== undefined && subject !== verdict.subject) return STALE;\n return verdict.perform(context);\n };\n\n // A step only a person may take: the Island opens on its notification for them, through the\n // attention queue, so a person busy with the Toaster is not interrupted.\n const summon = (step: AgentStepCallShape): AgentSummonOutcomeShape => {\n snapshot();\n const target = targets.get(step.ref);\n if (!target) return false;\n const result = port.summon(target.item.handle);\n if (result.status === 'rejected') return result.reason === 'no-host' ? freeze({ reached: false, note: texts.noToaster }) : false;\n return freeze({ reached: true, note: result.status === 'waiting' ? texts.islandLater : texts.islandOpen });\n };\n\n /**\n * The records of one committed change: its events in order, then what only the state shows (an\n * action back to idle, a field's new author, the Island). A form's values are never read here.\n */\n const collect = (commit: PortCommit<Slot>): readonly AgentChangeShape[] => {\n // The commit's own state, not the latest: a listener before this one may have committed again.\n const state = commit.controller;\n // Subscribed while this commit was still queued: what it did was read then.\n if (state.revision <= seeded) return EMPTY;\n const { events } = commit;\n const live = new Map(state.notifications.map((item) => [item.handle, item] as const));\n for (const [handle, entry] of known) {\n const item = live.get(handle);\n if (item) entry.label = item.content.title;\n }\n const changes: AgentChangeShape[] = [];\n // Who changed a notification's content in this commit: the author of what follows from it.\n const touched = new Map<NotificationHandle, ChangeSource>();\n const push = (handle: NotificationHandle, key: string, value: AgentValueShape, previous: AgentValueShape, by: ChangeSource, reason?: string): void => {\n const label = known.get(handle)?.label;\n changes.push(freeze({\n ref: refOf(handle), component: 'notification', ...(label === undefined ? {} : { label }), key, value, previous,\n ...(reason === undefined ? {} : { reason }), source: by,\n }));\n };\n for (const event of events) {\n switch (event.type) {\n case 'admitted': {\n // The number is issued here, so a notification closed before anyone reads still has one.\n refOf(event.handle);\n known.set(event.handle, {\n label: live.get(event.handle)?.content.title, action: 'idle', operation: null,\n authors: commit.authors.get(event.handle) ?? NO_AUTHORS,\n });\n push(event.handle, 'present', true, false, event.source);\n break;\n }\n case 'closed':\n push(event.handle, 'present', false, true, event.source, event.reason);\n known.delete(event.handle);\n break;\n case 'updated':\n touched.set(event.handle, event.source);\n push(event.handle, 'content', null, null, event.source);\n break;\n case 'action-started':\n case 'action-failed': {\n const entry = known.get(event.handle);\n if (!entry) break;\n const next = event.type === 'action-started' ? 'pending' : 'failed';\n push(event.handle, 'action', next, entry.action, event.source);\n entry.action = next;\n break;\n }\n case 'operation-started': {\n const entry = event.handle && known.get(event.handle);\n if (!entry) break;\n touched.set(event.handle!, event.source);\n push(event.handle!, 'operation', 'pending', entry.operation?.value ?? null, event.source);\n entry.operation = { token: event.token, value: 'pending' };\n break;\n }\n case 'cancellation-requested':\n case 'operation-settled': {\n const entry = event.handle && known.get(event.handle);\n // An attempt that a newer one replaced no longer speaks for the notification.\n if (!entry || entry.operation?.token !== event.token) break;\n if (event.type === 'operation-settled') touched.set(event.handle!, event.source);\n const next = event.type === 'operation-settled' ? event.status : 'cancel-requested';\n push(event.handle!, 'operation', next, entry.operation.value, event.source);\n entry.operation.value = next;\n break;\n }\n case 'overflow-acknowledged':\n changes.push(freeze({ ref: name, component: 'toaster', key: 'overflow', value: 0, previous: event.count, source: event.source }));\n break;\n }\n }\n for (const [handle, entry] of known) {\n // A notification missing here closed in a later commit; its own records follow.\n const item = live.get(handle);\n if (!item) continue;\n const by = touched.get(handle);\n if (item.action.status === 'idle' && entry.action !== 'idle') {\n push(handle, 'action', 'idle', entry.action, by ?? 'system');\n entry.action = 'idle';\n }\n const authors = commit.authors.get(handle) ?? NO_AUTHORS;\n if (authors !== entry.authors) {\n // In the form's own order; a field of the form that was replaced comes after them.\n const action = item.content.action;\n const names = action?.kind === 'form' ? action.fields.map((field) => field.name) : [];\n for (const field of new Set([...names, ...entry.authors.keys(), ...authors.keys()])) {\n const next = authors.get(field) ?? null;\n const previous = entry.authors.get(field) ?? null;\n // A new author is the source; a field emptied with its form was replaced by the app.\n if (next !== previous) push(handle, `field:${field}`, next, previous, next ?? by ?? 'app');\n }\n entry.authors = authors;\n }\n }\n const current = state.island.current ? refOf(state.island.current) : null;\n if (current !== islandRef) {\n changes.push(freeze({\n ref: name, component: 'toaster', key: 'island', value: current, previous: islandRef,\n source: state.island.source ?? commit.closedBy ?? 'system',\n }));\n islandRef = current;\n }\n return freeze(changes);\n };\n\n const subscribe = (listener: (changes?: readonly AgentChangeShape[]) => void): (() => void) => {\n // The same function may subscribe twice; each subscription is removed on its own.\n let own: Listener;\n if (!listeners.size) {\n // Refs of what is already there are issued as a snapshot does, top first.\n snapshot();\n const reading = port.read();\n const state = reading.controller;\n known.clear();\n for (const item of state.notifications) {\n const operation = item.operation;\n known.set(item.handle, {\n label: item.content.title, action: item.action.status,\n operation: operation ? { token: operation.token, value: operation.status === 'pending' && operation.cancelRequested ? 'cancel-requested' : operation.status } : null,\n authors: reading.forms.get(item.handle)?.authors ?? NO_AUTHORS,\n });\n }\n islandRef = state.island.current ? refOf(state.island.current) : null;\n seeded = state.revision;\n own = { call: listener, from: seeded };\n stop = port.subscribe((commit) => {\n const changes = collect(commit);\n const revision = commit.controller.revision;\n // Every listener hears the change, and each error goes on to the controller's diagnostics.\n for (const each of [...listeners]) {\n if (!listeners.has(each)) continue;\n // One that subscribed while this commit was queued read what it did on subscribing.\n try { each.call(revision <= each.from ? EMPTY : changes); } catch (error) { port.report(error); }\n }\n });\n } else {\n own = { call: listener, from: port.read().controller.revision };\n }\n listeners.add(own);\n return () => {\n if (!listeners.delete(own) || listeners.size) return;\n stop?.();\n stop = undefined;\n known.clear();\n };\n };\n\n return freeze({ protocol: 1 as const, name, snapshot, subscribe, check, run, summon, verbs: VERBS });\n}\n\n/**\n * Why a form was not sent, by field label and never with a value: the built-in messages as the\n * person sees them, and for the app's own `validate` only which fields it did not accept.\n */\nfunction describe(form: FormAction, errors: FormErrors): string {\n if (errors.broken) return `${FORM_FAILED}.`;\n if (errors.authored) {\n // Own keys only, as below.\n const labels = form.fields.flatMap((field) => Object.hasOwn(errors.fields, field.name) ? [quote(field.label)] : []);\n return `The form's own check did not accept ${labels.length ? labels.join(', ') : 'it'}.`;\n }\n const sentence = (message: string) => /[.!?]$/.test(message.trim()) ? message.trim() : `${message.trim()}.`;\n return [\n // Own keys only: a field named `constructor` must not read `Object.prototype`.\n ...form.fields.flatMap((field) => Object.hasOwn(errors.fields, field.name) ? [`${quote(field.label)}: ${sentence(errors.fields[field.name]!)}`] : []),\n ...(errors.form ? [sentence(errors.form)] : []),\n ].join(' ');\n}\n\nfunction notification<Slot>(item: NotificationSnapshot<Slot>, ref: string, shown: boolean, mounted: boolean, form: FormReading | undefined): NotificationEntry {\n const { content } = item;\n const description = content.description;\n const progress = content.progress;\n const operation = item.operation;\n const action = actionEntry(item, form);\n // `deny` stops pressing and submitting only: a person can still submit what an agent filled.\n const ready = item.action.status !== 'pending';\n const may = ready && action?.agent !== 'deny';\n return freeze({\n ref, component: 'notification' as const,\n actions: freeze([\n 'dismiss',\n ...(!shown && mounted ? ['show'] : []),\n ...(action?.kind === 'command' && may ? ['press'] : []),\n ...(action?.kind === 'form' && ready ? ['fill'] : []),\n ...(action?.kind === 'form' && may ? ['submit'] : []),\n ...(operation?.canCancel ? ['cancel'] : []),\n ...(operation?.canRetry ? ['retry'] : []),\n ]),\n label: content.title,\n text: description ? description.kind === 'text' ? description.text : description.announcement : null,\n kind: item.kind,\n priority: item.priority,\n occurrences: item.occurrences,\n location: item.location,\n remainingMs: item.remainingMs,\n pauseReasons: freeze([...item.pauseReasons]),\n progress: progress ? freeze({\n kind: progress.kind,\n value: progress.kind === 'determinate' ? progress.value : null,\n label: progress.label ?? null,\n }) : null,\n draft: item.draft,\n operation: operation ? freeze({\n status: operation.status, attempt: operation.attempt, canCancel: operation.canCancel,\n canRetry: operation.canRetry, cancelRequested: operation.cancelRequested,\n }) : null,\n action,\n });\n}\n\nfunction actionEntry<Slot>(item: NotificationSnapshot<Slot>, form: FormReading | undefined): ActionEntry | null {\n const action = item.content.action;\n if (!action) return null;\n const state = item.action;\n const common = {\n kind: action.kind, label: action.label, status: state.status,\n message: state.status !== 'failed' ? null : action.kind === 'form' ? FORM_FAILED : state.message,\n };\n if (action.kind === 'link') return freeze({ ...common, href: action.href });\n if (action.kind === 'command') return freeze({ ...common, agent: action.agent ?? 'confirm' });\n const errors = form?.errors;\n return freeze({\n ...common,\n agent: action.agent ?? 'confirm',\n fields: freeze(action.fields.map((field) => freeze({\n name: field.name, label: field.label, kind: field.kind, required: field.required ?? false,\n maxLength: field.maxLength ?? null, inputMode: field.inputMode ?? null,\n filled: form?.filled.has(field.name) ?? false,\n filledBy: form?.authors.get(field.name) ?? null,\n // Own keys only: a field named `constructor` must not read `Object.prototype`.\n error: errors && Object.hasOwn(errors.fields, field.name) ? errors.authored ? FORM_REJECTED : errors.fields[field.name]! : null,\n }))),\n error: errors?.form ? errors.broken ? FORM_FAILED : errors.authored ? FORM_REJECTED : errors.form : null,\n });\n}\n"],"mappings":";;AA0TA,IAAMA,IAAS,OAAO,QAChBC,IAA0BD,EAAO,CAAC,CAAC,GACnCE,IAAQ,KAAK,WACbC,oBAAqC,IAAI,IAAI;CAAC;CAAQ;CAAS;CAAS;AAAa,CAAC,GACtFC,oBAA0C,IAAI,IAAI;CAAC;CAAW;CAAQ;CAAS;CAAQ;CAAU;CAAU;AAAO,CAAC,GAGnHC,IAAyBL,EAAO;CACpC,SAASA,EAAO;EACd,MAAM;EACN,OAAO;EACP,OAAO;EACP,aAAa;CACf,CAAC;CACD,cAAcA,EAAO;EACnB,SAAS;EACT,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACR,QAAQ;EACR,OAAO;CACT,CAAC;AACH,CAAC,GACKM,IA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