@songsid/agend 2.4.0-beta.22 → 2.4.0-beta.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (284) hide show
  1. package/dist/agent-cli-instructions.md +4 -3
  2. package/dist/agent-cli.js +32 -2
  3. package/dist/agent-cli.js.map +1 -1
  4. package/dist/agent-file-read.js +2 -2
  5. package/dist/agent-file-read.js.map +1 -1
  6. package/dist/agent-whats-new.js +17 -1
  7. package/dist/agent-whats-new.js.map +1 -1
  8. package/dist/auth-api.d.ts +2 -0
  9. package/dist/auth-api.js +5 -2
  10. package/dist/auth-api.js.map +1 -1
  11. package/dist/authority/web-authority.d.ts +17 -3
  12. package/dist/authority/web-authority.js +56 -3
  13. package/dist/authority/web-authority.js.map +1 -1
  14. package/dist/backend/claude-code.d.ts +15 -0
  15. package/dist/backend/claude-code.js +8 -3
  16. package/dist/backend/claude-code.js.map +1 -1
  17. package/dist/backend/claude-mcp-carry.d.ts +63 -0
  18. package/dist/backend/claude-mcp-carry.js +242 -0
  19. package/dist/backend/claude-mcp-carry.js.map +1 -0
  20. package/dist/build-provenance.json +1 -1
  21. package/dist/channel/mcp-tools.js +15 -7
  22. package/dist/channel/mcp-tools.js.map +1 -1
  23. package/dist/classic-channel-manager.d.ts +1 -1
  24. package/dist/classic-channel-manager.js +2 -2
  25. package/dist/classic-channel-manager.js.map +1 -1
  26. package/dist/config-validator.js +6 -0
  27. package/dist/config-validator.js.map +1 -1
  28. package/dist/contact-auth-api.js +3 -1
  29. package/dist/contact-auth-api.js.map +1 -1
  30. package/dist/contact-auth-service.js +1 -1
  31. package/dist/contact-auth-service.js.map +1 -1
  32. package/dist/contact-auth-store.d.ts +28 -2
  33. package/dist/contact-auth-store.js +72 -4
  34. package/dist/contact-auth-store.js.map +1 -1
  35. package/dist/contact-change-proposals.d.ts +18 -1
  36. package/dist/contact-change-proposals.js +38 -4
  37. package/dist/contact-change-proposals.js.map +1 -1
  38. package/dist/contact-state-view.d.ts +103 -0
  39. package/dist/contact-state-view.js +80 -0
  40. package/dist/contact-state-view.js.map +1 -0
  41. package/dist/daemon.d.ts +11 -0
  42. package/dist/daemon.js +66 -15
  43. package/dist/daemon.js.map +1 -1
  44. package/dist/dashboard-permissions.d.ts +8 -0
  45. package/dist/dashboard-permissions.js +8 -0
  46. package/dist/dashboard-permissions.js.map +1 -1
  47. package/dist/delivery-outbox.d.ts +15 -1
  48. package/dist/delivery-outbox.js +60 -2
  49. package/dist/delivery-outbox.js.map +1 -1
  50. package/dist/fleet-manager.d.ts +157 -15
  51. package/dist/fleet-manager.js +522 -78
  52. package/dist/fleet-manager.js.map +1 -1
  53. package/dist/general-knowledge/skills/admin/SKILL.md +52 -0
  54. package/dist/general-knowledge/skills/concepts/SKILL.md +31 -21
  55. package/dist/general-knowledge/skills/credential-profiles/SKILL.md +6 -0
  56. package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +6 -3
  57. package/dist/general-knowledge/skills/fleet-config/SKILL.md +3 -3
  58. package/dist/general-knowledge/skills/hub/SKILL.md +6 -1
  59. package/dist/general-knowledge/skills/instance-lifecycle/SKILL.md +1 -1
  60. package/dist/general-knowledge/skills/task-board/SKILL.md +17 -0
  61. package/dist/general-knowledge/skills/web-appearance/SKILL.md +4 -0
  62. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +75 -12
  63. package/dist/general-knowledge/skills/worker-collaboration/SKILL.md +1 -1
  64. package/dist/general-role.d.ts +1 -1
  65. package/dist/general-role.js +1 -0
  66. package/dist/general-role.js.map +1 -1
  67. package/dist/hub/client.js +6 -1
  68. package/dist/hub/client.js.map +1 -1
  69. package/dist/hub/compose/member.d.ts +2 -1
  70. package/dist/hub/compose/member.js +3 -2
  71. package/dist/hub/compose/member.js.map +1 -1
  72. package/dist/hub/compose/server.js +2 -1
  73. package/dist/hub/compose/server.js.map +1 -1
  74. package/dist/hub/http/compose.js +5 -0
  75. package/dist/hub/http/compose.js.map +1 -1
  76. package/dist/hub/protocol.d.ts +21 -0
  77. package/dist/hub/protocol.js +3 -0
  78. package/dist/hub/protocol.js.map +1 -1
  79. package/dist/hub/question-close-model.d.ts +17 -0
  80. package/dist/hub/question-close-model.js +7 -0
  81. package/dist/hub/question-close-model.js.map +1 -0
  82. package/dist/hub/representative.d.ts +5 -0
  83. package/dist/hub/representative.js +51 -1
  84. package/dist/hub/representative.js.map +1 -1
  85. package/dist/hub/rooms/direct-view.js +1 -0
  86. package/dist/hub/rooms/direct-view.js.map +1 -1
  87. package/dist/hub/rooms/types.d.ts +1 -1
  88. package/dist/hub/rooms.d.ts +3 -0
  89. package/dist/hub/rooms.js +27 -1
  90. package/dist/hub/rooms.js.map +1 -1
  91. package/dist/hub/server.js +6 -1
  92. package/dist/hub/server.js.map +1 -1
  93. package/dist/hub/types.d.ts +2 -2
  94. package/dist/human-delivery-receipts.d.ts +12 -2
  95. package/dist/human-delivery-receipts.js +19 -4
  96. package/dist/human-delivery-receipts.js.map +1 -1
  97. package/dist/instance-lifecycle.d.ts +2 -0
  98. package/dist/instance-lifecycle.js +29 -1
  99. package/dist/instance-lifecycle.js.map +1 -1
  100. package/dist/instructions.d.ts +1 -1
  101. package/dist/instructions.js +1 -1
  102. package/dist/instructions.js.map +1 -1
  103. package/dist/locale.js +110 -12
  104. package/dist/locale.js.map +1 -1
  105. package/dist/needs-you-hub.d.ts +3 -0
  106. package/dist/needs-you-hub.js +31 -5
  107. package/dist/needs-you-hub.js.map +1 -1
  108. package/dist/needs-you.d.ts +16 -1
  109. package/dist/needs-you.js +7 -1
  110. package/dist/needs-you.js.map +1 -1
  111. package/dist/office-share-page.js +2 -2
  112. package/dist/office-share-page.js.map +1 -1
  113. package/dist/office-share.js +2 -1
  114. package/dist/office-share.js.map +1 -1
  115. package/dist/outbound-handlers.d.ts +4 -0
  116. package/dist/outbound-handlers.js +69 -11
  117. package/dist/outbound-handlers.js.map +1 -1
  118. package/dist/outbound-schemas.d.ts +5 -1
  119. package/dist/outbound-schemas.js +10 -7
  120. package/dist/outbound-schemas.js.map +1 -1
  121. package/dist/public-web-gateway.js +21 -0
  122. package/dist/public-web-gateway.js.map +1 -1
  123. package/dist/reply-buttons-controller.d.ts +2 -1
  124. package/dist/reply-buttons-controller.js +1 -1
  125. package/dist/reply-buttons-controller.js.map +1 -1
  126. package/dist/request-context-compatibility.d.ts +20 -0
  127. package/dist/request-context-compatibility.js +74 -0
  128. package/dist/request-context-compatibility.js.map +1 -0
  129. package/dist/request-context-protocol.d.ts +137 -0
  130. package/dist/request-context-protocol.js +38 -0
  131. package/dist/request-context-protocol.js.map +1 -0
  132. package/dist/request-context-store.d.ts +25 -0
  133. package/dist/request-context-store.js +137 -0
  134. package/dist/request-context-store.js.map +1 -0
  135. package/dist/scheduler/db.js +26 -0
  136. package/dist/scheduler/db.js.map +1 -1
  137. package/dist/scheduler/task-board-text.d.ts +2 -0
  138. package/dist/scheduler/task-board-text.js +12 -0
  139. package/dist/scheduler/task-board-text.js.map +1 -1
  140. package/dist/scheduler/task-board.d.ts +102 -2
  141. package/dist/scheduler/task-board.js +242 -24
  142. package/dist/scheduler/task-board.js.map +1 -1
  143. package/dist/scheduler/task-files.d.ts +80 -0
  144. package/dist/scheduler/task-files.js +357 -0
  145. package/dist/scheduler/task-files.js.map +1 -0
  146. package/dist/settings-api.d.ts +2 -0
  147. package/dist/settings-api.js +6 -1
  148. package/dist/settings-api.js.map +1 -1
  149. package/dist/settings-baseline.d.ts +1 -0
  150. package/dist/settings-baseline.js +1 -1
  151. package/dist/settings-baseline.js.map +1 -1
  152. package/dist/settings-effect.d.ts +2 -0
  153. package/dist/settings-effect.js +5 -1
  154. package/dist/settings-effect.js.map +1 -1
  155. package/dist/task-attach-client.d.ts +43 -0
  156. package/dist/task-attach-client.js +125 -0
  157. package/dist/task-attach-client.js.map +1 -0
  158. package/dist/task-board-tool.d.ts +12 -0
  159. package/dist/task-board-tool.js +107 -6
  160. package/dist/task-board-tool.js.map +1 -1
  161. package/dist/task-file-limits.d.ts +15 -0
  162. package/dist/task-file-limits.js +21 -0
  163. package/dist/task-file-limits.js.map +1 -0
  164. package/dist/tool-permissions.d.ts +32 -0
  165. package/dist/tool-permissions.js +64 -1
  166. package/dist/tool-permissions.js.map +1 -1
  167. package/dist/types.d.ts +6 -0
  168. package/dist/ui/accounts-keepalive.js +2 -1
  169. package/dist/ui/agent-details-settings.js +7 -5
  170. package/dist/ui/agent-who-can-use-strings.js +125 -0
  171. package/dist/ui/agent-who-can-use.js +238 -0
  172. package/dist/ui/chat-activity.js +2 -1
  173. package/dist/ui/chat-pins.js +2 -1
  174. package/dist/ui/claude-credentials.js +2 -1
  175. package/dist/ui/contact-auth-strings.js +28 -17
  176. package/dist/ui/contact-authorizations.js +6 -4
  177. package/dist/ui/contact-needs.js +6 -1
  178. package/dist/ui/contact-permissions.js +6 -4
  179. package/dist/ui/contact-tool-groups.js +1 -1
  180. package/dist/ui/contact-verify-need.js +46 -0
  181. package/dist/ui/fleet-cache.js +2 -1
  182. package/dist/ui/fleet-office-card.js +23 -5
  183. package/dist/ui/fleet-office-editor.js +5 -5
  184. package/dist/ui/fleet-office-pack.d.ts +10 -0
  185. package/dist/ui/fleet-office-pack.js +65 -2
  186. package/dist/ui/fleet-office-skin.js +52 -14
  187. package/dist/ui/fleet-office-store.js +33 -2
  188. package/dist/ui/fleet-office-vehicles.js +130 -0
  189. package/dist/ui/fleet-office-zones.js +27 -10
  190. package/dist/ui/fleet-office.js +128 -40
  191. package/dist/ui/fleet-org.js +6 -1
  192. package/dist/ui/fleet-tab-icons.js +19 -0
  193. package/dist/ui/fleet-task-activity.js +11 -83
  194. package/dist/ui/fleet-task-archive.js +111 -0
  195. package/dist/ui/fleet-task-card.js +6 -4
  196. package/dist/ui/fleet-task-common.js +2 -2
  197. package/dist/ui/fleet-task-edit.js +8 -1
  198. package/dist/ui/fleet-task-files.js +196 -0
  199. package/dist/ui/fleet-task-md.js +98 -0
  200. package/dist/ui/fleet-task-menu.js +1 -1
  201. package/dist/ui/fleet-task-stats.js +2 -2
  202. package/dist/ui/fleet-task-view.js +14 -9
  203. package/dist/ui/fleet-tasks.js +42 -18
  204. package/dist/ui/fleet-usage.js +2 -1
  205. package/dist/ui/hub-admin-overview.js +2 -1
  206. package/dist/ui/hub-agent-intro.js +2 -1
  207. package/dist/ui/hub-assistant-admin.js +2 -1
  208. package/dist/ui/hub-directory-notices.js +2 -1
  209. package/dist/ui/hub-enrolment-code.js +2 -1
  210. package/dist/ui/hub-my-agents.js +2 -1
  211. package/dist/ui/hub-quick-pairing.js +2 -1
  212. package/dist/ui/hub-role-audit.js +2 -1
  213. package/dist/ui/hub-role-forms.js +3 -2
  214. package/dist/ui/hub-role-view.js +3 -2
  215. package/dist/ui/hub-roles.js +2 -1
  216. package/dist/ui/hub-room-agent-strings.js +2 -1
  217. package/dist/ui/hub-room-list.js +2 -1
  218. package/dist/ui/hub-room-owner-requests.js +2 -1
  219. package/dist/ui/hub-room-pins.js +2 -1
  220. package/dist/ui/hub-room-strings.js +2 -2
  221. package/dist/ui/hub-room-thread.js +1 -1
  222. package/dist/ui/log-row.js +4 -3
  223. package/dist/ui/office-share-dialog.js +2 -1
  224. package/dist/ui/office-share-page.js +2 -1
  225. package/dist/ui/page-share-dialog.js +3 -2
  226. package/dist/ui/panel-chat.js +2 -1
  227. package/dist/ui/panel-details.js +5 -2
  228. package/dist/ui/panel-fleet.js +10 -5
  229. package/dist/ui/panel-hub.js +2 -1
  230. package/dist/ui/panel-needs.js +34 -6
  231. package/dist/ui/panel-notices.js +2 -1
  232. package/dist/ui/panel-runtimes.js +2 -1
  233. package/dist/ui/panel-settings.js +15 -1
  234. package/dist/ui/panel-windows-cli.js +3 -2
  235. package/dist/ui/runtime-cli-install.js +2 -1
  236. package/dist/ui/settings-appearance.js +2 -1
  237. package/dist/ui/settings-guests.js +4 -3
  238. package/dist/ui/settings-hub-member-address.js +2 -1
  239. package/dist/ui/settings-hub-setup.js +2 -1
  240. package/dist/ui/settings-hub-web-address.js +2 -1
  241. package/dist/ui/settings-hub.js +2 -1
  242. package/dist/ui/settings-registry.js +1 -0
  243. package/dist/ui/settings-shared-strings.js +9 -0
  244. package/dist/ui/settings-shared.js +6 -1
  245. package/dist/ui/settings-update.js +2 -1
  246. package/dist/ui/settings-web-authority.js +2 -1
  247. package/dist/ui/shared/agent-sheet.js +2 -1
  248. package/dist/ui/shared/app-i18n.js +2 -2
  249. package/dist/ui/shared/app-needs.js +8 -1
  250. package/dist/ui/shared/app-session.js +4 -3
  251. package/dist/ui/shared/app-shell.js +6 -2
  252. package/dist/ui/shared/app.css +93 -11
  253. package/dist/ui/shared/chat-strings.js +4 -4
  254. package/dist/ui/shared/chat-time.js +7 -4
  255. package/dist/ui/shared/clock-text.js +57 -0
  256. package/dist/ui/shared/device-roles.js +6 -5
  257. package/dist/ui/shared/instance-nav.js +17 -22
  258. package/dist/ui/shared/task-board.css +64 -0
  259. package/dist/ui/shared/usage-dialog.js +2 -1
  260. package/dist/ui/shared/view-strings.js +0 -14
  261. package/dist/ui/shared/web-authorize.js +3 -2
  262. package/dist/ui/subagent-row.js +2 -1
  263. package/dist/web-api.d.ts +18 -2
  264. package/dist/web-api.js +159 -27
  265. package/dist/web-api.js.map +1 -1
  266. package/dist/web-login.d.ts +6 -1
  267. package/dist/web-login.js +8 -3
  268. package/dist/web-login.js.map +1 -1
  269. package/dist/web-office-acts.d.ts +16 -0
  270. package/dist/web-office-acts.js +27 -9
  271. package/dist/web-office-acts.js.map +1 -1
  272. package/dist/web-office-pack-read.js +1 -1
  273. package/dist/web-office-pack-read.js.map +1 -1
  274. package/dist/web-office-skins.d.ts +5 -3
  275. package/dist/web-office-skins.js +20 -16
  276. package/dist/web-office-skins.js.map +1 -1
  277. package/dist/web-session-authorization.d.ts +3 -0
  278. package/dist/web-session-authorization.js +1 -1
  279. package/dist/web-session-authorization.js.map +1 -1
  280. package/dist/web-settings-patch.d.ts +27 -0
  281. package/dist/web-settings-patch.js +67 -0
  282. package/dist/web-settings-patch.js.map +1 -1
  283. package/dist/workflow-templates/default.md +1 -0
  284. package/package.json +1 -1
@@ -0,0 +1,130 @@
1
+ // A pack's vehicles (fleet-office-pack.js `vehicles`): a train round a loop of track. Where one is is a function of the
2
+ // wall clock alone, so every page shows it in the same place: it runs round its path at its speed and waits at each
3
+ // stop. People ride by their own choice (an agent's office_set `ride`): they walk to the platform, wait for the train
4
+ // to stop there, board, and ride in a seat (working there, moving with it); they get off only when it stops at a
5
+ // platform, then walk on. Pure — fleet-office.js draws the vehicles and moves the riders (the walkers' `ride`).
6
+
7
+ const LEGS = new WeakMap();
8
+ /** A vehicle's timetable: each leg (a path segment, then its stop's wait), in ms, and the whole lap. */
9
+ function legsOf(v) {
10
+ let t = LEGS.get(v);
11
+ if (t) return t;
12
+ const n = v.path.length, wait = new Map(v.stops.map((s, i) => [s.at, i])), legs = [];
13
+ let at = 0;
14
+ for (let i = 0; i < n; i++) {
15
+ const a = v.path[i], b = v.path[(i + 1) % n], len = Math.hypot(b.x - a.x, b.y - a.y), ms = (len / v.speed) * 1000;
16
+ if (ms > 0) { legs.push({ kind: "run", a, b, from: at, ms }); at += ms; }
17
+ const k = (i + 1) % n;
18
+ if (wait.has(k)) { const si = wait.get(k), s = v.stops[si]; legs.push({ kind: "stop", at: v.path[k], stop: si, from: at, ms: s.seconds * 1000, h: unit(a, b) }); at += s.seconds * 1000; }
19
+ }
20
+ t = { legs, lap: at };
21
+ LEGS.set(v, t);
22
+ return t;
23
+ }
24
+ const unit = (a, b) => { const d = Math.hypot(b.x - a.x, b.y - a.y); return d > 0 ? { x: (b.x - a.x) / d, y: (b.y - a.y) / d } : { x: 1, y: 0 }; };
25
+
26
+ /**
27
+ * Where vehicle `v` is at wall-clock `ms`: { x, y, heading: { x, y } (unit), stop: the stop index it waits at or null,
28
+ * left: ms until it leaves (at a stop) }.
29
+ */
30
+ export function vehicleAt(v, ms) {
31
+ const { legs, lap } = legsOf(v);
32
+ if (!(lap > 0)) return { x: v.path[0].x, y: v.path[0].y, heading: { x: 1, y: 0 }, stop: null, left: 0 };
33
+ const t = ((ms % lap) + lap) % lap;
34
+ for (const g of legs) {
35
+ if (t >= g.from + g.ms) continue;
36
+ const f = (t - g.from) / g.ms;
37
+ if (g.kind === "stop") return { x: g.at.x, y: g.at.y, heading: g.h, stop: g.stop, left: g.ms - (t - g.from) };
38
+ return { x: g.a.x + (g.b.x - g.a.x) * f, y: g.a.y + (g.b.y - g.a.y) * f, heading: unit(g.a, g.b), stop: null, left: 0 };
39
+ }
40
+ const last = legs[legs.length - 1];
41
+ return last.kind === "stop" ? { x: last.at.x, y: last.at.y, heading: last.h, stop: last.stop, left: 0 } : { x: last.b.x, y: last.b.y, heading: unit(last.a, last.b), stop: null, left: 0 };
42
+ }
43
+
44
+ /** Which way a vehicle faces, for its picture: the heading's main axis. */
45
+ export const facing = (h) => (Math.abs(h.x) >= Math.abs(h.y) ? (h.x < 0 ? "left" : "right") : (h.y < 0 ? "up" : "down"));
46
+
47
+ /**
48
+ * Seat `i` of vehicle `v` where it is (`at`, vehicleAt's), its offset (`dx` along the car, `dy` across it, as drawn
49
+ * heading right) placed for the way the car faces: right (dx, dy); left (−dx, dy) — the same deck, mirrored, as the
50
+ * picture is; down (−dy, dx); up (dy, −dx) — the car turned a quarter.
51
+ */
52
+ export function seatAt(v, at, i) {
53
+ const s = v.seats[i] || { dx: 0, dy: 0 }, f = facing(at.heading);
54
+ const [ox, oy] = f === "right" ? [s.dx, s.dy] : f === "left" ? [-s.dx, s.dy] : f === "down" ? [-s.dy, s.dx] : [s.dy, -s.dx];
55
+ return { x: Math.round(at.x + ox), y: Math.round(at.y + oy) };
56
+ }
57
+
58
+ /** How close (logical units) to the platform someone must stand to board, and the least wait left to step on. */
59
+ export const RIDE = { NEAR: 8, BOARD_MS: 400, SETTLE_MS: 60000 };
60
+ /** One lap of vehicle `v`, running and waiting (ms). */
61
+ export const lapMs = (v) => legsOf(v).lap;
62
+
63
+ /**
64
+ * Who is riding, waiting or on their way (one page's own; every page works it out alike from the same clock and acts).
65
+ * step({ wants, vehicles, wall, posOf, homeOf }) once a tick:
66
+ * - `wants`: name → the vehicle id they want to ride, or null (`null` for everyone else in the office);
67
+ * - `vehicles`: id → vehicle; `wall`: the wall clock; `posOf(name)`: where they are ({ x, y, walking }) or null;
68
+ * `homeOf(name)`: their seat (to pick the nearest platform); `sinceOf(name)`: when their ride began (wall clock), so
69
+ * a page opened long after shows them on board, not walking to a train they took long ago; `urgent(name)`: they
70
+ * must get off now (a call: #4415, nothing keeps a caller from the Help desk), where their seat is, between stops too.
71
+ * Returns { targets: name → where to walk now (the platform), board: [{ name, vehicle, seat }], alight: [{ name, at }] };
72
+ * `riding(name)` → { vehicle, seat } while on board; `clear()` forgets everyone and returns who was on board.
73
+ */
74
+ export function createRiders() {
75
+ const by = new Map();
76
+ const near = (a, b) => !!a && !!b && Math.hypot(a.x - b.x, a.y - b.y) <= RIDE.NEAR;
77
+ return {
78
+ step({ wants, vehicles, wall, posOf, homeOf, sinceOf = null, urgent = null }) {
79
+ const targets = new Map(), board = [], alight = [];
80
+ for (const name of [...by.keys()]) if (!wants.has(name)) by.delete(name); // gone from the office
81
+ const used = (vid) => new Set([...by.values()].filter((r) => r.phase === "riding" && r.vehicle === vid).map((r) => r.seat));
82
+ for (const [name, vid] of wants) {
83
+ let r = by.get(name);
84
+ const v = vid ? vehicles.get(vid) : null;
85
+ if (r && r.phase === "riding") {
86
+ const rv = vehicles.get(r.vehicle);
87
+ if (!rv) { // its vehicle is gone: off where they are
88
+ const p = posOf(name);
89
+ if (p) alight.push({ name, at: { x: p.x, y: p.y } });
90
+ by.delete(name); continue;
91
+ }
92
+ const at = vehicleAt(rv, wall);
93
+ if (urgent && urgent(name)) { alight.push({ name, at: seatAt(rv, at, r.seat) }); by.delete(name); continue; }
94
+ if (v && vid === r.vehicle) continue; // riding on
95
+ if (at.stop !== null) { alight.push({ name, at: rv.stops[at.stop].platform }); by.delete(name); }
96
+ continue; // off only at a stop
97
+ }
98
+ if (!v || !v.seats.length || !v.stops.length) { if (r) by.delete(name); continue; }
99
+ // A page opened long after the ride began (more than a lap and the walk ago, `since`): they are on board already.
100
+ const since = sinceOf ? sinceOf(name) : null;
101
+ if (!r && since !== null && wall - since > lapMs(v) + RIDE.SETTLE_MS) {
102
+ const taken = used(vid), seat = v.seats.findIndex((_, i) => !taken.has(i));
103
+ if (seat >= 0) { by.set(name, { phase: "riding", vehicle: vid, seat }); board.push({ name, vehicle: vid, seat }); continue; }
104
+ }
105
+ if (!r || r.vehicle !== vid) {
106
+ const home = homeOf(name) || posOf(name) || v.stops[0].platform;
107
+ let best = 0;
108
+ v.stops.forEach((s, i) => { if (Math.hypot(s.platform.x - home.x, s.platform.y - home.y) < Math.hypot(v.stops[best].platform.x - home.x, v.stops[best].platform.y - home.y)) best = i; });
109
+ r = { phase: "going", vehicle: vid, stop: best };
110
+ by.set(name, r);
111
+ }
112
+ const platform = v.stops[r.stop].platform, here = posOf(name);
113
+ targets.set(name, platform);
114
+ if (r.phase === "going" && here && !here.walking && near(here, platform)) r.phase = "waiting";
115
+ if (r.phase !== "waiting") continue;
116
+ const at = vehicleAt(v, wall);
117
+ if (at.stop !== r.stop || at.left < RIDE.BOARD_MS) continue; // the train is not in (or is leaving)
118
+ const taken = used(vid), seat = v.seats.findIndex((_, i) => !taken.has(i));
119
+ if (seat < 0) continue; // full: wait for the next one
120
+ r.phase = "riding"; r.seat = seat;
121
+ targets.delete(name);
122
+ board.push({ name, vehicle: vid, seat });
123
+ }
124
+ return { targets, board, alight };
125
+ },
126
+ riding(name) { const r = by.get(name); return r && r.phase === "riding" ? { vehicle: r.vehicle, seat: r.seat } : null; },
127
+ phase(name) { const r = by.get(name); return r ? r.phase : null; },
128
+ clear() { const on = [...by].filter(([, r]) => r.phase === "riding").map(([n]) => n); by.clear(); return on; },
129
+ };
130
+ }
@@ -531,6 +531,7 @@ export function createMail({ max = MAIL.MAX } = {}) {
531
531
  export function createWalkers() {
532
532
  const by = new Map();
533
533
  const posAt = (w, now) => {
534
+ if (w.ride) { const p = w.ride(now); return { x: p.x, y: p.y, walking: false, riding: true }; } // on board: where their seat is
534
535
  if (!w.pts) return { x: w.to.x, y: w.to.y, walking: false };
535
536
  const t = (now - w.start) / w.ms;
536
537
  if (t >= 1) return { x: w.to.x, y: w.to.y, walking: false };
@@ -542,7 +543,8 @@ export function createWalkers() {
542
543
  for (const name of [...by.keys()]) if (!targets.has(name)) by.delete(name);
543
544
  for (const [name, to] of targets) {
544
545
  const w = by.get(name);
545
- if (fresh) { by.set(name, { pts: null, to }); continue; }
546
+ if (fresh) { by.set(name, { pts: null, to }); continue; } // a rider too: a new office or style has no such vehicle
547
+ if (w && w.ride) continue; // a rider goes where the vehicle goes (place() gets them off)
546
548
  if (!w || still) { if (!w || w.to.x !== to.x || w.to.y !== to.y) by.set(name, { pts: null, to }); continue; }
547
549
  if (w.to.x === to.x && w.to.y === to.y) continue;
548
550
  const here = posAt(w, now), via = routeVia(graph, { x: here.x, y: here.y }, { x: to.x, y: to.y });
@@ -555,6 +557,8 @@ export function createWalkers() {
555
557
  /** M-3293: `name` set down at `at` (picked up and carried, or just dropped): standing there, no walk; the next sync
556
558
  * walks them from there to their target along the graph, as any walk. */
557
559
  place(name, at) { by.set(name, { pts: null, to: { x: at.x, y: at.y } }); },
560
+ /** On board a vehicle: `seat(now)` is where they are (fleet-office-vehicles.js seatAt); place() gets them off. */
561
+ ride(name, seat) { by.set(name, { ride: seat }); },
558
562
  moving(now) { for (const w of by.values()) if (posAt(w, now).walking) return true; return false; },
559
563
  };
560
564
  }
@@ -610,22 +614,35 @@ export function bubbleAt(name, state, ms, lines) {
610
614
  * another bubble (no two bubbles overlap) — so a name alone never keeps a call out (on Cozy a stuck agent stands right
611
615
  * under "Help desk", and its "Hmm, stuck?" went missing in beta.20).
612
616
  */
613
- export function placeBubbles(items, lift = 22, blocked = [], soft = []) {
617
+ /** M-3722: the space (logical px) a bubble's box keeps off an area's name (placeBubbles' `air`). */
618
+ export const NAME_AIR = 3;
619
+ export function placeBubbles(items, lift = 22, blocked = [], soft = [], air = 0) {
620
+ if (air) soft = soft.map((b) => ({ x: b.x - air, y: b.y - air, w: b.w + 2 * air, h: b.h + 2 * air }));
614
621
  const rank = (it) => (it.rank ?? (it.calling ? 0 : 2));
615
622
  const order = [...items].sort((a, b) => (rank(a) - rank(b)) || (b.shown - a.shown) || (a.key < b.key ? -1 : a.key > b.key ? 1 : 0));
616
623
  const taken = [...blocked], out = [];
617
624
  const hit = (list, r) => list.some((t) => r.x < t.x + t.w && t.x < r.x + r.w && r.y < t.y + t.h && t.y < r.y + r.h);
618
- const at = (it, dy) => {
619
- const r = { x: it.box.x, y: it.box.y + dy, w: it.box.w, h: it.box.h };
625
+ // M-3722: `flipBox` (the box on the tail's left) is a call's other side: tried before a call covers an area's name.
626
+ const at = (it, dy, flip = false) => {
627
+ const box = flip && it.flipBox ? it.flipBox : it.box;
628
+ const r = { x: box.x, y: box.y + dy, w: box.w, h: box.h };
620
629
  return { r, t: it.tail ? { x: it.tail.x - 1, y: r.y + r.h, w: 9, h: Math.max(0, it.tail.y - (r.y + r.h)) } : null };
621
630
  };
622
- const first = (it, dys, lists) => dys.find((dy) => { const { r, t } = at(it, dy); return !lists.some((l) => hit(l, r) || (t && hit(l, t))); });
631
+ // M-3722: an area's name (`soft`) keeps a bubble's BOX off it; a tail may cross a name (the Office writes the name again
632
+ // over it) — a caller standing at a name's height would otherwise always cover it.
633
+ const free = (it, [dy, flip], names) => { const { r, t } = at(it, dy, flip); return !hit(taken, r) && !(t && hit(taken, t)) && !(names && hit(soft, r)); };
634
+ const first = (it, spots, names) => spots.find((spot) => free(it, spot, names));
635
+ const sides = (dys) => dys.map((dy) => [dy, false]);
623
636
  for (const it of order) {
624
- let dy = first(it, [0, -lift], [taken, soft]);
625
- if (dy === undefined && it.calling) dy = first(it, [-2 * lift], [taken, soft]) ?? first(it, [0, -lift, -2 * lift], [taken]);
626
- if (dy === undefined) continue;
627
- const { r, t } = at(it, dy);
628
- taken.push(r); if (t) taken.push(t); out.push({ ...it, dy });
637
+ let spot = first(it, sides([0, -lift]), true);
638
+ if (spot === undefined && it.calling) {
639
+ spot = (it.flipBox ? first(it, [[0, true], [-lift, true]], true) : undefined)
640
+ ?? first(it, [[-2 * lift, false], ...(it.flipBox ? [[-2 * lift, true]] : [])], true)
641
+ ?? first(it, sides([0, -lift, -2 * lift]), false); // M-3648: a name never keeps a call out
642
+ }
643
+ if (spot === undefined) continue;
644
+ const [dy, flip] = spot, { r, t } = at(it, dy, flip);
645
+ taken.push(r); if (t) taken.push(t); out.push({ ...it, dy, ...(flip ? { flip: true } : {}) });
629
646
  }
630
647
  return out;
631
648
  }